@hygraph/cli 0.0.11 → 0.0.13

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
@@ -130,7 +130,7 @@ type Model = {
130
130
  * uniqueness are plan-time checks, reported together rather than thrown one
131
131
  * at a time while the config loads.
132
132
  */
133
- declare function model(input: ModelInput): Model;
133
+ declare function model$1(input: ModelInput): Model;
134
134
  //#endregion
135
135
  //#region src/define/fields/referenceOneWay.d.ts
136
136
  /**
@@ -204,6 +204,7 @@ type ReferenceOneWayField = {
204
204
  rules: ReferenceRules | null;
205
205
  visibility: FieldVisibility;
206
206
  visibilityCondition: FieldVisibilityCondition | null;
207
+ variantEnabled: boolean;
207
208
  renamedFrom: string | null;
208
209
  };
209
210
  /**
@@ -272,6 +273,7 @@ type ReferenceTwoWayField = {
272
273
  rules: ReferenceRules | null;
273
274
  visibility: FieldVisibility;
274
275
  visibilityCondition: FieldVisibilityCondition | null;
276
+ variantEnabled: boolean;
275
277
  renamedFrom: string | null;
276
278
  };
277
279
  /**
@@ -289,7 +291,7 @@ declare function referenceTwoWay(input: ReferenceTwoWayFieldInput): ReferenceTwo
289
291
  //#endregion
290
292
  //#region src/define/fields/referenceUnionMember.d.ts
291
293
  /** The options `referenceUnionMember` takes. A reference cannot be required. */
292
- type ReferenceUnionMemberFieldInput = Omit<FieldInput, "required"> & {
294
+ type ReferenceUnionMemberFieldInput = Omit<FieldInput, "required" | "variantEnabled"> & {
293
295
  /**
294
296
  * The model the union reference is on, as `define.model` returns it,
295
297
  * behind a function: `() => Page`. List the model in the environment's
@@ -326,6 +328,7 @@ type ReferenceUnionMemberField = {
326
328
  required: false;
327
329
  visibility: FieldVisibility;
328
330
  visibilityCondition: FieldVisibilityCondition | null;
331
+ variantEnabled: false;
329
332
  renamedFrom: string | null;
330
333
  };
331
334
  /**
@@ -438,6 +441,7 @@ type ComponentUnionField = {
438
441
  required: false;
439
442
  visibility: FieldVisibility;
440
443
  visibilityCondition: FieldVisibilityCondition | null;
444
+ variantEnabled: boolean;
441
445
  renamedFrom: string | null;
442
446
  };
443
447
  /**
@@ -470,7 +474,7 @@ type SystemAssetInput = {
470
474
  fields?: AssetModelField[];
471
475
  };
472
476
  /**
473
- * What `system.asset` hands back: Asset with your fields. Put it in
477
+ * What `system.model.asset` hands back: Asset with your fields. Put it in
474
478
  * `define.environment`'s `models`.
475
479
  */
476
480
  type SystemAsset = {
@@ -494,7 +498,7 @@ declare function asset$1(input?: SystemAssetInput): SystemAsset;
494
498
  * and Hygraph takes no rules and no `required` on it. There is no
495
499
  * condition: the reader cannot see one on Asset.
496
500
  */
497
- type AssetReverseFieldInput = Omit<FieldInput, "required" | "visibility" | "visibilityCondition"> & {
501
+ type AssetReverseFieldInput = Omit<FieldInput, "required" | "visibility" | "visibilityCondition" | "variantEnabled"> & {
498
502
  /**
499
503
  * Studio makes every field back `API_ONLY`, and an editor can show it
500
504
  * on Asset's form there.
@@ -534,11 +538,12 @@ type AssetReverseField = {
534
538
  visibility: FieldVisibility;
535
539
  /** Always `null`: the reader cannot see a condition on Asset. */
536
540
  visibilityCondition: null;
541
+ variantEnabled: false;
537
542
  renamedFrom: string | null;
538
543
  };
539
544
  /**
540
545
  * 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
546
+ * use the asset there. Goes in `system.model.asset`'s fields, and the asset
542
547
  * field names it in `reverse`. It has its own name, description and
543
548
  * visibility, and renames on its own. Asset only.
544
549
  *
@@ -562,6 +567,7 @@ type BooleanField = {
562
567
  title: boolean;
563
568
  visibility: FieldVisibility;
564
569
  visibilityCondition: FieldVisibilityCondition | null;
570
+ variantEnabled: boolean;
565
571
  /** A list of values on a list field, one value otherwise. */
566
572
  initialValue: boolean | boolean[] | null;
567
573
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -605,6 +611,7 @@ type ColorField = {
605
611
  title: false;
606
612
  visibility: FieldVisibility;
607
613
  visibilityCondition: FieldVisibilityCondition | null;
614
+ variantEnabled: boolean;
608
615
  /** A list of values on a list field, one value otherwise. */
609
616
  initialValue: ColorValue | ColorValue[] | null;
610
617
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -657,6 +664,7 @@ type ComponentField = {
657
664
  required: boolean;
658
665
  visibility: FieldVisibility;
659
666
  visibilityCondition: FieldVisibilityCondition | null;
667
+ variantEnabled: boolean;
660
668
  renamedFrom: string | null;
661
669
  };
662
670
  /**
@@ -688,6 +696,7 @@ type DateFieldAttributes = {
688
696
  title: boolean;
689
697
  visibility: FieldVisibility;
690
698
  visibilityCondition: FieldVisibilityCondition | null;
699
+ variantEnabled: boolean;
691
700
  /** A list of values on a list field, one value otherwise. */
692
701
  initialValue: string | string[] | null;
693
702
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -812,6 +821,7 @@ type EnumerationField<V extends string = string> = {
812
821
  title: boolean;
813
822
  visibility: FieldVisibility;
814
823
  visibilityCondition: FieldVisibilityCondition | null;
824
+ variantEnabled: boolean;
815
825
  /** A list of values on a list field, one value otherwise. */
816
826
  initialValue: V | V[] | null;
817
827
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -852,6 +862,7 @@ type JsonField = {
852
862
  title: false;
853
863
  visibility: FieldVisibility;
854
864
  visibilityCondition: FieldVisibilityCondition | null;
865
+ variantEnabled: boolean;
855
866
  /** A list of values on a list field, one value otherwise. */
856
867
  initialValue: JsonValue | JsonValue[] | null;
857
868
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -893,6 +904,7 @@ type LocationField = {
893
904
  title: false;
894
905
  visibility: FieldVisibility;
895
906
  visibilityCondition: FieldVisibilityCondition | null;
907
+ variantEnabled: boolean;
896
908
  /** A list of values on a list field, one value otherwise. */
897
909
  initialValue: LocationValue | LocationValue[] | null;
898
910
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -943,6 +955,7 @@ type NumberFieldAttributes = {
943
955
  title: boolean;
944
956
  visibility: FieldVisibility;
945
957
  visibilityCondition: FieldVisibilityCondition | null;
958
+ variantEnabled: boolean;
946
959
  /** A list of values on a list field, one value otherwise. */
947
960
  initialValue: number | number[] | null;
948
961
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -1031,6 +1044,7 @@ type ReferenceUnionField = {
1031
1044
  rules: ReferenceRules | null;
1032
1045
  visibility: FieldVisibility;
1033
1046
  visibilityCondition: FieldVisibilityCondition | null;
1047
+ variantEnabled: boolean;
1034
1048
  renamedFrom: string | null;
1035
1049
  };
1036
1050
  /**
@@ -1235,7 +1249,7 @@ type RemoteFieldArgInput = {
1235
1249
  list?: boolean;
1236
1250
  };
1237
1251
  /** The options every remote field takes, whatever its source. */
1238
- type RemoteFieldBaseInput = Omit<FieldInput, "visibility" | "visibilityCondition" | "renamedFrom"> & {
1252
+ type RemoteFieldBaseInput = Omit<FieldInput, "visibility" | "visibilityCondition" | "variantEnabled" | "renamedFrom"> & {
1239
1253
  /**
1240
1254
  * Hygraph cannot rename a remote field: the batch ignores the new apiId
1241
1255
  * (FND-5075).
@@ -1331,6 +1345,7 @@ type RemoteField = {
1331
1345
  visibility: FieldVisibility;
1332
1346
  /** Always `null`, so the checks every field shares can read it. */
1333
1347
  visibilityCondition: null;
1348
+ variantEnabled: false;
1334
1349
  renamedFrom: string | null;
1335
1350
  };
1336
1351
  /**
@@ -1385,6 +1400,7 @@ type RichTextField = {
1385
1400
  title: false;
1386
1401
  visibility: FieldVisibility;
1387
1402
  visibilityCondition: FieldVisibilityCondition | null;
1403
+ variantEnabled: boolean;
1388
1404
  /** A list of values on a list field, one value otherwise. */
1389
1405
  initialValue: RichTextValue | RichTextValue[] | null;
1390
1406
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -1427,6 +1443,7 @@ type StringFieldAttributes = {
1427
1443
  title: boolean;
1428
1444
  visibility: FieldVisibility;
1429
1445
  visibilityCondition: FieldVisibilityCondition | null;
1446
+ variantEnabled: boolean;
1430
1447
  /** A list of values on a list field, one value otherwise. */
1431
1448
  initialValue: string | string[] | null;
1432
1449
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -1597,6 +1614,7 @@ type TaxonomyField = {
1597
1614
  unique: boolean;
1598
1615
  visibility: FieldVisibility;
1599
1616
  visibilityCondition: FieldVisibilityCondition | null;
1617
+ variantEnabled: boolean;
1600
1618
  /** A list of node apiIds on a list field, one otherwise. */
1601
1619
  initialValue: string | string[] | null;
1602
1620
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
@@ -1682,6 +1700,14 @@ type FieldInput = {
1682
1700
  * @default null
1683
1701
  */
1684
1702
  visibilityCondition?: FieldVisibilityCondition;
1703
+ /**
1704
+ * Whether editors can give the field a different value per audience
1705
+ * segment, as variants of the entry. Hygraph adds its Segment model
1706
+ * with the first such field. Only on a field of a model, and not on a
1707
+ * unique one. Turning it off deletes the field's variant values.
1708
+ * @default false
1709
+ */
1710
+ variantEnabled?: boolean;
1685
1711
  /**
1686
1712
  * The apiId this field has in Hygraph right now, when you are renaming it.
1687
1713
  * The rename keeps the field's content instead of deleting the field and
@@ -1762,7 +1788,7 @@ type AssetFieldInput = Omit<FieldInput, "required"> & {
1762
1788
  /**
1763
1789
  * The apiId of the field back on Asset, such as `imagePost` for `image`
1764
1790
  * on `Post`. Required on a model, whose field back holds a slot on
1765
- * Asset: declare it in `system.asset`, `define.field.assetReverseField({
1791
+ * Asset: declare it in `system.model.asset`, `define.field.assetReverseField({
1766
1792
  * apiId: "imagePost", to: () => Post, reverse: "image" })`. Not on a
1767
1793
  * component, whose field back is hidden and named by the CLI. To rename
1768
1794
  * the field back, set `renamedFrom` on it and this to its new apiId.
@@ -1782,13 +1808,14 @@ type AssetField = {
1782
1808
  required: boolean;
1783
1809
  visibility: FieldVisibility;
1784
1810
  visibilityCondition: FieldVisibilityCondition | null;
1811
+ variantEnabled: boolean;
1785
1812
  reverse: string | null;
1786
1813
  renamedFrom: string | null;
1787
1814
  };
1788
1815
  /**
1789
1816
  * One asset, or a list of them, that editors connect to the entry. Hygraph
1790
1817
  * adds a field back on the Asset model: on a model, the
1791
- * `assetReverseField` on `system.asset` that `reverse` names; on a
1818
+ * `assetReverseField` on `system.model.asset` that `reverse` names; on a
1792
1819
  * component, a hidden one the CLI names after the field and the
1793
1820
  * component, `iconCard` for `icon` on `Card`.
1794
1821
  *
@@ -1903,7 +1930,7 @@ type SystemQueryInput = {
1903
1930
  fields?: (RemoteField | UnsupportedField)[];
1904
1931
  };
1905
1932
  /**
1906
- * What `system.query` hands back: Query with your fields. Put it in
1933
+ * What `system.model.query` hands back: Query with your fields. Put it in
1907
1934
  * `define.environment`'s `models`.
1908
1935
  */
1909
1936
  type SystemQuery = {
@@ -1921,6 +1948,45 @@ type SystemQuery = {
1921
1948
  */
1922
1949
  declare function query(input?: SystemQueryInput): SystemQuery;
1923
1950
  //#endregion
1951
+ //#region src/define/system/segment.d.ts
1952
+ /**
1953
+ * A field Hygraph takes on Segment: text, rich text, numbers, dates,
1954
+ * booleans, JSON, colors, locations, enumerations and taxonomies. No
1955
+ * component, reference, asset or remote field.
1956
+ */
1957
+ type SegmentModelField = Exclude<Field, ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | ReferenceUnionField | ReferenceUnionMemberField | AssetField | AssetReverseField | RemoteField>;
1958
+ type SystemSegmentInput = {
1959
+ /**
1960
+ * Your fields on Segment, built with `define.field.*`. They come after
1961
+ * Hygraph's own, its name and description, which are never listed here.
1962
+ * None can be `required` or `localized`, and none has variants. The order
1963
+ * here is the order editors see them in.
1964
+ * @default []
1965
+ */
1966
+ fields?: SegmentModelField[];
1967
+ };
1968
+ /**
1969
+ * What `system.model.segment` hands back: Segment with your fields. Put it in
1970
+ * `define.environment`'s `models`.
1971
+ */
1972
+ type SystemSegment = {
1973
+ __typename: "SystemSegment";
1974
+ apiId: "Segment";
1975
+ fields: Field[];
1976
+ };
1977
+ /**
1978
+ * Hygraph's Segment model, the audiences that fields with `variantEnabled`
1979
+ * have values for, with your fields on it. Hygraph adds Segment with the
1980
+ * first field that has variants, and keeps it after. Your fields on it
1981
+ * need such a field, live or in the same plan, which then makes Segment
1982
+ * first. Put it in `define.environment`'s `models` to manage those fields;
1983
+ * leave it out and the plan does not touch Segment at all. The plan never
1984
+ * creates or deletes Segment.
1985
+ *
1986
+ * Nothing here is validated: the checks run at plan time with the models'.
1987
+ */
1988
+ declare function segment(input?: SystemSegmentInput): SystemSegment;
1989
+ //#endregion
1924
1990
  //#region src/define/system/stage.d.ts
1925
1991
  /**
1926
1992
  * What `system.stage.draft()` and `system.stage.published()` hand back:
@@ -2307,7 +2373,7 @@ type EnvironmentInput = {
2307
2373
  remoteSources?: RemoteSource[];
2308
2374
  /** @default [] */
2309
2375
  components?: Component[];
2310
- models: (Model | SystemAsset | SystemQuery)[];
2376
+ models: (Model | SystemModel)[];
2311
2377
  };
2312
2378
  type Environment = {
2313
2379
  __typename: "Environment";
@@ -2320,8 +2386,10 @@ type Environment = {
2320
2386
  /** Your models. The ones Hygraph provides are in `systemModels`. */
2321
2387
  models: Model[];
2322
2388
  /** The models Hygraph provides that `models` lists, in its order. */
2323
- systemModels: (SystemAsset | SystemQuery)[];
2389
+ systemModels: SystemModel[];
2324
2390
  };
2391
+ /** A model Hygraph provides, as `system.*` hands it back. */
2392
+ type SystemModel = SystemAsset | SystemQuery | SystemSegment;
2325
2393
  /**
2326
2394
  * One environment: typed arrays per resource kind. The what.
2327
2395
  *
@@ -2358,14 +2426,21 @@ type Target = {
2358
2426
  */
2359
2427
  declare function target(input: TargetInput): Target;
2360
2428
  declare namespace index_d_exports {
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 };
2429
+ export { component$1 as component, enumeration$1 as enumeration, environment, index_d_exports$2 as field, graphqlRemoteSource, locale, model$1 as model, restRemoteSource, stage, target, taxonomy$1 as taxonomy };
2362
2430
  }
2363
- //#endregion
2364
- //#region src/define/system/segment.d.ts
2365
- declare function segment(_options?: unknown): never;
2366
2431
  declare namespace index_d_exports$1 {
2367
- export { asset$1 as asset, query, segment, stage$1 as stage };
2432
+ export { model, stage$1 as stage };
2368
2433
  }
2434
+ /**
2435
+ * The models Hygraph provides, with your fields on them:
2436
+ * `system.model.asset()`, `system.model.query()` and
2437
+ * `system.model.segment()`.
2438
+ */
2439
+ declare const model: {
2440
+ asset: typeof asset$1;
2441
+ query: typeof query;
2442
+ segment: typeof segment;
2443
+ };
2369
2444
  //#endregion
2370
2445
  //#region src/define.d.ts
2371
2446
  /**