@orpc/client
Advanced tools
Comparing version 0.0.0-next.7d3bd71 to 0.0.0-next.7e41bc4
import { | ||
RPCSerializer | ||
} from "./chunk-TPEMQB7D.js"; | ||
} from "./chunk-4HZVK3GJ.js"; | ||
import { | ||
ORPCError, | ||
createAutoRetryEventIterator | ||
} from "./chunk-2UPNYYFF.js"; | ||
} from "./chunk-X34KXUAJ.js"; | ||
// src/adapters/fetch/rpc-link.ts | ||
import { isAsyncIteratorObject } from "@orpc/server-standard"; | ||
import { toFetchBody, toStandardBody } from "@orpc/server-standard-fetch"; | ||
import { trim, value } from "@orpc/shared"; | ||
import { isAsyncIteratorObject } from "@orpc/standard-server"; | ||
import { toFetchBody, toStandardBody } from "@orpc/standard-server-fetch"; | ||
var InvalidEventSourceRetryResponse = class extends Error { | ||
@@ -104,5 +104,5 @@ }; | ||
const serialized = this.rpcSerializer.serialize(input); | ||
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !isAsyncIteratorObject(serialized)) { | ||
if (expectedMethod === "GET" && !(serialized instanceof FormData) && !(serialized instanceof Blob) && !isAsyncIteratorObject(serialized)) { | ||
const getUrl = new URL(url); | ||
getUrl.searchParams.append("data", JSON.stringify(serialized)); | ||
getUrl.searchParams.append("data", JSON.stringify(serialized) ?? ""); | ||
if (getUrl.toString().length <= this.maxUrlLength) { | ||
@@ -109,0 +109,0 @@ return { |
@@ -13,3 +13,3 @@ import { | ||
updateEventIteratorStatus | ||
} from "./chunk-2UPNYYFF.js"; | ||
} from "./chunk-X34KXUAJ.js"; | ||
@@ -57,9 +57,18 @@ // src/client.ts | ||
const output = await promise; | ||
return [output, void 0, false]; | ||
return Object.assign( | ||
[null, output, false], | ||
{ error: null, data: output, isDefined: false } | ||
); | ||
} catch (e) { | ||
const error = e; | ||
if (isDefinedError(error)) { | ||
return [void 0, error, true]; | ||
return Object.assign( | ||
[error, void 0, true], | ||
{ error, data: void 0, isDefined: true } | ||
); | ||
} | ||
return [void 0, error, false]; | ||
return Object.assign( | ||
[error, void 0, false], | ||
{ error, data: void 0, isDefined: false } | ||
); | ||
} | ||
@@ -66,0 +75,0 @@ } |
import { | ||
ORPCError, | ||
__export, | ||
mapEventIterator, | ||
toORPCError | ||
} from "./chunk-2UPNYYFF.js"; | ||
} from "./chunk-X34KXUAJ.js"; | ||
// src/openapi/bracket-notation.ts | ||
var bracket_notation_exports = {}; | ||
__export(bracket_notation_exports, { | ||
deserialize: () => deserialize, | ||
escapeSegment: () => escapeSegment, | ||
parsePath: () => parsePath, | ||
serialize: () => serialize, | ||
stringifyPath: () => stringifyPath | ||
}); | ||
import { isObject } from "@orpc/shared"; | ||
function serialize(payload, parentKey = "") { | ||
if (!Array.isArray(payload) && !isObject(payload)) | ||
return [["", payload]]; | ||
const result = []; | ||
function helper(value, path) { | ||
if (Array.isArray(value)) { | ||
value.forEach((item, index) => { | ||
helper(item, [...path, String(index)]); | ||
var BracketNotationSerializer = class { | ||
serialize(data, segments = [], result = []) { | ||
if (Array.isArray(data)) { | ||
data.forEach((item, i) => { | ||
this.serialize(item, [...segments, i], result); | ||
}); | ||
} else if (isObject(value)) { | ||
for (const [key, val] of Object.entries(value)) { | ||
helper(val, [...path, key]); | ||
} else if (isObject(data)) { | ||
for (const key in data) { | ||
this.serialize(data[key], [...segments, key], result); | ||
} | ||
} else { | ||
result.push([stringifyPath(path), value]); | ||
result.push([this.stringifyPath(segments), data]); | ||
} | ||
return result; | ||
} | ||
helper(payload, parentKey ? [parentKey] : []); | ||
return result; | ||
} | ||
function deserialize(entities) { | ||
if (entities.length === 0) { | ||
return void 0; | ||
} | ||
const isRootArray = entities.every(([path]) => path === ""); | ||
const result = isRootArray ? [] : {}; | ||
const arrayPushPaths = /* @__PURE__ */ new Set(); | ||
for (const [path, _] of entities) { | ||
const segments = parsePath(path); | ||
const base = segments.slice(0, -1).join("."); | ||
const last = segments[segments.length - 1]; | ||
if (last === "") { | ||
arrayPushPaths.add(base); | ||
} else { | ||
arrayPushPaths.delete(base); | ||
} | ||
} | ||
function setValue(obj, segments, value, fullPath) { | ||
const [first, ...rest_] = segments; | ||
if (Array.isArray(obj) && first === "") { | ||
; | ||
obj.push(value); | ||
return; | ||
} | ||
const objAsRecord = obj; | ||
if (rest_.length === 0) { | ||
objAsRecord[first] = value; | ||
return; | ||
} | ||
const rest = rest_; | ||
if (rest[0] === "") { | ||
const pathToCheck = segments.slice(0, -1).join("."); | ||
if (rest.length === 1 && arrayPushPaths.has(pathToCheck)) { | ||
if (!(first in objAsRecord)) { | ||
objAsRecord[first] = []; | ||
deserialize(serialized) { | ||
const arrayPushStyles = /* @__PURE__ */ new WeakSet(); | ||
const ref = { value: [] }; | ||
for (const [path, value] of serialized) { | ||
const segments = this.parsePath(path); | ||
let currentRef = ref; | ||
let nextSegment = "value"; | ||
segments.forEach((segment, i) => { | ||
if (!Array.isArray(currentRef[nextSegment]) && !isObject(currentRef[nextSegment])) { | ||
currentRef[nextSegment] = []; | ||
} | ||
if (Array.isArray(objAsRecord[first])) { | ||
; | ||
objAsRecord[first].push(value); | ||
return; | ||
} | ||
} | ||
if (!(first in objAsRecord)) { | ||
objAsRecord[first] = {}; | ||
} | ||
const target = objAsRecord[first]; | ||
target[""] = value; | ||
return; | ||
} | ||
if (!(first in objAsRecord)) { | ||
objAsRecord[first] = {}; | ||
} | ||
setValue( | ||
objAsRecord[first], | ||
rest, | ||
value, | ||
fullPath | ||
); | ||
} | ||
for (const [path, value] of entities) { | ||
const segments = parsePath(path); | ||
setValue(result, segments, value, path); | ||
} | ||
return result; | ||
} | ||
function escapeSegment(segment) { | ||
return segment.replace(/[\\[\]]/g, (match) => { | ||
switch (match) { | ||
case "\\": | ||
return "\\\\"; | ||
case "[": | ||
return "\\["; | ||
case "]": | ||
return "\\]"; | ||
default: | ||
return match; | ||
} | ||
}); | ||
} | ||
function stringifyPath(path) { | ||
const [first, ...rest] = path; | ||
const firstSegment = escapeSegment(first); | ||
const base = first === "" ? "" : firstSegment; | ||
return rest.reduce( | ||
(result, segment) => `${result}[${escapeSegment(segment)}]`, | ||
base | ||
); | ||
} | ||
function parsePath(path) { | ||
if (path === "") | ||
return [""]; | ||
const result = []; | ||
let currentSegment = ""; | ||
let inBracket = false; | ||
let bracketContent = ""; | ||
let backslashCount = 0; | ||
for (let i = 0; i < path.length; i++) { | ||
const char = path[i]; | ||
if (char === "\\") { | ||
backslashCount++; | ||
continue; | ||
} | ||
if (backslashCount > 0) { | ||
const literalBackslashes = "\\".repeat(Math.floor(backslashCount / 2)); | ||
if (char === "[" || char === "]") { | ||
if (backslashCount % 2 === 1) { | ||
if (inBracket) { | ||
bracketContent += literalBackslashes + char; | ||
} else { | ||
currentSegment += literalBackslashes + char; | ||
if (i !== segments.length - 1) { | ||
if (Array.isArray(currentRef[nextSegment]) && !isValidArrayIndex(segment)) { | ||
currentRef[nextSegment] = { ...currentRef[nextSegment] }; | ||
} | ||
} else { | ||
if (inBracket) { | ||
bracketContent += literalBackslashes; | ||
} else { | ||
currentSegment += literalBackslashes; | ||
} | ||
if (char === "[" && !inBracket) { | ||
if (currentSegment !== "" || result.length === 0) { | ||
result.push(currentSegment); | ||
} | ||
inBracket = true; | ||
bracketContent = ""; | ||
currentSegment = ""; | ||
} else if (char === "]" && inBracket) { | ||
result.push(bracketContent); | ||
inBracket = false; | ||
bracketContent = ""; | ||
} else { | ||
if (inBracket) { | ||
bracketContent += char; | ||
if (Array.isArray(currentRef[nextSegment])) { | ||
if (segment === "") { | ||
if (currentRef[nextSegment].length && !arrayPushStyles.has(currentRef[nextSegment])) { | ||
currentRef[nextSegment] = { ...currentRef[nextSegment] }; | ||
} | ||
} else { | ||
currentSegment += char; | ||
if (arrayPushStyles.has(currentRef[nextSegment])) { | ||
currentRef[nextSegment] = { "": currentRef[nextSegment].at(-1) }; | ||
} else if (!isValidArrayIndex(segment)) { | ||
currentRef[nextSegment] = { ...currentRef[nextSegment] }; | ||
} | ||
} | ||
} | ||
} | ||
} else { | ||
const allBackslashes = "\\".repeat(backslashCount); | ||
if (inBracket) { | ||
bracketContent += allBackslashes + char; | ||
currentRef = currentRef[nextSegment]; | ||
nextSegment = segment; | ||
}); | ||
if (Array.isArray(currentRef)) { | ||
if (nextSegment === "") { | ||
arrayPushStyles.add(currentRef); | ||
currentRef.push(value); | ||
} else { | ||
currentSegment += allBackslashes + char; | ||
currentRef[Number(nextSegment)] = value; | ||
} | ||
} else { | ||
currentRef[nextSegment] = value; | ||
} | ||
backslashCount = 0; | ||
continue; | ||
} | ||
if (char === "[" && !inBracket) { | ||
if (currentSegment !== "" || result.length === 0) { | ||
result.push(currentSegment); | ||
return ref.value; | ||
} | ||
stringifyPath(segments) { | ||
return segments.map((segment) => { | ||
return segment.toString().replace(/[\\[\]]/g, (match) => { | ||
switch (match) { | ||
case "\\": | ||
return "\\\\"; | ||
case "[": | ||
return "\\["; | ||
case "]": | ||
return "\\]"; | ||
/* v8 ignore next 2 */ | ||
default: | ||
return match; | ||
} | ||
}); | ||
}).reduce((result, segment, i) => { | ||
if (i === 0) { | ||
return segment; | ||
} | ||
inBracket = true; | ||
bracketContent = ""; | ||
currentSegment = ""; | ||
continue; | ||
} | ||
if (char === "]" && inBracket) { | ||
result.push(bracketContent); | ||
inBracket = false; | ||
bracketContent = ""; | ||
continue; | ||
} | ||
if (inBracket) { | ||
bracketContent += char; | ||
} else { | ||
currentSegment += char; | ||
} | ||
return `${result}[${segment}]`; | ||
}, ""); | ||
} | ||
if (backslashCount > 0) { | ||
const remainingBackslashes = "\\".repeat(backslashCount); | ||
if (inBracket) { | ||
bracketContent += remainingBackslashes; | ||
} else { | ||
currentSegment += remainingBackslashes; | ||
parsePath(path) { | ||
const segments = []; | ||
let inBrackets = false; | ||
let currentSegment = ""; | ||
let backslashCount = 0; | ||
for (let i = 0; i < path.length; i++) { | ||
const char = path[i]; | ||
const nextChar = path[i + 1]; | ||
if (inBrackets && char === "]" && (nextChar === void 0 || nextChar === "[") && backslashCount % 2 === 0) { | ||
if (nextChar === void 0) { | ||
inBrackets = false; | ||
} | ||
segments.push(currentSegment); | ||
currentSegment = ""; | ||
i++; | ||
} else if (segments.length === 0 && char === "[" && backslashCount % 2 === 0) { | ||
inBrackets = true; | ||
segments.push(currentSegment); | ||
currentSegment = ""; | ||
} else if (char === "\\") { | ||
backslashCount++; | ||
} else { | ||
currentSegment += "\\".repeat(backslashCount / 2) + char; | ||
backslashCount = 0; | ||
} | ||
} | ||
return inBrackets || segments.length === 0 ? [path] : segments; | ||
} | ||
if (inBracket) { | ||
if (currentSegment !== "" || result.length === 0) { | ||
result.push(currentSegment); | ||
} | ||
result.push(`[${bracketContent}`); | ||
} else if (currentSegment !== "" || result.length === 0) { | ||
result.push(currentSegment); | ||
} | ||
return result; | ||
}; | ||
function isValidArrayIndex(value) { | ||
return /^0$|^[1-9]\d*$/.test(value); | ||
} | ||
@@ -228,31 +128,34 @@ | ||
var OpenAPIJsonSerializer = class { | ||
serialize(payload) { | ||
if (payload instanceof Set) | ||
return this.serialize([...payload]); | ||
if (payload instanceof Map) | ||
return this.serialize([...payload.entries()]); | ||
if (Array.isArray(payload)) { | ||
return payload.map((v) => v === void 0 ? "undefined" : this.serialize(v)); | ||
serialize(data, hasBlobRef = { value: false }) { | ||
if (data instanceof Blob) { | ||
hasBlobRef.value = true; | ||
return [data, hasBlobRef.value]; | ||
} | ||
if (Number.isNaN(payload)) | ||
return "NaN"; | ||
if (typeof payload === "bigint") | ||
return payload.toString(); | ||
if (payload instanceof Date && Number.isNaN(payload.getTime())) { | ||
return "Invalid Date"; | ||
if (data instanceof Set) { | ||
return this.serialize(Array.from(data), hasBlobRef); | ||
} | ||
if (payload instanceof RegExp) | ||
return payload.toString(); | ||
if (payload instanceof URL) | ||
return payload.toString(); | ||
if (!isObject2(payload)) | ||
return payload; | ||
return Object.keys(payload).reduce( | ||
(carry, key) => { | ||
const val = payload[key]; | ||
carry[key] = this.serialize(val); | ||
return carry; | ||
}, | ||
{} | ||
); | ||
if (data instanceof Map) { | ||
return this.serialize(Array.from(data.entries()), hasBlobRef); | ||
} | ||
if (Array.isArray(data)) { | ||
const json = data.map((v) => v === void 0 ? null : this.serialize(v, hasBlobRef)[0]); | ||
return [json, hasBlobRef.value]; | ||
} | ||
if (isObject2(data)) { | ||
const json = {}; | ||
for (const k in data) { | ||
json[k] = this.serialize(data[k], hasBlobRef)[0]; | ||
} | ||
return [json, hasBlobRef.value]; | ||
} | ||
if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) { | ||
return [data.toString(), hasBlobRef.value]; | ||
} | ||
if (data instanceof Date) { | ||
return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value]; | ||
} | ||
if (Number.isNaN(data)) { | ||
return [null, hasBlobRef.value]; | ||
} | ||
return [data, hasBlobRef.value]; | ||
} | ||
@@ -262,20 +165,16 @@ }; | ||
// src/openapi/serializer.ts | ||
import { ErrorEvent, isAsyncIteratorObject } from "@orpc/server-standard"; | ||
import { findDeepMatches } from "@orpc/shared"; | ||
import { ErrorEvent, isAsyncIteratorObject } from "@orpc/standard-server"; | ||
var OpenAPISerializer = class { | ||
jsonSerializer; | ||
constructor(options) { | ||
this.jsonSerializer = options?.jsonSerializer ?? new OpenAPIJsonSerializer(); | ||
constructor(jsonSerializer = new OpenAPIJsonSerializer(), bracketNotation = new BracketNotationSerializer()) { | ||
this.jsonSerializer = jsonSerializer; | ||
this.bracketNotation = bracketNotation; | ||
} | ||
serialize(data) { | ||
if (data instanceof Blob || data === void 0) { | ||
return data; | ||
} | ||
if (isAsyncIteratorObject(data)) { | ||
return mapEventIterator(data, { | ||
value: async (value) => this.jsonSerializer.serialize(value), | ||
value: async (value) => this.#serialize(value, false), | ||
error: async (e) => { | ||
if (e instanceof ErrorEvent) { | ||
return new ErrorEvent({ | ||
data: this.jsonSerializer.serialize(e.data), | ||
data: this.#serialize(e.data, false), | ||
cause: e | ||
@@ -285,3 +184,3 @@ }); | ||
return new ErrorEvent({ | ||
data: this.jsonSerializer.serialize(toORPCError(e).toJSON()), | ||
data: this.#serialize(toORPCError(e).toJSON(), false), | ||
cause: e | ||
@@ -292,13 +191,16 @@ }); | ||
} | ||
const serializedJSON = this.jsonSerializer.serialize(data); | ||
const { values: blobs } = findDeepMatches((v) => v instanceof Blob, serializedJSON); | ||
if (blobs.length === 0) { | ||
return serializedJSON; | ||
return this.#serialize(data, true); | ||
} | ||
#serialize(data, enableFormData) { | ||
if (data instanceof Blob || data === void 0) { | ||
return data; | ||
} | ||
const [json, hasBlob] = this.jsonSerializer.serialize(data); | ||
if (!enableFormData || !hasBlob) { | ||
return json; | ||
} | ||
const form = new FormData(); | ||
for (const [path, value] of serialize(serializedJSON)) { | ||
for (const [path, value] of this.bracketNotation.serialize(json)) { | ||
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") { | ||
form.append(path, value.toString()); | ||
} else if (value instanceof Date) { | ||
form.append(path, value.toISOString()); | ||
} else if (value instanceof Blob) { | ||
@@ -310,8 +212,8 @@ form.append(path, value); | ||
} | ||
deserialize(serialized) { | ||
if (serialized instanceof URLSearchParams || serialized instanceof FormData) { | ||
return deserialize([...serialized.entries()]); | ||
deserialize(data) { | ||
if (data instanceof URLSearchParams || data instanceof FormData) { | ||
return this.bracketNotation.deserialize(Array.from(data.entries())); | ||
} | ||
if (isAsyncIteratorObject(serialized)) { | ||
return mapEventIterator(serialized, { | ||
if (isAsyncIteratorObject(data)) { | ||
return mapEventIterator(data, { | ||
value: async (value) => value, | ||
@@ -326,7 +228,7 @@ error: async (e) => { | ||
} | ||
return serialized; | ||
return data; | ||
} | ||
}; | ||
export { | ||
bracket_notation_exports as BracketNotation, | ||
BracketNotationSerializer, | ||
OpenAPIJsonSerializer, | ||
@@ -333,0 +235,0 @@ OpenAPISerializer |
import { | ||
RPCSerializer, | ||
serializeRPCJson | ||
} from "./chunk-TPEMQB7D.js"; | ||
import "./chunk-2UPNYYFF.js"; | ||
RPCJsonSerializer, | ||
RPCSerializer | ||
} from "./chunk-4HZVK3GJ.js"; | ||
import "./chunk-X34KXUAJ.js"; | ||
export { | ||
RPCSerializer, | ||
serializeRPCJson | ||
RPCJsonSerializer, | ||
RPCSerializer | ||
}; | ||
//# sourceMappingURL=rpc.js.map |
@@ -1,84 +0,9 @@ | ||
/** | ||
* Serialize an object or array into a list of [key, value] pairs. | ||
* The key will express by using bracket-notation. | ||
* | ||
* Notice: This way cannot express the empty object or array. | ||
* | ||
* @example | ||
* ```ts | ||
* const payload = { | ||
* name: 'John Doe', | ||
* pets: ['dog', 'cat'], | ||
* } | ||
* | ||
* const entities = serialize(payload) | ||
* | ||
* expect(entities).toEqual([ | ||
* ['name', 'John Doe'], | ||
* ['name[pets][0]', 'dog'], | ||
* ['name[pets][1]', 'cat'], | ||
* ]) | ||
* ``` | ||
*/ | ||
export declare function serialize(payload: unknown, parentKey?: string): [string, unknown][]; | ||
/** | ||
* Deserialize a list of [key, value] pairs into an object or array. | ||
* The key is expressed by using bracket-notation. | ||
* | ||
* @example | ||
* ```ts | ||
* const entities = [ | ||
* ['name', 'John Doe'], | ||
* ['name[pets][0]', 'dog'], | ||
* ['name[pets][1]', 'cat'], | ||
* ['name[dogs][]', 'hello'], | ||
* ['name[dogs][]', 'kitty'], | ||
* ] | ||
* | ||
* const payload = deserialize(entities) | ||
* | ||
* expect(payload).toEqual({ | ||
* name: 'John Doe', | ||
* pets: { 0: 'dog', 1: 'cat' }, | ||
* dogs: ['hello', 'kitty'], | ||
* }) | ||
* ``` | ||
*/ | ||
export declare function deserialize(entities: readonly (readonly [string, unknown])[]): Record<string, unknown> | unknown[] | undefined; | ||
/** | ||
* Escape the `[`, `]`, and `\` chars in a path segment. | ||
* | ||
* @example | ||
* ```ts | ||
* expect(escapeSegment('name[pets')).toEqual('name\\[pets') | ||
* ``` | ||
*/ | ||
export declare function escapeSegment(segment: string): string; | ||
/** | ||
* Convert an array of path segments into a path string using bracket-notation. | ||
* | ||
* For the special char `[`, `]`, and `\` will be escaped by adding `\` at start. | ||
* | ||
* @example | ||
* ```ts | ||
* expect(stringifyPath(['name', 'pets', '0'])).toEqual('name[pets][0]') | ||
* ``` | ||
*/ | ||
export declare function stringifyPath(path: readonly [string, ...string[]]): string; | ||
/** | ||
* Convert a path string using bracket-notation into an array of path segments. | ||
* | ||
* For the special char `[`, `]`, and `\` you should escape by adding `\` at start. | ||
* It only treats a pair `[${string}]` as a path segment. | ||
* If missing or escape it will bypass and treat as normal string. | ||
* | ||
* @example | ||
* ```ts | ||
* expect(parsePath('name[pets][0]')).toEqual(['name', 'pets', '0']) | ||
* expect(parsePath('name[pets][0')).toEqual(['name', 'pets', '[0']) | ||
* expect(parsePath('name[pets[0]')).toEqual(['name', 'pets[0') | ||
* expect(parsePath('name\\[pets][0]')).toEqual(['name[pets]', '0']) | ||
* ``` | ||
*/ | ||
export declare function parsePath(path: string): [string, ...string[]]; | ||
import { type Segment } from '@orpc/shared'; | ||
export type BracketNotationSerialized = [string, unknown][]; | ||
export declare class BracketNotationSerializer { | ||
serialize(data: unknown, segments?: Segment[], result?: BracketNotationSerialized): BracketNotationSerialized; | ||
deserialize(serialized: BracketNotationSerialized): unknown; | ||
stringifyPath(segments: readonly Segment[]): string; | ||
parsePath(path: string): string[]; | ||
} | ||
//# sourceMappingURL=bracket-notation.d.ts.map |
@@ -1,4 +0,4 @@ | ||
export * as BracketNotation from './bracket-notation'; | ||
export * from './bracket-notation'; | ||
export * from './json-serializer'; | ||
export * from './serializer'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,5 +1,7 @@ | ||
export type OpenAPIJsonSerialized = [json: unknown, hasBlob: boolean]; | ||
export declare class OpenAPIJsonSerializer { | ||
serialize(payload: unknown): unknown; | ||
serialize(data: unknown, hasBlobRef?: { | ||
value: boolean; | ||
}): OpenAPIJsonSerialized; | ||
} | ||
export type PublicOpenAPIJsonSerializer = Pick<OpenAPIJsonSerializer, keyof OpenAPIJsonSerializer>; | ||
//# sourceMappingURL=json-serializer.d.ts.map |
@@ -1,11 +0,11 @@ | ||
import type { PublicOpenAPIJsonSerializer } from './json-serializer'; | ||
export interface OpenAPISerializerOptions { | ||
jsonSerializer?: PublicOpenAPIJsonSerializer; | ||
} | ||
import { BracketNotationSerializer } from './bracket-notation'; | ||
import { OpenAPIJsonSerializer } from './json-serializer'; | ||
export declare class OpenAPISerializer { | ||
#private; | ||
private readonly jsonSerializer; | ||
constructor(options?: OpenAPISerializerOptions); | ||
private readonly bracketNotation; | ||
constructor(jsonSerializer?: OpenAPIJsonSerializer, bracketNotation?: BracketNotationSerializer); | ||
serialize(data: unknown): unknown; | ||
deserialize(serialized: unknown): unknown; | ||
deserialize(data: unknown): unknown; | ||
} | ||
//# sourceMappingURL=serializer.d.ts.map |
@@ -0,2 +1,3 @@ | ||
export * from './json-serializer'; | ||
export * from './serializer'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,22 +0,9 @@ | ||
import type { Segment } from '@orpc/shared'; | ||
export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url', Segment[]][]; | ||
export type RPCSerialized = { | ||
json: unknown; | ||
meta: RPCSerializedJsonMeta; | ||
} | FormData | AsyncIteratorObject<{ | ||
json: unknown; | ||
meta: RPCSerializedJsonMeta; | ||
}, { | ||
json: unknown; | ||
meta: RPCSerializedJsonMeta; | ||
}, void>; | ||
export type RPCSerializedFormDataMaps = Segment[][]; | ||
import { RPCJsonSerializer } from './json-serializer'; | ||
export declare class RPCSerializer { | ||
serialize(data: unknown): RPCSerialized; | ||
deserialize(serialized: RPCSerialized): unknown; | ||
#private; | ||
private readonly jsonSerializer; | ||
constructor(jsonSerializer?: RPCJsonSerializer); | ||
serialize(data: unknown): unknown; | ||
deserialize(data: unknown): unknown; | ||
} | ||
export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): { | ||
json: unknown; | ||
meta: RPCSerializedJsonMeta; | ||
}; | ||
//# sourceMappingURL=serializer.d.ts.map |
import type { ORPCError } from './error'; | ||
import type { ClientPromiseResult } from './types'; | ||
export type SafeResult<TOutput, TError extends Error> = [output: TOutput, error: undefined, isDefinedError: false] | [output: undefined, error: TError, isDefinedError: false] | [output: undefined, error: Extract<TError, ORPCError<any, any>>, isDefinedError: true]; | ||
export type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, isDefined: false] & { | ||
error: null; | ||
data: TOutput; | ||
isDefined: false; | ||
} | [error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false] & { | ||
error: Exclude<TError, ORPCError<any, any>>; | ||
data: undefined; | ||
isDefined: false; | ||
} | [error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true] & { | ||
error: Extract<TError, ORPCError<any, any>>; | ||
data: undefined; | ||
isDefined: true; | ||
}; | ||
export declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>; | ||
//# sourceMappingURL=utils.d.ts.map |
{ | ||
"name": "@orpc/client", | ||
"type": "module", | ||
"version": "0.0.0-next.7d3bd71", | ||
"version": "0.0.0-next.7e41bc4", | ||
"license": "MIT", | ||
@@ -47,5 +47,5 @@ "homepage": "https://orpc.unnoq.com", | ||
"dependencies": { | ||
"@orpc/server-standard": "^0.4.0", | ||
"@orpc/server-standard-fetch": "^0.4.0", | ||
"@orpc/shared": "0.0.0-next.7d3bd71" | ||
"@orpc/shared": "0.0.0-next.7e41bc4", | ||
"@orpc/standard-server": "0.0.0-next.7e41bc4", | ||
"@orpc/standard-server-fetch": "0.0.0-next.7e41bc4" | ||
}, | ||
@@ -52,0 +52,0 @@ "devDependencies": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
50608
27
0
89
1281
+ Added@orpc/shared@0.0.0-next.7e41bc4(transitive)
+ Added@orpc/standard-server@0.0.0-next.7e41bc4(transitive)
+ Added@orpc/standard-server-fetch@0.0.0-next.7e41bc4(transitive)
- Removed@orpc/server-standard@^0.4.0
- Removed@orpc/server-standard-fetch@^0.4.0
- Removed@orpc/server-standard@0.4.0(transitive)
- Removed@orpc/server-standard-fetch@0.4.0(transitive)
- Removed@orpc/shared@0.0.0-next.7d3bd71(transitive)