@webiny/api-headless-cms 6.5.2-beta.0 → 6.5.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.js +26 -19
- package/context.js.map +1 -1
- package/crud/AccessControl/AccessControl.d.ts +5 -0
- package/crud/AccessControl/AccessControl.js +4 -0
- package/crud/AccessControl/AccessControl.js.map +1 -1
- package/crud/contentEntry/references/validateEntries.js +14 -4
- package/crud/contentEntry/references/validateEntries.js.map +1 -1
- package/crud/contentModel/validation.js +4 -4
- package/crud/contentModel/validation.js.map +1 -1
- package/domain/contentEntry/errors.d.ts +4 -0
- package/domain/contentEntry/errors.js +8 -1
- package/domain/contentEntry/errors.js.map +1 -1
- package/domain/contentModel/schemas.js +3 -3
- package/domain/contentModel/schemas.js.map +1 -1
- package/domain/contentModelGroup/validation.js +2 -2
- package/domain/contentModelGroup/validation.js.map +1 -1
- package/export/crud/importing.js +12 -0
- package/export/crud/importing.js.map +1 -1
- package/export/graphql/index.js +1 -0
- package/export/graphql/index.js.map +1 -1
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.d.ts +12 -2
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js +18 -4
- package/features/contentEntry/CreateEntry/CreateEntryUseCase.js.map +1 -1
- package/features/contentEntry/CreateEntry/abstractions.d.ts +2 -1
- package/features/contentEntry/CreateEntry/abstractions.js.map +1 -1
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js +6 -0
- package/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js +4 -1
- package/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js.map +1 -1
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.d.ts +9 -2
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js +26 -4
- package/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js.map +1 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js +2 -1
- package/features/contentEntry/DeleteMultipleEntries/DeleteMultipleEntriesUseCase.js.map +1 -1
- package/features/contentEntry/DuplicateEntry/abstractions.d.ts +2 -1
- package/features/contentEntry/DuplicateEntry/abstractions.js.map +1 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetEntriesByIds/GetEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetLatestEntriesByIds/GetLatestEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js +5 -1
- package/features/contentEntry/GetLatestRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js +5 -1
- package/features/contentEntry/GetPreviousRevisionByEntryId/BaseUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js +3 -1
- package/features/contentEntry/GetPublishedEntriesByIds/GetPublishedEntriesByIdsUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.d.ts +5 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js +16 -3
- package/features/contentEntry/GetPublishedRevisionByEntryId/GetPublishedRevisionByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/abstractions.d.ts +2 -1
- package/features/contentEntry/GetPublishedRevisionByEntryId/abstractions.js.map +1 -1
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.d.ts +7 -2
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js +18 -4
- package/features/contentEntry/GetRevisionById/GetRevisionByIdUseCase.js.map +1 -1
- package/features/contentEntry/GetRevisionById/abstractions.d.ts +4 -2
- package/features/contentEntry/GetRevisionById/abstractions.js.map +1 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js +3 -1
- package/features/contentEntry/GetRevisionsByEntryId/GetRevisionsByEntryIdUseCase.js.map +1 -1
- package/features/contentEntry/GetSingletonEntry/abstractions.d.ts +2 -1
- package/features/contentEntry/GetSingletonEntry/abstractions.js.map +1 -1
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js +17 -6
- package/features/contentEntry/UpdateEntry/UpdateEntryUseCase.js.map +1 -1
- package/features/contentEntry/UpdateSingletonEntry/abstractions.d.ts +2 -1
- package/features/contentEntry/UpdateSingletonEntry/abstractions.js.map +1 -1
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js +34 -28
- package/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/CreateEntryRevisionFromDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.d.ts +3 -2
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js +39 -31
- package/features/contentEntry/entryDataFactories/UpdateEntryDataFactory/UpdateEntryDataFactory.js.map +1 -1
- package/features/contentEntry/entryDataFactories/canOverrideMetaFields.d.ts +16 -0
- package/features/contentEntry/entryDataFactories/canOverrideMetaFields.js +11 -0
- package/features/contentEntry/entryDataFactories/canOverrideMetaFields.js.map +1 -0
- package/features/contentEntry/shared/entryOwnerAccess.d.ts +15 -0
- package/features/contentEntry/shared/entryOwnerAccess.js +21 -0
- package/features/contentEntry/shared/entryOwnerAccess.js.map +1 -0
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js +2 -1
- package/features/contentModel/CreateModelFrom/CreateModelFromUseCase.js.map +1 -1
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.d.ts +3 -3
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js +6 -5
- package/features/contentModel/RefModelsGenerator/RefModelsGenerator.js.map +1 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.d.ts +3 -1
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js +20 -3
- package/features/contentModel/UpdateModel/UpdateModelUseCase.js.map +1 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js +2 -1
- package/features/contentModelGroup/DeleteGroup/DeleteGroupUseCase.js.map +1 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js +2 -1
- package/features/contentModelGroup/UpdateGroup/UpdateGroupUseCase.js.map +1 -1
- package/features/graphql/fields/base/RefToGraphQL.js +2 -0
- package/features/graphql/fields/base/RefToGraphQL.js.map +1 -1
- package/features/storage/fields/CompressedTextStorageTransform.js +2 -1
- package/features/storage/fields/CompressedTextStorageTransform.js.map +1 -1
- package/graphql/generateSchema.js +4 -0
- package/graphql/generateSchema.js.map +1 -1
- package/graphql/handleRequest.js +18 -9
- package/graphql/handleRequest.js.map +1 -1
- package/graphql/schema/cms/getModelResolver.js +14 -0
- package/graphql/schema/cms/getModelResolver.js.map +1 -1
- package/graphql/schema/cms/helpers/getModel.js +1 -1
- package/graphql/schema/cms/helpers/getModel.js.map +1 -1
- package/graphql/schema/contentEntries.js +15 -5
- package/graphql/schema/contentEntries.js.map +1 -1
- package/graphql/schema/contentModelGroups.js +11 -12
- package/graphql/schema/contentModelGroups.js.map +1 -1
- package/graphql/schema/contentModels.js +1 -1
- package/graphql/schema/contentModels.js.map +1 -1
- package/package.json +25 -25
- package/types/types.d.ts +5 -0
- package/types/types.js.map +1 -1
|
@@ -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 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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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,KAAK,CAACC,aAAa,QAAQ,GAAG,OAAO,CAAC,EAAE;IAClD,MAAMD,IAAAA,OACM,GACP,QAAQ,GACR,OAAO,GACP,SAAS,CAACQ,CAAAA,QACA,CAAC,CAACA,OAEZ,OAAO,CAAC;IACb,UAAUR,IAAAA,OACE,GACP,QAAQ,GACR,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D,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;IACJ"}
|
|
@@ -19,11 +19,11 @@ const createGroupCreateValidation = ()=>zod.object({
|
|
|
19
19
|
name: validation_name.min(1),
|
|
20
20
|
slug: str.max(100).optional().transform((value)=>value ? toSlug(value) : ""),
|
|
21
21
|
description: description.transform((value)=>value || ""),
|
|
22
|
-
icon
|
|
22
|
+
icon
|
|
23
23
|
});
|
|
24
24
|
const createGroupUpdateValidation = ()=>zod.object({
|
|
25
25
|
name: validation_name.optional(),
|
|
26
|
-
description
|
|
26
|
+
description,
|
|
27
27
|
icon: icon.optional()
|
|
28
28
|
});
|
|
29
29
|
export { createGroupCreateValidation, createGroupUpdateValidation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domain/contentModelGroup/validation.js","sources":["../../../src/domain/contentModelGroup/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { toSlug } from \"~/utils/toSlug.js\";\n\nconst str = zod.string().trim();\n\nconst name = str.max(100);\nconst description = str.max(255).optional().nullish();\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 });\nexport const createGroupCreateValidation = () => {\n return zod.object({\n id: str.optional().nullish(),\n name: name.min(1),\n slug: str\n .max(100)\n .optional()\n .transform(value => {\n return value ? toSlug(value) : \"\";\n }),\n description: description.transform(value => {\n return value || \"\";\n }),\n icon\n });\n};\n\nexport const createGroupUpdateValidation = () => {\n return zod.object({\n name: name.optional(),\n description,\n icon: icon.optional()\n });\n};\n"],"names":["str","zod","name","description","icon","value","createGroupCreateValidation","toSlug","createGroupUpdateValidation"],"mappings":";;AAGA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAE7B,MAAMC,kBAAOF,IAAI,GAAG,CAAC;AACrB,MAAMG,cAAcH,IAAI,GAAG,CAAC,KAAK,QAAQ,GAAG,OAAO;AACnD,MAAMI,OAAOH,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,CAACI,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AACG,MAAMC,8BAA8B,IAChCL,IAAI,MAAM,CAAC;QACd,IAAID,IAAI,QAAQ,GAAG,OAAO;QAC1B,MAAME,gBAAK,GAAG,CAAC;QACf,MAAMF,IACD,GAAG,CAAC,KACJ,QAAQ,GACR,SAAS,CAACK,CAAAA,QACAA,QAAQE,OAAOF,SAAS;QAEvC,aAAaF,YAAY,SAAS,CAACE,CAAAA,QACxBA,SAAS;QAEpBD
|
|
1
|
+
{"version":3,"file":"domain/contentModelGroup/validation.js","sources":["../../../src/domain/contentModelGroup/validation.ts"],"sourcesContent":["import zod from \"zod\";\nimport { toSlug } from \"~/utils/toSlug.js\";\n\nconst str = zod.string().trim();\n\nconst name = str.max(100);\nconst description = str.max(255).optional().nullish();\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 });\nexport const createGroupCreateValidation = () => {\n return zod.object({\n id: str.optional().nullish(),\n name: name.min(1),\n slug: str\n .max(100)\n .optional()\n .transform(value => {\n return value ? toSlug(value) : \"\";\n }),\n description: description.transform(value => {\n return value || \"\";\n }),\n icon\n });\n};\n\nexport const createGroupUpdateValidation = () => {\n return zod.object({\n name: name.optional(),\n description,\n icon: icon.optional()\n });\n};\n"],"names":["str","zod","name","description","icon","value","createGroupCreateValidation","toSlug","createGroupUpdateValidation"],"mappings":";;AAGA,MAAMA,MAAMC,IAAI,MAAM,GAAG,IAAI;AAE7B,MAAMC,kBAAOF,IAAI,GAAG,CAAC;AACrB,MAAMG,cAAcH,IAAI,GAAG,CAAC,KAAK,QAAQ,GAAG,OAAO;AACnD,MAAMI,OAAOH,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,CAACI,CAAAA;IACP,IAAI,AAAiB,YAAjB,OAAOA,OACP,OAAO;QACH,MAAM;QACN,MAAMA;IACV;IAEJ,OAAOA;AACX;AACG,MAAMC,8BAA8B,IAChCL,IAAI,MAAM,CAAC;QACd,IAAID,IAAI,QAAQ,GAAG,OAAO;QAC1B,MAAME,gBAAK,GAAG,CAAC;QACf,MAAMF,IACD,GAAG,CAAC,KACJ,QAAQ,GACR,SAAS,CAACK,CAAAA,QACAA,QAAQE,OAAOF,SAAS;QAEvC,aAAaF,YAAY,SAAS,CAACE,CAAAA,QACxBA,SAAS;QAEpBD;IACJ;AAGG,MAAMI,8BAA8B,IAChCP,IAAI,MAAM,CAAC;QACd,MAAMC,gBAAK,QAAQ;QACnBC;QACA,MAAMC,KAAK,QAAQ;IACvB"}
|
package/export/crud/importing.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import _webiny_error from "@webiny/error";
|
|
2
|
+
import { NotAuthorizedError } from "../../utils/errors.js";
|
|
2
3
|
import { importData } from "./imports/importData.js";
|
|
3
4
|
import { validateInput } from "./imports/validateInput.js";
|
|
4
5
|
const fetchGroupsAndModels = async (context)=>await context.security.withoutAuthorization(async ()=>({
|
|
5
6
|
groups: await context.cms.listGroups(),
|
|
6
7
|
models: await context.cms.listModels()
|
|
7
8
|
}));
|
|
9
|
+
const ensureCanImport = async (context)=>{
|
|
10
|
+
const canWriteGroups = await context.cms.accessControl.canAccessGroup({
|
|
11
|
+
rwd: "w"
|
|
12
|
+
});
|
|
13
|
+
const canWriteModels = await context.cms.accessControl.canAccessModel({
|
|
14
|
+
rwd: "w"
|
|
15
|
+
});
|
|
16
|
+
if (!canWriteGroups || !canWriteModels) throw new NotAuthorizedError("Not allowed to import content model groups and models.");
|
|
17
|
+
};
|
|
8
18
|
const createImportCrud = (context)=>({
|
|
9
19
|
validate: async (params)=>{
|
|
10
20
|
const { data } = params;
|
|
21
|
+
await ensureCanImport(context);
|
|
11
22
|
const { groups, models } = await fetchGroupsAndModels(context);
|
|
12
23
|
const validated = await validateInput({
|
|
13
24
|
groups,
|
|
@@ -27,6 +38,7 @@ const createImportCrud = (context)=>({
|
|
|
27
38
|
},
|
|
28
39
|
structure: async (params)=>{
|
|
29
40
|
const { data } = params;
|
|
41
|
+
await ensureCanImport(context);
|
|
30
42
|
const { groups, models } = await fetchGroupsAndModels(context);
|
|
31
43
|
const validated = await validateInput({
|
|
32
44
|
groups,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.security.withoutAuthorization(async () => {\n return {\n groups: await context.cms.listGroups(),\n models: await context.cms.listModels()\n };\n });\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"names":["fetchGroupsAndModels","context","createImportCrud","params","data","groups","models","validated","validateInput","WebinyError","imported","importData","modelError","model","error"],"mappings":"
|
|
1
|
+
{"version":3,"file":"export/crud/importing.js","sources":["../../../src/export/crud/importing.ts"],"sourcesContent":["import WebinyError from \"@webiny/error\";\nimport { NotAuthorizedError } from \"~/utils/errors.js\";\nimport type {\n HeadlessCmsImport,\n ValidCmsGroupResult,\n ValidCmsModelResult\n} from \"~/export/types.js\";\nimport type { CmsContext } from \"~/types/index.js\";\nimport { importData } from \"./imports/importData.js\";\nimport { validateInput } from \"./imports/validateInput.js\";\n\nconst fetchGroupsAndModels = async (context: CmsContext) => {\n return await context.security.withoutAuthorization(async () => {\n return {\n groups: await context.cms.listGroups(),\n models: await context.cms.listModels()\n };\n });\n};\n\n/**\n * Validation reads all groups and models, so require the access an import needs before doing\n * anything. Security: without this, the structure import was an existence oracle for groups and\n * models the identity cannot access.\n */\nconst ensureCanImport = async (context: CmsContext) => {\n const canWriteGroups = await context.cms.accessControl.canAccessGroup({ rwd: \"w\" });\n const canWriteModels = await context.cms.accessControl.canAccessModel({ rwd: \"w\" });\n if (!canWriteGroups || !canWriteModels) {\n throw new NotAuthorizedError(\"Not allowed to import content model groups and models.\");\n }\n};\n\nexport const createImportCrud = (context: CmsContext): HeadlessCmsImport => {\n return {\n validate: async params => {\n const { data } = params;\n\n await ensureCanImport(context);\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n return {\n groups: validated.groups,\n models: validated.models,\n message: validated.error\n };\n }\n\n return {\n groups: validated.groups,\n models: validated.models,\n message: \"Validation done.\"\n };\n },\n structure: async params => {\n const { data } = params;\n\n await ensureCanImport(context);\n\n const { groups, models } = await fetchGroupsAndModels(context);\n\n const validated = await validateInput({\n groups,\n models,\n data\n });\n if (validated.error) {\n throw new WebinyError(validated.error, \"VALIDATION_ERROR\");\n }\n\n const imported = await importData({\n context,\n groups: validated.groups as ValidCmsGroupResult[],\n models: validated.models as ValidCmsModelResult[]\n });\n\n const modelError = imported.models.find(model => !!model.error);\n const error = imported.error || modelError;\n\n return {\n ...imported,\n message: error ? null : \"Import done.\"\n };\n }\n };\n};\n"],"names":["fetchGroupsAndModels","context","ensureCanImport","canWriteGroups","canWriteModels","NotAuthorizedError","createImportCrud","params","data","groups","models","validated","validateInput","WebinyError","imported","importData","modelError","model","error"],"mappings":";;;;AAWA,MAAMA,uBAAuB,OAAOC,UACzB,MAAMA,QAAQ,QAAQ,CAAC,oBAAoB,CAAC,UACxC;YACH,QAAQ,MAAMA,QAAQ,GAAG,CAAC,UAAU;YACpC,QAAQ,MAAMA,QAAQ,GAAG,CAAC,UAAU;QACxC;AASR,MAAMC,kBAAkB,OAAOD;IAC3B,MAAME,iBAAiB,MAAMF,QAAQ,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC;QAAE,KAAK;IAAI;IACjF,MAAMG,iBAAiB,MAAMH,QAAQ,GAAG,CAAC,aAAa,CAAC,cAAc,CAAC;QAAE,KAAK;IAAI;IACjF,IAAI,CAACE,kBAAkB,CAACC,gBACpB,MAAM,IAAIC,mBAAmB;AAErC;AAEO,MAAMC,mBAAmB,CAACL,UACtB;QACH,UAAU,OAAMM;YACZ,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAML,gBAAgBD;YAEtB,MAAM,EAAEQ,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMV,qBAAqBC;YAEtD,MAAMU,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAASA,UAAU,KAAK;YAC5B;YAGJ,OAAO;gBACH,QAAQA,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;gBACxB,SAAS;YACb;QACJ;QACA,WAAW,OAAMJ;YACb,MAAM,EAAEC,IAAI,EAAE,GAAGD;YAEjB,MAAML,gBAAgBD;YAEtB,MAAM,EAAEQ,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAMV,qBAAqBC;YAEtD,MAAMU,YAAY,MAAMC,cAAc;gBAClCH;gBACAC;gBACAF;YACJ;YACA,IAAIG,UAAU,KAAK,EACf,MAAM,IAAIE,cAAYF,UAAU,KAAK,EAAE;YAG3C,MAAMG,WAAW,MAAMC,WAAW;gBAC9Bd;gBACA,QAAQU,UAAU,MAAM;gBACxB,QAAQA,UAAU,MAAM;YAC5B;YAEA,MAAMK,aAAaF,SAAS,MAAM,CAAC,IAAI,CAACG,CAAAA,QAAS,CAAC,CAACA,MAAM,KAAK;YAC9D,MAAMC,QAAQJ,SAAS,KAAK,IAAIE;YAEhC,OAAO;gBACH,GAAGF,QAAQ;gBACX,SAASI,QAAQ,OAAO;YAC5B;QACJ;IACJ"}
|
package/export/graphql/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { createCmsGraphQLSchemaPlugin } from "../../plugins/index.js";
|
|
|
2
2
|
import { ErrorResponse, Response } from "@webiny/handler-graphql";
|
|
3
3
|
import { ContextPlugin } from "@webiny/handler";
|
|
4
4
|
const graphql_plugin = createCmsGraphQLSchemaPlugin({
|
|
5
|
+
isApplicable: (context)=>context.cms.MANAGE,
|
|
5
6
|
typeDefs: `
|
|
6
7
|
type CmsExportStructureResponse {
|
|
7
8
|
data: String
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"export/graphql/index.js","sources":["../../../src/export/graphql/index.ts"],"sourcesContent":["import { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport type { CmsContext } from \"~/types/index.js\";\n\nconst plugin = createCmsGraphQLSchemaPlugin({\n typeDefs: /* GraphQL */ `\n type CmsExportStructureResponse {\n data: String\n error: CmsError\n }\n\n input CmsImportStructureGroupInput {\n id: ID!\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n input CmsImportStructureModelInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n group: String!\n icon: Icon\n description: String\n layout: JSON!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String!\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n enum CmsImportGroupStructureAction {\n create\n update\n code\n none\n }\n\n enum CmsImportModelStructureAction {\n create\n update\n code\n none\n }\n\n input CmsImportStructureInput {\n groups: [CmsImportStructureGroupInput!]!\n models: [CmsImportStructureModelInput!]!\n }\n\n type CmsImportValidateResponseDataGroupResultItem {\n id: String\n name: String\n slug: String\n }\n\n type CmsImportValidateResponseDataGroupResult {\n group: CmsImportValidateResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n }\n\n type CmsImportValidateResponseDataModelResultItem {\n modelId: String\n name: String\n group: String\n }\n\n type CmsImportValidateResponseDataModelResult {\n model: CmsImportValidateResponseDataModelResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n }\n\n type CmsImportValidateResponseData {\n groups: [CmsImportValidateResponseDataGroupResult!]!\n models: [CmsImportValidateResponseDataModelResult!]!\n message: String!\n }\n\n type CmsImportValidateResponse {\n data: CmsImportValidateResponseData\n error: CmsError\n }\n\n type CmsImportStructureResponseDataGroupResultItem {\n id: String!\n name: String!\n }\n type CmsImportStructureResponseDataGroupResult {\n group: CmsImportStructureResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseDataResultItem {\n modelId: String!\n name: String!\n group: String!\n }\n\n type CmsImportStructureResponseDataModelResult {\n model: CmsImportStructureResponseDataResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseData {\n groups: [CmsImportStructureResponseDataGroupResult!]!\n models: [CmsImportStructureResponseDataModelResult!]!\n message: String\n }\n\n type CmsImportStructureResponse {\n data: CmsImportStructureResponseData\n error: CmsError\n }\n\n extend type Query {\n exportStructure(models: [String!]): CmsExportStructureResponse!\n }\n\n extend type Mutation {\n validateImportStructure(data: CmsImportStructureInput!): CmsImportValidateResponse!\n importStructure(data: CmsImportStructureInput!): CmsImportStructureResponse!\n }\n `,\n resolvers: {\n Query: {\n exportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.export.structure({\n models: args.models\n });\n return new Response(JSON.stringify(result));\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n },\n Mutation: {\n validateImportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.validate({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n importStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.structure({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n }\n }\n});\nplugin.name = \"headless-cms.graphql.export\";\n\nexport const createExportGraphQL = () => {\n return new ContextPlugin<CmsContext>(async context => {\n if (!context.cms.MANAGE) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"names":["plugin","createCmsGraphQLSchemaPlugin","
|
|
1
|
+
{"version":3,"file":"export/graphql/index.js","sources":["../../../src/export/graphql/index.ts"],"sourcesContent":["import { createCmsGraphQLSchemaPlugin } from \"~/plugins/index.js\";\nimport { ErrorResponse, Response } from \"@webiny/handler-graphql\";\nimport { ContextPlugin } from \"@webiny/handler\";\nimport type { CmsContext } from \"~/types/index.js\";\n\nconst plugin = createCmsGraphQLSchemaPlugin({\n // Security: manage-only; a read/preview schema can be generated within a manage request.\n isApplicable: context => context.cms.MANAGE,\n typeDefs: /* GraphQL */ `\n type CmsExportStructureResponse {\n data: String\n error: CmsError\n }\n\n input CmsImportStructureGroupInput {\n id: ID!\n name: String!\n slug: String\n description: String\n icon: Icon!\n }\n\n input CmsImportStructureModelInput {\n name: String!\n singularApiName: String!\n pluralApiName: String!\n modelId: String!\n group: String!\n icon: Icon\n description: String\n layout: JSON!\n fields: [CmsContentModelFieldInput!]!\n titleFieldId: String!\n descriptionFieldId: String\n imageFieldId: String\n tags: [String!]\n }\n\n enum CmsImportGroupStructureAction {\n create\n update\n code\n none\n }\n\n enum CmsImportModelStructureAction {\n create\n update\n code\n none\n }\n\n input CmsImportStructureInput {\n groups: [CmsImportStructureGroupInput!]!\n models: [CmsImportStructureModelInput!]!\n }\n\n type CmsImportValidateResponseDataGroupResultItem {\n id: String\n name: String\n slug: String\n }\n\n type CmsImportValidateResponseDataGroupResult {\n group: CmsImportValidateResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n }\n\n type CmsImportValidateResponseDataModelResultItem {\n modelId: String\n name: String\n group: String\n }\n\n type CmsImportValidateResponseDataModelResult {\n model: CmsImportValidateResponseDataModelResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n }\n\n type CmsImportValidateResponseData {\n groups: [CmsImportValidateResponseDataGroupResult!]!\n models: [CmsImportValidateResponseDataModelResult!]!\n message: String!\n }\n\n type CmsImportValidateResponse {\n data: CmsImportValidateResponseData\n error: CmsError\n }\n\n type CmsImportStructureResponseDataGroupResultItem {\n id: String!\n name: String!\n }\n type CmsImportStructureResponseDataGroupResult {\n group: CmsImportStructureResponseDataGroupResultItem!\n error: CmsError\n action: CmsImportGroupStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseDataResultItem {\n modelId: String!\n name: String!\n group: String!\n }\n\n type CmsImportStructureResponseDataModelResult {\n model: CmsImportStructureResponseDataResultItem!\n related: [String!]\n error: CmsError\n action: CmsImportModelStructureAction\n imported: Boolean\n }\n\n type CmsImportStructureResponseData {\n groups: [CmsImportStructureResponseDataGroupResult!]!\n models: [CmsImportStructureResponseDataModelResult!]!\n message: String\n }\n\n type CmsImportStructureResponse {\n data: CmsImportStructureResponseData\n error: CmsError\n }\n\n extend type Query {\n exportStructure(models: [String!]): CmsExportStructureResponse!\n }\n\n extend type Mutation {\n validateImportStructure(data: CmsImportStructureInput!): CmsImportValidateResponse!\n importStructure(data: CmsImportStructureInput!): CmsImportStructureResponse!\n }\n `,\n resolvers: {\n Query: {\n exportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.export.structure({\n models: args.models\n });\n return new Response(JSON.stringify(result));\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n },\n Mutation: {\n validateImportStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.validate({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n },\n importStructure: async (_, args, context) => {\n try {\n const result = await context.cms.importing.structure({\n data: args.data\n });\n return new Response(result);\n } catch (ex) {\n return new ErrorResponse(ex);\n }\n }\n }\n }\n});\nplugin.name = \"headless-cms.graphql.export\";\n\nexport const createExportGraphQL = () => {\n return new ContextPlugin<CmsContext>(async context => {\n if (!context.cms.MANAGE) {\n return;\n }\n context.plugins.register(plugin);\n });\n};\n"],"names":["plugin","createCmsGraphQLSchemaPlugin","context","_","args","result","Response","JSON","ex","ErrorResponse","createExportGraphQL","ContextPlugin"],"mappings":";;;AAKA,MAAMA,iBAAS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}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { CreateEntryRepository, CreateEntryUseCase as UseCaseAbstraction } from "./abstractions.js";
|
|
3
3
|
import { EntryEventPublisher } from "../../../features/contentEntry/EntryEventPublisher/index.js";
|
|
4
|
-
import { AccessControl } from "../../../features/shared/abstractions.js";
|
|
4
|
+
import { AccessControl, StorageOperations } from "../../../features/shared/abstractions.js";
|
|
5
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
5
6
|
import type { CmsEntry, CmsEntryValues, CmsModel, CreateCmsEntryInput, CreateCmsEntryOptionsInput } from "../../../types/index.js";
|
|
6
7
|
import { CreateEntryDataFactory } from "../../../features/contentEntry/entryDataFactories/CreateEntryDataFactory/index.js";
|
|
7
8
|
declare class CreateEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
@@ -9,8 +10,17 @@ declare class CreateEntryUseCaseImpl implements UseCaseAbstraction.Interface {
|
|
|
9
10
|
private repository;
|
|
10
11
|
private accessControl;
|
|
11
12
|
private createEntryDataFactory;
|
|
12
|
-
|
|
13
|
+
private storageOperations;
|
|
14
|
+
private identityContext;
|
|
15
|
+
constructor(eventPublisher: EntryEventPublisher.Interface, repository: CreateEntryRepository.Interface, accessControl: AccessControl.Interface, createEntryDataFactory: CreateEntryDataFactory.Interface, storageOperations: StorageOperations.Interface, identityContext: IdentityContext.Interface);
|
|
13
16
|
execute<T extends CmsEntryValues = CmsEntryValues>(model: CmsModel, rawInput: CreateCmsEntryInput<T>, options?: CreateCmsEntryOptionsInput): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>>;
|
|
17
|
+
/**
|
|
18
|
+
* A caller-provided id must not point at an existing entry: storage writes the new revision
|
|
19
|
+
* over it, and the caller would take over someone else's entry. Deleted entries count too.
|
|
20
|
+
* Code running without authorization (imports, internal records that are re-created on
|
|
21
|
+
* purpose) is left alone, and so are private models unless the caller opts in.
|
|
22
|
+
*/
|
|
23
|
+
private isTakenEntryId;
|
|
14
24
|
}
|
|
15
25
|
export declare const CreateEntryUseCase: import("@webiny/di").Implementation<typeof CreateEntryUseCaseImpl>;
|
|
16
26
|
export {};
|
|
@@ -2,15 +2,18 @@ import { Result, createImplementation } from "@webiny/feature/api";
|
|
|
2
2
|
import { CreateEntryRepository, CreateEntryUseCase } from "./abstractions.js";
|
|
3
3
|
import { EntryEventPublisher } from "../EntryEventPublisher/index.js";
|
|
4
4
|
import { EntryAfterCreateEvent, EntryBeforeCreateEvent } from "./events.js";
|
|
5
|
-
import { AccessControl } from "../../shared/abstractions.js";
|
|
6
|
-
import {
|
|
5
|
+
import { AccessControl, StorageOperations } from "../../shared/abstractions.js";
|
|
6
|
+
import { IdentityContext } from "@webiny/api-core/features/security/IdentityContext/index.js";
|
|
7
|
+
import { EntryAlreadyExistsError, EntryNotAuthorizedError } from "../../../domain/contentEntry/errors.js";
|
|
7
8
|
import { CreateEntryDataFactory } from "../entryDataFactories/CreateEntryDataFactory/index.js";
|
|
8
9
|
class CreateEntryUseCaseImpl {
|
|
9
|
-
constructor(eventPublisher, repository, accessControl, createEntryDataFactory){
|
|
10
|
+
constructor(eventPublisher, repository, accessControl, createEntryDataFactory, storageOperations, identityContext){
|
|
10
11
|
this.eventPublisher = eventPublisher;
|
|
11
12
|
this.repository = repository;
|
|
12
13
|
this.accessControl = accessControl;
|
|
13
14
|
this.createEntryDataFactory = createEntryDataFactory;
|
|
15
|
+
this.storageOperations = storageOperations;
|
|
16
|
+
this.identityContext = identityContext;
|
|
14
17
|
}
|
|
15
18
|
async execute(model, rawInput, options) {
|
|
16
19
|
const canAccess = await this.accessControl.canAccessEntry({
|
|
@@ -26,6 +29,7 @@ class CreateEntryUseCaseImpl {
|
|
|
26
29
|
rwd: "w"
|
|
27
30
|
});
|
|
28
31
|
if (!canAccessEntry) return Result.fail(EntryNotAuthorizedError.fromEntry(entry));
|
|
32
|
+
if (await this.isTakenEntryId(model, rawInput, entry.entryId, options)) return Result.fail(new EntryAlreadyExistsError(entry.entryId));
|
|
29
33
|
await this.eventPublisher.publish(new EntryBeforeCreateEvent({
|
|
30
34
|
entry,
|
|
31
35
|
input,
|
|
@@ -43,6 +47,14 @@ class CreateEntryUseCaseImpl {
|
|
|
43
47
|
return Result.fail(error);
|
|
44
48
|
}
|
|
45
49
|
}
|
|
50
|
+
async isTakenEntryId(model, rawInput, entryId, options) {
|
|
51
|
+
if (!rawInput.id || !this.identityContext.isAuthorizationEnabled()) return false;
|
|
52
|
+
if (model.isPrivate && !options?.failIfExists) return false;
|
|
53
|
+
const existing = await this.storageOperations.entries.getLatestRevisionByEntryId(model, {
|
|
54
|
+
id: entryId
|
|
55
|
+
});
|
|
56
|
+
return !!existing;
|
|
57
|
+
}
|
|
46
58
|
}
|
|
47
59
|
const CreateEntryUseCase_CreateEntryUseCase = createImplementation({
|
|
48
60
|
abstraction: CreateEntryUseCase,
|
|
@@ -51,7 +63,9 @@ const CreateEntryUseCase_CreateEntryUseCase = createImplementation({
|
|
|
51
63
|
EntryEventPublisher,
|
|
52
64
|
CreateEntryRepository,
|
|
53
65
|
AccessControl,
|
|
54
|
-
CreateEntryDataFactory
|
|
66
|
+
CreateEntryDataFactory,
|
|
67
|
+
StorageOperations,
|
|
68
|
+
IdentityContext
|
|
55
69
|
]
|
|
56
70
|
});
|
|
57
71
|
export { CreateEntryUseCase_CreateEntryUseCase as CreateEntryUseCase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/CreateEntry/CreateEntryUseCase.js","sources":["../../../../src/features/contentEntry/CreateEntry/CreateEntryUseCase.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { CreateEntryRepository, CreateEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport { EntryAfterCreateEvent, EntryBeforeCreateEvent } from \"./events.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { CreateEntryDataFactory } from \"~/features/contentEntry/entryDataFactories/CreateEntryDataFactory/index.js\";\n\nclass CreateEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EntryEventPublisher.Interface,\n private repository: CreateEntryRepository.Interface,\n private accessControl: AccessControl.Interface,\n private createEntryDataFactory: CreateEntryDataFactory.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n const { entry, input } = await this.createEntryDataFactory.create<T>(\n model,\n rawInput,\n options\n );\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromEntry(entry));\n }\n\n await this.eventPublisher.publish(new EntryBeforeCreateEvent({ entry, input, model }));\n\n const result = await this.repository.execute(model, entry);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new EntryAfterCreateEvent({\n entry,\n input,\n model\n })\n );\n\n return Result.ok(entry);\n } catch (error) {\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const CreateEntryUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateEntryUseCaseImpl,\n dependencies: [\n EntryEventPublisher,\n CreateEntryRepository,\n AccessControl,\n CreateEntryDataFactory\n ]\n});\n"],"names":["CreateEntryUseCaseImpl","eventPublisher","repository","accessControl","createEntryDataFactory","model","rawInput","options","canAccess","Result","EntryNotAuthorizedError","entry","input","canAccessEntry","EntryBeforeCreateEvent","result","EntryAfterCreateEvent","error","CreateEntryUseCase","createImplementation","UseCaseAbstraction","EntryEventPublisher","CreateEntryRepository","AccessControl","CreateEntryDataFactory"],"mappings":"
|
|
1
|
+
{"version":3,"file":"features/contentEntry/CreateEntry/CreateEntryUseCase.js","sources":["../../../../src/features/contentEntry/CreateEntry/CreateEntryUseCase.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { CreateEntryRepository, CreateEntryUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport { EntryAfterCreateEvent, EntryBeforeCreateEvent } from \"./events.js\";\nimport { AccessControl, StorageOperations } from \"~/features/shared/abstractions.js\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport { EntryAlreadyExistsError, EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { CreateEntryDataFactory } from \"~/features/contentEntry/entryDataFactories/CreateEntryDataFactory/index.js\";\n\nclass CreateEntryUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private eventPublisher: EntryEventPublisher.Interface,\n private repository: CreateEntryRepository.Interface,\n private accessControl: AccessControl.Interface,\n private createEntryDataFactory: CreateEntryDataFactory.Interface,\n private storageOperations: StorageOperations.Interface,\n private identityContext: IdentityContext.Interface\n ) {}\n\n public async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n rawInput: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n const { entry, input } = await this.createEntryDataFactory.create<T>(\n model,\n rawInput,\n options\n );\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromEntry(entry));\n }\n\n if (await this.isTakenEntryId(model, rawInput, entry.entryId, options)) {\n return Result.fail(new EntryAlreadyExistsError(entry.entryId));\n }\n\n await this.eventPublisher.publish(new EntryBeforeCreateEvent({ entry, input, model }));\n\n const result = await this.repository.execute(model, entry);\n if (result.isFail()) {\n return Result.fail(result.error);\n }\n\n await this.eventPublisher.publish(\n new EntryAfterCreateEvent({\n entry,\n input,\n model\n })\n );\n\n return Result.ok(entry);\n } catch (error) {\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n\n /**\n * A caller-provided id must not point at an existing entry: storage writes the new revision\n * over it, and the caller would take over someone else's entry. Deleted entries count too.\n * Code running without authorization (imports, internal records that are re-created on\n * purpose) is left alone, and so are private models unless the caller opts in.\n */\n private async isTakenEntryId(\n model: CmsModel,\n rawInput: CreateCmsEntryInput,\n entryId: string,\n options?: CreateCmsEntryOptionsInput\n ): Promise<boolean> {\n if (!rawInput.id || !this.identityContext.isAuthorizationEnabled()) {\n return false;\n }\n if (model.isPrivate && !options?.failIfExists) {\n return false;\n }\n const existing = await this.storageOperations.entries.getLatestRevisionByEntryId(model, {\n id: entryId\n });\n return !!existing;\n }\n}\n\nexport const CreateEntryUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateEntryUseCaseImpl,\n dependencies: [\n EntryEventPublisher,\n CreateEntryRepository,\n AccessControl,\n CreateEntryDataFactory,\n StorageOperations,\n IdentityContext\n ]\n});\n"],"names":["CreateEntryUseCaseImpl","eventPublisher","repository","accessControl","createEntryDataFactory","storageOperations","identityContext","model","rawInput","options","canAccess","Result","EntryNotAuthorizedError","entry","input","canAccessEntry","EntryAlreadyExistsError","EntryBeforeCreateEvent","result","EntryAfterCreateEvent","error","entryId","existing","CreateEntryUseCase","createImplementation","UseCaseAbstraction","EntryEventPublisher","CreateEntryRepository","AccessControl","CreateEntryDataFactory","StorageOperations","IdentityContext"],"mappings":";;;;;;;;AAgBA,MAAMA;IACF,YACYC,cAA6C,EAC7CC,UAA2C,EAC3CC,aAAsC,EACtCC,sBAAwD,EACxDC,iBAA8C,EAC9CC,eAA0C,CACpD;aANUL,cAAc,GAAdA;aACAC,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,sBAAsB,GAAtBA;aACAC,iBAAiB,GAAjBA;aACAC,eAAe,GAAfA;IACT;IAEH,MAAa,QACTC,KAAe,EACfC,QAAgC,EAChCC,OAAoC,EACkB;QACtD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEH;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACG,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACL;QAGzD,IAAI;YACA,MAAM,EAAEM,KAAK,EAAEC,KAAK,EAAE,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAC7DP,OACAC,UACAC;YAGJ,MAAMM,iBAAiB,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;gBAC3DR;gBACAM;gBACA,KAAK;YACT;YAEA,IAAI,CAACE,gBACD,OAAOJ,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACC;YAGzD,IAAI,MAAM,IAAI,CAAC,cAAc,CAACN,OAAOC,UAAUK,MAAM,OAAO,EAAEJ,UAC1D,OAAOE,OAAO,IAAI,CAAC,IAAIK,wBAAwBH,MAAM,OAAO;YAGhE,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAII,uBAAuB;gBAAEJ;gBAAOC;gBAAOP;YAAM;YAEnF,MAAMW,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAACX,OAAOM;YACpD,IAAIK,OAAO,MAAM,IACb,OAAOP,OAAO,IAAI,CAACO,OAAO,KAAK;YAGnC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,sBAAsB;gBACtBN;gBACAC;gBACAP;YACJ;YAGJ,OAAOI,OAAO,EAAE,CAACE;QACrB,EAAE,OAAOO,OAAO;YACZ,OAAOT,OAAO,IAAI,CAACS;QACvB;IACJ;IAQA,MAAc,eACVb,KAAe,EACfC,QAA6B,EAC7Ba,OAAe,EACfZ,OAAoC,EACpB;QAChB,IAAI,CAACD,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,sBAAsB,IAC5D,OAAO;QAEX,IAAID,MAAM,SAAS,IAAI,CAACE,SAAS,cAC7B,OAAO;QAEX,MAAMa,WAAW,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,0BAA0B,CAACf,OAAO;YACpF,IAAIc;QACR;QACA,OAAO,CAAC,CAACC;IACb;AACJ;AAEO,MAAMC,wCAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBzB;IAChB,cAAc;QACV0B;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import type { CmsEntry, CmsEntryValues, CmsModel, CreateCmsEntryInput, CreateCmsEntryOptionsInput } from "../../../types/index.js";
|
|
3
|
-
import type { EntryNotAuthorizedError, EntryPersistenceError, EntryValidationError } from "../../../domain/contentEntry/errors.js";
|
|
3
|
+
import type { EntryAlreadyExistsError, EntryNotAuthorizedError, EntryPersistenceError, EntryValidationError } from "../../../domain/contentEntry/errors.js";
|
|
4
4
|
/**
|
|
5
5
|
* CreateEntry Use Case
|
|
6
6
|
*/
|
|
@@ -9,6 +9,7 @@ export interface ICreateEntryUseCase {
|
|
|
9
9
|
}
|
|
10
10
|
export interface ICreateEntryUseCaseErrors {
|
|
11
11
|
notAuthorized: EntryNotAuthorizedError;
|
|
12
|
+
alreadyExists: EntryAlreadyExistsError;
|
|
12
13
|
validation: EntryValidationError;
|
|
13
14
|
repository: RepositoryError;
|
|
14
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/CreateEntry/abstractions.js","sources":["../../../../src/features/contentEntry/CreateEntry/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport type {\n EntryNotAuthorizedError,\n EntryPersistenceError,\n EntryValidationError\n} from \"~/domain/contentEntry/errors.js\";\n\n/**\n * CreateEntry Use Case\n */\nexport interface ICreateEntryUseCase {\n execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseError>>;\n}\n\nexport interface ICreateEntryUseCaseErrors {\n notAuthorized: EntryNotAuthorizedError;\n validation: EntryValidationError;\n repository: RepositoryError;\n}\n\ntype UseCaseError = ICreateEntryUseCaseErrors[keyof ICreateEntryUseCaseErrors];\n\n/** Create a new content entry. */\nexport const CreateEntryUseCase = createAbstraction<ICreateEntryUseCase>(\"CreateEntryUseCase\");\n\nexport namespace CreateEntryUseCase {\n export type Interface = ICreateEntryUseCase;\n export type Input<T extends CmsEntryValues = CmsEntryValues> = CreateCmsEntryInput<T>;\n export type Options = CreateCmsEntryOptionsInput;\n\n export type Error = UseCaseError;\n export type Return<T extends CmsEntryValues = CmsEntryValues> = Promise<\n Result<CmsEntry<T>, UseCaseError>\n >;\n}\n\n/**\n * CreateEntryRepository - Persists a new entry to storage.\n * Takes a domain CmsEntry object and stores it.\n */\nexport interface ICreateEntryRepository {\n execute(model: CmsModel, entry: CmsEntry): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface ICreateEntryRepositoryErrors {\n storage: EntryPersistenceError;\n}\n\ntype RepositoryError = ICreateEntryRepositoryErrors[keyof ICreateEntryRepositoryErrors];\n\nexport const CreateEntryRepository =\n createAbstraction<ICreateEntryRepository>(\"CreateEntryRepository\");\n\nexport namespace CreateEntryRepository {\n export type Interface = ICreateEntryRepository;\n export type Error = RepositoryError;\n}\n"],"names":["CreateEntryUseCase","createAbstraction","CreateEntryRepository"],"mappings":";
|
|
1
|
+
{"version":3,"file":"features/contentEntry/CreateEntry/abstractions.js","sources":["../../../../src/features/contentEntry/CreateEntry/abstractions.ts"],"sourcesContent":["import { createAbstraction, Result } from \"@webiny/feature/api\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport type {\n EntryAlreadyExistsError,\n EntryNotAuthorizedError,\n EntryPersistenceError,\n EntryValidationError\n} from \"~/domain/contentEntry/errors.js\";\n\n/**\n * CreateEntry Use Case\n */\nexport interface ICreateEntryUseCase {\n execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n input: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseError>>;\n}\n\nexport interface ICreateEntryUseCaseErrors {\n notAuthorized: EntryNotAuthorizedError;\n alreadyExists: EntryAlreadyExistsError;\n validation: EntryValidationError;\n repository: RepositoryError;\n}\n\ntype UseCaseError = ICreateEntryUseCaseErrors[keyof ICreateEntryUseCaseErrors];\n\n/** Create a new content entry. */\nexport const CreateEntryUseCase = createAbstraction<ICreateEntryUseCase>(\"CreateEntryUseCase\");\n\nexport namespace CreateEntryUseCase {\n export type Interface = ICreateEntryUseCase;\n export type Input<T extends CmsEntryValues = CmsEntryValues> = CreateCmsEntryInput<T>;\n export type Options = CreateCmsEntryOptionsInput;\n\n export type Error = UseCaseError;\n export type Return<T extends CmsEntryValues = CmsEntryValues> = Promise<\n Result<CmsEntry<T>, UseCaseError>\n >;\n}\n\n/**\n * CreateEntryRepository - Persists a new entry to storage.\n * Takes a domain CmsEntry object and stores it.\n */\nexport interface ICreateEntryRepository {\n execute(model: CmsModel, entry: CmsEntry): Promise<Result<void, RepositoryError>>;\n}\n\nexport interface ICreateEntryRepositoryErrors {\n storage: EntryPersistenceError;\n}\n\ntype RepositoryError = ICreateEntryRepositoryErrors[keyof ICreateEntryRepositoryErrors];\n\nexport const CreateEntryRepository =\n createAbstraction<ICreateEntryRepository>(\"CreateEntryRepository\");\n\nexport namespace CreateEntryRepository {\n export type Interface = ICreateEntryRepository;\n export type Error = RepositoryError;\n}\n"],"names":["CreateEntryUseCase","createAbstraction","CreateEntryRepository"],"mappings":";AAoCO,MAAMA,qBAAqBC,kBAAuC;AA2BlE,MAAMC,wBACTD,kBAA0C"}
|
|
@@ -23,6 +23,12 @@ class CreateEntryRevisionFromUseCaseImpl {
|
|
|
23
23
|
const originalResult = await this.getRevisionById.execute(model, sourceId);
|
|
24
24
|
if (originalResult.isFail()) return Result.fail(originalResult.error);
|
|
25
25
|
const originalEntry = originalResult.value;
|
|
26
|
+
const canWriteOriginal = await this.accessControl.canAccessEntry({
|
|
27
|
+
model,
|
|
28
|
+
entry: originalEntry,
|
|
29
|
+
rwd: "w"
|
|
30
|
+
});
|
|
31
|
+
if (!canWriteOriginal) return Result.fail(EntryNotAuthorizedError.fromModel(model));
|
|
26
32
|
const dataResult = await this.createEntryRevisionFromDataFactory.create(sourceId, model, rawInput, originalEntry, options);
|
|
27
33
|
if (dataResult.isFail()) return Result.fail(dataResult.error);
|
|
28
34
|
const { entry, input } = dataResult.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js","sources":["../../../../src/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport {\n CreateEntryRevisionFromRepository,\n CreateEntryRevisionFromUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetRevisionByIdUseCase } from \"~/features/contentEntry/GetRevisionById/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport {\n EntryRevisionAfterCreateEvent,\n EntryRevisionBeforeCreateEvent,\n EntryRevisionCreateErrorEvent\n} from \"./events.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { CreateEntryRevisionFromDataFactory } from \"~/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/index.js\";\n\nclass CreateEntryRevisionFromUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: CreateEntryRevisionFromRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getRevisionById: GetRevisionByIdUseCase.Interface,\n private eventPublisher: EntryEventPublisher.Interface,\n private createEntryRevisionFromDataFactory: CreateEntryRevisionFromDataFactory.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n sourceId: string,\n rawInput: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n const originalResult = await this.getRevisionById.execute<T>(model, sourceId);\n\n if (originalResult.isFail()) {\n return Result.fail(originalResult.error);\n }\n\n const originalEntry = originalResult.value;\n\n const dataResult = await this.createEntryRevisionFromDataFactory.create<T>(\n sourceId,\n model,\n rawInput,\n originalEntry,\n options\n );\n if (dataResult.isFail()) {\n return Result.fail(dataResult.error);\n }\n const { entry, input } = dataResult.value;\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n await this.eventPublisher.publish(\n new EntryRevisionBeforeCreateEvent({\n entry,\n model,\n input,\n original: originalEntry\n })\n );\n\n const result = await this.repository.execute<T>(model, entry);\n\n if (result.isFail()) {\n await this.eventPublisher.publish(\n new EntryRevisionCreateErrorEvent({\n entry,\n model,\n input,\n original: originalEntry,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n const createdEntry = result.value;\n\n await this.eventPublisher.publish(\n new EntryRevisionAfterCreateEvent({\n entry: createdEntry,\n model,\n input,\n original: originalEntry\n })\n );\n\n return Result.ok(createdEntry);\n } catch (error) {\n await this.eventPublisher.publish(\n new EntryRevisionCreateErrorEvent({\n entry,\n model,\n input,\n original: originalEntry,\n error: error as Error\n })\n );\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const CreateEntryRevisionFromUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateEntryRevisionFromUseCaseImpl,\n dependencies: [\n CreateEntryRevisionFromRepository,\n AccessControl,\n GetRevisionByIdUseCase,\n EntryEventPublisher,\n CreateEntryRevisionFromDataFactory\n ]\n});\n"],"names":["CreateEntryRevisionFromUseCaseImpl","repository","accessControl","getRevisionById","eventPublisher","createEntryRevisionFromDataFactory","model","sourceId","rawInput","options","canAccess","Result","EntryNotAuthorizedError","originalResult","originalEntry","dataResult","entry","input","canAccessEntry","EntryRevisionBeforeCreateEvent","result","EntryRevisionCreateErrorEvent","createdEntry","EntryRevisionAfterCreateEvent","error","CreateEntryRevisionFromUseCase","createImplementation","UseCaseAbstraction","CreateEntryRevisionFromRepository","AccessControl","GetRevisionByIdUseCase","EntryEventPublisher","CreateEntryRevisionFromDataFactory"],"mappings":";;;;;;;;AAuBA,MAAMA;IACF,YACYC,UAAuD,EACvDC,aAAsC,EACtCC,eAAiD,EACjDC,cAA6C,EAC7CC,kCAAgF,CAC1F;aALUJ,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,kCAAkC,GAAlCA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,QAAgB,EAChBC,QAAgC,EAChCC,OAAoC,EACkB;QACtD,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEJ;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACI,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACN;QAGzD,MAAMO,iBAAiB,MAAM,IAAI,CAAC,eAAe,CAAC,OAAO,CAAIP,OAAOC;QAEpE,IAAIM,eAAe,MAAM,IACrB,OAAOF,OAAO,IAAI,CAACE,eAAe,KAAK;QAG3C,MAAMC,gBAAgBD,eAAe,KAAK;
|
|
1
|
+
{"version":3,"file":"features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.js","sources":["../../../../src/features/contentEntry/CreateEntryRevisionFrom/CreateEntryRevisionFromUseCase.ts"],"sourcesContent":["import { createImplementation, Result } from \"@webiny/feature/api\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport {\n CreateEntryRevisionFromRepository,\n CreateEntryRevisionFromUseCase as UseCaseAbstraction\n} from \"./abstractions.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetRevisionByIdUseCase } from \"~/features/contentEntry/GetRevisionById/index.js\";\nimport type {\n CmsEntry,\n CmsEntryValues,\n CmsModel,\n CreateCmsEntryInput,\n CreateCmsEntryOptionsInput\n} from \"~/types/index.js\";\nimport {\n EntryRevisionAfterCreateEvent,\n EntryRevisionBeforeCreateEvent,\n EntryRevisionCreateErrorEvent\n} from \"./events.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { CreateEntryRevisionFromDataFactory } from \"~/features/contentEntry/entryDataFactories/CreateEntryRevisionFromDataFactory/index.js\";\n\nclass CreateEntryRevisionFromUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: CreateEntryRevisionFromRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getRevisionById: GetRevisionByIdUseCase.Interface,\n private eventPublisher: EntryEventPublisher.Interface,\n private createEntryRevisionFromDataFactory: CreateEntryRevisionFromDataFactory.Interface\n ) {}\n\n async execute<T extends CmsEntryValues = CmsEntryValues>(\n model: CmsModel,\n sourceId: string,\n rawInput: CreateCmsEntryInput<T>,\n options?: CreateCmsEntryOptionsInput\n ): Promise<Result<CmsEntry<T>, UseCaseAbstraction.Error>> {\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"w\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n const originalResult = await this.getRevisionById.execute<T>(model, sourceId);\n\n if (originalResult.isFail()) {\n return Result.fail(originalResult.error);\n }\n\n const originalEntry = originalResult.value;\n\n // Security: write access must be checked against the source entry, not only against the\n // new revision (whose meta fields, e.g. createdBy, can come from input).\n const canWriteOriginal = await this.accessControl.canAccessEntry({\n model,\n entry: originalEntry,\n rwd: \"w\"\n });\n if (!canWriteOriginal) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n const dataResult = await this.createEntryRevisionFromDataFactory.create<T>(\n sourceId,\n model,\n rawInput,\n originalEntry,\n options\n );\n if (dataResult.isFail()) {\n return Result.fail(dataResult.error);\n }\n const { entry, input } = dataResult.value;\n\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry,\n rwd: \"w\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n try {\n await this.eventPublisher.publish(\n new EntryRevisionBeforeCreateEvent({\n entry,\n model,\n input,\n original: originalEntry\n })\n );\n\n const result = await this.repository.execute<T>(model, entry);\n\n if (result.isFail()) {\n await this.eventPublisher.publish(\n new EntryRevisionCreateErrorEvent({\n entry,\n model,\n input,\n original: originalEntry,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n const createdEntry = result.value;\n\n await this.eventPublisher.publish(\n new EntryRevisionAfterCreateEvent({\n entry: createdEntry,\n model,\n input,\n original: originalEntry\n })\n );\n\n return Result.ok(createdEntry);\n } catch (error) {\n await this.eventPublisher.publish(\n new EntryRevisionCreateErrorEvent({\n entry,\n model,\n input,\n original: originalEntry,\n error: error as Error\n })\n );\n return Result.fail(error as UseCaseAbstraction.Error);\n }\n }\n}\n\nexport const CreateEntryRevisionFromUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: CreateEntryRevisionFromUseCaseImpl,\n dependencies: [\n CreateEntryRevisionFromRepository,\n AccessControl,\n GetRevisionByIdUseCase,\n EntryEventPublisher,\n CreateEntryRevisionFromDataFactory\n ]\n});\n"],"names":["CreateEntryRevisionFromUseCaseImpl","repository","accessControl","getRevisionById","eventPublisher","createEntryRevisionFromDataFactory","model","sourceId","rawInput","options","canAccess","Result","EntryNotAuthorizedError","originalResult","originalEntry","canWriteOriginal","dataResult","entry","input","canAccessEntry","EntryRevisionBeforeCreateEvent","result","EntryRevisionCreateErrorEvent","createdEntry","EntryRevisionAfterCreateEvent","error","CreateEntryRevisionFromUseCase","createImplementation","UseCaseAbstraction","CreateEntryRevisionFromRepository","AccessControl","GetRevisionByIdUseCase","EntryEventPublisher","CreateEntryRevisionFromDataFactory"],"mappings":";;;;;;;;AAuBA,MAAMA;IACF,YACYC,UAAuD,EACvDC,aAAsC,EACtCC,eAAiD,EACjDC,cAA6C,EAC7CC,kCAAgF,CAC1F;aALUJ,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;aACAC,kCAAkC,GAAlCA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,QAAgB,EAChBC,QAAgC,EAChCC,OAAoC,EACkB;QACtD,MAAMC,YA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;gBACvB;gBAEJ,OAAOV,OAAO,IAAI,CAACU,OAAO,KAAK;YACnC;YAEA,MAAME,eAAeF,OAAO,KAAK;YAEjC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIG,8BAA8B;gBAC9B,OAAOD;gBACPjB;gBACAY;gBACA,UAAUJ;YACd;YAGJ,OAAOH,OAAO,EAAE,CAACY;QACrB,EAAE,OAAOE,OAAO;YACZ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIH,8BAA8B;gBAC9BL;gBACAX;gBACAY;gBACA,UAAUJ;gBACV,OAAOW;YACX;YAEJ,OAAOd,OAAO,IAAI,CAACc;QACvB;IACJ;AACJ;AAEO,MAAMC,gEAAiCC,qBAAqB;IAC/D,aAAaC;IACb,gBAAgB5B;IAChB,cAAc;QACV6B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -26,7 +26,10 @@ class MoveEntryToBinUseCaseImpl {
|
|
|
26
26
|
const getResult = await this.getLatestRevision.execute(model, {
|
|
27
27
|
id
|
|
28
28
|
});
|
|
29
|
-
if (getResult.isFail())
|
|
29
|
+
if (getResult.isFail()) {
|
|
30
|
+
if ("Cms/Entry/NotAuthorized" === getResult.error.code) return Result.fail(getResult.error);
|
|
31
|
+
return Result.fail(new EntryNotFoundError(id));
|
|
32
|
+
}
|
|
30
33
|
const originalEntry = getResult.value;
|
|
31
34
|
const canAccessEntry = await this.accessControl.canAccessEntry({
|
|
32
35
|
model,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js","sources":["../../../../src/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { MoveEntryToBinUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { MoveEntryToBinRepository } from \"./abstractions.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport { EntryBeforeDeleteEvent, EntryAfterDeleteEvent, EntryDeleteErrorEvent } from \"./events.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { EntryNotFoundError } from \"~/domain/contentEntry/errors.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\n\n/**\n * MoveEntryToBinUseCase - Orchestrates soft deletion of an entry (move to bin).\n *\n * Responsibilities:\n * - Apply access control\n * - Get the entry to delete by ID\n * - Mark entry as deleted (wbyDeleted = true)\n * - Update deletion metadata\n * - Publish domain events with permanent: false\n * - Delegate to repository for storage operations\n */\nclass MoveEntryToBinUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: MoveEntryToBinRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EntryEventPublisher.Interface\n ) {}\n\n async execute(model: CmsModel, id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n // Check access control\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"d\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n // Get the entry to delete by ID\n const getResult = await this.getLatestRevision.execute(model, { id });\n\n if (getResult.isFail()) {\n return Result.fail(new EntryNotFoundError(id));\n }\n\n const originalEntry = getResult.value;\n\n // Check access control on the specific entry\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry: originalEntry,\n rwd: \"d\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(new EntryNotAuthorizedError());\n }\n\n // Create the deleted entry data\n const currentDateTime = new Date().toISOString();\n const currentIdentity = this.identityContext.getIdentity();\n\n const entryToDelete = {\n ...originalEntry,\n wbyDeleted: true,\n\n // Entry location fields - move to root folder\n location: {\n folderId: ROOT_FOLDER\n },\n binOriginalFolderId: originalEntry.location?.folderId,\n\n // Entry-level meta fields\n deletedOn: getDate(currentDateTime, null),\n deletedBy: getIdentity(currentIdentity, null),\n\n // Revision-level meta fields\n revisionDeletedOn: getDate(currentDateTime, null),\n revisionDeletedBy: getIdentity(currentIdentity, null)\n };\n\n try {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeDeleteEvent({\n entry: entryToDelete,\n model,\n permanent: false\n })\n );\n\n // Delegate to repository\n const result = await this.repository.execute({\n model,\n entry: entryToDelete\n });\n\n if (result.isFail()) {\n await this.eventPublisher.publish(\n new EntryDeleteErrorEvent({\n entry: entryToDelete,\n model,\n permanent: false,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterDeleteEvent({\n entry: entryToDelete,\n model,\n permanent: false\n })\n );\n\n return Result.ok();\n } catch (error) {\n await this.eventPublisher.publish(\n new EntryDeleteErrorEvent({\n entry: entryToDelete,\n model,\n permanent: false,\n error: error as Error\n })\n );\n return Result.fail(error as any);\n }\n }\n}\n\nexport const MoveEntryToBinUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: MoveEntryToBinUseCaseImpl,\n dependencies: [\n MoveEntryToBinRepository,\n AccessControl,\n GetLatestRevisionByEntryIdUseCase,\n IdentityContext,\n EntryEventPublisher\n ]\n});\n"],"names":["MoveEntryToBinUseCaseImpl","repository","accessControl","getLatestRevision","identityContext","eventPublisher","model","id","canAccess","Result","EntryNotAuthorizedError","getResult","EntryNotFoundError","originalEntry","canAccessEntry","currentDateTime","Date","currentIdentity","entryToDelete","ROOT_FOLDER","getDate","getIdentity","EntryBeforeDeleteEvent","result","EntryDeleteErrorEvent","EntryAfterDeleteEvent","error","MoveEntryToBinUseCase","createImplementation","UseCaseAbstraction","MoveEntryToBinRepository","AccessControl","GetLatestRevisionByEntryIdUseCase","IdentityContext","EntryEventPublisher"],"mappings":";;;;;;;;;;;AA2BA,MAAMA;IACF,YACYC,UAA8C,EAC9CC,aAAsC,EACtCC,iBAA8D,EAC9DC,eAA0C,EAC1CC,cAA6C,CACvD;aALUJ,UAAU,GAAVA;aACAC,aAAa,GAAbA;aACAC,iBAAiB,GAAjBA;aACAC,eAAe,GAAfA;aACAC,cAAc,GAAdA;IACT;IAEH,MAAM,QAAQC,KAAe,EAAEC,EAAU,EAAmD;QAExF,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEF;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACE,WACD,OAAOC,OAAO,IAAI,CAACC,wBAAwB,SAAS,CAACJ;QAIzD,MAAMK,YAAY,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACL,OAAO;YAAEC;QAAG;QAEnE,IAAII,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.js","sources":["../../../../src/features/contentEntry/DeleteEntry/MoveEntryToBinUseCase.ts"],"sourcesContent":["import { Result } from \"@webiny/feature/api\";\nimport { createImplementation } from \"@webiny/feature/api\";\nimport { IdentityContext } from \"@webiny/api-core/features/security/IdentityContext/index.js\";\nimport { MoveEntryToBinUseCase as UseCaseAbstraction } from \"./abstractions.js\";\nimport { MoveEntryToBinRepository } from \"./abstractions.js\";\nimport { AccessControl } from \"~/features/shared/abstractions.js\";\nimport { GetLatestRevisionByEntryIdUseCase } from \"~/features/contentEntry/GetLatestRevisionByEntryId/index.js\";\nimport type { CmsModel } from \"~/types/index.js\";\nimport { EntryEventPublisher } from \"~/features/contentEntry/EntryEventPublisher/index.js\";\nimport { EntryBeforeDeleteEvent, EntryAfterDeleteEvent, EntryDeleteErrorEvent } from \"./events.js\";\nimport { EntryNotAuthorizedError } from \"~/domain/contentEntry/errors.js\";\nimport { EntryNotFoundError } from \"~/domain/contentEntry/errors.js\";\nimport { getDate } from \"~/utils/date.js\";\nimport { getIdentity } from \"~/utils/identity.js\";\nimport { ROOT_FOLDER } from \"~/constants.js\";\n\n/**\n * MoveEntryToBinUseCase - Orchestrates soft deletion of an entry (move to bin).\n *\n * Responsibilities:\n * - Apply access control\n * - Get the entry to delete by ID\n * - Mark entry as deleted (wbyDeleted = true)\n * - Update deletion metadata\n * - Publish domain events with permanent: false\n * - Delegate to repository for storage operations\n */\nclass MoveEntryToBinUseCaseImpl implements UseCaseAbstraction.Interface {\n public constructor(\n private repository: MoveEntryToBinRepository.Interface,\n private accessControl: AccessControl.Interface,\n private getLatestRevision: GetLatestRevisionByEntryIdUseCase.Interface,\n private identityContext: IdentityContext.Interface,\n private eventPublisher: EntryEventPublisher.Interface\n ) {}\n\n async execute(model: CmsModel, id: string): Promise<Result<void, UseCaseAbstraction.Error>> {\n // Check access control\n const canAccess = await this.accessControl.canAccessEntry({ model, rwd: \"d\" });\n if (!canAccess) {\n return Result.fail(EntryNotAuthorizedError.fromModel(model));\n }\n\n // Get the entry to delete by ID\n const getResult = await this.getLatestRevision.execute(model, { id });\n\n if (getResult.isFail()) {\n /* Keep \"not authorized\" as is. Turning it into \"not found\" would let a force delete\n treat someone else's entry as an orphan and wipe it. */\n if (getResult.error.code === \"Cms/Entry/NotAuthorized\") {\n return Result.fail(getResult.error);\n }\n return Result.fail(new EntryNotFoundError(id));\n }\n\n const originalEntry = getResult.value;\n\n // Check access control on the specific entry\n const canAccessEntry = await this.accessControl.canAccessEntry({\n model,\n entry: originalEntry,\n rwd: \"d\"\n });\n\n if (!canAccessEntry) {\n return Result.fail(new EntryNotAuthorizedError());\n }\n\n // Create the deleted entry data\n const currentDateTime = new Date().toISOString();\n const currentIdentity = this.identityContext.getIdentity();\n\n const entryToDelete = {\n ...originalEntry,\n wbyDeleted: true,\n\n // Entry location fields - move to root folder\n location: {\n folderId: ROOT_FOLDER\n },\n binOriginalFolderId: originalEntry.location?.folderId,\n\n // Entry-level meta fields\n deletedOn: getDate(currentDateTime, null),\n deletedBy: getIdentity(currentIdentity, null),\n\n // Revision-level meta fields\n revisionDeletedOn: getDate(currentDateTime, null),\n revisionDeletedBy: getIdentity(currentIdentity, null)\n };\n\n try {\n // Publish before event\n await this.eventPublisher.publish(\n new EntryBeforeDeleteEvent({\n entry: entryToDelete,\n model,\n permanent: false\n })\n );\n\n // Delegate to repository\n const result = await this.repository.execute({\n model,\n entry: entryToDelete\n });\n\n if (result.isFail()) {\n await this.eventPublisher.publish(\n new EntryDeleteErrorEvent({\n entry: entryToDelete,\n model,\n permanent: false,\n error: result.error\n })\n );\n return Result.fail(result.error);\n }\n\n // Publish after event\n await this.eventPublisher.publish(\n new EntryAfterDeleteEvent({\n entry: entryToDelete,\n model,\n permanent: false\n })\n );\n\n return Result.ok();\n } catch (error) {\n await this.eventPublisher.publish(\n new EntryDeleteErrorEvent({\n entry: entryToDelete,\n model,\n permanent: false,\n error: error as Error\n })\n );\n return Result.fail(error as any);\n }\n }\n}\n\nexport const MoveEntryToBinUseCase = createImplementation({\n abstraction: UseCaseAbstraction,\n implementation: MoveEntryToBinUseCaseImpl,\n dependencies: [\n MoveEntryToBinRepository,\n AccessControl,\n GetLatestRevisionByEntryIdUseCase,\n IdentityContext,\n EntryEventPublisher\n ]\n});\n"],"names":["MoveEntryToBinUseCaseImpl","repository","accessControl","getLatestRevision","identityContext","eventPublisher","model","id","canAccess","Result","EntryNotAuthorizedError","getResult","EntryNotFoundError","originalEntry","canAccessEntry","currentDateTime","Date","currentIdentity","entryToDelete","ROOT_FOLDER","getDate","getIdentity","EntryBeforeDeleteEvent","result","EntryDeleteErrorEvent","EntryAfterDeleteEvent","error","MoveEntryToBinUseCase","createImplementation","UseCaseAbstraction","MoveEntryToBinRepository","AccessControl","GetLatestRevisionByEntryIdUseCase","Id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M,YAAYJ,iBAAiB;QACpD;QAEA,IAAI;YAEA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIK,uBAAuB;gBACvB,OAAOJ;gBACPZ;gBACA,WAAW;YACf;YAIJ,MAAMiB,SAAS,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBACzCjB;gBACA,OAAOY;YACX;YAEA,IAAIK,OAAO,MAAM,IAAI;gBACjB,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIC,sBAAsB;oBACtB,OAAON;oBACPZ;oBACA,WAAW;oBACX,OAAOiB,OAAO,KAAK;gBACvB;gBAEJ,OAAOd,OAAO,IAAI,CAACc,OAAO,KAAK;YACnC;YAGA,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIE,sBAAsB;gBACtB,OAAOP;gBACPZ;gBACA,WAAW;YACf;YAGJ,OAAOG,OAAO,EAAE;QACpB,EAAE,OAAOiB,OAAO;YACZ,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAC7B,IAAIF,sBAAsB;gBACtB,OAAON;gBACPZ;gBACA,WAAW;gBACX,OAAOoB;YACX;YAEJ,OAAOjB,OAAO,IAAI,CAACiB;QACvB;IACJ;AACJ;AAEO,MAAMC,8CAAwBC,qBAAqB;IACtD,aAAaC;IACb,gBAAgB7B;IAChB,cAAc;QACV8B;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Result } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteEntryUseCase } from "../abstractions.js";
|
|
3
|
-
import { StorageOperations } from "../../../../features/shared/abstractions.js";
|
|
3
|
+
import { AccessControl, StorageOperations } from "../../../../features/shared/abstractions.js";
|
|
4
4
|
import type { CmsModel, CmsDeleteEntryOptions } from "../../../../types/index.js";
|
|
5
5
|
/**
|
|
6
6
|
* Handles force delete logic for cleanup scenarios.
|
|
@@ -11,9 +11,16 @@ import type { CmsModel, CmsDeleteEntryOptions } from "../../../../types/index.js
|
|
|
11
11
|
*/
|
|
12
12
|
declare class ForceDeleteDecoratorImpl implements DeleteEntryUseCase.Interface {
|
|
13
13
|
private storageOperations;
|
|
14
|
+
private accessControl;
|
|
14
15
|
private decoratee;
|
|
15
|
-
constructor(storageOperations: StorageOperations.Interface, decoratee: DeleteEntryUseCase.Interface);
|
|
16
|
+
constructor(storageOperations: StorageOperations.Interface, accessControl: AccessControl.Interface, decoratee: DeleteEntryUseCase.Interface);
|
|
16
17
|
execute(model: CmsModel, id: string, options?: CmsDeleteEntryOptions): Promise<Result<void, DeleteEntryUseCase.Error>>;
|
|
18
|
+
/**
|
|
19
|
+
* Force delete bypasses the use case, so check delete access here. If a record still exists
|
|
20
|
+
* (for example an entry in the bin), the caller must be allowed to delete it. If nothing is
|
|
21
|
+
* left, ownership can't be checked, so an "own entries only" caller is refused.
|
|
22
|
+
*/
|
|
23
|
+
private canForceDelete;
|
|
17
24
|
}
|
|
18
25
|
export declare const ForceDeleteDecorator: typeof ForceDeleteDecoratorImpl;
|
|
19
26
|
export {};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Result, createDecorator } from "@webiny/feature/api";
|
|
2
2
|
import { DeleteEntryUseCase } from "../abstractions.js";
|
|
3
|
-
import { StorageOperations } from "../../../shared/abstractions.js";
|
|
3
|
+
import { AccessControl, StorageOperations } from "../../../shared/abstractions.js";
|
|
4
4
|
import { parseIdentifier } from "@webiny/utils";
|
|
5
|
-
import { EntryPersistenceError } from "../../../../domain/contentEntry/errors.js";
|
|
5
|
+
import { EntryNotAuthorizedError, EntryPersistenceError } from "../../../../domain/contentEntry/errors.js";
|
|
6
6
|
class ForceDeleteDecoratorImpl {
|
|
7
|
-
constructor(storageOperations, decoratee){
|
|
7
|
+
constructor(storageOperations, accessControl, decoratee){
|
|
8
8
|
this.storageOperations = storageOperations;
|
|
9
|
+
this.accessControl = accessControl;
|
|
9
10
|
this.decoratee = decoratee;
|
|
10
11
|
}
|
|
11
12
|
async execute(model, id, options = {}) {
|
|
@@ -13,6 +14,8 @@ class ForceDeleteDecoratorImpl {
|
|
|
13
14
|
const result = await this.decoratee.execute(model, id, options);
|
|
14
15
|
if (force && result.isFail() && "Cms/Entry/NotFound" === result.error.code) {
|
|
15
16
|
const { id: entryId } = parseIdentifier(id);
|
|
17
|
+
const canForceDelete = await this.canForceDelete(model, entryId);
|
|
18
|
+
if (!canForceDelete) return Result.fail(new EntryNotAuthorizedError());
|
|
16
19
|
try {
|
|
17
20
|
await this.storageOperations.entries.delete(model, {
|
|
18
21
|
entry: {
|
|
@@ -27,12 +30,31 @@ class ForceDeleteDecoratorImpl {
|
|
|
27
30
|
}
|
|
28
31
|
return result;
|
|
29
32
|
}
|
|
33
|
+
async canForceDelete(model, entryId) {
|
|
34
|
+
const existing = await this.storageOperations.entries.getLatestRevisionByEntryId(model, {
|
|
35
|
+
id: entryId
|
|
36
|
+
});
|
|
37
|
+
if (existing) return this.accessControl.canAccessEntry({
|
|
38
|
+
model,
|
|
39
|
+
entry: existing,
|
|
40
|
+
rwd: "d"
|
|
41
|
+
});
|
|
42
|
+
const canDelete = await this.accessControl.canAccessEntry({
|
|
43
|
+
model,
|
|
44
|
+
rwd: "d"
|
|
45
|
+
});
|
|
46
|
+
if (!canDelete) return false;
|
|
47
|
+
return !await this.accessControl.canAccessOnlyOwnedEntries({
|
|
48
|
+
model
|
|
49
|
+
});
|
|
50
|
+
}
|
|
30
51
|
}
|
|
31
52
|
const ForceDeleteDecorator = createDecorator({
|
|
32
53
|
abstraction: DeleteEntryUseCase,
|
|
33
54
|
decorator: ForceDeleteDecoratorImpl,
|
|
34
55
|
dependencies: [
|
|
35
|
-
StorageOperations
|
|
56
|
+
StorageOperations,
|
|
57
|
+
AccessControl
|
|
36
58
|
]
|
|
37
59
|
});
|
|
38
60
|
export { ForceDeleteDecorator };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js","sources":["../../../../../src/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"../abstractions.js\";\nimport { StorageOperations } from \"~/features/shared/abstractions.js\";\nimport type { CmsModel, CmsDeleteEntryOptions } from \"~/types/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * Handles force delete logic for cleanup scenarios.\n *\n * When force=true and entry doesn't exist, this decorator directly calls storage\n * operations to clean up any orphaned records (e.g., in Elasticsearch when DynamoDB\n * record is already deleted).\n */\nclass ForceDeleteDecoratorImpl implements DeleteEntryUseCase.Interface {\n public constructor(\n private storageOperations: StorageOperations.Interface,\n private decoratee: DeleteEntryUseCase.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n id: string,\n options: CmsDeleteEntryOptions = {}\n ): Promise<Result<void, DeleteEntryUseCase.Error>> {\n const { force = false } = options;\n\n const result = await this.decoratee.execute(model, id, options);\n\n if (force && result.isFail() && result.error.code === \"Cms/Entry/NotFound\") {\n const { id: entryId } = parseIdentifier(id);\n\n try {\n // Not the nicest way to do it, but we need to revisit storage operations anyway.\n await this.storageOperations.entries.delete(model, {\n entry: {\n id,\n entryId\n }\n } as any);\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n\n return result;\n }\n}\n\nexport const ForceDeleteDecorator = createDecorator({\n abstraction: DeleteEntryUseCase,\n decorator: ForceDeleteDecoratorImpl,\n dependencies: [StorageOperations]\n});\n"],"names":["ForceDeleteDecoratorImpl","storageOperations","decoratee","model","id","options","force","result","entryId","parseIdentifier","Result","error","EntryPersistenceError","ForceDeleteDecorator","createDecorator","DeleteEntryUseCase","StorageOperations"],"mappings":";;;;;AAeA,MAAMA;IACF,YACYC,iBAA8C,EAC9CC,SAAuC,CACjD;
|
|
1
|
+
{"version":3,"file":"features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.js","sources":["../../../../../src/features/contentEntry/DeleteEntry/decorators/ForceDeleteDecorator.ts"],"sourcesContent":["import { createDecorator } from \"@webiny/feature/api\";\nimport { Result } from \"@webiny/feature/api\";\nimport { DeleteEntryUseCase } from \"../abstractions.js\";\nimport { AccessControl, StorageOperations } from \"~/features/shared/abstractions.js\";\nimport type { CmsModel, CmsDeleteEntryOptions } from \"~/types/index.js\";\nimport { parseIdentifier } from \"@webiny/utils\";\nimport { EntryNotAuthorizedError, EntryPersistenceError } from \"~/domain/contentEntry/errors.js\";\n\n/**\n * Handles force delete logic for cleanup scenarios.\n *\n * When force=true and entry doesn't exist, this decorator directly calls storage\n * operations to clean up any orphaned records (e.g., in Elasticsearch when DynamoDB\n * record is already deleted).\n */\nclass ForceDeleteDecoratorImpl implements DeleteEntryUseCase.Interface {\n public constructor(\n private storageOperations: StorageOperations.Interface,\n private accessControl: AccessControl.Interface,\n private decoratee: DeleteEntryUseCase.Interface\n ) {}\n\n async execute(\n model: CmsModel,\n id: string,\n options: CmsDeleteEntryOptions = {}\n ): Promise<Result<void, DeleteEntryUseCase.Error>> {\n const { force = false } = options;\n\n const result = await this.decoratee.execute(model, id, options);\n\n if (force && result.isFail() && result.error.code === \"Cms/Entry/NotFound\") {\n const { id: entryId } = parseIdentifier(id);\n\n const canForceDelete = await this.canForceDelete(model, entryId);\n if (!canForceDelete) {\n return Result.fail(new EntryNotAuthorizedError());\n }\n\n try {\n // Not the nicest way to do it, but we need to revisit storage operations anyway.\n await this.storageOperations.entries.delete(model, {\n entry: {\n id,\n entryId\n }\n } as any);\n\n return Result.ok();\n } catch (error) {\n return Result.fail(new EntryPersistenceError(error as Error));\n }\n }\n\n return result;\n }\n\n /**\n * Force delete bypasses the use case, so check delete access here. If a record still exists\n * (for example an entry in the bin), the caller must be allowed to delete it. If nothing is\n * left, ownership can't be checked, so an \"own entries only\" caller is refused.\n */\n private async canForceDelete(model: CmsModel, entryId: string): Promise<boolean> {\n const existing = await this.storageOperations.entries.getLatestRevisionByEntryId(model, {\n id: entryId\n });\n if (existing) {\n return this.accessControl.canAccessEntry({ model, entry: existing, rwd: \"d\" });\n }\n const canDelete = await this.accessControl.canAccessEntry({ model, rwd: \"d\" });\n if (!canDelete) {\n return false;\n }\n return !(await this.accessControl.canAccessOnlyOwnedEntries({ model }));\n }\n}\n\nexport const ForceDeleteDecorator = createDecorator({\n abstraction: DeleteEntryUseCase,\n decorator: ForceDeleteDecoratorImpl,\n dependencies: [StorageOperations, AccessControl]\n});\n"],"names":["ForceDeleteDecoratorImpl","storageOperations","accessControl","decoratee","model","id","options","force","result","entryId","parseIdentifier","canForceDelete","Result","EntryNotAuthorizedError","error","EntryPersistenceError","existing","canDelete","ForceDeleteDecorator","createDecorator","DeleteEntryUseCase","StorageOperations","AccessControl"],"mappings":";;;;;AAeA,MAAMA;IACF,YACYC,iBAA8C,EAC9CC,aAAsC,EACtCC,SAAuC,CACjD;aAHUF,iBAAiB,GAAjBA;aACAC,aAAa,GAAbA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,QACFC,KAAe,EACfC,EAAU,EACVC,UAAiC,CAAC,CAAC,EACY;QAC/C,MAAM,EAAEC,QAAQ,KAAK,EAAE,GAAGD;QAE1B,MAAME,SAAS,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAACJ,OAAOC,IAAIC;QAEvD,IAAIC,SAASC,OAAO,MAAM,MAAMA,AAAsB,yBAAtBA,OAAO,KAAK,CAAC,IAAI,EAA2B;YACxE,MAAM,EAAE,IAAIC,OAAO,EAAE,GAAGC,gBAAgBL;YAExC,MAAMM,iBAAiB,MAAM,IAAI,CAAC,cAAc,CAACP,OAAOK;YACxD,IAAI,CAACE,gBACD,OAAOC,OAAO,IAAI,CAAC,IAAIC;YAG3B,IAAI;gBAEA,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,MAAM,CAACT,OAAO;oBAC/C,OAAO;wBACHC;wBACAI;oBACJ;gBACJ;gBAEA,OAAOG,OAAO,EAAE;YACpB,EAAE,OAAOE,OAAO;gBACZ,OAAOF,OAAO,IAAI,CAAC,IAAIG,sBAAsBD;YACjD;QACJ;QAEA,OAAON;IACX;IAOA,MAAc,eAAeJ,KAAe,EAAEK,OAAe,EAAoB;QAC7E,MAAMO,WAAW,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,0BAA0B,CAACZ,OAAO;YACpF,IAAIK;QACR;QACA,IAAIO,UACA,OAAO,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEZ;YAAO,OAAOY;YAAU,KAAK;QAAI;QAEhF,MAAMC,YAAY,MAAM,IAAI,CAAC,aAAa,CAAC,cAAc,CAAC;YAAEb;YAAO,KAAK;QAAI;QAC5E,IAAI,CAACa,WACD,OAAO;QAEX,OAAO,CAAE,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;YAAEb;QAAM;IACxE;AACJ;AAEO,MAAMc,uBAAuBC,gBAAgB;IAChD,aAAaC;IACb,WAAWpB;IACX,cAAc;QAACqB;QAAmBC;KAAc;AACpD"}
|
|
@@ -43,7 +43,8 @@ class DeleteMultipleEntriesUseCaseImpl {
|
|
|
43
43
|
const { entries } = listResult.value;
|
|
44
44
|
const accessibleEntries = await filterAsync(entries, async (entry)=>this.accessControl.canAccessEntry({
|
|
45
45
|
model,
|
|
46
|
-
entry
|
|
46
|
+
entry,
|
|
47
|
+
rwd: "d"
|
|
47
48
|
}));
|
|
48
49
|
const items = accessibleEntries.map((entry)=>entry.id);
|
|
49
50
|
try {
|