@temporary-name/server 1.9.3-alpha.8026644f8b8b29ec5943323a4b1a32713d47dfd2 → 1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8
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/adapters/aws-lambda/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +4 -6
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -6
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -6
- package/dist/adapters/standard/index.d.mts +20 -31
- package/dist/adapters/standard/index.d.ts +20 -31
- package/dist/adapters/standard/index.mjs +4 -6
- package/dist/index.d.mts +69 -339
- package/dist/index.d.ts +69 -339
- package/dist/index.mjs +132 -357
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +60 -77
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.BSJugGGA.d.mts} +1 -2
- package/dist/shared/{server.SLLuK6_v.d.ts → server.Bs8EZATl.d.ts} +2 -2
- package/dist/shared/server.CHV9AQHl.mjs +412 -0
- package/dist/shared/server.CWWP8ypC.d.mts +239 -0
- package/dist/shared/server.CWWP8ypC.d.ts +239 -0
- package/dist/shared/{server.DLsti1Pv.mjs → server.Cn7WsRHl.mjs} +56 -95
- package/dist/shared/{server.BeuTpcmO.d.mts → server.DrMgIiBr.d.mts} +2 -2
- package/dist/shared/{server.C1fnTLq0.d.mts → server.EKwDe0d2.d.ts} +1 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
- package/package.json +10 -9
- package/dist/shared/server.BKSOrA6h.d.mts +0 -192
- package/dist/shared/server.BKSOrA6h.d.ts +0 -192
- package/dist/shared/server.BKh8I1Ny.mjs +0 -239
|
@@ -1,67 +1,37 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stringifyJSON, isObject, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { flattenHeader } from '@temporary-name/standard-server';
|
|
3
|
-
import { c as createProcedureClient } from './server.
|
|
4
|
-
import { fallbackContractConfig } from '@temporary-name/contract';
|
|
5
|
-
import { d as deserialize,
|
|
3
|
+
import { c as createProcedureClient } from './server.CHV9AQHl.mjs';
|
|
4
|
+
import { fallbackContractConfig, standardizeHTTPPath } from '@temporary-name/contract';
|
|
5
|
+
import { d as deserialize, b as bracketNotationDeserialize, s as serialize } from './server.JtIZ8YG7.mjs';
|
|
6
6
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
7
7
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return data;
|
|
29
|
-
}
|
|
30
|
-
const deserializeSearchParams = () => {
|
|
31
|
-
return deserialize(request.url.searchParams);
|
|
32
|
-
};
|
|
9
|
+
async function decode(request, pathParams) {
|
|
10
|
+
return {
|
|
11
|
+
path: pathParams ?? {},
|
|
12
|
+
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
13
|
+
headers: request.headers,
|
|
14
|
+
body: deserialize(await request.body()) ?? {}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function encode(output, procedure) {
|
|
18
|
+
const successStatus = fallbackContractConfig(
|
|
19
|
+
"defaultSuccessStatus",
|
|
20
|
+
procedure["~orpc"].route.successStatus
|
|
21
|
+
);
|
|
22
|
+
const outputStructure = fallbackContractConfig(
|
|
23
|
+
"defaultOutputStructure",
|
|
24
|
+
procedure["~orpc"].route.outputStructure
|
|
25
|
+
);
|
|
26
|
+
if (outputStructure === "compact") {
|
|
33
27
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
38
|
-
return value;
|
|
39
|
-
},
|
|
40
|
-
set query(value) {
|
|
41
|
-
Object.defineProperty(this, "query", { value, writable: true });
|
|
42
|
-
},
|
|
43
|
-
headers: request.headers,
|
|
44
|
-
body: deserialize(await request.body())
|
|
28
|
+
status: successStatus,
|
|
29
|
+
headers: {},
|
|
30
|
+
body: serialize(output)
|
|
45
31
|
};
|
|
46
32
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"defaultSuccessStatus",
|
|
50
|
-
procedure["~orpc"].route.successStatus
|
|
51
|
-
);
|
|
52
|
-
const outputStructure = fallbackContractConfig(
|
|
53
|
-
"defaultOutputStructure",
|
|
54
|
-
procedure["~orpc"].route.outputStructure
|
|
55
|
-
);
|
|
56
|
-
if (outputStructure === "compact") {
|
|
57
|
-
return {
|
|
58
|
-
status: successStatus,
|
|
59
|
-
headers: {},
|
|
60
|
-
body: serialize(output)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
if (!this.#isDetailedOutput(output)) {
|
|
64
|
-
throw new Error(`
|
|
33
|
+
if (!isDetailedOutput(output)) {
|
|
34
|
+
throw new Error(`
|
|
65
35
|
Invalid "detailed" output structure:
|
|
66
36
|
\u2022 Expected an object with optional properties:
|
|
67
37
|
- status (number 200-399)
|
|
@@ -72,32 +42,31 @@ class StandardOpenAPICodec {
|
|
|
72
42
|
Actual value:
|
|
73
43
|
${stringifyJSON(output)}
|
|
74
44
|
`);
|
|
75
|
-
}
|
|
76
|
-
return {
|
|
77
|
-
status: output.status ?? successStatus,
|
|
78
|
-
headers: output.headers ?? {},
|
|
79
|
-
body: serialize(output.body)
|
|
80
|
-
};
|
|
81
45
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
46
|
+
return {
|
|
47
|
+
status: output.status ?? successStatus,
|
|
48
|
+
headers: output.headers ?? {},
|
|
49
|
+
body: serialize(output.body)
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function encodeError(error) {
|
|
53
|
+
return {
|
|
54
|
+
status: error.status,
|
|
55
|
+
headers: {},
|
|
56
|
+
body: serialize(error.toJSON(), { outputFormat: "plain" })
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function isDetailedOutput(output) {
|
|
60
|
+
if (!isObject(output)) {
|
|
61
|
+
return false;
|
|
88
62
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
63
|
+
if (output.headers && !isObject(output.headers)) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
|
|
67
|
+
return false;
|
|
100
68
|
}
|
|
69
|
+
return true;
|
|
101
70
|
}
|
|
102
71
|
|
|
103
72
|
function resolveFriendlyStandardHandleOptions(options) {
|
|
@@ -121,9 +90,6 @@ class StandardOpenAPIMatcher {
|
|
|
121
90
|
pendingRouters = [];
|
|
122
91
|
init(router, path = []) {
|
|
123
92
|
const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
|
|
124
|
-
if (!value(true, traverseOptions)) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
93
|
const { path: path2, contract } = traverseOptions;
|
|
128
94
|
const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
|
|
129
95
|
const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
|
|
@@ -204,10 +170,8 @@ class StandardHandler {
|
|
|
204
170
|
clientInterceptors;
|
|
205
171
|
rootInterceptors;
|
|
206
172
|
matcher;
|
|
207
|
-
codec;
|
|
208
173
|
constructor(router, options) {
|
|
209
174
|
this.matcher = new StandardOpenAPIMatcher();
|
|
210
|
-
this.codec = new StandardOpenAPICodec();
|
|
211
175
|
const plugins = new CompositeStandardHandlerPlugin(options.plugins);
|
|
212
176
|
plugins.init(options, router);
|
|
213
177
|
this.interceptors = toArray(options.interceptors);
|
|
@@ -242,15 +206,12 @@ class StandardHandler {
|
|
|
242
206
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
243
207
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
244
208
|
step = "decode_input";
|
|
245
|
-
|
|
246
|
-
{ name: "decode_input" },
|
|
247
|
-
() => this.codec.decode(request2, match.params, match.procedure)
|
|
248
|
-
);
|
|
209
|
+
const input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
|
|
249
210
|
step = void 0;
|
|
250
|
-
if (isAsyncIteratorObject(input)) {
|
|
251
|
-
input = asyncIteratorWithSpan(
|
|
211
|
+
if (isAsyncIteratorObject(input.body)) {
|
|
212
|
+
input.body = asyncIteratorWithSpan(
|
|
252
213
|
{ name: "consume_event_iterator_input", signal: request2.signal },
|
|
253
|
-
input
|
|
214
|
+
input.body
|
|
254
215
|
);
|
|
255
216
|
}
|
|
256
217
|
const client = createProcedureClient(match.procedure, {
|
|
@@ -264,7 +225,7 @@ class StandardHandler {
|
|
|
264
225
|
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
|
265
226
|
});
|
|
266
227
|
step = void 0;
|
|
267
|
-
const response =
|
|
228
|
+
const response = encode(output, match.procedure);
|
|
268
229
|
return {
|
|
269
230
|
matched: true,
|
|
270
231
|
response
|
|
@@ -279,7 +240,7 @@ class StandardHandler {
|
|
|
279
240
|
message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
|
|
280
241
|
cause: e
|
|
281
242
|
}) : toORPCError(e);
|
|
282
|
-
const response =
|
|
243
|
+
const response = encodeError(error);
|
|
283
244
|
return {
|
|
284
245
|
matched: true,
|
|
285
246
|
response
|
|
@@ -290,4 +251,4 @@ class StandardHandler {
|
|
|
290
251
|
}
|
|
291
252
|
}
|
|
292
253
|
|
|
293
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as S,
|
|
254
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, encodeError as a, StandardOpenAPIMatcher as b, decodeParams as c, decode as d, encode as e, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
-
import { C as Context } from './server.
|
|
3
|
-
import { c as StandardHandleOptions } from './server.
|
|
2
|
+
import { C as Context } from './server.CWWP8ypC.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.BSJugGGA.mjs';
|
|
4
4
|
|
|
5
5
|
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
6
|
context?: T;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
2
|
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
3
|
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
|
|
4
|
-
import { C as Context, R as Router,
|
|
4
|
+
import { C as Context, R as Router, G as ProcedureClientInterceptorOptions } from './server.CWWP8ypC.js';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -48,7 +48,6 @@ declare class StandardHandler<T extends Context> {
|
|
|
48
48
|
private readonly clientInterceptors;
|
|
49
49
|
private readonly rootInterceptors;
|
|
50
50
|
private readonly matcher;
|
|
51
|
-
private readonly codec;
|
|
52
51
|
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
53
52
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
54
53
|
}
|
|
@@ -234,14 +234,4 @@ function deserialize(data) {
|
|
|
234
234
|
return data;
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
|
|
238
|
-
return `/${path.replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "")}`;
|
|
239
|
-
}
|
|
240
|
-
function getDynamicParams(path) {
|
|
241
|
-
return path ? standardizeHTTPPath(path).match(/\/\{[^}]+\}/g)?.map((v) => ({
|
|
242
|
-
raw: v,
|
|
243
|
-
name: v.match(/\{\+?([^}]+)\}/)[1]
|
|
244
|
-
})) : void 0;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
237
|
+
export { bracketNotationDeserialize as b, deserialize as d, jsonSerialize as j, serialize as s };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -71,16 +71,17 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
|
-
"@standard-schema/spec": "^1.0.0",
|
|
75
74
|
"rou3": "^0.7.7",
|
|
76
75
|
"zod": "^4.1.12",
|
|
77
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/standard-server
|
|
82
|
-
"@temporary-name/standard-server-
|
|
83
|
-
"@temporary-name/
|
|
76
|
+
"@temporary-name/interop": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
77
|
+
"@temporary-name/contract": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
79
|
+
"@temporary-name/shared": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
80
|
+
"@temporary-name/standard-server": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
81
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
83
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8",
|
|
84
|
+
"@temporary-name/zod": "1.9.3-alpha.8dcf0da5d97e7b89ab5ce50c8d1733c158e629a8"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/supertest": "^6.0.3",
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, HTTPPath, Promisable, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
|
-
|
|
4
|
-
type Context = Record<PropertyKey, any>;
|
|
5
|
-
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
6
|
-
type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
|
|
7
|
-
declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
|
|
8
|
-
|
|
9
|
-
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
|
10
|
-
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
|
11
|
-
type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
12
|
-
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
|
|
13
|
-
};
|
|
14
|
-
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
|
-
|
|
16
|
-
declare const LAZY_SYMBOL: unique symbol;
|
|
17
|
-
interface LazyMeta {
|
|
18
|
-
prefix?: HTTPPath;
|
|
19
|
-
}
|
|
20
|
-
interface Lazy<T> {
|
|
21
|
-
[LAZY_SYMBOL]: {
|
|
22
|
-
loader: () => Promise<{
|
|
23
|
-
default: T;
|
|
24
|
-
}>;
|
|
25
|
-
meta: LazyMeta;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
type Lazyable<T> = T | Lazy<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a lazy-loaded item.
|
|
31
|
-
*
|
|
32
|
-
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare function lazy<T>(loader: () => Promise<{
|
|
35
|
-
default: T;
|
|
36
|
-
}>, meta?: LazyMeta): Lazy<T>;
|
|
37
|
-
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
38
|
-
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
39
|
-
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
40
|
-
default: T extends Lazy<infer U> ? U : T;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
|
-
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
|
-
context: TCurrentContext;
|
|
45
|
-
input: TInput;
|
|
46
|
-
path: readonly string[];
|
|
47
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
48
|
-
signal?: AbortSignal;
|
|
49
|
-
lastEventId: string | undefined;
|
|
50
|
-
errors: TErrorConstructorMap;
|
|
51
|
-
}
|
|
52
|
-
interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
53
|
-
(opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
|
54
|
-
}
|
|
55
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
56
|
-
__initialContext?: (type: TInitialContext) => unknown;
|
|
57
|
-
middlewares: readonly AnyMiddleware[];
|
|
58
|
-
inputValidationIndex: number;
|
|
59
|
-
outputValidationIndex: number;
|
|
60
|
-
handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* This class represents a procedure.
|
|
64
|
-
*
|
|
65
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
66
|
-
*/
|
|
67
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
68
|
-
/**
|
|
69
|
-
* This property holds the defined options.
|
|
70
|
-
*/
|
|
71
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
|
-
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any, any, any, any, any>;
|
|
75
|
-
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
|
-
|
|
77
|
-
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
78
|
-
output: TOutput;
|
|
79
|
-
context: TOutContext;
|
|
80
|
-
}>;
|
|
81
|
-
type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
|
|
82
|
-
context?: TOutContext;
|
|
83
|
-
} : {
|
|
84
|
-
context: TOutContext;
|
|
85
|
-
};
|
|
86
|
-
interface MiddlewareNextFn<TOutput> {
|
|
87
|
-
<U extends Context = Record<never, never>>(...rest: MaybeOptionalOptions<MiddlewareNextFnOptions<U>>): MiddlewareResult<U, TOutput>;
|
|
88
|
-
}
|
|
89
|
-
interface MiddlewareOutputFn<TOutput> {
|
|
90
|
-
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
91
|
-
}
|
|
92
|
-
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
93
|
-
context: TInContext;
|
|
94
|
-
path: readonly string[];
|
|
95
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
96
|
-
signal?: AbortSignal;
|
|
97
|
-
lastEventId: string | undefined;
|
|
98
|
-
next: MiddlewareNextFn<TOutput>;
|
|
99
|
-
errors: TErrorConstructorMap;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* A function that represents a middleware.
|
|
103
|
-
*
|
|
104
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
105
|
-
*/
|
|
106
|
-
interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
107
|
-
(options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
|
|
108
|
-
}
|
|
109
|
-
type AnyMiddleware = Middleware<any, any, any, any, any, any>;
|
|
110
|
-
interface MapInputMiddleware<TInput, TMappedInput> {
|
|
111
|
-
(input: TInput): TMappedInput;
|
|
112
|
-
}
|
|
113
|
-
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
|
-
|
|
115
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
|
-
context: TInitialContext;
|
|
118
|
-
input: unknown;
|
|
119
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
120
|
-
path: readonly string[];
|
|
121
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
lastEventId: string | undefined;
|
|
124
|
-
}
|
|
125
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
-
/**
|
|
127
|
-
* This is helpful for logging and analytics.
|
|
128
|
-
*/
|
|
129
|
-
path?: readonly string[];
|
|
130
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
131
|
-
} & (Record<never, never> extends TInitialContext ? {
|
|
132
|
-
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
133
|
-
} : {
|
|
134
|
-
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* Create Server-side client from a procedure.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
140
|
-
*/
|
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Represents a router, which defines a hierarchical structure of procedures.
|
|
145
|
-
*
|
|
146
|
-
* @info A procedure is a router too.
|
|
147
|
-
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
148
|
-
*/
|
|
149
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
|
150
|
-
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
151
|
-
};
|
|
152
|
-
type AnyRouter = Router<any, any>;
|
|
153
|
-
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
|
154
|
-
/**
|
|
155
|
-
* Infer all initial context of the router.
|
|
156
|
-
*
|
|
157
|
-
* @info A procedure is a router too.
|
|
158
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
159
|
-
*/
|
|
160
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
|
161
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Infer all current context of the router.
|
|
165
|
-
*
|
|
166
|
-
* @info A procedure is a router too.
|
|
167
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
168
|
-
*/
|
|
169
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
|
170
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Infer all router inputs
|
|
174
|
-
*
|
|
175
|
-
* @info A procedure is a router too.
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
177
|
-
*/
|
|
178
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
|
179
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Infer all router outputs
|
|
183
|
-
*
|
|
184
|
-
* @info A procedure is a router too.
|
|
185
|
-
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
186
|
-
*/
|
|
187
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
|
188
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
|
|
192
|
-
export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
|