@orpc/client 1.14.10 → 1.14.11

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 (38) hide show
  1. package/README.md +52 -68
  2. package/dist/adapters/fetch/index.d.mts +54 -35
  3. package/dist/adapters/fetch/index.d.ts +54 -35
  4. package/dist/adapters/fetch/index.mjs +74 -27
  5. package/dist/adapters/message-port/index.d.mts +25 -30
  6. package/dist/adapters/message-port/index.d.ts +25 -30
  7. package/dist/adapters/message-port/index.mjs +39 -30
  8. package/dist/adapters/standard/index.d.mts +59 -9
  9. package/dist/adapters/standard/index.d.ts +59 -9
  10. package/dist/adapters/standard/index.mjs +5 -5
  11. package/dist/adapters/websocket/index.d.mts +113 -21
  12. package/dist/adapters/websocket/index.d.ts +113 -21
  13. package/dist/adapters/websocket/index.mjs +95 -37
  14. package/dist/index.d.mts +75 -184
  15. package/dist/index.d.ts +75 -184
  16. package/dist/index.mjs +74 -63
  17. package/dist/plugins/index.d.mts +191 -122
  18. package/dist/plugins/index.d.ts +191 -122
  19. package/dist/plugins/index.mjs +627 -281
  20. package/dist/shared/client.8f4DNmdE.d.mts +96 -0
  21. package/dist/shared/client.BBZBQID8.d.mts +167 -0
  22. package/dist/shared/client.BBZBQID8.d.ts +167 -0
  23. package/dist/shared/client.BMKYqpdy.d.ts +96 -0
  24. package/dist/shared/client.BRJnOJ0R.mjs +174 -0
  25. package/dist/shared/client.BdItY5DT.d.mts +111 -0
  26. package/dist/shared/client.BdItY5DT.d.ts +111 -0
  27. package/dist/shared/client.Dnfj8jnT.mjs +92 -0
  28. package/dist/shared/client.DqYwRDUO.mjs +343 -0
  29. package/package.json +7 -7
  30. package/dist/shared/client.2jUAqzYU.d.ts +0 -45
  31. package/dist/shared/client.B3pNRBih.d.ts +0 -91
  32. package/dist/shared/client.BFAVy68H.d.mts +0 -91
  33. package/dist/shared/client.BLtwTQUg.mjs +0 -40
  34. package/dist/shared/client.CpCa3si8.d.mts +0 -45
  35. package/dist/shared/client.DsgfctKs.mjs +0 -174
  36. package/dist/shared/client.i2uoJbEp.d.mts +0 -83
  37. package/dist/shared/client.i2uoJbEp.d.ts +0 -83
  38. package/dist/shared/client.wv-wJnEy.mjs +0 -404
@@ -0,0 +1,96 @@
1
+ import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
2
+ import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
3
+ import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.BBZBQID8.mjs';
4
+
5
+ type StandardLinkCodecDecodedResponse = {
6
+ kind: 'output';
7
+ output: unknown;
8
+ } | {
9
+ kind: 'error';
10
+ error: AnyORPCError;
11
+ };
12
+ interface StandardLinkCodec<T extends ClientContext> {
13
+ encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promisable<StandardRequest>;
14
+ decodeResponse(response: StandardLazyResponse, path: string[], options: ClientOptions<T>): Promisable<StandardLinkCodecDecodedResponse>;
15
+ }
16
+
17
+ interface StandardLinkPlugin<T extends ClientContext> extends OrderablePlugin {
18
+ /**
19
+ * Initializes the plugin and returns new link options.
20
+ * Called once per plugin instance during composition.
21
+ *
22
+ * This method allows plugins to wrap, extend, or transform link options
23
+ * such as interceptors, or configuration.
24
+ *
25
+ * @param options - The current link options from previous plugins or base configuration
26
+ * @returns Transformed link options with plugin's modifications applied
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * init(options) {
31
+ * return {
32
+ * ...options,
33
+ * interceptors: [...(options.interceptors || []), myInterceptor]
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ init?(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
39
+ }
40
+ declare class CompositeStandardLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
41
+ name: string;
42
+ protected readonly plugins: StandardLinkPlugin<T>[];
43
+ constructor(plugins?: StandardLinkPlugin<T>[]);
44
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
45
+ }
46
+
47
+ /**
48
+ * Handles the transport layer for sending requests and receiving responses.
49
+ *
50
+ * Implementations are responsible for the actual network communication,
51
+ * such as HTTP fetch, WebSocket, or other transport mechanisms.
52
+ */
53
+ interface StandardLinkTransport<T extends ClientContext> {
54
+ /**
55
+ * @throws Transport-level errors (network failures, timeouts, etc.)
56
+ */
57
+ send(request: StandardRequest, path: string[], options: ClientOptions<T>): Promise<StandardLazyResponse>;
58
+ }
59
+
60
+ interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
61
+ path: string[];
62
+ input: unknown;
63
+ }
64
+ type StandardLinkInterceptor<T extends ClientContext> = Interceptor<StandardLinkInterceptorOptions<T>, Promise<unknown>>;
65
+ interface StandardLinkTransportInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
66
+ path: string[];
67
+ request: StandardRequest;
68
+ }
69
+ type StandardLinkTransportInterceptor<T extends ClientContext> = Interceptor<StandardLinkTransportInterceptorOptions<T>, Promise<StandardLazyResponse>>;
70
+ interface StandardLinkOptions<T extends ClientContext> {
71
+ /**
72
+ * Interceptors that execute around the entire call, including transport and codec.
73
+ * Useful for error handling, logging, metrics, ...
74
+ */
75
+ interceptors?: StandardLinkInterceptor<T>[];
76
+ /**
77
+ * Interceptors that execute around the transport layer, after encoding and before decoding.
78
+ * Useful for modifying the request or response, adding transport-level logging, ...
79
+ */
80
+ transportInterceptors?: StandardLinkTransportInterceptor<T>[];
81
+ plugins?: StandardLinkPlugin<T>[];
82
+ }
83
+ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
84
+ private readonly codec;
85
+ private readonly transport;
86
+ private readonly interceptors;
87
+ private readonly transportInterceptors;
88
+ constructor(codec: StandardLinkCodec<T>, transport: StandardLinkTransport<T>, options?: StandardLinkOptions<T>);
89
+ /**
90
+ * @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
91
+ */
92
+ call(path: string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
93
+ }
94
+
95
+ export { CompositeStandardLinkPlugin as C, StandardLink as a };
96
+ export type { StandardLinkTransport as S, StandardLinkOptions as b, StandardLinkPlugin as c, StandardLinkTransportInterceptorOptions as d, StandardLinkInterceptorOptions as e, StandardLinkCodec as f, StandardLinkCodecDecodedResponse as g, StandardLinkInterceptor as h, StandardLinkTransportInterceptor as i };
@@ -0,0 +1,167 @@
1
+ import { PromiseWithError, Registry, MaybeOptionalOptions } from '@orpc/shared';
2
+
3
+ interface ClientContext {
4
+ [key: PropertyKey]: any;
5
+ }
6
+ interface ClientOptions<T extends ClientContext> {
7
+ signal?: AbortSignal | undefined;
8
+ lastEventId?: string | undefined;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (object extends T ? {
12
+ context?: T;
13
+ } : {
14
+ context: T;
15
+ });
16
+ type ClientRest<TClientContext extends ClientContext, TInput> = object extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
17
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
18
+ (...rest: ClientRest<TClientContext, TInput>): PromiseWithError<TOutput, TError>;
19
+ }
20
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
21
+ [k: string]: NestedClient<TClientContext>;
22
+ };
23
+ type AnyNestedClient = NestedClient<any>;
24
+ type InferClientContext<T extends AnyNestedClient> = T extends NestedClient<infer U> ? U : never;
25
+ interface ClientLink<TClientContext extends ClientContext> {
26
+ call: (path: string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
27
+ }
28
+ /**
29
+ * Recursively infers the **input types** from a client.
30
+ *
31
+ * Produces a nested map where each endpoint's input type is preserved.
32
+ */
33
+ type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U : {
34
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientInputs<T[K]> : never;
35
+ };
36
+ /**
37
+ * Recursively infers the **body input types** from a client.
38
+ *
39
+ * If an endpoint's input includes `{ body: ... }`, only the `body` portion is extracted.
40
+ * Produces a nested map of body input types.
41
+ */
42
+ type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U extends {
43
+ body: infer UBody;
44
+ } ? UBody : U : {
45
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyInputs<T[K]> : never;
46
+ };
47
+ /**
48
+ * Recursively infers the **output types** from a client.
49
+ *
50
+ * Produces a nested map where each endpoint's output type is preserved.
51
+ */
52
+ type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U : {
53
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientOutputs<T[K]> : never;
54
+ };
55
+ /**
56
+ * Recursively infers the **body output types** from a client.
57
+ *
58
+ * If an endpoint's output includes `{ body: ... }`, only the `body` portion is extracted.
59
+ * Produces a nested map of body output types.
60
+ */
61
+ type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U extends {
62
+ body: infer UBody;
63
+ } ? UBody : U : {
64
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyOutputs<T[K]> : never;
65
+ };
66
+ /**
67
+ * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
68
+ *
69
+ * Produces a nested map where each endpoint's error type is preserved.
70
+ */
71
+ type InferClientErrors<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
72
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientErrors<T[K]> : never;
73
+ };
74
+ /**
75
+ * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
76
+ *
77
+ * Useful when you want to handle all possible errors from any endpoint at once.
78
+ */
79
+ type InferClientError<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
80
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientError<T[K]> : never;
81
+ }[keyof T];
82
+
83
+ declare const COMMON_ERROR_STATUS_MAP: {
84
+ BAD_REQUEST: number;
85
+ UNAUTHORIZED: number;
86
+ PAYMENT_REQUIRED: number;
87
+ FORBIDDEN: number;
88
+ NOT_FOUND: number;
89
+ METHOD_NOT_SUPPORTED: number;
90
+ NOT_ACCEPTABLE: number;
91
+ TIMEOUT: number;
92
+ CONFLICT: number;
93
+ GONE: number;
94
+ PRECONDITION_FAILED: number;
95
+ PAYLOAD_TOO_LARGE: number;
96
+ UNSUPPORTED_MEDIA_TYPE: number;
97
+ UNPROCESSABLE_CONTENT: number;
98
+ PRECONDITION_REQUIRED: number;
99
+ TOO_MANY_REQUESTS: number;
100
+ CLIENT_CLOSED_REQUEST: number;
101
+ INTERNAL_SERVER_ERROR: number;
102
+ NOT_IMPLEMENTED: number;
103
+ BAD_GATEWAY: number;
104
+ SERVICE_UNAVAILABLE: number;
105
+ GATEWAY_TIMEOUT: number;
106
+ };
107
+ type ORPCErrorCode = Registry extends {
108
+ ORPCErrorCode: infer T extends string;
109
+ } ? T : (keyof typeof COMMON_ERROR_STATUS_MAP) | (string & {});
110
+ type ORPCErrorOptions<TData> = ErrorOptions & {
111
+ message?: string;
112
+ } & (undefined extends TData ? {
113
+ data?: TData;
114
+ } : {
115
+ data: TData;
116
+ });
117
+ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
118
+ /**
119
+ * @info
120
+ * The `__branch` property is used for type branding, helping TypeScript distinguish
121
+ * an `ORPCError` instance from plain objects with a similar structure.
122
+ */
123
+ readonly name: "ORPCError" & {
124
+ __branch: "ORPCError";
125
+ };
126
+ /**
127
+ * Indicates whether the error matches a definition in the procedure's `.errors` map.
128
+ */
129
+ readonly defined: boolean;
130
+ /**
131
+ * Indicates whether the error's type is inferable at the TypeScript level.
132
+ * This is typically true when the error is explicitly defined or returned within a handler.
133
+ */
134
+ readonly inferable: boolean;
135
+ code: TCode;
136
+ data: TData;
137
+ constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
138
+ toJSON(): ORPCErrorJSON<TCode, TData>;
139
+ /**
140
+ * Workaround for Next.js where different contexts use separate
141
+ * dependency graphs, causing multiple ORPCError constructors existing and breaking
142
+ * `instanceof` checks across contexts.
143
+ *
144
+ * This is particularly problematic with "Optimized SSR", where orpc-client
145
+ * executes in one context but is invoked from another. When an error is thrown
146
+ * in the execution context, `instanceof ORPCError` checks fail in the
147
+ * invocation context due to separate class constructors.
148
+ *
149
+ * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
150
+ */
151
+ static [Symbol.hasInstance](instance: unknown): boolean;
152
+ }
153
+ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCode, TData>, 'code' | 'message' | 'data'> {
154
+ /**
155
+ * remove readonly
156
+ */
157
+ defined: boolean;
158
+ /**
159
+ * remove readonly
160
+ */
161
+ inferable: boolean;
162
+ }
163
+ type AnyORPCError = ORPCError<any, any>;
164
+ type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
165
+
166
+ export { ORPCError as g, COMMON_ERROR_STATUS_MAP as j };
167
+ export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as h, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, ORPCErrorOptions as p };
@@ -0,0 +1,167 @@
1
+ import { PromiseWithError, Registry, MaybeOptionalOptions } from '@orpc/shared';
2
+
3
+ interface ClientContext {
4
+ [key: PropertyKey]: any;
5
+ }
6
+ interface ClientOptions<T extends ClientContext> {
7
+ signal?: AbortSignal | undefined;
8
+ lastEventId?: string | undefined;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (object extends T ? {
12
+ context?: T;
13
+ } : {
14
+ context: T;
15
+ });
16
+ type ClientRest<TClientContext extends ClientContext, TInput> = object extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
17
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
18
+ (...rest: ClientRest<TClientContext, TInput>): PromiseWithError<TOutput, TError>;
19
+ }
20
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
21
+ [k: string]: NestedClient<TClientContext>;
22
+ };
23
+ type AnyNestedClient = NestedClient<any>;
24
+ type InferClientContext<T extends AnyNestedClient> = T extends NestedClient<infer U> ? U : never;
25
+ interface ClientLink<TClientContext extends ClientContext> {
26
+ call: (path: string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
27
+ }
28
+ /**
29
+ * Recursively infers the **input types** from a client.
30
+ *
31
+ * Produces a nested map where each endpoint's input type is preserved.
32
+ */
33
+ type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U : {
34
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientInputs<T[K]> : never;
35
+ };
36
+ /**
37
+ * Recursively infers the **body input types** from a client.
38
+ *
39
+ * If an endpoint's input includes `{ body: ... }`, only the `body` portion is extracted.
40
+ * Produces a nested map of body input types.
41
+ */
42
+ type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U extends {
43
+ body: infer UBody;
44
+ } ? UBody : U : {
45
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyInputs<T[K]> : never;
46
+ };
47
+ /**
48
+ * Recursively infers the **output types** from a client.
49
+ *
50
+ * Produces a nested map where each endpoint's output type is preserved.
51
+ */
52
+ type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U : {
53
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientOutputs<T[K]> : never;
54
+ };
55
+ /**
56
+ * Recursively infers the **body output types** from a client.
57
+ *
58
+ * If an endpoint's output includes `{ body: ... }`, only the `body` portion is extracted.
59
+ * Produces a nested map of body output types.
60
+ */
61
+ type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U extends {
62
+ body: infer UBody;
63
+ } ? UBody : U : {
64
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyOutputs<T[K]> : never;
65
+ };
66
+ /**
67
+ * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
68
+ *
69
+ * Produces a nested map where each endpoint's error type is preserved.
70
+ */
71
+ type InferClientErrors<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
72
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientErrors<T[K]> : never;
73
+ };
74
+ /**
75
+ * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
76
+ *
77
+ * Useful when you want to handle all possible errors from any endpoint at once.
78
+ */
79
+ type InferClientError<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
80
+ [K in keyof T]: T[K] extends AnyNestedClient ? InferClientError<T[K]> : never;
81
+ }[keyof T];
82
+
83
+ declare const COMMON_ERROR_STATUS_MAP: {
84
+ BAD_REQUEST: number;
85
+ UNAUTHORIZED: number;
86
+ PAYMENT_REQUIRED: number;
87
+ FORBIDDEN: number;
88
+ NOT_FOUND: number;
89
+ METHOD_NOT_SUPPORTED: number;
90
+ NOT_ACCEPTABLE: number;
91
+ TIMEOUT: number;
92
+ CONFLICT: number;
93
+ GONE: number;
94
+ PRECONDITION_FAILED: number;
95
+ PAYLOAD_TOO_LARGE: number;
96
+ UNSUPPORTED_MEDIA_TYPE: number;
97
+ UNPROCESSABLE_CONTENT: number;
98
+ PRECONDITION_REQUIRED: number;
99
+ TOO_MANY_REQUESTS: number;
100
+ CLIENT_CLOSED_REQUEST: number;
101
+ INTERNAL_SERVER_ERROR: number;
102
+ NOT_IMPLEMENTED: number;
103
+ BAD_GATEWAY: number;
104
+ SERVICE_UNAVAILABLE: number;
105
+ GATEWAY_TIMEOUT: number;
106
+ };
107
+ type ORPCErrorCode = Registry extends {
108
+ ORPCErrorCode: infer T extends string;
109
+ } ? T : (keyof typeof COMMON_ERROR_STATUS_MAP) | (string & {});
110
+ type ORPCErrorOptions<TData> = ErrorOptions & {
111
+ message?: string;
112
+ } & (undefined extends TData ? {
113
+ data?: TData;
114
+ } : {
115
+ data: TData;
116
+ });
117
+ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
118
+ /**
119
+ * @info
120
+ * The `__branch` property is used for type branding, helping TypeScript distinguish
121
+ * an `ORPCError` instance from plain objects with a similar structure.
122
+ */
123
+ readonly name: "ORPCError" & {
124
+ __branch: "ORPCError";
125
+ };
126
+ /**
127
+ * Indicates whether the error matches a definition in the procedure's `.errors` map.
128
+ */
129
+ readonly defined: boolean;
130
+ /**
131
+ * Indicates whether the error's type is inferable at the TypeScript level.
132
+ * This is typically true when the error is explicitly defined or returned within a handler.
133
+ */
134
+ readonly inferable: boolean;
135
+ code: TCode;
136
+ data: TData;
137
+ constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
138
+ toJSON(): ORPCErrorJSON<TCode, TData>;
139
+ /**
140
+ * Workaround for Next.js where different contexts use separate
141
+ * dependency graphs, causing multiple ORPCError constructors existing and breaking
142
+ * `instanceof` checks across contexts.
143
+ *
144
+ * This is particularly problematic with "Optimized SSR", where orpc-client
145
+ * executes in one context but is invoked from another. When an error is thrown
146
+ * in the execution context, `instanceof ORPCError` checks fail in the
147
+ * invocation context due to separate class constructors.
148
+ *
149
+ * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
150
+ */
151
+ static [Symbol.hasInstance](instance: unknown): boolean;
152
+ }
153
+ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCode, TData>, 'code' | 'message' | 'data'> {
154
+ /**
155
+ * remove readonly
156
+ */
157
+ defined: boolean;
158
+ /**
159
+ * remove readonly
160
+ */
161
+ inferable: boolean;
162
+ }
163
+ type AnyORPCError = ORPCError<any, any>;
164
+ type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
165
+
166
+ export { ORPCError as g, COMMON_ERROR_STATUS_MAP as j };
167
+ export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as h, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, ORPCErrorOptions as p };
@@ -0,0 +1,96 @@
1
+ import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
2
+ import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
3
+ import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.BBZBQID8.js';
4
+
5
+ type StandardLinkCodecDecodedResponse = {
6
+ kind: 'output';
7
+ output: unknown;
8
+ } | {
9
+ kind: 'error';
10
+ error: AnyORPCError;
11
+ };
12
+ interface StandardLinkCodec<T extends ClientContext> {
13
+ encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promisable<StandardRequest>;
14
+ decodeResponse(response: StandardLazyResponse, path: string[], options: ClientOptions<T>): Promisable<StandardLinkCodecDecodedResponse>;
15
+ }
16
+
17
+ interface StandardLinkPlugin<T extends ClientContext> extends OrderablePlugin {
18
+ /**
19
+ * Initializes the plugin and returns new link options.
20
+ * Called once per plugin instance during composition.
21
+ *
22
+ * This method allows plugins to wrap, extend, or transform link options
23
+ * such as interceptors, or configuration.
24
+ *
25
+ * @param options - The current link options from previous plugins or base configuration
26
+ * @returns Transformed link options with plugin's modifications applied
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * init(options) {
31
+ * return {
32
+ * ...options,
33
+ * interceptors: [...(options.interceptors || []), myInterceptor]
34
+ * }
35
+ * }
36
+ * ```
37
+ */
38
+ init?(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
39
+ }
40
+ declare class CompositeStandardLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
41
+ name: string;
42
+ protected readonly plugins: StandardLinkPlugin<T>[];
43
+ constructor(plugins?: StandardLinkPlugin<T>[]);
44
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
45
+ }
46
+
47
+ /**
48
+ * Handles the transport layer for sending requests and receiving responses.
49
+ *
50
+ * Implementations are responsible for the actual network communication,
51
+ * such as HTTP fetch, WebSocket, or other transport mechanisms.
52
+ */
53
+ interface StandardLinkTransport<T extends ClientContext> {
54
+ /**
55
+ * @throws Transport-level errors (network failures, timeouts, etc.)
56
+ */
57
+ send(request: StandardRequest, path: string[], options: ClientOptions<T>): Promise<StandardLazyResponse>;
58
+ }
59
+
60
+ interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
61
+ path: string[];
62
+ input: unknown;
63
+ }
64
+ type StandardLinkInterceptor<T extends ClientContext> = Interceptor<StandardLinkInterceptorOptions<T>, Promise<unknown>>;
65
+ interface StandardLinkTransportInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
66
+ path: string[];
67
+ request: StandardRequest;
68
+ }
69
+ type StandardLinkTransportInterceptor<T extends ClientContext> = Interceptor<StandardLinkTransportInterceptorOptions<T>, Promise<StandardLazyResponse>>;
70
+ interface StandardLinkOptions<T extends ClientContext> {
71
+ /**
72
+ * Interceptors that execute around the entire call, including transport and codec.
73
+ * Useful for error handling, logging, metrics, ...
74
+ */
75
+ interceptors?: StandardLinkInterceptor<T>[];
76
+ /**
77
+ * Interceptors that execute around the transport layer, after encoding and before decoding.
78
+ * Useful for modifying the request or response, adding transport-level logging, ...
79
+ */
80
+ transportInterceptors?: StandardLinkTransportInterceptor<T>[];
81
+ plugins?: StandardLinkPlugin<T>[];
82
+ }
83
+ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
84
+ private readonly codec;
85
+ private readonly transport;
86
+ private readonly interceptors;
87
+ private readonly transportInterceptors;
88
+ constructor(codec: StandardLinkCodec<T>, transport: StandardLinkTransport<T>, options?: StandardLinkOptions<T>);
89
+ /**
90
+ * @throws ORPCError, transport-level errors (network failures, timeouts, etc.)
91
+ */
92
+ call(path: string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
93
+ }
94
+
95
+ export { CompositeStandardLinkPlugin as C, StandardLink as a };
96
+ export type { StandardLinkTransport as S, StandardLinkOptions as b, StandardLinkPlugin as c, StandardLinkTransportInterceptorOptions as d, StandardLinkInterceptorOptions as e, StandardLinkCodec as f, StandardLinkCodecDecodedResponse as g, StandardLinkInterceptor as h, StandardLinkTransportInterceptor as i };