@hydradb/sdk 0.0.1
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/LICENSE +24 -0
- package/README.md +578 -0
- package/dist/BaseClient.d.ts +42 -0
- package/dist/BaseClient.js +65 -0
- package/dist/Client.d.ts +58 -0
- package/dist/Client.js +142 -0
- package/dist/api/errors/BadRequestError.d.ts +5 -0
- package/dist/api/errors/BadRequestError.js +44 -0
- package/dist/api/errors/ForbiddenError.d.ts +5 -0
- package/dist/api/errors/ForbiddenError.js +44 -0
- package/dist/api/errors/InternalServerError.d.ts +5 -0
- package/dist/api/errors/InternalServerError.js +44 -0
- package/dist/api/errors/NotFoundError.d.ts +5 -0
- package/dist/api/errors/NotFoundError.js +44 -0
- package/dist/api/errors/ServiceUnavailableError.d.ts +5 -0
- package/dist/api/errors/ServiceUnavailableError.js +44 -0
- package/dist/api/errors/TooManyRequestsError.d.ts +6 -0
- package/dist/api/errors/TooManyRequestsError.js +44 -0
- package/dist/api/errors/UnauthorizedError.d.ts +5 -0
- package/dist/api/errors/UnauthorizedError.js +44 -0
- package/dist/api/errors/UnprocessableEntityError.d.ts +5 -0
- package/dist/api/errors/UnprocessableEntityError.js +44 -0
- package/dist/api/errors/index.d.ts +8 -0
- package/dist/api/errors/index.js +24 -0
- package/dist/api/index.d.ts +3 -0
- package/dist/api/index.js +19 -0
- package/dist/api/resources/data/client/Client.d.ts +33 -0
- package/dist/api/resources/data/client/Client.js +108 -0
- package/dist/api/resources/data/client/index.d.ts +1 -0
- package/dist/api/resources/data/client/index.js +17 -0
- package/dist/api/resources/data/client/requests/SourceDeleteRequest.d.ts +13 -0
- package/dist/api/resources/data/client/requests/SourceDeleteRequest.js +3 -0
- package/dist/api/resources/data/client/requests/index.d.ts +1 -0
- package/dist/api/resources/data/client/requests/index.js +2 -0
- package/dist/api/resources/data/exports.d.ts +2 -0
- package/dist/api/resources/data/exports.js +21 -0
- package/dist/api/resources/data/index.d.ts +1 -0
- package/dist/api/resources/data/index.js +17 -0
- package/dist/api/resources/embeddings/client/Client.d.ts +111 -0
- package/dist/api/resources/embeddings/client/Client.js +339 -0
- package/dist/api/resources/embeddings/client/index.d.ts +1 -0
- package/dist/api/resources/embeddings/client/index.js +17 -0
- package/dist/api/resources/embeddings/client/requests/BodyFilterRawEmbeddingsEndpointEmbeddingsFilterRawEmbeddingsPost.d.ts +21 -0
- package/dist/api/resources/embeddings/client/requests/BodyFilterRawEmbeddingsEndpointEmbeddingsFilterRawEmbeddingsPost.js +3 -0
- package/dist/api/resources/embeddings/client/requests/BodyInsertRawEmbeddingsEndpointEmbeddingsInsertRawEmbeddingsPost.d.ts +36 -0
- package/dist/api/resources/embeddings/client/requests/BodyInsertRawEmbeddingsEndpointEmbeddingsInsertRawEmbeddingsPost.js +3 -0
- package/dist/api/resources/embeddings/client/requests/BodySearchRawEmbeddingsEndpointEmbeddingsSearchRawEmbeddingsPost.d.ts +22 -0
- package/dist/api/resources/embeddings/client/requests/BodySearchRawEmbeddingsEndpointEmbeddingsSearchRawEmbeddingsPost.js +3 -0
- package/dist/api/resources/embeddings/client/requests/DeleteEmbeddingsRequest.d.ts +16 -0
- package/dist/api/resources/embeddings/client/requests/DeleteEmbeddingsRequest.js +3 -0
- package/dist/api/resources/embeddings/client/requests/index.d.ts +4 -0
- package/dist/api/resources/embeddings/client/requests/index.js +2 -0
- package/dist/api/resources/embeddings/exports.d.ts +2 -0
- package/dist/api/resources/embeddings/exports.js +21 -0
- package/dist/api/resources/embeddings/index.d.ts +1 -0
- package/dist/api/resources/embeddings/index.js +17 -0
- package/dist/api/resources/fetch/client/Client.d.ts +72 -0
- package/dist/api/resources/fetch/client/Client.js +252 -0
- package/dist/api/resources/fetch/client/index.d.ts +1 -0
- package/dist/api/resources/fetch/client/index.js +17 -0
- package/dist/api/resources/fetch/client/requests/GraphRelationsBySourceIdFetchRequest.d.ts +19 -0
- package/dist/api/resources/fetch/client/requests/GraphRelationsBySourceIdFetchRequest.js +3 -0
- package/dist/api/resources/fetch/client/requests/ListContentRequest.d.ts +25 -0
- package/dist/api/resources/fetch/client/requests/ListContentRequest.js +3 -0
- package/dist/api/resources/fetch/client/requests/SourceFetchRequest.d.ts +20 -0
- package/dist/api/resources/fetch/client/requests/SourceFetchRequest.js +3 -0
- package/dist/api/resources/fetch/client/requests/index.d.ts +3 -0
- package/dist/api/resources/fetch/client/requests/index.js +2 -0
- package/dist/api/resources/fetch/exports.d.ts +2 -0
- package/dist/api/resources/fetch/exports.js +21 -0
- package/dist/api/resources/fetch/index.d.ts +2 -0
- package/dist/api/resources/fetch/index.js +18 -0
- package/dist/api/resources/fetch/types/ListDataFetchResponse.d.ts +2 -0
- package/dist/api/resources/fetch/types/ListDataFetchResponse.js +3 -0
- package/dist/api/resources/fetch/types/index.d.ts +1 -0
- package/dist/api/resources/fetch/types/index.js +17 -0
- package/dist/api/resources/graphHealth/client/Client.d.ts +32 -0
- package/dist/api/resources/graphHealth/client/Client.js +115 -0
- package/dist/api/resources/graphHealth/client/index.d.ts +1 -0
- package/dist/api/resources/graphHealth/client/index.js +17 -0
- package/dist/api/resources/graphHealth/client/requests/GetSuperNodesGraphHealthSuperNodesGetRequest.d.ts +16 -0
- package/dist/api/resources/graphHealth/client/requests/GetSuperNodesGraphHealthSuperNodesGetRequest.js +3 -0
- package/dist/api/resources/graphHealth/client/requests/index.d.ts +1 -0
- package/dist/api/resources/graphHealth/client/requests/index.js +2 -0
- package/dist/api/resources/graphHealth/exports.d.ts +2 -0
- package/dist/api/resources/graphHealth/exports.js +21 -0
- package/dist/api/resources/graphHealth/index.d.ts +1 -0
- package/dist/api/resources/graphHealth/index.js +17 -0
- package/dist/api/resources/index.d.ts +19 -0
- package/dist/api/resources/index.js +48 -0
- package/dist/api/resources/ingestionPipeline/client/Client.d.ts +27 -0
- package/dist/api/resources/ingestionPipeline/client/Client.js +90 -0
- package/dist/api/resources/ingestionPipeline/client/index.d.ts +1 -0
- package/dist/api/resources/ingestionPipeline/client/index.js +17 -0
- package/dist/api/resources/ingestionPipeline/client/requests/MemoryIngestRequest.d.ts +19 -0
- package/dist/api/resources/ingestionPipeline/client/requests/MemoryIngestRequest.js +3 -0
- package/dist/api/resources/ingestionPipeline/client/requests/index.d.ts +1 -0
- package/dist/api/resources/ingestionPipeline/client/requests/index.js +2 -0
- package/dist/api/resources/ingestionPipeline/exports.d.ts +2 -0
- package/dist/api/resources/ingestionPipeline/exports.js +21 -0
- package/dist/api/resources/ingestionPipeline/index.d.ts +1 -0
- package/dist/api/resources/ingestionPipeline/index.js +17 -0
- package/dist/api/resources/key/client/Client.d.ts +30 -0
- package/dist/api/resources/key/client/Client.js +104 -0
- package/dist/api/resources/key/client/index.d.ts +1 -0
- package/dist/api/resources/key/client/index.js +17 -0
- package/dist/api/resources/key/client/requests/ApiKeyCreateRequest.d.ts +14 -0
- package/dist/api/resources/key/client/requests/ApiKeyCreateRequest.js +3 -0
- package/dist/api/resources/key/client/requests/index.d.ts +1 -0
- package/dist/api/resources/key/client/requests/index.js +2 -0
- package/dist/api/resources/key/exports.d.ts +2 -0
- package/dist/api/resources/key/exports.js +21 -0
- package/dist/api/resources/key/index.d.ts +1 -0
- package/dist/api/resources/key/index.js +17 -0
- package/dist/api/resources/recall/client/Client.d.ts +97 -0
- package/dist/api/resources/recall/client/Client.js +324 -0
- package/dist/api/resources/recall/client/index.d.ts +1 -0
- package/dist/api/resources/recall/client/index.js +17 -0
- package/dist/api/resources/recall/client/requests/FullTextSearchRequest.d.ts +22 -0
- package/dist/api/resources/recall/client/requests/FullTextSearchRequest.js +3 -0
- package/dist/api/resources/recall/client/requests/QnASearchRequest.d.ts +38 -0
- package/dist/api/resources/recall/client/requests/QnASearchRequest.js +3 -0
- package/dist/api/resources/recall/client/requests/index.d.ts +2 -0
- package/dist/api/resources/recall/client/requests/index.js +2 -0
- package/dist/api/resources/recall/exports.d.ts +2 -0
- package/dist/api/resources/recall/exports.js +21 -0
- package/dist/api/resources/recall/index.d.ts +1 -0
- package/dist/api/resources/recall/index.js +17 -0
- package/dist/api/resources/tenant/client/Client.d.ts +124 -0
- package/dist/api/resources/tenant/client/Client.js +456 -0
- package/dist/api/resources/tenant/client/index.d.ts +1 -0
- package/dist/api/resources/tenant/client/index.js +17 -0
- package/dist/api/resources/tenant/client/requests/DeleteTenantTenantRequest.d.ts +10 -0
- package/dist/api/resources/tenant/client/requests/DeleteTenantTenantRequest.js +3 -0
- package/dist/api/resources/tenant/client/requests/GetInfraStatusTenantRequest.d.ts +10 -0
- package/dist/api/resources/tenant/client/requests/GetInfraStatusTenantRequest.js +3 -0
- package/dist/api/resources/tenant/client/requests/GetSubTenantIdsTenantRequest.d.ts +10 -0
- package/dist/api/resources/tenant/client/requests/GetSubTenantIdsTenantRequest.js +3 -0
- package/dist/api/resources/tenant/client/requests/MonitorTenantRequest.d.ts +10 -0
- package/dist/api/resources/tenant/client/requests/MonitorTenantRequest.js +3 -0
- package/dist/api/resources/tenant/client/requests/TenantCreateRequest.d.ts +17 -0
- package/dist/api/resources/tenant/client/requests/TenantCreateRequest.js +3 -0
- package/dist/api/resources/tenant/client/requests/index.d.ts +5 -0
- package/dist/api/resources/tenant/client/requests/index.js +2 -0
- package/dist/api/resources/tenant/exports.d.ts +2 -0
- package/dist/api/resources/tenant/exports.js +21 -0
- package/dist/api/resources/tenant/index.d.ts +1 -0
- package/dist/api/resources/tenant/index.js +17 -0
- package/dist/api/resources/upload/client/Client.d.ts +92 -0
- package/dist/api/resources/upload/client/Client.js +349 -0
- package/dist/api/resources/upload/client/index.d.ts +1 -0
- package/dist/api/resources/upload/client/index.js +17 -0
- package/dist/api/resources/upload/client/requests/BodyAddMemoryMemoriesAddMemoryPost.d.ts +18 -0
- package/dist/api/resources/upload/client/requests/BodyAddMemoryMemoriesAddMemoryPost.js +3 -0
- package/dist/api/resources/upload/client/requests/BodyUploadKnowledgeIngestionUploadKnowledgePost.d.ts +23 -0
- package/dist/api/resources/upload/client/requests/BodyUploadKnowledgeIngestionUploadKnowledgePost.js +3 -0
- package/dist/api/resources/upload/client/requests/DeleteMemoryUploadRequest.d.ts +15 -0
- package/dist/api/resources/upload/client/requests/DeleteMemoryUploadRequest.js +3 -0
- package/dist/api/resources/upload/client/requests/VerifyProcessingUploadRequest.d.ts +16 -0
- package/dist/api/resources/upload/client/requests/VerifyProcessingUploadRequest.js +3 -0
- package/dist/api/resources/upload/client/requests/index.d.ts +4 -0
- package/dist/api/resources/upload/client/requests/index.js +2 -0
- package/dist/api/resources/upload/exports.d.ts +2 -0
- package/dist/api/resources/upload/exports.js +21 -0
- package/dist/api/resources/upload/index.d.ts +1 -0
- package/dist/api/resources/upload/index.js +17 -0
- package/dist/api/types/ActualErrorResponse.d.ts +4 -0
- package/dist/api/types/ActualErrorResponse.js +3 -0
- package/dist/api/types/AddMemoryResponse.d.ts +14 -0
- package/dist/api/types/AddMemoryResponse.js +3 -0
- package/dist/api/types/ApiKeyCreateResponse.d.ts +14 -0
- package/dist/api/types/ApiKeyCreateResponse.js +3 -0
- package/dist/api/types/AttachmentModel.d.ts +17 -0
- package/dist/api/types/AttachmentModel.js +3 -0
- package/dist/api/types/BatchProcessingStatus.d.ts +5 -0
- package/dist/api/types/BatchProcessingStatus.js +3 -0
- package/dist/api/types/Bm25OperatorType.d.ts +6 -0
- package/dist/api/types/Bm25OperatorType.js +9 -0
- package/dist/api/types/CollectionStats.d.ts +6 -0
- package/dist/api/types/CollectionStats.js +3 -0
- package/dist/api/types/ContentFilter.d.ts +24 -0
- package/dist/api/types/ContentFilter.js +3 -0
- package/dist/api/types/ContentModel.d.ts +14 -0
- package/dist/api/types/ContentModel.js +3 -0
- package/dist/api/types/CortexModelsResponseCommonsActualErrorResponse.d.ts +4 -0
- package/dist/api/types/CortexModelsResponseCommonsActualErrorResponse.js +3 -0
- package/dist/api/types/CortexModelsResponseCommonsErrorResponse.d.ts +5 -0
- package/dist/api/types/CortexModelsResponseCommonsErrorResponse.js +3 -0
- package/dist/api/types/CustomPropertyDefinition.d.ts +34 -0
- package/dist/api/types/CustomPropertyDefinition.js +3 -0
- package/dist/api/types/DeleteResult.d.ts +11 -0
- package/dist/api/types/DeleteResult.js +3 -0
- package/dist/api/types/DeleteUserMemoryResponse.d.ts +9 -0
- package/dist/api/types/DeleteUserMemoryResponse.js +3 -0
- package/dist/api/types/Entity.d.ts +12 -0
- package/dist/api/types/Entity.js +3 -0
- package/dist/api/types/ErrorResponse.d.ts +5 -0
- package/dist/api/types/ErrorResponse.js +3 -0
- package/dist/api/types/FetchMode.d.ts +7 -0
- package/dist/api/types/FetchMode.js +10 -0
- package/dist/api/types/ForcefulRelationsPayload.d.ts +6 -0
- package/dist/api/types/ForcefulRelationsPayload.js +3 -0
- package/dist/api/types/GraphContext.d.ts +11 -0
- package/dist/api/types/GraphContext.js +3 -0
- package/dist/api/types/HttpValidationError.d.ts +4 -0
- package/dist/api/types/HttpValidationError.js +3 -0
- package/dist/api/types/Infra.d.ts +5 -0
- package/dist/api/types/Infra.js +3 -0
- package/dist/api/types/InfraStatusResponse.d.ts +14 -0
- package/dist/api/types/InfraStatusResponse.js +3 -0
- package/dist/api/types/IngestResponse.d.ts +4 -0
- package/dist/api/types/IngestResponse.js +3 -0
- package/dist/api/types/InsertResult.d.ts +13 -0
- package/dist/api/types/InsertResult.js +3 -0
- package/dist/api/types/ListContentKind.d.ts +5 -0
- package/dist/api/types/ListContentKind.js +8 -0
- package/dist/api/types/ListUserMemoriesResponse.d.ts +14 -0
- package/dist/api/types/ListUserMemoriesResponse.js +3 -0
- package/dist/api/types/MemoryItem.d.ts +44 -0
- package/dist/api/types/MemoryItem.js +3 -0
- package/dist/api/types/MemoryResultItem.d.ts +16 -0
- package/dist/api/types/MemoryResultItem.js +3 -0
- package/dist/api/types/MilvusDataType.d.ts +16 -0
- package/dist/api/types/MilvusDataType.js +19 -0
- package/dist/api/types/PaginationMeta.d.ts +17 -0
- package/dist/api/types/PaginationMeta.js +3 -0
- package/dist/api/types/PathTriplet.d.ts +6 -0
- package/dist/api/types/PathTriplet.js +3 -0
- package/dist/api/types/ProcessingStatus.d.ts +26 -0
- package/dist/api/types/ProcessingStatus.js +16 -0
- package/dist/api/types/QnASearchResponse.d.ts +17 -0
- package/dist/api/types/QnASearchResponse.js +3 -0
- package/dist/api/types/RawEmbeddingDocument.d.ts +16 -0
- package/dist/api/types/RawEmbeddingDocument.js +3 -0
- package/dist/api/types/RawEmbeddingSearchResult.d.ts +16 -0
- package/dist/api/types/RawEmbeddingSearchResult.js +3 -0
- package/dist/api/types/RawEmbeddingVector.d.ts +9 -0
- package/dist/api/types/RawEmbeddingVector.js +3 -0
- package/dist/api/types/RecallSearchRequest.d.ts +34 -0
- package/dist/api/types/RecallSearchRequest.js +3 -0
- package/dist/api/types/RelationEvidence.d.ts +25 -0
- package/dist/api/types/RelationEvidence.js +3 -0
- package/dist/api/types/RetrievalResult.d.ts +12 -0
- package/dist/api/types/RetrievalResult.js +3 -0
- package/dist/api/types/RetrieveMode.d.ts +5 -0
- package/dist/api/types/RetrieveMode.js +8 -0
- package/dist/api/types/ScoredPathResponse.d.ts +10 -0
- package/dist/api/types/ScoredPathResponse.js +3 -0
- package/dist/api/types/SearchMode.d.ts +6 -0
- package/dist/api/types/SearchMode.js +9 -0
- package/dist/api/types/SourceDeleteResponse.d.ts +11 -0
- package/dist/api/types/SourceDeleteResponse.js +3 -0
- package/dist/api/types/SourceDeleteResultItem.d.ts +11 -0
- package/dist/api/types/SourceDeleteResultItem.js +3 -0
- package/dist/api/types/SourceFetchResponse.d.ts +23 -0
- package/dist/api/types/SourceFetchResponse.js +3 -0
- package/dist/api/types/SourceGraphRelationsResponse.d.ts +9 -0
- package/dist/api/types/SourceGraphRelationsResponse.js +3 -0
- package/dist/api/types/SourceInfo.d.ts +18 -0
- package/dist/api/types/SourceInfo.js +3 -0
- package/dist/api/types/SourceListResponse.d.ts +1 -0
- package/dist/api/types/SourceListResponse.js +3 -0
- package/dist/api/types/SourceModel.d.ts +42 -0
- package/dist/api/types/SourceModel.js +3 -0
- package/dist/api/types/SourceStatus.d.ts +7 -0
- package/dist/api/types/SourceStatus.js +10 -0
- package/dist/api/types/SourceUploadResponse.d.ts +11 -0
- package/dist/api/types/SourceUploadResponse.js +3 -0
- package/dist/api/types/SourceUploadResultItem.d.ts +11 -0
- package/dist/api/types/SourceUploadResultItem.js +3 -0
- package/dist/api/types/SubTenantIdsResponse.d.ts +9 -0
- package/dist/api/types/SubTenantIdsResponse.js +3 -0
- package/dist/api/types/SuperNodeItem.d.ts +9 -0
- package/dist/api/types/SuperNodeItem.js +3 -0
- package/dist/api/types/SuperNodeResponse.d.ts +11 -0
- package/dist/api/types/SuperNodeResponse.js +3 -0
- package/dist/api/types/SupportedLlmProviders.d.ts +8 -0
- package/dist/api/types/SupportedLlmProviders.js +11 -0
- package/dist/api/types/TenantCreateAcceptedResponse.d.ts +11 -0
- package/dist/api/types/TenantCreateAcceptedResponse.js +3 -0
- package/dist/api/types/TenantDeleteResponse.d.ts +6 -0
- package/dist/api/types/TenantDeleteResponse.js +3 -0
- package/dist/api/types/TenantIdsResponse.d.ts +8 -0
- package/dist/api/types/TenantIdsResponse.js +3 -0
- package/dist/api/types/TenantStatsResponse.d.ts +11 -0
- package/dist/api/types/TenantStatsResponse.js +3 -0
- package/dist/api/types/TripletWithEvidence.d.ts +12 -0
- package/dist/api/types/TripletWithEvidence.js +3 -0
- package/dist/api/types/UserAssistantPair.d.ts +9 -0
- package/dist/api/types/UserAssistantPair.js +3 -0
- package/dist/api/types/UserMemory.d.ts +9 -0
- package/dist/api/types/UserMemory.js +3 -0
- package/dist/api/types/ValidationError.d.ts +11 -0
- package/dist/api/types/ValidationError.js +3 -0
- package/dist/api/types/VectorStoreChunk.d.ts +26 -0
- package/dist/api/types/VectorStoreChunk.js +3 -0
- package/dist/api/types/index.d.ts +65 -0
- package/dist/api/types/index.js +81 -0
- package/dist/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/auth/BearerAuthProvider.js +58 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +5 -0
- package/dist/core/auth/AuthProvider.d.ts +8 -0
- package/dist/core/auth/AuthProvider.js +10 -0
- package/dist/core/auth/AuthRequest.d.ts +9 -0
- package/dist/core/auth/AuthRequest.js +2 -0
- package/dist/core/auth/BasicAuth.d.ts +8 -0
- package/dist/core/auth/BasicAuth.js +33 -0
- package/dist/core/auth/BearerToken.d.ts +7 -0
- package/dist/core/auth/BearerToken.js +16 -0
- package/dist/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/core/auth/NoOpAuthProvider.js +9 -0
- package/dist/core/auth/index.d.ts +5 -0
- package/dist/core/auth/index.js +11 -0
- package/dist/core/base64.d.ts +2 -0
- package/dist/core/base64.js +27 -0
- package/dist/core/exports.d.ts +2 -0
- package/dist/core/exports.js +18 -0
- package/dist/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/core/fetcher/APIResponse.js +2 -0
- package/dist/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/core/fetcher/BinaryResponse.js +18 -0
- package/dist/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/core/fetcher/EndpointSupplier.js +13 -0
- package/dist/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/core/fetcher/Fetcher.js +312 -0
- package/dist/core/fetcher/Headers.d.ts +3 -0
- package/dist/core/fetcher/Headers.js +92 -0
- package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/core/fetcher/HttpResponsePromise.js +92 -0
- package/dist/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/core/fetcher/RawResponse.js +44 -0
- package/dist/core/fetcher/Supplier.d.ts +4 -0
- package/dist/core/fetcher/Supplier.js +13 -0
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/core/fetcher/createRequestUrl.js +9 -0
- package/dist/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getErrorResponseBody.js +35 -0
- package/dist/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/core/fetcher/getFetchFn.js +7 -0
- package/dist/core/fetcher/getHeader.d.ts +1 -0
- package/dist/core/fetcher/getHeader.js +12 -0
- package/dist/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/core/fetcher/getRequestBody.js +17 -0
- package/dist/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/core/fetcher/getResponseBody.js +59 -0
- package/dist/core/fetcher/index.d.ts +13 -0
- package/dist/core/fetcher/index.js +19 -0
- package/dist/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/core/fetcher/makePassthroughRequest.js +123 -0
- package/dist/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/core/fetcher/makeRequest.js +52 -0
- package/dist/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/core/fetcher/requestWithRetries.js +60 -0
- package/dist/core/fetcher/signals.d.ts +5 -0
- package/dist/core/fetcher/signals.js +25 -0
- package/dist/core/file/exports.d.ts +1 -0
- package/dist/core/file/exports.js +2 -0
- package/dist/core/file/file.d.ts +10 -0
- package/dist/core/file/file.js +194 -0
- package/dist/core/file/index.d.ts +2 -0
- package/dist/core/file/index.js +18 -0
- package/dist/core/file/types.d.ts +70 -0
- package/dist/core/file/types.js +2 -0
- package/dist/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/core/form-data-utils/FormDataWrapper.js +155 -0
- package/dist/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/core/form-data-utils/encodeAsFormParameter.js +13 -0
- package/dist/core/form-data-utils/index.d.ts +2 -0
- package/dist/core/form-data-utils/index.js +20 -0
- package/dist/core/headers.d.ts +3 -0
- package/dist/core/headers.js +30 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +37 -0
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/logging/exports.d.ts +18 -0
- package/dist/core/logging/exports.js +35 -0
- package/dist/core/logging/index.d.ts +1 -0
- package/dist/core/logging/index.js +17 -0
- package/dist/core/logging/logger.d.ts +126 -0
- package/dist/core/logging/logger.js +144 -0
- package/dist/core/runtime/index.d.ts +1 -0
- package/dist/core/runtime/index.js +5 -0
- package/dist/core/runtime/runtime.d.ts +9 -0
- package/dist/core/runtime/runtime.js +104 -0
- package/dist/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/core/url/QueryStringBuilder.js +84 -0
- package/dist/core/url/encodePathParam.d.ts +1 -0
- package/dist/core/url/encodePathParam.js +22 -0
- package/dist/core/url/index.d.ts +4 -0
- package/dist/core/url/index.js +11 -0
- package/dist/core/url/join.d.ts +1 -0
- package/dist/core/url/join.js +69 -0
- package/dist/core/url/qs.d.ts +7 -0
- package/dist/core/url/qs.js +77 -0
- package/dist/environments.d.ts +4 -0
- package/dist/environments.js +7 -0
- package/dist/errors/HydraDBError.d.ts +14 -0
- package/dist/errors/HydraDBError.js +35 -0
- package/dist/errors/HydraDBTimeoutError.d.ts +6 -0
- package/dist/errors/HydraDBTimeoutError.js +18 -0
- package/dist/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/errors/handleNonStatusCodeError.js +59 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +7 -0
- package/dist/exports.d.ts +1 -0
- package/dist/exports.js +17 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +38 -0
- package/package.json +34 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type BinaryResponse = {
|
|
2
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) */
|
|
3
|
+
bodyUsed: Response["bodyUsed"];
|
|
4
|
+
/**
|
|
5
|
+
* Returns a ReadableStream of the response body.
|
|
6
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body)
|
|
7
|
+
*/
|
|
8
|
+
stream: () => Response["body"];
|
|
9
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) */
|
|
10
|
+
arrayBuffer: () => ReturnType<Response["arrayBuffer"]>;
|
|
11
|
+
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) */
|
|
12
|
+
blob: () => ReturnType<Response["blob"]>;
|
|
13
|
+
/**
|
|
14
|
+
* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes)
|
|
15
|
+
* Some versions of the Fetch API may not support this method.
|
|
16
|
+
*/
|
|
17
|
+
bytes?(): Promise<Uint8Array>;
|
|
18
|
+
};
|
|
19
|
+
export declare function getBinaryResponse(response: Response): BinaryResponse;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBinaryResponse = void 0;
|
|
4
|
+
function getBinaryResponse(response) {
|
|
5
|
+
const binaryResponse = {
|
|
6
|
+
get bodyUsed() {
|
|
7
|
+
return response.bodyUsed;
|
|
8
|
+
},
|
|
9
|
+
stream: () => response.body,
|
|
10
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
11
|
+
blob: response.blob.bind(response),
|
|
12
|
+
};
|
|
13
|
+
if ("bytes" in response && typeof response.bytes === "function") {
|
|
14
|
+
binaryResponse.bytes = response.bytes.bind(response);
|
|
15
|
+
}
|
|
16
|
+
return binaryResponse;
|
|
17
|
+
}
|
|
18
|
+
exports.getBinaryResponse = getBinaryResponse;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type SecuritySchemeKey = string;
|
|
2
|
+
/**
|
|
3
|
+
* A collection of security schemes, where the key is the name of the security scheme and the value is the list of scopes required for that scheme.
|
|
4
|
+
* All schemes in the collection must be satisfied for authentication to be successful.
|
|
5
|
+
*/
|
|
6
|
+
export type SecuritySchemeCollection = Record<SecuritySchemeKey, AuthScope[]>;
|
|
7
|
+
export type AuthScope = string;
|
|
8
|
+
export type EndpointMetadata = {
|
|
9
|
+
/**
|
|
10
|
+
* An array of security scheme collections. Each collection represents an alternative way to authenticate.
|
|
11
|
+
*/
|
|
12
|
+
security?: SecuritySchemeCollection[];
|
|
13
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
2
|
+
import type { Supplier } from "./Supplier.js";
|
|
3
|
+
type EndpointSupplierFn<T> = (arg: {
|
|
4
|
+
endpointMetadata?: EndpointMetadata;
|
|
5
|
+
}) => T | Promise<T>;
|
|
6
|
+
export type EndpointSupplier<T> = Supplier<T> | EndpointSupplierFn<T>;
|
|
7
|
+
export declare const EndpointSupplier: {
|
|
8
|
+
get: <T>(supplier: EndpointSupplier<T>, arg: {
|
|
9
|
+
endpointMetadata?: EndpointMetadata;
|
|
10
|
+
}) => Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointSupplier = void 0;
|
|
4
|
+
exports.EndpointSupplier = {
|
|
5
|
+
get: async (supplier, arg) => {
|
|
6
|
+
if (typeof supplier === "function") {
|
|
7
|
+
return supplier(arg);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return supplier;
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type LogConfig, type Logger } from "../logging/logger.js";
|
|
2
|
+
import type { APIResponse } from "./APIResponse.js";
|
|
3
|
+
import type { EndpointMetadata } from "./EndpointMetadata.js";
|
|
4
|
+
export type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
|
|
5
|
+
export declare namespace Fetcher {
|
|
6
|
+
interface Args {
|
|
7
|
+
url: string;
|
|
8
|
+
method: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
headers?: Record<string, unknown>;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Prefer `queryString` (produced by `core.url.queryBuilder()`).
|
|
13
|
+
* Retained for backwards compatibility with custom fetchers and callers that
|
|
14
|
+
* still construct request args with a query-parameter object.
|
|
15
|
+
*/
|
|
16
|
+
queryParameters?: Record<string, unknown>;
|
|
17
|
+
queryString?: string;
|
|
18
|
+
body?: unknown;
|
|
19
|
+
timeoutMs?: number;
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
withCredentials?: boolean;
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
requestType?: "json" | "file" | "bytes" | "form" | "other";
|
|
24
|
+
responseType?: "json" | "blob" | "sse" | "streaming" | "text" | "arrayBuffer" | "binary-response";
|
|
25
|
+
duplex?: "half";
|
|
26
|
+
endpointMetadata?: EndpointMetadata;
|
|
27
|
+
fetchFn?: typeof fetch;
|
|
28
|
+
logging?: LogConfig | Logger;
|
|
29
|
+
}
|
|
30
|
+
type Error = FailedStatusCodeError | NonJsonError | BodyIsNullError | TimeoutError | UnknownError;
|
|
31
|
+
interface FailedStatusCodeError {
|
|
32
|
+
reason: "status-code";
|
|
33
|
+
statusCode: number;
|
|
34
|
+
body: unknown;
|
|
35
|
+
}
|
|
36
|
+
interface NonJsonError {
|
|
37
|
+
reason: "non-json";
|
|
38
|
+
statusCode: number;
|
|
39
|
+
rawBody: string;
|
|
40
|
+
}
|
|
41
|
+
interface BodyIsNullError {
|
|
42
|
+
reason: "body-is-null";
|
|
43
|
+
statusCode: number;
|
|
44
|
+
}
|
|
45
|
+
interface TimeoutError {
|
|
46
|
+
reason: "timeout";
|
|
47
|
+
cause?: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface UnknownError {
|
|
50
|
+
reason: "unknown";
|
|
51
|
+
errorMessage: string;
|
|
52
|
+
cause?: unknown;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export declare function fetcherImpl<R = unknown>(args: Fetcher.Args): Promise<APIResponse<R, Fetcher.Error>>;
|
|
56
|
+
export declare const fetcher: FetchFunction;
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetcher = exports.fetcherImpl = void 0;
|
|
4
|
+
const json_js_1 = require("../json.js");
|
|
5
|
+
const logger_js_1 = require("../logging/logger.js");
|
|
6
|
+
const createRequestUrl_js_1 = require("./createRequestUrl.js");
|
|
7
|
+
const EndpointSupplier_js_1 = require("./EndpointSupplier.js");
|
|
8
|
+
const getErrorResponseBody_js_1 = require("./getErrorResponseBody.js");
|
|
9
|
+
const getFetchFn_js_1 = require("./getFetchFn.js");
|
|
10
|
+
const getRequestBody_js_1 = require("./getRequestBody.js");
|
|
11
|
+
const getResponseBody_js_1 = require("./getResponseBody.js");
|
|
12
|
+
const Headers_js_1 = require("./Headers.js");
|
|
13
|
+
const makeRequest_js_1 = require("./makeRequest.js");
|
|
14
|
+
const RawResponse_js_1 = require("./RawResponse.js");
|
|
15
|
+
const requestWithRetries_js_1 = require("./requestWithRetries.js");
|
|
16
|
+
const SENSITIVE_HEADERS = new Set([
|
|
17
|
+
"authorization",
|
|
18
|
+
"www-authenticate",
|
|
19
|
+
"x-api-key",
|
|
20
|
+
"api-key",
|
|
21
|
+
"apikey",
|
|
22
|
+
"x-api-token",
|
|
23
|
+
"x-auth-token",
|
|
24
|
+
"auth-token",
|
|
25
|
+
"cookie",
|
|
26
|
+
"set-cookie",
|
|
27
|
+
"proxy-authorization",
|
|
28
|
+
"proxy-authenticate",
|
|
29
|
+
"x-csrf-token",
|
|
30
|
+
"x-xsrf-token",
|
|
31
|
+
"x-session-token",
|
|
32
|
+
"x-access-token",
|
|
33
|
+
]);
|
|
34
|
+
function redactHeaders(headers) {
|
|
35
|
+
const filtered = {};
|
|
36
|
+
for (const [key, value] of headers instanceof Headers_js_1.Headers ? headers.entries() : Object.entries(headers)) {
|
|
37
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
38
|
+
filtered[key] = "[REDACTED]";
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
filtered[key] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return filtered;
|
|
45
|
+
}
|
|
46
|
+
const SENSITIVE_QUERY_PARAMS = new Set([
|
|
47
|
+
"api_key",
|
|
48
|
+
"api-key",
|
|
49
|
+
"apikey",
|
|
50
|
+
"token",
|
|
51
|
+
"access_token",
|
|
52
|
+
"access-token",
|
|
53
|
+
"auth_token",
|
|
54
|
+
"auth-token",
|
|
55
|
+
"password",
|
|
56
|
+
"passwd",
|
|
57
|
+
"secret",
|
|
58
|
+
"api_secret",
|
|
59
|
+
"api-secret",
|
|
60
|
+
"apisecret",
|
|
61
|
+
"key",
|
|
62
|
+
"session",
|
|
63
|
+
"session_id",
|
|
64
|
+
"session-id",
|
|
65
|
+
]);
|
|
66
|
+
function redactQueryParameters(queryParameters) {
|
|
67
|
+
if (queryParameters == null) {
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
const redacted = {};
|
|
71
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
72
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
73
|
+
}
|
|
74
|
+
return redacted;
|
|
75
|
+
}
|
|
76
|
+
function redactUrl(url) {
|
|
77
|
+
const protocolIndex = url.indexOf("://");
|
|
78
|
+
if (protocolIndex === -1)
|
|
79
|
+
return url;
|
|
80
|
+
const afterProtocol = protocolIndex + 3;
|
|
81
|
+
// Find the first delimiter that marks the end of the authority section
|
|
82
|
+
const pathStart = url.indexOf("/", afterProtocol);
|
|
83
|
+
let queryStart = url.indexOf("?", afterProtocol);
|
|
84
|
+
let fragmentStart = url.indexOf("#", afterProtocol);
|
|
85
|
+
const firstDelimiter = Math.min(pathStart === -1 ? url.length : pathStart, queryStart === -1 ? url.length : queryStart, fragmentStart === -1 ? url.length : fragmentStart);
|
|
86
|
+
// Find the LAST @ before the delimiter (handles multiple @ in credentials)
|
|
87
|
+
let atIndex = -1;
|
|
88
|
+
for (let i = afterProtocol; i < firstDelimiter; i++) {
|
|
89
|
+
if (url[i] === "@") {
|
|
90
|
+
atIndex = i;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (atIndex !== -1) {
|
|
94
|
+
url = `${url.slice(0, afterProtocol)}[REDACTED]@${url.slice(atIndex + 1)}`;
|
|
95
|
+
}
|
|
96
|
+
// Recalculate queryStart since url might have changed
|
|
97
|
+
queryStart = url.indexOf("?");
|
|
98
|
+
if (queryStart === -1)
|
|
99
|
+
return url;
|
|
100
|
+
fragmentStart = url.indexOf("#", queryStart);
|
|
101
|
+
const queryEnd = fragmentStart !== -1 ? fragmentStart : url.length;
|
|
102
|
+
const queryString = url.slice(queryStart + 1, queryEnd);
|
|
103
|
+
if (queryString.length === 0)
|
|
104
|
+
return url;
|
|
105
|
+
// FAST PATH: Quick check if any sensitive keywords present
|
|
106
|
+
// Using indexOf is faster than regex for simple substring matching
|
|
107
|
+
const lower = queryString.toLowerCase();
|
|
108
|
+
const hasSensitive = lower.includes("token") ||
|
|
109
|
+
lower.includes("key") ||
|
|
110
|
+
lower.includes("password") ||
|
|
111
|
+
lower.includes("passwd") ||
|
|
112
|
+
lower.includes("secret") ||
|
|
113
|
+
lower.includes("session") ||
|
|
114
|
+
lower.includes("auth");
|
|
115
|
+
if (!hasSensitive) {
|
|
116
|
+
return url;
|
|
117
|
+
}
|
|
118
|
+
// SLOW PATH: Parse and redact
|
|
119
|
+
const redactedParams = [];
|
|
120
|
+
const params = queryString.split("&");
|
|
121
|
+
for (const param of params) {
|
|
122
|
+
const equalIndex = param.indexOf("=");
|
|
123
|
+
if (equalIndex === -1) {
|
|
124
|
+
redactedParams.push(param);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const key = param.slice(0, equalIndex);
|
|
128
|
+
let shouldRedact = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase());
|
|
129
|
+
if (!shouldRedact && key.includes("%")) {
|
|
130
|
+
try {
|
|
131
|
+
const decodedKey = decodeURIComponent(key);
|
|
132
|
+
shouldRedact = SENSITIVE_QUERY_PARAMS.has(decodedKey.toLowerCase());
|
|
133
|
+
}
|
|
134
|
+
catch (_a) { }
|
|
135
|
+
}
|
|
136
|
+
redactedParams.push(shouldRedact ? `${key}=[REDACTED]` : param);
|
|
137
|
+
}
|
|
138
|
+
return url.slice(0, queryStart + 1) + redactedParams.join("&") + url.slice(queryEnd);
|
|
139
|
+
}
|
|
140
|
+
async function getHeaders(args) {
|
|
141
|
+
var _a;
|
|
142
|
+
const newHeaders = new Headers_js_1.Headers();
|
|
143
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
144
|
+
? "application/json"
|
|
145
|
+
: args.responseType === "text"
|
|
146
|
+
? "text/plain"
|
|
147
|
+
: args.responseType === "sse"
|
|
148
|
+
? "text/event-stream"
|
|
149
|
+
: "*/*");
|
|
150
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
151
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
152
|
+
}
|
|
153
|
+
if (args.headers == null) {
|
|
154
|
+
return newHeaders;
|
|
155
|
+
}
|
|
156
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
157
|
+
const result = await EndpointSupplier_js_1.EndpointSupplier.get(value, { endpointMetadata: (_a = args.endpointMetadata) !== null && _a !== void 0 ? _a : {} });
|
|
158
|
+
if (typeof result === "string") {
|
|
159
|
+
newHeaders.set(key, result);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (result == null) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
165
|
+
newHeaders.set(key, `${result}`);
|
|
166
|
+
}
|
|
167
|
+
return newHeaders;
|
|
168
|
+
}
|
|
169
|
+
async function fetcherImpl(args) {
|
|
170
|
+
var _a, _b, _c;
|
|
171
|
+
let url = args.url;
|
|
172
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
173
|
+
url = `${url}?${args.queryString}`;
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
url = (0, createRequestUrl_js_1.createRequestUrl)(args.url, args.queryParameters);
|
|
177
|
+
}
|
|
178
|
+
const requestBody = await (0, getRequestBody_js_1.getRequestBody)({
|
|
179
|
+
body: args.body,
|
|
180
|
+
type: (_a = args.requestType) !== null && _a !== void 0 ? _a : "other",
|
|
181
|
+
});
|
|
182
|
+
const fetchFn = (_b = args.fetchFn) !== null && _b !== void 0 ? _b : (await (0, getFetchFn_js_1.getFetchFn)());
|
|
183
|
+
const headers = await getHeaders(args);
|
|
184
|
+
const logger = (0, logger_js_1.createLogger)(args.logging);
|
|
185
|
+
if (logger.isDebug()) {
|
|
186
|
+
const metadata = {
|
|
187
|
+
method: args.method,
|
|
188
|
+
url: redactUrl(url),
|
|
189
|
+
headers: redactHeaders(headers),
|
|
190
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
191
|
+
hasBody: requestBody != null,
|
|
192
|
+
};
|
|
193
|
+
logger.debug("Making HTTP request", metadata);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
const response = await (0, requestWithRetries_js_1.requestWithRetries)(async () => (0, makeRequest_js_1.makeRequest)(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse"), args.maxRetries);
|
|
197
|
+
if (response.status >= 200 && response.status < 400) {
|
|
198
|
+
if (logger.isDebug()) {
|
|
199
|
+
const metadata = {
|
|
200
|
+
method: args.method,
|
|
201
|
+
url: redactUrl(url),
|
|
202
|
+
statusCode: response.status,
|
|
203
|
+
responseHeaders: redactHeaders(response.headers),
|
|
204
|
+
};
|
|
205
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
206
|
+
}
|
|
207
|
+
const body = await (0, getResponseBody_js_1.getResponseBody)(response, args.responseType);
|
|
208
|
+
return {
|
|
209
|
+
ok: true,
|
|
210
|
+
body: body,
|
|
211
|
+
headers: response.headers,
|
|
212
|
+
rawResponse: (0, RawResponse_js_1.toRawResponse)(response),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
if (logger.isError()) {
|
|
217
|
+
const metadata = {
|
|
218
|
+
method: args.method,
|
|
219
|
+
url: redactUrl(url),
|
|
220
|
+
statusCode: response.status,
|
|
221
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
222
|
+
};
|
|
223
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
224
|
+
}
|
|
225
|
+
return {
|
|
226
|
+
ok: false,
|
|
227
|
+
error: {
|
|
228
|
+
reason: "status-code",
|
|
229
|
+
statusCode: response.status,
|
|
230
|
+
body: await (0, getErrorResponseBody_js_1.getErrorResponseBody)(response),
|
|
231
|
+
},
|
|
232
|
+
rawResponse: (0, RawResponse_js_1.toRawResponse)(response),
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (error) {
|
|
237
|
+
if ((_c = args.abortSignal) === null || _c === void 0 ? void 0 : _c.aborted) {
|
|
238
|
+
if (logger.isError()) {
|
|
239
|
+
const metadata = {
|
|
240
|
+
method: args.method,
|
|
241
|
+
url: redactUrl(url),
|
|
242
|
+
};
|
|
243
|
+
logger.error("HTTP request was aborted", metadata);
|
|
244
|
+
}
|
|
245
|
+
return {
|
|
246
|
+
ok: false,
|
|
247
|
+
error: {
|
|
248
|
+
reason: "unknown",
|
|
249
|
+
errorMessage: "The user aborted a request",
|
|
250
|
+
cause: error,
|
|
251
|
+
},
|
|
252
|
+
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
256
|
+
if (logger.isError()) {
|
|
257
|
+
const metadata = {
|
|
258
|
+
method: args.method,
|
|
259
|
+
url: redactUrl(url),
|
|
260
|
+
timeoutMs: args.timeoutMs,
|
|
261
|
+
};
|
|
262
|
+
logger.error("HTTP request timed out", metadata);
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
ok: false,
|
|
266
|
+
error: {
|
|
267
|
+
reason: "timeout",
|
|
268
|
+
cause: error,
|
|
269
|
+
},
|
|
270
|
+
rawResponse: RawResponse_js_1.abortRawResponse,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
else if (error instanceof Error) {
|
|
274
|
+
if (logger.isError()) {
|
|
275
|
+
const metadata = {
|
|
276
|
+
method: args.method,
|
|
277
|
+
url: redactUrl(url),
|
|
278
|
+
errorMessage: error.message,
|
|
279
|
+
};
|
|
280
|
+
logger.error("HTTP request failed with error", metadata);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
ok: false,
|
|
284
|
+
error: {
|
|
285
|
+
reason: "unknown",
|
|
286
|
+
errorMessage: error.message,
|
|
287
|
+
cause: error,
|
|
288
|
+
},
|
|
289
|
+
rawResponse: RawResponse_js_1.unknownRawResponse,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
if (logger.isError()) {
|
|
293
|
+
const metadata = {
|
|
294
|
+
method: args.method,
|
|
295
|
+
url: redactUrl(url),
|
|
296
|
+
error: (0, json_js_1.toJson)(error),
|
|
297
|
+
};
|
|
298
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
ok: false,
|
|
302
|
+
error: {
|
|
303
|
+
reason: "unknown",
|
|
304
|
+
errorMessage: (0, json_js_1.toJson)(error),
|
|
305
|
+
cause: error,
|
|
306
|
+
},
|
|
307
|
+
rawResponse: RawResponse_js_1.unknownRawResponse,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.fetcherImpl = fetcherImpl;
|
|
312
|
+
exports.fetcher = fetcherImpl;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Headers = void 0;
|
|
4
|
+
let Headers;
|
|
5
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
6
|
+
exports.Headers = Headers = globalThis.Headers;
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
// This is a polyfill for the Headers class that is compatible with node-fetch.
|
|
10
|
+
// We use `as any` to bypass the TypeScript compiler's type checking, as the
|
|
11
|
+
// generated polyfill is not perfectly compatible with the node-fetch types.
|
|
12
|
+
exports.Headers = Headers = class Headers {
|
|
13
|
+
constructor(init) {
|
|
14
|
+
this.headers = new Map();
|
|
15
|
+
if (init) {
|
|
16
|
+
if (init instanceof Headers) {
|
|
17
|
+
init.forEach((value, key) => this.append(key, value));
|
|
18
|
+
}
|
|
19
|
+
else if (Array.isArray(init)) {
|
|
20
|
+
for (const [key, value] of init) {
|
|
21
|
+
if (typeof key === "string" && typeof value === "string") {
|
|
22
|
+
this.append(key, value);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
for (const [key, value] of Object.entries(init)) {
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
this.append(key, value);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
throw new TypeError("Header values must be strings");
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
append(name, value) {
|
|
42
|
+
const key = name.toLowerCase();
|
|
43
|
+
const existing = this.headers.get(key) || [];
|
|
44
|
+
this.headers.set(key, [...existing, value]);
|
|
45
|
+
}
|
|
46
|
+
delete(name) {
|
|
47
|
+
const key = name.toLowerCase();
|
|
48
|
+
this.headers.delete(key);
|
|
49
|
+
}
|
|
50
|
+
get(name) {
|
|
51
|
+
const key = name.toLowerCase();
|
|
52
|
+
const values = this.headers.get(key);
|
|
53
|
+
return values ? values.join(", ") : null;
|
|
54
|
+
}
|
|
55
|
+
has(name) {
|
|
56
|
+
const key = name.toLowerCase();
|
|
57
|
+
return this.headers.has(key);
|
|
58
|
+
}
|
|
59
|
+
set(name, value) {
|
|
60
|
+
const key = name.toLowerCase();
|
|
61
|
+
this.headers.set(key, [value]);
|
|
62
|
+
}
|
|
63
|
+
forEach(callbackfn, thisArg) {
|
|
64
|
+
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
65
|
+
// @ts-ignore
|
|
66
|
+
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
67
|
+
}
|
|
68
|
+
*entries() {
|
|
69
|
+
for (const [key, values] of this.headers.entries()) {
|
|
70
|
+
yield [key, values.join(", ")];
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
*keys() {
|
|
74
|
+
yield* this.headers.keys();
|
|
75
|
+
}
|
|
76
|
+
*values() {
|
|
77
|
+
for (const values of this.headers.values()) {
|
|
78
|
+
yield values.join(", ");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
[Symbol.iterator]() {
|
|
82
|
+
return this.entries();
|
|
83
|
+
}
|
|
84
|
+
raw() {
|
|
85
|
+
const result = {};
|
|
86
|
+
for (const [key, values] of this.headers.entries()) {
|
|
87
|
+
result[key] = values;
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { WithRawResponse } from "./RawResponse.js";
|
|
2
|
+
/**
|
|
3
|
+
* A promise that returns the parsed response and lets you retrieve the raw response too.
|
|
4
|
+
*/
|
|
5
|
+
export declare class HttpResponsePromise<T> extends Promise<T> {
|
|
6
|
+
private innerPromise;
|
|
7
|
+
private unwrappedPromise;
|
|
8
|
+
private constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Creates an `HttpResponsePromise` from a function that returns a promise.
|
|
11
|
+
*
|
|
12
|
+
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
13
|
+
* @param args - Arguments to pass to the function.
|
|
14
|
+
* @returns An `HttpResponsePromise` instance.
|
|
15
|
+
*/
|
|
16
|
+
static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
|
|
19
|
+
*
|
|
20
|
+
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
|
|
21
|
+
* @returns A function that returns an `HttpResponsePromise` instance.
|
|
22
|
+
*/
|
|
23
|
+
static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
|
|
24
|
+
/**
|
|
25
|
+
* Creates an `HttpResponsePromise` from an existing promise.
|
|
26
|
+
*
|
|
27
|
+
* @param promise - A promise resolving to a `WithRawResponse` object.
|
|
28
|
+
* @returns An `HttpResponsePromise` instance.
|
|
29
|
+
*/
|
|
30
|
+
static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates an `HttpResponsePromise` from an executor function.
|
|
33
|
+
*
|
|
34
|
+
* @param executor - A function that takes resolve and reject callbacks to create a promise.
|
|
35
|
+
* @returns An `HttpResponsePromise` instance.
|
|
36
|
+
*/
|
|
37
|
+
static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Creates an `HttpResponsePromise` from a resolved result.
|
|
40
|
+
*
|
|
41
|
+
* @param result - A `WithRawResponse` object to resolve immediately.
|
|
42
|
+
* @returns An `HttpResponsePromise` instance.
|
|
43
|
+
*/
|
|
44
|
+
static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
|
|
45
|
+
private unwrap;
|
|
46
|
+
/** @inheritdoc */
|
|
47
|
+
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
48
|
+
/** @inheritdoc */
|
|
49
|
+
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
50
|
+
/** @inheritdoc */
|
|
51
|
+
finally(onfinally?: (() => void) | null): Promise<T>;
|
|
52
|
+
/**
|
|
53
|
+
* Retrieves the data and raw response.
|
|
54
|
+
*
|
|
55
|
+
* @returns A promise resolving to a `WithRawResponse` object.
|
|
56
|
+
*/
|
|
57
|
+
withRawResponse(): Promise<WithRawResponse<T>>;
|
|
58
|
+
}
|