@tapra/sdk 0.0.0-stage → 0.1.2
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/README.md +60 -2
- package/dist/lib/index.d.ts +5 -0
- package/dist/lib/index.js +7 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/pricing.d.ts +70 -0
- package/dist/lib/pricing.js +67 -0
- package/dist/lib/pricing.js.map +1 -0
- package/dist/lib/realtime.d.ts +99 -0
- package/dist/lib/realtime.js +230 -0
- package/dist/lib/realtime.js.map +1 -0
- package/dist/src/BaseClient.d.ts +57 -0
- package/dist/src/BaseClient.js +37 -0
- package/dist/src/BaseClient.js.map +1 -0
- package/dist/src/Client.d.ts +41 -0
- package/dist/src/Client.js +61 -0
- package/dist/src/Client.js.map +1 -0
- package/dist/src/api/errors/BadRequestError.d.ts +7 -0
- package/dist/src/api/errors/BadRequestError.js +18 -0
- package/dist/src/api/errors/BadRequestError.js.map +1 -0
- package/dist/src/api/errors/ContentTooLargeError.d.ts +7 -0
- package/dist/src/api/errors/ContentTooLargeError.js +18 -0
- package/dist/src/api/errors/ContentTooLargeError.js.map +1 -0
- package/dist/src/api/errors/ForbiddenError.d.ts +7 -0
- package/dist/src/api/errors/ForbiddenError.js +18 -0
- package/dist/src/api/errors/ForbiddenError.js.map +1 -0
- package/dist/src/api/errors/InternalServerError.d.ts +7 -0
- package/dist/src/api/errors/InternalServerError.js +18 -0
- package/dist/src/api/errors/InternalServerError.js.map +1 -0
- package/dist/src/api/errors/PaymentRequiredError.d.ts +7 -0
- package/dist/src/api/errors/PaymentRequiredError.js +18 -0
- package/dist/src/api/errors/PaymentRequiredError.js.map +1 -0
- package/dist/src/api/errors/ServiceUnavailableError.d.ts +7 -0
- package/dist/src/api/errors/ServiceUnavailableError.js +18 -0
- package/dist/src/api/errors/ServiceUnavailableError.js.map +1 -0
- package/dist/src/api/errors/TooManyRequestsError.d.ts +7 -0
- package/dist/src/api/errors/TooManyRequestsError.js +18 -0
- package/dist/src/api/errors/TooManyRequestsError.js.map +1 -0
- package/dist/src/api/errors/UnauthorizedError.d.ts +7 -0
- package/dist/src/api/errors/UnauthorizedError.js +18 -0
- package/dist/src/api/errors/UnauthorizedError.js.map +1 -0
- package/dist/src/api/errors/index.d.ts +8 -0
- package/dist/src/api/errors/index.js +9 -0
- package/dist/src/api/errors/index.js.map +1 -0
- package/dist/src/api/index.d.ts +3 -0
- package/dist/src/api/index.js +4 -0
- package/dist/src/api/index.js.map +1 -0
- package/dist/src/api/resources/diarization/client/Client.d.ts +40 -0
- package/dist/src/api/resources/diarization/client/Client.js +97 -0
- package/dist/src/api/resources/diarization/client/Client.js.map +1 -0
- package/dist/src/api/resources/diarization/client/index.d.ts +1 -0
- package/dist/src/api/resources/diarization/client/index.js +2 -0
- package/dist/src/api/resources/diarization/client/index.js.map +1 -0
- package/dist/src/api/resources/diarization/client/requests/DiarizationRequest.d.ts +11 -0
- package/dist/src/api/resources/diarization/client/requests/DiarizationRequest.js +3 -0
- package/dist/src/api/resources/diarization/client/requests/DiarizationRequest.js.map +1 -0
- package/dist/src/api/resources/diarization/client/requests/index.d.ts +1 -0
- package/dist/src/api/resources/diarization/client/requests/index.js +2 -0
- package/dist/src/api/resources/diarization/client/requests/index.js.map +1 -0
- package/dist/src/api/resources/diarization/exports.d.ts +2 -0
- package/dist/src/api/resources/diarization/exports.js +4 -0
- package/dist/src/api/resources/diarization/exports.js.map +1 -0
- package/dist/src/api/resources/diarization/index.d.ts +1 -0
- package/dist/src/api/resources/diarization/index.js +2 -0
- package/dist/src/api/resources/diarization/index.js.map +1 -0
- package/dist/src/api/resources/index.d.ts +11 -0
- package/dist/src/api/resources/index.js +12 -0
- package/dist/src/api/resources/index.js.map +1 -0
- package/dist/src/api/resources/models/client/Client.d.ts +27 -0
- package/dist/src/api/resources/models/client/Client.js +56 -0
- package/dist/src/api/resources/models/client/Client.js.map +1 -0
- package/dist/src/api/resources/models/client/index.d.ts +1 -0
- package/dist/src/api/resources/models/client/index.js +2 -0
- package/dist/src/api/resources/models/client/index.js.map +1 -0
- package/dist/src/api/resources/models/exports.d.ts +2 -0
- package/dist/src/api/resources/models/exports.js +4 -0
- package/dist/src/api/resources/models/exports.js.map +1 -0
- package/dist/src/api/resources/models/index.d.ts +1 -0
- package/dist/src/api/resources/models/index.js +2 -0
- package/dist/src/api/resources/models/index.js.map +1 -0
- package/dist/src/api/resources/script/client/Client.d.ts +47 -0
- package/dist/src/api/resources/script/client/Client.js +99 -0
- package/dist/src/api/resources/script/client/Client.js.map +1 -0
- package/dist/src/api/resources/script/client/index.d.ts +1 -0
- package/dist/src/api/resources/script/client/index.js +2 -0
- package/dist/src/api/resources/script/client/index.js.map +1 -0
- package/dist/src/api/resources/script/client/requests/ConversionRequest.d.ts +26 -0
- package/dist/src/api/resources/script/client/requests/ConversionRequest.js +10 -0
- package/dist/src/api/resources/script/client/requests/ConversionRequest.js.map +1 -0
- package/dist/src/api/resources/script/client/requests/index.d.ts +1 -0
- package/dist/src/api/resources/script/client/requests/index.js +2 -0
- package/dist/src/api/resources/script/client/requests/index.js.map +1 -0
- package/dist/src/api/resources/script/exports.d.ts +2 -0
- package/dist/src/api/resources/script/exports.js +4 -0
- package/dist/src/api/resources/script/exports.js.map +1 -0
- package/dist/src/api/resources/script/index.d.ts +1 -0
- package/dist/src/api/resources/script/index.js +2 -0
- package/dist/src/api/resources/script/index.js.map +1 -0
- package/dist/src/api/resources/speech/client/Client.d.ts +43 -0
- package/dist/src/api/resources/speech/client/Client.js +136 -0
- package/dist/src/api/resources/speech/client/Client.js.map +1 -0
- package/dist/src/api/resources/speech/client/index.d.ts +1 -0
- package/dist/src/api/resources/speech/client/index.js +2 -0
- package/dist/src/api/resources/speech/client/index.js.map +1 -0
- package/dist/src/api/resources/speech/client/requests/SpeechRequest.d.ts +50 -0
- package/dist/src/api/resources/speech/client/requests/SpeechRequest.js +23 -0
- package/dist/src/api/resources/speech/client/requests/SpeechRequest.js.map +1 -0
- package/dist/src/api/resources/speech/client/requests/index.d.ts +1 -0
- package/dist/src/api/resources/speech/client/requests/index.js +2 -0
- package/dist/src/api/resources/speech/client/requests/index.js.map +1 -0
- package/dist/src/api/resources/speech/exports.d.ts +2 -0
- package/dist/src/api/resources/speech/exports.js +4 -0
- package/dist/src/api/resources/speech/exports.js.map +1 -0
- package/dist/src/api/resources/speech/index.d.ts +1 -0
- package/dist/src/api/resources/speech/index.js +2 -0
- package/dist/src/api/resources/speech/index.js.map +1 -0
- package/dist/src/api/resources/transcriptions/client/Client.d.ts +40 -0
- package/dist/src/api/resources/transcriptions/client/Client.js +118 -0
- package/dist/src/api/resources/transcriptions/client/Client.js.map +1 -0
- package/dist/src/api/resources/transcriptions/client/index.d.ts +1 -0
- package/dist/src/api/resources/transcriptions/client/index.js +2 -0
- package/dist/src/api/resources/transcriptions/client/index.js.map +1 -0
- package/dist/src/api/resources/transcriptions/client/requests/TranscriptionRequest.d.ts +32 -0
- package/dist/src/api/resources/transcriptions/client/requests/TranscriptionRequest.js +10 -0
- package/dist/src/api/resources/transcriptions/client/requests/TranscriptionRequest.js.map +1 -0
- package/dist/src/api/resources/transcriptions/client/requests/index.d.ts +1 -0
- package/dist/src/api/resources/transcriptions/client/requests/index.js +2 -0
- package/dist/src/api/resources/transcriptions/client/requests/index.js.map +1 -0
- package/dist/src/api/resources/transcriptions/exports.d.ts +2 -0
- package/dist/src/api/resources/transcriptions/exports.js +4 -0
- package/dist/src/api/resources/transcriptions/exports.js.map +1 -0
- package/dist/src/api/resources/transcriptions/index.d.ts +1 -0
- package/dist/src/api/resources/transcriptions/index.js +2 -0
- package/dist/src/api/resources/transcriptions/index.js.map +1 -0
- package/dist/src/api/resources/translations/client/Client.d.ts +57 -0
- package/dist/src/api/resources/translations/client/Client.js +208 -0
- package/dist/src/api/resources/translations/client/Client.js.map +1 -0
- package/dist/src/api/resources/translations/client/index.d.ts +1 -0
- package/dist/src/api/resources/translations/client/index.js +2 -0
- package/dist/src/api/resources/translations/client/index.js.map +1 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsRequest.d.ts +26 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsRequest.js +11 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsRequest.js.map +1 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsStreamRequest.d.ts +26 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsStreamRequest.js +11 -0
- package/dist/src/api/resources/translations/client/requests/CreateTranslationsStreamRequest.js.map +1 -0
- package/dist/src/api/resources/translations/client/requests/index.d.ts +2 -0
- package/dist/src/api/resources/translations/client/requests/index.js +3 -0
- package/dist/src/api/resources/translations/client/requests/index.js.map +1 -0
- package/dist/src/api/resources/translations/exports.d.ts +2 -0
- package/dist/src/api/resources/translations/exports.js +4 -0
- package/dist/src/api/resources/translations/exports.js.map +1 -0
- package/dist/src/api/resources/translations/index.d.ts +1 -0
- package/dist/src/api/resources/translations/index.js +2 -0
- package/dist/src/api/resources/translations/index.js.map +1 -0
- package/dist/src/api/types/Conversion.d.ts +20 -0
- package/dist/src/api/types/Conversion.js +9 -0
- package/dist/src/api/types/Conversion.js.map +1 -0
- package/dist/src/api/types/ConversionSegment.d.ts +10 -0
- package/dist/src/api/types/ConversionSegment.js +3 -0
- package/dist/src/api/types/ConversionSegment.js.map +1 -0
- package/dist/src/api/types/Diarization.d.ts +12 -0
- package/dist/src/api/types/Diarization.js +3 -0
- package/dist/src/api/types/Diarization.js.map +1 -0
- package/dist/src/api/types/ErrorObject.d.ts +18 -0
- package/dist/src/api/types/ErrorObject.js +16 -0
- package/dist/src/api/types/ErrorObject.js.map +1 -0
- package/dist/src/api/types/Error_.d.ts +6 -0
- package/dist/src/api/types/Error_.js +3 -0
- package/dist/src/api/types/Error_.js.map +1 -0
- package/dist/src/api/types/Model.d.ts +17 -0
- package/dist/src/api/types/Model.js +11 -0
- package/dist/src/api/types/Model.js.map +1 -0
- package/dist/src/api/types/ModelList.d.ts +13 -0
- package/dist/src/api/types/ModelList.js +8 -0
- package/dist/src/api/types/ModelList.js.map +1 -0
- package/dist/src/api/types/RealtimeClientMessage.d.ts +13 -0
- package/dist/src/api/types/RealtimeClientMessage.js +9 -0
- package/dist/src/api/types/RealtimeClientMessage.js.map +1 -0
- package/dist/src/api/types/RealtimeEvent.d.ts +39 -0
- package/dist/src/api/types/RealtimeEvent.js +13 -0
- package/dist/src/api/types/RealtimeEvent.js.map +1 -0
- package/dist/src/api/types/Segment.d.ts +10 -0
- package/dist/src/api/types/Segment.js +3 -0
- package/dist/src/api/types/Segment.js.map +1 -0
- package/dist/src/api/types/Speaker.d.ts +9 -0
- package/dist/src/api/types/Speaker.js +3 -0
- package/dist/src/api/types/Speaker.js.map +1 -0
- package/dist/src/api/types/SpeakerTurn.d.ts +7 -0
- package/dist/src/api/types/SpeakerTurn.js +3 -0
- package/dist/src/api/types/SpeakerTurn.js.map +1 -0
- package/dist/src/api/types/Speech.d.ts +25 -0
- package/dist/src/api/types/Speech.js +8 -0
- package/dist/src/api/types/Speech.js.map +1 -0
- package/dist/src/api/types/Transcription.d.ts +21 -0
- package/dist/src/api/types/Transcription.js +3 -0
- package/dist/src/api/types/Transcription.js.map +1 -0
- package/dist/src/api/types/Translation.d.ts +16 -0
- package/dist/src/api/types/Translation.js +3 -0
- package/dist/src/api/types/Translation.js.map +1 -0
- package/dist/src/api/types/TranslationLanguage.d.ts +8 -0
- package/dist/src/api/types/TranslationLanguage.js +3 -0
- package/dist/src/api/types/TranslationLanguage.js.map +1 -0
- package/dist/src/api/types/TranslationLanguageList.d.ts +14 -0
- package/dist/src/api/types/TranslationLanguageList.js +8 -0
- package/dist/src/api/types/TranslationLanguageList.js.map +1 -0
- package/dist/src/api/types/TranslationRequest.d.ts +22 -0
- package/dist/src/api/types/TranslationRequest.js +11 -0
- package/dist/src/api/types/TranslationRequest.js.map +1 -0
- package/dist/src/api/types/TranslationStreamEvent.d.ts +19 -0
- package/dist/src/api/types/TranslationStreamEvent.js +11 -0
- package/dist/src/api/types/TranslationStreamEvent.js.map +1 -0
- package/dist/src/api/types/Usage.d.ts +8 -0
- package/dist/src/api/types/Usage.js +3 -0
- package/dist/src/api/types/Usage.js.map +1 -0
- package/dist/src/api/types/Word.d.ts +9 -0
- package/dist/src/api/types/Word.js +3 -0
- package/dist/src/api/types/Word.js.map +1 -0
- package/dist/src/api/types/index.d.ts +21 -0
- package/dist/src/api/types/index.js +22 -0
- package/dist/src/api/types/index.js.map +1 -0
- package/dist/src/auth/BearerAuthProvider.d.ts +20 -0
- package/dist/src/auth/BearerAuthProvider.js +34 -0
- package/dist/src/auth/BearerAuthProvider.js.map +1 -0
- package/dist/src/auth/index.d.ts +1 -0
- package/dist/src/auth/index.js +2 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/core/auth/AuthProvider.d.ts +8 -0
- package/dist/src/core/auth/AuthProvider.js +7 -0
- package/dist/src/core/auth/AuthProvider.js.map +1 -0
- package/dist/src/core/auth/AuthRequest.d.ts +9 -0
- package/dist/src/core/auth/AuthRequest.js +2 -0
- package/dist/src/core/auth/AuthRequest.js.map +1 -0
- package/dist/src/core/auth/BasicAuth.d.ts +8 -0
- package/dist/src/core/auth/BasicAuth.js +30 -0
- package/dist/src/core/auth/BasicAuth.js.map +1 -0
- package/dist/src/core/auth/BearerToken.d.ts +7 -0
- package/dist/src/core/auth/BearerToken.js +14 -0
- package/dist/src/core/auth/BearerToken.js.map +1 -0
- package/dist/src/core/auth/NoOpAuthProvider.d.ts +5 -0
- package/dist/src/core/auth/NoOpAuthProvider.js +6 -0
- package/dist/src/core/auth/NoOpAuthProvider.js.map +1 -0
- package/dist/src/core/auth/index.d.ts +5 -0
- package/dist/src/core/auth/index.js +5 -0
- package/dist/src/core/auth/index.js.map +1 -0
- package/dist/src/core/base64.d.ts +2 -0
- package/dist/src/core/base64.js +23 -0
- package/dist/src/core/base64.js.map +1 -0
- package/dist/src/core/exports.d.ts +2 -0
- package/dist/src/core/exports.js +3 -0
- package/dist/src/core/exports.js.map +1 -0
- package/dist/src/core/fetcher/APIResponse.d.ts +20 -0
- package/dist/src/core/fetcher/APIResponse.js +2 -0
- package/dist/src/core/fetcher/APIResponse.js.map +1 -0
- package/dist/src/core/fetcher/BinaryResponse.d.ts +19 -0
- package/dist/src/core/fetcher/BinaryResponse.js +15 -0
- package/dist/src/core/fetcher/BinaryResponse.js.map +1 -0
- package/dist/src/core/fetcher/EndpointMetadata.d.ts +13 -0
- package/dist/src/core/fetcher/EndpointMetadata.js +2 -0
- package/dist/src/core/fetcher/EndpointMetadata.js.map +1 -0
- package/dist/src/core/fetcher/EndpointSupplier.d.ts +12 -0
- package/dist/src/core/fetcher/EndpointSupplier.js +11 -0
- package/dist/src/core/fetcher/EndpointSupplier.js.map +1 -0
- package/dist/src/core/fetcher/Fetcher.d.ts +56 -0
- package/dist/src/core/fetcher/Fetcher.js +224 -0
- package/dist/src/core/fetcher/Fetcher.js.map +1 -0
- package/dist/src/core/fetcher/Headers.d.ts +2 -0
- package/dist/src/core/fetcher/Headers.js +84 -0
- package/dist/src/core/fetcher/Headers.js.map +1 -0
- package/dist/src/core/fetcher/HttpResponsePromise.d.ts +58 -0
- package/dist/src/core/fetcher/HttpResponsePromise.js +91 -0
- package/dist/src/core/fetcher/HttpResponsePromise.js.map +1 -0
- package/dist/src/core/fetcher/RawResponse.d.ts +29 -0
- package/dist/src/core/fetcher/RawResponse.js +41 -0
- package/dist/src/core/fetcher/RawResponse.js.map +1 -0
- package/dist/src/core/fetcher/Supplier.d.ts +4 -0
- package/dist/src/core/fetcher/Supplier.js +11 -0
- package/dist/src/core/fetcher/Supplier.js.map +1 -0
- package/dist/src/core/fetcher/createRequestUrl.d.ts +1 -0
- package/dist/src/core/fetcher/createRequestUrl.js +6 -0
- package/dist/src/core/fetcher/createRequestUrl.js.map +1 -0
- package/dist/src/core/fetcher/getErrorResponseBody.d.ts +1 -0
- package/dist/src/core/fetcher/getErrorResponseBody.js +31 -0
- package/dist/src/core/fetcher/getErrorResponseBody.js.map +1 -0
- package/dist/src/core/fetcher/getFetchFn.d.ts +1 -0
- package/dist/src/core/fetcher/getFetchFn.js +4 -0
- package/dist/src/core/fetcher/getFetchFn.js.map +1 -0
- package/dist/src/core/fetcher/getHeader.d.ts +1 -0
- package/dist/src/core/fetcher/getHeader.js +9 -0
- package/dist/src/core/fetcher/getHeader.js.map +1 -0
- package/dist/src/core/fetcher/getRequestBody.d.ts +7 -0
- package/dist/src/core/fetcher/getRequestBody.js +14 -0
- package/dist/src/core/fetcher/getRequestBody.js.map +1 -0
- package/dist/src/core/fetcher/getResponseBody.d.ts +1 -0
- package/dist/src/core/fetcher/getResponseBody.js +67 -0
- package/dist/src/core/fetcher/getResponseBody.js.map +1 -0
- package/dist/src/core/fetcher/index.d.ts +13 -0
- package/dist/src/core/fetcher/index.js +8 -0
- package/dist/src/core/fetcher/index.js.map +1 -0
- package/dist/src/core/fetcher/makePassthroughRequest.d.ts +49 -0
- package/dist/src/core/fetcher/makePassthroughRequest.js +142 -0
- package/dist/src/core/fetcher/makePassthroughRequest.js.map +1 -0
- package/dist/src/core/fetcher/makeRequest.d.ts +6 -0
- package/dist/src/core/fetcher/makeRequest.js +54 -0
- package/dist/src/core/fetcher/makeRequest.js.map +1 -0
- package/dist/src/core/fetcher/redactUrl.d.ts +2 -0
- package/dist/src/core/fetcher/redactUrl.js +85 -0
- package/dist/src/core/fetcher/redactUrl.js.map +1 -0
- package/dist/src/core/fetcher/requestWithRetries.d.ts +1 -0
- package/dist/src/core/fetcher/requestWithRetries.js +57 -0
- package/dist/src/core/fetcher/requestWithRetries.js.map +1 -0
- package/dist/src/core/fetcher/signals.d.ts +5 -0
- package/dist/src/core/fetcher/signals.js +29 -0
- package/dist/src/core/fetcher/signals.js.map +1 -0
- package/dist/src/core/file/exports.d.ts +1 -0
- package/dist/src/core/file/exports.js +2 -0
- package/dist/src/core/file/exports.js.map +1 -0
- package/dist/src/core/file/file.d.ts +10 -0
- package/dist/src/core/file/file.js +169 -0
- package/dist/src/core/file/file.js.map +1 -0
- package/dist/src/core/file/index.d.ts +2 -0
- package/dist/src/core/file/index.js +3 -0
- package/dist/src/core/file/index.js.map +1 -0
- package/dist/src/core/file/types.d.ts +66 -0
- package/dist/src/core/file/types.js +2 -0
- package/dist/src/core/file/types.js.map +1 -0
- package/dist/src/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/src/core/form-data-utils/FormDataWrapper.js +109 -0
- package/dist/src/core/form-data-utils/FormDataWrapper.js.map +1 -0
- package/dist/src/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/src/core/form-data-utils/encodeAsFormParameter.js +10 -0
- package/dist/src/core/form-data-utils/encodeAsFormParameter.js.map +1 -0
- package/dist/src/core/form-data-utils/index.d.ts +2 -0
- package/dist/src/core/form-data-utils/index.js +3 -0
- package/dist/src/core/form-data-utils/index.js.map +1 -0
- package/dist/src/core/headers.d.ts +2 -0
- package/dist/src/core/headers.js +28 -0
- package/dist/src/core/headers.js.map +1 -0
- package/dist/src/core/index.d.ts +9 -0
- package/dist/src/core/index.js +10 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/core/json.d.ts +15 -0
- package/dist/src/core/json.js +20 -0
- package/dist/src/core/json.js.map +1 -0
- package/dist/src/core/logging/exports.d.ts +18 -0
- package/dist/src/core/logging/exports.js +10 -0
- package/dist/src/core/logging/exports.js.map +1 -0
- package/dist/src/core/logging/index.d.ts +1 -0
- package/dist/src/core/logging/index.js +2 -0
- package/dist/src/core/logging/index.js.map +1 -0
- package/dist/src/core/logging/logger.d.ts +126 -0
- package/dist/src/core/logging/logger.js +141 -0
- package/dist/src/core/logging/logger.js.map +1 -0
- package/dist/src/core/requestBody.d.ts +12 -0
- package/dist/src/core/requestBody.js +24 -0
- package/dist/src/core/requestBody.js.map +1 -0
- package/dist/src/core/runtime/index.d.ts +1 -0
- package/dist/src/core/runtime/index.js +2 -0
- package/dist/src/core/runtime/index.js.map +1 -0
- package/dist/src/core/runtime/runtime.d.ts +28 -0
- package/dist/src/core/runtime/runtime.js +172 -0
- package/dist/src/core/runtime/runtime.js.map +1 -0
- package/dist/src/core/stream/Stream.d.ts +100 -0
- package/dist/src/core/stream/Stream.js +427 -0
- package/dist/src/core/stream/Stream.js.map +1 -0
- package/dist/src/core/stream/index.d.ts +2 -0
- package/dist/src/core/stream/index.js +2 -0
- package/dist/src/core/stream/index.js.map +1 -0
- package/dist/src/core/url/QueryStringBuilder.d.ts +47 -0
- package/dist/src/core/url/QueryStringBuilder.js +79 -0
- package/dist/src/core/url/QueryStringBuilder.js.map +1 -0
- package/dist/src/core/url/encodePathParam.d.ts +1 -0
- package/dist/src/core/url/encodePathParam.js +19 -0
- package/dist/src/core/url/encodePathParam.js.map +1 -0
- package/dist/src/core/url/index.d.ts +4 -0
- package/dist/src/core/url/index.js +5 -0
- package/dist/src/core/url/index.js.map +1 -0
- package/dist/src/core/url/join.d.ts +1 -0
- package/dist/src/core/url/join.js +66 -0
- package/dist/src/core/url/join.js.map +1 -0
- package/dist/src/core/url/qs.d.ts +7 -0
- package/dist/src/core/url/qs.js +77 -0
- package/dist/src/core/url/qs.js.map +1 -0
- package/dist/src/environments.d.ts +4 -0
- package/dist/src/environments.js +5 -0
- package/dist/src/environments.js.map +1 -0
- package/dist/src/errors/TapraError.d.ts +15 -0
- package/dist/src/errors/TapraError.js +39 -0
- package/dist/src/errors/TapraError.js.map +1 -0
- package/dist/src/errors/TapraTimeoutError.d.ts +6 -0
- package/dist/src/errors/TapraTimeoutError.js +16 -0
- package/dist/src/errors/TapraTimeoutError.js.map +1 -0
- package/dist/src/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/src/errors/handleNonStatusCodeError.js +33 -0
- package/dist/src/errors/handleNonStatusCodeError.js.map +1 -0
- package/dist/src/errors/index.d.ts +2 -0
- package/dist/src/errors/index.js +3 -0
- package/dist/src/errors/index.js.map +1 -0
- package/dist/src/exports.d.ts +1 -0
- package/dist/src/exports.js +2 -0
- package/dist/src/exports.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/package.json +28 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function base64ToBytes(base64) {
|
|
2
|
+
const binString = atob(base64);
|
|
3
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
4
|
+
}
|
|
5
|
+
function bytesToBase64(bytes) {
|
|
6
|
+
const binString = String.fromCodePoint(...bytes);
|
|
7
|
+
return btoa(binString);
|
|
8
|
+
}
|
|
9
|
+
export function base64Encode(input) {
|
|
10
|
+
if (typeof Buffer !== "undefined") {
|
|
11
|
+
return Buffer.from(input, "utf8").toString("base64");
|
|
12
|
+
}
|
|
13
|
+
const bytes = new TextEncoder().encode(input);
|
|
14
|
+
return bytesToBase64(bytes);
|
|
15
|
+
}
|
|
16
|
+
export function base64Decode(input) {
|
|
17
|
+
if (typeof Buffer !== "undefined") {
|
|
18
|
+
return Buffer.from(input, "base64").toString("utf8");
|
|
19
|
+
}
|
|
20
|
+
const bytes = base64ToBytes(input);
|
|
21
|
+
return new TextDecoder().decode(bytes);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=base64.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64.js","sourceRoot":"","sources":["../../../src/core/base64.ts"],"names":[],"mappings":"AAAA,SAAS,aAAa,CAAC,MAAc;IACjC,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAE,CAAC,CAAC;AAChE,CAAC;AAED,SAAS,aAAa,CAAC,KAAiB;IACpC,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,CAAC;IACjD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,KAAa;IACtC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACnC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../../src/core/exports.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RawResponse } from "./RawResponse.js";
|
|
2
|
+
/**
|
|
3
|
+
* The response of an API call.
|
|
4
|
+
* It is a successful response or a failed response.
|
|
5
|
+
*/
|
|
6
|
+
export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
|
|
7
|
+
export interface SuccessfulResponse<T> {
|
|
8
|
+
ok: true;
|
|
9
|
+
body: T;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Use `rawResponse` instead
|
|
12
|
+
*/
|
|
13
|
+
headers?: Record<string, any>;
|
|
14
|
+
rawResponse: RawResponse;
|
|
15
|
+
}
|
|
16
|
+
export interface FailedResponse<T> {
|
|
17
|
+
ok: false;
|
|
18
|
+
error: T;
|
|
19
|
+
rawResponse: RawResponse;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"APIResponse.js","sourceRoot":"","sources":["../../../../src/core/fetcher/APIResponse.ts"],"names":[],"mappings":""}
|
|
@@ -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,15 @@
|
|
|
1
|
+
export function getBinaryResponse(response) {
|
|
2
|
+
const binaryResponse = {
|
|
3
|
+
get bodyUsed() {
|
|
4
|
+
return response.bodyUsed;
|
|
5
|
+
},
|
|
6
|
+
stream: () => response.body,
|
|
7
|
+
arrayBuffer: response.arrayBuffer.bind(response),
|
|
8
|
+
blob: response.blob.bind(response),
|
|
9
|
+
};
|
|
10
|
+
if ("bytes" in response && typeof response.bytes === "function") {
|
|
11
|
+
binaryResponse.bytes = response.bytes.bind(response);
|
|
12
|
+
}
|
|
13
|
+
return binaryResponse;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=BinaryResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BinaryResponse.js","sourceRoot":"","sources":["../../../../src/core/fetcher/BinaryResponse.ts"],"names":[],"mappings":"AAmBA,MAAM,UAAU,iBAAiB,CAAC,QAAkB;IAChD,MAAM,cAAc,GAAmB;QACnC,IAAI,QAAQ;YACR,OAAO,QAAQ,CAAC,QAAQ,CAAC;QAC7B,CAAC;QACD,MAAM,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI;QAC3B,WAAW,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;QAChD,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;KACrC,CAAC;IACF,IAAI,OAAO,IAAI,QAAQ,IAAI,OAAO,QAAQ,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC9D,cAAc,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,cAAc,CAAC;AAC1B,CAAC"}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../../src/core/fetcher/EndpointMetadata.ts"],"names":[],"mappings":""}
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointSupplier.js","sourceRoot":"","sources":["../../../../src/core/fetcher/EndpointSupplier.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC5B,GAAG,EAAE,KAAK,EAAK,QAA6B,EAAE,GAA4C,EAAc,EAAE;QACtG,IAAI,OAAO,QAAQ,KAAK,UAAU,EAAE,CAAC;YACjC,OAAQ,QAAkC,CAAC,GAAG,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACJ,OAAO,QAAQ,CAAC;QACpB,CAAC;IACL,CAAC;CACJ,CAAC"}
|
|
@@ -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,224 @@
|
|
|
1
|
+
import { toJson } from "../json.js";
|
|
2
|
+
import { createLogger } from "../logging/logger.js";
|
|
3
|
+
import { createRequestUrl } from "./createRequestUrl.js";
|
|
4
|
+
import { EndpointSupplier } from "./EndpointSupplier.js";
|
|
5
|
+
import { getErrorResponseBody } from "./getErrorResponseBody.js";
|
|
6
|
+
import { getFetchFn } from "./getFetchFn.js";
|
|
7
|
+
import { getRequestBody } from "./getRequestBody.js";
|
|
8
|
+
import { getResponseBody } from "./getResponseBody.js";
|
|
9
|
+
import { Headers } from "./Headers.js";
|
|
10
|
+
import { makeRequest } from "./makeRequest.js";
|
|
11
|
+
import { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse.js";
|
|
12
|
+
import { redactUrl, SENSITIVE_QUERY_PARAMS } from "./redactUrl.js";
|
|
13
|
+
import { requestWithRetries } from "./requestWithRetries.js";
|
|
14
|
+
const SENSITIVE_HEADERS = new Set([
|
|
15
|
+
"authorization",
|
|
16
|
+
"www-authenticate",
|
|
17
|
+
"x-api-key",
|
|
18
|
+
"api-key",
|
|
19
|
+
"apikey",
|
|
20
|
+
"x-api-token",
|
|
21
|
+
"x-auth-token",
|
|
22
|
+
"auth-token",
|
|
23
|
+
"cookie",
|
|
24
|
+
"set-cookie",
|
|
25
|
+
"proxy-authorization",
|
|
26
|
+
"proxy-authenticate",
|
|
27
|
+
"x-csrf-token",
|
|
28
|
+
"x-xsrf-token",
|
|
29
|
+
"x-session-token",
|
|
30
|
+
"x-access-token",
|
|
31
|
+
]);
|
|
32
|
+
function redactHeaders(headers) {
|
|
33
|
+
const filtered = {};
|
|
34
|
+
for (const [key, value] of headers instanceof Headers ? headers.entries() : Object.entries(headers)) {
|
|
35
|
+
if (SENSITIVE_HEADERS.has(key.toLowerCase())) {
|
|
36
|
+
filtered[key] = "[REDACTED]";
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
filtered[key] = value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return filtered;
|
|
43
|
+
}
|
|
44
|
+
function redactQueryParameters(queryParameters) {
|
|
45
|
+
if (queryParameters == null) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const redacted = {};
|
|
49
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
50
|
+
redacted[key] = SENSITIVE_QUERY_PARAMS.has(key.toLowerCase()) ? "[REDACTED]" : value;
|
|
51
|
+
}
|
|
52
|
+
return redacted;
|
|
53
|
+
}
|
|
54
|
+
async function getHeaders(args) {
|
|
55
|
+
const newHeaders = new Headers();
|
|
56
|
+
newHeaders.set("Accept", args.responseType === "json"
|
|
57
|
+
? "application/json"
|
|
58
|
+
: args.responseType === "text"
|
|
59
|
+
? "text/plain"
|
|
60
|
+
: args.responseType === "sse"
|
|
61
|
+
? "text/event-stream"
|
|
62
|
+
: "*/*");
|
|
63
|
+
if (args.body !== undefined && args.contentType != null) {
|
|
64
|
+
newHeaders.set("Content-Type", args.contentType);
|
|
65
|
+
}
|
|
66
|
+
if (args.headers == null) {
|
|
67
|
+
return newHeaders;
|
|
68
|
+
}
|
|
69
|
+
for (const [key, value] of Object.entries(args.headers)) {
|
|
70
|
+
const result = await EndpointSupplier.get(value, { endpointMetadata: args.endpointMetadata ?? {} });
|
|
71
|
+
if (typeof result === "string") {
|
|
72
|
+
newHeaders.set(key, result);
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (result == null) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
newHeaders.set(key, `${result}`);
|
|
79
|
+
}
|
|
80
|
+
return newHeaders;
|
|
81
|
+
}
|
|
82
|
+
export async function fetcherImpl(args) {
|
|
83
|
+
let url = args.url;
|
|
84
|
+
if (args.queryString != null && args.queryString.length > 0) {
|
|
85
|
+
url = `${url}?${args.queryString}`;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
url = createRequestUrl(args.url, args.queryParameters);
|
|
89
|
+
}
|
|
90
|
+
const requestBody = await getRequestBody({
|
|
91
|
+
body: args.body,
|
|
92
|
+
type: args.requestType ?? "other",
|
|
93
|
+
});
|
|
94
|
+
const fetchFn = args.fetchFn ?? (await getFetchFn());
|
|
95
|
+
const headers = await getHeaders(args);
|
|
96
|
+
const logger = createLogger(args.logging);
|
|
97
|
+
if (logger.isDebug()) {
|
|
98
|
+
const metadata = {
|
|
99
|
+
method: args.method,
|
|
100
|
+
url: redactUrl(url),
|
|
101
|
+
headers: redactHeaders(headers),
|
|
102
|
+
queryParameters: redactQueryParameters(args.queryParameters),
|
|
103
|
+
hasBody: requestBody != null,
|
|
104
|
+
};
|
|
105
|
+
logger.debug("Making HTTP request", metadata);
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const response = await requestWithRetries(async () => makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex, args.responseType === "streaming" || args.responseType === "sse"), args.maxRetries);
|
|
109
|
+
if (response.status >= 200 && response.status < 400) {
|
|
110
|
+
if (logger.isDebug()) {
|
|
111
|
+
const metadata = {
|
|
112
|
+
method: args.method,
|
|
113
|
+
url: redactUrl(url),
|
|
114
|
+
statusCode: response.status,
|
|
115
|
+
responseHeaders: redactHeaders(response.headers),
|
|
116
|
+
};
|
|
117
|
+
logger.debug("HTTP request succeeded", metadata);
|
|
118
|
+
}
|
|
119
|
+
const body = await getResponseBody(response, args.responseType);
|
|
120
|
+
return {
|
|
121
|
+
ok: true,
|
|
122
|
+
body: body,
|
|
123
|
+
headers: response.headers,
|
|
124
|
+
rawResponse: toRawResponse(response),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (logger.isError()) {
|
|
129
|
+
const metadata = {
|
|
130
|
+
method: args.method,
|
|
131
|
+
url: redactUrl(url),
|
|
132
|
+
statusCode: response.status,
|
|
133
|
+
responseHeaders: redactHeaders(Object.fromEntries(response.headers.entries())),
|
|
134
|
+
};
|
|
135
|
+
logger.error("HTTP request failed with error status", metadata);
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
ok: false,
|
|
139
|
+
error: {
|
|
140
|
+
reason: "status-code",
|
|
141
|
+
statusCode: response.status,
|
|
142
|
+
body: await getErrorResponseBody(response),
|
|
143
|
+
},
|
|
144
|
+
rawResponse: toRawResponse(response),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
if (args.abortSignal?.aborted) {
|
|
150
|
+
if (logger.isError()) {
|
|
151
|
+
const metadata = {
|
|
152
|
+
method: args.method,
|
|
153
|
+
url: redactUrl(url),
|
|
154
|
+
};
|
|
155
|
+
logger.error("HTTP request was aborted", metadata);
|
|
156
|
+
}
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
error: {
|
|
160
|
+
reason: "unknown",
|
|
161
|
+
errorMessage: "The user aborted a request",
|
|
162
|
+
cause: error,
|
|
163
|
+
},
|
|
164
|
+
rawResponse: abortRawResponse,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
else if (error instanceof Error && error.name === "AbortError") {
|
|
168
|
+
if (logger.isError()) {
|
|
169
|
+
const metadata = {
|
|
170
|
+
method: args.method,
|
|
171
|
+
url: redactUrl(url),
|
|
172
|
+
timeoutMs: args.timeoutMs,
|
|
173
|
+
};
|
|
174
|
+
logger.error("HTTP request timed out", metadata);
|
|
175
|
+
}
|
|
176
|
+
return {
|
|
177
|
+
ok: false,
|
|
178
|
+
error: {
|
|
179
|
+
reason: "timeout",
|
|
180
|
+
cause: error,
|
|
181
|
+
},
|
|
182
|
+
rawResponse: abortRawResponse,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
else if (error instanceof Error) {
|
|
186
|
+
if (logger.isError()) {
|
|
187
|
+
const metadata = {
|
|
188
|
+
method: args.method,
|
|
189
|
+
url: redactUrl(url),
|
|
190
|
+
errorMessage: error.message,
|
|
191
|
+
};
|
|
192
|
+
logger.error("HTTP request failed with error", metadata);
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
ok: false,
|
|
196
|
+
error: {
|
|
197
|
+
reason: "unknown",
|
|
198
|
+
errorMessage: error.message,
|
|
199
|
+
cause: error,
|
|
200
|
+
},
|
|
201
|
+
rawResponse: unknownRawResponse,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (logger.isError()) {
|
|
205
|
+
const metadata = {
|
|
206
|
+
method: args.method,
|
|
207
|
+
url: redactUrl(url),
|
|
208
|
+
error: toJson(error),
|
|
209
|
+
};
|
|
210
|
+
logger.error("HTTP request failed with unknown error", metadata);
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
ok: false,
|
|
214
|
+
error: {
|
|
215
|
+
reason: "unknown",
|
|
216
|
+
errorMessage: toJson(error),
|
|
217
|
+
cause: error,
|
|
218
|
+
},
|
|
219
|
+
rawResponse: unknownRawResponse,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export const fetcher = fetcherImpl;
|
|
224
|
+
//# sourceMappingURL=Fetcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Fetcher.js","sourceRoot":"","sources":["../../../../src/core/fetcher/Fetcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,EAA+B,MAAM,sBAAsB,CAAC;AAEjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EA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BACnB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;aACvB,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,QAAQ,CAAC,CAAC;QACrE,CAAC;QACD,OAAO;YACH,EAAE,EAAE,KAAK;YACT,KAAK,EAAE;gBACH,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC;gBAC3B,KAAK,EAAE,KAAK;aACf;YACD,WAAW,EAAE,kBAAkB;SAClC,CAAC;IACN,CAAC;AACL,CAAC;AAED,MAAM,CAAC,MAAM,OAAO,GAAkB,WAAW,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
let Headers;
|
|
2
|
+
if (typeof globalThis.Headers !== "undefined") {
|
|
3
|
+
Headers = globalThis.Headers;
|
|
4
|
+
}
|
|
5
|
+
else {
|
|
6
|
+
Headers = class Headers {
|
|
7
|
+
headers;
|
|
8
|
+
constructor(init) {
|
|
9
|
+
this.headers = new Map();
|
|
10
|
+
if (init) {
|
|
11
|
+
if (init instanceof Headers) {
|
|
12
|
+
init.forEach((value, key) => this.append(key, value));
|
|
13
|
+
}
|
|
14
|
+
else if (Array.isArray(init)) {
|
|
15
|
+
for (const [key, value] of init) {
|
|
16
|
+
if (typeof key === "string" && typeof value === "string") {
|
|
17
|
+
this.append(key, value);
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
throw new TypeError("Each header entry must be a [string, string] tuple");
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
for (const [key, value] of Object.entries(init)) {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
this.append(key, value);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new TypeError("Header values must be strings");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
append(name, value) {
|
|
37
|
+
const key = name.toLowerCase();
|
|
38
|
+
const existing = this.headers.get(key) || [];
|
|
39
|
+
this.headers.set(key, [...existing, value]);
|
|
40
|
+
}
|
|
41
|
+
delete(name) {
|
|
42
|
+
const key = name.toLowerCase();
|
|
43
|
+
this.headers.delete(key);
|
|
44
|
+
}
|
|
45
|
+
get(name) {
|
|
46
|
+
const key = name.toLowerCase();
|
|
47
|
+
const values = this.headers.get(key);
|
|
48
|
+
return values ? values.join(", ") : null;
|
|
49
|
+
}
|
|
50
|
+
has(name) {
|
|
51
|
+
const key = name.toLowerCase();
|
|
52
|
+
return this.headers.has(key);
|
|
53
|
+
}
|
|
54
|
+
set(name, value) {
|
|
55
|
+
const key = name.toLowerCase();
|
|
56
|
+
this.headers.set(key, [value]);
|
|
57
|
+
}
|
|
58
|
+
forEach(callbackfn, thisArg) {
|
|
59
|
+
const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
|
|
60
|
+
this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
|
|
61
|
+
}
|
|
62
|
+
getSetCookie() {
|
|
63
|
+
return this.headers.get("set-cookie") || [];
|
|
64
|
+
}
|
|
65
|
+
*entries() {
|
|
66
|
+
for (const [key, values] of this.headers.entries()) {
|
|
67
|
+
yield [key, values.join(", ")];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
*keys() {
|
|
71
|
+
yield* this.headers.keys();
|
|
72
|
+
}
|
|
73
|
+
*values() {
|
|
74
|
+
for (const values of this.headers.values()) {
|
|
75
|
+
yield values.join(", ");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
[Symbol.iterator]() {
|
|
79
|
+
return this.entries();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export { Headers };
|
|
84
|
+
//# sourceMappingURL=Headers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Headers.js","sourceRoot":"","sources":["../../../../src/core/fetcher/Headers.ts"],"names":[],"mappings":"AAAA,IAA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UAAU,CAAC;YACtE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC;QACvF,CAAC;QAED,YAAY;YACR,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;QAChD,CAAC;QAED,CAAC,OAAO;YACJ,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;gBACjD,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;YACnC,CAAC;QACL,CAAC;QAED,CAAC,IAAI;YACD,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAED,CAAC,MAAM;YACH,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;gBACzC,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC5B,CAAC;QACL,CAAC;QAED,CAAC,MAAM,CAAC,QAAQ,CAAC;YACb,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC;QAC1B,CAAC;KACJ,CAAC;AACN,CAAC;AAED,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -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
|
+
}
|