@orpc/server 0.0.0-next.b42ba03 → 0.0.0-next.b45a533

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +120 -0
  2. package/dist/adapters/fetch/index.d.mts +26 -0
  3. package/dist/adapters/fetch/index.d.ts +26 -0
  4. package/dist/adapters/fetch/index.mjs +9 -0
  5. package/dist/adapters/hono/index.d.mts +19 -0
  6. package/dist/adapters/hono/index.d.ts +19 -0
  7. package/dist/{hono.js → adapters/hono/index.mjs} +11 -19
  8. package/dist/adapters/next/index.d.mts +26 -0
  9. package/dist/adapters/next/index.d.ts +26 -0
  10. package/dist/{next.js → adapters/next/index.mjs} +11 -19
  11. package/dist/adapters/node/index.d.mts +34 -0
  12. package/dist/adapters/node/index.d.ts +34 -0
  13. package/dist/adapters/node/index.mjs +31 -0
  14. package/dist/adapters/standard/index.d.mts +25 -0
  15. package/dist/adapters/standard/index.d.ts +25 -0
  16. package/dist/adapters/standard/index.mjs +6 -0
  17. package/dist/index.d.mts +278 -0
  18. package/dist/index.d.ts +278 -0
  19. package/dist/{index.js → index.mjs} +93 -151
  20. package/dist/plugins/index.d.mts +31 -0
  21. package/dist/plugins/index.d.ts +31 -0
  22. package/dist/{chunk-XFBAK67J.js → plugins/index.mjs} +18 -43
  23. package/dist/shared/server.3mOimouH.mjs +158 -0
  24. package/dist/{chunk-EDQKEHUX.js → shared/server.B_5ZADvP.mjs} +181 -195
  25. package/dist/shared/server.BgDZnmUZ.mjs +28 -0
  26. package/dist/shared/server.CL84X8p4.d.mts +75 -0
  27. package/dist/shared/server.DnmJuN02.d.mts +144 -0
  28. package/dist/shared/server.DnmJuN02.d.ts +144 -0
  29. package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
  30. package/dist/shared/server.hqPWnakL.d.ts +75 -0
  31. package/package.json +29 -31
  32. package/dist/chunk-2OH4QMZ4.js +0 -145
  33. package/dist/chunk-BFGSRNYZ.js +0 -319
  34. package/dist/fetch.js +0 -16
  35. package/dist/node.js +0 -170
  36. package/dist/plugins.js +0 -11
  37. package/dist/src/adapters/fetch/index.d.ts +0 -4
  38. package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -10
  39. package/dist/src/adapters/fetch/types.d.ts +0 -13
  40. package/dist/src/adapters/fetch/utils.d.ts +0 -5
  41. package/dist/src/adapters/hono/index.d.ts +0 -3
  42. package/dist/src/adapters/hono/middleware.d.ts +0 -13
  43. package/dist/src/adapters/next/index.d.ts +0 -3
  44. package/dist/src/adapters/next/serve.d.ts +0 -20
  45. package/dist/src/adapters/node/index.d.ts +0 -4
  46. package/dist/src/adapters/node/rpc-handler.d.ts +0 -10
  47. package/dist/src/adapters/node/types.d.ts +0 -21
  48. package/dist/src/adapters/node/utils.d.ts +0 -5
  49. package/dist/src/adapters/standard/handler.d.ts +0 -51
  50. package/dist/src/adapters/standard/index.d.ts +0 -7
  51. package/dist/src/adapters/standard/rpc-codec.d.ts +0 -15
  52. package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
  53. package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
  54. package/dist/src/adapters/standard/rpc-serializer.d.ts +0 -16
  55. package/dist/src/adapters/standard/types.d.ts +0 -44
  56. package/dist/src/builder-variants.d.ts +0 -74
  57. package/dist/src/builder.d.ts +0 -57
  58. package/dist/src/config.d.ts +0 -6
  59. package/dist/src/context.d.ts +0 -9
  60. package/dist/src/hidden.d.ts +0 -8
  61. package/dist/src/implementer-procedure.d.ts +0 -30
  62. package/dist/src/implementer-variants.d.ts +0 -17
  63. package/dist/src/implementer.d.ts +0 -28
  64. package/dist/src/index.d.ts +0 -23
  65. package/dist/src/lazy-utils.d.ts +0 -6
  66. package/dist/src/lazy.d.ts +0 -22
  67. package/dist/src/middleware-decorated.d.ts +0 -10
  68. package/dist/src/middleware-utils.d.ts +0 -5
  69. package/dist/src/middleware.d.ts +0 -37
  70. package/dist/src/plugins/base.d.ts +0 -13
  71. package/dist/src/plugins/cors.d.ts +0 -19
  72. package/dist/src/plugins/index.d.ts +0 -4
  73. package/dist/src/plugins/response-headers.d.ts +0 -10
  74. package/dist/src/procedure-client.d.ts +0 -31
  75. package/dist/src/procedure-decorated.d.ts +0 -21
  76. package/dist/src/procedure-utils.d.ts +0 -17
  77. package/dist/src/procedure.d.ts +0 -29
  78. package/dist/src/router-accessible-lazy.d.ts +0 -8
  79. package/dist/src/router-client.d.ts +0 -11
  80. package/dist/src/router.d.ts +0 -29
  81. package/dist/src/utils.d.ts +0 -24
  82. package/dist/standard.js +0 -17
@@ -1,35 +1,15 @@
1
- import {
2
- LAZY_LOADER_SYMBOL,
3
- Procedure,
4
- adaptRouter,
5
- addMiddleware,
6
- convertPathToHttpPath,
7
- createAccessibleLazyRouter,
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-EDQKEHUX.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
- // src/builder.ts
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)
@@ -50,10 +29,14 @@ function decorateMiddleware(middleware) {
50
29
  decorated.concat = (concatMiddleware, mapInput) => {
51
30
  const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
52
31
  const concatted = decorateMiddleware((options, input, output, ...rest) => {
53
- const next = async (...[nextOptions]) => {
54
- return mapped({ ...options, context: { ...nextOptions?.context, ...options.context } }, input, output, ...rest);
55
- };
56
- const merged = middleware({ ...options, next }, input, output, ...rest);
32
+ const merged = middleware({
33
+ ...options,
34
+ next: (...[nextOptions1]) => mapped({
35
+ ...options,
36
+ context: { ...options.context, ...nextOptions1?.context },
37
+ next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
38
+ }, input, output, ...rest)
39
+ }, input, output, ...rest);
57
40
  return merged;
58
41
  });
59
42
  return concatted;
@@ -61,30 +44,28 @@ function decorateMiddleware(middleware) {
61
44
  return decorated;
62
45
  }
63
46
 
64
- // src/procedure-decorated.ts
65
- import { mergeErrorMap, mergeMeta, mergeRoute } from "@orpc/contract";
66
- var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
47
+ class DecoratedProcedure extends Procedure {
67
48
  errors(errors) {
68
- return new _DecoratedProcedure({
49
+ return new DecoratedProcedure({
69
50
  ...this["~orpc"],
70
51
  errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
71
52
  });
72
53
  }
73
54
  meta(meta) {
74
- return new _DecoratedProcedure({
55
+ return new DecoratedProcedure({
75
56
  ...this["~orpc"],
76
57
  meta: mergeMeta(this["~orpc"].meta, meta)
77
58
  });
78
59
  }
79
60
  route(route) {
80
- return new _DecoratedProcedure({
61
+ return new DecoratedProcedure({
81
62
  ...this["~orpc"],
82
63
  route: mergeRoute(this["~orpc"].route, route)
83
64
  });
84
65
  }
85
66
  use(middleware, mapInput) {
86
67
  const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
87
- return new _DecoratedProcedure({
68
+ return new DecoratedProcedure({
88
69
  ...this["~orpc"],
89
70
  middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
90
71
  });
@@ -93,9 +74,13 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
93
74
  * Make this procedure callable (works like a function while still being a procedure).
94
75
  */
95
76
  callable(...rest) {
96
- return Object.assign(createProcedureClient(this, ...rest), {
97
- "~type": "Procedure",
98
- "~orpc": this["~orpc"]
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
+ }
99
84
  });
100
85
  }
101
86
  /**
@@ -104,10 +89,9 @@ var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
104
89
  actionable(...rest) {
105
90
  return this.callable(...rest);
106
91
  }
107
- };
92
+ }
108
93
 
109
- // src/builder.ts
110
- var Builder = class _Builder {
94
+ class Builder {
111
95
  "~orpc";
112
96
  constructor(def) {
113
97
  this["~orpc"] = def;
@@ -118,9 +102,10 @@ var Builder = class _Builder {
118
102
  $config(config) {
119
103
  const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
120
104
  const outputValidationCount = this["~orpc"].outputValidationIndex - fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex);
121
- return new _Builder({
105
+ return new Builder({
122
106
  ...this["~orpc"],
123
107
  config,
108
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares),
124
109
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", config.initialInputValidationIndex) + inputValidationCount,
125
110
  outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config.initialOutputValidationIndex) + outputValidationCount
126
111
  });
@@ -129,7 +114,7 @@ var Builder = class _Builder {
129
114
  * Reset initial context
130
115
  */
131
116
  $context() {
132
- return new _Builder({
117
+ return new Builder({
133
118
  ...this["~orpc"],
134
119
  middlewares: [],
135
120
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex),
@@ -140,7 +125,7 @@ var Builder = class _Builder {
140
125
  * Reset initial meta
141
126
  */
142
127
  $meta(initialMeta) {
143
- return new _Builder({
128
+ return new Builder({
144
129
  ...this["~orpc"],
145
130
  meta: initialMeta
146
131
  });
@@ -149,48 +134,54 @@ var Builder = class _Builder {
149
134
  * Reset initial route
150
135
  */
151
136
  $route(initialRoute) {
152
- return new _Builder({
137
+ return new Builder({
153
138
  ...this["~orpc"],
154
139
  route: initialRoute
155
140
  });
156
141
  }
142
+ $input(initialInputSchema) {
143
+ return new Builder({
144
+ ...this["~orpc"],
145
+ inputSchema: initialInputSchema
146
+ });
147
+ }
157
148
  middleware(middleware) {
158
149
  return decorateMiddleware(middleware);
159
150
  }
160
151
  errors(errors) {
161
- return new _Builder({
152
+ return new Builder({
162
153
  ...this["~orpc"],
163
- errorMap: mergeErrorMap2(this["~orpc"].errorMap, errors)
154
+ errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
164
155
  });
165
156
  }
166
157
  use(middleware, mapInput) {
167
158
  const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
168
- return new _Builder({
159
+ return new Builder({
169
160
  ...this["~orpc"],
170
161
  middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
171
162
  });
172
163
  }
173
164
  meta(meta) {
174
- return new _Builder({
165
+ return new Builder({
175
166
  ...this["~orpc"],
176
- meta: mergeMeta2(this["~orpc"].meta, meta)
167
+ meta: mergeMeta(this["~orpc"].meta, meta)
177
168
  });
178
169
  }
179
170
  route(route) {
180
- return new _Builder({
171
+ return new Builder({
181
172
  ...this["~orpc"],
182
- route: mergeRoute2(this["~orpc"].route, route)
173
+ route: mergeRoute(this["~orpc"].route, route)
183
174
  });
184
175
  }
185
176
  input(schema) {
186
- return new _Builder({
177
+ return new Builder({
187
178
  ...this["~orpc"],
188
179
  inputSchema: schema,
189
180
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex) + this["~orpc"].middlewares.length
190
181
  });
191
182
  }
192
183
  output(schema) {
193
- return new _Builder({
184
+ return new Builder({
194
185
  ...this["~orpc"],
195
186
  outputSchema: schema,
196
187
  outputValidationIndex: fallbackConfig("initialOutputValidationIndex", this["~orpc"].config.initialOutputValidationIndex) + this["~orpc"].middlewares.length
@@ -203,43 +194,39 @@ var Builder = class _Builder {
203
194
  });
204
195
  }
205
196
  prefix(prefix) {
206
- return new _Builder({
197
+ return new Builder({
207
198
  ...this["~orpc"],
208
199
  prefix: mergePrefix(this["~orpc"].prefix, prefix)
209
200
  });
210
201
  }
211
202
  tag(...tags) {
212
- return new _Builder({
203
+ return new Builder({
213
204
  ...this["~orpc"],
214
205
  tags: mergeTags(this["~orpc"].tags, tags)
215
206
  });
216
207
  }
217
208
  router(router) {
218
- return adaptRouter(router, this["~orpc"]);
209
+ return enhanceRouter(router, this["~orpc"]);
219
210
  }
220
211
  lazy(loader) {
221
- return adaptRouter(flatLazy(lazy(loader)), this["~orpc"]);
212
+ return enhanceRouter(lazy(loader), this["~orpc"]);
222
213
  }
223
- };
224
- var os = new Builder({
214
+ }
215
+ const os = new Builder({
225
216
  config: {},
226
217
  route: {},
227
218
  meta: {},
228
219
  errorMap: {},
229
- inputSchema: void 0,
230
- outputSchema: void 0,
231
220
  inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
232
221
  outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
233
- middlewares: []
222
+ middlewares: [],
223
+ dedupeLeadingMiddlewares: true
234
224
  });
235
225
 
236
- // src/context.ts
237
- function mergeContext(context, other) {
226
+ function mergeCurrentContext(context, other) {
238
227
  return { ...context, ...other };
239
228
  }
240
229
 
241
- // src/implementer.ts
242
- import { isContractProcedure } from "@orpc/contract";
243
230
  function implementerInternal(contract, config, middlewares) {
244
231
  if (isContractProcedure(contract)) {
245
232
  const impl2 = new Builder({
@@ -247,12 +234,16 @@ function implementerInternal(contract, config, middlewares) {
247
234
  config,
248
235
  middlewares,
249
236
  inputValidationIndex: fallbackConfig("initialInputValidationIndex", config?.initialInputValidationIndex) + middlewares.length,
250
- outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length
237
+ outputValidationIndex: fallbackConfig("initialOutputValidationIndex", config?.initialOutputValidationIndex) + middlewares.length,
238
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
251
239
  });
252
240
  return impl2;
253
241
  }
254
242
  const impl = new Proxy(contract, {
255
243
  get: (target, key) => {
244
+ if (typeof key !== "string") {
245
+ return Reflect.get(target, key);
246
+ }
256
247
  let method;
257
248
  if (key === "middleware") {
258
249
  method = (mid) => decorateMiddleware(mid);
@@ -266,23 +257,29 @@ function implementerInternal(contract, config, middlewares) {
266
257
  };
267
258
  } else if (key === "router") {
268
259
  method = (router) => {
269
- const adapted = adaptRouter(router, {
260
+ const adapted = enhanceRouter(router, {
270
261
  middlewares,
271
- errorMap: {}
262
+ errorMap: {},
263
+ prefix: void 0,
264
+ tags: void 0,
265
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
272
266
  });
273
- return setRouterContract(adapted, contract);
267
+ return setHiddenRouterContract(adapted, contract);
274
268
  };
275
269
  } else if (key === "lazy") {
276
270
  method = (loader) => {
277
- const adapted = adaptRouter(flatLazy(lazy(loader)), {
271
+ const adapted = enhanceRouter(lazy(loader), {
278
272
  middlewares,
279
- errorMap: {}
273
+ errorMap: {},
274
+ prefix: void 0,
275
+ tags: void 0,
276
+ dedupeLeadingMiddlewares: fallbackConfig("dedupeLeadingMiddlewares", config.dedupeLeadingMiddlewares)
280
277
  });
281
- return setRouterContract(adapted, contract);
278
+ return setHiddenRouterContract(adapted, contract);
282
279
  };
283
280
  }
284
- const next = Reflect.get(target, key);
285
- if (!next || typeof next !== "function" && typeof next !== "object") {
281
+ const next = getContractRouter(target, [key]);
282
+ if (!next) {
286
283
  return method ?? next;
287
284
  }
288
285
  const nextImpl = implementerInternal(next, config, middlewares);
@@ -309,44 +306,34 @@ function implement(contract, config = {}) {
309
306
  method = (config2) => implement(contract, config2);
310
307
  }
311
308
  const next = Reflect.get(target, key);
312
- if (!next || typeof next !== "function" && typeof next !== "object") {
313
- return method ?? next;
314
- }
315
- if (method) {
316
- return new Proxy(method, {
317
- get(_, key2) {
318
- return Reflect.get(next, key2);
319
- }
320
- });
309
+ if (!method || !next || typeof next !== "function" && typeof next !== "object") {
310
+ return method || next;
321
311
  }
322
- return next;
312
+ return new Proxy(method, {
313
+ get(_, key2) {
314
+ return Reflect.get(next, key2);
315
+ }
316
+ });
323
317
  }
324
318
  });
325
319
  return impl;
326
320
  }
327
321
 
328
- // src/procedure-utils.ts
329
- function call(procedure, input, ...rest) {
330
- return createProcedureClient(procedure, ...rest)(input);
331
- }
332
-
333
- // src/router-client.ts
334
- function createRouterClient(router, ...rest) {
322
+ function createRouterClient(router, ...[options]) {
335
323
  if (isProcedure(router)) {
336
- const caller = createProcedureClient(router, ...rest);
324
+ const caller = createProcedureClient(router, options);
337
325
  return caller;
338
326
  }
339
- const procedureCaller = isLazy(router) ? createProcedureClient(createLazyProcedureFormAnyLazy(router), ...rest) : {};
327
+ const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
340
328
  const recursive = new Proxy(procedureCaller, {
341
329
  get(target, key) {
342
330
  if (typeof key !== "string") {
343
331
  return Reflect.get(target, key);
344
332
  }
345
- const next = getRouterChild(router, key);
333
+ const next = getRouter(router, [key]);
346
334
  if (!next) {
347
335
  return Reflect.get(target, key);
348
336
  }
349
- const [options] = rest;
350
337
  return createRouterClient(next, {
351
338
  ...options,
352
339
  path: [...options?.path ?? [], key]
@@ -356,49 +343,4 @@ function createRouterClient(router, ...rest) {
356
343
  return recursive;
357
344
  }
358
345
 
359
- // src/index.ts
360
- import { isDefinedError, ORPCError, safe, type, ValidationError } from "@orpc/contract";
361
- import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
362
- export {
363
- Builder,
364
- DecoratedProcedure,
365
- LAZY_LOADER_SYMBOL,
366
- ORPCError,
367
- Procedure,
368
- ValidationError,
369
- adaptRouter,
370
- call,
371
- convertPathToHttpPath,
372
- createAccessibleLazyRouter,
373
- createContractedProcedure,
374
- createLazyProcedureFormAnyLazy,
375
- createProcedureClient,
376
- createRouterClient,
377
- decorateMiddleware,
378
- deepSetLazyRouterPrefix,
379
- eachAllContractProcedure,
380
- eachContractProcedure,
381
- fallbackConfig,
382
- flatLazy,
383
- getLazyRouterPrefix,
384
- getRouterChild,
385
- getRouterContract,
386
- implement,
387
- implementerInternal,
388
- isDefinedError,
389
- isLazy,
390
- isProcedure,
391
- lazy,
392
- mergeContext,
393
- middlewareOutputFn,
394
- onError,
395
- onFinish,
396
- onStart,
397
- onSuccess,
398
- os,
399
- safe,
400
- setRouterContract,
401
- type,
402
- unlazy
403
- };
404
- //# 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,40 +1,21 @@
1
- // src/plugins/base.ts
2
- var CompositePlugin = class {
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
- beforeCreateProcedureClient(clientOptions, interceptorOptions) {
12
- for (const plugin of this.plugins) {
13
- plugin.beforeCreateProcedureClient?.(clientOptions, interceptorOptions);
14
- }
15
- }
16
- };
1
+ export { C as CompositePlugin } from '../shared/server.Q6ZmnTgO.mjs';
2
+ import { value } from '@orpc/shared';
17
3
 
18
- // src/plugins/cors.ts
19
- import { value } from "@orpc/shared";
20
- var CORSPlugin = class {
4
+ class CORSPlugin {
21
5
  options;
22
- constructor(options) {
6
+ constructor(options = {}) {
23
7
  const defaults = {
24
- origin: "*",
8
+ origin: (origin) => origin,
25
9
  allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH"]
26
10
  };
27
- if (options?.credentials) {
28
- defaults.origin = (origin) => origin;
29
- }
30
11
  this.options = {
31
12
  ...defaults,
32
13
  ...options
33
14
  };
34
15
  }
35
16
  init(options) {
36
- options.interceptorsRoot ??= [];
37
- options.interceptorsRoot.unshift(async (interceptorOptions) => {
17
+ options.rootInterceptors ??= [];
18
+ options.rootInterceptors.unshift(async (interceptorOptions) => {
38
19
  if (interceptorOptions.request.method === "OPTIONS") {
39
20
  const resHeaders = {};
40
21
  if (this.options.maxAge !== void 0) {
@@ -60,7 +41,7 @@ var CORSPlugin = class {
60
41
  }
61
42
  return interceptorOptions.next();
62
43
  });
63
- options.interceptorsRoot.unshift(async (interceptorOptions) => {
44
+ options.rootInterceptors.unshift(async (interceptorOptions) => {
64
45
  const result = await interceptorOptions.next();
65
46
  if (!result.matched) {
66
47
  return result;
@@ -92,13 +73,12 @@ var CORSPlugin = class {
92
73
  return result;
93
74
  });
94
75
  }
95
- };
76
+ }
96
77
 
97
- // src/plugins/response-headers.ts
98
- var ResponseHeadersPlugin = class {
78
+ class ResponseHeadersPlugin {
99
79
  init(options) {
100
- options.interceptorsRoot ??= [];
101
- options.interceptorsRoot.push(async (interceptorOptions) => {
80
+ options.rootInterceptors ??= [];
81
+ options.rootInterceptors.push(async (interceptorOptions) => {
102
82
  const headers = new Headers();
103
83
  interceptorOptions.context.resHeaders = headers;
104
84
  const result = await interceptorOptions.next();
@@ -106,23 +86,18 @@ var ResponseHeadersPlugin = class {
106
86
  return result;
107
87
  }
108
88
  const responseHeaders = result.response.headers;
109
- for (const [key, value2] of headers) {
89
+ for (const [key, value] of headers) {
110
90
  if (Array.isArray(responseHeaders[key])) {
111
- responseHeaders[key].push(value2);
91
+ responseHeaders[key].push(value);
112
92
  } else if (responseHeaders[key] !== void 0) {
113
- responseHeaders[key] = [responseHeaders[key], value2];
93
+ responseHeaders[key] = [responseHeaders[key], value];
114
94
  } else {
115
- responseHeaders[key] = value2;
95
+ responseHeaders[key] = value;
116
96
  }
117
97
  }
118
98
  return result;
119
99
  });
120
100
  }
121
- };
101
+ }
122
102
 
123
- export {
124
- CompositePlugin,
125
- CORSPlugin,
126
- ResponseHeadersPlugin
127
- };
128
- //# sourceMappingURL=chunk-XFBAK67J.js.map
103
+ export { CORSPlugin, ResponseHeadersPlugin };