@hygraph/cli 0.0.14 → 0.0.16
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 +1012 -168
- package/dist/define.d.ts +109 -7
- package/dist/define2.js +95 -3
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/define.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ type RemoteFieldApiMethod = "GET" | "POST";
|
|
|
6
6
|
type RemoteSourceKind = "CommerceLayer" | "CommerceTools" | "Custom";
|
|
7
7
|
/** Field types */
|
|
8
8
|
type SimpleFieldType = "BOOLEAN" | "COLOR" | "DATE" | "DATETIME" | "FLOAT" | "ID" | "INT" | "JSON" | "LOCATION" | "RICHTEXT" | "STRING" | "VECTOR";
|
|
9
|
+
type SystemSidebarElementType$1 = "AGENTS" | "CONTENT_WORKFLOWS" | "INFORMATION" | "LOCALIZATIONS" | "PREVIEW_URLS" | "RELEASES" | "STAGES" | "TAGS" | "VARIANTS" | "VERSIONS";
|
|
9
10
|
//#endregion
|
|
10
11
|
//#region src/ir/types.d.ts
|
|
11
12
|
/** A colour of Hygraph's palette. */
|
|
@@ -19,6 +20,8 @@ type IRSystemStage = {
|
|
|
19
20
|
isSystem: true;
|
|
20
21
|
position: number;
|
|
21
22
|
};
|
|
23
|
+
/** Hygraph's panels that take no settings. */
|
|
24
|
+
type IRSystemSidebarElementType = Exclude<SystemSidebarElementType$1, "PREVIEW_URLS">;
|
|
22
25
|
/**
|
|
23
26
|
* Hygraph's names for the field types it has: a simple field's `type`, a
|
|
24
27
|
* relation's, or the batch operation's for the others.
|
|
@@ -91,6 +94,89 @@ type IRRichTextValue = {
|
|
|
91
94
|
/** The flags Studio offers on a pattern: case insensitive, multiline, single line. */
|
|
92
95
|
type IRRegexFlag = "i" | "m" | "s";
|
|
93
96
|
//#endregion
|
|
97
|
+
//#region src/define/resources/sidebar.d.ts
|
|
98
|
+
/**
|
|
99
|
+
* A panel Hygraph provides:
|
|
100
|
+
* - `INFORMATION`: the entry's id, dates and authors.
|
|
101
|
+
* - `STAGES`: publish and unpublish.
|
|
102
|
+
* - `LOCALIZATIONS`: switch between locales.
|
|
103
|
+
* - `VERSIONS`: earlier versions of the entry.
|
|
104
|
+
* - `RELEASES`: schedule the entry.
|
|
105
|
+
* - `CONTENT_WORKFLOWS`: the entry's workflow steps. Hygraph adds and
|
|
106
|
+
* removes it when you link a workflow to the model in Studio.
|
|
107
|
+
* - `VARIANTS`: the entry's variants. Hygraph adds it when a field of the
|
|
108
|
+
* model gets `variantEnabled: true`.
|
|
109
|
+
* - `AGENTS`: run AI agents on the entry.
|
|
110
|
+
* - `TAGS`: tag the entry. Only in projects with Tags turned on.
|
|
111
|
+
*/
|
|
112
|
+
type SystemSidebarElementType = IRSystemSidebarElementType;
|
|
113
|
+
/** One link of a preview panel. */
|
|
114
|
+
type PreviewUrl = {
|
|
115
|
+
/** The label of the link. */
|
|
116
|
+
name: string;
|
|
117
|
+
/**
|
|
118
|
+
* The URL to open. Put a field's apiId or `locale` in braces to insert
|
|
119
|
+
* the entry's value, such as `"https://example.com/{locale}/{slug}"`.
|
|
120
|
+
*/
|
|
121
|
+
template: string;
|
|
122
|
+
};
|
|
123
|
+
/** The settings of a panel of an installed app. */
|
|
124
|
+
type SidebarAppConfig = {
|
|
125
|
+
[key: string]: IRJsonValue;
|
|
126
|
+
};
|
|
127
|
+
/** One panel beside an entry in Studio, as you write it in `sidebar`. */
|
|
128
|
+
type SidebarElementInput = {
|
|
129
|
+
element: SystemSidebarElementType;
|
|
130
|
+
} | {
|
|
131
|
+
/** Links that open the entry on your site, such as a preview deployment. */
|
|
132
|
+
element: "PREVIEW_URLS";
|
|
133
|
+
/** At least one link. */
|
|
134
|
+
previewUrls: PreviewUrl[];
|
|
135
|
+
/**
|
|
136
|
+
* Links for a variant of the entry. A template can also insert
|
|
137
|
+
* `{variant.id}` and `{variant.segments[0].id}`.
|
|
138
|
+
* @default []
|
|
139
|
+
*/
|
|
140
|
+
variantPreviewUrls?: PreviewUrl[];
|
|
141
|
+
/**
|
|
142
|
+
* Open the links in a new browser tab.
|
|
143
|
+
* @default false
|
|
144
|
+
*/
|
|
145
|
+
openInNewTab?: boolean;
|
|
146
|
+
} | {
|
|
147
|
+
/** A panel of an app installed in the environment. Install the app in Studio first. */
|
|
148
|
+
element: "app";
|
|
149
|
+
/** The app's apiId. */
|
|
150
|
+
appApiId: string;
|
|
151
|
+
/** The apiId of the app's sidebar element. */
|
|
152
|
+
appElementApiId: string;
|
|
153
|
+
/** The panel's title. */
|
|
154
|
+
displayName: string;
|
|
155
|
+
/** @default null */
|
|
156
|
+
description?: string;
|
|
157
|
+
/**
|
|
158
|
+
* Settings the app reads. Which ones it takes is up to the app.
|
|
159
|
+
* @default {}
|
|
160
|
+
*/
|
|
161
|
+
config?: SidebarAppConfig;
|
|
162
|
+
};
|
|
163
|
+
/** One panel of `Model.sidebar`: the input with every default filled in. */
|
|
164
|
+
type SidebarElement = {
|
|
165
|
+
element: SystemSidebarElementType;
|
|
166
|
+
} | {
|
|
167
|
+
element: "PREVIEW_URLS";
|
|
168
|
+
previewUrls: PreviewUrl[];
|
|
169
|
+
variantPreviewUrls: PreviewUrl[];
|
|
170
|
+
openInNewTab: boolean;
|
|
171
|
+
} | {
|
|
172
|
+
element: "app";
|
|
173
|
+
appApiId: string;
|
|
174
|
+
appElementApiId: string;
|
|
175
|
+
displayName: string;
|
|
176
|
+
description: string | null;
|
|
177
|
+
config: SidebarAppConfig;
|
|
178
|
+
};
|
|
179
|
+
//#endregion
|
|
94
180
|
//#region src/define/resources/model.d.ts
|
|
95
181
|
/** A field a model takes: every type but a field back, which is on Asset. */
|
|
96
182
|
type ModelField = Exclude<Field, AssetReverseField>;
|
|
@@ -104,6 +190,26 @@ type ModelInput = {
|
|
|
104
190
|
* order editors see them in. May be empty.
|
|
105
191
|
*/
|
|
106
192
|
fields: ModelField[];
|
|
193
|
+
/**
|
|
194
|
+
* The panels beside an entry in Studio, in the order editors see them.
|
|
195
|
+
* Leave it out to keep whatever panels the model has: Hygraph's default
|
|
196
|
+
* set on a new model. Once you set it, it is the whole sidebar: a panel
|
|
197
|
+
* you leave out is removed.
|
|
198
|
+
*
|
|
199
|
+
* To start from the panels the model has now, set `sidebar: []` and run
|
|
200
|
+
* `hygraph pull`: it prints them, ready to copy in. Do not plan or apply
|
|
201
|
+
* the empty list, which removes every panel.
|
|
202
|
+
*
|
|
203
|
+
* Leave it out on a model with a panel of a legacy UI extension: the CLI
|
|
204
|
+
* cannot place panels around that one, so plan refuses the sidebar.
|
|
205
|
+
* @example
|
|
206
|
+
* sidebar: [
|
|
207
|
+
* { element: "INFORMATION" },
|
|
208
|
+
* { element: "STAGES" },
|
|
209
|
+
* { element: "PREVIEW_URLS", previewUrls: [{ name: "Web", template: "https://example.com/{slug}" }] },
|
|
210
|
+
* ]
|
|
211
|
+
*/
|
|
212
|
+
sidebar?: SidebarElementInput[];
|
|
107
213
|
/**
|
|
108
214
|
* The apiId this model has in Hygraph right now, when you are renaming it.
|
|
109
215
|
* The rename keeps the model's content instead of deleting the model and
|
|
@@ -124,6 +230,8 @@ type Model = {
|
|
|
124
230
|
displayName: string;
|
|
125
231
|
description: string | null;
|
|
126
232
|
fields: Field[];
|
|
233
|
+
/** `null` when the config leaves the sidebar as it is. */
|
|
234
|
+
sidebar: SidebarElement[] | null;
|
|
127
235
|
renamedFrom: string | null;
|
|
128
236
|
};
|
|
129
237
|
/**
|
|
@@ -459,7 +567,7 @@ declare function component$1(input: ComponentInput): Component;
|
|
|
459
567
|
* The options `componentUnion` takes. Hygraph stores a union as never
|
|
460
568
|
* required, so it takes no `required`.
|
|
461
569
|
*/
|
|
462
|
-
type ComponentUnionFieldInput = Omit<FieldInput, "required"
|
|
570
|
+
type ComponentUnionFieldInput = Omit<FieldInput, "required"> & {
|
|
463
571
|
/**
|
|
464
572
|
* The components editors choose from, as `define.component` returns them,
|
|
465
573
|
* each behind a function: `[() => Hero, () => Banner]`. At least one, and
|
|
@@ -474,12 +582,6 @@ type ComponentUnionFieldInput = Omit<FieldInput, "required" | "visibility"> & {
|
|
|
474
582
|
* @default false
|
|
475
583
|
*/
|
|
476
584
|
list?: boolean;
|
|
477
|
-
/**
|
|
478
|
-
* Cannot change once the field exists: changing it deletes the field and
|
|
479
|
-
* its content.
|
|
480
|
-
* @default "READ_WRITE"
|
|
481
|
-
*/
|
|
482
|
-
visibility?: FieldVisibility;
|
|
483
585
|
};
|
|
484
586
|
/**
|
|
485
587
|
* What `define.field.componentUnion` hands back: the input with every
|
package/dist/define2.js
CHANGED
|
@@ -4873,6 +4873,21 @@ function byApiId(a, b) {
|
|
|
4873
4873
|
function byPrefix(a, b) {
|
|
4874
4874
|
return byApiId({ apiId: a.prefix }, { apiId: b.prefix });
|
|
4875
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
|
+
}
|
|
4876
4891
|
//#endregion
|
|
4877
4892
|
//#region src/ir/sdl.ts
|
|
4878
4893
|
/**
|
|
@@ -5395,6 +5410,80 @@ function convertTypeToIR(field, position) {
|
|
|
5395
5410
|
}
|
|
5396
5411
|
}
|
|
5397
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
|
|
5398
5487
|
//#region src/define/system/model.ts
|
|
5399
5488
|
/**
|
|
5400
5489
|
* A model Hygraph provides, as `system.model.asset` or `system.model.query` hands it
|
|
@@ -5524,13 +5613,15 @@ function model$1(input) {
|
|
|
5524
5613
|
displayName: input.displayName,
|
|
5525
5614
|
description: isEmpty(input.description) ? null : input.description,
|
|
5526
5615
|
fields: [...input.fields],
|
|
5616
|
+
sidebar: input.sidebar?.map(sidebarElement) ?? null,
|
|
5527
5617
|
renamedFrom: isEmpty(input.renamedFrom) ? null : input.renamedFrom
|
|
5528
5618
|
};
|
|
5529
5619
|
}
|
|
5530
5620
|
/**
|
|
5531
5621
|
* Everything the canonical form adds to a model happens here. `renamedFrom`
|
|
5532
5622
|
* is intent, not schema, and stays out. Fields are keyed by apiId, and a
|
|
5533
|
-
* 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.
|
|
5534
5625
|
*/
|
|
5535
5626
|
function convertModelToIR(model) {
|
|
5536
5627
|
return {
|
|
@@ -5538,7 +5629,8 @@ function convertModelToIR(model) {
|
|
|
5538
5629
|
apiIdPlural: model.apiIdPlural,
|
|
5539
5630
|
displayName: model.displayName,
|
|
5540
5631
|
description: model.description,
|
|
5541
|
-
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)
|
|
5542
5634
|
};
|
|
5543
5635
|
}
|
|
5544
5636
|
//#endregion
|
|
@@ -6103,4 +6195,4 @@ const model = {
|
|
|
6103
6195
|
segment
|
|
6104
6196
|
};
|
|
6105
6197
|
//#endregion
|
|
6106
|
-
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