@temporary-name/server 1.9.3-alpha.30822ad82102dcf9276d473ba372416778807e52 → 1.9.3-alpha.3f3cdc28e4c507442c043c8988bb757a44b8785b
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 +12 -6
- package/dist/adapters/aws-lambda/index.d.ts +12 -6
- package/dist/adapters/aws-lambda/index.mjs +12 -4
- package/dist/adapters/fetch/index.d.mts +12 -6
- package/dist/adapters/fetch/index.d.ts +12 -6
- package/dist/adapters/fetch/index.mjs +12 -11
- package/dist/adapters/node/index.d.mts +12 -6
- package/dist/adapters/node/index.d.ts +12 -6
- package/dist/adapters/node/index.mjs +12 -11
- package/dist/adapters/standard/index.d.mts +23 -13
- package/dist/adapters/standard/index.d.ts +23 -13
- package/dist/adapters/standard/index.mjs +8 -100
- package/dist/index.d.mts +41 -282
- package/dist/index.d.ts +41 -282
- package/dist/index.mjs +102 -156
- package/dist/openapi/index.d.mts +220 -0
- package/dist/openapi/index.d.ts +220 -0
- package/dist/openapi/index.mjs +742 -0
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/server.B93y_8tj.d.mts +23 -0
- package/dist/shared/{server.BEQrAa3A.mjs → server.BYYf0Wn6.mjs} +35 -40
- package/dist/shared/{server.C1YnHvvf.d.ts → server.C3RuMHWl.d.mts} +31 -31
- package/dist/shared/{server.C1YnHvvf.d.mts → server.C3RuMHWl.d.ts} +31 -31
- package/dist/shared/{server.Btxrgkj5.d.ts → server.CT1xhSmE.d.mts} +7 -24
- package/dist/shared/server.DIOj33oh.mjs +262 -0
- package/dist/shared/server.D_fags8X.d.ts +23 -0
- package/dist/shared/server.Kxw442A9.mjs +247 -0
- package/dist/shared/{server.Bo94xDTv.d.mts → server.cjcgLdr1.d.ts} +7 -24
- package/package.json +17 -10
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
|
|
3
3
|
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import {
|
|
5
|
-
import { C as Context,
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CT1xhSmE.mjs';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.mjs';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Value, Promisable, ORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
|
|
3
3
|
import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
|
|
4
|
-
import {
|
|
5
|
-
import { C as Context,
|
|
4
|
+
import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.cjcgLdr1.js';
|
|
5
|
+
import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.js';
|
|
6
6
|
import { Meta } from '@temporary-name/contract';
|
|
7
7
|
|
|
8
8
|
interface BatchHandlerOptions<T extends Context> {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { HTTPPath } from '@temporary-name/shared';
|
|
2
|
+
import { C as Context } from './server.C3RuMHWl.mjs';
|
|
3
|
+
import { c as StandardHandleOptions } from './server.CT1xhSmE.mjs';
|
|
4
|
+
|
|
5
|
+
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
|
6
|
+
context?: T;
|
|
7
|
+
} : {
|
|
8
|
+
context: T;
|
|
9
|
+
});
|
|
10
|
+
declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
|
|
11
|
+
/**
|
|
12
|
+
* {@link https://github.com/unjs/rou3}
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
declare function toRou3Pattern(path: HTTPPath): string;
|
|
17
|
+
/**
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
21
|
+
|
|
22
|
+
export { decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
23
|
+
export type { FriendlyStandardHandleOptions as F };
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { validateORPCError, ValidationError } from '@temporary-name/contract';
|
|
2
2
|
import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
|
|
3
3
|
import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
7
|
-
function lazy(loader, meta = {}) {
|
|
8
|
-
return {
|
|
9
|
-
[LAZY_SYMBOL]: {
|
|
10
|
-
loader,
|
|
11
|
-
meta
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function isLazy(item) {
|
|
16
|
-
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
|
|
17
|
-
}
|
|
18
|
-
function getLazyMeta(lazied) {
|
|
19
|
-
return lazied[LAZY_SYMBOL].meta;
|
|
20
|
-
}
|
|
21
|
-
function unlazy(lazied) {
|
|
22
|
-
return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
|
|
23
|
-
}
|
|
4
|
+
import { safeParseAsync } from '@temporary-name/zod';
|
|
24
5
|
|
|
25
6
|
function mergeCurrentContext(context, other) {
|
|
26
7
|
return { ...context, ...other };
|
|
@@ -49,6 +30,25 @@ function createORPCErrorConstructorMap(errors) {
|
|
|
49
30
|
return proxy;
|
|
50
31
|
}
|
|
51
32
|
|
|
33
|
+
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
|
34
|
+
function lazy(loader, meta = {}) {
|
|
35
|
+
return {
|
|
36
|
+
[LAZY_SYMBOL]: {
|
|
37
|
+
loader,
|
|
38
|
+
meta
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function isLazy(item) {
|
|
43
|
+
return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
|
|
44
|
+
}
|
|
45
|
+
function getLazyMeta(lazied) {
|
|
46
|
+
return lazied[LAZY_SYMBOL].meta;
|
|
47
|
+
}
|
|
48
|
+
function unlazy(lazied) {
|
|
49
|
+
return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
|
|
50
|
+
}
|
|
51
|
+
|
|
52
52
|
function middlewareOutputFn(output) {
|
|
53
53
|
return { output, context: {} };
|
|
54
54
|
}
|
|
@@ -115,37 +115,41 @@ async function validateInput(procedure, input) {
|
|
|
115
115
|
return input;
|
|
116
116
|
}
|
|
117
117
|
return runWithSpan({ name: "validate_input" }, async () => {
|
|
118
|
-
const result = await schema
|
|
119
|
-
if (result.
|
|
118
|
+
const result = await safeParseAsync(schema, input);
|
|
119
|
+
if (!result.success) {
|
|
120
120
|
throw new ORPCError("BAD_REQUEST", {
|
|
121
121
|
message: "Input validation failed",
|
|
122
122
|
data: {
|
|
123
|
-
issues: result.issues
|
|
123
|
+
issues: result.error.issues
|
|
124
124
|
},
|
|
125
125
|
cause: new ValidationError({
|
|
126
126
|
message: "Input validation failed",
|
|
127
|
-
issues: result.issues,
|
|
127
|
+
issues: result.error.issues,
|
|
128
128
|
data: input
|
|
129
129
|
})
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
return result.
|
|
132
|
+
return result.data;
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
-
async function validateOutput(
|
|
135
|
+
async function validateOutput(procedure, output) {
|
|
136
|
+
const schema = procedure["~orpc"].outputSchema;
|
|
137
|
+
if (!schema) {
|
|
138
|
+
return output;
|
|
139
|
+
}
|
|
136
140
|
return runWithSpan({ name: "validate_output" }, async () => {
|
|
137
|
-
const result = await schema
|
|
138
|
-
if (result.
|
|
141
|
+
const result = await safeParseAsync(schema, output);
|
|
142
|
+
if (!result.success) {
|
|
139
143
|
throw new ORPCError("INTERNAL_SERVER_ERROR", {
|
|
140
144
|
message: "Output validation failed",
|
|
141
145
|
cause: new ValidationError({
|
|
142
146
|
message: "Output validation failed",
|
|
143
|
-
issues: result.issues,
|
|
147
|
+
issues: result.error.issues,
|
|
144
148
|
data: output
|
|
145
149
|
})
|
|
146
150
|
});
|
|
147
151
|
}
|
|
148
|
-
return result.
|
|
152
|
+
return result.data;
|
|
149
153
|
});
|
|
150
154
|
}
|
|
151
155
|
async function executeProcedureInternal(procedure, options) {
|
|
@@ -188,16 +192,7 @@ async function executeProcedureInternal(procedure, options) {
|
|
|
188
192
|
() => procedure["~orpc"].handler({ ...options, context, input: currentInput })
|
|
189
193
|
);
|
|
190
194
|
if (index === outputValidationIndex) {
|
|
191
|
-
|
|
192
|
-
if (!schema) {
|
|
193
|
-
return output;
|
|
194
|
-
}
|
|
195
|
-
const validated = await validateOutput(schema, output);
|
|
196
|
-
const isGateEnabled = gatingContext.getStore();
|
|
197
|
-
if (!validated || !isGateEnabled) {
|
|
198
|
-
return validated;
|
|
199
|
-
}
|
|
200
|
-
return withoutGatedFields(validated, schema, isGateEnabled);
|
|
195
|
+
return await validateOutput(procedure, output);
|
|
201
196
|
}
|
|
202
197
|
return output;
|
|
203
198
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
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
16
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
18
|
input: TInput;
|
|
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
44
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
45
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
46
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
47
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
48
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
49
|
|
|
77
50
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -112,6 +85,33 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
85
|
}
|
|
113
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
87
|
|
|
88
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
89
|
+
interface LazyMeta {
|
|
90
|
+
prefix?: HTTPPath;
|
|
91
|
+
}
|
|
92
|
+
interface Lazy<T> {
|
|
93
|
+
[LAZY_SYMBOL]: {
|
|
94
|
+
loader: () => Promise<{
|
|
95
|
+
default: T;
|
|
96
|
+
}>;
|
|
97
|
+
meta: LazyMeta;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a lazy-loaded item.
|
|
103
|
+
*
|
|
104
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
105
|
+
*/
|
|
106
|
+
declare function lazy<T>(loader: () => Promise<{
|
|
107
|
+
default: T;
|
|
108
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
109
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
110
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
111
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
112
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
113
|
+
}>;
|
|
114
|
+
|
|
115
115
|
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
116
|
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
117
|
context: TInitialContext;
|
|
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
188
188
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
export { isProcedure as
|
|
192
|
-
export type {
|
|
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, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware 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 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
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
16
|
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
18
|
input: TInput;
|
|
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
|
|
|
71
44
|
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
72
45
|
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
73
46
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
47
|
+
type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
|
|
75
48
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
49
|
|
|
77
50
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -112,6 +85,33 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
85
|
}
|
|
113
86
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
87
|
|
|
88
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
89
|
+
interface LazyMeta {
|
|
90
|
+
prefix?: HTTPPath;
|
|
91
|
+
}
|
|
92
|
+
interface Lazy<T> {
|
|
93
|
+
[LAZY_SYMBOL]: {
|
|
94
|
+
loader: () => Promise<{
|
|
95
|
+
default: T;
|
|
96
|
+
}>;
|
|
97
|
+
meta: LazyMeta;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a lazy-loaded item.
|
|
103
|
+
*
|
|
104
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
105
|
+
*/
|
|
106
|
+
declare function lazy<T>(loader: () => Promise<{
|
|
107
|
+
default: T;
|
|
108
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
109
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
110
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
111
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
112
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
113
|
+
}>;
|
|
114
|
+
|
|
115
115
|
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
116
|
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
117
|
context: TInitialContext;
|
|
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
|
188
188
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
189
|
};
|
|
190
190
|
|
|
191
|
-
export { isProcedure as
|
|
192
|
-
export type {
|
|
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, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware 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 };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Meta } from '@temporary-name/contract';
|
|
2
|
-
import { HTTPPath,
|
|
3
|
-
import {
|
|
4
|
-
import { C as Context, R as Router,
|
|
2
|
+
import { HTTPPath, Interceptor } from '@temporary-name/shared';
|
|
3
|
+
import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
|
|
4
|
+
import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.C3RuMHWl.mjs';
|
|
5
5
|
|
|
6
6
|
interface StandardHandlerPlugin<T extends Context> {
|
|
7
7
|
order?: number;
|
|
@@ -13,22 +13,6 @@ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends
|
|
|
13
13
|
init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
type StandardParams = Record<string, string>;
|
|
17
|
-
type StandardMatchResult = {
|
|
18
|
-
path: readonly string[];
|
|
19
|
-
procedure: AnyProcedure;
|
|
20
|
-
params?: StandardParams;
|
|
21
|
-
} | undefined;
|
|
22
|
-
interface StandardMatcher {
|
|
23
|
-
init(router: AnyRouter): void;
|
|
24
|
-
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
|
25
|
-
}
|
|
26
|
-
interface StandardCodec {
|
|
27
|
-
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
|
28
|
-
encodeError(error: ORPCError<any, any>): StandardResponse;
|
|
29
|
-
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
16
|
interface StandardHandleOptions<T extends Context> {
|
|
33
17
|
prefix?: HTTPPath;
|
|
34
18
|
context: T;
|
|
@@ -60,14 +44,13 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
|
60
44
|
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
|
|
61
45
|
}
|
|
62
46
|
declare class StandardHandler<T extends Context> {
|
|
63
|
-
private readonly matcher;
|
|
64
|
-
private readonly codec;
|
|
65
47
|
private readonly interceptors;
|
|
66
48
|
private readonly clientInterceptors;
|
|
67
49
|
private readonly rootInterceptors;
|
|
68
|
-
|
|
50
|
+
private readonly matcher;
|
|
51
|
+
constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
|
|
69
52
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
70
53
|
}
|
|
71
54
|
|
|
72
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as
|
|
73
|
-
export type {
|
|
55
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as e };
|
|
56
|
+
export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardHandleOptions as c, StandardHandleResult as d };
|