@datocms/cma-client 5.1.11 → 5.1.13
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/README.md +313 -178
- package/dist/cjs/fieldTypes/file.js +6 -6
- package/dist/cjs/fieldTypes/gallery.js +7 -7
- package/dist/cjs/fieldTypes/rich_text.js +14 -12
- package/dist/cjs/fieldTypes/rich_text.js.map +1 -1
- package/dist/cjs/fieldTypes/schema.js +3 -0
- package/dist/cjs/fieldTypes/schema.js.map +1 -0
- package/dist/cjs/fieldTypes/single_block.js +13 -12
- package/dist/cjs/fieldTypes/single_block.js.map +1 -1
- package/dist/cjs/fieldTypes/structured_text.js +13 -12
- package/dist/cjs/fieldTypes/structured_text.js.map +1 -1
- package/dist/cjs/generated/Client.js +1 -1
- package/dist/cjs/generated/resources/Item.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/cjs/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/cjs/generated/resources/Upload.js.map +1 -1
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utilities/buildBlockRecord.js +1 -46
- package/dist/cjs/utilities/buildBlockRecord.js.map +1 -1
- package/dist/cjs/utilities/duplicateBlockRecord.js +50 -0
- package/dist/cjs/utilities/duplicateBlockRecord.js.map +1 -0
- package/dist/cjs/utilities/inspectItem.js +50 -20
- package/dist/cjs/utilities/inspectItem.js.map +1 -1
- package/dist/cjs/utilities/nonRecursiveBlocks.js +1 -170
- package/dist/cjs/utilities/nonRecursiveBlocks.js.map +1 -1
- package/dist/cjs/utilities/recursiveBlocks.js +52 -112
- package/dist/cjs/utilities/recursiveBlocks.js.map +1 -1
- package/dist/esm/fieldTypes/file.d.ts +3 -3
- package/dist/esm/fieldTypes/file.js +3 -3
- package/dist/esm/fieldTypes/gallery.d.ts +5 -5
- package/dist/esm/fieldTypes/gallery.js +5 -5
- package/dist/esm/fieldTypes/rich_text.d.ts +8 -9
- package/dist/esm/fieldTypes/rich_text.js +9 -7
- package/dist/esm/fieldTypes/rich_text.js.map +1 -1
- package/dist/esm/fieldTypes/schema.d.ts +59 -0
- package/dist/esm/fieldTypes/schema.js +2 -0
- package/dist/esm/fieldTypes/schema.js.map +1 -0
- package/dist/esm/fieldTypes/single_block.d.ts +30 -15
- package/dist/esm/fieldTypes/single_block.js +8 -7
- package/dist/esm/fieldTypes/single_block.js.map +1 -1
- package/dist/esm/fieldTypes/structured_text.d.ts +14 -15
- package/dist/esm/fieldTypes/structured_text.js +8 -7
- package/dist/esm/fieldTypes/structured_text.js.map +1 -1
- package/dist/esm/generated/ApiTypes.d.ts +94 -980
- package/dist/esm/generated/Client.js +1 -1
- package/dist/esm/generated/RawApiTypes.d.ts +160 -999
- package/dist/esm/generated/resources/Field.d.ts +300 -300
- package/dist/esm/generated/resources/Item.d.ts +34 -34
- package/dist/esm/generated/resources/Item.js.map +1 -1
- package/dist/esm/generated/resources/ItemVersion.d.ts +3 -1
- package/dist/esm/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/esm/generated/resources/ScheduledPublication.js.map +1 -1
- package/dist/esm/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/esm/generated/resources/ScheduledUnpublishing.js.map +1 -1
- package/dist/esm/generated/resources/Upload.d.ts +6 -6
- package/dist/esm/generated/resources/Upload.js.map +1 -1
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utilities/buildBlockRecord.d.ts +11 -5
- package/dist/esm/utilities/buildBlockRecord.js +0 -44
- package/dist/esm/utilities/buildBlockRecord.js.map +1 -1
- package/dist/esm/utilities/duplicateBlockRecord.d.ts +6 -0
- package/dist/esm/utilities/duplicateBlockRecord.js +46 -0
- package/dist/esm/utilities/duplicateBlockRecord.js.map +1 -0
- package/dist/esm/utilities/inspectItem.d.ts +3 -3
- package/dist/esm/utilities/inspectItem.js +28 -21
- package/dist/esm/utilities/inspectItem.js.map +1 -1
- package/dist/esm/utilities/itemDefinition.d.ts +25 -27
- package/dist/esm/utilities/nonRecursiveBlocks.d.ts +10 -75
- package/dist/esm/utilities/nonRecursiveBlocks.js +1 -164
- package/dist/esm/utilities/nonRecursiveBlocks.js.map +1 -1
- package/dist/esm/utilities/recursiveBlocks.d.ts +53 -23
- package/dist/esm/utilities/recursiveBlocks.js +52 -112
- package/dist/esm/utilities/recursiveBlocks.js.map +1 -1
- package/dist/types/fieldTypes/file.d.ts +3 -3
- package/dist/types/fieldTypes/gallery.d.ts +5 -5
- package/dist/types/fieldTypes/rich_text.d.ts +8 -9
- package/dist/types/fieldTypes/schema.d.ts +59 -0
- package/dist/types/fieldTypes/single_block.d.ts +30 -15
- package/dist/types/fieldTypes/structured_text.d.ts +14 -15
- package/dist/types/generated/ApiTypes.d.ts +94 -980
- package/dist/types/generated/RawApiTypes.d.ts +160 -999
- package/dist/types/generated/resources/Field.d.ts +300 -300
- package/dist/types/generated/resources/Item.d.ts +34 -34
- package/dist/types/generated/resources/ItemVersion.d.ts +3 -1
- package/dist/types/generated/resources/ScheduledPublication.d.ts +3 -3
- package/dist/types/generated/resources/ScheduledUnpublishing.d.ts +3 -3
- package/dist/types/generated/resources/Upload.d.ts +6 -6
- package/dist/types/index.d.ts +1 -0
- package/dist/types/utilities/buildBlockRecord.d.ts +11 -5
- package/dist/types/utilities/duplicateBlockRecord.d.ts +6 -0
- package/dist/types/utilities/inspectItem.d.ts +3 -3
- package/dist/types/utilities/itemDefinition.d.ts +25 -27
- package/dist/types/utilities/nonRecursiveBlocks.d.ts +10 -75
- package/dist/types/utilities/recursiveBlocks.d.ts +53 -23
- package/package.json +4 -4
- package/src/fieldTypes/file.ts +6 -6
- package/src/fieldTypes/gallery.ts +10 -10
- package/src/fieldTypes/rich_text.ts +26 -24
- package/src/fieldTypes/schema.ts +657 -0
- package/src/fieldTypes/single_block.ts +61 -38
- package/src/fieldTypes/structured_text.ts +57 -51
- package/src/generated/ApiTypes.ts +221 -1880
- package/src/generated/Client.ts +1 -1
- package/src/generated/RawApiTypes.ts +276 -2113
- package/src/generated/resources/Item.ts +93 -187
- package/src/generated/resources/ScheduledPublication.ts +4 -15
- package/src/generated/resources/ScheduledUnpublishing.ts +4 -15
- package/src/generated/resources/Upload.ts +9 -32
- package/src/index.ts +1 -0
- package/src/utilities/buildBlockRecord.ts +16 -56
- package/src/utilities/duplicateBlockRecord.ts +53 -0
- package/src/utilities/inspectItem.ts +64 -52
- package/src/utilities/itemDefinition.ts +109 -98
- package/src/utilities/nonRecursiveBlocks.ts +25 -279
- package/src/utilities/recursiveBlocks.ts +337 -72
|
@@ -0,0 +1,657 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BooleanFieldAppearance,
|
|
3
|
+
BooleanFieldValidators,
|
|
4
|
+
BooleanFieldValue,
|
|
5
|
+
ColorFieldAppearance,
|
|
6
|
+
ColorFieldValidators,
|
|
7
|
+
ColorFieldValue,
|
|
8
|
+
DateFieldAppearance,
|
|
9
|
+
DateFieldValidators,
|
|
10
|
+
DateFieldValue,
|
|
11
|
+
DateTimeFieldAppearance,
|
|
12
|
+
DateTimeFieldValidators,
|
|
13
|
+
DateTimeFieldValue,
|
|
14
|
+
FileFieldAppearance,
|
|
15
|
+
FileFieldValidators,
|
|
16
|
+
FloatFieldAppearance,
|
|
17
|
+
FloatFieldValidators,
|
|
18
|
+
FloatFieldValue,
|
|
19
|
+
GalleryFieldAppearance,
|
|
20
|
+
GalleryFieldValidators,
|
|
21
|
+
IntegerFieldAppearance,
|
|
22
|
+
IntegerFieldValidators,
|
|
23
|
+
IntegerFieldValue,
|
|
24
|
+
JsonFieldAppearance,
|
|
25
|
+
JsonFieldValidators,
|
|
26
|
+
JsonFieldValue,
|
|
27
|
+
LatLonFieldAppearance,
|
|
28
|
+
LatLonFieldValidators,
|
|
29
|
+
LatLonFieldValue,
|
|
30
|
+
LinkFieldAppearance,
|
|
31
|
+
LinkFieldValidators,
|
|
32
|
+
LinksFieldAppearance,
|
|
33
|
+
LinksFieldValidators,
|
|
34
|
+
RichTextFieldAppearance,
|
|
35
|
+
RichTextFieldValidators,
|
|
36
|
+
SeoFieldAppearance,
|
|
37
|
+
SeoFieldValidators,
|
|
38
|
+
SingleBlockFieldAppearance,
|
|
39
|
+
SingleBlockFieldValidators,
|
|
40
|
+
SlugFieldAppearance,
|
|
41
|
+
SlugFieldValidators,
|
|
42
|
+
StringFieldAppearance,
|
|
43
|
+
StringFieldValidators,
|
|
44
|
+
StringFieldValue,
|
|
45
|
+
StructuredTextFieldAppearance,
|
|
46
|
+
StructuredTextFieldValidators,
|
|
47
|
+
TextFieldAppearance,
|
|
48
|
+
TextFieldValidators,
|
|
49
|
+
TextFieldValue,
|
|
50
|
+
VideoFieldAppearance,
|
|
51
|
+
VideoFieldValidators,
|
|
52
|
+
} from '..';
|
|
53
|
+
import type { FieldAttributesStableShell } from '../generated/RawApiTypes';
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Enhanced appearance configuration with field-specific types and addon support
|
|
57
|
+
*/
|
|
58
|
+
type FieldAppearanceConfig<TAppearance> = TAppearance &
|
|
59
|
+
Omit<FieldAttributesStableShell['appearance'], keyof TAppearance>;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Base field configuration for attributes (non-localized), extending the original RawApiTypes
|
|
63
|
+
*/
|
|
64
|
+
type NonLocalizedFieldAttributesForFieldType<
|
|
65
|
+
SourceType,
|
|
66
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
67
|
+
FieldValue,
|
|
68
|
+
FieldValidators,
|
|
69
|
+
FieldAppearance,
|
|
70
|
+
> = Omit<
|
|
71
|
+
SourceType,
|
|
72
|
+
'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'
|
|
73
|
+
> & {
|
|
74
|
+
field_type: FieldType;
|
|
75
|
+
localized: false;
|
|
76
|
+
default_value: FieldValue;
|
|
77
|
+
validators: FieldValidators;
|
|
78
|
+
appearance: FieldAppearanceConfig<FieldAppearance>;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Base field configuration for attributes (localized), extending the original RawApiTypes
|
|
83
|
+
*/
|
|
84
|
+
type LocalizedFieldAttributesForFieldType<
|
|
85
|
+
SourceType,
|
|
86
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
87
|
+
FieldValue,
|
|
88
|
+
FieldValidators,
|
|
89
|
+
FieldAppearance,
|
|
90
|
+
> = Omit<
|
|
91
|
+
SourceType,
|
|
92
|
+
'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'
|
|
93
|
+
> & {
|
|
94
|
+
field_type: FieldType;
|
|
95
|
+
localized: true;
|
|
96
|
+
default_value: Record<string, FieldValue>;
|
|
97
|
+
validators: FieldValidators;
|
|
98
|
+
appearance: FieldAppearanceConfig<FieldAppearance>;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Union of localized and non-localized field configurations for attributes
|
|
103
|
+
*/
|
|
104
|
+
type FieldAttributesForFieldType<
|
|
105
|
+
SourceType,
|
|
106
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
107
|
+
FieldValue,
|
|
108
|
+
FieldValidators,
|
|
109
|
+
FieldAppearance,
|
|
110
|
+
> =
|
|
111
|
+
| NonLocalizedFieldAttributesForFieldType<
|
|
112
|
+
SourceType,
|
|
113
|
+
FieldType,
|
|
114
|
+
FieldValue,
|
|
115
|
+
FieldValidators,
|
|
116
|
+
FieldAppearance
|
|
117
|
+
>
|
|
118
|
+
| LocalizedFieldAttributesForFieldType<
|
|
119
|
+
SourceType,
|
|
120
|
+
FieldType,
|
|
121
|
+
FieldValue,
|
|
122
|
+
FieldValidators,
|
|
123
|
+
FieldAppearance
|
|
124
|
+
>;
|
|
125
|
+
|
|
126
|
+
export type GenericFieldAttributes<SourceType> =
|
|
127
|
+
| FieldAttributesForFieldType<
|
|
128
|
+
SourceType,
|
|
129
|
+
'boolean',
|
|
130
|
+
BooleanFieldValue,
|
|
131
|
+
BooleanFieldValidators,
|
|
132
|
+
BooleanFieldAppearance
|
|
133
|
+
>
|
|
134
|
+
| FieldAttributesForFieldType<
|
|
135
|
+
SourceType,
|
|
136
|
+
'color',
|
|
137
|
+
ColorFieldValue,
|
|
138
|
+
ColorFieldValidators,
|
|
139
|
+
ColorFieldAppearance
|
|
140
|
+
>
|
|
141
|
+
| FieldAttributesForFieldType<
|
|
142
|
+
SourceType,
|
|
143
|
+
'date',
|
|
144
|
+
DateFieldValue,
|
|
145
|
+
DateFieldValidators,
|
|
146
|
+
DateFieldAppearance
|
|
147
|
+
>
|
|
148
|
+
| FieldAttributesForFieldType<
|
|
149
|
+
SourceType,
|
|
150
|
+
'date_time',
|
|
151
|
+
DateTimeFieldValue,
|
|
152
|
+
DateTimeFieldValidators,
|
|
153
|
+
DateTimeFieldAppearance
|
|
154
|
+
>
|
|
155
|
+
| FieldAttributesForFieldType<
|
|
156
|
+
SourceType,
|
|
157
|
+
'file',
|
|
158
|
+
// this field type does not support default values
|
|
159
|
+
null,
|
|
160
|
+
FileFieldValidators,
|
|
161
|
+
FileFieldAppearance
|
|
162
|
+
>
|
|
163
|
+
| FieldAttributesForFieldType<
|
|
164
|
+
SourceType,
|
|
165
|
+
'float',
|
|
166
|
+
FloatFieldValue,
|
|
167
|
+
FloatFieldValidators,
|
|
168
|
+
FloatFieldAppearance
|
|
169
|
+
>
|
|
170
|
+
| FieldAttributesForFieldType<
|
|
171
|
+
SourceType,
|
|
172
|
+
'gallery',
|
|
173
|
+
// this field type does not support default values
|
|
174
|
+
null,
|
|
175
|
+
GalleryFieldValidators,
|
|
176
|
+
GalleryFieldAppearance
|
|
177
|
+
>
|
|
178
|
+
| FieldAttributesForFieldType<
|
|
179
|
+
SourceType,
|
|
180
|
+
'integer',
|
|
181
|
+
IntegerFieldValue,
|
|
182
|
+
IntegerFieldValidators,
|
|
183
|
+
IntegerFieldAppearance
|
|
184
|
+
>
|
|
185
|
+
| FieldAttributesForFieldType<
|
|
186
|
+
SourceType,
|
|
187
|
+
'json',
|
|
188
|
+
JsonFieldValue,
|
|
189
|
+
JsonFieldValidators,
|
|
190
|
+
JsonFieldAppearance
|
|
191
|
+
>
|
|
192
|
+
| FieldAttributesForFieldType<
|
|
193
|
+
SourceType,
|
|
194
|
+
'lat_lon',
|
|
195
|
+
LatLonFieldValue,
|
|
196
|
+
LatLonFieldValidators,
|
|
197
|
+
LatLonFieldAppearance
|
|
198
|
+
>
|
|
199
|
+
| FieldAttributesForFieldType<
|
|
200
|
+
SourceType,
|
|
201
|
+
'link',
|
|
202
|
+
// this field type does not support default values
|
|
203
|
+
null,
|
|
204
|
+
LinkFieldValidators,
|
|
205
|
+
LinkFieldAppearance
|
|
206
|
+
>
|
|
207
|
+
| FieldAttributesForFieldType<
|
|
208
|
+
SourceType,
|
|
209
|
+
'links',
|
|
210
|
+
// this field type does not support default values
|
|
211
|
+
null,
|
|
212
|
+
LinksFieldValidators,
|
|
213
|
+
LinksFieldAppearance
|
|
214
|
+
>
|
|
215
|
+
| FieldAttributesForFieldType<
|
|
216
|
+
SourceType,
|
|
217
|
+
'rich_text',
|
|
218
|
+
// this field type does not support default values
|
|
219
|
+
null,
|
|
220
|
+
RichTextFieldValidators,
|
|
221
|
+
RichTextFieldAppearance
|
|
222
|
+
>
|
|
223
|
+
| FieldAttributesForFieldType<
|
|
224
|
+
SourceType,
|
|
225
|
+
'seo',
|
|
226
|
+
// this field type does not support default values
|
|
227
|
+
null,
|
|
228
|
+
SeoFieldValidators,
|
|
229
|
+
SeoFieldAppearance
|
|
230
|
+
>
|
|
231
|
+
| FieldAttributesForFieldType<
|
|
232
|
+
SourceType,
|
|
233
|
+
'single_block',
|
|
234
|
+
// this field type does not support default values
|
|
235
|
+
null,
|
|
236
|
+
SingleBlockFieldValidators,
|
|
237
|
+
SingleBlockFieldAppearance
|
|
238
|
+
>
|
|
239
|
+
| FieldAttributesForFieldType<
|
|
240
|
+
SourceType,
|
|
241
|
+
'slug',
|
|
242
|
+
// this field type does not support default values
|
|
243
|
+
null,
|
|
244
|
+
SlugFieldValidators,
|
|
245
|
+
SlugFieldAppearance
|
|
246
|
+
>
|
|
247
|
+
| FieldAttributesForFieldType<
|
|
248
|
+
SourceType,
|
|
249
|
+
'string',
|
|
250
|
+
StringFieldValue,
|
|
251
|
+
StringFieldValidators,
|
|
252
|
+
StringFieldAppearance
|
|
253
|
+
>
|
|
254
|
+
| FieldAttributesForFieldType<
|
|
255
|
+
SourceType,
|
|
256
|
+
'structured_text',
|
|
257
|
+
// this field type does not support default values
|
|
258
|
+
null,
|
|
259
|
+
StructuredTextFieldValidators,
|
|
260
|
+
StructuredTextFieldAppearance
|
|
261
|
+
>
|
|
262
|
+
| FieldAttributesForFieldType<
|
|
263
|
+
SourceType,
|
|
264
|
+
'text',
|
|
265
|
+
TextFieldValue,
|
|
266
|
+
TextFieldValidators,
|
|
267
|
+
TextFieldAppearance
|
|
268
|
+
>
|
|
269
|
+
| FieldAttributesForFieldType<
|
|
270
|
+
SourceType,
|
|
271
|
+
'video',
|
|
272
|
+
// this field type does not support default values
|
|
273
|
+
null,
|
|
274
|
+
VideoFieldValidators,
|
|
275
|
+
VideoFieldAppearance
|
|
276
|
+
>;
|
|
277
|
+
|
|
278
|
+
type LocalizedFieldCreateConfigForFieldType<
|
|
279
|
+
SourceType,
|
|
280
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
281
|
+
FieldValue,
|
|
282
|
+
FieldValidators,
|
|
283
|
+
FieldAppearance,
|
|
284
|
+
> = Omit<
|
|
285
|
+
SourceType,
|
|
286
|
+
'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'
|
|
287
|
+
> & {
|
|
288
|
+
field_type: FieldType;
|
|
289
|
+
localized: true;
|
|
290
|
+
default_value?: Record<string, FieldValue>;
|
|
291
|
+
validators?: FieldValidators;
|
|
292
|
+
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
type NonLocalizedFieldCreateConfigForFieldType<
|
|
296
|
+
SourceType,
|
|
297
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
298
|
+
FieldValue,
|
|
299
|
+
FieldValidators,
|
|
300
|
+
FieldAppearance,
|
|
301
|
+
> = Omit<
|
|
302
|
+
SourceType,
|
|
303
|
+
'field_type' | 'default_value' | 'validators' | 'appearance' | 'localized'
|
|
304
|
+
> & {
|
|
305
|
+
field_type: FieldType;
|
|
306
|
+
localized?: false;
|
|
307
|
+
default_value?: FieldValue;
|
|
308
|
+
validators?: FieldValidators;
|
|
309
|
+
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
type FieldCreateConfigForFieldType<
|
|
313
|
+
SourceType,
|
|
314
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
315
|
+
FieldValue,
|
|
316
|
+
FieldValidators,
|
|
317
|
+
FieldAppearance,
|
|
318
|
+
> =
|
|
319
|
+
| LocalizedFieldCreateConfigForFieldType<
|
|
320
|
+
SourceType,
|
|
321
|
+
FieldType,
|
|
322
|
+
FieldValue,
|
|
323
|
+
FieldValidators,
|
|
324
|
+
FieldAppearance
|
|
325
|
+
>
|
|
326
|
+
| NonLocalizedFieldCreateConfigForFieldType<
|
|
327
|
+
SourceType,
|
|
328
|
+
FieldType,
|
|
329
|
+
FieldValue,
|
|
330
|
+
FieldValidators,
|
|
331
|
+
FieldAppearance
|
|
332
|
+
>;
|
|
333
|
+
|
|
334
|
+
export type FieldCreateConfig<SourceType> =
|
|
335
|
+
| FieldCreateConfigForFieldType<
|
|
336
|
+
SourceType,
|
|
337
|
+
'boolean',
|
|
338
|
+
BooleanFieldValue,
|
|
339
|
+
BooleanFieldValidators,
|
|
340
|
+
BooleanFieldAppearance
|
|
341
|
+
>
|
|
342
|
+
| FieldCreateConfigForFieldType<
|
|
343
|
+
SourceType,
|
|
344
|
+
'color',
|
|
345
|
+
ColorFieldValue,
|
|
346
|
+
ColorFieldValidators,
|
|
347
|
+
ColorFieldAppearance
|
|
348
|
+
>
|
|
349
|
+
| FieldCreateConfigForFieldType<
|
|
350
|
+
SourceType,
|
|
351
|
+
'date',
|
|
352
|
+
DateFieldValue,
|
|
353
|
+
DateFieldValidators,
|
|
354
|
+
DateFieldAppearance
|
|
355
|
+
>
|
|
356
|
+
| FieldCreateConfigForFieldType<
|
|
357
|
+
SourceType,
|
|
358
|
+
'date_time',
|
|
359
|
+
DateTimeFieldValue,
|
|
360
|
+
DateTimeFieldValidators,
|
|
361
|
+
DateTimeFieldAppearance
|
|
362
|
+
>
|
|
363
|
+
| FieldCreateConfigForFieldType<
|
|
364
|
+
SourceType,
|
|
365
|
+
'file',
|
|
366
|
+
// this field type does not support default values
|
|
367
|
+
null,
|
|
368
|
+
FileFieldValidators,
|
|
369
|
+
FileFieldAppearance
|
|
370
|
+
>
|
|
371
|
+
| FieldCreateConfigForFieldType<
|
|
372
|
+
SourceType,
|
|
373
|
+
'float',
|
|
374
|
+
FloatFieldValue,
|
|
375
|
+
FloatFieldValidators,
|
|
376
|
+
FloatFieldAppearance
|
|
377
|
+
>
|
|
378
|
+
| FieldCreateConfigForFieldType<
|
|
379
|
+
SourceType,
|
|
380
|
+
'gallery',
|
|
381
|
+
// this field type does not support default values
|
|
382
|
+
null,
|
|
383
|
+
GalleryFieldValidators,
|
|
384
|
+
GalleryFieldAppearance
|
|
385
|
+
>
|
|
386
|
+
| FieldCreateConfigForFieldType<
|
|
387
|
+
SourceType,
|
|
388
|
+
'integer',
|
|
389
|
+
IntegerFieldValue,
|
|
390
|
+
IntegerFieldValidators,
|
|
391
|
+
IntegerFieldAppearance
|
|
392
|
+
>
|
|
393
|
+
| FieldCreateConfigForFieldType<
|
|
394
|
+
SourceType,
|
|
395
|
+
'json',
|
|
396
|
+
JsonFieldValue,
|
|
397
|
+
JsonFieldValidators,
|
|
398
|
+
JsonFieldAppearance
|
|
399
|
+
>
|
|
400
|
+
| FieldCreateConfigForFieldType<
|
|
401
|
+
SourceType,
|
|
402
|
+
'lat_lon',
|
|
403
|
+
LatLonFieldValue,
|
|
404
|
+
LatLonFieldValidators,
|
|
405
|
+
LatLonFieldAppearance
|
|
406
|
+
>
|
|
407
|
+
| FieldCreateConfigForFieldType<
|
|
408
|
+
SourceType,
|
|
409
|
+
'link',
|
|
410
|
+
// this field type does not support default values
|
|
411
|
+
null,
|
|
412
|
+
LinkFieldValidators,
|
|
413
|
+
LinkFieldAppearance
|
|
414
|
+
>
|
|
415
|
+
| FieldCreateConfigForFieldType<
|
|
416
|
+
SourceType,
|
|
417
|
+
'links',
|
|
418
|
+
// this field type does not support default values
|
|
419
|
+
null,
|
|
420
|
+
LinksFieldValidators,
|
|
421
|
+
LinksFieldAppearance
|
|
422
|
+
>
|
|
423
|
+
| FieldCreateConfigForFieldType<
|
|
424
|
+
SourceType,
|
|
425
|
+
'rich_text',
|
|
426
|
+
// this field type does not support default values
|
|
427
|
+
null,
|
|
428
|
+
RichTextFieldValidators,
|
|
429
|
+
RichTextFieldAppearance
|
|
430
|
+
>
|
|
431
|
+
| FieldCreateConfigForFieldType<
|
|
432
|
+
SourceType,
|
|
433
|
+
'seo',
|
|
434
|
+
// this field type does not support default values
|
|
435
|
+
null,
|
|
436
|
+
SeoFieldValidators,
|
|
437
|
+
SeoFieldAppearance
|
|
438
|
+
>
|
|
439
|
+
| FieldCreateConfigForFieldType<
|
|
440
|
+
SourceType,
|
|
441
|
+
'single_block',
|
|
442
|
+
// this field type does not support default values
|
|
443
|
+
null,
|
|
444
|
+
SingleBlockFieldValidators,
|
|
445
|
+
SingleBlockFieldAppearance
|
|
446
|
+
>
|
|
447
|
+
| FieldCreateConfigForFieldType<
|
|
448
|
+
SourceType,
|
|
449
|
+
'slug',
|
|
450
|
+
// this field type does not support default values
|
|
451
|
+
null,
|
|
452
|
+
SlugFieldValidators,
|
|
453
|
+
SlugFieldAppearance
|
|
454
|
+
>
|
|
455
|
+
| FieldCreateConfigForFieldType<
|
|
456
|
+
SourceType,
|
|
457
|
+
'string',
|
|
458
|
+
StringFieldValue,
|
|
459
|
+
StringFieldValidators,
|
|
460
|
+
StringFieldAppearance
|
|
461
|
+
>
|
|
462
|
+
| FieldCreateConfigForFieldType<
|
|
463
|
+
SourceType,
|
|
464
|
+
'structured_text',
|
|
465
|
+
// this field type does not support default values
|
|
466
|
+
null,
|
|
467
|
+
StructuredTextFieldValidators,
|
|
468
|
+
StructuredTextFieldAppearance
|
|
469
|
+
>
|
|
470
|
+
| FieldCreateConfigForFieldType<
|
|
471
|
+
SourceType,
|
|
472
|
+
'text',
|
|
473
|
+
TextFieldValue,
|
|
474
|
+
TextFieldValidators,
|
|
475
|
+
TextFieldAppearance
|
|
476
|
+
>
|
|
477
|
+
| FieldCreateConfigForFieldType<
|
|
478
|
+
SourceType,
|
|
479
|
+
'video',
|
|
480
|
+
// this field type does not support default values
|
|
481
|
+
null,
|
|
482
|
+
VideoFieldValidators,
|
|
483
|
+
VideoFieldAppearance
|
|
484
|
+
>;
|
|
485
|
+
|
|
486
|
+
/**
|
|
487
|
+
* Helper type to conditionally handle default values based on localization for field updates
|
|
488
|
+
*/
|
|
489
|
+
type FieldUpdateDefaultValue<T> = T | Record<string, T> | undefined;
|
|
490
|
+
|
|
491
|
+
type FieldUpdateConfigForFieldType<
|
|
492
|
+
SourceType,
|
|
493
|
+
FieldType extends FieldAttributesStableShell['field_type'],
|
|
494
|
+
FieldValue,
|
|
495
|
+
FieldValidators,
|
|
496
|
+
FieldAppearance,
|
|
497
|
+
> = Omit<
|
|
498
|
+
SourceType,
|
|
499
|
+
'field_type' | 'default_value' | 'validators' | 'appearance'
|
|
500
|
+
> & {
|
|
501
|
+
field_type?: FieldType;
|
|
502
|
+
default_value?: FieldUpdateDefaultValue<FieldValue>;
|
|
503
|
+
validators?: FieldValidators;
|
|
504
|
+
appearance?: FieldAppearanceConfig<FieldAppearance>;
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
export type FieldUpdateConfig<SourceType> =
|
|
508
|
+
| FieldUpdateConfigForFieldType<
|
|
509
|
+
SourceType,
|
|
510
|
+
'boolean',
|
|
511
|
+
BooleanFieldValue,
|
|
512
|
+
BooleanFieldValidators,
|
|
513
|
+
BooleanFieldAppearance
|
|
514
|
+
>
|
|
515
|
+
| FieldUpdateConfigForFieldType<
|
|
516
|
+
SourceType,
|
|
517
|
+
'color',
|
|
518
|
+
ColorFieldValue,
|
|
519
|
+
ColorFieldValidators,
|
|
520
|
+
ColorFieldAppearance
|
|
521
|
+
>
|
|
522
|
+
| FieldUpdateConfigForFieldType<
|
|
523
|
+
SourceType,
|
|
524
|
+
'date',
|
|
525
|
+
DateFieldValue,
|
|
526
|
+
DateFieldValidators,
|
|
527
|
+
DateFieldAppearance
|
|
528
|
+
>
|
|
529
|
+
| FieldUpdateConfigForFieldType<
|
|
530
|
+
SourceType,
|
|
531
|
+
'date_time',
|
|
532
|
+
DateTimeFieldValue,
|
|
533
|
+
DateTimeFieldValidators,
|
|
534
|
+
DateTimeFieldAppearance
|
|
535
|
+
>
|
|
536
|
+
| FieldUpdateConfigForFieldType<
|
|
537
|
+
SourceType,
|
|
538
|
+
'file',
|
|
539
|
+
// this field type does not support default values
|
|
540
|
+
null,
|
|
541
|
+
FileFieldValidators,
|
|
542
|
+
FileFieldAppearance
|
|
543
|
+
>
|
|
544
|
+
| FieldUpdateConfigForFieldType<
|
|
545
|
+
SourceType,
|
|
546
|
+
'float',
|
|
547
|
+
FloatFieldValue,
|
|
548
|
+
FloatFieldValidators,
|
|
549
|
+
FloatFieldAppearance
|
|
550
|
+
>
|
|
551
|
+
| FieldUpdateConfigForFieldType<
|
|
552
|
+
SourceType,
|
|
553
|
+
'gallery',
|
|
554
|
+
// this field type does not support default values
|
|
555
|
+
null,
|
|
556
|
+
GalleryFieldValidators,
|
|
557
|
+
GalleryFieldAppearance
|
|
558
|
+
>
|
|
559
|
+
| FieldUpdateConfigForFieldType<
|
|
560
|
+
SourceType,
|
|
561
|
+
'integer',
|
|
562
|
+
IntegerFieldValue,
|
|
563
|
+
IntegerFieldValidators,
|
|
564
|
+
IntegerFieldAppearance
|
|
565
|
+
>
|
|
566
|
+
| FieldUpdateConfigForFieldType<
|
|
567
|
+
SourceType,
|
|
568
|
+
'json',
|
|
569
|
+
JsonFieldValue,
|
|
570
|
+
JsonFieldValidators,
|
|
571
|
+
JsonFieldAppearance
|
|
572
|
+
>
|
|
573
|
+
| FieldUpdateConfigForFieldType<
|
|
574
|
+
SourceType,
|
|
575
|
+
'lat_lon',
|
|
576
|
+
LatLonFieldValue,
|
|
577
|
+
LatLonFieldValidators,
|
|
578
|
+
LatLonFieldAppearance
|
|
579
|
+
>
|
|
580
|
+
| FieldUpdateConfigForFieldType<
|
|
581
|
+
SourceType,
|
|
582
|
+
'link',
|
|
583
|
+
// this field type does not support default values
|
|
584
|
+
null,
|
|
585
|
+
LinkFieldValidators,
|
|
586
|
+
LinkFieldAppearance
|
|
587
|
+
>
|
|
588
|
+
| FieldUpdateConfigForFieldType<
|
|
589
|
+
SourceType,
|
|
590
|
+
'links',
|
|
591
|
+
// this field type does not support default values
|
|
592
|
+
null,
|
|
593
|
+
LinksFieldValidators,
|
|
594
|
+
LinksFieldAppearance
|
|
595
|
+
>
|
|
596
|
+
| FieldUpdateConfigForFieldType<
|
|
597
|
+
SourceType,
|
|
598
|
+
'rich_text',
|
|
599
|
+
// this field type does not support default values
|
|
600
|
+
null,
|
|
601
|
+
RichTextFieldValidators,
|
|
602
|
+
RichTextFieldAppearance
|
|
603
|
+
>
|
|
604
|
+
| FieldUpdateConfigForFieldType<
|
|
605
|
+
SourceType,
|
|
606
|
+
'seo',
|
|
607
|
+
// this field type does not support default values
|
|
608
|
+
null,
|
|
609
|
+
SeoFieldValidators,
|
|
610
|
+
SeoFieldAppearance
|
|
611
|
+
>
|
|
612
|
+
| FieldUpdateConfigForFieldType<
|
|
613
|
+
SourceType,
|
|
614
|
+
'single_block',
|
|
615
|
+
// this field type does not support default values
|
|
616
|
+
null,
|
|
617
|
+
SingleBlockFieldValidators,
|
|
618
|
+
SingleBlockFieldAppearance
|
|
619
|
+
>
|
|
620
|
+
| FieldUpdateConfigForFieldType<
|
|
621
|
+
SourceType,
|
|
622
|
+
'slug',
|
|
623
|
+
// this field type does not support default values
|
|
624
|
+
null,
|
|
625
|
+
SlugFieldValidators,
|
|
626
|
+
SlugFieldAppearance
|
|
627
|
+
>
|
|
628
|
+
| FieldUpdateConfigForFieldType<
|
|
629
|
+
SourceType,
|
|
630
|
+
'string',
|
|
631
|
+
StringFieldValue,
|
|
632
|
+
StringFieldValidators,
|
|
633
|
+
StringFieldAppearance
|
|
634
|
+
>
|
|
635
|
+
| FieldUpdateConfigForFieldType<
|
|
636
|
+
SourceType,
|
|
637
|
+
'structured_text',
|
|
638
|
+
// this field type does not support default values
|
|
639
|
+
null,
|
|
640
|
+
StructuredTextFieldValidators,
|
|
641
|
+
StructuredTextFieldAppearance
|
|
642
|
+
>
|
|
643
|
+
| FieldUpdateConfigForFieldType<
|
|
644
|
+
SourceType,
|
|
645
|
+
'text',
|
|
646
|
+
TextFieldValue,
|
|
647
|
+
TextFieldValidators,
|
|
648
|
+
TextFieldAppearance
|
|
649
|
+
>
|
|
650
|
+
| FieldUpdateConfigForFieldType<
|
|
651
|
+
SourceType,
|
|
652
|
+
'video',
|
|
653
|
+
// this field type does not support default values
|
|
654
|
+
null,
|
|
655
|
+
VideoFieldValidators,
|
|
656
|
+
VideoFieldAppearance
|
|
657
|
+
>;
|