@actuate-media/cms-core 0.77.2 → 0.78.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/CHANGELOG.md +18 -0
- package/dist/__tests__/api/appearance-routes.test.js +1 -1
- package/dist/__tests__/api/appearance-routes.test.js.map +1 -1
- package/dist/__tests__/api/route-contracts.test.js +2 -0
- package/dist/__tests__/api/route-contracts.test.js.map +1 -1
- package/dist/__tests__/appearance/appearance.test.js +5 -4
- package/dist/__tests__/appearance/appearance.test.js.map +1 -1
- package/dist/__tests__/appearance/favicon-icon.test.d.ts +2 -0
- package/dist/__tests__/appearance/favicon-icon.test.d.ts.map +1 -0
- package/dist/__tests__/appearance/favicon-icon.test.js +12 -0
- package/dist/__tests__/appearance/favicon-icon.test.js.map +1 -0
- package/dist/__tests__/cron/cron.test.js +36 -4
- package/dist/__tests__/cron/cron.test.js.map +1 -1
- package/dist/__tests__/seo/audit-engine.test.js +30 -1
- package/dist/__tests__/seo/audit-engine.test.js.map +1 -1
- package/dist/__tests__/seo/audit-runner.test.js +70 -1
- package/dist/__tests__/seo/audit-runner.test.js.map +1 -1
- package/dist/__tests__/seo/audit-signals.test.d.ts +2 -0
- package/dist/__tests__/seo/audit-signals.test.d.ts.map +1 -0
- package/dist/__tests__/seo/audit-signals.test.js +30 -0
- package/dist/__tests__/seo/audit-signals.test.js.map +1 -0
- package/dist/__tests__/seo/effective-meta.test.d.ts +2 -0
- package/dist/__tests__/seo/effective-meta.test.d.ts.map +1 -0
- package/dist/__tests__/seo/effective-meta.test.js +58 -0
- package/dist/__tests__/seo/effective-meta.test.js.map +1 -0
- package/dist/__tests__/seo/migrate-meta.test.d.ts +2 -0
- package/dist/__tests__/seo/migrate-meta.test.d.ts.map +1 -0
- package/dist/__tests__/seo/migrate-meta.test.js +75 -0
- package/dist/__tests__/seo/migrate-meta.test.js.map +1 -0
- package/dist/__tests__/seo/migrate-schema.test.d.ts +2 -0
- package/dist/__tests__/seo/migrate-schema.test.d.ts.map +1 -0
- package/dist/__tests__/seo/migrate-schema.test.js +97 -0
- package/dist/__tests__/seo/migrate-schema.test.js.map +1 -0
- package/dist/__tests__/seo/schema-sync.test.d.ts +2 -0
- package/dist/__tests__/seo/schema-sync.test.d.ts.map +1 -0
- package/dist/__tests__/seo/schema-sync.test.js +59 -0
- package/dist/__tests__/seo/schema-sync.test.js.map +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +70 -9
- package/dist/actions.js.map +1 -1
- package/dist/api/route-helpers.d.ts.map +1 -1
- package/dist/api/route-helpers.js +3 -2
- package/dist/api/route-helpers.js.map +1 -1
- package/dist/api/routes/globals.d.ts.map +1 -1
- package/dist/api/routes/globals.js +24 -0
- package/dist/api/routes/globals.js.map +1 -1
- package/dist/api/routes/seo.d.ts.map +1 -1
- package/dist/api/routes/seo.js +5 -0
- package/dist/api/routes/seo.js.map +1 -1
- package/dist/appearance/favicon-icon.d.ts +12 -0
- package/dist/appearance/favicon-icon.d.ts.map +1 -0
- package/dist/appearance/favicon-icon.js +65 -0
- package/dist/appearance/favicon-icon.js.map +1 -0
- package/dist/appearance/favicon-paths.d.ts +6 -0
- package/dist/appearance/favicon-paths.d.ts.map +1 -0
- package/dist/appearance/favicon-paths.js +6 -0
- package/dist/appearance/favicon-paths.js.map +1 -0
- package/dist/appearance/index.d.ts +2 -0
- package/dist/appearance/index.d.ts.map +1 -1
- package/dist/appearance/index.js +2 -0
- package/dist/appearance/index.js.map +1 -1
- package/dist/appearance/resolve.d.ts.map +1 -1
- package/dist/appearance/resolve.js +9 -2
- package/dist/appearance/resolve.js.map +1 -1
- package/dist/cron/index.d.ts.map +1 -1
- package/dist/cron/index.js +19 -6
- package/dist/cron/index.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/seo/audit-engine.d.ts.map +1 -1
- package/dist/seo/audit-engine.js +107 -0
- package/dist/seo/audit-engine.js.map +1 -1
- package/dist/seo/audit-runner.d.ts +2 -1
- package/dist/seo/audit-runner.d.ts.map +1 -1
- package/dist/seo/audit-runner.js +56 -19
- package/dist/seo/audit-runner.js.map +1 -1
- package/dist/seo/audit-signals.d.ts +20 -0
- package/dist/seo/audit-signals.d.ts.map +1 -0
- package/dist/seo/audit-signals.js +107 -0
- package/dist/seo/audit-signals.js.map +1 -0
- package/dist/seo/index.d.ts +9 -1
- package/dist/seo/index.d.ts.map +1 -1
- package/dist/seo/index.js +5 -1
- package/dist/seo/index.js.map +1 -1
- package/dist/seo/migrate-meta.d.ts +23 -0
- package/dist/seo/migrate-meta.d.ts.map +1 -0
- package/dist/seo/migrate-meta.js +113 -0
- package/dist/seo/migrate-meta.js.map +1 -0
- package/dist/seo/migrate-schema.d.ts +28 -0
- package/dist/seo/migrate-schema.d.ts.map +1 -0
- package/dist/seo/migrate-schema.js +119 -0
- package/dist/seo/migrate-schema.js.map +1 -0
- package/dist/seo/page-meta.d.ts +35 -1
- package/dist/seo/page-meta.d.ts.map +1 -1
- package/dist/seo/page-meta.js +76 -1
- package/dist/seo/page-meta.js.map +1 -1
- package/dist/seo/schema-sync.d.ts +62 -0
- package/dist/seo/schema-sync.d.ts.map +1 -0
- package/dist/seo/schema-sync.js +139 -0
- package/dist/seo/schema-sync.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { detectBrokenInternalLinks } from '../../seo/audit-signals.js';
|
|
3
|
+
const home = {
|
|
4
|
+
entityType: 'page',
|
|
5
|
+
entityId: 'home',
|
|
6
|
+
title: 'Home',
|
|
7
|
+
url: '/',
|
|
8
|
+
content: '<p>Welcome <a href="/about">About</a></p>',
|
|
9
|
+
metaTitle: 'Home',
|
|
10
|
+
metaDescription: 'Welcome home page with enough characters to pass the minimum length check for meta descriptions in search.',
|
|
11
|
+
canonicalUrl: 'https://example.com/',
|
|
12
|
+
};
|
|
13
|
+
describe('detectBrokenInternalLinks', () => {
|
|
14
|
+
it('flags internal links that do not match known pages', () => {
|
|
15
|
+
const broken = detectBrokenInternalLinks([home, { ...home, entityId: 'about', url: '/about', content: '' }], { siteUrl: 'https://example.com' });
|
|
16
|
+
expect(broken).toHaveLength(0);
|
|
17
|
+
const missing = detectBrokenInternalLinks([home], { siteUrl: 'https://example.com' });
|
|
18
|
+
expect(missing).toHaveLength(1);
|
|
19
|
+
expect(missing[0].url).toBe('/about');
|
|
20
|
+
expect(missing[0].fromEntityId).toBe('home');
|
|
21
|
+
});
|
|
22
|
+
it('accepts targets reachable via redirect rules', () => {
|
|
23
|
+
const broken = detectBrokenInternalLinks([home], {
|
|
24
|
+
siteUrl: 'https://example.com',
|
|
25
|
+
redirectRules: [{ id: '1', from: '/about', to: '/', enabled: true }],
|
|
26
|
+
});
|
|
27
|
+
expect(broken).toHaveLength(0);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=audit-signals.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit-signals.test.js","sourceRoot":"","sources":["../../../src/__tests__/seo/audit-signals.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAGtE,MAAM,IAAI,GAAqB;IAC7B,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,MAAM;IAChB,KAAK,EAAE,MAAM;IACb,GAAG,EAAE,GAAG;IACR,OAAO,EAAE,2CAA2C;IACpD,SAAS,EAAE,MAAM;IACjB,eAAe,EACb,4GAA4G;IAC9G,YAAY,EAAE,sBAAsB;CACrC,CAAA;AAED,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,EAAE,CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,M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expect, it } from 'vitest';
|
|
2
|
+
import { setActuateConfig } from '../../config/runtime.js';
|
|
3
|
+
import { resolveEffectiveMeta } from '../../seo/page-meta.js';
|
|
4
|
+
describe('resolveEffectiveMeta', () => {
|
|
5
|
+
it('applies site title template when metaTitle is unset', () => {
|
|
6
|
+
setActuateConfig({
|
|
7
|
+
seo: {
|
|
8
|
+
siteName: 'Acme',
|
|
9
|
+
siteUrl: 'https://acme.com',
|
|
10
|
+
titleTemplate: '%page% | %site%',
|
|
11
|
+
},
|
|
12
|
+
collections: {
|
|
13
|
+
pages: { slug: 'pages', type: 'page', fields: [] },
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
const effective = resolveEffectiveMeta({
|
|
17
|
+
data: { title: 'About Us', slug: 'about' },
|
|
18
|
+
collectionSlug: 'pages',
|
|
19
|
+
site: {
|
|
20
|
+
siteName: 'Acme',
|
|
21
|
+
siteUrl: 'https://acme.com',
|
|
22
|
+
titleTemplate: '%page% | %site%',
|
|
23
|
+
},
|
|
24
|
+
siteUrl: 'https://acme.com',
|
|
25
|
+
});
|
|
26
|
+
expect(effective.metaTitle).toBe('About Us | Acme');
|
|
27
|
+
setActuateConfig({});
|
|
28
|
+
});
|
|
29
|
+
it('uses keyTakeaway as meta description fallback', () => {
|
|
30
|
+
const effective = resolveEffectiveMeta({
|
|
31
|
+
data: {
|
|
32
|
+
title: 'Pricing',
|
|
33
|
+
keyTakeaway: 'Transparent pricing for teams of every size with no hidden fees.',
|
|
34
|
+
},
|
|
35
|
+
collectionSlug: 'pages',
|
|
36
|
+
});
|
|
37
|
+
expect(effective.metaDescription).toBe('Transparent pricing for teams of every size with no hidden fees.');
|
|
38
|
+
});
|
|
39
|
+
it('prefers explicit metaTitle over title template', () => {
|
|
40
|
+
const effective = resolveEffectiveMeta({
|
|
41
|
+
data: { title: 'Home', metaTitle: 'Custom SEO Title Here For Home Page' },
|
|
42
|
+
collectionSlug: 'pages',
|
|
43
|
+
site: {
|
|
44
|
+
siteName: 'Acme',
|
|
45
|
+
titleTemplate: '%page% | %site%',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
expect(effective.metaTitle).toBe('Custom SEO Title Here For Home Page');
|
|
49
|
+
});
|
|
50
|
+
it('provides dynamic OG image URL when siteUrl is configured', () => {
|
|
51
|
+
const effective = resolveEffectiveMeta({
|
|
52
|
+
data: { title: 'Home', metaTitle: 'Home | Acme' },
|
|
53
|
+
siteUrl: 'https://acme.com',
|
|
54
|
+
});
|
|
55
|
+
expect(effective.ogImage).toContain('https://acme.com/api/cms/og.png');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=effective-meta.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective-meta.test.js","sourceRoot":"","sources":["../../../src/__tests__/seo/effective-meta.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,gBAAgB,CAAC;YACf,GAAG,EAAE;gBACH,QAAQ,EAAE,MAAM;gBAChB,OAAO,EAAE,kBAAkB;gBAC3B,aAAa,EAAE,iBAAiB;aACjC;YACD,WAAW,EAAE;gBACX,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE;aACnD;SACO,CAAC,CAAA;QAEX,MAAM,SAAS,GAAG,oBAAoB,CAAC;YACrC,IAAI,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE;YAC1C,cAAc,EAAE,OAAO;YACvB,IAAI,EAAE;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,CAAC,CAAA;IACxE,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-meta.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/seo/migrate-meta.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { setActuateConfig } from '../../config/runtime.js';
|
|
3
|
+
import { migrateMetaFields } from '../../seo/migrate-meta.js';
|
|
4
|
+
const { updateDocumentSeoFieldsMock } = vi.hoisted(() => ({
|
|
5
|
+
updateDocumentSeoFieldsMock: vi.fn(async () => ({})),
|
|
6
|
+
}));
|
|
7
|
+
vi.mock('../../actions.js', async (importOriginal) => {
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
updateDocumentSeoFields: updateDocumentSeoFieldsMock,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
function ctxFor(db) {
|
|
15
|
+
return { userId: 'admin-1', role: 'ADMIN', db, locale: 'en' };
|
|
16
|
+
}
|
|
17
|
+
describe('migrateMetaFields', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
updateDocumentSeoFieldsMock.mockClear();
|
|
20
|
+
setActuateConfig({
|
|
21
|
+
seo: {
|
|
22
|
+
siteName: 'Acme',
|
|
23
|
+
siteUrl: 'https://acme.com',
|
|
24
|
+
titleTemplate: '%page% | %site%',
|
|
25
|
+
},
|
|
26
|
+
collections: {
|
|
27
|
+
pages: { slug: 'pages', type: 'page', fields: [] },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
it('stamps metaTitle from title template when missing', async () => {
|
|
32
|
+
const db = {
|
|
33
|
+
document: {
|
|
34
|
+
findMany: vi
|
|
35
|
+
.fn()
|
|
36
|
+
.mockResolvedValueOnce([
|
|
37
|
+
{
|
|
38
|
+
id: 'p1',
|
|
39
|
+
collection: 'pages',
|
|
40
|
+
title: 'About',
|
|
41
|
+
slug: 'about',
|
|
42
|
+
status: 'PUBLISHED',
|
|
43
|
+
data: { title: 'About', slug: 'about' },
|
|
44
|
+
publishedAt: new Date(),
|
|
45
|
+
},
|
|
46
|
+
])
|
|
47
|
+
.mockResolvedValueOnce([]),
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
const result = await migrateMetaFields(ctxFor(db), { batchSize: 10 });
|
|
51
|
+
expect(result.migrated).toBe(1);
|
|
52
|
+
expect(updateDocumentSeoFieldsMock).toHaveBeenCalledWith('pages', 'p1', expect.objectContaining({ metaTitle: 'About | Acme' }), expect.any(Object));
|
|
53
|
+
});
|
|
54
|
+
it('dry run reports without writing', async () => {
|
|
55
|
+
const db = {
|
|
56
|
+
document: {
|
|
57
|
+
findMany: vi.fn().mockResolvedValueOnce([
|
|
58
|
+
{
|
|
59
|
+
id: 'p1',
|
|
60
|
+
collection: 'pages',
|
|
61
|
+
title: 'About',
|
|
62
|
+
slug: 'about',
|
|
63
|
+
status: 'PUBLISHED',
|
|
64
|
+
data: { title: 'About' },
|
|
65
|
+
publishedAt: new Date(),
|
|
66
|
+
},
|
|
67
|
+
]),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const result = await migrateMetaFields(ctxFor(db), { dryRun: true });
|
|
71
|
+
expect(result.migrated).toBe(1);
|
|
72
|
+
expect(updateDocumentSeoFieldsMock).not.toHaveBeenCalled();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=migrate-meta.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-meta.test.js","sourceRoot":"","sources":["../../../src/__tests__/seo/migrate-meta.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAE7D,O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AAA;QAEpE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,2BAA2B,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-schema.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/seo/migrate-schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
|
2
|
+
import { setActuateConfig } from '../../config/runtime.js';
|
|
3
|
+
import { migrateStructuredDataFields } from '../../seo/migrate-schema.js';
|
|
4
|
+
const { updateDocumentSeoFieldsMock } = vi.hoisted(() => ({
|
|
5
|
+
updateDocumentSeoFieldsMock: vi.fn(async () => ({})),
|
|
6
|
+
}));
|
|
7
|
+
vi.mock('../../actions.js', async (importOriginal) => {
|
|
8
|
+
const actual = await importOriginal();
|
|
9
|
+
return {
|
|
10
|
+
...actual,
|
|
11
|
+
updateDocumentSeoFields: updateDocumentSeoFieldsMock,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
function ctxFor(db) {
|
|
15
|
+
return { userId: 'admin-1', role: 'ADMIN', db, locale: 'en' };
|
|
16
|
+
}
|
|
17
|
+
describe('migrateStructuredDataFields', () => {
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
updateDocumentSeoFieldsMock.mockClear();
|
|
20
|
+
setActuateConfig({
|
|
21
|
+
collections: {
|
|
22
|
+
pages: { slug: 'pages', type: 'page', fields: [] },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it('stamps schema types on published pages missing structuredDataType', async () => {
|
|
27
|
+
const update = vi.fn(async () => ({}));
|
|
28
|
+
const db = {
|
|
29
|
+
document: {
|
|
30
|
+
findMany: vi
|
|
31
|
+
.fn()
|
|
32
|
+
.mockResolvedValueOnce([
|
|
33
|
+
{
|
|
34
|
+
id: 'p1',
|
|
35
|
+
collection: 'pages',
|
|
36
|
+
slug: 'home',
|
|
37
|
+
status: 'PUBLISHED',
|
|
38
|
+
data: { title: 'Home', slug: 'home' },
|
|
39
|
+
structuredData: null,
|
|
40
|
+
publishedAt: new Date(),
|
|
41
|
+
updatedAt: new Date(),
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
.mockResolvedValueOnce([]),
|
|
45
|
+
update,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const result = await migrateStructuredDataFields(ctxFor(db), { batchSize: 10 });
|
|
49
|
+
expect(result.scanned).toBe(1);
|
|
50
|
+
expect(result.migrated).toBe(1);
|
|
51
|
+
expect(updateDocumentSeoFieldsMock).toHaveBeenCalledWith('pages', 'p1', expect.objectContaining({ structuredDataType: 'WebPage', schemaType: 'WebPage' }), expect.any(Object));
|
|
52
|
+
});
|
|
53
|
+
it('skips documents that already have schema type and JSON-LD', async () => {
|
|
54
|
+
const db = {
|
|
55
|
+
document: {
|
|
56
|
+
findMany: vi.fn().mockResolvedValueOnce([
|
|
57
|
+
{
|
|
58
|
+
id: 'p1',
|
|
59
|
+
collection: 'pages',
|
|
60
|
+
slug: 'home',
|
|
61
|
+
status: 'PUBLISHED',
|
|
62
|
+
data: { title: 'Home', structuredDataType: 'WebPage', schemaType: 'WebPage' },
|
|
63
|
+
structuredData: { '@context': 'https://schema.org', '@type': 'WebPage' },
|
|
64
|
+
publishedAt: new Date(),
|
|
65
|
+
updatedAt: new Date(),
|
|
66
|
+
},
|
|
67
|
+
]),
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
const result = await migrateStructuredDataFields(ctxFor(db));
|
|
71
|
+
expect(result.migrated).toBe(0);
|
|
72
|
+
expect(result.skipped).toBe(1);
|
|
73
|
+
expect(updateDocumentSeoFieldsMock).not.toHaveBeenCalled();
|
|
74
|
+
});
|
|
75
|
+
it('dry run reports without writing', async () => {
|
|
76
|
+
const db = {
|
|
77
|
+
document: {
|
|
78
|
+
findMany: vi.fn().mockResolvedValueOnce([
|
|
79
|
+
{
|
|
80
|
+
id: 'p1',
|
|
81
|
+
collection: 'pages',
|
|
82
|
+
slug: 'home',
|
|
83
|
+
status: 'DRAFT',
|
|
84
|
+
data: { title: 'Draft' },
|
|
85
|
+
structuredData: null,
|
|
86
|
+
publishedAt: null,
|
|
87
|
+
updatedAt: new Date(),
|
|
88
|
+
},
|
|
89
|
+
]),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
const result = await migrateStructuredDataFields(ctxFor(db), { dryRun: true });
|
|
93
|
+
expect(result.migrated).toBe(1);
|
|
94
|
+
expect(updateDocumentSeoFieldsMock).not.toHaveBeenCalled();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=migrate-schema.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-schema.test.js","sourceRoot":"","sources":["../../../src/__tests__/seo/migrate-schema.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAA;AAEzE,MAAM,EAAE,2BAA2B,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,2BAA2B,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;CACrD,CAAC,CAAC,CAAA;AAEH,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE;IACnD,MAAM,MAAM,GAAG,MAAM,cAAc,EAAqC,CAA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;QAC9B,MAAM,CAAC,2BAA2B,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC5D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,iCAAiC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,EAAE,GAAG;YACT,QAAQ,EAAE;gBACR,QAAQ,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC;oBACtC;wBACE,EAAE,EAAE,IAAI;wBACR,UAAU,EAAE,OAAO;wBACnB,IAAI,EAAE,MAAM;wBACZ,MAAM,EAAE,OAAO;wBACf,IAAI,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;wBACxB,cAAc,EAAE,IAAI;wBACpB,WAAW,EAAE,IAAI;wBACjB,SAAS,EAAE,IAAI,IAAI,EAAE;qBACtB;iBACF,CAAC;aACH;SACF,CAAA;QAED,MAAM,MAAM,GAAG,MAAM,2BAA2B,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAA;QAE9E,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,CAAC,2BAA2B,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-sync.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/seo/schema-sync.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { applyStructuredDataFieldsToData, resolveEffectiveSchemaType, syncSchemaTypeFields, } from '../../seo/schema-sync.js';
|
|
3
|
+
const pagesCol = { slug: 'pages', type: 'page', fields: {} };
|
|
4
|
+
const faqCol = {
|
|
5
|
+
slug: 'faq',
|
|
6
|
+
type: 'page',
|
|
7
|
+
fields: {},
|
|
8
|
+
seo: { defaultSchemaType: 'FAQPage' },
|
|
9
|
+
};
|
|
10
|
+
describe('seo/schema-sync', () => {
|
|
11
|
+
it('defaults pages collection to WebPage when no explicit type is set', () => {
|
|
12
|
+
expect(resolveEffectiveSchemaType({
|
|
13
|
+
collection: 'pages',
|
|
14
|
+
data: { title: 'Home' },
|
|
15
|
+
collectionDef: pagesCol,
|
|
16
|
+
})).toBe('WebPage');
|
|
17
|
+
});
|
|
18
|
+
it('respects collection seo.defaultSchemaType', () => {
|
|
19
|
+
expect(resolveEffectiveSchemaType({
|
|
20
|
+
collection: 'faq',
|
|
21
|
+
data: {},
|
|
22
|
+
collectionDef: faqCol,
|
|
23
|
+
})).toBe('FAQPage');
|
|
24
|
+
});
|
|
25
|
+
it('prefers explicit structuredDataType on the document', () => {
|
|
26
|
+
expect(resolveEffectiveSchemaType({
|
|
27
|
+
collection: 'pages',
|
|
28
|
+
data: { structuredDataType: 'Article' },
|
|
29
|
+
collectionDef: pagesCol,
|
|
30
|
+
})).toBe('Article');
|
|
31
|
+
});
|
|
32
|
+
it('reads schema type from stored JSON-LD @graph', () => {
|
|
33
|
+
expect(resolveEffectiveSchemaType({
|
|
34
|
+
collection: 'pages',
|
|
35
|
+
data: {},
|
|
36
|
+
structuredData: {
|
|
37
|
+
'@context': 'https://schema.org',
|
|
38
|
+
'@graph': [{ '@type': 'WebSite' }, { '@type': 'FAQPage' }],
|
|
39
|
+
},
|
|
40
|
+
collectionDef: pagesCol,
|
|
41
|
+
})).toBe('FAQPage');
|
|
42
|
+
});
|
|
43
|
+
it('stamps structuredDataType on save when missing', () => {
|
|
44
|
+
const next = applyStructuredDataFieldsToData('pages', { title: 'About' }, pagesCol);
|
|
45
|
+
expect(next.structuredDataType).toBe('WebPage');
|
|
46
|
+
expect(next.schemaType).toBe('WebPage');
|
|
47
|
+
});
|
|
48
|
+
it('syncSchemaTypeFields mirrors structuredDataType to schemaType', () => {
|
|
49
|
+
expect(syncSchemaTypeFields({ structuredDataType: 'FAQPage' })).toEqual({
|
|
50
|
+
structuredDataType: 'FAQPage',
|
|
51
|
+
schemaType: 'FAQPage',
|
|
52
|
+
});
|
|
53
|
+
expect(syncSchemaTypeFields({ schemaType: 'BlogPosting' })).toEqual({
|
|
54
|
+
structuredDataType: 'BlogPosting',
|
|
55
|
+
schemaType: 'BlogPosting',
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=schema-sync.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-sync.test.js","sourceRoot":"","sources":["../../../src/__tests__/seo/schema-sync.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EACL,+BAA+B,EAC/B,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AAEjC,MAAM,QAAQ,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAW,CAAA;AACrE,MAAM,MAAM,GAAG;IACb,IAAI,EAAE,KAAK;IACX,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,EAAE;IACV,GAAG,EAAE,EAAE,iBAAiB,EAAE,SAAS,EAAE;CAC7B,CAAA;AAEV,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,mEAAmE,EAAE,GAAG,EAAE;QAC3E,MAAM,CACJ,0BAA0B,CAAC;YACzB,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;YACvB,aAAa,EAAE,QAAQ;SACxB,CAAC,CACH,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACnB,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;QACnD,MAAM,CACJ,0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AE,CAAC,CAAC,CAAC,OAAO,CAAC;YACtE,kBAAkB,EAAE,SAAS;YAC7B,UAAU,EAAE,SAAS;SACtB,CAAC,CAAA;QACF,MAAM,CAAC,oBAAoB,CAAC,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;YAClE,kBAAkB,EAAE,aAAa;YACjC,UAAU,EAAE,aAAa;SAC1B,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAQrD,OAAO,EAAqB,KAAK,cAAc,EAAwB,MAAM,uBAAuB,CAAA;AAcpG,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,uFAAuF;IACvF,EAAE,EAAE,OAAO,CAAA;CACZ;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,KAAK,GAAG,MAAM,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM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M,EAAE,OAAO,CAAC,CAAC,CA8DlC"}
|
package/dist/actions.js
CHANGED
|
@@ -4,6 +4,7 @@ import { sanitizeDocumentHtml, sanitizeLayoutTree } from './security/sanitize-do
|
|
|
4
4
|
import { layoutTreeToSections } from './sections/bridge.js';
|
|
5
5
|
import { stripInternalDataKeys } from './security/internal-keys.js';
|
|
6
6
|
import { getActuateConfig } from './config/runtime.js';
|
|
7
|
+
import { prepareContentStructuredData, syncSchemaTypeFields, applyStructuredDataFieldsToData, isPublicContentCollection, } from './seo/schema-sync.js';
|
|
7
8
|
import { validateRelations } from './fields/relations.js';
|
|
8
9
|
import { invalidationTagsForDocumentWrite, invalidationTagsForGlobalWrite } from './cache/http.js';
|
|
9
10
|
import { notifySitemapOnPublish } from './seo/sitemap-notify.js';
|
|
@@ -416,14 +417,18 @@ export async function createDocument(collection, data, ctx) {
|
|
|
416
417
|
config: getActuateConfig(),
|
|
417
418
|
});
|
|
418
419
|
}
|
|
420
|
+
const collectionDef = getActuateConfig()?.collections?.[collection];
|
|
421
|
+
const { data: dataForStore } = prepareContentStructuredData(collection, filteredData, {
|
|
422
|
+
collectionDef,
|
|
423
|
+
});
|
|
419
424
|
const pendingEffects = [];
|
|
420
425
|
const doc = await db.$transaction(async (tx) => {
|
|
421
426
|
const created = await tx.document.create({
|
|
422
427
|
data: {
|
|
423
428
|
collection,
|
|
424
|
-
title: typeof
|
|
425
|
-
slug: typeof
|
|
426
|
-
data:
|
|
429
|
+
title: typeof dataForStore.title === 'string' ? dataForStore.title : null,
|
|
430
|
+
slug: typeof dataForStore.slug === 'string' ? dataForStore.slug : null,
|
|
431
|
+
data: dataForStore,
|
|
427
432
|
status,
|
|
428
433
|
locale: ctx.locale ?? null,
|
|
429
434
|
createdById: ctx.userId,
|
|
@@ -433,10 +438,30 @@ export async function createDocument(collection, data, ctx) {
|
|
|
433
438
|
contentHash,
|
|
434
439
|
},
|
|
435
440
|
});
|
|
441
|
+
if (publishingNow && collectionDef) {
|
|
442
|
+
const publishedPrep = prepareContentStructuredData(collection, dataForStore, {
|
|
443
|
+
collectionDef,
|
|
444
|
+
config: getActuateConfig(),
|
|
445
|
+
publishing: true,
|
|
446
|
+
doc: {
|
|
447
|
+
id: created.id,
|
|
448
|
+
slug: created.slug,
|
|
449
|
+
publishedAt: created.publishedAt,
|
|
450
|
+
updatedAt: created.updatedAt,
|
|
451
|
+
},
|
|
452
|
+
});
|
|
453
|
+
if (publishedPrep.structuredData) {
|
|
454
|
+
await tx.document.update({
|
|
455
|
+
where: { id: created.id },
|
|
456
|
+
data: { structuredData: publishedPrep.structuredData },
|
|
457
|
+
});
|
|
458
|
+
created.structuredData = publishedPrep.structuredData;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
436
461
|
await tx.version.create({
|
|
437
462
|
data: {
|
|
438
463
|
documentId: created.id,
|
|
439
|
-
data:
|
|
464
|
+
data: dataForStore,
|
|
440
465
|
changedById: ctx.userId,
|
|
441
466
|
changeType: 'CREATE',
|
|
442
467
|
},
|
|
@@ -563,29 +588,55 @@ export async function updateDocument(collection, id, data, ctx) {
|
|
|
563
588
|
config: getActuateConfig(),
|
|
564
589
|
});
|
|
565
590
|
}
|
|
591
|
+
const collectionDef = getActuateConfig()?.collections?.[collection];
|
|
592
|
+
const existingStructured = existing.structuredData && typeof existing.structuredData === 'object'
|
|
593
|
+
? existing.structuredData
|
|
594
|
+
: null;
|
|
595
|
+
const seoPrep = prepareContentStructuredData(collection, filteredData, {
|
|
596
|
+
collectionDef,
|
|
597
|
+
existingStructuredData: existingStructured,
|
|
598
|
+
});
|
|
599
|
+
const dataForStore = seoPrep.data;
|
|
566
600
|
// Capture side-effects to fire AFTER the transaction commits so we never
|
|
567
601
|
// dispatch a webhook for a rolled-back write. Reuses the module-level
|
|
568
602
|
// `PendingEffect` type so newer effect kinds (e.g. cache-invalidate)
|
|
569
603
|
// are accepted here automatically.
|
|
570
604
|
const pendingEffects = [];
|
|
571
605
|
const updated = await db.$transaction(async (tx) => {
|
|
606
|
+
let structuredDataColumn;
|
|
607
|
+
if (willBePublished && collectionDef) {
|
|
608
|
+
const publishedPrep = prepareContentStructuredData(collection, dataForStore, {
|
|
609
|
+
collectionDef,
|
|
610
|
+
config: getActuateConfig(),
|
|
611
|
+
existingStructuredData: existingStructured,
|
|
612
|
+
publishing: true,
|
|
613
|
+
doc: {
|
|
614
|
+
id,
|
|
615
|
+
slug: typeof dataForStore.slug === 'string' ? dataForStore.slug : existing.slug,
|
|
616
|
+
publishedAt: isPublishingNow ? new Date() : existing.publishedAt,
|
|
617
|
+
updatedAt: new Date(),
|
|
618
|
+
},
|
|
619
|
+
});
|
|
620
|
+
structuredDataColumn = publishedPrep.structuredData ?? undefined;
|
|
621
|
+
}
|
|
572
622
|
const result = await tx.document.update({
|
|
573
623
|
where: { id },
|
|
574
624
|
data: {
|
|
575
|
-
title: typeof
|
|
576
|
-
slug: typeof
|
|
577
|
-
data:
|
|
625
|
+
title: typeof dataForStore.title === 'string' ? dataForStore.title : undefined,
|
|
626
|
+
slug: typeof dataForStore.slug === 'string' ? dataForStore.slug : undefined,
|
|
627
|
+
data: dataForStore,
|
|
578
628
|
updatedById: ctx.userId,
|
|
579
629
|
plainText,
|
|
580
630
|
contentHash,
|
|
581
631
|
...(status ? { status } : {}),
|
|
582
632
|
...(isPublishingNow ? { publishedAt: new Date() } : {}),
|
|
633
|
+
...(structuredDataColumn ? { structuredData: structuredDataColumn } : {}),
|
|
583
634
|
},
|
|
584
635
|
});
|
|
585
636
|
await tx.version.create({
|
|
586
637
|
data: {
|
|
587
638
|
documentId: id,
|
|
588
|
-
data:
|
|
639
|
+
data: dataForStore,
|
|
589
640
|
changedById: ctx.userId,
|
|
590
641
|
changeType: 'UPDATE',
|
|
591
642
|
},
|
|
@@ -681,7 +732,17 @@ export async function updateDocumentSeoFields(collection, id, seoFields, ctx) {
|
|
|
681
732
|
const existingData = existing.data && typeof existing.data === 'object'
|
|
682
733
|
? existing.data
|
|
683
734
|
: {};
|
|
684
|
-
const
|
|
735
|
+
const collectionDef = getActuateConfig()?.collections?.[collection];
|
|
736
|
+
const existingStructured = existing.structuredData && typeof existing.structuredData === 'object'
|
|
737
|
+
? existing.structuredData
|
|
738
|
+
: null;
|
|
739
|
+
let nextData = { ...existingData, ...seoFields };
|
|
740
|
+
if ('structuredDataType' in seoFields || 'schemaType' in seoFields) {
|
|
741
|
+
nextData = syncSchemaTypeFields(nextData);
|
|
742
|
+
}
|
|
743
|
+
if (isPublicContentCollection(collectionDef)) {
|
|
744
|
+
nextData = applyStructuredDataFieldsToData(collection, nextData, collectionDef, existingStructured);
|
|
745
|
+
}
|
|
685
746
|
const { plainText, contentHash } = await computeTextFields(nextData);
|
|
686
747
|
const pendingEffects = [];
|
|
687
748
|
const updated = await db.$transaction(async (tx) => {
|