@prenta/plugin-seo 0.1.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +274 -0
  2. package/LICENSE +21 -0
  3. package/README.md +29 -0
  4. package/dist/__tests__/audit-fixes.test.d.ts +2 -0
  5. package/dist/__tests__/audit-fixes.test.d.ts.map +1 -0
  6. package/dist/__tests__/audit-fixes.test.js +162 -0
  7. package/dist/__tests__/audit-fixes.test.js.map +1 -0
  8. package/dist/__tests__/canonical.test.d.ts +2 -0
  9. package/dist/__tests__/canonical.test.d.ts.map +1 -0
  10. package/dist/__tests__/canonical.test.js +67 -0
  11. package/dist/__tests__/canonical.test.js.map +1 -0
  12. package/dist/__tests__/hooks.test.d.ts +2 -0
  13. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  14. package/dist/__tests__/hooks.test.js +106 -0
  15. package/dist/__tests__/hooks.test.js.map +1 -0
  16. package/dist/__tests__/index.test.d.ts +2 -0
  17. package/dist/__tests__/index.test.d.ts.map +1 -0
  18. package/dist/__tests__/index.test.js +43 -0
  19. package/dist/__tests__/index.test.js.map +1 -0
  20. package/dist/__tests__/link-health.test.d.ts +2 -0
  21. package/dist/__tests__/link-health.test.d.ts.map +1 -0
  22. package/dist/__tests__/link-health.test.js +140 -0
  23. package/dist/__tests__/link-health.test.js.map +1 -0
  24. package/dist/__tests__/og-image.test.d.ts +2 -0
  25. package/dist/__tests__/og-image.test.d.ts.map +1 -0
  26. package/dist/__tests__/og-image.test.js +45 -0
  27. package/dist/__tests__/og-image.test.js.map +1 -0
  28. package/dist/__tests__/robots.test.d.ts +2 -0
  29. package/dist/__tests__/robots.test.d.ts.map +1 -0
  30. package/dist/__tests__/robots.test.js +27 -0
  31. package/dist/__tests__/robots.test.js.map +1 -0
  32. package/dist/__tests__/schema-composer.test.d.ts +2 -0
  33. package/dist/__tests__/schema-composer.test.d.ts.map +1 -0
  34. package/dist/__tests__/schema-composer.test.js +47 -0
  35. package/dist/__tests__/schema-composer.test.js.map +1 -0
  36. package/dist/__tests__/schema-validator.test.d.ts +2 -0
  37. package/dist/__tests__/schema-validator.test.d.ts.map +1 -0
  38. package/dist/__tests__/schema-validator.test.js +129 -0
  39. package/dist/__tests__/schema-validator.test.js.map +1 -0
  40. package/dist/__tests__/sitemap.test.d.ts +2 -0
  41. package/dist/__tests__/sitemap.test.d.ts.map +1 -0
  42. package/dist/__tests__/sitemap.test.js +196 -0
  43. package/dist/__tests__/sitemap.test.js.map +1 -0
  44. package/dist/admin/GooglePreview.d.ts +9 -0
  45. package/dist/admin/GooglePreview.d.ts.map +1 -0
  46. package/dist/admin/GooglePreview.js +68 -0
  47. package/dist/admin/GooglePreview.js.map +1 -0
  48. package/dist/admin/SEOPanel.d.ts +11 -0
  49. package/dist/admin/SEOPanel.d.ts.map +1 -0
  50. package/dist/admin/SEOPanel.js +76 -0
  51. package/dist/admin/SEOPanel.js.map +1 -0
  52. package/dist/admin/SchemaPreview.d.ts +7 -0
  53. package/dist/admin/SchemaPreview.d.ts.map +1 -0
  54. package/dist/admin/SchemaPreview.js +93 -0
  55. package/dist/admin/SchemaPreview.js.map +1 -0
  56. package/dist/canonical/index.d.ts +16 -0
  57. package/dist/canonical/index.d.ts.map +1 -0
  58. package/dist/canonical/index.js +77 -0
  59. package/dist/canonical/index.js.map +1 -0
  60. package/dist/collections.d.ts +3 -0
  61. package/dist/collections.d.ts.map +1 -0
  62. package/dist/collections.js +2 -0
  63. package/dist/collections.js.map +1 -0
  64. package/dist/fields.d.ts +3 -0
  65. package/dist/fields.d.ts.map +1 -0
  66. package/dist/fields.js +115 -0
  67. package/dist/fields.js.map +1 -0
  68. package/dist/hooks.d.ts +15 -0
  69. package/dist/hooks.d.ts.map +1 -0
  70. package/dist/hooks.js +20 -0
  71. package/dist/hooks.js.map +1 -0
  72. package/dist/index.d.ts +59 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +37 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/link-health/index.d.ts +48 -0
  77. package/dist/link-health/index.d.ts.map +1 -0
  78. package/dist/link-health/index.js +171 -0
  79. package/dist/link-health/index.js.map +1 -0
  80. package/dist/og-image/index.d.ts +11 -0
  81. package/dist/og-image/index.d.ts.map +1 -0
  82. package/dist/og-image/index.js +28 -0
  83. package/dist/og-image/index.js.map +1 -0
  84. package/dist/robots/index.d.ts +14 -0
  85. package/dist/robots/index.d.ts.map +1 -0
  86. package/dist/robots/index.js +45 -0
  87. package/dist/robots/index.js.map +1 -0
  88. package/dist/schema/auto-detect.d.ts +3 -0
  89. package/dist/schema/auto-detect.d.ts.map +1 -0
  90. package/dist/schema/auto-detect.js +3 -0
  91. package/dist/schema/auto-detect.js.map +1 -0
  92. package/dist/schema/composer.d.ts +15 -0
  93. package/dist/schema/composer.d.ts.map +1 -0
  94. package/dist/schema/composer.js +82 -0
  95. package/dist/schema/composer.js.map +1 -0
  96. package/dist/schema/registry.d.ts +170 -0
  97. package/dist/schema/registry.d.ts.map +1 -0
  98. package/dist/schema/registry.js +2 -0
  99. package/dist/schema/registry.js.map +1 -0
  100. package/dist/schema/validator.d.ts +23 -0
  101. package/dist/schema/validator.d.ts.map +1 -0
  102. package/dist/schema/validator.js +148 -0
  103. package/dist/schema/validator.js.map +1 -0
  104. package/dist/sitemap/index.d.ts +110 -0
  105. package/dist/sitemap/index.d.ts.map +1 -0
  106. package/dist/sitemap/index.js +228 -0
  107. package/dist/sitemap/index.js.map +1 -0
  108. package/package.json +43 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,274 @@
1
+ # @actuate-media/plugin-seo
2
+
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 5eea995: Product rename: ActuateCMS is now **Prenta**. Every package moves from the
8
+ `@actuate-media/*` scope to `@prenta/*` with simplified names (`@prenta/core`,
9
+ `@prenta/admin`, `create-prenta`), and version numbers continue from where the
10
+ old scope left off.
11
+
12
+ This is a clean break — no backwards-compat aliases:
13
+ - **npm packages**: `@actuate-media/cms-core` → `@prenta/core`,
14
+ `@actuate-media/cms-admin` → `@prenta/admin`, all other packages keep their
15
+ suffix under `@prenta/*`. `create-actuate-cms` → `create-prenta`
16
+ (`npm create prenta`), `create-actuate-astro` → `create-prenta-astro`.
17
+ CLI bins: `actuate`/`actuate-cms` → `prenta`/`prenta-cms`; `actuate-mcp` →
18
+ `prenta-mcp`.
19
+ - **Database**: migration `0012_rename_to_prenta` renames all 36 `actuate_*`
20
+ tables to `prenta_*` in place (plus prefixed constraints, indexes, and
21
+ sequences). Run `prisma migrate deploy` when upgrading.
22
+ - **Runtime identifiers**: `getActuateConfig` → `getPrentaConfig`,
23
+ `handleActuateAPI` → `handlePrentaAPI`, `ActuateClient` → `PrentaClient`,
24
+ `ActuateDB` → `PrentaDB`, config file `actuate.config.ts` →
25
+ `prenta.config.ts`, CSS scopes `.actuate-admin`/`.actuate-canvas` →
26
+ `.prenta-admin`/`.prenta-canvas`, preview protocol `actuate-preview:*` →
27
+ `prenta-preview:*`, webhook headers `X-Actuate-*` → `X-Prenta-*`, session
28
+ cookie `actuate_session` → `prenta_session`, env vars `ACTUATE_*` →
29
+ `PRENTA_*`, purge route `/api/actuate/purge` → `/api/prenta/purge`.
30
+ - **Sessions and webhooks**: all sessions reset on upgrade (cookie + JWT issuer
31
+ changed); webhook consumers must re-verify signatures against the new
32
+ `X-Prenta-*` headers.
33
+
34
+ The old `@actuate-media/*` packages are deprecated on npm and will receive no
35
+ further releases.
36
+
37
+ ## 0.0.21
38
+
39
+ ### Patch Changes
40
+
41
+ - b111907: `buildDocumentUrl` and `generateCollectionSitemap` now resolve document URLs through cms-core's `resolveDocumentUrl` — the same authority the CMS sitemap route uses — instead of naive `{base}/{prefix}/{slug}` joining. Root-mapped documents (slug `home` or `index`) emit the canonical site root in `<loc>` instead of `/home`, and `buildDocumentUrl` accepts an optional explicit `path` argument that takes precedence over the slug (issue #771).
42
+
43
+ ## 0.0.20
44
+
45
+ ### Patch Changes
46
+
47
+ - a26f61a: Fix Live link health false positives: extract outbound URLs from unescaped document fields (not `JSON.stringify`), strip trailing `\` artifacts, probe with GET + browser UA, treat 3xx as healthy and 403/405/429/999 as unverifiable, and skip first-party Vercel Blob media.
48
+
49
+ ## 0.0.19
50
+
51
+ ### Patch Changes
52
+
53
+ - daf91b4: Fix `composeSchema` never coercing a bare-string nested field into a typed entity.
54
+
55
+ The generic data-copy loop already placed the raw string on the schema, so the
56
+ `!schema[field]` guard on the coercion branch was always false and the branch was
57
+ dead code — e.g. `Article.author: 'Jane'` shipped as the raw string `"Jane"`
58
+ instead of `{ '@type': 'Person', name: 'Jane' }`. A bare string on a
59
+ nested-entity field is now wrapped into the correct entity type.
60
+
61
+ ## 0.0.18
62
+
63
+ ### Patch Changes
64
+
65
+ - e25cd48: Standardize React peer ranges to `^18.0.0 || ^19.0.0`.
66
+
67
+ Plugin React peer ranges were inconsistent: `plugin-ai`, `plugin-commerce`, and
68
+ `plugin-seo` pinned `react: ^19.2.0` (excluding React 18, which `cms-core`
69
+ supports via `react >=18.0.0`), while the others used `^18.0.0 || ^19.2.0`
70
+ (excluding React 19.0/19.1). Either produced an `ERESOLVE` install failure for
71
+ consumers on the excluded versions. All bundled plugins now declare `react`
72
+ (and `react-dom` where already peered) as `^18.0.0 || ^19.0.0`.
73
+
74
+ ## 0.0.17
75
+
76
+ ### Patch Changes
77
+
78
+ - 2e36f83: Declutter the SEO sidebar: surface a single "SEO" entry instead of three.
79
+
80
+ The plugin listed "SEO Overview", "Sitemap", and "Link Health" as separate
81
+ sidebar items, but the SEO Operations Center is a tabbed hub — Sitemap and Link
82
+ Health have no page of their own; they just deep-link into that hub's Technical
83
+ and Links tabs. So the sidebar duplicated the tab bar with mismatched labels
84
+ ("Link Health" opened a tab called "Links"). Now `plugin-seo` contributes one
85
+ "SEO" entry. Deep links to `/seo/sitemap` and `/seo/link-health` still resolve
86
+ (via cms-admin's `seoTabForPath`) so existing bookmarks keep working.
87
+
88
+ ## 0.0.16
89
+
90
+ ### Patch Changes
91
+
92
+ - c231dd0: Add `definePlugin` and migrate all 10 plugins onto the canonical `PluginDefinition` contract.
93
+
94
+ cms-core already exported `PluginDefinition`, but every plugin hand-rolled a
95
+ local `ActuatePlugin` interface — a lossy subset that dropped `version`/`init`
96
+ and, in blocks/email/ai, widened hook payloads to `unknown[]`/`event: string`.
97
+ That's copy-paste drift with no shared source of truth.
98
+
99
+ `cms-core` now exports `definePlugin(plugin: PluginDefinition)` (an identity
100
+ helper like `defineConfig`), and each plugin imports the canonical type instead
101
+ of its own: the local `ActuatePlugin` interfaces are deleted, factory return
102
+ types are `PluginDefinition`, and the widened `hooks.ts` types are retyped as
103
+ `PluginHook[]`. Type-only change — no runtime behavior, plugin `name`, or config
104
+ options changed. Net −69 lines.
105
+
106
+ - 325694f: Import `definePlugin` from the lightweight `@actuate-media/cms-core/config`
107
+ entry instead of the barrel.
108
+
109
+ The plugin-definition migration imported the `definePlugin` **value** from
110
+ `@actuate-media/cms-core`, which pulls the entire cms-core barrel (graphql,
111
+ sharp, sentry, codegen) into every plugin's runtime — bundle bloat for
112
+ consumers and, under parallel test load, a timeout. The `/config` subpath exists
113
+ precisely to avoid the barrel. Types stay as erased `import type`, so nothing
114
+ heavy is loaded. No API or behavior change.
115
+
116
+ ## 0.0.15
117
+
118
+ ### Patch Changes
119
+
120
+ - cc18833: SEO audit remediation — 47 verified fixes across the SEO system.
121
+
122
+ Highlights: redirect middleware no longer excludes legacy `.html/.php/.aspx`
123
+ URLs (migrations); robots.txt now `Allow`s the default OG image (`/api/cms/og.png`)
124
+ so social shares render; RSS always emits the mandatory channel `<description>`;
125
+ structured-data auto-detection no longer emits invalid `Review/Event/JobPosting`
126
+ (required fields enforced or the node is suppressed) and no longer mis-types
127
+ collections by substring (`newsletters`→NewsArticle etc.); the sitemap endpoint
128
+ no longer selects full document JSON for up to 45k rows; IndexNow submits on
129
+ every publish instead of being swallowed by the sitemap debounce; the exported
130
+ `renderJsonLdScript()` now escapes `<`; the editor no longer shows two
131
+ conflicting scores and the Content-tab analysis now understands section-built
132
+ pages; plus pagination `rel`/canonical, `og:locale` normalization + alternates,
133
+ canonical absolutization, VideoObject/Product/WebSite-SearchAction builders,
134
+ redirect loop/case handling, plugin-seo sitemap caps + real `lastmod`, and
135
+ plugin link-health routed through `safeFetch`. Adds several new exports on
136
+ `@actuate-media/cms-core` (e.g. `buildVideoObjectSchema`, `buildProductSchema`).
137
+
138
+ ## 0.0.14
139
+
140
+ ### Patch Changes
141
+
142
+ - 041a228: Add the MIT `license` field to every published package (previously missing) and correct `repository.url` to `github.com/actuate-media/actuatecms` (13 packages carried the wrong org).
143
+ - de419f2: Give plugin hooks a frozen, typed event contract. cms-core now exports
144
+ `PluginHook`, `PluginHookEvent`, and `PluginHookPayload` (document + upload
145
+ variants) as the single source of truth, and dispatches a complete, consistent
146
+ set of events: `afterCreate` / `afterUpdate` / `afterDelete` — each also in a
147
+ collection-namespaced form (`afterUpdate:navigations`, `afterCreate:orders`) —
148
+ plus `afterUpload` (fired post-upload from the media route). Every handler now
149
+ receives one typed payload; document field values live on `payload.data`.
150
+
151
+ Previously core fired only bare `afterCreate`/`afterUpdate` with the raw row, so
152
+ several shipped plugins' hooks were dead: `plugin-media`'s `afterUpload` never
153
+ fired, `plugin-navigation` read fields that didn't exist, and the namespaced
154
+ events `plugin-forms`/`plugin-commerce` declared were never dispatched. Each
155
+ plugin has been aligned to the shared type and dispatched events (and
156
+ `plugin-redirects`' request-time `onRedirectMatch` hook — which the lifecycle
157
+ bus never dispatched — was removed). Undispatched event names are now a
158
+ compile-time error.
159
+
160
+ ## 0.0.13
161
+
162
+ ### Patch Changes
163
+
164
+ - 869620b: Align SEO audit, render, and Content SEO editing: auto-canonical and effective schema type resolution match `composePageMeta()`, schema fields sync on save, Content SEO drawer adds schema type, plugin removes dead `beforeCreate` hook and re-exports cms-core schema detection.
165
+
166
+ ## 0.0.12
167
+
168
+ ### Patch Changes
169
+
170
+ - 854152d: Developer experience improvements from external-consumer feedback:
171
+ - Every published package now ships its `CHANGELOG.md` in the npm tarball, and packages that were missing a `README.md` (cli, cms-admin, cms-core, import, platform-vercel, all plugins, sections-react) now have one — so release notes and usage docs are visible on npmjs.com and in `node_modules`.
172
+ - New client-safe form validation entry point: `@actuate-media/cms-core/forms/client` exports `validateFormFieldClient()`, `validateFormValuesClient()`, visibility/conditional helpers, and the exact `FORM_EMAIL_RE` / `FORM_PHONE_RE` regexes the server enforces — zero Node dependencies, so public-site forms can mirror server rules without reimplementing them. The server validator now imports the same primitives, so client and server can never drift.
173
+
174
+ ## 0.0.11
175
+
176
+ ### Patch Changes
177
+
178
+ - b5de8dd: Fix ESM module resolution and dependency duplication issues reported during consumer integration.
179
+ - Add "default" export condition to all platform and plugin packages so they resolve correctly from require() contexts (fixes ERR_PACKAGE_PATH_NOT_EXPORTED in next.config.ts and serverless functions).
180
+ - Move @actuate-media/cms-core from direct dependencies to peerDependencies across all packages to prevent duplicate installations when consumer version ranges don't exactly match the pinned version.
181
+ - Add "prepack" lifecycle script to create-actuate-cms to guarantee dist/ is built before npm publishes the package (fixes empty dist/ in v0.4.0).
182
+
183
+ ## 0.0.10
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [54c7a3b]
188
+ - @actuate-media/cms-core@0.6.0
189
+
190
+ ## 0.0.9
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies [c08cf8b]
195
+ - Updated dependencies [80aa939]
196
+ - @actuate-media/cms-core@0.5.0
197
+
198
+ ## 0.0.8
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies [f2cf7d7]
203
+ - @actuate-media/cms-core@0.4.0
204
+
205
+ ## 0.0.7
206
+
207
+ ### Patch Changes
208
+
209
+ - Updated dependencies [0621037]
210
+ - @actuate-media/cms-core@0.3.1
211
+
212
+ ## 0.0.6
213
+
214
+ ### Patch Changes
215
+
216
+ - Updated dependencies [4e3a5eb]
217
+ - @actuate-media/cms-core@0.3.0
218
+
219
+ ## 0.0.5
220
+
221
+ ### Patch Changes
222
+
223
+ - Updated dependencies
224
+ - @actuate-media/cms-core@0.2.3
225
+
226
+ ## 0.0.4
227
+
228
+ ### Patch Changes
229
+
230
+ - Updated dependencies
231
+ - @actuate-media/cms-core@0.2.2
232
+
233
+ ## 0.0.3
234
+
235
+ ### Patch Changes
236
+
237
+ - Updated dependencies
238
+ - @actuate-media/cms-core@0.2.1
239
+
240
+ ## 0.0.2
241
+
242
+ ### Patch Changes
243
+
244
+ - 3fd38a2: Fix all 13 integration issues discovered during MaidPro.co deployment
245
+
246
+ **cms-core:**
247
+ - Add .js extensions to all ESM relative imports (58 files)
248
+ - Replace workspace:\* with versioned deps in all packages
249
+ - Add sideEffects:false for proper tree-shaking
250
+ - Subpath exports (/config, /api, /middleware, /next) avoid barrel side effects
251
+ - Stats/search routes use safeCount/safeFindMany for missing Prisma models
252
+ - Ship prisma/cms-schema.prisma with all required CMS models
253
+ - Accept both CMS_SECRET and CMS_SESSION_SECRET with clear error messages
254
+ - Fix hardcoded /admin paths in OAuth flow (now uses getAdminPath())
255
+ - Loosen withActuateCMS and createCMSMiddleware parameter types
256
+ - Auto-inject transpilePackages and serverExternalPackages in withActuateCMS
257
+ - Unify PluginDefinition with ActuatePlugin interface
258
+
259
+ **cms-admin:**
260
+ - Scope all 40+ CSS theme variables to .actuate-admin instead of :root
261
+ - ThemeProvider applies dark class to .actuate-admin, not document.documentElement
262
+ - Scaffold uses (admin)/(site) route groups for full CSS/script isolation
263
+ - Sidebar branding supports custom logo via config.admin.branding
264
+
265
+ **platform-vercel:**
266
+ - Email adapter accepts both `from` and `defaultFrom`
267
+
268
+ **All plugin/platform packages:**
269
+ - Fix ESM .js extensions in compiled output
270
+ - Replace workspace:\* with ^0.1.0 for publishable deps
271
+
272
+ - Updated dependencies [682dac7]
273
+ - Updated dependencies [3fd38a2]
274
+ - @actuate-media/cms-core@0.2.0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Actuate Media
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @prenta/plugin-seo
2
+
3
+ SEO toolkit for [Prenta CMS](https://github.com/actuate-media/prenta) —
4
+ meta/OG fields, sitemaps, robots controls, structured data, and site-wide SEO
5
+ scans.
6
+
7
+ ```bash
8
+ npm install @prenta/plugin-seo
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { seoPlugin } from '@prenta/plugin-seo'
15
+
16
+ export default defineConfig({
17
+ plugins: [seoPlugin()],
18
+ // ...
19
+ })
20
+ ```
21
+
22
+ ## Release notes
23
+
24
+ See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
25
+ [GitHub releases](https://github.com/actuate-media/prenta/releases).
26
+
27
+ ## License
28
+
29
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=audit-fixes.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-fixes.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/audit-fixes.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,162 @@
1
+ import { describe, it, expect, vi, afterEach } from 'vitest';
2
+ import { generateSitemapIndex, generateCollectionSitemap, SITEMAP_MAX_URLS, } from '../sitemap/index.js';
3
+ import { generateRobotsTxt } from '../robots/index.js';
4
+ import { validateSchemaGraph } from '../schema/validator.js';
5
+ import { composeAndValidateSchema } from '../schema/composer.js';
6
+ import { detectRedirectChains, detectBrokenLinks, MAX_LINKS } from '../link-health/index.js';
7
+ import { AI_TRAINING_BOTS, AI_RETRIEVAL_BOTS } from '@prenta/core';
8
+ // ---------------------------------------------------------------------------
9
+ // Finding 1 — sitemap 50k/50MB cap + stable index lastmod + Yoast child URLs
10
+ // ---------------------------------------------------------------------------
11
+ describe('sitemap generators (finding 1)', () => {
12
+ it('does not stamp a churning Date.now() lastmod on the index', () => {
13
+ const out = generateSitemapIndex(['posts'], 'https://example.com');
14
+ expect(out).not.toContain('<lastmod>');
15
+ // Yoast-style child URL, aligned with the core route.
16
+ expect(out).toContain('<loc>https://example.com/posts-sitemap.xml</loc>');
17
+ });
18
+ it('derives index lastmod from the collection newest-entry timestamp', () => {
19
+ const out = generateSitemapIndex([{ slug: 'posts', type: 'post', lastmod: '2026-01-02T03:04:05.000Z' }], 'https://example.com');
20
+ expect(out).toContain('<lastmod>2026-01-02T03:04:05.000Z</lastmod>');
21
+ // `post` Yoast base name for the canonical posts collection.
22
+ expect(out).toContain('<loc>https://example.com/post-sitemap.xml</loc>');
23
+ });
24
+ it('is deterministic across calls (same input -> same output)', () => {
25
+ const cfg = [{ slug: 'pages', type: 'page', lastmod: '2026-01-01T00:00:00.000Z' }];
26
+ expect(generateSitemapIndex(cfg, 'https://x.com')).toBe(generateSitemapIndex(cfg, 'https://x.com'));
27
+ });
28
+ it('renders a normal collection sitemap under the cap', () => {
29
+ const entries = [{ loc: 'a', lastmod: '2026-01-01' }, { loc: 'b' }];
30
+ const xml = generateCollectionSitemap(entries, 'https://example.com');
31
+ expect(xml).toContain('<loc>https://example.com/a</loc>');
32
+ expect(xml).toContain('<loc>https://example.com/b</loc>');
33
+ });
34
+ it('throws past the 50,000-URL limit instead of emitting an oversized file', () => {
35
+ const entries = Array.from({ length: SITEMAP_MAX_URLS + 1 }, (_, i) => ({
36
+ loc: `p${i}`,
37
+ }));
38
+ expect(() => generateCollectionSitemap(entries, 'https://example.com')).toThrow(RangeError);
39
+ });
40
+ it('accepts exactly the 50,000-URL limit', () => {
41
+ const entries = Array.from({ length: SITEMAP_MAX_URLS }, (_, i) => ({
42
+ loc: `p${i}`,
43
+ }));
44
+ expect(() => generateCollectionSitemap(entries, 'https://example.com')).not.toThrow();
45
+ });
46
+ });
47
+ // ---------------------------------------------------------------------------
48
+ // Finding 2 — validateSchema wired into the compose path (via @graph adapter)
49
+ // ---------------------------------------------------------------------------
50
+ describe('schema validation wiring (finding 2)', () => {
51
+ it('validateSchemaGraph flags a node in a @graph missing required fields', () => {
52
+ const graph = {
53
+ '@context': 'https://schema.org',
54
+ '@graph': [
55
+ { '@type': 'Article', headline: 'Hi', author: 'Jane', datePublished: '2026-01-01' },
56
+ { '@type': 'Review', reviewRating: { ratingValue: 5 } }, // missing itemReviewed, author
57
+ ],
58
+ };
59
+ const result = validateSchemaGraph(graph);
60
+ expect(result.valid).toBe(false);
61
+ const fields = result.errors.map((e) => e.field);
62
+ expect(fields).toContain('@graph[1].itemReviewed');
63
+ expect(fields).toContain('@graph[1].author');
64
+ // The valid Article node (node 0) has no error-severity findings.
65
+ const node0Errors = result.errors.filter((e) => e.field.startsWith('@graph[0].') && e.severity === 'error');
66
+ expect(node0Errors).toEqual([]);
67
+ });
68
+ it('validateSchemaGraph does not flag nodes for a wrapper-provided @context', () => {
69
+ const graph = {
70
+ '@context': 'https://schema.org',
71
+ '@graph': [{ '@type': 'Organization', name: 'Acme' }],
72
+ };
73
+ const result = validateSchemaGraph(graph);
74
+ expect(result.errors.some((e) => e.field.endsWith('@context'))).toBe(false);
75
+ expect(result.valid).toBe(true);
76
+ });
77
+ it('composeAndValidateSchema exercises the validator on the emitted node', () => {
78
+ const { schema, validation } = composeAndValidateSchema('Event', { name: 'Launch' });
79
+ expect(schema['@type']).toBe('Event');
80
+ // Missing startDate -> flagged, not silently shipped.
81
+ expect(validation.valid).toBe(false);
82
+ expect(validation.errors.some((e) => e.field === 'startDate')).toBe(true);
83
+ });
84
+ });
85
+ // ---------------------------------------------------------------------------
86
+ // Finding 3 — robots delegates to the canonical cms-core AI bot taxonomy
87
+ // ---------------------------------------------------------------------------
88
+ describe('generateRobotsTxt AI bots (finding 3)', () => {
89
+ it('blocks the full canonical training + retrieval taxonomy', () => {
90
+ const txt = generateRobotsTxt({ blockAIBots: true });
91
+ for (const bot of [...AI_TRAINING_BOTS, ...AI_RETRIEVAL_BOTS]) {
92
+ expect(txt).toContain(`User-agent: ${bot}`);
93
+ }
94
+ // 2026 bots that the stale hardcoded list of 8 was missing.
95
+ for (const bot of ['PerplexityBot', 'Amazonbot', 'Applebot-Extended', 'OAI-SearchBot']) {
96
+ expect(txt).toContain(`User-agent: ${bot}`);
97
+ }
98
+ });
99
+ it('does not emit AI bot rules when blockAIBots is off', () => {
100
+ const txt = generateRobotsTxt({ blockAIBots: false });
101
+ expect(txt).not.toContain('GPTBot');
102
+ });
103
+ it('dedupes an additional bot that repeats a canonical token', () => {
104
+ const txt = generateRobotsTxt({ blockAIBots: true, additionalAIBots: ['GPTBot'] });
105
+ expect(txt.match(/User-agent: GPTBot/g)?.length).toBe(1);
106
+ });
107
+ });
108
+ // ---------------------------------------------------------------------------
109
+ // Finding 4 — redirect loops distinguished from terminating chains
110
+ // ---------------------------------------------------------------------------
111
+ describe('detectRedirectChains (finding 4)', () => {
112
+ it('labels a cycle as a loop, not a chain', () => {
113
+ const result = detectRedirectChains([
114
+ { from: 'A', to: 'B' },
115
+ { from: 'B', to: 'A' },
116
+ ]);
117
+ expect(result).toHaveLength(1);
118
+ expect(result[0].kind).toBe('loop');
119
+ expect(result[0].chain).toEqual(['A', 'B', 'A']);
120
+ });
121
+ it('labels a terminating multi-hop redirect as a chain', () => {
122
+ const result = detectRedirectChains([
123
+ { from: 'A', to: 'B' },
124
+ { from: 'B', to: 'C' },
125
+ ]);
126
+ expect(result).toHaveLength(1);
127
+ expect(result[0].kind).toBe('chain');
128
+ expect(result[0].finalUrl).toBe('C');
129
+ expect(result[0].length).toBe(2);
130
+ });
131
+ it('does not emit a chain for a single hop', () => {
132
+ expect(detectRedirectChains([{ from: 'A', to: 'B' }])).toEqual([]);
133
+ });
134
+ });
135
+ // ---------------------------------------------------------------------------
136
+ // Finding 5 — broken-link checker uses safeFetch, caps links, keeps timeout
137
+ // ---------------------------------------------------------------------------
138
+ describe('detectBrokenLinks (finding 5)', () => {
139
+ afterEach(() => {
140
+ vi.restoreAllMocks();
141
+ });
142
+ it('blocks SSRF targets (loopback) via safeFetch instead of raw fetch', async () => {
143
+ const fetchSpy = vi.spyOn(globalThis, 'fetch');
144
+ const html = '<a href="http://127.0.0.1/admin">x</a>';
145
+ const results = await detectBrokenLinks(html, 'https://example.com');
146
+ expect(results).toHaveLength(1);
147
+ expect(results[0].status).toBe('blocked');
148
+ // safeFetch's SSRF preflight rejects before any network fetch is issued.
149
+ expect(fetchSpy).not.toHaveBeenCalled();
150
+ });
151
+ it('caps the number of links scanned at MAX_LINKS', async () => {
152
+ const fetchSpy = vi.spyOn(globalThis, 'fetch');
153
+ // Distinct loopback paths: rejected by safeFetch's synchronous IP-literal
154
+ // check (no DNS, no network), so this exercises the cap without hanging.
155
+ const html = Array.from({ length: MAX_LINKS + 50 }, (_, i) => `<a href="http://127.0.0.1/p${i}">x</a>`).join('');
156
+ const results = await detectBrokenLinks(html, 'https://example.com');
157
+ expect(results).toHaveLength(MAX_LINKS);
158
+ expect(results.every((r) => r.status === 'blocked')).toBe(true);
159
+ expect(fetchSpy).not.toHaveBeenCalled();
160
+ });
161
+ });
162
+ //# sourceMappingURL=audit-fixes.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-fixes.test.js","sourceRoot":"","sources":["../../src/__tests__/audit-fixes.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAC5D,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAC5F,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAElE,8EAA8E;AAC9E,6EAA6E;AAC7E,8EAA8E;AAC9E,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,EAAE,CAAC,2DAA2D,EAAE,GAAG,EAAE;QACnE,MAAM,GAAG,GAAG,oBAAoB,CAAC,CAAC,OAAO,CAAC,EAAE,qBAAqB,CAAC,CAAA;QAClE,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,WAAW,CAAC,CAAA;QACtC,sDAAsD;QACtD,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,CAAC,kDAAkD,CAAC,CAAA;IAC3E,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,kEAAkE,EAAE,GAAG,EAAE;QAC1E,MAAM,GAAG,GAAG,oBAAoB,CAC9B,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,E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AAE,CAAC,KAAK,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;QAC9C,0EAA0E;QAC1E,yEAAyE;QACzE,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CACrB,EAAE,MAAM,EAAE,SAAS,GAAG,EAAE,EAAE,EAC1B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,8BAA8B,CAAC,SAAS,CACnD,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;QACV,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,CAAC,CAAA;QACpE,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;QACvC,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC/D,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=canonical.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/canonical.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { detectDuplicates, suggestCanonical } from '../canonical/index.js';
3
+ // Gap 4: detectDuplicates groups pages by Dice-coefficient similarity >= 0.85,
4
+ // marks members assigned (single-group membership), and attaches a
5
+ // suggestedCanonical. Unrelated / below-threshold pages form no group.
6
+ describe('detectDuplicates (gap 4)', () => {
7
+ it('groups the two near-identical pages and excludes the unrelated one', () => {
8
+ const shared = 'the quick brown fox jumps over the lazy dog while the sun rises today';
9
+ const groups = detectDuplicates([
10
+ { url: '/dup-a', content: shared },
11
+ { url: '/dup-b', content: shared },
12
+ {
13
+ url: '/other',
14
+ content: 'completely unrelated marketing copy about kitchen appliances',
15
+ },
16
+ ]);
17
+ expect(groups).toHaveLength(1);
18
+ const group = groups[0];
19
+ expect(group.urls).toEqual(['/dup-a', '/dup-b']);
20
+ expect(group.similarity).toBeGreaterThanOrEqual(0.85);
21
+ // The unrelated page is not a member of any group.
22
+ expect(group.urls).not.toContain('/other');
23
+ // A canonical is chosen from the group members.
24
+ expect(group.urls).toContain(group.suggestedCanonical);
25
+ });
26
+ it('does NOT group a pair whose similarity sits just below 0.85', () => {
27
+ // Two 10-token sets sharing 8 tokens -> Dice = 2*8/(10+10) = 0.80 < 0.85.
28
+ const a = 'alpha bravo charlie delta echo foxtrot golf hotel india juliet';
29
+ const b = 'alpha bravo charlie delta echo foxtrot golf hotel kilo lima';
30
+ const groups = detectDuplicates([
31
+ { url: '/a', content: a },
32
+ { url: '/b', content: b },
33
+ ]);
34
+ expect(groups).toEqual([]);
35
+ });
36
+ it('does not re-group a page once it belongs to a group (single membership)', () => {
37
+ // Three identical pages -> a single group of all three, not overlapping pairs.
38
+ const same = 'identical paragraph repeated across three distinct urls verbatim';
39
+ const groups = detectDuplicates([
40
+ { url: '/1', content: same },
41
+ { url: '/2', content: same },
42
+ { url: '/3', content: same },
43
+ ]);
44
+ expect(groups).toHaveLength(1);
45
+ expect(groups[0].urls).toEqual(['/1', '/2', '/3']);
46
+ });
47
+ it('returns no groups when a single page has no peer to compare', () => {
48
+ expect(detectDuplicates([{ url: '/solo', content: 'lonely unique content here' }])).toEqual([]);
49
+ });
50
+ });
51
+ // Gap 5: suggestCanonical ranks by path depth, then query-string penalty, then
52
+ // length. Each tie-breaker is a distinct comparator branch.
53
+ describe('suggestCanonical (gap 5)', () => {
54
+ it('prefers the shallowest path (fewest segments)', () => {
55
+ expect(suggestCanonical({ urls: ['/a/b/c', '/a'], similarity: 1 })).toBe('/a');
56
+ });
57
+ it('penalizes a URL that carries a query string at equal depth', () => {
58
+ expect(suggestCanonical({ urls: ['/a?x=1', '/a'], similarity: 1 })).toBe('/a');
59
+ });
60
+ it('breaks a depth+query tie by shortest length', () => {
61
+ expect(suggestCanonical({ urls: ['/aaaa', '/aa'], similarity: 1 })).toBe('/aa');
62
+ });
63
+ it('falls back to empty string for an empty url list', () => {
64
+ expect(suggestCanonical({ urls: [], similarity: 1 })).toBe('');
65
+ });
66
+ });
67
+ //# sourceMappingURL=canonical.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canonical.test.js","sourceRoot":"","sources":["../../src/__tests__/canonical.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE1E,+EAA+E;AAC/E,mEAAmE;AACnE,uEAAuE;AACvE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,oEAAoE,EAAE,GAAG,EAAE;QAC5E,MAAM,MAAM,GAAG,uEAAuE,CAAA;QACtF,MAAM,MAAM,GAAG,gBAAgB,CAAC;YAC9B,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;YAClC,EAAE,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE;YAClC;gBACE,GAAG,EAAE,QAAQ;gBACb,OAAO,EAAE,8DAA8D;aACxE;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAA;QACxB,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;QAChD,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,sBAAsB,CAAC,IAAI,CA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