@orpc/server 0.0.0-next.fea68c1 → 0.0.0-next.ff68fdb
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 +4 -2
- package/dist/adapters/fetch/index.d.mts +26 -0
- package/dist/adapters/fetch/index.d.ts +26 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +19 -0
- package/dist/adapters/hono/index.d.ts +19 -0
- package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
- package/dist/adapters/next/index.d.mts +26 -0
- package/dist/adapters/next/index.d.ts +26 -0
- package/dist/{next.js → adapters/next/index.mjs} +11 -13
- package/dist/adapters/node/index.d.mts +34 -0
- package/dist/adapters/node/index.d.ts +34 -0
- package/dist/adapters/node/index.mjs +31 -0
- package/dist/adapters/standard/index.d.mts +25 -0
- package/dist/adapters/standard/index.d.ts +25 -0
- package/dist/adapters/standard/index.mjs +6 -0
- package/dist/index.d.mts +278 -0
- package/dist/index.d.ts +278 -0
- package/dist/{index.js → index.mjs} +85 -152
- package/dist/plugins/index.d.mts +31 -0
- package/dist/plugins/index.d.ts +31 -0
- package/dist/{chunk-TXHKQO7N.js → plugins/index.mjs} +12 -29
- package/dist/{chunk-NTHCS5CK.js → shared/server.3mOimouH.mjs} +21 -45
- package/dist/{chunk-MHVECKBC.js → shared/server.B_5ZADvP.mjs} +152 -210
- package/dist/shared/server.BgDZnmUZ.mjs +28 -0
- package/dist/shared/server.CL84X8p4.d.mts +75 -0
- package/dist/shared/server.DnmJuN02.d.mts +144 -0
- package/dist/shared/server.DnmJuN02.d.ts +144 -0
- package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
- package/dist/shared/server.hqPWnakL.d.ts +75 -0
- package/package.json +29 -34
- package/dist/chunk-MBMXGUNI.js +0 -32
- 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 -53
- package/dist/src/adapters/standard/index.d.ts +0 -6
- 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/types.d.ts +0 -21
- package/dist/src/builder-variants.d.ts +0 -75
- package/dist/src/builder.d.ts +0 -58
- package/dist/src/config.d.ts +0 -6
- package/dist/src/context.d.ts +0 -8
- package/dist/src/error.d.ts +0 -12
- package/dist/src/hidden.d.ts +0 -8
- package/dist/src/implementer-procedure.d.ts +0 -33
- package/dist/src/implementer-variants.d.ts +0 -18
- package/dist/src/implementer.d.ts +0 -29
- package/dist/src/index.d.ts +0 -25
- 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 -11
- package/dist/src/middleware-utils.d.ts +0 -5
- package/dist/src/middleware.d.ts +0 -38
- package/dist/src/plugins/base.d.ts +0 -11
- 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 -33
- package/dist/src/procedure-decorated.d.ts +0 -24
- package/dist/src/procedure-utils.d.ts +0 -19
- package/dist/src/procedure.d.ts +0 -31
- package/dist/src/router-accessible-lazy.d.ts +0 -8
- package/dist/src/router-client.d.ts +0 -12
- package/dist/src/router.d.ts +0 -30
- package/dist/src/utils.d.ts +0 -24
- package/dist/standard.js +0 -13
@@ -1,35 +1,15 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
createContractedProcedure,
|
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-MHVECKBC.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, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.B_5ZADvP.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, b as createContractedProcedure, j as createORPCErrorConstructorMap, q as getHiddenRouterContract, k as getLazyMeta, n as isStartWithMiddlewares, o as mergeMiddlewares, m as middlewareOutputFn, w as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.B_5ZADvP.mjs';
|
5
|
+
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
6
|
+
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
+
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
25
8
|
|
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 = {
|
9
|
+
const DEFAULT_CONFIG = {
|
31
10
|
initialInputValidationIndex: 0,
|
32
|
-
initialOutputValidationIndex: 0
|
11
|
+
initialOutputValidationIndex: 0,
|
12
|
+
dedupeLeadingMiddlewares: true
|
33
13
|
};
|
34
14
|
function fallbackConfig(key, value) {
|
35
15
|
if (value === void 0) {
|
@@ -38,9 +18,8 @@ function fallbackConfig(key, value) {
|
|
38
18
|
return value;
|
39
19
|
}
|
40
20
|
|
41
|
-
// src/middleware-decorated.ts
|
42
21
|
function decorateMiddleware(middleware) {
|
43
|
-
const decorated = middleware;
|
22
|
+
const decorated = (...args) => middleware(...args);
|
44
23
|
decorated.mapInput = (mapInput) => {
|
45
24
|
const mapped = decorateMiddleware(
|
46
25
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
@@ -65,30 +44,28 @@ function decorateMiddleware(middleware) {
|
|
65
44
|
return decorated;
|
66
45
|
}
|
67
46
|
|
68
|
-
|
69
|
-
import { mergeErrorMap, mergeMeta, mergeRoute } from "@orpc/contract";
|
70
|
-
var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
47
|
+
class DecoratedProcedure extends Procedure {
|
71
48
|
errors(errors) {
|
72
|
-
return new
|
49
|
+
return new DecoratedProcedure({
|
73
50
|
...this["~orpc"],
|
74
51
|
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
75
52
|
});
|
76
53
|
}
|
77
54
|
meta(meta) {
|
78
|
-
return new
|
55
|
+
return new DecoratedProcedure({
|
79
56
|
...this["~orpc"],
|
80
57
|
meta: mergeMeta(this["~orpc"].meta, meta)
|
81
58
|
});
|
82
59
|
}
|
83
60
|
route(route) {
|
84
|
-
return new
|
61
|
+
return new DecoratedProcedure({
|
85
62
|
...this["~orpc"],
|
86
63
|
route: mergeRoute(this["~orpc"].route, route)
|
87
64
|
});
|
88
65
|
}
|
89
66
|
use(middleware, mapInput) {
|
90
67
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
91
|
-
return new
|
68
|
+
return new DecoratedProcedure({
|
92
69
|
...this["~orpc"],
|
93
70
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
94
71
|
});
|
@@ -97,9 +74,13 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
|
97
74
|
* Make this procedure callable (works like a function while still being a procedure).
|
98
75
|
*/
|
99
76
|
callable(...rest) {
|
100
|
-
return
|
101
|
-
|
102
|
-
|
77
|
+
return new Proxy(createProcedureClient(this, ...rest), {
|
78
|
+
get: (target, key) => {
|
79
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
80
|
+
},
|
81
|
+
has: (target, key) => {
|
82
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
83
|
+
}
|
103
84
|
});
|
104
85
|
}
|
105
86
|
/**
|
@@ -108,10 +89,9 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
|
108
89
|
actionable(...rest) {
|
109
90
|
return this.callable(...rest);
|
110
91
|
}
|
111
|
-
}
|
92
|
+
}
|
112
93
|
|
113
|
-
|
114
|
-
var Builder = class _Builder {
|
94
|
+
class Builder {
|
115
95
|
"~orpc";
|
116
96
|
constructor(def) {
|
117
97
|
this["~orpc"] = def;
|
@@ -122,9 +102,10 @@ var Builder = class _Builder {
|
|
122
102
|
$config(config) {
|
123
103
|
const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
|
124
104
|
const outputValidationCount = this["~orpc"].outputValidationIndex - fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex);
|
125
|
-
return new
|
105
|
+
return new Builder({
|
126
106
|
...this["~orpc"],
|
127
107
|
config,
|
108
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares),
|
128
109
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
|
129
110
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config.initialOutputValidationIndex) + outputValidationCount
|
130
111
|
});
|
@@ -133,7 +114,7 @@ var Builder = class _Builder {
|
|
133
114
|
* Reset initial context
|
134
115
|
*/
|
135
116
|
$context() {
|
136
|
-
return new
|
117
|
+
return new Builder({
|
137
118
|
...this["~orpc"],
|
138
119
|
middlewares: [],
|
139
120
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
@@ -144,7 +125,7 @@ var Builder = class _Builder {
|
|
144
125
|
* Reset initial meta
|
145
126
|
*/
|
146
127
|
$meta(initialMeta) {
|
147
|
-
return new
|
128
|
+
return new Builder({
|
148
129
|
...this["~orpc"],
|
149
130
|
meta: initialMeta
|
150
131
|
});
|
@@ -153,48 +134,54 @@ var Builder = class _Builder {
|
|
153
134
|
* Reset initial route
|
154
135
|
*/
|
155
136
|
$route(initialRoute) {
|
156
|
-
return new
|
137
|
+
return new Builder({
|
157
138
|
...this["~orpc"],
|
158
139
|
route: initialRoute
|
159
140
|
});
|
160
141
|
}
|
142
|
+
$input(initialInputSchema) {
|
143
|
+
return new Builder({
|
144
|
+
...this["~orpc"],
|
145
|
+
inputSchema: initialInputSchema
|
146
|
+
});
|
147
|
+
}
|
161
148
|
middleware(middleware) {
|
162
149
|
return decorateMiddleware(middleware);
|
163
150
|
}
|
164
151
|
errors(errors) {
|
165
|
-
return new
|
152
|
+
return new Builder({
|
166
153
|
...this["~orpc"],
|
167
|
-
errorMap:
|
154
|
+
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
168
155
|
});
|
169
156
|
}
|
170
157
|
use(middleware, mapInput) {
|
171
158
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
172
|
-
return new
|
159
|
+
return new Builder({
|
173
160
|
...this["~orpc"],
|
174
161
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
175
162
|
});
|
176
163
|
}
|
177
164
|
meta(meta) {
|
178
|
-
return new
|
165
|
+
return new Builder({
|
179
166
|
...this["~orpc"],
|
180
|
-
meta:
|
167
|
+
meta: mergeMeta(this["~orpc"].meta, meta)
|
181
168
|
});
|
182
169
|
}
|
183
170
|
route(route) {
|
184
|
-
return new
|
171
|
+
return new Builder({
|
185
172
|
...this["~orpc"],
|
186
|
-
route:
|
173
|
+
route: mergeRoute(this["~orpc"].route, route)
|
187
174
|
});
|
188
175
|
}
|
189
176
|
input(schema) {
|
190
|
-
return new
|
177
|
+
return new Builder({
|
191
178
|
...this["~orpc"],
|
192
179
|
inputSchema: schema,
|
193
180
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + this["~orpc"].middlewares.length
|
194
181
|
});
|
195
182
|
}
|
196
183
|
output(schema) {
|
197
|
-
return new
|
184
|
+
return new Builder({
|
198
185
|
...this["~orpc"],
|
199
186
|
outputSchema: schema,
|
200
187
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + this["~orpc"].middlewares.length
|
@@ -207,43 +194,39 @@ var Builder = class _Builder {
|
|
207
194
|
});
|
208
195
|
}
|
209
196
|
prefix(prefix) {
|
210
|
-
return new
|
197
|
+
return new Builder({
|
211
198
|
...this["~orpc"],
|
212
199
|
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
213
200
|
});
|
214
201
|
}
|
215
202
|
tag(...tags) {
|
216
|
-
return new
|
203
|
+
return new Builder({
|
217
204
|
...this["~orpc"],
|
218
205
|
tags: mergeTags(this["~orpc"].tags, tags)
|
219
206
|
});
|
220
207
|
}
|
221
208
|
router(router) {
|
222
|
-
return
|
209
|
+
return enhanceRouter(router, this["~orpc"]);
|
223
210
|
}
|
224
211
|
lazy(loader) {
|
225
|
-
return
|
212
|
+
return enhanceRouter(lazy(loader), this["~orpc"]);
|
226
213
|
}
|
227
|
-
}
|
228
|
-
|
214
|
+
}
|
215
|
+
const os = new Builder({
|
229
216
|
config: {},
|
230
217
|
route: {},
|
231
218
|
meta: {},
|
232
219
|
errorMap: {},
|
233
|
-
inputSchema: void 0,
|
234
|
-
outputSchema: void 0,
|
235
220
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
|
236
221
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
|
237
|
-
middlewares: []
|
222
|
+
middlewares: [],
|
223
|
+
dedupeLeadingMiddlewares: true
|
238
224
|
});
|
239
225
|
|
240
|
-
|
241
|
-
function mergeContext(context, other) {
|
226
|
+
function mergeCurrentContext(context, other) {
|
242
227
|
return { ...context, ...other };
|
243
228
|
}
|
244
229
|
|
245
|
-
// src/implementer.ts
|
246
|
-
import { isContractProcedure } from "@orpc/contract";
|
247
230
|
function implementerInternal(contract, config, middlewares) {
|
248
231
|
if (isContractProcedure(contract)) {
|
249
232
|
const impl2 = new Builder({
|
@@ -251,12 +234,16 @@ function implementerInternal(contract, config, middlewares) {
|
|
251
234
|
config,
|
252
235
|
middlewares,
|
253
236
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config?.initialInputValidationIndex) + middlewares.length,
|
254
|
-
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length
|
237
|
+
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length,
|
238
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
255
239
|
});
|
256
240
|
return impl2;
|
257
241
|
}
|
258
242
|
const impl = new Proxy(contract, {
|
259
243
|
get: (target, key) => {
|
244
|
+
if (typeof key !== "string") {
|
245
|
+
return Reflect.get(target, key);
|
246
|
+
}
|
260
247
|
let method;
|
261
248
|
if (key === "middleware") {
|
262
249
|
method = (mid) => decorateMiddleware(mid);
|
@@ -270,23 +257,29 @@ function implementerInternal(contract, config, middlewares) {
|
|
270
257
|
};
|
271
258
|
} else if (key === "router") {
|
272
259
|
method = (router) => {
|
273
|
-
const adapted =
|
260
|
+
const adapted = enhanceRouter(router, {
|
274
261
|
middlewares,
|
275
|
-
errorMap: {}
|
262
|
+
errorMap: {},
|
263
|
+
prefix: void 0,
|
264
|
+
tags: void 0,
|
265
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
276
266
|
});
|
277
|
-
return
|
267
|
+
return setHiddenRouterContract(adapted, contract);
|
278
268
|
};
|
279
269
|
} else if (key === "lazy") {
|
280
270
|
method = (loader) => {
|
281
|
-
const adapted =
|
271
|
+
const adapted = enhanceRouter(lazy(loader), {
|
282
272
|
middlewares,
|
283
|
-
errorMap: {}
|
273
|
+
errorMap: {},
|
274
|
+
prefix: void 0,
|
275
|
+
tags: void 0,
|
276
|
+
dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
|
284
277
|
});
|
285
|
-
return
|
278
|
+
return setHiddenRouterContract(adapted, contract);
|
286
279
|
};
|
287
280
|
}
|
288
|
-
const next =
|
289
|
-
if (!next
|
281
|
+
const next = getContractRouter(target, [key]);
|
282
|
+
if (!next) {
|
290
283
|
return method ?? next;
|
291
284
|
}
|
292
285
|
const nextImpl = implementerInternal(next, config, middlewares);
|
@@ -313,44 +306,34 @@ function implement(contract, config = {}) {
|
|
313
306
|
method = (config2) => implement(contract, config2);
|
314
307
|
}
|
315
308
|
const next = Reflect.get(target, key);
|
316
|
-
if (!next || typeof next !== "function" && typeof next !== "object") {
|
317
|
-
return method
|
318
|
-
}
|
319
|
-
if (method) {
|
320
|
-
return new Proxy(method, {
|
321
|
-
get(_, key2) {
|
322
|
-
return Reflect.get(next, key2);
|
323
|
-
}
|
324
|
-
});
|
309
|
+
if (!method || !next || typeof next !== "function" && typeof next !== "object") {
|
310
|
+
return method || next;
|
325
311
|
}
|
326
|
-
return
|
312
|
+
return new Proxy(method, {
|
313
|
+
get(_, key2) {
|
314
|
+
return Reflect.get(next, key2);
|
315
|
+
}
|
316
|
+
});
|
327
317
|
}
|
328
318
|
});
|
329
319
|
return impl;
|
330
320
|
}
|
331
321
|
|
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) {
|
322
|
+
function createRouterClient(router, ...[options]) {
|
339
323
|
if (isProcedure(router)) {
|
340
|
-
const caller = createProcedureClient(router,
|
324
|
+
const caller = createProcedureClient(router, options);
|
341
325
|
return caller;
|
342
326
|
}
|
343
|
-
const procedureCaller = isLazy(router) ? createProcedureClient(
|
327
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
|
344
328
|
const recursive = new Proxy(procedureCaller, {
|
345
329
|
get(target, key) {
|
346
330
|
if (typeof key !== "string") {
|
347
331
|
return Reflect.get(target, key);
|
348
332
|
}
|
349
|
-
const next =
|
333
|
+
const next = getRouter(router, [key]);
|
350
334
|
if (!next) {
|
351
335
|
return Reflect.get(target, key);
|
352
336
|
}
|
353
|
-
const [options] = rest;
|
354
337
|
return createRouterClient(next, {
|
355
338
|
...options,
|
356
339
|
path: [...options?.path ?? [], key]
|
@@ -360,54 +343,4 @@ function createRouterClient(router, ...rest) {
|
|
360
343
|
return recursive;
|
361
344
|
}
|
362
345
|
|
363
|
-
|
364
|
-
import { isDefinedError, ORPCError, safe } from "@orpc/client";
|
365
|
-
import { eventIterator, type, ValidationError } from "@orpc/contract";
|
366
|
-
import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
|
367
|
-
import { getEventMeta, withEventMeta } from "@orpc/standard-server";
|
368
|
-
export {
|
369
|
-
Builder,
|
370
|
-
DecoratedProcedure,
|
371
|
-
LAZY_LOADER_SYMBOL,
|
372
|
-
ORPCError,
|
373
|
-
Procedure,
|
374
|
-
ValidationError,
|
375
|
-
adaptRouter,
|
376
|
-
call,
|
377
|
-
convertPathToHttpPath,
|
378
|
-
createAccessibleLazyRouter,
|
379
|
-
createContractedProcedure,
|
380
|
-
createLazyProcedureFormAnyLazy,
|
381
|
-
createProcedureClient,
|
382
|
-
createRouterClient,
|
383
|
-
decorateMiddleware,
|
384
|
-
deepSetLazyRouterPrefix,
|
385
|
-
eachAllContractProcedure,
|
386
|
-
eachContractProcedure,
|
387
|
-
eventIterator,
|
388
|
-
fallbackConfig,
|
389
|
-
flatLazy,
|
390
|
-
getEventMeta,
|
391
|
-
getLazyRouterPrefix,
|
392
|
-
getRouterChild,
|
393
|
-
getRouterContract,
|
394
|
-
implement,
|
395
|
-
implementerInternal,
|
396
|
-
isDefinedError,
|
397
|
-
isLazy,
|
398
|
-
isProcedure,
|
399
|
-
lazy,
|
400
|
-
mergeContext,
|
401
|
-
middlewareOutputFn,
|
402
|
-
onError,
|
403
|
-
onFinish,
|
404
|
-
onStart,
|
405
|
-
onSuccess,
|
406
|
-
os,
|
407
|
-
safe,
|
408
|
-
setRouterContract,
|
409
|
-
type,
|
410
|
-
unlazy,
|
411
|
-
withEventMeta
|
412
|
-
};
|
413
|
-
//# sourceMappingURL=index.js.map
|
346
|
+
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, mergeCurrentContext, os, setHiddenRouterContract };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CL84X8p4.mjs';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.CL84X8p4.mjs';
|
3
|
+
import { Value } from '@orpc/shared';
|
4
|
+
import { C as Context } from '../shared/server.DnmJuN02.mjs';
|
5
|
+
import '@orpc/contract';
|
6
|
+
import '@orpc/standard-server';
|
7
|
+
import '@orpc/client';
|
8
|
+
|
9
|
+
interface CORSOptions<TContext extends Context> {
|
10
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
+
allowMethods?: readonly string[];
|
13
|
+
allowHeaders?: readonly string[];
|
14
|
+
maxAge?: number;
|
15
|
+
credentials?: boolean;
|
16
|
+
exposeHeaders?: readonly string[];
|
17
|
+
}
|
18
|
+
declare class CORSPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
19
|
+
private readonly options;
|
20
|
+
constructor(options?: CORSOptions<TContext>);
|
21
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
22
|
+
}
|
23
|
+
|
24
|
+
interface ResponseHeadersPluginContext {
|
25
|
+
resHeaders?: Headers;
|
26
|
+
}
|
27
|
+
declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements HandlerPlugin<TContext> {
|
28
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
29
|
+
}
|
30
|
+
|
31
|
+
export { type CORSOptions, CORSPlugin, HandlerPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.hqPWnakL.js';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.hqPWnakL.js';
|
3
|
+
import { Value } from '@orpc/shared';
|
4
|
+
import { C as Context } from '../shared/server.DnmJuN02.js';
|
5
|
+
import '@orpc/contract';
|
6
|
+
import '@orpc/standard-server';
|
7
|
+
import '@orpc/client';
|
8
|
+
|
9
|
+
interface CORSOptions<TContext extends Context> {
|
10
|
+
origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
11
|
+
timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<TContext>]>;
|
12
|
+
allowMethods?: readonly string[];
|
13
|
+
allowHeaders?: readonly string[];
|
14
|
+
maxAge?: number;
|
15
|
+
credentials?: boolean;
|
16
|
+
exposeHeaders?: readonly string[];
|
17
|
+
}
|
18
|
+
declare class CORSPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
19
|
+
private readonly options;
|
20
|
+
constructor(options?: CORSOptions<TContext>);
|
21
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
22
|
+
}
|
23
|
+
|
24
|
+
interface ResponseHeadersPluginContext {
|
25
|
+
resHeaders?: Headers;
|
26
|
+
}
|
27
|
+
declare class ResponseHeadersPlugin<TContext extends ResponseHeadersPluginContext & Context> implements HandlerPlugin<TContext> {
|
28
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
29
|
+
}
|
30
|
+
|
31
|
+
export { type CORSOptions, CORSPlugin, HandlerPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext };
|
@@ -1,20 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
constructor(plugins = []) {
|
4
|
-
this.plugins = plugins;
|
5
|
-
}
|
6
|
-
init(options) {
|
7
|
-
for (const plugin of this.plugins) {
|
8
|
-
plugin.init?.(options);
|
9
|
-
}
|
10
|
-
}
|
11
|
-
};
|
1
|
+
export { C as CompositePlugin } from '../shared/server.Q6ZmnTgO.mjs';
|
2
|
+
import { value } from '@orpc/shared';
|
12
3
|
|
13
|
-
|
14
|
-
import { value } from "@orpc/shared";
|
15
|
-
var CORSPlugin = class {
|
4
|
+
class CORSPlugin {
|
16
5
|
options;
|
17
|
-
constructor(options) {
|
6
|
+
constructor(options = {}) {
|
18
7
|
const defaults = {
|
19
8
|
origin: (origin) => origin,
|
20
9
|
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"]
|
@@ -84,10 +73,9 @@ var CORSPlugin = class {
|
|
84
73
|
return result;
|
85
74
|
});
|
86
75
|
}
|
87
|
-
}
|
76
|
+
}
|
88
77
|
|
89
|
-
|
90
|
-
var ResponseHeadersPlugin = class {
|
78
|
+
class ResponseHeadersPlugin {
|
91
79
|
init(options) {
|
92
80
|
options.rootInterceptors ??= [];
|
93
81
|
options.rootInterceptors.push(async (interceptorOptions) => {
|
@@ -98,23 +86,18 @@ var ResponseHeadersPlugin = class {
|
|
98
86
|
return result;
|
99
87
|
}
|
100
88
|
const responseHeaders = result.response.headers;
|
101
|
-
for (const [key,
|
89
|
+
for (const [key, value] of headers) {
|
102
90
|
if (Array.isArray(responseHeaders[key])) {
|
103
|
-
responseHeaders[key].push(
|
91
|
+
responseHeaders[key].push(value);
|
104
92
|
} else if (responseHeaders[key] !== void 0) {
|
105
|
-
responseHeaders[key] = [responseHeaders[key],
|
93
|
+
responseHeaders[key] = [responseHeaders[key], value];
|
106
94
|
} else {
|
107
|
-
responseHeaders[key] =
|
95
|
+
responseHeaders[key] = value;
|
108
96
|
}
|
109
97
|
}
|
110
98
|
return result;
|
111
99
|
});
|
112
100
|
}
|
113
|
-
}
|
101
|
+
}
|
114
102
|
|
115
|
-
export {
|
116
|
-
CompositePlugin,
|
117
|
-
CORSPlugin,
|
118
|
-
ResponseHeadersPlugin
|
119
|
-
};
|
120
|
-
//# sourceMappingURL=chunk-TXHKQO7N.js.map
|
103
|
+
export { CORSPlugin, ResponseHeadersPlugin };
|
@@ -1,21 +1,10 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
eachContractProcedure,
|
6
|
-
getRouterChild,
|
7
|
-
isProcedure,
|
8
|
-
unlazy
|
9
|
-
} from "./chunk-MHVECKBC.js";
|
10
|
-
import {
|
11
|
-
CompositePlugin
|
12
|
-
} from "./chunk-TXHKQO7N.js";
|
1
|
+
import { ORPCError, toORPCError } from '@orpc/client';
|
2
|
+
import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
|
3
|
+
import { C as CompositePlugin } from './server.Q6ZmnTgO.mjs';
|
4
|
+
import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.B_5ZADvP.mjs';
|
13
5
|
|
14
|
-
|
15
|
-
|
16
|
-
import { intercept, trim } from "@orpc/shared";
|
17
|
-
var StandardHandler = class {
|
18
|
-
constructor(router, matcher, codec, options = {}) {
|
6
|
+
class StandardHandler {
|
7
|
+
constructor(router, matcher, codec, options) {
|
19
8
|
this.matcher = matcher;
|
20
9
|
this.codec = codec;
|
21
10
|
this.options = options;
|
@@ -78,15 +67,11 @@ var StandardHandler = class {
|
|
78
67
|
}
|
79
68
|
);
|
80
69
|
}
|
81
|
-
}
|
70
|
+
}
|
82
71
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
var RPCCodec = class {
|
87
|
-
serializer;
|
88
|
-
constructor(options = {}) {
|
89
|
-
this.serializer = options.serializer ?? new RPCSerializer();
|
72
|
+
class RPCCodec {
|
73
|
+
constructor(serializer) {
|
74
|
+
this.serializer = serializer;
|
90
75
|
}
|
91
76
|
async decode(request, _params, _procedure) {
|
92
77
|
const serialized = request.method === "GET" ? parseEmptyableJSON(request.url.searchParams.getAll("data").at(-1)) : await request.body();
|
@@ -106,18 +91,14 @@ var RPCCodec = class {
|
|
106
91
|
body: this.serializer.serialize(error.toJSON())
|
107
92
|
};
|
108
93
|
}
|
109
|
-
}
|
94
|
+
}
|
110
95
|
|
111
|
-
|
112
|
-
var RPCMatcher = class {
|
96
|
+
class RPCMatcher {
|
113
97
|
tree = {};
|
114
98
|
pendingRouters = [];
|
115
99
|
init(router, path = []) {
|
116
|
-
const laziedOptions =
|
117
|
-
|
118
|
-
path
|
119
|
-
}, ({ path: path2, contract }) => {
|
120
|
-
const httpPath = convertPathToHttpPath(path2);
|
100
|
+
const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
|
101
|
+
const httpPath = toHttpPath(path2);
|
121
102
|
if (isProcedure(contract)) {
|
122
103
|
this.tree[httpPath] = {
|
123
104
|
path: path2,
|
@@ -137,7 +118,7 @@ var RPCMatcher = class {
|
|
137
118
|
});
|
138
119
|
this.pendingRouters.push(...laziedOptions.map((option) => ({
|
139
120
|
...option,
|
140
|
-
httpPathPrefix:
|
121
|
+
httpPathPrefix: toHttpPath(option.path)
|
141
122
|
})));
|
142
123
|
}
|
143
124
|
async match(_method, pathname) {
|
@@ -145,7 +126,7 @@ var RPCMatcher = class {
|
|
145
126
|
const newPendingRouters = [];
|
146
127
|
for (const pendingRouter of this.pendingRouters) {
|
147
128
|
if (pathname.startsWith(pendingRouter.httpPathPrefix)) {
|
148
|
-
const { default: router } = await unlazy(pendingRouter.
|
129
|
+
const { default: router } = await unlazy(pendingRouter.router);
|
149
130
|
this.init(router, pendingRouter.path);
|
150
131
|
} else {
|
151
132
|
newPendingRouters.push(pendingRouter);
|
@@ -158,25 +139,20 @@ var RPCMatcher = class {
|
|
158
139
|
return void 0;
|
159
140
|
}
|
160
141
|
if (!match.procedure) {
|
161
|
-
const { default: maybeProcedure } = await unlazy(
|
142
|
+
const { default: maybeProcedure } = await unlazy(getRouter(match.router, match.path));
|
162
143
|
if (!isProcedure(maybeProcedure)) {
|
163
144
|
throw new Error(`
|
164
|
-
[Contract-First] Missing or invalid implementation for procedure at path: ${
|
145
|
+
[Contract-First] Missing or invalid implementation for procedure at path: ${toHttpPath(match.path)}.
|
165
146
|
Ensure that the procedure is correctly defined and matches the expected contract.
|
166
147
|
`);
|
167
148
|
}
|
168
|
-
match.procedure = createContractedProcedure(match.contract
|
149
|
+
match.procedure = createContractedProcedure(maybeProcedure, match.contract);
|
169
150
|
}
|
170
151
|
return {
|
171
152
|
path: match.path,
|
172
153
|
procedure: match.procedure
|
173
154
|
};
|
174
155
|
}
|
175
|
-
}
|
156
|
+
}
|
176
157
|
|
177
|
-
export {
|
178
|
-
StandardHandler,
|
179
|
-
RPCCodec,
|
180
|
-
RPCMatcher
|
181
|
-
};
|
182
|
-
//# sourceMappingURL=chunk-NTHCS5CK.js.map
|
158
|
+
export { RPCCodec as R, StandardHandler as S, RPCMatcher as a };
|