@prenta/plugin-redirects 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.
- package/CHANGELOG.md +248 -0
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/dist/__tests__/collections.test.d.ts +2 -0
- package/dist/__tests__/collections.test.d.ts.map +1 -0
- package/dist/__tests__/collections.test.js +43 -0
- package/dist/__tests__/collections.test.js.map +1 -0
- package/dist/__tests__/import.test.d.ts +2 -0
- package/dist/__tests__/import.test.d.ts.map +1 -0
- package/dist/__tests__/import.test.js +99 -0
- package/dist/__tests__/import.test.js.map +1 -0
- package/dist/__tests__/index.test.d.ts +2 -0
- package/dist/__tests__/index.test.d.ts.map +1 -0
- package/dist/__tests__/index.test.js +36 -0
- package/dist/__tests__/index.test.js.map +1 -0
- package/dist/__tests__/middleware.test.d.ts +2 -0
- package/dist/__tests__/middleware.test.d.ts.map +1 -0
- package/dist/__tests__/middleware.test.js +137 -0
- package/dist/__tests__/middleware.test.js.map +1 -0
- package/dist/admin/RedirectList.d.ts +19 -0
- package/dist/admin/RedirectList.d.ts.map +1 -0
- package/dist/admin/RedirectList.js +92 -0
- package/dist/admin/RedirectList.js.map +1 -0
- package/dist/collections.d.ts +3 -0
- package/dist/collections.d.ts.map +1 -0
- package/dist/collections.js +63 -0
- package/dist/collections.js.map +1 -0
- package/dist/fields.d.ts +3 -0
- package/dist/fields.d.ts.map +1 -0
- package/dist/fields.js +2 -0
- package/dist/fields.js.map +1 -0
- package/dist/hooks.d.ts +3 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +12 -0
- package/dist/hooks.js.map +1 -0
- package/dist/import.d.ts +22 -0
- package/dist/import.d.ts.map +1 -0
- package/dist/import.js +81 -0
- package/dist/import.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/middleware.d.ts +27 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +69 -0
- package/dist/middleware.js.map +1 -0
- package/package.json +47 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# @actuate-media/plugin-redirects
|
|
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.17
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- e25cd48: Standardize React peer ranges to `^18.0.0 || ^19.0.0`.
|
|
42
|
+
|
|
43
|
+
Plugin React peer ranges were inconsistent: `plugin-ai`, `plugin-commerce`, and
|
|
44
|
+
`plugin-seo` pinned `react: ^19.2.0` (excluding React 18, which `cms-core`
|
|
45
|
+
supports via `react >=18.0.0`), while the others used `^18.0.0 || ^19.2.0`
|
|
46
|
+
(excluding React 19.0/19.1). Either produced an `ERESOLVE` install failure for
|
|
47
|
+
consumers on the excluded versions. All bundled plugins now declare `react`
|
|
48
|
+
(and `react-dom` where already peered) as `^18.0.0 || ^19.0.0`.
|
|
49
|
+
|
|
50
|
+
## 0.0.16
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- e86e3f8: Remove the dead "Submissions" and "Redirects" sidebar links.
|
|
55
|
+
|
|
56
|
+
Both pointed at routes the admin doesn't have — clicking them 404'd — and both
|
|
57
|
+
features are already reachable elsewhere: submissions via Forms → All Entries,
|
|
58
|
+
redirects via the SEO Operations Center's Redirects tab (the standalone
|
|
59
|
+
Redirects view is deprecated).
|
|
60
|
+
- plugin-forms: drop the `Submissions` nav item; mark the `form-submissions`
|
|
61
|
+
collection `admin.hidden` so it doesn't resurface as grouped collection nav.
|
|
62
|
+
- plugin-redirects: drop the `Redirects` nav item; mark the `redirects`
|
|
63
|
+
collection `admin.hidden` likewise.
|
|
64
|
+
|
|
65
|
+
Net: the sidebar Content section is Pages · Posts · Templates · Media · Forms ·
|
|
66
|
+
SEO · Script Tags — no dead links, no stray "Forms"/"SEO" collection groups.
|
|
67
|
+
|
|
68
|
+
## 0.0.15
|
|
69
|
+
|
|
70
|
+
### Patch Changes
|
|
71
|
+
|
|
72
|
+
- c231dd0: Add `definePlugin` and migrate all 10 plugins onto the canonical `PluginDefinition` contract.
|
|
73
|
+
|
|
74
|
+
cms-core already exported `PluginDefinition`, but every plugin hand-rolled a
|
|
75
|
+
local `ActuatePlugin` interface — a lossy subset that dropped `version`/`init`
|
|
76
|
+
and, in blocks/email/ai, widened hook payloads to `unknown[]`/`event: string`.
|
|
77
|
+
That's copy-paste drift with no shared source of truth.
|
|
78
|
+
|
|
79
|
+
`cms-core` now exports `definePlugin(plugin: PluginDefinition)` (an identity
|
|
80
|
+
helper like `defineConfig`), and each plugin imports the canonical type instead
|
|
81
|
+
of its own: the local `ActuatePlugin` interfaces are deleted, factory return
|
|
82
|
+
types are `PluginDefinition`, and the widened `hooks.ts` types are retyped as
|
|
83
|
+
`PluginHook[]`. Type-only change — no runtime behavior, plugin `name`, or config
|
|
84
|
+
options changed. Net −69 lines.
|
|
85
|
+
|
|
86
|
+
- 325694f: Import `definePlugin` from the lightweight `@actuate-media/cms-core/config`
|
|
87
|
+
entry instead of the barrel.
|
|
88
|
+
|
|
89
|
+
The plugin-definition migration imported the `definePlugin` **value** from
|
|
90
|
+
`@actuate-media/cms-core`, which pulls the entire cms-core barrel (graphql,
|
|
91
|
+
sharp, sentry, codegen) into every plugin's runtime — bundle bloat for
|
|
92
|
+
consumers and, under parallel test load, a timeout. The `/config` subpath exists
|
|
93
|
+
precisely to avoid the barrel. Types stay as erased `import type`, so nothing
|
|
94
|
+
heavy is loaded. No API or behavior change.
|
|
95
|
+
|
|
96
|
+
## 0.0.14
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- cc18833: SEO audit remediation — 47 verified fixes across the SEO system.
|
|
101
|
+
|
|
102
|
+
Highlights: redirect middleware no longer excludes legacy `.html/.php/.aspx`
|
|
103
|
+
URLs (migrations); robots.txt now `Allow`s the default OG image (`/api/cms/og.png`)
|
|
104
|
+
so social shares render; RSS always emits the mandatory channel `<description>`;
|
|
105
|
+
structured-data auto-detection no longer emits invalid `Review/Event/JobPosting`
|
|
106
|
+
(required fields enforced or the node is suppressed) and no longer mis-types
|
|
107
|
+
collections by substring (`newsletters`→NewsArticle etc.); the sitemap endpoint
|
|
108
|
+
no longer selects full document JSON for up to 45k rows; IndexNow submits on
|
|
109
|
+
every publish instead of being swallowed by the sitemap debounce; the exported
|
|
110
|
+
`renderJsonLdScript()` now escapes `<`; the editor no longer shows two
|
|
111
|
+
conflicting scores and the Content-tab analysis now understands section-built
|
|
112
|
+
pages; plus pagination `rel`/canonical, `og:locale` normalization + alternates,
|
|
113
|
+
canonical absolutization, VideoObject/Product/WebSite-SearchAction builders,
|
|
114
|
+
redirect loop/case handling, plugin-seo sitemap caps + real `lastmod`, and
|
|
115
|
+
plugin link-health routed through `safeFetch`. Adds several new exports on
|
|
116
|
+
`@actuate-media/cms-core` (e.g. `buildVideoObjectSchema`, `buildProductSchema`).
|
|
117
|
+
|
|
118
|
+
## 0.0.13
|
|
119
|
+
|
|
120
|
+
### Patch Changes
|
|
121
|
+
|
|
122
|
+
- 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).
|
|
123
|
+
- de419f2: Give plugin hooks a frozen, typed event contract. cms-core now exports
|
|
124
|
+
`PluginHook`, `PluginHookEvent`, and `PluginHookPayload` (document + upload
|
|
125
|
+
variants) as the single source of truth, and dispatches a complete, consistent
|
|
126
|
+
set of events: `afterCreate` / `afterUpdate` / `afterDelete` — each also in a
|
|
127
|
+
collection-namespaced form (`afterUpdate:navigations`, `afterCreate:orders`) —
|
|
128
|
+
plus `afterUpload` (fired post-upload from the media route). Every handler now
|
|
129
|
+
receives one typed payload; document field values live on `payload.data`.
|
|
130
|
+
|
|
131
|
+
Previously core fired only bare `afterCreate`/`afterUpdate` with the raw row, so
|
|
132
|
+
several shipped plugins' hooks were dead: `plugin-media`'s `afterUpload` never
|
|
133
|
+
fired, `plugin-navigation` read fields that didn't exist, and the namespaced
|
|
134
|
+
events `plugin-forms`/`plugin-commerce` declared were never dispatched. Each
|
|
135
|
+
plugin has been aligned to the shared type and dispatched events (and
|
|
136
|
+
`plugin-redirects`' request-time `onRedirectMatch` hook — which the lifecycle
|
|
137
|
+
bus never dispatched — was removed). Undispatched event names are now a
|
|
138
|
+
compile-time error.
|
|
139
|
+
|
|
140
|
+
## 0.0.12
|
|
141
|
+
|
|
142
|
+
### Patch Changes
|
|
143
|
+
|
|
144
|
+
- 854152d: Developer experience improvements from external-consumer feedback:
|
|
145
|
+
- 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`.
|
|
146
|
+
- 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.
|
|
147
|
+
|
|
148
|
+
## 0.0.11
|
|
149
|
+
|
|
150
|
+
### Patch Changes
|
|
151
|
+
|
|
152
|
+
- b5de8dd: Fix ESM module resolution and dependency duplication issues reported during consumer integration.
|
|
153
|
+
- 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).
|
|
154
|
+
- 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.
|
|
155
|
+
- 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).
|
|
156
|
+
|
|
157
|
+
## 0.0.10
|
|
158
|
+
|
|
159
|
+
### Patch Changes
|
|
160
|
+
|
|
161
|
+
- Updated dependencies [54c7a3b]
|
|
162
|
+
- @actuate-media/cms-core@0.6.0
|
|
163
|
+
|
|
164
|
+
## 0.0.9
|
|
165
|
+
|
|
166
|
+
### Patch Changes
|
|
167
|
+
|
|
168
|
+
- Updated dependencies [c08cf8b]
|
|
169
|
+
- Updated dependencies [80aa939]
|
|
170
|
+
- @actuate-media/cms-core@0.5.0
|
|
171
|
+
|
|
172
|
+
## 0.0.8
|
|
173
|
+
|
|
174
|
+
### Patch Changes
|
|
175
|
+
|
|
176
|
+
- Updated dependencies [f2cf7d7]
|
|
177
|
+
- @actuate-media/cms-core@0.4.0
|
|
178
|
+
|
|
179
|
+
## 0.0.7
|
|
180
|
+
|
|
181
|
+
### Patch Changes
|
|
182
|
+
|
|
183
|
+
- Updated dependencies [0621037]
|
|
184
|
+
- @actuate-media/cms-core@0.3.1
|
|
185
|
+
|
|
186
|
+
## 0.0.6
|
|
187
|
+
|
|
188
|
+
### Patch Changes
|
|
189
|
+
|
|
190
|
+
- Updated dependencies [4e3a5eb]
|
|
191
|
+
- @actuate-media/cms-core@0.3.0
|
|
192
|
+
|
|
193
|
+
## 0.0.5
|
|
194
|
+
|
|
195
|
+
### Patch Changes
|
|
196
|
+
|
|
197
|
+
- Updated dependencies
|
|
198
|
+
- @actuate-media/cms-core@0.2.3
|
|
199
|
+
|
|
200
|
+
## 0.0.4
|
|
201
|
+
|
|
202
|
+
### Patch Changes
|
|
203
|
+
|
|
204
|
+
- Updated dependencies
|
|
205
|
+
- @actuate-media/cms-core@0.2.2
|
|
206
|
+
|
|
207
|
+
## 0.0.3
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- Updated dependencies
|
|
212
|
+
- @actuate-media/cms-core@0.2.1
|
|
213
|
+
|
|
214
|
+
## 0.0.2
|
|
215
|
+
|
|
216
|
+
### Patch Changes
|
|
217
|
+
|
|
218
|
+
- 3fd38a2: Fix all 13 integration issues discovered during MaidPro.co deployment
|
|
219
|
+
|
|
220
|
+
**cms-core:**
|
|
221
|
+
- Add .js extensions to all ESM relative imports (58 files)
|
|
222
|
+
- Replace workspace:\* with versioned deps in all packages
|
|
223
|
+
- Add sideEffects:false for proper tree-shaking
|
|
224
|
+
- Subpath exports (/config, /api, /middleware, /next) avoid barrel side effects
|
|
225
|
+
- Stats/search routes use safeCount/safeFindMany for missing Prisma models
|
|
226
|
+
- Ship prisma/cms-schema.prisma with all required CMS models
|
|
227
|
+
- Accept both CMS_SECRET and CMS_SESSION_SECRET with clear error messages
|
|
228
|
+
- Fix hardcoded /admin paths in OAuth flow (now uses getAdminPath())
|
|
229
|
+
- Loosen withActuateCMS and createCMSMiddleware parameter types
|
|
230
|
+
- Auto-inject transpilePackages and serverExternalPackages in withActuateCMS
|
|
231
|
+
- Unify PluginDefinition with ActuatePlugin interface
|
|
232
|
+
|
|
233
|
+
**cms-admin:**
|
|
234
|
+
- Scope all 40+ CSS theme variables to .actuate-admin instead of :root
|
|
235
|
+
- ThemeProvider applies dark class to .actuate-admin, not document.documentElement
|
|
236
|
+
- Scaffold uses (admin)/(site) route groups for full CSS/script isolation
|
|
237
|
+
- Sidebar branding supports custom logo via config.admin.branding
|
|
238
|
+
|
|
239
|
+
**platform-vercel:**
|
|
240
|
+
- Email adapter accepts both `from` and `defaultFrom`
|
|
241
|
+
|
|
242
|
+
**All plugin/platform packages:**
|
|
243
|
+
- Fix ESM .js extensions in compiled output
|
|
244
|
+
- Replace workspace:\* with ^0.1.0 for publishable deps
|
|
245
|
+
|
|
246
|
+
- Updated dependencies [682dac7]
|
|
247
|
+
- Updated dependencies [3fd38a2]
|
|
248
|
+
- @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,28 @@
|
|
|
1
|
+
# @prenta/plugin-redirects
|
|
2
|
+
|
|
3
|
+
Redirect management for [Prenta CMS](https://github.com/actuate-media/prenta)
|
|
4
|
+
— editor-managed 301/302 rules served to your middleware.
|
|
5
|
+
|
|
6
|
+
```bash
|
|
7
|
+
npm install @prenta/plugin-redirects
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { redirectsPlugin } from '@prenta/plugin-redirects'
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
plugins: [redirectsPlugin()],
|
|
17
|
+
// ...
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Release notes
|
|
22
|
+
|
|
23
|
+
See [CHANGELOG.md](./CHANGELOG.md) (shipped with the package) or the
|
|
24
|
+
[GitHub releases](https://github.com/actuate-media/prenta/releases).
|
|
25
|
+
|
|
26
|
+
## License
|
|
27
|
+
|
|
28
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/collections.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { redirectsCollections } from '../index.js';
|
|
3
|
+
const collection = redirectsCollections.redirects;
|
|
4
|
+
const fields = collection.fields;
|
|
5
|
+
describe('redirectsCollections.redirects — field config', () => {
|
|
6
|
+
it('requires both fromUrl and toUrl', () => {
|
|
7
|
+
expect(fields.fromUrl.required).toBe(true);
|
|
8
|
+
expect(fields.toUrl.required).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it('type is a select limited to 301/302 and defaults to 301', () => {
|
|
11
|
+
const type = fields.type;
|
|
12
|
+
expect(type.type).toBe('select');
|
|
13
|
+
if (type.type !== 'select')
|
|
14
|
+
throw new Error('expected a select field');
|
|
15
|
+
expect(type.options.map((o) => o.value)).toEqual(['301', '302']);
|
|
16
|
+
expect(type.defaultValue).toBe('301');
|
|
17
|
+
});
|
|
18
|
+
it('hitCount defaults to 0 and is read-only', () => {
|
|
19
|
+
expect(fields.hitCount.defaultValue).toBe(0);
|
|
20
|
+
expect(fields.hitCount.admin?.readOnly).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
it('isActive defaults to true', () => {
|
|
23
|
+
expect(fields.isActive.defaultValue).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
describe('redirectsCollections.redirects — admin/nav contract', () => {
|
|
27
|
+
it('is hidden from the sidebar (the documented 404-avoidance choice)', () => {
|
|
28
|
+
// A visible nav entry pointed at an unrouted '/redirects' path and 404'd;
|
|
29
|
+
// the collection is intentionally hidden and managed via the SEO tab.
|
|
30
|
+
expect(collection.admin?.hidden).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
it('titles rows by fromUrl and locks the default column set', () => {
|
|
33
|
+
expect(collection.admin?.useAsTitle).toBe('fromUrl');
|
|
34
|
+
expect(collection.admin?.defaultColumns).toEqual([
|
|
35
|
+
'fromUrl',
|
|
36
|
+
'toUrl',
|
|
37
|
+
'type',
|
|
38
|
+
'hitCount',
|
|
39
|
+
'isActive',
|
|
40
|
+
]);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=collections.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collections.test.js","sourceRoot":"","sources":["../../src/__tests__/collections.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAElD,MAAM,UAAU,GAAG,oBAAoB,CAAC,SAAU,CAAA;AAClD,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAA;AAEhC,QAAQ,CAAC,+CAA+C,EAAE,GAAG,EAAE;IAC7D,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,MAAM,CAAC,OAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3C,MAAM,CAAC,MAAM,CAAC,KAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,yDAAyD,EAAE,GAAG,EAAE;QACjE,MAAM,IAAI,GAA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C,KAAK,EAAE,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QACpD,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,cAAc,CAAC,CAAC,OAAO,CAAC;YAC/C,SAAS;YACT,OAAO;YACP,MAAM;YACN,UAAU;YACV,UAAU;SACX,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/import.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { parseRedirectCSV, validateRedirects } from '../import.js';
|
|
3
|
+
const redirect = (over = {}) => ({
|
|
4
|
+
fromUrl: '/from',
|
|
5
|
+
toUrl: '/to',
|
|
6
|
+
type: '301',
|
|
7
|
+
lineNumber: 1,
|
|
8
|
+
...over,
|
|
9
|
+
});
|
|
10
|
+
describe('parseRedirectCSV', () => {
|
|
11
|
+
it('drops the header, strips quotes, skips junk rows, defaults type, and preserves line numbers', () => {
|
|
12
|
+
const csv = [
|
|
13
|
+
'From,To,Type', // line 1 (index 0): header, dropped
|
|
14
|
+
'"/a","/b",302', // line 2: double-quoted cells, explicit 302
|
|
15
|
+
"'/e','/f'", // line 3: single-quoted cells, no type -> 301
|
|
16
|
+
'/one-col', // line 4: <2 comma parts, skipped
|
|
17
|
+
'', // line 5: blank, skipped
|
|
18
|
+
'/c,/d', // line 6: no type column -> 301
|
|
19
|
+
].join('\n');
|
|
20
|
+
const parsed = parseRedirectCSV(csv);
|
|
21
|
+
expect(parsed).toHaveLength(3);
|
|
22
|
+
// Quotes stripped, 302 preserved, lineNumber reflects the ORIGINAL file line
|
|
23
|
+
// (header offset kept: this row is physical line 2).
|
|
24
|
+
expect(parsed[0]).toEqual({ fromUrl: '/a', toUrl: '/b', type: '302', lineNumber: 2 });
|
|
25
|
+
// Single quotes stripped too; missing type column defaults to '301'.
|
|
26
|
+
expect(parsed[1]).toEqual({ fromUrl: '/e', toUrl: '/f', type: '301', lineNumber: 3 });
|
|
27
|
+
// The one-column row (line 4) and blank line (line 5) are skipped, so the
|
|
28
|
+
// next kept entry is physical line 6.
|
|
29
|
+
expect(parsed[2]).toEqual({ fromUrl: '/c', toUrl: '/d', type: '301', lineNumber: 6 });
|
|
30
|
+
});
|
|
31
|
+
it('only treats index 0 as the header — a later "from…" row is a real redirect', () => {
|
|
32
|
+
const csv = ['From,To', '/a,/b', 'from-us,/x'].join('\n');
|
|
33
|
+
const parsed = parseRedirectCSV(csv);
|
|
34
|
+
expect(parsed).toHaveLength(2);
|
|
35
|
+
expect(parsed[0]).toEqual({ fromUrl: '/a', toUrl: '/b', type: '301', lineNumber: 2 });
|
|
36
|
+
// 'from-us' at line 3 is not line 0, so it is parsed rather than skipped.
|
|
37
|
+
expect(parsed[1]).toEqual({ fromUrl: 'from-us', toUrl: '/x', type: '301', lineNumber: 3 });
|
|
38
|
+
});
|
|
39
|
+
it("defaults any non-'302' type token to '301'", () => {
|
|
40
|
+
const parsed = parseRedirectCSV('/a,/b,frog');
|
|
41
|
+
expect(parsed[0].type).toBe('301');
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe('validateRedirects — chain walker', () => {
|
|
45
|
+
it('flags a multi-hop cycle (A->B, B->C, C->A) with the full chain path', () => {
|
|
46
|
+
const cyclic = [
|
|
47
|
+
redirect({ fromUrl: '/a', toUrl: '/b', lineNumber: 1 }),
|
|
48
|
+
redirect({ fromUrl: '/b', toUrl: '/c', lineNumber: 2 }),
|
|
49
|
+
redirect({ fromUrl: '/c', toUrl: '/a', lineNumber: 3 }),
|
|
50
|
+
];
|
|
51
|
+
const result = validateRedirects(cyclic);
|
|
52
|
+
expect(result.valid).toBe(false);
|
|
53
|
+
const cycleError = result.errors.find((e) => e.message.includes('cycle'));
|
|
54
|
+
expect(cycleError).toBeDefined();
|
|
55
|
+
// The reported path joins every hop with ' → ' and closes the loop back to
|
|
56
|
+
// the start (this also proves the chain.includes short-circuit fired rather
|
|
57
|
+
// than looping forever).
|
|
58
|
+
expect(cycleError.message).toContain('→');
|
|
59
|
+
expect(cycleError.message).toContain('/a → /b → /c → /a');
|
|
60
|
+
});
|
|
61
|
+
it('passes a linear (non-cyclic) chain A->B, B->C with no errors', () => {
|
|
62
|
+
const linear = [
|
|
63
|
+
redirect({ fromUrl: '/a', toUrl: '/b', lineNumber: 1 }),
|
|
64
|
+
redirect({ fromUrl: '/b', toUrl: '/c', lineNumber: 2 }),
|
|
65
|
+
];
|
|
66
|
+
const result = validateRedirects(linear);
|
|
67
|
+
expect(result.valid).toBe(true);
|
|
68
|
+
expect(result.errors).toEqual([]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('validateRedirects — per-row checks', () => {
|
|
72
|
+
it('errors on a self-redirect (from === to) and marks the batch invalid', () => {
|
|
73
|
+
const result = validateRedirects([redirect({ fromUrl: '/x', toUrl: '/x', lineNumber: 1 })]);
|
|
74
|
+
expect(result.valid).toBe(false);
|
|
75
|
+
expect(result.errors.some((e) => e.message.includes('redirects to itself'))).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
it("errors on a missing 'from' URL", () => {
|
|
78
|
+
const result = validateRedirects([redirect({ fromUrl: '', toUrl: '/x', lineNumber: 4 })]);
|
|
79
|
+
expect(result.valid).toBe(false);
|
|
80
|
+
const missing = result.errors.find((e) => e.message.includes("Missing 'from'"));
|
|
81
|
+
expect(missing).toBeDefined();
|
|
82
|
+
expect(missing.lineNumber).toBe(4);
|
|
83
|
+
});
|
|
84
|
+
it("emits a duplicate 'from' as a WARNING (not an error) naming the first-seen line", () => {
|
|
85
|
+
const dup = [
|
|
86
|
+
redirect({ fromUrl: '/dup', toUrl: '/a', lineNumber: 2 }),
|
|
87
|
+
redirect({ fromUrl: '/dup', toUrl: '/b', lineNumber: 3 }),
|
|
88
|
+
];
|
|
89
|
+
const result = validateRedirects(dup);
|
|
90
|
+
// A duplicate is a soft signal: exactly one warning, zero errors, still valid.
|
|
91
|
+
expect(result.errors).toEqual([]);
|
|
92
|
+
expect(result.valid).toBe(true);
|
|
93
|
+
expect(result.warnings).toHaveLength(1);
|
|
94
|
+
expect(result.warnings[0].lineNumber).toBe(3);
|
|
95
|
+
// The message points back at the first occurrence (line 2).
|
|
96
|
+
expect(result.warnings[0].message).toContain('line 2');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
//# sourceMappingURL=import.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.test.js","sourceRoot":"","sources":["../../src/__tests__/import.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAuB,MAAM,cAAc,CAAA;AAEvF,MAAM,QAAQ,GAAG,CAAC,OAAgC,EAAE,EAAkB,EAAE,CAAC,CAAC;IACxE,OAAO,EAAE,OAAO;IAChB,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,KAAK;IACX,UAAU,EAAE,CAAC;IACb,GAAG,IAAI;CACR,CAAC,CAAA;AAEF,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,6FAA6F,EAAE,GAAG,EAAE;QACrG,MAAM,GAAG,GAAG;YACV,cAAc,EAAE,oCAAoC;YACpD,eAAe,EAAE,4CAA4C;YAC7D,WAAW,EAAE,8CAA8C;YAC3D,UAAU,EAAE,kCAAkC;YAC9C,EAAE,EAAE,yBAAyB;YAC7B,OAAO,EAAE,gCAAgC;SAC1C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEZ,MAAM,MAAM,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAEpC,MAAM,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA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CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QAC9C,4DAA4D;QAC5D,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAE,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IACzD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { redirectsPlugin } from '../index.js';
|
|
3
|
+
import { redirectsHooks } from '../hooks.js';
|
|
4
|
+
describe('redirects', () => {
|
|
5
|
+
describe('structure', () => {
|
|
6
|
+
it('returns name redirects', () => {
|
|
7
|
+
expect(redirectsPlugin().name).toBe('redirects');
|
|
8
|
+
});
|
|
9
|
+
it('exposes fields, collections, and admin nav', () => {
|
|
10
|
+
const plugin = redirectsPlugin();
|
|
11
|
+
expect(plugin.fields).toBeDefined();
|
|
12
|
+
expect(typeof plugin.fields).toBe('object');
|
|
13
|
+
expect(plugin.collections).toBeDefined();
|
|
14
|
+
expect(Object.keys(plugin.collections ?? {}).length).toBeGreaterThan(0);
|
|
15
|
+
// No sidebar item — the redirects UI lives in the SEO → Redirects tab;
|
|
16
|
+
// the old /redirects item pointed at a route the admin doesn't have.
|
|
17
|
+
expect(plugin.adminNavItems).toBeUndefined();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe('configuration', () => {
|
|
21
|
+
it('registers no lifecycle hooks by default', () => {
|
|
22
|
+
const plugin = redirectsPlugin();
|
|
23
|
+
// cms-core dispatches only document/upload lifecycle events; this plugin
|
|
24
|
+
// has no such hooks (its redirect-match tracking is request-time).
|
|
25
|
+
expect(plugin.hooks).toEqual([]);
|
|
26
|
+
expect(plugin.hooks?.length).toBe(redirectsHooks.length);
|
|
27
|
+
});
|
|
28
|
+
it('registers no lifecycle hooks when autoDetect404s is true', () => {
|
|
29
|
+
// autoDetect404s is a request-time concern handled by the redirect
|
|
30
|
+
// middleware, not the lifecycle hook bus, so it adds no plugin hooks.
|
|
31
|
+
const plugin = redirectsPlugin({ autoDetect404s: true });
|
|
32
|
+
expect(plugin.hooks).toEqual([]);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAE5C,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;QACzB,EAAE,CAAC,wBAAwB,EAAE,GAAG,EAAE;YAChC,MAAM,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QAClD,CAAC,CAAC,CAAA;QAEF,EAAE,CAAC,4CAA4C,EAAE,GAAG,EAAE;YACpD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAA;YAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAA;YACnC,MAAM,CAAC,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YAC3C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAA;YACxC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,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