@webiny/api-headless-cms 6.4.12-beta.4 → 6.5.0-beta.0
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/crud/contentEntry/entryDataValidation.d.ts +1 -1
- package/crud/contentEntry/entryDataValidation.js +33 -18
- package/crud/contentEntry/entryDataValidation.js.map +1 -1
- package/crud/contentEntry.crud.js +12 -39
- package/crud/contentEntry.crud.js.map +1 -1
- package/crud/contentModel/defaultFields.js +3 -2
- package/crud/contentModel/defaultFields.js.map +1 -1
- package/crud/contentModel/validate/endingAllowed.js +1 -1
- package/crud/contentModel/validate/endingAllowed.js.map +1 -1
- package/crud/contentModel/validate/pluralApiName.js +1 -1
- package/crud/contentModel/validate/pluralApiName.js.map +1 -1
- package/crud/contentModel/validate/singularApiName.js +1 -1
- package/crud/contentModel/validate/singularApiName.js.map +1 -1
- package/crud/contentModel/validation.js +2 -2
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentModel/schemas.d.ts +4 -0
- package/domain/contentModel/schemas.js +5 -2
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModel/validation/endingAllowed.js +1 -1
- package/domain/contentModel/validation/endingAllowed.js.map +1 -1
- package/domain/contentModel/validation/pluralApiName.js +1 -1
- package/domain/contentModel/validation/pluralApiName.js.map +1 -1
- package/domain/contentModel/validation/singularApiName.js +1 -1
- package/domain/contentModel/validation/singularApiName.js.map +1 -1
- package/export/crud/exporting.js +2 -2
- package/export/crud/exporting.js.map +1 -1
- package/export/crud/imports/importGroups.js +2 -1
- package/export/crud/imports/importGroups.js.map +1 -1
- package/export/crud/imports/validateModels.js +1 -1
- package/export/crud/imports/validateModels.js.map +1 -1
- package/exports/api/cms/model.d.ts +4 -1
- package/exports/api/cms/model.js +2 -0
- package/extension.d.ts +3 -0
- package/extension.js +19 -0
- package/extension.js.map +1 -0
- package/features/contentEntry/ContentEntriesFeature.js +2 -0
- package/features/contentEntry/ContentEntriesFeature.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +1 -2
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js +1 -0
- package/features/contentEntry/DeleteEntryRevision/DeleteEntryRevisionRepository.js.map +1 -1
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js +1 -3
- package/features/contentEntry/GetSingletonEntry/GetSingletonEntryUseCase.js.map +1 -1
- package/features/contentEntry/PublishEntry/PublishEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.d.ts +14 -0
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js +34 -0
- package/features/contentEntry/UpdateRevision/UpdateRevisionRepository.js.map +1 -0
- package/features/contentEntry/UpdateRevision/abstractions.d.ts +10 -0
- package/features/contentEntry/UpdateRevision/abstractions.js +5 -0
- package/features/contentEntry/UpdateRevision/abstractions.js.map +1 -0
- package/features/contentEntry/UpdateRevision/feature.d.ts +4 -0
- package/features/contentEntry/UpdateRevision/feature.js +11 -0
- package/features/contentEntry/UpdateRevision/feature.js.map +1 -0
- package/features/contentEntry/UpdateRevision/index.d.ts +1 -0
- package/features/contentEntry/UpdateRevision/index.js +1 -0
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.d.ts +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js +2 -2
- package/features/contentEntry/UpdateRevisionDescription/UpdateRevisionDescriptionUseCase.js.map +1 -1
- package/features/contentEntry/ensureItemIds.d.ts +13 -0
- package/features/contentEntry/ensureItemIds.js +22 -0
- package/features/contentEntry/ensureItemIds.js.map +1 -0
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js +9 -3
- package/features/contentEntry/entryDataFactories/CreateEntryDataFactory/CreateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.d.ts +3 -3
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +10 -6
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +3 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +9 -3
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/expiresAt.js +2 -2
- package/features/contentEntry/entryDataFactories/expiresAt.js.map +1 -1
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.d.ts +14 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js +32 -0
- package/features/contentModel/ComponentMapGenerator/ComponentMapGenerator.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js +5 -0
- package/features/contentModel/ComponentMapGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/feature.d.ts +4 -0
- package/features/contentModel/ComponentMapGenerator/feature.js +11 -0
- package/features/contentModel/ComponentMapGenerator/feature.js.map +1 -0
- package/features/contentModel/ComponentMapGenerator/index.d.ts +2 -0
- package/features/contentModel/ComponentMapGenerator/index.js +2 -0
- package/features/contentModel/ContentModelFeature.js +6 -0
- package/features/contentModel/ContentModelFeature.js.map +1 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js +2 -1
- package/features/contentModel/CreateModel/CreateModelRepository.js.map +1 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js +2 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromRepository.js.map +1 -1
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.d.ts +19 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +56 -0
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/abstractions.d.ts +11 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js +5 -0
- package/features/contentModel/RefModelsGenerator/abstractions.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/feature.d.ts +4 -0
- package/features/contentModel/RefModelsGenerator/feature.js +11 -0
- package/features/contentModel/RefModelsGenerator/feature.js.map +1 -0
- package/features/contentModel/RefModelsGenerator/index.d.ts +2 -0
- package/features/contentModel/RefModelsGenerator/index.js +2 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.d.ts +16 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js +54 -0
- package/features/contentModel/ValuesSelectionGenerator/ValuesSelectionGenerator.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.d.ts +8 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js +5 -0
- package/features/contentModel/ValuesSelectionGenerator/abstractions.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.d.ts +4 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js +11 -0
- package/features/contentModel/ValuesSelectionGenerator/feature.js.map +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.d.ts +1 -0
- package/features/contentModel/ValuesSelectionGenerator/index.js +1 -0
- package/features/graphql/feature.js +2 -0
- package/features/graphql/feature.js.map +1 -1
- package/features/graphql/fields/base/AssetToGraphQL.d.ts +26 -0
- package/features/graphql/fields/base/AssetToGraphQL.js +148 -0
- package/features/graphql/fields/base/AssetToGraphQL.js.map +1 -0
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js +12 -2
- package/features/graphql/fields/base/DynamicZoneToGraphQL.js.map +1 -1
- package/features/graphql/fields/base/ObjectToGraphQL.js +8 -5
- package/features/graphql/fields/base/ObjectToGraphQL.js.map +1 -1
- package/features/modelBuilder/abstractions.d.ts +9 -0
- package/features/modelBuilder/abstractions.js.map +1 -1
- package/features/modelBuilder/feature.js +2 -0
- package/features/modelBuilder/feature.js.map +1 -1
- package/features/modelBuilder/fields/AssetFieldType.d.ts +20 -0
- package/features/modelBuilder/fields/AssetFieldType.js +46 -0
- package/features/modelBuilder/fields/AssetFieldType.js.map +1 -0
- package/features/modelBuilder/fields/DataFieldBuilder.d.ts +62 -18
- package/features/modelBuilder/fields/DataFieldBuilder.js +8 -0
- package/features/modelBuilder/fields/DataFieldBuilder.js.map +1 -1
- package/features/modelBuilder/fields/DynamicZoneFieldType.d.ts +1 -0
- package/features/modelBuilder/fields/DynamicZoneFieldType.js +2 -6
- package/features/modelBuilder/fields/DynamicZoneFieldType.js.map +1 -1
- package/features/modelBuilder/fields/resolveAssetUrl.d.ts +35 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js +26 -0
- package/features/modelBuilder/fields/resolveAssetUrl.js.map +1 -0
- package/features/modelBuilder/index.d.ts +1 -1
- package/features/modelBuilder/models/BaseModelBuilder.d.ts +3 -1
- package/features/modelBuilder/models/BaseModelBuilder.js +7 -0
- package/features/modelBuilder/models/BaseModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js +2 -1
- package/features/modelBuilder/models/PrivateModelBuilder.js.map +1 -1
- package/features/modelBuilder/models/PublicModelBuilder.js +2 -1
- package/features/modelBuilder/models/PublicModelBuilder.js.map +1 -1
- package/features/sortMapper/SortMapper.js +2 -5
- package/features/sortMapper/SortMapper.js.map +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
- package/features/storage/fields/DateStorageTransform.js +4 -3
- package/features/storage/fields/DateStorageTransform.js.map +1 -1
- package/features/storage/fields/DynamicZoneStorageTransform.js +2 -2
- package/features/storage/fields/DynamicZoneStorageTransform.js.map +1 -1
- package/features/storage/fields/JsonStorageTransform.js +1 -1
- package/features/storage/fields/JsonStorageTransform.js.map +1 -1
- package/features/storage/fields/LongTextStorageTransform.js +1 -1
- package/features/storage/fields/LongTextStorageTransform.js.map +1 -1
- package/features/storage/fields/ObjectStorageTransform.js +27 -7
- package/features/storage/fields/ObjectStorageTransform.js.map +1 -1
- package/features/storage/fields/RichTextStorageTransform.js +1 -1
- package/features/storage/fields/RichTextStorageTransform.js.map +1 -1
- package/features/validation/validators/DateGteValidator.js +1 -1
- package/features/validation/validators/DateGteValidator.js.map +1 -1
- package/features/validation/validators/DateLteValidator.js +1 -1
- package/features/validation/validators/DateLteValidator.js.map +1 -1
- package/features/validation/validators/PatternValidator.js +1 -1
- package/features/validation/validators/PatternValidator.js.map +1 -1
- package/features/whereMapper/WhereMapper.js +10 -7
- package/features/whereMapper/WhereMapper.js.map +1 -1
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js +8 -2
- package/fieldConverters/CmsModelDynamicZoneFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js +8 -2
- package/fieldConverters/CmsModelObjectFieldConverterPlugin.js.map +1 -1
- package/fieldConverters/index.d.ts +1 -1
- package/graphql/getSchema/generateCacheKey.js +1 -1
- package/graphql/getSchema/generateCacheKey.js.map +1 -1
- package/graphql/scalars/RevisionId.js +1 -1
- package/graphql/scalars/RevisionId.js.map +1 -1
- package/graphql/schema/baseSchema.js +5 -25
- package/graphql/schema/baseSchema.js.map +1 -1
- package/graphql/schema/cms/getEntryResolver.js +3 -2
- package/graphql/schema/cms/getEntryResolver.js.map +1 -1
- package/graphql/schema/cms/getModelResolver.d.ts +35 -0
- package/graphql/schema/cms/getModelResolver.js +49 -0
- package/graphql/schema/cms/getModelResolver.js.map +1 -0
- package/graphql/schema/cms/helpers/buildFieldsSelection.js +9 -2
- package/graphql/schema/cms/helpers/buildFieldsSelection.js.map +1 -1
- package/graphql/schema/cms/helpers/expandFieldWildcards.d.ts +2 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js +13 -0
- package/graphql/schema/cms/helpers/expandFieldWildcards.js.map +1 -0
- package/graphql/schema/cms/helpers/index.d.ts +1 -0
- package/graphql/schema/cms/helpers/index.js +1 -0
- package/graphql/schema/cms/helpers.d.ts +1 -0
- package/graphql/schema/cms/helpers.js +1 -0
- package/graphql/schema/cms/index.js +2 -1
- package/graphql/schema/cms/index.js.map +1 -1
- package/graphql/schema/cms/listEntriesResolver.js +3 -2
- package/graphql/schema/cms/listEntriesResolver.js.map +1 -1
- package/graphql/schema/cms/resolvers/getModel.d.ts +8 -0
- package/graphql/schema/cms/resolvers/getModel.js +18 -0
- package/graphql/schema/cms/resolvers/getModel.js.map +1 -0
- package/graphql/schema/cms/resolvers/index.d.ts +1 -0
- package/graphql/schema/cms/resolvers/index.js +1 -0
- package/graphql/schema/cms/typeDefs/query.js +1 -0
- package/graphql/schema/cms/typeDefs/query.js.map +1 -1
- package/graphql/schema/cms/typeDefs/responses.js +5 -0
- package/graphql/schema/cms/typeDefs/responses.js.map +1 -1
- package/graphql/schema/contentModels.js +40 -1
- package/graphql/schema/contentModels.js.map +1 -1
- package/graphql/schema/createFieldResolvers.js +1 -1
- package/graphql/schema/createFieldResolvers.js.map +1 -1
- package/index.d.ts +2 -5
- package/index.js +1 -21
- package/package.json +26 -29
- package/plugins/CmsModelPlugin.js +12 -10
- package/plugins/CmsModelPlugin.js.map +1 -1
- package/types/fields/dynamicZoneField.d.ts +1 -0
- package/types/model.d.ts +6 -0
- package/types/modelField.d.ts +13 -0
- package/types/types.d.ts +8 -4
- package/types/types.js.map +1 -1
- package/utils/caching/Cache.js +1 -1
- package/utils/caching/Cache.js.map +1 -1
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.d.ts +28 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js +324 -0
- package/utils/contentModelToJsonSchema/CmsModelToJsonSchemaConverter.js.map +1 -0
- package/utils/contentModelToJsonSchema/index.d.ts +2 -0
- package/utils/contentModelToJsonSchema/index.js +1 -0
- package/utils/contentModelToJsonSchema/types.d.ts +24 -0
- package/utils/contentModelToJsonSchema/types.js +0 -0
- package/utils/createModelField.js +2 -1
- package/utils/createModelField.js.map +1 -1
- package/utils/date.js +1 -1
- package/utils/date.js.map +1 -1
- package/utils/entryStorage.js +1 -1
- package/utils/entryStorage.js.map +1 -1
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/renderFields.js +1 -1
- package/utils/renderFields.js.map +1 -1
- package/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud/contentModel/validate/singularApiName.js","sources":["../../../../src/crud/contentModel/validate/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;
|
|
1
|
+
{"version":3,"file":"crud/contentModel/validate/singularApiName.js","sources":["../../../../src/crud/contentModel/validate/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,eAAe,EAC5D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC7E,gCACA;QACI,OAAOA,MAAM,eAAe;IAChC;AAGZ"}
|
|
@@ -114,13 +114,13 @@ const refinementPluralValidationMessage = (value)=>({
|
|
|
114
114
|
});
|
|
115
115
|
const refinementModelIdValidation = (value)=>{
|
|
116
116
|
if (!value) return true;
|
|
117
|
-
|
|
117
|
+
if (null === value.match(/^[a-zA-Z]/)) return false;
|
|
118
118
|
const camelCasedValue = camelCase(value).toLowerCase();
|
|
119
119
|
return camelCasedValue === value.toLowerCase();
|
|
120
120
|
};
|
|
121
121
|
const refinementModelIdValidationMessage = (value)=>{
|
|
122
122
|
if (!value) return {};
|
|
123
|
-
|
|
123
|
+
if (null === value.match(/^[a-zA-Z]/)) return {
|
|
124
124
|
message: `The modelId "${value}" is not valid. It must start with a A-Z or a-z.`
|
|
125
125
|
};
|
|
126
126
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crud/contentModel/validation.js","sources":["../../../src/crud/contentModel/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst fieldSystemFields: string[] = [\n \"id\",\n \"entryId\",\n \"createdOn\",\n \"modifiedOn\",\n \"publishedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\",\n \"meta\",\n \"wbyAco_location\"\n];\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str.max(255);\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Provided value is not valid - must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Provided value is not valid - must be alphanumeric string.`\n })\n .superRefine((value, ctx) => {\n if (fieldSystemFields.includes(value)) {\n return ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `Field ID \"${value}\" is a reserved keyword, and is not allowed.`\n });\n }\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refinementModelIdValidation = (value?: string) => {\n if (!value) {\n return true;\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return false;\n }\n const camelCasedValue = camelCase(value).toLowerCase();\n return camelCasedValue === value.toLowerCase();\n};\nconst refinementModelIdValidationMessage = (value?: string) => {\n if (!value) {\n return {};\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return {\n message: `The modelId \"${value}\" is not valid. It must start with a A-Z or a-z.`\n };\n }\n return {\n message: `The modelId \"${value}\" is not valid.`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst refineModelId = (value: string, ctx: zod.RefinementCtx) => {\n if (!refinementModelIdValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementModelIdValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish()\n });\n};\n\nexport const createModelImportValidation = () => {\n return zod.object({\n name: shortString.min(1).superRefine((value, ctx) => {\n if (value.match(/[a-zA-Z]/) === null) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `The name \"${value}\" is not valid.`\n });\n }\n }),\n modelId: shortString.min(1).superRefine(refineModelId).transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).min(1),\n layout: zod.array(zod.array(zod.any())),\n tags: zod.array(shortString).optional(),\n titleFieldId: shortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional()\n });\n};\n"],"names":["fieldSystemFields","str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","ctx","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refinementModelIdValidation","camelCasedValue","refinementModelIdValidationMessage","refineSingularApiName","refinePluralApiName","refineModelId","modelIdTransformation","createModelCreateValidation","createModelImportValidation","createModelCreateFromValidation","createModelUpdateValidation"],"mappings":";;;AAIA,MAAMA,oBAA8B;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH,IAAI,GAAG,CAAC;AAC3B,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IACh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GG,MAAMuB,kCAAkC,IACpC1B,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACoB;QACvC,iBAAiBtB,YAAY,WAAW,CAACmB;QACzC,eAAenB,YAAY,WAAW,CAACoB;QACvC,aAAahB;QACb,OAAOJ;QACPM,MAAAA;IACJ;AAGG,MAAMoB,8BAA8B,IAChC3B,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACrD,IAAIF,OACAY,sBAAsBZ,OAAOE;QAErC;QACA,eAAeP,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACnD,IAAIF,OACAa,oBAAoBb,OAAOE;QAEnC;QACA,aAAaL;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC"}
|
|
1
|
+
{"version":3,"file":"crud/contentModel/validation.js","sources":["../../../src/crud/contentModel/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst fieldSystemFields: string[] = [\n \"id\",\n \"entryId\",\n \"createdOn\",\n \"modifiedOn\",\n \"publishedOn\",\n \"savedOn\",\n \"deletedOn\",\n \"restoredOn\",\n \"firstPublishedOn\",\n \"lastPublishedOn\",\n \"createdBy\",\n \"modifiedBy\",\n \"savedBy\",\n \"deletedBy\",\n \"restoredBy\",\n \"firstPublishedBy\",\n \"lastPublishedBy\",\n \"revisionCreatedOn\",\n \"revisionModifiedOn\",\n \"revisionSavedOn\",\n \"revisionDeletedOn\",\n \"revisionRestoredOn\",\n \"revisionFirstPublishedOn\",\n \"revisionLastPublishedOn\",\n \"revisionCreatedBy\",\n \"revisionModifiedBy\",\n \"revisionSavedBy\",\n \"revisionDeletedBy\",\n \"revisionRestoredBy\",\n \"revisionFirstPublishedBy\",\n \"revisionLastPublishedBy\",\n \"meta\",\n \"wbyAco_location\"\n];\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str.max(255);\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Provided value is not valid - must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Provided value is not valid - must be alphanumeric string.`\n })\n .superRefine((value, ctx) => {\n if (fieldSystemFields.includes(value)) {\n return ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `Field ID \"${value}\" is a reserved keyword, and is not allowed.`\n });\n }\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refinementModelIdValidation = (value?: string) => {\n if (!value) {\n return true;\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return false;\n }\n const camelCasedValue = camelCase(value).toLowerCase();\n return camelCasedValue === value.toLowerCase();\n};\nconst refinementModelIdValidationMessage = (value?: string) => {\n if (!value) {\n return {};\n } else if (value.match(/^[a-zA-Z]/) === null) {\n return {\n message: `The modelId \"${value}\" is not valid. It must start with a A-Z or a-z.`\n };\n }\n return {\n message: `The modelId \"${value}\" is not valid.`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst refineModelId = (value: string, ctx: zod.RefinementCtx) => {\n if (!refinementModelIdValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementModelIdValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish()\n });\n};\n\nexport const createModelImportValidation = () => {\n return zod.object({\n name: shortString.min(1).superRefine((value, ctx) => {\n if (value.match(/[a-zA-Z]/) === null) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n message: `The name \"${value}\" is not valid.`\n });\n }\n }),\n modelId: shortString.min(1).superRefine(refineModelId).transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).min(1),\n layout: zod.array(zod.array(zod.any())),\n tags: zod.array(shortString).optional(),\n titleFieldId: shortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional()\n });\n};\n"],"names":["fieldSystemFields","str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","ctx","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refinementModelIdValidation","camelCasedValue","refinementModelIdValidationMessage","refineSingularApiName","refinePluralApiName","refineModelId","modelIdTransformation","createModelCreateValidation","createModelImportValidation","createModelCreateFromValidation","createModelUpdateValidation"],"mappings":";;;AAIA,MAAMA,oBAA8B;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACH;AAED,MAAMC,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,M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,GAAG,WAAW,CAACoB;QAC9C,aAAahB;QACb,OAAOJ;QACPM,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS,aAAa,GAAG,CAAC;QACnC,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,MAAMA,IAAI,KAAK,CAACC,aAAa,QAAQ;QACrC,cAAcA,YAAY,OAAO;QACjC,oBAAoBE,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;IAC7C;AAGG,MAAMuB,kCAAkC,IACpC1B,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACoB;QACvC,iBAAiBtB,YAAY,WAAW,CAACmB;QACzC,eAAenB,YAAY,WAAW,CAACoB;QACvC,aAAahB;QACb,OAAOJ;QACPM,MAAAA;IACJ;AAGG,MAAMoB,8BAA8B,IAChC3B,IAAI,MAAM,CAAC;QACd,MAAMG;QACN,iBAAiBA,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACrD,IAAIF,OACAY,sBAAsBZ,OAAOE;QAErC;QACA,eAAeP,oBAAoB,WAAW,CAAC,CAACK,OAAOE;YACnD,IAAIF,OACAa,oBAAoBb,OAAOE;QAEnC;QACA,aAAaL;QACb,OAAOF;QACPI,MAAAA;QACA,QAAQP,IAAI,KAAK,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;IACzC"}
|
|
@@ -33,6 +33,7 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
|
|
|
33
33
|
type: zod.ZodString;
|
|
34
34
|
tags: zod.ZodDefault<zod.ZodOptional<zod.ZodArray<zod.ZodString>>>;
|
|
35
35
|
list: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
|
|
36
|
+
disabled: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
|
|
36
37
|
predefinedValues: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodDefault<zod.ZodObject<{
|
|
37
38
|
enabled: zod.ZodBoolean;
|
|
38
39
|
values: zod.ZodDefault<zod.ZodArray<zod.ZodObject<{
|
|
@@ -135,6 +136,7 @@ export declare const createModelCreateValidation: () => zod.ZodObject<{
|
|
|
135
136
|
descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
136
137
|
imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
137
138
|
defaultFields: zod.ZodOptional<zod.ZodNullable<zod.ZodBoolean>>;
|
|
139
|
+
settings: zod.ZodDefault<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>>;
|
|
138
140
|
}, zod.core.$strip>;
|
|
139
141
|
export declare const createModelUpdateValidation: () => zod.ZodObject<{
|
|
140
142
|
name: zod.ZodOptional<zod.ZodString>;
|
|
@@ -169,6 +171,7 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
|
|
|
169
171
|
type: zod.ZodString;
|
|
170
172
|
tags: zod.ZodDefault<zod.ZodOptional<zod.ZodArray<zod.ZodString>>>;
|
|
171
173
|
list: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
|
|
174
|
+
disabled: zod.ZodDefault<zod.ZodPipe<zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodBoolean>>>, zod.ZodTransform<boolean, boolean | null | undefined>>>;
|
|
172
175
|
predefinedValues: zod.ZodPipe<zod.ZodOptional<zod.ZodOptional<zod.ZodNullable<zod.ZodDefault<zod.ZodObject<{
|
|
173
176
|
enabled: zod.ZodBoolean;
|
|
174
177
|
values: zod.ZodDefault<zod.ZodArray<zod.ZodObject<{
|
|
@@ -270,6 +273,7 @@ export declare const createModelUpdateValidation: () => zod.ZodObject<{
|
|
|
270
273
|
descriptionFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
271
274
|
imageFieldId: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodString>>>;
|
|
272
275
|
tags: zod.ZodOptional<zod.ZodArray<zod.ZodString>>;
|
|
276
|
+
settings: zod.ZodOptional<zod.ZodNullable<zod.ZodOptional<zod.ZodObject<{}, zod.core.$loose>>>>;
|
|
273
277
|
}, zod.core.$strip>;
|
|
274
278
|
export declare const createModelCreateFromValidation: () => zod.ZodObject<{
|
|
275
279
|
name: zod.ZodString;
|
|
@@ -35,6 +35,7 @@ const fieldSchema = zod.object({
|
|
|
35
35
|
type: shortString,
|
|
36
36
|
tags: zod.array(shortString).optional().default([]),
|
|
37
37
|
list: zod.boolean().optional().nullish().transform((value)=>!!value).default(false),
|
|
38
|
+
disabled: zod.boolean().optional().nullish().transform((value)=>!!value).default(false),
|
|
38
39
|
predefinedValues: zod.object({
|
|
39
40
|
enabled: zod.boolean(),
|
|
40
41
|
values: zod.array(zod.object({
|
|
@@ -119,7 +120,8 @@ const createModelCreateValidation = ()=>zod.object({
|
|
|
119
120
|
titleFieldId: optionalShortString.nullish(),
|
|
120
121
|
descriptionFieldId: optionalShortString.nullish(),
|
|
121
122
|
imageFieldId: optionalShortString.nullish(),
|
|
122
|
-
defaultFields: zod.boolean().nullish()
|
|
123
|
+
defaultFields: zod.boolean().nullish(),
|
|
124
|
+
settings: zod.looseObject({}).optional().nullish().default({})
|
|
123
125
|
});
|
|
124
126
|
const createModelUpdateValidation = ()=>zod.object({
|
|
125
127
|
name: optionalShortString,
|
|
@@ -137,7 +139,8 @@ const createModelUpdateValidation = ()=>zod.object({
|
|
|
137
139
|
titleFieldId: optionalShortString.nullish(),
|
|
138
140
|
descriptionFieldId: optionalShortString.nullish(),
|
|
139
141
|
imageFieldId: optionalShortString.nullish(),
|
|
140
|
-
tags: zod.array(shortString).optional()
|
|
142
|
+
tags: zod.array(shortString).optional(),
|
|
143
|
+
settings: zod.looseObject({}).optional().nullish()
|
|
141
144
|
});
|
|
142
145
|
const createModelCreateFromValidation = ()=>zod.object({
|
|
143
146
|
name: shortString,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"condition\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish()\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH;AACnB,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IAChB,OAAOA,IAAI,MAAM,GAAG,QAAQ;AAChC,GACC,QAAQ,GACR,OAAO,GACP,OAAO,CAAC,MACR,SAAS,CAACQ,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AAEJ,MAAMC,cAAcT,IAAI,MAAM,CAAC;IAC3B,IAAIC;IACJ,WAAWD,IAAAA,MACA,GACN,QAAQ,GACR,SAAS,CAAC,IACA;IAEf,SAASC,YACJ,GAAG,CAAC,KACJ,KAAK,CAAC,eAAe;QAClB,SAAS;IACb,GACC,KAAK,CAAC,qBAAqB;QACxB,SAAS;IACb;IACJ,OAAOA;IACP,MAAMK;IACN,aAAaD;IACb,MAAMA;IACN,aAAaA;IACb,MAAM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AAI,KAAK,CAACC,aAAa,QAAQ;IACzC;AAGG,MAAMsB,kCAAkC,IACpCvB,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACgB;QACvC,iBAAiBlB,YAAY,WAAW,CAACe;QACzC,eAAef,YAAY,WAAW,CAACiB;QACvC,aAAab;QACb,OAAOJ;QACPM,MAAAA;IACJ"}
|
|
1
|
+
{"version":3,"file":"domain/contentModel/schemas.js","sources":["../../../src/domain/contentModel/schemas.ts"],"sourcesContent":["import zod from \"zod\";\nimport upperFirst from \"lodash/upperFirst.js\";\nimport camelCase from \"lodash/camelCase.js\";\n\nconst str = zod.string().trim();\nconst shortString = str.max(255);\nconst longString = str;\nconst optionalShortString = shortString.optional();\nconst optionalLongString = longString.optional();\nconst optionalNullishShortString = optionalShortString.nullish().default(null);\nconst optionalNullishLongString = optionalLongString.nullish().default(null);\n\nconst icon = zod\n .looseObject({\n type: zod.string(),\n name: zod.string(),\n value: zod.string().optional()\n })\n .optional()\n .nullish()\n .default(null)\n .transform(value => {\n if (typeof value === \"string\") {\n return {\n type: \"icon\",\n name: value\n };\n }\n return value;\n });\n\nconst fieldSchema = zod.object({\n id: shortString,\n storageId: zod\n .string()\n .optional()\n .transform(() => {\n return \"\";\n }),\n fieldId: shortString\n .max(100)\n .regex(/^!?[a-zA-Z]/, {\n message: `Must not start with a number.`\n })\n .regex(/^(^[a-zA-Z0-9]+)$/, {\n message: `Must be alphanumeric string.`\n }),\n label: shortString,\n help: optionalNullishLongString,\n description: optionalNullishShortString,\n note: optionalNullishShortString,\n placeholder: optionalNullishShortString,\n type: shortString,\n tags: zod.array(shortString).optional().default([]),\n list: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n disabled: zod\n .boolean()\n .optional()\n .nullish()\n .transform(value => {\n return !!value;\n })\n .default(false),\n predefinedValues: zod\n .object({\n enabled: zod.boolean(),\n values: zod\n .array(\n zod.object({\n value: shortString,\n label: shortString,\n selected: zod.boolean().optional().default(false)\n })\n )\n .default([])\n })\n .default({\n enabled: false,\n values: []\n })\n .nullish()\n .optional()\n .transform(value => {\n return value || undefined;\n }),\n renderer: zod\n .object({\n name: shortString,\n settings: zod.looseObject({}).nullish().optional()\n })\n .optional()\n .nullable()\n .default(null),\n validation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n listValidation: zod\n .array(\n zod.object({\n name: shortString,\n message: optionalShortString.default(\"Value is required.\"),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({})\n })\n )\n .nullish()\n .optional()\n .default([])\n .transform(value => value || []),\n settings: zod\n .looseObject({})\n .optional()\n .nullish()\n .transform(value => {\n return value || {};\n })\n .default({}),\n rules: zod\n .array(\n zod.object({\n type: zod.enum([\"accessControl\", \"condition\"]),\n target: shortString,\n operator: shortString,\n value: zod.union([zod.string(), zod.number(), zod.boolean(), zod.null()]),\n action: shortString\n })\n )\n .optional()\n .nullish()\n .default([])\n .transform(value => value || [])\n});\n\nconst apiNameRefinementValidation = (value: string): boolean => {\n if (value.match(/^[A-Z]/) === null) {\n return false;\n }\n return value === upperFirst(camelCase(value));\n};\nconst refinementSingularValidationMessage = (value?: string) => {\n return {\n message: `The Singular API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategory\" or \"CarMake\".`\n };\n};\nconst refinementPluralValidationMessage = (value?: string) => {\n return {\n message: `The Plural API Name value \"${\n value || \"undefined\"\n }\" is not valid. It must in Upper First + Camel Cased form. For example: \"ArticleCategories\" or \"CarMakes\".`\n };\n};\n\nconst refineSingularApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementSingularValidationMessage(value)\n });\n }\n};\n\nconst refinePluralApiName = (value: string, ctx: zod.RefinementCtx) => {\n if (!apiNameRefinementValidation(value)) {\n ctx.addIssue({\n code: zod.ZodIssueCode.custom,\n ...refinementPluralValidationMessage(value)\n });\n }\n};\n\nconst modelIdTransformation = (value?: string) => {\n if (!value) {\n return value;\n }\n const camelCasedValue = camelCase(value);\n if (camelCasedValue.toLowerCase() === value.toLowerCase()) {\n return value;\n }\n return camelCasedValue;\n};\n\nexport const createModelCreateValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.min(1).superRefine(refineSingularApiName),\n pluralApiName: shortString.min(1).superRefine(refinePluralApiName),\n description: optionalNullishShortString.transform(value => {\n return value || \"\";\n }),\n group: shortString,\n icon,\n fields: zod.array(fieldSchema).default([]),\n layout: zod.array(zod.array(zod.any())).default([]),\n tags: zod.array(shortString).optional(),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n defaultFields: zod.boolean().nullish(),\n settings: zod.looseObject({}).optional().nullish().default({})\n });\n};\n\nexport const createModelUpdateValidation = () => {\n return zod.object({\n name: optionalShortString,\n singularApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refineSingularApiName(value, ctx);\n }\n }),\n pluralApiName: optionalShortString.superRefine((value, ctx) => {\n if (value) {\n refinePluralApiName(value, ctx);\n }\n }),\n description: optionalNullishShortString,\n group: optionalShortString,\n icon,\n fields: zod.array(fieldSchema),\n layout: zod.array(zod.array(zod.any())),\n titleFieldId: optionalShortString.nullish(),\n descriptionFieldId: optionalShortString.nullish(),\n imageFieldId: optionalShortString.nullish(),\n tags: zod.array(shortString).optional(),\n settings: zod.looseObject({}).optional().nullish()\n });\n};\n\nexport const createModelCreateFromValidation = () => {\n return zod.object({\n name: shortString,\n modelId: optionalShortString.transform(modelIdTransformation),\n singularApiName: shortString.superRefine(refineSingularApiName),\n pluralApiName: shortString.superRefine(refinePluralApiName),\n description: optionalNullishShortString,\n group: shortString,\n icon\n });\n};\n"],"names":["str","zod","shortString","longString","optionalShortString","optionalLongString","optionalNullishShortString","optionalNullishLongString","icon","value","fieldSchema","undefined","apiNameRefinementValidation","upperFirst","camelCase","refinementSingularValidationMessage","refinementPluralValidationMessage","refineSingularApiName","ctx","refinePluralApiName","modelIdTransformation","camelCasedValue","createModelCreateValidation","createModelUpdateValidation","createModelCreateFromValidation"],"mappings":";;;AAIA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAC7B,MAAMC,cAAcF,IAAI,GAAG,CAAC;AAC5B,MAAMG,aAAaH;AACnB,MAAMI,sBAAsBF,YAAY,QAAQ;AAChD,MAAMG,qBAAqBF,WAAW,QAAQ;AAC9C,MAAMG,6BAA6BF,oBAAoB,OAAO,GAAG,OAAO,CAAC;AACzE,MAAMG,4BAA4BF,mBAAmB,OAAO,GAAG,OAAO,CAAC;AAEvE,MAAMG,OAAOP,IAAAA,WACG,CAAC;IACT,MAAMA,IAAI,MAAM;IAChB,MAAMA,IAAI,MAAM;IAChB,OAAOA,IAAI,MAAM,GAAG,QAAQ;AAChC,GACC,QAAQ,GACR,OAAO,GACP,OAAO,CAAC,MACR,SAAS,CAACQ,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AAEJ,MAAMC,cAAcT,IAAI,MAAM,CAAC;IAC3B,IAAIC;IACJ,WAAWD,IAAAA,MACA,GACN,QAAQ,GACR,SAAS,CAAC,IACA;IAEf,SAASC,YACJ,GAAG,CAAC,KACJ,KAAK,CAAC,eAAe;QAClB,SAAS;IACb,GACC,KAAK,CAAC,qBAAqB;QACxB,SAAS;IACb;IACJ,OAAOA;IACP,MAAMK;IACN,aAAaD;IACb,MAAMA;IACN,aAAaA;IACb,MAAMJ;IACN,MAAMD,IAAI,KAA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,CAACS;QAClB,QAAQT,IAAI,KAAK,CAACA,IAAI,KAAK,CAACA,IAAI,GAAG;QACnC,cAAcG,oBAAoB,OAAO;QACzC,oBAAoBA,oBAAoB,OAAO;QAC/C,cAAcA,oBAAoB,OAAO;QACzC,MAAMH,IAAI,KAAK,CAACC,aAAa,QAAQ;QACrC,UAAUD,IAAI,WAAW,CAAC,CAAC,GAAG,QAAQ,GAAG,OAAO;IACpD;AAGG,MAAMuB,kCAAkC,IACpCvB,IAAI,MAAM,CAAC;QACd,MAAMC;QACN,SAASE,oBAAoB,SAAS,CAACgB;QACvC,iBAAiBlB,YAAY,WAAW,CAACe;QACzC,eAAef,YAAY,WAAW,CAACiB;QACvC,aAAab;QACb,OAAOJ;QACPM,MAAAA;IACJ"}
|
|
@@ -6,7 +6,7 @@ const validateEndingAllowed = (params)=>{
|
|
|
6
6
|
input: model.singularApiName,
|
|
7
7
|
disallowedEnding: disallowedEnding
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
if (false === isModelEndingAllowed(model.pluralApiName)) throw new error(`Content model with pluralApiName "${model.pluralApiName}" is not allowed, as it ends in disallowed value.`, "MODEL_PLURAL_API_NAME_NOT_ENDING_ALLOWED", {
|
|
10
10
|
input: model.pluralApiName,
|
|
11
11
|
disallowedEnding: disallowedEnding
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/validation/endingAllowed.js","sources":["../../../../src/domain/contentModel/validation/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;
|
|
1
|
+
{"version":3,"file":"domain/contentModel/validation/endingAllowed.js","sources":["../../../../src/domain/contentModel/validation/endingAllowed.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { disallowedEnding, isModelEndingAllowed } from \"./isModelEndingAllowed.js\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateEndingAllowed","params","model","isModelEndingAllowed","WebinyError","disallowedEnding"],"mappings":";;AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,KAAK,EAAE,GAAGD;IAClB,IAAIE,AAAgD,UAAhDA,qBAAqBD,MAAM,eAAe,GAC1C,MAAM,IAAIE,MACN,CAAC,oCAAoC,EAAEF,MAAM,eAAe,CAAC,iDAAiD,CAAC,EAC/G,8CACA;QACI,OAAOA,MAAM,eAAe;QAC5BG,kBAAgBA;IACpB;IAED,IAAIF,AAA8C,UAA9CA,qBAAqBD,MAAM,aAAa,GAC/C,MAAM,IAAIE,MACN,CAAC,kCAAkC,EAAEF,MAAM,aAAa,CAAC,iDAAiD,CAAC,EAC3G,4CACA;QACI,OAAOA,MAAM,aAAa;QAC1B,kBAAkBG;IACtB;AAGZ"}
|
|
@@ -4,7 +4,7 @@ const validatePluralApiName = (params)=>{
|
|
|
4
4
|
if (existingModel.singularApiName === model.pluralApiName) throw new error(`Content model with singularApiName "${model.pluralApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
|
|
5
5
|
input: model.pluralApiName
|
|
6
6
|
});
|
|
7
|
-
|
|
7
|
+
if (existingModel.pluralApiName === model.pluralApiName) throw new error(`Content model with pluralApiName "${model.pluralApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
|
|
8
8
|
input: model.pluralApiName
|
|
9
9
|
});
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/validation/pluralApiName.js","sources":["../../../../src/domain/contentModel/validation/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;
|
|
1
|
+
{"version":3,"file":"domain/contentModel/validation/pluralApiName.js","sources":["../../../../src/domain/contentModel/validation/pluralApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validatePluralApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,wBAAwB,CAACC;IAClC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,aAAa,EACrD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC7E,kCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,aAAa,EAC1D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,aAAa,CAAC,iBAAiB,CAAC,EAC3E,gCACA;QACI,OAAOA,MAAM,aAAa;IAC9B;AAGZ"}
|
|
@@ -4,7 +4,7 @@ const validateSingularApiName = (params)=>{
|
|
|
4
4
|
if (existingModel.singularApiName === model.singularApiName) throw new error(`Content model with singularApiName "${model.singularApiName}" already exists.`, "MODEL_SINGULAR_API_NAME_EXISTS", {
|
|
5
5
|
input: model.singularApiName
|
|
6
6
|
});
|
|
7
|
-
|
|
7
|
+
if (existingModel.pluralApiName === model.singularApiName) throw new error(`Content model with pluralApiName "${model.singularApiName}" already exists.`, "MODEL_PLURAL_API_NAME_EXISTS", {
|
|
8
8
|
input: model.singularApiName
|
|
9
9
|
});
|
|
10
10
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModel/validation/singularApiName.js","sources":["../../../../src/domain/contentModel/validation/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;
|
|
1
|
+
{"version":3,"file":"domain/contentModel/validation/singularApiName.js","sources":["../../../../src/domain/contentModel/validation/singularApiName.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type { CmsModel } from \"~/types/index.js\";\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"],"names":["validateSingularApiName","params","existingModel","model","WebinyError"],"mappings":";AAQO,MAAMA,0BAA0B,CAACC;IACpC,MAAM,EAAEC,aAAa,EAAEC,KAAK,EAAE,GAAGF;IAEjC,IAAIC,cAAc,eAAe,KAAKC,MAAM,eAAe,EACvD,MAAM,IAAIC,MACN,CAAC,oCAAoC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC/E,kCACA;QACI,OAAOA,MAAM,eAAe;IAChC;IAED,IAAID,cAAc,aAAa,KAAKC,MAAM,eAAe,EAC5D,MAAM,IAAIC,MACN,CAAC,kCAAkC,EAAED,MAAM,eAAe,CAAC,iBAAiB,CAAC,EAC7E,gCACA;QACI,OAAOA,MAAM,eAAe;IAChC;AAGZ"}
|
package/export/crud/exporting.js
CHANGED
|
@@ -4,8 +4,8 @@ const createExportStructureContext = (context)=>async (params)=>{
|
|
|
4
4
|
const groups = (await context.cms.listGroups()).map(sanitizeGroup);
|
|
5
5
|
const models = (await context.cms.listModels()).filter((model)=>{
|
|
6
6
|
if (model.isPrivate) return false;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
if (!model.fields?.length) return false;
|
|
8
|
+
if (!modelIdList?.length) return true;
|
|
9
9
|
return modelIdList.includes(model.modelId);
|
|
10
10
|
}).map((model)=>{
|
|
11
11
|
const group = groups.find((group)=>group.slug === model.group);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const groups = (await context.cms.listGroups()).map(sanitizeGroup);\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const models = (await context.cms.listModels())\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.slug === model.group);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.slug);\n }),\n models\n };\n };\n};\n"],"names":["createExportStructureContext","context","params","modelIdList","groups","sanitizeGroup","models","model","group","sanitizeModel"],"mappings":";AAIO,MAAMA,+BAA+B,CAACC,UAClC,OAAMC;QACT,MAAM,EAAE,QAAQC,WAAW,EAAE,GAAGD;QAChC,MAAME,SAAU,OAAMH,QAAQ,GAAG,CAAC,UAAU,EAAC,EAAG,GAAG,CAACI;QAQpD,MAAMC,SAAU,OAAML,QAAQ,GAAG,CAAC,UAAU,EAAC,EACxC,MAAM,CAACM,CAAAA;YACJ,IAAIA,MAAM,SAAS,EACf,OAAO;
|
|
1
|
+
{"version":3,"file":"export/crud/exporting.js","sources":["../../../src/export/crud/exporting.ts"],"sourcesContent":["import type { HeadlessCmsExportStructure, SanitizedCmsModel } from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { sanitizeGroup, sanitizeModel } from \"./sanitize.js\";\n\nexport const createExportStructureContext = (context: CmsContext): HeadlessCmsExportStructure => {\n return async params => {\n const { models: modelIdList } = params;\n const groups = (await context.cms.listGroups()).map(sanitizeGroup);\n /**\n * We need all the models which:\n * * are accessible by current user\n * * are not private\n * * are included (if targets are provided)\n * * are part of one of the groups we already fetched\n */\n const models = (await context.cms.listModels())\n .filter(model => {\n if (model.isPrivate) {\n return false;\n } else if (!model.fields?.length) {\n return false;\n } else if (!modelIdList?.length) {\n return true;\n }\n return modelIdList.includes(model.modelId);\n })\n .map(model => {\n const group = groups.find(group => group.slug === model.group);\n if (!group) {\n return null;\n }\n return sanitizeModel(group, model);\n })\n .filter((model): model is SanitizedCmsModel => {\n return !!model;\n });\n\n return {\n groups: groups.filter(group => {\n return models.some(model => model.group === group.slug);\n }),\n models\n };\n };\n};\n"],"names":["createExportStructureContext","context","params","modelIdList","groups","sanitizeGroup","models","model","group","sanitizeModel"],"mappings":";AAIO,MAAMA,+BAA+B,CAACC,UAClC,OAAMC;QACT,MAAM,EAAE,QAAQC,WAAW,EAAE,GAAGD;QAChC,MAAME,SAAU,OAAMH,QAAQ,GAAG,CAAC,UAAU,EAAC,EAAG,GAAG,CAACI;QAQpD,MAAMC,SAAU,OAAML,QAAQ,GAAG,CAAC,UAAU,EAAC,EACxC,MAAM,CAACM,CAAAA;YACJ,IAAIA,MAAM,SAAS,EACf,OAAO;YACJ,IAAI,CAACA,MAAM,MAAM,EAAE,QACtB,OAAO;YACJ,IAAI,CAACJ,aAAa,QACrB,OAAO;YAEX,OAAOA,YAAY,QAAQ,CAACI,MAAM,OAAO;QAC7C,GACC,GAAG,CAACA,CAAAA;YACD,MAAMC,QAAQJ,OAAO,IAAI,CAACI,CAAAA,QAASA,MAAM,IAAI,KAAKD,MAAM,KAAK;YAC7D,IAAI,CAACC,OACD,OAAO;YAEX,OAAOC,cAAcD,OAAOD;QAChC,GACC,MAAM,CAAC,CAACA,QACE,CAAC,CAACA;QAGjB,OAAO;YACH,QAAQH,OAAO,MAAM,CAACI,CAAAA,QACXF,OAAO,IAAI,CAACC,CAAAA,QAASA,MAAM,KAAK,KAAKC,MAAM,IAAI;YAE1DF;QACJ;IACJ"}
|
|
@@ -19,7 +19,8 @@ const importGroups = async (params)=>{
|
|
|
19
19
|
imported: true
|
|
20
20
|
});
|
|
21
21
|
continue;
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
|
+
if (group.action === CmsImportAction.UPDATE) {
|
|
23
24
|
try {
|
|
24
25
|
const result = await context.cms.updateGroup(group.group.id, {
|
|
25
26
|
...group.group,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n try {\n const result = await context.cms.updateGroup(group.group.id, {\n ...group.group,\n icon: group.group.icon ?? undefined,\n description: group.group.description || undefined\n });\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"UPDATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n continue;\n }\n /**\n * Create the group\n */\n //\n try {\n const result = await context.cms.createGroup(group.group);\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"CREATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n }\n\n return results;\n};\n"],"names":["importGroups","params","context","groups","results","group","CmsImportAction","result","undefined","ex"],"mappings":";AASO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,UAAkC,EAAE;IAC1C,KAAK,MAAMC,SAASF,OAAQ;QACxB,IAAIE,MAAM,MAAM,KAAKC,gBAAgB,IAAI,IAAID,MAAM,KAAK,EACpDD,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAOA,MAAM,KAAK;YAClB,UAAU;YACV,OAAOA,MAAM,KAAK,IAAI;gBAClB,SAAS;gBACT,MAAM;YACV;QACJ;QAKJ,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,IAAI,EAAE;YACvCF,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;YACd;YACA;QACJ,
|
|
1
|
+
{"version":3,"file":"export/crud/imports/importGroups.js","sources":["../../../../src/export/crud/imports/importGroups.ts"],"sourcesContent":["import type { CmsContext } from \"~/types/index.js\";\nimport type { CmsGroupImportResult, ValidCmsGroupResult } from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\n\ninterface Params {\n context: CmsContext;\n groups: ValidCmsGroupResult[];\n}\n\nexport const importGroups = async (params: Params) => {\n const { context, groups } = params;\n\n const results: CmsGroupImportResult[] = [];\n for (const group of groups) {\n if (group.action === CmsImportAction.NONE || group.error) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: group.error || {\n message: \"No action to be ran on the group.\",\n code: \"NO_ACTION\"\n }\n });\n }\n /**\n * Cannot update if the group is created via plugin.\n */\n if (group.action === CmsImportAction.CODE) {\n results.push({\n action: group.action,\n group: group.group,\n imported: true\n });\n continue;\n }\n /**\n * Update the group.\n */\n //\n else if (group.action === CmsImportAction.UPDATE) {\n try {\n const result = await context.cms.updateGroup(group.group.id, {\n ...group.group,\n icon: group.group.icon ?? undefined,\n description: group.group.description || undefined\n });\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"UPDATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n continue;\n }\n /**\n * Create the group\n */\n //\n try {\n const result = await context.cms.createGroup(group.group);\n results.push({\n action: group.action,\n group: {\n ...result\n },\n imported: true\n });\n } catch (ex) {\n results.push({\n action: group.action,\n group: group.group,\n imported: false,\n error: {\n message: ex.message,\n code: ex.code || \"CREATE_GROUP_ERROR\",\n data: {\n ...ex.data,\n group\n }\n }\n });\n }\n }\n\n return results;\n};\n"],"names":["importGroups","params","context","groups","results","group","CmsImportAction","result","undefined","ex"],"mappings":";AASO,MAAMA,eAAe,OAAOC;IAC/B,MAAM,EAAEC,OAAO,EAAEC,MAAM,EAAE,GAAGF;IAE5B,MAAMG,UAAkC,EAAE;IAC1C,KAAK,MAAMC,SAASF,OAAQ;QACxB,IAAIE,MAAM,MAAM,KAAKC,gBAAgB,IAAI,IAAID,MAAM,KAAK,EACpDD,QAAQ,IAAI,CAAC;YACT,QAAQC,MAAM,MAAM;YACpB,OAAOA,MAAM,KAAK;YAClB,UAAU;YACV,OAAOA,MAAM,KAAK,IAAI;gBAClB,SAAS;gBACT,MAAM;YACV;QACJ;QAKJ,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,IAAI,EAAE;YACvCF,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;YACd;YACA;QACJ;QAKK,IAAIA,MAAM,MAAM,KAAKC,gBAAgB,MAAM,EAAE;YAC9C,IAAI;gBACA,MAAMC,SAAS,MAAML,QAAQ,GAAG,CAAC,WAAW,CAACG,MAAM,KAAK,CAAC,EAAE,EAAE;oBACzD,GAAGA,MAAM,KAAK;oBACd,MAAMA,MAAM,KAAK,CAAC,IAAI,IAAIG;oBAC1B,aAAaH,MAAM,KAAK,CAAC,WAAW,IAAIG;gBAC5C;gBACAJ,QAAQ,IAAI,CAAC;oBACT,QAAQC,MAAM,MAAM;oBACpB,OAAO;wBACH,GAAGE,MAAM;oBACb;oBACA,UAAU;gBACd;YACJ,EAAE,OAAOE,IAAI;gBACTL,QAAQ,IAAI,CAAC;oBACT,QAAQC,MAAM,MAAM;oBACpB,OAAOA,MAAM,KAAK;oBAClB,UAAU;oBACV,OAAO;wBACH,SAASI,GAAG,OAAO;wBACnB,MAAMA,GAAG,IAAI,IAAI;wBACjB,MAAM;4BACF,GAAGA,GAAG,IAAI;4BACVJ;wBACJ;oBACJ;gBACJ;YACJ;YACA;QACJ;QAKA,IAAI;YACA,MAAME,SAAS,MAAML,QAAQ,GAAG,CAAC,WAAW,CAACG,MAAM,KAAK;YACxDD,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAO;oBACH,GAAGE,MAAM;gBACb;gBACA,UAAU;YACd;QACJ,EAAE,OAAOE,IAAI;YACTL,QAAQ,IAAI,CAAC;gBACT,QAAQC,MAAM,MAAM;gBACpB,OAAOA,MAAM,KAAK;gBAClB,UAAU;gBACV,OAAO;oBACH,SAASI,GAAG,OAAO;oBACnB,MAAMA,GAAG,IAAI,IAAI;oBACjB,MAAM;wBACF,GAAGA,GAAG,IAAI;wBACVJ;oBACJ;gBACJ;YACJ;QACJ;IACJ;IAEA,OAAOD;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/imports/validateModels.js","sources":["../../../../src/export/crud/imports/validateModels.ts"],"sourcesContent":["import { createModelImportValidation } from \"~/crud/contentModel/validation.js\";\nimport type {\n CmsImportError,\n HeadlessCmsImportStructureParamsDataModel,\n ValidatedCmsModel,\n ValidatedCmsModelResult\n} from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\nimport type { CmsDynamicZoneTemplate, CmsGroup, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport { createZodError } from \"@webiny/utils\";\n\ninterface CreateModelValidationParams {\n model: ValidatedCmsModel;\n models: CmsModel[];\n}\n\ninterface AddCodeMessageParams {\n action: CmsImportAction;\n}\n\nconst addCodeMessage = (params: AddCodeMessageParams) => {\n if (params.action !== CmsImportAction.CODE) {\n return params;\n }\n return {\n ...params,\n errors: [\n {\n message: `The model is defined via plugin and it cannot be updated.`,\n code: \"MODEL_IS_A_PLUGIN\"\n }\n ]\n };\n};\n\ninterface ValidationResult {\n errors?: CmsImportError[];\n action: CmsImportAction;\n}\n\nconst validateModel = (params: CreateModelValidationParams): ValidationResult => {\n const { model, models } = params;\n /**\n * Let's check if model values that must be unique, already exist.\n */\n const existingModelId = models.find(\n m => m.modelId.toLowerCase() === model.modelId.toLowerCase()\n );\n const existingSingularApiName = models.find(\n m =>\n m.singularApiName.toLowerCase() === model.singularApiName.toLowerCase() ||\n m.singularApiName.toLowerCase() === model.pluralApiName.toString()\n );\n const existingPluralApiName = models.find(\n m =>\n m.pluralApiName.toLowerCase() === model.pluralApiName.toLowerCase() ||\n m.pluralApiName.toLowerCase() === model.singularApiName.toString()\n );\n\n const UPDATE_KEYWORD = existingModelId?.isPlugin\n ? CmsImportAction.CODE\n : CmsImportAction.UPDATE;\n /**\n * There are few cases that we must address:\n *\n * 1. modelId, singular and plural names do not exist in any of the models\n * - this is OK, we can create the model\n */\n if (!existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return {\n action: CmsImportAction.CREATE\n };\n }\n /**\n * 2. modelId, singular and plural names are a part of a single model\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName &&\n existingPluralApiName &&\n existingModelId.modelId === existingSingularApiName.modelId &&\n existingModelId.modelId === existingPluralApiName.modelId\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 3. modelId already exists, but singular and plural names do not\n * - this is OK, we can update the model\n */\n if (existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 4. modelId already exists, but only the singular name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName?.modelId === existingModelId.modelId &&\n !existingPluralApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 5. modelId already exists, but only the plural name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingPluralApiName?.modelId === existingModelId.modelId &&\n !existingSingularApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 6. modelId already exists, but singular and plural names are in different models.\n */\n if (\n existingModelId &&\n (existingSingularApiName?.modelId !== existingModelId.modelId ||\n existingPluralApiName?.modelId !== existingModelId.modelId)\n ) {\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model has singular or plural API names same as some other model.`,\n code: \"MODEL_API_NAMES_ERROR\"\n }\n ]\n };\n }\n\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model cannot be imported.`,\n code: \"MODEL_IMPORT_ERROR\",\n data: {\n modelId: existingModelId?.modelId,\n singularApiName: existingSingularApiName?.modelId,\n pluralApiName: existingPluralApiName?.modelId\n }\n }\n ]\n };\n};\n\ninterface InputGroup extends Pick<CmsGroup, \"id\" | \"slug\"> {\n target: string;\n}\n\ninterface Params {\n groups: InputGroup[];\n models: CmsModel[];\n input: HeadlessCmsImportStructureParamsDataModel[];\n}\n\ninterface GetRelatedModelsParams {\n fields: CmsModelField[];\n models: CmsModel[];\n}\n\nconst getRelatedModels = (params: GetRelatedModelsParams): string[] => {\n const { fields, models } = params;\n\n const result: string[] = [];\n for (const field of fields) {\n if (field.type === \"ref\") {\n for (const model of field.settings?.models || []) {\n result.push(model.modelId);\n }\n } else if (field.type === \"object\") {\n result.push(...getRelatedModels({ fields: field.settings?.fields || [], models }));\n } else if (field.type === \"dynamicZone\") {\n const templates = (field.settings?.templates || []) as CmsDynamicZoneTemplate[];\n for (const tpl of templates) {\n result.push(\n ...getRelatedModels({\n fields: tpl.fields || [],\n models\n })\n );\n }\n }\n }\n\n return Array.from(new Set(result));\n};\n\nexport const validateModels = async (params: Params): Promise<ValidatedCmsModelResult[]> => {\n const { groups, models, input } = params;\n\n const validation = createModelImportValidation();\n\n return await Promise.all(\n input.map(async (model): Promise<ValidatedCmsModelResult> => {\n const result = await validation.safeParseAsync(model);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n model: model as ValidatedCmsModel,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as unknown as ValidatedCmsModel;\n const group = groups.find(g => g.slug === data.group || g.target === data.group);\n if (!group) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `The model group \"${data.group}\" does not exist.`,\n code: \"MODEL_GROUP_NOT_FOUND\"\n }\n };\n } else if (!model.fields?.length) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Model is missing fields.`,\n code: \"MODEL_FIELDS_MISSING\"\n }\n };\n }\n\n const targetModel: ValidatedCmsModel = {\n ...data,\n group: group.slug\n };\n\n const modelValidationResult = validateModel({\n model: targetModel,\n models\n });\n\n if (!modelValidationResult.errors?.length) {\n return {\n model: targetModel,\n related: getRelatedModels({\n fields: targetModel.fields,\n models\n }),\n action: modelValidationResult.action\n };\n }\n return {\n model: targetModel,\n action: modelValidationResult.action,\n error: modelValidationResult.errors[0]\n };\n })\n );\n};\n"],"names":["addCodeMessage","params","CmsImportAction","validateModel","model","models","existingModelId","m","existingSingularApiName","existingPluralApiName","UPDATE_KEYWORD","getRelatedModels","fields","result","field","templates","tpl","Array","Set","validateModels","groups","input","validation","createModelImportValidation","Promise","error","createZodError","data","group","g","targetModel","modelValidationResult"],"mappings":";;;AAoBA,MAAMA,iBAAiB,CAACC;IACpB,IAAIA,OAAO,MAAM,KAAKC,gBAAgB,IAAI,EACtC,OAAOD;IAEX,OAAO;QACH,GAAGA,MAAM;QACT,QAAQ;YACJ;gBACI,SAAS;gBACT,MAAM;YACV;SACH;IACL;AACJ;AAOA,MAAME,gBAAgB,CAACF;IACnB,MAAM,EAAEG,KAAK,EAAEC,MAAM,EAAE,GAAGJ;IAI1B,MAAMK,kBAAkBD,OAAO,IAAI,CAC/BE,CAAAA,IAAKA,EAAE,OAAO,CAAC,WAAW,OAAOH,MAAM,OAAO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,IAAI;oBAChB,MAAMA,MAAM,IAAI;gBACpB;YACJ;QACJ;QACA,MAAME,OAAOd,OAAO,IAAI;QACxB,MAAMe,QAAQR,OAAO,IAAI,CAACS,CAAAA,IAAKA,EAAE,IAAI,KAAKF,KAAK,KAAK,IAAIE,EAAE,MAAM,KAAKF,KAAK,KAAK;QAC/E,IAAI,CAACC,OACD,OAAO;YACH,OAAOD;YACP,QAAQzB,gBAAgB,IAAI;YAC5B,OAAO;gBACH,SAAS,CAAC,iBAAiB,EAAEyB,KAAK,KAAK,CAAC,iBAAiB,CAAC;gBAC1D,MAAM;YACV;QACJ;aACG,IAAI,CAACvB,MAAM,MAAM,EAAE,QACtB,OAAO;YACH,OAAOuB;YACP,QAAQzB,gBAAgB,IAAI;YAC5B,OAAO;gBACH,SAAS;gBACT,MAAM;YACV;QACJ;QAGJ,MAAM4B,cAAiC;YACnC,GAAGH,IAAI;YACP,OAAOC,MAAM,IAAI;QACrB;QAEA,MAAMG,wBAAwB5B,cAAc;YACxC,OAAO2B;YACPzB;QACJ;QAEA,IAAI,CAAC0B,sBAAsB,MAAM,EAAE,QAC/B,OAAO;YACH,OAAOD;YACP,SAASnB,iBAAiB;gBACtB,QAAQmB,YAAY,MAAM;gBAC1BzB;YACJ;YACA,QAAQ0B,sBAAsB,MAAM;QACxC;QAEJ,OAAO;YACH,OAAOD;YACP,QAAQC,sBAAsB,MAAM;YACpC,OAAOA,sBAAsB,MAAM,CAAC,EAAE;QAC1C;IACJ;AAER"}
|
|
1
|
+
{"version":3,"file":"export/crud/imports/validateModels.js","sources":["../../../../src/export/crud/imports/validateModels.ts"],"sourcesContent":["import { createModelImportValidation } from \"~/crud/contentModel/validation.js\";\nimport type {\n CmsImportError,\n HeadlessCmsImportStructureParamsDataModel,\n ValidatedCmsModel,\n ValidatedCmsModelResult\n} from \"~/export/types.js\";\nimport { CmsImportAction } from \"~/export/types.js\";\nimport type { CmsDynamicZoneTemplate, CmsGroup, CmsModel, CmsModelField } from \"~/types/index.js\";\nimport { createZodError } from \"@webiny/utils\";\n\ninterface CreateModelValidationParams {\n model: ValidatedCmsModel;\n models: CmsModel[];\n}\n\ninterface AddCodeMessageParams {\n action: CmsImportAction;\n}\n\nconst addCodeMessage = (params: AddCodeMessageParams) => {\n if (params.action !== CmsImportAction.CODE) {\n return params;\n }\n return {\n ...params,\n errors: [\n {\n message: `The model is defined via plugin and it cannot be updated.`,\n code: \"MODEL_IS_A_PLUGIN\"\n }\n ]\n };\n};\n\ninterface ValidationResult {\n errors?: CmsImportError[];\n action: CmsImportAction;\n}\n\nconst validateModel = (params: CreateModelValidationParams): ValidationResult => {\n const { model, models } = params;\n /**\n * Let's check if model values that must be unique, already exist.\n */\n const existingModelId = models.find(\n m => m.modelId.toLowerCase() === model.modelId.toLowerCase()\n );\n const existingSingularApiName = models.find(\n m =>\n m.singularApiName.toLowerCase() === model.singularApiName.toLowerCase() ||\n m.singularApiName.toLowerCase() === model.pluralApiName.toString()\n );\n const existingPluralApiName = models.find(\n m =>\n m.pluralApiName.toLowerCase() === model.pluralApiName.toLowerCase() ||\n m.pluralApiName.toLowerCase() === model.singularApiName.toString()\n );\n\n const UPDATE_KEYWORD = existingModelId?.isPlugin\n ? CmsImportAction.CODE\n : CmsImportAction.UPDATE;\n /**\n * There are few cases that we must address:\n *\n * 1. modelId, singular and plural names do not exist in any of the models\n * - this is OK, we can create the model\n */\n if (!existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return {\n action: CmsImportAction.CREATE\n };\n }\n /**\n * 2. modelId, singular and plural names are a part of a single model\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName &&\n existingPluralApiName &&\n existingModelId.modelId === existingSingularApiName.modelId &&\n existingModelId.modelId === existingPluralApiName.modelId\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 3. modelId already exists, but singular and plural names do not\n * - this is OK, we can update the model\n */\n if (existingModelId && !existingSingularApiName && !existingPluralApiName) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 4. modelId already exists, but only the singular name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingSingularApiName?.modelId === existingModelId.modelId &&\n !existingPluralApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 5. modelId already exists, but only the plural name exists.\n * - this is OK, we can update the model\n */\n if (\n existingModelId &&\n existingPluralApiName?.modelId === existingModelId.modelId &&\n !existingSingularApiName\n ) {\n return addCodeMessage({\n action: UPDATE_KEYWORD\n });\n }\n /**\n * 6. modelId already exists, but singular and plural names are in different models.\n */\n if (\n existingModelId &&\n (existingSingularApiName?.modelId !== existingModelId.modelId ||\n existingPluralApiName?.modelId !== existingModelId.modelId)\n ) {\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model has singular or plural API names same as some other model.`,\n code: \"MODEL_API_NAMES_ERROR\"\n }\n ]\n };\n }\n\n return {\n action: CmsImportAction.NONE,\n errors: [\n {\n message: `The model cannot be imported.`,\n code: \"MODEL_IMPORT_ERROR\",\n data: {\n modelId: existingModelId?.modelId,\n singularApiName: existingSingularApiName?.modelId,\n pluralApiName: existingPluralApiName?.modelId\n }\n }\n ]\n };\n};\n\ninterface InputGroup extends Pick<CmsGroup, \"id\" | \"slug\"> {\n target: string;\n}\n\ninterface Params {\n groups: InputGroup[];\n models: CmsModel[];\n input: HeadlessCmsImportStructureParamsDataModel[];\n}\n\ninterface GetRelatedModelsParams {\n fields: CmsModelField[];\n models: CmsModel[];\n}\n\nconst getRelatedModels = (params: GetRelatedModelsParams): string[] => {\n const { fields, models } = params;\n\n const result: string[] = [];\n for (const field of fields) {\n if (field.type === \"ref\") {\n for (const model of field.settings?.models || []) {\n result.push(model.modelId);\n }\n } else if (field.type === \"object\") {\n result.push(...getRelatedModels({ fields: field.settings?.fields || [], models }));\n } else if (field.type === \"dynamicZone\") {\n const templates = (field.settings?.templates || []) as CmsDynamicZoneTemplate[];\n for (const tpl of templates) {\n result.push(\n ...getRelatedModels({\n fields: tpl.fields || [],\n models\n })\n );\n }\n }\n }\n\n return Array.from(new Set(result));\n};\n\nexport const validateModels = async (params: Params): Promise<ValidatedCmsModelResult[]> => {\n const { groups, models, input } = params;\n\n const validation = createModelImportValidation();\n\n return await Promise.all(\n input.map(async (model): Promise<ValidatedCmsModelResult> => {\n const result = await validation.safeParseAsync(model);\n if (!result.success) {\n const error = createZodError(result.error);\n return {\n model: model as ValidatedCmsModel,\n action: CmsImportAction.NONE,\n error: {\n message: error.message,\n code: error.code,\n data: error.data\n }\n };\n }\n const data = result.data as unknown as ValidatedCmsModel;\n const group = groups.find(g => g.slug === data.group || g.target === data.group);\n if (!group) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `The model group \"${data.group}\" does not exist.`,\n code: \"MODEL_GROUP_NOT_FOUND\"\n }\n };\n } else if (!model.fields?.length) {\n return {\n model: data,\n action: CmsImportAction.NONE,\n error: {\n message: `Model is missing fields.`,\n code: \"MODEL_FIELDS_MISSING\"\n }\n };\n }\n\n const targetModel: ValidatedCmsModel = {\n ...data,\n group: group.slug\n };\n\n const modelValidationResult = validateModel({\n model: targetModel,\n models\n });\n\n if (!modelValidationResult.errors?.length) {\n return {\n model: targetModel,\n related: getRelatedModels({\n fields: targetModel.fields,\n models\n }),\n action: modelValidationResult.action\n };\n }\n return {\n model: targetModel,\n action: modelValidationResult.action,\n error: modelValidationResult.errors[0]\n };\n })\n );\n};\n"],"names":["addCodeMessage","params","CmsImportAction","validateModel","model","models","existingModelId","m","existingSingularApiName","existingPluralApiName","UPDATE_KEYWORD","getRelatedModels","fields","result","field","templates","tpl","Array","Set","validateModels","groups","input","validation","createModelImportValidation","Promise","error","createZodError","data","group","g","targetModel","modelValidationResult"],"mappings":";;;AAoBA,MAAMA,iBAAiB,CAACC;IACpB,IAAIA,OAAO,MAAM,KAAKC,gBAAgB,IAAI,EACtC,OAAOD;IAEX,OAAO;QACH,GAAGA,MAAM;QACT,QA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|
3
3
|
export { DataFieldBuilder } from "../../../features/modelBuilder/fields/FieldBuilder.js";
|
|
4
4
|
export { LayoutFieldBuilder } from "../../../features/modelBuilder/fields/FieldBuilder.js";
|
|
5
5
|
export { FieldType } from "../../../features/modelBuilder/fields/abstractions.js";
|
|
6
|
+
export { type IAssetFieldBuilder } from "../../../features/modelBuilder/fields/AssetFieldType.js";
|
|
6
7
|
export type { IFieldRendererRegistry } from "../../../features/modelBuilder/fields/DataFieldBuilder.js";
|
|
7
|
-
export type { IFieldBuilderRegistry } from "../../../features/modelBuilder/abstractions.js";
|
|
8
|
+
export type { IFieldBuilderRegistry, IModelSettings } from "../../../features/modelBuilder/abstractions.js";
|
|
8
9
|
export { LayoutBuilder } from "../../../features/modelBuilder/LayoutBuilder.js";
|
|
9
10
|
export type { FieldTypeValidator } from "../../../features/modelBuilder/fields/fieldTypeValidator.js";
|
|
10
11
|
export type { CmsModel } from "../../../types/model.js";
|
|
@@ -19,3 +20,5 @@ export { DeleteModelUseCase } from "../../../features/contentModel/DeleteModel/a
|
|
|
19
20
|
export { ModelBeforeDeleteEventHandler, ModelAfterDeleteEventHandler } from "../../../features/contentModel/DeleteModel/events.js";
|
|
20
21
|
export { GetModelUseCase } from "../../../features/contentModel/GetModel/abstractions.js";
|
|
21
22
|
export { ListModelsUseCase } from "../../../features/contentModel/ListModels/abstractions.js";
|
|
23
|
+
export { ModelToAstConverter } from "../../../features/contentModel/ModelToAstConverter/index.js";
|
|
24
|
+
export { CmsModelToJsonSchemaConverter } from "../../../utils/index.js";
|
package/exports/api/cms/model.js
CHANGED
|
@@ -13,3 +13,5 @@ export { DeleteModelUseCase } from "../../../features/contentModel/DeleteModel/a
|
|
|
13
13
|
export { ModelAfterDeleteEventHandler, ModelBeforeDeleteEventHandler } from "../../../features/contentModel/DeleteModel/events.js";
|
|
14
14
|
export { GetModelUseCase } from "../../../features/contentModel/GetModel/abstractions.js";
|
|
15
15
|
export { ListModelsUseCase } from "../../../features/contentModel/ListModels/abstractions.js";
|
|
16
|
+
export { ModelToAstConverter } from "../../../features/contentModel/ModelToAstConverter/index.js";
|
|
17
|
+
export { CmsModelToJsonSchemaConverter } from "../../../utils/index.js";
|
package/extension.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type CreateGraphQLParams } from "./graphql/index.js";
|
|
2
|
+
export type ICreateCmsExtensionParams = CreateGraphQLParams;
|
|
3
|
+
export declare const createCmsExtension: (params?: ICreateCmsExtensionParams) => ((import("./fieldConverters/CmsModelDefaultFieldConverterPlugin").CmsModelDefaultFieldConverterPlugin | import("./fieldConverters/CmsModelDynamicZoneFieldConverterPlugin").CmsModelDynamicZoneFieldConverterPlugin | import("./fieldConverters/CmsModelObjectFieldConverterPlugin").CmsModelObjectFieldConverterPlugin)[] | import("./plugins").CmsParametersPlugin | import("@webiny/api/index").ContextPlugin<import("./types").CmsContext> | import("@webiny/plugins/types").Plugin)[];
|
package/extension.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createRevisionIdScalarPlugin } from "./graphql/scalars/RevisionIdScalarPlugin.js";
|
|
2
|
+
import { createContextParameterPlugin, createHeaderParameterPlugin, createPathParameterPlugin } from "./parameters/index.js";
|
|
3
|
+
import { createGraphQL } from "./graphql/index.js";
|
|
4
|
+
import { createExportGraphQL } from "./export/index.js";
|
|
5
|
+
import { createContextPlugin } from "./context.js";
|
|
6
|
+
import { createFieldConverters } from "./fieldConverters/index.js";
|
|
7
|
+
const createCmsExtension = (params = {})=>[
|
|
8
|
+
createContextPlugin(),
|
|
9
|
+
createFieldConverters(),
|
|
10
|
+
...createRevisionIdScalarPlugin(),
|
|
11
|
+
createPathParameterPlugin(),
|
|
12
|
+
createHeaderParameterPlugin(),
|
|
13
|
+
createContextParameterPlugin(),
|
|
14
|
+
...createGraphQL(params),
|
|
15
|
+
createExportGraphQL()
|
|
16
|
+
];
|
|
17
|
+
export { createCmsExtension };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=extension.js.map
|
package/extension.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extension.js","sources":["../src/extension.ts"],"sourcesContent":["import { createRevisionIdScalarPlugin } from \"~/graphql/scalars/RevisionIdScalarPlugin.js\";\nimport {\n createContextParameterPlugin,\n createHeaderParameterPlugin,\n createPathParameterPlugin\n} from \"~/parameters/index.js\";\nimport { createGraphQL as baseCreateGraphQL, type CreateGraphQLParams } from \"~/graphql/index.js\";\nimport { createExportGraphQL } from \"~/export/index.js\";\nimport { createContextPlugin } from \"~/context.js\";\nimport { createFieldConverters } from \"~/fieldConverters/index.js\";\n\nexport type ICreateCmsExtensionParams = CreateGraphQLParams;\n\nexport const createCmsExtension = (params: ICreateCmsExtensionParams = {}) => {\n return [\n createContextPlugin(),\n createFieldConverters(),\n ...createRevisionIdScalarPlugin(),\n /**\n * PathParameter plugins are used to determine the type of the cms endpoint\n */\n createPathParameterPlugin(),\n createHeaderParameterPlugin(),\n createContextParameterPlugin(),\n /**\n * At this point we can create, or not create, CMS GraphQL Schema.\n */\n ...baseCreateGraphQL(params),\n createExportGraphQL()\n ];\n};\n"],"names":["createCmsExtension","params","createContextPlugin","createFieldConverters","createRevisionIdScalarPlugin","createPathParameterPlugin","createHeaderParameterPlugin","createContextParameterPlugin","baseCreateGraphQL","createExportGraphQL"],"mappings":";;;;;;AAaO,MAAMA,qBAAqB,CAACC,SAAoC,CAAC,CAAC,GAC9D;QACHC;QACAC;WACGC;QAIHC;QACAC;QACAC;WAIGC,cAAkBP;QACrBQ;KACH"}
|
|
@@ -26,6 +26,7 @@ import { GetUniqueFieldValuesFeature } from "./GetUniqueFieldValues/feature.js";
|
|
|
26
26
|
import { GetSingletonEntryFeature } from "./GetSingletonEntry/feature.js";
|
|
27
27
|
import { UpdateSingletonEntryFeature } from "./UpdateSingletonEntry/feature.js";
|
|
28
28
|
import { ContentEntryTraverserFeature } from "./ContentEntryTraverser/feature.js";
|
|
29
|
+
import { UpdateRevisionFeature } from "./UpdateRevision/feature.js";
|
|
29
30
|
import { UpdateRevisionDescriptionFeature } from "./UpdateRevisionDescription/feature.js";
|
|
30
31
|
import { EntryDataFactoriesFeature } from "./entryDataFactories/EntryDataFactoriesFeature.js";
|
|
31
32
|
import { RuntimeTenant } from "../runtimeTenant/RuntimeTenant.js";
|
|
@@ -51,6 +52,7 @@ const ContentEntriesFeature = createFeature({
|
|
|
51
52
|
CreateEntryFeature.register(container);
|
|
52
53
|
CreateEntryRevisionFromFeature.register(container);
|
|
53
54
|
UpdateEntryFeature.register(container);
|
|
55
|
+
UpdateRevisionFeature.register(container);
|
|
54
56
|
UpdateRevisionDescriptionFeature.register(container);
|
|
55
57
|
ValidateEntryFeature.register(container);
|
|
56
58
|
MoveEntryFeature.register(container);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/ContentEntriesFeature.js","sources":["../../../src/features/contentEntry/ContentEntriesFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CreateEntryFeature } from \"./CreateEntry/feature.js\";\nimport { CreateEntryRevisionFromFeature } from \"./CreateEntryRevisionFrom/feature.js\";\nimport { UpdateEntryFeature } from \"./UpdateEntry/feature.js\";\nimport { ValidateEntryFeature } from \"./ValidateEntry/feature.js\";\nimport { MoveEntryFeature } from \"./MoveEntry/feature.js\";\nimport { RepublishEntryFeature } from \"./RepublishEntry/feature.js\";\nimport { PublishEntryFeature } from \"./PublishEntry/feature.js\";\nimport { GetRevisionByIdFeature } from \"./GetRevisionById/feature.js\";\nimport { ListEntriesFeature } from \"./ListEntries/feature.js\";\nimport { GetEntriesByIdsFeature } from \"./GetEntriesByIds/feature.js\";\nimport { GetEntryByIdFeature } from \"./GetEntryById/feature.js\";\nimport { GetPublishedEntriesByIdsFeature } from \"./GetPublishedEntriesByIds/feature.js\";\nimport { GetLatestEntriesByIdsFeature } from \"./GetLatestEntriesByIds/feature.js\";\nimport { GetRevisionsByEntryIdFeature } from \"./GetRevisionsByEntryId/feature.js\";\nimport { GetPreviousRevisionByEntryIdFeature } from \"./GetPreviousRevisionByEntryId/feature.js\";\nimport { GetEntryFeature } from \"./GetEntry/feature.js\";\nimport { DeleteEntryFeature } from \"./DeleteEntry/feature.js\";\nimport { DeleteEntryRevisionFeature } from \"./DeleteEntryRevision/feature.js\";\nimport { DeleteMultipleEntriesFeature } from \"./DeleteMultipleEntries/feature.js\";\nimport { RestoreEntryFromBinFeature } from \"./RestoreEntryFromBin/feature.js\";\nimport { GetLatestRevisionByEntryIdFeature } from \"./GetLatestRevisionByEntryId/feature.js\";\nimport { GetPublishedRevisionByEntryIdFeature } from \"./GetPublishedRevisionByEntryId/feature.js\";\nimport { UnpublishEntryFeature } from \"./UnpublishEntry/feature.js\";\nimport { GetUniqueFieldValuesFeature } from \"./GetUniqueFieldValues/feature.js\";\nimport { GetSingletonEntryFeature } from \"./GetSingletonEntry/feature.js\";\nimport { UpdateSingletonEntryFeature } from \"./UpdateSingletonEntry/feature.js\";\nimport { ContentEntryTraverserFeature } from \"./ContentEntryTraverser/feature.js\";\nimport { UpdateRevisionDescriptionFeature } from \"./UpdateRevisionDescription/feature.js\";\nimport { EntryDataFactoriesFeature } from \"./entryDataFactories/EntryDataFactoriesFeature.js\";\nimport { RuntimeTenant } from \"../runtimeTenant/RuntimeTenant.js\";\n\nexport const ContentEntriesFeature = createFeature({\n name: \"ContentEntries\",\n register(container) {\n container.register(RuntimeTenant);\n EntryDataFactoriesFeature.register(container);\n // Query features\n GetRevisionByIdFeature.register(container);\n GetEntriesByIdsFeature.register(container);\n GetEntryByIdFeature.register(container);\n GetPublishedEntriesByIdsFeature.register(container);\n GetPublishedRevisionByEntryIdFeature.register(container);\n GetLatestEntriesByIdsFeature.register(container);\n GetLatestRevisionByEntryIdFeature.register(container);\n GetRevisionsByEntryIdFeature.register(container);\n GetPreviousRevisionByEntryIdFeature.register(container);\n GetEntryFeature.register(container);\n ListEntriesFeature.register(container);\n GetUniqueFieldValuesFeature.register(container);\n GetSingletonEntryFeature.register(container);\n\n // Provider features\n ContentEntryTraverserFeature.register(container);\n\n // Command features\n CreateEntryFeature.register(container);\n CreateEntryRevisionFromFeature.register(container);\n UpdateEntryFeature.register(container);\n UpdateRevisionDescriptionFeature.register(container);\n ValidateEntryFeature.register(container);\n MoveEntryFeature.register(container);\n PublishEntryFeature.register(container);\n UnpublishEntryFeature.register(container);\n RepublishEntryFeature.register(container);\n DeleteEntryFeature.register(container);\n DeleteEntryRevisionFeature.register(container);\n DeleteMultipleEntriesFeature.register(container);\n RestoreEntryFromBinFeature.register(container);\n UpdateSingletonEntryFeature.register(container);\n }\n});\n"],"names":["ContentEntriesFeature","createFeature","container","RuntimeTenant","EntryDataFactoriesFeature","GetRevisionByIdFeature","GetEntriesByIdsFeature","GetEntryByIdFeature","GetPublishedEntriesByIdsFeature","GetPublishedRevisionByEntryIdFeature","GetLatestEntriesByIdsFeature","GetLatestRevisionByEntryIdFeature","GetRevisionsByEntryIdFeature","GetPreviousRevisionByEntryIdFeature","GetEntryFeature","ListEntriesFeature","GetUniqueFieldValuesFeature","GetSingletonEntryFeature","ContentEntryTraverserFeature","CreateEntryFeature","CreateEntryRevisionFromFeature","UpdateEntryFeature","UpdateRevisionDescriptionFeature","ValidateEntryFeature","MoveEntryFeature","PublishEntryFeature","UnpublishEntryFeature","RepublishEntryFeature","DeleteEntryFeature","DeleteEntryRevisionFeature","DeleteMultipleEntriesFeature","RestoreEntryFromBinFeature","UpdateSingletonEntryFeature"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/contentEntry/ContentEntriesFeature.js","sources":["../../../src/features/contentEntry/ContentEntriesFeature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/api\";\nimport { CreateEntryFeature } from \"./CreateEntry/feature.js\";\nimport { CreateEntryRevisionFromFeature } from \"./CreateEntryRevisionFrom/feature.js\";\nimport { UpdateEntryFeature } from \"./UpdateEntry/feature.js\";\nimport { ValidateEntryFeature } from \"./ValidateEntry/feature.js\";\nimport { MoveEntryFeature } from \"./MoveEntry/feature.js\";\nimport { RepublishEntryFeature } from \"./RepublishEntry/feature.js\";\nimport { PublishEntryFeature } from \"./PublishEntry/feature.js\";\nimport { GetRevisionByIdFeature } from \"./GetRevisionById/feature.js\";\nimport { ListEntriesFeature } from \"./ListEntries/feature.js\";\nimport { GetEntriesByIdsFeature } from \"./GetEntriesByIds/feature.js\";\nimport { GetEntryByIdFeature } from \"./GetEntryById/feature.js\";\nimport { GetPublishedEntriesByIdsFeature } from \"./GetPublishedEntriesByIds/feature.js\";\nimport { GetLatestEntriesByIdsFeature } from \"./GetLatestEntriesByIds/feature.js\";\nimport { GetRevisionsByEntryIdFeature } from \"./GetRevisionsByEntryId/feature.js\";\nimport { GetPreviousRevisionByEntryIdFeature } from \"./GetPreviousRevisionByEntryId/feature.js\";\nimport { GetEntryFeature } from \"./GetEntry/feature.js\";\nimport { DeleteEntryFeature } from \"./DeleteEntry/feature.js\";\nimport { DeleteEntryRevisionFeature } from \"./DeleteEntryRevision/feature.js\";\nimport { DeleteMultipleEntriesFeature } from \"./DeleteMultipleEntries/feature.js\";\nimport { RestoreEntryFromBinFeature } from \"./RestoreEntryFromBin/feature.js\";\nimport { GetLatestRevisionByEntryIdFeature } from \"./GetLatestRevisionByEntryId/feature.js\";\nimport { GetPublishedRevisionByEntryIdFeature } from \"./GetPublishedRevisionByEntryId/feature.js\";\nimport { UnpublishEntryFeature } from \"./UnpublishEntry/feature.js\";\nimport { GetUniqueFieldValuesFeature } from \"./GetUniqueFieldValues/feature.js\";\nimport { GetSingletonEntryFeature } from \"./GetSingletonEntry/feature.js\";\nimport { UpdateSingletonEntryFeature } from \"./UpdateSingletonEntry/feature.js\";\nimport { ContentEntryTraverserFeature } from \"./ContentEntryTraverser/feature.js\";\nimport { UpdateRevisionFeature } from \"./UpdateRevision/feature.js\";\nimport { UpdateRevisionDescriptionFeature } from \"./UpdateRevisionDescription/feature.js\";\nimport { EntryDataFactoriesFeature } from \"./entryDataFactories/EntryDataFactoriesFeature.js\";\nimport { RuntimeTenant } from \"../runtimeTenant/RuntimeTenant.js\";\n\nexport const ContentEntriesFeature = createFeature({\n name: \"ContentEntries\",\n register(container) {\n container.register(RuntimeTenant);\n EntryDataFactoriesFeature.register(container);\n // Query features\n GetRevisionByIdFeature.register(container);\n GetEntriesByIdsFeature.register(container);\n GetEntryByIdFeature.register(container);\n GetPublishedEntriesByIdsFeature.register(container);\n GetPublishedRevisionByEntryIdFeature.register(container);\n GetLatestEntriesByIdsFeature.register(container);\n GetLatestRevisionByEntryIdFeature.register(container);\n GetRevisionsByEntryIdFeature.register(container);\n GetPreviousRevisionByEntryIdFeature.register(container);\n GetEntryFeature.register(container);\n ListEntriesFeature.register(container);\n GetUniqueFieldValuesFeature.register(container);\n GetSingletonEntryFeature.register(container);\n\n // Provider features\n ContentEntryTraverserFeature.register(container);\n\n // Command features\n CreateEntryFeature.register(container);\n CreateEntryRevisionFromFeature.register(container);\n UpdateEntryFeature.register(container);\n UpdateRevisionFeature.register(container);\n UpdateRevisionDescriptionFeature.register(container);\n ValidateEntryFeature.register(container);\n MoveEntryFeature.register(container);\n PublishEntryFeature.register(container);\n UnpublishEntryFeature.register(container);\n RepublishEntryFeature.register(container);\n DeleteEntryFeature.register(container);\n DeleteEntryRevisionFeature.register(container);\n DeleteMultipleEntriesFeature.register(container);\n RestoreEntryFromBinFeature.register(container);\n UpdateSingletonEntryFeature.register(container);\n }\n});\n"],"names":["ContentEntriesFeature","createFeature","container","RuntimeTenant","EntryDataFactoriesFeature","GetRevisionByIdFeature","GetEntriesByIdsFeature","GetEntryByIdFeature","GetPublishedEntriesByIdsFeature","GetPublishedRevisionByEntryIdFeature","GetLatestEntriesByIdsFeature","GetLatestRevisionByEntryIdFeature","GetRevisionsByEntryIdFeature","GetPreviousRevisionByEntryIdFeature","GetEntryFeature","ListEntriesFeature","GetUniqueFieldValuesFeature","GetSingletonEntryFeature","ContentEntryTraverserFeature","CreateEntryFeature","CreateEntryRevisionFromFeature","UpdateEntryFeature","UpdateRevisionFeature","UpdateRevisionDescriptionFeature","ValidateEntryFeature","MoveEntryFeature","PublishEntryFeature","UnpublishEntryFeature","RepublishEntryFeature","DeleteEntryFeature","DeleteEntryRevisionFeature","DeleteMultipleEntriesFeature","RestoreEntryFromBinFeature","UpdateSingletonEntryFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCO,MAAMA,wBAAwBC,cAAc;IAC/C,MAAM;IACN,UAASC,SAAS;QACdA,UAAU,QAAQ,CAACC;QACnBC,0BAA0B,QAAQ,CAACF;QAEnCG,uBAAuB,QAAQ,CAACH;QAChCI,uBAAuB,QAAQ,CAACJ;QAChCK,oBAAoB,QAAQ,CAACL;QAC7BM,gCAAgC,QAAQ,CAACN;QACzCO,qCAAqC,QAAQ,CAACP;QAC9CQ,6BAA6B,QAAQ,CAACR;QACtCS,kCAAkC,QAAQ,CAACT;QAC3CU,6BAA6B,QAAQ,CAACV;QACtCW,oCAAoC,QAAQ,CAACX;QAC7CY,gBAAgB,QAAQ,CAACZ;QACzBa,mBAAmB,QAAQ,CAACb;QAC5Bc,4BAA4B,QAAQ,CAACd;QACrCe,yBAAyB,QAAQ,CAACf;QAGlCgB,6BAA6B,QAAQ,CAAChB;QAGtCiB,mBAAmB,QAAQ,CAACjB;QAC5BkB,+BAA+B,QAAQ,CAAClB;QACxCmB,mBAAmB,QAAQ,CAACnB;QAC5BoB,sBAAsB,QAAQ,CAACpB;QAC/BqB,iCAAiC,QAAQ,CAACrB;QAC1CsB,qBAAqB,QAAQ,CAACtB;QAC9BuB,iBAAiB,QAAQ,CAACvB;QAC1BwB,oBAAoB,QAAQ,CAACxB;QAC7ByB,sBAAsB,QAAQ,CAACzB;QAC/B0B,sBAAsB,QAAQ,CAAC1B;QAC/B2B,mBAAmB,QAAQ,CAAC3B;QAC5B4B,2BAA2B,QAAQ,CAAC5B;QACpC6B,6BAA6B,QAAQ,CAAC7B;QACtC8B,2BAA2B,QAAQ,CAAC9B;QACpC+B,4BAA4B,QAAQ,CAAC/B;IACzC;AACJ"}
|
|
@@ -3,7 +3,7 @@ import { CreateEntryRepository, CreateEntryUseCase } from "./abstractions.js";
|
|
|
3
3
|
import { EventPublisher } from "@webiny/api-core/features/eventPublisher/index.js";
|
|
4
4
|
import { EntryAfterCreateEvent, EntryBeforeCreateEvent } from "./events.js";
|
|
5
5
|
import { AccessControl } from "../../shared/abstractions.js";
|
|
6
|
-
import { EntryNotAuthorizedError
|
|
6
|
+
import { EntryNotAuthorizedError } from "../../../domain/contentEntry/errors.js";
|
|
7
7
|
import { CreateEntryDataFactory } from "../entryDataFactories/CreateEntryDataFactory/index.js";
|
|
8
8
|
class CreateEntryUseCaseImpl {
|
|
9
9
|
constructor(eventPublisher, repository, accessControl, createEntryDataFactory){
|
|
@@ -40,7 +40,6 @@ class CreateEntryUseCaseImpl {
|
|
|
40
40
|
}));
|
|
41
41
|
return Result.ok(entry);
|
|
42
42
|
} catch (error) {
|
|
43
|
-
if ("VALIDATION_FAILED" === error.code) return Result.fail(new EntryValidationError(error.message, error.data));
|
|
44
43
|
return Result.fail(error);
|
|
45
44
|
}
|
|
46
45
|
}
|