@lgriffin/esi.ts 7.4.0 → 9.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/CHANGELOG.md +27 -0
- package/README.md +100 -24
- package/dist/EsiClient.d.ts +3 -0
- package/dist/EsiClient.d.ts.map +1 -1
- package/dist/EsiClientBuilder.d.ts +1 -0
- package/dist/EsiClientBuilder.d.ts.map +1 -1
- package/dist/clients/AllianceClient.d.ts +3 -0
- package/dist/clients/AllianceClient.d.ts.map +1 -1
- package/dist/clients/BaseEsiClient.d.ts +1 -1
- package/dist/clients/BaseEsiClient.d.ts.map +1 -1
- package/dist/clients/CalendarClient.d.ts +3 -0
- package/dist/clients/CalendarClient.d.ts.map +1 -1
- package/dist/clients/CharacterClient.d.ts +10 -2
- package/dist/clients/CharacterClient.d.ts.map +1 -1
- package/dist/clients/ClonesClient.d.ts +2 -0
- package/dist/clients/ClonesClient.d.ts.map +1 -1
- package/dist/clients/ContactsClient.d.ts +7 -0
- package/dist/clients/ContactsClient.d.ts.map +1 -1
- package/dist/clients/CorporationsClient.d.ts +18 -0
- package/dist/clients/CorporationsClient.d.ts.map +1 -1
- package/dist/clients/FittingsClient.d.ts +2 -0
- package/dist/clients/FittingsClient.d.ts.map +1 -1
- package/dist/clients/FleetClient.d.ts +3 -0
- package/dist/clients/FleetClient.d.ts.map +1 -1
- package/dist/clients/IndustryClient.d.ts +9 -0
- package/dist/clients/IndustryClient.d.ts.map +1 -1
- package/dist/clients/LoyaltyClient.d.ts +3 -0
- package/dist/clients/LoyaltyClient.d.ts.map +1 -1
- package/dist/clients/MailClient.d.ts +6 -0
- package/dist/clients/MailClient.d.ts.map +1 -1
- package/dist/clients/MarketClient.d.ts +13 -22
- package/dist/clients/MarketClient.d.ts.map +1 -1
- package/dist/clients/PiClient.d.ts +3 -0
- package/dist/clients/PiClient.d.ts.map +1 -1
- package/dist/clients/SkillsClient.d.ts +2 -0
- package/dist/clients/SkillsClient.d.ts.map +1 -1
- package/dist/clients/WalletClient.d.ts +1 -0
- package/dist/clients/WalletClient.d.ts.map +1 -1
- package/dist/clients/WarsClient.d.ts +3 -0
- package/dist/clients/WarsClient.d.ts.map +1 -1
- package/dist/config/jest/globalSetup.d.ts.map +1 -1
- package/dist/config/jest/globalTeardown.d.ts.map +1 -1
- package/dist/core/ApiClient.d.ts +14 -6
- package/dist/core/ApiClient.d.ts.map +1 -1
- package/dist/core/ApiRequestHandler.d.ts +3 -11
- package/dist/core/ApiRequestHandler.d.ts.map +1 -1
- package/dist/core/IDeduplicator.d.ts +6 -0
- package/dist/core/IDeduplicator.d.ts.map +1 -0
- package/dist/core/IRetryStrategy.d.ts +5 -0
- package/dist/core/IRetryStrategy.d.ts.map +1 -0
- package/dist/core/RequestDeduplicator.d.ts +2 -1
- package/dist/core/RequestDeduplicator.d.ts.map +1 -1
- package/dist/core/RetryStrategy.d.ts +19 -0
- package/dist/core/RetryStrategy.d.ts.map +1 -0
- package/dist/core/circuitBreaker/CircuitBreaker.d.ts +11 -1
- package/dist/core/circuitBreaker/CircuitBreaker.d.ts.map +1 -1
- package/dist/core/circuitBreaker/ICircuitBreaker.d.ts +23 -0
- package/dist/core/circuitBreaker/ICircuitBreaker.d.ts.map +1 -0
- package/dist/core/configureApiClient.d.ts +18 -0
- package/dist/core/configureApiClient.d.ts.map +1 -0
- package/dist/core/endpoints/EndpointDefinition.d.ts +2 -0
- package/dist/core/endpoints/EndpointDefinition.d.ts.map +1 -1
- package/dist/core/endpoints/calendarEndpoints.d.ts +1 -1
- package/dist/core/endpoints/characterEndpoints.d.ts +3 -3
- package/dist/core/endpoints/contactEndpoints.d.ts +7 -3
- package/dist/core/endpoints/contactEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/corporationEndpoints.d.ts +4 -1
- package/dist/core/endpoints/corporationEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/createClient.d.ts +18 -1
- package/dist/core/endpoints/createClient.d.ts.map +1 -1
- package/dist/core/endpoints/dogmaEndpoints.d.ts +17 -0
- package/dist/core/endpoints/dogmaEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/esi-scopes.generated.d.ts +1 -1
- package/dist/core/endpoints/esi-scopes.generated.d.ts.map +1 -1
- package/dist/core/endpoints/fleetEndpoints.d.ts +5 -0
- package/dist/core/endpoints/fleetEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/mailEndpoints.d.ts +13 -0
- package/dist/core/endpoints/mailEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/marketEndpoints.d.ts +29 -48
- package/dist/core/endpoints/marketEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/piEndpoints.d.ts +3 -0
- package/dist/core/endpoints/piEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/universeEndpoints.d.ts +13 -2
- package/dist/core/endpoints/universeEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/walletEndpoints.d.ts +4 -0
- package/dist/core/endpoints/walletEndpoints.d.ts.map +1 -1
- package/dist/core/logger/logger.d.ts +2 -1
- package/dist/core/logger/logger.d.ts.map +1 -1
- package/dist/core/pagination/AsyncPaginationIterator.d.ts +4 -1
- package/dist/core/pagination/AsyncPaginationIterator.d.ts.map +1 -1
- package/dist/core/pagination/CursorPaginationHandler.d.ts +15 -6
- package/dist/core/pagination/CursorPaginationHandler.d.ts.map +1 -1
- package/dist/core/pagination/PaginationHandler.d.ts +7 -6
- package/dist/core/pagination/PaginationHandler.d.ts.map +1 -1
- package/dist/core/rateLimiter/RateLimiter.d.ts +8 -2
- package/dist/core/rateLimiter/RateLimiter.d.ts.map +1 -1
- package/dist/core/requestPipeline/cachePolicy.d.ts +31 -0
- package/dist/core/requestPipeline/cachePolicy.d.ts.map +1 -0
- package/dist/core/requestPipeline/dependencies.d.ts +10 -0
- package/dist/core/requestPipeline/dependencies.d.ts.map +1 -0
- package/dist/core/requestPipeline/fetchExecution.d.ts +28 -0
- package/dist/core/requestPipeline/fetchExecution.d.ts.map +1 -0
- package/dist/core/requestPipeline/headers.d.ts +11 -0
- package/dist/core/requestPipeline/headers.d.ts.map +1 -0
- package/dist/core/requestPipeline/index.d.ts +10 -0
- package/dist/core/requestPipeline/index.d.ts.map +1 -0
- package/dist/core/requestPipeline/middlewareBridge.d.ts +15 -0
- package/dist/core/requestPipeline/middlewareBridge.d.ts.map +1 -0
- package/dist/core/requestPipeline/paginationOrchestration.d.ts +15 -0
- package/dist/core/requestPipeline/paginationOrchestration.d.ts.map +1 -0
- package/dist/core/requestPipeline/statusHandling.d.ts +18 -0
- package/dist/core/requestPipeline/statusHandling.d.ts.map +1 -0
- package/dist/core/util/error.d.ts +6 -1
- package/dist/core/util/error.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +196 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +146 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9937 -176
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +9834 -0
- package/dist/index.mjs.map +1 -0
- package/dist/schemas/calendar.d.ts +1 -1
- package/dist/schemas/character.d.ts +1 -10
- package/dist/schemas/character.d.ts.map +1 -1
- package/dist/schemas/common.d.ts +9 -0
- package/dist/schemas/common.d.ts.map +1 -1
- package/dist/schemas/contacts.d.ts +2 -1
- package/dist/schemas/contacts.d.ts.map +1 -1
- package/dist/schemas/corporation.d.ts +4 -9
- package/dist/schemas/corporation.d.ts.map +1 -1
- package/dist/schemas/dogma.d.ts +17 -0
- package/dist/schemas/dogma.d.ts.map +1 -1
- package/dist/schemas/fleet.d.ts +1 -0
- package/dist/schemas/fleet.d.ts.map +1 -1
- package/dist/schemas/index.js +2085 -46
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/index.mjs +1914 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas/market.d.ts +91 -4
- package/dist/schemas/market.d.ts.map +1 -1
- package/dist/schemas/pi.d.ts +3 -0
- package/dist/schemas/pi.d.ts.map +1 -1
- package/dist/schemas/sovereignty.d.ts +2 -0
- package/dist/schemas/sovereignty.d.ts.map +1 -1
- package/dist/schemas/universe.d.ts +11 -2
- package/dist/schemas/universe.d.ts.map +1 -1
- package/dist/schemas/wallet.d.ts +2 -0
- package/dist/schemas/wallet.d.ts.map +1 -1
- package/dist/testing/TestDataFactory.d.ts.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +935 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/index.mjs +898 -0
- package/dist/testing/index.mjs.map +1 -0
- package/dist/types/character.d.ts +2 -1
- package/dist/types/character.d.ts.map +1 -1
- package/dist/types/generated/esi-spec.generated.d.ts +3 -3
- package/dist/types/generated/esi-spec.generated.d.ts.map +1 -1
- package/dist/types/generated/spec-alignment.check.d.ts +9 -0
- package/dist/types/generated/spec-alignment.check.d.ts.map +1 -1
- package/dist/types/market.d.ts +7 -1
- package/dist/types/market.d.ts.map +1 -1
- package/package.json +33 -6
- package/dist/EsiClient.js +0 -251
- package/dist/EsiClientBuilder.js +0 -217
- package/dist/clients/AccessListsClient.js +0 -20
- package/dist/clients/AllianceClient.js +0 -72
- package/dist/clients/AssetsClient.js +0 -81
- package/dist/clients/BaseEsiClient.js +0 -40
- package/dist/clients/CalendarClient.js +0 -54
- package/dist/clients/CharacterClient.js +0 -149
- package/dist/clients/ClonesClient.js +0 -31
- package/dist/clients/ContactsClient.js +0 -104
- package/dist/clients/ContractsClient.js +0 -111
- package/dist/clients/CorporationsClient.js +0 -227
- package/dist/clients/DogmaClient.js +0 -55
- package/dist/clients/FactionClient.js +0 -79
- package/dist/clients/FittingsClient.js +0 -42
- package/dist/clients/FleetClient.js +0 -162
- package/dist/clients/FreelanceJobsClient.js +0 -76
- package/dist/clients/IncursionsClient.js +0 -19
- package/dist/clients/IndustryClient.js +0 -88
- package/dist/clients/InsuranceClient.js +0 -19
- package/dist/clients/KillmailsClient.js +0 -47
- package/dist/clients/LocationClient.js +0 -41
- package/dist/clients/LoyaltyClient.js +0 -30
- package/dist/clients/MailClient.js +0 -108
- package/dist/clients/MarketClient.js +0 -131
- package/dist/clients/MercenaryClient.js +0 -27
- package/dist/clients/MetaClient.js +0 -56
- package/dist/clients/PiClient.js +0 -51
- package/dist/clients/RouteClient.js +0 -24
- package/dist/clients/SearchClient.js +0 -22
- package/dist/clients/SkillsClient.js +0 -41
- package/dist/clients/SkyhooksClient.js +0 -35
- package/dist/clients/SovereigntyClient.js +0 -27
- package/dist/clients/StatusClient.js +0 -19
- package/dist/clients/UiClient.js +0 -58
- package/dist/clients/UniverseClient.js +0 -277
- package/dist/clients/WalletClient.js +0 -82
- package/dist/clients/WarsClient.js +0 -37
- package/dist/config/configManager.js +0 -47
- package/dist/config/jest/globalSetup.js +0 -7
- package/dist/config/jest/globalTeardown.js +0 -7
- package/dist/config/jest/jest.setup.js +0 -29
- package/dist/core/ApiClient.js +0 -123
- package/dist/core/ApiClientBuilder.js +0 -54
- package/dist/core/ApiRequestHandler.js +0 -444
- package/dist/core/BatchRequestHandler.js +0 -66
- package/dist/core/ClientRegistry.js +0 -116
- package/dist/core/EsiDiagnostics.js +0 -47
- package/dist/core/RequestDeduplicator.js +0 -26
- package/dist/core/cache/ETagCacheManager.js +0 -184
- package/dist/core/cache/ICache.js +0 -2
- package/dist/core/circuitBreaker/CircuitBreaker.js +0 -156
- package/dist/core/constants.js +0 -7
- package/dist/core/endpoints/EndpointDefinition.js +0 -2
- package/dist/core/endpoints/accessListEndpoints.js +0 -13
- package/dist/core/endpoints/allianceEndpoints.js +0 -34
- package/dist/core/endpoints/assetEndpoints.js +0 -51
- package/dist/core/endpoints/buildEndpointPath.js +0 -44
- package/dist/core/endpoints/calendarEndpoints.js +0 -35
- package/dist/core/endpoints/characterEndpoints.js +0 -104
- package/dist/core/endpoints/cloneEndpoints.js +0 -21
- package/dist/core/endpoints/contactEndpoints.js +0 -72
- package/dist/core/endpoints/contractEndpoints.js +0 -70
- package/dist/core/endpoints/corporationEndpoints.js +0 -161
- package/dist/core/endpoints/createClient.js +0 -175
- package/dist/core/endpoints/dogmaEndpoints.js +0 -40
- package/dist/core/endpoints/esi-cache-ttls.generated.js +0 -133
- package/dist/core/endpoints/esi-rate-limit-groups.generated.js +0 -153
- package/dist/core/endpoints/esi-scopes.generated.js +0 -135
- package/dist/core/endpoints/factionEndpoints.js +0 -57
- package/dist/core/endpoints/fittingEndpoints.js +0 -27
- package/dist/core/endpoints/fleetEndpoints.js +0 -101
- package/dist/core/endpoints/freelanceJobsEndpoints.js +0 -51
- package/dist/core/endpoints/incursionEndpoints.js +0 -13
- package/dist/core/endpoints/industryEndpoints.js +0 -61
- package/dist/core/endpoints/insuranceEndpoints.js +0 -13
- package/dist/core/endpoints/killmailEndpoints.js +0 -28
- package/dist/core/endpoints/locationEndpoints.js +0 -27
- package/dist/core/endpoints/loyaltyEndpoints.js +0 -21
- package/dist/core/endpoints/mailEndpoints.js +0 -68
- package/dist/core/endpoints/marketEndpoints.js +0 -84
- package/dist/core/endpoints/mercenaryEndpoints.js +0 -19
- package/dist/core/endpoints/metaEndpoints.js +0 -12
- package/dist/core/endpoints/piEndpoints.js +0 -36
- package/dist/core/endpoints/routeEndpoints.js +0 -14
- package/dist/core/endpoints/searchEndpoints.js +0 -14
- package/dist/core/endpoints/skillEndpoints.js +0 -29
- package/dist/core/endpoints/skyhookEndpoints.js +0 -25
- package/dist/core/endpoints/sovereigntyEndpoints.js +0 -19
- package/dist/core/endpoints/statusEndpoints.js +0 -12
- package/dist/core/endpoints/uiEndpoints.js +0 -39
- package/dist/core/endpoints/universeEndpoints.js +0 -210
- package/dist/core/endpoints/walletEndpoints.js +0 -50
- package/dist/core/endpoints/warEndpoints.js +0 -28
- package/dist/core/logger/ILogger.js +0 -2
- package/dist/core/logger/logger.js +0 -16
- package/dist/core/logger/loggerUtil.js +0 -30
- package/dist/core/middleware/Middleware.js +0 -42
- package/dist/core/pagination/AsyncPaginationIterator.js +0 -27
- package/dist/core/pagination/CursorPaginationHandler.js +0 -148
- package/dist/core/pagination/PaginationHandler.js +0 -115
- package/dist/core/rateLimiter/IRateLimiter.js +0 -2
- package/dist/core/rateLimiter/RateLimiter.js +0 -307
- package/dist/core/util/error.js +0 -122
- package/dist/core/util/headersUtil.js +0 -37
- package/dist/core/util/retry.js +0 -9
- package/dist/core/util/sleep.js +0 -6
- package/dist/core/util/stringUtil.js +0 -6
- package/dist/core/util/testHelpers.js +0 -9
- package/dist/core/util/validation.js +0 -52
- package/dist/schemas/access-lists.js +0 -14
- package/dist/schemas/alliance.js +0 -28
- package/dist/schemas/assets.js +0 -26
- package/dist/schemas/calendar.js +0 -43
- package/dist/schemas/character.js +0 -122
- package/dist/schemas/clones.js +0 -21
- package/dist/schemas/common.js +0 -34
- package/dist/schemas/contacts.js +0 -15
- package/dist/schemas/contracts.js +0 -58
- package/dist/schemas/corporation.js +0 -192
- package/dist/schemas/dogma.js +0 -42
- package/dist/schemas/faction-warfare.js +0 -92
- package/dist/schemas/fittings.js +0 -15
- package/dist/schemas/fleet.js +0 -48
- package/dist/schemas/freelance-jobs.js +0 -99
- package/dist/schemas/incursions.js +0 -14
- package/dist/schemas/industry.js +0 -75
- package/dist/schemas/insurance.js +0 -12
- package/dist/schemas/killmails.js +0 -42
- package/dist/schemas/location.js +0 -20
- package/dist/schemas/loyalty.js +0 -20
- package/dist/schemas/mail.js +0 -38
- package/dist/schemas/market.js +0 -39
- package/dist/schemas/mercenary.js +0 -22
- package/dist/schemas/pi.js +0 -85
- package/dist/schemas/skills.js +0 -30
- package/dist/schemas/skyhooks.js +0 -30
- package/dist/schemas/sovereignty.js +0 -70
- package/dist/schemas/status.js +0 -10
- package/dist/schemas/universe.js +0 -245
- package/dist/schemas/wallet.js +0 -29
- package/dist/schemas/wars.js +0 -31
- package/dist/testing/TestDataFactory.js +0 -823
- package/dist/types/access-lists.js +0 -2
- package/dist/types/alliance.js +0 -2
- package/dist/types/api-responses.js +0 -73
- package/dist/types/assets.js +0 -2
- package/dist/types/branded.js +0 -6
- package/dist/types/calendar.js +0 -2
- package/dist/types/character.js +0 -2
- package/dist/types/clones.js +0 -2
- package/dist/types/common.js +0 -2
- package/dist/types/contacts.js +0 -2
- package/dist/types/contracts.js +0 -2
- package/dist/types/corporation.js +0 -2
- package/dist/types/dogma.js +0 -2
- package/dist/types/faction-warfare.js +0 -2
- package/dist/types/fittings.js +0 -2
- package/dist/types/fleet.js +0 -2
- package/dist/types/freelance-jobs.js +0 -2
- package/dist/types/generated/esi-spec.generated.js +0 -6
- package/dist/types/generated/spec-alignment.check.js +0 -14
- package/dist/types/incursions.js +0 -2
- package/dist/types/industry.js +0 -2
- package/dist/types/insurance.js +0 -2
- package/dist/types/killmails.js +0 -2
- package/dist/types/location.js +0 -2
- package/dist/types/loyalty.js +0 -2
- package/dist/types/mail.js +0 -2
- package/dist/types/market.js +0 -2
- package/dist/types/mercenary.js +0 -2
- package/dist/types/pi.js +0 -2
- package/dist/types/skills.js +0 -2
- package/dist/types/skyhooks.js +0 -2
- package/dist/types/sovereignty.js +0 -2
- package/dist/types/status.js +0 -2
- package/dist/types/universe.js +0 -2
- package/dist/types/wallet.js +0 -2
- package/dist/types/wars.js +0 -2
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.uiEndpoints = void 0;
|
|
4
|
-
exports.uiEndpoints = {
|
|
5
|
-
setAutopilotWaypoint: {
|
|
6
|
-
path: 'ui/autopilot/waypoint',
|
|
7
|
-
method: 'POST',
|
|
8
|
-
requiresAuth: true,
|
|
9
|
-
queryParams: {
|
|
10
|
-
destinationId: 'destination_id',
|
|
11
|
-
addToBeginning: 'add_to_beginning',
|
|
12
|
-
clearOtherWaypoints: 'clear_other_waypoints',
|
|
13
|
-
},
|
|
14
|
-
},
|
|
15
|
-
openContractWindow: {
|
|
16
|
-
path: 'ui/openwindow/contract',
|
|
17
|
-
method: 'POST',
|
|
18
|
-
requiresAuth: true,
|
|
19
|
-
queryParams: { contractId: 'contract_id' },
|
|
20
|
-
},
|
|
21
|
-
openInformationWindow: {
|
|
22
|
-
path: 'ui/openwindow/information',
|
|
23
|
-
method: 'POST',
|
|
24
|
-
requiresAuth: true,
|
|
25
|
-
queryParams: { targetId: 'target_id' },
|
|
26
|
-
},
|
|
27
|
-
openMarketDetailsWindow: {
|
|
28
|
-
path: 'ui/openwindow/marketdetails',
|
|
29
|
-
method: 'POST',
|
|
30
|
-
requiresAuth: true,
|
|
31
|
-
queryParams: { typeId: 'type_id' },
|
|
32
|
-
},
|
|
33
|
-
openNewMailWindow: {
|
|
34
|
-
path: 'ui/openwindow/newmail',
|
|
35
|
-
method: 'POST',
|
|
36
|
-
requiresAuth: true,
|
|
37
|
-
hasBody: true,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.universeEndpoints = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const universe_1 = require("../../schemas/universe");
|
|
6
|
-
exports.universeEndpoints = {
|
|
7
|
-
getAncestries: {
|
|
8
|
-
path: 'universe/ancestries',
|
|
9
|
-
method: 'GET',
|
|
10
|
-
requiresAuth: false,
|
|
11
|
-
responseSchema: zod_1.z.array(universe_1.AncestrySchema),
|
|
12
|
-
},
|
|
13
|
-
getAsteroidBeltInfo: {
|
|
14
|
-
path: 'universe/asteroid_belts/{asteroidBeltId}',
|
|
15
|
-
method: 'GET',
|
|
16
|
-
requiresAuth: false,
|
|
17
|
-
pathParams: ['asteroidBeltId'],
|
|
18
|
-
responseSchema: universe_1.AsteroidBeltInfoSchema,
|
|
19
|
-
},
|
|
20
|
-
getBloodlines: {
|
|
21
|
-
path: 'universe/bloodlines',
|
|
22
|
-
method: 'GET',
|
|
23
|
-
requiresAuth: false,
|
|
24
|
-
responseSchema: zod_1.z.array(universe_1.BloodlineSchema),
|
|
25
|
-
},
|
|
26
|
-
getCategories: {
|
|
27
|
-
path: 'universe/categories',
|
|
28
|
-
method: 'GET',
|
|
29
|
-
requiresAuth: false,
|
|
30
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
31
|
-
},
|
|
32
|
-
getCategoryById: {
|
|
33
|
-
path: 'universe/categories/{categoryId}',
|
|
34
|
-
method: 'GET',
|
|
35
|
-
requiresAuth: false,
|
|
36
|
-
pathParams: ['categoryId'],
|
|
37
|
-
responseSchema: universe_1.ItemCategorySchema,
|
|
38
|
-
},
|
|
39
|
-
getConstellations: {
|
|
40
|
-
path: 'universe/constellations',
|
|
41
|
-
method: 'GET',
|
|
42
|
-
requiresAuth: false,
|
|
43
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
44
|
-
},
|
|
45
|
-
getConstellationById: {
|
|
46
|
-
path: 'universe/constellations/{constellationId}',
|
|
47
|
-
method: 'GET',
|
|
48
|
-
requiresAuth: false,
|
|
49
|
-
pathParams: ['constellationId'],
|
|
50
|
-
responseSchema: universe_1.ConstellationInfoSchema,
|
|
51
|
-
},
|
|
52
|
-
getFactions: {
|
|
53
|
-
path: 'universe/factions',
|
|
54
|
-
method: 'GET',
|
|
55
|
-
requiresAuth: false,
|
|
56
|
-
responseSchema: zod_1.z.array(universe_1.FactionSchema),
|
|
57
|
-
},
|
|
58
|
-
getGraphics: {
|
|
59
|
-
path: 'universe/graphics',
|
|
60
|
-
method: 'GET',
|
|
61
|
-
requiresAuth: false,
|
|
62
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
63
|
-
},
|
|
64
|
-
getGraphicById: {
|
|
65
|
-
path: 'universe/graphics/{graphicId}',
|
|
66
|
-
method: 'GET',
|
|
67
|
-
requiresAuth: false,
|
|
68
|
-
pathParams: ['graphicId'],
|
|
69
|
-
responseSchema: universe_1.GraphicInfoSchema,
|
|
70
|
-
},
|
|
71
|
-
getItemGroups: {
|
|
72
|
-
path: 'universe/groups',
|
|
73
|
-
method: 'GET',
|
|
74
|
-
requiresAuth: false,
|
|
75
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
76
|
-
},
|
|
77
|
-
getItemGroupById: {
|
|
78
|
-
path: 'universe/groups/{groupId}',
|
|
79
|
-
method: 'GET',
|
|
80
|
-
requiresAuth: false,
|
|
81
|
-
pathParams: ['groupId'],
|
|
82
|
-
responseSchema: universe_1.ItemGroupSchema,
|
|
83
|
-
},
|
|
84
|
-
postBulkNamesToIds: {
|
|
85
|
-
path: 'universe/ids',
|
|
86
|
-
method: 'POST',
|
|
87
|
-
requiresAuth: false,
|
|
88
|
-
bodyBuilder: (names) => names,
|
|
89
|
-
responseSchema: universe_1.BulkIdResultSchema,
|
|
90
|
-
},
|
|
91
|
-
getMoonById: {
|
|
92
|
-
path: 'universe/moons/{moonId}',
|
|
93
|
-
method: 'GET',
|
|
94
|
-
requiresAuth: false,
|
|
95
|
-
pathParams: ['moonId'],
|
|
96
|
-
responseSchema: universe_1.MoonInfoSchema,
|
|
97
|
-
},
|
|
98
|
-
postNamesAndCategories: {
|
|
99
|
-
path: 'universe/names',
|
|
100
|
-
method: 'POST',
|
|
101
|
-
requiresAuth: false,
|
|
102
|
-
bodyBuilder: (ids) => ids,
|
|
103
|
-
responseSchema: zod_1.z.array(universe_1.NameAndCategorySchema),
|
|
104
|
-
},
|
|
105
|
-
getPlanetById: {
|
|
106
|
-
path: 'universe/planets/{planetId}',
|
|
107
|
-
method: 'GET',
|
|
108
|
-
requiresAuth: false,
|
|
109
|
-
pathParams: ['planetId'],
|
|
110
|
-
responseSchema: universe_1.PlanetInfoSchema,
|
|
111
|
-
},
|
|
112
|
-
getRaces: {
|
|
113
|
-
path: 'universe/races',
|
|
114
|
-
method: 'GET',
|
|
115
|
-
requiresAuth: false,
|
|
116
|
-
responseSchema: zod_1.z.array(universe_1.RaceSchema),
|
|
117
|
-
},
|
|
118
|
-
getRegions: {
|
|
119
|
-
path: 'universe/regions',
|
|
120
|
-
method: 'GET',
|
|
121
|
-
requiresAuth: false,
|
|
122
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
123
|
-
},
|
|
124
|
-
getRegionById: {
|
|
125
|
-
path: 'universe/regions/{regionId}',
|
|
126
|
-
method: 'GET',
|
|
127
|
-
requiresAuth: false,
|
|
128
|
-
pathParams: ['regionId'],
|
|
129
|
-
responseSchema: universe_1.RegionInfoSchema,
|
|
130
|
-
},
|
|
131
|
-
getSchematicById: {
|
|
132
|
-
path: 'universe/schematics/{schematicId}',
|
|
133
|
-
method: 'GET',
|
|
134
|
-
requiresAuth: false,
|
|
135
|
-
pathParams: ['schematicId'],
|
|
136
|
-
responseSchema: universe_1.SchematicInfoSchema,
|
|
137
|
-
},
|
|
138
|
-
getStargateById: {
|
|
139
|
-
path: 'universe/stargates/{stargateId}',
|
|
140
|
-
method: 'GET',
|
|
141
|
-
requiresAuth: false,
|
|
142
|
-
pathParams: ['stargateId'],
|
|
143
|
-
responseSchema: universe_1.StargateInfoSchema,
|
|
144
|
-
},
|
|
145
|
-
getStarById: {
|
|
146
|
-
path: 'universe/stars/{starId}',
|
|
147
|
-
method: 'GET',
|
|
148
|
-
requiresAuth: false,
|
|
149
|
-
pathParams: ['starId'],
|
|
150
|
-
responseSchema: universe_1.StarInfoSchema,
|
|
151
|
-
},
|
|
152
|
-
getStationById: {
|
|
153
|
-
path: 'universe/stations/{stationId}',
|
|
154
|
-
method: 'GET',
|
|
155
|
-
requiresAuth: false,
|
|
156
|
-
pathParams: ['stationId'],
|
|
157
|
-
responseSchema: universe_1.StationInfoSchema,
|
|
158
|
-
},
|
|
159
|
-
getStructures: {
|
|
160
|
-
path: 'universe/structures',
|
|
161
|
-
method: 'GET',
|
|
162
|
-
requiresAuth: false,
|
|
163
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
164
|
-
},
|
|
165
|
-
getStructureById: {
|
|
166
|
-
path: 'universe/structures/{structureId}',
|
|
167
|
-
method: 'GET',
|
|
168
|
-
requiresAuth: true,
|
|
169
|
-
pathParams: ['structureId'],
|
|
170
|
-
responseSchema: universe_1.StructureInfoSchema,
|
|
171
|
-
},
|
|
172
|
-
getSystemJumps: {
|
|
173
|
-
path: 'universe/system_jumps',
|
|
174
|
-
method: 'GET',
|
|
175
|
-
requiresAuth: false,
|
|
176
|
-
responseSchema: zod_1.z.array(universe_1.SystemJumpSchema),
|
|
177
|
-
},
|
|
178
|
-
getSystemKills: {
|
|
179
|
-
path: 'universe/system_kills',
|
|
180
|
-
method: 'GET',
|
|
181
|
-
requiresAuth: false,
|
|
182
|
-
responseSchema: zod_1.z.array(universe_1.SystemKillSchema),
|
|
183
|
-
},
|
|
184
|
-
getSystems: {
|
|
185
|
-
path: 'universe/systems',
|
|
186
|
-
method: 'GET',
|
|
187
|
-
requiresAuth: false,
|
|
188
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
189
|
-
},
|
|
190
|
-
getSystemById: {
|
|
191
|
-
path: 'universe/systems/{systemId}',
|
|
192
|
-
method: 'GET',
|
|
193
|
-
requiresAuth: false,
|
|
194
|
-
pathParams: ['systemId'],
|
|
195
|
-
responseSchema: universe_1.SolarSystemInfoSchema,
|
|
196
|
-
},
|
|
197
|
-
getTypes: {
|
|
198
|
-
path: 'universe/types',
|
|
199
|
-
method: 'GET',
|
|
200
|
-
requiresAuth: false,
|
|
201
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
202
|
-
},
|
|
203
|
-
getTypeById: {
|
|
204
|
-
path: 'universe/types/{typeId}',
|
|
205
|
-
method: 'GET',
|
|
206
|
-
requiresAuth: false,
|
|
207
|
-
pathParams: ['typeId'],
|
|
208
|
-
responseSchema: universe_1.TypeInfoSchema,
|
|
209
|
-
},
|
|
210
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.walletEndpoints = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const wallet_1 = require("../../schemas/wallet");
|
|
6
|
-
const corporation_1 = require("../../schemas/corporation");
|
|
7
|
-
exports.walletEndpoints = {
|
|
8
|
-
getCharacterWallet: {
|
|
9
|
-
path: 'characters/{characterId}/wallet',
|
|
10
|
-
method: 'GET',
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
pathParams: ['characterId'],
|
|
13
|
-
responseSchema: zod_1.z.number(),
|
|
14
|
-
},
|
|
15
|
-
getCharacterWalletJournal: {
|
|
16
|
-
path: 'characters/{characterId}/wallet/journal',
|
|
17
|
-
method: 'GET',
|
|
18
|
-
requiresAuth: true,
|
|
19
|
-
pathParams: ['characterId'],
|
|
20
|
-
responseSchema: zod_1.z.array(wallet_1.WalletJournalSchema),
|
|
21
|
-
},
|
|
22
|
-
getCharacterWalletTransactions: {
|
|
23
|
-
path: 'characters/{characterId}/wallet/transactions',
|
|
24
|
-
method: 'GET',
|
|
25
|
-
requiresAuth: true,
|
|
26
|
-
pathParams: ['characterId'],
|
|
27
|
-
responseSchema: zod_1.z.array(wallet_1.WalletTransactionSchema),
|
|
28
|
-
},
|
|
29
|
-
getCorporationWallets: {
|
|
30
|
-
path: 'corporations/{corporationId}/wallets',
|
|
31
|
-
method: 'GET',
|
|
32
|
-
requiresAuth: true,
|
|
33
|
-
pathParams: ['corporationId'],
|
|
34
|
-
responseSchema: zod_1.z.array(corporation_1.CorporationWalletDivisionSchema),
|
|
35
|
-
},
|
|
36
|
-
getCorporationWalletJournal: {
|
|
37
|
-
path: 'corporations/{corporationId}/wallets/{division}/journal',
|
|
38
|
-
method: 'GET',
|
|
39
|
-
requiresAuth: true,
|
|
40
|
-
pathParams: ['corporationId', 'division'],
|
|
41
|
-
responseSchema: zod_1.z.array(wallet_1.WalletJournalSchema),
|
|
42
|
-
},
|
|
43
|
-
getCorporationWalletTransactions: {
|
|
44
|
-
path: 'corporations/{corporationId}/wallets/{division}/transactions',
|
|
45
|
-
method: 'GET',
|
|
46
|
-
requiresAuth: true,
|
|
47
|
-
pathParams: ['corporationId', 'division'],
|
|
48
|
-
responseSchema: zod_1.z.array(wallet_1.WalletTransactionSchema),
|
|
49
|
-
},
|
|
50
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.warEndpoints = void 0;
|
|
4
|
-
const zod_1 = require("zod");
|
|
5
|
-
const wars_1 = require("../../schemas/wars");
|
|
6
|
-
const killmails_1 = require("../../schemas/killmails");
|
|
7
|
-
exports.warEndpoints = {
|
|
8
|
-
getWars: {
|
|
9
|
-
path: 'wars',
|
|
10
|
-
method: 'GET',
|
|
11
|
-
requiresAuth: false,
|
|
12
|
-
responseSchema: zod_1.z.array(zod_1.z.number()),
|
|
13
|
-
},
|
|
14
|
-
getWarById: {
|
|
15
|
-
path: 'wars/{warId}',
|
|
16
|
-
method: 'GET',
|
|
17
|
-
requiresAuth: false,
|
|
18
|
-
pathParams: ['warId'],
|
|
19
|
-
responseSchema: wars_1.WarSchema,
|
|
20
|
-
},
|
|
21
|
-
getWarKillmails: {
|
|
22
|
-
path: 'wars/{warId}/killmails',
|
|
23
|
-
method: 'GET',
|
|
24
|
-
requiresAuth: false,
|
|
25
|
-
pathParams: ['warId'],
|
|
26
|
-
responseSchema: zod_1.z.array(killmails_1.KillmailSummarySchema),
|
|
27
|
-
},
|
|
28
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const winston_1 = require("winston");
|
|
4
|
-
const { combine, timestamp, printf, colorize } = winston_1.format;
|
|
5
|
-
// Define custom log format
|
|
6
|
-
const logFormat = printf(({ level, message, timestamp }) => {
|
|
7
|
-
return `${String(timestamp)} [${String(level)}]: ${String(message)}`;
|
|
8
|
-
});
|
|
9
|
-
// Create Winston logger instance — console only by default.
|
|
10
|
-
// Libraries should not write to files; the consuming application controls logging.
|
|
11
|
-
const logger = (0, winston_1.createLogger)({
|
|
12
|
-
level: process.env.ESI_LOG_LEVEL || 'warn',
|
|
13
|
-
format: combine(colorize(), timestamp(), logFormat),
|
|
14
|
-
transports: [new winston_1.transports.Console()],
|
|
15
|
-
});
|
|
16
|
-
exports.default = logger;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.logDebug = exports.logWarn = exports.logError = exports.logInfo = exports.getLogger = exports.setLogger = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
8
|
-
let activeLogger = logger_1.default;
|
|
9
|
-
const setLogger = (customLogger) => {
|
|
10
|
-
activeLogger = customLogger;
|
|
11
|
-
};
|
|
12
|
-
exports.setLogger = setLogger;
|
|
13
|
-
const getLogger = () => activeLogger;
|
|
14
|
-
exports.getLogger = getLogger;
|
|
15
|
-
const logInfo = (message) => {
|
|
16
|
-
activeLogger.info(message);
|
|
17
|
-
};
|
|
18
|
-
exports.logInfo = logInfo;
|
|
19
|
-
const logError = (message) => {
|
|
20
|
-
activeLogger.error(message);
|
|
21
|
-
};
|
|
22
|
-
exports.logError = logError;
|
|
23
|
-
const logWarn = (message) => {
|
|
24
|
-
activeLogger.warn(message);
|
|
25
|
-
};
|
|
26
|
-
exports.logWarn = logWarn;
|
|
27
|
-
const logDebug = (message) => {
|
|
28
|
-
activeLogger.debug(message);
|
|
29
|
-
};
|
|
30
|
-
exports.logDebug = logDebug;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MiddlewareManager = void 0;
|
|
4
|
-
class MiddlewareManager {
|
|
5
|
-
requestInterceptors = [];
|
|
6
|
-
responseInterceptors = [];
|
|
7
|
-
addRequestInterceptor(fn) {
|
|
8
|
-
this.requestInterceptors.push(fn);
|
|
9
|
-
return () => {
|
|
10
|
-
this.requestInterceptors = this.requestInterceptors.filter((i) => i !== fn);
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
addResponseInterceptor(fn) {
|
|
14
|
-
this.responseInterceptors.push(fn);
|
|
15
|
-
return () => {
|
|
16
|
-
this.responseInterceptors = this.responseInterceptors.filter((i) => i !== fn);
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
async applyRequestInterceptors(context) {
|
|
20
|
-
let ctx = context;
|
|
21
|
-
for (const interceptor of this.requestInterceptors) {
|
|
22
|
-
ctx = await interceptor(ctx);
|
|
23
|
-
}
|
|
24
|
-
return ctx;
|
|
25
|
-
}
|
|
26
|
-
async applyResponseInterceptors(context) {
|
|
27
|
-
let ctx = context;
|
|
28
|
-
for (const interceptor of this.responseInterceptors) {
|
|
29
|
-
ctx = await interceptor(ctx);
|
|
30
|
-
}
|
|
31
|
-
return ctx;
|
|
32
|
-
}
|
|
33
|
-
hasInterceptors() {
|
|
34
|
-
return (this.requestInterceptors.length > 0 ||
|
|
35
|
-
this.responseInterceptors.length > 0);
|
|
36
|
-
}
|
|
37
|
-
clear() {
|
|
38
|
-
this.requestInterceptors = [];
|
|
39
|
-
this.responseInterceptors = [];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.MiddlewareManager = MiddlewareManager;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchPages = fetchPages;
|
|
4
|
-
const ApiRequestHandler_1 = require("../ApiRequestHandler");
|
|
5
|
-
const loggerUtil_1 = require("../logger/loggerUtil");
|
|
6
|
-
function extractArray(body) {
|
|
7
|
-
if (Array.isArray(body))
|
|
8
|
-
return body;
|
|
9
|
-
if (body !== undefined && body !== null)
|
|
10
|
-
return [body];
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
async function* fetchPages(client, endpoint, method, requiresAuth = false, body) {
|
|
14
|
-
const firstResponse = await (0, ApiRequestHandler_1.handleSinglePageRequest)(client, endpoint, method, body, requiresAuth);
|
|
15
|
-
const totalPages = parseInt(firstResponse.headers['x-pages'] || '1', 10);
|
|
16
|
-
yield { data: extractArray(firstResponse.body), page: 1, totalPages };
|
|
17
|
-
for (let page = 2; page <= totalPages; page++) {
|
|
18
|
-
const sep = endpoint.includes('?') ? '&' : '?';
|
|
19
|
-
const pagedEndpoint = `${endpoint}${sep}page=${page}`;
|
|
20
|
-
(0, loggerUtil_1.logInfo)(`Fetching page ${page}/${totalPages}: ${pagedEndpoint}`);
|
|
21
|
-
const response = await (0, ApiRequestHandler_1.handleSinglePageRequest)(client, pagedEndpoint, method, body, requiresAuth);
|
|
22
|
-
const pageData = extractArray(response.body);
|
|
23
|
-
if (pageData.length === 0)
|
|
24
|
-
break;
|
|
25
|
-
yield { data: pageData, page, totalPages };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Cursor-based Pagination Handler for ESI API calls.
|
|
4
|
-
*
|
|
5
|
-
* New ESI routes (starting with Corporation Projects) use opaque
|
|
6
|
-
* before/after cursor tokens instead of page numbers.
|
|
7
|
-
*
|
|
8
|
-
* Response headers:
|
|
9
|
-
* x-cursor-before – token to fetch data preceding the current batch
|
|
10
|
-
* x-cursor-after – token to fetch data following the current batch
|
|
11
|
-
*
|
|
12
|
-
* Query parameters:
|
|
13
|
-
* before=<token> – crawl backwards
|
|
14
|
-
* after=<token> – crawl forwards
|
|
15
|
-
*
|
|
16
|
-
* An empty result array signals the beginning/end of the dataset.
|
|
17
|
-
*/
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.CursorPaginationHandler = void 0;
|
|
20
|
-
const loggerUtil_1 = require("../logger/loggerUtil");
|
|
21
|
-
const constants_1 = require("../constants");
|
|
22
|
-
const sleep_1 = require("../util/sleep");
|
|
23
|
-
class CursorPaginationHandler {
|
|
24
|
-
static DEFAULT_OPTIONS = {
|
|
25
|
-
maxPages: 1000,
|
|
26
|
-
maxRetries: 3,
|
|
27
|
-
retryDelayMs: 1000,
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Fetch a single cursor page, returning data + cursor tokens.
|
|
31
|
-
*/
|
|
32
|
-
static async fetchPage(client, endpoint, method, requiresAuth, cursor, body) {
|
|
33
|
-
const url = this.buildUrl(client, endpoint, cursor);
|
|
34
|
-
(0, loggerUtil_1.logInfo)(`Cursor fetch: ${url}`);
|
|
35
|
-
const response = await fetch(url, {
|
|
36
|
-
method,
|
|
37
|
-
headers: {
|
|
38
|
-
accept: 'gzip, deflate, br',
|
|
39
|
-
'User-Agent': constants_1.USER_AGENT,
|
|
40
|
-
'X-Compatibility-Date': constants_1.COMPATIBILITY_DATE,
|
|
41
|
-
...(requiresAuth
|
|
42
|
-
? { Authorization: client.getAuthorizationHeader() }
|
|
43
|
-
: {}),
|
|
44
|
-
},
|
|
45
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
46
|
-
});
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
49
|
-
}
|
|
50
|
-
let data;
|
|
51
|
-
try {
|
|
52
|
-
const parsed = await response.json();
|
|
53
|
-
data = Array.isArray(parsed) ? parsed : [parsed];
|
|
54
|
-
}
|
|
55
|
-
catch (jsonError) {
|
|
56
|
-
throw new Error(`Invalid JSON response: ${jsonError instanceof Error ? jsonError.message : String(jsonError)}`);
|
|
57
|
-
}
|
|
58
|
-
const cursors = this.extractCursors(response.headers);
|
|
59
|
-
return { data, cursors };
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Auto-fetch all pages by following `after` tokens until an empty
|
|
63
|
-
* response is received. Combines the caller-supplied first page
|
|
64
|
-
* data with all subsequent pages.
|
|
65
|
-
*/
|
|
66
|
-
static async fetchAll(client, endpoint, method, requiresAuth, firstPageData, firstCursors, body, options = {}) {
|
|
67
|
-
const opts = { ...this.DEFAULT_OPTIONS, ...options };
|
|
68
|
-
const rateLimiter = client.getRateLimiter();
|
|
69
|
-
const allData = [...firstPageData];
|
|
70
|
-
let afterToken = firstCursors.after;
|
|
71
|
-
let pageCount = 1;
|
|
72
|
-
let consecutiveFailures = 0;
|
|
73
|
-
while (afterToken && pageCount < opts.maxPages) {
|
|
74
|
-
try {
|
|
75
|
-
if (rateLimiter)
|
|
76
|
-
await rateLimiter.checkRateLimit();
|
|
77
|
-
const page = await this.fetchPageWithRetry(client, endpoint, method, requiresAuth, { after: afterToken }, body, opts);
|
|
78
|
-
consecutiveFailures = 0;
|
|
79
|
-
pageCount++;
|
|
80
|
-
if (page.data.length === 0) {
|
|
81
|
-
(0, loggerUtil_1.logInfo)('Cursor pagination: empty page received, dataset complete.');
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
allData.push(...page.data);
|
|
85
|
-
afterToken = page.cursors.after;
|
|
86
|
-
(0, loggerUtil_1.logInfo)(`Cursor page ${pageCount} fetched (${page.data.length} items)`);
|
|
87
|
-
}
|
|
88
|
-
catch (error) {
|
|
89
|
-
consecutiveFailures++;
|
|
90
|
-
(0, loggerUtil_1.logError)(`Cursor page fetch failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
91
|
-
if (consecutiveFailures >= opts.maxRetries) {
|
|
92
|
-
(0, loggerUtil_1.logWarn)(`${consecutiveFailures} consecutive failures. Stopping cursor pagination.`);
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
(0, loggerUtil_1.logInfo)(`Cursor pagination complete. ${allData.length} total items from ${pageCount} pages.`);
|
|
98
|
-
return allData;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Fetch a single cursor page with retry logic.
|
|
102
|
-
*/
|
|
103
|
-
static async fetchPageWithRetry(client, endpoint, method, requiresAuth, cursor, body, options) {
|
|
104
|
-
let lastError = null;
|
|
105
|
-
for (let attempt = 1; attempt <= options.maxRetries; attempt++) {
|
|
106
|
-
try {
|
|
107
|
-
return await this.fetchPage(client, endpoint, method, requiresAuth, cursor, body);
|
|
108
|
-
}
|
|
109
|
-
catch (error) {
|
|
110
|
-
lastError = error;
|
|
111
|
-
(0, loggerUtil_1.logWarn)(`Cursor fetch attempt ${attempt}/${options.maxRetries} failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
112
|
-
if (attempt < options.maxRetries) {
|
|
113
|
-
await (0, sleep_1.sleep)(options.retryDelayMs * attempt);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
throw lastError || new Error('Cursor page fetch failed after all retries');
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Extract cursor tokens from response headers.
|
|
121
|
-
*/
|
|
122
|
-
static extractCursors(headers) {
|
|
123
|
-
const get = (name) => headers.get(name) || null;
|
|
124
|
-
return {
|
|
125
|
-
before: get('x-cursor-before'),
|
|
126
|
-
after: get('x-cursor-after'),
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Build a URL with cursor query parameters appended.
|
|
131
|
-
*/
|
|
132
|
-
static buildUrl(client, endpoint, cursor) {
|
|
133
|
-
let url = `${client.getLink()}/${endpoint}`;
|
|
134
|
-
if (!cursor)
|
|
135
|
-
return url;
|
|
136
|
-
const parts = [];
|
|
137
|
-
if (cursor.before)
|
|
138
|
-
parts.push(`before=${encodeURIComponent(cursor.before)}`);
|
|
139
|
-
if (cursor.after)
|
|
140
|
-
parts.push(`after=${encodeURIComponent(cursor.after)}`);
|
|
141
|
-
if (parts.length > 0) {
|
|
142
|
-
const separator = url.includes('?') ? '&' : '?';
|
|
143
|
-
url += separator + parts.join('&');
|
|
144
|
-
}
|
|
145
|
-
return url;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
exports.CursorPaginationHandler = CursorPaginationHandler;
|