@webiny/api-headless-cms 5.25.0-beta.2 → 5.25.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/graphQLHandlerFactory.js +11 -2
- package/content/graphQLHandlerFactory.js.map +1 -1
- package/content/plugins/crud/contentModel/afterCreateFrom.d.ts +8 -0
- package/content/plugins/crud/contentModel/afterCreateFrom.js +18 -0
- package/content/plugins/crud/contentModel/afterCreateFrom.js.map +1 -0
- package/content/plugins/crud/contentModel.crud.js +6 -0
- package/content/plugins/crud/contentModel.crud.js.map +1 -1
- package/content/plugins/schema/baseSchema.js +5 -0
- package/content/plugins/schema/baseSchema.js.map +1 -1
- package/content/plugins/schema/contentEntries.js +294 -75
- package/content/plugins/schema/contentEntries.js.map +1 -1
- package/content/plugins/schema/createManageSDL.js +1 -1
- package/content/plugins/schema/createManageSDL.js.map +1 -1
- package/content/plugins/schema/resolvers/manage/resolveGet.js +63 -1
- package/content/plugins/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.js +46 -2
- package/index.js.map +1 -1
- package/package.json +23 -23
- package/types.d.ts +13 -4
- package/types.js.map +1 -1
|
@@ -1,17 +1,79 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.resolveGet = void 0;
|
|
7
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
8
14
|
var _responses = require("@webiny/handler-graphql/responses");
|
|
9
15
|
|
|
16
|
+
var _utils = require("@webiny/utils");
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
22
|
+
const possibleTypes = ["published", "latest"];
|
|
23
|
+
|
|
24
|
+
const getValuesFromArgs = args => {
|
|
25
|
+
const {
|
|
26
|
+
status,
|
|
27
|
+
revision,
|
|
28
|
+
entryId
|
|
29
|
+
} = args || {};
|
|
30
|
+
|
|
31
|
+
if (!revision && !entryId) {
|
|
32
|
+
throw new _error.default("You must pass a 'revision' or an 'entryId' argument.", "GRAPHQL_ARGS_ERROR", _objectSpread({}, args || {}));
|
|
33
|
+
} else if (revision && entryId) {
|
|
34
|
+
throw new _error.default("Cannot have both of GraphQL query arguments: revision and entryId. Must have only one.", "GRAPHQL_ARGS_ERROR", _objectSpread({}, args));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (status && possibleTypes.includes(status) === false) {
|
|
38
|
+
throw new _error.default(`Status can only be one of the following values: ${possibleTypes.join(" | ")}.`, "GRAPHQL_ARGS_ERROR", _objectSpread({}, args));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* In case we are searching for latest or published but we do not have entryId, we need to set it.
|
|
42
|
+
* OR if version was not passed we will find latest or published, depending on status sent.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if (status || !revision) {
|
|
47
|
+
const {
|
|
48
|
+
id
|
|
49
|
+
} = (0, _utils.parseIdentifier)(entryId || revision);
|
|
50
|
+
return {
|
|
51
|
+
published: status === "published",
|
|
52
|
+
entryId: id
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
revision
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
10
61
|
const resolveGet = ({
|
|
11
62
|
model
|
|
12
63
|
}) => async (_, args, context) => {
|
|
13
64
|
try {
|
|
14
|
-
const
|
|
65
|
+
const {
|
|
66
|
+
entryId,
|
|
67
|
+
published,
|
|
68
|
+
revision
|
|
69
|
+
} = getValuesFromArgs(args);
|
|
70
|
+
|
|
71
|
+
if (entryId) {
|
|
72
|
+
const result = published ? await context.cms.getPublishedEntriesByIds(model, [entryId]) : await context.cms.getLatestEntriesByIds(model, [entryId]);
|
|
73
|
+
return new _responses.Response(result.shift() || null);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const entry = await context.cms.getEntryById(model, revision);
|
|
15
77
|
return new _responses.Response(entry);
|
|
16
78
|
} catch (e) {
|
|
17
79
|
return new _responses.ErrorResponse(e);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["resolveGet.ts"],"names":["resolveGet","model","_","
|
|
1
|
+
{"version":3,"sources":["resolveGet.ts"],"names":["possibleTypes","getValuesFromArgs","args","status","revision","entryId","WebinyError","includes","join","id","published","resolveGet","model","_","context","result","cms","getPublishedEntriesByIds","getLatestEntriesByIds","Response","shift","entry","getEntryById","e","ErrorResponse"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA;;;;;;AAmBA,MAAMA,aAAa,GAAG,CAAC,WAAD,EAAc,QAAd,CAAtB;;AAEA,MAAMC,iBAAiB,GAAIC,IAAD,IAA6C;AACnE,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,QAAV;AAAoBC,IAAAA;AAApB,MAAgCH,IAAI,IAAI,EAA9C;;AACA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AAD,CAAzC,CAFZ;AAGA,aAAO,IAAIc,mBAAJ,CAAaJ,MAAM,CAACK,KAAP,MAAkB,IAA/B,CAAP;AACH;;AAED,UAAMC,KAAK,GAAG,MAAMP,OAAO,CAACE,GAAR,CAAYM,YAAZ,CAAyBV,KAAzB,EAAgCR,QAAhC,CAApB;AAEA,WAAO,IAAIe,mBAAJ,CAAaE,KAAb,CAAP;AACH,GAbD,CAaE,OAAOE,CAAP,EAAU;AACR,WAAO,IAAIC,wBAAJ,CAAkBD,CAAlB,CAAP;AACH;AACJ,CAnBE","sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql/responses\";\nimport { CmsEntryResolverFactory as ResolverFactory } from \"~/types\";\nimport { parseIdentifier } from \"@webiny/utils\";\n\ninterface ResolveGetArgs {\n revision: string;\n}\n\ntype ResolveGet = ResolverFactory<any, ResolveGetArgs>;\n\ninterface ValuesFromArgsParams {\n status?: \"published\" | \"latest\";\n entryId?: string;\n revision: string;\n}\ninterface ArgsValues {\n published?: boolean;\n entryId?: string;\n revision?: string;\n}\n\nconst possibleTypes = [\"published\", \"latest\"];\n\nconst getValuesFromArgs = (args?: ValuesFromArgsParams): ArgsValues => {\n const { status, revision, entryId } = args || {};\n if (!revision && !entryId) {\n throw new WebinyError(\n \"You must pass a 'revision' or an 'entryId' argument.\",\n \"GRAPHQL_ARGS_ERROR\",\n {\n ...(args || {})\n }\n );\n } else if (revision && entryId) {\n throw new WebinyError(\n \"Cannot have both of GraphQL query arguments: revision and entryId. Must have only one.\",\n \"GRAPHQL_ARGS_ERROR\",\n {\n ...args\n }\n );\n }\n if (status && possibleTypes.includes(status) === false) {\n throw new WebinyError(\n `Status can only be one of the following values: ${possibleTypes.join(\" | \")}.`,\n \"GRAPHQL_ARGS_ERROR\",\n {\n ...args\n }\n );\n }\n /**\n * In case we are searching for latest or published but we do not have entryId, we need to set it.\n * OR if version was not passed we will find latest or published, depending on status sent.\n */\n if (status || !revision) {\n const { id } = parseIdentifier(entryId || revision);\n return {\n published: status === \"published\",\n entryId: id\n };\n }\n return {\n revision\n };\n};\n\nexport const resolveGet: ResolveGet =\n ({ model }) =>\n async (_, args: any, context) => {\n try {\n const { entryId, published, revision } = getValuesFromArgs(args);\n\n if (entryId) {\n const result = published\n ? await context.cms.getPublishedEntriesByIds(model, [entryId])\n : await context.cms.getLatestEntriesByIds(model, [entryId]);\n return new Response(result.shift() || null);\n }\n\n const entry = await context.cms.getEntryById(model, revision as string);\n\n return new Response(entry);\n } catch (e) {\n return new ErrorResponse(e);\n }\n };\n"]}
|
package/index.d.ts
CHANGED
|
@@ -6,12 +6,14 @@ import { CreateParametersPluginsParams } from "./content/parameterPlugins";
|
|
|
6
6
|
import { CmsParametersPlugin } from "./content/plugins/CmsParametersPlugin";
|
|
7
7
|
import { CmsGroupPlugin } from "./content/plugins/CmsGroupPlugin";
|
|
8
8
|
import { CmsModelPlugin } from "./content/plugins/CmsModelPlugin";
|
|
9
|
+
import { ContextPlugin } from "@webiny/handler";
|
|
10
|
+
import { CmsContext } from "./types";
|
|
9
11
|
export declare type AdminContextParams = CreateAdminCrudsParams;
|
|
10
|
-
export declare const createAdminHeadlessCmsContext: (params: AdminContextParams) => (
|
|
12
|
+
export declare const createAdminHeadlessCmsContext: (params: AdminContextParams) => (ContextPlugin<CmsContext> | import("@webiny/api-upgrade").UpgradePlugin<CmsContext>[])[];
|
|
11
13
|
export declare const createAdminHeadlessCmsGraphQL: () => import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("@webiny/handler/types").Context>;
|
|
12
14
|
export interface ContentContextParams extends CreateContentCrudsParams, CreateParametersPluginsParams {
|
|
13
15
|
}
|
|
14
|
-
export declare const createContentHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("./types").CmsModelFieldToGraphQLPlugin[] | StorageTransformPlugin<any, any> |
|
|
16
|
+
export declare const createContentHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("./types").CmsModelFieldToGraphQLPlugin[] | StorageTransformPlugin<any, any> | ContextPlugin<CmsContext> | CmsParametersPlugin[] | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[])[];
|
|
15
17
|
export declare type ContentGraphQLParams = CreateGraphQLHandlerOptions;
|
|
16
18
|
export declare const createContentHeadlessCmsGraphQL: (params?: CreateGraphQLHandlerOptions | undefined) => import("@webiny/plugins/types").PluginCollection;
|
|
17
19
|
export { StorageTransformPlugin, CmsParametersPlugin, CmsGroupPlugin, CmsModelPlugin };
|
package/index.js
CHANGED
|
@@ -31,6 +31,8 @@ Object.defineProperty(exports, "StorageTransformPlugin", {
|
|
|
31
31
|
});
|
|
32
32
|
exports.createContentHeadlessCmsGraphQL = exports.createContentHeadlessCmsContext = exports.createAdminHeadlessCmsGraphQL = exports.createAdminHeadlessCmsContext = void 0;
|
|
33
33
|
|
|
34
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
35
|
+
|
|
34
36
|
var _graphql = require("./plugins/graphql");
|
|
35
37
|
|
|
36
38
|
var _crud = require("./plugins/crud");
|
|
@@ -65,8 +67,50 @@ var _CmsGroupPlugin = require("./content/plugins/CmsGroupPlugin");
|
|
|
65
67
|
|
|
66
68
|
var _CmsModelPlugin = require("./content/plugins/CmsModelPlugin");
|
|
67
69
|
|
|
70
|
+
var _handler = require("@webiny/handler");
|
|
71
|
+
|
|
72
|
+
var _utils = require("@webiny/utils");
|
|
73
|
+
|
|
74
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
75
|
+
|
|
76
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
77
|
+
|
|
78
|
+
const DEFAULT_HEADERS = _objectSpread({
|
|
79
|
+
"Access-Control-Allow-Origin": "*",
|
|
80
|
+
"Access-Control-Allow-Headers": "*",
|
|
81
|
+
"Access-Control-Allow-Methods": "OPTIONS,POST",
|
|
82
|
+
"Content-Type": "application/json"
|
|
83
|
+
}, (0, _utils.getWebinyVersionHeaders)());
|
|
84
|
+
|
|
85
|
+
const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
|
|
86
|
+
|
|
87
|
+
const OPTIONS_HEADERS = {
|
|
88
|
+
"Access-Control-Max-Age": `${DEFAULT_CACHE_MAX_AGE}`,
|
|
89
|
+
"Cache-Control": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const breakOptionsRequestContextPlugin = () => {
|
|
93
|
+
const plugin = new _handler.ContextPlugin(async context => {
|
|
94
|
+
var _context$http, _context$http$request;
|
|
95
|
+
|
|
96
|
+
const method = (((_context$http = context.http) === null || _context$http === void 0 ? void 0 : (_context$http$request = _context$http.request) === null || _context$http$request === void 0 ? void 0 : _context$http$request.method) || "").toLowerCase();
|
|
97
|
+
|
|
98
|
+
if (method !== "options") {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
context.setResult({
|
|
103
|
+
statusCode: 204,
|
|
104
|
+
body: "",
|
|
105
|
+
headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), OPTIONS_HEADERS)
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
plugin.name = "break-options-request";
|
|
109
|
+
return plugin;
|
|
110
|
+
};
|
|
111
|
+
|
|
68
112
|
const createAdminHeadlessCmsContext = params => {
|
|
69
|
-
return [(0, _context.default)(), (0, _crud.createAdminCruds)(params), (0, _upgrades.default)()];
|
|
113
|
+
return [breakOptionsRequestContextPlugin(), (0, _context.default)(), (0, _crud.createAdminCruds)(params), (0, _upgrades.default)()];
|
|
70
114
|
};
|
|
71
115
|
|
|
72
116
|
exports.createAdminHeadlessCmsContext = createAdminHeadlessCmsContext;
|
|
@@ -78,7 +122,7 @@ const createAdminHeadlessCmsGraphQL = () => {
|
|
|
78
122
|
exports.createAdminHeadlessCmsGraphQL = createAdminHeadlessCmsGraphQL;
|
|
79
123
|
|
|
80
124
|
const createContentHeadlessCmsContext = params => {
|
|
81
|
-
return [(0, _parameterPlugins.createParametersPlugins)(params), (0, _contextSetup.default)(), (0, _modelManager.default)(), (0, _crud2.createContentCruds)(params), (0, _graphqlFields.default)(), (0, _validators.default)(), (0, _default.default)(), (0, _object.default)() // new InternalAuthenticationPlugin("read-api-key"),
|
|
125
|
+
return [breakOptionsRequestContextPlugin(), (0, _parameterPlugins.createParametersPlugins)(params), (0, _contextSetup.default)(), (0, _modelManager.default)(), (0, _crud2.createContentCruds)(params), (0, _graphqlFields.default)(), (0, _validators.default)(), (0, _default.default)(), (0, _object.default)() // new InternalAuthenticationPlugin("read-api-key"),
|
|
82
126
|
// new InternalAuthorizationPlugin("read-api-key")
|
|
83
127
|
];
|
|
84
128
|
};
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":["createAdminHeadlessCmsContext","params","createAdminHeadlessCmsGraphQL","createContentHeadlessCmsContext","createContentHeadlessCmsGraphQL"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["DEFAULT_HEADERS","DEFAULT_CACHE_MAX_AGE","OPTIONS_HEADERS","breakOptionsRequestContextPlugin","plugin","ContextPlugin","context","method","http","request","toLowerCase","setResult","statusCode","body","headers","name","createAdminHeadlessCmsContext","params","createAdminHe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GAAG,MAAM;AAC/C,SAAO,mCAAP;AACH,CAFM;;;;AAOA,MAAMC,+BAA+B,GAAIF,MAAD,IAAkC;AAC7E,SAAO,CACHd,gCAAgC,EAD7B,EAEH,+CAAwBc,MAAxB,CAFG,EAGH,4BAHG,EAIH,4BAJG,EAKH,+BAAmBA,MAAnB,CALG,EAMH,6BANG,EAOH,0BAPG,EAQH,uBARG,EASH,sBATG,CAUH;AACA;AAXG,GAAP;AAaH,CAdM;;;;AAgBA,MAAMG,+BAA+B,GAAIH,MAAD,IAAmC;AAC9E,SAAO,kDAAsBA,MAAtB,CAAP;AACH,CAFM","sourcesContent":["import { createGraphQLPlugin } from \"~/plugins/graphql\";\nimport { createAdminCruds, CreateAdminCrudsParams } from \"~/plugins/crud\";\nimport context from \"~/plugins/context\";\nimport upgrades from \"~/plugins/upgrades\";\nimport contextSetup from \"~/content/contextSetup\";\nimport modelManager from \"~/content/plugins/modelManager\";\nimport { createContentCruds, CreateContentCrudsParams } from \"~/content/plugins/crud\";\nimport fieldTypePlugins from \"~/content/plugins/graphqlFields\";\nimport validatorsPlugins from \"~/content/plugins/validators\";\nimport defaultStoragePlugin from \"~/content/plugins/storage/default\";\nimport objectStoragePlugin from \"~/content/plugins/storage/object\";\nimport {\n CreateGraphQLHandlerOptions,\n graphQLHandlerFactory\n} from \"~/content/graphQLHandlerFactory\";\nimport { StorageTransformPlugin } from \"~/content/plugins/storage/StorageTransformPlugin\";\nimport { createParametersPlugins, CreateParametersPluginsParams } from \"~/content/parameterPlugins\";\nimport { CmsParametersPlugin } from \"~/content/plugins/CmsParametersPlugin\";\nimport { CmsGroupPlugin } from \"~/content/plugins/CmsGroupPlugin\";\nimport { CmsModelPlugin } from \"~/content/plugins/CmsModelPlugin\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { CmsContext } from \"~/types\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\n\nexport type AdminContextParams = CreateAdminCrudsParams;\n\nconst DEFAULT_HEADERS: Record<string, string> = {\n \"Access-Control-Allow-Origin\": \"*\",\n \"Access-Control-Allow-Headers\": \"*\",\n \"Access-Control-Allow-Methods\": \"OPTIONS,POST\",\n \"Content-Type\": \"application/json\",\n ...getWebinyVersionHeaders()\n};\n\nconst DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year\n\nconst OPTIONS_HEADERS: Record<string, string> = {\n \"Access-Control-Max-Age\": `${DEFAULT_CACHE_MAX_AGE}`,\n \"Cache-Control\": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`\n};\n\nconst breakOptionsRequestContextPlugin = (): ContextPlugin<CmsContext> => {\n const plugin = new ContextPlugin<CmsContext>(async context => {\n const method = (context.http?.request?.method || \"\").toLowerCase();\n if (method !== \"options\") {\n return;\n }\n context.setResult({\n statusCode: 204,\n body: \"\",\n headers: {\n ...DEFAULT_HEADERS,\n ...OPTIONS_HEADERS\n }\n });\n });\n plugin.name = \"break-options-request\";\n\n return plugin;\n};\n\nexport const createAdminHeadlessCmsContext = (params: AdminContextParams) => {\n return [breakOptionsRequestContextPlugin(), context(), createAdminCruds(params), upgrades()];\n};\n\nexport const createAdminHeadlessCmsGraphQL = () => {\n return createGraphQLPlugin();\n};\n\nexport interface ContentContextParams\n extends CreateContentCrudsParams,\n CreateParametersPluginsParams {}\nexport const createContentHeadlessCmsContext = (params: ContentContextParams) => {\n return [\n breakOptionsRequestContextPlugin(),\n createParametersPlugins(params),\n contextSetup(),\n modelManager(),\n createContentCruds(params),\n fieldTypePlugins(),\n validatorsPlugins(),\n defaultStoragePlugin(),\n objectStoragePlugin()\n // new InternalAuthenticationPlugin(\"read-api-key\"),\n // new InternalAuthorizationPlugin(\"read-api-key\")\n ];\n};\nexport type ContentGraphQLParams = CreateGraphQLHandlerOptions;\nexport const createContentHeadlessCmsGraphQL = (params?: ContentGraphQLParams) => {\n return graphQLHandlerFactory(params);\n};\n\nexport { StorageTransformPlugin, CmsParametersPlugin, CmsGroupPlugin, CmsModelPlugin };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/api-headless-cms",
|
|
3
|
-
"version": "5.25.0-beta.
|
|
3
|
+
"version": "5.25.0-beta.3",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cms:base"
|
|
@@ -21,23 +21,23 @@
|
|
|
21
21
|
"@babel/runtime": "7.17.7",
|
|
22
22
|
"@commodo/fields": "1.1.2-beta.20",
|
|
23
23
|
"@graphql-tools/schema": "7.1.5",
|
|
24
|
-
"@webiny/api-file-manager": "5.25.0-beta.
|
|
25
|
-
"@webiny/api-i18n": "5.25.0-beta.
|
|
26
|
-
"@webiny/api-i18n-content": "5.25.0-beta.
|
|
27
|
-
"@webiny/api-i18n-ddb": "5.25.0-beta.
|
|
28
|
-
"@webiny/api-security": "5.25.0-beta.
|
|
29
|
-
"@webiny/api-tenancy": "5.25.0-beta.
|
|
30
|
-
"@webiny/api-upgrade": "5.25.0-beta.
|
|
31
|
-
"@webiny/error": "5.25.0-beta.
|
|
32
|
-
"@webiny/handler": "5.25.0-beta.
|
|
33
|
-
"@webiny/handler-aws": "5.25.0-beta.
|
|
34
|
-
"@webiny/handler-db": "5.25.0-beta.
|
|
35
|
-
"@webiny/handler-graphql": "5.25.0-beta.
|
|
36
|
-
"@webiny/handler-http": "5.25.0-beta.
|
|
37
|
-
"@webiny/plugins": "5.25.0-beta.
|
|
38
|
-
"@webiny/pubsub": "5.25.0-beta.
|
|
39
|
-
"@webiny/utils": "5.25.0-beta.
|
|
40
|
-
"@webiny/validation": "5.25.0-beta.
|
|
24
|
+
"@webiny/api-file-manager": "5.25.0-beta.3",
|
|
25
|
+
"@webiny/api-i18n": "5.25.0-beta.3",
|
|
26
|
+
"@webiny/api-i18n-content": "5.25.0-beta.3",
|
|
27
|
+
"@webiny/api-i18n-ddb": "5.25.0-beta.3",
|
|
28
|
+
"@webiny/api-security": "5.25.0-beta.3",
|
|
29
|
+
"@webiny/api-tenancy": "5.25.0-beta.3",
|
|
30
|
+
"@webiny/api-upgrade": "5.25.0-beta.3",
|
|
31
|
+
"@webiny/error": "5.25.0-beta.3",
|
|
32
|
+
"@webiny/handler": "5.25.0-beta.3",
|
|
33
|
+
"@webiny/handler-aws": "5.25.0-beta.3",
|
|
34
|
+
"@webiny/handler-db": "5.25.0-beta.3",
|
|
35
|
+
"@webiny/handler-graphql": "5.25.0-beta.3",
|
|
36
|
+
"@webiny/handler-http": "5.25.0-beta.3",
|
|
37
|
+
"@webiny/plugins": "5.25.0-beta.3",
|
|
38
|
+
"@webiny/pubsub": "5.25.0-beta.3",
|
|
39
|
+
"@webiny/utils": "5.25.0-beta.3",
|
|
40
|
+
"@webiny/validation": "5.25.0-beta.3",
|
|
41
41
|
"boolean": "3.2.0",
|
|
42
42
|
"commodo-fields-object": "1.0.6",
|
|
43
43
|
"dataloader": "2.0.0",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@babel/core": "^7.16.0",
|
|
56
56
|
"@babel/preset-env": "^7.16.4",
|
|
57
57
|
"@babel/preset-flow": "^7.16.0",
|
|
58
|
-
"@webiny/api-security-so-ddb": "^5.25.0-beta.
|
|
59
|
-
"@webiny/api-tenancy-so-ddb": "^5.25.0-beta.
|
|
60
|
-
"@webiny/cli": "^5.25.0-beta.
|
|
61
|
-
"@webiny/project-utils": "^5.25.0-beta.
|
|
58
|
+
"@webiny/api-security-so-ddb": "^5.25.0-beta.3",
|
|
59
|
+
"@webiny/api-tenancy-so-ddb": "^5.25.0-beta.3",
|
|
60
|
+
"@webiny/cli": "^5.25.0-beta.3",
|
|
61
|
+
"@webiny/project-utils": "^5.25.0-beta.3",
|
|
62
62
|
"apollo-graphql": "^0.9.5",
|
|
63
63
|
"get-yarn-workspaces": "^1.0.2",
|
|
64
64
|
"graphql": "^15.7.2",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"build": "yarn webiny run build",
|
|
79
79
|
"watch": "yarn webiny run watch"
|
|
80
80
|
},
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "3364dbf65ade9f33f4decff7e45da1efd02b2af0"
|
|
82
82
|
}
|
package/types.d.ts
CHANGED
|
@@ -92,7 +92,12 @@ interface CmsModelFieldRenderer {
|
|
|
92
92
|
*/
|
|
93
93
|
export interface CmsModelField {
|
|
94
94
|
/**
|
|
95
|
-
* A generated ID for the model field
|
|
95
|
+
* A generated unique ID for the model field.
|
|
96
|
+
* MUST be absolute unique throughout the models.
|
|
97
|
+
* Must be in form of a-zA-Z0-9.
|
|
98
|
+
*
|
|
99
|
+
* We generate a unique id value when you're building a model via UI,
|
|
100
|
+
* but when user is creating a model via a plugin it is up to them to be careful about this.
|
|
96
101
|
*/
|
|
97
102
|
id: string;
|
|
98
103
|
/**
|
|
@@ -100,7 +105,11 @@ export interface CmsModelField {
|
|
|
100
105
|
*/
|
|
101
106
|
type: string;
|
|
102
107
|
/**
|
|
103
|
-
* A unique field ID for mapping values
|
|
108
|
+
* A unique field ID for mapping values.
|
|
109
|
+
* Must in form of a-zA-Z0-9.
|
|
110
|
+
*
|
|
111
|
+
* We generate a unique fieldId value when you're building a model via UI,
|
|
112
|
+
* but when user is creating a model via a plugin it is up to them to be careful about this.
|
|
104
113
|
*/
|
|
105
114
|
fieldId: string;
|
|
106
115
|
/**
|
|
@@ -335,11 +344,11 @@ export interface CmsModel {
|
|
|
335
344
|
/**
|
|
336
345
|
* Date created
|
|
337
346
|
*/
|
|
338
|
-
createdOn?:
|
|
347
|
+
createdOn?: string;
|
|
339
348
|
/**
|
|
340
349
|
* Date saved. Changes on both save and create.
|
|
341
350
|
*/
|
|
342
|
-
savedOn?:
|
|
351
|
+
savedOn?: string;
|
|
343
352
|
/**
|
|
344
353
|
* CreatedBy object wrapper. Contains id, name and type of the user.
|
|
345
354
|
*/
|