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

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.
Files changed (39) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +12 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +12 -7
  3. package/dist/adapters/aws-lambda/index.mjs +12 -4
  4. package/dist/adapters/fetch/index.d.mts +12 -7
  5. package/dist/adapters/fetch/index.d.ts +12 -7
  6. package/dist/adapters/fetch/index.mjs +12 -11
  7. package/dist/adapters/node/index.d.mts +12 -7
  8. package/dist/adapters/node/index.d.ts +12 -7
  9. package/dist/adapters/node/index.mjs +12 -11
  10. package/dist/adapters/standard/index.d.mts +27 -13
  11. package/dist/adapters/standard/index.d.ts +27 -13
  12. package/dist/adapters/standard/index.mjs +8 -100
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +82 -459
  15. package/dist/index.d.ts +82 -459
  16. package/dist/index.mjs +213 -366
  17. package/dist/openapi/index.d.mts +220 -0
  18. package/dist/openapi/index.d.ts +220 -0
  19. package/dist/openapi/index.mjs +709 -0
  20. package/dist/plugins/index.d.mts +5 -83
  21. package/dist/plugins/index.d.ts +5 -83
  22. package/dist/plugins/index.mjs +17 -189
  23. package/dist/shared/{server.Btxrgkj5.d.ts → server.25yUS-xw.d.mts} +7 -25
  24. package/dist/shared/server.BKwU5-Ea.d.mts +23 -0
  25. package/dist/shared/server.C1RJffw4.mjs +30 -0
  26. package/dist/shared/{server.Bo94xDTv.d.mts → server.Co-zpS8Y.d.ts} +7 -25
  27. package/dist/shared/server.DRYRuXpK.mjs +254 -0
  28. package/dist/shared/server.DV_PWBS2.d.ts +23 -0
  29. package/dist/shared/server.DWEp52Gx.mjs +379 -0
  30. package/dist/shared/server.JtIZ8YG7.mjs +237 -0
  31. package/dist/shared/server.VtI8pLxV.d.mts +242 -0
  32. package/dist/shared/server.VtI8pLxV.d.ts +242 -0
  33. package/package.json +18 -23
  34. package/dist/shared/server.BEQrAa3A.mjs +0 -207
  35. package/dist/shared/server.C1YnHvvf.d.mts +0 -192
  36. package/dist/shared/server.C1YnHvvf.d.ts +0 -192
  37. package/dist/shared/server.D6K9uoPI.mjs +0 -35
  38. package/dist/shared/server.DZ5BIITo.mjs +0 -9
  39. package/dist/shared/server.X0YaZxSJ.mjs +0 -13
@@ -0,0 +1,237 @@
1
+ import { isObject, NullProtoObj, isAsyncIteratorObject, isORPCErrorJson, createORPCErrorFromJson, toORPCError } from '@temporary-name/shared';
2
+ import { mapEventIterator, ErrorEvent } from '@temporary-name/standard-server';
3
+
4
+ function bracketNotationSerialize(data, segments = [], result = []) {
5
+ if (Array.isArray(data)) {
6
+ data.forEach((item, i) => {
7
+ bracketNotationSerialize(item, [...segments, i], result);
8
+ });
9
+ } else if (isObject(data)) {
10
+ for (const key in data) {
11
+ bracketNotationSerialize(data[key], [...segments, key], result);
12
+ }
13
+ } else {
14
+ result.push([stringifyPath(segments), data]);
15
+ }
16
+ return result;
17
+ }
18
+ function bracketNotationDeserialize(serialized, { maxArrayIndex = 9999 } = {}) {
19
+ if (serialized.length === 0) {
20
+ return {};
21
+ }
22
+ const arrayPushStyles = /* @__PURE__ */ new WeakSet();
23
+ const ref = { value: [] };
24
+ for (const [path, value] of serialized) {
25
+ const segments = parsePath(path);
26
+ let currentRef = ref;
27
+ let nextSegment = "value";
28
+ segments.forEach((segment, i) => {
29
+ if (!Array.isArray(currentRef[nextSegment]) && !isObject(currentRef[nextSegment])) {
30
+ currentRef[nextSegment] = [];
31
+ }
32
+ if (i !== segments.length - 1) {
33
+ if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment, maxArrayIndex)) {
34
+ if (arrayPushStyles.has(currentRef[nextSegment])) {
35
+ arrayPushStyles.delete(currentRef[nextSegment]);
36
+ currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
37
+ } else {
38
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
39
+ }
40
+ }
41
+ } else {
42
+ if (Array.isArray(currentRef[nextSegment])) {
43
+ if (segment === "") {
44
+ if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
45
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
46
+ }
47
+ } else {
48
+ if (arrayPushStyles.has(currentRef[nextSegment])) {
49
+ arrayPushStyles.delete(currentRef[nextSegment]);
50
+ currentRef[nextSegment] = pushStyleArrayToObject(currentRef[nextSegment]);
51
+ } else if (!isValidArrayIndex(segment, maxArrayIndex)) {
52
+ currentRef[nextSegment] = arrayToObject(currentRef[nextSegment]);
53
+ }
54
+ }
55
+ }
56
+ }
57
+ currentRef = currentRef[nextSegment];
58
+ nextSegment = segment;
59
+ });
60
+ if (Array.isArray(currentRef) && nextSegment === "") {
61
+ arrayPushStyles.add(currentRef);
62
+ currentRef.push(value);
63
+ } else if (nextSegment in currentRef) {
64
+ if (Array.isArray(currentRef[nextSegment])) {
65
+ currentRef[nextSegment].push(value);
66
+ } else {
67
+ currentRef[nextSegment] = [currentRef[nextSegment], value];
68
+ }
69
+ } else {
70
+ currentRef[nextSegment] = value;
71
+ }
72
+ }
73
+ return ref.value;
74
+ }
75
+ function stringifyPath(segments) {
76
+ return segments.map((segment) => {
77
+ return segment.toString().replace(/[\\[\]]/g, (match) => {
78
+ switch (match) {
79
+ case "\\":
80
+ return "\\\\";
81
+ case "[":
82
+ return "\\[";
83
+ case "]":
84
+ return "\\]";
85
+ /* v8 ignore next 2 */
86
+ default:
87
+ return match;
88
+ }
89
+ });
90
+ }).reduce((result, segment, i) => {
91
+ if (i === 0) {
92
+ return segment;
93
+ }
94
+ return `${result}[${segment}]`;
95
+ }, "");
96
+ }
97
+ function parsePath(path) {
98
+ const segments = [];
99
+ let inBrackets = false;
100
+ let currentSegment = "";
101
+ let backslashCount = 0;
102
+ for (let i = 0; i < path.length; i++) {
103
+ const char = path[i];
104
+ const nextChar = path[i + 1];
105
+ if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) {
106
+ if (nextChar === void 0) {
107
+ inBrackets = false;
108
+ }
109
+ segments.push(currentSegment);
110
+ currentSegment = "";
111
+ i++;
112
+ } else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) {
113
+ inBrackets = true;
114
+ segments.push(currentSegment);
115
+ currentSegment = "";
116
+ } else if (char === "\\") {
117
+ backslashCount++;
118
+ } else {
119
+ currentSegment += "\\".repeat(backslashCount / 2) + char;
120
+ backslashCount = 0;
121
+ }
122
+ }
123
+ return inBrackets || segments.length === 0 ? [path] : segments;
124
+ }
125
+ function isValidArrayIndex(value, maxIndex) {
126
+ return /^0$|^[1-9]\d*$/.test(value) && Number(value) <= maxIndex;
127
+ }
128
+ function arrayToObject(array) {
129
+ const obj = new NullProtoObj();
130
+ array.forEach((item, i) => {
131
+ obj[i] = item;
132
+ });
133
+ return obj;
134
+ }
135
+ function pushStyleArrayToObject(array) {
136
+ const obj = new NullProtoObj();
137
+ obj[""] = array.length === 1 ? array[0] : array;
138
+ return obj;
139
+ }
140
+
141
+ function jsonSerialize(data, hasBlobRef = { value: false }) {
142
+ if (data instanceof Blob) {
143
+ hasBlobRef.value = true;
144
+ return [data, hasBlobRef.value];
145
+ }
146
+ if (data instanceof Set) {
147
+ return jsonSerialize(Array.from(data), hasBlobRef);
148
+ }
149
+ if (data instanceof Map) {
150
+ return jsonSerialize(Array.from(data.entries()), hasBlobRef);
151
+ }
152
+ if (Array.isArray(data)) {
153
+ const json = data.map((v) => v === void 0 ? null : jsonSerialize(v, hasBlobRef)[0]);
154
+ return [json, hasBlobRef.value];
155
+ }
156
+ if (isObject(data)) {
157
+ const json = {};
158
+ for (const k in data) {
159
+ if (k === "toJSON" && typeof data[k] === "function") {
160
+ continue;
161
+ }
162
+ json[k] = jsonSerialize(data[k], hasBlobRef)[0];
163
+ }
164
+ return [json, hasBlobRef.value];
165
+ }
166
+ if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
167
+ return [data.toString(), hasBlobRef.value];
168
+ }
169
+ if (data instanceof Date) {
170
+ return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
171
+ }
172
+ if (Number.isNaN(data)) {
173
+ return [null, hasBlobRef.value];
174
+ }
175
+ return [data, hasBlobRef.value];
176
+ }
177
+
178
+ function serialize(data, options = {}) {
179
+ if (isAsyncIteratorObject(data) && !options.outputFormat) {
180
+ return mapEventIterator(data, {
181
+ value: async (value) => _serialize(value, { outputFormat: "plain" }),
182
+ error: async (e) => {
183
+ return new ErrorEvent({
184
+ data: _serialize(toORPCError(e).toJSON(), { outputFormat: "plain" }),
185
+ cause: e
186
+ });
187
+ }
188
+ });
189
+ }
190
+ return _serialize(data, options);
191
+ }
192
+ function _serialize(data, options) {
193
+ const [json, hasBlob] = jsonSerialize(data);
194
+ if (options.outputFormat === "plain") {
195
+ return json;
196
+ }
197
+ if (options.outputFormat === "URLSearchParams") {
198
+ const params = new URLSearchParams();
199
+ for (const [path, value] of bracketNotationSerialize(json)) {
200
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
201
+ params.append(path, value.toString());
202
+ }
203
+ }
204
+ return params;
205
+ }
206
+ if (json instanceof Blob || json === void 0 || !hasBlob) {
207
+ return json;
208
+ }
209
+ const form = new FormData();
210
+ for (const [path, value] of bracketNotationSerialize(json)) {
211
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
212
+ form.append(path, value.toString());
213
+ } else if (value instanceof Blob) {
214
+ form.append(path, value);
215
+ }
216
+ }
217
+ return form;
218
+ }
219
+ function deserialize(data) {
220
+ if (data instanceof URLSearchParams || data instanceof FormData) {
221
+ return bracketNotationDeserialize(Array.from(data.entries()));
222
+ }
223
+ if (isAsyncIteratorObject(data)) {
224
+ return mapEventIterator(data, {
225
+ value: async (value) => value,
226
+ error: async (e) => {
227
+ if (e instanceof ErrorEvent && isORPCErrorJson(e.data)) {
228
+ return createORPCErrorFromJson(e.data, { cause: e });
229
+ }
230
+ return e;
231
+ }
232
+ });
233
+ }
234
+ return data;
235
+ }
236
+
237
+ export { bracketNotationDeserialize as b, deserialize as d, jsonSerialize as j, serialize as s };
@@ -0,0 +1,242 @@
1
+ import { Meta, Schemas, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, AnyContractProcedure, ContractRouter, AnySchema } from '@temporary-name/contract';
2
+ import { Promisable, StandardLazyRequest, HTTPPath, ClientContext, Interceptor, Value, Client, MaybeOptionalOptions } 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
+ type BuildContextWithAuth<TContext extends Context, TAuthContext> = MergedCurrentContext<TContext, {
8
+ auth: TAuthContext | ('auth' extends keyof TContext ? TContext['auth'] : never);
9
+ }>;
10
+ declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
11
+
12
+ type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
13
+ output: TOutput;
14
+ context: TOutContext;
15
+ }>;
16
+ interface MiddlewareNextFn<TOutput> {
17
+ <U extends Context = {}>(options?: {
18
+ context?: U;
19
+ }): MiddlewareResult<U, TOutput>;
20
+ }
21
+ interface MiddlewareOutputFn<TOutput> {
22
+ (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
23
+ }
24
+ interface MiddlewareOptions<TInContext extends Context, TOutput, TMeta extends Meta> extends ProcedureHandlerOptions<TInContext, TMeta> {
25
+ next: MiddlewareNextFn<TOutput>;
26
+ }
27
+ /**
28
+ * A function that represents a middleware.
29
+ *
30
+ * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
31
+ */
32
+ interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> {
33
+ (options: MiddlewareOptions<TInContext, TOutput, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
34
+ }
35
+ type AnyMiddleware = Middleware<any, any, any, any, any>;
36
+ interface MapInputMiddleware<TInput, TMappedInput> {
37
+ (input: TInput): TMappedInput;
38
+ }
39
+ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
40
+
41
+ type DefaultProcedureHandlerOptions = ProcedureHandlerOptions<Context, Meta>;
42
+ interface ProcedureHandlerOptions<TCurrentContext extends Context, TMeta extends Meta> {
43
+ context: TCurrentContext;
44
+ path: readonly string[];
45
+ procedure: Procedure<Context, Context, Schemas, TMeta>;
46
+ signal?: AbortSignal;
47
+ request?: StandardLazyRequest;
48
+ lastEventId: string | undefined;
49
+ }
50
+ interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
51
+ path: any;
52
+ query: any;
53
+ body: any;
54
+ }, THandlerOutput, TMeta extends Meta> {
55
+ (input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, TMeta>): Promisable<THandlerOutput>;
56
+ }
57
+ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TMeta> {
58
+ __initialContext?: (type: TInitialContext) => unknown;
59
+ middlewares: readonly AnyMiddleware[];
60
+ authConfigs: TypedAuthConfig[];
61
+ inputValidationIndex: number;
62
+ outputValidationIndex: number;
63
+ handler: ProcedureHandler<TCurrentContext, any, any, any>;
64
+ }
65
+ /**
66
+ * This class represents a procedure.
67
+ *
68
+ * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
69
+ */
70
+ declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> {
71
+ /**
72
+ * This property holds the defined options.
73
+ */
74
+ '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TMeta>;
75
+ constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TMeta>);
76
+ }
77
+ type AnyProcedure = Procedure<any, any, Schemas, any>;
78
+ declare function isProcedure(item: unknown): item is AnyProcedure;
79
+
80
+ type ValidatedAuthContext = {};
81
+ interface BasicAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
82
+ tokenPrefix?: string;
83
+ validate: (username: string, password: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
84
+ }
85
+ interface TokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> {
86
+ tokenPrefix?: string;
87
+ validate: (token: string, options: ProcedureHandlerOptions<TCurrentContext, TMeta>) => Promisable<TAuthContext>;
88
+ }
89
+ interface NamedTokenAuthConfig<TAuthContext extends ValidatedAuthContext, TCurrentContext extends Context, TMeta extends Meta> extends TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> {
90
+ name: string;
91
+ }
92
+ type AuthType = 'header' | 'query' | 'cookie' | 'bearer' | 'basic' | 'none';
93
+ type AuthConfig<TAuthType extends AuthType, TAuthContext extends ValidatedAuthContext = ValidatedAuthContext, TCurrentContext extends Context = Context, TMeta extends Meta = Meta> = TAuthType extends 'basic' ? BasicAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'bearer' ? TokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'header' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'query' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'cookie' ? NamedTokenAuthConfig<TAuthContext, TCurrentContext, TMeta> : TAuthType extends 'none' ? {} : never;
94
+ type TypedAuthConfig<TAuthType extends AuthType = AuthType> = {
95
+ type: TAuthType;
96
+ } & AuthConfig<TAuthType, object>;
97
+
98
+ /**
99
+ * Represents a router, which defines a hierarchical structure of procedures.
100
+ *
101
+ * @info A procedure is a router too.
102
+ * @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
103
+ */
104
+ type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UMeta> : {
105
+ [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
106
+ };
107
+ type AnyRouter = Router<any, any>;
108
+ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
109
+ /**
110
+ * Infer all initial context of the router.
111
+ *
112
+ * @info A procedure is a router too.
113
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
114
+ */
115
+ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any> ? UInitialContext : {
116
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
117
+ };
118
+ /**
119
+ * Infer all current context of the router.
120
+ *
121
+ * @info A procedure is a router too.
122
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
123
+ */
124
+ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any> ? UCurrentContext : {
125
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
126
+ };
127
+ /**
128
+ * Infer all router inputs
129
+ *
130
+ * @info A procedure is a router too.
131
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
132
+ */
133
+ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferProcedureClientInputs<USchemas> : {
134
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
135
+ };
136
+ /**
137
+ * Infer all router outputs
138
+ *
139
+ * @info A procedure is a router too.
140
+ * @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
141
+ */
142
+ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
143
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
144
+ };
145
+
146
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
147
+ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
148
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
149
+ };
150
+ declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
151
+ type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext>> : T extends Procedure<infer UInitialContext, infer UCurrentContext, infer USchemas, infer UMeta> ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, UMeta> : {
152
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext> : never;
153
+ };
154
+ interface EnhanceRouterOptions extends EnhanceRouteOptions {
155
+ middlewares: readonly AnyMiddleware[];
156
+ dedupeLeadingMiddlewares: boolean;
157
+ }
158
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: EnhanceRouterOptions): EnhancedRouter<T, TInitialContext, TCurrentContext>;
159
+ interface TraverseContractProceduresOptions {
160
+ router: AnyContractRouter | AnyRouter;
161
+ path: readonly string[];
162
+ }
163
+ interface TraverseContractProcedureCallbackOptions {
164
+ contract: AnyContractProcedure | AnyProcedure;
165
+ path: readonly string[];
166
+ }
167
+ /**
168
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
169
+ */
170
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
171
+ interface LazyTraverseContractProceduresOptions {
172
+ router: Lazy<AnyRouter>;
173
+ path: readonly string[];
174
+ }
175
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
176
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
177
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
178
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
179
+ };
180
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
181
+
182
+ declare const LAZY_SYMBOL: unique symbol;
183
+ interface LazyMeta {
184
+ prefix?: HTTPPath;
185
+ }
186
+ interface Lazy<T> {
187
+ [LAZY_SYMBOL]: {
188
+ loader: () => Promise<{
189
+ default: T;
190
+ }>;
191
+ meta: LazyMeta;
192
+ };
193
+ }
194
+ type Lazyable<T> = T | Lazy<T>;
195
+ /**
196
+ * @internal
197
+ */
198
+ declare function lazyInternal<T>(loader: () => Promise<{
199
+ default: T;
200
+ }>, meta?: LazyMeta): Lazy<T>;
201
+ /**
202
+ * Creates a lazy-loaded item.
203
+ *
204
+ * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
205
+ */
206
+ declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
207
+ default: T;
208
+ }>): EnhancedRouter<Lazy<T>, {}, {}>;
209
+ declare function isLazy(item: unknown): item is Lazy<any>;
210
+ declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
211
+ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
212
+ default: T extends Lazy<infer U> ? U : T;
213
+ }>;
214
+
215
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
216
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TMeta extends Meta> extends ProcedureHandlerOptions<TInitialContext, TMeta> {
217
+ input: {
218
+ path: unknown;
219
+ query: unknown;
220
+ body: unknown;
221
+ };
222
+ }
223
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TMeta extends Meta, TClientContext extends ClientContext> = {
224
+ /**
225
+ * This is helpful for logging and analytics.
226
+ */
227
+ path?: readonly string[];
228
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TMeta>, Promise<InferSchemaOutput<TOutputSchema>>>[];
229
+ } & (Record<never, never> extends TInitialContext ? {
230
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
231
+ } : {
232
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
233
+ });
234
+ /**
235
+ * Create Server-side client from a procedure.
236
+ *
237
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
238
+ */
239
+ declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TMeta, TClientContext>>): ProcedureClient<TClientContext, TSchemas>;
240
+
241
+ export { isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as S, createAccessibleLazyRouter as W, enhanceRouter as X, traverseContractProcedures as a0, resolveContractProcedures as a1, unlazyRouter as a3, mergeCurrentContext as m, LAZY_SYMBOL as n, lazyInternal as p, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, middlewareOutputFn as y };
242
+ export type { LazyTraverseContractProceduresOptions as $, AuthType as A, BuildContextWithAuth as B, Context as C, DefaultProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, InferRouterInputs as O, InferRouterOutputs as Q, Router as R, TypedAuthConfig as T, AccessibleLazyRouter as U, ValidatedAuthContext as V, TraverseContractProceduresOptions as Y, TraverseContractProcedureCallbackOptions as Z, ContractProcedureCallbackOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a2, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, AuthConfig as e, ProcedureHandler as f, EnhancedRouter as g, MapInputMiddleware as h, AnyMiddleware as i, AnyProcedure as j, Lazyable as k, AnyRouter as l, LazyMeta as o, MiddlewareResult as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };