@orpc/server 0.0.0-next.d7b5662 → 0.0.0-next.d7c4772

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 (89) hide show
  1. package/README.md +128 -0
  2. package/dist/adapters/aws-lambda/index.d.mts +46 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +46 -0
  4. package/dist/adapters/aws-lambda/index.mjs +42 -0
  5. package/dist/adapters/bun-ws/index.d.mts +36 -0
  6. package/dist/adapters/bun-ws/index.d.ts +36 -0
  7. package/dist/adapters/bun-ws/index.mjs +47 -0
  8. package/dist/adapters/crossws/index.d.mts +33 -0
  9. package/dist/adapters/crossws/index.d.ts +33 -0
  10. package/dist/adapters/crossws/index.mjs +45 -0
  11. package/dist/adapters/fetch/index.d.mts +124 -0
  12. package/dist/adapters/fetch/index.d.ts +124 -0
  13. package/dist/adapters/fetch/index.mjs +179 -0
  14. package/dist/adapters/message-port/index.d.mts +31 -0
  15. package/dist/adapters/message-port/index.d.ts +31 -0
  16. package/dist/adapters/message-port/index.mjs +39 -0
  17. package/dist/adapters/node/index.d.mts +99 -0
  18. package/dist/adapters/node/index.d.ts +99 -0
  19. package/dist/adapters/node/index.mjs +152 -0
  20. package/dist/adapters/standard/index.d.mts +21 -0
  21. package/dist/adapters/standard/index.d.ts +21 -0
  22. package/dist/adapters/standard/index.mjs +8 -0
  23. package/dist/adapters/standard-peer/index.d.mts +18 -0
  24. package/dist/adapters/standard-peer/index.d.ts +18 -0
  25. package/dist/adapters/standard-peer/index.mjs +7 -0
  26. package/dist/adapters/websocket/index.d.mts +54 -0
  27. package/dist/adapters/websocket/index.d.ts +54 -0
  28. package/dist/adapters/websocket/index.mjs +67 -0
  29. package/dist/adapters/ws/index.d.mts +31 -0
  30. package/dist/adapters/ws/index.d.ts +31 -0
  31. package/dist/adapters/ws/index.mjs +37 -0
  32. package/dist/helpers/index.d.mts +134 -0
  33. package/dist/helpers/index.d.ts +134 -0
  34. package/dist/helpers/index.mjs +188 -0
  35. package/dist/hibernation/index.d.mts +44 -0
  36. package/dist/hibernation/index.d.ts +44 -0
  37. package/dist/hibernation/index.mjs +65 -0
  38. package/dist/index.d.mts +803 -0
  39. package/dist/index.d.ts +803 -0
  40. package/dist/index.mjs +489 -0
  41. package/dist/plugins/index.d.mts +169 -0
  42. package/dist/plugins/index.d.ts +169 -0
  43. package/dist/plugins/index.mjs +285 -0
  44. package/dist/shared/server.7jWaIryJ.mjs +416 -0
  45. package/dist/shared/server.B7b2w3_i.d.ts +12 -0
  46. package/dist/shared/server.BEFBl-Cb.d.mts +12 -0
  47. package/dist/shared/server.BHZCyRuJ.mjs +219 -0
  48. package/dist/shared/server.BU4WI18A.d.mts +32 -0
  49. package/dist/shared/server.BW-nUGgA.mjs +36 -0
  50. package/dist/shared/server.Bmh5xd4n.d.ts +74 -0
  51. package/dist/shared/server.CYNGeoCm.d.mts +194 -0
  52. package/dist/shared/server.CYNGeoCm.d.ts +194 -0
  53. package/dist/shared/server.D0H-iaY3.d.ts +32 -0
  54. package/dist/shared/server.DZ5BIITo.mjs +9 -0
  55. package/dist/shared/server.DhJj-1X9.d.mts +42 -0
  56. package/dist/shared/server.UVMTOWrk.mjs +26 -0
  57. package/dist/shared/server.gqRxT-yN.d.mts +74 -0
  58. package/dist/shared/server.jMTkVNIb.d.ts +42 -0
  59. package/package.json +94 -15
  60. package/dist/chunk-YAVPFNPF.js +0 -182
  61. package/dist/fetch.js +0 -286
  62. package/dist/index.js +0 -518
  63. package/dist/src/builder.d.ts +0 -35
  64. package/dist/src/fetch/composite-handler.d.ts +0 -8
  65. package/dist/src/fetch/index.d.ts +0 -6
  66. package/dist/src/fetch/orpc-handler.d.ts +0 -20
  67. package/dist/src/fetch/orpc-payload-codec.d.ts +0 -9
  68. package/dist/src/fetch/orpc-procedure-matcher.d.ts +0 -12
  69. package/dist/src/fetch/super-json.d.ts +0 -12
  70. package/dist/src/fetch/types.d.ts +0 -16
  71. package/dist/src/hidden.d.ts +0 -6
  72. package/dist/src/implementer-chainable.d.ts +0 -10
  73. package/dist/src/index.d.ts +0 -23
  74. package/dist/src/lazy-decorated.d.ts +0 -10
  75. package/dist/src/lazy-utils.d.ts +0 -4
  76. package/dist/src/lazy.d.ts +0 -18
  77. package/dist/src/middleware-decorated.d.ts +0 -8
  78. package/dist/src/middleware.d.ts +0 -23
  79. package/dist/src/procedure-builder.d.ts +0 -22
  80. package/dist/src/procedure-client.d.ts +0 -34
  81. package/dist/src/procedure-decorated.d.ts +0 -14
  82. package/dist/src/procedure-implementer.d.ts +0 -18
  83. package/dist/src/procedure.d.ts +0 -23
  84. package/dist/src/router-builder.d.ts +0 -29
  85. package/dist/src/router-client.d.ts +0 -25
  86. package/dist/src/router-implementer.d.ts +0 -21
  87. package/dist/src/router.d.ts +0 -16
  88. package/dist/src/types.d.ts +0 -12
  89. package/dist/src/utils.d.ts +0 -3
@@ -0,0 +1,74 @@
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta } from '@orpc/contract';
3
+ import { Interceptor } from '@orpc/shared';
4
+ import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
+ import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.CYNGeoCm.mjs';
6
+
7
+ interface StandardHandlerPlugin<T extends Context> {
8
+ order?: number;
9
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
10
+ }
11
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
+ protected readonly plugins: TPlugin[];
13
+ constructor(plugins?: readonly TPlugin[]);
14
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
15
+ }
16
+
17
+ type StandardParams = Record<string, string>;
18
+ type StandardMatchResult = {
19
+ path: readonly string[];
20
+ procedure: AnyProcedure;
21
+ params?: StandardParams;
22
+ } | undefined;
23
+ interface StandardMatcher {
24
+ init(router: AnyRouter): void;
25
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
26
+ }
27
+ interface StandardCodec {
28
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
29
+ encodeError(error: ORPCError<any, any>): StandardResponse;
30
+ decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
31
+ }
32
+
33
+ interface StandardHandleOptions<T extends Context> {
34
+ prefix?: HTTPPath;
35
+ context: T;
36
+ }
37
+ type StandardHandleResult = {
38
+ matched: true;
39
+ response: StandardResponse;
40
+ } | {
41
+ matched: false;
42
+ response: undefined;
43
+ };
44
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
45
+ request: StandardLazyRequest;
46
+ }
47
+ interface StandardHandlerOptions<TContext extends Context> {
48
+ plugins?: StandardHandlerPlugin<TContext>[];
49
+ /**
50
+ * Interceptors at the request level, helpful when you want catch errors
51
+ */
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
53
+ /**
54
+ * Interceptors at the root level, helpful when you want override the request/response
55
+ */
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
57
+ /**
58
+ *
59
+ * Interceptors for procedure client.
60
+ */
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
62
+ }
63
+ declare class StandardHandler<T extends Context> {
64
+ private readonly matcher;
65
+ private readonly codec;
66
+ private readonly interceptors;
67
+ private readonly clientInterceptors;
68
+ private readonly rootInterceptors;
69
+ constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
70
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
71
+ }
72
+
73
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as f };
74
+ export type { StandardCodec as S, StandardParams as a, StandardHandleOptions as b, StandardHandleResult as c, StandardHandlerInterceptorOptions as d, StandardHandlerOptions as e, StandardHandlerPlugin as g, StandardMatchResult as h, StandardMatcher as i };
@@ -0,0 +1,42 @@
1
+ import { ErrorMap, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure } from '@orpc/contract';
2
+ import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.CYNGeoCm.js';
3
+
4
+ declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
5
+ 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> & {
6
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
7
+ };
8
+ declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
9
+ type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
10
+ [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
11
+ };
12
+ interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
13
+ middlewares: readonly AnyMiddleware[];
14
+ errorMap: TErrorMap;
15
+ dedupeLeadingMiddlewares: boolean;
16
+ }
17
+ declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
18
+ interface TraverseContractProceduresOptions {
19
+ router: AnyContractRouter | AnyRouter;
20
+ path: readonly string[];
21
+ }
22
+ interface TraverseContractProcedureCallbackOptions {
23
+ contract: AnyContractProcedure | AnyProcedure;
24
+ path: readonly string[];
25
+ }
26
+ /**
27
+ * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
28
+ */
29
+ type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
30
+ interface LazyTraverseContractProceduresOptions {
31
+ router: Lazy<AnyRouter>;
32
+ path: readonly string[];
33
+ }
34
+ declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
35
+ declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
36
+ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
37
+ [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
38
+ };
39
+ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
40
+
41
+ export { createAccessibleLazyRouter as c, enhanceRouter as e, getRouter as g, resolveContractProcedures as r, traverseContractProcedures as t, unlazyRouter as u };
42
+ export type { AccessibleLazyRouter as A, ContractProcedureCallbackOptions as C, EnhanceRouterOptions as E, LazyTraverseContractProceduresOptions as L, TraverseContractProcedureCallbackOptions as T, UnlaziedRouter as U, EnhancedRouter as a, TraverseContractProceduresOptions as b };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.d7b5662",
4
+ "version": "0.0.0-next.d7c4772",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,33 +15,112 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
+ },
22
+ "./helpers": {
23
+ "types": "./dist/helpers/index.d.mts",
24
+ "import": "./dist/helpers/index.mjs",
25
+ "default": "./dist/helpers/index.mjs"
26
+ },
27
+ "./plugins": {
28
+ "types": "./dist/plugins/index.d.mts",
29
+ "import": "./dist/plugins/index.mjs",
30
+ "default": "./dist/plugins/index.mjs"
31
+ },
32
+ "./hibernation": {
33
+ "types": "./dist/hibernation/index.d.mts",
34
+ "import": "./dist/hibernation/index.mjs",
35
+ "default": "./dist/hibernation/index.mjs"
36
+ },
37
+ "./standard": {
38
+ "types": "./dist/adapters/standard/index.d.mts",
39
+ "import": "./dist/adapters/standard/index.mjs",
40
+ "default": "./dist/adapters/standard/index.mjs"
41
+ },
42
+ "./standard-peer": {
43
+ "types": "./dist/adapters/standard-peer/index.d.mts",
44
+ "import": "./dist/adapters/standard-peer/index.mjs",
45
+ "default": "./dist/adapters/standard-peer/index.mjs"
21
46
  },
22
47
  "./fetch": {
23
- "types": "./dist/src/fetch/index.d.ts",
24
- "import": "./dist/fetch.js",
25
- "default": "./dist/fetch.js"
48
+ "types": "./dist/adapters/fetch/index.d.mts",
49
+ "import": "./dist/adapters/fetch/index.mjs",
50
+ "default": "./dist/adapters/fetch/index.mjs"
51
+ },
52
+ "./node": {
53
+ "types": "./dist/adapters/node/index.d.mts",
54
+ "import": "./dist/adapters/node/index.mjs",
55
+ "default": "./dist/adapters/node/index.mjs"
56
+ },
57
+ "./aws-lambda": {
58
+ "types": "./dist/adapters/aws-lambda/index.d.mts",
59
+ "import": "./dist/adapters/aws-lambda/index.mjs",
60
+ "default": "./dist/adapters/aws-lambda/index.mjs"
61
+ },
62
+ "./websocket": {
63
+ "types": "./dist/adapters/websocket/index.d.mts",
64
+ "import": "./dist/adapters/websocket/index.mjs",
65
+ "default": "./dist/adapters/websocket/index.mjs"
26
66
  },
27
- "./🔒/*": {
28
- "types": "./dist/src/*.d.ts"
67
+ "./crossws": {
68
+ "types": "./dist/adapters/crossws/index.d.mts",
69
+ "import": "./dist/adapters/crossws/index.mjs",
70
+ "default": "./dist/adapters/crossws/index.mjs"
71
+ },
72
+ "./ws": {
73
+ "types": "./dist/adapters/ws/index.d.mts",
74
+ "import": "./dist/adapters/ws/index.mjs",
75
+ "default": "./dist/adapters/ws/index.mjs"
76
+ },
77
+ "./bun-ws": {
78
+ "types": "./dist/adapters/bun-ws/index.d.mts",
79
+ "import": "./dist/adapters/bun-ws/index.mjs",
80
+ "default": "./dist/adapters/bun-ws/index.mjs"
81
+ },
82
+ "./message-port": {
83
+ "types": "./dist/adapters/message-port/index.d.mts",
84
+ "import": "./dist/adapters/message-port/index.mjs",
85
+ "default": "./dist/adapters/message-port/index.mjs"
29
86
  }
30
87
  },
31
88
  "files": [
32
- "!**/*.map",
33
- "!**/*.tsbuildinfo",
34
89
  "dist"
35
90
  ],
91
+ "peerDependencies": {
92
+ "crossws": ">=0.3.4",
93
+ "ws": ">=8.18.1"
94
+ },
95
+ "peerDependenciesMeta": {
96
+ "crossws": {
97
+ "optional": true
98
+ },
99
+ "ws": {
100
+ "optional": true
101
+ }
102
+ },
36
103
  "dependencies": {
37
- "@orpc/contract": "0.0.0-next.d7b5662",
38
- "@orpc/shared": "0.0.0-next.d7b5662"
104
+ "cookie": "^1.0.2",
105
+ "@orpc/client": "0.0.0-next.d7c4772",
106
+ "@orpc/contract": "0.0.0-next.d7c4772",
107
+ "@orpc/shared": "0.0.0-next.d7c4772",
108
+ "@orpc/interop": "0.0.0-next.d7c4772",
109
+ "@orpc/standard-server": "0.0.0-next.d7c4772",
110
+ "@orpc/standard-server-aws-lambda": "0.0.0-next.d7c4772",
111
+ "@orpc/standard-server-fetch": "0.0.0-next.d7c4772",
112
+ "@orpc/standard-server-node": "0.0.0-next.d7c4772",
113
+ "@orpc/standard-server-peer": "0.0.0-next.d7c4772"
39
114
  },
40
115
  "devDependencies": {
41
- "zod": "^3.24.1"
116
+ "@types/ws": "^8.18.1",
117
+ "crossws": "^0.4.1",
118
+ "next": "^15.5.0",
119
+ "supertest": "^7.1.4",
120
+ "ws": "^8.18.3"
42
121
  },
43
122
  "scripts": {
44
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
123
+ "build": "unbuild",
45
124
  "build:watch": "pnpm run build --watch",
46
125
  "type:check": "tsc -b"
47
126
  }
@@ -1,182 +0,0 @@
1
- // src/utils.ts
2
- function mergeContext(a, b) {
3
- if (!a)
4
- return b;
5
- if (!b)
6
- return a;
7
- return {
8
- ...a,
9
- ...b
10
- };
11
- }
12
-
13
- // src/procedure.ts
14
- import { isContractProcedure } from "@orpc/contract";
15
- var Procedure = class {
16
- "~type" = "Procedure";
17
- "~orpc";
18
- constructor(def) {
19
- this["~orpc"] = def;
20
- }
21
- };
22
- function isProcedure(item) {
23
- if (item instanceof Procedure) {
24
- return true;
25
- }
26
- return (typeof item === "object" || typeof item === "function") && item !== null && "~type" in item && item["~type"] === "Procedure" && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "contract" in item["~orpc"] && isContractProcedure(item["~orpc"].contract) && "func" in item["~orpc"] && typeof item["~orpc"].func === "function";
27
- }
28
-
29
- // src/lazy.ts
30
- var LAZY_LOADER_SYMBOL = Symbol("ORPC_LAZY_LOADER");
31
- function lazy(loader) {
32
- return {
33
- [LAZY_LOADER_SYMBOL]: loader
34
- };
35
- }
36
- function isLazy(item) {
37
- return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_LOADER_SYMBOL in item && typeof item[LAZY_LOADER_SYMBOL] === "function";
38
- }
39
- function unlazy(lazied) {
40
- return isLazy(lazied) ? lazied[LAZY_LOADER_SYMBOL]() : Promise.resolve({ default: lazied });
41
- }
42
- function flatLazy(lazied) {
43
- const flattenLoader = async () => {
44
- let current = await unlazy(lazied);
45
- while (true) {
46
- if (!isLazy(current.default)) {
47
- break;
48
- }
49
- current = await unlazy(current.default);
50
- }
51
- return current;
52
- };
53
- return lazy(flattenLoader);
54
- }
55
-
56
- // src/procedure-client.ts
57
- import { executeWithHooks, value } from "@orpc/shared";
58
- import { ORPCError } from "@orpc/shared/error";
59
- function createProcedureClient(options) {
60
- return async (...[input, callerOptions]) => {
61
- const path = options.path ?? [];
62
- const { default: procedure } = await unlazy(options.procedure);
63
- const context = await value(options.context);
64
- const meta = {
65
- path,
66
- procedure,
67
- signal: callerOptions?.signal
68
- };
69
- const executeWithValidation = async () => {
70
- const validInput = await validateInput(procedure, input);
71
- const output = await executeMiddlewareChain(
72
- procedure,
73
- validInput,
74
- context,
75
- meta
76
- );
77
- return validateOutput(procedure, output);
78
- };
79
- return executeWithHooks({
80
- hooks: options,
81
- input,
82
- context,
83
- meta,
84
- execute: executeWithValidation
85
- });
86
- };
87
- }
88
- async function validateInput(procedure, input) {
89
- const schema = procedure["~orpc"].contract["~orpc"].InputSchema;
90
- if (!schema)
91
- return input;
92
- const result = await schema["~standard"].validate(input);
93
- if (result.issues) {
94
- throw new ORPCError({
95
- message: "Input validation failed",
96
- code: "BAD_REQUEST",
97
- issues: result.issues
98
- });
99
- }
100
- return result.value;
101
- }
102
- async function validateOutput(procedure, output) {
103
- const schema = procedure["~orpc"].contract["~orpc"].OutputSchema;
104
- if (!schema)
105
- return output;
106
- const result = await schema["~standard"].validate(output);
107
- if (result.issues) {
108
- throw new ORPCError({
109
- message: "Output validation failed",
110
- code: "INTERNAL_SERVER_ERROR",
111
- issues: result.issues
112
- });
113
- }
114
- return result.value;
115
- }
116
- async function executeMiddlewareChain(procedure, input, context, meta) {
117
- const middlewares = procedure["~orpc"].middlewares ?? [];
118
- let currentMidIndex = 0;
119
- let currentContext = context;
120
- const next = async (nextOptions) => {
121
- const mid = middlewares[currentMidIndex];
122
- currentMidIndex += 1;
123
- currentContext = mergeContext(currentContext, nextOptions.context);
124
- if (mid) {
125
- return await mid(input, currentContext, {
126
- ...meta,
127
- next,
128
- output: (output) => ({ output, context: void 0 })
129
- });
130
- }
131
- const result = {
132
- output: await procedure["~orpc"].func(input, currentContext, meta),
133
- context: currentContext
134
- };
135
- return result;
136
- };
137
- return (await next({})).output;
138
- }
139
-
140
- // src/router.ts
141
- function getRouterChild(router, ...path) {
142
- let current = router;
143
- for (let i = 0; i < path.length; i++) {
144
- const segment = path[i];
145
- if (!current) {
146
- return void 0;
147
- }
148
- if (isProcedure(current)) {
149
- return void 0;
150
- }
151
- if (!isLazy(current)) {
152
- current = current[segment];
153
- continue;
154
- }
155
- const lazied = current;
156
- const rest = path.slice(i);
157
- const newLazy = lazy(async () => {
158
- const unwrapped = await unlazy(lazied);
159
- if (!unwrapped.default) {
160
- return unwrapped;
161
- }
162
- const next = getRouterChild(unwrapped.default, ...rest);
163
- return { default: next };
164
- });
165
- return flatLazy(newLazy);
166
- }
167
- return current;
168
- }
169
-
170
- export {
171
- mergeContext,
172
- Procedure,
173
- isProcedure,
174
- LAZY_LOADER_SYMBOL,
175
- lazy,
176
- isLazy,
177
- unlazy,
178
- flatLazy,
179
- createProcedureClient,
180
- getRouterChild
181
- };
182
- //# sourceMappingURL=chunk-YAVPFNPF.js.map