@igniter-js/caller 0.1.4 → 0.1.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/AGENTS.md +112 -5
- package/README.md +123 -5
- package/dist/adapters/index.d.mts +70 -1
- package/dist/adapters/index.d.ts +70 -1
- package/dist/client/index.d.mts +212 -0
- package/dist/client/index.d.ts +212 -0
- package/dist/client/index.js +688 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +679 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/index.d.mts +66 -995
- package/dist/index.d.ts +66 -995
- package/dist/index.js +406 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -7
- package/dist/index.mjs.map +1 -1
- package/dist/manager-CVi9utzy.d.ts +1121 -0
- package/dist/manager-DWvX2zsz.d.mts +1121 -0
- package/dist/store-D2p2dqGN.d.mts +54 -0
- package/dist/store-D2p2dqGN.d.ts +54 -0
- package/package.json +14 -5
- package/dist/index-COZVROi_.d.mts +0 -121
- package/dist/index-COZVROi_.d.ts +0 -121
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store adapter interface compatible with Igniter.js Store.
|
|
3
|
+
*
|
|
4
|
+
* This allows IgniterCaller to use any store implementation (Redis, in-memory, etc.)
|
|
5
|
+
* for persistent caching across requests and deployments.
|
|
6
|
+
*/
|
|
7
|
+
interface IgniterCallerStoreAdapter<TClient = any> {
|
|
8
|
+
/** The underlying client instance (e.g., Redis client). */
|
|
9
|
+
readonly client: TClient;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a value from the store by its key.
|
|
12
|
+
*
|
|
13
|
+
* @param key - The key to retrieve.
|
|
14
|
+
* @returns The value if found (auto-deserialized), otherwise null.
|
|
15
|
+
*/
|
|
16
|
+
get<T = any>(key: string): Promise<T | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Stores a value in the store.
|
|
19
|
+
*
|
|
20
|
+
* @param key - The key to store the value under.
|
|
21
|
+
* @param value - The value to store (will be auto-serialized).
|
|
22
|
+
* @param options - Configuration options, such as TTL.
|
|
23
|
+
*/
|
|
24
|
+
set(key: string, value: any, options?: {
|
|
25
|
+
ttl?: number;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a key from the store.
|
|
30
|
+
*
|
|
31
|
+
* @param key - The key to delete.
|
|
32
|
+
*/
|
|
33
|
+
delete(key: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a key exists in the store.
|
|
36
|
+
*
|
|
37
|
+
* @param key - The key to check.
|
|
38
|
+
* @returns `true` if the key exists, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
has(key: string): Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Configuration options for store-based caching.
|
|
44
|
+
*/
|
|
45
|
+
interface IgniterCallerStoreOptions {
|
|
46
|
+
/** Default TTL in seconds for cached entries (default: 3600 = 1 hour). */
|
|
47
|
+
ttl?: number;
|
|
48
|
+
/** Prefix for all cache keys (default: 'igniter:caller:'). */
|
|
49
|
+
keyPrefix?: string;
|
|
50
|
+
/** Whether to fallback to fetch cache when store is unavailable (default: true). */
|
|
51
|
+
fallbackToFetch?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type { IgniterCallerStoreAdapter as I, IgniterCallerStoreOptions as a };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Store adapter interface compatible with Igniter.js Store.
|
|
3
|
+
*
|
|
4
|
+
* This allows IgniterCaller to use any store implementation (Redis, in-memory, etc.)
|
|
5
|
+
* for persistent caching across requests and deployments.
|
|
6
|
+
*/
|
|
7
|
+
interface IgniterCallerStoreAdapter<TClient = any> {
|
|
8
|
+
/** The underlying client instance (e.g., Redis client). */
|
|
9
|
+
readonly client: TClient;
|
|
10
|
+
/**
|
|
11
|
+
* Retrieves a value from the store by its key.
|
|
12
|
+
*
|
|
13
|
+
* @param key - The key to retrieve.
|
|
14
|
+
* @returns The value if found (auto-deserialized), otherwise null.
|
|
15
|
+
*/
|
|
16
|
+
get<T = any>(key: string): Promise<T | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Stores a value in the store.
|
|
19
|
+
*
|
|
20
|
+
* @param key - The key to store the value under.
|
|
21
|
+
* @param value - The value to store (will be auto-serialized).
|
|
22
|
+
* @param options - Configuration options, such as TTL.
|
|
23
|
+
*/
|
|
24
|
+
set(key: string, value: any, options?: {
|
|
25
|
+
ttl?: number;
|
|
26
|
+
[key: string]: any;
|
|
27
|
+
}): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a key from the store.
|
|
30
|
+
*
|
|
31
|
+
* @param key - The key to delete.
|
|
32
|
+
*/
|
|
33
|
+
delete(key: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Checks if a key exists in the store.
|
|
36
|
+
*
|
|
37
|
+
* @param key - The key to check.
|
|
38
|
+
* @returns `true` if the key exists, otherwise `false`.
|
|
39
|
+
*/
|
|
40
|
+
has(key: string): Promise<boolean>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Configuration options for store-based caching.
|
|
44
|
+
*/
|
|
45
|
+
interface IgniterCallerStoreOptions {
|
|
46
|
+
/** Default TTL in seconds for cached entries (default: 3600 = 1 hour). */
|
|
47
|
+
ttl?: number;
|
|
48
|
+
/** Prefix for all cache keys (default: 'igniter:caller:'). */
|
|
49
|
+
keyPrefix?: string;
|
|
50
|
+
/** Whether to fallback to fetch cache when store is unavailable (default: true). */
|
|
51
|
+
fallbackToFetch?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type { IgniterCallerStoreAdapter as I, IgniterCallerStoreOptions as a };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@igniter-js/caller",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Type-safe HTTP client for Igniter.js with interceptors, retries, caching, and StandardSchema validation",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,6 +26,11 @@
|
|
|
26
26
|
"types": "./dist/adapters/index.d.ts",
|
|
27
27
|
"import": "./dist/adapters/index.mjs",
|
|
28
28
|
"require": "./dist/adapters/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./client": {
|
|
31
|
+
"types": "./dist/client/index.d.ts",
|
|
32
|
+
"import": "./dist/client/index.mjs",
|
|
33
|
+
"require": "./dist/client/index.js"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"scripts": {
|
|
@@ -63,21 +68,25 @@
|
|
|
63
68
|
},
|
|
64
69
|
"homepage": "https://igniterjs.com",
|
|
65
70
|
"dependencies": {
|
|
71
|
+
"@igniter-js/common": ">=0.1.0",
|
|
66
72
|
"@igniter-js/telemetry": ">=0.1.12"
|
|
67
73
|
},
|
|
68
74
|
"devDependencies": {
|
|
69
|
-
"@igniter-js/
|
|
75
|
+
"@igniter-js/common": "*",
|
|
70
76
|
"@igniter-js/telemetry": "*",
|
|
71
77
|
"@types/node": "^22.7.5",
|
|
72
78
|
"tsup": "^8.3.0",
|
|
73
79
|
"typescript": "^5.6.3",
|
|
74
80
|
"vitest": "^2.1.4",
|
|
75
|
-
"zod": "^4.2.1"
|
|
81
|
+
"zod": "^4.2.1",
|
|
82
|
+
"@types/react": "^18.3.12",
|
|
83
|
+
"react": "^18.3.1"
|
|
76
84
|
},
|
|
77
85
|
"peerDependencies": {
|
|
78
|
-
"@igniter-js/
|
|
86
|
+
"@igniter-js/common": ">=0.1.0",
|
|
79
87
|
"@igniter-js/telemetry": ">=0.1.12",
|
|
80
|
-
"zod": ">=4.2.1"
|
|
88
|
+
"zod": ">=4.2.1",
|
|
89
|
+
"react": ">=18.0.0"
|
|
81
90
|
},
|
|
82
91
|
"peerDependenciesMeta": {
|
|
83
92
|
"zod": {
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store adapter interface compatible with Igniter.js Store.
|
|
3
|
-
*
|
|
4
|
-
* This allows IgniterCaller to use any store implementation (Redis, in-memory, etc.)
|
|
5
|
-
* for persistent caching across requests and deployments.
|
|
6
|
-
*/
|
|
7
|
-
interface IgniterCallerStoreAdapter<TClient = any> {
|
|
8
|
-
/** The underlying client instance (e.g., Redis client). */
|
|
9
|
-
readonly client: TClient;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves a value from the store by its key.
|
|
12
|
-
*
|
|
13
|
-
* @param key - The key to retrieve.
|
|
14
|
-
* @returns The value if found (auto-deserialized), otherwise null.
|
|
15
|
-
*/
|
|
16
|
-
get<T = any>(key: string): Promise<T | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Stores a value in the store.
|
|
19
|
-
*
|
|
20
|
-
* @param key - The key to store the value under.
|
|
21
|
-
* @param value - The value to store (will be auto-serialized).
|
|
22
|
-
* @param options - Configuration options, such as TTL.
|
|
23
|
-
*/
|
|
24
|
-
set(key: string, value: any, options?: {
|
|
25
|
-
ttl?: number;
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Deletes a key from the store.
|
|
30
|
-
*
|
|
31
|
-
* @param key - The key to delete.
|
|
32
|
-
*/
|
|
33
|
-
delete(key: string): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Checks if a key exists in the store.
|
|
36
|
-
*
|
|
37
|
-
* @param key - The key to check.
|
|
38
|
-
* @returns `true` if the key exists, otherwise `false`.
|
|
39
|
-
*/
|
|
40
|
-
has(key: string): Promise<boolean>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Configuration options for store-based caching.
|
|
44
|
-
*/
|
|
45
|
-
interface IgniterCallerStoreOptions {
|
|
46
|
-
/** Default TTL in seconds for cached entries (default: 3600 = 1 hour). */
|
|
47
|
-
ttl?: number;
|
|
48
|
-
/** Prefix for all cache keys (default: 'igniter:caller:'). */
|
|
49
|
-
keyPrefix?: string;
|
|
50
|
-
/** Whether to fallback to fetch cache when store is unavailable (default: true). */
|
|
51
|
-
fallbackToFetch?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @fileoverview In-memory mock store adapter for @igniter-js/caller.
|
|
56
|
-
* @module @igniter-js/caller/adapters/mock
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* In-memory mock adapter for request caching in tests.
|
|
61
|
-
*/
|
|
62
|
-
declare class MockCallerStoreAdapter implements IgniterCallerStoreAdapter<Map<string, unknown>> {
|
|
63
|
-
/** Creates a new mock adapter instance. */
|
|
64
|
-
static create(): MockCallerStoreAdapter;
|
|
65
|
-
/** Underlying in-memory store. */
|
|
66
|
-
readonly client: Map<string, unknown>;
|
|
67
|
-
/** Tracks all calls for assertions. */
|
|
68
|
-
readonly calls: {
|
|
69
|
-
get: number;
|
|
70
|
-
set: number;
|
|
71
|
-
delete: number;
|
|
72
|
-
has: number;
|
|
73
|
-
};
|
|
74
|
-
/** Captures recent operations. */
|
|
75
|
-
readonly history: {
|
|
76
|
-
get: string[];
|
|
77
|
-
set: Array<{
|
|
78
|
-
key: string;
|
|
79
|
-
value: unknown;
|
|
80
|
-
options?: IgniterCallerStoreOptions;
|
|
81
|
-
}>;
|
|
82
|
-
delete: string[];
|
|
83
|
-
has: string[];
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves a cached value by key.
|
|
87
|
-
*
|
|
88
|
-
* @param key - Cache key (without prefix).
|
|
89
|
-
* @returns Cached value or null.
|
|
90
|
-
*/
|
|
91
|
-
get<T = any>(key: string): Promise<T | null>;
|
|
92
|
-
/**
|
|
93
|
-
* Stores a cached value.
|
|
94
|
-
*
|
|
95
|
-
* @param key - Cache key (without prefix).
|
|
96
|
-
* @param value - Value to store.
|
|
97
|
-
* @param options - Cache options (ttl, etc).
|
|
98
|
-
*/
|
|
99
|
-
set(key: string, value: any, options?: IgniterCallerStoreOptions): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Removes a cached value.
|
|
102
|
-
*
|
|
103
|
-
* @param key - Cache key (without prefix).
|
|
104
|
-
*/
|
|
105
|
-
delete(key: string): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* Checks if a cached value exists.
|
|
108
|
-
*
|
|
109
|
-
* @param key - Cache key (without prefix).
|
|
110
|
-
* @returns True when the key exists.
|
|
111
|
-
*/
|
|
112
|
-
has(key: string): Promise<boolean>;
|
|
113
|
-
/**
|
|
114
|
-
* Clears all tracked state.
|
|
115
|
-
*
|
|
116
|
-
* @returns Nothing.
|
|
117
|
-
*/
|
|
118
|
-
clear(): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { type IgniterCallerStoreAdapter as I, MockCallerStoreAdapter as M, type IgniterCallerStoreOptions as a };
|
package/dist/index-COZVROi_.d.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Store adapter interface compatible with Igniter.js Store.
|
|
3
|
-
*
|
|
4
|
-
* This allows IgniterCaller to use any store implementation (Redis, in-memory, etc.)
|
|
5
|
-
* for persistent caching across requests and deployments.
|
|
6
|
-
*/
|
|
7
|
-
interface IgniterCallerStoreAdapter<TClient = any> {
|
|
8
|
-
/** The underlying client instance (e.g., Redis client). */
|
|
9
|
-
readonly client: TClient;
|
|
10
|
-
/**
|
|
11
|
-
* Retrieves a value from the store by its key.
|
|
12
|
-
*
|
|
13
|
-
* @param key - The key to retrieve.
|
|
14
|
-
* @returns The value if found (auto-deserialized), otherwise null.
|
|
15
|
-
*/
|
|
16
|
-
get<T = any>(key: string): Promise<T | null>;
|
|
17
|
-
/**
|
|
18
|
-
* Stores a value in the store.
|
|
19
|
-
*
|
|
20
|
-
* @param key - The key to store the value under.
|
|
21
|
-
* @param value - The value to store (will be auto-serialized).
|
|
22
|
-
* @param options - Configuration options, such as TTL.
|
|
23
|
-
*/
|
|
24
|
-
set(key: string, value: any, options?: {
|
|
25
|
-
ttl?: number;
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
}): Promise<void>;
|
|
28
|
-
/**
|
|
29
|
-
* Deletes a key from the store.
|
|
30
|
-
*
|
|
31
|
-
* @param key - The key to delete.
|
|
32
|
-
*/
|
|
33
|
-
delete(key: string): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Checks if a key exists in the store.
|
|
36
|
-
*
|
|
37
|
-
* @param key - The key to check.
|
|
38
|
-
* @returns `true` if the key exists, otherwise `false`.
|
|
39
|
-
*/
|
|
40
|
-
has(key: string): Promise<boolean>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Configuration options for store-based caching.
|
|
44
|
-
*/
|
|
45
|
-
interface IgniterCallerStoreOptions {
|
|
46
|
-
/** Default TTL in seconds for cached entries (default: 3600 = 1 hour). */
|
|
47
|
-
ttl?: number;
|
|
48
|
-
/** Prefix for all cache keys (default: 'igniter:caller:'). */
|
|
49
|
-
keyPrefix?: string;
|
|
50
|
-
/** Whether to fallback to fetch cache when store is unavailable (default: true). */
|
|
51
|
-
fallbackToFetch?: boolean;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @fileoverview In-memory mock store adapter for @igniter-js/caller.
|
|
56
|
-
* @module @igniter-js/caller/adapters/mock
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* In-memory mock adapter for request caching in tests.
|
|
61
|
-
*/
|
|
62
|
-
declare class MockCallerStoreAdapter implements IgniterCallerStoreAdapter<Map<string, unknown>> {
|
|
63
|
-
/** Creates a new mock adapter instance. */
|
|
64
|
-
static create(): MockCallerStoreAdapter;
|
|
65
|
-
/** Underlying in-memory store. */
|
|
66
|
-
readonly client: Map<string, unknown>;
|
|
67
|
-
/** Tracks all calls for assertions. */
|
|
68
|
-
readonly calls: {
|
|
69
|
-
get: number;
|
|
70
|
-
set: number;
|
|
71
|
-
delete: number;
|
|
72
|
-
has: number;
|
|
73
|
-
};
|
|
74
|
-
/** Captures recent operations. */
|
|
75
|
-
readonly history: {
|
|
76
|
-
get: string[];
|
|
77
|
-
set: Array<{
|
|
78
|
-
key: string;
|
|
79
|
-
value: unknown;
|
|
80
|
-
options?: IgniterCallerStoreOptions;
|
|
81
|
-
}>;
|
|
82
|
-
delete: string[];
|
|
83
|
-
has: string[];
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Retrieves a cached value by key.
|
|
87
|
-
*
|
|
88
|
-
* @param key - Cache key (without prefix).
|
|
89
|
-
* @returns Cached value or null.
|
|
90
|
-
*/
|
|
91
|
-
get<T = any>(key: string): Promise<T | null>;
|
|
92
|
-
/**
|
|
93
|
-
* Stores a cached value.
|
|
94
|
-
*
|
|
95
|
-
* @param key - Cache key (without prefix).
|
|
96
|
-
* @param value - Value to store.
|
|
97
|
-
* @param options - Cache options (ttl, etc).
|
|
98
|
-
*/
|
|
99
|
-
set(key: string, value: any, options?: IgniterCallerStoreOptions): Promise<void>;
|
|
100
|
-
/**
|
|
101
|
-
* Removes a cached value.
|
|
102
|
-
*
|
|
103
|
-
* @param key - Cache key (without prefix).
|
|
104
|
-
*/
|
|
105
|
-
delete(key: string): Promise<void>;
|
|
106
|
-
/**
|
|
107
|
-
* Checks if a cached value exists.
|
|
108
|
-
*
|
|
109
|
-
* @param key - Cache key (without prefix).
|
|
110
|
-
* @returns True when the key exists.
|
|
111
|
-
*/
|
|
112
|
-
has(key: string): Promise<boolean>;
|
|
113
|
-
/**
|
|
114
|
-
* Clears all tracked state.
|
|
115
|
-
*
|
|
116
|
-
* @returns Nothing.
|
|
117
|
-
*/
|
|
118
|
-
clear(): void;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export { type IgniterCallerStoreAdapter as I, MockCallerStoreAdapter as M, type IgniterCallerStoreOptions as a };
|