@endora-commerce/mod-cms 0.102.0 → 0.103.1
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/admin/components/PageBuilderEditor.d.ts.map +1 -1
- package/dist/admin/components/PageBuilderEditor.js +87 -40
- package/dist/admin/components/PageBuilderEditor.js.map +1 -1
- package/dist/admin/components/block-contributions.d.ts +74 -0
- package/dist/admin/components/block-contributions.d.ts.map +1 -0
- package/dist/admin/components/block-contributions.js +94 -0
- package/dist/admin/components/block-contributions.js.map +1 -0
- package/dist/backend/index.d.ts +3 -0
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +2 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/plugin.d.ts +7 -0
- package/dist/backend/plugin.d.ts.map +1 -1
- package/dist/backend/plugin.js +1 -1
- package/dist/backend/plugin.js.map +1 -1
- package/dist/backend/services/cms-page-service.d.ts +36 -1
- package/dist/backend/services/cms-page-service.d.ts.map +1 -1
- package/dist/backend/services/cms-page-service.js +231 -114
- package/dist/backend/services/cms-page-service.js.map +1 -1
- package/dist/manifest.d.ts +2 -2
- package/docs/cms/extending-page-builder.md +521 -64
- package/docs/cms/index.md +4 -5
- package/i18n/en.json +1 -0
- package/i18n/pl.json +1 -0
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,qBAAqB,GAOtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,8BAA8B,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCA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AE;QACd,MAAM,EAAE,sBAAsB,EAAE,SAAS,EAAE,GAAG,GAAG,CAAC,MAAM,EAAa,CAAC;QACtE,0BAA0B,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACvB,MAAM,GAAG,CAAC,MAAM,EAAa,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH;;;;;;;;;;OAUG;IACH,GAAG,CAAC,MAAM,CAAC,GAAG,EAAE;QACd,6BAA6B,CAC3B,QAAQ,CAAkC,GAAG,EAAE,2BAA2B,CAAC,EAC3E,GAAG,CAAC,MAAM,EAAa,CAAC,SAAS,CAClC,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,QAAQ;IACR,sBAAsB;IACtB,OAAO;IACP,OAAO;IACP,WAAW;CACZ,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAI3B;IACH,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,aAAa,EAAE;CAC5F,CAAC"}
|
package/dist/backend/plugin.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { StorefrontResolver, type CmsAssetResolver } from './services/storefront
|
|
|
11
11
|
import { CmsHookService } from './services/cms-hook-service.js';
|
|
12
12
|
import { CmsCache } from './services/cms-cache.js';
|
|
13
13
|
import type { RequireAdminFactory } from '@endora-commerce/platform/kernel';
|
|
14
|
+
import type { CommandBus } from '@endora-commerce/platform/commands';
|
|
14
15
|
export interface ColorPaletteAuditContext {
|
|
15
16
|
actorAdminUserId: string | null;
|
|
16
17
|
requestId?: string | null;
|
|
@@ -18,6 +19,12 @@ export interface ColorPaletteAuditContext {
|
|
|
18
19
|
export type ColorPaletteWriter = (entries: CmsColorPaletteEntry[], expectedVersion: string | null, actor: ColorPaletteAuditContext) => Promise<CmsColorPaletteEntry[]>;
|
|
19
20
|
export interface CmsModuleOptions {
|
|
20
21
|
emFactory: () => EntityManager;
|
|
22
|
+
/**
|
|
23
|
+
* The platform's Command Bus (Constitution XIII): every admin write to a Page
|
|
24
|
+
* runs through it, so each one is audited in its own transaction. Required —
|
|
25
|
+
* an optional bus would be a write path whose absent form records nothing.
|
|
26
|
+
*/
|
|
27
|
+
commandBus: CommandBus;
|
|
21
28
|
/**
|
|
22
29
|
* Required since feature 072 (T093). It was optional, and `routes.admin.ts`
|
|
23
30
|
* defaulted it to `?? (async () => {})` — a permission gate whose absent form
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/backend/plugin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEvF,OAAO,EAAE,mBAAmB,EAAE,KAAK,8BAA8B,EAAE,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAG1I,OAAO,EAAE,cAAc,EAAE,KAAK,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,KAAK,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,MAAM,gC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AKG;IACH,+BAA+B,EAAE,CAAC,QAAQ,EAAE,4BAA4B,KAAK,IAAI,CAAC;IAClF,qBAAqB,EAAE,MAAM,kBAAkB,GAAG,IAAI,CAAC;IACvD,gBAAgB,EAAE,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG;IACpD,MAAM,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,EAAE,eAAe,CAAC;CACzB,CAiFA"}
|
package/dist/backend/plugin.js
CHANGED
|
@@ -31,7 +31,7 @@ export function cmsModule(options) {
|
|
|
31
31
|
});
|
|
32
32
|
const cache = options.redis ? new CmsCache(options.redis, {}) : undefined;
|
|
33
33
|
const referenceRegistry = new CmsReferenceRegistry(options.emFactory);
|
|
34
|
-
const pageService = new CmsPageService(options.emFactory, () => pageBuilderRegistry.knownNames(), cache, referenceRegistry);
|
|
34
|
+
const pageService = new CmsPageService(options.emFactory, options.commandBus, () => pageBuilderRegistry.knownNames(), cache, referenceRegistry);
|
|
35
35
|
const blockService = new CmsBlockService(options.emFactory, () => pageBuilderRegistry.knownNames(), referenceRegistry, cache);
|
|
36
36
|
const templateService = new CmsTemplateService(options.emFactory, () => pageBuilderRegistry.knownNames(), referenceRegistry, cache);
|
|
37
37
|
const hookService = new CmsHookService(options.emFactory, cache);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/backend/plugin.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,uEAAuE;AACvE,qEAAqE;AACrE,sEAAsE;AACtE,qEAAqE;AAOrE,OAAO,EAAE,mBAAmB,EAAkE,MAAM,qCAAqC,CAAC;AAC1I,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA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,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EntityManager } from '@mikro-orm/postgresql';
|
|
2
2
|
import { type CmsPageDetail, type CmsPageSummary, type CreateCmsPageRequest, type PatchCmsPageRequest } from '@endora-commerce/contracts';
|
|
3
|
+
import type { CommandBus } from '@endora-commerce/platform/commands';
|
|
3
4
|
import type { CmsCache } from './cms-cache.js';
|
|
4
5
|
import type { CmsReferenceRegistry } from './cms-reference-registry.js';
|
|
5
6
|
/**
|
|
@@ -30,8 +31,26 @@ export type ReservedSlugSegmentsResolver = () => Promise<unknown>;
|
|
|
30
31
|
* `"7"` reserving a path is a rule nobody wrote.
|
|
31
32
|
*/
|
|
32
33
|
export declare function normalizeReservedSegments(value: unknown): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Every write below runs as a Command (Constitution XIII): `CommandBus.run`
|
|
36
|
+
* opens the transaction, derives the actor from the ambient TenantContext and
|
|
37
|
+
* records exactly one audit entry beside the write, so a rolled-back write
|
|
38
|
+
* leaves no entry and a committed one cannot skip it. The statements are raw
|
|
39
|
+
* SQL and stay so — what changed is the EntityManager they run on, which is the
|
|
40
|
+
* Command's and no longer one this service opened for itself.
|
|
41
|
+
*
|
|
42
|
+
* What stays **outside** the Command is what is not part of the write: the
|
|
43
|
+
* reserved-segment refusal (a settings read), the storefront cache invalidation
|
|
44
|
+
* (Redis, and only meaningful once the row is committed) and the response read.
|
|
45
|
+
*/
|
|
33
46
|
export declare class CmsPageService {
|
|
34
47
|
private readonly emFactory;
|
|
48
|
+
/**
|
|
49
|
+
* Required, with no un-audited fallback: an optional bus is a write path
|
|
50
|
+
* whose absent form audits nothing, which is the defect this parameter
|
|
51
|
+
* exists to remove.
|
|
52
|
+
*/
|
|
53
|
+
private readonly commandBus;
|
|
35
54
|
private readonly knownComponentNames;
|
|
36
55
|
private readonly cache?;
|
|
37
56
|
private readonly references?;
|
|
@@ -42,7 +61,13 @@ export declare class CmsPageService {
|
|
|
42
61
|
* a *failing* read is not this state: it propagates, see `reservedSegments`.
|
|
43
62
|
*/
|
|
44
63
|
private reservedSegmentsResolver;
|
|
45
|
-
constructor(emFactory: () => EntityManager,
|
|
64
|
+
constructor(emFactory: () => EntityManager,
|
|
65
|
+
/**
|
|
66
|
+
* Required, with no un-audited fallback: an optional bus is a write path
|
|
67
|
+
* whose absent form audits nothing, which is the defect this parameter
|
|
68
|
+
* exists to remove.
|
|
69
|
+
*/
|
|
70
|
+
commandBus: CommandBus, knownComponentNames: () => Iterable<string>, cache?: CmsCache | undefined, references?: CmsReferenceRegistry | undefined);
|
|
46
71
|
setReservedSegmentsResolver(resolver: ReservedSlugSegmentsResolver | null): void;
|
|
47
72
|
/**
|
|
48
73
|
* The deployment's reserved first path segments — the **one** value the
|
|
@@ -67,6 +92,16 @@ export declare class CmsPageService {
|
|
|
67
92
|
*/
|
|
68
93
|
private assertSlugNotReserved;
|
|
69
94
|
private invalidateForPageId;
|
|
95
|
+
/** Every slug a page is served under — its own and each channel's. */
|
|
96
|
+
private slugsOf;
|
|
97
|
+
/**
|
|
98
|
+
* What an audit entry keeps of a Page: the facts an operator sets, and not
|
|
99
|
+
* the content tree. A page's tree is routinely hundreds of kilobytes and is
|
|
100
|
+
* saved many times in one editing session, so carrying it on both sides of
|
|
101
|
+
* every entry would make the audit table the largest copy of the CMS. A
|
|
102
|
+
* content save records which language changed and the version it produced.
|
|
103
|
+
*/
|
|
104
|
+
private auditState;
|
|
70
105
|
private invalidateForSlugs;
|
|
71
106
|
list(filters?: {
|
|
72
107
|
salesChannelId?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cms-page-service.d.ts","sourceRoot":"","sources":["../../../src/backend/services/cms-page-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KA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A6B;YA+B7B,mBAAmB;YAkBnB,sBAAsB;YAwBtB,aAAa;IAQ3B,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,SAAS;YA4BH,SAAS;YAgBT,QAAQ;IAUtB,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,GAAG;IAIX,OAAO,CAAC,UAAU;CAInB"}
|
|
@@ -27,8 +27,31 @@ export function normalizeReservedSegments(value) {
|
|
|
27
27
|
}
|
|
28
28
|
return [...out];
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The audit `objectType` of every Page write. One value, so the trail of one
|
|
32
|
+
* page is one query whichever of the seven actions wrote the row.
|
|
33
|
+
*/
|
|
34
|
+
const PAGE_OBJECT_TYPE = 'cms_page';
|
|
35
|
+
const TRANSITION_ACTIONS = {
|
|
36
|
+
published: 'cms_page.publish',
|
|
37
|
+
archived: 'cms_page.archive',
|
|
38
|
+
draft: 'cms_page.unarchive',
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Every write below runs as a Command (Constitution XIII): `CommandBus.run`
|
|
42
|
+
* opens the transaction, derives the actor from the ambient TenantContext and
|
|
43
|
+
* records exactly one audit entry beside the write, so a rolled-back write
|
|
44
|
+
* leaves no entry and a committed one cannot skip it. The statements are raw
|
|
45
|
+
* SQL and stay so — what changed is the EntityManager they run on, which is the
|
|
46
|
+
* Command's and no longer one this service opened for itself.
|
|
47
|
+
*
|
|
48
|
+
* What stays **outside** the Command is what is not part of the write: the
|
|
49
|
+
* reserved-segment refusal (a settings read), the storefront cache invalidation
|
|
50
|
+
* (Redis, and only meaningful once the row is committed) and the response read.
|
|
51
|
+
*/
|
|
30
52
|
export class CmsPageService {
|
|
31
53
|
emFactory;
|
|
54
|
+
commandBus;
|
|
32
55
|
knownComponentNames;
|
|
33
56
|
cache;
|
|
34
57
|
references;
|
|
@@ -39,8 +62,15 @@ export class CmsPageService {
|
|
|
39
62
|
* a *failing* read is not this state: it propagates, see `reservedSegments`.
|
|
40
63
|
*/
|
|
41
64
|
reservedSegmentsResolver = null;
|
|
42
|
-
constructor(emFactory,
|
|
65
|
+
constructor(emFactory,
|
|
66
|
+
/**
|
|
67
|
+
* Required, with no un-audited fallback: an optional bus is a write path
|
|
68
|
+
* whose absent form audits nothing, which is the defect this parameter
|
|
69
|
+
* exists to remove.
|
|
70
|
+
*/
|
|
71
|
+
commandBus, knownComponentNames, cache, references) {
|
|
43
72
|
this.emFactory = emFactory;
|
|
73
|
+
this.commandBus = commandBus;
|
|
44
74
|
this.knownComponentNames = knownComponentNames;
|
|
45
75
|
this.cache = cache;
|
|
46
76
|
this.references = references;
|
|
@@ -85,12 +115,34 @@ export class CmsPageService {
|
|
|
85
115
|
async invalidateForPageId(pageId) {
|
|
86
116
|
if (!this.cache)
|
|
87
117
|
return;
|
|
88
|
-
|
|
118
|
+
await this.invalidateForSlugs(await this.slugsOf(pageId));
|
|
119
|
+
}
|
|
120
|
+
/** Every slug a page is served under — its own and each channel's. */
|
|
121
|
+
async slugsOf(pageId, em = this.emFactory()) {
|
|
122
|
+
const rows = (await em.execute(`select slug from cms_page_sales_channels where page_id = ?
|
|
89
123
|
union
|
|
90
124
|
select slug from cms_pages where id = ?`, [pageId, pageId]));
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
125
|
+
return rows.map((r) => r.slug);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* What an audit entry keeps of a Page: the facts an operator sets, and not
|
|
129
|
+
* the content tree. A page's tree is routinely hundreds of kilobytes and is
|
|
130
|
+
* saved many times in one editing session, so carrying it on both sides of
|
|
131
|
+
* every entry would make the audit table the largest copy of the CMS. A
|
|
132
|
+
* content save records which language changed and the version it produced.
|
|
133
|
+
*/
|
|
134
|
+
async auditState(em, row) {
|
|
135
|
+
return {
|
|
136
|
+
name: row.name,
|
|
137
|
+
slug: row.slug,
|
|
138
|
+
status: row.status,
|
|
139
|
+
active: row.active,
|
|
140
|
+
description: row.description,
|
|
141
|
+
languages: row.languages,
|
|
142
|
+
salesChannelIds: await this.channelIdsFor(row.id, em),
|
|
143
|
+
meta: this.combineMeta(row),
|
|
144
|
+
version: row.version,
|
|
145
|
+
};
|
|
94
146
|
}
|
|
95
147
|
async invalidateForSlugs(slugs) {
|
|
96
148
|
if (!this.cache)
|
|
@@ -132,7 +184,6 @@ export class CmsPageService {
|
|
|
132
184
|
// transaction to refuse it would hold a connection for the length of a
|
|
133
185
|
// settings read.
|
|
134
186
|
await this.assertSlugNotReserved(input.slug);
|
|
135
|
-
const em = this.emFactory();
|
|
136
187
|
const id = randomUUID();
|
|
137
188
|
const now = new Date();
|
|
138
189
|
const meta = this.splitMeta(input.meta ?? null);
|
|
@@ -141,32 +192,43 @@ export class CmsPageService {
|
|
|
141
192
|
input.meta?.[language]?.title?.trim() || input.name,
|
|
142
193
|
]));
|
|
143
194
|
const body = Object.fromEntries(input.languages.map((language) => [language, '']));
|
|
144
|
-
await
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
195
|
+
await this.commandBus.run({
|
|
196
|
+
action: 'cms_page.create',
|
|
197
|
+
objectType: PAGE_OBJECT_TYPE,
|
|
198
|
+
objectId: id,
|
|
199
|
+
run: async ({ em: tx }) => {
|
|
200
|
+
await this.assertLanguagesInChannelScope(tx, input.languages, input.salesChannelIds);
|
|
201
|
+
await this.assertSlugAvailable(tx, input.slug, input.salesChannelIds);
|
|
202
|
+
await tx.execute(`insert into cms_pages
|
|
203
|
+
(id, path, status, title, body, published_at, archived_at, created_at, updated_at,
|
|
204
|
+
name, slug, active, description, meta_title, meta_description, meta_keywords,
|
|
205
|
+
content, languages, version)
|
|
206
|
+
values (?, ?, 'draft', ?::jsonb, ?::jsonb, null, null, ?, ?,
|
|
207
|
+
?, ?, ?, ?, ?::jsonb, ?::jsonb, ?::jsonb, ?::jsonb, ?::jsonb, 1)`, [
|
|
208
|
+
id,
|
|
209
|
+
this.legacyPath(input.slug, id),
|
|
210
|
+
JSON.stringify(title),
|
|
211
|
+
JSON.stringify(body),
|
|
212
|
+
now,
|
|
213
|
+
now,
|
|
214
|
+
input.name,
|
|
215
|
+
input.slug,
|
|
216
|
+
input.active ?? true,
|
|
217
|
+
input.description ?? null,
|
|
218
|
+
JSON.stringify(meta.metaTitle),
|
|
219
|
+
JSON.stringify(meta.metaDescription),
|
|
220
|
+
JSON.stringify(meta.metaKeywords),
|
|
221
|
+
JSON.stringify(emptyContent),
|
|
222
|
+
JSON.stringify(input.languages),
|
|
223
|
+
]);
|
|
224
|
+
await this.replaceChannelScope(tx, id, input.salesChannelIds, input.slug);
|
|
225
|
+
const created = await this.findRow(id, tx);
|
|
226
|
+
return {
|
|
227
|
+
result: undefined,
|
|
228
|
+
before: null,
|
|
229
|
+
after: created ? await this.auditState(tx, created) : null,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
170
232
|
});
|
|
171
233
|
await this.invalidateForSlugs([input.slug]);
|
|
172
234
|
return this.get(id);
|
|
@@ -185,81 +247,106 @@ export class CmsPageService {
|
|
|
185
247
|
// else made later.
|
|
186
248
|
if (input.slug !== undefined)
|
|
187
249
|
await this.assertSlugNotReserved(input.slug);
|
|
188
|
-
const em = this.emFactory();
|
|
189
250
|
const slugsToInvalidate = new Set();
|
|
190
|
-
await
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
set
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
251
|
+
await this.commandBus.run({
|
|
252
|
+
action: 'cms_page.update',
|
|
253
|
+
objectType: PAGE_OBJECT_TYPE,
|
|
254
|
+
objectId: id,
|
|
255
|
+
run: async ({ em: tx }) => {
|
|
256
|
+
const row = await this.findRow(id, tx);
|
|
257
|
+
if (!row)
|
|
258
|
+
throw new HttpError(404, ERROR_CODES.CMS_PAGE_NOT_FOUND, 'CMS Page not found.');
|
|
259
|
+
this.assertVersion(row, input.version);
|
|
260
|
+
slugsToInvalidate.add(row.slug);
|
|
261
|
+
const before = await this.auditState(tx, row);
|
|
262
|
+
const nextSlug = input.slug ?? row.slug;
|
|
263
|
+
const nextChannels = input.salesChannelIds ?? (await this.channelIdsFor(id, tx));
|
|
264
|
+
const nextLanguages = input.languages ?? row.languages;
|
|
265
|
+
await this.assertLanguagesInChannelScope(tx, nextLanguages, nextChannels);
|
|
266
|
+
if (input.slug || input.salesChannelIds) {
|
|
267
|
+
await this.assertSlugAvailable(tx, nextSlug, nextChannels, id);
|
|
268
|
+
}
|
|
269
|
+
const meta = input.meta !== undefined ? this.splitMeta(input.meta ?? null) : null;
|
|
270
|
+
const sets = [];
|
|
271
|
+
const params = [];
|
|
272
|
+
const set = (sql, value) => {
|
|
273
|
+
sets.push(sql);
|
|
274
|
+
params.push(value);
|
|
275
|
+
};
|
|
276
|
+
if (input.name !== undefined)
|
|
277
|
+
set('name = ?', input.name);
|
|
278
|
+
if (input.slug !== undefined)
|
|
279
|
+
set('slug = ?', input.slug);
|
|
280
|
+
if (input.active !== undefined)
|
|
281
|
+
set('active = ?', input.active);
|
|
282
|
+
if (input.description !== undefined)
|
|
283
|
+
set('description = ?', input.description);
|
|
284
|
+
if (input.languages !== undefined)
|
|
285
|
+
set('languages = ?::jsonb', JSON.stringify(input.languages));
|
|
286
|
+
if (meta) {
|
|
287
|
+
set('meta_title = ?::jsonb', JSON.stringify(meta.metaTitle));
|
|
288
|
+
set('meta_description = ?::jsonb', JSON.stringify(meta.metaDescription));
|
|
289
|
+
set('meta_keywords = ?::jsonb', JSON.stringify(meta.metaKeywords));
|
|
290
|
+
}
|
|
291
|
+
if (sets.length > 0) {
|
|
292
|
+
params.push(id);
|
|
293
|
+
await tx.execute(`update cms_pages
|
|
294
|
+
set ${sets.join(', ')}, version = version + 1, updated_at = now()
|
|
295
|
+
where id = ?`, params);
|
|
296
|
+
}
|
|
297
|
+
const rescoped = Boolean(input.salesChannelIds || input.slug);
|
|
298
|
+
if (rescoped) {
|
|
299
|
+
await this.replaceChannelScope(tx, id, nextChannels, nextSlug);
|
|
300
|
+
}
|
|
301
|
+
slugsToInvalidate.add(nextSlug);
|
|
302
|
+
// A patch that named no field wrote no row, so it leaves no entry: "no
|
|
303
|
+
// write, no audit row" is the bus's own rule and `skipAudit` its spelling.
|
|
304
|
+
if (sets.length === 0 && !rescoped)
|
|
305
|
+
return { result: undefined, skipAudit: true };
|
|
306
|
+
const updated = await this.findRow(id, tx);
|
|
307
|
+
return {
|
|
308
|
+
result: undefined,
|
|
309
|
+
before,
|
|
310
|
+
after: updated ? await this.auditState(tx, updated) : null,
|
|
311
|
+
};
|
|
312
|
+
},
|
|
235
313
|
});
|
|
236
314
|
await this.invalidateForSlugs(slugsToInvalidate);
|
|
237
315
|
return this.get(id);
|
|
238
316
|
}
|
|
239
317
|
async setContent(id, language, data, version) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
318
|
+
await this.commandBus.run({
|
|
319
|
+
action: 'cms_page.set_content',
|
|
320
|
+
objectType: PAGE_OBJECT_TYPE,
|
|
321
|
+
objectId: id,
|
|
322
|
+
run: async ({ em: tx }) => {
|
|
323
|
+
const row = await this.findRow(id, tx);
|
|
324
|
+
if (!row)
|
|
325
|
+
throw new HttpError(404, ERROR_CODES.CMS_PAGE_NOT_FOUND, 'CMS Page not found.');
|
|
326
|
+
this.assertVersion(row, version);
|
|
327
|
+
const unknown = walkUnknownComponents(data, new Set(this.knownComponentNames()));
|
|
328
|
+
if (unknown.size > 0) {
|
|
329
|
+
console.warn(`CMS page ${id} saved with unknown components: ${Array.from(unknown).join(', ')}`);
|
|
330
|
+
}
|
|
331
|
+
await this.assertBlockEmbedsExist(tx, data, await this.channelIdsFor(id, tx));
|
|
332
|
+
const content = {
|
|
333
|
+
languages: {
|
|
334
|
+
...(row.content.languages ?? {}),
|
|
335
|
+
[language]: data,
|
|
336
|
+
},
|
|
337
|
+
};
|
|
338
|
+
if (!row.languages.includes(language)) {
|
|
339
|
+
throw new HttpError(400, ERROR_CODES.CMS_LANGUAGE_NOT_IN_CHANNEL_SCOPE, `CMS Page language "${language}" is not assigned to this page.`);
|
|
340
|
+
}
|
|
341
|
+
await tx.execute(`update cms_pages
|
|
342
|
+
set content = ?::jsonb, version = version + 1, updated_at = now()
|
|
343
|
+
where id = ?`, [JSON.stringify(content), id]);
|
|
344
|
+
return {
|
|
345
|
+
result: undefined,
|
|
346
|
+
before: { language, version: row.version },
|
|
347
|
+
after: { language, version: row.version + 1 },
|
|
348
|
+
};
|
|
349
|
+
},
|
|
263
350
|
});
|
|
264
351
|
await this.invalidateForPageId(id);
|
|
265
352
|
return this.get(id);
|
|
@@ -280,21 +367,51 @@ export class CmsPageService {
|
|
|
280
367
|
throw new HttpError(409, ERROR_CODES.CMS_REFERENCED, 'CMS Page is referenced.');
|
|
281
368
|
}
|
|
282
369
|
}
|
|
283
|
-
|
|
284
|
-
|
|
370
|
+
// Read inside the Command, before the row goes: the channel rows that carry
|
|
371
|
+
// the slugs cascade with it. Invalidated after the commit, so a storefront
|
|
372
|
+
// read racing the delete cannot re-cache a page that is about to be gone.
|
|
373
|
+
let slugs = [];
|
|
374
|
+
await this.commandBus.run({
|
|
375
|
+
action: 'cms_page.delete',
|
|
376
|
+
objectType: PAGE_OBJECT_TYPE,
|
|
377
|
+
objectId: id,
|
|
378
|
+
run: async ({ em }) => {
|
|
379
|
+
const row = await this.findRow(id, em);
|
|
380
|
+
// Deleting a page that is not there has always answered success, and
|
|
381
|
+
// still does — it removed nothing, so it records nothing.
|
|
382
|
+
if (!row)
|
|
383
|
+
return { result: undefined, skipAudit: true };
|
|
384
|
+
const before = await this.auditState(em, row);
|
|
385
|
+
slugs = await this.slugsOf(id, em);
|
|
386
|
+
await em.execute('delete from cms_pages where id = ?', [id]);
|
|
387
|
+
return { result: undefined, before, after: null };
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
await this.invalidateForSlugs(slugs);
|
|
285
391
|
}
|
|
286
392
|
async transition(id, status) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
393
|
+
await this.commandBus.run({
|
|
394
|
+
action: TRANSITION_ACTIONS[status],
|
|
395
|
+
objectType: PAGE_OBJECT_TYPE,
|
|
396
|
+
objectId: id,
|
|
397
|
+
run: async ({ em }) => {
|
|
398
|
+
const row = await this.findRow(id, em);
|
|
399
|
+
if (!row)
|
|
400
|
+
throw new HttpError(404, ERROR_CODES.CMS_PAGE_NOT_FOUND, 'CMS Page not found.');
|
|
401
|
+
await em.execute(`update cms_pages
|
|
402
|
+
set status = ?,
|
|
403
|
+
published_at = case when ? = 'published' then now() else published_at end,
|
|
404
|
+
archived_at = case when ? = 'archived' then now() else null end,
|
|
405
|
+
version = version + 1,
|
|
406
|
+
updated_at = now()
|
|
407
|
+
where id = ?`, [status, status, status, id]);
|
|
408
|
+
return {
|
|
409
|
+
result: undefined,
|
|
410
|
+
before: { status: row.status, version: row.version },
|
|
411
|
+
after: { status, version: row.version + 1 },
|
|
412
|
+
};
|
|
413
|
+
},
|
|
414
|
+
});
|
|
298
415
|
await this.invalidateForPageId(id);
|
|
299
416
|
return this.get(id);
|
|
300
417
|
}
|