-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.ts
137 lines (126 loc) · 3.25 KB
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// Welcome to your schema
// Schema driven development is Keystone's modus operandi
//
// This file is where we define the lists, fields and hooks for our data.
// If you want to learn more about how lists are configured, please read
// - https://keystonejs.com/docs/config/lists
import { graphql, list } from '@keystone-6/core'
import { allowAll } from '@keystone-6/core/access'
import { geometry } from './src/geometry'
import { virtualProperties } from './src/virtualProperties'
import { queryableJson } from './src/queryableJson'
// see https://keystonejs.com/docs/fields/overview for the full list of fields
// this is a few common fields for an example
import {
text,
relationship,
password,
timestamp,
select,
json,
float,
virtual,
} from '@keystone-6/core/fields'
// the document field is a more complicated field, so it has it's own package
import { document } from '@keystone-6/fields-document'
// if you want to make your own fields, see https://keystonejs.com/docs/guides/custom-fields
// when using Typescript, you can refine your types to a stricter subset by importing
// the generated types from '.keystone/types'
import { type Lists } from '.keystone/types'
export const lists = {
//
// Using KeyValue_ model for property storage
//
KeyValue_MapLayer: list({
access: allowAll,
fields: {
name: text(),
description: json(),
featurePropertySchema: json(),
parentMapLayer: relationship({
ref: 'KeyValue_MapLayer',
many: false,
}),
features: relationship({
ref: 'KeyValue_MapFeature.mapLayer',
many: true,
}),
},
}),
KeyValue_MapFeature: list({
access: allowAll,
fields: {
mapLayer: relationship({
ref: 'KeyValue_MapLayer.features',
many: false,
}),
name: text(),
geometry: geometry(),
properties: virtualProperties({
propertiesListKey: 'KeyValue_MapFeatureProperty',
propertyOwnerReferencePropertyKey: 'mapFeature',
}),
},
}),
KeyValue_MapFeatureProperty: list({
access: allowAll,
fields: {
mapFeature: relationship({
ref: 'KeyValue_MapFeature',
many: false,
}),
key: text({
validation: {
isRequired: true,
},
}),
type: select({
options: [
{
label: 'Text',
value: 'text',
},
{
label: 'Number',
value: 'number',
},
],
}),
value_text: text(),
value_number: float(),
},
}),
//
// Using Json model for property storage
//
Json_MapLayer: list({
access: allowAll,
fields: {
name: text(),
description: json(),
featurePropertySchema: json(),
parentMapLayer: relationship({
ref: 'Json_MapLayer',
many: false,
}),
features: relationship({
ref: 'Json_MapFeature.mapLayer',
many: true,
}),
},
}),
Json_MapFeature: list({
access: allowAll,
fields: {
mapLayer: relationship({
ref: 'Json_MapLayer.features',
many: false,
}),
name: text({
isIndexed: true,
}),
geometry: geometry(),
properties: queryableJson({}),
},
}),
} satisfies Lists