@lgriffin/esi.ts 4.0.0 → 5.1.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 +174 -0
- package/LICENSE +26 -26
- package/README.md +562 -557
- package/dist/EsiClient.d.ts +8 -2
- package/dist/EsiClient.d.ts.map +1 -1
- package/dist/EsiClient.js +9 -0
- package/dist/EsiClientBuilder.d.ts +4 -1
- package/dist/EsiClientBuilder.d.ts.map +1 -1
- package/dist/EsiClientBuilder.js +9 -0
- package/dist/clients/AccessListsClient.d.ts +15 -0
- package/dist/clients/AccessListsClient.d.ts.map +1 -0
- package/dist/clients/AccessListsClient.js +20 -0
- package/dist/clients/MercenaryClient.d.ts +20 -0
- package/dist/clients/MercenaryClient.d.ts.map +1 -0
- package/dist/clients/MercenaryClient.js +27 -0
- package/dist/clients/SkyhooksClient.d.ts +26 -0
- package/dist/clients/SkyhooksClient.d.ts.map +1 -0
- package/dist/clients/SkyhooksClient.js +35 -0
- package/dist/clients/SovereigntyClient.d.ts +4 -10
- package/dist/clients/SovereigntyClient.d.ts.map +1 -1
- package/dist/clients/SovereigntyClient.js +4 -12
- package/dist/clients/UniverseClient.d.ts +2 -2
- package/dist/clients/UniverseClient.d.ts.map +1 -1
- package/dist/clients/UniverseClient.js +3 -3
- package/dist/config/configManager.d.ts.map +1 -1
- package/dist/config/configManager.js +12 -6
- package/dist/config/jest/jest.setup.js +0 -1
- package/dist/core/ApiRequestHandler.d.ts.map +1 -1
- package/dist/core/ApiRequestHandler.js +7 -3
- package/dist/core/ClientRegistry.d.ts +6 -4
- package/dist/core/ClientRegistry.d.ts.map +1 -1
- package/dist/core/ClientRegistry.js +11 -2
- package/dist/core/circuitBreaker/CircuitBreaker.js +2 -2
- package/dist/core/constants.d.ts +3 -3
- package/dist/core/constants.js +2 -2
- package/dist/core/endpoints/accessListEndpoints.d.ts +9 -0
- package/dist/core/endpoints/accessListEndpoints.d.ts.map +1 -0
- package/dist/core/endpoints/accessListEndpoints.js +11 -0
- package/dist/core/endpoints/assetEndpoints.d.ts +4 -12
- package/dist/core/endpoints/assetEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/assetEndpoints.js +4 -4
- package/dist/core/endpoints/contactEndpoints.d.ts +1 -3
- package/dist/core/endpoints/contactEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/contactEndpoints.js +1 -1
- package/dist/core/endpoints/mercenaryEndpoints.d.ts +13 -0
- package/dist/core/endpoints/mercenaryEndpoints.d.ts.map +1 -0
- package/dist/core/endpoints/mercenaryEndpoints.js +15 -0
- package/dist/core/endpoints/skyhookEndpoints.d.ts +18 -0
- package/dist/core/endpoints/skyhookEndpoints.d.ts.map +1 -0
- package/dist/core/endpoints/skyhookEndpoints.js +20 -0
- package/dist/core/endpoints/sovereigntyEndpoints.d.ts +2 -7
- package/dist/core/endpoints/sovereigntyEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/sovereigntyEndpoints.js +2 -7
- package/dist/core/endpoints/universeEndpoints.d.ts +2 -6
- package/dist/core/endpoints/universeEndpoints.d.ts.map +1 -1
- package/dist/core/endpoints/universeEndpoints.js +2 -2
- package/dist/core/rateLimiter/RateLimiter.d.ts.map +1 -1
- package/dist/core/rateLimiter/RateLimiter.js +5 -11
- package/dist/core/util/headersUtil.d.ts.map +1 -1
- package/dist/core/util/headersUtil.js +2 -1
- package/dist/core/util/testHelpers.d.ts +0 -2
- package/dist/core/util/testHelpers.d.ts.map +1 -1
- package/dist/core/util/testHelpers.js +3 -19
- package/dist/core/util/validation.js +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/testing/TestDataFactory.d.ts +8 -2
- package/dist/testing/TestDataFactory.d.ts.map +1 -1
- package/dist/testing/TestDataFactory.js +86 -1
- package/dist/types/access-lists.d.ts +11 -0
- package/dist/types/access-lists.d.ts.map +1 -0
- package/dist/types/api-responses.d.ts +3 -0
- package/dist/types/api-responses.d.ts.map +1 -1
- package/dist/types/api-responses.js +3 -0
- package/dist/types/mercenary.d.ts +19 -0
- package/dist/types/mercenary.d.ts.map +1 -0
- package/dist/types/mercenary.js +2 -0
- package/dist/types/skyhooks.d.ts +27 -0
- package/dist/types/skyhooks.d.ts.map +1 -0
- package/dist/types/skyhooks.js +2 -0
- package/dist/types/sovereignty.d.ts +11 -9
- package/dist/types/sovereignty.d.ts.map +1 -1
- package/package.json +181 -156
- package/dist/api/alliances/getAllianceById.js +0 -17
- package/dist/api/alliances/getAllianceContactLabels.js +0 -13
- package/dist/api/alliances/getAllianceContacts.js +0 -13
- package/dist/api/alliances/getAllianceCorporations.js +0 -13
- package/dist/api/alliances/getAllianceIcons.js +0 -13
- package/dist/api/alliances/getAlliances.js +0 -13
- package/dist/api/assets/getCharacterAssets.js +0 -13
- package/dist/api/assets/getCorporationAssets.js +0 -13
- package/dist/api/assets/postCharacterAssetLocations.js +0 -13
- package/dist/api/assets/postCharacterAssetNames.js +0 -13
- package/dist/api/assets/postCorporationAssetLocations.js +0 -13
- package/dist/api/assets/postCorporationAssetNames.js +0 -13
- package/dist/api/bookmarks/getCharacterBookmarkFolders.js +0 -13
- package/dist/api/bookmarks/getCharacterBookmarks.js +0 -13
- package/dist/api/bookmarks/getCorporationBookmarkFolders.js +0 -13
- package/dist/api/bookmarks/getCorporationBookmarks.js +0 -13
- package/dist/api/calendar/getCalendarEventById.js +0 -13
- package/dist/api/calendar/getCalendarEvents.js +0 -13
- package/dist/api/calendar/getEventAttendees.js +0 -13
- package/dist/api/calendar/respondToCalendarEvent.js +0 -14
- package/dist/api/characters/getAgentsResearch.js +0 -13
- package/dist/api/characters/getBlueprints.js +0 -13
- package/dist/api/characters/getCharacterPublicInfo.js +0 -13
- package/dist/api/characters/getCharacterRoles.js +0 -13
- package/dist/api/characters/getCharacterStandings.js +0 -13
- package/dist/api/characters/getCharacterTitles.js +0 -13
- package/dist/api/characters/getContactNotifications.js +0 -13
- package/dist/api/characters/getCorporationHistory.js +0 -13
- package/dist/api/characters/getJumpFatigue.js +0 -13
- package/dist/api/characters/getMedals.js +0 -13
- package/dist/api/characters/getNotifications.js +0 -13
- package/dist/api/characters/getPortrait.js +0 -13
- package/dist/api/characters/postCSPAChargeCost.js +0 -13
- package/dist/api/characters/postCharacterAffiliations.js +0 -14
- package/dist/api/clones/getClones.js +0 -14
- package/dist/api/clones/getImplants.js +0 -14
- package/dist/api/clones/postJumpCloneActivation.js +0 -14
- package/dist/api/contacts/deleteCharacterContacts.js +0 -13
- package/dist/api/contacts/getAllianceContactLabels.js +0 -13
- package/dist/api/contacts/getAllianceContacts.js +0 -13
- package/dist/api/contacts/getCharacterContactLabels.js +0 -13
- package/dist/api/contacts/getCharacterContacts.js +0 -13
- package/dist/api/contacts/getCorporationContactLabels.js +0 -13
- package/dist/api/contacts/getCorporationContacts.js +0 -13
- package/dist/api/contacts/postCharacterContacts.js +0 -13
- package/dist/api/contacts/putCharacterContacts.js +0 -13
- package/dist/api/contracts/getCharacterContractBids.js +0 -13
- package/dist/api/contracts/getCharacterContractItems.js +0 -13
- package/dist/api/contracts/getCharacterContracts.js +0 -13
- package/dist/api/contracts/getCorporationContractBids.js +0 -13
- package/dist/api/contracts/getCorporationContractItems.js +0 -13
- package/dist/api/contracts/getCorporationContracts.js +0 -13
- package/dist/api/contracts/getPublicContractBids.js +0 -13
- package/dist/api/contracts/getPublicContractItems.js +0 -13
- package/dist/api/contracts/getPublicContracts.js +0 -13
- package/dist/api/corporations/getCorporationAllianceHistory.js +0 -13
- package/dist/api/corporations/getCorporationAlscLogs.js +0 -13
- package/dist/api/corporations/getCorporationBlueprints.js +0 -13
- package/dist/api/corporations/getCorporationDivisions.js +0 -13
- package/dist/api/corporations/getCorporationFacilities.js +0 -13
- package/dist/api/corporations/getCorporationIcon.js +0 -13
- package/dist/api/corporations/getCorporationInfo.js +0 -13
- package/dist/api/corporations/getCorporationIssuedMedals.js +0 -13
- package/dist/api/corporations/getCorporationMedals.js +0 -13
- package/dist/api/corporations/getCorporationMemberLimit.js +0 -13
- package/dist/api/corporations/getCorporationMemberRoles.js +0 -13
- package/dist/api/corporations/getCorporationMemberRolesHistory.js +0 -13
- package/dist/api/corporations/getCorporationMemberTracking.js +0 -13
- package/dist/api/corporations/getCorporationMembers.js +0 -13
- package/dist/api/corporations/getCorporationMembersTitles.js +0 -13
- package/dist/api/corporations/getCorporationProjects.js +0 -13
- package/dist/api/corporations/getCorporationShareholders.js +0 -13
- package/dist/api/corporations/getCorporationStandings.js +0 -13
- package/dist/api/corporations/getCorporationStarbaseDetail.js +0 -13
- package/dist/api/corporations/getCorporationStarbases.js +0 -13
- package/dist/api/corporations/getCorporationStructures.js +0 -13
- package/dist/api/corporations/getCorporationTitles.js +0 -13
- package/dist/api/corporations/getNpcCorporations.js +0 -13
- package/dist/api/dogma/getDogmaAttributeById.js +0 -13
- package/dist/api/dogma/getDogmaAttributes.js +0 -13
- package/dist/api/dogma/getDogmaDynamicItemAttributes.js +0 -13
- package/dist/api/dogma/getDogmaEffectById.js +0 -13
- package/dist/api/dogma/getDogmaEffects.js +0 -13
- package/dist/api/factions/getCharacterFactionWarfareStats.js +0 -13
- package/dist/api/factions/getCharacterLeaderboards.js +0 -13
- package/dist/api/factions/getCorporationFactionWarfareStats.js +0 -13
- package/dist/api/factions/getCorporationLeaderboards.js +0 -13
- package/dist/api/factions/getFactionLeaderboards.js +0 -13
- package/dist/api/factions/getFactionWarfareStats.js +0 -13
- package/dist/api/factions/getFactionWarfareSystems.js +0 -13
- package/dist/api/factions/getFactionWarfareWars.js +0 -13
- package/dist/api/fittings/deleteCharacterFitting.js +0 -13
- package/dist/api/fittings/getCharacterFittings.js +0 -13
- package/dist/api/fittings/postCharacterFittings.js +0 -13
- package/dist/api/fleets/deleteFleetMember.js +0 -13
- package/dist/api/fleets/deleteFleetSquad.js +0 -13
- package/dist/api/fleets/deleteFleetWing.js +0 -13
- package/dist/api/fleets/getCharacterFleetInfo.js +0 -13
- package/dist/api/fleets/getFleetInfo.js +0 -13
- package/dist/api/fleets/getFleetMembers.js +0 -13
- package/dist/api/fleets/getFleetWings.js +0 -13
- package/dist/api/fleets/postFleetInvitation.js +0 -13
- package/dist/api/fleets/postFleetSquad.js +0 -14
- package/dist/api/fleets/postFleetWing.js +0 -13
- package/dist/api/fleets/putFleetMember.js +0 -13
- package/dist/api/fleets/putFleetSquad.js +0 -13
- package/dist/api/fleets/putFleetWing.js +0 -14
- package/dist/api/fleets/updateFleet.js +0 -13
- package/dist/api/incursions/getIncursions.js +0 -13
- package/dist/api/industry/getCharacterIndustryJobs.js +0 -13
- package/dist/api/industry/getCharacterMiningLedger.js +0 -13
- package/dist/api/industry/getCorporationIndustryJobs.js +0 -13
- package/dist/api/industry/getCorporationMiningObserver.js +0 -13
- package/dist/api/industry/getCorporationMiningObservers.js +0 -13
- package/dist/api/industry/getIndustryFacilities.js +0 -13
- package/dist/api/industry/getIndustrySystems.js +0 -13
- package/dist/api/industry/getMoonExtractionTimers.js +0 -13
- package/dist/api/insurance/getInsurancePrices.js +0 -13
- package/dist/api/killmails/getCharacterRecentKillmails.js +0 -13
- package/dist/api/killmails/getCorporationRecentKillmails.js +0 -13
- package/dist/api/killmails/getKillmail.js +0 -13
- package/dist/api/location/getCharacterLocation.js +0 -13
- package/dist/api/location/getCharacterOnline.js +0 -13
- package/dist/api/location/getCharacterShip.js +0 -13
- package/dist/api/loyalty/getLoyaltyPoints.js +0 -13
- package/dist/api/loyalty/getLoyaltyStoreOffers.js +0 -13
- package/dist/api/mail/deleteCharacterMail.js +0 -13
- package/dist/api/mail/deleteCharacterMailLabel.js +0 -13
- package/dist/api/mail/deleteCharacterMailLabel.test.js +0 -21
- package/dist/api/mail/getCharacerMailingLists.test.js +0 -33
- package/dist/api/mail/getCharacterMail.js +0 -13
- package/dist/api/mail/getCharacterMailHeaders.js +0 -13
- package/dist/api/mail/getCharacterMailLabels.js +0 -13
- package/dist/api/mail/getCharacterMailingLists.js +0 -13
- package/dist/api/mail/postCharacterMail.js +0 -13
- package/dist/api/mail/postCharacterMailLabels.js +0 -13
- package/dist/api/mail/putCharacterMail.js +0 -13
- package/dist/api/market/getCharacterOrderHistory.js +0 -13
- package/dist/api/market/getCharacterOrders.js +0 -13
- package/dist/api/market/getCorporationOrderHistory.js +0 -13
- package/dist/api/market/getCorporationOrders.js +0 -13
- package/dist/api/market/getMarketGroupInformation.js +0 -13
- package/dist/api/market/getMarketGroups.js +0 -13
- package/dist/api/market/getMarketHistory.js +0 -13
- package/dist/api/market/getMarketOrders.js +0 -13
- package/dist/api/market/getMarketOrdersInStructure.js +0 -13
- package/dist/api/market/getMarketPrices.js +0 -13
- package/dist/api/market/getMarketTypes.js +0 -13
- package/dist/api/meta/getSwaggerJson.js +0 -13
- package/dist/api/meta/getSwaggerYaml.js +0 -37
- package/dist/api/opportunities/getCharacterOpportunities.js +0 -13
- package/dist/api/opportunities/getOpportunitiesGroupById.js +0 -13
- package/dist/api/opportunities/getOpportunitiesGroups.js +0 -13
- package/dist/api/opportunities/getOpportunitiesTaskById.js +0 -13
- package/dist/api/opportunities/getOpportunitiesTasks.js +0 -13
- package/dist/api/pi/getColonies.js +0 -13
- package/dist/api/pi/getColonyLayout.js +0 -13
- package/dist/api/pi/getCorporationCustomsOffices.js +0 -13
- package/dist/api/pi/getSchematicInformation.js +0 -13
- package/dist/api/route/getRoute.js +0 -13
- package/dist/api/search/getCharacterSearch.js +0 -13
- package/dist/api/skills/getCharacterAttributes.js +0 -13
- package/dist/api/skills/getCharacterSkillQueue.js +0 -13
- package/dist/api/skills/getCharacterSkills.js +0 -13
- package/dist/api/sovereignty/getSovereigntyCampaigns.js +0 -13
- package/dist/api/sovereignty/getSovereigntyMap.js +0 -13
- package/dist/api/sovereignty/getSovereigntyStructures.js +0 -13
- package/dist/api/status/getStatus.js +0 -13
- package/dist/api/ui/postAutopilotWaypoint.js +0 -13
- package/dist/api/ui/postOpenContractWindow.js +0 -13
- package/dist/api/ui/postOpenInformationWindow.js +0 -13
- package/dist/api/ui/postOpenMarketDetailsWindow.js +0 -13
- package/dist/api/ui/postOpenNewMailWindow.js +0 -13
- package/dist/api/universe/getAncestries.js +0 -13
- package/dist/api/universe/getAsteroidBeltInfo.js +0 -13
- package/dist/api/universe/getBloodlines.js +0 -13
- package/dist/api/universe/getConstellationById.js +0 -13
- package/dist/api/universe/getConstellations.js +0 -13
- package/dist/api/universe/getFactions.js +0 -13
- package/dist/api/universe/getGraphicById.js +0 -13
- package/dist/api/universe/getGraphics.js +0 -13
- package/dist/api/universe/getItemCategories.js +0 -13
- package/dist/api/universe/getItemCategoryById.js +0 -13
- package/dist/api/universe/getItemGroupById.js +0 -13
- package/dist/api/universe/getItemGroups.js +0 -13
- package/dist/api/universe/getMoonById.js +0 -13
- package/dist/api/universe/getPlanetById.js +0 -13
- package/dist/api/universe/getRaces.js +0 -13
- package/dist/api/universe/getRegionById.js +0 -13
- package/dist/api/universe/getRegions.js +0 -13
- package/dist/api/universe/getSchematicById.js +0 -13
- package/dist/api/universe/getStarById.js +0 -13
- package/dist/api/universe/getStargateById.js +0 -13
- package/dist/api/universe/getStationById.js +0 -13
- package/dist/api/universe/getStructureById.js +0 -13
- package/dist/api/universe/getStructures.js +0 -13
- package/dist/api/universe/getSystemById.js +0 -13
- package/dist/api/universe/getSystemJumps.js +0 -13
- package/dist/api/universe/getSystemKills.js +0 -13
- package/dist/api/universe/getSystems.js +0 -13
- package/dist/api/universe/getTypeById.js +0 -13
- package/dist/api/universe/getTypes.js +0 -13
- package/dist/api/universe/postBulkNamesToIds.js +0 -14
- package/dist/api/universe/postNamesAndCategories.js +0 -14
- package/dist/api/wallet/getCharacterWallet.js +0 -13
- package/dist/api/wallet/getCharacterWalletJournal.js +0 -13
- package/dist/api/wallet/getCharacterWalletTransactions.js +0 -13
- package/dist/api/wallet/getCorporationWalletJournal.js +0 -13
- package/dist/api/wallet/getCorporationWalletTransactions.js +0 -13
- package/dist/api/wallet/getCorporationWallets.js +0 -13
- package/dist/api/wars/getWarById.js +0 -13
- package/dist/api/wars/getWarKillmails.js +0 -13
- package/dist/api/wars/getWars.js +0 -13
- package/dist/builders/AllianceApiBuilder.js +0 -13
- package/dist/builders/AssetsApiBuilder.js +0 -13
- package/dist/builders/BookmarkApiBuilder.js +0 -13
- package/dist/builders/CalendarApiBuilder.js +0 -13
- package/dist/builders/CharacterApiBuilder.js +0 -13
- package/dist/builders/ClonesApiBuilder.js +0 -13
- package/dist/builders/ContactsApiBuilder.js +0 -13
- package/dist/builders/ContractsApiBuilder.js +0 -13
- package/dist/builders/CorporationsApiBuilder.js +0 -13
- package/dist/builders/DogmaApiBuilder.js +0 -13
- package/dist/builders/FactionApiBuilder.js +0 -13
- package/dist/builders/FittingsApiBuilder.js +0 -13
- package/dist/builders/FleetApiBuilder.js +0 -13
- package/dist/builders/IncursionsApiBuilder.js +0 -13
- package/dist/builders/IndustryApiBuilder.js +0 -13
- package/dist/builders/InsuranceApiBuilder.js +0 -13
- package/dist/builders/KillmailsBuilder.js +0 -13
- package/dist/builders/LocationApiBuilder.js +0 -13
- package/dist/builders/LoyaltyApiBuilder.js +0 -13
- package/dist/builders/MailApiBuilder.js +0 -13
- package/dist/builders/MarketApiBuilder.js +0 -13
- package/dist/builders/MetaApiBuilder.js +0 -13
- package/dist/builders/OpportunitiesApiBuilder.js +0 -13
- package/dist/builders/PiApiBuilder.js +0 -13
- package/dist/builders/RouteApiBuilder.js +0 -13
- package/dist/builders/SearchApiBuilder.js +0 -13
- package/dist/builders/SkillsApiBuilder.js +0 -13
- package/dist/builders/SovereigntyApiBuilder.js +0 -13
- package/dist/builders/StatusApiBuilder.js +0 -13
- package/dist/builders/UiApiBuilder.js +0 -13
- package/dist/builders/UniverseApiBuilder.js +0 -13
- package/dist/builders/WalletApiBuilder.js +0 -13
- package/dist/builders/WarsAPIBuilder.js +0 -13
- package/dist/clients/BookmarkClient.js +0 -28
- package/dist/clients/OpportunitiesClient.js +0 -33
- package/dist/config/constants.js +0 -11
- package/dist/core/ApiError.js +0 -11
- package/dist/core/container/Container.js +0 -145
- package/dist/core/errors/ApiError.js +0 -129
- package/dist/core/factory/ApiFactory.js +0 -170
- package/dist/core/logger/index.d.ts +0 -2
- package/dist/core/logger/index.d.ts.map +0 -1
- package/dist/core/logger/index.js +0 -8
- package/dist/core/util/file.js +0 -26
- package/dist/core/util/inputValidation.js +0 -9
- package/dist/core/util/network.js +0 -15
- package/dist/core/util/request.js +0 -21
- package/dist/testing/TestHelpers.js +0 -205
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/dist/{core/IAPIBuilder.js → types/access-lists.js} +0 -0
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ErrorHandler = exports.ApiError = exports.ApiErrorType = void 0;
|
|
4
|
-
var ApiErrorType;
|
|
5
|
-
(function (ApiErrorType) {
|
|
6
|
-
ApiErrorType["NETWORK_ERROR"] = "NETWORK_ERROR";
|
|
7
|
-
ApiErrorType["AUTHENTICATION_ERROR"] = "AUTHENTICATION_ERROR";
|
|
8
|
-
ApiErrorType["AUTHORIZATION_ERROR"] = "AUTHORIZATION_ERROR";
|
|
9
|
-
ApiErrorType["RATE_LIMIT_ERROR"] = "RATE_LIMIT_ERROR";
|
|
10
|
-
ApiErrorType["SERVER_ERROR"] = "SERVER_ERROR";
|
|
11
|
-
ApiErrorType["CLIENT_ERROR"] = "CLIENT_ERROR";
|
|
12
|
-
ApiErrorType["VALIDATION_ERROR"] = "VALIDATION_ERROR";
|
|
13
|
-
ApiErrorType["NOT_FOUND_ERROR"] = "NOT_FOUND_ERROR";
|
|
14
|
-
ApiErrorType["TIMEOUT_ERROR"] = "TIMEOUT_ERROR";
|
|
15
|
-
ApiErrorType["UNKNOWN_ERROR"] = "UNKNOWN_ERROR";
|
|
16
|
-
})(ApiErrorType || (exports.ApiErrorType = ApiErrorType = {}));
|
|
17
|
-
class ApiError extends Error {
|
|
18
|
-
constructor(message, type = ApiErrorType.UNKNOWN_ERROR, statusCode, details, requestId) {
|
|
19
|
-
super(message);
|
|
20
|
-
this.name = 'ApiError';
|
|
21
|
-
this.type = type;
|
|
22
|
-
this.statusCode = statusCode;
|
|
23
|
-
this.details = details;
|
|
24
|
-
this.timestamp = new Date();
|
|
25
|
-
this.requestId = requestId;
|
|
26
|
-
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
27
|
-
if (Error.captureStackTrace) {
|
|
28
|
-
Error.captureStackTrace(this, ApiError);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
static fromHttpStatus(statusCode, message, details, requestId) {
|
|
32
|
-
let type;
|
|
33
|
-
switch (Math.floor(statusCode / 100)) {
|
|
34
|
-
case 4:
|
|
35
|
-
if (statusCode === 401) {
|
|
36
|
-
type = ApiErrorType.AUTHENTICATION_ERROR;
|
|
37
|
-
}
|
|
38
|
-
else if (statusCode === 403) {
|
|
39
|
-
type = ApiErrorType.AUTHORIZATION_ERROR;
|
|
40
|
-
}
|
|
41
|
-
else if (statusCode === 404) {
|
|
42
|
-
type = ApiErrorType.NOT_FOUND_ERROR;
|
|
43
|
-
}
|
|
44
|
-
else if (statusCode === 429) {
|
|
45
|
-
type = ApiErrorType.RATE_LIMIT_ERROR;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
type = ApiErrorType.CLIENT_ERROR;
|
|
49
|
-
}
|
|
50
|
-
break;
|
|
51
|
-
case 5:
|
|
52
|
-
type = ApiErrorType.SERVER_ERROR;
|
|
53
|
-
break;
|
|
54
|
-
default:
|
|
55
|
-
type = ApiErrorType.UNKNOWN_ERROR;
|
|
56
|
-
}
|
|
57
|
-
return new ApiError(message, type, statusCode, details, requestId);
|
|
58
|
-
}
|
|
59
|
-
static networkError(message = 'Network connection failed', details) {
|
|
60
|
-
return new ApiError(message, ApiErrorType.NETWORK_ERROR, undefined, details);
|
|
61
|
-
}
|
|
62
|
-
static timeoutError(message = 'Request timeout', details) {
|
|
63
|
-
return new ApiError(message, ApiErrorType.TIMEOUT_ERROR, undefined, details);
|
|
64
|
-
}
|
|
65
|
-
static validationError(message, details) {
|
|
66
|
-
return new ApiError(message, ApiErrorType.VALIDATION_ERROR, 400, details);
|
|
67
|
-
}
|
|
68
|
-
toJSON() {
|
|
69
|
-
return {
|
|
70
|
-
name: this.name,
|
|
71
|
-
message: this.message,
|
|
72
|
-
type: this.type,
|
|
73
|
-
statusCode: this.statusCode,
|
|
74
|
-
details: this.details,
|
|
75
|
-
timestamp: this.timestamp.toISOString(),
|
|
76
|
-
requestId: this.requestId,
|
|
77
|
-
stack: this.stack
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.ApiError = ApiError;
|
|
82
|
-
class ErrorHandler {
|
|
83
|
-
static handle(error, requestId) {
|
|
84
|
-
var _a, _b, _c;
|
|
85
|
-
if (error instanceof ApiError) {
|
|
86
|
-
throw error;
|
|
87
|
-
}
|
|
88
|
-
// Handle Axios/HTTP errors
|
|
89
|
-
if (error.response) {
|
|
90
|
-
const statusCode = error.response.status;
|
|
91
|
-
const message = ((_a = error.response.data) === null || _a === void 0 ? void 0 : _a.error) ||
|
|
92
|
-
((_b = error.response.data) === null || _b === void 0 ? void 0 : _b.message) ||
|
|
93
|
-
error.message ||
|
|
94
|
-
`HTTP ${statusCode} Error`;
|
|
95
|
-
throw ApiError.fromHttpStatus(statusCode, message, error.response.data, requestId);
|
|
96
|
-
}
|
|
97
|
-
// Handle network errors
|
|
98
|
-
if (error.code === 'ECONNREFUSED' || error.code === 'ENOTFOUND' || error.code === 'ECONNRESET') {
|
|
99
|
-
throw ApiError.networkError(`Network error: ${error.message}`, { code: error.code });
|
|
100
|
-
}
|
|
101
|
-
// Handle timeout errors
|
|
102
|
-
if (error.code === 'ECONNABORTED' || ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('timeout'))) {
|
|
103
|
-
throw ApiError.timeoutError(`Request timeout: ${error.message}`);
|
|
104
|
-
}
|
|
105
|
-
// Default to unknown error
|
|
106
|
-
throw new ApiError(error.message || 'An unknown error occurred', ApiErrorType.UNKNOWN_ERROR, undefined, error, requestId);
|
|
107
|
-
}
|
|
108
|
-
static isRetryable(error) {
|
|
109
|
-
return [
|
|
110
|
-
ApiErrorType.NETWORK_ERROR,
|
|
111
|
-
ApiErrorType.TIMEOUT_ERROR,
|
|
112
|
-
ApiErrorType.SERVER_ERROR,
|
|
113
|
-
ApiErrorType.RATE_LIMIT_ERROR
|
|
114
|
-
].includes(error.type);
|
|
115
|
-
}
|
|
116
|
-
static getRetryDelay(error, attempt) {
|
|
117
|
-
var _a, _b;
|
|
118
|
-
if (error.type === ApiErrorType.RATE_LIMIT_ERROR) {
|
|
119
|
-
// Check for Retry-After header in details
|
|
120
|
-
const retryAfter = (_b = (_a = error.details) === null || _a === void 0 ? void 0 : _a.headers) === null || _b === void 0 ? void 0 : _b['retry-after'];
|
|
121
|
-
if (retryAfter) {
|
|
122
|
-
return parseInt(retryAfter) * 1000; // Convert to milliseconds
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
// Exponential backoff: 1s, 2s, 4s, 8s, etc.
|
|
126
|
-
return Math.min(1000 * Math.pow(2, attempt - 1), 30000); // Max 30 seconds
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.ErrorHandler = ErrorHandler;
|
|
@@ -1,170 +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.apiFactory = exports.ApiFactory = exports.ApiModule = void 0;
|
|
7
|
-
const ApiClient_1 = require("../ApiClient");
|
|
8
|
-
const Container_1 = require("../container/Container");
|
|
9
|
-
const ApiError_1 = require("../errors/ApiError");
|
|
10
|
-
const logger_1 = __importDefault(require("../logger/logger"));
|
|
11
|
-
class ApiModule {
|
|
12
|
-
constructor(client, container) {
|
|
13
|
-
this.client = client;
|
|
14
|
-
this.container = container;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ApiModule = ApiModule;
|
|
18
|
-
class ApiFactory {
|
|
19
|
-
constructor() {
|
|
20
|
-
this.clients = new Map();
|
|
21
|
-
this.modules = new Map();
|
|
22
|
-
this.container = new Container_1.Container({
|
|
23
|
-
enableLogging: process.env.NODE_ENV === 'development',
|
|
24
|
-
enableCircularDependencyDetection: true
|
|
25
|
-
});
|
|
26
|
-
this.registerCoreServices();
|
|
27
|
-
}
|
|
28
|
-
static getInstance() {
|
|
29
|
-
if (!this.instance) {
|
|
30
|
-
this.instance = new ApiFactory();
|
|
31
|
-
}
|
|
32
|
-
return this.instance;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Register core services in the container
|
|
36
|
-
*/
|
|
37
|
-
registerCoreServices() {
|
|
38
|
-
this.container.registerInstance('logger', logger_1.default);
|
|
39
|
-
this.container.registerInstance('errorHandler', ApiError_1.ErrorHandler);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Create and register an API client
|
|
43
|
-
*/
|
|
44
|
-
createClient(name, config) {
|
|
45
|
-
try {
|
|
46
|
-
const client = new ApiClient_1.ApiClient(config.clientId, config.baseUrl, config.accessToken);
|
|
47
|
-
this.clients.set(name, client);
|
|
48
|
-
this.container.registerInstance(`client:${name}`, client);
|
|
49
|
-
logger_1.default.info(`API client '${name}' created and registered`);
|
|
50
|
-
return client;
|
|
51
|
-
}
|
|
52
|
-
catch (error) {
|
|
53
|
-
logger_1.default.error(`Failed to create API client '${name}':`, error);
|
|
54
|
-
throw ApiError_1.ErrorHandler.handle(error);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get an existing API client
|
|
59
|
-
*/
|
|
60
|
-
getClient(name) {
|
|
61
|
-
const client = this.clients.get(name);
|
|
62
|
-
if (!client) {
|
|
63
|
-
throw new ApiError_1.ApiError(`API client '${name}' not found. Available clients: ${Array.from(this.clients.keys()).join(', ')}`, ApiError_1.ApiErrorType.CLIENT_ERROR);
|
|
64
|
-
}
|
|
65
|
-
return client;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Register an API module
|
|
69
|
-
*/
|
|
70
|
-
registerModule(module) {
|
|
71
|
-
try {
|
|
72
|
-
// Check dependencies
|
|
73
|
-
if (module.config.dependencies) {
|
|
74
|
-
for (const dependency of module.config.dependencies) {
|
|
75
|
-
if (!this.container.has(dependency)) {
|
|
76
|
-
throw new ApiError_1.ApiError(`Module '${module.config.name}' requires dependency '${dependency}' which is not registered`, ApiError_1.ApiErrorType.VALIDATION_ERROR);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// Register the module
|
|
81
|
-
module.register();
|
|
82
|
-
this.modules.set(module.config.name, module);
|
|
83
|
-
this.container.registerInstance(`module:${module.config.name}`, module);
|
|
84
|
-
logger_1.default.info(`API module '${module.config.name}' v${module.config.version} registered`);
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
logger_1.default.error(`Failed to register module '${module.config.name}':`, error);
|
|
88
|
-
throw ApiError_1.ErrorHandler.handle(error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Get a service from the container
|
|
93
|
-
*/
|
|
94
|
-
getService(token) {
|
|
95
|
-
try {
|
|
96
|
-
return this.container.resolve(token);
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
logger_1.default.error(`Failed to resolve service '${token}':`, error);
|
|
100
|
-
throw ApiError_1.ErrorHandler.handle(error);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Register a service in the container
|
|
105
|
-
*/
|
|
106
|
-
registerService(token, factory, singleton = false) {
|
|
107
|
-
try {
|
|
108
|
-
this.container.register(token, factory, singleton);
|
|
109
|
-
logger_1.default.debug(`Service '${token}' registered (singleton: ${singleton})`);
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
logger_1.default.error(`Failed to register service '${token}':`, error);
|
|
113
|
-
throw ApiError_1.ErrorHandler.handle(error);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
/**
|
|
117
|
-
* Get all registered clients
|
|
118
|
-
*/
|
|
119
|
-
getRegisteredClients() {
|
|
120
|
-
return Array.from(this.clients.keys());
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Get all registered modules
|
|
124
|
-
*/
|
|
125
|
-
getRegisteredModules() {
|
|
126
|
-
return Array.from(this.modules.keys());
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Health check for all registered clients
|
|
130
|
-
*/
|
|
131
|
-
async healthCheck() {
|
|
132
|
-
const results = {};
|
|
133
|
-
for (const [name, client] of this.clients) {
|
|
134
|
-
try {
|
|
135
|
-
// Perform a simple health check (this would need to be implemented in ApiClient)
|
|
136
|
-
// For now, just check if client exists and has required properties
|
|
137
|
-
results[name] = !!(client && client.getLink());
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
logger_1.default.warn(`Health check failed for client '${name}':`, error);
|
|
141
|
-
results[name] = false;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return results;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Shutdown factory and cleanup resources
|
|
148
|
-
*/
|
|
149
|
-
async shutdown() {
|
|
150
|
-
try {
|
|
151
|
-
// Cleanup modules
|
|
152
|
-
for (const [name, module] of this.modules) {
|
|
153
|
-
logger_1.default.debug(`Shutting down module: ${name}`);
|
|
154
|
-
// If modules have cleanup methods, call them here
|
|
155
|
-
}
|
|
156
|
-
// Clear containers
|
|
157
|
-
this.container.clear();
|
|
158
|
-
this.clients.clear();
|
|
159
|
-
this.modules.clear();
|
|
160
|
-
logger_1.default.info('ApiFactory shutdown completed');
|
|
161
|
-
}
|
|
162
|
-
catch (error) {
|
|
163
|
-
logger_1.default.error('Error during ApiFactory shutdown:', error);
|
|
164
|
-
throw ApiError_1.ErrorHandler.handle(error);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
exports.ApiFactory = ApiFactory;
|
|
169
|
-
// Export singleton instance
|
|
170
|
-
exports.apiFactory = ApiFactory.getInstance();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/logger/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -1,8 +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.default = void 0;
|
|
7
|
-
var logger_1 = require("./logger");
|
|
8
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(logger_1).default; } });
|
package/dist/core/util/file.js
DELETED
|
@@ -1,26 +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.log = exports.getSettings = exports.checkForConfig = void 0;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const checkForConfig = () => {
|
|
10
|
-
const configPath = path_1.default.join(__dirname, '../../config/esi.json');
|
|
11
|
-
return fs_1.default.existsSync(configPath);
|
|
12
|
-
};
|
|
13
|
-
exports.checkForConfig = checkForConfig;
|
|
14
|
-
const getSettings = () => {
|
|
15
|
-
const configPath = path_1.default.join(__dirname, '../../config/esi.json');
|
|
16
|
-
if (fs_1.default.existsSync(configPath)) {
|
|
17
|
-
const config = fs_1.default.readFileSync(configPath, 'utf8');
|
|
18
|
-
return JSON.parse(config);
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
};
|
|
22
|
-
exports.getSettings = getSettings;
|
|
23
|
-
const log = (message, level = 'INFO') => {
|
|
24
|
-
console.log(`[${level}] ${message}`);
|
|
25
|
-
};
|
|
26
|
-
exports.log = log;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inputValidation = void 0;
|
|
4
|
-
const inputValidation = ({ input, type, message }) => {
|
|
5
|
-
if (typeof input !== type) {
|
|
6
|
-
throw new Error(message);
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
exports.inputValidation = inputValidation;
|
|
@@ -1,15 +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.request = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const request = async ({ subUrl, needsAuth = false }) => {
|
|
9
|
-
const baseUrl = 'https://esi.evetech.net/latest/';
|
|
10
|
-
const url = `${baseUrl}${subUrl}`;
|
|
11
|
-
const headers = needsAuth ? { Authorization: `Bearer ${process.env.AUTH_TOKEN}` } : {};
|
|
12
|
-
const response = await axios_1.default.get(url, { headers });
|
|
13
|
-
return response.data;
|
|
14
|
-
};
|
|
15
|
-
exports.request = request;
|
|
@@ -1,21 +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.inputValidation = exports.request = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const request = async ({ subUrl, needsAuth = false }) => {
|
|
9
|
-
const baseUrl = 'https://esi.evetech.net/latest/';
|
|
10
|
-
const url = `${baseUrl}${subUrl}`;
|
|
11
|
-
const headers = needsAuth ? { Authorization: `Bearer ${process.env.AUTH_TOKEN}` } : {};
|
|
12
|
-
const response = await axios_1.default.get(url, { headers });
|
|
13
|
-
return response.data;
|
|
14
|
-
};
|
|
15
|
-
exports.request = request;
|
|
16
|
-
const inputValidation = ({ input, type, message }) => {
|
|
17
|
-
if (typeof input !== type) {
|
|
18
|
-
throw new Error(message);
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
exports.inputValidation = inputValidation;
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHeaders = exports.getBody = exports.TestAssertions = exports.TestScenarios = exports.MockApiClient = exports.TestDataFactory = void 0;
|
|
4
|
-
exports.createMockApiClient = createMockApiClient;
|
|
5
|
-
const ApiClient_1 = require("../core/ApiClient");
|
|
6
|
-
const ApiError_1 = require("../core/errors/ApiError");
|
|
7
|
-
class TestDataFactory {
|
|
8
|
-
static createAllianceInfo(overrides = {}) {
|
|
9
|
-
return Object.assign({ alliance_id: 99005338, name: 'Goonswarm Federation', ticker: 'CONDI', creator_id: 1689391488, creator_corporation_id: 1344654522, executor_corporation_id: 1344654522, date_founded: '2010-06-01T00:00:00Z', faction_id: 500001 }, overrides);
|
|
10
|
-
}
|
|
11
|
-
static createAllianceContact(overrides = {}) {
|
|
12
|
-
return Object.assign({ contact_id: 1689391488, contact_type: 'character', standing: 10.0, label_ids: [1, 2] }, overrides);
|
|
13
|
-
}
|
|
14
|
-
static createAllianceContactLabel(overrides = {}) {
|
|
15
|
-
return Object.assign({ label_id: 1, label_name: 'Test Label' }, overrides);
|
|
16
|
-
}
|
|
17
|
-
static createError(type, statusCode) {
|
|
18
|
-
const messages = {
|
|
19
|
-
[ApiError_1.ApiErrorType.NETWORK_ERROR]: 'Network connection failed',
|
|
20
|
-
[ApiError_1.ApiErrorType.AUTHENTICATION_ERROR]: 'Authentication failed',
|
|
21
|
-
[ApiError_1.ApiErrorType.AUTHORIZATION_ERROR]: 'Access denied',
|
|
22
|
-
[ApiError_1.ApiErrorType.RATE_LIMIT_ERROR]: 'Rate limit exceeded',
|
|
23
|
-
[ApiError_1.ApiErrorType.SERVER_ERROR]: 'Internal server error',
|
|
24
|
-
[ApiError_1.ApiErrorType.CLIENT_ERROR]: 'Bad request',
|
|
25
|
-
[ApiError_1.ApiErrorType.VALIDATION_ERROR]: 'Validation failed',
|
|
26
|
-
[ApiError_1.ApiErrorType.NOT_FOUND_ERROR]: 'Resource not found',
|
|
27
|
-
[ApiError_1.ApiErrorType.TIMEOUT_ERROR]: 'Request timeout',
|
|
28
|
-
[ApiError_1.ApiErrorType.UNKNOWN_ERROR]: 'Unknown error occurred'
|
|
29
|
-
};
|
|
30
|
-
return new ApiError_1.ApiError(messages[type], type, statusCode);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.TestDataFactory = TestDataFactory;
|
|
34
|
-
class MockApiClient {
|
|
35
|
-
constructor(config = {}) {
|
|
36
|
-
this.config = Object.assign({ delay: 0, failureRate: 0, networkErrors: false, timeoutErrors: false, serverErrors: false }, config);
|
|
37
|
-
}
|
|
38
|
-
async mockRequest(data) {
|
|
39
|
-
// Simulate network delay
|
|
40
|
-
if (this.config.delay && this.config.delay > 0) {
|
|
41
|
-
await this.delay(this.config.delay);
|
|
42
|
-
}
|
|
43
|
-
// Simulate random failures
|
|
44
|
-
if (this.config.failureRate && Math.random() < this.config.failureRate) {
|
|
45
|
-
throw this.generateRandomError();
|
|
46
|
-
}
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
async delay(ms) {
|
|
50
|
-
return new Promise(resolve => setTimeout(resolve, ms));
|
|
51
|
-
}
|
|
52
|
-
generateRandomError() {
|
|
53
|
-
const errorTypes = [];
|
|
54
|
-
if (this.config.networkErrors)
|
|
55
|
-
errorTypes.push(ApiError_1.ApiErrorType.NETWORK_ERROR);
|
|
56
|
-
if (this.config.timeoutErrors)
|
|
57
|
-
errorTypes.push(ApiError_1.ApiErrorType.TIMEOUT_ERROR);
|
|
58
|
-
if (this.config.serverErrors)
|
|
59
|
-
errorTypes.push(ApiError_1.ApiErrorType.SERVER_ERROR);
|
|
60
|
-
if (errorTypes.length === 0) {
|
|
61
|
-
errorTypes.push(ApiError_1.ApiErrorType.CLIENT_ERROR);
|
|
62
|
-
}
|
|
63
|
-
const randomType = errorTypes[Math.floor(Math.random() * errorTypes.length)];
|
|
64
|
-
return TestDataFactory.createError(randomType, this.getStatusCodeForError(randomType));
|
|
65
|
-
}
|
|
66
|
-
getStatusCodeForError(type) {
|
|
67
|
-
switch (type) {
|
|
68
|
-
case ApiError_1.ApiErrorType.AUTHENTICATION_ERROR: return 401;
|
|
69
|
-
case ApiError_1.ApiErrorType.AUTHORIZATION_ERROR: return 403;
|
|
70
|
-
case ApiError_1.ApiErrorType.NOT_FOUND_ERROR: return 404;
|
|
71
|
-
case ApiError_1.ApiErrorType.RATE_LIMIT_ERROR: return 429;
|
|
72
|
-
case ApiError_1.ApiErrorType.SERVER_ERROR: return 500;
|
|
73
|
-
case ApiError_1.ApiErrorType.CLIENT_ERROR: return 400;
|
|
74
|
-
default: return 500;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.MockApiClient = MockApiClient;
|
|
79
|
-
class TestScenarios {
|
|
80
|
-
static async testRetryLogic(operation, maxRetries = 3, expectedFailures = 2) {
|
|
81
|
-
let attempts = 0;
|
|
82
|
-
let lastError;
|
|
83
|
-
while (attempts < maxRetries) {
|
|
84
|
-
try {
|
|
85
|
-
attempts++;
|
|
86
|
-
const result = await operation();
|
|
87
|
-
if (attempts <= expectedFailures) {
|
|
88
|
-
throw new Error(`Expected failure on attempt ${attempts}`);
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
catch (error) {
|
|
93
|
-
lastError = error;
|
|
94
|
-
if (attempts >= maxRetries) {
|
|
95
|
-
throw lastError;
|
|
96
|
-
}
|
|
97
|
-
// Wait before retry (exponential backoff)
|
|
98
|
-
await new Promise(resolve => setTimeout(resolve, Math.pow(2, attempts - 1) * 100));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
throw lastError;
|
|
102
|
-
}
|
|
103
|
-
static async testConcurrency(operation, concurrentRequests = 10) {
|
|
104
|
-
const promises = Array(concurrentRequests)
|
|
105
|
-
.fill(null)
|
|
106
|
-
.map(() => operation());
|
|
107
|
-
return Promise.all(promises);
|
|
108
|
-
}
|
|
109
|
-
static async testErrorRecovery(operation, fallbackOperation) {
|
|
110
|
-
try {
|
|
111
|
-
return await operation();
|
|
112
|
-
}
|
|
113
|
-
catch (error) {
|
|
114
|
-
console.warn('Primary operation failed, trying fallback:', error);
|
|
115
|
-
return await fallbackOperation();
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
exports.TestScenarios = TestScenarios;
|
|
120
|
-
class TestAssertions {
|
|
121
|
-
static assertValidAllianceInfo(data) {
|
|
122
|
-
if (!data || typeof data !== 'object') {
|
|
123
|
-
throw new Error('Alliance info must be an object');
|
|
124
|
-
}
|
|
125
|
-
const required = ['alliance_id', 'name', 'ticker', 'creator_id', 'creator_corporation_id', 'date_founded'];
|
|
126
|
-
for (const field of required) {
|
|
127
|
-
if (!(field in data)) {
|
|
128
|
-
throw new Error(`Alliance info missing required field: ${field}`);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
if (typeof data.alliance_id !== 'number' || data.alliance_id <= 0) {
|
|
132
|
-
throw new Error('Alliance ID must be a positive number');
|
|
133
|
-
}
|
|
134
|
-
if (typeof data.name !== 'string' || data.name.length === 0) {
|
|
135
|
-
throw new Error('Alliance name must be a non-empty string');
|
|
136
|
-
}
|
|
137
|
-
if (typeof data.ticker !== 'string' || data.ticker.length === 0) {
|
|
138
|
-
throw new Error('Alliance ticker must be a non-empty string');
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
static assertValidError(error) {
|
|
142
|
-
if (!(error instanceof ApiError_1.ApiError)) {
|
|
143
|
-
throw new Error('Expected ApiError instance');
|
|
144
|
-
}
|
|
145
|
-
if (!error.type || !Object.values(ApiError_1.ApiErrorType).includes(error.type)) {
|
|
146
|
-
throw new Error(`Invalid error type: ${error.type}`);
|
|
147
|
-
}
|
|
148
|
-
if (!error.message || error.message.length === 0) {
|
|
149
|
-
throw new Error('Error must have a non-empty message');
|
|
150
|
-
}
|
|
151
|
-
if (!error.timestamp || !(error.timestamp instanceof Date)) {
|
|
152
|
-
throw new Error('Error must have a valid timestamp');
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
static assertResponseTime(startTime, maxMs) {
|
|
156
|
-
const elapsed = Date.now() - startTime;
|
|
157
|
-
if (elapsed > maxMs) {
|
|
158
|
-
throw new Error(`Response time ${elapsed}ms exceeded maximum ${maxMs}ms`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
static assertArrayNotEmpty(array, message) {
|
|
162
|
-
if (!Array.isArray(array) || array.length === 0) {
|
|
163
|
-
throw new Error(message || 'Array must not be empty');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
exports.TestAssertions = TestAssertions;
|
|
168
|
-
function createMockApiClient(config = {}) {
|
|
169
|
-
// This would be a more sophisticated mock in a real implementation
|
|
170
|
-
const mockClient = new ApiClient_1.ApiClient('test-client', 'https://esi.evetech.net', 'mock-token');
|
|
171
|
-
// Override methods for testing
|
|
172
|
-
const originalGetLink = mockClient.getLink;
|
|
173
|
-
mockClient.getLink = function () {
|
|
174
|
-
if (config.networkErrors && Math.random() < 0.1) {
|
|
175
|
-
throw TestDataFactory.createError(ApiError_1.ApiErrorType.NETWORK_ERROR);
|
|
176
|
-
}
|
|
177
|
-
return originalGetLink.call(this);
|
|
178
|
-
};
|
|
179
|
-
return mockClient;
|
|
180
|
-
}
|
|
181
|
-
// Export utility functions that were in the original testHelpers
|
|
182
|
-
const getBody = async (operation) => {
|
|
183
|
-
try {
|
|
184
|
-
return await operation();
|
|
185
|
-
}
|
|
186
|
-
catch (error) {
|
|
187
|
-
if (error instanceof ApiError_1.ApiError) {
|
|
188
|
-
throw error;
|
|
189
|
-
}
|
|
190
|
-
throw new ApiError_1.ApiError('Operation failed', ApiError_1.ApiErrorType.UNKNOWN_ERROR, undefined, error);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
exports.getBody = getBody;
|
|
194
|
-
const getHeaders = (client) => {
|
|
195
|
-
const headers = {
|
|
196
|
-
'Content-Type': 'application/json',
|
|
197
|
-
'User-Agent': 'ESI.ts/2.0.0'
|
|
198
|
-
};
|
|
199
|
-
const authHeader = client.getAuthorizationHeader();
|
|
200
|
-
if (authHeader) {
|
|
201
|
-
headers['Authorization'] = authHeader;
|
|
202
|
-
}
|
|
203
|
-
return headers;
|
|
204
|
-
};
|
|
205
|
-
exports.getHeaders = getHeaders;
|