@aglyn/plugins-redirects 1.0.0-beta.143 → 1.0.0-beta.144
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/README.md +57 -6
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -1,7 +1,58 @@
|
|
|
1
|
-
# @aglyn/plugins-
|
|
1
|
+
# @aglyn/plugins-redirects
|
|
2
2
|
|
|
3
|
-
The Redirects
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
The Redirects plugin for Aglyn: URL redirect rules for a site, the console page that manages them, and the server hook that answers a request with a redirect before the site resolves a route. Install it if you run the Aglyn console and tenant runtime and want redirect rules; it is a first-party plugin, not a standalone library.
|
|
4
|
+
|
|
5
|
+
> Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
npm install @aglyn/plugins-redirects@beta
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `react`, `@mui/material`, `firebase`, and `firebase-admin` for the server entry.
|
|
12
|
+
|
|
13
|
+
## What's in it
|
|
14
|
+
|
|
15
|
+
**On a published site.** Nothing is drawn. Redirects are enforced on the server: `registerRedirectsApi` (the `tenantApi` registrar, exported from `@aglyn/plugins-redirects/server`) registers a site redirect resolver with `@aglyn/aglyn/server`. For each request the resolver is given the host and path and returns a destination and status code, or nothing.
|
|
16
|
+
|
|
17
|
+
**Console** (`registerRedirectsConsole`, the `console` registrar): a `Redirects` nav item at `/redirects`, gated by the `redirects` entitlement. The page is code-split and loads when opened.
|
|
18
|
+
|
|
19
|
+
**The rule model**, exported from `.`:
|
|
20
|
+
|
|
21
|
+
- `HostRedirect`: a rule's `source`, `destination`, `statusCode` (`REDIRECT_STATUS_CODES`), `kind` (`REDIRECT_KINDS`: `exact`, `prefix`, `regex`), `priority` and `enabled`.
|
|
22
|
+
- `matchRedirect(rules, path)`: evaluates rules in priority order and returns a `RedirectMatch` or `null`. Disabled, self-targeting and invalid rules never fire, and an external destination is served only when the rule records the publisher who approved it.
|
|
23
|
+
- `validateRedirectRule`, `compileRedirectRegex`, `normalizeRedirectSource`, `normalizeRedirectDestination`, `isExternalRedirectDestination`, `isSelfRedirect`, `REDIRECT_DEFAULT_PRIORITY`.
|
|
24
|
+
- `BUNDLE_ID` (`'redirects'`).
|
|
25
|
+
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
The plugin is loaded through Aglyn's plugin manager: the generated loader manifests import the package and call the registrars named in `plugins.config.json`. An app that wires plugins by hand calls them once at startup:
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
// console, client side
|
|
32
|
+
import { registerRedirectsConsole } from '@aglyn/plugins-redirects'
|
|
33
|
+
registerRedirectsConsole()
|
|
34
|
+
|
|
35
|
+
// tenant runtime, server side
|
|
36
|
+
import { registerRedirectsApi } from '@aglyn/plugins-redirects/server'
|
|
37
|
+
registerRedirectsApi()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The matcher is pure and can be used directly:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { matchRedirect, type HostRedirect } from '@aglyn/plugins-redirects'
|
|
44
|
+
|
|
45
|
+
const rules: HostRedirect[] = [
|
|
46
|
+
{ source: '/old', destination: '/new', statusCode: 301 },
|
|
47
|
+
]
|
|
48
|
+
const match = matchRedirect(rules, '/old')
|
|
49
|
+
// match?.destination === '/new'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## How it fits
|
|
53
|
+
|
|
54
|
+
A plugin package (`scope:plugin`). It depends on the core (`@aglyn/aglyn`), the tenant packages (`@aglyn/tenant-data-admin`, `@aglyn/tenant-feature-instance`) and generic `@aglyn/shared-*` packages. It imports no other plugin, and the core never imports it: the tenant runtime asks whichever resolver is registered, and the console reaches the page through the loader manifest.
|
|
55
|
+
|
|
56
|
+
## License
|
|
57
|
+
|
|
58
|
+
Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/plugins/redirects
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-redirects",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.144",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.0.0-beta.
|
|
29
|
-
"@aglyn/shared-data-mdi": "1.0.0-beta.
|
|
30
|
-
"@aglyn/shared-ui-jsx": "1.0.0-beta.
|
|
31
|
-
"@aglyn/shared-ui-snackstack": "1.0.0-beta.
|
|
32
|
-
"@aglyn/shared-util-http": "1.0.0-beta.
|
|
33
|
-
"@aglyn/shared-util-timestamp": "1.0.0-beta.
|
|
34
|
-
"@aglyn/shared-util-tools": "1.0.0-beta.
|
|
35
|
-
"@aglyn/tenant-data-admin": "1.0.0-beta.
|
|
36
|
-
"@aglyn/tenant-feature-instance": "1.0.0-beta.
|
|
28
|
+
"@aglyn/aglyn": "1.0.0-beta.144",
|
|
29
|
+
"@aglyn/shared-data-mdi": "1.0.0-beta.144",
|
|
30
|
+
"@aglyn/shared-ui-jsx": "1.0.0-beta.144",
|
|
31
|
+
"@aglyn/shared-ui-snackstack": "1.0.0-beta.144",
|
|
32
|
+
"@aglyn/shared-util-http": "1.0.0-beta.144",
|
|
33
|
+
"@aglyn/shared-util-timestamp": "1.0.0-beta.144",
|
|
34
|
+
"@aglyn/shared-util-tools": "1.0.0-beta.144",
|
|
35
|
+
"@aglyn/tenant-data-admin": "1.0.0-beta.144",
|
|
36
|
+
"@aglyn/tenant-feature-instance": "1.0.0-beta.144",
|
|
37
37
|
"@swc/helpers": "0.5.23"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|