jiren 1.4.5 → 1.5.5
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 +284 -337
- package/components/client-node-native.ts +11 -11
- package/components/client.ts +423 -126
- package/components/index.ts +3 -0
- package/components/metrics.ts +420 -0
- package/components/native.ts +42 -0
- package/components/types.ts +65 -5
- package/lib/libhttpclient.dylib +0 -0
- package/package.json +1 -1
- package/components/client-node.ts +0 -473
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
RequestOptions,
|
|
7
7
|
JirenResponse,
|
|
8
8
|
JirenResponseBody,
|
|
9
|
-
|
|
9
|
+
TargetUrlConfig,
|
|
10
10
|
UrlRequestOptions,
|
|
11
11
|
UrlEndpoint,
|
|
12
12
|
CacheConfig,
|
|
@@ -32,8 +32,8 @@ export type UrlConfig = string | { url: string; cache?: boolean | CacheConfig };
|
|
|
32
32
|
|
|
33
33
|
/** Options for JirenClient constructor */
|
|
34
34
|
export interface JirenClientOptions<
|
|
35
|
-
T extends readonly
|
|
36
|
-
| readonly
|
|
35
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig> =
|
|
36
|
+
| readonly TargetUrlConfig[]
|
|
37
37
|
| Record<string, UrlConfig>
|
|
38
38
|
> {
|
|
39
39
|
/** URLs to warmup on client creation (pre-connect + handshake) */
|
|
@@ -45,8 +45,8 @@ export interface JirenClientOptions<
|
|
|
45
45
|
|
|
46
46
|
/** Helper to extract keys from Warmup Config */
|
|
47
47
|
export type ExtractWarmupKeys<
|
|
48
|
-
T extends readonly
|
|
49
|
-
> = T extends readonly
|
|
48
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig>
|
|
49
|
+
> = T extends readonly TargetUrlConfig[]
|
|
50
50
|
? T[number]["key"]
|
|
51
51
|
: T extends Record<string, UrlConfig>
|
|
52
52
|
? keyof T
|
|
@@ -54,7 +54,7 @@ export type ExtractWarmupKeys<
|
|
|
54
54
|
|
|
55
55
|
/** Type-safe URL accessor - maps keys to UrlEndpoint objects */
|
|
56
56
|
export type UrlAccessor<
|
|
57
|
-
T extends readonly
|
|
57
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig>
|
|
58
58
|
> = {
|
|
59
59
|
[K in ExtractWarmupKeys<T>]: UrlEndpoint;
|
|
60
60
|
};
|
|
@@ -62,15 +62,15 @@ export type UrlAccessor<
|
|
|
62
62
|
/**
|
|
63
63
|
* Helper function to define warmup URLs with type inference.
|
|
64
64
|
*/
|
|
65
|
-
export function defineUrls<const T extends readonly
|
|
65
|
+
export function defineUrls<const T extends readonly TargetUrlConfig[]>(
|
|
66
66
|
urls: T
|
|
67
67
|
): T {
|
|
68
68
|
return urls;
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export class JirenClient<
|
|
72
|
-
T extends readonly
|
|
73
|
-
| readonly
|
|
72
|
+
T extends readonly TargetUrlConfig[] | Record<string, UrlConfig> =
|
|
73
|
+
| readonly TargetUrlConfig[]
|
|
74
74
|
| Record<string, UrlConfig>
|
|
75
75
|
> {
|
|
76
76
|
private ptr: any = null; // Koffi pointer (Buffer or External)
|
|
@@ -105,8 +105,8 @@ export class JirenClient<
|
|
|
105
105
|
if (typeof item === "string") {
|
|
106
106
|
urls.push(item);
|
|
107
107
|
} else {
|
|
108
|
-
//
|
|
109
|
-
const config = item as
|
|
108
|
+
// TargetUrlConfig with key and optional cache
|
|
109
|
+
const config = item as TargetUrlConfig;
|
|
110
110
|
urls.push(config.url);
|
|
111
111
|
this.urlMap.set(config.key, config.url);
|
|
112
112
|
|