@modularizer/plat-client 0.4.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/args/coerce.d.ts +54 -0
- package/dist/args/coerce.d.ts.map +1 -0
- package/dist/args/coerce.js +236 -0
- package/dist/args/coerce.js.map +1 -0
- package/dist/args/index.d.ts +2 -0
- package/dist/args/index.d.ts.map +1 -0
- package/dist/args/index.js +2 -0
- package/dist/args/index.js.map +1 -0
- package/dist/args/scalars.d.ts +87 -0
- package/dist/args/scalars.d.ts.map +1 -0
- package/dist/args/scalars.js +22 -0
- package/dist/args/scalars.js.map +1 -0
- package/dist/args/validate.d.ts +23 -0
- package/dist/args/validate.d.ts.map +1 -0
- package/dist/args/validate.js +185 -0
- package/dist/args/validate.js.map +1 -0
- package/dist/args/z2.d.ts +27 -0
- package/dist/args/z2.d.ts.map +1 -0
- package/dist/args/z2.js +24 -0
- package/dist/args/z2.js.map +1 -0
- package/dist/client/css-transport-plugin.d.ts +19 -0
- package/dist/client/css-transport-plugin.d.ts.map +1 -0
- package/dist/client/css-transport-plugin.js +78 -0
- package/dist/client/css-transport-plugin.js.map +1 -0
- package/dist/client/file-transport-plugin.d.ts +28 -0
- package/dist/client/file-transport-plugin.d.ts.map +1 -0
- package/dist/client/file-transport-plugin.js +80 -0
- package/dist/client/file-transport-plugin.js.map +1 -0
- package/dist/client/http-transport-plugin.d.ts +27 -0
- package/dist/client/http-transport-plugin.d.ts.map +1 -0
- package/dist/client/http-transport-plugin.js +48 -0
- package/dist/client/http-transport-plugin.js.map +1 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +7 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/openapi-client.d.ts +334 -0
- package/dist/client/openapi-client.d.ts.map +1 -0
- package/dist/client/openapi-client.js +910 -0
- package/dist/client/openapi-client.js.map +1 -0
- package/dist/client/proxy.d.ts +5 -0
- package/dist/client/proxy.d.ts.map +1 -0
- package/dist/client/proxy.js +353 -0
- package/dist/client/proxy.js.map +1 -0
- package/dist/client/request-builder.d.ts +5 -0
- package/dist/client/request-builder.d.ts.map +1 -0
- package/dist/client/request-builder.js +88 -0
- package/dist/client/request-builder.js.map +1 -0
- package/dist/client/rpc-transport-plugin.d.ts +17 -0
- package/dist/client/rpc-transport-plugin.d.ts.map +1 -0
- package/dist/client/rpc-transport-plugin.js +69 -0
- package/dist/client/rpc-transport-plugin.js.map +1 -0
- package/dist/client/tools.d.ts +69 -0
- package/dist/client/tools.d.ts.map +1 -0
- package/dist/client/tools.js +122 -0
- package/dist/client/tools.js.map +1 -0
- package/dist/client/transport-plugin.d.ts +62 -0
- package/dist/client/transport-plugin.d.ts.map +1 -0
- package/dist/client/transport-plugin.js +40 -0
- package/dist/client/transport-plugin.js.map +1 -0
- package/dist/client-entry.d.ts +25 -0
- package/dist/client-entry.d.ts.map +1 -0
- package/dist/client-entry.js +25 -0
- package/dist/client-entry.js.map +1 -0
- package/dist/client-server-entry.d.ts +13 -0
- package/dist/client-server-entry.d.ts.map +1 -0
- package/dist/client-server-entry.js +13 -0
- package/dist/client-server-entry.js.map +1 -0
- package/dist/client-side-python/runtime.d.ts +102 -0
- package/dist/client-side-python/runtime.d.ts.map +1 -0
- package/dist/client-side-python/runtime.js +595 -0
- package/dist/client-side-python/runtime.js.map +1 -0
- package/dist/client-side-server/bootstrap.d.ts +3 -0
- package/dist/client-side-server/bootstrap.d.ts.map +1 -0
- package/dist/client-side-server/bootstrap.js +20 -0
- package/dist/client-side-server/bootstrap.js.map +1 -0
- package/dist/client-side-server/channel.d.ts +17 -0
- package/dist/client-side-server/channel.d.ts.map +1 -0
- package/dist/client-side-server/channel.js +38 -0
- package/dist/client-side-server/channel.js.map +1 -0
- package/dist/client-side-server/identity.d.ts +116 -0
- package/dist/client-side-server/identity.d.ts.map +1 -0
- package/dist/client-side-server/identity.js +358 -0
- package/dist/client-side-server/identity.js.map +1 -0
- package/dist/client-side-server/mqtt-webrtc.d.ts +77 -0
- package/dist/client-side-server/mqtt-webrtc.d.ts.map +1 -0
- package/dist/client-side-server/mqtt-webrtc.js +575 -0
- package/dist/client-side-server/mqtt-webrtc.js.map +1 -0
- package/dist/client-side-server/protocol.d.ts +49 -0
- package/dist/client-side-server/protocol.d.ts.map +1 -0
- package/dist/client-side-server/protocol.js +13 -0
- package/dist/client-side-server/protocol.js.map +1 -0
- package/dist/client-side-server/runtime.d.ts +57 -0
- package/dist/client-side-server/runtime.d.ts.map +1 -0
- package/dist/client-side-server/runtime.js +188 -0
- package/dist/client-side-server/runtime.js.map +1 -0
- package/dist/client-side-server/server.d.ts +75 -0
- package/dist/client-side-server/server.d.ts.map +1 -0
- package/dist/client-side-server/server.js +380 -0
- package/dist/client-side-server/server.js.map +1 -0
- package/dist/client-side-server/signaling.d.ts +10 -0
- package/dist/client-side-server/signaling.d.ts.map +1 -0
- package/dist/client-side-server/signaling.js +19 -0
- package/dist/client-side-server/signaling.js.map +1 -0
- package/dist/client-side-server/source-analysis.d.ts +29 -0
- package/dist/client-side-server/source-analysis.d.ts.map +1 -0
- package/dist/client-side-server/source-analysis.js +395 -0
- package/dist/client-side-server/source-analysis.js.map +1 -0
- package/dist/generated/python-browser-sources.d.ts +2 -0
- package/dist/generated/python-browser-sources.d.ts.map +1 -0
- package/dist/generated/python-browser-sources.js +13 -0
- package/dist/generated/python-browser-sources.js.map +1 -0
- package/dist/logging.d.ts +9 -0
- package/dist/logging.d.ts.map +1 -0
- package/dist/logging.js +64 -0
- package/dist/logging.js.map +1 -0
- package/dist/python-browser-entry.d.ts +2 -0
- package/dist/python-browser-entry.d.ts.map +1 -0
- package/dist/python-browser-entry.js +2 -0
- package/dist/python-browser-entry.js.map +1 -0
- package/dist/rpc.d.ts +39 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +2 -0
- package/dist/rpc.js.map +1 -0
- package/dist/server/authority-server.d.ts +27 -0
- package/dist/server/authority-server.d.ts.map +1 -0
- package/dist/server/authority-server.js +97 -0
- package/dist/server/authority-server.js.map +1 -0
- package/dist/server/cache/index.d.ts +2 -0
- package/dist/server/cache/index.d.ts.map +1 -0
- package/dist/server/cache/index.js +2 -0
- package/dist/server/cache/index.js.map +1 -0
- package/dist/server/cache/utils.d.ts +30 -0
- package/dist/server/cache/utils.d.ts.map +1 -0
- package/dist/server/cache/utils.js +116 -0
- package/dist/server/cache/utils.js.map +1 -0
- package/dist/server/core.d.ts +43 -0
- package/dist/server/core.d.ts.map +1 -0
- package/dist/server/core.js +215 -0
- package/dist/server/core.js.map +1 -0
- package/dist/server/operation-registry.d.ts +9 -0
- package/dist/server/operation-registry.d.ts.map +1 -0
- package/dist/server/operation-registry.js +16 -0
- package/dist/server/operation-registry.js.map +1 -0
- package/dist/server/param-aliases.d.ts +40 -0
- package/dist/server/param-aliases.d.ts.map +1 -0
- package/dist/server/param-aliases.js +112 -0
- package/dist/server/param-aliases.js.map +1 -0
- package/dist/server/rate-limit/index.d.ts +2 -0
- package/dist/server/rate-limit/index.d.ts.map +1 -0
- package/dist/server/rate-limit/index.js +2 -0
- package/dist/server/rate-limit/index.js.map +1 -0
- package/dist/server/rate-limit/utils.d.ts +27 -0
- package/dist/server/rate-limit/utils.d.ts.map +1 -0
- package/dist/server/rate-limit/utils.js +126 -0
- package/dist/server/rate-limit/utils.js.map +1 -0
- package/dist/server/routing.d.ts +39 -0
- package/dist/server/routing.d.ts.map +1 -0
- package/dist/server/routing.js +70 -0
- package/dist/server/routing.js.map +1 -0
- package/dist/server/token-limit/index.d.ts +2 -0
- package/dist/server/token-limit/index.d.ts.map +1 -0
- package/dist/server/token-limit/index.js +2 -0
- package/dist/server/token-limit/index.js.map +1 -0
- package/dist/server/token-limit/utils.d.ts +44 -0
- package/dist/server/token-limit/utils.d.ts.map +1 -0
- package/dist/server/token-limit/utils.js +260 -0
- package/dist/server/token-limit/utils.js.map +1 -0
- package/dist/server/tools.d.ts +33 -0
- package/dist/server/tools.d.ts.map +1 -0
- package/dist/server/tools.js +160 -0
- package/dist/server/tools.js.map +1 -0
- package/dist/server/transports.d.ts +25 -0
- package/dist/server/transports.d.ts.map +1 -0
- package/dist/server/transports.js +2 -0
- package/dist/server/transports.js.map +1 -0
- package/dist/shared/tools.d.ts +24 -0
- package/dist/shared/tools.d.ts.map +1 -0
- package/dist/shared/tools.js +86 -0
- package/dist/shared/tools.js.map +1 -0
- package/dist/spec/decorators.d.ts +41 -0
- package/dist/spec/decorators.d.ts.map +1 -0
- package/dist/spec/decorators.js +93 -0
- package/dist/spec/decorators.js.map +1 -0
- package/dist/spec/index.d.ts +3 -0
- package/dist/spec/index.d.ts.map +1 -0
- package/dist/spec/index.js +3 -0
- package/dist/spec/index.js.map +1 -0
- package/dist/spec/metadata.d.ts +5 -0
- package/dist/spec/metadata.d.ts.map +1 -0
- package/dist/spec/metadata.js +37 -0
- package/dist/spec/metadata.js.map +1 -0
- package/dist/types/client-route.d.ts +7 -0
- package/dist/types/client-route.d.ts.map +1 -0
- package/dist/types/client-route.js +2 -0
- package/dist/types/client-route.js.map +1 -0
- package/dist/types/client.d.ts +81 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/client.js +14 -0
- package/dist/types/client.js.map +1 -0
- package/dist/types/endpoints.d.ts +76 -0
- package/dist/types/endpoints.d.ts.map +1 -0
- package/dist/types/endpoints.js +2 -0
- package/dist/types/endpoints.js.map +1 -0
- package/dist/types/errors.d.ts +86 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/errors.js +153 -0
- package/dist/types/errors.js.map +1 -0
- package/dist/types/http.d.ts +80 -0
- package/dist/types/http.d.ts.map +1 -0
- package/dist/types/http.js +61 -0
- package/dist/types/http.js.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/openapi.d.ts +220 -0
- package/dist/types/openapi.d.ts.map +1 -0
- package/dist/types/openapi.js +11 -0
- package/dist/types/openapi.js.map +1 -0
- package/dist/types/opts.d.ts +46 -0
- package/dist/types/opts.d.ts.map +1 -0
- package/dist/types/opts.js +2 -0
- package/dist/types/opts.js.map +1 -0
- package/dist/types/plugins.d.ts +93 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/plugins.js +5 -0
- package/dist/types/plugins.js.map +1 -0
- package/dist/types/tools.d.ts +52 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +2 -0
- package/dist/types/tools.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { ClientRouteLike } from './client-route';
|
|
2
|
+
export interface ErrorPayload {
|
|
3
|
+
code?: string;
|
|
4
|
+
message?: string;
|
|
5
|
+
details?: unknown;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare class HttpError extends Error {
|
|
9
|
+
readonly statusCode: number;
|
|
10
|
+
readonly data?: any;
|
|
11
|
+
constructor(statusCode: number, message: string, data?: any);
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class HttpProxyError extends Error {
|
|
14
|
+
readonly route: ClientRouteLike | undefined;
|
|
15
|
+
readonly url: string;
|
|
16
|
+
readonly method: string;
|
|
17
|
+
readonly status: number | undefined;
|
|
18
|
+
readonly statusText: string | undefined;
|
|
19
|
+
readonly headers: Headers | undefined;
|
|
20
|
+
readonly bodyText: string | undefined;
|
|
21
|
+
readonly bodyJson: unknown;
|
|
22
|
+
readonly cause: unknown;
|
|
23
|
+
protected constructor(args: {
|
|
24
|
+
name: string;
|
|
25
|
+
message: string;
|
|
26
|
+
route?: ClientRouteLike;
|
|
27
|
+
url: string;
|
|
28
|
+
method: string;
|
|
29
|
+
status: number | undefined;
|
|
30
|
+
statusText: string | undefined;
|
|
31
|
+
headers: Headers | undefined;
|
|
32
|
+
bodyText: string | undefined;
|
|
33
|
+
bodyJson: unknown;
|
|
34
|
+
cause: unknown;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export declare class ClientError extends HttpProxyError {
|
|
38
|
+
readonly payload: ErrorPayload | undefined;
|
|
39
|
+
constructor(args: {
|
|
40
|
+
route?: ClientRouteLike;
|
|
41
|
+
url: string;
|
|
42
|
+
method: string;
|
|
43
|
+
status: number;
|
|
44
|
+
statusText: string;
|
|
45
|
+
headers: Headers;
|
|
46
|
+
bodyText: string | undefined;
|
|
47
|
+
bodyJson: unknown;
|
|
48
|
+
});
|
|
49
|
+
get isUnauthorized(): boolean;
|
|
50
|
+
get isForbidden(): boolean;
|
|
51
|
+
get isNotFound(): boolean;
|
|
52
|
+
get isConflict(): boolean;
|
|
53
|
+
get isUnprocessable(): boolean;
|
|
54
|
+
get isRateLimited(): boolean;
|
|
55
|
+
get retryAfterMs(): number | undefined;
|
|
56
|
+
}
|
|
57
|
+
export declare class ServerError extends HttpProxyError {
|
|
58
|
+
readonly payload: ErrorPayload | undefined;
|
|
59
|
+
constructor(args: {
|
|
60
|
+
route?: ClientRouteLike;
|
|
61
|
+
url: string;
|
|
62
|
+
method: string;
|
|
63
|
+
status: number;
|
|
64
|
+
statusText: string;
|
|
65
|
+
headers: Headers;
|
|
66
|
+
bodyText: string | undefined;
|
|
67
|
+
bodyJson: unknown;
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
export declare class NetworkError extends HttpProxyError {
|
|
71
|
+
constructor(args: {
|
|
72
|
+
route?: ClientRouteLike;
|
|
73
|
+
url: string;
|
|
74
|
+
method: string;
|
|
75
|
+
cause: unknown;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
export declare class TimeoutError extends HttpProxyError {
|
|
79
|
+
constructor(args: {
|
|
80
|
+
route?: ClientRouteLike;
|
|
81
|
+
url: string;
|
|
82
|
+
method: string;
|
|
83
|
+
cause: unknown;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AAED,qBAAa,YAAa,SAAQ,cAAc;gBAChC,IAAI,EAAE;QACd,KAAK,CAAC,EAAE,eAAe,CAAA;QACvB,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,OAAO,CAAA;KACjB;CAeJ;AAED,qBAAa,YAAa,SAAQ,cAAc;gBAChC,IAAI,EAAE;QACd,KAAK,CAAC,EAAE,eAAe,CAAA;QACvB,GAAG,EAAE,MAAM,CAAA;QACX,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,OAAO,CAAA;KACjB;CAeJ"}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
function asErrorPayload(value) {
|
|
2
|
+
if (!value || typeof value !== 'object')
|
|
3
|
+
return undefined;
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
function buildHttpErrorMessage(status, statusText, bodyJson, bodyText) {
|
|
7
|
+
const jsonMessage = bodyJson &&
|
|
8
|
+
typeof bodyJson === 'object' &&
|
|
9
|
+
'message' in bodyJson &&
|
|
10
|
+
typeof bodyJson.message === 'string'
|
|
11
|
+
? bodyJson.message
|
|
12
|
+
: undefined;
|
|
13
|
+
return jsonMessage || bodyText || `HTTP ${status} ${statusText}`;
|
|
14
|
+
}
|
|
15
|
+
export class HttpError extends Error {
|
|
16
|
+
statusCode;
|
|
17
|
+
data;
|
|
18
|
+
constructor(statusCode, message, data) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = 'HttpError';
|
|
21
|
+
this.statusCode = statusCode;
|
|
22
|
+
this.data = data;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export class HttpProxyError extends Error {
|
|
26
|
+
route;
|
|
27
|
+
url;
|
|
28
|
+
method;
|
|
29
|
+
status;
|
|
30
|
+
statusText;
|
|
31
|
+
headers;
|
|
32
|
+
bodyText;
|
|
33
|
+
bodyJson;
|
|
34
|
+
cause;
|
|
35
|
+
constructor(args) {
|
|
36
|
+
super(args.message, { cause: args.cause });
|
|
37
|
+
this.name = args.name;
|
|
38
|
+
this.route = args.route;
|
|
39
|
+
this.url = args.url;
|
|
40
|
+
this.method = args.method;
|
|
41
|
+
this.status = args.status;
|
|
42
|
+
this.statusText = args.statusText;
|
|
43
|
+
this.headers = args.headers;
|
|
44
|
+
this.bodyText = args.bodyText;
|
|
45
|
+
this.bodyJson = args.bodyJson;
|
|
46
|
+
this.cause = args.cause;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export class ClientError extends HttpProxyError {
|
|
50
|
+
payload;
|
|
51
|
+
constructor(args) {
|
|
52
|
+
super({
|
|
53
|
+
name: 'ClientError',
|
|
54
|
+
message: buildHttpErrorMessage(args.status, args.statusText, args.bodyJson, args.bodyText),
|
|
55
|
+
route: args.route,
|
|
56
|
+
url: args.url,
|
|
57
|
+
method: args.method,
|
|
58
|
+
status: args.status,
|
|
59
|
+
statusText: args.statusText,
|
|
60
|
+
headers: args.headers,
|
|
61
|
+
bodyText: args.bodyText,
|
|
62
|
+
bodyJson: args.bodyJson,
|
|
63
|
+
cause: undefined,
|
|
64
|
+
});
|
|
65
|
+
this.payload = asErrorPayload(args.bodyJson);
|
|
66
|
+
}
|
|
67
|
+
get isUnauthorized() {
|
|
68
|
+
return this.status === 401;
|
|
69
|
+
}
|
|
70
|
+
get isForbidden() {
|
|
71
|
+
return this.status === 403;
|
|
72
|
+
}
|
|
73
|
+
get isNotFound() {
|
|
74
|
+
return this.status === 404;
|
|
75
|
+
}
|
|
76
|
+
get isConflict() {
|
|
77
|
+
return this.status === 409;
|
|
78
|
+
}
|
|
79
|
+
get isUnprocessable() {
|
|
80
|
+
return this.status === 422;
|
|
81
|
+
}
|
|
82
|
+
get isRateLimited() {
|
|
83
|
+
return this.status === 429;
|
|
84
|
+
}
|
|
85
|
+
get retryAfterMs() {
|
|
86
|
+
const raw = this.headers?.get('retry-after');
|
|
87
|
+
if (!raw)
|
|
88
|
+
return undefined;
|
|
89
|
+
const seconds = Number(raw);
|
|
90
|
+
if (Number.isFinite(seconds)) {
|
|
91
|
+
return Math.max(0, seconds * 1000);
|
|
92
|
+
}
|
|
93
|
+
const dateMs = Date.parse(raw);
|
|
94
|
+
if (Number.isFinite(dateMs)) {
|
|
95
|
+
return Math.max(0, dateMs - Date.now());
|
|
96
|
+
}
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export class ServerError extends HttpProxyError {
|
|
101
|
+
payload;
|
|
102
|
+
constructor(args) {
|
|
103
|
+
super({
|
|
104
|
+
name: 'ServerError',
|
|
105
|
+
message: buildHttpErrorMessage(args.status, args.statusText, args.bodyJson, args.bodyText),
|
|
106
|
+
route: args.route,
|
|
107
|
+
url: args.url,
|
|
108
|
+
method: args.method,
|
|
109
|
+
status: args.status,
|
|
110
|
+
statusText: args.statusText,
|
|
111
|
+
headers: args.headers,
|
|
112
|
+
bodyText: args.bodyText,
|
|
113
|
+
bodyJson: args.bodyJson,
|
|
114
|
+
cause: undefined,
|
|
115
|
+
});
|
|
116
|
+
this.payload = asErrorPayload(args.bodyJson);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export class NetworkError extends HttpProxyError {
|
|
120
|
+
constructor(args) {
|
|
121
|
+
super({
|
|
122
|
+
name: 'NetworkError',
|
|
123
|
+
message: `Network error calling ${args.method} ${args.url}`,
|
|
124
|
+
route: args.route,
|
|
125
|
+
url: args.url,
|
|
126
|
+
method: args.method,
|
|
127
|
+
status: undefined,
|
|
128
|
+
statusText: undefined,
|
|
129
|
+
headers: undefined,
|
|
130
|
+
bodyText: undefined,
|
|
131
|
+
bodyJson: undefined,
|
|
132
|
+
cause: args.cause,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
export class TimeoutError extends HttpProxyError {
|
|
137
|
+
constructor(args) {
|
|
138
|
+
super({
|
|
139
|
+
name: 'TimeoutError',
|
|
140
|
+
message: `Timed out calling ${args.method} ${args.url}`,
|
|
141
|
+
route: args.route,
|
|
142
|
+
url: args.url,
|
|
143
|
+
method: args.method,
|
|
144
|
+
status: undefined,
|
|
145
|
+
statusText: undefined,
|
|
146
|
+
headers: undefined,
|
|
147
|
+
bodyText: undefined,
|
|
148
|
+
bodyJson: undefined,
|
|
149
|
+
cause: args.cause,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../typescript/src/types/errors.ts"],"names":[],"mappings":"AASA,SAAS,cAAc,CAAC,KAAc;IAClC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAA;IACzD,OAAO,KAAqB,CAAA;AAChC,CAAC;AAED,SAAS,qBAAqB,CAC1B,MAAc,EACd,UAAkB,EAClB,QAAkB,EAClB,QAAiB;IAEjB,MAAM,WAAW,GACb,QAAQ;QACR,OAAO,QAAQ,KAAK,QAAQ;QAC5B,SAAS,IAAI,QAAQ;QACrB,OAAQ,QAAgB,CAAC,OAAO,KAAK,QAAQ;QACzC,CAAC,CAAE,QAAgB,CAAC,OAAO;QAC3B,CAAC,CAAC,SAAS,CAAA;IAEnB,OAAO,WAAW,IAAI,QAAQ,IAAI,QAAQ,MAAM,IAAI,UAAU,EAAE,CAAA;AACpE,CAAC;AAED,MAAM,OAAO,SAAU,SAAQ,KAAK;IACvB,UAAU,CAAQ;IAClB,IAAI,CAAM;IAEnB,YAAY,UAAkB,EAAE,OAAe,EAAE,IAAU;QACvD,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,WAAW,CAAA;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IACpB,CAAC;CACJ;AAGD,MAAM,OAAgB,cAAe,SAAQ,KAAK;IACrC,KAAK,CAA6B;IA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K;SACpB,CAAC,CAAA;IACN,CAAC;CACJ;AAED,MAAM,OAAO,YAAa,SAAQ,cAAc;IAC5C,YAAY,IAKX;QACG,KAAK,CAAC;YACF,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,qBAAqB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,GAAG,EAAE;YACvD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,SAAS;YAClB,QAAQ,EAAE,SAAS;YACnB,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SACpB,CAAC,CAAA;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** A header value that will be auto-coerced to a string at request time. */
|
|
2
|
+
export type HeaderValue = string | number | boolean;
|
|
3
|
+
/** Common MIME types for Content-Type / Accept headers. */
|
|
4
|
+
export declare const ContentTypes: {
|
|
5
|
+
readonly JSON: "application/json";
|
|
6
|
+
readonly FORM: "application/x-www-form-urlencoded";
|
|
7
|
+
readonly MULTIPART: "multipart/form-data";
|
|
8
|
+
readonly TEXT: "text/plain";
|
|
9
|
+
readonly HTML: "text/html";
|
|
10
|
+
readonly CSV: "text/csv";
|
|
11
|
+
readonly XML: "application/xml";
|
|
12
|
+
readonly BINARY: "application/octet-stream";
|
|
13
|
+
};
|
|
14
|
+
export type ContentType = typeof ContentTypes[keyof typeof ContentTypes];
|
|
15
|
+
export type ContentTypeValue = ContentType | (string & {});
|
|
16
|
+
/** Common authorization schemes. */
|
|
17
|
+
export declare const AuthSchemes: {
|
|
18
|
+
readonly BEARER: "Bearer";
|
|
19
|
+
readonly BASIC: "Basic";
|
|
20
|
+
};
|
|
21
|
+
export type AuthScheme = typeof AuthSchemes[keyof typeof AuthSchemes];
|
|
22
|
+
export type AuthorizationValue = `${AuthScheme} ${string}` | (string & {});
|
|
23
|
+
/** Common Cache-Control directives. */
|
|
24
|
+
export declare const CacheDirectives: {
|
|
25
|
+
readonly NO_CACHE: "no-cache";
|
|
26
|
+
readonly NO_STORE: "no-store";
|
|
27
|
+
readonly NO_TRANSFORM: "no-transform";
|
|
28
|
+
readonly MAX_AGE_0: "max-age=0";
|
|
29
|
+
};
|
|
30
|
+
export type CacheDirective = typeof CacheDirectives[keyof typeof CacheDirectives];
|
|
31
|
+
export type CacheControlValue = CacheDirective | `max-age=${number}` | (string & {});
|
|
32
|
+
/** Well-known HTTP headers with narrowed value types. */
|
|
33
|
+
export interface WellKnownHeaders {
|
|
34
|
+
'Content-Type'?: ContentTypeValue;
|
|
35
|
+
'Accept'?: ContentTypeValue;
|
|
36
|
+
'Authorization'?: AuthorizationValue;
|
|
37
|
+
'Cache-Control'?: CacheControlValue;
|
|
38
|
+
'If-None-Match'?: string;
|
|
39
|
+
'If-Modified-Since'?: string;
|
|
40
|
+
'X-Request-ID'?: string;
|
|
41
|
+
[key: string]: HeaderValue | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Typed HTTP headers: well-known headers get narrowed value types,
|
|
45
|
+
* custom headers (TCustom) are merged in, and any unknown header
|
|
46
|
+
* falls back to HeaderValue.
|
|
47
|
+
*/
|
|
48
|
+
export type TypedHeaders<TCustom extends Record<string, HeaderValue | undefined> = {}> = WellKnownHeaders & TCustom & Record<string, HeaderValue | undefined>;
|
|
49
|
+
export declare const HttpMethods: {
|
|
50
|
+
readonly GET: "GET";
|
|
51
|
+
readonly POST: "POST";
|
|
52
|
+
readonly PUT: "PUT";
|
|
53
|
+
readonly PATCH: "PATCH";
|
|
54
|
+
readonly DELETE: "DELETE";
|
|
55
|
+
};
|
|
56
|
+
export type HttpMethod = typeof HttpMethods[keyof typeof HttpMethods];
|
|
57
|
+
/** Property names reserved by the OpenAPIClient proxy system. */
|
|
58
|
+
export declare const ProxyProps: {
|
|
59
|
+
readonly ROOT: "root";
|
|
60
|
+
readonly CLIENT: "client";
|
|
61
|
+
readonly SPEC: "spec";
|
|
62
|
+
readonly ROUTES: "routes";
|
|
63
|
+
readonly CHILDREN: "children";
|
|
64
|
+
readonly THEN: "then";
|
|
65
|
+
};
|
|
66
|
+
export type ProxyProp = typeof ProxyProps[keyof typeof ProxyProps];
|
|
67
|
+
/** OpenAPI parameter location values. */
|
|
68
|
+
export declare const ParamLocations: {
|
|
69
|
+
readonly QUERY: "query";
|
|
70
|
+
readonly PATH: "path";
|
|
71
|
+
readonly HEADER: "header";
|
|
72
|
+
readonly COOKIE: "cookie";
|
|
73
|
+
};
|
|
74
|
+
export type ParamLocation = typeof ParamLocations[keyof typeof ParamLocations];
|
|
75
|
+
/**
|
|
76
|
+
* All names reserved by the OpenAPIClient and its proxy system.
|
|
77
|
+
* The plat server should reject routes/methods whose names collide with these.
|
|
78
|
+
*/
|
|
79
|
+
export declare const RESERVED_ROUTE_NAMES: readonly string[];
|
|
80
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../typescript/src/types/http.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;AAEnD,2DAA2D;AAC3D,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AACX,MAAM,MAAM,WAAW,GAAG,OAAO,YAAY,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AACzE,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAA;AAE1D,oCAAoC;AACpC,eAAO,MAAM,WAAW;;;CAGd,CAAC;AACX,MAAM,MAAM,UAAU,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AACtE,MAAM,MAAM,kBAAkB,GAAG,GAAG,U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cAAc,CAAC,MAAM,OAAO,cAAc,CAAC,CAAC;AAE/E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EAOxC,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// ── Header types ──────────────────────────────────────────
|
|
2
|
+
/** Common MIME types for Content-Type / Accept headers. */
|
|
3
|
+
export const ContentTypes = {
|
|
4
|
+
JSON: 'application/json',
|
|
5
|
+
FORM: 'application/x-www-form-urlencoded',
|
|
6
|
+
MULTIPART: 'multipart/form-data',
|
|
7
|
+
TEXT: 'text/plain',
|
|
8
|
+
HTML: 'text/html',
|
|
9
|
+
CSV: 'text/csv',
|
|
10
|
+
XML: 'application/xml',
|
|
11
|
+
BINARY: 'application/octet-stream',
|
|
12
|
+
};
|
|
13
|
+
/** Common authorization schemes. */
|
|
14
|
+
export const AuthSchemes = {
|
|
15
|
+
BEARER: 'Bearer',
|
|
16
|
+
BASIC: 'Basic',
|
|
17
|
+
};
|
|
18
|
+
/** Common Cache-Control directives. */
|
|
19
|
+
export const CacheDirectives = {
|
|
20
|
+
NO_CACHE: 'no-cache',
|
|
21
|
+
NO_STORE: 'no-store',
|
|
22
|
+
NO_TRANSFORM: 'no-transform',
|
|
23
|
+
MAX_AGE_0: 'max-age=0',
|
|
24
|
+
};
|
|
25
|
+
// ── HTTP methods ──────────────────────────────────────────
|
|
26
|
+
export const HttpMethods = {
|
|
27
|
+
GET: 'GET',
|
|
28
|
+
POST: 'POST',
|
|
29
|
+
PUT: 'PUT',
|
|
30
|
+
PATCH: 'PATCH',
|
|
31
|
+
DELETE: 'DELETE',
|
|
32
|
+
};
|
|
33
|
+
/** Property names reserved by the OpenAPIClient proxy system. */
|
|
34
|
+
export const ProxyProps = {
|
|
35
|
+
ROOT: 'root',
|
|
36
|
+
CLIENT: 'client',
|
|
37
|
+
SPEC: 'spec',
|
|
38
|
+
ROUTES: 'routes',
|
|
39
|
+
CHILDREN: 'children',
|
|
40
|
+
THEN: 'then',
|
|
41
|
+
};
|
|
42
|
+
/** OpenAPI parameter location values. */
|
|
43
|
+
export const ParamLocations = {
|
|
44
|
+
QUERY: 'query',
|
|
45
|
+
PATH: 'path',
|
|
46
|
+
HEADER: 'header',
|
|
47
|
+
COOKIE: 'cookie',
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* All names reserved by the OpenAPIClient and its proxy system.
|
|
51
|
+
* The plat server should reject routes/methods whose names collide with these.
|
|
52
|
+
*/
|
|
53
|
+
export const RESERVED_ROUTE_NAMES = [
|
|
54
|
+
...Object.values(ProxyProps),
|
|
55
|
+
...Object.values(HttpMethods).map(m => m.toLowerCase()),
|
|
56
|
+
// Native function properties that the proxy falls through to
|
|
57
|
+
'bind', 'call', 'apply', 'toString', 'valueOf',
|
|
58
|
+
'constructor', 'prototype', 'length', 'name',
|
|
59
|
+
'tools', 'buildHeaders',
|
|
60
|
+
];
|
|
61
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../typescript/src/types/http.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAK7D,2DAA2D;AAC3D,MAAM,CAAC,MAAM,YAAY,GAAG;IACxB,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,mCAAmC;IACzC,SAAS,EAAE,qBAAqB;IAChC,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;IACf,GAAG,EAAE,iBAAiB;IACtB,MAAM,EAAE,0BAA0B;CAC5B,CAAC;AAIX,oCAAoC;AACpC,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;CACR,CAAC;AAIX,uCAAuC;AACvC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,QAAQ,EAAE,UAAU;IACpB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;CAChB,CAAC;AAwBX,6DAA6D;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,QAAQ;CACV,CAAC;AAGX,iEAAiE;AACjE,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;CACN,CAAC;AAGX,yCAAyC;AACzC,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;CACV,CAAC;AAGX;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAsB;IACnD,GAAG,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;IAC5B,GAAG,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACvD,6DAA6D;IAC7D,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS;IAC9C,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM;IAC5C,OAAO,EAAE,cAAc;CACjB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './client';
|
|
2
|
+
export * from './client-route';
|
|
3
|
+
export * from './endpoints';
|
|
4
|
+
export * from './errors';
|
|
5
|
+
export * from './http';
|
|
6
|
+
export * from './openapi';
|
|
7
|
+
export * from './opts';
|
|
8
|
+
export * from './plugins';
|
|
9
|
+
export * from './tools';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../typescript/src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './client.js';
|
|
2
|
+
export * from './client-route.js';
|
|
3
|
+
export * from './endpoints.js';
|
|
4
|
+
export * from './errors.js';
|
|
5
|
+
export * from './http.js';
|
|
6
|
+
export * from './openapi.js';
|
|
7
|
+
export * from './opts.js';
|
|
8
|
+
export * from './plugins.js';
|
|
9
|
+
export * from './tools.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../typescript/src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,aAAa,CAAA;AAC3B,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenAPI 3.x spec type definitions.
|
|
3
|
+
*
|
|
4
|
+
* Every piece of the spec has its own exported interface so that
|
|
5
|
+
* consumers can reference exactly the part they need.
|
|
6
|
+
*
|
|
7
|
+
* Designed to work with both wide types (plain objects) and narrow
|
|
8
|
+
* `as const` literals for full type-level inference.
|
|
9
|
+
*/
|
|
10
|
+
export interface OpenAPISchema {
|
|
11
|
+
readonly type?: string;
|
|
12
|
+
readonly format?: string;
|
|
13
|
+
readonly enum?: readonly (string | number | boolean)[];
|
|
14
|
+
readonly const?: string | number | boolean;
|
|
15
|
+
readonly properties?: Readonly<Record<string, OpenAPISchema>>;
|
|
16
|
+
readonly required?: readonly string[];
|
|
17
|
+
readonly additionalProperties?: boolean | OpenAPISchema;
|
|
18
|
+
readonly items?: OpenAPISchema;
|
|
19
|
+
readonly prefixItems?: readonly OpenAPISchema[];
|
|
20
|
+
readonly minItems?: number;
|
|
21
|
+
readonly maxItems?: number;
|
|
22
|
+
readonly uniqueItems?: boolean;
|
|
23
|
+
readonly minimum?: number;
|
|
24
|
+
readonly maximum?: number;
|
|
25
|
+
readonly exclusiveMinimum?: number | boolean;
|
|
26
|
+
readonly exclusiveMaximum?: number | boolean;
|
|
27
|
+
readonly multipleOf?: number;
|
|
28
|
+
readonly minLength?: number;
|
|
29
|
+
readonly maxLength?: number;
|
|
30
|
+
readonly pattern?: string;
|
|
31
|
+
readonly default?: unknown;
|
|
32
|
+
readonly examples?: readonly unknown[];
|
|
33
|
+
readonly description?: string;
|
|
34
|
+
readonly title?: string;
|
|
35
|
+
readonly nullable?: boolean;
|
|
36
|
+
readonly readOnly?: boolean;
|
|
37
|
+
readonly writeOnly?: boolean;
|
|
38
|
+
readonly deprecated?: boolean;
|
|
39
|
+
readonly $ref?: string;
|
|
40
|
+
readonly allOf?: readonly OpenAPISchema[];
|
|
41
|
+
readonly oneOf?: readonly OpenAPISchema[];
|
|
42
|
+
readonly anyOf?: readonly OpenAPISchema[];
|
|
43
|
+
readonly not?: OpenAPISchema;
|
|
44
|
+
readonly discriminator?: OpenAPIDiscriminator;
|
|
45
|
+
}
|
|
46
|
+
export interface OpenAPIDiscriminator {
|
|
47
|
+
readonly propertyName: string;
|
|
48
|
+
readonly mapping?: Readonly<Record<string, string>>;
|
|
49
|
+
}
|
|
50
|
+
export interface OpenAPIParameter {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly in: 'query' | 'path' | 'header' | 'cookie' | string;
|
|
53
|
+
readonly required?: boolean;
|
|
54
|
+
readonly deprecated?: boolean;
|
|
55
|
+
readonly description?: string;
|
|
56
|
+
readonly schema?: OpenAPISchema;
|
|
57
|
+
readonly style?: string;
|
|
58
|
+
readonly explode?: boolean;
|
|
59
|
+
readonly example?: unknown;
|
|
60
|
+
readonly examples?: Readonly<Record<string, OpenAPIExample>>;
|
|
61
|
+
}
|
|
62
|
+
export interface OpenAPIExample {
|
|
63
|
+
readonly summary?: string;
|
|
64
|
+
readonly description?: string;
|
|
65
|
+
readonly value?: unknown;
|
|
66
|
+
readonly externalValue?: string;
|
|
67
|
+
}
|
|
68
|
+
export interface OpenAPIRequestBody {
|
|
69
|
+
readonly description?: string;
|
|
70
|
+
readonly required?: boolean;
|
|
71
|
+
readonly content: Readonly<Record<string, OpenAPIMediaType>>;
|
|
72
|
+
}
|
|
73
|
+
export interface OpenAPIMediaType {
|
|
74
|
+
readonly schema?: OpenAPISchema;
|
|
75
|
+
readonly example?: unknown;
|
|
76
|
+
readonly examples?: Readonly<Record<string, OpenAPIExample>>;
|
|
77
|
+
readonly encoding?: Readonly<Record<string, OpenAPIEncoding>>;
|
|
78
|
+
}
|
|
79
|
+
export interface OpenAPIEncoding {
|
|
80
|
+
readonly contentType?: string;
|
|
81
|
+
readonly headers?: Readonly<Record<string, OpenAPIHeader>>;
|
|
82
|
+
readonly style?: string;
|
|
83
|
+
readonly explode?: boolean;
|
|
84
|
+
readonly allowReserved?: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface OpenAPIResponse {
|
|
87
|
+
readonly description?: string;
|
|
88
|
+
readonly headers?: Readonly<Record<string, OpenAPIHeader>>;
|
|
89
|
+
readonly content?: Readonly<Record<string, OpenAPIMediaType>>;
|
|
90
|
+
readonly links?: Readonly<Record<string, OpenAPILink>>;
|
|
91
|
+
}
|
|
92
|
+
export interface OpenAPIHeader {
|
|
93
|
+
readonly description?: string;
|
|
94
|
+
readonly required?: boolean;
|
|
95
|
+
readonly deprecated?: boolean;
|
|
96
|
+
readonly schema?: OpenAPISchema;
|
|
97
|
+
}
|
|
98
|
+
export interface OpenAPILink {
|
|
99
|
+
readonly operationRef?: string;
|
|
100
|
+
readonly operationId?: string;
|
|
101
|
+
readonly parameters?: Readonly<Record<string, unknown>>;
|
|
102
|
+
readonly requestBody?: unknown;
|
|
103
|
+
readonly description?: string;
|
|
104
|
+
readonly server?: OpenAPIServer;
|
|
105
|
+
}
|
|
106
|
+
export interface OpenAPIOperation {
|
|
107
|
+
readonly operationId?: string;
|
|
108
|
+
readonly summary?: string;
|
|
109
|
+
readonly description?: string;
|
|
110
|
+
readonly tags?: readonly string[];
|
|
111
|
+
readonly deprecated?: boolean;
|
|
112
|
+
readonly parameters?: readonly OpenAPIParameter[];
|
|
113
|
+
readonly requestBody?: OpenAPIRequestBody;
|
|
114
|
+
readonly responses: Readonly<Record<string, OpenAPIResponse>>;
|
|
115
|
+
readonly security?: readonly OpenAPISecurityRequirement[];
|
|
116
|
+
readonly servers?: readonly OpenAPIServer[];
|
|
117
|
+
readonly callbacks?: Readonly<Record<string, OpenAPIPathItem>>;
|
|
118
|
+
readonly externalDocs?: OpenAPIExternalDocs;
|
|
119
|
+
}
|
|
120
|
+
export interface OpenAPIPathItem {
|
|
121
|
+
readonly summary?: string;
|
|
122
|
+
readonly description?: string;
|
|
123
|
+
readonly get?: OpenAPIOperation;
|
|
124
|
+
readonly post?: OpenAPIOperation;
|
|
125
|
+
readonly put?: OpenAPIOperation;
|
|
126
|
+
readonly patch?: OpenAPIOperation;
|
|
127
|
+
readonly delete?: OpenAPIOperation;
|
|
128
|
+
readonly options?: OpenAPIOperation;
|
|
129
|
+
readonly head?: OpenAPIOperation;
|
|
130
|
+
readonly trace?: OpenAPIOperation;
|
|
131
|
+
readonly parameters?: readonly OpenAPIParameter[];
|
|
132
|
+
readonly servers?: readonly OpenAPIServer[];
|
|
133
|
+
}
|
|
134
|
+
export interface OpenAPIComponents {
|
|
135
|
+
readonly schemas?: Readonly<Record<string, OpenAPISchema>>;
|
|
136
|
+
readonly responses?: Readonly<Record<string, OpenAPIResponse>>;
|
|
137
|
+
readonly parameters?: Readonly<Record<string, OpenAPIParameter>>;
|
|
138
|
+
readonly examples?: Readonly<Record<string, OpenAPIExample>>;
|
|
139
|
+
readonly requestBodies?: Readonly<Record<string, OpenAPIRequestBody>>;
|
|
140
|
+
readonly headers?: Readonly<Record<string, OpenAPIHeader>>;
|
|
141
|
+
readonly securitySchemes?: Readonly<Record<string, OpenAPISecurityScheme>>;
|
|
142
|
+
readonly links?: Readonly<Record<string, OpenAPILink>>;
|
|
143
|
+
readonly callbacks?: Readonly<Record<string, OpenAPIPathItem>>;
|
|
144
|
+
readonly pathItems?: Readonly<Record<string, OpenAPIPathItem>>;
|
|
145
|
+
}
|
|
146
|
+
export interface OpenAPISecurityScheme {
|
|
147
|
+
readonly type: 'apiKey' | 'http' | 'oauth2' | 'openIdConnect' | string;
|
|
148
|
+
readonly description?: string;
|
|
149
|
+
readonly name?: string;
|
|
150
|
+
readonly in?: 'query' | 'header' | 'cookie' | string;
|
|
151
|
+
readonly scheme?: string;
|
|
152
|
+
readonly bearerFormat?: string;
|
|
153
|
+
readonly flows?: OpenAPIOAuthFlows;
|
|
154
|
+
readonly openIdConnectUrl?: string;
|
|
155
|
+
}
|
|
156
|
+
export interface OpenAPIOAuthFlows {
|
|
157
|
+
readonly implicit?: OpenAPIOAuthFlow;
|
|
158
|
+
readonly password?: OpenAPIOAuthFlow;
|
|
159
|
+
readonly clientCredentials?: OpenAPIOAuthFlow;
|
|
160
|
+
readonly authorizationCode?: OpenAPIOAuthFlow;
|
|
161
|
+
}
|
|
162
|
+
export interface OpenAPIOAuthFlow {
|
|
163
|
+
readonly authorizationUrl?: string;
|
|
164
|
+
readonly tokenUrl?: string;
|
|
165
|
+
readonly refreshUrl?: string;
|
|
166
|
+
readonly scopes: Readonly<Record<string, string>>;
|
|
167
|
+
}
|
|
168
|
+
export type OpenAPISecurityRequirement = Readonly<Record<string, readonly string[]>>;
|
|
169
|
+
export interface OpenAPIInfo {
|
|
170
|
+
readonly title: string;
|
|
171
|
+
readonly version: string;
|
|
172
|
+
readonly description?: string;
|
|
173
|
+
readonly termsOfService?: string;
|
|
174
|
+
readonly contact?: OpenAPIContact;
|
|
175
|
+
readonly license?: OpenAPILicense;
|
|
176
|
+
readonly summary?: string;
|
|
177
|
+
}
|
|
178
|
+
export interface OpenAPIContact {
|
|
179
|
+
readonly name?: string;
|
|
180
|
+
readonly url?: string;
|
|
181
|
+
readonly email?: string;
|
|
182
|
+
}
|
|
183
|
+
export interface OpenAPILicense {
|
|
184
|
+
readonly name: string;
|
|
185
|
+
readonly identifier?: string;
|
|
186
|
+
readonly url?: string;
|
|
187
|
+
}
|
|
188
|
+
export interface OpenAPIServer {
|
|
189
|
+
readonly url: string;
|
|
190
|
+
readonly description?: string;
|
|
191
|
+
readonly variables?: Readonly<Record<string, OpenAPIServerVariable>>;
|
|
192
|
+
}
|
|
193
|
+
export interface OpenAPIServerVariable {
|
|
194
|
+
readonly enum?: readonly string[];
|
|
195
|
+
readonly default: string;
|
|
196
|
+
readonly description?: string;
|
|
197
|
+
}
|
|
198
|
+
export interface OpenAPIExternalDocs {
|
|
199
|
+
readonly url: string;
|
|
200
|
+
readonly description?: string;
|
|
201
|
+
}
|
|
202
|
+
export interface OpenAPITag {
|
|
203
|
+
readonly name: string;
|
|
204
|
+
readonly description?: string;
|
|
205
|
+
readonly externalDocs?: OpenAPIExternalDocs;
|
|
206
|
+
}
|
|
207
|
+
/** Full OpenAPI 3.x specification */
|
|
208
|
+
export interface OpenAPISpec {
|
|
209
|
+
readonly openapi: string;
|
|
210
|
+
readonly info: OpenAPIInfo;
|
|
211
|
+
readonly jsonSchemaDialect?: string;
|
|
212
|
+
readonly servers?: readonly OpenAPIServer[];
|
|
213
|
+
readonly paths?: Readonly<Record<string, OpenAPIPathItem>>;
|
|
214
|
+
readonly webhooks?: Readonly<Record<string, OpenAPIPathItem>>;
|
|
215
|
+
readonly components?: OpenAPIComponents;
|
|
216
|
+
readonly security?: readonly OpenAPISecurityRequirement[];
|
|
217
|
+
readonly tags?: readonly OpenAPITag[];
|
|
218
|
+
readonly externalDocs?: OpenAPIExternalDocs;
|
|
219
|
+
}
|
|
220
|
+
//# sourceMappingURL=openapi.d.ts.map
|