@orpc/server 0.0.0-next.93e7a4c → 0.0.0-next.93fa264

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 (80) hide show
  1. package/README.md +126 -0
  2. package/dist/adapters/aws-lambda/index.d.mts +45 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +45 -0
  4. package/dist/adapters/aws-lambda/index.mjs +41 -0
  5. package/dist/adapters/bun-ws/index.d.mts +35 -0
  6. package/dist/adapters/bun-ws/index.d.ts +35 -0
  7. package/dist/adapters/bun-ws/index.mjs +46 -0
  8. package/dist/adapters/crossws/index.d.mts +30 -0
  9. package/dist/adapters/crossws/index.d.ts +30 -0
  10. package/dist/adapters/crossws/index.mjs +46 -0
  11. package/dist/adapters/fetch/index.d.mts +78 -0
  12. package/dist/adapters/fetch/index.d.ts +78 -0
  13. package/dist/adapters/fetch/index.mjs +110 -0
  14. package/dist/adapters/message-port/index.d.mts +28 -0
  15. package/dist/adapters/message-port/index.d.ts +28 -0
  16. package/dist/adapters/message-port/index.mjs +41 -0
  17. package/dist/adapters/node/index.d.mts +77 -0
  18. package/dist/adapters/node/index.d.ts +77 -0
  19. package/dist/adapters/node/index.mjs +95 -0
  20. package/dist/adapters/standard/index.d.mts +26 -0
  21. package/dist/adapters/standard/index.d.ts +26 -0
  22. package/dist/adapters/standard/index.mjs +7 -0
  23. package/dist/adapters/websocket/index.d.mts +51 -0
  24. package/dist/adapters/websocket/index.d.ts +51 -0
  25. package/dist/adapters/websocket/index.mjs +69 -0
  26. package/dist/adapters/ws/index.d.mts +28 -0
  27. package/dist/adapters/ws/index.d.ts +28 -0
  28. package/dist/adapters/ws/index.mjs +39 -0
  29. package/dist/hibernation/index.d.mts +44 -0
  30. package/dist/hibernation/index.d.ts +44 -0
  31. package/dist/hibernation/index.mjs +65 -0
  32. package/dist/index.d.mts +834 -0
  33. package/dist/index.d.ts +834 -0
  34. package/dist/index.mjs +488 -0
  35. package/dist/plugins/index.d.mts +156 -0
  36. package/dist/plugins/index.d.ts +156 -0
  37. package/dist/plugins/index.mjs +253 -0
  38. package/dist/shared/server.-ACo36I0.d.ts +74 -0
  39. package/dist/shared/server.BPAWobQg.d.ts +12 -0
  40. package/dist/shared/server.BW-nUGgA.mjs +36 -0
  41. package/dist/shared/server.Bd52nNaH.d.mts +12 -0
  42. package/dist/shared/server.BliFSTnG.d.mts +10 -0
  43. package/dist/shared/server.CHvOkcM3.mjs +186 -0
  44. package/dist/shared/server.DD2C4ujN.d.mts +192 -0
  45. package/dist/shared/server.DD2C4ujN.d.ts +192 -0
  46. package/dist/shared/server.DG7Tamti.mjs +367 -0
  47. package/dist/shared/server.DZ5BIITo.mjs +9 -0
  48. package/dist/shared/server.Dq8xr7PQ.d.mts +74 -0
  49. package/dist/shared/server.IG2MjhrD.d.ts +10 -0
  50. package/package.json +82 -15
  51. package/dist/chunk-FN62GL22.js +0 -182
  52. package/dist/fetch.js +0 -286
  53. package/dist/index.js +0 -518
  54. package/dist/src/builder.d.ts +0 -35
  55. package/dist/src/fetch/composite-handler.d.ts +0 -8
  56. package/dist/src/fetch/index.d.ts +0 -6
  57. package/dist/src/fetch/orpc-handler.d.ts +0 -20
  58. package/dist/src/fetch/orpc-payload-codec.d.ts +0 -9
  59. package/dist/src/fetch/orpc-procedure-matcher.d.ts +0 -12
  60. package/dist/src/fetch/super-json.d.ts +0 -12
  61. package/dist/src/fetch/types.d.ts +0 -16
  62. package/dist/src/hidden.d.ts +0 -6
  63. package/dist/src/implementer-chainable.d.ts +0 -10
  64. package/dist/src/index.d.ts +0 -23
  65. package/dist/src/lazy-decorated.d.ts +0 -10
  66. package/dist/src/lazy-utils.d.ts +0 -4
  67. package/dist/src/lazy.d.ts +0 -18
  68. package/dist/src/middleware-decorated.d.ts +0 -8
  69. package/dist/src/middleware.d.ts +0 -23
  70. package/dist/src/procedure-builder.d.ts +0 -22
  71. package/dist/src/procedure-client.d.ts +0 -29
  72. package/dist/src/procedure-decorated.d.ts +0 -14
  73. package/dist/src/procedure-implementer.d.ts +0 -18
  74. package/dist/src/procedure.d.ts +0 -23
  75. package/dist/src/router-builder.d.ts +0 -29
  76. package/dist/src/router-client.d.ts +0 -25
  77. package/dist/src/router-implementer.d.ts +0 -21
  78. package/dist/src/router.d.ts +0 -16
  79. package/dist/src/types.d.ts +0 -12
  80. package/dist/src/utils.d.ts +0 -3
@@ -0,0 +1,367 @@
1
+ import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
2
+ import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
3
+ import { value, intercept } from '@orpc/shared';
4
+
5
+ const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
6
+ function lazy(loader, meta = {}) {
7
+ return {
8
+ [LAZY_SYMBOL]: {
9
+ loader,
10
+ meta
11
+ }
12
+ };
13
+ }
14
+ function isLazy(item) {
15
+ return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
16
+ }
17
+ function getLazyMeta(lazied) {
18
+ return lazied[LAZY_SYMBOL].meta;
19
+ }
20
+ function unlazy(lazied) {
21
+ return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
22
+ }
23
+
24
+ function isStartWithMiddlewares(middlewares, compare) {
25
+ if (compare.length > middlewares.length) {
26
+ return false;
27
+ }
28
+ for (let i = 0; i < middlewares.length; i++) {
29
+ if (compare[i] === void 0) {
30
+ return true;
31
+ }
32
+ if (middlewares[i] !== compare[i]) {
33
+ return false;
34
+ }
35
+ }
36
+ return true;
37
+ }
38
+ function mergeMiddlewares(first, second, options) {
39
+ if (options.dedupeLeading && isStartWithMiddlewares(second, first)) {
40
+ return second;
41
+ }
42
+ return [...first, ...second];
43
+ }
44
+ function addMiddleware(middlewares, addition) {
45
+ return [...middlewares, addition];
46
+ }
47
+
48
+ class Procedure {
49
+ /**
50
+ * This property holds the defined options.
51
+ */
52
+ "~orpc";
53
+ constructor(def) {
54
+ this["~orpc"] = def;
55
+ }
56
+ }
57
+ function isProcedure(item) {
58
+ if (item instanceof Procedure) {
59
+ return true;
60
+ }
61
+ return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
62
+ }
63
+
64
+ function mergeCurrentContext(context, other) {
65
+ return { ...context, ...other };
66
+ }
67
+
68
+ function createORPCErrorConstructorMap(errors) {
69
+ const proxy = new Proxy(errors, {
70
+ get(target, code) {
71
+ if (typeof code !== "string") {
72
+ return Reflect.get(target, code);
73
+ }
74
+ const item = (...[options]) => {
75
+ const config = errors[code];
76
+ return new ORPCError(code, {
77
+ defined: Boolean(config),
78
+ status: config?.status,
79
+ message: options?.message ?? config?.message,
80
+ data: options?.data,
81
+ cause: options?.cause
82
+ });
83
+ };
84
+ return item;
85
+ }
86
+ });
87
+ return proxy;
88
+ }
89
+ async function validateORPCError(map, error) {
90
+ const { code, status, message, data, cause, defined } = error;
91
+ const config = map?.[error.code];
92
+ if (!config || fallbackORPCErrorStatus(error.code, config.status) !== error.status) {
93
+ return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
94
+ }
95
+ if (!config.data) {
96
+ return defined ? error : new ORPCError(code, { defined: true, status, message, data, cause });
97
+ }
98
+ const validated = await config.data["~standard"].validate(error.data);
99
+ if (validated.issues) {
100
+ return defined ? new ORPCError(code, { defined: false, status, message, data, cause }) : error;
101
+ }
102
+ return new ORPCError(code, { defined: true, status, message, data: validated.value, cause });
103
+ }
104
+
105
+ function middlewareOutputFn(output) {
106
+ return { output, context: {} };
107
+ }
108
+
109
+ function createProcedureClient(lazyableProcedure, ...[options]) {
110
+ return async (...[input, callerOptions]) => {
111
+ const path = options?.path ?? [];
112
+ const { default: procedure } = await unlazy(lazyableProcedure);
113
+ const clientContext = callerOptions?.context ?? {};
114
+ const context = await value(options?.context ?? {}, clientContext);
115
+ const errors = createORPCErrorConstructorMap(procedure["~orpc"].errorMap);
116
+ try {
117
+ return await intercept(
118
+ options?.interceptors ?? [],
119
+ {
120
+ context,
121
+ input,
122
+ // input only optional when it undefinable so we can safely cast it
123
+ errors,
124
+ path,
125
+ procedure,
126
+ signal: callerOptions?.signal,
127
+ lastEventId: callerOptions?.lastEventId
128
+ },
129
+ (interceptorOptions) => executeProcedureInternal(interceptorOptions.procedure, interceptorOptions)
130
+ );
131
+ } catch (e) {
132
+ if (!(e instanceof ORPCError)) {
133
+ throw e;
134
+ }
135
+ const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
136
+ throw validated;
137
+ }
138
+ };
139
+ }
140
+ async function validateInput(procedure, input) {
141
+ const schema = procedure["~orpc"].inputSchema;
142
+ if (!schema) {
143
+ return input;
144
+ }
145
+ const result = await schema["~standard"].validate(input);
146
+ if (result.issues) {
147
+ throw new ORPCError("BAD_REQUEST", {
148
+ message: "Input validation failed",
149
+ data: {
150
+ issues: result.issues
151
+ },
152
+ cause: new ValidationError({ message: "Input validation failed", issues: result.issues })
153
+ });
154
+ }
155
+ return result.value;
156
+ }
157
+ async function validateOutput(procedure, output) {
158
+ const schema = procedure["~orpc"].outputSchema;
159
+ if (!schema) {
160
+ return output;
161
+ }
162
+ const result = await schema["~standard"].validate(output);
163
+ if (result.issues) {
164
+ throw new ORPCError("INTERNAL_SERVER_ERROR", {
165
+ message: "Output validation failed",
166
+ cause: new ValidationError({ message: "Output validation failed", issues: result.issues })
167
+ });
168
+ }
169
+ return result.value;
170
+ }
171
+ async function executeProcedureInternal(procedure, options) {
172
+ const middlewares = procedure["~orpc"].middlewares;
173
+ const inputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].inputValidationIndex), middlewares.length);
174
+ const outputValidationIndex = Math.min(Math.max(0, procedure["~orpc"].outputValidationIndex), middlewares.length);
175
+ const next = async (index, context, input) => {
176
+ let currentInput = input;
177
+ if (index === inputValidationIndex) {
178
+ currentInput = await validateInput(procedure, currentInput);
179
+ }
180
+ const mid = middlewares[index];
181
+ const output = mid ? (await mid({
182
+ ...options,
183
+ context,
184
+ next: async (...[nextOptions]) => {
185
+ const nextContext = nextOptions?.context ?? {};
186
+ return {
187
+ output: await next(index + 1, mergeCurrentContext(context, nextContext), currentInput),
188
+ context: nextContext
189
+ };
190
+ }
191
+ }, currentInput, middlewareOutputFn)).output : await procedure["~orpc"].handler({ ...options, context, input: currentInput });
192
+ if (index === outputValidationIndex) {
193
+ return await validateOutput(procedure, output);
194
+ }
195
+ return output;
196
+ };
197
+ return next(0, options.context, options.input);
198
+ }
199
+
200
+ const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
201
+ function setHiddenRouterContract(router, contract) {
202
+ return new Proxy(router, {
203
+ get(target, key) {
204
+ if (key === HIDDEN_ROUTER_CONTRACT_SYMBOL) {
205
+ return contract;
206
+ }
207
+ return Reflect.get(target, key);
208
+ }
209
+ });
210
+ }
211
+ function getHiddenRouterContract(router) {
212
+ return router[HIDDEN_ROUTER_CONTRACT_SYMBOL];
213
+ }
214
+
215
+ function getRouter(router, path) {
216
+ let current = router;
217
+ for (let i = 0; i < path.length; i++) {
218
+ const segment = path[i];
219
+ if (!current) {
220
+ return void 0;
221
+ }
222
+ if (isProcedure(current)) {
223
+ return void 0;
224
+ }
225
+ if (!isLazy(current)) {
226
+ current = current[segment];
227
+ continue;
228
+ }
229
+ const lazied = current;
230
+ const rest = path.slice(i);
231
+ return lazy(async () => {
232
+ const unwrapped = await unlazy(lazied);
233
+ const next = getRouter(unwrapped.default, rest);
234
+ return unlazy(next);
235
+ }, getLazyMeta(lazied));
236
+ }
237
+ return current;
238
+ }
239
+ function createAccessibleLazyRouter(lazied) {
240
+ const recursive = new Proxy(lazied, {
241
+ get(target, key) {
242
+ if (typeof key !== "string") {
243
+ return Reflect.get(target, key);
244
+ }
245
+ const next = getRouter(lazied, [key]);
246
+ return createAccessibleLazyRouter(next);
247
+ }
248
+ });
249
+ return recursive;
250
+ }
251
+ function enhanceRouter(router, options) {
252
+ if (isLazy(router)) {
253
+ const laziedMeta = getLazyMeta(router);
254
+ const enhancedPrefix = laziedMeta?.prefix ? mergePrefix(options.prefix, laziedMeta?.prefix) : options.prefix;
255
+ const enhanced2 = lazy(async () => {
256
+ const { default: unlaziedRouter } = await unlazy(router);
257
+ const enhanced3 = enhanceRouter(unlaziedRouter, options);
258
+ return unlazy(enhanced3);
259
+ }, {
260
+ ...laziedMeta,
261
+ prefix: enhancedPrefix
262
+ });
263
+ const accessible = createAccessibleLazyRouter(enhanced2);
264
+ return accessible;
265
+ }
266
+ if (isProcedure(router)) {
267
+ const newMiddlewares = mergeMiddlewares(options.middlewares, router["~orpc"].middlewares, { dedupeLeading: options.dedupeLeadingMiddlewares });
268
+ const newMiddlewareAdded = newMiddlewares.length - router["~orpc"].middlewares.length;
269
+ const enhanced2 = new Procedure({
270
+ ...router["~orpc"],
271
+ route: enhanceRoute(router["~orpc"].route, options),
272
+ errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
273
+ middlewares: newMiddlewares,
274
+ inputValidationIndex: router["~orpc"].inputValidationIndex + newMiddlewareAdded,
275
+ outputValidationIndex: router["~orpc"].outputValidationIndex + newMiddlewareAdded
276
+ });
277
+ return enhanced2;
278
+ }
279
+ const enhanced = {};
280
+ for (const key in router) {
281
+ enhanced[key] = enhanceRouter(router[key], options);
282
+ }
283
+ return enhanced;
284
+ }
285
+ function traverseContractProcedures(options, callback, lazyOptions = []) {
286
+ let currentRouter = options.router;
287
+ const hiddenContract = getHiddenRouterContract(options.router);
288
+ if (hiddenContract !== void 0) {
289
+ currentRouter = hiddenContract;
290
+ }
291
+ if (isLazy(currentRouter)) {
292
+ lazyOptions.push({
293
+ router: currentRouter,
294
+ path: options.path
295
+ });
296
+ } else if (isContractProcedure(currentRouter)) {
297
+ callback({
298
+ contract: currentRouter,
299
+ path: options.path
300
+ });
301
+ } else {
302
+ for (const key in currentRouter) {
303
+ traverseContractProcedures(
304
+ {
305
+ router: currentRouter[key],
306
+ path: [...options.path, key]
307
+ },
308
+ callback,
309
+ lazyOptions
310
+ );
311
+ }
312
+ }
313
+ return lazyOptions;
314
+ }
315
+ async function resolveContractProcedures(options, callback) {
316
+ const pending = [options];
317
+ for (const options2 of pending) {
318
+ const lazyOptions = traverseContractProcedures(options2, callback);
319
+ for (const options3 of lazyOptions) {
320
+ const { default: router } = await unlazy(options3.router);
321
+ pending.push({
322
+ router,
323
+ path: options3.path
324
+ });
325
+ }
326
+ }
327
+ }
328
+ async function unlazyRouter(router) {
329
+ if (isProcedure(router)) {
330
+ return router;
331
+ }
332
+ const unlazied = {};
333
+ for (const key in router) {
334
+ const item = router[key];
335
+ const { default: unlaziedRouter } = await unlazy(item);
336
+ unlazied[key] = await unlazyRouter(unlaziedRouter);
337
+ }
338
+ return unlazied;
339
+ }
340
+
341
+ function createAssertedLazyProcedure(lazied) {
342
+ const lazyProcedure = lazy(async () => {
343
+ const { default: maybeProcedure } = await unlazy(lazied);
344
+ if (!isProcedure(maybeProcedure)) {
345
+ throw new Error(`
346
+ Expected a lazy<procedure> but got lazy<unknown>.
347
+ This should be caught by TypeScript compilation.
348
+ Please report this issue if this makes you feel uncomfortable.
349
+ `);
350
+ }
351
+ return { default: maybeProcedure };
352
+ }, getLazyMeta(lazied));
353
+ return lazyProcedure;
354
+ }
355
+ function createContractedProcedure(procedure, contract) {
356
+ return new Procedure({
357
+ ...procedure["~orpc"],
358
+ errorMap: contract["~orpc"].errorMap,
359
+ route: contract["~orpc"].route,
360
+ meta: contract["~orpc"].meta
361
+ });
362
+ }
363
+ function call(procedure, input, ...rest) {
364
+ return createProcedureClient(procedure, ...rest)(input);
365
+ }
366
+
367
+ export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
@@ -0,0 +1,9 @@
1
+ function resolveFriendlyStandardHandleOptions(options) {
2
+ return {
3
+ ...options,
4
+ context: options.context ?? {}
5
+ // Context only optional if all fields are optional
6
+ };
7
+ }
8
+
9
+ export { resolveFriendlyStandardHandleOptions as r };
@@ -0,0 +1,74 @@
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta } from '@orpc/contract';
3
+ import { Interceptor } from '@orpc/shared';
4
+ import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
+ import { C as Context, R as Router, f as AnyRouter, h as AnyProcedure, F as ProcedureClientInterceptorOptions } from './server.DD2C4ujN.mjs';
6
+
7
+ interface StandardHandlerPlugin<T extends Context> {
8
+ order?: number;
9
+ init?(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
10
+ }
11
+ declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
12
+ protected readonly plugins: TPlugin[];
13
+ constructor(plugins?: readonly TPlugin[]);
14
+ init(options: StandardHandlerOptions<T>, router: Router<any, T>): void;
15
+ }
16
+
17
+ type StandardParams = Record<string, string>;
18
+ type StandardMatchResult = {
19
+ path: readonly string[];
20
+ procedure: AnyProcedure;
21
+ params?: StandardParams;
22
+ } | undefined;
23
+ interface StandardMatcher {
24
+ init(router: AnyRouter): void;
25
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
26
+ }
27
+ interface StandardCodec {
28
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
29
+ encodeError(error: ORPCError<any, any>): StandardResponse;
30
+ decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
31
+ }
32
+
33
+ interface StandardHandleOptions<T extends Context> {
34
+ prefix?: HTTPPath;
35
+ context: T;
36
+ }
37
+ type StandardHandleResult = {
38
+ matched: true;
39
+ response: StandardResponse;
40
+ } | {
41
+ matched: false;
42
+ response: undefined;
43
+ };
44
+ interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
45
+ request: StandardLazyRequest;
46
+ }
47
+ interface StandardHandlerOptions<TContext extends Context> {
48
+ plugins?: StandardHandlerPlugin<TContext>[];
49
+ /**
50
+ * Interceptors at the request level, helpful when you want catch errors
51
+ */
52
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
53
+ /**
54
+ * Interceptors at the root level, helpful when you want override the request/response
55
+ */
56
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
57
+ /**
58
+ *
59
+ * Interceptors for procedure client.
60
+ */
61
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
62
+ }
63
+ declare class StandardHandler<T extends Context> {
64
+ private readonly matcher;
65
+ private readonly codec;
66
+ private readonly interceptors;
67
+ private readonly clientInterceptors;
68
+ private readonly rootInterceptors;
69
+ constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
70
+ handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
71
+ }
72
+
73
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as i };
74
+ export type { StandardHandlerInterceptorOptions as S, StandardHandlerPlugin as a, StandardHandlerOptions as b, StandardCodec as c, StandardParams as d, StandardMatcher as e, StandardMatchResult as f, StandardHandleOptions as g, StandardHandleResult as h };
@@ -0,0 +1,10 @@
1
+ import { C as Context } from './server.DD2C4ujN.js';
2
+ import { g as StandardHandleOptions } from './server.-ACo36I0.js';
3
+
4
+ type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
+ context?: T;
6
+ } : {
7
+ context: T;
8
+ });
9
+
10
+ export type { FriendlyStandardHandleOptions as F };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.93e7a4c",
4
+ "version": "0.0.0-next.93fa264",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,33 +15,100 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
+ },
22
+ "./plugins": {
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
26
+ },
27
+ "./hibernation": {
28
+ "types": "./dist/hibernation/index.d.mts",
29
+ "import": "./dist/hibernation/index.mjs",
30
+ "default": "./dist/hibernation/index.mjs"
31
+ },
32
+ "./standard": {
33
+ "types": "./dist/adapters/standard/index.d.mts",
34
+ "import": "./dist/adapters/standard/index.mjs",
35
+ "default": "./dist/adapters/standard/index.mjs"
21
36
  },
22
37
  "./fetch": {
23
- "types": "./dist/src/fetch/index.d.ts",
24
- "import": "./dist/fetch.js",
25
- "default": "./dist/fetch.js"
38
+ "types": "./dist/adapters/fetch/index.d.mts",
39
+ "import": "./dist/adapters/fetch/index.mjs",
40
+ "default": "./dist/adapters/fetch/index.mjs"
41
+ },
42
+ "./node": {
43
+ "types": "./dist/adapters/node/index.d.mts",
44
+ "import": "./dist/adapters/node/index.mjs",
45
+ "default": "./dist/adapters/node/index.mjs"
46
+ },
47
+ "./aws-lambda": {
48
+ "types": "./dist/adapters/aws-lambda/index.d.mts",
49
+ "import": "./dist/adapters/aws-lambda/index.mjs",
50
+ "default": "./dist/adapters/aws-lambda/index.mjs"
51
+ },
52
+ "./websocket": {
53
+ "types": "./dist/adapters/websocket/index.d.mts",
54
+ "import": "./dist/adapters/websocket/index.mjs",
55
+ "default": "./dist/adapters/websocket/index.mjs"
56
+ },
57
+ "./crossws": {
58
+ "types": "./dist/adapters/crossws/index.d.mts",
59
+ "import": "./dist/adapters/crossws/index.mjs",
60
+ "default": "./dist/adapters/crossws/index.mjs"
26
61
  },
27
- "./🔒/*": {
28
- "types": "./dist/src/*.d.ts"
62
+ "./ws": {
63
+ "types": "./dist/adapters/ws/index.d.mts",
64
+ "import": "./dist/adapters/ws/index.mjs",
65
+ "default": "./dist/adapters/ws/index.mjs"
66
+ },
67
+ "./bun-ws": {
68
+ "types": "./dist/adapters/bun-ws/index.d.mts",
69
+ "import": "./dist/adapters/bun-ws/index.mjs",
70
+ "default": "./dist/adapters/bun-ws/index.mjs"
71
+ },
72
+ "./message-port": {
73
+ "types": "./dist/adapters/message-port/index.d.mts",
74
+ "import": "./dist/adapters/message-port/index.mjs",
75
+ "default": "./dist/adapters/message-port/index.mjs"
29
76
  }
30
77
  },
31
78
  "files": [
32
- "!**/*.map",
33
- "!**/*.tsbuildinfo",
34
79
  "dist"
35
80
  ],
81
+ "peerDependencies": {
82
+ "crossws": ">=0.3.4",
83
+ "ws": ">=8.18.1"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "crossws": {
87
+ "optional": true
88
+ },
89
+ "ws": {
90
+ "optional": true
91
+ }
92
+ },
36
93
  "dependencies": {
37
- "@orpc/contract": "0.0.0-next.93e7a4c",
38
- "@orpc/shared": "0.0.0-next.93e7a4c"
94
+ "@orpc/client": "0.0.0-next.93fa264",
95
+ "@orpc/contract": "0.0.0-next.93fa264",
96
+ "@orpc/shared": "0.0.0-next.93fa264",
97
+ "@orpc/standard-server": "0.0.0-next.93fa264",
98
+ "@orpc/standard-server-fetch": "0.0.0-next.93fa264",
99
+ "@orpc/standard-server-node": "0.0.0-next.93fa264",
100
+ "@orpc/standard-server-aws-lambda": "0.0.0-next.93fa264",
101
+ "@orpc/standard-server-peer": "0.0.0-next.93fa264"
39
102
  },
40
103
  "devDependencies": {
41
- "zod": "^3.24.1"
104
+ "@types/ws": "^8.18.1",
105
+ "crossws": "^0.4.1",
106
+ "next": "^15.3.0",
107
+ "supertest": "^7.1.0",
108
+ "ws": "^8.18.1"
42
109
  },
43
110
  "scripts": {
44
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --entry.fetch=src/fetch/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
111
+ "build": "unbuild",
45
112
  "build:watch": "pnpm run build --watch",
46
113
  "type:check": "tsc -b"
47
114
  }