Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion gen-typebox.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ const TO_GEN = ['observation', 'track', 'preset', 'field']
// We extend the schema instead of assigning values to a clone
// because JSDoc has no clean way to mark nested trees as mutable

// These are not part of the scheme but are added by the DataType class
// to show who authored a particular change
const authorFields = {
createdBy: {
type: 'string',
},
updatedBy: {
type: 'string',
},
}

const observationSchema = extendProperties(originals.observation, {
...authorFields,
attachments: {
type: 'array',
items: {
Expand All @@ -28,17 +40,21 @@ const observationSchema = extendProperties(originals.observation, {
})

const presetSchema = extendProperties(originals.preset, {
...authorFields,
fieldRefs: addUrlFieldArray(originals.preset.properties.fieldRefs),
iconRef: addUrlField(originals.preset.properties.iconRef),
})

const trackSchema = extendProperties(originals.track, {
...authorFields,
observationRefs: addUrlFieldArray(originals.track.properties.observationRefs),
presetRef: addUrlField(originals.track.properties.presetRef),
})

const fieldSchema = extendProperties(originals.field, authorFields)

const schemas = {
...originals,
field: fieldSchema,
observation: observationSchema,
preset: presetSchema,
track: trackSchema,
Expand Down
Loading
Loading