@owlmeans/client-entrypoint 0.1.20-rc.1 → 0.1.22-rc.0
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 +23 -6
- package/agent-meta/manifest.json +2 -2
- package/agent-meta/skills/client-entrypoint/SKILL.md +21 -3
- package/build/utils/entrypoint.d.ts.map +1 -1
- package/build/utils/entrypoint.js +6 -1
- package/build/utils/entrypoint.js.map +1 -1
- package/build/utils/handler.d.ts.map +1 -1
- package/build/utils/handler.js +6 -2
- package/build/utils/handler.js.map +1 -1
- package/package.json +12 -12
- package/src/utils/entrypoint.ts +6 -1
- package/src/utils/handler.ts +6 -2
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ re-exports of `@owlmeans/web-client` or `@owlmeans/web-panel`. Protocols are dec
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
12
12
|
```bash
|
|
13
|
-
bun add @owlmeans/client-entrypoint@^0.1.
|
|
13
|
+
bun add @owlmeans/client-entrypoint@^0.1.22-rc.0
|
|
14
14
|
```
|
|
15
15
|
|
|
16
16
|
## Concepts
|
|
@@ -29,7 +29,8 @@ bun add @owlmeans/client-entrypoint@^0.1.20-rc.1
|
|
|
29
29
|
the API client named by `cfg.webService` does — a string, or a map keyed by service name with a
|
|
30
30
|
default key. Callers never branch on it.
|
|
31
31
|
- **Call options** — a request holds only the contract's sections (`params`, `query`, `body`,
|
|
32
|
-
`headers`) plus `CallOptions`: `auth`, `host`, `base`, `unsecure`, `timeout
|
|
32
|
+
`headers`) plus `CallOptions`: `auth`, `host`, `base`, `unsecure`, `timeout`, `signal`,
|
|
33
|
+
`onUploadProgress` and `onDownloadProgress`.
|
|
33
34
|
|
|
34
35
|
## Usage
|
|
35
36
|
|
|
@@ -112,9 +113,25 @@ try {
|
|
|
112
113
|
```
|
|
113
114
|
|
|
114
115
|
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.
|
|
116
|
+
so `call({ params })` is enough. Never add `{ body: {} }` as a workaround. A streamed-body route
|
|
117
|
+
(`streamBody()` of `@owlmeans/route`) is the exception: its body is raw bytes, and an absent one
|
|
118
|
+
stays absent.
|
|
116
119
|
|
|
117
|
-
### 5.
|
|
120
|
+
### 5. Uploading to a streamed-body route
|
|
121
|
+
|
|
122
|
+
The body is a `Blob`/`File`, bytes or (in Bun/Node) a `Readable`, typed `BinaryBody` by the
|
|
123
|
+
contract; the progress listener gets `{ loaded, total?, progress?, bytes, rate?, estimated? }`.
|
|
124
|
+
`validateOnCall` validates `params`/`query` and skips the body.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const material = await ctx.entrypoint(apiProtocols.material.upload).call({
|
|
128
|
+
params: { id }, body: file,
|
|
129
|
+
onUploadProgress: ({ loaded, total }) => setProgress(total != null ? loaded / total : 0),
|
|
130
|
+
signal: controller.signal,
|
|
131
|
+
})
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 6. Narrowing a payload to a schema
|
|
118
135
|
|
|
119
136
|
`clientRequestHelper.pickPerSchema(object, schema)` keeps only the keys the AJV schema declares and skips `null` values.
|
|
120
137
|
It is useful when a form model carries more fields than the contract accepts.
|
|
@@ -168,7 +185,7 @@ await ctx.entrypoint(apiProtocols.project.update).call({ params: { id }, body })
|
|
|
168
185
|
| `apiCallOf(ref).apiInvoke(options?)` | helper member | The round trip behind `invoke()` |
|
|
169
186
|
| `apiCallOf(ref).apiHandler` | helper member | The handler that picks the transport service or the API client |
|
|
170
187
|
| `apiCallOf(ref).entrypointUrl(request?, options?)` | helper member | The address behind `url()` |
|
|
171
|
-
| `validate(ref)` | function | The filter behind `validate()` |
|
|
188
|
+
| `validate(ref)` | function | The filter behind `validate()`: every section with a schema, never `headers`, `response` or a streamed body |
|
|
172
189
|
| `isEntrypoint(value)` | function | Re-export from `@owlmeans/entrypoint/utils` |
|
|
173
190
|
|
|
174
191
|
## Common pitfalls
|
|
@@ -205,7 +222,7 @@ This package ships embedded agent skills under `agent-meta/`. After installing y
|
|
|
205
222
|
your project's skill store (`.agents/skills/`):
|
|
206
223
|
|
|
207
224
|
```sh
|
|
208
|
-
npx @owlmeans/agent-skills@^0.1.
|
|
225
|
+
npx @owlmeans/agent-skills@^0.1.22-rc.0
|
|
209
226
|
```
|
|
210
227
|
|
|
211
228
|
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": 3,
|
|
3
3
|
"package": "@owlmeans/client-entrypoint",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"generatedAt": "2026-11-
|
|
4
|
+
"version": "0.1.22-rc.0",
|
|
5
|
+
"generatedAt": "2026-11-11T20:57:15.685Z",
|
|
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/client-entrypoint
|
|
9
9
|
|
|
10
|
-
**Install:** `bun add @owlmeans/client-entrypoint@^0.1.
|
|
10
|
+
**Install:** `bun add @owlmeans/client-entrypoint@^0.1.22-rc.0`
|
|
11
11
|
|
|
12
12
|
Bind a declaration from `@owlmeans/entrypoint`; never construct or replace a contextual
|
|
13
13
|
entrypoint by alias.
|
|
@@ -43,8 +43,26 @@ not add an explicit result generic. `entrypointRef<Request, Response>(alias)` is
|
|
|
43
43
|
dynamic remote declaration that cannot be imported.
|
|
44
44
|
|
|
45
45
|
Client calls include only contract request sections plus `CallOptions` (`auth`, host/port/base,
|
|
46
|
-
timeout, signal). `url` accepts params/query plus the same
|
|
47
|
-
chosen by the declaration; callers do not branch for HTTP,
|
|
46
|
+
timeout, signal, `onUploadProgress`/`onDownloadProgress`). `url` accepts params/query plus the same
|
|
47
|
+
address options. The route transport is chosen by the declaration; callers do not branch for HTTP,
|
|
48
|
+
socket, or queue.
|
|
49
|
+
|
|
50
|
+
An upload goes to a streamed-body route (`streamBody()` of `@owlmeans/route`, served by
|
|
51
|
+
`streamedBody()` of `@owlmeans/server-api`). The body is a `BinaryBody` — a `Blob`/`File`, bytes,
|
|
52
|
+
or a Node `Readable` in Bun — sent as is (`/api`); in a browser and in Bun alike:
|
|
53
|
+
|
|
54
|
+
```ts
|
|
55
|
+
const material = await context.entrypoint(materialProtocols.upload).call({
|
|
56
|
+
params: { id }, body: file,
|
|
57
|
+
onUploadProgress: ({ loaded, total }) => setProgress(total != null ? loaded / total : 0),
|
|
58
|
+
timeout: 120_000, signal: controller.signal,
|
|
59
|
+
})
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- A streamed-body route gets no `{}` default body: an absent body stays absent.
|
|
63
|
+
- `validateOnCall` validates every section that HAS a schema (`params`, `query`, `body`) and skips a
|
|
64
|
+
streamed route's body; a section the contract left without a schema is never compiled.
|
|
65
|
+
- `authMiddleware` (`@owlmeans/auth-common`) still stamps the guard's token on such a call.
|
|
48
66
|
|
|
49
67
|
`ensureEntrypointFailureService(context)` returns the context-local failure plugin host. Register
|
|
50
68
|
an `onFailure` plugin there to observe a rejected remote `invoke`/`call`, show a toast, or collect
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"entrypoint.d.ts","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAKzD;;;GAGG;AACH,eAAO,MAAM,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,EAAE,GAAG,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,gBAqClG,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Ajv from 'ajv';
|
|
2
2
|
import { ClientValidationError } from '../errors.js';
|
|
3
3
|
import formatsPlugin from 'ajv-formats';
|
|
4
|
+
import { streamBodyOf } from '@owlmeans/route';
|
|
4
5
|
export { isEntrypoint } from '@owlmeans/entrypoint/utils';
|
|
5
6
|
const ajv = new Ajv({ strict: false });
|
|
6
7
|
formatsPlugin(ajv);
|
|
@@ -19,7 +20,11 @@ export const validate = (ref) => async (req) => {
|
|
|
19
20
|
if (ep.filter == null) {
|
|
20
21
|
throw new SyntaxError(`Entrypoint ${req.alias} has no filter to validate against`);
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
// A streamed-body route's body is raw bytes — there is nothing to validate against a schema.
|
|
24
|
+
const streamed = streamBodyOf(ep.route.route) != null;
|
|
25
|
+
const results = await Promise.all(Object.entries(ep.filter)
|
|
26
|
+
.filter(([key, filter]) => filter != null && !['headers', 'response'].includes(key)
|
|
27
|
+
&& !(streamed && key === 'body'))
|
|
23
28
|
.map(async ([key, filter]) => {
|
|
24
29
|
if (req[key] == null) {
|
|
25
30
|
throw new SyntaxError(`Request has no required section ${key}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"entrypoint.js","sourceRoot":"","sources":["../../src/utils/entrypoint.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,KAAK,CAAA;AAGrB,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAA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EA,OAAO,EAAE,KAAK,eAAe,EAAwG,MAAM,sBAAsB,CAAA;AACjK,OAAO,KAAK,EAAsC,oBAAoB,EAA2B,aAAa,EAAE,aAAa,EAA4B,MAAM,aAAa,CAAA;AAU5K,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,OACzE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,aAAa,CAAC,CAAC,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,eAAe,EAAwG,MAAM,sBAAsB,CAAA;AACjK,OAAO,KAAK,EAAsC,oBAAoB,EAA2B,aAAa,EAAE,aAAa,EAA4B,MAAM,aAAa,CAAA;AAU5K,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAIvD,eAAO,MAAM,iBAAiB,GAAI,CAAC,EAAE,CAAC,SAAS,eAAe,GAAG,eAAe,OACzE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KACvB,aAAa,CAAC,CAAC,EAAE,CAAC,CAgJpB,CAAA;AAED,eAAO,MAAM,SAAS,GApJY,CAAC,EAAE,CAAC,SAAS,eAAe,2EAoJA,CAAA;AAE9D,0FAA0F;AAC1F,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,SAAS,aAAa,GAAG,aAAa,OACjE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,QAAQ,OAAO,CAAC,CAAC,CAAC,SAAS,oBAAoB,KACtE,OAAO,CAAC,MAAM,CAAoD,CAAA"}
|
package/build/utils/handler.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DEFAULT_KEY } from '@owlmeans/client-config';
|
|
|
2
2
|
import { EntrypointOutcome, provideResponse, transportAlias } from '@owlmeans/entrypoint';
|
|
3
3
|
import { validate } from './entrypoint.js';
|
|
4
4
|
import { clientRouteHelper } from '@owlmeans/client-route';
|
|
5
|
-
import { PARAM, RouteMethod, RouteProtocols } from '@owlmeans/route';
|
|
5
|
+
import { PARAM, RouteMethod, RouteProtocols, streamBodyOf } from '@owlmeans/route';
|
|
6
6
|
import { stringify } from 'qs';
|
|
7
7
|
import { assertContext, memoHelper } from '@owlmeans/context';
|
|
8
8
|
import { makeSecurityHelper } from '@owlmeans/config';
|
|
@@ -49,13 +49,15 @@ export const makeApiCallHelper = (ref) => {
|
|
|
49
49
|
if (req?.canceled) {
|
|
50
50
|
return { value: null, outcome: EntrypointOutcome.Ok };
|
|
51
51
|
}
|
|
52
|
+
// A streamed-body route carries raw bytes, never a JSON default: an absent body stays absent.
|
|
53
|
+
const streamed = streamBodyOf(ep.route.route) != null;
|
|
52
54
|
const request = {
|
|
53
55
|
alias: ep.alias,
|
|
54
56
|
params: req?.params ?? {},
|
|
55
57
|
// JSON transports must send a body for mutation methods even when the contract has no
|
|
56
58
|
// payload. Keeping that rule here makes every typed caller use `call({ params })`, never
|
|
57
59
|
// an SDK-specific `{ body: {} }` workaround.
|
|
58
|
-
body: req?.body ?? ([RouteMethod.POST, RouteMethod.PUT, RouteMethod.PATCH]
|
|
60
|
+
body: req?.body ?? (!streamed && [RouteMethod.POST, RouteMethod.PUT, RouteMethod.PATCH]
|
|
59
61
|
.includes(ep.route.route.method ?? RouteMethod.GET) ? {} : undefined),
|
|
60
62
|
headers: req?.headers ?? {},
|
|
61
63
|
query: req?.query ?? {},
|
|
@@ -64,6 +66,8 @@ export const makeApiCallHelper = (ref) => {
|
|
|
64
66
|
path: ep.path(),
|
|
65
67
|
timeout: req?.timeout,
|
|
66
68
|
signal: req?.signal,
|
|
69
|
+
...(req?.onUploadProgress != null ? { onUploadProgress: req.onUploadProgress } : {}),
|
|
70
|
+
...(req?.onDownloadProgress != null ? { onDownloadProgress: req.onDownloadProgress } : {}),
|
|
67
71
|
};
|
|
68
72
|
if (req?.cancel != null) {
|
|
69
73
|
const cancel = req.cancel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAA0E,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEjK,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"handler.js","sourceRoot":"","sources":["../../src/utils/handler.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAA0E,iBAAiB,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAEjK,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,IAAI,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAItC,MAAM,GAAG,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAA;AAEvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAwB,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C,CAAA;IAED,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AACjD,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAE9D,0FAA0F;AAC1F,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAwB,EAAE,GAAgB,EAAE,IAA2B,EACtD,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,aAAa,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@owlmeans/client-entrypoint",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://owlmeans.com/docs/",
|
|
6
6
|
"repository": {
|
|
@@ -38,16 +38,16 @@
|
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@owlmeans/api": "^0.1.
|
|
42
|
-
"@owlmeans/client-config": "^0.1.
|
|
43
|
-
"@owlmeans/client-context": "^0.1.
|
|
44
|
-
"@owlmeans/client-route": "^0.1.
|
|
45
|
-
"@owlmeans/config": "^0.1.
|
|
46
|
-
"@owlmeans/context": "^0.1.
|
|
47
|
-
"@owlmeans/entrypoint": "^0.1.
|
|
48
|
-
"@owlmeans/error": "^0.1.
|
|
49
|
-
"@owlmeans/log": "^0.1.
|
|
50
|
-
"@owlmeans/route": "^0.1.
|
|
41
|
+
"@owlmeans/api": "^0.1.22-rc.0",
|
|
42
|
+
"@owlmeans/client-config": "^0.1.22-rc.0",
|
|
43
|
+
"@owlmeans/client-context": "^0.1.22-rc.0",
|
|
44
|
+
"@owlmeans/client-route": "^0.1.22-rc.0",
|
|
45
|
+
"@owlmeans/config": "^0.1.22-rc.0",
|
|
46
|
+
"@owlmeans/context": "^0.1.21",
|
|
47
|
+
"@owlmeans/entrypoint": "^0.1.22-rc.0",
|
|
48
|
+
"@owlmeans/error": "^0.1.21",
|
|
49
|
+
"@owlmeans/log": "^0.1.21",
|
|
50
|
+
"@owlmeans/route": "^0.1.22-rc.0",
|
|
51
51
|
"ajv-formats": "^3.0.1",
|
|
52
52
|
"qs": "^6.17.0"
|
|
53
53
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"ajv": "*"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@owlmeans/dep-config": "^0.1.
|
|
58
|
+
"@owlmeans/dep-config": "^0.1.21",
|
|
59
59
|
"@types/qs": "^6.15.1",
|
|
60
60
|
"nodemon": "^3.1.14",
|
|
61
61
|
"typescript": "^7.0.2"
|
package/src/utils/entrypoint.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ClientValidationError } from '../errors.js'
|
|
|
5
5
|
import type { AbstractRequest } from '@owlmeans/entrypoint'
|
|
6
6
|
import type { EntrypointRef } from '../types.js'
|
|
7
7
|
import formatsPlugin from 'ajv-formats'
|
|
8
|
+
import { streamBodyOf } from '@owlmeans/route'
|
|
8
9
|
|
|
9
10
|
export { isEntrypoint } from '@owlmeans/entrypoint/utils'
|
|
10
11
|
|
|
@@ -27,7 +28,11 @@ export const validate: <T, R extends AbstractRequest = AbstractRequest>(ref: Ent
|
|
|
27
28
|
if (ep.filter == null) {
|
|
28
29
|
throw new SyntaxError(`Entrypoint ${req.alias} has no filter to validate against`)
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
// A streamed-body route's body is raw bytes — there is nothing to validate against a schema.
|
|
32
|
+
const streamed = streamBodyOf(ep.route.route) != null
|
|
33
|
+
const results = await Promise.all(Object.entries(ep.filter)
|
|
34
|
+
.filter(([key, filter]) => filter != null && !['headers', 'response'].includes(key)
|
|
35
|
+
&& !(streamed && key === 'body'))
|
|
31
36
|
.map(async ([key, filter]) => {
|
|
32
37
|
if (req[key as keyof typeof req] == null) {
|
|
33
38
|
throw new SyntaxError(`Request has no required section ${key}`)
|
package/src/utils/handler.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { type AbstractRequest, type EntrypointHandler, type EntrypointTransport,
|
|
|
4
4
|
import type { ClientEntrypoint, EntrypointInvoke, EntrypointUrlOptions, ClientEntrypointOptions, EntrypointRef, ClientRequest, EntrypointFailureService } from '../types.js'
|
|
5
5
|
import { validate } from './entrypoint.js'
|
|
6
6
|
import { clientRouteHelper } from '@owlmeans/client-route'
|
|
7
|
-
import { PARAM, RouteMethod, RouteProtocols } from '@owlmeans/route'
|
|
7
|
+
import { PARAM, RouteMethod, RouteProtocols, streamBodyOf } from '@owlmeans/route'
|
|
8
8
|
import { stringify } from 'qs'
|
|
9
9
|
import { assertContext, memoHelper } from '@owlmeans/context'
|
|
10
10
|
import { makeSecurityHelper } from '@owlmeans/config'
|
|
@@ -70,13 +70,15 @@ export const makeApiCallHelper = <T, R extends AbstractRequest = AbstractRequest
|
|
|
70
70
|
return { value: null, outcome: EntrypointOutcome.Ok }
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
// A streamed-body route carries raw bytes, never a JSON default: an absent body stays absent.
|
|
74
|
+
const streamed = streamBodyOf(ep.route.route) != null
|
|
73
75
|
const request: AbstractRequest = {
|
|
74
76
|
alias: ep.alias,
|
|
75
77
|
params: req?.params ?? {},
|
|
76
78
|
// JSON transports must send a body for mutation methods even when the contract has no
|
|
77
79
|
// payload. Keeping that rule here makes every typed caller use `call({ params })`, never
|
|
78
80
|
// an SDK-specific `{ body: {} }` workaround.
|
|
79
|
-
body: req?.body ?? ([RouteMethod.POST, RouteMethod.PUT, RouteMethod.PATCH]
|
|
81
|
+
body: req?.body ?? (!streamed && [RouteMethod.POST, RouteMethod.PUT, RouteMethod.PATCH]
|
|
80
82
|
.includes(ep.route.route.method ?? RouteMethod.GET) ? {} : undefined),
|
|
81
83
|
headers: req?.headers ?? {},
|
|
82
84
|
query: req?.query ?? {},
|
|
@@ -85,6 +87,8 @@ export const makeApiCallHelper = <T, R extends AbstractRequest = AbstractRequest
|
|
|
85
87
|
path: ep.path(),
|
|
86
88
|
timeout: req?.timeout,
|
|
87
89
|
signal: req?.signal,
|
|
90
|
+
...(req?.onUploadProgress != null ? { onUploadProgress: req.onUploadProgress } : {}),
|
|
91
|
+
...(req?.onDownloadProgress != null ? { onDownloadProgress: req.onDownloadProgress } : {}),
|
|
88
92
|
}
|
|
89
93
|
if (req?.cancel != null) {
|
|
90
94
|
const cancel = req.cancel
|