@lgriffin/esi.ts 5.0.0 → 5.2.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/CHANGELOG.md +39 -0
- package/README.md +174 -7
- package/dist/EsiClient.d.ts +5 -0
- package/dist/EsiClient.d.ts.map +1 -1
- package/dist/EsiClient.js +13 -0
- package/dist/core/ApiClient.d.ts +4 -0
- package/dist/core/ApiClient.d.ts.map +1 -1
- package/dist/core/ApiClient.js +7 -0
- package/dist/core/ApiRequestHandler.d.ts +3 -1
- package/dist/core/ApiRequestHandler.d.ts.map +1 -1
- package/dist/core/ApiRequestHandler.js +107 -41
- package/dist/core/BatchRequestHandler.d.ts +12 -0
- package/dist/core/BatchRequestHandler.d.ts.map +1 -0
- package/dist/core/BatchRequestHandler.js +66 -0
- package/dist/core/constants.d.ts +2 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/endpoints/createClient.d.ts.map +1 -1
- package/dist/core/endpoints/createClient.js +14 -2
- package/dist/core/endpoints/esi-cache-ttls.generated.d.ts +2 -0
- package/dist/core/endpoints/esi-cache-ttls.generated.d.ts.map +1 -0
- package/dist/core/endpoints/esi-cache-ttls.generated.js +126 -0
- package/dist/core/endpoints/esi-rate-limit-groups.generated.d.ts +7 -0
- package/dist/core/endpoints/esi-rate-limit-groups.generated.d.ts.map +1 -0
- package/dist/core/endpoints/esi-rate-limit-groups.generated.js +153 -0
- package/dist/core/pagination/PaginationHandler.d.ts +1 -1
- package/dist/core/pagination/PaginationHandler.d.ts.map +1 -1
- package/dist/core/pagination/PaginationHandler.js +2 -2
- package/dist/core/rateLimiter/IRateLimiter.d.ts +13 -3
- package/dist/core/rateLimiter/IRateLimiter.d.ts.map +1 -1
- package/dist/core/rateLimiter/RateLimiter.d.ts +24 -51
- package/dist/core/rateLimiter/RateLimiter.d.ts.map +1 -1
- package/dist/core/rateLimiter/RateLimiter.js +213 -109
- package/dist/core/util/error.d.ts +5 -1
- package/dist/core/util/error.d.ts.map +1 -1
- package/dist/core/util/error.js +11 -2
- package/dist/core/util/headersUtil.d.ts.map +1 -1
- package/dist/core/util/headersUtil.js +2 -1
- package/dist/core/util/retry.d.ts +8 -0
- package/dist/core/util/retry.d.ts.map +1 -0
- package/dist/core/util/retry.js +9 -0
- package/dist/core/util/stringUtil.d.ts +2 -0
- package/dist/core/util/stringUtil.d.ts.map +1 -0
- package/dist/core/util/stringUtil.js +6 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -2
- package/dist/types/api-responses.d.ts +1 -0
- package/dist/types/api-responses.d.ts.map +1 -1
- package/dist/types/api-responses.js +24 -0
- package/dist/types/common.d.ts +9 -0
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/generated/esi-spec.generated.d.ts +1763 -0
- package/dist/types/generated/esi-spec.generated.d.ts.map +1 -0
- package/dist/types/generated/esi-spec.generated.js +6 -0
- package/package.json +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,45 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.2.0] - 2026-06-29
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Spec-driven type generation** from ESI swagger spec (`npm run generate:types`) — 147 TypeScript interfaces + cache TTL map for 119 endpoints
|
|
15
|
+
- **Spec-aware cache bypass** — GET requests within ESI-specified `x-cached-seconds` TTL return cached data with zero HTTP calls, layered on top of ETag caching
|
|
16
|
+
- **`batch()` and `batchPost()` methods** on `EsiClient` — bounded concurrency for multi-ID fetches, auto-chunking for POST endpoints
|
|
17
|
+
- **`EsiSpec` namespace export** with generated response types alongside hand-written types
|
|
18
|
+
- **Type drift detection** in `npm run validate:esi` — compares hand-written types against generated spec types
|
|
19
|
+
- CI step to verify generated types are up to date
|
|
20
|
+
- **Retry with exponential backoff** — configurable retry for transient 5xx, timeout, and rate limit errors with jitter; respects circuit breaker state; GET-only by default with `retryMutations` opt-in
|
|
21
|
+
- **`TimeoutError`** subclass of `EsiError` — typed timeout errors with `timeoutMs` property; per-request timeout override via `handleRequest()`
|
|
22
|
+
- **Enhanced response metadata** via `withMetadata()` — rate limit info (`RateLimitMeta`), response timing (`responseTimeMs`), and cache hit type (`cacheHitType`: `'spec-ttl'` | `'etag-304'` | `'stale-on-error'`)
|
|
23
|
+
- `RetryConfig` interface and `retryConfig` option on `EsiClientConfig`
|
|
24
|
+
- `CircuitOpenError` passthrough in request handler (previously wrapped as generic Error)
|
|
25
|
+
- **Per-group rate limiting** — 36 ESI rate limit groups extracted from the OpenAPI meta spec at build time; each group gets its own token bucket instead of a single global counter, preventing a burst of market requests from starving unrelated endpoints
|
|
26
|
+
- **Optional per-user bucketing** — `userKeyExtractor` config option creates separate bucket sets per user key, supporting multi-character EVE applications
|
|
27
|
+
- **Group-aware rate limit status** — `getGroupStatus(group)` and `getAllGroupStatuses()` methods for fine-grained rate limit monitoring; `isBlocked(group?)` accepts an optional group name
|
|
28
|
+
- Generated `esi-rate-limit-groups.generated.ts` with 146 endpoint-to-group mappings
|
|
29
|
+
- Exported `RateLimitGroupStatus` and `RateLimitGroupSpec` types
|
|
30
|
+
|
|
31
|
+
## [5.1.0] - 2026-06-26
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- **`noUncheckedIndexedAccess`** compiler flag — array/record indexing now returns `T | undefined`, catching unguarded index access at compile time
|
|
36
|
+
- **`noImplicitReturns`** compiler flag — all function code paths must explicitly return a value
|
|
37
|
+
- **`noImplicitOverride`** compiler flag — `override` keyword required when overriding base class methods
|
|
38
|
+
- **`tsconfig.test.json`** — separate TypeScript config for tests, relaxing `noUncheckedIndexedAccess` for test utility patterns
|
|
39
|
+
|
|
40
|
+
### Changed
|
|
41
|
+
|
|
42
|
+
- `RateLimiter` token cost lookup inlined (removed unnecessary `Record` indirection)
|
|
43
|
+
- Jest configs (`jest.unit.config.cjs`, `jest.integration.config.cjs`) now use `tsconfig.test.json`
|
|
44
|
+
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Unguarded indexed access in `ApiRequestHandler`, `CircuitBreaker`, `RateLimiter`, and `headersUtil`
|
|
48
|
+
|
|
10
49
|
## [5.0.0] - 2026-06-26
|
|
11
50
|
|
|
12
51
|
### Breaking Changes
|
package/README.md
CHANGED
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
A type-safe TypeScript client for the [EVE Online ESI API](https://esi.evetech.net/).
|
|
12
12
|
|
|
13
13
|
- Typed responses for all endpoints
|
|
14
|
+
- Spec-driven type generation from ESI swagger spec (147 interfaces)
|
|
14
15
|
- ETag caching with Cache-Control TTL, stale-on-error, and write invalidation
|
|
16
|
+
- Spec-aware cache TTLs — zero-request cache hits within ESI-specified windows
|
|
17
|
+
- Batch requests with bounded concurrency and auto-chunking
|
|
15
18
|
- Automatic offset-based pagination and cursor-based pagination support
|
|
16
19
|
- Rate limiting with header-driven backoff
|
|
17
20
|
- Automatic token refresh with 401 retry and concurrent coalescing
|
|
@@ -75,7 +78,12 @@ const client = new EsiClient({
|
|
|
75
78
|
baseUrl: 'https://esi.evetech.net', // ESI base URL (default)
|
|
76
79
|
onTokenRefresh: async () => newToken, // Auto-refresh on 401 (optional)
|
|
77
80
|
timeout: 30000, // Request timeout in ms (default: 30000)
|
|
78
|
-
|
|
81
|
+
retryConfig: {
|
|
82
|
+
maxRetries: 3, // Max retry attempts for transient errors (default: 0)
|
|
83
|
+
baseDelayMs: 1000, // Initial backoff delay (default: 1000)
|
|
84
|
+
maxDelayMs: 30000, // Maximum backoff delay (default: 30000)
|
|
85
|
+
retryMutations: false, // Retry POST/PUT/DELETE (default: false, GET only)
|
|
86
|
+
},
|
|
79
87
|
enableETagCache: true, // ETag caching (default: true)
|
|
80
88
|
etagCacheConfig: {
|
|
81
89
|
maxEntries: 1000, // Max cached responses (default: 1000)
|
|
@@ -85,6 +93,8 @@ const client = new EsiClient({
|
|
|
85
93
|
});
|
|
86
94
|
```
|
|
87
95
|
|
|
96
|
+
Retry is disabled by default (`maxRetries: 0`). When enabled, transient errors (502, 503, 504, timeout, rate limit) are retried with exponential backoff and jitter. The circuit breaker is respected — requests are not retried when the circuit is open.
|
|
97
|
+
|
|
88
98
|
The access token can be updated at runtime:
|
|
89
99
|
|
|
90
100
|
```typescript
|
|
@@ -257,6 +267,86 @@ client.updateCacheConfig({ maxEntries: 2000 });
|
|
|
257
267
|
const uncachedClient = new EsiClient({ enableETagCache: false });
|
|
258
268
|
```
|
|
259
269
|
|
|
270
|
+
### Spec-Aware Cache TTLs
|
|
271
|
+
|
|
272
|
+
The library reads `x-cached-seconds` from the ESI swagger spec (119 of 195 endpoints). Within the TTL window, repeated GET requests return cached data with **zero HTTP calls** — not even a conditional GET.
|
|
273
|
+
|
|
274
|
+
This layers on top of ETag caching in three tiers:
|
|
275
|
+
|
|
276
|
+
1. **Spec TTL** — data can't have changed yet, return cached data immediately
|
|
277
|
+
2. **ETag conditional GET** — data might have changed, send `If-None-Match` to check
|
|
278
|
+
3. **Full request** — no cache entry, fetch fresh data
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const client = new EsiClient();
|
|
282
|
+
|
|
283
|
+
// First call — fetches from ESI
|
|
284
|
+
const alliances = await client.alliance.getAlliances();
|
|
285
|
+
|
|
286
|
+
// Second call within the next 3600s — returns cached data, zero HTTP calls
|
|
287
|
+
const same = await client.alliance.getAlliances();
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Batch Requests
|
|
291
|
+
|
|
292
|
+
Fetch data for multiple IDs with bounded concurrency using `batch()`, or chunk large POST payloads with `batchPost()`:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { EsiClient } from '@lgriffin/esi.ts';
|
|
296
|
+
|
|
297
|
+
const client = new EsiClient();
|
|
298
|
+
|
|
299
|
+
// Fetch 500 type details with at most 10 concurrent requests
|
|
300
|
+
const result = await client.batch(
|
|
301
|
+
typeIds,
|
|
302
|
+
(id) => client.universe.getTypeById(id),
|
|
303
|
+
{
|
|
304
|
+
concurrency: 10,
|
|
305
|
+
onProgress: (done, total) => console.log(`${done}/${total}`),
|
|
306
|
+
},
|
|
307
|
+
);
|
|
308
|
+
|
|
309
|
+
// result.results: Map<number, T> — successful responses
|
|
310
|
+
// result.errors: Map<number, Error> — failed requests
|
|
311
|
+
console.log(`${result.results.size} succeeded, ${result.errors.size} failed`);
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
For POST endpoints that accept arrays (e.g., `postUniverseNames` with a 1000-ID limit), `batchPost` auto-chunks and concatenates:
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
const allNames = await client.batchPost(
|
|
318
|
+
largeIdArray,
|
|
319
|
+
(chunk) => client.universe.postUniverseNames(chunk),
|
|
320
|
+
1000, // chunk size
|
|
321
|
+
);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
## Generated Types
|
|
325
|
+
|
|
326
|
+
The library includes TypeScript interfaces generated directly from the ESI swagger spec, available as the `EsiSpec` namespace. These are guaranteed to match the live spec and complement the hand-written types:
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
import { EsiSpec } from '@lgriffin/esi.ts';
|
|
330
|
+
|
|
331
|
+
// Generated type — exact spec field names and optionality
|
|
332
|
+
const order: EsiSpec.GetMarketsRegionIdOrders200Ok = {
|
|
333
|
+
order_id: 123,
|
|
334
|
+
type_id: 34,
|
|
335
|
+
price: 5.5,
|
|
336
|
+
volume_remain: 1000,
|
|
337
|
+
volume_total: 5000,
|
|
338
|
+
is_buy_order: false,
|
|
339
|
+
// ...
|
|
340
|
+
};
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
To regenerate types from the latest ESI spec:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
npm run generate:types # fetches spec, generates 147 interfaces + cache TTL map + rate limit groups
|
|
347
|
+
npm run validate:esi # reports type drift between hand-written and generated types
|
|
348
|
+
```
|
|
349
|
+
|
|
260
350
|
## Cursor-based Pagination
|
|
261
351
|
|
|
262
352
|
Newer ESI routes (Freelance Jobs, and future routes) use cursor-based pagination with opaque `before`/`after` tokens in the response body. See the [ESI blog post](https://developers.eveonline.com/blog/changing-pagination-turning-a-new-page) for background.
|
|
@@ -321,17 +411,22 @@ Key points:
|
|
|
321
411
|
API errors throw `EsiError` with `statusCode`, `message`, and `url` properties:
|
|
322
412
|
|
|
323
413
|
```typescript
|
|
324
|
-
import {
|
|
414
|
+
import {
|
|
415
|
+
EsiError,
|
|
416
|
+
TimeoutError,
|
|
417
|
+
isTimeout,
|
|
418
|
+
isRetryable,
|
|
419
|
+
} from '@lgriffin/esi.ts';
|
|
325
420
|
|
|
326
421
|
try {
|
|
327
422
|
const alliance = await client.alliance.getAllianceById(99999999);
|
|
328
423
|
console.log('Alliance:', alliance.name);
|
|
329
424
|
} catch (err) {
|
|
330
|
-
if (err
|
|
425
|
+
if (isTimeout(err)) {
|
|
426
|
+
console.log(`Request timed out after ${err.timeoutMs}ms`);
|
|
427
|
+
} else if (err instanceof EsiError) {
|
|
331
428
|
console.log(`ESI error ${err.statusCode}: ${err.message}`);
|
|
332
|
-
|
|
333
|
-
} else {
|
|
334
|
-
console.error('Network or parse error:', err);
|
|
429
|
+
console.log(`Retryable: ${err.retryable}`);
|
|
335
430
|
}
|
|
336
431
|
}
|
|
337
432
|
```
|
|
@@ -340,6 +435,76 @@ try {
|
|
|
340
435
|
- **304 Not Modified** — handled internally, returns cached data
|
|
341
436
|
- **4xx/5xx** — throws `EsiError`
|
|
342
437
|
- **5xx with cache** — returns stale cached data instead of throwing
|
|
438
|
+
- **Timeout** — throws `TimeoutError` (extends `EsiError` with `statusCode: 0` and `timeoutMs`)
|
|
439
|
+
- **Retryable errors** — `EsiError.retryable` returns `true` for 502, 503, 504, 420, 429, and timeouts
|
|
440
|
+
|
|
441
|
+
## Response Metadata
|
|
442
|
+
|
|
443
|
+
Use `withMetadata()` to get response headers, cache status, rate limit info, and timing alongside the data:
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
const metaClient = client.alliance.withMetadata();
|
|
447
|
+
const result = await metaClient.getAllianceById(99000001);
|
|
448
|
+
|
|
449
|
+
console.log(result.data.name); // "Goonswarm Federation"
|
|
450
|
+
console.log(result.meta.fromCache); // true if served from cache
|
|
451
|
+
console.log(result.meta.cacheHitType); // 'spec-ttl' | 'etag-304' | 'stale-on-error'
|
|
452
|
+
console.log(result.meta.responseTimeMs); // milliseconds
|
|
453
|
+
console.log(result.meta.rateLimit); // { remaining, limit, used, group }
|
|
454
|
+
console.log(result.meta.requestId); // ESI request ID for debugging
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
The `meta` object includes:
|
|
458
|
+
|
|
459
|
+
| Field | Type | Description |
|
|
460
|
+
| ---------------- | ------------------------ | ------------------------------------------------- |
|
|
461
|
+
| `headers` | `Record<string, string>` | Raw response headers |
|
|
462
|
+
| `fromCache` | `boolean` | Whether data was served from cache |
|
|
463
|
+
| `stale` | `boolean` | Whether cached data is stale (5xx fallback) |
|
|
464
|
+
| `cacheHitType` | `string?` | `'spec-ttl'`, `'etag-304'`, or `'stale-on-error'` |
|
|
465
|
+
| `rateLimit` | `RateLimitMeta?` | Rate limit status from ESI headers |
|
|
466
|
+
| `responseTimeMs` | `number?` | Request duration in milliseconds |
|
|
467
|
+
| `requestId` | `string?` | ESI request ID |
|
|
468
|
+
| `warning` | `object?` | ESI deprecation warning |
|
|
469
|
+
|
|
470
|
+
## Rate Limiting
|
|
471
|
+
|
|
472
|
+
ESI.ts automatically manages rate limiting using ESI's per-group token bucket system. The 36 rate limit groups from the ESI OpenAPI spec are extracted at build time, so each group (e.g., `market-order`, `char-notification`) gets its own independent bucket. A burst of market requests won't starve unrelated endpoints.
|
|
473
|
+
|
|
474
|
+
Rate limiting works out of the box with no configuration. For multi-character applications, enable per-user bucketing:
|
|
475
|
+
|
|
476
|
+
```typescript
|
|
477
|
+
import { EsiClient } from '@lgriffin/esi.ts';
|
|
478
|
+
|
|
479
|
+
const client = new EsiClient({
|
|
480
|
+
rateLimiterConfig: {
|
|
481
|
+
userKeyExtractor: (headers) => headers['authorization'] ?? 'anon',
|
|
482
|
+
},
|
|
483
|
+
});
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Monitor rate limit status per group:
|
|
487
|
+
|
|
488
|
+
```typescript
|
|
489
|
+
const limiter = client.getRateLimiter();
|
|
490
|
+
|
|
491
|
+
// Worst-case across all groups (backward-compatible)
|
|
492
|
+
const status = limiter.getStatus();
|
|
493
|
+
console.log(status.remaining, status.limit, status.group);
|
|
494
|
+
|
|
495
|
+
// Specific group
|
|
496
|
+
const marketStatus = limiter.getGroupStatus('market-order');
|
|
497
|
+
console.log(marketStatus?.remaining); // tokens remaining in this group
|
|
498
|
+
|
|
499
|
+
// All active groups
|
|
500
|
+
const all = limiter.getAllGroupStatuses();
|
|
501
|
+
for (const [group, info] of all) {
|
|
502
|
+
console.log(`${group}: ${info.remaining}/${info.limit}`);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
// Check if a specific group is blocked
|
|
506
|
+
console.log(limiter.isBlocked('char-notification')); // true if 429'd
|
|
507
|
+
```
|
|
343
508
|
|
|
344
509
|
## Lightweight Clients
|
|
345
510
|
|
|
@@ -492,6 +657,7 @@ npm run bdd # BDD scenario tests
|
|
|
492
657
|
npm run knip # Detect dead code and unused exports
|
|
493
658
|
npm run validate:esi # Validate endpoints against live ESI swagger spec
|
|
494
659
|
npm run validate # Run all checks: lint, format, build, coverage, knip
|
|
660
|
+
npm run generate:types # Regenerate TypeScript interfaces from ESI swagger spec
|
|
495
661
|
|
|
496
662
|
# Documentation
|
|
497
663
|
npm run docs # Generate TypeDoc API documentation
|
|
@@ -523,6 +689,7 @@ Every pull request runs the full validation suite:
|
|
|
523
689
|
- ESLint (with security and sonarjs plugins)
|
|
524
690
|
- Prettier formatting check
|
|
525
691
|
- TypeScript compilation
|
|
692
|
+
- Generated types staleness check (regenerates from live ESI spec and verifies no diff)
|
|
526
693
|
- Unit tests across Node.js 18, 20, and 22
|
|
527
694
|
- BDD scenario tests
|
|
528
695
|
- Coverage threshold enforcement (branches: 50%, functions: 50%, lines: 65%, statements: 65%)
|
|
@@ -534,7 +701,7 @@ See [.github/workflows/README.md](.github/workflows/README.md) for full workflow
|
|
|
534
701
|
## Testing
|
|
535
702
|
|
|
536
703
|
```bash
|
|
537
|
-
npm test # Unit +
|
|
704
|
+
npm test # Unit + BDD tests (108 suites, 2836 tests)
|
|
538
705
|
npm run coverage # Tests with coverage report (thresholds enforced)
|
|
539
706
|
npm run bdd # BDD scenario tests only
|
|
540
707
|
```
|
package/dist/EsiClient.d.ts
CHANGED
|
@@ -38,7 +38,9 @@ import { AccessListsClient } from './clients/AccessListsClient';
|
|
|
38
38
|
import { ETagCacheConfig } from './core/cache/ETagCacheManager';
|
|
39
39
|
import { CircuitBreakerConfig } from './core/circuitBreaker/CircuitBreaker';
|
|
40
40
|
import { RateLimiterConfig } from './core/rateLimiter/RateLimiter';
|
|
41
|
+
import { RetryConfig } from './core/util/retry';
|
|
41
42
|
import { EsiDiagnostics } from './core/EsiDiagnostics';
|
|
43
|
+
import { BatchOptions, BatchResult } from './core/BatchRequestHandler';
|
|
42
44
|
export type EsiDatasource = 'tranquility' | 'singularity';
|
|
43
45
|
export interface EsiClientConfig {
|
|
44
46
|
clientId?: string;
|
|
@@ -48,6 +50,7 @@ export interface EsiClientConfig {
|
|
|
48
50
|
onTokenRefresh?: TokenProvider;
|
|
49
51
|
timeout?: number;
|
|
50
52
|
retryAttempts?: number;
|
|
53
|
+
retryConfig?: RetryConfig;
|
|
51
54
|
enableETagCache?: boolean;
|
|
52
55
|
etagCacheConfig?: ETagCacheConfig;
|
|
53
56
|
enableCircuitBreaker?: boolean;
|
|
@@ -111,6 +114,8 @@ export declare class EsiClient {
|
|
|
111
114
|
updateCacheConfig(newConfig: Partial<ETagCacheConfig>): void;
|
|
112
115
|
getCircuitBreakerStats(): import(".").CircuitBreakerStats | null;
|
|
113
116
|
resetCircuitBreaker(endpoint?: string): void;
|
|
117
|
+
batch<K, T>(keys: K[], fetcher: (key: K) => Promise<T>, options?: BatchOptions): Promise<BatchResult<K, T>>;
|
|
118
|
+
batchPost<T>(ids: number[], poster: (chunk: number[]) => Promise<T[]>, chunkSize?: number): Promise<T[]>;
|
|
114
119
|
shutdown(): void;
|
|
115
120
|
}
|
|
116
121
|
export declare function getDefaultClient(): EsiClient;
|
package/dist/EsiClient.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EsiClient.d.ts","sourceRoot":"","sources":["../src/EsiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE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,QAAQ,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAO3D,IAAI,WAAW,IAAI,cAAc,CAShC;IAED,aAAa;IAIb,UAAU,IAAI,IAAI;IAIlB,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG,IAAI;IAI5D,sBAAsB;IAItB,mBAAmB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAItC,KAAK,CAAC,CAAC,EAAE,CAAC,EACd,IAAI,EAAE,CAAC,EAAE,EACT,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,EAC/B,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIvB,SAAS,CAAC,CAAC,EACf,GAAG,EAAE,MAAM,EAAE,EACb,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,EACzC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,EAAE,CAAC;IAIf,QAAQ,IAAI,IAAI;CAejB;AAGD,wBAAgB,gBAAgB,IAAI,SAAS,CAK5C"}
|
package/dist/EsiClient.js
CHANGED
|
@@ -13,6 +13,7 @@ const CircuitBreaker_1 = require("./core/circuitBreaker/CircuitBreaker");
|
|
|
13
13
|
const RateLimiter_1 = require("./core/rateLimiter/RateLimiter");
|
|
14
14
|
const RequestDeduplicator_1 = require("./core/RequestDeduplicator");
|
|
15
15
|
const EsiDiagnostics_1 = require("./core/EsiDiagnostics");
|
|
16
|
+
const BatchRequestHandler_1 = require("./core/BatchRequestHandler");
|
|
16
17
|
const logger_1 = __importDefault(require("./core/logger/logger"));
|
|
17
18
|
class EsiClient {
|
|
18
19
|
apiClient;
|
|
@@ -47,6 +48,12 @@ class EsiClient {
|
|
|
47
48
|
if (config?.enableCircuitBreaker) {
|
|
48
49
|
this.apiClient.setCircuitBreaker(new CircuitBreaker_1.CircuitBreaker(config.circuitBreakerConfig));
|
|
49
50
|
}
|
|
51
|
+
if (config?.retryConfig) {
|
|
52
|
+
this.apiClient.setRetryConfig(config.retryConfig);
|
|
53
|
+
}
|
|
54
|
+
else if (config?.retryAttempts !== undefined) {
|
|
55
|
+
this.apiClient.setRetryConfig({ maxRetries: config.retryAttempts });
|
|
56
|
+
}
|
|
50
57
|
if (config?.requestInterceptors) {
|
|
51
58
|
for (const interceptor of config.requestInterceptors) {
|
|
52
59
|
this.apiClient.addRequestInterceptor(interceptor);
|
|
@@ -206,6 +213,12 @@ class EsiClient {
|
|
|
206
213
|
resetCircuitBreaker(endpoint) {
|
|
207
214
|
this.diagnostics.resetCircuitBreaker(endpoint);
|
|
208
215
|
}
|
|
216
|
+
async batch(keys, fetcher, options) {
|
|
217
|
+
return (0, BatchRequestHandler_1.batchFetch)(keys, fetcher, options);
|
|
218
|
+
}
|
|
219
|
+
async batchPost(ids, poster, chunkSize) {
|
|
220
|
+
return (0, BatchRequestHandler_1.batchPost)(ids, poster, chunkSize);
|
|
221
|
+
}
|
|
209
222
|
shutdown() {
|
|
210
223
|
const cache = this.apiClient.getCache();
|
|
211
224
|
if (cache) {
|
package/dist/core/ApiClient.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { ICache } from './cache/ICache';
|
|
|
3
3
|
import { IRateLimiter } from './rateLimiter/IRateLimiter';
|
|
4
4
|
import { CircuitBreaker } from './circuitBreaker/CircuitBreaker';
|
|
5
5
|
import { RequestDeduplicator } from './RequestDeduplicator';
|
|
6
|
+
import { RetryConfig } from './util/retry';
|
|
6
7
|
export type EsiDatasource = 'tranquility' | 'singularity';
|
|
7
8
|
export type TokenProvider = () => Promise<string>;
|
|
8
9
|
export declare class ApiClient {
|
|
@@ -18,6 +19,7 @@ export declare class ApiClient {
|
|
|
18
19
|
private circuitBreaker;
|
|
19
20
|
private timeout;
|
|
20
21
|
private deduplicator;
|
|
22
|
+
private retryConfig;
|
|
21
23
|
constructor(clientId: string, link: string, accessToken?: string | undefined);
|
|
22
24
|
getTimeout(): number;
|
|
23
25
|
setTimeout(timeout: number): void;
|
|
@@ -29,6 +31,8 @@ export declare class ApiClient {
|
|
|
29
31
|
setCircuitBreaker(cb: CircuitBreaker | null): void;
|
|
30
32
|
getDeduplicator(): RequestDeduplicator | null;
|
|
31
33
|
setDeduplicator(dedup: RequestDeduplicator | null): void;
|
|
34
|
+
getRetryConfig(): RetryConfig | null;
|
|
35
|
+
setRetryConfig(config: RetryConfig | null): void;
|
|
32
36
|
getMiddleware(): MiddlewareManager;
|
|
33
37
|
addRequestInterceptor(fn: RequestInterceptor): () => void;
|
|
34
38
|
addResponseInterceptor(fn: ResponseInterceptor): () => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiClient.d.ts","sourceRoot":"","sources":["../../src/core/ApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiClient.d.ts","sourceRoot":"","sources":["../../src/core/ApiClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D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AE,WAAW,GAAG,IAAI,GAAG,IAAI;IAIhD,aAAa,IAAI,iBAAiB;IAIlC,qBAAqB,CAAC,EAAE,EAAE,kBAAkB,GAAG,MAAM,IAAI;IAIzD,sBAAsB,CAAC,EAAE,EAAE,mBAAmB,GAAG,MAAM,IAAI;IAI3D,sBAAsB,IAAI,MAAM,GAAG,SAAS;IAI5C,OAAO,IAAI,MAAM;IAIjB,aAAa,IAAI,aAAa,GAAG,SAAS;IAI1C,aAAa,CAAC,UAAU,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAI1D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAInC,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,SAAS,GAAG,IAAI;IAI3D,gBAAgB,IAAI,OAAO;IAIrB,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;CAuBtC"}
|
package/dist/core/ApiClient.js
CHANGED
|
@@ -15,6 +15,7 @@ class ApiClient {
|
|
|
15
15
|
circuitBreaker = null;
|
|
16
16
|
timeout = 30_000;
|
|
17
17
|
deduplicator = null;
|
|
18
|
+
retryConfig = null;
|
|
18
19
|
constructor(clientId, link, accessToken) {
|
|
19
20
|
this.clientId = clientId;
|
|
20
21
|
this.link = link;
|
|
@@ -51,6 +52,12 @@ class ApiClient {
|
|
|
51
52
|
setDeduplicator(dedup) {
|
|
52
53
|
this.deduplicator = dedup;
|
|
53
54
|
}
|
|
55
|
+
getRetryConfig() {
|
|
56
|
+
return this.retryConfig;
|
|
57
|
+
}
|
|
58
|
+
setRetryConfig(config) {
|
|
59
|
+
this.retryConfig = config;
|
|
60
|
+
}
|
|
54
61
|
getMiddleware() {
|
|
55
62
|
return this.middleware;
|
|
56
63
|
}
|
|
@@ -5,7 +5,9 @@ export interface EsiHandlerResponse {
|
|
|
5
5
|
body: unknown;
|
|
6
6
|
fromCache?: boolean;
|
|
7
7
|
stale?: boolean;
|
|
8
|
+
cacheHitType?: 'spec-ttl' | 'etag-304' | 'stale-on-error';
|
|
9
|
+
responseTimeMs?: number;
|
|
8
10
|
cursors?: CursorTokens;
|
|
9
11
|
}
|
|
10
|
-
export declare const handleRequest: (client: ApiClient, endpoint: string, method: string, body?: unknown, requiresAuth?: boolean, useETag?: boolean) => Promise<EsiHandlerResponse>;
|
|
12
|
+
export declare const handleRequest: (client: ApiClient, endpoint: string, method: string, body?: unknown, requiresAuth?: boolean, useETag?: boolean, templatePath?: string, requestTimeout?: number) => Promise<EsiHandlerResponse>;
|
|
11
13
|
//# sourceMappingURL=ApiRequestHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiRequestHandler.d.ts","sourceRoot":"","sources":["../../src/core/ApiRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiRequestHandler.d.ts","sourceRoot":"","sources":["../../src/core/ApiRequestHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAYxC,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AASpE,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,YAAY,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,gBAAgB,CAAC;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAqoBD,eAAO,MAAM,aAAa,GACxB,QAAQ,SAAS,EACjB,UAAU,MAAM,EAChB,QAAQ,MAAM,EACd,OAAO,OAAO,EACd,eAAc,OAAe,EAC7B,UAAS,OAAc,EACvB,eAAe,MAAM,EACrB,iBAAiB,MAAM,KACtB,OAAO,CAAC,kBAAkB,CA8F5B,CAAC"}
|