@webiny/api-headless-cms 0.0.0-mt-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/LICENSE +21 -0
- package/README.md +73 -0
- package/content/contextSetup.d.ts +4 -0
- package/content/contextSetup.js +65 -0
- package/content/graphQLHandlerFactory.d.ts +5 -0
- package/content/graphQLHandlerFactory.js +173 -0
- package/content/plugins/CmsGroupPlugin.d.ts +11 -0
- package/content/plugins/CmsGroupPlugin.js +24 -0
- package/content/plugins/CmsModelPlugin.d.ts +11 -0
- package/content/plugins/CmsModelPlugin.js +24 -0
- package/content/plugins/buildSchemaPlugins.d.ts +7 -0
- package/content/plugins/buildSchemaPlugins.js +29 -0
- package/content/plugins/crud/contentEntry/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentEntry/afterDelete.js +41 -0
- package/content/plugins/crud/contentEntry/beforeCreate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeCreate.js +28 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.d.ts +7 -0
- package/content/plugins/crud/contentEntry/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.d.ts +4 -0
- package/content/plugins/crud/contentEntry/entryDataValidation.js +188 -0
- package/content/plugins/crud/contentEntry/markLockedFields.d.ts +12 -0
- package/content/plugins/crud/contentEntry/markLockedFields.js +117 -0
- package/content/plugins/crud/contentEntry.crud.d.ts +17 -0
- package/content/plugins/crud/contentEntry.crud.js +931 -0
- package/content/plugins/crud/contentModel/afterCreate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterCreate.js +18 -0
- package/content/plugins/crud/contentModel/afterDelete.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterDelete.js +18 -0
- package/content/plugins/crud/contentModel/afterUpdate.d.ts +7 -0
- package/content/plugins/crud/contentModel/afterUpdate.js +18 -0
- package/content/plugins/crud/contentModel/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeCreate.js +146 -0
- package/content/plugins/crud/contentModel/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeDelete.js +56 -0
- package/content/plugins/crud/contentModel/beforeUpdate.d.ts +9 -0
- package/content/plugins/crud/contentModel/beforeUpdate.js +128 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.d.ts +2 -0
- package/content/plugins/crud/contentModel/contentModelManagerFactory.js +29 -0
- package/content/plugins/crud/contentModel/createFieldModels.d.ts +2 -0
- package/content/plugins/crud/contentModel/createFieldModels.js +22 -0
- package/content/plugins/crud/contentModel/idValidation.d.ts +2 -0
- package/content/plugins/crud/contentModel/idValidation.js +22 -0
- package/content/plugins/crud/contentModel/models.d.ts +3 -0
- package/content/plugins/crud/contentModel/models.js +141 -0
- package/content/plugins/crud/contentModel/validateLayout.d.ts +2 -0
- package/content/plugins/crud/contentModel/validateLayout.js +38 -0
- package/content/plugins/crud/contentModel.crud.d.ts +12 -0
- package/content/plugins/crud/contentModel.crud.js +425 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeCreate.js +66 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.d.ts +9 -0
- package/content/plugins/crud/contentModelGroup/beforeDelete.js +48 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.d.ts +8 -0
- package/content/plugins/crud/contentModelGroup/beforeUpdate.js +28 -0
- package/content/plugins/crud/contentModelGroup.crud.d.ts +12 -0
- package/content/plugins/crud/contentModelGroup.crud.js +351 -0
- package/content/plugins/crud/index.d.ts +6 -0
- package/content/plugins/crud/index.js +100 -0
- package/content/plugins/graphqlFields/boolean.d.ts +3 -0
- package/content/plugins/graphqlFields/boolean.js +69 -0
- package/content/plugins/graphqlFields/datetime.d.ts +3 -0
- package/content/plugins/graphqlFields/datetime.js +83 -0
- package/content/plugins/graphqlFields/file.d.ts +3 -0
- package/content/plugins/graphqlFields/file.js +49 -0
- package/content/plugins/graphqlFields/index.d.ts +2 -0
- package/content/plugins/graphqlFields/index.js +30 -0
- package/content/plugins/graphqlFields/longText.d.ts +3 -0
- package/content/plugins/graphqlFields/longText.js +62 -0
- package/content/plugins/graphqlFields/number.d.ts +3 -0
- package/content/plugins/graphqlFields/number.js +75 -0
- package/content/plugins/graphqlFields/object.d.ts +3 -0
- package/content/plugins/graphqlFields/object.js +180 -0
- package/content/plugins/graphqlFields/ref.d.ts +3 -0
- package/content/plugins/graphqlFields/ref.js +205 -0
- package/content/plugins/graphqlFields/richText.d.ts +3 -0
- package/content/plugins/graphqlFields/richText.js +55 -0
- package/content/plugins/graphqlFields/text.d.ts +3 -0
- package/content/plugins/graphqlFields/text.js +72 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.d.ts +8 -0
- package/content/plugins/internalSecurity/InternalAuthenticationPlugin.js +54 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.d.ts +7 -0
- package/content/plugins/internalSecurity/InternalAuthorizationPlugin.js +35 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.d.ts +15 -0
- package/content/plugins/modelManager/DefaultCmsModelManager.js +62 -0
- package/content/plugins/modelManager/index.d.ts +3 -0
- package/content/plugins/modelManager/index.js +20 -0
- package/content/plugins/schema/baseSchema.d.ts +4 -0
- package/content/plugins/schema/baseSchema.js +98 -0
- package/content/plugins/schema/contentEntries.d.ts +4 -0
- package/content/plugins/schema/contentEntries.js +166 -0
- package/content/plugins/schema/contentModelGroups.d.ts +4 -0
- package/content/plugins/schema/contentModelGroups.js +153 -0
- package/content/plugins/schema/contentModels.d.ts +4 -0
- package/content/plugins/schema/contentModels.js +225 -0
- package/content/plugins/schema/createFieldResolvers.d.ts +19 -0
- package/content/plugins/schema/createFieldResolvers.js +92 -0
- package/content/plugins/schema/createManageResolvers.d.ts +11 -0
- package/content/plugins/schema/createManageResolvers.js +135 -0
- package/content/plugins/schema/createManageSDL.d.ts +9 -0
- package/content/plugins/schema/createManageSDL.js +153 -0
- package/content/plugins/schema/createPreviewResolvers.d.ts +10 -0
- package/content/plugins/schema/createPreviewResolvers.js +55 -0
- package/content/plugins/schema/createReadResolvers.d.ts +10 -0
- package/content/plugins/schema/createReadResolvers.js +55 -0
- package/content/plugins/schema/createReadSDL.d.ts +9 -0
- package/content/plugins/schema/createReadSDL.js +96 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.d.ts +6 -0
- package/content/plugins/schema/resolvers/commonFieldResolvers.js +14 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveCreate.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveCreateFrom.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveDelete.js +30 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGet.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetByIds.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveGetRevisions.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolvePublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestChanges.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.d.ts +6 -0
- package/content/plugins/schema/resolvers/manage/resolveRequestReview.js +23 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.d.ts +2 -0
- package/content/plugins/schema/resolvers/manage/resolveUnpublish.js +21 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.d.ts +7 -0
- package/content/plugins/schema/resolvers/manage/resolveUpdate.js +23 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/preview/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/preview/resolveList.js +23 -0
- package/content/plugins/schema/resolvers/read/resolveGet.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveGet.js +38 -0
- package/content/plugins/schema/resolvers/read/resolveList.d.ts +2 -0
- package/content/plugins/schema/resolvers/read/resolveList.js +23 -0
- package/content/plugins/schema/schemaPlugins.d.ts +3 -0
- package/content/plugins/schema/schemaPlugins.js +92 -0
- package/content/plugins/storage/StorageTransformPlugin.d.ts +30 -0
- package/content/plugins/storage/StorageTransformPlugin.js +36 -0
- package/content/plugins/storage/default.d.ts +3 -0
- package/content/plugins/storage/default.js +28 -0
- package/content/plugins/storage/object.d.ts +3 -0
- package/content/plugins/storage/object.js +119 -0
- package/content/plugins/utils/createTypeName.d.ts +3 -0
- package/content/plugins/utils/createTypeName.js +28 -0
- package/content/plugins/utils/entryStorage.d.ts +17 -0
- package/content/plugins/utils/entryStorage.js +125 -0
- package/content/plugins/utils/getEntryTitle.d.ts +2 -0
- package/content/plugins/utils/getEntryTitle.js +42 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.d.ts +11 -0
- package/content/plugins/utils/getSchemaFromFieldPlugins.js +30 -0
- package/content/plugins/utils/pluralizedTypeName.d.ts +1 -0
- package/content/plugins/utils/pluralizedTypeName.js +26 -0
- package/content/plugins/utils/renderFields.d.ts +16 -0
- package/content/plugins/utils/renderFields.js +51 -0
- package/content/plugins/utils/renderGetFilterFields.d.ts +9 -0
- package/content/plugins/utils/renderGetFilterFields.js +41 -0
- package/content/plugins/utils/renderInputFields.d.ts +14 -0
- package/content/plugins/utils/renderInputFields.js +53 -0
- package/content/plugins/utils/renderListFilterFields.d.ts +10 -0
- package/content/plugins/utils/renderListFilterFields.js +39 -0
- package/content/plugins/utils/renderSortEnum.d.ts +9 -0
- package/content/plugins/utils/renderSortEnum.js +32 -0
- package/content/plugins/validators/dateGte.d.ts +3 -0
- package/content/plugins/validators/dateGte.js +37 -0
- package/content/plugins/validators/dateLte.d.ts +3 -0
- package/content/plugins/validators/dateLte.js +37 -0
- package/content/plugins/validators/gte.d.ts +3 -0
- package/content/plugins/validators/gte.js +32 -0
- package/content/plugins/validators/in.d.ts +3 -0
- package/content/plugins/validators/in.js +32 -0
- package/content/plugins/validators/index.d.ts +2 -0
- package/content/plugins/validators/index.js +36 -0
- package/content/plugins/validators/lte.d.ts +3 -0
- package/content/plugins/validators/lte.js +32 -0
- package/content/plugins/validators/maxLength.d.ts +3 -0
- package/content/plugins/validators/maxLength.js +32 -0
- package/content/plugins/validators/minLength.d.ts +3 -0
- package/content/plugins/validators/minLength.js +32 -0
- package/content/plugins/validators/pattern.d.ts +3 -0
- package/content/plugins/validators/pattern.js +47 -0
- package/content/plugins/validators/patternPlugins/email.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/email.js +17 -0
- package/content/plugins/validators/patternPlugins/index.d.ts +2 -0
- package/content/plugins/validators/patternPlugins/index.js +19 -0
- package/content/plugins/validators/patternPlugins/lowerCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/lowerCase.js +17 -0
- package/content/plugins/validators/patternPlugins/upperCase.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/upperCase.js +17 -0
- package/content/plugins/validators/patternPlugins/url.d.ts +3 -0
- package/content/plugins/validators/patternPlugins/url.js +17 -0
- package/content/plugins/validators/required.d.ts +3 -0
- package/content/plugins/validators/required.js +25 -0
- package/content/plugins/validators/timeGte.d.ts +3 -0
- package/content/plugins/validators/timeGte.js +32 -0
- package/content/plugins/validators/timeLte.d.ts +3 -0
- package/content/plugins/validators/timeLte.js +32 -0
- package/index.d.ts +12 -0
- package/index.js +66 -0
- package/migrateCMSPermissions.d.ts +17 -0
- package/migrateCMSPermissions.js +193 -0
- package/package.json +80 -0
- package/plugins/context.d.ts +4 -0
- package/plugins/context.js +34 -0
- package/plugins/crud/index.d.ts +6 -0
- package/plugins/crud/index.js +100 -0
- package/plugins/crud/settings.crud.d.ts +10 -0
- package/plugins/crud/settings.crud.js +93 -0
- package/plugins/crud/system.crud.d.ts +10 -0
- package/plugins/crud/system.crud.js +182 -0
- package/plugins/graphql/system.d.ts +17 -0
- package/plugins/graphql/system.js +72 -0
- package/plugins/graphql.d.ts +2 -0
- package/plugins/graphql.js +79 -0
- package/plugins/upgrades/index.d.ts +2 -0
- package/plugins/upgrades/index.js +14 -0
- package/plugins/upgrades/v5.5.0/helpers.d.ts +6 -0
- package/plugins/upgrades/v5.5.0/helpers.js +10 -0
- package/plugins/upgrades/v5.5.0/index.d.ts +4 -0
- package/plugins/upgrades/v5.5.0/index.js +129 -0
- package/transformers.d.ts +2 -0
- package/transformers.js +25 -0
- package/types.d.ts +2149 -0
- package/types.js +366 -0
- package/utils.d.ts +25 -0
- package/utils.js +251 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.validateLayout = void 0;
|
|
7
|
+
|
|
8
|
+
const validateLayout = ({
|
|
9
|
+
layout
|
|
10
|
+
}, fields) => {
|
|
11
|
+
const flatLayoutIdList = layout.reduce((acc, id) => {
|
|
12
|
+
return acc.concat(Array.isArray(id) ? id : [id]);
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
if (flatLayoutIdList.length !== fields.length) {
|
|
16
|
+
throw new Error(`There are ${flatLayoutIdList.length} IDs in the layout and ${fields.length} in fields, which cannot be - numbers must be the same.`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
for (const field of fields) {
|
|
20
|
+
if (flatLayoutIdList.includes(field.id)) {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error(`Field "${field.id}" is not defined in layout.`);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
for (const id of flatLayoutIdList) {
|
|
28
|
+
const fieldFound = fields.some(f => f.id === id);
|
|
29
|
+
|
|
30
|
+
if (fieldFound) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
throw new Error(`Field id "${id}" is in layout but not in fields.`);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.validateLayout = validateLayout;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CmsContext, CmsModelContext, HeadlessCmsStorageOperations } from "../../../types";
|
|
2
|
+
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
|
+
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
|
+
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
5
|
+
export interface Params {
|
|
6
|
+
getTenant: () => Tenant;
|
|
7
|
+
getLocale: () => I18NLocale;
|
|
8
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
9
|
+
context: CmsContext;
|
|
10
|
+
getIdentity: () => SecurityIdentity;
|
|
11
|
+
}
|
|
12
|
+
export declare const createModelsCrud: (params: Params) => CmsModelContext;
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.createModelsCrud = void 0;
|
|
9
|
+
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
12
|
+
var utils = _interopRequireWildcard(require("../../../utils"));
|
|
13
|
+
|
|
14
|
+
var _dataloader = _interopRequireDefault(require("dataloader"));
|
|
15
|
+
|
|
16
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
17
|
+
|
|
18
|
+
var _contentModelManagerFactory = require("./contentModel/contentModelManagerFactory");
|
|
19
|
+
|
|
20
|
+
var _models = require("./contentModel/models");
|
|
21
|
+
|
|
22
|
+
var _createFieldModels = require("./contentModel/createFieldModels");
|
|
23
|
+
|
|
24
|
+
var _validateLayout = require("./contentModel/validateLayout");
|
|
25
|
+
|
|
26
|
+
var _apiSecurity = require("@webiny/api-security");
|
|
27
|
+
|
|
28
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
29
|
+
|
|
30
|
+
var _CmsModelPlugin = require("../CmsModelPlugin");
|
|
31
|
+
|
|
32
|
+
var _pubsub = require("@webiny/pubsub");
|
|
33
|
+
|
|
34
|
+
var _beforeCreate = require("./contentModel/beforeCreate");
|
|
35
|
+
|
|
36
|
+
var _beforeUpdate = require("./contentModel/beforeUpdate");
|
|
37
|
+
|
|
38
|
+
var _beforeDelete = require("./contentModel/beforeDelete");
|
|
39
|
+
|
|
40
|
+
var _afterCreate = require("./contentModel/afterCreate");
|
|
41
|
+
|
|
42
|
+
var _afterUpdate = require("./contentModel/afterUpdate");
|
|
43
|
+
|
|
44
|
+
var _afterDelete = require("./contentModel/afterDelete");
|
|
45
|
+
|
|
46
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
|
+
|
|
48
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
49
|
+
|
|
50
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
51
|
+
|
|
52
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
53
|
+
|
|
54
|
+
const createModelsCrud = params => {
|
|
55
|
+
const {
|
|
56
|
+
getTenant,
|
|
57
|
+
getIdentity,
|
|
58
|
+
getLocale,
|
|
59
|
+
storageOperations,
|
|
60
|
+
context
|
|
61
|
+
} = params;
|
|
62
|
+
const loaders = {
|
|
63
|
+
listModels: new _dataloader.default(async () => {
|
|
64
|
+
const models = await storageOperations.models.list({
|
|
65
|
+
where: {
|
|
66
|
+
tenant: getTenant().id,
|
|
67
|
+
locale: getLocale().code
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
return [models.map(model => {
|
|
71
|
+
return _objectSpread(_objectSpread({}, model), {}, {
|
|
72
|
+
tenant: model.tenant || getTenant().id,
|
|
73
|
+
locale: model.locale || getLocale().code
|
|
74
|
+
});
|
|
75
|
+
})];
|
|
76
|
+
})
|
|
77
|
+
};
|
|
78
|
+
const managers = new Map();
|
|
79
|
+
|
|
80
|
+
const updateManager = async (context, model) => {
|
|
81
|
+
const manager = await (0, _contentModelManagerFactory.contentModelManagerFactory)(context, model);
|
|
82
|
+
managers.set(model.modelId, manager);
|
|
83
|
+
return manager;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const checkModelPermissions = check => {
|
|
87
|
+
return utils.checkPermissions(context, "cms.contentModel", {
|
|
88
|
+
rwd: check
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const getModelsAsPlugins = () => {
|
|
93
|
+
const tenant = getTenant().id;
|
|
94
|
+
const locale = getLocale().code;
|
|
95
|
+
return context.plugins.byType(_CmsModelPlugin.CmsModelPlugin.type)
|
|
96
|
+
/**
|
|
97
|
+
* We need to filter out models that are not for this tenant or locale.
|
|
98
|
+
* If it does not have tenant or locale define, it is for every locale and tenant
|
|
99
|
+
*/
|
|
100
|
+
.filter(plugin => {
|
|
101
|
+
const {
|
|
102
|
+
tenant: t,
|
|
103
|
+
locale: l
|
|
104
|
+
} = plugin.contentModel;
|
|
105
|
+
|
|
106
|
+
if (t && t !== tenant) {
|
|
107
|
+
return false;
|
|
108
|
+
} else if (l && l !== locale) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return true;
|
|
113
|
+
}).map(plugin => {
|
|
114
|
+
return _objectSpread(_objectSpread({}, plugin.contentModel), {}, {
|
|
115
|
+
tenant,
|
|
116
|
+
locale,
|
|
117
|
+
webinyVersion: context.WEBINY_VERSION
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const modelsGet = async modelId => {
|
|
123
|
+
const pluginModel = getModelsAsPlugins().find(model => model.modelId === modelId);
|
|
124
|
+
|
|
125
|
+
if (pluginModel) {
|
|
126
|
+
return pluginModel;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const model = await storageOperations.models.get({
|
|
130
|
+
tenant: getTenant().id,
|
|
131
|
+
locale: getLocale().code,
|
|
132
|
+
modelId
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
if (!model) {
|
|
136
|
+
throw new _handlerGraphql.NotFoundError(`Content model "${modelId}" was not found!`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return _objectSpread(_objectSpread({}, model), {}, {
|
|
140
|
+
tenant: model.tenant || getTenant().id,
|
|
141
|
+
locale: model.locale || getLocale().code
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const modelsList = async () => {
|
|
146
|
+
const databaseModels = await loaders.listModels.load("listModels");
|
|
147
|
+
const pluginsModels = getModelsAsPlugins();
|
|
148
|
+
return databaseModels.concat(pluginsModels);
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const listOperations = async () => {
|
|
152
|
+
const permission = await checkModelPermissions("r");
|
|
153
|
+
const models = await modelsList();
|
|
154
|
+
return utils.filterAsync(models, async model => {
|
|
155
|
+
if (!utils.validateOwnership(context, permission, model)) {
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return utils.validateModelAccess(context, model);
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const get = async modelId => {
|
|
164
|
+
const permission = await checkModelPermissions("r");
|
|
165
|
+
const model = await modelsGet(modelId);
|
|
166
|
+
utils.checkOwnership(context, permission, model);
|
|
167
|
+
await utils.checkModelAccess(context, model);
|
|
168
|
+
return model;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const getManager = async modelId => {
|
|
172
|
+
if (managers.has(modelId)) {
|
|
173
|
+
return managers.get(modelId);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const models = await modelsList();
|
|
177
|
+
const model = models.find(m => m.modelId === modelId);
|
|
178
|
+
|
|
179
|
+
if (!model) {
|
|
180
|
+
throw new _handlerGraphql.NotFoundError(`There is no content model "${modelId}".`);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return await updateManager(context, model);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const onBeforeCreate = (0, _pubsub.createTopic)();
|
|
187
|
+
const onAfterCreate = (0, _pubsub.createTopic)();
|
|
188
|
+
const onBeforeUpdate = (0, _pubsub.createTopic)();
|
|
189
|
+
const onAfterUpdate = (0, _pubsub.createTopic)();
|
|
190
|
+
const onBeforeDelete = (0, _pubsub.createTopic)();
|
|
191
|
+
const onAfterDelete = (0, _pubsub.createTopic)();
|
|
192
|
+
/**
|
|
193
|
+
* We need to assign some default behaviors.
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
(0, _beforeCreate.assignBeforeModelCreate)({
|
|
197
|
+
onBeforeCreate,
|
|
198
|
+
plugins: context.plugins,
|
|
199
|
+
storageOperations
|
|
200
|
+
});
|
|
201
|
+
(0, _afterCreate.assignAfterModelCreate)({
|
|
202
|
+
context,
|
|
203
|
+
onAfterCreate
|
|
204
|
+
});
|
|
205
|
+
(0, _beforeUpdate.assignBeforeModelUpdate)({
|
|
206
|
+
onBeforeUpdate,
|
|
207
|
+
plugins: context.plugins,
|
|
208
|
+
storageOperations
|
|
209
|
+
});
|
|
210
|
+
(0, _afterUpdate.assignAfterModelUpdate)({
|
|
211
|
+
context,
|
|
212
|
+
onAfterUpdate
|
|
213
|
+
});
|
|
214
|
+
(0, _beforeDelete.assignBeforeModelDelete)({
|
|
215
|
+
onBeforeDelete,
|
|
216
|
+
plugins: context.plugins,
|
|
217
|
+
storageOperations
|
|
218
|
+
});
|
|
219
|
+
(0, _afterDelete.assignAfterModelDelete)({
|
|
220
|
+
context,
|
|
221
|
+
onAfterDelete
|
|
222
|
+
});
|
|
223
|
+
return {
|
|
224
|
+
onBeforeModelCreate: onBeforeCreate,
|
|
225
|
+
onAfterModelCreate: onAfterCreate,
|
|
226
|
+
onBeforeModelUpdate: onBeforeUpdate,
|
|
227
|
+
onAfterModelUpdate: onAfterUpdate,
|
|
228
|
+
onBeforeModelDelete: onBeforeDelete,
|
|
229
|
+
onAfterModelDelete: onAfterDelete,
|
|
230
|
+
silentAuthModel: () => {
|
|
231
|
+
return {
|
|
232
|
+
list: async () => {
|
|
233
|
+
try {
|
|
234
|
+
return await listOperations();
|
|
235
|
+
} catch (ex) {
|
|
236
|
+
if (ex instanceof _apiSecurity.NotAuthorizedError) {
|
|
237
|
+
return [];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
throw ex;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
},
|
|
245
|
+
getModel: get,
|
|
246
|
+
listModels: listOperations,
|
|
247
|
+
|
|
248
|
+
async createModel(inputData) {
|
|
249
|
+
await checkModelPermissions("w");
|
|
250
|
+
const createdData = new _models.CreateContentModelModel().populate(inputData);
|
|
251
|
+
await createdData.validate();
|
|
252
|
+
const input = await createdData.toJSON();
|
|
253
|
+
context.security.disableAuthorization();
|
|
254
|
+
const group = await context.cms.getGroup(input.group);
|
|
255
|
+
context.security.enableAuthorization();
|
|
256
|
+
|
|
257
|
+
if (!group) {
|
|
258
|
+
throw new _handlerGraphql.NotFoundError(`There is no group "${input.group}".`);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const identity = getIdentity();
|
|
262
|
+
|
|
263
|
+
const model = _objectSpread(_objectSpread({}, input), {}, {
|
|
264
|
+
titleFieldId: "id",
|
|
265
|
+
locale: getLocale().code,
|
|
266
|
+
tenant: getTenant().id,
|
|
267
|
+
group: {
|
|
268
|
+
id: group.id,
|
|
269
|
+
name: group.name
|
|
270
|
+
},
|
|
271
|
+
createdBy: {
|
|
272
|
+
id: identity.id,
|
|
273
|
+
displayName: identity.displayName,
|
|
274
|
+
type: identity.type
|
|
275
|
+
},
|
|
276
|
+
createdOn: new Date().toISOString(),
|
|
277
|
+
savedOn: new Date().toISOString(),
|
|
278
|
+
fields: [],
|
|
279
|
+
lockedFields: [],
|
|
280
|
+
layout: [],
|
|
281
|
+
webinyVersion: context.WEBINY_VERSION
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
await onBeforeCreate.publish({
|
|
285
|
+
model,
|
|
286
|
+
input
|
|
287
|
+
});
|
|
288
|
+
const createdModel = await storageOperations.models.create({
|
|
289
|
+
input,
|
|
290
|
+
model
|
|
291
|
+
});
|
|
292
|
+
loaders.listModels.clearAll();
|
|
293
|
+
await updateManager(context, model);
|
|
294
|
+
await onAfterCreate.publish({
|
|
295
|
+
input,
|
|
296
|
+
model: createdModel
|
|
297
|
+
});
|
|
298
|
+
return createdModel;
|
|
299
|
+
},
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Method does not check for permissions or ownership.
|
|
303
|
+
* @internal
|
|
304
|
+
*/
|
|
305
|
+
async updateModelDirect(params) {
|
|
306
|
+
const {
|
|
307
|
+
model: initialModel,
|
|
308
|
+
original
|
|
309
|
+
} = params;
|
|
310
|
+
|
|
311
|
+
const model = _objectSpread(_objectSpread({}, initialModel), {}, {
|
|
312
|
+
tenant: initialModel.tenant || getTenant().id,
|
|
313
|
+
locale: initialModel.locale || getLocale().code,
|
|
314
|
+
webinyVersion: context.WEBINY_VERSION
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
await onBeforeUpdate.publish({
|
|
318
|
+
input: {},
|
|
319
|
+
original,
|
|
320
|
+
model
|
|
321
|
+
});
|
|
322
|
+
const resultModel = await storageOperations.models.update({
|
|
323
|
+
original,
|
|
324
|
+
model,
|
|
325
|
+
input: {}
|
|
326
|
+
});
|
|
327
|
+
await updateManager(context, resultModel);
|
|
328
|
+
loaders.listModels.clearAll();
|
|
329
|
+
await onAfterUpdate.publish({
|
|
330
|
+
input: {},
|
|
331
|
+
original,
|
|
332
|
+
model: resultModel
|
|
333
|
+
});
|
|
334
|
+
return resultModel;
|
|
335
|
+
},
|
|
336
|
+
|
|
337
|
+
async updateModel(modelId, inputData) {
|
|
338
|
+
await checkModelPermissions("w"); // Get a model record; this will also perform ownership validation.
|
|
339
|
+
|
|
340
|
+
const original = await get(modelId);
|
|
341
|
+
const updatedData = new _models.UpdateContentModelModel().populate(inputData);
|
|
342
|
+
await updatedData.validate();
|
|
343
|
+
const input = await updatedData.toJSON({
|
|
344
|
+
onlyDirty: true
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
if (Object.keys(input).length === 0) {
|
|
348
|
+
return {};
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (input.group) {
|
|
352
|
+
context.security.disableAuthorization();
|
|
353
|
+
const group = await context.cms.getGroup(input.group);
|
|
354
|
+
context.security.enableAuthorization();
|
|
355
|
+
|
|
356
|
+
if (!group) {
|
|
357
|
+
throw new _handlerGraphql.NotFoundError(`There is no group "${input.group}".`);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
input.group = {
|
|
361
|
+
id: group.id,
|
|
362
|
+
name: group.name
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const modelFields = await (0, _createFieldModels.createFieldModels)(original, inputData);
|
|
367
|
+
(0, _validateLayout.validateLayout)(input, modelFields);
|
|
368
|
+
|
|
369
|
+
const model = _objectSpread(_objectSpread(_objectSpread({}, original), input), {}, {
|
|
370
|
+
tenant: original.tenant || getTenant().id,
|
|
371
|
+
locale: original.locale || getLocale().code,
|
|
372
|
+
webinyVersion: context.WEBINY_VERSION,
|
|
373
|
+
fields: modelFields,
|
|
374
|
+
savedOn: new Date().toISOString()
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
await onBeforeUpdate.publish({
|
|
378
|
+
input,
|
|
379
|
+
original,
|
|
380
|
+
model
|
|
381
|
+
});
|
|
382
|
+
const resultModel = await storageOperations.models.update({
|
|
383
|
+
original,
|
|
384
|
+
model,
|
|
385
|
+
input
|
|
386
|
+
});
|
|
387
|
+
await updateManager(context, resultModel);
|
|
388
|
+
await onAfterUpdate.publish({
|
|
389
|
+
original,
|
|
390
|
+
model: resultModel,
|
|
391
|
+
input
|
|
392
|
+
});
|
|
393
|
+
return resultModel;
|
|
394
|
+
},
|
|
395
|
+
|
|
396
|
+
async deleteModel(modelId) {
|
|
397
|
+
await checkModelPermissions("d");
|
|
398
|
+
const model = await get(modelId);
|
|
399
|
+
await onBeforeDelete.publish({
|
|
400
|
+
model
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
try {
|
|
404
|
+
await storageOperations.models.delete({
|
|
405
|
+
model
|
|
406
|
+
});
|
|
407
|
+
} catch (ex) {
|
|
408
|
+
throw new _error.default(ex.message || "Could not delete the content model", ex.code || "CONTENT_MODEL_DELETE_ERROR", {
|
|
409
|
+
error: ex,
|
|
410
|
+
modelId: model.modelId
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
await onAfterDelete.publish({
|
|
415
|
+
model
|
|
416
|
+
});
|
|
417
|
+
managers.delete(model.modelId);
|
|
418
|
+
},
|
|
419
|
+
|
|
420
|
+
getModelManager: getManager,
|
|
421
|
+
getManagers: () => managers
|
|
422
|
+
};
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
exports.createModelsCrud = createModelsCrud;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BeforeGroupCreateTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
2
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
export interface Params {
|
|
5
|
+
onBeforeCreate: Topic<BeforeGroupCreateTopicParams>;
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
8
|
+
}
|
|
9
|
+
export declare const assignBeforeGroupCreate: (params: Params) => void;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.assignBeforeGroupCreate = void 0;
|
|
9
|
+
|
|
10
|
+
var _CmsGroupPlugin = require("../../CmsGroupPlugin");
|
|
11
|
+
|
|
12
|
+
var _utils = require("../../../../utils");
|
|
13
|
+
|
|
14
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
15
|
+
|
|
16
|
+
var _shortid = _interopRequireDefault(require("shortid"));
|
|
17
|
+
|
|
18
|
+
const assignBeforeGroupCreate = params => {
|
|
19
|
+
const {
|
|
20
|
+
onBeforeCreate,
|
|
21
|
+
plugins,
|
|
22
|
+
storageOperations
|
|
23
|
+
} = params;
|
|
24
|
+
onBeforeCreate.subscribe(async params => {
|
|
25
|
+
const {
|
|
26
|
+
group
|
|
27
|
+
} = params;
|
|
28
|
+
|
|
29
|
+
if (group.slug && group.slug.trim()) {
|
|
30
|
+
const groups = await storageOperations.groups.list({
|
|
31
|
+
where: {
|
|
32
|
+
tenant: group.tenant,
|
|
33
|
+
locale: group.locale,
|
|
34
|
+
slug: group.slug
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (groups.length > 0) {
|
|
39
|
+
throw new _error.default(`Cms Group with the slug "${group.slug}" already exists.`, "SLUG_ALREADY_EXISTS");
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
const slug = (0, _utils.toSlug)(group.name);
|
|
43
|
+
const groups = await storageOperations.groups.list({
|
|
44
|
+
where: {
|
|
45
|
+
tenant: group.tenant,
|
|
46
|
+
locale: group.locale,
|
|
47
|
+
slug
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (groups.length === 0) {
|
|
52
|
+
group.slug = slug;
|
|
53
|
+
} else {
|
|
54
|
+
group.slug = `${slug}-${_shortid.default.generate()}`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const groupPlugin = plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).find(item => item.contentModelGroup.slug === group.slug);
|
|
59
|
+
|
|
60
|
+
if (groupPlugin) {
|
|
61
|
+
throw new Error(`Cannot create "${group.slug}" content model group because one is already registered via a plugin.`);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
exports.assignBeforeGroupCreate = assignBeforeGroupCreate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { BeforeGroupDeleteTopicParams, HeadlessCmsStorageOperations } from "../../../../types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
export interface Params {
|
|
5
|
+
onBeforeDelete: Topic<BeforeGroupDeleteTopicParams>;
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
8
|
+
}
|
|
9
|
+
export declare const assignBeforeGroupDelete: (params: Params) => void;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.assignBeforeGroupDelete = void 0;
|
|
9
|
+
|
|
10
|
+
var _CmsGroupPlugin = require("../../CmsGroupPlugin");
|
|
11
|
+
|
|
12
|
+
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
+
|
|
14
|
+
const assignBeforeGroupDelete = params => {
|
|
15
|
+
const {
|
|
16
|
+
onBeforeDelete,
|
|
17
|
+
plugins,
|
|
18
|
+
storageOperations
|
|
19
|
+
} = params;
|
|
20
|
+
onBeforeDelete.subscribe(async params => {
|
|
21
|
+
const {
|
|
22
|
+
group
|
|
23
|
+
} = params;
|
|
24
|
+
const groupPlugin = plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).find(item => item.contentModelGroup.slug === group.slug);
|
|
25
|
+
|
|
26
|
+
if (groupPlugin) {
|
|
27
|
+
throw new Error(`Cms Groups defined via plugins cannot be deleted.`);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const models = await storageOperations.models.list({
|
|
31
|
+
where: {
|
|
32
|
+
tenant: group.tenant,
|
|
33
|
+
locale: group.locale
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
const items = models.filter(model => {
|
|
37
|
+
return model.group.id === group.id;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (items.length > 0) {
|
|
41
|
+
throw new _error.default("Cannot delete this group because there are models that belong to it.", "BEFORE_DELETE_ERROR", {
|
|
42
|
+
group
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.assignBeforeGroupDelete = assignBeforeGroupDelete;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Topic } from "@webiny/pubsub/types";
|
|
2
|
+
import { BeforeGroupUpdateTopicParams } from "../../../../types";
|
|
3
|
+
import { PluginsContainer } from "@webiny/plugins";
|
|
4
|
+
export interface Params {
|
|
5
|
+
onBeforeUpdate: Topic<BeforeGroupUpdateTopicParams>;
|
|
6
|
+
plugins: PluginsContainer;
|
|
7
|
+
}
|
|
8
|
+
export declare const assignBeforeGroupUpdate: (params: Params) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.assignBeforeGroupUpdate = void 0;
|
|
7
|
+
|
|
8
|
+
var _CmsGroupPlugin = require("../../CmsGroupPlugin");
|
|
9
|
+
|
|
10
|
+
const assignBeforeGroupUpdate = params => {
|
|
11
|
+
const {
|
|
12
|
+
onBeforeUpdate,
|
|
13
|
+
plugins
|
|
14
|
+
} = params;
|
|
15
|
+
onBeforeUpdate.subscribe(({
|
|
16
|
+
group
|
|
17
|
+
}) => {
|
|
18
|
+
const groupPlugin = plugins.byType(_CmsGroupPlugin.CmsGroupPlugin.type).find(item => item.contentModelGroup.slug === group.slug);
|
|
19
|
+
|
|
20
|
+
if (!groupPlugin) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error(`Cms Groups defined via plugins cannot be updated.`);
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.assignBeforeGroupUpdate = assignBeforeGroupUpdate;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { CmsGroupContext, CmsContext, HeadlessCmsStorageOperations } from "../../../types";
|
|
2
|
+
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
|
+
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
|
+
import { SecurityIdentity } from "@webiny/api-security/types";
|
|
5
|
+
export interface Params {
|
|
6
|
+
getTenant: () => Tenant;
|
|
7
|
+
getLocale: () => I18NLocale;
|
|
8
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
9
|
+
context: CmsContext;
|
|
10
|
+
getIdentity: () => SecurityIdentity;
|
|
11
|
+
}
|
|
12
|
+
export declare const createModelGroupsCrud: (params: Params) => CmsGroupContext;
|