@hygraph/cli 0.0.13 → 0.0.14

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
@@ -43,6 +43,8 @@ type IRConnectionsRule = {
43
43
  };
44
44
  /** Who sees a field: editors and the API, or fewer of them. */
45
45
  type IRFieldVisibility = "READ_WRITE" | "READ_ONLY" | "HIDDEN" | "API_ONLY";
46
+ /** An app element's settings, by the names the element declares. */
47
+ type IRAppRendererConfig = Record<string, IRJsonValue>;
46
48
  /** While the boolean base field is, or is not, `booleanValue`. */
47
49
  type IRBooleanVisibilityCondition = {
48
50
  baseField: string;
@@ -105,7 +107,8 @@ type ModelInput = {
105
107
  /**
106
108
  * The apiId this model has in Hygraph right now, when you are renaming it.
107
109
  * The rename keeps the model's content instead of deleting the model and
108
- * creating a new one. Safe to leave in place once applied.
110
+ * creating a new one. Safe to leave in place once applied. An environment
111
+ * that has neither apiId gets a new model under the new apiId.
109
112
  */
110
113
  renamedFrom?: string;
111
114
  };
@@ -132,6 +135,47 @@ type Model = {
132
135
  */
133
136
  declare function model$1(input: ModelInput): Model;
134
137
  //#endregion
138
+ //#region src/define/fields/renderer.d.ts
139
+ /**
140
+ * A setting of an app element, by the name the element declares. Studio's
141
+ * form offers text, numbers and switches.
142
+ */
143
+ type AppRendererConfig = IRAppRendererConfig;
144
+ type FieldRendererInput = {
145
+ /**
146
+ * An app's element as the field's editor in Studio. The app must be
147
+ * installed in the environment, which you do in Studio, and the element
148
+ * must be made for the field's type.
149
+ *
150
+ * @example { app: { appApiId: "stars", appElementApiId: "stars", config: { max: 5 } } }
151
+ */
152
+ app: {
153
+ /** The app's apiId. */
154
+ appApiId: string;
155
+ /** The element's apiId within the app. */
156
+ appElementApiId: string;
157
+ /**
158
+ * The element's settings for this field, by the names the element
159
+ * declares.
160
+ * @default {}
161
+ */
162
+ config?: AppRendererConfig;
163
+ };
164
+ };
165
+ /** What every `define.field.custom` builder takes besides its type's options. */
166
+ type CustomFieldInput = {
167
+ /** The installed app's element that is the field's editor in Studio. */
168
+ renderer: FieldRendererInput;
169
+ };
170
+ /** What a builder hands back for `renderer`: the input with its defaults. */
171
+ type FieldRenderer = {
172
+ app: {
173
+ appApiId: string;
174
+ appElementApiId: string;
175
+ config: AppRendererConfig;
176
+ };
177
+ };
178
+ //#endregion
135
179
  //#region src/define/fields/referenceOneWay.d.ts
136
180
  /**
137
181
  * The options `referenceOneWay` takes. A reference cannot be required. To
@@ -205,6 +249,11 @@ type ReferenceOneWayField = {
205
249
  visibility: FieldVisibility;
206
250
  visibilityCondition: FieldVisibilityCondition | null;
207
251
  variantEnabled: boolean;
252
+ /**
253
+ * The field's editor: `null` for Hygraph's own, or an app's element,
254
+ * which `define.field.custom` sets.
255
+ */
256
+ renderer: FieldRenderer | null;
208
257
  renamedFrom: string | null;
209
258
  };
210
259
  /**
@@ -274,6 +323,11 @@ type ReferenceTwoWayField = {
274
323
  visibility: FieldVisibility;
275
324
  visibilityCondition: FieldVisibilityCondition | null;
276
325
  variantEnabled: boolean;
326
+ /**
327
+ * The field's editor: `null` for Hygraph's own, or an app's element,
328
+ * which `define.field.custom` sets.
329
+ */
330
+ renderer: FieldRenderer | null;
277
331
  renamedFrom: string | null;
278
332
  };
279
333
  /**
@@ -373,7 +427,8 @@ type ComponentInput = {
373
427
  * The apiId this component has in Hygraph right now, when you are
374
428
  * renaming it. The rename keeps the component's fields and content
375
429
  * instead of deleting the component and creating a new one. Safe to leave
376
- * in place once applied.
430
+ * in place once applied. An environment that has neither apiId gets a new
431
+ * component under the new apiId.
377
432
  */
378
433
  renamedFrom?: string;
379
434
  };
@@ -572,6 +627,11 @@ type BooleanField = {
572
627
  initialValue: boolean | boolean[] | null;
573
628
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
574
629
  migrationValue: boolean | boolean[] | null;
630
+ /**
631
+ * The field's editor: `null` for Hygraph's own, or an app's element,
632
+ * which `define.field.custom` sets.
633
+ */
634
+ renderer: FieldRenderer | null;
575
635
  renamedFrom: string | null;
576
636
  };
577
637
  /**
@@ -616,6 +676,11 @@ type ColorField = {
616
676
  initialValue: ColorValue | ColorValue[] | null;
617
677
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
618
678
  migrationValue: ColorValue | ColorValue[] | null;
679
+ /**
680
+ * The field's editor: `null` for Hygraph's own, or an app's element,
681
+ * which `define.field.custom` sets.
682
+ */
683
+ renderer: FieldRenderer | null;
619
684
  renamedFrom: string | null;
620
685
  };
621
686
  /**
@@ -701,6 +766,11 @@ type DateFieldAttributes = {
701
766
  initialValue: string | string[] | null;
702
767
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
703
768
  migrationValue: string | string[] | null;
769
+ /**
770
+ * The field's editor: `null` for Hygraph's own, or an app's element,
771
+ * which `define.field.custom` sets.
772
+ */
773
+ renderer: FieldRenderer | null;
704
774
  renamedFrom: string | null;
705
775
  };
706
776
  /** What `define.field.date` hands back. */
@@ -731,7 +801,8 @@ type EnumerationValueInput<V extends string = string> = {
731
801
  /**
732
802
  * The apiId this value has in Hygraph right now, when you are renaming
733
803
  * it. The rename keeps the entries that hold the value. Safe to leave in
734
- * place once applied.
804
+ * place once applied. An enumeration that has no value under either apiId
805
+ * gets a new value under the new apiId.
735
806
  */
736
807
  renamedFrom?: string;
737
808
  };
@@ -756,7 +827,8 @@ type EnumerationInput<V extends string = string> = {
756
827
  /**
757
828
  * The apiId this enumeration has in Hygraph right now, when you are
758
829
  * renaming it. The rename keeps the enumeration's values and the fields
759
- * that use it. Safe to leave in place once applied.
830
+ * that use it. Safe to leave in place once applied. An environment that
831
+ * has neither apiId gets a new enumeration under the new apiId.
760
832
  */
761
833
  renamedFrom?: string;
762
834
  };
@@ -867,6 +939,11 @@ type JsonField = {
867
939
  initialValue: JsonValue | JsonValue[] | null;
868
940
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
869
941
  migrationValue: JsonValue | JsonValue[] | null;
942
+ /**
943
+ * The field's editor: `null` for Hygraph's own, or an app's element,
944
+ * which `define.field.custom` sets.
945
+ */
946
+ renderer: FieldRenderer | null;
870
947
  renamedFrom: string | null;
871
948
  };
872
949
  /**
@@ -909,6 +986,11 @@ type LocationField = {
909
986
  initialValue: LocationValue | LocationValue[] | null;
910
987
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
911
988
  migrationValue: LocationValue | LocationValue[] | null;
989
+ /**
990
+ * The field's editor: `null` for Hygraph's own, or an app's element,
991
+ * which `define.field.custom` sets.
992
+ */
993
+ renderer: FieldRenderer | null;
912
994
  renamedFrom: string | null;
913
995
  };
914
996
  /**
@@ -961,6 +1043,11 @@ type NumberFieldAttributes = {
961
1043
  /** Intent, like `renamedFrom`: read by the plan, never part of the IR. */
962
1044
  migrationValue: number | number[] | null;
963
1045
  validations: NumberValidationRules | null;
1046
+ /**
1047
+ * The field's editor: `null` for Hygraph's own, or an app's element,
1048
+ * which `define.field.custom` sets.
1049
+ */
1050
+ renderer: FieldRenderer | null;
964
1051
  renamedFrom: string | null;
965
1052
  };
966
1053
  /** What `define.field.int` hands back. */
@@ -1407,6 +1494,11 @@ type RichTextField = {
1407
1494
  migrationValue: RichTextValue | RichTextValue[] | null;
1408
1495
  embeds: (() => Model)[] | null;
1409
1496
  actions: RichTextAction[] | null;
1497
+ /**
1498
+ * The field's editor: `null` for Hygraph's own, or an app's element,
1499
+ * which `define.field.custom` sets.
1500
+ */
1501
+ renderer: FieldRenderer | null;
1410
1502
  renamedFrom: string | null;
1411
1503
  };
1412
1504
  /**
@@ -1470,13 +1562,17 @@ type SlugField = StringFieldAttributes & {
1470
1562
  autoGenerate: boolean;
1471
1563
  template: string | null;
1472
1564
  };
1565
+ /** What `define.field.custom.string` hands back: text an app's element edits. */
1566
+ type StringField = StringFieldAttributes & {
1567
+ __typename: "StringField";
1568
+ renderer: FieldRenderer;
1569
+ };
1473
1570
  /**
1474
- * A text field of any editor. Every text editor is Hygraph's `STRING`
1475
- * type, so switching editor is an update, not a new field.
1571
+ * A text field of any editor, Hygraph's or an app's. Every text editor is
1572
+ * Hygraph's `STRING` type, so switching editor is an update, not a new
1573
+ * field.
1476
1574
  */
1477
- type StringField = SingleLineField | MultilineField | MarkdownField | SlugField;
1478
- /** Text rendered by an installed app's element. `renderer` is required. */
1479
- declare function string(_options: unknown): never;
1575
+ type TextField = SingleLineField | MultilineField | MarkdownField | SlugField | StringField;
1480
1576
  /** `i` case insensitive, `m` multiline, `s` single line, as Studio offers them. */
1481
1577
  type RegexFlag = IRRegexFlag;
1482
1578
  type RegexRuleInput = {
@@ -1530,7 +1626,8 @@ type TaxonomyNodeInput = {
1530
1626
  /**
1531
1627
  * The apiId this node has in Hygraph right now, when you are renaming
1532
1628
  * it. The rename keeps the entries that hold the node. Safe to leave in
1533
- * place once applied.
1629
+ * place once applied. A taxonomy that has no node under either apiId gets
1630
+ * a new node under the new apiId.
1534
1631
  */
1535
1632
  renamedFrom?: string;
1536
1633
  };
@@ -1555,7 +1652,8 @@ type TaxonomyInput = {
1555
1652
  /**
1556
1653
  * The apiId this taxonomy has in Hygraph right now, when you are
1557
1654
  * renaming it. The rename keeps its nodes and the fields that use it.
1558
- * Safe to leave in place once applied.
1655
+ * Safe to leave in place once applied. An environment that has neither
1656
+ * apiId gets a new taxonomy under the new apiId.
1559
1657
  */
1560
1658
  renamedFrom?: string;
1561
1659
  };
@@ -1653,7 +1751,7 @@ declare function unsupported(input: UnsupportedFieldInput): UnsupportedField;
1653
1751
  //#endregion
1654
1752
  //#region src/define/fields/field.d.ts
1655
1753
  /** One field of any type, as a `define.field.*` builder returns it. */
1656
- type Field = BooleanField | StringField | DateField | DateTimeField | IntField | FloatField | EnumerationField | TaxonomyField | JsonField | RichTextField | ColorField | LocationField | ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | ReferenceUnionField | ReferenceUnionMemberField | AssetField | AssetReverseField | RemoteField | UnsupportedField;
1754
+ type Field = BooleanField | TextField | DateField | DateTimeField | IntField | FloatField | EnumerationField | TaxonomyField | JsonField | RichTextField | ColorField | LocationField | ComponentField | ComponentUnionField | ReferenceOneWayField | ReferenceTwoWayField | ReferenceUnionField | ReferenceUnionMemberField | AssetField | AssetReverseField | RemoteField | UnsupportedField;
1657
1755
  /**
1658
1756
  * Who sees the field. `READ_WRITE` shows it to editors and the API,
1659
1757
  * `READ_ONLY` shows it without letting editors change it, `HIDDEN` hides
@@ -1711,7 +1809,9 @@ type FieldInput = {
1711
1809
  /**
1712
1810
  * The apiId this field has in Hygraph right now, when you are renaming it.
1713
1811
  * The rename keeps the field's content instead of deleting the field and
1714
- * creating a new one. Safe to leave in place once applied.
1812
+ * creating a new one. Safe to leave in place once applied. A model or
1813
+ * component that has no field under either apiId gets a new field under
1814
+ * the new apiId.
1715
1815
  */
1716
1816
  renamedFrom?: string;
1717
1817
  };
@@ -1810,6 +1910,11 @@ type AssetField = {
1810
1910
  visibilityCondition: FieldVisibilityCondition | null;
1811
1911
  variantEnabled: boolean;
1812
1912
  reverse: string | null;
1913
+ /**
1914
+ * The field's editor: `null` for Hygraph's own, or an app's element,
1915
+ * which `define.field.custom` sets.
1916
+ */
1917
+ renderer: FieldRenderer | null;
1813
1918
  renamedFrom: string | null;
1814
1919
  };
1815
1920
  /**
@@ -1824,6 +1929,35 @@ type AssetField = {
1824
1929
  */
1825
1930
  declare function asset(input: AssetFieldInput): AssetField;
1826
1931
  //#endregion
1932
+ //#region src/define/fields/custom.d.ts
1933
+ /**
1934
+ * Fields whose editor in Studio is an installed app's element, in place of
1935
+ * Hygraph's own. Each builder takes what its type's builder takes, and the
1936
+ * element as `renderer`. Install the app in the environment in Studio;
1937
+ * the element must be made for the field's type.
1938
+ *
1939
+ * @example define.field.custom.int({ apiId: "rating", displayName: "Rating", renderer: { app: { appApiId: "stars", appElementApiId: "stars", config: { max: 5 } } } })
1940
+ */
1941
+ declare const custom: {
1942
+ /** Text. Takes what `singleLine` takes. */
1943
+ string: (input: StringFieldInput & CustomFieldInput) => StringField;
1944
+ int: (input: NumberFieldInput & CustomFieldInput) => IntField;
1945
+ float: (input: NumberFieldInput & CustomFieldInput) => FloatField;
1946
+ boolean: (input: BooleanFieldInput & CustomFieldInput) => BooleanField;
1947
+ date: (input: DateFieldInput & CustomFieldInput) => DateField;
1948
+ dateTime: (input: DateFieldInput & CustomFieldInput) => DateTimeField;
1949
+ json: (input: JsonFieldInput & CustomFieldInput) => JsonField;
1950
+ color: (input: ColorFieldInput & CustomFieldInput) => ColorField;
1951
+ location: (input: LocationFieldInput & CustomFieldInput) => LocationField;
1952
+ /** Rich text without `actions`: the element replaces the toolbar. */
1953
+ richText: (input: RichTextFieldInput & CustomFieldInput & {
1954
+ actions?: never;
1955
+ }) => RichTextField;
1956
+ referenceOneWay: (input: ReferenceOneWayFieldInput & CustomFieldInput) => ReferenceOneWayField;
1957
+ referenceTwoWay: (input: ReferenceTwoWayFieldInput & CustomFieldInput) => ReferenceTwoWayField;
1958
+ asset: (input: AssetFieldInput & CustomFieldInput) => AssetField;
1959
+ };
1960
+ //#endregion
1827
1961
  //#region src/define/fields/dateTime.d.ts
1828
1962
  /**
1829
1963
  * A moment, such as when an event starts. Values are ISO 8601 with seconds
@@ -1913,7 +2047,7 @@ declare function slug(input: SlugFieldInput): SlugField;
1913
2047
  /** An embedding. `dimension` is required (1 to 3072); `index` is refused above 2000. */
1914
2048
  declare function vector(_options: unknown): never;
1915
2049
  declare namespace index_d_exports$2 {
1916
- 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 };
2050
+ export { asset, assetReverseField, boolean, color, component, componentUnion, custom, date, dateTime, enumeration, float, int, json, location, markdown, multiline, referenceOneWay, referenceTwoWay, referenceUnion, referenceUnionMember, remote, richText, singleLine, slug, taxonomy, unsupported, vector };
1917
2051
  }
1918
2052
  //#endregion
1919
2053
  //#region src/define/system/query.d.ts
@@ -2292,7 +2426,8 @@ type LocaleInput<DisplayName extends string = string, ApiId extends string = str
2292
2426
  /**
2293
2427
  * The apiId this locale has in Hygraph right now, when you are renaming
2294
2428
  * it. The rename keeps the content in that locale. Safe to leave in place
2295
- * once applied.
2429
+ * once applied. An environment that has neither apiId gets a new locale
2430
+ * under the new apiId.
2296
2431
  */
2297
2432
  renamedFrom?: string;
2298
2433
  };