@temporary-name/server 1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93 → 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc

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 (28) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -3
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -3
  3. package/dist/adapters/aws-lambda/index.mjs +4 -6
  4. package/dist/adapters/fetch/index.d.mts +3 -3
  5. package/dist/adapters/fetch/index.d.ts +3 -3
  6. package/dist/adapters/fetch/index.mjs +4 -6
  7. package/dist/adapters/node/index.d.mts +3 -3
  8. package/dist/adapters/node/index.d.ts +3 -3
  9. package/dist/adapters/node/index.mjs +4 -6
  10. package/dist/adapters/standard/index.d.mts +14 -30
  11. package/dist/adapters/standard/index.d.ts +14 -30
  12. package/dist/adapters/standard/index.mjs +4 -6
  13. package/dist/index.d.mts +41 -282
  14. package/dist/index.d.ts +41 -282
  15. package/dist/index.mjs +102 -155
  16. package/dist/openapi/index.mjs +27 -61
  17. package/dist/plugins/index.d.mts +2 -2
  18. package/dist/plugins/index.d.ts +2 -2
  19. package/dist/shared/{server.BeuTpcmO.d.mts → server.B93y_8tj.d.mts} +2 -2
  20. package/dist/shared/{server.BKh8I1Ny.mjs → server.BYYf0Wn6.mjs} +36 -73
  21. package/dist/shared/{server.BKSOrA6h.d.mts → server.C3RuMHWl.d.mts} +30 -30
  22. package/dist/shared/{server.BKSOrA6h.d.ts → server.C3RuMHWl.d.ts} +30 -30
  23. package/dist/shared/{server.CQyYNJ1H.d.ts → server.CT1xhSmE.d.mts} +1 -2
  24. package/dist/shared/{server.DLsti1Pv.mjs → server.CqTex_jI.mjs} +57 -85
  25. package/dist/shared/{server.SLLuK6_v.d.ts → server.D_fags8X.d.ts} +2 -2
  26. package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
  27. package/dist/shared/{server.C1fnTLq0.d.mts → server.cjcgLdr1.d.ts} +1 -2
  28. package/package.json +10 -9
@@ -1,58 +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 { AsyncLocalStorage } from 'node:async_hooks';
5
- import 'zod';
6
- import * as z4 from 'zod/v4/core';
7
-
8
- const gatingContext = new AsyncLocalStorage();
9
- function withoutGatedFields(data, schema, isGateEnabled) {
10
- const filtered = { ...data };
11
- const gatedFields = getGatedFields(schema);
12
- for (const [fieldName, gate] of gatedFields) {
13
- if (!isGateEnabled(gate)) {
14
- delete filtered[fieldName];
15
- }
16
- }
17
- return filtered;
18
- }
19
- function getGatedFields(schema) {
20
- if (!schema || schema["~standard"].vendor !== "zod") {
21
- return [];
22
- }
23
- const gatedFields = [];
24
- const zodDef = schema._zod.def;
25
- if (zodDef.type === "object") {
26
- const shape = zodDef.shape;
27
- for (const fieldName in shape) {
28
- const fieldSchema = shape[fieldName];
29
- const gate = z4.globalRegistry.get(fieldSchema)?.gate;
30
- if (gate) {
31
- gatedFields.push([fieldName, gate]);
32
- }
33
- }
34
- }
35
- return gatedFields;
36
- }
37
-
38
- const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
39
- function lazy(loader, meta = {}) {
40
- return {
41
- [LAZY_SYMBOL]: {
42
- loader,
43
- meta
44
- }
45
- };
46
- }
47
- function isLazy(item) {
48
- return (typeof item === "object" || typeof item === "function") && item !== null && LAZY_SYMBOL in item;
49
- }
50
- function getLazyMeta(lazied) {
51
- return lazied[LAZY_SYMBOL].meta;
52
- }
53
- function unlazy(lazied) {
54
- return isLazy(lazied) ? lazied[LAZY_SYMBOL].loader() : Promise.resolve({ default: lazied });
55
- }
4
+ import { safeParseAsync } from '@temporary-name/zod';
56
5
 
57
6
  function mergeCurrentContext(context, other) {
58
7
  return { ...context, ...other };
@@ -81,6 +30,25 @@ function createORPCErrorConstructorMap(errors) {
81
30
  return proxy;
82
31
  }
83
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
+
84
52
  function middlewareOutputFn(output) {
85
53
  return { output, context: {} };
86
54
  }
@@ -147,37 +115,41 @@ async function validateInput(procedure, input) {
147
115
  return input;
148
116
  }
149
117
  return runWithSpan({ name: "validate_input" }, async () => {
150
- const result = await schema["~standard"].validate(input);
151
- if (result.issues) {
118
+ const result = await safeParseAsync(schema, input);
119
+ if (!result.success) {
152
120
  throw new ORPCError("BAD_REQUEST", {
153
121
  message: "Input validation failed",
154
122
  data: {
155
- issues: result.issues
123
+ issues: result.error.issues
156
124
  },
157
125
  cause: new ValidationError({
158
126
  message: "Input validation failed",
159
- issues: result.issues,
127
+ issues: result.error.issues,
160
128
  data: input
161
129
  })
162
130
  });
163
131
  }
164
- return result.value;
132
+ return result.data;
165
133
  });
166
134
  }
167
- async function validateOutput(schema, output) {
135
+ async function validateOutput(procedure, output) {
136
+ const schema = procedure["~orpc"].outputSchema;
137
+ if (!schema) {
138
+ return output;
139
+ }
168
140
  return runWithSpan({ name: "validate_output" }, async () => {
169
- const result = await schema["~standard"].validate(output);
170
- if (result.issues) {
141
+ const result = await safeParseAsync(schema, output);
142
+ if (!result.success) {
171
143
  throw new ORPCError("INTERNAL_SERVER_ERROR", {
172
144
  message: "Output validation failed",
173
145
  cause: new ValidationError({
174
146
  message: "Output validation failed",
175
- issues: result.issues,
147
+ issues: result.error.issues,
176
148
  data: output
177
149
  })
178
150
  });
179
151
  }
180
- return result.value;
152
+ return result.data;
181
153
  });
182
154
  }
183
155
  async function executeProcedureInternal(procedure, options) {
@@ -220,20 +192,11 @@ async function executeProcedureInternal(procedure, options) {
220
192
  () => procedure["~orpc"].handler({ ...options, context, input: currentInput })
221
193
  );
222
194
  if (index === outputValidationIndex) {
223
- const schema = procedure["~orpc"].outputSchema;
224
- if (!schema) {
225
- return output;
226
- }
227
- const validated = await validateOutput(schema, output);
228
- const isGateEnabled = gatingContext.getStore();
229
- if (!validated || !isGateEnabled) {
230
- return validated;
231
- }
232
- return withoutGatedFields(validated, schema, isGateEnabled);
195
+ return await validateOutput(procedure, output);
233
196
  }
234
197
  return output;
235
198
  };
236
199
  return next(0, options.context, options.input);
237
200
  }
238
201
 
239
- export { LAZY_SYMBOL as L, gatingContext as a, createORPCErrorConstructorMap as b, createProcedureClient as c, middlewareOutputFn as d, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
202
+ export { LAZY_SYMBOL as L, createORPCErrorConstructorMap as a, middlewareOutputFn as b, createProcedureClient as c, getLazyMeta as g, isLazy as i, lazy as l, mergeCurrentContext as m, unlazy as u };
@@ -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;
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
71
44
  '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
72
45
  constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
73
46
  }
74
- type AnyProcedure = Procedure<any, any, any, any, any, any>;
47
+ type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
75
48
  declare function isProcedure(item: unknown): item is AnyProcedure;
76
49
 
77
50
  type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
@@ -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;
@@ -71,7 +44,7 @@ declare class Procedure<TInitialContext extends Context, TCurrentContext extends
71
44
  '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
72
45
  constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
73
46
  }
74
- type AnyProcedure = Procedure<any, any, any, any, any, any>;
47
+ type AnyProcedure = Procedure<any, any, AnySchema, AnySchema, any, any>;
75
48
  declare function isProcedure(item: unknown): item is AnyProcedure;
76
49
 
77
50
  type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
@@ -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.BKSOrA6h.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
  }
@@ -1,67 +1,45 @@
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.BKh8I1Ny.mjs';
3
+ import { c as createProcedureClient } from './server.BYYf0Wn6.mjs';
4
4
  import { fallbackContractConfig } from '@temporary-name/contract';
5
- import { d as deserialize, s as serialize, a as standardizeHTTPPath } from './server.BEHw7Eyx.mjs';
5
+ import { d as deserialize, s as serialize, b as bracketNotationDeserialize, a as standardizeHTTPPath } from './server.Kxw442A9.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() {
9
+ async function decode(request, pathParams) {
10
+ const deserializeSearchParams = () => {
11
+ return bracketNotationDeserialize(Array.from(request.url.searchParams.entries()));
12
+ };
13
+ const data = request.method === "GET" ? deserializeSearchParams() : deserialize(await request.body());
14
+ if (data === void 0) {
15
+ return pathParams;
11
16
  }
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;
29
- }
30
- const deserializeSearchParams = () => {
31
- return deserialize(request.url.searchParams);
17
+ if (isObject(data)) {
18
+ return {
19
+ ...pathParams,
20
+ ...data
32
21
  };
22
+ }
23
+ return data;
24
+ }
25
+ function encode(output, procedure) {
26
+ const successStatus = fallbackContractConfig(
27
+ "defaultSuccessStatus",
28
+ procedure["~orpc"].route.successStatus
29
+ );
30
+ const outputStructure = fallbackContractConfig(
31
+ "defaultOutputStructure",
32
+ procedure["~orpc"].route.outputStructure
33
+ );
34
+ if (outputStructure === "compact") {
33
35
  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())
36
+ status: successStatus,
37
+ headers: {},
38
+ body: serialize(output)
45
39
  };
46
40
  }
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") {
57
- return {
58
- status: successStatus,
59
- headers: {},
60
- body: serialize(output)
61
- };
62
- }
63
- if (!this.#isDetailedOutput(output)) {
64
- throw new Error(`
41
+ if (!isDetailedOutput(output)) {
42
+ throw new Error(`
65
43
  Invalid "detailed" output structure:
66
44
  \u2022 Expected an object with optional properties:
67
45
  - status (number 200-399)
@@ -72,32 +50,31 @@ class StandardOpenAPICodec {
72
50
  Actual value:
73
51
  ${stringifyJSON(output)}
74
52
  `);
75
- }
76
- return {
77
- status: output.status ?? successStatus,
78
- headers: output.headers ?? {},
79
- body: serialize(output.body)
80
- };
81
53
  }
82
- encodeError(error) {
83
- return {
84
- status: error.status,
85
- headers: {},
86
- body: serialize(error.toJSON(), { outputFormat: "plain" })
87
- };
54
+ return {
55
+ status: output.status ?? successStatus,
56
+ headers: output.headers ?? {},
57
+ body: serialize(output.body)
58
+ };
59
+ }
60
+ function encodeError(error) {
61
+ return {
62
+ status: error.status,
63
+ headers: {},
64
+ body: serialize(error.toJSON(), { outputFormat: "plain" })
65
+ };
66
+ }
67
+ function isDetailedOutput(output) {
68
+ if (!isObject(output)) {
69
+ return false;
88
70
  }
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;
71
+ if (output.headers && !isObject(output.headers)) {
72
+ return false;
73
+ }
74
+ if (output.status !== void 0 && (typeof output.status !== "number" || !Number.isInteger(output.status) || isORPCErrorStatus(output.status))) {
75
+ return false;
100
76
  }
77
+ return true;
101
78
  }
102
79
 
103
80
  function resolveFriendlyStandardHandleOptions(options) {
@@ -204,10 +181,8 @@ class StandardHandler {
204
181
  clientInterceptors;
205
182
  rootInterceptors;
206
183
  matcher;
207
- codec;
208
184
  constructor(router, options) {
209
185
  this.matcher = new StandardOpenAPIMatcher();
210
- this.codec = new StandardOpenAPICodec();
211
186
  const plugins = new CompositeStandardHandlerPlugin(options.plugins);
212
187
  plugins.init(options, router);
213
188
  this.interceptors = toArray(options.interceptors);
@@ -242,10 +217,7 @@ class StandardHandler {
242
217
  span?.setAttribute("rpc.system", ORPC_NAME);
243
218
  span?.setAttribute("rpc.method", match.path.join("."));
244
219
  step = "decode_input";
245
- let input = await runWithSpan(
246
- { name: "decode_input" },
247
- () => this.codec.decode(request2, match.params, match.procedure)
248
- );
220
+ let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
249
221
  step = void 0;
250
222
  if (isAsyncIteratorObject(input)) {
251
223
  input = asyncIteratorWithSpan(
@@ -264,7 +236,7 @@ class StandardHandler {
264
236
  lastEventId: flattenHeader(request2.headers["last-event-id"])
265
237
  });
266
238
  step = void 0;
267
- const response = this.codec.encode(output, match.procedure);
239
+ const response = encode(output, match.procedure);
268
240
  return {
269
241
  matched: true,
270
242
  response
@@ -279,7 +251,7 @@ class StandardHandler {
279
251
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
280
252
  cause: e
281
253
  }) : toORPCError(e);
282
- const response = this.codec.encodeError(error);
254
+ const response = encodeError(error);
283
255
  return {
284
256
  matched: true,
285
257
  response
@@ -290,4 +262,4 @@ class StandardHandler {
290
262
  }
291
263
  }
292
264
 
293
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardOpenAPICodec as a, StandardOpenAPIMatcher as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
265
+ 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,6 +1,6 @@
1
1
  import { HTTPPath } from '@temporary-name/shared';
2
- import { C as Context } from './server.BKSOrA6h.js';
3
- import { c as StandardHandleOptions } from './server.CQyYNJ1H.js';
2
+ import { C as Context } from './server.C3RuMHWl.js';
3
+ import { c as StandardHandleOptions } from './server.cjcgLdr1.js';
4
4
 
5
5
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
6
6
  context?: T;
@@ -244,4 +244,4 @@ function getDynamicParams(path) {
244
244
  })) : void 0;
245
245
  }
246
246
 
247
- export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
247
+ export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
@@ -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.BKSOrA6h.mjs';
4
+ import { C as Context, R as Router, E as ProcedureClientInterceptorOptions } from './server.C3RuMHWl.js';
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@temporary-name/server",
3
3
  "type": "module",
4
- "version": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
4
+ "version": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -71,16 +71,17 @@
71
71
  },
72
72
  "dependencies": {
73
73
  "cookie": "^1.0.2",
74
- "@standard-schema/spec": "^1.0.0",
75
74
  "rou3": "^0.7.7",
76
75
  "zod": "^4.1.12",
77
- "@temporary-name/interop": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
78
- "@temporary-name/standard-server": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
79
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
80
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
81
- "@temporary-name/standard-server-node": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
82
- "@temporary-name/contract": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93",
83
- "@temporary-name/shared": "1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93"
76
+ "@temporary-name/interop": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
77
+ "@temporary-name/json-schema": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
78
+ "@temporary-name/shared": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
79
+ "@temporary-name/standard-server": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
80
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
81
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
82
+ "@temporary-name/standard-server-node": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
83
+ "@temporary-name/contract": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc",
84
+ "@temporary-name/zod": "1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc"
84
85
  },
85
86
  "devDependencies": {
86
87
  "@types/supertest": "^6.0.3",