feat: add pinned inventory location enrichment

This commit is contained in:
jb
2026-09-20 12:13:51 -04:00
parent fe7d218195
commit 0c9197f841
32 changed files with 3116 additions and 55 deletions
+18 -4
View File
@@ -16,6 +16,7 @@ import {
ESI_ASSET_NAME_MAX_RESPONSE_BYTES,
ESI_ASSETS_SCOPE,
ESI_COMPATIBILITY_DATE,
ESI_STRUCTURES_SCOPE,
ESI_READ_OPERATIONS,
ESI_WALLET_MAX_RESPONSE_BYTES,
ESI_WALLET_SCOPE,
@@ -97,6 +98,18 @@ describe("central ESI client", () => {
expect(JSON.stringify(queued.calls)).not.toContain("secret");
});
test("reads private structures through the fixed lossless endpoint and isolates its scope", async () => {
const queued = queueFetch([response('{"structure_id":9007199254740993,"name":"Private Keep","solar_system_id":30000142,"owner_id":99000001,"type_id":35832,"position":{"x":1,"y":2,"z":3}}', { "Cache-Control": "max-age=60" })]);
const client = new EsiClient({ userAgent: "test", fetch: queued.fetch, now: () => 1_000 });
const result = await client.getStructure(42, "9007199254740993", "secret-token", authority("u", 42, [ESI_STRUCTURES_SCOPE]));
expect(result.structureId).toBe("9007199254740993");
expect(result.solarSystemId).toBe("30000142");
expect(queued.calls[0]?.url).toBe("https://esi.evetech.net/universe/structures/9007199254740993");
expect(new Headers(queued.calls[0]?.init.headers).get("authorization")).toBe("Bearer secret-token");
await expect(client.getStructure(42, "9007199254740994", "secret-token", authority("u", 42, [ESI_ASSETS_SCOPE]))).rejects.toThrow("missing required scope");
expect(ESI_READ_OPERATIONS.characterStructure.requiredScope).toBe(ESI_STRUCTURES_SCOPE);
});
test("retries transient responses with Retry-After but does not retry 401/403", async () => {
const delays: number[] = [];
const retryable = queueFetch([
@@ -366,13 +379,14 @@ describe("T06 transport bounds, authority, and metadata", () => {
expect(bounded.getCacheStats().cacheEntries).toBeLessThanOrEqual(512);
expect(bounded.getCacheStats(7 * 60 * 60 * 1000).cacheEntries).toBe(0);
const weightedBody = `[{\"item_id\":1,\"name\":\"${"x".repeat(900_000)}\"}]`;
const weightedQueue = queueFetch(Array.from({ length: 40 }, () => response(weightedBody, { "Cache-Control": "max-age=60" })));
const weightedBody = JSON.stringify(Array.from({ length: 1_000 }, (_, index) => ({ item_id: index + 1, name: "x".repeat(512) })));
const weightedIds = Array.from({ length: 1_000 }, (_, index) => String(index + 1));
const weightedQueue = queueFetch(Array.from({ length: 80 }, () => response(weightedBody, { "Cache-Control": "max-age=60" })));
const weighted = new EsiClient({ userAgent: "test", fetch: weightedQueue.fetch, now: () => 0 });
for (let index = 0; index < 40; index += 1) await weighted.getAssetNames(7, ["1"], "token", authority(`weighted-${index}`, 7));
for (let index = 0; index < 80; index += 1) await weighted.getAssetNames(7, weightedIds, "token", authority(`weighted-${index}`, 7));
const weightedStats = weighted.getCacheStats();
expect(weightedStats.cacheBytes).toBeLessThanOrEqual(ESI_CACHE_MAX_BYTES);
expect(weightedStats.cacheEntries).toBeLessThan(40);
expect(weightedStats.cacheEntries).toBeLessThan(80);
const snapshotRows = Array.from({ length: 1_000 }, (_, index) => asset(String(index + 1)));
const snapshotBody = JSON.stringify(snapshotRows);