mapeo-schema
Version:
JSON schema and flow types for Mapeo
230 lines (197 loc) • 4.8 kB
Flow
// @flow
import type { Field,Filter,Observation,Preset } from '../../'
// Export un-typed for checking against strict types
export const field_number = {
"id": "1",
"key": "foo",
"type": "number",
"label": "How many?"
}
// This is the type check
;({...field_number}: Field)
// Export un-typed for checking against strict types
export const field_select_multiple_labels = {
"id": "1",
"key": "foo",
"type": "select_one",
"label": "Select which one?",
"options": [
{
"value": "one",
"label": "Option One Label"
}, {
"value": "two",
"label": "Option Two Label"
}, {
"value": "three",
"label": "Option Three Label"
}
]
}
// This is the type check
;({...field_select_multiple_labels}: Field)
// Export un-typed for checking against strict types
export const field_select_multiple = {
"id": "1",
"key": "foo",
"type": "select_multiple",
"label": "Select which one?",
"options": [
"option_one",
"option_two",
"option_three"
]
}
// This is the type check
;({...field_select_multiple}: Field)
// Export un-typed for checking against strict types
export const field_select_one_labels = {
"id": "1",
"key": "foo",
"type": "select_one",
"label": "Select which one?",
"options": [
{
"value": "one",
"label": "Option One Label"
}, {
"value": "two",
"label": "Option Two Label"
}, {
"value": "three",
"label": "Option Three Label"
}
]
}
// This is the type check
;({...field_select_one_labels}: Field)
// Export un-typed for checking against strict types
export const field_select_one = {
"id": "1",
"key": "foo",
"type": "select_one",
"label": "Select which one?",
"options": [
"option_one",
"option_two",
"option_three"
]
}
// This is the type check
;({...field_select_one}: Field)
// Export un-typed for checking against strict types
export const field_text = {
"id": "1",
"key": "foo",
"type": "text",
"appearance": "singleline",
"label": "What is foo?"
}
// This is the type check
;({...field_text}: Field)
// Export un-typed for checking against strict types
export const filter = {
"id": "PqC1cBy7nAN8u2rGfI",
"version": "1c481ef0a313ffe1685fda5517b1a121e246c3deeb1af76f48dcf800d22c25b9",
"created_at": "2019-09-11T21:25:01.689Z",
"timestamp": "2019-09-12T19:27:39.983Z",
"type": "filter",
"schemaVersion": 1,
"filter": [
"all",
["in", "categoryId", "oil_spill", "mining", "logging"],
["==", "$type", "observation"]
],
"name": "Oil, mining and logging observations"
}
// This is the type check
;({...filter}: Filter)
// Export un-typed for checking against strict types
export const observation_full = {
"id": "79be849f934590ec",
"version": "4d822ba6f2e502a5a944f50476217fe90ed5927fe92e71e7d94b0849a65929f3",
"created_at": "2018-12-28T21:25:01.689Z",
"timestamp": "2019-01-13T19:27:39.983Z",
"userId": "dc3051daf7308322",
"type": "observation",
"links": [
"d319db9aabf823aefdcf1912540124f9465782db3d568006ea920d81fef5f82e"
],
"schemaVersion": 4,
"lon": -77.22702101848337,
"lat": 0.22186675006751497,
"metadata": {
"location": {
"precision": 10.234124,
"altitude": 123
},
"manualLocation": true
},
"refs": [
{
"id": "19a2a0bb4eae0664"
}
],
"tags": {
"notes": "After a long day at school and work, a pear is the monkey of a grapes;",
"categoryId": "flora/planta",
"nested_tag": {
"foo": "bar"
}
},
"attachments": [
{
"id": "475704826aff65305e26723396f3d526.jpg"
}
]
}
// This is the type check
;({...observation_full}: Observation)
// Export un-typed for checking against strict types
export const observation_minimal = {
"id": "79be849f934590ec",
"version": "4d822ba6f2e502a5a944f50476217fe90ed5927fe92e71e7d94b0849a65929f3",
"created_at": "2018-12-28T21:25:01.689Z",
"timestamp": "2019-01-13T19:27:39.983Z",
"type": "observation",
"schemaVersion": 4
}
// This is the type check
;({...observation_minimal}: Observation)
// Export un-typed for checking against strict types
export const preset_full = {
"id": "1",
"icon": "territory",
"fields": [
"actividad_de_vigilancia",
"privacidad"
],
"geometry": [
"point",
"line"
],
"tags": {
"boundary": "territory"
},
"terms": [
"frontera",
"limite",
"indigena",
"comunitario"
],
"name": "Limite Territorial",
"sort": 11
}
// This is the type check
;({...preset_full}: Preset)
// Export un-typed for checking against strict types
export const preset_minimal = {
"id": "1",
"geometry": [
"point"
],
"tags": {},
"name": "Limite Territorial"
}
// This is the type check
;({...preset_minimal}: Preset)