@jack-kernel/sdk 1.0.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 +757 -0
- package/dist/cjs/agent.js +321 -0
- package/dist/cjs/agent.js.map +1 -0
- package/dist/cjs/cache.js +58 -0
- package/dist/cjs/cache.js.map +1 -0
- package/dist/cjs/client.js +196 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/costs.js +104 -0
- package/dist/cjs/costs.js.map +1 -0
- package/dist/cjs/errors.js +287 -0
- package/dist/cjs/errors.js.map +1 -0
- package/dist/cjs/execution.js +385 -0
- package/dist/cjs/execution.js.map +1 -0
- package/dist/cjs/index.js +256 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/intents.js +185 -0
- package/dist/cjs/intents.js.map +1 -0
- package/dist/cjs/serialization.js +164 -0
- package/dist/cjs/serialization.js.map +1 -0
- package/dist/cjs/types.js +31 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/validation.js +114 -0
- package/dist/cjs/validation.js.map +1 -0
- package/dist/esm/agent.js +317 -0
- package/dist/esm/agent.js.map +1 -0
- package/dist/esm/cache.js +54 -0
- package/dist/esm/cache.js.map +1 -0
- package/dist/esm/client.js +192 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/costs.js +100 -0
- package/dist/esm/costs.js.map +1 -0
- package/dist/esm/errors.js +278 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/execution.js +381 -0
- package/dist/esm/execution.js.map +1 -0
- package/dist/esm/index.js +236 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/intents.js +181 -0
- package/dist/esm/intents.js.map +1 -0
- package/dist/esm/serialization.js +159 -0
- package/dist/esm/serialization.js.map +1 -0
- package/dist/esm/types.js +28 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/validation.js +111 -0
- package/dist/esm/validation.js.map +1 -0
- package/dist/types/agent.d.ts +171 -0
- package/dist/types/agent.d.ts.map +1 -0
- package/dist/types/cache.d.ts +25 -0
- package/dist/types/cache.d.ts.map +1 -0
- package/dist/types/client.d.ts +46 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/costs.d.ts +91 -0
- package/dist/types/costs.d.ts.map +1 -0
- package/dist/types/errors.d.ts +242 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/execution.d.ts +145 -0
- package/dist/types/execution.d.ts.map +1 -0
- package/dist/types/index.d.ts +205 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/intents.d.ts +158 -0
- package/dist/types/intents.d.ts.map +1 -0
- package/dist/types/serialization.d.ts +82 -0
- package/dist/types/serialization.d.ts.map +1 -0
- package/dist/types/types.d.ts +302 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/validation.d.ts +40 -0
- package/dist/types/validation.d.ts.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Agent utilities for the JACK SDK
|
|
4
|
+
*
|
|
5
|
+
* This module provides the AgentUtils class with high-level abstractions
|
|
6
|
+
* for batch operations, dry-run validation, policy enforcement, and
|
|
7
|
+
* event subscriptions for automated agent systems.
|
|
8
|
+
*
|
|
9
|
+
* Requirements: 8.1, 8.2, 8.3, 8.4, 8.5
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.AgentUtils = void 0;
|
|
13
|
+
const intents_js_1 = require("./intents.js");
|
|
14
|
+
const execution_js_1 = require("./execution.js");
|
|
15
|
+
const validation_js_1 = require("./validation.js");
|
|
16
|
+
/**
|
|
17
|
+
* Utilities for agent-based intent orchestration
|
|
18
|
+
*
|
|
19
|
+
* Provides batch operations, dry-run validation, policy enforcement,
|
|
20
|
+
* and multi-intent subscriptions for automated systems.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const client = new JackClient({ baseUrl: 'https://api.jack.example' });
|
|
25
|
+
* const agent = new AgentUtils(client);
|
|
26
|
+
*
|
|
27
|
+
* // Batch submit multiple intents
|
|
28
|
+
* const results = await agent.batchSubmit([
|
|
29
|
+
* { params: intent1, signature: sig1 },
|
|
30
|
+
* { params: intent2, signature: sig2 }
|
|
31
|
+
* ]);
|
|
32
|
+
*
|
|
33
|
+
* results.forEach(result => {
|
|
34
|
+
* if (result.success) {
|
|
35
|
+
* console.log('Submitted:', result.intentId);
|
|
36
|
+
* } else {
|
|
37
|
+
* console.error('Failed:', result.error);
|
|
38
|
+
* }
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
class AgentUtils {
|
|
43
|
+
client;
|
|
44
|
+
intentManager;
|
|
45
|
+
executionTracker;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new AgentUtils instance
|
|
48
|
+
*
|
|
49
|
+
* @param client - The JackClient instance to use for API requests
|
|
50
|
+
*/
|
|
51
|
+
constructor(client) {
|
|
52
|
+
this.client = client;
|
|
53
|
+
this.intentManager = new intents_js_1.IntentManager(client);
|
|
54
|
+
this.executionTracker = new execution_js_1.ExecutionTracker(client);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Submit multiple intents in parallel
|
|
58
|
+
*
|
|
59
|
+
* Uses Promise.allSettled() to submit all intents concurrently,
|
|
60
|
+
* ensuring that failures in individual submissions don't affect others.
|
|
61
|
+
* The result array length always matches the input array length,
|
|
62
|
+
* with each result corresponding to the same index in the input.
|
|
63
|
+
*
|
|
64
|
+
* @param intents - Array of intent parameters and signatures to submit
|
|
65
|
+
* @returns Promise resolving to array of BatchSubmitResult objects
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const results = await agent.batchSubmit([
|
|
70
|
+
* { params: intent1, signature: sig1 },
|
|
71
|
+
* { params: intent2, signature: sig2 },
|
|
72
|
+
* { params: intent3, signature: sig3 }
|
|
73
|
+
* ]);
|
|
74
|
+
*
|
|
75
|
+
* // Results array has same length as input
|
|
76
|
+
* console.log(results.length); // 3
|
|
77
|
+
*
|
|
78
|
+
* // Check individual results
|
|
79
|
+
* results.forEach((result, index) => {
|
|
80
|
+
* if (result.success) {
|
|
81
|
+
* console.log(`Intent ${index} submitted: ${result.intentId}`);
|
|
82
|
+
* } else {
|
|
83
|
+
* console.error(`Intent ${index} failed:`, result.error?.message);
|
|
84
|
+
* }
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* // Count successes and failures
|
|
88
|
+
* const successes = results.filter(r => r.success).length;
|
|
89
|
+
* const failures = results.filter(r => !r.success).length;
|
|
90
|
+
* console.log(`${successes} succeeded, ${failures} failed`);
|
|
91
|
+
* ```
|
|
92
|
+
*
|
|
93
|
+
* **Validates: Requirements 8.1, 8.2**
|
|
94
|
+
*/
|
|
95
|
+
async batchSubmit(intents) {
|
|
96
|
+
// Submit all intents in parallel using Promise.allSettled
|
|
97
|
+
// This ensures all submissions are attempted regardless of individual failures
|
|
98
|
+
const promises = intents.map(async ({ params, signature }) => {
|
|
99
|
+
return this.intentManager.submit(params, signature);
|
|
100
|
+
});
|
|
101
|
+
const results = await Promise.allSettled(promises);
|
|
102
|
+
// Transform PromiseSettledResult to BatchSubmitResult
|
|
103
|
+
// Ensure result array length matches input array length
|
|
104
|
+
return results.map((result, index) => {
|
|
105
|
+
if (result.status === 'fulfilled') {
|
|
106
|
+
return {
|
|
107
|
+
intentId: result.value,
|
|
108
|
+
success: true
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return {
|
|
113
|
+
intentId: '', // Empty string for failed submissions
|
|
114
|
+
success: false,
|
|
115
|
+
error: result.reason instanceof Error ? result.reason : new Error(String(result.reason))
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Simulate intent execution without submission
|
|
122
|
+
*
|
|
123
|
+
* Validates intent parameters and estimates costs without actually
|
|
124
|
+
* submitting the intent to the API. Useful for testing and validation.
|
|
125
|
+
*
|
|
126
|
+
* @param params - Intent parameters to validate
|
|
127
|
+
* @returns Promise resolving to DryRunResult with validation status
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* const result = await agent.dryRun(params);
|
|
132
|
+
* if (result.valid) {
|
|
133
|
+
* console.log('Estimated cost:', result.estimatedCost);
|
|
134
|
+
* } else {
|
|
135
|
+
* console.error('Validation errors:', result.errors);
|
|
136
|
+
* }
|
|
137
|
+
* ```
|
|
138
|
+
*
|
|
139
|
+
* **Validates: Requirement 8.4**
|
|
140
|
+
*/
|
|
141
|
+
async dryRun(params) {
|
|
142
|
+
const validation = (0, validation_js_1.validateIntentParams)(params);
|
|
143
|
+
if (!validation.valid) {
|
|
144
|
+
return {
|
|
145
|
+
valid: false,
|
|
146
|
+
errors: validation.errors
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// In a real implementation, this might call an API endpoint
|
|
150
|
+
// to get cost estimates. For now, we just return validation status.
|
|
151
|
+
return {
|
|
152
|
+
valid: true,
|
|
153
|
+
estimatedCost: undefined, // Could be populated by API call
|
|
154
|
+
errors: []
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Validate intent parameters against policy rules
|
|
159
|
+
*
|
|
160
|
+
* Checks that intent parameters comply with the specified policy,
|
|
161
|
+
* including amount limits, allowed chains, tokens, and deadline constraints.
|
|
162
|
+
*
|
|
163
|
+
* @param params - Intent parameters to validate
|
|
164
|
+
* @param policy - Policy rules to enforce
|
|
165
|
+
* @returns ValidationResult with valid flag and error messages
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* const policy: Policy = {
|
|
170
|
+
* maxAmountIn: '1000000000',
|
|
171
|
+
* allowedSourceChains: ['arbitrum', 'optimism'],
|
|
172
|
+
* allowedDestinationChains: ['base', 'ethereum'],
|
|
173
|
+
* maxDeadlineOffset: 3600000 // 1 hour
|
|
174
|
+
* };
|
|
175
|
+
*
|
|
176
|
+
* const result = agent.validatePolicy(params, policy);
|
|
177
|
+
* if (!result.valid) {
|
|
178
|
+
* console.error('Policy violations:', result.errors);
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* **Validates: Requirement 8.5**
|
|
183
|
+
*/
|
|
184
|
+
validatePolicy(params, policy) {
|
|
185
|
+
const errors = [];
|
|
186
|
+
// Check maximum amount in
|
|
187
|
+
if (policy.maxAmountIn !== undefined) {
|
|
188
|
+
const maxAmount = BigInt(policy.maxAmountIn);
|
|
189
|
+
const amount = BigInt(params.amountIn);
|
|
190
|
+
if (amount > maxAmount) {
|
|
191
|
+
errors.push(`Amount in ${params.amountIn} exceeds maximum ${policy.maxAmountIn}`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// Check minimum amount out
|
|
195
|
+
if (policy.minAmountOut !== undefined) {
|
|
196
|
+
const minAmount = BigInt(policy.minAmountOut);
|
|
197
|
+
const amount = BigInt(params.minAmountOut);
|
|
198
|
+
if (amount < minAmount) {
|
|
199
|
+
errors.push(`Minimum amount out ${params.minAmountOut} is below policy minimum ${policy.minAmountOut}`);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// Check allowed source chains
|
|
203
|
+
if (policy.allowedSourceChains !== undefined) {
|
|
204
|
+
if (!policy.allowedSourceChains.includes(params.sourceChain)) {
|
|
205
|
+
errors.push(`Source chain ${params.sourceChain} is not in allowed list: ${policy.allowedSourceChains.join(', ')}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
// Check allowed destination chains
|
|
209
|
+
if (policy.allowedDestinationChains !== undefined) {
|
|
210
|
+
if (!policy.allowedDestinationChains.includes(params.destinationChain)) {
|
|
211
|
+
errors.push(`Destination chain ${params.destinationChain} is not in allowed list: ${policy.allowedDestinationChains.join(', ')}`);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
// Check allowed input tokens
|
|
215
|
+
if (policy.allowedTokensIn !== undefined) {
|
|
216
|
+
if (!policy.allowedTokensIn.includes(params.tokenIn)) {
|
|
217
|
+
errors.push(`Input token ${params.tokenIn} is not in allowed list`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Check allowed output tokens
|
|
221
|
+
if (policy.allowedTokensOut !== undefined) {
|
|
222
|
+
if (!policy.allowedTokensOut.includes(params.tokenOut)) {
|
|
223
|
+
errors.push(`Output token ${params.tokenOut} is not in allowed list`);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// Check maximum deadline offset
|
|
227
|
+
if (policy.maxDeadlineOffset !== undefined) {
|
|
228
|
+
const now = Date.now();
|
|
229
|
+
const deadlineOffset = params.deadline - now;
|
|
230
|
+
if (deadlineOffset > policy.maxDeadlineOffset) {
|
|
231
|
+
errors.push(`Deadline offset ${deadlineOffset}ms exceeds maximum ${policy.maxDeadlineOffset}ms`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return {
|
|
235
|
+
valid: errors.length === 0,
|
|
236
|
+
errors
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Subscribe to status changes for multiple intents
|
|
241
|
+
*
|
|
242
|
+
* Polls multiple intents in parallel and invokes the callback whenever
|
|
243
|
+
* any intent's status changes. Returns a Subscription object that can
|
|
244
|
+
* be used to unsubscribe and stop polling.
|
|
245
|
+
*
|
|
246
|
+
* @param intentIds - Array of intent IDs to monitor
|
|
247
|
+
* @param callback - Function to call when any intent status changes
|
|
248
|
+
* @param options - Polling options (interval, timeout)
|
|
249
|
+
* @returns Subscription object with unsubscribe() method
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const subscription = agent.subscribeToUpdates(
|
|
254
|
+
* ['JK-ABC123456', 'JK-DEF789012'],
|
|
255
|
+
* (intentId, intent) => {
|
|
256
|
+
* console.log(`${intentId} status changed to ${intent.status}`);
|
|
257
|
+
* },
|
|
258
|
+
* { interval: 5000 }
|
|
259
|
+
* );
|
|
260
|
+
*
|
|
261
|
+
* // Later, stop polling
|
|
262
|
+
* subscription.unsubscribe();
|
|
263
|
+
* ```
|
|
264
|
+
*
|
|
265
|
+
* **Validates: Requirement 8.3**
|
|
266
|
+
*/
|
|
267
|
+
subscribeToUpdates(intentIds, callback, options) {
|
|
268
|
+
const interval = options?.interval ?? 2000;
|
|
269
|
+
const timeout = options?.timeout;
|
|
270
|
+
const startTime = Date.now();
|
|
271
|
+
// Track last known status for each intent
|
|
272
|
+
const lastStatuses = new Map();
|
|
273
|
+
let intervalId = null;
|
|
274
|
+
let stopped = false;
|
|
275
|
+
const poll = async () => {
|
|
276
|
+
if (stopped)
|
|
277
|
+
return;
|
|
278
|
+
// Check timeout
|
|
279
|
+
if (timeout && Date.now() - startTime > timeout) {
|
|
280
|
+
stopped = true;
|
|
281
|
+
if (intervalId)
|
|
282
|
+
clearInterval(intervalId);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
// Poll all intents in parallel
|
|
286
|
+
const promises = intentIds.map(async (intentId) => {
|
|
287
|
+
try {
|
|
288
|
+
const intent = await this.intentManager.get(intentId);
|
|
289
|
+
// Check if status changed
|
|
290
|
+
const lastStatus = lastStatuses.get(intentId);
|
|
291
|
+
if (lastStatus !== intent.status) {
|
|
292
|
+
lastStatuses.set(intentId, intent.status);
|
|
293
|
+
callback(intentId, intent);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
// Silently ignore errors in polling
|
|
298
|
+
// In a production implementation, might want to expose error callbacks
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
await Promise.allSettled(promises);
|
|
302
|
+
};
|
|
303
|
+
// Start polling
|
|
304
|
+
intervalId = setInterval(poll, interval);
|
|
305
|
+
// Do initial poll
|
|
306
|
+
poll().catch(() => {
|
|
307
|
+
// Ignore initial poll errors
|
|
308
|
+
});
|
|
309
|
+
return {
|
|
310
|
+
unsubscribe() {
|
|
311
|
+
stopped = true;
|
|
312
|
+
if (intervalId) {
|
|
313
|
+
clearInterval(intervalId);
|
|
314
|
+
intervalId = null;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
exports.AgentUtils = AgentUtils;
|
|
321
|
+
//# sourceMappingURL=agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agent.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAaH,6CAA6C;AAC7C,iDAAkD;AAClD,mDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,UAAU;IACJ,MAAM,CAAa;IACnB,aAAa,CAAgB;IAC7B,gBAAgB,CAAmB;IAEpD;;;;OAIG;IACH,YAAY,MAAkB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,IAAI,0BAAa,CAAC,MAAM,CAAC,CAAC;QAC/C,IAAI,CAAC,gBAAgB,GAAG,IAAI,+BAAgB,CAAC,MAAM,CAAC,CAAC;IACvD,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACH,KAAK,CAAC,WAAW,CACf,OAA2D;QAE3D,0DAA0D;QAC1D,+EAA+E;QAC/E,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE;YAC3D,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACtD,CAAC,CAAC,CAAC;QAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CA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C;QAEzC,kBAAkB;QAClB,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,6BAA6B;QAC/B,CAAC,CAAC,CAAC;QAEH,OAAO;YACL,WAAW;gBACT,OAAO,GAAG,IAAI,CAAC;gBACf,IAAI,UAAU,EAAE,CAAC;oBACf,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,UAAU,GAAG,IAAI,CAAC;gBACpB,CAAC;YACH,CAAC;SACF,CAAC;IACJ,CAAC;CACF;AAlTD,gCAkTC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cache = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Simple in-memory cache with TTL support
|
|
6
|
+
*/
|
|
7
|
+
class Cache {
|
|
8
|
+
store = new Map();
|
|
9
|
+
defaultTTL;
|
|
10
|
+
constructor(defaultTTL = 60000) {
|
|
11
|
+
this.defaultTTL = defaultTTL;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get value from cache if not expired
|
|
15
|
+
*/
|
|
16
|
+
get(key) {
|
|
17
|
+
const entry = this.store.get(key);
|
|
18
|
+
if (!entry) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
// Check if expired
|
|
22
|
+
if (Date.now() > entry.expiresAt) {
|
|
23
|
+
this.store.delete(key);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return entry.value;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Set value in cache with TTL
|
|
30
|
+
*/
|
|
31
|
+
set(key, value, ttl) {
|
|
32
|
+
const expiresAt = Date.now() + (ttl ?? this.defaultTTL);
|
|
33
|
+
this.store.set(key, { value, expiresAt });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Clear cache entries matching pattern
|
|
37
|
+
*/
|
|
38
|
+
clear(pattern) {
|
|
39
|
+
if (!pattern) {
|
|
40
|
+
this.store.clear();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const regex = new RegExp(pattern);
|
|
44
|
+
for (const key of this.store.keys()) {
|
|
45
|
+
if (regex.test(key)) {
|
|
46
|
+
this.store.delete(key);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Get cache size
|
|
52
|
+
*/
|
|
53
|
+
size() {
|
|
54
|
+
return this.store.size;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.Cache = Cache;
|
|
58
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../src/cache.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,KAAK;IACR,KAAK,GAA4B,IAAI,GAAG,EAAE,CAAC;IAClC,UAAU,CAAS;IAEpC,YAAY,aAAqB,KAAK;QACpC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,GAAG,CAAI,GAAW;QAChB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAElC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,IAAI,CAAC;QACd,CAAC;QAED,mBAAmB;QACnB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACvB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,KAAK,CAAC,KAAU,CAAC;IAC1B,CAAC;IAED;;OAEG;IACH,GAAG,CAAI,GAAW,EAAE,KAAQ,EAAE,GAAY;QACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,OAAgB;QACpB,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,OAAO;QACT,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;YACpC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;gBACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AA1DD,sBA0DC"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JackClient = void 0;
|
|
4
|
+
const errors_js_1 = require("./errors.js");
|
|
5
|
+
const cache_js_1 = require("./cache.js");
|
|
6
|
+
/**
|
|
7
|
+
* Core HTTP client for JACK API with retry logic, timeout handling, and caching
|
|
8
|
+
*/
|
|
9
|
+
class JackClient {
|
|
10
|
+
config;
|
|
11
|
+
cache;
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.validateConfig(config);
|
|
14
|
+
this.config = {
|
|
15
|
+
baseUrl: config.baseUrl,
|
|
16
|
+
timeout: config.timeout ?? 30000,
|
|
17
|
+
maxRetries: config.maxRetries ?? 3,
|
|
18
|
+
retryDelay: config.retryDelay ?? 1000,
|
|
19
|
+
retryBackoff: config.retryBackoff ?? 2,
|
|
20
|
+
enableCache: config.enableCache ?? true,
|
|
21
|
+
cacheTTL: config.cacheTTL ?? 60000,
|
|
22
|
+
headers: config.headers ?? {},
|
|
23
|
+
};
|
|
24
|
+
this.cache = new cache_js_1.Cache(this.config.cacheTTL);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Validate client configuration
|
|
28
|
+
*/
|
|
29
|
+
validateConfig(config) {
|
|
30
|
+
const errors = [];
|
|
31
|
+
if (!config.baseUrl || config.baseUrl.trim() === '') {
|
|
32
|
+
errors.push('baseUrl is required and cannot be empty');
|
|
33
|
+
}
|
|
34
|
+
if (config.timeout !== undefined && config.timeout <= 0) {
|
|
35
|
+
errors.push('timeout must be positive');
|
|
36
|
+
}
|
|
37
|
+
if (config.maxRetries !== undefined && config.maxRetries < 0) {
|
|
38
|
+
errors.push('maxRetries cannot be negative');
|
|
39
|
+
}
|
|
40
|
+
if (config.retryDelay !== undefined && config.retryDelay < 0) {
|
|
41
|
+
errors.push('retryDelay cannot be negative');
|
|
42
|
+
}
|
|
43
|
+
if (config.retryBackoff !== undefined && config.retryBackoff < 1) {
|
|
44
|
+
errors.push('retryBackoff must be >= 1');
|
|
45
|
+
}
|
|
46
|
+
if (config.cacheTTL !== undefined && config.cacheTTL < 0) {
|
|
47
|
+
errors.push('cacheTTL cannot be negative');
|
|
48
|
+
}
|
|
49
|
+
if (errors.length > 0) {
|
|
50
|
+
throw new errors_js_1.ValidationError('Invalid client configuration', errors);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Perform GET request with caching support
|
|
55
|
+
*/
|
|
56
|
+
async get(path, options) {
|
|
57
|
+
const cacheKey = this.getCacheKey(path, options);
|
|
58
|
+
// Check cache if enabled
|
|
59
|
+
if (this.config.enableCache && !options?.skipCache) {
|
|
60
|
+
const cached = this.cache.get(cacheKey);
|
|
61
|
+
if (cached !== null) {
|
|
62
|
+
return cached;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// Execute request with retry
|
|
66
|
+
const result = await this.executeWithRetry(() => this.executeRequest('GET', path, undefined, options));
|
|
67
|
+
// Cache successful GET responses
|
|
68
|
+
if (this.config.enableCache && !options?.skipCache) {
|
|
69
|
+
this.cache.set(cacheKey, result);
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Perform POST request (never cached)
|
|
75
|
+
*/
|
|
76
|
+
async post(path, body, options) {
|
|
77
|
+
return this.executeWithRetry(() => this.executeRequest('POST', path, body, options));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Clear cache entries matching pattern
|
|
81
|
+
*/
|
|
82
|
+
clearCache(pattern) {
|
|
83
|
+
this.cache.clear(pattern);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Generate cache key from URL and options
|
|
87
|
+
*/
|
|
88
|
+
getCacheKey(path, options) {
|
|
89
|
+
const params = options?.params ? JSON.stringify(options.params) : '';
|
|
90
|
+
return `${path}${params}`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Execute HTTP request with timeout
|
|
94
|
+
*/
|
|
95
|
+
async executeRequest(method, path, body, options) {
|
|
96
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
97
|
+
const timeout = options?.timeout ?? this.config.timeout;
|
|
98
|
+
// Create abort controller for timeout
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
101
|
+
try {
|
|
102
|
+
const headers = {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
...this.config.headers,
|
|
105
|
+
...options?.headers,
|
|
106
|
+
};
|
|
107
|
+
const response = await fetch(url, {
|
|
108
|
+
method,
|
|
109
|
+
headers,
|
|
110
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
111
|
+
signal: controller.signal,
|
|
112
|
+
});
|
|
113
|
+
clearTimeout(timeoutId);
|
|
114
|
+
if (!response.ok) {
|
|
115
|
+
const errorBody = await response.text();
|
|
116
|
+
let errorMessage;
|
|
117
|
+
try {
|
|
118
|
+
const errorJson = JSON.parse(errorBody);
|
|
119
|
+
errorMessage = errorJson.message || errorJson.error || response.statusText;
|
|
120
|
+
}
|
|
121
|
+
catch {
|
|
122
|
+
errorMessage = errorBody || response.statusText;
|
|
123
|
+
}
|
|
124
|
+
throw new errors_js_1.APIError(errorMessage, response.status, errorBody);
|
|
125
|
+
}
|
|
126
|
+
const data = await response.json();
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
clearTimeout(timeoutId);
|
|
131
|
+
if (error instanceof errors_js_1.APIError) {
|
|
132
|
+
throw error;
|
|
133
|
+
}
|
|
134
|
+
if (error instanceof Error) {
|
|
135
|
+
if (error.name === 'AbortError') {
|
|
136
|
+
throw new errors_js_1.TimeoutError(`Request timed out after ${timeout}ms`, timeout);
|
|
137
|
+
}
|
|
138
|
+
throw new errors_js_1.NetworkError(`Network request failed: ${error.message}`, error);
|
|
139
|
+
}
|
|
140
|
+
throw new errors_js_1.NetworkError('Unknown network error', new Error(String(error)));
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Execute function with retry logic and exponential backoff
|
|
145
|
+
*/
|
|
146
|
+
async executeWithRetry(fn) {
|
|
147
|
+
let lastError = null;
|
|
148
|
+
let delay = this.config.retryDelay;
|
|
149
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
150
|
+
try {
|
|
151
|
+
return await fn();
|
|
152
|
+
}
|
|
153
|
+
catch (error) {
|
|
154
|
+
lastError = error;
|
|
155
|
+
// Don't retry on non-retryable errors - throw immediately
|
|
156
|
+
if (error instanceof errors_js_1.APIError && !this.isRetryable(error)) {
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
if (error instanceof errors_js_1.ValidationError) {
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
if (error instanceof errors_js_1.TimeoutError) {
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
// Don't retry if we've exhausted attempts
|
|
166
|
+
if (attempt === this.config.maxRetries) {
|
|
167
|
+
// If maxRetries is 0, throw the original error, not RetryError
|
|
168
|
+
if (this.config.maxRetries === 0) {
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
// Wait before retrying
|
|
174
|
+
await this.sleep(delay);
|
|
175
|
+
delay *= this.config.retryBackoff;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// All retries exhausted
|
|
179
|
+
throw new errors_js_1.RetryError(`Request failed after ${this.config.maxRetries + 1} attempts`, this.config.maxRetries + 1, lastError);
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Check if error is retryable
|
|
183
|
+
*/
|
|
184
|
+
isRetryable(error) {
|
|
185
|
+
// Retry on 5xx server errors and 429 rate limit
|
|
186
|
+
return error.statusCode >= 500 || error.statusCode === 429;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Sleep for specified milliseconds
|
|
190
|
+
*/
|
|
191
|
+
sleep(ms) {
|
|
192
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.JackClient = JackClient;
|
|
196
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AAAA,2CAAgG;AAEhG,yCAAmC;AAEnC;;GAEG;AACH,MAAa,UAAU;IACJ,MAAM,CAAyB;IAC/B,KAAK,CAAQ;IAE9B,YAAY,MAAoB;QAC9B,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAE5B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,UAAU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