@orpc/server 0.0.0-next.d74cac4 → 0.0.0-next.d760838
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -0
- package/dist/adapters/fetch/index.d.mts +54 -0
- package/dist/adapters/fetch/index.d.ts +54 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +22 -0
- package/dist/adapters/hono/index.d.ts +22 -0
- package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
- package/dist/adapters/next/index.d.mts +29 -0
- package/dist/adapters/next/index.d.ts +29 -0
- package/dist/{next.js → adapters/next/index.mjs} +11 -13
- package/dist/adapters/node/index.d.mts +53 -0
- package/dist/adapters/node/index.d.ts +53 -0
- package/dist/adapters/node/index.mjs +85 -0
- package/dist/adapters/standard/index.d.mts +26 -0
- package/dist/adapters/standard/index.d.ts +26 -0
- package/dist/adapters/standard/index.mjs +6 -0
- package/dist/index.d.mts +291 -0
- package/dist/index.d.ts +291 -0
- package/dist/{index.js → index.mjs} +107 -156
- package/dist/plugins/index.d.mts +66 -0
- package/dist/plugins/index.d.ts +66 -0
- package/dist/plugins/index.mjs +196 -0
- package/dist/shared/server.BFt8M4Cr.d.ts +8 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.Bc6jnvPE.d.ts +10 -0
- package/dist/shared/server.BlxK0o8R.d.mts +66 -0
- package/dist/shared/server.C37gDhSZ.mjs +364 -0
- package/dist/shared/server.CCPFkKqC.mjs +98 -0
- package/dist/shared/server.CCgy73tk.d.mts +10 -0
- package/dist/shared/server.DJrRF9vD.mjs +162 -0
- package/dist/shared/server.DLt5njUb.d.mts +143 -0
- package/dist/shared/server.DLt5njUb.d.ts +143 -0
- package/dist/shared/server.DuTpqr2w.d.ts +66 -0
- package/dist/shared/server.JgWzFqlo.d.mts +8 -0
- package/package.json +30 -34
- package/dist/chunk-L4ESXQX7.js +0 -32
- package/dist/chunk-NXEANHUK.js +0 -351
- package/dist/chunk-XI6WGCB3.js +0 -125
- package/dist/chunk-XXBE6CYD.js +0 -379
- package/dist/fetch.js +0 -10
- package/dist/node.js +0 -31
- package/dist/plugins.js +0 -11
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/fetch/types.d.ts +0 -14
- package/dist/src/adapters/hono/index.d.ts +0 -3
- package/dist/src/adapters/hono/middleware.d.ts +0 -12
- package/dist/src/adapters/next/index.d.ts +0 -3
- package/dist/src/adapters/next/serve.d.ts +0 -19
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
- package/dist/src/adapters/node/types.d.ts +0 -22
- package/dist/src/adapters/standard/handler.d.ts +0 -51
- package/dist/src/adapters/standard/index.d.ts +0 -7
- package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
- package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
- package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
- package/dist/src/adapters/standard/rpc-serializer.d.ts +0 -22
- package/dist/src/adapters/standard/types.d.ts +0 -20
- package/dist/src/builder-variants.d.ts +0 -74
- package/dist/src/builder.d.ts +0 -57
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -8
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -31
- package/dist/src/implementer-variants.d.ts +0 -17
- package/dist/src/implementer.d.ts +0 -28
- package/dist/src/index.d.ts +0 -24
- package/dist/src/lazy-utils.d.ts +0 -6
- package/dist/src/lazy.d.ts +0 -22
- package/dist/src/middleware-decorated.d.ts +0 -10
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -37
- package/dist/src/plugins/base.d.ts +0 -13
- package/dist/src/plugins/cors.d.ts +0 -19
- package/dist/src/plugins/index.d.ts +0 -4
- package/dist/src/plugins/response-headers.d.ts +0 -10
- package/dist/src/procedure-client.d.ts +0 -31
- package/dist/src/procedure-decorated.d.ts +0 -22
- package/dist/src/procedure-utils.d.ts +0 -18
- package/dist/src/procedure.d.ts +0 -30
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -11
- package/dist/src/router.d.ts +0 -30
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -17
@@ -1,35 +1,16 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
createLazyProcedureFormAnyLazy,
|
10
|
-
createProcedureClient,
|
11
|
-
deepSetLazyRouterPrefix,
|
12
|
-
eachAllContractProcedure,
|
13
|
-
eachContractProcedure,
|
14
|
-
flatLazy,
|
15
|
-
getLazyRouterPrefix,
|
16
|
-
getRouterChild,
|
17
|
-
getRouterContract,
|
18
|
-
isLazy,
|
19
|
-
isProcedure,
|
20
|
-
lazy,
|
21
|
-
middlewareOutputFn,
|
22
|
-
setRouterContract,
|
23
|
-
unlazy
|
24
|
-
} from "./chunk-XXBE6CYD.js";
|
1
|
+
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
|
2
|
+
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.C37gDhSZ.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, w as resolveContractProcedures, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.C37gDhSZ.mjs';
|
5
|
+
import { toORPCError } from '@orpc/client';
|
6
|
+
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
|
+
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
8
|
+
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
25
9
|
|
26
|
-
|
27
|
-
import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
|
28
|
-
|
29
|
-
// src/config.ts
|
30
|
-
var DEFAULT_CONFIG = {
|
10
|
+
const DEFAULT_CONFIG = {
|
31
11
|
initialInputValidationIndex: 0,
|
32
|
-
initialOutputValidationIndex: 0
|
12
|
+
initialOutputValidationIndex: 0,
|
13
|
+
dedupeLeadingMiddlewares: true
|
33
14
|
};
|
34
15
|
function fallbackConfig(key, value) {
|
35
16
|
if (value === void 0) {
|
@@ -38,9 +19,8 @@ function fallbackConfig(key, value) {
|
|
38
19
|
return value;
|
39
20
|
}
|
40
21
|
|
41
|
-
// src/middleware-decorated.ts
|
42
22
|
function decorateMiddleware(middleware) {
|
43
|
-
const decorated = middleware;
|
23
|
+
const decorated = (...args) => middleware(...args);
|
44
24
|
decorated.mapInput = (mapInput) => {
|
45
25
|
const mapped = decorateMiddleware(
|
46
26
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
@@ -65,30 +45,39 @@ function decorateMiddleware(middleware) {
|
|
65
45
|
return decorated;
|
66
46
|
}
|
67
47
|
|
68
|
-
|
69
|
-
|
70
|
-
|
48
|
+
function createActionableClient(client) {
|
49
|
+
const action = async (input) => {
|
50
|
+
try {
|
51
|
+
return [null, await client(input)];
|
52
|
+
} catch (error) {
|
53
|
+
return [toORPCError(error).toJSON(), void 0];
|
54
|
+
}
|
55
|
+
};
|
56
|
+
return action;
|
57
|
+
}
|
58
|
+
|
59
|
+
class DecoratedProcedure extends Procedure {
|
71
60
|
errors(errors) {
|
72
|
-
return new
|
61
|
+
return new DecoratedProcedure({
|
73
62
|
...this["~orpc"],
|
74
63
|
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
75
64
|
});
|
76
65
|
}
|
77
66
|
meta(meta) {
|
78
|
-
return new
|
67
|
+
return new DecoratedProcedure({
|
79
68
|
...this["~orpc"],
|
80
69
|
meta: mergeMeta(this["~orpc"].meta, meta)
|
81
70
|
});
|
82
71
|
}
|
83
72
|
route(route) {
|
84
|
-
return new
|
73
|
+
return new DecoratedProcedure({
|
85
74
|
...this["~orpc"],
|
86
75
|
route: mergeRoute(this["~orpc"].route, route)
|
87
76
|
});
|
88
77
|
}
|
89
78
|
use(middleware, mapInput) {
|
90
79
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
91
|
-
return new
|
80
|
+
return new DecoratedProcedure({
|
92
81
|
...this["~orpc"],
|
93
82
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
94
83
|
});
|
@@ -97,21 +86,33 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
|
97
86
|
* Make this procedure callable (works like a function while still being a procedure).
|
98
87
|
*/
|
99
88
|
callable(...rest) {
|
100
|
-
|
101
|
-
|
102
|
-
|
89
|
+
const client = createProcedureClient(this, ...rest);
|
90
|
+
return new Proxy(client, {
|
91
|
+
get: (target, key) => {
|
92
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
93
|
+
},
|
94
|
+
has: (target, key) => {
|
95
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
96
|
+
}
|
103
97
|
});
|
104
98
|
}
|
105
99
|
/**
|
106
|
-
* Make this procedure compatible with server action
|
100
|
+
* Make this procedure compatible with server action.
|
107
101
|
*/
|
108
102
|
actionable(...rest) {
|
109
|
-
|
103
|
+
const action = createActionableClient(createProcedureClient(this, ...rest));
|
104
|
+
return new Proxy(action, {
|
105
|
+
get: (target, key) => {
|
106
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
107
|
+
},
|
108
|
+
has: (target, key) => {
|
109
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
110
|
+
}
|
111
|
+
});
|
110
112
|
}
|
111
|
-
}
|
113
|
+
}
|
112
114
|
|
113
|
-
|
114
|
-
var Builder = class _Builder {
|
115
|
+
class Builder {
|
115
116
|
"~orpc";
|
116
117
|
constructor(def) {
|
117
118
|
this["~orpc"] = def;
|
@@ -122,9 +123,10 @@ var Builder = class _Builder {
|
|
122
123
|
$config(config) {
|
123
124
|
const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
|
124
125
|
const outputValidationCount = this["~orpc"].outputValidationIndex - fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex);
|
125
|
-
return new
|
126
|
+
return new Builder({
|
126
127
|
...this["~orpc"],
|
127
128
|
config,
|
129
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares),
|
128
130
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
|
129
131
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config.initialOutputValidationIndex) + outputValidationCount
|
130
132
|
});
|
@@ -133,7 +135,7 @@ var Builder = class _Builder {
|
|
133
135
|
* Reset initial context
|
134
136
|
*/
|
135
137
|
$context() {
|
136
|
-
return new
|
138
|
+
return new Builder({
|
137
139
|
...this["~orpc"],
|
138
140
|
middlewares: [],
|
139
141
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
@@ -144,7 +146,7 @@ var Builder = class _Builder {
|
|
144
146
|
* Reset initial meta
|
145
147
|
*/
|
146
148
|
$meta(initialMeta) {
|
147
|
-
return new
|
149
|
+
return new Builder({
|
148
150
|
...this["~orpc"],
|
149
151
|
meta: initialMeta
|
150
152
|
});
|
@@ -153,48 +155,54 @@ var Builder = class _Builder {
|
|
153
155
|
* Reset initial route
|
154
156
|
*/
|
155
157
|
$route(initialRoute) {
|
156
|
-
return new
|
158
|
+
return new Builder({
|
157
159
|
...this["~orpc"],
|
158
160
|
route: initialRoute
|
159
161
|
});
|
160
162
|
}
|
163
|
+
$input(initialInputSchema) {
|
164
|
+
return new Builder({
|
165
|
+
...this["~orpc"],
|
166
|
+
inputSchema: initialInputSchema
|
167
|
+
});
|
168
|
+
}
|
161
169
|
middleware(middleware) {
|
162
170
|
return decorateMiddleware(middleware);
|
163
171
|
}
|
164
172
|
errors(errors) {
|
165
|
-
return new
|
173
|
+
return new Builder({
|
166
174
|
...this["~orpc"],
|
167
|
-
errorMap:
|
175
|
+
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
168
176
|
});
|
169
177
|
}
|
170
178
|
use(middleware, mapInput) {
|
171
179
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
172
|
-
return new
|
180
|
+
return new Builder({
|
173
181
|
...this["~orpc"],
|
174
182
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
175
183
|
});
|
176
184
|
}
|
177
185
|
meta(meta) {
|
178
|
-
return new
|
186
|
+
return new Builder({
|
179
187
|
...this["~orpc"],
|
180
|
-
meta:
|
188
|
+
meta: mergeMeta(this["~orpc"].meta, meta)
|
181
189
|
});
|
182
190
|
}
|
183
191
|
route(route) {
|
184
|
-
return new
|
192
|
+
return new Builder({
|
185
193
|
...this["~orpc"],
|
186
|
-
route:
|
194
|
+
route: mergeRoute(this["~orpc"].route, route)
|
187
195
|
});
|
188
196
|
}
|
189
197
|
input(schema) {
|
190
|
-
return new
|
198
|
+
return new Builder({
|
191
199
|
...this["~orpc"],
|
192
200
|
inputSchema: schema,
|
193
201
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + this["~orpc"].middlewares.length
|
194
202
|
});
|
195
203
|
}
|
196
204
|
output(schema) {
|
197
|
-
return new
|
205
|
+
return new Builder({
|
198
206
|
...this["~orpc"],
|
199
207
|
outputSchema: schema,
|
200
208
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + this["~orpc"].middlewares.length
|
@@ -207,43 +215,35 @@ var Builder = class _Builder {
|
|
207
215
|
});
|
208
216
|
}
|
209
217
|
prefix(prefix) {
|
210
|
-
return new
|
218
|
+
return new Builder({
|
211
219
|
...this["~orpc"],
|
212
220
|
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
213
221
|
});
|
214
222
|
}
|
215
223
|
tag(...tags) {
|
216
|
-
return new
|
224
|
+
return new Builder({
|
217
225
|
...this["~orpc"],
|
218
226
|
tags: mergeTags(this["~orpc"].tags, tags)
|
219
227
|
});
|
220
228
|
}
|
221
229
|
router(router) {
|
222
|
-
return
|
230
|
+
return enhanceRouter(router, this["~orpc"]);
|
223
231
|
}
|
224
232
|
lazy(loader) {
|
225
|
-
return
|
233
|
+
return enhanceRouter(lazy(loader), this["~orpc"]);
|
226
234
|
}
|
227
|
-
}
|
228
|
-
|
235
|
+
}
|
236
|
+
const os = new Builder({
|
229
237
|
config: {},
|
230
238
|
route: {},
|
231
239
|
meta: {},
|
232
240
|
errorMap: {},
|
233
|
-
inputSchema: void 0,
|
234
|
-
outputSchema: void 0,
|
235
241
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
|
236
242
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
|
237
|
-
middlewares: []
|
243
|
+
middlewares: [],
|
244
|
+
dedupeLeadingMiddlewares: true
|
238
245
|
});
|
239
246
|
|
240
|
-
// src/context.ts
|
241
|
-
function mergeContext(context, other) {
|
242
|
-
return { ...context, ...other };
|
243
|
-
}
|
244
|
-
|
245
|
-
// src/implementer.ts
|
246
|
-
import { isContractProcedure } from "@orpc/contract";
|
247
247
|
function implementerInternal(contract, config, middlewares) {
|
248
248
|
if (isContractProcedure(contract)) {
|
249
249
|
const impl2 = new Builder({
|
@@ -251,12 +251,16 @@ function implementerInternal(contract, config, middlewares) {
|
|
251
251
|
config,
|
252
252
|
middlewares,
|
253
253
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config?.initialInputValidationIndex) + middlewares.length,
|
254
|
-
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length
|
254
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length,
|
255
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
255
256
|
});
|
256
257
|
return impl2;
|
257
258
|
}
|
258
259
|
const impl = new Proxy(contract, {
|
259
260
|
get: (target, key) => {
|
261
|
+
if (typeof key !== "string") {
|
262
|
+
return Reflect.get(target, key);
|
263
|
+
}
|
260
264
|
let method;
|
261
265
|
if (key === "middleware") {
|
262
266
|
method = (mid) => decorateMiddleware(mid);
|
@@ -270,23 +274,29 @@ function implementerInternal(contract, config, middlewares) {
|
|
270
274
|
};
|
271
275
|
} else if (key === "router") {
|
272
276
|
method = (router) => {
|
273
|
-
const adapted =
|
277
|
+
const adapted = enhanceRouter(router, {
|
274
278
|
middlewares,
|
275
|
-
errorMap: {}
|
279
|
+
errorMap: {},
|
280
|
+
prefix: void 0,
|
281
|
+
tags: void 0,
|
282
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
276
283
|
});
|
277
|
-
return
|
284
|
+
return setHiddenRouterContract(adapted, contract);
|
278
285
|
};
|
279
286
|
} else if (key === "lazy") {
|
280
287
|
method = (loader) => {
|
281
|
-
const adapted =
|
288
|
+
const adapted = enhanceRouter(lazy(loader), {
|
282
289
|
middlewares,
|
283
|
-
errorMap: {}
|
290
|
+
errorMap: {},
|
291
|
+
prefix: void 0,
|
292
|
+
tags: void 0,
|
293
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
284
294
|
});
|
285
|
-
return
|
295
|
+
return setHiddenRouterContract(adapted, contract);
|
286
296
|
};
|
287
297
|
}
|
288
|
-
const next =
|
289
|
-
if (!next
|
298
|
+
const next = getContractRouter(target, [key]);
|
299
|
+
if (!next) {
|
290
300
|
return method ?? next;
|
291
301
|
}
|
292
302
|
const nextImpl = implementerInternal(next, config, middlewares);
|
@@ -313,44 +323,34 @@ function implement(contract, config = {}) {
|
|
313
323
|
method = (config2) => implement(contract, config2);
|
314
324
|
}
|
315
325
|
const next = Reflect.get(target, key);
|
316
|
-
if (!next || typeof next !== "function" && typeof next !== "object") {
|
317
|
-
return method
|
326
|
+
if (!method || !next || typeof next !== "function" && typeof next !== "object") {
|
327
|
+
return method || next;
|
318
328
|
}
|
319
|
-
|
320
|
-
|
321
|
-
get(
|
322
|
-
|
323
|
-
|
324
|
-
});
|
325
|
-
}
|
326
|
-
return next;
|
329
|
+
return new Proxy(method, {
|
330
|
+
get(_, key2) {
|
331
|
+
return Reflect.get(next, key2);
|
332
|
+
}
|
333
|
+
});
|
327
334
|
}
|
328
335
|
});
|
329
336
|
return impl;
|
330
337
|
}
|
331
338
|
|
332
|
-
|
333
|
-
function call(procedure, input, ...rest) {
|
334
|
-
return createProcedureClient(procedure, ...rest)(input);
|
335
|
-
}
|
336
|
-
|
337
|
-
// src/router-client.ts
|
338
|
-
function createRouterClient(router, ...rest) {
|
339
|
+
function createRouterClient(router, ...[options]) {
|
339
340
|
if (isProcedure(router)) {
|
340
|
-
const caller = createProcedureClient(router,
|
341
|
+
const caller = createProcedureClient(router, options);
|
341
342
|
return caller;
|
342
343
|
}
|
343
|
-
const procedureCaller = isLazy(router) ? createProcedureClient(
|
344
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
|
344
345
|
const recursive = new Proxy(procedureCaller, {
|
345
346
|
get(target, key) {
|
346
347
|
if (typeof key !== "string") {
|
347
348
|
return Reflect.get(target, key);
|
348
349
|
}
|
349
|
-
const next =
|
350
|
+
const next = getRouter(router, [key]);
|
350
351
|
if (!next) {
|
351
352
|
return Reflect.get(target, key);
|
352
353
|
}
|
353
|
-
const [options] = rest;
|
354
354
|
return createRouterClient(next, {
|
355
355
|
...options,
|
356
356
|
path: [...options?.path ?? [], key]
|
@@ -360,53 +360,4 @@ function createRouterClient(router, ...rest) {
|
|
360
360
|
return recursive;
|
361
361
|
}
|
362
362
|
|
363
|
-
|
364
|
-
import { eventIterator, isDefinedError, ORPCError, safe, type, ValidationError } from "@orpc/contract";
|
365
|
-
import { getEventMeta, withEventMeta } from "@orpc/server-standard";
|
366
|
-
import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
|
367
|
-
export {
|
368
|
-
Builder,
|
369
|
-
DecoratedProcedure,
|
370
|
-
LAZY_LOADER_SYMBOL,
|
371
|
-
ORPCError,
|
372
|
-
Procedure,
|
373
|
-
ValidationError,
|
374
|
-
adaptRouter,
|
375
|
-
call,
|
376
|
-
convertPathToHttpPath,
|
377
|
-
createAccessibleLazyRouter,
|
378
|
-
createContractedProcedure,
|
379
|
-
createLazyProcedureFormAnyLazy,
|
380
|
-
createProcedureClient,
|
381
|
-
createRouterClient,
|
382
|
-
decorateMiddleware,
|
383
|
-
deepSetLazyRouterPrefix,
|
384
|
-
eachAllContractProcedure,
|
385
|
-
eachContractProcedure,
|
386
|
-
eventIterator,
|
387
|
-
fallbackConfig,
|
388
|
-
flatLazy,
|
389
|
-
getEventMeta,
|
390
|
-
getLazyRouterPrefix,
|
391
|
-
getRouterChild,
|
392
|
-
getRouterContract,
|
393
|
-
implement,
|
394
|
-
implementerInternal,
|
395
|
-
isDefinedError,
|
396
|
-
isLazy,
|
397
|
-
isProcedure,
|
398
|
-
lazy,
|
399
|
-
mergeContext,
|
400
|
-
middlewareOutputFn,
|
401
|
-
onError,
|
402
|
-
onFinish,
|
403
|
-
onStart,
|
404
|
-
onSuccess,
|
405
|
-
os,
|
406
|
-
safe,
|
407
|
-
setRouterContract,
|
408
|
-
type,
|
409
|
-
unlazy,
|
410
|
-
withEventMeta
|
411
|
-
};
|
412
|
-
//# sourceMappingURL=index.js.map
|
363
|
+
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { Value } from '@orpc/shared';
|
2
|
+
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
|
+
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
+
import { h as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.BlxK0o8R.mjs';
|
5
|
+
import { C as Context } from '../shared/server.DLt5njUb.mjs';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/contract';
|
8
|
+
|
9
|
+
interface BatchHandlerOptions<T extends Context> {
|
10
|
+
/**
|
11
|
+
* The max size of the batch allowed.
|
12
|
+
*
|
13
|
+
* @default 10
|
14
|
+
*/
|
15
|
+
maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
|
16
|
+
/**
|
17
|
+
* Map the request before processing it.
|
18
|
+
*
|
19
|
+
* @default merged back batch request headers into the request
|
20
|
+
*/
|
21
|
+
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
22
|
+
/**
|
23
|
+
* Success batch response status code.
|
24
|
+
*
|
25
|
+
* @default 207
|
26
|
+
*/
|
27
|
+
successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
28
|
+
/**
|
29
|
+
* success batch response headers.
|
30
|
+
*
|
31
|
+
* @default {}
|
32
|
+
*/
|
33
|
+
headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
34
|
+
}
|
35
|
+
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
36
|
+
private readonly maxSize;
|
37
|
+
private readonly mapRequestItem;
|
38
|
+
private readonly successStatus;
|
39
|
+
private readonly headers;
|
40
|
+
constructor(options?: BatchHandlerOptions<T>);
|
41
|
+
init(options: StandardHandlerOptions<T>): void;
|
42
|
+
}
|
43
|
+
|
44
|
+
interface CORSOptions<T extends Context> {
|
45
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
46
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
47
|
+
allowMethods?: readonly string[];
|
48
|
+
allowHeaders?: readonly string[];
|
49
|
+
maxAge?: number;
|
50
|
+
credentials?: boolean;
|
51
|
+
exposeHeaders?: readonly string[];
|
52
|
+
}
|
53
|
+
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
54
|
+
private readonly options;
|
55
|
+
constructor(options?: CORSOptions<T>);
|
56
|
+
init(options: StandardHandlerOptions<T>): void;
|
57
|
+
}
|
58
|
+
|
59
|
+
interface ResponseHeadersPluginContext {
|
60
|
+
resHeaders?: Headers;
|
61
|
+
}
|
62
|
+
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
63
|
+
init(options: StandardHandlerOptions<T>): void;
|
64
|
+
}
|
65
|
+
|
66
|
+
export { type BatchHandlerOptions, BatchHandlerPlugin, type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { Value } from '@orpc/shared';
|
2
|
+
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
|
+
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
+
import { h as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.DuTpqr2w.js';
|
5
|
+
import { C as Context } from '../shared/server.DLt5njUb.js';
|
6
|
+
import '@orpc/client';
|
7
|
+
import '@orpc/contract';
|
8
|
+
|
9
|
+
interface BatchHandlerOptions<T extends Context> {
|
10
|
+
/**
|
11
|
+
* The max size of the batch allowed.
|
12
|
+
*
|
13
|
+
* @default 10
|
14
|
+
*/
|
15
|
+
maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
|
16
|
+
/**
|
17
|
+
* Map the request before processing it.
|
18
|
+
*
|
19
|
+
* @default merged back batch request headers into the request
|
20
|
+
*/
|
21
|
+
mapRequestItem?(request: StandardRequest, batchOptions: StandardHandlerInterceptorOptions<T>): StandardRequest;
|
22
|
+
/**
|
23
|
+
* Success batch response status code.
|
24
|
+
*
|
25
|
+
* @default 207
|
26
|
+
*/
|
27
|
+
successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
28
|
+
/**
|
29
|
+
* success batch response headers.
|
30
|
+
*
|
31
|
+
* @default {}
|
32
|
+
*/
|
33
|
+
headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
|
34
|
+
}
|
35
|
+
declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
36
|
+
private readonly maxSize;
|
37
|
+
private readonly mapRequestItem;
|
38
|
+
private readonly successStatus;
|
39
|
+
private readonly headers;
|
40
|
+
constructor(options?: BatchHandlerOptions<T>);
|
41
|
+
init(options: StandardHandlerOptions<T>): void;
|
42
|
+
}
|
43
|
+
|
44
|
+
interface CORSOptions<T extends Context> {
|
45
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
46
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
|
47
|
+
allowMethods?: readonly string[];
|
48
|
+
allowHeaders?: readonly string[];
|
49
|
+
maxAge?: number;
|
50
|
+
credentials?: boolean;
|
51
|
+
exposeHeaders?: readonly string[];
|
52
|
+
}
|
53
|
+
declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
54
|
+
private readonly options;
|
55
|
+
constructor(options?: CORSOptions<T>);
|
56
|
+
init(options: StandardHandlerOptions<T>): void;
|
57
|
+
}
|
58
|
+
|
59
|
+
interface ResponseHeadersPluginContext {
|
60
|
+
resHeaders?: Headers;
|
61
|
+
}
|
62
|
+
declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
|
63
|
+
init(options: StandardHandlerOptions<T>): void;
|
64
|
+
}
|
65
|
+
|
66
|
+
export { type BatchHandlerOptions, BatchHandlerPlugin, type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|