@hygraph/cli 0.0.2 → 0.0.4
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/LICENSE +21 -0
- package/README.md +17 -0
- package/dist/cli.js +16304 -165
- package/dist/define.d.ts +1643 -87
- package/dist/define.js +1 -314
- package/dist/define2.js +1411 -0
- package/dist/rolldown-runtime.js +21 -1
- package/dist/version.js +1 -1
- package/package.json +13 -6
- package/dist/is-empty.js +0 -11
package/dist/define2.js
ADDED
|
@@ -0,0 +1,1411 @@
|
|
|
1
|
+
import { n as __exportAll } from "./rolldown-runtime.js";
|
|
2
|
+
//#region src/utils/is-empty.ts
|
|
3
|
+
/**
|
|
4
|
+
* A nullable string that was omitted, `null` or written as `""` canonicalises
|
|
5
|
+
* to `null`. Studio writes empty strings where it means nothing, and the
|
|
6
|
+
* server treats the two the same, so the IR keeps one of them.
|
|
7
|
+
*/
|
|
8
|
+
function isEmpty(value) {
|
|
9
|
+
return value === void 0 || value === null || value === "";
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/define/fields/asset.ts
|
|
13
|
+
/**
|
|
14
|
+
* One asset, or a list of them, that editors connect to the entry. Hygraph
|
|
15
|
+
* adds a field back on the Asset model, named after this field and its
|
|
16
|
+
* model or component: `imagePost` for `image` on `Post`. It is `API_ONLY`.
|
|
17
|
+
* Allowed on components.
|
|
18
|
+
*
|
|
19
|
+
* Nothing here is validated: the checks run at plan time with the model's
|
|
20
|
+
* or component's own.
|
|
21
|
+
*/
|
|
22
|
+
function asset$1(input) {
|
|
23
|
+
return {
|
|
24
|
+
__typename: "AssetField",
|
|
25
|
+
apiId: input.apiId,
|
|
26
|
+
displayName: input.displayName,
|
|
27
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
28
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
29
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
30
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
31
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
32
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** `renamedFrom` stays out of the IR. */
|
|
36
|
+
function convertAssetFieldToIR(field, position) {
|
|
37
|
+
return {
|
|
38
|
+
kind: "asset",
|
|
39
|
+
apiId: field.apiId,
|
|
40
|
+
displayName: field.displayName,
|
|
41
|
+
description: field.description,
|
|
42
|
+
position,
|
|
43
|
+
list: field.list,
|
|
44
|
+
required: field.required,
|
|
45
|
+
visibility: field.visibility,
|
|
46
|
+
visibilityCondition: field.visibilityCondition
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The apiId of an asset field's other side on Asset, as Studio names it:
|
|
51
|
+
* `imagePost` for a field `image` on `Post`.
|
|
52
|
+
*/
|
|
53
|
+
function assetReverseApiId(apiId, parentApiId) {
|
|
54
|
+
return `${apiId}${parentApiId.charAt(0).toUpperCase()}${parentApiId.slice(1)}`;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/define/fields/boolean.ts
|
|
58
|
+
/**
|
|
59
|
+
* True or false.
|
|
60
|
+
*
|
|
61
|
+
* Nothing here is validated. The apiId format, uniqueness within the model
|
|
62
|
+
* or component and options that exclude each other are plan-time checks,
|
|
63
|
+
* reported together with its own.
|
|
64
|
+
*/
|
|
65
|
+
function boolean(input) {
|
|
66
|
+
return {
|
|
67
|
+
__typename: "BooleanField",
|
|
68
|
+
apiId: input.apiId,
|
|
69
|
+
displayName: input.displayName,
|
|
70
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
71
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
72
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
73
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
74
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
75
|
+
title: input.title ?? FIELD_DEFAULTS.title,
|
|
76
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
77
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
78
|
+
initialValue: booleanValue(input.initialValue),
|
|
79
|
+
migrationValue: booleanValue(input.migrationValue),
|
|
80
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** `renamedFrom` and `migrationValue` are intent, not schema, and stay out. */
|
|
84
|
+
function convertBooleanFieldToIR(field, position) {
|
|
85
|
+
return {
|
|
86
|
+
kind: "boolean",
|
|
87
|
+
apiId: field.apiId,
|
|
88
|
+
displayName: field.displayName,
|
|
89
|
+
description: field.description,
|
|
90
|
+
position,
|
|
91
|
+
list: field.list,
|
|
92
|
+
required: field.required,
|
|
93
|
+
unique: field.unique,
|
|
94
|
+
localized: field.localized,
|
|
95
|
+
title: field.title,
|
|
96
|
+
visibility: field.visibility,
|
|
97
|
+
visibilityCondition: field.visibilityCondition,
|
|
98
|
+
initialValue: field.initialValue
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/** An empty list means no value, as Studio writes it. */
|
|
102
|
+
function booleanValue(value) {
|
|
103
|
+
if (value === void 0) return null;
|
|
104
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
105
|
+
}
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/define/fields/color.ts
|
|
108
|
+
/**
|
|
109
|
+
* A colour, such as a brand colour. Nothing here is validated; the checks
|
|
110
|
+
* run at plan time with the model's or component's own.
|
|
111
|
+
*/
|
|
112
|
+
function color(input) {
|
|
113
|
+
return {
|
|
114
|
+
__typename: "ColorField",
|
|
115
|
+
apiId: input.apiId,
|
|
116
|
+
displayName: input.displayName,
|
|
117
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
118
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
119
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
120
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
121
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
122
|
+
title: false,
|
|
123
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
124
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
125
|
+
initialValue: colorValue(input.initialValue),
|
|
126
|
+
migrationValue: colorValue(input.migrationValue),
|
|
127
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** `renamedFrom` and `migrationValue` are intent, not schema, and stay out. */
|
|
131
|
+
function convertColorFieldToIR(field, position) {
|
|
132
|
+
return {
|
|
133
|
+
kind: "color",
|
|
134
|
+
apiId: field.apiId,
|
|
135
|
+
displayName: field.displayName,
|
|
136
|
+
description: field.description,
|
|
137
|
+
position,
|
|
138
|
+
list: field.list,
|
|
139
|
+
required: field.required,
|
|
140
|
+
unique: field.unique,
|
|
141
|
+
localized: field.localized,
|
|
142
|
+
title: false,
|
|
143
|
+
visibility: field.visibility,
|
|
144
|
+
visibilityCondition: field.visibilityCondition,
|
|
145
|
+
initialValue: field.initialValue
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
/** An empty list means no value, as Studio writes it. */
|
|
149
|
+
function colorValue(value) {
|
|
150
|
+
if (value === void 0) return null;
|
|
151
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
//#region src/define/fields/component.ts
|
|
155
|
+
/**
|
|
156
|
+
* One component, or a list of them, that editors fill in inside the entry.
|
|
157
|
+
*
|
|
158
|
+
* Nothing here is validated, and the component is not looked at until the
|
|
159
|
+
* plan: the checks run at plan time with the model's or component's own.
|
|
160
|
+
*/
|
|
161
|
+
function component$1(input) {
|
|
162
|
+
return {
|
|
163
|
+
__typename: "ComponentField",
|
|
164
|
+
apiId: input.apiId,
|
|
165
|
+
displayName: input.displayName,
|
|
166
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
167
|
+
component: input.component,
|
|
168
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
169
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
170
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
171
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
172
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
/** The IR names the component by its apiId. `renamedFrom` stays out. */
|
|
176
|
+
function convertComponentFieldToIR(field, position) {
|
|
177
|
+
return {
|
|
178
|
+
kind: "component",
|
|
179
|
+
apiId: field.apiId,
|
|
180
|
+
displayName: field.displayName,
|
|
181
|
+
description: field.description,
|
|
182
|
+
component: field.component().apiId,
|
|
183
|
+
position,
|
|
184
|
+
list: field.list,
|
|
185
|
+
required: field.required,
|
|
186
|
+
visibility: field.visibility,
|
|
187
|
+
visibilityCondition: field.visibilityCondition
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/define/fields/componentUnion.ts
|
|
192
|
+
/**
|
|
193
|
+
* A choice of components, or a list of them, that editors fill in inside
|
|
194
|
+
* the entry, such as page sections.
|
|
195
|
+
*
|
|
196
|
+
* Nothing here is validated, and the components are not looked at until
|
|
197
|
+
* the plan: the checks run at plan time with the model's or component's
|
|
198
|
+
* own.
|
|
199
|
+
*/
|
|
200
|
+
function componentUnion(input) {
|
|
201
|
+
return {
|
|
202
|
+
__typename: "ComponentUnionField",
|
|
203
|
+
apiId: input.apiId,
|
|
204
|
+
displayName: input.displayName,
|
|
205
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
206
|
+
components: [...input.components],
|
|
207
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
208
|
+
required: false,
|
|
209
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
210
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
211
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/** The IR names the members by apiId, sorted. `renamedFrom` stays out. */
|
|
215
|
+
function convertComponentUnionFieldToIR(field, position) {
|
|
216
|
+
return {
|
|
217
|
+
kind: "componentUnion",
|
|
218
|
+
apiId: field.apiId,
|
|
219
|
+
displayName: field.displayName,
|
|
220
|
+
description: field.description,
|
|
221
|
+
components: field.components.map((member) => member().apiId).toSorted(),
|
|
222
|
+
position,
|
|
223
|
+
list: field.list,
|
|
224
|
+
required: false,
|
|
225
|
+
visibility: field.visibility,
|
|
226
|
+
visibilityCondition: field.visibilityCondition
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
//#endregion
|
|
230
|
+
//#region src/define/fields/date.ts
|
|
231
|
+
/**
|
|
232
|
+
* A calendar day, such as a release date. Nothing here is validated; the
|
|
233
|
+
* checks run at plan time with the model's or component's own.
|
|
234
|
+
*/
|
|
235
|
+
function date(input) {
|
|
236
|
+
return {
|
|
237
|
+
__typename: "DateField",
|
|
238
|
+
...dateFieldAttributes(input)
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
/** The attributes `date` and `dateTime` return. */
|
|
242
|
+
function dateFieldAttributes(input) {
|
|
243
|
+
return {
|
|
244
|
+
apiId: input.apiId,
|
|
245
|
+
displayName: input.displayName,
|
|
246
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
247
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
248
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
249
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
250
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
251
|
+
title: input.title ?? FIELD_DEFAULTS.title,
|
|
252
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
253
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
254
|
+
initialValue: dateValue(input.initialValue),
|
|
255
|
+
migrationValue: dateValue(input.migrationValue),
|
|
256
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* A day or a moment, each its own Hygraph type and IR kind. `renamedFrom`
|
|
261
|
+
* and `migrationValue` are intent, not schema, and stay out.
|
|
262
|
+
*/
|
|
263
|
+
function convertDateFieldToIR(field, position) {
|
|
264
|
+
return {
|
|
265
|
+
kind: field.__typename === "DateField" ? "date" : "dateTime",
|
|
266
|
+
apiId: field.apiId,
|
|
267
|
+
displayName: field.displayName,
|
|
268
|
+
description: field.description,
|
|
269
|
+
position,
|
|
270
|
+
list: field.list,
|
|
271
|
+
required: field.required,
|
|
272
|
+
unique: field.unique,
|
|
273
|
+
localized: field.localized,
|
|
274
|
+
title: field.title,
|
|
275
|
+
visibility: field.visibility,
|
|
276
|
+
visibilityCondition: field.visibilityCondition,
|
|
277
|
+
initialValue: field.initialValue
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
/** An empty text or an empty list means no value, as Studio writes it. */
|
|
281
|
+
function dateValue(value) {
|
|
282
|
+
if (value === void 0 || value === "") return null;
|
|
283
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
284
|
+
}
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/define/fields/enumeration.ts
|
|
287
|
+
/**
|
|
288
|
+
* One value, or a list of them, from an enumeration. Takes the enumeration
|
|
289
|
+
* itself, not a lambda, and types `initialValue` and `migrationValue` by
|
|
290
|
+
* its values.
|
|
291
|
+
*
|
|
292
|
+
* Nothing here is validated; the checks run at plan time with the model's
|
|
293
|
+
* or component's own.
|
|
294
|
+
*/
|
|
295
|
+
function enumeration$1(input) {
|
|
296
|
+
return {
|
|
297
|
+
__typename: "EnumerationField",
|
|
298
|
+
apiId: input.apiId,
|
|
299
|
+
displayName: input.displayName,
|
|
300
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
301
|
+
enumeration: input.enumeration,
|
|
302
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
303
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
304
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
305
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
306
|
+
title: input.title ?? FIELD_DEFAULTS.title,
|
|
307
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
308
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
309
|
+
initialValue: enumerationValue(input.initialValue),
|
|
310
|
+
migrationValue: enumerationValue(input.migrationValue),
|
|
311
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* The IR names the enumeration by its apiId. `renamedFrom` and
|
|
316
|
+
* `migrationValue` are intent, not schema, and stay out.
|
|
317
|
+
*/
|
|
318
|
+
function convertEnumerationFieldToIR(field, position) {
|
|
319
|
+
return {
|
|
320
|
+
kind: "enumeration",
|
|
321
|
+
apiId: field.apiId,
|
|
322
|
+
displayName: field.displayName,
|
|
323
|
+
description: field.description,
|
|
324
|
+
enumeration: field.enumeration.apiId,
|
|
325
|
+
position,
|
|
326
|
+
list: field.list,
|
|
327
|
+
required: field.required,
|
|
328
|
+
unique: field.unique,
|
|
329
|
+
localized: field.localized,
|
|
330
|
+
title: field.title,
|
|
331
|
+
visibility: field.visibility,
|
|
332
|
+
visibilityCondition: field.visibilityCondition,
|
|
333
|
+
initialValue: field.initialValue
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/** An empty list means no value, as Studio writes it. */
|
|
337
|
+
function enumerationValue(value) {
|
|
338
|
+
if (value === void 0) return null;
|
|
339
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
340
|
+
}
|
|
341
|
+
//#endregion
|
|
342
|
+
//#region src/define/fields/json.ts
|
|
343
|
+
/**
|
|
344
|
+
* Any JSON, such as settings for a widget. One value may be a list or an
|
|
345
|
+
* object itself. Nothing here is validated; the checks run at plan time
|
|
346
|
+
* with the model's or component's own.
|
|
347
|
+
*/
|
|
348
|
+
function json(input) {
|
|
349
|
+
return {
|
|
350
|
+
__typename: "JsonField",
|
|
351
|
+
apiId: input.apiId,
|
|
352
|
+
displayName: input.displayName,
|
|
353
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
354
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
355
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
356
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
357
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
358
|
+
title: false,
|
|
359
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
360
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
361
|
+
initialValue: jsonValue(input.initialValue),
|
|
362
|
+
migrationValue: jsonValue(input.migrationValue),
|
|
363
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/** `renamedFrom` and `migrationValue` are intent, not schema, and stay out. */
|
|
367
|
+
function convertJsonFieldToIR(field, position) {
|
|
368
|
+
return {
|
|
369
|
+
kind: "json",
|
|
370
|
+
apiId: field.apiId,
|
|
371
|
+
displayName: field.displayName,
|
|
372
|
+
description: field.description,
|
|
373
|
+
position,
|
|
374
|
+
list: field.list,
|
|
375
|
+
required: field.required,
|
|
376
|
+
unique: field.unique,
|
|
377
|
+
localized: field.localized,
|
|
378
|
+
title: false,
|
|
379
|
+
visibility: field.visibility,
|
|
380
|
+
visibilityCondition: field.visibilityCondition,
|
|
381
|
+
initialValue: field.initialValue
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* `null`, an empty text and an empty list mean no value, as the live
|
|
386
|
+
* reader reads them.
|
|
387
|
+
*/
|
|
388
|
+
function jsonValue(value) {
|
|
389
|
+
if (value === void 0 || value === null || value === "") return null;
|
|
390
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
391
|
+
}
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/define/fields/location.ts
|
|
394
|
+
/**
|
|
395
|
+
* A point on the globe, such as where a store is. Nothing here is
|
|
396
|
+
* validated; the checks run at plan time with the model's or component's
|
|
397
|
+
* own.
|
|
398
|
+
*/
|
|
399
|
+
function location(input) {
|
|
400
|
+
return {
|
|
401
|
+
__typename: "LocationField",
|
|
402
|
+
apiId: input.apiId,
|
|
403
|
+
displayName: input.displayName,
|
|
404
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
405
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
406
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
407
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
408
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
409
|
+
title: false,
|
|
410
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
411
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
412
|
+
initialValue: locationValue(input.initialValue),
|
|
413
|
+
migrationValue: locationValue(input.migrationValue),
|
|
414
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
/** `renamedFrom` and `migrationValue` are intent, not schema, and stay out. */
|
|
418
|
+
function convertLocationFieldToIR(field, position) {
|
|
419
|
+
return {
|
|
420
|
+
kind: "location",
|
|
421
|
+
apiId: field.apiId,
|
|
422
|
+
displayName: field.displayName,
|
|
423
|
+
description: field.description,
|
|
424
|
+
position,
|
|
425
|
+
list: field.list,
|
|
426
|
+
required: field.required,
|
|
427
|
+
unique: field.unique,
|
|
428
|
+
localized: field.localized,
|
|
429
|
+
title: false,
|
|
430
|
+
visibility: field.visibility,
|
|
431
|
+
visibilityCondition: field.visibilityCondition,
|
|
432
|
+
initialValue: field.initialValue
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/** An empty list means no value, as Studio writes it. */
|
|
436
|
+
function locationValue(value) {
|
|
437
|
+
if (value === void 0) return null;
|
|
438
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
439
|
+
}
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/define/fields/rangeRule.ts
|
|
442
|
+
/** A range with every default filled in, `null` when it is not given. */
|
|
443
|
+
function rangeRule(input) {
|
|
444
|
+
if (input === void 0) return null;
|
|
445
|
+
return {
|
|
446
|
+
min: input.min ?? null,
|
|
447
|
+
max: input.max ?? null,
|
|
448
|
+
errorMessage: input.errorMessage
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/define/fields/number.ts
|
|
453
|
+
/**
|
|
454
|
+
* The attributes `int` and `float` return. Nothing here is validated; the
|
|
455
|
+
* checks run at plan time with the model's or component's own.
|
|
456
|
+
*/
|
|
457
|
+
function numberFieldAttributes(input) {
|
|
458
|
+
return {
|
|
459
|
+
apiId: input.apiId,
|
|
460
|
+
displayName: input.displayName,
|
|
461
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
462
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
463
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
464
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
465
|
+
localized: input.localized ?? FIELD_DEFAULTS.localized,
|
|
466
|
+
title: input.title ?? FIELD_DEFAULTS.title,
|
|
467
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
468
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
469
|
+
initialValue: numberValue(input.initialValue),
|
|
470
|
+
migrationValue: numberValue(input.migrationValue),
|
|
471
|
+
validations: numberValidationRules(input.validations),
|
|
472
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* A whole or a decimal number, each its own Hygraph type and IR kind.
|
|
477
|
+
* `renamedFrom` and `migrationValue` are intent, not schema, and stay out.
|
|
478
|
+
*/
|
|
479
|
+
function convertNumberFieldToIR(field, position) {
|
|
480
|
+
return {
|
|
481
|
+
kind: field.__typename === "IntField" ? "int" : "float",
|
|
482
|
+
apiId: field.apiId,
|
|
483
|
+
displayName: field.displayName,
|
|
484
|
+
description: field.description,
|
|
485
|
+
position,
|
|
486
|
+
list: field.list,
|
|
487
|
+
required: field.required,
|
|
488
|
+
unique: field.unique,
|
|
489
|
+
localized: field.localized,
|
|
490
|
+
title: field.title,
|
|
491
|
+
visibility: field.visibility,
|
|
492
|
+
visibilityCondition: field.visibilityCondition,
|
|
493
|
+
initialValue: field.initialValue,
|
|
494
|
+
validations: field.validations
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
/** An empty list means no value, as Studio writes it. */
|
|
498
|
+
function numberValue(value) {
|
|
499
|
+
if (value === void 0) return null;
|
|
500
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
501
|
+
}
|
|
502
|
+
/** The validations with every default filled in, `null` when there are none. */
|
|
503
|
+
function numberValidationRules(input) {
|
|
504
|
+
if (input === void 0) return null;
|
|
505
|
+
const validations = {
|
|
506
|
+
range: rangeRule(input.range),
|
|
507
|
+
listItemCount: rangeRule(input.listItemCount)
|
|
508
|
+
};
|
|
509
|
+
return Object.values(validations).every((each) => each === null) ? null : validations;
|
|
510
|
+
}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/define/fields/referenceOneWay.ts
|
|
513
|
+
/**
|
|
514
|
+
* Entries of another model, or of the same one, that editors connect to
|
|
515
|
+
* the entry. Only this side has a field: Hygraph keeps the other side
|
|
516
|
+
* hidden on the model referenced. Allowed on components.
|
|
517
|
+
*
|
|
518
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
519
|
+
* plan: the checks run at plan time with the model's or component's own.
|
|
520
|
+
*/
|
|
521
|
+
function referenceOneWay(input) {
|
|
522
|
+
return {
|
|
523
|
+
__typename: "ReferenceOneWayField",
|
|
524
|
+
apiId: input.apiId,
|
|
525
|
+
displayName: input.displayName,
|
|
526
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
527
|
+
to: input.to,
|
|
528
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
529
|
+
required: false,
|
|
530
|
+
rules: input.rules === void 0 ? null : referenceRules(input.rules),
|
|
531
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
532
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
533
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
function referenceRules({ connections }) {
|
|
537
|
+
return { connections: {
|
|
538
|
+
min: connections.min ?? null,
|
|
539
|
+
max: connections.max ?? null,
|
|
540
|
+
errorMessage: isEmpty(connections.errorMessage) ? null : connections.errorMessage
|
|
541
|
+
} };
|
|
542
|
+
}
|
|
543
|
+
/** The IR names the model by its apiId. `renamedFrom` stays out. */
|
|
544
|
+
function convertReferenceOneWayFieldToIR(field, position) {
|
|
545
|
+
return {
|
|
546
|
+
kind: "referenceOneWay",
|
|
547
|
+
apiId: field.apiId,
|
|
548
|
+
displayName: field.displayName,
|
|
549
|
+
description: field.description,
|
|
550
|
+
to: field.to().apiId,
|
|
551
|
+
rules: field.rules,
|
|
552
|
+
position,
|
|
553
|
+
list: field.list,
|
|
554
|
+
required: false,
|
|
555
|
+
visibility: field.visibility,
|
|
556
|
+
visibilityCondition: field.visibilityCondition
|
|
557
|
+
};
|
|
558
|
+
}
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/define/fields/referenceTwoWay.ts
|
|
561
|
+
/**
|
|
562
|
+
* Entries of another model, or of the same one, that editors connect to
|
|
563
|
+
* the entry, and that show the connection back in a field of their own.
|
|
564
|
+
* Declare both fields, each on the model it belongs to, each naming the
|
|
565
|
+
* other in `reverse`. Both can be on the same model. Each one has its own
|
|
566
|
+
* name, list, visibility, rules and condition, and renames on its own.
|
|
567
|
+
* Models only: a component cannot have one.
|
|
568
|
+
*
|
|
569
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
570
|
+
* plan: the checks run at plan time with the model's own.
|
|
571
|
+
*/
|
|
572
|
+
function referenceTwoWay(input) {
|
|
573
|
+
return {
|
|
574
|
+
__typename: "ReferenceTwoWayField",
|
|
575
|
+
apiId: input.apiId,
|
|
576
|
+
displayName: input.displayName,
|
|
577
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
578
|
+
to: input.to,
|
|
579
|
+
reverse: input.reverse,
|
|
580
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
581
|
+
required: false,
|
|
582
|
+
rules: input.rules === void 0 ? null : referenceRules(input.rules),
|
|
583
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
584
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
585
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
/** The IR names the model by its apiId. `renamedFrom` stays out. */
|
|
589
|
+
function convertReferenceTwoWayFieldToIR(field, position) {
|
|
590
|
+
return {
|
|
591
|
+
kind: "referenceTwoWay",
|
|
592
|
+
apiId: field.apiId,
|
|
593
|
+
displayName: field.displayName,
|
|
594
|
+
description: field.description,
|
|
595
|
+
to: field.to().apiId,
|
|
596
|
+
reverse: field.reverse,
|
|
597
|
+
rules: field.rules,
|
|
598
|
+
position,
|
|
599
|
+
list: field.list,
|
|
600
|
+
required: false,
|
|
601
|
+
visibility: field.visibility,
|
|
602
|
+
visibilityCondition: field.visibilityCondition
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
//#endregion
|
|
606
|
+
//#region src/define/not-implemented.ts
|
|
607
|
+
/**
|
|
608
|
+
* Every builder is declared so the authoring surface is fixed, but none of
|
|
609
|
+
* them are implemented yet. They throw rather than returning a half-shaped
|
|
610
|
+
* object: a config that silently produced the wrong schema would be worse
|
|
611
|
+
* than one that refuses to load.
|
|
612
|
+
*/
|
|
613
|
+
function notImplemented(builder) {
|
|
614
|
+
throw new Error(`${builder} is not implemented yet`);
|
|
615
|
+
}
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/define/fields/string.ts
|
|
618
|
+
/**
|
|
619
|
+
* The attributes every editor's builder returns, filling in its
|
|
620
|
+
* `defaults`. Nothing here is validated; the checks run at plan time with
|
|
621
|
+
* the model's or component's own.
|
|
622
|
+
*/
|
|
623
|
+
function stringFieldAttributes(input, defaults = FIELD_DEFAULTS) {
|
|
624
|
+
return {
|
|
625
|
+
apiId: input.apiId,
|
|
626
|
+
displayName: input.displayName,
|
|
627
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
628
|
+
list: input.list ?? defaults.list,
|
|
629
|
+
required: input.required ?? defaults.required,
|
|
630
|
+
unique: input.unique ?? defaults.unique,
|
|
631
|
+
localized: input.localized ?? defaults.localized,
|
|
632
|
+
title: input.title ?? defaults.title,
|
|
633
|
+
visibility: input.visibility ?? defaults.visibility,
|
|
634
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
635
|
+
initialValue: textValue(input.initialValue),
|
|
636
|
+
migrationValue: textValue(input.migrationValue),
|
|
637
|
+
validations: stringValidationRules(input.validations),
|
|
638
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
/** The form renderer each text field's `__typename` stands for, in the IR. */
|
|
642
|
+
const FORM_RENDERERS = {
|
|
643
|
+
SingleLineField: "GCMS_SINGLE_LINE",
|
|
644
|
+
MultilineField: "GCMS_MULTI_LINE",
|
|
645
|
+
MarkdownField: "GCMS_MARKDOWN",
|
|
646
|
+
SlugField: "GCMS_SLUG"
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* The IR names the form renderer, which the config says by `__typename`.
|
|
650
|
+
* `renamedFrom` and `migrationValue` are intent, not schema, and stay out.
|
|
651
|
+
*/
|
|
652
|
+
function convertStringFieldToIR(field, position) {
|
|
653
|
+
return {
|
|
654
|
+
kind: "string",
|
|
655
|
+
formRenderer: FORM_RENDERERS[field.__typename],
|
|
656
|
+
apiId: field.apiId,
|
|
657
|
+
displayName: field.displayName,
|
|
658
|
+
description: field.description,
|
|
659
|
+
position,
|
|
660
|
+
list: field.list,
|
|
661
|
+
required: field.required,
|
|
662
|
+
unique: field.unique,
|
|
663
|
+
localized: field.localized,
|
|
664
|
+
title: field.title,
|
|
665
|
+
visibility: field.visibility,
|
|
666
|
+
visibilityCondition: field.visibilityCondition,
|
|
667
|
+
initialValue: field.initialValue,
|
|
668
|
+
validations: convertStringValidationRulesToIR(field.validations),
|
|
669
|
+
slug: field.__typename === "SlugField" ? {
|
|
670
|
+
lowercase: field.lowercase,
|
|
671
|
+
autoGenerate: field.autoGenerate,
|
|
672
|
+
template: field.template
|
|
673
|
+
} : null
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
/** An empty text or an empty list means no value, as Studio writes it. */
|
|
677
|
+
function textValue(value) {
|
|
678
|
+
if (value === void 0 || value === "") return null;
|
|
679
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
680
|
+
}
|
|
681
|
+
/** Text rendered by an installed app's element. `renderer` is required. */
|
|
682
|
+
function string(_options) {
|
|
683
|
+
return notImplemented("define.field.string");
|
|
684
|
+
}
|
|
685
|
+
/** The validations with every default filled in, `null` when there are none. */
|
|
686
|
+
function stringValidationRules(input) {
|
|
687
|
+
if (input === void 0) return null;
|
|
688
|
+
const validations = {
|
|
689
|
+
characters: rangeRule(input.characters),
|
|
690
|
+
matches: regex(input.matches),
|
|
691
|
+
notMatches: regex(input.notMatches),
|
|
692
|
+
listItemCount: rangeRule(input.listItemCount)
|
|
693
|
+
};
|
|
694
|
+
return Object.values(validations).every((each) => each === null) ? null : validations;
|
|
695
|
+
}
|
|
696
|
+
function regex(input) {
|
|
697
|
+
if (input === void 0) return null;
|
|
698
|
+
return {
|
|
699
|
+
regex: input.regex,
|
|
700
|
+
flags: input.flags === void 0 || input.flags.length === 0 ? null : [...input.flags],
|
|
701
|
+
errorMessage: input.errorMessage
|
|
702
|
+
};
|
|
703
|
+
}
|
|
704
|
+
/** The validations as the IR holds them, with flags sorted. */
|
|
705
|
+
function convertStringValidationRulesToIR(validations) {
|
|
706
|
+
if (validations === null) return null;
|
|
707
|
+
return {
|
|
708
|
+
characters: validations.characters,
|
|
709
|
+
matches: regexToIR(validations.matches),
|
|
710
|
+
notMatches: regexToIR(validations.notMatches),
|
|
711
|
+
listItemCount: validations.listItemCount
|
|
712
|
+
};
|
|
713
|
+
}
|
|
714
|
+
function regexToIR(validation) {
|
|
715
|
+
if (validation === null) return null;
|
|
716
|
+
return {
|
|
717
|
+
regex: validation.regex,
|
|
718
|
+
flags: validation.flags === null ? null : [...new Set(validation.flags)].toSorted(),
|
|
719
|
+
errorMessage: validation.errorMessage
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/define/fields/taxonomy.ts
|
|
724
|
+
/**
|
|
725
|
+
* One node, or a list of them, from a taxonomy. Takes the taxonomy itself,
|
|
726
|
+
* not a lambda.
|
|
727
|
+
*
|
|
728
|
+
* Nothing here is validated; the checks run at plan time with the model's
|
|
729
|
+
* or component's own, the nodes `initialValue` and `migrationValue` name
|
|
730
|
+
* included.
|
|
731
|
+
*/
|
|
732
|
+
function taxonomy$1(input) {
|
|
733
|
+
return {
|
|
734
|
+
__typename: "TaxonomyField",
|
|
735
|
+
apiId: input.apiId,
|
|
736
|
+
displayName: input.displayName,
|
|
737
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
738
|
+
taxonomy: input.taxonomy,
|
|
739
|
+
list: input.list ?? FIELD_DEFAULTS.list,
|
|
740
|
+
required: input.required ?? FIELD_DEFAULTS.required,
|
|
741
|
+
unique: input.unique ?? FIELD_DEFAULTS.unique,
|
|
742
|
+
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
743
|
+
visibilityCondition: input.visibilityCondition ?? null,
|
|
744
|
+
initialValue: taxonomyValue(input.initialValue),
|
|
745
|
+
migrationValue: taxonomyValue(input.migrationValue),
|
|
746
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
/**
|
|
750
|
+
* The IR names the taxonomy by its apiId. `renamedFrom` and
|
|
751
|
+
* `migrationValue` are intent, not schema, and stay out.
|
|
752
|
+
*/
|
|
753
|
+
function convertTaxonomyFieldToIR(field, position) {
|
|
754
|
+
return {
|
|
755
|
+
kind: "taxonomy",
|
|
756
|
+
apiId: field.apiId,
|
|
757
|
+
displayName: field.displayName,
|
|
758
|
+
description: field.description,
|
|
759
|
+
taxonomy: field.taxonomy.apiId,
|
|
760
|
+
position,
|
|
761
|
+
list: field.list,
|
|
762
|
+
required: field.required,
|
|
763
|
+
unique: field.unique,
|
|
764
|
+
visibility: field.visibility,
|
|
765
|
+
visibilityCondition: field.visibilityCondition,
|
|
766
|
+
initialValue: field.initialValue
|
|
767
|
+
};
|
|
768
|
+
}
|
|
769
|
+
/** An empty list means no value, as Studio writes it. */
|
|
770
|
+
function taxonomyValue(value) {
|
|
771
|
+
if (value === void 0) return null;
|
|
772
|
+
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
773
|
+
}
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/define/fields/unsupported.ts
|
|
776
|
+
/**
|
|
777
|
+
* A field the CLI cannot read yet, written by export in the field's slot.
|
|
778
|
+
* The plan only moves it, or deletes it when it is left out. To change
|
|
779
|
+
* anything else, use Studio.
|
|
780
|
+
*/
|
|
781
|
+
function unsupported(input) {
|
|
782
|
+
return {
|
|
783
|
+
__typename: "UnsupportedField",
|
|
784
|
+
apiId: input.apiId,
|
|
785
|
+
type: input.type
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
function convertUnsupportedFieldToIR(field, position) {
|
|
789
|
+
return {
|
|
790
|
+
kind: "unsupported",
|
|
791
|
+
apiId: field.apiId,
|
|
792
|
+
type: field.type,
|
|
793
|
+
position
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/define/fields/field.ts
|
|
798
|
+
const FIELD_DEFAULTS = {
|
|
799
|
+
list: false,
|
|
800
|
+
required: false,
|
|
801
|
+
unique: false,
|
|
802
|
+
localized: false,
|
|
803
|
+
title: false,
|
|
804
|
+
visibility: "READ_WRITE"
|
|
805
|
+
};
|
|
806
|
+
/**
|
|
807
|
+
* Where the field is in its model or component is its index in `fields`. A condition's
|
|
808
|
+
* values have no order, so the IR sorts them.
|
|
809
|
+
*/
|
|
810
|
+
function convertFieldToIR(field, position) {
|
|
811
|
+
const ir = convertTypeToIR(field, position);
|
|
812
|
+
if (ir.kind === "unsupported") return ir;
|
|
813
|
+
const condition = ir.visibilityCondition;
|
|
814
|
+
return condition !== null && "enumerationValues" in condition ? {
|
|
815
|
+
...ir,
|
|
816
|
+
visibilityCondition: {
|
|
817
|
+
...condition,
|
|
818
|
+
enumerationValues: condition.enumerationValues.toSorted()
|
|
819
|
+
}
|
|
820
|
+
} : ir;
|
|
821
|
+
}
|
|
822
|
+
function convertTypeToIR(field, position) {
|
|
823
|
+
switch (field.__typename) {
|
|
824
|
+
case "BooleanField": return convertBooleanFieldToIR(field, position);
|
|
825
|
+
case "DateField":
|
|
826
|
+
case "DateTimeField": return convertDateFieldToIR(field, position);
|
|
827
|
+
case "IntField":
|
|
828
|
+
case "FloatField": return convertNumberFieldToIR(field, position);
|
|
829
|
+
case "EnumerationField": return convertEnumerationFieldToIR(field, position);
|
|
830
|
+
case "TaxonomyField": return convertTaxonomyFieldToIR(field, position);
|
|
831
|
+
case "JsonField": return convertJsonFieldToIR(field, position);
|
|
832
|
+
case "ColorField": return convertColorFieldToIR(field, position);
|
|
833
|
+
case "LocationField": return convertLocationFieldToIR(field, position);
|
|
834
|
+
case "ComponentField": return convertComponentFieldToIR(field, position);
|
|
835
|
+
case "ComponentUnionField": return convertComponentUnionFieldToIR(field, position);
|
|
836
|
+
case "ReferenceOneWayField": return convertReferenceOneWayFieldToIR(field, position);
|
|
837
|
+
case "ReferenceTwoWayField": return convertReferenceTwoWayFieldToIR(field, position);
|
|
838
|
+
case "AssetField": return convertAssetFieldToIR(field, position);
|
|
839
|
+
case "SingleLineField":
|
|
840
|
+
case "MultilineField":
|
|
841
|
+
case "MarkdownField":
|
|
842
|
+
case "SlugField": return convertStringFieldToIR(field, position);
|
|
843
|
+
case "UnsupportedField": return convertUnsupportedFieldToIR(field, position);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
//#endregion
|
|
847
|
+
//#region src/ir/order.ts
|
|
848
|
+
/**
|
|
849
|
+
* Code-unit order, which is code-point order for the characters an `apiId`
|
|
850
|
+
* may contain. Not `localeCompare`, whose result depends on the machine.
|
|
851
|
+
*
|
|
852
|
+
* Both sides of the diff sort their unordered collections with this, so the
|
|
853
|
+
* same set of entities hashes the same wherever it was read from.
|
|
854
|
+
*/
|
|
855
|
+
function byApiId(a, b) {
|
|
856
|
+
if (a.apiId === b.apiId) return 0;
|
|
857
|
+
return a.apiId < b.apiId ? -1 : 1;
|
|
858
|
+
}
|
|
859
|
+
//#endregion
|
|
860
|
+
//#region src/define/resources/component.ts
|
|
861
|
+
/**
|
|
862
|
+
* A group of fields that editors fill in inside an entry. A component has
|
|
863
|
+
* no entries of its own.
|
|
864
|
+
*
|
|
865
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
866
|
+
* checks, reported together with the rest of the config's.
|
|
867
|
+
*/
|
|
868
|
+
function component(input) {
|
|
869
|
+
return {
|
|
870
|
+
__typename: "Component",
|
|
871
|
+
apiId: input.apiId,
|
|
872
|
+
apiIdPlural: input.apiIdPlural,
|
|
873
|
+
displayName: input.displayName,
|
|
874
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
875
|
+
fields: [...input.fields],
|
|
876
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* The canonical form, as `convertModelToIR` makes a model's. `renamedFrom`
|
|
881
|
+
* is intent, not schema, and stays out. A field's index in `fields`
|
|
882
|
+
* becomes its position.
|
|
883
|
+
*/
|
|
884
|
+
function convertComponentToIR(component) {
|
|
885
|
+
return {
|
|
886
|
+
apiId: component.apiId,
|
|
887
|
+
apiIdPlural: component.apiIdPlural,
|
|
888
|
+
displayName: component.displayName,
|
|
889
|
+
description: component.description,
|
|
890
|
+
fields: Object.fromEntries(component.fields.map((field, position) => [field.apiId, convertFieldToIR(field, position)]))
|
|
891
|
+
};
|
|
892
|
+
}
|
|
893
|
+
//#endregion
|
|
894
|
+
//#region src/define/resources/enumeration.ts
|
|
895
|
+
/**
|
|
896
|
+
* A fixed set of values, for enumeration fields to pick from.
|
|
897
|
+
*
|
|
898
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
899
|
+
* checks, reported together with the rest of the config's.
|
|
900
|
+
*/
|
|
901
|
+
function enumeration(input) {
|
|
902
|
+
return {
|
|
903
|
+
__typename: "Enumeration",
|
|
904
|
+
apiId: input.apiId,
|
|
905
|
+
displayName: input.displayName,
|
|
906
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
907
|
+
values: input.values.map((value) => ({
|
|
908
|
+
apiId: value.apiId,
|
|
909
|
+
displayName: value.displayName,
|
|
910
|
+
renamedFrom: isEmpty(value.renamedFrom) ? null : value.renamedFrom
|
|
911
|
+
})),
|
|
912
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* Values have no order, so the IR sorts them by apiId. `renamedFrom` is
|
|
917
|
+
* intent, not schema, and stays out.
|
|
918
|
+
*/
|
|
919
|
+
function convertEnumerationToIR(enumeration) {
|
|
920
|
+
return {
|
|
921
|
+
apiId: enumeration.apiId,
|
|
922
|
+
displayName: enumeration.displayName,
|
|
923
|
+
description: enumeration.description,
|
|
924
|
+
values: enumeration.values.map((value) => ({
|
|
925
|
+
apiId: value.apiId,
|
|
926
|
+
displayName: value.displayName
|
|
927
|
+
})).toSorted(byApiId)
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
//#endregion
|
|
931
|
+
//#region src/define/resources/locale.ts
|
|
932
|
+
/**
|
|
933
|
+
* A language or region content can be localized into. Fields take
|
|
934
|
+
* `localized: true`; the locales themselves are listed in the
|
|
935
|
+
* environment's `locales`.
|
|
936
|
+
*
|
|
937
|
+
* Nothing here is validated. Format rules, uniqueness and the one default
|
|
938
|
+
* are plan-time checks, reported together with the rest of the config's.
|
|
939
|
+
*/
|
|
940
|
+
function locale(input) {
|
|
941
|
+
return {
|
|
942
|
+
__typename: "Locale",
|
|
943
|
+
apiId: input.apiId,
|
|
944
|
+
displayName: input.displayName,
|
|
945
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
946
|
+
isDefault: input.isDefault ?? false,
|
|
947
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
948
|
+
};
|
|
949
|
+
}
|
|
950
|
+
/** `renamedFrom` is intent, not schema, and stays out. */
|
|
951
|
+
function convertLocaleToIR(locale) {
|
|
952
|
+
return {
|
|
953
|
+
apiId: locale.apiId,
|
|
954
|
+
displayName: locale.displayName,
|
|
955
|
+
description: locale.description,
|
|
956
|
+
isDefault: locale.isDefault
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
//#endregion
|
|
960
|
+
//#region src/define/resources/model.ts
|
|
961
|
+
/**
|
|
962
|
+
* One model.
|
|
963
|
+
*
|
|
964
|
+
* Nothing here is validated. Format rules, `apiIdPlural` against `apiId` and
|
|
965
|
+
* uniqueness are plan-time checks, reported together rather than thrown one
|
|
966
|
+
* at a time while the config loads.
|
|
967
|
+
*/
|
|
968
|
+
function model(input) {
|
|
969
|
+
return {
|
|
970
|
+
__typename: "Model",
|
|
971
|
+
apiId: input.apiId,
|
|
972
|
+
apiIdPlural: input.apiIdPlural,
|
|
973
|
+
displayName: input.displayName,
|
|
974
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
975
|
+
fields: [...input.fields],
|
|
976
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Everything the canonical form adds to a model happens here. `renamedFrom`
|
|
981
|
+
* is intent, not schema, and stays out. Fields are keyed by apiId, and a
|
|
982
|
+
* field's index in `fields` becomes its position.
|
|
983
|
+
*/
|
|
984
|
+
function convertModelToIR(model) {
|
|
985
|
+
return {
|
|
986
|
+
apiId: model.apiId,
|
|
987
|
+
apiIdPlural: model.apiIdPlural,
|
|
988
|
+
displayName: model.displayName,
|
|
989
|
+
description: model.description,
|
|
990
|
+
fields: Object.fromEntries(model.fields.map((field, position) => [field.apiId, convertFieldToIR(field, position)]))
|
|
991
|
+
};
|
|
992
|
+
}
|
|
993
|
+
//#endregion
|
|
994
|
+
//#region src/define/resources/stage.ts
|
|
995
|
+
/**
|
|
996
|
+
* A content stage entries can be published to. The environment's `stages`
|
|
997
|
+
* lists every stage in order, Draft and Published included, as
|
|
998
|
+
* `system.stage.draft()` and `system.stage.published()`.
|
|
999
|
+
*
|
|
1000
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
1001
|
+
* checks, reported together with the rest of the config's.
|
|
1002
|
+
*/
|
|
1003
|
+
function stage$1(input) {
|
|
1004
|
+
return {
|
|
1005
|
+
__typename: "Stage",
|
|
1006
|
+
apiId: input.apiId,
|
|
1007
|
+
displayName: input.displayName,
|
|
1008
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
1009
|
+
color: input.color
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
/** `index` is the stage's index in `stages`, which is its position. */
|
|
1013
|
+
function convertStageToIR(stage, index) {
|
|
1014
|
+
if (stage.__typename === "SystemStage") return {
|
|
1015
|
+
apiId: stage.apiId,
|
|
1016
|
+
isSystem: true,
|
|
1017
|
+
position: index
|
|
1018
|
+
};
|
|
1019
|
+
return {
|
|
1020
|
+
apiId: stage.apiId,
|
|
1021
|
+
isSystem: false,
|
|
1022
|
+
displayName: stage.displayName,
|
|
1023
|
+
description: stage.description,
|
|
1024
|
+
color: stage.color,
|
|
1025
|
+
position: index
|
|
1026
|
+
};
|
|
1027
|
+
}
|
|
1028
|
+
//#endregion
|
|
1029
|
+
//#region src/define/resources/taxonomy.ts
|
|
1030
|
+
/**
|
|
1031
|
+
* A tree of nodes, for taxonomy fields to pick from.
|
|
1032
|
+
*
|
|
1033
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
1034
|
+
* checks, reported together with the rest of the config's.
|
|
1035
|
+
*/
|
|
1036
|
+
function taxonomy(input) {
|
|
1037
|
+
return {
|
|
1038
|
+
__typename: "Taxonomy",
|
|
1039
|
+
apiId: input.apiId,
|
|
1040
|
+
displayName: input.displayName,
|
|
1041
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
1042
|
+
root: taxonomyNode(input.root),
|
|
1043
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
1044
|
+
};
|
|
1045
|
+
}
|
|
1046
|
+
function taxonomyNode(input) {
|
|
1047
|
+
return {
|
|
1048
|
+
apiId: input.apiId,
|
|
1049
|
+
displayName: input.displayName,
|
|
1050
|
+
children: (input.children ?? []).map(taxonomyNode),
|
|
1051
|
+
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* The tree as a list of nodes, each naming its parent, sorted by apiId:
|
|
1056
|
+
* siblings have no order. `renamedFrom` is intent, not schema, and stays
|
|
1057
|
+
* out.
|
|
1058
|
+
*/
|
|
1059
|
+
function convertTaxonomyToIR(taxonomy) {
|
|
1060
|
+
return {
|
|
1061
|
+
apiId: taxonomy.apiId,
|
|
1062
|
+
displayName: taxonomy.displayName,
|
|
1063
|
+
description: taxonomy.description,
|
|
1064
|
+
nodes: flatten(taxonomy.root, null).toSorted(byApiId)
|
|
1065
|
+
};
|
|
1066
|
+
}
|
|
1067
|
+
function flatten(node, parent) {
|
|
1068
|
+
return [{
|
|
1069
|
+
apiId: node.apiId,
|
|
1070
|
+
displayName: node.displayName,
|
|
1071
|
+
parent
|
|
1072
|
+
}, ...node.children.flatMap((child) => flatten(child, node.apiId))];
|
|
1073
|
+
}
|
|
1074
|
+
//#endregion
|
|
1075
|
+
//#region src/define/resources/environment.ts
|
|
1076
|
+
/**
|
|
1077
|
+
* One environment: typed arrays per resource kind. The what.
|
|
1078
|
+
*
|
|
1079
|
+
* Ordering, keying and positions are not decided here. This returns the
|
|
1080
|
+
* resources as written; `convertToIR` turns them into the canonical form.
|
|
1081
|
+
*/
|
|
1082
|
+
function environment(input) {
|
|
1083
|
+
return {
|
|
1084
|
+
__typename: "Environment",
|
|
1085
|
+
locales: [...input.locales],
|
|
1086
|
+
stages: [...input.stages],
|
|
1087
|
+
enumerations: [...input.enumerations ?? []],
|
|
1088
|
+
taxonomies: [...input.taxonomies ?? []],
|
|
1089
|
+
components: [...input.components ?? []],
|
|
1090
|
+
models: [...input.models]
|
|
1091
|
+
};
|
|
1092
|
+
}
|
|
1093
|
+
/** Converts every resource it holds on the way. */
|
|
1094
|
+
function convertEnvironmentToIR(environment) {
|
|
1095
|
+
return {
|
|
1096
|
+
locales: environment.locales.map((locale) => convertLocaleToIR(locale)).toSorted(byApiId),
|
|
1097
|
+
stages: environment.stages.map((stage, index) => convertStageToIR(stage, index)).toSorted(byApiId),
|
|
1098
|
+
enumerations: environment.enumerations.map((enumeration) => convertEnumerationToIR(enumeration)).toSorted(byApiId),
|
|
1099
|
+
taxonomies: environment.taxonomies.map((taxonomy) => convertTaxonomyToIR(taxonomy)).toSorted(byApiId),
|
|
1100
|
+
components: environment.components.map((component) => convertComponentToIR(component)).toSorted(byApiId),
|
|
1101
|
+
models: environment.models.map((model) => convertModelToIR(model)).toSorted(byApiId)
|
|
1102
|
+
};
|
|
1103
|
+
}
|
|
1104
|
+
/**
|
|
1105
|
+
* The renames the locales, the models, the components, the enumerations,
|
|
1106
|
+
* the taxonomies and what they hold declare, and the fields' migration
|
|
1107
|
+
* values. Locale, model, component, enumeration and taxonomy renames are
|
|
1108
|
+
* sorted by apiId, the rest by their parent's apiId and then their own.
|
|
1109
|
+
*/
|
|
1110
|
+
function collectIntents(environment) {
|
|
1111
|
+
const localeRenames = environment.locales.flatMap((locale) => locale.renamedFrom === null ? [] : [{
|
|
1112
|
+
resource: "locale",
|
|
1113
|
+
apiId: locale.apiId,
|
|
1114
|
+
renamedFrom: locale.renamedFrom
|
|
1115
|
+
}]);
|
|
1116
|
+
const enumerationRenames = environment.enumerations.flatMap((enumeration) => enumeration.renamedFrom === null ? [] : [{
|
|
1117
|
+
resource: "enumeration",
|
|
1118
|
+
apiId: enumeration.apiId,
|
|
1119
|
+
renamedFrom: enumeration.renamedFrom
|
|
1120
|
+
}]);
|
|
1121
|
+
const valueRenames = environment.enumerations.toSorted(byApiId).flatMap((enumeration) => enumeration.values.toSorted(byApiId).flatMap((value) => value.renamedFrom === null ? [] : [{
|
|
1122
|
+
enumeration: enumeration.apiId,
|
|
1123
|
+
apiId: value.apiId,
|
|
1124
|
+
renamedFrom: value.renamedFrom
|
|
1125
|
+
}]));
|
|
1126
|
+
const taxonomyRenames = environment.taxonomies.flatMap((taxonomy) => taxonomy.renamedFrom === null ? [] : [{
|
|
1127
|
+
resource: "taxonomy",
|
|
1128
|
+
apiId: taxonomy.apiId,
|
|
1129
|
+
renamedFrom: taxonomy.renamedFrom
|
|
1130
|
+
}]);
|
|
1131
|
+
const nodeRenames = environment.taxonomies.toSorted(byApiId).flatMap((taxonomy) => treeNodes(taxonomy.root).toSorted(byApiId).flatMap((node) => node.renamedFrom === null ? [] : [{
|
|
1132
|
+
taxonomy: taxonomy.apiId,
|
|
1133
|
+
apiId: node.apiId,
|
|
1134
|
+
renamedFrom: node.renamedFrom
|
|
1135
|
+
}]));
|
|
1136
|
+
const modelRenames = environment.models.flatMap((model) => model.renamedFrom === null ? [] : [{
|
|
1137
|
+
resource: "model",
|
|
1138
|
+
apiId: model.apiId,
|
|
1139
|
+
renamedFrom: model.renamedFrom
|
|
1140
|
+
}]);
|
|
1141
|
+
const componentRenames = environment.components.flatMap((component) => component.renamedFrom === null ? [] : [{
|
|
1142
|
+
resource: "component",
|
|
1143
|
+
apiId: component.apiId,
|
|
1144
|
+
renamedFrom: component.renamedFrom
|
|
1145
|
+
}]);
|
|
1146
|
+
const parents = [...environment.models, ...environment.components].toSorted(byApiId);
|
|
1147
|
+
const fieldRenames = parents.flatMap((parent) => parent.fields.toSorted(byApiId).flatMap((field) => field.__typename === "UnsupportedField" || field.renamedFrom === null ? [] : [{
|
|
1148
|
+
parent: parent.apiId,
|
|
1149
|
+
apiId: field.apiId,
|
|
1150
|
+
renamedFrom: field.renamedFrom
|
|
1151
|
+
}]));
|
|
1152
|
+
const migrationValues = parents.flatMap((parent) => parent.fields.toSorted(byApiId).flatMap((field) => !("migrationValue" in field) || field.migrationValue === null ? [] : [{
|
|
1153
|
+
parent: parent.apiId,
|
|
1154
|
+
apiId: field.apiId,
|
|
1155
|
+
value: field.migrationValue
|
|
1156
|
+
}]));
|
|
1157
|
+
return {
|
|
1158
|
+
renames: [
|
|
1159
|
+
...localeRenames,
|
|
1160
|
+
...modelRenames,
|
|
1161
|
+
...componentRenames,
|
|
1162
|
+
...enumerationRenames,
|
|
1163
|
+
...taxonomyRenames
|
|
1164
|
+
].toSorted(byApiId),
|
|
1165
|
+
fieldRenames,
|
|
1166
|
+
valueRenames,
|
|
1167
|
+
nodeRenames,
|
|
1168
|
+
migrationValues
|
|
1169
|
+
};
|
|
1170
|
+
}
|
|
1171
|
+
/** A node and every node below it. */
|
|
1172
|
+
function treeNodes(node) {
|
|
1173
|
+
return [node, ...node.children.flatMap(treeNodes)];
|
|
1174
|
+
}
|
|
1175
|
+
//#endregion
|
|
1176
|
+
//#region src/define/fields/dateTime.ts
|
|
1177
|
+
/**
|
|
1178
|
+
* A moment, such as when an event starts. Values are ISO 8601 with seconds
|
|
1179
|
+
* and `Z` or an offset like `+02:00`, `"2026-09-29T10:00:00Z"`. Same
|
|
1180
|
+
* options as `date`. A `migrationValue` loses its fractions of a second.
|
|
1181
|
+
*/
|
|
1182
|
+
function dateTime(input) {
|
|
1183
|
+
return {
|
|
1184
|
+
__typename: "DateTimeField",
|
|
1185
|
+
...dateFieldAttributes(input)
|
|
1186
|
+
};
|
|
1187
|
+
}
|
|
1188
|
+
//#endregion
|
|
1189
|
+
//#region src/define/fields/float.ts
|
|
1190
|
+
/** A decimal number, such as a price or a rating. Same options as `int`. */
|
|
1191
|
+
function float(input) {
|
|
1192
|
+
return {
|
|
1193
|
+
__typename: "FloatField",
|
|
1194
|
+
...numberFieldAttributes(input)
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
//#endregion
|
|
1198
|
+
//#region src/define/fields/int.ts
|
|
1199
|
+
/** A whole number, such as a count or a year. */
|
|
1200
|
+
function int(input) {
|
|
1201
|
+
return {
|
|
1202
|
+
__typename: "IntField",
|
|
1203
|
+
...numberFieldAttributes(input)
|
|
1204
|
+
};
|
|
1205
|
+
}
|
|
1206
|
+
//#endregion
|
|
1207
|
+
//#region src/define/fields/markdown.ts
|
|
1208
|
+
/**
|
|
1209
|
+
* Text written in Markdown. Studio's Markdown editor. Same options and
|
|
1210
|
+
* validations as `singleLine`.
|
|
1211
|
+
*/
|
|
1212
|
+
function markdown(input) {
|
|
1213
|
+
return {
|
|
1214
|
+
__typename: "MarkdownField",
|
|
1215
|
+
...stringFieldAttributes(input)
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1218
|
+
//#endregion
|
|
1219
|
+
//#region src/define/fields/multiline.ts
|
|
1220
|
+
/**
|
|
1221
|
+
* Text over several lines, such as a summary. Studio's text area editor.
|
|
1222
|
+
* Same options and validations as `singleLine`.
|
|
1223
|
+
*/
|
|
1224
|
+
function multiline(input) {
|
|
1225
|
+
return {
|
|
1226
|
+
__typename: "MultilineField",
|
|
1227
|
+
...stringFieldAttributes(input)
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
//#endregion
|
|
1231
|
+
//#region src/define/fields/referenceUnion.ts
|
|
1232
|
+
/** A reference to several models. On models every member declares `unionMember`. */
|
|
1233
|
+
function referenceUnion(_options) {
|
|
1234
|
+
return notImplemented("define.field.referenceUnion");
|
|
1235
|
+
}
|
|
1236
|
+
//#endregion
|
|
1237
|
+
//#region src/define/fields/remote.ts
|
|
1238
|
+
/** A field resolved from a remote source. `visibility` defaults to READ_ONLY. */
|
|
1239
|
+
function remote(_options) {
|
|
1240
|
+
return notImplemented("define.field.remote");
|
|
1241
|
+
}
|
|
1242
|
+
//#endregion
|
|
1243
|
+
//#region src/define/fields/richText.ts
|
|
1244
|
+
/** Rich text. `embeds` enables embedding; `actions` picks the toolbar. */
|
|
1245
|
+
function richText(_options) {
|
|
1246
|
+
return notImplemented("define.field.richText");
|
|
1247
|
+
}
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region src/define/fields/singleLine.ts
|
|
1250
|
+
/**
|
|
1251
|
+
* One line of text, such as a heading or a title. Studio's single line
|
|
1252
|
+
* editor.
|
|
1253
|
+
*/
|
|
1254
|
+
function singleLine(input) {
|
|
1255
|
+
return {
|
|
1256
|
+
__typename: "SingleLineField",
|
|
1257
|
+
...stringFieldAttributes(input)
|
|
1258
|
+
};
|
|
1259
|
+
}
|
|
1260
|
+
//#endregion
|
|
1261
|
+
//#region src/define/fields/slug.ts
|
|
1262
|
+
/** What `slug` fills in for an option it is not given, as Studio creates one. */
|
|
1263
|
+
const SLUG_DEFAULTS = {
|
|
1264
|
+
...FIELD_DEFAULTS,
|
|
1265
|
+
unique: true,
|
|
1266
|
+
lowercase: true,
|
|
1267
|
+
autoGenerate: false
|
|
1268
|
+
};
|
|
1269
|
+
/**
|
|
1270
|
+
* A URL friendly identifier. Studio's slug editor. Unique and lowercase
|
|
1271
|
+
* unless said otherwise, as Studio creates one.
|
|
1272
|
+
*/
|
|
1273
|
+
function slug(input) {
|
|
1274
|
+
return {
|
|
1275
|
+
__typename: "SlugField",
|
|
1276
|
+
...stringFieldAttributes({
|
|
1277
|
+
...input,
|
|
1278
|
+
list: false
|
|
1279
|
+
}, SLUG_DEFAULTS),
|
|
1280
|
+
lowercase: input.lowercase ?? SLUG_DEFAULTS.lowercase,
|
|
1281
|
+
autoGenerate: input.autoGenerate ?? SLUG_DEFAULTS.autoGenerate,
|
|
1282
|
+
template: isEmpty(input.template) ? null : input.template
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
//#endregion
|
|
1286
|
+
//#region src/define/fields/unionMember.ts
|
|
1287
|
+
/** The slot a union's member model declares. All members share one `apiId`. Models only. */
|
|
1288
|
+
function unionMember(_options) {
|
|
1289
|
+
return notImplemented("define.field.unionMember");
|
|
1290
|
+
}
|
|
1291
|
+
//#endregion
|
|
1292
|
+
//#region src/define/fields/vector.ts
|
|
1293
|
+
/** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
|
|
1294
|
+
function vector(_options) {
|
|
1295
|
+
return notImplemented("define.field.vector");
|
|
1296
|
+
}
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region src/define/fields/index.ts
|
|
1299
|
+
var fields_exports = /* @__PURE__ */ __exportAll({
|
|
1300
|
+
asset: () => asset$1,
|
|
1301
|
+
boolean: () => boolean,
|
|
1302
|
+
color: () => color,
|
|
1303
|
+
component: () => component$1,
|
|
1304
|
+
componentUnion: () => componentUnion,
|
|
1305
|
+
date: () => date,
|
|
1306
|
+
dateTime: () => dateTime,
|
|
1307
|
+
enumeration: () => enumeration$1,
|
|
1308
|
+
float: () => float,
|
|
1309
|
+
int: () => int,
|
|
1310
|
+
json: () => json,
|
|
1311
|
+
location: () => location,
|
|
1312
|
+
markdown: () => markdown,
|
|
1313
|
+
multiline: () => multiline,
|
|
1314
|
+
referenceOneWay: () => referenceOneWay,
|
|
1315
|
+
referenceTwoWay: () => referenceTwoWay,
|
|
1316
|
+
referenceUnion: () => referenceUnion,
|
|
1317
|
+
remote: () => remote,
|
|
1318
|
+
richText: () => richText,
|
|
1319
|
+
singleLine: () => singleLine,
|
|
1320
|
+
slug: () => slug,
|
|
1321
|
+
string: () => string,
|
|
1322
|
+
taxonomy: () => taxonomy$1,
|
|
1323
|
+
unionMember: () => unionMember,
|
|
1324
|
+
unsupported: () => unsupported,
|
|
1325
|
+
vector: () => vector
|
|
1326
|
+
});
|
|
1327
|
+
//#endregion
|
|
1328
|
+
//#region src/define/resources/graphqlRemoteSource.ts
|
|
1329
|
+
function graphqlRemoteSource(_options) {
|
|
1330
|
+
return notImplemented("define.graphqlRemoteSource");
|
|
1331
|
+
}
|
|
1332
|
+
//#endregion
|
|
1333
|
+
//#region src/define/resources/restRemoteSource.ts
|
|
1334
|
+
function restRemoteSource(_options) {
|
|
1335
|
+
return notImplemented("define.restRemoteSource");
|
|
1336
|
+
}
|
|
1337
|
+
//#endregion
|
|
1338
|
+
//#region src/define/resources/target.ts
|
|
1339
|
+
/**
|
|
1340
|
+
* One environment of one project, where to reach it and the token to do so,
|
|
1341
|
+
* and the environment definition to apply there. The where.
|
|
1342
|
+
*/
|
|
1343
|
+
function target(input) {
|
|
1344
|
+
return {
|
|
1345
|
+
__typename: "Target",
|
|
1346
|
+
name: input.name,
|
|
1347
|
+
project: input.project.replace(/-/g, ""),
|
|
1348
|
+
environment: input.environment,
|
|
1349
|
+
endpoint: input.endpoint,
|
|
1350
|
+
token: input.token,
|
|
1351
|
+
apply: input.apply
|
|
1352
|
+
};
|
|
1353
|
+
}
|
|
1354
|
+
//#endregion
|
|
1355
|
+
//#region src/define/index.ts
|
|
1356
|
+
var define_exports = /* @__PURE__ */ __exportAll({
|
|
1357
|
+
component: () => component,
|
|
1358
|
+
enumeration: () => enumeration,
|
|
1359
|
+
environment: () => environment,
|
|
1360
|
+
field: () => fields_exports,
|
|
1361
|
+
graphqlRemoteSource: () => graphqlRemoteSource,
|
|
1362
|
+
locale: () => locale,
|
|
1363
|
+
model: () => model,
|
|
1364
|
+
restRemoteSource: () => restRemoteSource,
|
|
1365
|
+
stage: () => stage$1,
|
|
1366
|
+
target: () => target,
|
|
1367
|
+
taxonomy: () => taxonomy
|
|
1368
|
+
});
|
|
1369
|
+
//#endregion
|
|
1370
|
+
//#region src/define/system/asset.ts
|
|
1371
|
+
function asset(_options) {
|
|
1372
|
+
return notImplemented("system.asset");
|
|
1373
|
+
}
|
|
1374
|
+
//#endregion
|
|
1375
|
+
//#region src/define/system/query.ts
|
|
1376
|
+
function query(_options) {
|
|
1377
|
+
return notImplemented("system.query");
|
|
1378
|
+
}
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region src/define/system/segment.ts
|
|
1381
|
+
function segment(_options) {
|
|
1382
|
+
return notImplemented("system.segment");
|
|
1383
|
+
}
|
|
1384
|
+
//#endregion
|
|
1385
|
+
//#region src/define/system/stage.ts
|
|
1386
|
+
const stage = {
|
|
1387
|
+
/** Draft. Always the first of `stages`. */
|
|
1388
|
+
draft() {
|
|
1389
|
+
return {
|
|
1390
|
+
__typename: "SystemStage",
|
|
1391
|
+
apiId: "DRAFT"
|
|
1392
|
+
};
|
|
1393
|
+
},
|
|
1394
|
+
/** Published. Anywhere in `stages` after Draft. */
|
|
1395
|
+
published() {
|
|
1396
|
+
return {
|
|
1397
|
+
__typename: "SystemStage",
|
|
1398
|
+
apiId: "PUBLISHED"
|
|
1399
|
+
};
|
|
1400
|
+
}
|
|
1401
|
+
};
|
|
1402
|
+
//#endregion
|
|
1403
|
+
//#region src/define/system/index.ts
|
|
1404
|
+
var system_exports = /* @__PURE__ */ __exportAll({
|
|
1405
|
+
asset: () => asset,
|
|
1406
|
+
query: () => query,
|
|
1407
|
+
segment: () => segment,
|
|
1408
|
+
stage: () => stage
|
|
1409
|
+
});
|
|
1410
|
+
//#endregion
|
|
1411
|
+
export { SLUG_DEFAULTS as a, environment as c, assetReverseApiId as d, isEmpty as f, target as i, byApiId as l, stage as n, collectIntents as o, define_exports as r, convertEnvironmentToIR as s, system_exports as t, FIELD_DEFAULTS as u };
|