@orpc/openapi 0.35.1 → 0.36.0

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.
@@ -223,7 +223,7 @@ function parsePath(path) {
223
223
 
224
224
  // src/adapters/standard/openapi-codec.ts
225
225
  import { fallbackContractConfig } from "@orpc/contract";
226
- import { isPlainObject as isPlainObject2, once } from "@orpc/shared";
226
+ import { isPlainObject as isPlainObject2 } from "@orpc/shared";
227
227
 
228
228
  // src/adapters/standard/openapi-serializer.ts
229
229
  import { findDeepMatches } from "@orpc/shared";
@@ -261,54 +261,43 @@ var OpenAPISerializer = class {
261
261
  }
262
262
  };
263
263
 
264
- // src/adapters/standard/schema-coercer.ts
265
- var CompositeSchemaCoercer = class {
266
- constructor(coercers) {
267
- this.coercers = coercers;
268
- }
269
- coerce(schema, value) {
270
- let current = value;
271
- for (const coercer of this.coercers) {
272
- current = coercer.coerce(schema, current);
273
- }
274
- return current;
275
- }
276
- };
277
-
278
264
  // src/adapters/standard/openapi-codec.ts
279
265
  var OpenAPICodec = class {
280
266
  serializer;
281
- compositeSchemaCoercer;
282
267
  constructor(options) {
283
268
  this.serializer = options?.serializer ?? new OpenAPISerializer();
284
- this.compositeSchemaCoercer = new CompositeSchemaCoercer(options?.schemaCoercers ?? []);
285
269
  }
286
270
  async decode(request, params, procedure) {
287
271
  const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
288
272
  if (inputStructure === "compact") {
289
273
  const data = request.method === "GET" ? this.serializer.deserialize(request.url.searchParams) : this.serializer.deserialize(await request.body());
290
274
  if (data === void 0) {
291
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, params);
275
+ return params;
292
276
  }
293
277
  if (isPlainObject2(data)) {
294
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
278
+ return {
295
279
  ...params,
296
280
  ...data
297
- });
281
+ };
298
282
  }
299
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, data);
283
+ return data;
300
284
  }
301
- const query = once(() => {
285
+ const deserializeSearchParams = () => {
302
286
  return this.serializer.deserialize(request.url.searchParams);
303
- });
304
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
287
+ };
288
+ return {
305
289
  params,
306
290
  get query() {
307
- return query();
291
+ const value = deserializeSearchParams();
292
+ Object.defineProperty(this, "query", { value, writable: true });
293
+ return value;
294
+ },
295
+ set query(value) {
296
+ Object.defineProperty(this, "query", { value, writable: true });
308
297
  },
309
298
  headers: request.headers,
310
299
  body: this.serializer.deserialize(await request.body())
311
- });
300
+ };
312
301
  }
313
302
  encode(output, procedure) {
314
303
  const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
@@ -414,7 +403,8 @@ var OpenAPIMatcher = class {
414
403
  return {
415
404
  path: match.data.path,
416
405
  procedure: match.data.procedure,
417
- params: match.params
406
+ params: match.params ? { ...match.params } : void 0
407
+ // normalize params to be a plain object
418
408
  };
419
409
  }
420
410
  };
@@ -425,8 +415,7 @@ function convertOpenAPIPathToRouterPath(path) {
425
415
  export {
426
416
  bracket_notation_exports,
427
417
  OpenAPISerializer,
428
- CompositeSchemaCoercer,
429
418
  OpenAPICodec,
430
419
  OpenAPIMatcher
431
420
  };
432
- //# sourceMappingURL=chunk-M5HOHBLW.js.map
421
+ //# sourceMappingURL=chunk-44Q55FOB.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPICodec,
3
3
  OpenAPIMatcher
4
- } from "./chunk-M5HOHBLW.js";
4
+ } from "./chunk-44Q55FOB.js";
5
5
 
6
6
  // src/adapters/fetch/openapi-handler.ts
7
7
  import { fetchRequestToStandardRequest, standardResponseToFetchResponse } from "@orpc/server/fetch";
@@ -29,4 +29,4 @@ var OpenAPIHandler = class {
29
29
  export {
30
30
  OpenAPIHandler
31
31
  };
32
- //# sourceMappingURL=chunk-HQ34JZI7.js.map
32
+ //# sourceMappingURL=chunk-WBGO55OM.js.map
package/dist/fetch.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
3
+ } from "./chunk-WBGO55OM.js";
4
+ import "./chunk-44Q55FOB.js";
5
5
  import "./chunk-BHJYKXQL.js";
6
6
  export {
7
7
  OpenAPIHandler
package/dist/hono.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
3
+ } from "./chunk-WBGO55OM.js";
4
+ import "./chunk-44Q55FOB.js";
5
5
  import "./chunk-BHJYKXQL.js";
6
6
  export {
7
7
  OpenAPIHandler
package/dist/next.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
3
+ } from "./chunk-WBGO55OM.js";
4
+ import "./chunk-44Q55FOB.js";
5
5
  import "./chunk-BHJYKXQL.js";
6
6
  export {
7
7
  OpenAPIHandler
package/dist/node.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPICodec,
3
3
  OpenAPIMatcher
4
- } from "./chunk-M5HOHBLW.js";
4
+ } from "./chunk-44Q55FOB.js";
5
5
  import "./chunk-BHJYKXQL.js";
6
6
 
7
7
  // src/adapters/node/openapi-handler.ts
@@ -3,5 +3,4 @@ export * from './openapi-codec';
3
3
  export * from './openapi-handler';
4
4
  export * from './openapi-matcher';
5
5
  export * from './openapi-serializer';
6
- export * from './schema-coercer';
7
6
  //# sourceMappingURL=index.d.ts.map
@@ -2,14 +2,11 @@ import type { AnyProcedure } from '@orpc/server';
2
2
  import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from '@orpc/server/standard';
3
3
  import { type ORPCError } from '@orpc/contract';
4
4
  import { OpenAPISerializer } from './openapi-serializer';
5
- import { type SchemaCoercer } from './schema-coercer';
6
5
  export interface OpenAPICodecOptions {
7
6
  serializer?: OpenAPISerializer;
8
- schemaCoercers?: SchemaCoercer[];
9
7
  }
10
8
  export declare class OpenAPICodec implements StandardCodec {
11
9
  private readonly serializer;
12
- private readonly compositeSchemaCoercer;
13
10
  constructor(options?: OpenAPICodecOptions);
14
11
  decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
15
12
  encode(output: unknown, procedure: AnyProcedure): StandardResponse;
package/dist/standard.js CHANGED
@@ -1,14 +1,12 @@
1
1
  import {
2
- CompositeSchemaCoercer,
3
2
  OpenAPICodec,
4
3
  OpenAPIMatcher,
5
4
  OpenAPISerializer,
6
5
  bracket_notation_exports
7
- } from "./chunk-M5HOHBLW.js";
6
+ } from "./chunk-44Q55FOB.js";
8
7
  import "./chunk-BHJYKXQL.js";
9
8
  export {
10
9
  bracket_notation_exports as BracketNotation,
11
- CompositeSchemaCoercer,
12
10
  OpenAPICodec,
13
11
  OpenAPIMatcher,
14
12
  OpenAPISerializer
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/openapi",
3
3
  "type": "module",
4
- "version": "0.35.1",
4
+ "version": "0.36.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -63,9 +63,9 @@
63
63
  "openapi3-ts": "^4.4.0",
64
64
  "rou3": "^0.5.1",
65
65
  "wildcard-match": "^5.1.3",
66
- "@orpc/contract": "0.35.1",
67
- "@orpc/server": "0.35.1",
68
- "@orpc/shared": "0.35.1"
66
+ "@orpc/contract": "0.36.0",
67
+ "@orpc/server": "0.36.0",
68
+ "@orpc/shared": "0.36.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@readme/openapi-parser": "^2.6.0",
@@ -1,10 +0,0 @@
1
- import type { Schema } from '@orpc/contract';
2
- export interface SchemaCoercer {
3
- coerce(schema: Schema, value: unknown): unknown;
4
- }
5
- export declare class CompositeSchemaCoercer implements SchemaCoercer {
6
- private readonly coercers;
7
- constructor(coercers: SchemaCoercer[]);
8
- coerce(schema: Schema, value: unknown): unknown;
9
- }
10
- //# sourceMappingURL=schema-coercer.d.ts.map