stitchkit 0.40.0 → 0.42.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/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/http.d.ts +1 -1
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/contract/errors-factory.d.ts +88 -15
- package/dist/contract/errors-factory.d.ts.map +1 -1
- package/dist/contract/errors.d.ts +4 -4
- package/dist/contract/errors.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/contract/index.js +2 -2
- package/dist/{index-xax049k6.js → index-11x5dts2.js} +44 -13
- package/dist/{index-7rbzbnnf.js → index-181aebw8.js} +10 -15
- package/dist/{index-92gs1m5b.js → index-310bfer5.js} +1 -1
- package/dist/{index-fyfk537k.js → index-gex6gxhe.js} +25 -5
- package/dist/{index-p1x65gk7.js → index-p9vkwns1.js} +11 -13
- package/dist/{index-809wc1tt.js → index-s4qsmgwe.js} +4 -1
- package/dist/index.js +37 -13
- package/dist/internal/errors.d.ts +13 -0
- package/dist/internal/errors.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +8 -0
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/node.js +2 -2
- package/dist/observability/index.js +1 -1
- package/dist/react.js +1 -1
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +8 -4
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/index.js +7 -6
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +8 -6
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +13 -5
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp-handler.d.ts +5 -4
- package/dist/tools/mcp-handler.d.ts.map +1 -1
- package/dist/tools/mcp-stdio.d.ts +3 -2
- package/dist/tools/mcp-stdio.d.ts.map +1 -1
- package/dist/tools/mcp.d.ts +49 -9
- package/dist/tools/mcp.d.ts.map +1 -1
- package/dist/tools/native-mcp.d.ts +4 -18
- package/dist/tools/native-mcp.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -3
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/surface.d.ts +37 -0
- package/dist/tools/surface.d.ts.map +1 -0
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transports.d.ts +11 -9
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tools/view-file.d.ts +3 -3
- package/dist/tools.d.ts +5 -5
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +320 -165
- package/llms-full.txt +310 -53
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/browser/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAEL,KAAK,UAAU,IAAI,WAAW,EAG9B,KAAK,mBAAmB,EACzB,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/browser/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAGjB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAEL,KAAK,UAAU,IAAI,WAAW,EAG9B,KAAK,mBAAmB,EACzB,MAAM,QAAQ,CAAC;AA4ChB,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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AAC,CAAC,SAAS,MAAM,GAAG,KAAK,EAE9B,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,gBAAgB,EACxB,cAAc,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACvC;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;CAAE,CAOxE;AAED,mFAAmF;AACnF,wBAAgB,uBAAuB,CACrC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACnD,KAAK,CAAC,OAAO,SAAS,kBAAkB,CAAC,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAEnE,SAAS,EAAE,CAAC,EACZ,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,OAAO,GACpB,wBAAwB,CAAC,CAAC,EAAE,OAAO,CAAC,CAOtC"}
|
package/dist/browser/http.d.ts
CHANGED
|
@@ -69,7 +69,7 @@ export interface RequestOptions {
|
|
|
69
69
|
* caller still gets `.blob()` / `.body`, plus the headers where
|
|
70
70
|
* `Content-Disposition` (the download filename) lives.
|
|
71
71
|
*/
|
|
72
|
-
responseType?: 'json' | 'blob' | 'response';
|
|
72
|
+
responseType?: 'json' | 'blob' | 'response' | 'void';
|
|
73
73
|
}
|
|
74
74
|
/** The HTTP transport adapter `createClient` builds typed methods on. */
|
|
75
75
|
export interface HttpClient {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/browser/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAIjD,MAAM,MAAM,QAAQ,GAChB;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,GACxB;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,GACzB;IAAE,IAAI,EAAE,QAAQ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AW,oBAAqB,SAAQ,UAAU;IACtD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAmL/E"}
|
package/dist/cli.js
CHANGED
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
emitResult,
|
|
5
5
|
parseCliArgs,
|
|
6
6
|
pollUntilDone
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-p9vkwns1.js";
|
|
8
8
|
import"./index-frfyw9fa.js";
|
|
9
9
|
import"./index-x3fcszf8.js";
|
|
10
|
-
import"./index-
|
|
10
|
+
import"./index-gex6gxhe.js";
|
|
11
11
|
export {
|
|
12
12
|
pollUntilDone,
|
|
13
13
|
parseCliArgs,
|
|
@@ -1,18 +1,91 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Declare an application's domain errors once. Each definition owns its HTTP
|
|
3
|
+
* status and optional Zod schema for structured details; generated factories
|
|
4
|
+
* construct (but do not throw) branded `AppError` instances.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* export const appErrors = defineErrors({
|
|
8
|
+
* SESSION_NOT_FOUND: { status: 404 },
|
|
9
|
+
* QUOTA_EXCEEDED: {
|
|
10
|
+
* status: 429,
|
|
11
|
+
* details: z.object({ retryAfterSeconds: z.number().int().positive() }),
|
|
12
|
+
* },
|
|
13
|
+
* })
|
|
14
|
+
*
|
|
15
|
+
* throw appErrors.errors.SESSION_NOT_FOUND({ message: 'No such session' })
|
|
16
|
+
* throw appErrors.errors.QUOTA_EXCEEDED({
|
|
17
|
+
* details: { retryAfterSeconds: 30 },
|
|
18
|
+
* hint: 'Wait for the current window to expire',
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
import { z } from 'zod';
|
|
23
|
+
import { AppError } from './errors';
|
|
24
|
+
/** Supported structured-details schemas: a required or optional Zod object. */
|
|
25
|
+
export type ErrorDetailsSchema = z.ZodObject | z.ZodOptional<z.ZodObject>;
|
|
26
|
+
/** One domain error definition. Omitting `details` forbids structured details. */
|
|
27
|
+
export type ErrorDefinition = {
|
|
28
|
+
readonly status: number;
|
|
29
|
+
readonly details?: never;
|
|
30
|
+
} | {
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly details: ErrorDetailsSchema;
|
|
33
|
+
};
|
|
34
|
+
export type ErrorDefinitions = Record<string, ErrorDefinition>;
|
|
35
|
+
/** Parsed details retained by the constructed `AppError`. */
|
|
36
|
+
export type ErrorDetailsOutput<TDefinition extends ErrorDefinition> = TDefinition extends {
|
|
37
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
38
|
+
} ? Extract<z.output<TSchema>, Record<string, unknown> | undefined> : undefined;
|
|
39
|
+
/** AppError instance with required details refined when its schema is required. */
|
|
40
|
+
export type DefinedAppError<TCode extends string, TDefinition extends ErrorDefinition> = AppError<TCode, ErrorDetailsOutput<TDefinition>> & (TDefinition extends {
|
|
41
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
42
|
+
} ? undefined extends z.output<TSchema> ? object : {
|
|
43
|
+
readonly details: ErrorDetailsOutput<TDefinition>;
|
|
44
|
+
} : object);
|
|
45
|
+
/**
|
|
46
|
+
* Factory arguments inferred from the definition: details are forbidden,
|
|
47
|
+
* required or optional according to the declared schema.
|
|
48
|
+
*/
|
|
49
|
+
export type ErrorFactoryArguments<TDefinition extends ErrorDefinition> = TDefinition extends {
|
|
50
|
+
details: infer TSchema extends ErrorDetailsSchema;
|
|
51
|
+
} ? undefined extends z.input<TSchema> ? [
|
|
52
|
+
options?: {
|
|
53
|
+
message?: string;
|
|
54
|
+
details?: Exclude<z.input<TSchema>, undefined>;
|
|
55
|
+
hint?: string;
|
|
56
|
+
}
|
|
57
|
+
] : [
|
|
58
|
+
options: {
|
|
59
|
+
message?: string;
|
|
60
|
+
details: z.input<TSchema>;
|
|
61
|
+
hint?: string;
|
|
62
|
+
}
|
|
63
|
+
] : [options?: {
|
|
64
|
+
message?: string;
|
|
65
|
+
details?: never;
|
|
66
|
+
hint?: string;
|
|
67
|
+
}];
|
|
68
|
+
/** Typed constructor for one declared domain error code. */
|
|
69
|
+
export type ErrorFactory<TCode extends string, TDefinition extends ErrorDefinition> = (...args: ErrorFactoryArguments<TDefinition>) => DefinedAppError<TCode, TDefinition>;
|
|
70
|
+
export type ErrorFactories<TDefinitions extends ErrorDefinitions> = {
|
|
71
|
+
readonly [TCode in keyof TDefinitions]: ErrorFactory<TCode & string, TDefinitions[TCode]>;
|
|
72
|
+
};
|
|
73
|
+
export type FrozenErrorDefinitions<TDefinitions extends ErrorDefinitions> = {
|
|
74
|
+
readonly [TCode in keyof TDefinitions]: Readonly<TDefinitions[TCode]>;
|
|
75
|
+
};
|
|
76
|
+
/** The immutable handle returned by `defineErrors`. */
|
|
77
|
+
export interface DefinedErrors<TDefinitions extends ErrorDefinitions> {
|
|
78
|
+
/** One typed `AppError` constructor per code. The caller chooses when to throw. */
|
|
79
|
+
readonly errors: ErrorFactories<TDefinitions>;
|
|
80
|
+
/** Code literals for client-side matching without magic strings. */
|
|
81
|
+
readonly codes: {
|
|
82
|
+
readonly [TCode in keyof TDefinitions]: TCode & string;
|
|
8
83
|
};
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/** Type guard — is `code` one of this app's declared codes? */
|
|
14
|
-
isCode: (code: string) => code is keyof TDef & string;
|
|
84
|
+
/** Read-only definitions; status and details schemas remain one source of truth. */
|
|
85
|
+
readonly definitions: FrozenErrorDefinitions<TDefinitions>;
|
|
86
|
+
/** Type guard — is `code` one of this application's declared codes? */
|
|
87
|
+
readonly isCode: (code: string) => code is Extract<keyof TDefinitions, string>;
|
|
15
88
|
}
|
|
16
|
-
/** Declare
|
|
17
|
-
export declare function defineErrors<const
|
|
89
|
+
/** Declare an immutable, Zod-first domain error vocabulary. */
|
|
90
|
+
export declare function defineErrors<const TDefinitions extends ErrorDefinitions>(source: TDefinitions): DefinedErrors<TDefinitions>;
|
|
18
91
|
//# sourceMappingURL=errors-factory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-factory.d.ts","sourceRoot":"","sources":["../../src/contract/errors-factory.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors-factory.d.ts","sourceRoot":"","sources":["../../src/contract/errors-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,+EAA+E;AAC/E,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AAE1E,kFAAkF;AAClF,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAA;CAAE,GACrD;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEtE,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;AAE/D,6DAA6D;AAC7D,MAAM,MAAM,kBAAkB,CAAC,WAAW,SAAS,eAAe,IAAI,WAAW,SAAS;IACxF,OAAO,EAAE,MAAM,OAAO,SAAS,kBAAkB,CAAC;CACnD,GACG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,GAC/D,SAAS,CA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AE,qBAAqB,CAAC,WAAW,CAAC,KACxC,eAAe,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;AAEzC,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,gBAAgB,IAAI;IAClE,QAAQ,EAAE,KAAK,IAAI,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,GAAG,MAAM,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC;CAC1F,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,YAAY,SAAS,gBAAgB,IAAI;IAC1E,QAAQ,EAAE,KAAK,IAAI,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;CACtE,CAAC;AAEF,uDAAuD;AACvD,MAAM,WAAW,aAAa,CAAC,YAAY,SAAS,gBAAgB;IAClE,mFAAmF;IACnF,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC9C,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,KAAK,IAAI,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM;KAAE,CAAC;IAC3E,oFAAoF;IACpF,QAAQ,CAAC,WAAW,EAAE,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAC3D,uEAAuE;IACvE,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC;CAChF;AAgCD,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,KAAK,CAAC,YAAY,SAAS,gBAAgB,EACtE,MAAM,EAAE,YAAY,GACnB,aAAa,CAAC,YAAY,CAAC,CA0C7B"}
|
|
@@ -21,12 +21,12 @@ export interface ErrorEnvelope {
|
|
|
21
21
|
* structured `details` and a `hint`. `toJSON()` renders the public error
|
|
22
22
|
* envelope. Throw it directly, or via the typed helpers below.
|
|
23
23
|
*/
|
|
24
|
-
export declare class AppError extends Error {
|
|
25
|
-
readonly code:
|
|
24
|
+
export declare class AppError<TCode extends string = string, TDetails extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> extends Error {
|
|
25
|
+
readonly code: TCode;
|
|
26
26
|
readonly status: number;
|
|
27
|
-
readonly details?:
|
|
27
|
+
readonly details?: TDetails | undefined;
|
|
28
28
|
readonly hint?: string | undefined;
|
|
29
|
-
constructor(code:
|
|
29
|
+
constructor(code: TCode, message?: string, status?: number, details?: TDetails | undefined, hint?: string | undefined);
|
|
30
30
|
static is(err: unknown): err is AppError;
|
|
31
31
|
toJSON(): ErrorEnvelope;
|
|
32
32
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/contract/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,8BAA8B;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,0BAA0B;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAcD;;;;GAIG;AACH,qBAAa,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/contract/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE;QACL,2CAA2C;QAC3C,IAAI,EAAE,MAAM,CAAC;QACb,8BAA8B;QAC9B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,gCAAgC;QAChC,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,0BAA0B;QAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH;AAcD;;;;GAIG;AACH,qBAAa,QAAQ,CACnB,KAAK,SAAS,MAAM,GAAG,MAAM,EAC7B,QAAQ,SAAS,M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AAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,IAAI,eAAe,CAEvE;AAED,+FAA+F;AAC/F,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,KAAK,CAOP"}
|
package/dist/contract/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ALL_TRANSPORTS, type BodyHttpSuccessStatus, type ContractDef, type ContractMeta, defineContract, type EndpointDef, type EndpointFn, type EndpointResponseMeta, type EndpointToolAnnotations, type EndpointUiMeta, type FileDescriptor, type HandlerContext, type HeadEndpointDef, type HttpMethod, type HttpSuccessStatus, type MultipartFile, type ResponseMetadata, type RuntimeContext, type ScopedEndpointFn, type ScopedHttpClient, type ScopedUrlBuilder, type ScopedUrlFn, type Transport, type TransportSource, type TypedClient, type TypedHttpClient, type TypedUrlBuilder, } from './define';
|
|
2
2
|
export { AppError, appError, badRequest, conflict, type ErrorEnvelope, forbidden, isStitchErrorCode, notFound, rateLimited, STITCH_ERROR_STATUS, type StitchErrorCode, unauthorized, } from './errors';
|
|
3
|
-
export { type DefinedErrors, defineErrors, type
|
|
3
|
+
export { type DefinedAppError, type DefinedErrors, defineErrors, type ErrorDefinition, type ErrorDefinitions, type ErrorDetailsOutput, type ErrorDetailsSchema, type ErrorFactories, type ErrorFactory, type ErrorFactoryArguments, type FrozenErrorDefinitions, } from './errors-factory';
|
|
4
4
|
export { createContractFactory, type ScopedDefineContract } from './factory';
|
|
5
5
|
export { decodeCursor, encodeCursor, type Paginated, paginatedSchema, } from './pagination';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contract/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,KAAK,qBAAqB,EAC1B,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,cAAc,EACd,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,KAAK,aAAa,EAClB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,GAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,qBAAqB,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAE7E,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,KAAK,SAAS,EACd,eAAe,GAChB,MAAM,cAAc,CAAC"}
|
package/dist/contract/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./index-
|
|
2
|
+
mapObjectTypeBoundary
|
|
3
|
+
} from "./index-s4qsmgwe.js";
|
|
4
4
|
|
|
5
5
|
// src/contract/define.ts
|
|
6
6
|
import { z } from "zod";
|
|
@@ -237,17 +237,48 @@ function appError(code, message, details) {
|
|
|
237
237
|
throw new AppError(code, message, isStitchErrorCode(code) ? STITCH_ERROR_STATUS[code] : 500, details);
|
|
238
238
|
}
|
|
239
239
|
// src/contract/errors-factory.ts
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
240
|
+
import { z as z2 } from "zod";
|
|
241
|
+
function isErrorDetailsSchema(value) {
|
|
242
|
+
return value instanceof z2.ZodObject || value instanceof z2.ZodOptional && value.unwrap() instanceof z2.ZodObject;
|
|
243
|
+
}
|
|
244
|
+
function validateDefinition(code, definition) {
|
|
245
|
+
if (!Number.isInteger(definition.status) || definition.status < 400 || definition.status > 599) {
|
|
246
|
+
throw new Error(`[stitchkit] Error "${code}" must declare an integer HTTP status from 400 to 599`);
|
|
247
|
+
}
|
|
248
|
+
if (definition.details !== undefined && !isErrorDetailsSchema(definition.details)) {
|
|
249
|
+
throw new Error(`[stitchkit] Error "${code}" details must be a Zod object or optional Zod object`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function defineErrors(source) {
|
|
253
|
+
const definitions = mapObjectTypeBoundary(source, (code, definition) => {
|
|
254
|
+
const name = String(code);
|
|
255
|
+
validateDefinition(name, definition);
|
|
256
|
+
return Object.freeze({ ...definition });
|
|
243
257
|
});
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
258
|
+
Object.freeze(definitions);
|
|
259
|
+
const errors = mapObjectTypeBoundary(definitions, (code, definition) => {
|
|
260
|
+
const name = String(code);
|
|
261
|
+
return (options = {}) => {
|
|
262
|
+
if (definition.details === undefined) {
|
|
263
|
+
if ("details" in options) {
|
|
264
|
+
throw new Error(`[stitchkit] Error "${name}" does not declare details`);
|
|
265
|
+
}
|
|
266
|
+
return new AppError(name, options.message, definition.status, undefined, options.hint);
|
|
267
|
+
}
|
|
268
|
+
const details = definition.details.parse(options.details);
|
|
269
|
+
return new AppError(name, options.message, definition.status, details, options.hint);
|
|
270
|
+
};
|
|
271
|
+
});
|
|
272
|
+
Object.freeze(errors);
|
|
273
|
+
const codes = mapObjectTypeBoundary(definitions, (code) => String(code));
|
|
274
|
+
Object.freeze(codes);
|
|
275
|
+
const known = new Set(Object.keys(definitions));
|
|
276
|
+
return Object.freeze({
|
|
247
277
|
errors,
|
|
248
278
|
codes,
|
|
279
|
+
definitions,
|
|
249
280
|
isCode: (code) => known.has(code)
|
|
250
|
-
};
|
|
281
|
+
});
|
|
251
282
|
}
|
|
252
283
|
// src/contract/factory.ts
|
|
253
284
|
function createContractFactory() {
|
|
@@ -262,7 +293,7 @@ function createContractFactory() {
|
|
|
262
293
|
};
|
|
263
294
|
}
|
|
264
295
|
// src/contract/pagination.ts
|
|
265
|
-
import { z as
|
|
296
|
+
import { z as z3 } from "zod";
|
|
266
297
|
|
|
267
298
|
// src/internal/base64url.ts
|
|
268
299
|
function bytesToBase64Url(bytes) {
|
|
@@ -282,9 +313,9 @@ function base64UrlToBytes(segment) {
|
|
|
282
313
|
|
|
283
314
|
// src/contract/pagination.ts
|
|
284
315
|
function paginatedSchema(itemSchema) {
|
|
285
|
-
return
|
|
286
|
-
items:
|
|
287
|
-
nextCursor:
|
|
316
|
+
return z3.object({
|
|
317
|
+
items: z3.array(itemSchema),
|
|
318
|
+
nextCursor: z3.string().nullable()
|
|
288
319
|
});
|
|
289
320
|
}
|
|
290
321
|
function toBase64Url(str) {
|
|
@@ -27,8 +27,8 @@ import {
|
|
|
27
27
|
setRequestEndpoint,
|
|
28
28
|
setRequestError,
|
|
29
29
|
typedEntries,
|
|
30
|
-
|
|
31
|
-
} from "./index-
|
|
30
|
+
validateDeclaredOutput
|
|
31
|
+
} from "./index-gex6gxhe.js";
|
|
32
32
|
|
|
33
33
|
// src/server/multipart.ts
|
|
34
34
|
var DEFAULT_MAX_UPLOAD_BYTES = 25 * 1024 * 1024;
|
|
@@ -879,25 +879,20 @@ function createHandler(config) {
|
|
|
879
879
|
if (result instanceof Response) {
|
|
880
880
|
throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} produced a Response on the data path — only a \`rawResponse: true\` endpoint may return one (an afterHandle hook must return data)`, 500);
|
|
881
881
|
}
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
throw new AppError("INTERNAL_SERVER_ERROR", checked.message, 500);
|
|
888
|
-
}
|
|
889
|
-
result = checked.data;
|
|
882
|
+
const checked = validateDeclaredOutput(method.outputSchema, result, config.warnOnOutputStrip && method.outputSchema ? (paths) => {
|
|
883
|
+
warn(`[stitchkit] output strip ${method.serviceName}.${method.key}: ${paths.join(", ")}`);
|
|
884
|
+
} : undefined);
|
|
885
|
+
if (!checked.ok) {
|
|
886
|
+
throw new AppError("INTERNAL_SERVER_ERROR", checked.message, 500);
|
|
890
887
|
}
|
|
891
|
-
|
|
888
|
+
result = checked.data;
|
|
889
|
+
const responseStatus = method.responseMeta?.status ?? (method.outputSchema ? 200 : 204);
|
|
892
890
|
if (method.outputSchema && (responseStatus === 204 || responseStatus === 205)) {
|
|
893
891
|
throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} cannot combine output with bodyless status ${responseStatus}`, 500);
|
|
894
892
|
}
|
|
895
|
-
if (result !== undefined && result !== null && (responseStatus === 204 || responseStatus === 205)) {
|
|
896
|
-
throw new AppError("INTERNAL_SERVER_ERROR", `${method.serviceName}.${method.key} produced data for bodyless status ${responseStatus}`, 500);
|
|
897
|
-
}
|
|
898
893
|
const responseHeaders = new Headers(corsHeaders2(cors, req));
|
|
899
894
|
applyResponseMetadata(responseHeaders, responseMetadata, `${method.serviceName}.${method.key}`);
|
|
900
|
-
if (
|
|
895
|
+
if (!method.outputSchema) {
|
|
901
896
|
const empty = new Response(null, { status: responseStatus, headers: responseHeaders });
|
|
902
897
|
logDone(responseStatus);
|
|
903
898
|
return empty;
|
|
@@ -121,6 +121,9 @@ function mergeMeta(contractMeta, endpointMeta) {
|
|
|
121
121
|
return { ...contractMeta };
|
|
122
122
|
return { ...contractMeta, ...endpointMeta };
|
|
123
123
|
}
|
|
124
|
+
// src/contract/errors-factory.ts
|
|
125
|
+
import { z as z2 } from "zod";
|
|
126
|
+
|
|
124
127
|
// src/internal/typed.ts
|
|
125
128
|
function typedEntries(value) {
|
|
126
129
|
return Object.entries(value);
|
|
@@ -129,7 +132,7 @@ function isRecord(value) {
|
|
|
129
132
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
130
133
|
}
|
|
131
134
|
// src/contract/pagination.ts
|
|
132
|
-
import { z as
|
|
135
|
+
import { z as z3 } from "zod";
|
|
133
136
|
|
|
134
137
|
// src/internal/base64url.ts
|
|
135
138
|
function bytesToBase64Url(bytes) {
|
|
@@ -147,7 +150,7 @@ function base64UrlToBytes(segment) {
|
|
|
147
150
|
return Uint8Array.from(atob(padded), (c) => c.charCodeAt(0));
|
|
148
151
|
}
|
|
149
152
|
// src/internal/errors.ts
|
|
150
|
-
import { z as
|
|
153
|
+
import { z as z4 } from "zod";
|
|
151
154
|
function issuePath(path) {
|
|
152
155
|
return path.length > 0 ? path.map(String).join(".") : "(root)";
|
|
153
156
|
}
|
|
@@ -170,7 +173,7 @@ var MAX_DETAIL_ISSUES = 20;
|
|
|
170
173
|
function errorCode(err) {
|
|
171
174
|
if (AppError.is(err))
|
|
172
175
|
return err.code;
|
|
173
|
-
if (err instanceof
|
|
176
|
+
if (err instanceof z4.ZodError)
|
|
174
177
|
return "VALIDATION_ERROR";
|
|
175
178
|
return;
|
|
176
179
|
}
|
|
@@ -186,7 +189,7 @@ function recordedErrorMessage(code, envelopeMessage, thrown) {
|
|
|
186
189
|
function normalizeError(err) {
|
|
187
190
|
if (AppError.is(err))
|
|
188
191
|
return err;
|
|
189
|
-
if (err instanceof
|
|
192
|
+
if (err instanceof z4.ZodError) {
|
|
190
193
|
return new AppError("VALIDATION_ERROR", formatZodError(err), 400, {
|
|
191
194
|
issues: zodIssues(err).slice(0, MAX_DETAIL_ISSUES)
|
|
192
195
|
});
|
|
@@ -228,6 +231,23 @@ function validateHandlerOutput(schema, data, onStripped) {
|
|
|
228
231
|
message: `Handler output does not match the contract: ${formatZodError(parsed.error)}`
|
|
229
232
|
};
|
|
230
233
|
}
|
|
234
|
+
function validateDeclaredOutput(schema, data, onStripped) {
|
|
235
|
+
if (!schema) {
|
|
236
|
+
if (data === undefined || data === null)
|
|
237
|
+
return { ok: true, data };
|
|
238
|
+
return {
|
|
239
|
+
ok: false,
|
|
240
|
+
message: "Handler returned data but the contract declares no output"
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (data === undefined) {
|
|
244
|
+
return {
|
|
245
|
+
ok: false,
|
|
246
|
+
message: "Handler returned undefined but the contract declares an output"
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
return validateHandlerOutput(schema, data, onStripped);
|
|
250
|
+
}
|
|
231
251
|
|
|
232
252
|
// src/internal/safe-json.ts
|
|
233
253
|
function isUnsafeKey(key) {
|
|
@@ -382,4 +402,4 @@ function wrapInRequestContext(handler, options = {}) {
|
|
|
382
402
|
};
|
|
383
403
|
}
|
|
384
404
|
|
|
385
|
-
export { __require, parseTrailingWildcard, mergeMeta, AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError, typedEntries, isRecord, bytesToBase64Url, base64UrlToBytes, formatZodError, zodIssues, errorCode, recordedErrorMessage, normalizeError,
|
|
405
|
+
export { __require, parseTrailingWildcard, mergeMeta, AppError, notFound, badRequest, unauthorized, forbidden, conflict, rateLimited, STITCH_ERROR_STATUS, isStitchErrorCode, appError, typedEntries, isRecord, bytesToBase64Url, base64UrlToBytes, formatZodError, zodIssues, errorCode, recordedErrorMessage, normalizeError, validateDeclaredOutput, isUnsafeKey, safeJsonParse, generateTraceId, resolveTraceId, resolveSocketIp, extractIp, getClientInfo, parseQueryParams, createTraceContext, parseTraceparent, formatTraceparent, resolveTraceContext, childSpan, runWithRequestContext, getRequestContext, getTraceId, getUserId, setRequestUser, setRequestEndpoint, setRequestDimensions, setRequestError, wrapInRequestContext };
|
|
@@ -16,8 +16,8 @@ import {
|
|
|
16
16
|
normalizeError,
|
|
17
17
|
runWithRequestContext,
|
|
18
18
|
safeJsonParse,
|
|
19
|
-
|
|
20
|
-
} from "./index-
|
|
19
|
+
validateDeclaredOutput
|
|
20
|
+
} from "./index-gex6gxhe.js";
|
|
21
21
|
|
|
22
22
|
// src/tools/coerce.ts
|
|
23
23
|
import { z } from "zod";
|
|
@@ -640,17 +640,15 @@ async function runToolMethod(method, toolName, rawArgs, context, hooks, lifecycl
|
|
|
640
640
|
if (transformed !== undefined)
|
|
641
641
|
data = transformed;
|
|
642
642
|
}
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
});
|
|
651
|
-
}
|
|
652
|
-
data = checked.data;
|
|
643
|
+
const checked = validateDeclaredOutput(method.outputSchema, data, onOutputStrip);
|
|
644
|
+
if (!checked.ok) {
|
|
645
|
+
return finish({
|
|
646
|
+
ok: false,
|
|
647
|
+
code: "INTERNAL_SERVER_ERROR",
|
|
648
|
+
details: { message: checked.message }
|
|
649
|
+
});
|
|
653
650
|
}
|
|
651
|
+
data = checked.data;
|
|
654
652
|
const output = (data === undefined || data === null) && !method.outputSchema ? { status: "ok" } : data;
|
|
655
653
|
return finish({ ok: true, data: output });
|
|
656
654
|
} catch (err) {
|
|
@@ -719,7 +717,7 @@ function toToolName(serviceName, methodName) {
|
|
|
719
717
|
}
|
|
720
718
|
function assertUniqueToolName(name, taken, surface) {
|
|
721
719
|
if (taken) {
|
|
722
|
-
throw new Error(`Duplicate ${surface} "${name}" across mounted
|
|
720
|
+
throw new Error(`Duplicate ${surface} "${name}" across mounted operations`);
|
|
723
721
|
}
|
|
724
722
|
}
|
|
725
723
|
|
|
@@ -14,5 +14,8 @@ function mapObject(source, mapper) {
|
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
16
16
|
}
|
|
17
|
+
function mapObjectTypeBoundary(source, mapper) {
|
|
18
|
+
return mapObject(source, (key, value) => mapper(key, value));
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
export { typedEntries, isRecord, mapObject };
|
|
21
|
+
export { typedEntries, isRecord, mapObject, mapObjectTypeBoundary };
|
package/dist/index.js
CHANGED
|
@@ -17,12 +17,12 @@ import {
|
|
|
17
17
|
parseTrailingWildcard,
|
|
18
18
|
rateLimited,
|
|
19
19
|
unauthorized
|
|
20
|
-
} from "./index-
|
|
20
|
+
} from "./index-11x5dts2.js";
|
|
21
21
|
import {
|
|
22
22
|
isRecord,
|
|
23
23
|
mapObject,
|
|
24
24
|
typedEntries
|
|
25
|
-
} from "./index-
|
|
25
|
+
} from "./index-s4qsmgwe.js";
|
|
26
26
|
|
|
27
27
|
// src/browser/client-multipart.ts
|
|
28
28
|
function isFileDescriptor(value) {
|
|
@@ -371,7 +371,13 @@ function createHttpClient(config) {
|
|
|
371
371
|
return await client[method](url, kyOptions);
|
|
372
372
|
}
|
|
373
373
|
const response = await client[method](url, kyOptions);
|
|
374
|
-
if (
|
|
374
|
+
if (options.responseType === "void") {
|
|
375
|
+
const text = await response.text();
|
|
376
|
+
if (text.length > 0) {
|
|
377
|
+
throw new Error("Server returned data for an endpoint with no output contract");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
if (options.responseType === "void" || response.status === 204 || response.headers.get("content-length") === "0") {
|
|
375
381
|
return;
|
|
376
382
|
}
|
|
377
383
|
return response.json();
|
|
@@ -414,7 +420,7 @@ function createHttpClient(config) {
|
|
|
414
420
|
|
|
415
421
|
// src/browser/client.ts
|
|
416
422
|
function withTimeout(options, endpoint) {
|
|
417
|
-
const responseType = endpoint.rawResponse ? "response" : undefined;
|
|
423
|
+
const responseType = endpoint.rawResponse ? "response" : endpoint.output ? undefined : "void";
|
|
418
424
|
if (endpoint.timeout === undefined && responseType === undefined)
|
|
419
425
|
return options;
|
|
420
426
|
return {
|
|
@@ -424,10 +430,20 @@ function withTimeout(options, endpoint) {
|
|
|
424
430
|
};
|
|
425
431
|
}
|
|
426
432
|
function withOutput(endpoint, result) {
|
|
427
|
-
|
|
428
|
-
if (!schema)
|
|
433
|
+
if (endpoint.rawResponse)
|
|
429
434
|
return result;
|
|
430
|
-
|
|
435
|
+
const schema = endpoint.output;
|
|
436
|
+
return result.then((value) => {
|
|
437
|
+
if (!schema) {
|
|
438
|
+
if (value === undefined || value === null)
|
|
439
|
+
return;
|
|
440
|
+
throw new Error("Server returned data for an endpoint with no output contract");
|
|
441
|
+
}
|
|
442
|
+
if (value === undefined) {
|
|
443
|
+
throw new Error("Server returned no body for an endpoint with an output contract");
|
|
444
|
+
}
|
|
445
|
+
return schema.parse(value);
|
|
446
|
+
});
|
|
431
447
|
}
|
|
432
448
|
function contractEndpointMatchers(contract, endpointNames, contractConfig) {
|
|
433
449
|
const selected = endpointNames ? new Set(endpointNames) : null;
|
|
@@ -554,10 +570,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
554
570
|
}
|
|
555
571
|
if (endpoint.rawResponse)
|
|
556
572
|
return res2;
|
|
557
|
-
if (
|
|
573
|
+
if (!endpoint.output) {
|
|
574
|
+
const text = await res2.text();
|
|
575
|
+
if (text.length > 0) {
|
|
576
|
+
throw new Error("Server returned data for an endpoint with no output contract");
|
|
577
|
+
}
|
|
558
578
|
return;
|
|
559
|
-
|
|
560
|
-
return endpoint.output
|
|
579
|
+
}
|
|
580
|
+
return endpoint.output.parse(await res2.json());
|
|
561
581
|
}
|
|
562
582
|
const res = await fetch(url, {
|
|
563
583
|
method: endpoint.method,
|
|
@@ -573,10 +593,14 @@ function createFetchMethod(endpoint, prefix, config, contractConfig) {
|
|
|
573
593
|
}
|
|
574
594
|
if (endpoint.rawResponse)
|
|
575
595
|
return res;
|
|
576
|
-
if (
|
|
596
|
+
if (!endpoint.output) {
|
|
597
|
+
const text = await res.text();
|
|
598
|
+
if (text.length > 0) {
|
|
599
|
+
throw new Error("Server returned data for an endpoint with no output contract");
|
|
600
|
+
}
|
|
577
601
|
return;
|
|
578
|
-
|
|
579
|
-
return endpoint.output
|
|
602
|
+
}
|
|
603
|
+
return endpoint.output.parse(await res.json());
|
|
580
604
|
};
|
|
581
605
|
}
|
|
582
606
|
async function throwForErrorResponse(res, config, fallbackBody) {
|