@temporary-name/server 1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56 → 1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46

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 +46 -96
  14. package/dist/index.d.ts +46 -96
  15. package/dist/index.mjs +15 -215
  16. package/dist/openapi/index.mjs +30 -64
  17. package/dist/plugins/index.d.mts +2 -2
  18. package/dist/plugins/index.d.ts +2 -2
  19. package/dist/shared/{server.ChraIVaQ.d.mts → server.B-pKBQ0r.d.mts} +2 -2
  20. package/dist/shared/{server.8gkXYsTZ.d.ts → server.BQV-lt_s.d.ts} +2 -2
  21. package/dist/shared/{server.DcfsPloY.mjs → server.BdGbIyq8.mjs} +211 -17
  22. package/dist/shared/{server.B15EEOr0.d.ts → server.DAzElr6Q.d.ts} +1 -2
  23. package/dist/shared/{server.CZNLCQBm.d.mts → server.Do2Whl-h.d.mts} +114 -71
  24. package/dist/shared/{server.CZNLCQBm.d.ts → server.Do2Whl-h.d.ts} +114 -71
  25. package/dist/shared/{server.YXplw8TW.d.mts → server.KIlJQ8K_.d.mts} +1 -2
  26. package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
  27. package/dist/shared/{server.B9VxPdeK.mjs → server.SmOM3Fae.mjs} +58 -89
  28. package/package.json +10 -10
@@ -1,67 +1,45 @@
1
- import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, value, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
1
+ import { isObject, stringifyJSON, isORPCErrorStatus, tryDecodeURIComponent, 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.BdGbIyq8.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) {
@@ -121,9 +98,6 @@ class StandardOpenAPIMatcher {
121
98
  pendingRouters = [];
122
99
  init(router, path = []) {
123
100
  const laziedOptions = traverseContractProcedures({ router, path }, (traverseOptions) => {
124
- if (!value(true, traverseOptions)) {
125
- return;
126
- }
127
101
  const { path: path2, contract } = traverseOptions;
128
102
  const method = fallbackContractConfig("defaultMethod", contract["~orpc"].route.method);
129
103
  const httpPath = toRou3Pattern(contract["~orpc"].route.path ?? toHttpPath(path2));
@@ -204,10 +178,8 @@ class StandardHandler {
204
178
  clientInterceptors;
205
179
  rootInterceptors;
206
180
  matcher;
207
- codec;
208
181
  constructor(router, options) {
209
182
  this.matcher = new StandardOpenAPIMatcher();
210
- this.codec = new StandardOpenAPICodec();
211
183
  const plugins = new CompositeStandardHandlerPlugin(options.plugins);
212
184
  plugins.init(options, router);
213
185
  this.interceptors = toArray(options.interceptors);
@@ -242,10 +214,7 @@ class StandardHandler {
242
214
  span?.setAttribute("rpc.system", ORPC_NAME);
243
215
  span?.setAttribute("rpc.method", match.path.join("."));
244
216
  step = "decode_input";
245
- let input = await runWithSpan(
246
- { name: "decode_input" },
247
- () => this.codec.decode(request2, match.params, match.procedure)
248
- );
217
+ let input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
249
218
  step = void 0;
250
219
  if (isAsyncIteratorObject(input)) {
251
220
  input = asyncIteratorWithSpan(
@@ -264,7 +233,7 @@ class StandardHandler {
264
233
  lastEventId: flattenHeader(request2.headers["last-event-id"])
265
234
  });
266
235
  step = void 0;
267
- const response = this.codec.encode(output, match.procedure);
236
+ const response = encode(output, match.procedure);
268
237
  return {
269
238
  matched: true,
270
239
  response
@@ -279,7 +248,7 @@ class StandardHandler {
279
248
  message: `Malformed request. Ensure the request body is properly formatted and the 'Content-Type' header is set correctly.`,
280
249
  cause: e
281
250
  }) : toORPCError(e);
282
- const response = this.codec.encodeError(error);
251
+ const response = encodeError(error);
283
252
  return {
284
253
  matched: true,
285
254
  response
@@ -290,4 +259,4 @@ class StandardHandler {
290
259
  }
291
260
  }
292
261
 
293
- export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardOpenAPICodec as a, StandardOpenAPIMatcher as b, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
262
+ 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 };
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.d751d322a9d105467b863db2bab6037dd277fd56",
4
+ "version": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
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/interop": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
77
- "@temporary-name/shared": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
78
- "@temporary-name/contract": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
79
- "@temporary-name/standard-server": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
80
- "@temporary-name/standard-server-fetch": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
81
- "@temporary-name/zod": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
82
- "@temporary-name/standard-server-node": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
83
- "@temporary-name/json-schema": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56",
84
- "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.d751d322a9d105467b863db2bab6037dd277fd56"
76
+ "@temporary-name/contract": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
77
+ "@temporary-name/interop": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
78
+ "@temporary-name/json-schema": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
79
+ "@temporary-name/shared": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
80
+ "@temporary-name/standard-server": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
81
+ "@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
82
+ "@temporary-name/standard-server-fetch": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
83
+ "@temporary-name/standard-server-node": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46",
84
+ "@temporary-name/zod": "1.9.3-alpha.df53e70739ea63d3ba6cfa5052b30dae1e12de46"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@types/supertest": "^6.0.3",