@webiny/app-headless-cms-common 0.0.0-unstable.ac6ebf63c6 → 0.0.0-unstable.b6d7105cee

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.
Files changed (81) hide show
  1. package/constants.js +2 -1
  2. package/constants.js.map +1 -1
  3. package/exports/admin/cms.d.ts +1 -1
  4. package/exports/admin/cms.js +0 -3
  5. package/index.d.ts +1 -10
  6. package/index.js +1 -12
  7. package/package.json +21 -25
  8. package/types/index.d.ts +21 -299
  9. package/types/index.js +1 -3
  10. package/types/model.d.ts +63 -18
  11. package/types/model.js +4 -1
  12. package/types/model.js.map +1 -1
  13. package/types/shared.d.ts +6 -0
  14. package/types/shared.js +0 -3
  15. package/Fields/ErrorBoundary.d.ts +0 -24
  16. package/Fields/ErrorBoundary.js +0 -40
  17. package/Fields/ErrorBoundary.js.map +0 -1
  18. package/Fields/FieldElement.d.ts +0 -64
  19. package/Fields/FieldElement.js +0 -77
  20. package/Fields/FieldElement.js.map +0 -1
  21. package/Fields/FieldElementError.d.ts +0 -7
  22. package/Fields/FieldElementError.js +0 -25
  23. package/Fields/FieldElementError.js.map +0 -1
  24. package/Fields/Fields.d.ts +0 -11
  25. package/Fields/Fields.js +0 -35
  26. package/Fields/Fields.js.map +0 -1
  27. package/Fields/Label.d.ts +0 -6
  28. package/Fields/Label.js +0 -10
  29. package/Fields/Label.js.map +0 -1
  30. package/Fields/index.d.ts +0 -3
  31. package/Fields/index.js +0 -5
  32. package/Fields/index.js.map +0 -1
  33. package/Fields/useBind.d.ts +0 -9
  34. package/Fields/useBind.js +0 -113
  35. package/Fields/useBind.js.map +0 -1
  36. package/Fields/useRenderPlugins.d.ts +0 -1
  37. package/Fields/useRenderPlugins.js +0 -7
  38. package/Fields/useRenderPlugins.js.map +0 -1
  39. package/ModelFieldProvider/ModelFieldContext.d.ts +0 -38
  40. package/ModelFieldProvider/ModelFieldContext.js +0 -26
  41. package/ModelFieldProvider/ModelFieldContext.js.map +0 -1
  42. package/ModelFieldProvider/index.d.ts +0 -2
  43. package/ModelFieldProvider/index.js +0 -4
  44. package/ModelFieldProvider/index.js.map +0 -1
  45. package/ModelFieldProvider/useModelField.d.ts +0 -15
  46. package/ModelFieldProvider/useModelField.js +0 -29
  47. package/ModelFieldProvider/useModelField.js.map +0 -1
  48. package/ModelProvider/ModelContext.d.ts +0 -9
  49. package/ModelProvider/ModelContext.js +0 -12
  50. package/ModelProvider/ModelContext.js.map +0 -1
  51. package/ModelProvider/index.d.ts +0 -2
  52. package/ModelProvider/index.js +0 -4
  53. package/ModelProvider/index.js.map +0 -1
  54. package/ModelProvider/useModel.d.ts +0 -9
  55. package/ModelProvider/useModel.js +0 -16
  56. package/ModelProvider/useModel.js.map +0 -1
  57. package/createFieldsList.d.ts +0 -8
  58. package/createFieldsList.js +0 -49
  59. package/createFieldsList.js.map +0 -1
  60. package/createValidationContainer.d.ts +0 -18
  61. package/createValidationContainer.js +0 -23
  62. package/createValidationContainer.js.map +0 -1
  63. package/createValidators.d.ts +0 -3
  64. package/createValidators.js +0 -52
  65. package/createValidators.js.map +0 -1
  66. package/entries.graphql.d.ts +0 -218
  67. package/entries.graphql.js +0 -422
  68. package/entries.graphql.js.map +0 -1
  69. package/exports/admin/cms.js.map +0 -1
  70. package/getModelTitleFieldId.d.ts +0 -2
  71. package/getModelTitleFieldId.js +0 -8
  72. package/getModelTitleFieldId.js.map +0 -1
  73. package/index.js.map +0 -1
  74. package/prepareFormData.d.ts +0 -2
  75. package/prepareFormData.js +0 -71
  76. package/prepareFormData.js.map +0 -1
  77. package/types/index.js.map +0 -1
  78. package/types/shared.js.map +0 -1
  79. package/types/validation.d.ts +0 -79
  80. package/types/validation.js +0 -3
  81. package/types/validation.js.map +0 -1
package/constants.js CHANGED
@@ -1,3 +1,4 @@
1
- export const CMS_MODEL_SINGLETON_TAG = "singleEntry";
1
+ const CMS_MODEL_SINGLETON_TAG = "singleEntry";
2
+ export { CMS_MODEL_SINGLETON_TAG };
2
3
 
3
4
  //# sourceMappingURL=constants.js.map
package/constants.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["CMS_MODEL_SINGLETON_TAG"],"sources":["constants.ts"],"sourcesContent":["export const CMS_MODEL_SINGLETON_TAG = \"singleEntry\";\n"],"mappings":"AAAA,OAAO,MAAMA,uBAAuB,GAAG,aAAa","ignoreList":[]}
1
+ {"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const CMS_MODEL_SINGLETON_TAG = \"singleEntry\";\n"],"names":["CMS_MODEL_SINGLETON_TAG"],"mappings":"AAAO,MAAMA,0BAA0B"}
@@ -1 +1 @@
1
- export type { CmsContentEntry, CmsModel, CmsModelField, CmsIdentity } from "../../types/index.ts";
1
+ export type { CmsContentEntry, CmsModel, CmsModelField, CmsModelLayoutField, CmsIdentity } from "../../types/index.js";
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=cms.js.map
package/index.d.ts CHANGED
@@ -1,10 +1 @@
1
- export * from "./Fields/index.js";
2
- export * from "./ModelFieldProvider/index.js";
3
- export * from "./ModelProvider/index.js";
4
- export * from "./entries.graphql.js";
5
- export * from "./getModelTitleFieldId.js";
6
- export * from "./createFieldsList.js";
7
- export * from "./createValidationContainer.js";
8
- export * from "./createValidators.js";
9
- export * from "./prepareFormData.js";
10
- export * from "./constants.js";
1
+ export { CMS_MODEL_SINGLETON_TAG } from "./constants.js";
package/index.js CHANGED
@@ -1,12 +1 @@
1
- export * from "./Fields/index.js";
2
- export * from "./ModelFieldProvider/index.js";
3
- export * from "./ModelProvider/index.js";
4
- export * from "./entries.graphql.js";
5
- export * from "./getModelTitleFieldId.js";
6
- export * from "./createFieldsList.js";
7
- export * from "./createValidationContainer.js";
8
- export * from "./createValidators.js";
9
- export * from "./prepareFormData.js";
10
- export * from "./constants.js";
11
-
12
- //# sourceMappingURL=index.js.map
1
+ export { CMS_MODEL_SINGLETON_TAG } from "./constants.js";
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms-common",
3
- "version": "0.0.0-unstable.ac6ebf63c6",
3
+ "version": "0.0.0-unstable.b6d7105cee",
4
4
  "type": "module",
5
- "main": "index.js",
5
+ "exports": {
6
+ ".": "./index.js",
7
+ "./*": "./*"
8
+ },
6
9
  "repository": {
7
10
  "type": "git",
8
11
  "url": "https://github.com/webiny/webiny-js.git"
@@ -14,34 +17,27 @@
14
17
  ],
15
18
  "license": "MIT",
16
19
  "dependencies": {
17
- "@emotion/react": "11.10.8",
18
- "@emotion/styled": "11.10.6",
19
- "@fortawesome/fontawesome-svg-core": "1.3.0",
20
- "@webiny/admin-ui": "0.0.0-unstable.ac6ebf63c6",
21
- "@webiny/app": "0.0.0-unstable.ac6ebf63c6",
22
- "@webiny/app-admin": "0.0.0-unstable.ac6ebf63c6",
23
- "@webiny/form": "0.0.0-unstable.ac6ebf63c6",
24
- "@webiny/plugins": "0.0.0-unstable.ac6ebf63c6",
25
- "@webiny/react-composition": "0.0.0-unstable.ac6ebf63c6",
26
- "@webiny/validation": "0.0.0-unstable.ac6ebf63c6",
20
+ "@fortawesome/fontawesome-svg-core": "7.3.1",
21
+ "@webiny/admin-ui": "0.0.0-unstable.b6d7105cee",
22
+ "@webiny/app": "0.0.0-unstable.b6d7105cee",
23
+ "@webiny/app-admin": "0.0.0-unstable.b6d7105cee",
24
+ "@webiny/form": "0.0.0-unstable.b6d7105cee",
25
+ "@webiny/plugins": "0.0.0-unstable.b6d7105cee",
26
+ "@webiny/validation": "0.0.0-unstable.b6d7105cee",
27
27
  "dnd-core": "16.0.1",
28
- "graphql": "16.12.0",
29
- "graphql-tag": "2.12.6",
30
- "lodash": "4.17.23",
31
- "prop-types": "15.8.1",
32
- "react": "18.2.0"
28
+ "react": "18.3.1"
33
29
  },
34
30
  "devDependencies": {
35
- "@emotion/babel-plugin": "11.13.5",
36
- "@types/react": "18.2.79",
37
- "@webiny/build-tools": "0.0.0-unstable.ac6ebf63c6",
38
- "babel-plugin-module-resolver": "5.0.2",
31
+ "@types/react": "18.3.31",
32
+ "@webiny/build-tools": "0.0.0-unstable.b6d7105cee",
39
33
  "rimraf": "6.1.3",
40
- "typescript": "5.9.3"
34
+ "typescript": "7.0.2"
41
35
  },
42
36
  "publishConfig": {
43
- "access": "public",
44
- "directory": "dist"
37
+ "access": "public"
45
38
  },
46
- "gitHead": "ac6ebf63c6de308703d41f2c1b375e03cd96b813"
39
+ "gitHead": "8476da73b653c89cc1474d968baf55c1b0ae0e5f",
40
+ "webiny": {
41
+ "publishFrom": "dist"
42
+ }
47
43
  }
package/types/index.d.ts CHANGED
@@ -3,24 +3,19 @@ import type { ReactElement, ReactNode } from "react";
3
3
  import type { Plugin } from "@webiny/plugins/types.js";
4
4
  import type { BindComponent as BaseBindComponent, BindComponentProps as BaseBindComponentProps, BindComponentRenderProp as BaseBindComponentRenderProp, FormAPI } from "@webiny/form";
5
5
  import type { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
6
- import type { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation.js";
7
- import type { CmsModel, CmsModelField } from "./model.js";
6
+ import type { CmsEditorFieldsLayout, CmsLayoutField, CmsModel, CmsModelField } from "./model.js";
8
7
  import type { CmsIdentity } from "../types/shared.js";
9
8
  import type { SourceType } from "dnd-core";
10
9
  import type { IconPickerIconDto } from "@webiny/admin-ui";
11
- import { GenericRecord } from "@webiny/app/types.js";
12
- import { Identity } from "@webiny/app-admin/domain/Identity.js";
10
+ import type { GenericRecord } from "@webiny/app/types.js";
11
+ import type { Identity } from "@webiny/app-admin/domain/Identity.js";
12
+ import type { CmsModelFieldValidator } from "./model.js";
13
13
  export type DragObjectWithType = {
14
14
  type: SourceType;
15
15
  };
16
- export type * from "./validation.js";
17
16
  export type * from "./model.js";
17
+ export { isLayoutField } from "./model.js";
18
18
  export type * from "./shared.js";
19
- interface QueryFieldParams {
20
- model: CmsModel;
21
- field: CmsModelField;
22
- graphQLTypePrefix: string;
23
- }
24
19
  interface Position {
25
20
  row: number;
26
21
  index: number;
@@ -31,282 +26,12 @@ interface Location {
31
26
  export interface DragSource extends DragObjectWithType {
32
27
  parent?: string;
33
28
  pos?: Partial<Position>;
34
- type: "row" | "field" | "newField";
29
+ type: "row" | "field" | "newField" | "newLayoutField" | "layoutField";
35
30
  fieldType?: string;
31
+ layoutFieldType?: string;
36
32
  field?: CmsModelField | null;
37
33
  fields?: CmsModelField[];
38
- }
39
- /**
40
- * @deprecated Use `CmsModelFieldTypePlugin`.
41
- */
42
- export type CmsEditorFieldTypePlugin = CmsModelFieldTypePlugin;
43
- export interface CmsModelFieldTypePlugin extends Plugin {
44
- /**
45
- * a plugin type
46
- */
47
- type: "cms-editor-field-type";
48
- field: {
49
- /**
50
- * A unique identifier of the field type (text, number, json, myField, ...).
51
- *
52
- * ```ts
53
- * type: "myField"
54
- * ```
55
- */
56
- type: string;
57
- /**
58
- * A display name for the field.
59
- *
60
- * ```ts
61
- * label: "Field name"
62
- * ```
63
- */
64
- label: string;
65
- /**
66
- * A list of available validators for the model field.
67
- *
68
- * ```ts
69
- * validators: [
70
- * "required",
71
- * "gte",
72
- * "lte"
73
- * ]
74
- * ```
75
- */
76
- validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;
77
- /**
78
- * A list of available validators when a model field accepts a list (array) of values.
79
- *
80
- * ```ts
81
- * listValidators: [
82
- * "minLength",
83
- * "maxLength"
84
- * ]
85
- * ```
86
- */
87
- listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;
88
- /**
89
- * An explanation of the field displayed beneath the label.
90
- *
91
- * ```ts
92
- * description: "A short description of the field"
93
- * ```
94
- */
95
- description: string;
96
- /**
97
- * A ReactNode to display the icon for the field.
98
- *
99
- * ```tsx
100
- * icon: <MyIconComponent />
101
- * ```
102
- */
103
- icon: React.ReactNode;
104
- /**
105
- * Is it allowed to have multiple values in this field?
106
- *
107
- * ```ts
108
- * allowList: true
109
- * ```
110
- */
111
- allowList?: boolean;
112
- /**
113
- * Does this field type have a fixed list of values that can be selected?
114
- *
115
- * ```ts
116
- * allowPredefinedValues: false
117
- * ```
118
- */
119
- allowPredefinedValues?: boolean;
120
- /**
121
- * A ReactNode label when multiple values are enabled.
122
- */
123
- listLabel?: React.ReactNode;
124
- /**
125
- * Determines if this field type should be hidden from the admin UI.
126
- * If set to `true`, the field type will not be visible or selectable in the admin interface.
127
- */
128
- hideInAdmin?: boolean;
129
- /**
130
- * These are default values when the field is first created. This is a representation of the field that is stored in the database.
131
- *
132
- * ```ts
133
- * createField: () => ({
134
- * type: "fieldType",
135
- * validation: [],
136
- * renderer: {
137
- * name: "fieldTypeRenderer"
138
- * }
139
- * })
140
- * ```
141
- */
142
- createField: () => Pick<CmsModelField, "type" | "validation" | "renderer" | "settings">;
143
- /**
144
- * If `true` (default), this field will be configurable via a settings dialog.
145
- * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.
146
- */
147
- canEditSettings?: boolean;
148
- /**
149
- * Determine if a `draggable` can be dropped into this field.
150
- * NOTE: This is only applicable to nested field types.
151
- */
152
- canAccept?(field: CmsModelField, draggable: DragSource): boolean;
153
- /**
154
- * If `true` (default), will allow fields to be laid out into columns (next to each other).
155
- * If `false`, horizontal layout will not be allowed.
156
- * NOTE: This is only applicable to nested field types.
157
- */
158
- allowLayout?: boolean;
159
- /**
160
- * A ReactNode that you can add in the section below the help text when creating/editing field.
161
- *
162
- * ```tsx
163
- * renderSettings: (params) => {
164
- * return <FieldSettingsComponent />;
165
- * }
166
- * ```
167
- */
168
- renderSettings?: (params: {
169
- afterChangeLabel: (value: string) => void;
170
- uniqueFieldIdValidator: (fieldId: string) => void;
171
- contentModel: CmsModel;
172
- }) => React.ReactNode;
173
- /**
174
- * A ReactNode that renders in the Predefined values tab.
175
- *
176
- * ```tsx
177
- * renderPredefinedValues: (params) => {
178
- * const {form: {Bind}} = params;
179
- * return (
180
- * <Bind name="fieldProperty">
181
- * <InputComponent />
182
- * </Bind>
183
- * );
184
- * }
185
- * ```
186
- */
187
- renderPredefinedValues?: (params: {
188
- getBind: (index?: number) => any;
189
- }) => React.ReactElement;
190
- /**
191
- * Object wrapper for GraphQL stuff
192
- */
193
- graphql?: {
194
- /**
195
- * Define field selection.
196
- *
197
- * ```ts
198
- * graphql: {
199
- * queryField: `
200
- * {
201
- * id
202
- * title
203
- * createdOn
204
- * }
205
- * `,
206
- * }
207
- * ```
208
- */
209
- queryField?: string | ((params: QueryFieldParams) => string | null);
210
- };
211
- render?(params: any): React.ReactElement;
212
- tags?: string[];
213
- /**
214
- * Render additional information in the Admin UI Model edit view
215
- */
216
- renderInfo?: (params: {
217
- field: CmsModelField;
218
- model: CmsModel;
219
- }) => React.ReactElement;
220
- };
221
- }
222
- export interface CmsModelFieldRendererSettingsProps {
223
- field: CmsModelField;
224
- }
225
- export interface CmsModelFieldRendererProps {
226
- field: CmsModelField;
227
- Label: React.ComponentType<React.PropsWithChildren>;
228
- getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;
229
- contentModel: CmsModel;
230
- }
231
- /**
232
- * @deprecated Use `CmsModelFieldRendererProps`.
233
- */
234
- export type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;
235
- /**
236
- * @deprecated Use `CmsModelFieldRendererPlugin`.
237
- */
238
- export type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;
239
- export interface CmsModelFieldRendererPlugin extends Plugin {
240
- /**
241
- * a plugin type
242
- */
243
- type: "cms-editor-field-renderer";
244
- renderer: {
245
- /**
246
- * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.
247
- *
248
- * ```ts
249
- * renderName: "myFieldTypeRenderer"
250
- * ```
251
- */
252
- rendererName: string;
253
- /**
254
- * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.
255
- *
256
- * ```tsx
257
- * name: <MyFieldNameComponent />
258
- * ```
259
- */
260
- name: React.ReactNode;
261
- /**
262
- * A description for the field in the UI. Works exactly like the `name` property.
263
- *
264
- * ```tsx
265
- * name: <MyFieldDescriptionComponent />
266
- * ```
267
- */
268
- description: React.ReactNode;
269
- /**
270
- * A method that determines if the field can be rendered by this plugin.
271
- *
272
- * ```ts
273
- * canUse({ field }) {
274
- * return (
275
- * field.type === "myType" && !field.list
276
- * );
277
- * }
278
- * ```
279
- */
280
- canUse(props: {
281
- field: CmsModelField;
282
- fieldPlugin: CmsModelFieldTypePlugin;
283
- model: CmsModel;
284
- }): boolean;
285
- /**
286
- * Renders a field in the UI.
287
- *
288
- * ```tsx
289
- * render({ field, getBind }) {
290
- * const Bind = getBind();
291
- *
292
- * return (
293
- * <Bind>
294
- * {bind => {
295
- * return (
296
- * <Input
297
- * value={bind.value}
298
- * onChange={bind.onChange}
299
- * />
300
- * )
301
- * }}
302
- * </Bind>
303
- * );
304
- * }
305
- * ```
306
- */
307
- render(props: CmsModelFieldRendererProps): React.ReactNode;
308
- renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;
309
- };
34
+ layoutField?: CmsLayoutField;
310
35
  }
311
36
  export interface CmsEditorFieldPredefinedValuesEntry {
312
37
  label: string;
@@ -324,18 +49,17 @@ export interface CmsDynamicZoneTemplate {
324
49
  description: string;
325
50
  icon: string;
326
51
  fields: CmsModelField[];
327
- layout: string[][];
52
+ layout: CmsEditorFieldsLayout;
328
53
  validation: CmsModelFieldValidator[];
329
54
  tags?: string[];
330
- }
331
- export interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {
332
- __typename: string;
55
+ componentName?: string;
333
56
  }
334
57
  export type CmsContentEntryStatusType = "draft" | "published" | "unpublished";
335
- /**
336
- * @deprecated Use `CmsContentEntry`.
337
- */
338
- export type CmsEditorContentEntry = CmsContentEntry;
58
+ export interface CmsContentEntryLive {
59
+ version: number;
60
+ }
61
+ export interface CmsContentEntrySystem {
62
+ }
339
63
  export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord> {
340
64
  id: string;
341
65
  entryId: string;
@@ -365,6 +89,8 @@ export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord>
365
89
  revisionLastPublishedOn: string | null;
366
90
  revisionLastPublishedBy: CmsIdentity | null;
367
91
  wbyAco_location: Location;
92
+ live: CmsContentEntryLive | null;
93
+ system: CmsContentEntrySystem | null;
368
94
  meta: {
369
95
  title: string;
370
96
  description?: string;
@@ -373,7 +99,8 @@ export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord>
373
99
  status: CmsContentEntryStatusType;
374
100
  version: number;
375
101
  };
376
- values?: TValues;
102
+ revisionDescription?: string;
103
+ values: TValues;
377
104
  }
378
105
  export interface CmsContentEntryRevision {
379
106
  id: string;
@@ -397,6 +124,7 @@ export interface CmsContentEntryRevision {
397
124
  revisionFirstPublishedBy: CmsIdentity | null;
398
125
  revisionLastPublishedBy: CmsIdentity | null;
399
126
  wbyAco_location: Location;
127
+ revisionDescription?: string;
400
128
  meta: {
401
129
  title: string;
402
130
  locked: boolean;
@@ -404,9 +132,6 @@ export interface CmsContentEntryRevision {
404
132
  version: number;
405
133
  };
406
134
  }
407
- export type CmsEditorContentTab = React.ComponentType<{
408
- activeTab: boolean;
409
- }>;
410
135
  export interface CmsEditorFieldOptionPlugin extends Plugin {
411
136
  type: "cms-editor-field-option";
412
137
  render(): ReactElement;
@@ -414,10 +139,6 @@ export interface CmsEditorFieldOptionPlugin extends Plugin {
414
139
  export interface CmsContentDetailsPlugin extends Plugin {
415
140
  render: (params: any) => ReactNode;
416
141
  }
417
- export interface FieldLayoutPosition {
418
- row: number;
419
- index: number | null;
420
- }
421
142
  export interface CmsEditorFormSettingsPlugin<T = GenericRecord> extends Plugin {
422
143
  type: "cms-editor-form-settings";
423
144
  title: string;
@@ -517,6 +238,7 @@ export interface CmsSecurityPermission extends Identity.Permission {
517
238
  rwd?: string;
518
239
  own?: boolean;
519
240
  pw?: string;
241
+ _src?: string;
520
242
  }
521
243
  /**
522
244
  * @category GraphQL
package/types/index.js CHANGED
@@ -1,3 +1 @@
1
- export {};
2
-
3
- //# sourceMappingURL=index.js.map
1
+ export { isLayoutField } from "./model.js";
package/types/model.d.ts CHANGED
@@ -1,23 +1,31 @@
1
+ import type React from "react";
1
2
  import type { Validator } from "@webiny/validation/types.js";
2
- import type { CmsModelFieldValidator } from "../types/validation.js";
3
- import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "../types/index.js";
3
+ import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues } from "../types/index.js";
4
4
  import type { CmsIdentity } from "../types/shared.js";
5
- import type React from "react";
6
- /**
7
- * @deprecated Use `CmsModelField` instead.
8
- */
9
- export type CmsEditorField<T = unknown> = CmsModelField<T>;
5
+ export interface CmsModelFieldValidator {
6
+ name: string;
7
+ message?: string;
8
+ settings?: any;
9
+ }
10
10
  export interface CmsModelFieldSettings<T = unknown> {
11
11
  defaultValue?: string | boolean | number | null | undefined;
12
12
  defaultSetValue?: string;
13
13
  type?: string;
14
14
  fields?: CmsModelField<T>[];
15
- layout?: string[][];
15
+ layout?: CmsEditorFieldsLayout;
16
16
  models?: Pick<CmsModel, "modelId">[];
17
17
  templates?: CmsDynamicZoneTemplate[];
18
18
  imagesOnly?: boolean;
19
19
  [key: string]: any;
20
20
  }
21
+ export type FieldRuleAction = "hide" | "disable" | string;
22
+ export interface FieldRule {
23
+ type: "accessControl" | "condition";
24
+ target: string;
25
+ operator: string;
26
+ value: string | number | boolean | null;
27
+ action: FieldRuleAction;
28
+ }
21
29
  export type CmsModelField<T = unknown> = T & {
22
30
  id: string;
23
31
  type: string;
@@ -36,21 +44,54 @@ export type CmsModelField<T = unknown> = T & {
36
44
  renderer: {
37
45
  name: string;
38
46
  settings?: Record<string, any>;
39
- }
40
- /**
41
- * Use this only for programmatic assignment of renderers.
42
- * Since functions cannot be serialized, this can only work via code.
43
- */
44
- | CmsModelFieldRendererPlugin["renderer"]["render"];
47
+ };
45
48
  tags?: string[];
49
+ rules?: FieldRule[];
46
50
  };
47
51
  export type CmsEditorFieldId = string;
48
- export type CmsEditorFieldsLayout = CmsEditorFieldId[][];
52
+ export interface CmsModelLayoutField {
53
+ id: string;
54
+ type: string;
55
+ rules?: FieldRule[];
56
+ }
57
+ export interface CmsSeparatorLayoutField extends CmsModelLayoutField {
58
+ type: "separator";
59
+ label: string;
60
+ description?: string;
61
+ }
62
+ export interface CmsAlertLayoutField extends CmsModelLayoutField {
63
+ type: "alert";
64
+ label: string;
65
+ alertType: "info" | "success" | "warning" | "danger";
66
+ }
67
+ export interface CmsTabLayoutTab {
68
+ id: string;
69
+ label: string;
70
+ icon?: string;
71
+ layout: CmsEditorFieldsLayout;
72
+ rules?: FieldRule[];
73
+ }
74
+ export interface CmsTabLayoutField extends CmsModelLayoutField {
75
+ type: "tabs";
76
+ label: string;
77
+ description?: string | null;
78
+ help?: string | null;
79
+ tabs: CmsTabLayoutTab[];
80
+ }
81
+ export type CmsLayoutField = CmsSeparatorLayoutField | CmsAlertLayoutField | CmsTabLayoutField | CmsModelLayoutField;
82
+ export type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;
83
+ export type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];
49
84
  /**
50
- * @category GraphQL
51
- * @category Model
85
+ * Distinguish layout fields from field IDs (strings) and CmsModelField objects.
86
+ *
87
+ * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)
88
+ * or layout field objects — the `typeof` check handles that.
89
+ *
90
+ * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`
91
+ * or layout field objects — both have `{ id, type }`, but only `CmsModelField`
92
+ * has `fieldId`, so we use its absence as the discriminator.
52
93
  */
53
- export type CmsEditorContentModel = CmsModel;
94
+ export declare function isLayoutField(cell: unknown): cell is CmsLayoutField;
54
95
  /**
55
96
  * @category GraphQL
56
97
  * @category Group
@@ -96,7 +137,11 @@ export interface CmsModel {
96
137
  * Is model currently being deleted?
97
138
  */
98
139
  isBeingDeleted?: boolean;
140
+ valuesSelection?: string;
99
141
  settings: {
100
142
  [key: string]: any;
101
143
  };
144
+ metadata: {
145
+ valuesSelection: string;
146
+ };
102
147
  }
package/types/model.js CHANGED
@@ -1,3 +1,6 @@
1
- export {};
1
+ function isLayoutField(cell) {
2
+ return "object" == typeof cell && null !== cell && "type" in cell && "string" == typeof cell.type && !("fieldId" in cell);
3
+ }
4
+ export { isLayoutField };
2
5
 
3
6
  //# sourceMappingURL=model.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsModelFieldValidator } from \"~/types/validation.js\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type React from \"react\";\n\n/**\n * @deprecated Use `CmsModelField` instead.\n */\nexport type CmsEditorField<T = unknown> = CmsModelField<T>;\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: string[][];\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n};\n\nexport type CmsEditorFieldId = string;\nexport type CmsEditorFieldsLayout = CmsEditorFieldId[][];\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n settings: {\n [key: string]: any;\n };\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types/model.js","sources":["../../src/types/model.ts"],"sourcesContent":["import type React from \"react\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues } from \"~/types/index.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: CmsEditorFieldsLayout;\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"condition\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n help?: string | React.ReactNode;\n description?: string | React.ReactNode;\n note?: string | React.ReactNode;\n placeholder?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n list?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer: {\n name: string;\n settings?: Record<string, any>;\n };\n tags?: string[];\n rules?: FieldRule[];\n};\n\nexport type CmsEditorFieldId = string;\n\nexport interface CmsModelLayoutField {\n id: string;\n type: string;\n rules?: FieldRule[];\n}\n\nexport interface CmsSeparatorLayoutField extends CmsModelLayoutField {\n type: \"separator\";\n label: string;\n description?: string;\n}\n\nexport interface CmsAlertLayoutField extends CmsModelLayoutField {\n type: \"alert\";\n label: string;\n alertType: \"info\" | \"success\" | \"warning\" | \"danger\";\n}\n\nexport interface CmsTabLayoutTab {\n id: string;\n label: string;\n icon?: string;\n layout: CmsEditorFieldsLayout;\n rules?: FieldRule[];\n}\n\nexport interface CmsTabLayoutField extends CmsModelLayoutField {\n type: \"tabs\";\n label: string;\n description?: string | null;\n help?: string | null;\n tabs: CmsTabLayoutTab[];\n}\n\nexport type CmsLayoutField =\n | CmsSeparatorLayoutField\n | CmsAlertLayoutField\n | CmsTabLayoutField\n | CmsModelLayoutField;\n\nexport type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutField;\nexport type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];\n\n/**\n * Distinguish layout fields from field IDs (strings) and CmsModelField objects.\n *\n * In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)\n * or layout field objects — the `typeof` check handles that.\n *\n * In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`\n * or layout field objects — both have `{ id, type }`, but only `CmsModelField`\n * has `fieldId`, so we use its absence as the discriminator.\n */\nexport function isLayoutField(cell: unknown): cell is CmsLayoutField {\n return (\n typeof cell === \"object\" &&\n cell !== null &&\n \"type\" in cell &&\n typeof (cell as any).type === \"string\" &&\n !(\"fieldId\" in cell)\n );\n}\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: string;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n /**\n * Is model currently being deleted?\n */\n isBeingDeleted?: boolean;\n valuesSelection?: string;\n settings: {\n [key: string]: any;\n };\n metadata: {\n valuesSelection: string;\n };\n}\n"],"names":["isLayoutField","cell"],"mappings":"AA+GO,SAASA,cAAcC,IAAa;IACvC,OACI,AAAgB,YAAhB,OAAOA,QACPA,AAAS,SAATA,QACA,UAAUA,QACV,AAA8B,YAA9B,OAAQA,KAAa,IAAI,IACzB,CAAE,cAAaA,IAAG;AAE1B"}
package/types/shared.d.ts CHANGED
@@ -1,5 +1,11 @@
1
+ import type { IconPickerIconDto } from "@webiny/admin-ui";
2
+ import type { Plugin } from "@webiny/plugins/types.js";
1
3
  export interface CmsIdentity {
2
4
  id: string;
3
5
  displayName: string;
4
6
  type: string;
5
7
  }
8
+ export interface CmsIconsPlugin extends Plugin {
9
+ type: "cms-icons";
10
+ getIcons(): IconPickerIconDto[];
11
+ }