@cloudcannon/configuration-types 0.0.31 → 0.0.32

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.32",
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,154 @@ 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
+
47
195
  interface WithEmptyTypeText {
48
196
  /**
49
197
  * Set how an ‘empty’ value will be saved. Does not apply to existing empty values.
@@ -138,7 +286,10 @@ export interface BaseInput {
138
286
  cascade?: boolean;
139
287
  }
140
288
 
141
- export interface TextInputOptions extends WithEmptyTypeText {
289
+ export interface TextInputOptions
290
+ extends WithEmptyTypeText,
291
+ WithTextValidation,
292
+ WithRequiredValidation {
142
293
  /**
143
294
  * Text shown when this input has no value.
144
295
  */
@@ -154,17 +305,17 @@ export interface TextInput extends BaseInput {
154
305
  * Sets an input type, which controls how this input appears and behaves.
155
306
  */
156
307
  type:
157
- | 'text'
158
- | 'email'
159
- | 'disabled'
160
- | 'pinterest'
161
- | 'facebook'
162
- | 'twitter'
163
- | 'github'
164
- | 'instagram';
308
+ | 'text'
309
+ | 'email'
310
+ | 'disabled'
311
+ | 'pinterest'
312
+ | 'facebook'
313
+ | 'twitter'
314
+ | 'github'
315
+ | 'instagram';
165
316
 
166
317
  /**
167
- * Options that are specific to this `type` of input.
318
+ * Options that are specific to Text Inputs.
168
319
  */
169
320
  options?: TextInputOptions;
170
321
  }
@@ -184,12 +335,16 @@ export interface TextareaInput extends BaseInput {
184
335
  */
185
336
  type: 'textarea';
186
337
  /**
187
- * Options that are specific to this `type` of input.
338
+ * Options that are specific to Textarea Inputs.
188
339
  */
189
340
  options?: TextareaInputOptions;
190
341
  }
191
342
 
192
- export interface CodeInputOptions extends WithEmptyTypeText, SourceEditor {
343
+ export interface CodeInputOptions
344
+ extends WithEmptyTypeText,
345
+ SourceEditor,
346
+ WithTextValidation,
347
+ WithRequiredValidation {
193
348
  /**
194
349
  * Sets the maximum number of visible lines for this input, effectively controlling maximum
195
350
  * height. When the containing text exceeds this number, the input becomes a scroll area.
@@ -218,12 +373,15 @@ export interface CodeInput extends BaseInput {
218
373
  */
219
374
  type: 'code';
220
375
  /**
221
- * Options that are specific to this `type` of input.
376
+ * Options that are specific to Code Inputs.
222
377
  */
223
378
  options?: CodeInputOptions;
224
379
  }
225
380
 
226
- export interface ColorInputOptions extends WithEmptyTypeText {
381
+ export interface ColorInputOptions
382
+ extends WithEmptyTypeText,
383
+ WithTextValidation,
384
+ WithRequiredValidation {
227
385
  /**
228
386
  * Sets what format the color value is saved as. Defaults to the naming convention, or HEX if that
229
387
  * is unset.
@@ -242,7 +400,7 @@ export interface ColorInput extends BaseInput {
242
400
  */
243
401
  type: 'color';
244
402
  /**
245
- * Options that are specific to this `type` of input.
403
+ * Options that are specific to Color Inputs.
246
404
  */
247
405
  options?: ColorInputOptions;
248
406
  }
@@ -254,13 +412,29 @@ export interface BooleanInput extends Omit<BaseInput, 'options'> {
254
412
  type: 'checkbox' | 'switch';
255
413
  }
256
414
 
257
- export interface NumberInputOptions extends WithEmptyTypeNumber {
415
+ export interface NumberInputOptions extends WithEmptyTypeNumber, WithRequiredValidation {
258
416
  /**
259
- * The lowest value in the range of permitted values.
417
+ * This key defines the minimum numerical value CloudCannon will allow in an Input. When
418
+ * configured, CloudCannon will prevent you from entering a lesser numerical value. If the Input
419
+ * already contains a lesser numerical value, CloudCannon will require you to enter a valid value
420
+ * to save your changes, or discard your unsaved changes.
421
+ *
422
+ * Value can be any integer. If `options.max` is also configured, this key cannot be a greater
423
+ * number.
424
+ *
425
+ * This key has no default.
260
426
  */
261
427
  min?: number;
262
428
  /**
263
- * The greatest value in the range of permitted values.
429
+ * This key defines the maximum numerical value CloudCannon will allow in an Input. When
430
+ * configured, CloudCannon will prevent you from entering a greater numerical value. If the Input
431
+ * already contains a greater numerical value, CloudCannon will require you to enter a valid value
432
+ * to save your changes, or discard your unsaved changes.
433
+ *
434
+ * Value can be any integer. If `options.min` is also configured, this key cannot be a lesser
435
+ * number.
436
+ *
437
+ * This key has no default.
264
438
  */
265
439
  max?: number;
266
440
  /**
@@ -276,20 +450,32 @@ export interface NumberInput extends BaseInput {
276
450
  */
277
451
  type: 'number';
278
452
  /**
279
- * Options that are specific to this `type` of input.
453
+ * Options that are specific to this Number Inputs.
280
454
  */
281
455
  options?: NumberInputOptions;
282
456
  }
283
457
 
284
458
  export interface RangeInputOptions extends NumberInputOptions {
285
459
  /**
286
- * The lowest value in the range of permitted values.
460
+ * This key defines the minimum numerical value CloudCannon will allow in an Input. When
461
+ * configured, CloudCannon will prevent you from entering a lesser numerical value. If the Input
462
+ * already contains a lesser numerical value, CloudCannon will require you to enter a valid value
463
+ * to save your changes, or discard your unsaved changes.
464
+ *
465
+ * Value can be any integer. If `options.max` is also configured, this key cannot be a greater
466
+ * number.
287
467
  *
288
468
  * @default 0
289
469
  */
290
470
  min?: number;
291
471
  /**
292
- * The greatest value in the range of permitted values.
472
+ * This key defines the maximum numerical value CloudCannon will allow in an Input. When
473
+ * configured, CloudCannon will prevent you from entering a greater numerical value. If the Input
474
+ * already contains a greater numerical value, CloudCannon will require you to enter a valid value
475
+ * to save your changes, or discard your unsaved changes.
476
+ *
477
+ * Value can be any integer. If `options.min` is also configured, this key cannot be a lesser
478
+ * number.
293
479
  *
294
480
  * @default 10
295
481
  */
@@ -309,12 +495,17 @@ export interface RangeInput extends BaseInput {
309
495
  */
310
496
  type: 'range';
311
497
  /**
312
- * Options that are specific to this `type` of input.
498
+ * Options that are specific to Range Inputs.
313
499
  */
314
500
  options?: RangeInputOptions;
315
501
  }
316
502
 
317
- export interface RichTextInputOptions extends WithEmptyTypeText, ImageResizeable, BlockEditable {
503
+ export interface RichTextInputOptions
504
+ extends WithEmptyTypeText,
505
+ ImageResizeable,
506
+ BlockEditable,
507
+ WithTextValidation,
508
+ WithRequiredValidation {
318
509
  /**
319
510
  * Shows or hides the resize handler to vertically resize the input.
320
511
  *
@@ -335,7 +526,7 @@ export interface RichTextInput extends BaseInput {
335
526
  */
336
527
  type: 'html' | 'markdown';
337
528
  /**
338
- * Options that are specific to this `type` of input.
529
+ * Options that are specific to Rich Text Inputs.
339
530
  */
340
531
  options?: RichTextInputOptions;
341
532
  }
@@ -348,6 +539,30 @@ export interface DateInputOptions extends WithEmptyTypeText {
348
539
  * @default Etc/UTC
349
540
  */
350
541
  timezone?: Timezone;
542
+ /**
543
+ * This key defines the earliest date and time, inclusive, that CloudCannon will allow in an
544
+ * Input. When configured, CloudCannon will prevent you from selecting an earlier date and time.
545
+ * If the Input already contains an earlier date and time, CloudCannon will require you to change
546
+ * it to a valid value to save your changes, or discard your unsaved changes.
547
+ *
548
+ * Value must be in ISO8601 format. If `options.end_before` is also configured, this key cannot be
549
+ * a later date and time.
550
+ *
551
+ * This key has no default.
552
+ */
553
+ start_from?: Date;
554
+ /**
555
+ * This key defines the date and time, exclusive, that CloudCannon will allow in an Input. When
556
+ * configured, CloudCannon will prevent you from selecting a later date and time. If the Input
557
+ * already contains a later date and time, CloudCannon will require you to change it to a valid
558
+ * value to save your changes, or discard your unsaved changes.
559
+ *
560
+ * Value must be in ISO8601 format. If options.start_from is also configured, this key cannot be
561
+ * an earlier date and time.
562
+ *
563
+ * This key has no default.
564
+ */
565
+ end_before?: Date;
351
566
  }
352
567
 
353
568
  export interface DateInput extends BaseInput {
@@ -369,10 +584,15 @@ export interface TimeInput extends BaseInput {
369
584
  /**
370
585
  * Options that are specific to Time inputs.
371
586
  */
372
- options?: WithEmptyTypeText;
587
+ options?: WithEmptyTypeText & WithRequiredValidation;
373
588
  }
374
589
 
375
- export interface FileInputOptions extends WithEmptyTypeText, WithPaths, ImageResizeable {
590
+ export interface FileInputOptions
591
+ extends WithEmptyTypeText,
592
+ WithPaths,
593
+ ImageResizeable,
594
+ WithTextValidation,
595
+ WithRequiredValidation {
376
596
  /**
377
597
  * Restricts which file types are available to select or upload to this input. Accepted format is
378
598
  * an array or comma-separated string of MIME types. The special value '*' means any type is
@@ -492,9 +712,34 @@ export interface SelectInput extends BaseInput {
492
712
  */
493
713
  type: 'select';
494
714
  /**
495
- * Options that are specific to this `type` of input.
715
+ * Options that are specific to Select Inputs.
716
+ */
717
+ options?: SelectInputOptions & WithEmptyTypeText & WithTextValidation & WithRequiredValidation;
718
+ }
719
+
720
+ export interface MultiselectInputOptions
721
+ extends WithEmptyTypeArray,
722
+ WithArrayValidation,
723
+ WithRequiredValidation {
724
+ /**
725
+ * Hides the add button, and context menu actions on each array item for adding new items to this
726
+ * Input.
727
+ *
728
+ * @default false
729
+ */
730
+ disable_add?: boolean;
731
+ /**
732
+ * Hides the context menu actions on each array item for removing them.
733
+ *
734
+ * @default false
496
735
  */
497
- options?: SelectInputOptions & WithEmptyTypeText;
736
+ disable_remove?: boolean;
737
+ /**
738
+ * Hides the controls on each array item for moving them.
739
+ *
740
+ * @default false
741
+ */
742
+ disable_reorder?: boolean;
498
743
  }
499
744
 
500
745
  export interface MultiselectInput extends BaseInput {
@@ -503,12 +748,12 @@ export interface MultiselectInput extends BaseInput {
503
748
  */
504
749
  type: 'multiselect';
505
750
  /**
506
- * Options that are specific to this `type` of input.
751
+ * Options that are specific to Multiselect Inputs.
507
752
  */
508
- options?: SelectInputOptions & WithEmptyTypeArray;
753
+ options?: MultiselectInputOptions;
509
754
  }
510
755
 
511
- export interface ChoiceInputOptions extends Omit<SelectInputOptions, 'allow_create'> { }
756
+ export type ChoiceInputOptions = Omit<SelectInputOptions, 'allow_create'>;
512
757
 
513
758
  export interface ChoiceInput extends BaseInput {
514
759
  /**
@@ -516,9 +761,9 @@ export interface ChoiceInput extends BaseInput {
516
761
  */
517
762
  type: 'choice';
518
763
  /**
519
- * Options that are specific to this `type` of input.
764
+ * Options that are specific to Choice Inputs.
520
765
  */
521
- options?: ChoiceInputOptions & WithEmptyTypeText;
766
+ options?: ChoiceInputOptions & WithEmptyTypeText & WithTextValidation & WithRequiredValidation;
522
767
  }
523
768
 
524
769
  export interface MultichoiceInput extends BaseInput {
@@ -527,9 +772,9 @@ export interface MultichoiceInput extends BaseInput {
527
772
  */
528
773
  type: 'multichoice';
529
774
  /**
530
- * Options that are specific to this `type` of input.
775
+ * Options that are specific to Multichoice Inputs.
531
776
  */
532
- options?: ChoiceInputOptions & WithEmptyTypeArray;
777
+ options?: ChoiceInputOptions & WithEmptyTypeArray & WithArrayValidation & WithRequiredValidation;
533
778
  }
534
779
 
535
780
  export interface ObjectInputGroup {
@@ -558,7 +803,10 @@ export interface ObjectInputGroup {
558
803
  documentation?: Documentation;
559
804
  }
560
805
 
561
- export interface ObjectInputOptions extends WithEmptyTypeObject, WithPreview {
806
+ export interface ObjectInputOptions
807
+ extends WithEmptyTypeObject,
808
+ WithPreview,
809
+ WithRequiredValidation {
562
810
  /**
563
811
  * Changes the appearance and behavior of the input.
564
812
  *
@@ -621,17 +869,39 @@ export interface ObjectInput extends BaseInput {
621
869
  */
622
870
  type: 'object';
623
871
  /**
624
- * Options that are specific to this `type` of input.
872
+ * Options that are specific to Object Inputs.
625
873
  */
626
874
  options?: ObjectInputOptions;
627
875
  }
628
876
 
629
- export interface ArrayInputOptions extends WithEmptyTypeArray {
877
+ export interface ArrayInputOptions
878
+ extends WithEmptyTypeArray,
879
+ WithRequiredValidation,
880
+ WithArrayValidation {
630
881
  /**
631
882
  * Provides data formats for value of this object. When choosing an item, team members are
632
883
  * prompted to choose from a number of values you have defined.
633
884
  */
634
885
  structures?: string | Structure;
886
+ /**
887
+ * Hides the add button, and context menu actions on each array item for adding new items to this
888
+ * Input.
889
+ *
890
+ * @default false
891
+ */
892
+ disable_add?: boolean;
893
+ /**
894
+ * Hides the context menu actions on each array item for removing them.
895
+ *
896
+ * @default false
897
+ */
898
+ disable_remove?: boolean;
899
+ /**
900
+ * Hides the controls on each array item for moving them.
901
+ *
902
+ * @default false
903
+ */
904
+ disable_reorder?: boolean;
635
905
  }
636
906
 
637
907
  export interface ArrayInput extends BaseInput {
@@ -640,7 +910,7 @@ export interface ArrayInput extends BaseInput {
640
910
  */
641
911
  type: 'array';
642
912
  /**
643
- * Options that are specific to this `type` of input.
913
+ * Options that are specific to Array Inputs.
644
914
  */
645
915
  options?: ArrayInputOptions;
646
916
  }