@owlmeans/client-entrypoint 0.1.18-rc.4 → 0.1.18-rc.40

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.
Files changed (42) hide show
  1. package/README.md +169 -49
  2. package/agent-meta/manifest.json +2 -2
  3. package/agent-meta/skills/client-entrypoint/SKILL.md +33 -30
  4. package/build/entrypoint.d.ts +2 -3
  5. package/build/entrypoint.d.ts.map +1 -1
  6. package/build/entrypoint.js +25 -38
  7. package/build/entrypoint.js.map +1 -1
  8. package/build/failure.d.ts +19 -0
  9. package/build/failure.d.ts.map +1 -0
  10. package/build/failure.js +25 -0
  11. package/build/failure.js.map +1 -0
  12. package/build/helper.d.ts +2 -3
  13. package/build/helper.d.ts.map +1 -1
  14. package/build/helper.js +0 -15
  15. package/build/helper.js.map +1 -1
  16. package/build/index.d.ts +3 -2
  17. package/build/index.d.ts.map +1 -1
  18. package/build/index.js +3 -2
  19. package/build/index.js.map +1 -1
  20. package/build/protocol.d.ts +9 -0
  21. package/build/protocol.d.ts.map +1 -0
  22. package/build/protocol.js +15 -0
  23. package/build/protocol.js.map +1 -0
  24. package/build/types.d.ts +39 -9
  25. package/build/types.d.ts.map +1 -1
  26. package/build/utils/entrypoint.d.ts +2 -4
  27. package/build/utils/entrypoint.d.ts.map +1 -1
  28. package/build/utils/entrypoint.js +0 -9
  29. package/build/utils/entrypoint.js.map +1 -1
  30. package/build/utils/handler.d.ts +3 -3
  31. package/build/utils/handler.d.ts.map +1 -1
  32. package/build/utils/handler.js +54 -31
  33. package/build/utils/handler.js.map +1 -1
  34. package/package.json +10 -10
  35. package/src/entrypoint.ts +35 -48
  36. package/src/failure.ts +41 -0
  37. package/src/helper.ts +2 -26
  38. package/src/index.ts +3 -2
  39. package/src/protocol.ts +39 -0
  40. package/src/types.ts +50 -11
  41. package/src/utils/entrypoint.ts +2 -17
  42. package/src/utils/handler.ts +64 -40
package/README.md CHANGED
@@ -1,80 +1,200 @@
1
1
  # @owlmeans/client-entrypoint
2
2
 
3
- Client-side entrypoint system: elevates route definitions into API-calling `ClientEntrypoint` instances.
4
-
5
- ## Overview
6
-
7
- - `elevate(entrypoints, alias, handler?, opts?)` — attaches a client handler to an entrypoint (mirrors server `elevate`)
8
- - `ClientEntrypoint<T>` has a `call(request?)` method that resolves the URL and makes an HTTP/WS request
9
- - `stab` — no-op handler for entrypoints that only need URL resolution (no logic)
10
- - `provideRequest(alias, path)` — creates an `AbstractRequest` for programmatic entrypoint calls
11
- - `pickPerSchema(schema, obj)` — extracts fields from an object matching an AJV schema
12
- - Re-exported as `celevate` from `@owlmeans/server-app`
3
+ Client-side binding of shared entrypoint protocols. It turns an immutable `@owlmeans/entrypoint`
4
+ declaration into a context entrypoint with three verbs: `call()`, `invoke()` and `url()`. Every
5
+ browser and native OwlMeans app uses it, usually through the `bind` / `bindAll` / `bindScreen`
6
+ re-exports of `@owlmeans/web-client` or `@owlmeans/web-panel`. Protocols are declared with
7
+ [`@owlmeans/entrypoint`](../entrypoint), never here. Server handlers are bound with
8
+ [`@owlmeans/server-entrypoint`](../server-entrypoint).
13
9
 
14
10
  ## Installation
15
11
 
16
12
  ```bash
17
- bun add @owlmeans/client-entrypoint
13
+ bun add @owlmeans/client-entrypoint@^0.1.18-rc.40
18
14
  ```
19
15
 
20
- ## Usage
21
-
22
- Define and elevate a client entrypoint for API calls:
16
+ ## Concepts
17
+
18
+ - **Protocol** — the shared, immutable declaration of one route, its typed request sections, its
19
+ response, guards and gate. Binding never mutates it, and `context.entrypoint(protocol)` derives
20
+ the request and reply types from it.
21
+ - **Binding** — `bind`, `bindAll` and `bindScreen` materialize protocols into
22
+ `ClientProtocolEntrypoint<Protocol>` values, which the app hands to `context.registerEntrypoints`.
23
+ - **Screen** — a binding that carries a renderer. It is addressed by `url()`; `call()` and
24
+ `invoke()` throw and point the caller at `url()`.
25
+ - **Verbs** — `call()` resolves to the value and throws the reply's error; `invoke()` resolves to
26
+ `{ value, outcome }`; `url()` builds the address with `:params` filled in and the query appended.
27
+ - **Transport selection** — the route's protocol decides the carrier. When a service is registered
28
+ under that protocol's transport alias (a socket or queue transport), it takes the call. Otherwise
29
+ the API client named by `cfg.webService` does — a string, or a map keyed by service name with a
30
+ default key. Callers never branch on it.
31
+ - **Call options** — a request holds only the contract's sections (`params`, `query`, `body`,
32
+ `headers`) plus `CallOptions`: `auth`, `host`, `base`, `unsecure`, `timeout` and `signal`.
23
33
 
24
- ```typescript
25
- import { elevate, stab } from '@owlmeans/client-entrypoint'
26
- import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
34
+ ## Usage
27
35
 
28
- const appModules = [
29
- entrypoint(route('project-list', '/projects', frontend('base'))),
30
- entrypoint(route('project-create', '/projects', backend(RouteMethod.POST))),
36
+ ### 1. Bind a protocol tree and screens
37
+
38
+ ```ts
39
+ import { handler } from '@owlmeans/client'
40
+ import { bind, bindAll, bindScreen, stab } from '@owlmeans/client-entrypoint'
41
+ import { apiProtocols, webProtocols } from 'my-app-common'
42
+ import { ProjectListScreen } from './screens/project-list.js'
43
+
44
+ export const clientBindings = [
45
+ // Every API declaration the browser may call, route parents included.
46
+ ...bindAll(apiProtocols),
47
+ // A backend route outside that tree.
48
+ bind(apiProtocols.health),
49
+ bindScreen(webProtocols.projectList, handler(ProjectListScreen)),
50
+ // A frontend route only ever addressed by URL, with no component of its own here.
51
+ bindScreen(webProtocols.projectExport, stab),
31
52
  ]
32
53
 
33
- // Frontend navigation — just a stub, no network call
34
- elevate(appModules, 'project-list', stab)
35
-
36
- // Backend API call — call() makes a POST request
37
- elevate(appModules, 'project-create')
54
+ context.registerEntrypoints(clientBindings)
38
55
  ```
39
56
 
40
- Call an entrypoint from a service:
57
+ ### 2. Per-binding options
58
+
59
+ `bind` and `bindScreen` take `ClientEntrypointOptions`. Use `bind` instead of `bindAll` when one
60
+ protocol needs something the rest do not.
61
+
62
+ ```ts
63
+ import { authProtocols } from '@owlmeans/auth-common'
64
+ import { bind, bindScreen, stab } from '@owlmeans/client-entrypoint'
65
+ import { apiProtocols, MY_APP_WEB } from 'my-app-common'
41
66
 
42
- ```typescript
43
- const agentEntrypoint = ctx.entrypoint<ClientEntrypoint<Project>>(agent.project.create)
44
- const [result] = await agentEntrypoint.call({
45
- body: { prompt: payload.prompt, entity: req.auth?.entityId }
46
- })
67
+ export const extraBindings = [
68
+ // Validate the request against the protocol's schemas before it leaves the browser.
69
+ bind(apiProtocols.project.create, { validateOnCall: true }),
70
+ // Pin a frontend route to an explicitly selected service.
71
+ bindScreen(authProtocols.flowEnter, stab, { routeOptions: { overrides: { service: MY_APP_WEB } } }),
72
+ ]
47
73
  ```
48
74
 
49
- ## API
75
+ ### 3. Call, invoke, url
50
76
 
51
- ### `elevate<T, R>(entrypoints, alias, handler?, opts?): ClientEntrypoint<T, R>[]`
77
+ ```ts
78
+ import { EntrypointOutcome } from '@owlmeans/entrypoint'
52
79
 
53
- Mutates `entrypoints` in-place and returns the array typed as `ClientEntrypoint`. The `handler` sets how `call()` behaves.
80
+ const create = ctx.entrypoint(apiProtocols.project.create)
54
81
 
55
- ### `stab: RefedEntrypointHandler`
82
+ // Value only. The body type comes from the shared contract; do not add a generic here.
83
+ const project = await create.call({ body: { name: form.name } })
56
84
 
57
- No-op handler for frontend-only entrypoints that just need URL resolution.
85
+ // Value and outcome, when the outcome decides the next step.
86
+ const { value, outcome } = await ctx.entrypoint(apiProtocols.project.get).invoke({ params: { id } })
87
+ if (outcome !== EntrypointOutcome.Ok) {
88
+ throw new ProjectMissing(id)
89
+ }
58
90
 
59
- ### `ClientEntrypoint<T>` (type)
91
+ // A screen address; absolute when the route belongs to another service or when asked for.
92
+ const href = await ctx.entrypoint(webProtocols.project).url({ params: { id: value.id } }, { absolute: true })
93
+ ```
60
94
 
61
- - `call(request?)` — resolves URL, makes HTTP request, returns `[T, EntrypointOutcome]`
62
- - `validate(request?)` — validates the request against the entrypoint filter schema
63
- - `getPath(partial?)` — returns the URL path (with or without path params)
95
+ ### 4. Timeouts and cancellation
96
+
97
+ ```ts
98
+ const controller = new AbortController()
99
+ const timer = setTimeout(() => controller.abort(), 15_000)
100
+
101
+ try {
102
+ const files = await ctx.entrypoint(apiProtocols.files.list).call({
103
+ params: { id: projectId },
104
+ query: { path: '/' },
105
+ timeout: 10_000,
106
+ signal: controller.signal,
107
+ })
108
+ showFiles(files)
109
+ } finally {
110
+ clearTimeout(timer)
111
+ }
112
+ ```
64
113
 
65
- ### `provideRequest<T>(alias, path): AbstractRequest<T>`
114
+ A mutation route (`POST`, `PUT`, `PATCH`) always sends a body — `{}` when the contract has none —
115
+ so `call({ params })` is enough. Never add `{ body: {} }` as a workaround.
66
116
 
67
- Creates a minimal request object for programmatic `call()` invocations.
117
+ ### 5. Narrowing a payload to a schema
68
118
 
69
- ### `pickPerSchema<T>(schema, obj): Partial<T>`
119
+ `pickPerSchema(object, schema)` keeps only the keys the AJV schema declares and skips `null` values.
120
+ It is useful when a form model carries more fields than the contract accepts.
70
121
 
71
- Extracts only the keys present in the AJV schema from `obj`.
122
+ ```ts
123
+ import { pickPerSchema } from '@owlmeans/client-entrypoint'
124
+ import type { ProjectUpdate } from 'my-app-common'
125
+ import { ProjectUpdateSchema } from 'my-app-common'
72
126
 
73
- ## Related Packages
127
+ const body = pickPerSchema<typeof formValues, ProjectUpdate>(formValues, ProjectUpdateSchema)
128
+ await ctx.entrypoint(apiProtocols.project.update).call({ params: { id }, body })
129
+ ```
130
+
131
+ ## API
74
132
 
75
- - [`@owlmeans/entrypoint`](../entrypoint) — `CommonEntrypoint` base that gets elevated
76
- - [`@owlmeans/client`](../client) — `useNavigate` uses `ClientEntrypoint.call()`
77
- - [`@owlmeans/server-app`](../server-app) — re-exports `elevate` as `celevate`
133
+ ### `@owlmeans/client-entrypoint`
134
+
135
+ | Symbol | Kind | Purpose |
136
+ |---|---|---|
137
+ | `bind(protocol, options?)` | function | Materialize one protocol for a client context |
138
+ | `bindAll(tree)` | function | Materialize every protocol in a named declaration tree |
139
+ | `bindScreen(protocol, handler, options?)` | function | Materialize a frontend protocol with its renderer |
140
+ | `stab` | const | No-op `RefedEntrypointHandler` for a URL-only frontend binding |
141
+ | `provideRequest(alias, path)` | function | A minimal `AbstractRequest` for a dynamic boundary (for example a socket request) |
142
+ | `pickPerSchema(object, schema)` | function | Keep only the non-null keys an AJV schema declares |
143
+ | `ClientProtocolEntrypoint<Protocol>` | type | The bound view of a protocol — see *Entrypoint members* |
144
+ | `ClientEntrypoint<T, R>` | type | The untyped bound entrypoint shape the protocol view is built from |
145
+ | `ClientEntrypointOptions` | type | `routeOptions?` (`ClientRouteOptions`), `validateOnCall?`, plus common entrypoint options |
146
+ | `ClientRequest` | type | `AbstractRequest` as the client sends it |
147
+ | `EntrypointCall`, `EntrypointInvoke`, `EntrypointReply`, `EntrypointUrl`, `EntrypointUrlOptions`, `EntrypointFilter` | type | Verb signatures; `EntrypointReply` is `{ value, outcome }`, `EntrypointUrlOptions` is `{ absolute? }` |
148
+ | `EntrypointRef`, `RefedEntrypointHandler` | type | The handler-factory contract `bindScreen` and `stab` use |
149
+ | `ClientEntrypointError` | class | Base client entrypoint error |
150
+ | `ClientValidationError` | class | Thrown by `validate()` when a request does not match its schema |
151
+
152
+ ### Entrypoint members
153
+
154
+ | Member | Purpose |
155
+ |---|---|
156
+ | `call(request?)` | Round trip; resolves to the value and throws the reply's error |
157
+ | `invoke(request?)` | Same round trip; resolves to `{ value, outcome }` |
158
+ | `url(request?, { absolute? })` | The address, with `:params` filled and the query appended |
159
+ | `validate(request?)` | Check the request against the protocol's filter schemas |
160
+ | `segment()`, `path()`, `mount()` | This route's segment, the segment under its ancestors, and that path under the service base — computed on every call, never written back |
161
+ | `protocol` | The declaration the binding was made from |
162
+
163
+ ### `@owlmeans/client-entrypoint/utils`
164
+
165
+ | Symbol | Kind | Purpose |
166
+ |---|---|---|
167
+ | `apiInvoke(ref, options?)` | function | The round trip behind `invoke()` |
168
+ | `apiHandler(ref)` | function | The handler that picks the transport service or the API client |
169
+ | `entrypointUrl(ref, request?, options?)` | function | The address behind `url()` |
170
+ | `validate(ref)` | function | The filter behind `validate()` |
171
+ | `isEntrypoint(value)` | function | Re-export from `@owlmeans/entrypoint/utils` |
172
+
173
+ ## Common pitfalls
174
+
175
+ - **Pass protocol objects, never alias strings.** `context.entrypoint(protocol)` is the lookup;
176
+ `entrypointRef<Request, Response>(alias)` from `@owlmeans/entrypoint` is reserved for a dynamic
177
+ remote declaration that cannot be imported.
178
+ - **Do not add a result generic at the call site.** When a type is wrong, fix the shared contract.
179
+ - **Bind route parents too.** An unbound protocol throws "entrypoint not found" before the request
180
+ is sent, which a broad `catch` easily misreports as a server error.
181
+ - **Screens reject `call()` and `invoke()`.** Use `url()` or navigate to them.
182
+ - **`cfg.webService` must resolve.** A context whose `webService` names no client for the route's
183
+ service (and no default key) throws a `SyntaxError` on the first call.
184
+ - **Socket URLs are always absolute.** A relative value would resolve against the page origin, which
185
+ in a split deployment is the web host rather than the service answering the upgrade.
186
+ - **Never mutate a declaration or a shared declaration collection** to change a guard, gate or
187
+ service. Use binding options, or derive an immutable decoration in the shared package.
188
+
189
+ ## Related packages
190
+
191
+ - [`@owlmeans/entrypoint`](../entrypoint) — `protocol()`, `contract()`, `typed()` and protocol trees
192
+ - [`@owlmeans/client`](../client) — `handler`, `useNavigate`, `useEntrypoint`
193
+ - [`@owlmeans/client-route`](../client-route) — client route models and `ClientRouteOptions`
194
+ - [`@owlmeans/api`](../api) — the HTTP client that carries calls
195
+ - [`@owlmeans/client-socket`](../client-socket) — socket transport for socket protocols
196
+ - [`@owlmeans/server-entrypoint`](../server-entrypoint) — the server-side counterpart
197
+ - [`@owlmeans/web-client`](../web-client) — re-exports the binding helpers for browser apps
78
198
 
79
199
  <!-- owlmeans:agent-guidance:start -->
80
200
  ## Agent guidance
@@ -84,7 +204,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
84
204
  your project's skill store (`.agents/skills/`):
85
205
 
86
206
  ```sh
87
- npx @owlmeans/agent-skills
207
+ npx @owlmeans/agent-skills@^0.1.18-rc.41
88
208
  ```
89
209
 
90
210
  The embedded files are version-matched to this package release. Do not edit them
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schemaVersion": 2,
3
3
  "package": "@owlmeans/client-entrypoint",
4
- "version": "0.1.18-rc.0",
5
- "generatedAt": "2026-08-16T22:20:50.501Z",
4
+ "version": "0.1.18-rc.40",
5
+ "generatedAt": "2026-09-28T02:06:37.875Z",
6
6
  "canonicalRepo": "https://github.com/owlmeans/common",
7
7
  "entries": [
8
8
  {
@@ -1,50 +1,53 @@
1
1
  ---
2
2
  name: client-entrypoint
3
- description: How to use @owlmeans/client-entrypoint — client-side entrypoint helpers extending @owlmeans/entrypoint with React component attachment and call helpers. Auto-invoked when importing client entrypoint helpers. Also covers the deprecated @owlmeans/client-module reexport shim.
3
+ description: Bind shared entrypoint protocols in a client context with typed call(), invoke(), url(), bindAll(), and bindScreen(). Load when wiring client API routes or screens.
4
4
  user-invocable: false
5
5
  ---
6
6
  <!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->
7
7
 
8
8
  # @owlmeans/client-entrypoint
9
9
 
10
- **Layer:** Client
11
- **Install:** `"@owlmeans/client-entrypoint": "^0.1.18-rc.0"` in `dependencies`
10
+ **Install:** `bun add @owlmeans/client-entrypoint@^0.1.18-rc.40`
12
11
 
13
- ## Key Exports
12
+ Bind a declaration from `@owlmeans/entrypoint`; never construct or replace a contextual
13
+ entrypoint by alias.
14
14
 
15
- | Export | Description |
16
- |--------|-------------|
17
- | `ClientEntrypoint<T>` types | Client entrypoint interface (handler component + call helpers) |
18
- | `EntrypointCall` / `EntrypointFilter` | Typed call and validation helpers |
19
- | `EntrypointRef` / `RefedEntrypointHandler` | Handler reference pattern |
20
- | Entrypoint helpers | Build client entrypoints; resolve callable references |
15
+ ```ts
16
+ import { bind, bindAll, bindScreen } from '@owlmeans/client-entrypoint'
21
17
 
22
- ## Subpath Exports
18
+ context.registerEntrypoints(bindAll(projectProtocols))
19
+ context.registerEntrypoint(bind(projectProtocols.health))
20
+ context.registerEntrypoint(bindScreen(projectProtocols.home, handler(Home)))
23
21
 
24
- - `./utils`
25
-
26
- ## Usage
27
-
28
- Most app code uses `elevate()` from `@owlmeans/web-client` (which builds on this). Use this directly only for cross-platform entrypoint helpers.
29
-
30
- ```typescript
31
- import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
22
+ const value = await context.entrypoint(projectProtocols.create).call({ body })
23
+ const { value, outcome } = await context.entrypoint(projectProtocols.create).invoke({ body })
24
+ const href = await context.entrypoint(projectProtocols.edit).url({ params: { id } })
32
25
  ```
33
26
 
34
- ## URL Generation via Entrypoint Call
35
-
36
- Entrypoints with a `handler` (React component) use `urlCall` internally — calling `.call()` returns a URL string. Use `{ full: true }` to get a fully-qualified URL via `makeSecurityHelper`:
27
+ `bindAll(tree)` flattens a nested named declaration tree while preserving the union of its protocol
28
+ types. `bind(protocol)` is appropriate where one protocol must use a distinct client option.
29
+ `bindScreen` is for a frontend route and renderer; screens are addressed by `url` and reject
30
+ `call`/`invoke`.
37
31
 
38
- ```typescript
39
- import type { ClientEntrypoint } from '@owlmeans/client-entrypoint'
40
- import { HOME } from '@owlmeans/context'
32
+ `bindScreen` takes a `lazyHandler(...)` result (`@owlmeans/client`) directly, the same as
33
+ `handler(Component)`: both return a `RefedEntrypointHandler`, the lazy one also carrying
34
+ `.preload()`, so no different wiring is needed. Create it at module scope, never in a render.
41
35
 
42
- const [url] = await context.entrypoint<ClientEntrypoint<string>>(HOME).call({ full: true }) ?? []
43
- // Returns e.g. "https://app.example.com/"
36
+ ```ts
37
+ const reports = lazyHandler(() => import('./reports.js'), 'Reports', { fallback: <Spinner /> })
38
+ context.registerEntrypoint(bindScreen(projectProtocols.reports, reports))
44
39
  ```
45
40
 
46
- This is the preferred pattern for redirect URIs and navigation targets instead of manual `window.location` concatenation.
41
+ `context.entrypoint(protocol)` derives `ClientProtocolEntrypoint<Protocol>` from the protocol. Do
42
+ not add an explicit result generic. `entrypointRef<Request, Response>(alias)` is reserved for a
43
+ dynamic remote declaration that cannot be imported.
47
44
 
48
- ## Depends On
45
+ Client calls include only contract request sections plus `CallOptions` (`auth`, host/port/base,
46
+ timeout, signal). `url` accepts params/query plus the same address options. The route transport is
47
+ chosen by the declaration; callers do not branch for HTTP, socket, or queue.
49
48
 
50
- - `@owlmeans/entrypoint`, `@owlmeans/client-route`, `@owlmeans/client-context`
49
+ `ensureEntrypointFailureService(context)` returns the context-local failure plugin host. Register
50
+ an `onFailure` plugin there to observe a rejected remote `invoke`/`call`, show a toast, or collect
51
+ diagnostics. Plugins run after the transport fails and the original error is still rethrown to
52
+ the caller. This is the opt-in seam for application-wide failure UI; keep the transport independent
53
+ of the chosen toast library.
@@ -1,6 +1,5 @@
1
- import type { ClientRouteModel } from '@owlmeans/client-route';
2
1
  import type { ClientEntrypoint, ClientEntrypointOptions, RefedEntrypointHandler } from './types.js';
3
2
  import type { AbstractRequest, CommonEntrypoint } from '@owlmeans/entrypoint';
4
- import type { CommonRouteModel } from '@owlmeans/route';
5
- export declare const entrypoint: <T, R extends AbstractRequest = AbstractRequest>(arg: CommonEntrypoint | ClientRouteModel | CommonRouteModel, handler?: RefedEntrypointHandler<T, R> | ClientEntrypointOptions | boolean, opts?: ClientEntrypointOptions | boolean) => ClientEntrypoint<T, R>;
3
+ /** Attach client behaviour to an entrypoint already materialized from a protocol. */
4
+ export declare const bindMaterializedEntrypoint: <T, R extends AbstractRequest = AbstractRequest>(arg: CommonEntrypoint, handler?: RefedEntrypointHandler<T, R>, opts?: ClientEntrypointOptions) => ClientEntrypoint<T, R>;
6
5
  //# sourceMappingURL=entrypoint.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAiB,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAClH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAO7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGvD,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,OAClE,gBAAgB,GAAG,gBAAgB,GAAG,gBAAgB,YACjD,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,uBAAuB,GAAG,OAAO,SACnE,uBAAuB,GAAG,OAAO,KACvC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CA+DvB,CAAA"}
1
+ {"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAiB,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAClH,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAO7E,qFAAqF;AACrF,eAAO,MAAM,0BAA0B,GAAI,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,OAClF,gBAAgB,YACX,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,SAC/B,uBAAuB,KAC7B,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAqDvB,CAAA"}
@@ -1,44 +1,36 @@
1
- import { isEntrypoint, makeBasicEntrypoint, normalizeHelperParams, validate } from './utils/entrypoint.js';
2
- import { isClientRouteModel, route } from '@owlmeans/client-route';
3
- import { apiCall, apiHandler, urlCall } from './utils/handler.js';
1
+ import { validate } from './utils/entrypoint.js';
2
+ import { route } from '@owlmeans/client-route';
3
+ import { apiInvoke, apiHandler, entrypointUrl } from './utils/handler.js';
4
4
  import { AppType } from '@owlmeans/context';
5
- import { normalizePath } from '@owlmeans/route';
6
5
  import { provideRequest } from './helper.js';
7
- export const entrypoint = (arg, handler, opts) => {
6
+ /** Attach client behaviour to an entrypoint already materialized from a protocol. */
7
+ export const bindMaterializedEntrypoint = (arg, handler, opts) => {
8
8
  const entrypointHandle = { ref: undefined };
9
9
  let _entrypoint;
10
- [handler, opts] = normalizeHelperParams(handler, opts);
11
- const _handler = handler ??
12
- (('route' in arg.route ? arg.route.route.type : arg.route.type)
13
- === AppType.Backend ? apiHandler : undefined);
14
- if (isEntrypoint(arg)) {
15
- assertExplicitHandler(arg.route.route.type, handler);
16
- const routeModel = route(arg.route, opts?.routeOptions);
17
- _entrypoint = arg;
18
- _entrypoint.route = routeModel;
19
- _entrypoint.guards = opts?.guards ?? arg.guards;
20
- _entrypoint.filter = opts?.filter ?? arg.filter;
21
- _entrypoint.gate = opts?.gate ?? arg.gate;
22
- _entrypoint.gateParams = opts?.gateParams ?? arg.gateParams;
23
- }
24
- else if (isClientRouteModel(arg)) {
25
- assertExplicitHandler(arg.route.type, handler);
26
- _entrypoint = makeBasicEntrypoint(arg, { ...opts });
27
- _entrypoint.route = arg;
28
- }
29
- else {
30
- assertExplicitHandler(arg.route.type, handler);
31
- const _route = route(arg, opts?.routeOptions);
32
- _entrypoint = makeBasicEntrypoint(_route, { ...opts });
33
- _entrypoint.route = _route;
34
- }
35
- _entrypoint.getPath = (partial) => partial === true ? normalizePath(_entrypoint.route.route.partialPath) : _entrypoint.route.route.path;
36
- _entrypoint.call = handler != null ? urlCall(entrypointHandle, opts) : apiCall(entrypointHandle, opts);
10
+ const _handler = handler ?? (arg.route.route.type === AppType.Backend ? apiHandler : undefined);
11
+ assertExplicitHandler(arg.route.route.type, handler);
12
+ const routeModel = route(arg.route, opts?.routeOptions);
13
+ _entrypoint = arg;
14
+ _entrypoint.route = routeModel;
15
+ // Binding adds guards, it never swaps them: what the declaration carries still applies.
16
+ _entrypoint.guards = [...new Set([...(arg.guards ?? []), ...(opts?.guards ?? [])])];
17
+ _entrypoint.filter = opts?.filter ?? arg.filter;
18
+ _entrypoint.gate = opts?.gate ?? arg.gate;
19
+ _entrypoint.gateParams = opts?.gateParams ?? arg.gateParams;
20
+ _entrypoint.url = ((req, urlOpts) => entrypointUrl(entrypointHandle, req, urlOpts));
21
+ // An entrypoint carrying a renderer IS a screen: it is addressed by URL, never called over the
22
+ // wire. Saying so here turns what used to be a URL-shaped answer from `call()` into a report.
23
+ _entrypoint.invoke = (handler != null
24
+ ? (async () => {
25
+ throw new SyntaxError(`Entrypoint ${_entrypoint.alias} renders a screen - address it with url() instead of call()/invoke()`);
26
+ })
27
+ : apiInvoke(entrypointHandle, opts));
28
+ _entrypoint.call = (async (req) => (await _entrypoint.invoke(req)).value);
37
29
  _entrypoint.request = ((request) => {
38
30
  if (entrypointHandle.ref == null) {
39
31
  throw SyntaxError(`Try to request uninitialized entrypoint ${JSON.stringify(arg)}`);
40
32
  }
41
- const _request = provideRequest(entrypointHandle.ref.getAlias(), entrypointHandle.ref.getPath());
33
+ const _request = provideRequest(entrypointHandle.ref.alias, entrypointHandle.ref.path());
42
34
  request != null && Object.entries(request).forEach(([key, value]) => {
43
35
  _request[key] = value;
44
36
  });
@@ -46,11 +38,6 @@ export const entrypoint = (arg, handler, opts) => {
46
38
  });
47
39
  _entrypoint.handle = _handler?.(entrypointHandle);
48
40
  _entrypoint.validate = validate(entrypointHandle);
49
- _entrypoint.reinitializeContext = (context) => {
50
- const newEntrypoint = entrypoint(_entrypoint.route, handler, opts);
51
- newEntrypoint.ctx = context;
52
- return newEntrypoint;
53
- };
54
41
  entrypointHandle.ref = _entrypoint;
55
42
  return _entrypoint;
56
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../src/entrypoint.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAA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,CAAA;QAClC,CAAC,CAAC,CAAA;QAEF,OAAO,QAAQ,CAAA;IACjB,CAAC,CAAQ,CAAA;IAET,WAAW,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC,gBAAgB,CAAC,CAAA;IAEjD,WAAW,CAAC,QAAQ,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAA;IAEjD,gBAAgB,CAAC,GAAG,GAAG,WAAW,CAAA;IAElC,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA;AAED,MAAM,qBAAqB,GAAG,CAC5B,IAAa,EAAE,OAAiD,EAChE,EAAE;IACF,IAAI,IAAI,KAAK,OAAO,CAAC,OAAO,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,WAAW,CAAC,iEAAiE,CAAC,CAAA;IAC1F,CAAC;AACH,CAAC,CAAA"}
@@ -0,0 +1,19 @@
1
+ import type { BasicContext, LazyService } from '@owlmeans/context';
2
+ import type { AbstractRequest } from '@owlmeans/entrypoint';
3
+ export declare const ENTRYPOINT_FAILURE_SERVICE = "client-entrypoint:failure";
4
+ export interface EntrypointFailure {
5
+ alias: string;
6
+ request: AbstractRequest;
7
+ error: unknown;
8
+ }
9
+ export interface EntrypointFailurePlugin {
10
+ alias: string;
11
+ onFailure: (failure: EntrypointFailure) => void | Promise<void>;
12
+ }
13
+ export interface EntrypointFailureService extends LazyService {
14
+ registerPlugin: (plugin: EntrypointFailurePlugin) => void;
15
+ notify: (failure: EntrypointFailure) => Promise<void>;
16
+ }
17
+ /** Context-local observers for rejected client calls; observers never replace the thrown error. */
18
+ export declare const ensureEntrypointFailureService: (ctx: BasicContext<any>) => EntrypointFailureService;
19
+ //# sourceMappingURL=failure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.d.ts","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAClE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,eAAO,MAAM,0BAA0B,8BAA8B,CAAA;AAErE,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,eAAe,CAAA;IACxB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChE;AAED,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,cAAc,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IACzD,MAAM,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;CACtD;AAED,mGAAmG;AACnG,eAAO,MAAM,8BAA8B,QAAS,YAAY,CAAC,GAAG,CAAC,KAAG,wBAiBvE,CAAA"}
@@ -0,0 +1,25 @@
1
+ import { createLazyService } from '@owlmeans/context';
2
+ export const ENTRYPOINT_FAILURE_SERVICE = 'client-entrypoint:failure';
3
+ /** Context-local observers for rejected client calls; observers never replace the thrown error. */
4
+ export const ensureEntrypointFailureService = (ctx) => {
5
+ if (ctx.hasService(ENTRYPOINT_FAILURE_SERVICE)) {
6
+ return ctx.service(ENTRYPOINT_FAILURE_SERVICE);
7
+ }
8
+ const plugins = new Map();
9
+ const service = createLazyService(ENTRYPOINT_FAILURE_SERVICE, {
10
+ registerPlugin: plugin => { plugins.set(plugin.alias, plugin); },
11
+ notify: async (failure) => {
12
+ for (const plugin of plugins.values()) {
13
+ try {
14
+ await plugin.onFailure(failure);
15
+ }
16
+ catch (cause) {
17
+ console.warn('Entrypoint failure observer failed', cause);
18
+ }
19
+ }
20
+ },
21
+ });
22
+ ctx.registerService(service);
23
+ return service;
24
+ };
25
+ //# sourceMappingURL=failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failure.js","sourceRoot":"","sources":["../src/failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAIrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,2BAA2B,CAAA;AAkBrE,mGAAmG;AACnG,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,GAAsB,EAA4B,EAAE;IACjG,IAAI,GAAG,CAAC,UAAU,CAAC,0BAA0B,CAAC,EAAE,CAAC;QAC/C,OAAO,GAAG,CAAC,OAAO,CAA2B,0BAA0B,CAAC,CAAA;IAC1E,CAAC;IACD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmC,CAAA;IAC1D,MAAM,OAAO,GAAG,iBAAiB,CAA2B,0BAA0B,EAAE;QACtF,cAAc,EAAE,MAAM,CAAC,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA,CAAC,CAAC;QAC/D,MAAM,EAAE,KAAK,EAAC,OAAO,EAAC,EAAE;YACtB,KAAK,MAAM,MAAM,IAAI,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACtC,IAAI,CAAC;oBAAC,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;gBAAC,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACrD,OAAO,CAAC,IAAI,CAAC,oCAAoC,EAAE,KAAK,CAAC,CAAA;gBAC3D,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAA;IACF,GAAG,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;IAC5B,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA"}
package/build/helper.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import type { ClientEntrypoint, ClientEntrypointOptions, RefedEntrypointHandler } from './types.js';
2
- import type { AbstractRequest, CommonEntrypoint } from '@owlmeans/entrypoint';
1
+ import type { RefedEntrypointHandler } from './types.js';
2
+ import type { AbstractRequest } from '@owlmeans/entrypoint';
3
3
  import type { JSONSchemaType } from "ajv";
4
- export declare const elevate: <T = {}, R extends AbstractRequest = AbstractRequest>(entrypoints: (CommonEntrypoint | ClientEntrypoint<T, R>)[], alias: string, handler?: RefedEntrypointHandler<T, R> | ClientEntrypointOptions | boolean, opts?: ClientEntrypointOptions | boolean) => ClientEntrypoint<T, R>[];
5
4
  export declare const stab: RefedEntrypointHandler<{}>;
6
5
  export declare const provideRequest: <T extends {} = {}>(alias: string, path: string) => AbstractRequest<T>;
7
6
  export declare const pickPerSchema: <T, R>(object: T, schema: JSONSchemaType<R>) => Partial<R>;
@@ -1 +1 @@
1
- {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AAGnG,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC,eAAO,MAAM,OAAO,GAAI,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,eAC5D,CAAC,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SACnD,MAAM,YACH,sBAAsB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,uBAAuB,GAAG,OAAO,SACnE,uBAAuB,GAAG,OAAO,KACvC,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,EAcxB,CAAA;AAED,eAAO,MAAM,IAAI,EAAE,sBAAsB,CAAC,EAAE,CAE3C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,MAAM,QAAQ,MAAM,KAAG,eAAe,CAAC,CAAC,CAYhG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,cAAc,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAQjF,CAAA"}
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AAEzC,eAAO,MAAM,IAAI,EAAE,sBAAsB,CAAC,EAAE,CAE3C,CAAA;AAED,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,MAAM,QAAQ,MAAM,KAAG,eAAe,CAAC,CAAC,CAYhG,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,cAAc,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,CAAC,CAQjF,CAAA"}
package/build/helper.js CHANGED
@@ -1,18 +1,3 @@
1
- import { entrypoint } from './entrypoint.js';
2
- import { isClientRouteModel } from '@owlmeans/client-route';
3
- import { normalizeHelperParams } from './utils/entrypoint.js';
4
- export const elevate = (entrypoints, alias, handler, opts) => {
5
- [handler, opts] = normalizeHelperParams(handler, opts);
6
- const idx = entrypoints.findIndex(({ route }) => route.route.alias === alias);
7
- if (idx === -1) {
8
- throw new SyntaxError(`Entrypoint with alias ${alias} not present`);
9
- }
10
- if (isClientRouteModel(entrypoints[idx].route) && opts?.force !== true) {
11
- throw new SyntaxError(`Entrypoint with alias ${alias} is already elevated`);
12
- }
13
- entrypoints[idx] = entrypoint(entrypoints[idx], handler, opts);
14
- return entrypoints;
15
- };
16
1
  export const stab = () => () => {
17
2
  return void 0;
18
3
  };
@@ -1 +1 @@
1
- {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],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,EAAE,GAAG,EAAE,EAAE;IACX,IAAI,MAAM,CAAC,GAAc,CAAC,IAAI,IAAI,EAAE,CAAC;QACnC,GAAG,CAAC,GAAc,CAAC,GAAG,MAAM,CAAC,GAAc,CAA0B,CAAA;IACvE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,EAAE,EAAgB,CACpB,CAAA"}
package/build/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './helper.js';
2
1
  export type * from './types.js';
3
- export * from './entrypoint.js';
4
2
  export * from './errors.js';
3
+ export * from './failure.js';
4
+ export * from './protocol.js';
5
+ export { pickPerSchema, provideRequest, stab } from './helper.js';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAC3B,mBAAmB,YAAY,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA"}
package/build/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export * from './helper.js';
2
- export * from './entrypoint.js';
3
1
  export * from './errors.js';
2
+ export * from './failure.js';
3
+ export * from './protocol.js';
4
+ export { pickPerSchema, provideRequest, stab } from './helper.js';
4
5
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,aAAa,CAAA;AAE3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,aAAa,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { EntrypointProtocolDeclaration, EntrypointTree } from '@owlmeans/entrypoint';
2
+ import type { ClientEntrypointOptions, ClientProtocolEntrypoint, RefedEntrypointHandler } from './types.js';
3
+ /** Bind a shared protocol to the client context without changing the declaration itself. */
4
+ export declare const bind: <Protocol extends EntrypointProtocolDeclaration>(protocol: Protocol, options?: ClientEntrypointOptions) => ClientProtocolEntrypoint<Protocol>;
5
+ /** Materialize every protocol in an exported declaration tree for a browser context. */
6
+ export declare const bindAll: (tree: EntrypointTree) => ClientProtocolEntrypoint<EntrypointProtocolDeclaration>[];
7
+ /** Bind a frontend protocol to the component that renders it. */
8
+ export declare const bindScreen: <Protocol extends EntrypointProtocolDeclaration>(protocol: Protocol, handler: RefedEntrypointHandler, options?: ClientEntrypointOptions) => ClientProtocolEntrypoint<Protocol>;
9
+ //# sourceMappingURL=protocol.d.ts.map