@webiny/api-headless-cms 0.0.0-unstable.9e825fd5fb → 0.0.0-unstable.a9593f74dd
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/constants.d.ts +32 -0
- package/constants.js +57 -0
- package/constants.js.map +1 -0
- package/context.js +77 -39
- package/context.js.map +1 -1
- package/crud/contentEntry/afterDelete.js +3 -1
- package/crud/contentEntry/afterDelete.js.map +1 -1
- package/crud/contentEntry/beforeCreate.js +3 -1
- package/crud/contentEntry/beforeCreate.js.map +1 -1
- package/crud/contentEntry/beforeUpdate.js +3 -1
- package/crud/contentEntry/beforeUpdate.js.map +1 -1
- package/crud/contentEntry/entryDataFactories/createEntryData.d.ts +20 -0
- package/crud/contentEntry/entryDataFactories/createEntryData.js +228 -0
- package/crud/contentEntry/entryDataFactories/createEntryData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.d.ts +21 -0
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js +114 -0
- package/crud/contentEntry/entryDataFactories/createEntryRevisionFromData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.d.ts +13 -0
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.js +61 -0
- package/crud/contentEntry/entryDataFactories/createPublishEntryData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.d.ts +12 -0
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js +57 -0
- package/crud/contentEntry/entryDataFactories/createRepublishEntryData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.d.ts +12 -0
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js +38 -0
- package/crud/contentEntry/entryDataFactories/createUnpublishEntryData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.d.ts +20 -0
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js +122 -0
- package/crud/contentEntry/entryDataFactories/createUpdateEntryData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/index.d.ts +8 -0
- package/crud/contentEntry/entryDataFactories/index.js +95 -0
- package/crud/contentEntry/entryDataFactories/index.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.d.ts +5 -0
- package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js +36 -0
- package/crud/contentEntry/entryDataFactories/mapAndCleanUpdatedInputData.js.map +1 -0
- package/crud/contentEntry/entryDataFactories/statuses.d.ts +4 -0
- package/crud/contentEntry/entryDataFactories/statuses.js +15 -0
- package/crud/contentEntry/entryDataFactories/statuses.js.map +1 -0
- package/crud/contentEntry/entryDataValidation.d.ts +4 -2
- package/crud/contentEntry/entryDataValidation.js +223 -45
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry/markLockedFields.js +17 -10
- package/crud/contentEntry/markLockedFields.js.map +1 -1
- package/crud/contentEntry/referenceFieldsMapping.d.ts +6 -0
- package/crud/contentEntry/referenceFieldsMapping.js +142 -90
- package/crud/contentEntry/referenceFieldsMapping.js.map +1 -1
- package/crud/contentEntry/searchableFields.js +5 -4
- package/crud/contentEntry/searchableFields.js.map +1 -1
- package/crud/contentEntry.crud.d.ts +5 -4
- package/crud/contentEntry.crud.js +558 -528
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/beforeCreate.d.ts +1 -1
- package/crud/contentModel/beforeCreate.js +11 -9
- package/crud/contentModel/beforeCreate.js.map +1 -1
- package/crud/contentModel/beforeDelete.d.ts +1 -1
- package/crud/contentModel/beforeDelete.js +4 -6
- package/crud/contentModel/beforeDelete.js.map +1 -1
- package/crud/contentModel/beforeUpdate.d.ts +1 -1
- package/crud/contentModel/beforeUpdate.js +3 -6
- package/crud/contentModel/beforeUpdate.js.map +1 -1
- package/crud/contentModel/compatibility/modelApiName.js +3 -1
- package/crud/contentModel/compatibility/modelApiName.js.map +1 -1
- package/crud/contentModel/contentModelManagerFactory.js +3 -1
- package/crud/contentModel/contentModelManagerFactory.js.map +1 -1
- package/crud/contentModel/createFieldStorageId.js +3 -1
- package/crud/contentModel/createFieldStorageId.js.map +1 -1
- package/crud/contentModel/defaultFields.js +3 -1
- package/crud/contentModel/defaultFields.js.map +1 -1
- package/crud/contentModel/ensureTypeTag.d.ts +5 -0
- package/crud/contentModel/ensureTypeTag.js +21 -0
- package/crud/contentModel/ensureTypeTag.js.map +1 -0
- package/crud/contentModel/fields/descriptionField.js +4 -2
- package/crud/contentModel/fields/descriptionField.js.map +1 -1
- package/crud/contentModel/fields/imageField.js +6 -8
- package/crud/contentModel/fields/imageField.js.map +1 -1
- package/crud/contentModel/fields/titleField.js +4 -2
- package/crud/contentModel/fields/titleField.js.map +1 -1
- package/crud/contentModel/listModelsFromDatabase.d.ts +10 -0
- package/crud/contentModel/listModelsFromDatabase.js +38 -0
- package/crud/contentModel/listModelsFromDatabase.js.map +1 -0
- package/crud/contentModel/validate/endingAllowed.js +3 -1
- package/crud/contentModel/validate/endingAllowed.js.map +1 -1
- package/crud/contentModel/validate/isModelEndingAllowed.js +4 -2
- package/crud/contentModel/validate/isModelEndingAllowed.js.map +1 -1
- package/crud/contentModel/validate/modelId.js +3 -1
- package/crud/contentModel/validate/modelId.js.map +1 -1
- package/crud/contentModel/validate/pluralApiName.js +3 -1
- package/crud/contentModel/validate/pluralApiName.js.map +1 -1
- package/crud/contentModel/validate/singularApiName.js +3 -1
- package/crud/contentModel/validate/singularApiName.js.map +1 -1
- package/crud/contentModel/validateModel.js +3 -1
- package/crud/contentModel/validateModel.js.map +1 -1
- package/crud/contentModel/validateModelFields.js +8 -7
- package/crud/contentModel/validateModelFields.js.map +1 -1
- package/crud/contentModel/validation.d.ts +586 -233
- package/crud/contentModel/validation.js +73 -13
- package/crud/contentModel/validation.js.map +1 -1
- package/crud/contentModel.crud.d.ts +2 -0
- package/crud/contentModel.crud.js +146 -181
- package/crud/contentModel.crud.js.map +1 -1
- package/crud/contentModelGroup/beforeCreate.d.ts +1 -1
- package/crud/contentModelGroup/beforeCreate.js +15 -1
- package/crud/contentModelGroup/beforeCreate.js.map +1 -1
- package/crud/contentModelGroup/beforeDelete.js +3 -1
- package/crud/contentModelGroup/beforeDelete.js.map +1 -1
- package/crud/contentModelGroup/beforeUpdate.js +3 -1
- package/crud/contentModelGroup/beforeUpdate.js.map +1 -1
- package/crud/contentModelGroup/listGroupsFromDatabase.d.ts +8 -0
- package/crud/contentModelGroup/listGroupsFromDatabase.js +22 -0
- package/crud/contentModelGroup/listGroupsFromDatabase.js.map +1 -0
- package/crud/contentModelGroup/validation.d.ts +10 -7
- package/crud/contentModelGroup/validation.js +5 -2
- package/crud/contentModelGroup/validation.js.map +1 -1
- package/crud/contentModelGroup.crud.d.ts +3 -1
- package/crud/contentModelGroup.crud.js +139 -123
- package/crud/contentModelGroup.crud.js.map +1 -1
- package/crud/system.crud.js +8 -11
- package/crud/system.crud.js.map +1 -1
- package/export/crud/exporting.d.ts +3 -0
- package/export/crud/exporting.js +49 -0
- package/export/crud/exporting.js.map +1 -0
- package/export/crud/importing.d.ts +3 -0
- package/export/crud/importing.js +79 -0
- package/export/crud/importing.js.map +1 -0
- package/export/crud/imports/importData.d.ts +14 -0
- package/export/crud/imports/importData.js +52 -0
- package/export/crud/imports/importData.js.map +1 -0
- package/export/crud/imports/importGroups.d.ts +8 -0
- package/export/crud/imports/importGroups.js +104 -0
- package/export/crud/imports/importGroups.js.map +1 -0
- package/export/crud/imports/importModels.d.ts +8 -0
- package/export/crud/imports/importModels.js +136 -0
- package/export/crud/imports/importModels.js.map +1 -0
- package/export/crud/imports/validateGroups.d.ts +8 -0
- package/export/crud/imports/validateGroups.js +112 -0
- package/export/crud/imports/validateGroups.js.map +1 -0
- package/export/crud/imports/validateInput.d.ts +19 -0
- package/export/crud/imports/validateInput.js +55 -0
- package/export/crud/imports/validateInput.js.map +1 -0
- package/export/crud/imports/validateModels.d.ts +12 -0
- package/export/crud/imports/validateModels.js +203 -0
- package/export/crud/imports/validateModels.js.map +1 -0
- package/export/crud/index.d.ts +4 -0
- package/export/crud/index.js +15 -0
- package/export/crud/index.js.map +1 -0
- package/export/crud/sanitize.d.ts +4 -0
- package/export/crud/sanitize.js +35 -0
- package/export/crud/sanitize.js.map +1 -0
- package/export/graphql/index.d.ts +3 -0
- package/export/graphql/index.js +188 -0
- package/export/graphql/index.js.map +1 -0
- package/export/index.d.ts +2 -0
- package/export/index.js +29 -0
- package/export/index.js.map +1 -0
- package/export/types.d.ts +113 -0
- package/export/types.js +22 -0
- package/export/types.js.map +1 -0
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js +4 -7
- package/fieldConverters/CmsModelDefaultFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +5 -8
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +47 -38
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/index.js +3 -1
- package/fieldConverters/index.js.map +1 -1
- package/graphql/buildSchemaPlugins.js +7 -1
- package/graphql/buildSchemaPlugins.js.map +1 -1
- package/graphql/checkEndpointAccess.d.ts +2 -0
- package/graphql/checkEndpointAccess.js +20 -0
- package/graphql/checkEndpointAccess.js.map +1 -0
- package/graphql/createExecutableSchema.js +3 -1
- package/graphql/createExecutableSchema.js.map +1 -1
- package/graphql/createRequestBody.d.ts +2 -0
- package/graphql/createRequestBody.js +16 -0
- package/graphql/createRequestBody.js.map +1 -0
- package/graphql/formatErrorPayload.d.ts +1 -0
- package/graphql/formatErrorPayload.js +27 -0
- package/graphql/formatErrorPayload.js.map +1 -0
- package/graphql/generateSchema.js +3 -1
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/getSchema.d.ts +16 -0
- package/graphql/getSchema.js +118 -0
- package/graphql/getSchema.js.map +1 -0
- package/graphql/graphQLHandlerFactory.js +8 -191
- package/graphql/graphQLHandlerFactory.js.map +1 -1
- package/graphql/handleRequest.d.ts +11 -0
- package/graphql/handleRequest.js +79 -0
- package/graphql/handleRequest.js.map +1 -0
- package/graphql/index.d.ts +1 -1
- package/graphql/index.js +4 -2
- package/graphql/index.js.map +1 -1
- package/graphql/schema/baseContentSchema.js +9 -8
- package/graphql/schema/baseContentSchema.js.map +1 -1
- package/graphql/schema/baseSchema.d.ts +2 -3
- package/graphql/schema/baseSchema.js +95 -2
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/contentEntries.js +54 -16
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +5 -2
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +10 -10
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.d.ts +1 -1
- package/graphql/schema/createFieldResolvers.js +18 -22
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/graphql/schema/createFieldTypePluginRecords.d.ts +3 -0
- package/graphql/schema/createFieldTypePluginRecords.js +15 -0
- package/graphql/schema/createFieldTypePluginRecords.js.map +1 -0
- package/graphql/schema/createManageResolvers.d.ts +1 -1
- package/graphql/schema/createManageResolvers.js +27 -10
- package/graphql/schema/createManageResolvers.js.map +1 -1
- package/graphql/schema/createManageSDL.js +83 -42
- package/graphql/schema/createManageSDL.js.map +1 -1
- package/graphql/schema/createPreviewResolvers.js +7 -6
- package/graphql/schema/createPreviewResolvers.js.map +1 -1
- package/graphql/schema/createReadResolvers.js +7 -6
- package/graphql/schema/createReadResolvers.js.map +1 -1
- package/graphql/schema/createReadSDL.js +35 -24
- package/graphql/schema/createReadSDL.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreate.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveCreate.js +4 -2
- package/graphql/schema/resolvers/manage/resolveCreate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js +4 -2
- package/graphql/schema/resolvers/manage/resolveCreateFrom.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDelete.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveDelete.js +16 -4
- package/graphql/schema/resolvers/manage/resolveDelete.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.d.ts +7 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js +22 -0
- package/graphql/schema/resolvers/manage/resolveDeleteMultiple.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveGet.js +12 -5
- package/graphql/schema/resolvers/manage/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.js +3 -1
- package/graphql/schema/resolvers/manage/resolveGetByIds.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js +3 -1
- package/graphql/schema/resolvers/manage/resolveGetRevisions.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.d.ts +4 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js +20 -0
- package/graphql/schema/resolvers/manage/resolveGetUniqueFieldValues.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolveList.js +3 -1
- package/graphql/schema/resolvers/manage/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveMove.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveMove.js +27 -0
- package/graphql/schema/resolvers/manage/resolveMove.js.map +1 -0
- package/graphql/schema/resolvers/manage/resolvePublish.js +3 -1
- package/graphql/schema/resolvers/manage/resolvePublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.js +3 -1
- package/graphql/schema/resolvers/manage/resolveRepublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.js +3 -1
- package/graphql/schema/resolvers/manage/resolveUnpublish.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.d.ts +2 -1
- package/graphql/schema/resolvers/manage/resolveUpdate.js +4 -2
- package/graphql/schema/resolvers/manage/resolveUpdate.js.map +1 -1
- package/graphql/schema/resolvers/manage/resolveValidate.d.ts +8 -0
- package/graphql/schema/resolvers/manage/resolveValidate.js +20 -0
- package/graphql/schema/resolvers/manage/resolveValidate.js.map +1 -0
- package/graphql/schema/resolvers/preview/resolveGet.js +6 -5
- package/graphql/schema/resolvers/preview/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/preview/resolveList.js +3 -1
- package/graphql/schema/resolvers/preview/resolveList.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveGet.js +6 -5
- package/graphql/schema/resolvers/read/resolveGet.js.map +1 -1
- package/graphql/schema/resolvers/read/resolveList.js +3 -1
- package/graphql/schema/resolvers/read/resolveList.js.map +1 -1
- package/graphql/schema/schemaPlugins.js +5 -12
- package/graphql/schema/schemaPlugins.js.map +1 -1
- package/graphql/system.d.ts +2 -5
- package/graphql/system.js +4 -12
- package/graphql/system.js.map +1 -1
- package/graphqlFields/boolean.js +3 -1
- package/graphqlFields/boolean.js.map +1 -1
- package/graphqlFields/datetime.js +5 -5
- package/graphqlFields/datetime.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.d.ts +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneField.js +76 -26
- package/graphqlFields/dynamicZone/dynamicZoneField.js.map +1 -1
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js +60 -12
- package/graphqlFields/dynamicZone/dynamicZoneStorage.js.map +1 -1
- package/graphqlFields/dynamicZone/index.js +3 -1
- package/graphqlFields/dynamicZone/index.js.map +1 -1
- package/graphqlFields/file.js +3 -1
- package/graphqlFields/file.js.map +1 -1
- package/graphqlFields/helpers.d.ts +0 -1
- package/graphqlFields/helpers.js +6 -18
- package/graphqlFields/helpers.js.map +1 -1
- package/graphqlFields/index.js +5 -2
- package/graphqlFields/index.js.map +1 -1
- package/graphqlFields/json.d.ts +2 -0
- package/graphqlFields/json.js +49 -0
- package/graphqlFields/json.js.map +1 -0
- package/graphqlFields/longText.js +14 -3
- package/graphqlFields/longText.js.map +1 -1
- package/graphqlFields/number.js +4 -1
- package/graphqlFields/number.js.map +1 -1
- package/graphqlFields/object.js +26 -46
- package/graphqlFields/object.js.map +1 -1
- package/graphqlFields/ref.js +35 -23
- package/graphqlFields/ref.js.map +1 -1
- package/graphqlFields/richText/RichTextPluginsProcessor.d.ts +6 -0
- package/graphqlFields/richText/RichTextPluginsProcessor.js +34 -0
- package/graphqlFields/richText/RichTextPluginsProcessor.js.map +1 -0
- package/graphqlFields/richText/richTextResolver.d.ts +7 -0
- package/graphqlFields/richText/richTextResolver.js +39 -0
- package/graphqlFields/richText/richTextResolver.js.map +1 -0
- package/graphqlFields/richText.js +11 -3
- package/graphqlFields/richText.js.map +1 -1
- package/graphqlFields/text.js +5 -1
- package/graphqlFields/text.js.map +1 -1
- package/htmlRenderer/LexicalRenderer.d.ts +5 -0
- package/htmlRenderer/LexicalRenderer.js +28 -0
- package/htmlRenderer/LexicalRenderer.js.map +1 -0
- package/htmlRenderer/createLexicalHTMLRenderer.d.ts +2 -0
- package/htmlRenderer/createLexicalHTMLRenderer.js +31 -0
- package/htmlRenderer/createLexicalHTMLRenderer.js.map +1 -0
- package/index.d.ts +3 -2
- package/index.js +33 -14
- package/index.js.map +1 -1
- package/modelManager/DefaultCmsModelManager.js +3 -5
- package/modelManager/DefaultCmsModelManager.js.map +1 -1
- package/modelManager/index.js +3 -1
- package/modelManager/index.js.map +1 -1
- package/package.json +36 -39
- package/parameters/context.js +4 -2
- package/parameters/context.js.map +1 -1
- package/parameters/header.js +7 -6
- package/parameters/header.js.map +1 -1
- package/parameters/index.js +3 -1
- package/parameters/index.js.map +1 -1
- package/parameters/manual.js +9 -4
- package/parameters/manual.js.map +1 -1
- package/parameters/path.js +4 -3
- package/parameters/path.js.map +1 -1
- package/plugins/CmsGraphQLSchemaPlugin.js +5 -4
- package/plugins/CmsGraphQLSchemaPlugin.js.map +1 -1
- package/plugins/CmsGraphQLSchemaSorterPlugin.js +4 -5
- package/plugins/CmsGraphQLSchemaSorterPlugin.js.map +1 -1
- package/plugins/CmsGroupPlugin.d.ts +6 -3
- package/plugins/CmsGroupPlugin.js +8 -6
- package/plugins/CmsGroupPlugin.js.map +1 -1
- package/plugins/CmsModelFieldConverterPlugin.js +5 -4
- package/plugins/CmsModelFieldConverterPlugin.js.map +1 -1
- package/plugins/CmsModelPlugin.d.ts +8 -4
- package/plugins/CmsModelPlugin.js +61 -32
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/plugins/CmsParametersPlugin.js +7 -4
- package/plugins/CmsParametersPlugin.js.map +1 -1
- package/plugins/CmsRichTextRendererPlugin.d.ts +24 -0
- package/plugins/CmsRichTextRendererPlugin.js +28 -0
- package/plugins/CmsRichTextRendererPlugin.js.map +1 -0
- package/plugins/StorageOperationsCmsModelPlugin.d.ts +23 -0
- package/plugins/StorageOperationsCmsModelPlugin.js +41 -0
- package/plugins/StorageOperationsCmsModelPlugin.js.map +1 -0
- package/plugins/StorageTransformPlugin.d.ts +2 -2
- package/plugins/StorageTransformPlugin.js +3 -4
- package/plugins/StorageTransformPlugin.js.map +1 -1
- package/plugins/index.d.ts +2 -0
- package/plugins/index.js +25 -1
- package/plugins/index.js.map +1 -1
- package/storage/default.js +3 -1
- package/storage/default.js.map +1 -1
- package/storage/index.d.ts +1 -0
- package/storage/index.js +15 -0
- package/storage/index.js.map +1 -0
- package/storage/json.d.ts +2 -0
- package/storage/json.js +27 -0
- package/storage/json.js.map +1 -0
- package/storage/object.js +8 -8
- package/storage/object.js.map +1 -1
- package/types.d.ts +437 -313
- package/types.js +20 -20
- package/types.js.map +1 -1
- package/utils/access.d.ts +9 -8
- package/utils/access.js +12 -62
- package/utils/access.js.map +1 -1
- package/utils/caching/Cache.d.ts +2 -0
- package/utils/caching/Cache.js +51 -0
- package/utils/caching/Cache.js.map +1 -0
- package/utils/caching/CacheKey.d.ts +2 -0
- package/utils/caching/CacheKey.js +40 -0
- package/utils/caching/CacheKey.js.map +1 -0
- package/utils/caching/index.d.ts +2 -0
- package/utils/caching/index.js +29 -0
- package/utils/caching/index.js.map +1 -0
- package/utils/caching/types.d.ts +11 -0
- package/utils/caching/types.js +7 -0
- package/utils/caching/types.js.map +1 -0
- package/utils/converters/Converter.js +4 -5
- package/utils/converters/Converter.js.map +1 -1
- package/utils/converters/ConverterCollection.js +13 -7
- package/utils/converters/ConverterCollection.js.map +1 -1
- package/utils/converters/valueKeyStorageConverter.d.ts +1 -5
- package/utils/converters/valueKeyStorageConverter.js +32 -26
- package/utils/converters/valueKeyStorageConverter.js.map +1 -1
- package/utils/createTypeFromFields.js +8 -4
- package/utils/createTypeFromFields.js.map +1 -1
- package/utils/createTypeName.d.ts +0 -2
- package/utils/createTypeName.js +3 -9
- package/utils/createTypeName.js.map +1 -1
- package/utils/date.d.ts +10 -0
- package/utils/date.js +36 -0
- package/utils/date.js.map +1 -0
- package/utils/entryStorage.d.ts +4 -4
- package/utils/entryStorage.js +6 -4
- package/utils/entryStorage.js.map +1 -1
- package/utils/filterAsync.js +9 -8
- package/utils/filterAsync.js.map +1 -1
- package/utils/getBaseFieldType.d.ts +1 -3
- package/utils/getBaseFieldType.js +3 -1
- package/utils/getBaseFieldType.js.map +1 -1
- package/utils/getEntryDescription.d.ts +1 -1
- package/utils/getEntryDescription.js +3 -1
- package/utils/getEntryDescription.js.map +1 -1
- package/utils/getEntryImage.d.ts +1 -1
- package/utils/getEntryImage.js +3 -1
- package/utils/getEntryImage.js.map +1 -1
- package/utils/getEntryTitle.d.ts +1 -1
- package/utils/getEntryTitle.js +3 -1
- package/utils/getEntryTitle.js.map +1 -1
- package/utils/getSchemaFromFieldPlugins.d.ts +13 -2
- package/utils/getSchemaFromFieldPlugins.js +22 -4
- package/utils/getSchemaFromFieldPlugins.js.map +1 -1
- package/utils/identity.d.ts +2 -0
- package/utils/identity.js +20 -0
- package/utils/identity.js.map +1 -0
- package/utils/incrementEntryIdVersion.js +3 -1
- package/utils/incrementEntryIdVersion.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +18 -0
- package/utils/index.js.map +1 -0
- package/utils/permissions/EntriesPermissions.d.ts +4 -0
- package/utils/permissions/EntriesPermissions.js +11 -0
- package/utils/permissions/EntriesPermissions.js.map +1 -0
- package/utils/permissions/ModelGroupsPermissions.d.ts +9 -0
- package/utils/permissions/ModelGroupsPermissions.js +50 -0
- package/utils/permissions/ModelGroupsPermissions.js.map +1 -0
- package/utils/permissions/ModelsPermissions.d.ts +22 -0
- package/utils/permissions/ModelsPermissions.js +90 -0
- package/utils/permissions/ModelsPermissions.js.map +1 -0
- package/utils/renderFields.d.ts +2 -1
- package/utils/renderFields.js +5 -2
- package/utils/renderFields.js.map +1 -1
- package/utils/renderGetFilterFields.d.ts +2 -2
- package/utils/renderGetFilterFields.js +9 -21
- package/utils/renderGetFilterFields.js.map +1 -1
- package/utils/renderInputFields.d.ts +2 -1
- package/utils/renderInputFields.js +17 -7
- package/utils/renderInputFields.js.map +1 -1
- package/utils/renderListFilterFields.d.ts +3 -1
- package/utils/renderListFilterFields.js +25 -22
- package/utils/renderListFilterFields.js.map +1 -1
- package/utils/renderSortEnum.d.ts +3 -2
- package/utils/renderSortEnum.js +10 -3
- package/utils/renderSortEnum.js.map +1 -1
- package/utils/toSlug.js +3 -1
- package/utils/toSlug.js.map +1 -1
- package/validators/dateGte.js +3 -1
- package/validators/dateGte.js.map +1 -1
- package/validators/dateLte.js +3 -1
- package/validators/dateLte.js.map +1 -1
- package/validators/gte.js +4 -3
- package/validators/gte.js.map +1 -1
- package/validators/in.js +4 -3
- package/validators/in.js.map +1 -1
- package/validators/index.js +4 -3
- package/validators/index.js.map +1 -1
- package/validators/lte.js +4 -3
- package/validators/lte.js.map +1 -1
- package/validators/maxLength.js +4 -3
- package/validators/maxLength.js.map +1 -1
- package/validators/minLength.js +4 -3
- package/validators/minLength.js.map +1 -1
- package/validators/pattern.js +5 -3
- package/validators/pattern.js.map +1 -1
- package/validators/patternPlugins/email.js +3 -1
- package/validators/patternPlugins/email.js.map +1 -1
- package/validators/patternPlugins/index.js +3 -1
- package/validators/patternPlugins/index.js.map +1 -1
- package/validators/patternPlugins/lowerCase.js +3 -1
- package/validators/patternPlugins/lowerCase.js.map +1 -1
- package/validators/patternPlugins/lowerCaseSpace.js +3 -1
- package/validators/patternPlugins/lowerCaseSpace.js.map +1 -1
- package/validators/patternPlugins/upperCase.js +3 -1
- package/validators/patternPlugins/upperCase.js.map +1 -1
- package/validators/patternPlugins/upperCaseSpace.js +3 -1
- package/validators/patternPlugins/upperCaseSpace.js.map +1 -1
- package/validators/patternPlugins/url.js +3 -1
- package/validators/patternPlugins/url.js.map +1 -1
- package/validators/required.js +3 -1
- package/validators/required.js.map +1 -1
- package/validators/timeGte.js +4 -3
- package/validators/timeGte.js.map +1 -1
- package/validators/timeLte.js +4 -3
- package/validators/timeLte.js.map +1 -1
- package/validators/unique.js +4 -2
- package/validators/unique.js.map +1 -1
- package/crud/contentModel/afterCreate.d.ts +0 -8
- package/crud/contentModel/afterCreate.js +0 -16
- package/crud/contentModel/afterCreate.js.map +0 -1
- package/crud/contentModel/afterCreateFrom.d.ts +0 -8
- package/crud/contentModel/afterCreateFrom.js +0 -16
- package/crud/contentModel/afterCreateFrom.js.map +0 -1
- package/crud/contentModel/afterDelete.d.ts +0 -8
- package/crud/contentModel/afterDelete.js +0 -16
- package/crud/contentModel/afterDelete.js.map +0 -1
- package/crud/contentModel/afterUpdate.d.ts +0 -8
- package/crud/contentModel/afterUpdate.js +0 -16
- package/crud/contentModel/afterUpdate.js.map +0 -1
- package/crud/contentModel/createFieldModels.d.ts +0 -2
- package/crud/contentModel/createFieldModels.js +0 -26
- package/crud/contentModel/createFieldModels.js.map +0 -1
- package/crud/contentModel/fieldIdValidation.d.ts +0 -1
- package/crud/contentModel/fieldIdValidation.js +0 -25
- package/crud/contentModel/fieldIdValidation.js.map +0 -1
- package/crud/contentModel/idValidation.d.ts +0 -1
- package/crud/contentModel/idValidation.js +0 -22
- package/crud/contentModel/idValidation.js.map +0 -1
- package/crud/contentModel/models.d.ts +0 -4
- package/crud/contentModel/models.js +0 -192
- package/crud/contentModel/models.js.map +0 -1
- package/crud/contentModel/systemFields.d.ts +0 -1
- package/crud/contentModel/systemFields.js +0 -8
- package/crud/contentModel/systemFields.js.map +0 -1
- package/crud/contentModel/validateLayout.d.ts +0 -2
- package/crud/contentModel/validateLayout.js +0 -28
- package/crud/contentModel/validateLayout.js.map +0 -1
- package/crud/settings.crud.d.ts +0 -10
- package/crud/settings.crud.js +0 -66
- package/crud/settings.crud.js.map +0 -1
- package/graphql/schema/resolvers/commonFieldResolvers.d.ts +0 -7
- package/graphql/schema/resolvers/commonFieldResolvers.js +0 -13
- package/graphql/schema/resolvers/commonFieldResolvers.js.map +0 -1
- package/upgrades/5.33.0/index.d.ts +0 -3
- package/upgrades/5.33.0/index.js +0 -182
- package/upgrades/5.33.0/index.js.map +0 -1
- package/upgrades/index.d.ts +0 -1
- package/upgrades/index.js +0 -12
- package/upgrades/index.js.map +0 -1
- package/utils/ownership.d.ts +0 -8
- package/utils/ownership.js +0 -33
- package/utils/ownership.js.map +0 -1
- package/utils/permissions.d.ts +0 -7
- package/utils/permissions.js +0 -91
- package/utils/permissions.js.map +0 -1
- package/utils/pluralizedTypeName.d.ts +0 -1
- package/utils/pluralizedTypeName.js +0 -26
- package/utils/pluralizedTypeName.js.map +0 -1
- package/validators/dynamicZone.d.ts +0 -2
- package/validators/dynamicZone.js +0 -20
- package/validators/dynamicZone.js.map +0 -1
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.assignModelBeforeUpdate = void 0;
|
|
7
7
|
var _validateModel = require("./validateModel");
|
|
8
|
-
var _validateLayout = require("./validateLayout");
|
|
9
8
|
var _singularApiName = require("./validate/singularApiName");
|
|
10
9
|
var _pluralApiName = require("./validate/pluralApiName");
|
|
11
10
|
var _endingAllowed = require("./validate/endingAllowed");
|
|
@@ -18,10 +17,6 @@ const assignModelBeforeUpdate = params => {
|
|
|
18
17
|
model: newModel,
|
|
19
18
|
original
|
|
20
19
|
}) => {
|
|
21
|
-
/**
|
|
22
|
-
* First we go through the layout...
|
|
23
|
-
*/
|
|
24
|
-
(0, _validateLayout.validateLayout)(newModel.layout, newModel.fields);
|
|
25
20
|
const models = await context.security.withoutAuthorization(async () => {
|
|
26
21
|
return (await context.cms.listModels()).filter(model => {
|
|
27
22
|
return model.modelId !== newModel.modelId;
|
|
@@ -57,4 +52,6 @@ const assignModelBeforeUpdate = params => {
|
|
|
57
52
|
});
|
|
58
53
|
});
|
|
59
54
|
};
|
|
60
|
-
exports.assignModelBeforeUpdate = assignModelBeforeUpdate;
|
|
55
|
+
exports.assignModelBeforeUpdate = assignModelBeforeUpdate;
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=beforeUpdate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_validateModel","require","_singularApiName","_pluralApiName","_endingAllowed","assignModelBeforeUpdate","params","onModelBeforeUpdate","context","subscribe","model","newModel","original","models","security","withoutAuthorization","cms","listModels","filter","modelId","validateEndingAllowed","validateSingularApiName","existingModel","validatePluralApiName","validateModel","exports"],"sources":["beforeUpdate.ts"],"sourcesContent":["import { Topic } from \"@webiny/pubsub/types\";\nimport { CmsContext, OnModelBeforeUpdateTopicParams } from \"~/types\";\nimport { validateModel } from \"./validateModel\";\nimport { validateSingularApiName } from \"./validate/singularApiName\";\nimport { validatePluralApiName } from \"./validate/pluralApiName\";\nimport { validateEndingAllowed } from \"~/crud/contentModel/validate/endingAllowed\";\n\ninterface AssignBeforeModelUpdateParams {\n onModelBeforeUpdate: Topic<OnModelBeforeUpdateTopicParams>;\n context: CmsContext;\n}\n\nexport const assignModelBeforeUpdate = (params: AssignBeforeModelUpdateParams) => {\n const { onModelBeforeUpdate, context } = params;\n\n onModelBeforeUpdate.subscribe(async ({ model: newModel, original }) => {\n const models = await context.security.withoutAuthorization(async () => {\n return (await context.cms.listModels()).filter(model => {\n return model.modelId !== newModel.modelId;\n });\n });\n\n validateEndingAllowed({\n model: newModel\n });\n /**\n * We need to check for the existence of:\n * - modelId\n * - singularApiName\n * - pluralApiName\n */\n for (const model of models) {\n validateSingularApiName({\n existingModel: model,\n model: newModel\n });\n validatePluralApiName({\n existingModel: model,\n model: newModel\n });\n }\n /**\n * then the model and fields...\n */\n await validateModel({\n models,\n model: newModel,\n original,\n context\n });\n });\n};\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AAOO,MAAMI,uBAAuB,GAAIC,MAAqC,IAAK;EAC9E,MAAM;IAAEC,mBAAmB;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAE/CC,mBAAmB,CAACE,SAAS,CAAC,OAAO;IAAEC,KAAK,EAAEC,QAAQ;IAAEC;EAAS,CAAC,KAAK;IACnE,MAAMC,MAAM,GAAG,MAAML,OAAO,CAACM,QAAQ,CAACC,oBAAoB,CAAC,YAAY;MACnE,OAAO,CAAC,MAAMP,OAAO,CAACQ,GAAG,CAACC,UAAU,CAAC,CAAC,EAAEC,MAAM,CAACR,KAAK,IAAI;QACpD,OAAOA,KAAK,CAACS,OAAO,KAAKR,QAAQ,CAACQ,OAAO;MAC7C,CAAC,CAAC;IACN,CAAC,CAAC;IAEF,IAAAC,oCAAqB,EAAC;MAClBV,KAAK,EAAEC;IACX,CAAC,CAAC;IACF;AACR;AACA;AACA;AACA;AACA;IACQ,KAAK,MAAMD,KAAK,IAAIG,MAAM,EAAE;MACxB,IAAAQ,wCAAuB,EAAC;QACpBC,aAAa,EAAEZ,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;MACF,IAAAY,oCAAqB,EAAC;QAClBD,aAAa,EAAEZ,KAAK;QACpBA,KAAK,EAAEC;MACX,CAAC,CAAC;IACN;IACA;AACR;AACA;IACQ,MAAM,IAAAa,4BAAa,EAAC;MAChBX,MAAM;MACNH,KAAK,EAAEC,QAAQ;MACfC,QAAQ;MACRJ;IACJ,CAAC,CAAC;EACN,CAAC,CAAC;AACN,CAAC;AAACiB,OAAA,CAAApB,uBAAA,GAAAA,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ensureSingularApiName","model","singularApiName","upperFirst","camelCase","modelId","ensurePluralApiName","pluralApiName","pluralize"],"sources":["modelApiName.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { CmsModel } from \"~/types\";\n\nexport const ensureSingularApiName = (model: CmsModel): string => {\n if (!model.singularApiName) {\n return upperFirst(camelCase(model.modelId));\n }\n return model.singularApiName;\n};\n\nexport const ensurePluralApiName = (model: CmsModel): string => {\n if (!model.pluralApiName) {\n return pluralize(ensureSingularApiName(model));\n }\n return model.pluralApiName;\n};\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AAGO,
|
|
1
|
+
{"version":3,"names":["_camelCase","_interopRequireDefault","require","_upperFirst","_pluralize","ensureSingularApiName","model","singularApiName","upperFirst","camelCase","modelId","exports","ensurePluralApiName","pluralApiName","pluralize"],"sources":["modelApiName.ts"],"sourcesContent":["import camelCase from \"lodash/camelCase\";\nimport upperFirst from \"lodash/upperFirst\";\nimport pluralize from \"pluralize\";\nimport { CmsModel } from \"~/types\";\n\nexport const ensureSingularApiName = (model: CmsModel): string => {\n if (!model.singularApiName) {\n return upperFirst(camelCase(model.modelId));\n }\n return model.singularApiName;\n};\n\nexport const ensurePluralApiName = (model: CmsModel): string => {\n if (!model.pluralApiName) {\n return pluralize(ensureSingularApiName(model));\n }\n return model.pluralApiName;\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,UAAA,GAAAH,sBAAA,CAAAC,OAAA;AAGO,MAAMG,qBAAqB,GAAIC,KAAe,IAAa;EAC9D,IAAI,CAACA,KAAK,CAACC,eAAe,EAAE;IACxB,OAAO,IAAAC,mBAAU,EAAC,IAAAC,kBAAS,EAACH,KAAK,CAACI,OAAO,CAAC,CAAC;EAC/C;EACA,OAAOJ,KAAK,CAACC,eAAe;AAChC,CAAC;AAACI,OAAA,CAAAN,qBAAA,GAAAA,qBAAA;AAEK,MAAMO,mBAAmB,GAAIN,KAAe,IAAa;EAC5D,IAAI,CAACA,KAAK,CAACO,aAAa,EAAE;IACtB,OAAO,IAAAC,kBAAS,EAACT,qBAAqB,CAACC,KAAK,CAAC,CAAC;EAClD;EACA,OAAOA,KAAK,CAACO,aAAa;AAC9B,CAAC;AAACF,OAAA,CAAAC,mBAAA,GAAAA,mBAAA"}
|
|
@@ -19,4 +19,6 @@ const contentModelManagerFactory = async (context, model) => {
|
|
|
19
19
|
}
|
|
20
20
|
return await plugin.create(context, model);
|
|
21
21
|
};
|
|
22
|
-
exports.contentModelManagerFactory = contentModelManagerFactory;
|
|
22
|
+
exports.contentModelManagerFactory = contentModelManagerFactory;
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=contentModelManagerFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultName","contentModelManagerFactory","context","model","pluginsByType","plugins","byType","reverse","plugin","target","Array","isArray","modelId","includes","name","create","find","Error"],"sources":["contentModelManagerFactory.ts"],"sourcesContent":["import { CmsModel, CmsContext, ModelManagerPlugin, CmsModelManager } from \"~/types\";\n\nconst defaultName = \"content-model-manager-default\";\n\nexport const contentModelManagerFactory = async (\n context: CmsContext,\n model: CmsModel\n): Promise<CmsModelManager> => {\n const pluginsByType = context.plugins\n .byType<ModelManagerPlugin>(\"cms-content-model-manager\")\n .reverse();\n for (const plugin of pluginsByType) {\n const target = Array.isArray(plugin.modelId) ? plugin.modelId : [plugin.modelId];\n if (target.includes(model.modelId) === true && plugin.name !== defaultName) {\n return await plugin.create(context, model);\n }\n }\n const plugin = pluginsByType.find(plugin => plugin.name === defaultName);\n if (!plugin) {\n throw new Error(\"There is no default plugin to create CmsModelManager\");\n }\n return await plugin.create(context, model);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,WAAW,GAAG,+BAA+B;AAE5C,MAAMC,0BAA0B,GAAG,
|
|
1
|
+
{"version":3,"names":["defaultName","contentModelManagerFactory","context","model","pluginsByType","plugins","byType","reverse","plugin","target","Array","isArray","modelId","includes","name","create","find","Error","exports"],"sources":["contentModelManagerFactory.ts"],"sourcesContent":["import { CmsModel, CmsContext, ModelManagerPlugin, CmsModelManager } from \"~/types\";\n\nconst defaultName = \"content-model-manager-default\";\n\nexport const contentModelManagerFactory = async (\n context: CmsContext,\n model: CmsModel\n): Promise<CmsModelManager> => {\n const pluginsByType = context.plugins\n .byType<ModelManagerPlugin>(\"cms-content-model-manager\")\n .reverse();\n for (const plugin of pluginsByType) {\n const target = Array.isArray(plugin.modelId) ? plugin.modelId : [plugin.modelId];\n if (target.includes(model.modelId) === true && plugin.name !== defaultName) {\n return await plugin.create(context, model);\n }\n }\n const plugin = pluginsByType.find(plugin => plugin.name === defaultName);\n if (!plugin) {\n throw new Error(\"There is no default plugin to create CmsModelManager\");\n }\n return await plugin.create(context, model);\n};\n"],"mappings":";;;;;;AAEA,MAAMA,WAAW,GAAG,+BAA+B;AAE5C,MAAMC,0BAA0B,GAAG,MAAAA,CACtCC,OAAmB,EACnBC,KAAe,KACY;EAC3B,MAAMC,aAAa,GAAGF,OAAO,CAACG,OAAO,CAChCC,MAAM,CAAqB,2BAA2B,CAAC,CACvDC,OAAO,CAAC,CAAC;EACd,KAAK,MAAMC,MAAM,IAAIJ,aAAa,EAAE;IAChC,MAAMK,MAAM,GAAGC,KAAK,CAACC,OAAO,CAACH,MAAM,CAACI,OAAO,CAAC,GAAGJ,MAAM,CAACI,OAAO,GAAG,CAACJ,MAAM,CAACI,OAAO,CAAC;IAChF,IAAIH,MAAM,CAACI,QAAQ,CAACV,KAAK,CAACS,OAAO,CAAC,KAAK,IAAI,IAAIJ,MAAM,CAACM,IAAI,KAAKd,WAAW,EAAE;MACxE,OAAO,MAAMQ,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;IAC9C;EACJ;EACA,MAAMK,MAAM,GAAGJ,aAAa,CAACY,IAAI,CAACR,MAAM,IAAIA,MAAM,CAACM,IAAI,KAAKd,WAAW,CAAC;EACxE,IAAI,CAACQ,MAAM,EAAE;IACT,MAAM,IAAIS,KAAK,CAAC,sDAAsD,CAAC;EAC3E;EACA,OAAO,MAAMT,MAAM,CAACO,MAAM,CAACb,OAAO,EAAEC,KAAK,CAAC;AAC9C,CAAC;AAACe,OAAA,CAAAjB,0BAAA,GAAAA,0BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createFieldStorageId","params","type","id","getBaseFieldType"],"sources":["createFieldStorageId.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport const createFieldStorageId = (params: Pick<CmsModelField, \"id\" | \"type\">): string => {\n const { type, id } = params;\n return `${getBaseFieldType({ type })}@${id}`;\n};\n"],"mappings":";;;;;;AACA;AAEO,
|
|
1
|
+
{"version":3,"names":["_getBaseFieldType","require","createFieldStorageId","params","type","id","getBaseFieldType","exports"],"sources":["createFieldStorageId.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\n\nexport const createFieldStorageId = (params: Pick<CmsModelField, \"id\" | \"type\">): string => {\n const { type, id } = params;\n return `${getBaseFieldType({ type })}@${id}`;\n};\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AAEO,MAAMC,oBAAoB,GAAIC,MAA0C,IAAa;EACxF,MAAM;IAAEC,IAAI;IAAEC;EAAG,CAAC,GAAGF,MAAM;EAC3B,OAAQ,GAAE,IAAAG,kCAAgB,EAAC;IAAEF;EAAK,CAAC,CAAE,IAAGC,EAAG,EAAC;AAChD,CAAC;AAACE,OAAA,CAAAL,oBAAA,GAAAA,oBAAA"}
|
|
@@ -55,4 +55,6 @@ const assignModelDefaultFields = model => {
|
|
|
55
55
|
model.fields = createDefaultFields();
|
|
56
56
|
model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];
|
|
57
57
|
};
|
|
58
|
-
exports.assignModelDefaultFields = assignModelDefaultFields;
|
|
58
|
+
exports.assignModelDefaultFields = assignModelDefaultFields;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=defaultFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createDefaultFields","id","generateAlphaNumericLowerCaseId","fieldId","type","label","validation","name","message","listValidation","renderer","settings","imagesOnly","assignModelDefaultFields","model","fields","length","layout"],"sources":["defaultFields.ts"],"sourcesContent":["import { CmsModelCreateInput, CmsModelFieldInput } from \"~/types\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\n\nconst createDefaultFields = (): CmsModelFieldInput[] => {\n return [\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n validation: [\n {\n name: \"required\",\n message: \"Title is a required field.\"\n }\n ],\n listValidation: [],\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"description\",\n type: \"long-text\",\n label: \"Description\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"long-text-text-area\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"image\",\n type: \"file\",\n label: \"Image\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"file-input\"\n },\n settings: {\n imagesOnly: true\n }\n }\n ];\n};\n\n/**\n * We only assign default fields if there are no fields in the model already.\n */\nexport const assignModelDefaultFields = (model: CmsModelCreateInput): void => {\n if (model.fields && model.fields.length !== 0) {\n return;\n }\n\n model.fields = createDefaultFields();\n model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];\n};\n"],"mappings":";;;;;;AACA;AAEA,
|
|
1
|
+
{"version":3,"names":["_utils","require","createDefaultFields","id","generateAlphaNumericLowerCaseId","fieldId","type","label","validation","name","message","listValidation","renderer","settings","imagesOnly","assignModelDefaultFields","model","fields","length","layout","exports"],"sources":["defaultFields.ts"],"sourcesContent":["import { CmsModelCreateInput, CmsModelFieldInput } from \"~/types\";\nimport { generateAlphaNumericLowerCaseId } from \"@webiny/utils\";\n\nconst createDefaultFields = (): CmsModelFieldInput[] => {\n return [\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"title\",\n type: \"text\",\n label: \"Title\",\n validation: [\n {\n name: \"required\",\n message: \"Title is a required field.\"\n }\n ],\n listValidation: [],\n renderer: {\n name: \"text-input\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"description\",\n type: \"long-text\",\n label: \"Description\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"long-text-text-area\"\n }\n },\n {\n id: generateAlphaNumericLowerCaseId(8),\n fieldId: \"image\",\n type: \"file\",\n label: \"Image\",\n validation: [],\n listValidation: [],\n renderer: {\n name: \"file-input\"\n },\n settings: {\n imagesOnly: true\n }\n }\n ];\n};\n\n/**\n * We only assign default fields if there are no fields in the model already.\n */\nexport const assignModelDefaultFields = (model: CmsModelCreateInput): void => {\n if (model.fields && model.fields.length !== 0) {\n return;\n }\n\n model.fields = createDefaultFields();\n model.layout = [[model.fields[0].id], [model.fields[1].id, model.fields[2].id]];\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AAEA,MAAMC,mBAAmB,GAAGA,CAAA,KAA4B;EACpD,OAAO,CACH;IACIC,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,OAAO;IAChBC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAE,OAAO;IACdC,UAAU,EAAE,CACR;MACIC,IAAI,EAAE,UAAU;MAChBC,OAAO,EAAE;IACb,CAAC,CACJ;IACDC,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,aAAa;IACtBC,IAAI,EAAE,WAAW;IACjBC,KAAK,EAAE,aAAa;IACpBC,UAAU,EAAE,EAAE;IACdG,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV;EACJ,CAAC,EACD;IACIN,EAAE,EAAE,IAAAC,sCAA+B,EAAC,CAAC,CAAC;IACtCC,OAAO,EAAE,OAAO;IAChBC,IAAI,EAAE,MAAM;IACZC,KAAK,EAAE,OAAO;IACdC,UAAU,EAAE,EAAE;IACdG,cAAc,EAAE,EAAE;IAClBC,QAAQ,EAAE;MACNH,IAAI,EAAE;IACV,CAAC;IACDI,QAAQ,EAAE;MACNC,UAAU,EAAE;IAChB;EACJ,CAAC,CACJ;AACL,CAAC;;AAED;AACA;AACA;AACO,MAAMC,wBAAwB,GAAIC,KAA0B,IAAW;EAC1E,IAAIA,KAAK,CAACC,MAAM,IAAID,KAAK,CAACC,MAAM,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3C;EACJ;EAEAF,KAAK,CAACC,MAAM,GAAGf,mBAAmB,CAAC,CAAC;EACpCc,KAAK,CAACG,MAAM,GAAG,CAAC,CAACH,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,CAAC,EAAE,CAACa,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,EAAEa,KAAK,CAACC,MAAM,CAAC,CAAC,CAAC,CAACd,EAAE,CAAC,CAAC;AACnF,CAAC;AAACiB,OAAA,CAAAL,wBAAA,GAAAA,wBAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ensureTypeTag = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Given a model, return an array of tags ensuring the `type` tag is set.
|
|
9
|
+
*/
|
|
10
|
+
const ensureTypeTag = model => {
|
|
11
|
+
// Let's make sure we have a `type` tag assigned.
|
|
12
|
+
// If `type` tag is not set, set it to a default one (`model`).
|
|
13
|
+
const tags = model.tags || [];
|
|
14
|
+
if (!tags.some(tag => tag.startsWith("type:"))) {
|
|
15
|
+
tags.push("type:model");
|
|
16
|
+
}
|
|
17
|
+
return tags;
|
|
18
|
+
};
|
|
19
|
+
exports.ensureTypeTag = ensureTypeTag;
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=ensureTypeTag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["ensureTypeTag","model","tags","some","tag","startsWith","push","exports"],"sources":["ensureTypeTag.ts"],"sourcesContent":["import { CmsModel } from \"~/types\";\n\n/**\n * Given a model, return an array of tags ensuring the `type` tag is set.\n */\nexport const ensureTypeTag = (model: Pick<CmsModel, \"tags\">) => {\n // Let's make sure we have a `type` tag assigned.\n // If `type` tag is not set, set it to a default one (`model`).\n const tags = model.tags || [];\n if (!tags.some(tag => tag.startsWith(\"type:\"))) {\n tags.push(\"type:model\");\n }\n\n return tags;\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACO,MAAMA,aAAa,GAAIC,KAA6B,IAAK;EAC5D;EACA;EACA,MAAMC,IAAI,GAAGD,KAAK,CAACC,IAAI,IAAI,EAAE;EAC7B,IAAI,CAACA,IAAI,CAACC,IAAI,CAACC,GAAG,IAAIA,GAAG,CAACC,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE;IAC5CH,IAAI,CAACI,IAAI,CAAC,YAAY,CAAC;EAC3B;EAEA,OAAOJ,IAAI;AACf,CAAC;AAACK,OAAA,CAAAP,aAAA,GAAAA,aAAA"}
|
|
@@ -21,7 +21,7 @@ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
|
|
|
21
21
|
const descriptionField = fields.find(field => {
|
|
22
22
|
return (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text" && !field.multipleValues;
|
|
23
23
|
});
|
|
24
|
-
return
|
|
24
|
+
return descriptionField?.fieldId || null;
|
|
25
25
|
}
|
|
26
26
|
const target = fields.find(field => field.fieldId === descriptionFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "long-text");
|
|
27
27
|
if (!target) {
|
|
@@ -39,4 +39,6 @@ const getContentModelDescriptionFieldId = (fields, descriptionFieldId) => {
|
|
|
39
39
|
}
|
|
40
40
|
return target.fieldId;
|
|
41
41
|
};
|
|
42
|
-
exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
|
|
42
|
+
exports.getContentModelDescriptionFieldId = getContentModelDescriptionFieldId;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=descriptionField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getContentModelDescriptionFieldId","fields","descriptionFieldId","length","descriptionField","find","field","getBaseFieldType","multipleValues","fieldId","target","WebinyError","storageId","type"],"sources":["descriptionField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelDescriptionFieldId = (\n fields: CmsModelField[],\n descriptionFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If description field is not defined, let us find possible one.\n */\n if (!descriptionFieldId) {\n const descriptionField = fields.find(field => {\n return getBaseFieldType(field) === \"long-text\" && !field.multipleValues;\n });\n return descriptionField?.fieldId || null;\n }\n const target = fields.find(\n field => field.fieldId === descriptionFieldId && getBaseFieldType(field) === \"long-text\"\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the description field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: descriptionFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry description.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA;AACA;AAEO,
|
|
1
|
+
{"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","getContentModelDescriptionFieldId","fields","descriptionFieldId","length","descriptionField","find","field","getBaseFieldType","multipleValues","fieldId","target","WebinyError","storageId","type","exports"],"sources":["descriptionField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelDescriptionFieldId = (\n fields: CmsModelField[],\n descriptionFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If description field is not defined, let us find possible one.\n */\n if (!descriptionFieldId) {\n const descriptionField = fields.find(field => {\n return getBaseFieldType(field) === \"long-text\" && !field.multipleValues;\n });\n return descriptionField?.fieldId || null;\n }\n const target = fields.find(\n field => field.fieldId === descriptionFieldId && getBaseFieldType(field) === \"long-text\"\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the description field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: descriptionFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry description.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,iCAAiC,GAAGA,CAC7CC,MAAuB,EACvBC,kBAAkC,KACN;EAC5B;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACD,kBAAkB,EAAE;IACrB,MAAME,gBAAgB,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MAC1C,OAAO,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,WAAW,IAAI,CAACA,KAAK,CAACE,cAAc;IAC3E,CAAC,CAAC;IACF,OAAOJ,gBAAgB,EAAEK,OAAO,IAAI,IAAI;EAC5C;EACA,MAAMC,MAAM,GAAGT,MAAM,CAACI,IAAI,CACtBC,KAAK,IAAIA,KAAK,CAACG,OAAO,KAAKP,kBAAkB,IAAI,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,WACjF,CAAC;EACD,IAAI,CAACI,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,uEAAsE,EACvE,kBAAkB,EAClB;MACIF,OAAO,EAAEP,kBAAkB;MAC3BD;IACJ,CACJ,CAAC;EACL;EACA,IAAIS,MAAM,CAACF,cAAc,EAAE;IACvB,MAAM,IAAIG,cAAW,CAChB,6EAA4E,EAC7E,wBAAwB,EACxB;MACIC,SAAS,EAAEF,MAAM,CAACE,SAAS;MAC3BH,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBI,IAAI,EAAEH,MAAM,CAACG;IACjB,CACJ,CAAC;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAACK,OAAA,CAAAd,iCAAA,GAAAA,iCAAA"}
|
|
@@ -19,15 +19,11 @@ const getContentModelImageFieldId = (fields, imageFieldId) => {
|
|
|
19
19
|
*/
|
|
20
20
|
if (!imageFieldId) {
|
|
21
21
|
const imageField = fields.find(field => {
|
|
22
|
-
|
|
23
|
-
return (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && !field.multipleValues && ((_field$settings = field.settings) === null || _field$settings === void 0 ? void 0 : _field$settings.imagesOnly);
|
|
22
|
+
return (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && !field.multipleValues && field.settings?.imagesOnly;
|
|
24
23
|
});
|
|
25
|
-
return
|
|
24
|
+
return imageField?.fieldId || null;
|
|
26
25
|
}
|
|
27
|
-
const target = fields.find(field =>
|
|
28
|
-
var _field$settings2;
|
|
29
|
-
return field.fieldId === imageFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && ((_field$settings2 = field.settings) === null || _field$settings2 === void 0 ? void 0 : _field$settings2.imagesOnly);
|
|
30
|
-
});
|
|
26
|
+
const target = fields.find(field => field.fieldId === imageFieldId && (0, _getBaseFieldType.getBaseFieldType)(field) === "file" && field.settings?.imagesOnly);
|
|
31
27
|
if (!target) {
|
|
32
28
|
throw new _error.default(`Field selected for the image field does not exist in the model.`, "VALIDATION_ERROR", {
|
|
33
29
|
fieldId: imageFieldId,
|
|
@@ -43,4 +39,6 @@ const getContentModelImageFieldId = (fields, imageFieldId) => {
|
|
|
43
39
|
}
|
|
44
40
|
return target.fieldId;
|
|
45
41
|
};
|
|
46
|
-
exports.getContentModelImageFieldId = getContentModelImageFieldId;
|
|
42
|
+
exports.getContentModelImageFieldId = getContentModelImageFieldId;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=imageField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getContentModelImageFieldId","fields","imageFieldId","length","imageField","find","field","getBaseFieldType","multipleValues","settings","imagesOnly","fieldId","target","WebinyError","storageId","type"],"sources":["imageField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelImageFieldId = (\n fields: CmsModelField[],\n imageFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If image field is not defined, let us find possible one.\n */\n if (!imageFieldId) {\n const imageField = fields.find(field => {\n return (\n getBaseFieldType(field) === \"file\" &&\n !field.multipleValues &&\n field.settings?.imagesOnly\n );\n });\n return imageField?.fieldId || null;\n }\n const target = fields.find(\n field =>\n field.fieldId === imageFieldId &&\n getBaseFieldType(field) === \"file\" &&\n field.settings?.imagesOnly\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the image field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: imageFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry image.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA;AACA;AAEO,
|
|
1
|
+
{"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","getContentModelImageFieldId","fields","imageFieldId","length","imageField","find","field","getBaseFieldType","multipleValues","settings","imagesOnly","fieldId","target","WebinyError","storageId","type","exports"],"sources":["imageField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nexport const getContentModelImageFieldId = (\n fields: CmsModelField[],\n imageFieldId?: string | null\n): string | null | undefined => {\n /**\n * If there are no fields defined, we will just set as null.\n */\n if (fields.length === 0) {\n return null;\n }\n /**\n * If image field is not defined, let us find possible one.\n */\n if (!imageFieldId) {\n const imageField = fields.find(field => {\n return (\n getBaseFieldType(field) === \"file\" &&\n !field.multipleValues &&\n field.settings?.imagesOnly\n );\n });\n return imageField?.fieldId || null;\n }\n const target = fields.find(\n field =>\n field.fieldId === imageFieldId &&\n getBaseFieldType(field) === \"file\" &&\n field.settings?.imagesOnly\n );\n if (!target) {\n throw new WebinyError(\n `Field selected for the image field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: imageFieldId,\n fields\n }\n );\n }\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry image.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEO,MAAMG,2BAA2B,GAAGA,CACvCC,MAAuB,EACvBC,YAA4B,KACA;EAC5B;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAO,IAAI;EACf;EACA;AACJ;AACA;EACI,IAAI,CAACD,YAAY,EAAE;IACf,MAAME,UAAU,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MACpC,OACI,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAClC,CAACA,KAAK,CAACE,cAAc,IACrBF,KAAK,CAACG,QAAQ,EAAEC,UAAU;IAElC,CAAC,CAAC;IACF,OAAON,UAAU,EAAEO,OAAO,IAAI,IAAI;EACtC;EACA,MAAMC,MAAM,GAAGX,MAAM,CAACI,IAAI,CACtBC,KAAK,IACDA,KAAK,CAACK,OAAO,KAAKT,YAAY,IAC9B,IAAAK,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAClCA,KAAK,CAACG,QAAQ,EAAEC,UACxB,CAAC;EACD,IAAI,CAACE,MAAM,EAAE;IACT,MAAM,IAAIC,cAAW,CAChB,iEAAgE,EACjE,kBAAkB,EAClB;MACIF,OAAO,EAAET,YAAY;MACrBD;IACJ,CACJ,CAAC;EACL;EACA,IAAIW,MAAM,CAACJ,cAAc,EAAE;IACvB,MAAM,IAAIK,cAAW,CAChB,uEAAsE,EACvE,wBAAwB,EACxB;MACIC,SAAS,EAAEF,MAAM,CAACE,SAAS;MAC3BH,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBI,IAAI,EAAEH,MAAM,CAACG;IACjB,CACJ,CAAC;EACL;EAEA,OAAOH,MAAM,CAACD,OAAO;AACzB,CAAC;AAACK,OAAA,CAAAhB,2BAAA,GAAAA,2BAAA"}
|
|
@@ -25,7 +25,7 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
|
25
25
|
const titleField = fields.find(field => {
|
|
26
26
|
return (0, _getBaseFieldType.getBaseFieldType)(field) === "text" && !field.multipleValues;
|
|
27
27
|
});
|
|
28
|
-
return
|
|
28
|
+
return titleField?.fieldId || defaultTitleFieldId;
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* check existing titleFieldId for existence in the model
|
|
@@ -55,4 +55,6 @@ const getContentModelTitleFieldId = (fields, titleFieldId) => {
|
|
|
55
55
|
}
|
|
56
56
|
return target.fieldId;
|
|
57
57
|
};
|
|
58
|
-
exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
|
|
58
|
+
exports.getContentModelTitleFieldId = getContentModelTitleFieldId;
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=titleField.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","length","titleField","find","field","getBaseFieldType","multipleValues","fieldId","target","f","WebinyError","includes","type","join","storageId"],"sources":["titleField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nexport const getContentModelTitleFieldId = (\n fields: CmsModelField[],\n titleFieldId?: string\n): string => {\n /**\n * If there are no fields defined, we will return the default field\n */\n if (fields.length === 0) {\n return defaultTitleFieldId;\n }\n /**\n * if there is no title field defined either in input data or existing content model data\n * we will take first text field that has no multiple values enabled\n * or if initial titleFieldId is the default one also try to find first available text field\n */\n if (!titleFieldId || titleFieldId === defaultTitleFieldId) {\n const titleField = fields.find(field => {\n return getBaseFieldType(field) === \"text\" && !field.multipleValues;\n });\n return titleField?.fieldId || defaultTitleFieldId;\n }\n /**\n * check existing titleFieldId for existence in the model\n * for correct type\n * and that it is not multiple values field\n */\n const target = fields.find(f => f.fieldId === titleFieldId);\n if (!target) {\n throw new WebinyError(\n `Field selected for the title field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: titleFieldId,\n fields\n }\n );\n }\n\n if (allowedTitleFieldTypes.includes(target.type) === false) {\n throw new WebinyError(\n `Only ${allowedTitleFieldTypes.join(\n \", \"\n )} and id fields can be used as an entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA;AACA;AAEA,
|
|
1
|
+
{"version":3,"names":["_getBaseFieldType","require","_error","_interopRequireDefault","defaultTitleFieldId","allowedTitleFieldTypes","getContentModelTitleFieldId","fields","titleFieldId","length","titleField","find","field","getBaseFieldType","multipleValues","fieldId","target","f","WebinyError","includes","type","join","storageId","exports"],"sources":["titleField.ts"],"sourcesContent":["import { CmsModelField } from \"~/types\";\nimport { getBaseFieldType } from \"~/utils/getBaseFieldType\";\nimport WebinyError from \"@webiny/error\";\n\nconst defaultTitleFieldId = \"id\";\n\nconst allowedTitleFieldTypes = [\"text\", \"number\"];\n\nexport const getContentModelTitleFieldId = (\n fields: CmsModelField[],\n titleFieldId?: string\n): string => {\n /**\n * If there are no fields defined, we will return the default field\n */\n if (fields.length === 0) {\n return defaultTitleFieldId;\n }\n /**\n * if there is no title field defined either in input data or existing content model data\n * we will take first text field that has no multiple values enabled\n * or if initial titleFieldId is the default one also try to find first available text field\n */\n if (!titleFieldId || titleFieldId === defaultTitleFieldId) {\n const titleField = fields.find(field => {\n return getBaseFieldType(field) === \"text\" && !field.multipleValues;\n });\n return titleField?.fieldId || defaultTitleFieldId;\n }\n /**\n * check existing titleFieldId for existence in the model\n * for correct type\n * and that it is not multiple values field\n */\n const target = fields.find(f => f.fieldId === titleFieldId);\n if (!target) {\n throw new WebinyError(\n `Field selected for the title field does not exist in the model.`,\n \"VALIDATION_ERROR\",\n {\n fieldId: titleFieldId,\n fields\n }\n );\n }\n\n if (allowedTitleFieldTypes.includes(target.type) === false) {\n throw new WebinyError(\n `Only ${allowedTitleFieldTypes.join(\n \", \"\n )} and id fields can be used as an entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n if (target.multipleValues) {\n throw new WebinyError(\n `Fields that accept multiple values cannot be used as the entry title.`,\n \"ENTRY_TITLE_FIELD_TYPE\",\n {\n storageId: target.storageId,\n fieldId: target.fieldId,\n type: target.type\n }\n );\n }\n\n return target.fieldId;\n};\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,MAAMG,mBAAmB,GAAG,IAAI;AAEhC,MAAMC,sBAAsB,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC;AAE1C,MAAMC,2BAA2B,GAAGA,CACvCC,MAAuB,EACvBC,YAAqB,KACZ;EACT;AACJ;AACA;EACI,IAAID,MAAM,CAACE,MAAM,KAAK,CAAC,EAAE;IACrB,OAAOL,mBAAmB;EAC9B;EACA;AACJ;AACA;AACA;AACA;EACI,IAAI,CAACI,YAAY,IAAIA,YAAY,KAAKJ,mBAAmB,EAAE;IACvD,MAAMM,UAAU,GAAGH,MAAM,CAACI,IAAI,CAACC,KAAK,IAAI;MACpC,OAAO,IAAAC,kCAAgB,EAACD,KAAK,CAAC,KAAK,MAAM,IAAI,CAACA,KAAK,CAACE,cAAc;IACtE,CAAC,CAAC;IACF,OAAOJ,UAAU,EAAEK,OAAO,IAAIX,mBAAmB;EACrD;EACA;AACJ;AACA;AACA;AACA;EACI,MAAMY,MAAM,GAAGT,MAAM,CAACI,IAAI,CAACM,CAAC,IAAIA,CAAC,CAACF,OAAO,KAAKP,YAAY,CAAC;EAC3D,IAAI,CAACQ,MAAM,EAAE;IACT,MAAM,IAAIE,cAAW,CAChB,iEAAgE,EACjE,kBAAkB,EAClB;MACIH,OAAO,EAAEP,YAAY;MACrBD;IACJ,CACJ,CAAC;EACL;EAEA,IAAIF,sBAAsB,CAACc,QAAQ,CAACH,MAAM,CAACI,IAAI,CAAC,KAAK,KAAK,EAAE;IACxD,MAAM,IAAIF,cAAW,CAChB,QAAOb,sBAAsB,CAACgB,IAAI,CAC/B,IACJ,CAAE,+CAA8C,EAChD,wBAAwB,EACxB;MACIC,SAAS,EAAEN,MAAM,CAACM,SAAS;MAC3BP,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBK,IAAI,EAAEJ,MAAM,CAACI;IACjB,CACJ,CAAC;EACL;EAEA,IAAIJ,MAAM,CAACF,cAAc,EAAE;IACvB,MAAM,IAAII,cAAW,CAChB,uEAAsE,EACvE,wBAAwB,EACxB;MACII,SAAS,EAAEN,MAAM,CAACM,SAAS;MAC3BP,OAAO,EAAEC,MAAM,CAACD,OAAO;MACvBK,IAAI,EAAEJ,MAAM,CAACI;IACjB,CACJ,CAAC;EACL;EAEA,OAAOJ,MAAM,CAACD,OAAO;AACzB,CAAC;AAACQ,OAAA,CAAAjB,2BAAA,GAAAA,2BAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CmsModel, HeadlessCmsStorageOperations } from "../../types";
|
|
2
|
+
import { Tenant } from "@webiny/api-tenancy/types";
|
|
3
|
+
import { I18NLocale } from "@webiny/api-i18n/types";
|
|
4
|
+
interface Params {
|
|
5
|
+
storageOperations: HeadlessCmsStorageOperations;
|
|
6
|
+
getTenant: () => Tenant;
|
|
7
|
+
getLocale: () => I18NLocale;
|
|
8
|
+
}
|
|
9
|
+
export declare const listModelsFromDatabase: (params: Params) => Promise<CmsModel[]>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.listModelsFromDatabase = void 0;
|
|
7
|
+
var _modelApiName = require("./compatibility/modelApiName");
|
|
8
|
+
var _ensureTypeTag = require("./ensureTypeTag");
|
|
9
|
+
const listModelsFromDatabase = async params => {
|
|
10
|
+
const {
|
|
11
|
+
storageOperations,
|
|
12
|
+
getTenant,
|
|
13
|
+
getLocale
|
|
14
|
+
} = params;
|
|
15
|
+
const models = await storageOperations.models.list({
|
|
16
|
+
where: {
|
|
17
|
+
tenant: getTenant().id,
|
|
18
|
+
locale: getLocale().code
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return models.map(model => {
|
|
22
|
+
return {
|
|
23
|
+
...model,
|
|
24
|
+
tags: (0, _ensureTypeTag.ensureTypeTag)(model),
|
|
25
|
+
tenant: model.tenant || getTenant().id,
|
|
26
|
+
locale: model.locale || getLocale().code,
|
|
27
|
+
/**
|
|
28
|
+
* TODO: remove in v5.36.0
|
|
29
|
+
* This is for backward compatibility while migrations are not yet executed.
|
|
30
|
+
*/
|
|
31
|
+
singularApiName: (0, _modelApiName.ensureSingularApiName)(model),
|
|
32
|
+
pluralApiName: (0, _modelApiName.ensurePluralApiName)(model)
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.listModelsFromDatabase = listModelsFromDatabase;
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=listModelsFromDatabase.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_modelApiName","require","_ensureTypeTag","listModelsFromDatabase","params","storageOperations","getTenant","getLocale","models","list","where","tenant","id","locale","code","map","model","tags","ensureTypeTag","singularApiName","ensureSingularApiName","pluralApiName","ensurePluralApiName","exports"],"sources":["listModelsFromDatabase.ts"],"sourcesContent":["import { CmsModel, HeadlessCmsStorageOperations } from \"~/types\";\nimport {\n ensurePluralApiName,\n ensureSingularApiName\n} from \"~/crud/contentModel/compatibility/modelApiName\";\nimport { Tenant } from \"@webiny/api-tenancy/types\";\nimport { I18NLocale } from \"@webiny/api-i18n/types\";\nimport { ensureTypeTag } from \"./ensureTypeTag\";\n\ninterface Params {\n storageOperations: HeadlessCmsStorageOperations;\n getTenant: () => Tenant;\n getLocale: () => I18NLocale;\n}\n\nexport const listModelsFromDatabase = async (params: Params): Promise<CmsModel[]> => {\n const { storageOperations, getTenant, getLocale } = params;\n const models = await storageOperations.models.list({\n where: {\n tenant: getTenant().id,\n locale: getLocale().code\n }\n });\n return models.map(model => {\n return {\n ...model,\n tags: ensureTypeTag(model),\n tenant: model.tenant || getTenant().id,\n locale: model.locale || getLocale().code,\n /**\n * TODO: remove in v5.36.0\n * This is for backward compatibility while migrations are not yet executed.\n */\n singularApiName: ensureSingularApiName(model),\n pluralApiName: ensurePluralApiName(model)\n };\n });\n};\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAMA,IAAAC,cAAA,GAAAD,OAAA;AAQO,MAAME,sBAAsB,GAAG,MAAOC,MAAc,IAA0B;EACjF,MAAM;IAAEC,iBAAiB;IAAEC,SAAS;IAAEC;EAAU,CAAC,GAAGH,MAAM;EAC1D,MAAMI,MAAM,GAAG,MAAMH,iBAAiB,CAACG,MAAM,CAACC,IAAI,CAAC;IAC/CC,KAAK,EAAE;MACHC,MAAM,EAAEL,SAAS,CAAC,CAAC,CAACM,EAAE;MACtBC,MAAM,EAAEN,SAAS,CAAC,CAAC,CAACO;IACxB;EACJ,CAAC,CAAC;EACF,OAAON,MAAM,CAACO,GAAG,CAACC,KAAK,IAAI;IACvB,OAAO;MACH,GAAGA,KAAK;MACRC,IAAI,EAAE,IAAAC,4BAAa,EAACF,KAAK,CAAC;MAC1BL,MAAM,EAAEK,KAAK,CAACL,MAAM,IAAIL,SAAS,CAAC,CAAC,CAACM,EAAE;MACtCC,MAAM,EAAEG,KAAK,CAACH,MAAM,IAAIN,SAAS,CAAC,CAAC,CAACO,IAAI;MACxC;AACZ;AACA;AACA;MACYK,eAAe,EAAE,IAAAC,mCAAqB,EAACJ,KAAK,CAAC;MAC7CK,aAAa,EAAE,IAAAC,iCAAmB,EAACN,KAAK;IAC5C,CAAC;EACL,CAAC,CAAC;AACN,CAAC;AAACO,OAAA,CAAApB,sBAAA,GAAAA,sBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["validateEndingAllowed","params","model","isModelEndingAllowed","singularApiName","WebinyError","input","disallowedEnding","pluralApiName"],"sources":["endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AACA;AAOO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_isModelEndingAllowed","validateEndingAllowed","params","model","isModelEndingAllowed","singularApiName","WebinyError","input","disallowedEnding","pluralApiName","exports"],"sources":["endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateEndingAllowed = (params: Params): void => {\n const { model } = params;\n if (isModelEndingAllowed(model.singularApiName) === false) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_SINGULAR_API_NAME_ENDING_NOT_ALLOWED\",\n {\n input: model.singularApiName,\n disallowedEnding\n }\n );\n } else if (isModelEndingAllowed(model.pluralApiName) === false) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" is not allowed, as it ends in disallowed value.`,\n \"MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED\",\n {\n input: model.pluralApiName,\n disallowedEnding: disallowedEnding\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AAOO,MAAME,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAI,IAAAE,0CAAoB,EAACD,KAAK,CAACE,eAAe,CAAC,KAAK,KAAK,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,eAAgB,mDAAkD,EAC/G,4CAA4C,EAC5C;MACIE,KAAK,EAAEJ,KAAK,CAACE,eAAe;MAC5BG,gBAAgB,EAAhBA;IACJ,CACJ,CAAC;EACL,CAAC,MAAM,IAAI,IAAAJ,0CAAoB,EAACD,KAAK,CAACM,aAAa,CAAC,KAAK,KAAK,EAAE;IAC5D,MAAM,IAAIH,cAAW,CAChB,qCAAoCH,KAAK,CAACM,aAAc,mDAAkD,EAC3G,0CAA0C,EAC1C;MACIF,KAAK,EAAEJ,KAAK,CAACM,aAAa;MAC1BD,gBAAgB,EAAEA;IACtB,CACJ,CAAC;EACL;AACJ,CAAC;AAACE,OAAA,CAAAT,qBAAA,GAAAA,qBAAA"}
|
|
@@ -12,7 +12,7 @@ const disallowedEnding = ["Response", "List", "Meta", "Input", "Sorter", "RefTyp
|
|
|
12
12
|
exports.disallowedEnding = disallowedEnding;
|
|
13
13
|
const isModelEndingAllowed = apiName => {
|
|
14
14
|
for (const ending of disallowedEnding) {
|
|
15
|
-
const re = new RegExp(`${ending}
|
|
15
|
+
const re = new RegExp(`${ending}$`);
|
|
16
16
|
const matched = apiName.match(re);
|
|
17
17
|
if (matched === null) {
|
|
18
18
|
continue;
|
|
@@ -21,4 +21,6 @@ const isModelEndingAllowed = apiName => {
|
|
|
21
21
|
}
|
|
22
22
|
return true;
|
|
23
23
|
};
|
|
24
|
-
exports.isModelEndingAllowed = isModelEndingAllowed;
|
|
24
|
+
exports.isModelEndingAllowed = isModelEndingAllowed;
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=isModelEndingAllowed.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["disallowedEnding","isModelEndingAllowed","apiName","ending","re","RegExp","matched","match"],"sources":["isModelEndingAllowed.ts"],"sourcesContent":["/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nexport const disallowedEnding: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\nexport const isModelEndingAllowed = (apiName: string): boolean => {\n for (const ending of disallowedEnding) {\n const re = new RegExp(`${ending}
|
|
1
|
+
{"version":3,"names":["disallowedEnding","exports","isModelEndingAllowed","apiName","ending","re","RegExp","matched","match"],"sources":["isModelEndingAllowed.ts"],"sourcesContent":["/**\n * This list is to disallow creating models that might interfere with GraphQL schema creation.\n * Add more if required.\n */\nexport const disallowedEnding: string[] = [\n \"Response\",\n \"List\",\n \"Meta\",\n \"Input\",\n \"Sorter\",\n \"RefType\"\n];\n\nexport const isModelEndingAllowed = (apiName: string): boolean => {\n for (const ending of disallowedEnding) {\n const re = new RegExp(`${ending}$`);\n const matched = apiName.match(re);\n if (matched === null) {\n continue;\n }\n return false;\n }\n return true;\n};\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACO,MAAMA,gBAA0B,GAAG,CACtC,UAAU,EACV,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,SAAS,CACZ;AAACC,OAAA,CAAAD,gBAAA,GAAAA,gBAAA;AAEK,MAAME,oBAAoB,GAAIC,OAAe,IAAc;EAC9D,KAAK,MAAMC,MAAM,IAAIJ,gBAAgB,EAAE;IACnC,MAAMK,EAAE,GAAG,IAAIC,MAAM,CAAE,GAAEF,MAAO,GAAE,CAAC;IACnC,MAAMG,OAAO,GAAGJ,OAAO,CAACK,KAAK,CAACH,EAAE,CAAC;IACjC,IAAIE,OAAO,KAAK,IAAI,EAAE;MAClB;IACJ;IACA,OAAO,KAAK;EAChB;EACA,OAAO,IAAI;AACf,CAAC;AAACN,OAAA,CAAAC,oBAAA,GAAAA,oBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["disallowedModelIdList","isModelIdAllowed","modelId","includes","validateModelIdAllowed","params","model","WebinyError","input","validateExistingModelId","existingModel"],"sources":["modelId.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\nconst isModelIdAllowed = (modelId: string): boolean => {\n return disallowedModelIdList.includes(modelId) === false;\n};\n\ninterface ModelIdAllowedParams {\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateModelIdAllowed = (params: ModelIdAllowedParams) => {\n const { model } = params;\n if (isModelIdAllowed(model.modelId)) {\n return;\n }\n throw new WebinyError(\n `Provided model ID \"${model.modelId}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n input: model.modelId\n }\n );\n};\n\ninterface Params {\n existingModel: Pick<CmsModel, \"modelId\">;\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateExistingModelId = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.modelId === model.modelId) {\n throw new WebinyError(\n `Content model with modelId \"${model.modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n input: existingModel.modelId\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAGA,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","disallowedModelIdList","isModelIdAllowed","modelId","includes","validateModelIdAllowed","params","model","WebinyError","input","exports","validateExistingModelId","existingModel"],"sources":["modelId.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\nconst disallowedModelIdList: string[] = [\n \"contentModel\",\n \"contentModels\",\n \"contentModelGroup\",\n \"contentModelGroups\"\n];\nconst isModelIdAllowed = (modelId: string): boolean => {\n return disallowedModelIdList.includes(modelId) === false;\n};\n\ninterface ModelIdAllowedParams {\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateModelIdAllowed = (params: ModelIdAllowedParams) => {\n const { model } = params;\n if (isModelIdAllowed(model.modelId)) {\n return;\n }\n throw new WebinyError(\n `Provided model ID \"${model.modelId}\" is not allowed.`,\n \"MODEL_ID_NOT_ALLOWED\",\n {\n input: model.modelId\n }\n );\n};\n\ninterface Params {\n existingModel: Pick<CmsModel, \"modelId\">;\n model: Pick<CmsModel, \"modelId\">;\n}\n\nexport const validateExistingModelId = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.modelId === model.modelId) {\n throw new WebinyError(\n `Content model with modelId \"${model.modelId}\" already exists.`,\n \"MODEL_ID_EXISTS\",\n {\n input: existingModel.modelId\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAGA,MAAMC,qBAA+B,GAAG,CACpC,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,oBAAoB,CACvB;AACD,MAAMC,gBAAgB,GAAIC,OAAe,IAAc;EACnD,OAAOF,qBAAqB,CAACG,QAAQ,CAACD,OAAO,CAAC,KAAK,KAAK;AAC5D,CAAC;AAMM,MAAME,sBAAsB,GAAIC,MAA4B,IAAK;EACpE,MAAM;IAAEC;EAAM,CAAC,GAAGD,MAAM;EACxB,IAAIJ,gBAAgB,CAACK,KAAK,CAACJ,OAAO,CAAC,EAAE;IACjC;EACJ;EACA,MAAM,IAAIK,cAAW,CAChB,sBAAqBD,KAAK,CAACJ,OAAQ,mBAAkB,EACtD,sBAAsB,EACtB;IACIM,KAAK,EAAEF,KAAK,CAACJ;EACjB,CACJ,CAAC;AACL,CAAC;AAACO,OAAA,CAAAL,sBAAA,GAAAA,sBAAA;AAOK,MAAMM,uBAAuB,GAAIL,MAAc,IAAW;EAC7D,MAAM;IAAEM,aAAa;IAAEL;EAAM,CAAC,GAAGD,MAAM;EAEvC,IAAIM,aAAa,CAACT,OAAO,KAAKI,KAAK,CAACJ,OAAO,EAAE;IACzC,MAAM,IAAIK,cAAW,CAChB,+BAA8BD,KAAK,CAACJ,OAAQ,mBAAkB,EAC/D,iBAAiB,EACjB;MACIM,KAAK,EAAEG,aAAa,CAACT;IACzB,CACJ,CAAC;EACL;AACJ,CAAC;AAACO,OAAA,CAAAC,uBAAA,GAAAA,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["validatePluralApiName","params","existingModel","model","singularApiName","pluralApiName","WebinyError","input"],"sources":["pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","validatePluralApiName","params","existingModel","model","singularApiName","pluralApiName","WebinyError","input","exports"],"sources":["pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validatePluralApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n } else if (existingModel.pluralApiName === model.pluralApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.pluralApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.pluralApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQO,MAAMC,qBAAqB,GAAIC,MAAc,IAAW;EAC3D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACE,aAAa,EAAE;IACvD,MAAM,IAAIC,cAAW,CAChB,uCAAsCH,KAAK,CAACE,aAAc,mBAAkB,EAC7E,gCAAgC,EAChC;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CACJ,CAAC;EACL,CAAC,MAAM,IAAIH,aAAa,CAACG,aAAa,KAAKF,KAAK,CAACE,aAAa,EAAE;IAC5D,MAAM,IAAIC,cAAW,CAChB,qCAAoCH,KAAK,CAACE,aAAc,mBAAkB,EAC3E,8BAA8B,EAC9B;MACIE,KAAK,EAAEJ,KAAK,CAACE;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAACG,OAAA,CAAAR,qBAAA,GAAAA,qBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["validateSingularApiName","params","existingModel","model","singularApiName","WebinyError","input","pluralApiName"],"sources":["singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA;AAQO,
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","validateSingularApiName","params","existingModel","model","singularApiName","WebinyError","input","pluralApiName","exports"],"sources":["singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModel } from \"~/types\";\n\ninterface Params {\n existingModel: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n model: Pick<CmsModel, \"singularApiName\" | \"pluralApiName\">;\n}\n\nexport const validateSingularApiName = (params: Params): void => {\n const { existingModel, model } = params;\n\n if (existingModel.singularApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with singularApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_SINGULAR_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n } else if (existingModel.pluralApiName === model.singularApiName) {\n throw new WebinyError(\n `Content model with pluralApiName \"${model.singularApiName}\" already exists.`,\n \"MODEL_PLURAL_API_NAME_EXISTS\",\n {\n input: model.singularApiName\n }\n );\n }\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAQO,MAAMC,uBAAuB,GAAIC,MAAc,IAAW;EAC7D,MAAM;IAAEC,aAAa;IAAEC;EAAM,CAAC,GAAGF,MAAM;EAEvC,IAAIC,aAAa,CAACE,eAAe,KAAKD,KAAK,CAACC,eAAe,EAAE;IACzD,MAAM,IAAIC,cAAW,CAChB,uCAAsCF,KAAK,CAACC,eAAgB,mBAAkB,EAC/E,gCAAgC,EAChC;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CACJ,CAAC;EACL,CAAC,MAAM,IAAIF,aAAa,CAACK,aAAa,KAAKJ,KAAK,CAACC,eAAe,EAAE;IAC9D,MAAM,IAAIC,cAAW,CAChB,qCAAoCF,KAAK,CAACC,eAAgB,mBAAkB,EAC7E,8BAA8B,EAC9B;MACIE,KAAK,EAAEH,KAAK,CAACC;IACjB,CACJ,CAAC;EACL;AACJ,CAAC;AAACI,OAAA,CAAAR,uBAAA,GAAAA,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"
|
|
1
|
+
{"version":3,"names":["_error","_interopRequireDefault","require","_CmsModelPlugin","_validateModelFields","validateModel","params","model","context","plugins","modelPlugin","byType","CmsModelPlugin","type","find","item","contentModel","modelId","WebinyError","validateModelFields","exports"],"sources":["validateModel.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { CmsModelPlugin } from \"~/plugins/CmsModelPlugin\";\nimport { CmsContext, CmsModel } from \"~/types\";\nimport { validateModelFields } from \"./validateModelFields\";\n\ninterface ValidateModelParams {\n models: CmsModel[];\n model: CmsModel;\n original?: CmsModel;\n context: CmsContext;\n}\n\nexport const validateModel = async (params: ValidateModelParams): Promise<void> => {\n const { model, context } = params;\n\n const { plugins } = context;\n\n const modelPlugin = plugins\n .byType<CmsModelPlugin>(CmsModelPlugin.type)\n .find(item => item.contentModel.modelId === model.modelId);\n\n if (modelPlugin) {\n throw new WebinyError(\n \"Content models defined via plugins cannot be updated.\",\n \"CONTENT_MODEL_UPDATE_ERROR\",\n {\n modelId: model.modelId\n }\n );\n }\n\n await validateModelFields(params);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA,IAAAE,oBAAA,GAAAF,OAAA;AASO,MAAMG,aAAa,GAAG,MAAOC,MAA2B,IAAoB;EAC/E,MAAM;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAGF,MAAM;EAEjC,MAAM;IAAEG;EAAQ,CAAC,GAAGD,OAAO;EAE3B,MAAME,WAAW,GAAGD,OAAO,CACtBE,MAAM,CAAiBC,8BAAc,CAACC,IAAI,CAAC,CAC3CC,IAAI,CAACC,IAAI,IAAIA,IAAI,CAACC,YAAY,CAACC,OAAO,KAAKV,KAAK,CAACU,OAAO,CAAC;EAE9D,IAAIP,WAAW,EAAE;IACb,MAAM,IAAIQ,cAAW,CACjB,uDAAuD,EACvD,4BAA4B,EAC5B;MACID,OAAO,EAAEV,KAAK,CAACU;IACnB,CACJ,CAAC;EACL;EAEA,MAAM,IAAAE,wCAAmB,EAACb,MAAM,CAAC;AACrC,CAAC;AAACc,OAAA,CAAAf,aAAA,GAAAA,aAAA"}
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.validateModelFields = void 0;
|
|
8
|
-
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
9
8
|
var _graphqlTag = _interopRequireDefault(require("graphql-tag"));
|
|
10
9
|
var _error = _interopRequireDefault(require("@webiny/error"));
|
|
11
10
|
var _createManageSDL = require("../../graphql/schema/createManageSDL");
|
|
@@ -19,8 +18,7 @@ var _buildSchemaPlugins = require("../../graphql/buildSchemaPlugins");
|
|
|
19
18
|
var _createExecutableSchema = require("../../graphql/createExecutableSchema");
|
|
20
19
|
var _utils = require("@webiny/utils");
|
|
21
20
|
const extractInvalidField = (model, err) => {
|
|
22
|
-
|
|
23
|
-
const sdl = ((_err$source = err.source) === null || _err$source === void 0 ? void 0 : _err$source.body) || "";
|
|
21
|
+
const sdl = err.source?.body || "";
|
|
24
22
|
|
|
25
23
|
/**
|
|
26
24
|
* Find the invalid type
|
|
@@ -249,7 +247,7 @@ const validateModelFields = async params => {
|
|
|
249
247
|
const fieldTypePlugins = plugins.byType("cms-model-field-to-graphql");
|
|
250
248
|
validateFields({
|
|
251
249
|
fields,
|
|
252
|
-
originalFields:
|
|
250
|
+
originalFields: original?.fields || [],
|
|
253
251
|
lockedFields,
|
|
254
252
|
plugins: fieldTypePlugins
|
|
255
253
|
});
|
|
@@ -261,7 +259,8 @@ const validateModelFields = async params => {
|
|
|
261
259
|
const schema = (0, _createManageSDL.createManageSDL)({
|
|
262
260
|
models,
|
|
263
261
|
model,
|
|
264
|
-
fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => (
|
|
262
|
+
fieldTypePlugins: fieldTypePlugins.reduce((acc, pl) => ({
|
|
263
|
+
...acc,
|
|
265
264
|
[pl.fieldType]: pl
|
|
266
265
|
}), {}),
|
|
267
266
|
sorterPlugins
|
|
@@ -309,7 +308,7 @@ const validateModelFields = async params => {
|
|
|
309
308
|
if (!existingField) {
|
|
310
309
|
continue;
|
|
311
310
|
}
|
|
312
|
-
if (lockedField.multipleValues !== existingField.multipleValues) {
|
|
311
|
+
if (Boolean(lockedField.multipleValues) !== Boolean(existingField.multipleValues)) {
|
|
313
312
|
throw new _error.default(`Cannot change "multipleValues" for the "${lockedField.fieldId}" field because it's already in use in created content.`, "ENTRY_FIELD_USED", {
|
|
314
313
|
reason: `"multipleValues" changed`,
|
|
315
314
|
field: existingField
|
|
@@ -339,4 +338,6 @@ const validateModelFields = async params => {
|
|
|
339
338
|
}
|
|
340
339
|
}
|
|
341
340
|
};
|
|
342
|
-
exports.validateModelFields = validateModelFields;
|
|
341
|
+
exports.validateModelFields = validateModelFields;
|
|
342
|
+
|
|
343
|
+
//# sourceMappingURL=validateModelFields.js.map
|