@xyo-network/api 2.75.0 → 2.75.3
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/dist/browser/Api/Api.d.cts +12 -0
- package/dist/browser/Api/Api.d.cts.map +1 -0
- package/dist/browser/Api/Api.js +3 -155
- package/dist/browser/Api/Api.js.map +1 -1
- package/dist/browser/Api/index.d.cts +2 -0
- package/dist/browser/Api/index.d.cts.map +1 -0
- package/dist/browser/Api/index.js +1 -166
- package/dist/browser/Api/index.js.map +1 -1
- package/dist/browser/Base.d.cts +32 -0
- package/dist/browser/Base.d.cts.map +1 -0
- package/dist/browser/Base.js +7 -8
- package/dist/browser/Base.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.d.cts +12 -0
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js +5 -16
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApi.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +10 -0
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +2 -3
- package/dist/browser/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts +5 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts +12 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +3 -4
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts +3 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +2 -11
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts +12 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +3 -4
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts +2 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +1 -11
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts +18 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts +5 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts +6 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +2 -3
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts +8 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts +12 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +3 -4
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts +3 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +2 -11
- package/dist/browser/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Queries/index.d.cts +7 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Queries/index.js +6 -42
- package/dist/browser/Diviner/LocationDiviner/Queries/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts +13 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +1 -2
- package/dist/browser/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts +21 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js +1 -2
- package/dist/browser/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/Witnesses/index.d.cts +3 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js +2 -9
- package/dist/browser/Diviner/LocationDiviner/Witnesses/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/index.d.cts +5 -0
- package/dist/browser/Diviner/LocationDiviner/index.d.cts.map +1 -0
- package/dist/browser/Diviner/LocationDiviner/index.js +4 -82
- package/dist/browser/Diviner/LocationDiviner/index.js.map +1 -1
- package/dist/browser/Diviner/LocationDiviner/models.d.cts +5 -0
- package/dist/browser/Diviner/LocationDiviner/models.d.cts.map +1 -0
- package/dist/browser/Diviner/RemoteDivinerConfig.d.cts +11 -0
- package/dist/browser/Diviner/RemoteDivinerConfig.d.cts.map +1 -0
- package/dist/browser/Diviner/RemoteDivinerConfig.js +1 -2
- package/dist/browser/Diviner/RemoteDivinerConfig.js.map +1 -1
- package/dist/browser/Diviner/RemoteDivinerError.d.cts +6 -0
- package/dist/browser/Diviner/RemoteDivinerError.d.cts.map +1 -0
- package/dist/browser/Diviner/RemoteDivinerError.js +2 -3
- package/dist/browser/Diviner/RemoteDivinerError.js.map +1 -1
- package/dist/browser/Diviner/index.d.cts +3 -0
- package/dist/browser/Diviner/index.d.cts.map +1 -0
- package/dist/browser/Diviner/index.js +2 -86
- package/dist/browser/Diviner/index.js.map +1 -1
- package/dist/browser/Simple.d.cts +22 -0
- package/dist/browser/Simple.d.cts.map +1 -0
- package/dist/browser/Simple.js +4 -109
- package/dist/browser/Simple.js.map +1 -1
- package/dist/browser/Test/index.d.cts +3 -0
- package/dist/browser/Test/index.d.cts.map +1 -0
- package/dist/browser/Test/index.js +2 -32
- package/dist/browser/Test/index.js.map +1 -1
- package/dist/browser/Test/testBoundWitness.d.cts +4 -0
- package/dist/browser/Test/testBoundWitness.d.cts.map +1 -0
- package/dist/browser/Test/testBoundWitness.js +1 -2
- package/dist/browser/Test/testBoundWitness.js.map +1 -1
- package/dist/browser/Test/testPayload.d.cts +6 -0
- package/dist/browser/Test/testPayload.d.cts.map +1 -0
- package/dist/browser/Test/testPayload.js +2 -3
- package/dist/browser/Test/testPayload.js.map +1 -1
- package/dist/browser/WithArchive.d.cts +4 -0
- package/dist/browser/WithArchive.d.cts.map +1 -0
- package/dist/browser/index.d.cts +7 -0
- package/dist/browser/index.d.cts.map +1 -0
- package/dist/browser/index.js +6 -253
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/models/ArchivePath.d.cts +4 -0
- package/dist/browser/models/ArchivePath.d.cts.map +1 -0
- package/dist/browser/models/index.d.cts +2 -0
- package/dist/browser/models/index.d.cts.map +1 -0
- package/dist/browser/models/index.js +1 -0
- package/dist/browser/models/index.js.map +1 -1
- package/dist/browser/objToQuery.d.cts +2 -0
- package/dist/browser/objToQuery.d.cts.map +1 -0
- package/dist/browser/objToQuery.js +1 -2
- package/dist/browser/objToQuery.js.map +1 -1
- package/dist/docs.json +16171 -0
- package/dist/node/Api/Api.d.cts +12 -0
- package/dist/node/Api/Api.d.cts.map +1 -0
- package/dist/node/Api/Api.js +161 -4
- package/dist/node/Api/Api.js.map +1 -1
- package/dist/node/Api/Api.mjs +159 -3
- package/dist/node/Api/Api.mjs.map +1 -1
- package/dist/node/Api/index.d.cts +2 -0
- package/dist/node/Api/index.d.cts.map +1 -0
- package/dist/node/Api/index.js +178 -3
- package/dist/node/Api/index.js.map +1 -1
- package/dist/node/Api/index.mjs +170 -1
- package/dist/node/Api/index.mjs.map +1 -1
- package/dist/node/Base.d.cts +32 -0
- package/dist/node/Base.d.cts.map +1 -0
- package/dist/node/Base.js +20 -14
- package/dist/node/Base.js.map +1 -1
- package/dist/node/Base.mjs +19 -14
- package/dist/node/Base.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.d.cts +12 -0
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js +18 -6
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs +16 -5
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApi.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts +10 -0
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js +4 -2
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs +3 -2
- package/dist/node/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts +5 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js +2 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapPointProperties.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts +12 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js +6 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs +5 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts +3 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js +21 -5
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs +11 -2
- package/dist/node/Diviner/LocationDiviner/Queries/LocationHeatmapQuery/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts +12 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js +6 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs +5 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts +2 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js +21 -3
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs +11 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts +18 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js +2 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationRequest.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts +5 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js +2 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQueryCreationResponse.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts +6 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js +4 -2
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs +3 -2
- package/dist/node/Diviner/LocationDiviner/Queries/LocationQuerySchema.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts +8 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js +2 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangePointProperties.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts +12 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js +6 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs +5 -4
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts +3 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js +21 -5
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs +11 -2
- package/dist/node/Diviner/LocationDiviner/Queries/LocationTimeRangeQuery/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/index.d.cts +7 -0
- package/dist/node/Diviner/LocationDiviner/Queries/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Queries/index.js +59 -13
- package/dist/node/Diviner/LocationDiviner/Queries/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Queries/index.mjs +42 -6
- package/dist/node/Diviner/LocationDiviner/Queries/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts +13 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js +3 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs +2 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/CurrentLocationWitness.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts +21 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js +3 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs +2 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/LocationWitness.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.d.cts +3 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.js +18 -5
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs +9 -2
- package/dist/node/Diviner/LocationDiviner/Witnesses/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/index.d.cts +5 -0
- package/dist/node/Diviner/LocationDiviner/index.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/index.js +102 -9
- package/dist/node/Diviner/LocationDiviner/index.js.map +1 -1
- package/dist/node/Diviner/LocationDiviner/index.mjs +82 -4
- package/dist/node/Diviner/LocationDiviner/index.mjs.map +1 -1
- package/dist/node/Diviner/LocationDiviner/models.d.cts +5 -0
- package/dist/node/Diviner/LocationDiviner/models.d.cts.map +1 -0
- package/dist/node/Diviner/LocationDiviner/models.js +2 -0
- package/dist/node/Diviner/LocationDiviner/models.js.map +1 -1
- package/dist/node/Diviner/RemoteDivinerConfig.d.cts +11 -0
- package/dist/node/Diviner/RemoteDivinerConfig.d.cts.map +1 -0
- package/dist/node/Diviner/RemoteDivinerConfig.js +3 -1
- package/dist/node/Diviner/RemoteDivinerConfig.js.map +1 -1
- package/dist/node/Diviner/RemoteDivinerConfig.mjs +2 -1
- package/dist/node/Diviner/RemoteDivinerConfig.mjs.map +1 -1
- package/dist/node/Diviner/RemoteDivinerError.d.cts +6 -0
- package/dist/node/Diviner/RemoteDivinerError.d.cts.map +1 -0
- package/dist/node/Diviner/RemoteDivinerError.js +4 -2
- package/dist/node/Diviner/RemoteDivinerError.js.map +1 -1
- package/dist/node/Diviner/RemoteDivinerError.mjs +3 -2
- package/dist/node/Diviner/RemoteDivinerError.mjs.map +1 -1
- package/dist/node/Diviner/index.d.cts +3 -0
- package/dist/node/Diviner/index.d.cts.map +1 -0
- package/dist/node/Diviner/index.js +107 -5
- package/dist/node/Diviner/index.js.map +1 -1
- package/dist/node/Diviner/index.mjs +86 -2
- package/dist/node/Diviner/index.mjs.map +1 -1
- package/dist/node/Simple.d.cts +22 -0
- package/dist/node/Simple.d.cts.map +1 -0
- package/dist/node/Simple.js +118 -6
- package/dist/node/Simple.js.map +1 -1
- package/dist/node/Simple.mjs +113 -4
- package/dist/node/Simple.mjs.map +1 -1
- package/dist/node/Test/index.d.cts +3 -0
- package/dist/node/Test/index.d.cts.map +1 -0
- package/dist/node/Test/index.js +42 -5
- package/dist/node/Test/index.js.map +1 -1
- package/dist/node/Test/index.mjs +32 -2
- package/dist/node/Test/index.mjs.map +1 -1
- package/dist/node/Test/testBoundWitness.d.cts +4 -0
- package/dist/node/Test/testBoundWitness.d.cts.map +1 -0
- package/dist/node/Test/testBoundWitness.js +3 -1
- package/dist/node/Test/testBoundWitness.js.map +1 -1
- package/dist/node/Test/testBoundWitness.mjs +2 -1
- package/dist/node/Test/testBoundWitness.mjs.map +1 -1
- package/dist/node/Test/testPayload.d.cts +6 -0
- package/dist/node/Test/testPayload.d.cts.map +1 -0
- package/dist/node/Test/testPayload.js +4 -2
- package/dist/node/Test/testPayload.js.map +1 -1
- package/dist/node/Test/testPayload.mjs +3 -2
- package/dist/node/Test/testPayload.mjs.map +1 -1
- package/dist/node/WithArchive.d.cts +4 -0
- package/dist/node/WithArchive.d.cts.map +1 -0
- package/dist/node/WithArchive.js +2 -0
- package/dist/node/WithArchive.js.map +1 -1
- package/dist/node/index.d.cts +7 -0
- package/dist/node/index.d.cts.map +1 -0
- package/dist/node/index.js +281 -13
- package/dist/node/index.js.map +1 -1
- package/dist/node/index.mjs +257 -6
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/models/ArchivePath.d.cts +4 -0
- package/dist/node/models/ArchivePath.d.cts.map +1 -0
- package/dist/node/models/ArchivePath.js +2 -0
- package/dist/node/models/ArchivePath.js.map +1 -1
- package/dist/node/models/index.d.cts +2 -0
- package/dist/node/models/index.d.cts.map +1 -0
- package/dist/node/models/index.js +2 -6
- package/dist/node/models/index.js.map +1 -1
- package/dist/node/models/index.mjs +0 -1
- package/dist/node/models/index.mjs.map +1 -1
- package/dist/node/objToQuery.d.cts +2 -0
- package/dist/node/objToQuery.d.cts.map +1 -0
- package/dist/node/objToQuery.js +3 -1
- package/dist/node/objToQuery.js.map +1 -1
- package/dist/node/objToQuery.mjs +2 -1
- package/dist/node/objToQuery.mjs.map +1 -1
- package/package.json +12 -12
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiConfig } from '@xyo-network/api-models';
|
|
2
|
+
import { Huri } from '@xyo-network/huri';
|
|
3
|
+
import { Payload } from '@xyo-network/payload-model';
|
|
4
|
+
import { ApiSimple } from '../Simple';
|
|
5
|
+
export declare class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {
|
|
6
|
+
huri(huri: Huri | string): ApiSimple<{
|
|
7
|
+
schema: string;
|
|
8
|
+
} & import("@xyo-network/payload-model").PayloadFields, {
|
|
9
|
+
schema: string;
|
|
10
|
+
} & import("@xyo-network/payload-model").PayloadFields, import("@xyo-network/payload-model").PayloadFindFilter, ApiConfig>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=Api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Api.d.ts","sourceRoot":"","sources":["../../../src/Api/Api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAA;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAErC,qBAAa,YAAY,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,CAAE,SAAQ,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACxF,IAAI,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;;;;;CAOzB"}
|
package/dist/browser/Api/Api.js
CHANGED
|
@@ -1,158 +1,6 @@
|
|
|
1
|
-
// src/Api/Api.ts
|
|
2
1
|
import { Huri } from "@xyo-network/huri";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { AxiosJson } from "@xyo-network/axios";
|
|
6
|
-
var ApiBase = class _ApiBase {
|
|
7
|
-
config;
|
|
8
|
-
axios;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.axios = new AxiosJson({ ...this.config, headers: this.headers });
|
|
12
|
-
}
|
|
13
|
-
get authenticated() {
|
|
14
|
-
return !!this.config.apiKey || !!this.config.jwtToken;
|
|
15
|
-
}
|
|
16
|
-
get headers() {
|
|
17
|
-
const headers = {};
|
|
18
|
-
if (this.config.jwtToken) {
|
|
19
|
-
headers.Authorization = `Bearer ${this.config.jwtToken}`;
|
|
20
|
-
}
|
|
21
|
-
if (this.config.apiKey) {
|
|
22
|
-
headers["x-api-key"] = this.config.apiKey;
|
|
23
|
-
}
|
|
24
|
-
return headers;
|
|
25
|
-
}
|
|
26
|
-
get query() {
|
|
27
|
-
return this.config.query ?? "";
|
|
28
|
-
}
|
|
29
|
-
get root() {
|
|
30
|
-
return this.config.root ?? "/";
|
|
31
|
-
}
|
|
32
|
-
static resolveResponse(result) {
|
|
33
|
-
return [result?.data?.data, result?.data, result];
|
|
34
|
-
}
|
|
35
|
-
static shapeResponse(response, responseType) {
|
|
36
|
-
const resolvedResponse = _ApiBase.resolveResponse(response);
|
|
37
|
-
return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
|
|
38
|
-
}
|
|
39
|
-
onError(error, depth = 0) {
|
|
40
|
-
this.config.reportableParent?.onError?.(error, depth + 1);
|
|
41
|
-
this.config.onError?.(error, depth);
|
|
42
|
-
}
|
|
43
|
-
onFailure(response, depth = 0) {
|
|
44
|
-
this.config.reportableParent?.onFailure?.(response, depth + 1);
|
|
45
|
-
this.config.onFailure?.(response, depth);
|
|
46
|
-
}
|
|
47
|
-
onSuccess(response, depth = 0) {
|
|
48
|
-
this.config.reportableParent?.onSuccess?.(response, depth + 1);
|
|
49
|
-
this.config.onSuccess?.(response, depth);
|
|
50
|
-
}
|
|
51
|
-
async deleteEndpoint(endPoint = "", responseType) {
|
|
52
|
-
const response = await this.monitorResponse(async () => {
|
|
53
|
-
return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
54
|
-
});
|
|
55
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
56
|
-
}
|
|
57
|
-
async getEndpoint(endPoint = "", responseType) {
|
|
58
|
-
const response = await this.monitorResponse(async () => {
|
|
59
|
-
return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
60
|
-
});
|
|
61
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
62
|
-
}
|
|
63
|
-
handleMonitorResponseError(error, trapAxiosException) {
|
|
64
|
-
if (!error.isError) {
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
if (trapAxiosException) {
|
|
68
|
-
error.response ? this.onFailure(error.response) : this.onError(error);
|
|
69
|
-
if (this.config.throwFailure) {
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
return error.response;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async monitorResponse(closure) {
|
|
76
|
-
let trapAxiosException = true;
|
|
77
|
-
try {
|
|
78
|
-
const response = await closure();
|
|
79
|
-
trapAxiosException = false;
|
|
80
|
-
response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
|
|
81
|
-
return response;
|
|
82
|
-
} catch (ex) {
|
|
83
|
-
this.handleMonitorResponseError(ex, trapAxiosException);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async postEndpoint(endPoint = "", data, responseType) {
|
|
87
|
-
const response = await this.monitorResponse(async () => {
|
|
88
|
-
return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
89
|
-
});
|
|
90
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
91
|
-
}
|
|
92
|
-
async putEndpoint(endPoint = "", data, responseType) {
|
|
93
|
-
const response = await this.monitorResponse(async () => {
|
|
94
|
-
return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
95
|
-
});
|
|
96
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
97
|
-
}
|
|
98
|
-
resolveRoot() {
|
|
99
|
-
return `${this.config.apiDomain}${this.root}`;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// src/objToQuery.ts
|
|
104
|
-
var objToQuery = (obj) => {
|
|
105
|
-
return `?${Object.entries(obj).map(([key, value]) => {
|
|
106
|
-
return `${key}=${value}`;
|
|
107
|
-
}).filter((value) => value !== void 0).join("&")}`;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/Simple.ts
|
|
111
|
-
var ApiSimple = class extends ApiBase {
|
|
112
|
-
async delete(responseType) {
|
|
113
|
-
switch (responseType) {
|
|
114
|
-
case "tuple":
|
|
115
|
-
return await this.deleteEndpoint(void 0, "tuple");
|
|
116
|
-
default:
|
|
117
|
-
return await this.deleteEndpoint(void 0);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async find(query = {}, responseType) {
|
|
121
|
-
switch (responseType) {
|
|
122
|
-
case "tuple":
|
|
123
|
-
return await this.getEndpoint(objToQuery(query), "tuple");
|
|
124
|
-
default:
|
|
125
|
-
return await this.getEndpoint(objToQuery(query));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async get(responseType) {
|
|
129
|
-
switch (responseType) {
|
|
130
|
-
case "tuple":
|
|
131
|
-
return await this.getEndpoint(void 0, "tuple");
|
|
132
|
-
default:
|
|
133
|
-
return await this.getEndpoint(void 0);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async post(data, responseType) {
|
|
137
|
-
switch (responseType) {
|
|
138
|
-
case "tuple":
|
|
139
|
-
return await this.postEndpoint(void 0, data, "tuple");
|
|
140
|
-
default:
|
|
141
|
-
return await this.postEndpoint(void 0, data);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async put(data, responseType) {
|
|
145
|
-
switch (responseType) {
|
|
146
|
-
case "tuple":
|
|
147
|
-
return await this.putEndpoint(void 0, data, "tuple");
|
|
148
|
-
default:
|
|
149
|
-
return await this.putEndpoint(void 0, data);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// src/Api/Api.ts
|
|
155
|
-
var ArchivistApi = class extends ApiSimple {
|
|
2
|
+
import { ApiSimple } from "../Simple";
|
|
3
|
+
class ArchivistApi extends ApiSimple {
|
|
156
4
|
huri(huri) {
|
|
157
5
|
const huriObj = typeof huri === "string" ? new Huri(huri) : huri;
|
|
158
6
|
return new ApiSimple({
|
|
@@ -160,7 +8,7 @@ var ArchivistApi = class extends ApiSimple {
|
|
|
160
8
|
root: `${this.root}${huriObj.href}/`
|
|
161
9
|
});
|
|
162
10
|
}
|
|
163
|
-
}
|
|
11
|
+
}
|
|
164
12
|
export {
|
|
165
13
|
ArchivistApi
|
|
166
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Api/Api.ts","../../../src/Base.ts","../../../src/objToQuery.ts","../../../src/Simple.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { Huri } from '@xyo-network/huri'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { ApiSimple } from '../Simple'\n\nexport class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {\n huri(huri: Huri | string) {\n const huriObj = typeof huri === 'string' ? new Huri(huri) : huri\n return new ApiSimple<Payload>({\n ...this.config,\n root: `${this.root}${huriObj.href}/`,\n })\n }\n}\n","import {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\nimport { AxiosJson } from '@xyo-network/axios'\n\nexport class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {\n readonly config: C\n protected axios: AxiosJson\n\n constructor(config: C) {\n this.config = config\n this.axios = new AxiosJson({ ...this.config, headers: this.headers })\n }\n\n get authenticated() {\n return !!this.config.apiKey || !!this.config.jwtToken\n }\n\n protected get headers(): Record<string, string> {\n const headers: Record<string, string> = {}\n if (this.config.jwtToken) {\n headers.Authorization = `Bearer ${this.config.jwtToken}`\n }\n if (this.config.apiKey) {\n headers['x-api-key'] = this.config.apiKey\n }\n return headers\n }\n\n protected get query() {\n return this.config.query ?? ''\n }\n\n protected get root() {\n return this.config.root ?? '/'\n }\n\n private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {\n return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>\n }\n\n private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {\n const resolvedResponse = ApiBase.resolveResponse(response)\n return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]\n }\n\n onError(error: ApiError, depth = 0) {\n this.config.reportableParent?.onError?.(error, depth + 1)\n this.config.onError?.(error, depth)\n }\n\n onFailure(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onFailure?.(response, depth + 1)\n this.config.onFailure?.(response, depth)\n }\n\n onSuccess(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onSuccess?.(response, depth + 1)\n this.config.onSuccess?.(response, depth)\n }\n\n protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {\n if (!error.isError) {\n throw error\n }\n\n if (trapAxiosException) {\n error.response ? this.onFailure(error.response) : this.onError(error)\n if (this.config.throwFailure) {\n throw error\n }\n return error.response as ApiResponse<ApiEnvelope<T>>\n }\n }\n\n protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {\n //we use this to prevent accidental catching on exceptions in callbacks\n let trapAxiosException = true\n try {\n const response = await closure()\n trapAxiosException = false\n\n response.status < 300 ? this.onSuccess(response) : this.onFailure(response)\n\n return response\n } catch (ex) {\n this.handleMonitorResponseError(ex as ApiError, trapAxiosException)\n }\n }\n\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async postEndpoint<T = unknown, D = unknown>(\n endPoint = '',\n data?: D,\n responseType?: ApiResponseType,\n ): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n private resolveRoot() {\n return `${this.config.apiDomain}${this.root}`\n }\n}\n","export const objToQuery = (obj: Record<string, string | number | undefined>) => {\n return `?${Object.entries(obj)\n .map(([key, value]) => {\n return `${key}=${value}`\n })\n .filter((value) => value !== undefined)\n .join('&')}`\n}\n","import { ApiConfig, ApiResponseBody, ApiResponseTuple, ApiResponseTupleOrBody, ApiResponseType } from '@xyo-network/api-models'\nimport { Payload, PayloadFindFilter } from '@xyo-network/payload-model'\n\nimport { ApiBase } from './Base'\nimport { objToQuery } from './objToQuery'\n\nexport type ApiSimpleQuery = PayloadFindFilter\n\nexport class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {\n async delete(): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async delete(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.deleteEndpoint(undefined, 'tuple')\n default:\n return await this.deleteEndpoint(undefined)\n }\n }\n\n async find(query?: Q): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async find(query = {}, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(objToQuery(query), 'tuple')\n default:\n return await this.getEndpoint(objToQuery(query))\n }\n }\n\n async get(): Promise<ApiResponseBody<T>>\n async get(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async get(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(undefined, 'tuple')\n default:\n return await this.getEndpoint(undefined)\n }\n }\n\n async post(data?: D): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async post(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.postEndpoint(undefined, data, 'tuple')\n default:\n return await this.postEndpoint(undefined, data)\n }\n }\n\n async put(data?: D): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async put(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.putEndpoint(undefined, data, 'tuple')\n default:\n return await this.putEndpoint(undefined, data)\n }\n }\n}\n"],"mappings":";AACA,SAAS,YAAY;;;ACUrB,SAAS,iBAAiB;AAEnB,IAAM,UAAN,MAAM,SAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,CAAC,CAAC,KAAK,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,IAAc,UAAkC;AAC9C,UAAM,UAAkC,CAAC;AACzC,QAAI,KAAK,OAAO,UAAU;AACxB,cAAQ,gBAAgB,UAAU,KAAK,OAAO,QAAQ;AAAA,IACxD;AACA,QAAI,KAAK,OAAO,QAAQ;AACtB,cAAQ,WAAW,IAAI,KAAK,OAAO;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,QAAQ;AACp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AA,IACjD;AAAA,EACF;AACF;;;AH9DO,IAAM,eAAN,cAA4D,UAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,UAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/Api/Api.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { Huri } from '@xyo-network/huri'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { ApiSimple } from '../Simple'\n\nexport class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {\n huri(huri: Huri | string) {\n const huriObj = typeof huri === 'string' ? new Huri(huri) : huri\n return new ApiSimple<Payload>({\n ...this.config,\n root: `${this.root}${huriObj.href}/`,\n })\n }\n}\n"],"mappings":"AACA,SAAS,YAAY;AAGrB,SAAS,iBAAiB;AAEnB,MAAM,qBAAsD,UAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,UAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA"}
|
|
@@ -1,167 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { Huri } from "@xyo-network/huri";
|
|
3
|
-
|
|
4
|
-
// src/Base.ts
|
|
5
|
-
import { AxiosJson } from "@xyo-network/axios";
|
|
6
|
-
var ApiBase = class _ApiBase {
|
|
7
|
-
config;
|
|
8
|
-
axios;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.axios = new AxiosJson({ ...this.config, headers: this.headers });
|
|
12
|
-
}
|
|
13
|
-
get authenticated() {
|
|
14
|
-
return !!this.config.apiKey || !!this.config.jwtToken;
|
|
15
|
-
}
|
|
16
|
-
get headers() {
|
|
17
|
-
const headers = {};
|
|
18
|
-
if (this.config.jwtToken) {
|
|
19
|
-
headers.Authorization = `Bearer ${this.config.jwtToken}`;
|
|
20
|
-
}
|
|
21
|
-
if (this.config.apiKey) {
|
|
22
|
-
headers["x-api-key"] = this.config.apiKey;
|
|
23
|
-
}
|
|
24
|
-
return headers;
|
|
25
|
-
}
|
|
26
|
-
get query() {
|
|
27
|
-
return this.config.query ?? "";
|
|
28
|
-
}
|
|
29
|
-
get root() {
|
|
30
|
-
return this.config.root ?? "/";
|
|
31
|
-
}
|
|
32
|
-
static resolveResponse(result) {
|
|
33
|
-
return [result?.data?.data, result?.data, result];
|
|
34
|
-
}
|
|
35
|
-
static shapeResponse(response, responseType) {
|
|
36
|
-
const resolvedResponse = _ApiBase.resolveResponse(response);
|
|
37
|
-
return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
|
|
38
|
-
}
|
|
39
|
-
onError(error, depth = 0) {
|
|
40
|
-
this.config.reportableParent?.onError?.(error, depth + 1);
|
|
41
|
-
this.config.onError?.(error, depth);
|
|
42
|
-
}
|
|
43
|
-
onFailure(response, depth = 0) {
|
|
44
|
-
this.config.reportableParent?.onFailure?.(response, depth + 1);
|
|
45
|
-
this.config.onFailure?.(response, depth);
|
|
46
|
-
}
|
|
47
|
-
onSuccess(response, depth = 0) {
|
|
48
|
-
this.config.reportableParent?.onSuccess?.(response, depth + 1);
|
|
49
|
-
this.config.onSuccess?.(response, depth);
|
|
50
|
-
}
|
|
51
|
-
async deleteEndpoint(endPoint = "", responseType) {
|
|
52
|
-
const response = await this.monitorResponse(async () => {
|
|
53
|
-
return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
54
|
-
});
|
|
55
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
56
|
-
}
|
|
57
|
-
async getEndpoint(endPoint = "", responseType) {
|
|
58
|
-
const response = await this.monitorResponse(async () => {
|
|
59
|
-
return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
60
|
-
});
|
|
61
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
62
|
-
}
|
|
63
|
-
handleMonitorResponseError(error, trapAxiosException) {
|
|
64
|
-
if (!error.isError) {
|
|
65
|
-
throw error;
|
|
66
|
-
}
|
|
67
|
-
if (trapAxiosException) {
|
|
68
|
-
error.response ? this.onFailure(error.response) : this.onError(error);
|
|
69
|
-
if (this.config.throwFailure) {
|
|
70
|
-
throw error;
|
|
71
|
-
}
|
|
72
|
-
return error.response;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
async monitorResponse(closure) {
|
|
76
|
-
let trapAxiosException = true;
|
|
77
|
-
try {
|
|
78
|
-
const response = await closure();
|
|
79
|
-
trapAxiosException = false;
|
|
80
|
-
response.status < 300 ? this.onSuccess(response) : this.onFailure(response);
|
|
81
|
-
return response;
|
|
82
|
-
} catch (ex) {
|
|
83
|
-
this.handleMonitorResponseError(ex, trapAxiosException);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async postEndpoint(endPoint = "", data, responseType) {
|
|
87
|
-
const response = await this.monitorResponse(async () => {
|
|
88
|
-
return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
89
|
-
});
|
|
90
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
91
|
-
}
|
|
92
|
-
async putEndpoint(endPoint = "", data, responseType) {
|
|
93
|
-
const response = await this.monitorResponse(async () => {
|
|
94
|
-
return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
95
|
-
});
|
|
96
|
-
return _ApiBase.shapeResponse(response, responseType);
|
|
97
|
-
}
|
|
98
|
-
resolveRoot() {
|
|
99
|
-
return `${this.config.apiDomain}${this.root}`;
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
// src/objToQuery.ts
|
|
104
|
-
var objToQuery = (obj) => {
|
|
105
|
-
return `?${Object.entries(obj).map(([key, value]) => {
|
|
106
|
-
return `${key}=${value}`;
|
|
107
|
-
}).filter((value) => value !== void 0).join("&")}`;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/Simple.ts
|
|
111
|
-
var ApiSimple = class extends ApiBase {
|
|
112
|
-
async delete(responseType) {
|
|
113
|
-
switch (responseType) {
|
|
114
|
-
case "tuple":
|
|
115
|
-
return await this.deleteEndpoint(void 0, "tuple");
|
|
116
|
-
default:
|
|
117
|
-
return await this.deleteEndpoint(void 0);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async find(query = {}, responseType) {
|
|
121
|
-
switch (responseType) {
|
|
122
|
-
case "tuple":
|
|
123
|
-
return await this.getEndpoint(objToQuery(query), "tuple");
|
|
124
|
-
default:
|
|
125
|
-
return await this.getEndpoint(objToQuery(query));
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
async get(responseType) {
|
|
129
|
-
switch (responseType) {
|
|
130
|
-
case "tuple":
|
|
131
|
-
return await this.getEndpoint(void 0, "tuple");
|
|
132
|
-
default:
|
|
133
|
-
return await this.getEndpoint(void 0);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async post(data, responseType) {
|
|
137
|
-
switch (responseType) {
|
|
138
|
-
case "tuple":
|
|
139
|
-
return await this.postEndpoint(void 0, data, "tuple");
|
|
140
|
-
default:
|
|
141
|
-
return await this.postEndpoint(void 0, data);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
async put(data, responseType) {
|
|
145
|
-
switch (responseType) {
|
|
146
|
-
case "tuple":
|
|
147
|
-
return await this.putEndpoint(void 0, data, "tuple");
|
|
148
|
-
default:
|
|
149
|
-
return await this.putEndpoint(void 0, data);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
// src/Api/Api.ts
|
|
155
|
-
var ArchivistApi = class extends ApiSimple {
|
|
156
|
-
huri(huri) {
|
|
157
|
-
const huriObj = typeof huri === "string" ? new Huri(huri) : huri;
|
|
158
|
-
return new ApiSimple({
|
|
159
|
-
...this.config,
|
|
160
|
-
root: `${this.root}${huriObj.href}/`
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
export {
|
|
165
|
-
ArchivistApi
|
|
166
|
-
};
|
|
1
|
+
export * from "./Api";
|
|
167
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/Api/Api.ts","../../../src/Base.ts","../../../src/objToQuery.ts","../../../src/Simple.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { Huri } from '@xyo-network/huri'\nimport { Payload } from '@xyo-network/payload-model'\n\nimport { ApiSimple } from '../Simple'\n\nexport class ArchivistApi<C extends ApiConfig = ApiConfig> extends ApiSimple<Payload[], C> {\n huri(huri: Huri | string) {\n const huriObj = typeof huri === 'string' ? new Huri(huri) : huri\n return new ApiSimple<Payload>({\n ...this.config,\n root: `${this.root}${huriObj.href}/`,\n })\n }\n}\n","import {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\nimport { AxiosJson } from '@xyo-network/axios'\n\nexport class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {\n readonly config: C\n protected axios: AxiosJson\n\n constructor(config: C) {\n this.config = config\n this.axios = new AxiosJson({ ...this.config, headers: this.headers })\n }\n\n get authenticated() {\n return !!this.config.apiKey || !!this.config.jwtToken\n }\n\n protected get headers(): Record<string, string> {\n const headers: Record<string, string> = {}\n if (this.config.jwtToken) {\n headers.Authorization = `Bearer ${this.config.jwtToken}`\n }\n if (this.config.apiKey) {\n headers['x-api-key'] = this.config.apiKey\n }\n return headers\n }\n\n protected get query() {\n return this.config.query ?? ''\n }\n\n protected get root() {\n return this.config.root ?? '/'\n }\n\n private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {\n return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>\n }\n\n private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {\n const resolvedResponse = ApiBase.resolveResponse(response)\n return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]\n }\n\n onError(error: ApiError, depth = 0) {\n this.config.reportableParent?.onError?.(error, depth + 1)\n this.config.onError?.(error, depth)\n }\n\n onFailure(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onFailure?.(response, depth + 1)\n this.config.onFailure?.(response, depth)\n }\n\n onSuccess(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onSuccess?.(response, depth + 1)\n this.config.onSuccess?.(response, depth)\n }\n\n protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {\n if (!error.isError) {\n throw error\n }\n\n if (trapAxiosException) {\n error.response ? this.onFailure(error.response) : this.onError(error)\n if (this.config.throwFailure) {\n throw error\n }\n return error.response as ApiResponse<ApiEnvelope<T>>\n }\n }\n\n protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {\n //we use this to prevent accidental catching on exceptions in callbacks\n let trapAxiosException = true\n try {\n const response = await closure()\n trapAxiosException = false\n\n response.status < 300 ? this.onSuccess(response) : this.onFailure(response)\n\n return response\n } catch (ex) {\n this.handleMonitorResponseError(ex as ApiError, trapAxiosException)\n }\n }\n\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async postEndpoint<T = unknown, D = unknown>(\n endPoint = '',\n data?: D,\n responseType?: ApiResponseType,\n ): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n private resolveRoot() {\n return `${this.config.apiDomain}${this.root}`\n }\n}\n","export const objToQuery = (obj: Record<string, string | number | undefined>) => {\n return `?${Object.entries(obj)\n .map(([key, value]) => {\n return `${key}=${value}`\n })\n .filter((value) => value !== undefined)\n .join('&')}`\n}\n","import { ApiConfig, ApiResponseBody, ApiResponseTuple, ApiResponseTupleOrBody, ApiResponseType } from '@xyo-network/api-models'\nimport { Payload, PayloadFindFilter } from '@xyo-network/payload-model'\n\nimport { ApiBase } from './Base'\nimport { objToQuery } from './objToQuery'\n\nexport type ApiSimpleQuery = PayloadFindFilter\n\nexport class ApiSimple<T = Payload, D = T, Q extends ApiSimpleQuery = ApiSimpleQuery, C extends ApiConfig = ApiConfig> extends ApiBase<C> {\n async delete(): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async delete(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async delete(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.deleteEndpoint(undefined, 'tuple')\n default:\n return await this.deleteEndpoint(undefined)\n }\n }\n\n async find(query?: Q): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async find(query?: Q, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async find(query = {}, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(objToQuery(query), 'tuple')\n default:\n return await this.getEndpoint(objToQuery(query))\n }\n }\n\n async get(): Promise<ApiResponseBody<T>>\n async get(responseType?: 'body'): Promise<ApiResponseBody<T>>\n async get(responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async get(responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.getEndpoint(undefined, 'tuple')\n default:\n return await this.getEndpoint(undefined)\n }\n }\n\n async post(data?: D): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async post(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async post(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.postEndpoint(undefined, data, 'tuple')\n default:\n return await this.postEndpoint(undefined, data)\n }\n }\n\n async put(data?: D): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n async put(data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n async put(data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n switch (responseType) {\n case 'tuple':\n return await this.putEndpoint(undefined, data, 'tuple')\n default:\n return await this.putEndpoint(undefined, data)\n }\n }\n}\n"],"mappings":";AACA,SAAS,YAAY;;;ACUrB,SAAS,iBAAiB;AAEnB,IAAM,UAAN,MAAM,SAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WA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AoE;AACvF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,aAAa,QAAW,MAAM,OAAO;AAAA,MACzD;AACE,eAAO,MAAM,KAAK,aAAa,QAAW,IAAI;AAAA,IAClD;AAAA,EACF;AAAA,EAKA,MAAM,IAAI,MAAU,cAAoE;AACtF,YAAQ,cAAc;AAAA,MACpB,KAAK;AACH,eAAO,MAAM,KAAK,YAAY,QAAW,MAAM,OAAO;AAAA,MACxD;AACE,eAAO,MAAM,KAAK,YAAY,QAAW,IAAI;AAAA,IACjD;AAAA,EACF;AACF;;;AH9DO,IAAM,eAAN,cAA4D,UAAwB;AAAA,EACzF,KAAK,MAAqB;AACxB,UAAM,UAAU,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;AAC5D,WAAO,IAAI,UAAmB;AAAA,MAC5B,GAAG,KAAK;AAAA,MACR,MAAM,GAAG,KAAK,IAAI,GAAG,QAAQ,IAAI;AAAA,IACnC,CAAC;AAAA,EACH;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/Api/index.ts"],"sourcesContent":["export * from './Api'\n"],"mappings":"AAAA,cAAc;","names":[]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ApiConfig, ApiEnvelope, ApiError, ApiReportable, ApiResponse, ApiResponseBody, ApiResponseTuple } from '@xyo-network/api-models';
|
|
2
|
+
import { AxiosJson } from '@xyo-network/axios';
|
|
3
|
+
export declare class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {
|
|
4
|
+
readonly config: C;
|
|
5
|
+
protected axios: AxiosJson;
|
|
6
|
+
constructor(config: C);
|
|
7
|
+
get authenticated(): boolean;
|
|
8
|
+
protected get headers(): Record<string, string>;
|
|
9
|
+
protected get query(): string;
|
|
10
|
+
protected get root(): string;
|
|
11
|
+
private static resolveResponse;
|
|
12
|
+
private static shapeResponse;
|
|
13
|
+
onError(error: ApiError, depth?: number): void;
|
|
14
|
+
onFailure(response: ApiResponse, depth?: number): void;
|
|
15
|
+
onSuccess(response: ApiResponse, depth?: number): void;
|
|
16
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
17
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
18
|
+
protected deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
19
|
+
protected getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>;
|
|
20
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
21
|
+
protected getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
22
|
+
protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean): ApiResponse<ApiEnvelope<T>> | undefined;
|
|
23
|
+
protected monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>): Promise<ApiResponse<ApiEnvelope<T>> | undefined>;
|
|
24
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
25
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
26
|
+
protected postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
27
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>;
|
|
28
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>;
|
|
29
|
+
protected putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>;
|
|
30
|
+
private resolveRoot;
|
|
31
|
+
}
|
|
32
|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AC,CAAC,CAAC;cAYzH,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;cAC/F,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;cACtH,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAQxI,OAAO,CAAC,WAAW;CAGpB"}
|
package/dist/browser/Base.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
// src/Base.ts
|
|
2
1
|
import { AxiosJson } from "@xyo-network/axios";
|
|
3
|
-
|
|
2
|
+
class ApiBase {
|
|
4
3
|
config;
|
|
5
4
|
axios;
|
|
6
5
|
constructor(config) {
|
|
@@ -30,7 +29,7 @@ var ApiBase = class _ApiBase {
|
|
|
30
29
|
return [result?.data?.data, result?.data, result];
|
|
31
30
|
}
|
|
32
31
|
static shapeResponse(response, responseType) {
|
|
33
|
-
const resolvedResponse =
|
|
32
|
+
const resolvedResponse = ApiBase.resolveResponse(response);
|
|
34
33
|
return responseType === "tuple" ? resolvedResponse : resolvedResponse[0];
|
|
35
34
|
}
|
|
36
35
|
onError(error, depth = 0) {
|
|
@@ -49,13 +48,13 @@ var ApiBase = class _ApiBase {
|
|
|
49
48
|
const response = await this.monitorResponse(async () => {
|
|
50
49
|
return await this.axios.delete(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
51
50
|
});
|
|
52
|
-
return
|
|
51
|
+
return ApiBase.shapeResponse(response, responseType);
|
|
53
52
|
}
|
|
54
53
|
async getEndpoint(endPoint = "", responseType) {
|
|
55
54
|
const response = await this.monitorResponse(async () => {
|
|
56
55
|
return await this.axios.get(`${this.resolveRoot()}${endPoint}${this.query}`);
|
|
57
56
|
});
|
|
58
|
-
return
|
|
57
|
+
return ApiBase.shapeResponse(response, responseType);
|
|
59
58
|
}
|
|
60
59
|
handleMonitorResponseError(error, trapAxiosException) {
|
|
61
60
|
if (!error.isError) {
|
|
@@ -84,18 +83,18 @@ var ApiBase = class _ApiBase {
|
|
|
84
83
|
const response = await this.monitorResponse(async () => {
|
|
85
84
|
return await this.axios.post(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
86
85
|
});
|
|
87
|
-
return
|
|
86
|
+
return ApiBase.shapeResponse(response, responseType);
|
|
88
87
|
}
|
|
89
88
|
async putEndpoint(endPoint = "", data, responseType) {
|
|
90
89
|
const response = await this.monitorResponse(async () => {
|
|
91
90
|
return await this.axios.put(`${this.resolveRoot()}${endPoint}${this.query}`, data);
|
|
92
91
|
});
|
|
93
|
-
return
|
|
92
|
+
return ApiBase.shapeResponse(response, responseType);
|
|
94
93
|
}
|
|
95
94
|
resolveRoot() {
|
|
96
95
|
return `${this.config.apiDomain}${this.root}`;
|
|
97
96
|
}
|
|
98
|
-
}
|
|
97
|
+
}
|
|
99
98
|
export {
|
|
100
99
|
ApiBase
|
|
101
100
|
};
|
package/dist/browser/Base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Base.ts"],"sourcesContent":["import {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\nimport { AxiosJson } from '@xyo-network/axios'\n\nexport class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {\n readonly config: C\n protected axios: AxiosJson\n\n constructor(config: C) {\n this.config = config\n this.axios = new AxiosJson({ ...this.config, headers: this.headers })\n }\n\n get authenticated() {\n return !!this.config.apiKey || !!this.config.jwtToken\n }\n\n protected get headers(): Record<string, string> {\n const headers: Record<string, string> = {}\n if (this.config.jwtToken) {\n headers.Authorization = `Bearer ${this.config.jwtToken}`\n }\n if (this.config.apiKey) {\n headers['x-api-key'] = this.config.apiKey\n }\n return headers\n }\n\n protected get query() {\n return this.config.query ?? ''\n }\n\n protected get root() {\n return this.config.root ?? '/'\n }\n\n private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {\n return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>\n }\n\n private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {\n const resolvedResponse = ApiBase.resolveResponse(response)\n return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]\n }\n\n onError(error: ApiError, depth = 0) {\n this.config.reportableParent?.onError?.(error, depth + 1)\n this.config.onError?.(error, depth)\n }\n\n onFailure(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onFailure?.(response, depth + 1)\n this.config.onFailure?.(response, depth)\n }\n\n onSuccess(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onSuccess?.(response, depth + 1)\n this.config.onSuccess?.(response, depth)\n }\n\n protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {\n if (!error.isError) {\n throw error\n }\n\n if (trapAxiosException) {\n error.response ? this.onFailure(error.response) : this.onError(error)\n if (this.config.throwFailure) {\n throw error\n }\n return error.response as ApiResponse<ApiEnvelope<T>>\n }\n }\n\n protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {\n //we use this to prevent accidental catching on exceptions in callbacks\n let trapAxiosException = true\n try {\n const response = await closure()\n trapAxiosException = false\n\n response.status < 300 ? this.onSuccess(response) : this.onFailure(response)\n\n return response\n } catch (ex) {\n this.handleMonitorResponseError(ex as ApiError, trapAxiosException)\n }\n }\n\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async postEndpoint<T = unknown, D = unknown>(\n endPoint = '',\n data?: D,\n responseType?: ApiResponseType,\n ): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n private resolveRoot() {\n return `${this.config.apiDomain}${this.root}`\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/Base.ts"],"sourcesContent":["import {\n ApiConfig,\n ApiEnvelope,\n ApiError,\n ApiReportable,\n ApiResponse,\n ApiResponseBody,\n ApiResponseTuple,\n ApiResponseTupleOrBody,\n ApiResponseType,\n} from '@xyo-network/api-models'\nimport { AxiosJson } from '@xyo-network/axios'\n\nexport class ApiBase<C extends ApiConfig = ApiConfig> implements ApiReportable {\n readonly config: C\n protected axios: AxiosJson\n\n constructor(config: C) {\n this.config = config\n this.axios = new AxiosJson({ ...this.config, headers: this.headers })\n }\n\n get authenticated() {\n return !!this.config.apiKey || !!this.config.jwtToken\n }\n\n protected get headers(): Record<string, string> {\n const headers: Record<string, string> = {}\n if (this.config.jwtToken) {\n headers.Authorization = `Bearer ${this.config.jwtToken}`\n }\n if (this.config.apiKey) {\n headers['x-api-key'] = this.config.apiKey\n }\n return headers\n }\n\n protected get query() {\n return this.config.query ?? ''\n }\n\n protected get root() {\n return this.config.root ?? '/'\n }\n\n private static resolveResponse<T>(result?: ApiResponse<ApiEnvelope<T>>) {\n return [result?.data?.data, result?.data, result] as ApiResponseTuple<T>\n }\n\n private static shapeResponse<T = unknown>(response: ApiResponse<ApiEnvelope<T>> | undefined, responseType?: ApiResponseType) {\n const resolvedResponse = ApiBase.resolveResponse(response)\n return responseType === 'tuple' ? resolvedResponse : resolvedResponse[0]\n }\n\n onError(error: ApiError, depth = 0) {\n this.config.reportableParent?.onError?.(error, depth + 1)\n this.config.onError?.(error, depth)\n }\n\n onFailure(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onFailure?.(response, depth + 1)\n this.config.onFailure?.(response, depth)\n }\n\n onSuccess(response: ApiResponse, depth = 0) {\n this.config.reportableParent?.onSuccess?.(response, depth + 1)\n this.config.onSuccess?.(response, depth)\n }\n\n protected async deleteEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async deleteEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async deleteEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.delete<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async getEndpoint<T = unknown>(endPoint?: string): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async getEndpoint<T = unknown>(endPoint?: string, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async getEndpoint<T = unknown>(endPoint = '', responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.get<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>>>(`${this.resolveRoot()}${endPoint}${this.query}`)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected handleMonitorResponseError<T>(error: ApiError, trapAxiosException: boolean) {\n if (!error.isError) {\n throw error\n }\n\n if (trapAxiosException) {\n error.response ? this.onFailure(error.response) : this.onError(error)\n if (this.config.throwFailure) {\n throw error\n }\n return error.response as ApiResponse<ApiEnvelope<T>>\n }\n }\n\n protected async monitorResponse<T>(closure: () => Promise<ApiResponse<ApiEnvelope<T>>>) {\n //we use this to prevent accidental catching on exceptions in callbacks\n let trapAxiosException = true\n try {\n const response = await closure()\n trapAxiosException = false\n\n response.status < 300 ? this.onSuccess(response) : this.onFailure(response)\n\n return response\n } catch (ex) {\n this.handleMonitorResponseError(ex as ApiError, trapAxiosException)\n }\n }\n\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async postEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async postEndpoint<T = unknown, D = unknown>(\n endPoint = '',\n data?: D,\n responseType?: ApiResponseType,\n ): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.post<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'body'): Promise<ApiResponseBody<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint?: string, data?: D, responseType?: 'tuple'): Promise<ApiResponseTuple<T>>\n protected async putEndpoint<T = unknown, D = unknown>(endPoint = '', data?: D, responseType?: ApiResponseType): Promise<ApiResponseTupleOrBody<T>> {\n const response = await this.monitorResponse<T>(async () => {\n return await this.axios.put<ApiEnvelope<T>, ApiResponse<ApiEnvelope<T>, D>, D>(`${this.resolveRoot()}${endPoint}${this.query}`, data)\n })\n return ApiBase.shapeResponse<T>(response, responseType)\n }\n\n private resolveRoot() {\n return `${this.config.apiDomain}${this.root}`\n }\n}\n"],"mappings":"AAWA,SAAS,iBAAiB;AAEnB,MAAM,QAAkE;AAAA,EACpE;AAAA,EACC;AAAA,EAEV,YAAY,QAAW;AACrB,SAAK,SAAS;AACd,SAAK,QAAQ,IAAI,UAAU,EAAE,GAAG,KAAK,QAAQ,SAAS,KAAK,QAAQ,CAAC;AAAA,EACtE;AAAA,EAEA,IAAI,gBAAgB;AAClB,WAAO,CAAC,CAAC,KAAK,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO;AAAA,EAC/C;AAAA,EAEA,IAAc,UAAkC;AAC9C,UAAM,UAAkC,CAAC;AACzC,QAAI,KAAK,OAAO,UAAU;AACxB,cAAQ,gBAAgB,UAAU,KAAK,OAAO,QAAQ;AAAA,IACxD;AACA,QAAI,KAAK,OAAO,QAAQ;AACtB,cAAQ,WAAW,IAAI,KAAK,OAAO;AAAA,IACrC;AACA,WAAO;AAAA,EACT;AAAA,EAEA,IAAc,QAAQ;AACpB,WAAO,KAAK,OAAO,SAAS;AAAA,EAC9B;AAAA,EAEA,IAAc,OAAO;AACnB,WAAO,KAAK,OAAO,QAAQ;AAAA,EAC7B;AAAA,EAEA,OAAe,gBAAmB,QAAsC;AACtE,WAAO,CAAC,QAAQ,MAAM,MAAM,QAAQ,MAAM,MAAM;AAAA,EAClD;AAAA,EAEA,OAAe,cAA2B,UAAmD,cAAgC;AAC3H,UAAM,mBAAmB,QAAQ,gBAAgB,QAAQ;AACzD,WAAO,iBAAiB,UAAU,mBAAmB,iBAAiB,CAAC;AAAA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gB,gBAAmB,SAAqD;AAEtF,QAAI,qBAAqB;AACzB,QAAI;AACF,YAAM,WAAW,MAAM,QAAQ;AAC/B,2BAAqB;AAErB,eAAS,SAAS,MAAM,KAAK,UAAU,QAAQ,IAAI,KAAK,UAAU,QAAQ;AAE1E,aAAO;AAAA,IACT,SAAS,IAAI;AACX,WAAK,2BAA2B,IAAgB,kBAAkB;AAAA,IACpE;AAAA,EACF;AAAA,EAKA,MAAgB,aACd,WAAW,IACX,MACA,cACoC;AACpC,UAAM,WAAW,MAAM,KAAK,gBAAmB,YAAY;AACzD,aAAO,MAAM,KAAK,MAAM,KAAwD,GAAG,KAAK,YAAY,CAAC,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI;AAAA,IACvI,CAAC;AACD,WAAO,QAAQ,cAAiB,UAAU,YAAY;AAAA,EACxD;AAAA,EAKA,MAAgB,YAAsC,WAAW,IAAI,MAAU,cAAoE;AACjJ,UAAM,WAAW,MAAM,KAAK,gBAAmB,YAAY;AACzD,aAAO,MAAM,KAAK,MAAM,IAAuD,GAAG,KAAK,YAAY,CAAC,GAAG,QAAQ,GAAG,KAAK,KAAK,IAAI,IAAI;AAAA,IACtI,CAAC;AACD,WAAO,QAAQ,cAAiB,UAAU,YAAY;AAAA,EACxD;AAAA,EAEQ,cAAc;AACpB,WAAO,GAAG,KAAK,OAAO,SAAS,GAAG,KAAK,IAAI;AAAA,EAC7C;AACF;","names":[]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ApiConfig } from '@xyo-network/api-models';
|
|
2
|
+
import { GetLocationQueryResponse } from './models';
|
|
3
|
+
import { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries';
|
|
4
|
+
declare class LocationDivinerApi {
|
|
5
|
+
config: ApiConfig;
|
|
6
|
+
constructor(config: ApiConfig);
|
|
7
|
+
private get axiosRequestConfig();
|
|
8
|
+
getLocationQuery(hash: string): Promise<GetLocationQueryResponse>;
|
|
9
|
+
postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse>;
|
|
10
|
+
}
|
|
11
|
+
export { LocationDivinerApi };
|
|
12
|
+
//# sourceMappingURL=LocationDivinerApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationDivinerApi.d.ts","sourceRoot":"","sources":["../../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAInD,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EAAE,6BAA6B,EAAE,qCAAqC,EAAE,MAAM,WAAW,CAAA;AAEhG,cAAM,kBAAkB;IACtB,MAAM,EAAE,SAAS,CAAA;gBACL,MAAM,EAAE,SAAS;IAI7B,OAAO,KAAK,kBAAkB,GAI7B;IAEK,gBAAgB,CAAC,IAAI,EAAE,MAAM;IAI7B,iBAAiB,CAAC,OAAO,EAAE,qCAAqC;CAGvE;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
// src/Diviner/LocationDiviner/LocationDivinerApi.ts
|
|
2
|
-
import { axios as axios2 } from "@xyo-network/axios";
|
|
3
|
-
|
|
4
|
-
// src/Diviner/LocationDiviner/LocationDivinerApiResponseTransformer.ts
|
|
5
1
|
import { axios } from "@xyo-network/axios";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var getLocationDivinerApiResponseTransformer = (axiosInstance = axios) => {
|
|
10
|
-
return axiosInstance.defaults.transformResponse ? [].concat(axiosInstance.defaults.transformResponse, locationDivinerApiResponseTransformer) : [locationDivinerApiResponseTransformer];
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/Diviner/LocationDiviner/LocationDivinerApi.ts
|
|
14
|
-
var LocationDivinerApi = class {
|
|
2
|
+
import { getLocationDivinerApiResponseTransformer } from "./LocationDivinerApiResponseTransformer";
|
|
3
|
+
class LocationDivinerApi {
|
|
15
4
|
config;
|
|
16
5
|
constructor(config) {
|
|
17
6
|
this.config = config;
|
|
@@ -22,12 +11,12 @@ var LocationDivinerApi = class {
|
|
|
22
11
|
};
|
|
23
12
|
}
|
|
24
13
|
async getLocationQuery(hash) {
|
|
25
|
-
return (await
|
|
14
|
+
return (await axios.get(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data;
|
|
26
15
|
}
|
|
27
16
|
async postLocationQuery(request) {
|
|
28
|
-
return (await
|
|
17
|
+
return (await axios.post(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data;
|
|
29
18
|
}
|
|
30
|
-
}
|
|
19
|
+
}
|
|
31
20
|
export {
|
|
32
21
|
LocationDivinerApi
|
|
33
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts"
|
|
1
|
+
{"version":3,"sources":["../../../../src/Diviner/LocationDiviner/LocationDivinerApi.ts"],"sourcesContent":["import { ApiConfig } from '@xyo-network/api-models'\nimport { axios, RawAxiosRequestConfig } from '@xyo-network/axios'\n\nimport { getLocationDivinerApiResponseTransformer } from './LocationDivinerApiResponseTransformer'\nimport { GetLocationQueryResponse } from './models'\nimport { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries'\n\nclass LocationDivinerApi {\n config: ApiConfig\n constructor(config: ApiConfig) {\n this.config = config\n }\n\n private get axiosRequestConfig(): RawAxiosRequestConfig {\n return {\n transformResponse: getLocationDivinerApiResponseTransformer(),\n }\n }\n\n async getLocationQuery(hash: string) {\n return (await axios.get<GetLocationQueryResponse>(`${this.config.apiDomain}/location/query/${hash}`, this.axiosRequestConfig)).data\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest) {\n return (await axios.post<LocationQueryCreationResponse>(`${this.config.apiDomain}/location/query`, { ...request }, this.axiosRequestConfig)).data\n }\n}\n\nexport { LocationDivinerApi }\n"],"mappings":"AACA,SAAS,aAAoC;AAE7C,SAAS,gDAAgD;AAIzD,MAAM,mBAAmB;AAAA,EACvB;AAAA,EACA,YAAY,QAAmB;AAC7B,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,IAAY,qBAA4C;AACtD,WAAO;AAAA,MACL,mBAAmB,yCAAyC;AAAA,IAC9D;AAAA,EACF;AAAA,EAEA,MAAM,iBAAiB,MAAc;AACnC,YAAQ,MAAM,MAAM,IAA8B,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,IAAI,KAAK,kBAAkB,GAAG;AAAA,EACjI;AAAA,EAEA,MAAM,kBAAkB,SAAgD;AACtE,YAAQ,MAAM,MAAM,KAAoC,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,GAAG,KAAK,kBAAkB,GAAG;AAAA,EAC/I;AACF;","names":[]}
|