@orpc/openapi 2.0.0-beta.49 → 2.0.0-beta.50

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 (65) hide show
  1. package/dist/adapters/aws-lambda/index.d.ts +3 -15
  2. package/dist/adapters/aws-lambda/index.js +1 -1
  3. package/dist/adapters/aws-lambda/openapi-handler.d.ts +8 -9
  4. package/dist/adapters/aws-lambda/openapi-handler.js +19 -17
  5. package/dist/adapters/fastify/index.d.ts +2 -1
  6. package/dist/adapters/fastify/index.js +1 -1
  7. package/dist/adapters/fastify/openapi-handler.d.ts +8 -9
  8. package/dist/adapters/fastify/openapi-handler.js +16 -14
  9. package/dist/adapters/fetch/index.d.ts +3 -2
  10. package/dist/adapters/fetch/index.js +2 -2
  11. package/dist/adapters/fetch/openapi-handler.d.ts +8 -9
  12. package/dist/adapters/fetch/openapi-handler.js +16 -14
  13. package/dist/adapters/fetch/openapi-link.d.ts +9 -10
  14. package/dist/adapters/fetch/openapi-link.js +21 -19
  15. package/dist/adapters/node/index.d.ts +2 -1
  16. package/dist/adapters/node/index.js +1 -1
  17. package/dist/adapters/node/openapi-handler.d.ts +8 -9
  18. package/dist/adapters/node/openapi-handler.js +16 -14
  19. package/dist/adapters/standard/index.d.ts +4 -3
  20. package/dist/adapters/standard/index.js +3 -3
  21. package/dist/adapters/standard/openapi-handler-codec.d.ts +56 -57
  22. package/dist/adapters/standard/openapi-handler-codec.js +143 -205
  23. package/dist/adapters/standard/openapi-link-codec.d.ts +55 -59
  24. package/dist/adapters/standard/openapi-link-codec.js +262 -377
  25. package/dist/adapters/standard/openapi-matcher.d.ts +26 -26
  26. package/dist/adapters/standard/openapi-matcher.js +78 -108
  27. package/dist/adapters/standard/utils.js +28 -44
  28. package/dist/bracket-notation.d.ts +22 -22
  29. package/dist/bracket-notation.js +123 -173
  30. package/dist/client-factory.d.ts +12 -12
  31. package/dist/client-factory.js +13 -11
  32. package/dist/constants.d.ts +1 -4
  33. package/dist/constants.js +5 -4
  34. package/dist/extensions/route.d.ts +36 -36
  35. package/dist/extensions/route.js +7 -6
  36. package/dist/helpers/form-data.d.ts +1 -1
  37. package/dist/helpers/form-data.js +74 -86
  38. package/dist/helpers/index.d.ts +2 -1
  39. package/dist/helpers/index.js +1 -1
  40. package/dist/index.d.ts +15 -13
  41. package/dist/index.js +11 -11
  42. package/dist/meta.d.ts +298 -298
  43. package/dist/meta.js +54 -72
  44. package/dist/openapi-generator-components.d.ts +2 -31
  45. package/dist/openapi-generator-components.js +200 -248
  46. package/dist/openapi-generator-operation.d.ts +12 -33
  47. package/dist/openapi-generator-operation.js +369 -437
  48. package/dist/openapi-generator.d.ts +75 -80
  49. package/dist/openapi-generator.js +114 -142
  50. package/dist/openapi-json-serializer.d.ts +65 -65
  51. package/dist/openapi-json-serializer.js +218 -257
  52. package/dist/openapi-serializer.d.ts +31 -32
  53. package/dist/openapi-serializer.js +68 -92
  54. package/dist/plugins/index.d.ts +2 -1
  55. package/dist/plugins/index.js +1 -1
  56. package/dist/plugins/openapi-reference.d.ts +99 -102
  57. package/dist/plugins/openapi-reference.js +109 -132
  58. package/dist/router-utils.d.ts +7 -10
  59. package/dist/router-utils.js +30 -34
  60. package/dist/types.d.ts +8 -12
  61. package/dist/utils.d.ts +5 -10
  62. package/dist/utils.js +39 -42
  63. package/package.json +12 -12
  64. package/dist/adapters/standard/utils.d.ts +0 -4
  65. package/dist/types.js +0 -1
@@ -1,185 +1,135 @@
1
- import { isPlainObject, NullProtoObj, setOwn } from '@orpc/shared';
2
- export class BracketNotationSerializer {
3
- maxDeserializingEmptySlots;
4
- constructor(options = {}) {
5
- this.maxDeserializingEmptySlots = options.maxDeserializingEmptySlots ?? 1_000;
6
- }
7
- serialize(data) {
8
- const result = [];
9
- this.internalSerialize(data, '', true, result);
10
- return result;
11
- }
12
- internalSerialize(data, path, isRoot, result) {
13
- if (Array.isArray(data)) {
14
- data.forEach((item, i) => {
15
- this.internalSerialize(item, isRoot ? i.toString() : `${path}[${i}]`, false, result);
16
- });
17
- }
18
- else if (isPlainObject(data)) {
19
- for (const key of Object.keys(data)) {
20
- this.internalSerialize(data[key], isRoot ? key : `${path}[${key}]`, false, result);
21
- }
22
- }
23
- else {
24
- result.push([path, data]);
25
- }
26
- }
27
- deserialize(serialized) {
28
- // A caller-supplied object value can become a container for deeper paths, and unlike
29
- // `NullProtoObj` it carries a real prototype, so accesses below stay own-property only.
30
- let arrayPushStyles;
31
- const root = new NullProtoObj();
32
- let emptySlotsLeft = this.maxDeserializingEmptySlots;
33
- for (const [path, value] of serialized) {
34
- const segments = this.parsePath(path);
35
- let currentRef = root;
36
- // Arrays take keys as numbers, so engines do not parse the same key again on each access
37
- let nextSegment = segments[0];
38
- for (let i = 1; i < segments.length; i++) {
39
- const segment = segments[i];
40
- const isLast = i === segments.length - 1;
41
- const hasExisting = Object.hasOwn(currentRef, nextSegment);
42
- const existing = hasExisting ? currentRef[nextSegment] : undefined;
43
- let child = existing;
44
- let key = segment;
45
- // A missing value is treated like an empty array and a leaf value like a one-item array (as if its key
46
- // were repeated), which becomes an object if it cannot stay one
47
- if (Array.isArray(child) || !isPlainObject(child)) {
48
- if (hasExisting && !Array.isArray(child)) {
49
- child = [child];
50
- }
51
- const isArray = Array.isArray(child);
52
- const isPushStyle = isArray && !!arrayPushStyles?.has(child);
53
- const length = isArray ? child.length : 0;
54
- const index = internalToArrayIndex(segment);
55
- const emptySlots = index === undefined ? 0 : Math.max(0, index - length);
56
- const canBeArray = segment === ''
57
- ? isLast && (isPushStyle || length === 0)
58
- : index !== undefined && !(isLast && isPushStyle) && emptySlots <= emptySlotsLeft;
59
- if (canBeArray) {
60
- emptySlotsLeft -= emptySlots;
61
- child = isArray ? child : [];
62
- key = index ?? segment;
63
- }
64
- else if (isArray) {
65
- arrayPushStyles?.delete(child);
66
- child = isPushStyle
67
- ? internalPushStyleArrayToObject(child)
68
- : internalArrayToObject(child);
69
- }
70
- else {
71
- child = new NullProtoObj();
72
- }
73
- }
74
- if (child !== existing) {
75
- internalSetOwn(currentRef, nextSegment, child);
76
- }
77
- currentRef = child;
78
- nextSegment = key;
79
- }
80
- if (Array.isArray(currentRef) && nextSegment === '') {
81
- arrayPushStyles ??= new WeakSet();
82
- arrayPushStyles.add(currentRef);
83
- currentRef.push(value);
84
- }
85
- else if (Object.hasOwn(currentRef, nextSegment)) {
86
- const current = currentRef[nextSegment];
87
- if (Array.isArray(current)) {
88
- current.push(value);
89
- }
90
- else {
91
- internalSetOwn(currentRef, nextSegment, [current, value]);
92
- }
93
- }
94
- else {
95
- internalSetOwn(currentRef, nextSegment, value);
96
- }
97
- }
98
- return root;
99
- }
100
- stringifyPath(segments) {
101
- if (segments.length === 0) {
102
- return '';
103
- }
104
- let result = segments[0].toString();
105
- for (let i = 1; i < segments.length; i++) {
106
- result += `[${segments[i]}]`;
107
- }
108
- return result;
109
- }
110
- parsePath(path) {
111
- const start = path.indexOf('[');
112
- // Brackets must open after the first segment and close at the very end, e.g. `a[b][c]`
113
- if (start === -1 || path[path.length - 1] !== ']') {
114
- return [path];
115
- }
116
- const segments = [path.slice(0, start)];
117
- let from = start + 1;
118
- let to = path.indexOf('][', from);
119
- while (to !== -1) {
120
- segments.push(path.slice(from, to));
121
- from = to + 2;
122
- to = path.indexOf('][', from);
123
- }
124
- segments.push(path.slice(from, -1));
125
- return segments;
126
- }
127
- }
1
+ import { NullProtoObj, isPlainObject, setOwn } from "@orpc/shared";
2
+ // src/bracket-notation.ts
3
+ var BracketNotationSerializer = class {
4
+ maxDeserializingEmptySlots;
5
+ constructor(options = {}) {
6
+ this.maxDeserializingEmptySlots = options.maxDeserializingEmptySlots ?? 1e3;
7
+ }
8
+ serialize(data) {
9
+ const result = [];
10
+ this.internalSerialize(data, "", true, result);
11
+ return result;
12
+ }
13
+ internalSerialize(data, path, isRoot, result) {
14
+ if (Array.isArray(data)) data.forEach((item, i) => {
15
+ this.internalSerialize(item, isRoot ? i.toString() : `${path}[${i}]`, false, result);
16
+ });
17
+ else if (isPlainObject(data)) for (const key of Object.keys(data)) this.internalSerialize(data[key], isRoot ? key : `${path}[${key}]`, false, result);
18
+ else result.push([path, data]);
19
+ }
20
+ deserialize(serialized) {
21
+ let arrayPushStyles;
22
+ const root = new NullProtoObj();
23
+ let emptySlotsLeft = this.maxDeserializingEmptySlots;
24
+ for (const [path, value] of serialized) {
25
+ const segments = this.parsePath(path);
26
+ let currentRef = root;
27
+ let nextSegment = segments[0];
28
+ for (let i = 1; i < segments.length; i++) {
29
+ const segment = segments[i];
30
+ const isLast = i === segments.length - 1;
31
+ const hasExisting = Object.hasOwn(currentRef, nextSegment);
32
+ const existing = hasExisting ? currentRef[nextSegment] : void 0;
33
+ let child = existing;
34
+ let key = segment;
35
+ if (Array.isArray(child) || !isPlainObject(child)) {
36
+ if (hasExisting && !Array.isArray(child)) child = [child];
37
+ const isArray = Array.isArray(child);
38
+ const isPushStyle = isArray && !!arrayPushStyles?.has(child);
39
+ const length = isArray ? child.length : 0;
40
+ const index = internalToArrayIndex(segment);
41
+ const emptySlots = index === void 0 ? 0 : Math.max(0, index - length);
42
+ if (segment === "" ? isLast && (isPushStyle || length === 0) : index !== void 0 && !(isLast && isPushStyle) && emptySlots <= emptySlotsLeft) {
43
+ emptySlotsLeft -= emptySlots;
44
+ child = isArray ? child : [];
45
+ key = index ?? segment;
46
+ } else if (isArray) {
47
+ arrayPushStyles?.delete(child);
48
+ child = isPushStyle ? internalPushStyleArrayToObject(child) : internalArrayToObject(child);
49
+ } else child = new NullProtoObj();
50
+ }
51
+ if (child !== existing) internalSetOwn(currentRef, nextSegment, child);
52
+ currentRef = child;
53
+ nextSegment = key;
54
+ }
55
+ if (Array.isArray(currentRef) && nextSegment === "") {
56
+ arrayPushStyles ??= /* @__PURE__ */ new WeakSet();
57
+ arrayPushStyles.add(currentRef);
58
+ currentRef.push(value);
59
+ } else if (Object.hasOwn(currentRef, nextSegment)) {
60
+ const current = currentRef[nextSegment];
61
+ if (Array.isArray(current)) current.push(value);
62
+ else internalSetOwn(currentRef, nextSegment, [current, value]);
63
+ } else internalSetOwn(currentRef, nextSegment, value);
64
+ }
65
+ return root;
66
+ }
67
+ stringifyPath(segments) {
68
+ if (segments.length === 0) return "";
69
+ let result = segments[0].toString();
70
+ for (let i = 1; i < segments.length; i++) result += `[${segments[i]}]`;
71
+ return result;
72
+ }
73
+ parsePath(path) {
74
+ const start = path.indexOf("[");
75
+ if (start === -1 || path[path.length - 1] !== "]") return [path];
76
+ const segments = [path.slice(0, start)];
77
+ let from = start + 1;
78
+ let to = path.indexOf("][", from);
79
+ while (to !== -1) {
80
+ segments.push(path.slice(from, to));
81
+ from = to + 2;
82
+ to = path.indexOf("][", from);
83
+ }
84
+ segments.push(path.slice(from, -1));
85
+ return segments;
86
+ }
87
+ };
128
88
  /**
129
- * The largest array index. Larger integer keys are ordinary properties.
130
- */
89
+ * The largest array index. Larger integer keys are ordinary properties.
90
+ */
131
91
  const MAX_ARRAY_INDEX = 2 ** 32 - 2;
132
92
  /**
133
- * Returns `key` as an array index (no sign, no leading zeros), which is also how engines store the
134
- * integer keys of objects, or `undefined` if it is not one.
135
- */
93
+ * Returns `key` as an array index (no sign, no leading zeros), which is also how engines store the
94
+ * integer keys of objects, or `undefined` if it is not one.
95
+ */
136
96
  function internalToArrayIndex(key) {
137
- // `MAX_ARRAY_INDEX` has 10 digits
138
- if (key.length === 0 || key.length > 10) {
139
- return undefined;
140
- }
141
- let index = key.charCodeAt(0) - 48; // '0'
142
- if (index < 0 || index > 9 || (index === 0 && key.length > 1)) {
143
- return undefined;
144
- }
145
- for (let i = 1; i < key.length; i++) {
146
- const digit = key.charCodeAt(i) - 48;
147
- if (digit < 0 || digit > 9) {
148
- return undefined;
149
- }
150
- index = index * 10 + digit;
151
- }
152
- return index <= MAX_ARRAY_INDEX ? index : undefined;
97
+ if (key.length === 0 || key.length > 10) return;
98
+ let index = key.charCodeAt(0) - 48;
99
+ if (index < 0 || index > 9 || index === 0 && key.length > 1) return;
100
+ for (let i = 1; i < key.length; i++) {
101
+ const digit = key.charCodeAt(i) - 48;
102
+ if (digit < 0 || digit > 9) return;
103
+ index = index * 10 + digit;
104
+ }
105
+ return index <= MAX_ARRAY_INDEX ? index : void 0;
153
106
  }
154
107
  function internalArrayToObject(array) {
155
- const obj = new NullProtoObj(); // Prevent Prototype Pollution with NullProtoObj
156
- array.forEach((item, i) => {
157
- obj[i] = item;
158
- });
159
- return obj;
108
+ const obj = new NullProtoObj();
109
+ array.forEach((item, i) => {
110
+ obj[i] = item;
111
+ });
112
+ return obj;
160
113
  }
161
114
  function internalPushStyleArrayToObject(array) {
162
- const obj = new NullProtoObj();
163
- obj[''] = array.length === 1 ? array[0] : array;
164
- return obj;
115
+ const obj = new NullProtoObj();
116
+ obj[""] = array.length === 1 ? array[0] : array;
117
+ return obj;
165
118
  }
166
119
  /**
167
- * Like `setOwn`, but first switches an object created during deserialization to sparse storage when an
168
- * integer key would leave a gap. Engines keep integer keys in a flat backing store sized by the largest one,
169
- * so a lone `{ 999: x }` takes ~12KB in V8. Holding `MAX_ARRAY_INDEX` switches an object to sparse storage
170
- * for good (V8 and JSC), so writing and deleting it keeps the object's integer keys cheap without a trace.
171
- */
120
+ * Like `setOwn`, but first switches an object created during deserialization to sparse storage when an
121
+ * integer key would leave a gap. Engines keep integer keys in a flat backing store sized by the largest one,
122
+ * so a lone `{ 999: x }` takes ~12KB in V8. Holding `MAX_ARRAY_INDEX` switches an object to sparse storage
123
+ * for good (V8 and JSC), so writing and deleting it keeps the object's integer keys cheap without a trace.
124
+ */
172
125
  function internalSetOwn(container, key, value) {
173
- if (typeof key === 'string' && container instanceof NullProtoObj) {
174
- const index = internalToArrayIndex(key);
175
- // `0`, or the key right after an existing one, keeps the flat store filled
176
- if (index !== undefined &&
177
- index !== 0 &&
178
- !Object.hasOwn(container, index - 1) &&
179
- !Object.hasOwn(container, MAX_ARRAY_INDEX)) {
180
- container[MAX_ARRAY_INDEX] = undefined;
181
- delete container[MAX_ARRAY_INDEX];
182
- }
183
- }
184
- setOwn(container, key, value);
126
+ if (typeof key === "string" && container instanceof NullProtoObj) {
127
+ const index = internalToArrayIndex(key);
128
+ if (index !== void 0 && index !== 0 && !Object.hasOwn(container, index - 1) && !Object.hasOwn(container, MAX_ARRAY_INDEX)) {
129
+ container[MAX_ARRAY_INDEX] = void 0;
130
+ delete container[MAX_ARRAY_INDEX];
131
+ }
132
+ }
133
+ setOwn(container, key, value);
185
134
  }
135
+ export { BracketNotationSerializer };
@@ -1,16 +1,16 @@
1
- import type { ClientContext, ClientLink, ORPCClientOptions } from '@orpc/client';
2
- import type { RouterContract, RouterContractClient } from '@orpc/contract';
3
- import type { JsonifiedClient } from './types.ts';
1
+ import { JsonifiedClient } from "./types.js";
2
+ import { RouterContract, RouterContractClient } from "@orpc/contract";
3
+ import { ClientContext, ClientLink, ORPCClientOptions } from "@orpc/client";
4
4
  export interface ContractJsonifiedClientFactory<TClientContext extends ClientContext> {
5
- <T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
5
+ <T extends RouterContract>(contract: T): JsonifiedClient<RouterContractClient<T, TClientContext>>;
6
6
  }
7
- export interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, 'interceptors' | 'scoped'> {
8
- /**
9
- * An optional reference to the root router-contract.
10
- * When provided, the client factory will automatically register the passed contract
11
- * into the router at the path defined by `meta.path`.
12
- */
13
- contractRef?: RouterContract | undefined;
7
+ export interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<JsonifiedClient<RouterContractClient<RouterContract, TClientContext>>>, "interceptors" | "scoped"> {
8
+ /**
9
+ * An optional reference to the root router-contract.
10
+ * When provided, the client factory will automatically register the passed contract
11
+ * into the router at the path defined by `meta.path`.
12
+ */
13
+ contractRef?: RouterContract | undefined;
14
14
  }
15
15
  /**
16
16
  * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
@@ -21,4 +21,4 @@ export interface ContractJsonifiedClientFactoryOptions<TClientContext extends Cl
21
21
  *
22
22
  * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
23
23
  */
24
- export declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
24
+ export declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
@@ -1,13 +1,15 @@
1
- import { createContractClientFactory } from '@orpc/contract';
1
+ import { createContractClientFactory } from "@orpc/contract";
2
+ // src/client-factory.ts
2
3
  /**
3
- * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
4
- * for links that require it, such as OpenAPI Link.
5
- *
6
- * @remarks
7
- * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
8
- *
9
- * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
10
- */
11
- export function createContractJsonifiedClientFactory(link, options = {}) {
12
- return createContractClientFactory(link, options);
4
+ * Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
5
+ * for links that require it, such as OpenAPI Link.
6
+ *
7
+ * @remarks
8
+ * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
9
+ *
10
+ * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
11
+ */
12
+ function createContractJsonifiedClientFactory(link, options = {}) {
13
+ return createContractClientFactory(link, options);
13
14
  }
15
+ export { createContractJsonifiedClientFactory };
@@ -1,4 +1 @@
1
- export declare const DEFAULT_OPENAPI_METHOD = "POST";
2
- export declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
3
- export declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
4
- export declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
1
+ export declare const DEFAULT_OPENAPI_METHOD = "POST";
package/dist/constants.js CHANGED
@@ -1,4 +1,5 @@
1
- export const DEFAULT_OPENAPI_METHOD = 'POST';
2
- export const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = 'OK';
3
- export const DEFAULT_OPENAPI_INPUT_STRUCTURE = 'compact';
4
- export const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = 'compact';
1
+ // src/constants.ts
2
+ const DEFAULT_OPENAPI_METHOD = "POST";
3
+ const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
4
+ const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
5
+ export { DEFAULT_OPENAPI_INPUT_STRUCTURE, DEFAULT_OPENAPI_METHOD, DEFAULT_OPENAPI_OUTPUT_STRUCTURE };
@@ -1,37 +1,37 @@
1
- import type { AnySchema, ErrorMap } from '@orpc/contract';
2
- import type { Context } from '@orpc/server';
3
- import type { OpenAPIMeta } from '../meta.ts';
4
- declare module '@orpc/contract' {
5
- interface ContractBuilder<TErrorMap extends ErrorMap> {
6
- route(meta: OpenAPIMeta): ContractBuilder<TErrorMap>;
7
- }
8
- interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
9
- route(meta: OpenAPIMeta): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
10
- }
11
- interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
12
- route(meta: OpenAPIMeta): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
13
- }
14
- interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
15
- route(meta: OpenAPIMeta): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
16
- }
17
- }
18
- declare module '@orpc/server' {
19
- interface Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
20
- route(meta: OpenAPIMeta): Builder<TInitialContext, TErrorMap>;
21
- }
22
- interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
23
- route(meta: OpenAPIMeta): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
24
- }
25
- interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
26
- route(meta: OpenAPIMeta): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
27
- }
28
- interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
29
- route(meta: OpenAPIMeta): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
30
- }
31
- interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
32
- route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
33
- }
34
- interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
35
- route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
36
- }
1
+ import { OpenAPIMeta } from "../meta.js";
2
+ import { AnySchema, ErrorMap } from "@orpc/contract";
3
+ import { Context } from "@orpc/server";
4
+ declare module "@orpc/contract" {
5
+ interface ContractBuilder<TErrorMap extends ErrorMap> {
6
+ route(meta: OpenAPIMeta): ContractBuilder<TErrorMap>;
7
+ }
8
+ interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
9
+ route(meta: OpenAPIMeta): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
10
+ }
11
+ interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
12
+ route(meta: OpenAPIMeta): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
13
+ }
14
+ interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
15
+ route(meta: OpenAPIMeta): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
16
+ }
37
17
  }
18
+ declare module "@orpc/server" {
19
+ interface Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
20
+ route(meta: OpenAPIMeta): Builder<TInitialContext, TErrorMap>;
21
+ }
22
+ interface BuilderWithMiddlewares<TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> {
23
+ route(meta: OpenAPIMeta): BuilderWithMiddlewares<TInitialContext, TInjectedContext, TErrorMap>;
24
+ }
25
+ interface BuilderWithInput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap> {
26
+ route(meta: OpenAPIMeta): BuilderWithInput<TInitialContext, TInjectedContext, TInputSchema, TErrorMap>;
27
+ }
28
+ interface BuilderWithOutput<TInitialContext extends Context, TInjectedContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
29
+ route(meta: OpenAPIMeta): BuilderWithOutput<TInitialContext, TInjectedContext, TOutputSchema, TErrorMap>;
30
+ }
31
+ interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
32
+ route(meta: OpenAPIMeta): BuilderWithInputOutput<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
33
+ }
34
+ interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> {
35
+ route(meta: OpenAPIMeta): DecoratedProcedure<TInitialContext, TInjectedContext, TInputSchema, TOutputSchema, TErrorMap>;
36
+ }
37
+ }
@@ -1,12 +1,13 @@
1
- import { ContractBuilder } from '@orpc/contract';
2
- import { Builder, DecoratedProcedure } from '@orpc/server';
3
- import { openapi } from '../meta.js';
1
+ import { openapi } from "../meta.js";
2
+ import { ContractBuilder } from "@orpc/contract";
3
+ import { Builder, DecoratedProcedure } from "@orpc/server";
4
+ // src/extensions/route.ts
4
5
  ContractBuilder.prototype.route = function route(meta) {
5
- return this.meta(openapi(meta));
6
+ return this.meta(openapi(meta));
6
7
  };
7
8
  Builder.prototype.route = function route(meta) {
8
- return this.meta(openapi(meta));
9
+ return this.meta(openapi(meta));
9
10
  };
10
11
  DecoratedProcedure.prototype.route = function route(meta) {
11
- return this.meta(openapi(meta));
12
+ return this.meta(openapi(meta));
12
13
  };
@@ -54,4 +54,4 @@ export declare function parseFormData(form: FormData): any;
54
54
  *
55
55
  * @see {@link https://orpc.dev/docs/helpers/form-data#getissuemessage | Form Data Helpers - getIssueMessage}
56
56
  */
57
- export declare function getIssueMessage(error: unknown, path: string): string | undefined;
57
+ export declare function getIssueMessage(error: unknown, path: string): string | undefined;