@cloudcannon/configuration-types 0.0.31 → 0.0.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcannon/configuration-types",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "description": "Contains TypeScript declarations and generates JSONSchema files for the CloudCannon configuration file.",
6
6
  "author": "CloudCannon <support@cloudcannon.com>",
@@ -12,7 +12,7 @@
12
12
  "homepage": "https://github.com/CloudCannon/configuration-types#readme",
13
13
  "repository": {
14
14
  "type": "git",
15
- "url": "https://github.com/CloudCannon/configuration-types.git"
15
+ "url": "git+https://github.com/CloudCannon/configuration-types.git"
16
16
  },
17
17
  "bugs": {
18
18
  "url": "https://github.com/CloudCannon/configuration-types/issues",
package/src/inputs.d.ts CHANGED
@@ -44,6 +44,175 @@ export type InputType =
44
44
  | 'array'
45
45
  | 'auto';
46
46
 
47
+ interface WithRequiredValidation {
48
+ /**
49
+ * This key toggles whether CloudCannon requires this Input to have a value. If set to true,
50
+ * CloudCannon will require you to enter a value to save your changes, or discard your unsaved
51
+ * changes.
52
+ *
53
+ * By default, this key is false (i.e, CloudCannon does not require this Input to have a value).
54
+ */
55
+ required?: boolean;
56
+ }
57
+
58
+ interface WithTextValidation {
59
+ /**
60
+ * This key defines the maximum string length, in characters, that CloudCannon will allow in an
61
+ * Input. When configured, CloudCannon will warn you when an Input value is too long. If the Input
62
+ * already contains a longer value, CloudCannon will require you to remove characters until the
63
+ * Input contains a valid string to save your changes, or discard your unsaved changes.
64
+ *
65
+ * Value can be any non-negative integer. If this key is set to 0, CloudCannon requires the Input
66
+ * to be empty. If `options.min_length` is also configured, this key cannot be a smaller number.
67
+ *
68
+ * This key has no default.
69
+ *
70
+ * To use this key in a Select Input, `options.allow_create` must be set to true.
71
+ */
72
+ max_length?: number;
73
+ /**
74
+ * This key defines the minimum string length, in characters, that CloudCannon will allow in an
75
+ * Input. When configured, CloudCannon will warn you when an Input value is too short. If the
76
+ * Input already contains a shorter value, CloudCannon will require you to add characters until
77
+ * the Input contains a valid string to save your changes, or discard your unsaved changes.
78
+ *
79
+ * Value can be any positive integer. If `options.max_length` is also configured, this key cannot
80
+ * be a greater number.
81
+ *
82
+ * This key has no default.
83
+ *
84
+ * To use this key in a Select Input, `options.allow_create` must be set to true.
85
+ */
86
+ min_length?: number;
87
+ /**
88
+ * This key defines a regular expression that the Input value must match. When configured,
89
+ * CloudCannon will require you to enter a value that matches the REGEX pattern. If the Input
90
+ * already contains an invalid value, CloudCannon will require you to enter a valid string to save
91
+ * your changes, or discard your unsaved changes.
92
+ *
93
+ * Value must be a valid REGEX string.
94
+ *
95
+ * This key has no default.
96
+ *
97
+ * To use this key in a Select Input, `options.allow_create` must be set to true.
98
+ */
99
+ pattern?: string;
100
+ /**
101
+ * This key defines the message that explains which regular expression an Input will accept. This
102
+ * key requires you to define `options.pattern`.
103
+ *
104
+ * This key has no default.
105
+ */
106
+ pattern_message?: string;
107
+ /**
108
+ * This key defines the flags (e.g. case-insensitive searching) for the regular expression set in
109
+ * `options.pattern`. This key requires you to define `options.pattern`.
110
+ *
111
+ * The flags available match those a subset for [JavaScript regular
112
+ * expressions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions#advanced_searching_with_flags).
113
+ *
114
+ * This key has no default.
115
+ */
116
+ pattern_flags?: {
117
+ /**
118
+ * `g` - Search globally.
119
+ *
120
+ * @default false
121
+ */
122
+ global?: boolean;
123
+ /**
124
+ * `i` - Case-insensitive.
125
+ *
126
+ * @default false
127
+ */
128
+ ignore_case?: boolean;
129
+ /**
130
+ * `m` - `^` and `$` match the start and end of each line rather than the entire string.
131
+ *
132
+ * @default false
133
+ */
134
+ multiline?: boolean;
135
+ /**
136
+ * `s` - `.` matches newline characters.
137
+ *
138
+ * @default false
139
+ */
140
+ dot_all?: boolean;
141
+ /**
142
+ * `u` - Pattern is treated as a sequence of Unicode code points.
143
+ *
144
+ * @default false
145
+ */
146
+ unicode?: boolean;
147
+ /**
148
+ * `v` - Extended `unicode` mode.
149
+ *
150
+ * @default false
151
+ */
152
+ unicode_sets?: boolean;
153
+ };
154
+ }
155
+
156
+ interface WithArrayValidation {
157
+ /**
158
+ * This key defines the maximum number of items CloudCannon will allow in an Input. When
159
+ * configured, CloudCannon will prevent you from adding more items to this Input. If the Input
160
+ * already contains more items, CloudCannon will require you to remove items until the Input
161
+ * contains a valid number to save your changes, or discard your unsaved changes.
162
+ *
163
+ * Value can be any positive integer. If `options.min_items` is also configured, this key cannot
164
+ * be a lesser number.
165
+ *
166
+ * This key has no default.
167
+ */
168
+ max_items?: number;
169
+ /**
170
+ * This key defines the minimum number of items CloudCannon will allow in an Input. When
171
+ * configured, CloudCannon will prevent you from removing items from this Input below this value.
172
+ * If the Input already contains fewer items, CloudCannon will require you to add items until the
173
+ * Input contains a valid number to save your changes, or discard your unsaved changes.
174
+ *
175
+ * Value can be any positive integer. If `options.min_items` is also configured, this key cannot
176
+ * be a greater number.
177
+ *
178
+ * This key has no default.
179
+ */
180
+ min_items?: number;
181
+ /**
182
+ * This key defines the JSON Path selector that CloudCannon should use to determine if the value
183
+ * of an Input is unique. When configured, CloudCannon will require the value of the Input to be
184
+ * unique compared to the value defined on the JSON Path. If the Input already contains a
185
+ * non-unique value, CloudCannon will require you to change it to a valid value to save your
186
+ * changes, or discard your unsaved changes.
187
+ *
188
+ * Value must be a valid JSON Path.
189
+ *
190
+ * This key has no default.
191
+ */
192
+ unique_on?: string;
193
+ }
194
+
195
+ export interface WithArrayControlOptions {
196
+ /**
197
+ * Hides the add button, and context menu actions on each item for adding new items to this Input.
198
+ *
199
+ * @default false
200
+ */
201
+ disable_add?: boolean;
202
+ /**
203
+ * Hides the context menu actions on each item for removing them.
204
+ *
205
+ * @default false
206
+ */
207
+ disable_remove?: boolean;
208
+ /**
209
+ * Hides the controls on each item for moving them.
210
+ *
211
+ * @default false
212
+ */
213
+ disable_reorder?: boolean;
214
+ }
215
+
47
216
  interface WithEmptyTypeText {
48
217
  /**
49
218
  * Set how an ‘empty’ value will be saved. Does not apply to existing empty values.
@@ -138,7 +307,10 @@ export interface BaseInput {
138
307
  cascade?: boolean;
139
308
  }
140
309
 
141
- export interface TextInputOptions extends WithEmptyTypeText {
310
+ export interface TextInputOptions
311
+ extends WithEmptyTypeText,
312
+ WithTextValidation,
313
+ WithRequiredValidation {
142
314
  /**
143
315
  * Text shown when this input has no value.
144
316
  */
@@ -154,17 +326,17 @@ export interface TextInput extends BaseInput {
154
326
  * Sets an input type, which controls how this input appears and behaves.
155
327
  */
156
328
  type:
157
- | 'text'
158
- | 'email'
159
- | 'disabled'
160
- | 'pinterest'
161
- | 'facebook'
162
- | 'twitter'
163
- | 'github'
164
- | 'instagram';
329
+ | 'text'
330
+ | 'email'
331
+ | 'disabled'
332
+ | 'pinterest'
333
+ | 'facebook'
334
+ | 'twitter'
335
+ | 'github'
336
+ | 'instagram';
165
337
 
166
338
  /**
167
- * Options that are specific to this `type` of input.
339
+ * Options that are specific to Text Inputs.
168
340
  */
169
341
  options?: TextInputOptions;
170
342
  }
@@ -184,12 +356,16 @@ export interface TextareaInput extends BaseInput {
184
356
  */
185
357
  type: 'textarea';
186
358
  /**
187
- * Options that are specific to this `type` of input.
359
+ * Options that are specific to Textarea Inputs.
188
360
  */
189
361
  options?: TextareaInputOptions;
190
362
  }
191
363
 
192
- export interface CodeInputOptions extends WithEmptyTypeText, SourceEditor {
364
+ export interface CodeInputOptions
365
+ extends WithEmptyTypeText,
366
+ SourceEditor,
367
+ WithTextValidation,
368
+ WithRequiredValidation {
193
369
  /**
194
370
  * Sets the maximum number of visible lines for this input, effectively controlling maximum
195
371
  * height. When the containing text exceeds this number, the input becomes a scroll area.
@@ -218,12 +394,15 @@ export interface CodeInput extends BaseInput {
218
394
  */
219
395
  type: 'code';
220
396
  /**
221
- * Options that are specific to this `type` of input.
397
+ * Options that are specific to Code Inputs.
222
398
  */
223
399
  options?: CodeInputOptions;
224
400
  }
225
401
 
226
- export interface ColorInputOptions extends WithEmptyTypeText {
402
+ export interface ColorInputOptions
403
+ extends WithEmptyTypeText,
404
+ WithTextValidation,
405
+ WithRequiredValidation {
227
406
  /**
228
407
  * Sets what format the color value is saved as. Defaults to the naming convention, or HEX if that
229
408
  * is unset.
@@ -242,7 +421,7 @@ export interface ColorInput extends BaseInput {
242
421
  */
243
422
  type: 'color';
244
423
  /**
245
- * Options that are specific to this `type` of input.
424
+ * Options that are specific to Color Inputs.
246
425
  */
247
426
  options?: ColorInputOptions;
248
427
  }
@@ -254,13 +433,29 @@ export interface BooleanInput extends Omit<BaseInput, 'options'> {
254
433
  type: 'checkbox' | 'switch';
255
434
  }
256
435
 
257
- export interface NumberInputOptions extends WithEmptyTypeNumber {
436
+ export interface NumberInputOptions extends WithEmptyTypeNumber, WithRequiredValidation {
258
437
  /**
259
- * The lowest value in the range of permitted values.
438
+ * This key defines the minimum numerical value CloudCannon will allow in an Input. When
439
+ * configured, CloudCannon will prevent you from entering a lesser numerical value. If the Input
440
+ * already contains a lesser numerical value, CloudCannon will require you to enter a valid value
441
+ * to save your changes, or discard your unsaved changes.
442
+ *
443
+ * Value can be any integer. If `options.max` is also configured, this key cannot be a greater
444
+ * number.
445
+ *
446
+ * This key has no default.
260
447
  */
261
448
  min?: number;
262
449
  /**
263
- * The greatest value in the range of permitted values.
450
+ * This key defines the maximum numerical value CloudCannon will allow in an Input. When
451
+ * configured, CloudCannon will prevent you from entering a greater numerical value. If the Input
452
+ * already contains a greater numerical value, CloudCannon will require you to enter a valid value
453
+ * to save your changes, or discard your unsaved changes.
454
+ *
455
+ * Value can be any integer. If `options.min` is also configured, this key cannot be a lesser
456
+ * number.
457
+ *
458
+ * This key has no default.
264
459
  */
265
460
  max?: number;
266
461
  /**
@@ -276,20 +471,32 @@ export interface NumberInput extends BaseInput {
276
471
  */
277
472
  type: 'number';
278
473
  /**
279
- * Options that are specific to this `type` of input.
474
+ * Options that are specific to this Number Inputs.
280
475
  */
281
476
  options?: NumberInputOptions;
282
477
  }
283
478
 
284
479
  export interface RangeInputOptions extends NumberInputOptions {
285
480
  /**
286
- * The lowest value in the range of permitted values.
481
+ * This key defines the minimum numerical value CloudCannon will allow in an Input. When
482
+ * configured, CloudCannon will prevent you from entering a lesser numerical value. If the Input
483
+ * already contains a lesser numerical value, CloudCannon will require you to enter a valid value
484
+ * to save your changes, or discard your unsaved changes.
485
+ *
486
+ * Value can be any integer. If `options.max` is also configured, this key cannot be a greater
487
+ * number.
287
488
  *
288
489
  * @default 0
289
490
  */
290
491
  min?: number;
291
492
  /**
292
- * The greatest value in the range of permitted values.
493
+ * This key defines the maximum numerical value CloudCannon will allow in an Input. When
494
+ * configured, CloudCannon will prevent you from entering a greater numerical value. If the Input
495
+ * already contains a greater numerical value, CloudCannon will require you to enter a valid value
496
+ * to save your changes, or discard your unsaved changes.
497
+ *
498
+ * Value can be any integer. If `options.min` is also configured, this key cannot be a lesser
499
+ * number.
293
500
  *
294
501
  * @default 10
295
502
  */
@@ -309,12 +516,17 @@ export interface RangeInput extends BaseInput {
309
516
  */
310
517
  type: 'range';
311
518
  /**
312
- * Options that are specific to this `type` of input.
519
+ * Options that are specific to Range Inputs.
313
520
  */
314
521
  options?: RangeInputOptions;
315
522
  }
316
523
 
317
- export interface RichTextInputOptions extends WithEmptyTypeText, ImageResizeable, BlockEditable {
524
+ export interface RichTextInputOptions
525
+ extends WithEmptyTypeText,
526
+ ImageResizeable,
527
+ BlockEditable,
528
+ WithTextValidation,
529
+ WithRequiredValidation {
318
530
  /**
319
531
  * Shows or hides the resize handler to vertically resize the input.
320
532
  *
@@ -335,7 +547,7 @@ export interface RichTextInput extends BaseInput {
335
547
  */
336
548
  type: 'html' | 'markdown';
337
549
  /**
338
- * Options that are specific to this `type` of input.
550
+ * Options that are specific to Rich Text Inputs.
339
551
  */
340
552
  options?: RichTextInputOptions;
341
553
  }
@@ -348,6 +560,30 @@ export interface DateInputOptions extends WithEmptyTypeText {
348
560
  * @default Etc/UTC
349
561
  */
350
562
  timezone?: Timezone;
563
+ /**
564
+ * This key defines the earliest date and time, inclusive, that CloudCannon will allow in an
565
+ * Input. When configured, CloudCannon will prevent you from selecting an earlier date and time.
566
+ * If the Input already contains an earlier date and time, CloudCannon will require you to change
567
+ * it to a valid value to save your changes, or discard your unsaved changes.
568
+ *
569
+ * Value must be in ISO8601 format. If `options.end_before` is also configured, this key cannot be
570
+ * a later date and time.
571
+ *
572
+ * This key has no default.
573
+ */
574
+ start_from?: Date;
575
+ /**
576
+ * This key defines the date and time, exclusive, that CloudCannon will allow in an Input. When
577
+ * configured, CloudCannon will prevent you from selecting a later date and time. If the Input
578
+ * already contains a later date and time, CloudCannon will require you to change it to a valid
579
+ * value to save your changes, or discard your unsaved changes.
580
+ *
581
+ * Value must be in ISO8601 format. If options.start_from is also configured, this key cannot be
582
+ * an earlier date and time.
583
+ *
584
+ * This key has no default.
585
+ */
586
+ end_before?: Date;
351
587
  }
352
588
 
353
589
  export interface DateInput extends BaseInput {
@@ -369,10 +605,15 @@ export interface TimeInput extends BaseInput {
369
605
  /**
370
606
  * Options that are specific to Time inputs.
371
607
  */
372
- options?: WithEmptyTypeText;
608
+ options?: WithEmptyTypeText & WithRequiredValidation;
373
609
  }
374
610
 
375
- export interface FileInputOptions extends WithEmptyTypeText, WithPaths, ImageResizeable {
611
+ export interface FileInputOptions
612
+ extends WithEmptyTypeText,
613
+ WithPaths,
614
+ ImageResizeable,
615
+ WithTextValidation,
616
+ WithRequiredValidation {
376
617
  /**
377
618
  * Restricts which file types are available to select or upload to this input. Accepted format is
378
619
  * an array or comma-separated string of MIME types. The special value '*' means any type is
@@ -451,7 +692,10 @@ export interface UrlInput extends BaseInput {
451
692
  options?: UrlInputOptions;
452
693
  }
453
694
 
454
- export interface SelectInputOptions extends WithPreview, WithPickerPreview {
695
+ export interface SharedSelectInputOptions
696
+ extends WithPreview,
697
+ WithPickerPreview,
698
+ WithRequiredValidation {
455
699
  /**
456
700
  * Allows new text values to be created at edit time.
457
701
  *
@@ -486,29 +730,37 @@ export interface SelectInputOptions extends WithPreview, WithPickerPreview {
486
730
  picker_view?: 'card' | 'text' | 'gallery' | 'gallery-left';
487
731
  }
488
732
 
733
+ export type SelectInputOptions = SharedSelectInputOptions & WithEmptyTypeText & WithTextValidation;
734
+
489
735
  export interface SelectInput extends BaseInput {
490
736
  /**
491
737
  * Sets an input type, which controls how this input appears and behaves.
492
738
  */
493
739
  type: 'select';
494
740
  /**
495
- * Options that are specific to this `type` of input.
741
+ * Options that are specific to Select Inputs.
496
742
  */
497
- options?: SelectInputOptions & WithEmptyTypeText;
743
+ options?: SelectInputOptions;
498
744
  }
499
745
 
746
+ export type MultiselectInputOptions = SharedSelectInputOptions &
747
+ WithEmptyTypeArray &
748
+ WithArrayValidation &
749
+ WithArrayControlOptions;
750
+
500
751
  export interface MultiselectInput extends BaseInput {
501
752
  /**
502
753
  * Sets an input type, which controls how this input appears and behaves.
503
754
  */
504
755
  type: 'multiselect';
505
756
  /**
506
- * Options that are specific to this `type` of input.
757
+ * Options that are specific to Multiselect Inputs.
507
758
  */
508
- options?: SelectInputOptions & WithEmptyTypeArray;
759
+ options?: MultiselectInputOptions;
509
760
  }
510
761
 
511
- export interface ChoiceInputOptions extends Omit<SelectInputOptions, 'allow_create'> { }
762
+ export type SharedChoiceInputOptions = Omit<SharedSelectInputOptions, 'allow_create'>;
763
+ export type ChoiceInputOptions = SharedChoiceInputOptions & WithEmptyTypeText & WithTextValidation;
512
764
 
513
765
  export interface ChoiceInput extends BaseInput {
514
766
  /**
@@ -516,20 +768,24 @@ export interface ChoiceInput extends BaseInput {
516
768
  */
517
769
  type: 'choice';
518
770
  /**
519
- * Options that are specific to this `type` of input.
771
+ * Options that are specific to Choice Inputs.
520
772
  */
521
- options?: ChoiceInputOptions & WithEmptyTypeText;
773
+ options?: ChoiceInputOptions;
522
774
  }
523
775
 
776
+ export type MultichoiceInputOptions = SharedChoiceInputOptions &
777
+ WithEmptyTypeArray &
778
+ WithArrayValidation;
779
+
524
780
  export interface MultichoiceInput extends BaseInput {
525
781
  /**
526
782
  * Sets an input type, which controls how this input appears and behaves.
527
783
  */
528
784
  type: 'multichoice';
529
785
  /**
530
- * Options that are specific to this `type` of input.
786
+ * Options that are specific to Multichoice Inputs.
531
787
  */
532
- options?: ChoiceInputOptions & WithEmptyTypeArray;
788
+ options?: MultichoiceInputOptions;
533
789
  }
534
790
 
535
791
  export interface ObjectInputGroup {
@@ -558,7 +814,10 @@ export interface ObjectInputGroup {
558
814
  documentation?: Documentation;
559
815
  }
560
816
 
561
- export interface ObjectInputOptions extends WithEmptyTypeObject, WithPreview {
817
+ export interface ObjectInputOptions
818
+ extends WithEmptyTypeObject,
819
+ WithPreview,
820
+ WithRequiredValidation {
562
821
  /**
563
822
  * Changes the appearance and behavior of the input.
564
823
  *
@@ -621,12 +880,16 @@ export interface ObjectInput extends BaseInput {
621
880
  */
622
881
  type: 'object';
623
882
  /**
624
- * Options that are specific to this `type` of input.
883
+ * Options that are specific to Object Inputs.
625
884
  */
626
885
  options?: ObjectInputOptions;
627
886
  }
628
887
 
629
- export interface ArrayInputOptions extends WithEmptyTypeArray {
888
+ export interface ArrayInputOptions
889
+ extends WithEmptyTypeArray,
890
+ WithRequiredValidation,
891
+ WithArrayValidation,
892
+ WithArrayControlOptions {
630
893
  /**
631
894
  * Provides data formats for value of this object. When choosing an item, team members are
632
895
  * prompted to choose from a number of values you have defined.
@@ -640,7 +903,7 @@ export interface ArrayInput extends BaseInput {
640
903
  */
641
904
  type: 'array';
642
905
  /**
643
- * Options that are specific to this `type` of input.
906
+ * Options that are specific to Array Inputs.
644
907
  */
645
908
  options?: ArrayInputOptions;
646
909
  }