sitero-server 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/export/index.js +10 -0
- package/dist/src/application/resources/file/operations/queries/find-detail/cache.js +4 -1
- package/dist/src/application/resources/file/operations/queries/find-list-cards/cache.js +1 -0
- package/dist/src/application/resources/file/operations/queries/find-relations/cache.js +4 -1
- package/dist/src/application/resources/page/collect-page-file-ids.js +14 -0
- package/dist/src/application/resources/page/errors/codes.js +7 -0
- package/dist/src/application/resources/page/errors/operation-errors.js +23 -0
- package/dist/src/application/resources/page/operations/commands/update/cache.js +23 -0
- package/dist/src/application/resources/page/operations/commands/update/page-update-command.js +36 -0
- package/dist/src/application/resources/page/operations/commands/update/validation/schema.js +104 -0
- package/dist/src/application/resources/page/operations/commands/update/validation/validate-input.js +25 -0
- package/dist/src/application/resources/page/operations/queries/find-detail/cache.js +28 -0
- package/dist/src/application/resources/page/operations/queries/find-detail/page-find-detail-query.js +35 -0
- package/dist/src/application/resources/page/operations/queries/find-detail/validation/schema.js +9 -0
- package/dist/src/application/resources/page/operations/queries/find-many/cache.js +17 -0
- package/dist/src/application/resources/page/operations/queries/find-many/page-find-many-query.js +35 -0
- package/dist/src/application/resources/page/operations/queries/find-many/validation/schema.js +8 -0
- package/dist/src/application/resources/page/operations/queries/find-many/validation/validate-input.js +12 -0
- package/dist/src/application/resources/post/assert-post-write-relations-exist.js +0 -1
- package/dist/src/application/resources/post/collect-post-reference-ids.js +1 -3
- package/dist/src/application/resources/post/create-post-list-card-cache-tags.js +19 -0
- package/dist/src/application/resources/post/errors/codes.js +6 -0
- package/dist/src/application/resources/post/operations/commands/create/cache.js +0 -1
- package/dist/src/application/resources/post/operations/commands/create/post-create-command.js +2 -0
- package/dist/src/application/resources/post/operations/commands/create/validation/schema.js +1 -1
- package/dist/src/application/resources/post/operations/commands/create/validation/validate-input.js +8 -0
- package/dist/src/application/resources/post/operations/commands/delete/cache.js +0 -1
- package/dist/src/application/resources/post/operations/commands/lifecycle.js +32 -0
- package/dist/src/application/resources/post/operations/commands/update/cache.js +0 -2
- package/dist/src/application/resources/post/operations/commands/update/post-update-command.js +2 -0
- package/dist/src/application/resources/post/operations/commands/update/validation/schema.js +1 -1
- package/dist/src/application/resources/post/operations/commands/update/validation/validate-input.js +8 -0
- package/dist/src/application/resources/post/operations/queries/find-detail/cache.js +5 -15
- package/dist/src/application/resources/post/operations/queries/find-detail/validation/schema.js +9 -0
- package/dist/src/application/resources/post/operations/queries/find-detail/validation/validate-input.js +2 -0
- package/dist/src/application/resources/post/operations/queries/find-list-cards/cache.js +6 -13
- package/dist/src/application/resources/post/operations/queries/find-list-cards/validation/schema.js +3 -1
- package/dist/src/application/resources/post/operations/queries/find-many/cache.js +3 -1
- package/dist/src/application/resources/post/operations/queries/find-many/validation/schema.js +3 -1
- package/dist/src/application/resources/post/operations/queries/find-relations/cache.js +1 -0
- package/dist/src/application/resources/post/validate-topic.js +35 -0
- package/dist/src/application/resources/seo-metadata/errors/codes.js +2 -0
- package/dist/src/application/resources/seo-metadata/errors/operation-errors.js +13 -1
- package/dist/src/application/resources/seo-metadata/operations/commands/upsert/cache.js +8 -2
- package/dist/src/application/resources/seo-metadata/operations/commands/upsert/seo-metadata-upsert-command.js +7 -2
- package/dist/src/application/resources/seo-metadata/operations/commands/upsert/validation/schema.js +9 -2
- package/dist/src/application/resources/seo-metadata/operations/commands/upsert/validation/validate-input.js +13 -7
- package/dist/src/composition/create-sitero-server.js +38 -1
- package/dist/types/src/application/conventions/cache/constants.d.ts +2 -1
- package/dist/types/src/application/conventions/cache/constants.d.ts.map +1 -1
- package/dist/types/src/application/resources/file/operations/queries/find-detail/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/file/operations/queries/find-list-cards/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/file/operations/queries/find-relations/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/file/projections/detail.d.ts +2 -1
- package/dist/types/src/application/resources/file/projections/detail.d.ts.map +1 -1
- package/dist/types/src/application/resources/file/projections/relations.d.ts +1 -0
- package/dist/types/src/application/resources/file/projections/relations.d.ts.map +1 -1
- package/dist/types/src/application/resources/page/collect-page-file-ids.d.ts +6 -0
- package/dist/types/src/application/resources/page/collect-page-file-ids.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/errors/codes.d.ts +7 -0
- package/dist/types/src/application/resources/page/errors/codes.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/errors/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/errors/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/errors/operation-errors.d.ts +11 -0
- package/dist/types/src/application/resources/page/errors/operation-errors.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/index.d.ts +5 -0
- package/dist/types/src/application/resources/page/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/index.d.ts +2 -0
- package/dist/types/src/application/resources/page/operations/commands/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/cache.d.ts +4 -0
- package/dist/types/src/application/resources/page/operations/commands/update/cache.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/commands/update/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/page-update-command.d.ts +11 -0
- package/dist/types/src/application/resources/page/operations/commands/update/page-update-command.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/types.d.ts +15 -0
- package/dist/types/src/application/resources/page/operations/commands/update/types.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/validation/schema.d.ts +98 -0
- package/dist/types/src/application/resources/page/operations/commands/update/validation/schema.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/commands/update/validation/validate-input.d.ts +9 -0
- package/dist/types/src/application/resources/page/operations/commands/update/validation/validate-input.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/cache.d.ts +5 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/cache.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/page-find-detail-query.d.ts +6 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/page-find-detail-query.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/types.d.ts +11 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/types.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/validation/schema.d.ts +7 -0
- package/dist/types/src/application/resources/page/operations/queries/find-detail/validation/schema.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/cache.d.ts +4 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/cache.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/page-find-many-query.d.ts +8 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/page-find-many-query.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/types.d.ts +9 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/types.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/validation/schema.d.ts +5 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/validation/schema.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/validation/validate-input.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/queries/find-many/validation/validate-input.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/operations/queries/index.d.ts +3 -0
- package/dist/types/src/application/resources/page/operations/queries/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/ports.d.ts +38 -0
- package/dist/types/src/application/resources/page/ports.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/projections/detail.d.ts +14 -0
- package/dist/types/src/application/resources/page/projections/detail.d.ts.map +1 -0
- package/dist/types/src/application/resources/page/projections/index.d.ts +2 -0
- package/dist/types/src/application/resources/page/projections/index.d.ts.map +1 -0
- package/dist/types/src/application/resources/post/assert-post-write-relations-exist.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/collect-post-reference-ids.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/create-post-list-card-cache-tags.d.ts +3 -0
- package/dist/types/src/application/resources/post/create-post-list-card-cache-tags.d.ts.map +1 -0
- package/dist/types/src/application/resources/post/errors/codes.d.ts +6 -0
- package/dist/types/src/application/resources/post/errors/codes.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/index.d.ts +3 -2
- package/dist/types/src/application/resources/post/index.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/create/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/create/post-create-command.d.ts +2 -0
- package/dist/types/src/application/resources/post/operations/commands/create/post-create-command.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/create/validation/schema.d.ts +1 -5
- package/dist/types/src/application/resources/post/operations/commands/create/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/create/validation/validate-input.d.ts +2 -0
- package/dist/types/src/application/resources/post/operations/commands/create/validation/validate-input.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/delete/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/index.d.ts +1 -0
- package/dist/types/src/application/resources/post/operations/commands/index.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/lifecycle.d.ts +11 -0
- package/dist/types/src/application/resources/post/operations/commands/lifecycle.d.ts.map +1 -0
- package/dist/types/src/application/resources/post/operations/commands/update/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/update/post-update-command.d.ts +2 -0
- package/dist/types/src/application/resources/post/operations/commands/update/post-update-command.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/update/validation/schema.d.ts +0 -3
- package/dist/types/src/application/resources/post/operations/commands/update/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/commands/update/validation/validate-input.d.ts +2 -0
- package/dist/types/src/application/resources/post/operations/commands/update/validation/validate-input.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-detail/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-detail/validation/schema.d.ts +6 -2
- package/dist/types/src/application/resources/post/operations/queries/find-detail/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-detail/validation/validate-input.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-list-cards/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-list-cards/validation/schema.d.ts +7 -3
- package/dist/types/src/application/resources/post/operations/queries/find-list-cards/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-many/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-many/validation/schema.d.ts +7 -3
- package/dist/types/src/application/resources/post/operations/queries/find-many/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/operations/queries/find-relations/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/ports.d.ts +26 -9
- package/dist/types/src/application/resources/post/ports.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/projections/detail.d.ts +3 -4
- package/dist/types/src/application/resources/post/projections/detail.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/projections/index.d.ts +1 -0
- package/dist/types/src/application/resources/post/projections/index.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/projections/list-card.d.ts +4 -8
- package/dist/types/src/application/resources/post/projections/list-card.d.ts.map +1 -1
- package/dist/types/src/application/resources/post/projections/reference-with-cover.d.ts +7 -0
- package/dist/types/src/application/resources/post/projections/reference-with-cover.d.ts.map +1 -0
- package/dist/types/src/application/resources/post/validate-topic.d.ts +11 -0
- package/dist/types/src/application/resources/post/validate-topic.d.ts.map +1 -0
- package/dist/types/src/application/resources/seo-metadata/errors/codes.d.ts +2 -0
- package/dist/types/src/application/resources/seo-metadata/errors/codes.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/errors/index.d.ts +1 -1
- package/dist/types/src/application/resources/seo-metadata/errors/index.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/errors/operation-errors.d.ts +6 -0
- package/dist/types/src/application/resources/seo-metadata/errors/operation-errors.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/index.d.ts +2 -1
- package/dist/types/src/application/resources/seo-metadata/index.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/cache.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/seo-metadata-upsert-command.d.ts +2 -0
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/seo-metadata-upsert-command.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/types.d.ts +5 -7
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/types.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/validation/schema.d.ts +55 -2
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/validation/schema.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/validation/validate-input.d.ts +2 -0
- package/dist/types/src/application/resources/seo-metadata/operations/commands/upsert/validation/validate-input.d.ts.map +1 -1
- package/dist/types/src/application/resources/seo-metadata/ports.d.ts +10 -3
- package/dist/types/src/application/resources/seo-metadata/ports.d.ts.map +1 -1
- package/dist/types/src/composition/create-sitero-server.d.ts.map +1 -1
- package/dist/types/src/composition/policies.d.ts +6 -0
- package/dist/types/src/composition/policies.d.ts.map +1 -1
- package/dist/types/src/composition/types.d.ts +14 -0
- package/dist/types/src/composition/types.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +8 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/export/index.js
CHANGED
|
@@ -20,3 +20,13 @@ export { isStorageFile } from '../src/contracts/storage/file.js';
|
|
|
20
20
|
export { createAdminForgotPasswordEmailSender } from '../src/application/email/authentication/admin/forgot-password/send.js';
|
|
21
21
|
export { createAdminVerificationEmailSender } from '../src/application/email/authentication/admin/verify-email/send.js';
|
|
22
22
|
export { createNewInquiryEmailSender } from '../src/application/email/inquiry/new-inquiry/send.js';
|
|
23
|
+
export { PAGE_ERROR_CODES } from '../src/application/resources/page/errors/codes.js';
|
|
24
|
+
export { PageMediaTypeInvalidError, PageNotFoundError, PageUnavailableError } from '../src/application/resources/page/errors/operation-errors.js';
|
|
25
|
+
export { createPageFindDetailQuery } from '../src/application/resources/page/operations/queries/find-detail/page-find-detail-query.js';
|
|
26
|
+
export { createPageFindManyQuery } from '../src/application/resources/page/operations/queries/find-many/page-find-many-query.js';
|
|
27
|
+
export { createPageUpdateCommand } from '../src/application/resources/page/operations/commands/update/page-update-command.js';
|
|
28
|
+
export { SEO_METADATA_ERROR_CODES } from '../src/application/resources/seo-metadata/errors/codes.js';
|
|
29
|
+
export { SeoMetadataPageNotFoundError, SeoMetadataPageUnavailableError, SeoMetadataPostNotFoundError } from '../src/application/resources/seo-metadata/errors/operation-errors.js';
|
|
30
|
+
import '../src/application/resources/seo-metadata/operations/commands/upsert/validation/schema.js';
|
|
31
|
+
export { POST_ERROR_CODES } from '../src/application/resources/post/errors/codes.js';
|
|
32
|
+
import '../src/application/resources/post/operations/commands/create/validation/schema.js';
|
|
@@ -2,6 +2,9 @@ import { createCacheKey } from '../../../../../conventions/cache/cache-key.js';
|
|
|
2
2
|
import { createResourceTag } from '../../../../../conventions/cache/cache-tag.js';
|
|
3
3
|
|
|
4
4
|
const createFileFindDetailCacheKey = (input) => createCacheKey("file", "find-detail", { id: input.id });
|
|
5
|
-
const createFileFindDetailCacheTags = (_, result) => [
|
|
5
|
+
const createFileFindDetailCacheTags = (_, result) => [
|
|
6
|
+
createResourceTag("post"),
|
|
7
|
+
createResourceTag("file", { id: result.data.file.id })
|
|
8
|
+
].flat();
|
|
6
9
|
|
|
7
10
|
export { createFileFindDetailCacheKey, createFileFindDetailCacheTags };
|
|
@@ -2,6 +2,9 @@ import { createCacheKey } from '../../../../../conventions/cache/cache-key.js';
|
|
|
2
2
|
import { createResourceTag } from '../../../../../conventions/cache/cache-tag.js';
|
|
3
3
|
|
|
4
4
|
const createFileFindRelationsCacheKey = (input) => createCacheKey("file", "find-relations", { id: input.id });
|
|
5
|
-
const createFileFindRelationsCacheTags = (input) => [
|
|
5
|
+
const createFileFindRelationsCacheTags = (input) => [
|
|
6
|
+
createResourceTag("post"),
|
|
7
|
+
createResourceTag("file", { id: input.id })
|
|
8
|
+
].flat();
|
|
6
9
|
|
|
7
10
|
export { createFileFindRelationsCacheKey, createFileFindRelationsCacheTags };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PAGE_MEDIA_FIELDS } from 'sitero-domain';
|
|
2
|
+
|
|
3
|
+
function collectPageFileIds(page) {
|
|
4
|
+
return [
|
|
5
|
+
...new Set(
|
|
6
|
+
PAGE_MEDIA_FIELDS.flatMap((field) => {
|
|
7
|
+
const id = page[`${field}Id`];
|
|
8
|
+
return id ? [id] : [];
|
|
9
|
+
})
|
|
10
|
+
)
|
|
11
|
+
];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { collectPageFileIds };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { OperationError } from '../../../../contracts/operation/error.js';
|
|
2
|
+
import { PAGE_ERROR_CODES } from './codes.js';
|
|
3
|
+
|
|
4
|
+
class PageNotFoundError extends OperationError {
|
|
5
|
+
constructor() {
|
|
6
|
+
super({ code: PAGE_ERROR_CODES.NOT_FOUND });
|
|
7
|
+
this.name = "PageNotFoundError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
class PageMediaTypeInvalidError extends OperationError {
|
|
11
|
+
constructor() {
|
|
12
|
+
super({ code: PAGE_ERROR_CODES.MEDIA_TYPE_INVALID });
|
|
13
|
+
this.name = "PageMediaTypeInvalidError";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
class PageUnavailableError extends OperationError {
|
|
17
|
+
constructor() {
|
|
18
|
+
super({ code: PAGE_ERROR_CODES.UNAVAILABLE });
|
|
19
|
+
this.name = "PageUnavailableError";
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { PageMediaTypeInvalidError, PageNotFoundError, PageUnavailableError };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createResourceTag, createRelationTag } from '../../../../../conventions/cache/cache-tag.js';
|
|
2
|
+
import { collectPageFileIds } from '../../../collect-page-file-ids.js';
|
|
3
|
+
|
|
4
|
+
const createPageUpdateInvalidationTags = (input, result) => {
|
|
5
|
+
const pages = [input.previous, result.data.page];
|
|
6
|
+
const fileIds = /* @__PURE__ */ new Set([
|
|
7
|
+
...collectPageFileIds(input.previous),
|
|
8
|
+
...collectPageFileIds(result.data.page)
|
|
9
|
+
]);
|
|
10
|
+
const tags = [
|
|
11
|
+
createResourceTag("page"),
|
|
12
|
+
...pages.flatMap((page) => [
|
|
13
|
+
createResourceTag("page", { id: page.id }),
|
|
14
|
+
createResourceTag("page", { key: page.key }),
|
|
15
|
+
// Main and section cover media references.
|
|
16
|
+
createRelationTag("page", "file", { id: page.id })
|
|
17
|
+
]),
|
|
18
|
+
...[...fileIds].map((id) => createResourceTag("file", { id }))
|
|
19
|
+
].flat();
|
|
20
|
+
return [...new Set(tags)];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { createPageUpdateInvalidationTags };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createOperation } from '../../../../../../kernel/operation/operation.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import { operationResult } from '../../../../../../contracts/operation/result.js';
|
|
4
|
+
import { createPageUpdateInvalidationTags } from './cache.js';
|
|
5
|
+
import { validateInput } from './validation/validate-input.js';
|
|
6
|
+
|
|
7
|
+
function createPageUpdateCommand(input) {
|
|
8
|
+
const { authorization, pageQueryPort, pageCommandPort, fileQueryPort } = input;
|
|
9
|
+
return createOperation(
|
|
10
|
+
{
|
|
11
|
+
authorization,
|
|
12
|
+
behavior: {
|
|
13
|
+
kind: "command",
|
|
14
|
+
invalidate: {
|
|
15
|
+
tags: createPageUpdateInvalidationTags
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
async validate(input2) {
|
|
19
|
+
return validateInput({
|
|
20
|
+
input: input2,
|
|
21
|
+
pageQueryPort,
|
|
22
|
+
fileQueryPort
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async (input2) => {
|
|
27
|
+
const { previous: _, ...writeInput } = input2;
|
|
28
|
+
const page = await pageCommandPort.update(writeInput);
|
|
29
|
+
return operationResult.success({
|
|
30
|
+
page
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { createPageUpdateCommand };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { addDuplicateLocaleIssues } from '../../../../../../conventions/validation/add-duplicate-locale-issues.js';
|
|
3
|
+
import { textSchema, requiredTextSchema, idSchema } from '../../../../../../conventions/validation/schema.js';
|
|
4
|
+
|
|
5
|
+
const pageUpdateInputSchema = () => z.object({
|
|
6
|
+
id: idSchema(),
|
|
7
|
+
page: z.object({
|
|
8
|
+
coverMediaId: idSchema().nullable().optional(),
|
|
9
|
+
section1CoverMediaId: idSchema().nullable().optional(),
|
|
10
|
+
section2CoverMediaId: idSchema().nullable().optional(),
|
|
11
|
+
section3CoverMediaId: idSchema().nullable().optional(),
|
|
12
|
+
section4CoverMediaId: idSchema().nullable().optional(),
|
|
13
|
+
section5CoverMediaId: idSchema().nullable().optional(),
|
|
14
|
+
section6CoverMediaId: idSchema().nullable().optional(),
|
|
15
|
+
section7CoverMediaId: idSchema().nullable().optional(),
|
|
16
|
+
section8CoverMediaId: idSchema().nullable().optional(),
|
|
17
|
+
section9CoverMediaId: idSchema().nullable().optional(),
|
|
18
|
+
section10CoverMediaId: idSchema().nullable().optional(),
|
|
19
|
+
translations: z.array(
|
|
20
|
+
z.object({
|
|
21
|
+
locale: requiredTextSchema(),
|
|
22
|
+
title: textSchema().nullable().optional(),
|
|
23
|
+
subtitle: textSchema().nullable().optional(),
|
|
24
|
+
description: textSchema().nullable().optional(),
|
|
25
|
+
text1: textSchema().nullable().optional(),
|
|
26
|
+
text2: textSchema().nullable().optional(),
|
|
27
|
+
text3: textSchema().nullable().optional(),
|
|
28
|
+
text4: textSchema().nullable().optional(),
|
|
29
|
+
section1Title: textSchema().nullable().optional(),
|
|
30
|
+
section1Subtitle: textSchema().nullable().optional(),
|
|
31
|
+
section1Description: textSchema().nullable().optional(),
|
|
32
|
+
section1Text1: textSchema().nullable().optional(),
|
|
33
|
+
section1Text2: textSchema().nullable().optional(),
|
|
34
|
+
section1Text3: textSchema().nullable().optional(),
|
|
35
|
+
section1Text4: textSchema().nullable().optional(),
|
|
36
|
+
section2Title: textSchema().nullable().optional(),
|
|
37
|
+
section2Subtitle: textSchema().nullable().optional(),
|
|
38
|
+
section2Description: textSchema().nullable().optional(),
|
|
39
|
+
section2Text1: textSchema().nullable().optional(),
|
|
40
|
+
section2Text2: textSchema().nullable().optional(),
|
|
41
|
+
section2Text3: textSchema().nullable().optional(),
|
|
42
|
+
section2Text4: textSchema().nullable().optional(),
|
|
43
|
+
section3Title: textSchema().nullable().optional(),
|
|
44
|
+
section3Subtitle: textSchema().nullable().optional(),
|
|
45
|
+
section3Description: textSchema().nullable().optional(),
|
|
46
|
+
section3Text1: textSchema().nullable().optional(),
|
|
47
|
+
section3Text2: textSchema().nullable().optional(),
|
|
48
|
+
section3Text3: textSchema().nullable().optional(),
|
|
49
|
+
section3Text4: textSchema().nullable().optional(),
|
|
50
|
+
section4Title: textSchema().nullable().optional(),
|
|
51
|
+
section4Subtitle: textSchema().nullable().optional(),
|
|
52
|
+
section4Description: textSchema().nullable().optional(),
|
|
53
|
+
section4Text1: textSchema().nullable().optional(),
|
|
54
|
+
section4Text2: textSchema().nullable().optional(),
|
|
55
|
+
section4Text3: textSchema().nullable().optional(),
|
|
56
|
+
section4Text4: textSchema().nullable().optional(),
|
|
57
|
+
section5Title: textSchema().nullable().optional(),
|
|
58
|
+
section5Subtitle: textSchema().nullable().optional(),
|
|
59
|
+
section5Description: textSchema().nullable().optional(),
|
|
60
|
+
section5Text1: textSchema().nullable().optional(),
|
|
61
|
+
section5Text2: textSchema().nullable().optional(),
|
|
62
|
+
section5Text3: textSchema().nullable().optional(),
|
|
63
|
+
section5Text4: textSchema().nullable().optional(),
|
|
64
|
+
section6Title: textSchema().nullable().optional(),
|
|
65
|
+
section6Subtitle: textSchema().nullable().optional(),
|
|
66
|
+
section6Description: textSchema().nullable().optional(),
|
|
67
|
+
section6Text1: textSchema().nullable().optional(),
|
|
68
|
+
section6Text2: textSchema().nullable().optional(),
|
|
69
|
+
section6Text3: textSchema().nullable().optional(),
|
|
70
|
+
section6Text4: textSchema().nullable().optional(),
|
|
71
|
+
section7Title: textSchema().nullable().optional(),
|
|
72
|
+
section7Subtitle: textSchema().nullable().optional(),
|
|
73
|
+
section7Description: textSchema().nullable().optional(),
|
|
74
|
+
section7Text1: textSchema().nullable().optional(),
|
|
75
|
+
section7Text2: textSchema().nullable().optional(),
|
|
76
|
+
section7Text3: textSchema().nullable().optional(),
|
|
77
|
+
section7Text4: textSchema().nullable().optional(),
|
|
78
|
+
section8Title: textSchema().nullable().optional(),
|
|
79
|
+
section8Subtitle: textSchema().nullable().optional(),
|
|
80
|
+
section8Description: textSchema().nullable().optional(),
|
|
81
|
+
section8Text1: textSchema().nullable().optional(),
|
|
82
|
+
section8Text2: textSchema().nullable().optional(),
|
|
83
|
+
section8Text3: textSchema().nullable().optional(),
|
|
84
|
+
section8Text4: textSchema().nullable().optional(),
|
|
85
|
+
section9Title: textSchema().nullable().optional(),
|
|
86
|
+
section9Subtitle: textSchema().nullable().optional(),
|
|
87
|
+
section9Description: textSchema().nullable().optional(),
|
|
88
|
+
section9Text1: textSchema().nullable().optional(),
|
|
89
|
+
section9Text2: textSchema().nullable().optional(),
|
|
90
|
+
section9Text3: textSchema().nullable().optional(),
|
|
91
|
+
section9Text4: textSchema().nullable().optional(),
|
|
92
|
+
section10Title: textSchema().nullable().optional(),
|
|
93
|
+
section10Subtitle: textSchema().nullable().optional(),
|
|
94
|
+
section10Description: textSchema().nullable().optional(),
|
|
95
|
+
section10Text1: textSchema().nullable().optional(),
|
|
96
|
+
section10Text2: textSchema().nullable().optional(),
|
|
97
|
+
section10Text3: textSchema().nullable().optional(),
|
|
98
|
+
section10Text4: textSchema().nullable().optional()
|
|
99
|
+
}).strict()
|
|
100
|
+
).min(1).superRefine(addDuplicateLocaleIssues)
|
|
101
|
+
}).strict()
|
|
102
|
+
}).strict();
|
|
103
|
+
|
|
104
|
+
export { pageUpdateInputSchema };
|
package/dist/src/application/resources/page/operations/commands/update/validation/validate-input.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { FILE_TYPES } from 'sitero-domain';
|
|
2
|
+
import { FileNotFoundError } from '../../../../../file/errors/operation-errors.js';
|
|
3
|
+
import 'zod';
|
|
4
|
+
import 'p-limit';
|
|
5
|
+
import { collectPageFileIds } from '../../../../collect-page-file-ids.js';
|
|
6
|
+
import { PageNotFoundError, PageMediaTypeInvalidError } from '../../../../errors/operation-errors.js';
|
|
7
|
+
import { pageUpdateInputSchema } from './schema.js';
|
|
8
|
+
|
|
9
|
+
async function validateInput(input) {
|
|
10
|
+
const parsed = pageUpdateInputSchema().parse(input.input);
|
|
11
|
+
const previous = await input.pageQueryPort.findDetail({ id: parsed.id });
|
|
12
|
+
if (!previous) throw new PageNotFoundError();
|
|
13
|
+
await Promise.all(
|
|
14
|
+
collectPageFileIds(parsed.page).map(async (id) => {
|
|
15
|
+
const file = await input.fileQueryPort.find({ id });
|
|
16
|
+
if (!file || file.deletedAt || file.purgeStartedAt)
|
|
17
|
+
throw new FileNotFoundError();
|
|
18
|
+
if (file.type !== FILE_TYPES.IMAGE && file.type !== FILE_TYPES.VIDEO)
|
|
19
|
+
throw new PageMediaTypeInvalidError();
|
|
20
|
+
})
|
|
21
|
+
);
|
|
22
|
+
return { ...parsed, previous };
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { validateInput };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createCacheKey } from '../../../../../conventions/cache/cache-key.js';
|
|
2
|
+
import { createResourceTag, createRelationTag } from '../../../../../conventions/cache/cache-tag.js';
|
|
3
|
+
import { collectPageFileIds } from '../../../collect-page-file-ids.js';
|
|
4
|
+
|
|
5
|
+
const createPageFindDetailCacheKey = (input) => {
|
|
6
|
+
return createCacheKey(
|
|
7
|
+
"page",
|
|
8
|
+
"find-detail",
|
|
9
|
+
input.id !== void 0 ? { id: input.id } : { key: input.key }
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
const createPageFindDetailCacheTags = (_, result) => {
|
|
13
|
+
const { page } = result.data;
|
|
14
|
+
const fileIds = collectPageFileIds(page);
|
|
15
|
+
return [
|
|
16
|
+
createResourceTag("page", { id: page.id }),
|
|
17
|
+
createResourceTag("page", { key: page.key }),
|
|
18
|
+
// Main and section cover media references.
|
|
19
|
+
...fileIds.map((fileId) => createResourceTag("file", { id: fileId })),
|
|
20
|
+
createRelationTag("page", "file", { id: page.id }),
|
|
21
|
+
createRelationTag("page", "seo-metadata", { id: page.id }),
|
|
22
|
+
...page.seoMetadatas.map(
|
|
23
|
+
(seo) => createResourceTag("seo-metadata", { id: seo.id })
|
|
24
|
+
)
|
|
25
|
+
].flat();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { createPageFindDetailCacheKey, createPageFindDetailCacheTags };
|
package/dist/src/application/resources/page/operations/queries/find-detail/page-find-detail-query.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createOperation } from '../../../../../../kernel/operation/operation.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import { operationResult } from '../../../../../../contracts/operation/result.js';
|
|
4
|
+
import { PageNotFoundError } from '../../../errors/operation-errors.js';
|
|
5
|
+
import { createPageFindDetailCacheTags, createPageFindDetailCacheKey } from './cache.js';
|
|
6
|
+
import { pageFindDetailInputSchema } from './validation/schema.js';
|
|
7
|
+
|
|
8
|
+
function createPageFindDetailQuery(input) {
|
|
9
|
+
const { pageQueryPort } = input;
|
|
10
|
+
return createOperation(
|
|
11
|
+
{
|
|
12
|
+
behavior: {
|
|
13
|
+
kind: "query",
|
|
14
|
+
cache: {
|
|
15
|
+
key: createPageFindDetailCacheKey,
|
|
16
|
+
tags: createPageFindDetailCacheTags
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
validate(input2) {
|
|
20
|
+
return pageFindDetailInputSchema().parse(input2);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async (input2) => {
|
|
24
|
+
const page = await pageQueryPort.findDetail(input2);
|
|
25
|
+
if (!page) {
|
|
26
|
+
return operationResult.failure(new PageNotFoundError());
|
|
27
|
+
}
|
|
28
|
+
return operationResult.success({
|
|
29
|
+
page
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { createPageFindDetailQuery };
|
package/dist/src/application/resources/page/operations/queries/find-detail/validation/schema.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { idSchema, requiredTextSchema } from '../../../../../../conventions/validation/schema.js';
|
|
3
|
+
|
|
4
|
+
const pageFindDetailInputSchema = () => z.union([
|
|
5
|
+
z.object({ id: idSchema() }).strict(),
|
|
6
|
+
z.object({ key: requiredTextSchema() }).strict()
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
export { pageFindDetailInputSchema };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createCacheKey, normalizeSelection } from '../../../../../conventions/cache/cache-key.js';
|
|
2
|
+
import { createResourceTag } from '../../../../../conventions/cache/cache-tag.js';
|
|
3
|
+
|
|
4
|
+
const createPageFindManyCacheKey = (input) => createCacheKey("page", "find-many", {
|
|
5
|
+
keys: normalizeSelection(input?.keys)
|
|
6
|
+
});
|
|
7
|
+
const createPageFindManyCacheTags = (input, result) => input?.keys?.length === 0 ? [] : [
|
|
8
|
+
.../* @__PURE__ */ new Set([
|
|
9
|
+
...createResourceTag("page"),
|
|
10
|
+
...result.data.pages.flatMap((page) => [
|
|
11
|
+
...createResourceTag("page", { id: page.id }),
|
|
12
|
+
...createResourceTag("page", { key: page.key })
|
|
13
|
+
])
|
|
14
|
+
])
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export { createPageFindManyCacheKey, createPageFindManyCacheTags };
|
package/dist/src/application/resources/page/operations/queries/find-many/page-find-many-query.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createOperation } from '../../../../../../kernel/operation/operation.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import { operationResult } from '../../../../../../contracts/operation/result.js';
|
|
4
|
+
import { createPageFindManyCacheTags, createPageFindManyCacheKey } from './cache.js';
|
|
5
|
+
import { validatePageFindManyInput } from './validation/validate-input.js';
|
|
6
|
+
|
|
7
|
+
function createPageFindManyQuery(input) {
|
|
8
|
+
const { pageQueryPort, authorization } = input;
|
|
9
|
+
return createOperation(
|
|
10
|
+
{
|
|
11
|
+
authorization,
|
|
12
|
+
behavior: {
|
|
13
|
+
kind: "query",
|
|
14
|
+
cache: {
|
|
15
|
+
key: createPageFindManyCacheKey,
|
|
16
|
+
tags: createPageFindManyCacheTags
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
validate(input2) {
|
|
20
|
+
return validatePageFindManyInput(input2);
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
async (input2) => {
|
|
24
|
+
if (input2?.keys?.length === 0) {
|
|
25
|
+
return operationResult.success({ pages: [] });
|
|
26
|
+
}
|
|
27
|
+
const pages = await pageQueryPort.findMany(input2);
|
|
28
|
+
return operationResult.success({
|
|
29
|
+
pages
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { createPageFindManyQuery };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { requiredTextSchema } from '../../../../../../conventions/validation/schema.js';
|
|
3
|
+
|
|
4
|
+
const pageFindManyInputSchema = () => z.object({
|
|
5
|
+
keys: z.array(requiredTextSchema()).optional()
|
|
6
|
+
}).optional();
|
|
7
|
+
|
|
8
|
+
export { pageFindManyInputSchema };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { normalizeStringSelection } from '../../../../../../conventions/normalization/normalize-string-selection.js';
|
|
2
|
+
import { pageFindManyInputSchema } from './schema.js';
|
|
3
|
+
|
|
4
|
+
function validatePageFindManyInput(input) {
|
|
5
|
+
const parsedInput = pageFindManyInputSchema().parse(input);
|
|
6
|
+
if (!parsedInput || parsedInput.keys === void 0) {
|
|
7
|
+
return void 0;
|
|
8
|
+
}
|
|
9
|
+
return { keys: normalizeStringSelection(parsedInput.keys) };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export { validatePageFindManyInput };
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
function collectPostReferenceIds(post) {
|
|
2
2
|
return [
|
|
3
|
-
post.topic?.id,
|
|
4
3
|
...post.parents.map((item) => item.id),
|
|
5
4
|
...post.children.map((item) => item.id),
|
|
6
5
|
...post.tags.map((item) => item.id),
|
|
7
6
|
...post.taggedPosts.map((item) => item.id),
|
|
8
7
|
...post.relatedPosts.map((item) => item.id),
|
|
9
|
-
...post.referencingPosts.map((item) => item.id)
|
|
10
|
-
...post.postsInTopic.map((item) => item.id)
|
|
8
|
+
...post.referencingPosts.map((item) => item.id)
|
|
11
9
|
].filter((id) => Boolean(id));
|
|
12
10
|
}
|
|
13
11
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { createResourceTag, createRelationTag } from '../../conventions/cache/cache-tag.js';
|
|
2
|
+
|
|
3
|
+
function createPostListCardCacheTags(post) {
|
|
4
|
+
return [
|
|
5
|
+
createResourceTag("post", { id: post.id }),
|
|
6
|
+
createRelationTag("post", "parent", { id: post.id }),
|
|
7
|
+
...post.parents.flatMap((parent) => [
|
|
8
|
+
createResourceTag("post", { id: parent.id }),
|
|
9
|
+
createRelationTag("post", "cover-image", { id: parent.id }),
|
|
10
|
+
...parent.coverImage ? [createResourceTag("file", { id: parent.coverImage.id })] : []
|
|
11
|
+
]),
|
|
12
|
+
...post.coverImage ? [
|
|
13
|
+
createResourceTag("file", { id: post.coverImage.id }),
|
|
14
|
+
createRelationTag("post", "cover-image", { id: post.id })
|
|
15
|
+
] : []
|
|
16
|
+
].flat();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { createPostListCardCacheTags };
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
const POST_ERROR_CODES = {
|
|
2
2
|
NOT_FOUND: "POST_NOT_FOUND",
|
|
3
|
+
IN_USE: "POST_IN_USE",
|
|
4
|
+
INVALID_STATE: "POST_INVALID_STATE",
|
|
5
|
+
SLUG_CONFLICT: "POST_SLUG_CONFLICT",
|
|
6
|
+
PARENT_UNPUBLISHED: "POST_PARENT_UNPUBLISHED",
|
|
7
|
+
HAS_PUBLISHED_CHILDREN: "POST_HAS_PUBLISHED_CHILDREN",
|
|
8
|
+
REFERENCE_UNAVAILABLE: "POST_REFERENCE_UNAVAILABLE",
|
|
3
9
|
DELETE_LOCKED: "POST_DELETE_LOCKED"
|
|
4
10
|
};
|
|
5
11
|
const POST_FIELD_ERROR_CODES = {
|
|
@@ -3,7 +3,6 @@ import { createResourceTag, createRelationTag } from '../../../../../conventions
|
|
|
3
3
|
const createPostCreateInvalidationTags = (input, result) => {
|
|
4
4
|
const { post } = result.data;
|
|
5
5
|
const postIds = [
|
|
6
|
-
input.topic?.id,
|
|
7
6
|
...input.parents.map((item) => item.id),
|
|
8
7
|
...input.tags.map((item) => item.id),
|
|
9
8
|
...input.relatedPosts.map((item) => item.id)
|
package/dist/src/application/resources/post/operations/commands/create/post-create-command.js
CHANGED
|
@@ -6,6 +6,7 @@ import { validateInput } from './validation/validate-input.js';
|
|
|
6
6
|
|
|
7
7
|
function createPostCreateCommand(input) {
|
|
8
8
|
const {
|
|
9
|
+
topics = {},
|
|
9
10
|
authorization,
|
|
10
11
|
postCommandPort,
|
|
11
12
|
postQueryPort,
|
|
@@ -22,6 +23,7 @@ function createPostCreateCommand(input) {
|
|
|
22
23
|
async validate(input2) {
|
|
23
24
|
return validateInput({
|
|
24
25
|
input: input2,
|
|
26
|
+
topics,
|
|
25
27
|
postQueryPort,
|
|
26
28
|
adminQueryPort,
|
|
27
29
|
fileQueryPort
|
|
@@ -62,7 +62,7 @@ const postCreateInputSchema = () => z.object({
|
|
|
62
62
|
int3: nullableInteger,
|
|
63
63
|
int4: nullableInteger,
|
|
64
64
|
author: singleItemSchema(),
|
|
65
|
-
|
|
65
|
+
topicKey: requiredTextSchema().nullable(),
|
|
66
66
|
parents: multiItemsSchema(),
|
|
67
67
|
tags: multiItemsSchema(),
|
|
68
68
|
relatedPosts: multiItemsSchema(),
|
package/dist/src/application/resources/post/operations/commands/create/validation/validate-input.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { normalizeStringSelection } from '../../../../../../conventions/normalization/normalize-string-selection.js';
|
|
2
2
|
import { assertPostWriteRelationsExist } from '../../../../assert-post-write-relations-exist.js';
|
|
3
|
+
import { validatePostTopic } from '../../../../validate-topic.js';
|
|
3
4
|
import { postCreateInputSchema } from './schema.js';
|
|
4
5
|
|
|
5
6
|
async function validateInput(input) {
|
|
@@ -22,6 +23,13 @@ async function validateInput(input) {
|
|
|
22
23
|
files1: normalizeItems(validatedInput.files1),
|
|
23
24
|
files2: normalizeItems(validatedInput.files2)
|
|
24
25
|
};
|
|
26
|
+
await validatePostTopic({
|
|
27
|
+
type: preparedInput.type,
|
|
28
|
+
topicKey: preparedInput.topicKey,
|
|
29
|
+
parents: preparedInput.parents,
|
|
30
|
+
topics: input.topics,
|
|
31
|
+
postQueryPort
|
|
32
|
+
});
|
|
25
33
|
await assertPostWriteRelationsExist({
|
|
26
34
|
relations: preparedInput,
|
|
27
35
|
adminQueryPort,
|
|
@@ -17,7 +17,6 @@ const createPostDeleteInvalidationTags = (input, result) => {
|
|
|
17
17
|
),
|
|
18
18
|
...previous.author ? [createResourceTag("admin", { id: previous.author.id })] : [],
|
|
19
19
|
createRelationTag("post", "author", { id: previous.id }),
|
|
20
|
-
createRelationTag("post", "topic", { id: previous.id }),
|
|
21
20
|
createRelationTag("post", "parent", { id: previous.id }),
|
|
22
21
|
createRelationTag("post", "tag", { id: previous.id }),
|
|
23
22
|
createRelationTag("post", "related-post", { id: previous.id }),
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createOperation } from '../../../../../kernel/operation/operation.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
import { operationResult } from '../../../../../contracts/operation/result.js';
|
|
4
|
+
import { PostNotFoundError } from '../../errors/operation-errors.js';
|
|
5
|
+
import { createPostDeleteInvalidationTags } from './delete/cache.js';
|
|
6
|
+
import { postDeleteInputSchema } from './delete/validation/schema.js';
|
|
7
|
+
|
|
8
|
+
function createPostLifecycleCommand(input) {
|
|
9
|
+
return createOperation(
|
|
10
|
+
{
|
|
11
|
+
authorization: input.authorization,
|
|
12
|
+
behavior: {
|
|
13
|
+
kind: "command",
|
|
14
|
+
invalidate: { tags: createPostDeleteInvalidationTags }
|
|
15
|
+
},
|
|
16
|
+
async validate(raw) {
|
|
17
|
+
const parsed = postDeleteInputSchema().parse(raw);
|
|
18
|
+
const { post: previous } = await input.postQueryPort.findDetail({
|
|
19
|
+
...parsed,
|
|
20
|
+
deletion: "deleted"
|
|
21
|
+
});
|
|
22
|
+
if (!previous) throw new PostNotFoundError();
|
|
23
|
+
return { ...parsed, previous };
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
async ({ id }) => operationResult.success({
|
|
27
|
+
post: await input.postCommandPort[input.action]({ id })
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { createPostLifecycleCommand };
|
|
@@ -6,7 +6,6 @@ const createPostUpdateInvalidationTags = (input, result) => {
|
|
|
6
6
|
const { previous } = input;
|
|
7
7
|
const postIds = [
|
|
8
8
|
...collectPostReferenceIds(previous),
|
|
9
|
-
input.topic?.id,
|
|
10
9
|
...input.parents.map((item) => item.id),
|
|
11
10
|
...input.tags.map((item) => item.id),
|
|
12
11
|
...input.relatedPosts.map((item) => item.id)
|
|
@@ -32,7 +31,6 @@ const createPostUpdateInvalidationTags = (input, result) => {
|
|
|
32
31
|
...previous.author ? [createResourceTag("admin", { id: previous.author.id })] : [],
|
|
33
32
|
...input.author ? [createResourceTag("admin", { id: input.author.id })] : [],
|
|
34
33
|
createRelationTag("post", "author", { id: input.id }),
|
|
35
|
-
createRelationTag("post", "topic", { id: input.id }),
|
|
36
34
|
createRelationTag("post", "parent", { id: input.id }),
|
|
37
35
|
createRelationTag("post", "tag", { id: input.id }),
|
|
38
36
|
createRelationTag("post", "related-post", { id: input.id }),
|
package/dist/src/application/resources/post/operations/commands/update/post-update-command.js
CHANGED
|
@@ -6,6 +6,7 @@ import { validateInput } from './validation/validate-input.js';
|
|
|
6
6
|
|
|
7
7
|
function createPostUpdateCommand(input) {
|
|
8
8
|
const {
|
|
9
|
+
topics = {},
|
|
9
10
|
authorization,
|
|
10
11
|
postCommandPort,
|
|
11
12
|
postQueryPort,
|
|
@@ -22,6 +23,7 @@ function createPostUpdateCommand(input) {
|
|
|
22
23
|
async validate(input2) {
|
|
23
24
|
return validateInput({
|
|
24
25
|
input: input2,
|
|
26
|
+
topics,
|
|
25
27
|
postQueryPort,
|
|
26
28
|
adminQueryPort,
|
|
27
29
|
fileQueryPort
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { idSchema } from '../../../../../../conventions/validation/schema.js';
|
|
2
2
|
import { postCreateInputSchema } from '../../create/validation/schema.js';
|
|
3
3
|
|
|
4
|
-
const postUpdateInputSchema = () => postCreateInputSchema().omit({ type: true }).extend({ id: idSchema() }).strict();
|
|
4
|
+
const postUpdateInputSchema = () => postCreateInputSchema().omit({ type: true, topicKey: true }).extend({ id: idSchema() }).strict();
|
|
5
5
|
|
|
6
6
|
export { postUpdateInputSchema };
|