@webiny/app-headless-cms-common 5.37.8-beta.0 → 5.38.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/createFieldsList.d.ts +2 -1
- package/createFieldsList.js +26 -7
- package/createFieldsList.js.map +1 -1
- package/entries.graphql.d.ts +4 -0
- package/entries.graphql.js +8 -5
- package/entries.graphql.js.map +1 -1
- package/getModelTitleFieldId.js +3 -1
- package/index.d.ts +1 -0
- package/index.js +14 -1
- package/index.js.map +1 -1
- package/package.json +7 -7
- package/prepareFormData.d.ts +2 -0
- package/prepareFormData.js +90 -0
- package/prepareFormData.js.map +1 -0
- package/types/index.d.ts +3 -2
- package/types/index.js +3 -1
- package/types/index.js.map +1 -1
- package/types/model.js +3 -1
- package/types/shared.js +3 -1
- package/types/validation.js +3 -1
package/createFieldsList.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { CmsModelField, CmsModel } from "./types";
|
|
|
2
2
|
interface CreateFieldsListParams {
|
|
3
3
|
model: CmsModel;
|
|
4
4
|
fields: CmsModelField[];
|
|
5
|
+
graphQLTypePrefix?: string;
|
|
5
6
|
}
|
|
6
|
-
export declare function createFieldsList({ model, fields }: CreateFieldsListParams): string;
|
|
7
|
+
export declare function createFieldsList({ model, fields, graphQLTypePrefix }: CreateFieldsListParams): string;
|
|
7
8
|
export {};
|
package/createFieldsList.js
CHANGED
|
@@ -10,13 +10,13 @@ var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/obje
|
|
|
10
10
|
var _plugins = require("@webiny/plugins");
|
|
11
11
|
function createFieldsList(_ref) {
|
|
12
12
|
var model = _ref.model,
|
|
13
|
-
fields = _ref.fields
|
|
13
|
+
fields = _ref.fields,
|
|
14
|
+
graphQLTypePrefix = _ref.graphQLTypePrefix;
|
|
14
15
|
var fieldPlugins = _plugins.plugins.byType("cms-editor-field-type").reduce(function (acc, item) {
|
|
15
16
|
return (0, _objectSpread3.default)((0, _objectSpread3.default)({}, acc), {}, (0, _defineProperty2.default)({}, item.field.type, item.field));
|
|
16
17
|
}, {});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return fields.map(function (field) {
|
|
18
|
+
var typePrefix = graphQLTypePrefix !== null && graphQLTypePrefix !== void 0 ? graphQLTypePrefix : model.singularApiName;
|
|
19
|
+
var allFields = fields.map(function (field) {
|
|
20
20
|
if (!fieldPlugins[field.type]) {
|
|
21
21
|
console.log("Unknown field plugin for field type \"".concat(field.type, "\"."));
|
|
22
22
|
return null;
|
|
@@ -26,10 +26,29 @@ function createFieldsList(_ref) {
|
|
|
26
26
|
var queryField = graphql.queryField;
|
|
27
27
|
var selection = typeof queryField === "string" ? queryField : queryField({
|
|
28
28
|
model: model,
|
|
29
|
-
field: field
|
|
29
|
+
field: field,
|
|
30
|
+
graphQLTypePrefix: typePrefix
|
|
30
31
|
});
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* If field type plugin returns `null`, we don't include the field in the selection.
|
|
35
|
+
*/
|
|
36
|
+
if (selection === null) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
31
39
|
return "".concat(field.fieldId, " ").concat(selection);
|
|
32
40
|
}
|
|
33
41
|
return field.fieldId;
|
|
34
|
-
}).filter(Boolean)
|
|
35
|
-
|
|
42
|
+
}).filter(Boolean);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* If there are no fields for a given type, we add a dummy `_empty` field, which will also be present in the schema
|
|
46
|
+
* on the API side, to protect the schema from invalid types.
|
|
47
|
+
*/
|
|
48
|
+
if (!allFields.length) {
|
|
49
|
+
allFields.push("_empty");
|
|
50
|
+
}
|
|
51
|
+
return allFields.join("\n");
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=createFieldsList.js.map
|
package/createFieldsList.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_plugins","require","createFieldsList","_ref","model","fields","fieldPlugins","plugins","byType","reduce","acc","item","_objectSpread3","default","_defineProperty2","field","type","map","console","log","concat","graphql","queryField","selection","fieldId","filter","Boolean","join"],"sources":["createFieldsList.ts"],"sourcesContent":["import { CmsModelField,
|
|
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,IA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AAI,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"}
|
package/entries.graphql.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CmsContentEntryRevision, CmsContentEntry, CmsEditorContentModel, CmsErrorResponse, CmsMetaResponse, CmsModelField } from "./types";
|
|
2
|
+
import { FormSubmitOptions } from "@webiny/form";
|
|
2
3
|
/**
|
|
3
4
|
* ############################################
|
|
4
5
|
* Get CMS Entry Query
|
|
@@ -78,6 +79,7 @@ export interface CmsEntryCreateMutationVariables {
|
|
|
78
79
|
* We have any here because we do not know which fields does entry have
|
|
79
80
|
*/
|
|
80
81
|
data: Record<string, any>;
|
|
82
|
+
options?: FormSubmitOptions;
|
|
81
83
|
}
|
|
82
84
|
export declare const createCreateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
|
|
83
85
|
/**
|
|
@@ -96,6 +98,7 @@ export interface CmsEntryCreateFromMutationVariables {
|
|
|
96
98
|
* We have any here because we do not know which fields does entry have
|
|
97
99
|
*/
|
|
98
100
|
data?: Record<string, any>;
|
|
101
|
+
options?: FormSubmitOptions;
|
|
99
102
|
}
|
|
100
103
|
export declare const createCreateFromMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
|
|
101
104
|
/**
|
|
@@ -114,6 +117,7 @@ export interface CmsEntryUpdateMutationVariables {
|
|
|
114
117
|
* We have any here because we do not know which fields does entry have
|
|
115
118
|
*/
|
|
116
119
|
data: Record<string, any>;
|
|
120
|
+
options?: FormSubmitOptions;
|
|
117
121
|
}
|
|
118
122
|
export declare const createUpdateMutation: (model: CmsEditorContentModel) => import("graphql").DocumentNode;
|
|
119
123
|
/**
|
package/entries.graphql.js
CHANGED
|
@@ -65,10 +65,11 @@ var createDeleteMutation = function createDeleteMutation(model) {
|
|
|
65
65
|
*/
|
|
66
66
|
exports.createDeleteMutation = createDeleteMutation;
|
|
67
67
|
var createCreateMutation = function createCreateMutation(model) {
|
|
68
|
-
|
|
68
|
+
var createFields = (0, _createFieldsList.createFieldsList)({
|
|
69
69
|
model: model,
|
|
70
70
|
fields: model.fields
|
|
71
|
-
})
|
|
71
|
+
});
|
|
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);
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
/**
|
|
@@ -77,7 +78,7 @@ var createCreateMutation = function createCreateMutation(model) {
|
|
|
77
78
|
*/
|
|
78
79
|
exports.createCreateMutation = createCreateMutation;
|
|
79
80
|
var createCreateFromMutation = function createCreateFromMutation(model) {
|
|
80
|
-
return (0, _graphqlTag.default)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsCreate", "From($revision: ID!, $data: ", "Input) {\n content: create", "From(revision: $revision, data: $data) {\n data {\n ", "\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, model.singularApiName, CONTENT_ENTRY_SYSTEM_FIELDS, (0, _createFieldsList.createFieldsList)({
|
|
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)({
|
|
81
82
|
model: model,
|
|
82
83
|
fields: model.fields
|
|
83
84
|
}), ERROR_FIELD);
|
|
@@ -89,7 +90,7 @@ var createCreateFromMutation = function createCreateFromMutation(model) {
|
|
|
89
90
|
*/
|
|
90
91
|
exports.createCreateFromMutation = createCreateFromMutation;
|
|
91
92
|
var createUpdateMutation = function createUpdateMutation(model) {
|
|
92
|
-
return (0, _graphqlTag.default)(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUpdate", "($revision: ID!, $data: ", "Input
|
|
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)({
|
|
93
94
|
model: model,
|
|
94
95
|
fields: model.fields
|
|
95
96
|
}), ERROR_FIELD);
|
|
@@ -112,4 +113,6 @@ exports.createPublishMutation = createPublishMutation;
|
|
|
112
113
|
var createUnpublishMutation = function createUnpublishMutation(model) {
|
|
113
114
|
return (0, _graphqlTag.default)(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n mutation CmsUnpublish", "($revision: ID!) {\n content: unpublish", "(revision: $revision) {\n data {\n id\n ", "\n }\n error ", "\n }\n }"])), model.singularApiName, model.singularApiName, CONTENT_META_FIELDS, ERROR_FIELD);
|
|
114
115
|
};
|
|
115
|
-
exports.createUnpublishMutation = createUnpublishMutation;
|
|
116
|
+
exports.createUnpublishMutation = createUnpublishMutation;
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=entries.graphql.js.map
|
package/entries.graphql.js.map
CHANGED
|
@@ -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","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\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n meta {\n title\n description\n image\n publishedOn\n version\n locked\n status\n }\n`;\n\nconst CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */ `\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ${CONTENT_META_FIELDS}\n`;\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n message\n code\n data\n }\n`;\n\n/**\n * ############################################\n * Get CMS Entry Query\n */\nexport interface CmsEntryGetQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryGetQueryVariables {\n revision?: string;\n entryId?: string;\n}\n\nexport const createReadQuery = (model: CmsEditorContentModel) => {\n /**\n * This query now accepts both revision or entryId as we can load exact revision or latest (if entryId was sent).\n */\n return gql`\n query CmsEntriesGet${model.singularApiName}($revision: ID, $entryId: ID) {\n content: get${model.singularApiName}(revision: $revision, entryId: $entryId) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entry Revisions Query\n */\nexport interface CmsEntriesListRevisionsQueryResponse {\n revisions: {\n data: CmsContentEntryRevision[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListRevisionsQueryVariables {\n id: string;\n}\n\nexport const createRevisionsQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntriesGet${model.singularApiName}Revisions($id: ID!) {\n revisions: get${model.singularApiName}Revisions(id: $id) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entries Query\n */\nexport interface CmsEntriesListQueryResponse {\n content: {\n data: CmsContentEntry[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListQueryVariables {\n // TODO @ts-refactor better list types\n where?: {\n [key: string]: any;\n };\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport const createListQuery = (model: CmsEditorContentModel, fields?: CmsModelField[]) => {\n return gql`\n query CmsEntriesList${model.pluralApiName}($where: ${\n model.singularApiName\n }ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Delete Mutation\n */\nexport interface CmsEntryDeleteMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryDeleteMutationVariables {\n revision: string;\n}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!) {\n content: delete${model.singularApiName}(revision: $revision) {\n data\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create Mutation\n */\nexport interface CmsEntryCreateMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryCreateMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n}\n\nexport const createCreateMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!) {\n content: create${model.singularApiName}(data: $data) {\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 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}\n\nexport const createCreateFromMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${\n model.singularApiName\n }Input) {\n content: create${model.singularApiName}From(revision: $revision, data: $data) {\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}\n\nexport const createUpdateMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($revision: ID!, $data: ${\n model.singularApiName\n }Input!) {\n content: update${model.singularApiName}(revision: $revision, data: $data) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Publish Mutation\n */\nexport interface CmsEntryPublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryPublishMutationVariables {\n revision: string;\n}\n\nexport const createPublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsPublish${model.singularApiName}($revision: ID!) {\n content: publish${model.singularApiName}(revision: $revision) {\n data {\n id\n ${CONTENT_META_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Unpublish Mutation\n */\nexport interface CmsEntryUnpublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUnpublishMutationVariables {\n revision: string;\n}\n\nexport const createUnpublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUnpublish${model.singularApiName}($revision: ID!) {\n content: unpublish${model.singularApiName}(revision: $revision) {\n data {\n id\n ${CONTENT_META_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,qBAAA,GAAAF,OAAA;AAA8D,IAAAG,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AU,uBAAA,GAAAA,uBAAA"}
|
|
1
|
+
{"version":3,"names":["_graphqlTag","_interopRequireDefault","require","_createFieldsList","_getModelTitleFieldId","_templateObject","_templateObject2","_templateObject3","_templateObject4","_templateObject5","_templateObject6","_templateObject7","_templateObject8","_templateObject9","CONTENT_META_FIELDS","CONTENT_ENTRY_SYSTEM_FIELDS","concat","ERROR_FIELD","createReadQuery","model","gql","_taggedTemplateLiteral2","default","singularApiName","createFieldsList","fields","exports","createRevisionsQuery","createListQuery","pluralApiName","getModelTitleFieldId","createDeleteMutation","createCreateMutation","createFields","createCreateFromMutation","createUpdateMutation","createPublishMutation","createUnpublishMutation"],"sources":["entries.graphql.ts"],"sourcesContent":["import gql from \"graphql-tag\";\nimport {\n CmsContentEntryRevision,\n CmsContentEntry,\n CmsEditorContentModel,\n CmsErrorResponse,\n CmsMetaResponse,\n CmsModelField\n} from \"~/types\";\nimport { createFieldsList } from \"./createFieldsList\";\nimport { getModelTitleFieldId } from \"./getModelTitleFieldId\";\nimport { FormSubmitOptions } from \"@webiny/form\";\n\nconst CONTENT_META_FIELDS = /* GraphQL */ `\n meta {\n title\n description\n image\n publishedOn\n version\n locked\n status\n }\n`;\n\nconst CONTENT_ENTRY_SYSTEM_FIELDS = /* GraphQL */ `\n id\n entryId\n savedOn\n createdOn\n createdBy {\n id\n type\n displayName\n }\n ownedBy {\n id\n type\n displayName\n }\n wbyAco_location {\n folderId\n }\n ${CONTENT_META_FIELDS}\n`;\n\nconst ERROR_FIELD = /* GraphQL */ `\n {\n message\n code\n data\n }\n`;\n\n/**\n * ############################################\n * Get CMS Entry Query\n */\nexport interface CmsEntryGetQueryResponse {\n content: {\n data: CmsContentEntry;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryGetQueryVariables {\n revision?: string;\n entryId?: string;\n}\n\nexport const createReadQuery = (model: CmsEditorContentModel) => {\n /**\n * This query now accepts both revision or entryId as we can load exact revision or latest (if entryId was sent).\n */\n return gql`\n query CmsEntriesGet${model.singularApiName}($revision: ID, $entryId: ID) {\n content: get${model.singularApiName}(revision: $revision, entryId: $entryId) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entry Revisions Query\n */\nexport interface CmsEntriesListRevisionsQueryResponse {\n revisions: {\n data: CmsContentEntryRevision[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListRevisionsQueryVariables {\n id: string;\n}\n\nexport const createRevisionsQuery = (model: CmsEditorContentModel) => {\n return gql`\n query CmsEntriesGet${model.singularApiName}Revisions($id: ID!) {\n revisions: get${model.singularApiName}Revisions(id: $id) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * List CMS Entries Query\n */\nexport interface CmsEntriesListQueryResponse {\n content: {\n data: CmsContentEntry[];\n error: CmsErrorResponse | null;\n meta: CmsMetaResponse;\n };\n}\n\nexport interface CmsEntriesListQueryVariables {\n // TODO @ts-refactor better list types\n where?: {\n [key: string]: any;\n };\n sort?: string[];\n limit?: number;\n after?: string;\n}\n\nexport const createListQuery = (model: CmsEditorContentModel, fields?: CmsModelField[]) => {\n return gql`\n query CmsEntriesList${model.pluralApiName}($where: ${\n model.singularApiName\n }ListWhereInput, $sort: [${\n model.singularApiName\n }ListSorter], $limit: Int, $after: String, $search: String) {\n content: list${model.pluralApiName}(\n where: $where\n sort: $sort\n limit: $limit\n after: $after\n search: $search\n ) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${fields ? createFieldsList({ model, fields }) : \"\"}\n ${!fields ? getModelTitleFieldId(model) : \"\"}\n }\n meta {\n cursor\n hasMoreItems\n totalCount\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Delete Mutation\n */\nexport interface CmsEntryDeleteMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryDeleteMutationVariables {\n revision: string;\n}\n\nexport const createDeleteMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsEntriesDelete${model.singularApiName}($revision: ID!) {\n content: delete${model.singularApiName}(revision: $revision) {\n data\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create Mutation\n */\nexport interface CmsEntryCreateMutationResponse {\n content: {\n data: CmsContentEntry | null;\n error: CmsErrorResponse | null;\n };\n}\n\nexport interface CmsEntryCreateMutationVariables {\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormSubmitOptions;\n}\n\nexport const createCreateMutation = (model: CmsEditorContentModel) => {\n const createFields = createFieldsList({ model, fields: model.fields });\n\n return gql`\n mutation CmsEntriesCreate${model.singularApiName}($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) {\n content: create${model.singularApiName}(data: $data, options: $options) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFields}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Create From Mutation\n */\nexport interface CmsEntryCreateFromMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryCreateFromMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data?: Record<string, any>;\n options?: FormSubmitOptions;\n}\n\nexport const createCreateFromMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsCreate${model.singularApiName}From($revision: ID!, $data: ${\n model.singularApiName\n }Input, $options: CreateRevisionCmsEntryOptionsInput) {\n content: create${\n model.singularApiName\n }From(revision: $revision, data: $data, options: $options) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Update Mutation\n */\nexport interface CmsEntryUpdateMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUpdateMutationVariables {\n revision: string;\n /**\n * We have any here because we do not know which fields does entry have\n */\n data: Record<string, any>;\n options?: FormSubmitOptions;\n}\n\nexport const createUpdateMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUpdate${model.singularApiName}($revision: ID!, $data: ${\n model.singularApiName\n }Input!, $options: UpdateCmsEntryOptionsInput) {\n content: update${\n model.singularApiName\n }(revision: $revision, data: $data, options: $options) {\n data {\n ${CONTENT_ENTRY_SYSTEM_FIELDS}\n ${createFieldsList({ model, fields: model.fields })}\n }\n error ${ERROR_FIELD}\n }\n }\n `;\n};\n\n/**\n * ############################################\n * Publish Mutation\n */\nexport interface CmsEntryPublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryPublishMutationVariables {\n revision: string;\n}\n\nexport const createPublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsPublish${model.singularApiName}($revision: ID!) {\n content: publish${model.singularApiName}(revision: $revision) {\n data {\n id\n ${CONTENT_META_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n\n/**\n * ############################################\n * Unpublish Mutation\n */\nexport interface CmsEntryUnpublishMutationResponse {\n content: {\n data?: CmsContentEntry;\n error?: CmsErrorResponse;\n };\n}\n\nexport interface CmsEntryUnpublishMutationVariables {\n revision: string;\n}\n\nexport const createUnpublishMutation = (model: CmsEditorContentModel) => {\n return gql`\n mutation CmsUnpublish${model.singularApiName}($revision: ID!) {\n content: unpublish${model.singularApiName}(revision: $revision) {\n data {\n id\n ${CONTENT_META_FIELDS}\n }\n error ${ERROR_FIELD}\n }\n }`;\n};\n"],"mappings":";;;;;;;;AAAA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,i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AK,CAACI,eAAe,EACpBJ,KAAK,CAACI,eAAe,EAG/BT,mBAAmB,EAEjBG,WAAW;AAGnC,CAAC;AAACS,OAAA,CAAAW,uBAAA,GAAAA,uBAAA"}
|
package/getModelTitleFieldId.js
CHANGED
|
@@ -10,4 +10,6 @@ var getModelTitleFieldId = function getModelTitleFieldId(model) {
|
|
|
10
10
|
}
|
|
11
11
|
return model.titleFieldId;
|
|
12
12
|
};
|
|
13
|
-
exports.getModelTitleFieldId = getModelTitleFieldId;
|
|
13
|
+
exports.getModelTitleFieldId = getModelTitleFieldId;
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=getModelTitleFieldId.js.map
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -35,4 +35,17 @@ Object.keys(_createFieldsList).forEach(function (key) {
|
|
|
35
35
|
return _createFieldsList[key];
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
|
-
});
|
|
38
|
+
});
|
|
39
|
+
var _prepareFormData = require("./prepareFormData");
|
|
40
|
+
Object.keys(_prepareFormData).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _prepareFormData[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function get() {
|
|
46
|
+
return _prepareFormData[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_entries","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_getModelTitleFieldId","_createFieldsList"],"sources":["index.ts"],"sourcesContent":["export * from \"./entries.graphql\";\nexport * from \"./getModelTitleFieldId\";\nexport * from \"./createFieldsList\";\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"}
|
|
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"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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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/app-headless-cms-common",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.38.0-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@babel/runtime": "7.22.6",
|
|
17
17
|
"@fortawesome/fontawesome-svg-core": "1.3.0",
|
|
18
18
|
"@types/react": "17.0.39",
|
|
19
|
-
"@webiny/app-security": "5.
|
|
20
|
-
"@webiny/form": "5.
|
|
21
|
-
"@webiny/plugins": "5.
|
|
19
|
+
"@webiny/app-security": "5.38.0-beta.0",
|
|
20
|
+
"@webiny/form": "5.38.0-beta.0",
|
|
21
|
+
"@webiny/plugins": "5.38.0-beta.0",
|
|
22
22
|
"graphql": "15.8.0",
|
|
23
23
|
"graphql-tag": "2.12.6",
|
|
24
24
|
"prop-types": "15.8.1",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@babel/preset-env": "7.22.7",
|
|
32
32
|
"@babel/preset-react": "7.22.5",
|
|
33
33
|
"@babel/preset-typescript": "7.22.5",
|
|
34
|
-
"@webiny/cli": "5.
|
|
35
|
-
"@webiny/project-utils": "5.
|
|
34
|
+
"@webiny/cli": "5.38.0-beta.0",
|
|
35
|
+
"@webiny/project-utils": "5.38.0-beta.0",
|
|
36
36
|
"babel-plugin-emotion": "9.2.11",
|
|
37
37
|
"babel-plugin-module-resolver": "4.1.0",
|
|
38
38
|
"rimraf": "3.0.2",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"build": "yarn webiny run build",
|
|
48
48
|
"watch": "yarn webiny run watch"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "5746389d4988626b50e2523ccfa0a9a5e398e0ed"
|
|
51
51
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.prepareFormData = void 0;
|
|
8
|
+
var _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
/**
|
|
11
|
+
* This method builds transformer plugins only once.
|
|
12
|
+
* Really no need in building more than once because at this point all plugins are registered.
|
|
13
|
+
*/
|
|
14
|
+
var availableTransformerPlugins = undefined;
|
|
15
|
+
var getAvailableTransformerPlugins = function getAvailableTransformerPlugins() {
|
|
16
|
+
if (availableTransformerPlugins) {
|
|
17
|
+
return availableTransformerPlugins;
|
|
18
|
+
}
|
|
19
|
+
availableTransformerPlugins = _plugins.plugins.byType("cms-field-value-transformer").reduce(function (transformers, pl) {
|
|
20
|
+
var fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];
|
|
21
|
+
var _iterator = (0, _createForOfIteratorHelper2.default)(fieldTypes),
|
|
22
|
+
_step;
|
|
23
|
+
try {
|
|
24
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
25
|
+
var _fieldType = _step.value;
|
|
26
|
+
if (transformers[_fieldType]) {
|
|
27
|
+
console.warn("Transformer for field type \"".concat(_fieldType, "\" is already defined. There cannot be more than one transformer."));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
transformers[_fieldType] = pl;
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
_iterator.e(err);
|
|
34
|
+
} finally {
|
|
35
|
+
_iterator.f();
|
|
36
|
+
}
|
|
37
|
+
return transformers;
|
|
38
|
+
}, {});
|
|
39
|
+
return availableTransformerPlugins;
|
|
40
|
+
};
|
|
41
|
+
var transformationRunner;
|
|
42
|
+
var createTransformationRunner = function createTransformationRunner() {
|
|
43
|
+
if (transformationRunner) {
|
|
44
|
+
return transformationRunner;
|
|
45
|
+
}
|
|
46
|
+
var availablePlugins = getAvailableTransformerPlugins();
|
|
47
|
+
transformationRunner = function transformationRunner(field, value) {
|
|
48
|
+
var transformer = availablePlugins[field.type];
|
|
49
|
+
if (!transformer) {
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
52
|
+
return transformer.transform(value, field);
|
|
53
|
+
};
|
|
54
|
+
return transformationRunner;
|
|
55
|
+
};
|
|
56
|
+
var prepareFormData = function prepareFormData(input, fields) {
|
|
57
|
+
var runTransformation = createTransformationRunner();
|
|
58
|
+
return fields.reduce(function (output, field) {
|
|
59
|
+
var inputValue = input[field.fieldId];
|
|
60
|
+
if (field.multipleValues) {
|
|
61
|
+
var values = Array.isArray(inputValue) ? inputValue : undefined;
|
|
62
|
+
if (!(values !== null && values !== void 0 && values.length)) {
|
|
63
|
+
return output;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.
|
|
67
|
+
*
|
|
68
|
+
* In case there are more items in the array, and they are null / undefined,
|
|
69
|
+
* we must not do anything because it means the user added new items into the array,
|
|
70
|
+
* 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).
|
|
71
|
+
*/
|
|
72
|
+
//
|
|
73
|
+
else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {
|
|
74
|
+
return output;
|
|
75
|
+
}
|
|
76
|
+
output[field.fieldId] = values.map(function (value) {
|
|
77
|
+
return runTransformation(field, value);
|
|
78
|
+
});
|
|
79
|
+
return output;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Regular values, single values.
|
|
83
|
+
*/
|
|
84
|
+
output[field.fieldId] = runTransformation(field, inputValue);
|
|
85
|
+
return output;
|
|
86
|
+
}, {});
|
|
87
|
+
};
|
|
88
|
+
exports.prepareFormData = prepareFormData;
|
|
89
|
+
|
|
90
|
+
//# sourceMappingURL=prepareFormData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_plugins","require","availableTransformerPlugins","undefined","getAvailableTransformerPlugins","plugins","byType","reduce","transformers","pl","fieldTypes","Array","isArray","fieldType","_iterator","_createForOfIteratorHelper2","default","_step","s","n","done","value","console","warn","concat","err","e","f","transformationRunner","createTransformationRunner","availablePlugins","field","transformer","type","transform","prepareFormData","input","fields","runTransformation","output","inputValue","fieldId","multipleValues","values","length","map","exports"],"sources":["prepareFormData.ts"],"sourcesContent":["import { CmsContentEntry, CmsFieldValueTransformer, CmsModelField } from \"~/types\";\nimport { plugins } from \"@webiny/plugins\";\n\ninterface AvailableFieldTransformers {\n [fieldType: string]: CmsFieldValueTransformer;\n}\n\n/**\n * This method builds transformer plugins only once.\n * Really no need in building more than once because at this point all plugins are registered.\n */\nlet availableTransformerPlugins: AvailableFieldTransformers | undefined = undefined;\nconst getAvailableTransformerPlugins = (): AvailableFieldTransformers => {\n if (availableTransformerPlugins) {\n return availableTransformerPlugins;\n }\n availableTransformerPlugins = plugins\n .byType<CmsFieldValueTransformer>(\"cms-field-value-transformer\")\n .reduce<AvailableFieldTransformers>((transformers, pl) => {\n const fieldTypes = Array.isArray(pl.fieldType) ? pl.fieldType : [pl.fieldType];\n for (const fieldType of fieldTypes) {\n if (transformers[fieldType]) {\n console.warn(\n `Transformer for field type \"${fieldType}\" is already defined. There cannot be more than one transformer.`\n );\n continue;\n }\n transformers[fieldType] = pl;\n }\n return transformers;\n }, {});\n\n return availableTransformerPlugins;\n};\n\ninterface TransformationRunnerCallable {\n (field: CmsModelField, value: any): any;\n}\n\nlet transformationRunner: TransformationRunnerCallable;\nconst createTransformationRunner = (): TransformationRunnerCallable => {\n if (transformationRunner) {\n return transformationRunner;\n }\n const availablePlugins = getAvailableTransformerPlugins();\n\n transformationRunner = (field, value) => {\n const transformer = availablePlugins[field.type];\n if (!transformer) {\n return value;\n }\n return transformer.transform(value, field);\n };\n return transformationRunner;\n};\n\nexport const prepareFormData = (\n input: Partial<CmsContentEntry>,\n fields: CmsModelField[]\n): CmsContentEntry => {\n const runTransformation = createTransformationRunner();\n\n return fields.reduce<CmsContentEntry>((output, field) => {\n const inputValue = input[field.fieldId];\n\n if (field.multipleValues) {\n const values = Array.isArray(inputValue) ? inputValue : undefined;\n if (!values?.length) {\n return output;\n }\n /**\n * We need to skip sending the values if there is only one item in the array, and it is a null or undefined value.\n *\n * In case there are more items in the array, and they are null / undefined,\n * we must not do anything because it means the user added new items into the array,\n * and they want to have it like that - or is a mistake by user - in that case they will then remove the extra item(s).\n */\n //\n else if (values.length === 1 && (values[0] === null || values[0] === undefined)) {\n return output;\n }\n output[field.fieldId] = values.map(value => runTransformation(field, value));\n return output;\n }\n /**\n * Regular values, single values.\n */\n output[field.fieldId] = runTransformation(field, inputValue);\n\n return output;\n }, {} as CmsContentEntry);\n};\n"],"mappings":";;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAMA;AACA;AACA;AACA;AACA,IAAIC,2BAAmE,GAAGC,SAAS;AACnF,IAAMC,8BAA8B,GAAG,SAAjCA,8BAA8BA,CAAA,EAAqC;EACrE,IAAIF,2BAA2B,EAAE;IAC7B,OAAOA,2BAA2B;EACtC;EACAA,2BAA2B,GAAGG,gBAAO,CAChCC,MAAM,CAA2B,6BAA6B,CAAC,CAC/DC,MAAM,CAA6B,UAACC,YAAY,EAAEC,EAAE,EAAK;IACtD,IAAMC,UAAU,GAAGC,KAAK,CAACC,OAAO,CAACH,EAAE,CAACI,SAAS,CAAC,GAAGJ,EAAE,CAACI,SAAS,GAAG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M,CAAC9B,MAAM,CAAkB,UAACgC,MAAM,EAAER,KAAK,EAAK;IACrD,IAAMS,UAAU,GAAGJ,KAAK,CAACL,KAAK,CAACU,OAAO,CAAC;IAEvC,IAAIV,KAAK,CAACW,cAAc,EAAE;MACtB,IAAMC,MAAM,GAAGhC,KAAK,CAACC,OAAO,CAAC4B,UAAU,CAAC,GAAGA,UAAU,GAAGrC,SAAS;MACjE,IAAI,EAACwC,MAAM,aAANA,MAAM,eAANA,MAAM,CAAEC,MAAM,GAAE;QACjB,OAAOL,MAAM;MACjB;MACA;AACZ;AACA;AACA;AACA;AACA;AACA;MACY;MAAA,KACK,IAAII,MAAM,CAACC,MAAM,KAAK,CAAC,KAAKD,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,IAAIA,MAAM,CAAC,CAAC,CAAC,KAAKxC,SAAS,CAAC,EAAE;QAC7E,OAAOoC,MAAM;MACjB;MACAA,MAAM,CAACR,KAAK,CAACU,OAAO,CAAC,GAAGE,MAAM,CAACE,GAAG,CAAC,UAAAxB,KAAK;QAAA,OAAIiB,iBAAiB,CAACP,KAAK,EAAEV,KAAK,CAAC;MAAA,EAAC;MAC5E,OAAOkB,MAAM;IACjB;IACA;AACR;AACA;IACQA,MAAM,CAACR,KAAK,CAACU,OAAO,CAAC,GAAGH,iBAAiB,CAACP,KAAK,EAAES,UAAU,CAAC;IAE5D,OAAOD,MAAM;EACjB,CAAC,EAAE,CAAC,CAAoB,CAAC;AAC7B,CAAC;AAACO,OAAA,CAAAX,eAAA,GAAAA,eAAA"}
|
package/types/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from "./shared";
|
|
|
14
14
|
interface QueryFieldParams {
|
|
15
15
|
model: CmsModel;
|
|
16
16
|
field: CmsModelField;
|
|
17
|
+
graphQLTypePrefix: string;
|
|
17
18
|
}
|
|
18
19
|
interface Position {
|
|
19
20
|
row: number;
|
|
@@ -195,7 +196,7 @@ export interface CmsModelFieldTypePlugin extends Plugin {
|
|
|
195
196
|
* }
|
|
196
197
|
* ```
|
|
197
198
|
*/
|
|
198
|
-
queryField?: string | ((params: QueryFieldParams) => string);
|
|
199
|
+
queryField?: string | ((params: QueryFieldParams) => string | null);
|
|
199
200
|
};
|
|
200
201
|
render?(params: any): React.ReactElement;
|
|
201
202
|
tags?: string[];
|
|
@@ -469,7 +470,7 @@ export interface CmsSecurityPermission extends SecurityPermission {
|
|
|
469
470
|
export interface CmsErrorResponse {
|
|
470
471
|
message: string;
|
|
471
472
|
code: string;
|
|
472
|
-
data: Record<string, any
|
|
473
|
+
data: Record<string, any>;
|
|
473
474
|
}
|
|
474
475
|
/**
|
|
475
476
|
* @category GraphQL
|
package/types/index.js
CHANGED
package/types/index.js.map
CHANGED
|
@@ -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}\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);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.FC;\n getBind: (index?: number, key?: string) => BindComponent;\n contentModel: CmsModel;\n}\n\n/**\n * @deprecated Use `CmsModelFieldRendererProps`.\n */\nexport type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;\n\n/**\n * @deprecated Use `CmsModelFieldRendererPlugin`.\n */\nexport type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.multipleValues\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidator[];\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.FC<{ activeTab: boolean }>;\n\n// ------------------------------------------------------------------------------------------------------------\nexport interface CmsEditorFieldOptionPlugin extends Plugin {\n type: \"cms-editor-field-option\";\n render(): ReactElement;\n}\n\nexport interface CmsContentDetailsPlugin extends Plugin {\n render: (params: any) => ReactNode;\n}\n\nexport interface FieldLayoutPosition {\n row: number;\n index: number | null;\n}\n\nexport interface CmsEditorFormSettingsPlugin extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n render(props: { Bind: BaseBindComponent; form: FormAPI; formData: any }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI;\n formData: any;\n }): React.ReactNode;\n}\n\nexport interface CmsIcon {\n /**\n * [ pack, icon ], ex: [\"fab\", \"cog\"]\n */\n id: [IconPrefix, IconName];\n /**\n * Icon name\n */\n name: string;\n /**\n * SVG element\n */\n svg: ReactElement;\n}\n\nexport interface CmsIconsPlugin extends Plugin {\n type: \"cms-icons\";\n getIcons(): CmsIcon[];\n}\n\n/**\n * Transform field value when sending data to the API.\n */\nexport interface CmsFieldValueTransformer<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-value-transformer\";\n /**\n * A field type for the value transformer. Or a list of field types.\n */\n fieldType: string | string[];\n /**\n * A transformer function that takes a value and returns a new one.\n */\n transform: (value: any, field: TField) => any;\n}\n\n/**\n * Define a custom form layout renderer for a specific content model.\n */\nexport interface CmsContentFormRendererPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-form-renderer\";\n /**\n * Content model ID that will use this renderer.\n */\n modelId: string;\n\n /**\n * A function that will render a custom form layout.\n */\n render(props: {\n /**\n * Content model that is being rendered.\n */\n contentModel: CmsModel;\n /**\n * Content entry data handled by the Form element.\n */\n data: Record<string, any>;\n /**\n * A component to bind data to the Form.\n */\n Bind: BindComponent;\n /**\n * Content model fields to render.\n */\n fields: Record<string, React.ReactElement>;\n }): React.ReactNode;\n}\n/**\n * #########################\n * Data types\n * #########################\n */\nexport interface CmsSecurityPermission extends SecurityPermission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: Record<string, string>;\n groups?: Record<string, string>;\n endpoints?: string[];\n locales?: string[];\n rwd?: string;\n own?: boolean;\n pw?: string;\n}\n\n/**\n * @category GraphQL\n * @category Error\n */\nexport interface CmsErrorResponse {\n message: string;\n code: string;\n data: Record<string, any> | Record<string, any>[];\n}\n/**\n * @category GraphQL\n * @category Meta\n */\nexport interface CmsMetaResponse {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\n/***\n * ###### FORM ########\n */\nexport interface BindComponentRenderProp<T = any, F = Record<string, any>>\n extends BaseBindComponentRenderProp<T, F> {\n parentName: string;\n appendValue: (value: any, index?: number) => void;\n prependValue: (value: any) => void;\n appendValues: (values: any[]) => void;\n removeValue: (index: number) => void;\n moveValueUp: (index: number) => void;\n moveValueDown: (index: number) => void;\n}\n\ninterface BindComponentProps extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent = React.FC<BindComponentProps> & {\n parentName?: string;\n};\n\n/**\n * After RequestReview and RequestChanges was removed, we need an option to add new status filters\n */\nexport interface CmsEntryFilterStatusPlugin extends Plugin {\n type: \"cms.entry.filter.status\";\n label: string;\n value: string;\n}\n"],"mappings":";;;;;AAoBA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,OAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
|
|
1
|
+
{"version":3,"names":["_validation","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_model","_shared"],"sources":["index.ts"],"sourcesContent":["import * as React from \"react\";\nimport { ReactElement, ReactNode } from \"react\";\nimport { Plugin } from \"@webiny/plugins/types\";\nimport {\n BindComponent as BaseBindComponent,\n BindComponentProps as BaseBindComponentProps,\n BindComponentRenderProp as BaseBindComponentRenderProp,\n FormAPI\n} from \"@webiny/form\";\nimport { IconName, IconPrefix } from \"@fortawesome/fontawesome-svg-core\";\nimport { SecurityPermission } from \"@webiny/app-security/types\";\nimport {\n CmsModelFieldValidator,\n CmsModelFieldValidatorsFactory,\n CmsModelFieldValidatorsGroup\n} from \"./validation\";\nimport { CmsModel, CmsModelField } from \"./model\";\nimport { CmsIdentity } from \"~/types/shared\";\nimport { DragObjectWithType } from \"react-dnd\";\n\nexport * from \"./validation\";\nexport * from \"./model\";\nexport * from \"./shared\";\n\ninterface QueryFieldParams {\n model: CmsModel;\n field: CmsModelField;\n graphQLTypePrefix: string;\n}\n\ninterface Position {\n row: number;\n index: number;\n}\n\ninterface Location {\n folderId: string;\n}\n\nexport interface DragSource extends DragObjectWithType {\n parent?: string;\n pos?: Partial<Position>;\n type: \"row\" | \"field\" | \"newField\";\n fieldType?: string;\n field?: CmsModelField | null;\n fields?: CmsModelField[];\n}\n\n/**\n * @deprecated Use `CmsModelFieldTypePlugin`.\n */\nexport type CmsEditorFieldTypePlugin = CmsModelFieldTypePlugin;\n\nexport interface CmsModelFieldTypePlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-type\";\n field: {\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n *\n * ```ts\n * type: \"myField\"\n * ```\n */\n type: string;\n /**\n * A display name for the field.\n *\n * ```ts\n * label: \"Field name\"\n * ```\n */\n label: string;\n /**\n * A list of available validators for the model field.\n *\n * ```ts\n * validators: [\n * \"required\",\n * \"gte\",\n * \"lte\"\n * ]\n * ```\n */\n validators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * A list of available validators when a model field accepts a list (array) of values.\n *\n * ```ts\n * listValidators: [\n * \"minLength\",\n * \"maxLength\"\n * ]\n * ```\n */\n listValidators?: string[] | CmsModelFieldValidatorsGroup | CmsModelFieldValidatorsFactory;\n /**\n * An explanation of the field displayed beneath the label.\n *\n * ```ts\n * description: \"A short description of the field\"\n * ```\n */\n description: string;\n /**\n * A ReactNode to display the icon for the field.\n *\n * ```tsx\n * icon: <MyIconComponent />\n * ```\n */\n icon: React.ReactNode;\n /**\n * Is it allowed to have multiple values in this field?\n *\n * ```ts\n * allowMultipleValues: true\n * ```\n */\n allowMultipleValues?: boolean;\n /**\n * Does this field type have a fixed list of values that can be selected?\n *\n * ```ts\n * allowPredefinedValues: false\n * ```\n */\n allowPredefinedValues?: boolean;\n /**\n * A ReactNode label when multiple values are enabled.\n */\n multipleValuesLabel?: React.ReactNode;\n /**\n * These are default values when the field is first created. This is a representation of the field that is stored in the database.\n *\n * ```ts\n * createField: () => ({\n * type: \"fieldType\",\n * validation: [],\n * renderer: {\n * name: \"fieldTypeRenderer\"\n * }\n * })\n * ```\n */\n createField: () => Pick<CmsModelField, \"type\" | \"validation\" | \"renderer\" | \"settings\">;\n /**\n * If `true` (default), this field will be configurable via a settings dialog.\n * If `false`, a user will not be able to open the settings dialog, not will the dialog be opened on field drop.\n */\n canEditSettings?: boolean;\n /**\n * Determine if a `draggable` can be dropped into this field.\n * NOTE: This is only applicable to nested field types.\n */\n canAccept?(field: CmsModelField, draggable: DragSource): boolean;\n /**\n * If `true` (default), will allow fields to be laid out into columns (next to each other).\n * If `false`, horizontal layout will not be allowed.\n * NOTE: This is only applicable to nested field types.\n */\n allowLayout?: boolean;\n /**\n * A ReactNode that you can add in the section below the help text when creating/editing field.\n *\n * ```tsx\n * renderSettings: (params) => {\n * return <FieldSettingsComponent />;\n * }\n * ```\n */\n renderSettings?: (params: {\n afterChangeLabel: (value: string) => void;\n uniqueFieldIdValidator: (fieldId: string) => void;\n contentModel: CmsModel;\n }) => React.ReactNode;\n /**\n * A ReactNode that renders in the Predefined values tab.\n *\n * ```tsx\n * renderPredefinedValues: (params) => {\n * const {form: {Bind}} = params;\n * return (\n * <Bind name=\"fieldProperty\">\n * <InputComponent />\n * </Bind>\n * );\n * }\n * ```\n */\n renderPredefinedValues?: (params: {\n getBind: (index?: number) => any;\n }) => React.ReactElement;\n /**\n * Object wrapper for GraphQL stuff\n */\n graphql?: {\n /**\n * Define field selection.\n *\n * ```ts\n * graphql: {\n * queryField: `\n * {\n * id\n * title\n * createdOn\n * }\n * `,\n * }\n * ```\n */\n queryField?: string | ((params: QueryFieldParams) => string | null);\n };\n render?(params: any): React.ReactElement;\n tags?: string[];\n /**\n * Render additional information in the Admin UI Model edit view\n */\n renderInfo?: (params: { field: CmsModelField; model: CmsModel }) => React.ReactElement;\n };\n}\n\nexport interface CmsModelFieldRendererProps {\n field: CmsModelField;\n Label: React.FC;\n getBind: (index?: number, key?: string) => BindComponent;\n contentModel: CmsModel;\n}\n\n/**\n * @deprecated Use `CmsModelFieldRendererProps`.\n */\nexport type CmsEditorFieldRendererProps = CmsModelFieldRendererProps;\n\n/**\n * @deprecated Use `CmsModelFieldRendererPlugin`.\n */\nexport type CmsEditorFieldRendererPlugin = CmsModelFieldRendererPlugin;\n\nexport interface CmsModelFieldRendererPlugin extends Plugin {\n /**\n * a plugin type\n */\n type: \"cms-editor-field-renderer\";\n renderer: {\n /**\n * Name of the renderer to match the one from `createField()` method in `CmsModelFieldTypePlugin`.\n *\n * ```ts\n * renderName: \"myFieldTypeRenderer\"\n * ```\n */\n rendererName: string;\n /**\n * A display name for the field in the UI. It is a `ReactNode` type, so you can use a JSX element.\n *\n * ```tsx\n * name: <MyFieldNameComponent />\n * ```\n */\n name: React.ReactNode;\n /**\n * A description for the field in the UI. Works exactly like the `name` property.\n *\n * ```tsx\n * name: <MyFieldDescriptionComponent />\n * ```\n */\n description: React.ReactNode;\n /**\n * A method that determines if the field can be rendered by this plugin.\n *\n * ```ts\n * canUse({ field }) {\n * return (\n * field.type === \"myType\" && !field.multipleValues\n * );\n * }\n * ```\n */\n canUse(props: {\n field: CmsModelField;\n fieldPlugin: CmsModelFieldTypePlugin;\n model: CmsModel;\n }): boolean;\n /**\n * Renders a field in the UI.\n *\n * ```tsx\n * render({ field, getBind }) {\n * const Bind = getBind();\n *\n * return (\n * <Bind>\n * {bind => {\n * return (\n * <Input\n * value={bind.value}\n * onChange={bind.onChange}\n * />\n * )\n * }}\n * </Bind>\n * );\n * }\n * ```\n */\n render(props: CmsModelFieldRendererProps): React.ReactNode;\n };\n}\n\nexport interface CmsEditorFieldPredefinedValuesEntry {\n label: string;\n value: string;\n selected?: boolean;\n}\n\nexport interface CmsEditorFieldPredefinedValues {\n enabled: boolean;\n values: CmsEditorFieldPredefinedValuesEntry[];\n}\n\nexport interface CmsDynamicZoneTemplate {\n id: string;\n name: string;\n gqlTypeName: string;\n description: string;\n icon: string;\n fields: CmsModelField[];\n layout: string[][];\n validation: CmsModelFieldValidator[];\n}\n\nexport type CmsContentEntryStatusType = \"draft\" | \"published\" | \"unpublished\";\n\n/**\n * @deprecated Use `CmsContentEntry`.\n */\nexport type CmsEditorContentEntry = CmsContentEntry;\n\nexport interface CmsContentEntry {\n id: string;\n savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n description?: string;\n image?: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n [key: string]: any;\n}\n\nexport interface CmsContentEntryRevision {\n id: string;\n savedOn: string;\n modelId: string;\n createdBy: CmsIdentity;\n wbyAco_location: Location;\n meta: {\n title: string;\n publishedOn: string;\n locked: boolean;\n status: CmsContentEntryStatusType;\n version: number;\n };\n}\n\nexport type CmsEditorContentTab = React.FC<{ activeTab: boolean }>;\n\n// ------------------------------------------------------------------------------------------------------------\nexport interface CmsEditorFieldOptionPlugin extends Plugin {\n type: \"cms-editor-field-option\";\n render(): ReactElement;\n}\n\nexport interface CmsContentDetailsPlugin extends Plugin {\n render: (params: any) => ReactNode;\n}\n\nexport interface FieldLayoutPosition {\n row: number;\n index: number | null;\n}\n\nexport interface CmsEditorFormSettingsPlugin extends Plugin {\n type: \"cms-editor-form-settings\";\n title: string;\n description: string;\n icon: React.ReactElement;\n render(props: { Bind: BaseBindComponent; form: FormAPI; formData: any }): React.ReactNode;\n renderHeaderActions?(props: {\n Bind: BaseBindComponent;\n form: FormAPI;\n formData: any;\n }): React.ReactNode;\n}\n\nexport interface CmsIcon {\n /**\n * [ pack, icon ], ex: [\"fab\", \"cog\"]\n */\n id: [IconPrefix, IconName];\n /**\n * Icon name\n */\n name: string;\n /**\n * SVG element\n */\n svg: ReactElement;\n}\n\nexport interface CmsIconsPlugin extends Plugin {\n type: \"cms-icons\";\n getIcons(): CmsIcon[];\n}\n\n/**\n * Transform field value when sending data to the API.\n */\nexport interface CmsFieldValueTransformer<TField extends CmsModelField = CmsModelField>\n extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-field-value-transformer\";\n /**\n * A field type for the value transformer. Or a list of field types.\n */\n fieldType: string | string[];\n /**\n * A transformer function that takes a value and returns a new one.\n */\n transform: (value: any, field: TField) => any;\n}\n\n/**\n * Define a custom form layout renderer for a specific content model.\n */\nexport interface CmsContentFormRendererPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-form-renderer\";\n /**\n * Content model ID that will use this renderer.\n */\n modelId: string;\n\n /**\n * A function that will render a custom form layout.\n */\n render(props: {\n /**\n * Content model that is being rendered.\n */\n contentModel: CmsModel;\n /**\n * Content entry data handled by the Form element.\n */\n data: Record<string, any>;\n /**\n * A component to bind data to the Form.\n */\n Bind: BindComponent;\n /**\n * Content model fields to render.\n */\n fields: Record<string, React.ReactElement>;\n }): React.ReactNode;\n}\n/**\n * #########################\n * Data types\n * #########################\n */\nexport interface CmsSecurityPermission extends SecurityPermission {\n accessLevel?: \"full\" | \"no\" | \"custom\";\n models?: Record<string, string>;\n groups?: Record<string, string>;\n endpoints?: string[];\n locales?: string[];\n rwd?: string;\n own?: boolean;\n pw?: string;\n}\n\n/**\n * @category GraphQL\n * @category Error\n */\nexport interface CmsErrorResponse {\n message: string;\n code: string;\n data: Record<string, any>;\n}\n/**\n * @category GraphQL\n * @category Meta\n */\nexport interface CmsMetaResponse {\n totalCount: number;\n cursor: string | null;\n hasMoreItems: boolean;\n}\n\n/***\n * ###### FORM ########\n */\nexport interface BindComponentRenderProp<T = any, F = Record<string, any>>\n extends BaseBindComponentRenderProp<T, F> {\n parentName: string;\n appendValue: (value: any, index?: number) => void;\n prependValue: (value: any) => void;\n appendValues: (values: any[]) => void;\n removeValue: (index: number) => void;\n moveValueUp: (index: number) => void;\n moveValueDown: (index: number) => void;\n}\n\ninterface BindComponentProps extends Omit<BaseBindComponentProps, \"children\" | \"name\"> {\n name?: string;\n children?: ((props: BindComponentRenderProp) => React.ReactElement) | React.ReactElement;\n}\n\nexport type BindComponent = React.FC<BindComponentProps> & {\n parentName?: string;\n};\n\n/**\n * After RequestReview and RequestChanges was removed, we need an option to add new status filters\n */\nexport interface CmsEntryFilterStatusPlugin extends Plugin {\n type: \"cms.entry.filter.status\";\n label: string;\n value: string;\n}\n"],"mappings":";;;;;AAoBA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,MAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,MAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,MAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAC,MAAA,CAAAL,GAAA;IAAA;EAAA;AAAA;AACA,IAAAM,OAAA,GAAAV,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAQ,OAAA,EAAAP,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAM,OAAA,CAAAN,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAE,OAAA,CAAAN,GAAA;IAAA;EAAA;AAAA"}
|
package/types/model.js
CHANGED
package/types/shared.js
CHANGED