@temporary-name/server 1.9.3-alpha.0d2fa3247b6b23bbc2e3097a95f631b86740e4d8

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.
@@ -0,0 +1,207 @@
1
+ import { validateORPCError, ValidationError } from '@temporary-name/contract';
2
+ import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
3
+ import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
4
+ import { g as gatingContext, w as withoutGatedFields } from './server.D6K9uoPI.mjs';
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
+ }
24
+
25
+ function mergeCurrentContext(context, other) {
26
+ return { ...context, ...other };
27
+ }
28
+
29
+ function createORPCErrorConstructorMap(errors) {
30
+ const proxy = new Proxy(errors, {
31
+ get(target, code) {
32
+ if (typeof code !== "string") {
33
+ return Reflect.get(target, code);
34
+ }
35
+ const item = (...rest) => {
36
+ const options = resolveMaybeOptionalOptions(rest);
37
+ const config = errors[code];
38
+ return new ORPCError(code, {
39
+ defined: Boolean(config),
40
+ status: config?.status,
41
+ message: options.message ?? config?.message,
42
+ data: options.data,
43
+ cause: options.cause
44
+ });
45
+ };
46
+ return item;
47
+ }
48
+ });
49
+ return proxy;
50
+ }
51
+
52
+ function middlewareOutputFn(output) {
53
+ return { output, context: {} };
54
+ }
55
+
56
+ function createProcedureClient(lazyableProcedure, ...rest) {
57
+ const options = resolveMaybeOptionalOptions(rest);
58
+ return async (...[input, callerOptions]) => {
59
+ const path = toArray(options.path);
60
+ const { default: procedure } = await unlazy(lazyableProcedure);
61
+ const clientContext = callerOptions?.context ?? {};
62
+ const context = await value(options.context ?? {}, clientContext);
63
+ const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
64
+ const validateError = async (e) => {
65
+ if (e instanceof ORPCError) {
66
+ return await validateORPCError(procedure["~orpc"].errorMap, e);
67
+ }
68
+ return e;
69
+ };
70
+ try {
71
+ const output = await runWithSpan({ name: "call_procedure", signal: callerOptions?.signal }, (span) => {
72
+ span?.setAttribute("procedure.path", [...path]);
73
+ return intercept(
74
+ toArray(options.interceptors),
75
+ {
76
+ context,
77
+ input,
78
+ // input only optional when it undefinable so we can safely cast it
79
+ errors,
80
+ path,
81
+ procedure,
82
+ signal: callerOptions?.signal,
83
+ lastEventId: callerOptions?.lastEventId
84
+ },
85
+ (interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
86
+ );
87
+ });
88
+ if (isAsyncIteratorObject(output)) {
89
+ if (output instanceof HibernationEventIterator) {
90
+ return output;
91
+ }
92
+ return overlayProxy(
93
+ output,
94
+ mapEventIterator(
95
+ asyncIteratorWithSpan(
96
+ { name: "consume_event_iterator_output", signal: callerOptions?.signal },
97
+ output
98
+ ),
99
+ {
100
+ value: (v) => v,
101
+ error: (e) => validateError(e)
102
+ }
103
+ )
104
+ );
105
+ }
106
+ return output;
107
+ } catch (e) {
108
+ throw await validateError(e);
109
+ }
110
+ };
111
+ }
112
+ async function validateInput(procedure, input) {
113
+ const schema = procedure["~orpc"].inputSchema;
114
+ if (!schema) {
115
+ return input;
116
+ }
117
+ return runWithSpan({ name: "validate_input" }, async () => {
118
+ const result = await schema["~standard"].validate(input);
119
+ if (result.issues) {
120
+ throw new ORPCError("BAD_REQUEST", {
121
+ message: "Input validation failed",
122
+ data: {
123
+ issues: result.issues
124
+ },
125
+ cause: new ValidationError({
126
+ message: "Input validation failed",
127
+ issues: result.issues,
128
+ data: input
129
+ })
130
+ });
131
+ }
132
+ return result.value;
133
+ });
134
+ }
135
+ async function validateOutput(schema, output) {
136
+ return runWithSpan({ name: "validate_output" }, async () => {
137
+ const result = await schema["~standard"].validate(output);
138
+ if (result.issues) {
139
+ throw new ORPCError("INTERNAL_SERVER_ERROR", {
140
+ message: "Output validation failed",
141
+ cause: new ValidationError({
142
+ message: "Output validation failed",
143
+ issues: result.issues,
144
+ data: output
145
+ })
146
+ });
147
+ }
148
+ return result.value;
149
+ });
150
+ }
151
+ async function executeProcedureInternal(procedure, options) {
152
+ const middlewares = procedure["~orpc"].middlewares;
153
+ const inputValidationIndex = Math.min(
154
+ Math.max(0, procedure["~orpc"].inputValidationIndex),
155
+ middlewares.length
156
+ );
157
+ const outputValidationIndex = Math.min(
158
+ Math.max(0, procedure["~orpc"].outputValidationIndex),
159
+ middlewares.length
160
+ );
161
+ const next = async (index, context, input) => {
162
+ let currentInput = input;
163
+ if (index === inputValidationIndex) {
164
+ currentInput = await validateInput(procedure, currentInput);
165
+ }
166
+ const mid = middlewares[index];
167
+ const output = mid ? await runWithSpan({ name: `middleware.${mid.name}`, signal: options.signal }, async (span) => {
168
+ span?.setAttribute("middleware.index", index);
169
+ span?.setAttribute("middleware.name", mid.name);
170
+ const result = await mid(
171
+ {
172
+ ...options,
173
+ context,
174
+ next: async (...[nextOptions]) => {
175
+ const nextContext = nextOptions?.context ?? {};
176
+ return {
177
+ output: await next(index + 1, mergeCurrentContext(context, nextContext), currentInput),
178
+ context: nextContext
179
+ };
180
+ }
181
+ },
182
+ currentInput,
183
+ middlewareOutputFn
184
+ );
185
+ return result.output;
186
+ }) : await runWithSpan(
187
+ { name: "handler", signal: options.signal },
188
+ () => procedure["~orpc"].handler({ ...options, context, input: currentInput })
189
+ );
190
+ if (index === outputValidationIndex) {
191
+ const schema = procedure["~orpc"].outputSchema;
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);
201
+ }
202
+ return output;
203
+ };
204
+ return next(0, options.context, options.input);
205
+ }
206
+
207
+ export { LAZY_SYMBOL as L, createORPCErrorConstructorMap as a, middlewareOutputFn as b, createProcedureClient as c, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
@@ -0,0 +1,73 @@
1
+ import { Meta } from '@temporary-name/contract';
2
+ import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
+ import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
+ import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.mjs';
5
+
6
+ interface StandardHandlerPlugin<T extends Context> {
7
+ order?: number;
8
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
9
+ }
10
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
11
+ protected readonly plugins: TPlugin[];
12
+ constructor(plugins?: readonly TPlugin[]);
13
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
+ }
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
+ interface StandardHandleOptions<T extends Context> {
33
+ prefix?: HTTPPath;
34
+ context: T;
35
+ }
36
+ type StandardHandleResult = {
37
+ matched: true;
38
+ response: StandardResponse;
39
+ } | {
40
+ matched: false;
41
+ response: undefined;
42
+ };
43
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
44
+ request: StandardLazyRequest;
45
+ }
46
+ interface StandardHandlerOptions<TContext extends Context> {
47
+ plugins?: StandardHandlerPlugin<TContext>[];
48
+ /**
49
+ * Interceptors at the request level, helpful when you want catch errors
50
+ */
51
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
52
+ /**
53
+ * Interceptors at the root level, helpful when you want override the request/response
54
+ */
55
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
56
+ /**
57
+ *
58
+ * Interceptors for procedure client.
59
+ */
60
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
61
+ }
62
+ declare class StandardHandler<T extends Context> {
63
+ private readonly matcher;
64
+ private readonly codec;
65
+ private readonly interceptors;
66
+ private readonly clientInterceptors;
67
+ private readonly rootInterceptors;
68
+ constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
69
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
+ }
71
+
72
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
+ export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
@@ -0,0 +1,73 @@
1
+ import { Meta } from '@temporary-name/contract';
2
+ import { HTTPPath, ORPCError, Interceptor } from '@temporary-name/shared';
3
+ import { StandardResponse, StandardLazyRequest } from '@temporary-name/standard-server';
4
+ import { C as Context, R as Router, A as AnyRouter, a as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.C1YnHvvf.js';
5
+
6
+ interface StandardHandlerPlugin<T extends Context> {
7
+ order?: number;
8
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
9
+ }
10
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
11
+ protected readonly plugins: TPlugin[];
12
+ constructor(plugins?: readonly TPlugin[]);
13
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
14
+ }
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
+ interface StandardHandleOptions<T extends Context> {
33
+ prefix?: HTTPPath;
34
+ context: T;
35
+ }
36
+ type StandardHandleResult = {
37
+ matched: true;
38
+ response: StandardResponse;
39
+ } | {
40
+ matched: false;
41
+ response: undefined;
42
+ };
43
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
44
+ request: StandardLazyRequest;
45
+ }
46
+ interface StandardHandlerOptions<TContext extends Context> {
47
+ plugins?: StandardHandlerPlugin<TContext>[];
48
+ /**
49
+ * Interceptors at the request level, helpful when you want catch errors
50
+ */
51
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
52
+ /**
53
+ * Interceptors at the root level, helpful when you want override the request/response
54
+ */
55
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
56
+ /**
57
+ *
58
+ * Interceptors for procedure client.
59
+ */
60
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
61
+ }
62
+ declare class StandardHandler<T extends Context> {
63
+ private readonly matcher;
64
+ private readonly codec;
65
+ private readonly interceptors;
66
+ private readonly clientInterceptors;
67
+ private readonly rootInterceptors;
68
+ constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
69
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
70
+ }
71
+
72
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as S };
73
+ export type { StandardHandlerPlugin as a, StandardHandleOptions as b, StandardHandlerInterceptorOptions as c, StandardHandlerOptions as d, StandardHandleResult as e, StandardParams as f, StandardMatchResult as g, StandardMatcher as h, StandardCodec as i };
@@ -0,0 +1,192 @@
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 E, createProcedureClient as F, Procedure as b, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as z };
192
+ export type { AnyRouter as A, ProcedureHandlerOptions as B, Context as C, ProcedureDef as D, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, ProcedureClientInterceptorOptions as P, Router as R, AnyProcedure as a, MergedInitialContext as c, MergedCurrentContext as d, MapInputMiddleware as e, CreateProcedureClientOptions as f, ProcedureClient as g, AnyMiddleware as h, Lazy as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as v, MiddlewareNextFn as w, MiddlewareOutputFn as x, MiddlewareOptions as y };