@hygraph/cli 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -5
- package/dist/cli.js +3394 -250
- package/dist/define.d.ts +712 -155
- package/dist/define2.js +4461 -48
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/define.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
//#region src/management/graphql.d.ts
|
|
2
2
|
type ColorPalette = "BLUE" | "BROWN" | "GREEN" | "INDIGO" | "NEUTRAL" | "OLIVE" | "ORANGE" | "PINK" | "PURPLE" | "RED" | "ROSE" | "TEAL" | "YELLOW";
|
|
3
|
+
type GraphQlRemoteSourceIntrospectionMethod = "GET" | "POST";
|
|
3
4
|
type RelationalFieldType = "ASSET" | "RELATION";
|
|
5
|
+
type RemoteFieldApiMethod = "GET" | "POST";
|
|
6
|
+
type RemoteSourceKind = "CommerceLayer" | "CommerceTools" | "Custom";
|
|
4
7
|
/** Field types */
|
|
5
8
|
type SimpleFieldType = "BOOLEAN" | "COLOR" | "DATE" | "DATETIME" | "FLOAT" | "ID" | "INT" | "JSON" | "LOCATION" | "RICHTEXT" | "STRING" | "VECTOR";
|
|
6
9
|
//#endregion
|
|
@@ -86,77 +89,9 @@ type IRRichTextValue = {
|
|
|
86
89
|
/** The flags Studio offers on a pattern: case insensitive, multiline, single line. */
|
|
87
90
|
type IRRegexFlag = "i" | "m" | "s";
|
|
88
91
|
//#endregion
|
|
89
|
-
//#region src/define/fields/boolean.d.ts
|
|
90
|
-
type BooleanFieldInput = FieldInput & ValueFieldInput<boolean> & UniqueFieldInput & LocalizedFieldInput;
|
|
91
|
-
/** What `define.field.boolean` hands back: the input with every default filled in. */
|
|
92
|
-
type BooleanField = {
|
|
93
|
-
__typename: "BooleanField";
|
|
94
|
-
apiId: string;
|
|
95
|
-
displayName: string;
|
|
96
|
-
description: string | null;
|
|
97
|
-
list: boolean;
|
|
98
|
-
required: boolean;
|
|
99
|
-
unique: boolean;
|
|
100
|
-
localized: boolean;
|
|
101
|
-
title: boolean;
|
|
102
|
-
visibility: FieldVisibility;
|
|
103
|
-
visibilityCondition: FieldVisibilityCondition | null;
|
|
104
|
-
/** A list of values on a list field, one value otherwise. */
|
|
105
|
-
initialValue: boolean | boolean[] | null;
|
|
106
|
-
/** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
|
|
107
|
-
migrationValue: boolean | boolean[] | null;
|
|
108
|
-
renamedFrom: string | null;
|
|
109
|
-
};
|
|
110
|
-
/**
|
|
111
|
-
* True or false.
|
|
112
|
-
*
|
|
113
|
-
* Nothing here is validated. The apiId format, uniqueness within the model
|
|
114
|
-
* or component and options that exclude each other are plan-time checks,
|
|
115
|
-
* reported together with its own.
|
|
116
|
-
*/
|
|
117
|
-
declare function boolean(input: BooleanFieldInput): BooleanField;
|
|
118
|
-
//#endregion
|
|
119
|
-
//#region src/define/fields/color.d.ts
|
|
120
|
-
/**
|
|
121
|
-
* A colour: `r`, `g` and `b` whole numbers from 0 to 255, `a` from 0 to 1.
|
|
122
|
-
*
|
|
123
|
-
* @example { rgba: { r: 255, g: 99, b: 71, a: 1 } }
|
|
124
|
-
*/
|
|
125
|
-
type ColorValue = IRColor;
|
|
126
|
-
/**
|
|
127
|
-
* The options `color` takes. Studio has no title on a color field, so it
|
|
128
|
-
* takes no `title`.
|
|
129
|
-
*/
|
|
130
|
-
type ColorFieldInput = FieldInput & ValueFieldInput<ColorValue> & UniqueFieldInput & LocalizedFieldInput & {
|
|
131
|
-
title?: never;
|
|
132
|
-
};
|
|
133
|
-
/** What `define.field.color` hands back: the input with every default filled in. */
|
|
134
|
-
type ColorField = {
|
|
135
|
-
__typename: "ColorField";
|
|
136
|
-
apiId: string;
|
|
137
|
-
displayName: string;
|
|
138
|
-
description: string | null;
|
|
139
|
-
list: boolean;
|
|
140
|
-
required: boolean;
|
|
141
|
-
unique: boolean;
|
|
142
|
-
localized: boolean;
|
|
143
|
-
/** Always `false`: Studio has no title on a color field. */
|
|
144
|
-
title: false;
|
|
145
|
-
visibility: FieldVisibility;
|
|
146
|
-
visibilityCondition: FieldVisibilityCondition | null;
|
|
147
|
-
/** A list of values on a list field, one value otherwise. */
|
|
148
|
-
initialValue: ColorValue | ColorValue[] | null;
|
|
149
|
-
/** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
|
|
150
|
-
migrationValue: ColorValue | ColorValue[] | null;
|
|
151
|
-
renamedFrom: string | null;
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* A colour, such as a brand colour. Nothing here is validated; the checks
|
|
155
|
-
* run at plan time with the model's or component's own.
|
|
156
|
-
*/
|
|
157
|
-
declare function color(input: ColorFieldInput): ColorField;
|
|
158
|
-
//#endregion
|
|
159
92
|
//#region src/define/resources/model.d.ts
|
|
93
|
+
/** A field a model takes: every type but a field back, which is on Asset. */
|
|
94
|
+
type ModelField = Exclude<Field, AssetReverseField>;
|
|
160
95
|
type ModelInput = {
|
|
161
96
|
apiId: string;
|
|
162
97
|
apiIdPlural: string;
|
|
@@ -166,7 +101,7 @@ type ModelInput = {
|
|
|
166
101
|
* The model's fields, built with `define.field.*`. The order here is the
|
|
167
102
|
* order editors see them in. May be empty.
|
|
168
103
|
*/
|
|
169
|
-
fields:
|
|
104
|
+
fields: ModelField[];
|
|
170
105
|
/**
|
|
171
106
|
* The apiId this model has in Hygraph right now, when you are renaming it.
|
|
172
107
|
* The rename keeps the model's content instead of deleting the model and
|
|
@@ -352,6 +287,60 @@ type ReferenceTwoWayField = {
|
|
|
352
287
|
*/
|
|
353
288
|
declare function referenceTwoWay(input: ReferenceTwoWayFieldInput): ReferenceTwoWayField;
|
|
354
289
|
//#endregion
|
|
290
|
+
//#region src/define/fields/referenceUnionMember.d.ts
|
|
291
|
+
/** The options `referenceUnionMember` takes. A reference cannot be required. */
|
|
292
|
+
type ReferenceUnionMemberFieldInput = Omit<FieldInput, "required"> & {
|
|
293
|
+
/**
|
|
294
|
+
* The model the union reference is on, as `define.model` returns it,
|
|
295
|
+
* behind a function: `() => Page`. List the model in the environment's
|
|
296
|
+
* `models` too. Cannot change once the field exists.
|
|
297
|
+
*/
|
|
298
|
+
to: () => Model;
|
|
299
|
+
/**
|
|
300
|
+
* The apiId of the union reference on `to`, a
|
|
301
|
+
* `define.field.referenceUnion` that lists this model and has this
|
|
302
|
+
* field's apiId as its `reverse`. Cannot change once the field exists.
|
|
303
|
+
*/
|
|
304
|
+
reverse: string;
|
|
305
|
+
/**
|
|
306
|
+
* Whether the field connects to a list of entries. Every model of the
|
|
307
|
+
* union has the same. Cannot change once the field exists: changing it
|
|
308
|
+
* deletes the union reference, every field back and their connections.
|
|
309
|
+
* @default false
|
|
310
|
+
*/
|
|
311
|
+
list?: boolean;
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* What `define.field.referenceUnionMember` hands back: the input with every
|
|
315
|
+
* default filled in.
|
|
316
|
+
*/
|
|
317
|
+
type ReferenceUnionMemberField = {
|
|
318
|
+
__typename: "ReferenceUnionMemberField";
|
|
319
|
+
apiId: string;
|
|
320
|
+
displayName: string;
|
|
321
|
+
description: string | null;
|
|
322
|
+
to: () => Model;
|
|
323
|
+
reverse: string;
|
|
324
|
+
list: boolean;
|
|
325
|
+
/** Always `false`: a reference cannot be required. */
|
|
326
|
+
required: false;
|
|
327
|
+
visibility: FieldVisibility;
|
|
328
|
+
visibilityCondition: FieldVisibilityCondition | null;
|
|
329
|
+
renamedFrom: string | null;
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* The entries whose union reference connects to this one: the field back
|
|
333
|
+
* of a `define.field.referenceUnion`, on each model it lists. Every one
|
|
334
|
+
* has the same apiId, the union's `reverse`; each has its own name,
|
|
335
|
+
* visibility and condition. To rename them, set `renamedFrom` on one that
|
|
336
|
+
* already exists: the others follow. Models only: a component cannot have
|
|
337
|
+
* one.
|
|
338
|
+
*
|
|
339
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
340
|
+
* plan: the checks run at plan time with the model's own.
|
|
341
|
+
*/
|
|
342
|
+
declare function referenceUnionMember(input: ReferenceUnionMemberFieldInput): ReferenceUnionMemberField;
|
|
343
|
+
//#endregion
|
|
355
344
|
//#region src/define/resources/component.d.ts
|
|
356
345
|
type ComponentInput = {
|
|
357
346
|
/**
|
|
@@ -374,9 +363,9 @@ type ComponentInput = {
|
|
|
374
363
|
/**
|
|
375
364
|
* The component's fields, built with `define.field.*`. The order here is
|
|
376
365
|
* the order editors see them in. May be empty. Every field type but
|
|
377
|
-
* `referenceTwoWay`, which only models have.
|
|
366
|
+
* `referenceTwoWay` and `referenceUnionMember`, which only models have.
|
|
378
367
|
*/
|
|
379
|
-
fields: Exclude<Field, ReferenceTwoWayField>[];
|
|
368
|
+
fields: Exclude<Field, ReferenceTwoWayField | ReferenceUnionMemberField | AssetReverseField>[];
|
|
380
369
|
/**
|
|
381
370
|
* The apiId this component has in Hygraph right now, when you are
|
|
382
371
|
* renaming it. The rename keeps the component's fields and content
|
|
@@ -407,56 +396,6 @@ type Component = {
|
|
|
407
396
|
*/
|
|
408
397
|
declare function component$1(input: ComponentInput): Component;
|
|
409
398
|
//#endregion
|
|
410
|
-
//#region src/define/fields/component.d.ts
|
|
411
|
-
/** The options `component` takes. */
|
|
412
|
-
type ComponentFieldInput = Omit<FieldInput, "required"> & {
|
|
413
|
-
/**
|
|
414
|
-
* The component, as `define.component` returns it, behind a function:
|
|
415
|
-
* `() => Seo`. The function lets a component hold itself, and two files
|
|
416
|
-
* use each other in any order. List the component in the environment's
|
|
417
|
-
* `components` too. Cannot change once the field exists: changing it
|
|
418
|
-
* deletes the field and its content.
|
|
419
|
-
*/
|
|
420
|
-
component: () => Component;
|
|
421
|
-
/**
|
|
422
|
-
* Whether the field holds a list of components. Cannot change once the
|
|
423
|
-
* field exists: changing it deletes the field and its content.
|
|
424
|
-
* @default false
|
|
425
|
-
*/
|
|
426
|
-
list?: boolean;
|
|
427
|
-
/**
|
|
428
|
-
* Whether an entry needs the component filled in to be saved. On a model
|
|
429
|
-
* or component that already has entries, add the field without it, fill
|
|
430
|
-
* the field in every entry, then make it required: Hygraph refuses a
|
|
431
|
-
* required component field that existing entries would leave empty.
|
|
432
|
-
* @default false
|
|
433
|
-
*/
|
|
434
|
-
required?: boolean;
|
|
435
|
-
};
|
|
436
|
-
/**
|
|
437
|
-
* What `define.field.component` hands back: the input with every default
|
|
438
|
-
* filled in.
|
|
439
|
-
*/
|
|
440
|
-
type ComponentField = {
|
|
441
|
-
__typename: "ComponentField";
|
|
442
|
-
apiId: string;
|
|
443
|
-
displayName: string;
|
|
444
|
-
description: string | null;
|
|
445
|
-
component: () => Component;
|
|
446
|
-
list: boolean;
|
|
447
|
-
required: boolean;
|
|
448
|
-
visibility: FieldVisibility;
|
|
449
|
-
visibilityCondition: FieldVisibilityCondition | null;
|
|
450
|
-
renamedFrom: string | null;
|
|
451
|
-
};
|
|
452
|
-
/**
|
|
453
|
-
* One component, or a list of them, that editors fill in inside the entry.
|
|
454
|
-
*
|
|
455
|
-
* Nothing here is validated, and the component is not looked at until the
|
|
456
|
-
* plan: the checks run at plan time with the model's or component's own.
|
|
457
|
-
*/
|
|
458
|
-
declare function component(input: ComponentFieldInput): ComponentField;
|
|
459
|
-
//#endregion
|
|
460
399
|
//#region src/define/fields/componentUnion.d.ts
|
|
461
400
|
/**
|
|
462
401
|
* The options `componentUnion` takes. Hygraph stores a union as never
|
|
@@ -511,6 +450,223 @@ type ComponentUnionField = {
|
|
|
511
450
|
*/
|
|
512
451
|
declare function componentUnion(input: ComponentUnionFieldInput): ComponentUnionField;
|
|
513
452
|
//#endregion
|
|
453
|
+
//#region src/define/system/asset.d.ts
|
|
454
|
+
/**
|
|
455
|
+
* A field Hygraph takes on Asset: every type but a component union and a
|
|
456
|
+
* union member, as a union lists only your models. A two-way reference on
|
|
457
|
+
* Asset is a field back, an `assetReverseField`.
|
|
458
|
+
*/
|
|
459
|
+
type AssetModelField = Exclude<Field, ComponentUnionField | ReferenceTwoWayField | ReferenceUnionMemberField>;
|
|
460
|
+
type SystemAssetInput = {
|
|
461
|
+
/**
|
|
462
|
+
* Your fields on Asset, built with `define.field.*`. They come after
|
|
463
|
+
* Hygraph's own, which are never listed here. None can be `required`:
|
|
464
|
+
* Hygraph refuses a required field on a system model. The field back an
|
|
465
|
+
* asset field on a model names in `reverse` goes here too:
|
|
466
|
+
* `define.field.assetReverseField({ apiId: "imagePost", to: () => Post,
|
|
467
|
+
* reverse: "image" })`. The order here is the order editors see them in.
|
|
468
|
+
* @default []
|
|
469
|
+
*/
|
|
470
|
+
fields?: AssetModelField[];
|
|
471
|
+
};
|
|
472
|
+
/**
|
|
473
|
+
* What `system.asset` hands back: Asset with your fields. Put it in
|
|
474
|
+
* `define.environment`'s `models`.
|
|
475
|
+
*/
|
|
476
|
+
type SystemAsset = {
|
|
477
|
+
__typename: "SystemAsset";
|
|
478
|
+
apiId: "Asset";
|
|
479
|
+
fields: Field[];
|
|
480
|
+
};
|
|
481
|
+
/**
|
|
482
|
+
* Hygraph's Asset model, with your fields on it. Put it in
|
|
483
|
+
* `define.environment`'s `models` to manage those fields; leave it out and
|
|
484
|
+
* the plan does not touch Asset at all. The plan never creates or deletes
|
|
485
|
+
* Asset or one of Hygraph's own fields on it.
|
|
486
|
+
*
|
|
487
|
+
* Nothing here is validated: the checks run at plan time with the models'.
|
|
488
|
+
*/
|
|
489
|
+
declare function asset$1(input?: SystemAssetInput): SystemAsset;
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/define/fields/assetReverseField.d.ts
|
|
492
|
+
/**
|
|
493
|
+
* The options `assetReverseField` takes. A field back is always a list,
|
|
494
|
+
* and Hygraph takes no rules and no `required` on it. There is no
|
|
495
|
+
* condition: the reader cannot see one on Asset.
|
|
496
|
+
*/
|
|
497
|
+
type AssetReverseFieldInput = Omit<FieldInput, "required" | "visibility" | "visibilityCondition"> & {
|
|
498
|
+
/**
|
|
499
|
+
* Studio makes every field back `API_ONLY`, and an editor can show it
|
|
500
|
+
* on Asset's form there.
|
|
501
|
+
* @default "API_ONLY"
|
|
502
|
+
*/
|
|
503
|
+
visibility?: FieldVisibility;
|
|
504
|
+
/**
|
|
505
|
+
* The model the asset field is on, as `define.model` returns it, behind a
|
|
506
|
+
* function: `() => Post`, or Asset itself for an asset field on Asset:
|
|
507
|
+
* `() => Asset`. List the model in the environment's `models` too.
|
|
508
|
+
* Cannot change once the field exists: changing it deletes both fields.
|
|
509
|
+
*/
|
|
510
|
+
to: () => Model | SystemAsset;
|
|
511
|
+
/**
|
|
512
|
+
* The apiId of the asset field on `to` whose field back this is. That
|
|
513
|
+
* asset field names this one in its own `reverse`. When the asset field
|
|
514
|
+
* is renamed with `renamedFrom`, set this to its new apiId. Changing it
|
|
515
|
+
* to another field deletes both fields.
|
|
516
|
+
*/
|
|
517
|
+
reverse: string;
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* What `define.field.assetReverseField` hands back: the input with every
|
|
521
|
+
* default filled in.
|
|
522
|
+
*/
|
|
523
|
+
type AssetReverseField = {
|
|
524
|
+
__typename: "AssetReverseField";
|
|
525
|
+
apiId: string;
|
|
526
|
+
displayName: string;
|
|
527
|
+
description: string | null;
|
|
528
|
+
to: () => Model | SystemAsset;
|
|
529
|
+
reverse: string;
|
|
530
|
+
/** Always `true`: Hygraph keeps every field back as a list. */
|
|
531
|
+
list: true;
|
|
532
|
+
/** Always `false`: a field back cannot be required. */
|
|
533
|
+
required: false;
|
|
534
|
+
visibility: FieldVisibility;
|
|
535
|
+
/** Always `null`: the reader cannot see a condition on Asset. */
|
|
536
|
+
visibilityCondition: null;
|
|
537
|
+
renamedFrom: string | null;
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* The field back on Asset of an asset field on a model: the entries that
|
|
541
|
+
* use the asset there. Goes in `system.asset`'s fields, and the asset
|
|
542
|
+
* field names it in `reverse`. It has its own name, description and
|
|
543
|
+
* visibility, and renames on its own. Asset only.
|
|
544
|
+
*
|
|
545
|
+
* Nothing here is validated, and the model is not looked at until the
|
|
546
|
+
* plan: the checks run at plan time with the model's own.
|
|
547
|
+
*/
|
|
548
|
+
declare function assetReverseField(input: AssetReverseFieldInput): AssetReverseField;
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/define/fields/boolean.d.ts
|
|
551
|
+
type BooleanFieldInput = FieldInput & ValueFieldInput<boolean> & UniqueFieldInput & LocalizedFieldInput;
|
|
552
|
+
/** What `define.field.boolean` hands back: the input with every default filled in. */
|
|
553
|
+
type BooleanField = {
|
|
554
|
+
__typename: "BooleanField";
|
|
555
|
+
apiId: string;
|
|
556
|
+
displayName: string;
|
|
557
|
+
description: string | null;
|
|
558
|
+
list: boolean;
|
|
559
|
+
required: boolean;
|
|
560
|
+
unique: boolean;
|
|
561
|
+
localized: boolean;
|
|
562
|
+
title: boolean;
|
|
563
|
+
visibility: FieldVisibility;
|
|
564
|
+
visibilityCondition: FieldVisibilityCondition | null;
|
|
565
|
+
/** A list of values on a list field, one value otherwise. */
|
|
566
|
+
initialValue: boolean | boolean[] | null;
|
|
567
|
+
/** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
|
|
568
|
+
migrationValue: boolean | boolean[] | null;
|
|
569
|
+
renamedFrom: string | null;
|
|
570
|
+
};
|
|
571
|
+
/**
|
|
572
|
+
* True or false.
|
|
573
|
+
*
|
|
574
|
+
* Nothing here is validated. The apiId format, uniqueness within the model
|
|
575
|
+
* or component and options that exclude each other are plan-time checks,
|
|
576
|
+
* reported together with its own.
|
|
577
|
+
*/
|
|
578
|
+
declare function boolean(input: BooleanFieldInput): BooleanField;
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/define/fields/color.d.ts
|
|
581
|
+
/**
|
|
582
|
+
* A colour: `r`, `g` and `b` whole numbers from 0 to 255, `a` from 0 to 1.
|
|
583
|
+
*
|
|
584
|
+
* @example { rgba: { r: 255, g: 99, b: 71, a: 1 } }
|
|
585
|
+
*/
|
|
586
|
+
type ColorValue = IRColor;
|
|
587
|
+
/**
|
|
588
|
+
* The options `color` takes. Studio has no title on a color field, so it
|
|
589
|
+
* takes no `title`.
|
|
590
|
+
*/
|
|
591
|
+
type ColorFieldInput = FieldInput & ValueFieldInput<ColorValue> & UniqueFieldInput & LocalizedFieldInput & {
|
|
592
|
+
title?: never;
|
|
593
|
+
};
|
|
594
|
+
/** What `define.field.color` hands back: the input with every default filled in. */
|
|
595
|
+
type ColorField = {
|
|
596
|
+
__typename: "ColorField";
|
|
597
|
+
apiId: string;
|
|
598
|
+
displayName: string;
|
|
599
|
+
description: string | null;
|
|
600
|
+
list: boolean;
|
|
601
|
+
required: boolean;
|
|
602
|
+
unique: boolean;
|
|
603
|
+
localized: boolean;
|
|
604
|
+
/** Always `false`: Studio has no title on a color field. */
|
|
605
|
+
title: false;
|
|
606
|
+
visibility: FieldVisibility;
|
|
607
|
+
visibilityCondition: FieldVisibilityCondition | null;
|
|
608
|
+
/** A list of values on a list field, one value otherwise. */
|
|
609
|
+
initialValue: ColorValue | ColorValue[] | null;
|
|
610
|
+
/** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
|
|
611
|
+
migrationValue: ColorValue | ColorValue[] | null;
|
|
612
|
+
renamedFrom: string | null;
|
|
613
|
+
};
|
|
614
|
+
/**
|
|
615
|
+
* A colour, such as a brand colour. Nothing here is validated; the checks
|
|
616
|
+
* run at plan time with the model's or component's own.
|
|
617
|
+
*/
|
|
618
|
+
declare function color(input: ColorFieldInput): ColorField;
|
|
619
|
+
//#endregion
|
|
620
|
+
//#region src/define/fields/component.d.ts
|
|
621
|
+
/** The options `component` takes. */
|
|
622
|
+
type ComponentFieldInput = Omit<FieldInput, "required"> & {
|
|
623
|
+
/**
|
|
624
|
+
* The component, as `define.component` returns it, behind a function:
|
|
625
|
+
* `() => Seo`. The function lets a component hold itself, and two files
|
|
626
|
+
* use each other in any order. List the component in the environment's
|
|
627
|
+
* `components` too. Cannot change once the field exists: changing it
|
|
628
|
+
* deletes the field and its content.
|
|
629
|
+
*/
|
|
630
|
+
component: () => Component;
|
|
631
|
+
/**
|
|
632
|
+
* Whether the field holds a list of components. Cannot change once the
|
|
633
|
+
* field exists: changing it deletes the field and its content.
|
|
634
|
+
* @default false
|
|
635
|
+
*/
|
|
636
|
+
list?: boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Whether an entry needs the component filled in to be saved. On a model
|
|
639
|
+
* or component that already has entries, add the field without it, fill
|
|
640
|
+
* the field in every entry, then make it required: Hygraph refuses a
|
|
641
|
+
* required component field that existing entries would leave empty.
|
|
642
|
+
* @default false
|
|
643
|
+
*/
|
|
644
|
+
required?: boolean;
|
|
645
|
+
};
|
|
646
|
+
/**
|
|
647
|
+
* What `define.field.component` hands back: the input with every default
|
|
648
|
+
* filled in.
|
|
649
|
+
*/
|
|
650
|
+
type ComponentField = {
|
|
651
|
+
__typename: "ComponentField";
|
|
652
|
+
apiId: string;
|
|
653
|
+
displayName: string;
|
|
654
|
+
description: string | null;
|
|
655
|
+
component: () => Component;
|
|
656
|
+
list: boolean;
|
|
657
|
+
required: boolean;
|
|
658
|
+
visibility: FieldVisibility;
|
|
659
|
+
visibilityCondition: FieldVisibilityCondition | null;
|
|
660
|
+
renamedFrom: string | null;
|
|
661
|
+
};
|
|
662
|
+
/**
|
|
663
|
+
* One component, or a list of them, that editors fill in inside the entry.
|
|
664
|
+
*
|
|
665
|
+
* Nothing here is validated, and the component is not looked at until the
|
|
666
|
+
* plan: the checks run at plan time with the model's or component's own.
|
|
667
|
+
*/
|
|
668
|
+
declare function component(input: ComponentFieldInput): ComponentField;
|
|
669
|
+
//#endregion
|
|
514
670
|
//#region src/define/fields/date.d.ts
|
|
515
671
|
/**
|
|
516
672
|
* The options `date` and `dateTime` take. Values are ISO strings: a day,
|
|
@@ -814,6 +970,378 @@ type NumberValidationRules = {
|
|
|
814
970
|
listItemCount: RangeRule | null;
|
|
815
971
|
};
|
|
816
972
|
//#endregion
|
|
973
|
+
//#region src/define/fields/referenceUnion.d.ts
|
|
974
|
+
/**
|
|
975
|
+
* The options `referenceUnion` takes. A reference cannot be required. To
|
|
976
|
+
* make editors connect an entry, set `rules: { connections: { min: 1 } }`.
|
|
977
|
+
*/
|
|
978
|
+
type ReferenceUnionFieldInput = Omit<FieldInput, "required"> & {
|
|
979
|
+
/**
|
|
980
|
+
* The models whose entries the field connects to, as `define.model`
|
|
981
|
+
* returns them, each behind a function: `[() => Video, () => Image]`.
|
|
982
|
+
* The functions let a model be one of its own, and two files use each
|
|
983
|
+
* other in any order. List each model once, and in the environment's
|
|
984
|
+
* `models` too. Adding a model gives it its field back; removing one
|
|
985
|
+
* deletes that field and its connections. Replacing every model deletes
|
|
986
|
+
* the field, every field back and their connections, and creates them
|
|
987
|
+
* again.
|
|
988
|
+
*/
|
|
989
|
+
to: (() => Model)[];
|
|
990
|
+
/**
|
|
991
|
+
* The apiId of the field each model in `to` has back to this one, its
|
|
992
|
+
* `define.field.referenceUnionMember`. Every one of them has this apiId. Set
|
|
993
|
+
* it on a model, and leave it out on a component: a component's union has no
|
|
994
|
+
* field back that you see. To rename the fields back, set `renamedFrom` on
|
|
995
|
+
* one of them that already exists, and set this to the new apiId. Any other
|
|
996
|
+
* change deletes the field, every field back and their connections, and
|
|
997
|
+
* creates them again.
|
|
998
|
+
* @default null
|
|
999
|
+
*/
|
|
1000
|
+
reverse?: string;
|
|
1001
|
+
/**
|
|
1002
|
+
* Whether the field connects to a list of entries. Cannot change once
|
|
1003
|
+
* the field exists: changing it deletes the field, every field back and
|
|
1004
|
+
* their connections.
|
|
1005
|
+
* @default false
|
|
1006
|
+
*/
|
|
1007
|
+
list?: boolean;
|
|
1008
|
+
/**
|
|
1009
|
+
* What Studio asks of editors before they save an entry. The API does
|
|
1010
|
+
* not check it. To require a connected entry, set
|
|
1011
|
+
* `{ connections: { min: 1 } }`. That is the only rule a single
|
|
1012
|
+
* reference takes; a list takes any `min` and `max`.
|
|
1013
|
+
* @default null
|
|
1014
|
+
*/
|
|
1015
|
+
rules?: ReferenceRulesInput;
|
|
1016
|
+
};
|
|
1017
|
+
/**
|
|
1018
|
+
* What `define.field.referenceUnion` hands back: the input with every
|
|
1019
|
+
* default filled in.
|
|
1020
|
+
*/
|
|
1021
|
+
type ReferenceUnionField = {
|
|
1022
|
+
__typename: "ReferenceUnionField";
|
|
1023
|
+
apiId: string;
|
|
1024
|
+
displayName: string;
|
|
1025
|
+
description: string | null;
|
|
1026
|
+
to: (() => Model)[];
|
|
1027
|
+
reverse: string | null;
|
|
1028
|
+
list: boolean;
|
|
1029
|
+
/** Always `false`: a reference cannot be required. */
|
|
1030
|
+
required: false;
|
|
1031
|
+
rules: ReferenceRules | null;
|
|
1032
|
+
visibility: FieldVisibility;
|
|
1033
|
+
visibilityCondition: FieldVisibilityCondition | null;
|
|
1034
|
+
renamedFrom: string | null;
|
|
1035
|
+
};
|
|
1036
|
+
/**
|
|
1037
|
+
* Entries of several models, which editors choose from, such as a video or an
|
|
1038
|
+
* image. On a model, each of those models shows the connection back in a field
|
|
1039
|
+
* of its own: declare it there with `define.field.referenceUnionMember`, and
|
|
1040
|
+
* name it here in `reverse`. On a component, leave `reverse` out.
|
|
1041
|
+
*
|
|
1042
|
+
* Nothing here is validated, and the models are not looked at until the
|
|
1043
|
+
* plan: the checks run at plan time with the model's own.
|
|
1044
|
+
*/
|
|
1045
|
+
declare function referenceUnion(input: ReferenceUnionFieldInput): ReferenceUnionField;
|
|
1046
|
+
//#endregion
|
|
1047
|
+
//#region src/define/resources/restRemoteSource.d.ts
|
|
1048
|
+
type RESTRemoteSourceInput = RemoteSourceInput & {
|
|
1049
|
+
/**
|
|
1050
|
+
* Every type the source's remote fields return or take as arguments, in
|
|
1051
|
+
* SDL, such as `"type Forecast { temp: Float city: String }"`. A REST API
|
|
1052
|
+
* has no schema to introspect, so these are all Hygraph knows of it.
|
|
1053
|
+
* @default null
|
|
1054
|
+
*/
|
|
1055
|
+
remoteTypeDefinitions?: string;
|
|
1056
|
+
};
|
|
1057
|
+
/** What `define.restRemoteSource` hands back, every default filled in. */
|
|
1058
|
+
type RESTRemoteSource = RemoteSourceAttributes & {
|
|
1059
|
+
__typename: "RESTRemoteSource";
|
|
1060
|
+
};
|
|
1061
|
+
/**
|
|
1062
|
+
* A REST API remote fields can call. List it in the environment's
|
|
1063
|
+
* `remoteSources`.
|
|
1064
|
+
*
|
|
1065
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
1066
|
+
* checks, reported together with the rest of the config's.
|
|
1067
|
+
*/
|
|
1068
|
+
declare function restRemoteSource(input: RESTRemoteSourceInput): RESTRemoteSource;
|
|
1069
|
+
//#endregion
|
|
1070
|
+
//#region src/define/resources/remoteSource.d.ts
|
|
1071
|
+
/**
|
|
1072
|
+
* HTTP headers by name. A header with more than one value takes a list.
|
|
1073
|
+
* Read secrets from the environment, such as
|
|
1074
|
+
* `{ Authorization: process.env.SHOP_AUTHORIZATION }`, so they stay out of
|
|
1075
|
+
* the repository. A header without a value, such as a variable that is not
|
|
1076
|
+
* set, stops the plan, so it never reaches Hygraph empty.
|
|
1077
|
+
*/
|
|
1078
|
+
type RemoteHeadersInput = Record<string, string | (string | undefined)[] | undefined>;
|
|
1079
|
+
/**
|
|
1080
|
+
* How Hygraph signs in to a commerce source, with the `client_credentials`
|
|
1081
|
+
* grant: it trades the client's id and secret for a token at
|
|
1082
|
+
* `authorizationUrl` and sends the token with every request.
|
|
1083
|
+
*/
|
|
1084
|
+
type RemoteSourceOAuthInput = {
|
|
1085
|
+
/** The API client's id. */
|
|
1086
|
+
clientId: string;
|
|
1087
|
+
/**
|
|
1088
|
+
* The API client's secret. Read it from the environment, such as
|
|
1089
|
+
* `process.env.SHOP_OAUTH_CLIENT_SECRET`. Hygraph keeps it and never returns
|
|
1090
|
+
* it, so apply sends it only when a plan needs it: when it creates the
|
|
1091
|
+
* source or adds OAuth to it, and when `clientId` changes. After you
|
|
1092
|
+
* change the secret, plan with `--rotate-secret <prefix>` to send it.
|
|
1093
|
+
*/
|
|
1094
|
+
clientSecret?: string | undefined;
|
|
1095
|
+
/** What the token may do, such as `manage_project:shop`. @default [] */
|
|
1096
|
+
scopes?: string[];
|
|
1097
|
+
/**
|
|
1098
|
+
* Where Hygraph gets the token, such as
|
|
1099
|
+
* `https://auth.europe-west1.gcp.commercetools.com/oauth/token`.
|
|
1100
|
+
*/
|
|
1101
|
+
authorizationUrl: string;
|
|
1102
|
+
};
|
|
1103
|
+
/**
|
|
1104
|
+
* What `kind` lets `oAuth` hold: a Custom source signs in with headers
|
|
1105
|
+
* only, a CommerceTools one needs the client's secret, and a CommerceLayer
|
|
1106
|
+
* sales channel signs in with a client id alone. A source made in Studio
|
|
1107
|
+
* keeps its kind: changing it is refused.
|
|
1108
|
+
*/
|
|
1109
|
+
type RemoteSourceKindInput = {
|
|
1110
|
+
/**
|
|
1111
|
+
* Which commerce platform the source is, for the ones Hygraph knows.
|
|
1112
|
+
* @default "Custom"
|
|
1113
|
+
*/
|
|
1114
|
+
kind?: "Custom";
|
|
1115
|
+
/** Hygraph signs in with OAuth to CommerceTools and CommerceLayer only. */
|
|
1116
|
+
oAuth?: never;
|
|
1117
|
+
} | {
|
|
1118
|
+
kind: "CommerceTools";
|
|
1119
|
+
/** @default null */
|
|
1120
|
+
oAuth?: RemoteSourceOAuthInput & {
|
|
1121
|
+
clientSecret: string | undefined;
|
|
1122
|
+
};
|
|
1123
|
+
} | {
|
|
1124
|
+
kind: "CommerceLayer";
|
|
1125
|
+
/** @default null */
|
|
1126
|
+
oAuth?: RemoteSourceOAuthInput;
|
|
1127
|
+
};
|
|
1128
|
+
/** What both kinds of remote source take, `kind` and `oAuth` besides. */
|
|
1129
|
+
type RemoteSourceBaseInput = {
|
|
1130
|
+
/**
|
|
1131
|
+
* Put in front of every type the source brings into the Content API,
|
|
1132
|
+
* such as `Shop` for `Shop_Product`, and how remote fields name the
|
|
1133
|
+
* source. An uppercase letter, then letters, digits and underscores, up
|
|
1134
|
+
* to 64 characters, not ending in `_`. Hygraph never changes it: a source
|
|
1135
|
+
* with another prefix is another source, created after the old one is
|
|
1136
|
+
* deleted.
|
|
1137
|
+
*/
|
|
1138
|
+
prefix: string;
|
|
1139
|
+
/** The label editors see in Studio. */
|
|
1140
|
+
displayName: string;
|
|
1141
|
+
/** @default null */
|
|
1142
|
+
description?: string;
|
|
1143
|
+
/** Where Hygraph sends the requests of the source's remote fields. */
|
|
1144
|
+
url: string;
|
|
1145
|
+
/**
|
|
1146
|
+
* Sent with every request to the source.
|
|
1147
|
+
* @default {}
|
|
1148
|
+
*/
|
|
1149
|
+
headers?: RemoteHeadersInput;
|
|
1150
|
+
/**
|
|
1151
|
+
* Whether the Content API puts the remote API's errors in its responses.
|
|
1152
|
+
* @default false
|
|
1153
|
+
*/
|
|
1154
|
+
debugEnabled?: boolean;
|
|
1155
|
+
};
|
|
1156
|
+
/** What both kinds of remote source take. */
|
|
1157
|
+
type RemoteSourceInput = RemoteSourceBaseInput & RemoteSourceKindInput;
|
|
1158
|
+
/** What `oAuth` hands back. No secret is `null`. */
|
|
1159
|
+
type RemoteSourceOAuth = {
|
|
1160
|
+
clientId: string;
|
|
1161
|
+
clientSecret: string | null;
|
|
1162
|
+
scopes: string[];
|
|
1163
|
+
authorizationUrl: string;
|
|
1164
|
+
};
|
|
1165
|
+
/** The attributes both builders hand back, every default filled in. */
|
|
1166
|
+
type RemoteSourceAttributes = {
|
|
1167
|
+
prefix: string;
|
|
1168
|
+
displayName: string;
|
|
1169
|
+
description: string | null;
|
|
1170
|
+
url: string;
|
|
1171
|
+
headers: RemoteHeadersInput;
|
|
1172
|
+
debugEnabled: boolean;
|
|
1173
|
+
kind: RemoteSourceKind;
|
|
1174
|
+
oAuth: RemoteSourceOAuth | null;
|
|
1175
|
+
remoteTypeDefinitions: string | null;
|
|
1176
|
+
};
|
|
1177
|
+
type RemoteSource = GraphQLRemoteSource | RESTRemoteSource;
|
|
1178
|
+
//#endregion
|
|
1179
|
+
//#region src/define/resources/graphqlRemoteSource.d.ts
|
|
1180
|
+
type GraphQLRemoteSourceInput = RemoteSourceInput & {
|
|
1181
|
+
/**
|
|
1182
|
+
* How Hygraph asks the remote API for its schema. It does when it creates
|
|
1183
|
+
* the source, and keeps that copy: types the API adds later reach Hygraph
|
|
1184
|
+
* only through the Management API's `refreshGraphQLRemoteSourceSchema`.
|
|
1185
|
+
*/
|
|
1186
|
+
introspectionMethod: GraphQlRemoteSourceIntrospectionMethod;
|
|
1187
|
+
/**
|
|
1188
|
+
* Where to introspect, when not at `url`. It cannot change once the
|
|
1189
|
+
* source exists: changing it deletes the source and creates it again.
|
|
1190
|
+
* @default null
|
|
1191
|
+
*/
|
|
1192
|
+
introspectionUrl?: string;
|
|
1193
|
+
/**
|
|
1194
|
+
* Sent with the introspection request only, besides `headers`.
|
|
1195
|
+
* @default {}
|
|
1196
|
+
*/
|
|
1197
|
+
introspectionHeaders?: RemoteHeadersInput;
|
|
1198
|
+
/**
|
|
1199
|
+
* Input types remote fields of this source take as arguments, in SDL,
|
|
1200
|
+
* such as `"input ProductLookup { id: ID! locale: String }"`. The remote
|
|
1201
|
+
* API's own types come from introspection and are not written here.
|
|
1202
|
+
* @default null
|
|
1203
|
+
*/
|
|
1204
|
+
remoteTypeDefinitions?: string;
|
|
1205
|
+
};
|
|
1206
|
+
/** What `define.graphqlRemoteSource` hands back, every default filled in. */
|
|
1207
|
+
type GraphQLRemoteSource = RemoteSourceAttributes & {
|
|
1208
|
+
__typename: "GraphQLRemoteSource";
|
|
1209
|
+
introspectionMethod: GraphQlRemoteSourceIntrospectionMethod;
|
|
1210
|
+
introspectionUrl: string | null;
|
|
1211
|
+
introspectionHeaders: RemoteHeadersInput;
|
|
1212
|
+
};
|
|
1213
|
+
/**
|
|
1214
|
+
* A GraphQL API remote fields can query. List it in the environment's
|
|
1215
|
+
* `remoteSources`.
|
|
1216
|
+
*
|
|
1217
|
+
* Nothing here is validated. Format rules and uniqueness are plan-time
|
|
1218
|
+
* checks, reported together with the rest of the config's.
|
|
1219
|
+
*/
|
|
1220
|
+
declare function graphqlRemoteSource(input: GraphQLRemoteSourceInput): GraphQLRemoteSource;
|
|
1221
|
+
//#endregion
|
|
1222
|
+
//#region src/define/fields/remote.d.ts
|
|
1223
|
+
/** One argument the field takes in the Content API. */
|
|
1224
|
+
type RemoteFieldArgInput = {
|
|
1225
|
+
/** How the Content API names the argument, such as `lookup`. */
|
|
1226
|
+
apiId: string;
|
|
1227
|
+
/**
|
|
1228
|
+
* A scalar, such as `String`, or one of the source's input types from its
|
|
1229
|
+
* `remoteTypeDefinitions`, without the prefix.
|
|
1230
|
+
*/
|
|
1231
|
+
type: string;
|
|
1232
|
+
/** @default false */
|
|
1233
|
+
required?: boolean;
|
|
1234
|
+
/** @default false */
|
|
1235
|
+
list?: boolean;
|
|
1236
|
+
};
|
|
1237
|
+
/** The options every remote field takes, whatever its source. */
|
|
1238
|
+
type RemoteFieldBaseInput = Omit<FieldInput, "visibility" | "visibilityCondition" | "renamedFrom"> & {
|
|
1239
|
+
/**
|
|
1240
|
+
* Hygraph cannot rename a remote field: the batch ignores the new apiId
|
|
1241
|
+
* (FND-5075).
|
|
1242
|
+
* Change `apiId` alone instead; the plan deletes the field and creates
|
|
1243
|
+
* it again, which loses nothing, since a remote field holds no content.
|
|
1244
|
+
*/
|
|
1245
|
+
renamedFrom?: never;
|
|
1246
|
+
/**
|
|
1247
|
+
* The name of the type the field returns, without the prefix: one of the
|
|
1248
|
+
* source's types, or a scalar.
|
|
1249
|
+
*/
|
|
1250
|
+
returnType: string;
|
|
1251
|
+
/** How Hygraph calls the source. Hygraph has no default. */
|
|
1252
|
+
method: RemoteFieldApiMethod;
|
|
1253
|
+
/**
|
|
1254
|
+
* The arguments the field takes. `{{args.<apiId>}}` puts one's value in
|
|
1255
|
+
* the query, the path or a header; `{{args.<apiId>.<field>}}` one field
|
|
1256
|
+
* of an input type.
|
|
1257
|
+
* @default []
|
|
1258
|
+
*/
|
|
1259
|
+
args?: RemoteFieldArgInput[];
|
|
1260
|
+
/**
|
|
1261
|
+
* Sent with this field's requests, besides the source's. `{{doc.<apiId>}}`
|
|
1262
|
+
* and `{{args.<apiId>}}` placeholders work here too.
|
|
1263
|
+
* @default {}
|
|
1264
|
+
*/
|
|
1265
|
+
headers?: RemoteHeadersInput;
|
|
1266
|
+
/**
|
|
1267
|
+
* Whether the headers a Content API request comes with are passed on.
|
|
1268
|
+
* @default false
|
|
1269
|
+
*/
|
|
1270
|
+
forwardClientHeaders?: boolean;
|
|
1271
|
+
/**
|
|
1272
|
+
* How long the Content API caches a response: 0 for not at all, or 60
|
|
1273
|
+
* seconds and more.
|
|
1274
|
+
* @default 900
|
|
1275
|
+
*/
|
|
1276
|
+
cacheTTLSeconds?: number;
|
|
1277
|
+
/** Whether the field returns a list. @default false */
|
|
1278
|
+
list?: boolean;
|
|
1279
|
+
/**
|
|
1280
|
+
* Who sees the field. Editors cannot change a remote field's value.
|
|
1281
|
+
* @default "READ_ONLY"
|
|
1282
|
+
*/
|
|
1283
|
+
visibility?: FieldVisibility;
|
|
1284
|
+
/** Hygraph takes no condition on a remote field. */
|
|
1285
|
+
visibilityCondition?: never;
|
|
1286
|
+
};
|
|
1287
|
+
/**
|
|
1288
|
+
* The options `remote` takes. A GraphQL source is sent `query`, a REST one
|
|
1289
|
+
* is called at `path`; placeholders such as `{{doc.city}}` put the entry's
|
|
1290
|
+
* field values in either.
|
|
1291
|
+
*/
|
|
1292
|
+
type RemoteFieldInput = RemoteFieldBaseInput & ({
|
|
1293
|
+
/** The GraphQL source, as `define.graphqlRemoteSource` returns it. */
|
|
1294
|
+
source: GraphQLRemoteSource;
|
|
1295
|
+
/**
|
|
1296
|
+
* The query sent to the source: a named operation that spreads
|
|
1297
|
+
* `...EntryPoint` where `returnType` is, such as
|
|
1298
|
+
* `query product { product(id: "{{args.id}}") { ...EntryPoint } }`.
|
|
1299
|
+
* Hygraph fills the fragment in with what the Content API query
|
|
1300
|
+
* asks for.
|
|
1301
|
+
*/
|
|
1302
|
+
query: string;
|
|
1303
|
+
path?: never;
|
|
1304
|
+
} | {
|
|
1305
|
+
/** The REST source, as `define.restRemoteSource` returns it. */
|
|
1306
|
+
source: RESTRemoteSource;
|
|
1307
|
+
/**
|
|
1308
|
+
* What follows the source's `url`, such as `/forecast/{{doc.city}}`.
|
|
1309
|
+
* @default ""
|
|
1310
|
+
*/
|
|
1311
|
+
path?: string;
|
|
1312
|
+
query?: never;
|
|
1313
|
+
});
|
|
1314
|
+
/** What `define.field.remote` hands back: the input with every default filled in. */
|
|
1315
|
+
type RemoteField = {
|
|
1316
|
+
__typename: "RemoteField";
|
|
1317
|
+
apiId: string;
|
|
1318
|
+
displayName: string;
|
|
1319
|
+
description: string | null;
|
|
1320
|
+
source: RemoteSource;
|
|
1321
|
+
returnType: string;
|
|
1322
|
+
method: RemoteFieldApiMethod;
|
|
1323
|
+
query: string | null;
|
|
1324
|
+
path: string | null;
|
|
1325
|
+
args: Required<RemoteFieldArgInput>[];
|
|
1326
|
+
headers: RemoteHeadersInput;
|
|
1327
|
+
forwardClientHeaders: boolean;
|
|
1328
|
+
cacheTTLSeconds: number;
|
|
1329
|
+
list: boolean;
|
|
1330
|
+
required: boolean;
|
|
1331
|
+
visibility: FieldVisibility;
|
|
1332
|
+
/** Always `null`, so the checks every field shares can read it. */
|
|
1333
|
+
visibilityCondition: null;
|
|
1334
|
+
renamedFrom: string | null;
|
|
1335
|
+
};
|
|
1336
|
+
/**
|
|
1337
|
+
* Data a remote source returns when the field is queried. List the source
|
|
1338
|
+
* in the environment's `remoteSources` too.
|
|
1339
|
+
*
|
|
1340
|
+
* Nothing here is validated; the checks run at plan time with the model's
|
|
1341
|
+
* own, the placeholders included.
|
|
1342
|
+
*/
|
|
1343
|
+
declare function remote(input: RemoteFieldInput): RemoteField;
|
|
1344
|
+
//#endregion
|
|
817
1345
|
//#region src/define/fields/richText.d.ts
|
|
818
1346
|
/**
|
|
819
1347
|
* Rich text as Hygraph stores it: the root of a Slate document, such as
|
|
@@ -1107,7 +1635,7 @@ declare function unsupported(input: UnsupportedFieldInput): UnsupportedField;
|
|
|
1107
1635
|
//#endregion
|
|
1108
1636
|
//#region src/define/fields/field.d.ts
|
|
1109
1637
|
/** One field of any type, as a `define.field.*` builder returns it. */
|
|
1110
|
-
type Field = BooleanField | StringField | DateField | DateTimeField | IntField | FloatField | EnumerationField | TaxonomyField | JsonField | RichTextField | ColorField | LocationField | ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | AssetField | UnsupportedField;
|
|
1638
|
+
type Field = BooleanField | StringField | DateField | DateTimeField | IntField | FloatField | EnumerationField | TaxonomyField | JsonField | RichTextField | ColorField | LocationField | ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | ReferenceUnionField | ReferenceUnionMemberField | AssetField | AssetReverseField | RemoteField | UnsupportedField;
|
|
1111
1639
|
/**
|
|
1112
1640
|
* Who sees the field. `READ_WRITE` shows it to editors and the API,
|
|
1113
1641
|
* `READ_ONLY` shows it without letting editors change it, `HIDDEN` hides
|
|
@@ -1231,6 +1759,15 @@ type AssetFieldInput = Omit<FieldInput, "required"> & {
|
|
|
1231
1759
|
* @default false
|
|
1232
1760
|
*/
|
|
1233
1761
|
required?: boolean;
|
|
1762
|
+
/**
|
|
1763
|
+
* The apiId of the field back on Asset, such as `imagePost` for `image`
|
|
1764
|
+
* on `Post`. Required on a model, whose field back holds a slot on
|
|
1765
|
+
* Asset: declare it in `system.asset`, `define.field.assetReverseField({
|
|
1766
|
+
* apiId: "imagePost", to: () => Post, reverse: "image" })`. Not on a
|
|
1767
|
+
* component, whose field back is hidden and named by the CLI. To rename
|
|
1768
|
+
* the field back, set `renamedFrom` on it and this to its new apiId.
|
|
1769
|
+
*/
|
|
1770
|
+
reverse?: string;
|
|
1234
1771
|
};
|
|
1235
1772
|
/**
|
|
1236
1773
|
* What `define.field.asset` hands back: the input with every default filled
|
|
@@ -1245,18 +1782,20 @@ type AssetField = {
|
|
|
1245
1782
|
required: boolean;
|
|
1246
1783
|
visibility: FieldVisibility;
|
|
1247
1784
|
visibilityCondition: FieldVisibilityCondition | null;
|
|
1785
|
+
reverse: string | null;
|
|
1248
1786
|
renamedFrom: string | null;
|
|
1249
1787
|
};
|
|
1250
1788
|
/**
|
|
1251
1789
|
* One asset, or a list of them, that editors connect to the entry. Hygraph
|
|
1252
|
-
* adds a field back on the Asset model
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1790
|
+
* adds a field back on the Asset model: on a model, the
|
|
1791
|
+
* `assetReverseField` on `system.asset` that `reverse` names; on a
|
|
1792
|
+
* component, a hidden one the CLI names after the field and the
|
|
1793
|
+
* component, `iconCard` for `icon` on `Card`.
|
|
1255
1794
|
*
|
|
1256
1795
|
* Nothing here is validated: the checks run at plan time with the model's
|
|
1257
1796
|
* or component's own.
|
|
1258
1797
|
*/
|
|
1259
|
-
declare function asset
|
|
1798
|
+
declare function asset(input: AssetFieldInput): AssetField;
|
|
1260
1799
|
//#endregion
|
|
1261
1800
|
//#region src/define/fields/dateTime.d.ts
|
|
1262
1801
|
/**
|
|
@@ -1288,14 +1827,6 @@ declare function markdown(input: StringFieldInput): MarkdownField;
|
|
|
1288
1827
|
*/
|
|
1289
1828
|
declare function multiline(input: StringFieldInput): MultilineField;
|
|
1290
1829
|
//#endregion
|
|
1291
|
-
//#region src/define/fields/referenceUnion.d.ts
|
|
1292
|
-
/** A reference to several models. On models every member declares `unionMember`. */
|
|
1293
|
-
declare function referenceUnion(_options: unknown): never;
|
|
1294
|
-
//#endregion
|
|
1295
|
-
//#region src/define/fields/remote.d.ts
|
|
1296
|
-
/** A field resolved from a remote source. `visibility` defaults to READ_ONLY. */
|
|
1297
|
-
declare function remote(_options: unknown): never;
|
|
1298
|
-
//#endregion
|
|
1299
1830
|
//#region src/define/fields/singleLine.d.ts
|
|
1300
1831
|
/**
|
|
1301
1832
|
* One line of text, such as a heading or a title. Studio's single line
|
|
@@ -1351,17 +1882,45 @@ type SlugFieldInput = FieldInput & LocalizedFieldInput & {
|
|
|
1351
1882
|
*/
|
|
1352
1883
|
declare function slug(input: SlugFieldInput): SlugField;
|
|
1353
1884
|
//#endregion
|
|
1354
|
-
//#region src/define/fields/unionMember.d.ts
|
|
1355
|
-
/** The slot a union's member model declares. All members share one `apiId`. Models only. */
|
|
1356
|
-
declare function unionMember(_options: unknown): never;
|
|
1357
|
-
//#endregion
|
|
1358
1885
|
//#region src/define/fields/vector.d.ts
|
|
1359
1886
|
/** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
|
|
1360
1887
|
declare function vector(_options: unknown): never;
|
|
1361
1888
|
declare namespace index_d_exports$2 {
|
|
1362
|
-
export { asset
|
|
1889
|
+
export { asset, assetReverseField, boolean, color, component, componentUnion, date, dateTime, enumeration, float, int, json, location, markdown, multiline, referenceOneWay, referenceTwoWay, referenceUnion, referenceUnionMember, remote, richText, singleLine, slug, string, taxonomy, unsupported, vector };
|
|
1363
1890
|
}
|
|
1364
1891
|
//#endregion
|
|
1892
|
+
//#region src/define/system/query.d.ts
|
|
1893
|
+
type SystemQueryInput = {
|
|
1894
|
+
/**
|
|
1895
|
+
* Your remote fields at the root of the Content API, built with
|
|
1896
|
+
* `define.field.remote`. Hygraph takes no other type here. There is no
|
|
1897
|
+
* entry, so a field reads `{{args.x}}` placeholders only. The order here
|
|
1898
|
+
* is the order Studio shows them in. Export writes a remote field the CLI
|
|
1899
|
+
* cannot read yet, such as one on a source with OAuth, as
|
|
1900
|
+
* `define.field.unsupported`.
|
|
1901
|
+
* @default []
|
|
1902
|
+
*/
|
|
1903
|
+
fields?: (RemoteField | UnsupportedField)[];
|
|
1904
|
+
};
|
|
1905
|
+
/**
|
|
1906
|
+
* What `system.query` hands back: Query with your fields. Put it in
|
|
1907
|
+
* `define.environment`'s `models`.
|
|
1908
|
+
*/
|
|
1909
|
+
type SystemQuery = {
|
|
1910
|
+
__typename: "SystemQuery";
|
|
1911
|
+
apiId: "QueryModel";
|
|
1912
|
+
fields: Field[];
|
|
1913
|
+
};
|
|
1914
|
+
/**
|
|
1915
|
+
* Hygraph's Query model, which Studio shows as Query, with your remote
|
|
1916
|
+
* fields on it. Put it in `define.environment`'s `models` to manage those
|
|
1917
|
+
* fields; leave it out and the plan does not touch Query at all. The plan
|
|
1918
|
+
* never creates or deletes Query.
|
|
1919
|
+
*
|
|
1920
|
+
* Nothing here is validated: the checks run at plan time with the models'.
|
|
1921
|
+
*/
|
|
1922
|
+
declare function query(input?: SystemQueryInput): SystemQuery;
|
|
1923
|
+
//#endregion
|
|
1365
1924
|
//#region src/define/system/stage.d.ts
|
|
1366
1925
|
/**
|
|
1367
1926
|
* What `system.stage.draft()` and `system.stage.published()` hand back:
|
|
@@ -1740,9 +2299,15 @@ type EnvironmentInput = {
|
|
|
1740
2299
|
enumerations?: Enumeration[];
|
|
1741
2300
|
/** @default [] */
|
|
1742
2301
|
taxonomies?: Taxonomy[];
|
|
2302
|
+
/**
|
|
2303
|
+
* Every remote source, from `define.graphqlRemoteSource` and
|
|
2304
|
+
* `define.restRemoteSource`.
|
|
2305
|
+
* @default []
|
|
2306
|
+
*/
|
|
2307
|
+
remoteSources?: RemoteSource[];
|
|
1743
2308
|
/** @default [] */
|
|
1744
2309
|
components?: Component[];
|
|
1745
|
-
models: Model[];
|
|
2310
|
+
models: (Model | SystemAsset | SystemQuery)[];
|
|
1746
2311
|
};
|
|
1747
2312
|
type Environment = {
|
|
1748
2313
|
__typename: "Environment";
|
|
@@ -1750,8 +2315,12 @@ type Environment = {
|
|
|
1750
2315
|
stages: (Stage | SystemStage)[];
|
|
1751
2316
|
enumerations: Enumeration[];
|
|
1752
2317
|
taxonomies: Taxonomy[];
|
|
2318
|
+
remoteSources: RemoteSource[];
|
|
1753
2319
|
components: Component[];
|
|
2320
|
+
/** Your models. The ones Hygraph provides are in `systemModels`. */
|
|
1754
2321
|
models: Model[];
|
|
2322
|
+
/** The models Hygraph provides that `models` lists, in its order. */
|
|
2323
|
+
systemModels: (SystemAsset | SystemQuery)[];
|
|
1755
2324
|
};
|
|
1756
2325
|
/**
|
|
1757
2326
|
* One environment: typed arrays per resource kind. The what.
|
|
@@ -1761,12 +2330,6 @@ type Environment = {
|
|
|
1761
2330
|
*/
|
|
1762
2331
|
declare function environment(input: EnvironmentInput): Environment;
|
|
1763
2332
|
//#endregion
|
|
1764
|
-
//#region src/define/resources/graphqlRemoteSource.d.ts
|
|
1765
|
-
declare function graphqlRemoteSource(_options: unknown): never;
|
|
1766
|
-
//#endregion
|
|
1767
|
-
//#region src/define/resources/restRemoteSource.d.ts
|
|
1768
|
-
declare function restRemoteSource(_options: unknown): never;
|
|
1769
|
-
//#endregion
|
|
1770
2333
|
//#region src/define/resources/target.d.ts
|
|
1771
2334
|
type TargetInput = {
|
|
1772
2335
|
name: string;
|
|
@@ -1798,16 +2361,10 @@ declare namespace index_d_exports {
|
|
|
1798
2361
|
export { component$1 as component, enumeration$1 as enumeration, environment, index_d_exports$2 as field, graphqlRemoteSource, locale, model, restRemoteSource, stage, target, taxonomy$1 as taxonomy };
|
|
1799
2362
|
}
|
|
1800
2363
|
//#endregion
|
|
1801
|
-
//#region src/define/system/asset.d.ts
|
|
1802
|
-
declare function asset(_options?: unknown): never;
|
|
1803
|
-
//#endregion
|
|
1804
|
-
//#region src/define/system/query.d.ts
|
|
1805
|
-
declare function query(_options?: unknown): never;
|
|
1806
|
-
//#endregion
|
|
1807
2364
|
//#region src/define/system/segment.d.ts
|
|
1808
2365
|
declare function segment(_options?: unknown): never;
|
|
1809
2366
|
declare namespace index_d_exports$1 {
|
|
1810
|
-
export { asset, query, segment, stage$1 as stage };
|
|
2367
|
+
export { asset$1 as asset, query, segment, stage$1 as stage };
|
|
1811
2368
|
}
|
|
1812
2369
|
//#endregion
|
|
1813
2370
|
//#region src/define.d.ts
|