@webiny/app-headless-cms-common 5.40.0-beta.2 → 5.40.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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":";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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","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import { CmsContentEntryRevision, CmsContentEntry, CmsEditorContentModel, CmsErrorResponse, CmsMetaResponse, CmsModelField } from "./types";
2
- import { FormSubmitOptions } from "@webiny/form";
2
+ import { FormValidationOptions } from "@webiny/form";
3
3
  /**
4
4
  * ############################################
5
5
  * Get CMS Entry Query
@@ -49,7 +49,8 @@ export interface CmsEntriesListQueryVariables {
49
49
  limit?: number;
50
50
  after?: string;
51
51
  }
52
- export declare const createListQuery: (model: CmsEditorContentModel, fields?: CmsModelField[]) => import("graphql").DocumentNode;
52
+ export declare const createListQueryDataSelection: (model: CmsEditorContentModel, fields?: CmsModelField[]) => string;
53
+ export declare const createListQuery: (model: CmsEditorContentModel, fields?: CmsModelField[], deleted?: boolean) => import("graphql").DocumentNode;
53
54
  /**
54
55
  * ############################################
55
56
  * Delete Mutation
@@ -62,8 +63,23 @@ export interface CmsEntryDeleteMutationResponse {
62
63
  }
63
64
  export interface CmsEntryDeleteMutationVariables {
64
65
  revision: string;
66
+ permanently?: boolean;
65
67
  }
66
68
  export declare const createDeleteMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
69
+ /**
70
+ * ############################################
71
+ * Restore from bin Mutation
72
+ */
73
+ export interface CmsEntryRestoreFromBinMutationResponse {
74
+ content: {
75
+ data: CmsContentEntry | null;
76
+ error: CmsErrorResponse | null;
77
+ };
78
+ }
79
+ export interface CmsEntryRestoreFromBinMutationVariables {
80
+ revision: string;
81
+ }
82
+ export declare const createRestoreFromBinMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
67
83
  /**
68
84
  * ############################################
69
85
  * Create Mutation
@@ -79,7 +95,7 @@ export interface CmsEntryCreateMutationVariables {
79
95
  * We have any here because we do not know which fields does entry have
80
96
  */
81
97
  data: Record<string, any>;
82
- options?: FormSubmitOptions;
98
+ options?: FormValidationOptions;
83
99
  }
84
100
  export declare const createCreateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
85
101
  /**
@@ -98,7 +114,7 @@ export interface CmsEntryCreateFromMutationVariables {
98
114
  * We have any here because we do not know which fields does entry have
99
115
  */
100
116
  data?: Record<string, any>;
101
- options?: FormSubmitOptions;
117
+ options?: FormValidationOptions;
102
118
  }
103
119
  export declare const createCreateFromMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
104
120
  /**
@@ -117,7 +133,7 @@ export interface CmsEntryUpdateMutationVariables {
117
133
  * We have any here because we do not know which fields does entry have
118
134
  */
119
135
  data: Record<string, any>;
120
- options?: FormSubmitOptions;
136
+ options?: FormValidationOptions;
121
137
  }
122
138
  export declare const createUpdateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
123
139
  /**
@@ -4,14 +4,14 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.createUpdateMutation = exports.createUnpublishMutation = exports.createRevisionsQuery = exports.createReadQuery = exports.createPublishMutation = exports.createListQuery = exports.createDeleteMutation = exports.createCreateMutation = exports.createCreateFromMutation = void 0;
7
+ exports.createUpdateMutation = exports.createUnpublishMutation = exports.createRevisionsQuery = exports.createRestoreFromBinMutation = exports.createReadQuery = exports.createPublishMutation = exports.createListQueryDataSelection = exports.createListQuery = exports.createDeleteMutation = exports.createCreateMutation = exports.createCreateFromMutation = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
9
  var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
10
10
  var _createFieldsList = require("./createFieldsList");
11
11
  var _getModelTitleFieldId = require("./getModelTitleFieldId");
12
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
12
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
13
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");
14
+ var CONTENT_ENTRY_SYSTEM_FIELDS = /* 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 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
  /**
@@ -19,7 +19,7 @@ var ERROR_FIELD = /* GraphQL */"\n {\n message\n code\n
19
19
  * Get CMS Entry Query
20
20
  */
21
21
 
22
- var createReadQuery = function createReadQuery(model) {
22
+ var createReadQuery = exports.createReadQuery = function createReadQuery(model) {
23
23
  /**
24
24
  * This query now accepts both revision or entryId as we can load exact revision or latest (if entryId was sent).
25
25
  */
@@ -33,8 +33,8 @@ var createReadQuery = function createReadQuery(model) {
33
33
  * ############################################
34
34
  * List CMS Entry Revisions Query
35
35
  */
36
- exports.createReadQuery = createReadQuery;
37
- var createRevisionsQuery = function createRevisionsQuery(model) {
36
+
37
+ var createRevisionsQuery = exports.createRevisionsQuery = function createRevisionsQuery(model) {
38
38
  return (0, _graphqlTag.default)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n query CmsEntriesGet", "Revisions($id: ID!) {\n revisions: get", "Revisions(id: $id) {\n data {\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, ERROR_FIELD);
39
39
  };
40
40
 
@@ -42,43 +42,59 @@ var createRevisionsQuery = function createRevisionsQuery(model) {
42
42
  * ############################################
43
43
  * List CMS Entries Query
44
44
  */
45
- exports.createRevisionsQuery = createRevisionsQuery;
46
- var createListQuery = function createListQuery(model, fields) {
47
- return (0, _graphqlTag.default)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n query CmsEntriesList", "($where: ", "ListWhereInput, $sort: [", "ListSorter], $limit: Int, $after: String, $search: String) {\n content: list", "(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ", "\n ", "\n ", "\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ", "\n }\n }\n "])), model.pluralApiName, model.singularApiName, model.singularApiName, model.pluralApiName, CONTENT_ENTRY_SYSTEM_FIELDS, fields ? (0, _createFieldsList.createFieldsList)({
45
+
46
+ var createListQueryDataSelection = exports.createListQueryDataSelection = function createListQueryDataSelection(model, fields) {
47
+ return "\n ".concat(CONTENT_ENTRY_SYSTEM_FIELDS, "\n ").concat(fields ? (0, _createFieldsList.createFieldsList)({
48
48
  model: model,
49
49
  fields: fields
50
- }) : "", !fields ? (0, _getModelTitleFieldId.getModelTitleFieldId)(model) : "", ERROR_FIELD);
50
+ }) : "", "\n ").concat(!fields ? (0, _getModelTitleFieldId.getModelTitleFieldId)(model) : "", "\n ");
51
+ };
52
+ var createListQuery = exports.createListQuery = function createListQuery(model, fields, deleted) {
53
+ var queryName = deleted ? "Deleted".concat(model.pluralApiName) : model.pluralApiName;
54
+ return (0, _graphqlTag.default)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n query CmsEntriesList", "($where: ", "ListWhereInput, $sort: [", "ListSorter], $limit: Int, $after: String, $search: String) {\n content: list", "(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ", "\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ", "\n }\n }\n "])), queryName, model.singularApiName, model.singularApiName, queryName, createListQueryDataSelection(model, fields), ERROR_FIELD);
51
55
  };
52
56
 
53
57
  /**
54
58
  * ############################################
55
59
  * Delete Mutation
56
60
  */
57
- exports.createListQuery = createListQuery;
58
- var createDeleteMutation = function createDeleteMutation(model) {
59
- return (0, _graphqlTag.default)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsEntriesDelete", "($revision: ID!) {\n content: delete", "(revision: $revision) {\n data\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, ERROR_FIELD);
61
+
62
+ var createDeleteMutation = exports.createDeleteMutation = function createDeleteMutation(model) {
63
+ return (0, _graphqlTag.default)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsEntriesDelete", "($revision: ID!, $permanently: Boolean) {\n content: delete", "(revision: $revision, options: {permanently: $permanently}) {\n data\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, ERROR_FIELD);
64
+ };
65
+
66
+ /**
67
+ * ############################################
68
+ * Restore from bin Mutation
69
+ */
70
+
71
+ var createRestoreFromBinMutation = exports.createRestoreFromBinMutation = function createRestoreFromBinMutation(model) {
72
+ return (0, _graphqlTag.default)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsEntriesRestore", "FromBin($revision: ID!) {\n content: restore", "FromBin(revision: $revision) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
73
+ model: model,
74
+ fields: model.fields
75
+ }), ERROR_FIELD);
60
76
  };
61
77
 
62
78
  /**
63
79
  * ############################################
64
80
  * Create Mutation
65
81
  */
66
- exports.createDeleteMutation = createDeleteMutation;
67
- var createCreateMutation = function createCreateMutation(model) {
82
+
83
+ var createCreateMutation = exports.createCreateMutation = function createCreateMutation(model) {
68
84
  var createFields = (0, _createFieldsList.createFieldsList)({
69
85
  model: model,
70
86
  fields: model.fields
71
87
  });
72
- return (0, _graphqlTag.default)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsEntriesCreate", "($data: ", "Input!, $options: CreateCmsEntryOptionsInput) {\n content: create", "(data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, createFields, ERROR_FIELD);
88
+ return (0, _graphqlTag.default)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsEntriesCreate", "($data: ", "Input!, $options: CreateCmsEntryOptionsInput) {\n content: create", "(data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, createFields, ERROR_FIELD);
73
89
  };
74
90
 
75
91
  /**
76
92
  * ############################################
77
93
  * Create From Mutation
78
94
  */
79
- exports.createCreateMutation = createCreateMutation;
80
- var createCreateFromMutation = function createCreateFromMutation(model) {
81
- return (0, _graphqlTag.default)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsCreate", "From($revision: ID!, $data: ", "Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create", "From(revision: $revision, data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
95
+
96
+ var createCreateFromMutation = exports.createCreateFromMutation = function createCreateFromMutation(model) {
97
+ return (0, _graphqlTag.default)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsCreate", "From($revision: ID!, $data: ", "Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create", "From(revision: $revision, data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
82
98
  model: model,
83
99
  fields: model.fields
84
100
  }), ERROR_FIELD);
@@ -88,9 +104,9 @@ var createCreateFromMutation = function createCreateFromMutation(model) {
88
104
  * ############################################
89
105
  * Update Mutation
90
106
  */
91
- exports.createCreateFromMutation = createCreateFromMutation;
92
- var createUpdateMutation = function createUpdateMutation(model) {
93
- return (0, _graphqlTag.default)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUpdate", "($revision: ID!, $data: ", "Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update", "(revision: $revision, data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
107
+
108
+ var createUpdateMutation = exports.createUpdateMutation = function createUpdateMutation(model) {
109
+ return (0, _graphqlTag.default)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUpdate", "($revision: ID!, $data: ", "Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update", "(revision: $revision, data: $data, options: $options) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }\n "])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
94
110
  model: model,
95
111
  fields: model.fields
96
112
  }), ERROR_FIELD);
@@ -100,9 +116,9 @@ var createUpdateMutation = function createUpdateMutation(model) {
100
116
  * ############################################
101
117
  * Publish Mutation
102
118
  */
103
- exports.createUpdateMutation = createUpdateMutation;
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 ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
119
+
120
+ var createPublishMutation = exports.createPublishMutation = function createPublishMutation(model) {
121
+ return (0, _graphqlTag.default)(_templateObject9 || (_templateObject9 = (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
122
  model: model,
107
123
  fields: model.fields
108
124
  }), ERROR_FIELD);
@@ -112,13 +128,12 @@ var createPublishMutation = function createPublishMutation(model) {
112
128
  * ############################################
113
129
  * Unpublish Mutation
114
130
  */
115
- exports.createPublishMutation = createPublishMutation;
116
- var createUnpublishMutation = function createUnpublishMutation(model) {
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)({
131
+
132
+ var createUnpublishMutation = exports.createUnpublishMutation = function createUnpublishMutation(model) {
133
+ return (0, _graphqlTag.default)(_templateObject10 || (_templateObject10 = (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
134
  model: model,
119
135
  fields: model.fields
120
136
  }), ERROR_FIELD);
121
137
  };
122
- exports.createUnpublishMutation = createUnpublishMutation;
123
138
 
124
139
  //# sourceMappingURL=entries.graphql.js.map
@@ -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 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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,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"}
1
+ {"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_createFieldsList","_getModelTitleFieldId","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","_templateObject10","CONTENT_META_FIELDS","CONTENT_ENTRY_SYSTEM_FIELDS","concat","ERROR_FIELD","createReadQuery","exports","model","gql","_taggedTemplateLiteral2","default","singularApiName","createFieldsList","fields","createRevisionsQuery","createListQueryDataSelection","getModelTitleFieldId","createListQuery","deleted","queryName","pluralApiName","createDeleteMutation","createRestoreFromBinMutation","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 { FormValidationOptions } 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 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 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 createListQueryDataSelection = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[]\n) => {\n return `\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\n `;\n};\n\nexport const createListQuery = (\n model: CmsEditorContentModel,\n fields?: CmsModelField[],\n deleted?: boolean\n) => {\n const queryName = deleted ? `Deleted${model.pluralApiName}` : model.pluralApiName;\n\n return gql`\n query CmsEntriesList${queryName}($where: ${model.singularApiName}ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${queryName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${createListQueryDataSelection(model, fields)}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Delete Mutation\n */\nexport interface CmsEntryDeleteMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryDeleteMutationVariables {\n revision: string;\n permanently?: boolean;\n}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!, $permanently: Boolean) {\n content: delete${model.singularApiName}(revision: $revision, options: {permanently: $permanently}) {\n data\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Restore from bin Mutation\n */\nexport interface CmsEntryRestoreFromBinMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryRestoreFromBinMutationVariables {\n revision: string;\n}\n\nexport const createRestoreFromBinMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesRestore${model.singularApiName}FromBin($revision: ID!) {\n content: restore${model.singularApiName}FromBin(revision: $revision) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create Mutation\n */\nexport interface CmsEntryCreateMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryCreateMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormValidationOptions;\n}\n\nexport const createCreateMutation = (model: CmsEditorContentModel) => {\n const createFields = createFieldsList({ model, fields: model.fields });\n\n return gql`\n mutation CmsEntriesCreate${model.singularApiName}($data: ${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?: 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 ${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?: 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 ${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,EAAAC,iBAAA;AAG9D,IAAMC,mBAAmB,GAAG,wIAS3B;AAED,IAAMC,2BAA2B,GAAG,0wDAAAC,MAAA,CA4G9BF,mBAAmB,OACxB;AAED,IAAMG,WAAW,GAAG,4EAMnB;;AAED;AACA;AACA;AACA;;AAaO,IAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,SAAlBA,eAAeA,CAAIE,KAA4B,EAAK;EAC7D;AACJ;AACA;EACI,WAAOC,mBAAG,EAAAjB,eAAA,KAAAA,eAAA,OAAAkB,uBAAA,CAAAC,OAAA,6SACeH,KAAK,CAACI,eAAe,EACxBJ,KAAK,CAACI,eAAe,EAEzBT,2BAA2B,EAC3B,IAAAU,kCAAgB,EAAC;IAAEL,KAAK,EAALA,KAAK;IAAEM,MAAM,EAAEN,KAAK,CAACM;EAAO,CAAC,CAAC,EAE/CT,WAAW;AAInC,CAAC;;AAED;AACA;AACA;AACA;;AAaO,IAAMU,oBAAoB,GAAAR,OAAA,CAAAQ,oBAAA,GAAG,SAAvBA,oBAAoBA,CAAIP,KAA4B,EAAK;EAClE,WAAOC,mBAAG,EAAAhB,gBAAA,KAAAA,gBAAA,OAAAiB,uBAA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O,CAAC,CAAC,EAE/CT,WAAW;AAGnC,CAAC","ignoreList":[]}
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getModelTitleFieldId = void 0;
7
- var getModelTitleFieldId = function getModelTitleFieldId(model) {
7
+ var getModelTitleFieldId = exports.getModelTitleFieldId = function getModelTitleFieldId(model) {
8
8
  if (!model.titleFieldId || model.titleFieldId === "id") {
9
9
  return "";
10
10
  }
11
11
  return model.titleFieldId;
12
12
  };
13
- exports.getModelTitleFieldId = getModelTitleFieldId;
14
13
 
15
14
  //# sourceMappingURL=getModelTitleFieldId.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getModelTitleFieldId","model","titleFieldId","exports"],"sources":["getModelTitleFieldId.ts"],"sourcesContent":["import { CmsEditorContentModel } from \"~/types\";\n\nexport const getModelTitleFieldId = (model: CmsEditorContentModel): string => {\n if (!model.titleFieldId || model.titleFieldId === \"id\") {\n return \"\";\n }\n return model.titleFieldId;\n};\n"],"mappings":";;;;;;AAEO,IAAMA,oBAAoB,GAAG,SAAvBA,oBAAoBA,CAAIC,KAA4B,EAAa;EAC1E,IAAI,CAACA,KAAK,CAACC,YAAY,IAAID,KAAK,CAACC,YAAY,KAAK,IAAI,EAAE;IACpD,OAAO,EAAE;EACb;EACA,OAAOD,KAAK,CAACC,YAAY;AAC7B,CAAC;AAACC,OAAA,CAAAH,oBAAA,GAAAA,oBAAA"}
1
+ {"version":3,"names":["getModelTitleFieldId","exports","model","titleFieldId"],"sources":["getModelTitleFieldId.ts"],"sourcesContent":["import { CmsEditorContentModel } from \"~/types\";\n\nexport const getModelTitleFieldId = (model: CmsEditorContentModel): string => {\n if (!model.titleFieldId || model.titleFieldId === \"id\") {\n return \"\";\n }\n return model.titleFieldId;\n};\n"],"mappings":";;;;;;AAEO,IAAMA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,GAAG,SAAvBA,oBAAoBA,CAAIE,KAA4B,EAAa;EAC1E,IAAI,CAACA,KAAK,CAACC,YAAY,IAAID,KAAK,CAACC,YAAY,KAAK,IAAI,EAAE;IACpD,OAAO,EAAE;EACb;EACA,OAAOD,KAAK,CAACC,YAAY;AAC7B,CAAC","ignoreList":[]}
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_entries","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_getModelTitleFieldId","_createFieldsList","_prepareFormData"],"sources":["index.ts"],"sourcesContent":["export * from \"./entries.graphql\";\nexport * from \"./getModelTitleFieldId\";\nexport * from \"./createFieldsList\";\nexport * from \"./prepareFormData\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,qBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,qBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,qBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,qBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,iBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,iBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,iBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,iBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,gBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,gBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,gBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,gBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_entries","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_getModelTitleFieldId","_createFieldsList","_prepareFormData"],"sources":["index.ts"],"sourcesContent":["export * from \"./entries.graphql\";\nexport * from \"./getModelTitleFieldId\";\nexport * from \"./createFieldsList\";\nexport * from \"./prepareFormData\";\n"],"mappings":";;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,QAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,QAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,QAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,qBAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,qBAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,qBAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,qBAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,iBAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,iBAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,iBAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,iBAAA,CAAAN,GAAA;IAAA;EAAA;AAAA;AACA,IAAAO,gBAAA,GAAAX,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAS,gBAAA,EAAAR,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAO,gBAAA,CAAAP,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAG,gBAAA,CAAAP,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/app-headless-cms-common",
3
- "version": "5.40.0-beta.2",
3
+ "version": "5.40.0-beta.4",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,29 +13,30 @@
13
13
  ],
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@babel/runtime": "7.22.6",
16
+ "@babel/runtime": "7.24.1",
17
17
  "@fortawesome/fontawesome-svg-core": "1.3.0",
18
- "@types/react": "17.0.39",
19
- "@webiny/app-security": "5.40.0-beta.2",
20
- "@webiny/form": "5.40.0-beta.2",
21
- "@webiny/plugins": "5.40.0-beta.2",
18
+ "@types/react": "18.2.79",
19
+ "@webiny/app-security": "5.40.0-beta.4",
20
+ "@webiny/form": "5.40.0-beta.4",
21
+ "@webiny/plugins": "5.40.0-beta.4",
22
+ "@webiny/validation": "5.40.0-beta.4",
23
+ "dnd-core": "16.0.1",
22
24
  "graphql": "15.8.0",
23
25
  "graphql-tag": "2.12.6",
24
26
  "prop-types": "15.8.1",
25
- "react": "17.0.2",
26
- "react-dnd": "11.1.3"
27
+ "react": "18.2.0"
27
28
  },
28
29
  "devDependencies": {
29
- "@babel/cli": "7.22.6",
30
- "@babel/core": "7.22.8",
31
- "@babel/preset-env": "7.22.7",
32
- "@babel/preset-react": "7.22.5",
33
- "@babel/preset-typescript": "7.22.5",
34
- "@webiny/cli": "5.40.0-beta.2",
35
- "@webiny/project-utils": "5.40.0-beta.2",
36
- "babel-plugin-emotion": "9.2.11",
37
- "babel-plugin-module-resolver": "4.1.0",
38
- "rimraf": "3.0.2",
30
+ "@babel/cli": "7.24.1",
31
+ "@babel/core": "7.24.3",
32
+ "@babel/preset-env": "7.24.3",
33
+ "@babel/preset-react": "7.24.1",
34
+ "@babel/preset-typescript": "7.24.1",
35
+ "@emotion/babel-plugin": "11.11.0",
36
+ "@webiny/cli": "5.40.0-beta.4",
37
+ "@webiny/project-utils": "5.40.0-beta.4",
38
+ "babel-plugin-module-resolver": "5.0.0",
39
+ "rimraf": "5.0.5",
39
40
  "ttypescript": "1.5.15",
40
41
  "typescript": "4.7.4"
41
42
  },
@@ -47,5 +48,5 @@
47
48
  "build": "yarn webiny run build",
48
49
  "watch": "yarn webiny run watch"
49
50
  },
50
- "gitHead": "15e414a228687140ce2f30bd2f55763368e99827"
51
+ "gitHead": "42f3b1c985d6f8317d5c1084838b43a270c79f01"
51
52
  }
@@ -53,7 +53,7 @@ var createTransformationRunner = function createTransformationRunner() {
53
53
  };
54
54
  return transformationRunner;
55
55
  };
56
- var prepareFormData = function prepareFormData(input, fields) {
56
+ var prepareFormData = exports.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];
@@ -86,6 +86,5 @@ var prepareFormData = function prepareFormData(input, fields) {
86
86
  return output;
87
87
  }, {});
88
88
  };
89
- exports.prepareFormData = prepareFormData;
90
89
 
91
90
  //# sourceMappingURL=prepareFormData.js.map
@@ -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 { 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;EACA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b,KAAK,EAAEU,KAAK,CAAC;EAC9C,CAAC;EACD,OAAOH,oBAAoB;AAC/B,CAAC;AAEM,IAAMO,eAAe,GAAG,SAAlBA,eAAeA,CACxBC,KAAQ,EACRC,MAAuB,EACnB;EACJ,IAAMC,iBAAiB,GAAGT,0BAA0B,CAAC,CAAC;EAEtD,OAAOQ,MAAM,CAAC9B,MAAM,CAAuB,UAACgC,MAAM,EAAER,KAAK,EAAK;IAC1D,IAAMS,UAAU,GAAGJ,KAAK,CAACL,KAAK,CAACU,OAAO,CAAC;IAEvC,IAAMA,OAAgB,GAAGV,KAAK,CAACU,OAAO;IAEtC,IAAIV,KAAK,CAACW,cAAc,EAAE;MACtB,IAAMC,MAAM,GAAGhC,KAAK,CAACC,OAAO,CAAC4B,UAAU,CAAC,GAAGA,UAAU,GAAGrC,SAAS;MACjE,IAAI,CAACwC,MAAM,EAAE;QACT,OAAOJ,MAAM;MACjB;MACA;AACZ;AACA;AACA;AACA;AACA;AACA;MACY;MAAA,KACK,IAAII,MAAM,CAACC,MAAM,KAAK,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,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"}
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","exports","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map"],"sources":["prepareFormData.ts"],"sourcesContent":["import { CmsFieldValueTransformer, CmsModelField } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = <T extends Record<string, any>>(\n input: T,\n fields: CmsModelField[]\n): T => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<Record<keyof T, any>>((output, field) => {\n const inputValue = input[field.fieldId];\n\n const fieldId: keyof T = field.fieldId;\n\n if (field.multipleValues) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n\n output[fieldId] = values.map(value => runTransformation(field, value));\n\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as T);\n};\n"],"mappings":";;;;;;;;AACA,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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,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,KAAKzC,SAAS,CAAC,EAAE;QAC7E,OAAOqC,MAAM;MACjB;MAEAA,MAAM,CAACE,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAAC,UAAAzB,KAAK;QAAA,OAAIkB,iBAAiB,CAACR,KAAK,EAAEV,KAAK,CAAC;MAAA,EAAC;MAEtE,OAAOmB,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACE,OAAO,CAAC,GAAGH,iBAAiB,CAACR,KAAK,EAAEU,UAAU,CAAC;IAEtD,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAM,CAAC;AACf,CAAC","ignoreList":[]}
package/types/index.d.ts CHANGED
@@ -7,7 +7,10 @@ import { SecurityPermission } from "@webiny/app-security/types";
7
7
  import { CmsModelFieldValidator, CmsModelFieldValidatorsFactory, CmsModelFieldValidatorsGroup } from "./validation";
8
8
  import { CmsModel, CmsModelField } from "./model";
9
9
  import { CmsIdentity } from "./shared";
10
- import { DragObjectWithType } from "react-dnd";
10
+ import type { SourceType } from "dnd-core";
11
+ export declare type DragObjectWithType = {
12
+ type: SourceType;
13
+ };
11
14
  export * from "./validation";
12
15
  export * from "./model";
13
16
  export * from "./shared";
@@ -209,10 +212,13 @@ export interface CmsModelFieldTypePlugin extends Plugin {
209
212
  }) => React.ReactElement;
210
213
  };
211
214
  }
215
+ export interface CmsModelFieldRendererSettingsProps {
216
+ field: CmsModelField;
217
+ }
212
218
  export interface CmsModelFieldRendererProps {
213
219
  field: CmsModelField;
214
- Label: React.ComponentType;
215
- getBind: <T = any, F = any>(index?: number, key?: string) => BindComponent<T, F>;
220
+ Label: React.ComponentType<React.PropsWithChildren>;
221
+ getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;
216
222
  contentModel: CmsModel;
217
223
  }
218
224
  /**
@@ -292,6 +298,7 @@ export interface CmsModelFieldRendererPlugin extends Plugin {
292
298
  * ```
293
299
  */
294
300
  render(props: CmsModelFieldRendererProps): React.ReactNode;
301
+ renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;
295
302
  };
296
303
  }
297
304
  export interface CmsEditorFieldPredefinedValuesEntry {
@@ -314,6 +321,9 @@ export interface CmsDynamicZoneTemplate {
314
321
  validation: CmsModelFieldValidator[];
315
322
  tags?: string[];
316
323
  }
324
+ export interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {
325
+ __typename: string;
326
+ }
317
327
  export declare type CmsContentEntryStatusType = "draft" | "published" | "unpublished";
318
328
  /**
319
329
  * @deprecated Use `CmsContentEntry`.
@@ -321,6 +331,7 @@ export declare type CmsContentEntryStatusType = "draft" | "published" | "unpubli
321
331
  export declare type CmsEditorContentEntry = CmsContentEntry;
322
332
  export interface CmsContentEntry {
323
333
  id: string;
334
+ entryId: string;
324
335
  modelId: string;
325
336
  createdOn: string;
326
337
  createdBy: CmsIdentity;
@@ -328,6 +339,8 @@ export interface CmsContentEntry {
328
339
  savedBy: CmsIdentity;
329
340
  modifiedOn: string | null;
330
341
  modifiedBy: CmsIdentity | null;
342
+ deletedOn: string | null;
343
+ deletedBy: CmsIdentity | null;
331
344
  firstPublishedOn: string | null;
332
345
  firstPublishedBy: CmsIdentity | null;
333
346
  lastPublishedOn: string | null;
@@ -338,6 +351,8 @@ export interface CmsContentEntry {
338
351
  revisionSavedBy: CmsIdentity;
339
352
  revisionModifiedOn: string | null;
340
353
  revisionModifiedBy: CmsIdentity | null;
354
+ revisionDeletedOn: string | null;
355
+ revisionDeletedBy: CmsIdentity | null;
341
356
  revisionFirstPublishedOn: string | null;
342
357
  revisionFirstPublishedBy: CmsIdentity | null;
343
358
  revisionLastPublishedOn: string | null;
@@ -357,17 +372,21 @@ export interface CmsContentEntryRevision {
357
372
  id: string;
358
373
  modelId: string;
359
374
  savedOn: string;
375
+ deletedOn: string | null;
360
376
  firstPublishedOn: string | null;
361
377
  lastPublishedOn: string | null;
362
378
  createdBy: CmsIdentity;
379
+ deletedBy: CmsIdentity | null;
363
380
  revisionCreatedOn: string;
364
381
  revisionSavedOn: string;
365
382
  revisionModifiedOn: string;
383
+ revisionDeletedOn: string | null;
366
384
  revisionFirstPublishedOn: string;
367
385
  revisionLastPublishedOn: string;
368
386
  revisionCreatedBy: CmsIdentity;
369
387
  revisionSavedBy: CmsIdentity;
370
388
  revisionModifiedBy: CmsIdentity;
389
+ revisionDeletedBy: CmsIdentity | null;
371
390
  revisionFirstPublishedBy: CmsIdentity;
372
391
  revisionLastPublishedBy: CmsIdentity;
373
392
  wbyAco_location: Location;
@@ -513,7 +532,7 @@ export interface CmsMetaResponse {
513
532
  /***
514
533
  * ###### FORM ########
515
534
  */
516
- export interface BindComponentRenderProp<T = any, F = Record<string, any>> extends BaseBindComponentRenderProp<T, F> {
535
+ export interface BindComponentRenderProp<T = any> extends BaseBindComponentRenderProp<T> {
517
536
  parentName: string;
518
537
  appendValue: (value: any, index?: number) => void;
519
538
  prependValue: (value: any) => void;
@@ -522,11 +541,11 @@ export interface BindComponentRenderProp<T = any, F = Record<string, any>> exten
522
541
  moveValueUp: (index: number) => void;
523
542
  moveValueDown: (index: number) => void;
524
543
  }
525
- interface BindComponentProps<T = any, F = any> extends Omit<BaseBindComponentProps, "children" | "name"> {
544
+ interface BindComponentProps<T = any> extends Omit<BaseBindComponentProps, "children" | "name"> {
526
545
  name?: string;
527
- children?: ((props: BindComponentRenderProp<T, F>) => React.ReactElement) | React.ReactElement;
546
+ children?: ((props: BindComponentRenderProp<T>) => React.ReactElement) | React.ReactElement;
528
547
  }
529
- export declare type BindComponent<T = any, F = any> = React.ComponentType<BindComponentProps<T, F>> & {
548
+ export declare type BindComponent<T = any> = React.ComponentType<BindComponentProps<T>> & {
530
549
  parentName: string;
531
550
  };
532
551
  /**
@@ -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.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 tags?: string[];\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n 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"}
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 type { SourceType } from \"dnd-core\";\n\nexport type DragObjectWithType = {\n type: SourceType;\n};\n\nexport * from \"./validation\";\nexport * from \"./model\";\nexport * from \"./shared\";\n\ninterface QueryFieldParams {\n model: CmsModel;\n field: CmsModelField;\n graphQLTypePrefix: string;\n}\n\ninterface Position {\n row: number;\n index: number;\n}\n\ninterface Location {\n folderId: string;\n}\n\nexport interface DragSource extends DragObjectWithType {\n parent?: string;\n pos?: Partial<Position>;\n type: \"row\" | \"field\" | \"newField\";\n fieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n}\n\n/**\n * @deprecated Use `CmsModelFieldTypePlugin`.\n */\nexport type CmsEditorFieldTypePlugin = CmsModelFieldTypePlugin;\n\nexport interface CmsModelFieldTypePlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-type\";\n field: {\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * type: \"myField\"\n * ```\n */\n type: string;\n /**\n * A display name for the field.\n *\n * ```ts\n * label: \"Field name\"\n * ```\n */\n label: string;\n /**\n * A list of available validators for the model field.\n *\n * ```ts\n * validators: [\n * \"required\",\n * \"gte\",\n * \"lte\"\n * ]\n * ```\n */\n validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * A list of available validators when a model field accepts a list (array) of values.\n *\n * ```ts\n * listValidators: [\n * \"minLength\",\n * \"maxLength\"\n * ]\n * ```\n */\n listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * An explanation of the field displayed beneath the label.\n *\n * ```ts\n * description: \"A short description of the field\"\n * ```\n */\n description: string;\n /**\n * A ReactNode to display the icon for the field.\n *\n * ```tsx\n * icon: <MyIconComponent />\n * ```\n */\n icon: React.ReactNode;\n /**\n * Is it allowed to have multiple values in this field?\n *\n * ```ts\n * allowMultipleValues: true\n * ```\n */\n allowMultipleValues?: boolean;\n /**\n * Does this field type have a fixed list of values that can be selected?\n *\n * ```ts\n * allowPredefinedValues: false\n * ```\n */\n allowPredefinedValues?: boolean;\n /**\n * A ReactNode label when multiple values are enabled.\n */\n multipleValuesLabel?: React.ReactNode;\n /**\n * These are default values when the field is first created. This is a representation of the field that is stored in the database.\n *\n * ```ts\n * createField: () => ({\n * type: \"fieldType\",\n * validation: [],\n * renderer: {\n * name: \"fieldTypeRenderer\"\n * }\n * })\n * ```\n */\n createField: () => Pick<CmsModelField, \"type\" | \"validation\" | \"renderer\" | \"settings\">;\n /**\n * If `true` (default), this field will be configurable via a settings dialog.\n * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.\n */\n canEditSettings?: boolean;\n /**\n * Determine if a `draggable` can be dropped into this field.\n * NOTE: This is only applicable to nested field types.\n */\n canAccept?(field: CmsModelField, draggable: DragSource): boolean;\n /**\n * If `true` (default), will allow fields to be laid out into columns (next to each other).\n * If `false`, horizontal layout will not be allowed.\n * NOTE: This is only applicable to nested field types.\n */\n allowLayout?: boolean;\n /**\n * A ReactNode that you can add in the section below the help text when creating/editing field.\n *\n * ```tsx\n * renderSettings: (params) => {\n * return <FieldSettingsComponent />;\n * }\n * ```\n */\n renderSettings?: (params: {\n afterChangeLabel: (value: string) => void;\n uniqueFieldIdValidator: (fieldId: string) => void;\n contentModel: CmsModel;\n }) => React.ReactNode;\n /**\n * A ReactNode that renders in the Predefined values tab.\n *\n * ```tsx\n * renderPredefinedValues: (params) => {\n * const {form: {Bind}} = params;\n * return (\n * <Bind name=\"fieldProperty\">\n * <InputComponent />\n * </Bind>\n * );\n * }\n * ```\n */\n renderPredefinedValues?: (params: {\n getBind: (index?: number) => any;\n }) => React.ReactElement;\n /**\n * Object wrapper for GraphQL stuff\n */\n graphql?: {\n /**\n * Define field selection.\n *\n * ```ts\n * graphql: {\n * queryField: `\n * {\n * id\n * title\n * createdOn\n * }\n * `,\n * }\n * ```\n */\n queryField?: string | ((params: QueryFieldParams) => string | null);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelFieldRendererSettingsProps {\n field: CmsModelField;\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.ComponentType<React.PropsWithChildren>;\n getBind: <T = any>(index?: number, key?: string) => BindComponent<T>;\n contentModel: CmsModel;\n}\n\n/**\n * @deprecated Use `CmsModelFieldRendererProps`.\n */\nexport type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;\n\n/**\n * @deprecated Use `CmsModelFieldRendererPlugin`.\n */\nexport type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.multipleValues\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n renderSettings?: (props: CmsModelFieldRendererSettingsProps) => React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidator[];\n tags?: string[];\n}\n\nexport interface CmsDynamicZoneTemplateWithTypename extends CmsDynamicZoneTemplate {\n __typename: string;\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n entryId: string;\n modelId: string;\n createdOn: string;\n createdBy: CmsIdentity;\n savedOn: string;\n savedBy: CmsIdentity;\n modifiedOn: string | null;\n modifiedBy: CmsIdentity | null;\n deletedOn: string | null;\n deletedBy: CmsIdentity | null;\n firstPublishedOn: string | null;\n firstPublishedBy: CmsIdentity | null;\n lastPublishedOn: string | null;\n lastPublishedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedOn: string;\n revisionSavedBy: CmsIdentity;\n revisionModifiedOn: string | null;\n revisionModifiedBy: CmsIdentity | null;\n revisionDeletedOn: string | null;\n revisionDeletedBy: CmsIdentity | null;\n revisionFirstPublishedOn: string | null;\n revisionFirstPublishedBy: CmsIdentity | null;\n revisionLastPublishedOn: string | null;\n revisionLastPublishedBy: CmsIdentity | null;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n modelId: string;\n savedOn: string;\n deletedOn: string | null;\n firstPublishedOn: string | null;\n lastPublishedOn: string | null;\n createdBy: CmsIdentity;\n deletedBy: CmsIdentity | null;\n revisionCreatedOn: string;\n revisionSavedOn: string;\n revisionModifiedOn: string;\n revisionDeletedOn: string | null;\n revisionFirstPublishedOn: string;\n revisionLastPublishedOn: string;\n revisionCreatedBy: CmsIdentity;\n revisionSavedBy: CmsIdentity;\n revisionModifiedBy: CmsIdentity;\n revisionDeletedBy: CmsIdentity | null;\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> 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};\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":";;;;;AAwBA,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","ignoreList":[]}
package/types/model.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { Validator } from "@webiny/validation/types";
1
2
  import { CmsModelFieldValidator } from "./validation";
2
3
  import { CmsDynamicZoneTemplate, CmsEditorFieldPredefinedValues, CmsModelFieldRendererPlugin } from "./index";
3
4
  import { CmsIdentity } from "./shared";
@@ -24,13 +25,14 @@ export declare type CmsModelField<T = unknown> = T & {
24
25
  label: string;
25
26
  helpText?: string;
26
27
  placeholderText?: string;
27
- validation?: CmsModelFieldValidator[];
28
+ validation?: (CmsModelFieldValidator | Validator)[];
28
29
  listValidation?: CmsModelFieldValidator[];
29
30
  multipleValues?: boolean;
30
31
  predefinedValues?: CmsEditorFieldPredefinedValues;
31
32
  settings?: CmsModelFieldSettings<T>;
32
33
  renderer: {
33
34
  name: string;
35
+ settings?: Record<string, any>;
34
36
  }
35
37
  /**
36
38
  * Use this only for programmatic assignment of renderers.
@@ -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 { Validator } from \"@webiny/validation/types\";\nimport { CmsModelFieldValidator } from \"~/types/validation\";\nimport {\n CmsDynamicZoneTemplate,\n CmsEditorFieldPredefinedValues,\n CmsModelFieldRendererPlugin\n} from \"~/types/index\";\nimport { CmsIdentity } from \"~/types/shared\";\n\n/**\n * @deprecated Use `CmsModelField` instead.\n */\nexport type CmsEditorField<T = unknown> = CmsModelField<T>;\n\nexport interface CmsModelFieldSettings<T = unknown> {\n defaultValue?: string | boolean | number | null | undefined;\n defaultSetValue?: string;\n type?: string;\n fields?: CmsModelField<T>[];\n layout?: string[][];\n models?: Pick<CmsModel, \"modelId\">[];\n templates?: CmsDynamicZoneTemplate[];\n imagesOnly?: boolean;\n [key: string]: any;\n}\n\nexport type CmsModelField<T = unknown> = T & {\n id: string;\n type: string;\n fieldId: CmsEditorFieldId;\n storageId?: string;\n label: string;\n helpText?: string;\n placeholderText?: string;\n validation?: (CmsModelFieldValidator | Validator)[];\n listValidation?: CmsModelFieldValidator[];\n multipleValues?: boolean;\n predefinedValues?: CmsEditorFieldPredefinedValues;\n settings?: CmsModelFieldSettings<T>;\n renderer:\n | {\n name: string;\n settings?: Record<string, any>;\n }\n /**\n * Use this only for programmatic assignment of renderers.\n * Since functions cannot be serialized, this can only work via code.\n */\n | CmsModelFieldRendererPlugin[\"renderer\"][\"render\"];\n tags?: string[];\n};\n\nexport type CmsEditorFieldId = string;\nexport type CmsEditorFieldsLayout = CmsEditorFieldId[][];\n\n/**\n * @category GraphQL\n * @category Model\n */\nexport type CmsEditorContentModel = CmsModel;\n\n/**\n * @category GraphQL\n * @category Group\n */\nexport interface CmsGroup {\n id: string;\n name: string;\n slug: string;\n icon: string;\n description?: string;\n contentModels: CmsModel[];\n createdBy: CmsIdentity;\n /**\n * Tells if this group is a plugin one (cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n\nexport interface CmsModel {\n id: string;\n group: Pick<CmsGroup, \"id\" | \"name\">;\n description?: string;\n version: number;\n layout?: CmsEditorFieldsLayout;\n fields: CmsModelField[];\n lockedFields: CmsModelField[];\n icon: string;\n name: string;\n modelId: string;\n singularApiName: string;\n pluralApiName: string;\n titleFieldId: string | null;\n descriptionFieldId: string | null;\n imageFieldId: string | null;\n settings: {\n [key: string]: any;\n };\n status: string;\n savedOn: string;\n meta: any;\n createdBy: CmsIdentity;\n tags: string[];\n /**\n * If model is a plugin one (it cannot be changed/deleted)\n */\n plugin?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["shared.ts"],"sourcesContent":["export interface CmsIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["shared.ts"],"sourcesContent":["export interface CmsIdentity {\n id: string;\n displayName: string;\n type: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { CmsModelField } from \"~/types\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["validation.ts"],"sourcesContent":["import * as React from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport { CmsModelField } from \"~/types\";\n\nexport interface CmsModelFieldValidatorConfigAdapter {\n isRequired(): boolean;\n getName(): string;\n getLabel(): string;\n getDescription(): string;\n getDefaultMessage(): string;\n getDefaultSettings(): Record<string, any> | undefined;\n getVariables(): CmsModelFieldValidatorVariable[];\n getVariableDescription(variableName: string): string | undefined;\n}\n\nexport interface CmsModelFieldValidatorVariable {\n name: string;\n description: string;\n}\n\n/**\n * This interface is used in the validator configuration UI (Field dialog).\n */\nexport interface CmsModelFieldValidatorConfig {\n name: string;\n required?: boolean;\n label?: string;\n description?: string;\n defaultMessage?: string;\n defaultSettings?: Record<string, any>;\n variables?: CmsModelFieldValidatorVariable[];\n}\n\n/**\n * This interface allows you to control the title, description, and validators located in the specific\n * validators group, like `validators` or `listValidators` within the Field dialog.\n */\nexport interface CmsModelFieldValidatorsGroup {\n validators: (string | CmsModelFieldValidatorConfig)[];\n title?: string;\n description?: string;\n}\n\n/**\n * This interface allows you to generate validators based on the field configuration.\n */\nexport interface CmsModelFieldValidatorsFactory {\n (field: CmsModelField): string[] | CmsModelFieldValidatorsGroup;\n}\n\nexport interface CmsModelFieldValidator {\n name: string;\n message?: string;\n settings?: any;\n}\n\nexport interface CmsModelFieldValidatorPlugin<T = any> extends Plugin {\n type: \"cms-model-field-validator\";\n validator: {\n name: string;\n label: string;\n description: string;\n defaultMessage: string;\n variables?: CmsModelFieldValidatorVariable[];\n defaultSettings?: Record<string, any>;\n getVariableValues?: (context: {\n validator: CmsModelFieldValidator;\n }) => Record<string, string>;\n renderSettings?: (config: CmsModelFieldValidatorConfigAdapter) => React.ReactElement;\n renderCustomUi?: () => React.ReactElement;\n validate: (\n value: T,\n context: {\n validator: CmsModelFieldValidator;\n field: CmsModelField;\n }\n ) => Promise<any>;\n };\n}\n\nexport interface CmsModelFieldRegexValidatorExpressionPlugin extends Plugin {\n type: \"cms-model-field-regex-validator-expression\";\n pattern: {\n name: string;\n message: string;\n label: string;\n regex: string;\n flags: string;\n };\n}\n"],"mappings":"","ignoreList":[]}