@temporary-name/server 1.9.3-alpha.cf2fe368e72e6a6ab0ce041b812dbf8134f70b0b → 1.9.3-alpha.d9b25e999833b2b788712bccd5957f10e42416b0

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/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  import { onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
2
2
  export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
3
- import { isContractProcedure, mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, enhanceRoute, mergeTags, ContractProcedure, prefixRoute, getContractRouter } from '@temporary-name/contract';
3
+ import { isContractProcedure, mergePrefix, mergeErrorMap, enhanceRoute, mergeTags, ContractProcedure, mergeMeta, mergeRoute, prefixRoute, getContractRouter } from '@temporary-name/contract';
4
4
  export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
5
5
  import { SchemaClass, gatingContext } from '@temporary-name/zod';
6
- import { c as createProcedureClient, i as isLazy, g as getLazyMeta, l as lazy, u as unlazy } from './shared/server.NLSomL7m.mjs';
7
- export { L as LAZY_SYMBOL, a as createORPCErrorConstructorMap, m as mergeCurrentContext, b as middlewareOutputFn } from './shared/server.NLSomL7m.mjs';
6
+ import { c as createProcedureClient, i as isLazy, g as getLazyMeta, l as lazy, u as unlazy } from './shared/server.BYYf0Wn6.mjs';
7
+ export { L as LAZY_SYMBOL, a as createORPCErrorConstructorMap, m as mergeCurrentContext, b as middlewareOutputFn } from './shared/server.BYYf0Wn6.mjs';
8
8
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
9
9
 
10
10
  function isStartWithMiddlewares(middlewares, compare) {
@@ -31,42 +31,6 @@ function addMiddleware(middlewares, addition) {
31
31
  return [...middlewares, addition];
32
32
  }
33
33
 
34
- function decorateMiddleware(middleware) {
35
- const decorated = ((...args) => middleware(...args));
36
- decorated.mapInput = (mapInput) => {
37
- const mapped = decorateMiddleware(
38
- (options, input, ...rest) => middleware(options, mapInput(input), ...rest)
39
- );
40
- return mapped;
41
- };
42
- decorated.concat = (concatMiddleware, mapInput) => {
43
- const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
44
- const concatted = decorateMiddleware((options, input, output, ...rest) => {
45
- const merged = middleware(
46
- {
47
- ...options,
48
- next: (...[nextOptions1]) => mapped(
49
- {
50
- ...options,
51
- context: { ...options.context, ...nextOptions1?.context },
52
- next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
53
- },
54
- input,
55
- output,
56
- ...rest
57
- )
58
- },
59
- input,
60
- output,
61
- ...rest
62
- );
63
- return merged;
64
- });
65
- return concatted;
66
- };
67
- return decorated;
68
- }
69
-
70
34
  class Procedure {
71
35
  /**
72
36
  * This property holds the defined options.
@@ -80,55 +44,10 @@ function isProcedure(item) {
80
44
  if (item instanceof Procedure) {
81
45
  return true;
82
46
  }
83
- return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
47
+ return isContractProcedure(item) && "middlewares" in item["~orpc"] && "handler" in item["~orpc"];
84
48
  }
85
49
 
86
50
  class DecoratedProcedure extends Procedure {
87
- /**
88
- * Adds type-safe custom errors.
89
- * The provided errors are spared-merged with any existing errors.
90
- *
91
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
92
- */
93
- errors(errors) {
94
- return new DecoratedProcedure({
95
- ...this["~orpc"],
96
- errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
97
- });
98
- }
99
- /**
100
- * Sets or updates the metadata.
101
- * The provided metadata is spared-merged with any existing metadata.
102
- *
103
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
104
- */
105
- meta(meta) {
106
- return new DecoratedProcedure({
107
- ...this["~orpc"],
108
- meta: mergeMeta(this["~orpc"].meta, meta)
109
- });
110
- }
111
- /**
112
- * Sets or updates the route definition.
113
- * The provided route is spared-merged with any existing route.
114
- * This option is typically relevant when integrating with OpenAPI.
115
- *
116
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
117
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
118
- */
119
- route(route) {
120
- return new DecoratedProcedure({
121
- ...this["~orpc"],
122
- route: mergeRoute(this["~orpc"].route, route)
123
- });
124
- }
125
- use(middleware, mapInput) {
126
- const mapped = mapInput ? decorateMiddleware(middleware).mapInput(mapInput) : middleware;
127
- return new DecoratedProcedure({
128
- ...this["~orpc"],
129
- middlewares: addMiddleware(this["~orpc"].middlewares, mapped)
130
- });
131
- }
132
51
  /**
133
52
  * Make this procedure callable (works like a function while still being a procedure).
134
53
  *
@@ -430,15 +349,42 @@ class BuilderWithMiddlewares extends ProcedureBuilder {
430
349
  router(router) {
431
350
  return enhanceRouter(router, this["~orpc"]);
432
351
  }
433
- /**
434
- * Create a lazy router
435
- * And applies all of the previously defined options to the specified router.
436
- *
437
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
438
- */
439
- lazyRoute(loader) {
440
- return enhanceRouter(lazy(loader), this["~orpc"]);
441
- }
352
+ }
353
+
354
+ function decorateMiddleware(middleware) {
355
+ const decorated = ((...args) => middleware(...args));
356
+ decorated.mapInput = (mapInput) => {
357
+ const mapped = decorateMiddleware(
358
+ (options, input, ...rest) => middleware(options, mapInput(input), ...rest)
359
+ );
360
+ return mapped;
361
+ };
362
+ decorated.concat = (concatMiddleware, mapInput) => {
363
+ const mapped = mapInput ? decorateMiddleware(concatMiddleware).mapInput(mapInput) : concatMiddleware;
364
+ const concatted = decorateMiddleware((options, input, output, ...rest) => {
365
+ const merged = middleware(
366
+ {
367
+ ...options,
368
+ next: (...[nextOptions1]) => mapped(
369
+ {
370
+ ...options,
371
+ context: { ...options.context, ...nextOptions1?.context },
372
+ next: (...[nextOptions2]) => options.next({ context: { ...nextOptions1?.context, ...nextOptions2?.context } })
373
+ },
374
+ input,
375
+ output,
376
+ ...rest
377
+ )
378
+ },
379
+ input,
380
+ output,
381
+ ...rest
382
+ );
383
+ return merged;
384
+ });
385
+ return concatted;
386
+ };
387
+ return decorated;
442
388
  }
443
389
 
444
390
  class Builder extends BuilderWithMiddlewares {
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.C-j2WKJz.mjs';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.Bzrdopnd.mjs';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.CT1xhSmE.mjs';
5
+ import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.mjs';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable, ORPCError } from '@temporary-name/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@temporary-name/standard-server';
3
3
  import { BatchResponseBodyItem } from '@temporary-name/standard-server/batch';
4
- import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.B9i6p26R.js';
5
- import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.Bzrdopnd.js';
4
+ import { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.cjcgLdr1.js';
5
+ import { C as Context, E as ProcedureClientInterceptorOptions } from '../shared/server.C3RuMHWl.js';
6
6
  import { Meta } from '@temporary-name/contract';
7
7
 
8
8
  interface BatchHandlerOptions<T extends Context> {
@@ -1,6 +1,6 @@
1
1
  import { HTTPPath } from '@temporary-name/shared';
2
- import { C as Context } from './server.Bzrdopnd.mjs';
3
- import { c as StandardHandleOptions } from './server.C-j2WKJz.mjs';
2
+ import { C as Context } from './server.C3RuMHWl.mjs';
3
+ import { c as StandardHandleOptions } from './server.CT1xhSmE.mjs';
4
4
 
5
5
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
6
  context?: T;
@@ -1,26 +1,7 @@
1
1
  import { validateORPCError, ValidationError } from '@temporary-name/contract';
2
2
  import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@temporary-name/shared';
3
3
  import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
4
- import { safeDecodeAsync, safeEncodeAsync } from '@temporary-name/zod';
5
-
6
- const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
7
- function lazy(loader, meta = {}) {
8
- return {
9
- [LAZY_SYMBOL]: {
10
- loader,
11
- meta
12
- }
13
- };
14
- }
15
- function isLazy(item) {
16
- return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
17
- }
18
- function getLazyMeta(lazied) {
19
- return lazied[LAZY_SYMBOL].meta;
20
- }
21
- function unlazy(lazied) {
22
- return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
23
- }
4
+ import { safeParseAsync } from '@temporary-name/zod';
24
5
 
25
6
  function mergeCurrentContext(context, other) {
26
7
  return { ...context, ...other };
@@ -49,6 +30,25 @@ function createORPCErrorConstructorMap(errors) {
49
30
  return proxy;
50
31
  }
51
32
 
33
+ const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
34
+ function lazy(loader, meta = {}) {
35
+ return {
36
+ [LAZY_SYMBOL]: {
37
+ loader,
38
+ meta
39
+ }
40
+ };
41
+ }
42
+ function isLazy(item) {
43
+ return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
44
+ }
45
+ function getLazyMeta(lazied) {
46
+ return lazied[LAZY_SYMBOL].meta;
47
+ }
48
+ function unlazy(lazied) {
49
+ return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
50
+ }
51
+
52
52
  function middlewareOutputFn(output) {
53
53
  return { output, context: {} };
54
54
  }
@@ -115,7 +115,7 @@ async function validateInput(procedure, input) {
115
115
  return input;
116
116
  }
117
117
  return runWithSpan({ name: "validate_input" }, async () => {
118
- const result = await safeDecodeAsync(schema, input);
118
+ const result = await safeParseAsync(schema, input);
119
119
  if (!result.success) {
120
120
  throw new ORPCError("BAD_REQUEST", {
121
121
  message: "Input validation failed",
@@ -138,7 +138,7 @@ async function validateOutput(procedure, output) {
138
138
  return output;
139
139
  }
140
140
  return runWithSpan({ name: "validate_output" }, async () => {
141
- const result = await safeEncodeAsync(schema, output);
141
+ const result = await safeParseAsync(schema, output);
142
142
  if (!result.success) {
143
143
  throw new ORPCError("INTERNAL_SERVER_ERROR", {
144
144
  message: "Output validation failed",
@@ -1,67 +1,64 @@
1
1
  import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, value, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
2
2
  import { flattenHeader } from '@temporary-name/standard-server';
3
- import { c as createProcedureClient } from './server.NLSomL7m.mjs';
3
+ import { c as createProcedureClient } from './server.BYYf0Wn6.mjs';
4
4
  import { fallbackContractConfig } from '@temporary-name/contract';
5
5
  import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.BEHw7Eyx.mjs';
6
6
  import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
7
7
  import { createRouter, addRoute, findRoute } from 'rou3';
8
8
 
9
- class StandardOpenAPICodec {
10
- constructor() {
11
- }
12
- async decode(request, params, procedure) {
13
- const inputStructure = fallbackContractConfig(
14
- "defaultInputStructure",
15
- procedure["~orpc"].route.inputStructure
16
- );
17
- if (inputStructure === "compact") {
18
- const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
19
- if (data === void 0) {
20
- return params;
21
- }
22
- if (isObject(data)) {
23
- return {
24
- ...params,
25
- ...data
26
- };
27
- }
28
- return data;
9
+ async function decode(request, params, procedure) {
10
+ const inputStructure = fallbackContractConfig(
11
+ "defaultInputStructure",
12
+ procedure["~orpc"].route.inputStructure
13
+ );
14
+ if (inputStructure === "compact") {
15
+ const data = request.method === "GET" ? deserialize(request.url.searchParams) : deserialize(await request.body());
16
+ if (data === void 0) {
17
+ return params;
29
18
  }
30
- const deserializeSearchParams = () => {
31
- return deserialize(request.url.searchParams);
32
- };
33
- return {
34
- params,
35
- get query() {
36
- const value = deserializeSearchParams();
37
- Object.defineProperty(this, "query", { value, writable: true });
38
- return value;
39
- },
40
- set query(value) {
41
- Object.defineProperty(this, "query", { value, writable: true });
42
- },
43
- headers: request.headers,
44
- body: deserialize(await request.body())
45
- };
46
- }
47
- encode(output, procedure) {
48
- const successStatus = fallbackContractConfig(
49
- "defaultSuccessStatus",
50
- procedure["~orpc"].route.successStatus
51
- );
52
- const outputStructure = fallbackContractConfig(
53
- "defaultOutputStructure",
54
- procedure["~orpc"].route.outputStructure
55
- );
56
- if (outputStructure === "compact") {
19
+ if (isObject(data)) {
57
20
  return {
58
- status: successStatus,
59
- headers: {},
60
- body: serialize(output)
21
+ ...params,
22
+ ...data
61
23
  };
62
24
  }
63
- if (!this.#isDetailedOutput(output)) {
64
- throw new Error(`
25
+ return data;
26
+ }
27
+ const deserializeSearchParams = () => {
28
+ return deserialize(request.url.searchParams);
29
+ };
30
+ return {
31
+ params,
32
+ get query() {
33
+ const value = deserializeSearchParams();
34
+ Object.defineProperty(this, "query", { value, writable: true });
35
+ return value;
36
+ },
37
+ set query(value) {
38
+ Object.defineProperty(this, "query", { value, writable: true });
39
+ },
40
+ headers: request.headers,
41
+ body: deserialize(await request.body())
42
+ };
43
+ }
44
+ function encode(output, procedure) {
45
+ const successStatus = fallbackContractConfig(
46
+ "defaultSuccessStatus",
47
+ procedure["~orpc"].route.successStatus
48
+ );
49
+ const outputStructure = fallbackContractConfig(
50
+ "defaultOutputStructure",
51
+ procedure["~orpc"].route.outputStructure
52
+ );
53
+ if (outputStructure === "compact") {
54
+ return {
55
+ status: successStatus,
56
+ headers: {},
57
+ body: serialize(output)
58
+ };
59
+ }
60
+ if (!isDetailedOutput(output)) {
61
+ throw new Error(`
65
62
  Invalid "detailed" output structure:
66
63
  \u2022 Expected an object with optional properties:
67
64
  - status (number 200-399)
@@ -72,32 +69,31 @@ class StandardOpenAPICodec {
72
69
  Actual value:
73
70
  ${stringifyJSON(output)}
74
71
  `);
75
- }
76
- return {
77
- status: output.status ?? successStatus,
78
- headers: output.headers ?? {},
79
- body: serialize(output.body)
80
- };
81
72
  }
82
- encodeError(error) {
83
- return {
84
- status: error.status,
85
- headers: {},
86
- body: serialize(error.toJSON(), { outputFormat: "plain" })
87
- };
73
+ return {
74
+ status: output.status ?? successStatus,
75
+ headers: output.headers ?? {},
76
+ body: serialize(output.body)
77
+ };
78
+ }
79
+ function encodeError(error) {
80
+ return {
81
+ status: error.status,
82
+ headers: {},
83
+ body: serialize(error.toJSON(), { outputFormat: "plain" })
84
+ };
85
+ }
86
+ function isDetailedOutput(output) {
87
+ if (!isObject(output)) {
88
+ return false;
88
89
  }
89
- #isDetailedOutput(output) {
90
- if (!isObject(output)) {
91
- return false;
92
- }
93
- if (output.headers && !isObject(output.headers)) {
94
- return false;
95
- }
96
- if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
97
- return false;
98
- }
99
- return true;
90
+ if (output.headers && !isObject(output.headers)) {
91
+ return false;
92
+ }
93
+ if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
94
+ return false;
100
95
  }
96
+ return true;
101
97
  }
102
98
 
103
99
  function resolveFriendlyStandardHandleOptions(options) {
@@ -204,10 +200,8 @@ class StandardHandler {
204
200
  clientInterceptors;
205
201
  rootInterceptors;
206
202
  matcher;
207
- codec;
208
203
  constructor(router, options) {
209
204
  this.matcher = new StandardOpenAPIMatcher();
210
- this.codec = new StandardOpenAPICodec();
211
205
  const plugins = new CompositeStandardHandlerPlugin(options.plugins);
212
206
  plugins.init(options, router);
213
207
  this.interceptors = toArray(options.interceptors);
@@ -244,7 +238,7 @@ class StandardHandler {
244
238
  step = "decode_input";
245
239
  let input = await runWithSpan(
246
240
  { name: "decode_input" },
247
- () => this.codec.decode(request2, match.params, match.procedure)
241
+ () => decode(request2, match.params, match.procedure)
248
242
  );
249
243
  step = void 0;
250
244
  if (isAsyncIteratorObject(input)) {
@@ -264,7 +258,7 @@ class StandardHandler {
264
258
  lastEventId: flattenHeader(request2.headers["last-event-id"])
265
259
  });
266
260
  step = void 0;
267
- const response = this.codec.encode(output, match.procedure);
261
+ const response = encode(output, match.procedure);
268
262
  return {
269
263
  matched: true,
270
264
  response
@@ -279,7 +273,7 @@ class StandardHandler {
279
273
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
280
274
  cause: e
281
275
  }) : toORPCError(e);
282
- const response = this.codec.encodeError(error);
276
+ const response = encodeError(error);
283
277
  return {
284
278
  matched: true,
285
279
  response
@@ -290,4 +284,4 @@ class StandardHandler {
290
284
  }
291
285
  }
292
286
 
293
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardOpenAPICodec as a, StandardOpenAPIMatcher as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
287
+ export { CompositeStandardHandlerPlugin as C, StandardHandler as S, encodeError as a, StandardOpenAPIMatcher as b, decodeParams as c, decode as d, encode as e, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
@@ -1,5 +1,5 @@
1
1
  import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
2
- import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, HTTPPath, Promisable, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
2
+ import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
3
 
4
4
  type Context = Record<PropertyKey, any>;
5
5
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
13
13
  };
14
14
  declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
15
15
 
16
- declare const LAZY_SYMBOL: unique symbol;
17
- interface LazyMeta {
18
- prefix?: HTTPPath;
19
- }
20
- interface Lazy<T> {
21
- [LAZY_SYMBOL]: {
22
- loader: () => Promise<{
23
- default: T;
24
- }>;
25
- meta: LazyMeta;
26
- };
27
- }
28
- type Lazyable<T> = T | Lazy<T>;
29
- /**
30
- * Creates a lazy-loaded item.
31
- *
32
- * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
33
- */
34
- declare function lazy<T>(loader: () => Promise<{
35
- default: T;
36
- }>, meta?: LazyMeta): Lazy<T>;
37
- declare function isLazy(item: unknown): item is Lazy<any>;
38
- declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
39
- declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
40
- default: T extends Lazy<infer U> ? U : T;
41
- }>;
42
-
43
16
  interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
44
17
  context: TCurrentContext;
45
18
  input: TInput;
@@ -112,6 +85,33 @@ interface MapInputMiddleware<TInput, TMappedInput> {
112
85
  }
113
86
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
114
87
 
88
+ declare const LAZY_SYMBOL: unique symbol;
89
+ interface LazyMeta {
90
+ prefix?: HTTPPath;
91
+ }
92
+ interface Lazy<T> {
93
+ [LAZY_SYMBOL]: {
94
+ loader: () => Promise<{
95
+ default: T;
96
+ }>;
97
+ meta: LazyMeta;
98
+ };
99
+ }
100
+ type Lazyable<T> = T | Lazy<T>;
101
+ /**
102
+ * Creates a lazy-loaded item.
103
+ *
104
+ * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
+ */
106
+ declare function lazy<T>(loader: () => Promise<{
107
+ default: T;
108
+ }>, meta?: LazyMeta): Lazy<T>;
109
+ declare function isLazy(item: unknown): item is Lazy<any>;
110
+ declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
+ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
+ default: T extends Lazy<infer U> ? U : T;
113
+ }>;
114
+
115
115
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
116
116
  interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
117
117
  context: TInitialContext;
@@ -189,4 +189,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
189
189
  };
190
190
 
191
191
  export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
192
- export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
192
+ export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
@@ -1,5 +1,5 @@
1
1
  import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@temporary-name/contract';
2
- import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, HTTPPath, Promisable, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
2
+ import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
3
3
 
4
4
  type Context = Record<PropertyKey, any>;
5
5
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -13,33 +13,6 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
13
13
  };
14
14
  declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
15
15
 
16
- declare const LAZY_SYMBOL: unique symbol;
17
- interface LazyMeta {
18
- prefix?: HTTPPath;
19
- }
20
- interface Lazy<T> {
21
- [LAZY_SYMBOL]: {
22
- loader: () => Promise<{
23
- default: T;
24
- }>;
25
- meta: LazyMeta;
26
- };
27
- }
28
- type Lazyable<T> = T | Lazy<T>;
29
- /**
30
- * Creates a lazy-loaded item.
31
- *
32
- * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
33
- */
34
- declare function lazy<T>(loader: () => Promise<{
35
- default: T;
36
- }>, meta?: LazyMeta): Lazy<T>;
37
- declare function isLazy(item: unknown): item is Lazy<any>;
38
- declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
39
- declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
40
- default: T extends Lazy<infer U> ? U : T;
41
- }>;
42
-
43
16
  interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
44
17
  context: TCurrentContext;
45
18
  input: TInput;
@@ -112,6 +85,33 @@ interface MapInputMiddleware<TInput, TMappedInput> {
112
85
  }
113
86
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
114
87
 
88
+ declare const LAZY_SYMBOL: unique symbol;
89
+ interface LazyMeta {
90
+ prefix?: HTTPPath;
91
+ }
92
+ interface Lazy<T> {
93
+ [LAZY_SYMBOL]: {
94
+ loader: () => Promise<{
95
+ default: T;
96
+ }>;
97
+ meta: LazyMeta;
98
+ };
99
+ }
100
+ type Lazyable<T> = T | Lazy<T>;
101
+ /**
102
+ * Creates a lazy-loaded item.
103
+ *
104
+ * @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
105
+ */
106
+ declare function lazy<T>(loader: () => Promise<{
107
+ default: T;
108
+ }>, meta?: LazyMeta): Lazy<T>;
109
+ declare function isLazy(item: unknown): item is Lazy<any>;
110
+ declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
111
+ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
112
+ default: T extends Lazy<infer U> ? U : T;
113
+ }>;
114
+
115
115
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
116
116
  interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
117
117
  context: TInitialContext;
@@ -189,4 +189,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
189
189
  };
190
190
 
191
191
  export { isProcedure as D, createProcedureClient as F, Procedure as P, createORPCErrorConstructorMap as l, mergeCurrentContext as m, LAZY_SYMBOL as n, lazy as p, isLazy as q, getLazyMeta as r, unlazy as u, middlewareOutputFn as y };
192
- export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, Middleware as M, ORPCErrorConstructorMap as O, Router as R, MergedInitialContext as a, MergedCurrentContext as b, MapInputMiddleware as c, CreateProcedureClientOptions as d, ProcedureClient as e, AnyRouter as f, Lazy as g, AnyProcedure as h, ProcedureHandler as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
192
+ export type { AnyMiddleware as A, ProcedureDef as B, Context as C, ProcedureClientInterceptorOptions as E, InferRouterInitialContexts as G, InferRouterCurrentContexts as H, InferRouterInitialContext as I, InferRouterInputs as J, InferRouterOutputs as K, Lazyable as L, MergedInitialContext as M, ORPCErrorConstructorMap as O, Router as R, CreateProcedureClientOptions as a, ProcedureClient as b, AnyRouter as c, Lazy as d, AnyProcedure as e, Middleware as f, MergedCurrentContext as g, ProcedureHandler as h, MapInputMiddleware as i, ORPCErrorConstructorMapItemOptions as j, ORPCErrorConstructorMapItem as k, LazyMeta as o, MiddlewareResult as s, MiddlewareNextFnOptions as t, MiddlewareNextFn as v, MiddlewareOutputFn as w, MiddlewareOptions as x, ProcedureHandlerOptions as z };
@@ -1,7 +1,7 @@
1
1
  import { Meta } from '@temporary-name/contract';
2
2
  import { HTTPPath, Interceptor } from '@temporary-name/shared';
3
3
  import { StandardLazyRequest, StandardResponse } from '@temporary-name/standard-server';
4
- import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.Bzrdopnd.js';
4
+ import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.C3RuMHWl.mjs';
5
5
 
6
6
  interface StandardHandlerPlugin<T extends Context> {
7
7
  order?: number;
@@ -48,7 +48,6 @@ declare class StandardHandler<T extends Context> {
48
48
  private readonly clientInterceptors;
49
49
  private readonly rootInterceptors;
50
50
  private readonly matcher;
51
- private readonly codec;
52
51
  constructor(router: Router<any, T>, options: NoInfer<StandardHandlerOptions<T>>);
53
52
  handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
54
53
  }