@vitessce/schemas 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +19 -0
  3. package/dist/index.js +16360 -0
  4. package/dist-tsc/file-def-options-legacy.d.ts +72 -0
  5. package/dist-tsc/file-def-options-legacy.d.ts.map +1 -0
  6. package/dist-tsc/file-def-options-legacy.js +28 -0
  7. package/dist-tsc/file-def-options.d.ts +417 -0
  8. package/dist-tsc/file-def-options.d.ts.map +1 -0
  9. package/dist-tsc/file-def-options.js +139 -0
  10. package/dist-tsc/index.d.ts +11 -0
  11. package/dist-tsc/index.d.ts.map +1 -0
  12. package/dist-tsc/index.js +10 -0
  13. package/dist-tsc/previous-config-meta.d.ts +251 -0
  14. package/dist-tsc/previous-config-meta.d.ts.map +1 -0
  15. package/dist-tsc/previous-config-meta.js +22 -0
  16. package/dist-tsc/previous-config-schemas.d.ts +4053 -0
  17. package/dist-tsc/previous-config-schemas.d.ts.map +1 -0
  18. package/dist-tsc/previous-config-schemas.js +204 -0
  19. package/dist-tsc/previous-config-upgraders.d.ts +25 -0
  20. package/dist-tsc/previous-config-upgraders.d.ts.map +1 -0
  21. package/dist-tsc/previous-config-upgraders.js +589 -0
  22. package/dist-tsc/raster-json.d.ts +274 -0
  23. package/dist-tsc/raster-json.d.ts.map +1 -0
  24. package/dist-tsc/raster-json.js +36 -0
  25. package/dist-tsc/schema-builders.d.ts +465 -0
  26. package/dist-tsc/schema-builders.d.ts.map +1 -0
  27. package/dist-tsc/schema-builders.js +127 -0
  28. package/dist-tsc/shared.d.ts +145 -0
  29. package/dist-tsc/shared.d.ts.map +1 -0
  30. package/dist-tsc/shared.js +100 -0
  31. package/dist-tsc/spatial-layers.d.ts +112 -0
  32. package/dist-tsc/spatial-layers.d.ts.map +1 -0
  33. package/dist-tsc/spatial-layers.js +81 -0
  34. package/dist-tsc/view-config-utils.test.d.ts +2 -0
  35. package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
  36. package/dist-tsc/view-config-utils.test.fixtures.d.ts +495 -0
  37. package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
  38. package/dist-tsc/view-config-utils.test.fixtures.js +881 -0
  39. package/dist-tsc/view-config-utils.test.js +23 -0
  40. package/dist-tsc/view-config-versions.d.ts +6 -0
  41. package/dist-tsc/view-config-versions.d.ts.map +1 -0
  42. package/dist-tsc/view-config-versions.js +78 -0
  43. package/package.json +49 -0
  44. package/src/file-def-options-legacy.js +34 -0
  45. package/src/file-def-options.ts +158 -0
  46. package/src/index.ts +41 -0
  47. package/src/missing-types.d.ts +1 -0
  48. package/src/previous-config-meta.ts +85 -0
  49. package/src/previous-config-schemas.ts +259 -0
  50. package/src/previous-config-upgraders.ts +739 -0
  51. package/src/raster-json.ts +38 -0
  52. package/src/schema-builders.ts +179 -0
  53. package/src/shared.ts +158 -0
  54. package/src/spatial-layers.ts +103 -0
  55. package/src/view-config-utils.test.fixtures.ts +901 -0
  56. package/src/view-config-utils.test.ts +39 -0
  57. package/src/view-config-versions.ts +87 -0
@@ -0,0 +1,259 @@
1
+ /* eslint-disable camelcase */
2
+ import { z } from 'zod';
3
+ import {
4
+ coordinationScopeName,
5
+ requestInit,
6
+ componentCoordinationScopes,
7
+ componentCoordinationScopesBy,
8
+ } from './shared.js';
9
+
10
+ // Base schemas for previous config versions.
11
+ // These do not validate coordinationType, viewType, or fileType-related values;
12
+ // only the latest version validates these after merging with plugin schemas.
13
+
14
+ const nameSchema = z.string();
15
+ const publicFlagSchema = z.boolean().optional();
16
+ const descriptionSchema = z.string().optional();
17
+
18
+ export const configSchema0_1_0 = z.object({
19
+ version: z.literal('0.1.0'),
20
+ name: nameSchema,
21
+ public: publicFlagSchema,
22
+ description: descriptionSchema,
23
+ layers: z.array(
24
+ z.object({
25
+ name: z.string(),
26
+ type: z.string(),
27
+ fileType: z.string(),
28
+ url: z.string(),
29
+ }),
30
+ ),
31
+ staticLayout: z.array(
32
+ z.object({
33
+ component: z.string(),
34
+ props: z.record(z.any())
35
+ .optional(),
36
+ x: z.number().int(),
37
+ y: z.number().int(),
38
+ w: z.number().int().optional(),
39
+ h: z.number().int().optional(),
40
+ }),
41
+ ),
42
+ });
43
+
44
+ const fileOptionsSchema = z.any();
45
+
46
+ // Cannot keep extending, so using composition instead.
47
+ // const nextVersionSchema = prevVersionSchema.extend(...)
48
+ // causes Typescript error after ~15 times.
49
+ // Reference: https://github.com/colinhacks/zod/issues/1990
50
+ export const coordinationSpaceSchema = z.object({})
51
+ .catchall(z.record(coordinationScopeName, z.any()));
52
+
53
+ const initStrategySchema = z.enum(['none', 'auto']);
54
+
55
+ const layoutSchema1_0_0 = z.array(
56
+ z.object({
57
+ component: z.string(),
58
+ props: z.record(z.any())
59
+ .optional(),
60
+ x: z.number().int(),
61
+ y: z.number().int(),
62
+ w: z.number().int().optional(),
63
+ h: z.number().int().optional(),
64
+ coordinationScopes: z.record(z.string())
65
+ .optional(),
66
+ }),
67
+ );
68
+
69
+ const datasetsSchema1_0_0 = z.array(
70
+ z.object({
71
+ uid: z.string(),
72
+ name: z.string().optional(),
73
+ description: z.string().optional(),
74
+ files: z.array(
75
+ z.object({
76
+ name: z.string().optional(),
77
+ fileType: z.string(),
78
+ url: z.string().optional(),
79
+ options: fileOptionsSchema.optional(),
80
+ requestInit: requestInit.optional(),
81
+ }),
82
+ ),
83
+ }),
84
+ );
85
+
86
+ export const configSchema1_0_0 = z.object({
87
+ version: z.literal('1.0.0'),
88
+ name: nameSchema,
89
+ public: publicFlagSchema,
90
+ description: descriptionSchema,
91
+ datasets: datasetsSchema1_0_0,
92
+ coordinationSpace: coordinationSpaceSchema.optional(),
93
+ layout: layoutSchema1_0_0,
94
+ initStrategy: initStrategySchema,
95
+ });
96
+
97
+ // Only coordination type or behavioral changes.
98
+ export const configSchema1_0_1 = configSchema1_0_0.extend({
99
+ version: z.literal('1.0.1'),
100
+ });
101
+
102
+ // Only coordination type or behavioral changes.
103
+ export const configSchema1_0_2 = configSchema1_0_0.extend({
104
+ version: z.literal('1.0.2'),
105
+ });
106
+
107
+ // Only coordination type or behavioral changes.
108
+ export const configSchema1_0_3 = configSchema1_0_0.extend({
109
+ version: z.literal('1.0.3'),
110
+ });
111
+
112
+ // Only coordination type or behavioral changes.
113
+ export const configSchema1_0_4 = configSchema1_0_0.extend({
114
+ version: z.literal('1.0.4'),
115
+ });
116
+
117
+ // Only coordination type or behavioral changes.
118
+ export const configSchema1_0_5 = configSchema1_0_0.extend({
119
+ version: z.literal('1.0.5'),
120
+ });
121
+
122
+ // Only coordination type or behavioral changes.
123
+ export const configSchema1_0_6 = configSchema1_0_0.extend({
124
+ version: z.literal('1.0.6'),
125
+ });
126
+
127
+ // Only coordination type or behavioral changes.
128
+ export const configSchema1_0_7 = configSchema1_0_0.extend({
129
+ version: z.literal('1.0.7'),
130
+ });
131
+
132
+ // Allow implicit per-dataset coordination scope mappings,
133
+ // (initially for Polyphony use case).
134
+
135
+ const polyphonyStyleCoordinationScopes = z.record(z.union([
136
+ z.string(),
137
+ z.array(z.string()),
138
+ z.record(z.string()),
139
+ ]));
140
+
141
+ const layoutSchema1_0_8 = z.array(
142
+ z.object({
143
+ component: z.string(),
144
+ props: z.record(z.any())
145
+ .optional(),
146
+ x: z.number().int(),
147
+ y: z.number().int(),
148
+ w: z.number().int().optional(),
149
+ h: z.number().int().optional(),
150
+ // New: can be one of
151
+ // - coordinationType: string
152
+ // - dataset: string[]
153
+ // - coordinationType: { datasetA: string, datasetB: string }
154
+ coordinationScopes: polyphonyStyleCoordinationScopes
155
+ .optional(),
156
+ }),
157
+ );
158
+
159
+ export const configSchema1_0_8 = configSchema1_0_0.extend({
160
+ version: z.literal('1.0.8'),
161
+ layout: layoutSchema1_0_8,
162
+ });
163
+
164
+ // Only coordination type or behavioral changes.
165
+ export const configSchema1_0_9 = configSchema1_0_8.extend({
166
+ version: z.literal('1.0.9'),
167
+ });
168
+
169
+ // Allow for each view to have a uid
170
+ const layoutSchema1_0_10 = z.array(
171
+ z.object({
172
+ // New: uid property allowed.
173
+ uid: z.string()
174
+ .optional(),
175
+ component: z.string(),
176
+ props: z.record(z.any())
177
+ .optional(),
178
+ x: z.number().int(),
179
+ y: z.number().int(),
180
+ w: z.number().int().optional(),
181
+ h: z.number().int().optional(),
182
+ coordinationScopes: polyphonyStyleCoordinationScopes
183
+ .optional(),
184
+ }),
185
+ );
186
+
187
+ export const configSchema1_0_10 = configSchema1_0_8.extend({
188
+ version: z.literal('1.0.10'),
189
+ layout: layoutSchema1_0_10,
190
+ });
191
+
192
+ // Only coordination type or behavioral changes.
193
+ export const configSchema1_0_11 = configSchema1_0_10.extend({
194
+ version: z.literal('1.0.11'),
195
+ });
196
+
197
+ // Only coordination type or behavioral changes.
198
+ export const configSchema1_0_12 = configSchema1_0_10.extend({
199
+ version: z.literal('1.0.12'),
200
+ });
201
+
202
+ export const latestFileDefSchema = z.object({
203
+ name: z.string().optional(),
204
+ fileType: z.string(),
205
+ url: z.string().optional(),
206
+ options: fileOptionsSchema.optional(),
207
+ requestInit: requestInit.optional(),
208
+ // New: file def can have coordinationValues.
209
+ coordinationValues: z.record(z.string()).optional(),
210
+ });
211
+
212
+ // Allow file definitions to have coordinationValues.
213
+ const datasetsSchema1_0_13 = z.array(
214
+ z.object({
215
+ uid: z.string(),
216
+ name: z.string().optional(),
217
+ description: z.string().optional(),
218
+ files: z.array(
219
+ latestFileDefSchema,
220
+ ),
221
+ }),
222
+ );
223
+ export const configSchema1_0_13 = configSchema1_0_10.extend({
224
+ version: z.literal('1.0.13'),
225
+ datasets: datasetsSchema1_0_13,
226
+ });
227
+
228
+ // Only coordination type or behavioral changes.
229
+ export const configSchema1_0_14 = configSchema1_0_13.extend({
230
+ version: z.literal('1.0.14'),
231
+ });
232
+
233
+ // Only coordination type or behavioral changes.
234
+ export const configSchema1_0_15 = configSchema1_0_13.extend({
235
+ version: z.literal('1.0.15'),
236
+ });
237
+
238
+ export const configSchema1_0_16 = configSchema1_0_13.extend({
239
+ version: z.literal('1.0.16'),
240
+ uid: z.string().optional(),
241
+ layout: z.array(
242
+ z.object({
243
+ uid: z.string()
244
+ .optional(),
245
+ component: z.string(),
246
+ props: z.record(z.any())
247
+ .optional(),
248
+ x: z.number().int(),
249
+ y: z.number().int(),
250
+ w: z.number().int().optional(),
251
+ h: z.number().int().optional(),
252
+ // Updates coordinationScopes and coordinationScopesBy
253
+ coordinationScopes: componentCoordinationScopes
254
+ .optional(),
255
+ coordinationScopesBy: componentCoordinationScopesBy
256
+ .optional(),
257
+ }),
258
+ ),
259
+ });