@webiny/app-headless-cms-common 6.4.5 → 6.6.0-alpha.0

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 (103) hide show
  1. package/index.d.ts +1 -10
  2. package/index.js +1 -10
  3. package/package.json +10 -17
  4. package/types/index.d.ts +5 -338
  5. package/types/index.js +1 -1
  6. package/types/model.d.ts +9 -18
  7. package/types/model.js +1 -2
  8. package/types/model.js.map +1 -1
  9. package/types/shared.d.ts +6 -0
  10. package/Fields/ErrorBoundary.d.ts +0 -24
  11. package/Fields/ErrorBoundary.js +0 -35
  12. package/Fields/ErrorBoundary.js.map +0 -1
  13. package/Fields/FieldElement.d.ts +0 -64
  14. package/Fields/FieldElement.js +0 -54
  15. package/Fields/FieldElement.js.map +0 -1
  16. package/Fields/FieldElementError.d.ts +0 -7
  17. package/Fields/FieldElementError.js +0 -16
  18. package/Fields/FieldElementError.js.map +0 -1
  19. package/Fields/FieldRulesProvider.d.ts +0 -9
  20. package/Fields/FieldRulesProvider.js +0 -14
  21. package/Fields/FieldRulesProvider.js.map +0 -1
  22. package/Fields/Fields.d.ts +0 -11
  23. package/Fields/Fields.js +0 -93
  24. package/Fields/Fields.js.map +0 -1
  25. package/Fields/Label.d.ts +0 -6
  26. package/Fields/Label.js +0 -10
  27. package/Fields/Label.js.map +0 -1
  28. package/Fields/LayoutDescriptorCell.d.ts +0 -12
  29. package/Fields/LayoutDescriptorCell.js +0 -40
  30. package/Fields/LayoutDescriptorCell.js.map +0 -1
  31. package/Fields/evaluateExpression.d.ts +0 -23
  32. package/Fields/evaluateExpression.js +0 -66
  33. package/Fields/evaluateExpression.js.map +0 -1
  34. package/Fields/fieldOptions.d.ts +0 -36
  35. package/Fields/fieldOptions.js +0 -65
  36. package/Fields/fieldOptions.js.map +0 -1
  37. package/Fields/index.d.ts +0 -8
  38. package/Fields/index.js +0 -8
  39. package/Fields/layoutFieldRenderers/AlertFieldRenderer.d.ts +0 -7
  40. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js +0 -10
  41. package/Fields/layoutFieldRenderers/AlertFieldRenderer.js.map +0 -1
  42. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.d.ts +0 -7
  43. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js +0 -15
  44. package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js.map +0 -1
  45. package/Fields/layoutFieldRenderers/TabsFieldRenderer.d.ts +0 -12
  46. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js +0 -61
  47. package/Fields/layoutFieldRenderers/TabsFieldRenderer.js.map +0 -1
  48. package/Fields/operatorOptions.d.ts +0 -10
  49. package/Fields/operatorOptions.js +0 -120
  50. package/Fields/operatorOptions.js.map +0 -1
  51. package/Fields/useBind.d.ts +0 -10
  52. package/Fields/useBind.js +0 -111
  53. package/Fields/useBind.js.map +0 -1
  54. package/Fields/useFieldRules.d.ts +0 -32
  55. package/Fields/useFieldRules.js +0 -99
  56. package/Fields/useFieldRules.js.map +0 -1
  57. package/Fields/useRenderPlugins.d.ts +0 -2
  58. package/Fields/useRenderPlugins.js +0 -8
  59. package/Fields/useRenderPlugins.js.map +0 -1
  60. package/ModelFieldProvider/CanEditField.d.ts +0 -5
  61. package/ModelFieldProvider/CanEditField.js +0 -10
  62. package/ModelFieldProvider/CanEditField.js.map +0 -1
  63. package/ModelFieldProvider/ModelFieldContext.d.ts +0 -39
  64. package/ModelFieldProvider/ModelFieldContext.js +0 -19
  65. package/ModelFieldProvider/ModelFieldContext.js.map +0 -1
  66. package/ModelFieldProvider/index.d.ts +0 -3
  67. package/ModelFieldProvider/index.js +0 -3
  68. package/ModelFieldProvider/useModelField.d.ts +0 -15
  69. package/ModelFieldProvider/useModelField.js +0 -23
  70. package/ModelFieldProvider/useModelField.js.map +0 -1
  71. package/ModelProvider/ModelContext.d.ts +0 -9
  72. package/ModelProvider/ModelContext.js +0 -14
  73. package/ModelProvider/ModelContext.js.map +0 -1
  74. package/ModelProvider/index.d.ts +0 -2
  75. package/ModelProvider/index.js +0 -2
  76. package/ModelProvider/useModel.d.ts +0 -9
  77. package/ModelProvider/useModel.js +0 -12
  78. package/ModelProvider/useModel.js.map +0 -1
  79. package/createFieldsList.d.ts +0 -12
  80. package/createFieldsList.js +0 -31
  81. package/createFieldsList.js.map +0 -1
  82. package/createValidationContainer.d.ts +0 -18
  83. package/createValidationContainer.js +0 -16
  84. package/createValidationContainer.js.map +0 -1
  85. package/createValidators.d.ts +0 -3
  86. package/createValidators.js +0 -47
  87. package/createValidators.js.map +0 -1
  88. package/entries.graphql.d.ts +0 -229
  89. package/entries.graphql.js +0 -335
  90. package/entries.graphql.js.map +0 -1
  91. package/exports/admin/cms/model.d.ts +0 -1
  92. package/exports/admin/cms/model.js +0 -1
  93. package/getModelTitleFieldId.d.ts +0 -2
  94. package/getModelTitleFieldId.js +0 -7
  95. package/getModelTitleFieldId.js.map +0 -1
  96. package/normalizeIcon.d.ts +0 -3
  97. package/normalizeIcon.js +0 -11
  98. package/normalizeIcon.js.map +0 -1
  99. package/prepareFormData.d.ts +0 -2
  100. package/prepareFormData.js +0 -49
  101. package/prepareFormData.js.map +0 -1
  102. package/types/validation.d.ts +0 -79
  103. package/types/validation.js +0 -0
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- export interface CanEditFieldProps {
3
- children: React.ReactNode;
4
- }
5
- export declare const CanEditField: ({ children }: CanEditFieldProps) => React.JSX.Element | null;
@@ -1,10 +0,0 @@
1
- import react from "react";
2
- import { useParentRules } from "../Fields/index.js";
3
- const CanEditField = ({ children })=>{
4
- const rules = useParentRules();
5
- if (!rules.canEdit || rules.disabled) return null;
6
- return /*#__PURE__*/ react.createElement(react.Fragment, null, children);
7
- };
8
- export { CanEditField };
9
-
10
- //# sourceMappingURL=CanEditField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelFieldProvider/CanEditField.js","sources":["../../src/ModelFieldProvider/CanEditField.tsx"],"sourcesContent":["import React from \"react\";\nimport { useParentRules } from \"~/Fields/index.js\";\n\nexport interface CanEditFieldProps {\n children: React.ReactNode;\n}\n\nexport const CanEditField = ({ children }: CanEditFieldProps) => {\n const rules = useParentRules();\n\n if (!rules.canEdit || rules.disabled) {\n return null;\n }\n\n return <>{children}</>;\n};\n"],"names":["CanEditField","children","rules","useParentRules"],"mappings":";;AAOO,MAAMA,eAAe,CAAC,EAAEC,QAAQ,EAAqB;IACxD,MAAMC,QAAQC;IAEd,IAAI,CAACD,MAAM,OAAO,IAAIA,MAAM,QAAQ,EAChC,OAAO;IAGX,OAAO,WAAP,GAAO,0CAAGD;AACd"}
@@ -1,39 +0,0 @@
1
- import React from "react";
2
- import type { CmsModelField } from "../types/index.js";
3
- export type ModelFieldContext = CmsModelField;
4
- export declare const ModelFieldContext: React.Context<{
5
- id: string;
6
- type: string;
7
- fieldId: import("~/types/index.js").CmsEditorFieldId;
8
- storageId?: string;
9
- label: string;
10
- help?: string | React.ReactNode;
11
- description?: string | React.ReactNode;
12
- note?: string | React.ReactNode;
13
- placeholder?: string;
14
- validation?: (import("~/types/index.js").CmsModelFieldValidator | import("@webiny/validation/types").Validator)[];
15
- listValidation?: import("~/types/index.js").CmsModelFieldValidator[];
16
- list?: boolean;
17
- predefinedValues?: import("~/types/index.js").CmsEditorFieldPredefinedValues;
18
- settings?: import("~/types/index.js").CmsModelFieldSettings<unknown> | undefined;
19
- renderer: {
20
- name: string;
21
- settings?: Record<string, any>;
22
- } | import("~/types/index.js").CmsModelFieldRendererPlugin["renderer"]["render"];
23
- tags?: string[];
24
- rules?: import("~/types/index.js").FieldRule[];
25
- } | undefined>;
26
- export interface ModelFieldProviderProps {
27
- field: CmsModelField;
28
- children: React.ReactNode;
29
- }
30
- export declare const ModelFieldProvider: ({ field, children }: ModelFieldProviderProps) => React.JSX.Element;
31
- export declare const ParentValueIndexProvider: {
32
- ({ children, ...props }: {
33
- index: number;
34
- } & {
35
- children: React.ReactNode;
36
- }): React.JSX.Element;
37
- displayName: string;
38
- };
39
- export declare const useParentValueIndex: () => number;
@@ -1,19 +0,0 @@
1
- import react from "react";
2
- import { createGenericContext } from "@webiny/app-admin";
3
- const ModelFieldContext = /*#__PURE__*/ react.createContext(void 0);
4
- const ModelFieldProvider = ({ field, children })=>/*#__PURE__*/ react.createElement(ModelFieldContext.Provider, {
5
- value: field
6
- }, children);
7
- const { Provider: Provider, useHook: useHook } = createGenericContext("FieldIndex");
8
- const ParentValueIndexProvider = Provider;
9
- const useParentValueIndex = ()=>{
10
- try {
11
- const context = useHook();
12
- return context.index;
13
- } catch {
14
- return -1;
15
- }
16
- };
17
- export { ModelFieldContext, ModelFieldProvider, ParentValueIndexProvider, useParentValueIndex };
18
-
19
- //# sourceMappingURL=ModelFieldContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelFieldProvider/ModelFieldContext.js","sources":["../../src/ModelFieldProvider/ModelFieldContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModelField } from \"~/types/index.js\";\nimport { createGenericContext } from \"@webiny/app-admin\";\n\nexport type ModelFieldContext = CmsModelField;\n\nexport const ModelFieldContext = React.createContext<ModelFieldContext | undefined>(undefined);\n\nexport interface ModelFieldProviderProps {\n field: CmsModelField;\n children: React.ReactNode;\n}\n\nexport const ModelFieldProvider = ({ field, children }: ModelFieldProviderProps) => {\n return <ModelFieldContext.Provider value={field}>{children}</ModelFieldContext.Provider>;\n};\n\nconst { Provider, useHook } = createGenericContext<{ index: number }>(\"FieldIndex\");\n\nexport const ParentValueIndexProvider = Provider;\n\nexport const useParentValueIndex = () => {\n try {\n const context = useHook();\n return context.index;\n } catch {\n return -1;\n }\n};\n"],"names":["ModelFieldContext","React","undefined","ModelFieldProvider","field","children","Provider","useHook","createGenericContext","ParentValueIndexProvider","useParentValueIndex","context"],"mappings":";;AAMO,MAAMA,oBAAoB,WAAHA,GAAGC,MAAAA,aAAmB,CAAgCC;AAO7E,MAAMC,qBAAqB,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAA2B,GACpE,WAAP,GAAO,oBAACL,kBAAkB,QAAQ;QAAC,OAAOI;OAAQC;AAGtD,MAAM,EAAEC,UAAAA,QAAQ,EAAEC,SAAAA,OAAO,EAAE,GAAGC,qBAAwC;AAE/D,MAAMC,2BAA2BH;AAEjC,MAAMI,sBAAsB;IAC/B,IAAI;QACA,MAAMC,UAAUJ;QAChB,OAAOI,QAAQ,KAAK;IACxB,EAAE,OAAM;QACJ,OAAO;IACX;AACJ"}
@@ -1,3 +0,0 @@
1
- export * from "./ModelFieldContext.js";
2
- export * from "./useModelField.js";
3
- export * from "./CanEditField.js";
@@ -1,3 +0,0 @@
1
- export * from "./ModelFieldContext.js";
2
- export * from "./useModelField.js";
3
- export * from "./CanEditField.js";
@@ -1,15 +0,0 @@
1
- import type { CmsModelField, CmsModelFieldTypePlugin } from "../types/index.js";
2
- export interface UseModelField {
3
- field: CmsModelField;
4
- parentValueIndex: number;
5
- fieldPlugin: CmsModelFieldTypePlugin;
6
- }
7
- /**
8
- * Get model field from the current context.
9
- */
10
- export declare const useModelField: import("@webiny/react-composition").GenericHook<unknown, UseModelField> & {
11
- original: import("@webiny/react-composition").GenericHook<unknown, UseModelField>;
12
- originalName: string;
13
- } & {
14
- createDecorator: (decorator: import("@webiny/react-composition").Decorator<() => UseModelField>) => () => React.JSX.Element;
15
- };
@@ -1,23 +0,0 @@
1
- import { useContext } from "react";
2
- import { plugins } from "@webiny/plugins";
3
- import { makeDecoratable } from "@webiny/react-composition";
4
- import { ModelFieldContext, useParentValueIndex } from "./ModelFieldContext.js";
5
- const getFieldPlugin = (type)=>{
6
- const plugin = plugins.byType("cms-editor-field-type").find((plugin)=>plugin.field.type === type);
7
- if (!plugin) throw Error(`Missing plugin for field type "${type}"!`);
8
- return plugin;
9
- };
10
- const useModelField = makeDecoratable(()=>{
11
- const field = useContext(ModelFieldContext);
12
- if (!field) throw Error('Missing "ModelFieldProvider" in the component tree. Are you using the "useModelField()" hook in the right place?');
13
- const parentValueIndex = useParentValueIndex();
14
- const fieldPlugin = getFieldPlugin(field.type);
15
- return {
16
- field,
17
- fieldPlugin,
18
- parentValueIndex
19
- };
20
- });
21
- export { useModelField };
22
-
23
- //# sourceMappingURL=useModelField.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelFieldProvider/useModelField.js","sources":["../../src/ModelFieldProvider/useModelField.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { ModelFieldContext, useParentValueIndex } from \"./ModelFieldContext.js\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types/index.js\";\n\ninterface GetFieldPlugin {\n (type: string): CmsModelFieldTypePlugin;\n}\n\nconst getFieldPlugin: GetFieldPlugin = type => {\n const plugin = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .find(plugin => plugin.field.type === type);\n\n if (!plugin) {\n throw Error(`Missing plugin for field type \"${type}\"!`);\n }\n\n return plugin;\n};\n\nexport interface UseModelField {\n field: CmsModelField;\n parentValueIndex: number;\n fieldPlugin: CmsModelFieldTypePlugin;\n}\n\n/**\n * Get model field from the current context.\n */\nexport const useModelField = makeDecoratable((): UseModelField => {\n const field = useContext(ModelFieldContext);\n\n if (!field) {\n throw Error(\n `Missing \"ModelFieldProvider\" in the component tree. Are you using the \"useModelField()\" hook in the right place?`\n );\n }\n\n const parentValueIndex = useParentValueIndex();\n\n const fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"names":["getFieldPlugin","type","plugin","plugins","Error","useModelField","makeDecoratable","field","useContext","ModelFieldContext","parentValueIndex","useParentValueIndex","fieldPlugin"],"mappings":";;;;AAUA,MAAMA,iBAAiCC,CAAAA;IACnC,MAAMC,SAASC,QAAAA,MACJ,CAA0B,yBAChC,IAAI,CAACD,CAAAA,SAAUA,OAAO,KAAK,CAAC,IAAI,KAAKD;IAE1C,IAAI,CAACC,QACD,MAAME,MAAM,CAAC,+BAA+B,EAAEH,KAAK,EAAE,CAAC;IAG1D,OAAOC;AACX;AAWO,MAAMG,gBAAgBC,gBAAgB;IACzC,MAAMC,QAAQC,WAAWC;IAEzB,IAAI,CAACF,OACD,MAAMH,MACF;IAIR,MAAMM,mBAAmBC;IAEzB,MAAMC,cAAcZ,eAAeO,MAAM,IAAI;IAE7C,OAAO;QAAEA;QAAOK;QAAaF;IAAiB;AAClD"}
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import type { CmsModel } from "../types/index.js";
3
- export type ModelContext = CmsModel;
4
- export declare const ModelContext: React.Context<CmsModel | undefined>;
5
- export interface ModelProviderProps {
6
- model: CmsModel;
7
- children: React.ReactNode;
8
- }
9
- export declare const ModelProvider: ({ model, children }: ModelProviderProps) => React.JSX.Element;
@@ -1,14 +0,0 @@
1
- import react from "react";
2
- import { DevToolsSection } from "@webiny/app-admin";
3
- const ModelContext = /*#__PURE__*/ react.createContext(void 0);
4
- const ModelProvider = ({ model, children })=>/*#__PURE__*/ react.createElement(ModelContext.Provider, {
5
- value: model
6
- }, /*#__PURE__*/ react.createElement(DevToolsSection, {
7
- name: "Model",
8
- group: "CMS",
9
- data: model,
10
- views: "raw"
11
- }), children);
12
- export { ModelContext, ModelProvider };
13
-
14
- //# sourceMappingURL=ModelContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelProvider/ModelContext.js","sources":["../../src/ModelProvider/ModelContext.tsx"],"sourcesContent":["import React from \"react\";\nimport { DevToolsSection } from \"@webiny/app-admin\";\nimport type { CmsModel } from \"~/types/index.js\";\n\nexport type ModelContext = CmsModel;\n\nexport const ModelContext = React.createContext<ModelContext | undefined>(undefined);\n\nexport interface ModelProviderProps {\n model: CmsModel;\n children: React.ReactNode;\n}\n\nexport const ModelProvider = ({ model, children }: ModelProviderProps) => {\n return (\n <ModelContext.Provider value={model}>\n <DevToolsSection name={\"Model\"} group=\"CMS\" data={model} views={\"raw\"} />\n {children}\n </ModelContext.Provider>\n );\n};\n"],"names":["ModelContext","React","undefined","ModelProvider","model","children","DevToolsSection"],"mappings":";;AAMO,MAAMA,eAAe,WAAHA,GAAGC,MAAAA,aAAmB,CAA2BC;AAOnE,MAAMC,gBAAgB,CAAC,EAAEC,KAAK,EAAEC,QAAQ,EAAsB,GAC1D,WAAP,GACI,oBAACL,aAAa,QAAQ;QAAC,OAAOI;qBAC1B,oBAACE,iBAAeA;QAAC,MAAM;QAAS,OAAM;QAAM,MAAMF;QAAO,OAAO;QAC/DC"}
@@ -1,2 +0,0 @@
1
- export * from "./ModelContext.js";
2
- export * from "./useModel.js";
@@ -1,2 +0,0 @@
1
- export * from "./ModelContext.js";
2
- export * from "./useModel.js";
@@ -1,9 +0,0 @@
1
- import type { CmsModel } from "../types/index.js";
2
- type UseModelReturnType = {
3
- model: CmsModel;
4
- };
5
- /**
6
- * Get model from the current context.
7
- */
8
- export declare function useModel(): UseModelReturnType;
9
- export {};
@@ -1,12 +0,0 @@
1
- import { useContext } from "react";
2
- import { ModelContext } from "./ModelContext.js";
3
- function useModel() {
4
- const model = useContext(ModelContext);
5
- if (!model) throw Error('Missing "ModelContext" in the component tree. Are you using the "useModel()" hook in the right place?');
6
- return {
7
- model
8
- };
9
- }
10
- export { useModel };
11
-
12
- //# sourceMappingURL=useModel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ModelProvider/useModel.js","sources":["../../src/ModelProvider/useModel.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ModelContext } from \"./ModelContext.js\";\nimport type { CmsModel } from \"~/types/index.js\";\n\ntype UseModelReturnType = {\n model: CmsModel;\n};\n\n/**\n * Get model from the current context.\n */\nexport function useModel(): UseModelReturnType {\n const model = useContext(ModelContext);\n if (!model) {\n throw Error(\n `Missing \"ModelContext\" in the component tree. Are you using the \"useModel()\" hook in the right place?`\n );\n }\n\n return { model };\n}\n"],"names":["useModel","model","useContext","ModelContext","Error"],"mappings":";;AAWO,SAASA;IACZ,MAAMC,QAAQC,WAAWC;IACzB,IAAI,CAACF,OACD,MAAMG,MACF;IAIR,OAAO;QAAEH;IAAM;AACnB"}
@@ -1,12 +0,0 @@
1
- import type { CmsModel, CmsModelField } from "./types/index.js";
2
- interface CreateFieldsListParams {
3
- model: CmsModel;
4
- fields: CmsModelField[];
5
- graphQLTypePrefix?: string;
6
- }
7
- /**
8
- * When used in ACO, this method receives a filtered list of field types.
9
- * Find `createListRecords` in app-aco to find out more.
10
- */
11
- export declare function createFieldsList({ model, fields: inputFields, graphQLTypePrefix }: CreateFieldsListParams): string;
12
- export {};
@@ -1,31 +0,0 @@
1
- import { plugins } from "@webiny/plugins";
2
- function createFieldsList({ model, fields: inputFields, graphQLTypePrefix }) {
3
- const fieldPlugins = plugins.byType("cms-editor-field-type").reduce((acc, item)=>({
4
- ...acc,
5
- [item.field.type]: item.field
6
- }), {});
7
- const typePrefix = graphQLTypePrefix ?? model.singularApiName;
8
- const fields = inputFields.map((field)=>{
9
- if (!fieldPlugins[field.type]) {
10
- console.log(`Unknown field plugin for field type "${field.type}".`);
11
- return null;
12
- }
13
- const { graphql } = fieldPlugins[field.type];
14
- if (graphql && graphql.queryField) {
15
- const { queryField } = graphql;
16
- const selection = "string" == typeof queryField ? queryField : queryField({
17
- model,
18
- field,
19
- graphQLTypePrefix: typePrefix
20
- });
21
- if (null === selection) return null;
22
- return `${field.fieldId} ${selection}`;
23
- }
24
- return field.fieldId;
25
- }).filter(Boolean);
26
- if (0 === fields.length) fields.push("_empty");
27
- return fields.join("\n");
28
- }
29
- export { createFieldsList };
30
-
31
- //# sourceMappingURL=createFieldsList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createFieldsList.js","sources":["../src/createFieldsList.ts"],"sourcesContent":["import type { CmsModel, CmsModelField, CmsModelFieldTypePlugin } from \"~/types/index.js\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface CreateFieldsListParams {\n model: CmsModel;\n fields: CmsModelField[];\n graphQLTypePrefix?: string;\n}\n\n/**\n * When used in ACO, this method receives a filtered list of field types.\n * Find `createListRecords` in app-aco to find out more.\n */\nexport function createFieldsList({\n model,\n fields: inputFields,\n graphQLTypePrefix\n}: CreateFieldsListParams): string {\n const fieldPlugins: Record<string, CmsModelFieldTypePlugin[\"field\"]> = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .reduce((acc, item) => ({ ...acc, [item.field.type]: item.field }), {});\n\n const typePrefix = graphQLTypePrefix ?? model.singularApiName;\n\n const fields = inputFields\n .map(field => {\n if (!fieldPlugins[field.type]) {\n console.log(`Unknown field plugin for field type \"${field.type}\".`);\n return null;\n }\n const { graphql } = fieldPlugins[field.type];\n\n if (graphql && graphql.queryField) {\n const { queryField } = graphql;\n const selection =\n typeof queryField === \"string\"\n ? queryField\n : queryField({ model, field, graphQLTypePrefix: typePrefix });\n\n /**\n * If field type plugin returns `null`, we don't include the field in the selection.\n */\n if (selection === null) {\n return null;\n }\n\n return `${field.fieldId} ${selection}`;\n }\n\n return field.fieldId;\n })\n .filter(Boolean);\n /**\n * If there are no fields, let's always load the `_empty` field.\n */\n if (fields.length === 0) {\n fields.push(\"_empty\");\n }\n return fields.join(\"\\n\");\n}\n"],"names":["createFieldsList","model","inputFields","graphQLTypePrefix","fieldPlugins","plugins","acc","item","typePrefix","fields","field","console","graphql","queryField","selection","Boolean"],"mappings":";AAaO,SAASA,iBAAiB,EAC7BC,KAAK,EACL,QAAQC,WAAW,EACnBC,iBAAiB,EACI;IACrB,MAAMC,eAAiEC,QAAAA,MAC5D,CAA0B,yBAChC,MAAM,CAAC,CAACC,KAAKC,OAAU;YAAE,GAAGD,GAAG;YAAE,CAACC,KAAK,KAAK,CAAC,IAAI,CAAC,EAAEA,KAAK,KAAK;QAAC,IAAI,CAAC;IAEzE,MAAMC,aAAaL,qBAAqBF,MAAM,eAAe;IAE7D,MAAMQ,SAASP,YACV,GAAG,CAACQ,CAAAA;QACD,IAAI,CAACN,YAAY,CAACM,MAAM,IAAI,CAAC,EAAE;YAC3BC,QAAQ,GAAG,CAAC,CAAC,qCAAqC,EAAED,MAAM,IAAI,CAAC,EAAE,CAAC;YAClE,OAAO;QACX;QACA,MAAM,EAAEE,OAAO,EAAE,GAAGR,YAAY,CAACM,MAAM,IAAI,CAAC;QAE5C,IAAIE,WAAWA,QAAQ,UAAU,EAAE;YAC/B,MAAM,EAAEC,UAAU,EAAE,GAAGD;YACvB,MAAME,YACF,AAAsB,YAAtB,OAAOD,aACDA,aACAA,WAAW;gBAAEZ;gBAAOS;gBAAO,mBAAmBF;YAAW;YAKnE,IAAIM,AAAc,SAAdA,WACA,OAAO;YAGX,OAAO,GAAGJ,MAAM,OAAO,CAAC,CAAC,EAAEI,WAAW;QAC1C;QAEA,OAAOJ,MAAM,OAAO;IACxB,GACC,MAAM,CAACK;IAIZ,IAAIN,AAAkB,MAAlBA,OAAO,MAAM,EACbA,OAAO,IAAI,CAAC;IAEhB,OAAOA,OAAO,IAAI,CAAC;AACvB"}
@@ -1,18 +0,0 @@
1
- import React from "react";
2
- declare module "react" {
3
- namespace JSX {
4
- interface IntrinsicElements {
5
- "hcms-field-validation": {
6
- class: string;
7
- "data-path": string;
8
- "data-field-type": string;
9
- "data-field-multiple-values": string;
10
- "data-field-renderer": string;
11
- children: React.ReactNode;
12
- };
13
- }
14
- }
15
- }
16
- export declare const createValidationContainer: (path: string) => ({ children }: {
17
- children: React.ReactNode;
18
- }) => React.JSX.Element;
@@ -1,16 +0,0 @@
1
- import react from "react";
2
- import { useModelField } from "./ModelFieldProvider/index.js";
3
- const createValidationContainer = (path)=>function({ children }) {
4
- const { field } = useModelField();
5
- if (void 0 === field.list) field.list = false;
6
- return /*#__PURE__*/ react.createElement("hcms-field-validation", {
7
- class: "block",
8
- "data-path": path,
9
- "data-field-type": field.type,
10
- "data-field-multiple-values": String(field.list),
11
- "data-field-renderer": String(field.renderer.name)
12
- }, children);
13
- };
14
- export { createValidationContainer };
15
-
16
- //# sourceMappingURL=createValidationContainer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createValidationContainer.js","sources":["../src/createValidationContainer.tsx"],"sourcesContent":["import React from \"react\";\nimport { useModelField } from \"./ModelFieldProvider/index.js\";\n\ndeclare module \"react\" {\n namespace JSX {\n interface IntrinsicElements {\n \"hcms-field-validation\": {\n class: string;\n \"data-path\": string;\n \"data-field-type\": string;\n \"data-field-multiple-values\": string;\n \"data-field-renderer\": string;\n children: React.ReactNode;\n };\n }\n }\n}\n\nexport const createValidationContainer = (path: string) => {\n return function ValidationContainer({ children }: { children: React.ReactNode }) {\n const { field } = useModelField();\n\n if (field.list === undefined) {\n field.list = false;\n }\n\n return (\n <hcms-field-validation\n class={\"block\"}\n data-path={path}\n data-field-type={field.type}\n data-field-multiple-values={String(field.list)}\n data-field-renderer={String(field.renderer.name)}\n >\n {children}\n </hcms-field-validation>\n );\n };\n};\n"],"names":["createValidationContainer","path","children","field","useModelField","undefined","String"],"mappings":";;AAkBO,MAAMA,4BAA4B,CAACC,OAC/B,SAA6B,EAAEC,QAAQ,EAAiC;QAC3E,MAAM,EAAEC,KAAK,EAAE,GAAGC;QAElB,IAAID,AAAeE,WAAfF,MAAM,IAAI,EACVA,MAAM,IAAI,GAAG;QAGjB,OAAO,WAAP,GACI,oBAAC;YACG,OAAO;YACP,aAAWF;YACX,mBAAiBE,MAAM,IAAI;YAC3B,8BAA4BG,OAAOH,MAAM,IAAI;YAC7C,uBAAqBG,OAAOH,MAAM,QAAQ,CAAC,IAAI;WAE9CD;IAGb"}
@@ -1,3 +0,0 @@
1
- import type { CmsModelField, CmsModelFieldValidator } from "./types/index.js";
2
- import type { Validator } from "@webiny/validation/types.js";
3
- export declare const createValidators: (field: CmsModelField, validation: (CmsModelFieldValidator | Validator)[]) => Validator[];
@@ -1,47 +0,0 @@
1
- import { plugins } from "@webiny/plugins";
2
- import camelCase from "lodash/camelCase.js";
3
- const createValidators = (field, validation)=>{
4
- const validatorPlugins = plugins.byType("cms-model-field-validator");
5
- return validation.reduce((collection, item)=>{
6
- if ("function" == typeof item) return [
7
- ...collection,
8
- item
9
- ];
10
- const validatorPlugin = validatorPlugins.find((plugin)=>plugin.validator.name === item.name);
11
- if (!validatorPlugin || "function" != typeof validatorPlugin.validator.validate) return collection;
12
- const validator = async (value)=>{
13
- let isInvalid;
14
- let message = item.message;
15
- try {
16
- const result = await validatorPlugin.validator.validate(value, {
17
- validator: item,
18
- field
19
- });
20
- isInvalid = false === result;
21
- } catch (e) {
22
- isInvalid = true;
23
- if (e.message && !item.message) message = e.message;
24
- }
25
- if (isInvalid) {
26
- let interpolated = message || "Invalid value.";
27
- const getVariableValues = validatorPlugin.validator.getVariableValues;
28
- if ("function" == typeof getVariableValues) {
29
- const variables = getVariableValues({
30
- validator: item
31
- });
32
- Object.keys(variables).forEach((key)=>{
33
- const regex = new RegExp(`{${key}}`, "g");
34
- interpolated = interpolated.replace(regex, variables[key]);
35
- });
36
- }
37
- throw new Error(interpolated);
38
- }
39
- };
40
- validator.validatorName = camelCase(validatorPlugin.validator.name);
41
- collection.push(validator);
42
- return collection;
43
- }, []);
44
- };
45
- export { createValidators };
46
-
47
- //# sourceMappingURL=createValidators.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createValidators.js","sources":["../src/createValidators.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport type {\n CmsModelField,\n CmsModelFieldValidator,\n CmsModelFieldValidatorPlugin\n} from \"~/types/index.js\";\nimport type { Validator } from \"@webiny/validation/types.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nexport const createValidators = (\n field: CmsModelField,\n validation: (CmsModelFieldValidator | Validator)[]\n): Validator[] => {\n const validatorPlugins = plugins.byType<CmsModelFieldValidatorPlugin>(\n \"cms-model-field-validator\"\n );\n\n return validation.reduce<Validator[]>((collection, item) => {\n if (typeof item === \"function\") {\n return [...collection, item];\n }\n\n const validatorPlugin = validatorPlugins.find(\n plugin => plugin.validator.name === item.name\n );\n\n if (!validatorPlugin || typeof validatorPlugin.validator.validate !== \"function\") {\n return collection;\n }\n\n const validator = async (value: any | any[]) => {\n let isInvalid;\n let message = item.message;\n try {\n const result = await validatorPlugin.validator.validate(value, {\n validator: item,\n field\n });\n\n isInvalid = result === false;\n } catch (e) {\n isInvalid = true;\n if (e.message && !item.message) {\n message = e.message;\n }\n }\n\n if (isInvalid) {\n let interpolated = message || \"Invalid value.\";\n\n const getVariableValues = validatorPlugin.validator.getVariableValues;\n if (typeof getVariableValues === \"function\") {\n const variables = getVariableValues({ validator: item });\n\n Object.keys(variables).forEach(key => {\n const regex = new RegExp(`{${key}}`, \"g\");\n interpolated = interpolated.replace(regex, variables[key]);\n });\n }\n\n throw new Error(interpolated);\n }\n };\n /**\n * We need to set the validator name because it will be used as the reference to skip, if necessary.\n */\n validator.validatorName = camelCase(validatorPlugin.validator.name);\n\n collection.push(validator);\n return collection;\n }, [] as Validator[]);\n};\n"],"names":["createValidators","field","validation","validatorPlugins","plugins","collection","item","validatorPlugin","plugin","validator","value","isInvalid","message","result","e","interpolated","getVariableValues","variables","Object","key","regex","RegExp","Error","camelCase"],"mappings":";;AASO,MAAMA,mBAAmB,CAC5BC,OACAC;IAEA,MAAMC,mBAAmBC,QAAQ,MAAM,CACnC;IAGJ,OAAOF,WAAW,MAAM,CAAc,CAACG,YAAYC;QAC/C,IAAI,AAAgB,cAAhB,OAAOA,MACP,OAAO;eAAID;YAAYC;SAAK;QAGhC,MAAMC,kBAAkBJ,iBAAiB,IAAI,CACzCK,CAAAA,SAAUA,OAAO,SAAS,CAAC,IAAI,KAAKF,KAAK,IAAI;QAGjD,IAAI,CAACC,mBAAmB,AAA8C,cAA9C,OAAOA,gBAAgB,SAAS,CAAC,QAAQ,EAC7D,OAAOF;QAGX,MAAMI,YAAY,OAAOC;YACrB,IAAIC;YACJ,IAAIC,UAAUN,KAAK,OAAO;YAC1B,IAAI;gBACA,MAAMO,SAAS,MAAMN,gBAAgB,SAAS,CAAC,QAAQ,CAACG,OAAO;oBAC3D,WAAWJ;oBACXL;gBACJ;gBAEAU,YAAYE,AAAW,UAAXA;YAChB,EAAE,OAAOC,GAAG;gBACRH,YAAY;gBACZ,IAAIG,EAAE,OAAO,IAAI,CAACR,KAAK,OAAO,EAC1BM,UAAUE,EAAE,OAAO;YAE3B;YAEA,IAAIH,WAAW;gBACX,IAAII,eAAeH,WAAW;gBAE9B,MAAMI,oBAAoBT,gBAAgB,SAAS,CAAC,iBAAiB;gBACrE,IAAI,AAA6B,cAA7B,OAAOS,mBAAkC;oBACzC,MAAMC,YAAYD,kBAAkB;wBAAE,WAAWV;oBAAK;oBAEtDY,OAAO,IAAI,CAACD,WAAW,OAAO,CAACE,CAAAA;wBAC3B,MAAMC,QAAQ,IAAIC,OAAO,CAAC,CAAC,EAAEF,IAAI,CAAC,CAAC,EAAE;wBACrCJ,eAAeA,aAAa,OAAO,CAACK,OAAOH,SAAS,CAACE,IAAI;oBAC7D;gBACJ;gBAEA,MAAM,IAAIG,MAAMP;YACpB;QACJ;QAIAN,UAAU,aAAa,GAAGc,UAAUhB,gBAAgB,SAAS,CAAC,IAAI;QAElEF,WAAW,IAAI,CAACI;QAChB,OAAOJ;IACX,GAAG,EAAE;AACT"}
@@ -1,229 +0,0 @@
1
- import type { CmsContentEntry, CmsContentEntryRevision, CmsEditorContentModel, CmsErrorResponse, CmsMetaResponse, CmsModelField } from "./types/index.js";
2
- import type { FormValidationOptions } from "@webiny/form";
3
- /**
4
- * ############################################
5
- * Get CMS Entry Query
6
- */
7
- export interface CmsEntryGetQueryResponse {
8
- content: {
9
- data: CmsContentEntry;
10
- error: CmsErrorResponse | null;
11
- };
12
- }
13
- export interface CmsEntryGetQueryVariables {
14
- revision?: string;
15
- entryId?: string;
16
- }
17
- export declare const createReadQuery: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
18
- /**
19
- * ############################################
20
- * Get CMS Singleton Entry Query
21
- */
22
- export interface CmsEntryGetSingletonQueryResponse {
23
- content: {
24
- data: CmsContentEntry;
25
- error: CmsErrorResponse | null;
26
- };
27
- }
28
- export declare const createReadSingletonQuery: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
29
- /**
30
- * ############################################
31
- * List CMS Entry Revisions Query
32
- */
33
- export interface CmsEntriesListRevisionsQueryResponse {
34
- revisions: {
35
- data: CmsContentEntryRevision[];
36
- error: CmsErrorResponse | null;
37
- meta: CmsMetaResponse;
38
- };
39
- }
40
- export interface CmsEntriesListRevisionsQueryVariables {
41
- id: string;
42
- }
43
- export declare const createRevisionsQuery: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
44
- /**
45
- * ############################################
46
- * List CMS Entries Query
47
- */
48
- export interface CmsEntriesListQueryResponse {
49
- content: {
50
- data: CmsContentEntry[];
51
- error: CmsErrorResponse | null;
52
- meta: CmsMetaResponse;
53
- };
54
- }
55
- export interface CmsEntriesListQueryVariables {
56
- where?: {
57
- [key: string]: any;
58
- };
59
- sort?: string[];
60
- limit?: number;
61
- after?: string;
62
- }
63
- export declare const createListQueryDataSelection: (model: CmsEditorContentModel, fields?: CmsModelField[]) => string;
64
- export declare const createListQuery: (model: CmsEditorContentModel, fields?: CmsModelField[], deleted?: boolean) => import("graphql").DocumentNode;
65
- /**
66
- * ############################################
67
- * Delete Mutation
68
- */
69
- export interface CmsEntryDeleteMutationResponse {
70
- content: {
71
- data: CmsContentEntry | null;
72
- error: CmsErrorResponse | null;
73
- };
74
- }
75
- export interface CmsEntryDeleteMutationVariables {
76
- revision: string;
77
- permanently?: boolean;
78
- }
79
- export declare const createDeleteMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
80
- /**
81
- * ############################################
82
- * Restore from bin Mutation
83
- */
84
- export interface CmsEntryRestoreFromBinMutationResponse {
85
- content: {
86
- data: CmsContentEntry | null;
87
- error: CmsErrorResponse | null;
88
- };
89
- }
90
- export interface CmsEntryRestoreFromBinMutationVariables {
91
- revision: string;
92
- }
93
- export declare const createRestoreFromBinMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
94
- /**
95
- * ############################################
96
- * Create Mutation
97
- */
98
- export interface CmsEntryCreateMutationResponse {
99
- content: {
100
- data: CmsContentEntry | null;
101
- error: CmsErrorResponse | null;
102
- };
103
- }
104
- export interface CmsEntryCreateMutationVariables {
105
- /**
106
- * We have any here because we do not know which fields does entry have
107
- */
108
- data: Record<string, any>;
109
- options?: FormValidationOptions;
110
- }
111
- export declare const createCreateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
112
- /**
113
- * ############################################
114
- * Create From Mutation
115
- */
116
- export interface CmsEntryCreateFromMutationResponse {
117
- content: {
118
- data?: CmsContentEntry;
119
- error?: CmsErrorResponse;
120
- };
121
- }
122
- export interface CmsEntryCreateFromMutationVariables {
123
- revision: string;
124
- /**
125
- * We have any here because we do not know which fields does entry have
126
- */
127
- data?: Record<string, any>;
128
- options?: FormValidationOptions;
129
- }
130
- export declare const createCreateFromMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
131
- /**
132
- * ############################################
133
- * Update Mutation
134
- */
135
- export interface CmsEntryUpdateMutationResponse {
136
- content: {
137
- data?: CmsContentEntry;
138
- error?: CmsErrorResponse;
139
- };
140
- }
141
- export interface CmsEntryUpdateMutationVariables {
142
- revision: string;
143
- /**
144
- * We have any here because we do not know which fields does entry have
145
- */
146
- data: Record<string, any>;
147
- options?: FormValidationOptions;
148
- }
149
- export declare const createUpdateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
150
- /**
151
- * ############################################
152
- * Update Singleton Mutation
153
- */
154
- export interface CmsEntryUpdateSingletonMutationResponse {
155
- content: {
156
- data?: CmsContentEntry;
157
- error?: CmsErrorResponse;
158
- };
159
- }
160
- export interface CmsEntryUpdateSingletonMutationVariables {
161
- /**
162
- * We have any here because we do not know which fields does entry have
163
- */
164
- data: Record<string, any>;
165
- options?: FormValidationOptions;
166
- }
167
- export declare const createUpdateSingletonMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
168
- export interface CmsEntryUpdateRevisionDescriptionMutationResponse {
169
- content: {
170
- data?: CmsContentEntry;
171
- error?: CmsErrorResponse;
172
- };
173
- }
174
- export interface CmsEntryUpdateRevisionDescriptionMutationVariables {
175
- revision: string;
176
- revisionDescription: string;
177
- }
178
- export declare const createUpdateRevisionDescriptionMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
179
- /**
180
- * ############################################
181
- * Publish Mutation
182
- */
183
- export interface CmsEntryPublishMutationResponse {
184
- content: {
185
- data?: CmsContentEntry;
186
- error?: CmsErrorResponse;
187
- };
188
- }
189
- export interface CmsEntryPublishMutationVariables {
190
- revision: string;
191
- }
192
- export declare const createPublishMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
193
- /**
194
- * ############################################
195
- * Unpublish Mutation
196
- */
197
- export interface CmsEntryUnpublishMutationResponse {
198
- content: {
199
- data?: CmsContentEntry;
200
- error?: CmsErrorResponse;
201
- };
202
- }
203
- export interface CmsEntryUnpublishMutationVariables {
204
- revision: string;
205
- }
206
- export declare const createUnpublishMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
207
- /**
208
- * ############################################
209
- * Bulk Action Mutation
210
- */
211
- export interface CmsEntryBulkActionMutationResponse {
212
- content: {
213
- data?: {
214
- id: string;
215
- };
216
- error?: CmsErrorResponse;
217
- };
218
- }
219
- export interface CmsEntryBulkActionMutationVariables {
220
- action: string;
221
- where?: {
222
- [key: string]: any;
223
- };
224
- search?: string;
225
- data?: {
226
- [key: string]: any;
227
- };
228
- }
229
- export declare const createBulkActionMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;