@orpc/client 0.43.0 → 0.45.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.
Files changed (34) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/fetch/index.d.mts +103 -0
  3. package/dist/{src/adapters/fetch/rpc-link.d.ts → adapters/fetch/index.d.ts} +15 -10
  4. package/dist/{fetch.js → adapters/fetch/index.mjs} +15 -22
  5. package/dist/adapters/standard/index.d.mts +22 -0
  6. package/dist/adapters/standard/index.d.ts +22 -0
  7. package/dist/adapters/standard/index.mjs +4 -0
  8. package/dist/index.d.mts +153 -0
  9. package/dist/index.d.ts +153 -0
  10. package/dist/{index.js → index.mjs} +8 -35
  11. package/dist/{chunk-4HZVK3GJ.js → shared/client.DHJ8vRIG.mjs} +9 -29
  12. package/dist/shared/client.D_CzLDyB.d.mts +42 -0
  13. package/dist/shared/client.D_CzLDyB.d.ts +42 -0
  14. package/dist/{chunk-X34KXUAJ.js → shared/client.Ly4zGQrc.mjs} +12 -28
  15. package/package.json +15 -25
  16. package/dist/openapi.js +0 -231
  17. package/dist/rpc.js +0 -10
  18. package/dist/src/adapters/fetch/index.d.ts +0 -3
  19. package/dist/src/adapters/fetch/types.d.ts +0 -5
  20. package/dist/src/client.d.ts +0 -9
  21. package/dist/src/dynamic-link.d.ts +0 -12
  22. package/dist/src/error.d.ts +0 -106
  23. package/dist/src/event-iterator-state.d.ts +0 -9
  24. package/dist/src/event-iterator.d.ts +0 -12
  25. package/dist/src/index.d.ts +0 -9
  26. package/dist/src/openapi/bracket-notation.d.ts +0 -9
  27. package/dist/src/openapi/index.d.ts +0 -4
  28. package/dist/src/openapi/json-serializer.d.ts +0 -7
  29. package/dist/src/openapi/serializer.d.ts +0 -11
  30. package/dist/src/rpc/index.d.ts +0 -3
  31. package/dist/src/rpc/json-serializer.d.ts +0 -12
  32. package/dist/src/rpc/serializer.d.ts +0 -9
  33. package/dist/src/types.d.ts +0 -29
  34. package/dist/src/utils.d.ts +0 -17
@@ -1,106 +0,0 @@
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,9 +0,0 @@
1
- export type ConnectionStatus = 'reconnecting' | 'connected' | 'closed';
2
- export interface EventIteratorState {
3
- status: ConnectionStatus;
4
- listeners: Array<(newStatus: ConnectionStatus) => void>;
5
- }
6
- export declare function registerEventIteratorState(iterator: AsyncIteratorObject<unknown, unknown, void>, state: EventIteratorState): void;
7
- export declare function updateEventIteratorStatus(state: EventIteratorState, status: ConnectionStatus): void;
8
- export declare function onEventIteratorStatusChange(iterator: AsyncIteratorObject<unknown, unknown, void>, callback: (status: ConnectionStatus) => void, notifyImmediately?: boolean): () => void;
9
- //# sourceMappingURL=event-iterator-state.d.ts.map
@@ -1,12 +0,0 @@
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>;
5
- export interface EventIteratorReconnectOptions {
6
- lastRetry: number | undefined;
7
- lastEventId: string | undefined;
8
- retryTimes: number;
9
- error: unknown;
10
- }
11
- export 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>;
12
- //# sourceMappingURL=event-iterator.d.ts.map
@@ -1,9 +0,0 @@
1
- /** unnoq */
2
- export * from './client';
3
- export * from './dynamic-link';
4
- export * from './error';
5
- export * from './event-iterator';
6
- export * from './event-iterator-state';
7
- export * from './types';
8
- export * from './utils';
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,9 +0,0 @@
1
- import { type Segment } from '@orpc/shared';
2
- export type BracketNotationSerialized = [string, unknown][];
3
- export declare class BracketNotationSerializer {
4
- serialize(data: unknown, segments?: Segment[], result?: BracketNotationSerialized): BracketNotationSerialized;
5
- deserialize(serialized: BracketNotationSerialized): unknown;
6
- stringifyPath(segments: readonly Segment[]): string;
7
- parsePath(path: string): string[];
8
- }
9
- //# sourceMappingURL=bracket-notation.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './bracket-notation';
2
- export * from './json-serializer';
3
- export * from './serializer';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,7 +0,0 @@
1
- export type OpenAPIJsonSerialized = [json: unknown, hasBlob: boolean];
2
- export declare class OpenAPIJsonSerializer {
3
- serialize(data: unknown, hasBlobRef?: {
4
- value: boolean;
5
- }): OpenAPIJsonSerialized;
6
- }
7
- //# sourceMappingURL=json-serializer.d.ts.map
@@ -1,11 +0,0 @@
1
- import { BracketNotationSerializer } from './bracket-notation';
2
- import { OpenAPIJsonSerializer } from './json-serializer';
3
- export declare class OpenAPISerializer {
4
- #private;
5
- private readonly jsonSerializer;
6
- private readonly bracketNotation;
7
- constructor(jsonSerializer?: OpenAPIJsonSerializer, bracketNotation?: BracketNotationSerializer);
8
- serialize(data: unknown): unknown;
9
- deserialize(data: unknown): unknown;
10
- }
11
- //# sourceMappingURL=serializer.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from './json-serializer';
2
- export * from './serializer';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,12 +0,0 @@
1
- import { type Segment } from '@orpc/shared';
2
- export type RPCJsonSerializedMeta = [
3
- 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7,
4
- Segment[]
5
- ][];
6
- export type RPCJsonSerialized = [json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], blobs: Blob[]];
7
- export declare class RPCJsonSerializer {
8
- serialize(data: unknown, segments?: Segment[], meta?: RPCJsonSerializedMeta, maps?: Segment[][], blobs?: Blob[]): RPCJsonSerialized;
9
- deserialize(json: unknown, meta: RPCJsonSerializedMeta): unknown;
10
- deserialize(json: unknown, meta: RPCJsonSerializedMeta, maps: Segment[][], getBlob: (index: number) => Blob): unknown;
11
- }
12
- //# sourceMappingURL=json-serializer.d.ts.map
@@ -1,9 +0,0 @@
1
- import { RPCJsonSerializer } from './json-serializer';
2
- export declare class RPCSerializer {
3
- #private;
4
- private readonly jsonSerializer;
5
- constructor(jsonSerializer?: RPCJsonSerializer);
6
- serialize(data: unknown): unknown;
7
- deserialize(data: unknown): unknown;
8
- }
9
- //# sourceMappingURL=serializer.d.ts.map
@@ -1,29 +0,0 @@
1
- export type ClientContext = Record<string, any>;
2
- export 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
- export 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
- export type ClientPromiseResult<TOutput, TError extends Error> = Promise<TOutput> & {
12
- __error?: {
13
- type: TError;
14
- };
15
- };
16
- export interface Client<TClientContext extends ClientContext, TInput, TOutput, TError extends Error> {
17
- (...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
18
- }
19
- export type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
20
- [k: string]: NestedClient<TClientContext>;
21
- };
22
- export type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
23
- export type ClientOptionsOut<TClientContext extends ClientContext> = ClientOptions<TClientContext> & {
24
- context: TClientContext;
25
- };
26
- export interface ClientLink<TClientContext extends ClientContext> {
27
- call: (path: readonly string[], input: unknown, options: ClientOptionsOut<TClientContext>) => Promise<unknown>;
28
- }
29
- //# sourceMappingURL=types.d.ts.map
@@ -1,17 +0,0 @@
1
- import type { ORPCError } from './error';
2
- import type { ClientPromiseResult } from './types';
3
- export type SafeResult<TOutput, TError extends Error> = [error: null, data: TOutput, isDefined: false] & {
4
- error: null;
5
- data: TOutput;
6
- isDefined: false;
7
- } | [error: Exclude<TError, ORPCError<any, any>>, data: undefined, isDefined: false] & {
8
- error: Exclude<TError, ORPCError<any, any>>;
9
- data: undefined;
10
- isDefined: false;
11
- } | [error: Extract<TError, ORPCError<any, any>>, data: undefined, isDefined: true] & {
12
- error: Extract<TError, ORPCError<any, any>>;
13
- data: undefined;
14
- isDefined: true;
15
- };
16
- export declare function safe<TOutput, TError extends Error>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
17
- //# sourceMappingURL=utils.d.ts.map