@orpc/openapi 2.0.0-beta.4 → 2.0.0-beta.41

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 (45) hide show
  1. package/README.md +97 -94
  2. package/dist/adapters/aws-lambda/index.d.mts +26 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +26 -0
  4. package/dist/adapters/aws-lambda/index.mjs +21 -0
  5. package/dist/adapters/fastify/index.d.mts +23 -0
  6. package/dist/adapters/fastify/index.d.ts +23 -0
  7. package/dist/adapters/fastify/index.mjs +21 -0
  8. package/dist/adapters/fetch/index.d.mts +15 -5
  9. package/dist/adapters/fetch/index.d.ts +15 -5
  10. package/dist/adapters/fetch/index.mjs +6 -6
  11. package/dist/adapters/node/index.d.mts +9 -4
  12. package/dist/adapters/node/index.d.ts +9 -4
  13. package/dist/adapters/node/index.mjs +4 -4
  14. package/dist/adapters/standard/index.d.mts +10 -46
  15. package/dist/adapters/standard/index.d.ts +10 -46
  16. package/dist/adapters/standard/index.mjs +6 -6
  17. package/dist/extensions/route.d.mts +5 -7
  18. package/dist/extensions/route.d.ts +5 -7
  19. package/dist/helpers/index.d.mts +9 -1
  20. package/dist/helpers/index.d.ts +9 -1
  21. package/dist/helpers/index.mjs +1 -1
  22. package/dist/index.d.mts +77 -45
  23. package/dist/index.d.ts +77 -45
  24. package/dist/index.mjs +614 -765
  25. package/dist/plugins/index.d.mts +35 -6
  26. package/dist/plugins/index.d.ts +35 -6
  27. package/dist/plugins/index.mjs +15 -10
  28. package/dist/shared/{openapi.B2SK0ZAr.mjs → openapi.8cM6P94D.mjs} +32 -36
  29. package/dist/shared/openapi.B2G-HeFn.mjs +123 -0
  30. package/dist/shared/{openapi.7vgmPxca.d.ts → openapi.BCNfESWr.d.ts} +12 -9
  31. package/dist/shared/{openapi.CX6Ri5dP.d.mts → openapi.BgpM--nz.d.mts} +12 -9
  32. package/dist/shared/{openapi.CTlpLuKN.mjs → openapi.Bi1qxGF9.mjs} +102 -54
  33. package/dist/shared/{openapi.DmAa7YPO.mjs → openapi.Bu_PfTtX.mjs} +140 -61
  34. package/dist/shared/{openapi.C7m7NAmH.d.mts → openapi.C2LayTNZ.d.mts} +16 -5
  35. package/dist/shared/{openapi.C7m7NAmH.d.ts → openapi.C2LayTNZ.d.ts} +16 -5
  36. package/dist/shared/openapi.C6FFC29v.d.mts +31 -0
  37. package/dist/shared/openapi.C6FFC29v.d.ts +31 -0
  38. package/dist/shared/{openapi.BQzzr4-4.d.ts → openapi.Cem81Zhm.d.mts} +41 -12
  39. package/dist/shared/{openapi.BcEtAxQj.d.mts → openapi.Cem81Zhm.d.ts} +41 -12
  40. package/dist/shared/openapi.Cg9h6jpm.d.mts +45 -0
  41. package/dist/shared/openapi.D0yWs-uW.d.ts +45 -0
  42. package/package.json +57 -17
  43. package/dist/shared/openapi.Bt87OzTt.mjs +0 -131
  44. package/dist/shared/openapi.CYgMBSUF.d.mts +0 -18
  45. package/dist/shared/openapi.CYgMBSUF.d.ts +0 -18
@@ -1,131 +0,0 @@
1
- import { isPlainObject, NullProtoObj } from '@orpc/shared';
2
-
3
- class BracketNotationSerializer {
4
- maxExplicitDeserializingArrayIndex;
5
- constructor(options = {}) {
6
- this.maxExplicitDeserializingArrayIndex = options.maxExplicitDeserializingArrayIndex ?? 999;
7
- }
8
- serialize(data) {
9
- return this.internalSerialize(data, [], []);
10
- }
11
- internalSerialize(data, segments, result) {
12
- if (Array.isArray(data)) {
13
- data.forEach((item, i) => {
14
- this.internalSerialize(item, [...segments, i], result);
15
- });
16
- } else if (isPlainObject(data)) {
17
- for (const key in data) {
18
- this.internalSerialize(data[key], [...segments, key], result);
19
- }
20
- } else {
21
- result.push([this.stringifyPath(segments), data]);
22
- }
23
- return result;
24
- }
25
- deserialize(serialized) {
26
- if (serialized.length === 0) {
27
- return new NullProtoObj();
28
- }
29
- const arrayPushStyles = /* @__PURE__ */ new WeakSet();
30
- const ref = { value: new NullProtoObj() };
31
- for (const [path, value] of serialized) {
32
- const segments = this.parsePath(path);
33
- let currentRef = ref;
34
- let nextSegment = "value";
35
- segments.forEach((segment, i) => {
36
- if (!Array.isArray(currentRef[nextSegment]) && !isPlainObject(currentRef[nextSegment])) {
37
- currentRef[nextSegment] = [];
38
- }
39
- if (i !== segments.length - 1) {
40
- if (Array.isArray(currentRef[nextSegment]) && !internalIsValidArrayIndex(segment, this.maxExplicitDeserializingArrayIndex)) {
41
- if (arrayPushStyles.has(currentRef[nextSegment])) {
42
- arrayPushStyles.delete(currentRef[nextSegment]);
43
- currentRef[nextSegment] = internalPushStyleArrayToObject(currentRef[nextSegment]);
44
- } else {
45
- currentRef[nextSegment] = internalArrayToObject(currentRef[nextSegment]);
46
- }
47
- }
48
- } else {
49
- if (Array.isArray(currentRef[nextSegment])) {
50
- if (segment === "") {
51
- if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
52
- currentRef[nextSegment] = internalArrayToObject(currentRef[nextSegment]);
53
- }
54
- } else {
55
- if (arrayPushStyles.has(currentRef[nextSegment])) {
56
- arrayPushStyles.delete(currentRef[nextSegment]);
57
- currentRef[nextSegment] = internalPushStyleArrayToObject(currentRef[nextSegment]);
58
- } else if (!internalIsValidArrayIndex(segment, this.maxExplicitDeserializingArrayIndex)) {
59
- currentRef[nextSegment] = internalArrayToObject(currentRef[nextSegment]);
60
- }
61
- }
62
- }
63
- }
64
- currentRef = currentRef[nextSegment];
65
- nextSegment = segment;
66
- });
67
- if (Array.isArray(currentRef) && nextSegment === "") {
68
- arrayPushStyles.add(currentRef);
69
- currentRef.push(value);
70
- } else if (nextSegment in currentRef) {
71
- if (Array.isArray(currentRef[nextSegment])) {
72
- currentRef[nextSegment].push(value);
73
- } else {
74
- currentRef[nextSegment] = [currentRef[nextSegment], value];
75
- }
76
- } else {
77
- currentRef[nextSegment] = value;
78
- }
79
- }
80
- return ref.value;
81
- }
82
- stringifyPath(segments) {
83
- return segments.reduce((result, segment, i) => {
84
- if (i === 0) {
85
- return segment.toString();
86
- }
87
- return `${result}[${segment}]`;
88
- }, "");
89
- }
90
- parsePath(path) {
91
- const segments = [];
92
- let inBrackets = false;
93
- let currentSegment = "";
94
- for (let i = 0; i < path.length; i++) {
95
- const char = path[i];
96
- const nextChar = path[i + 1];
97
- if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[")) {
98
- if (nextChar === void 0) {
99
- inBrackets = false;
100
- }
101
- segments.push(currentSegment);
102
- currentSegment = "";
103
- i++;
104
- } else if (segments.length === 0 && char === "[") {
105
- inBrackets = true;
106
- segments.push(currentSegment);
107
- currentSegment = "";
108
- } else {
109
- currentSegment += char;
110
- }
111
- }
112
- return inBrackets || segments.length === 0 ? [path] : segments;
113
- }
114
- }
115
- function internalIsValidArrayIndex(value, maxIndex) {
116
- return /^0$|^[1-9]\d*$/.test(value) && Number(value) <= maxIndex;
117
- }
118
- function internalArrayToObject(array) {
119
- const obj = new NullProtoObj();
120
- array.forEach((item, i) => {
121
- obj[i] = item;
122
- });
123
- return obj;
124
- }
125
- function internalPushStyleArrayToObject(array) {
126
- const obj = new NullProtoObj();
127
- obj[""] = array.length === 1 ? array[0] : array;
128
- return obj;
129
- }
130
-
131
- export { BracketNotationSerializer as B };
@@ -1,18 +0,0 @@
1
- import { OpenAPIV3_1 } from '@hey-api/spec-types';
2
- import { ORPCError, AnyNestedClient, Client } from '@orpc/client';
3
-
4
- type OpenAPIDocument = OpenAPIV3_1.Document;
5
- type OpenAPIOperationObject = OpenAPIV3_1.OperationObject;
6
- type JsonifiedValue<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends null ? T : T extends undefined ? T : T extends Array<unknown> ? JsonifiedArray<T> : T extends Record<string, unknown> ? {
7
- [K in keyof T]: JsonifiedValue<T[K]>;
8
- } : T extends Date ? string : T extends bigint ? string : T extends File ? File : T extends Blob ? Blob : T extends RegExp ? string : T extends URL ? string : T extends Map<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends Set<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown;
9
- type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends Array<infer U> ? Array<JsonifiedValue<U>> : unknown;
10
- type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
11
- /**
12
- * Convert types that JSON not support to corresponding json types
13
- */
14
- type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
15
- [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
16
- };
17
-
18
- export type { JsonifiedValue as J, OpenAPIOperationObject as O, OpenAPIDocument as a, JsonifiedClientError as b, JsonifiedClient as c, JsonifiedArray as d };
@@ -1,18 +0,0 @@
1
- import { OpenAPIV3_1 } from '@hey-api/spec-types';
2
- import { ORPCError, AnyNestedClient, Client } from '@orpc/client';
3
-
4
- type OpenAPIDocument = OpenAPIV3_1.Document;
5
- type OpenAPIOperationObject = OpenAPIV3_1.OperationObject;
6
- type JsonifiedValue<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends null ? T : T extends undefined ? T : T extends Array<unknown> ? JsonifiedArray<T> : T extends Record<string, unknown> ? {
7
- [K in keyof T]: JsonifiedValue<T[K]>;
8
- } : T extends Date ? string : T extends bigint ? string : T extends File ? File : T extends Blob ? Blob : T extends RegExp ? string : T extends URL ? string : T extends Map<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends Set<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown;
9
- type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [U extends undefined ? null : JsonifiedValue<U>, ...JsonifiedArray<V>] : T extends Array<infer U> ? Array<JsonifiedValue<U>> : unknown;
10
- type JsonifiedClientError<T> = T extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : T;
11
- /**
12
- * Convert types that JSON not support to corresponding json types
13
- */
14
- type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, JsonifiedClientError<UError>> : {
15
- [K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
16
- };
17
-
18
- export type { JsonifiedValue as J, OpenAPIOperationObject as O, OpenAPIDocument as a, JsonifiedClientError as b, JsonifiedClient as c, JsonifiedArray as d };