jiren 3.1.0 → 3.3.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.
- package/README.md +1 -9
- package/components/client-node-native.ts +150 -292
- package/components/client.ts +385 -286
- package/components/index.ts +0 -2
- package/components/native-cache-node.ts +0 -3
- package/components/native-cache.ts +0 -8
- package/components/native-node.ts +142 -4
- package/components/native.ts +33 -65
- package/components/types.ts +25 -41
- package/dist/components/client-node-native.d.ts +0 -1
- package/dist/components/client-node-native.d.ts.map +1 -1
- package/dist/components/client-node-native.js +84 -202
- package/dist/components/client-node-native.js.map +1 -1
- package/dist/components/native-cache-node.d.ts.map +1 -1
- package/dist/components/native-cache-node.js +0 -1
- package/dist/components/native-cache-node.js.map +1 -1
- package/dist/components/native-node.d.ts +78 -0
- package/dist/components/native-node.d.ts.map +1 -1
- package/dist/components/native-node.js +125 -2
- package/dist/components/native-node.js.map +1 -1
- package/dist/components/types.d.ts +5 -13
- package/dist/components/types.d.ts.map +1 -1
- package/lib/libhttpclient.dylib +0 -0
- package/package.json +3 -3
- package/components/cache.ts +0 -451
- package/components/native-json.ts +0 -195
- package/components/persistent-worker.ts +0 -67
- package/components/subprocess-worker.ts +0 -60
- package/components/worker-pool.ts +0 -153
- package/components/worker.ts +0 -154
- package/dist/components/cache.d.ts +0 -32
- package/dist/components/cache.d.ts.map +0 -1
- package/dist/components/cache.js +0 -374
- package/dist/components/cache.js.map +0 -1
package/components/index.ts
CHANGED
|
@@ -88,14 +88,6 @@ export class NativeCache {
|
|
|
88
88
|
bodyUsed = true;
|
|
89
89
|
return new Blob([bodyData]);
|
|
90
90
|
},
|
|
91
|
-
jsonFields: async <T extends Record<string, any> = any>(
|
|
92
|
-
fields: (keyof T)[]
|
|
93
|
-
): Promise<Partial<T>> => {
|
|
94
|
-
bodyUsed = true;
|
|
95
|
-
// For cache values, we'd need to reconstruct the body.
|
|
96
|
-
// Since this is a mock body for cache misses/metadata, return empty.
|
|
97
|
-
return {};
|
|
98
|
-
},
|
|
99
91
|
};
|
|
100
92
|
|
|
101
93
|
Object.defineProperty(body, "bodyUsed", {
|
|
@@ -6,8 +6,9 @@ import { fileURLToPath } from "url";
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = path.dirname(__filename);
|
|
8
8
|
|
|
9
|
-
// Determine library extension based on platform
|
|
10
9
|
const platform = process.platform;
|
|
10
|
+
const arch = process.arch;
|
|
11
|
+
|
|
11
12
|
let suffix = "so";
|
|
12
13
|
if (platform === "darwin") {
|
|
13
14
|
suffix = "dylib";
|
|
@@ -15,9 +16,11 @@ if (platform === "darwin") {
|
|
|
15
16
|
suffix = "dll";
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
//
|
|
19
|
+
// Reverted to flat structure based on user request
|
|
19
20
|
let libPath = path.join(__dirname, `../lib/libhttpclient.${suffix}`);
|
|
21
|
+
|
|
20
22
|
if (!fs.existsSync(libPath)) {
|
|
23
|
+
// Try one level up (monorepo/dev context)
|
|
21
24
|
libPath = path.join(__dirname, `../../lib/libhttpclient.${suffix}`);
|
|
22
25
|
}
|
|
23
26
|
|
|
@@ -60,12 +63,12 @@ export const symbols = {
|
|
|
60
63
|
zclient_response_headers_len: lib.func(
|
|
61
64
|
"zclient_response_headers_len",
|
|
62
65
|
"uint64_t",
|
|
63
|
-
["void *"]
|
|
66
|
+
["void *"],
|
|
64
67
|
),
|
|
65
68
|
zclient_response_parse_header_offsets: lib.func(
|
|
66
69
|
"zclient_response_parse_header_offsets",
|
|
67
70
|
"void *",
|
|
68
|
-
["void *"]
|
|
71
|
+
["void *"],
|
|
69
72
|
),
|
|
70
73
|
zclient_header_offsets_free: lib.func("zclient_header_offsets_free", "void", [
|
|
71
74
|
"void *",
|
|
@@ -83,6 +86,102 @@ export const symbols = {
|
|
|
83
86
|
"void *",
|
|
84
87
|
"bool",
|
|
85
88
|
]),
|
|
89
|
+
zclient_request_full: lib.func("zclient_request_full", "void *", [
|
|
90
|
+
"void *",
|
|
91
|
+
"const char *",
|
|
92
|
+
"const char *",
|
|
93
|
+
"const char *",
|
|
94
|
+
"const char *",
|
|
95
|
+
"uint8_t",
|
|
96
|
+
"bool",
|
|
97
|
+
]),
|
|
98
|
+
zfull_response_status: lib.func("zfull_response_status", "uint16_t", [
|
|
99
|
+
"void *",
|
|
100
|
+
]),
|
|
101
|
+
zfull_response_header_ptr: lib.func("zfull_response_header_ptr", "void *", [
|
|
102
|
+
"void *",
|
|
103
|
+
]),
|
|
104
|
+
zfull_response_header_len: lib.func("zfull_response_header_len", "uint64_t", [
|
|
105
|
+
"void *",
|
|
106
|
+
]),
|
|
107
|
+
zfull_response_body_ptr: lib.func("zfull_response_body_ptr", "void *", [
|
|
108
|
+
"void *",
|
|
109
|
+
]),
|
|
110
|
+
zfull_response_body_len: lib.func("zfull_response_body_len", "uint64_t", [
|
|
111
|
+
"void *",
|
|
112
|
+
]),
|
|
113
|
+
zfull_response_was_decompressed: lib.func(
|
|
114
|
+
"zfull_response_was_decompressed",
|
|
115
|
+
"uint8_t",
|
|
116
|
+
["void *"],
|
|
117
|
+
),
|
|
118
|
+
z_simd_key_match: lib.func("z_simd_key_match", "bool", [
|
|
119
|
+
"void *",
|
|
120
|
+
"uint64_t",
|
|
121
|
+
"void *",
|
|
122
|
+
"uint64_t",
|
|
123
|
+
]),
|
|
124
|
+
z_find_double_crlf: lib.func("z_find_double_crlf", "int64_t", [
|
|
125
|
+
"void *",
|
|
126
|
+
"uint64_t",
|
|
127
|
+
]),
|
|
128
|
+
zclient_get_json_fields: lib.func("zclient_get_json_fields", "void *", [
|
|
129
|
+
"void *",
|
|
130
|
+
"const char *",
|
|
131
|
+
"const char **",
|
|
132
|
+
"uint64_t",
|
|
133
|
+
]),
|
|
134
|
+
zclient_request_json_fields: lib.func(
|
|
135
|
+
"zclient_request_json_fields",
|
|
136
|
+
"void *",
|
|
137
|
+
[
|
|
138
|
+
"void *",
|
|
139
|
+
"const char *",
|
|
140
|
+
"const char *",
|
|
141
|
+
"const char *",
|
|
142
|
+
"const char *",
|
|
143
|
+
"const char **",
|
|
144
|
+
"uint64_t",
|
|
145
|
+
],
|
|
146
|
+
),
|
|
147
|
+
zclient_json_fields_free: lib.func("zclient_json_fields_free", "void", [
|
|
148
|
+
"void *",
|
|
149
|
+
]),
|
|
150
|
+
zjson_field_str: lib.func("zjson_field_str", "void *", [
|
|
151
|
+
"void *",
|
|
152
|
+
"uint64_t",
|
|
153
|
+
]),
|
|
154
|
+
zjson_field_len: lib.func("zjson_field_len", "uint64_t", [
|
|
155
|
+
"void *",
|
|
156
|
+
"uint64_t",
|
|
157
|
+
]),
|
|
158
|
+
zjson_field_type: lib.func("zjson_field_type", "uint8_t", [
|
|
159
|
+
"void *",
|
|
160
|
+
"uint64_t",
|
|
161
|
+
]),
|
|
162
|
+
zjson_object_len: lib.func("zjson_object_len", "uint64_t", ["void *"]),
|
|
163
|
+
zjson_validate: lib.func("zjson_validate", "bool", ["void *", "uint64_t"]),
|
|
164
|
+
zjson_parse: lib.func("zjson_parse", "void *", ["void *", "uint64_t"]),
|
|
165
|
+
zjson_get_string: lib.func("zjson_get_string", "void *", [
|
|
166
|
+
"void *",
|
|
167
|
+
"const char *",
|
|
168
|
+
]),
|
|
169
|
+
zjson_get_string_len: lib.func("zjson_get_string_len", "uint64_t", [
|
|
170
|
+
"void *",
|
|
171
|
+
"const char *",
|
|
172
|
+
]),
|
|
173
|
+
zjson_get_int: lib.func("zjson_get_int", "int64_t", [
|
|
174
|
+
"void *",
|
|
175
|
+
"const char *",
|
|
176
|
+
]),
|
|
177
|
+
zjson_get_bool: lib.func("zjson_get_bool", "bool", [
|
|
178
|
+
"void *",
|
|
179
|
+
"const char *",
|
|
180
|
+
]),
|
|
181
|
+
zjson_has_key: lib.func("zjson_has_key", "bool", ["void *", "const char *"]),
|
|
182
|
+
zjson_get_type: lib.func("zjson_get_type", "uint8_t", ["void *"]),
|
|
183
|
+
zjson_array_len: lib.func("zjson_array_len", "uint64_t", ["void *"]),
|
|
184
|
+
zjson_free: lib.func("zjson_free", "void", ["void *"]),
|
|
86
185
|
|
|
87
186
|
zcache_new: lib.func("zcache_new", "void *", ["uint64_t"]),
|
|
88
187
|
zcache_free: lib.func("zcache_free", "void", ["void *"]),
|
|
@@ -131,6 +230,45 @@ export const symbols = {
|
|
|
131
230
|
]),
|
|
132
231
|
zstream_is_complete: lib.func("zstream_is_complete", "bool", ["void *"]),
|
|
133
232
|
zstream_free: lib.func("zstream_free", "void", ["void *"]),
|
|
233
|
+
|
|
234
|
+
// =========================================================================
|
|
235
|
+
// STREAMING UPLOAD FFI (PROGRESS TRACKING)
|
|
236
|
+
// =========================================================================
|
|
237
|
+
zclient_upload_stream: lib.func("zclient_upload_stream", "void *", [
|
|
238
|
+
"void *", // client
|
|
239
|
+
"const char *", // method
|
|
240
|
+
"const char *", // url
|
|
241
|
+
"const char *", // headers (nullable)
|
|
242
|
+
"void *", // body pointer
|
|
243
|
+
"uint64_t", // body length
|
|
244
|
+
"void *", // progress_callback (nullable)
|
|
245
|
+
]),
|
|
246
|
+
zupload_send_chunk: lib.func("zupload_send_chunk", "uint64_t", ["void *"]),
|
|
247
|
+
zupload_read_response: lib.func("zupload_read_response", "uint64_t", [
|
|
248
|
+
"void *",
|
|
249
|
+
]),
|
|
250
|
+
zupload_bytes_sent: lib.func("zupload_bytes_sent", "uint64_t", ["void *"]),
|
|
251
|
+
zupload_total_bytes: lib.func("zupload_total_bytes", "uint64_t", ["void *"]),
|
|
252
|
+
zupload_is_upload_complete: lib.func("zupload_is_upload_complete", "bool", [
|
|
253
|
+
"void *",
|
|
254
|
+
]),
|
|
255
|
+
zupload_is_complete: lib.func("zupload_is_complete", "bool", ["void *"]),
|
|
256
|
+
zupload_status: lib.func("zupload_status", "uint16_t", ["void *"]),
|
|
257
|
+
zupload_response_body: lib.func("zupload_response_body", "void *", [
|
|
258
|
+
"void *",
|
|
259
|
+
]),
|
|
260
|
+
zupload_response_body_len: lib.func("zupload_response_body_len", "uint64_t", [
|
|
261
|
+
"void *",
|
|
262
|
+
]),
|
|
263
|
+
zupload_response_headers: lib.func("zupload_response_headers", "void *", [
|
|
264
|
+
"void *",
|
|
265
|
+
]),
|
|
266
|
+
zupload_response_headers_len: lib.func(
|
|
267
|
+
"zupload_response_headers_len",
|
|
268
|
+
"uint64_t",
|
|
269
|
+
["void *"],
|
|
270
|
+
),
|
|
271
|
+
zupload_free: lib.func("zupload_free", "void", ["void *"]),
|
|
134
272
|
};
|
|
135
273
|
|
|
136
274
|
export const nativeLib = {
|
package/components/native.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { dlopen, FFIType, suffix } from "bun:ffi";
|
|
2
2
|
import { join } from "path";
|
|
3
3
|
|
|
4
|
+
const platform = process.platform;
|
|
5
|
+
const arch = process.arch;
|
|
6
|
+
|
|
7
|
+
// Reverted to flat structure
|
|
4
8
|
const libPath = join(import.meta.dir, `../lib/libhttpclient.${suffix}`);
|
|
5
9
|
|
|
6
10
|
export const ffiDef = {
|
|
@@ -100,6 +104,7 @@ export const ffiDef = {
|
|
|
100
104
|
FFIType.bool, // antibot
|
|
101
105
|
],
|
|
102
106
|
returns: FFIType.ptr, // ZFullResponse*
|
|
107
|
+
async: true,
|
|
103
108
|
},
|
|
104
109
|
zclient_response_full_free: {
|
|
105
110
|
args: [FFIType.ptr],
|
|
@@ -126,30 +131,9 @@ export const ffiDef = {
|
|
|
126
131
|
args: [FFIType.ptr],
|
|
127
132
|
returns: FFIType.u64,
|
|
128
133
|
},
|
|
129
|
-
|
|
130
|
-
zclient_request_batch: {
|
|
131
|
-
args: [
|
|
132
|
-
FFIType.ptr, // client
|
|
133
|
-
FFIType.ptr, // requests array (ZBatchRequest*)
|
|
134
|
-
FFIType.u64, // request_count
|
|
135
|
-
],
|
|
136
|
-
returns: FFIType.ptr, // ZBatchResult*
|
|
137
|
-
},
|
|
138
|
-
zclient_batch_result_free: {
|
|
134
|
+
zfull_response_was_decompressed: {
|
|
139
135
|
args: [FFIType.ptr],
|
|
140
|
-
returns: FFIType.
|
|
141
|
-
},
|
|
142
|
-
zbatch_response_status: {
|
|
143
|
-
args: [FFIType.ptr, FFIType.u64], // result, index
|
|
144
|
-
returns: FFIType.u16,
|
|
145
|
-
},
|
|
146
|
-
zbatch_response_body: {
|
|
147
|
-
args: [FFIType.ptr, FFIType.u64], // result, index
|
|
148
|
-
returns: FFIType.ptr,
|
|
149
|
-
},
|
|
150
|
-
zbatch_response_body_len: {
|
|
151
|
-
args: [FFIType.ptr, FFIType.u64], // result, index
|
|
152
|
-
returns: FFIType.u64,
|
|
136
|
+
returns: FFIType.u8,
|
|
153
137
|
},
|
|
154
138
|
|
|
155
139
|
zcache_new: {
|
|
@@ -198,9 +182,6 @@ export const ffiDef = {
|
|
|
198
182
|
returns: FFIType.void,
|
|
199
183
|
},
|
|
200
184
|
|
|
201
|
-
// =========================================================================
|
|
202
|
-
// STREAMING DOWNLOAD FFI (PROGRESS TRACKING)
|
|
203
|
-
// =========================================================================
|
|
204
185
|
zclient_request_stream: {
|
|
205
186
|
args: [
|
|
206
187
|
FFIType.ptr, // client
|
|
@@ -253,9 +234,6 @@ export const ffiDef = {
|
|
|
253
234
|
returns: FFIType.void,
|
|
254
235
|
},
|
|
255
236
|
|
|
256
|
-
// =========================================================================
|
|
257
|
-
// STREAMING UPLOAD FFI (PROGRESS TRACKING)
|
|
258
|
-
// =========================================================================
|
|
259
237
|
zclient_upload_stream: {
|
|
260
238
|
args: [
|
|
261
239
|
FFIType.ptr, // client
|
|
@@ -316,22 +294,11 @@ export const ffiDef = {
|
|
|
316
294
|
args: [FFIType.ptr],
|
|
317
295
|
returns: FFIType.void,
|
|
318
296
|
},
|
|
319
|
-
|
|
320
|
-
// =========================================================================
|
|
321
|
-
// JSON PARSING FFI
|
|
322
|
-
// =========================================================================
|
|
323
297
|
zjson_validate: {
|
|
324
298
|
args: [FFIType.ptr, FFIType.u64],
|
|
325
299
|
returns: FFIType.bool,
|
|
326
300
|
},
|
|
327
|
-
|
|
328
|
-
args: [FFIType.ptr, FFIType.u64],
|
|
329
|
-
returns: FFIType.ptr,
|
|
330
|
-
},
|
|
331
|
-
zjson_result_free: {
|
|
332
|
-
args: [FFIType.ptr],
|
|
333
|
-
returns: FFIType.void,
|
|
334
|
-
},
|
|
301
|
+
|
|
335
302
|
zjson_parse: {
|
|
336
303
|
args: [FFIType.ptr, FFIType.u64],
|
|
337
304
|
returns: FFIType.ptr,
|
|
@@ -364,53 +331,54 @@ export const ffiDef = {
|
|
|
364
331
|
args: [FFIType.ptr],
|
|
365
332
|
returns: FFIType.u8,
|
|
366
333
|
},
|
|
367
|
-
|
|
334
|
+
zjson_object_len: {
|
|
368
335
|
args: [FFIType.ptr],
|
|
369
336
|
returns: FFIType.u64,
|
|
370
337
|
},
|
|
371
|
-
|
|
338
|
+
zjson_array_len: {
|
|
372
339
|
args: [FFIType.ptr],
|
|
373
340
|
returns: FFIType.u64,
|
|
374
341
|
},
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
342
|
+
z_simd_key_match: {
|
|
343
|
+
args: [FFIType.ptr, FFIType.u64, FFIType.ptr, FFIType.u64],
|
|
344
|
+
returns: FFIType.bool,
|
|
345
|
+
},
|
|
346
|
+
z_find_double_crlf: {
|
|
347
|
+
args: [FFIType.ptr, FFIType.u64],
|
|
348
|
+
returns: FFIType.i64,
|
|
349
|
+
},
|
|
379
350
|
zclient_get_json_fields: {
|
|
380
|
-
args: [
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
FFIType.ptr, // field_names array (char**)
|
|
384
|
-
FFIType.u64, // field_count
|
|
385
|
-
],
|
|
386
|
-
returns: FFIType.ptr, // ZJsonFieldsResult*
|
|
351
|
+
args: [FFIType.ptr, FFIType.cstring, FFIType.ptr, FFIType.u64],
|
|
352
|
+
returns: FFIType.ptr,
|
|
353
|
+
async: true,
|
|
387
354
|
},
|
|
388
355
|
zclient_request_json_fields: {
|
|
389
356
|
args: [
|
|
390
|
-
FFIType.ptr,
|
|
391
|
-
FFIType.cstring,
|
|
392
|
-
FFIType.cstring,
|
|
393
|
-
FFIType.cstring,
|
|
394
|
-
FFIType.cstring,
|
|
395
|
-
FFIType.ptr,
|
|
396
|
-
FFIType.u64,
|
|
357
|
+
FFIType.ptr,
|
|
358
|
+
FFIType.cstring,
|
|
359
|
+
FFIType.cstring,
|
|
360
|
+
FFIType.cstring,
|
|
361
|
+
FFIType.cstring,
|
|
362
|
+
FFIType.ptr,
|
|
363
|
+
FFIType.u64,
|
|
397
364
|
],
|
|
398
|
-
returns: FFIType.ptr,
|
|
365
|
+
returns: FFIType.ptr,
|
|
366
|
+
async: true,
|
|
399
367
|
},
|
|
400
368
|
zclient_json_fields_free: {
|
|
401
369
|
args: [FFIType.ptr],
|
|
402
370
|
returns: FFIType.void,
|
|
403
371
|
},
|
|
404
372
|
zjson_field_str: {
|
|
405
|
-
args: [FFIType.ptr, FFIType.u64],
|
|
373
|
+
args: [FFIType.ptr, FFIType.u64],
|
|
406
374
|
returns: FFIType.ptr,
|
|
407
375
|
},
|
|
408
376
|
zjson_field_len: {
|
|
409
|
-
args: [FFIType.ptr, FFIType.u64],
|
|
377
|
+
args: [FFIType.ptr, FFIType.u64],
|
|
410
378
|
returns: FFIType.u64,
|
|
411
379
|
},
|
|
412
380
|
zjson_field_type: {
|
|
413
|
-
args: [FFIType.ptr, FFIType.u64],
|
|
381
|
+
args: [FFIType.ptr, FFIType.u64],
|
|
414
382
|
returns: FFIType.u8,
|
|
415
383
|
},
|
|
416
384
|
} as const;
|
package/components/types.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
export interface BatchOptions {
|
|
2
|
-
count?: number;
|
|
3
|
-
threads?: number;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// =========================================================================
|
|
7
|
-
// PROGRESS TRACKING TYPES
|
|
8
|
-
// =========================================================================
|
|
9
|
-
|
|
10
|
-
/** Progress event emitted during downloads/uploads */
|
|
11
1
|
export interface ProgressEvent {
|
|
12
2
|
loaded: number;
|
|
13
3
|
total: number;
|
|
@@ -27,13 +17,6 @@ export interface ProgressRequestOptions {
|
|
|
27
17
|
onUploadProgress?: ProgressCallback;
|
|
28
18
|
}
|
|
29
19
|
|
|
30
|
-
export interface BatchResult {
|
|
31
|
-
success: number;
|
|
32
|
-
total: number;
|
|
33
|
-
duration: number;
|
|
34
|
-
requestsPerSecond: number;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
20
|
export interface RequestOptions {
|
|
38
21
|
method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD";
|
|
39
22
|
headers?: Record<string, string>;
|
|
@@ -51,9 +34,6 @@ export interface JirenResponseBody<T = any> {
|
|
|
51
34
|
blob(): Promise<Blob>;
|
|
52
35
|
json<R = T>(): Promise<R>;
|
|
53
36
|
text(): Promise<string>;
|
|
54
|
-
jsonFields<T extends Record<string, any> = any>(
|
|
55
|
-
fields: (keyof T)[]
|
|
56
|
-
): Promise<Partial<T>>;
|
|
57
37
|
}
|
|
58
38
|
|
|
59
39
|
export interface JirenResponse<T = any> {
|
|
@@ -113,30 +93,30 @@ export interface UrlRequestOptions {
|
|
|
113
93
|
export interface UrlEndpoint {
|
|
114
94
|
get<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
|
|
115
95
|
get<T = any>(
|
|
116
|
-
options?: UrlRequestOptions & { responseType: "json" }
|
|
96
|
+
options?: UrlRequestOptions & { responseType: "json" },
|
|
117
97
|
): Promise<T>;
|
|
118
98
|
get<T = any>(
|
|
119
|
-
options?: UrlRequestOptions & { responseType: "text" }
|
|
99
|
+
options?: UrlRequestOptions & { responseType: "text" },
|
|
120
100
|
): Promise<string>;
|
|
121
101
|
|
|
122
102
|
post<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
|
|
123
103
|
post<T = any>(
|
|
124
|
-
options?: UrlRequestOptions & { responseType: "json" }
|
|
104
|
+
options?: UrlRequestOptions & { responseType: "json" },
|
|
125
105
|
): Promise<T>;
|
|
126
106
|
|
|
127
107
|
put<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
|
|
128
108
|
put<T = any>(
|
|
129
|
-
options?: UrlRequestOptions & { responseType: "json" }
|
|
109
|
+
options?: UrlRequestOptions & { responseType: "json" },
|
|
130
110
|
): Promise<T>;
|
|
131
111
|
|
|
132
112
|
patch<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
|
|
133
113
|
patch<T = any>(
|
|
134
|
-
options?: UrlRequestOptions & { responseType: "json" }
|
|
114
|
+
options?: UrlRequestOptions & { responseType: "json" },
|
|
135
115
|
): Promise<T>;
|
|
136
116
|
|
|
137
117
|
delete<T = any>(options?: UrlRequestOptions): Promise<JirenResponse<T>>;
|
|
138
118
|
delete<T = any>(
|
|
139
|
-
options?: UrlRequestOptions & { responseType: "json" }
|
|
119
|
+
options?: UrlRequestOptions & { responseType: "json" },
|
|
140
120
|
): Promise<T>;
|
|
141
121
|
|
|
142
122
|
head(options?: UrlRequestOptions): Promise<JirenResponse<any>>;
|
|
@@ -145,21 +125,25 @@ export interface UrlEndpoint {
|
|
|
145
125
|
|
|
146
126
|
prefetch(options?: UrlRequestOptions): Promise<void>;
|
|
147
127
|
|
|
148
|
-
getJsonFields<T extends Record<string, any>>(
|
|
149
|
-
fields: (keyof T)[],
|
|
150
|
-
options?: UrlRequestOptions
|
|
151
|
-
): Promise<Partial<T>>;
|
|
152
|
-
|
|
153
128
|
download<T = any>(
|
|
154
|
-
options?: ProgressRequestOptions
|
|
129
|
+
options?: ProgressRequestOptions,
|
|
155
130
|
): Promise<JirenResponse<T>>;
|
|
156
131
|
|
|
157
132
|
upload<T = any>(
|
|
158
133
|
options?: ProgressRequestOptions & {
|
|
159
134
|
method?: "POST" | "PUT" | "PATCH";
|
|
160
135
|
body?: string | object | null;
|
|
161
|
-
}
|
|
136
|
+
},
|
|
162
137
|
): Promise<JirenResponse<T>>;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Optimized extraction of specific JSON fields.
|
|
141
|
+
* Reduces FFI overhead by making request and parsing JSON in one native call.
|
|
142
|
+
*/
|
|
143
|
+
getJsonFields<T = any>(
|
|
144
|
+
fields: string[],
|
|
145
|
+
options?: UrlRequestOptions,
|
|
146
|
+
): Promise<T>;
|
|
163
147
|
}
|
|
164
148
|
|
|
165
149
|
export type UrlConfig =
|
|
@@ -167,12 +151,12 @@ export type UrlConfig =
|
|
|
167
151
|
| { url: string; cache?: boolean | CacheConfig; antibot?: boolean };
|
|
168
152
|
|
|
169
153
|
export type ExtractTargetKeys<
|
|
170
|
-
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig
|
|
154
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig>,
|
|
171
155
|
> = T extends readonly TargetUrlConfig[]
|
|
172
156
|
? T[number]["key"]
|
|
173
157
|
: T extends Record<string, UrlConfig>
|
|
174
|
-
|
|
175
|
-
|
|
158
|
+
? keyof T
|
|
159
|
+
: never;
|
|
176
160
|
|
|
177
161
|
export interface InterceptorRequestContext {
|
|
178
162
|
method: string;
|
|
@@ -188,16 +172,16 @@ export interface InterceptorResponseContext<T = any> {
|
|
|
188
172
|
}
|
|
189
173
|
|
|
190
174
|
export type RequestInterceptor = (
|
|
191
|
-
ctx: InterceptorRequestContext
|
|
175
|
+
ctx: InterceptorRequestContext,
|
|
192
176
|
) => InterceptorRequestContext | Promise<InterceptorRequestContext>;
|
|
193
177
|
|
|
194
178
|
export type ResponseInterceptor = <T>(
|
|
195
|
-
ctx: InterceptorResponseContext<T
|
|
179
|
+
ctx: InterceptorResponseContext<T>,
|
|
196
180
|
) => InterceptorResponseContext<T> | Promise<InterceptorResponseContext<T>>;
|
|
197
181
|
|
|
198
182
|
export type ErrorInterceptor = (
|
|
199
183
|
error: Error,
|
|
200
|
-
ctx: InterceptorRequestContext
|
|
184
|
+
ctx: InterceptorRequestContext,
|
|
201
185
|
) => void | Promise<void>;
|
|
202
186
|
|
|
203
187
|
export interface Interceptors {
|
|
@@ -266,7 +250,7 @@ export interface MetricsAPI {
|
|
|
266
250
|
export interface JirenClientOptions<
|
|
267
251
|
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig> =
|
|
268
252
|
| readonly TargetUrlConfig[]
|
|
269
|
-
| Record<string, UrlConfig
|
|
253
|
+
| Record<string, UrlConfig>,
|
|
270
254
|
> {
|
|
271
255
|
urls?: T;
|
|
272
256
|
|
|
@@ -279,7 +263,7 @@ export interface JirenClientOptions<
|
|
|
279
263
|
}
|
|
280
264
|
|
|
281
265
|
export type UrlAccessor<
|
|
282
|
-
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig
|
|
266
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig>,
|
|
283
267
|
> = {
|
|
284
268
|
[K in ExtractTargetKeys<T>]: UrlEndpoint;
|
|
285
269
|
};
|
|
@@ -20,7 +20,6 @@ export declare class JirenClient<T extends readonly TargetUrlConfig[] | Record<s
|
|
|
20
20
|
/** Type-safe URL accessor for warmed-up URLs */
|
|
21
21
|
readonly url: UrlAccessor<T>;
|
|
22
22
|
/** Alias for url property */
|
|
23
|
-
readonly targets: UrlAccessor<T>;
|
|
24
23
|
private metricsCollector;
|
|
25
24
|
readonly metrics: MetricsAPI;
|
|
26
25
|
constructor(options?: JirenClientOptions<T>);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-node-native.d.ts","sourceRoot":"","sources":["../../components/client-node-native.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EAEb,eAAe,EAKf,YAAY,EAMZ,UAAU,EAGV,SAAS,EACT,kBAAkB,EAElB,WAAW,EACZ,MAAM,YAAY,CAAC;AAiBpB,wBAAgB,UAAU,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,eAAe,EAAE,EACnE,IAAI,EAAE,CAAC,GACN,CAAC,CAEH;AAUD,qBAAa,WAAW,CACtB,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