@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,465 @@
1
+ import { z } from 'zod';
2
+ import { PluginViewType, PluginCoordinationType, PluginFileType, PluginJointFileType } from '@vitessce/plugins';
3
+ /**
4
+ * Build a Zod schema for the latest Vitessce config,
5
+ * which is specific to any registered plugins.
6
+ * The builder pattern allows the returned
7
+ * Zod schema to be typed despite not knowing
8
+ * the plugin names or sub-schemas in advance.
9
+ * @param pluginFileTypes
10
+ * @param pluginJointFileTypes
11
+ * @param pluginCoordinationTypes
12
+ * @param pluginViewTypes
13
+ * @returns The Zod schema.
14
+ */
15
+ export declare function buildConfigSchema<T1 extends PluginFileType<any, any, z.ZodTypeAny>, T2 extends PluginJointFileType<z.ZodTypeAny>, T3 extends PluginCoordinationType<z.ZodTypeAny>>(pluginFileTypes: Array<T1>, pluginJointFileTypes: Array<T2>, pluginCoordinationTypes: Array<T3>, pluginViewTypes: Array<PluginViewType>): z.ZodObject<{
16
+ version: z.ZodLiteral<string>;
17
+ uid: z.ZodOptional<z.ZodString>;
18
+ name: z.ZodString;
19
+ public: z.ZodOptional<z.ZodBoolean>;
20
+ description: z.ZodOptional<z.ZodString>;
21
+ datasets: z.ZodArray<z.ZodObject<{
22
+ uid: z.ZodString;
23
+ name: z.ZodOptional<z.ZodString>;
24
+ description: z.ZodOptional<z.ZodString>;
25
+ files: z.ZodArray<z.ZodNull | z.ZodObject<{
26
+ fileType: z.ZodLiteral<string>;
27
+ options: z.ZodOptional<z.ZodTypeAny>;
28
+ url: z.ZodOptional<z.ZodString>;
29
+ requestInit: z.ZodOptional<z.ZodObject<{
30
+ method: z.ZodOptional<z.ZodString>;
31
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
32
+ body: z.ZodOptional<z.ZodString>;
33
+ mode: z.ZodOptional<z.ZodString>;
34
+ credentials: z.ZodOptional<z.ZodString>;
35
+ cache: z.ZodOptional<z.ZodString>;
36
+ redirect: z.ZodOptional<z.ZodString>;
37
+ referrer: z.ZodOptional<z.ZodString>;
38
+ integrity: z.ZodOptional<z.ZodString>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ method?: string | undefined;
41
+ headers?: Record<string, any> | undefined;
42
+ body?: string | undefined;
43
+ mode?: string | undefined;
44
+ credentials?: string | undefined;
45
+ cache?: string | undefined;
46
+ redirect?: string | undefined;
47
+ referrer?: string | undefined;
48
+ integrity?: string | undefined;
49
+ }, {
50
+ method?: string | undefined;
51
+ headers?: Record<string, any> | undefined;
52
+ body?: string | undefined;
53
+ mode?: string | undefined;
54
+ credentials?: string | undefined;
55
+ cache?: string | undefined;
56
+ redirect?: string | undefined;
57
+ referrer?: string | undefined;
58
+ integrity?: string | undefined;
59
+ }>>;
60
+ coordinationValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
61
+ }, "strip", z.ZodTypeAny, {
62
+ fileType: string;
63
+ options?: any;
64
+ url?: string | undefined;
65
+ requestInit?: {
66
+ method?: string | undefined;
67
+ headers?: Record<string, any> | undefined;
68
+ body?: string | undefined;
69
+ mode?: string | undefined;
70
+ credentials?: string | undefined;
71
+ cache?: string | undefined;
72
+ redirect?: string | undefined;
73
+ referrer?: string | undefined;
74
+ integrity?: string | undefined;
75
+ } | undefined;
76
+ coordinationValues?: Record<string, string> | undefined;
77
+ }, {
78
+ fileType: string;
79
+ options?: any;
80
+ url?: string | undefined;
81
+ requestInit?: {
82
+ method?: string | undefined;
83
+ headers?: Record<string, any> | undefined;
84
+ body?: string | undefined;
85
+ mode?: string | undefined;
86
+ credentials?: string | undefined;
87
+ cache?: string | undefined;
88
+ redirect?: string | undefined;
89
+ referrer?: string | undefined;
90
+ integrity?: string | undefined;
91
+ } | undefined;
92
+ coordinationValues?: Record<string, string> | undefined;
93
+ }> | z.ZodDiscriminatedUnion<"fileType", [z.ZodObject<{
94
+ fileType: z.ZodLiteral<string>;
95
+ options: z.ZodOptional<z.ZodTypeAny>;
96
+ url: z.ZodOptional<z.ZodString>;
97
+ requestInit: z.ZodOptional<z.ZodObject<{
98
+ method: z.ZodOptional<z.ZodString>;
99
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
100
+ body: z.ZodOptional<z.ZodString>;
101
+ mode: z.ZodOptional<z.ZodString>;
102
+ credentials: z.ZodOptional<z.ZodString>;
103
+ cache: z.ZodOptional<z.ZodString>;
104
+ redirect: z.ZodOptional<z.ZodString>;
105
+ referrer: z.ZodOptional<z.ZodString>;
106
+ integrity: z.ZodOptional<z.ZodString>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ method?: string | undefined;
109
+ headers?: Record<string, any> | undefined;
110
+ body?: string | undefined;
111
+ mode?: string | undefined;
112
+ credentials?: string | undefined;
113
+ cache?: string | undefined;
114
+ redirect?: string | undefined;
115
+ referrer?: string | undefined;
116
+ integrity?: string | undefined;
117
+ }, {
118
+ method?: string | undefined;
119
+ headers?: Record<string, any> | undefined;
120
+ body?: string | undefined;
121
+ mode?: string | undefined;
122
+ credentials?: string | undefined;
123
+ cache?: string | undefined;
124
+ redirect?: string | undefined;
125
+ referrer?: string | undefined;
126
+ integrity?: string | undefined;
127
+ }>>;
128
+ coordinationValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
129
+ }, "strip", z.ZodTypeAny, {
130
+ fileType: string;
131
+ options?: any;
132
+ url?: string | undefined;
133
+ requestInit?: {
134
+ method?: string | undefined;
135
+ headers?: Record<string, any> | undefined;
136
+ body?: string | undefined;
137
+ mode?: string | undefined;
138
+ credentials?: string | undefined;
139
+ cache?: string | undefined;
140
+ redirect?: string | undefined;
141
+ referrer?: string | undefined;
142
+ integrity?: string | undefined;
143
+ } | undefined;
144
+ coordinationValues?: Record<string, string> | undefined;
145
+ }, {
146
+ fileType: string;
147
+ options?: any;
148
+ url?: string | undefined;
149
+ requestInit?: {
150
+ method?: string | undefined;
151
+ headers?: Record<string, any> | undefined;
152
+ body?: string | undefined;
153
+ mode?: string | undefined;
154
+ credentials?: string | undefined;
155
+ cache?: string | undefined;
156
+ redirect?: string | undefined;
157
+ referrer?: string | undefined;
158
+ integrity?: string | undefined;
159
+ } | undefined;
160
+ coordinationValues?: Record<string, string> | undefined;
161
+ }>, z.ZodObject<{
162
+ fileType: z.ZodLiteral<string>;
163
+ options: z.ZodOptional<z.ZodTypeAny>;
164
+ url: z.ZodOptional<z.ZodString>;
165
+ requestInit: z.ZodOptional<z.ZodObject<{
166
+ method: z.ZodOptional<z.ZodString>;
167
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
168
+ body: z.ZodOptional<z.ZodString>;
169
+ mode: z.ZodOptional<z.ZodString>;
170
+ credentials: z.ZodOptional<z.ZodString>;
171
+ cache: z.ZodOptional<z.ZodString>;
172
+ redirect: z.ZodOptional<z.ZodString>;
173
+ referrer: z.ZodOptional<z.ZodString>;
174
+ integrity: z.ZodOptional<z.ZodString>;
175
+ }, "strip", z.ZodTypeAny, {
176
+ method?: string | undefined;
177
+ headers?: Record<string, any> | undefined;
178
+ body?: string | undefined;
179
+ mode?: string | undefined;
180
+ credentials?: string | undefined;
181
+ cache?: string | undefined;
182
+ redirect?: string | undefined;
183
+ referrer?: string | undefined;
184
+ integrity?: string | undefined;
185
+ }, {
186
+ method?: string | undefined;
187
+ headers?: Record<string, any> | undefined;
188
+ body?: string | undefined;
189
+ mode?: string | undefined;
190
+ credentials?: string | undefined;
191
+ cache?: string | undefined;
192
+ redirect?: string | undefined;
193
+ referrer?: string | undefined;
194
+ integrity?: string | undefined;
195
+ }>>;
196
+ coordinationValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
197
+ }, "strip", z.ZodTypeAny, {
198
+ fileType: string;
199
+ options?: any;
200
+ url?: string | undefined;
201
+ requestInit?: {
202
+ method?: string | undefined;
203
+ headers?: Record<string, any> | undefined;
204
+ body?: string | undefined;
205
+ mode?: string | undefined;
206
+ credentials?: string | undefined;
207
+ cache?: string | undefined;
208
+ redirect?: string | undefined;
209
+ referrer?: string | undefined;
210
+ integrity?: string | undefined;
211
+ } | undefined;
212
+ coordinationValues?: Record<string, string> | undefined;
213
+ }, {
214
+ fileType: string;
215
+ options?: any;
216
+ url?: string | undefined;
217
+ requestInit?: {
218
+ method?: string | undefined;
219
+ headers?: Record<string, any> | undefined;
220
+ body?: string | undefined;
221
+ mode?: string | undefined;
222
+ credentials?: string | undefined;
223
+ cache?: string | undefined;
224
+ redirect?: string | undefined;
225
+ referrer?: string | undefined;
226
+ integrity?: string | undefined;
227
+ } | undefined;
228
+ coordinationValues?: Record<string, string> | undefined;
229
+ }>, ...z.ZodObject<{
230
+ fileType: z.ZodLiteral<string>;
231
+ options: z.ZodOptional<z.ZodTypeAny>;
232
+ url: z.ZodOptional<z.ZodString>;
233
+ requestInit: z.ZodOptional<z.ZodObject<{
234
+ method: z.ZodOptional<z.ZodString>;
235
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
236
+ body: z.ZodOptional<z.ZodString>;
237
+ mode: z.ZodOptional<z.ZodString>;
238
+ credentials: z.ZodOptional<z.ZodString>;
239
+ cache: z.ZodOptional<z.ZodString>;
240
+ redirect: z.ZodOptional<z.ZodString>;
241
+ referrer: z.ZodOptional<z.ZodString>;
242
+ integrity: z.ZodOptional<z.ZodString>;
243
+ }, "strip", z.ZodTypeAny, {
244
+ method?: string | undefined;
245
+ headers?: Record<string, any> | undefined;
246
+ body?: string | undefined;
247
+ mode?: string | undefined;
248
+ credentials?: string | undefined;
249
+ cache?: string | undefined;
250
+ redirect?: string | undefined;
251
+ referrer?: string | undefined;
252
+ integrity?: string | undefined;
253
+ }, {
254
+ method?: string | undefined;
255
+ headers?: Record<string, any> | undefined;
256
+ body?: string | undefined;
257
+ mode?: string | undefined;
258
+ credentials?: string | undefined;
259
+ cache?: string | undefined;
260
+ redirect?: string | undefined;
261
+ referrer?: string | undefined;
262
+ integrity?: string | undefined;
263
+ }>>;
264
+ coordinationValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
265
+ }, "strip", z.ZodTypeAny, {
266
+ fileType: string;
267
+ options?: any;
268
+ url?: string | undefined;
269
+ requestInit?: {
270
+ method?: string | undefined;
271
+ headers?: Record<string, any> | undefined;
272
+ body?: string | undefined;
273
+ mode?: string | undefined;
274
+ credentials?: string | undefined;
275
+ cache?: string | undefined;
276
+ redirect?: string | undefined;
277
+ referrer?: string | undefined;
278
+ integrity?: string | undefined;
279
+ } | undefined;
280
+ coordinationValues?: Record<string, string> | undefined;
281
+ }, {
282
+ fileType: string;
283
+ options?: any;
284
+ url?: string | undefined;
285
+ requestInit?: {
286
+ method?: string | undefined;
287
+ headers?: Record<string, any> | undefined;
288
+ body?: string | undefined;
289
+ mode?: string | undefined;
290
+ credentials?: string | undefined;
291
+ cache?: string | undefined;
292
+ redirect?: string | undefined;
293
+ referrer?: string | undefined;
294
+ integrity?: string | undefined;
295
+ } | undefined;
296
+ coordinationValues?: Record<string, string> | undefined;
297
+ }>[]]>, "many">;
298
+ }, "strip", z.ZodTypeAny, {
299
+ uid: string;
300
+ files: ({
301
+ fileType: string;
302
+ options?: any;
303
+ url?: string | undefined;
304
+ requestInit?: {
305
+ method?: string | undefined;
306
+ headers?: Record<string, any> | undefined;
307
+ body?: string | undefined;
308
+ mode?: string | undefined;
309
+ credentials?: string | undefined;
310
+ cache?: string | undefined;
311
+ redirect?: string | undefined;
312
+ referrer?: string | undefined;
313
+ integrity?: string | undefined;
314
+ } | undefined;
315
+ coordinationValues?: Record<string, string> | undefined;
316
+ } | null)[];
317
+ name?: string | undefined;
318
+ description?: string | undefined;
319
+ }, {
320
+ uid: string;
321
+ files: ({
322
+ fileType: string;
323
+ options?: any;
324
+ url?: string | undefined;
325
+ requestInit?: {
326
+ method?: string | undefined;
327
+ headers?: Record<string, any> | undefined;
328
+ body?: string | undefined;
329
+ mode?: string | undefined;
330
+ credentials?: string | undefined;
331
+ cache?: string | undefined;
332
+ redirect?: string | undefined;
333
+ referrer?: string | undefined;
334
+ integrity?: string | undefined;
335
+ } | undefined;
336
+ coordinationValues?: Record<string, string> | undefined;
337
+ } | null)[];
338
+ name?: string | undefined;
339
+ description?: string | undefined;
340
+ }>, "many">;
341
+ coordinationSpace: z.ZodOptional<z.ZodObject<any, "strict", z.ZodTypeAny, {
342
+ [x: string]: any;
343
+ }, {
344
+ [x: string]: any;
345
+ }>>;
346
+ layout: z.ZodArray<z.ZodObject<{
347
+ uid: z.ZodOptional<z.ZodString>;
348
+ component: z.ZodNull | z.ZodLiteral<string> | z.ZodEnum<[string, ...string[]]>;
349
+ props: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
350
+ x: z.ZodNumber;
351
+ y: z.ZodNumber;
352
+ w: z.ZodOptional<z.ZodNumber>;
353
+ h: z.ZodOptional<z.ZodNumber>;
354
+ coordinationScopes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>;
355
+ coordinationScopesBy: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>>>>;
356
+ }, "strip", z.ZodTypeAny, {
357
+ component: string | null;
358
+ x: number;
359
+ y: number;
360
+ uid?: string | undefined;
361
+ props?: Record<string, any> | undefined;
362
+ w?: number | undefined;
363
+ h?: number | undefined;
364
+ coordinationScopes?: Record<string, string | string[]> | undefined;
365
+ coordinationScopesBy?: Record<string, Record<string, Record<string, string | string[]>>> | undefined;
366
+ }, {
367
+ component: string | null;
368
+ x: number;
369
+ y: number;
370
+ uid?: string | undefined;
371
+ props?: Record<string, any> | undefined;
372
+ w?: number | undefined;
373
+ h?: number | undefined;
374
+ coordinationScopes?: Record<string, string | string[]> | undefined;
375
+ coordinationScopesBy?: Record<string, Record<string, Record<string, string | string[]>>> | undefined;
376
+ }>, "many">;
377
+ initStrategy: z.ZodEnum<["none", "auto"]>;
378
+ }, "strip", z.ZodTypeAny, {
379
+ name: string;
380
+ version: string;
381
+ datasets: {
382
+ uid: string;
383
+ files: ({
384
+ fileType: string;
385
+ options?: any;
386
+ url?: string | undefined;
387
+ requestInit?: {
388
+ method?: string | undefined;
389
+ headers?: Record<string, any> | undefined;
390
+ body?: string | undefined;
391
+ mode?: string | undefined;
392
+ credentials?: string | undefined;
393
+ cache?: string | undefined;
394
+ redirect?: string | undefined;
395
+ referrer?: string | undefined;
396
+ integrity?: string | undefined;
397
+ } | undefined;
398
+ coordinationValues?: Record<string, string> | undefined;
399
+ } | null)[];
400
+ name?: string | undefined;
401
+ description?: string | undefined;
402
+ }[];
403
+ layout: {
404
+ component: string | null;
405
+ x: number;
406
+ y: number;
407
+ uid?: string | undefined;
408
+ props?: Record<string, any> | undefined;
409
+ w?: number | undefined;
410
+ h?: number | undefined;
411
+ coordinationScopes?: Record<string, string | string[]> | undefined;
412
+ coordinationScopesBy?: Record<string, Record<string, Record<string, string | string[]>>> | undefined;
413
+ }[];
414
+ initStrategy: "none" | "auto";
415
+ uid?: string | undefined;
416
+ public?: boolean | undefined;
417
+ description?: string | undefined;
418
+ coordinationSpace?: {
419
+ [x: string]: any;
420
+ } | undefined;
421
+ }, {
422
+ name: string;
423
+ version: string;
424
+ datasets: {
425
+ uid: string;
426
+ files: ({
427
+ fileType: string;
428
+ options?: any;
429
+ url?: string | undefined;
430
+ requestInit?: {
431
+ method?: string | undefined;
432
+ headers?: Record<string, any> | undefined;
433
+ body?: string | undefined;
434
+ mode?: string | undefined;
435
+ credentials?: string | undefined;
436
+ cache?: string | undefined;
437
+ redirect?: string | undefined;
438
+ referrer?: string | undefined;
439
+ integrity?: string | undefined;
440
+ } | undefined;
441
+ coordinationValues?: Record<string, string> | undefined;
442
+ } | null)[];
443
+ name?: string | undefined;
444
+ description?: string | undefined;
445
+ }[];
446
+ layout: {
447
+ component: string | null;
448
+ x: number;
449
+ y: number;
450
+ uid?: string | undefined;
451
+ props?: Record<string, any> | undefined;
452
+ w?: number | undefined;
453
+ h?: number | undefined;
454
+ coordinationScopes?: Record<string, string | string[]> | undefined;
455
+ coordinationScopesBy?: Record<string, Record<string, Record<string, string | string[]>>> | undefined;
456
+ }[];
457
+ initStrategy: "none" | "auto";
458
+ uid?: string | undefined;
459
+ public?: boolean | undefined;
460
+ description?: string | undefined;
461
+ coordinationSpace?: {
462
+ [x: string]: any;
463
+ } | undefined;
464
+ }>;
465
+ //# sourceMappingURL=schema-builders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-builders.d.ts","sourceRoot":"","sources":["../src/schema-builders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,cAAc,EACd,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AAuE3B;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,EAAE,SAAS,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,UAAU,CAAC,EACjD,EAAE,SAAS,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,EAC5C,EAAE,SAAS,sBAAsB,CAAC,CAAC,CAAC,UAAU,CAAC,EAE/C,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,EAC1B,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,EAC/B,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC,EAClC,eAAe,EAAE,KAAK,CAAC,cAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFvC"}
@@ -0,0 +1,127 @@
1
+ import { z } from 'zod';
2
+ import { fromEntries } from '@vitessce/utils';
3
+ import { requestInit, coordinationScopeName, componentCoordinationScopes, componentCoordinationScopesBy, } from './shared.js';
4
+ import { latestConfigSchema } from './previous-config-meta.js';
5
+ import { configSchemaToVersion } from './view-config-versions.js';
6
+ /**
7
+ * Convert an array of strings into a Zod enum schema,
8
+ * bypassing the need for the input array to have
9
+ * at least two elements.
10
+ * @param schemaArr Array of strings.
11
+ * @returns Zod enum schema.
12
+ */
13
+ function toEnum(schemaArr) {
14
+ if (schemaArr.length === 0)
15
+ return z.null();
16
+ if (schemaArr.length === 1)
17
+ return z.literal(schemaArr[0]);
18
+ return z.enum([schemaArr[0], ...schemaArr.slice(1, schemaArr.length)]);
19
+ }
20
+ /**
21
+ * Build a Zod schema for a file definition.
22
+ * The builder pattern allows the returned
23
+ * Zod schema to be typed despite not knowing
24
+ * the file type name or options sub-schema in advance,
25
+ * which is the case for plugin file types in particular.
26
+ * @param fileType The file type name.
27
+ * @param options Zod schema for the file definition options.
28
+ * @returns Zod object schema for the file definition.
29
+ */
30
+ function buildFileDefSchema(fileType, options) {
31
+ return z.object({
32
+ fileType: z.literal(fileType),
33
+ options: options.optional(),
34
+ url: z.string()
35
+ .optional(),
36
+ requestInit: requestInit
37
+ .describe('The properties of this object correspond to the parameters of the JavaScript fetch() function.')
38
+ .optional(),
39
+ coordinationValues: z.record(z.string())
40
+ .describe('Keys are coordination types. Values are coordination values. Used for matching views to files.')
41
+ .optional(),
42
+ });
43
+ }
44
+ /**
45
+ * Convert an array of Zod schemas into a Zod union schema,
46
+ * bypassing the need for the input array to have
47
+ * at least two elements.
48
+ * @param schemaArr Array of Zod schemas.
49
+ * @returns Zod union schema.
50
+ */
51
+ function toFileDefUnion(schemaArr) {
52
+ if (schemaArr.length === 0)
53
+ return z.null();
54
+ if (schemaArr.length === 1)
55
+ return schemaArr[0];
56
+ return z.discriminatedUnion('fileType', [
57
+ schemaArr[0],
58
+ schemaArr[1],
59
+ ...schemaArr.slice(2, schemaArr.length),
60
+ ]);
61
+ }
62
+ /**
63
+ * Build a Zod schema for the latest Vitessce config,
64
+ * which is specific to any registered plugins.
65
+ * The builder pattern allows the returned
66
+ * Zod schema to be typed despite not knowing
67
+ * the plugin names or sub-schemas in advance.
68
+ * @param pluginFileTypes
69
+ * @param pluginJointFileTypes
70
+ * @param pluginCoordinationTypes
71
+ * @param pluginViewTypes
72
+ * @returns The Zod schema.
73
+ */
74
+ export function buildConfigSchema(pluginFileTypes, pluginJointFileTypes, pluginCoordinationTypes, pluginViewTypes) {
75
+ const fileTypeSchemas = [...pluginFileTypes, ...pluginJointFileTypes]
76
+ .map(ft => buildFileDefSchema(ft.name, ft.optionsSchema));
77
+ const fileDefs = toFileDefUnion(fileTypeSchemas);
78
+ // TODO: make this less redundant with latestSchema from ./previous-base-schemas
79
+ return z.object({
80
+ // eslint-disable-next-line no-underscore-dangle
81
+ version: z.literal(configSchemaToVersion(latestConfigSchema))
82
+ .describe('The schema version for the view config.'),
83
+ uid: z.string().optional(),
84
+ name: z.string(),
85
+ public: z.boolean().optional(),
86
+ description: z.string().optional(),
87
+ datasets: z.array(z.object({
88
+ uid: z.string(),
89
+ name: z.string().optional(),
90
+ description: z.string().optional(),
91
+ files: z.array(fileDefs),
92
+ }))
93
+ .describe('The datasets array defines groups of files, where the files within each dataset reference the same entities (cells, genes, cell sets, etc).'),
94
+ // Merge with coordination type schemas.
95
+ coordinationSpace: z.object(
96
+ // Wrap each value schema in z.record()
97
+ fromEntries(pluginCoordinationTypes
98
+ .map(ct => ([
99
+ ct.name,
100
+ z.record(coordinationScopeName, ct.valueSchema.optional()).optional(),
101
+ ]))))
102
+ .strict()
103
+ .describe('The coordination space stores the values for each scope of each coordination object.')
104
+ .optional(),
105
+ layout: z.array(z.object({
106
+ uid: z.string()
107
+ .describe('A unique identifier for the view, to refer to it in getter and setter functions in object-oriented contexts.')
108
+ .optional(),
109
+ component: toEnum(pluginViewTypes.map(vt => vt.name))
110
+ .describe('Specify a component using a name defined in the component registry.'),
111
+ props: z.record(z.any())
112
+ .describe('Extra prop values for the component.')
113
+ .optional(),
114
+ x: z.number().int(),
115
+ y: z.number().int(),
116
+ w: z.number().int().optional(),
117
+ h: z.number().int().optional(),
118
+ coordinationScopes: componentCoordinationScopes
119
+ .optional(),
120
+ coordinationScopesBy: componentCoordinationScopesBy
121
+ .optional(),
122
+ }))
123
+ .describe('The layout array defines the views, or components, rendered in the grid.'),
124
+ initStrategy: z.enum(['none', 'auto'])
125
+ .describe('The initialization strategy determines how missing coordination objects and coordination scope mappings are initially filled in.'),
126
+ });
127
+ }