@webiny/app-headless-cms-common 6.0.0-rc.1 → 6.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Fields/FieldRulesProvider.d.ts +9 -0
- package/Fields/FieldRulesProvider.js +20 -0
- package/Fields/FieldRulesProvider.js.map +1 -0
- package/Fields/Fields.js +127 -14
- package/Fields/Fields.js.map +1 -1
- package/Fields/LayoutDescriptorCell.d.ts +12 -0
- package/Fields/LayoutDescriptorCell.js +47 -0
- package/Fields/LayoutDescriptorCell.js.map +1 -0
- package/Fields/evaluateExpression.d.ts +23 -0
- package/Fields/evaluateExpression.js +102 -0
- package/Fields/evaluateExpression.js.map +1 -0
- package/Fields/fieldOptions.d.ts +36 -0
- package/Fields/fieldOptions.js +113 -0
- package/Fields/fieldOptions.js.map +1 -0
- package/Fields/index.d.ts +5 -0
- package/Fields/index.js +5 -0
- package/Fields/index.js.map +1 -1
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.d.ts +7 -0
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.js +13 -0
- package/Fields/layoutFieldRenderers/AlertFieldRenderer.js.map +1 -0
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.d.ts +7 -0
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js +18 -0
- package/Fields/layoutFieldRenderers/SeparatorFieldRenderer.js.map +1 -0
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.d.ts +12 -0
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.js +72 -0
- package/Fields/layoutFieldRenderers/TabsFieldRenderer.js.map +1 -0
- package/Fields/operatorOptions.d.ts +10 -0
- package/Fields/operatorOptions.js +92 -0
- package/Fields/operatorOptions.js.map +1 -0
- package/Fields/useBind.d.ts +1 -0
- package/Fields/useBind.js +7 -3
- package/Fields/useBind.js.map +1 -1
- package/Fields/useFieldRules.d.ts +32 -0
- package/Fields/useFieldRules.js +153 -0
- package/Fields/useFieldRules.js.map +1 -0
- package/ModelFieldProvider/CanEditField.d.ts +5 -0
- package/ModelFieldProvider/CanEditField.js +13 -0
- package/ModelFieldProvider/CanEditField.js.map +1 -0
- package/ModelFieldProvider/ModelFieldContext.d.ts +1 -0
- package/ModelFieldProvider/index.d.ts +1 -0
- package/ModelFieldProvider/index.js +1 -0
- package/ModelFieldProvider/index.js.map +1 -1
- package/ModelFieldProvider/useModelField.js +1 -1
- package/ModelFieldProvider/useModelField.js.map +1 -1
- package/entries.graphql.js +3 -0
- package/entries.graphql.js.map +1 -1
- package/exports/admin/cms/model.d.ts +2 -0
- package/exports/admin/cms/model.js +3 -0
- package/exports/admin/cms/model.js.map +1 -0
- package/exports/admin/cms.d.ts +1 -1
- package/exports/admin/cms.js.map +1 -1
- package/normalizeIcon.d.ts +3 -0
- package/normalizeIcon.js +10 -0
- package/normalizeIcon.js.map +1 -0
- package/package.json +12 -11
- package/types/index.d.ts +66 -3
- package/types/index.js +51 -1
- package/types/index.js.map +1 -1
- package/types/model.d.ts +53 -2
- package/types/model.js +27 -1
- package/types/model.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelFieldContext.js\";\nexport * from \"./useModelField.js\";\n"],"mappings":"AAAA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./ModelFieldContext.js\";\nexport * from \"./useModelField.js\";\nexport * from \"./CanEditField.js\";\n"],"mappings":"AAAA;AACA;AACA","ignoreList":[]}
|
|
@@ -14,10 +14,10 @@ const getFieldPlugin = type => {
|
|
|
14
14
|
*/
|
|
15
15
|
export const useModelField = makeDecoratable(() => {
|
|
16
16
|
const field = useContext(ModelFieldContext);
|
|
17
|
-
const parentValueIndex = useParentValueIndex();
|
|
18
17
|
if (!field) {
|
|
19
18
|
throw Error(`Missing "ModelFieldProvider" in the component tree. Are you using the "useModelField()" hook in the right place?`);
|
|
20
19
|
}
|
|
20
|
+
const parentValueIndex = useParentValueIndex();
|
|
21
21
|
const fieldPlugin = getFieldPlugin(field.type);
|
|
22
22
|
return {
|
|
23
23
|
field,
|
|
@@ -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.js\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types/index.js\";\n\ninterface GetFieldPlugin {\n (type: string): CmsModelFieldTypePlugin;\n}\n\nconst getFieldPlugin: GetFieldPlugin = type => {\n const plugin = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .find(plugin => plugin.field.type === type);\n\n if (!plugin) {\n throw Error(`Missing plugin for field type \"${type}\"!`);\n }\n\n return plugin;\n};\n\nexport interface UseModelField {\n field: CmsModelField;\n parentValueIndex: number;\n fieldPlugin: CmsModelFieldTypePlugin;\n}\n\n/**\n * Get model field from the current context.\n */\nexport const useModelField = makeDecoratable((): UseModelField => {\n const field = useContext(ModelFieldContext);\n
|
|
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.js\";\nimport type { CmsModelField, CmsModelFieldTypePlugin } from \"~/types/index.js\";\n\ninterface GetFieldPlugin {\n (type: string): CmsModelFieldTypePlugin;\n}\n\nconst getFieldPlugin: GetFieldPlugin = type => {\n const plugin = plugins\n .byType<CmsModelFieldTypePlugin>(\"cms-editor-field-type\")\n .find(plugin => plugin.field.type === type);\n\n if (!plugin) {\n throw Error(`Missing plugin for field type \"${type}\"!`);\n }\n\n return plugin;\n};\n\nexport interface UseModelField {\n field: CmsModelField;\n parentValueIndex: number;\n fieldPlugin: CmsModelFieldTypePlugin;\n}\n\n/**\n * Get model field from the current context.\n */\nexport const useModelField = makeDecoratable((): UseModelField => {\n const field = useContext(ModelFieldContext);\n\n if (!field) {\n throw Error(\n `Missing \"ModelFieldProvider\" in the component tree. Are you using the \"useModelField()\" hook in the right place?`\n );\n }\n\n const parentValueIndex = useParentValueIndex();\n\n const fieldPlugin = getFieldPlugin(field.type);\n\n return { field, fieldPlugin, parentValueIndex };\n});\n"],"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;EAE3C,IAAI,CAACO,KAAK,EAAE;IACR,MAAMC,KAAK,CACP,kHACJ,CAAC;EACL;EAEA,MAAME,gBAAgB,GAAGT,mBAAmB,CAAC,CAAC;EAE9C,MAAMU,WAAW,GAAGT,cAAc,CAACK,KAAK,CAACJ,IAAI,CAAC;EAE9C,OAAO;IAAEI,KAAK;IAAEI,WAAW;IAAED;EAAiB,CAAC;AACnD,CAAC,CAAC","ignoreList":[]}
|
package/entries.graphql.js
CHANGED
package/entries.graphql.js.map
CHANGED
|
@@ -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","selection","createDeleteMutation","createRestoreFromBinMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createUpdateSingletonMutation","createPublishMutation","createUnpublishMutation","createBulkActionMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type {\n CmsContentEntry,\n CmsContentEntryRevision,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModel,\n CmsModelField\n} from \"~/types/index.js\";\nimport { createFieldsList } from \"./createFieldsList.js\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId.js\";\nimport type { FormValidationOptions } from \"@webiny/form\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"./constants.js\";\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${fields ? createFieldsList({ model, fields }) : getModelTitleFieldId(model)}\n }\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 const selection = createListQueryDataSelection(model, fields);\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 ${selection}\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFields}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,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ED;AACA;AACA;AACA;;AAYA,OAAO,MAAMmB,qBAAqB,GAAIxB,KAA4B,IAAK;EACnE,OAAON,GAAG;AACd,6BAA6BM,KAAK,CAACO,eAAe;AAClD,8BAA8BP,KAAK,CAACO,eAAe;AACnD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AAC3E;AACA;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAYA,OAAO,MAAMoB,uBAAuB,GAAIzB,KAA4B,IAAK;EACrE,OAAON,GAAG;AACd,+BAA+BM,KAAK,CAACO,eAAe;AACpD,gCAAgCP,KAAK,CAACO,eAAe;AACrD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AAC3E;AACA;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAqBA,OAAO,MAAMqB,wBAAwB,GAAI1B,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","selection","createDeleteMutation","createRestoreFromBinMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createUpdateSingletonMutation","createPublishMutation","createUnpublishMutation","createBulkActionMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport type {\n CmsContentEntry,\n CmsContentEntryRevision,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModel,\n CmsModelField\n} from \"~/types/index.js\";\nimport { createFieldsList } from \"./createFieldsList.js\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId.js\";\nimport type { FormValidationOptions } from \"@webiny/form\";\nimport { CMS_MODEL_SINGLETON_TAG } from \"./constants.js\";\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 live {\n version\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${fields ? createFieldsList({ model, fields }) : getModelTitleFieldId(model)}\n }\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 const selection = createListQueryDataSelection(model, fields);\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 ${selection}\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFields}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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 values {\n ${createFieldsList({ model, fields: model.fields })}\n }\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;AACA;AACA;AACA,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;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AAC3E;AACA;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;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CA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;AACA;AACA;;AAYA,OAAO,MAAMoB,uBAAuB,GAAIzB,KAA4B,IAAK;EACrE,OAAON,GAAG;AACd,+BAA+BM,KAAK,CAACO,eAAe;AACpD,gCAAgCP,KAAK,CAACO,eAAe;AACrD;AACA,sBAAsBR,uBAAuB,CAACC,KAAK,CAAC;AACpD;AACA,0BAA0BL,gBAAgB,CAAC;IAAEK,KAAK;IAAEQ,MAAM,EAAER,KAAK,CAACQ;EAAO,CAAC,CAAC;AAC3E;AACA;AACA,wBAAwBH,WAAW;AACnC;AACA,UAAU;AACV,CAAC;;AAED;AACA;AACA;AACA;;AAqBA,OAAO,MAAMqB,wBAAwB,GAAI1B,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":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useFieldAccessControlRules","useEffectiveRules"],"sources":["model.ts"],"sourcesContent":["export { useFieldAccessControlRules, useEffectiveRules } from \"~/Fields/index.js\";\n\nexport type {\n CmsLayoutFieldTypePlugin,\n CmsLayoutDescriptorRendererPlugin,\n CmsBaseLayoutDescriptor,\n CmsLayoutDescriptor\n} from \"~/types/index.ts\";\n"],"mappings":"AAAA,SAASA,0BAA0B,EAAEC,iBAAiB","ignoreList":[]}
|
package/exports/admin/cms.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export type { CmsContentEntry, CmsModel, CmsModelField, CmsIdentity } from "../../types/index.ts";
|
|
1
|
+
export type { CmsContentEntry, CmsModel, CmsModelField, CmsIdentity, CmsLayoutFieldTypePlugin, CmsLayoutDescriptorRendererPlugin, CmsBaseLayoutDescriptor, CmsLayoutDescriptor } from "../../types/index.ts";
|
package/exports/admin/cms.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["cms.ts"],"sourcesContent":["export type {
|
|
1
|
+
{"version":3,"names":[],"sources":["cms.ts"],"sourcesContent":["export type {\n CmsContentEntry,\n CmsModel,\n CmsModelField,\n CmsIdentity,\n CmsLayoutFieldTypePlugin,\n CmsLayoutDescriptorRendererPlugin,\n CmsBaseLayoutDescriptor,\n CmsLayoutDescriptor\n} from \"~/types/index.ts\";\n"],"mappings":"","ignoreList":[]}
|
package/normalizeIcon.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["normalizeIcon","icon","iconName","undefined","name","split"],"sources":["normalizeIcon.ts"],"sourcesContent":["import type { IconProp } from \"@fortawesome/fontawesome-svg-core\";\nimport type { CmsIcon } from \"~/types/index.js\";\n\nexport const normalizeIcon = (icon: string | CmsIcon | undefined) => {\n let iconName: IconProp | undefined = undefined;\n if (icon) {\n const name = typeof icon === \"string\" ? icon : icon.name;\n iconName = name.split(\"/\") as IconProp;\n }\n return iconName;\n};\n"],"mappings":"AAGA,OAAO,MAAMA,aAAa,GAAIC,IAAkC,IAAK;EACjE,IAAIC,QAA8B,GAAGC,SAAS;EAC9C,IAAIF,IAAI,EAAE;IACN,MAAMG,IAAI,GAAG,OAAOH,IAAI,KAAK,QAAQ,GAAGA,IAAI,GAAGA,IAAI,CAACG,IAAI;IACxDF,QAAQ,GAAGE,IAAI,CAACC,KAAK,CAAC,GAAG,CAAa;EAC1C;EACA,OAAOH,QAAQ;AACnB,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-rc.
|
|
3
|
+
"version": "6.0.0-rc.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -17,15 +17,16 @@
|
|
|
17
17
|
"@emotion/react": "11.10.8",
|
|
18
18
|
"@emotion/styled": "11.10.6",
|
|
19
19
|
"@fortawesome/fontawesome-svg-core": "1.3.0",
|
|
20
|
-
"@
|
|
21
|
-
"@webiny/
|
|
22
|
-
"@webiny/app
|
|
23
|
-
"@webiny/
|
|
24
|
-
"@webiny/
|
|
25
|
-
"@webiny/
|
|
26
|
-
"@webiny/
|
|
20
|
+
"@fortawesome/react-fontawesome": "0.1.19",
|
|
21
|
+
"@webiny/admin-ui": "6.0.0-rc.3",
|
|
22
|
+
"@webiny/app": "6.0.0-rc.3",
|
|
23
|
+
"@webiny/app-admin": "6.0.0-rc.3",
|
|
24
|
+
"@webiny/form": "6.0.0-rc.3",
|
|
25
|
+
"@webiny/plugins": "6.0.0-rc.3",
|
|
26
|
+
"@webiny/react-composition": "6.0.0-rc.3",
|
|
27
|
+
"@webiny/validation": "6.0.0-rc.3",
|
|
27
28
|
"dnd-core": "16.0.1",
|
|
28
|
-
"graphql": "16.
|
|
29
|
+
"graphql": "16.13.0",
|
|
29
30
|
"graphql-tag": "2.12.6",
|
|
30
31
|
"lodash": "4.17.23",
|
|
31
32
|
"prop-types": "15.8.1",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@emotion/babel-plugin": "11.13.5",
|
|
36
37
|
"@types/react": "18.2.79",
|
|
37
|
-
"@webiny/build-tools": "6.0.0-rc.
|
|
38
|
+
"@webiny/build-tools": "6.0.0-rc.3",
|
|
38
39
|
"babel-plugin-module-resolver": "5.0.2",
|
|
39
40
|
"rimraf": "6.1.3",
|
|
40
41
|
"typescript": "5.9.3"
|
|
@@ -43,5 +44,5 @@
|
|
|
43
44
|
"access": "public",
|
|
44
45
|
"directory": "dist"
|
|
45
46
|
},
|
|
46
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "228fe25e1a17f248d566bce1c33d11c291955513"
|
|
47
48
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { Plugin } from "@webiny/plugins/types.js";
|
|
|
4
4
|
import type { BindComponent as BaseBindComponent, BindComponentProps as BaseBindComponentProps, BindComponentRenderProp as BaseBindComponentRenderProp, FormAPI } from "@webiny/form";
|
|
5
5
|
import type { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
|
|
6
6
|
import type { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation.js";
|
|
7
|
-
import type { CmsModel, CmsModelField } from "./model.js";
|
|
7
|
+
import type { CmsBaseLayoutDescriptor, CmsEditorFieldsLayout, CmsLayoutDescriptor, CmsModel, CmsModelField } from "./model.js";
|
|
8
8
|
import type { CmsIdentity } from "../types/shared.js";
|
|
9
9
|
import type { SourceType } from "dnd-core";
|
|
10
10
|
import type { IconPickerIconDto } from "@webiny/admin-ui";
|
|
@@ -15,6 +15,7 @@ export type DragObjectWithType = {
|
|
|
15
15
|
};
|
|
16
16
|
export type * from "./validation.js";
|
|
17
17
|
export type * from "./model.js";
|
|
18
|
+
export { isLayoutDescriptor } from "./model.js";
|
|
18
19
|
export type * from "./shared.js";
|
|
19
20
|
interface QueryFieldParams {
|
|
20
21
|
model: CmsModel;
|
|
@@ -31,10 +32,12 @@ interface Location {
|
|
|
31
32
|
export interface DragSource extends DragObjectWithType {
|
|
32
33
|
parent?: string;
|
|
33
34
|
pos?: Partial<Position>;
|
|
34
|
-
type: "row" | "field" | "newField";
|
|
35
|
+
type: "row" | "field" | "newField" | "newLayoutField" | "layoutField";
|
|
35
36
|
fieldType?: string;
|
|
37
|
+
layoutFieldType?: string;
|
|
36
38
|
field?: CmsModelField | null;
|
|
37
39
|
fields?: CmsModelField[];
|
|
40
|
+
descriptor?: CmsLayoutDescriptor;
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
43
|
* @deprecated Use `CmsModelFieldTypePlugin`.
|
|
@@ -219,6 +222,59 @@ export interface CmsModelFieldTypePlugin extends Plugin {
|
|
|
219
222
|
}) => React.ReactElement;
|
|
220
223
|
};
|
|
221
224
|
}
|
|
225
|
+
export interface CmsLayoutFieldTypePlugin extends Plugin {
|
|
226
|
+
type: "cms-editor-layout-field-type";
|
|
227
|
+
field: {
|
|
228
|
+
type: CmsLayoutDescriptor["type"];
|
|
229
|
+
label: string;
|
|
230
|
+
description: string;
|
|
231
|
+
icon: React.ReactElement;
|
|
232
|
+
createDescriptor(): Omit<CmsLayoutDescriptor, "id">;
|
|
233
|
+
canEditSettings?: boolean;
|
|
234
|
+
renderSettings?(): React.ReactNode;
|
|
235
|
+
/**
|
|
236
|
+
* Collect all model fields embedded inside a layout descriptor's nested layout.
|
|
237
|
+
* Used during drag-and-drop to move embedded fields along with the descriptor
|
|
238
|
+
* across parent boundaries. Return `[]` or omit for descriptors with no nested fields.
|
|
239
|
+
*/
|
|
240
|
+
collectFields?(params: {
|
|
241
|
+
descriptor: CmsLayoutDescriptor;
|
|
242
|
+
getField: (id: string) => CmsModelField | undefined;
|
|
243
|
+
}): CmsModelField[];
|
|
244
|
+
/**
|
|
245
|
+
* Return a label prefix for each field ID nested inside this layout descriptor.
|
|
246
|
+
* Used by `buildFieldOptions` to include layout hierarchy in field labels.
|
|
247
|
+
*
|
|
248
|
+
* For example, a tabs descriptor with label "My Tabs" containing a tab "SEO"
|
|
249
|
+
* with field "metaTitle" would return: `{ "metaTitle": "My Tabs › SEO" }`.
|
|
250
|
+
*
|
|
251
|
+
* Omit or return `{}` for descriptors that don't group fields.
|
|
252
|
+
*/
|
|
253
|
+
getFieldLabelPrefixes?(params: {
|
|
254
|
+
descriptor: CmsLayoutDescriptor;
|
|
255
|
+
}): Record<string, string>;
|
|
256
|
+
/**
|
|
257
|
+
* Controls how this layout field looks on the model editor canvas.
|
|
258
|
+
* Each plugin fully owns its visual representation.
|
|
259
|
+
*/
|
|
260
|
+
render(params: {
|
|
261
|
+
descriptor: CmsLayoutDescriptor;
|
|
262
|
+
onUpdate: (d: CmsLayoutDescriptor) => void;
|
|
263
|
+
onDelete: () => void;
|
|
264
|
+
}): React.ReactElement;
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
export interface CmsLayoutDescriptorRendererPlugin extends Plugin {
|
|
268
|
+
type: "cms-layout-descriptor-renderer";
|
|
269
|
+
descriptorType: string;
|
|
270
|
+
render(props: {
|
|
271
|
+
descriptor: CmsBaseLayoutDescriptor;
|
|
272
|
+
Bind: BindComponent;
|
|
273
|
+
fields: CmsModelField[];
|
|
274
|
+
contentModel: CmsModel;
|
|
275
|
+
gridClassName?: string;
|
|
276
|
+
}): React.ReactElement | null;
|
|
277
|
+
}
|
|
222
278
|
export interface CmsModelFieldRendererSettingsProps {
|
|
223
279
|
field: CmsModelField;
|
|
224
280
|
}
|
|
@@ -324,7 +380,7 @@ export interface CmsDynamicZoneTemplate {
|
|
|
324
380
|
description: string;
|
|
325
381
|
icon: string;
|
|
326
382
|
fields: CmsModelField[];
|
|
327
|
-
layout:
|
|
383
|
+
layout: CmsEditorFieldsLayout;
|
|
328
384
|
validation: CmsModelFieldValidator[];
|
|
329
385
|
tags?: string[];
|
|
330
386
|
}
|
|
@@ -336,6 +392,11 @@ export type CmsContentEntryStatusType = "draft" | "published" | "unpublished";
|
|
|
336
392
|
* @deprecated Use `CmsContentEntry`.
|
|
337
393
|
*/
|
|
338
394
|
export type CmsEditorContentEntry = CmsContentEntry;
|
|
395
|
+
export interface CmsContentEntryLive {
|
|
396
|
+
version: number;
|
|
397
|
+
}
|
|
398
|
+
export interface CmsContentEntrySystem {
|
|
399
|
+
}
|
|
339
400
|
export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord> {
|
|
340
401
|
id: string;
|
|
341
402
|
entryId: string;
|
|
@@ -365,6 +426,8 @@ export interface CmsContentEntry<TValues extends GenericRecord = GenericRecord>
|
|
|
365
426
|
revisionLastPublishedOn: string | null;
|
|
366
427
|
revisionLastPublishedBy: CmsIdentity | null;
|
|
367
428
|
wbyAco_location: Location;
|
|
429
|
+
live: CmsContentEntryLive | null;
|
|
430
|
+
system: CmsContentEntrySystem | null;
|
|
368
431
|
meta: {
|
|
369
432
|
title: string;
|
|
370
433
|
description?: string;
|
package/types/index.js
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { isLayoutDescriptor } from "./model.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Use `CmsModelFieldTypePlugin`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Use `CmsModelFieldRendererProps`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Use `CmsModelFieldRendererPlugin`.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Use `CmsContentEntry`.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// ------------------------------------------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Transform field value when sending data to the API.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Define a custom form layout renderer for a specific content model.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* #########################
|
|
31
|
+
* Data types
|
|
32
|
+
* #########################
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* @category GraphQL
|
|
37
|
+
* @category Error
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* @category GraphQL
|
|
42
|
+
* @category Meta
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/***
|
|
46
|
+
* ###### FORM ########
|
|
47
|
+
*/
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* After RequestReview and RequestChanges was removed, we need an option to add new status filters
|
|
51
|
+
*/
|
|
2
52
|
|
|
3
53
|
//# sourceMappingURL=index.js.map
|
package/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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.js\";\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 {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation.js\";\nimport type { CmsModel, CmsModelField } from \"./model.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type { SourceType } from \"dnd-core\";\nimport type { IconPickerIconDto } from \"@webiny/admin-ui\";\nimport { GenericRecord } from \"@webiny/app/types.js\";\nimport { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport type * from \"./validation.js\";\nexport type * from \"./model.js\";\nexport type * from \"./shared.js\";\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 * allowList: true\n * ```\n */\n allowList?: 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 listLabel?: 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.list\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<TValues extends GenericRecord = GenericRecord> {\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 values?: TValues;\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<T = GenericRecord> extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n showSave?: boolean;\n render(props: { Bind: BaseBindComponent; form: FormAPI<T>; formData: T }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI<T>;\n formData: T;\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 Identity.Permission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: string[];\n groups?: string[];\n endpoints?: 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":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["isLayoutDescriptor"],"sources":["index.ts"],"sourcesContent":["import type * as React from \"react\";\nimport type { ReactElement, ReactNode } from \"react\";\nimport type { Plugin } from \"@webiny/plugins/types.js\";\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 {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation.js\";\nimport type {\n CmsBaseLayoutDescriptor,\n CmsEditorFieldsLayout,\n CmsLayoutDescriptor,\n CmsModel,\n CmsModelField\n} from \"./model.js\";\nimport type { CmsIdentity } from \"~/types/shared.js\";\nimport type { SourceType } from \"dnd-core\";\nimport type { IconPickerIconDto } from \"@webiny/admin-ui\";\nimport { GenericRecord } from \"@webiny/app/types.js\";\nimport { Identity } from \"@webiny/app-admin/domain/Identity.js\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport type * from \"./validation.js\";\nexport type * from \"./model.js\";\nexport { isLayoutDescriptor } from \"./model.js\";\nexport type * from \"./shared.js\";\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\" | \"newLayoutField\" | \"layoutField\";\n fieldType?: string;\n layoutFieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n descriptor?: CmsLayoutDescriptor;\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 * allowList: true\n * ```\n */\n allowList?: 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 listLabel?: 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 CmsLayoutFieldTypePlugin extends Plugin {\n type: \"cms-editor-layout-field-type\";\n field: {\n type: CmsLayoutDescriptor[\"type\"];\n label: string;\n description: string;\n icon: React.ReactElement;\n createDescriptor(): Omit<CmsLayoutDescriptor, \"id\">;\n canEditSettings?: boolean;\n renderSettings?(): React.ReactNode;\n /**\n * Collect all model fields embedded inside a layout descriptor's nested layout.\n * Used during drag-and-drop to move embedded fields along with the descriptor\n * across parent boundaries. Return `[]` or omit for descriptors with no nested fields.\n */\n collectFields?(params: {\n descriptor: CmsLayoutDescriptor;\n getField: (id: string) => CmsModelField | undefined;\n }): CmsModelField[];\n /**\n * Return a label prefix for each field ID nested inside this layout descriptor.\n * Used by `buildFieldOptions` to include layout hierarchy in field labels.\n *\n * For example, a tabs descriptor with label \"My Tabs\" containing a tab \"SEO\"\n * with field \"metaTitle\" would return: `{ \"metaTitle\": \"My Tabs › SEO\" }`.\n *\n * Omit or return `{}` for descriptors that don't group fields.\n */\n getFieldLabelPrefixes?(params: { descriptor: CmsLayoutDescriptor }): Record<string, string>;\n /**\n * Controls how this layout field looks on the model editor canvas.\n * Each plugin fully owns its visual representation.\n */\n render(params: {\n descriptor: CmsLayoutDescriptor;\n onUpdate: (d: CmsLayoutDescriptor) => void;\n onDelete: () => void;\n }): React.ReactElement;\n };\n}\n\nexport interface CmsLayoutDescriptorRendererPlugin extends Plugin {\n type: \"cms-layout-descriptor-renderer\";\n descriptorType: string;\n render(props: {\n descriptor: CmsBaseLayoutDescriptor;\n Bind: BindComponent;\n fields: CmsModelField[];\n contentModel: CmsModel;\n gridClassName?: string;\n }): React.ReactElement | null;\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.list\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: CmsEditorFieldsLayout;\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 CmsContentEntryLive {\n version: number;\n}\n\nexport interface CmsContentEntrySystem {\n // to be extended\n}\n\nexport interface CmsContentEntry<TValues extends GenericRecord = GenericRecord> {\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 live: CmsContentEntryLive | null;\n system: CmsContentEntrySystem | null;\n meta: {\n title: string;\n description?: string;\n image?: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n values?: TValues;\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<T = GenericRecord> extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n showSave?: boolean;\n render(props: { Bind: BaseBindComponent; form: FormAPI<T>; formData: T }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI<T>;\n formData: T;\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 Identity.Permission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: string[];\n groups?: string[];\n endpoints?: 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":"AAkCA,SAASA,kBAAkB;;AA6B3B;AACA;AACA;;AAoPA;AACA;AACA;;AAGA;AACA;AACA;;AAyGA;AACA;AACA;;AAqFA;;AAiDA;AACA;AACA;;AAiBA;AACA;AACA;;AAiCA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAqBA;AACA;AACA","ignoreList":[]}
|
package/types/model.d.ts
CHANGED
|
@@ -12,12 +12,20 @@ export interface CmsModelFieldSettings<T = unknown> {
|
|
|
12
12
|
defaultSetValue?: string;
|
|
13
13
|
type?: string;
|
|
14
14
|
fields?: CmsModelField<T>[];
|
|
15
|
-
layout?:
|
|
15
|
+
layout?: CmsEditorFieldsLayout;
|
|
16
16
|
models?: Pick<CmsModel, "modelId">[];
|
|
17
17
|
templates?: CmsDynamicZoneTemplate[];
|
|
18
18
|
imagesOnly?: boolean;
|
|
19
19
|
[key: string]: any;
|
|
20
20
|
}
|
|
21
|
+
export type FieldRuleAction = "hide" | "disable" | string;
|
|
22
|
+
export interface FieldRule {
|
|
23
|
+
type: "accessControl" | "condition";
|
|
24
|
+
target: string;
|
|
25
|
+
operator: string;
|
|
26
|
+
value: string | number | boolean | null;
|
|
27
|
+
action: FieldRuleAction;
|
|
28
|
+
}
|
|
21
29
|
export type CmsModelField<T = unknown> = T & {
|
|
22
30
|
id: string;
|
|
23
31
|
type: string;
|
|
@@ -43,9 +51,52 @@ export type CmsModelField<T = unknown> = T & {
|
|
|
43
51
|
*/
|
|
44
52
|
| CmsModelFieldRendererPlugin["renderer"]["render"];
|
|
45
53
|
tags?: string[];
|
|
54
|
+
rules?: FieldRule[];
|
|
46
55
|
};
|
|
47
56
|
export type CmsEditorFieldId = string;
|
|
48
|
-
export
|
|
57
|
+
export interface CmsBaseLayoutDescriptor {
|
|
58
|
+
id: string;
|
|
59
|
+
type: string;
|
|
60
|
+
rules?: FieldRule[];
|
|
61
|
+
}
|
|
62
|
+
export interface CmsSeparatorLayoutDescriptor extends CmsBaseLayoutDescriptor {
|
|
63
|
+
type: "separator";
|
|
64
|
+
label: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface CmsAlertLayoutDescriptor extends CmsBaseLayoutDescriptor {
|
|
68
|
+
type: "alert";
|
|
69
|
+
label: string;
|
|
70
|
+
alertType: "info" | "success" | "warning" | "danger";
|
|
71
|
+
}
|
|
72
|
+
export interface CmsTabLayoutTab {
|
|
73
|
+
id: string;
|
|
74
|
+
label: string;
|
|
75
|
+
icon?: string;
|
|
76
|
+
layout: CmsEditorFieldsLayout;
|
|
77
|
+
rules?: FieldRule[];
|
|
78
|
+
}
|
|
79
|
+
export interface CmsTabLayoutDescriptor extends CmsBaseLayoutDescriptor {
|
|
80
|
+
type: "tabs";
|
|
81
|
+
label: string;
|
|
82
|
+
description?: string | null;
|
|
83
|
+
help?: string | null;
|
|
84
|
+
tabs: CmsTabLayoutTab[];
|
|
85
|
+
}
|
|
86
|
+
export type CmsLayoutDescriptor = CmsSeparatorLayoutDescriptor | CmsAlertLayoutDescriptor | CmsTabLayoutDescriptor | CmsBaseLayoutDescriptor;
|
|
87
|
+
export type CmsEditorLayoutCell = CmsEditorFieldId | CmsLayoutDescriptor;
|
|
88
|
+
export type CmsEditorFieldsLayout = CmsEditorLayoutCell[][];
|
|
89
|
+
/**
|
|
90
|
+
* Distinguish layout descriptors from field IDs (strings) and CmsModelField objects.
|
|
91
|
+
*
|
|
92
|
+
* In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)
|
|
93
|
+
* or layout descriptor objects — the `typeof` check handles that.
|
|
94
|
+
*
|
|
95
|
+
* In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`
|
|
96
|
+
* or layout descriptor objects — both have `{ id, type }`, but only `CmsModelField`
|
|
97
|
+
* has `fieldId`, so we use its absence as the discriminator.
|
|
98
|
+
*/
|
|
99
|
+
export declare function isLayoutDescriptor(cell: unknown): cell is CmsLayoutDescriptor;
|
|
49
100
|
/**
|
|
50
101
|
* @category GraphQL
|
|
51
102
|
* @category Model
|
package/types/model.js
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @deprecated Use `CmsModelField` instead.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Distinguish layout descriptors from field IDs (strings) and CmsModelField objects.
|
|
7
|
+
*
|
|
8
|
+
* In raw layout data (`CmsEditorFieldsLayout`), cells are either strings (field IDs)
|
|
9
|
+
* or layout descriptor objects — the `typeof` check handles that.
|
|
10
|
+
*
|
|
11
|
+
* In resolved layout data (after `getFieldsInLayout`), cells are either `CmsModelField`
|
|
12
|
+
* or layout descriptor objects — both have `{ id, type }`, but only `CmsModelField`
|
|
13
|
+
* has `fieldId`, so we use its absence as the discriminator.
|
|
14
|
+
*/
|
|
15
|
+
export function isLayoutDescriptor(cell) {
|
|
16
|
+
return typeof cell === "object" && cell !== null && "type" in cell && typeof cell.type === "string" && !("fieldId" in cell);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* @category GraphQL
|
|
21
|
+
* @category Model
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @category GraphQL
|
|
26
|
+
* @category Group
|
|
27
|
+
*/
|
|
2
28
|
|
|
3
29
|
//# sourceMappingURL=model.js.map
|