@hygraph/cli 0.0.8 → 0.0.10

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/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: Field[];
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
@@ -430,7 +365,7 @@ type ComponentInput = {
430
365
  * the order editors see them in. May be empty. Every field type but
431
366
  * `referenceTwoWay` and `referenceUnionMember`, which only models have.
432
367
  */
433
- fields: Exclude<Field, ReferenceTwoWayField | ReferenceUnionMemberField>[];
368
+ fields: Exclude<Field, ReferenceTwoWayField | ReferenceUnionMemberField | AssetReverseField>[];
434
369
  /**
435
370
  * The apiId this component has in Hygraph right now, when you are
436
371
  * renaming it. The rename keeps the component's fields and content
@@ -461,56 +396,6 @@ type Component = {
461
396
  */
462
397
  declare function component$1(input: ComponentInput): Component;
463
398
  //#endregion
464
- //#region src/define/fields/component.d.ts
465
- /** The options `component` takes. */
466
- type ComponentFieldInput = Omit<FieldInput, "required"> & {
467
- /**
468
- * The component, as `define.component` returns it, behind a function:
469
- * `() => Seo`. The function lets a component hold itself, and two files
470
- * use each other in any order. List the component in the environment's
471
- * `components` too. Cannot change once the field exists: changing it
472
- * deletes the field and its content.
473
- */
474
- component: () => Component;
475
- /**
476
- * Whether the field holds a list of components. Cannot change once the
477
- * field exists: changing it deletes the field and its content.
478
- * @default false
479
- */
480
- list?: boolean;
481
- /**
482
- * Whether an entry needs the component filled in to be saved. On a model
483
- * or component that already has entries, add the field without it, fill
484
- * the field in every entry, then make it required: Hygraph refuses a
485
- * required component field that existing entries would leave empty.
486
- * @default false
487
- */
488
- required?: boolean;
489
- };
490
- /**
491
- * What `define.field.component` hands back: the input with every default
492
- * filled in.
493
- */
494
- type ComponentField = {
495
- __typename: "ComponentField";
496
- apiId: string;
497
- displayName: string;
498
- description: string | null;
499
- component: () => Component;
500
- list: boolean;
501
- required: boolean;
502
- visibility: FieldVisibility;
503
- visibilityCondition: FieldVisibilityCondition | null;
504
- renamedFrom: string | null;
505
- };
506
- /**
507
- * One component, or a list of them, that editors fill in inside the entry.
508
- *
509
- * Nothing here is validated, and the component is not looked at until the
510
- * plan: the checks run at plan time with the model's or component's own.
511
- */
512
- declare function component(input: ComponentFieldInput): ComponentField;
513
- //#endregion
514
399
  //#region src/define/fields/componentUnion.d.ts
515
400
  /**
516
401
  * The options `componentUnion` takes. Hygraph stores a union as never
@@ -565,6 +450,223 @@ type ComponentUnionField = {
565
450
  */
566
451
  declare function componentUnion(input: ComponentUnionFieldInput): ComponentUnionField;
567
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
568
670
  //#region src/define/fields/date.d.ts
569
671
  /**
570
672
  * The options `date` and `dateTime` take. Values are ISO strings: a day,
@@ -942,6 +1044,304 @@ type ReferenceUnionField = {
942
1044
  */
943
1045
  declare function referenceUnion(input: ReferenceUnionFieldInput): ReferenceUnionField;
944
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
945
1345
  //#region src/define/fields/richText.d.ts
946
1346
  /**
947
1347
  * Rich text as Hygraph stores it: the root of a Slate document, such as
@@ -1235,7 +1635,7 @@ declare function unsupported(input: UnsupportedFieldInput): UnsupportedField;
1235
1635
  //#endregion
1236
1636
  //#region src/define/fields/field.d.ts
1237
1637
  /** One field of any type, as a `define.field.*` builder returns it. */
1238
- type Field = BooleanField | StringField | DateField | DateTimeField | IntField | FloatField | EnumerationField | TaxonomyField | JsonField | RichTextField | ColorField | LocationField | ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | ReferenceUnionField | ReferenceUnionMemberField | 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;
1239
1639
  /**
1240
1640
  * Who sees the field. `READ_WRITE` shows it to editors and the API,
1241
1641
  * `READ_ONLY` shows it without letting editors change it, `HIDDEN` hides
@@ -1359,6 +1759,15 @@ type AssetFieldInput = Omit<FieldInput, "required"> & {
1359
1759
  * @default false
1360
1760
  */
1361
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;
1362
1771
  };
1363
1772
  /**
1364
1773
  * What `define.field.asset` hands back: the input with every default filled
@@ -1373,18 +1782,20 @@ type AssetField = {
1373
1782
  required: boolean;
1374
1783
  visibility: FieldVisibility;
1375
1784
  visibilityCondition: FieldVisibilityCondition | null;
1785
+ reverse: string | null;
1376
1786
  renamedFrom: string | null;
1377
1787
  };
1378
1788
  /**
1379
1789
  * One asset, or a list of them, that editors connect to the entry. Hygraph
1380
- * adds a field back on the Asset model, named after this field and its
1381
- * model or component: `imagePost` for `image` on `Post`. It is `API_ONLY`.
1382
- * Allowed on components.
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`.
1383
1794
  *
1384
1795
  * Nothing here is validated: the checks run at plan time with the model's
1385
1796
  * or component's own.
1386
1797
  */
1387
- declare function asset$1(input: AssetFieldInput): AssetField;
1798
+ declare function asset(input: AssetFieldInput): AssetField;
1388
1799
  //#endregion
1389
1800
  //#region src/define/fields/dateTime.d.ts
1390
1801
  /**
@@ -1416,10 +1827,6 @@ declare function markdown(input: StringFieldInput): MarkdownField;
1416
1827
  */
1417
1828
  declare function multiline(input: StringFieldInput): MultilineField;
1418
1829
  //#endregion
1419
- //#region src/define/fields/remote.d.ts
1420
- /** A field resolved from a remote source. `visibility` defaults to READ_ONLY. */
1421
- declare function remote(_options: unknown): never;
1422
- //#endregion
1423
1830
  //#region src/define/fields/singleLine.d.ts
1424
1831
  /**
1425
1832
  * One line of text, such as a heading or a title. Studio's single line
@@ -1479,9 +1886,41 @@ declare function slug(input: SlugFieldInput): SlugField;
1479
1886
  /** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
1480
1887
  declare function vector(_options: unknown): never;
1481
1888
  declare namespace index_d_exports$2 {
1482
- export { asset$1 as asset, 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 };
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 };
1483
1890
  }
1484
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
1485
1924
  //#region src/define/system/stage.d.ts
1486
1925
  /**
1487
1926
  * What `system.stage.draft()` and `system.stage.published()` hand back:
@@ -1860,9 +2299,15 @@ type EnvironmentInput = {
1860
2299
  enumerations?: Enumeration[];
1861
2300
  /** @default [] */
1862
2301
  taxonomies?: Taxonomy[];
2302
+ /**
2303
+ * Every remote source, from `define.graphqlRemoteSource` and
2304
+ * `define.restRemoteSource`.
2305
+ * @default []
2306
+ */
2307
+ remoteSources?: RemoteSource[];
1863
2308
  /** @default [] */
1864
2309
  components?: Component[];
1865
- models: Model[];
2310
+ models: (Model | SystemAsset | SystemQuery)[];
1866
2311
  };
1867
2312
  type Environment = {
1868
2313
  __typename: "Environment";
@@ -1870,8 +2315,12 @@ type Environment = {
1870
2315
  stages: (Stage | SystemStage)[];
1871
2316
  enumerations: Enumeration[];
1872
2317
  taxonomies: Taxonomy[];
2318
+ remoteSources: RemoteSource[];
1873
2319
  components: Component[];
2320
+ /** Your models. The ones Hygraph provides are in `systemModels`. */
1874
2321
  models: Model[];
2322
+ /** The models Hygraph provides that `models` lists, in its order. */
2323
+ systemModels: (SystemAsset | SystemQuery)[];
1875
2324
  };
1876
2325
  /**
1877
2326
  * One environment: typed arrays per resource kind. The what.
@@ -1881,12 +2330,6 @@ type Environment = {
1881
2330
  */
1882
2331
  declare function environment(input: EnvironmentInput): Environment;
1883
2332
  //#endregion
1884
- //#region src/define/resources/graphqlRemoteSource.d.ts
1885
- declare function graphqlRemoteSource(_options: unknown): never;
1886
- //#endregion
1887
- //#region src/define/resources/restRemoteSource.d.ts
1888
- declare function restRemoteSource(_options: unknown): never;
1889
- //#endregion
1890
2333
  //#region src/define/resources/target.d.ts
1891
2334
  type TargetInput = {
1892
2335
  name: string;
@@ -1918,16 +2361,10 @@ declare namespace index_d_exports {
1918
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 };
1919
2362
  }
1920
2363
  //#endregion
1921
- //#region src/define/system/asset.d.ts
1922
- declare function asset(_options?: unknown): never;
1923
- //#endregion
1924
- //#region src/define/system/query.d.ts
1925
- declare function query(_options?: unknown): never;
1926
- //#endregion
1927
2364
  //#region src/define/system/segment.d.ts
1928
2365
  declare function segment(_options?: unknown): never;
1929
2366
  declare namespace index_d_exports$1 {
1930
- export { asset, query, segment, stage$1 as stage };
2367
+ export { asset$1 as asset, query, segment, stage$1 as stage };
1931
2368
  }
1932
2369
  //#endregion
1933
2370
  //#region src/define.d.ts