@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,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestWithRetries = void 0;
|
|
4
|
+
const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
5
|
+
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
6
|
+
const DEFAULT_MAX_RETRIES = 2;
|
|
7
|
+
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
8
|
+
function isRetryableStatusCode(statusCode) {
|
|
9
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
10
|
+
}
|
|
11
|
+
function addPositiveJitter(delay) {
|
|
12
|
+
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
13
|
+
return delay * jitterMultiplier;
|
|
14
|
+
}
|
|
15
|
+
function addSymmetricJitter(delay) {
|
|
16
|
+
const jitterMultiplier = 1 + (Math.random() - 0.5) * JITTER_FACTOR;
|
|
17
|
+
return delay * jitterMultiplier;
|
|
18
|
+
}
|
|
19
|
+
function getRetryDelayFromHeaders(response, retryAttempt) {
|
|
20
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
21
|
+
if (retryAfter) {
|
|
22
|
+
const retryAfterSeconds = parseInt(retryAfter, 10);
|
|
23
|
+
if (!Number.isNaN(retryAfterSeconds) && retryAfterSeconds > 0) {
|
|
24
|
+
return Math.min(retryAfterSeconds * 1000, MAX_RETRY_DELAY);
|
|
25
|
+
}
|
|
26
|
+
const retryAfterDate = new Date(retryAfter);
|
|
27
|
+
if (!Number.isNaN(retryAfterDate.getTime())) {
|
|
28
|
+
const delay = retryAfterDate.getTime() - Date.now();
|
|
29
|
+
if (delay > 0) {
|
|
30
|
+
return Math.min(Math.max(delay, 0), MAX_RETRY_DELAY);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const rateLimitReset = response.headers.get("X-RateLimit-Reset");
|
|
35
|
+
if (rateLimitReset) {
|
|
36
|
+
const resetTime = parseInt(rateLimitReset, 10);
|
|
37
|
+
if (!Number.isNaN(resetTime)) {
|
|
38
|
+
const delay = resetTime * 1000 - Date.now();
|
|
39
|
+
if (delay > 0) {
|
|
40
|
+
return addPositiveJitter(Math.min(delay, MAX_RETRY_DELAY));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return addSymmetricJitter(Math.min(INITIAL_RETRY_DELAY * 2 ** retryAttempt, MAX_RETRY_DELAY));
|
|
45
|
+
}
|
|
46
|
+
async function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
47
|
+
let response = await requestFn();
|
|
48
|
+
for (let i = 0; i < maxRetries; ++i) {
|
|
49
|
+
if (isRetryableStatusCode(response.status)) {
|
|
50
|
+
const delay = getRetryDelayFromHeaders(response, i);
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
52
|
+
response = await requestFn();
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return response;
|
|
59
|
+
}
|
|
60
|
+
exports.requestWithRetries = requestWithRetries;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.anySignal = exports.getTimeoutSignal = void 0;
|
|
4
|
+
const TIMEOUT = "timeout";
|
|
5
|
+
function getTimeoutSignal(timeoutMs) {
|
|
6
|
+
const controller = new AbortController();
|
|
7
|
+
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
8
|
+
return { signal: controller.signal, abortId };
|
|
9
|
+
}
|
|
10
|
+
exports.getTimeoutSignal = getTimeoutSignal;
|
|
11
|
+
function anySignal(...args) {
|
|
12
|
+
const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
|
|
13
|
+
const controller = new AbortController();
|
|
14
|
+
for (const signal of signals) {
|
|
15
|
+
if (signal.aborted) {
|
|
16
|
+
controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
signal.addEventListener("abort", () => controller.abort(signal === null || signal === void 0 ? void 0 : signal.reason), {
|
|
20
|
+
signal: controller.signal,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return controller.signal;
|
|
24
|
+
}
|
|
25
|
+
exports.anySignal = anySignal;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Uploadable } from "./types.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Uploadable } from "./types.js";
|
|
2
|
+
export declare function toBinaryUploadRequest(file: Uploadable): Promise<{
|
|
3
|
+
body: Uploadable.FileLike;
|
|
4
|
+
headers?: Record<string, string>;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function toMultipartDataPart(file: Uploadable): Promise<{
|
|
7
|
+
data: Uploadable.FileLike;
|
|
8
|
+
filename?: string;
|
|
9
|
+
contentType?: string;
|
|
10
|
+
}>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.toMultipartDataPart = exports.toBinaryUploadRequest = void 0;
|
|
27
|
+
async function toBinaryUploadRequest(file) {
|
|
28
|
+
const { data, filename, contentLength, contentType } = await getFileWithMetadata(file);
|
|
29
|
+
const request = {
|
|
30
|
+
body: data,
|
|
31
|
+
headers: {},
|
|
32
|
+
};
|
|
33
|
+
if (filename) {
|
|
34
|
+
request.headers["Content-Disposition"] = `attachment; filename="${filename}"`;
|
|
35
|
+
}
|
|
36
|
+
if (contentType) {
|
|
37
|
+
request.headers["Content-Type"] = contentType;
|
|
38
|
+
}
|
|
39
|
+
if (contentLength != null) {
|
|
40
|
+
request.headers["Content-Length"] = contentLength.toString();
|
|
41
|
+
}
|
|
42
|
+
return request;
|
|
43
|
+
}
|
|
44
|
+
exports.toBinaryUploadRequest = toBinaryUploadRequest;
|
|
45
|
+
async function toMultipartDataPart(file) {
|
|
46
|
+
const { data, filename, contentType } = await getFileWithMetadata(file, {
|
|
47
|
+
noSniffFileSize: true,
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
data,
|
|
51
|
+
filename,
|
|
52
|
+
contentType,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
exports.toMultipartDataPart = toMultipartDataPart;
|
|
56
|
+
async function getFileWithMetadata(file, { noSniffFileSize } = {}) {
|
|
57
|
+
var _a, _b, _c, _d, _e;
|
|
58
|
+
if (isFileLike(file)) {
|
|
59
|
+
return getFileWithMetadata({
|
|
60
|
+
data: file,
|
|
61
|
+
}, { noSniffFileSize });
|
|
62
|
+
}
|
|
63
|
+
if ("path" in file) {
|
|
64
|
+
const fs = await Promise.resolve().then(() => __importStar(require("fs")));
|
|
65
|
+
if (!(fs === null || fs === void 0 ? void 0 : fs.createReadStream)) {
|
|
66
|
+
throw new Error("File path uploads are not supported in this environment.");
|
|
67
|
+
}
|
|
68
|
+
const data = fs.createReadStream(file.path);
|
|
69
|
+
const contentLength = (_a = file.contentLength) !== null && _a !== void 0 ? _a : (noSniffFileSize === true ? undefined : await tryGetFileSizeFromPath(file.path));
|
|
70
|
+
const filename = (_b = file.filename) !== null && _b !== void 0 ? _b : getNameFromPath(file.path);
|
|
71
|
+
return {
|
|
72
|
+
data,
|
|
73
|
+
filename,
|
|
74
|
+
contentType: file.contentType,
|
|
75
|
+
contentLength,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if ("data" in file) {
|
|
79
|
+
const data = file.data;
|
|
80
|
+
const contentLength = (_c = file.contentLength) !== null && _c !== void 0 ? _c : (await tryGetContentLengthFromFileLike(data, {
|
|
81
|
+
noSniffFileSize,
|
|
82
|
+
}));
|
|
83
|
+
const filename = (_d = file.filename) !== null && _d !== void 0 ? _d : tryGetNameFromFileLike(data);
|
|
84
|
+
return {
|
|
85
|
+
data,
|
|
86
|
+
filename,
|
|
87
|
+
contentType: (_e = file.contentType) !== null && _e !== void 0 ? _e : tryGetContentTypeFromFileLike(data),
|
|
88
|
+
contentLength,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`Invalid FileUpload of type ${typeof file}: ${JSON.stringify(file)}`);
|
|
92
|
+
}
|
|
93
|
+
function isFileLike(value) {
|
|
94
|
+
return (isBuffer(value) ||
|
|
95
|
+
isArrayBufferView(value) ||
|
|
96
|
+
isArrayBuffer(value) ||
|
|
97
|
+
isUint8Array(value) ||
|
|
98
|
+
isBlob(value) ||
|
|
99
|
+
isFile(value) ||
|
|
100
|
+
isStreamLike(value) ||
|
|
101
|
+
isReadableStream(value));
|
|
102
|
+
}
|
|
103
|
+
async function tryGetFileSizeFromPath(path) {
|
|
104
|
+
var _a;
|
|
105
|
+
try {
|
|
106
|
+
const fs = await Promise.resolve().then(() => __importStar(require("fs")));
|
|
107
|
+
if (!((_a = fs === null || fs === void 0 ? void 0 : fs.promises) === null || _a === void 0 ? void 0 : _a.stat)) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const fileStat = await fs.promises.stat(path);
|
|
111
|
+
return fileStat.size;
|
|
112
|
+
}
|
|
113
|
+
catch (_fallbackError) {
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function tryGetNameFromFileLike(data) {
|
|
118
|
+
if (isNamedValue(data)) {
|
|
119
|
+
return data.name;
|
|
120
|
+
}
|
|
121
|
+
if (isPathedValue(data)) {
|
|
122
|
+
return getNameFromPath(data.path.toString());
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
async function tryGetContentLengthFromFileLike(data, { noSniffFileSize } = {}) {
|
|
127
|
+
if (isBuffer(data)) {
|
|
128
|
+
return data.length;
|
|
129
|
+
}
|
|
130
|
+
if (isArrayBufferView(data)) {
|
|
131
|
+
return data.byteLength;
|
|
132
|
+
}
|
|
133
|
+
if (isArrayBuffer(data)) {
|
|
134
|
+
return data.byteLength;
|
|
135
|
+
}
|
|
136
|
+
if (isBlob(data)) {
|
|
137
|
+
return data.size;
|
|
138
|
+
}
|
|
139
|
+
if (isFile(data)) {
|
|
140
|
+
return data.size;
|
|
141
|
+
}
|
|
142
|
+
if (noSniffFileSize === true) {
|
|
143
|
+
return undefined;
|
|
144
|
+
}
|
|
145
|
+
if (isPathedValue(data)) {
|
|
146
|
+
return await tryGetFileSizeFromPath(data.path.toString());
|
|
147
|
+
}
|
|
148
|
+
return undefined;
|
|
149
|
+
}
|
|
150
|
+
function tryGetContentTypeFromFileLike(data) {
|
|
151
|
+
if (isBlob(data)) {
|
|
152
|
+
return data.type;
|
|
153
|
+
}
|
|
154
|
+
if (isFile(data)) {
|
|
155
|
+
return data.type;
|
|
156
|
+
}
|
|
157
|
+
return undefined;
|
|
158
|
+
}
|
|
159
|
+
function getNameFromPath(path) {
|
|
160
|
+
const lastForwardSlash = path.lastIndexOf("/");
|
|
161
|
+
const lastBackSlash = path.lastIndexOf("\\");
|
|
162
|
+
const lastSlashIndex = Math.max(lastForwardSlash, lastBackSlash);
|
|
163
|
+
return lastSlashIndex >= 0 ? path.substring(lastSlashIndex + 1) : path;
|
|
164
|
+
}
|
|
165
|
+
function isNamedValue(value) {
|
|
166
|
+
return typeof value === "object" && value != null && "name" in value;
|
|
167
|
+
}
|
|
168
|
+
function isPathedValue(value) {
|
|
169
|
+
return typeof value === "object" && value != null && "path" in value;
|
|
170
|
+
}
|
|
171
|
+
function isStreamLike(value) {
|
|
172
|
+
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
173
|
+
}
|
|
174
|
+
function isReadableStream(value) {
|
|
175
|
+
return typeof value === "object" && value != null && "getReader" in value;
|
|
176
|
+
}
|
|
177
|
+
function isBuffer(value) {
|
|
178
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
179
|
+
}
|
|
180
|
+
function isArrayBufferView(value) {
|
|
181
|
+
return typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView(value);
|
|
182
|
+
}
|
|
183
|
+
function isArrayBuffer(value) {
|
|
184
|
+
return typeof ArrayBuffer !== "undefined" && value instanceof ArrayBuffer;
|
|
185
|
+
}
|
|
186
|
+
function isUint8Array(value) {
|
|
187
|
+
return typeof Uint8Array !== "undefined" && value instanceof Uint8Array;
|
|
188
|
+
}
|
|
189
|
+
function isBlob(value) {
|
|
190
|
+
return typeof Blob !== "undefined" && value instanceof Blob;
|
|
191
|
+
}
|
|
192
|
+
function isFile(value) {
|
|
193
|
+
return typeof File !== "undefined" && value instanceof File;
|
|
194
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file.js"), exports);
|
|
18
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
/**
|
|
6
|
+
* A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
|
|
7
|
+
* a path to a file, or an object with a file-like object and metadata.
|
|
8
|
+
*/
|
|
9
|
+
export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
|
|
10
|
+
export declare namespace Uploadable {
|
|
11
|
+
/**
|
|
12
|
+
* Various file-like objects that can be used to upload a file.
|
|
13
|
+
*/
|
|
14
|
+
type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
|
|
15
|
+
/**
|
|
16
|
+
* A file path with optional metadata, used for uploading a file from the file system.
|
|
17
|
+
*/
|
|
18
|
+
type FromPath = {
|
|
19
|
+
/** The path to the file to upload */
|
|
20
|
+
path: string;
|
|
21
|
+
/**
|
|
22
|
+
* Optional override for the file name (defaults to basename of path).
|
|
23
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
24
|
+
*/
|
|
25
|
+
filename?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
28
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
29
|
+
*/
|
|
30
|
+
contentType?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional file size in bytes.
|
|
33
|
+
* If not provided, the file size will be determined from the file system.
|
|
34
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
35
|
+
*/
|
|
36
|
+
contentLength?: number;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A file-like object with metadata, used for uploading files.
|
|
40
|
+
*/
|
|
41
|
+
type WithMetadata = {
|
|
42
|
+
/** The file data */
|
|
43
|
+
data: FileLike;
|
|
44
|
+
/**
|
|
45
|
+
* Optional override for the file name (defaults to basename of path).
|
|
46
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
47
|
+
*/
|
|
48
|
+
filename?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
51
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
52
|
+
*
|
|
53
|
+
* If not provided, the content type may be determined from the data itself.
|
|
54
|
+
* * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
|
|
55
|
+
* * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
|
|
56
|
+
*/
|
|
57
|
+
contentType?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Optional file size in bytes.
|
|
60
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
61
|
+
* If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
|
|
62
|
+
*
|
|
63
|
+
* If not provided, the file size will be determined depending on the data type.
|
|
64
|
+
* * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
|
|
65
|
+
* * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
|
|
66
|
+
* * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
|
|
67
|
+
*/
|
|
68
|
+
contentLength?: number;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Uploadable } from "../../core/file/index.js";
|
|
2
|
+
interface FormDataRequest<Body> {
|
|
3
|
+
body: Body;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
duplex?: "half";
|
|
6
|
+
}
|
|
7
|
+
export declare function newFormData(): Promise<FormDataWrapper>;
|
|
8
|
+
export declare class FormDataWrapper {
|
|
9
|
+
private fd;
|
|
10
|
+
setup(): Promise<void>;
|
|
11
|
+
append(key: string, value: unknown): void;
|
|
12
|
+
appendFile(key: string, value: Uploadable): Promise<void>;
|
|
13
|
+
getRequest(): FormDataRequest<FormData>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
26
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
27
|
+
var m = o[Symbol.asyncIterator], i;
|
|
28
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
29
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
30
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
31
|
+
};
|
|
32
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
+
exports.FormDataWrapper = exports.newFormData = void 0;
|
|
34
|
+
const index_js_1 = require("../../core/file/index.js");
|
|
35
|
+
const json_js_1 = require("../../core/json.js");
|
|
36
|
+
const index_js_2 = require("../runtime/index.js");
|
|
37
|
+
async function newFormData() {
|
|
38
|
+
return new FormDataWrapper();
|
|
39
|
+
}
|
|
40
|
+
exports.newFormData = newFormData;
|
|
41
|
+
class FormDataWrapper {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.fd = new FormData();
|
|
44
|
+
}
|
|
45
|
+
async setup() {
|
|
46
|
+
// noop
|
|
47
|
+
}
|
|
48
|
+
append(key, value) {
|
|
49
|
+
this.fd.append(key, String(value));
|
|
50
|
+
}
|
|
51
|
+
async appendFile(key, value) {
|
|
52
|
+
const { data, filename, contentType } = await (0, index_js_1.toMultipartDataPart)(value);
|
|
53
|
+
const blob = await convertToBlob(data, contentType);
|
|
54
|
+
if (filename) {
|
|
55
|
+
this.fd.append(key, blob, filename);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.fd.append(key, blob);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
getRequest() {
|
|
62
|
+
return {
|
|
63
|
+
body: this.fd,
|
|
64
|
+
headers: {},
|
|
65
|
+
duplex: "half",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.FormDataWrapper = FormDataWrapper;
|
|
70
|
+
function isStreamLike(value) {
|
|
71
|
+
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
72
|
+
}
|
|
73
|
+
function isReadableStream(value) {
|
|
74
|
+
return typeof value === "object" && value != null && "getReader" in value;
|
|
75
|
+
}
|
|
76
|
+
function isBuffer(value) {
|
|
77
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
78
|
+
}
|
|
79
|
+
function isArrayBufferView(value) {
|
|
80
|
+
return ArrayBuffer.isView(value);
|
|
81
|
+
}
|
|
82
|
+
async function streamToBuffer(stream) {
|
|
83
|
+
var _a, e_1, _b, _c;
|
|
84
|
+
if (index_js_2.RUNTIME.type === "node") {
|
|
85
|
+
const { Readable } = await Promise.resolve().then(() => __importStar(require("stream")));
|
|
86
|
+
if (stream instanceof Readable) {
|
|
87
|
+
const chunks = [];
|
|
88
|
+
try {
|
|
89
|
+
for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = await stream_1.next(), _a = stream_1_1.done, !_a; _d = true) {
|
|
90
|
+
_c = stream_1_1.value;
|
|
91
|
+
_d = false;
|
|
92
|
+
const chunk = _c;
|
|
93
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
97
|
+
finally {
|
|
98
|
+
try {
|
|
99
|
+
if (!_d && !_a && (_b = stream_1.return)) await _b.call(stream_1);
|
|
100
|
+
}
|
|
101
|
+
finally { if (e_1) throw e_1.error; }
|
|
102
|
+
}
|
|
103
|
+
return Buffer.concat(chunks);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (isReadableStream(stream)) {
|
|
107
|
+
const reader = stream.getReader();
|
|
108
|
+
const chunks = [];
|
|
109
|
+
try {
|
|
110
|
+
while (true) {
|
|
111
|
+
const { done, value } = await reader.read();
|
|
112
|
+
if (done)
|
|
113
|
+
break;
|
|
114
|
+
chunks.push(value);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
finally {
|
|
118
|
+
reader.releaseLock();
|
|
119
|
+
}
|
|
120
|
+
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
121
|
+
const result = new Uint8Array(totalLength);
|
|
122
|
+
let offset = 0;
|
|
123
|
+
for (const chunk of chunks) {
|
|
124
|
+
result.set(chunk, offset);
|
|
125
|
+
offset += chunk.length;
|
|
126
|
+
}
|
|
127
|
+
return Buffer.from(result);
|
|
128
|
+
}
|
|
129
|
+
throw new Error(`Unsupported stream type: ${typeof stream}. Expected Node.js Readable stream or Web ReadableStream.`);
|
|
130
|
+
}
|
|
131
|
+
async function convertToBlob(value, contentType) {
|
|
132
|
+
if (isStreamLike(value) || isReadableStream(value)) {
|
|
133
|
+
const buffer = await streamToBuffer(value);
|
|
134
|
+
return new Blob([buffer], { type: contentType });
|
|
135
|
+
}
|
|
136
|
+
if (value instanceof Blob) {
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
if (isBuffer(value)) {
|
|
140
|
+
return new Blob([value], { type: contentType });
|
|
141
|
+
}
|
|
142
|
+
if (value instanceof ArrayBuffer) {
|
|
143
|
+
return new Blob([value], { type: contentType });
|
|
144
|
+
}
|
|
145
|
+
if (isArrayBufferView(value)) {
|
|
146
|
+
return new Blob([value], { type: contentType });
|
|
147
|
+
}
|
|
148
|
+
if (typeof value === "string") {
|
|
149
|
+
return new Blob([value], { type: contentType });
|
|
150
|
+
}
|
|
151
|
+
if (typeof value === "object" && value !== null) {
|
|
152
|
+
return new Blob([(0, json_js_1.toJson)(value)], { type: contentType !== null && contentType !== void 0 ? contentType : "application/json" });
|
|
153
|
+
}
|
|
154
|
+
return new Blob([String(value)], { type: contentType });
|
|
155
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeAsFormParameter(value: unknown): Record<string, string>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeAsFormParameter = void 0;
|
|
4
|
+
const qs_js_1 = require("../url/qs.js");
|
|
5
|
+
function encodeAsFormParameter(value) {
|
|
6
|
+
const stringified = (0, qs_js_1.toQueryString)(value, { encode: false });
|
|
7
|
+
const keyValuePairs = stringified.split("&").map((pair) => {
|
|
8
|
+
const [key, value] = pair.split("=");
|
|
9
|
+
return [key, value];
|
|
10
|
+
});
|
|
11
|
+
return Object.fromEntries(keyValuePairs);
|
|
12
|
+
}
|
|
13
|
+
exports.encodeAsFormParameter = encodeAsFormParameter;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.encodeAsFormParameter = void 0;
|
|
18
|
+
var encodeAsFormParameter_js_1 = require("./encodeAsFormParameter.js");
|
|
19
|
+
Object.defineProperty(exports, "encodeAsFormParameter", { enumerable: true, get: function () { return encodeAsFormParameter_js_1.encodeAsFormParameter; } });
|
|
20
|
+
__exportStar(require("./FormDataWrapper.js"), exports);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as core from "./index.js";
|
|
2
|
+
export declare function mergeHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|
|
3
|
+
export declare function mergeOnlyDefinedHeaders(...headersArray: (Record<string, string | core.Supplier<string | undefined> | undefined> | undefined)[]): Record<string, string | core.Supplier<string | undefined>>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeOnlyDefinedHeaders = exports.mergeHeaders = void 0;
|
|
4
|
+
function mergeHeaders(...headersArray) {
|
|
5
|
+
const result = {};
|
|
6
|
+
for (const [key, value] of headersArray
|
|
7
|
+
.filter((headers) => headers != null)
|
|
8
|
+
.flatMap((headers) => Object.entries(headers || {}))) {
|
|
9
|
+
if (value != null) {
|
|
10
|
+
result[key] = value;
|
|
11
|
+
}
|
|
12
|
+
else if (key in result) {
|
|
13
|
+
delete result[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
exports.mergeHeaders = mergeHeaders;
|
|
19
|
+
function mergeOnlyDefinedHeaders(...headersArray) {
|
|
20
|
+
const result = {};
|
|
21
|
+
for (const [key, value] of headersArray
|
|
22
|
+
.filter((headers) => headers != null)
|
|
23
|
+
.flatMap((headers) => Object.entries(headers || {}))) {
|
|
24
|
+
if (value != null) {
|
|
25
|
+
result[key] = value;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
exports.mergeOnlyDefinedHeaders = mergeOnlyDefinedHeaders;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./auth/index.js";
|
|
2
|
+
export * from "./base64.js";
|
|
3
|
+
export * from "./fetcher/index.js";
|
|
4
|
+
export * as file from "./file/index.js";
|
|
5
|
+
export * from "./form-data-utils/index.js";
|
|
6
|
+
export * as logging from "./logging/index.js";
|
|
7
|
+
export * from "./runtime/index.js";
|
|
8
|
+
export * as url from "./url/index.js";
|