@orpc/client 0.0.0-next.84e58e0 → 0.0.0-next.85cc28f
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 +15 -2
- package/dist/adapters/fetch/index.d.mts +20 -97
- package/dist/adapters/fetch/index.d.ts +20 -97
- package/dist/adapters/fetch/index.mjs +23 -112
- package/dist/adapters/standard/index.d.mts +10 -0
- package/dist/adapters/standard/index.d.ts +10 -0
- package/dist/adapters/standard/index.mjs +4 -0
- package/dist/index.d.mts +20 -18
- package/dist/index.d.ts +20 -18
- package/dist/index.mjs +35 -33
- package/dist/plugins/index.d.mts +65 -0
- package/dist/plugins/index.d.ts +65 -0
- package/dist/plugins/index.mjs +131 -0
- package/dist/shared/client.5813Ufvs.d.mts +39 -0
- package/dist/shared/client.Bt94sjrK.d.mts +103 -0
- package/dist/shared/client.C0lT7w02.d.mts +30 -0
- package/dist/shared/client.C0lT7w02.d.ts +30 -0
- package/dist/shared/client.D-jrSuDb.d.ts +103 -0
- package/dist/shared/client.DSPm2IGZ.mjs +337 -0
- package/dist/shared/client.grRbC25r.d.ts +39 -0
- package/dist/shared/{client.Ly4zGQrc.mjs → client.jKEwIsRd.mjs} +6 -96
- package/package.json +13 -13
- package/dist/openapi/index.d.mts +0 -27
- package/dist/openapi/index.d.ts +0 -27
- package/dist/openapi/index.mjs +0 -213
- package/dist/rpc/index.d.mts +0 -22
- package/dist/rpc/index.d.ts +0 -22
- package/dist/rpc/index.mjs +0 -4
- package/dist/shared/client.DHJ8vRIG.mjs +0 -192
- package/dist/shared/client.D_CzLDyB.d.mts +0 -42
- package/dist/shared/client.D_CzLDyB.d.ts +0 -42
package/dist/openapi/index.mjs
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { isObject, isAsyncIteratorObject } from '@orpc/shared';
|
|
2
|
-
import { ErrorEvent } from '@orpc/standard-server';
|
|
3
|
-
import { m as mapEventIterator, t as toORPCError, O as ORPCError } from '../shared/client.Ly4zGQrc.mjs';
|
|
4
|
-
|
|
5
|
-
class BracketNotationSerializer {
|
|
6
|
-
serialize(data, segments = [], result = []) {
|
|
7
|
-
if (Array.isArray(data)) {
|
|
8
|
-
data.forEach((item, i) => {
|
|
9
|
-
this.serialize(item, [...segments, i], result);
|
|
10
|
-
});
|
|
11
|
-
} else if (isObject(data)) {
|
|
12
|
-
for (const key in data) {
|
|
13
|
-
this.serialize(data[key], [...segments, key], result);
|
|
14
|
-
}
|
|
15
|
-
} else {
|
|
16
|
-
result.push([this.stringifyPath(segments), data]);
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
}
|
|
20
|
-
deserialize(serialized) {
|
|
21
|
-
const arrayPushStyles = /* @__PURE__ */ new WeakSet();
|
|
22
|
-
const ref = { value: [] };
|
|
23
|
-
for (const [path, value] of serialized) {
|
|
24
|
-
const segments = this.parsePath(path);
|
|
25
|
-
let currentRef = ref;
|
|
26
|
-
let nextSegment = "value";
|
|
27
|
-
segments.forEach((segment, i) => {
|
|
28
|
-
if (!Array.isArray(currentRef[nextSegment]) && !isObject(currentRef[nextSegment])) {
|
|
29
|
-
currentRef[nextSegment] = [];
|
|
30
|
-
}
|
|
31
|
-
if (i !== segments.length - 1) {
|
|
32
|
-
if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment)) {
|
|
33
|
-
currentRef[nextSegment] = { ...currentRef[nextSegment] };
|
|
34
|
-
}
|
|
35
|
-
} else {
|
|
36
|
-
if (Array.isArray(currentRef[nextSegment])) {
|
|
37
|
-
if (segment === "") {
|
|
38
|
-
if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) {
|
|
39
|
-
currentRef[nextSegment] = { ...currentRef[nextSegment] };
|
|
40
|
-
}
|
|
41
|
-
} else {
|
|
42
|
-
if (arrayPushStyles.has(currentRef[nextSegment])) {
|
|
43
|
-
currentRef[nextSegment] = { "": currentRef[nextSegment].at(-1) };
|
|
44
|
-
} else if (!isValidArrayIndex(segment)) {
|
|
45
|
-
currentRef[nextSegment] = { ...currentRef[nextSegment] };
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
currentRef = currentRef[nextSegment];
|
|
51
|
-
nextSegment = segment;
|
|
52
|
-
});
|
|
53
|
-
if (Array.isArray(currentRef)) {
|
|
54
|
-
if (nextSegment === "") {
|
|
55
|
-
arrayPushStyles.add(currentRef);
|
|
56
|
-
currentRef.push(value);
|
|
57
|
-
} else {
|
|
58
|
-
currentRef[Number(nextSegment)] = value;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
currentRef[nextSegment] = value;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
return ref.value;
|
|
65
|
-
}
|
|
66
|
-
stringifyPath(segments) {
|
|
67
|
-
return segments.map((segment) => {
|
|
68
|
-
return segment.toString().replace(/[\\[\]]/g, (match) => {
|
|
69
|
-
switch (match) {
|
|
70
|
-
case "\\":
|
|
71
|
-
return "\\\\";
|
|
72
|
-
case "[":
|
|
73
|
-
return "\\[";
|
|
74
|
-
case "]":
|
|
75
|
-
return "\\]";
|
|
76
|
-
/* v8 ignore next 2 */
|
|
77
|
-
default:
|
|
78
|
-
return match;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}).reduce((result, segment, i) => {
|
|
82
|
-
if (i === 0) {
|
|
83
|
-
return segment;
|
|
84
|
-
}
|
|
85
|
-
return `${result}[${segment}]`;
|
|
86
|
-
}, "");
|
|
87
|
-
}
|
|
88
|
-
parsePath(path) {
|
|
89
|
-
const segments = [];
|
|
90
|
-
let inBrackets = false;
|
|
91
|
-
let currentSegment = "";
|
|
92
|
-
let backslashCount = 0;
|
|
93
|
-
for (let i = 0; i < path.length; i++) {
|
|
94
|
-
const char = path[i];
|
|
95
|
-
const nextChar = path[i + 1];
|
|
96
|
-
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) {
|
|
97
|
-
if (nextChar === void 0) {
|
|
98
|
-
inBrackets = false;
|
|
99
|
-
}
|
|
100
|
-
segments.push(currentSegment);
|
|
101
|
-
currentSegment = "";
|
|
102
|
-
i++;
|
|
103
|
-
} else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) {
|
|
104
|
-
inBrackets = true;
|
|
105
|
-
segments.push(currentSegment);
|
|
106
|
-
currentSegment = "";
|
|
107
|
-
} else if (char === "\\") {
|
|
108
|
-
backslashCount++;
|
|
109
|
-
} else {
|
|
110
|
-
currentSegment += "\\".repeat(backslashCount / 2) + char;
|
|
111
|
-
backslashCount = 0;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return inBrackets || segments.length === 0 ? [path] : segments;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function isValidArrayIndex(value) {
|
|
118
|
-
return /^0$|^[1-9]\d*$/.test(value);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
class OpenAPIJsonSerializer {
|
|
122
|
-
serialize(data, hasBlobRef = { value: false }) {
|
|
123
|
-
if (data instanceof Blob) {
|
|
124
|
-
hasBlobRef.value = true;
|
|
125
|
-
return [data, hasBlobRef.value];
|
|
126
|
-
}
|
|
127
|
-
if (data instanceof Set) {
|
|
128
|
-
return this.serialize(Array.from(data), hasBlobRef);
|
|
129
|
-
}
|
|
130
|
-
if (data instanceof Map) {
|
|
131
|
-
return this.serialize(Array.from(data.entries()), hasBlobRef);
|
|
132
|
-
}
|
|
133
|
-
if (Array.isArray(data)) {
|
|
134
|
-
const json = data.map((v) => v === void 0 ? null : this.serialize(v, hasBlobRef)[0]);
|
|
135
|
-
return [json, hasBlobRef.value];
|
|
136
|
-
}
|
|
137
|
-
if (isObject(data)) {
|
|
138
|
-
const json = {};
|
|
139
|
-
for (const k in data) {
|
|
140
|
-
json[k] = this.serialize(data[k], hasBlobRef)[0];
|
|
141
|
-
}
|
|
142
|
-
return [json, hasBlobRef.value];
|
|
143
|
-
}
|
|
144
|
-
if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
|
|
145
|
-
return [data.toString(), hasBlobRef.value];
|
|
146
|
-
}
|
|
147
|
-
if (data instanceof Date) {
|
|
148
|
-
return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
|
|
149
|
-
}
|
|
150
|
-
if (Number.isNaN(data)) {
|
|
151
|
-
return [null, hasBlobRef.value];
|
|
152
|
-
}
|
|
153
|
-
return [data, hasBlobRef.value];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
class OpenAPISerializer {
|
|
158
|
-
constructor(jsonSerializer = new OpenAPIJsonSerializer(), bracketNotation = new BracketNotationSerializer()) {
|
|
159
|
-
this.jsonSerializer = jsonSerializer;
|
|
160
|
-
this.bracketNotation = bracketNotation;
|
|
161
|
-
}
|
|
162
|
-
serialize(data) {
|
|
163
|
-
if (isAsyncIteratorObject(data)) {
|
|
164
|
-
return mapEventIterator(data, {
|
|
165
|
-
value: async (value) => this.#serialize(value, false),
|
|
166
|
-
error: async (e) => {
|
|
167
|
-
return new ErrorEvent({
|
|
168
|
-
data: this.#serialize(toORPCError(e).toJSON(), false),
|
|
169
|
-
cause: e
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
return this.#serialize(data, true);
|
|
175
|
-
}
|
|
176
|
-
#serialize(data, enableFormData) {
|
|
177
|
-
if (data instanceof Blob || data === void 0) {
|
|
178
|
-
return data;
|
|
179
|
-
}
|
|
180
|
-
const [json, hasBlob] = this.jsonSerializer.serialize(data);
|
|
181
|
-
if (!enableFormData || !hasBlob) {
|
|
182
|
-
return json;
|
|
183
|
-
}
|
|
184
|
-
const form = new FormData();
|
|
185
|
-
for (const [path, value] of this.bracketNotation.serialize(json)) {
|
|
186
|
-
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
187
|
-
form.append(path, value.toString());
|
|
188
|
-
} else if (value instanceof Blob) {
|
|
189
|
-
form.append(path, value);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return form;
|
|
193
|
-
}
|
|
194
|
-
deserialize(data) {
|
|
195
|
-
if (data instanceof URLSearchParams || data instanceof FormData) {
|
|
196
|
-
return this.bracketNotation.deserialize(Array.from(data.entries()));
|
|
197
|
-
}
|
|
198
|
-
if (isAsyncIteratorObject(data)) {
|
|
199
|
-
return mapEventIterator(data, {
|
|
200
|
-
value: async (value) => value,
|
|
201
|
-
error: async (e) => {
|
|
202
|
-
if (e instanceof ErrorEvent && ORPCError.isValidJSON(e.data)) {
|
|
203
|
-
return ORPCError.fromJSON(e.data, { cause: e });
|
|
204
|
-
}
|
|
205
|
-
return e;
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return data;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export { BracketNotationSerializer, OpenAPIJsonSerializer, OpenAPISerializer };
|
package/dist/rpc/index.d.mts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Segment } from '@orpc/shared';
|
|
2
|
-
|
|
3
|
-
type RPCJsonSerializedMeta = [
|
|
4
|
-
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7,
|
|
5
|
-
Segment[]
|
|
6
|
-
][];
|
|
7
|
-
type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
|
|
8
|
-
declare class RPCJsonSerializer {
|
|
9
|
-
serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
|
|
10
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
|
|
11
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare class RPCSerializer {
|
|
15
|
-
#private;
|
|
16
|
-
private readonly jsonSerializer;
|
|
17
|
-
constructor(jsonSerializer?: RPCJsonSerializer);
|
|
18
|
-
serialize(data: unknown): unknown;
|
|
19
|
-
deserialize(data: unknown): unknown;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { type RPCJsonSerialized, type RPCJsonSerializedMeta, RPCJsonSerializer, RPCSerializer };
|
package/dist/rpc/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Segment } from '@orpc/shared';
|
|
2
|
-
|
|
3
|
-
type RPCJsonSerializedMeta = [
|
|
4
|
-
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7,
|
|
5
|
-
Segment[]
|
|
6
|
-
][];
|
|
7
|
-
type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
|
|
8
|
-
declare class RPCJsonSerializer {
|
|
9
|
-
serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
|
|
10
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
|
|
11
|
-
deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare class RPCSerializer {
|
|
15
|
-
#private;
|
|
16
|
-
private readonly jsonSerializer;
|
|
17
|
-
constructor(jsonSerializer?: RPCJsonSerializer);
|
|
18
|
-
serialize(data: unknown): unknown;
|
|
19
|
-
deserialize(data: unknown): unknown;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export { type RPCJsonSerialized, type RPCJsonSerializedMeta, RPCJsonSerializer, RPCSerializer };
|
package/dist/rpc/index.mjs
DELETED
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { isObject, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
2
|
-
import { ErrorEvent } from '@orpc/standard-server';
|
|
3
|
-
import { m as mapEventIterator, t as toORPCError, O as ORPCError } from './client.Ly4zGQrc.mjs';
|
|
4
|
-
|
|
5
|
-
class RPCJsonSerializer {
|
|
6
|
-
serialize(data, segments = [], meta = [], maps = [], blobs = []) {
|
|
7
|
-
if (data instanceof Blob) {
|
|
8
|
-
maps.push(segments);
|
|
9
|
-
blobs.push(data);
|
|
10
|
-
return [data, meta, maps, blobs];
|
|
11
|
-
}
|
|
12
|
-
if (typeof data === "bigint") {
|
|
13
|
-
meta.push([0, segments]);
|
|
14
|
-
return [data.toString(), meta, maps, blobs];
|
|
15
|
-
}
|
|
16
|
-
if (data instanceof Date) {
|
|
17
|
-
meta.push([1, segments]);
|
|
18
|
-
if (Number.isNaN(data.getTime())) {
|
|
19
|
-
return [null, meta, maps, blobs];
|
|
20
|
-
}
|
|
21
|
-
return [data.toISOString(), meta, maps, blobs];
|
|
22
|
-
}
|
|
23
|
-
if (Number.isNaN(data)) {
|
|
24
|
-
meta.push([2, segments]);
|
|
25
|
-
return [null, meta, maps, blobs];
|
|
26
|
-
}
|
|
27
|
-
if (data instanceof URL) {
|
|
28
|
-
meta.push([4, segments]);
|
|
29
|
-
return [data.toString(), meta, maps, blobs];
|
|
30
|
-
}
|
|
31
|
-
if (data instanceof RegExp) {
|
|
32
|
-
meta.push([5, segments]);
|
|
33
|
-
return [data.toString(), meta, maps, blobs];
|
|
34
|
-
}
|
|
35
|
-
if (data instanceof Set) {
|
|
36
|
-
const result = this.serialize(Array.from(data), segments, meta, maps, blobs);
|
|
37
|
-
meta.push([6, segments]);
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
if (data instanceof Map) {
|
|
41
|
-
const result = this.serialize(Array.from(data.entries()), segments, meta, maps, blobs);
|
|
42
|
-
meta.push([7, segments]);
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
if (Array.isArray(data)) {
|
|
46
|
-
const json = data.map((v, i) => {
|
|
47
|
-
if (v === void 0) {
|
|
48
|
-
meta.push([3, [...segments, i]]);
|
|
49
|
-
return v;
|
|
50
|
-
}
|
|
51
|
-
return this.serialize(v, [...segments, i], meta, maps, blobs)[0];
|
|
52
|
-
});
|
|
53
|
-
return [json, meta, maps, blobs];
|
|
54
|
-
}
|
|
55
|
-
if (isObject(data)) {
|
|
56
|
-
const json = {};
|
|
57
|
-
for (const k in data) {
|
|
58
|
-
json[k] = this.serialize(data[k], [...segments, k], meta, maps, blobs)[0];
|
|
59
|
-
}
|
|
60
|
-
return [json, meta, maps, blobs];
|
|
61
|
-
}
|
|
62
|
-
return [data, meta, maps, blobs];
|
|
63
|
-
}
|
|
64
|
-
deserialize(json, meta, maps, getBlob) {
|
|
65
|
-
const ref = { data: json };
|
|
66
|
-
if (maps && getBlob) {
|
|
67
|
-
maps.forEach((segments, i) => {
|
|
68
|
-
let currentRef = ref;
|
|
69
|
-
let preSegment = "data";
|
|
70
|
-
segments.forEach((segment) => {
|
|
71
|
-
currentRef = currentRef[preSegment];
|
|
72
|
-
preSegment = segment;
|
|
73
|
-
});
|
|
74
|
-
currentRef[preSegment] = getBlob(i);
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
for (const [type, segments] of meta) {
|
|
78
|
-
let currentRef = ref;
|
|
79
|
-
let preSegment = "data";
|
|
80
|
-
segments.forEach((segment) => {
|
|
81
|
-
currentRef = currentRef[preSegment];
|
|
82
|
-
preSegment = segment;
|
|
83
|
-
});
|
|
84
|
-
switch (type) {
|
|
85
|
-
case 0:
|
|
86
|
-
currentRef[preSegment] = BigInt(currentRef[preSegment]);
|
|
87
|
-
break;
|
|
88
|
-
case 1:
|
|
89
|
-
currentRef[preSegment] = new Date(currentRef[preSegment] ?? "Invalid Date");
|
|
90
|
-
break;
|
|
91
|
-
case 2:
|
|
92
|
-
currentRef[preSegment] = Number.NaN;
|
|
93
|
-
break;
|
|
94
|
-
case 3:
|
|
95
|
-
currentRef[preSegment] = void 0;
|
|
96
|
-
break;
|
|
97
|
-
case 4:
|
|
98
|
-
currentRef[preSegment] = new URL(currentRef[preSegment]);
|
|
99
|
-
break;
|
|
100
|
-
case 5: {
|
|
101
|
-
const [, pattern, flags] = currentRef[preSegment].match(/^\/(.*)\/([a-z]*)$/);
|
|
102
|
-
currentRef[preSegment] = new RegExp(pattern, flags);
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case 6:
|
|
106
|
-
currentRef[preSegment] = new Set(currentRef[preSegment]);
|
|
107
|
-
break;
|
|
108
|
-
case 7:
|
|
109
|
-
currentRef[preSegment] = new Map(currentRef[preSegment]);
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return ref.data;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class RPCSerializer {
|
|
118
|
-
constructor(jsonSerializer = new RPCJsonSerializer()) {
|
|
119
|
-
this.jsonSerializer = jsonSerializer;
|
|
120
|
-
}
|
|
121
|
-
serialize(data) {
|
|
122
|
-
if (isAsyncIteratorObject(data)) {
|
|
123
|
-
return mapEventIterator(data, {
|
|
124
|
-
value: async (value) => this.#serialize(value, false),
|
|
125
|
-
error: async (e) => {
|
|
126
|
-
return new ErrorEvent({
|
|
127
|
-
data: this.#serialize(toORPCError(e).toJSON(), false),
|
|
128
|
-
cause: e
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
return this.#serialize(data, true);
|
|
134
|
-
}
|
|
135
|
-
#serialize(data, enableFormData) {
|
|
136
|
-
if (data === void 0 || data instanceof Blob) {
|
|
137
|
-
return data;
|
|
138
|
-
}
|
|
139
|
-
const [json, meta_, maps, blobs] = this.jsonSerializer.serialize(data);
|
|
140
|
-
const meta = meta_.length === 0 ? void 0 : meta_;
|
|
141
|
-
if (!enableFormData || blobs.length === 0) {
|
|
142
|
-
return {
|
|
143
|
-
json,
|
|
144
|
-
meta
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
const form = new FormData();
|
|
148
|
-
form.set("data", stringifyJSON({ json, meta, maps }));
|
|
149
|
-
blobs.forEach((blob, i) => {
|
|
150
|
-
form.set(i.toString(), blob);
|
|
151
|
-
});
|
|
152
|
-
return form;
|
|
153
|
-
}
|
|
154
|
-
deserialize(data) {
|
|
155
|
-
if (isAsyncIteratorObject(data)) {
|
|
156
|
-
return mapEventIterator(data, {
|
|
157
|
-
value: async (value) => this.#deserialize(value),
|
|
158
|
-
error: async (e) => {
|
|
159
|
-
if (!(e instanceof ErrorEvent)) {
|
|
160
|
-
return e;
|
|
161
|
-
}
|
|
162
|
-
const deserialized = this.#deserialize(e.data);
|
|
163
|
-
if (ORPCError.isValidJSON(deserialized)) {
|
|
164
|
-
return ORPCError.fromJSON(deserialized, { cause: e });
|
|
165
|
-
}
|
|
166
|
-
return new ErrorEvent({
|
|
167
|
-
data: deserialized,
|
|
168
|
-
cause: e
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return this.#deserialize(data);
|
|
174
|
-
}
|
|
175
|
-
#deserialize(data) {
|
|
176
|
-
if (data === void 0 || data instanceof Blob) {
|
|
177
|
-
return data;
|
|
178
|
-
}
|
|
179
|
-
if (!(data instanceof FormData)) {
|
|
180
|
-
return this.jsonSerializer.deserialize(data.json, data.meta ?? []);
|
|
181
|
-
}
|
|
182
|
-
const serialized = JSON.parse(data.get("data"));
|
|
183
|
-
return this.jsonSerializer.deserialize(
|
|
184
|
-
serialized.json,
|
|
185
|
-
serialized.meta ?? [],
|
|
186
|
-
serialized.maps,
|
|
187
|
-
(i) => data.get(i.toString())
|
|
188
|
-
);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export { RPCJsonSerializer as R, RPCSerializer as a };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
type ClientContext = Record<string, any>;
|
|
2
|
-
type ClientOptions<TClientContext extends ClientContext> = {
|
|
3
|
-
signal?: AbortSignal;
|
|
4
|
-
lastEventId?: string | undefined;
|
|
5
|
-
} & (Record<never, never> extends TClientContext ? {
|
|
6
|
-
context?: TClientContext;
|
|
7
|
-
} : {
|
|
8
|
-
context: TClientContext;
|
|
9
|
-
});
|
|
10
|
-
type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
|
|
11
|
-
type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
|
12
|
-
__error?: {
|
|
13
|
-
type: TError;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
|
17
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
18
|
-
}
|
|
19
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
|
20
|
-
[k: string]: NestedClient<TClientContext>;
|
|
21
|
-
};
|
|
22
|
-
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
23
|
-
type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
|
|
24
|
-
context: TClientContext;
|
|
25
|
-
};
|
|
26
|
-
interface ClientLink<TClientContext extends ClientContext> {
|
|
27
|
-
call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
31
|
-
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
32
|
-
error: (error: unknown) => Promise<unknown>;
|
|
33
|
-
}): AsyncGenerator<TMap, TMap, TNext>;
|
|
34
|
-
interface EventIteratorReconnectOptions {
|
|
35
|
-
lastRetry: number | undefined;
|
|
36
|
-
lastEventId: string | undefined;
|
|
37
|
-
retryTimes: number;
|
|
38
|
-
error: unknown;
|
|
39
|
-
}
|
|
40
|
-
declare function createAutoRetryEventIterator<TYield, TReturn>(initial: AsyncIterator<TYield, TReturn, void>, reconnect: (options: EventIteratorReconnectOptions) => Promise<AsyncIterator<TYield, TReturn, void> | null>, initialLastEventId: string | undefined): AsyncGenerator<TYield, TReturn, void>;
|
|
41
|
-
|
|
42
|
-
export { type ClientContext as C, type EventIteratorReconnectOptions as E, type InferClientContext as I, type NestedClient as N, type ClientOptionsOut as a, type ClientLink as b, type ClientPromiseResult as c, createAutoRetryEventIterator as d, type ClientOptions as e, type ClientRest as f, type Client as g, mapEventIterator as m };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
type ClientContext = Record<string, any>;
|
|
2
|
-
type ClientOptions<TClientContext extends ClientContext> = {
|
|
3
|
-
signal?: AbortSignal;
|
|
4
|
-
lastEventId?: string | undefined;
|
|
5
|
-
} & (Record<never, never> extends TClientContext ? {
|
|
6
|
-
context?: TClientContext;
|
|
7
|
-
} : {
|
|
8
|
-
context: TClientContext;
|
|
9
|
-
});
|
|
10
|
-
type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options?: ClientOptions<TClientContext>] : [input: TInput, options: ClientOptions<TClientContext>];
|
|
11
|
-
type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
|
|
12
|
-
__error?: {
|
|
13
|
-
type: TError;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
|
|
17
|
-
(...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
|
|
18
|
-
}
|
|
19
|
-
type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
|
|
20
|
-
[k: string]: NestedClient<TClientContext>;
|
|
21
|
-
};
|
|
22
|
-
type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
|
|
23
|
-
type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
|
|
24
|
-
context: TClientContext;
|
|
25
|
-
};
|
|
26
|
-
interface ClientLink<TClientContext extends ClientContext> {
|
|
27
|
-
call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
|
|
31
|
-
value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
|
|
32
|
-
error: (error: unknown) => Promise<unknown>;
|
|
33
|
-
}): AsyncGenerator<TMap, TMap, TNext>;
|
|
34
|
-
interface EventIteratorReconnectOptions {
|
|
35
|
-
lastRetry: number | undefined;
|
|
36
|
-
lastEventId: string | undefined;
|
|
37
|
-
retryTimes: number;
|
|
38
|
-
error: unknown;
|
|
39
|
-
}
|
|
40
|
-
declare function createAutoRetryEventIterator<TYield, TReturn>(initial: AsyncIterator<TYield, TReturn, void>, reconnect: (options: EventIteratorReconnectOptions) => Promise<AsyncIterator<TYield, TReturn, void> | null>, initialLastEventId: string | undefined): AsyncGenerator<TYield, TReturn, void>;
|
|
41
|
-
|
|
42
|
-
export { type ClientContext as C, type EventIteratorReconnectOptions as E, type InferClientContext as I, type NestedClient as N, type ClientOptionsOut as a, type ClientLink as b, type ClientPromiseResult as c, createAutoRetryEventIterator as d, type ClientOptions as e, type ClientRest as f, type Client as g, mapEventIterator as m };
|