@orpc/openapi-client 0.46.0 → 1.0.0-beta.1
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.
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
|
33
33
|
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
|
34
34
|
- **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
|
|
35
|
-
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
|
|
35
|
+
- **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
|
|
36
36
|
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
|
37
37
|
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
|
38
38
|
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
|
@@ -55,6 +55,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
55
55
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
56
56
|
- [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
|
|
57
57
|
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
|
58
|
+
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
|
59
|
+
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
|
58
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
59
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
60
62
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import { Segment } from '@orpc/shared';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
declare class
|
|
5
|
-
serialize(data: unknown, segments?: Segment[], result?:
|
|
6
|
-
deserialize(serialized:
|
|
3
|
+
type StandardBracketNotationSerialized = [string, unknown][];
|
|
4
|
+
declare class StandardBracketNotationSerializer {
|
|
5
|
+
serialize(data: unknown, segments?: Segment[], result?: StandardBracketNotationSerialized): StandardBracketNotationSerialized;
|
|
6
|
+
deserialize(serialized: StandardBracketNotationSerialized): Record<string, unknown> | unknown[];
|
|
7
7
|
stringifyPath(segments: readonly Segment[]): string;
|
|
8
8
|
parsePath(path: string): string[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
type
|
|
12
|
-
|
|
11
|
+
type StandardOpenAPIJsonSerialized = [json: unknown, hasBlob: boolean];
|
|
12
|
+
interface StandardOpenAPICustomJsonSerializer {
|
|
13
|
+
condition(data: unknown): boolean;
|
|
14
|
+
serialize(data: any): unknown;
|
|
15
|
+
}
|
|
16
|
+
interface StandardOpenAPIJsonSerializerOptions {
|
|
17
|
+
customJsonSerializers?: readonly StandardOpenAPICustomJsonSerializer[];
|
|
18
|
+
}
|
|
19
|
+
declare class StandardOpenAPIJsonSerializer {
|
|
20
|
+
private readonly customSerializers;
|
|
21
|
+
constructor(options?: StandardOpenAPIJsonSerializerOptions);
|
|
13
22
|
serialize(data: unknown, hasBlobRef?: {
|
|
14
23
|
value: boolean;
|
|
15
|
-
}):
|
|
24
|
+
}): StandardOpenAPIJsonSerialized;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
declare class
|
|
27
|
+
declare class StandardOpenAPISerializer {
|
|
19
28
|
#private;
|
|
20
29
|
private readonly jsonSerializer;
|
|
21
30
|
private readonly bracketNotation;
|
|
22
|
-
constructor(jsonSerializer
|
|
31
|
+
constructor(jsonSerializer: StandardOpenAPIJsonSerializer, bracketNotation: StandardBracketNotationSerializer);
|
|
23
32
|
serialize(data: unknown): unknown;
|
|
24
33
|
deserialize(data: unknown): unknown;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
export { type
|
|
36
|
+
export { type StandardBracketNotationSerialized, StandardBracketNotationSerializer, type StandardOpenAPICustomJsonSerializer, type StandardOpenAPIJsonSerialized, StandardOpenAPIJsonSerializer, type StandardOpenAPIJsonSerializerOptions, StandardOpenAPISerializer };
|
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
import { Segment } from '@orpc/shared';
|
|
2
2
|
|
|
3
|
-
type
|
|
4
|
-
declare class
|
|
5
|
-
serialize(data: unknown, segments?: Segment[], result?:
|
|
6
|
-
deserialize(serialized:
|
|
3
|
+
type StandardBracketNotationSerialized = [string, unknown][];
|
|
4
|
+
declare class StandardBracketNotationSerializer {
|
|
5
|
+
serialize(data: unknown, segments?: Segment[], result?: StandardBracketNotationSerialized): StandardBracketNotationSerialized;
|
|
6
|
+
deserialize(serialized: StandardBracketNotationSerialized): Record<string, unknown> | unknown[];
|
|
7
7
|
stringifyPath(segments: readonly Segment[]): string;
|
|
8
8
|
parsePath(path: string): string[];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
type
|
|
12
|
-
|
|
11
|
+
type StandardOpenAPIJsonSerialized = [json: unknown, hasBlob: boolean];
|
|
12
|
+
interface StandardOpenAPICustomJsonSerializer {
|
|
13
|
+
condition(data: unknown): boolean;
|
|
14
|
+
serialize(data: any): unknown;
|
|
15
|
+
}
|
|
16
|
+
interface StandardOpenAPIJsonSerializerOptions {
|
|
17
|
+
customJsonSerializers?: readonly StandardOpenAPICustomJsonSerializer[];
|
|
18
|
+
}
|
|
19
|
+
declare class StandardOpenAPIJsonSerializer {
|
|
20
|
+
private readonly customSerializers;
|
|
21
|
+
constructor(options?: StandardOpenAPIJsonSerializerOptions);
|
|
13
22
|
serialize(data: unknown, hasBlobRef?: {
|
|
14
23
|
value: boolean;
|
|
15
|
-
}):
|
|
24
|
+
}): StandardOpenAPIJsonSerialized;
|
|
16
25
|
}
|
|
17
26
|
|
|
18
|
-
declare class
|
|
27
|
+
declare class StandardOpenAPISerializer {
|
|
19
28
|
#private;
|
|
20
29
|
private readonly jsonSerializer;
|
|
21
30
|
private readonly bracketNotation;
|
|
22
|
-
constructor(jsonSerializer
|
|
31
|
+
constructor(jsonSerializer: StandardOpenAPIJsonSerializer, bracketNotation: StandardBracketNotationSerializer);
|
|
23
32
|
serialize(data: unknown): unknown;
|
|
24
33
|
deserialize(data: unknown): unknown;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
|
-
export { type
|
|
36
|
+
export { type StandardBracketNotationSerialized, StandardBracketNotationSerializer, type StandardOpenAPICustomJsonSerializer, type StandardOpenAPIJsonSerialized, StandardOpenAPIJsonSerializer, type StandardOpenAPIJsonSerializerOptions, StandardOpenAPISerializer };
|
|
@@ -2,7 +2,7 @@ import { isObject, isAsyncIteratorObject } from '@orpc/shared';
|
|
|
2
2
|
import { mapEventIterator, toORPCError, ORPCError } from '@orpc/client';
|
|
3
3
|
import { ErrorEvent } from '@orpc/standard-server';
|
|
4
4
|
|
|
5
|
-
class
|
|
5
|
+
class StandardBracketNotationSerializer {
|
|
6
6
|
serialize(data, segments = [], result = []) {
|
|
7
7
|
if (Array.isArray(data)) {
|
|
8
8
|
data.forEach((item, i) => {
|
|
@@ -121,8 +121,18 @@ function isValidArrayIndex(value) {
|
|
|
121
121
|
return /^0$|^[1-9]\d*$/.test(value);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
class
|
|
124
|
+
class StandardOpenAPIJsonSerializer {
|
|
125
|
+
customSerializers;
|
|
126
|
+
constructor(options = {}) {
|
|
127
|
+
this.customSerializers = options.customJsonSerializers ?? [];
|
|
128
|
+
}
|
|
125
129
|
serialize(data, hasBlobRef = { value: false }) {
|
|
130
|
+
for (const custom of this.customSerializers) {
|
|
131
|
+
if (custom.condition(data)) {
|
|
132
|
+
const result = this.serialize(custom.serialize(data), hasBlobRef);
|
|
133
|
+
return result;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
126
136
|
if (data instanceof Blob) {
|
|
127
137
|
hasBlobRef.value = true;
|
|
128
138
|
return [data, hasBlobRef.value];
|
|
@@ -157,8 +167,8 @@ class OpenAPIJsonSerializer {
|
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
|
|
160
|
-
class
|
|
161
|
-
constructor(jsonSerializer
|
|
170
|
+
class StandardOpenAPISerializer {
|
|
171
|
+
constructor(jsonSerializer, bracketNotation) {
|
|
162
172
|
this.jsonSerializer = jsonSerializer;
|
|
163
173
|
this.bracketNotation = bracketNotation;
|
|
164
174
|
}
|
|
@@ -213,4 +223,4 @@ class OpenAPISerializer {
|
|
|
213
223
|
}
|
|
214
224
|
}
|
|
215
225
|
|
|
216
|
-
export {
|
|
226
|
+
export { StandardBracketNotationSerializer, StandardOpenAPIJsonSerializer, StandardOpenAPISerializer };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi-client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "1.0.0-beta.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@orpc/shared": "0.
|
|
33
|
-
"@orpc/client": "0.
|
|
34
|
-
"@orpc/standard-server": "0.
|
|
32
|
+
"@orpc/shared": "1.0.0-beta.1",
|
|
33
|
+
"@orpc/client": "1.0.0-beta.1",
|
|
34
|
+
"@orpc/standard-server": "1.0.0-beta.1"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "unbuild",
|