@orpc/client 1.14.11 → 1.14.12

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 +68 -52
  2. package/dist/adapters/fetch/index.d.mts +35 -54
  3. package/dist/adapters/fetch/index.d.ts +35 -54
  4. package/dist/adapters/fetch/index.mjs +27 -74
  5. package/dist/adapters/message-port/index.d.mts +30 -25
  6. package/dist/adapters/message-port/index.d.ts +30 -25
  7. package/dist/adapters/message-port/index.mjs +30 -39
  8. package/dist/adapters/standard/index.d.mts +9 -59
  9. package/dist/adapters/standard/index.d.ts +9 -59
  10. package/dist/adapters/standard/index.mjs +5 -5
  11. package/dist/adapters/websocket/index.d.mts +21 -113
  12. package/dist/adapters/websocket/index.d.ts +21 -113
  13. package/dist/adapters/websocket/index.mjs +37 -95
  14. package/dist/index.d.mts +184 -75
  15. package/dist/index.d.ts +184 -75
  16. package/dist/index.mjs +63 -74
  17. package/dist/plugins/index.d.mts +122 -191
  18. package/dist/plugins/index.d.ts +122 -191
  19. package/dist/plugins/index.mjs +281 -627
  20. package/dist/shared/client.2jUAqzYU.d.ts +45 -0
  21. package/dist/shared/client.B3pNRBih.d.ts +91 -0
  22. package/dist/shared/client.BFAVy68H.d.mts +91 -0
  23. package/dist/shared/client.BLtwTQUg.mjs +40 -0
  24. package/dist/shared/client.C1VUaWTu.mjs +404 -0
  25. package/dist/shared/client.CpCa3si8.d.mts +45 -0
  26. package/dist/shared/client.DrCRv_sG.mjs +174 -0
  27. package/dist/shared/client.i2uoJbEp.d.mts +83 -0
  28. package/dist/shared/client.i2uoJbEp.d.ts +83 -0
  29. package/package.json +7 -7
  30. package/dist/shared/client.8f4DNmdE.d.mts +0 -96
  31. package/dist/shared/client.BBZBQID8.d.mts +0 -167
  32. package/dist/shared/client.BBZBQID8.d.ts +0 -167
  33. package/dist/shared/client.BMKYqpdy.d.ts +0 -96
  34. package/dist/shared/client.BRJnOJ0R.mjs +0 -174
  35. package/dist/shared/client.BdItY5DT.d.mts +0 -111
  36. package/dist/shared/client.BdItY5DT.d.ts +0 -111
  37. package/dist/shared/client.Dnfj8jnT.mjs +0 -92
  38. package/dist/shared/client.DqYwRDUO.mjs +0 -343
@@ -0,0 +1,45 @@
1
+ import { Interceptor } from '@orpc/shared';
2
+ import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
+ import { b as ClientContext, c as ClientOptions, C as ClientLink } from './client.i2uoJbEp.mjs';
4
+
5
+ interface StandardLinkPlugin<T extends ClientContext> {
6
+ order?: number;
7
+ init?(options: StandardLinkOptions<T>): void;
8
+ }
9
+ declare class CompositeStandardLinkPlugin<T extends ClientContext, TPlugin extends StandardLinkPlugin<T>> implements StandardLinkPlugin<T> {
10
+ protected readonly plugins: TPlugin[];
11
+ constructor(plugins?: readonly TPlugin[]);
12
+ init(options: StandardLinkOptions<T>): void;
13
+ }
14
+
15
+ interface StandardLinkCodec<T extends ClientContext> {
16
+ encode(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<StandardRequest>;
17
+ decode(response: StandardLazyResponse, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<unknown>;
18
+ }
19
+ interface StandardLinkClient<T extends ClientContext> {
20
+ call(request: StandardRequest, options: ClientOptions<T>, path: readonly string[], input: unknown): Promise<StandardLazyResponse>;
21
+ }
22
+
23
+ interface StandardLinkInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
24
+ path: readonly string[];
25
+ input: unknown;
26
+ }
27
+ interface StandardLinkClientInterceptorOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
28
+ request: StandardRequest;
29
+ }
30
+ interface StandardLinkOptions<T extends ClientContext> {
31
+ interceptors?: Interceptor<StandardLinkInterceptorOptions<T>, Promise<unknown>>[];
32
+ clientInterceptors?: Interceptor<StandardLinkClientInterceptorOptions<T>, Promise<StandardLazyResponse>>[];
33
+ plugins?: StandardLinkPlugin<T>[];
34
+ }
35
+ declare class StandardLink<T extends ClientContext> implements ClientLink<T> {
36
+ readonly codec: StandardLinkCodec<T>;
37
+ readonly sender: StandardLinkClient<T>;
38
+ private readonly interceptors;
39
+ private readonly clientInterceptors;
40
+ constructor(codec: StandardLinkCodec<T>, sender: StandardLinkClient<T>, options?: StandardLinkOptions<T>);
41
+ call(path: readonly string[], input: unknown, options: ClientOptions<T>): Promise<unknown>;
42
+ }
43
+
44
+ export { CompositeStandardLinkPlugin as C, StandardLink as d };
45
+ export type { StandardLinkClientInterceptorOptions as S, StandardLinkPlugin as a, StandardLinkOptions as b, StandardLinkInterceptorOptions as c, StandardLinkCodec as e, StandardLinkClient as f };
@@ -0,0 +1,174 @@
1
+ import { resolveMaybeOptionalOptions, getConstructor, isObject } from '@orpc/shared';
2
+
3
+ const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
4
+ const ORPC_CLIENT_PACKAGE_VERSION = "1.14.12";
5
+
6
+ const COMMON_ORPC_ERROR_DEFS = {
7
+ BAD_REQUEST: {
8
+ status: 400,
9
+ message: "Bad Request"
10
+ },
11
+ UNAUTHORIZED: {
12
+ status: 401,
13
+ message: "Unauthorized"
14
+ },
15
+ FORBIDDEN: {
16
+ status: 403,
17
+ message: "Forbidden"
18
+ },
19
+ NOT_FOUND: {
20
+ status: 404,
21
+ message: "Not Found"
22
+ },
23
+ METHOD_NOT_SUPPORTED: {
24
+ status: 405,
25
+ message: "Method Not Supported"
26
+ },
27
+ NOT_ACCEPTABLE: {
28
+ status: 406,
29
+ message: "Not Acceptable"
30
+ },
31
+ TIMEOUT: {
32
+ status: 408,
33
+ message: "Request Timeout"
34
+ },
35
+ CONFLICT: {
36
+ status: 409,
37
+ message: "Conflict"
38
+ },
39
+ PRECONDITION_FAILED: {
40
+ status: 412,
41
+ message: "Precondition Failed"
42
+ },
43
+ PAYLOAD_TOO_LARGE: {
44
+ status: 413,
45
+ message: "Payload Too Large"
46
+ },
47
+ UNSUPPORTED_MEDIA_TYPE: {
48
+ status: 415,
49
+ message: "Unsupported Media Type"
50
+ },
51
+ UNPROCESSABLE_CONTENT: {
52
+ status: 422,
53
+ message: "Unprocessable Content"
54
+ },
55
+ TOO_MANY_REQUESTS: {
56
+ status: 429,
57
+ message: "Too Many Requests"
58
+ },
59
+ CLIENT_CLOSED_REQUEST: {
60
+ status: 499,
61
+ message: "Client Closed Request"
62
+ },
63
+ INTERNAL_SERVER_ERROR: {
64
+ status: 500,
65
+ message: "Internal Server Error"
66
+ },
67
+ NOT_IMPLEMENTED: {
68
+ status: 501,
69
+ message: "Not Implemented"
70
+ },
71
+ BAD_GATEWAY: {
72
+ status: 502,
73
+ message: "Bad Gateway"
74
+ },
75
+ SERVICE_UNAVAILABLE: {
76
+ status: 503,
77
+ message: "Service Unavailable"
78
+ },
79
+ GATEWAY_TIMEOUT: {
80
+ status: 504,
81
+ message: "Gateway Timeout"
82
+ }
83
+ };
84
+ function fallbackORPCErrorStatus(code, status) {
85
+ return status ?? COMMON_ORPC_ERROR_DEFS[code]?.status ?? 500;
86
+ }
87
+ function fallbackORPCErrorMessage(code, message) {
88
+ return message || COMMON_ORPC_ERROR_DEFS[code]?.message || code;
89
+ }
90
+ let globalORPCErrorConstructors;
91
+ class ORPCError extends Error {
92
+ defined;
93
+ code;
94
+ status;
95
+ data;
96
+ static {
97
+ const GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL = Symbol.for(`__${ORPC_CLIENT_PACKAGE_NAME}@${ORPC_CLIENT_PACKAGE_VERSION}/error/ORPC_ERROR_CONSTRUCTORS__`);
98
+ void (globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= /* @__PURE__ */ new WeakSet());
99
+ globalORPCErrorConstructors = globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL];
100
+ globalORPCErrorConstructors.add(ORPCError);
101
+ }
102
+ constructor(code, ...rest) {
103
+ const options = resolveMaybeOptionalOptions(rest);
104
+ if (options.status !== void 0 && !isORPCErrorStatus(options.status)) {
105
+ throw new Error("[ORPCError] Invalid error status code.");
106
+ }
107
+ const message = fallbackORPCErrorMessage(code, options.message);
108
+ super(message, options);
109
+ this.code = code;
110
+ this.status = fallbackORPCErrorStatus(code, options.status);
111
+ this.defined = options.defined ?? false;
112
+ this.data = options.data;
113
+ }
114
+ toJSON() {
115
+ return {
116
+ defined: this.defined,
117
+ code: this.code,
118
+ status: this.status,
119
+ message: this.message,
120
+ data: this.data
121
+ };
122
+ }
123
+ /**
124
+ * Workaround for Next.js where different contexts use separate
125
+ * dependency graphs, causing multiple ORPCError constructors existing and breaking
126
+ * `instanceof` checks across contexts.
127
+ *
128
+ * This is particularly problematic with "Optimized SSR", where orpc-client
129
+ * executes in one context but is invoked from another. When an error is thrown
130
+ * in the execution context, `instanceof ORPCError` checks fail in the
131
+ * invocation context due to separate class constructors.
132
+ *
133
+ * @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
134
+ */
135
+ static [Symbol.hasInstance](instance) {
136
+ if (globalORPCErrorConstructors.has(this)) {
137
+ const constructor = getConstructor(instance);
138
+ if (constructor && globalORPCErrorConstructors.has(constructor)) {
139
+ return true;
140
+ }
141
+ }
142
+ return super[Symbol.hasInstance](instance);
143
+ }
144
+ }
145
+ function isDefinedError(error) {
146
+ return error instanceof ORPCError && error.defined;
147
+ }
148
+ function toORPCError(error) {
149
+ return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", {
150
+ message: "Internal server error",
151
+ cause: error
152
+ });
153
+ }
154
+ function isORPCErrorStatus(status) {
155
+ return status < 200 || status >= 400;
156
+ }
157
+ function isORPCErrorJson(json) {
158
+ if (!isObject(json)) {
159
+ return false;
160
+ }
161
+ const validKeys = ["defined", "code", "status", "message", "data"];
162
+ if (Object.keys(json).some((k) => !validKeys.includes(k))) {
163
+ return false;
164
+ }
165
+ return "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "status" in json && typeof json.status === "number" && isORPCErrorStatus(json.status) && "message" in json && typeof json.message === "string";
166
+ }
167
+ function createORPCErrorFromJson(json, options = {}) {
168
+ return new ORPCError(json.code, {
169
+ ...options,
170
+ ...json
171
+ });
172
+ }
173
+
174
+ export { COMMON_ORPC_ERROR_DEFS as C, ORPC_CLIENT_PACKAGE_NAME as O, ORPC_CLIENT_PACKAGE_VERSION as a, fallbackORPCErrorMessage as b, ORPCError as c, isORPCErrorStatus as d, isORPCErrorJson as e, fallbackORPCErrorStatus as f, createORPCErrorFromJson as g, isDefinedError as i, toORPCError as t };
@@ -0,0 +1,83 @@
1
+ import { PromiseWithError } from '@orpc/shared';
2
+
3
+ type HTTPPath = `/${string}`;
4
+ type HTTPMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
+ type ClientContext = Record<PropertyKey, any>;
6
+ interface ClientOptions<T extends ClientContext> {
7
+ signal?: AbortSignal;
8
+ lastEventId?: string | undefined;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
12
+ context?: T;
13
+ } : {
14
+ context: T;
15
+ });
16
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
17
+ type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
18
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
19
+ (...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
20
+ }
21
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
22
+ [k: string]: NestedClient<TClientContext>;
23
+ };
24
+ type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
25
+ interface ClientLink<TClientContext extends ClientContext> {
26
+ call: (path: readonly 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 NestedClient<any>> = T extends Client<any, infer U, any, any> ? U : {
34
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 NestedClient<any>> = 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 NestedClient<any> ? 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 NestedClient<any>> = T extends Client<any, any, infer U, any> ? U : {
53
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 NestedClient<any>> = 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 NestedClient<any> ? 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 NestedClient<any>> = T extends Client<any, any, any, infer U> ? U : {
72
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 InferClientErrorUnion<T extends NestedClient<any>> = T extends Client<any, any, any, infer U> ? U : {
80
+ [K in keyof T]: T[K] extends NestedClient<any> ? InferClientErrorUnion<T[K]> : never;
81
+ }[keyof T];
82
+
83
+ export type { ClientLink as C, FriendlyClientOptions as F, HTTPPath as H, InferClientContext as I, NestedClient as N, ClientPromiseResult as a, ClientContext as b, ClientOptions as c, Client as d, ClientRest as e, HTTPMethod as f, InferClientInputs as g, InferClientBodyInputs as h, InferClientOutputs as i, InferClientBodyOutputs as j, InferClientErrors as k, InferClientErrorUnion as l };
@@ -0,0 +1,83 @@
1
+ import { PromiseWithError } from '@orpc/shared';
2
+
3
+ type HTTPPath = `/${string}`;
4
+ type HTTPMethod = 'HEAD' | 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
5
+ type ClientContext = Record<PropertyKey, any>;
6
+ interface ClientOptions<T extends ClientContext> {
7
+ signal?: AbortSignal;
8
+ lastEventId?: string | undefined;
9
+ context: T;
10
+ }
11
+ type FriendlyClientOptions<T extends ClientContext> = Omit<ClientOptions<T>, 'context'> & (Record<never, never> extends T ? {
12
+ context?: T;
13
+ } : {
14
+ context: T;
15
+ });
16
+ type ClientRest<TClientContext extends ClientContext, TInput> = Record<never, never> extends TClientContext ? undefined extends TInput ? [input?: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options?: FriendlyClientOptions<TClientContext>] : [input: TInput, options: FriendlyClientOptions<TClientContext>];
17
+ type ClientPromiseResult<TOutput, TError> = PromiseWithError<TOutput, TError>;
18
+ interface Client<TClientContext extends ClientContext, TInput, TOutput, TError> {
19
+ (...rest: ClientRest<TClientContext, TInput>): ClientPromiseResult<TOutput, TError>;
20
+ }
21
+ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext, any, any, any> | {
22
+ [k: string]: NestedClient<TClientContext>;
23
+ };
24
+ type InferClientContext<T extends NestedClient<any>> = T extends NestedClient<infer U> ? U : never;
25
+ interface ClientLink<TClientContext extends ClientContext> {
26
+ call: (path: readonly 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 NestedClient<any>> = T extends Client<any, infer U, any, any> ? U : {
34
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 NestedClient<any>> = 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 NestedClient<any> ? 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 NestedClient<any>> = T extends Client<any, any, infer U, any> ? U : {
53
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 NestedClient<any>> = 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 NestedClient<any> ? 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 NestedClient<any>> = T extends Client<any, any, any, infer U> ? U : {
72
+ [K in keyof T]: T[K] extends NestedClient<any> ? 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 InferClientErrorUnion<T extends NestedClient<any>> = T extends Client<any, any, any, infer U> ? U : {
80
+ [K in keyof T]: T[K] extends NestedClient<any> ? InferClientErrorUnion<T[K]> : never;
81
+ }[keyof T];
82
+
83
+ export type { ClientLink as C, FriendlyClientOptions as F, HTTPPath as H, InferClientContext as I, NestedClient as N, ClientPromiseResult as a, ClientContext as b, ClientOptions as c, Client as d, ClientRest as e, HTTPMethod as f, InferClientInputs as g, InferClientBodyInputs as h, InferClientOutputs as i, InferClientBodyOutputs as j, InferClientErrors as k, InferClientErrorUnion as l };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "1.14.11",
4
+ "version": "1.14.12",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -14,7 +14,6 @@
14
14
  ],
15
15
  "sideEffects": false,
16
16
  "exports": {
17
- "./package.json": "./package.json",
18
17
  ".": {
19
18
  "types": "./dist/index.d.mts",
20
19
  "import": "./dist/index.mjs",
@@ -50,16 +49,17 @@
50
49
  "dist"
51
50
  ],
52
51
  "dependencies": {
53
- "@standardserver/core": "^0.5.0",
54
- "@standardserver/fetch": "^0.5.0",
55
- "@standardserver/peer": "^0.5.0",
56
- "@orpc/shared": "1.14.11"
52
+ "@orpc/shared": "1.14.12",
53
+ "@orpc/standard-server": "1.14.12",
54
+ "@orpc/standard-server-fetch": "1.14.12",
55
+ "@orpc/standard-server-peer": "1.14.12"
57
56
  },
58
57
  "devDependencies": {
59
- "zod": "^4.4.3"
58
+ "zod": "^4.3.6"
60
59
  },
61
60
  "scripts": {
62
61
  "build": "unbuild",
62
+ "build:watch": "pnpm run build --watch",
63
63
  "type:check": "tsc -b"
64
64
  }
65
65
  }
@@ -1,96 +0,0 @@
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 };