@webiny/app-headless-cms-common 6.0.0-alpha.0 → 6.0.0-alpha.2

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.
@@ -1,4 +1,5 @@
1
- import React, { ErrorInfo } from "react";
1
+ import type { ErrorInfo } from "react";
2
+ import React from "react";
2
3
  import type { CmsModelField } from "../types";
3
4
  type State = {
4
5
  hasError: true;
@@ -1 +1 @@
1
- {"version":3,"names":["React","FieldElementError","ErrorBoundary","Component","constructor","props","state","hasError","error","undefined","getDerivedStateFromError","componentDidCatch","errorInfo","field","console","groupCollapsed","fieldId","id","type","log","groupEnd","render","createElement","title","message","description","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["import React, { ErrorInfo } from \"react\";\nimport type { CmsModelField } from \"~/types\";\nimport { FieldElementError } from \"./FieldElementError\";\n\ntype State =\n | {\n hasError: true;\n error: Error;\n }\n | { hasError: false; error: undefined };\n\ninterface Props {\n field: CmsModelField;\n [key: string]: any;\n}\n\nexport class ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n error: undefined\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n return {\n hasError: true,\n error\n };\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { field } = this.props;\n if (!field) {\n return;\n }\n console.groupCollapsed(\n `%cFIELD ERROR%c: An error occurred while rendering model field \"${field.fieldId}\" (${field.id}) of type \"${field.type}\".`,\n \"color:red\",\n \"color:default\"\n );\n console.log(\"Field definition\", field);\n console.error(error, errorInfo);\n console.groupEnd();\n }\n\n public override render() {\n if (this.state.hasError) {\n return (\n <FieldElementError\n title={`Error: ${this.state.error.message}`}\n description={\"See developer console for more details.\"}\n />\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AAAA,OAAOA,KAAK,MAAqB,OAAO;AAExC,SAASC,iBAAiB;AAc1B,OAAO,MAAMC,aAAa,SAASF,KAAK,CAACG,SAAS,CAAe;EAC7DC,WAAWA,CAACC,KAAY,EAAE;IACtB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MACTC,QAAQ,EAAE,KAAK;MACfC,KAAK,EAAEC;IACX,CAAC;EACL;EAEA,OAAOC,wBAAwBA,CAACF,KAAY,EAAE;IAC1C,OAAO;MACHD,QAAQ,EAAE,IAAI;MACdC;IACJ,CAAC;EACL;EAEgBG,iBAAiBA,CAACH,KAAY,EAAEI,SAAoB,EAAE;IAClE,MAAM;MAAEC;IAAM,CAAC,GAAG,IAAI,CAACR,KAAK;IAC5B,IAAI,CAACQ,KAAK,EAAE;MACR;IACJ;IACAC,OAAO,CAACC,cAAc,CAClB,mEAAmEF,KAAK,CAACG,OAAO,MAAMH,KAAK,CAACI,EAAE,cAAcJ,KAAK,CAACK,IAAI,IAAI,EAC1H,WAAW,EACX,eACJ,CAAC;IACDJ,OAAO,CAACK,GAAG,CAAC,kBAAkB,EAAEN,KAAK,CAAC;IACtCC,OAAO,CAACN,KAAK,CAACA,KAAK,EAAEI,SAAS,CAAC;IAC/BE,OAAO,CAACM,QAAQ,CAAC,CAAC;EACtB;EAEgBC,MAAMA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACf,KAAK,CAACC,QAAQ,EAAE;MACrB,oBACIP,KAAA,CAAAsB,aAAA,CAACrB,iBAAiB;QACdsB,KAAK,EAAE,UAAU,IAAI,CAACjB,KAAK,CAACE,KAAK,CAACgB,OAAO,EAAG;QAC5CC,WAAW,EAAE;MAA0C,CAC1D,CAAC;IAEV;IAEA,OAAO,IAAI,CAACpB,KAAK,CAACqB,QAAQ;EAC9B;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["React","FieldElementError","ErrorBoundary","Component","constructor","props","state","hasError","error","undefined","getDerivedStateFromError","componentDidCatch","errorInfo","field","console","groupCollapsed","fieldId","id","type","log","groupEnd","render","createElement","title","message","description","children"],"sources":["ErrorBoundary.tsx"],"sourcesContent":["import type { ErrorInfo } from \"react\";\nimport React from \"react\";\nimport type { CmsModelField } from \"~/types\";\nimport { FieldElementError } from \"./FieldElementError\";\n\ntype State =\n | {\n hasError: true;\n error: Error;\n }\n | { hasError: false; error: undefined };\n\ninterface Props {\n field: CmsModelField;\n [key: string]: any;\n}\n\nexport class ErrorBoundary extends React.Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = {\n hasError: false,\n error: undefined\n };\n }\n\n static getDerivedStateFromError(error: Error) {\n return {\n hasError: true,\n error\n };\n }\n\n public override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n const { field } = this.props;\n if (!field) {\n return;\n }\n console.groupCollapsed(\n `%cFIELD ERROR%c: An error occurred while rendering model field \"${field.fieldId}\" (${field.id}) of type \"${field.type}\".`,\n \"color:red\",\n \"color:default\"\n );\n console.log(\"Field definition\", field);\n console.error(error, errorInfo);\n console.groupEnd();\n }\n\n public override render() {\n if (this.state.hasError) {\n return (\n <FieldElementError\n title={`Error: ${this.state.error.message}`}\n description={\"See developer console for more details.\"}\n />\n );\n }\n\n return this.props.children;\n }\n}\n"],"mappings":"AACA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,iBAAiB;AAc1B,OAAO,MAAMC,aAAa,SAASF,KAAK,CAACG,SAAS,CAAe;EAC7DC,WAAWA,CAACC,KAAY,EAAE;IACtB,KAAK,CAACA,KAAK,CAAC;IACZ,IAAI,CAACC,KAAK,GAAG;MACTC,QAAQ,EAAE,KAAK;MACfC,KAAK,EAAEC;IACX,CAAC;EACL;EAEA,OAAOC,wBAAwBA,CAACF,KAAY,EAAE;IAC1C,OAAO;MACHD,QAAQ,EAAE,IAAI;MACdC;IACJ,CAAC;EACL;EAEgBG,iBAAiBA,CAACH,KAAY,EAAEI,SAAoB,EAAE;IAClE,MAAM;MAAEC;IAAM,CAAC,GAAG,IAAI,CAACR,KAAK;IAC5B,IAAI,CAACQ,KAAK,EAAE;MACR;IACJ;IACAC,OAAO,CAACC,cAAc,CAClB,mEAAmEF,KAAK,CAACG,OAAO,MAAMH,KAAK,CAACI,EAAE,cAAcJ,KAAK,CAACK,IAAI,IAAI,EAC1H,WAAW,EACX,eACJ,CAAC;IACDJ,OAAO,CAACK,GAAG,CAAC,kBAAkB,EAAEN,KAAK,CAAC;IACtCC,OAAO,CAACN,KAAK,CAACA,KAAK,EAAEI,SAAS,CAAC;IAC/BE,OAAO,CAACM,QAAQ,CAAC,CAAC;EACtB;EAEgBC,MAAMA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACf,KAAK,CAACC,QAAQ,EAAE;MACrB,oBACIP,KAAA,CAAAsB,aAAA,CAACrB,iBAAiB;QACdsB,KAAK,EAAE,UAAU,IAAI,CAACjB,KAAK,CAACE,KAAK,CAACgB,OAAO,EAAG;QAC5CC,WAAW,EAAE;MAA0C,CAC1D,CAAC;IAEV;IAEA,OAAO,IAAI,CAACpB,KAAK,CAACqB,QAAQ;EAC9B;AACJ","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CmsModelField, CmsEditorContentModel, BindComponent } from "../types";
2
+ import type { CmsModelField, CmsEditorContentModel, BindComponent } from "../types";
3
3
  declare global {
4
4
  namespace JSX {
5
5
  interface IntrinsicElements {
@@ -1 +1 @@
1
- {"version":3,"names":["React","get","makeDecoratable","i18n","Label","useBind","useRenderPlugins","ModelFieldProvider","useModelField","ErrorBoundary","t","ns","RenderField","props","renderPlugins","Bind","contentModel","field","getBind","renderer","createElement","Fragment","renderPlugin","find","plugin","rendererName","fieldName","fieldId","render","FieldElement","id","type","RenderFieldElement"],"sources":["FieldElement.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport Label from \"./Label\";\nimport { useBind } from \"./useBind\";\nimport { useRenderPlugins } from \"./useRenderPlugins\";\nimport { ModelFieldProvider, useModelField } from \"../ModelFieldProvider\";\nimport { CmsModelField, CmsEditorContentModel, BindComponent } from \"~/types\";\nimport { ErrorBoundary } from \"./ErrorBoundary\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/content-form\");\n\ndeclare global {\n // eslint-disable-next-line\n namespace JSX {\n interface IntrinsicElements {\n \"hcms-model-field\": {\n \"data-id\": string;\n \"data-type\": string;\n \"data-field-id\": string;\n children: React.ReactNode;\n };\n }\n }\n}\n\ntype RenderFieldProps = Omit<FieldElementProps, \"field\">;\n\nconst RenderField = (props: RenderFieldProps) => {\n const renderPlugins = useRenderPlugins();\n const { Bind, contentModel } = props;\n const { field } = useModelField();\n const getBind = useBind({ Bind });\n\n if (typeof field.renderer === \"function\") {\n return <>{field.renderer({ field, getBind, Label, contentModel })}</>;\n }\n\n const renderPlugin = renderPlugins.find(\n plugin => plugin.renderer.rendererName === get(field, \"renderer.name\")\n );\n\n if (!renderPlugin) {\n return t`Cannot render \"{fieldName}\" field - field renderer missing.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n return <>{renderPlugin.renderer.render({ field, getBind, Label, contentModel })}</>;\n};\n\nexport interface FieldElementProps {\n field: CmsModelField;\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\n\nexport const FieldElement = makeDecoratable(\n \"FieldElement\",\n ({ field, ...props }: FieldElementProps) => {\n if (!field) {\n return null;\n }\n\n return (\n <hcms-model-field\n data-id={field.id}\n data-field-id={field.fieldId}\n data-type={field.type}\n >\n <ErrorBoundary field={field}>\n <ModelFieldProvider field={field}>\n <RenderField {...props} />\n </ModelFieldProvider>\n </ErrorBoundary>\n </hcms-model-field>\n );\n }\n);\n\n/**\n * @deprecated Use `FieldElement` instead.\n */\nexport const RenderFieldElement = FieldElement;\n\n/**\n * @deprecated Use `FieldElementProps` instead.\n */\nexport type RenderFieldElementProps = FieldElementProps;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,YAAY;AAC5B,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SA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eAAe,CACvC,cAAc,EACd,CAAC;EAAEe,KAAK;EAAE,GAAGJ;AAAyB,CAAC,KAAK;EACxC,IAAI,CAACI,KAAK,EAAE;IACR,OAAO,IAAI;EACf;EAEA,oBACIjB,KAAA,CAAAoB,aAAA;IACI,WAASH,KAAK,CAACa,EAAG;IAClB,iBAAeb,KAAK,CAACU,OAAQ;IAC7B,aAAWV,KAAK,CAACc;EAAK,gBAEtB/B,KAAA,CAAAoB,aAAA,CAACX,aAAa;IAACQ,KAAK,EAAEA;EAAM,gBACxBjB,KAAA,CAAAoB,aAAA,CAACb,kBAAkB;IAACU,KAAK,EAAEA;EAAM,gBAC7BjB,KAAA,CAAAoB,aAAA,CAACR,WAAW,EAAKC,KAAQ,CACT,CACT,CACD,CAAC;AAE3B,CACJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMmB,kBAAkB,GAAGH,YAAY;;AAE9C;AACA;AACA","ignoreList":[]}
1
+ {"version":3,"names":["React","get","makeDecoratable","i18n","Label","useBind","useRenderPlugins","ModelFieldProvider","useModelField","ErrorBoundary","t","ns","RenderField","props","renderPlugins","Bind","contentModel","field","getBind","renderer","createElement","Fragment","renderPlugin","find","plugin","rendererName","fieldName","fieldId","render","FieldElement","id","type","RenderFieldElement"],"sources":["FieldElement.tsx"],"sourcesContent":["import React from \"react\";\nimport get from \"lodash/get\";\nimport { makeDecoratable } from \"@webiny/app-admin\";\nimport { i18n } from \"@webiny/app/i18n\";\nimport Label from \"./Label\";\nimport { useBind } from \"./useBind\";\nimport { useRenderPlugins } from \"./useRenderPlugins\";\nimport { ModelFieldProvider, useModelField } from \"../ModelFieldProvider\";\nimport type { CmsModelField, CmsEditorContentModel, BindComponent } from \"~/types\";\nimport { ErrorBoundary } from \"./ErrorBoundary\";\n\nconst t = i18n.ns(\"app-headless-cms/admin/components/content-form\");\n\ndeclare global {\n // eslint-disable-next-line\n namespace JSX {\n interface IntrinsicElements {\n \"hcms-model-field\": {\n \"data-id\": string;\n \"data-type\": string;\n \"data-field-id\": string;\n children: React.ReactNode;\n };\n }\n }\n}\n\ntype RenderFieldProps = Omit<FieldElementProps, \"field\">;\n\nconst RenderField = (props: RenderFieldProps) => {\n const renderPlugins = useRenderPlugins();\n const { Bind, contentModel } = props;\n const { field } = useModelField();\n const getBind = useBind({ Bind });\n\n if (typeof field.renderer === \"function\") {\n return <>{field.renderer({ field, getBind, Label, contentModel })}</>;\n }\n\n const renderPlugin = renderPlugins.find(\n plugin => plugin.renderer.rendererName === get(field, \"renderer.name\")\n );\n\n if (!renderPlugin) {\n return t`Cannot render \"{fieldName}\" field - field renderer missing.`({\n fieldName: <strong>{field.fieldId}</strong>\n });\n }\n\n return <>{renderPlugin.renderer.render({ field, getBind, Label, contentModel })}</>;\n};\n\nexport interface FieldElementProps {\n field: CmsModelField;\n Bind: BindComponent;\n contentModel: CmsEditorContentModel;\n}\n\nexport const FieldElement = makeDecoratable(\n \"FieldElement\",\n ({ field, ...props }: FieldElementProps) => {\n if (!field) {\n return null;\n }\n\n return (\n <hcms-model-field\n data-id={field.id}\n data-field-id={field.fieldId}\n data-type={field.type}\n >\n <ErrorBoundary field={field}>\n <ModelFieldProvider field={field}>\n <RenderField {...props} />\n </ModelFieldProvider>\n </ErrorBoundary>\n </hcms-model-field>\n );\n }\n);\n\n/**\n * @deprecated Use `FieldElement` instead.\n */\nexport const RenderFieldElement = FieldElement;\n\n/**\n * @deprecated Use `FieldElementProps` instead.\n */\nexport type RenderFieldElementProps = FieldElementProps;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,YAAY;AAC5B,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,KAAK;AACZ,SAASC,OAAO;AAChB,SAASC,gBAAgB;AACzB,SAASC,kBAAkB,EAAEC,aAAa;AAE1C,SAASC,aAAa;AAEtB,MAAMC,CAAC,GAAGP,IAAI,CAACQ,EAAE,CAAC,gD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IAClB,iBAAeb,KAAK,CAACU,OAAQ;IAC7B,aAAWV,KAAK,CAACc;EAAK,gBAEtB/B,KAAA,CAAAoB,aAAA,CAACX,aAAa;IAACQ,KAAK,EAAEA;EAAM,gBACxBjB,KAAA,CAAAoB,aAAA,CAACb,kBAAkB;IAACU,KAAK,EAAEA;EAAM,gBAC7BjB,KAAA,CAAAoB,aAAA,CAACR,WAAW,EAAKC,KAAQ,CACT,CACT,CACD,CAAC;AAE3B,CACJ,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMmB,kBAAkB,GAAGH,YAAY;;AAE9C;AACA;AACA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { BindComponent } from "../types";
1
+ import type { BindComponent } from "../types";
2
2
  interface UseBindProps {
3
3
  Bind: BindComponent;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","useRef","cloneElement","useForm","createValidators","useModelField","createValidationContainer","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","Bind","memoizedBindComponents","cacheKey","form","index","parentName","name","undefined","filter","v","componentId","current","validators","listValidators","isMultipleValues","multipleValues","inputValidators","defaultValueFromSettings","settings","defaultValue","UseBind","params","childName","childValidators","children","createElement","context","bind","props","appendValue","newValue","currentValue","value","newIndex","length","onChange","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","displayName","ValidationContainer"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, cloneElement } from \"react\";\nimport { Validator } from \"@webiny/validation/types\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/createValidators\";\nimport { BindComponent, CmsModelField } from \"~/types\";\nimport { useModelField } from \"~/ModelFieldProvider\";\nimport { createValidationContainer } from \"~/createValidationContainer\";\n\ninterface UseBindProps {\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n defaultValue?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind }: UseBindProps) {\n const { field } = useModelField();\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n // We only use default values for single-value fields.\n const defaultValueFromSettings = !isMultipleValues ? field.settings?.defaultValue : null;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const {\n name: childName,\n validators: childValidators,\n children,\n defaultValue = defaultValueFromSettings\n } = params;\n\n const { field } = useModelField();\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={defaultValue ?? null}\n context={{ field }}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n\n const value = [\n ...bind.value.slice(0, index),\n ...bind.value.slice(index + 1)\n ];\n\n bind.onChange(value.length === 0 ? null : value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n return typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n memoizedBindComponents.current[componentId].ValidationContainer =\n createValidationContainer(name);\n\n return memoizedBindComponents.current[componentId];\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,YAAY,QAAQ,OAAO;AAEnD,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,gBAAgB;AAEzB,SAASC,aAAa;AACtB,SAASC,yBAAyB;AAalC,MAAMC,mBAAmB,GAAIC,KAAoB,IAAK;EAClD,OAAO,CACHA,KAAK,CAACC,EAAE,EACRD,KAAK,CAACE,OAAO,EACbC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACK,UAAU,CAAC,EAChCF,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACM,cAAc,CAAC,CACvC,CAACC,IAAI,CAAC,GAAG,CAAC;AACf,CAAC;AAMD,MAAMC,eAA4B,GAAG,EAAE;AAEvC,OAAO,SAASC,OAAOA,CAAC;EAAEC;AAAmB,CAAC,EAAE;EAC5C,MAAM;IAAEV;EAAM,CAAC,GAAGH,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ACxB,CAAC;QACL;QAEA,OAAO,OAAOR,QAAQ,KAAK,UAAU,GAC/BA,QAAQ,CAACI,KAAK,CAAC,gBACf5C,YAAY,CAACwC,QAAQ,EAAEI,KAAK,CAAC;MACvC,CACE,CAAC;IAEf,CAAkB;;IAElB;IACA3B,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACL,UAAU,GAAGC,IAAI;IAC7DL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACmC,WAAW,GAAG,QAAQvC,IAAI,GAAG;IACzEL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACoC,mBAAmB,GAC3D1D,yBAAyB,CAACkB,IAAI,CAAC;IAEnC,OAAOL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC;EACtD,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"names":["React","useRef","cloneElement","useForm","createValidators","useModelField","createValidationContainer","createFieldCacheKey","field","id","fieldId","JSON","stringify","validation","listValidation","join","emptyValidators","useBind","Bind","memoizedBindComponents","cacheKey","form","index","parentName","name","undefined","filter","v","componentId","current","validators","listValidators","isMultipleValues","multipleValues","inputValidators","defaultValueFromSettings","settings","defaultValue","UseBind","params","childName","childValidators","children","createElement","context","bind","props","appendValue","newValue","currentValue","value","newIndex","length","onChange","slice","prependValue","appendValues","newValues","removeValue","validateInput","moveValueUp","splice","moveValueDown","displayName","ValidationContainer"],"sources":["useBind.tsx"],"sourcesContent":["import React, { useRef, cloneElement } from \"react\";\nimport type { Validator } from \"@webiny/validation/types\";\nimport { useForm } from \"@webiny/form\";\nimport { createValidators } from \"~/createValidators\";\nimport type { BindComponent, CmsModelField } from \"~/types\";\nimport { useModelField } from \"~/ModelFieldProvider\";\nimport { createValidationContainer } from \"~/createValidationContainer\";\n\ninterface UseBindProps {\n Bind: BindComponent;\n}\n\ninterface UseBindParams {\n name?: string;\n validators?: Validator | Validator[];\n children?: any;\n defaultValue?: any;\n}\n\nconst createFieldCacheKey = (field: CmsModelField) => {\n return [\n field.id,\n field.fieldId,\n JSON.stringify(field.validation),\n JSON.stringify(field.listValidation)\n ].join(\";\");\n};\n\nexport interface GetBindCallable {\n (index?: number): BindComponent;\n}\n\nconst emptyValidators: Validator[] = [];\n\nexport function useBind({ Bind }: UseBindProps) {\n const { field } = useModelField();\n const memoizedBindComponents = useRef<Record<string, BindComponent>>({});\n const cacheKey = createFieldCacheKey(field);\n const form = useForm();\n\n return (index = -1) => {\n const { parentName } = Bind;\n\n // If there's a parent name assigned to the given Bind component, we need to include it in the new field \"name\".\n // This allows us to have nested fields (like \"object\" field with nested properties)\n const name = [parentName, field.fieldId, index >= 0 ? index : undefined]\n .filter(v => v !== undefined)\n .join(\".\");\n\n const componentId = `${name};${cacheKey}`;\n\n if (memoizedBindComponents.current[componentId]) {\n return memoizedBindComponents.current[componentId];\n }\n\n const validators = createValidators(field, field.validation || emptyValidators);\n const listValidators = createValidators(field, field.listValidation || emptyValidators);\n const isMultipleValues = index === -1 && field.multipleValues;\n const inputValidators = isMultipleValues ? listValidators : validators;\n\n // We only use default values for single-value fields.\n const defaultValueFromSettings = !isMultipleValues ? field.settings?.defaultValue : null;\n\n memoizedBindComponents.current[componentId] = function UseBind(params: UseBindParams) {\n const {\n name: childName,\n validators: childValidators,\n children,\n defaultValue = defaultValueFromSettings\n } = params;\n\n const { field } = useModelField();\n\n return (\n <Bind\n name={childName || name}\n validators={childValidators || inputValidators}\n defaultValue={defaultValue ?? null}\n context={{ field }}\n >\n {bind => {\n // Multiple-values functions below.\n const props = { ...bind };\n if (field.multipleValues && index === -1) {\n props.appendValue = (newValue: any, index?: number) => {\n const currentValue = bind.value || [];\n const newIndex = index ?? currentValue.length;\n\n bind.onChange([\n ...currentValue.slice(0, newIndex),\n newValue,\n ...currentValue.slice(newIndex)\n ]);\n };\n props.prependValue = (newValue: any) => {\n bind.onChange([newValue, ...(bind.value || [])]);\n };\n props.appendValues = (newValues: any[]) => {\n bind.onChange([...(bind.value || []), ...newValues]);\n };\n\n props.removeValue = (index: number) => {\n if (index < 0) {\n return;\n }\n\n const value = [\n ...bind.value.slice(0, index),\n ...bind.value.slice(index + 1)\n ];\n\n bind.onChange(value.length === 0 ? null : value);\n\n // To make sure the field is still valid, we must trigger validation.\n form.validateInput(field.fieldId);\n };\n\n props.moveValueUp = (index: number) => {\n if (index <= 0) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index - 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n\n props.moveValueDown = (index: number) => {\n if (index >= bind.value.length) {\n return;\n }\n\n const value = [...bind.value];\n value.splice(index, 1);\n value.splice(index + 1, 0, bind.value[index]);\n\n bind.onChange(value);\n };\n }\n\n return typeof children === \"function\"\n ? children(props)\n : cloneElement(children, props);\n }}\n </Bind>\n );\n } as BindComponent;\n\n // We need to keep track of current field name, to support nested fields.\n memoizedBindComponents.current[componentId].parentName = name;\n memoizedBindComponents.current[componentId].displayName = `Bind<${name}>`;\n memoizedBindComponents.current[componentId].ValidationContainer =\n createValidationContainer(name);\n\n return memoizedBindComponents.current[componentId];\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,MAAM,EAAEC,YAAY,QAAQ,OAAO;AAEnD,SAASC,OAAO,QAAQ,cAAc;AACtC,SAASC,gBAAgB;AAEzB,SAASC,aAAa;AACtB,SAASC,yBAAyB;AAalC,MAAMC,mBAAmB,GAAIC,KAAoB,IAAK;EAClD,OAAO,CACHA,KAAK,CAACC,EAAE,EACRD,KAAK,CAACE,OAAO,EACbC,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACK,UAAU,CAAC,EAChCF,IAAI,CAACC,SAAS,CAACJ,KAAK,CAACM,cAAc,CAAC,CACvC,CAACC,IAAI,CAAC,GAAG,CAAC;AACf,CAAC;AAMD,MAAMC,eAA4B,GAAG,EAAE;AAEvC,OAAO,SAASC,OAAOA,CAAC;EAAEC;AAAmB,CAAC,EAAE;EAC5C,MAAM;IAAEV;EAAM,CAAC,GAAG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;UACxB,CAAC;QACL;QAEA,OAAO,OAAOR,QAAQ,KAAK,UAAU,GAC/BA,QAAQ,CAACI,KAAK,CAAC,gBACf5C,YAAY,CAACwC,QAAQ,EAAEI,KAAK,CAAC;MACvC,CACE,CAAC;IAEf,CAAkB;;IAElB;IACA3B,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACL,UAAU,GAAGC,IAAI;IAC7DL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACmC,WAAW,GAAG,QAAQvC,IAAI,GAAG;IACzEL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC,CAACoC,mBAAmB,GAC3D1D,yBAAyB,CAACkB,IAAI,CAAC;IAEnC,OAAOL,sBAAsB,CAACU,OAAO,CAACD,WAAW,CAAC;EACtD,CAAC;AACL","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["plugins","useMemo","useRenderPlugins","byType"],"sources":["useRenderPlugins.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport { useMemo } from \"react\";\nimport { CmsEditorFieldRendererPlugin } from \"~/types\";\n\nexport function useRenderPlugins() {\n return useMemo(\n () => plugins.byType<CmsEditorFieldRendererPlugin>(\"cms-editor-field-renderer\"),\n []\n );\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AACzC,SAASC,OAAO,QAAQ,OAAO;AAG/B,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAC/B,OAAOD,OAAO,CACV,MAAMD,OAAO,CAACG,MAAM,CAA+B,2BAA2B,CAAC,EAC/E,EACJ,CAAC;AACL","ignoreList":[]}
1
+ {"version":3,"names":["plugins","useMemo","useRenderPlugins","byType"],"sources":["useRenderPlugins.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport { useMemo } from \"react\";\nimport type { CmsEditorFieldRendererPlugin } from \"~/types\";\n\nexport function useRenderPlugins() {\n return useMemo(\n () => plugins.byType<CmsEditorFieldRendererPlugin>(\"cms-editor-field-renderer\"),\n []\n );\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AACzC,SAASC,OAAO,QAAQ,OAAO;AAG/B,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAC/B,OAAOD,OAAO,CACV,MAAMD,OAAO,CAACG,MAAM,CAA+B,2BAA2B,CAAC,EAC/E,EACJ,CAAC;AACL","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CmsModelField } from "../types";
2
+ import type { CmsModelField } from "../types";
3
3
  export type ModelFieldContext = CmsModelField;
4
4
  export declare const ModelFieldContext: React.Context<{
5
5
  id: string;
@@ -9,7 +9,7 @@ export declare const ModelFieldContext: React.Context<{
9
9
  label: string;
10
10
  helpText?: string | undefined;
11
11
  placeholderText?: string | undefined;
12
- validation?: (import("@webiny/validation/types").Validator | import("../types").CmsModelFieldValidator)[] | undefined;
12
+ validation?: (import("../types").CmsModelFieldValidator | import("@webiny/validation/types").Validator)[] | undefined;
13
13
  listValidation?: import("../types").CmsModelFieldValidator[] | undefined;
14
14
  multipleValues?: boolean | undefined;
15
15
  predefinedValues?: import("../types").CmsEditorFieldPredefinedValues | undefined;
@@ -1 +1 @@
1
- {"version":3,"names":["React","createGenericContext","ModelFieldContext","createContext","undefined","ModelFieldProvider","field","children","createElement","Provider","value","useHook","ParentValueIndexProvider","useParentValueIndex","context","index"],"sources":["ModelFieldContext.tsx"],"sourcesContent":["import React from \"react\";\nimport { CmsModelField } from \"~/types\";\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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB,QAAQ,mBAAmB;AAIxD,OAAO,MAAMC,iBAAiB,gBAAGF,KAAK,CAACG,aAAa,CAAgCC,SAAS,CAAC;AAO9F,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkC,CAAC,KAAK;EAChF,oBAAOP,KAAA,CAAAQ,aAAA,CAACN,iBAAiB,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAqC,CAAC;AAC5F,CAAC;AAED,MAAM;EAAEE,QAAQ;EAAEE;AAAQ,CAAC,GAAGV,oBAAoB,CAAoB,YAAY,CAAC;AAEnF,OAAO,MAAMW,wBAAwB,GAAGH,QAAQ;AAEhD,OAAO,MAAMI,mBAAmB,GAAGA,CAAA,KAAM;EACrC,IAAI;IACA,MAAMC,OAAO,GAAGH,OAAO,CAAC,CAAC;IACzB,OAAOG,OAAO,CAACC,KAAK;EACxB,CAAC,CAAC,MAAM;IACJ,OAAO,CAAC,CAAC;EACb;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","createGenericContext","ModelFieldContext","createContext","undefined","ModelFieldProvider","field","children","createElement","Provider","value","useHook","ParentValueIndexProvider","useParentValueIndex","context","index"],"sources":["ModelFieldContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModelField } from \"~/types\";\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"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,oBAAoB,QAAQ,mBAAmB;AAIxD,OAAO,MAAMC,iBAAiB,gBAAGF,KAAK,CAACG,aAAa,CAAgCC,SAAS,CAAC;AAO9F,OAAO,MAAMC,kBAAkB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAkC,CAAC,KAAK;EAChF,oBAAOP,KAAA,CAAAQ,aAAA,CAACN,iBAAiB,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAqC,CAAC;AAC5F,CAAC;AAED,MAAM;EAAEE,QAAQ;EAAEE;AAAQ,CAAC,GAAGV,oBAAoB,CAAoB,YAAY,CAAC;AAEnF,OAAO,MAAMW,wBAAwB,GAAGH,QAAQ;AAEhD,OAAO,MAAMI,mBAAmB,GAAGA,CAAA,KAAM;EACrC,IAAI;IACA,MAAMC,OAAO,GAAGH,OAAO,CAAC,CAAC;IACzB,OAAOG,OAAO,CAACC,KAAK;EACxB,CAAC,CAAC,MAAM;IACJ,OAAO,CAAC,CAAC;EACb;AACJ,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CmsModelField, CmsModelFieldTypePlugin } from "../types";
2
+ import type { CmsModelField, CmsModelFieldTypePlugin } from "../types";
3
3
  export interface UseModelField {
4
4
  field: CmsModelField;
5
5
  parentValueIndex: number;
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","plugins","makeDecoratable","ModelFieldContext","useParentValueIndex","getFieldPlugin","type","plugin","byType","find","field","Error","useModelField","parentValueIndex","fieldPlugin"],"sources":["useModelField.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { ModelFieldContext, useParentValueIndex } from \"./ModelFieldContext\";\nimport { CmsModelField, CmsModelFieldTypePlugin } from \"~/types\";\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 const parentValueIndex = useParentValueIndex();\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 fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,iBAAiB,EAAEC,mBAAmB;AAO/C,MAAMC,cAA8B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,MAAM,GAAGN,OAAO,CACjBO,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,IAAI,CAACF,MAAM,IAAIA,MAAM,CAACG,KAAK,CAACJ,IAAI,KAAKA,IAAI,CAAC;EAE/C,IAAI,CAACC,MAAM,EAAE;IACT,MAAMI,KAAK,CAAC,kCAAkCL,IAAI,IAAI,CAAC;EAC3D;EAEA,OAAOC,MAAM;AACjB,CAAC;AAQD;AACA;AACA;AACA,OAAO,MAAMK,aAAa,GAAGV,eAAe,CAAC,MAAqB;EAC9D,MAAMQ,KAAK,GAAGV,UAAU,CAACG,iBAAiB,CAAC;EAC3C,MAAMU,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,IAAI,CAACM,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,kHACJ,CAAC;EACL;EAEA,MAAMG,WAAW,GAAGT,cAAc,CAACK,KAAK,CAACJ,IAAI,CAAC;EAE9C,OAAO;IAAEI,KAAK;IAAEI,WAAW;IAAED;EAAiB,CAAC;AACnD,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["useContext","plugins","makeDecoratable","ModelFieldContext","useParentValueIndex","getFieldPlugin","type","plugin","byType","find","field","Error","useModelField","parentValueIndex","fieldPlugin"],"sources":["useModelField.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { plugins } from \"@webiny/plugins\";\nimport { makeDecoratable } from \"@webiny/react-composition\";\nimport { ModelFieldContext, useParentValueIndex } from \"./ModelFieldContext\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types\";\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 const parentValueIndex = useParentValueIndex();\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 fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,OAAO,QAAQ,iBAAiB;AACzC,SAASC,eAAe,QAAQ,2BAA2B;AAC3D,SAASC,iBAAiB,EAAEC,mBAAmB;AAO/C,MAAMC,cAA8B,GAAGC,IAAI,IAAI;EAC3C,MAAMC,MAAM,GAAGN,OAAO,CACjBO,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,IAAI,CAACF,MAAM,IAAIA,MAAM,CAACG,KAAK,CAACJ,IAAI,KAAKA,IAAI,CAAC;EAE/C,IAAI,CAACC,MAAM,EAAE;IACT,MAAMI,KAAK,CAAC,kCAAkCL,IAAI,IAAI,CAAC;EAC3D;EAEA,OAAOC,MAAM;AACjB,CAAC;AAQD;AACA;AACA;AACA,OAAO,MAAMK,aAAa,GAAGV,eAAe,CAAC,MAAqB;EAC9D,MAAMQ,KAAK,GAAGV,UAAU,CAACG,iBAAiB,CAAC;EAC3C,MAAMU,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,IAAI,CAACM,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,kHACJ,CAAC;EACL;EAEA,MAAMG,WAAW,GAAGT,cAAc,CAACK,KAAK,CAACJ,IAAI,CAAC;EAE9C,OAAO;IAAEI,KAAK;IAAEI,WAAW;IAAED;EAAiB,CAAC;AACnD,CAAC,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { CmsModel } from "../types";
2
+ import type { CmsModel } from "../types";
3
3
  export type ModelContext = CmsModel;
4
4
  export declare const ModelContext: React.Context<CmsModel | undefined>;
5
5
  export interface ModelProviderProps {
@@ -1 +1 @@
1
- {"version":3,"names":["React","ModelContext","createContext","undefined","ModelProvider","model","children","createElement","Provider","value"],"sources":["ModelContext.tsx"],"sourcesContent":["import React from \"react\";\nimport { CmsModel } from \"~/types\";\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 <ModelContext.Provider value={model}>{children}</ModelContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAKzB,OAAO,MAAMC,YAAY,gBAAGD,KAAK,CAACE,aAAa,CAA2BC,SAAS,CAAC;AAOpF,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAA6B,CAAC,KAAK;EACtE,oBAAON,KAAA,CAAAO,aAAA,CAACN,YAAY,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAgC,CAAC;AAClF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["React","ModelContext","createContext","undefined","ModelProvider","model","children","createElement","Provider","value"],"sources":["ModelContext.tsx"],"sourcesContent":["import React from \"react\";\nimport type { CmsModel } from \"~/types\";\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 <ModelContext.Provider value={model}>{children}</ModelContext.Provider>;\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAKzB,OAAO,MAAMC,YAAY,gBAAGD,KAAK,CAACE,aAAa,CAA2BC,SAAS,CAAC;AAOpF,OAAO,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAA6B,CAAC,KAAK;EACtE,oBAAON,KAAA,CAAAO,aAAA,CAACN,YAAY,CAACO,QAAQ;IAACC,KAAK,EAAEJ;EAAM,GAAEC,QAAgC,CAAC;AAClF,CAAC","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModel } from "../types";
1
+ import type { CmsModel } from "../types";
2
2
  type UseModelReturnType = {
3
3
  model: CmsModel;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useContext","ModelContext","useModel","model","Error"],"sources":["useModel.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ModelContext } from \"./ModelContext\";\nimport { CmsModel } from \"~/types\";\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"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,YAAY;AAOrB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAuB;EAC3C,MAAMC,KAAK,GAAGH,UAAU,CAACC,YAAY,CAAC;EACtC,IAAI,CAACE,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,uGACJ,CAAC;EACL;EAEA,OAAO;IAAED;EAAM,CAAC;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["useContext","ModelContext","useModel","model","Error"],"sources":["useModel.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { ModelContext } from \"./ModelContext\";\nimport type { CmsModel } from \"~/types\";\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"],"mappings":"AAAA,SAASA,UAAU,QAAQ,OAAO;AAClC,SAASC,YAAY;AAOrB;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAAA,EAAuB;EAC3C,MAAMC,KAAK,GAAGH,UAAU,CAACC,YAAY,CAAC;EACtC,IAAI,CAACE,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,uGACJ,CAAC;EACL;EAEA,OAAO;IAAED;EAAM,CAAC;AACpB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { CmsModel, CmsModelField } from "./types";
1
+ import type { CmsModel, CmsModelField } from "./types";
2
2
  interface CreateFieldsListParams {
3
3
  model: CmsModel;
4
4
  fields: CmsModelField[];
@@ -1 +1 @@
1
- {"version":3,"names":["plugins","createFieldsList","model","fields","inputFields","graphQLTypePrefix","fieldPlugins","byType","reduce","acc","item","field","type","typePrefix","singularApiName","map","console","log","graphql","queryField","selection","fieldId","filter","Boolean","length","push","join"],"sources":["createFieldsList.ts"],"sourcesContent":["import { CmsModel, CmsModelField, CmsModelFieldTypePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface CreateFieldsListParams {\n model: CmsModel;\n fields: CmsModelField[];\n graphQLTypePrefix?: string;\n}\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"],"mappings":"AACA,SAASA,OAAO,QAAQ,iBAAiB;AAQzC,OAAO,SAASC,gBAAgBA,CAAC;EAC7BC,KAAK;EACLC,MAAM,EAAEC,WAAW;EACnBC;AACoB,CAAC,EAAU;EAC/B,MAAMC,YAA8D,GAAGN,OAAO,CACzEO,MAAM,CAA0B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","model","fields","inputFields","graphQLTypePrefix","fieldPlugins","byType","reduce","acc","item","field","type","typePrefix","singularApiName","map","console","log","graphql","queryField","selection","fieldId","filter","Boolean","length","push","join"],"sources":["createFieldsList.ts"],"sourcesContent":["import type { CmsModel, CmsModelField, CmsModelFieldTypePlugin } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface CreateFieldsListParams {\n model: CmsModel;\n fields: CmsModelField[];\n graphQLTypePrefix?: string;\n}\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"],"mappings":"AACA,SAASA,OAAO,QAAQ,iBAAiB;AAQzC,OAAO,SAASC,gBAAgBA,CAAC;EAC7BC,KAAK;EACLC,MAAM,EAAEC,WAAW;EACnBC;AACoB,CAAC,EAAU;EAC/B,MAAMC,YAA8D,GAAGN,OAAO,CACzEO,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,MAAM;IAAE,GAAGD,GAAG;IAAE,CAACC,IAAI,CAACC,KAAK,CAACC,IAAI,GAAGF,IAAI,CAACC;EAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAE3E,MAAME,UAAU,GAAGR,iBAAiB,IAAIH,KAAK,CAACY,eAAe;EAE7D,MAAMX,MAAM,GAAGC,WAAW,CACrBW,GAAG,CAACJ,KAAK,IAAI;IACV,IAAI,CAACL,YAAY,CAACK,KAAK,CAACC,IAAI,CAAC,EAAE;MAC3BI,OAAO,CAACC,GAAG,CAAC,wCAAwCN,KAAK,CAACC,IAAI,IAAI,CAAC;MACnE,OAAO,IAAI;IACf;IACA,MAAM;MAAEM;IAAQ,CAAC,GAAGZ,YAAY,CAACK,KAAK,CAACC,IAAI,CAAC;IAE5C,IAAIM,OAAO,IAAIA,OAAO,CAACC,UAAU,EAAE;MAC/B,MAAM;QAAEA;MAAW,CAAC,GAAGD,OAAO;MAC9B,MAAME,SAAS,GACX,OAAOD,UAAU,KAAK,QAAQ,GACxBA,UAAU,GACVA,UAAU,CAAC;QAAEjB,KAAK;QAAES,KAAK;QAAEN,iBAAiB,EAAEQ;MAAW,CAAC,CAAC;;MAErE;AAChB;AACA;MACgB,IAAIO,SAAS,KAAK,IAAI,EAAE;QACpB,OAAO,IAAI;MACf;MAEA,OAAO,GAAGT,KAAK,CAACU,OAAO,IAAID,SAAS,EAAE;IAC1C;IAEA,OAAOT,KAAK,CAACU,OAAO;EACxB,CAAC,CAAC,CACDC,MAAM,CAACC,OAAO,CAAC;EACpB;AACJ;AACA;EACI,IAAIpB,MAAM,CAACqB,MAAM,KAAK,CAAC,EAAE;IACrBrB,MAAM,CAACsB,IAAI,CAAC,QAAQ,CAAC;EACzB;EACA,OAAOtB,MAAM,CAACuB,IAAI,CAAC,IAAI,CAAC;AAC5B","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import { CmsModelField, CmsModelFieldValidator } from "./types";
2
- import { Validator } from "@webiny/validation/types";
1
+ import type { CmsModelField, CmsModelFieldValidator } from "./types";
2
+ import type { Validator } from "@webiny/validation/types";
3
3
  export declare const createValidators: (field: CmsModelField, validation: (CmsModelFieldValidator | Validator)[]) => Validator[];
@@ -1 +1 @@
1
- {"version":3,"names":["plugins","camelCase","createValidators","field","validation","validatorPlugins","byType","reduce","collection","item","validatorPlugin","find","plugin","validator","name","validate","value","isInvalid","message","result","e","interpolated","getVariableValues","variables","Object","keys","forEach","key","regex","RegExp","replace","Error","validatorName","push"],"sources":["createValidators.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport { CmsModelField, CmsModelFieldValidator, CmsModelFieldValidatorPlugin } from \"~/types\";\nimport { Validator } from \"@webiny/validation/types\";\nimport camelCase from \"lodash/camelCase\";\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"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AAGzC,OAAOC,SAAS,MAAM,kBAAkB;AAExC,OAAO,MAAMC,gBAAgB,GAAGA,CAC5BC,KAAoB,EACpBC,UAAkD,KACpC;EACd,MAAMC,gBAAgB,GAAGL,OAAO,CAACM,MAAM,CACnC,2BACJ,CAAC;EAED,OAAOF,UAAU,CAACG,MAAM,CAAc,CAACC,UAAU,EAAEC,IAAI,KAAK;IACxD,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;MAC5B,OAAO,CAAC,GAAGD,UAAU,EAAEC,IAAI,CAAC;IAChC;IAEA,MAAMC,eAAe,GAAGL,gBAAgB,CAACM,IAAI,CACzCC,MAAM,IAAIA,MAAM,CAACC,SAAS,CAACC,IAAI,KAAKL,IAAI,CAACK,IAC7C,CAAC;IAED,IAAI,CAACJ,eAAe,IAAI,OAAOA,eAAe,CAACG,SAAS,CAACE,QAAQ,KAAK,UAAU,EAAE;MAC9E,OAAOP,UAAU;IACrB;IAEA,MAAMK,SAAS,GAAG,MAAOG,KAAkB,IAAK;MAC5C,IAAIC,SAAS;MACb,IAAIC,OAAO,GAAGT,IAAI,CAACS,OAAO;MAC1B,IAAI;QACA,MAAMC,MAAM,GAAG,MAAMT,eAAe,CAACG,SAAS,CAACE,QAAQ,CAACC,KAAK,EAAE;UAC3DH,SAAS,EAAEJ,IAAI;UACfN;QACJ,CAAC,CAAC;QAEFc,SAAS,GAAGE,MAAM,KAAK,KAAK;MAChC,CAAC,CAAC,OAAOC,CAAC,EAAE;QACRH,SAAS,GAAG,IAAI;QAChB,IAAIG,CAAC,CAACF,OAAO,IAAI,CAACT,IAAI,CAACS,OAAO,EAAE;UAC5BA,OAAO,GAAGE,CAAC,CAACF,OAAO;QACvB;MACJ;MAEA,IAAID,SAAS,EAAE;QACX,IAAII,YAAY,GAAGH,OAAO,IAAI,gBAAgB;QAE9C,MAAMI,iBAAiB,GAAGZ,eAAe,CAACG,SAAS,CAACS,iBAAiB;QACrE,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;UACzC,MAAMC,SAAS,GAAGD,iBAAiB,CAAC;YAAET,SAAS,EAAEJ;UAAK,CAAC,CAAC;UAExDe,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC,CAACG,OAAO,CAACC,GAAG,IAAI;YAClC,MAAMC,KAAK,GAAG,IAAIC,MAAM,CAAC,KAAKF,GAAG,IAAI,EAAE,GAAG,CAAC;YAC3CN,YAAY,GAAGA,YAAY,CAACS,OAAO,CAACF,KAAK,EAAEL,SAAS,CAACI,GAAG,CAAC,CAAC;UAC9D,CAAC,CAAC;QACN;QAEA,MAAM,IAAII,KAAK,CAACV,YAAY,CAAC;MACjC;IACJ,CAAC;IACD;AACR;AACA;IACQR,SAAS,CAACmB,aAAa,GAAG/B,SAAS,CAACS,eAAe,CAACG,SAAS,CAACC,IAAI,CAAC;IAEnEN,UAAU,CAACyB,IAAI,CAACpB,SAAS,CAAC;IAC1B,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAiB,CAAC;AACzB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["plugins","camelCase","createValidators","field","validation","validatorPlugins","byType","reduce","collection","item","validatorPlugin","find","plugin","validator","name","validate","value","isInvalid","message","result","e","interpolated","getVariableValues","variables","Object","keys","forEach","key","regex","RegExp","replace","Error","validatorName","push"],"sources":["createValidators.ts"],"sourcesContent":["import { plugins } from \"@webiny/plugins\";\nimport type { CmsModelField, CmsModelFieldValidator, CmsModelFieldValidatorPlugin } from \"~/types\";\nimport type { Validator } from \"@webiny/validation/types\";\nimport camelCase from \"lodash/camelCase\";\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"],"mappings":"AAAA,SAASA,OAAO,QAAQ,iBAAiB;AAGzC,OAAOC,SAAS,MAAM,kBAAkB;AAExC,OAAO,MAAMC,gBAAgB,GAAGA,CAC5BC,KAAoB,EACpBC,UAAkD,KACpC;EACd,MAAMC,gBAAgB,GAAGL,OAAO,CAACM,MAAM,CACnC,2BACJ,CAAC;EAED,OAAOF,UAAU,CAACG,MAAM,CAAc,CAACC,UAAU,EAAEC,IAAI,KAAK;IACxD,IAAI,OAAOA,IAAI,KAAK,UAAU,EAAE;MAC5B,OAAO,CAAC,GAAGD,UAAU,EAAEC,IAAI,CAAC;IAChC;IAEA,MAAMC,eAAe,GAAGL,gBAAgB,CAACM,IAAI,CACzCC,MAAM,IAAIA,MAAM,CAACC,SAAS,CAACC,IAAI,KAAKL,IAAI,CAACK,IAC7C,CAAC;IAED,IAAI,CAACJ,eAAe,IAAI,O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,CAAC;IAEnEN,UAAU,CAACyB,IAAI,CAACpB,SAAS,CAAC;IAC1B,OAAOL,UAAU;EACrB,CAAC,EAAE,EAAiB,CAAC;AACzB,CAAC","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { CmsContentEntryRevision, CmsContentEntry, CmsEditorContentModel, CmsErrorResponse, CmsMetaResponse, CmsModelField } from "./types";
2
- import { FormValidationOptions } from "@webiny/form";
1
+ import type { CmsContentEntryRevision, CmsContentEntry, CmsEditorContentModel, CmsErrorResponse, CmsMetaResponse, CmsModelField } from "./types";
2
+ import type { FormValidationOptions } from "@webiny/form";
3
3
  /**
4
4
  * ############################################
5
5
  * Get CMS Entry Query
@@ -1 +1 @@
1
- {"version":3,"names":["gql","createFieldsList","getModelTitleFieldId","CMS_MODEL_SINGLETON_TAG","CONTENT_META_FIELDS","createEntrySystemFields","model","isSingletonModel","tags","includes","optionalFields","ERROR_FIELD","createReadQuery","singularApiName","fields","createReadSingletonQuery","createRevisionsQuery","createListQueryDataSelection","createListQuery","deleted","queryName","pluralApiName","createDeleteMutation","createRestoreFromBinMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createUpdateSingletonMutation","createPublishMutation","createUnpublishMutation","createBulkActionMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport {\n CmsContentEntryRevision,\n CmsContentEntry,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModelField,\n CmsModel\n} from \"~/types\";\nimport { createFieldsList } from \"./createFieldsList\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId\";\nimport { FormValidationOptions } from \"@webiny/form\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"./constants\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n title\n description\n image\n version\n locked\n status\n`;\n\nconst createEntrySystemFields = (model: CmsModel) => {\n const isSingletonModel = model.tags.includes(CMS_MODEL_SINGLETON_TAG);\n\n let optionalFields = \"\";\n if (!isSingletonModel) {\n optionalFields = `\n wbyAco_location {\n folderId\n }\n meta {\n ${CONTENT_META_FIELDS}\n }\n `;\n }\n\n return /* GraphQL */ `\n id\n entryId\n createdOn\n savedOn\n modifiedOn,\n deletedOn\n firstPublishedOn\n lastPublishedOn\n createdBy {\n id\n type\n displayName\n }\n savedBy {\n id\n type\n displayName\n }\n modifiedBy {\n id\n type\n displayName\n }\n deletedBy {\n id\n type\n displayName\n }\n firstPublishedBy {\n id\n type\n displayName\n }\n lastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\n revisionDeletedOn\n revisionFirstPublishedOn\n revisionLastPublishedOn\n revisionCreatedBy {\n id\n type\n displayName\n }\n revisionSavedBy {\n id\n type\n displayName\n }\n revisionModifiedBy {\n id\n type\n displayName\n }\n revisionDeletedBy {\n id\n type\n displayName\n }\n revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n ${optionalFields}\n `;\n};\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n message\n code\n data\n }\n`;\n\n/**\n * ############################################\n * Get CMS Entry Query\n */\nexport interface CmsEntryGetQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryGetQueryVariables {\n revision?: string;\n entryId?: string;\n}\n\nexport const createReadQuery = (model: CmsEditorContentModel) => {\n /**\n * This query now accepts both revision or entryId as we can load exact revision or latest (if entryId was sent).\n */\n return gql`\n query CmsEntriesGet${model.singularApiName}($revision: ID, $entryId: ID) {\n content: get${model.singularApiName}(revision: $revision, entryId: $entryId) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Get CMS Singleton Entry Query\n */\nexport interface CmsEntryGetSingletonQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport const createReadSingletonQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntryGetSingleton${model.singularApiName} {\n content: get${model.singularApiName} {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entry Revisions Query\n */\nexport interface CmsEntriesListRevisionsQueryResponse {\n revisions: {\n data: CmsContentEntryRevision[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListRevisionsQueryVariables {\n id: string;\n}\n\nexport const createRevisionsQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntriesGet${model.singularApiName}Revisions($id: ID!) {\n revisions: get${model.singularApiName}Revisions(id: $id) {\n data {\n ${createEntrySystemFields(model)}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entries Query\n */\nexport interface CmsEntriesListQueryResponse {\n content: {\n data: CmsContentEntry[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListQueryVariables {\n // TODO @ts-refactor better list types\n where?: {\n [key: string]: any;\n };\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport const createListQueryDataSelection = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[]\n) => {\n return `\n ${createEntrySystemFields(model)}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\n `;\n};\n\nexport const createListQuery = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[],\n deleted?: boolean\n) => {\n const queryName = deleted ? `Deleted${model.pluralApiName}` : model.pluralApiName;\n\n return gql`\n query CmsEntriesList${queryName}($where: ${model.singularApiName}ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${queryName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${createListQueryDataSelection(model, fields)}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Delete Mutation\n */\nexport interface CmsEntryDeleteMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryDeleteMutationVariables {\n revision: string;\n permanently?: boolean;\n}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!, $permanently: Boolean) {\n content: delete${model.singularApiName}(revision: $revision, options: {permanently: $permanently}) {\n data\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Restore from bin Mutation\n */\nexport interface CmsEntryRestoreFromBinMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryRestoreFromBinMutationVariables {\n revision: string;\n}\n\nexport const createRestoreFromBinMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesRestore${model.singularApiName}FromBin($revision: ID!) {\n content: restore${model.singularApiName}FromBin(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create Mutation\n */\nexport interface CmsEntryCreateMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryCreateMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createCreateMutation = (model: CmsEditorContentModel) => {\n const createFields = createFieldsList({ model, fields: model.fields });\n\n return gql`\n mutation CmsEntriesCreate${model.singularApiName}($data: ${\n model.singularApiName\n }Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFields}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create From Mutation\n */\nexport interface CmsEntryCreateFromMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryCreateFromMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data?: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createCreateFromMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${\n model.singularApiName\n }Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${\n model.singularApiName\n }From(revision: $revision, data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Update Mutation\n */\nexport interface CmsEntryUpdateMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUpdateMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createUpdateMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($revision: ID!, $data: ${\n model.singularApiName\n }Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update${\n model.singularApiName\n }(revision: $revision, data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Update Singleton Mutation\n */\nexport interface CmsEntryUpdateSingletonMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUpdateSingletonMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createUpdateSingletonMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($data: ${\n model.singularApiName\n }Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update${model.singularApiName}(data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Publish Mutation\n */\nexport interface CmsEntryPublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryPublishMutationVariables {\n revision: string;\n}\n\nexport const createPublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsPublish${model.singularApiName}($revision: ID!) {\n content: publish${model.singularApiName}(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Unpublish Mutation\n */\nexport interface CmsEntryUnpublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUnpublishMutationVariables {\n revision: string;\n}\n\nexport const createUnpublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUnpublish${model.singularApiName}($revision: ID!) {\n content: unpublish${model.singularApiName}(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Bulk Action Mutation\n */\nexport interface CmsEntryBulkActionMutationResponse {\n content: {\n data?: {\n id: string;\n };\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryBulkActionMutationVariables {\n action: string;\n where?: {\n [key: string]: any;\n };\n search?: string;\n data?: {\n [key: string]: any;\n };\n}\n\nexport const createBulkActionMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsBulkAction${model.singularApiName}($action: BulkAction${model.singularApiName}Name!, $where: ${model.singularApiName}ListWhereInput, $search: String, $data: JSON) {\n content: bulkAction${model.singularApiName}(action: $action, where: $where, search: $search, data: $data) {\n data {\n id\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,aAAa;AAU7B,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAE7B,SAASC,uBAAuB;AAEhC,MAAMC,mBAAmB,GAAG,aAAc;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,uBAAuB,GAAIC,KAAe,IAAK;EACjD,MAAMC,gBAAgB,GAAGD,KAAK,CAACE,IAAI,CAACC,QAAQ,CAACN,uBAAuB,CAAC;EAErE,IAAIO,cAAc,GAAG,EAAE;EACvB,IAAI,CAACH,gBAAgB,EAAE;IACnBG,cAAc,GAAG;AACzB;AACA;AACA;AACA;AACA,kBAAkBN,mBAAmB;AACrC;AACA,SAAS;EACL;EAEA,OAAO,aAAc;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUM,cAAc;AACxB,KAAK;AACL,CAAC;AAED,MAAMC,WAAW,GAAG,aAAc;AAClC;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAaA,OAAO,MAAMC,eAAe,GAAIN,KAA4B,IAAK;EAC7D;AACJ;AACA;EACI,OAAON,GAAG;AACd,6BAA6BM,KAAK,CAACO,eAAe;AAClD,0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AER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACnE;AACA,oBAAoBH,WAAW;AAC/B;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;;AAYA,OAAO,MAAMkB,qBAAqB,GAAIvB,KAA4B,IAAK;EACnE,OAAON,GAAG;AACd,6BAA6BM,KAAK,CAACO,eAAe;AAClD,8BAA8BP,KAAK,CAACO,eAAe;AACnD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD,sBAAsBL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACvE;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAYA,OAAO,MAAMmB,uBAAuB,GAAIxB,KAA4B,IAAK;EACrE,OAAON,GAAG;AACd,+BAA+BM,KAAK,CAACO,eAAe;AACpD,gCAAgCP,KAAK,CAACO,eAAe;AACrD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD,sBAAsBL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACvE;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAqBA,OAAO,MAAMoB,wBAAwB,GAAIzB,KAA4B,IAAK;EACtE,OAAON,GAAG;AACd,gCAAgCM,KAAK,CAACO,eAAe,uBAAuBP,KAAK,CAACO,eAAe,kBAAkBP,KAAK,CAACO,eAAe;AACxI,iCAAiCP,KAAK,CAACO,eAAe;AACtD;AACA;AACA;AACA,wBAAwBF,WAAW;AACnC;AACA,UAAU;AACV,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["gql","createFieldsList","getModelTitleFieldId","CMS_MODEL_SINGLETON_TAG","CONTENT_META_FIELDS","createEntrySystemFields","model","isSingletonModel","tags","includes","optionalFields","ERROR_FIELD","createReadQuery","singularApiName","fields","createReadSingletonQuery","createRevisionsQuery","createListQueryDataSelection","createListQuery","deleted","queryName","pluralApiName","createDeleteMutation","createRestoreFromBinMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createUpdateSingletonMutation","createPublishMutation","createUnpublishMutation","createBulkActionMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type {\n CmsContentEntryRevision,\n CmsContentEntry,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModelField,\n CmsModel\n} from \"~/types\";\nimport { createFieldsList } from \"./createFieldsList\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId\";\nimport type { FormValidationOptions } from \"@webiny/form\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"./constants\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n title\n description\n image\n version\n locked\n status\n`;\n\nconst createEntrySystemFields = (model: CmsModel) => {\n const isSingletonModel = model.tags.includes(CMS_MODEL_SINGLETON_TAG);\n\n let optionalFields = \"\";\n if (!isSingletonModel) {\n optionalFields = `\n wbyAco_location {\n folderId\n }\n meta {\n ${CONTENT_META_FIELDS}\n }\n `;\n }\n\n return /* GraphQL */ `\n id\n entryId\n createdOn\n savedOn\n modifiedOn,\n deletedOn\n firstPublishedOn\n lastPublishedOn\n createdBy {\n id\n type\n displayName\n }\n savedBy {\n id\n type\n displayName\n }\n modifiedBy {\n id\n type\n displayName\n }\n deletedBy {\n id\n type\n displayName\n }\n firstPublishedBy {\n id\n type\n displayName\n }\n lastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\n revisionDeletedOn\n revisionFirstPublishedOn\n revisionLastPublishedOn\n revisionCreatedBy {\n id\n type\n displayName\n }\n revisionSavedBy {\n id\n type\n displayName\n }\n revisionModifiedBy {\n id\n type\n displayName\n }\n revisionDeletedBy {\n id\n type\n displayName\n }\n revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n ${optionalFields}\n `;\n};\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n message\n code\n data\n }\n`;\n\n/**\n * ############################################\n * Get CMS Entry Query\n */\nexport interface CmsEntryGetQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryGetQueryVariables {\n revision?: string;\n entryId?: string;\n}\n\nexport const createReadQuery = (model: CmsEditorContentModel) => {\n /**\n * This query now accepts both revision or entryId as we can load exact revision or latest (if entryId was sent).\n */\n return gql`\n query CmsEntriesGet${model.singularApiName}($revision: ID, $entryId: ID) {\n content: get${model.singularApiName}(revision: $revision, entryId: $entryId) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Get CMS Singleton Entry Query\n */\nexport interface CmsEntryGetSingletonQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport const createReadSingletonQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntryGetSingleton${model.singularApiName} {\n content: get${model.singularApiName} {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entry Revisions Query\n */\nexport interface CmsEntriesListRevisionsQueryResponse {\n revisions: {\n data: CmsContentEntryRevision[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListRevisionsQueryVariables {\n id: string;\n}\n\nexport const createRevisionsQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntriesGet${model.singularApiName}Revisions($id: ID!) {\n revisions: get${model.singularApiName}Revisions(id: $id) {\n data {\n ${createEntrySystemFields(model)}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entries Query\n */\nexport interface CmsEntriesListQueryResponse {\n content: {\n data: CmsContentEntry[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListQueryVariables {\n // TODO @ts-refactor better list types\n where?: {\n [key: string]: any;\n };\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport const createListQueryDataSelection = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[]\n) => {\n return `\n ${createEntrySystemFields(model)}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\n `;\n};\n\nexport const createListQuery = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[],\n deleted?: boolean\n) => {\n const queryName = deleted ? `Deleted${model.pluralApiName}` : model.pluralApiName;\n\n return gql`\n query CmsEntriesList${queryName}($where: ${model.singularApiName}ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${queryName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${createListQueryDataSelection(model, fields)}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Delete Mutation\n */\nexport interface CmsEntryDeleteMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryDeleteMutationVariables {\n revision: string;\n permanently?: boolean;\n}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!, $permanently: Boolean) {\n content: delete${model.singularApiName}(revision: $revision, options: {permanently: $permanently}) {\n data\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Restore from bin Mutation\n */\nexport interface CmsEntryRestoreFromBinMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryRestoreFromBinMutationVariables {\n revision: string;\n}\n\nexport const createRestoreFromBinMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesRestore${model.singularApiName}FromBin($revision: ID!) {\n content: restore${model.singularApiName}FromBin(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create Mutation\n */\nexport interface CmsEntryCreateMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryCreateMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createCreateMutation = (model: CmsEditorContentModel) => {\n const createFields = createFieldsList({ model, fields: model.fields });\n\n return gql`\n mutation CmsEntriesCreate${model.singularApiName}($data: ${\n model.singularApiName\n }Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFields}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create From Mutation\n */\nexport interface CmsEntryCreateFromMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryCreateFromMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data?: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createCreateFromMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${\n model.singularApiName\n }Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${\n model.singularApiName\n }From(revision: $revision, data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Update Mutation\n */\nexport interface CmsEntryUpdateMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUpdateMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createUpdateMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($revision: ID!, $data: ${\n model.singularApiName\n }Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update${\n model.singularApiName\n }(revision: $revision, data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Update Singleton Mutation\n */\nexport interface CmsEntryUpdateSingletonMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUpdateSingletonMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createUpdateSingletonMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($data: ${\n model.singularApiName\n }Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update${model.singularApiName}(data: $data, options: $options) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Publish Mutation\n */\nexport interface CmsEntryPublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryPublishMutationVariables {\n revision: string;\n}\n\nexport const createPublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsPublish${model.singularApiName}($revision: ID!) {\n content: publish${model.singularApiName}(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Unpublish Mutation\n */\nexport interface CmsEntryUnpublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUnpublishMutationVariables {\n revision: string;\n}\n\nexport const createUnpublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUnpublish${model.singularApiName}($revision: ID!) {\n content: unpublish${model.singularApiName}(revision: $revision) {\n data {\n ${createEntrySystemFields(model)}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Bulk Action Mutation\n */\nexport interface CmsEntryBulkActionMutationResponse {\n content: {\n data?: {\n id: string;\n };\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryBulkActionMutationVariables {\n action: string;\n where?: {\n [key: string]: any;\n };\n search?: string;\n data?: {\n [key: string]: any;\n };\n}\n\nexport const createBulkActionMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsBulkAction${model.singularApiName}($action: BulkAction${model.singularApiName}Name!, $where: ${model.singularApiName}ListWhereInput, $search: String, $data: JSON) {\n content: bulkAction${model.singularApiName}(action: $action, where: $where, search: $search, data: $data) {\n data {\n id\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":"AAAA,OAAOA,GAAG,MAAM,aAAa;AAU7B,SAASC,gBAAgB;AACzB,SAASC,oBAAoB;AAE7B,SAASC,uBAAuB;AAEhC,MAAMC,mBAAmB,GAAG,aAAc;AAC1C;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,uBAAuB,GAAIC,KAAe,IAAK;EACjD,MAAMC,gBAAgB,GAAGD,KAAK,CAACE,IAAI,CAACC,QAAQ,CAACN,uBAAuB,CAAC;EAErE,IAAIO,cAAc,GAAG,EAAE;EACvB,IAAI,CAACH,gBAAgB,EAAE;IACnBG,cAAc,GAAG;AACzB;AACA;AACA;AACA;AACA,kBAAkBN,mBAAmB;AACrC;AACA,SAAS;EACL;EAEA,OAAO,aAAc;AACzB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUM,cAAc;AACxB,KAAK;AACL,CAAC;AAED,MAAMC,WAAW,GAAG,aAAc;AAClC;AACA;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACA;;AAaA,OAAO,MAAMC,eAAe,GAAIN,KAA4B,IAAK;EAC7D;AACJ;AACA;EACI,OAAON,GAAG;AACd,6BAA6BM,KAAK,CAACO,eAAe;AAClD,0BAA0BP,KAAK,CAACO,eAAe;AAC/C;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD,sBAAsBL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACvE;AACA,wBAAwBH,WAAW;AACnC;AACA;AACA,KAAK;AACL,CAAC;;AAED;AACA;AACA;AACA;;AAQA,OAAO,MAAMI,wBAAwB,GAAIT,KAA4B,IAAK;EACtE,OAAON,GAAG;AACd,oCAAoCM,KAAK,CAACO,eAAe;AACzD,0BAA0BP,KAAK,CAACO,eAAe;AAC/C;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD,sBAAsBL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACvE;AACA,wBAAwBH,WAAW;AACnC;AACA;AACA,KAAK;AACL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CAAgCP,KAAK,CAACO,eAAe;AACrD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD,sBAAsBL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AACvE;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAqBA,OAAO,MAAMoB,wBAAwB,GAAIzB,KAA4B,IAAK;EACtE,OAAON,GAAG;AACd,gCAAgCM,KAAK,CAACO,eAAe,uBAAuBP,KAAK,CAACO,eAAe,kBAAkBP,KAAK,CAACO,eAAe;AACxI,iCAAiCP,KAAK,CAACO,eAAe;AACtD;AACA;AACA;AACA,wBAAwBF,WAAW;AACnC;AACA,UAAU;AACV,CAAC","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import { CmsEditorContentModel } from "./types";
1
+ import type { CmsEditorContentModel } from "./types";
2
2
  export declare const getModelTitleFieldId: (model: CmsEditorContentModel) => string;
@@ -1 +1 @@
1
- {"version":3,"names":["getModelTitleFieldId","model","titleFieldId"],"sources":["getModelTitleFieldId.ts"],"sourcesContent":["import { CmsEditorContentModel } from \"~/types\";\n\nexport const getModelTitleFieldId = (model: CmsEditorContentModel): string => {\n if (!model.titleFieldId || model.titleFieldId === \"id\") {\n return \"\";\n }\n return model.titleFieldId;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,oBAAoB,GAAIC,KAA4B,IAAa;EAC1E,IAAI,CAACA,KAAK,CAACC,YAAY,IAAID,KAAK,CAACC,YAAY,KAAK,IAAI,EAAE;IACpD,OAAO,EAAE;EACb;EACA,OAAOD,KAAK,CAACC,YAAY;AAC7B,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["getModelTitleFieldId","model","titleFieldId"],"sources":["getModelTitleFieldId.ts"],"sourcesContent":["import type { CmsEditorContentModel } from \"~/types\";\n\nexport const getModelTitleFieldId = (model: CmsEditorContentModel): string => {\n if (!model.titleFieldId || model.titleFieldId === \"id\") {\n return \"\";\n }\n return model.titleFieldId;\n};\n"],"mappings":"AAEA,OAAO,MAAMA,oBAAoB,GAAIC,KAA4B,IAAa;EAC1E,IAAI,CAACA,KAAK,CAACC,YAAY,IAAID,KAAK,CAACC,YAAY,KAAK,IAAI,EAAE;IACpD,OAAO,EAAE;EACb;EACA,OAAOD,KAAK,CAACC,YAAY;AAC7B,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms-common",
3
- "version": "6.0.0-alpha.0",
3
+ "version": "6.0.0-alpha.2",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,14 +16,14 @@
16
16
  "@emotion/react": "11.10.8",
17
17
  "@emotion/styled": "11.10.6",
18
18
  "@fortawesome/fontawesome-svg-core": "1.3.0",
19
- "@webiny/admin-ui": "6.0.0-alpha.0",
20
- "@webiny/app": "6.0.0-alpha.0",
21
- "@webiny/app-admin": "6.0.0-alpha.0",
22
- "@webiny/app-security": "6.0.0-alpha.0",
23
- "@webiny/form": "6.0.0-alpha.0",
24
- "@webiny/plugins": "6.0.0-alpha.0",
25
- "@webiny/react-composition": "6.0.0-alpha.0",
26
- "@webiny/validation": "6.0.0-alpha.0",
19
+ "@webiny/admin-ui": "6.0.0-alpha.2",
20
+ "@webiny/app": "6.0.0-alpha.2",
21
+ "@webiny/app-admin": "6.0.0-alpha.2",
22
+ "@webiny/app-security": "6.0.0-alpha.2",
23
+ "@webiny/form": "6.0.0-alpha.2",
24
+ "@webiny/plugins": "6.0.0-alpha.2",
25
+ "@webiny/react-composition": "6.0.0-alpha.2",
26
+ "@webiny/validation": "6.0.0-alpha.2",
27
27
  "dnd-core": "16.0.1",
28
28
  "graphql": "15.9.0",
29
29
  "graphql-tag": "2.12.6",
@@ -34,8 +34,8 @@
34
34
  "devDependencies": {
35
35
  "@emotion/babel-plugin": "11.11.0",
36
36
  "@types/react": "18.2.79",
37
- "@webiny/cli": "6.0.0-alpha.0",
38
- "@webiny/project-utils": "6.0.0-alpha.0",
37
+ "@webiny/cli": "6.0.0-alpha.2",
38
+ "@webiny/project-utils": "6.0.0-alpha.2",
39
39
  "babel-plugin-module-resolver": "5.0.2",
40
40
  "rimraf": "6.0.1",
41
41
  "typescript": "5.3.3"
@@ -48,5 +48,5 @@
48
48
  "build": "node ../cli/bin.js run build",
49
49
  "watch": "node ../cli/bin.js run watch"
50
50
  },
51
- "gitHead": "a5b28fed7a242d8f56712197a8ea83aa6d2ed101"
51
+ "gitHead": "7c9e8fbfd62a57ece5f880dbad6c864636b0355e"
52
52
  }
@@ -1,2 +1,2 @@
1
- import { CmsModelField } from "./types";
1
+ import type { CmsModelField } from "./types";
2
2
  export declare const prepareFormData: <T extends Record<string, any>>(input: T, fields: CmsModelField[]) => T;
@@ -1 +1 @@
1
- {"version":3,"names":["plugins","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","console","warn","transformationRunner","createTransformationRunner","availablePlugins","field","value","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map"],"sources":["prepareFormData.ts"],"sourcesContent":["import { CmsFieldValueTransformer, CmsModelField } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = <T extends Record<string, any>>(\n input: T,\n fields: CmsModelField[]\n): T => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<Record<keyof T, any>>((output, field) => {\n const inputValue = input[field.fieldId];\n\n const fieldId: keyof T = field.fieldId;\n\n if (field.multipleValues) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n\n output[fieldId] = values.map(value => runTransformation(field, value));\n\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as T);\n};\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,iBAAiB;AAMzC;AACA;AACA;AACA;AACA,IAAIC,2BAAmE,GAAGC,SAAS;AACnF,MAAMC,8BAA8B,GAAGA,CAAA,KAAkC;EACrE,IAAIF,2BAA2B,EAAE;IAC7B,OAAOA,2BAA2B;EACtC;EACAA,2BAA2B,GAAGD,OAAO,CAChCI,MAAM,CAA2B,6BAA6B,CAAC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,OAAO;IAEtC,IAAIX,KAAK,CAACY,cAAc,EAAE;MACtB,MAAMC,MAAM,GAAGrB,KAAK,CAACC,OAAO,CAACiB,UAAU,CAAC,GAAGA,UAAU,GAAGzB,SAAS;MACjE,IAAI,CAAC4B,MAAM,EAAE;QACT,OAAOJ,MAAM;MACjB;MACA;AACZ;AACA;AACA;AACA;AACA;AACA;MACY;MAAA,KACK,IAAII,MAAM,CAACC,MAAM,KAAK,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,KAAK5B,SAAS,CAAC,EAAE;QAC7E,OAAOwB,MAAM;MACjB;MAEAA,MAAM,CAACE,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAACd,KAAK,IAAIO,iBAAiB,CAACR,KAAK,EAAEC,KAAK,CAAC,CAAC;MAEtE,OAAOQ,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACE,OAAO,CAAC,GAAGH,iBAAiB,CAACR,KAAK,EAAEU,UAAU,CAAC;IAEtD,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["plugins","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","console","warn","transformationRunner","createTransformationRunner","availablePlugins","field","value","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map"],"sources":["prepareFormData.ts"],"sourcesContent":["import type { CmsFieldValueTransformer, CmsModelField } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = <T extends Record<string, any>>(\n input: T,\n fields: CmsModelField[]\n): T => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<Record<keyof T, any>>((output, field) => {\n const inputValue = input[field.fieldId];\n\n const fieldId: keyof T = field.fieldId;\n\n if (field.multipleValues) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n\n output[fieldId] = values.map(value => runTransformation(field, value));\n\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as T);\n};\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,iBAAiB;AAMzC;AACA;AACA;AAC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BAA0B,CAAC,CAAC;EAEtD,OAAOS,MAAM,CAACnB,MAAM,CAAuB,CAACqB,MAAM,EAAET,KAAK,KAAK;IAC1D,MAAMU,UAAU,GAAGJ,KAAK,CAACN,KAAK,CAACW,OAAO,CAAC;IAEvC,MAAMA,OAAgB,GAAGX,KAAK,CAACW,OAAO;IAEtC,IAAIX,KAAK,CAACY,cAAc,EAAE;MACtB,MAAMC,MAAM,GAAGrB,KAAK,CAACC,OAAO,CAACiB,UAAU,CAAC,GAAGA,UAAU,GAAGzB,SAAS;MACjE,IAAI,CAAC4B,MAAM,EAAE;QACT,OAAOJ,MAAM;MACjB;MACA;AACZ;AACA;AACA;AACA;AACA;AACA;MACY;MAAA,KACK,IAAII,MAAM,CAACC,MAAM,KAAK,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,KAAK5B,SAAS,CAAC,EAAE;QAC7E,OAAOwB,MAAM;MACjB;MAEAA,MAAM,CAACE,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAACd,KAAK,IAAIO,iBAAiB,CAACR,KAAK,EAAEC,KAAK,CAAC,CAAC;MAEtE,OAAOQ,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACE,OAAO,CAAC,GAAGH,iBAAiB,CAACR,KAAK,EAAEU,UAAU,CAAC;IAEtD,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]}
package/types/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
- import * as React from "react";
2
- import { ReactElement, ReactNode } from "react";
3
- import { Plugin } from "@webiny/plugins/types";
4
- import { BindComponent as BaseBindComponent, BindComponentProps as BaseBindComponentProps, BindComponentRenderProp as BaseBindComponentRenderProp, FormAPI } from "@webiny/form";
5
- import { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
6
- import { SecurityPermission } from "@webiny/app-security/types";
7
- import { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation";
8
- import { CmsModel, CmsModelField } from "./model";
9
- import { CmsIdentity } from "./shared";
1
+ import type * as React from "react";
2
+ import type { ReactElement, ReactNode } from "react";
3
+ import type { Plugin } from "@webiny/plugins/types";
4
+ import type { BindComponent as BaseBindComponent, BindComponentProps as BaseBindComponentProps, BindComponentRenderProp as BaseBindComponentRenderProp, FormAPI } from "@webiny/form";
5
+ import type { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
6
+ import type { SecurityPermission } from "@webiny/app-security/types";
7
+ import type { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation";
8
+ import type { CmsModel, CmsModelField } from "./model";
9
+ import type { CmsIdentity } from "./shared";
10
10
  import type { SourceType } from "dnd-core";
11
- import { IconPickerIconDto } from "@webiny/admin-ui";
11
+ import type { IconPickerIconDto } from "@webiny/admin-ui";
12
12
  export type DragObjectWithType = {
13
13
  type: SourceType;
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { ReactElement, ReactNode } from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport {\n BindComponent as BaseBindComponent,\n BindComponentProps as BaseBindComponentProps,\n BindComponentRenderProp as BaseBindComponentRenderProp,\n FormAPI\n} from \"@webiny/form\";\nimport { IconName, IconPrefix } from \"@fortawesome/fontawesome-svg-core\";\nimport { SecurityPermission } from \"@webiny/app-security/types\";\nimport {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation\";\nimport { CmsModel, CmsModelField } from \"./model\";\nimport { CmsIdentity } from \"~/types/shared\";\nimport type { SourceType } from \"dnd-core\";\nimport { IconPickerIconDto } from \"@webiny/admin-ui\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport * from \"./validation\";\nexport * from \"./model\";\nexport * from \"./shared\";\n\ninterface QueryFieldParams {\n model: CmsModel;\n field: CmsModelField;\n graphQLTypePrefix: string;\n}\n\ninterface Position {\n row: number;\n index: number;\n}\n\ninterface Location {\n folderId: string;\n}\n\nexport interface DragSource extends DragObjectWithType {\n parent?: string;\n pos?: Partial<Position>;\n type: \"row\" | \"field\" | \"newField\";\n fieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n}\n\n/**\n * @deprecated Use `CmsModelFieldTypePlugin`.\n */\nexport type CmsEditorFieldTypePlugin = CmsModelFieldTypePlugin;\n\nexport interface CmsModelFieldTypePlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-type\";\n field: {\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * type: \"myField\"\n * ```\n */\n type: string;\n /**\n * A display name for the field.\n *\n * ```ts\n * label: \"Field name\"\n * ```\n */\n label: string;\n /**\n * A list of available validators for the model field.\n *\n * ```ts\n * validators: [\n * \"required\",\n * \"gte\",\n * \"lte\"\n * ]\n * ```\n */\n validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * A list of available validators when a model field accepts a list (array) of values.\n *\n * ```ts\n * listValidators: [\n * \"minLength\",\n * \"maxLength\"\n * ]\n * ```\n */\n listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * An explanation of the field displayed beneath the label.\n *\n * ```ts\n * description: \"A short description of the field\"\n * ```\n */\n description: string;\n /**\n * A ReactNode to display the icon for the field.\n *\n * ```tsx\n * icon: <MyIconComponent />\n * ```\n */\n icon: React.ReactNode;\n /**\n * Is it allowed to have multiple values in this field?\n *\n * ```ts\n * allowMultipleValues: true\n * ```\n */\n allowMultipleValues?: boolean;\n /**\n * Does this field type have a fixed list of values that can be selected?\n *\n * ```ts\n * allowPredefinedValues: false\n * ```\n */\n allowPredefinedValues?: boolean;\n /**\n * A ReactNode label when multiple values are enabled.\n */\n multipleValuesLabel?: React.ReactNode;\n /**\n * Determines if this field type should be hidden from the admin UI.\n * If set to `true`, the field type will not be visible or selectable in the admin interface.\n */\n hideInAdmin?: boolean;\n /**\n * These are default values when the field is first created. This is a representation of the field that is stored in the database.\n *\n * ```ts\n * createField: () => ({\n * type: \"fieldType\",\n * validation: [],\n * renderer: {\n * name: \"fieldTypeRenderer\"\n * }\n * })\n * ```\n */\n createField: () => Pick<CmsModelField, \"type\" | \"validation\" | \"renderer\" | \"settings\">;\n /**\n * If `true` (default), this field will be configurable via a settings dialog.\n * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.\n */\n canEditSettings?: boolean;\n /**\n * Determine if a `draggable` can be dropped into this field.\n * NOTE: This is only applicable to nested field types.\n */\n canAccept?(field: CmsModelField, draggable: DragSource): boolean;\n /**\n * If `true` (default), will allow fields to be laid out into columns (next to each other).\n * If `false`, horizontal layout will not be allowed.\n * NOTE: This is only applicable to nested field types.\n */\n allowLayout?: boolean;\n /**\n * A ReactNode that you can add in the section below the help text when creating/editing field.\n *\n * ```tsx\n * renderSettings: (params) => {\n * return <FieldSettingsComponent />;\n * }\n * ```\n */\n renderSettings?: (params: {\n afterChangeLabel: (value: string) => void;\n uniqueFieldIdValidator: (fieldId: string) => void;\n contentModel: CmsModel;\n }) => React.ReactNode;\n /**\n * A ReactNode that renders in the Predefined values tab.\n *\n * ```tsx\n * renderPredefinedValues: (params) => {\n * const {form: {Bind}} = params;\n * return (\n * <Bind name=\"fieldProperty\">\n * <InputComponent />\n * </Bind>\n * );\n * }\n * ```\n */\n renderPredefinedValues?: (params: {\n getBind: (index?: number) => any;\n }) => React.ReactElement;\n /**\n * Object wrapper for GraphQL stuff\n */\n graphql?: {\n /**\n * Define field selection.\n *\n * ```ts\n * graphql: {\n * queryField: `\n * {\n * id\n * title\n * createdOn\n * }\n * `,\n * }\n * ```\n */\n queryField?: string | ((params: QueryFieldParams) => string | null);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelFieldRendererSettingsProps {\n field: CmsModelField;\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.ComponentType<React.PropsWithChildren>;\n getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;\n contentModel: CmsModel;\n}\n\n/**\n * @deprecated Use `CmsModelFieldRendererProps`.\n */\nexport type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;\n\n/**\n * @deprecated Use `CmsModelFieldRendererPlugin`.\n */\nexport type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.multipleValues\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidator[];\n tags?: string[];\n}\n\nexport interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {\n __typename: string;\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n entryId: string;\n modelId: string;\n createdOn: string;\n createdBy: CmsIdentity;\n savedOn: string;\n savedBy: CmsIdentity;\n modifiedOn: string | null;\n modifiedBy: CmsIdentity | null;\n deletedOn: string | null;\n deletedBy: CmsIdentity | null;\n firstPublishedOn: string | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedOn: string | null;\n lastPublishedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedOn: string;\n revisionSavedBy: CmsIdentity;\n revisionModifiedOn: string | null;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedOn: string | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedOn: string | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedOn: string | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n modelId: string;\n savedOn: string;\n deletedOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string | null;\n revisionDeletedOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.ComponentType<{ activeTab: boolean }>;\n\n// ------------------------------------------------------------------------------------------------------------\nexport interface CmsEditorFieldOptionPlugin extends Plugin {\n type: \"cms-editor-field-option\";\n render(): ReactElement;\n}\n\nexport interface CmsContentDetailsPlugin extends Plugin {\n render: (params: any) => ReactNode;\n}\n\nexport interface FieldLayoutPosition {\n row: number;\n index: number | null;\n}\n\nexport interface CmsEditorFormSettingsPlugin extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n render(props: { Bind: BaseBindComponent; form: FormAPI; formData: any }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI;\n formData: any;\n }): React.ReactNode;\n}\n\nexport interface CmsIcon {\n /**\n * [ pack, icon ], ex: [\"fab\", \"cog\"]\n */\n id: [IconPrefix, IconName];\n /**\n * Icon name\n */\n name: string;\n /**\n * SVG element\n */\n svg: ReactElement;\n}\n\nexport interface CmsIconsPlugin extends Plugin {\n type: \"cms-icons\";\n getIcons(): IconPickerIconDto[];\n}\n\n/**\n * Transform field value when sending data to the API.\n */\nexport interface CmsFieldValueTransformer<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-value-transformer\";\n /**\n * A field type for the value transformer. Or a list of field types.\n */\n fieldType: string | string[];\n /**\n * A transformer function that takes a value and returns a new one.\n */\n transform: (value: any, field: TField) => any;\n}\n\n/**\n * Define a custom form layout renderer for a specific content model.\n */\nexport interface CmsContentFormRendererPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-form-renderer\";\n /**\n * Content model ID that will use this renderer.\n */\n modelId: string;\n\n /**\n * A function that will render a custom form layout.\n */\n render(props: {\n /**\n * Content model that is being rendered.\n */\n contentModel: CmsModel;\n /**\n * Content entry data handled by the Form element.\n */\n data: Record<string, any>;\n /**\n * A component to bind data to the Form.\n */\n Bind: BindComponent;\n /**\n * Content model fields to render.\n */\n fields: Record<string, React.ReactElement>;\n }): React.ReactNode;\n}\n/**\n * #########################\n * Data types\n * #########################\n */\nexport interface CmsSecurityPermission extends SecurityPermission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: Record<string, string>;\n groups?: Record<string, string>;\n endpoints?: string[];\n locales?: string[];\n rwd?: string;\n own?: boolean;\n pw?: string;\n}\n\n/**\n * @category GraphQL\n * @category Error\n */\nexport interface CmsErrorResponse {\n message: string;\n code: string;\n data?: Record<string, any> | null;\n}\n/**\n * @category GraphQL\n * @category Meta\n */\nexport interface CmsMetaResponse {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\n/***\n * ###### FORM ########\n */\nexport interface BindComponentRenderProp<T = any> extends BaseBindComponentRenderProp<T> {\n parentName: string;\n appendValue: (value: any, index?: number) => void;\n prependValue: (value: any) => void;\n appendValues: (values: any[]) => void;\n removeValue: (index: number) => void;\n moveValueUp: (index: number) => void;\n moveValueDown: (index: number) => void;\n}\n\ninterface BindComponentProps<T = any> extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp<T>) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent<T = any> = React.ComponentType<BindComponentProps<T>> & {\n parentName: string;\n ValidationContainer: React.ComponentType<{ children: React.ReactNode }>;\n};\n\n/**\n * After RequestReview and RequestChanges was removed, we need an option to add new status filters\n */\nexport interface CmsEntryFilterStatusPlugin extends Plugin {\n type: \"cms.entry.filter.status\";\n label: string;\n value: string;\n}\n"],"mappings":"AAyBA;AACA;AACA;;AA0BA;AACA;AACA;;AA+LA;AACA;AACA;;AAGA;AACA;AACA;;AAyGA;AACA;AACA;;AA2EA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqBA;AACA;AACA;AAFA","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type {\n BindComponent as BaseBindComponent,\n BindComponentProps as BaseBindComponentProps,\n BindComponentRenderProp as BaseBindComponentRenderProp,\n FormAPI\n} from \"@webiny/form\";\nimport type { IconName, IconPrefix } from \"@fortawesome/fontawesome-svg-core\";\nimport type { SecurityPermission } from \"@webiny/app-security/types\";\nimport type {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation\";\nimport type { CmsModel, CmsModelField } from \"./model\";\nimport type { CmsIdentity } from \"~/types/shared\";\nimport type { SourceType } from \"dnd-core\";\nimport type { IconPickerIconDto } from \"@webiny/admin-ui\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport * from \"./validation\";\nexport * from \"./model\";\nexport * from \"./shared\";\n\ninterface QueryFieldParams {\n model: CmsModel;\n field: CmsModelField;\n graphQLTypePrefix: string;\n}\n\ninterface Position {\n row: number;\n index: number;\n}\n\ninterface Location {\n folderId: string;\n}\n\nexport interface DragSource extends DragObjectWithType {\n parent?: string;\n pos?: Partial<Position>;\n type: \"row\" | \"field\" | \"newField\";\n fieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n}\n\n/**\n * @deprecated Use `CmsModelFieldTypePlugin`.\n */\nexport type CmsEditorFieldTypePlugin = CmsModelFieldTypePlugin;\n\nexport interface CmsModelFieldTypePlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-type\";\n field: {\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * type: \"myField\"\n * ```\n */\n type: string;\n /**\n * A display name for the field.\n *\n * ```ts\n * label: \"Field name\"\n * ```\n */\n label: string;\n /**\n * A list of available validators for the model field.\n *\n * ```ts\n * validators: [\n * \"required\",\n * \"gte\",\n * \"lte\"\n * ]\n * ```\n */\n validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * A list of available validators when a model field accepts a list (array) of values.\n *\n * ```ts\n * listValidators: [\n * \"minLength\",\n * \"maxLength\"\n * ]\n * ```\n */\n listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * An explanation of the field displayed beneath the label.\n *\n * ```ts\n * description: \"A short description of the field\"\n * ```\n */\n description: string;\n /**\n * A ReactNode to display the icon for the field.\n *\n * ```tsx\n * icon: <MyIconComponent />\n * ```\n */\n icon: React.ReactNode;\n /**\n * Is it allowed to have multiple values in this field?\n *\n * ```ts\n * allowMultipleValues: true\n * ```\n */\n allowMultipleValues?: boolean;\n /**\n * Does this field type have a fixed list of values that can be selected?\n *\n * ```ts\n * allowPredefinedValues: false\n * ```\n */\n allowPredefinedValues?: boolean;\n /**\n * A ReactNode label when multiple values are enabled.\n */\n multipleValuesLabel?: React.ReactNode;\n /**\n * Determines if this field type should be hidden from the admin UI.\n * If set to `true`, the field type will not be visible or selectable in the admin interface.\n */\n hideInAdmin?: boolean;\n /**\n * These are default values when the field is first created. This is a representation of the field that is stored in the database.\n *\n * ```ts\n * createField: () => ({\n * type: \"fieldType\",\n * validation: [],\n * renderer: {\n * name: \"fieldTypeRenderer\"\n * }\n * })\n * ```\n */\n createField: () => Pick<CmsModelField, \"type\" | \"validation\" | \"renderer\" | \"settings\">;\n /**\n * If `true` (default), this field will be configurable via a settings dialog.\n * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.\n */\n canEditSettings?: boolean;\n /**\n * Determine if a `draggable` can be dropped into this field.\n * NOTE: This is only applicable to nested field types.\n */\n canAccept?(field: CmsModelField, draggable: DragSource): boolean;\n /**\n * If `true` (default), will allow fields to be laid out into columns (next to each other).\n * If `false`, horizontal layout will not be allowed.\n * NOTE: This is only applicable to nested field types.\n */\n allowLayout?: boolean;\n /**\n * A ReactNode that you can add in the section below the help text when creating/editing field.\n *\n * ```tsx\n * renderSettings: (params) => {\n * return <FieldSettingsComponent />;\n * }\n * ```\n */\n renderSettings?: (params: {\n afterChangeLabel: (value: string) => void;\n uniqueFieldIdValidator: (fieldId: string) => void;\n contentModel: CmsModel;\n }) => React.ReactNode;\n /**\n * A ReactNode that renders in the Predefined values tab.\n *\n * ```tsx\n * renderPredefinedValues: (params) => {\n * const {form: {Bind}} = params;\n * return (\n * <Bind name=\"fieldProperty\">\n * <InputComponent />\n * </Bind>\n * );\n * }\n * ```\n */\n renderPredefinedValues?: (params: {\n getBind: (index?: number) => any;\n }) => React.ReactElement;\n /**\n * Object wrapper for GraphQL stuff\n */\n graphql?: {\n /**\n * Define field selection.\n *\n * ```ts\n * graphql: {\n * queryField: `\n * {\n * id\n * title\n * createdOn\n * }\n * `,\n * }\n * ```\n */\n queryField?: string | ((params: QueryFieldParams) => string | null);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelFieldRendererSettingsProps {\n field: CmsModelField;\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.ComponentType<React.PropsWithChildren>;\n getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;\n contentModel: CmsModel;\n}\n\n/**\n * @deprecated Use `CmsModelFieldRendererProps`.\n */\nexport type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;\n\n/**\n * @deprecated Use `CmsModelFieldRendererPlugin`.\n */\nexport type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.multipleValues\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidator[];\n tags?: string[];\n}\n\nexport interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {\n __typename: string;\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n entryId: string;\n modelId: string;\n createdOn: string;\n createdBy: CmsIdentity;\n savedOn: string;\n savedBy: CmsIdentity;\n modifiedOn: string | null;\n modifiedBy: CmsIdentity | null;\n deletedOn: string | null;\n deletedBy: CmsIdentity | null;\n firstPublishedOn: string | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedOn: string | null;\n lastPublishedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedOn: string;\n revisionSavedBy: CmsIdentity;\n revisionModifiedOn: string | null;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedOn: string | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedOn: string | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedOn: string | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n modelId: string;\n savedOn: string;\n deletedOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string | null;\n revisionDeletedOn: string | null;\n revisionFirstPublishedOn: string | null;\n revisionLastPublishedOn: string | null;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.ComponentType<{ activeTab: boolean }>;\n\n// ------------------------------------------------------------------------------------------------------------\nexport interface CmsEditorFieldOptionPlugin extends Plugin {\n type: \"cms-editor-field-option\";\n render(): ReactElement;\n}\n\nexport interface CmsContentDetailsPlugin extends Plugin {\n render: (params: any) => ReactNode;\n}\n\nexport interface FieldLayoutPosition {\n row: number;\n index: number | null;\n}\n\nexport interface CmsEditorFormSettingsPlugin extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n render(props: { Bind: BaseBindComponent; form: FormAPI; formData: any }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI;\n formData: any;\n }): React.ReactNode;\n}\n\nexport interface CmsIcon {\n /**\n * [ pack, icon ], ex: [\"fab\", \"cog\"]\n */\n id: [IconPrefix, IconName];\n /**\n * Icon name\n */\n name: string;\n /**\n * SVG element\n */\n svg: ReactElement;\n}\n\nexport interface CmsIconsPlugin extends Plugin {\n type: \"cms-icons\";\n getIcons(): IconPickerIconDto[];\n}\n\n/**\n * Transform field value when sending data to the API.\n */\nexport interface CmsFieldValueTransformer<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-value-transformer\";\n /**\n * A field type for the value transformer. Or a list of field types.\n */\n fieldType: string | string[];\n /**\n * A transformer function that takes a value and returns a new one.\n */\n transform: (value: any, field: TField) => any;\n}\n\n/**\n * Define a custom form layout renderer for a specific content model.\n */\nexport interface CmsContentFormRendererPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-form-renderer\";\n /**\n * Content model ID that will use this renderer.\n */\n modelId: string;\n\n /**\n * A function that will render a custom form layout.\n */\n render(props: {\n /**\n * Content model that is being rendered.\n */\n contentModel: CmsModel;\n /**\n * Content entry data handled by the Form element.\n */\n data: Record<string, any>;\n /**\n * A component to bind data to the Form.\n */\n Bind: BindComponent;\n /**\n * Content model fields to render.\n */\n fields: Record<string, React.ReactElement>;\n }): React.ReactNode;\n}\n/**\n * #########################\n * Data types\n * #########################\n */\nexport interface CmsSecurityPermission extends SecurityPermission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: Record<string, string>;\n groups?: Record<string, string>;\n endpoints?: string[];\n locales?: string[];\n rwd?: string;\n own?: boolean;\n pw?: string;\n}\n\n/**\n * @category GraphQL\n * @category Error\n */\nexport interface CmsErrorResponse {\n message: string;\n code: string;\n data?: Record<string, any> | null;\n}\n/**\n * @category GraphQL\n * @category Meta\n */\nexport interface CmsMetaResponse {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\n/***\n * ###### FORM ########\n */\nexport interface BindComponentRenderProp<T = any> extends BaseBindComponentRenderProp<T> {\n parentName: string;\n appendValue: (value: any, index?: number) => void;\n prependValue: (value: any) => void;\n appendValues: (values: any[]) => void;\n removeValue: (index: number) => void;\n moveValueUp: (index: number) => void;\n moveValueDown: (index: number) => void;\n}\n\ninterface BindComponentProps<T = any> extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp<T>) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent<T = any> = React.ComponentType<BindComponentProps<T>> & {\n parentName: string;\n ValidationContainer: React.ComponentType<{ children: React.ReactNode }>;\n};\n\n/**\n * After RequestReview and RequestChanges was removed, we need an option to add new status filters\n */\nexport interface CmsEntryFilterStatusPlugin extends Plugin {\n type: \"cms.entry.filter.status\";\n label: string;\n value: string;\n}\n"],"mappings":"AAyBA;AACA;AACA;;AA0BA;AACA;AACA;;AA+LA;AACA;AACA;;AAGA;AACA;AACA;;AAyGA;AACA;AACA;;AA2EA;;AAgDA;AACA;AACA;;AAiBA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqBA;AACA;AACA;AAFA","ignoreList":[]}
package/types/model.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Validator } from "@webiny/validation/types";
2
- import { CmsModelFieldValidator } from "./validation";
3
- import { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "./index";
4
- import { CmsIdentity } from "./shared";
1
+ import type { Validator } from "@webiny/validation/types";
2
+ import type { CmsModelFieldValidator } from "./validation";
3
+ import type { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "./index";
4
+ import type { CmsIdentity } from "./shared";
5
5
  /**
6
6
  * @deprecated Use `CmsModelField` instead.
7
7
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import { Validator } from \"@webiny/validation/types\";\nimport { CmsModelFieldValidator } from \"~/types/validation\";\nimport {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index\";\nimport { CmsIdentity } from \"~/types/shared\";\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 helpText?: string;\n placeholderText?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: 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: Pick<CmsGroup, \"id\" | \"name\">;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n lockedFields: 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 settings: {\n [key: string]: any;\n };\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}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import type { Validator } from \"@webiny/validation/types\";\nimport type { CmsModelFieldValidator } from \"~/types/validation\";\nimport type {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index\";\nimport type { CmsIdentity } from \"~/types/shared\";\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 helpText?: string;\n placeholderText?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: 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: Pick<CmsGroup, \"id\" | \"name\">;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n lockedFields: 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 settings: {\n [key: string]: any;\n };\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}\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import * as React from "react";
2
- import { Plugin } from "@webiny/plugins/types";
3
- import { CmsModelField } from "./";
1
+ import type * as React from "react";
2
+ import type { Plugin } from "@webiny/plugins/types";
3
+ import type { CmsModelField } from "./";
4
4
  export interface CmsModelFieldValidatorConfigAdapter {
5
5
  isRequired(): boolean;
6
6
  getName(): string;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { CmsModelField } from \"~/types\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types\";\nimport type { CmsModelField } from \"~/types\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":"","ignoreList":[]}