@webiny/api-headless-cms 5.30.0-beta.1 → 5.31.0-beta.1

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/context.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { CmsContext } from "./types";
2
- import { ContextPlugin } from "@webiny/handler";
2
+ import { ContextPlugin } from "@webiny/api";
3
3
  export declare const createContextPlugin: () => ContextPlugin<CmsContext>;
package/context.js CHANGED
@@ -11,7 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
 
12
12
  var _error = _interopRequireDefault(require("@webiny/error"));
13
13
 
14
- var _handler = require("@webiny/handler");
14
+ var _api = require("@webiny/api");
15
15
 
16
16
  var _CmsParametersPlugin = require("./plugins/CmsParametersPlugin");
17
17
 
@@ -34,13 +34,7 @@ const getParameters = async context => {
34
34
  };
35
35
 
36
36
  const createContextPlugin = () => {
37
- return new _handler.ContextPlugin(async context => {
38
- var _context$http, _context$http$request;
39
-
40
- if (((_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) === "OPTIONS") {
41
- return;
42
- }
43
-
37
+ return new _api.ContextPlugin(async context => {
44
38
  const {
45
39
  type,
46
40
  locale
package/context.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["getParameters","context","plugins","byType","CmsParametersPlugin","type","plugin","result","WebinyError","createContextPlugin","ContextPlugin","http","request","method","locale","getLocale","systemLocale","i18n","cms","READ","PREVIEW","MANAGE"],"sources":["context.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { CmsParametersPlugin, CmsParametersPluginResponse } from \"./plugins/CmsParametersPlugin\";\n\nconst getParameters = async (context: CmsContext): Promise<CmsParametersPluginResponse> => {\n const plugins = context.plugins.byType<CmsParametersPlugin>(CmsParametersPlugin.type);\n\n for (const plugin of plugins) {\n const result = await plugin.getParameters(context);\n if (result !== null) {\n return result;\n }\n }\n throw new WebinyError(\n \"Could not determine locale and/or type of the CMS.\",\n \"CMS_LOCALE_AND_TYPE_ERROR\"\n );\n};\n\nexport const createContextPlugin = () => {\n return new ContextPlugin<CmsContext>(async context => {\n if (context.http?.request?.method === \"OPTIONS\") {\n return;\n }\n\n const { type, locale } = await getParameters(context);\n\n const getLocale = () => {\n const systemLocale = context.i18n.getLocale(locale);\n if (!systemLocale) {\n throw new WebinyError(`There is no locale \"${locale}\" in the system.`);\n }\n return systemLocale;\n };\n\n context.cms = {\n ...(context.cms || {}),\n type,\n locale,\n getLocale,\n READ: type === \"read\",\n PREVIEW: type === \"preview\",\n MANAGE: type === \"manage\"\n };\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,aAAa,GAAG,MAAOC,OAAP,IAAqE;EACvF,MAAMC,OAAO,GAAGD,OAAO,CAACC,OAAR,CAAgBC,MAAhB,CAA4CC,wCAAA,CAAoBC,IAAhE,CAAhB;;EAEA,KAAK,MAAMC,MAAX,IAAqBJ,OAArB,EAA8B;IAC1B,MAAMK,MAAM,GAAG,MAAMD,MAAM,CAACN,aAAP,CAAqBC,OAArB,CAArB;;IACA,IAAIM,MAAM,KAAK,IAAf,EAAqB;MACjB,OAAOA,MAAP;IACH;EACJ;;EACD,MAAM,IAAIC,cAAJ,CACF,oDADE,EAEF,2BAFE,CAAN;AAIH,CAbD;;AAeO,MAAMC,mBAAmB,GAAG,MAAM;EACrC,OAAO,IAAIC,sBAAJ,CAA8B,MAAMT,OAAN,IAAiB;IAAA;;IAClD,IAAI,kBAAAA,OAAO,CAACU,IAAR,yFAAcC,OAAd,gFAAuBC,MAAvB,MAAkC,SAAtC,EAAiD;MAC7C;IACH;;IAED,MAAM;MAAER,IAAF;MAAQS;IAAR,IAAmB,MAAMd,aAAa,CAACC,OAAD,CAA5C;;IAEA,MAAMc,SAAS,GAAG,MAAM;MACpB,MAAMC,YAAY,GAAGf,OAAO,CAACgB,IAAR,CAAaF,SAAb,CAAuBD,MAAvB,CAArB;;MACA,IAAI,CAACE,YAAL,EAAmB;QACf,MAAM,IAAIR,cAAJ,CAAiB,uBAAsBM,MAAO,kBAA9C,CAAN;MACH;;MACD,OAAOE,YAAP;IACH,CAND;;IAQAf,OAAO,CAACiB,GAAR,mCACQjB,OAAO,CAACiB,GAAR,IAAe,EADvB;MAEIb,IAFJ;MAGIS,MAHJ;MAIIC,SAJJ;MAKII,IAAI,EAAEd,IAAI,KAAK,MALnB;MAMIe,OAAO,EAAEf,IAAI,KAAK,SANtB;MAOIgB,MAAM,EAAEhB,IAAI,KAAK;IAPrB;EASH,CAxBM,CAAP;AAyBH,CA1BM"}
1
+ {"version":3,"names":["getParameters","context","plugins","byType","CmsParametersPlugin","type","plugin","result","WebinyError","createContextPlugin","ContextPlugin","locale","getLocale","systemLocale","i18n","cms","READ","PREVIEW","MANAGE"],"sources":["context.ts"],"sourcesContent":["import { CmsContext } from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { ContextPlugin } from \"@webiny/api\";\nimport { CmsParametersPlugin, CmsParametersPluginResponse } from \"./plugins/CmsParametersPlugin\";\n\nconst getParameters = async (context: CmsContext): Promise<CmsParametersPluginResponse> => {\n const plugins = context.plugins.byType<CmsParametersPlugin>(CmsParametersPlugin.type);\n\n for (const plugin of plugins) {\n const result = await plugin.getParameters(context);\n if (result !== null) {\n return result;\n }\n }\n throw new WebinyError(\n \"Could not determine locale and/or type of the CMS.\",\n \"CMS_LOCALE_AND_TYPE_ERROR\"\n );\n};\n\nexport const createContextPlugin = () => {\n return new ContextPlugin<CmsContext>(async context => {\n const { type, locale } = await getParameters(context);\n\n const getLocale = () => {\n const systemLocale = context.i18n.getLocale(locale);\n if (!systemLocale) {\n throw new WebinyError(`There is no locale \"${locale}\" in the system.`);\n }\n return systemLocale;\n };\n\n context.cms = {\n ...(context.cms || {}),\n type,\n locale,\n getLocale,\n READ: type === \"read\",\n PREVIEW: type === \"preview\",\n MANAGE: type === \"manage\"\n };\n });\n};\n"],"mappings":";;;;;;;;;;;AACA;;AACA;;AACA;;;;;;AAEA,MAAMA,aAAa,GAAG,MAAOC,OAAP,IAAqE;EACvF,MAAMC,OAAO,GAAGD,OAAO,CAACC,OAAR,CAAgBC,MAAhB,CAA4CC,wCAAA,CAAoBC,IAAhE,CAAhB;;EAEA,KAAK,MAAMC,MAAX,IAAqBJ,OAArB,EAA8B;IAC1B,MAAMK,MAAM,GAAG,MAAMD,MAAM,CAACN,aAAP,CAAqBC,OAArB,CAArB;;IACA,IAAIM,MAAM,KAAK,IAAf,EAAqB;MACjB,OAAOA,MAAP;IACH;EACJ;;EACD,MAAM,IAAIC,cAAJ,CACF,oDADE,EAEF,2BAFE,CAAN;AAIH,CAbD;;AAeO,MAAMC,mBAAmB,GAAG,MAAM;EACrC,OAAO,IAAIC,kBAAJ,CAA8B,MAAMT,OAAN,IAAiB;IAClD,MAAM;MAAEI,IAAF;MAAQM;IAAR,IAAmB,MAAMX,aAAa,CAACC,OAAD,CAA5C;;IAEA,MAAMW,SAAS,GAAG,MAAM;MACpB,MAAMC,YAAY,GAAGZ,OAAO,CAACa,IAAR,CAAaF,SAAb,CAAuBD,MAAvB,CAArB;;MACA,IAAI,CAACE,YAAL,EAAmB;QACf,MAAM,IAAIL,cAAJ,CAAiB,uBAAsBG,MAAO,kBAA9C,CAAN;MACH;;MACD,OAAOE,YAAP;IACH,CAND;;IAQAZ,OAAO,CAACc,GAAR,mCACQd,OAAO,CAACc,GAAR,IAAe,EADvB;MAEIV,IAFJ;MAGIM,MAHJ;MAIIC,SAJJ;MAKII,IAAI,EAAEX,IAAI,KAAK,MALnB;MAMIY,OAAO,EAAEZ,IAAI,KAAK,SANtB;MAOIa,MAAM,EAAEb,IAAI,KAAK;IAPrB;EASH,CApBM,CAAP;AAqBH,CAtBM"}
package/crud/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ContextPlugin } from "@webiny/handler";
1
+ import { ContextPlugin } from "@webiny/api";
2
2
  import { CmsContext, HeadlessCmsStorageOperations } from "../types";
3
3
  export interface CrudParams {
4
4
  storageOperations: HeadlessCmsStorageOperations;
package/crud/index.js CHANGED
@@ -9,7 +9,7 @@ exports.createCrud = void 0;
9
9
 
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
 
12
- var _handler = require("@webiny/handler");
12
+ var _api = require("@webiny/api");
13
13
 
14
14
  var _contentModelGroup = require("./contentModelGroup.crud");
15
15
 
@@ -29,13 +29,7 @@ const createCrud = params => {
29
29
  const {
30
30
  storageOperations
31
31
  } = params;
32
- return new _handler.ContextPlugin(async context => {
33
- var _context$http, _context$http$request;
34
-
35
- if (((_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) === "OPTIONS") {
36
- return;
37
- }
38
-
32
+ return new _api.ContextPlugin(async context => {
39
33
  const getLocale = () => {
40
34
  return context.cms.getLocale();
41
35
  };
package/crud/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["createCrud","params","storageOperations","ContextPlugin","context","http","request","method","getLocale","cms","getIdentity","security","getTenant","tenancy","getCurrentTenant","beforeInit","createSystemCrud","createSettingsCrud","createModelGroupsCrud","createModelsCrud","createContentEntryCrud","init"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/handler\";\nimport { CmsContext, HeadlessCmsStorageOperations } from \"~/types\";\nimport { createModelGroupsCrud } from \"./contentModelGroup.crud\";\nimport { createModelsCrud } from \"./contentModel.crud\";\nimport { createContentEntryCrud } from \"./contentEntry.crud\";\nimport { createSystemCrud } from \"./system.crud\";\nimport { createSettingsCrud } from \"./settings.crud\";\n\nexport interface CrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nexport const createCrud = (params: CrudParams) => {\n const { storageOperations } = params;\n return new ContextPlugin<CmsContext>(async context => {\n if (context.http?.request?.method === \"OPTIONS\") {\n return;\n }\n\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n if (storageOperations.beforeInit) {\n await storageOperations.beforeInit(context);\n }\n\n context.cms = {\n ...context.cms,\n storageOperations,\n ...createSystemCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createSettingsCrud({\n context,\n getTenant,\n getLocale,\n storageOperations\n }),\n ...createModelGroupsCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createModelsCrud({\n context,\n getLocale,\n getTenant,\n getIdentity,\n storageOperations\n }),\n ...createContentEntryCrud({\n context,\n getIdentity,\n getTenant,\n storageOperations\n })\n };\n\n if (!storageOperations.init) {\n return;\n }\n await storageOperations.init(context);\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMO,MAAMA,UAAU,GAAIC,MAAD,IAAwB;EAC9C,MAAM;IAAEC;EAAF,IAAwBD,MAA9B;EACA,OAAO,IAAIE,sBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAAA;;IAClD,IAAI,kBAAAA,OAAO,CAACC,IAAR,yFAAcC,OAAd,gFAAuBC,MAAvB,MAAkC,SAAtC,EAAiD;MAC7C;IACH;;IAED,MAAMC,SAAS,GAAG,MAAM;MACpB,OAAOJ,OAAO,CAACK,GAAR,CAAYD,SAAZ,EAAP;IACH,CAFD;;IAIA,MAAME,WAAW,GAAG,MAAM;MACtB,OAAON,OAAO,CAACO,QAAR,CAAiBD,WAAjB,EAAP;IACH,CAFD;;IAIA,MAAME,SAAS,GAAG,MAAM;MACpB,OAAOR,OAAO,CAACS,OAAR,CAAgBC,gBAAhB,EAAP;IACH,CAFD;;IAIA,IAAIZ,iBAAiB,CAACa,UAAtB,EAAkC;MAC9B,MAAMb,iBAAiB,CAACa,UAAlB,CAA6BX,OAA7B,CAAN;IACH;;IAEDA,OAAO,CAACK,GAAR,2FACOL,OAAO,CAACK,GADf;MAEIP;IAFJ,GAGO,IAAAc,wBAAA,EAAiB;MAChBZ,OADgB;MAEhBQ,SAFgB;MAGhBJ,SAHgB;MAIhBE,WAJgB;MAKhBR;IALgB,CAAjB,CAHP,GAUO,IAAAe,4BAAA,EAAmB;MAClBb,OADkB;MAElBQ,SAFkB;MAGlBJ,SAHkB;MAIlBN;IAJkB,CAAnB,CAVP,GAgBO,IAAAgB,wCAAA,EAAsB;MACrBd,OADqB;MAErBQ,SAFqB;MAGrBJ,SAHqB;MAIrBE,WAJqB;MAKrBR;IALqB,CAAtB,CAhBP,GAuBO,IAAAiB,8BAAA,EAAiB;MAChBf,OADgB;MAEhBI,SAFgB;MAGhBI,SAHgB;MAIhBF,WAJgB;MAKhBR;IALgB,CAAjB,CAvBP,GA8BO,IAAAkB,oCAAA,EAAuB;MACtBhB,OADsB;MAEtBM,WAFsB;MAGtBE,SAHsB;MAItBV;IAJsB,CAAvB,CA9BP;;IAsCA,IAAI,CAACA,iBAAiB,CAACmB,IAAvB,EAA6B;MACzB;IACH;;IACD,MAAMnB,iBAAiB,CAACmB,IAAlB,CAAuBjB,OAAvB,CAAN;EACH,CA/DM,CAAP;AAgEH,CAlEM"}
1
+ {"version":3,"names":["createCrud","params","storageOperations","ContextPlugin","context","getLocale","cms","getIdentity","security","getTenant","tenancy","getCurrentTenant","beforeInit","createSystemCrud","createSettingsCrud","createModelGroupsCrud","createModelsCrud","createContentEntryCrud","init"],"sources":["index.ts"],"sourcesContent":["import { ContextPlugin } from \"@webiny/api\";\nimport { CmsContext, HeadlessCmsStorageOperations } from \"~/types\";\nimport { createModelGroupsCrud } from \"./contentModelGroup.crud\";\nimport { createModelsCrud } from \"./contentModel.crud\";\nimport { createContentEntryCrud } from \"./contentEntry.crud\";\nimport { createSystemCrud } from \"./system.crud\";\nimport { createSettingsCrud } from \"./settings.crud\";\n\nexport interface CrudParams {\n storageOperations: HeadlessCmsStorageOperations;\n}\n\nexport const createCrud = (params: CrudParams) => {\n const { storageOperations } = params;\n return new ContextPlugin<CmsContext>(async context => {\n const getLocale = () => {\n return context.cms.getLocale();\n };\n\n const getIdentity = () => {\n return context.security.getIdentity();\n };\n\n const getTenant = () => {\n return context.tenancy.getCurrentTenant();\n };\n\n if (storageOperations.beforeInit) {\n await storageOperations.beforeInit(context);\n }\n\n context.cms = {\n ...context.cms,\n storageOperations,\n ...createSystemCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createSettingsCrud({\n context,\n getTenant,\n getLocale,\n storageOperations\n }),\n ...createModelGroupsCrud({\n context,\n getTenant,\n getLocale,\n getIdentity,\n storageOperations\n }),\n ...createModelsCrud({\n context,\n getLocale,\n getTenant,\n getIdentity,\n storageOperations\n }),\n ...createContentEntryCrud({\n context,\n getIdentity,\n getTenant,\n storageOperations\n })\n };\n\n if (!storageOperations.init) {\n return;\n }\n await storageOperations.init(context);\n });\n};\n"],"mappings":";;;;;;;;;;;AAAA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAMO,MAAMA,UAAU,GAAIC,MAAD,IAAwB;EAC9C,MAAM;IAAEC;EAAF,IAAwBD,MAA9B;EACA,OAAO,IAAIE,kBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAClD,MAAMC,SAAS,GAAG,MAAM;MACpB,OAAOD,OAAO,CAACE,GAAR,CAAYD,SAAZ,EAAP;IACH,CAFD;;IAIA,MAAME,WAAW,GAAG,MAAM;MACtB,OAAOH,OAAO,CAACI,QAAR,CAAiBD,WAAjB,EAAP;IACH,CAFD;;IAIA,MAAME,SAAS,GAAG,MAAM;MACpB,OAAOL,OAAO,CAACM,OAAR,CAAgBC,gBAAhB,EAAP;IACH,CAFD;;IAIA,IAAIT,iBAAiB,CAACU,UAAtB,EAAkC;MAC9B,MAAMV,iBAAiB,CAACU,UAAlB,CAA6BR,OAA7B,CAAN;IACH;;IAEDA,OAAO,CAACE,GAAR,2FACOF,OAAO,CAACE,GADf;MAEIJ;IAFJ,GAGO,IAAAW,wBAAA,EAAiB;MAChBT,OADgB;MAEhBK,SAFgB;MAGhBJ,SAHgB;MAIhBE,WAJgB;MAKhBL;IALgB,CAAjB,CAHP,GAUO,IAAAY,4BAAA,EAAmB;MAClBV,OADkB;MAElBK,SAFkB;MAGlBJ,SAHkB;MAIlBH;IAJkB,CAAnB,CAVP,GAgBO,IAAAa,wCAAA,EAAsB;MACrBX,OADqB;MAErBK,SAFqB;MAGrBJ,SAHqB;MAIrBE,WAJqB;MAKrBL;IALqB,CAAtB,CAhBP,GAuBO,IAAAc,8BAAA,EAAiB;MAChBZ,OADgB;MAEhBC,SAFgB;MAGhBI,SAHgB;MAIhBF,WAJgB;MAKhBL;IALgB,CAAjB,CAvBP,GA8BO,IAAAe,oCAAA,EAAuB;MACtBb,OADsB;MAEtBG,WAFsB;MAGtBE,SAHsB;MAItBP;IAJsB,CAAvB,CA9BP;;IAsCA,IAAI,CAACA,iBAAiB,CAACgB,IAAvB,EAA6B;MACzB;IACH;;IACD,MAAMhB,iBAAiB,CAACgB,IAAlB,CAAuBd,OAAvB,CAAN;EACH,CA3DM,CAAP;AA4DH,CA9DM"}
@@ -7,8 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.graphQLHandlerFactory = void 0;
9
9
 
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
10
  var _schema = require("@graphql-tools/schema");
13
11
 
14
12
  var _apiSecurity = require("@webiny/api-security");
@@ -21,33 +19,7 @@ var _buildSchemaPlugins = require("./buildSchemaPlugins");
21
19
 
22
20
  var _plugins = require("@webiny/handler-graphql/plugins");
23
21
 
24
- var _utils = require("@webiny/utils");
25
-
26
- 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; }
27
-
28
- 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; }
29
-
30
- const DEFAULT_HEADERS = _objectSpread({
31
- "Access-Control-Allow-Origin": "*",
32
- "Access-Control-Allow-Headers": "*",
33
- "Access-Control-Allow-Methods": "OPTIONS,POST",
34
- "Content-Type": "application/json"
35
- }, (0, _utils.getWebinyVersionHeaders)());
36
-
37
- const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
38
-
39
- const OPTIONS_HEADERS = {
40
- "Access-Control-Max-Age": `${DEFAULT_CACHE_MAX_AGE}`,
41
- "Cache-Control": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`
42
- };
43
-
44
- const respond = (http, result) => {
45
- return http.response({
46
- body: JSON.stringify(result),
47
- statusCode: 200,
48
- headers: DEFAULT_HEADERS
49
- });
50
- };
22
+ var _handler = require("@webiny/handler");
51
23
 
52
24
  const schemaList = new Map();
53
25
 
@@ -141,66 +113,44 @@ const checkEndpointAccess = async context => {
141
113
  }
142
114
  };
143
115
 
144
- const graphQLHandlerFactory = ({
145
- debug
116
+ const cmsRoutes = new _handler.RoutePlugin(({
117
+ onPost,
118
+ onOptions,
119
+ context
146
120
  }) => {
147
- const handler = {
148
- type: "handler",
149
- name: "handler.cms.graphql",
150
-
151
- async handle(context, next) {
152
- const {
153
- http,
154
- cms
155
- } = context;
156
- /**
157
- * Possibly not a CMS request?
158
- */
159
-
160
- const type = cms === null || cms === void 0 ? void 0 : cms.type;
161
-
162
- if (!type || !(http !== null && http !== void 0 && http.request)) {
163
- return next();
164
- }
165
-
166
- const method = (http.request.method || "").toLowerCase();
167
- /**
168
- * In case of OPTIONS method we just return the headers since there is no need to go further.
169
- */
170
-
171
- if (method.toLowerCase() === "options") {
172
- return http.response({
173
- statusCode: 204,
174
- headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), OPTIONS_HEADERS)
175
- });
176
- }
177
- /**
178
- * We expect, and allow, only POST method to access our GraphQL
179
- */
180
-
181
-
182
- if (method !== "post") {
183
- return next();
184
- }
185
-
186
- try {
187
- await checkEndpointAccess(context);
188
- } catch (ex) {
189
- return respond(http, new _apiSecurity.NotAuthorizedResponse(ex));
190
- }
191
-
192
- const schema = await getSchema({
193
- context,
194
- locale: cms.getLocale(),
195
- type
121
+ onPost("/cms/:type(^manage|preview|read$)/:locale", async (request, reply) => {
122
+ try {
123
+ await checkEndpointAccess(context);
124
+ } catch (ex) {
125
+ return reply.code(401).send({
126
+ data: null,
127
+ error: {
128
+ message: ex.message || "Not authorized!",
129
+ code: ex.code || "SECURITY_NOT_AUTHORIZED",
130
+ data: ex.data || null,
131
+ stack: null
132
+ }
196
133
  });
197
- const body = JSON.parse(http.request.body);
198
- const result = await (0, _processRequestBody.default)(body, schema, context);
199
- return respond(http, result);
200
134
  }
201
135
 
202
- };
203
- return [...(debug ? (0, _debugPlugins.default)() : []), handler, {
136
+ const schema = await getSchema({
137
+ context,
138
+ locale: context.cms.getLocale(),
139
+ type: context.cms.type
140
+ });
141
+ const body = request.body;
142
+ const result = await (0, _processRequestBody.default)(body, schema, context);
143
+ return reply.code(200).send(result);
144
+ });
145
+ onOptions("/cms/:type(^manage|preview|read$)/:locale", async (_, reply) => {
146
+ return reply.hijack().send({});
147
+ });
148
+ });
149
+
150
+ const graphQLHandlerFactory = ({
151
+ debug
152
+ }) => {
153
+ return [...(debug ? (0, _debugPlugins.default)() : []), cmsRoutes, {
204
154
  type: "wcp-telemetry-tracker"
205
155
  }];
206
156
  };
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_HEADERS","getWebinyVersionHeaders","DEFAULT_CACHE_MAX_AGE","OPTIONS_HEADERS","respond","http","result","response","body","JSON","stringify","statusCode","headers","schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","generateSchema","plugins","register","buildSchemaPlugins","typeDefs","resolvers","schemaPlugins","byType","GraphQLSchemaPlugin","pl","push","schema","makeExecutableSchema","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","has","set","key","cache","get","checkEndpointAccess","permission","security","getPermission","NotAuthorizedError","data","reason","graphQLHandlerFactory","debug","handler","name","handle","next","request","method","toLowerCase","ex","NotAuthorizedResponse","getLocale","parse","processRequestBody","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError, NotAuthorizedResponse } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\nimport { HttpObject } from \"@webiny/handler-http/types\";\nimport { HandlerPlugin } from \"@webiny/handler/types\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\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 respond = (http: HttpObject, result: unknown) => {\n return http.response({\n body: JSON.stringify(result),\n statusCode: 200,\n headers: DEFAULT_HEADERS\n });\n};\nconst schemaList = new Map<string, SchemaCache>();\n\nconst generateCacheKey = async (args: GetSchemaParams): Promise<string> => {\n const { context, locale, type } = args;\n const lastModelChange = await context.cms.getModelLastChange();\n return [locale.code, type, lastModelChange.toISOString()].join(\"#\");\n};\n\nconst generateSchema = async (args: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = args;\n\n context.plugins.register(await buildSchemaPlugins(context));\n /**\n * Really hard to type this to satisfy the makeExecutableSchema\n */\n // TODO @ts-refactor\n const typeDefs: any = [];\n const resolvers: any = [];\n\n // Get schema definitions from plugins\n const schemaPlugins = context.plugins.byType<GraphQLSchemaPlugin>(GraphQLSchemaPlugin.type);\n for (const pl of schemaPlugins) {\n typeDefs.push(pl.schema.typeDefs);\n resolvers.push(pl.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers\n });\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context, type, locale } = params;\n const tenantId = context.tenancy.getCurrentTenant().id;\n const id = `${tenantId}#${type}#${locale.code}`;\n\n const cacheKey = await generateCacheKey(params);\n if (!schemaList.has(id)) {\n const schema = await generateSchema(params);\n\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n }\n /**\n * Safe to cast because check was done few lines up.\n */\n const cache = schemaList.get(id) as SchemaCache;\n if (cache.key === cacheKey) {\n return cache.schema;\n }\n const schema = await generateSchema(params);\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n const handler: HandlerPlugin = {\n type: \"handler\",\n name: \"handler.cms.graphql\",\n async handle(context: CmsContext, next) {\n const { http, cms } = context;\n /**\n * Possibly not a CMS request?\n */\n const type = cms?.type;\n if (!type || !http?.request) {\n return next();\n }\n\n const method = (http.request.method || \"\").toLowerCase();\n /**\n * In case of OPTIONS method we just return the headers since there is no need to go further.\n */\n if (method.toLowerCase() === \"options\") {\n return http.response({\n statusCode: 204,\n headers: {\n ...DEFAULT_HEADERS,\n ...OPTIONS_HEADERS\n }\n });\n }\n /**\n * We expect, and allow, only POST method to access our GraphQL\n */\n if (method !== \"post\") {\n return next();\n }\n\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return respond(http, new NotAuthorizedResponse(ex));\n }\n\n const schema = await getSchema({\n context,\n locale: cms.getLocale(),\n type\n });\n\n const body: GraphQLRequestBody | GraphQLRequestBody[] = JSON.parse(http.request.body);\n\n const result = await processRequestBody(body, schema, context);\n return respond(http, result);\n }\n };\n\n return [\n ...(debug ? debugPlugins() : []),\n handler,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;;;;;AACA;;AAGA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;;;AAeA,MAAMA,eAAuC;EACzC,+BAA+B,GADU;EAEzC,gCAAgC,GAFS;EAGzC,gCAAgC,cAHS;EAIzC,gBAAgB;AAJyB,GAKtC,IAAAC,8BAAA,GALsC,CAA7C;;AAQA,MAAMC,qBAAqB,GAAG,QAA9B,C,CAAwC;;AAExC,MAAMC,eAAuC,GAAG;EAC5C,0BAA2B,GAAED,qBAAsB,EADP;EAE5C,iBAAkB,mBAAkBA,qBAAsB;AAFd,CAAhD;;AAKA,MAAME,OAAO,GAAG,CAACC,IAAD,EAAmBC,MAAnB,KAAuC;EACnD,OAAOD,IAAI,CAACE,QAAL,CAAc;IACjBC,IAAI,EAAEC,IAAI,CAACC,SAAL,CAAeJ,MAAf,CADW;IAEjBK,UAAU,EAAE,GAFK;IAGjBC,OAAO,EAAEZ;EAHQ,CAAd,CAAP;AAKH,CAND;;AAOA,MAAMa,UAAU,GAAG,IAAIC,GAAJ,EAAnB;;AAEA,MAAMC,gBAAgB,GAAG,MAAOC,IAAP,IAAkD;EACvE,MAAM;IAAEC,OAAF;IAAWC,MAAX;IAAmBC;EAAnB,IAA4BH,IAAlC;EACA,MAAMI,eAAe,GAAG,MAAMH,OAAO,CAACI,GAAR,CAAYC,kBAAZ,EAA9B;EACA,OAAO,CAACJ,MAAM,CAACK,IAAR,EAAcJ,IAAd,EAAoBC,eAAe,CAACI,WAAhB,EAApB,EAAmDC,IAAnD,CAAwD,GAAxD,CAAP;AACH,CAJD;;AAMA,MAAMC,cAAc,GAAG,MAAOV,IAAP,IAAyD;EAC5E,MAAM;IAAEC;EAAF,IAAcD,IAApB;EAEAC,OAAO,CAACU,OAAR,CAAgBC,QAAhB,CAAyB,MAAM,IAAAC,sCAAA,EAAmBZ,OAAnB,CAA/B;EACA;AACJ;AACA;EACI;;EACA,MAAMa,QAAa,GAAG,EAAtB;EACA,MAAMC,SAAc,GAAG,EAAvB,CAT4E,CAW5E;;EACA,MAAMC,aAAa,GAAGf,OAAO,CAACU,OAAR,CAAgBM,MAAhB,CAA4CC,4BAAA,CAAoBf,IAAhE,CAAtB;;EACA,KAAK,MAAMgB,EAAX,IAAiBH,aAAjB,EAAgC;IAC5BF,QAAQ,CAACM,IAAT,CAAcD,EAAE,CAACE,MAAH,CAAUP,QAAxB;IACAC,SAAS,CAACK,IAAV,CAAeD,EAAE,CAACE,MAAH,CAAUN,SAAzB;EACH;;EAED,OAAO,IAAAO,4BAAA,EAAqB;IACxBR,QADwB;IAExBC;EAFwB,CAArB,CAAP;AAIH,CAtBD;AAwBA;AACA;AACA;AACA;;;AACA,MAAMQ,SAAS,GAAG,MAAOC,MAAP,IAA2D;EACzE,MAAM;IAAEvB,OAAF;IAAWE,IAAX;IAAiBD;EAAjB,IAA4BsB,MAAlC;EACA,MAAMC,QAAQ,GAAGxB,OAAO,CAACyB,OAAR,CAAgBC,gBAAhB,GAAmCC,EAApD;EACA,MAAMA,EAAE,GAAI,GAAEH,QAAS,IAAGtB,IAAK,IAAGD,MAAM,CAACK,IAAK,EAA9C;EAEA,MAAMsB,QAAQ,GAAG,MAAM9B,gBAAgB,CAACyB,MAAD,CAAvC;;EACA,IAAI,CAAC3B,UAAU,CAACiC,GAAX,CAAeF,EAAf,CAAL,EAAyB;IACrB,MAAMP,MAAM,GAAG,MAAMX,cAAc,CAACc,MAAD,CAAnC;IAEA3B,UAAU,CAACkC,GAAX,CAAeH,EAAf,EAAmB;MACfI,GAAG,EAAEH,QADU;MAEfR;IAFe,CAAnB;IAIA,OAAOA,MAAP;EACH;EACD;AACJ;AACA;;;EACI,MAAMY,KAAK,GAAGpC,UAAU,CAACqC,GAAX,CAAeN,EAAf,CAAd;;EACA,IAAIK,KAAK,CAACD,GAAN,KAAcH,QAAlB,EAA4B;IACxB,OAAOI,KAAK,CAACZ,MAAb;EACH;;EACD,MAAMA,MAAM,GAAG,MAAMX,cAAc,CAACc,MAAD,CAAnC;EACA3B,UAAU,CAACkC,GAAX,CAAeH,EAAf,EAAmB;IACfI,GAAG,EAAEH,QADU;IAEfR;EAFe,CAAnB;EAIA,OAAOA,MAAP;AACH,CA5BD;;AA8BA,MAAMc,mBAAmB,GAAG,MAAOlC,OAAP,IAA8C;EACtE,MAAMmC,UAAU,GAAG,MAAMnC,OAAO,CAACoC,QAAR,CAAiBC,aAAjB,CAAgC,gBAAerC,OAAO,CAACI,GAAR,CAAYF,IAAK,EAAhE,CAAzB;;EACA,IAAI,CAACiC,UAAL,EAAiB;IACb,MAAM,IAAIG,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,0BAAyBxC,OAAO,CAACI,GAAR,CAAYF,IAAK;MADjD;IADmB,CAAvB,CAAN;EAKH;AACJ,CATD;;AAeO,MAAMuC,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA8D;EAC/F,MAAMC,OAAsB,GAAG;IAC3BzC,IAAI,EAAE,SADqB;IAE3B0C,IAAI,EAAE,qBAFqB;;IAG3B,MAAMC,MAAN,CAAa7C,OAAb,EAAkC8C,IAAlC,EAAwC;MACpC,MAAM;QAAE1D,IAAF;QAAQgB;MAAR,IAAgBJ,OAAtB;MACA;AACZ;AACA;;MACY,MAAME,IAAI,GAAGE,GAAH,aAAGA,GAAH,uBAAGA,GAAG,CAAEF,IAAlB;;MACA,IAAI,CAACA,IAAD,IAAS,EAACd,IAAD,aAACA,IAAD,eAACA,IAAI,CAAE2D,OAAP,CAAb,EAA6B;QACzB,OAAOD,IAAI,EAAX;MACH;;MAED,MAAME,MAAM,GAAG,CAAC5D,IAAI,CAAC2D,OAAL,CAAaC,MAAb,IAAuB,EAAxB,EAA4BC,WAA5B,EAAf;MACA;AACZ;AACA;;MACY,IAAID,MAAM,CAACC,WAAP,OAAyB,SAA7B,EAAwC;QACpC,OAAO7D,IAAI,CAACE,QAAL,CAAc;UACjBI,UAAU,EAAE,GADK;UAEjBC,OAAO,kCACAZ,eADA,GAEAG,eAFA;QAFU,CAAd,CAAP;MAOH;MACD;AACZ;AACA;;;MACY,IAAI8D,MAAM,KAAK,MAAf,EAAuB;QACnB,OAAOF,IAAI,EAAX;MACH;;MAED,IAAI;QACA,MAAMZ,mBAAmB,CAAClC,OAAD,CAAzB;MACH,CAFD,CAEE,OAAOkD,EAAP,EAAW;QACT,OAAO/D,OAAO,CAACC,IAAD,EAAO,IAAI+D,kCAAJ,CAA0BD,EAA1B,CAAP,CAAd;MACH;;MAED,MAAM9B,MAAM,GAAG,MAAME,SAAS,CAAC;QAC3BtB,OAD2B;QAE3BC,MAAM,EAAEG,GAAG,CAACgD,SAAJ,EAFmB;QAG3BlD;MAH2B,CAAD,CAA9B;MAMA,MAAMX,IAA+C,GAAGC,IAAI,CAAC6D,KAAL,CAAWjE,IAAI,CAAC2D,OAAL,CAAaxD,IAAxB,CAAxD;MAEA,MAAMF,MAAM,GAAG,MAAM,IAAAiE,2BAAA,EAAmB/D,IAAnB,EAAyB6B,MAAzB,EAAiCpB,OAAjC,CAArB;MACA,OAAOb,OAAO,CAACC,IAAD,EAAOC,MAAP,CAAd;IACH;;EAjD0B,CAA/B;EAoDA,OAAO,CACH,IAAIqD,KAAK,GAAG,IAAAa,qBAAA,GAAH,GAAoB,EAA7B,CADG,EAEHZ,OAFG,EAGH;IACIzC,IAAI,EAAE;EADV,CAHG,CAAP;AAOH,CA5DM"}
1
+ {"version":3,"names":["schemaList","Map","generateCacheKey","args","context","locale","type","lastModelChange","cms","getModelLastChange","code","toISOString","join","generateSchema","plugins","register","buildSchemaPlugins","typeDefs","resolvers","schemaPlugins","byType","GraphQLSchemaPlugin","pl","push","schema","makeExecutableSchema","getSchema","params","tenantId","tenancy","getCurrentTenant","id","cacheKey","has","set","key","cache","get","checkEndpointAccess","permission","security","getPermission","NotAuthorizedError","data","reason","cmsRoutes","RoutePlugin","onPost","onOptions","request","reply","ex","send","error","message","stack","getLocale","body","result","processRequestBody","_","hijack","graphQLHandlerFactory","debug","debugPlugins"],"sources":["graphQLHandlerFactory.ts"],"sourcesContent":["import { GraphQLSchema } from \"graphql\";\nimport { makeExecutableSchema } from \"@graphql-tools/schema\";\nimport { ApiEndpoint, CmsContext } from \"~/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { NotAuthorizedError } from \"@webiny/api-security\";\nimport { PluginCollection } from \"@webiny/plugins/types\";\nimport debugPlugins from \"@webiny/handler-graphql/debugPlugins\";\nimport processRequestBody from \"@webiny/handler-graphql/processRequestBody\";\nimport { buildSchemaPlugins } from \"./buildSchemaPlugins\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/plugins\";\nimport { GraphQLRequestBody } from \"@webiny/handler-graphql/types\";\nimport { RoutePlugin } from \"@webiny/handler\";\n\ninterface SchemaCache {\n key: string;\n schema: GraphQLSchema;\n}\ninterface GetSchemaParams {\n context: CmsContext;\n type: ApiEndpoint;\n locale: I18NLocale;\n}\n\nconst schemaList = new Map<string, SchemaCache>();\n\nconst generateCacheKey = async (args: GetSchemaParams): Promise<string> => {\n const { context, locale, type } = args;\n const lastModelChange = await context.cms.getModelLastChange();\n return [locale.code, type, lastModelChange.toISOString()].join(\"#\");\n};\n\nconst generateSchema = async (args: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context } = args;\n\n context.plugins.register(await buildSchemaPlugins(context));\n /**\n * Really hard to type this to satisfy the makeExecutableSchema\n */\n // TODO @ts-refactor\n const typeDefs: any = [];\n const resolvers: any = [];\n\n // Get schema definitions from plugins\n const schemaPlugins = context.plugins.byType<GraphQLSchemaPlugin>(GraphQLSchemaPlugin.type);\n for (const pl of schemaPlugins) {\n typeDefs.push(pl.schema.typeDefs);\n resolvers.push(pl.schema.resolvers);\n }\n\n return makeExecutableSchema({\n typeDefs,\n resolvers\n });\n};\n\n/**\n * Gets an existing schema or rewrites existing one or creates a completely new one\n * depending on the schemaId created from type and locale parameters\n */\nconst getSchema = async (params: GetSchemaParams): Promise<GraphQLSchema> => {\n const { context, type, locale } = params;\n const tenantId = context.tenancy.getCurrentTenant().id;\n const id = `${tenantId}#${type}#${locale.code}`;\n\n const cacheKey = await generateCacheKey(params);\n if (!schemaList.has(id)) {\n const schema = await generateSchema(params);\n\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n }\n /**\n * Safe to cast because check was done few lines up.\n */\n const cache = schemaList.get(id) as SchemaCache;\n if (cache.key === cacheKey) {\n return cache.schema;\n }\n const schema = await generateSchema(params);\n schemaList.set(id, {\n key: cacheKey,\n schema\n });\n return schema;\n};\n\nconst checkEndpointAccess = async (context: CmsContext): Promise<void> => {\n const permission = await context.security.getPermission(`cms.endpoint.${context.cms.type}`);\n if (!permission) {\n throw new NotAuthorizedError({\n data: {\n reason: `Not allowed to access \"${context.cms.type}\" endpoint.`\n }\n });\n }\n};\n\nexport interface GraphQLHandlerFactoryParams {\n debug?: boolean;\n}\n\nconst cmsRoutes = new RoutePlugin<CmsContext>(({ onPost, onOptions, context }) => {\n onPost(\"/cms/:type(^manage|preview|read$)/:locale\", async (request, reply) => {\n try {\n await checkEndpointAccess(context);\n } catch (ex) {\n return reply.code(401).send({\n data: null,\n error: {\n message: ex.message || \"Not authorized!\",\n code: ex.code || \"SECURITY_NOT_AUTHORIZED\",\n data: ex.data || null,\n stack: null\n }\n });\n }\n\n const schema = await getSchema({\n context,\n locale: context.cms.getLocale(),\n type: context.cms.type as ApiEndpoint\n });\n const body: GraphQLRequestBody | GraphQLRequestBody[] = request.body as any;\n const result = await processRequestBody(body, schema, context);\n return reply.code(200).send(result);\n });\n\n onOptions(\"/cms/:type(^manage|preview|read$)/:locale\", async (_, reply) => {\n return reply.hijack().send({});\n });\n});\n\nexport const graphQLHandlerFactory = ({ debug }: GraphQLHandlerFactoryParams): PluginCollection => {\n return [\n ...(debug ? debugPlugins() : []),\n cmsRoutes,\n {\n type: \"wcp-telemetry-tracker\"\n }\n ];\n};\n"],"mappings":";;;;;;;;;AACA;;AAGA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;AAYA,MAAMA,UAAU,GAAG,IAAIC,GAAJ,EAAnB;;AAEA,MAAMC,gBAAgB,GAAG,MAAOC,IAAP,IAAkD;EACvE,MAAM;IAAEC,OAAF;IAAWC,MAAX;IAAmBC;EAAnB,IAA4BH,IAAlC;EACA,MAAMI,eAAe,GAAG,MAAMH,OAAO,CAACI,GAAR,CAAYC,kBAAZ,EAA9B;EACA,OAAO,CAACJ,MAAM,CAACK,IAAR,EAAcJ,IAAd,EAAoBC,eAAe,CAACI,WAAhB,EAApB,EAAmDC,IAAnD,CAAwD,GAAxD,CAAP;AACH,CAJD;;AAMA,MAAMC,cAAc,GAAG,MAAOV,IAAP,IAAyD;EAC5E,MAAM;IAAEC;EAAF,IAAcD,IAApB;EAEAC,OAAO,CAACU,OAAR,CAAgBC,QAAhB,CAAyB,MAAM,IAAAC,sCAAA,EAAmBZ,OAAnB,CAA/B;EACA;AACJ;AACA;EACI;;EACA,MAAMa,QAAa,GAAG,EAAtB;EACA,MAAMC,SAAc,GAAG,EAAvB,CAT4E,CAW5E;;EACA,MAAMC,aAAa,GAAGf,OAAO,CAACU,OAAR,CAAgBM,MAAhB,CAA4CC,4BAAA,CAAoBf,IAAhE,CAAtB;;EACA,KAAK,MAAMgB,EAAX,IAAiBH,aAAjB,EAAgC;IAC5BF,QAAQ,CAACM,IAAT,CAAcD,EAAE,CAACE,MAAH,CAAUP,QAAxB;IACAC,SAAS,CAACK,IAAV,CAAeD,EAAE,CAACE,MAAH,CAAUN,SAAzB;EACH;;EAED,OAAO,IAAAO,4BAAA,EAAqB;IACxBR,QADwB;IAExBC;EAFwB,CAArB,CAAP;AAIH,CAtBD;AAwBA;AACA;AACA;AACA;;;AACA,MAAMQ,SAAS,GAAG,MAAOC,MAAP,IAA2D;EACzE,MAAM;IAAEvB,OAAF;IAAWE,IAAX;IAAiBD;EAAjB,IAA4BsB,MAAlC;EACA,MAAMC,QAAQ,GAAGxB,OAAO,CAACyB,OAAR,CAAgBC,gBAAhB,GAAmCC,EAApD;EACA,MAAMA,EAAE,GAAI,GAAEH,QAAS,IAAGtB,IAAK,IAAGD,MAAM,CAACK,IAAK,EAA9C;EAEA,MAAMsB,QAAQ,GAAG,MAAM9B,gBAAgB,CAACyB,MAAD,CAAvC;;EACA,IAAI,CAAC3B,UAAU,CAACiC,GAAX,CAAeF,EAAf,CAAL,EAAyB;IACrB,MAAMP,MAAM,GAAG,MAAMX,cAAc,CAACc,MAAD,CAAnC;IAEA3B,UAAU,CAACkC,GAAX,CAAeH,EAAf,EAAmB;MACfI,GAAG,EAAEH,QADU;MAEfR;IAFe,CAAnB;IAIA,OAAOA,MAAP;EACH;EACD;AACJ;AACA;;;EACI,MAAMY,KAAK,GAAGpC,UAAU,CAACqC,GAAX,CAAeN,EAAf,CAAd;;EACA,IAAIK,KAAK,CAACD,GAAN,KAAcH,QAAlB,EAA4B;IACxB,OAAOI,KAAK,CAACZ,MAAb;EACH;;EACD,MAAMA,MAAM,GAAG,MAAMX,cAAc,CAACc,MAAD,CAAnC;EACA3B,UAAU,CAACkC,GAAX,CAAeH,EAAf,EAAmB;IACfI,GAAG,EAAEH,QADU;IAEfR;EAFe,CAAnB;EAIA,OAAOA,MAAP;AACH,CA5BD;;AA8BA,MAAMc,mBAAmB,GAAG,MAAOlC,OAAP,IAA8C;EACtE,MAAMmC,UAAU,GAAG,MAAMnC,OAAO,CAACoC,QAAR,CAAiBC,aAAjB,CAAgC,gBAAerC,OAAO,CAACI,GAAR,CAAYF,IAAK,EAAhE,CAAzB;;EACA,IAAI,CAACiC,UAAL,EAAiB;IACb,MAAM,IAAIG,+BAAJ,CAAuB;MACzBC,IAAI,EAAE;QACFC,MAAM,EAAG,0BAAyBxC,OAAO,CAACI,GAAR,CAAYF,IAAK;MADjD;IADmB,CAAvB,CAAN;EAKH;AACJ,CATD;;AAeA,MAAMuC,SAAS,GAAG,IAAIC,oBAAJ,CAA4B,CAAC;EAAEC,MAAF;EAAUC,SAAV;EAAqB5C;AAArB,CAAD,KAAoC;EAC9E2C,MAAM,CAAC,2CAAD,EAA8C,OAAOE,OAAP,EAAgBC,KAAhB,KAA0B;IAC1E,IAAI;MACA,MAAMZ,mBAAmB,CAAClC,OAAD,CAAzB;IACH,CAFD,CAEE,OAAO+C,EAAP,EAAW;MACT,OAAOD,KAAK,CAACxC,IAAN,CAAW,GAAX,EAAgB0C,IAAhB,CAAqB;QACxBT,IAAI,EAAE,IADkB;QAExBU,KAAK,EAAE;UACHC,OAAO,EAAEH,EAAE,CAACG,OAAH,IAAc,iBADpB;UAEH5C,IAAI,EAAEyC,EAAE,CAACzC,IAAH,IAAW,yBAFd;UAGHiC,IAAI,EAAEQ,EAAE,CAACR,IAAH,IAAW,IAHd;UAIHY,KAAK,EAAE;QAJJ;MAFiB,CAArB,CAAP;IASH;;IAED,MAAM/B,MAAM,GAAG,MAAME,SAAS,CAAC;MAC3BtB,OAD2B;MAE3BC,MAAM,EAAED,OAAO,CAACI,GAAR,CAAYgD,SAAZ,EAFmB;MAG3BlD,IAAI,EAAEF,OAAO,CAACI,GAAR,CAAYF;IAHS,CAAD,CAA9B;IAKA,MAAMmD,IAA+C,GAAGR,OAAO,CAACQ,IAAhE;IACA,MAAMC,MAAM,GAAG,MAAM,IAAAC,2BAAA,EAAmBF,IAAnB,EAAyBjC,MAAzB,EAAiCpB,OAAjC,CAArB;IACA,OAAO8C,KAAK,CAACxC,IAAN,CAAW,GAAX,EAAgB0C,IAAhB,CAAqBM,MAArB,CAAP;EACH,CAvBK,CAAN;EAyBAV,SAAS,CAAC,2CAAD,EAA8C,OAAOY,CAAP,EAAUV,KAAV,KAAoB;IACvE,OAAOA,KAAK,CAACW,MAAN,GAAeT,IAAf,CAAoB,EAApB,CAAP;EACH,CAFQ,CAAT;AAGH,CA7BiB,CAAlB;;AA+BO,MAAMU,qBAAqB,GAAG,CAAC;EAAEC;AAAF,CAAD,KAA8D;EAC/F,OAAO,CACH,IAAIA,KAAK,GAAG,IAAAC,qBAAA,GAAH,GAAoB,EAA7B,CADG,EAEHnB,SAFG,EAGH;IACIvC,IAAI,EAAE;EADV,CAHG,CAAP;AAOH,CARM"}
@@ -2,4 +2,4 @@ import { GraphQLSchemaPlugin } from "@webiny/handler-graphql/types";
2
2
  import { GraphQLHandlerFactoryParams } from "./graphQLHandlerFactory";
3
3
  import { CmsContext } from "../types";
4
4
  export declare type CreateGraphQLParams = GraphQLHandlerFactoryParams;
5
- export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/handler").ContextPlugin<CmsContext> | GraphQLSchemaPlugin<CmsContext> | import("@webiny/plugins/types").PluginCollection)[];
5
+ export declare const createGraphQL: (params: CreateGraphQLParams) => (import("@webiny/api").ContextPlugin<CmsContext> | GraphQLSchemaPlugin<CmsContext> | import("@webiny/plugins/types").PluginCollection)[];
@@ -1,5 +1,5 @@
1
1
  import { CmsContext } from "../types";
2
- import { ContextPlugin } from "@webiny/handler";
2
+ import { ContextPlugin } from "@webiny/api";
3
3
  /**
4
4
  * We only register system schema plugin if the endpoint is not manage/preview/read.
5
5
  */
package/graphql/system.js CHANGED
@@ -7,7 +7,7 @@ exports.createSystemSchemaPlugin = void 0;
7
7
 
8
8
  var _handlerGraphql = require("@webiny/handler-graphql");
9
9
 
10
- var _handler = require("@webiny/handler");
10
+ var _api = require("@webiny/api");
11
11
 
12
12
  const emptyResolver = () => ({});
13
13
 
@@ -105,7 +105,7 @@ const plugin = {
105
105
  */
106
106
 
107
107
  const createSystemSchemaPlugin = () => {
108
- return new _handler.ContextPlugin(async context => {
108
+ return new _api.ContextPlugin(async context => {
109
109
  var _context$cms;
110
110
 
111
111
  if ((_context$cms = context.cms) !== null && _context$cms !== void 0 && _context$cms.type) {
@@ -1 +1 @@
1
- {"version":3,"names":["emptyResolver","plugin","name","type","schema","typeDefs","resolvers","Query","cms","Mutation","CmsQuery","version","_","__","context","getSystemVersion","e","ErrorResponse","CmsMutation","install","code","message","installSystem","Response","upgrade","args","upgradeSystem","createSystemSchemaPlugin","ContextPlugin","plugins","register"],"sources":["system.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { ContextPlugin } from \"@webiny/handler\";\n\nconst emptyResolver = () => ({});\n\nconst plugin: GraphQLSchemaPlugin<CmsContext> = {\n name: \"cms.graphql.schema.system\",\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n extend type Query {\n cms: CmsQuery\n }\n\n extend type Mutation {\n cms: CmsMutation\n }\n\n type CmsQuery {\n _empty: String\n }\n\n type CmsMutation {\n _empty: String\n }\n extend type CmsQuery {\n # Get installed version\n version: String\n }\n\n extend type CmsMutation {\n # Install CMS\n install: CmsBooleanResponse\n\n # Upgrade CMS\n upgrade(version: String!): CmsBooleanResponse\n }\n `,\n resolvers: {\n Query: {\n cms: emptyResolver\n },\n Mutation: {\n cms: emptyResolver\n },\n CmsQuery: {\n version: async (_: any, __: any, context: CmsContext) => {\n try {\n return context.cms.getSystemVersion();\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsMutation: {\n install: async (_: any, __: any, { cms }: CmsContext) => {\n try {\n const version = await cms.getSystemVersion();\n if (version) {\n return new ErrorResponse({\n code: \"CMS_INSTALLATION_ERROR\",\n message: \"CMS is already installed.\"\n });\n }\n\n await cms.installSystem();\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n upgrade: async (_: any, args: any, { cms }: CmsContext) => {\n const { version } = args;\n try {\n await cms.upgradeSystem(version);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n }\n }\n};\n/**\n * We only register system schema plugin if the endpoint is not manage/preview/read.\n */\nexport const createSystemSchemaPlugin = (): ContextPlugin<CmsContext> => {\n return new ContextPlugin<CmsContext>(async context => {\n if (context.cms?.type) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;;AAEA,MAAMC,MAAuC,GAAG;EAC5CC,IAAI,EAAE,2BADsC;EAE5CC,IAAI,EAAE,gBAFsC;EAG5CC,MAAM,EAAE;IACJC,QAAQ;IAAE;IAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SA7BY;IA8BJC,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,GAAG,EAAER;MADF,CADA;MAIPS,QAAQ,EAAE;QACND,GAAG,EAAER;MADC,CAJH;MAOPU,QAAQ,EAAE;QACNC,OAAO,EAAE,OAAOC,CAAP,EAAeC,EAAf,EAAwBC,OAAxB,KAAgD;UACrD,IAAI;YACA,OAAOA,OAAO,CAACN,GAAR,CAAYO,gBAAZ,EAAP;UACH,CAFD,CAEE,OAAOC,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ;MAPK,CAPH;MAgBPE,WAAW,EAAE;QACTC,OAAO,EAAE,OAAOP,CAAP,EAAeC,EAAf,EAAwB;UAAEL;QAAF,CAAxB,KAAgD;UACrD,IAAI;YACA,MAAMG,OAAO,GAAG,MAAMH,GAAG,CAACO,gBAAJ,EAAtB;;YACA,IAAIJ,OAAJ,EAAa;cACT,OAAO,IAAIM,6BAAJ,CAAkB;gBACrBG,IAAI,EAAE,wBADe;gBAErBC,OAAO,EAAE;cAFY,CAAlB,CAAP;YAIH;;YAED,MAAMb,GAAG,CAACc,aAAJ,EAAN;YACA,OAAO,IAAIC,wBAAJ,CAAa,IAAb,CAAP;UACH,CAXD,CAWE,OAAOP,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ,CAhBQ;QAiBTQ,OAAO,EAAE,OAAOZ,CAAP,EAAea,IAAf,EAA0B;UAAEjB;QAAF,CAA1B,KAAkD;UACvD,MAAM;YAAEG;UAAF,IAAcc,IAApB;;UACA,IAAI;YACA,MAAMjB,GAAG,CAACkB,aAAJ,CAAkBf,OAAlB,CAAN;YACA,OAAO,IAAIY,wBAAJ,CAAa,IAAb,CAAP;UACH,CAHD,CAGE,OAAOP,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ;MAzBQ;IAhBN;EA9BP;AAHoC,CAAhD;AA+EA;AACA;AACA;;AACO,MAAMW,wBAAwB,GAAG,MAAiC;EACrE,OAAO,IAAIC,sBAAJ,CAA8B,MAAMd,OAAN,IAAiB;IAAA;;IAClD,oBAAIA,OAAO,CAACN,GAAZ,yCAAI,aAAaL,IAAjB,EAAuB;MACnB;IACH;;IACDW,OAAO,CAACe,OAAR,CAAgBC,QAAhB,CAAyB7B,MAAzB;EACH,CALM,CAAP;AAMH,CAPM"}
1
+ {"version":3,"names":["emptyResolver","plugin","name","type","schema","typeDefs","resolvers","Query","cms","Mutation","CmsQuery","version","_","__","context","getSystemVersion","e","ErrorResponse","CmsMutation","install","code","message","installSystem","Response","upgrade","args","upgradeSystem","createSystemSchemaPlugin","ContextPlugin","plugins","register"],"sources":["system.ts"],"sourcesContent":["import { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\nimport { GraphQLSchemaPlugin } from \"@webiny/handler-graphql/types\";\nimport { ContextPlugin } from \"@webiny/api\";\n\nconst emptyResolver = () => ({});\n\nconst plugin: GraphQLSchemaPlugin<CmsContext> = {\n name: \"cms.graphql.schema.system\",\n type: \"graphql-schema\",\n schema: {\n typeDefs: /* GraphQL */ `\n extend type Query {\n cms: CmsQuery\n }\n\n extend type Mutation {\n cms: CmsMutation\n }\n\n type CmsQuery {\n _empty: String\n }\n\n type CmsMutation {\n _empty: String\n }\n extend type CmsQuery {\n # Get installed version\n version: String\n }\n\n extend type CmsMutation {\n # Install CMS\n install: CmsBooleanResponse\n\n # Upgrade CMS\n upgrade(version: String!): CmsBooleanResponse\n }\n `,\n resolvers: {\n Query: {\n cms: emptyResolver\n },\n Mutation: {\n cms: emptyResolver\n },\n CmsQuery: {\n version: async (_: any, __: any, context: CmsContext) => {\n try {\n return context.cms.getSystemVersion();\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n },\n CmsMutation: {\n install: async (_: any, __: any, { cms }: CmsContext) => {\n try {\n const version = await cms.getSystemVersion();\n if (version) {\n return new ErrorResponse({\n code: \"CMS_INSTALLATION_ERROR\",\n message: \"CMS is already installed.\"\n });\n }\n\n await cms.installSystem();\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n },\n upgrade: async (_: any, args: any, { cms }: CmsContext) => {\n const { version } = args;\n try {\n await cms.upgradeSystem(version);\n return new Response(true);\n } catch (e) {\n return new ErrorResponse(e);\n }\n }\n }\n }\n }\n};\n/**\n * We only register system schema plugin if the endpoint is not manage/preview/read.\n */\nexport const createSystemSchemaPlugin = (): ContextPlugin<CmsContext> => {\n return new ContextPlugin<CmsContext>(async context => {\n if (context.cms?.type) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,aAAa,GAAG,OAAO,EAAP,CAAtB;;AAEA,MAAMC,MAAuC,GAAG;EAC5CC,IAAI,EAAE,2BADsC;EAE5CC,IAAI,EAAE,gBAFsC;EAG5CC,MAAM,EAAE;IACJC,QAAQ;IAAE;IAAe;AACjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SA7BY;IA8BJC,SAAS,EAAE;MACPC,KAAK,EAAE;QACHC,GAAG,EAAER;MADF,CADA;MAIPS,QAAQ,EAAE;QACND,GAAG,EAAER;MADC,CAJH;MAOPU,QAAQ,EAAE;QACNC,OAAO,EAAE,OAAOC,CAAP,EAAeC,EAAf,EAAwBC,OAAxB,KAAgD;UACrD,IAAI;YACA,OAAOA,OAAO,CAACN,GAAR,CAAYO,gBAAZ,EAAP;UACH,CAFD,CAEE,OAAOC,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ;MAPK,CAPH;MAgBPE,WAAW,EAAE;QACTC,OAAO,EAAE,OAAOP,CAAP,EAAeC,EAAf,EAAwB;UAAEL;QAAF,CAAxB,KAAgD;UACrD,IAAI;YACA,MAAMG,OAAO,GAAG,MAAMH,GAAG,CAACO,gBAAJ,EAAtB;;YACA,IAAIJ,OAAJ,EAAa;cACT,OAAO,IAAIM,6BAAJ,CAAkB;gBACrBG,IAAI,EAAE,wBADe;gBAErBC,OAAO,EAAE;cAFY,CAAlB,CAAP;YAIH;;YAED,MAAMb,GAAG,CAACc,aAAJ,EAAN;YACA,OAAO,IAAIC,wBAAJ,CAAa,IAAb,CAAP;UACH,CAXD,CAWE,OAAOP,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ,CAhBQ;QAiBTQ,OAAO,EAAE,OAAOZ,CAAP,EAAea,IAAf,EAA0B;UAAEjB;QAAF,CAA1B,KAAkD;UACvD,MAAM;YAAEG;UAAF,IAAcc,IAApB;;UACA,IAAI;YACA,MAAMjB,GAAG,CAACkB,aAAJ,CAAkBf,OAAlB,CAAN;YACA,OAAO,IAAIY,wBAAJ,CAAa,IAAb,CAAP;UACH,CAHD,CAGE,OAAOP,CAAP,EAAU;YACR,OAAO,IAAIC,6BAAJ,CAAkBD,CAAlB,CAAP;UACH;QACJ;MAzBQ;IAhBN;EA9BP;AAHoC,CAAhD;AA+EA;AACA;AACA;;AACO,MAAMW,wBAAwB,GAAG,MAAiC;EACrE,OAAO,IAAIC,kBAAJ,CAA8B,MAAMd,OAAN,IAAiB;IAAA;;IAClD,oBAAIA,OAAO,CAACN,GAAZ,yCAAI,aAAaL,IAAjB,EAAuB;MACnB;IACH;;IACDW,OAAO,CAACe,OAAR,CAAgBC,QAAhB,CAAyB7B,MAAzB;EACH,CALM,CAAP;AAMH,CAPM"}
@@ -27,13 +27,13 @@ const attachRequiredFieldValue = (def, field) => {
27
27
 
28
28
  return `${def}!`;
29
29
  };
30
+
31
+ exports.attachRequiredFieldValue = attachRequiredFieldValue;
32
+ const envVars = ["HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM", "WEBINY_HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM"];
30
33
  /**
31
34
  * Method creates single and multiple values fields.
32
35
  */
33
36
 
34
-
35
- exports.attachRequiredFieldValue = attachRequiredFieldValue;
36
-
37
37
  const createGraphQLInputField = (field, graphQlType) => {
38
38
  const singleRequired = getIsRequired(field.validation) ? "!" : "";
39
39
 
@@ -42,7 +42,7 @@ const createGraphQLInputField = (field, graphQlType) => {
42
42
  }
43
43
 
44
44
  const multipleRequired = getIsRequired(field.listValidation) ? "!" : "";
45
- const itemRequired = process.env.HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM === "false" ? "" : "!";
45
+ const itemRequired = envVars.some(v => process.env[v] === "false") ? "" : "!";
46
46
  return `${field.fieldId}: [${graphQlType}${itemRequired}]${multipleRequired}`;
47
47
  };
48
48
 
@@ -1 +1 @@
1
- {"version":3,"names":["requiredValidationName","getIsRequired","validations","some","validation","name","attachRequiredFieldValue","def","field","length","isRequired","createGraphQLInputField","graphQlType","singleRequired","multipleValues","fieldId","multipleRequired","listValidation","itemRequired","process","env","HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM"],"sources":["helpers.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldValidation } from \"~/types\";\n\nconst requiredValidationName = \"required\";\n\nconst getIsRequired = (validations?: CmsModelFieldValidation[]): boolean => {\n return (validations || []).some(validation => {\n return validation.name === requiredValidationName;\n });\n};\n\nexport const attachRequiredFieldValue = (def: string, field: CmsModelField): string => {\n if (!field.validation || field.validation.length === 0) {\n return def;\n }\n const isRequired = field.validation.some(validation => {\n return validation.name === \"required\";\n });\n if (!isRequired) {\n return def;\n }\n return `${def}!`;\n};\n/**\n * Method creates single and multiple values fields.\n */\nexport const createGraphQLInputField = (field: CmsModelField, graphQlType: string): string => {\n const singleRequired = getIsRequired(field.validation) ? \"!\" : \"\";\n if (!field.multipleValues) {\n return `${field.fieldId}: ${graphQlType}${singleRequired}`;\n }\n const multipleRequired = getIsRequired(field.listValidation) ? \"!\" : \"\";\n\n const itemRequired =\n process.env.HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM === \"false\" ? \"\" : \"!\";\n\n return `${field.fieldId}: [${graphQlType}${itemRequired}]${multipleRequired}`;\n};\n"],"mappings":";;;;;;AAEA,MAAMA,sBAAsB,GAAG,UAA/B;;AAEA,MAAMC,aAAa,GAAIC,WAAD,IAAsD;EACxE,OAAO,CAACA,WAAW,IAAI,EAAhB,EAAoBC,IAApB,CAAyBC,UAAU,IAAI;IAC1C,OAAOA,UAAU,CAACC,IAAX,KAAoBL,sBAA3B;EACH,CAFM,CAAP;AAGH,CAJD;;AAMO,MAAMM,wBAAwB,GAAG,CAACC,GAAD,EAAcC,KAAd,KAA+C;EACnF,IAAI,CAACA,KAAK,CAACJ,UAAP,IAAqBI,KAAK,CAACJ,UAAN,CAAiBK,MAAjB,KAA4B,CAArD,EAAwD;IACpD,OAAOF,GAAP;EACH;;EACD,MAAMG,UAAU,GAAGF,KAAK,CAACJ,UAAN,CAAiBD,IAAjB,CAAsBC,UAAU,IAAI;IACnD,OAAOA,UAAU,CAACC,IAAX,KAAoB,UAA3B;EACH,CAFkB,CAAnB;;EAGA,IAAI,CAACK,UAAL,EAAiB;IACb,OAAOH,GAAP;EACH;;EACD,OAAQ,GAAEA,GAAI,GAAd;AACH,CAXM;AAYP;AACA;AACA;;;;;AACO,MAAMI,uBAAuB,GAAG,CAACH,KAAD,EAAuBI,WAAvB,KAAuD;EAC1F,MAAMC,cAAc,GAAGZ,aAAa,CAACO,KAAK,CAACJ,UAAP,CAAb,GAAkC,GAAlC,GAAwC,EAA/D;;EACA,IAAI,CAACI,KAAK,CAACM,cAAX,EAA2B;IACvB,OAAQ,GAAEN,KAAK,CAACO,OAAQ,KAAIH,WAAY,GAAEC,cAAe,EAAzD;EACH;;EACD,MAAMG,gBAAgB,GAAGf,aAAa,CAACO,KAAK,CAACS,cAAP,CAAb,GAAsC,GAAtC,GAA4C,EAArE;EAEA,MAAMC,YAAY,GACdC,OAAO,CAACC,GAAR,CAAYC,6CAAZ,KAA8D,OAA9D,GAAwE,EAAxE,GAA6E,GADjF;EAGA,OAAQ,GAAEb,KAAK,CAACO,OAAQ,MAAKH,WAAY,GAAEM,YAAa,IAAGF,gBAAiB,EAA5E;AACH,CAXM"}
1
+ {"version":3,"names":["requiredValidationName","getIsRequired","validations","some","validation","name","attachRequiredFieldValue","def","field","length","isRequired","envVars","createGraphQLInputField","graphQlType","singleRequired","multipleValues","fieldId","multipleRequired","listValidation","itemRequired","v","process","env"],"sources":["helpers.ts"],"sourcesContent":["import { CmsModelField, CmsModelFieldValidation } from \"~/types\";\n\nconst requiredValidationName = \"required\";\n\nconst getIsRequired = (validations?: CmsModelFieldValidation[]): boolean => {\n return (validations || []).some(validation => {\n return validation.name === requiredValidationName;\n });\n};\n\nexport const attachRequiredFieldValue = (def: string, field: CmsModelField): string => {\n if (!field.validation || field.validation.length === 0) {\n return def;\n }\n const isRequired = field.validation.some(validation => {\n return validation.name === \"required\";\n });\n if (!isRequired) {\n return def;\n }\n return `${def}!`;\n};\n\nconst envVars: string[] = [\n \"HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM\",\n \"WEBINY_HEADLESS_CMS_GRAPHQL_INPUT_REQUIRE_ARRAY_ITEM\"\n];\n/**\n * Method creates single and multiple values fields.\n */\nexport const createGraphQLInputField = (field: CmsModelField, graphQlType: string): string => {\n const singleRequired = getIsRequired(field.validation) ? \"!\" : \"\";\n if (!field.multipleValues) {\n return `${field.fieldId}: ${graphQlType}${singleRequired}`;\n }\n const multipleRequired = getIsRequired(field.listValidation) ? \"!\" : \"\";\n\n const itemRequired = envVars.some(v => process.env[v] === \"false\") ? \"\" : \"!\";\n\n return `${field.fieldId}: [${graphQlType}${itemRequired}]${multipleRequired}`;\n};\n"],"mappings":";;;;;;AAEA,MAAMA,sBAAsB,GAAG,UAA/B;;AAEA,MAAMC,aAAa,GAAIC,WAAD,IAAsD;EACxE,OAAO,CAACA,WAAW,IAAI,EAAhB,EAAoBC,IAApB,CAAyBC,UAAU,IAAI;IAC1C,OAAOA,UAAU,CAACC,IAAX,KAAoBL,sBAA3B;EACH,CAFM,CAAP;AAGH,CAJD;;AAMO,MAAMM,wBAAwB,GAAG,CAACC,GAAD,EAAcC,KAAd,KAA+C;EACnF,IAAI,CAACA,KAAK,CAACJ,UAAP,IAAqBI,KAAK,CAACJ,UAAN,CAAiBK,MAAjB,KAA4B,CAArD,EAAwD;IACpD,OAAOF,GAAP;EACH;;EACD,MAAMG,UAAU,GAAGF,KAAK,CAACJ,UAAN,CAAiBD,IAAjB,CAAsBC,UAAU,IAAI;IACnD,OAAOA,UAAU,CAACC,IAAX,KAAoB,UAA3B;EACH,CAFkB,CAAnB;;EAGA,IAAI,CAACK,UAAL,EAAiB;IACb,OAAOH,GAAP;EACH;;EACD,OAAQ,GAAEA,GAAI,GAAd;AACH,CAXM;;;AAaP,MAAMI,OAAiB,GAAG,CACtB,+CADsB,EAEtB,sDAFsB,CAA1B;AAIA;AACA;AACA;;AACO,MAAMC,uBAAuB,GAAG,CAACJ,KAAD,EAAuBK,WAAvB,KAAuD;EAC1F,MAAMC,cAAc,GAAGb,aAAa,CAACO,KAAK,CAACJ,UAAP,CAAb,GAAkC,GAAlC,GAAwC,EAA/D;;EACA,IAAI,CAACI,KAAK,CAACO,cAAX,EAA2B;IACvB,OAAQ,GAAEP,KAAK,CAACQ,OAAQ,KAAIH,WAAY,GAAEC,cAAe,EAAzD;EACH;;EACD,MAAMG,gBAAgB,GAAGhB,aAAa,CAACO,KAAK,CAACU,cAAP,CAAb,GAAsC,GAAtC,GAA4C,EAArE;EAEA,MAAMC,YAAY,GAAGR,OAAO,CAACR,IAAR,CAAaiB,CAAC,IAAIC,OAAO,CAACC,GAAR,CAAYF,CAAZ,MAAmB,OAArC,IAAgD,EAAhD,GAAqD,GAA1E;EAEA,OAAQ,GAAEZ,KAAK,CAACQ,OAAQ,MAAKH,WAAY,GAAEM,YAAa,IAAGF,gBAAiB,EAA5E;AACH,CAVM"}
package/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  import { CreateGraphQLParams } from "./graphql";
2
2
  import { CrudParams } from "./crud";
3
- import { ContextPlugin } from "@webiny/handler";
4
- import { CmsContext } from "./types";
5
3
  import { entryFieldFromStorageTransform, entryFromStorageTransform, entryToStorageTransform } from "./utils/entryStorage";
6
4
  export declare type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;
7
- export declare const createHeadlessCmsGraphQL: (params?: CreateHeadlessCmsGraphQLParams) => (import("./plugins").CmsParametersPlugin | ContextPlugin<CmsContext> | (ContextPlugin<CmsContext> | import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<CmsContext> | import("@webiny/plugins/types").PluginCollection)[])[];
5
+ export declare const createHeadlessCmsGraphQL: (params?: CreateHeadlessCmsGraphQLParams) => (import("./plugins").CmsParametersPlugin | (import("@webiny/api").ContextPlugin<import("./types").CmsContext> | import("@webiny/handler-graphql/types").GraphQLSchemaPlugin<import("./types").CmsContext> | import("@webiny/plugins/types").PluginCollection)[])[];
8
6
  export declare type ContentContextParams = CrudParams;
9
- export declare const createHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | ContextPlugin<CmsContext> | import("./plugins").StorageTransformPlugin<any, any> | import("./types").CmsModelFieldToGraphQLPlugin[] | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[])[];
7
+ export declare const createHeadlessCmsContext: (params: ContentContextParams) => (import("./types").ModelManagerPlugin | import("@webiny/api").ContextPlugin<import("./types").CmsContext> | import("./plugins").StorageTransformPlugin<any, any> | import("./types").CmsModelFieldToGraphQLPlugin[] | (import("./types").CmsModelFieldValidatorPlugin | import("./types").CmsModelFieldPatternValidatorPlugin[])[])[];
10
8
  export * from "./graphqlFields";
11
9
  export * from "./plugins";
12
10
  export { entryToStorageTransform, entryFieldFromStorageTransform, entryFromStorageTransform };
package/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -32,8 +30,6 @@ Object.defineProperty(exports, "entryToStorageTransform", {
32
30
  }
33
31
  });
34
32
 
35
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
36
-
37
33
  var _graphql = require("./graphql");
38
34
 
39
35
  var _upgrades = require("./upgrades");
@@ -64,10 +60,6 @@ var _object = require("./storage/object");
64
60
 
65
61
  var _parameters = require("./parameters");
66
62
 
67
- var _handler = require("@webiny/handler");
68
-
69
- var _utils = require("@webiny/utils");
70
-
71
63
  var _context = require("./context");
72
64
 
73
65
  var _entryStorage = require("./utils/entryStorage");
@@ -86,46 +78,8 @@ Object.keys(_plugins).forEach(function (key) {
86
78
  });
87
79
  });
88
80
 
89
- 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; }
90
-
91
- 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; }
92
-
93
- const DEFAULT_HEADERS = _objectSpread({
94
- "Access-Control-Allow-Origin": "*",
95
- "Access-Control-Allow-Headers": "*",
96
- "Access-Control-Allow-Methods": "OPTIONS,POST",
97
- "Content-Type": "application/json"
98
- }, (0, _utils.getWebinyVersionHeaders)());
99
-
100
- const DEFAULT_CACHE_MAX_AGE = 30758400; // 1 year
101
-
102
- const OPTIONS_HEADERS = {
103
- "Access-Control-Max-Age": `${DEFAULT_CACHE_MAX_AGE}`,
104
- "Cache-Control": `public, max-age=${DEFAULT_CACHE_MAX_AGE}`
105
- };
106
-
107
- const breakOptionsRequestContextPlugin = () => {
108
- const plugin = new _handler.ContextPlugin(async context => {
109
- var _context$http, _context$http$request;
110
-
111
- 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();
112
-
113
- if (method !== "options") {
114
- return;
115
- }
116
-
117
- context.setResult({
118
- statusCode: 204,
119
- body: "",
120
- headers: _objectSpread(_objectSpread({}, DEFAULT_HEADERS), OPTIONS_HEADERS)
121
- });
122
- });
123
- plugin.name = "break-options-request";
124
- return plugin;
125
- };
126
-
127
81
  const createHeadlessCmsGraphQL = (params = {}) => {
128
- return [breakOptionsRequestContextPlugin(),
82
+ return [
129
83
  /**
130
84
  * PathParameter plugins are used to determine the type of the cms endpoint
131
85
  */
@@ -139,7 +93,7 @@ const createHeadlessCmsGraphQL = (params = {}) => {
139
93
  exports.createHeadlessCmsGraphQL = createHeadlessCmsGraphQL;
140
94
 
141
95
  const createHeadlessCmsContext = params => {
142
- return [breakOptionsRequestContextPlugin(),
96
+ return [
143
97
  /**
144
98
  * Context for all Lambdas - everything is loaded now.
145
99
  */
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["DEFAULT_HEADERS","getWebinyVersionHeaders","DEFAULT_CACHE_MAX_AGE","OPTIONS_HEADERS","breakOptionsRequestContextPlugin","plugin","ContextPlugin","context","method","http","request","toLowerCase","setResult","statusCode","body","headers","name","createHeadlessCmsGraphQL","params","createPathParameterPlugin","createHeaderParameterPlugin","createContextParameterPlugin","baseCreateGraphQL","createHeadlessCmsContext","createContextPlugin","createDefaultModelManager","createCrud","createGraphQLFields","createValidators","createDefaultStorageTransform","createObjectStorageTransform","createUpgrades"],"sources":["index.ts"],"sourcesContent":["import { createGraphQL as baseCreateGraphQL, CreateGraphQLParams } from \"~/graphql\";\nimport { createUpgrades } from \"~/upgrades\";\nimport { createDefaultModelManager } from \"~/modelManager\";\nimport { createCrud, CrudParams } from \"~/crud\";\nimport { createGraphQLFields } from \"~/graphqlFields\";\nimport { createValidators } from \"~/validators\";\nimport { createDefaultStorageTransform } from \"~/storage/default\";\nimport { createObjectStorageTransform } from \"~/storage/object\";\nimport {\n createContextParameterPlugin,\n createHeaderParameterPlugin,\n createPathParameterPlugin\n} from \"~/parameters\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport { CmsContext } from \"~/types\";\nimport { getWebinyVersionHeaders } from \"@webiny/utils\";\nimport { createContextPlugin } from \"~/context\";\nimport {\n entryFieldFromStorageTransform,\n entryFromStorageTransform,\n entryToStorageTransform\n} from \"./utils/entryStorage\";\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 type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;\nexport const createHeadlessCmsGraphQL = (params: CreateHeadlessCmsGraphQLParams = {}) => {\n return [\n breakOptionsRequestContextPlugin(),\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 ];\n};\n\nexport type ContentContextParams = CrudParams;\nexport const createHeadlessCmsContext = (params: ContentContextParams) => {\n return [\n breakOptionsRequestContextPlugin(),\n /**\n * Context for all Lambdas - everything is loaded now.\n */\n createContextPlugin(),\n createDefaultModelManager(),\n /**\n *\n */\n createCrud(params),\n createGraphQLFields(),\n createValidators(),\n createDefaultStorageTransform(),\n createObjectStorageTransform(),\n createUpgrades()\n ];\n};\nexport * from \"~/graphqlFields\";\nexport * from \"~/plugins\";\nexport { entryToStorageTransform, entryFieldFromStorageTransform, entryFromStorageTransform };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AA2FA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AA1FA;;AACA;;AACA;;AACA;;AAKA;;AAEA;;AACA;;AACA;;AA+EA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;;;;;AAzEA,MAAMA,eAAuC;EACzC,+BAA+B,GADU;EAEzC,gCAAgC,GAFS;EAGzC,gCAAgC,cAHS;EAIzC,gBAAgB;AAJyB,GAKtC,IAAAC,8BAAA,GALsC,CAA7C;;AAQA,MAAMC,qBAAqB,GAAG,QAA9B,C,CAAwC;;AAExC,MAAMC,eAAuC,GAAG;EAC5C,0BAA2B,GAAED,qBAAsB,EADP;EAE5C,iBAAkB,mBAAkBA,qBAAsB;AAFd,CAAhD;;AAKA,MAAME,gCAAgC,GAAG,MAAiC;EACtE,MAAMC,MAAM,GAAG,IAAIC,sBAAJ,CAA8B,MAAMC,OAAN,IAAiB;IAAA;;IAC1D,MAAMC,MAAM,GAAG,CAAC,kBAAAD,OAAO,CAACE,IAAR,yFAAcC,OAAd,gFAAuBF,MAAvB,KAAiC,EAAlC,EAAsCG,WAAtC,EAAf;;IACA,IAAIH,MAAM,KAAK,SAAf,EAA0B;MACtB;IACH;;IACDD,OAAO,CAACK,SAAR,CAAkB;MACdC,UAAU,EAAE,GADE;MAEdC,IAAI,EAAE,EAFQ;MAGdC,OAAO,kCACAf,eADA,GAEAG,eAFA;IAHO,CAAlB;EAQH,CAbc,CAAf;EAcAE,MAAM,CAACW,IAAP,GAAc,uBAAd;EAEA,OAAOX,MAAP;AACH,CAlBD;;AAqBO,MAAMY,wBAAwB,GAAG,CAACC,MAAsC,GAAG,EAA1C,KAAiD;EACrF,OAAO,CACHd,gCAAgC,EAD7B;EAEH;AACR;AACA;EACQ,IAAAe,qCAAA,GALG,EAMH,IAAAC,uCAAA,GANG,EAOH,IAAAC,wCAAA,GAPG;EAQH;AACR;AACA;EACQ,IAAAC,sBAAA,EAAkBJ,MAAlB,CAXG,CAAP;AAaH,CAdM;;;;AAiBA,MAAMK,wBAAwB,GAAIL,MAAD,IAAkC;EACtE,OAAO,CACHd,gCAAgC,EAD7B;EAEH;AACR;AACA;EACQ,IAAAoB,4BAAA,GALG,EAMH,IAAAC,uCAAA,GANG;EAOH;AACR;AACA;EACQ,IAAAC,gBAAA,EAAWR,MAAX,CAVG,EAWH,IAAAS,kCAAA,GAXG,EAYH,IAAAC,4BAAA,GAZG,EAaH,IAAAC,sCAAA,GAbG,EAcH,IAAAC,oCAAA,GAdG,EAeH,IAAAC,wBAAA,GAfG,CAAP;AAiBH,CAlBM"}
1
+ {"version":3,"names":["createHeadlessCmsGraphQL","params","createPathParameterPlugin","createHeaderParameterPlugin","createContextParameterPlugin","baseCreateGraphQL","createHeadlessCmsContext","createContextPlugin","createDefaultModelManager","createCrud","createGraphQLFields","createValidators","createDefaultStorageTransform","createObjectStorageTransform","createUpgrades"],"sources":["index.ts"],"sourcesContent":["import { createGraphQL as baseCreateGraphQL, CreateGraphQLParams } from \"~/graphql\";\nimport { createUpgrades } from \"~/upgrades\";\nimport { createDefaultModelManager } from \"~/modelManager\";\nimport { createCrud, CrudParams } from \"~/crud\";\nimport { createGraphQLFields } from \"~/graphqlFields\";\nimport { createValidators } from \"~/validators\";\nimport { createDefaultStorageTransform } from \"~/storage/default\";\nimport { createObjectStorageTransform } from \"~/storage/object\";\nimport {\n createContextParameterPlugin,\n createHeaderParameterPlugin,\n createPathParameterPlugin\n} from \"~/parameters\";\nimport { createContextPlugin } from \"~/context\";\nimport {\n entryFieldFromStorageTransform,\n entryFromStorageTransform,\n entryToStorageTransform\n} from \"./utils/entryStorage\";\n\nexport type CreateHeadlessCmsGraphQLParams = CreateGraphQLParams;\nexport const createHeadlessCmsGraphQL = (params: CreateHeadlessCmsGraphQLParams = {}) => {\n return [\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 ];\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(),\n createDefaultModelManager(),\n /**\n *\n */\n createCrud(params),\n createGraphQLFields(),\n createValidators(),\n createDefaultStorageTransform(),\n createObjectStorageTransform(),\n createUpgrades()\n ];\n};\nexport * from \"~/graphqlFields\";\nexport * from \"~/plugins\";\nexport { entryToStorageTransform, entryFieldFromStorageTransform, entryFromStorageTransform };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAmDA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAlDA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AA0CA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAnCO,MAAMA,wBAAwB,GAAG,CAACC,MAAsC,GAAG,EAA1C,KAAiD;EACrF,OAAO;EACH;AACR;AACA;EACQ,IAAAC,qCAAA,GAJG,EAKH,IAAAC,uCAAA,GALG,EAMH,IAAAC,wCAAA,GANG;EAOH;AACR;AACA;EACQ,IAAAC,sBAAA,EAAkBJ,MAAlB,CAVG,CAAP;AAYH,CAbM;;;;AAgBA,MAAMK,wBAAwB,GAAIL,MAAD,IAAkC;EACtE,OAAO;EACH;AACR;AACA;EACQ,IAAAM,4BAAA,GAJG,EAKH,IAAAC,uCAAA,GALG;EAMH;AACR;AACA;EACQ,IAAAC,gBAAA,EAAWR,MAAX,CATG,EAUH,IAAAS,kCAAA,GAVG,EAWH,IAAAC,4BAAA,GAXG,EAYH,IAAAC,sCAAA,GAZG,EAaH,IAAAC,oCAAA,GAbG,EAcH,IAAAC,wBAAA,GAdG,CAAP;AAgBH,CAjBM"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/api-headless-cms",
3
- "version": "5.30.0-beta.1",
3
+ "version": "5.31.0-beta.1",
4
4
  "main": "index.js",
5
5
  "keywords": [
6
6
  "cms:base"
@@ -18,25 +18,25 @@
18
18
  ],
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@babel/runtime": "7.18.6",
21
+ "@babel/runtime": "7.18.9",
22
22
  "@commodo/fields": "1.1.2-beta.20",
23
23
  "@graphql-tools/schema": "7.1.5",
24
- "@webiny/api-file-manager": "5.30.0-beta.1",
25
- "@webiny/api-i18n": "5.30.0-beta.1",
26
- "@webiny/api-i18n-ddb": "5.30.0-beta.1",
27
- "@webiny/api-security": "5.30.0-beta.1",
28
- "@webiny/api-tenancy": "5.30.0-beta.1",
29
- "@webiny/api-upgrade": "5.30.0-beta.1",
30
- "@webiny/error": "5.30.0-beta.1",
31
- "@webiny/handler": "5.30.0-beta.1",
32
- "@webiny/handler-aws": "5.30.0-beta.1",
33
- "@webiny/handler-db": "5.30.0-beta.1",
34
- "@webiny/handler-graphql": "5.30.0-beta.1",
35
- "@webiny/handler-http": "5.30.0-beta.1",
36
- "@webiny/plugins": "5.30.0-beta.1",
37
- "@webiny/pubsub": "5.30.0-beta.1",
38
- "@webiny/utils": "5.30.0-beta.1",
39
- "@webiny/validation": "5.30.0-beta.1",
24
+ "@webiny/api": "5.31.0-beta.1",
25
+ "@webiny/api-file-manager": "5.31.0-beta.1",
26
+ "@webiny/api-i18n": "5.31.0-beta.1",
27
+ "@webiny/api-i18n-ddb": "5.31.0-beta.1",
28
+ "@webiny/api-security": "5.31.0-beta.1",
29
+ "@webiny/api-tenancy": "5.31.0-beta.1",
30
+ "@webiny/api-upgrade": "5.31.0-beta.1",
31
+ "@webiny/error": "5.31.0-beta.1",
32
+ "@webiny/handler": "5.31.0-beta.1",
33
+ "@webiny/handler-aws": "5.31.0-beta.1",
34
+ "@webiny/handler-db": "5.31.0-beta.1",
35
+ "@webiny/handler-graphql": "5.31.0-beta.1",
36
+ "@webiny/plugins": "5.31.0-beta.1",
37
+ "@webiny/pubsub": "5.31.0-beta.1",
38
+ "@webiny/utils": "5.31.0-beta.1",
39
+ "@webiny/validation": "5.31.0-beta.1",
40
40
  "commodo-fields-object": "1.0.6",
41
41
  "dataloader": "2.1.0",
42
42
  "dot-prop": "6.0.1",
@@ -53,11 +53,11 @@
53
53
  "@babel/core": "^7.16.0",
54
54
  "@babel/preset-env": "^7.16.4",
55
55
  "@babel/preset-flow": "^7.16.0",
56
- "@webiny/api-security-so-ddb": "^5.30.0-beta.1",
57
- "@webiny/api-tenancy-so-ddb": "^5.30.0-beta.1",
58
- "@webiny/api-wcp": "^5.30.0-beta.1",
59
- "@webiny/cli": "^5.30.0-beta.1",
60
- "@webiny/project-utils": "^5.30.0-beta.1",
56
+ "@webiny/api-security-so-ddb": "^5.31.0-beta.1",
57
+ "@webiny/api-tenancy-so-ddb": "^5.31.0-beta.1",
58
+ "@webiny/api-wcp": "^5.31.0-beta.1",
59
+ "@webiny/cli": "^5.31.0-beta.1",
60
+ "@webiny/project-utils": "^5.31.0-beta.1",
61
61
  "apollo-graphql": "^0.9.5",
62
62
  "get-yarn-workspaces": "^1.0.2",
63
63
  "graphql": "^15.7.2",
@@ -77,5 +77,5 @@
77
77
  "build": "yarn webiny run build",
78
78
  "watch": "yarn webiny run watch"
79
79
  },
80
- "gitHead": "d3b1e74ec1077a608fe40dfd3aba237b1b29a458"
80
+ "gitHead": "b29a1cdd4c7cba5af3b9b993a78f4561525a9201"
81
81
  }
@@ -20,33 +20,33 @@ var HeaderKeys;
20
20
 
21
21
  const createHeaderParameterPlugin = () => {
22
22
  return new _CmsParametersPlugin.CmsParametersPlugin(async context => {
23
- var _context$http, _context$http$request;
23
+ var _context$request;
24
24
 
25
25
  /**
26
26
  * If any of the properties is not defined, just ignore this plugin
27
27
  */
28
- if (!((_context$http = context.http) !== null && _context$http !== void 0 && (_context$http$request = _context$http.request) !== null && _context$http$request !== void 0 && _context$http$request.headers)) {
28
+ if (!((_context$request = context.request) !== null && _context$request !== void 0 && _context$request.headers)) {
29
29
  return null;
30
30
  }
31
31
 
32
- const headers = context.http.request.headers;
32
+ const headers = context.request.headers;
33
33
  const type = headers[HeaderKeys.TYPE];
34
34
  const locale = headers[HeaderKeys.LOCALE];
35
35
 
36
36
  if (!type && !locale) {
37
37
  return null;
38
- } else if (!locale) {
38
+ } else if (!locale || typeof locale !== "string") {
39
39
  throw new _error.default(`There is a "${HeaderKeys.TYPE}" header but no "${HeaderKeys.LOCALE}".`, "MALFORMED_HEADERS_ERROR", {
40
40
  headers
41
41
  });
42
- } else if (!type) {
42
+ } else if (!type || typeof type !== "string") {
43
43
  throw new _error.default(`There is a "${HeaderKeys.LOCALE}" header but no "${HeaderKeys.TYPE}".`, "MALFORMED_HEADERS_ERROR", {
44
44
  headers
45
45
  });
46
46
  }
47
47
 
48
48
  return {
49
- type,
49
+ type: type,
50
50
  locale
51
51
  };
52
52
  });
@@ -1 +1 @@
1
- {"version":3,"names":["HeaderKeys","createHeaderParameterPlugin","CmsParametersPlugin","context","http","request","headers","type","TYPE","locale","LOCALE","WebinyError"],"sources":["header.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\n\nenum HeaderKeys {\n TYPE = \"x-webiny-cms-endpoint\",\n LOCALE = \"x-webiny-cms-locale\"\n}\n\nexport const createHeaderParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.http?.request?.headers) {\n return null;\n }\n\n const headers = context.http.request.headers;\n\n const type = headers[HeaderKeys.TYPE];\n const locale = headers[HeaderKeys.LOCALE];\n\n if (!type && !locale) {\n return null;\n } else if (!locale) {\n throw new WebinyError(\n `There is a \"${HeaderKeys.TYPE}\" header but no \"${HeaderKeys.LOCALE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n } else if (!type) {\n throw new WebinyError(\n `There is a \"${HeaderKeys.LOCALE}\" header but no \"${HeaderKeys.TYPE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n }\n\n return {\n type,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;IAEKA,U;;WAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,KAAAA,U;;AAKE,MAAMC,2BAA2B,GAAG,MAAM;EAC7C,OAAO,IAAIC,wCAAJ,CAAwB,MAAMC,OAAN,IAAiB;IAAA;;IAC5C;AACR;AACA;IACQ,IAAI,mBAACA,OAAO,CAACC,IAAT,mEAAC,cAAcC,OAAf,kDAAC,sBAAuBC,OAAxB,CAAJ,EAAqC;MACjC,OAAO,IAAP;IACH;;IAED,MAAMA,OAAO,GAAGH,OAAO,CAACC,IAAR,CAAaC,OAAb,CAAqBC,OAArC;IAEA,MAAMC,IAAI,GAAGD,OAAO,CAACN,UAAU,CAACQ,IAAZ,CAApB;IACA,MAAMC,MAAM,GAAGH,OAAO,CAACN,UAAU,CAACU,MAAZ,CAAtB;;IAEA,IAAI,CAACH,IAAD,IAAS,CAACE,MAAd,EAAsB;MAClB,OAAO,IAAP;IACH,CAFD,MAEO,IAAI,CAACA,MAAL,EAAa;MAChB,MAAM,IAAIE,cAAJ,CACD,eAAcX,UAAU,CAACQ,IAAK,oBAAmBR,UAAU,CAACU,MAAO,IADlE,EAEF,yBAFE,EAGF;QACIJ;MADJ,CAHE,CAAN;IAOH,CARM,MAQA,IAAI,CAACC,IAAL,EAAW;MACd,MAAM,IAAII,cAAJ,CACD,eAAcX,UAAU,CAACU,MAAO,oBAAmBV,UAAU,CAACQ,IAAK,IADlE,EAEF,yBAFE,EAGF;QACIF;MADJ,CAHE,CAAN;IAOH;;IAED,OAAO;MACHC,IADG;MAEHE;IAFG,CAAP;EAIH,CArCM,CAAP;AAsCH,CAvCM"}
1
+ {"version":3,"names":["HeaderKeys","createHeaderParameterPlugin","CmsParametersPlugin","context","request","headers","type","TYPE","locale","LOCALE","WebinyError"],"sources":["header.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nenum HeaderKeys {\n TYPE = \"x-webiny-cms-endpoint\",\n LOCALE = \"x-webiny-cms-locale\"\n}\n\nexport const createHeaderParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.request?.headers) {\n return null;\n }\n\n const headers = context.request.headers;\n\n const type = headers[HeaderKeys.TYPE];\n const locale = headers[HeaderKeys.LOCALE];\n\n if (!type && !locale) {\n return null;\n } else if (!locale || typeof locale !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.TYPE}\" header but no \"${HeaderKeys.LOCALE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n } else if (!type || typeof type !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.LOCALE}\" header but no \"${HeaderKeys.TYPE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;IAGKA,U;;WAAAA,U;EAAAA,U;EAAAA,U;GAAAA,U,KAAAA,U;;AAKE,MAAMC,2BAA2B,GAAG,MAAM;EAC7C,OAAO,IAAIC,wCAAJ,CAAwB,MAAMC,OAAN,IAAiB;IAAA;;IAC5C;AACR;AACA;IACQ,IAAI,sBAACA,OAAO,CAACC,OAAT,6CAAC,iBAAiBC,OAAlB,CAAJ,EAA+B;MAC3B,OAAO,IAAP;IACH;;IAED,MAAMA,OAAO,GAAGF,OAAO,CAACC,OAAR,CAAgBC,OAAhC;IAEA,MAAMC,IAAI,GAAGD,OAAO,CAACL,UAAU,CAACO,IAAZ,CAApB;IACA,MAAMC,MAAM,GAAGH,OAAO,CAACL,UAAU,CAACS,MAAZ,CAAtB;;IAEA,IAAI,CAACH,IAAD,IAAS,CAACE,MAAd,EAAsB;MAClB,OAAO,IAAP;IACH,CAFD,MAEO,IAAI,CAACA,MAAD,IAAW,OAAOA,MAAP,KAAkB,QAAjC,EAA2C;MAC9C,MAAM,IAAIE,cAAJ,CACD,eAAcV,UAAU,CAACO,IAAK,oBAAmBP,UAAU,CAACS,MAAO,IADlE,EAEF,yBAFE,EAGF;QACIJ;MADJ,CAHE,CAAN;IAOH,CARM,MAQA,IAAI,CAACC,IAAD,IAAS,OAAOA,IAAP,KAAgB,QAA7B,EAAuC;MAC1C,MAAM,IAAII,cAAJ,CACD,eAAcV,UAAU,CAACS,MAAO,oBAAmBT,UAAU,CAACO,IAAK,IADlE,EAEF,yBAFE,EAGF;QACIF;MADJ,CAHE,CAAN;IAOH;;IAED,OAAO;MACHC,IAAI,EAAEA,IADH;MAEHE;IAFG,CAAP;EAIH,CArCM,CAAP;AAsCH,CAvCM"}
@@ -15,31 +15,28 @@ const allowedEndpoints = ["manage", "read", "preview"];
15
15
 
16
16
  const createPathParameterPlugin = () => {
17
17
  return new _CmsParametersPlugin.CmsParametersPlugin(async context => {
18
- var _context$http, _context$http$request, _context$http$request2;
18
+ var _context$request;
19
19
 
20
20
  /**
21
21
  * If any of the properties is not defined, just ignore this plugin
22
22
  */
23
- if (!((_context$http = context.http) !== null && _context$http !== void 0 && (_context$http$request = _context$http.request) !== null && _context$http$request !== void 0 && (_context$http$request2 = _context$http$request.path) !== null && _context$http$request2 !== void 0 && _context$http$request2.parameters)) {
23
+ if (!((_context$request = context.request) !== null && _context$request !== void 0 && _context$request.params)) {
24
24
  return null;
25
25
  }
26
26
 
27
27
  const {
28
- key
29
- } = context.http.request.path.parameters;
28
+ type,
29
+ locale
30
+ } = context.request.params;
30
31
 
31
- if (typeof key !== "string") {
32
- throw new _error.default("The key property in context.http.request.path.parameters is not a string.", "MALFORMED_KEY", {
33
- key
34
- });
32
+ if (!type && !locale) {
33
+ return null;
35
34
  }
36
35
 
37
- const [type, locale] = key.split("/");
38
-
39
36
  if (!type) {
40
- throw new _error.default(`Missing context.http.request.path.parameters.key parameter "type".`);
37
+ throw new _error.default(`Missing request parameter "type".`);
41
38
  } else if (!locale) {
42
- throw new _error.default(`Missing context.http.request.path.parameters.key "locale".`);
39
+ throw new _error.default(`Missing request parameter "locale".`);
43
40
  } else if (allowedEndpoints.includes(type) === false) {
44
41
  throw new _error.default(`Endpoint "${type}" not allowed!`);
45
42
  }
@@ -1 +1 @@
1
- {"version":3,"names":["allowedEndpoints","createPathParameterPlugin","CmsParametersPlugin","context","http","request","path","parameters","key","WebinyError","type","locale","split","includes"],"sources":["path.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nconst allowedEndpoints: ApiEndpoint[] = [\"manage\", \"read\", \"preview\"];\n\nexport const createPathParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.http?.request?.path?.parameters) {\n return null;\n }\n\n const { key } = context.http.request.path.parameters;\n if (typeof key !== \"string\") {\n throw new WebinyError(\n \"The key property in context.http.request.path.parameters is not a string.\",\n \"MALFORMED_KEY\",\n {\n key\n }\n );\n }\n const [type, locale] = key.split(\"/\");\n if (!type) {\n throw new WebinyError(\n `Missing context.http.request.path.parameters.key parameter \"type\".`\n );\n } else if (!locale) {\n throw new WebinyError(`Missing context.http.request.path.parameters.key \"locale\".`);\n } else if (allowedEndpoints.includes(type as ApiEndpoint) === false) {\n throw new WebinyError(`Endpoint \"${type}\" not allowed!`);\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA,MAAMA,gBAA+B,GAAG,CAAC,QAAD,EAAW,MAAX,EAAmB,SAAnB,CAAxC;;AAEO,MAAMC,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,wCAAJ,CAAwB,MAAMC,OAAN,IAAiB;IAAA;;IAC5C;AACR;AACA;IACQ,IAAI,mBAACA,OAAO,CAACC,IAAT,mEAAC,cAAcC,OAAf,4EAAC,sBAAuBC,IAAxB,mDAAC,uBAA6BC,UAA9B,CAAJ,EAA8C;MAC1C,OAAO,IAAP;IACH;;IAED,MAAM;MAAEC;IAAF,IAAUL,OAAO,CAACC,IAAR,CAAaC,OAAb,CAAqBC,IAArB,CAA0BC,UAA1C;;IACA,IAAI,OAAOC,GAAP,KAAe,QAAnB,EAA6B;MACzB,MAAM,IAAIC,cAAJ,CACF,2EADE,EAEF,eAFE,EAGF;QACID;MADJ,CAHE,CAAN;IAOH;;IACD,MAAM,CAACE,IAAD,EAAOC,MAAP,IAAiBH,GAAG,CAACI,KAAJ,CAAU,GAAV,CAAvB;;IACA,IAAI,CAACF,IAAL,EAAW;MACP,MAAM,IAAID,cAAJ,CACD,oEADC,CAAN;IAGH,CAJD,MAIO,IAAI,CAACE,MAAL,EAAa;MAChB,MAAM,IAAIF,cAAJ,CAAiB,4DAAjB,CAAN;IACH,CAFM,MAEA,IAAIT,gBAAgB,CAACa,QAAjB,CAA0BH,IAA1B,MAAmD,KAAvD,EAA8D;MACjE,MAAM,IAAID,cAAJ,CAAiB,aAAYC,IAAK,gBAAlC,CAAN;IACH;;IAED,OAAO;MACHA,IAAI,EAAEA,IADH;MAEHC;IAFG,CAAP;EAIH,CAjCM,CAAP;AAkCH,CAnCM"}
1
+ {"version":3,"names":["allowedEndpoints","createPathParameterPlugin","CmsParametersPlugin","context","request","params","type","locale","WebinyError","includes"],"sources":["path.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nconst allowedEndpoints: ApiEndpoint[] = [\"manage\", \"read\", \"preview\"];\n\nexport const createPathParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.request?.params) {\n return null;\n }\n\n const { type, locale } = context.request.params as Record<string, string | null>;\n if (!type && !locale) {\n return null;\n }\n\n if (!type) {\n throw new WebinyError(`Missing request parameter \"type\".`);\n } else if (!locale) {\n throw new WebinyError(`Missing request parameter \"locale\".`);\n } else if (allowedEndpoints.includes(type as ApiEndpoint) === false) {\n throw new WebinyError(`Endpoint \"${type}\" not allowed!`);\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AAGA,MAAMA,gBAA+B,GAAG,CAAC,QAAD,EAAW,MAAX,EAAmB,SAAnB,CAAxC;;AAEO,MAAMC,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,wCAAJ,CAAwB,MAAMC,OAAN,IAAiB;IAAA;;IAC5C;AACR;AACA;IACQ,IAAI,sBAACA,OAAO,CAACC,OAAT,6CAAC,iBAAiBC,MAAlB,CAAJ,EAA8B;MAC1B,OAAO,IAAP;IACH;;IAED,MAAM;MAAEC,IAAF;MAAQC;IAAR,IAAmBJ,OAAO,CAACC,OAAR,CAAgBC,MAAzC;;IACA,IAAI,CAACC,IAAD,IAAS,CAACC,MAAd,EAAsB;MAClB,OAAO,IAAP;IACH;;IAED,IAAI,CAACD,IAAL,EAAW;MACP,MAAM,IAAIE,cAAJ,CAAiB,mCAAjB,CAAN;IACH,CAFD,MAEO,IAAI,CAACD,MAAL,EAAa;MAChB,MAAM,IAAIC,cAAJ,CAAiB,qCAAjB,CAAN;IACH,CAFM,MAEA,IAAIR,gBAAgB,CAACS,QAAjB,CAA0BH,IAA1B,MAAmD,KAAvD,EAA8D;MACjE,MAAM,IAAIE,cAAJ,CAAiB,aAAYF,IAAK,gBAAlC,CAAN;IACH;;IAED,OAAO;MACHA,IAAI,EAAEA,IADH;MAEHC;IAFG,CAAP;EAIH,CAzBM,CAAP;AA0BH,CA3BM"}
package/types.d.ts CHANGED
@@ -1,10 +1,9 @@
1
1
  import { Plugin } from "@webiny/plugins/types";
2
2
  import { I18NContext, I18NLocale } from "@webiny/api-i18n/types";
3
- import { Context } from "@webiny/handler/types";
3
+ import { Context } from "@webiny/api/types";
4
4
  import { TenancyContext } from "@webiny/api-tenancy/types";
5
5
  import { GraphQLFieldResolver, GraphQLSchemaDefinition, Resolvers } from "@webiny/handler-graphql/types";
6
6
  import { SecurityPermission } from "@webiny/api-security/types";
7
- import { HttpContext } from "@webiny/handler-http/types";
8
7
  import { DbContext } from "@webiny/handler-db/types";
9
8
  import { FileManagerContext } from "@webiny/api-file-manager/types";
10
9
  import { UpgradePlugin } from "@webiny/api-upgrade/types";
@@ -45,7 +44,7 @@ export interface HeadlessCms extends CmsSettingsContext, CmsSystemContext, CmsGr
45
44
  *
46
45
  * @category Context
47
46
  */
48
- export interface CmsContext extends Context, DbContext, HttpContext, I18NContext, FileManagerContext, TenancyContext {
47
+ export interface CmsContext extends Context, DbContext, I18NContext, FileManagerContext, TenancyContext {
49
48
  cms: HeadlessCms;
50
49
  }
51
50
  interface CmsModelFieldPredefinedValuesValue {
package/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["CONTENT_ENTRY_STATUS"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Context } from \"@webiny/handler/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport {\n GraphQLFieldResolver,\n GraphQLSchemaDefinition,\n Resolvers\n} from \"@webiny/handler-graphql/types\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { HttpContext } from \"@webiny/handler-http/types\";\nimport { DbContext } from \"@webiny/handler-db/types\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { UpgradePlugin } from \"@webiny/api-upgrade/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\nexport interface HeadlessCms\n extends CmsSettingsContext,\n CmsSystemContext,\n CmsGroupContext,\n CmsModelContext,\n CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Requested locale\n */\n locale: string;\n /**\n * returns an instance of current locale\n */\n getLocale: () => I18NLocale;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n}\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext\n extends Context,\n DbContext,\n HttpContext,\n I18NContext,\n FileManagerContext,\n TenancyContext {\n cms: HeadlessCms;\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\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\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\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 */\n type: string;\n /**\n * A unique field ID for mapping values.\n * Must in form of a-zA-Z0-9.\n *\n * We generate a unique fieldId 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 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;\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 * Any user defined settings.\n *\n * @default {}\n */\n settings?: {\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 | number | null | undefined;\n /**\n * Object field.\n */\n fields?: CmsModelField[];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\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/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains type property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T = any> {\n /**\n * A value to be validated.\n */\n value: T;\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry;\n}\n\n/**\n * Definition for the field validator.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-model-field-validator\";\n /**\n * Actual validator definition.\n */\n validator: {\n /**\n * Name of the validator.\n */\n name: string;\n /**\n * Validation method.\n */\n validate(params: CmsModelFieldValidatorValidateParams): Promise<boolean>;\n };\n}\n\n/**\n * A pattern validator for the content entry field value.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldPatternValidatorPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-validator-pattern\";\n /**\n * A pattern object for the validator.\n */\n pattern: {\n /**\n * name of the pattern.\n */\n name: string;\n /**\n * RegExp of the validator.\n */\n regex: string;\n /**\n * RegExp flags\n */\n flags: string;\n };\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 ID - one used for mapping values.\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 [key: string]: any;\n}\n\n/**\n * Cms Model defining an entry.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Locale this model belongs to.\n */\n locale: string;\n /**\n * Cms Group reference object.\n */\n group: {\n /**\n * Generated ID of the group\n */\n id: string;\n /**\n * Name of the group\n */\n name: string;\n };\n /**\n * Description for the content model.\n */\n description: string;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CreatedBy;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * List of locked fields. Updated when entry is saved and a field has been used.\n */\n lockedFields?: LockedField[];\n /**\n * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId: string;\n /**\n * The version of Webiny which this record was stored with.\n */\n webinyVersion: string;\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: CmsModelField;\n createFieldResolvers: any;\n}\nexport interface CmsModelFieldToGraphQLCreateResolver {\n (params: CmsModelFieldToGraphQLCreateResolverParams):\n | GraphQLFieldResolver\n | { resolver: GraphQLFieldResolver | null; typeResolvers: Resolvers<CmsContext> }\n | false;\n}\n\n/**\n * @category Plugin\n * @category ModelField\n * @category GraphQL\n */\nexport interface CmsModelFieldToGraphQLPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-graphql\";\n /**\n * Field type name which must be exact as the one in `CmsEditorFieldTypePlugin` plugin.\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * Is the field searchable via the GraphQL?\n *\n * ```ts\n * isSearchable: false\n * ```\n */\n isSearchable: boolean;\n /**\n * Is the field searchable via full text search?\n *\n * Field is not full text searchable by default.\n * ```ts\n * fullTextSearch: false\n * ```\n */\n fullTextSearch?: boolean;\n /**\n * Is the field sortable via the GraphQL?\n *\n * ```ts\n * isSortable: true\n * ```\n */\n isSortable: boolean;\n /**\n * Read API methods.\n */\n read: {\n /**\n * Definition for get filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createGetFilters({ field }) {\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createGetFilters?(params: { model: CmsModel; field: CmsModelField }): string;\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?(params: { model: CmsModel; field: CmsModelField }): string;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected.\n *\n * ```ts\n * read: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return `${field.fieldId}: [MyFieldType]`;\n * }\n *\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createTypeField(params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }): CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.\n *\n * ```ts\n * read: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.fieldId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver;\n /**\n * Read API schema definitions for the field and resolvers for them.\n *\n * ```ts\n * read: {\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n };\n manage: {\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * manage: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?: (params: { model: CmsModel; field: CmsModelField }) => string;\n /**\n * Manage API schema definitions for the field and resolvers for them. Probably similar to `read.createSchema`.\n *\n * ```ts\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected. Probably same as `read.createTypeField`.\n *\n * ```ts\n * manage: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyType]\";\n * }\n *\n * return field.fieldId + \": MyType\";\n * }\n * }\n * ```\n */\n createTypeField: (params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for input GraphQL field type.\n *\n * ```ts\n * manage: {\n * createInputField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyField]\";\n * }\n *\n * return field.fieldId + \": MyField\";\n * }\n * }\n * ```\n */\n createInputField: (params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.\n *\n * ```ts\n * manage: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.fieldId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver;\n };\n}\n\n/**\n * Check for content model locked field.\n * A custom plugin definable by the user.\n *\n * @category CmsModel\n * @category Plugin\n */\nexport interface CmsModelLockedFieldPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-locked-field\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n */\n fieldType: string;\n /**\n * A method to check if field really is locked.\n */\n checkLockedField?: (params: { lockedField: LockedField; field: CmsModelField }) => void;\n /**\n * A method to get the locked field data.\n */\n getLockedFieldData?: (params: { field: CmsModelField }) => Record<string, any>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\n/**\n * Representation of settings database model.\n *\n * @category Database model\n */\nexport interface CmsSettings {\n /**\n * Last content model change. Used to cache GraphQL schema.\n */\n contentModelLastChange: Date;\n /**\n * Settings tenant.\n */\n tenant: string;\n /**\n * Settings locale.\n */\n locale: string;\n}\n\n/**\n * Settings CRUD in context.\n *\n * @category Context\n */\nexport interface CmsSettingsContext {\n /**\n * Gets settings model from the database.\n */\n getSettings: () => Promise<CmsSettings | null>;\n /**\n * Updates settings model with a new date.\n */\n updateModelLastChange: () => Promise<void>;\n /**\n * Get the datetime when content model last changed.\n */\n getModelLastChange: () => Promise<Date>;\n}\n\nexport interface BeforeInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface AfterInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport type CmsSystemContext = {\n getSystemVersion: () => Promise<string | null>;\n setSystemVersion: (version: string) => Promise<void>;\n getReadAPIKey(): Promise<string | null>;\n installSystem: () => Promise<void>;\n upgradeSystem: (version: string) => Promise<boolean>;\n /**\n * Events\n */\n onBeforeSystemInstall: Topic<BeforeInstallTopicParams>;\n onAfterSystemInstall: Topic<AfterInstallTopicParams>;\n};\n\n/**\n * A GraphQL params.data parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n name: string;\n slug?: string;\n description?: string;\n icon: string;\n}\n\n/**\n * A GraphQL params.data parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: string;\n}\n\n/**\n * A representation of content model group in the database.\n *\n * @category CmsGroup\n * @category Database model\n */\nexport interface CmsGroup {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Name of the group.\n */\n name: string;\n /**\n * Slug for the group. Must be unique.\n */\n slug: string;\n /**\n * Group tenant.\n */\n tenant: string;\n /**\n * Locale this group belongs to.\n */\n locale: string;\n /**\n * Description for the group.\n */\n description: string;\n /**\n * Icon for the group. In a form of \"ico/ico\".\n */\n icon: string;\n /**\n * CreatedBy reference object.\n */\n createdBy?: CreatedBy;\n /**\n * Date group was created on.\n */\n createdOn?: string;\n /**\n * Date group was created or changed on.\n */\n savedOn?: string;\n /**\n * Which Webiny version was this record stored with.\n */\n webinyVersion: string;\n /**\n * Is group private?\n * This is meant to be used for some internal groups - will not be visible in the schema.\n * Only available for the plugin constructed groups.\n */\n isPrivate?: boolean;\n}\n\n/**\n * A data.where parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n locale: string;\n [key: string]: any;\n };\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n /**\n * Events.\n */\n onBeforeGroupCreate: Topic<BeforeGroupCreateTopicParams>;\n onAfterGroupCreate: Topic<AfterGroupCreateTopicParams>;\n onBeforeGroupUpdate: Topic<BeforeGroupUpdateTopicParams>;\n onAfterGroupUpdate: Topic<AfterGroupUpdateTopicParams>;\n onBeforeGroupDelete: Topic<BeforeGroupDeleteTopicParams>;\n onAfterGroupDelete: Topic<AfterGroupDeleteTopicParams>;\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 * A GraphQL params.data parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string;\n /**\n * Group where to put the content model in.\n */\n group: string;\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 * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId?: string;\n}\n\n/**\n * A GraphQL params.data parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {\n /**\n * Locale into which we want to clone the model into.\n */\n locale?: string;\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 * A unique ID for the field. Values will be mapped via this value.\n * This field MUST be in range of \"a-zA-Z\".\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;\n /**\n * Text to display in the field.\n */\n placeholderText?: 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;\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 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;\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 * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId?: string;\n}\n\n/**\n * A plugin to load a CmsModelManager.\n *\n * @see CmsModelManager\n *\n * @category Plugin\n * @category CmsModel\n * @category CmsEntry\n */\nexport interface ModelManagerPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-model-manager\";\n /**\n * Specific model CmsModelManager loader. Can target exact modelId(s).\n * Be aware that if you define multiple plugins without `modelId`, last one will run.\n */\n modelId?: string[] | string;\n /**\n * Create a CmsModelManager for specific type - or new default one.\n * For reference in how is this plugin run check [contentModelManagerFactory](https://github.com/webiny/webiny-js/blob/f15676/packages/api-headless-cms/src/content/plugins/CRUD/contentModel/contentModelManagerFactory.ts)\n */\n create: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;\n}\n\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry {\n /**\n * A version of the webiny this entry was created with.\n * This can be used when upgrading the system so we know which entries to update.\n */\n webinyVersion: string;\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n /**\n * CreatedBy object reference.\n */\n createdBy: CreatedBy;\n /**\n * OwnedBy object reference. Can be different from CreatedBy.\n */\n ownedBy: CreatedBy;\n /**\n * A string of Date.toISOString() type.\n * Populated on creation.\n */\n createdOn: string;\n /**\n * A string of Date.toISOString() type.\n * Populated every time entry is saved.\n */\n savedOn: string;\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A locale of the entry.\n * @see I18NLocale.code\n */\n locale: string;\n /**\n * A string of Date.toISOString() type - if published.\n * Populated when entry is published.\n */\n publishedOn?: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped fieldId -> value object.\n *\n * @see CmsModelField\n */\n values: {\n [key: string]: any;\n };\n /**\n * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow - will be always inserted after this PR is merged.\n * Be aware that when accessing properties in it on old systems - it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type meta.data property.\n */\n meta?: {\n [key: string]: any;\n };\n}\n\nexport interface CmsStorageEntry extends CmsEntry {\n [key: string]: any;\n}\n\n/**\n * A definition for content model manager to be used in the code.\n * The default one uses `CmsEntryContext` methods internally, but devs can change to what every they want.\n *\n * @see CmsEntryContext\n *\n * @category Context\n * @category CmsEntry\n * @category CmsModel\n */\nexport interface CmsModelManager {\n /**\n * List only published entries in the content model.\n */\n listPublished: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List latest entries in the content model. Used for administration.\n */\n listLatest: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Get a list of published entries by the ID list.\n */\n getPublishedByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get a list of latest entries by the ID list.\n */\n getLatestByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get an entry filtered by given params. Will always get one.\n */\n get: (id: string) => Promise<CmsEntry>;\n /**\n * Create a entry.\n */\n create: (data: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Update a entry.\n */\n update: (id: string, data: UpdateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Delete a entry.\n */\n delete: (id: string) => Promise<void>;\n}\n\nexport interface BeforeModelCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\nexport interface AfterModelCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\nexport interface BeforeModelCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface AfterModelCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface BeforeModelUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface AfterModelUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface BeforeModelDeleteTopicParams {\n model: CmsModel;\n}\nexport interface AfterModelDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface CmsModelUpdateDirectParams {\n model: CmsModel;\n original: CmsModel;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n */\n getModel: (modelId: string) => Promise<CmsModel | null>;\n /**\n * Get all content models.\n */\n listModels: () => Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel: (data: CmsModelCreateInput) => Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom: (modelId: string, data: CmsModelCreateFromInput) => Promise<CmsModel>;\n /**\n * Update content model without data validation. Used internally.\n * @hidden\n */\n updateModelDirect: (params: CmsModelUpdateDirectParams) => Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel: (modelId: string, data: CmsModelUpdateInput) => Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel: (modelId: string) => Promise<void>;\n /**\n * Get a instance of CmsModelManager for given content modelId.\n *\n * @see CmsModelManager\n *\n * @deprecated use the getEntryManager() method instead\n */\n getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n getEntryManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n /**\n * Get all content model managers mapped by modelId.\n * @see CmsModelManager\n * @deprecated use getEntryManagers instead\n */\n getManagers: () => Map<string, CmsModelManager>;\n getEntryManagers: () => Map<string, CmsModelManager>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache: () => void;\n /**\n * Events.\n */\n onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;\n onAfterModelCreate: Topic<AfterModelCreateTopicParams>;\n onBeforeModelCreateFrom: Topic<BeforeModelCreateFromTopicParams>;\n onAfterModelCreateFrom: Topic<AfterModelCreateFromTopicParams>;\n onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;\n onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;\n onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;\n onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus =\n | \"published\"\n | \"unpublished\"\n | \"reviewRequested\"\n | \"changesRequested\"\n | \"draft\";\n\nexport interface CmsEntryListWhereRef {\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Generated ID without the version.\n */\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n /**\n * Contains the owner of the entry. An \"owner\" is the identity who originally created the entry.\n * Subsequent revisions can be created by other identities, and those will be stored in `createdBy`,\n * but the `owner` is always the original author of the entry.\n *\n * Can be sent via the API or set internal if user can see only their own entries.\n */\n ownedBy?: string;\n ownedBy_not?: string;\n ownedBy_in?: string[];\n ownedBy_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n version?: number;\n version_lt?: number;\n version_gt?: number;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n published?: boolean;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n latest?: boolean;\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]: any | CmsEntryListWhereRef;\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSort = string[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport interface BeforeEntryCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryCreateRevisionTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryCreateRevisionTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryRequestChangesTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryRequestChangesTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryRequestReviewTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryRequestReviewTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface BeforeEntryDeleteRevisionTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryDeleteRevisionTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface BeforeEntryGetTopicParams {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n\nexport interface BeforeEntryListTopicParams {\n where: CmsEntryListWhere;\n model: CmsModel;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput {\n [key: string]: any;\n}\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get a single content entry for a model.\n */\n getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry | null>;\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: (\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Lists latest entries. Used for manage API.\n */\n listLatestEntries: (\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List published entries. Used for read API.\n */\n listPublishedEntries: (\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry[], 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: (model: CmsModel, input: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Create a new entry from already existing entry.\n */\n createEntryRevisionFrom: (\n model: CmsModel,\n id: string,\n input: CreateFromCmsEntryInput\n ) => Promise<CmsEntry>;\n /**\n * Update existing entry.\n */\n updateEntry: (\n model: CmsModel,\n id: string,\n input: UpdateCmsEntryInput,\n meta?: Record<string, any>\n ) => 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) => Promise<void>;\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 * Request a review for the entry.\n */\n requestEntryReview: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Request changes for the entry.\n */\n requestEntryChanges: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Get all entry revisions.\n */\n getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;\n /**\n * Events.\n */\n onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;\n onAfterEntryCreate: Topic<AfterEntryCreateTopicParams>;\n onBeforeEntryCreateRevision: Topic<BeforeEntryCreateRevisionTopicParams>;\n onAfterEntryCreateRevision: Topic<AfterEntryCreateRevisionTopicParams>;\n onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;\n onAfterEntryUpdate: Topic<AfterEntryUpdateTopicParams>;\n onBeforeEntryDelete: Topic<BeforeEntryDeleteTopicParams>;\n onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;\n onBeforeEntryDeleteRevision: Topic<BeforeEntryDeleteRevisionTopicParams>;\n onAfterEntryDeleteRevision: Topic<AfterEntryDeleteRevisionTopicParams>;\n onBeforeEntryPublish: Topic<BeforeEntryPublishTopicParams>;\n onAfterEntryPublish: Topic<AfterEntryPublishTopicParams>;\n onBeforeEntryUnpublish: Topic<BeforeEntryUnpublishTopicParams>;\n onAfterEntryUnpublish: Topic<AfterEntryUnpublishTopicParams>;\n onBeforeEntryRequestChanges: Topic<BeforeEntryRequestChangesTopicParams>;\n onAfterEntryRequestChanges: Topic<AfterEntryRequestChangesTopicParams>;\n onBeforeEntryRequestReview: Topic<BeforeEntryRequestReviewTopicParams>;\n onAfterEntryRequestReview: Topic<AfterEntryRequestReviewTopicParams>;\n onBeforeEntryGet: Topic<BeforeEntryGetTopicParams>;\n onBeforeEntryList: Topic<BeforeEntryListTopicParams>;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * Settings security permission.\n *\n * @category SecurityPermission\n */\nexport interface CmsSettingsPermission extends SecurityPermission {} // eslint-disable-line\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string | number;\n}\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n /**\n * A object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n /**\n * A object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: any;\n}\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<CmsGroup>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<CmsGroup>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n locale: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: T;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: T | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams {\n /**\n * Entry that is going to be deleted.\n */\n entry: CmsEntry;\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsRequestChangesParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry data updated with the required properties.\n */\n entry: CmsEntry;\n /**\n * Entry that is prepared for the storageOperations, with the transformations.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsRequestReviewParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that is prepared for the storageOperations.\n */\n entry: CmsEntry;\n /**\n * Entry that is prepared for the storageOperations, with the transformations.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorageEntry> {\n /**\n * Get all the entries of the ids.\n */\n getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of all of the given IDs.\n */\n // getAllRevisionsByIds: (\n // model: CmsModel,\n // params: CmsEntryStorageOperationsGetAllRevisionsParams\n // ) => Promise<T[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<T | null>;\n /**\n * Gets entry by given params.\n */\n get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: (\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<T>>;\n /**\n * Create a new entry.\n */\n create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: (\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<T>;\n /**\n * Update existing entry.\n */\n update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;\n /**\n * Unpublish the entry.\n */\n unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;\n /**\n * Request changes the entry.\n */\n requestChanges: (\n model: CmsModel,\n params: CmsEntryStorageOperationsRequestChangesParams<T>\n ) => Promise<T>;\n /**\n * Request review the entry.\n */\n requestReview: (\n model: CmsModel,\n params: CmsEntryStorageOperationsRequestReviewParams<T>\n ) => Promise<CmsEntry>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\",\n CHANGES_REQUESTED = \"changesRequested\",\n REVIEW_REQUESTED = \"reviewRequested\"\n}\n\nexport interface CmsSettingsStorageOperationsGetParams {\n locale: string;\n tenant: string;\n}\n\nexport interface CmsSettingsStorageOperationsCreateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperationsUpdateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperations {\n /**\n * Get the settings from the storage.\n */\n get: (params: CmsSettingsStorageOperationsGetParams) => Promise<CmsSettings | null>;\n /**\n * Create settings in the storage.\n */\n create: (params: CmsSettingsStorageOperationsCreateParams) => Promise<CmsSettings>;\n /**\n * Update the settings in the storage.\n */\n update: (params: CmsSettingsStorageOperationsUpdateParams) => Promise<CmsSettings>;\n}\n\nexport interface CmsSystem {\n version?: string;\n readAPIKey?: string;\n /**\n * System tenant.\n */\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsGetParams {\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsCreateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperationsUpdateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperations {\n /**\n * Get the system data.\n */\n get: (params: CmsSystemStorageOperationsGetParams) => Promise<CmsSystem | null>;\n /**\n * Create the system info in the storage.\n */\n create: (params: CmsSystemStorageOperationsCreateParams) => Promise<CmsSystem>;\n /**\n * Update the system info in the storage.\n */\n update: (params: CmsSystemStorageOperationsUpdateParams) => Promise<CmsSystem>;\n}\n\nexport interface HeadlessCmsStorageOperations {\n system: CmsSystemStorageOperations;\n settings: CmsSettingsStorageOperations;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit?: (context: CmsContext) => Promise<void>;\n init?: (context: CmsContext) => Promise<void>;\n /**\n * An upgrade to run if necessary.\n */\n upgrade?: UpgradePlugin | null;\n}\n"],"mappings":";;;;;;;AAoDA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AA4FA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAmFA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;;AA8NA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;;AAoCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AA0FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4EA;AACA;AACA;AACA;AACA;AACA;;AAgEA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAiEA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAiIA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AA0HA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACqE;;AAErE;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AA6CA;AACA;AACA;AACA;AACA;;AAoDA;AACA;AACA;AACA;AACA;;AAoNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IA2HYA,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}
1
+ {"version":3,"names":["CONTENT_ENTRY_STATUS"],"sources":["types.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins/types\";\nimport { I18NContext, I18NLocale } from \"@webiny/api-i18n/types\";\nimport { Context } from \"@webiny/api/types\";\nimport { TenancyContext } from \"@webiny/api-tenancy/types\";\nimport {\n GraphQLFieldResolver,\n GraphQLSchemaDefinition,\n Resolvers\n} from \"@webiny/handler-graphql/types\";\nimport { SecurityPermission } from \"@webiny/api-security/types\";\nimport { DbContext } from \"@webiny/handler-db/types\";\nimport { FileManagerContext } from \"@webiny/api-file-manager/types\";\nimport { UpgradePlugin } from \"@webiny/api-upgrade/types\";\nimport { Topic } from \"@webiny/pubsub/types\";\n\nexport type ApiEndpoint = \"manage\" | \"preview\" | \"read\";\nexport interface HeadlessCms\n extends CmsSettingsContext,\n CmsSystemContext,\n CmsGroupContext,\n CmsModelContext,\n CmsEntryContext {\n /**\n * API type\n */\n type: ApiEndpoint | null;\n /**\n * Requested locale\n */\n locale: string;\n /**\n * returns an instance of current locale\n */\n getLocale: () => I18NLocale;\n /**\n * Means this request is a READ API\n */\n READ: boolean;\n /**\n * Means this request is a MANAGE API\n */\n MANAGE: boolean;\n /**\n * Means this request is a PREVIEW API\n */\n PREVIEW: boolean;\n /**\n * The storage operations loaded for current context.\n */\n storageOperations: HeadlessCmsStorageOperations;\n}\n/**\n * @description This combines all contexts used in the CMS into a single one.\n *\n * @category Context\n */\nexport interface CmsContext\n extends Context,\n DbContext,\n // HttpContext,\n I18NContext,\n FileManagerContext,\n TenancyContext {\n cms: HeadlessCms;\n}\n\ninterface CmsModelFieldPredefinedValuesValue {\n value: string;\n label: string;\n /**\n * Default selected predefined value.\n */\n selected?: boolean;\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\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\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 */\n type: string;\n /**\n * A unique field ID for mapping values.\n * Must in form of a-zA-Z0-9.\n *\n * We generate a unique fieldId 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 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;\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 * Any user defined settings.\n *\n * @default {}\n */\n settings?: {\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 | number | null | undefined;\n /**\n * Object field.\n */\n fields?: CmsModelField[];\n /**\n * Ref field.\n */\n models?: Pick<CmsModel, \"modelId\">[];\n /**\n * Date field.\n */\n type?: string;\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/**\n * A definition for dateTime field to show possible type of the field in settings.\n */\nexport interface CmsModelDateTimeField extends CmsModelField {\n /**\n * Settings object for the field. Contains type property.\n */\n settings: {\n type: \"time\" | \"date\" | \"dateTimeWithoutTimezone\" | \"dateTimeWithTimezone\";\n };\n}\n\n/**\n * Arguments for the field validator validate method.\n *\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorValidateParams<T = any> {\n /**\n * A value to be validated.\n */\n value: T;\n /**\n * Options from the CmsModelField validations.\n *\n * @see CmsModelField.validation\n * @see CmsModelField.listValidation\n */\n validator: CmsModelFieldValidation;\n /**\n * An instance of the current context.\n */\n context: CmsContext;\n /**\n * Field being validated.\n */\n field: CmsModelField;\n /**\n * An instance of the content model being validated.\n */\n model: CmsModel;\n /**\n * If entry is sent it means it is an update operation.\n * First usage is for the unique field value.\n */\n entry?: CmsEntry;\n}\n\n/**\n * Definition for the field validator.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldValidatorPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-model-field-validator\";\n /**\n * Actual validator definition.\n */\n validator: {\n /**\n * Name of the validator.\n */\n name: string;\n /**\n * Validation method.\n */\n validate(params: CmsModelFieldValidatorValidateParams): Promise<boolean>;\n };\n}\n\n/**\n * A pattern validator for the content entry field value.\n *\n * @category Plugin\n * @category ModelField\n * @category FieldValidation\n */\nexport interface CmsModelFieldPatternValidatorPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-validator-pattern\";\n /**\n * A pattern object for the validator.\n */\n pattern: {\n /**\n * name of the pattern.\n */\n name: string;\n /**\n * RegExp of the validator.\n */\n regex: string;\n /**\n * RegExp flags\n */\n flags: string;\n };\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 ID - one used for mapping values.\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 [key: string]: any;\n}\n\n/**\n * Cms Model defining an entry.\n *\n * @category Database model\n * @category CmsModel\n */\nexport interface CmsModel {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID for the content model. Created from name if not defined by user.\n */\n modelId: string;\n /**\n * Model tenant.\n */\n tenant: string;\n /**\n * Locale this model belongs to.\n */\n locale: string;\n /**\n * Cms Group reference object.\n */\n group: {\n /**\n * Generated ID of the group\n */\n id: string;\n /**\n * Name of the group\n */\n name: string;\n };\n /**\n * Description for the content model.\n */\n description: string;\n /**\n * Date created\n */\n createdOn?: string;\n /**\n * Date saved. Changes on both save and create.\n */\n savedOn?: string;\n /**\n * CreatedBy object wrapper. Contains id, name and type of the user.\n */\n createdBy?: CreatedBy;\n /**\n * List of fields defining entry values.\n */\n fields: CmsModelField[];\n /**\n * Admin UI field layout\n *\n * ```ts\n * layout: [\n * [field1id, field2id],\n * [field3id]\n * ]\n * ```\n */\n layout: string[][];\n /**\n * List of locked fields. Updated when entry is saved and a field has been used.\n */\n lockedFields?: LockedField[];\n /**\n * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId: string;\n /**\n * The version of Webiny which this record was stored with.\n */\n webinyVersion: string;\n /**\n * Is model private?\n * This is meant to be used for some internal models - will not be visible in the schema.\n * Only available for the plugin constructed models.\n */\n isPrivate?: boolean;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsModelFieldDefinition {\n fields: string;\n typeDefs?: string;\n}\n\ninterface CmsModelFieldToGraphQLCreateResolverParams {\n models: CmsModel[];\n model: CmsModel;\n graphQLType: string;\n field: CmsModelField;\n createFieldResolvers: any;\n}\nexport interface CmsModelFieldToGraphQLCreateResolver {\n (params: CmsModelFieldToGraphQLCreateResolverParams):\n | GraphQLFieldResolver\n | { resolver: GraphQLFieldResolver | null; typeResolvers: Resolvers<CmsContext> }\n | false;\n}\n\n/**\n * @category Plugin\n * @category ModelField\n * @category GraphQL\n */\nexport interface CmsModelFieldToGraphQLPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-field-to-graphql\";\n /**\n * Field type name which must be exact as the one in `CmsEditorFieldTypePlugin` plugin.\n *\n * ```ts\n * fieldType: \"myField\"\n * ```\n */\n fieldType: string;\n /**\n * Is the field searchable via the GraphQL?\n *\n * ```ts\n * isSearchable: false\n * ```\n */\n isSearchable: boolean;\n /**\n * Is the field searchable via full text search?\n *\n * Field is not full text searchable by default.\n * ```ts\n * fullTextSearch: false\n * ```\n */\n fullTextSearch?: boolean;\n /**\n * Is the field sortable via the GraphQL?\n *\n * ```ts\n * isSortable: true\n * ```\n */\n isSortable: boolean;\n /**\n * Read API methods.\n */\n read: {\n /**\n * Definition for get filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createGetFilters({ field }) {\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createGetFilters?(params: { model: CmsModel; field: CmsModelField }): string;\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * read: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?(params: { model: CmsModel; field: CmsModelField }): string;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected.\n *\n * ```ts\n * read: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return `${field.fieldId}: [MyFieldType]`;\n * }\n *\n * return `${field.fieldId}: MyField`;\n * }\n * }\n * ```\n */\n createTypeField(params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }): CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.\n *\n * ```ts\n * read: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.fieldId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver;\n /**\n * Read API schema definitions for the field and resolvers for them.\n *\n * ```ts\n * read: {\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n };\n manage: {\n /**\n * Definition for list filtering for GraphQL.\n *\n * ```ts\n * manage: {\n * createListFilters({ field }) {\n * return `\n * ${field.fieldId}: MyType\n * ${field.fieldId}_not: MyType\n * ${field.fieldId}_in: [MyType]\n * ${field.fieldId}_not_in: [MyType]\n * `;\n * }\n * }\n * ```\n */\n createListFilters?: (params: { model: CmsModel; field: CmsModelField }) => string;\n /**\n * Manage API schema definitions for the field and resolvers for them. Probably similar to `read.createSchema`.\n *\n * ```ts\n * createSchema() {\n * return {\n * typeDefs: `\n * myField {\n * id\n * date\n * }\n * `,\n * resolvers: {}\n * }\n * }\n * ```\n */\n createSchema?: (params: { models: CmsModel[] }) => GraphQLSchemaDefinition<CmsContext>;\n /**\n * Definition of the field type for GraphQL - be aware if multiple values is selected. Probably same as `read.createTypeField`.\n *\n * ```ts\n * manage: {\n * createTypeField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyType]\";\n * }\n *\n * return field.fieldId + \": MyType\";\n * }\n * }\n * ```\n */\n createTypeField: (params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for input GraphQL field type.\n *\n * ```ts\n * manage: {\n * createInputField({ field }) {\n * if (field.multipleValues) {\n * return field.fieldId + \": [MyField]\";\n * }\n *\n * return field.fieldId + \": MyField\";\n * }\n * }\n * ```\n */\n createInputField: (params: {\n model: CmsModel;\n field: CmsModelField;\n fieldTypePlugins: CmsFieldTypePlugins;\n }) => CmsModelFieldDefinition | string | null;\n /**\n * Definition for field resolver.\n * By default it is simple return of the `instance.values[fieldId]` but if required, users can define their own.\n *\n * ```ts\n * manage: {\n * createResolver({ field }) {\n * return instance => {\n * return instance.values[field.fieldId];\n * };\n * }\n * }\n * ```\n */\n createResolver?: CmsModelFieldToGraphQLCreateResolver;\n };\n}\n\n/**\n * Check for content model locked field.\n * A custom plugin definable by the user.\n *\n * @category CmsModel\n * @category Plugin\n */\nexport interface CmsModelLockedFieldPlugin extends Plugin {\n /**\n * A plugin type\n */\n type: \"cms-model-locked-field\";\n /**\n * A unique identifier of the field type (text, number, json, myField, ...).\n */\n fieldType: string;\n /**\n * A method to check if field really is locked.\n */\n checkLockedField?: (params: { lockedField: LockedField; field: CmsModelField }) => void;\n /**\n * A method to get the locked field data.\n */\n getLockedFieldData?: (params: { field: CmsModelField }) => Record<string, any>;\n}\n\n/**\n * @category ModelField\n */\nexport interface CmsFieldTypePlugins {\n [key: string]: CmsModelFieldToGraphQLPlugin;\n}\n\n/**\n * A interface describing the reference to a user that created some data in the database.\n *\n * @category General\n */\nexport interface CreatedBy {\n /**\n * ID if the user.\n */\n id: string;\n /**\n * Full name of the user.\n */\n displayName: string | null;\n /**\n * Type of the user (admin, user)\n */\n type: string;\n}\n\n/**\n * Representation of settings database model.\n *\n * @category Database model\n */\nexport interface CmsSettings {\n /**\n * Last content model change. Used to cache GraphQL schema.\n */\n contentModelLastChange: Date;\n /**\n * Settings tenant.\n */\n tenant: string;\n /**\n * Settings locale.\n */\n locale: string;\n}\n\n/**\n * Settings CRUD in context.\n *\n * @category Context\n */\nexport interface CmsSettingsContext {\n /**\n * Gets settings model from the database.\n */\n getSettings: () => Promise<CmsSettings | null>;\n /**\n * Updates settings model with a new date.\n */\n updateModelLastChange: () => Promise<void>;\n /**\n * Get the datetime when content model last changed.\n */\n getModelLastChange: () => Promise<Date>;\n}\n\nexport interface BeforeInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport interface AfterInstallTopicParams {\n tenant: string;\n locale: string;\n}\n\nexport type CmsSystemContext = {\n getSystemVersion: () => Promise<string | null>;\n setSystemVersion: (version: string) => Promise<void>;\n getReadAPIKey(): Promise<string | null>;\n installSystem: () => Promise<void>;\n upgradeSystem: (version: string) => Promise<boolean>;\n /**\n * Events\n */\n onBeforeSystemInstall: Topic<BeforeInstallTopicParams>;\n onAfterSystemInstall: Topic<AfterInstallTopicParams>;\n};\n\n/**\n * A GraphQL params.data parameter received when creating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupCreateInput {\n name: string;\n slug?: string;\n description?: string;\n icon: string;\n}\n\n/**\n * A GraphQL params.data parameter received when updating content model group.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupUpdateInput {\n name?: string;\n slug?: string;\n description?: string;\n icon?: string;\n}\n\n/**\n * A representation of content model group in the database.\n *\n * @category CmsGroup\n * @category Database model\n */\nexport interface CmsGroup {\n /**\n * Generated ID.\n */\n id: string;\n /**\n * Name of the group.\n */\n name: string;\n /**\n * Slug for the group. Must be unique.\n */\n slug: string;\n /**\n * Group tenant.\n */\n tenant: string;\n /**\n * Locale this group belongs to.\n */\n locale: string;\n /**\n * Description for the group.\n */\n description: string;\n /**\n * Icon for the group. In a form of \"ico/ico\".\n */\n icon: string;\n /**\n * CreatedBy reference object.\n */\n createdBy?: CreatedBy;\n /**\n * Date group was created on.\n */\n createdOn?: string;\n /**\n * Date group was created or changed on.\n */\n savedOn?: string;\n /**\n * Which Webiny version was this record stored with.\n */\n webinyVersion: string;\n /**\n * Is group private?\n * This is meant to be used for some internal groups - will not be visible in the schema.\n * Only available for the plugin constructed groups.\n */\n isPrivate?: boolean;\n}\n\n/**\n * A data.where parameter received when listing content model groups.\n *\n * @category CmsGroup\n * @category GraphQL params\n */\nexport interface CmsGroupListParams {\n where: {\n tenant: string;\n locale: string;\n [key: string]: any;\n };\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupCreateTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupUpdateTopicParams {\n original: CmsGroup;\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface BeforeGroupDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * @category CmsGroup\n * @category Topic\n */\nexport interface AfterGroupDeleteTopicParams {\n group: CmsGroup;\n}\n\n/**\n * Cms Group in context.\n *\n * @category Context\n * @category CmsGroup\n */\nexport interface CmsGroupContext {\n /**\n * Gets content model group by given id.\n */\n getGroup: (id: string) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n listGroups: (params?: CmsGroupListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n createGroup: (data: CmsGroupCreateInput) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n updateGroup: (id: string, data: CmsGroupUpdateInput) => Promise<CmsGroup>;\n /**\n * Delete content model group by given id.\n */\n deleteGroup: (id: string) => Promise<boolean>;\n /**\n * Clear the cached groups.\n */\n clearGroupsCache: () => void;\n /**\n * Events.\n */\n onBeforeGroupCreate: Topic<BeforeGroupCreateTopicParams>;\n onAfterGroupCreate: Topic<AfterGroupCreateTopicParams>;\n onBeforeGroupUpdate: Topic<BeforeGroupUpdateTopicParams>;\n onAfterGroupUpdate: Topic<AfterGroupUpdateTopicParams>;\n onBeforeGroupDelete: Topic<BeforeGroupDeleteTopicParams>;\n onAfterGroupDelete: Topic<AfterGroupDeleteTopicParams>;\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 * A GraphQL params.data parameter received when creating content model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateInput {\n /**\n * Name of the content model.\n */\n name: string;\n /**\n * Unique ID of the content model. Created from name if not sent by the user. Cannot be changed.\n */\n modelId?: string;\n /**\n * Description of the content model.\n */\n description?: string;\n /**\n * Group where to put the content model in.\n */\n group: string;\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 * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId?: string;\n}\n\n/**\n * A GraphQL params.data parameter received when creating content model from existing model.\n *\n * @category GraphQL params\n * @category CmsModel\n */\nexport interface CmsModelCreateFromInput extends CmsModelCreateInput {\n /**\n * Locale into which we want to clone the model into.\n */\n locale?: string;\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 * A unique ID for the field. Values will be mapped via this value.\n * This field MUST be in range of \"a-zA-Z\".\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;\n /**\n * Text to display in the field.\n */\n placeholderText?: 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;\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 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;\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 * The field that is being displayed as entry title.\n * It is picked as first available text field. Or user can select own field.\n */\n titleFieldId?: string;\n}\n\n/**\n * A plugin to load a CmsModelManager.\n *\n * @see CmsModelManager\n *\n * @category Plugin\n * @category CmsModel\n * @category CmsEntry\n */\nexport interface ModelManagerPlugin extends Plugin {\n /**\n * A plugin type.\n */\n type: \"cms-content-model-manager\";\n /**\n * Specific model CmsModelManager loader. Can target exact modelId(s).\n * Be aware that if you define multiple plugins without `modelId`, last one will run.\n */\n modelId?: string[] | string;\n /**\n * Create a CmsModelManager for specific type - or new default one.\n * For reference in how is this plugin run check [contentModelManagerFactory](https://github.com/webiny/webiny-js/blob/f15676/packages/api-headless-cms/src/content/plugins/CRUD/contentModel/contentModelManagerFactory.ts)\n */\n create: (context: CmsContext, model: CmsModel) => Promise<CmsModelManager>;\n}\n\n/**\n * A content entry definition for and from the database.\n *\n * @category Database model\n * @category CmsEntry\n */\nexport interface CmsEntry {\n /**\n * A version of the webiny this entry was created with.\n * This can be used when upgrading the system so we know which entries to update.\n */\n webinyVersion: string;\n /**\n * Tenant id which is this entry for. Can be used in case of shared storage.\n */\n tenant: string;\n /**\n * Generated ID of the entry. It is shared across all the records in the database that represent a single entry.\n * So version 1, 2, ..., 2371 will have the same value in this field to link them together.\n */\n entryId: string;\n /**\n * Generated ID + version of the entry.\n */\n id: string;\n /**\n * CreatedBy object reference.\n */\n createdBy: CreatedBy;\n /**\n * OwnedBy object reference. Can be different from CreatedBy.\n */\n ownedBy: CreatedBy;\n /**\n * A string of Date.toISOString() type.\n * Populated on creation.\n */\n createdOn: string;\n /**\n * A string of Date.toISOString() type.\n * Populated every time entry is saved.\n */\n savedOn: string;\n /**\n * Model ID of the definition for the entry.\n * @see CmsModel\n */\n modelId: string;\n /**\n * A locale of the entry.\n * @see I18NLocale.code\n */\n locale: string;\n /**\n * A string of Date.toISOString() type - if published.\n * Populated when entry is published.\n */\n publishedOn?: string;\n /**\n * A revision version of the entry.\n */\n version: number;\n /**\n * Is the entry locked?\n */\n locked: boolean;\n /**\n * Status type of the entry.\n */\n status: CmsEntryStatus;\n /**\n * A mapped fieldId -> value object.\n *\n * @see CmsModelField\n */\n values: {\n [key: string]: any;\n };\n /**\n * Settings for the given entry.\n *\n * Introduced with Advanced Publishing Workflow - will be always inserted after this PR is merged.\n * Be aware that when accessing properties in it on old systems - it will break if not checked first.\n *\n * Available only on the Manage API in entry GraphQL type meta.data property.\n */\n meta?: {\n [key: string]: any;\n };\n}\n\nexport interface CmsStorageEntry extends CmsEntry {\n [key: string]: any;\n}\n\n/**\n * A definition for content model manager to be used in the code.\n * The default one uses `CmsEntryContext` methods internally, but devs can change to what every they want.\n *\n * @see CmsEntryContext\n *\n * @category Context\n * @category CmsEntry\n * @category CmsModel\n */\nexport interface CmsModelManager {\n /**\n * List only published entries in the content model.\n */\n listPublished: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List latest entries in the content model. Used for administration.\n */\n listLatest: (params: CmsEntryListParams) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Get a list of published entries by the ID list.\n */\n getPublishedByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get a list of latest entries by the ID list.\n */\n getLatestByIds: (ids: string[]) => Promise<CmsEntry[]>;\n /**\n * Get an entry filtered by given params. Will always get one.\n */\n get: (id: string) => Promise<CmsEntry>;\n /**\n * Create a entry.\n */\n create: (data: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Update a entry.\n */\n update: (id: string, data: UpdateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Delete a entry.\n */\n delete: (id: string) => Promise<void>;\n}\n\nexport interface BeforeModelCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\nexport interface AfterModelCreateTopicParams {\n input: CmsModelCreateInput;\n model: CmsModel;\n}\nexport interface BeforeModelCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface AfterModelCreateFromTopicParams {\n input: CmsModelCreateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface BeforeModelUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface AfterModelUpdateTopicParams {\n input: CmsModelUpdateInput;\n original: CmsModel;\n model: CmsModel;\n}\nexport interface BeforeModelDeleteTopicParams {\n model: CmsModel;\n}\nexport interface AfterModelDeleteTopicParams {\n model: CmsModel;\n}\n\nexport interface CmsModelUpdateDirectParams {\n model: CmsModel;\n original: CmsModel;\n}\n\n/**\n * Cms Model in the context.\n *\n * @category Context\n * @category CmsModel\n */\nexport interface CmsModelContext {\n /**\n * Get a single content model.\n */\n getModel: (modelId: string) => Promise<CmsModel | null>;\n /**\n * Get all content models.\n */\n listModels: () => Promise<CmsModel[]>;\n /**\n * Create a content model.\n */\n createModel: (data: CmsModelCreateInput) => Promise<CmsModel>;\n /**\n * Create a content model from the given model - clone.\n */\n createModelFrom: (modelId: string, data: CmsModelCreateFromInput) => Promise<CmsModel>;\n /**\n * Update content model without data validation. Used internally.\n * @hidden\n */\n updateModelDirect: (params: CmsModelUpdateDirectParams) => Promise<CmsModel>;\n /**\n * Update content model.\n */\n updateModel: (modelId: string, data: CmsModelUpdateInput) => Promise<CmsModel>;\n /**\n * Delete content model. Should not allow deletion if there are entries connected to it.\n */\n deleteModel: (modelId: string) => Promise<void>;\n /**\n * Get a instance of CmsModelManager for given content modelId.\n *\n * @see CmsModelManager\n *\n * @deprecated use the getEntryManager() method instead\n */\n getModelManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n getEntryManager: (model: CmsModel | string) => Promise<CmsModelManager>;\n /**\n * Get all content model managers mapped by modelId.\n * @see CmsModelManager\n * @deprecated use getEntryManagers instead\n */\n getManagers: () => Map<string, CmsModelManager>;\n getEntryManagers: () => Map<string, CmsModelManager>;\n /**\n * Clear all the model caches.\n */\n clearModelsCache: () => void;\n /**\n * Events.\n */\n onBeforeModelCreate: Topic<BeforeModelCreateTopicParams>;\n onAfterModelCreate: Topic<AfterModelCreateTopicParams>;\n onBeforeModelCreateFrom: Topic<BeforeModelCreateFromTopicParams>;\n onAfterModelCreateFrom: Topic<AfterModelCreateFromTopicParams>;\n onBeforeModelUpdate: Topic<BeforeModelUpdateTopicParams>;\n onAfterModelUpdate: Topic<AfterModelUpdateTopicParams>;\n onBeforeModelDelete: Topic<BeforeModelDeleteTopicParams>;\n onAfterModelDelete: Topic<AfterModelDeleteTopicParams>;\n}\n\n/**\n * Available statuses for content entry.\n *\n * @category CmsEntry\n */\nexport type CmsEntryStatus =\n | \"published\"\n | \"unpublished\"\n | \"reviewRequested\"\n | \"changesRequested\"\n | \"draft\";\n\nexport interface CmsEntryListWhereRef {\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n}\n/**\n * Entry listing where params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListWhere {\n /**\n * Fields.\n */\n id?: string;\n id_in?: string[];\n id_not?: string;\n id_not_in?: string[];\n /**\n * Generated ID without the version.\n */\n entryId?: string;\n entryId_not?: string;\n entryId_in?: string[];\n entryId_not_in?: string[];\n /**\n * Contains the owner of the entry. An \"owner\" is the identity who originally created the entry.\n * Subsequent revisions can be created by other identities, and those will be stored in `createdBy`,\n * but the `owner` is always the original author of the entry.\n *\n * Can be sent via the API or set internal if user can see only their own entries.\n */\n ownedBy?: string;\n ownedBy_not?: string;\n ownedBy_in?: string[];\n ownedBy_not_in?: string[];\n /**\n * Who created the entry?\n */\n createdBy?: string;\n createdBy_not?: string;\n createdBy_in?: string[];\n createdBy_not_in?: string[];\n /**\n * Version of the entry.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n version?: number;\n version_lt?: number;\n version_gt?: number;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `published` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n published?: boolean;\n /**\n * Each storage operations implementation MUST determine how to use this field.\n * In SQL, it can be a `latest` field, and in DynamoDB it can be an SK.\n *\n * It is not meant to be used via the API.\n * @internal\n */\n latest?: boolean;\n /**\n * This is to allow querying by any content model field defined by the user.\n */\n [key: string]: any | CmsEntryListWhereRef;\n}\n\n/**\n * Entry listing sort.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport type CmsEntryListSort = string[];\n\n/**\n * Get entry GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n}\n\n/**\n * List entries GraphQL resolver params.\n *\n * @category CmsEntry\n * @category GraphQL params\n */\nexport interface CmsEntryListParams {\n where?: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\n/**\n * Meta information for GraphQL output.\n *\n * @category CmsEntry\n * @category GraphQL output\n */\nexport interface CmsEntryMeta {\n /**\n * A cursor for pagination.\n */\n cursor: string | null;\n /**\n * Is there more items to load?\n */\n hasMoreItems: boolean;\n /**\n * Total count of the items in the storage.\n */\n totalCount: number;\n}\n\nexport interface BeforeEntryCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryCreateTopicParams {\n input: CreateCmsEntryInput;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryCreateRevisionTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryCreateRevisionTopicParams {\n input: CreateFromCmsEntryInput;\n entry: CmsEntry;\n original: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryUpdateTopicParams {\n input: UpdateCmsEntryInput;\n original: CmsEntry;\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryPublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryUnpublishTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryRequestChangesTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryRequestChangesTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryRequestReviewTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface AfterEntryRequestReviewTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n storageEntry: CmsEntry;\n}\n\nexport interface BeforeEntryDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryDeleteTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface BeforeEntryDeleteRevisionTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\nexport interface AfterEntryDeleteRevisionTopicParams {\n entry: CmsEntry;\n model: CmsModel;\n}\n\nexport interface BeforeEntryGetTopicParams {\n model: CmsModel;\n where: CmsEntryListWhere;\n}\n\nexport interface BeforeEntryListTopicParams {\n where: CmsEntryListWhere;\n model: CmsModel;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface CreateFromCmsEntryInput {\n [key: string]: any;\n}\n\n/**\n * @category Context\n * @category CmsEntry\n */\nexport interface UpdateCmsEntryInput {\n [key: string]: any;\n}\n/**\n * Cms Entry CRUD methods in the context.\n *\n * @category Context\n * @category CmsEntry\n */\nexport interface CmsEntryContext {\n /**\n * Get a single content entry for a model.\n */\n getEntry: (model: CmsModel, params: CmsEntryGetParams) => Promise<CmsEntry | null>;\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: (\n model: CmsModel,\n params: CmsEntryListParams\n ) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * Lists latest entries. Used for manage API.\n */\n listLatestEntries: (\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry[], CmsEntryMeta]>;\n /**\n * List published entries. Used for read API.\n */\n listPublishedEntries: (\n model: CmsModel,\n params?: CmsEntryListParams\n ) => Promise<[CmsEntry[], 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: (model: CmsModel, input: CreateCmsEntryInput) => Promise<CmsEntry>;\n /**\n * Create a new entry from already existing entry.\n */\n createEntryRevisionFrom: (\n model: CmsModel,\n id: string,\n input: CreateFromCmsEntryInput\n ) => Promise<CmsEntry>;\n /**\n * Update existing entry.\n */\n updateEntry: (\n model: CmsModel,\n id: string,\n input: UpdateCmsEntryInput,\n meta?: Record<string, any>\n ) => 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) => Promise<void>;\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 * Request a review for the entry.\n */\n requestEntryReview: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Request changes for the entry.\n */\n requestEntryChanges: (model: CmsModel, id: string) => Promise<CmsEntry>;\n /**\n * Get all entry revisions.\n */\n getEntryRevisions: (model: CmsModel, id: string) => Promise<CmsEntry[]>;\n /**\n * Events.\n */\n onBeforeEntryCreate: Topic<BeforeEntryCreateTopicParams>;\n onAfterEntryCreate: Topic<AfterEntryCreateTopicParams>;\n onBeforeEntryCreateRevision: Topic<BeforeEntryCreateRevisionTopicParams>;\n onAfterEntryCreateRevision: Topic<AfterEntryCreateRevisionTopicParams>;\n onBeforeEntryUpdate: Topic<BeforeEntryUpdateTopicParams>;\n onAfterEntryUpdate: Topic<AfterEntryUpdateTopicParams>;\n onBeforeEntryDelete: Topic<BeforeEntryDeleteTopicParams>;\n onAfterEntryDelete: Topic<AfterEntryDeleteTopicParams>;\n onBeforeEntryDeleteRevision: Topic<BeforeEntryDeleteRevisionTopicParams>;\n onAfterEntryDeleteRevision: Topic<AfterEntryDeleteRevisionTopicParams>;\n onBeforeEntryPublish: Topic<BeforeEntryPublishTopicParams>;\n onAfterEntryPublish: Topic<AfterEntryPublishTopicParams>;\n onBeforeEntryUnpublish: Topic<BeforeEntryUnpublishTopicParams>;\n onAfterEntryUnpublish: Topic<AfterEntryUnpublishTopicParams>;\n onBeforeEntryRequestChanges: Topic<BeforeEntryRequestChangesTopicParams>;\n onAfterEntryRequestChanges: Topic<AfterEntryRequestChangesTopicParams>;\n onBeforeEntryRequestReview: Topic<BeforeEntryRequestReviewTopicParams>;\n onAfterEntryRequestReview: Topic<AfterEntryRequestReviewTopicParams>;\n onBeforeEntryGet: Topic<BeforeEntryGetTopicParams>;\n onBeforeEntryList: Topic<BeforeEntryListTopicParams>;\n}\n\n/**\n * Parameters for CmsEntryResolverFactory.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\ninterface CmsEntryResolverFactoryParams {\n model: CmsModel;\n}\n\n/**\n * A type for EntryResolvers. Used when creating get, list, update, publish, ...etc.\n *\n * @category GraphQL resolver\n * @category CmsEntry\n */\nexport type CmsEntryResolverFactory<TSource = any, TArgs = any, TContext = CmsContext> = {\n (params: CmsEntryResolverFactoryParams): GraphQLFieldResolver<TSource, TArgs, TContext>;\n};\n\n/**\n * Settings security permission.\n *\n * @category SecurityPermission\n */\nexport interface CmsSettingsPermission extends SecurityPermission {} // eslint-disable-line\n\n/**\n * A base security permission for CMS.\n *\n * @category SecurityPermission\n */\nexport interface BaseCmsSecurityPermission extends SecurityPermission {\n own?: boolean;\n rwd: string | number;\n}\n/**\n * A security permission for content model.\n *\n * @category SecurityPermission\n * @category CmsModel\n */\nexport interface CmsModelPermission extends BaseCmsSecurityPermission {\n /**\n * A object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content model groups.\n *\n * @category SecurityPermission\n * @category CmsGroup\n */\nexport interface CmsGroupPermission extends BaseCmsSecurityPermission {\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\n/**\n * The security permission for content entry.\n *\n * @category SecurityPermission\n * @category CmsEntry\n */\nexport interface CmsEntryPermission extends BaseCmsSecurityPermission {\n pw?: string;\n /**\n * A object representing `key: model.modelId` values where key is locale code.\n */\n models?: {\n [key: string]: string[];\n };\n /**\n * A object representing `key: group.id` values where key is locale code.\n */\n groups?: {\n [key: string]: string[];\n };\n}\n\nexport interface CmsGroupStorageOperationsGetParams {\n id: string;\n tenant: string;\n locale: string;\n}\n\nexport interface CmsGroupStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: any;\n}\nexport interface CmsGroupStorageOperationsListParams {\n where: CmsGroupStorageOperationsListWhereParams;\n sort?: string[];\n}\n\nexport interface CmsGroupStorageOperationsCreateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsUpdateParams {\n group: CmsGroup;\n}\n\nexport interface CmsGroupStorageOperationsDeleteParams {\n group: CmsGroup;\n}\n\n/**\n * Description of the CmsGroup CRUD operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsGroupStorageOperations {\n /**\n * Gets content model group by given id.\n */\n get: (params: CmsGroupStorageOperationsGetParams) => Promise<CmsGroup | null>;\n /**\n * List all content model groups. Filterable via params.\n */\n list: (params: CmsGroupStorageOperationsListParams) => Promise<CmsGroup[]>;\n /**\n * Create a new content model group.\n */\n create: (params: CmsGroupStorageOperationsCreateParams) => Promise<CmsGroup>;\n /**\n * Update existing content model group.\n */\n update: (params: CmsGroupStorageOperationsUpdateParams) => Promise<CmsGroup>;\n /**\n * Delete the content model group.\n */\n delete: (params: CmsGroupStorageOperationsDeleteParams) => Promise<CmsGroup>;\n}\n\nexport interface CmsModelStorageOperationsGetParams {\n tenant: string;\n locale: string;\n modelId: string;\n}\n\nexport interface CmsModelStorageOperationsListWhereParams {\n tenant: string;\n locale: string;\n [key: string]: string;\n}\n\nexport interface CmsModelStorageOperationsListParams {\n where: CmsModelStorageOperationsListWhereParams;\n}\n\nexport interface CmsModelStorageOperationsCreateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsUpdateParams {\n model: CmsModel;\n}\n\nexport interface CmsModelStorageOperationsDeleteParams {\n model: CmsModel;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n */\nexport interface CmsModelStorageOperations {\n /**\n * Gets content model by given id.\n */\n get: (params: CmsModelStorageOperationsGetParams) => Promise<CmsModel | null>;\n /**\n * List all content models. Filterable via params.\n */\n list: (params: CmsModelStorageOperationsListParams) => Promise<CmsModel[]>;\n /**\n * Create a new content model.\n */\n create: (params: CmsModelStorageOperationsCreateParams) => Promise<CmsModel>;\n /**\n * Update existing content model.\n */\n update: (params: CmsModelStorageOperationsUpdateParams) => Promise<CmsModel>;\n /**\n * Delete the content model.\n */\n delete: (params: CmsModelStorageOperationsDeleteParams) => Promise<CmsModel>;\n}\n\nexport interface CmsEntryStorageOperationsGetParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n limit?: number;\n}\n\nexport interface CmsEntryStorageOperationsListParams {\n where: CmsEntryListWhere;\n sort?: CmsEntryListSort;\n search?: string;\n fields?: string[];\n limit?: number;\n after?: string | null;\n}\n\nexport interface CmsEntryStorageOperationsCreateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsCreateRevisionFromParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUpdateParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Real entry, with no transformations on it.\n */\n entry: CmsEntry;\n /**\n * Entry prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsDeleteRevisionParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that was deleted.\n */\n entry: CmsEntry;\n /**\n * Entry that was deleted, directly from storage, with transformations.\n */\n storageEntry: T;\n /**\n * Entry that was set as latest.\n */\n latestEntry: CmsEntry | null;\n /**\n * Entry that was set as latest, directly from storage, with transformations.\n */\n latestStorageEntry: T | null;\n}\n\nexport interface CmsEntryStorageOperationsDeleteParams {\n /**\n * Entry that is going to be deleted.\n */\n entry: CmsEntry;\n}\n\nexport interface CmsEntryStorageOperationsPublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as published.\n * Entry is in its original form.\n */\n entry: CmsEntry;\n /**\n * The modified entry and prepared for the storage.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsUnpublishParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * The modified entry that is going to be saved as unpublished.\n */\n entry: CmsEntry;\n /**\n * The modified entry that is going to be saved as unpublished, with transformations on it.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsRequestChangesParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry data updated with the required properties.\n */\n entry: CmsEntry;\n /**\n * Entry that is prepared for the storageOperations, with the transformations.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsRequestReviewParams<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Entry that is prepared for the storageOperations.\n */\n entry: CmsEntry;\n /**\n * Entry that is prepared for the storageOperations, with the transformations.\n */\n storageEntry: T;\n}\n\nexport interface CmsEntryStorageOperationsGetByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetLatestByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedByIdsParams {\n ids: readonly string[];\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionsParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPublishedRevisionParams {\n id: string;\n}\nexport interface CmsEntryStorageOperationsGetLatestRevisionParams {\n id: string;\n}\n\nexport interface CmsEntryStorageOperationsGetPreviousRevisionParams {\n entryId: string;\n version: number;\n}\n\nexport interface CmsEntryStorageOperationsListResponse<\n T extends CmsStorageEntry = CmsStorageEntry\n> {\n /**\n * Has more items to load with the current filtering?\n */\n hasMoreItems: boolean;\n /**\n * Items loaded with current filtering.\n */\n items: T[];\n /**\n * Pointer for where to start the new item set.\n */\n cursor: string | null;\n /**\n * Total amount of items with the current filter.\n */\n totalCount: number;\n}\n\n/**\n * Description of the CmsModel storage operations.\n * If user wants to add another database to the application, this is how it is done.\n * This is just plain read, update, write, delete and list - no authentication or permission checks.\n *\n *\n * @category StorageOperations\n * @category CmsEntry\n */\nexport interface CmsEntryStorageOperations<T extends CmsStorageEntry = CmsStorageEntry> {\n /**\n * Get all the entries of the ids.\n */\n getByIds: (model: CmsModel, params: CmsEntryStorageOperationsGetByIdsParams) => Promise<T[]>;\n /**\n * Get all the published entries of the ids.\n */\n getPublishedByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all the latest entries of the ids.\n */\n getLatestByIds: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestByIdsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of the given entry id.\n */\n getRevisions: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionsParams\n ) => Promise<T[]>;\n /**\n * Get all revisions of all of the given IDs.\n */\n // getAllRevisionsByIds: (\n // model: CmsModel,\n // params: CmsEntryStorageOperationsGetAllRevisionsParams\n // ) => Promise<T[]>;\n /**\n * Get the entry by the given revision id.\n */\n getRevisionById: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the published entry by given entryId.\n */\n getPublishedRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPublishedRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the latest entry by given entryId.\n */\n getLatestRevisionByEntryId: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetLatestRevisionParams\n ) => Promise<T | null>;\n /**\n * Get the revision of the entry before given one.\n */\n getPreviousRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsGetPreviousRevisionParams\n ) => Promise<T | null>;\n /**\n * Gets entry by given params.\n */\n get: (model: CmsModel, params: CmsEntryStorageOperationsGetParams) => Promise<T | null>;\n /**\n * List all entries. Filterable via params.\n */\n list: (\n model: CmsModel,\n params: CmsEntryStorageOperationsListParams\n ) => Promise<CmsEntryStorageOperationsListResponse<T>>;\n /**\n * Create a new entry.\n */\n create: (model: CmsModel, params: CmsEntryStorageOperationsCreateParams<T>) => Promise<T>;\n /**\n * Create a new entry from existing one.\n */\n createRevisionFrom: (\n model: CmsModel,\n params: CmsEntryStorageOperationsCreateRevisionFromParams<T>\n ) => Promise<T>;\n /**\n * Update existing entry.\n */\n update: (model: CmsModel, params: CmsEntryStorageOperationsUpdateParams<T>) => Promise<T>;\n /**\n * Delete the entry revision.\n */\n deleteRevision: (\n model: CmsModel,\n params: CmsEntryStorageOperationsDeleteRevisionParams<T>\n ) => Promise<void>;\n /**\n * Delete the entry.\n */\n delete: (model: CmsModel, params: CmsEntryStorageOperationsDeleteParams) => Promise<void>;\n /**\n * Publish the entry.\n */\n publish: (model: CmsModel, params: CmsEntryStorageOperationsPublishParams<T>) => Promise<T>;\n /**\n * Unpublish the entry.\n */\n unpublish: (model: CmsModel, params: CmsEntryStorageOperationsUnpublishParams<T>) => Promise<T>;\n /**\n * Request changes the entry.\n */\n requestChanges: (\n model: CmsModel,\n params: CmsEntryStorageOperationsRequestChangesParams<T>\n ) => Promise<T>;\n /**\n * Request review the entry.\n */\n requestReview: (\n model: CmsModel,\n params: CmsEntryStorageOperationsRequestReviewParams<T>\n ) => Promise<CmsEntry>;\n}\n\nexport enum CONTENT_ENTRY_STATUS {\n DRAFT = \"draft\",\n PUBLISHED = \"published\",\n UNPUBLISHED = \"unpublished\",\n CHANGES_REQUESTED = \"changesRequested\",\n REVIEW_REQUESTED = \"reviewRequested\"\n}\n\nexport interface CmsSettingsStorageOperationsGetParams {\n locale: string;\n tenant: string;\n}\n\nexport interface CmsSettingsStorageOperationsCreateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperationsUpdateParams {\n settings: CmsSettings;\n}\n\nexport interface CmsSettingsStorageOperations {\n /**\n * Get the settings from the storage.\n */\n get: (params: CmsSettingsStorageOperationsGetParams) => Promise<CmsSettings | null>;\n /**\n * Create settings in the storage.\n */\n create: (params: CmsSettingsStorageOperationsCreateParams) => Promise<CmsSettings>;\n /**\n * Update the settings in the storage.\n */\n update: (params: CmsSettingsStorageOperationsUpdateParams) => Promise<CmsSettings>;\n}\n\nexport interface CmsSystem {\n version?: string;\n readAPIKey?: string;\n /**\n * System tenant.\n */\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsGetParams {\n tenant: string;\n}\n\nexport interface CmsSystemStorageOperationsCreateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperationsUpdateParams {\n system: CmsSystem;\n}\n\nexport interface CmsSystemStorageOperations {\n /**\n * Get the system data.\n */\n get: (params: CmsSystemStorageOperationsGetParams) => Promise<CmsSystem | null>;\n /**\n * Create the system info in the storage.\n */\n create: (params: CmsSystemStorageOperationsCreateParams) => Promise<CmsSystem>;\n /**\n * Update the system info in the storage.\n */\n update: (params: CmsSystemStorageOperationsUpdateParams) => Promise<CmsSystem>;\n}\n\nexport interface HeadlessCmsStorageOperations {\n system: CmsSystemStorageOperations;\n settings: CmsSettingsStorageOperations;\n groups: CmsGroupStorageOperations;\n models: CmsModelStorageOperations;\n entries: CmsEntryStorageOperations;\n /**\n * Either attach something from the storage operations or run something in it.\n */\n beforeInit?: (context: CmsContext) => Promise<void>;\n init?: (context: CmsContext) => Promise<void>;\n /**\n * An upgrade to run if necessary.\n */\n upgrade?: UpgradePlugin | null;\n}\n"],"mappings":";;;;;;;AAmDA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;;AA4FA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAgCA;AACA;AACA;AACA;AACA;AACA;AACA;;AAqBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAyBA;AACA;AACA;AACA;AACA;AACA;AACA;;AAiBA;AACA;AACA;AACA;AACA;AACA;;AAmFA;AACA;AACA;;AAoBA;AACA;AACA;AACA;AACA;;AA8NA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoBA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;;AAuCA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;;AASA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAqCA;AACA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;;AAwCA;AACA;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAsDA;AACA;AACA;AACA;AACA;AACA;;AAoCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AA0FA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA4EA;AACA;AACA;AACA;AACA;AACA;;AAgEA;AACA;AACA;AACA;AACA;;AAkBA;AACA;AACA;AACA;AACA;AACA;;AAiEA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AAiIA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;;AA0HA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACqE;;AAErE;AACA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;;AAgBA;AACA;AACA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;;AA6CA;AACA;AACA;AACA;AACA;;AAoDA;AACA;AACA;AACA;AACA;;AAoNA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IA2HYA,oB;;;WAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;EAAAA,oB;GAAAA,oB,oCAAAA,oB"}