@orpc/server 0.0.0-next.ac2a918 → 0.0.0-next.ac2c329

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 (81) hide show
  1. package/README.md +15 -2
  2. package/dist/adapters/fetch/index.d.mts +58 -0
  3. package/dist/adapters/fetch/index.d.ts +58 -0
  4. package/dist/adapters/fetch/index.mjs +105 -0
  5. package/dist/adapters/node/index.d.mts +57 -0
  6. package/dist/adapters/node/index.d.ts +57 -0
  7. package/dist/adapters/node/index.mjs +90 -0
  8. package/dist/adapters/standard/index.d.mts +26 -0
  9. package/dist/adapters/standard/index.d.ts +26 -0
  10. package/dist/adapters/standard/index.mjs +8 -0
  11. package/dist/index.d.mts +291 -0
  12. package/dist/index.d.ts +291 -0
  13. package/dist/{index.js → index.mjs} +107 -157
  14. package/dist/plugins/index.d.mts +124 -0
  15. package/dist/plugins/index.d.ts +124 -0
  16. package/dist/plugins/index.mjs +252 -0
  17. package/dist/shared/server.B5yVxwZh.d.mts +17 -0
  18. package/dist/shared/server.BVwwTHyO.mjs +9 -0
  19. package/dist/shared/server.BW-nUGgA.mjs +36 -0
  20. package/dist/shared/server.By38lRwX.d.ts +17 -0
  21. package/dist/{chunk-MHVECKBC.js → shared/server.C37gDhSZ.mjs} +167 -224
  22. package/dist/shared/server.ClO23hLW.d.mts +73 -0
  23. package/dist/shared/server.Cqam9L0P.d.mts +10 -0
  24. package/dist/shared/server.CuXY46Yy.d.ts +10 -0
  25. package/dist/shared/server.DFuJLDuo.mjs +190 -0
  26. package/dist/shared/server.DQJX4Gnf.d.mts +143 -0
  27. package/dist/shared/server.DQJX4Gnf.d.ts +143 -0
  28. package/dist/shared/server.DsVSuKTu.d.ts +73 -0
  29. package/package.json +24 -43
  30. package/dist/chunk-MBMXGUNI.js +0 -32
  31. package/dist/chunk-NTHCS5CK.js +0 -182
  32. package/dist/chunk-TXHKQO7N.js +0 -120
  33. package/dist/fetch.js +0 -10
  34. package/dist/hono.js +0 -34
  35. package/dist/next.js +0 -31
  36. package/dist/node.js +0 -31
  37. package/dist/plugins.js +0 -11
  38. package/dist/src/adapters/fetch/index.d.ts +0 -3
  39. package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
  40. package/dist/src/adapters/fetch/types.d.ts +0 -14
  41. package/dist/src/adapters/hono/index.d.ts +0 -3
  42. package/dist/src/adapters/hono/middleware.d.ts +0 -12
  43. package/dist/src/adapters/next/index.d.ts +0 -3
  44. package/dist/src/adapters/next/serve.d.ts +0 -19
  45. package/dist/src/adapters/node/index.d.ts +0 -3
  46. package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
  47. package/dist/src/adapters/node/types.d.ts +0 -22
  48. package/dist/src/adapters/standard/handler.d.ts +0 -53
  49. package/dist/src/adapters/standard/index.d.ts +0 -6
  50. package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
  51. package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
  52. package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
  53. package/dist/src/adapters/standard/types.d.ts +0 -21
  54. package/dist/src/builder-variants.d.ts +0 -75
  55. package/dist/src/builder.d.ts +0 -58
  56. package/dist/src/config.d.ts +0 -6
  57. package/dist/src/context.d.ts +0 -8
  58. package/dist/src/error.d.ts +0 -12
  59. package/dist/src/hidden.d.ts +0 -8
  60. package/dist/src/implementer-procedure.d.ts +0 -33
  61. package/dist/src/implementer-variants.d.ts +0 -18
  62. package/dist/src/implementer.d.ts +0 -29
  63. package/dist/src/index.d.ts +0 -25
  64. package/dist/src/lazy-utils.d.ts +0 -6
  65. package/dist/src/lazy.d.ts +0 -22
  66. package/dist/src/middleware-decorated.d.ts +0 -11
  67. package/dist/src/middleware-utils.d.ts +0 -5
  68. package/dist/src/middleware.d.ts +0 -38
  69. package/dist/src/plugins/base.d.ts +0 -11
  70. package/dist/src/plugins/cors.d.ts +0 -19
  71. package/dist/src/plugins/index.d.ts +0 -4
  72. package/dist/src/plugins/response-headers.d.ts +0 -10
  73. package/dist/src/procedure-client.d.ts +0 -33
  74. package/dist/src/procedure-decorated.d.ts +0 -24
  75. package/dist/src/procedure-utils.d.ts +0 -19
  76. package/dist/src/procedure.d.ts +0 -31
  77. package/dist/src/router-accessible-lazy.d.ts +0 -8
  78. package/dist/src/router-client.d.ts +0 -12
  79. package/dist/src/router.d.ts +0 -30
  80. package/dist/src/utils.d.ts +0 -24
  81. package/dist/standard.js +0 -13
@@ -1,35 +1,16 @@
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-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, 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
- // 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 = {
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
- // src/procedure-decorated.ts
69
- import { mergeErrorMap, mergeMeta, mergeRoute } from "@orpc/contract";
70
- var DecoratedProcedure = class _DecoratedProcedure extends Procedure {
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 _DecoratedProcedure({
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 _DecoratedProcedure({
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 _DecoratedProcedure({
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 _DecoratedProcedure({
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
- return Object.assign(createProcedureClient(this, ...rest), {
101
- "~type": "Procedure",
102
- "~orpc": this["~orpc"]
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 (the same as .callable, but the type is compatible with server action).
100
+ * Make this procedure compatible with server action.
107
101
  */
108
102
  actionable(...rest) {
109
- return this.callable(...rest);
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
- // src/builder.ts
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 _Builder({
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 _Builder({
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 _Builder({
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 _Builder({
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 _Builder({
173
+ return new Builder({
166
174
  ...this["~orpc"],
167
- errorMap: mergeErrorMap2(this["~orpc"].errorMap, errors)
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 _Builder({
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 _Builder({
186
+ return new Builder({
179
187
  ...this["~orpc"],
180
- meta: mergeMeta2(this["~orpc"].meta, meta)
188
+ meta: mergeMeta(this["~orpc"].meta, meta)
181
189
  });
182
190
  }
183
191
  route(route) {
184
- return new _Builder({
192
+ return new Builder({
185
193
  ...this["~orpc"],
186
- route: mergeRoute2(this["~orpc"].route, route)
194
+ route: mergeRoute(this["~orpc"].route, route)
187
195
  });
188
196
  }
189
197
  input(schema) {
190
- return new _Builder({
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 _Builder({
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 _Builder({
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 _Builder({
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 adaptRouter(router, this["~orpc"]);
230
+ return enhanceRouter(router, this["~orpc"]);
223
231
  }
224
232
  lazy(loader) {
225
- return adaptRouter(flatLazy(lazy(loader)), this["~orpc"]);
233
+ return enhanceRouter(lazy(loader), this["~orpc"]);
226
234
  }
227
- };
228
- var os = new Builder({
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 = adaptRouter(router, {
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 setRouterContract(adapted, contract);
284
+ return setHiddenRouterContract(adapted, contract);
278
285
  };
279
286
  } else if (key === "lazy") {
280
287
  method = (loader) => {
281
- const adapted = adaptRouter(flatLazy(lazy(loader)), {
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 setRouterContract(adapted, contract);
295
+ return setHiddenRouterContract(adapted, contract);
286
296
  };
287
297
  }
288
- const next = Reflect.get(target, key);
289
- if (!next || typeof next !== "function" && typeof next !== "object") {
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,101 +323,41 @@ 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 ?? next;
318
- }
319
- if (method) {
320
- return new Proxy(method, {
321
- get(_, key2) {
322
- return Reflect.get(next, key2);
323
- }
324
- });
326
+ if (!method || !next || typeof next !== "function" && typeof next !== "object") {
327
+ return method || next;
325
328
  }
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
- // src/procedure-utils.ts
333
- function call(procedure, input, ...rest) {
334
- return createProcedureClient(procedure, ...rest)(input);
335
- }
336
-
337
- // src/router-client.ts
338
339
  function createRouterClient(router, ...rest) {
339
340
  if (isProcedure(router)) {
340
341
  const caller = createProcedureClient(router, ...rest);
341
342
  return caller;
342
343
  }
343
- const procedureCaller = isLazy(router) ? createProcedureClient(createLazyProcedureFormAnyLazy(router), ...rest) : {};
344
+ const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), ...rest) : {};
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 = getRouterChild(router, key);
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
- ...options,
356
- path: [...options?.path ?? [], key]
355
+ ...rest[0],
356
+ path: [...rest[0]?.path ?? [], key]
357
357
  });
358
358
  }
359
359
  });
360
360
  return recursive;
361
361
  }
362
362
 
363
- // src/index.ts
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
363
+ export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
@@ -0,0 +1,124 @@
1
+ import { Value } from '@orpc/shared';
2
+ import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
+ import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.ClO23hLW.mjs';
5
+ import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DQJX4Gnf.mjs';
6
+ import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
+ import { ORPCError } from '@orpc/client';
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
+ order: number;
41
+ constructor(options?: BatchHandlerOptions<T>);
42
+ init(options: StandardHandlerOptions<T>): void;
43
+ }
44
+
45
+ interface CORSOptions<T extends Context> {
46
+ origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
47
+ timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
48
+ allowMethods?: readonly string[];
49
+ allowHeaders?: readonly string[];
50
+ maxAge?: number;
51
+ credentials?: boolean;
52
+ exposeHeaders?: readonly string[];
53
+ }
54
+ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
55
+ private readonly options;
56
+ order: number;
57
+ constructor(options?: CORSOptions<T>);
58
+ init(options: StandardHandlerOptions<T>): void;
59
+ }
60
+
61
+ interface ResponseHeadersPluginContext {
62
+ resHeaders?: Headers;
63
+ }
64
+ declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
65
+ init(options: StandardHandlerOptions<T>): void;
66
+ }
67
+
68
+ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
69
+ /**
70
+ * The name of the header to check.
71
+ *
72
+ * @default 'x-csrf-token'
73
+ */
74
+ headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
75
+ /**
76
+ * The value of the header to check.
77
+ *
78
+ * @default 'orpc'
79
+ *
80
+ */
81
+ headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
82
+ /**
83
+ * Exclude a procedure from the plugin.
84
+ *
85
+ * @default false
86
+ *
87
+ */
88
+ exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
89
+ /**
90
+ * The error thrown when the CSRF token is invalid.
91
+ *
92
+ * @default new ORPCError('CSRF_TOKEN_MISMATCH', {
93
+ * status: 403,
94
+ * message: 'Invalid CSRF token',
95
+ * })
96
+ */
97
+ error?: InstanceType<typeof ORPCError>;
98
+ }
99
+ declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
100
+ private readonly headerName;
101
+ private readonly headerValue;
102
+ private readonly exclude;
103
+ private readonly error;
104
+ constructor(options?: SimpleCsrfProtectionHandlerPluginOptions<T>);
105
+ order: number;
106
+ init(options: StandardHandlerOptions<T>): void;
107
+ }
108
+
109
+ interface StrictGetMethodPluginOptions {
110
+ /**
111
+ * The error thrown when a GET request is made to a procedure that doesn't allow GET.
112
+ *
113
+ * @default new ORPCError('METHOD_NOT_SUPPORTED')
114
+ */
115
+ error?: InstanceType<typeof ORPCError$1>;
116
+ }
117
+ declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
118
+ private readonly error;
119
+ order: number;
120
+ constructor(options?: StrictGetMethodPluginOptions);
121
+ init(options: StandardHandlerOptions<T>): void;
122
+ }
123
+
124
+ export { type BatchHandlerOptions, BatchHandlerPlugin, type CORSOptions, CORSPlugin, ResponseHeadersPlugin, type ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPlugin, type SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPlugin, type StrictGetMethodPluginOptions };