@hygraph/cli 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7121 -5547
- package/dist/define.d.ts +258 -15
- package/dist/define2.js +235 -27
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/define2.js
CHANGED
|
@@ -9,6 +9,33 @@ function isEmpty(value) {
|
|
|
9
9
|
return value === void 0 || value === null || value === "";
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
+
//#region src/define/fields/renderer.ts
|
|
13
|
+
/**
|
|
14
|
+
* An app's element with its defaults filled in. Nothing is checked here: a
|
|
15
|
+
* config that leaves it out, which only an untyped one can, gets empty
|
|
16
|
+
* apiIds, which the plan's config checks report.
|
|
17
|
+
*/
|
|
18
|
+
function appRenderer(input) {
|
|
19
|
+
return { app: {
|
|
20
|
+
appApiId: input?.app?.appApiId ?? "",
|
|
21
|
+
appElementApiId: input?.app?.appElementApiId ?? "",
|
|
22
|
+
config: { ...input?.app?.config }
|
|
23
|
+
} };
|
|
24
|
+
}
|
|
25
|
+
/** The renderer as the IR holds it, `null` for Hygraph's editor. */
|
|
26
|
+
function convertFieldRendererToIR(renderer) {
|
|
27
|
+
return renderer === null ? null : convertAppRendererToIR(renderer);
|
|
28
|
+
}
|
|
29
|
+
/** An app's element as the IR holds it: no settings is `null`. */
|
|
30
|
+
function convertAppRendererToIR(renderer) {
|
|
31
|
+
const { appApiId, appElementApiId, config } = renderer.app;
|
|
32
|
+
return { app: {
|
|
33
|
+
appApiId,
|
|
34
|
+
appElementApiId,
|
|
35
|
+
config: Object.keys(config).length === 0 ? null : { ...config }
|
|
36
|
+
} };
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
12
39
|
//#region src/define/fields/asset.ts
|
|
13
40
|
/**
|
|
14
41
|
* One asset, or a list of them, that editors connect to the entry. Hygraph
|
|
@@ -32,6 +59,7 @@ function asset$1(input) {
|
|
|
32
59
|
visibilityCondition: input.visibilityCondition ?? null,
|
|
33
60
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
34
61
|
reverse: isEmpty(input.reverse) ? null : input.reverse,
|
|
62
|
+
renderer: null,
|
|
35
63
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
36
64
|
};
|
|
37
65
|
}
|
|
@@ -48,6 +76,7 @@ function convertAssetFieldToIR(field, position) {
|
|
|
48
76
|
visibility: field.visibility,
|
|
49
77
|
visibilityCondition: field.visibilityCondition,
|
|
50
78
|
variantEnabled: field.variantEnabled,
|
|
79
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
51
80
|
...field.reverse !== null && { reverse: field.reverse }
|
|
52
81
|
};
|
|
53
82
|
}
|
|
@@ -103,7 +132,8 @@ function convertAssetReverseFieldToIR(field, position) {
|
|
|
103
132
|
required: false,
|
|
104
133
|
visibility: field.visibility,
|
|
105
134
|
visibilityCondition: null,
|
|
106
|
-
variantEnabled: false
|
|
135
|
+
variantEnabled: false,
|
|
136
|
+
formRenderer: null
|
|
107
137
|
};
|
|
108
138
|
}
|
|
109
139
|
//#endregion
|
|
@@ -131,6 +161,7 @@ function boolean(input) {
|
|
|
131
161
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
132
162
|
initialValue: booleanValue(input.initialValue),
|
|
133
163
|
migrationValue: booleanValue(input.migrationValue),
|
|
164
|
+
renderer: null,
|
|
134
165
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
135
166
|
};
|
|
136
167
|
}
|
|
@@ -150,6 +181,7 @@ function convertBooleanFieldToIR(field, position) {
|
|
|
150
181
|
visibility: field.visibility,
|
|
151
182
|
visibilityCondition: field.visibilityCondition,
|
|
152
183
|
variantEnabled: field.variantEnabled,
|
|
184
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
153
185
|
initialValue: field.initialValue
|
|
154
186
|
};
|
|
155
187
|
}
|
|
@@ -180,6 +212,7 @@ function color(input) {
|
|
|
180
212
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
181
213
|
initialValue: colorValue(input.initialValue),
|
|
182
214
|
migrationValue: colorValue(input.migrationValue),
|
|
215
|
+
renderer: null,
|
|
183
216
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
184
217
|
};
|
|
185
218
|
}
|
|
@@ -199,6 +232,7 @@ function convertColorFieldToIR(field, position) {
|
|
|
199
232
|
visibility: field.visibility,
|
|
200
233
|
visibilityCondition: field.visibilityCondition,
|
|
201
234
|
variantEnabled: field.variantEnabled,
|
|
235
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
202
236
|
initialValue: field.initialValue
|
|
203
237
|
};
|
|
204
238
|
}
|
|
@@ -315,6 +349,7 @@ function dateFieldAttributes(input) {
|
|
|
315
349
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
316
350
|
initialValue: dateValue(input.initialValue),
|
|
317
351
|
migrationValue: dateValue(input.migrationValue),
|
|
352
|
+
renderer: null,
|
|
318
353
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
319
354
|
};
|
|
320
355
|
}
|
|
@@ -337,6 +372,7 @@ function convertDateFieldToIR(field, position) {
|
|
|
337
372
|
visibility: field.visibility,
|
|
338
373
|
visibilityCondition: field.visibilityCondition,
|
|
339
374
|
variantEnabled: field.variantEnabled,
|
|
375
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
340
376
|
initialValue: field.initialValue
|
|
341
377
|
};
|
|
342
378
|
}
|
|
@@ -426,6 +462,7 @@ function json(input) {
|
|
|
426
462
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
427
463
|
initialValue: jsonValue(input.initialValue),
|
|
428
464
|
migrationValue: jsonValue(input.migrationValue),
|
|
465
|
+
renderer: null,
|
|
429
466
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
430
467
|
};
|
|
431
468
|
}
|
|
@@ -445,6 +482,7 @@ function convertJsonFieldToIR(field, position) {
|
|
|
445
482
|
visibility: field.visibility,
|
|
446
483
|
visibilityCondition: field.visibilityCondition,
|
|
447
484
|
variantEnabled: field.variantEnabled,
|
|
485
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
448
486
|
initialValue: field.initialValue
|
|
449
487
|
};
|
|
450
488
|
}
|
|
@@ -479,6 +517,7 @@ function location(input) {
|
|
|
479
517
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
480
518
|
initialValue: locationValue(input.initialValue),
|
|
481
519
|
migrationValue: locationValue(input.migrationValue),
|
|
520
|
+
renderer: null,
|
|
482
521
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
483
522
|
};
|
|
484
523
|
}
|
|
@@ -498,6 +537,7 @@ function convertLocationFieldToIR(field, position) {
|
|
|
498
537
|
visibility: field.visibility,
|
|
499
538
|
visibilityCondition: field.visibilityCondition,
|
|
500
539
|
variantEnabled: field.variantEnabled,
|
|
540
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
501
541
|
initialValue: field.initialValue
|
|
502
542
|
};
|
|
503
543
|
}
|
|
@@ -539,6 +579,7 @@ function numberFieldAttributes(input) {
|
|
|
539
579
|
initialValue: numberValue(input.initialValue),
|
|
540
580
|
migrationValue: numberValue(input.migrationValue),
|
|
541
581
|
validations: numberValidationRules(input.validations),
|
|
582
|
+
renderer: null,
|
|
542
583
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
543
584
|
};
|
|
544
585
|
}
|
|
@@ -561,6 +602,7 @@ function convertNumberFieldToIR(field, position) {
|
|
|
561
602
|
visibility: field.visibility,
|
|
562
603
|
visibilityCondition: field.visibilityCondition,
|
|
563
604
|
variantEnabled: field.variantEnabled,
|
|
605
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
564
606
|
initialValue: field.initialValue,
|
|
565
607
|
validations: field.validations
|
|
566
608
|
};
|
|
@@ -602,6 +644,7 @@ function referenceOneWay(input) {
|
|
|
602
644
|
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
603
645
|
visibilityCondition: input.visibilityCondition ?? null,
|
|
604
646
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
647
|
+
renderer: null,
|
|
605
648
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
606
649
|
};
|
|
607
650
|
}
|
|
@@ -626,7 +669,8 @@ function convertReferenceOneWayFieldToIR(field, position) {
|
|
|
626
669
|
required: false,
|
|
627
670
|
visibility: field.visibility,
|
|
628
671
|
visibilityCondition: field.visibilityCondition,
|
|
629
|
-
variantEnabled: field.variantEnabled
|
|
672
|
+
variantEnabled: field.variantEnabled,
|
|
673
|
+
formRenderer: convertFieldRendererToIR(field.renderer)
|
|
630
674
|
};
|
|
631
675
|
}
|
|
632
676
|
//#endregion
|
|
@@ -656,6 +700,7 @@ function referenceTwoWay(input) {
|
|
|
656
700
|
visibility: input.visibility ?? FIELD_DEFAULTS.visibility,
|
|
657
701
|
visibilityCondition: input.visibilityCondition ?? null,
|
|
658
702
|
variantEnabled: input.variantEnabled ?? FIELD_DEFAULTS.variantEnabled,
|
|
703
|
+
renderer: null,
|
|
659
704
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
660
705
|
};
|
|
661
706
|
}
|
|
@@ -674,7 +719,8 @@ function convertReferenceTwoWayFieldToIR(field, position) {
|
|
|
674
719
|
required: false,
|
|
675
720
|
visibility: field.visibility,
|
|
676
721
|
visibilityCondition: field.visibilityCondition,
|
|
677
|
-
variantEnabled: field.variantEnabled
|
|
722
|
+
variantEnabled: field.variantEnabled,
|
|
723
|
+
formRenderer: convertFieldRendererToIR(field.renderer)
|
|
678
724
|
};
|
|
679
725
|
}
|
|
680
726
|
//#endregion
|
|
@@ -4827,6 +4873,21 @@ function byApiId(a, b) {
|
|
|
4827
4873
|
function byPrefix(a, b) {
|
|
4828
4874
|
return byApiId({ apiId: a.prefix }, { apiId: b.prefix });
|
|
4829
4875
|
}
|
|
4876
|
+
/**
|
|
4877
|
+
* What tells a model's sidebar panels apart: the type of one of Hygraph's,
|
|
4878
|
+
* the app and element of an app's. A model has each at most once.
|
|
4879
|
+
*/
|
|
4880
|
+
function sidebarElementKey(element) {
|
|
4881
|
+
switch (element.kind) {
|
|
4882
|
+
case "system": return element.type;
|
|
4883
|
+
case "previewUrls": return "PREVIEW_URLS";
|
|
4884
|
+
case "app": return `${element.appApiId}/${element.appElementApiId}`;
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
/** `byApiId` for sidebar panels, by `sidebarElementKey`. */
|
|
4888
|
+
function bySidebarElementKey(a, b) {
|
|
4889
|
+
return byApiId({ apiId: sidebarElementKey(a) }, { apiId: sidebarElementKey(b) });
|
|
4890
|
+
}
|
|
4830
4891
|
//#endregion
|
|
4831
4892
|
//#region src/ir/sdl.ts
|
|
4832
4893
|
/**
|
|
@@ -5051,6 +5112,7 @@ function richText(input) {
|
|
|
5051
5112
|
migrationValue: richTextValue(input.migrationValue),
|
|
5052
5113
|
embeds: input.embeds === void 0 ? null : [...input.embeds],
|
|
5053
5114
|
actions: input.actions === void 0 ? null : [...input.actions],
|
|
5115
|
+
renderer: null,
|
|
5054
5116
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5055
5117
|
};
|
|
5056
5118
|
}
|
|
@@ -5074,6 +5136,7 @@ function convertRichTextFieldToIR(field, position) {
|
|
|
5074
5136
|
visibility: field.visibility,
|
|
5075
5137
|
visibilityCondition: field.visibilityCondition,
|
|
5076
5138
|
variantEnabled: field.variantEnabled,
|
|
5139
|
+
formRenderer: convertFieldRendererToIR(field.renderer),
|
|
5077
5140
|
initialValue: field.initialValue,
|
|
5078
5141
|
embeds: field.embeds?.map((model) => model().apiId).toSorted() ?? null,
|
|
5079
5142
|
actions: richTextActions(field.actions)
|
|
@@ -5106,17 +5169,6 @@ function richTextValue(value) {
|
|
|
5106
5169
|
return value === void 0 || isEmptyRichText(value) ? null : value;
|
|
5107
5170
|
}
|
|
5108
5171
|
//#endregion
|
|
5109
|
-
//#region src/define/not-implemented.ts
|
|
5110
|
-
/**
|
|
5111
|
-
* Every builder is declared so the authoring surface is fixed, but none of
|
|
5112
|
-
* them are implemented yet. They throw rather than returning a half-shaped
|
|
5113
|
-
* object: a config that silently produced the wrong schema would be worse
|
|
5114
|
-
* than one that refuses to load.
|
|
5115
|
-
*/
|
|
5116
|
-
function notImplemented(builder) {
|
|
5117
|
-
throw new Error(`${builder} is not implemented yet`);
|
|
5118
|
-
}
|
|
5119
|
-
//#endregion
|
|
5120
5172
|
//#region src/define/fields/string.ts
|
|
5121
5173
|
/**
|
|
5122
5174
|
* The attributes every editor's builder returns, filling in its
|
|
@@ -5142,7 +5194,10 @@ function stringFieldAttributes(input, defaults = FIELD_DEFAULTS) {
|
|
|
5142
5194
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5143
5195
|
};
|
|
5144
5196
|
}
|
|
5145
|
-
/**
|
|
5197
|
+
/**
|
|
5198
|
+
* The form renderer each of Hygraph's text editors' `__typename` stands
|
|
5199
|
+
* for, in the IR. `StringField` is an app's, `define.field.custom.string`.
|
|
5200
|
+
*/
|
|
5146
5201
|
const FORM_RENDERERS = {
|
|
5147
5202
|
SingleLineField: "GCMS_SINGLE_LINE",
|
|
5148
5203
|
MultilineField: "GCMS_MULTI_LINE",
|
|
@@ -5150,13 +5205,14 @@ const FORM_RENDERERS = {
|
|
|
5150
5205
|
SlugField: "GCMS_SLUG"
|
|
5151
5206
|
};
|
|
5152
5207
|
/**
|
|
5153
|
-
* The IR names the form renderer, which the config says by `__typename
|
|
5154
|
-
* `renamedFrom` and `migrationValue` are intent, not
|
|
5208
|
+
* The IR names the form renderer, which the config says by `__typename`,
|
|
5209
|
+
* or the app's element. `renamedFrom` and `migrationValue` are intent, not
|
|
5210
|
+
* schema, and stay out.
|
|
5155
5211
|
*/
|
|
5156
5212
|
function convertStringFieldToIR(field, position) {
|
|
5157
5213
|
return {
|
|
5158
5214
|
kind: "string",
|
|
5159
|
-
formRenderer: FORM_RENDERERS[field.__typename],
|
|
5215
|
+
formRenderer: field.__typename === "StringField" ? convertAppRendererToIR(field.renderer) : FORM_RENDERERS[field.__typename],
|
|
5160
5216
|
apiId: field.apiId,
|
|
5161
5217
|
displayName: field.displayName,
|
|
5162
5218
|
description: field.description,
|
|
@@ -5183,10 +5239,6 @@ function textValue(value) {
|
|
|
5183
5239
|
if (value === void 0 || value === "") return null;
|
|
5184
5240
|
return Array.isArray(value) && value.length === 0 ? null : value;
|
|
5185
5241
|
}
|
|
5186
|
-
/** Text rendered by an installed app's element. `renderer` is required. */
|
|
5187
|
-
function string(_options) {
|
|
5188
|
-
return notImplemented("define.field.string");
|
|
5189
|
-
}
|
|
5190
5242
|
/** The validations with every default filled in, `null` when there are none. */
|
|
5191
5243
|
function stringValidationRules(input) {
|
|
5192
5244
|
if (input === void 0) return null;
|
|
@@ -5352,11 +5404,86 @@ function convertTypeToIR(field, position) {
|
|
|
5352
5404
|
case "SingleLineField":
|
|
5353
5405
|
case "MultilineField":
|
|
5354
5406
|
case "MarkdownField":
|
|
5355
|
-
case "SlugField":
|
|
5407
|
+
case "SlugField":
|
|
5408
|
+
case "StringField": return convertStringFieldToIR(field, position);
|
|
5356
5409
|
case "UnsupportedField": return convertUnsupportedFieldToIR(field, position);
|
|
5357
5410
|
}
|
|
5358
5411
|
}
|
|
5359
5412
|
//#endregion
|
|
5413
|
+
//#region src/define/resources/sidebar.ts
|
|
5414
|
+
/**
|
|
5415
|
+
* The titles Hygraph gives its panels, which no app panel on the same model
|
|
5416
|
+
* may have. The batch finds a panel to change by its title.
|
|
5417
|
+
*/
|
|
5418
|
+
const SYSTEM_SIDEBAR_DISPLAY_NAMES = {
|
|
5419
|
+
INFORMATION: "Entry information",
|
|
5420
|
+
RELEASES: "Schedule",
|
|
5421
|
+
STAGES: "Stages",
|
|
5422
|
+
LOCALIZATIONS: "Localizations",
|
|
5423
|
+
VERSIONS: "Versions",
|
|
5424
|
+
PREVIEW_URLS: "Preview",
|
|
5425
|
+
CONTENT_WORKFLOWS: "Content workflows",
|
|
5426
|
+
VARIANTS: "Variants",
|
|
5427
|
+
AGENTS: "Agents",
|
|
5428
|
+
TAGS: "Tags"
|
|
5429
|
+
};
|
|
5430
|
+
function sidebarElement(input) {
|
|
5431
|
+
switch (input.element) {
|
|
5432
|
+
case "PREVIEW_URLS": return {
|
|
5433
|
+
element: "PREVIEW_URLS",
|
|
5434
|
+
previewUrls: input.previewUrls.map(previewUrl),
|
|
5435
|
+
variantPreviewUrls: (input.variantPreviewUrls ?? []).map(previewUrl),
|
|
5436
|
+
openInNewTab: input.openInNewTab ?? false
|
|
5437
|
+
};
|
|
5438
|
+
case "app": return {
|
|
5439
|
+
element: "app",
|
|
5440
|
+
appApiId: input.appApiId,
|
|
5441
|
+
appElementApiId: input.appElementApiId,
|
|
5442
|
+
displayName: input.displayName,
|
|
5443
|
+
description: isEmpty(input.description) ? null : input.description,
|
|
5444
|
+
config: { ...input.config }
|
|
5445
|
+
};
|
|
5446
|
+
default: return { element: input.element };
|
|
5447
|
+
}
|
|
5448
|
+
}
|
|
5449
|
+
function previewUrl({ name, template }) {
|
|
5450
|
+
return {
|
|
5451
|
+
name,
|
|
5452
|
+
template
|
|
5453
|
+
};
|
|
5454
|
+
}
|
|
5455
|
+
/**
|
|
5456
|
+
* A panel's index in `sidebar` is its position. Empty lists and settings
|
|
5457
|
+
* become `null`, as the live reader reads them.
|
|
5458
|
+
*/
|
|
5459
|
+
function convertSidebarToIR(sidebar) {
|
|
5460
|
+
return sidebar.map((element, position) => {
|
|
5461
|
+
switch (element.element) {
|
|
5462
|
+
case "PREVIEW_URLS": return {
|
|
5463
|
+
kind: "previewUrls",
|
|
5464
|
+
previewUrls: element.previewUrls.map(previewUrl),
|
|
5465
|
+
variantPreviewUrls: element.variantPreviewUrls.length === 0 ? null : element.variantPreviewUrls.map(previewUrl),
|
|
5466
|
+
openInNewTab: element.openInNewTab,
|
|
5467
|
+
position
|
|
5468
|
+
};
|
|
5469
|
+
case "app": return {
|
|
5470
|
+
kind: "app",
|
|
5471
|
+
appApiId: element.appApiId,
|
|
5472
|
+
appElementApiId: element.appElementApiId,
|
|
5473
|
+
displayName: element.displayName,
|
|
5474
|
+
description: element.description,
|
|
5475
|
+
config: Object.keys(element.config).length === 0 ? null : element.config,
|
|
5476
|
+
position
|
|
5477
|
+
};
|
|
5478
|
+
default: return {
|
|
5479
|
+
kind: "system",
|
|
5480
|
+
type: element.element,
|
|
5481
|
+
position
|
|
5482
|
+
};
|
|
5483
|
+
}
|
|
5484
|
+
}).toSorted(bySidebarElementKey);
|
|
5485
|
+
}
|
|
5486
|
+
//#endregion
|
|
5360
5487
|
//#region src/define/system/model.ts
|
|
5361
5488
|
/**
|
|
5362
5489
|
* A model Hygraph provides, as `system.model.asset` or `system.model.query` hands it
|
|
@@ -5486,13 +5613,15 @@ function model$1(input) {
|
|
|
5486
5613
|
displayName: input.displayName,
|
|
5487
5614
|
description: isEmpty(input.description) ? null : input.description,
|
|
5488
5615
|
fields: [...input.fields],
|
|
5616
|
+
sidebar: input.sidebar?.map(sidebarElement) ?? null,
|
|
5489
5617
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5490
5618
|
};
|
|
5491
5619
|
}
|
|
5492
5620
|
/**
|
|
5493
5621
|
* Everything the canonical form adds to a model happens here. `renamedFrom`
|
|
5494
5622
|
* is intent, not schema, and stays out. Fields are keyed by apiId, and a
|
|
5495
|
-
* field's index in `fields` becomes its position
|
|
5623
|
+
* field's index in `fields` becomes its position, as a panel's in
|
|
5624
|
+
* `sidebar` does.
|
|
5496
5625
|
*/
|
|
5497
5626
|
function convertModelToIR(model) {
|
|
5498
5627
|
return {
|
|
@@ -5500,7 +5629,8 @@ function convertModelToIR(model) {
|
|
|
5500
5629
|
apiIdPlural: model.apiIdPlural,
|
|
5501
5630
|
displayName: model.displayName,
|
|
5502
5631
|
description: model.description,
|
|
5503
|
-
fields: Object.fromEntries(model.fields.map((field, position) => [field.apiId, convertFieldToIR(field, position)]))
|
|
5632
|
+
fields: Object.fromEntries(model.fields.map((field, position) => [field.apiId, convertFieldToIR(field, position)])),
|
|
5633
|
+
sidebar: model.sidebar === null ? null : convertSidebarToIR(model.sidebar)
|
|
5504
5634
|
};
|
|
5505
5635
|
}
|
|
5506
5636
|
//#endregion
|
|
@@ -5736,6 +5866,73 @@ function int(input) {
|
|
|
5736
5866
|
};
|
|
5737
5867
|
}
|
|
5738
5868
|
//#endregion
|
|
5869
|
+
//#region src/define/fields/custom.ts
|
|
5870
|
+
/**
|
|
5871
|
+
* Fields whose editor in Studio is an installed app's element, in place of
|
|
5872
|
+
* Hygraph's own. Each builder takes what its type's builder takes, and the
|
|
5873
|
+
* element as `renderer`. Install the app in the environment in Studio;
|
|
5874
|
+
* the element must be made for the field's type.
|
|
5875
|
+
*
|
|
5876
|
+
* @example define.field.custom.int({ apiId: "rating", displayName: "Rating", renderer: { app: { appApiId: "stars", appElementApiId: "stars", config: { max: 5 } } } })
|
|
5877
|
+
*/
|
|
5878
|
+
const custom = {
|
|
5879
|
+
/** Text. Takes what `singleLine` takes. */
|
|
5880
|
+
string: (input) => ({
|
|
5881
|
+
__typename: "StringField",
|
|
5882
|
+
...stringFieldAttributes(input),
|
|
5883
|
+
renderer: appRenderer(input.renderer)
|
|
5884
|
+
}),
|
|
5885
|
+
int: (input) => ({
|
|
5886
|
+
...int(input),
|
|
5887
|
+
renderer: appRenderer(input.renderer)
|
|
5888
|
+
}),
|
|
5889
|
+
float: (input) => ({
|
|
5890
|
+
...float(input),
|
|
5891
|
+
renderer: appRenderer(input.renderer)
|
|
5892
|
+
}),
|
|
5893
|
+
boolean: (input) => ({
|
|
5894
|
+
...boolean(input),
|
|
5895
|
+
renderer: appRenderer(input.renderer)
|
|
5896
|
+
}),
|
|
5897
|
+
date: (input) => ({
|
|
5898
|
+
...date(input),
|
|
5899
|
+
renderer: appRenderer(input.renderer)
|
|
5900
|
+
}),
|
|
5901
|
+
dateTime: (input) => ({
|
|
5902
|
+
...dateTime(input),
|
|
5903
|
+
renderer: appRenderer(input.renderer)
|
|
5904
|
+
}),
|
|
5905
|
+
json: (input) => ({
|
|
5906
|
+
...json(input),
|
|
5907
|
+
renderer: appRenderer(input.renderer)
|
|
5908
|
+
}),
|
|
5909
|
+
color: (input) => ({
|
|
5910
|
+
...color(input),
|
|
5911
|
+
renderer: appRenderer(input.renderer)
|
|
5912
|
+
}),
|
|
5913
|
+
location: (input) => ({
|
|
5914
|
+
...location(input),
|
|
5915
|
+
renderer: appRenderer(input.renderer)
|
|
5916
|
+
}),
|
|
5917
|
+
/** Rich text without `actions`: the element replaces the toolbar. */
|
|
5918
|
+
richText: (input) => ({
|
|
5919
|
+
...richText(input),
|
|
5920
|
+
renderer: appRenderer(input.renderer)
|
|
5921
|
+
}),
|
|
5922
|
+
referenceOneWay: (input) => ({
|
|
5923
|
+
...referenceOneWay(input),
|
|
5924
|
+
renderer: appRenderer(input.renderer)
|
|
5925
|
+
}),
|
|
5926
|
+
referenceTwoWay: (input) => ({
|
|
5927
|
+
...referenceTwoWay(input),
|
|
5928
|
+
renderer: appRenderer(input.renderer)
|
|
5929
|
+
}),
|
|
5930
|
+
asset: (input) => ({
|
|
5931
|
+
...asset$1(input),
|
|
5932
|
+
renderer: appRenderer(input.renderer)
|
|
5933
|
+
})
|
|
5934
|
+
};
|
|
5935
|
+
//#endregion
|
|
5739
5936
|
//#region src/define/fields/markdown.ts
|
|
5740
5937
|
/**
|
|
5741
5938
|
* Text written in Markdown. Studio's Markdown editor. Same options and
|
|
@@ -5797,6 +5994,17 @@ function slug(input) {
|
|
|
5797
5994
|
};
|
|
5798
5995
|
}
|
|
5799
5996
|
//#endregion
|
|
5997
|
+
//#region src/define/not-implemented.ts
|
|
5998
|
+
/**
|
|
5999
|
+
* Every builder is declared so the authoring surface is fixed, but none of
|
|
6000
|
+
* them are implemented yet. They throw rather than returning a half-shaped
|
|
6001
|
+
* object: a config that silently produced the wrong schema would be worse
|
|
6002
|
+
* than one that refuses to load.
|
|
6003
|
+
*/
|
|
6004
|
+
function notImplemented(builder) {
|
|
6005
|
+
throw new Error(`${builder} is not implemented yet`);
|
|
6006
|
+
}
|
|
6007
|
+
//#endregion
|
|
5800
6008
|
//#region src/define/fields/vector.ts
|
|
5801
6009
|
/** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
|
|
5802
6010
|
function vector(_options) {
|
|
@@ -5811,6 +6019,7 @@ var fields_exports = /* @__PURE__ */ __exportAll({
|
|
|
5811
6019
|
color: () => color,
|
|
5812
6020
|
component: () => component$1,
|
|
5813
6021
|
componentUnion: () => componentUnion,
|
|
6022
|
+
custom: () => custom,
|
|
5814
6023
|
date: () => date,
|
|
5815
6024
|
dateTime: () => dateTime,
|
|
5816
6025
|
enumeration: () => enumeration$1,
|
|
@@ -5828,7 +6037,6 @@ var fields_exports = /* @__PURE__ */ __exportAll({
|
|
|
5828
6037
|
richText: () => richText,
|
|
5829
6038
|
singleLine: () => singleLine,
|
|
5830
6039
|
slug: () => slug,
|
|
5831
|
-
string: () => string,
|
|
5832
6040
|
taxonomy: () => taxonomy$1,
|
|
5833
6041
|
unsupported: () => unsupported,
|
|
5834
6042
|
vector: () => vector
|
|
@@ -5987,4 +6195,4 @@ const model = {
|
|
|
5987
6195
|
segment
|
|
5988
6196
|
};
|
|
5989
6197
|
//#endregion
|
|
5990
|
-
export {
|
|
6198
|
+
export { require_parser as C, isEmpty as D, assetReverseApiId as E, sidebarElementKey as S, require_kinds as T, splitTypeDefinitions as _, SLUG_DEFAULTS as a, byPrefix as b, environment as c, RICH_TEXT_ACTIONS as d, isEmptyRichText as f, convertOAuthToIR as g, convertHeadersToIR as h, target as i, SYSTEM_SIDEBAR_DISPLAY_NAMES as l, REMOTE_DEFAULTS as m, stage as n, collectIntents as o, richTextActions as p, define_exports as r, convertEnvironmentToIR as s, system_exports as t, FIELD_DEFAULTS as u, typeDefinitionName as v, require_GraphQLError as w, bySidebarElementKey as x, byApiId as y };
|
package/dist/version.js
CHANGED