@temporary-name/server 1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d → 1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28

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 +3 -3
  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 +3 -3
  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 +3 -3
  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 +3 -3
  13. package/dist/index.d.mts +9 -69
  14. package/dist/index.d.ts +9 -69
  15. package/dist/index.mjs +40 -94
  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.Cp__uvkw.d.mts → server.B93y_8tj.d.mts} +2 -2
  20. package/dist/shared/{server.Bzrdopnd.d.ts → server.C3RuMHWl.d.mts} +29 -29
  21. package/dist/shared/{server.Bzrdopnd.d.mts → server.C3RuMHWl.d.ts} +29 -29
  22. package/dist/shared/{server.B9i6p26R.d.ts → server.CT1xhSmE.d.mts} +1 -2
  23. package/dist/shared/{server.B9VxPdeK.mjs → server.CqTex_jI.mjs} +57 -85
  24. package/dist/shared/{server.CYRDznXq.d.ts → server.D_fags8X.d.ts} +2 -2
  25. package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
  26. package/dist/shared/{server.C-j2WKJz.d.mts → server.cjcgLdr1.d.ts} +1 -2
  27. package/package.json +10 -10
  28. package/dist/shared/{server.DcfsPloY.mjs → server.BYYf0Wn6.mjs} +19 -19
@@ -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.DcfsPloY.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.Bzrdopnd.js';
3
- import { c as StandardHandleOptions } from './server.B9i6p26R.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.Bzrdopnd.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.5537ef74244620c125352bc9356d8c0ae804f10d",
4
+ "version": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
5
5
  "license": "MIT",
6
6
  "homepage": "https://www.stainless.com/",
7
7
  "repository": {
@@ -73,15 +73,15 @@
73
73
  "cookie": "^1.0.2",
74
74
  "rou3": "^0.7.7",
75
75
  "zod": "^4.1.12",
76
- "@temporary-name/contract": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
77
- "@temporary-name/interop": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
78
- "@temporary-name/shared": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
79
- "@temporary-name/standard-server": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
80
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
81
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
82
- "@temporary-name/standard-server-node": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
83
- "@temporary-name/json-schema": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d",
84
- "@temporary-name/zod": "1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d"
76
+ "@temporary-name/contract": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
77
+ "@temporary-name/interop": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
78
+ "@temporary-name/shared": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
79
+ "@temporary-name/standard-server": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
80
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
81
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
82
+ "@temporary-name/standard-server-node": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
83
+ "@temporary-name/zod": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28",
84
+ "@temporary-name/json-schema": "1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/supertest": "^6.0.3",
@@ -3,25 +3,6 @@ import { resolveMaybeOptionalOptions, ORPCError, toArray, value, runWithSpan, in
3
3
  import { HibernationEventIterator, mapEventIterator } from '@temporary-name/standard-server';
4
4
  import { safeParseAsync } from '@temporary-name/zod';
5
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
- }
24
-
25
6
  function mergeCurrentContext(context, other) {
26
7
  return { ...context, ...other };
27
8
  }
@@ -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
  }