@orpc/server 0.0.0-next.4220427 → 0.0.0-next.43889a7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-V3I7RIRY.js → chunk-26GHKV43.js} +6 -7
- package/dist/{chunk-DNG2IB3R.js → chunk-LDIL7OEP.js} +40 -50
- package/dist/fetch.js +4 -4
- package/dist/hono.js +5 -5
- package/dist/index.js +687 -181
- package/dist/next.js +5 -5
- package/dist/node.js +10 -10
- package/dist/src/adapters/fetch/orpc-handler.d.ts +4 -4
- package/dist/src/adapters/fetch/types.d.ts +3 -3
- package/dist/src/adapters/hono/middleware.d.ts +3 -3
- package/dist/src/adapters/next/serve.d.ts +3 -3
- package/dist/src/adapters/node/orpc-handler.d.ts +5 -5
- package/dist/src/adapters/node/types.d.ts +3 -3
- package/dist/src/builder-with-errors-middlewares.d.ts +49 -0
- package/dist/src/builder-with-errors.d.ts +49 -0
- package/dist/src/builder-with-middlewares.d.ts +49 -0
- package/dist/src/builder.d.ts +33 -23
- package/dist/src/config.d.ts +6 -0
- package/dist/src/context.d.ts +10 -0
- package/dist/src/error.d.ts +1 -1
- package/dist/src/hidden.d.ts +2 -2
- package/dist/src/implementer-chainable.d.ts +11 -5
- package/dist/src/index.d.ts +5 -4
- package/dist/src/lazy-decorated.d.ts +4 -6
- package/dist/src/middleware-decorated.d.ts +5 -5
- package/dist/src/middleware.d.ts +19 -15
- package/dist/src/procedure-builder-with-input.d.ts +35 -0
- package/dist/src/procedure-builder-with-output.d.ts +34 -0
- package/dist/src/procedure-builder.d.ts +23 -19
- package/dist/src/procedure-client.d.ts +8 -21
- package/dist/src/procedure-decorated.d.ts +21 -11
- package/dist/src/procedure-implementer.d.ts +14 -10
- package/dist/src/procedure-utils.d.ts +17 -0
- package/dist/src/procedure.d.ts +16 -12
- package/dist/src/router-builder.d.ts +20 -16
- package/dist/src/router-client.d.ts +7 -6
- package/dist/src/router-implementer.d.ts +12 -10
- package/dist/src/router.d.ts +4 -4
- package/dist/src/types.d.ts +0 -3
- package/package.json +3 -3
- package/dist/src/utils.d.ts +0 -3
package/dist/index.js
CHANGED
@@ -8,16 +8,24 @@ import {
|
|
8
8
|
isLazy,
|
9
9
|
isProcedure,
|
10
10
|
lazy,
|
11
|
-
|
11
|
+
middlewareOutputFn,
|
12
12
|
unlazy
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-LDIL7OEP.js";
|
14
14
|
|
15
15
|
// src/builder.ts
|
16
|
+
import { ContractProcedure as ContractProcedure4 } from "@orpc/contract";
|
17
|
+
|
18
|
+
// src/builder-with-errors.ts
|
19
|
+
import { ContractProcedure as ContractProcedure2 } from "@orpc/contract";
|
20
|
+
|
21
|
+
// src/builder-with-errors-middlewares.ts
|
16
22
|
import { ContractProcedure } from "@orpc/contract";
|
17
23
|
|
18
|
-
// src/
|
19
|
-
import {
|
20
|
-
|
24
|
+
// src/procedure-builder.ts
|
25
|
+
import { ContractProcedureBuilder, DecoratedContractProcedure as DecoratedContractProcedure4 } from "@orpc/contract";
|
26
|
+
|
27
|
+
// src/procedure-builder-with-input.ts
|
28
|
+
import { ContractProcedureBuilderWithInput, DecoratedContractProcedure as DecoratedContractProcedure2 } from "@orpc/contract";
|
21
29
|
|
22
30
|
// src/middleware-decorated.ts
|
23
31
|
function decorateMiddleware(middleware) {
|
@@ -31,8 +39,8 @@ function decorateMiddleware(middleware) {
|
|
31
39
|
decorated.concat = (concatMiddleware, mapInput) => {
|
32
40
|
const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
|
33
41
|
const concatted = decorateMiddleware((options, input, output, ...rest) => {
|
34
|
-
const next = async (nextOptions) => {
|
35
|
-
return mapped({ ...options, context:
|
42
|
+
const next = async (...[nextOptions]) => {
|
43
|
+
return mapped({ ...options, context: { ...nextOptions?.context, ...options.context } }, input, output, ...rest);
|
36
44
|
};
|
37
45
|
const merged = middleware({ ...options, next }, input, output, ...rest);
|
38
46
|
return merged;
|
@@ -44,58 +52,82 @@ function decorateMiddleware(middleware) {
|
|
44
52
|
|
45
53
|
// src/procedure-decorated.ts
|
46
54
|
import { DecoratedContractProcedure } from "@orpc/contract";
|
47
|
-
|
48
|
-
|
49
|
-
procedure
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
55
|
+
var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
56
|
+
static decorate(procedure) {
|
57
|
+
if (procedure instanceof _DecoratedProcedure) {
|
58
|
+
return procedure;
|
59
|
+
}
|
60
|
+
return new _DecoratedProcedure(procedure["~orpc"]);
|
61
|
+
}
|
62
|
+
prefix(prefix) {
|
63
|
+
return new _DecoratedProcedure({
|
64
|
+
...this["~orpc"],
|
65
|
+
contract: DecoratedContractProcedure.decorate(this["~orpc"].contract).prefix(prefix)
|
66
|
+
});
|
67
|
+
}
|
68
|
+
route(route) {
|
69
|
+
return new _DecoratedProcedure({
|
70
|
+
...this["~orpc"],
|
71
|
+
contract: DecoratedContractProcedure.decorate(this["~orpc"].contract).route(route)
|
72
|
+
});
|
73
|
+
}
|
74
|
+
errors(errors) {
|
75
|
+
return new _DecoratedProcedure({
|
76
|
+
...this["~orpc"],
|
77
|
+
contract: DecoratedContractProcedure.decorate(this["~orpc"].contract).errors(errors)
|
78
|
+
});
|
79
|
+
}
|
80
|
+
use(middleware, mapInput) {
|
68
81
|
const middleware_ = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
69
|
-
return
|
70
|
-
...
|
71
|
-
middlewares: [...
|
72
|
-
})
|
73
|
-
}
|
74
|
-
|
75
|
-
return
|
76
|
-
...
|
77
|
-
contract: DecoratedContractProcedure.decorate(
|
78
|
-
})
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
+
return new _DecoratedProcedure({
|
83
|
+
...this["~orpc"],
|
84
|
+
middlewares: [...this["~orpc"].middlewares, middleware_]
|
85
|
+
});
|
86
|
+
}
|
87
|
+
unshiftTag(...tags) {
|
88
|
+
return new _DecoratedProcedure({
|
89
|
+
...this["~orpc"],
|
90
|
+
contract: DecoratedContractProcedure.decorate(this["~orpc"].contract).unshiftTag(...tags)
|
91
|
+
});
|
92
|
+
}
|
93
|
+
unshiftMiddleware(...middlewares) {
|
94
|
+
const castedMiddlewares = middlewares;
|
95
|
+
if (this["~orpc"].middlewares.length) {
|
82
96
|
let min = 0;
|
83
|
-
for (let i = 0; i <
|
84
|
-
const index =
|
97
|
+
for (let i = 0; i < this["~orpc"].middlewares.length; i++) {
|
98
|
+
const index = castedMiddlewares.indexOf(this["~orpc"].middlewares[i], min);
|
85
99
|
if (index === -1) {
|
86
|
-
|
100
|
+
castedMiddlewares.push(...this["~orpc"].middlewares.slice(i));
|
87
101
|
break;
|
88
102
|
}
|
89
103
|
min = index + 1;
|
90
104
|
}
|
91
105
|
}
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
}
|
106
|
+
const numNewMiddlewares = castedMiddlewares.length - this["~orpc"].middlewares.length;
|
107
|
+
const decorated = new _DecoratedProcedure({
|
108
|
+
...this["~orpc"],
|
109
|
+
inputValidationIndex: this["~orpc"].inputValidationIndex + numNewMiddlewares,
|
110
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex + numNewMiddlewares,
|
111
|
+
middlewares: castedMiddlewares
|
112
|
+
});
|
113
|
+
return decorated;
|
114
|
+
}
|
115
|
+
/**
|
116
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
117
|
+
*/
|
118
|
+
callable(...rest) {
|
119
|
+
return Object.assign(createProcedureClient(this, ...rest), {
|
120
|
+
"~type": "Procedure",
|
121
|
+
"~orpc": this["~orpc"]
|
122
|
+
});
|
123
|
+
}
|
124
|
+
/**
|
125
|
+
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
126
|
+
*/
|
127
|
+
actionable(...rest) {
|
128
|
+
return this.callable(...rest);
|
129
|
+
}
|
130
|
+
};
|
99
131
|
|
100
132
|
// src/procedure-implementer.ts
|
101
133
|
var ProcedureImplementer = class _ProcedureImplementer {
|
@@ -108,15 +140,146 @@ var ProcedureImplementer = class _ProcedureImplementer {
|
|
108
140
|
const mappedMiddleware = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
109
141
|
return new _ProcedureImplementer({
|
110
142
|
...this["~orpc"],
|
111
|
-
middlewares: [...this["~orpc"].middlewares
|
143
|
+
middlewares: [...this["~orpc"].middlewares, mappedMiddleware]
|
112
144
|
});
|
113
145
|
}
|
114
146
|
handler(handler) {
|
115
|
-
return
|
116
|
-
|
147
|
+
return new DecoratedProcedure({
|
148
|
+
...this["~orpc"],
|
149
|
+
handler
|
150
|
+
});
|
151
|
+
}
|
152
|
+
};
|
153
|
+
|
154
|
+
// src/procedure-builder-with-input.ts
|
155
|
+
var ProcedureBuilderWithInput = class _ProcedureBuilderWithInput {
|
156
|
+
"~type" = "ProcedureBuilderWithInput";
|
157
|
+
"~orpc";
|
158
|
+
constructor(def) {
|
159
|
+
this["~orpc"] = def;
|
160
|
+
}
|
161
|
+
errors(errors) {
|
162
|
+
return new _ProcedureBuilderWithInput({
|
163
|
+
...this["~orpc"],
|
164
|
+
contract: DecoratedContractProcedure2.decorate(this["~orpc"].contract).errors(errors)
|
165
|
+
});
|
166
|
+
}
|
167
|
+
route(route) {
|
168
|
+
return new _ProcedureBuilderWithInput({
|
169
|
+
...this["~orpc"],
|
170
|
+
contract: DecoratedContractProcedure2.decorate(this["~orpc"].contract).route(route)
|
171
|
+
});
|
172
|
+
}
|
173
|
+
use(middleware, mapInput) {
|
174
|
+
const maybeWithMapInput = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
175
|
+
return new _ProcedureBuilderWithInput({
|
176
|
+
...this["~orpc"],
|
177
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex + 1,
|
178
|
+
middlewares: [...this["~orpc"].middlewares, maybeWithMapInput]
|
179
|
+
});
|
180
|
+
}
|
181
|
+
output(schema, example) {
|
182
|
+
return new ProcedureImplementer({
|
183
|
+
...this["~orpc"],
|
184
|
+
contract: new ContractProcedureBuilderWithInput(this["~orpc"].contract["~orpc"]).output(schema, example)
|
185
|
+
});
|
186
|
+
}
|
187
|
+
handler(handler) {
|
188
|
+
return new DecoratedProcedure({
|
189
|
+
...this["~orpc"],
|
190
|
+
handler
|
191
|
+
});
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
// src/procedure-builder-with-output.ts
|
196
|
+
import { ContractProcedureBuilderWithOutput, DecoratedContractProcedure as DecoratedContractProcedure3 } from "@orpc/contract";
|
197
|
+
var ProcedureBuilderWithOutput = class _ProcedureBuilderWithOutput {
|
198
|
+
"~type" = "ProcedureBuilderWithOutput";
|
199
|
+
"~orpc";
|
200
|
+
constructor(def) {
|
201
|
+
this["~orpc"] = def;
|
202
|
+
}
|
203
|
+
errors(errors) {
|
204
|
+
return new _ProcedureBuilderWithOutput({
|
205
|
+
...this["~orpc"],
|
206
|
+
contract: DecoratedContractProcedure3.decorate(this["~orpc"].contract).errors(errors)
|
207
|
+
});
|
208
|
+
}
|
209
|
+
route(route) {
|
210
|
+
return new _ProcedureBuilderWithOutput({
|
211
|
+
...this["~orpc"],
|
212
|
+
contract: DecoratedContractProcedure3.decorate(this["~orpc"].contract).route(route)
|
213
|
+
});
|
214
|
+
}
|
215
|
+
use(middleware) {
|
216
|
+
const builder = new _ProcedureBuilderWithOutput({
|
117
217
|
contract: this["~orpc"].contract,
|
218
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex,
|
219
|
+
inputValidationIndex: this["~orpc"].inputValidationIndex + 1,
|
220
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
221
|
+
});
|
222
|
+
return builder;
|
223
|
+
}
|
224
|
+
input(schema, example) {
|
225
|
+
return new ProcedureImplementer({
|
226
|
+
...this["~orpc"],
|
227
|
+
contract: new ContractProcedureBuilderWithOutput(this["~orpc"].contract["~orpc"]).input(schema, example)
|
228
|
+
});
|
229
|
+
}
|
230
|
+
handler(handler) {
|
231
|
+
return new DecoratedProcedure({
|
232
|
+
...this["~orpc"],
|
118
233
|
handler
|
119
|
-
})
|
234
|
+
});
|
235
|
+
}
|
236
|
+
};
|
237
|
+
|
238
|
+
// src/procedure-builder.ts
|
239
|
+
var ProcedureBuilder = class _ProcedureBuilder {
|
240
|
+
"~type" = "ProcedureBuilder";
|
241
|
+
"~orpc";
|
242
|
+
constructor(def) {
|
243
|
+
this["~orpc"] = def;
|
244
|
+
}
|
245
|
+
errors(errors) {
|
246
|
+
return new _ProcedureBuilder({
|
247
|
+
...this["~orpc"],
|
248
|
+
contract: DecoratedContractProcedure4.decorate(this["~orpc"].contract).errors(errors)
|
249
|
+
});
|
250
|
+
}
|
251
|
+
route(route) {
|
252
|
+
return new _ProcedureBuilder({
|
253
|
+
...this["~orpc"],
|
254
|
+
contract: DecoratedContractProcedure4.decorate(this["~orpc"].contract).route(route)
|
255
|
+
});
|
256
|
+
}
|
257
|
+
use(middleware) {
|
258
|
+
const builder = new _ProcedureBuilder({
|
259
|
+
contract: this["~orpc"].contract,
|
260
|
+
inputValidationIndex: this["~orpc"].inputValidationIndex + 1,
|
261
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex + 1,
|
262
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
263
|
+
});
|
264
|
+
return builder;
|
265
|
+
}
|
266
|
+
input(schema, example) {
|
267
|
+
return new ProcedureBuilderWithInput({
|
268
|
+
...this["~orpc"],
|
269
|
+
contract: new ContractProcedureBuilder(this["~orpc"].contract["~orpc"]).input(schema, example)
|
270
|
+
});
|
271
|
+
}
|
272
|
+
output(schema, example) {
|
273
|
+
return new ProcedureBuilderWithOutput({
|
274
|
+
...this["~orpc"],
|
275
|
+
contract: new ContractProcedureBuilder(this["~orpc"].contract["~orpc"]).output(schema, example)
|
276
|
+
});
|
277
|
+
}
|
278
|
+
handler(handler) {
|
279
|
+
return new DecoratedProcedure({
|
280
|
+
...this["~orpc"],
|
281
|
+
handler
|
282
|
+
});
|
120
283
|
}
|
121
284
|
};
|
122
285
|
|
@@ -154,31 +317,10 @@ function getLazyRouterPrefix(obj) {
|
|
154
317
|
return obj[LAZY_ROUTER_PREFIX_SYMBOL];
|
155
318
|
}
|
156
319
|
|
157
|
-
// src/lazy-utils.ts
|
158
|
-
function createLazyProcedureFormAnyLazy(lazied) {
|
159
|
-
const lazyProcedure = lazy(async () => {
|
160
|
-
const { default: maybeProcedure } = await unlazy(flatLazy(lazied));
|
161
|
-
if (!isProcedure(maybeProcedure)) {
|
162
|
-
throw new Error(`
|
163
|
-
Expected a lazy<procedure> but got lazy<unknown>.
|
164
|
-
This should be caught by TypeScript compilation.
|
165
|
-
Please report this issue if this makes you feel uncomfortable.
|
166
|
-
`);
|
167
|
-
}
|
168
|
-
return { default: maybeProcedure };
|
169
|
-
});
|
170
|
-
return lazyProcedure;
|
171
|
-
}
|
172
|
-
|
173
320
|
// src/lazy-decorated.ts
|
174
321
|
function decorateLazy(lazied) {
|
175
322
|
const flattenLazy = flatLazy(lazied);
|
176
|
-
const
|
177
|
-
procedure: createLazyProcedureFormAnyLazy(flattenLazy),
|
178
|
-
context: void 0
|
179
|
-
});
|
180
|
-
Object.assign(procedureProcedureClient, flattenLazy);
|
181
|
-
const recursive = new Proxy(procedureProcedureClient, {
|
323
|
+
const recursive = new Proxy(flattenLazy, {
|
182
324
|
get(target, key) {
|
183
325
|
if (typeof key !== "string") {
|
184
326
|
return Reflect.get(target, key);
|
@@ -215,12 +357,24 @@ var RouterBuilder = class _RouterBuilder {
|
|
215
357
|
tags: [...this["~orpc"].tags ?? [], ...tags]
|
216
358
|
});
|
217
359
|
}
|
218
|
-
|
360
|
+
errors(errors) {
|
219
361
|
return new _RouterBuilder({
|
220
362
|
...this["~orpc"],
|
221
|
-
|
363
|
+
errorMap: {
|
364
|
+
...this["~orpc"].errorMap,
|
365
|
+
...errors
|
366
|
+
}
|
222
367
|
});
|
223
368
|
}
|
369
|
+
use(middleware) {
|
370
|
+
const builder = new _RouterBuilder({
|
371
|
+
tags: this["~orpc"].tags,
|
372
|
+
prefix: this["~orpc"].prefix,
|
373
|
+
errorMap: this["~orpc"].errorMap,
|
374
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
375
|
+
});
|
376
|
+
return builder;
|
377
|
+
}
|
224
378
|
router(router) {
|
225
379
|
const adapted = adapt(router, this["~orpc"]);
|
226
380
|
return adapted;
|
@@ -245,7 +399,7 @@ function adapt(item, options) {
|
|
245
399
|
return adaptedLazy;
|
246
400
|
}
|
247
401
|
if (isProcedure(item)) {
|
248
|
-
let decorated =
|
402
|
+
let decorated = DecoratedProcedure.decorate(item);
|
249
403
|
if (options.tags?.length) {
|
250
404
|
decorated = decorated.unshiftTag(...options.tags);
|
251
405
|
}
|
@@ -255,6 +409,9 @@ function adapt(item, options) {
|
|
255
409
|
if (options.middlewares?.length) {
|
256
410
|
decorated = decorated.unshiftMiddleware(...options.middlewares);
|
257
411
|
}
|
412
|
+
if (Object.keys(options.errorMap).length) {
|
413
|
+
decorated = decorated.errors(options.errorMap);
|
414
|
+
}
|
258
415
|
return decorated;
|
259
416
|
}
|
260
417
|
const adapted = {};
|
@@ -264,6 +421,246 @@ function adapt(item, options) {
|
|
264
421
|
return adapted;
|
265
422
|
}
|
266
423
|
|
424
|
+
// src/builder-with-errors-middlewares.ts
|
425
|
+
var BuilderWithErrorsMiddlewares = class _BuilderWithErrorsMiddlewares {
|
426
|
+
"~type" = "BuilderWithErrorsMiddlewares";
|
427
|
+
"~orpc";
|
428
|
+
constructor(def) {
|
429
|
+
this["~orpc"] = def;
|
430
|
+
}
|
431
|
+
errors(errors) {
|
432
|
+
return new _BuilderWithErrorsMiddlewares({
|
433
|
+
...this["~orpc"],
|
434
|
+
errorMap: {
|
435
|
+
...this["~orpc"].errorMap,
|
436
|
+
...errors
|
437
|
+
}
|
438
|
+
});
|
439
|
+
}
|
440
|
+
use(middleware) {
|
441
|
+
const builder = new _BuilderWithErrorsMiddlewares({
|
442
|
+
config: this["~orpc"].config,
|
443
|
+
errorMap: this["~orpc"].errorMap,
|
444
|
+
inputValidationIndex: this["~orpc"].inputValidationIndex + 1,
|
445
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex + 1,
|
446
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
447
|
+
});
|
448
|
+
return builder;
|
449
|
+
}
|
450
|
+
route(route) {
|
451
|
+
return new ProcedureBuilder({
|
452
|
+
...this["~orpc"],
|
453
|
+
contract: new ContractProcedure({
|
454
|
+
route: {
|
455
|
+
...this["~orpc"].config.initialRoute,
|
456
|
+
...route
|
457
|
+
},
|
458
|
+
InputSchema: void 0,
|
459
|
+
OutputSchema: void 0,
|
460
|
+
errorMap: this["~orpc"].errorMap
|
461
|
+
})
|
462
|
+
});
|
463
|
+
}
|
464
|
+
input(schema, example) {
|
465
|
+
return new ProcedureBuilderWithInput({
|
466
|
+
...this["~orpc"],
|
467
|
+
contract: new ContractProcedure({
|
468
|
+
route: this["~orpc"].config.initialRoute,
|
469
|
+
OutputSchema: void 0,
|
470
|
+
InputSchema: schema,
|
471
|
+
inputExample: example,
|
472
|
+
errorMap: this["~orpc"].errorMap
|
473
|
+
})
|
474
|
+
});
|
475
|
+
}
|
476
|
+
output(schema, example) {
|
477
|
+
return new ProcedureBuilderWithOutput({
|
478
|
+
...this["~orpc"],
|
479
|
+
contract: new ContractProcedure({
|
480
|
+
route: this["~orpc"].config.initialRoute,
|
481
|
+
InputSchema: void 0,
|
482
|
+
OutputSchema: schema,
|
483
|
+
outputExample: example,
|
484
|
+
errorMap: this["~orpc"].errorMap
|
485
|
+
})
|
486
|
+
});
|
487
|
+
}
|
488
|
+
handler(handler) {
|
489
|
+
return new DecoratedProcedure({
|
490
|
+
...this["~orpc"],
|
491
|
+
contract: new ContractProcedure({
|
492
|
+
route: this["~orpc"].config.initialRoute,
|
493
|
+
InputSchema: void 0,
|
494
|
+
OutputSchema: void 0,
|
495
|
+
errorMap: this["~orpc"].errorMap
|
496
|
+
}),
|
497
|
+
handler
|
498
|
+
});
|
499
|
+
}
|
500
|
+
prefix(prefix) {
|
501
|
+
return new RouterBuilder({
|
502
|
+
...this["~orpc"],
|
503
|
+
prefix
|
504
|
+
});
|
505
|
+
}
|
506
|
+
tag(...tags) {
|
507
|
+
return new RouterBuilder({
|
508
|
+
...this["~orpc"],
|
509
|
+
tags
|
510
|
+
});
|
511
|
+
}
|
512
|
+
router(router) {
|
513
|
+
return new RouterBuilder(this["~orpc"]).router(router);
|
514
|
+
}
|
515
|
+
lazy(loader) {
|
516
|
+
return new RouterBuilder(this["~orpc"]).lazy(loader);
|
517
|
+
}
|
518
|
+
};
|
519
|
+
|
520
|
+
// src/config.ts
|
521
|
+
var DEFAULT_CONFIG = {
|
522
|
+
initialInputValidationIndex: 0,
|
523
|
+
initialOutputValidationIndex: 0
|
524
|
+
};
|
525
|
+
function fallbackConfig(key, value) {
|
526
|
+
if (value === void 0) {
|
527
|
+
return DEFAULT_CONFIG[key];
|
528
|
+
}
|
529
|
+
return value;
|
530
|
+
}
|
531
|
+
|
532
|
+
// src/builder-with-errors.ts
|
533
|
+
var BuilderWithErrors = class _BuilderWithErrors {
|
534
|
+
"~type" = "BuilderWithErrors";
|
535
|
+
"~orpc";
|
536
|
+
constructor(def) {
|
537
|
+
this["~orpc"] = def;
|
538
|
+
}
|
539
|
+
config(config) {
|
540
|
+
return new _BuilderWithErrors({
|
541
|
+
...this["~orpc"],
|
542
|
+
config: {
|
543
|
+
...this["~orpc"].config,
|
544
|
+
...config
|
545
|
+
}
|
546
|
+
});
|
547
|
+
}
|
548
|
+
context() {
|
549
|
+
return this;
|
550
|
+
}
|
551
|
+
errors(errors) {
|
552
|
+
return new _BuilderWithErrors({
|
553
|
+
...this["~orpc"],
|
554
|
+
errorMap: {
|
555
|
+
...this["~orpc"].errorMap,
|
556
|
+
...errors
|
557
|
+
}
|
558
|
+
});
|
559
|
+
}
|
560
|
+
middleware(middleware) {
|
561
|
+
return decorateMiddleware(middleware);
|
562
|
+
}
|
563
|
+
use(middleware) {
|
564
|
+
return new BuilderWithErrorsMiddlewares({
|
565
|
+
...this["~orpc"],
|
566
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + 1,
|
567
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + 1,
|
568
|
+
middlewares: [middleware]
|
569
|
+
});
|
570
|
+
}
|
571
|
+
route(route) {
|
572
|
+
return new ProcedureBuilder({
|
573
|
+
middlewares: [],
|
574
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
575
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
576
|
+
contract: new ContractProcedure2({
|
577
|
+
route: {
|
578
|
+
...this["~orpc"].config.initialRoute,
|
579
|
+
...route
|
580
|
+
},
|
581
|
+
InputSchema: void 0,
|
582
|
+
OutputSchema: void 0,
|
583
|
+
errorMap: this["~orpc"].errorMap
|
584
|
+
})
|
585
|
+
});
|
586
|
+
}
|
587
|
+
input(schema, example) {
|
588
|
+
return new ProcedureBuilderWithInput({
|
589
|
+
middlewares: [],
|
590
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
591
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
592
|
+
contract: new ContractProcedure2({
|
593
|
+
route: this["~orpc"].config.initialRoute,
|
594
|
+
OutputSchema: void 0,
|
595
|
+
InputSchema: schema,
|
596
|
+
inputExample: example,
|
597
|
+
errorMap: this["~orpc"].errorMap
|
598
|
+
})
|
599
|
+
});
|
600
|
+
}
|
601
|
+
output(schema, example) {
|
602
|
+
return new ProcedureBuilderWithOutput({
|
603
|
+
middlewares: [],
|
604
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
605
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
606
|
+
contract: new ContractProcedure2({
|
607
|
+
route: this["~orpc"].config.initialRoute,
|
608
|
+
InputSchema: void 0,
|
609
|
+
OutputSchema: schema,
|
610
|
+
outputExample: example,
|
611
|
+
errorMap: this["~orpc"].errorMap
|
612
|
+
})
|
613
|
+
});
|
614
|
+
}
|
615
|
+
handler(handler) {
|
616
|
+
return new DecoratedProcedure({
|
617
|
+
middlewares: [],
|
618
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
619
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
620
|
+
contract: new ContractProcedure2({
|
621
|
+
route: this["~orpc"].config.initialRoute,
|
622
|
+
InputSchema: void 0,
|
623
|
+
OutputSchema: void 0,
|
624
|
+
errorMap: this["~orpc"].errorMap
|
625
|
+
}),
|
626
|
+
handler
|
627
|
+
});
|
628
|
+
}
|
629
|
+
prefix(prefix) {
|
630
|
+
return new RouterBuilder({
|
631
|
+
middlewares: [],
|
632
|
+
errorMap: this["~orpc"].errorMap,
|
633
|
+
prefix
|
634
|
+
});
|
635
|
+
}
|
636
|
+
tag(...tags) {
|
637
|
+
return new RouterBuilder({
|
638
|
+
middlewares: [],
|
639
|
+
errorMap: this["~orpc"].errorMap,
|
640
|
+
tags
|
641
|
+
});
|
642
|
+
}
|
643
|
+
router(router) {
|
644
|
+
return new RouterBuilder({
|
645
|
+
middlewares: [],
|
646
|
+
...this["~orpc"]
|
647
|
+
}).router(router);
|
648
|
+
}
|
649
|
+
lazy(loader) {
|
650
|
+
return new RouterBuilder({
|
651
|
+
middlewares: [],
|
652
|
+
...this["~orpc"]
|
653
|
+
}).lazy(loader);
|
654
|
+
}
|
655
|
+
};
|
656
|
+
|
657
|
+
// src/builder-with-middlewares.ts
|
658
|
+
import { ContractProcedure as ContractProcedure3 } from "@orpc/contract";
|
659
|
+
|
660
|
+
// src/implementer-chainable.ts
|
661
|
+
import { isContractProcedure } from "@orpc/contract";
|
662
|
+
import { createCallableObject } from "@orpc/shared";
|
663
|
+
|
267
664
|
// src/router-implementer.ts
|
268
665
|
var RouterImplementer = class _RouterImplementer {
|
269
666
|
"~type" = "RouterImplementer";
|
@@ -272,37 +669,49 @@ var RouterImplementer = class _RouterImplementer {
|
|
272
669
|
this["~orpc"] = def;
|
273
670
|
}
|
274
671
|
use(middleware) {
|
275
|
-
|
276
|
-
|
277
|
-
middlewares: [...this["~orpc"].middlewares
|
672
|
+
const builder = new _RouterImplementer({
|
673
|
+
contract: this["~orpc"].contract,
|
674
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
278
675
|
});
|
676
|
+
return builder;
|
279
677
|
}
|
280
678
|
router(router) {
|
281
|
-
const adapted = new RouterBuilder(
|
679
|
+
const adapted = new RouterBuilder({
|
680
|
+
...this["~orpc"],
|
681
|
+
errorMap: {}
|
682
|
+
}).router(router);
|
282
683
|
const contracted = setRouterContract(adapted, this["~orpc"].contract);
|
283
684
|
return contracted;
|
284
685
|
}
|
285
686
|
lazy(loader) {
|
286
|
-
const adapted = new RouterBuilder(
|
687
|
+
const adapted = new RouterBuilder({
|
688
|
+
...this["~orpc"],
|
689
|
+
errorMap: {}
|
690
|
+
}).lazy(loader);
|
287
691
|
const contracted = setRouterContract(adapted, this["~orpc"].contract);
|
288
692
|
return contracted;
|
289
693
|
}
|
290
694
|
};
|
291
695
|
|
292
696
|
// src/implementer-chainable.ts
|
293
|
-
function createChainableImplementer(contract,
|
697
|
+
function createChainableImplementer(contract, options) {
|
294
698
|
if (isContractProcedure(contract)) {
|
295
699
|
const implementer = new ProcedureImplementer({
|
296
700
|
contract,
|
297
|
-
middlewares
|
701
|
+
middlewares: options.middlewares,
|
702
|
+
inputValidationIndex: options.inputValidationIndex,
|
703
|
+
outputValidationIndex: options.outputValidationIndex
|
298
704
|
});
|
299
705
|
return implementer;
|
300
706
|
}
|
301
707
|
const chainable = {};
|
302
708
|
for (const key in contract) {
|
303
|
-
chainable[key] = createChainableImplementer(contract[key],
|
709
|
+
chainable[key] = createChainableImplementer(contract[key], options);
|
304
710
|
}
|
305
|
-
const routerImplementer = new RouterImplementer({
|
711
|
+
const routerImplementer = new RouterImplementer({
|
712
|
+
contract,
|
713
|
+
middlewares: options.middlewares
|
714
|
+
});
|
306
715
|
const merged = new Proxy(chainable, {
|
307
716
|
get(target, key) {
|
308
717
|
const next = Reflect.get(target, key);
|
@@ -319,58 +728,106 @@ function createChainableImplementer(contract, middlewares) {
|
|
319
728
|
return merged;
|
320
729
|
}
|
321
730
|
|
322
|
-
// src/
|
323
|
-
|
324
|
-
|
325
|
-
} from "@orpc/contract";
|
326
|
-
var ProcedureBuilder = class _ProcedureBuilder {
|
327
|
-
"~type" = "ProcedureBuilder";
|
731
|
+
// src/builder-with-middlewares.ts
|
732
|
+
var BuilderWithMiddlewares = class _BuilderWithMiddlewares {
|
733
|
+
"~type" = "BuilderHasMiddlewares";
|
328
734
|
"~orpc";
|
329
735
|
constructor(def) {
|
330
736
|
this["~orpc"] = def;
|
331
737
|
}
|
738
|
+
use(middleware) {
|
739
|
+
const builder = new _BuilderWithMiddlewares({
|
740
|
+
config: this["~orpc"].config,
|
741
|
+
inputValidationIndex: this["~orpc"].inputValidationIndex + 1,
|
742
|
+
outputValidationIndex: this["~orpc"].outputValidationIndex + 1,
|
743
|
+
middlewares: [...this["~orpc"].middlewares, middleware]
|
744
|
+
});
|
745
|
+
return builder;
|
746
|
+
}
|
747
|
+
errors(errors) {
|
748
|
+
return new BuilderWithErrorsMiddlewares({
|
749
|
+
...this["~orpc"],
|
750
|
+
errorMap: errors
|
751
|
+
});
|
752
|
+
}
|
332
753
|
route(route) {
|
333
|
-
return new
|
754
|
+
return new ProcedureBuilder({
|
334
755
|
...this["~orpc"],
|
335
|
-
contract:
|
756
|
+
contract: new ContractProcedure3({
|
757
|
+
route: {
|
758
|
+
...this["~orpc"].config.initialRoute,
|
759
|
+
...route
|
760
|
+
},
|
761
|
+
InputSchema: void 0,
|
762
|
+
OutputSchema: void 0,
|
763
|
+
errorMap: {}
|
764
|
+
})
|
336
765
|
});
|
337
766
|
}
|
338
767
|
input(schema, example) {
|
339
|
-
return new
|
768
|
+
return new ProcedureBuilderWithInput({
|
340
769
|
...this["~orpc"],
|
341
|
-
contract:
|
770
|
+
contract: new ContractProcedure3({
|
771
|
+
route: this["~orpc"].config.initialRoute,
|
772
|
+
OutputSchema: void 0,
|
773
|
+
InputSchema: schema,
|
774
|
+
inputExample: example,
|
775
|
+
errorMap: {}
|
776
|
+
})
|
342
777
|
});
|
343
778
|
}
|
344
779
|
output(schema, example) {
|
345
|
-
return new
|
780
|
+
return new ProcedureBuilderWithOutput({
|
346
781
|
...this["~orpc"],
|
347
|
-
contract:
|
782
|
+
contract: new ContractProcedure3({
|
783
|
+
route: this["~orpc"].config.initialRoute,
|
784
|
+
InputSchema: void 0,
|
785
|
+
OutputSchema: schema,
|
786
|
+
outputExample: example,
|
787
|
+
errorMap: {}
|
788
|
+
})
|
348
789
|
});
|
349
790
|
}
|
350
|
-
|
351
|
-
return new
|
791
|
+
handler(handler) {
|
792
|
+
return new DecoratedProcedure({
|
352
793
|
...this["~orpc"],
|
353
|
-
contract:
|
794
|
+
contract: new ContractProcedure3({
|
795
|
+
route: this["~orpc"].config.initialRoute,
|
796
|
+
InputSchema: void 0,
|
797
|
+
OutputSchema: void 0,
|
798
|
+
errorMap: {}
|
799
|
+
}),
|
800
|
+
handler
|
354
801
|
});
|
355
802
|
}
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
}
|
363
|
-
return new ProcedureImplementer({
|
364
|
-
contract: this["~orpc"].contract,
|
365
|
-
middlewares: this["~orpc"].middlewares
|
366
|
-
}).use(middleware, mapInput);
|
803
|
+
prefix(prefix) {
|
804
|
+
return new RouterBuilder({
|
805
|
+
middlewares: this["~orpc"].middlewares,
|
806
|
+
errorMap: {},
|
807
|
+
prefix
|
808
|
+
});
|
367
809
|
}
|
368
|
-
|
369
|
-
return
|
810
|
+
tag(...tags) {
|
811
|
+
return new RouterBuilder({
|
370
812
|
middlewares: this["~orpc"].middlewares,
|
371
|
-
|
372
|
-
|
373
|
-
})
|
813
|
+
errorMap: {},
|
814
|
+
tags
|
815
|
+
});
|
816
|
+
}
|
817
|
+
router(router) {
|
818
|
+
return new RouterBuilder({
|
819
|
+
errorMap: {},
|
820
|
+
...this["~orpc"]
|
821
|
+
}).router(router);
|
822
|
+
}
|
823
|
+
lazy(loader) {
|
824
|
+
return new RouterBuilder({
|
825
|
+
errorMap: {},
|
826
|
+
...this["~orpc"]
|
827
|
+
}).lazy(loader);
|
828
|
+
}
|
829
|
+
contract(contract) {
|
830
|
+
return createChainableImplementer(contract, this["~orpc"]);
|
374
831
|
}
|
375
832
|
};
|
376
833
|
|
@@ -381,125 +838,171 @@ var Builder = class _Builder {
|
|
381
838
|
constructor(def) {
|
382
839
|
this["~orpc"] = def;
|
383
840
|
}
|
384
|
-
|
385
|
-
return new _Builder({});
|
386
|
-
}
|
387
|
-
use(middleware) {
|
841
|
+
config(config) {
|
388
842
|
return new _Builder({
|
389
843
|
...this["~orpc"],
|
390
|
-
|
844
|
+
config: {
|
845
|
+
...this["~orpc"].config,
|
846
|
+
...config
|
847
|
+
}
|
391
848
|
});
|
392
849
|
}
|
850
|
+
context() {
|
851
|
+
return this;
|
852
|
+
}
|
393
853
|
middleware(middleware) {
|
394
854
|
return decorateMiddleware(middleware);
|
395
855
|
}
|
856
|
+
errors(errors) {
|
857
|
+
return new BuilderWithErrors({
|
858
|
+
...this["~orpc"],
|
859
|
+
errorMap: errors
|
860
|
+
});
|
861
|
+
}
|
862
|
+
use(middleware) {
|
863
|
+
const builder = new BuilderWithMiddlewares({
|
864
|
+
...this["~orpc"],
|
865
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + 1,
|
866
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + 1,
|
867
|
+
middlewares: [middleware]
|
868
|
+
// FIXME: I believe we can remove `as any` here
|
869
|
+
});
|
870
|
+
return builder;
|
871
|
+
}
|
396
872
|
route(route) {
|
397
873
|
return new ProcedureBuilder({
|
398
|
-
middlewares:
|
399
|
-
|
400
|
-
|
874
|
+
middlewares: [],
|
875
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
876
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
877
|
+
contract: new ContractProcedure4({
|
878
|
+
route: {
|
879
|
+
...this["~orpc"].config.initialRoute,
|
880
|
+
...route
|
881
|
+
},
|
401
882
|
InputSchema: void 0,
|
402
883
|
OutputSchema: void 0,
|
403
|
-
errorMap:
|
884
|
+
errorMap: {}
|
404
885
|
})
|
405
886
|
});
|
406
887
|
}
|
407
888
|
input(schema, example) {
|
408
|
-
return new
|
409
|
-
middlewares:
|
410
|
-
|
889
|
+
return new ProcedureBuilderWithInput({
|
890
|
+
middlewares: [],
|
891
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
892
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
893
|
+
contract: new ContractProcedure4({
|
894
|
+
route: this["~orpc"].config.initialRoute,
|
411
895
|
OutputSchema: void 0,
|
412
896
|
InputSchema: schema,
|
413
897
|
inputExample: example,
|
414
|
-
errorMap:
|
898
|
+
errorMap: {}
|
415
899
|
})
|
416
900
|
});
|
417
901
|
}
|
418
902
|
output(schema, example) {
|
419
|
-
return new
|
420
|
-
middlewares:
|
421
|
-
|
903
|
+
return new ProcedureBuilderWithOutput({
|
904
|
+
middlewares: [],
|
905
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
906
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
907
|
+
contract: new ContractProcedure4({
|
908
|
+
route: this["~orpc"].config.initialRoute,
|
422
909
|
InputSchema: void 0,
|
423
910
|
OutputSchema: schema,
|
424
911
|
outputExample: example,
|
425
|
-
errorMap:
|
426
|
-
})
|
427
|
-
});
|
428
|
-
}
|
429
|
-
errors(errors) {
|
430
|
-
return new ProcedureBuilder({
|
431
|
-
middlewares: this["~orpc"].middlewares,
|
432
|
-
contract: new ContractProcedure({
|
433
|
-
InputSchema: void 0,
|
434
|
-
OutputSchema: void 0,
|
435
|
-
errorMap: errors
|
912
|
+
errorMap: {}
|
436
913
|
})
|
437
914
|
});
|
438
915
|
}
|
439
916
|
handler(handler) {
|
440
|
-
return
|
441
|
-
middlewares:
|
442
|
-
|
917
|
+
return new DecoratedProcedure({
|
918
|
+
middlewares: [],
|
919
|
+
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
920
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex),
|
921
|
+
contract: new ContractProcedure4({
|
922
|
+
route: this["~orpc"].config.initialRoute,
|
443
923
|
InputSchema: void 0,
|
444
924
|
OutputSchema: void 0,
|
445
|
-
errorMap:
|
925
|
+
errorMap: {}
|
446
926
|
}),
|
447
927
|
handler
|
448
|
-
})
|
928
|
+
});
|
449
929
|
}
|
450
930
|
prefix(prefix) {
|
451
931
|
return new RouterBuilder({
|
452
|
-
middlewares:
|
932
|
+
middlewares: [],
|
933
|
+
errorMap: {},
|
453
934
|
prefix
|
454
935
|
});
|
455
936
|
}
|
456
937
|
tag(...tags) {
|
457
938
|
return new RouterBuilder({
|
458
|
-
middlewares:
|
939
|
+
middlewares: [],
|
940
|
+
errorMap: {},
|
459
941
|
tags
|
460
942
|
});
|
461
943
|
}
|
462
944
|
router(router) {
|
463
|
-
return new RouterBuilder(
|
945
|
+
return new RouterBuilder({
|
946
|
+
middlewares: [],
|
947
|
+
errorMap: []
|
948
|
+
}).router(router);
|
464
949
|
}
|
465
950
|
lazy(loader) {
|
466
|
-
return new RouterBuilder(
|
951
|
+
return new RouterBuilder({
|
952
|
+
middlewares: [],
|
953
|
+
errorMap: {}
|
954
|
+
}).lazy(loader);
|
467
955
|
}
|
468
956
|
contract(contract) {
|
469
|
-
return createChainableImplementer(contract,
|
957
|
+
return createChainableImplementer(contract, {
|
958
|
+
middlewares: [],
|
959
|
+
inputValidationIndex: 0,
|
960
|
+
outputValidationIndex: 0
|
961
|
+
});
|
470
962
|
}
|
471
963
|
};
|
472
964
|
|
965
|
+
// src/procedure-utils.ts
|
966
|
+
function call(procedure, input, ...rest) {
|
967
|
+
return createProcedureClient(procedure, ...rest)(input);
|
968
|
+
}
|
969
|
+
|
970
|
+
// src/lazy-utils.ts
|
971
|
+
function createLazyProcedureFormAnyLazy(lazied) {
|
972
|
+
const lazyProcedure = lazy(async () => {
|
973
|
+
const { default: maybeProcedure } = await unlazy(flatLazy(lazied));
|
974
|
+
if (!isProcedure(maybeProcedure)) {
|
975
|
+
throw new Error(`
|
976
|
+
Expected a lazy<procedure> but got lazy<unknown>.
|
977
|
+
This should be caught by TypeScript compilation.
|
978
|
+
Please report this issue if this makes you feel uncomfortable.
|
979
|
+
`);
|
980
|
+
}
|
981
|
+
return { default: maybeProcedure };
|
982
|
+
});
|
983
|
+
return lazyProcedure;
|
984
|
+
}
|
985
|
+
|
473
986
|
// src/router-client.ts
|
474
|
-
function createRouterClient(
|
475
|
-
if (isProcedure(
|
476
|
-
const caller = createProcedureClient(
|
477
|
-
...options,
|
478
|
-
procedure: options.router,
|
479
|
-
context: options.context,
|
480
|
-
path: options.path
|
481
|
-
});
|
987
|
+
function createRouterClient(router, ...rest) {
|
988
|
+
if (isProcedure(router)) {
|
989
|
+
const caller = createProcedureClient(router, ...rest);
|
482
990
|
return caller;
|
483
991
|
}
|
484
|
-
const procedureCaller = isLazy(
|
485
|
-
...options,
|
486
|
-
procedure: createLazyProcedureFormAnyLazy(options.router),
|
487
|
-
context: options.context,
|
488
|
-
path: options.path
|
489
|
-
}) : {};
|
992
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createLazyProcedureFormAnyLazy(router), ...rest) : {};
|
490
993
|
const recursive = new Proxy(procedureCaller, {
|
491
994
|
get(target, key) {
|
492
995
|
if (typeof key !== "string") {
|
493
996
|
return Reflect.get(target, key);
|
494
997
|
}
|
495
|
-
const next = getRouterChild(
|
998
|
+
const next = getRouterChild(router, key);
|
496
999
|
if (!next) {
|
497
1000
|
return Reflect.get(target, key);
|
498
1001
|
}
|
499
|
-
|
1002
|
+
const [options] = rest;
|
1003
|
+
return createRouterClient(next, {
|
500
1004
|
...options,
|
501
|
-
|
502
|
-
path: [...options.path ?? [], key]
|
1005
|
+
path: [...options?.path ?? [], key]
|
503
1006
|
});
|
504
1007
|
}
|
505
1008
|
});
|
@@ -507,10 +1010,13 @@ function createRouterClient(options) {
|
|
507
1010
|
}
|
508
1011
|
|
509
1012
|
// src/index.ts
|
510
|
-
import {
|
511
|
-
var os = new Builder({
|
1013
|
+
import { isDefinedError, ORPCError, safe, type } from "@orpc/contract";
|
1014
|
+
var os = new Builder({
|
1015
|
+
config: {}
|
1016
|
+
});
|
512
1017
|
export {
|
513
1018
|
Builder,
|
1019
|
+
DecoratedProcedure,
|
514
1020
|
LAZY_LOADER_SYMBOL,
|
515
1021
|
ORPCError,
|
516
1022
|
Procedure,
|
@@ -518,16 +1024,15 @@ export {
|
|
518
1024
|
ProcedureImplementer,
|
519
1025
|
RouterBuilder,
|
520
1026
|
RouterImplementer,
|
521
|
-
|
1027
|
+
call,
|
522
1028
|
createChainableImplementer,
|
523
1029
|
createORPCErrorConstructorMap,
|
524
1030
|
createProcedureClient,
|
525
1031
|
createRouterClient,
|
526
1032
|
decorateLazy,
|
527
1033
|
decorateMiddleware,
|
528
|
-
decorateProcedure,
|
529
1034
|
deepSetLazyRouterPrefix,
|
530
|
-
|
1035
|
+
fallbackConfig,
|
531
1036
|
flatLazy,
|
532
1037
|
getLazyRouterPrefix,
|
533
1038
|
getRouterChild,
|
@@ -536,10 +1041,11 @@ export {
|
|
536
1041
|
isLazy,
|
537
1042
|
isProcedure,
|
538
1043
|
lazy,
|
539
|
-
|
1044
|
+
middlewareOutputFn,
|
540
1045
|
os,
|
541
1046
|
safe,
|
542
1047
|
setRouterContract,
|
1048
|
+
type,
|
543
1049
|
unlazy
|
544
1050
|
};
|
545
1051
|
//# sourceMappingURL=index.js.map
|