Skip to content
This repository was archived by the owner on Dec 21, 2021. It is now read-only.

Commit b084961

Browse files
Tuomas Koponentimoxley
authored andcommitted
Remove FieldDetector class
1 parent c205059 commit b084961

File tree

3 files changed

+18
-38
lines changed

3 files changed

+18
-38
lines changed

src/stream/index.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getEndpointUrl, FieldDetector } from '../utils'
1+
import { getEndpointUrl } from '../utils'
22
import authFetch from '../rest/authFetch'
33

44
import StorageNode from './StorageNode'
@@ -136,8 +136,22 @@ export default class Stream {
136136

137137
if (receivedMsgs.length > 0) {
138138
const lastMessage = receivedMsgs[0]
139-
const fd = new FieldDetector(lastMessage)
140-
const fields = fd.detect()
139+
const fields = []
140+
141+
Object.keys(lastMessage).forEach((key) => {
142+
let type
143+
if (Array.isArray(lastMessage[key])) {
144+
type = 'list'
145+
} else if ((typeof lastMessage[key]) === 'object') {
146+
type = 'map'
147+
} else {
148+
type = typeof lastMessage[key]
149+
}
150+
fields.push({
151+
name: key,
152+
type,
153+
})
154+
})
141155

142156
// Save field config back to the stream
143157
this.config.fields = fields

src/utils/FieldDetector.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/utils/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import pkg from '../../package.json'
1111

1212
import AggregatedError from './AggregatedError'
1313
import Scaffold from './Scaffold'
14-
import FieldDetector from './FieldDetector'
1514

16-
export { AggregatedError, Scaffold, FieldDetector }
15+
export { AggregatedError, Scaffold }
1716

1817
const UUID = uuidv4()
1918

0 commit comments

Comments
 (0)