@webiny/api-headless-cms 0.0.0-unstable.3386f66516 → 0.0.0-unstable.496cf268ac
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.js +0 -25
- package/context.js.map +1 -1
- package/crud/contentEntry/afterDelete.js +0 -5
- package/crud/contentEntry/afterDelete.js.map +1 -1
- package/crud/contentEntry/beforeCreate.js +0 -3
- package/crud/contentEntry/beforeCreate.js.map +1 -1
- package/crud/contentEntry/beforeUpdate.js +0 -3
- package/crud/contentEntry/beforeUpdate.js.map +1 -1
- package/crud/contentEntry/entryDataValidation.js +1 -40
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/markLockedFields.d.ts +1 -1
- package/crud/contentEntry/markLockedFields.js +15 -28
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.js +5 -61
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/searchableFields.js +1 -12
- package/crud/contentEntry/searchableFields.js.map +1 -1
- package/crud/contentEntry.crud.d.ts +2 -1
- package/crud/contentEntry.crud.js +59 -166
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/afterCreate.js +0 -2
- package/crud/contentModel/afterCreate.js.map +1 -1
- package/crud/contentModel/afterCreateFrom.js +0 -2
- package/crud/contentModel/afterCreateFrom.js.map +1 -1
- package/crud/contentModel/afterDelete.js +0 -2
- package/crud/contentModel/afterDelete.js.map +1 -1
- package/crud/contentModel/afterUpdate.js +0 -2
- package/crud/contentModel/afterUpdate.js.map +1 -1
- package/crud/contentModel/beforeCreate.js +7 -32
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.js +0 -10
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.js +4 -5
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/compatibility/modelApiName.d.ts +3 -0
- package/crud/contentModel/compatibility/modelApiName.js +24 -0
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -0
- package/crud/contentModel/contentModelManagerFactory.js +0 -7
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
- package/crud/contentModel/createFieldStorageId.js +0 -3
- package/crud/contentModel/createFieldStorageId.js.map +1 -1
- package/crud/contentModel/defaultFields.d.ts +5 -0
- package/crud/contentModel/defaultFields.js +58 -0
- package/crud/contentModel/defaultFields.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.d.ts +2 -0
- package/crud/contentModel/fields/descriptionField.js +42 -0
- package/crud/contentModel/fields/descriptionField.js.map +1 -0
- package/crud/contentModel/fields/imageField.d.ts +2 -0
- package/crud/contentModel/fields/imageField.js +46 -0
- package/crud/contentModel/fields/imageField.js.map +1 -0
- package/crud/contentModel/fields/titleField.d.ts +2 -0
- package/crud/contentModel/fields/titleField.js +58 -0
- package/crud/contentModel/fields/titleField.js.map +1 -0
- package/crud/contentModel/validateLayout.js +0 -8
- package/crud/contentModel/validateLayout.js.map +1 -1
- package/crud/contentModel/validateModel.d.ts +1 -0
- package/crud/contentModel/validateModel.js +0 -8
- package/crud/contentModel/validateModel.js.map +1 -1
- package/crud/contentModel/validateModelFields.d.ts +2 -1
- package/crud/contentModel/validateModelFields.js +35 -128
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +85 -43
- package/crud/contentModel/validation.js +57 -21
- package/crud/contentModel/validation.js.map +1 -1
- package/crud/contentModel.crud.js +46 -110
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/beforeCreate.js +0 -12
- package/crud/contentModelGroup/beforeCreate.js.map +1 -1
- package/crud/contentModelGroup/beforeDelete.js +0 -8
- package/crud/contentModelGroup/beforeDelete.js.map +1 -1
- package/crud/contentModelGroup/beforeUpdate.js +0 -5
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
- package/crud/contentModelGroup/validation.js +0 -9
- package/crud/contentModelGroup/validation.js.map +1 -1
- package/crud/contentModelGroup.crud.js +5 -47
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/settings.crud.js +0 -12
- package/crud/settings.crud.js.map +1 -1
- package/crud/system.crud.js +1 -96
- package/crud/system.crud.js.map +1 -1
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +0 -13
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +0 -36
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +0 -53
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/index.js +0 -5
- package/fieldConverters/index.js.map +1 -1
- package/graphql/buildSchemaPlugins.js +4 -9
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/createExecutableSchema.js +2 -6
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/generateSchema.js +0 -7
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/graphQLHandlerFactory.js +16 -39
- package/graphql/graphQLHandlerFactory.js.map +1 -1
- package/graphql/index.js +0 -5
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseContentSchema.js +5 -17
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.js +1 -8
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/contentEntries.js +107 -102
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +3 -20
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +22 -25
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +5 -28
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createManageResolvers.d.ts +1 -1
- package/graphql/schema/createManageResolvers.js +33 -43
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.d.ts +1 -0
- package/graphql/schema/createManageSDL.js +57 -63
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.js +3 -17
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.js +4 -18
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.d.ts +1 -0
- package/graphql/schema/createReadSDL.js +24 -32
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +3 -2
- package/graphql/schema/resolvers/commonFieldResolvers.js +2 -3
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreate.js +0 -3
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +0 -3
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +0 -6
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGet.js +0 -16
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +0 -3
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +0 -3
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveList.js +0 -3
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolvePublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.js +0 -3
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveGet.js +0 -8
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveList.js +0 -3
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js +0 -8
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveList.js +0 -3
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
- package/graphql/schema/schemaPlugins.js +16 -26
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.js +1 -30
- package/graphql/system.js.map +1 -1
- package/graphqlFields/boolean.js +0 -12
- package/graphqlFields/boolean.js.map +1 -1
- package/graphqlFields/datetime.js +0 -17
- package/graphqlFields/datetime.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.js +15 -33
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +2 -18
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
- package/graphqlFields/dynamicZone/index.js +0 -2
- package/graphqlFields/dynamicZone/index.js.map +1 -1
- package/graphqlFields/file.js +0 -8
- package/graphqlFields/file.js.map +1 -1
- package/graphqlFields/helpers.js +0 -10
- package/graphqlFields/helpers.js.map +1 -1
- package/graphqlFields/index.js +0 -12
- package/graphqlFields/index.js.map +1 -1
- package/graphqlFields/longText.js +0 -10
- package/graphqlFields/longText.js.map +1 -1
- package/graphqlFields/number.js +0 -12
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js +7 -37
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +59 -65
- package/graphqlFields/ref.js.map +1 -1
- package/graphqlFields/richText.js +0 -9
- package/graphqlFields/richText.js.map +1 -1
- package/graphqlFields/text.js +0 -11
- package/graphqlFields/text.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +1 -21
- package/index.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.js +0 -16
- package/modelManager/DefaultCmsModelManager.js.map +1 -1
- package/modelManager/index.js +0 -4
- package/modelManager/index.js.map +1 -1
- package/package.json +24 -25
- package/parameters/context.js +0 -4
- package/parameters/context.js.map +1 -1
- package/parameters/header.js +0 -11
- package/parameters/header.js.map +1 -1
- package/parameters/index.js +0 -8
- package/parameters/index.js.map +1 -1
- package/parameters/manual.js +1 -8
- package/parameters/manual.js.map +1 -1
- package/parameters/path.js +0 -11
- package/parameters/path.js.map +1 -1
- package/plugins/CmsGraphQLSchemaPlugin.js +0 -5
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -1
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +0 -10
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
- package/plugins/CmsGroupPlugin.js +0 -8
- package/plugins/CmsGroupPlugin.js.map +1 -1
- package/plugins/CmsModelFieldConverterPlugin.js +0 -5
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
- package/plugins/CmsModelPlugin.d.ts +11 -1
- package/plugins/CmsModelPlugin.js +15 -40
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/CmsParametersPlugin.js +0 -7
- package/plugins/CmsParametersPlugin.js.map +1 -1
- package/plugins/StorageTransformPlugin.js +0 -9
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/plugins/index.js +0 -14
- package/plugins/index.js.map +1 -1
- package/storage/default.js +0 -3
- package/storage/default.js.map +1 -1
- package/storage/object.js +0 -19
- package/storage/object.js.map +1 -1
- package/types.d.ts +77 -22
- package/types.js +1 -80
- package/types.js.map +1 -1
- package/utils/access.js +11 -25
- package/utils/access.js.map +1 -1
- package/utils/converters/Converter.js +0 -13
- package/utils/converters/Converter.js.map +1 -1
- package/utils/converters/ConverterCollection.js +9 -33
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.js +2 -27
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.d.ts +1 -0
- package/utils/createTypeFromFields.js +11 -19
- package/utils/createTypeFromFields.js.map +1 -1
- package/utils/createTypeName.js +0 -9
- package/utils/createTypeName.js.map +1 -1
- package/utils/entryStorage.js +10 -26
- package/utils/entryStorage.js.map +1 -1
- package/utils/filterAsync.js +0 -5
- package/utils/filterAsync.js.map +1 -1
- package/utils/getBaseFieldType.js +0 -2
- package/utils/getBaseFieldType.js.map +1 -1
- package/utils/getEntryDescription.d.ts +2 -0
- package/utils/getEntryDescription.js +17 -0
- package/utils/getEntryDescription.js.map +1 -0
- package/utils/getEntryImage.d.ts +2 -0
- package/utils/getEntryImage.js +17 -0
- package/utils/getEntryImage.js.map +1 -0
- package/utils/getEntryTitle.js +0 -9
- package/utils/getEntryTitle.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.js +2 -11
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/ownership.d.ts +3 -3
- package/utils/ownership.js +0 -8
- package/utils/ownership.js.map +1 -1
- package/utils/permissions.js +8 -23
- package/utils/permissions.js.map +1 -1
- package/utils/removeNullValues.d.ts +1 -0
- package/utils/removeNullValues.js +17 -0
- package/utils/removeNullValues.js.map +1 -0
- package/utils/removeUndefinedValues.d.ts +1 -0
- package/utils/removeUndefinedValues.js +17 -0
- package/utils/removeUndefinedValues.js.map +1 -0
- package/utils/renderFields.d.ts +2 -1
- package/utils/renderFields.js +8 -10
- package/utils/renderFields.js.map +1 -1
- package/utils/renderGetFilterFields.js +0 -13
- package/utils/renderGetFilterFields.js.map +1 -1
- package/utils/renderInputFields.d.ts +2 -1
- package/utils/renderInputFields.js +4 -9
- package/utils/renderInputFields.js.map +1 -1
- package/utils/renderListFilterFields.js +1 -10
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.js +0 -9
- package/utils/renderSortEnum.js.map +1 -1
- package/utils/toSlug.js +0 -4
- package/utils/toSlug.js.map +1 -1
- package/validators/dateGte.js +0 -7
- package/validators/dateGte.js.map +1 -1
- package/validators/dateLte.js +0 -7
- package/validators/dateLte.js.map +1 -1
- package/validators/dynamicZone.js +0 -4
- package/validators/dynamicZone.js.map +1 -1
- package/validators/gte.js +0 -8
- package/validators/gte.js.map +1 -1
- package/validators/in.js +0 -8
- package/validators/in.js.map +1 -1
- package/validators/index.js +0 -16
- package/validators/index.js.map +1 -1
- package/validators/lte.js +0 -8
- package/validators/lte.js.map +1 -1
- package/validators/maxLength.js +0 -8
- package/validators/maxLength.js.map +1 -1
- package/validators/minLength.js +0 -8
- package/validators/minLength.js.map +1 -1
- package/validators/pattern.js +0 -9
- package/validators/pattern.js.map +1 -1
- package/validators/patternPlugins/email.js +0 -2
- package/validators/patternPlugins/email.js.map +1 -1
- package/validators/patternPlugins/index.js +0 -8
- package/validators/patternPlugins/index.js.map +1 -1
- package/validators/patternPlugins/lowerCase.js +0 -2
- package/validators/patternPlugins/lowerCase.js.map +1 -1
- package/validators/patternPlugins/lowerCaseSpace.js +0 -2
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
- package/validators/patternPlugins/upperCase.js +0 -2
- package/validators/patternPlugins/upperCase.js.map +1 -1
- package/validators/patternPlugins/upperCaseSpace.js +0 -2
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
- package/validators/patternPlugins/url.js +0 -2
- package/validators/patternPlugins/url.js.map +1 -1
- package/validators/required.js +0 -5
- package/validators/required.js.map +1 -1
- package/validators/timeGte.js +0 -8
- package/validators/timeGte.js.map +1 -1
- package/validators/timeLte.js +0 -8
- package/validators/timeLte.js.map +1 -1
- package/validators/unique.js +0 -7
- package/validators/unique.js.map +1 -1
package/parameters/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _manual = require("./manual");
|
|
8
|
-
|
|
9
7
|
Object.keys(_manual).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _manual[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_manual).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _path = require("./path");
|
|
21
|
-
|
|
22
18
|
Object.keys(_path).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _path[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_path).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _context = require("./context");
|
|
34
|
-
|
|
35
29
|
Object.keys(_context).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _context[key]) return;
|
|
@@ -42,9 +36,7 @@ Object.keys(_context).forEach(function (key) {
|
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
|
-
|
|
46
39
|
var _header = require("./header");
|
|
47
|
-
|
|
48
40
|
Object.keys(_header).forEach(function (key) {
|
|
49
41
|
if (key === "default" || key === "__esModule") return;
|
|
50
42
|
if (key in exports && exports[key] === _header[key]) return;
|
package/parameters/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./manual\";\nexport * from \"./path\";\nexport * from \"./context\";\nexport * from \"./header\";\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./manual\";\nexport * from \"./path\";\nexport * from \"./context\";\nexport * from \"./header\";\n"],"mappings":";;;;;AAAA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
package/parameters/manual.js
CHANGED
|
@@ -1,21 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createManualPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
13
|
-
|
|
14
10
|
var _CmsParametersPlugin = require("../plugins/CmsParametersPlugin");
|
|
15
|
-
|
|
16
11
|
/**
|
|
17
12
|
* This would be used for custom Lambdas when there is no path or header information about the endpoint type and locale.
|
|
18
13
|
*/
|
|
14
|
+
|
|
19
15
|
const createManualPlugin = params => {
|
|
20
16
|
return new _CmsParametersPlugin.CmsParametersPlugin(async () => {
|
|
21
17
|
const {
|
|
@@ -25,7 +21,6 @@ const createManualPlugin = params => {
|
|
|
25
21
|
/**
|
|
26
22
|
* if both of parameters are not existing, just skip this plugin.
|
|
27
23
|
*/
|
|
28
|
-
|
|
29
24
|
if (!type && !locale) {
|
|
30
25
|
return null;
|
|
31
26
|
} else if (!type) {
|
|
@@ -33,12 +28,10 @@ const createManualPlugin = params => {
|
|
|
33
28
|
} else if (!locale) {
|
|
34
29
|
throw new _error.default(`There is defined "endpointType" CMS parameter but no "locale".`, "MALFORMED_LOCALE_TYPE", (0, _objectSpread2.default)({}, params));
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
return {
|
|
38
32
|
type,
|
|
39
33
|
locale
|
|
40
34
|
};
|
|
41
35
|
});
|
|
42
36
|
};
|
|
43
|
-
|
|
44
37
|
exports.createManualPlugin = createManualPlugin;
|
package/parameters/manual.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createManualPlugin","params","CmsParametersPlugin","endpointType","type","locale","WebinyError"],"sources":["manual.ts"],"sourcesContent":["/**\n * This would be used for custom Lambdas when there is no path or header information about the endpoint type and locale.\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsParametersPlugin,\n CmsParametersPluginResponseLocale,\n CmsParametersPluginResponseType\n} from \"~/plugins/CmsParametersPlugin\";\n\nexport interface ManualPluginParams {\n endpointType?: CmsParametersPluginResponseType;\n locale?: CmsParametersPluginResponseLocale;\n}\n\nexport const createManualPlugin = (params: ManualPluginParams): CmsParametersPlugin => {\n return new CmsParametersPlugin(async () => {\n const { endpointType: type, locale } = params;\n /**\n * if both of parameters are not existing, just skip this plugin.\n */\n if (!type && !locale) {\n return null;\n } else if (!type) {\n throw new WebinyError(\n `There is defined \"locale\" CMS parameter but no \"endpointType\".`,\n \"MALFORMED_ENDPOINT_TYPE\",\n {\n ...params\n }\n );\n } else if (!locale) {\n throw new WebinyError(\n `There is defined \"endpointType\" CMS parameter but no \"locale\".`,\n \"MALFORMED_LOCALE_TYPE\",\n {\n ...params\n }\n );\n }\n\n return {\n type,\n locale\n };\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["createManualPlugin","params","CmsParametersPlugin","endpointType","type","locale","WebinyError"],"sources":["manual.ts"],"sourcesContent":["/**\n * This would be used for custom Lambdas when there is no path or header information about the endpoint type and locale.\n */\nimport WebinyError from \"@webiny/error\";\nimport {\n CmsParametersPlugin,\n CmsParametersPluginResponseLocale,\n CmsParametersPluginResponseType\n} from \"~/plugins/CmsParametersPlugin\";\n\nexport interface ManualPluginParams {\n endpointType?: CmsParametersPluginResponseType;\n locale?: CmsParametersPluginResponseLocale;\n}\n\nexport const createManualPlugin = (params: ManualPluginParams): CmsParametersPlugin => {\n return new CmsParametersPlugin(async () => {\n const { endpointType: type, locale } = params;\n /**\n * if both of parameters are not existing, just skip this plugin.\n */\n if (!type && !locale) {\n return null;\n } else if (!type) {\n throw new WebinyError(\n `There is defined \"locale\" CMS parameter but no \"endpointType\".`,\n \"MALFORMED_ENDPOINT_TYPE\",\n {\n ...params\n }\n );\n } else if (!locale) {\n throw new WebinyError(\n `There is defined \"endpointType\" CMS parameter but no \"locale\".`,\n \"MALFORMED_LOCALE_TYPE\",\n {\n ...params\n }\n );\n }\n\n return {\n type,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;;AAGA;AACA;AAJA;AACA;AACA;;AAaO,MAAMA,kBAAkB,GAAIC,MAA0B,IAA0B;EACnF,OAAO,IAAIC,wCAAmB,CAAC,YAAY;IACvC,MAAM;MAAEC,YAAY,EAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGJ,MAAM;IAC7C;AACR;AACA;IACQ,IAAI,CAACG,IAAI,IAAI,CAACC,MAAM,EAAE;MAClB,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,CAACD,IAAI,EAAE;MACd,MAAM,IAAIE,cAAW,CAChB,gEAA+D,EAChE,yBAAyB,kCAElBL,MAAM,EAEhB;IACL,CAAC,MAAM,IAAI,CAACI,MAAM,EAAE;MAChB,MAAM,IAAIC,cAAW,CAChB,gEAA+D,EAChE,uBAAuB,kCAEhBL,MAAM,EAEhB;IACL;IAEA,OAAO;MACHG,IAAI;MACJC;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAAC"}
|
package/parameters/path.js
CHANGED
|
@@ -1,38 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createPathParameterPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
var _CmsParametersPlugin = require("../plugins/CmsParametersPlugin");
|
|
13
|
-
|
|
14
10
|
const allowedEndpoints = ["manage", "read", "preview"];
|
|
15
|
-
|
|
16
11
|
const createPathParameterPlugin = () => {
|
|
17
12
|
return new _CmsParametersPlugin.CmsParametersPlugin(async context => {
|
|
18
13
|
var _context$request;
|
|
19
|
-
|
|
20
14
|
/**
|
|
21
15
|
* If any of the properties is not defined, just ignore this plugin
|
|
22
16
|
*/
|
|
23
17
|
if (!((_context$request = context.request) !== null && _context$request !== void 0 && _context$request.params)) {
|
|
24
18
|
return null;
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
const {
|
|
28
21
|
type,
|
|
29
22
|
locale
|
|
30
23
|
} = context.request.params;
|
|
31
|
-
|
|
32
24
|
if (!type && !locale) {
|
|
33
25
|
return null;
|
|
34
26
|
}
|
|
35
|
-
|
|
36
27
|
if (!type) {
|
|
37
28
|
throw new _error.default(`Missing request parameter "type".`);
|
|
38
29
|
} else if (!locale) {
|
|
@@ -40,12 +31,10 @@ const createPathParameterPlugin = () => {
|
|
|
40
31
|
} else if (allowedEndpoints.includes(type) === false) {
|
|
41
32
|
throw new _error.default(`Endpoint "${type}" not allowed!`);
|
|
42
33
|
}
|
|
43
|
-
|
|
44
34
|
return {
|
|
45
35
|
type: type,
|
|
46
36
|
locale
|
|
47
37
|
};
|
|
48
38
|
});
|
|
49
39
|
};
|
|
50
|
-
|
|
51
40
|
exports.createPathParameterPlugin = createPathParameterPlugin;
|
package/parameters/path.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC;AAE9D,MAAMC,yBAAyB,GAAG,MAAM;EAC3C,OAAO,IAAIC,wCAAmB,CAAC,MAAMC,OAAO,IAAI;IAAA;IAC5C;AACR;AACA;IACQ,IAAI,sBAACA,OAAO,CAACC,OAAO,6CAAf,iBAAiBC,MAAM,GAAE;MAC1B,OAAO,IAAI;IACf;IAEA,MAAM;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAGJ,OAAO,CAACC,OAAO,CAACC,MAAuC;IAChF,IAAI,CAACC,IAAI,IAAI,CAACC,MAAM,EAAE;MAClB,OAAO,IAAI;IACf;IAEA,IAAI,CAACD,IAAI,EAAE;MACP,MAAM,IAAIE,cAAW,CAAE,mCAAkC,CAAC;IAC9D,CAAC,MAAM,IAAI,CAACD,MAAM,EAAE;MAChB,MAAM,IAAIC,cAAW,CAAE,qCAAoC,CAAC;IAChE,CAAC,MAAM,IAAIR,gBAAgB,CAACS,QAAQ,CAACH,IAAI,CAAgB,KAAK,KAAK,EAAE;MACjE,MAAM,IAAIE,cAAW,CAAE,aAAYF,IAAK,gBAAe,CAAC;IAC5D;IAEA,OAAO;MACHA,IAAI,EAAEA,IAAmB;MACzBC;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CmsGraphQLSchemaPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
13
|
-
|
|
14
10
|
class CmsGraphQLSchemaPlugin extends _handlerGraphql.GraphQLSchemaPlugin {}
|
|
15
|
-
|
|
16
11
|
exports.CmsGraphQLSchemaPlugin = CmsGraphQLSchemaPlugin;
|
|
17
12
|
(0, _defineProperty2.default)(CmsGraphQLSchemaPlugin, "type", "cms.graphql.schema");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsGraphQLSchemaPlugin","GraphQLSchemaPlugin"],"sources":["CmsGraphQLSchemaPlugin.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\n\nexport class CmsGraphQLSchemaPlugin<T = CmsContext> extends GraphQLSchemaPlugin<T> {\n public static override type = \"cms.graphql.schema\";\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CmsGraphQLSchemaPlugin","GraphQLSchemaPlugin"],"sources":["CmsGraphQLSchemaPlugin.ts"],"sourcesContent":["import { GraphQLSchemaPlugin } from \"@webiny/handler-graphql\";\nimport { CmsContext } from \"~/types\";\n\nexport class CmsGraphQLSchemaPlugin<T = CmsContext> extends GraphQLSchemaPlugin<T> {\n public static override type = \"cms.graphql.schema\";\n}\n"],"mappings":";;;;;;;;AAAA;AAGO,MAAMA,sBAAsB,SAAyBC,mCAAmB,CAAI;AAElF;AAAA,8BAFYD,sBAAsB,UACD,oBAAoB"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createCmsGraphQLSchemaSorterPlugin = exports.CmsGraphQLSchemaSorterPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CmsGraphQLSchemaSorterPlugin extends _plugins.Plugin {
|
|
15
11
|
constructor(cb) {
|
|
16
12
|
super();
|
|
@@ -20,19 +16,13 @@ class CmsGraphQLSchemaSorterPlugin extends _plugins.Plugin {
|
|
|
20
16
|
/**
|
|
21
17
|
* Method must return new sorting array. Or existing one if no changes are made.
|
|
22
18
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
19
|
createSorter(params) {
|
|
26
20
|
return this.cb(params);
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
exports.CmsGraphQLSchemaSorterPlugin = CmsGraphQLSchemaSorterPlugin;
|
|
32
24
|
(0, _defineProperty2.default)(CmsGraphQLSchemaSorterPlugin, "type", "cms.graphql.schema.sorter");
|
|
33
|
-
|
|
34
25
|
const createCmsGraphQLSchemaSorterPlugin = cb => {
|
|
35
26
|
return new CmsGraphQLSchemaSorterPlugin(cb);
|
|
36
27
|
};
|
|
37
|
-
|
|
38
28
|
exports.createCmsGraphQLSchemaSorterPlugin = createCmsGraphQLSchemaSorterPlugin;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsGraphQLSchemaSorterPlugin","Plugin","constructor","cb","createSorter","params","createCmsGraphQLSchemaSorterPlugin"],"sources":["CmsGraphQLSchemaSorterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModel } from \"~/types\";\n\ninterface CmsGraphQLSchemaSorterPluginCallableParams {\n model: CmsModel;\n sorters: string[];\n}\ninterface CmsGraphQLSchemaSorterPluginCallable {\n (params: CmsGraphQLSchemaSorterPluginCallableParams): string[];\n}\nexport class CmsGraphQLSchemaSorterPlugin extends Plugin {\n public static override readonly type: string = \"cms.graphql.schema.sorter\";\n\n private readonly cb: CmsGraphQLSchemaSorterPluginCallable;\n public constructor(cb: CmsGraphQLSchemaSorterPluginCallable) {\n super();\n\n this.cb = cb;\n }\n /**\n * Method must return new sorting array. Or existing one if no changes are made.\n */\n public createSorter(params: CmsGraphQLSchemaSorterPluginCallableParams): string[] {\n return this.cb(params);\n }\n}\n\nexport const createCmsGraphQLSchemaSorterPlugin = (\n cb: CmsGraphQLSchemaSorterPluginCallable\n): CmsGraphQLSchemaSorterPlugin => {\n return new CmsGraphQLSchemaSorterPlugin(cb);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CmsGraphQLSchemaSorterPlugin","Plugin","constructor","cb","createSorter","params","createCmsGraphQLSchemaSorterPlugin"],"sources":["CmsGraphQLSchemaSorterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsModel } from \"~/types\";\n\ninterface CmsGraphQLSchemaSorterPluginCallableParams {\n model: CmsModel;\n sorters: string[];\n}\ninterface CmsGraphQLSchemaSorterPluginCallable {\n (params: CmsGraphQLSchemaSorterPluginCallableParams): string[];\n}\nexport class CmsGraphQLSchemaSorterPlugin extends Plugin {\n public static override readonly type: string = \"cms.graphql.schema.sorter\";\n\n private readonly cb: CmsGraphQLSchemaSorterPluginCallable;\n public constructor(cb: CmsGraphQLSchemaSorterPluginCallable) {\n super();\n\n this.cb = cb;\n }\n /**\n * Method must return new sorting array. Or existing one if no changes are made.\n */\n public createSorter(params: CmsGraphQLSchemaSorterPluginCallableParams): string[] {\n return this.cb(params);\n }\n}\n\nexport const createCmsGraphQLSchemaSorterPlugin = (\n cb: CmsGraphQLSchemaSorterPluginCallable\n): CmsGraphQLSchemaSorterPlugin => {\n return new CmsGraphQLSchemaSorterPlugin(cb);\n};\n"],"mappings":";;;;;;;;AAAA;AAUO,MAAMA,4BAA4B,SAASC,eAAM,CAAC;EAI9CC,WAAW,CAACC,EAAwC,EAAE;IACzD,KAAK,EAAE;IAAC;IAER,IAAI,CAACA,EAAE,GAAGA,EAAE;EAChB;EACA;AACJ;AACA;EACWC,YAAY,CAACC,MAAkD,EAAY;IAC9E,OAAO,IAAI,CAACF,EAAE,CAACE,MAAM,CAAC;EAC1B;AACJ;AAAC;AAAA,8BAfYL,4BAA4B,UACU,2BAA2B;AAgBvE,MAAMM,kCAAkC,GAC3CH,EAAwC,IACT;EAC/B,OAAO,IAAIH,4BAA4B,CAACG,EAAE,CAAC;AAC/C,CAAC;AAAC"}
|
|
@@ -1,30 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createCmsGroup = exports.CmsGroupPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CmsGroupPlugin extends _plugins.Plugin {
|
|
15
11
|
constructor(contentModelGroup) {
|
|
16
12
|
super();
|
|
17
13
|
(0, _defineProperty2.default)(this, "contentModelGroup", void 0);
|
|
18
14
|
this.contentModelGroup = contentModelGroup;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
}
|
|
22
|
-
|
|
23
17
|
exports.CmsGroupPlugin = CmsGroupPlugin;
|
|
24
18
|
(0, _defineProperty2.default)(CmsGroupPlugin, "type", "cms-content-model-group");
|
|
25
|
-
|
|
26
19
|
const createCmsGroup = group => {
|
|
27
20
|
return new CmsGroupPlugin(group);
|
|
28
21
|
};
|
|
29
|
-
|
|
30
22
|
exports.createCmsGroup = createCmsGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsGroupPlugin","Plugin","constructor","contentModelGroup","createCmsGroup","group"],"sources":["CmsGroupPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsGroup as BaseCmsGroup } from \"~/types\";\n\ninterface CmsGroup extends Omit<BaseCmsGroup, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n tenant?: string;\n locale?: string;\n}\nexport class CmsGroupPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model-group\";\n public readonly contentModelGroup: CmsGroup;\n\n constructor(contentModelGroup: CmsGroup) {\n super();\n this.contentModelGroup = contentModelGroup;\n }\n}\n\nexport const createCmsGroup = (group: CmsGroup): CmsGroupPlugin => {\n return new CmsGroupPlugin(group);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CmsGroupPlugin","Plugin","constructor","contentModelGroup","createCmsGroup","group"],"sources":["CmsGroupPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsGroup as BaseCmsGroup } from \"~/types\";\n\ninterface CmsGroup extends Omit<BaseCmsGroup, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n tenant?: string;\n locale?: string;\n}\nexport class CmsGroupPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model-group\";\n public readonly contentModelGroup: CmsGroup;\n\n constructor(contentModelGroup: CmsGroup) {\n super();\n this.contentModelGroup = contentModelGroup;\n }\n}\n\nexport const createCmsGroup = (group: CmsGroup): CmsGroupPlugin => {\n return new CmsGroupPlugin(group);\n};\n"],"mappings":";;;;;;;;AAAA;AAOO,MAAMA,cAAc,SAASC,eAAM,CAAC;EAIvCC,WAAW,CAACC,iBAA2B,EAAE;IACrC,KAAK,EAAE;IAAC;IACR,IAAI,CAACA,iBAAiB,GAAGA,iBAAiB;EAC9C;AACJ;AAAC;AAAA,8BARYH,cAAc,UACwB,yBAAyB;AASrE,MAAMI,cAAc,GAAIC,KAAe,IAAqB;EAC/D,OAAO,IAAIL,cAAc,CAACK,KAAK,CAAC;AACpC,CAAC;AAAC"}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CmsModelFieldConverterPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CmsModelFieldConverterPlugin extends _plugins.Plugin {}
|
|
15
|
-
|
|
16
11
|
exports.CmsModelFieldConverterPlugin = CmsModelFieldConverterPlugin;
|
|
17
12
|
(0, _defineProperty2.default)(CmsModelFieldConverterPlugin, "type", "cms.field.converter");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsModelFieldConverterPlugin","Plugin"],"sources":["CmsModelFieldConverterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsEntryValues, CmsModelFieldWithParent } from \"~/types\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\n\nexport interface ConvertParams<F = CmsModelFieldWithParent> {\n field: F;\n value: any;\n converterCollection: ConverterCollection;\n}\n\nexport abstract class CmsModelFieldConverterPlugin extends Plugin {\n public static override type = \"cms.field.converter\";\n\n public abstract getFieldType(): string;\n\n public abstract convertToStorage(params: ConvertParams): CmsEntryValues;\n public abstract convertFromStorage(params: ConvertParams): CmsEntryValues;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["CmsModelFieldConverterPlugin","Plugin"],"sources":["CmsModelFieldConverterPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport { CmsEntryValues, CmsModelFieldWithParent } from \"~/types\";\nimport { ConverterCollection } from \"~/utils/converters/ConverterCollection\";\n\nexport interface ConvertParams<F = CmsModelFieldWithParent> {\n field: F;\n value: any;\n converterCollection: ConverterCollection;\n}\n\nexport abstract class CmsModelFieldConverterPlugin extends Plugin {\n public static override type = \"cms.field.converter\";\n\n public abstract getFieldType(): string;\n\n public abstract convertToStorage(params: ConvertParams): CmsEntryValues;\n public abstract convertFromStorage(params: ConvertParams): CmsEntryValues;\n}\n"],"mappings":";;;;;;;;AAAA;AAUO,MAAeA,4BAA4B,SAASC,eAAM,CAAC;AAOjE;AAAA,8BAPqBD,4BAA4B,UAChB,qBAAqB"}
|
|
@@ -20,11 +20,21 @@ interface CmsModelFieldInput extends Omit<CmsModelFieldBase, "storageId" | "sett
|
|
|
20
20
|
*/
|
|
21
21
|
settings?: CmsModelFieldSettings;
|
|
22
22
|
}
|
|
23
|
-
interface
|
|
23
|
+
interface CmsApiModel extends Omit<CmsModelBase, "isPrivate" | "locale" | "tenant" | "webinyVersion" | "fields"> {
|
|
24
|
+
isPrivate?: never;
|
|
24
25
|
fields: CmsModelFieldInput[];
|
|
25
26
|
locale?: string;
|
|
26
27
|
tenant?: string;
|
|
27
28
|
}
|
|
29
|
+
interface CmsPrivateModel extends Omit<CmsModelBase, "isPrivate" | "singularApiName" | "pluralApiName" | "locale" | "tenant" | "webinyVersion" | "fields"> {
|
|
30
|
+
singularApiName?: never;
|
|
31
|
+
pluralApiName?: never;
|
|
32
|
+
isPrivate: true;
|
|
33
|
+
fields: CmsModelFieldInput[];
|
|
34
|
+
locale?: string;
|
|
35
|
+
tenant?: string;
|
|
36
|
+
}
|
|
37
|
+
declare type CmsModelInput = CmsApiModel | CmsPrivateModel;
|
|
28
38
|
interface CmsModel extends Omit<CmsModelBase, "locale" | "tenant" | "webinyVersion"> {
|
|
29
39
|
locale?: string;
|
|
30
40
|
tenant?: string;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.createCmsModel = exports.CmsModelPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
11
|
-
|
|
12
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
-
|
|
14
|
-
var _plugins = require("@webiny/plugins");
|
|
15
|
-
|
|
16
10
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
17
|
-
|
|
18
|
-
var _createFieldStorageId = require("../crud/contentModel/createFieldStorageId");
|
|
19
|
-
|
|
20
11
|
var _camelCase = _interopRequireDefault(require("lodash/camelCase"));
|
|
21
|
-
|
|
12
|
+
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst"));
|
|
13
|
+
var _pluralize = _interopRequireDefault(require("pluralize"));
|
|
14
|
+
var _plugins = require("@webiny/plugins");
|
|
15
|
+
var _createFieldStorageId = require("../crud/contentModel/createFieldStorageId");
|
|
16
|
+
const transformNameToSingularApiName = name => {
|
|
17
|
+
return (0, _upperFirst.default)((0, _camelCase.default)(name));
|
|
18
|
+
};
|
|
19
|
+
const transformNameToPluralApiName = name => {
|
|
20
|
+
return (0, _pluralize.default)(transformNameToSingularApiName(name));
|
|
21
|
+
};
|
|
22
22
|
class CmsModelPlugin extends _plugins.Plugin {
|
|
23
23
|
constructor(contentModel, options) {
|
|
24
24
|
super();
|
|
@@ -27,29 +27,27 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
27
27
|
this.options = options || {};
|
|
28
28
|
this.contentModel = this.buildModel(contentModel);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
buildModel(input) {
|
|
32
31
|
const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
32
|
+
isPrivate: input.isPrivate || false,
|
|
33
|
+
singularApiName: input.singularApiName || transformNameToSingularApiName(input.name),
|
|
34
|
+
pluralApiName: input.pluralApiName || transformNameToPluralApiName(input.name),
|
|
33
35
|
fields: this.buildFields(input, input.fields)
|
|
34
36
|
});
|
|
35
37
|
this.validateLayout(model);
|
|
36
38
|
return model;
|
|
37
39
|
}
|
|
38
|
-
|
|
39
40
|
buildFields(model, inputFields) {
|
|
40
41
|
if (inputFields.length === 0) {
|
|
41
42
|
throw new _error.default(`Missing fields for the defined model "${model.modelId}".`, "MISSING_FIELDS", {
|
|
42
43
|
model
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
|
-
|
|
46
46
|
const fields = [];
|
|
47
47
|
const storageIdList = [];
|
|
48
48
|
const fieldIdList = [];
|
|
49
|
-
|
|
50
49
|
for (const input of inputFields) {
|
|
51
50
|
var _settings;
|
|
52
|
-
|
|
53
51
|
/**
|
|
54
52
|
* Field must contain an fieldId. It is required in the graphql, but lets check it just in case
|
|
55
53
|
*/
|
|
@@ -59,12 +57,10 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
59
57
|
field: input
|
|
60
58
|
});
|
|
61
59
|
}
|
|
62
|
-
|
|
63
60
|
const fieldId = (0, _camelCase.default)(input.fieldId);
|
|
64
61
|
/**
|
|
65
62
|
* FieldID must be in correct pattern.
|
|
66
63
|
*/
|
|
67
|
-
|
|
68
64
|
if (fieldId.match(/^[0-9]/) !== null) {
|
|
69
65
|
throw new _error.default(`Field's "fieldId" does not match correct pattern in the content model "${model.modelId}" - cannot start with a number.`, "FIELD_FIELD_ID_ERROR", {
|
|
70
66
|
model,
|
|
@@ -74,8 +70,6 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
74
70
|
/**
|
|
75
71
|
* FieldID also must be camelCased.
|
|
76
72
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
73
|
if (fieldId !== input.fieldId) {
|
|
80
74
|
throw new _error.default(`Field's "fieldId" must be a camel cased string in the content model "${model.modelId}".`, "FIELD_FIELD_ID_ERROR", {
|
|
81
75
|
model,
|
|
@@ -85,20 +79,16 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
85
79
|
/**
|
|
86
80
|
* ... and fieldId must be unique.
|
|
87
81
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
82
|
if (fieldIdList.includes(fieldId) === true) {
|
|
91
83
|
throw new _error.default(`Field's "fieldId" is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
|
|
92
84
|
model,
|
|
93
85
|
field: input
|
|
94
86
|
});
|
|
95
87
|
}
|
|
96
|
-
|
|
97
88
|
let storageId = input.storageId ? (0, _camelCase.default)(input.storageId) : null;
|
|
98
89
|
/**
|
|
99
90
|
* If defined, storageId MUST be camel cased string - for backward compatibility.
|
|
100
91
|
*/
|
|
101
|
-
|
|
102
92
|
if (storageId && (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)) {
|
|
103
93
|
throw new _error.default(`Field's "storageId" of the field with "fieldId" ${input.fieldId} is not camel cased string in the content model "${model.modelId}".`, "STORAGE_ID_NOT_CAMEL_CASED_ERROR", {
|
|
104
94
|
model,
|
|
@@ -108,32 +98,28 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
108
98
|
} else if (!storageId) {
|
|
109
99
|
storageId = (0, _createFieldStorageId.createFieldStorageId)(input);
|
|
110
100
|
}
|
|
101
|
+
|
|
111
102
|
/**
|
|
112
103
|
* Fields storageId must be unique.
|
|
113
104
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
105
|
if (storageIdList.includes(storageId) === true) {
|
|
117
106
|
throw new _error.default(`Field's "storageId" is not unique in the content model "${model.modelId}".`, "STORAGE_ID_ERROR", {
|
|
118
107
|
model,
|
|
119
108
|
field: input
|
|
120
109
|
});
|
|
121
110
|
}
|
|
111
|
+
|
|
122
112
|
/**
|
|
123
113
|
* We can safely ignore error because we are going through the fields and making sure each has storageId.
|
|
124
114
|
*/
|
|
125
115
|
// @ts-ignore
|
|
126
|
-
|
|
127
|
-
|
|
128
116
|
let settings = input.settings;
|
|
129
117
|
const childFields = ((_settings = settings) === null || _settings === void 0 ? void 0 : _settings.fields) || [];
|
|
130
|
-
|
|
131
118
|
if (input.type === "object" && childFields.length > 0) {
|
|
132
119
|
settings = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings || {}), {}, {
|
|
133
120
|
fields: this.buildFields(model, childFields)
|
|
134
121
|
});
|
|
135
122
|
}
|
|
136
|
-
|
|
137
123
|
const field = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
138
124
|
settings,
|
|
139
125
|
storageId
|
|
@@ -141,15 +127,12 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
141
127
|
/**
|
|
142
128
|
* Add all relevant data to arrays.
|
|
143
129
|
*/
|
|
144
|
-
|
|
145
130
|
fields.push(field);
|
|
146
131
|
storageIdList.push(field.storageId);
|
|
147
132
|
fieldIdList.push(field.fieldId);
|
|
148
133
|
}
|
|
149
|
-
|
|
150
134
|
return fields;
|
|
151
135
|
}
|
|
152
|
-
|
|
153
136
|
validateLayout(model) {
|
|
154
137
|
/**
|
|
155
138
|
* Only skip validation if option.validateLayout was set as false, explicitly.
|
|
@@ -157,15 +140,12 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
157
140
|
if (this.options.validateLayout === false) {
|
|
158
141
|
return;
|
|
159
142
|
}
|
|
160
|
-
|
|
161
143
|
for (const field of model.fields) {
|
|
162
144
|
let total = 0;
|
|
163
|
-
|
|
164
145
|
for (const row of model.layout) {
|
|
165
146
|
const count = row.filter(cell => cell === field.id).length;
|
|
166
147
|
total = total + count;
|
|
167
148
|
}
|
|
168
|
-
|
|
169
149
|
if (total === 1) {
|
|
170
150
|
continue;
|
|
171
151
|
} else if (total > 1) {
|
|
@@ -174,21 +154,16 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
174
154
|
field
|
|
175
155
|
});
|
|
176
156
|
}
|
|
177
|
-
|
|
178
157
|
throw new _error.default(`Missing field "${field.id}" in layout.`, "MISSING_FIELD_IN_LAYOUT", {
|
|
179
158
|
model,
|
|
180
159
|
field
|
|
181
160
|
});
|
|
182
161
|
}
|
|
183
162
|
}
|
|
184
|
-
|
|
185
163
|
}
|
|
186
|
-
|
|
187
164
|
exports.CmsModelPlugin = CmsModelPlugin;
|
|
188
165
|
(0, _defineProperty2.default)(CmsModelPlugin, "type", "cms-content-model");
|
|
189
|
-
|
|
190
166
|
const createCmsModel = (model, options) => {
|
|
191
167
|
return new CmsModelPlugin(model, options);
|
|
192
168
|
};
|
|
193
|
-
|
|
194
169
|
exports.createCmsModel = createCmsModel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CmsModelPlugin","Plugin","constructor","contentModel","options","buildModel","input","model","fields","buildFields","validateLayout","inputFields","length","WebinyError","modelId","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","createFieldStorageId","settings","childFields","type","push","total","row","layout","count","filter","cell","id","createCmsModel"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport WebinyError from \"@webiny/error\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\nimport lodashCamelCase from \"lodash/camelCase\";\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * News ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\ninterface CmsModelInput\n extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\" | \"fields\"> {\n fields: CmsModelFieldInput[];\n locale?: string;\n tenant?: string;\n}\ninterface CmsModel extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModel {\n const model: CmsModel = {\n ...input,\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId) === true) {\n throw new WebinyError(\n `Field's \"fieldId\" is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId ? lodashCamelCase(input.storageId) : null;\n /**\n * If defined, storageId MUST be camel cased string - for backward compatibility.\n */\n if (\n storageId &&\n (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)\n ) {\n throw new WebinyError(\n `Field's \"storageId\" of the field with \"fieldId\" ${input.fieldId} is not camel cased string in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_NOT_CAMEL_CASED_ERROR\",\n {\n model,\n storageId,\n field: input\n }\n );\n } else if (!storageId) {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId) === true) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-ignore\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n"],"mappings":";;;;;;;;;;;;;AAAA;;AAMA;;AACA;;AACA;;AAuCO,MAAMA,cAAN,SAA6BC,eAA7B,CAAoC;EAMvCC,WAAW,CAACC,YAAD,EAA8BC,OAA9B,EAA+D;IACtE;IADsE;IAAA;IAEtE,KAAKA,OAAL,GAAeA,OAAO,IAAI,EAA1B;IACA,KAAKD,YAAL,GAAoB,KAAKE,UAAL,CAAgBF,YAAhB,CAApB;EACH;;EAEOE,UAAU,CAACC,KAAD,EAAiC;IAC/C,MAAMC,KAAe,+DACdD,KADc;MAEjBE,MAAM,EAAE,KAAKC,WAAL,CAAiBH,KAAjB,EAAwBA,KAAK,CAACE,MAA9B;IAFS,EAArB;IAIA,KAAKE,cAAL,CAAoBH,KAApB;IACA,OAAOA,KAAP;EACH;;EAEOE,WAAW,CACfF,KADe,EAEfI,WAFe,EAGI;IACnB,IAAIA,WAAW,CAACC,MAAZ,KAAuB,CAA3B,EAA8B;MAC1B,MAAM,IAAIC,cAAJ,CACD,yCAAwCN,KAAK,CAACO,OAAQ,IADrD,EAEF,gBAFE,EAGF;QACIP;MADJ,CAHE,CAAN;IAOH;;IACD,MAAMC,MAA2B,GAAG,EAApC;IACA,MAAMO,aAAuB,GAAG,EAAhC;IACA,MAAMC,WAAqB,GAAG,EAA9B;;IACA,KAAK,MAAMV,KAAX,IAAoBK,WAApB,EAAiC;MAAA;;MAC7B;AACZ;AACA;MACY,IAAI,CAAC,CAACL,KAAK,CAACW,OAAN,IAAiB,EAAlB,EAAsBC,IAAtB,EAAL,EAAmC;QAC/B,MAAM,IAAIL,cAAJ,CACD,6DAA4DN,KAAK,CAACO,OAAQ,IADzE,EAEF,gBAFE,EAGF;UACIP,KADJ;UAEIY,KAAK,EAAEb;QAFX,CAHE,CAAN;MAQH;;MACD,MAAMW,OAA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,IAAI,IAAIA,IAAI,KAAKf,KAAK,CAACgB,EAAlC,EAAsCvB,MAApD;QACAiB,KAAK,GAAGA,KAAK,GAAGG,KAAhB;MACH;;MACD,IAAIH,KAAK,KAAK,CAAd,EAAiB;QACb;MACH,CAFD,MAEO,IAAIA,KAAK,GAAG,CAAZ,EAAe;QAClB,MAAM,IAAIhB,cAAJ,CACD,UAASM,KAAK,CAACgB,EAAG,oCADjB,EAEF,2BAFE,EAGF;UACI5B,KADJ;UAEIY;QAFJ,CAHE,CAAN;MAQH;;MACD,MAAM,IAAIN,cAAJ,CACD,kBAAiBM,KAAK,CAACgB,EAAG,cADzB,EAEF,yBAFE,EAGF;QACI5B,KADJ;QAEIY;MAFJ,CAHE,CAAN;IAQH;EACJ;;AA9LsC;;;8BAA9BnB,c,UACsC,mB;;AAgM5C,MAAMoC,cAAc,GAAG,CAC1B7B,KAD0B,EAE1BH,OAF0B,KAGT;EACjB,OAAO,IAAIJ,cAAJ,CAAmBO,KAAnB,EAA0BH,OAA1B,CAAP;AACH,CALM"}
|
|
1
|
+
{"version":3,"names":["transformNameToSingularApiName","name","upperFirst","camelCase","transformNameToPluralApiName","pluralize","CmsModelPlugin","Plugin","constructor","contentModel","options","buildModel","input","model","isPrivate","singularApiName","pluralApiName","fields","buildFields","validateLayout","inputFields","length","WebinyError","modelId","storageIdList","fieldIdList","fieldId","trim","field","lodashCamelCase","match","includes","storageId","createFieldStorageId","settings","childFields","type","push","total","row","layout","count","filter","cell","id","createCmsModel"],"sources":["CmsModelPlugin.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport lodashCamelCase from \"lodash/camelCase\";\nimport camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { Plugin } from \"@webiny/plugins\";\nimport {\n CmsModel as CmsModelBase,\n CmsModelField as CmsModelFieldBase,\n CmsModelFieldSettings as BaseCmsModelFieldSettings\n} from \"~/types\";\nimport { createFieldStorageId } from \"~/crud/contentModel/createFieldStorageId\";\n\nconst transformNameToSingularApiName = (name: string) => {\n return upperFirst(camelCase(name));\n};\n\nconst transformNameToPluralApiName = (name: string) => {\n return pluralize(transformNameToSingularApiName(name));\n};\n\ninterface CmsModelFieldSettings extends Omit<BaseCmsModelFieldSettings, \"fields\"> {\n /**\n * Object field has child fields.\n */\n fields?: CmsModelFieldInput[];\n}\n\ninterface CmsModelFieldInput extends Omit<CmsModelFieldBase, \"storageId\" | \"settings\"> {\n /**\n * If defined, it must be camelCased string.\n * This is for backwards compatibility - before fields had storageId.\n *\n * This should only be populated in old model fields.\n * News ones must have this empty.\n */\n storageId?: string;\n /**\n * We must have a possibility to have a nested field defined without the storageId.\n */\n settings?: CmsModelFieldSettings;\n}\n\ninterface CmsApiModel\n extends Omit<CmsModelBase, \"isPrivate\" | \"locale\" | \"tenant\" | \"webinyVersion\" | \"fields\"> {\n isPrivate?: never;\n fields: CmsModelFieldInput[];\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsPrivateModel\n extends Omit<\n CmsModelBase,\n | \"isPrivate\"\n | \"singularApiName\"\n | \"pluralApiName\"\n | \"locale\"\n | \"tenant\"\n | \"webinyVersion\"\n | \"fields\"\n > {\n singularApiName?: never;\n pluralApiName?: never;\n isPrivate: true;\n fields: CmsModelFieldInput[];\n locale?: string;\n tenant?: string;\n}\n\ntype CmsModelInput = CmsApiModel | CmsPrivateModel;\n\ninterface CmsModel extends Omit<CmsModelBase, \"locale\" | \"tenant\" | \"webinyVersion\"> {\n locale?: string;\n tenant?: string;\n}\n\ninterface CmsModelPluginOptions {\n validateLayout?: boolean;\n}\n\nexport class CmsModelPlugin extends Plugin {\n public static override readonly type: string = \"cms-content-model\";\n public readonly contentModel: CmsModel;\n\n private readonly options: CmsModelPluginOptions;\n\n constructor(contentModel: CmsModelInput, options?: CmsModelPluginOptions) {\n super();\n this.options = options || {};\n this.contentModel = this.buildModel(contentModel);\n }\n\n private buildModel(input: CmsModelInput): CmsModel {\n const model: CmsModel = {\n ...input,\n isPrivate: input.isPrivate || false,\n singularApiName: input.singularApiName || transformNameToSingularApiName(input.name),\n pluralApiName: input.pluralApiName || transformNameToPluralApiName(input.name),\n fields: this.buildFields(input, input.fields)\n };\n this.validateLayout(model);\n return model;\n }\n\n private buildFields(\n model: CmsModelInput,\n inputFields: CmsModelFieldInput[]\n ): CmsModelFieldBase[] {\n if (inputFields.length === 0) {\n throw new WebinyError(\n `Missing fields for the defined model \"${model.modelId}\".`,\n \"MISSING_FIELDS\",\n {\n model\n }\n );\n }\n const fields: CmsModelFieldBase[] = [];\n const storageIdList: string[] = [];\n const fieldIdList: string[] = [];\n for (const input of inputFields) {\n /**\n * Field must contain an fieldId. It is required in the graphql, but lets check it just in case\n */\n if (!(input.fieldId || \"\").trim()) {\n throw new WebinyError(\n `Field's \"storageId\" is not defined for the content model \"${model.modelId}\".`,\n \"FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n const fieldId = lodashCamelCase(input.fieldId);\n /**\n * FieldID must be in correct pattern.\n */\n if (fieldId.match(/^[0-9]/) !== null) {\n throw new WebinyError(\n `Field's \"fieldId\" does not match correct pattern in the content model \"${model.modelId}\" - cannot start with a number.`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * FieldID also must be camelCased.\n */\n if (fieldId !== input.fieldId) {\n throw new WebinyError(\n `Field's \"fieldId\" must be a camel cased string in the content model \"${model.modelId}\".`,\n \"FIELD_FIELD_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n /**\n * ... and fieldId must be unique.\n */\n if (fieldIdList.includes(fieldId) === true) {\n throw new WebinyError(\n `Field's \"fieldId\" is not unique in the content model \"${model.modelId}\".`,\n \"FIELD_ID_NOT_UNIQUE_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n let storageId = input.storageId ? lodashCamelCase(input.storageId) : null;\n /**\n * If defined, storageId MUST be camel cased string - for backward compatibility.\n */\n if (\n storageId &&\n (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)\n ) {\n throw new WebinyError(\n `Field's \"storageId\" of the field with \"fieldId\" ${input.fieldId} is not camel cased string in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_NOT_CAMEL_CASED_ERROR\",\n {\n model,\n storageId,\n field: input\n }\n );\n } else if (!storageId) {\n storageId = createFieldStorageId(input);\n }\n\n /**\n * Fields storageId must be unique.\n */\n if (storageIdList.includes(storageId) === true) {\n throw new WebinyError(\n `Field's \"storageId\" is not unique in the content model \"${model.modelId}\".`,\n \"STORAGE_ID_ERROR\",\n {\n model,\n field: input\n }\n );\n }\n\n /**\n * We can safely ignore error because we are going through the fields and making sure each has storageId.\n */\n // @ts-ignore\n let settings: BaseCmsModelFieldSettings = input.settings;\n\n const childFields = settings?.fields || [];\n if (input.type === \"object\" && childFields.length > 0) {\n settings = {\n ...(settings || {}),\n fields: this.buildFields(model, childFields)\n };\n }\n\n const field: CmsModelFieldBase = {\n ...input,\n settings,\n storageId\n };\n /**\n * Add all relevant data to arrays.\n */\n fields.push(field);\n storageIdList.push(field.storageId);\n fieldIdList.push(field.fieldId);\n }\n return fields;\n }\n\n private validateLayout(model: CmsModel): void {\n /**\n * Only skip validation if option.validateLayout was set as false, explicitly.\n */\n if (this.options.validateLayout === false) {\n return;\n }\n for (const field of model.fields) {\n let total = 0;\n for (const row of model.layout) {\n const count = row.filter(cell => cell === field.id).length;\n total = total + count;\n }\n if (total === 1) {\n continue;\n } else if (total > 1) {\n throw new WebinyError(\n `Field \"${field.id}\" is in more than one layout cell.`,\n \"DUPLICATE_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n throw new WebinyError(\n `Missing field \"${field.id}\" in layout.`,\n \"MISSING_FIELD_IN_LAYOUT\",\n {\n model,\n field\n }\n );\n }\n }\n}\n\nexport const createCmsModel = (\n model: CmsModelInput,\n options?: CmsModelPluginOptions\n): CmsModelPlugin => {\n return new CmsModelPlugin(model, options);\n};\n"],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OT,MAAM;EACjB;EAEQE,cAAc,CAACN,KAAe,EAAQ;IAC1C;AACR;AACA;IACQ,IAAI,IAAI,CAACH,OAAO,CAACS,cAAc,KAAK,KAAK,EAAE;MACvC;IACJ;IACA,KAAK,MAAMS,KAAK,IAAIf,KAAK,CAACI,MAAM,EAAE;MAC9B,IAAIqB,KAAK,GAAG,CAAC;MACb,KAAK,MAAMC,GAAG,IAAI1B,KAAK,CAAC2B,MAAM,EAAE;QAC5B,MAAMC,KAAK,GAAGF,GAAG,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKf,KAAK,CAACgB,EAAE,CAAC,CAACvB,MAAM;QAC1DiB,KAAK,GAAGA,KAAK,GAAGG,KAAK;MACzB;MACA,IAAIH,KAAK,KAAK,CAAC,EAAE;QACb;MACJ,CAAC,MAAM,IAAIA,KAAK,GAAG,CAAC,EAAE;QAClB,MAAM,IAAIhB,cAAW,CAChB,UAASM,KAAK,CAACgB,EAAG,oCAAmC,EACtD,2BAA2B,EAC3B;UACI/B,KAAK;UACLe;QACJ,CAAC,CACJ;MACL;MACA,MAAM,IAAIN,cAAW,CAChB,kBAAiBM,KAAK,CAACgB,EAAG,cAAa,EACxC,yBAAyB,EACzB;QACI/B,KAAK;QACLe;MACJ,CAAC,CACJ;IACL;EACJ;AACJ;AAAC;AAAA,8BAlMYtB,cAAc,UACwB,mBAAmB;AAmM/D,MAAMuC,cAAc,GAAG,CAC1BhC,KAAoB,EACpBH,OAA+B,KACd;EACjB,OAAO,IAAIJ,cAAc,CAACO,KAAK,EAAEH,OAAO,CAAC;AAC7C,CAAC;AAAC"}
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.CmsParametersPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
9
|
var _plugins = require("@webiny/plugins");
|
|
13
|
-
|
|
14
10
|
class CmsParametersPlugin extends _plugins.Plugin {
|
|
15
11
|
constructor(callable) {
|
|
16
12
|
super();
|
|
17
13
|
(0, _defineProperty2.default)(this, "callable", void 0);
|
|
18
14
|
this.callable = callable;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
async getParameters(context) {
|
|
22
17
|
return this.callable(context);
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
}
|
|
26
|
-
|
|
27
20
|
exports.CmsParametersPlugin = CmsParametersPlugin;
|
|
28
21
|
(0, _defineProperty2.default)(CmsParametersPlugin, "type", "cms-parameters-plugin");
|