@orpc/openapi 0.0.0-next.6acfc62 → 0.0.0-next.6affcc9

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.
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  OpenAPICodec,
3
3
  OpenAPIMatcher
4
- } from "./chunk-M5HOHBLW.js";
4
+ } from "./chunk-TOZPXKQC.js";
5
5
 
6
6
  // src/adapters/fetch/openapi-handler.ts
7
- import { fetchRequestToStandardRequest, standardResponseToFetchResponse } from "@orpc/server/fetch";
7
+ import { toFetchResponse, toStandardRequest } from "@orpc/server-standard-fetch";
8
8
  import { StandardHandler } from "@orpc/server/standard";
9
9
  var OpenAPIHandler = class {
10
10
  standardHandler;
@@ -14,14 +14,14 @@ var OpenAPIHandler = class {
14
14
  this.standardHandler = new StandardHandler(router, matcher, codec, options);
15
15
  }
16
16
  async handle(request, ...rest) {
17
- const standardRequest = fetchRequestToStandardRequest(request);
17
+ const standardRequest = toStandardRequest(request);
18
18
  const result = await this.standardHandler.handle(standardRequest, ...rest);
19
19
  if (!result.matched) {
20
20
  return result;
21
21
  }
22
22
  return {
23
23
  matched: true,
24
- response: standardResponseToFetchResponse(result.response)
24
+ response: toFetchResponse(result.response)
25
25
  };
26
26
  }
27
27
  };
@@ -29,4 +29,4 @@ var OpenAPIHandler = class {
29
29
  export {
30
30
  OpenAPIHandler
31
31
  };
32
- //# sourceMappingURL=chunk-HQ34JZI7.js.map
32
+ //# sourceMappingURL=chunk-5QMOOQSF.js.map
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/json-serializer.ts
8
- import { isPlainObject } from "@orpc/shared";
8
+ import { isObject } from "@orpc/shared";
9
9
  var JSONSerializer = class {
10
10
  serialize(payload) {
11
11
  if (payload instanceof Set)
@@ -26,7 +26,7 @@ var JSONSerializer = class {
26
26
  return payload.toString();
27
27
  if (payload instanceof URL)
28
28
  return payload.toString();
29
- if (!isPlainObject(payload))
29
+ if (!isObject(payload))
30
30
  return payload;
31
31
  return Object.keys(payload).reduce(
32
32
  (carry, key) => {
@@ -49,4 +49,4 @@ export {
49
49
  JSONSerializer,
50
50
  standardizeHTTPPath
51
51
  };
52
- //# sourceMappingURL=chunk-BHJYKXQL.js.map
52
+ //# sourceMappingURL=chunk-HC5PVG4R.js.map
@@ -2,7 +2,7 @@ import {
2
2
  JSONSerializer,
3
3
  __export,
4
4
  standardizeHTTPPath
5
- } from "./chunk-BHJYKXQL.js";
5
+ } from "./chunk-HC5PVG4R.js";
6
6
 
7
7
  // src/adapters/standard/bracket-notation.ts
8
8
  var bracket_notation_exports = {};
@@ -13,9 +13,9 @@ __export(bracket_notation_exports, {
13
13
  serialize: () => serialize,
14
14
  stringifyPath: () => stringifyPath
15
15
  });
16
- import { isPlainObject } from "@orpc/shared";
16
+ import { isObject } from "@orpc/shared";
17
17
  function serialize(payload, parentKey = "") {
18
- if (!Array.isArray(payload) && !isPlainObject(payload))
18
+ if (!Array.isArray(payload) && !isObject(payload))
19
19
  return [["", payload]];
20
20
  const result = [];
21
21
  function helper(value, path) {
@@ -23,7 +23,7 @@ function serialize(payload, parentKey = "") {
23
23
  value.forEach((item, index) => {
24
24
  helper(item, [...path, String(index)]);
25
25
  });
26
- } else if (isPlainObject(value)) {
26
+ } else if (isObject(value)) {
27
27
  for (const [key, val] of Object.entries(value)) {
28
28
  helper(val, [...path, key]);
29
29
  }
@@ -223,9 +223,11 @@ 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 { isObject as isObject2 } from "@orpc/shared";
227
227
 
228
228
  // src/adapters/standard/openapi-serializer.ts
229
+ import { mapEventIterator, ORPCError, toORPCError } from "@orpc/contract";
230
+ import { ErrorEvent, isAsyncIteratorObject } from "@orpc/server-standard";
229
231
  import { findDeepMatches } from "@orpc/shared";
230
232
  var OpenAPISerializer = class {
231
233
  jsonSerializer;
@@ -236,6 +238,23 @@ var OpenAPISerializer = class {
236
238
  if (data instanceof Blob || data === void 0) {
237
239
  return data;
238
240
  }
241
+ if (isAsyncIteratorObject(data)) {
242
+ return mapEventIterator(data, {
243
+ value: async (value) => this.jsonSerializer.serialize(value),
244
+ error: async (e) => {
245
+ if (e instanceof ErrorEvent) {
246
+ return new ErrorEvent({
247
+ data: this.jsonSerializer.serialize(e.data),
248
+ cause: e
249
+ });
250
+ }
251
+ return new ErrorEvent({
252
+ data: this.jsonSerializer.serialize(toORPCError(e).toJSON()),
253
+ cause: e
254
+ });
255
+ }
256
+ });
257
+ }
239
258
  const serializedJSON = this.jsonSerializer.serialize(data);
240
259
  const { values: blobs } = findDeepMatches((v) => v instanceof Blob, serializedJSON);
241
260
  if (blobs.length === 0) {
@@ -257,58 +276,58 @@ var OpenAPISerializer = class {
257
276
  if (serialized instanceof URLSearchParams || serialized instanceof FormData) {
258
277
  return deserialize([...serialized.entries()]);
259
278
  }
260
- return serialized;
261
- }
262
- };
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);
279
+ if (isAsyncIteratorObject(serialized)) {
280
+ return mapEventIterator(serialized, {
281
+ value: async (value) => value,
282
+ error: async (e) => {
283
+ if (e instanceof ErrorEvent && ORPCError.isValidJSON(e.data)) {
284
+ return ORPCError.fromJSON(e.data, { cause: e });
285
+ }
286
+ return e;
287
+ }
288
+ });
273
289
  }
274
- return current;
290
+ return serialized;
275
291
  }
276
292
  };
277
293
 
278
294
  // src/adapters/standard/openapi-codec.ts
279
295
  var OpenAPICodec = class {
280
296
  serializer;
281
- compositeSchemaCoercer;
282
297
  constructor(options) {
283
298
  this.serializer = options?.serializer ?? new OpenAPISerializer();
284
- this.compositeSchemaCoercer = new CompositeSchemaCoercer(options?.schemaCoercers ?? []);
285
299
  }
286
300
  async decode(request, params, procedure) {
287
301
  const inputStructure = fallbackContractConfig("defaultInputStructure", procedure["~orpc"].route.inputStructure);
288
302
  if (inputStructure === "compact") {
289
303
  const data = request.method === "GET" ? this.serializer.deserialize(request.url.searchParams) : this.serializer.deserialize(await request.body());
290
304
  if (data === void 0) {
291
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, params);
305
+ return params;
292
306
  }
293
- if (isPlainObject2(data)) {
294
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
307
+ if (isObject2(data)) {
308
+ return {
295
309
  ...params,
296
310
  ...data
297
- });
311
+ };
298
312
  }
299
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, data);
313
+ return data;
300
314
  }
301
- const query = once(() => {
315
+ const deserializeSearchParams = () => {
302
316
  return this.serializer.deserialize(request.url.searchParams);
303
- });
304
- return this.compositeSchemaCoercer.coerce(procedure["~orpc"].inputSchema, {
317
+ };
318
+ return {
305
319
  params,
306
320
  get query() {
307
- return query();
321
+ const value = deserializeSearchParams();
322
+ Object.defineProperty(this, "query", { value, writable: true });
323
+ return value;
324
+ },
325
+ set query(value) {
326
+ Object.defineProperty(this, "query", { value, writable: true });
308
327
  },
309
328
  headers: request.headers,
310
329
  body: this.serializer.deserialize(await request.body())
311
- });
330
+ };
312
331
  }
313
332
  encode(output, procedure) {
314
333
  const successStatus = fallbackContractConfig("defaultSuccessStatus", procedure["~orpc"].route.successStatus);
@@ -320,7 +339,7 @@ var OpenAPICodec = class {
320
339
  body: this.serializer.serialize(output)
321
340
  };
322
341
  }
323
- if (!isPlainObject2(output)) {
342
+ if (!isObject2(output)) {
324
343
  throw new Error(
325
344
  'Invalid output structure for "detailed" output. Expected format: { body: any, headers?: Record<string, string | string[] | undefined> }'
326
345
  );
@@ -425,8 +444,7 @@ function convertOpenAPIPathToRouterPath(path) {
425
444
  export {
426
445
  bracket_notation_exports,
427
446
  OpenAPISerializer,
428
- CompositeSchemaCoercer,
429
447
  OpenAPICodec,
430
448
  OpenAPIMatcher
431
449
  };
432
- //# sourceMappingURL=chunk-M5HOHBLW.js.map
450
+ //# sourceMappingURL=chunk-TOZPXKQC.js.map
package/dist/fetch.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
5
- import "./chunk-BHJYKXQL.js";
3
+ } from "./chunk-5QMOOQSF.js";
4
+ import "./chunk-TOZPXKQC.js";
5
+ import "./chunk-HC5PVG4R.js";
6
6
  export {
7
7
  OpenAPIHandler
8
8
  };
package/dist/hono.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
5
- import "./chunk-BHJYKXQL.js";
3
+ } from "./chunk-5QMOOQSF.js";
4
+ import "./chunk-TOZPXKQC.js";
5
+ import "./chunk-HC5PVG4R.js";
6
6
  export {
7
7
  OpenAPIHandler
8
8
  };
package/dist/index.js CHANGED
@@ -1,7 +1,53 @@
1
1
  import {
2
2
  JSONSerializer,
3
3
  standardizeHTTPPath
4
- } from "./chunk-BHJYKXQL.js";
4
+ } from "./chunk-HC5PVG4R.js";
5
+
6
+ // src/openapi-operation-extender.ts
7
+ import { isProcedure } from "@orpc/server";
8
+ var OPERATION_EXTENDER_SYMBOL = Symbol("ORPC_OPERATION_EXTENDER");
9
+ function setOperationExtender(o, extend) {
10
+ return new Proxy(o, {
11
+ get(target, prop, receiver) {
12
+ if (prop === OPERATION_EXTENDER_SYMBOL) {
13
+ return extend;
14
+ }
15
+ return Reflect.get(target, prop, receiver);
16
+ }
17
+ });
18
+ }
19
+ function getOperationExtender(o) {
20
+ return o[OPERATION_EXTENDER_SYMBOL];
21
+ }
22
+ function extendOperation(operation, procedure) {
23
+ const operationExtenders = [];
24
+ for (const errorItem of Object.values(procedure["~orpc"].errorMap)) {
25
+ const maybeExtender = getOperationExtender(errorItem);
26
+ if (maybeExtender) {
27
+ operationExtenders.push(maybeExtender);
28
+ }
29
+ }
30
+ if (isProcedure(procedure)) {
31
+ for (const middleware of procedure["~orpc"].middlewares) {
32
+ const maybeExtender = getOperationExtender(middleware);
33
+ if (maybeExtender) {
34
+ operationExtenders.push(maybeExtender);
35
+ }
36
+ }
37
+ }
38
+ let currentOperation = operation;
39
+ for (const extender of operationExtenders) {
40
+ if (typeof extender === "function") {
41
+ currentOperation = extender(currentOperation, procedure);
42
+ } else {
43
+ currentOperation = {
44
+ ...currentOperation,
45
+ ...extender
46
+ };
47
+ }
48
+ }
49
+ return currentOperation;
50
+ }
5
51
 
6
52
  // src/openapi.ts
7
53
  import { OpenApiBuilder } from "openapi3-ts/oas31";
@@ -34,7 +80,7 @@ var OpenAPIContentBuilder = class {
34
80
  };
35
81
 
36
82
  // src/openapi-generator.ts
37
- import { fallbackContractConfig as fallbackContractConfig2, fallbackORPCErrorStatus } from "@orpc/contract";
83
+ import { fallbackContractConfig as fallbackContractConfig2, fallbackORPCErrorStatus, getEventIteratorSchemaDetails } from "@orpc/contract";
38
84
  import { eachAllContractProcedure } from "@orpc/server";
39
85
  import { group } from "@orpc/shared";
40
86
 
@@ -183,14 +229,14 @@ var OpenAPIOutputStructureParser = class {
183
229
  };
184
230
 
185
231
  // src/openapi-parameters-builder.ts
186
- import { get, isPlainObject, omit } from "@orpc/shared";
232
+ import { get, isObject, omit } from "@orpc/shared";
187
233
  var OpenAPIParametersBuilder = class {
188
234
  build(paramIn, jsonSchema, options) {
189
235
  const parameters = [];
190
236
  for (const name in jsonSchema.properties) {
191
237
  const schema = jsonSchema.properties[name];
192
238
  const paramExamples = jsonSchema.examples?.filter((example) => {
193
- return isPlainObject(example) && name in example;
239
+ return isObject(example) && name in example;
194
240
  }).map((example) => {
195
241
  return example[name];
196
242
  });
@@ -251,7 +297,7 @@ var CompositeSchemaConverter = class {
251
297
  };
252
298
 
253
299
  // src/schema-utils.ts
254
- import { isPlainObject as isPlainObject2 } from "@orpc/shared";
300
+ import { isObject as isObject2 } from "@orpc/shared";
255
301
 
256
302
  // src/schema.ts
257
303
  import * as JSONSchema from "json-schema-typed/draft-2020-12";
@@ -313,7 +359,7 @@ var SchemaUtils = class {
313
359
  }, {});
314
360
  matched.required = schema.required?.filter((key) => separatedProperties.includes(key));
315
361
  matched.examples = schema.examples?.map((example) => {
316
- if (!isPlainObject2(example)) {
362
+ if (!isObject2(example)) {
317
363
  return example;
318
364
  }
319
365
  return Object.entries(example).reduce((acc, [key, value]) => {
@@ -329,7 +375,7 @@ var SchemaUtils = class {
329
375
  }, {});
330
376
  rest.required = schema.required?.filter((key) => !separatedProperties.includes(key));
331
377
  rest.examples = schema.examples?.map((example) => {
332
- if (!isPlainObject2(example)) {
378
+ if (!isObject2(example)) {
333
379
  return example;
334
380
  }
335
381
  return Object.entries(example).reduce((acc, [key, value]) => {
@@ -416,26 +462,123 @@ var OpenAPIGenerator = class {
416
462
  }
417
463
  const method = fallbackContractConfig2("defaultMethod", def.route?.method);
418
464
  const httpPath = def.route?.path ? standardizeHTTPPath(def.route?.path) : `/${path.map(encodeURIComponent).join("/")}`;
419
- const inputStructure = fallbackContractConfig2("defaultInputStructure", def.route?.inputStructure);
420
- const outputStructure = fallbackContractConfig2("defaultOutputStructure", def.route?.outputStructure);
421
- const { paramsSchema, querySchema, headersSchema, bodySchema } = this.inputStructureParser.parse(contract, inputStructure);
422
- const { headersSchema: resHeadersSchema, bodySchema: resBodySchema } = this.outputStructureParser.parse(contract, outputStructure);
423
- const params = paramsSchema ? this.parametersBuilder.build("path", paramsSchema, {
424
- required: true
425
- }) : [];
426
- const query = querySchema ? this.parametersBuilder.build("query", querySchema) : [];
427
- const headers = headersSchema ? this.parametersBuilder.build("header", headersSchema) : [];
428
- const parameters = [...params, ...query, ...headers];
429
- const requestBody = bodySchema !== void 0 ? {
430
- required: this.schemaUtils.isUndefinableSchema(bodySchema),
431
- content: this.contentBuilder.build(bodySchema)
432
- } : void 0;
433
- const responses = {};
434
- responses[fallbackContractConfig2("defaultSuccessStatus", def.route?.successStatus)] = {
435
- description: fallbackContractConfig2("defaultSuccessDescription", def.route?.successDescription),
436
- content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema) : void 0,
437
- headers: resHeadersSchema !== void 0 ? this.parametersBuilder.buildHeadersObject(resHeadersSchema) : void 0
438
- };
465
+ const { parameters, requestBody } = (() => {
466
+ const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(def.inputSchema);
467
+ if (eventIteratorSchemaDetails) {
468
+ const requestBody3 = {
469
+ required: true,
470
+ content: {
471
+ "text/event-stream": {
472
+ schema: {
473
+ oneOf: [
474
+ {
475
+ type: "object",
476
+ properties: {
477
+ event: { type: "string", const: "message" },
478
+ data: this.schemaConverter.convert(eventIteratorSchemaDetails.yields, { strategy: "input" }),
479
+ id: { type: "string" },
480
+ retry: { type: "number" }
481
+ },
482
+ required: ["event", "data"]
483
+ },
484
+ {
485
+ type: "object",
486
+ properties: {
487
+ event: { type: "string", const: "done" },
488
+ data: this.schemaConverter.convert(eventIteratorSchemaDetails.returns, { strategy: "input" }),
489
+ id: { type: "string" },
490
+ retry: { type: "number" }
491
+ },
492
+ required: ["event", "data"]
493
+ },
494
+ {
495
+ type: "object",
496
+ properties: {
497
+ event: { type: "string", const: "error" },
498
+ data: {},
499
+ id: { type: "string" },
500
+ retry: { type: "number" }
501
+ },
502
+ required: ["event", "data"]
503
+ }
504
+ ]
505
+ }
506
+ }
507
+ }
508
+ };
509
+ return { requestBody: requestBody3, parameters: [] };
510
+ }
511
+ const inputStructure = fallbackContractConfig2("defaultInputStructure", def.route?.inputStructure);
512
+ const { paramsSchema, querySchema, headersSchema, bodySchema } = this.inputStructureParser.parse(contract, inputStructure);
513
+ const params = paramsSchema ? this.parametersBuilder.build("path", paramsSchema, {
514
+ required: true
515
+ }) : [];
516
+ const query = querySchema ? this.parametersBuilder.build("query", querySchema) : [];
517
+ const headers = headersSchema ? this.parametersBuilder.build("header", headersSchema) : [];
518
+ const parameters2 = [...params, ...query, ...headers];
519
+ const requestBody2 = bodySchema !== void 0 ? {
520
+ required: this.schemaUtils.isUndefinableSchema(bodySchema),
521
+ content: this.contentBuilder.build(bodySchema)
522
+ } : void 0;
523
+ return { parameters: parameters2, requestBody: requestBody2 };
524
+ })();
525
+ const { responses } = (() => {
526
+ const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(def.outputSchema);
527
+ if (eventIteratorSchemaDetails) {
528
+ const responses3 = {};
529
+ responses3[fallbackContractConfig2("defaultSuccessStatus", def.route?.successStatus)] = {
530
+ description: fallbackContractConfig2("defaultSuccessDescription", def.route?.successDescription),
531
+ content: {
532
+ "text/event-stream": {
533
+ schema: {
534
+ oneOf: [
535
+ {
536
+ type: "object",
537
+ properties: {
538
+ event: { type: "string", const: "message" },
539
+ data: this.schemaConverter.convert(eventIteratorSchemaDetails.yields, { strategy: "input" }),
540
+ id: { type: "string" },
541
+ retry: { type: "number" }
542
+ },
543
+ required: ["event", "data"]
544
+ },
545
+ {
546
+ type: "object",
547
+ properties: {
548
+ event: { type: "string", const: "done" },
549
+ data: this.schemaConverter.convert(eventIteratorSchemaDetails.returns, { strategy: "input" }),
550
+ id: { type: "string" },
551
+ retry: { type: "number" }
552
+ },
553
+ required: ["event", "data"]
554
+ },
555
+ {
556
+ type: "object",
557
+ properties: {
558
+ event: { type: "string", const: "error" },
559
+ data: {},
560
+ id: { type: "string" },
561
+ retry: { type: "number" }
562
+ },
563
+ required: ["event", "data"]
564
+ }
565
+ ]
566
+ }
567
+ }
568
+ }
569
+ };
570
+ return { responses: responses3 };
571
+ }
572
+ const outputStructure = fallbackContractConfig2("defaultOutputStructure", def.route?.outputStructure);
573
+ const { headersSchema: resHeadersSchema, bodySchema: resBodySchema } = this.outputStructureParser.parse(contract, outputStructure);
574
+ const responses2 = {};
575
+ responses2[fallbackContractConfig2("defaultSuccessStatus", def.route?.successStatus)] = {
576
+ description: fallbackContractConfig2("defaultSuccessDescription", def.route?.successDescription),
577
+ content: resBodySchema !== void 0 ? this.contentBuilder.build(resBodySchema) : void 0,
578
+ headers: resHeadersSchema !== void 0 ? this.parametersBuilder.buildHeadersObject(resHeadersSchema) : void 0
579
+ };
580
+ return { responses: responses2 };
581
+ })();
439
582
  const errors = group(Object.entries(def.errorMap ?? {}).filter(([_, config]) => config).map(([code, config]) => ({
440
583
  ...config,
441
584
  code,
@@ -506,8 +649,9 @@ var OpenAPIGenerator = class {
506
649
  requestBody,
507
650
  responses
508
651
  };
652
+ const extendedOperation = extendOperation(operation, contract);
509
653
  builder.addPath(httpPath, {
510
- [method.toLocaleLowerCase()]: operation
654
+ [method.toLocaleLowerCase()]: extendedOperation
511
655
  });
512
656
  } catch (e) {
513
657
  if (e instanceof OpenAPIError) {
@@ -529,6 +673,11 @@ var OpenAPIGenerator = class {
529
673
  return this.jsonSerializer.serialize(builder.getSpec());
530
674
  }
531
675
  };
676
+
677
+ // src/index.ts
678
+ var oo = {
679
+ spec: setOperationExtender
680
+ };
532
681
  export {
533
682
  CompositeSchemaConverter,
534
683
  JSONSchema,
@@ -541,6 +690,10 @@ export {
541
690
  OpenAPIPathParser,
542
691
  OpenApiBuilder,
543
692
  SchemaUtils,
693
+ extendOperation,
694
+ getOperationExtender,
695
+ oo,
696
+ setOperationExtender,
544
697
  standardizeHTTPPath
545
698
  };
546
699
  //# sourceMappingURL=index.js.map
package/dist/next.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  OpenAPIHandler
3
- } from "./chunk-HQ34JZI7.js";
4
- import "./chunk-M5HOHBLW.js";
5
- import "./chunk-BHJYKXQL.js";
3
+ } from "./chunk-5QMOOQSF.js";
4
+ import "./chunk-TOZPXKQC.js";
5
+ import "./chunk-HC5PVG4R.js";
6
6
  export {
7
7
  OpenAPIHandler
8
8
  };
package/dist/node.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  OpenAPICodec,
3
3
  OpenAPIMatcher
4
- } from "./chunk-M5HOHBLW.js";
5
- import "./chunk-BHJYKXQL.js";
4
+ } from "./chunk-TOZPXKQC.js";
5
+ import "./chunk-HC5PVG4R.js";
6
6
 
7
7
  // src/adapters/node/openapi-handler.ts
8
- import { nodeHttpResponseSendStandardResponse, nodeHttpToStandardRequest } from "@orpc/server/node";
8
+ import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
9
9
  import { StandardHandler } from "@orpc/server/standard";
10
10
  var OpenAPIHandler = class {
11
11
  standardHandler;
@@ -15,12 +15,12 @@ var OpenAPIHandler = class {
15
15
  this.standardHandler = new StandardHandler(router, matcher, codec, { ...options });
16
16
  }
17
17
  async handle(req, res, ...rest) {
18
- const standardRequest = nodeHttpToStandardRequest(req, res);
18
+ const standardRequest = toStandardRequest(req, res);
19
19
  const result = await this.standardHandler.handle(standardRequest, ...rest);
20
20
  if (!result.matched) {
21
21
  return { matched: false };
22
22
  }
23
- await nodeHttpResponseSendStandardResponse(res, result.response);
23
+ await sendStandardResponse(res, result.response);
24
24
  return { matched: true };
25
25
  }
26
26
  };
@@ -1,10 +1,11 @@
1
1
  import type { Context, Router } from '@orpc/server';
2
2
  import type { FetchHandler, FetchHandleResult } from '@orpc/server/fetch';
3
- import type { StandardHandleRest } from '@orpc/server/standard';
3
+ import type { StandardHandleOptions } from '@orpc/server/standard';
4
+ import type { MaybeOptionalOptions } from '@orpc/shared';
4
5
  import type { OpenAPIHandlerOptions } from '../standard';
5
6
  export declare class OpenAPIHandler<T extends Context> implements FetchHandler<T> {
6
7
  private readonly standardHandler;
7
8
  constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
8
- handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
9
+ handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
9
10
  }
10
11
  //# sourceMappingURL=openapi-handler.d.ts.map
@@ -1,10 +1,11 @@
1
1
  import type { Context, Router } from '@orpc/server';
2
2
  import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from '@orpc/server/node';
3
- import type { StandardHandleRest } from '@orpc/server/standard';
3
+ import type { StandardHandleOptions } from '@orpc/server/standard';
4
+ import type { MaybeOptionalOptions } from '@orpc/shared';
4
5
  import type { OpenAPIHandlerOptions } from '../standard';
5
6
  export declare class OpenAPIHandler<T extends Context> implements NodeHttpHandler<T> {
6
7
  private readonly standardHandler;
7
8
  constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
8
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
9
+ handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
9
10
  }
10
11
  //# sourceMappingURL=openapi-handler.d.ts.map
@@ -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
@@ -1,15 +1,13 @@
1
1
  import type { AnyProcedure } from '@orpc/server';
2
- import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from '@orpc/server/standard';
2
+ import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
3
+ import type { StandardCodec, StandardParams } from '@orpc/server/standard';
3
4
  import { type ORPCError } from '@orpc/contract';
4
5
  import { OpenAPISerializer } from './openapi-serializer';
5
- import { type SchemaCoercer } from './schema-coercer';
6
6
  export interface OpenAPICodecOptions {
7
7
  serializer?: OpenAPISerializer;
8
- schemaCoercers?: SchemaCoercer[];
9
8
  }
10
9
  export declare class OpenAPICodec implements StandardCodec {
11
10
  private readonly serializer;
12
- private readonly compositeSchemaCoercer;
13
11
  constructor(options?: OpenAPICodecOptions);
14
12
  decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
15
13
  encode(output: unknown, procedure: AnyProcedure): StandardResponse;
@@ -1,12 +1,17 @@
1
1
  /** unnoq */
2
+ import { setOperationExtender } from './openapi-operation-extender';
2
3
  export * from './json-serializer';
3
4
  export * from './openapi';
4
5
  export * from './openapi-content-builder';
5
6
  export * from './openapi-generator';
7
+ export * from './openapi-operation-extender';
6
8
  export * from './openapi-parameters-builder';
7
9
  export * from './openapi-path-parser';
8
10
  export * from './schema';
9
11
  export * from './schema-converter';
10
12
  export * from './schema-utils';
11
13
  export * from './utils';
14
+ export declare const oo: {
15
+ spec: typeof setOperationExtender;
16
+ };
12
17
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { AnyContractProcedure } from '@orpc/contract';
2
+ import type { OpenAPI } from './openapi';
3
+ export type OverrideOperationValue = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
4
+ export declare function setOperationExtender<T extends object>(o: T, extend: OverrideOperationValue): T;
5
+ export declare function getOperationExtender(o: object): OverrideOperationValue | undefined;
6
+ export declare function extendOperation(operation: OpenAPI.OperationObject, procedure: AnyContractProcedure): OpenAPI.OperationObject;
7
+ //# sourceMappingURL=openapi-operation-extender.d.ts.map
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";
8
- import "./chunk-BHJYKXQL.js";
6
+ } from "./chunk-TOZPXKQC.js";
7
+ import "./chunk-HC5PVG4R.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.0.0-next.6acfc62",
4
+ "version": "0.0.0-next.6affcc9",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -54,18 +54,15 @@
54
54
  "dist"
55
55
  ],
56
56
  "dependencies": {
57
- "@standard-schema/spec": "1.0.0-beta.4",
58
- "@types/content-disposition": "^0.5.8",
59
- "content-disposition": "^0.5.4",
60
- "escape-string-regexp": "^5.0.0",
61
- "fast-content-type-parse": "^2.0.0",
57
+ "@orpc/server-standard": "^0.4.0",
58
+ "@orpc/server-standard-fetch": "^0.4.0",
59
+ "@orpc/server-standard-node": "^0.4.0",
62
60
  "json-schema-typed": "^8.0.1",
63
61
  "openapi3-ts": "^4.4.0",
64
62
  "rou3": "^0.5.1",
65
- "wildcard-match": "^5.1.3",
66
- "@orpc/contract": "0.0.0-next.6acfc62",
67
- "@orpc/server": "0.0.0-next.6acfc62",
68
- "@orpc/shared": "0.0.0-next.6acfc62"
63
+ "@orpc/contract": "0.0.0-next.6affcc9",
64
+ "@orpc/shared": "0.0.0-next.6affcc9",
65
+ "@orpc/server": "0.0.0-next.6affcc9"
69
66
  },
70
67
  "devDependencies": {
71
68
  "@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