@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,302 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core TypeScript types for the JACK SDK
|
|
3
|
+
*
|
|
4
|
+
* This module exports all interfaces, types, and enums used in the public API.
|
|
5
|
+
* Requirements: 1.5, 3.4, 4.3, 5.1
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Parameters required to create an intent
|
|
9
|
+
* Requirement 1.5
|
|
10
|
+
*/
|
|
11
|
+
export interface IntentParams {
|
|
12
|
+
/** Source blockchain identifier (e.g., 'arbitrum', 'ethereum') */
|
|
13
|
+
sourceChain: string;
|
|
14
|
+
/** Destination blockchain identifier (e.g., 'base', 'optimism') */
|
|
15
|
+
destinationChain: string;
|
|
16
|
+
/** Address of the input token on the source chain */
|
|
17
|
+
tokenIn: string;
|
|
18
|
+
/** Address of the output token on the destination chain */
|
|
19
|
+
tokenOut: string;
|
|
20
|
+
/** Amount of input token (in smallest unit, e.g., wei) */
|
|
21
|
+
amountIn: string;
|
|
22
|
+
/** Minimum acceptable amount of output token */
|
|
23
|
+
minAmountOut: string;
|
|
24
|
+
/** Unix timestamp (milliseconds) after which the intent expires */
|
|
25
|
+
deadline: number;
|
|
26
|
+
/** Allow additional properties for extensibility */
|
|
27
|
+
[key: string]: string | number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Execution status of an intent
|
|
31
|
+
* Requirement 1.5
|
|
32
|
+
*/
|
|
33
|
+
export declare enum ExecutionStatus {
|
|
34
|
+
/** Intent created but not yet quoted */
|
|
35
|
+
CREATED = "CREATED",
|
|
36
|
+
/** Solver quotes received */
|
|
37
|
+
QUOTED = "QUOTED",
|
|
38
|
+
/** Intent is being executed */
|
|
39
|
+
EXECUTING = "EXECUTING",
|
|
40
|
+
/** Settlement transaction is being processed */
|
|
41
|
+
SETTLING = "SETTLING",
|
|
42
|
+
/** Intent successfully settled on-chain */
|
|
43
|
+
SETTLED = "SETTLED",
|
|
44
|
+
/** Intent execution was aborted */
|
|
45
|
+
ABORTED = "ABORTED",
|
|
46
|
+
/** Intent expired before completion */
|
|
47
|
+
EXPIRED = "EXPIRED"
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A discrete step in the intent execution lifecycle
|
|
51
|
+
* Requirement 1.5
|
|
52
|
+
*/
|
|
53
|
+
export interface ExecutionStep {
|
|
54
|
+
/** Name of the execution step (e.g., 'signing', 'quoting', 'routing') */
|
|
55
|
+
step: string;
|
|
56
|
+
/** Current status of this step */
|
|
57
|
+
status: 'COMPLETED' | 'IN_PROGRESS' | 'PENDING' | 'FAILED';
|
|
58
|
+
/** Unix timestamp (milliseconds) when this step was updated */
|
|
59
|
+
timestamp: number;
|
|
60
|
+
/** Optional additional details about the step */
|
|
61
|
+
details?: string;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Complete intent object with execution state
|
|
65
|
+
* Requirement 1.5
|
|
66
|
+
*/
|
|
67
|
+
export interface Intent {
|
|
68
|
+
/** Unique intent identifier (format: JK-[A-Z0-9]{9}) */
|
|
69
|
+
id: string;
|
|
70
|
+
/** Intent parameters */
|
|
71
|
+
params: IntentParams;
|
|
72
|
+
/** EIP-712 signature (if signed) */
|
|
73
|
+
signature?: string;
|
|
74
|
+
/** Current execution status */
|
|
75
|
+
status: ExecutionStatus;
|
|
76
|
+
/** Unix timestamp (milliseconds) when intent was created */
|
|
77
|
+
createdAt: number;
|
|
78
|
+
/** Array of execution steps with their statuses */
|
|
79
|
+
executionSteps: ExecutionStep[];
|
|
80
|
+
/** Settlement transaction hash (if settled) */
|
|
81
|
+
settlementTx?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A step in the execution route
|
|
85
|
+
* Requirement 3.4
|
|
86
|
+
*/
|
|
87
|
+
export interface RouteStep {
|
|
88
|
+
/** Blockchain where this step executes */
|
|
89
|
+
chain: string;
|
|
90
|
+
/** Protocol used for this step (e.g., 'uniswap', 'stargate') */
|
|
91
|
+
protocol: string;
|
|
92
|
+
/** Action performed (e.g., 'swap', 'bridge') */
|
|
93
|
+
action: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A solver's quote for executing an intent
|
|
97
|
+
* Requirement 3.4
|
|
98
|
+
*/
|
|
99
|
+
export interface Quote {
|
|
100
|
+
/** Unique identifier of the solver */
|
|
101
|
+
solverId: string;
|
|
102
|
+
/** Human-readable name of the solver */
|
|
103
|
+
solverName: string;
|
|
104
|
+
/** Total fee charged by the solver (in output token units) */
|
|
105
|
+
totalFee: string;
|
|
106
|
+
/** Estimated execution time in seconds */
|
|
107
|
+
estimatedTime: number;
|
|
108
|
+
/** Detailed execution route */
|
|
109
|
+
route: RouteStep[];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A single cost entry
|
|
113
|
+
* Requirement 4.3
|
|
114
|
+
*/
|
|
115
|
+
export interface CostEntry {
|
|
116
|
+
/** Cost amount */
|
|
117
|
+
cost: number;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Cost tracking for a specific issue
|
|
121
|
+
* Requirement 4.3
|
|
122
|
+
*/
|
|
123
|
+
export interface IssueCost {
|
|
124
|
+
/** Issue identifier */
|
|
125
|
+
issueId: string;
|
|
126
|
+
/** Total cost accumulated for this issue */
|
|
127
|
+
totalCost: number;
|
|
128
|
+
/** Budget allocated for this issue */
|
|
129
|
+
budget: number;
|
|
130
|
+
/** Whether the issue has exceeded its budget */
|
|
131
|
+
overBudget: boolean;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Response from the costs API endpoint
|
|
135
|
+
* Requirement 4.3
|
|
136
|
+
*/
|
|
137
|
+
export interface CostsResponse {
|
|
138
|
+
/** Array of cost data per issue */
|
|
139
|
+
issueCosts: IssueCost[];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Configuration options for the JACK SDK client
|
|
143
|
+
* Requirement 5.1
|
|
144
|
+
*/
|
|
145
|
+
export interface ClientConfig {
|
|
146
|
+
/** Base URL for the JACK API (e.g., 'https://api.jack.example') */
|
|
147
|
+
baseUrl: string;
|
|
148
|
+
/** Request timeout in milliseconds (default: 30000) */
|
|
149
|
+
timeout?: number;
|
|
150
|
+
/** Maximum number of retry attempts for failed requests (default: 3) */
|
|
151
|
+
maxRetries?: number;
|
|
152
|
+
/** Initial delay between retries in milliseconds (default: 1000) */
|
|
153
|
+
retryDelay?: number;
|
|
154
|
+
/** Backoff multiplier for exponential retry delay (default: 2) */
|
|
155
|
+
retryBackoff?: number;
|
|
156
|
+
/** Enable response caching for GET requests (default: false) */
|
|
157
|
+
enableCache?: boolean;
|
|
158
|
+
/** Cache time-to-live in milliseconds (default: 60000) */
|
|
159
|
+
cacheTTL?: number;
|
|
160
|
+
/** Custom HTTP headers to include in all requests */
|
|
161
|
+
headers?: Record<string, string>;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Options for individual HTTP requests
|
|
165
|
+
* Requirement 5.1
|
|
166
|
+
*/
|
|
167
|
+
export interface RequestOptions {
|
|
168
|
+
/** Override the default timeout for this request */
|
|
169
|
+
timeout?: number;
|
|
170
|
+
/** Disable retries for this request */
|
|
171
|
+
noRetry?: boolean;
|
|
172
|
+
/** Disable caching for this request */
|
|
173
|
+
noCache?: boolean;
|
|
174
|
+
/** Skip cache for this request (alias for noCache) */
|
|
175
|
+
skipCache?: boolean;
|
|
176
|
+
/** Query parameters for the request */
|
|
177
|
+
params?: Record<string, unknown>;
|
|
178
|
+
/** Additional headers for this request */
|
|
179
|
+
headers?: Record<string, string>;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Options for polling operations
|
|
183
|
+
* Requirement 5.1
|
|
184
|
+
*/
|
|
185
|
+
export interface PollOptions {
|
|
186
|
+
/** Polling interval in milliseconds (default: 2000) */
|
|
187
|
+
interval?: number;
|
|
188
|
+
/** Maximum time to poll in milliseconds (default: 60000) */
|
|
189
|
+
timeout?: number;
|
|
190
|
+
/** Stop polling when any of these statuses are reached */
|
|
191
|
+
stopStatuses?: ExecutionStatus[];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Result of a single intent submission in a batch operation
|
|
195
|
+
* Requirement 5.1
|
|
196
|
+
*/
|
|
197
|
+
export interface BatchSubmitResult {
|
|
198
|
+
/** Intent ID if submission succeeded */
|
|
199
|
+
intentId: string;
|
|
200
|
+
/** Whether the submission was successful */
|
|
201
|
+
success: boolean;
|
|
202
|
+
/** Error object if submission failed */
|
|
203
|
+
error?: Error;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Result of a dry-run validation
|
|
207
|
+
* Requirement 5.1
|
|
208
|
+
*/
|
|
209
|
+
export interface DryRunResult {
|
|
210
|
+
/** Whether the intent parameters are valid */
|
|
211
|
+
valid: boolean;
|
|
212
|
+
/** Estimated cost if validation succeeded */
|
|
213
|
+
estimatedCost?: string;
|
|
214
|
+
/** Array of validation error messages */
|
|
215
|
+
errors?: string[];
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Result of intent parameter validation
|
|
219
|
+
* Requirement 5.1
|
|
220
|
+
*/
|
|
221
|
+
export interface ValidationResult {
|
|
222
|
+
/** Whether validation passed */
|
|
223
|
+
valid: boolean;
|
|
224
|
+
/** Array of validation error messages */
|
|
225
|
+
errors: string[];
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* EIP-712 domain separator
|
|
229
|
+
* Requirement 5.1
|
|
230
|
+
*/
|
|
231
|
+
export interface EIP712Domain {
|
|
232
|
+
/** Protocol name */
|
|
233
|
+
name: string;
|
|
234
|
+
/** Protocol version */
|
|
235
|
+
version: string;
|
|
236
|
+
/** Chain ID where the contract is deployed */
|
|
237
|
+
chainId: number;
|
|
238
|
+
/** Address of the verifying contract */
|
|
239
|
+
verifyingContract: `0x${string}`;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Complete EIP-712 typed data structure
|
|
243
|
+
* Requirement 5.1
|
|
244
|
+
*/
|
|
245
|
+
export interface TypedData {
|
|
246
|
+
/** Domain separator */
|
|
247
|
+
domain: EIP712Domain;
|
|
248
|
+
/** Type definitions */
|
|
249
|
+
types: Record<string, Array<{
|
|
250
|
+
name: string;
|
|
251
|
+
type: string;
|
|
252
|
+
}>>;
|
|
253
|
+
/** Message data to be signed */
|
|
254
|
+
message: Record<string, unknown>;
|
|
255
|
+
/** Primary type being signed */
|
|
256
|
+
primaryType: string;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Subscription handle for event-based updates
|
|
260
|
+
* Requirement 5.1
|
|
261
|
+
*/
|
|
262
|
+
export interface Subscription {
|
|
263
|
+
/** Unsubscribe from updates and stop polling */
|
|
264
|
+
unsubscribe(): void;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Watcher for continuous intent status updates
|
|
268
|
+
* Requirement 5.1
|
|
269
|
+
*/
|
|
270
|
+
export interface ExecutionWatcher extends Subscription {
|
|
271
|
+
/** Intent ID being watched */
|
|
272
|
+
intentId: string;
|
|
273
|
+
/** Register callback for status updates */
|
|
274
|
+
onUpdate(callback: (intent: Intent) => void): void;
|
|
275
|
+
/** Register callback for errors */
|
|
276
|
+
onError(callback: (error: Error) => void): void;
|
|
277
|
+
/** Register callback for completion (SETTLED, ABORTED, or EXPIRED) */
|
|
278
|
+
onComplete(callback: (intent: Intent) => void): void;
|
|
279
|
+
/** Stop watching and clean up resources */
|
|
280
|
+
stop(): void;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Policy rules for intent validation
|
|
284
|
+
* Requirement 5.1
|
|
285
|
+
*/
|
|
286
|
+
export interface Policy {
|
|
287
|
+
/** Maximum allowed amount in (in smallest unit) */
|
|
288
|
+
maxAmountIn?: string;
|
|
289
|
+
/** Minimum allowed amount out (in smallest unit) */
|
|
290
|
+
minAmountOut?: string;
|
|
291
|
+
/** Allowed source chains */
|
|
292
|
+
allowedSourceChains?: string[];
|
|
293
|
+
/** Allowed destination chains */
|
|
294
|
+
allowedDestinationChains?: string[];
|
|
295
|
+
/** Allowed input tokens */
|
|
296
|
+
allowedTokensIn?: string[];
|
|
297
|
+
/** Allowed output tokens */
|
|
298
|
+
allowedTokensOut?: string[];
|
|
299
|
+
/** Maximum deadline offset in milliseconds */
|
|
300
|
+
maxDeadlineOffset?: number;
|
|
301
|
+
}
|
|
302
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,WAAW,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,gBAAgB,EAAE,MAAM,CAAC;IACzB,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,YAAY,EAAE,MAAM,CAAC;IACr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AAE,MAAM,EAAE,CAAC;IAC3B,4BAA4B;IAC5B,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,8CAA8C;IAC9C,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Input validation helpers for the JACK SDK
|
|
3
|
+
*
|
|
4
|
+
* This module provides validation functions for intent parameters and other inputs.
|
|
5
|
+
* Requirements: 5.4, 8.5
|
|
6
|
+
*/
|
|
7
|
+
import type { IntentParams, ValidationResult } from './types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Validates intent parameters before submission
|
|
10
|
+
*
|
|
11
|
+
* This function checks:
|
|
12
|
+
* - All required fields are present and non-empty
|
|
13
|
+
* - Amounts (amountIn, minAmountOut) are positive numbers
|
|
14
|
+
* - Deadline is in the future
|
|
15
|
+
* - Token addresses are valid Ethereum address format
|
|
16
|
+
*
|
|
17
|
+
* @param params - The intent parameters to validate
|
|
18
|
+
* @returns ValidationResult with valid flag and array of error messages
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const result = validateIntentParams({
|
|
23
|
+
* sourceChain: 'arbitrum',
|
|
24
|
+
* destinationChain: 'base',
|
|
25
|
+
* tokenIn: '0x...',
|
|
26
|
+
* tokenOut: '0x...',
|
|
27
|
+
* amountIn: '1000000',
|
|
28
|
+
* minAmountOut: '950000',
|
|
29
|
+
* deadline: Date.now() + 3600000
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* if (!result.valid) {
|
|
33
|
+
* console.error('Validation errors:', result.errors);
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* **Validates: Requirements 5.4, 8.5**
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateIntentParams(params: IntentParams): ValidationResult;
|
|
40
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AA0BjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,YAAY,GAAG,gBAAgB,CA8D3E"}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@jack-kernel/sdk",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript SDK for JACK cross-chain execution kernel",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/esm/index.js",
|
|
11
|
+
"require": "./dist/cjs/index.js",
|
|
12
|
+
"types": "./dist/types/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"README.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
20
|
+
"keywords": [
|
|
21
|
+
"jack",
|
|
22
|
+
"cross-chain",
|
|
23
|
+
"intent",
|
|
24
|
+
"blockchain",
|
|
25
|
+
"sdk"
|
|
26
|
+
],
|
|
27
|
+
"author": "JACK Team",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/your-org/jack.git",
|
|
32
|
+
"directory": "packages/sdk"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"viem": "^2.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@fast-check/vitest": "^0.2.4",
|
|
39
|
+
"@types/node": "^20.0.0",
|
|
40
|
+
"@vitest/coverage-v8": "^1.0.0",
|
|
41
|
+
"fast-check": "^3.23.2",
|
|
42
|
+
"msw": "^2.0.0",
|
|
43
|
+
"typescript": "^5.0.0",
|
|
44
|
+
"vitest": "^1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "pnpm run build:esm && pnpm run build:cjs && pnpm run build:types",
|
|
48
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
49
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
50
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:watch": "vitest",
|
|
53
|
+
"test:coverage": "vitest run --coverage",
|
|
54
|
+
"lint": "eslint src/**/*.ts"
|
|
55
|
+
}
|
|
56
|
+
}
|