@klnap/payload-redirect 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +41 -40
- package/dist/core/redirects/auto/create-redirect.d.ts +3 -3
- package/dist/core/redirects/auto/create-redirect.js +6 -5
- package/dist/core/redirects/auto/create-redirect.js.map +1 -0
- package/dist/core/redirects/auto/match-existing-rule.d.ts +1 -1
- package/dist/core/redirects/auto/match-existing-rule.js +3 -2
- package/dist/core/redirects/auto/match-existing-rule.js.map +1 -0
- package/dist/core/redirects/auto/persist-auto-rule.d.ts +2 -2
- package/dist/core/redirects/auto/persist-auto-rule.js +12 -11
- package/dist/core/redirects/auto/persist-auto-rule.js.map +1 -0
- package/dist/core/redirects/auto/publication/get-publication-transition.d.ts +2 -2
- package/dist/core/redirects/auto/publication/get-publication-transition.js +7 -6
- package/dist/core/redirects/auto/publication/get-publication-transition.js.map +1 -0
- package/dist/core/redirects/auto/publication/locales.d.ts +1 -1
- package/dist/core/redirects/auto/publication/locales.js +14 -13
- package/dist/core/redirects/auto/publication/locales.js.map +1 -0
- package/dist/core/redirects/auto/publication/publish-intent.d.ts +1 -1
- package/dist/core/redirects/auto/publication/publish-intent.js +5 -4
- package/dist/core/redirects/auto/publication/publish-intent.js.map +1 -0
- package/dist/core/redirects/auto/publication/versions/document-locale.d.ts +1 -1
- package/dist/core/redirects/auto/publication/versions/document-locale.js +1 -0
- package/dist/core/redirects/auto/publication/versions/document-locale.js.map +1 -0
- package/dist/core/redirects/auto/publication/versions/version-pages.d.ts +2 -2
- package/dist/core/redirects/auto/publication/versions/version-pages.js +3 -2
- package/dist/core/redirects/auto/publication/versions/version-pages.js.map +1 -0
- package/dist/core/redirects/auto/publication/versions/version-rows.js +5 -4
- package/dist/core/redirects/auto/publication/versions/version-rows.js.map +1 -0
- package/dist/core/redirects/auto/types.d.ts +1 -1
- package/dist/core/redirects/auto/types.js +1 -0
- package/dist/core/redirects/auto/types.js.map +1 -0
- package/dist/core/redirects/collection/access.d.ts +1 -1
- package/dist/core/redirects/collection/access.js +3 -2
- package/dist/core/redirects/collection/access.js.map +1 -0
- package/dist/core/redirects/collection/collection.d.ts +2 -2
- package/dist/core/redirects/collection/collection.js +10 -9
- package/dist/core/redirects/collection/collection.js.map +1 -0
- package/dist/core/redirects/collection/duplicate-guard.d.ts +1 -1
- package/dist/core/redirects/collection/duplicate-guard.js +34 -33
- package/dist/core/redirects/collection/duplicate-guard.js.map +1 -0
- package/dist/core/redirects/collection/fields.d.ts +1 -1
- package/dist/core/redirects/collection/fields.js +51 -50
- package/dist/core/redirects/collection/fields.js.map +1 -0
- package/dist/core/redirects/collection/graph-lock.d.ts +1 -1
- package/dist/core/redirects/collection/graph-lock.js +8 -7
- package/dist/core/redirects/collection/graph-lock.js.map +1 -0
- package/dist/core/redirects/collection/origin-hook.d.ts +1 -1
- package/dist/core/redirects/collection/origin-hook.js +6 -5
- package/dist/core/redirects/collection/origin-hook.js.map +1 -0
- package/dist/core/redirects/collection/types.d.ts +2 -2
- package/dist/core/redirects/collection/types.js +1 -0
- package/dist/core/redirects/collection/types.js.map +1 -0
- package/dist/core/redirects/context-keys.d.ts +2 -2
- package/dist/core/redirects/context-keys.js +3 -2
- package/dist/core/redirects/context-keys.js.map +1 -0
- package/dist/core/redirects/model/errors.js +2 -1
- package/dist/core/redirects/model/errors.js.map +1 -0
- package/dist/core/redirects/model/origin.d.ts +1 -1
- package/dist/core/redirects/model/origin.js +4 -3
- package/dist/core/redirects/model/origin.js.map +1 -0
- package/dist/core/redirects/model/status-code.js +5 -4
- package/dist/core/redirects/model/status-code.js.map +1 -0
- package/dist/core/redirects/normalize-path.js +23 -22
- package/dist/core/redirects/normalize-path.js.map +1 -0
- package/dist/core/redirects/queries.d.ts +2 -2
- package/dist/core/redirects/queries.js +1 -0
- package/dist/core/redirects/queries.js.map +1 -0
- package/dist/core/url/published-path.js +20 -19
- package/dist/core/url/published-path.js.map +1 -0
- package/dist/core/url/route-params.js +9 -8
- package/dist/core/url/route-params.js.map +1 -0
- package/dist/exports/index.d.ts +4 -4
- package/dist/exports/index.js +2 -1
- package/dist/exports/index.js.map +1 -0
- package/dist/plugin/payload-plugin.d.ts +2 -2
- package/dist/plugin/payload-plugin.js +22 -21
- package/dist/plugin/payload-plugin.js.map +1 -0
- package/dist/plugin/types.d.ts +4 -4
- package/dist/plugin/types.js +1 -0
- package/dist/plugin/types.js.map +1 -0
- package/docs/FAILURE_SEMANTICS.md +28 -28
- package/package.json +21 -13
|
@@ -4,31 +4,31 @@ This document records observable configuration, validation, and publication beha
|
|
|
4
4
|
|
|
5
5
|
## Plugin configuration
|
|
6
6
|
|
|
7
|
-
| Condition
|
|
8
|
-
|
|
9
|
-
| `redirects()` is not registered
|
|
10
|
-
| The redirects collection slug already exists
|
|
11
|
-
| `redirects()` is registered more than once
|
|
12
|
-
| `overrides.fields` changes a required field type
|
|
13
|
-
| A collection has no redirect configuration
|
|
14
|
-
| Central collection options name an unregistered collection | Plugin configuration throws and names the collection.
|
|
15
|
-
| A configured collection has no `versions.drafts`
|
|
16
|
-
| Path config has unsupported options or multiple strategies | Plugin configuration throws before Payload builds.
|
|
17
|
-
| Locale map omits or adds a Payload locale
|
|
18
|
-
| Automatic generation is disabled
|
|
7
|
+
| Condition | Result |
|
|
8
|
+
| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
9
|
+
| `redirects()` is not registered | Payload config has no redirects collection or automatic publication hooks. |
|
|
10
|
+
| The redirects collection slug already exists | Plugin config throws and names the colliding slug. |
|
|
11
|
+
| `redirects()` is registered more than once | Plugin config throws; register it once. |
|
|
12
|
+
| `overrides.fields` changes a required field type | Plugin config throws before Payload builds. Missing required fields are restored from defaults. |
|
|
13
|
+
| A collection has no redirect configuration | The collection is left unchanged; no publication hook is added. |
|
|
14
|
+
| Central collection options name an unregistered collection | Plugin configuration throws and names the collection. |
|
|
15
|
+
| A configured collection has no `versions.drafts` | Plugin configuration throws and names the collection. |
|
|
16
|
+
| Path config has unsupported options or multiple strategies | Plugin configuration throws before Payload builds. |
|
|
17
|
+
| Locale map omits or adds a Payload locale | Plugin configuration throws and names invalid locales. |
|
|
18
|
+
| Automatic generation is disabled | No automatic hook is added; manual rules remain available. |
|
|
19
19
|
|
|
20
20
|
## Redirect collection writes
|
|
21
21
|
|
|
22
22
|
`from` and `to` must be non-empty site-relative paths. The plugin normalizes them before checking
|
|
23
23
|
duplicates and loops.
|
|
24
24
|
|
|
25
|
-
| Condition
|
|
26
|
-
|
|
27
|
-
| Duplicate normalized `from`
|
|
28
|
-
| Enabled redirect chain loops or exceeds 1,000 hops
|
|
29
|
-
| `statusCode` is not `301` or `302`
|
|
30
|
-
| `to` is missing or invalid
|
|
31
|
-
| `origin` is invalid
|
|
25
|
+
| Condition | Result |
|
|
26
|
+
| --------------------------------------------------- | -------------------------------------------------------------- |
|
|
27
|
+
| Duplicate normalized `from` | Payload validation error on `from`. |
|
|
28
|
+
| Enabled redirect chain loops or exceeds 1,000 hops | Payload validation error on `to`. |
|
|
29
|
+
| `statusCode` is not `301` or `302` | Payload field validation error. |
|
|
30
|
+
| `to` is missing or invalid | Payload field validation error. |
|
|
31
|
+
| `origin` is invalid | Payload field validation error. |
|
|
32
32
|
| A manual rule already owns an automatic source path | Automatic write is skipped; the manual rule remains unchanged. |
|
|
33
33
|
|
|
34
34
|
Internal writes carry server-side request context and run inside the Payload transaction. PostgreSQL
|
|
@@ -40,15 +40,15 @@ same concurrent-write guarantee.
|
|
|
40
40
|
Automatic rules use one of `path`, `paths`, or `getPath`, configured centrally or in
|
|
41
41
|
`custom.redirect`. Central configuration replaces local configuration.
|
|
42
42
|
|
|
43
|
-
| Condition
|
|
44
|
-
|
|
45
|
-
| No matching path configuration
|
|
46
|
-
| Template value is missing or unsafe
|
|
47
|
-
| `getPath` returns `null` or a non-site-relative path
|
|
48
|
-
| `getPath` returns a non-string value
|
|
49
|
-
| Locale is absent
|
|
50
|
-
| Locale is missing from a configured prefix map
|
|
51
|
-
| Generated source and destination normalize to the same path | No redirect is written.
|
|
43
|
+
| Condition | Result |
|
|
44
|
+
| ----------------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
45
|
+
| No matching path configuration | Automatic generation is not registered for that collection. |
|
|
46
|
+
| Template value is missing or unsafe | That locale's publication transition is skipped. |
|
|
47
|
+
| `getPath` returns `null` or a non-site-relative path | That locale's transition is skipped. |
|
|
48
|
+
| `getPath` returns a non-string value | That locale's transition is skipped. |
|
|
49
|
+
| Locale is absent | A shared `path` works without a prefix map; localized `paths` cannot resolve. |
|
|
50
|
+
| Locale is missing from a configured prefix map | Plugin configuration fails before Payload builds. |
|
|
51
|
+
| Generated source and destination normalize to the same path | No redirect is written. |
|
|
52
52
|
|
|
53
53
|
Draft saves, first publications, unpublishes, deletions, and unchanged complete paths do not create
|
|
54
54
|
automatic rules.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klnap/payload-redirect",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Redirect management for Payload CMS.",
|
|
5
5
|
"homepage": "https://github.com/klnap/payload-redirect#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"type": "module",
|
|
25
25
|
"sideEffects": false,
|
|
26
|
+
"packageManager": "bun@1.4.5",
|
|
26
27
|
"exports": {
|
|
27
28
|
".": {
|
|
28
29
|
"types": "./dist/exports/index.d.ts",
|
|
@@ -38,17 +39,20 @@
|
|
|
38
39
|
],
|
|
39
40
|
"scripts": {
|
|
40
41
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
-
"typecheck:consumer": "
|
|
42
|
+
"typecheck:consumer": "tsc -p tsconfig.type-fixture.json && tsc -p tsconfig.type-fixture.no-generated.json",
|
|
42
43
|
"test": "bun test src tests/unit",
|
|
43
44
|
"test:int": "bun scripts/with-ephemeral-postgres.mjs scripts/ephemeral-postgres.config.mjs -- bun test tests/integration tests/security --max-concurrency 1 --timeout=15000",
|
|
44
45
|
"check:boundaries": "depcruise --config dependency-cruiser.config.mjs --output-type err-long src",
|
|
45
|
-
"lint": "biome
|
|
46
|
-
"format": "biome format
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
46
|
+
"lint": "biome lint .",
|
|
47
|
+
"format": "biome format .",
|
|
48
|
+
"format:write": "biome format --write .",
|
|
49
|
+
"verify:package": "publint --strict && attw --profile esm-only --pack .",
|
|
50
|
+
"check": "bun run format && bun run lint && bun run check:boundaries && bun run typecheck && bun run test && bun run build && bun run typecheck:consumer && bun run verify:package && bun run check:exports",
|
|
51
|
+
"changeset": "changeset",
|
|
52
|
+
"changeset:version": "changeset version",
|
|
53
|
+
"changeset:version-check": "bun run changeset:version && bun run check",
|
|
50
54
|
"check:exports": "bun scripts/check-exports.mjs",
|
|
51
|
-
"build": "
|
|
55
|
+
"build": "bun -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\" && tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json"
|
|
52
56
|
},
|
|
53
57
|
"peerDependencies": {
|
|
54
58
|
"@payloadcms/db-postgres": ">=3.94.1 <4",
|
|
@@ -60,14 +64,17 @@
|
|
|
60
64
|
}
|
|
61
65
|
},
|
|
62
66
|
"devDependencies": {
|
|
67
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
68
|
+
"@biomejs/biome": "2.6.8",
|
|
69
|
+
"@changesets/cli": "3.0.3",
|
|
63
70
|
"@swc/core": "1.16.22",
|
|
64
71
|
"@payloadcms/db-postgres": "3.94.1",
|
|
65
72
|
"@payloadcms/richtext-lexical": "3.94.1",
|
|
66
|
-
"@types/bun": "
|
|
73
|
+
"@types/bun": "1.4.5",
|
|
67
74
|
"@types/pg": "^8.23.1",
|
|
68
|
-
"@biomejs/biome": "2.6.8",
|
|
69
|
-
"oxlint": "1.94.0",
|
|
70
75
|
"dependency-cruiser": "^18.8.0",
|
|
76
|
+
"npm": "12.2.3",
|
|
77
|
+
"publint": "0.3.25",
|
|
71
78
|
"payload": "3.94.1",
|
|
72
79
|
"pg": "^8.23.1",
|
|
73
80
|
"tsc-alias": "^1.9.10",
|
|
@@ -78,10 +85,11 @@
|
|
|
78
85
|
"happy-dom": "21.0.4"
|
|
79
86
|
},
|
|
80
87
|
"engines": {
|
|
81
|
-
"node": "^24.22.3 || >=26.13.1"
|
|
88
|
+
"node": "^22.23.5 || ^24.22.3 || >=26.13.1"
|
|
82
89
|
},
|
|
83
90
|
"publishConfig": {
|
|
84
|
-
"access": "public"
|
|
91
|
+
"access": "public",
|
|
92
|
+
"registry": "https://registry.npmjs.org/"
|
|
85
93
|
},
|
|
86
94
|
"types": "./dist/exports/index.d.ts"
|
|
87
95
|
}
|