@webiny/api-headless-cms 6.0.0-rc.2 → 6.0.0-rc.4

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 (96) hide show
  1. package/crud/contentEntry/searchableFields.js +6 -2
  2. package/crud/contentEntry/searchableFields.js.map +1 -1
  3. package/crud/contentModel/validation.d.ts +9 -9
  4. package/crud/contentModel/validation.js +3 -3
  5. package/crud/contentModel/validation.js.map +1 -1
  6. package/domain/contentModel/errors.d.ts +1 -1
  7. package/domain/contentModel/errors.js.map +1 -1
  8. package/domain/contentModel/schemas.d.ts +126 -8
  9. package/domain/contentModel/schemas.js +12 -13
  10. package/domain/contentModel/schemas.js.map +1 -1
  11. package/export/graphql/index.js +1 -1
  12. package/export/graphql/index.js.map +1 -1
  13. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.d.ts +2 -2
  14. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js +3 -4
  15. package/features/contentEntry/GetUniqueFieldValues/GetUniqueFieldValuesUseCase.js.map +1 -1
  16. package/features/contentModel/CreateModel/CreateModelRepository.js +4 -1
  17. package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
  18. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +12 -3
  19. package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
  20. package/features/contentModel/UpdateModel/UpdateModelRepository.js +8 -2
  21. package/features/contentModel/UpdateModel/UpdateModelRepository.js.map +1 -1
  22. package/features/contentModel/UpdateModel/UpdateModelUseCase.js +4 -1
  23. package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
  24. package/features/modelBuilder/feature.js +2 -2
  25. package/features/modelBuilder/feature.js.map +1 -1
  26. package/features/modelBuilder/fields/BaseFieldBuilder.d.ts +36 -0
  27. package/features/modelBuilder/fields/BaseFieldBuilder.js +41 -0
  28. package/features/modelBuilder/fields/BaseFieldBuilder.js.map +1 -0
  29. package/features/modelBuilder/fields/DataFieldBuilder.d.ts +228 -0
  30. package/features/modelBuilder/fields/DataFieldBuilder.js +219 -0
  31. package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -0
  32. package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +2 -2
  33. package/features/modelBuilder/fields/DynamicZoneFieldType.js +6 -3
  34. package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
  35. package/features/modelBuilder/fields/FieldBuilder.d.ts +5 -228
  36. package/features/modelBuilder/fields/FieldBuilder.js +3 -231
  37. package/features/modelBuilder/fields/FieldBuilder.js.map +1 -1
  38. package/features/modelBuilder/fields/LayoutFieldBuilder.d.ts +7 -0
  39. package/features/modelBuilder/fields/LayoutFieldBuilder.js +9 -0
  40. package/features/modelBuilder/fields/LayoutFieldBuilder.js.map +1 -0
  41. package/features/modelBuilder/fields/ObjectFieldType.d.ts +4 -3
  42. package/features/modelBuilder/fields/ObjectFieldType.js +19 -4
  43. package/features/modelBuilder/fields/ObjectFieldType.js.map +1 -1
  44. package/features/modelBuilder/fields/UiAlertFieldType.d.ts +8 -4
  45. package/features/modelBuilder/fields/UiAlertFieldType.js +23 -6
  46. package/features/modelBuilder/fields/UiAlertFieldType.js.map +1 -1
  47. package/features/modelBuilder/fields/UiSeparatorFieldType.d.ts +6 -4
  48. package/features/modelBuilder/fields/UiSeparatorFieldType.js +18 -4
  49. package/features/modelBuilder/fields/UiSeparatorFieldType.js.map +1 -1
  50. package/features/modelBuilder/fields/UiTabsFieldType.d.ts +28 -0
  51. package/features/modelBuilder/fields/UiTabsFieldType.js +75 -0
  52. package/features/modelBuilder/fields/UiTabsFieldType.js.map +1 -0
  53. package/features/modelBuilder/fields/abstractions.d.ts +2 -2
  54. package/features/modelBuilder/fields/abstractions.js.map +1 -1
  55. package/features/modelBuilder/index.d.ts +2 -0
  56. package/features/modelBuilder/index.js +2 -0
  57. package/features/modelBuilder/index.js.map +1 -1
  58. package/features/modelBuilder/models/BaseModelBuilder.d.ts +8 -3
  59. package/features/modelBuilder/models/BaseModelBuilder.js +19 -0
  60. package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
  61. package/features/modelBuilder/models/PrivateModelBuilder.js +4 -2
  62. package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
  63. package/features/modelBuilder/models/PublicModelBuilder.js +16 -11
  64. package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
  65. package/graphql/schema/cms/helpers/index.d.ts +1 -0
  66. package/graphql/schema/cms/helpers/index.js +1 -0
  67. package/graphql/schema/cms/helpers/index.js.map +1 -1
  68. package/graphql/schema/cms/helpers/transformWhereToNested.d.ts +17 -0
  69. package/graphql/schema/cms/helpers/transformWhereToNested.js +54 -0
  70. package/graphql/schema/cms/helpers/transformWhereToNested.js.map +1 -0
  71. package/graphql/schema/cms/helpers.d.ts +1 -0
  72. package/graphql/schema/cms/helpers.js +1 -0
  73. package/graphql/schema/cms/helpers.js.map +1 -1
  74. package/graphql/schema/cms/listEntriesResolver.js +6 -2
  75. package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
  76. package/graphql/schema/contentModels.js +21 -3
  77. package/graphql/schema/contentModels.js.map +1 -1
  78. package/graphqlFields/index.js +1 -2
  79. package/graphqlFields/index.js.map +1 -1
  80. package/package.json +20 -20
  81. package/plugins/CmsModelPlugin.js +19 -4
  82. package/plugins/CmsModelPlugin.js.map +1 -1
  83. package/types/fields/objectField.d.ts +2 -0
  84. package/types/fields/objectField.js.map +1 -1
  85. package/types/model.d.ts +32 -3
  86. package/types/model.js.map +1 -1
  87. package/types/modelField.d.ts +19 -3
  88. package/types/modelField.js.map +1 -1
  89. package/utils/createModelField.js +4 -2
  90. package/utils/createModelField.js.map +1 -1
  91. package/features/modelBuilder/fields/UiFieldType.d.ts +0 -18
  92. package/features/modelBuilder/fields/UiFieldType.js +0 -25
  93. package/features/modelBuilder/fields/UiFieldType.js.map +0 -1
  94. package/graphqlFields/ui.d.ts +0 -2
  95. package/graphqlFields/ui.js +0 -32
  96. package/graphqlFields/ui.js.map +0 -1
@@ -1,6 +1,14 @@
1
- import type { CmsModel } from "./model.js";
1
+ import type { CmsModel, CmsModelLayout } from "./model.js";
2
2
  import type { GenericRecord } from "@webiny/api/types.js";
3
3
  import type { CmsDynamicZoneTemplate } from "../types/fields/dynamicZoneField.js";
4
+ export type FieldRuleAction = "hide" | "disable" | string;
5
+ export interface FieldRule {
6
+ type: "accessControl" | "entryValue";
7
+ target: string;
8
+ operator: string;
9
+ value: string | number | boolean | null;
10
+ action: FieldRuleAction;
11
+ }
4
12
  export type CmsModelFieldType = "boolean" | "datetime" | "file" | "long-text" | "number" | "json" | "object" | "ref" | "rich-text" | "text" | "dynamicZone" | string;
5
13
  export type ICmsModelFieldStorageId = `${string}@${string}` | string;
6
14
  /**
@@ -99,6 +107,10 @@ export interface CmsModelField {
99
107
  * @default {}
100
108
  */
101
109
  settings?: CmsModelFieldSettings;
110
+ /**
111
+ * Rules that control field visibility and editability (access control and entry value conditions).
112
+ */
113
+ rules?: FieldRule[];
102
114
  }
103
115
  /**
104
116
  * A definition for content model field received from the user.
@@ -173,6 +185,10 @@ export interface CmsModelFieldInput {
173
185
  settings?: {
174
186
  [key: string]: any;
175
187
  };
188
+ /**
189
+ * Rules that control field visibility and editability (access control and entry value conditions).
190
+ */
191
+ rules?: FieldRule[];
176
192
  }
177
193
  /**
178
194
  * A GraphQL `params.data` parameter received when updating content model.
@@ -215,7 +231,7 @@ export interface CmsModelUpdateInput {
215
231
  * ]
216
232
  * ```
217
233
  */
218
- layout: string[][];
234
+ layout: CmsModelLayout;
219
235
  /**
220
236
  * Tags for the content model.
221
237
  */
@@ -266,7 +282,7 @@ export interface CmsModelFieldSettings {
266
282
  /**
267
283
  * Object field has child fields - so it needs to have a layout.
268
284
  */
269
- layout?: string[][];
285
+ layout?: CmsModelLayout;
270
286
  /**
271
287
  * Ref field.
272
288
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import type { CmsModel } from \"./model.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsDynamicZoneTemplate } from \"~/types/fields/dynamicZoneField.js\";\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\nexport type ICmsModelFieldStorageId = `${string}@${string}` | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: ICmsModelFieldStorageId;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n list?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n list?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field.\n */\n validation: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: {\n [key: string]: any;\n };\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Tags for the content model.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n /**\n * Renderer settings allow you to configure field renderer on a field level.\n */\n settings?: GenericRecord<string> | null;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | boolean | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: string[][];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * Disable full text search explicitly on this field.\n */\n disableFullTextSearch?: boolean;\n /**\n * Dynamic zone field templates.\n */\n templates?: CmsDynamicZoneTemplate[];\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import type { CmsModel, CmsModelLayout } from \"./model.js\";\nimport type { GenericRecord } from \"@webiny/api/types.js\";\nimport type { CmsDynamicZoneTemplate } from \"~/types/fields/dynamicZoneField.js\";\n\nexport type FieldRuleAction = \"hide\" | \"disable\" | string;\n\nexport interface FieldRule {\n type: \"accessControl\" | \"entryValue\";\n target: string;\n operator: string;\n value: string | number | boolean | null;\n action: FieldRuleAction;\n}\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\nexport type ICmsModelFieldStorageId = `${string}@${string}` | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: ICmsModelFieldStorageId;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n list?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n /**\n * Rules that control field visibility and editability (access control and entry value conditions).\n */\n rules?: FieldRule[];\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Field description right below the label.\n */\n description?: string | null;\n /**\n * Note displayed below the input.\n */\n note?: string | null;\n /**\n * Text in the tooltip next to the input label.\n */\n help?: string | null;\n /**\n * Placeholder text to be displayed in the field\n */\n placeholder?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n list?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field.\n */\n validation: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: {\n [key: string]: any;\n };\n /**\n * Rules that control field visibility and editability (access control and entry value conditions).\n */\n rules?: FieldRule[];\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: CmsModelLayout;\n /**\n * Tags for the content model.\n */\n tags?: string[];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n /**\n * Renderer settings allow you to configure field renderer on a field level.\n */\n settings?: GenericRecord<string> | null;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | boolean | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: CmsModelLayout;\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * Disable full text search explicitly on this field.\n */\n disableFullTextSearch?: boolean;\n /**\n * Dynamic zone field templates.\n */\n templates?: CmsDynamicZoneTemplate[];\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -19,7 +19,8 @@ export const createModelField = params => {
19
19
  },
20
20
  help = null,
21
21
  placeholder = null,
22
- renderer = null
22
+ renderer = null,
23
+ rules = []
23
24
  } = params;
24
25
 
25
26
  // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.
@@ -39,7 +40,8 @@ export const createModelField = params => {
39
40
  predefinedValues,
40
41
  help,
41
42
  placeholder,
42
- renderer
43
+ renderer,
44
+ rules
43
45
  };
44
46
  };
45
47
 
@@ -1 +1 @@
1
- {"version":3,"names":["camelCase","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","list","predefinedValues","values","enabled","help","placeholder","renderer"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport type { CmsModelField, CmsModelFieldValidation } from \"~/types/index.js\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"validation\" | \"listValidation\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n validation?: CmsModelFieldValidation[];\n listValidation?: CmsModelFieldValidation[];\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags = [],\n settings = {},\n listValidation = [],\n validation = [],\n list = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n help = null,\n placeholder = null,\n renderer = null\n } = params;\n\n // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.\n // TODO: Once this legacy field is removed, we can enable camelCase on the initialFieldId.\n const fieldId = initialFieldId ? initialFieldId : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${id ?? fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n list,\n predefinedValues,\n help,\n placeholder,\n renderer\n };\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,qBAAqB;AAY3C,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI,GAAG,EAAE;IACTC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,IAAI,GAAG,KAAK;IACZC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,IAAI,GAAG,IAAI;IACXC,WAAW,GAAG,IAAI;IAClBC,QAAQ,GAAG;EACf,CAAC,GAAGjB,MAAM;;EAEV;EACA;EACA,MAAMG,OAAO,GAAGC,cAAc,GAAGA,cAAc,GAAGN,SAAS,CAACI,KAAK,CAAC;EAElE,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIL,EAAE,IAAIE,OAAO,EAAE;IAClDA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,IAAI;IACJC,gBAAgB;IAChBG,IAAI;IACJC,WAAW;IACXC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["camelCase","createModelField","params","id","label","fieldId","initialFieldId","storageId","type","tags","settings","listValidation","validation","list","predefinedValues","values","enabled","help","placeholder","renderer","rules"],"sources":["createModelField.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase.js\";\nimport type { CmsModelField, CmsModelFieldValidation } from \"~/types/index.js\";\n\nexport interface CreateModelFieldParams\n extends Omit<CmsModelField, \"id\" | \"storageId\" | \"fieldId\" | \"validation\" | \"listValidation\"> {\n id?: string;\n fieldId?: string;\n storageId?: string;\n validation?: CmsModelFieldValidation[];\n listValidation?: CmsModelFieldValidation[];\n}\n\nexport const createModelField = (params: CreateModelFieldParams): CmsModelField => {\n // We are not just spreading `params` because we want to ensure\n // a default value is set for every property of the model field.\n const {\n id,\n label,\n fieldId: initialFieldId,\n storageId,\n type,\n tags = [],\n settings = {},\n listValidation = [],\n validation = [],\n list = false,\n predefinedValues = {\n values: [],\n enabled: false\n },\n help = null,\n placeholder = null,\n renderer = null,\n rules = []\n } = params;\n\n // TODO: ideally, initialFieldId should also be passed through `camelCase` but currently this would break `wbyAco_location` field.\n // TODO: Once this legacy field is removed, we can enable camelCase on the initialFieldId.\n const fieldId = initialFieldId ? initialFieldId : camelCase(label);\n\n return {\n id: id ?? fieldId,\n storageId: storageId ?? `${type}@${id ?? fieldId}`,\n fieldId,\n label,\n type,\n settings,\n tags,\n listValidation,\n validation,\n list,\n predefinedValues,\n help,\n placeholder,\n renderer,\n rules\n };\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,qBAAqB;AAY3C,OAAO,MAAMC,gBAAgB,GAAIC,MAA8B,IAAoB;EAC/E;EACA;EACA,MAAM;IACFC,EAAE;IACFC,KAAK;IACLC,OAAO,EAAEC,cAAc;IACvBC,SAAS;IACTC,IAAI;IACJC,IAAI,GAAG,EAAE;IACTC,QAAQ,GAAG,CAAC,CAAC;IACbC,cAAc,GAAG,EAAE;IACnBC,UAAU,GAAG,EAAE;IACfC,IAAI,GAAG,KAAK;IACZC,gBAAgB,GAAG;MACfC,MAAM,EAAE,EAAE;MACVC,OAAO,EAAE;IACb,CAAC;IACDC,IAAI,GAAG,IAAI;IACXC,WAAW,GAAG,IAAI;IAClBC,QAAQ,GAAG,IAAI;IACfC,KAAK,GAAG;EACZ,CAAC,GAAGlB,MAAM;;EAEV;EACA;EACA,MAAMG,OAAO,GAAGC,cAAc,GAAGA,cAAc,GAAGN,SAAS,CAACI,KAAK,CAAC;EAElE,OAAO;IACHD,EAAE,EAAEA,EAAE,IAAIE,OAAO;IACjBE,SAAS,EAAEA,SAAS,IAAI,GAAGC,IAAI,IAAIL,EAAE,IAAIE,OAAO,EAAE;IAClDA,OAAO;IACPD,KAAK;IACLI,IAAI;IACJE,QAAQ;IACRD,IAAI;IACJE,cAAc;IACdC,UAAU;IACVC,IAAI;IACJC,gBAAgB;IAChBG,IAAI;IACJC,WAAW;IACXC,QAAQ;IACRC;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -1,18 +0,0 @@
1
- import { FieldBuilder } from "./FieldBuilder.js";
2
- import { type IFieldTypeFactory } from "./abstractions.js";
3
- export interface IUiFieldBuilder extends FieldBuilder<"ui" | `ui:${string}`> {
4
- }
5
- declare module "../abstractions.js" {
6
- interface IFieldBuilderRegistry {
7
- ui(): IUiFieldBuilder;
8
- }
9
- }
10
- export declare class UiFieldBuilder extends FieldBuilder<"ui" | `ui:${string}`> implements IUiFieldBuilder {
11
- constructor(subtype?: string);
12
- }
13
- declare class UiFieldTypeFactory implements IFieldTypeFactory {
14
- readonly type = "ui";
15
- create(): IUiFieldBuilder;
16
- }
17
- export declare const UiFieldType: import("@webiny/di").Implementation<typeof UiFieldTypeFactory>;
18
- export {};
@@ -1,25 +0,0 @@
1
- import { createImplementation } from "@webiny/feature/api";
2
- import { FieldBuilder } from "./FieldBuilder.js";
3
- import { FieldType } from "./abstractions.js";
4
-
5
- // Module augmentation for TypeScript autocomplete
6
-
7
- export class UiFieldBuilder extends FieldBuilder {
8
- constructor(subtype) {
9
- const type = subtype ? `ui:${subtype}` : "ui";
10
- super(type);
11
- }
12
- }
13
- class UiFieldTypeFactory {
14
- type = "ui";
15
- create() {
16
- return new UiFieldBuilder();
17
- }
18
- }
19
- export const UiFieldType = createImplementation({
20
- abstraction: FieldType,
21
- implementation: UiFieldTypeFactory,
22
- dependencies: []
23
- });
24
-
25
- //# sourceMappingURL=UiFieldType.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createImplementation","FieldBuilder","FieldType","UiFieldBuilder","constructor","subtype","type","UiFieldTypeFactory","create","UiFieldType","abstraction","implementation","dependencies"],"sources":["UiFieldType.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/feature/api\";\nimport { FieldBuilder } from \"./FieldBuilder.js\";\nimport { FieldType, type IFieldTypeFactory } from \"./abstractions.js\";\n\nexport interface IUiFieldBuilder extends FieldBuilder<\"ui\" | `ui:${string}`> {}\n\n// Module augmentation for TypeScript autocomplete\ndeclare module \"../abstractions.js\" {\n interface IFieldBuilderRegistry {\n ui(): IUiFieldBuilder;\n }\n}\n\nexport class UiFieldBuilder extends FieldBuilder<\"ui\" | `ui:${string}`> implements IUiFieldBuilder {\n public constructor(subtype?: string) {\n const type = (subtype ? `ui:${subtype}` : \"ui\") as \"ui\" | `ui:${string}`;\n super(type);\n }\n}\n\nclass UiFieldTypeFactory implements IFieldTypeFactory {\n public readonly type = \"ui\";\n\n public create(): IUiFieldBuilder {\n return new UiFieldBuilder();\n }\n}\n\nexport const UiFieldType = createImplementation({\n abstraction: FieldType,\n implementation: UiFieldTypeFactory,\n dependencies: []\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,qBAAqB;AAC1D,SAASC,YAAY;AACrB,SAASC,SAAS;;AAIlB;;AAOA,OAAO,MAAMC,cAAc,SAASF,YAAY,CAAmD;EACxFG,WAAWA,CAACC,OAAgB,EAAE;IACjC,MAAMC,IAAI,GAAID,OAAO,GAAG,MAAMA,OAAO,EAAE,GAAG,IAA8B;IACxE,KAAK,CAACC,IAAI,CAAC;EACf;AACJ;AAEA,MAAMC,kBAAkB,CAA8B;EAClCD,IAAI,GAAG,IAAI;EAEpBE,MAAMA,CAAA,EAAoB;IAC7B,OAAO,IAAIL,cAAc,CAAC,CAAC;EAC/B;AACJ;AAEA,OAAO,MAAMM,WAAW,GAAGT,oBAAoB,CAAC;EAC5CU,WAAW,EAAER,SAAS;EACtBS,cAAc,EAAEJ,kBAAkB;EAClCK,YAAY,EAAE;AAClB,CAAC,CAAC","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- import type { CmsModelFieldToGraphQLPlugin } from "../types/index.js";
2
- export declare const createUiField: () => CmsModelFieldToGraphQLPlugin;
@@ -1,32 +0,0 @@
1
- import { createGraphQLInputField } from "./helpers.js";
2
- export const createUiField = () => {
3
- return {
4
- name: "cms-model-field-to-graphql-ui",
5
- type: "cms-model-field-to-graphql",
6
- fieldType: "ui",
7
- isSortable: false,
8
- isSearchable: false,
9
- fullTextSearch: false,
10
- read: {
11
- createTypeField({
12
- field
13
- }) {
14
- return `${field.fieldId}: String`;
15
- }
16
- },
17
- manage: {
18
- createTypeField({
19
- field
20
- }) {
21
- return `${field.fieldId}: String`;
22
- },
23
- createInputField({
24
- field
25
- }) {
26
- return createGraphQLInputField(field, "String");
27
- }
28
- }
29
- };
30
- };
31
-
32
- //# sourceMappingURL=ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createGraphQLInputField","createUiField","name","type","fieldType","isSortable","isSearchable","fullTextSearch","read","createTypeField","field","fieldId","manage","createInputField"],"sources":["ui.ts"],"sourcesContent":["import type { CmsModelFieldToGraphQLPlugin } from \"~/types/index.js\";\nimport { createGraphQLInputField } from \"~/graphqlFields/helpers.js\";\n\nexport const createUiField = (): CmsModelFieldToGraphQLPlugin => {\n return {\n name: \"cms-model-field-to-graphql-ui\",\n type: \"cms-model-field-to-graphql\",\n fieldType: \"ui\",\n isSortable: false,\n isSearchable: false,\n fullTextSearch: false,\n read: {\n createTypeField({ field }) {\n return `${field.fieldId}: String`;\n }\n },\n manage: {\n createTypeField({ field }) {\n return `${field.fieldId}: String`;\n },\n createInputField({ field }) {\n return createGraphQLInputField(field, \"String\");\n }\n }\n };\n};\n"],"mappings":"AACA,SAASA,uBAAuB;AAEhC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAoC;EAC7D,OAAO;IACHC,IAAI,EAAE,+BAA+B;IACrCC,IAAI,EAAE,4BAA4B;IAClCC,SAAS,EAAE,IAAI;IACfC,UAAU,EAAE,KAAK;IACjBC,YAAY,EAAE,KAAK;IACnBC,cAAc,EAAE,KAAK;IACrBC,IAAI,EAAE;MACFC,eAAeA,CAAC;QAAEC;MAAM,CAAC,EAAE;QACvB,OAAO,GAAGA,KAAK,CAACC,OAAO,UAAU;MACrC;IACJ,CAAC;IACDC,MAAM,EAAE;MACJH,eAAeA,CAAC;QAAEC;MAAM,CAAC,EAAE;QACvB,OAAO,GAAGA,KAAK,CAACC,OAAO,UAAU;MACrC,CAAC;MACDE,gBAAgBA,CAAC;QAAEH;MAAM,CAAC,EAAE;QACxB,OAAOV,uBAAuB,CAACU,KAAK,EAAE,QAAQ,CAAC;MACnD;IACJ;EACJ,CAAC;AACL,CAAC","ignoreList":[]}