@orpc/client 0.0.0-next.cba521d → 0.0.0-next.cc8802c
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.
- package/README.md +88 -0
- package/dist/adapters/fetch/index.d.mts +29 -0
- package/dist/adapters/fetch/index.d.ts +29 -0
- package/dist/adapters/fetch/index.mjs +35 -0
- package/dist/adapters/standard/index.d.mts +148 -0
- package/dist/adapters/standard/index.d.ts +148 -0
- package/dist/adapters/standard/index.mjs +4 -0
- package/dist/index.d.mts +155 -0
- package/dist/index.d.ts +155 -0
- package/dist/index.mjs +63 -0
- package/dist/shared/client.D_CzLDyB.d.mts +42 -0
- package/dist/shared/client.D_CzLDyB.d.ts +42 -0
- package/dist/shared/client.Df5pd75N.mjs +320 -0
- package/dist/shared/client.XAn8cDTM.mjs +266 -0
- package/package.json +17 -18
- package/dist/fetch.js +0 -89
- package/dist/index.js +0 -42
- package/dist/src/adapters/fetch/index.d.ts +0 -3
- package/dist/src/adapters/fetch/orpc-link.d.ts +0 -46
- package/dist/src/adapters/fetch/types.d.ts +0 -4
- package/dist/src/client.d.ts +0 -11
- package/dist/src/dynamic-link.d.ts +0 -13
- package/dist/src/index.d.ts +0 -6
- package/dist/src/types.d.ts +0 -5
@@ -0,0 +1,266 @@
|
|
1
|
+
import { isObject, isTypescriptObject, retry } from '@orpc/shared';
|
2
|
+
import { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
3
|
+
|
4
|
+
const COMMON_ORPC_ERROR_DEFS = {
|
5
|
+
BAD_REQUEST: {
|
6
|
+
status: 400,
|
7
|
+
message: "Bad Request"
|
8
|
+
},
|
9
|
+
UNAUTHORIZED: {
|
10
|
+
status: 401,
|
11
|
+
message: "Unauthorized"
|
12
|
+
},
|
13
|
+
FORBIDDEN: {
|
14
|
+
status: 403,
|
15
|
+
message: "Forbidden"
|
16
|
+
},
|
17
|
+
NOT_FOUND: {
|
18
|
+
status: 404,
|
19
|
+
message: "Not Found"
|
20
|
+
},
|
21
|
+
METHOD_NOT_SUPPORTED: {
|
22
|
+
status: 405,
|
23
|
+
message: "Method Not Supported"
|
24
|
+
},
|
25
|
+
NOT_ACCEPTABLE: {
|
26
|
+
status: 406,
|
27
|
+
message: "Not Acceptable"
|
28
|
+
},
|
29
|
+
TIMEOUT: {
|
30
|
+
status: 408,
|
31
|
+
message: "Request Timeout"
|
32
|
+
},
|
33
|
+
CONFLICT: {
|
34
|
+
status: 409,
|
35
|
+
message: "Conflict"
|
36
|
+
},
|
37
|
+
PRECONDITION_FAILED: {
|
38
|
+
status: 412,
|
39
|
+
message: "Precondition Failed"
|
40
|
+
},
|
41
|
+
PAYLOAD_TOO_LARGE: {
|
42
|
+
status: 413,
|
43
|
+
message: "Payload Too Large"
|
44
|
+
},
|
45
|
+
UNSUPPORTED_MEDIA_TYPE: {
|
46
|
+
status: 415,
|
47
|
+
message: "Unsupported Media Type"
|
48
|
+
},
|
49
|
+
UNPROCESSABLE_CONTENT: {
|
50
|
+
status: 422,
|
51
|
+
message: "Unprocessable Content"
|
52
|
+
},
|
53
|
+
TOO_MANY_REQUESTS: {
|
54
|
+
status: 429,
|
55
|
+
message: "Too Many Requests"
|
56
|
+
},
|
57
|
+
CLIENT_CLOSED_REQUEST: {
|
58
|
+
status: 499,
|
59
|
+
message: "Client Closed Request"
|
60
|
+
},
|
61
|
+
INTERNAL_SERVER_ERROR: {
|
62
|
+
status: 500,
|
63
|
+
message: "Internal Server Error"
|
64
|
+
},
|
65
|
+
NOT_IMPLEMENTED: {
|
66
|
+
status: 501,
|
67
|
+
message: "Not Implemented"
|
68
|
+
},
|
69
|
+
BAD_GATEWAY: {
|
70
|
+
status: 502,
|
71
|
+
message: "Bad Gateway"
|
72
|
+
},
|
73
|
+
SERVICE_UNAVAILABLE: {
|
74
|
+
status: 503,
|
75
|
+
message: "Service Unavailable"
|
76
|
+
},
|
77
|
+
GATEWAY_TIMEOUT: {
|
78
|
+
status: 504,
|
79
|
+
message: "Gateway Timeout"
|
80
|
+
}
|
81
|
+
};
|
82
|
+
function fallbackORPCErrorStatus(code, status) {
|
83
|
+
return status ?? COMMON_ORPC_ERROR_DEFS[code]?.status ?? 500;
|
84
|
+
}
|
85
|
+
function fallbackORPCErrorMessage(code, message) {
|
86
|
+
return message || COMMON_ORPC_ERROR_DEFS[code]?.message || code;
|
87
|
+
}
|
88
|
+
class ORPCError extends Error {
|
89
|
+
defined;
|
90
|
+
code;
|
91
|
+
status;
|
92
|
+
data;
|
93
|
+
constructor(code, ...[options]) {
|
94
|
+
if (options?.status && (options.status < 400 || options.status >= 600)) {
|
95
|
+
throw new Error("[ORPCError] The error status code must be in the 400-599 range.");
|
96
|
+
}
|
97
|
+
const message = fallbackORPCErrorMessage(code, options?.message);
|
98
|
+
super(message, options);
|
99
|
+
this.code = code;
|
100
|
+
this.status = fallbackORPCErrorStatus(code, options?.status);
|
101
|
+
this.defined = options?.defined ?? false;
|
102
|
+
this.data = options?.data;
|
103
|
+
}
|
104
|
+
toJSON() {
|
105
|
+
return {
|
106
|
+
defined: this.defined,
|
107
|
+
code: this.code,
|
108
|
+
status: this.status,
|
109
|
+
message: this.message,
|
110
|
+
data: this.data
|
111
|
+
};
|
112
|
+
}
|
113
|
+
static fromJSON(json, options) {
|
114
|
+
return new ORPCError(json.code, {
|
115
|
+
...options,
|
116
|
+
...json
|
117
|
+
});
|
118
|
+
}
|
119
|
+
static isValidJSON(json) {
|
120
|
+
if (!isObject(json)) {
|
121
|
+
return false;
|
122
|
+
}
|
123
|
+
const validKeys = ["defined", "code", "status", "message", "data"];
|
124
|
+
if (Object.keys(json).some((k) => !validKeys.includes(k))) {
|
125
|
+
return false;
|
126
|
+
}
|
127
|
+
return "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "status" in json && typeof json.status === "number" && "message" in json && typeof json.message === "string";
|
128
|
+
}
|
129
|
+
}
|
130
|
+
function isDefinedError(error) {
|
131
|
+
return error instanceof ORPCError && error.defined;
|
132
|
+
}
|
133
|
+
function toORPCError(error) {
|
134
|
+
return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", {
|
135
|
+
message: "Internal server error",
|
136
|
+
cause: error
|
137
|
+
});
|
138
|
+
}
|
139
|
+
|
140
|
+
const iteratorStates = /* @__PURE__ */ new WeakMap();
|
141
|
+
function registerEventIteratorState(iterator, state) {
|
142
|
+
iteratorStates.set(iterator, state);
|
143
|
+
}
|
144
|
+
function updateEventIteratorStatus(state, status) {
|
145
|
+
if (state.status !== status) {
|
146
|
+
state.status = status;
|
147
|
+
state.listeners.forEach((cb) => cb(status));
|
148
|
+
}
|
149
|
+
}
|
150
|
+
function onEventIteratorStatusChange(iterator, callback, options = {}) {
|
151
|
+
const notifyImmediately = options.notifyImmediately ?? true;
|
152
|
+
const state = iteratorStates.get(iterator);
|
153
|
+
if (!state) {
|
154
|
+
throw new Error("Iterator is not registered.");
|
155
|
+
}
|
156
|
+
if (notifyImmediately) {
|
157
|
+
callback(state.status);
|
158
|
+
}
|
159
|
+
state.listeners.push(callback);
|
160
|
+
return () => {
|
161
|
+
const index = state.listeners.indexOf(callback);
|
162
|
+
if (index !== -1) {
|
163
|
+
state.listeners.splice(index, 1);
|
164
|
+
}
|
165
|
+
};
|
166
|
+
}
|
167
|
+
|
168
|
+
function mapEventIterator(iterator, maps) {
|
169
|
+
return async function* () {
|
170
|
+
try {
|
171
|
+
while (true) {
|
172
|
+
const { done, value } = await iterator.next();
|
173
|
+
let mappedValue = await maps.value(value, done);
|
174
|
+
if (mappedValue !== value) {
|
175
|
+
const meta = getEventMeta(value);
|
176
|
+
if (meta && isTypescriptObject(mappedValue)) {
|
177
|
+
mappedValue = withEventMeta(mappedValue, meta);
|
178
|
+
}
|
179
|
+
}
|
180
|
+
if (done) {
|
181
|
+
return mappedValue;
|
182
|
+
}
|
183
|
+
yield mappedValue;
|
184
|
+
}
|
185
|
+
} catch (error) {
|
186
|
+
let mappedError = await maps.error(error);
|
187
|
+
if (mappedError !== error) {
|
188
|
+
const meta = getEventMeta(error);
|
189
|
+
if (meta && isTypescriptObject(mappedError)) {
|
190
|
+
mappedError = withEventMeta(mappedError, meta);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
throw mappedError;
|
194
|
+
} finally {
|
195
|
+
await iterator.return?.();
|
196
|
+
}
|
197
|
+
}();
|
198
|
+
}
|
199
|
+
const MAX_ALLOWED_RETRY_TIMES = 99;
|
200
|
+
function createAutoRetryEventIterator(initial, reconnect, initialLastEventId) {
|
201
|
+
const state = {
|
202
|
+
status: "connected",
|
203
|
+
listeners: []
|
204
|
+
};
|
205
|
+
const iterator = async function* () {
|
206
|
+
let current = initial;
|
207
|
+
let lastEventId = initialLastEventId;
|
208
|
+
let lastRetry;
|
209
|
+
let retryTimes = 0;
|
210
|
+
try {
|
211
|
+
while (true) {
|
212
|
+
try {
|
213
|
+
updateEventIteratorStatus(state, "connected");
|
214
|
+
const { done, value } = await current.next();
|
215
|
+
const meta = getEventMeta(value);
|
216
|
+
lastEventId = meta?.id ?? lastEventId;
|
217
|
+
lastRetry = meta?.retry ?? lastRetry;
|
218
|
+
retryTimes = 0;
|
219
|
+
if (done) {
|
220
|
+
return value;
|
221
|
+
}
|
222
|
+
yield value;
|
223
|
+
} catch (e) {
|
224
|
+
updateEventIteratorStatus(state, "reconnecting");
|
225
|
+
const meta = getEventMeta(e);
|
226
|
+
lastEventId = meta?.id ?? lastEventId;
|
227
|
+
lastRetry = meta?.retry ?? lastRetry;
|
228
|
+
let currentError = e;
|
229
|
+
current = await retry({ times: MAX_ALLOWED_RETRY_TIMES }, async (exit) => {
|
230
|
+
retryTimes += 1;
|
231
|
+
if (retryTimes > MAX_ALLOWED_RETRY_TIMES) {
|
232
|
+
throw exit(new Error(
|
233
|
+
`Exceeded maximum retry attempts (${MAX_ALLOWED_RETRY_TIMES}) for event iterator. Possible infinite retry loop detected. Please review the retry logic.`,
|
234
|
+
{ cause: currentError }
|
235
|
+
));
|
236
|
+
}
|
237
|
+
const reconnected = await (async () => {
|
238
|
+
try {
|
239
|
+
return await reconnect({
|
240
|
+
lastRetry,
|
241
|
+
lastEventId,
|
242
|
+
retryTimes,
|
243
|
+
error: currentError
|
244
|
+
});
|
245
|
+
} catch (e2) {
|
246
|
+
currentError = e2;
|
247
|
+
throw e2;
|
248
|
+
}
|
249
|
+
})();
|
250
|
+
if (!reconnected) {
|
251
|
+
throw exit(currentError);
|
252
|
+
}
|
253
|
+
return reconnected;
|
254
|
+
});
|
255
|
+
}
|
256
|
+
}
|
257
|
+
} finally {
|
258
|
+
updateEventIteratorStatus(state, "closed");
|
259
|
+
await current.return?.();
|
260
|
+
}
|
261
|
+
}();
|
262
|
+
registerEventIteratorState(iterator, state);
|
263
|
+
return iterator;
|
264
|
+
}
|
265
|
+
|
266
|
+
export { COMMON_ORPC_ERROR_DEFS as C, ORPCError as O, fallbackORPCErrorMessage as a, createAutoRetryEventIterator as c, fallbackORPCErrorStatus as f, isDefinedError as i, mapEventIterator as m, onEventIteratorStatusChange as o, registerEventIteratorState as r, toORPCError as t, updateEventIteratorStatus as u };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/client",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.cc8802c",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -15,35 +15,34 @@
|
|
15
15
|
],
|
16
16
|
"exports": {
|
17
17
|
".": {
|
18
|
-
"types": "./dist/
|
19
|
-
"import": "./dist/index.
|
20
|
-
"default": "./dist/index.
|
18
|
+
"types": "./dist/index.d.mts",
|
19
|
+
"import": "./dist/index.mjs",
|
20
|
+
"default": "./dist/index.mjs"
|
21
21
|
},
|
22
|
-
"./
|
23
|
-
"types": "./dist/
|
24
|
-
"import": "./dist/
|
25
|
-
"default": "./dist/
|
22
|
+
"./standard": {
|
23
|
+
"types": "./dist/adapters/standard/index.d.mts",
|
24
|
+
"import": "./dist/adapters/standard/index.mjs",
|
25
|
+
"default": "./dist/adapters/standard/index.mjs"
|
26
26
|
},
|
27
|
-
"
|
28
|
-
"types": "./dist/
|
27
|
+
"./fetch": {
|
28
|
+
"types": "./dist/adapters/fetch/index.d.mts",
|
29
|
+
"import": "./dist/adapters/fetch/index.mjs",
|
30
|
+
"default": "./dist/adapters/fetch/index.mjs"
|
29
31
|
}
|
30
32
|
},
|
31
33
|
"files": [
|
32
|
-
"!**/*.map",
|
33
|
-
"!**/*.tsbuildinfo",
|
34
34
|
"dist"
|
35
35
|
],
|
36
36
|
"dependencies": {
|
37
|
-
"@orpc/
|
38
|
-
"@orpc/server": "0.0.0-next.
|
39
|
-
"@orpc/
|
37
|
+
"@orpc/shared": "0.0.0-next.cc8802c",
|
38
|
+
"@orpc/standard-server-fetch": "0.0.0-next.cc8802c",
|
39
|
+
"@orpc/standard-server": "0.0.0-next.cc8802c"
|
40
40
|
},
|
41
41
|
"devDependencies": {
|
42
|
-
"zod": "^3.24.
|
43
|
-
"@orpc/openapi": "0.0.0-next.cba521d"
|
42
|
+
"zod": "^3.24.2"
|
44
43
|
},
|
45
44
|
"scripts": {
|
46
|
-
"build": "
|
45
|
+
"build": "unbuild",
|
47
46
|
"build:watch": "pnpm run build --watch",
|
48
47
|
"type:check": "tsc -b"
|
49
48
|
}
|
package/dist/fetch.js
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
// src/adapters/fetch/orpc-link.ts
|
2
|
-
import { ORPCError } from "@orpc/contract";
|
3
|
-
import { ORPCPayloadCodec } from "@orpc/server/fetch";
|
4
|
-
import { ORPC_HANDLER_HEADER, ORPC_HANDLER_VALUE, trim } from "@orpc/shared";
|
5
|
-
var RPCLink = class {
|
6
|
-
fetch;
|
7
|
-
payloadCodec;
|
8
|
-
maxURLLength;
|
9
|
-
fallbackMethod;
|
10
|
-
getMethod;
|
11
|
-
getHeaders;
|
12
|
-
url;
|
13
|
-
constructor(options) {
|
14
|
-
this.fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
15
|
-
this.payloadCodec = options.payloadCodec ?? new ORPCPayloadCodec();
|
16
|
-
this.maxURLLength = options.maxURLLength ?? 2083;
|
17
|
-
this.fallbackMethod = options.fallbackMethod ?? "POST";
|
18
|
-
this.url = options.url;
|
19
|
-
this.getMethod = async (path, input, context) => {
|
20
|
-
return await options.method?.(path, input, context) ?? this.fallbackMethod;
|
21
|
-
};
|
22
|
-
this.getHeaders = async (path, input, context) => {
|
23
|
-
return new Headers(await options.headers?.(path, input, context));
|
24
|
-
};
|
25
|
-
}
|
26
|
-
async call(path, input, options) {
|
27
|
-
const clientContext = options.context;
|
28
|
-
const encoded = await this.encode(path, input, options);
|
29
|
-
const response = await this.fetch(encoded.url, {
|
30
|
-
method: encoded.method,
|
31
|
-
headers: encoded.headers,
|
32
|
-
body: encoded.body,
|
33
|
-
signal: options.signal
|
34
|
-
}, clientContext);
|
35
|
-
const decoded = await this.payloadCodec.decode(response);
|
36
|
-
if (!response.ok) {
|
37
|
-
if (ORPCError.isValidJSON(decoded)) {
|
38
|
-
throw new ORPCError(decoded);
|
39
|
-
}
|
40
|
-
throw new ORPCError({
|
41
|
-
status: response.status,
|
42
|
-
code: "INTERNAL_SERVER_ERROR",
|
43
|
-
message: "Internal server error",
|
44
|
-
cause: decoded
|
45
|
-
});
|
46
|
-
}
|
47
|
-
return decoded;
|
48
|
-
}
|
49
|
-
async encode(path, input, options) {
|
50
|
-
const clientContext = options.context;
|
51
|
-
const expectMethod = await this.getMethod(path, input, clientContext);
|
52
|
-
const methods = /* @__PURE__ */ new Set([expectMethod, this.fallbackMethod]);
|
53
|
-
const baseHeaders = await this.getHeaders(path, input, clientContext);
|
54
|
-
const baseUrl = new URL(`${trim(this.url, "/")}/${path.map(encodeURIComponent).join("/")}`);
|
55
|
-
baseHeaders.append(ORPC_HANDLER_HEADER, ORPC_HANDLER_VALUE);
|
56
|
-
for (const method of methods) {
|
57
|
-
const url = new URL(baseUrl);
|
58
|
-
const headers = new Headers(baseHeaders);
|
59
|
-
const encoded = this.payloadCodec.encode(input, method, this.fallbackMethod);
|
60
|
-
if (encoded.query) {
|
61
|
-
for (const [key, value] of encoded.query.entries()) {
|
62
|
-
url.searchParams.append(key, value);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
if (url.toString().length > this.maxURLLength) {
|
66
|
-
continue;
|
67
|
-
}
|
68
|
-
if (encoded.headers) {
|
69
|
-
for (const [key, value] of encoded.headers.entries()) {
|
70
|
-
headers.append(key, value);
|
71
|
-
}
|
72
|
-
}
|
73
|
-
return {
|
74
|
-
url,
|
75
|
-
headers,
|
76
|
-
method: encoded.method,
|
77
|
-
body: encoded.body
|
78
|
-
};
|
79
|
-
}
|
80
|
-
throw new ORPCError({
|
81
|
-
code: "BAD_REQUEST",
|
82
|
-
message: "Cannot encode the request, please check the url length or payload."
|
83
|
-
});
|
84
|
-
}
|
85
|
-
};
|
86
|
-
export {
|
87
|
-
RPCLink
|
88
|
-
};
|
89
|
-
//# sourceMappingURL=fetch.js.map
|
package/dist/index.js
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
// src/client.ts
|
2
|
-
function createORPCClient(link, options) {
|
3
|
-
const path = options?.path ?? [];
|
4
|
-
const procedureClient = async (...[input, options2]) => {
|
5
|
-
return await link.call(path, input, options2 ?? {});
|
6
|
-
};
|
7
|
-
const recursive = new Proxy(procedureClient, {
|
8
|
-
get(target, key) {
|
9
|
-
if (typeof key !== "string") {
|
10
|
-
return Reflect.get(target, key);
|
11
|
-
}
|
12
|
-
return createORPCClient(link, {
|
13
|
-
...options,
|
14
|
-
path: [...path, key]
|
15
|
-
});
|
16
|
-
}
|
17
|
-
});
|
18
|
-
return recursive;
|
19
|
-
}
|
20
|
-
|
21
|
-
// src/dynamic-link.ts
|
22
|
-
var DynamicLink = class {
|
23
|
-
constructor(linkResolver) {
|
24
|
-
this.linkResolver = linkResolver;
|
25
|
-
}
|
26
|
-
async call(path, input, options) {
|
27
|
-
const resolvedLink = await this.linkResolver(path, input, options.context);
|
28
|
-
const output = await resolvedLink.call(path, input, options);
|
29
|
-
return output;
|
30
|
-
}
|
31
|
-
};
|
32
|
-
|
33
|
-
// src/index.ts
|
34
|
-
import { isDefinedError, ORPCError, safe } from "@orpc/contract";
|
35
|
-
export {
|
36
|
-
DynamicLink,
|
37
|
-
ORPCError,
|
38
|
-
createORPCClient,
|
39
|
-
isDefinedError,
|
40
|
-
safe
|
41
|
-
};
|
42
|
-
//# sourceMappingURL=index.js.map
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import type { ClientOptions, HTTPMethod } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { ClientLink } from '../../types';
|
4
|
-
import type { FetchWithContext } from './types';
|
5
|
-
import { type PublicORPCPayloadCodec } from '@orpc/server/fetch';
|
6
|
-
export interface RPCLinkOptions<TClientContext> {
|
7
|
-
/**
|
8
|
-
* Base url for all requests.
|
9
|
-
*/
|
10
|
-
url: string;
|
11
|
-
/**
|
12
|
-
* The maximum length of the URL.
|
13
|
-
*
|
14
|
-
* @default 2083
|
15
|
-
*/
|
16
|
-
maxURLLength?: number;
|
17
|
-
/**
|
18
|
-
* The method used to make the request.
|
19
|
-
*
|
20
|
-
* @default 'POST'
|
21
|
-
*/
|
22
|
-
method?: (path: readonly string[], input: unknown, context: TClientContext) => Promisable<HTTPMethod | undefined>;
|
23
|
-
/**
|
24
|
-
* The method to use when the payload cannot safely pass to the server with method return from method function.
|
25
|
-
* Do not use GET as fallback method, it's very dangerous.
|
26
|
-
*
|
27
|
-
* @default 'POST'
|
28
|
-
*/
|
29
|
-
fallbackMethod?: HTTPMethod;
|
30
|
-
headers?: (path: readonly string[], input: unknown, context: TClientContext) => Promisable<Headers | Record<string, string>>;
|
31
|
-
fetch?: FetchWithContext<TClientContext>;
|
32
|
-
payloadCodec?: PublicORPCPayloadCodec;
|
33
|
-
}
|
34
|
-
export declare class RPCLink<TClientContext> implements ClientLink<TClientContext> {
|
35
|
-
private readonly fetch;
|
36
|
-
private readonly payloadCodec;
|
37
|
-
private readonly maxURLLength;
|
38
|
-
private readonly fallbackMethod;
|
39
|
-
private readonly getMethod;
|
40
|
-
private readonly getHeaders;
|
41
|
-
private readonly url;
|
42
|
-
constructor(options: RPCLinkOptions<TClientContext>);
|
43
|
-
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
44
|
-
private encode;
|
45
|
-
}
|
46
|
-
//# sourceMappingURL=orpc-link.d.ts.map
|
package/dist/src/client.d.ts
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
import type { ContractRouter, ContractRouterClient } from '@orpc/contract';
|
2
|
-
import type { ANY_ROUTER, RouterClient } from '@orpc/server';
|
3
|
-
import type { ClientLink } from './types';
|
4
|
-
export interface createORPCClientOptions {
|
5
|
-
/**
|
6
|
-
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
7
|
-
*/
|
8
|
-
path?: string[];
|
9
|
-
}
|
10
|
-
export declare function createORPCClient<TRouter extends ANY_ROUTER | ContractRouter, TClientContext = unknown>(link: ClientLink<TClientContext>, options?: createORPCClientOptions): TRouter extends ContractRouter ? ContractRouterClient<TRouter, TClientContext> : TRouter extends ANY_ROUTER ? RouterClient<TRouter, TClientContext> : never;
|
11
|
-
//# sourceMappingURL=client.d.ts.map
|
@@ -1,13 +0,0 @@
|
|
1
|
-
import type { ClientOptions } from '@orpc/contract';
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type { ClientLink } from './types';
|
4
|
-
/**
|
5
|
-
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
6
|
-
* based on the request path, input, and context.
|
7
|
-
*/
|
8
|
-
export declare class DynamicLink<TClientContext> implements ClientLink<TClientContext> {
|
9
|
-
private readonly linkResolver;
|
10
|
-
constructor(linkResolver: (path: readonly string[], input: unknown, context: TClientContext) => Promisable<ClientLink<TClientContext>>);
|
11
|
-
call(path: readonly string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
12
|
-
}
|
13
|
-
//# sourceMappingURL=dynamic-link.d.ts.map
|
package/dist/src/index.d.ts
DELETED
package/dist/src/types.d.ts
DELETED