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

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 (93) hide show
  1. package/README.md +6 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +10 -22
  3. package/dist/adapters/aws-lambda/index.js +1 -0
  4. package/dist/adapters/aws-lambda/openapi-handler.d.ts +18 -0
  5. package/dist/adapters/aws-lambda/openapi-handler.js +18 -0
  6. package/dist/adapters/fastify/index.d.ts +1 -23
  7. package/dist/adapters/fastify/index.js +1 -0
  8. package/dist/adapters/fastify/openapi-handler.d.ts +15 -0
  9. package/dist/adapters/fastify/openapi-handler.js +15 -0
  10. package/dist/adapters/fetch/index.d.ts +2 -37
  11. package/dist/adapters/fetch/index.js +2 -0
  12. package/dist/adapters/fetch/openapi-handler.d.ts +15 -0
  13. package/dist/adapters/fetch/openapi-handler.js +15 -0
  14. package/dist/adapters/fetch/openapi-link.d.ts +21 -0
  15. package/dist/adapters/fetch/openapi-link.js +20 -0
  16. package/dist/adapters/node/index.d.ts +1 -23
  17. package/dist/adapters/node/index.js +1 -0
  18. package/dist/adapters/node/openapi-handler.d.ts +15 -0
  19. package/dist/adapters/node/openapi-handler.js +15 -0
  20. package/dist/adapters/standard/index.d.ts +3 -56
  21. package/dist/adapters/standard/index.js +3 -0
  22. package/dist/adapters/standard/openapi-handler-codec.d.ts +62 -0
  23. package/dist/adapters/standard/openapi-handler-codec.js +220 -0
  24. package/dist/adapters/standard/{index.d.mts → openapi-link-codec.d.ts} +25 -19
  25. package/dist/adapters/standard/openapi-link-codec.js +405 -0
  26. package/dist/adapters/standard/openapi-matcher.d.ts +29 -0
  27. package/dist/adapters/standard/openapi-matcher.js +108 -0
  28. package/dist/adapters/standard/utils.d.ts +4 -0
  29. package/dist/adapters/standard/utils.js +47 -0
  30. package/dist/bracket-notation.d.ts +26 -0
  31. package/dist/bracket-notation.js +185 -0
  32. package/dist/client-factory.d.ts +24 -0
  33. package/dist/client-factory.js +13 -0
  34. package/dist/constants.d.ts +4 -0
  35. package/dist/constants.js +4 -0
  36. package/dist/extensions/route.d.ts +3 -7
  37. package/dist/extensions/route.js +12 -0
  38. package/dist/helpers/{index.d.mts → form-data.d.ts} +2 -4
  39. package/dist/helpers/form-data.js +90 -0
  40. package/dist/helpers/index.d.ts +1 -59
  41. package/dist/helpers/index.js +1 -0
  42. package/dist/index.d.ts +12 -165
  43. package/dist/index.js +11 -0
  44. package/dist/{shared/openapi.zGZlCOwp.d.mts → meta.d.ts} +14 -18
  45. package/dist/meta.js +84 -0
  46. package/dist/openapi-generator-components.d.ts +31 -0
  47. package/dist/openapi-generator-components.js +275 -0
  48. package/dist/openapi-generator-operation.d.ts +34 -0
  49. package/dist/openapi-generator-operation.js +469 -0
  50. package/dist/openapi-generator.d.ts +92 -0
  51. package/dist/openapi-generator.js +147 -0
  52. package/dist/openapi-json-serializer.d.ts +79 -0
  53. package/dist/openapi-json-serializer.js +260 -0
  54. package/dist/openapi-serializer.d.ts +43 -0
  55. package/dist/openapi-serializer.js +93 -0
  56. package/dist/plugins/index.d.ts +1 -121
  57. package/dist/plugins/index.js +1 -0
  58. package/dist/plugins/{index.d.mts → openapi-reference.d.ts} +15 -21
  59. package/dist/plugins/openapi-reference.js +187 -0
  60. package/dist/router-utils.d.ts +20 -0
  61. package/dist/router-utils.js +36 -0
  62. package/dist/types.d.ts +31 -0
  63. package/dist/types.js +1 -0
  64. package/dist/utils.d.ts +14 -0
  65. package/dist/utils.js +47 -0
  66. package/package.json +69 -71
  67. package/dist/adapters/aws-lambda/index.d.mts +0 -27
  68. package/dist/adapters/aws-lambda/index.mjs +0 -21
  69. package/dist/adapters/fastify/index.d.mts +0 -23
  70. package/dist/adapters/fastify/index.mjs +0 -21
  71. package/dist/adapters/fetch/index.d.mts +0 -37
  72. package/dist/adapters/fetch/index.mjs +0 -34
  73. package/dist/adapters/node/index.d.mts +0 -23
  74. package/dist/adapters/node/index.mjs +0 -21
  75. package/dist/adapters/standard/index.mjs +0 -12
  76. package/dist/extensions/route.d.mts +0 -41
  77. package/dist/extensions/route.mjs +0 -14
  78. package/dist/helpers/index.mjs +0 -39
  79. package/dist/index.d.mts +0 -166
  80. package/dist/index.mjs +0 -780
  81. package/dist/plugins/index.mjs +0 -167
  82. package/dist/shared/openapi.B9PQzqBn.mjs +0 -49
  83. package/dist/shared/openapi.CQkXu1nY.mjs +0 -366
  84. package/dist/shared/openapi.Covi8zVE.d.mts +0 -33
  85. package/dist/shared/openapi.Covi8zVE.d.ts +0 -33
  86. package/dist/shared/openapi.DfmCR1pB.d.mts +0 -94
  87. package/dist/shared/openapi.DtEVcxuW.mjs +0 -149
  88. package/dist/shared/openapi.E3ZBiweM.mjs +0 -353
  89. package/dist/shared/openapi.Y4K_-I5W.d.ts +0 -94
  90. package/dist/shared/openapi.YMRD3b4R.d.mts +0 -157
  91. package/dist/shared/openapi.YMRD3b4R.d.ts +0 -157
  92. package/dist/shared/openapi.g7ucL05o.mjs +0 -410
  93. package/dist/shared/openapi.zGZlCOwp.d.ts +0 -329
@@ -1,157 +0,0 @@
1
- import { StandardBody } from '@standard-server/core';
2
- import { Segment } from '@orpc/shared';
3
-
4
- type BracketNotationSerializeResult = [string, unknown][];
5
- interface BracketNotationSerializerOptions {
6
- /**
7
- * Maximum number of empty slots that explicit array indexes may leave in total during deserialization
8
- * (e.g., `a[0]=x&a[3]=y` leaves 2). An index that would exceed it turns its array into an object
9
- * instead (e.g., `?arr[5000]=x` becomes `{ arr: { 5000: 'x' } }`).
10
- *
11
- * Empty slots take memory (a lone `?arr[999]=x` takes ~12KB in V8), and code iterating an array walks
12
- * every one of them, so this keeps both in line with the input.
13
- *
14
- * NOTE: Append-style notation (e.g., `arr[]`) never leaves empty slots.
15
- *
16
- * @default 1_000
17
- */
18
- maxDeserializingEmptySlots?: number | undefined;
19
- }
20
- declare class BracketNotationSerializer {
21
- private readonly maxDeserializingEmptySlots;
22
- constructor(options?: BracketNotationSerializerOptions);
23
- serialize(data: unknown): BracketNotationSerializeResult;
24
- private internalSerialize;
25
- deserialize(serialized: BracketNotationSerializeResult): Record<string, unknown>;
26
- stringifyPath(segments: readonly Segment[]): string;
27
- parsePath(path: string): string[];
28
- }
29
-
30
- type OpenAPIJsonSerialization = {
31
- json: unknown;
32
- maps?: undefined;
33
- blobs?: undefined;
34
- } | {
35
- json: unknown;
36
- maps: Segment[][];
37
- blobs: Blob[];
38
- };
39
- interface OpenAPIJsonSerializerHandler {
40
- condition(value: unknown): boolean;
41
- serialize(value: any): unknown;
42
- /**
43
- * If false, the result of this serializer will not be further processed by other serializers,
44
- * even if it matches their conditions and treat it as final serialized value.
45
- * This can be useful for serializers that return primitive values, which should not be further processed.
46
- * to improve performance and avoid potential issues with other serializers.
47
- *
48
- * @default false
49
- */
50
- isTerminal?: boolean | undefined;
51
- }
52
- interface OpenAPIJsonSerializerOptions {
53
- /**
54
- * Extend or override the built-in type handlers used during serialization.
55
- *
56
- * Each key is a unique type identifier (e.g. `"date"`, `"bigint"`) and maps to a handler
57
- * that defines how to detect and serialize values of that type.
58
- *
59
- * **Extending:** Add new keys to support custom types:
60
- * ```ts
61
- * handlers: {
62
- * buffer: {
63
- * condition: (v) => v instanceof Buffer,
64
- * serialize: (v: Buffer) => v.toString('base64'),
65
- * isTerminal: true,
66
- * }
67
- * }
68
- * ```
69
- *
70
- * **Overriding:** Use an existing key to replace a built-in handler:
71
- * ```ts
72
- * handlers: {
73
- * date: {
74
- * condition: (v) => v instanceof Date,
75
- * serialize: (v: Date) => v.getTime(),
76
- * isTerminal: true,
77
- * }
78
- * }
79
- * ```
80
- *
81
- * **Disabling:** Set a key to `undefined` to remove a built-in handler:
82
- * ```ts
83
- * handlers: { url: undefined }
84
- * ```
85
- *
86
- * Built-in type keys: `undefined`, `bigint`, `date`, `nan`, `infinity`, `url`, `set`, `map`.
87
- */
88
- handlers?: Record<string, undefined | OpenAPIJsonSerializerHandler> | undefined;
89
- /**
90
- * If true, properties with undefined values will be omitted during serialization.
91
- *
92
- * @default true
93
- */
94
- omitUndefinedProperties?: boolean | undefined;
95
- }
96
- /**
97
- * The JSON layer behind `OpenAPISerializer`: one-way serialization of types like `Date`, `BigInt`,
98
- * and `Set` into JSON-friendly values, for places that only accept JSON.
99
- *
100
- * @see {@link https://orpc.dev/docs/openapi/serializer#openapi-json-serializer | OpenAPI Serializer - OpenAPI JSON Serializer}
101
- */
102
- declare class OpenAPIJsonSerializer {
103
- private readonly inlineBuiltInHandlers;
104
- private readonly handlerEntries;
105
- private readonly omitUndefinedProperties;
106
- constructor(options?: OpenAPIJsonSerializerOptions);
107
- serializeJson(data: unknown): OpenAPIJsonSerialization;
108
- /**
109
- * `segments` is a shared mutable stack (push/pop while walking),
110
- * so it must be copied before being stored in `maps`.
111
- */
112
- private serializeValue;
113
- deserializeJson(serialized: OpenAPIJsonSerialization): unknown;
114
- }
115
-
116
- interface OpenAPISerializerSerializeOptions {
117
- /**
118
- * Use FormData for serialization when nested blobs are present.
119
- * Does not apply to root-level Blob values.
120
- *
121
- * @default true
122
- */
123
- useFormDataForBlobFields?: boolean | undefined;
124
- /**
125
- * When enabled, the serialized output is always returned as a FormData instance using bracket notation.
126
- *
127
- * @default false
128
- */
129
- asFormData?: boolean | undefined;
130
- }
131
- interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
132
- /**
133
- * Options for bracket notation serializer, like maxDeserializingEmptySlots
134
- */
135
- bracketNotation?: BracketNotationSerializerOptions | undefined;
136
- /**
137
- * Default options for serialize method
138
- */
139
- serialize?: OpenAPISerializerSerializeOptions | undefined;
140
- }
141
- /**
142
- * Handles one-way serialization of oRPC payloads into JSON-friendly formats,
143
- * partially supporting complex data types beyond plain JSON such as `Date`, `BigInt`, and `Set`.
144
- *
145
- * @see {@link https://orpc.dev/docs/openapi/serializer | OpenAPI Serializer}
146
- */
147
- declare class OpenAPISerializer extends OpenAPIJsonSerializer {
148
- private readonly bracketNotation;
149
- private readonly defaultSerializeOptions;
150
- constructor({ bracketNotation, serialize, ...options }?: OpenAPISerializerOptions);
151
- serialize(data: unknown, options?: OpenAPISerializerSerializeOptions): StandardBody;
152
- private serializePayload;
153
- deserialize(data: StandardBody): unknown;
154
- }
155
-
156
- export { OpenAPISerializer as O, OpenAPIJsonSerializer as a, BracketNotationSerializer as b };
157
- export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
@@ -1,157 +0,0 @@
1
- import { StandardBody } from '@standard-server/core';
2
- import { Segment } from '@orpc/shared';
3
-
4
- type BracketNotationSerializeResult = [string, unknown][];
5
- interface BracketNotationSerializerOptions {
6
- /**
7
- * Maximum number of empty slots that explicit array indexes may leave in total during deserialization
8
- * (e.g., `a[0]=x&a[3]=y` leaves 2). An index that would exceed it turns its array into an object
9
- * instead (e.g., `?arr[5000]=x` becomes `{ arr: { 5000: 'x' } }`).
10
- *
11
- * Empty slots take memory (a lone `?arr[999]=x` takes ~12KB in V8), and code iterating an array walks
12
- * every one of them, so this keeps both in line with the input.
13
- *
14
- * NOTE: Append-style notation (e.g., `arr[]`) never leaves empty slots.
15
- *
16
- * @default 1_000
17
- */
18
- maxDeserializingEmptySlots?: number | undefined;
19
- }
20
- declare class BracketNotationSerializer {
21
- private readonly maxDeserializingEmptySlots;
22
- constructor(options?: BracketNotationSerializerOptions);
23
- serialize(data: unknown): BracketNotationSerializeResult;
24
- private internalSerialize;
25
- deserialize(serialized: BracketNotationSerializeResult): Record<string, unknown>;
26
- stringifyPath(segments: readonly Segment[]): string;
27
- parsePath(path: string): string[];
28
- }
29
-
30
- type OpenAPIJsonSerialization = {
31
- json: unknown;
32
- maps?: undefined;
33
- blobs?: undefined;
34
- } | {
35
- json: unknown;
36
- maps: Segment[][];
37
- blobs: Blob[];
38
- };
39
- interface OpenAPIJsonSerializerHandler {
40
- condition(value: unknown): boolean;
41
- serialize(value: any): unknown;
42
- /**
43
- * If false, the result of this serializer will not be further processed by other serializers,
44
- * even if it matches their conditions and treat it as final serialized value.
45
- * This can be useful for serializers that return primitive values, which should not be further processed.
46
- * to improve performance and avoid potential issues with other serializers.
47
- *
48
- * @default false
49
- */
50
- isTerminal?: boolean | undefined;
51
- }
52
- interface OpenAPIJsonSerializerOptions {
53
- /**
54
- * Extend or override the built-in type handlers used during serialization.
55
- *
56
- * Each key is a unique type identifier (e.g. `"date"`, `"bigint"`) and maps to a handler
57
- * that defines how to detect and serialize values of that type.
58
- *
59
- * **Extending:** Add new keys to support custom types:
60
- * ```ts
61
- * handlers: {
62
- * buffer: {
63
- * condition: (v) => v instanceof Buffer,
64
- * serialize: (v: Buffer) => v.toString('base64'),
65
- * isTerminal: true,
66
- * }
67
- * }
68
- * ```
69
- *
70
- * **Overriding:** Use an existing key to replace a built-in handler:
71
- * ```ts
72
- * handlers: {
73
- * date: {
74
- * condition: (v) => v instanceof Date,
75
- * serialize: (v: Date) => v.getTime(),
76
- * isTerminal: true,
77
- * }
78
- * }
79
- * ```
80
- *
81
- * **Disabling:** Set a key to `undefined` to remove a built-in handler:
82
- * ```ts
83
- * handlers: { url: undefined }
84
- * ```
85
- *
86
- * Built-in type keys: `undefined`, `bigint`, `date`, `nan`, `infinity`, `url`, `set`, `map`.
87
- */
88
- handlers?: Record<string, undefined | OpenAPIJsonSerializerHandler> | undefined;
89
- /**
90
- * If true, properties with undefined values will be omitted during serialization.
91
- *
92
- * @default true
93
- */
94
- omitUndefinedProperties?: boolean | undefined;
95
- }
96
- /**
97
- * The JSON layer behind `OpenAPISerializer`: one-way serialization of types like `Date`, `BigInt`,
98
- * and `Set` into JSON-friendly values, for places that only accept JSON.
99
- *
100
- * @see {@link https://orpc.dev/docs/openapi/serializer#openapi-json-serializer | OpenAPI Serializer - OpenAPI JSON Serializer}
101
- */
102
- declare class OpenAPIJsonSerializer {
103
- private readonly inlineBuiltInHandlers;
104
- private readonly handlerEntries;
105
- private readonly omitUndefinedProperties;
106
- constructor(options?: OpenAPIJsonSerializerOptions);
107
- serializeJson(data: unknown): OpenAPIJsonSerialization;
108
- /**
109
- * `segments` is a shared mutable stack (push/pop while walking),
110
- * so it must be copied before being stored in `maps`.
111
- */
112
- private serializeValue;
113
- deserializeJson(serialized: OpenAPIJsonSerialization): unknown;
114
- }
115
-
116
- interface OpenAPISerializerSerializeOptions {
117
- /**
118
- * Use FormData for serialization when nested blobs are present.
119
- * Does not apply to root-level Blob values.
120
- *
121
- * @default true
122
- */
123
- useFormDataForBlobFields?: boolean | undefined;
124
- /**
125
- * When enabled, the serialized output is always returned as a FormData instance using bracket notation.
126
- *
127
- * @default false
128
- */
129
- asFormData?: boolean | undefined;
130
- }
131
- interface OpenAPISerializerOptions extends OpenAPIJsonSerializerOptions {
132
- /**
133
- * Options for bracket notation serializer, like maxDeserializingEmptySlots
134
- */
135
- bracketNotation?: BracketNotationSerializerOptions | undefined;
136
- /**
137
- * Default options for serialize method
138
- */
139
- serialize?: OpenAPISerializerSerializeOptions | undefined;
140
- }
141
- /**
142
- * Handles one-way serialization of oRPC payloads into JSON-friendly formats,
143
- * partially supporting complex data types beyond plain JSON such as `Date`, `BigInt`, and `Set`.
144
- *
145
- * @see {@link https://orpc.dev/docs/openapi/serializer | OpenAPI Serializer}
146
- */
147
- declare class OpenAPISerializer extends OpenAPIJsonSerializer {
148
- private readonly bracketNotation;
149
- private readonly defaultSerializeOptions;
150
- constructor({ bracketNotation, serialize, ...options }?: OpenAPISerializerOptions);
151
- serialize(data: unknown, options?: OpenAPISerializerSerializeOptions): StandardBody;
152
- private serializePayload;
153
- deserialize(data: StandardBody): unknown;
154
- }
155
-
156
- export { OpenAPISerializer as O, OpenAPIJsonSerializer as a, BracketNotationSerializer as b };
157
- export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };