@cloudcannon/configuration-types 0.0.44 → 0.0.46
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.
- package/dist/cloudcannon-collections.schema.json +838 -816
- package/dist/cloudcannon-config.documentation.schema.json +1157 -1661
- package/dist/cloudcannon-config.latest.schema.json +1165 -1644
- package/dist/cloudcannon-config.legacy-eleventy.schema.json +1166 -1645
- package/dist/cloudcannon-config.legacy-hugo.schema.json +1166 -1645
- package/dist/cloudcannon-config.legacy-jekyll.schema.json +1166 -1645
- package/dist/cloudcannon-config.legacy-reader.schema.json +1166 -1645
- package/dist/cloudcannon-editables.schema.json +151 -151
- package/dist/cloudcannon-inputs.schema.json +671 -663
- package/dist/cloudcannon-schemas.schema.json +820 -801
- package/dist/cloudcannon-snippets-imports.schema.json +12 -16
- package/dist/cloudcannon-snippets.schema.json +956 -1451
- package/dist/cloudcannon-structure-value.schema.json +671 -663
- package/dist/cloudcannon-structures.schema.json +671 -663
- package/dist/documentation.json +20400 -31108
- package/package.json +1 -1
- package/src/cascade.ts +6 -6
- package/src/collections.ts +6 -6
- package/src/documentation.ts +1 -1
- package/src/editables.ts +38 -34
- package/src/image-options.ts +9 -9
- package/src/inputs.ts +48 -45
- package/src/preview.ts +63 -28
- package/src/snippets.ts +69 -56
- package/src/structures.ts +9 -3
package/src/inputs.ts
CHANGED
|
@@ -58,12 +58,12 @@ const typeMeta = {
|
|
|
58
58
|
|
|
59
59
|
const RequiredValidationSchema = z.object({
|
|
60
60
|
required: z.boolean().default(false).optional().meta({
|
|
61
|
-
id: 'required',
|
|
61
|
+
id: 'type._inputs.*.options.required',
|
|
62
62
|
description:
|
|
63
63
|
'This key toggles whether CloudCannon requires this Input to have a value. If set to true, CloudCannon will require you to enter a value to save your changes, or discard your unsaved changes.',
|
|
64
64
|
}),
|
|
65
65
|
required_message: z.string().optional().meta({
|
|
66
|
-
id: 'required_message',
|
|
66
|
+
id: 'type._inputs.*.options.required_message',
|
|
67
67
|
description:
|
|
68
68
|
'This key defines the message that explains why an Input is required. This key requires you to define `options.required`.',
|
|
69
69
|
}),
|
|
@@ -71,32 +71,32 @@ const RequiredValidationSchema = z.object({
|
|
|
71
71
|
|
|
72
72
|
const TextValidationSchema = z.object({
|
|
73
73
|
max_length: z.number().optional().meta({
|
|
74
|
-
id: 'max_length',
|
|
74
|
+
id: 'type._inputs.*.options.max_length',
|
|
75
75
|
description:
|
|
76
76
|
'This key defines the maximum string length, in characters, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too long. If the Input already contains a longer value, CloudCannon will require you to remove characters until the Input contains a valid string to save your changes, or discard your unsaved changes.',
|
|
77
77
|
}),
|
|
78
78
|
max_length_message: z.string().optional().meta({
|
|
79
|
-
id: 'max_length_message',
|
|
79
|
+
id: 'type._inputs.*.options.max_length_message',
|
|
80
80
|
description:
|
|
81
81
|
'This key defines the message that explains which maximum string length an Input will accept. This key requires you to define `options.max_length`.',
|
|
82
82
|
}),
|
|
83
83
|
min_length: z.number().optional().meta({
|
|
84
|
-
id: 'min_length',
|
|
84
|
+
id: 'type._inputs.*.options.min_length',
|
|
85
85
|
description:
|
|
86
86
|
'This key defines the minimum string length, in characters, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too short. If the Input already contains a shorter value, CloudCannon will require you to add characters until the Input contains a valid string to save your changes, or discard your unsaved changes.',
|
|
87
87
|
}),
|
|
88
88
|
min_length_message: z.string().optional().meta({
|
|
89
|
-
id: 'min_length_message',
|
|
89
|
+
id: 'type._inputs.*.options.min_length_message',
|
|
90
90
|
description:
|
|
91
91
|
'This key defines the message that explains which minimum string length an Input will accept. This key requires you to define `options.min_length`.',
|
|
92
92
|
}),
|
|
93
93
|
pattern: z.string().optional().meta({
|
|
94
|
-
id: 'pattern',
|
|
94
|
+
id: 'type._inputs.*.options.pattern',
|
|
95
95
|
description:
|
|
96
96
|
'This key defines a regular expression that the Input value must match. When configured, CloudCannon will require you to enter a value that matches the REGEX pattern. If the Input already contains an invalid value, CloudCannon will require you to enter a valid string to save your changes, or discard your unsaved changes.',
|
|
97
97
|
}),
|
|
98
98
|
pattern_message: z.string().optional().meta({
|
|
99
|
-
id: 'pattern_message',
|
|
99
|
+
id: 'type._inputs.*.options.pattern_message',
|
|
100
100
|
description:
|
|
101
101
|
'This key defines the message that explains which regular expression an Input will accept. This key requires you to define `options.pattern`.',
|
|
102
102
|
}),
|
|
@@ -124,7 +124,7 @@ const TextValidationSchema = z.object({
|
|
|
124
124
|
})
|
|
125
125
|
.optional()
|
|
126
126
|
.meta({
|
|
127
|
-
id: 'pattern_flags',
|
|
127
|
+
id: 'type._inputs.*.options.pattern_flags',
|
|
128
128
|
description:
|
|
129
129
|
'This key defines the flags (e.g. case-insensitive searching) for the regular expression set in `options.pattern`.',
|
|
130
130
|
}),
|
|
@@ -132,32 +132,32 @@ const TextValidationSchema = z.object({
|
|
|
132
132
|
|
|
133
133
|
const ArrayValidationSchema = z.object({
|
|
134
134
|
max_items: z.number().optional().meta({
|
|
135
|
-
id: 'max_items',
|
|
135
|
+
id: 'type._inputs.*.options.max_items',
|
|
136
136
|
description:
|
|
137
137
|
'This key defines the maximum number of items CloudCannon will allow in an Input. When configured, CloudCannon will prevent you from adding more items to this Input. If the Input already contains more items, CloudCannon will require you to remove items until the Input contains a valid number to save your changes, or discard your unsaved changes.',
|
|
138
138
|
}),
|
|
139
139
|
max_items_message: z.string().optional().meta({
|
|
140
|
-
id: 'max_items_message',
|
|
140
|
+
id: 'type._inputs.*.options.max_items_message',
|
|
141
141
|
description:
|
|
142
142
|
'This key defines the message that explains why an Input needs to have a maximum number of items. This key requires you to define `options.max_items`.',
|
|
143
143
|
}),
|
|
144
144
|
min_items: z.number().optional().meta({
|
|
145
|
-
id: 'min_items',
|
|
145
|
+
id: 'type._inputs.*.options.min_items',
|
|
146
146
|
description:
|
|
147
147
|
'This key defines the minimum number of items CloudCannon will allow in an Input. When configured, CloudCannon will prevent you from removing items from this Input below this value. If the Input already contains fewer items, CloudCannon will require you to add items until the Input contains a valid number to save your changes, or discard your unsaved changes.',
|
|
148
148
|
}),
|
|
149
149
|
min_items_message: z.string().optional().meta({
|
|
150
|
-
id: 'min_items_message',
|
|
150
|
+
id: 'type._inputs.*.options.min_items_message',
|
|
151
151
|
description:
|
|
152
152
|
'This key defines the message that explains why an Input needs to have a minimum number of items. This key requires you to define `options.min_items`.',
|
|
153
153
|
}),
|
|
154
154
|
unique_on: z.string().optional().meta({
|
|
155
|
-
id: 'unique_on',
|
|
155
|
+
id: 'type._inputs.*.options.unique_on',
|
|
156
156
|
description:
|
|
157
157
|
'This key defines the JSON Path selector that CloudCannon should use to determine if the value of an Input is unique. When configured, CloudCannon will require the value of the Input to be unique compared to the value defined on the JSON Path. If the Input already contains a non-unique value, CloudCannon will require you to change it to a valid value to save your changes, or discard your unsaved changes.',
|
|
158
158
|
}),
|
|
159
159
|
unique_on_message: z.string().optional().meta({
|
|
160
|
-
id: 'unique_on_message',
|
|
160
|
+
id: 'type._inputs.*.options.unique_on_message',
|
|
161
161
|
description:
|
|
162
162
|
'This key defines the message that explains why an Input needs to be unique. This key requires you to define `options.unique_on`.',
|
|
163
163
|
}),
|
|
@@ -180,22 +180,22 @@ const ArrayControlOptionsSchema = z.object({
|
|
|
180
180
|
});
|
|
181
181
|
|
|
182
182
|
const EmptyTypeTextSchema = z.enum(['null', 'string']).default('null').meta({
|
|
183
|
-
id: 'empty_type_text',
|
|
183
|
+
id: 'type._inputs.*.options.empty_type_text',
|
|
184
184
|
description: 'Set how an ‘empty’ value will be saved. Does not apply to existing empty values.',
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
const EmptyTypeNumberSchema = z.enum(['null', 'number']).default('null').meta({
|
|
188
|
-
id: 'empty_type_number',
|
|
188
|
+
id: 'type._inputs.*.options.empty_type_number',
|
|
189
189
|
description: 'Set how an ‘empty’ value will be saved. Does not apply to existing empty values.',
|
|
190
190
|
});
|
|
191
191
|
|
|
192
192
|
const EmptyTypeObjectSchema = z.enum(['null', 'object']).default('null').meta({
|
|
193
|
-
id: 'empty_type_object',
|
|
193
|
+
id: 'type._inputs.*.options.empty_type_object',
|
|
194
194
|
description: 'Set how an ‘empty’ value will be saved. Does not apply to existing empty values.',
|
|
195
195
|
});
|
|
196
196
|
|
|
197
197
|
const EmptyTypeArraySchema = z.enum(['null', 'array']).default('null').meta({
|
|
198
|
-
id: 'empty_type_array',
|
|
198
|
+
id: 'type._inputs.*.options.empty_type_array',
|
|
199
199
|
description: 'Set how an ‘empty’ value will be saved. Does not apply to existing empty values.',
|
|
200
200
|
});
|
|
201
201
|
|
|
@@ -215,13 +215,13 @@ export const ContextSchema = z
|
|
|
215
215
|
}),
|
|
216
216
|
})
|
|
217
217
|
.meta({
|
|
218
|
-
id: 'context',
|
|
218
|
+
id: 'type._inputs.*.context',
|
|
219
219
|
description: 'Adds an expandable section of rich text below the input.',
|
|
220
220
|
});
|
|
221
221
|
|
|
222
222
|
export const BaseInputSchema = z.object({
|
|
223
223
|
comment: z.string().optional().meta({
|
|
224
|
-
id: 'comment',
|
|
224
|
+
id: 'type._inputs.*.comment',
|
|
225
225
|
description:
|
|
226
226
|
'Changes the subtext below the _Label_. Has no default. Supports a limited set of Markdown: links, bold, italic, subscript, superscript, and inline code elements are allowed.',
|
|
227
227
|
}),
|
|
@@ -230,7 +230,7 @@ export const BaseInputSchema = z.object({
|
|
|
230
230
|
description: 'Provides a custom link for documentation for editors shown above input.',
|
|
231
231
|
}),
|
|
232
232
|
label: z.string().optional().meta({
|
|
233
|
-
id: 'label',
|
|
233
|
+
id: 'type._inputs.*.label',
|
|
234
234
|
description: 'Optionally changes the text above this input.',
|
|
235
235
|
}),
|
|
236
236
|
hidden: z
|
|
@@ -238,7 +238,7 @@ export const BaseInputSchema = z.object({
|
|
|
238
238
|
.default(false)
|
|
239
239
|
.optional()
|
|
240
240
|
.meta({
|
|
241
|
-
id: 'hidden',
|
|
241
|
+
id: 'type._inputs.*.hidden',
|
|
242
242
|
description: 'Toggles the visibility of this input.',
|
|
243
243
|
}),
|
|
244
244
|
disabled: z
|
|
@@ -246,22 +246,22 @@ export const BaseInputSchema = z.object({
|
|
|
246
246
|
.default(false)
|
|
247
247
|
.optional()
|
|
248
248
|
.meta({
|
|
249
|
-
id: 'disabled',
|
|
249
|
+
id: 'type._inputs.*.disabled',
|
|
250
250
|
description: 'Toggles if this input can be edited.',
|
|
251
251
|
}),
|
|
252
252
|
instance_value: z.enum(['UUID', 'NOW']).optional().meta({
|
|
253
|
-
id: 'instance_value',
|
|
253
|
+
id: 'type._inputs.*.instance_value',
|
|
254
254
|
title: 'Instance Value',
|
|
255
255
|
description:
|
|
256
256
|
'Controls if and how the value of this input is instantiated when created. This occurs when creating files, or adding array items containing the configured input.',
|
|
257
257
|
}),
|
|
258
258
|
disable_instance_value_rehydration: z.boolean().default(false).optional().meta({
|
|
259
|
-
id: 'disable_instance_value_rehydration',
|
|
259
|
+
id: 'type._inputs.*.disable_instance_value_rehydration',
|
|
260
260
|
description:
|
|
261
261
|
'Prevents the default where inputs configured with an `instance_value` are rehydrated with a new value when duplicated in the CMS.',
|
|
262
262
|
}),
|
|
263
263
|
cascade: z.boolean().default(true).optional().meta({
|
|
264
|
-
id: 'cascade',
|
|
264
|
+
id: 'type._inputs.*.cascade',
|
|
265
265
|
description:
|
|
266
266
|
'Specifies whether or not this input configuration should be merged with any matching, less specific configuration.',
|
|
267
267
|
}),
|
|
@@ -413,13 +413,13 @@ export const BooleanInputSchema = z
|
|
|
413
413
|
});
|
|
414
414
|
|
|
415
415
|
const MinSchema = z.number().meta({
|
|
416
|
-
id: 'min',
|
|
416
|
+
id: 'type._inputs.*.options.min',
|
|
417
417
|
description:
|
|
418
418
|
'This key defines the minimum numerical value CloudCannon will allow in an Input. When configured, CloudCannon will prevent you from entering a lesser numerical value. If the Input already contains a lesser numerical value, CloudCannon will require you to enter a valid value to save your changes, or discard your unsaved changes.',
|
|
419
419
|
});
|
|
420
420
|
|
|
421
421
|
const MaxSchema = z.number().meta({
|
|
422
|
-
id: 'max',
|
|
422
|
+
id: 'type._inputs.*.options.max',
|
|
423
423
|
description:
|
|
424
424
|
'This key defines the maximum numerical value CloudCannon will allow in an Input. When configured, CloudCannon will prevent you from entering a greater numerical value. If the Input already contains a greater numerical value, CloudCannon will require you to enter a valid value to save your changes, or discard your unsaved changes.',
|
|
425
425
|
});
|
|
@@ -431,17 +431,17 @@ export const NumberInputOptionsSchema = z
|
|
|
431
431
|
min: MinSchema.optional(),
|
|
432
432
|
max: MaxSchema.optional(),
|
|
433
433
|
step: z.number().optional().meta({
|
|
434
|
-
id: 'step',
|
|
434
|
+
id: 'type._inputs.*.options.step',
|
|
435
435
|
description:
|
|
436
436
|
'A number that specifies the granularity that the value must adhere to, or the special value any, which allows any decimal value between `max` and `min`.',
|
|
437
437
|
}),
|
|
438
438
|
min_message: z.string().optional().meta({
|
|
439
|
-
id: 'min_message',
|
|
439
|
+
id: 'type._inputs.*.options.min_message',
|
|
440
440
|
description:
|
|
441
441
|
'This key defines the message that explains why an Input needs to have a minimum numerical value. This key requires you to define `options.min`.',
|
|
442
442
|
}),
|
|
443
443
|
max_message: z.string().optional().meta({
|
|
444
|
-
id: 'max_message',
|
|
444
|
+
id: 'type._inputs.*.options.max_message',
|
|
445
445
|
description:
|
|
446
446
|
'This key defines the message that explains why an Input needs to have a maximum numerical value. This key requires you to define `options.max`.',
|
|
447
447
|
}),
|
|
@@ -602,31 +602,31 @@ export const FileInputOptionsSchema = z
|
|
|
602
602
|
])
|
|
603
603
|
.optional()
|
|
604
604
|
.meta({
|
|
605
|
-
id: 'accepts_mime_types',
|
|
605
|
+
id: 'type._inputs.*.options.accepts_mime_types',
|
|
606
606
|
description:
|
|
607
607
|
'Restricts which file types are available to select or upload to this input. Accepted format is an array or comma-separated string of MIME types. The special value "*" means any type is accepted.',
|
|
608
608
|
}),
|
|
609
609
|
max_file_size: z.number().optional().meta({
|
|
610
|
-
id: 'max_file_size',
|
|
610
|
+
id: 'type._inputs.*.options.max_file_size',
|
|
611
611
|
description:
|
|
612
612
|
'This key defines the maximum file size, in kilobytes, that CloudCannon will allow in an Input. When configured, CloudCannon will prevent you from uploading a file larger than the specified size. If the Input already contains a file larger than the specified size, CloudCannon will require you to change it to a valid value to save your changes, or discard your unsaved changes. Value can be any positive integer.',
|
|
613
613
|
}),
|
|
614
614
|
max_file_size_message: z.string().optional().meta({
|
|
615
|
-
id: 'max_file_size_message',
|
|
615
|
+
id: 'type._inputs.*.options.max_file_size_message',
|
|
616
616
|
description:
|
|
617
617
|
'This key defines the message that explains why an Input needs to have a maximum file size. This key requires you to define `options.max_file_size`. This key has no default.',
|
|
618
618
|
}),
|
|
619
619
|
disable_upload_file: z.boolean().default(false).optional().meta({
|
|
620
|
-
id: 'disable_upload_file',
|
|
620
|
+
id: 'type._inputs.*.options.disable_upload_file',
|
|
621
621
|
description: 'Disables the context menu option and the drop area for uploading files.',
|
|
622
622
|
}),
|
|
623
623
|
disable_direct_input: z.boolean().default(false).optional().meta({
|
|
624
|
-
id: 'disable_direct_input',
|
|
624
|
+
id: 'type._inputs.*.options.disable_direct_input',
|
|
625
625
|
description:
|
|
626
626
|
'Prevents typing into the text input, while still allowing context menu options to change the value.',
|
|
627
627
|
}),
|
|
628
628
|
disable_upload_file_in_file_browser: z.boolean().default(false).optional().meta({
|
|
629
|
-
id: 'disable_upload_file_in_file_browser',
|
|
629
|
+
id: 'type._inputs.*.options.disable_upload_file_in_file_browser',
|
|
630
630
|
description:
|
|
631
631
|
'Prevents file uploads inside the "Select existing file/image" file browser modal window.',
|
|
632
632
|
}),
|
|
@@ -689,11 +689,11 @@ export const SharedSelectInputOptionsSchema = z.object({
|
|
|
689
689
|
preview: PreviewSchema.optional(),
|
|
690
690
|
picker_preview: PreviewSchema.optional(),
|
|
691
691
|
allow_create: z.boolean().default(false).optional().meta({
|
|
692
|
-
id: 'allow_create',
|
|
692
|
+
id: 'type._inputs.*.options.allow_create',
|
|
693
693
|
description: 'Allows new text values to be created at edit time.',
|
|
694
694
|
}),
|
|
695
695
|
allow_empty: z.boolean().default(true).optional().meta({
|
|
696
|
-
id: 'allow_empty',
|
|
696
|
+
id: 'type._inputs.*.options.allow_empty',
|
|
697
697
|
description: 'Provides an empty option alongside the options provided by values.',
|
|
698
698
|
}),
|
|
699
699
|
values: z
|
|
@@ -703,21 +703,21 @@ export const SharedSelectInputOptionsSchema = z.object({
|
|
|
703
703
|
])
|
|
704
704
|
.optional()
|
|
705
705
|
.meta({
|
|
706
|
-
id: 'values',
|
|
706
|
+
id: 'type._inputs.*.options.values',
|
|
707
707
|
description:
|
|
708
708
|
'Defines the values available to choose from. Optional, defaults to fetching values from the naming convention (e.g. colors or my_colors for data set colors).',
|
|
709
709
|
}),
|
|
710
710
|
value_key: z.string().optional().meta({
|
|
711
|
-
id: 'value_key',
|
|
711
|
+
id: 'type._inputs.*.options.value_key',
|
|
712
712
|
description:
|
|
713
713
|
'Defines the key used for mapping between saved values and objects in values. This changes how the input saves selected values to match. Defaults to checking for "id", "uuid", "path", "title", then "name". Has no effect unless values is an array of objects, the key is used instead for objects, and the value itself is used for primitive types.',
|
|
714
714
|
}),
|
|
715
715
|
view: z.enum(['card', 'text', 'gallery', 'gallery-left']).optional().meta({
|
|
716
|
-
id: 'view',
|
|
716
|
+
id: 'type._inputs.*.options.view',
|
|
717
717
|
description: 'Controls how selected items are rendered.',
|
|
718
718
|
}),
|
|
719
719
|
picker_view: z.enum(['card', 'text', 'gallery', 'gallery-left']).optional().meta({
|
|
720
|
-
id: 'picker_view',
|
|
720
|
+
id: 'type._inputs.*.options.picker_view',
|
|
721
721
|
description: 'Controls how selectable options are rendered.',
|
|
722
722
|
}),
|
|
723
723
|
});
|
|
@@ -868,7 +868,6 @@ export const ObjectInputOptionsSchema = z
|
|
|
868
868
|
'Used to supply help text above the key input when adding/renaming within a mutable object input. Has no default. Supports a limited set of Markdown: links, bold, italic, subscript, superscript and inline code elements are allowed.',
|
|
869
869
|
}),
|
|
870
870
|
documentation: DocumentationSchema.optional().meta({
|
|
871
|
-
id: 'entries_documentation',
|
|
872
871
|
description:
|
|
873
872
|
'Provides a custom link for documentation for editors shown above the key input when adding/renaming within a mutable object input.',
|
|
874
873
|
}),
|
|
@@ -1011,6 +1010,10 @@ export const InputsSchema = z.record(z.string(), InputSchema).meta({
|
|
|
1011
1010
|
'Controls the behavior and appearance of your inputs in all data editing interfaces.',
|
|
1012
1011
|
});
|
|
1013
1012
|
|
|
1013
|
+
export const InputsFromGlobSchema = z.array(z.string()).meta({
|
|
1014
|
+
id: 'type._inputs_from_glob',
|
|
1015
|
+
});
|
|
1016
|
+
|
|
1014
1017
|
export type Context = z.infer<typeof ContextSchema>;
|
|
1015
1018
|
export type BaseInput = z.infer<typeof BaseInputSchema>;
|
|
1016
1019
|
export type TextInputOptions = z.infer<typeof TextInputOptionsSchema>;
|
package/src/preview.ts
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
|
|
3
|
-
const PreviewKeyEntrySchema = z
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const PreviewKeyEntrySchema = z.object({ key: z.string().meta({ title: 'Key Value' }) }).meta({
|
|
4
|
+
id: 'type.preview-entry.(key)',
|
|
5
|
+
title: 'Key',
|
|
6
|
+
});
|
|
6
7
|
|
|
7
8
|
const PreviewTemplateEntrySchema = z
|
|
8
9
|
.object({ template: z.string().meta({ title: 'Template Value' }) })
|
|
9
|
-
.meta({
|
|
10
|
+
.meta({
|
|
11
|
+
id: 'type.preview-entry.(template)',
|
|
12
|
+
title: 'Template',
|
|
13
|
+
});
|
|
10
14
|
|
|
11
|
-
const PreviewTextEntrySchema = z
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
const PreviewTextEntrySchema = z.object({ text: z.string().meta({ title: 'Text Value' }) }).meta({
|
|
16
|
+
id: 'type.preview-entry.(text)',
|
|
17
|
+
title: 'Text',
|
|
18
|
+
});
|
|
14
19
|
|
|
15
|
-
const PreviewRawTextEntrySchema = z.string().meta({
|
|
16
|
-
|
|
20
|
+
const PreviewRawTextEntrySchema = z.string().meta({
|
|
21
|
+
id: 'type.preview-entry.(raw-text)',
|
|
22
|
+
title: 'Raw Text',
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const PreviewFalseEntrySchema = z.literal(false).meta({
|
|
26
|
+
id: 'type.preview-entry.(false)',
|
|
27
|
+
title: 'False',
|
|
28
|
+
});
|
|
17
29
|
|
|
18
30
|
const PreviewEntrySchema = z
|
|
19
31
|
.union([
|
|
@@ -23,50 +35,73 @@ const PreviewEntrySchema = z
|
|
|
23
35
|
PreviewRawTextEntrySchema,
|
|
24
36
|
PreviewFalseEntrySchema,
|
|
25
37
|
])
|
|
26
|
-
.meta({
|
|
38
|
+
.meta({
|
|
39
|
+
id: 'type.preview-entry',
|
|
40
|
+
title: 'Preview Entry',
|
|
41
|
+
});
|
|
27
42
|
|
|
28
43
|
export const PreviewEntriesSchema = z
|
|
29
44
|
.union([
|
|
30
|
-
z.array(PreviewEntrySchema).meta({
|
|
45
|
+
z.array(PreviewEntrySchema).meta({
|
|
46
|
+
id: 'type.preview-entry.(array)',
|
|
47
|
+
title: 'Array',
|
|
48
|
+
}),
|
|
31
49
|
PreviewRawTextEntrySchema,
|
|
32
50
|
PreviewFalseEntrySchema,
|
|
33
51
|
])
|
|
34
52
|
.meta({ id: 'PreviewEntries' });
|
|
35
53
|
|
|
54
|
+
const TextPreviewEntriesSchema = PreviewEntriesSchema.optional().meta({ id: 'type.preview.text' });
|
|
55
|
+
const SubtextPreviewEntriesSchema = PreviewEntriesSchema.optional().meta({
|
|
56
|
+
id: 'type.preview.subtext',
|
|
57
|
+
});
|
|
58
|
+
const ImagePreviewEntriesSchema = PreviewEntriesSchema.optional().meta({
|
|
59
|
+
id: 'type.preview.image',
|
|
60
|
+
});
|
|
61
|
+
const IconPreviewEntriesSchema = PreviewEntriesSchema.optional().meta({ id: 'type.preview.icon' });
|
|
62
|
+
const IconColorPreviewEntriesSchema = PreviewEntriesSchema.optional().meta({
|
|
63
|
+
id: 'type.preview.icon_color',
|
|
64
|
+
});
|
|
65
|
+
const IconBackgroundColorPreviewEntriesSchema = PreviewEntriesSchema.optional().meta({
|
|
66
|
+
id: 'type.preview.icon_background_color',
|
|
67
|
+
});
|
|
68
|
+
|
|
36
69
|
export const PreviewGallerySchema = z
|
|
37
70
|
.object({
|
|
38
|
-
text:
|
|
39
|
-
image:
|
|
40
|
-
icon:
|
|
41
|
-
icon_color:
|
|
42
|
-
icon_background_color:
|
|
71
|
+
text: TextPreviewEntriesSchema,
|
|
72
|
+
image: ImagePreviewEntriesSchema,
|
|
73
|
+
icon: IconPreviewEntriesSchema,
|
|
74
|
+
icon_color: IconColorPreviewEntriesSchema,
|
|
75
|
+
icon_background_color: IconBackgroundColorPreviewEntriesSchema,
|
|
43
76
|
fit: z
|
|
44
77
|
.enum(['padded', 'cover', 'contain', 'cover-top'])
|
|
45
78
|
.default('padded')
|
|
46
79
|
.optional()
|
|
47
80
|
.meta({ id: 'preview.gallery.fit' }),
|
|
48
|
-
background_color: PreviewEntriesSchema.optional()
|
|
81
|
+
background_color: PreviewEntriesSchema.optional().meta({
|
|
82
|
+
id: 'type.preview.gallery.background_color',
|
|
83
|
+
}),
|
|
49
84
|
})
|
|
50
85
|
.meta({ id: 'preview.gallery' });
|
|
51
86
|
|
|
52
87
|
const PreviewMetadataEntrySchema = z
|
|
53
88
|
.object({
|
|
54
|
-
text:
|
|
55
|
-
image:
|
|
56
|
-
icon:
|
|
57
|
-
icon_color:
|
|
58
|
-
icon_background_color:
|
|
89
|
+
text: TextPreviewEntriesSchema,
|
|
90
|
+
image: ImagePreviewEntriesSchema,
|
|
91
|
+
icon: IconPreviewEntriesSchema,
|
|
92
|
+
icon_color: IconColorPreviewEntriesSchema,
|
|
93
|
+
icon_background_color: IconBackgroundColorPreviewEntriesSchema,
|
|
59
94
|
})
|
|
60
95
|
.meta({ id: 'PreviewMetadataEntry' });
|
|
61
96
|
|
|
62
97
|
export const PreviewSchema = z
|
|
63
98
|
.object({
|
|
64
|
-
text:
|
|
65
|
-
subtext:
|
|
66
|
-
image:
|
|
67
|
-
icon:
|
|
68
|
-
icon_color:
|
|
69
|
-
icon_background_color:
|
|
99
|
+
text: TextPreviewEntriesSchema,
|
|
100
|
+
subtext: SubtextPreviewEntriesSchema,
|
|
101
|
+
image: ImagePreviewEntriesSchema,
|
|
102
|
+
icon: IconPreviewEntriesSchema,
|
|
103
|
+
icon_color: IconColorPreviewEntriesSchema,
|
|
104
|
+
icon_background_color: IconBackgroundColorPreviewEntriesSchema,
|
|
70
105
|
tags: z.array(z.string()).optional().meta({ id: 'preview.tags' }),
|
|
71
106
|
metadata: z.array(PreviewMetadataEntrySchema).optional().meta({ id: 'preview.metadata' }),
|
|
72
107
|
gallery: PreviewGallerySchema.optional(),
|
package/src/snippets.ts
CHANGED
|
@@ -2,70 +2,83 @@ import * as z from 'zod';
|
|
|
2
2
|
import { ReducedCascadeSchema } from './cascade.ts';
|
|
3
3
|
import { PreviewSchema } from './preview.ts';
|
|
4
4
|
|
|
5
|
-
export const ParserModelSchema = z
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
export const ParserModelSchema = z
|
|
6
|
+
.object({
|
|
7
|
+
source_key: z.string().optional(),
|
|
8
|
+
editor_key: z.string().optional(),
|
|
9
|
+
remove_empty: z.boolean(),
|
|
10
|
+
optional: z.boolean(),
|
|
11
|
+
type: z.enum(['array', 'object', 'string', 'boolean', 'number']).optional(),
|
|
12
|
+
allowed_values: z.array(z.any()).optional(),
|
|
13
|
+
implied_boolean: z.boolean(),
|
|
14
|
+
default: z.any().optional(),
|
|
15
|
+
})
|
|
16
|
+
.meta({
|
|
17
|
+
id: 'type.snippet-model',
|
|
18
|
+
title: 'Snippet Model',
|
|
19
|
+
});
|
|
15
20
|
|
|
16
21
|
export const PairedTokenSchema = z.object({
|
|
17
22
|
start: z.string(),
|
|
18
23
|
end: z.string(),
|
|
19
24
|
});
|
|
20
25
|
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export const SnippetStyleSchema = z.object({
|
|
30
|
-
output: z.enum(['legacy', 'inline', 'block']),
|
|
31
|
-
inline: z
|
|
32
|
-
.object({
|
|
33
|
-
leading: z.string().optional(),
|
|
34
|
-
trailing: z.string().optional(),
|
|
35
|
-
})
|
|
26
|
+
export const SnippetStyleSchema = z
|
|
27
|
+
.object({
|
|
28
|
+
output: z.enum(['legacy', 'inline', 'block']),
|
|
29
|
+
inline: z
|
|
30
|
+
.object({
|
|
31
|
+
leading: z.string().optional(),
|
|
32
|
+
trailing: z.string().optional(),
|
|
33
|
+
})
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
.optional(),
|
|
36
|
+
block: z
|
|
37
|
+
.object({
|
|
38
|
+
leading: z.string().optional(),
|
|
39
|
+
trailing: z.string().optional(),
|
|
40
|
+
indent: z.string().optional(),
|
|
41
|
+
})
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
})
|
|
43
|
+
.optional(),
|
|
44
|
+
})
|
|
45
|
+
.meta({
|
|
46
|
+
id: 'type.snippet-style',
|
|
47
|
+
title: 'Snippet Style',
|
|
48
|
+
});
|
|
47
49
|
|
|
48
|
-
export const ParserFormatSchema = z
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
export const ParserFormatSchema = z
|
|
51
|
+
.object({
|
|
52
|
+
root_boundary: PairedTokenSchema,
|
|
53
|
+
root_value_boundary: PairedTokenSchema,
|
|
54
|
+
root_value_boundary_optional: z.record(z.string(), z.boolean()),
|
|
55
|
+
root_value_delimiter: z.string().optional(),
|
|
56
|
+
root_pair_delimiter: z.array(z.string()),
|
|
57
|
+
remove_empty_root_boundary: z.boolean(),
|
|
58
|
+
object_boundary: PairedTokenSchema,
|
|
59
|
+
object_value_delimiter: z.string(),
|
|
60
|
+
object_pair_delimiter: z.string(),
|
|
61
|
+
array_boundary: PairedTokenSchema,
|
|
62
|
+
array_delimiter: z.string(),
|
|
63
|
+
string_boundary: z.array(z.string()),
|
|
64
|
+
string_escape_character: z.string(),
|
|
65
|
+
allow_booleans: z.boolean(),
|
|
66
|
+
allow_numbers: z.boolean(),
|
|
67
|
+
allow_implied_values: z.boolean(),
|
|
68
|
+
allow_null: z.boolean(),
|
|
69
|
+
forbidden_tokens: z.array(z.string()),
|
|
70
|
+
allowed_string_cases: z.object({
|
|
71
|
+
any: z.boolean().optional(),
|
|
72
|
+
leading_upper: z.boolean().optional(),
|
|
73
|
+
leading_lower: z.boolean().optional(),
|
|
74
|
+
lower: z.boolean().optional(),
|
|
75
|
+
upper: z.boolean().optional(),
|
|
76
|
+
}),
|
|
77
|
+
})
|
|
78
|
+
.meta({
|
|
79
|
+
id: 'type.snippet-format',
|
|
80
|
+
title: 'Snippet Format',
|
|
81
|
+
});
|
|
69
82
|
|
|
70
83
|
export const ArgumentListParserConfigSchema = z.object({
|
|
71
84
|
parser: z.literal('argument_list'),
|
|
@@ -219,7 +232,7 @@ export const SnippetConfigSchema = z
|
|
|
219
232
|
|
|
220
233
|
const SnippetImportSchema = z
|
|
221
234
|
.union([
|
|
222
|
-
z.boolean().meta({ title: 'Full Import' }),
|
|
235
|
+
z.boolean().meta({ id: 'type._snippets_imports.*.(full-import)', title: 'Full Import' }),
|
|
223
236
|
z
|
|
224
237
|
.object({
|
|
225
238
|
exclude: z.array(z.string()).meta({
|
package/src/structures.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { DocumentationSchema } from './documentation.ts';
|
|
3
3
|
import { IconSchema } from './icon.ts';
|
|
4
|
-
import { InputsSchema, ObjectInputGroupSchema } from './inputs.ts';
|
|
4
|
+
import { InputsFromGlobSchema, InputsSchema, ObjectInputGroupSchema } from './inputs.ts';
|
|
5
5
|
import { PreviewSchema } from './preview.ts';
|
|
6
6
|
import { SelectDataSchema } from './select-values.ts';
|
|
7
7
|
|
|
@@ -29,6 +29,10 @@ const StructureBaseSchema = z.object({
|
|
|
29
29
|
}),
|
|
30
30
|
});
|
|
31
31
|
|
|
32
|
+
export const StructuresFromGlobSchema = z.array(z.string()).meta({
|
|
33
|
+
id: 'type._structures_from_glob',
|
|
34
|
+
});
|
|
35
|
+
|
|
32
36
|
export const StructureValueSchema = StructureBaseSchema.extend({
|
|
33
37
|
preview: PreviewSchema.optional(),
|
|
34
38
|
picker_preview: PreviewSchema.optional(),
|
|
@@ -37,12 +41,14 @@ export const StructureValueSchema = StructureBaseSchema.extend({
|
|
|
37
41
|
get _inputs() {
|
|
38
42
|
return InputsSchema.optional();
|
|
39
43
|
},
|
|
40
|
-
_inputs_from_glob
|
|
44
|
+
get _inputs_from_glob() {
|
|
45
|
+
return InputsFromGlobSchema.optional();
|
|
46
|
+
},
|
|
41
47
|
_select_data: SelectDataSchema.optional(),
|
|
42
48
|
get _structures() {
|
|
43
49
|
return StructuresSchema.optional();
|
|
44
50
|
},
|
|
45
|
-
_structures_from_glob:
|
|
51
|
+
_structures_from_glob: StructuresFromGlobSchema.optional(),
|
|
46
52
|
|
|
47
53
|
id: z.string().optional().meta({
|
|
48
54
|
description:
|