@orpc/client 0.40.0 → 0.41.0

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.
@@ -0,0 +1,329 @@
1
+ import {
2
+ ORPCError,
3
+ __export,
4
+ mapEventIterator,
5
+ toORPCError
6
+ } from "./chunk-2UPNYYFF.js";
7
+
8
+ // src/openapi/bracket-notation.ts
9
+ var bracket_notation_exports = {};
10
+ __export(bracket_notation_exports, {
11
+ deserialize: () => deserialize,
12
+ escapeSegment: () => escapeSegment,
13
+ parsePath: () => parsePath,
14
+ serialize: () => serialize,
15
+ stringifyPath: () => stringifyPath
16
+ });
17
+ import { isObject } from "@orpc/shared";
18
+ function serialize(payload, parentKey = "") {
19
+ if (!Array.isArray(payload) && !isObject(payload))
20
+ return [["", payload]];
21
+ const result = [];
22
+ function helper(value, path) {
23
+ if (Array.isArray(value)) {
24
+ value.forEach((item, index) => {
25
+ helper(item, [...path, String(index)]);
26
+ });
27
+ } else if (isObject(value)) {
28
+ for (const [key, val] of Object.entries(value)) {
29
+ helper(val, [...path, key]);
30
+ }
31
+ } else {
32
+ result.push([stringifyPath(path), value]);
33
+ }
34
+ }
35
+ helper(payload, parentKey ? [parentKey] : []);
36
+ return result;
37
+ }
38
+ function deserialize(entities) {
39
+ if (entities.length === 0) {
40
+ return void 0;
41
+ }
42
+ const isRootArray = entities.every(([path]) => path === "");
43
+ const result = isRootArray ? [] : {};
44
+ const arrayPushPaths = /* @__PURE__ */ new Set();
45
+ for (const [path, _] of entities) {
46
+ const segments = parsePath(path);
47
+ const base = segments.slice(0, -1).join(".");
48
+ const last = segments[segments.length - 1];
49
+ if (last === "") {
50
+ arrayPushPaths.add(base);
51
+ } else {
52
+ arrayPushPaths.delete(base);
53
+ }
54
+ }
55
+ function setValue(obj, segments, value, fullPath) {
56
+ const [first, ...rest_] = segments;
57
+ if (Array.isArray(obj) && first === "") {
58
+ ;
59
+ obj.push(value);
60
+ return;
61
+ }
62
+ const objAsRecord = obj;
63
+ if (rest_.length === 0) {
64
+ objAsRecord[first] = value;
65
+ return;
66
+ }
67
+ const rest = rest_;
68
+ if (rest[0] === "") {
69
+ const pathToCheck = segments.slice(0, -1).join(".");
70
+ if (rest.length === 1 && arrayPushPaths.has(pathToCheck)) {
71
+ if (!(first in objAsRecord)) {
72
+ objAsRecord[first] = [];
73
+ }
74
+ if (Array.isArray(objAsRecord[first])) {
75
+ ;
76
+ objAsRecord[first].push(value);
77
+ return;
78
+ }
79
+ }
80
+ if (!(first in objAsRecord)) {
81
+ objAsRecord[first] = {};
82
+ }
83
+ const target = objAsRecord[first];
84
+ target[""] = value;
85
+ return;
86
+ }
87
+ if (!(first in objAsRecord)) {
88
+ objAsRecord[first] = {};
89
+ }
90
+ setValue(
91
+ objAsRecord[first],
92
+ rest,
93
+ value,
94
+ fullPath
95
+ );
96
+ }
97
+ for (const [path, value] of entities) {
98
+ const segments = parsePath(path);
99
+ setValue(result, segments, value, path);
100
+ }
101
+ return result;
102
+ }
103
+ function escapeSegment(segment) {
104
+ return segment.replace(/[\\[\]]/g, (match) => {
105
+ switch (match) {
106
+ case "\\":
107
+ return "\\\\";
108
+ case "[":
109
+ return "\\[";
110
+ case "]":
111
+ return "\\]";
112
+ default:
113
+ return match;
114
+ }
115
+ });
116
+ }
117
+ function stringifyPath(path) {
118
+ const [first, ...rest] = path;
119
+ const firstSegment = escapeSegment(first);
120
+ const base = first === "" ? "" : firstSegment;
121
+ return rest.reduce(
122
+ (result, segment) => `${result}[${escapeSegment(segment)}]`,
123
+ base
124
+ );
125
+ }
126
+ function parsePath(path) {
127
+ if (path === "")
128
+ return [""];
129
+ const result = [];
130
+ let currentSegment = "";
131
+ let inBracket = false;
132
+ let bracketContent = "";
133
+ let backslashCount = 0;
134
+ for (let i = 0; i < path.length; i++) {
135
+ const char = path[i];
136
+ if (char === "\\") {
137
+ backslashCount++;
138
+ continue;
139
+ }
140
+ if (backslashCount > 0) {
141
+ const literalBackslashes = "\\".repeat(Math.floor(backslashCount / 2));
142
+ if (char === "[" || char === "]") {
143
+ if (backslashCount % 2 === 1) {
144
+ if (inBracket) {
145
+ bracketContent += literalBackslashes + char;
146
+ } else {
147
+ currentSegment += literalBackslashes + char;
148
+ }
149
+ } else {
150
+ if (inBracket) {
151
+ bracketContent += literalBackslashes;
152
+ } else {
153
+ currentSegment += literalBackslashes;
154
+ }
155
+ if (char === "[" && !inBracket) {
156
+ if (currentSegment !== "" || result.length === 0) {
157
+ result.push(currentSegment);
158
+ }
159
+ inBracket = true;
160
+ bracketContent = "";
161
+ currentSegment = "";
162
+ } else if (char === "]" && inBracket) {
163
+ result.push(bracketContent);
164
+ inBracket = false;
165
+ bracketContent = "";
166
+ } else {
167
+ if (inBracket) {
168
+ bracketContent += char;
169
+ } else {
170
+ currentSegment += char;
171
+ }
172
+ }
173
+ }
174
+ } else {
175
+ const allBackslashes = "\\".repeat(backslashCount);
176
+ if (inBracket) {
177
+ bracketContent += allBackslashes + char;
178
+ } else {
179
+ currentSegment += allBackslashes + char;
180
+ }
181
+ }
182
+ backslashCount = 0;
183
+ continue;
184
+ }
185
+ if (char === "[" && !inBracket) {
186
+ if (currentSegment !== "" || result.length === 0) {
187
+ result.push(currentSegment);
188
+ }
189
+ inBracket = true;
190
+ bracketContent = "";
191
+ currentSegment = "";
192
+ continue;
193
+ }
194
+ if (char === "]" && inBracket) {
195
+ result.push(bracketContent);
196
+ inBracket = false;
197
+ bracketContent = "";
198
+ continue;
199
+ }
200
+ if (inBracket) {
201
+ bracketContent += char;
202
+ } else {
203
+ currentSegment += char;
204
+ }
205
+ }
206
+ if (backslashCount > 0) {
207
+ const remainingBackslashes = "\\".repeat(backslashCount);
208
+ if (inBracket) {
209
+ bracketContent += remainingBackslashes;
210
+ } else {
211
+ currentSegment += remainingBackslashes;
212
+ }
213
+ }
214
+ if (inBracket) {
215
+ if (currentSegment !== "" || result.length === 0) {
216
+ result.push(currentSegment);
217
+ }
218
+ result.push(`[${bracketContent}`);
219
+ } else if (currentSegment !== "" || result.length === 0) {
220
+ result.push(currentSegment);
221
+ }
222
+ return result;
223
+ }
224
+
225
+ // src/openapi/json-serializer.ts
226
+ import { isObject as isObject2 } from "@orpc/shared";
227
+ var OpenAPIJsonSerializer = class {
228
+ serialize(payload) {
229
+ if (payload instanceof Set)
230
+ return this.serialize([...payload]);
231
+ if (payload instanceof Map)
232
+ return this.serialize([...payload.entries()]);
233
+ if (Array.isArray(payload)) {
234
+ return payload.map((v) => v === void 0 ? "undefined" : this.serialize(v));
235
+ }
236
+ if (Number.isNaN(payload))
237
+ return "NaN";
238
+ if (typeof payload === "bigint")
239
+ return payload.toString();
240
+ if (payload instanceof Date && Number.isNaN(payload.getTime())) {
241
+ return "Invalid Date";
242
+ }
243
+ if (payload instanceof RegExp)
244
+ return payload.toString();
245
+ if (payload instanceof URL)
246
+ return payload.toString();
247
+ if (!isObject2(payload))
248
+ return payload;
249
+ return Object.keys(payload).reduce(
250
+ (carry, key) => {
251
+ const val = payload[key];
252
+ carry[key] = this.serialize(val);
253
+ return carry;
254
+ },
255
+ {}
256
+ );
257
+ }
258
+ };
259
+
260
+ // src/openapi/serializer.ts
261
+ import { ErrorEvent, isAsyncIteratorObject } from "@orpc/server-standard";
262
+ import { findDeepMatches } from "@orpc/shared";
263
+ var OpenAPISerializer = class {
264
+ jsonSerializer;
265
+ constructor(options) {
266
+ this.jsonSerializer = options?.jsonSerializer ?? new OpenAPIJsonSerializer();
267
+ }
268
+ serialize(data) {
269
+ if (data instanceof Blob || data === void 0) {
270
+ return data;
271
+ }
272
+ if (isAsyncIteratorObject(data)) {
273
+ return mapEventIterator(data, {
274
+ value: async (value) => this.jsonSerializer.serialize(value),
275
+ error: async (e) => {
276
+ if (e instanceof ErrorEvent) {
277
+ return new ErrorEvent({
278
+ data: this.jsonSerializer.serialize(e.data),
279
+ cause: e
280
+ });
281
+ }
282
+ return new ErrorEvent({
283
+ data: this.jsonSerializer.serialize(toORPCError(e).toJSON()),
284
+ cause: e
285
+ });
286
+ }
287
+ });
288
+ }
289
+ const serializedJSON = this.jsonSerializer.serialize(data);
290
+ const { values: blobs } = findDeepMatches((v) => v instanceof Blob, serializedJSON);
291
+ if (blobs.length === 0) {
292
+ return serializedJSON;
293
+ }
294
+ const form = new FormData();
295
+ for (const [path, value] of serialize(serializedJSON)) {
296
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
297
+ form.append(path, value.toString());
298
+ } else if (value instanceof Date) {
299
+ form.append(path, value.toISOString());
300
+ } else if (value instanceof Blob) {
301
+ form.append(path, value);
302
+ }
303
+ }
304
+ return form;
305
+ }
306
+ deserialize(serialized) {
307
+ if (serialized instanceof URLSearchParams || serialized instanceof FormData) {
308
+ return deserialize([...serialized.entries()]);
309
+ }
310
+ if (isAsyncIteratorObject(serialized)) {
311
+ return mapEventIterator(serialized, {
312
+ value: async (value) => value,
313
+ error: async (e) => {
314
+ if (e instanceof ErrorEvent && ORPCError.isValidJSON(e.data)) {
315
+ return ORPCError.fromJSON(e.data, { cause: e });
316
+ }
317
+ return e;
318
+ }
319
+ });
320
+ }
321
+ return serialized;
322
+ }
323
+ };
324
+ export {
325
+ bracket_notation_exports as BracketNotation,
326
+ OpenAPIJsonSerializer,
327
+ OpenAPISerializer
328
+ };
329
+ //# sourceMappingURL=openapi.js.map
package/dist/rpc.js ADDED
@@ -0,0 +1,10 @@
1
+ import {
2
+ RPCSerializer,
3
+ serializeRPCJson
4
+ } from "./chunk-TPEMQB7D.js";
5
+ import "./chunk-2UPNYYFF.js";
6
+ export {
7
+ RPCSerializer,
8
+ serializeRPCJson
9
+ };
10
+ //# sourceMappingURL=rpc.js.map
@@ -1,3 +1,3 @@
1
- export * from './orpc-link';
1
+ export * from './rpc-link';
2
2
  export * from './types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,9 +1,9 @@
1
- import type { ClientContext, HTTPMethod } from '@orpc/contract';
2
1
  import type { Value } from '@orpc/shared';
3
- import type { ClientLink, ClientOptionsOut } from '../../types';
2
+ import type { ClientContext, ClientLink, ClientOptionsOut } from '../../types';
4
3
  import type { FetchWithContext } from './types';
5
- import { RPCSerializer } from '@orpc/server/standard';
6
4
  import { type EventIteratorReconnectOptions } from '../../event-iterator';
5
+ import { RPCSerializer } from '../../rpc';
6
+ type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
7
7
  export declare class InvalidEventSourceRetryResponse extends Error {
8
8
  }
9
9
  export interface RPCLinkOptions<TClientContext extends ClientContext> {
@@ -94,4 +94,5 @@ export declare class RPCLink<TClientContext extends ClientContext> implements Cl
94
94
  private performCall;
95
95
  private encodeRequest;
96
96
  }
97
- //# sourceMappingURL=orpc-link.d.ts.map
97
+ export {};
98
+ //# sourceMappingURL=rpc-link.d.ts.map
@@ -1,5 +1,4 @@
1
- import type { ClientContext } from '@orpc/contract';
2
- import type { ClientOptionsOut } from '../../types';
1
+ import type { ClientContext, ClientOptionsOut } from '../../types';
3
2
  export interface FetchWithContext<TClientContext extends ClientContext> {
4
3
  (url: URL, init: RequestInit, options: ClientOptionsOut<TClientContext>, path: readonly string[], input: unknown): Promise<Response>;
5
4
  }
@@ -1,11 +1,9 @@
1
- import type { AnyContractRouter, ClientContext, ContractRouterClient } from '@orpc/contract';
2
- import type { AnyRouter, RouterClient } from '@orpc/server';
3
- import type { ClientLink } from './types';
1
+ import type { ClientLink, InferClientContext, NestedClient } from './types';
4
2
  export interface createORPCClientOptions {
5
3
  /**
6
4
  * Use as base path for all procedure, useful when you only want to call a subset of the procedure.
7
5
  */
8
6
  path?: string[];
9
7
  }
10
- export declare function createORPCClient<TRouter extends AnyRouter | AnyContractRouter, TClientContext extends ClientContext = Record<never, never>>(link: ClientLink<TClientContext>, options?: createORPCClientOptions): TRouter extends AnyRouter ? RouterClient<TRouter, TClientContext> : TRouter extends AnyContractRouter ? ContractRouterClient<TRouter, TClientContext> : never;
8
+ export declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
11
9
  //# sourceMappingURL=client.d.ts.map
@@ -1,6 +1,5 @@
1
- import type { ClientContext } from '@orpc/contract';
2
1
  import type { Promisable } from '@orpc/shared';
3
- import type { ClientLink, ClientOptionsOut } from './types';
2
+ import type { ClientContext, ClientLink, ClientOptionsOut } from './types';
4
3
  /**
5
4
  * DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
6
5
  * based on the request path, input, and context.
@@ -0,0 +1,106 @@
1
+ import { type MaybeOptionalOptions } from '@orpc/shared';
2
+ export declare const COMMON_ORPC_ERROR_DEFS: {
3
+ readonly BAD_REQUEST: {
4
+ readonly status: 400;
5
+ readonly message: "Bad Request";
6
+ };
7
+ readonly UNAUTHORIZED: {
8
+ readonly status: 401;
9
+ readonly message: "Unauthorized";
10
+ };
11
+ readonly FORBIDDEN: {
12
+ readonly status: 403;
13
+ readonly message: "Forbidden";
14
+ };
15
+ readonly NOT_FOUND: {
16
+ readonly status: 404;
17
+ readonly message: "Not Found";
18
+ };
19
+ readonly METHOD_NOT_SUPPORTED: {
20
+ readonly status: 405;
21
+ readonly message: "Method Not Supported";
22
+ };
23
+ readonly NOT_ACCEPTABLE: {
24
+ readonly status: 406;
25
+ readonly message: "Not Acceptable";
26
+ };
27
+ readonly TIMEOUT: {
28
+ readonly status: 408;
29
+ readonly message: "Request Timeout";
30
+ };
31
+ readonly CONFLICT: {
32
+ readonly status: 409;
33
+ readonly message: "Conflict";
34
+ };
35
+ readonly PRECONDITION_FAILED: {
36
+ readonly status: 412;
37
+ readonly message: "Precondition Failed";
38
+ };
39
+ readonly PAYLOAD_TOO_LARGE: {
40
+ readonly status: 413;
41
+ readonly message: "Payload Too Large";
42
+ };
43
+ readonly UNSUPPORTED_MEDIA_TYPE: {
44
+ readonly status: 415;
45
+ readonly message: "Unsupported Media Type";
46
+ };
47
+ readonly UNPROCESSABLE_CONTENT: {
48
+ readonly status: 422;
49
+ readonly message: "Unprocessable Content";
50
+ };
51
+ readonly TOO_MANY_REQUESTS: {
52
+ readonly status: 429;
53
+ readonly message: "Too Many Requests";
54
+ };
55
+ readonly CLIENT_CLOSED_REQUEST: {
56
+ readonly status: 499;
57
+ readonly message: "Client Closed Request";
58
+ };
59
+ readonly INTERNAL_SERVER_ERROR: {
60
+ readonly status: 500;
61
+ readonly message: "Internal Server Error";
62
+ };
63
+ readonly NOT_IMPLEMENTED: {
64
+ readonly status: 501;
65
+ readonly message: "Not Implemented";
66
+ };
67
+ readonly BAD_GATEWAY: {
68
+ readonly status: 502;
69
+ readonly message: "Bad Gateway";
70
+ };
71
+ readonly SERVICE_UNAVAILABLE: {
72
+ readonly status: 503;
73
+ readonly message: "Service Unavailable";
74
+ };
75
+ readonly GATEWAY_TIMEOUT: {
76
+ readonly status: 504;
77
+ readonly message: "Gateway Timeout";
78
+ };
79
+ };
80
+ export type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
81
+ export type ORPCErrorCode = CommonORPCErrorCode | (string & {});
82
+ export declare function fallbackORPCErrorStatus(code: ORPCErrorCode, status: number | undefined): number;
83
+ export declare function fallbackORPCErrorMessage(code: ORPCErrorCode, message: string | undefined): string;
84
+ export type ORPCErrorOptions<TData> = ErrorOptions & {
85
+ defined?: boolean;
86
+ status?: number;
87
+ message?: string;
88
+ } & (undefined extends TData ? {
89
+ data?: TData;
90
+ } : {
91
+ data: TData;
92
+ });
93
+ export declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
94
+ readonly defined: boolean;
95
+ readonly code: TCode;
96
+ readonly status: number;
97
+ readonly data: TData;
98
+ constructor(code: TCode, ...[options]: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
99
+ toJSON(): ORPCErrorJSON<TCode, TData>;
100
+ static fromJSON<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
101
+ static isValidJSON(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
102
+ }
103
+ export type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
104
+ export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
105
+ export declare function toORPCError(error: unknown): ORPCError<any, any>;
106
+ //# sourceMappingURL=error.d.ts.map
@@ -1,3 +1,7 @@
1
+ export declare function mapEventIterator<TYield, TReturn, TNext, TMap = TYield | TReturn>(iterator: AsyncIterator<TYield, TReturn, TNext>, maps: {
2
+ value: (value: NoInfer<TYield | TReturn>, done: boolean | undefined) => Promise<TMap>;
3
+ error: (error: unknown) => Promise<unknown>;
4
+ }): AsyncGenerator<TMap, TMap, TNext>;
1
5
  export interface EventIteratorReconnectOptions {
2
6
  lastRetry: number | undefined;
3
7
  lastEventId: string | undefined;
@@ -1,8 +1,9 @@
1
1
  /** unnoq */
2
2
  export * from './client';
3
3
  export * from './dynamic-link';
4
+ export * from './error';
4
5
  export * from './event-iterator';
5
6
  export * from './event-iterator-state';
6
7
  export * from './types';
7
- export { isDefinedError, ORPCError, safe } from '@orpc/contract';
8
+ export * from './utils';
8
9
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Serialize an object or array into a list of [key, value] pairs.
3
+ * The key will express by using bracket-notation.
4
+ *
5
+ * Notice: This way cannot express the empty object or array.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * const payload = {
10
+ * name: 'John Doe',
11
+ * pets: ['dog', 'cat'],
12
+ * }
13
+ *
14
+ * const entities = serialize(payload)
15
+ *
16
+ * expect(entities).toEqual([
17
+ * ['name', 'John Doe'],
18
+ * ['name[pets][0]', 'dog'],
19
+ * ['name[pets][1]', 'cat'],
20
+ * ])
21
+ * ```
22
+ */
23
+ export declare function serialize(payload: unknown, parentKey?: string): [string, unknown][];
24
+ /**
25
+ * Deserialize a list of [key, value] pairs into an object or array.
26
+ * The key is expressed by using bracket-notation.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * const entities = [
31
+ * ['name', 'John Doe'],
32
+ * ['name[pets][0]', 'dog'],
33
+ * ['name[pets][1]', 'cat'],
34
+ * ['name[dogs][]', 'hello'],
35
+ * ['name[dogs][]', 'kitty'],
36
+ * ]
37
+ *
38
+ * const payload = deserialize(entities)
39
+ *
40
+ * expect(payload).toEqual({
41
+ * name: 'John Doe',
42
+ * pets: { 0: 'dog', 1: 'cat' },
43
+ * dogs: ['hello', 'kitty'],
44
+ * })
45
+ * ```
46
+ */
47
+ export declare function deserialize(entities: readonly (readonly [string, unknown])[]): Record<string, unknown> | unknown[] | undefined;
48
+ /**
49
+ * Escape the `[`, `]`, and `\` chars in a path segment.
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * expect(escapeSegment('name[pets')).toEqual('name\\[pets')
54
+ * ```
55
+ */
56
+ export declare function escapeSegment(segment: string): string;
57
+ /**
58
+ * Convert an array of path segments into a path string using bracket-notation.
59
+ *
60
+ * For the special char `[`, `]`, and `\` will be escaped by adding `\` at start.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * expect(stringifyPath(['name', 'pets', '0'])).toEqual('name[pets][0]')
65
+ * ```
66
+ */
67
+ export declare function stringifyPath(path: readonly [string, ...string[]]): string;
68
+ /**
69
+ * Convert a path string using bracket-notation into an array of path segments.
70
+ *
71
+ * For the special char `[`, `]`, and `\` you should escape by adding `\` at start.
72
+ * It only treats a pair `[${string}]` as a path segment.
73
+ * If missing or escape it will bypass and treat as normal string.
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * expect(parsePath('name[pets][0]')).toEqual(['name', 'pets', '0'])
78
+ * expect(parsePath('name[pets][0')).toEqual(['name', 'pets', '[0'])
79
+ * expect(parsePath('name[pets[0]')).toEqual(['name', 'pets[0')
80
+ * expect(parsePath('name\\[pets][0]')).toEqual(['name[pets]', '0'])
81
+ * ```
82
+ */
83
+ export declare function parsePath(path: string): [string, ...string[]];
84
+ //# sourceMappingURL=bracket-notation.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * as BracketNotation from './bracket-notation';
2
+ export * from './json-serializer';
3
+ export * from './serializer';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,5 @@
1
+ export declare class OpenAPIJsonSerializer {
2
+ serialize(payload: unknown): unknown;
3
+ }
4
+ export type PublicOpenAPIJsonSerializer = Pick<OpenAPIJsonSerializer, keyof OpenAPIJsonSerializer>;
5
+ //# sourceMappingURL=json-serializer.d.ts.map
@@ -0,0 +1,11 @@
1
+ import type { PublicOpenAPIJsonSerializer } from './json-serializer';
2
+ export interface OpenAPISerializerOptions {
3
+ jsonSerializer?: PublicOpenAPIJsonSerializer;
4
+ }
5
+ export declare class OpenAPISerializer {
6
+ private readonly jsonSerializer;
7
+ constructor(options?: OpenAPISerializerOptions);
8
+ serialize(data: unknown): unknown;
9
+ deserialize(serialized: unknown): unknown;
10
+ }
11
+ //# sourceMappingURL=serializer.d.ts.map
@@ -0,0 +1,2 @@
1
+ export * from './serializer';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,22 @@
1
+ import type { Segment } from '@orpc/shared';
2
+ export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url', Segment[]][];
3
+ export type RPCSerialized = {
4
+ json: unknown;
5
+ meta: RPCSerializedJsonMeta;
6
+ } | FormData | AsyncIteratorObject<{
7
+ json: unknown;
8
+ meta: RPCSerializedJsonMeta;
9
+ }, {
10
+ json: unknown;
11
+ meta: RPCSerializedJsonMeta;
12
+ }, void>;
13
+ export type RPCSerializedFormDataMaps = Segment[][];
14
+ export declare class RPCSerializer {
15
+ serialize(data: unknown): RPCSerialized;
16
+ deserialize(serialized: RPCSerialized): unknown;
17
+ }
18
+ export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): {
19
+ json: unknown;
20
+ meta: RPCSerializedJsonMeta;
21
+ };
22
+ //# sourceMappingURL=serializer.d.ts.map