@webiny/api-headless-cms 0.0.0-unstable.aad28a72ae → 0.0.0-unstable.b14eaecf38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +5 -2
- package/context.js +61 -23
- 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 +5 -2
- package/crud/contentEntry.crud.js +871 -936
- 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.d.ts +2 -3
- package/crud/contentModel/beforeCreate.js +43 -109
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.d.ts +1 -1
- package/crud/contentModel/beforeDelete.js +1 -15
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.d.ts +2 -4
- package/crud/contentModel/beforeUpdate.js +33 -10
- 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/validate/endingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/endingAllowed.js +26 -0
- package/crud/contentModel/validate/endingAllowed.js.map +1 -0
- package/crud/contentModel/validate/isModelEndingAllowed.d.ts +6 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js +24 -0
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -0
- package/crud/contentModel/validate/modelId.d.ts +11 -0
- package/crud/contentModel/validate/modelId.js +36 -0
- package/crud/contentModel/validate/modelId.js.map +1 -0
- package/crud/contentModel/validate/pluralApiName.d.ts +7 -0
- package/crud/contentModel/validate/pluralApiName.js +24 -0
- package/crud/contentModel/validate/pluralApiName.js.map +1 -0
- package/crud/contentModel/validate/singularApiName.d.ts +7 -0
- package/crud/contentModel/validate/singularApiName.js +24 -0
- package/crud/contentModel/validate/singularApiName.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 +4 -4
- package/crud/contentModel/validateModel.js +6 -11
- package/crud/contentModel/validateModel.js.map +1 -1
- package/crud/contentModel/validateModelFields.d.ts +4 -4
- package/crud/contentModel/validateModelFields.js +97 -126
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +551 -0
- package/crud/contentModel/validation.js +145 -0
- package/crud/contentModel/validation.js.map +1 -0
- package/crud/contentModel.crud.js +357 -391
- 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.d.ts +30 -0
- package/crud/contentModelGroup/validation.js +34 -0
- package/crud/contentModelGroup/validation.js.map +1 -0
- package/crud/contentModelGroup.crud.js +177 -221
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/settings.crud.d.ts +1 -1
- package/crud/settings.crud.js +5 -22
- 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.d.ts +8 -3
- package/graphql/buildSchemaPlugins.js +6 -14
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +18 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.d.ts +6 -0
- package/graphql/createExecutableSchema.js +29 -0
- package/graphql/createExecutableSchema.js.map +1 -0
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +14 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +25 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.d.ts +8 -0
- package/graphql/generateSchema.js +31 -0
- package/graphql/generateSchema.js.map +1 -0
- package/graphql/getSchema.d.ts +17 -0
- package/graphql/getSchema.js +102 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.js +8 -169
- package/graphql/graphQLHandlerFactory.js.map +1 -1
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +81 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +1 -3
- package/graphql/index.js +2 -46
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseContentSchema.d.ts +6 -2
- package/graphql/schema/baseContentSchema.js +10 -20
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +3 -0
- package/graphql/schema/baseSchema.js +53 -0
- package/graphql/schema/baseSchema.js.map +1 -0
- package/graphql/schema/contentEntries.d.ts +6 -2
- package/graphql/schema/contentEntries.js +118 -107
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.d.ts +6 -2
- package/graphql/schema/contentModelGroups.js +16 -29
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.d.ts +6 -2
- package/graphql/schema/contentModels.js +41 -24
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +13 -24
- 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 +3 -0
- package/graphql/schema/createManageSDL.js +61 -65
- 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 +8 -17
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.d.ts +3 -0
- package/graphql/schema/createReadSDL.js +30 -34
- 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.d.ts +8 -3
- package/graphql/schema/schemaPlugins.js +64 -66
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.js +55 -87
- 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.d.ts +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.js +27 -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 +22 -39
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +64 -66
- 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 +5 -3
- package/index.js +26 -28
- 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 +26 -28
- 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.d.ts +5 -0
- package/plugins/CmsGraphQLSchemaPlugin.js +12 -0
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.d.ts +20 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +28 -0
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -0
- 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 +19 -3
- package/plugins/CmsModelPlugin.js +30 -40
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/CmsParametersPlugin.js +0 -7
- package/plugins/CmsParametersPlugin.js.map +1 -1
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +42 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.js +0 -9
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +33 -10
- 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 +173 -79
- package/types.js +23 -73
- 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.d.ts +1 -5
- package/utils/converters/valueKeyStorageConverter.js +21 -44
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.d.ts +1 -0
- package/utils/createTypeFromFields.js +11 -20
- package/utils/createTypeFromFields.js.map +1 -1
- package/utils/createTypeName.d.ts +0 -2
- package/utils/createTypeName.js +2 -19
- 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.d.ts +4 -7
- package/utils/getSchemaFromFieldPlugins.js +23 -19
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/incrementEntryIdVersion.d.ts +5 -0
- package/utils/incrementEntryIdVersion.js +29 -0
- package/utils/incrementEntryIdVersion.js.map +1 -0
- 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/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.d.ts +7 -4
- package/utils/renderSortEnum.js +19 -11
- 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/crud/index.d.ts +0 -6
- package/crud/index.js +0 -85
- package/crud/index.js.map +0 -1
- package/utils/filterModelFields.d.ts +0 -16
- package/utils/filterModelFields.js +0 -77
- package/utils/filterModelFields.js.map +0 -1
package/parameters/header.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.createHeaderParameterPlugin = void 0;
|
|
9
|
-
|
|
10
8
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
|
-
|
|
12
9
|
var _CmsParametersPlugin = require("../plugins/CmsParametersPlugin");
|
|
13
|
-
|
|
14
10
|
var HeaderKeys;
|
|
15
|
-
|
|
16
11
|
(function (HeaderKeys) {
|
|
17
12
|
HeaderKeys["TYPE"] = "x-webiny-cms-endpoint";
|
|
18
13
|
HeaderKeys["LOCALE"] = "x-webiny-cms-locale";
|
|
19
14
|
})(HeaderKeys || (HeaderKeys = {}));
|
|
20
|
-
|
|
21
15
|
const createHeaderParameterPlugin = () => {
|
|
22
16
|
return new _CmsParametersPlugin.CmsParametersPlugin(async context => {
|
|
23
17
|
var _context$request;
|
|
24
|
-
|
|
25
18
|
/**
|
|
26
19
|
* If any of the properties is not defined, just ignore this plugin
|
|
27
20
|
*/
|
|
28
21
|
if (!((_context$request = context.request) !== null && _context$request !== void 0 && _context$request.headers)) {
|
|
29
22
|
return null;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
const headers = context.request.headers;
|
|
33
25
|
const type = headers[HeaderKeys.TYPE];
|
|
34
26
|
const locale = headers[HeaderKeys.LOCALE];
|
|
35
|
-
|
|
36
27
|
if (!type && !locale) {
|
|
37
28
|
return null;
|
|
38
29
|
} else if (!locale || typeof locale !== "string") {
|
|
@@ -44,12 +35,10 @@ const createHeaderParameterPlugin = () => {
|
|
|
44
35
|
headers
|
|
45
36
|
});
|
|
46
37
|
}
|
|
47
|
-
|
|
48
38
|
return {
|
|
49
39
|
type: type,
|
|
50
40
|
locale
|
|
51
41
|
};
|
|
52
42
|
});
|
|
53
43
|
};
|
|
54
|
-
|
|
55
44
|
exports.createHeaderParameterPlugin = createHeaderParameterPlugin;
|
package/parameters/header.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["HeaderKeys","createHeaderParameterPlugin","CmsParametersPlugin","context","request","headers","type","TYPE","locale","LOCALE","WebinyError"],"sources":["header.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nenum HeaderKeys {\n TYPE = \"x-webiny-cms-endpoint\",\n LOCALE = \"x-webiny-cms-locale\"\n}\n\nexport const createHeaderParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.request?.headers) {\n return null;\n }\n\n const headers = context.request.headers;\n\n const type = headers[HeaderKeys.TYPE];\n const locale = headers[HeaderKeys.LOCALE];\n\n if (!type && !locale) {\n return null;\n } else if (!locale || typeof locale !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.TYPE}\" header but no \"${HeaderKeys.LOCALE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n } else if (!type || typeof type !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.LOCALE}\" header but no \"${HeaderKeys.TYPE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["HeaderKeys","createHeaderParameterPlugin","CmsParametersPlugin","context","request","headers","type","TYPE","locale","LOCALE","WebinyError"],"sources":["header.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsParametersPlugin } from \"~/plugins/CmsParametersPlugin\";\nimport { ApiEndpoint } from \"~/types\";\n\nenum HeaderKeys {\n TYPE = \"x-webiny-cms-endpoint\",\n LOCALE = \"x-webiny-cms-locale\"\n}\n\nexport const createHeaderParameterPlugin = () => {\n return new CmsParametersPlugin(async context => {\n /**\n * If any of the properties is not defined, just ignore this plugin\n */\n if (!context.request?.headers) {\n return null;\n }\n\n const headers = context.request.headers;\n\n const type = headers[HeaderKeys.TYPE];\n const locale = headers[HeaderKeys.LOCALE];\n\n if (!type && !locale) {\n return null;\n } else if (!locale || typeof locale !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.TYPE}\" header but no \"${HeaderKeys.LOCALE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n } else if (!type || typeof type !== \"string\") {\n throw new WebinyError(\n `There is a \"${HeaderKeys.LOCALE}\" header but no \"${HeaderKeys.TYPE}\".`,\n \"MALFORMED_HEADERS_ERROR\",\n {\n headers\n }\n );\n }\n\n return {\n type: type as ApiEndpoint,\n locale\n };\n });\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAAoE,IAG/DA,UAAU;AAAA,WAAVA,UAAU;EAAVA,UAAU;EAAVA,UAAU;AAAA,GAAVA,UAAU,KAAVA,UAAU;AAKR,MAAMC,2BAA2B,GAAG,MAAM;EAC7C,OAAO,IAAIC,wCAAmB,CAAC,MAAMC,OAAO,IAAI;IAAA;IAC5C;AACR;AACA;IACQ,IAAI,sBAACA,OAAO,CAACC,OAAO,6CAAf,iBAAiBC,OAAO,GAAE;MAC3B,OAAO,IAAI;IACf;IAEA,MAAMA,OAAO,GAAGF,OAAO,CAACC,OAAO,CAACC,OAAO;IAEvC,MAAMC,IAAI,GAAGD,OAAO,CAACL,UAAU,CAACO,IAAI,CAAC;IACrC,MAAMC,MAAM,GAAGH,OAAO,CAACL,UAAU,CAACS,MAAM,CAAC;IAEzC,IAAI,CAACH,IAAI,IAAI,CAACE,MAAM,EAAE;MAClB,OAAO,IAAI;IACf,CAAC,MAAM,IAAI,CAACA,MAAM,IAAI,OAAOA,MAAM,KAAK,QAAQ,EAAE;MAC9C,MAAM,IAAIE,cAAW,CAChB,eAAcV,UAAU,CAACO,IAAK,oBAAmBP,UAAU,CAACS,MAAO,IAAG,EACvE,yBAAyB,EACzB;QACIJ;MACJ,CAAC,CACJ;IACL,CAAC,MAAM,IAAI,CAACC,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;MAC1C,MAAM,IAAII,cAAW,CAChB,eAAcV,UAAU,CAACS,MAAO,oBAAmBT,UAAU,CAACO,IAAK,IAAG,EACvE,yBAAyB,EACzB;QACIF;MACJ,CAAC,CACJ;IACL;IAEA,OAAO;MACHC,IAAI,EAAEA,IAAmB;MACzBE;IACJ,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAAC"}
|
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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.CmsGraphQLSchemaPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _handlerGraphql = require("@webiny/handler-graphql");
|
|
10
|
+
class CmsGraphQLSchemaPlugin extends _handlerGraphql.GraphQLSchemaPlugin {}
|
|
11
|
+
exports.CmsGraphQLSchemaPlugin = CmsGraphQLSchemaPlugin;
|
|
12
|
+
(0, _defineProperty2.default)(CmsGraphQLSchemaPlugin, "type", "cms.graphql.schema");
|
|
@@ -0,0 +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":";;;;;;;;AAAA;AAGO,MAAMA,sBAAsB,SAAyBC,mCAAmB,CAAI;AAElF;AAAA,8BAFYD,sBAAsB,UACD,oBAAoB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Plugin } from "@webiny/plugins";
|
|
2
|
+
import { CmsModel } from "../types";
|
|
3
|
+
interface CmsGraphQLSchemaSorterPluginCallableParams {
|
|
4
|
+
model: CmsModel;
|
|
5
|
+
sorters: string[];
|
|
6
|
+
}
|
|
7
|
+
interface CmsGraphQLSchemaSorterPluginCallable {
|
|
8
|
+
(params: CmsGraphQLSchemaSorterPluginCallableParams): string[];
|
|
9
|
+
}
|
|
10
|
+
export declare class CmsGraphQLSchemaSorterPlugin extends Plugin {
|
|
11
|
+
static readonly type: string;
|
|
12
|
+
private readonly cb;
|
|
13
|
+
constructor(cb: CmsGraphQLSchemaSorterPluginCallable);
|
|
14
|
+
/**
|
|
15
|
+
* Method must return new sorting array. Or existing one if no changes are made.
|
|
16
|
+
*/
|
|
17
|
+
createSorter(params: CmsGraphQLSchemaSorterPluginCallableParams): string[];
|
|
18
|
+
}
|
|
19
|
+
export declare const createCmsGraphQLSchemaSorterPlugin: (cb: CmsGraphQLSchemaSorterPluginCallable) => CmsGraphQLSchemaSorterPlugin;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.createCmsGraphQLSchemaSorterPlugin = exports.CmsGraphQLSchemaSorterPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _plugins = require("@webiny/plugins");
|
|
10
|
+
class CmsGraphQLSchemaSorterPlugin extends _plugins.Plugin {
|
|
11
|
+
constructor(cb) {
|
|
12
|
+
super();
|
|
13
|
+
(0, _defineProperty2.default)(this, "cb", void 0);
|
|
14
|
+
this.cb = cb;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Method must return new sorting array. Or existing one if no changes are made.
|
|
18
|
+
*/
|
|
19
|
+
createSorter(params) {
|
|
20
|
+
return this.cb(params);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.CmsGraphQLSchemaSorterPlugin = CmsGraphQLSchemaSorterPlugin;
|
|
24
|
+
(0, _defineProperty2.default)(CmsGraphQLSchemaSorterPlugin, "type", "cms.graphql.schema.sorter");
|
|
25
|
+
const createCmsGraphQLSchemaSorterPlugin = cb => {
|
|
26
|
+
return new CmsGraphQLSchemaSorterPlugin(cb);
|
|
27
|
+
};
|
|
28
|
+
exports.createCmsGraphQLSchemaSorterPlugin = createCmsGraphQLSchemaSorterPlugin;
|
|
@@ -0,0 +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":";;;;;;;;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,27 @@ interface CmsModelFieldInput extends Omit<CmsModelFieldBase, "storageId" | "sett
|
|
|
20
20
|
*/
|
|
21
21
|
settings?: CmsModelFieldSettings;
|
|
22
22
|
}
|
|
23
|
-
interface
|
|
23
|
+
export interface CmsApiModel extends Omit<CmsModel, "isPrivate" | "fields"> {
|
|
24
|
+
isPrivate?: never;
|
|
25
|
+
noValidate?: never;
|
|
24
26
|
fields: CmsModelFieldInput[];
|
|
25
|
-
locale?: string;
|
|
26
|
-
tenant?: string;
|
|
27
27
|
}
|
|
28
|
+
export interface CmsApiModelFull extends Omit<CmsApiModel, "fields" | "noValidate"> {
|
|
29
|
+
noValidate: true;
|
|
30
|
+
fields: CmsModelFieldBase[];
|
|
31
|
+
}
|
|
32
|
+
interface CmsPrivateModel extends Omit<CmsModel, "isPrivate" | "singularApiName" | "pluralApiName" | "fields"> {
|
|
33
|
+
noValidate?: never;
|
|
34
|
+
singularApiName?: never;
|
|
35
|
+
pluralApiName?: never;
|
|
36
|
+
isPrivate: true;
|
|
37
|
+
fields: CmsModelFieldInput[];
|
|
38
|
+
}
|
|
39
|
+
export interface CmsPrivateModelFull extends Omit<CmsPrivateModel, "fields" | "noValidate"> {
|
|
40
|
+
fields: CmsModelFieldBase[];
|
|
41
|
+
noValidate: true;
|
|
42
|
+
}
|
|
43
|
+
export declare type CmsModelInput = CmsApiModel | CmsPrivateModel | CmsApiModelFull | CmsPrivateModelFull;
|
|
28
44
|
interface CmsModel extends Omit<CmsModelBase, "locale" | "tenant" | "webinyVersion"> {
|
|
29
45
|
locale?: string;
|
|
30
46
|
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 createApiName = name => {
|
|
17
|
+
return (0, _upperFirst.default)((0, _camelCase.default)(name));
|
|
18
|
+
};
|
|
19
|
+
const createPluralApiName = name => {
|
|
20
|
+
return (0, _pluralize.default)(createApiName(name));
|
|
21
|
+
};
|
|
22
22
|
class CmsModelPlugin extends _plugins.Plugin {
|
|
23
23
|
constructor(contentModel, options) {
|
|
24
24
|
super();
|
|
@@ -27,29 +27,42 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
27
27
|
this.options = options || {};
|
|
28
28
|
this.contentModel = this.buildModel(contentModel);
|
|
29
29
|
}
|
|
30
|
-
|
|
31
30
|
buildModel(input) {
|
|
31
|
+
const isPrivate = input.isPrivate || false;
|
|
32
|
+
const singularApiName = input.singularApiName ? createApiName(input.singularApiName) : createApiName(input.name);
|
|
33
|
+
const pluralApiName = input.pluralApiName ? createApiName(input.pluralApiName) : createPluralApiName(input.name);
|
|
34
|
+
if (input.noValidate) {
|
|
35
|
+
/**
|
|
36
|
+
* We can safely ignore this error, because we are sure noValidate is not a model field.
|
|
37
|
+
*/
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
delete input["noValidate"];
|
|
40
|
+
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
41
|
+
isPrivate,
|
|
42
|
+
singularApiName,
|
|
43
|
+
pluralApiName
|
|
44
|
+
});
|
|
45
|
+
}
|
|
32
46
|
const model = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
47
|
+
isPrivate,
|
|
48
|
+
singularApiName,
|
|
49
|
+
pluralApiName,
|
|
33
50
|
fields: this.buildFields(input, input.fields)
|
|
34
51
|
});
|
|
35
52
|
this.validateLayout(model);
|
|
36
53
|
return model;
|
|
37
54
|
}
|
|
38
|
-
|
|
39
55
|
buildFields(model, inputFields) {
|
|
40
56
|
if (inputFields.length === 0) {
|
|
41
57
|
throw new _error.default(`Missing fields for the defined model "${model.modelId}".`, "MISSING_FIELDS", {
|
|
42
58
|
model
|
|
43
59
|
});
|
|
44
60
|
}
|
|
45
|
-
|
|
46
61
|
const fields = [];
|
|
47
62
|
const storageIdList = [];
|
|
48
63
|
const fieldIdList = [];
|
|
49
|
-
|
|
50
64
|
for (const input of inputFields) {
|
|
51
65
|
var _settings;
|
|
52
|
-
|
|
53
66
|
/**
|
|
54
67
|
* Field must contain an fieldId. It is required in the graphql, but lets check it just in case
|
|
55
68
|
*/
|
|
@@ -59,12 +72,10 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
59
72
|
field: input
|
|
60
73
|
});
|
|
61
74
|
}
|
|
62
|
-
|
|
63
75
|
const fieldId = (0, _camelCase.default)(input.fieldId);
|
|
64
76
|
/**
|
|
65
77
|
* FieldID must be in correct pattern.
|
|
66
78
|
*/
|
|
67
|
-
|
|
68
79
|
if (fieldId.match(/^[0-9]/) !== null) {
|
|
69
80
|
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
81
|
model,
|
|
@@ -74,8 +85,6 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
74
85
|
/**
|
|
75
86
|
* FieldID also must be camelCased.
|
|
76
87
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
88
|
if (fieldId !== input.fieldId) {
|
|
80
89
|
throw new _error.default(`Field's "fieldId" must be a camel cased string in the content model "${model.modelId}".`, "FIELD_FIELD_ID_ERROR", {
|
|
81
90
|
model,
|
|
@@ -85,20 +94,16 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
85
94
|
/**
|
|
86
95
|
* ... and fieldId must be unique.
|
|
87
96
|
*/
|
|
88
|
-
|
|
89
|
-
|
|
90
97
|
if (fieldIdList.includes(fieldId) === true) {
|
|
91
98
|
throw new _error.default(`Field's "fieldId" is not unique in the content model "${model.modelId}".`, "FIELD_ID_NOT_UNIQUE_ERROR", {
|
|
92
99
|
model,
|
|
93
100
|
field: input
|
|
94
101
|
});
|
|
95
102
|
}
|
|
96
|
-
|
|
97
103
|
let storageId = input.storageId ? (0, _camelCase.default)(input.storageId) : null;
|
|
98
104
|
/**
|
|
99
105
|
* If defined, storageId MUST be camel cased string - for backward compatibility.
|
|
100
106
|
*/
|
|
101
|
-
|
|
102
107
|
if (storageId && (storageId.match(/^([a-zA-Z-0-9]+)$/) === null || storageId !== input.storageId)) {
|
|
103
108
|
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
109
|
model,
|
|
@@ -108,32 +113,28 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
108
113
|
} else if (!storageId) {
|
|
109
114
|
storageId = (0, _createFieldStorageId.createFieldStorageId)(input);
|
|
110
115
|
}
|
|
116
|
+
|
|
111
117
|
/**
|
|
112
118
|
* Fields storageId must be unique.
|
|
113
119
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
116
120
|
if (storageIdList.includes(storageId) === true) {
|
|
117
121
|
throw new _error.default(`Field's "storageId" is not unique in the content model "${model.modelId}".`, "STORAGE_ID_ERROR", {
|
|
118
122
|
model,
|
|
119
123
|
field: input
|
|
120
124
|
});
|
|
121
125
|
}
|
|
126
|
+
|
|
122
127
|
/**
|
|
123
128
|
* We can safely ignore error because we are going through the fields and making sure each has storageId.
|
|
124
129
|
*/
|
|
125
130
|
// @ts-ignore
|
|
126
|
-
|
|
127
|
-
|
|
128
131
|
let settings = input.settings;
|
|
129
132
|
const childFields = ((_settings = settings) === null || _settings === void 0 ? void 0 : _settings.fields) || [];
|
|
130
|
-
|
|
131
133
|
if (input.type === "object" && childFields.length > 0) {
|
|
132
134
|
settings = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, settings || {}), {}, {
|
|
133
135
|
fields: this.buildFields(model, childFields)
|
|
134
136
|
});
|
|
135
137
|
}
|
|
136
|
-
|
|
137
138
|
const field = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, input), {}, {
|
|
138
139
|
settings,
|
|
139
140
|
storageId
|
|
@@ -141,15 +142,12 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
141
142
|
/**
|
|
142
143
|
* Add all relevant data to arrays.
|
|
143
144
|
*/
|
|
144
|
-
|
|
145
145
|
fields.push(field);
|
|
146
146
|
storageIdList.push(field.storageId);
|
|
147
147
|
fieldIdList.push(field.fieldId);
|
|
148
148
|
}
|
|
149
|
-
|
|
150
149
|
return fields;
|
|
151
150
|
}
|
|
152
|
-
|
|
153
151
|
validateLayout(model) {
|
|
154
152
|
/**
|
|
155
153
|
* Only skip validation if option.validateLayout was set as false, explicitly.
|
|
@@ -157,15 +155,12 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
157
155
|
if (this.options.validateLayout === false) {
|
|
158
156
|
return;
|
|
159
157
|
}
|
|
160
|
-
|
|
161
158
|
for (const field of model.fields) {
|
|
162
159
|
let total = 0;
|
|
163
|
-
|
|
164
160
|
for (const row of model.layout) {
|
|
165
161
|
const count = row.filter(cell => cell === field.id).length;
|
|
166
162
|
total = total + count;
|
|
167
163
|
}
|
|
168
|
-
|
|
169
164
|
if (total === 1) {
|
|
170
165
|
continue;
|
|
171
166
|
} else if (total > 1) {
|
|
@@ -174,21 +169,16 @@ class CmsModelPlugin extends _plugins.Plugin {
|
|
|
174
169
|
field
|
|
175
170
|
});
|
|
176
171
|
}
|
|
177
|
-
|
|
178
172
|
throw new _error.default(`Missing field "${field.id}" in layout.`, "MISSING_FIELD_IN_LAYOUT", {
|
|
179
173
|
model,
|
|
180
174
|
field
|
|
181
175
|
});
|
|
182
176
|
}
|
|
183
177
|
}
|
|
184
|
-
|
|
185
178
|
}
|
|
186
|
-
|
|
187
179
|
exports.CmsModelPlugin = CmsModelPlugin;
|
|
188
180
|
(0, _defineProperty2.default)(CmsModelPlugin, "type", "cms-content-model");
|
|
189
|
-
|
|
190
181
|
const createCmsModel = (model, options) => {
|
|
191
182
|
return new CmsModelPlugin(model, options);
|
|
192
183
|
};
|
|
193
|
-
|
|
194
184
|
exports.createCmsModel = createCmsModel;
|