ts-procedures 10.3.1 → 11.0.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/CHANGELOG.md +26 -0
- package/agent_config/skills/ts-procedures/api-reference.md +4 -4
- package/build/client/call.d.ts +2 -1
- package/build/client/call.js +20 -9
- package/build/client/call.js.map +1 -1
- package/build/client/call.test.js +72 -9
- package/build/client/call.test.js.map +1 -1
- package/build/client/errors.d.ts +0 -4
- package/build/client/errors.js +0 -2
- package/build/client/errors.js.map +1 -1
- package/build/client/errors.test.js +1 -16
- package/build/client/errors.test.js.map +1 -1
- package/build/client/freeze.test.js +22 -10
- package/build/client/freeze.test.js.map +1 -1
- package/build/client/index.d.ts +1 -1
- package/build/client/index.js +1 -1
- package/build/client/index.js.map +1 -1
- package/build/client/index.test.js +6 -6
- package/build/client/index.test.js.map +1 -1
- package/build/client/resolve-options.d.ts +1 -14
- package/build/client/resolve-options.js +0 -15
- package/build/client/resolve-options.js.map +1 -1
- package/build/client/resolve-options.test.js +1 -63
- package/build/client/resolve-options.test.js.map +1 -1
- package/build/client/stream.test.js +3 -3
- package/build/client/stream.test.js.map +1 -1
- package/build/client/typed-error-dispatch.test.js +2 -2
- package/build/client/typed-error-dispatch.test.js.map +1 -1
- package/build/codegen/e2e.test.js +2 -2
- package/build/codegen/e2e.test.js.map +1 -1
- package/build/codegen/emit-client-runtime.test.js +3 -3
- package/build/codegen/emit-client-runtime.test.js.map +1 -1
- package/build/codegen/emit-index.js +17 -0
- package/build/codegen/emit-index.js.map +1 -1
- package/build/codegen/goldens.test.js +18 -0
- package/build/codegen/goldens.test.js.map +1 -1
- package/build/exports.d.ts +1 -1
- package/build/schema/json-schema.d.ts +0 -2
- package/docs/client-and-codegen.md +2 -2
- package/docs/client-error-handling.md +3 -3
- package/docs/core.md +1 -2
- package/docs/migration-v8-to-v9.md +2 -2
- package/package.json +1 -1
- package/src/client/call.test.ts +80 -8
- package/src/client/call.ts +23 -9
- package/src/client/errors.test.ts +0 -18
- package/src/client/errors.ts +0 -7
- package/src/client/freeze.test.ts +22 -10
- package/src/client/index.test.ts +6 -6
- package/src/client/index.ts +0 -1
- package/src/client/resolve-options.test.ts +0 -73
- package/src/client/resolve-options.ts +1 -20
- package/src/client/stream.test.ts +3 -3
- package/src/client/typed-error-dispatch.test.ts +2 -2
- package/src/codegen/__goldens__/ts-default--models/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-default--models/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-default--models/index.ts +10 -0
- package/src/codegen/__goldens__/ts-default--users/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-default--users/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-default--users/index.ts +10 -0
- package/src/codegen/__goldens__/ts-external-runtime--models/index.ts +10 -0
- package/src/codegen/__goldens__/ts-external-runtime--users/index.ts +10 -0
- package/src/codegen/__goldens__/ts-flat--models/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-flat--models/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-flat--models/index.ts +10 -0
- package/src/codegen/__goldens__/ts-flat--users/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-flat--users/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-flat--users/index.ts +10 -0
- package/src/codegen/__goldens__/ts-no-share-models--models/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-no-share-models--models/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-no-share-models--models/index.ts +10 -0
- package/src/codegen/__goldens__/ts-no-share-models--users/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-no-share-models--users/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-no-share-models--users/index.ts +10 -0
- package/src/codegen/__goldens__/ts-shared-models-module--models/_client.ts +24 -36
- package/src/codegen/__goldens__/ts-shared-models-module--models/_types.ts +0 -7
- package/src/codegen/__goldens__/ts-shared-models-module--models/index.ts +10 -0
- package/src/codegen/e2e.test.ts +2 -2
- package/src/codegen/emit-client-runtime.test.ts +3 -3
- package/src/codegen/emit-index.ts +19 -0
- package/src/codegen/goldens.test.ts +18 -0
- package/src/exports.ts +1 -1
- package/src/schema/json-schema.ts +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-client-runtime.test.js","sourceRoot":"","sources":["../../src/codegen/emit-client-runtime.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAA;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,EAAE,CAAC,kBAAkB,EAAE,KAAK,IAAI,EAAE;QAChC,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,iBAAiB,CAAC,CAAA;QAC3C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAA;QACjD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAA;IAC7D,CAAC,C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F,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;QAC1D,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,mCAAmC,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,8CAA8C,EAAE,KAAK,IAAI,EAAE;QAC5D,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAA;IAC/D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,sEAAsE,EAAE,KAAK,IAAI,EAAE;QACpF,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,+BAA+B,CAAC,CAAA;IAC7D,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,4DAA4D,EAAE,KAAK,IAAI,EAAE;QAC1E,MAAM,MAAM,GAAG,MAAM,qBAAqB,EAAE,CAAA;QAC5C,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -55,12 +55,29 @@ export function emitIndexFile(groups, options) {
|
|
|
55
55
|
return ` ${g.camelCase}: ${bindCall},`;
|
|
56
56
|
})
|
|
57
57
|
.join('\n');
|
|
58
|
+
// Re-export the client error classes so consumers can `instanceof`-narrow
|
|
59
|
+
// failures (e.g. in an `onError` hook) straight from the package index,
|
|
60
|
+
// without reaching into `./_client`. Sourced from the runtime import path so
|
|
61
|
+
// it resolves in both self-contained (`./_client`) and external-runtime
|
|
62
|
+
// (`ts-procedures/client`) modes. Unconditional: even a service with no typed
|
|
63
|
+
// errors throws `ClientHttpError`.
|
|
64
|
+
const errorClassReExport = `export {\n` +
|
|
65
|
+
` ClientHttpError,\n` +
|
|
66
|
+
` ClientPathParamError,\n` +
|
|
67
|
+
` ClientStreamError,\n` +
|
|
68
|
+
` ClientNetworkError,\n` +
|
|
69
|
+
` ClientTimeoutError,\n` +
|
|
70
|
+
` ClientAbortError,\n` +
|
|
71
|
+
` ClientParseError,\n` +
|
|
72
|
+
`} from '${clientRuntimeImportPath}'`;
|
|
58
73
|
const pieces = [
|
|
59
74
|
CODEGEN_HEADER,
|
|
60
75
|
`import { createClient } from '${clientRuntimeImportPath}'`,
|
|
61
76
|
`import type { ClientInstance, CreateClientConfig } from '${clientImportPath}'`,
|
|
62
77
|
importsBlock,
|
|
63
78
|
'',
|
|
79
|
+
errorClassReExport,
|
|
80
|
+
'',
|
|
64
81
|
namespaceBlock,
|
|
65
82
|
`export function ${factoryName}(client: ClientInstance) {`,
|
|
66
83
|
' return {',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-index.js","sourceRoot":"","sources":["../../src/codegen/emit-index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE1C,MAAM,mBAAmB,GAAG,eAAe,CAAA;AAoB3C;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,MAAoB,EAAE,OAA0B;IAC5E,MAAM,EACJ,gBAAgB,GAAG,sBAAsB,EACzC,SAAS,GAAG,KAAK,EACjB,cAAc,GAAG,KAAK,EACtB,WAAW,GAAG,KAAK,GACpB,GAAG,OAAO,IAAI,EAAE,CAAA;IACjB,MAAM,uBAAuB,GA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,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QACvB,6BAA6B,CAAC,CAAC,SAAS,yEAAyE;QACjH,eAAe,YAAY,CAAC,CAAC,CAAC,SAAS,CAAC,YAAY,mBAAmB,KAAK,CAAC,CAAC,SAAS,IAAI;KAC5F,CAAC,EACF,EAAE,CACH,CAAA;IAED,4EAA4E;IAC5E,4EAA4E;IAC5E,uEAAuE;IACvE,iBAAiB;IACjB,IAAI,SAAS,EAAE,CAAC;QACd,wEAAwE;QACxE,kDAAkD;QAClD,MAAM,YAAY,GAAG,cAAc;YACjC,CAAC,CAAC,GAAG,mBAAmB,IAAI,kBAAkB,IAAI,YAAY,EAAE;YAChE,CAAC,CAAC,GAAG,mBAAmB,IAAI,YAAY,EAAE,CAAA;QAE5C,MAAM,CAAC,IAAI,CACT,KAAK,EACL,qEAAqE,EACrE,2EAA2E,EAC3E,sEAAsE,EACtE,kCAAkC,EAClC,KAAK,EACL,mBAAmB,iBAAiB,GAAG,EACvC,uDAAuD,WAAW,iCAAiC,EACnG,KAAK,EACL,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,YAAY,GAAG,EACrC,2BAA2B,WAAW,WAAW,EACjD,MAAM,EACN,GAAG,EACH,EAAE,CACH,CAAA;IACH,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CACT,KAAK,EACL,kEAAkE,EAClE,gEAAgE,EAChE,KAAK,EACL,mBAAmB,iBAAiB,GAAG,EACvC,uDAAuD,WAAW,eAAe,EACjF,KAAK,EACL,yBAAyB,EACzB,gBAAgB,EAChB,2BAA2B,WAAW,WAAW,EACjD,MAAM,EACN,GAAG,EACH,EAAE,CACH,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
|
|
1
|
+
{"version":3,"file":"emit-index.js","sourceRoot":"","sources":["../../src/codegen/emit-index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,g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GAAG,EACvC,uDAAuD,WAAW,iCAAiC,EACnG,KAAK,EACL,yBAAyB,EACzB,gBAAgB,EAChB,sBAAsB,YAAY,GAAG,EACrC,2BAA2B,WAAW,WAAW,EACjD,MAAM,EACN,GAAG,EACH,EAAE,CACH,CAAA;IACH,CAAC;SAAM,CAAC;QACN,MAAM,CAAC,IAAI,CACT,KAAK,EACL,kEAAkE,EAClE,gEAAgE,EAChE,KAAK,EACL,mBAAmB,iBAAiB,GAAG,EACvC,uDAAuD,WAAW,eAAe,EACjF,KAAK,EACL,yBAAyB,EACzB,gBAAgB,EAChB,2BAA2B,WAAW,WAAW,EACjD,MAAM,EACN,GAAG,EACH,EAAE,CACH,CAAA;IACH,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC1B,CAAC"}
|
|
@@ -21,6 +21,24 @@ import { resolveProductionSwiftEmitter } from './targets/swift/ajsc-adapter.js';
|
|
|
21
21
|
* because the header intentionally records the producing version. Everything
|
|
22
22
|
* else — including the envelope-hash line — must match exactly (both sides
|
|
23
23
|
* hash the same fixture envelopes).
|
|
24
|
+
*
|
|
25
|
+
* DOCUMENTED DEVIATIONS from v8.6.0 (intentional bug fixes / major-version
|
|
26
|
+
* removals; the affected golden files were surgically updated, NOT
|
|
27
|
+
* full-recaptured):
|
|
28
|
+
* 1. Bundled client runtime (`_client.ts`, self-contained TS cases only):
|
|
29
|
+
* `executeCall` now fires `onError` on non-2xx HTTP responses (401/403/5xx),
|
|
30
|
+
* not just on adapter throws. v8.6.0 skipped the hook here despite its
|
|
31
|
+
* docstring claiming otherwise. See `src/client/call.ts`.
|
|
32
|
+
* 2. Bundled client runtime (`_client.ts`, self-contained TS cases only), v11
|
|
33
|
+
* major: removed the deprecated `ClientRequestError` alias (`errors.ts`)
|
|
34
|
+
* and the deprecated internal `resolveSignal` helper (`resolve-options.ts`,
|
|
35
|
+
* superseded by `resolveSignalSources`).
|
|
36
|
+
* 3. Generated `index.ts` (ALL TS cases, incl. external-runtime), v11 major:
|
|
37
|
+
* now re-exports the client error classes (`ClientHttpError`, …) so
|
|
38
|
+
* consumers can `instanceof`-narrow failures straight from the package
|
|
39
|
+
* index. See `emit-index.ts`.
|
|
40
|
+
* See the matching notes in `src/client/freeze.test.ts`.
|
|
41
|
+
* Kotlin/Swift goldens are unaffected by all of the above.
|
|
24
42
|
*/
|
|
25
43
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
26
44
|
const fixturesDir = resolve(here, '__fixtures__');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"goldens.test.js","sourceRoot":"","sources":["../../src/codegen/goldens.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAA;AAE/E
|
|
1
|
+
{"version":3,"file":"goldens.test.js","sourceRoot":"","sources":["../../src/codegen/goldens.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAA;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,E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W,CAAC,CAAA;gBAEzF,KAAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;oBAC/B,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;oBACpE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,CAAC,CAAA;oBAC7D,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,KAAK,YAAY,IAAI,IAAI,EAAE,CAAC,CAAC,IAAI,CACzE,gBAAgB,CAAC,MAAM,CAAC,CACzB,CAAA;gBACH,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC,CAAC,CAAA"}
|
package/build/exports.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export { computeSchema } from './schema/compute-schema.js';
|
|
|
25
25
|
export type { ComputedSchema } from './schema/compute-schema.js';
|
|
26
26
|
export { createValidatorCompiler, DEFAULT_AJV_OPTIONS } from './schema/compile.js';
|
|
27
27
|
export type { Validate, ValidatorCompiler, ValidationOptions, TSchemaValidationError, } from './schema/compile.js';
|
|
28
|
-
export type { Infer,
|
|
28
|
+
export type { Infer, TJSONSchema, Prettify } from './schema/json-schema.js';
|
|
29
29
|
export { writeDocEnvelope } from './server/doc-envelope.js';
|
|
30
30
|
export type { DocEnvelopeSource } from './server/doc-envelope.js';
|
|
31
31
|
export type { DocEnvelope } from './server/types.js';
|
|
@@ -13,5 +13,3 @@ export type Prettify<TObject> = {
|
|
|
13
13
|
* provided for TypeBox (other schemas infer as `unknown`).
|
|
14
14
|
*/
|
|
15
15
|
export type Infer<SchemaType> = SchemaType extends TSchema ? Static<SchemaType> : unknown;
|
|
16
|
-
/** v8-compatible alias for {@link Infer}. */
|
|
17
|
-
export type TSchemaLib<SchemaType> = Infer<SchemaType>;
|
|
@@ -641,7 +641,7 @@ import {
|
|
|
641
641
|
dispatchTypedError,
|
|
642
642
|
defaultClassifyError,
|
|
643
643
|
// Error classes (7.0+)
|
|
644
|
-
ClientHttpError, // non-2xx HTTP response
|
|
644
|
+
ClientHttpError, // non-2xx HTTP response
|
|
645
645
|
ClientNetworkError, // network-level failure (e.g., fetch TypeError)
|
|
646
646
|
ClientTimeoutError, // request timed out via AbortSignal.timeout
|
|
647
647
|
ClientAbortError, // request aborted by caller signal
|
|
@@ -673,4 +673,4 @@ import type {
|
|
|
673
673
|
import { generateClient } from 'ts-procedures/codegen'
|
|
674
674
|
```
|
|
675
675
|
|
|
676
|
-
> **Migration note:** `ClientRequestError` was renamed to `ClientHttpError` in 7.0.0. The
|
|
676
|
+
> **Migration note:** `ClientRequestError` was renamed to `ClientHttpError` in 7.0.0; the deprecated alias was removed in 11.0.0. Update imports to `ClientHttpError`. The generated `index.ts` now also re-exports these error classes, so you can import them from your generated client's index instead of `ts-procedures/client`.
|
|
@@ -45,7 +45,7 @@ All framework error classes are exported from `ts-procedures/client` (or from `.
|
|
|
45
45
|
|
|
46
46
|
Every class carries `cause` to surface the underlying platform error — typically a `TypeError` or `DOMException` — when one exists.
|
|
47
47
|
|
|
48
|
-
`ClientRequestError`
|
|
48
|
+
`ClientRequestError` (the pre-7.0.0 name for `ClientHttpError`) was removed in 11.0.0. Use `ClientHttpError`.
|
|
49
49
|
|
|
50
50
|
---
|
|
51
51
|
|
|
@@ -308,9 +308,9 @@ Three breaking changes in 7.0.0 affect error handling.
|
|
|
308
308
|
|
|
309
309
|
### 8a. `ClientRequestError` Renamed to `ClientHttpError`
|
|
310
310
|
|
|
311
|
-
`ClientRequestError`
|
|
311
|
+
`ClientRequestError` was renamed to `ClientHttpError` in 7.0.0; the deprecated alias was removed in 11.0.0.
|
|
312
312
|
|
|
313
|
-
**Action**: rename your imports
|
|
313
|
+
**Action**: rename your imports and `instanceof` guards from `ClientRequestError` to `ClientHttpError`.
|
|
314
314
|
|
|
315
315
|
```ts
|
|
316
316
|
// Before
|
package/docs/core.md
CHANGED
|
@@ -577,8 +577,7 @@ import type {
|
|
|
577
577
|
ValidationOptions,
|
|
578
578
|
Validate,
|
|
579
579
|
ValidatorCompiler,
|
|
580
|
-
Infer, //
|
|
581
|
-
TSchemaLib, // alias for Infer (kept for compatibility)
|
|
580
|
+
Infer, // inference type (TypeBox-only)
|
|
582
581
|
TJSONSchema,
|
|
583
582
|
TSchemaValidationError,
|
|
584
583
|
Prettify,
|
|
@@ -32,7 +32,7 @@ Server-side and tooling APIs have breaking changes, listed exhaustively below.
|
|
|
32
32
|
| `import { HonoAppBuilder } from 'ts-procedures/hono'` | unchanged |
|
|
33
33
|
| `TStreamProcedureRegistration.isStream` | Removed — branch on `kind: 'rpc-stream'` |
|
|
34
34
|
| Duplicate-name registration threw `Error` | Throws `ProcedureRegistrationError` (same message) |
|
|
35
|
-
| `TSchemaLib<T>` |
|
|
35
|
+
| `TSchemaLib<T>` | Use `Infer<T>` — `TSchemaLib` was a compat alias, removed in 11.0.0 |
|
|
36
36
|
| `extractJsonSchema(schema)` | `extractJsonSchema(schema, adapters)` — or just use the factory |
|
|
37
37
|
| `schemaParser(...)` | Removed — `computeSchema(name, schema, { adapters, compile })` |
|
|
38
38
|
| `isSuretypeSchema` | Removed |
|
|
@@ -204,5 +204,5 @@ Unchanged (`createAstroHandler`, `getAstroContext` from `ts-procedures/astro`).
|
|
|
204
204
|
- `Procedures({ validation: { ajv } })` — per-factory AJV configuration.
|
|
205
205
|
- `Procedures({ schema: { adapters } })` — pluggable schema libraries.
|
|
206
206
|
- `ts-procedures/server` — the adapter toolkit described above.
|
|
207
|
-
- `Infer<T>` as the primary inference type (alias `TSchemaLib`
|
|
207
|
+
- `Infer<T>` as the primary inference type (compat alias `TSchemaLib` removed in 11.0.0).
|
|
208
208
|
- `ProcedureError.kind` discriminant.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-procedures",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "A TypeScript RPC framework that creates type-safe, schema-validated procedure calls with a single function definition. Define your procedures once and get full type inference, runtime validation, and framework integration hooks.",
|
|
5
5
|
"main": "build/exports.js",
|
|
6
6
|
"types": "build/exports.d.ts",
|
package/src/client/call.test.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest'
|
|
2
2
|
import { executeCall } from './call.js'
|
|
3
3
|
import {
|
|
4
|
-
ClientRequestError,
|
|
5
4
|
ClientNetworkError,
|
|
6
5
|
ClientTimeoutError,
|
|
7
6
|
ClientAbortError,
|
|
@@ -15,6 +14,7 @@ import type {
|
|
|
15
14
|
CallDescriptor,
|
|
16
15
|
ProcedureCallDefaults,
|
|
17
16
|
ProcedureCallOptions,
|
|
17
|
+
ErrorRegistry,
|
|
18
18
|
} from './types.js'
|
|
19
19
|
|
|
20
20
|
// ── helpers ───────────────────────────────────────────────
|
|
@@ -52,6 +52,7 @@ interface RunConfig {
|
|
|
52
52
|
options?: ProcedureCallOptions
|
|
53
53
|
descriptor?: CallDescriptor
|
|
54
54
|
basePath?: string
|
|
55
|
+
errorRegistry?: ErrorRegistry
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
function run<T>({
|
|
@@ -61,8 +62,9 @@ function run<T>({
|
|
|
61
62
|
options,
|
|
62
63
|
descriptor = makeDescriptor(),
|
|
63
64
|
basePath = 'https://api.example.com',
|
|
65
|
+
errorRegistry,
|
|
64
66
|
}: RunConfig): Promise<T> {
|
|
65
|
-
return executeCall<T>({ descriptor, basePath, adapter, hooks, defaults, options })
|
|
67
|
+
return executeCall<T>({ descriptor, basePath, adapter, hooks, defaults, options, errorRegistry })
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
// ── executeCall ───────────────────────────────────────────
|
|
@@ -75,19 +77,19 @@ describe('executeCall', () => {
|
|
|
75
77
|
expect(result).toEqual({ id: '1', name: 'Bob' })
|
|
76
78
|
})
|
|
77
79
|
|
|
78
|
-
it('throws
|
|
80
|
+
it('throws ClientHttpError on 4xx response', async () => {
|
|
79
81
|
const adapter = makeAdapter({ status: 404, body: { message: 'Not Found' } })
|
|
80
|
-
await expect(run({ adapter })).rejects.toThrow(
|
|
82
|
+
await expect(run({ adapter })).rejects.toThrow(ClientHttpError)
|
|
81
83
|
})
|
|
82
84
|
|
|
83
|
-
it('throws
|
|
85
|
+
it('throws ClientHttpError on 5xx response', async () => {
|
|
84
86
|
const adapter = makeAdapter({ status: 500, body: { message: 'Server Error' } })
|
|
85
|
-
await expect(run({ adapter })).rejects.toThrow(
|
|
87
|
+
await expect(run({ adapter })).rejects.toThrow(ClientHttpError)
|
|
86
88
|
})
|
|
87
89
|
|
|
88
|
-
it('throws
|
|
90
|
+
it('throws ClientHttpError on 199 response (below 200)', async () => {
|
|
89
91
|
const adapter = makeAdapter({ status: 199, body: null })
|
|
90
|
-
await expect(run({ adapter })).rejects.toThrow(
|
|
92
|
+
await expect(run({ adapter })).rejects.toThrow(ClientHttpError)
|
|
91
93
|
})
|
|
92
94
|
|
|
93
95
|
it('does not throw on 2xx boundary responses (200, 201, 299)', async () => {
|
|
@@ -164,6 +166,76 @@ describe('executeCall', () => {
|
|
|
164
166
|
expect(receivedErrors[0]).toBe(adapterError)
|
|
165
167
|
})
|
|
166
168
|
|
|
169
|
+
// ── onError on non-2xx HTTP responses (401, etc.) ──
|
|
170
|
+
// Regression: `fetch` resolves non-2xx responses instead of throwing, so the
|
|
171
|
+
// adapter never enters the throw path. `onError` must still fire on the
|
|
172
|
+
// status-check failure, otherwise a 401 silently skips the error hook.
|
|
173
|
+
|
|
174
|
+
it('runs onError on a non-2xx (401) response with the ClientHttpError', async () => {
|
|
175
|
+
const adapter = makeAdapter({ status: 401, body: { message: 'Unauthorized' } })
|
|
176
|
+
const receivedErrors: unknown[] = []
|
|
177
|
+
const hooks: ClientHooks = {
|
|
178
|
+
onError: (ctx) => { receivedErrors.push(ctx.error) },
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
await expect(run({ adapter, hooks })).rejects.toBeInstanceOf(ClientHttpError)
|
|
182
|
+
expect(receivedErrors).toHaveLength(1)
|
|
183
|
+
expect(receivedErrors[0]).toBeInstanceOf(ClientHttpError)
|
|
184
|
+
expect((receivedErrors[0] as ClientHttpError).status).toBe(401)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('runs onAfterResponse then onError on a non-2xx response', async () => {
|
|
188
|
+
const adapter = makeAdapter({ status: 401, body: { message: 'Unauthorized' } })
|
|
189
|
+
const order: string[] = []
|
|
190
|
+
const hooks: ClientHooks = {
|
|
191
|
+
onAfterResponse: () => { order.push('after') },
|
|
192
|
+
onError: () => { order.push('error') },
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
await expect(run({ adapter, hooks })).rejects.toBeInstanceOf(ClientHttpError)
|
|
196
|
+
expect(order).toEqual(['after', 'error'])
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
it('runs both global and local onError on a non-2xx response', async () => {
|
|
200
|
+
const adapter = makeAdapter({ status: 403, body: { message: 'Forbidden' } })
|
|
201
|
+
const order: string[] = []
|
|
202
|
+
const hooks: ClientHooks = { onError: () => { order.push('global') } }
|
|
203
|
+
const options: ProcedureCallOptions = { onError: () => { order.push('local') } }
|
|
204
|
+
|
|
205
|
+
await expect(run({ adapter, hooks, options })).rejects.toBeInstanceOf(ClientHttpError)
|
|
206
|
+
expect(order).toEqual(['global', 'local'])
|
|
207
|
+
})
|
|
208
|
+
|
|
209
|
+
it('does NOT run onError when onAfterResponse swallows non-2xx by mutating status', async () => {
|
|
210
|
+
const adapter = makeAdapter({ status: 401, body: { message: 'Unauthorized' } })
|
|
211
|
+
const receivedErrors: unknown[] = []
|
|
212
|
+
const hooks: ClientHooks = {
|
|
213
|
+
onAfterResponse: (ctx) => { ctx.response.status = 200 },
|
|
214
|
+
onError: (ctx) => { receivedErrors.push(ctx.error) },
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
await expect(run({ adapter, hooks })).resolves.not.toThrow()
|
|
218
|
+
expect(receivedErrors).toHaveLength(0)
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it('runs onError with the typed registry error on a non-2xx response', async () => {
|
|
222
|
+
class UnauthorizedError extends Error {
|
|
223
|
+
readonly name = 'UnauthorizedError'
|
|
224
|
+
constructor(readonly body: unknown) { super('unauthorized') }
|
|
225
|
+
}
|
|
226
|
+
const errorRegistry: ErrorRegistry = {
|
|
227
|
+
Unauthorized: { fromResponse: (body) => new UnauthorizedError(body) },
|
|
228
|
+
}
|
|
229
|
+
const adapter = makeAdapter({ status: 401, body: { name: 'Unauthorized', message: 'nope' } })
|
|
230
|
+
const receivedErrors: unknown[] = []
|
|
231
|
+
const hooks: ClientHooks = {
|
|
232
|
+
onError: (ctx) => { receivedErrors.push(ctx.error) },
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
await expect(run({ adapter, hooks, errorRegistry })).rejects.toBeInstanceOf(UnauthorizedError)
|
|
236
|
+
expect(receivedErrors[0]).toBeInstanceOf(UnauthorizedError)
|
|
237
|
+
})
|
|
238
|
+
|
|
167
239
|
it('passes per-procedure hooks as local options', async () => {
|
|
168
240
|
const adapter = makeAdapter()
|
|
169
241
|
const localOrder: string[] = []
|
package/src/client/call.ts
CHANGED
|
@@ -117,19 +117,32 @@ export async function executeCall<TResponse>(config: ExecuteCallConfig): Promise
|
|
|
117
117
|
procedureName: descriptor.name,
|
|
118
118
|
scope: descriptor.scope,
|
|
119
119
|
})
|
|
120
|
+
let httpError: Error
|
|
120
121
|
if (typed) {
|
|
121
122
|
// Tag so executeSafeCall can distinguish typed registry errors from plain
|
|
122
123
|
// ClientHttpError without re-inspecting the registry.
|
|
123
124
|
;(typed as unknown as { __tsProceduresTyped?: boolean }).__tsProceduresTyped = true
|
|
124
|
-
|
|
125
|
+
httpError = typed
|
|
126
|
+
} else {
|
|
127
|
+
httpError = new ClientHttpError({
|
|
128
|
+
status: response.status,
|
|
129
|
+
headers: response.headers,
|
|
130
|
+
body: response.body,
|
|
131
|
+
procedureName: descriptor.name,
|
|
132
|
+
scope: descriptor.scope,
|
|
133
|
+
})
|
|
125
134
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
// A non-2xx response is not a thrown adapter error (fetch resolves it), so
|
|
136
|
+
// it bypasses the catch block above. Fire onError here too so the hook is a
|
|
137
|
+
// uniform cross-cutting failure signal across adapter throws AND HTTP error
|
|
138
|
+
// statuses (401/403/5xx). Runs after onAfterResponse, which had its chance
|
|
139
|
+
// to swallow the error by mutating status back into the 2xx range.
|
|
140
|
+
await runOnError(
|
|
141
|
+
{ procedureName: descriptor.name, scope: descriptor.scope, request, error: httpError },
|
|
142
|
+
hooks,
|
|
143
|
+
options,
|
|
144
|
+
)
|
|
145
|
+
throw httpError
|
|
133
146
|
}
|
|
134
147
|
|
|
135
148
|
// 8. Return the body (or { body, headers } when the route declares res.headers)
|
|
@@ -147,7 +160,8 @@ export async function executeCall<TResponse>(config: ExecuteCallConfig): Promise
|
|
|
147
160
|
* 2. Adapter throw, classified → `kind: 'network' | 'timeout' | 'aborted' | <custom> | 'unknown'`
|
|
148
161
|
* 3. Adapter returns non-2xx → `kind: 'typed'` (registry match) or `kind: 'http'`
|
|
149
162
|
*
|
|
150
|
-
* `onError` hook fires on path 2 and 3 (cross-cutting telemetry)
|
|
163
|
+
* `onError` hook fires on path 2 and 3 (cross-cutting telemetry) — including
|
|
164
|
+
* plain non-2xx `ClientHttpError` and typed registry errors — but NOT on
|
|
151
165
|
* path 1 (usage errors bypass the classifier and onError entirely).
|
|
152
166
|
*/
|
|
153
167
|
export async function executeSafeCall<TResponse, ETyped = never>(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest'
|
|
2
2
|
import {
|
|
3
3
|
ClientHttpError,
|
|
4
|
-
ClientRequestError,
|
|
5
4
|
ClientPathParamError,
|
|
6
5
|
ClientStreamError,
|
|
7
6
|
ClientNetworkError,
|
|
@@ -52,23 +51,6 @@ describe('ClientHttpError', () => {
|
|
|
52
51
|
})
|
|
53
52
|
})
|
|
54
53
|
|
|
55
|
-
describe('ClientRequestError deprecated alias', () => {
|
|
56
|
-
it('is identical to ClientHttpError', () => {
|
|
57
|
-
expect(ClientRequestError).toBe(ClientHttpError)
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('instanceof check works against thrown ClientHttpError', () => {
|
|
61
|
-
// Consumers on the previous major used `catch (e) { if (e instanceof
|
|
62
|
-
// ClientRequestError) ... }`. The alias must keep that pattern working
|
|
63
|
-
// until the alias is removed in the next minor cycle's deprecation window.
|
|
64
|
-
const err = new ClientHttpError({
|
|
65
|
-
status: 500, headers: {}, body: null,
|
|
66
|
-
procedureName: 'X', scope: 'y',
|
|
67
|
-
})
|
|
68
|
-
expect(err instanceof ClientRequestError).toBe(true)
|
|
69
|
-
})
|
|
70
|
-
})
|
|
71
|
-
|
|
72
54
|
describe('ClientPathParamError', () => {
|
|
73
55
|
it('reports missing param', () => {
|
|
74
56
|
const err = new ClientPathParamError('id', '/users/:id', 'GetUser')
|
package/src/client/errors.ts
CHANGED
|
@@ -26,13 +26,6 @@ export class ClientHttpError extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
/** @deprecated Renamed to `ClientHttpError`. The alias is retained for one minor release after the 7.0.0 major bump and will be removed in a subsequent minor (e.g. 7.1.0). Migrate to `ClientHttpError` now. */
|
|
30
|
-
|
|
31
|
-
export const ClientRequestError = ClientHttpError
|
|
32
|
-
/** @deprecated Renamed to `ClientHttpError`. The alias is retained for one minor release after the 7.0.0 major bump and will be removed in a subsequent minor (e.g. 7.1.0). Migrate to `ClientHttpError` now. */
|
|
33
|
-
// eslint-disable-next-line no-redeclare
|
|
34
|
-
export type ClientRequestError = ClientHttpError
|
|
35
|
-
|
|
36
29
|
export class ClientPathParamError extends Error {
|
|
37
30
|
readonly name = 'ClientPathParamError'
|
|
38
31
|
|
|
@@ -5,28 +5,40 @@ import { fileURLToPath } from 'node:url'
|
|
|
5
5
|
import { describe, expect, it } from 'vitest'
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
* The client runtime is CONTENT-FROZEN
|
|
8
|
+
* The client runtime is CONTENT-FROZEN.
|
|
9
9
|
*
|
|
10
10
|
* Self-contained codegen (the default) bundles these source files verbatim
|
|
11
|
-
* (imports stripped) into the generated `_client.ts` / `_types.ts`.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* (imports stripped) into the generated `_client.ts` / `_types.ts`. Generated
|
|
12
|
+
* output must stay stable for downstream apps, so these files must not change
|
|
13
|
+
* incidentally. If you intentionally change one, you are changing generated
|
|
14
|
+
* output for every downstream app: regenerate the affected codegen goldens,
|
|
15
15
|
* verify the diff is wanted, and update the hash here.
|
|
16
16
|
*
|
|
17
|
-
*
|
|
17
|
+
* Baseline hashes were recorded from v8.6.0 `src/client/*.ts`. Files carrying an
|
|
18
|
+
* intentional, documented deviation from that baseline are marked inline below;
|
|
19
|
+
* see the matching "DOCUMENTED DEVIATIONS" note in `goldens.test.ts`:
|
|
20
|
+
* - `call.ts`: `onError` now fires on non-2xx HTTP responses (401/403/5xx),
|
|
21
|
+
* not just adapter throws (v8.6.0 claimed this but never did it).
|
|
22
|
+
* - `errors.ts`: removed the deprecated `ClientRequestError` alias (v11 major).
|
|
23
|
+
* - `index.ts`: dropped `ClientRequestError` from the barrel re-export (v11).
|
|
24
|
+
* - `resolve-options.ts`: removed the deprecated internal `resolveSignal`
|
|
25
|
+
* helper, superseded by `resolveSignalSources` (v11).
|
|
18
26
|
*/
|
|
19
27
|
const FROZEN_FILES: ReadonlyArray<readonly [file: string, sha256: string]> = [
|
|
20
|
-
|
|
28
|
+
// v11 deviation (ClientRequestError alias removed) — NOT the v8.6.0 hash.
|
|
29
|
+
['errors.ts', 'e1c81db4f7dac5052958b9026cf5a80449eb9df7bbd93791c79581b1680ac5f7'],
|
|
21
30
|
['classify-error.ts', '28062fdc3be39461eeec4cc96e3edcf46377922bac6fb3cc7b54111b42199773'],
|
|
22
31
|
['error-dispatch.ts', '1bdd89319239e8aca0f186714c15b77ae5f4a9ac2c257416ddaf36d965dbe141'],
|
|
23
32
|
['request-builder.ts', 'ac15485e6786de00386e6c4a425dbab503589bc012af6ef6515b1c3e4176a51e'],
|
|
24
|
-
|
|
33
|
+
// v11 deviation (resolveSignal removed) — NOT the v8.6.0 hash.
|
|
34
|
+
['resolve-options.ts', '5fa7d9281e76f905cdd426edf15df4f680a56962adbd1f9b7af954e42b2864e8'],
|
|
25
35
|
['hooks.ts', '15d67ba827dbb6e38407af606c05a459ec27e3b1e738aac868233d0f10478aa7'],
|
|
26
|
-
|
|
36
|
+
// v9 deviation (onError on non-2xx) — NOT the v8.6.0 hash. See header note.
|
|
37
|
+
['call.ts', 'a053f33b545b7bf644b81232d007a3933e239789ed0065c15d38959b9a1e09cc'],
|
|
27
38
|
['stream.ts', '655af96f789150e3fedb7b345aae70d58b1d3b3cad9eb8b341d5a4780d5760ce'],
|
|
28
39
|
['fetch-adapter.ts', 'c5a6ebdeecac3a5efc3d77f346135609e23c5eebc671a08456175901106655a2'],
|
|
29
|
-
|
|
40
|
+
// v11 deviation (ClientRequestError dropped from barrel) — NOT the v8.6.0 hash.
|
|
41
|
+
['index.ts', 'b4f20bec518746364d60abf3368b249f0cbede1207151ea3c1ee9c5c769f6327'],
|
|
30
42
|
['types.ts', 'e236213020290fd187a80cdf060fcb3d67e734e94aa060c736f142cbefd4ced7'],
|
|
31
43
|
]
|
|
32
44
|
|
package/src/client/index.test.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { describe, it, expect, vi } from 'vitest'
|
|
2
2
|
import { createClient } from './index.js'
|
|
3
|
-
import {
|
|
3
|
+
import { ClientHttpError } from './errors.js'
|
|
4
4
|
import type {
|
|
5
5
|
ClientAdapter,
|
|
6
6
|
AdapterRequest,
|
|
@@ -108,7 +108,7 @@ describe('createClient', () => {
|
|
|
108
108
|
expect(result).toEqual({ id: '1', name: 'Alice' })
|
|
109
109
|
})
|
|
110
110
|
|
|
111
|
-
it('throws
|
|
111
|
+
it('throws ClientHttpError on non-2xx from scope callable', async () => {
|
|
112
112
|
const adapter: ClientAdapter = {
|
|
113
113
|
request: vi.fn(async (): Promise<AdapterResponse> => ({
|
|
114
114
|
status: 404,
|
|
@@ -133,7 +133,7 @@ describe('createClient', () => {
|
|
|
133
133
|
}),
|
|
134
134
|
})
|
|
135
135
|
|
|
136
|
-
await expect(client.users.getUser('99')).rejects.toThrow(
|
|
136
|
+
await expect(client.users.getUser('99')).rejects.toThrow(ClientHttpError)
|
|
137
137
|
})
|
|
138
138
|
|
|
139
139
|
it('applies global hooks to all calls', async () => {
|
|
@@ -282,10 +282,10 @@ describe('createClient', () => {
|
|
|
282
282
|
expect(capturedHeaders[0]?.['x-stream-key']).toBe('stream-secret')
|
|
283
283
|
})
|
|
284
284
|
|
|
285
|
-
it('barrel exports: re-exports
|
|
285
|
+
it('barrel exports: re-exports ClientHttpError', async () => {
|
|
286
286
|
// This verifies the exports are accessible — the import at the top covers this
|
|
287
|
-
const {
|
|
288
|
-
expect(
|
|
287
|
+
const { ClientHttpError: CHE } = await import('./index.js')
|
|
288
|
+
expect(CHE).toBeDefined()
|
|
289
289
|
})
|
|
290
290
|
|
|
291
291
|
// ── defaults + per-call options ───────────────────────────
|
package/src/client/index.ts
CHANGED
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
resolveBasePath,
|
|
5
5
|
resolveHeaders,
|
|
6
6
|
resolveMeta,
|
|
7
|
-
resolveSignal,
|
|
8
7
|
resolveSignalSources,
|
|
9
8
|
} from './resolve-options.js'
|
|
10
9
|
import type { AdapterRequest, ProcedureCallDefaults, ProcedureCallOptions } from './types.js'
|
|
@@ -123,78 +122,6 @@ describe('resolveMeta', () => {
|
|
|
123
122
|
})
|
|
124
123
|
})
|
|
125
124
|
|
|
126
|
-
// ── resolveSignal ─────────────────────────────────────────
|
|
127
|
-
|
|
128
|
-
describe('resolveSignal', () => {
|
|
129
|
-
it('returns undefined when nothing is set', () => {
|
|
130
|
-
expect(resolveSignal(undefined, undefined)).toBeUndefined()
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
it('returns the default signal when no timeout and no per-call signal', () => {
|
|
134
|
-
const controller = new AbortController()
|
|
135
|
-
expect(resolveSignal({ signal: controller.signal }, undefined)).toBe(controller.signal)
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
it('returns the per-call signal when no default and no timeout', () => {
|
|
139
|
-
const controller = new AbortController()
|
|
140
|
-
expect(resolveSignal(undefined, { signal: controller.signal })).toBe(controller.signal)
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
it('combines default + per-call signals — default aborts combined signal', () => {
|
|
144
|
-
const defaultCtrl = new AbortController()
|
|
145
|
-
const callCtrl = new AbortController()
|
|
146
|
-
const signal = resolveSignal({ signal: defaultCtrl.signal }, { signal: callCtrl.signal })!
|
|
147
|
-
|
|
148
|
-
expect(signal.aborted).toBe(false)
|
|
149
|
-
defaultCtrl.abort(new Error('default-abort'))
|
|
150
|
-
expect(signal.aborted).toBe(true)
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
it('combines default + per-call signals — per-call aborts combined signal', () => {
|
|
154
|
-
const defaultCtrl = new AbortController()
|
|
155
|
-
const callCtrl = new AbortController()
|
|
156
|
-
const signal = resolveSignal({ signal: defaultCtrl.signal }, { signal: callCtrl.signal })!
|
|
157
|
-
|
|
158
|
-
callCtrl.abort(new Error('call-abort'))
|
|
159
|
-
expect(signal.aborted).toBe(true)
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
it('applies timeout via AbortSignal.timeout', () => {
|
|
163
|
-
const spy = vi.spyOn(AbortSignal, 'timeout')
|
|
164
|
-
try {
|
|
165
|
-
const signal = resolveSignal(undefined, { timeout: 100 })
|
|
166
|
-
expect(spy).toHaveBeenCalledWith(100)
|
|
167
|
-
expect(signal).toBeDefined()
|
|
168
|
-
} finally {
|
|
169
|
-
spy.mockRestore()
|
|
170
|
-
}
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
it('per-call timeout overrides default timeout', () => {
|
|
174
|
-
const spy = vi.spyOn(AbortSignal, 'timeout')
|
|
175
|
-
try {
|
|
176
|
-
resolveSignal({ timeout: 10_000 }, { timeout: 100 })
|
|
177
|
-
expect(spy).toHaveBeenCalledWith(100)
|
|
178
|
-
expect(spy).not.toHaveBeenCalledWith(10_000)
|
|
179
|
-
} finally {
|
|
180
|
-
spy.mockRestore()
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
it('combines signal + timeout — signal aborts first', () => {
|
|
185
|
-
const controller = new AbortController()
|
|
186
|
-
const signal = resolveSignal(undefined, { signal: controller.signal, timeout: 10_000 })!
|
|
187
|
-
expect(signal.aborted).toBe(false)
|
|
188
|
-
controller.abort()
|
|
189
|
-
expect(signal.aborted).toBe(true)
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
it('per-call timeout: 0 disables default timeout', () => {
|
|
193
|
-
const signal = resolveSignal({ timeout: 1000 }, { timeout: 0 })
|
|
194
|
-
expect(signal).toBeUndefined()
|
|
195
|
-
})
|
|
196
|
-
})
|
|
197
|
-
|
|
198
125
|
// ── resolveSignalSources ──────────────────────────────────
|
|
199
126
|
|
|
200
127
|
describe('resolveSignalSources', () => {
|