@webiny/api-headless-cms 5.40.6 → 5.41.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/constants.d.ts +1 -1
- package/crud/AccessControl/AccessControl.d.ts +2 -2
- package/crud/contentEntry/abstractions/IListEntries.d.ts +2 -2
- package/crud/contentEntry/abstractions/IListEntries.js.map +1 -1
- package/crud/contentEntry/afterDelete.js +7 -1
- package/crud/contentEntry/afterDelete.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +1 -1
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +1 -1
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +1 -1
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +1 -1
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +1 -1
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.js +0 -8
- package/crud/contentEntry/useCases/DeleteEntry/TransformEntryMoveToBin.js.map +1 -1
- package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.js +0 -8
- package/crud/contentEntry/useCases/RestoreEntryFromBin/TransformEntryRestoreFromBin.js.map +1 -1
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/validation.d.ts +50 -50
- package/crud/contentModel.crud.js.map +1 -1
- package/export/crud/sanitize.d.ts +1 -1
- package/export/crud/sanitize.js.map +1 -1
- package/export/types.d.ts +3 -3
- package/graphql/createExecutableSchema.js +14 -7
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/getSchema.js +6 -5
- package/graphql/getSchema.js.map +1 -1
- package/graphql/index.d.ts +1 -1
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.js +1 -3
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createSingularSDL.js +4 -0
- package/graphql/schema/createSingularSDL.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveList.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveListDeleted.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveMove.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolvePublish.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveRestoreFromBin.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +1 -1
- package/graphql/schema/resolvers/manage/resolveValidate.d.ts +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.d.ts +1 -1
- package/graphql/schema/resolvers/preview/resolveList.d.ts +1 -1
- package/graphql/schema/resolvers/read/resolveGet.d.ts +1 -1
- package/graphql/schema/resolvers/read/resolveList.d.ts +1 -1
- package/graphql/schema/resolvers/singular/resolveGet.d.ts +1 -1
- package/graphql/schema/resolvers/singular/resolveUpdate.d.ts +1 -1
- package/index.d.ts +4 -2
- package/index.js +24 -0
- package/index.js.map +1 -1
- package/package.json +26 -24
- package/plugins/CmsGraphQLSchemaPlugin/CmsGraphQLSchemaPlugin.d.ts +2 -2
- package/plugins/CmsModelPlugin.d.ts +1 -1
- package/plugins/CmsModelPlugin.js +1 -1
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/CmsParametersPlugin.d.ts +2 -2
- package/types/context.d.ts +7 -7
- package/types/context.js.map +1 -1
- package/types/modelAst.d.ts +4 -4
- package/types/modelField.d.ts +3 -2
- package/types/modelField.js.map +1 -1
- package/types/types.d.ts +25 -17
- package/types/types.js.map +1 -1
- package/utils/contentEntryTraverser/ContentEntryTraverser.d.ts +4 -1
- package/utils/contentEntryTraverser/ContentEntryTraverser.js.map +1 -1
- package/utils/contentModelAst/CmsModelToAstConverter.d.ts +1 -1
- package/utils/contentModelAst/CmsModelToAstConverter.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +11 -0
- package/utils/index.js.map +1 -1
- package/utils/modelFieldTraverser/ModelFieldTraverser.d.ts +16 -0
- package/utils/modelFieldTraverser/ModelFieldTraverser.js +41 -0
- package/utils/modelFieldTraverser/ModelFieldTraverser.js.map +1 -0
- package/utils/modelFieldTraverser/index.d.ts +1 -0
- package/utils/modelFieldTraverser/index.js +18 -0
- package/utils/modelFieldTraverser/index.js.map +1 -0
package/index.js
CHANGED
|
@@ -136,6 +136,30 @@ Object.keys(_handleRequest).forEach(function (key) {
|
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
138
|
});
|
|
139
|
+
var _ContentEntryTraverser = require("./utils/contentEntryTraverser/ContentEntryTraverser");
|
|
140
|
+
Object.keys(_ContentEntryTraverser).forEach(function (key) {
|
|
141
|
+
if (key === "default" || key === "__esModule") return;
|
|
142
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
143
|
+
if (key in exports && exports[key] === _ContentEntryTraverser[key]) return;
|
|
144
|
+
Object.defineProperty(exports, key, {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return _ContentEntryTraverser[key];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
var _contentModelAst = require("./utils/contentModelAst");
|
|
152
|
+
Object.keys(_contentModelAst).forEach(function (key) {
|
|
153
|
+
if (key === "default" || key === "__esModule") return;
|
|
154
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
155
|
+
if (key in exports && exports[key] === _contentModelAst[key]) return;
|
|
156
|
+
Object.defineProperty(exports, key, {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return _contentModelAst[key];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
});
|
|
139
163
|
const createHeadlessCmsGraphQL = (params = {}) => {
|
|
140
164
|
return [(0, _RevisionIdScalarPlugin.createRevisionIdScalarPlugin)(),
|
|
141
165
|
/**
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_graphql","require","_modelManager","_graphqlFields","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_validators","_parameters","_context","_entryStorage","_fieldConverters","_export","_storage","_createLexicalHTMLRenderer","_RevisionIdScalarPlugin","_isHeadlessCmsReady","_createModelField","_normalizeGraphQlInput","_plugins","_incrementEntryIdVersion","_RichTextRenderer","_handleRequest","createHeadlessCmsGraphQL","params","createRevisionIdScalarPlugin","createPathParameterPlugin","createHeaderParameterPlugin","createContextParameterPlugin","baseCreateGraphQL","createExportGraphQL","createLexicalHTMLRenderer","createHeadlessCmsContext","createContextPlugin","createDefaultModelManager","createGraphQLFields","createFieldConverters","createValidators","createStorageTransform"],"sources":["index.ts"],"sourcesContent":["import { createGraphQL as baseCreateGraphQL, CreateGraphQLParams } from \"~/graphql\";\nimport { createDefaultModelManager } from \"~/modelManager\";\nimport { createGraphQLFields } from \"~/graphqlFields\";\nimport { createValidators } from \"~/validators\";\nimport {\n createContextParameterPlugin,\n createHeaderParameterPlugin,\n createPathParameterPlugin\n} from \"~/parameters\";\nimport { createContextPlugin, CrudParams } from \"~/context\";\nimport {\n entryFieldFromStorageTransform,\n entryFromStorageTransform,\n entryToStorageTransform\n} from \"./utils/entryStorage\";\nimport { createFieldConverters } from \"~/fieldConverters\";\nimport { createExportGraphQL } from \"~/export\";\nimport { createStorageTransform } from \"~/storage\";\nimport { createLexicalHTMLRenderer } from \"./htmlRenderer/createLexicalHTMLRenderer\";\nimport { createRevisionIdScalarPlugin } from \"~/graphql/scalars/RevisionIdScalarPlugin\";\n\nexport * from \"./utils/isHeadlessCmsReady\";\nexport * from \"./utils/createModelField\";\nexport * from \"./graphql/schema/resolvers/manage/normalizeGraphQlInput\";\n\nexport type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;\nexport const createHeadlessCmsGraphQL = (params: CreateHeadlessCmsGraphQLParams = {}) => {\n return [\n createRevisionIdScalarPlugin(),\n /**\n * PathParameter plugins are used to determine the type of the cms endpoint\n */\n createPathParameterPlugin(),\n createHeaderParameterPlugin(),\n createContextParameterPlugin(),\n /**\n * At this point we can create, or not create, CMS GraphQL Schema.\n */\n ...baseCreateGraphQL(params),\n createExportGraphQL(),\n createLexicalHTMLRenderer()\n ];\n};\n\nexport type ContentContextParams = CrudParams;\nexport const createHeadlessCmsContext = (params: ContentContextParams) => {\n return [\n /**\n * Context for all Lambdas - everything is loaded now.\n */\n createContextPlugin(params),\n createDefaultModelManager(),\n createGraphQLFields(),\n createFieldConverters(),\n createValidators(),\n ...createStorageTransform()\n ];\n};\nexport * from \"~/graphqlFields\";\nexport * from \"~/plugins\";\nexport * from \"~/utils/incrementEntryIdVersion\";\nexport * from \"~/utils/RichTextRenderer\";\nexport * from \"./graphql/handleRequest\";\nexport { entryToStorageTransform, entryFieldFromStorageTransform, entryFromStorageTransform };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAwDAG,MAAA,CAAAC,IAAA,CAAAF,cA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AA,OAAA,CAAAL,GAAA,MAAAwB,cAAA,CAAAxB,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAgB,cAAA,CAAAxB,GAAA;IAAA;EAAA;AAAA;
|
|
1
|
+
{"version":3,"names":["_graphql","require","_modelManager","_graphqlFields","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_validators","_parameters","_context","_entryStorage","_fieldConverters","_export","_storage","_createLexicalHTMLRenderer","_RevisionIdScalarPlugin","_isHeadlessCmsReady","_createModelField","_normalizeGraphQlInput","_plugins","_incrementEntryIdVersion","_RichTextRenderer","_handleRequest","_ContentEntryTraverser","_contentModelAst","createHeadlessCmsGraphQL","params","createRevisionIdScalarPlugin","createPathParameterPlugin","createHeaderParameterPlugin","createContextParameterPlugin","baseCreateGraphQL","createExportGraphQL","createLexicalHTMLRenderer","createHeadlessCmsContext","createContextPlugin","createDefaultModelManager","createGraphQLFields","createFieldConverters","createValidators","createStorageTransform"],"sources":["index.ts"],"sourcesContent":["import { createGraphQL as baseCreateGraphQL, CreateGraphQLParams } from \"~/graphql\";\nimport { createDefaultModelManager } from \"~/modelManager\";\nimport { createGraphQLFields } from \"~/graphqlFields\";\nimport { createValidators } from \"~/validators\";\nimport {\n createContextParameterPlugin,\n createHeaderParameterPlugin,\n createPathParameterPlugin\n} from \"~/parameters\";\nimport { createContextPlugin, CrudParams } from \"~/context\";\nimport {\n entryFieldFromStorageTransform,\n entryFromStorageTransform,\n entryToStorageTransform\n} from \"./utils/entryStorage\";\nimport { createFieldConverters } from \"~/fieldConverters\";\nimport { createExportGraphQL } from \"~/export\";\nimport { createStorageTransform } from \"~/storage\";\nimport { createLexicalHTMLRenderer } from \"./htmlRenderer/createLexicalHTMLRenderer\";\nimport { createRevisionIdScalarPlugin } from \"~/graphql/scalars/RevisionIdScalarPlugin\";\n\nexport * from \"./utils/isHeadlessCmsReady\";\nexport * from \"./utils/createModelField\";\nexport * from \"./graphql/schema/resolvers/manage/normalizeGraphQlInput\";\n\nexport type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;\nexport const createHeadlessCmsGraphQL = (params: CreateHeadlessCmsGraphQLParams = {}) => {\n return [\n createRevisionIdScalarPlugin(),\n /**\n * PathParameter plugins are used to determine the type of the cms endpoint\n */\n createPathParameterPlugin(),\n createHeaderParameterPlugin(),\n createContextParameterPlugin(),\n /**\n * At this point we can create, or not create, CMS GraphQL Schema.\n */\n ...baseCreateGraphQL(params),\n createExportGraphQL(),\n createLexicalHTMLRenderer()\n ];\n};\n\nexport type ContentContextParams = CrudParams;\nexport const createHeadlessCmsContext = (params: ContentContextParams) => {\n return [\n /**\n * Context for all Lambdas - everything is loaded now.\n */\n createContextPlugin(params),\n createDefaultModelManager(),\n createGraphQLFields(),\n createFieldConverters(),\n createValidators(),\n ...createStorageTransform()\n ];\n};\nexport * from \"~/graphqlFields\";\nexport * from \"~/plugins\";\nexport * from \"~/utils/incrementEntryIdVersion\";\nexport * from \"~/utils/RichTextRenderer\";\nexport * from \"./graphql/handleRequest\";\nexport * from \"./utils/contentEntryTraverser/ContentEntryTraverser\";\nexport * from \"./utils/contentModelAst\";\nexport { entryToStorageTransform, entryFieldFromStorageTransform, entryFromStorageTransform };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAwDAG,MAAA,CAAAC,IAAA,CAAAF,cAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,c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ACrB,IAAAC,oDAAyB,EAAC,CAAC,CAC9B;AACL,CAAC;AAAC9B,OAAA,CAAAsB,wBAAA,GAAAA,wBAAA;AAGK,MAAMS,wBAAwB,GAAIR,MAA4B,IAAK;EACtE,OAAO;EACH;AACR;AACA;EACQ,IAAAS,4BAAmB,EAACT,MAAM,CAAC,EAC3B,IAAAU,uCAAyB,EAAC,CAAC,EAC3B,IAAAC,kCAAmB,EAAC,CAAC,EACrB,IAAAC,sCAAqB,EAAC,CAAC,EACvB,IAAAC,4BAAgB,EAAC,CAAC,EAClB,GAAG,IAAAC,+BAAsB,EAAC,CAAC,CAC9B;AACL,CAAC;AAACrC,OAAA,CAAA+B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.41.0-beta.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -18,23 +18,24 @@
|
|
|
18
18
|
],
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@babel/code-frame": "7.24.7",
|
|
21
22
|
"@babel/runtime": "7.24.1",
|
|
22
|
-
"@graphql-tools/
|
|
23
|
-
"@
|
|
24
|
-
"@webiny/api
|
|
25
|
-
"@webiny/api-
|
|
26
|
-
"@webiny/api-
|
|
27
|
-
"@webiny/
|
|
28
|
-
"@webiny/
|
|
29
|
-
"@webiny/handler
|
|
30
|
-
"@webiny/handler-
|
|
31
|
-
"@webiny/handler-
|
|
32
|
-
"@webiny/
|
|
33
|
-
"@webiny/
|
|
34
|
-
"@webiny/
|
|
35
|
-
"@webiny/
|
|
36
|
-
"@webiny/
|
|
37
|
-
"
|
|
23
|
+
"@graphql-tools/merge": "9.0.7",
|
|
24
|
+
"@graphql-tools/schema": "10.0.6",
|
|
25
|
+
"@webiny/api": "5.41.0-beta.0",
|
|
26
|
+
"@webiny/api-i18n": "5.41.0-beta.0",
|
|
27
|
+
"@webiny/api-security": "5.41.0-beta.0",
|
|
28
|
+
"@webiny/api-tenancy": "5.41.0-beta.0",
|
|
29
|
+
"@webiny/error": "5.41.0-beta.0",
|
|
30
|
+
"@webiny/handler": "5.41.0-beta.0",
|
|
31
|
+
"@webiny/handler-aws": "5.41.0-beta.0",
|
|
32
|
+
"@webiny/handler-db": "5.41.0-beta.0",
|
|
33
|
+
"@webiny/handler-graphql": "5.41.0-beta.0",
|
|
34
|
+
"@webiny/lexical-converter": "5.41.0-beta.0",
|
|
35
|
+
"@webiny/plugins": "5.41.0-beta.0",
|
|
36
|
+
"@webiny/pubsub": "5.41.0-beta.0",
|
|
37
|
+
"@webiny/utils": "5.41.0-beta.0",
|
|
38
|
+
"@webiny/validation": "5.41.0-beta.0",
|
|
38
39
|
"dot-prop": "6.0.1",
|
|
39
40
|
"graphql": "15.8.0",
|
|
40
41
|
"graphql-tag": "2.12.6",
|
|
@@ -45,16 +46,17 @@
|
|
|
45
46
|
"pluralize": "8.0.0",
|
|
46
47
|
"semver": "7.5.4",
|
|
47
48
|
"slugify": "1.6.5",
|
|
48
|
-
"zod": "3.
|
|
49
|
+
"zod": "3.23.8"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
52
|
"@babel/cli": "7.24.1",
|
|
52
53
|
"@babel/core": "7.24.3",
|
|
53
54
|
"@babel/preset-env": "7.24.3",
|
|
54
|
-
"@
|
|
55
|
-
"@webiny/
|
|
56
|
-
"@webiny/
|
|
57
|
-
"@webiny/
|
|
55
|
+
"@types/babel__code-frame": "7.0.6",
|
|
56
|
+
"@webiny/api-wcp": "5.41.0-beta.0",
|
|
57
|
+
"@webiny/aws-sdk": "5.41.0-beta.0",
|
|
58
|
+
"@webiny/cli": "5.41.0-beta.0",
|
|
59
|
+
"@webiny/project-utils": "5.41.0-beta.0",
|
|
58
60
|
"apollo-graphql": "0.9.7",
|
|
59
61
|
"get-yarn-workspaces": "1.0.2",
|
|
60
62
|
"graphql": "15.8.0",
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
"rimraf": "5.0.5",
|
|
64
66
|
"sinon": "9.2.4",
|
|
65
67
|
"ttypescript": "1.5.15",
|
|
66
|
-
"typescript": "4.
|
|
68
|
+
"typescript": "4.9.5",
|
|
67
69
|
"write-json-file": "4.3.0"
|
|
68
70
|
},
|
|
69
71
|
"publishConfig": {
|
|
@@ -74,5 +76,5 @@
|
|
|
74
76
|
"build": "yarn webiny run build",
|
|
75
77
|
"watch": "yarn webiny run watch"
|
|
76
78
|
},
|
|
77
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "9ce5e75fc577aa4de2cf08d5ca734b3c98fe65b6"
|
|
78
80
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { GraphQLSchemaPlugin, GraphQLSchemaPluginConfig as BaseGraphQLSchemaPluginConfig, IGraphQLSchemaPlugin } from "@webiny/handler-graphql";
|
|
2
2
|
import { CmsContext } from "../../types";
|
|
3
|
-
export
|
|
4
|
-
export
|
|
3
|
+
export type ICmsGraphQLSchemaPlugin<T extends CmsContext = CmsContext> = IGraphQLSchemaPlugin<T>;
|
|
4
|
+
export type CmsGraphQLSchemaPluginConfig<T extends CmsContext = CmsContext> = BaseGraphQLSchemaPluginConfig<T>;
|
|
5
5
|
export declare class CmsGraphQLSchemaPlugin<T extends CmsContext = CmsContext> extends GraphQLSchemaPlugin<T> implements ICmsGraphQLSchemaPlugin<T> {
|
|
6
6
|
static readonly type = "cms.graphql.schema";
|
|
7
7
|
}
|
|
@@ -41,7 +41,7 @@ interface CmsPrivateModel extends Omit<CmsModelPluginModel, "isPrivate" | "singu
|
|
|
41
41
|
export interface CmsPrivateModelFull extends Omit<CmsPrivateModel, "fields" | "createdBy" | "createdOn" | "savedOn"> {
|
|
42
42
|
fields: CmsModelFieldBase[];
|
|
43
43
|
}
|
|
44
|
-
export
|
|
44
|
+
export type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;
|
|
45
45
|
export interface CmsModelPluginModel extends Omit<CmsModelBase, "locale" | "tenant" | "webinyVersion"> {
|
|
46
46
|
locale?: string;
|
|
47
47
|
tenant?: string;
|
|
@@ -111,7 +111,7 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
111
111
|
* ... and fieldId must be unique.
|
|
112
112
|
*/
|
|
113
113
|
if (fieldIdList.includes(fieldId)) {
|
|
114
|
-
throw new _error.default(`Field's "fieldId" is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
|
|
114
|
+
throw new _error.default(`Field's "fieldId" (id: ${input.id}) is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
|
|
115
115
|
model,
|
|
116
116
|
field: input
|
|
117
117
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_error","_interopRequireDefault","require","_camelCase","_upperFirst","_pluralize","_plugins","_createFieldStorageId","_validateStorageId","createApiName","name","upperFirst","camelCase","createPluralApiName","pluralize","CmsModelPlugin","Plugin","type","constructor","contentModel","options","buildModel","input","isPrivate","singularApiName","pluralApiName","modelPlugin","group","id","description","fields","isPlugin","layout","modelId","titleFieldId","noValidate","model","buildFields","validateLayout","inputFields","length","WebinyError","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","validateStorageId","e","from","data","createFieldStorageId","settings","childFields","push","total","row","count","filter","cell","exports","createCmsModel","createCmsModelPlugin","createPrivateModel","authorization"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\nimport { validateStorageId } from \"~/crud/contentModel/validateStorageId\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * New ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsApiModel\n extends Omit<\n CmsModelPluginModel,\n \"isPrivate\" | \"fields\" | \"singularApiName\" | \"pluralApiName\" | \"isPlugin\"\n > {\n isPrivate?: never;\n noValidate?: boolean;\n singularApiName?: string;\n pluralApiName?: string;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsApiModelFull extends Omit<CmsApiModel, \"fields\"> {\n fields: CmsModelFieldBase[];\n}\n\ninterface CmsPrivateModel\n extends Omit<\n CmsModelPluginModel,\n | \"isPrivate\"\n | \"singularApiName\"\n | \"pluralApiName\"\n | \"fields\"\n | \"isPlugin\"\n | \"layout\"\n | \"titleFieldId\"\n | \"description\"\n > {\n noValidate?: boolean;\n titleFieldId?: string;\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsPrivateModelFull\n extends Omit<CmsPrivateModel, \"fields\" | \"createdBy\" | \"createdOn\" | \"savedOn\"> {\n fields: CmsModelFieldBase[];\n}\n\nexport type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;\n\nexport interface CmsModelPluginModel\n extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModelPluginModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModelPluginModel {\n const isPrivate = input.isPrivate ?? false;\n\n const singularApiName = input.singularApiName\n ? createApiName(input.singularApiName)\n : createApiName(input.name);\n\n const pluralApiName = input.pluralApiName\n ? createApiName(input.pluralApiName)\n : createPluralApiName(input.name);\n\n const modelPlugin: CmsModelPluginModel = {\n group: {\n id: \"\",\n name: \"\"\n },\n description: \"\",\n fields: [],\n isPlugin: true,\n isPrivate,\n layout: [],\n modelId: input.modelId,\n name: input.name,\n pluralApiName,\n singularApiName,\n titleFieldId: \"id\"\n };\n\n if (input.noValidate) {\n /**\n * We can safely ignore this error, because we are sure noValidate is not a model field.\n */\n delete input[\"noValidate\"];\n\n return {\n ...modelPlugin,\n ...input,\n // Since `noValidate` is set, we trust the input, and cast to `CmsModelFieldBase`.\n fields: input.fields as CmsModelFieldBase[],\n pluralApiName,\n singularApiName\n };\n }\n\n const model: CmsModelPluginModel = {\n ...modelPlugin,\n ...input,\n pluralApiName,\n singularApiName,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId)) {\n throw new WebinyError(\n `Field's \"fieldId\" is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId;\n if (storageId) {\n try {\n validateStorageId(storageId);\n } catch (e) {\n throw WebinyError.from(e, {\n data: { model, storageId, field: input }\n });\n }\n } else {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId)) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-expect-error\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModelPluginModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\n/**\n * @deprecated Use `createCmsModelPlugin` instead.\n */\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\nexport const createCmsModelPlugin = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\nexport const createPrivateModel = (\n input: Omit<CmsPrivateModelFull, \"group\" | \"isPrivate\">\n): CmsPrivateModelFull => {\n return {\n authorization: false,\n noValidate: true,\n isPrivate: true,\n group: {\n id: \"private\",\n name: \"Private Models\"\n },\n ...input\n };\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AAEA,IAAAE,WAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,UAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAMA,IAAAK,qBAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;A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,CAAC;MACL;MACA,MAAM,IAAIL,cAAW,CAChB,kBAAiBK,KAAK,CAAClB,EAAG,cAAa,EACxC,yBAAyB,EACzB;QACIQ,KAAK;QACLU;MACJ,CACJ,CAAC;IACL;EACJ;AACJ;;AAEA;AACA;AACA;AAFAkB,OAAA,CAAAjD,cAAA,GAAAA,cAAA;AAGO,MAAMkD,cAAc,GAAGA,CAC1B7B,KAAoB,EACpBhB,OAA+B,KACd;EACjB,OAAO,IAAIL,cAAc,CAACqB,KAAK,EAAEhB,OAAO,CAAC;AAC7C,CAAC;AAAC4C,OAAA,CAAAC,cAAA,GAAAA,cAAA;AAEK,MAAMC,oBAAoB,GAAGA,CAChC9B,KAAoB,EACpBhB,OAA+B,KACd;EACjB,OAAO,IAAIL,cAAc,CAACqB,KAAK,EAAEhB,OAAO,CAAC;AAC7C,CAAC;AAAC4C,OAAA,CAAAE,oBAAA,GAAAA,oBAAA;AAEK,MAAMC,kBAAkB,GAC3B7C,KAAuD,IACjC;EACtB,OAAO;IACH8C,aAAa,EAAE,KAAK;IACpBjC,UAAU,EAAE,IAAI;IAChBZ,SAAS,EAAE,IAAI;IACfI,KAAK,EAAE;MACHC,EAAE,EAAE,SAAS;MACblB,IAAI,EAAE;IACV,CAAC;IACD,GAAGY;EACP,CAAC;AACL,CAAC;AAAC0C,OAAA,CAAAG,kBAAA,GAAAA,kBAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_camelCase","_upperFirst","_pluralize","_plugins","_createFieldStorageId","_validateStorageId","createApiName","name","upperFirst","camelCase","createPluralApiName","pluralize","CmsModelPlugin","Plugin","type","constructor","contentModel","options","buildModel","input","isPrivate","singularApiName","pluralApiName","modelPlugin","group","id","description","fields","isPlugin","layout","modelId","titleFieldId","noValidate","model","buildFields","validateLayout","inputFields","length","WebinyError","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","validateStorageId","e","from","data","createFieldStorageId","settings","childFields","push","total","row","count","filter","cell","exports","createCmsModel","createCmsModelPlugin","createPrivateModel","authorization"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\nimport { validateStorageId } from \"~/crud/contentModel/validateStorageId\";\n\nconst createApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst createPluralApiName = (name: string) => {\n return pluralize(createApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * New ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\nexport interface CmsApiModel\n extends Omit<\n CmsModelPluginModel,\n \"isPrivate\" | \"fields\" | \"singularApiName\" | \"pluralApiName\" | \"isPlugin\"\n > {\n isPrivate?: never;\n noValidate?: boolean;\n singularApiName?: string;\n pluralApiName?: string;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsApiModelFull extends Omit<CmsApiModel, \"fields\"> {\n fields: CmsModelFieldBase[];\n}\n\ninterface CmsPrivateModel\n extends Omit<\n CmsModelPluginModel,\n | \"isPrivate\"\n | \"singularApiName\"\n | \"pluralApiName\"\n | \"fields\"\n | \"isPlugin\"\n | \"layout\"\n | \"titleFieldId\"\n | \"description\"\n > {\n noValidate?: boolean;\n titleFieldId?: string;\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n}\n\nexport interface CmsPrivateModelFull\n extends Omit<CmsPrivateModel, \"fields\" | \"createdBy\" | \"createdOn\" | \"savedOn\"> {\n fields: CmsModelFieldBase[];\n}\n\nexport type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;\n\nexport interface CmsModelPluginModel\n extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModelPluginModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModelPluginModel {\n const isPrivate = input.isPrivate ?? false;\n\n const singularApiName = input.singularApiName\n ? createApiName(input.singularApiName)\n : createApiName(input.name);\n\n const pluralApiName = input.pluralApiName\n ? createApiName(input.pluralApiName)\n : createPluralApiName(input.name);\n\n const modelPlugin: CmsModelPluginModel = {\n group: {\n id: \"\",\n name: \"\"\n },\n description: \"\",\n fields: [],\n isPlugin: true,\n isPrivate,\n layout: [],\n modelId: input.modelId,\n name: input.name,\n pluralApiName,\n singularApiName,\n titleFieldId: \"id\"\n };\n\n if (input.noValidate) {\n /**\n * We can safely ignore this error, because we are sure noValidate is not a model field.\n */\n delete input[\"noValidate\"];\n\n return {\n ...modelPlugin,\n ...input,\n // Since `noValidate` is set, we trust the input, and cast to `CmsModelFieldBase`.\n fields: input.fields as CmsModelFieldBase[],\n pluralApiName,\n singularApiName\n };\n }\n\n const model: CmsModelPluginModel = {\n ...modelPlugin,\n ...input,\n pluralApiName,\n singularApiName,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId)) {\n throw new WebinyError(\n `Field's \"fieldId\" (id: ${input.id}) is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId;\n if (storageId) {\n try {\n validateStorageId(storageId);\n } catch (e) {\n throw WebinyError.from(e, {\n data: { model, storageId, field: input }\n });\n }\n } else {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId)) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-expect-error\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModelPluginModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\n/**\n * @deprecated Use `createCmsModelPlugin` instead.\n */\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\nexport const createCmsModelPlugin = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n\nexport const createPrivateModel = (\n input: Omit<CmsPrivateModelFull, \"group\" | \"isPrivate\">\n): CmsPrivateModelFull => {\n return {\n authorization: false,\n noValidate: true,\n isPrivate: true,\n group: {\n id: \"private\",\n name: \"Private Models\"\n },\n ...input\n };\n};\n"],"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msContext } from "../types";
|
|
|
3
3
|
/**
|
|
4
4
|
* Type can be null because it might be that Headless CMS context is loaded on a different Lambda where there is no GraphQL Schema generated.
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
7
|
-
export
|
|
6
|
+
export type CmsParametersPluginResponseType = ApiEndpoint | null;
|
|
7
|
+
export type CmsParametersPluginResponseLocale = string;
|
|
8
8
|
export interface CmsParametersPluginResponse {
|
|
9
9
|
type: CmsParametersPluginResponseType;
|
|
10
10
|
locale: CmsParametersPluginResponseLocale;
|
package/types/context.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export interface CmsEntryContext {
|
|
|
16
16
|
/**
|
|
17
17
|
* Get a single content entry for a model.
|
|
18
18
|
*/
|
|
19
|
-
getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry
|
|
19
|
+
getEntry: <T = CmsEntryValues>(model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry<T>>;
|
|
20
20
|
/**
|
|
21
21
|
* Get a list of entries for a model by a given ID (revision).
|
|
22
22
|
*/
|
|
@@ -28,19 +28,19 @@ export interface CmsEntryContext {
|
|
|
28
28
|
/**
|
|
29
29
|
* List entries for a model. Internal method used by get, listLatest and listPublished.
|
|
30
30
|
*/
|
|
31
|
-
listEntries: <T = CmsEntryValues>(model: CmsModel, params: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
31
|
+
listEntries: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
32
32
|
/**
|
|
33
33
|
* Lists the latest entries. Used for manage API.
|
|
34
34
|
*/
|
|
35
|
-
listLatestEntries: <T = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
35
|
+
listLatestEntries: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
36
36
|
/**
|
|
37
37
|
* List published entries. Used for read API.
|
|
38
38
|
*/
|
|
39
|
-
listPublishedEntries: <T = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
39
|
+
listPublishedEntries: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
40
40
|
/**
|
|
41
41
|
* Lists the deleted entries. Used for manage API.
|
|
42
42
|
*/
|
|
43
|
-
listDeletedEntries: <T = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
43
|
+
listDeletedEntries: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, params?: CmsEntryListParams) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;
|
|
44
44
|
/**
|
|
45
45
|
* List published entries by IDs.
|
|
46
46
|
*/
|
|
@@ -52,7 +52,7 @@ export interface CmsEntryContext {
|
|
|
52
52
|
/**
|
|
53
53
|
* Create a new content entry.
|
|
54
54
|
*/
|
|
55
|
-
createEntry: (model: CmsModel, input: CreateCmsEntryInput
|
|
55
|
+
createEntry: <T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, input: CreateCmsEntryInput<T>, options?: CreateCmsEntryOptionsInput) => Promise<CmsEntry<T>>;
|
|
56
56
|
/**
|
|
57
57
|
* Create a new entry from already existing entry.
|
|
58
58
|
*/
|
|
@@ -60,7 +60,7 @@ export interface CmsEntryContext {
|
|
|
60
60
|
/**
|
|
61
61
|
* Update existing entry.
|
|
62
62
|
*/
|
|
63
|
-
updateEntry: (model: CmsModel, id: string, input: UpdateCmsEntryInput
|
|
63
|
+
updateEntry: <TInput = CmsEntryValues>(model: CmsModel, id: string, input: UpdateCmsEntryInput<TInput>, meta?: Record<string, any>, options?: UpdateCmsEntryOptionsInput) => Promise<CmsEntry>;
|
|
64
64
|
/**
|
|
65
65
|
* Validate the entry - either new one or existing one.
|
|
66
66
|
*/
|
package/types/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["context.ts"],"sourcesContent":["import { ContentEntryTraverser } from \"~/utils/contentEntryTraverser/ContentEntryTraverser\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport {\n CmsDeleteEntryOptions,\n CmsEntry,\n CmsEntryGetParams,\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryUniqueValue,\n CmsEntryValidateResponse,\n CmsEntryValues,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput,\n CreateFromCmsEntryInput,\n CreateRevisionCmsEntryOptionsInput,\n DeleteMultipleEntriesParams,\n DeleteMultipleEntriesResponse,\n EntryBeforeListTopicParams,\n GetUniqueFieldValuesParams,\n OnEntryAfterCreateTopicParams,\n OnEntryAfterDeleteTopicParams,\n OnEntryAfterMoveTopicParams,\n OnEntryAfterPublishTopicParams,\n OnEntryAfterRepublishTopicParams,\n OnEntryAfterRestoreFromBinTopicParams,\n OnEntryAfterUnpublishTopicParams,\n OnEntryAfterUpdateTopicParams,\n OnEntryBeforeCreateTopicParams,\n OnEntryBeforeDeleteTopicParams,\n OnEntryBeforeGetTopicParams,\n OnEntryBeforeMoveTopicParams,\n OnEntryBeforePublishTopicParams,\n OnEntryBeforeRepublishTopicParams,\n OnEntryBeforeRestoreFromBinTopicParams,\n OnEntryBeforeUnpublishTopicParams,\n OnEntryBeforeUpdateTopicParams,\n OnEntryCreateErrorTopicParams,\n OnEntryCreateRevisionErrorTopicParams,\n OnEntryDeleteErrorTopicParams,\n OnEntryMoveErrorTopicParams,\n OnEntryPublishErrorTopicParams,\n OnEntryRepublishErrorTopicParams,\n OnEntryRestoreFromBinErrorTopicParams,\n OnEntryRevisionAfterCreateTopicParams,\n OnEntryRevisionAfterDeleteTopicParams,\n OnEntryRevisionBeforeCreateTopicParams,\n OnEntryRevisionBeforeDeleteTopicParams,\n OnEntryRevisionDeleteErrorTopicParams,\n OnEntryUnpublishErrorTopicParams,\n OnEntryUpdateErrorTopicParams,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"./types\";\nimport { CmsModel } from \"./model\";\n\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get content entry traverser.\n */\n getEntryTraverser: (modelId: string) => Promise<ContentEntryTraverser>;\n /**\n * Get a single content entry for a model.\n */\n getEntry: (model: CmsModel
|
|
1
|
+
{"version":3,"names":[],"sources":["context.ts"],"sourcesContent":["import { ContentEntryTraverser } from \"~/utils/contentEntryTraverser/ContentEntryTraverser\";\nimport { Topic } from \"@webiny/pubsub/types\";\nimport {\n CmsDeleteEntryOptions,\n CmsEntry,\n CmsEntryGetParams,\n CmsEntryListParams,\n CmsEntryMeta,\n CmsEntryUniqueValue,\n CmsEntryValidateResponse,\n CmsEntryValues,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput,\n CreateFromCmsEntryInput,\n CreateRevisionCmsEntryOptionsInput,\n DeleteMultipleEntriesParams,\n DeleteMultipleEntriesResponse,\n EntryBeforeListTopicParams,\n GetUniqueFieldValuesParams,\n OnEntryAfterCreateTopicParams,\n OnEntryAfterDeleteTopicParams,\n OnEntryAfterMoveTopicParams,\n OnEntryAfterPublishTopicParams,\n OnEntryAfterRepublishTopicParams,\n OnEntryAfterRestoreFromBinTopicParams,\n OnEntryAfterUnpublishTopicParams,\n OnEntryAfterUpdateTopicParams,\n OnEntryBeforeCreateTopicParams,\n OnEntryBeforeDeleteTopicParams,\n OnEntryBeforeGetTopicParams,\n OnEntryBeforeMoveTopicParams,\n OnEntryBeforePublishTopicParams,\n OnEntryBeforeRepublishTopicParams,\n OnEntryBeforeRestoreFromBinTopicParams,\n OnEntryBeforeUnpublishTopicParams,\n OnEntryBeforeUpdateTopicParams,\n OnEntryCreateErrorTopicParams,\n OnEntryCreateRevisionErrorTopicParams,\n OnEntryDeleteErrorTopicParams,\n OnEntryMoveErrorTopicParams,\n OnEntryPublishErrorTopicParams,\n OnEntryRepublishErrorTopicParams,\n OnEntryRestoreFromBinErrorTopicParams,\n OnEntryRevisionAfterCreateTopicParams,\n OnEntryRevisionAfterDeleteTopicParams,\n OnEntryRevisionBeforeCreateTopicParams,\n OnEntryRevisionBeforeDeleteTopicParams,\n OnEntryRevisionDeleteErrorTopicParams,\n OnEntryUnpublishErrorTopicParams,\n OnEntryUpdateErrorTopicParams,\n UpdateCmsEntryInput,\n UpdateCmsEntryOptionsInput\n} from \"./types\";\nimport { CmsModel } from \"./model\";\n\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get content entry traverser.\n */\n getEntryTraverser: (modelId: string) => Promise<ContentEntryTraverser>;\n /**\n * Get a single content entry for a model.\n */\n getEntry: <T = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryGetParams\n ) => Promise<CmsEntry<T>>;\n /**\n * Get a list of entries for a model by a given ID (revision).\n */\n getEntriesByIds: (model: CmsModel, revisions: string[]) => Promise<CmsEntry[]>;\n /**\n * Get the entry for a model by a given ID.\n */\n getEntryById: (model: CmsModel, revision: string) => Promise<CmsEntry>;\n /**\n * List entries for a model. Internal method used by get, listLatest and listPublished.\n */\n listEntries: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * Lists the latest entries. Used for manage API.\n */\n listLatestEntries: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries. Used for read API.\n */\n listPublishedEntries: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * Lists the deleted entries. Used for manage API.\n */\n listDeletedEntries: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry<T>[], CmsEntryMeta]>;\n /**\n * List published entries by IDs.\n */\n getPublishedEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * List latest entries by IDs.\n */\n getLatestEntriesByIds: (model: CmsModel, ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Create a new content entry.\n */\n createEntry: <T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ) => Promise<CmsEntry<T>>;\n /**\n * Create a new entry from already existing entry.\n */\n createEntryRevisionFrom: (\n model: CmsModel,\n id: string,\n input: CreateFromCmsEntryInput,\n options?: CreateRevisionCmsEntryOptionsInput\n ) => Promise<CmsEntry>;\n /**\n * Update existing entry.\n */\n updateEntry: <TInput = CmsEntryValues>(\n model: CmsModel,\n id: string,\n input: UpdateCmsEntryInput<TInput>,\n meta?: Record<string, any>,\n options?: UpdateCmsEntryOptionsInput\n ) => Promise<CmsEntry>;\n /**\n * Validate the entry - either new one or existing one.\n */\n validateEntry: (\n model: CmsModel,\n id?: string,\n input?: UpdateCmsEntryInput\n ) => Promise<CmsEntryValidateResponse>;\n /**\n * Move entry, and all its revisions, to a new folder.\n */\n moveEntry: (model: CmsModel, id: string, folderId: string) => Promise<CmsEntry>;\n /**\n * Method that republishes entry with given identifier.\n * @internal\n */\n republishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Delete only a certain revision of the entry.\n */\n deleteEntryRevision: (model: CmsModel, id: string) => Promise<void>;\n /**\n * Delete entry with all its revisions.\n */\n deleteEntry: (model: CmsModel, id: string, options?: CmsDeleteEntryOptions) => Promise<void>;\n /**\n * Restore entry from trash bin with all its revisions.\n */\n restoreEntryFromBin: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Delete multiple entries\n */\n deleteMultipleEntries: (\n model: CmsModel,\n params: DeleteMultipleEntriesParams\n ) => Promise<DeleteMultipleEntriesResponse>;\n /**\n * Publish entry.\n */\n publishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Unpublish entry.\n */\n unpublishEntry: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Get all entry revisions.\n */\n getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;\n /**\n * List all unique values for a given field.\n *\n * @internal\n */\n getUniqueFieldValues: (\n model: CmsModel,\n params: GetUniqueFieldValuesParams\n ) => Promise<CmsEntryUniqueValue[]>;\n /**\n * Lifecycle Events\n */\n onEntryBeforeCreate: Topic<OnEntryBeforeCreateTopicParams>;\n onEntryAfterCreate: Topic<OnEntryAfterCreateTopicParams>;\n onEntryCreateError: Topic<OnEntryCreateErrorTopicParams>;\n\n onEntryRevisionBeforeCreate: Topic<OnEntryRevisionBeforeCreateTopicParams>;\n onEntryRevisionAfterCreate: Topic<OnEntryRevisionAfterCreateTopicParams>;\n onEntryRevisionCreateError: Topic<OnEntryCreateRevisionErrorTopicParams>;\n\n onEntryBeforeUpdate: Topic<OnEntryBeforeUpdateTopicParams>;\n onEntryAfterUpdate: Topic<OnEntryAfterUpdateTopicParams>;\n onEntryUpdateError: Topic<OnEntryUpdateErrorTopicParams>;\n\n onEntryBeforeMove: Topic<OnEntryBeforeMoveTopicParams>;\n onEntryAfterMove: Topic<OnEntryAfterMoveTopicParams>;\n onEntryMoveError: Topic<OnEntryMoveErrorTopicParams>;\n\n onEntryBeforeDelete: Topic<OnEntryBeforeDeleteTopicParams>;\n onEntryAfterDelete: Topic<OnEntryAfterDeleteTopicParams>;\n onEntryDeleteError: Topic<OnEntryDeleteErrorTopicParams>;\n\n onEntryBeforeRestoreFromBin: Topic<OnEntryBeforeRestoreFromBinTopicParams>;\n onEntryAfterRestoreFromBin: Topic<OnEntryAfterRestoreFromBinTopicParams>;\n onEntryRestoreFromBinError: Topic<OnEntryRestoreFromBinErrorTopicParams>;\n\n onEntryRevisionBeforeDelete: Topic<OnEntryRevisionBeforeDeleteTopicParams>;\n onEntryRevisionAfterDelete: Topic<OnEntryRevisionAfterDeleteTopicParams>;\n onEntryRevisionDeleteError: Topic<OnEntryRevisionDeleteErrorTopicParams>;\n\n onEntryBeforePublish: Topic<OnEntryBeforePublishTopicParams>;\n onEntryAfterPublish: Topic<OnEntryAfterPublishTopicParams>;\n onEntryPublishError: Topic<OnEntryPublishErrorTopicParams>;\n\n onEntryBeforeRepublish: Topic<OnEntryBeforeRepublishTopicParams>;\n onEntryAfterRepublish: Topic<OnEntryAfterRepublishTopicParams>;\n onEntryRepublishError: Topic<OnEntryRepublishErrorTopicParams>;\n\n onEntryBeforeUnpublish: Topic<OnEntryBeforeUnpublishTopicParams>;\n onEntryAfterUnpublish: Topic<OnEntryAfterUnpublishTopicParams>;\n onEntryUnpublishError: Topic<OnEntryUnpublishErrorTopicParams>;\n\n onEntryBeforeGet: Topic<OnEntryBeforeGetTopicParams>;\n onEntryBeforeList: Topic<EntryBeforeListTopicParams>;\n}\n"],"mappings":"","ignoreList":[]}
|
package/types/modelAst.d.ts
CHANGED
|
@@ -5,23 +5,23 @@ import { CmsModelField } from "./modelField";
|
|
|
5
5
|
export interface ICmsModelFieldToAst {
|
|
6
6
|
toAst(field: CmsModelField): CmsModelFieldAstNode;
|
|
7
7
|
}
|
|
8
|
-
export
|
|
8
|
+
export type CmsModelAst = {
|
|
9
9
|
type: "root";
|
|
10
10
|
children: CmsModelFieldAstNode[];
|
|
11
11
|
};
|
|
12
|
-
export
|
|
12
|
+
export type CmsModelFieldAstNodeCollection = {
|
|
13
13
|
type: "collection";
|
|
14
14
|
collection: {
|
|
15
15
|
discriminator: string;
|
|
16
16
|
} & Record<string, any>;
|
|
17
17
|
children: CmsModelFieldAstNode[];
|
|
18
18
|
};
|
|
19
|
-
export
|
|
19
|
+
export type CmsModelFieldAstNodeField = {
|
|
20
20
|
type: "field";
|
|
21
21
|
field: CmsModelField;
|
|
22
22
|
children: CmsModelFieldAstNode[];
|
|
23
23
|
};
|
|
24
|
-
export
|
|
24
|
+
export type CmsModelFieldAstNode = CmsModelFieldAstNodeCollection | CmsModelFieldAstNodeField;
|
|
25
25
|
export interface GetCmsModelFieldAst<TField> {
|
|
26
26
|
(field: TField, converter: ICmsModelFieldToAst): CmsModelFieldAstNode;
|
|
27
27
|
}
|
package/types/modelField.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CmsModel } from "./model";
|
|
2
2
|
import { GenericRecord } from "@webiny/api/types";
|
|
3
|
-
export
|
|
3
|
+
export type CmsModelFieldType = "boolean" | "datetime" | "file" | "long-text" | "number" | "json" | "object" | "ref" | "rich-text" | "text" | "dynamicZone" | string;
|
|
4
|
+
export type ICmsModelFieldStorageId = `${string}@${string}` | string;
|
|
4
5
|
/**
|
|
5
6
|
* A definition for content model field. This type exists on the app side as well.
|
|
6
7
|
*
|
|
@@ -30,7 +31,7 @@ export interface CmsModelField {
|
|
|
30
31
|
*
|
|
31
32
|
* This is used as path for the entry value.
|
|
32
33
|
*/
|
|
33
|
-
storageId:
|
|
34
|
+
storageId: ICmsModelFieldStorageId;
|
|
34
35
|
/**
|
|
35
36
|
* Field identifier for the model field that will be available to the outside world.
|
|
36
37
|
* `storageId` is used as path (or column) to store the data.
|
package/types/modelField.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import { CmsModel } from \"./model\";\nimport { GenericRecord } from \"@webiny/api/types\";\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId:
|
|
1
|
+
{"version":3,"names":[],"sources":["modelField.ts"],"sourcesContent":["import { CmsModel } from \"./model\";\nimport { GenericRecord } from \"@webiny/api/types\";\n\nexport type CmsModelFieldType =\n | \"boolean\"\n | \"datetime\"\n | \"file\"\n | \"long-text\"\n | \"number\"\n | \"json\"\n | \"object\"\n | \"ref\"\n | \"rich-text\"\n | \"text\"\n | \"dynamicZone\"\n | string;\n\nexport type ICmsModelFieldStorageId = `${string}@${string}` | string;\n/**\n * A definition for content model field. This type exists on the app side as well.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelField {\n /**\n * A generated unique ID for the model field.\n * MUST be absolute unique throughout the models.\n * Must be in form of a-zA-Z0-9.\n *\n * We generate a unique id value when you're building a model via UI,\n * but when user is creating a model via a plugin it is up to them to be careful about this.\n */\n id: string;\n /**\n * A type of the field.\n * We are defining our built-in fields, so people know which are available by the default.\n */\n type: CmsModelFieldType;\n /**\n * A unique storage ID for storing actual values.\n * Must in form of a-zA-Z0-9@a-zA-Z0-9\n *\n * This is an auto-generated value: uses `id` and `type`\n *\n * This is used as path for the entry value.\n */\n storageId: ICmsModelFieldStorageId;\n /**\n * Field identifier for the model field that will be available to the outside world.\n * `storageId` is used as path (or column) to store the data.\n *\n * Must in form of a-zA-Z0-9.\n *\n * This value MUST be unique in the CmsModel.\n */\n fieldId: string;\n /**\n * A label for the field\n */\n label: string;\n /**\n * Text below the field to clarify what is it meant to be in the field value\n */\n helpText?: string | null;\n /**\n * Text to be displayed in the field\n */\n placeholderText?: string | null;\n /**\n * Are predefined values enabled? And list of them\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Field renderer. Blank if determined automatically.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field\n *\n * @default []\n */\n validation?: CmsModelFieldValidation[];\n /**\n * List of validations for the list of values, when a field is set to accept a list of values.\n * These validations will be applied to the entire list, and `validation` (see above) will be applied\n * to each individual value in the list.\n *\n * @default []\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * Is this a multiple values field?\n *\n */\n multipleValues?: boolean;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Any user defined settings.\n *\n * @default {}\n */\n settings?: CmsModelFieldSettings;\n}\n\n/**\n * A definition for content model field received from the user.\n *\n * Input type for `CmsModelField`.\n * @see CmsModelField\n *\n * @category GraphQL params\n * @category ModelField\n */\nexport interface CmsModelFieldInput {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Type of the field. A plugin for the field must be defined.\n * @see CmsModelFieldToGraphQLPlugin\n */\n type: string;\n /**\n * Field outside world identifier for the field. Must be unique in the model.\n */\n fieldId: string;\n /**\n * Label for the field.\n */\n label: string;\n /**\n * Text to display below the field to help user what to write in the field.\n */\n helpText?: string | null;\n /**\n * Text to display in the field.\n */\n placeholderText?: string | null;\n /**\n * Fields can be tagged to give them contextual meaning.\n */\n tags?: string[];\n /**\n * Are multiple values allowed?\n */\n multipleValues?: boolean;\n /**\n * Predefined values options for the field. Check the reference for more information.\n */\n predefinedValues?: CmsModelFieldPredefinedValues;\n /**\n * Renderer options for the field. Check the reference for more information.\n */\n renderer?: CmsModelFieldRenderer | null;\n /**\n * List of validations for the field.\n */\n validation?: CmsModelFieldValidation[];\n /**\n * @see CmsModelField.listValidation\n */\n listValidation?: CmsModelFieldValidation[];\n /**\n * User defined settings.\n */\n settings?: Record<string, any>;\n}\n\n/**\n * A GraphQL `params.data` parameter received when updating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelUpdateInput {\n /**\n * A new content model name.\n */\n name?: string;\n /**\n * A new singular name of the content model to be used in the API.\n */\n singularApiName?: string;\n /**\n * A new plural name of the content model to be used in the API.\n */\n pluralApiName?: string;\n /**\n * A group we want to move the model to.\n */\n group?: string;\n /**\n * A new description of the content model.\n */\n description?: string | null;\n /**\n * A list of content model fields to define the entry values.\n */\n fields: CmsModelFieldInput[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * Fields fieldId which are picked to represent the CMS entry.\n */\n titleFieldId?: string | null;\n descriptionFieldId?: string | null;\n imageFieldId?: string | null;\n}\n\n/**\n * Locked field in the content model\n *\n * @see CmsModel.lockedFields\n *\n * @category ModelField\n */\nexport interface LockedField {\n /**\n * Locked field storage ID - one used to store values.\n * We cannot change this due to old systems.\n */\n fieldId: string;\n /**\n * Is the field multiple values field?\n */\n multipleValues: boolean;\n /**\n * Field type.\n */\n type: string;\n\n [key: string]: any;\n}\n\n/**\n * Object containing content model field renderer options.\n *\n * @category CmsModelField\n */\ninterface CmsModelFieldRenderer {\n /**\n * Name of the field renderer. Must have one in field renderer plugins.\n * Can be blank to let automatically determine the renderer.\n */\n name: string;\n /**\n * Renderer settings allow you to configure field renderer on a field level.\n */\n settings?: GenericRecord<string> | null;\n}\n\n/**\n * A definition for content model field settings.\n *\n * @category ModelField\n * @category Database model\n */\nexport interface CmsModelFieldSettings {\n /**\n * Predefined values (text, number)\n * The default value for the field in case it is not predefined values field.\n */\n defaultValue?: string | boolean | number | null | undefined;\n /**\n * Object field has child fields.\n */\n fields?: CmsModelField[];\n /**\n * Is the file field images only one?\n */\n imagesOnly?: boolean;\n /**\n * Object field has child fields - so it needs to have a layout.\n */\n layout?: string[][];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\n /**\n * Disable full text search explicitly on this field.\n */\n disableFullTextSearch?: boolean;\n\n /**\n * There are a lot of other settings that are possible to add, so we keep the type opened.\n */\n [key: string]: any;\n}\n\n/**\n * Definition for content model field validator.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidation {\n name: string;\n message: string;\n settings?: {\n value?: string | number;\n values?: string[];\n preset?: string;\n [key: string]: any;\n };\n}\n\n/**\n * Object containing content model field predefined options and values.\n *\n * @category CmsModelField\n */\nexport interface CmsModelFieldPredefinedValues {\n /**\n * Are predefined field values enabled?\n */\n enabled: boolean;\n /**\n * Predefined values array.\n */\n values: CmsModelFieldPredefinedValuesValue[];\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
|