@orpc/server 0.0.0-next.cc4cb21 → 0.0.0-next.cc8802c
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 +1 -1
- 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 +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/{index.js → index.mjs} +68 -138
- 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/shared/server.CM3tWr3C.d.mts +75 -0
- package/dist/{chunk-MHVECKBC.js → shared/server.CMrS28Go.mjs} +135 -210
- package/dist/shared/server.CPteJIPP.d.mts +143 -0
- package/dist/shared/server.CPteJIPP.d.ts +143 -0
- package/dist/{chunk-EWOWWNDI.js → shared/server.CSZRzcSW.mjs} +21 -45
- package/dist/shared/server.Cq3B6PoL.mjs +28 -0
- package/dist/shared/server.DmW25ynm.d.ts +75 -0
- package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
- package/package.json +29 -34
- package/dist/chunk-XT6IYOIS.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,33 +1,12 @@
|
|
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.CMrS28Go.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, k as call, o as createAccessibleLazyRouter, b as createContractedProcedure, n as getHiddenRouterContract, j as getLazyMeta, m as middlewareOutputFn, r as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, p as unlazyRouter } from './shared/server.CMrS28Go.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
11
|
initialOutputValidationIndex: 0
|
33
12
|
};
|
@@ -38,9 +17,8 @@ function fallbackConfig(key, value) {
|
|
38
17
|
return value;
|
39
18
|
}
|
40
19
|
|
41
|
-
// src/middleware-decorated.ts
|
42
20
|
function decorateMiddleware(middleware) {
|
43
|
-
const decorated = middleware;
|
21
|
+
const decorated = (...args) => middleware(...args);
|
44
22
|
decorated.mapInput = (mapInput) => {
|
45
23
|
const mapped = decorateMiddleware(
|
46
24
|
(options, input, ...rest) => middleware(options, mapInput(input), ...rest)
|
@@ -65,30 +43,28 @@ function decorateMiddleware(middleware) {
|
|
65
43
|
return decorated;
|
66
44
|
}
|
67
45
|
|
68
|
-
|
69
|
-
import { mergeErrorMap, mergeMeta, mergeRoute } from "@orpc/contract";
|
70
|
-
var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
46
|
+
class DecoratedProcedure extends Procedure {
|
71
47
|
errors(errors) {
|
72
|
-
return new
|
48
|
+
return new DecoratedProcedure({
|
73
49
|
...this["~orpc"],
|
74
50
|
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
75
51
|
});
|
76
52
|
}
|
77
53
|
meta(meta) {
|
78
|
-
return new
|
54
|
+
return new DecoratedProcedure({
|
79
55
|
...this["~orpc"],
|
80
56
|
meta: mergeMeta(this["~orpc"].meta, meta)
|
81
57
|
});
|
82
58
|
}
|
83
59
|
route(route) {
|
84
|
-
return new
|
60
|
+
return new DecoratedProcedure({
|
85
61
|
...this["~orpc"],
|
86
62
|
route: mergeRoute(this["~orpc"].route, route)
|
87
63
|
});
|
88
64
|
}
|
89
65
|
use(middleware, mapInput) {
|
90
66
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
91
|
-
return new
|
67
|
+
return new DecoratedProcedure({
|
92
68
|
...this["~orpc"],
|
93
69
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
94
70
|
});
|
@@ -97,9 +73,13 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
|
97
73
|
* Make this procedure callable (works like a function while still being a procedure).
|
98
74
|
*/
|
99
75
|
callable(...rest) {
|
100
|
-
return
|
101
|
-
|
102
|
-
|
76
|
+
return new Proxy(createProcedureClient(this, ...rest), {
|
77
|
+
get: (target, key) => {
|
78
|
+
return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
|
79
|
+
},
|
80
|
+
has: (target, key) => {
|
81
|
+
return Reflect.has(this, key) || Reflect.has(target, key);
|
82
|
+
}
|
103
83
|
});
|
104
84
|
}
|
105
85
|
/**
|
@@ -108,10 +88,9 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
|
|
108
88
|
actionable(...rest) {
|
109
89
|
return this.callable(...rest);
|
110
90
|
}
|
111
|
-
}
|
91
|
+
}
|
112
92
|
|
113
|
-
|
114
|
-
var Builder = class _Builder {
|
93
|
+
class Builder {
|
115
94
|
"~orpc";
|
116
95
|
constructor(def) {
|
117
96
|
this["~orpc"] = def;
|
@@ -122,7 +101,7 @@ var Builder = class _Builder {
|
|
122
101
|
$config(config) {
|
123
102
|
const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
|
124
103
|
const outputValidationCount = this["~orpc"].outputValidationIndex - fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex);
|
125
|
-
return new
|
104
|
+
return new Builder({
|
126
105
|
...this["~orpc"],
|
127
106
|
config,
|
128
107
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
|
@@ -133,7 +112,7 @@ var Builder = class _Builder {
|
|
133
112
|
* Reset initial context
|
134
113
|
*/
|
135
114
|
$context() {
|
136
|
-
return new
|
115
|
+
return new Builder({
|
137
116
|
...this["~orpc"],
|
138
117
|
middlewares: [],
|
139
118
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
|
@@ -144,7 +123,7 @@ var Builder = class _Builder {
|
|
144
123
|
* Reset initial meta
|
145
124
|
*/
|
146
125
|
$meta(initialMeta) {
|
147
|
-
return new
|
126
|
+
return new Builder({
|
148
127
|
...this["~orpc"],
|
149
128
|
meta: initialMeta
|
150
129
|
});
|
@@ -153,48 +132,54 @@ var Builder = class _Builder {
|
|
153
132
|
* Reset initial route
|
154
133
|
*/
|
155
134
|
$route(initialRoute) {
|
156
|
-
return new
|
135
|
+
return new Builder({
|
157
136
|
...this["~orpc"],
|
158
137
|
route: initialRoute
|
159
138
|
});
|
160
139
|
}
|
140
|
+
$input(initialInputSchema) {
|
141
|
+
return new Builder({
|
142
|
+
...this["~orpc"],
|
143
|
+
inputSchema: initialInputSchema
|
144
|
+
});
|
145
|
+
}
|
161
146
|
middleware(middleware) {
|
162
147
|
return decorateMiddleware(middleware);
|
163
148
|
}
|
164
149
|
errors(errors) {
|
165
|
-
return new
|
150
|
+
return new Builder({
|
166
151
|
...this["~orpc"],
|
167
|
-
errorMap:
|
152
|
+
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
168
153
|
});
|
169
154
|
}
|
170
155
|
use(middleware, mapInput) {
|
171
156
|
const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
|
172
|
-
return new
|
157
|
+
return new Builder({
|
173
158
|
...this["~orpc"],
|
174
159
|
middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
|
175
160
|
});
|
176
161
|
}
|
177
162
|
meta(meta) {
|
178
|
-
return new
|
163
|
+
return new Builder({
|
179
164
|
...this["~orpc"],
|
180
|
-
meta:
|
165
|
+
meta: mergeMeta(this["~orpc"].meta, meta)
|
181
166
|
});
|
182
167
|
}
|
183
168
|
route(route) {
|
184
|
-
return new
|
169
|
+
return new Builder({
|
185
170
|
...this["~orpc"],
|
186
|
-
route:
|
171
|
+
route: mergeRoute(this["~orpc"].route, route)
|
187
172
|
});
|
188
173
|
}
|
189
174
|
input(schema) {
|
190
|
-
return new
|
175
|
+
return new Builder({
|
191
176
|
...this["~orpc"],
|
192
177
|
inputSchema: schema,
|
193
178
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + this["~orpc"].middlewares.length
|
194
179
|
});
|
195
180
|
}
|
196
181
|
output(schema) {
|
197
|
-
return new
|
182
|
+
return new Builder({
|
198
183
|
...this["~orpc"],
|
199
184
|
outputSchema: schema,
|
200
185
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + this["~orpc"].middlewares.length
|
@@ -207,43 +192,38 @@ var Builder = class _Builder {
|
|
207
192
|
});
|
208
193
|
}
|
209
194
|
prefix(prefix) {
|
210
|
-
return new
|
195
|
+
return new Builder({
|
211
196
|
...this["~orpc"],
|
212
197
|
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
213
198
|
});
|
214
199
|
}
|
215
200
|
tag(...tags) {
|
216
|
-
return new
|
201
|
+
return new Builder({
|
217
202
|
...this["~orpc"],
|
218
203
|
tags: mergeTags(this["~orpc"].tags, tags)
|
219
204
|
});
|
220
205
|
}
|
221
206
|
router(router) {
|
222
|
-
return
|
207
|
+
return enhanceRouter(router, this["~orpc"]);
|
223
208
|
}
|
224
209
|
lazy(loader) {
|
225
|
-
return
|
210
|
+
return enhanceRouter(lazy(loader), this["~orpc"]);
|
226
211
|
}
|
227
|
-
}
|
228
|
-
|
212
|
+
}
|
213
|
+
const os = new Builder({
|
229
214
|
config: {},
|
230
215
|
route: {},
|
231
216
|
meta: {},
|
232
217
|
errorMap: {},
|
233
|
-
inputSchema: void 0,
|
234
|
-
outputSchema: void 0,
|
235
218
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
|
236
219
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
|
237
220
|
middlewares: []
|
238
221
|
});
|
239
222
|
|
240
|
-
// src/context.ts
|
241
223
|
function mergeContext(context, other) {
|
242
224
|
return { ...context, ...other };
|
243
225
|
}
|
244
226
|
|
245
|
-
// src/implementer.ts
|
246
|
-
import { isContractProcedure } from "@orpc/contract";
|
247
227
|
function implementerInternal(contract, config, middlewares) {
|
248
228
|
if (isContractProcedure(contract)) {
|
249
229
|
const impl2 = new Builder({
|
@@ -257,6 +237,9 @@ function implementerInternal(contract, config, middlewares) {
|
|
257
237
|
}
|
258
238
|
const impl = new Proxy(contract, {
|
259
239
|
get: (target, key) => {
|
240
|
+
if (typeof key !== "string") {
|
241
|
+
return Reflect.get(target, key);
|
242
|
+
}
|
260
243
|
let method;
|
261
244
|
if (key === "middleware") {
|
262
245
|
method = (mid) => decorateMiddleware(mid);
|
@@ -270,23 +253,27 @@ function implementerInternal(contract, config, middlewares) {
|
|
270
253
|
};
|
271
254
|
} else if (key === "router") {
|
272
255
|
method = (router) => {
|
273
|
-
const adapted =
|
256
|
+
const adapted = enhanceRouter(router, {
|
274
257
|
middlewares,
|
275
|
-
errorMap: {}
|
258
|
+
errorMap: {},
|
259
|
+
prefix: void 0,
|
260
|
+
tags: void 0
|
276
261
|
});
|
277
|
-
return
|
262
|
+
return setHiddenRouterContract(adapted, contract);
|
278
263
|
};
|
279
264
|
} else if (key === "lazy") {
|
280
265
|
method = (loader) => {
|
281
|
-
const adapted =
|
266
|
+
const adapted = enhanceRouter(lazy(loader), {
|
282
267
|
middlewares,
|
283
|
-
errorMap: {}
|
268
|
+
errorMap: {},
|
269
|
+
prefix: void 0,
|
270
|
+
tags: void 0
|
284
271
|
});
|
285
|
-
return
|
272
|
+
return setHiddenRouterContract(adapted, contract);
|
286
273
|
};
|
287
274
|
}
|
288
|
-
const next =
|
289
|
-
if (!next
|
275
|
+
const next = getContractRouter(target, [key]);
|
276
|
+
if (!next) {
|
290
277
|
return method ?? next;
|
291
278
|
}
|
292
279
|
const nextImpl = implementerInternal(next, config, middlewares);
|
@@ -329,28 +316,21 @@ function implement(contract, config = {}) {
|
|
329
316
|
return impl;
|
330
317
|
}
|
331
318
|
|
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) {
|
319
|
+
function createRouterClient(router, ...[options]) {
|
339
320
|
if (isProcedure(router)) {
|
340
|
-
const caller = createProcedureClient(router,
|
321
|
+
const caller = createProcedureClient(router, options);
|
341
322
|
return caller;
|
342
323
|
}
|
343
|
-
const procedureCaller = isLazy(router) ? createProcedureClient(
|
324
|
+
const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
|
344
325
|
const recursive = new Proxy(procedureCaller, {
|
345
326
|
get(target, key) {
|
346
327
|
if (typeof key !== "string") {
|
347
328
|
return Reflect.get(target, key);
|
348
329
|
}
|
349
|
-
const next =
|
330
|
+
const next = getRouter(router, [key]);
|
350
331
|
if (!next) {
|
351
332
|
return Reflect.get(target, key);
|
352
333
|
}
|
353
|
-
const [options] = rest;
|
354
334
|
return createRouterClient(next, {
|
355
335
|
...options,
|
356
336
|
path: [...options?.path ?? [], key]
|
@@ -360,54 +340,4 @@ function createRouterClient(router, ...rest) {
|
|
360
340
|
return recursive;
|
361
341
|
}
|
362
342
|
|
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
|
343
|
+
export { Builder, DecoratedProcedure, Procedure, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, mergeContext, os, setHiddenRouterContract };
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CM3tWr3C.mjs';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.CM3tWr3C.mjs';
|
3
|
+
import { Value } from '@orpc/shared';
|
4
|
+
import { C as Context } from '../shared/server.CPteJIPP.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.DmW25ynm.js';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.DmW25ynm.js';
|
3
|
+
import { Value } from '@orpc/shared';
|
4
|
+
import { C as Context } from '../shared/server.CPteJIPP.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 };
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
2
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
|
+
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CPteJIPP.mjs';
|
5
|
+
import { ORPCError } from '@orpc/client';
|
6
|
+
|
7
|
+
type StandardParams = Record<string, string>;
|
8
|
+
type StandardMatchResult = {
|
9
|
+
path: readonly string[];
|
10
|
+
procedure: AnyProcedure;
|
11
|
+
params?: StandardParams;
|
12
|
+
} | undefined;
|
13
|
+
interface StandardMatcher {
|
14
|
+
init(router: AnyRouter): void;
|
15
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
16
|
+
}
|
17
|
+
interface StandardCodec {
|
18
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
19
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
20
|
+
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
21
|
+
}
|
22
|
+
|
23
|
+
type StandardHandleOptions<T extends Context> = {
|
24
|
+
prefix?: HTTPPath;
|
25
|
+
} & (Record<never, never> extends T ? {
|
26
|
+
context?: T;
|
27
|
+
} : {
|
28
|
+
context: T;
|
29
|
+
});
|
30
|
+
type StandardHandleResult = {
|
31
|
+
matched: true;
|
32
|
+
response: StandardResponse;
|
33
|
+
} | {
|
34
|
+
matched: false;
|
35
|
+
response: undefined;
|
36
|
+
};
|
37
|
+
type StandardHandlerInterceptorOptions<T extends Context> = StandardHandleOptions<T> & {
|
38
|
+
context: T;
|
39
|
+
request: StandardLazyRequest;
|
40
|
+
};
|
41
|
+
interface StandardHandlerOptions<TContext extends Context> {
|
42
|
+
plugins?: HandlerPlugin<TContext>[];
|
43
|
+
/**
|
44
|
+
* Interceptors at the request level, helpful when you want catch errors
|
45
|
+
*/
|
46
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
47
|
+
/**
|
48
|
+
* Interceptors at the root level, helpful when you want override the request/response
|
49
|
+
*/
|
50
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
|
51
|
+
/**
|
52
|
+
*
|
53
|
+
* Interceptors for procedure client.
|
54
|
+
*/
|
55
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
56
|
+
}
|
57
|
+
declare class StandardHandler<T extends Context> {
|
58
|
+
private readonly matcher;
|
59
|
+
private readonly codec;
|
60
|
+
private readonly options;
|
61
|
+
private readonly plugin;
|
62
|
+
constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
|
63
|
+
handle(request: StandardLazyRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
64
|
+
}
|
65
|
+
|
66
|
+
interface HandlerPlugin<TContext extends Context> {
|
67
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
68
|
+
}
|
69
|
+
declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
70
|
+
private readonly plugins;
|
71
|
+
constructor(plugins?: HandlerPlugin<TContext>[]);
|
72
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
73
|
+
}
|
74
|
+
|
75
|
+
export { CompositePlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerInterceptorOptions as a, type StandardHandlerOptions as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
|