@owlmeans/server-entrypoint 0.1.18-rc.19 → 0.1.18-rc.20
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 +119 -32
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/server-entrypoint/SKILL.md +10 -4
- package/build/entrypoint.js +2 -2
- package/build/entrypoint.js.map +1 -1
- package/build/helper.d.ts +5 -4
- package/build/helper.d.ts.map +1 -1
- package/build/helper.js +16 -2
- package/build/helper.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,63 +1,150 @@
|
|
|
1
1
|
# @owlmeans/server-entrypoint
|
|
2
2
|
|
|
3
|
-
Server-side entrypoint
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- `
|
|
8
|
-
|
|
9
|
-
- Used by `@owlmeans/server-app` when assembling a server context
|
|
3
|
+
Server-side entrypoint binding: turns an immutable protocol declaration from the shared package into
|
|
4
|
+
a server-local entrypoint that carries its route, guards, gate and handler. An application calls
|
|
5
|
+
`bind` / `bindAll` in its `entrypoints.ts` (often through the `@owlmeans/server-app` re-export) to
|
|
6
|
+
build the list it registers on the context. It does not write handlers — use `handlers<Context>()`
|
|
7
|
+
from `@owlmeans/server-api` for HTTP and `connection()` from `@owlmeans/server-socket` for sockets —
|
|
8
|
+
and a browser app binds the same protocols with `@owlmeans/client-entrypoint` instead.
|
|
10
9
|
|
|
11
10
|
## Installation
|
|
12
11
|
|
|
13
12
|
```bash
|
|
14
|
-
bun add @owlmeans/server-entrypoint@^0.1.18-rc.
|
|
13
|
+
bun add @owlmeans/server-entrypoint@^0.1.18-rc.19
|
|
15
14
|
```
|
|
16
15
|
|
|
16
|
+
## Concepts
|
|
17
|
+
|
|
18
|
+
- **Protocol declaration** — the frozen `protocol()` / `openProtocol()` object from
|
|
19
|
+
`@owlmeans/entrypoint`, shared by callers and servers. It is data; binding never changes it.
|
|
20
|
+
- **Server entrypoint** — what `bind` returns: a materialized copy with a server route, merged
|
|
21
|
+
guards, gate, filter, optional fixer and handler, plus a `protocol` field pointing at its
|
|
22
|
+
declaration.
|
|
23
|
+
- **Bound handler** — `{ protocol, bind }`, produced by `handlers<Context>()` or `connection()`. It
|
|
24
|
+
is inseparable from the protocol whose request it accepts.
|
|
25
|
+
- **Group node** — a parent declaration (`base`) bound without a handler. It contributes the path
|
|
26
|
+
prefix, guards and gate its children inherit and is never mounted as a route itself.
|
|
27
|
+
- **Intermediate** — an entrypoint whose handler runs before matching routes and may replace the
|
|
28
|
+
request context; declared per route or forced with `{ intermediate: true }`.
|
|
29
|
+
|
|
17
30
|
## Usage
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
### Bind leaves and their parents
|
|
20
33
|
|
|
21
|
-
```
|
|
34
|
+
```ts
|
|
22
35
|
import { bind } from '@owlmeans/server-entrypoint'
|
|
23
36
|
import { handlers } from '@owlmeans/server-api'
|
|
24
|
-
import {
|
|
25
|
-
import type { Context } from '
|
|
37
|
+
import { projectProtocols } from 'my-app-common'
|
|
38
|
+
import type { Context } from './context.js'
|
|
26
39
|
|
|
27
40
|
const api = handlers<Context>()
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
bind(
|
|
32
|
-
|
|
41
|
+
|
|
42
|
+
export const serverBindings = [
|
|
43
|
+
bind(projectProtocols.base),
|
|
44
|
+
bind(projectProtocols.create, api.body(projectProtocols.create, async (body, context) =>
|
|
45
|
+
context.project().create(body))),
|
|
46
|
+
bind(projectProtocols.get, api.params(projectProtocols.get, async ({ id }, context) =>
|
|
47
|
+
context.project().load(id))),
|
|
33
48
|
]
|
|
34
49
|
```
|
|
35
50
|
|
|
36
|
-
|
|
51
|
+
### Bind a flat collection
|
|
52
|
+
|
|
53
|
+
`bindAll` pairs each declaration with the implementation whose `protocol` is the same object.
|
|
54
|
+
Declarations without an implementation are bound as group nodes. Flatten a tree with `protocols()`
|
|
55
|
+
only here, at the registration boundary.
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { bindAll } from '@owlmeans/server-entrypoint'
|
|
59
|
+
import { protocols } from '@owlmeans/entrypoint'
|
|
60
|
+
import * as project from './app/project.js'
|
|
37
61
|
|
|
38
|
-
|
|
62
|
+
export const projectBindings = bindAll(protocols(projectProtocols), [
|
|
63
|
+
project.list,
|
|
64
|
+
project.create,
|
|
65
|
+
project.get,
|
|
66
|
+
])
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Bind a tree by path
|
|
39
70
|
|
|
40
|
-
|
|
71
|
+
Larger services walk the protocol tree and look up the implementation at the same path, so a new or
|
|
72
|
+
renamed declaration stays type-checked at its binding site:
|
|
41
73
|
|
|
42
|
-
|
|
74
|
+
```ts
|
|
75
|
+
import { bind } from '@owlmeans/server-entrypoint'
|
|
76
|
+
import type { ServerEntrypoint } from '@owlmeans/server-entrypoint'
|
|
77
|
+
import { isEntrypointProtocol } from '@owlmeans/entrypoint'
|
|
78
|
+
import type { EntrypointTree } from '@owlmeans/entrypoint'
|
|
79
|
+
|
|
80
|
+
type Implementations = Record<string, unknown>
|
|
81
|
+
|
|
82
|
+
const bindTree = (tree: EntrypointTree, implementations: Implementations = {}): ServerEntrypoint<object>[] =>
|
|
83
|
+
Object.entries(tree).flatMap(([key, declaration]) => {
|
|
84
|
+
const implementation = implementations[key]
|
|
85
|
+
if (isEntrypointProtocol(declaration)) {
|
|
86
|
+
return [bind(declaration, implementation as never)]
|
|
87
|
+
}
|
|
88
|
+
return bindTree(declaration, (implementation ?? {}) as Implementations)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
export const serverBindings = bindTree({ project: projectProtocols, invoice: invoiceProtocols }, {
|
|
92
|
+
project: { list: project.list, create: project.create, get: project.get },
|
|
93
|
+
invoice: { list: invoice.list, pay: invoice.pay },
|
|
94
|
+
})
|
|
95
|
+
```
|
|
43
96
|
|
|
44
|
-
|
|
97
|
+
### Server-local options
|
|
45
98
|
|
|
46
|
-
|
|
99
|
+
The third argument adjusts only the local binding. `guards` are merged with the declaration's,
|
|
100
|
+
`fixer` names a `FixerService` that answers errors instead of the default mapping, and
|
|
101
|
+
`intermediate` forces the entrypoint to run as an intermediate.
|
|
47
102
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
answers whether a request hits it
|
|
51
|
-
- `handle: RefedEntrypointHandler<R>` — the attached handler
|
|
103
|
+
```ts
|
|
104
|
+
import { bind } from '@owlmeans/server-entrypoint'
|
|
52
105
|
|
|
53
|
-
|
|
106
|
+
export const serverBindings = [
|
|
107
|
+
bind(sessionProtocols.base, undefined, { intermediate: true }),
|
|
108
|
+
bind(invoiceProtocols.download, invoice.download, { fixer: MY_APP_DOWNLOAD_FIXER }),
|
|
109
|
+
]
|
|
110
|
+
```
|
|
54
111
|
|
|
55
|
-
|
|
112
|
+
## API
|
|
56
113
|
|
|
57
|
-
|
|
114
|
+
| Symbol | Kind | Purpose |
|
|
115
|
+
|---|---|---|
|
|
116
|
+
| `bind(protocol, implementation?, options?)` | function | Materialize one declaration and attach a bound handler (or a `RefedEntrypointHandler`); returns `ServerProtocolEntrypoint<Protocol>` |
|
|
117
|
+
| `bindAll(declarations, implementations = [])` | function | Bind a flat declaration list, pairing implementations by `implementation.protocol === declaration` |
|
|
118
|
+
| `ServerEntrypoint<R>` | type | `CommonEntrypoint` with `route: ServerRouteModel<R>`, `handle: EntrypointHandler`, `fixer?` |
|
|
119
|
+
| `ServerProtocolEntrypoint<Protocol>` | type | `ServerEntrypoint<object>` plus `readonly protocol` |
|
|
120
|
+
| `BoundEntrypointHandler<Protocol>` | type | `{ readonly protocol, bind: RefedEntrypointHandler }` |
|
|
121
|
+
| `RefedEntrypointHandler<R>` | type | `(ref: EntrypointRef<R>) => EntrypointHandler`; the handler reads the bound entrypoint (and its context) from `ref.ref` |
|
|
122
|
+
| `EntrypointRef<R>` | type | `{ ref?: ServerEntrypoint<R> }` |
|
|
123
|
+
| `EntrypointOptions<R>` | type | `CommonEntrypointOptions` plus `fixer?`, `intermediate?`, `routeOptions?` |
|
|
124
|
+
| `FixerService` | type | Service with `handle(reply, error)` used when a binding names a `fixer` |
|
|
125
|
+
|
|
126
|
+
## Common pitfalls
|
|
127
|
+
|
|
128
|
+
- A handler carries its `protocol`, and collections match by object identity. Never attach, find or
|
|
129
|
+
replace a handler by alias.
|
|
130
|
+
- A decorated tree (`withOidcGuard(tree)`, `decorateEntrypoint(...)`) consists of new objects. Make
|
|
131
|
+
handlers from the same decorated protocols you bind, or `bindAll` will not pair them.
|
|
132
|
+
- Do not mutate a declaration or create a mutable contextual declaration; decorate the tree before
|
|
133
|
+
binding instead.
|
|
134
|
+
- Bind parent declarations too. A route whose parent is not registered loses its inherited path,
|
|
135
|
+
guards and gate.
|
|
136
|
+
- A binding without a handler is never mounted as an HTTP route — that is how group nodes work, and
|
|
137
|
+
also why a forgotten implementation shows up as a 404.
|
|
138
|
+
- HTTP handlers come from `handlers<Context>()`; socket handlers from `connection(protocol, callback)`.
|
|
139
|
+
|
|
140
|
+
## Related packages
|
|
58
141
|
|
|
59
142
|
- [`@owlmeans/entrypoint`](../entrypoint) — immutable protocol declarations
|
|
60
|
-
- [`@owlmeans/server-api`](../server-api) —
|
|
143
|
+
- [`@owlmeans/server-api`](../server-api) — `handlers<Context>()` for HTTP bindings
|
|
144
|
+
- [`@owlmeans/server-socket`](../server-socket) — `connection()` for socket bindings
|
|
145
|
+
- [`@owlmeans/server-route`](../server-route) — the server route model a binding carries
|
|
146
|
+
- [`@owlmeans/server-app`](../server-app) — re-exports `bind` / `bindAll` and registers the list
|
|
147
|
+
- [`@owlmeans/client-entrypoint`](../client-entrypoint) — the browser-side binding of the same protocols
|
|
61
148
|
|
|
62
149
|
<!-- owlmeans:agent-guidance:start -->
|
|
63
150
|
## Agent guidance
|
|
@@ -67,7 +154,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
67
154
|
your project's skill store (`.agents/skills/`):
|
|
68
155
|
|
|
69
156
|
```sh
|
|
70
|
-
npx @owlmeans/agent-skills@^0.1.18-rc.
|
|
157
|
+
npx @owlmeans/agent-skills@^0.1.18-rc.21
|
|
71
158
|
```
|
|
72
159
|
|
|
73
160
|
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
2
|
"schemaVersion": 2,
|
|
3
3
|
"package": "@owlmeans/server-entrypoint",
|
|
4
|
-
"version": "0.1.18-rc.
|
|
5
|
-
"generatedAt": "2026-09-
|
|
4
|
+
"version": "0.1.18-rc.20",
|
|
5
|
+
"generatedAt": "2026-09-15T12:21:31.922Z",
|
|
6
6
|
"canonicalRepo": "https://github.com/owlmeans/common",
|
|
7
7
|
"entries": [
|
|
8
8
|
{
|
|
@@ -7,7 +7,7 @@ user-invocable: false
|
|
|
7
7
|
|
|
8
8
|
# @owlmeans/server-entrypoint
|
|
9
9
|
|
|
10
|
-
**Install:** `bun add @owlmeans/server-entrypoint@^0.1.18-rc.
|
|
10
|
+
**Install:** `bun add @owlmeans/server-entrypoint@^0.1.18-rc.19`
|
|
11
11
|
|
|
12
12
|
Bind the imported protocol object to the implementation that serves it:
|
|
13
13
|
|
|
@@ -17,17 +17,23 @@ import { handlers } from '@owlmeans/server-api'
|
|
|
17
17
|
|
|
18
18
|
const api = handlers<AppContext>()
|
|
19
19
|
|
|
20
|
-
export const
|
|
21
|
-
bind(
|
|
20
|
+
export const serverBindings = [
|
|
21
|
+
bind(projectProtocols.create, api.body(projectProtocols.create, async (body, context) =>
|
|
22
22
|
context.projects.create(body)
|
|
23
23
|
)),
|
|
24
24
|
]
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
`bind(protocol, handler?, options?)` returns a `ServerProtocolEntrypoint<Protocol>`.
|
|
28
|
-
`bindAll(declarations, handlers?)` is for a flat protocol collection. A handler carries its
|
|
28
|
+
`bindAll(declarations, handlers?)` is for a flat protocol collection at a registration boundary. A handler carries its
|
|
29
29
|
`protocol`, and a collection is matched by object identity; an alias is never used to find or
|
|
30
30
|
replace it. HTTP code should use `handlers<Context>()`; sockets use `connection(protocol, callback)`.
|
|
31
31
|
|
|
32
|
+
The second argument is either a protocol-bound handler (from `handlers<Context>()` above, or a
|
|
33
|
+
library factory that returns one) or omitted entirely for a parent route. A plain callback passed
|
|
34
|
+
directly to `bind()` is NOT the same thing: it is treated as a ref handler and invoked once, at
|
|
35
|
+
bind time, with the entrypoint ref as its only argument — not per-request. Wrap it with
|
|
36
|
+
`handlers<Context>()` first.
|
|
37
|
+
|
|
32
38
|
Do not create a mutable contextual declaration, use a compatibility entrypoint type, or attach a
|
|
33
39
|
handler with an alias. The declaration is shared data; the binding is its server-local runtime.
|
package/build/entrypoint.js
CHANGED
|
@@ -4,7 +4,7 @@ export const entrypoint = (arg, handler, opts) => {
|
|
|
4
4
|
const entrypointHandle = { ref: undefined };
|
|
5
5
|
let _entrypoint;
|
|
6
6
|
if (isEntrypoint(arg)) {
|
|
7
|
-
//
|
|
7
|
+
// Elevating the same alias again is legal, so an intermediate route stays intermediate unless
|
|
8
8
|
// this call says otherwise.
|
|
9
9
|
const intermediate = opts?.intermediate
|
|
10
10
|
?? (isServerRouteModel(arg.route) ? arg.route.isIntermediate() : false);
|
|
@@ -12,7 +12,7 @@ export const entrypoint = (arg, handler, opts) => {
|
|
|
12
12
|
_entrypoint = arg;
|
|
13
13
|
_entrypoint.route = routeModel;
|
|
14
14
|
_entrypoint.filter = opts?.filter ?? arg.filter;
|
|
15
|
-
//
|
|
15
|
+
// Elevating adds guards, it never swaps them: what the entrypoint declared still applies.
|
|
16
16
|
_entrypoint.guards = [...new Set([...(arg.guards ?? []), ...(opts?.guards ?? [])])];
|
|
17
17
|
_entrypoint.gate = opts?.gate ?? arg.gate;
|
|
18
18
|
_entrypoint.gateParams = opts?.gateParams ?? arg.gateParams;
|
package/build/entrypoint.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.js","sourceR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1,13 @@
|
|
|
1
|
-
import type { ServerEntrypoint, EntrypointOptions, RefedEntrypointHandler } from './types.js';
|
|
2
|
-
import type { CommonEntrypoint } from '@owlmeans/entrypoint';
|
|
1
|
+
import type { BoundEntrypointHandler, ServerEntrypoint, EntrypointOptions, RefedEntrypointHandler, ServerProtocolEntrypoint } from './types.js';
|
|
2
|
+
import type { CommonEntrypoint, EntrypointProtocolDeclaration } from '@owlmeans/entrypoint';
|
|
3
3
|
/**
|
|
4
|
-
* Replace the entrypoint declared under `alias` with its
|
|
4
|
+
* Replace the entrypoint declared under `alias` with its elevated counterpart. Elevating is
|
|
5
5
|
* idempotent — calling it again simply replaces the element once more, and the guards it brings
|
|
6
6
|
* are added to the ones already declared.
|
|
7
7
|
*
|
|
8
8
|
* @throws {SyntaxError} when no entrypoint carries the alias
|
|
9
9
|
*/
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function elevate(declarations: EntrypointProtocolDeclaration[], implementations: readonly BoundEntrypointHandler<EntrypointProtocolDeclaration>[]): ServerProtocolEntrypoint<EntrypointProtocolDeclaration>[];
|
|
11
|
+
export declare function elevate<R>(entrypoints: (CommonEntrypoint | ServerEntrypoint<R>)[], alias: string, handler?: RefedEntrypointHandler<R> | boolean | EntrypointOptions<R>, opts?: boolean | EntrypointOptions<R>): ServerEntrypoint<R>[];
|
|
11
12
|
export declare const guard: <R>(guard: string, opts?: EntrypointOptions<R>) => EntrypointOptions<R>;
|
|
12
13
|
//# 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,KAAK,EACV,gBAAgB,EAAE,iBAAiB,EAAE,sBAAsB,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,sBAAsB,EACnF,wBAAwB,EACzB,MAAM,YAAY,CAAA;AAKnB,OAAO,KAAK,EAAE,gBAAgB,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAA;AAE3F;;;;;;GAMG;AACH,wBAAgB,OAAO,CACrB,YAAY,EAAE,6BAA6B,EAAE,EAC7C,eAAe,EAAE,SAAS,sBAAsB,CAAC,6BAA6B,CAAC,EAAE,GAChF,wBAAwB,CAAC,6BAA6B,CAAC,EAAE,CAAA;AAC5D,wBAAgB,OAAO,CAAC,CAAC,EACvB,WAAW,EAAE,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,EACvD,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,sBAAsB,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,EACpE,IAAI,CAAC,EAAE,OAAO,GAAG,iBAAiB,CAAC,CAAC,CAAC,GACpC,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAA;AA4CxB,eAAO,MAAM,KAAK,GAAI,CAAC,SAAS,MAAM,SAAS,iBAAiB,CAAC,CAAC,CAAC,KAAG,iBAAiB,CAAC,CAAC,CACjD,CAAA"}
|
package/build/helper.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { entrypoint } from './entrypoint.js';
|
|
2
|
+
import { bind } from './protocol.js';
|
|
2
3
|
import { createBasicGuard } from './utils/helper.js';
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { isEntrypointProtocol } from '@owlmeans/entrypoint';
|
|
5
|
+
export function elevate(entrypoints, target, handler, opts) {
|
|
6
|
+
if (typeof target !== 'string') {
|
|
7
|
+
return entrypoints.map((declaration) => {
|
|
8
|
+
if (!isEntrypointProtocol(declaration)) {
|
|
9
|
+
throw new SyntaxError('Protocol elevation accepts protocol declarations only');
|
|
10
|
+
}
|
|
11
|
+
const implementation = target.find(bound => bound.protocol === declaration);
|
|
12
|
+
return bind(declaration, implementation);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
const idx = entrypoints.findIndex((candidate) => !isEntrypointProtocol(candidate) && candidate.route.route.alias === target);
|
|
5
16
|
if (idx === -1) {
|
|
6
17
|
throw new SyntaxError(`Entrypoint with alias ${target} not present`);
|
|
7
18
|
}
|
|
@@ -14,6 +25,9 @@ export function replaceEntrypoint(entrypoints, target, handler, opts) {
|
|
|
14
25
|
handler = undefined;
|
|
15
26
|
}
|
|
16
27
|
const declaration = entrypoints[idx];
|
|
28
|
+
if (isEntrypointProtocol(declaration)) {
|
|
29
|
+
throw new SyntaxError('String elevation accepts materialized entrypoints only');
|
|
30
|
+
}
|
|
17
31
|
entrypoints[idx] = entrypoint(declaration, handler, typeof opts === 'boolean' ? { intermediate: opts } : opts);
|
|
18
32
|
return entrypoints;
|
|
19
33
|
}
|
package/build/helper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAoB3D,MAAM,UAAU,OAAO,CACrB,WAAiE,EACjE,MAAiF,EACjF,OAAsE,EACtE,IAA0C;IAE1C,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;YACrC,IAAI,CAAC,oBAAoB,CAAC,WAAW,CAAC,EAAE,CAAC;gBACvC,MAAM,IAAI,WAAW,CAAC,uDAAuD,CAA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AE,IAA2B,EAAwB,EAAE,CAC3F,CAAC,EAAE,GAAG,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/server-entrypoint",
|
|
3
|
-
"version": "0.1.18-rc.
|
|
3
|
+
"version": "0.1.18-rc.20",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@owlmeans/context": "^0.1.18-rc.
|
|
25
|
-
"@owlmeans/entrypoint": "^0.1.18-rc.
|
|
26
|
-
"@owlmeans/route": "^0.1.18-rc.
|
|
27
|
-
"@owlmeans/server-route": "^0.1.18-rc.
|
|
24
|
+
"@owlmeans/context": "^0.1.18-rc.17",
|
|
25
|
+
"@owlmeans/entrypoint": "^0.1.18-rc.20",
|
|
26
|
+
"@owlmeans/route": "^0.1.18-rc.18",
|
|
27
|
+
"@owlmeans/server-route": "^0.1.18-rc.18"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@owlmeans/dep-config": "workspace:*",
|