@owlmeans/route 0.1.18-rc.9 → 0.1.18
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 +217 -70
- package/agent-meta/manifest.json +3 -3
- package/agent-meta/skills/route/SKILL.md +15 -17
- package/build/consts.d.ts +2 -3
- package/build/consts.d.ts.map +1 -1
- package/build/consts.js +1 -2
- package/build/consts.js.map +1 -1
- package/build/helper.d.ts +0 -6
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +0 -10
- package/build/helper.js.map +1 -1
- package/build/model.d.ts.map +1 -1
- package/build/model.js +4 -1
- package/build/model.js.map +1 -1
- package/build/types.d.ts +11 -14
- package/build/types.d.ts.map +1 -1
- package/build/utils/declaration/types.d.ts +9 -0
- package/build/utils/declaration/types.d.ts.map +1 -0
- package/build/utils/declaration/types.js +2 -0
- package/build/utils/declaration/types.js.map +1 -0
- package/build/utils/declaration.d.ts +4 -0
- package/build/utils/declaration.d.ts.map +1 -0
- package/build/utils/declaration.js +18 -0
- package/build/utils/declaration.js.map +1 -0
- package/build/utils/index.d.ts +4 -0
- package/build/utils/index.d.ts.map +1 -1
- package/build/utils/index.js +1 -0
- package/build/utils/index.js.map +1 -1
- package/build/utils/route/types.d.ts +35 -0
- package/build/utils/route/types.d.ts.map +1 -0
- package/build/utils/route/types.js +2 -0
- package/build/utils/route/types.js.map +1 -0
- package/build/utils/route.d.ts +5 -28
- package/build/utils/route.d.ts.map +1 -1
- package/build/utils/route.js +76 -97
- package/build/utils/route.js.map +1 -1
- package/build/utils/service/types.d.ts +9 -0
- package/build/utils/service/types.d.ts.map +1 -0
- package/build/utils/service/types.js +2 -0
- package/build/utils/service/types.js.map +1 -0
- package/build/utils/service.d.ts +3 -4
- package/build/utils/service.d.ts.map +1 -1
- package/build/utils/service.js +7 -4
- package/build/utils/service.js.map +1 -1
- package/build/utils/types.local.d.ts +9 -0
- package/build/utils/types.local.d.ts.map +1 -0
- package/build/utils/types.local.js +2 -0
- package/build/utils/types.local.js.map +1 -0
- package/package.json +3 -3
- package/src/consts.ts +2 -3
- package/src/helper.ts +0 -13
- package/src/model.ts +5 -2
- package/src/types.ts +13 -14
- package/src/utils/declaration/types.ts +9 -0
- package/src/utils/declaration.ts +24 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/route/types.ts +35 -0
- package/src/utils/route.ts +85 -125
- package/src/utils/service/types.ts +9 -0
- package/src/utils/service.ts +12 -6
- package/src/utils/types.local.ts +10 -0
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# @owlmeans/route
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
- This package is a dependency of `@owlmeans/entrypoint` — you rarely use it directly unless defining entrypoint-level routes
|
|
3
|
+
The route declaration vocabulary for OwlMeans entrypoints. An app imports it in its shared contract
|
|
4
|
+
package, next to `@owlmeans/entrypoint`, to state for each entrypoint the URL segment, parent,
|
|
5
|
+
HTTP method, app type (backend or frontend) and transport identifier. It is not a
|
|
6
|
+
router and serves nothing: server binding is `@owlmeans/server-route` / `@owlmeans/server-app`,
|
|
7
|
+
client binding is `@owlmeans/client-route` / `@owlmeans/client-entrypoint`, UI routing is
|
|
8
|
+
`@owlmeans/router`. Application code usually reads addresses through the entrypoint accessors
|
|
9
|
+
(`path()`, `mount()`, `address()`) rather than through this package's `./utils`.
|
|
11
10
|
|
|
12
11
|
A `RouteDeclaration` is plain, immutable data: its `path` is the segment the route contributes under
|
|
13
12
|
its parent, and it is never rewritten. Where the route actually answers — the full path, the mount
|
|
@@ -17,86 +16,234 @@ context that asks, so the same declaration serves a server and a browser alike.
|
|
|
17
16
|
## Installation
|
|
18
17
|
|
|
19
18
|
```bash
|
|
20
|
-
bun add @owlmeans/route@^0.1.18
|
|
19
|
+
bun add @owlmeans/route@^0.1.18
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
## Concepts
|
|
23
|
+
|
|
24
|
+
- **Declaration** — the `RouteDeclaration` a `route()` call produces: `alias`, `path` (the segment
|
|
25
|
+
under `parent`), `type`, `method`, `protocol`, opaque `protocolOptions`, and service coordinates.
|
|
26
|
+
- **Model** — `RouteModel` is `{ route: RouteDeclaration }` and nothing more. `protocol()` and
|
|
27
|
+
`openProtocol()` from `@owlmeans/entrypoint` take it as their first argument.
|
|
28
|
+
- **Marker** — `backend()`, `frontend()` and `socket()` return `Partial<RouteOptions>` that set the
|
|
29
|
+
app type and built-in protocol; a transport package may provide another marker.
|
|
30
|
+
- **Parent** — a route nests under another entrypoint. Pass the parent protocol object
|
|
31
|
+
(`parent: storyProtocols.base`); the declaration stores only its alias.
|
|
32
|
+
- **Service** — `service` names the configured service (`cfg.services`) that answers the route.
|
|
33
|
+
Without it the route belongs to the asking context's own service or the default one of its type.
|
|
34
|
+
- **Protocol** — `RouteProtocols` contains the built-in HTTP and WebSocket identifiers. A backend
|
|
35
|
+
transport package may supply another string identifier and owns its opaque option data.
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
const storyEntrypoint = entrypoint(
|
|
38
|
-
route('story-view', '/stories/:id', frontend('app'))
|
|
39
|
-
)
|
|
37
|
+
## Usage
|
|
40
38
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
### A backend protocol tree
|
|
40
|
+
|
|
41
|
+
Aliases stay private to the declaration module; the exported value is a tree of protocol objects.
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import { contract, protocol } from '@owlmeans/entrypoint'
|
|
45
|
+
import { backend, route, RouteMethod } from '@owlmeans/route'
|
|
46
|
+
import { DEFAULT_GUARD } from '@owlmeans/auth-common'
|
|
47
|
+
import { InvoiceSchema, CreateInvoiceBodySchema } from './schemas.js'
|
|
48
|
+
|
|
49
|
+
const aliases = {
|
|
50
|
+
base: 'my-app:api:invoice:base',
|
|
51
|
+
list: 'my-app:api:invoice:list',
|
|
52
|
+
create: 'my-app:api:invoice:create',
|
|
53
|
+
} as const
|
|
54
|
+
|
|
55
|
+
const base = protocol(route(aliases.base, '/invoice', backend()), contract(), {
|
|
56
|
+
guards: DEFAULT_GUARD,
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
export const invoiceProtocols = {
|
|
60
|
+
base,
|
|
61
|
+
list: protocol(
|
|
62
|
+
route(aliases.list, '/', backend({ parent: base, method: RouteMethod.GET })),
|
|
63
|
+
contract(InvoiceSchema),
|
|
64
|
+
),
|
|
65
|
+
create: protocol(
|
|
66
|
+
route(aliases.create, '/', backend({ parent: base, method: RouteMethod.POST })),
|
|
67
|
+
contract(CreateInvoiceBodySchema, InvoiceSchema),
|
|
68
|
+
),
|
|
69
|
+
} as const
|
|
45
70
|
```
|
|
46
71
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
72
|
+
`invoiceProtocols.create` resolves to `/invoice` on the backend service, answering `POST`, and
|
|
73
|
+
inherits the guard declared on `base`.
|
|
74
|
+
|
|
75
|
+
### Path params, screens and default children
|
|
76
|
+
|
|
77
|
+
Path params use the `:name` form and are typed through `contract.request`. `frontend()` marks a
|
|
78
|
+
screen; `default: true` marks the child screen shown at the parent's path.
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
82
|
+
import { backend, frontend, route, RouteMethod } from '@owlmeans/route'
|
|
83
|
+
import type { ProjectParams, Project, RenameProject } from './types.js'
|
|
84
|
+
import { ProjectParamsSchema, RenameProjectSchema } from './schemas.js'
|
|
85
|
+
|
|
86
|
+
const aliases = {
|
|
87
|
+
base: 'my-app:api:project:base',
|
|
88
|
+
rename: 'my-app:api:project:rename',
|
|
89
|
+
web: 'my-app:web:project:base',
|
|
90
|
+
dashboard: 'my-app:web:project:dashboard',
|
|
91
|
+
overview: 'my-app:web:project:overview',
|
|
92
|
+
} as const
|
|
93
|
+
|
|
94
|
+
const base = openProtocol(route(aliases.base, '/project', backend()))
|
|
95
|
+
const web = openProtocol(route(aliases.web, '/project/:projectId', frontend()))
|
|
96
|
+
|
|
97
|
+
export const projectProtocols = {
|
|
98
|
+
base,
|
|
99
|
+
rename: protocol(
|
|
100
|
+
route(aliases.rename, '/:id/rename', backend({ parent: base, method: RouteMethod.PATCH })),
|
|
101
|
+
contract.request(
|
|
102
|
+
{ params: typed<ProjectParams>(ProjectParamsSchema), body: typed<RenameProject>(RenameProjectSchema) },
|
|
103
|
+
typed<Project>(),
|
|
104
|
+
),
|
|
105
|
+
),
|
|
106
|
+
web: {
|
|
107
|
+
base: web,
|
|
108
|
+
dashboard: openProtocol(route(aliases.dashboard, '/dashboard', frontend({ parent: web }))),
|
|
109
|
+
overview: openProtocol(route(aliases.overview, '/', frontend({ parent: web, default: true }))),
|
|
110
|
+
},
|
|
111
|
+
} as const
|
|
112
|
+
```
|
|
58
113
|
|
|
59
|
-
|
|
114
|
+
### Sockets, custom protocols and other services
|
|
115
|
+
|
|
116
|
+
`socket()` is `backend()` with a different protocol. A route pointed at another service carries
|
|
117
|
+
`service`. Adapter packages may add their own protocol and opaque `protocolOptions`; route does not
|
|
118
|
+
define their semantics.
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
122
|
+
import { route, socket } from '@owlmeans/route'
|
|
123
|
+
import type { ProjectParams, StoryUpdate } from './types.js'
|
|
124
|
+
import { ProjectParamsSchema } from './schemas.js'
|
|
125
|
+
|
|
126
|
+
const aliases = {
|
|
127
|
+
updates: 'my-app:api:update:base',
|
|
128
|
+
story: 'my-app:api:update:story',
|
|
129
|
+
} as const
|
|
130
|
+
|
|
131
|
+
const updates = openProtocol(route(aliases.updates, '/update'))
|
|
132
|
+
|
|
133
|
+
export const storyProtocols = {
|
|
134
|
+
updates,
|
|
135
|
+
// WebSocket subscription under /update
|
|
136
|
+
story: protocol(
|
|
137
|
+
route(aliases.story, '/story/:id', socket({ parent: updates })),
|
|
138
|
+
contract.request({ params: typed<ProjectParams>(ProjectParamsSchema) }, typed<StoryUpdate>()),
|
|
139
|
+
),
|
|
140
|
+
} as const
|
|
141
|
+
```
|
|
60
142
|
|
|
61
|
-
###
|
|
143
|
+
### Reading where a route answers
|
|
62
144
|
|
|
63
|
-
|
|
145
|
+
Once protocols are registered on a context, the entrypoint accessors answer address questions. The
|
|
146
|
+
`./utils` helpers are the same functions over a bare declaration.
|
|
64
147
|
|
|
65
|
-
|
|
148
|
+
```ts
|
|
149
|
+
import { AppType } from '@owlmeans/context'
|
|
150
|
+
import { service } from '@owlmeans/config'
|
|
151
|
+
import { routeAddressOf } from '@owlmeans/route/utils'
|
|
152
|
+
import { invoiceProtocols } from 'my-app-common'
|
|
66
153
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
```
|
|
154
|
+
// Config side: the service the backend routes resolve against
|
|
155
|
+
const cfg = service({ service: 'my-app-api', type: AppType.Backend, host: 'localhost', port: 8080, base: 'api' }, baseCfg)
|
|
70
156
|
|
|
71
|
-
|
|
157
|
+
// Runtime side, through the registered entrypoint
|
|
158
|
+
const entrypoint = context.entrypoint(invoiceProtocols.create)
|
|
159
|
+
entrypoint.path() // '/invoice'
|
|
160
|
+
entrypoint.mount() // '/api/invoice'
|
|
161
|
+
entrypoint.address() // { host: 'localhost', port: 8080, base: 'api', secure: true, protocol: 'http' }
|
|
162
|
+
entrypoint.isLocal() // true inside the my-app-api process
|
|
72
163
|
|
|
73
|
-
|
|
74
|
-
|
|
164
|
+
// Same answers from a declaration
|
|
165
|
+
const declaration = invoiceProtocols.create.route.route
|
|
166
|
+
const addresses = routeAddressOf(context)
|
|
167
|
+
addresses.resolveMount(declaration)
|
|
168
|
+
addresses.resolveAddress(declaration)
|
|
75
169
|
```
|
|
76
170
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
### Types
|
|
171
|
+
## API
|
|
80
172
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
173
|
+
### `@owlmeans/route`
|
|
174
|
+
|
|
175
|
+
| Symbol | Kind | Purpose |
|
|
176
|
+
|--------|------|---------|
|
|
177
|
+
| `route(alias, path, opts?)` | function | Build a `RouteModel`; `opts` is `RouteOptions` or a parent alias string |
|
|
178
|
+
| `createRoute(alias, path, opts?)` | function | Build the bare `RouteDeclaration` (parent reference collapsed to its alias) |
|
|
179
|
+
| `makeRouteModel(declaration)` | function | Wrap a declaration as `{ route }` |
|
|
180
|
+
| `backend(opts?, method?)` | function | Mark `AppType.Backend`; `opts` is options, a parent alias or `null`; `method` is a `RouteMethod` or more options |
|
|
181
|
+
| `frontend(opts?, default?)` | function | Mark `AppType.Frontend`; `default` is a boolean flag or more options |
|
|
182
|
+
| `socket(opts?, secondary?)` | function | `backend()` with `protocol: RouteProtocols.SOCKET` |
|
|
183
|
+
| `service(alias, opts?)` | function | Set `service` on `opts` (mutated and returned) |
|
|
184
|
+
| `rtype(type, opts?)` | function | Set an arbitrary `AppType`; the primitive behind `backend()` / `frontend()` |
|
|
185
|
+
| `normalizePath(path)` | function | Trim whitespace and one leading and trailing `/` |
|
|
186
|
+
| `RouteMethod` | enum | `GET = 'get'`, `POST = 'post'`, `PATCH = 'patch'`, `PUT = 'put'`, `DELETE = 'delete'` |
|
|
187
|
+
| `RouteProtocols` | enum | Generic built-ins: `WEB = 'http'`, `SOCKET = 'ws'` |
|
|
188
|
+
| `SEP` | const | Path separator `'/'` |
|
|
189
|
+
| `PARAM` | const | Path param prefix `':'` |
|
|
190
|
+
| `BasicRoute` | interface | `type`, `service?`, `host?`, `port?`, `base?`, `internalHost?`, `internalPort?` |
|
|
191
|
+
| `RouteDeclaration` | interface | `BasicRoute` + `alias`, `path`, `parent?`, `default?`, `method?`, `protocol?`, transport-owned `protocolOptions?`, `secure?`, `timeout?` |
|
|
192
|
+
| `RouteOptions` | interface | `Partial<RouteDeclaration>` whose `parent` is a `RouteParent` |
|
|
193
|
+
| `RouteParent` | type | `string \| EntrypointReference` |
|
|
194
|
+
| `RouteModel` | interface | `{ route: RouteDeclaration }` |
|
|
195
|
+
| `RouteAddress` | interface | `{ host, port?, base?, secure, protocol }` |
|
|
196
|
+
| `CommonServiceRoute` | interface | A service entry: `BasicRoute` + `service`, `home?`, `default?` |
|
|
197
|
+
| `ResolvedServiceRoute` | interface | A service entry that names its `host` |
|
|
86
198
|
|
|
87
199
|
### `@owlmeans/route/utils`
|
|
88
200
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
201
|
+
`routeAddressOf(context)` answers address questions against a context (one helper per context,
|
|
202
|
+
built on first use; `makeRouteAddressHelper(context)` builds a fresh one). `routeDeclarationHelper`
|
|
203
|
+
and `serviceRouteHelper` are pure and take no context.
|
|
204
|
+
|
|
205
|
+
| Symbol | Kind | Purpose |
|
|
206
|
+
|--------|------|---------|
|
|
207
|
+
| `routeAddressOf(context).resolvePath(route)` | helper member | Every ancestor's segment, then this one |
|
|
208
|
+
| `routeAddressOf(context).resolveMount(route)` | helper member | Service `base` + the full path |
|
|
209
|
+
| `routeAddressOf(context).resolveService(route)` | helper member | The named service, else the default of the route's type, else the first of that type |
|
|
210
|
+
| `routeAddressOf(context).resolveAddress(route)` | helper member | The `RouteAddress`; a hop over the service's internal host is never TLS |
|
|
211
|
+
| `routeAddressOf(context).isLocalRoute(route)` | helper member | Does the route belong to the context's own service |
|
|
212
|
+
| `routeAddressOf(context).getParentRoute(route)` | helper member | The parent declaration, with parentship-cycle detection |
|
|
213
|
+
| `routeDeclarationHelper.overrideParams(route, overrides?, filter?)` | helper member | Fill only blank fields of `route` from `overrides`; mutates, returns nothing |
|
|
214
|
+
| `routeDeclarationHelper.prependBase(route, path)` | helper member | `path` prefixed with `route.base` when set |
|
|
215
|
+
| `serviceRouteHelper.isServiceRoute(obj?)` | type guard | Is `obj` a `CommonServiceRoute` with a known `AppType` |
|
|
216
|
+
| `serviceRouteHelper.isServiceRouteResolved(route)` | type guard | Does the service entry name a host |
|
|
217
|
+
| `CreateRouteSignature<R>` | interface | Call signature shared by `route()` and `createRoute()` |
|
|
218
|
+
|
|
219
|
+
## Common pitfalls
|
|
220
|
+
|
|
221
|
+
- Pass the parent protocol object in route options, never an exported alias string. Keep aliases
|
|
222
|
+
private to the declaration module and export a `*Protocols` tree.
|
|
223
|
+
- The positional marker forms (`backend(parent, method)`, `frontend(parent, true)`) accept a parent
|
|
224
|
+
only as an alias string: a protocol object in first position is spread into the options and
|
|
225
|
+
overwrites the child's alias. Pass protocols as `{ parent }`.
|
|
226
|
+
- `path` is only this route's segment. Do not repeat the parent's path in it; `resolvePath()` joins
|
|
227
|
+
the chain.
|
|
228
|
+
- Custom transport options are opaque here. Validate them through the package that owns the
|
|
229
|
+
protocol.
|
|
230
|
+
- Do not pass a context to the pure `./utils` helpers: `routeDeclarationHelper.overrideParams(ctx, decl)`
|
|
231
|
+
writes route fields into the context object instead of resolving anything.
|
|
232
|
+
- A mis-wired tree (no `cfg.services`, a service without a host, a parentship cycle) throws
|
|
233
|
+
`SyntaxError` when an address is resolved. Fix the config; do not catch it.
|
|
234
|
+
- `transportAlias` and `EntrypointTransport` live in `@owlmeans/entrypoint`, not here. A route only
|
|
235
|
+
names its protocol.
|
|
236
|
+
|
|
237
|
+
## Related packages
|
|
238
|
+
|
|
239
|
+
- [`@owlmeans/entrypoint`](../entrypoint) — `protocol()` / `openProtocol()` consume a `RouteModel` and
|
|
240
|
+
expose `path()`, `mount()`, `address()`, `isLocal()`
|
|
241
|
+
- [`@owlmeans/context`](../context) — `AppType`, `EntrypointReference` and the registry the address helpers walk
|
|
242
|
+
- [`@owlmeans/config`](../config) — `service()` declares the service entries routes resolve against
|
|
243
|
+
- [`@owlmeans/server-route`](../server-route) — server-side route model; re-exported by
|
|
244
|
+
[`@owlmeans/server-app`](../server-app) as `broute`
|
|
245
|
+
- [`@owlmeans/client-route`](../client-route) — marks a route as client-side and extracts its params
|
|
246
|
+
- [`@owlmeans/socket`](../socket) — the SOCKET transport contracts
|
|
100
247
|
|
|
101
248
|
<!-- owlmeans:agent-guidance:start -->
|
|
102
249
|
## Agent guidance
|
|
@@ -106,7 +253,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
106
253
|
your project's skill store (`.agents/skills/`):
|
|
107
254
|
|
|
108
255
|
```sh
|
|
109
|
-
npx @owlmeans/agent-skills@^0.1.18
|
|
256
|
+
npx @owlmeans/agent-skills@^0.1.18
|
|
110
257
|
```
|
|
111
258
|
|
|
112
259
|
The embedded files are version-matched to this package release. Do not edit them
|
package/agent-meta/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"schemaVersion":
|
|
2
|
+
"schemaVersion": 3,
|
|
3
3
|
"package": "@owlmeans/route",
|
|
4
|
-
"version": "0.1.18
|
|
5
|
-
"generatedAt": "2026-
|
|
4
|
+
"version": "0.1.18",
|
|
5
|
+
"generatedAt": "2026-10-28T00:31:34.757Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: route
|
|
3
|
-
description: How to use @owlmeans/route — route
|
|
3
|
+
description: How to use @owlmeans/route — transport-neutral route declarations, frontend/backend/socket markers, HTTP methods, extensible protocol identifiers, and address helpers. Auto-invoked when importing route helpers or defining an entrypoint's URL path.
|
|
4
4
|
user-invocable: false
|
|
5
5
|
---
|
|
6
6
|
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
|
|
@@ -8,7 +8,7 @@ user-invocable: false
|
|
|
8
8
|
# @owlmeans/route
|
|
9
9
|
|
|
10
10
|
**Layer:** Core
|
|
11
|
-
**Install:** `"@owlmeans/route": "^0.1.18
|
|
11
|
+
**Install:** `"@owlmeans/route": "^0.1.18"` in `dependencies`
|
|
12
12
|
|
|
13
13
|
## Key Exports
|
|
14
14
|
|
|
@@ -18,10 +18,10 @@ user-invocable: false
|
|
|
18
18
|
| `frontend(options?, default?)` | Mark a route as a React page (web only) |
|
|
19
19
|
| `backend(options?, method?)` | Mark a route as a backend endpoint |
|
|
20
20
|
| `socket(options?, secondary?)` | A backend route answering over `RouteProtocols.SOCKET` |
|
|
21
|
-
| `job(options?, secondary?)` | A backend route carried by the queue (`RouteProtocols.QUEUE`); its declaration adds `queue`, `reply` and `timeout` |
|
|
22
21
|
| `service(alias, options?)` | Point a route at a named service |
|
|
23
22
|
| `RouteMethod` | enum of GET, POST, PUT, PATCH, DELETE |
|
|
24
|
-
| `RouteProtocols` |
|
|
23
|
+
| `RouteProtocols` | built-in WEB (`http`) and SOCKET (`ws`) identifiers |
|
|
24
|
+
| `RouteProtocol` | a built-in or package-owned transport identifier |
|
|
25
25
|
| `rtype(type, options?)` | The primitive `frontend()` / `backend()` are built from |
|
|
26
26
|
| `createRoute(alias, path, opts?)` / `makeRouteModel(decl)` | The declaration and its wrapper, when you need them apart |
|
|
27
27
|
| `BasicRoute` | `{ type, service?, host?, port?, base?, internalHost?, internalPort? }` |
|
|
@@ -40,18 +40,15 @@ route contributes under its parent and is never rewritten, and the model carries
|
|
|
40
40
|
Where the route answers is worked out on demand, against the context that asks — which is what lets
|
|
41
41
|
the same declaration serve a client and a server at once.
|
|
42
42
|
|
|
43
|
-
## Protocol
|
|
43
|
+
## Protocol ownership
|
|
44
44
|
|
|
45
45
|
A route names the protocol it answers on, and an application binds one by registering a transport
|
|
46
46
|
service under `transportAlias(protocol)`. So the protocol is what decides whether a call travels as
|
|
47
|
-
an HTTP request, a socket frame or a
|
|
48
|
-
and
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
protocol: `queue` (which queue carries it), `reply` and `timeout`. `reply: false` resolves once the
|
|
53
|
-
broker has taken the job — the value is the job's identity and the outcome is `Accepted`, not the
|
|
54
|
-
job's result; the default is to wait for the result.
|
|
47
|
+
an HTTP request, a socket frame or a package-owned transport — the call site never says. Both
|
|
48
|
+
`transportAlias` and `EntrypointTransport` are exported by `@owlmeans/entrypoint`; this package only
|
|
49
|
+
stores an opaque protocol identifier and `protocolOptions`. The package defining a custom protocol
|
|
50
|
+
owns its marker, option type, validation and transport; the generic route package does not describe
|
|
51
|
+
that transport's implementation semantics.
|
|
55
52
|
|
|
56
53
|
## Subpath Exports
|
|
57
54
|
|
|
@@ -81,18 +78,19 @@ Application code rarely calls these directly — `@owlmeans/entrypoint` exposes
|
|
|
81
78
|
|
|
82
79
|
```typescript
|
|
83
80
|
import { route, frontend, RouteMethod } from '@owlmeans/route'
|
|
84
|
-
import {
|
|
81
|
+
import { contract, openProtocol, protocol, typed } from '@owlmeans/entrypoint'
|
|
85
82
|
|
|
86
83
|
// Server route
|
|
87
|
-
|
|
84
|
+
protocol(
|
|
88
85
|
route(manager.back.project.create, '/create', {
|
|
89
86
|
parent: manager.back.project.base,
|
|
90
87
|
method: RouteMethod.POST,
|
|
91
|
-
})
|
|
88
|
+
}),
|
|
89
|
+
contract(typed<Project>()),
|
|
92
90
|
)
|
|
93
91
|
|
|
94
92
|
// Web route — frontend() marks it as a React page
|
|
95
|
-
|
|
93
|
+
openProtocol(
|
|
96
94
|
route(HOME, '/', frontend({ default: true, parent: BASE }))
|
|
97
95
|
)
|
|
98
96
|
```
|
package/build/consts.d.ts
CHANGED
|
@@ -10,11 +10,10 @@ export declare const PARAM = ":";
|
|
|
10
10
|
/**
|
|
11
11
|
* How a route is carried. The protocol picks the transport that answers it — an application binds
|
|
12
12
|
* one by registering a service under `transportAlias(protocol)` — so a caller writes `call()` and
|
|
13
|
-
* never learns
|
|
13
|
+
* never learns which transport carried the work.
|
|
14
14
|
*/
|
|
15
15
|
export declare enum RouteProtocols {
|
|
16
16
|
WEB = "http",
|
|
17
|
-
SOCKET = "ws"
|
|
18
|
-
QUEUE = "queue"
|
|
17
|
+
SOCKET = "ws"
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=consts.d.ts.map
|
package/build/consts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,GAAG,MAAM,CAAA;AAEtB,eAAO,MAAM,KAAK,MAAM,CAAA;AAExB;;;;GAIG;AACH,oBAAY,cAAc;IACxB,GAAG,SAAS;IACZ,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"consts.d.ts","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,oBAAY,WAAW;IACrB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,eAAO,MAAM,GAAG,MAAM,CAAA;AAEtB,eAAO,MAAM,KAAK,MAAM,CAAA;AAExB;;;;GAIG;AACH,oBAAY,cAAc;IACxB,GAAG,SAAS;IACZ,MAAM,OAAO;CACd"}
|
package/build/consts.js
CHANGED
|
@@ -11,12 +11,11 @@ export const PARAM = ':';
|
|
|
11
11
|
/**
|
|
12
12
|
* How a route is carried. The protocol picks the transport that answers it — an application binds
|
|
13
13
|
* one by registering a service under `transportAlias(protocol)` — so a caller writes `call()` and
|
|
14
|
-
* never learns
|
|
14
|
+
* never learns which transport carried the work.
|
|
15
15
|
*/
|
|
16
16
|
export var RouteProtocols;
|
|
17
17
|
(function (RouteProtocols) {
|
|
18
18
|
RouteProtocols["WEB"] = "http";
|
|
19
19
|
RouteProtocols["SOCKET"] = "ws";
|
|
20
|
-
RouteProtocols["QUEUE"] = "queue";
|
|
21
20
|
})(RouteProtocols || (RouteProtocols = {}));
|
|
22
21
|
//# sourceMappingURL=consts.js.map
|
package/build/consts.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,0BAAW,CAAA;IACX,gCAAiB,CAAA;AACnB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;AAEtB,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB;;;;GAIG;AACH,MAAM,CAAN,IAAY,
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AACA,MAAM,CAAN,IAAY,WAMX;AAND,WAAY,WAAW;IACrB,0BAAW,CAAA;IACX,4BAAa,CAAA;IACb,8BAAe,CAAA;IACf,0BAAW,CAAA;IACX,gCAAiB,CAAA;AACnB,CAAC,EANW,WAAW,KAAX,WAAW,QAMtB;AAED,MAAM,CAAC,MAAM,GAAG,GAAG,GAAG,CAAA;AAEtB,MAAM,CAAC,MAAM,KAAK,GAAG,GAAG,CAAA;AAExB;;;;GAIG;AACH,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,8BAAY,CAAA;IACZ,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,KAAd,cAAc,QAGzB"}
|
package/build/helper.d.ts
CHANGED
|
@@ -8,11 +8,5 @@ export declare const rtype: (type: AppType, opts?: RouteOptions | string) => Par
|
|
|
8
8
|
export declare const backend: (opts?: RouteOptions | string | null, method?: RouteOptions | RouteMethod) => Partial<RouteOptions>;
|
|
9
9
|
export declare const service: (service: string, opts?: Partial<RouteOptions>) => Partial<RouteOptions>;
|
|
10
10
|
export declare const socket: (opts?: RouteOptions | string | null, secondary?: RouteOptions) => Partial<RouteOptions>;
|
|
11
|
-
/**
|
|
12
|
-
* A backend route carried by the queue rather than by HTTP. Everything else about it is a normal
|
|
13
|
-
* backend route — it has a path, a parent, guards and a filter — so the same declaration is served
|
|
14
|
-
* with `elevate(...)` and called with `call()`; only the transport underneath differs.
|
|
15
|
-
*/
|
|
16
|
-
export declare const job: (opts?: RouteOptions | string | null, secondary?: RouteOptions) => Partial<RouteOptions>;
|
|
17
11
|
export declare const frontend: (opts?: RouteOptions | string | null, def?: RouteOptions | boolean) => Partial<RouteOptions>;
|
|
18
12
|
//# sourceMappingURL=helper.d.ts.map
|
package/build/helper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAuB,MAAM,aAAa,CAAA;AAE9D,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAC1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE5D,eAAO,MAAM,KAAK,EAAE,oBAAoB,CAAC,UAAU,CACH,CAAA;AAEhD,eAAO,MAAM,aAAa,SAAU,MAAM,KAAG,MAM5C,CAAA;AAED,eAAO,MAAM,KAAK,SAAU,OAAO,SAAS,YAAY,GAAG,MAAM,KAAG,OAAO,CAAC,YAAY,CAEvF,CAAA;AAED,eAAO,MAAM,OAAO,UAAW,YAAY,GAAG,MAAM,GAAG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AAC,YAAY,CAQhH,CAAA"}
|
package/build/helper.js
CHANGED
|
@@ -28,16 +28,6 @@ export const socket = (opts, secondary) => {
|
|
|
28
28
|
route.protocol = RouteProtocols.SOCKET;
|
|
29
29
|
return route;
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* A backend route carried by the queue rather than by HTTP. Everything else about it is a normal
|
|
33
|
-
* backend route — it has a path, a parent, guards and a filter — so the same declaration is served
|
|
34
|
-
* with `elevate(...)` and called with `call()`; only the transport underneath differs.
|
|
35
|
-
*/
|
|
36
|
-
export const job = (opts, secondary) => {
|
|
37
|
-
const route = backend(opts, secondary);
|
|
38
|
-
route.protocol = RouteProtocols.QUEUE;
|
|
39
|
-
return route;
|
|
40
|
-
};
|
|
41
31
|
export const frontend = (opts, def) => {
|
|
42
32
|
if (typeof def === 'boolean') {
|
|
43
33
|
opts = typeof opts === 'string' ? { parent: opts, default: def } : { default: def, ...(opts ?? {}) };
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAe,cAAc,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAC9D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAIxD,MAAM,CAAC,MAAM,KAAK,GAAqC,CAAC,KAAK,EAAE,IAAI,EAAE,IAAK,EAAE,EAAE,CAC5E,cAAc,CAAC,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AAEhD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,IAAY,EAAU,EAAE;IACpD,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAA;IAClB,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CA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,GAAG,cAAc,CAAC,MAAM,CAAA;IAEtC,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAmC,EAAE,GAA4B,EAAyB,EAAE;IACnH,IAAI,OAAO,GAAG,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,EAAE,CAAA;IACtG,CAAC;SAAM,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,IAAI,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,GAAG,EAAE,CAAA;IAClF,CAAC;IAED,OAAO,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAoB,CAAC,CAAA;AACtD,CAAC,CAAA"}
|
package/build/model.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,eAAO,MAAM,cAAc,UAAW,gBAAgB,KAAG,UAAyB,CAAA;AAElF,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAG5D,eAAO,MAAM,cAAc,UAAW,gBAAgB,KAAG,UAAyB,CAAA;AAElF,eAAO,MAAM,WAAW,EAAE,oBAAoB,CAAC,gBAAgB,CAY9D,CAAA"}
|
package/build/model.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { AppType } from '@owlmeans/context';
|
|
2
2
|
export const makeRouteModel = (route) => ({ route });
|
|
3
3
|
export const createRoute = (alias, path, opts) => {
|
|
4
|
+
const options = typeof opts === 'string' ? { parent: opts } : opts;
|
|
5
|
+
const { parent, ...rest } = options ?? {};
|
|
4
6
|
const route = {
|
|
5
7
|
alias,
|
|
6
8
|
type: AppType.Backend,
|
|
7
9
|
path,
|
|
8
|
-
...
|
|
10
|
+
...rest,
|
|
11
|
+
...(parent == null ? {} : { parent: typeof parent === 'string' ? parent : parent.alias }),
|
|
9
12
|
};
|
|
10
13
|
return route;
|
|
11
14
|
};
|
package/build/model.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAuB,EAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAElF,MAAM,CAAC,MAAM,WAAW,GAA2C,CAAC,KAAK,EAAE,IAAI,EAAE,IAAK,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../src/model.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAE3C,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAuB,EAAc,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAElF,MAAM,CAAC,MAAM,WAAW,GAA2C,CAAC,KAAK,EAAE,IAAI,EAAE,IAAK,EAAoB,EAAE;IAC1G,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IAClE,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,CAAA;IACzC,MAAM,KAAK,GAAqB;QAC9B,KAAK;QACL,IAAI,EAAE,OAAO,CAAC,OAAO;QACrB,IAAI;QACJ,GAAG,IAAI;QACP,GAAG,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;KAC1F,CAAA;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA"}
|
package/build/types.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { AppType } from '@owlmeans/context';
|
|
1
|
+
import type { AppType, EntrypointReference } from '@owlmeans/context';
|
|
2
2
|
import type { RouteProtocols, RouteMethod } from './consts';
|
|
3
|
+
/** A built-in or package-owned transport identifier. */
|
|
4
|
+
export type RouteProtocol = RouteProtocols | (string & {});
|
|
3
5
|
export interface BasicRoute {
|
|
4
6
|
type: AppType;
|
|
5
7
|
service?: string;
|
|
@@ -20,18 +22,10 @@ export interface RouteDeclaration extends BasicRoute {
|
|
|
20
22
|
parent?: string;
|
|
21
23
|
default?: boolean;
|
|
22
24
|
method?: RouteMethod;
|
|
23
|
-
protocol?:
|
|
25
|
+
protocol?: RouteProtocol;
|
|
24
26
|
secure?: boolean;
|
|
25
|
-
/**
|
|
26
|
-
|
|
27
|
-
* process — which queues a given process consumes is configuration, never a declaration.
|
|
28
|
-
*/
|
|
29
|
-
queue?: string;
|
|
30
|
-
/**
|
|
31
|
-
* QUEUE routes only: whether the caller waits for the job's return value. `false` resolves as
|
|
32
|
-
* soon as the job is accepted, which is what a long pipeline wants; the default is to wait.
|
|
33
|
-
*/
|
|
34
|
-
reply?: boolean;
|
|
27
|
+
/** Transport-owned declaration data. The package defining `protocol` owns and validates it. */
|
|
28
|
+
protocolOptions?: unknown;
|
|
35
29
|
/** How long a caller waits for an answer, in milliseconds, when the transport supports it. */
|
|
36
30
|
timeout?: number;
|
|
37
31
|
}
|
|
@@ -49,7 +43,7 @@ export interface RouteAddress {
|
|
|
49
43
|
port?: number;
|
|
50
44
|
base?: string;
|
|
51
45
|
secure: boolean;
|
|
52
|
-
protocol:
|
|
46
|
+
protocol: RouteProtocol;
|
|
53
47
|
}
|
|
54
48
|
/**
|
|
55
49
|
* The model wrapping a declaration. It carries no resolution state of its own — every address
|
|
@@ -58,6 +52,9 @@ export interface RouteAddress {
|
|
|
58
52
|
export interface RouteModel {
|
|
59
53
|
route: RouteDeclaration;
|
|
60
54
|
}
|
|
61
|
-
export
|
|
55
|
+
export type RouteParent = string | EntrypointReference;
|
|
56
|
+
export interface RouteOptions extends Omit<Partial<RouteDeclaration>, 'parent'> {
|
|
57
|
+
/** A parent protocol is preferred in application declarations; strings remain adapter input. */
|
|
58
|
+
parent?: RouteParent;
|
|
62
59
|
}
|
|
63
60
|
//# sourceMappingURL=types.d.ts.map
|
package/build/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACrE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EA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H,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,gBAAgB,CAAA;CACxB;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,mBAAmB,CAAA;AAEtD,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC;IAC7E,gGAAgG;IAChG,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RouteDeclaration } from '../../types.js';
|
|
2
|
+
/** Context-free edits and reads of one route declaration. */
|
|
3
|
+
export interface RouteDeclarationHelper {
|
|
4
|
+
/** Fills the declaration's unset fields from `overrides`, limited to `filter` keys when given. */
|
|
5
|
+
overrideParams: (route: RouteDeclaration, overrides?: Partial<RouteDeclaration>, filter?: string[]) => void;
|
|
6
|
+
/** `path` under the declaration's own `base`, when it has one. */
|
|
7
|
+
prependBase: (route: RouteDeclaration, path: string) => string;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/declaration/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,6DAA6D;AAC7D,MAAM,WAAW,sBAAsB;IACrC,kGAAkG;IAClG,cAAc,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,SAAS,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,IAAI,CAAA;IAC3G,kEAAkE;IAClE,WAAW,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAAA;CAC/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/declaration/types.ts"],"names":[],"mappings":""}
|