@webiny/app-headless-cms-common 5.39.0-beta.1 → 5.39.0-beta.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.
@@ -15,7 +15,7 @@ function createFieldsList(_ref) {
15
15
  var fieldPlugins = _plugins.plugins.byType("cms-editor-field-type").reduce(function (acc, item) {
16
16
  return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, acc), {}, (0, _defineProperty2.default)({}, item.field.type, item.field));
17
17
  }, {});
18
- var typePrefix = graphQLTypePrefix !== null && graphQLTypePrefix !== void 0 ? graphQLTypePrefix : model.singularApiName;
18
+ var typePrefix = graphQLTypePrefix ?? model.singularApiName;
19
19
  var allFields = fields.map(function (field) {
20
20
  if (!fieldPlugins[field.type]) {
21
21
  console.log("Unknown field plugin for field type \"".concat(field.type, "\"."));
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","createFieldsList","_ref","model","fields","graphQLTypePrefix","fieldPlugins","plugins","byType","reduce","acc","item","_objectSpread3","default","_defineProperty2","field","type","typePrefix","singularApiName","allFields","map","console","log","concat","graphql","queryField","selection","fieldId","filter","Boolean","length","push","join"],"sources":["createFieldsList.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldTypePlugin, CmsModel } 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,\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 allFields = fields\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 /**\n * If there are no fields for a given type, we add a dummy `_empty` field, which will also be present in the schema\n * on the API side, to protect the schema from invalid types.\n */\n if (!allFields.length) {\n allFields.push(\"_empty\");\n }\n\n return allFields.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAQO,SAASC,gBAAgBA,CAAAC,IAAA,EAIG;EAAA,IAH/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;EAEjB,IAAMC,YAA8D,GAAGC,gBAAO,CACzEC,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,MAAM,CAAC,UAACC,GAAG,EAAEC,IAAI;IAAA,WAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAAWH,GAAG,WAAAI,gBAAA,CAAAD,OAAA,MAAGF,IAAI,CAACI,KAAK,CAACC,IAAI,EAAGL,IAAI,CAACI,KAAK;EAAA,CAAG,EAAE,CAAC,CAAC,CAAC;EAE3E,IAAME,UAAU,GAAGZ,iBAAiB,aAAjBA,iBAAiB,cAAjBA,iBAAiB,GAAIF,KAAK,CAACe,eAAe;EAE7D,IAAMC,SAAS,GAAGf,MAAM,CACnBgB,GAAG,CAAC,UAAAL,KAAK,EAAI;IACV,IAAI,CAACT,YAAY,CAACS,KAAK,CAACC,IAAI,CAAC,EAAE;MAC3BK,OAAO,CAACC,GAAG,0CAAAC,MAAA,CAAyCR,KAAK,CAACC,IAAI,QAAI,CAAC;MACnE,OAAO,IAAI;IACf;IACA,IAAQQ,OAAO,GAAKlB,YAAY,CAACS,KAAK,CAACC,IAAI,CAAC,CAApCQ,OAAO;IAEf,IAAIA,OAAO,IAAIA,OAAO,CAACC,UAAU,EAAE;MAC/B,IAAQA,UAAU,GAAKD,OAAO,CAAtBC,UAAU;MAClB,IAAMC,SAAS,GACX,OAAOD,UAAU,KAAK,QAAQ,GACxBA,UAAU,GACVA,UAAU,CAAC;QAAEtB,KAAK,EAALA,KAAK;QAAEY,KAAK,EAALA,KAAK;QAAEV,iBAAiB,EAAEY;MAAW,CAAC,CAAC;;MAErE;AAChB;AACA;MACgB,IAAIS,SAAS,KAAK,IAAI,EAAE;QACpB,OAAO,IAAI;MACf;MAEA,UAAAH,MAAA,CAAUR,KAAK,CAACY,OAAO,OAAAJ,MAAA,CAAIG,SAAS;IACxC;IAEA,OAAOX,KAAK,CAACY,OAAO;EACxB,CAAC,CAAC,CACDC,MAAM,CAACC,OAAO,CAAC;;EAEpB;AACJ;AACA;AACA;EACI,IAAI,CAACV,SAAS,CAACW,MAAM,EAAE;IACnBX,SAAS,CAACY,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAOZ,SAAS,CAACa,IAAI,CAAC,IAAI,CAAC;AAC/B"}
1
+ {"version":3,"names":["_plugins","require","createFieldsList","_ref","model","fields","graphQLTypePrefix","fieldPlugins","plugins","byType","reduce","acc","item","_objectSpread3","default","_defineProperty2","field","type","typePrefix","singularApiName","allFields","map","console","log","concat","graphql","queryField","selection","fieldId","filter","Boolean","length","push","join"],"sources":["createFieldsList.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldTypePlugin, CmsModel } 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,\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 allFields = fields\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 /**\n * If there are no fields for a given type, we add a dummy `_empty` field, which will also be present in the schema\n * on the API side, to protect the schema from invalid types.\n */\n if (!allFields.length) {\n allFields.push(\"_empty\");\n }\n\n return allFields.join(\"\\n\");\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAQO,SAASC,gBAAgBA,CAAAC,IAAA,EAIG;EAAA,IAH/BC,KAAK,GAAAD,IAAA,CAALC,KAAK;IACLC,MAAM,GAAAF,IAAA,CAANE,MAAM;IACNC,iBAAiB,GAAAH,IAAA,CAAjBG,iBAAiB;EAEjB,IAAMC,YAA8D,GAAGC,gBAAO,CACzEC,MAAM,CAA0B,uBAAuB,CAAC,CACxDC,MAAM,CAAC,UAACC,GAAG,EAAEC,IAAI;IAAA,WAAAC,cAAA,CAAAC,OAAA,MAAAD,cAAA,CAAAC,OAAA,MAAWH,GAAG,WAAAI,gBAAA,CAAAD,OAAA,MAAGF,IAAI,CAACI,KAAK,CAACC,IAAI,EAAGL,IAAI,CAACI,KAAK;EAAA,CAAG,EAAE,CAAC,CAAC,CAAC;EAE3E,IAAME,UAAU,GAAGZ,iBAAiB,IAAIF,KAAK,CAACe,eAAe;EAE7D,IAAMC,SAAS,GAAGf,MAAM,CACnBgB,GAAG,CAAC,UAAAL,KAAK,EAAI;IACV,IAAI,CAACT,YAAY,CAACS,KAAK,CAACC,IAAI,CAAC,EAAE;MAC3BK,OAAO,CAACC,GAAG,0CAAAC,MAAA,CAAyCR,KAAK,CAACC,IAAI,QAAI,CAAC;MACnE,OAAO,IAAI;IACf;IACA,IAAQQ,OAAO,GAAKlB,YAAY,CAACS,KAAK,CAACC,IAAI,CAAC,CAApCQ,OAAO;IAEf,IAAIA,OAAO,IAAIA,OAAO,CAACC,UAAU,EAAE;MAC/B,IAAQA,UAAU,GAAKD,OAAO,CAAtBC,UAAU;MAClB,IAAMC,SAAS,GACX,OAAOD,UAAU,KAAK,QAAQ,GACxBA,UAAU,GACVA,UAAU,CAAC;QAAEtB,KAAK,EAALA,KAAK;QAAEY,KAAK,EAALA,KAAK;QAAEV,iBAAiB,EAAEY;MAAW,CAAC,CAAC;;MAErE;AAChB;AACA;MACgB,IAAIS,SAAS,KAAK,IAAI,EAAE;QACpB,OAAO,IAAI;MACf;MAEA,UAAAH,MAAA,CAAUR,KAAK,CAACY,OAAO,OAAAJ,MAAA,CAAIG,SAAS;IACxC;IAEA,OAAOX,KAAK,CAACY,OAAO;EACxB,CAAC,CAAC,CACDC,MAAM,CAACC,OAAO,CAAC;;EAEpB;AACJ;AACA;AACA;EACI,IAAI,CAACV,SAAS,CAACW,MAAM,EAAE;IACnBX,SAAS,CAACY,IAAI,CAAC,QAAQ,CAAC;EAC5B;EAEA,OAAOZ,SAAS,CAACa,IAAI,CAAC,IAAI,CAAC;AAC/B"}
@@ -10,8 +10,8 @@ var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
10
  var _createFieldsList = require("./createFieldsList");
11
11
  var _getModelTitleFieldId = require("./getModelTitleFieldId");
12
12
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
13
- var CONTENT_META_FIELDS = /* GraphQL */"\n meta {\n title\n description\n image\n publishedOn\n version\n locked\n status\n }\n";
14
- var CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */"\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ".concat(CONTENT_META_FIELDS, "\n");
13
+ var CONTENT_META_FIELDS = /* GraphQL */"\n meta {\n title\n description\n image\n version\n locked\n status\n }\n";
14
+ var CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */"\n id\n entryId\n createdOn\n savedOn\n modifiedOn\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 firstPublishedBy {\n id\n type\n displayName\n }\n lastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\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 revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\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 revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ".concat(CONTENT_META_FIELDS, "\n");
15
15
  var ERROR_FIELD = /* GraphQL */"\n {\n message\n code\n data\n }\n";
16
16
 
17
17
  /**
@@ -102,7 +102,10 @@ var createUpdateMutation = function createUpdateMutation(model) {
102
102
  */
103
103
  exports.createUpdateMutation = createUpdateMutation;
104
104
  var createPublishMutation = function createPublishMutation(model) {
105
- return (0, _graphqlTag.default)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsPublish", "($revision: ID!) {\n content: publish", "(revision: $revision) {\n data {\n id\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_META_FIELDS, ERROR_FIELD);
105
+ return (0, _graphqlTag.default)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsPublish", "($revision: ID!) {\n content: publish", "(revision: $revision) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
106
+ model: model,
107
+ fields: model.fields
108
+ }), ERROR_FIELD);
106
109
  };
107
110
 
108
111
  /**
@@ -111,7 +114,10 @@ var createPublishMutation = function createPublishMutation(model) {
111
114
  */
112
115
  exports.createPublishMutation = createPublishMutation;
113
116
  var createUnpublishMutation = function createUnpublishMutation(model) {
114
- return (0, _graphqlTag.default)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUnpublish", "($revision: ID!) {\n content: unpublish", "(revision: $revision) {\n data {\n id\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_META_FIELDS, ERROR_FIELD);
117
+ return (0, _graphqlTag.default)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUnpublish", "($revision: ID!) {\n content: unpublish", "(revision: $revision) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
118
+ model: model,
119
+ fields: model.fields
120
+ }), ERROR_FIELD);
115
121
  };
116
122
  exports.createUnpublishMutation = createUnpublishMutation;
117
123
 
@@ -1 +1 @@
1
- {"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_createFieldsList","_getModelTitleFieldId","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","CONTENT_META_FIELDS","CONTENT_ENTRY_SYSTEM_FIELDS","concat","ERROR_FIELD","createReadQuery","model","gql","_taggedTemplateLiteral2","default","singularApiName","createFieldsList","fields","exports","createRevisionsQuery","createListQuery","pluralApiName","getModelTitleFieldId","createDeleteMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createPublishMutation","createUnpublishMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport {\n CmsContentEntryRevision,\n CmsContentEntry,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModelField\n} from \"~/types\";\nimport { createFieldsList } from \"./createFieldsList\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId\";\nimport { FormSubmitOptions } from \"@webiny/form\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n meta {\n title\n description\n image\n publishedOn\n version\n locked\n status\n }\n`;\n\nconst CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */ `\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ${CONTENT_META_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 createListQuery = (model: CmsEditorContentModel, fields?: CmsModelField[]) => {\n return gql`\n query CmsEntriesList${model.pluralApiName}($where: ${\n model.singularApiName\n }ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\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}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!) {\n content: delete${model.singularApiName}(revision: $revision) {\n data\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?: FormSubmitOptions;\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: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\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?: FormSubmitOptions;\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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?: FormSubmitOptions;\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 id\n ${CONTENT_META_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 id\n ${CONTENT_META_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAA8D,IAAAG,eAAA,EAAAC,gBAAA,EA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ACS,OAAA,CAAAW,uBAAA,GAAAA,uBAAA"}
1
+ {"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_createFieldsList","_getModelTitleFieldId","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","CONTENT_META_FIELDS","CONTENT_ENTRY_SYSTEM_FIELDS","concat","ERROR_FIELD","createReadQuery","model","gql","_taggedTemplateLiteral2","default","singularApiName","createFieldsList","fields","exports","createRevisionsQuery","createListQuery","pluralApiName","getModelTitleFieldId","createDeleteMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createPublishMutation","createUnpublishMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport {\n CmsContentEntryRevision,\n CmsContentEntry,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModelField\n} from \"~/types\";\nimport { createFieldsList } from \"./createFieldsList\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId\";\nimport { FormSubmitOptions } from \"@webiny/form\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n meta {\n title\n description\n image\n version\n locked\n status\n }\n`;\n\nconst CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */ `\n id\n entryId\n createdOn\n savedOn\n modifiedOn\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 firstPublishedBy {\n id\n type\n displayName\n }\n lastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\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 revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n revisionCreatedOn\n revisionSavedOn\n revisionModifiedOn\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 revisionFirstPublishedBy {\n id\n type\n displayName\n }\n revisionLastPublishedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ${CONTENT_META_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 createListQuery = (model: CmsEditorContentModel, fields?: CmsModelField[]) => {\n return gql`\n query CmsEntriesList${model.pluralApiName}($where: ${\n model.singularApiName\n }ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\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}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!) {\n content: delete${model.singularApiName}(revision: $revision) {\n data\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?: FormSubmitOptions;\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: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\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?: FormSubmitOptions;\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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?: FormSubmitOptions;\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\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 ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAA8D,IAAAG,eAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA,EAAAC,gBAAA;AAG9D,IAAMC,mBAAmB,GAAG,wIAS3B;AAED,IAAMC,2BAA2B,GAAG,6kDAAAC,MAAA,CAgG9BF,mBAAmB,OACxB;AAED,IAAMG,WAAW,GAAG,4EAMnB;;AAED;AACA;AACA;AACA;;AAaO,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIC,KAA4B,EAAK;EAC7D;AACJ;AACA;EACI,WAAOC,mBAAG,EAAAf,eAAA,KAAAA,eAAA,OAAAgB,uBAAA,CAAAC,OAAA,6SACeH,KAAK,CAACI,eAAe,EACxBJ,KAAK,CAACI,eAAe,EAEzBR,2BAA2B,EAC3B,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A2B,EAC3B,IAAAS,kCAAgB,EAAC;IAAEL,KAAK,EAALA,KAAK;IAAEM,MAAM,EAAEN,KAAK,CAACM;EAAO,CAAC,CAAC,EAE/CR,WAAW;AAInC,CAAC;;AAED;AACA;AACA;AACA;AAHAS,OAAA,CAAAS,oBAAA,GAAAA,oBAAA;AAeO,IAAMC,qBAAqB,GAAG,SAAxBA,qBAAqBA,CAAIjB,KAA4B,EAAK;EACnE,WAAOC,mBAAG,EAAAR,gBAAA,KAAAA,gBAAA,OAAAS,uBAAA,CAAAC,OAAA,2QACeH,KAAK,CAACI,eAAe,EACpBJ,KAAK,CAACI,eAAe,EAE7BR,2BAA2B,EAC3B,IAAAS,kCAAgB,EAAC;IAAEL,KAAK,EAALA,KAAK;IAAEM,MAAM,EAAEN,KAAK,CAACM;EAAO,CAAC,CAAC,EAE/CR,WAAW;AAGnC,CAAC;;AAED;AACA;AACA;AACA;AAHAS,OAAA,CAAAU,qBAAA,GAAAA,qBAAA;AAeO,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,CAAIlB,KAA4B,EAAK;EACrE,WAAOC,mBAAG,EAAAP,gBAAA,KAAAA,gBAAA,OAAAQ,uBAAA,CAAAC,OAAA,gRACiBH,KAAK,CAACI,eAAe,EACpBJ,KAAK,CAACI,eAAe,EAE/BR,2BAA2B,EAC3B,IAAAS,kCAAgB,EAAC;IAAEL,KAAK,EAALA,KAAK;IAAEM,MAAM,EAAEN,KAAK,CAACM;EAAO,CAAC,CAAC,EAE/CR,WAAW;AAGnC,CAAC;AAACS,OAAA,CAAAW,uBAAA,GAAAA,uBAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms-common",
3
- "version": "5.39.0-beta.1",
3
+ "version": "5.39.0-beta.3",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -16,9 +16,9 @@
16
16
  "@babel/runtime": "7.22.6",
17
17
  "@fortawesome/fontawesome-svg-core": "1.3.0",
18
18
  "@types/react": "17.0.39",
19
- "@webiny/app-security": "5.39.0-beta.1",
20
- "@webiny/form": "5.39.0-beta.1",
21
- "@webiny/plugins": "5.39.0-beta.1",
19
+ "@webiny/app-security": "5.39.0-beta.3",
20
+ "@webiny/form": "5.39.0-beta.3",
21
+ "@webiny/plugins": "5.39.0-beta.3",
22
22
  "graphql": "15.8.0",
23
23
  "graphql-tag": "2.12.6",
24
24
  "prop-types": "15.8.1",
@@ -31,8 +31,8 @@
31
31
  "@babel/preset-env": "7.22.7",
32
32
  "@babel/preset-react": "7.22.5",
33
33
  "@babel/preset-typescript": "7.22.5",
34
- "@webiny/cli": "5.39.0-beta.1",
35
- "@webiny/project-utils": "5.39.0-beta.1",
34
+ "@webiny/cli": "5.39.0-beta.3",
35
+ "@webiny/project-utils": "5.39.0-beta.3",
36
36
  "babel-plugin-emotion": "9.2.11",
37
37
  "babel-plugin-module-resolver": "4.1.0",
38
38
  "rimraf": "3.0.2",
@@ -47,5 +47,5 @@
47
47
  "build": "yarn webiny run build",
48
48
  "watch": "yarn webiny run watch"
49
49
  },
50
- "gitHead": "a22d4ab9fbb4ad35106687cbe17b51a84afd4976"
50
+ "gitHead": "3846541fd9c1764e6a8041f0b4208d720eb9c314"
51
51
  }
@@ -1,2 +1,2 @@
1
- import { CmsContentEntry, CmsModelField } from "./types";
2
- export declare const prepareFormData: (input: Partial<CmsContentEntry>, fields: CmsModelField[]) => CmsContentEntry;
1
+ import { CmsModelField } from "./types";
2
+ export declare const prepareFormData: <T extends Record<string, any>>(input: T, fields: CmsModelField[]) => T;
@@ -57,9 +57,10 @@ var prepareFormData = function prepareFormData(input, fields) {
57
57
  var runTransformation = createTransformationRunner();
58
58
  return fields.reduce(function (output, field) {
59
59
  var inputValue = input[field.fieldId];
60
+ var fieldId = field.fieldId;
60
61
  if (field.multipleValues) {
61
62
  var values = Array.isArray(inputValue) ? inputValue : undefined;
62
- if (!(values !== null && values !== void 0 && values.length)) {
63
+ if (!values) {
63
64
  return output;
64
65
  }
65
66
  /**
@@ -73,7 +74,7 @@ var prepareFormData = function prepareFormData(input, fields) {
73
74
  else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {
74
75
  return output;
75
76
  }
76
- output[field.fieldId] = values.map(function (value) {
77
+ output[fieldId] = values.map(function (value) {
77
78
  return runTransformation(field, value);
78
79
  });
79
80
  return output;
@@ -81,7 +82,7 @@ var prepareFormData = function prepareFormData(input, fields) {
81
82
  /**
82
83
  * Regular values, single values.
83
84
  */
84
- output[field.fieldId] = runTransformation(field, inputValue);
85
+ output[fieldId] = runTransformation(field, inputValue);
85
86
  return output;
86
87
  }, {});
87
88
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_plugins","require","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","plugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","_iterator","_createForOfIteratorHelper2","default","_step","s","n","done","value","console","warn","concat","err","e","f","transformationRunner","createTransformationRunner","availablePlugins","field","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map","exports"],"sources":["prepareFormData.ts"],"sourcesContent":["import { CmsContentEntry, 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 = (\n input: Partial<CmsContentEntry>,\n fields: CmsModelField[]\n): CmsContentEntry => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<CmsContentEntry>((output, field) => {\n const inputValue = input[field.fieldId];\n\n if (field.multipleValues) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values?.length) {\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 output[field.fieldId] = values.map(value => runTransformation(field, value));\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[field.fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as CmsContentEntry);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA,IAAIC,2BAAmE,GAAGC,SAAS;AACnF,IAAMC,8BAA8B,GAAG,SAAjCA,8BAA8BA,CAAA,EAAqC;EACrE,IAAIF,2BAA2B,EAAE;IAC7B,OAAOA,2BAA2B;EACtC;EACAA,2BAA2B,GAAGG,gBAAO,CAChCC,MAAM,CAA2B,6BAA6B,CAAC,CAC/DC,MAAM,CAA6B,U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AMO,eAAe,GAAG,SAAlBA,eAAeA,CACxBC,KAA+B,EAC/BC,MAAuB,EACL;EAClB,IAAMC,iBAAiB,GAAGT,0BAA0B,CAAC,CAAC;EAEtD,OAAOQ,MAAM,CAAC9B,MAAM,CAAkB,UAACgC,MAAM,EAAER,KAAK,EAAK;IACrD,IAAMS,UAAU,GAAGJ,KAAK,CAACL,KAAK,CAACU,OAAO,CAAC;IAEvC,IAAIV,KAAK,CAACW,cAAc,EAAE;MACtB,IAAMC,MAAM,GAAGhC,KAAK,CAACC,OAAO,CAAC4B,UAAU,CAAC,GAAGA,UAAU,GAAGrC,SAAS;MACjE,IAAI,EAACwC,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,MAAM,GAAE;QACjB,OAAOL,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,KAAKxC,SAAS,CAAC,EAAE;QAC7E,OAAOoC,MAAM;MACjB;MACAA,MAAM,CAACR,KAAK,CAACU,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAAC,UAAAxB,KAAK;QAAA,OAAIiB,iBAAiB,CAACP,KAAK,EAAEV,KAAK,CAAC;MAAA,EAAC;MAC5E,OAAOkB,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACR,KAAK,CAACU,OAAO,CAAC,GAAGH,iBAAiB,CAACP,KAAK,EAAES,UAAU,CAAC;IAE5D,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAoB,CAAC;AAC7B,CAAC;AAACO,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
1
+ {"version":3,"names":["_plugins","require","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","plugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","_iterator","_createForOfIteratorHelper2","default","_step","s","n","done","value","console","warn","concat","err","e","f","transformationRunner","createTransformationRunner","availablePlugins","field","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map","exports"],"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,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA,IAAIC,2BAAmE,GAAGC,SAAS;AACnF,IAAMC,8BAA8B,GAAG,SAAjCA,8BAA8BA,CAAA,EAAqC;EACrE,IAAIF,2BAA2B,EAAE;IAC7B,OAAOA,2BAA2B;EACtC;EACAA,2BAA2B,GAAGG,gBAAO,CAChCC,MAAM,CAA2B,6BAA6B,CAAC,CAC/DC,MAAM,CAA6B,UAACC,YAAY,EAAEC,EAAE,EAAK;IACtD,IAAMC,UAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,EAAE,CAACI,SAAS,CAAC,GAAGJ,EAAE,CAACI,SAAS,GAAG,CAACJ,EAAE,CAACI,SAAS,CAAC;IAAC,IAAAC,SAAA,OAAAC,2BAAA,CAAAC,OAAA,EACvDN,UAAU;MAAAO,KAAA;IAAA;MAAlC,KAAAH,SAAA,CAAAI,CAAA,MAAAD,KAAA,GAAAH,SAAA,CAAAK,CAAA,IAAAC,IAAA,GAAoC;QAAA,IAAzBP,UAAS,GAAAI,KAAA,CAAAI,KAAA;QAChB,IAAIb,YAAY,CAACK,UAAS,CAAC,EAAE;UACzBS,OAAO,CAACC,IAAI,iCAAAC,MAAA,CACuBX,UAAS,sEAC5C,CAAC;UACD;QACJ;QACAL,YAAY,CAACK,UAAS,CAAC,GAAGJ,EAAE;MAChC;IAAC,SA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K,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,KAAKxC,SAAS,CAAC,EAAE;QAC7E,OAAOoC,MAAM;MACjB;MAEAA,MAAM,CAACE,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAAC,UAAAxB,KAAK;QAAA,OAAIiB,iBAAiB,CAACP,KAAK,EAAEV,KAAK,CAAC;MAAA,EAAC;MAEtE,OAAOkB,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACE,OAAO,CAAC,GAAGH,iBAAiB,CAACP,KAAK,EAAES,UAAU,CAAC;IAEtD,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC;AAACO,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
package/types/index.d.ts CHANGED
@@ -211,8 +211,8 @@ export interface CmsModelFieldTypePlugin extends Plugin {
211
211
  }
212
212
  export interface CmsModelFieldRendererProps {
213
213
  field: CmsModelField;
214
- Label: React.FC;
215
- getBind: (index?: number, key?: string) => BindComponent;
214
+ Label: React.ComponentType;
215
+ getBind: <T = any, F = any>(index?: number, key?: string) => BindComponent<T, F>;
216
216
  contentModel: CmsModel;
217
217
  }
218
218
  /**
@@ -320,15 +320,32 @@ export declare type CmsContentEntryStatusType = "draft" | "published" | "unpubli
320
320
  export declare type CmsEditorContentEntry = CmsContentEntry;
321
321
  export interface CmsContentEntry {
322
322
  id: string;
323
- savedOn: string;
324
323
  modelId: string;
324
+ createdOn: string;
325
325
  createdBy: CmsIdentity;
326
+ savedOn: string;
327
+ savedBy: CmsIdentity;
328
+ modifiedOn: string | null;
329
+ modifiedBy: CmsIdentity | null;
330
+ firstPublishedOn: string | null;
331
+ firstPublishedBy: CmsIdentity | null;
332
+ lastPublishedOn: string | null;
333
+ lastPublishedBy: CmsIdentity | null;
334
+ revisionCreatedOn: string;
335
+ revisionCreatedBy: CmsIdentity;
336
+ revisionSavedOn: string;
337
+ revisionSavedBy: CmsIdentity;
338
+ revisionModifiedOn: string | null;
339
+ revisionModifiedBy: CmsIdentity | null;
340
+ revisionFirstPublishedOn: string | null;
341
+ revisionFirstPublishedBy: CmsIdentity | null;
342
+ revisionLastPublishedOn: string | null;
343
+ revisionLastPublishedBy: CmsIdentity | null;
326
344
  wbyAco_location: Location;
327
345
  meta: {
328
346
  title: string;
329
347
  description?: string;
330
348
  image?: string;
331
- publishedOn: string;
332
349
  locked: boolean;
333
350
  status: CmsContentEntryStatusType;
334
351
  version: number;
@@ -337,19 +354,30 @@ export interface CmsContentEntry {
337
354
  }
338
355
  export interface CmsContentEntryRevision {
339
356
  id: string;
340
- savedOn: string;
341
357
  modelId: string;
358
+ savedOn: string;
359
+ firstPublishedOn: string | null;
360
+ lastPublishedOn: string | null;
342
361
  createdBy: CmsIdentity;
362
+ revisionCreatedOn: string;
363
+ revisionSavedOn: string;
364
+ revisionModifiedOn: string;
365
+ revisionFirstPublishedOn: string;
366
+ revisionLastPublishedOn: string;
367
+ revisionCreatedBy: CmsIdentity;
368
+ revisionSavedBy: CmsIdentity;
369
+ revisionModifiedBy: CmsIdentity;
370
+ revisionFirstPublishedBy: CmsIdentity;
371
+ revisionLastPublishedBy: CmsIdentity;
343
372
  wbyAco_location: Location;
344
373
  meta: {
345
374
  title: string;
346
- publishedOn: string;
347
375
  locked: boolean;
348
376
  status: CmsContentEntryStatusType;
349
377
  version: number;
350
378
  };
351
379
  }
352
- export declare type CmsEditorContentTab = React.FC<{
380
+ export declare type CmsEditorContentTab = React.ComponentType<{
353
381
  activeTab: boolean;
354
382
  }>;
355
383
  export interface CmsEditorFieldOptionPlugin extends Plugin {
@@ -493,11 +521,11 @@ export interface BindComponentRenderProp<T = any, F = Record<string, any>> exten
493
521
  moveValueUp: (index: number) => void;
494
522
  moveValueDown: (index: number) => void;
495
523
  }
496
- interface BindComponentProps extends Omit<BaseBindComponentProps, "children" | "name"> {
524
+ interface BindComponentProps<T = any, F = any> extends Omit<BaseBindComponentProps, "children" | "name"> {
497
525
  name?: string;
498
- children?: ((props: BindComponentRenderProp) => React.ReactElement) | React.ReactElement;
526
+ children?: ((props: BindComponentRenderProp<T, F>) => React.ReactElement) | React.ReactElement;
499
527
  }
500
- export declare type BindComponent = React.FC<BindComponentProps> & {
528
+ export declare type BindComponent<T = any, F = any> = React.ComponentType<BindComponentProps<T, F>> & {
501
529
  parentName?: string;
502
530
  };
503
531
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["_validation","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_model","_shared"],"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 { DragObjectWithType } from \"react-dnd\";\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 * 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 CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.FC;\n getBind: (index?: number, key?: string) => BindComponent;\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 };\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}\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 savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.FC<{ 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(): CmsIcon[];\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>;\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, F = Record<string, any>>\n extends BaseBindComponentRenderProp<T, F> {\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 extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent = React.FC<BindComponentProps> & {\n parentName?: string;\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":";;;;;AAoBA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,OAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_validation","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_model","_shared"],"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 { DragObjectWithType } from \"react-dnd\";\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 * 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 CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.ComponentType;\n getBind: <T = any, F = any>(index?: number, key?: string) => BindComponent<T, F>;\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 };\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}\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 modelId: string;\n createdOn: string;\n createdBy: CmsIdentity;\n savedOn: string;\n savedBy: CmsIdentity;\n modifiedOn: string | null;\n modifiedBy: 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 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 firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string;\n revisionFirstPublishedOn: string;\n revisionLastPublishedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity;\n revisionFirstPublishedBy: CmsIdentity;\n revisionLastPublishedBy: CmsIdentity;\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(): CmsIcon[];\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>;\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, F = Record<string, any>>\n extends BaseBindComponentRenderProp<T, F> {\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, F = any>\n extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp<T, F>) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent<T = any, F = any> = React.ComponentType<BindComponentProps<T, F>> & {\n parentName?: string;\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":";;;;;AAoBA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,OAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
package/types/model.d.ts CHANGED
@@ -54,7 +54,7 @@ export interface CmsGroup {
54
54
  id: string;
55
55
  name: string;
56
56
  slug: string;
57
- icon?: string;
57
+ icon: string;
58
58
  description?: string;
59
59
  contentModels: CmsModel[];
60
60
  createdBy: CmsIdentity;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import { 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[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\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"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["model.ts"],"sourcesContent":["import { 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[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\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"],"mappings":""}