@cartesia/cartesia-js 2.0.1 → 2.0.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/Client.js +9 -13
- package/api/index.js +1 -17
- package/api/resources/apiStatus/client/Client.js +6 -33
- package/api/resources/apiStatus/client/index.js +1 -2
- package/api/resources/apiStatus/index.js +2 -18
- package/api/resources/apiStatus/types/ApiInfo.js +1 -2
- package/api/resources/apiStatus/types/index.js +1 -17
- package/api/resources/embedding/index.js +1 -17
- package/api/resources/embedding/types/Embedding.js +1 -2
- package/api/resources/embedding/types/index.js +1 -17
- package/api/resources/index.js +12 -41
- package/api/resources/tts/client/Client.js +10 -40
- package/api/resources/tts/client/index.js +1 -2
- package/api/resources/tts/index.js +2 -18
- package/api/resources/tts/types/CancelContextRequest.js +1 -2
- package/api/resources/tts/types/ContextId.js +1 -2
- package/api/resources/tts/types/Controls.js +1 -2
- package/api/resources/tts/types/Emotion.js +1 -4
- package/api/resources/tts/types/GenerationRequest.js +1 -2
- package/api/resources/tts/types/Mp3OutputFormat.js +1 -2
- package/api/resources/tts/types/NaturalSpecifier.js +1 -4
- package/api/resources/tts/types/NumericalSpecifier.js +1 -2
- package/api/resources/tts/types/OutputFormat.js +1 -2
- package/api/resources/tts/types/RawEncoding.js +1 -4
- package/api/resources/tts/types/RawOutputFormat.js +1 -2
- package/api/resources/tts/types/Speed.js +1 -2
- package/api/resources/tts/types/SupportedLanguage.js +1 -4
- package/api/resources/tts/types/TtsRequest.js +1 -2
- package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +1 -2
- package/api/resources/tts/types/TtsRequestIdSpecifier.js +1 -2
- package/api/resources/tts/types/TtsRequestVoiceSpecifier.js +1 -2
- package/api/resources/tts/types/WavOutputFormat.js +1 -2
- package/api/resources/tts/types/WebSocketBaseResponse.js +1 -2
- package/api/resources/tts/types/WebSocketChunkResponse.js +1 -2
- package/api/resources/tts/types/WebSocketDoneResponse.js +1 -2
- package/api/resources/tts/types/WebSocketErrorResponse.js +1 -2
- package/api/resources/tts/types/WebSocketRawOutputFormat.js +1 -2
- package/api/resources/tts/types/WebSocketRequest.js +1 -2
- package/api/resources/tts/types/WebSocketResponse.js +1 -2
- package/api/resources/tts/types/WebSocketStreamOptions.js +1 -2
- package/api/resources/tts/types/WebSocketTimestampsResponse.js +1 -2
- package/api/resources/tts/types/WebSocketTtsOutput.js +1 -2
- package/api/resources/tts/types/WebSocketTtsRequest.js +1 -2
- package/api/resources/tts/types/WordTimestamps.js +1 -2
- package/api/resources/tts/types/index.js +30 -46
- package/api/resources/voiceChanger/client/Client.js +10 -40
- package/api/resources/voiceChanger/client/index.js +1 -17
- package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +1 -2
- package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +1 -2
- package/api/resources/voiceChanger/client/requests/index.js +1 -2
- package/api/resources/voiceChanger/index.js +2 -18
- package/api/resources/voiceChanger/types/OutputFormatContainer.js +1 -4
- package/api/resources/voiceChanger/types/StreamingResponse.js +1 -2
- package/api/resources/voiceChanger/types/index.js +2 -18
- package/api/resources/voices/client/Client.js +22 -52
- package/api/resources/voices/client/index.js +1 -17
- package/api/resources/voices/client/requests/CloneVoiceRequest.js +1 -2
- package/api/resources/voices/client/requests/index.js +1 -2
- package/api/resources/voices/index.js +2 -18
- package/api/resources/voices/types/BaseVoiceId.js +1 -2
- package/api/resources/voices/types/CloneMode.js +1 -4
- package/api/resources/voices/types/CreateVoiceRequest.js +1 -2
- package/api/resources/voices/types/EmbeddingResponse.js +1 -2
- package/api/resources/voices/types/EmbeddingSpecifier.js +1 -2
- package/api/resources/voices/types/Gender.js +1 -4
- package/api/resources/voices/types/IdSpecifier.js +1 -2
- package/api/resources/voices/types/LocalizeDialect.js +1 -4
- package/api/resources/voices/types/LocalizeTargetLanguage.js +1 -4
- package/api/resources/voices/types/LocalizeVoiceRequest.js +1 -2
- package/api/resources/voices/types/MixVoiceSpecifier.js +1 -2
- package/api/resources/voices/types/MixVoicesRequest.js +1 -2
- package/api/resources/voices/types/UpdateVoiceRequest.js +1 -2
- package/api/resources/voices/types/Voice.js +1 -2
- package/api/resources/voices/types/VoiceId.js +1 -2
- package/api/resources/voices/types/VoiceMetadata.js +1 -2
- package/api/resources/voices/types/Weight.js +1 -2
- package/api/resources/voices/types/index.js +17 -33
- package/core/fetcher/APIResponse.js +1 -2
- package/core/fetcher/Fetcher.js +14 -18
- package/core/fetcher/Supplier.js +1 -4
- package/core/fetcher/createRequestUrl.js +3 -10
- package/core/fetcher/getFetchFn.js +6 -33
- package/core/fetcher/getHeader.js +1 -5
- package/core/fetcher/getRequestBody.js +1 -5
- package/core/fetcher/getResponseBody.js +3 -7
- package/core/fetcher/index.js +3 -9
- package/core/fetcher/makeRequest.js +4 -8
- package/core/fetcher/requestWithRetries.js +1 -5
- package/core/fetcher/signals.js +2 -7
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +7 -34
- package/core/form-data-utils/FormDataWrapper.js +11 -41
- package/core/form-data-utils/index.js +1 -17
- package/core/index.js +5 -34
- package/core/runtime/index.js +1 -5
- package/core/runtime/runtime.js +1 -4
- package/core/schemas/Schema.js +1 -4
- package/core/schemas/builders/bigint/bigint.js +9 -13
- package/core/schemas/builders/bigint/index.js +1 -5
- package/core/schemas/builders/date/date.js +10 -14
- package/core/schemas/builders/date/index.js +1 -5
- package/core/schemas/builders/enum/enum.js +7 -11
- package/core/schemas/builders/enum/index.js +1 -5
- package/core/schemas/builders/index.js +14 -30
- package/core/schemas/builders/lazy/index.js +2 -7
- package/core/schemas/builders/lazy/lazy.js +5 -11
- package/core/schemas/builders/lazy/lazyObject.js +7 -11
- package/core/schemas/builders/list/index.js +1 -5
- package/core/schemas/builders/list/list.js +8 -12
- package/core/schemas/builders/literals/booleanLiteral.js +6 -10
- package/core/schemas/builders/literals/index.js +2 -7
- package/core/schemas/builders/literals/stringLiteral.js +6 -10
- package/core/schemas/builders/object/index.js +3 -11
- package/core/schemas/builders/object/object.js +33 -38
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +3 -7
- package/core/schemas/builders/object/property.js +2 -7
- package/core/schemas/builders/object/types.js +1 -2
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -15
- package/core/schemas/builders/object-like/index.js +1 -6
- package/core/schemas/builders/object-like/types.js +1 -2
- package/core/schemas/builders/primitives/any.js +3 -6
- package/core/schemas/builders/primitives/boolean.js +5 -8
- package/core/schemas/builders/primitives/index.js +5 -13
- package/core/schemas/builders/primitives/number.js +5 -8
- package/core/schemas/builders/primitives/string.js +5 -8
- package/core/schemas/builders/primitives/unknown.js +3 -6
- package/core/schemas/builders/record/index.js +1 -5
- package/core/schemas/builders/record/record.js +14 -18
- package/core/schemas/builders/record/types.js +1 -2
- package/core/schemas/builders/schema-utils/JsonError.js +3 -7
- package/core/schemas/builders/schema-utils/ParseError.js +3 -7
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +9 -15
- package/core/schemas/builders/schema-utils/index.js +3 -11
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -5
- package/core/schemas/builders/set/index.js +1 -5
- package/core/schemas/builders/set/set.js +10 -14
- package/core/schemas/builders/undiscriminated-union/index.js +1 -5
- package/core/schemas/builders/undiscriminated-union/types.js +1 -2
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +6 -10
- package/core/schemas/builders/union/discriminant.js +1 -5
- package/core/schemas/builders/union/index.js +2 -7
- package/core/schemas/builders/union/types.js +1 -2
- package/core/schemas/builders/union/union.js +14 -18
- package/core/schemas/index.js +1 -17
- package/core/schemas/utils/MaybePromise.js +1 -2
- package/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -2
- package/core/schemas/utils/createIdentitySchemaCreator.js +4 -8
- package/core/schemas/utils/entries.js +1 -5
- package/core/schemas/utils/filterObject.js +1 -5
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -5
- package/core/schemas/utils/isPlainObject.js +1 -5
- package/core/schemas/utils/keys.js +1 -5
- package/core/schemas/utils/maybeSkipValidation.js +1 -5
- package/core/schemas/utils/partition.js +1 -5
- package/core/streaming-fetcher/Stream.js +4 -9
- package/core/streaming-fetcher/index.js +1 -5
- package/core/websocket/events.js +3 -9
- package/core/websocket/index.js +1 -17
- package/core/websocket/ws.js +6 -33
- package/dist/Client.js +9 -13
- package/dist/api/index.js +1 -17
- package/dist/api/resources/apiStatus/client/Client.js +6 -33
- package/dist/api/resources/apiStatus/client/index.js +1 -2
- package/dist/api/resources/apiStatus/index.js +2 -18
- package/dist/api/resources/apiStatus/types/ApiInfo.js +1 -2
- package/dist/api/resources/apiStatus/types/index.js +1 -17
- package/dist/api/resources/embedding/index.js +1 -17
- package/dist/api/resources/embedding/types/Embedding.js +1 -2
- package/dist/api/resources/embedding/types/index.js +1 -17
- package/dist/api/resources/index.js +12 -41
- package/dist/api/resources/tts/client/Client.js +10 -40
- package/dist/api/resources/tts/client/index.js +1 -2
- package/dist/api/resources/tts/index.js +2 -18
- package/dist/api/resources/tts/types/CancelContextRequest.js +1 -2
- package/dist/api/resources/tts/types/ContextId.js +1 -2
- package/dist/api/resources/tts/types/Controls.js +1 -2
- package/dist/api/resources/tts/types/Emotion.js +1 -4
- package/dist/api/resources/tts/types/GenerationRequest.js +1 -2
- package/dist/api/resources/tts/types/Mp3OutputFormat.js +1 -2
- package/dist/api/resources/tts/types/NaturalSpecifier.js +1 -4
- package/dist/api/resources/tts/types/NumericalSpecifier.js +1 -2
- package/dist/api/resources/tts/types/OutputFormat.js +1 -2
- package/dist/api/resources/tts/types/RawEncoding.js +1 -4
- package/dist/api/resources/tts/types/RawOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/Speed.js +1 -2
- package/dist/api/resources/tts/types/SupportedLanguage.js +1 -4
- package/dist/api/resources/tts/types/TtsRequest.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestIdSpecifier.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.js +1 -2
- package/dist/api/resources/tts/types/WavOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/WebSocketBaseResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketChunkResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketDoneResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketErrorResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketRawOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/WebSocketRequest.js +1 -2
- package/dist/api/resources/tts/types/WebSocketResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketStreamOptions.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTimestampsResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTtsOutput.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTtsRequest.js +1 -2
- package/dist/api/resources/tts/types/WordTimestamps.js +1 -2
- package/dist/api/resources/tts/types/index.js +30 -46
- package/dist/api/resources/voiceChanger/client/Client.js +10 -40
- package/dist/api/resources/voiceChanger/client/index.js +1 -17
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +1 -2
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +1 -2
- package/dist/api/resources/voiceChanger/client/requests/index.js +1 -2
- package/dist/api/resources/voiceChanger/index.js +2 -18
- package/dist/api/resources/voiceChanger/types/OutputFormatContainer.js +1 -4
- package/dist/api/resources/voiceChanger/types/StreamingResponse.js +1 -2
- package/dist/api/resources/voiceChanger/types/index.js +2 -18
- package/dist/api/resources/voices/client/Client.js +22 -52
- package/dist/api/resources/voices/client/index.js +1 -17
- package/dist/api/resources/voices/client/requests/CloneVoiceRequest.js +1 -2
- package/dist/api/resources/voices/client/requests/index.js +1 -2
- package/dist/api/resources/voices/index.js +2 -18
- package/dist/api/resources/voices/types/BaseVoiceId.js +1 -2
- package/dist/api/resources/voices/types/CloneMode.js +1 -4
- package/dist/api/resources/voices/types/CreateVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/EmbeddingResponse.js +1 -2
- package/dist/api/resources/voices/types/EmbeddingSpecifier.js +1 -2
- package/dist/api/resources/voices/types/Gender.js +1 -4
- package/dist/api/resources/voices/types/IdSpecifier.js +1 -2
- package/dist/api/resources/voices/types/LocalizeDialect.js +1 -4
- package/dist/api/resources/voices/types/LocalizeTargetLanguage.js +1 -4
- package/dist/api/resources/voices/types/LocalizeVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/MixVoiceSpecifier.js +1 -2
- package/dist/api/resources/voices/types/MixVoicesRequest.js +1 -2
- package/dist/api/resources/voices/types/UpdateVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/Voice.js +1 -2
- package/dist/api/resources/voices/types/VoiceId.js +1 -2
- package/dist/api/resources/voices/types/VoiceMetadata.js +1 -2
- package/dist/api/resources/voices/types/Weight.js +1 -2
- package/dist/api/resources/voices/types/index.js +17 -33
- package/dist/core/fetcher/APIResponse.js +1 -2
- package/dist/core/fetcher/Fetcher.js +14 -18
- package/dist/core/fetcher/Supplier.js +1 -4
- package/dist/core/fetcher/createRequestUrl.js +3 -10
- package/dist/core/fetcher/getFetchFn.js +6 -33
- package/dist/core/fetcher/getHeader.js +1 -5
- package/dist/core/fetcher/getRequestBody.js +1 -5
- package/dist/core/fetcher/getResponseBody.js +3 -7
- package/dist/core/fetcher/index.js +3 -9
- package/dist/core/fetcher/makeRequest.js +4 -8
- package/dist/core/fetcher/requestWithRetries.js +1 -5
- package/dist/core/fetcher/signals.js +2 -7
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +7 -34
- package/dist/core/form-data-utils/FormDataWrapper.js +11 -41
- package/dist/core/form-data-utils/index.js +1 -17
- package/dist/core/index.js +5 -34
- package/dist/core/runtime/index.js +1 -5
- package/dist/core/runtime/runtime.js +1 -4
- package/dist/core/schemas/Schema.js +1 -4
- package/dist/core/schemas/builders/bigint/bigint.js +9 -13
- package/dist/core/schemas/builders/bigint/index.js +1 -5
- package/dist/core/schemas/builders/date/date.js +10 -14
- package/dist/core/schemas/builders/date/index.js +1 -5
- package/dist/core/schemas/builders/enum/enum.js +7 -11
- package/dist/core/schemas/builders/enum/index.js +1 -5
- package/dist/core/schemas/builders/index.js +14 -30
- package/dist/core/schemas/builders/lazy/index.js +2 -7
- package/dist/core/schemas/builders/lazy/lazy.js +5 -11
- package/dist/core/schemas/builders/lazy/lazyObject.js +7 -11
- package/dist/core/schemas/builders/list/index.js +1 -5
- package/dist/core/schemas/builders/list/list.js +8 -12
- package/dist/core/schemas/builders/literals/booleanLiteral.js +6 -10
- package/dist/core/schemas/builders/literals/index.js +2 -7
- package/dist/core/schemas/builders/literals/stringLiteral.js +6 -10
- package/dist/core/schemas/builders/object/index.js +3 -11
- package/dist/core/schemas/builders/object/object.js +33 -38
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +3 -7
- package/dist/core/schemas/builders/object/property.js +2 -7
- package/dist/core/schemas/builders/object/types.js +1 -2
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -15
- package/dist/core/schemas/builders/object-like/index.js +1 -6
- package/dist/core/schemas/builders/object-like/types.js +1 -2
- package/dist/core/schemas/builders/primitives/any.js +3 -6
- package/dist/core/schemas/builders/primitives/boolean.js +5 -8
- package/dist/core/schemas/builders/primitives/index.js +5 -13
- package/dist/core/schemas/builders/primitives/number.js +5 -8
- package/dist/core/schemas/builders/primitives/string.js +5 -8
- package/dist/core/schemas/builders/primitives/unknown.js +3 -6
- package/dist/core/schemas/builders/record/index.js +1 -5
- package/dist/core/schemas/builders/record/record.js +14 -18
- package/dist/core/schemas/builders/record/types.js +1 -2
- package/dist/core/schemas/builders/schema-utils/JsonError.js +3 -7
- package/dist/core/schemas/builders/schema-utils/ParseError.js +3 -7
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +9 -15
- package/dist/core/schemas/builders/schema-utils/index.js +3 -11
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -5
- package/dist/core/schemas/builders/set/index.js +1 -5
- package/dist/core/schemas/builders/set/set.js +10 -14
- package/dist/core/schemas/builders/undiscriminated-union/index.js +1 -5
- package/dist/core/schemas/builders/undiscriminated-union/types.js +1 -2
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +6 -10
- package/dist/core/schemas/builders/union/discriminant.js +1 -5
- package/dist/core/schemas/builders/union/index.js +2 -7
- package/dist/core/schemas/builders/union/types.js +1 -2
- package/dist/core/schemas/builders/union/union.js +14 -18
- package/dist/core/schemas/index.js +1 -17
- package/dist/core/schemas/utils/MaybePromise.js +1 -2
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -2
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +4 -8
- package/dist/core/schemas/utils/entries.js +1 -5
- package/dist/core/schemas/utils/filterObject.js +1 -5
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -5
- package/dist/core/schemas/utils/isPlainObject.js +1 -5
- package/dist/core/schemas/utils/keys.js +1 -5
- package/dist/core/schemas/utils/maybeSkipValidation.js +1 -5
- package/dist/core/schemas/utils/partition.js +1 -5
- package/dist/core/streaming-fetcher/Stream.js +4 -9
- package/dist/core/streaming-fetcher/index.js +1 -5
- package/dist/core/websocket/events.js +3 -9
- package/dist/core/websocket/index.js +1 -17
- package/dist/core/websocket/ws.js +6 -33
- package/dist/environments.js +1 -4
- package/dist/errors/CartesiaError.js +1 -5
- package/dist/errors/CartesiaTimeoutError.js +1 -5
- package/dist/errors/index.js +2 -7
- package/dist/index.js +4 -34
- package/dist/serialization/index.js +1 -17
- package/dist/serialization/resources/apiStatus/index.js +1 -17
- package/dist/serialization/resources/apiStatus/types/ApiInfo.js +2 -28
- package/dist/serialization/resources/apiStatus/types/index.js +1 -17
- package/dist/serialization/resources/embedding/index.js +1 -17
- package/dist/serialization/resources/embedding/types/Embedding.js +2 -28
- package/dist/serialization/resources/embedding/types/index.js +1 -17
- package/dist/serialization/resources/index.js +10 -39
- package/dist/serialization/resources/tts/index.js +1 -17
- package/dist/serialization/resources/tts/types/CancelContextRequest.js +4 -30
- package/dist/serialization/resources/tts/types/ContextId.js +2 -28
- package/dist/serialization/resources/tts/types/Controls.js +6 -32
- package/dist/serialization/resources/tts/types/Emotion.js +2 -28
- package/dist/serialization/resources/tts/types/GenerationRequest.js +10 -36
- package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +2 -28
- package/dist/serialization/resources/tts/types/NaturalSpecifier.js +2 -28
- package/dist/serialization/resources/tts/types/NumericalSpecifier.js +2 -28
- package/dist/serialization/resources/tts/types/OutputFormat.js +8 -34
- package/dist/serialization/resources/tts/types/RawEncoding.js +2 -28
- package/dist/serialization/resources/tts/types/RawOutputFormat.js +4 -30
- package/dist/serialization/resources/tts/types/Speed.js +4 -30
- package/dist/serialization/resources/tts/types/SupportedLanguage.js +2 -28
- package/dist/serialization/resources/tts/types/TtsRequest.js +8 -34
- package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +6 -32
- package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +6 -32
- package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +4 -30
- package/dist/serialization/resources/tts/types/WavOutputFormat.js +3 -29
- package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +3 -29
- package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketRequest.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketResponse.js +10 -36
- package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +2 -28
- package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +6 -32
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +6 -32
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +6 -32
- package/dist/serialization/resources/tts/types/WordTimestamps.js +2 -28
- package/dist/serialization/resources/tts/types/index.js +30 -46
- package/dist/serialization/resources/voiceChanger/index.js +1 -17
- package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +2 -28
- package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +8 -34
- package/dist/serialization/resources/voiceChanger/types/index.js +2 -18
- package/dist/serialization/resources/voices/client/index.js +1 -27
- package/dist/serialization/resources/voices/client/list.js +3 -29
- package/dist/serialization/resources/voices/index.js +2 -18
- package/dist/serialization/resources/voices/types/BaseVoiceId.js +2 -5
- package/dist/serialization/resources/voices/types/CloneMode.js +2 -28
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +8 -34
- package/dist/serialization/resources/voices/types/EmbeddingResponse.js +4 -30
- package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +6 -32
- package/dist/serialization/resources/voices/types/Gender.js +2 -28
- package/dist/serialization/resources/voices/types/IdSpecifier.js +6 -32
- package/dist/serialization/resources/voices/types/LocalizeDialect.js +2 -28
- package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +2 -28
- package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +10 -36
- package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +4 -30
- package/dist/serialization/resources/voices/types/MixVoicesRequest.js +4 -30
- package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +2 -28
- package/dist/serialization/resources/voices/types/Voice.js +10 -36
- package/dist/serialization/resources/voices/types/VoiceId.js +2 -28
- package/dist/serialization/resources/voices/types/VoiceMetadata.js +6 -32
- package/dist/serialization/resources/voices/types/Weight.js +2 -28
- package/dist/serialization/resources/voices/types/index.js +17 -33
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -4
- package/dist/wrapper/Client.js +4 -8
- package/dist/wrapper/StreamingTTSClient.js +4 -11
- package/dist/wrapper/WebPlayer.js +3 -7
- package/dist/wrapper/Websocket.js +23 -52
- package/dist/wrapper/source.js +5 -11
- package/dist/wrapper/utils.js +13 -28
- package/environments.js +1 -4
- package/errors/CartesiaError.js +1 -5
- package/errors/CartesiaTimeoutError.js +1 -5
- package/errors/index.js +2 -7
- package/index.js +4 -34
- package/package.json +1 -1
- package/serialization/index.js +1 -17
- package/serialization/resources/apiStatus/index.js +1 -17
- package/serialization/resources/apiStatus/types/ApiInfo.js +2 -28
- package/serialization/resources/apiStatus/types/index.js +1 -17
- package/serialization/resources/embedding/index.js +1 -17
- package/serialization/resources/embedding/types/Embedding.js +2 -28
- package/serialization/resources/embedding/types/index.js +1 -17
- package/serialization/resources/index.js +10 -39
- package/serialization/resources/tts/index.js +1 -17
- package/serialization/resources/tts/types/CancelContextRequest.js +4 -30
- package/serialization/resources/tts/types/ContextId.js +2 -28
- package/serialization/resources/tts/types/Controls.js +6 -32
- package/serialization/resources/tts/types/Emotion.js +2 -28
- package/serialization/resources/tts/types/GenerationRequest.js +10 -36
- package/serialization/resources/tts/types/Mp3OutputFormat.js +2 -28
- package/serialization/resources/tts/types/NaturalSpecifier.js +2 -28
- package/serialization/resources/tts/types/NumericalSpecifier.js +2 -28
- package/serialization/resources/tts/types/OutputFormat.js +8 -34
- package/serialization/resources/tts/types/RawEncoding.js +2 -28
- package/serialization/resources/tts/types/RawOutputFormat.js +4 -30
- package/serialization/resources/tts/types/Speed.js +4 -30
- package/serialization/resources/tts/types/SupportedLanguage.js +2 -28
- package/serialization/resources/tts/types/TtsRequest.js +8 -34
- package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +6 -32
- package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +6 -32
- package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +4 -30
- package/serialization/resources/tts/types/WavOutputFormat.js +3 -29
- package/serialization/resources/tts/types/WebSocketBaseResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketChunkResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketDoneResponse.js +3 -29
- package/serialization/resources/tts/types/WebSocketErrorResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +4 -30
- package/serialization/resources/tts/types/WebSocketRequest.js +4 -30
- package/serialization/resources/tts/types/WebSocketResponse.js +10 -36
- package/serialization/resources/tts/types/WebSocketStreamOptions.js +2 -28
- package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +6 -32
- package/serialization/resources/tts/types/WebSocketTtsOutput.js +6 -32
- package/serialization/resources/tts/types/WebSocketTtsRequest.js +6 -32
- package/serialization/resources/tts/types/WordTimestamps.js +2 -28
- package/serialization/resources/tts/types/index.js +30 -46
- package/serialization/resources/voiceChanger/index.js +1 -17
- package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +2 -28
- package/serialization/resources/voiceChanger/types/StreamingResponse.js +8 -34
- package/serialization/resources/voiceChanger/types/index.js +2 -18
- package/serialization/resources/voices/client/index.js +1 -27
- package/serialization/resources/voices/client/list.js +3 -29
- package/serialization/resources/voices/index.js +2 -18
- package/serialization/resources/voices/types/BaseVoiceId.js +2 -5
- package/serialization/resources/voices/types/CloneMode.js +2 -28
- package/serialization/resources/voices/types/CreateVoiceRequest.js +8 -34
- package/serialization/resources/voices/types/EmbeddingResponse.js +4 -30
- package/serialization/resources/voices/types/EmbeddingSpecifier.js +6 -32
- package/serialization/resources/voices/types/Gender.js +2 -28
- package/serialization/resources/voices/types/IdSpecifier.js +6 -32
- package/serialization/resources/voices/types/LocalizeDialect.js +2 -28
- package/serialization/resources/voices/types/LocalizeTargetLanguage.js +2 -28
- package/serialization/resources/voices/types/LocalizeVoiceRequest.js +10 -36
- package/serialization/resources/voices/types/MixVoiceSpecifier.js +4 -30
- package/serialization/resources/voices/types/MixVoicesRequest.js +4 -30
- package/serialization/resources/voices/types/UpdateVoiceRequest.js +2 -28
- package/serialization/resources/voices/types/Voice.js +10 -36
- package/serialization/resources/voices/types/VoiceId.js +2 -28
- package/serialization/resources/voices/types/VoiceMetadata.js +6 -32
- package/serialization/resources/voices/types/Weight.js +2 -28
- package/serialization/resources/voices/types/index.js +17 -33
- package/version.d.ts +1 -1
- package/version.js +1 -4
- package/wrapper/Client.js +4 -8
- package/wrapper/StreamingTTSClient.js +4 -11
- package/wrapper/WebPlayer.js +3 -7
- package/wrapper/Websocket.js +23 -52
- package/wrapper/source.js +5 -11
- package/wrapper/utils.js +13 -28
|
@@ -1,33 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./BaseVoiceId"), exports);
|
|
19
|
-
__exportStar(require("./Voice"), exports);
|
|
20
|
-
__exportStar(require("./VoiceMetadata"), exports);
|
|
21
|
-
__exportStar(require("./CreateVoiceRequest"), exports);
|
|
22
|
-
__exportStar(require("./UpdateVoiceRequest"), exports);
|
|
23
|
-
__exportStar(require("./LocalizeTargetLanguage"), exports);
|
|
24
|
-
__exportStar(require("./LocalizeDialect"), exports);
|
|
25
|
-
__exportStar(require("./Gender"), exports);
|
|
26
|
-
__exportStar(require("./LocalizeVoiceRequest"), exports);
|
|
27
|
-
__exportStar(require("./EmbeddingResponse"), exports);
|
|
28
|
-
__exportStar(require("./MixVoicesRequest"), exports);
|
|
29
|
-
__exportStar(require("./Weight"), exports);
|
|
30
|
-
__exportStar(require("./IdSpecifier"), exports);
|
|
31
|
-
__exportStar(require("./EmbeddingSpecifier"), exports);
|
|
32
|
-
__exportStar(require("./MixVoiceSpecifier"), exports);
|
|
33
|
-
__exportStar(require("./CloneMode"), exports);
|
|
1
|
+
export * from "./VoiceId";
|
|
2
|
+
export * from "./BaseVoiceId";
|
|
3
|
+
export * from "./Voice";
|
|
4
|
+
export * from "./VoiceMetadata";
|
|
5
|
+
export * from "./CreateVoiceRequest";
|
|
6
|
+
export * from "./UpdateVoiceRequest";
|
|
7
|
+
export * from "./LocalizeTargetLanguage";
|
|
8
|
+
export * from "./LocalizeDialect";
|
|
9
|
+
export * from "./Gender";
|
|
10
|
+
export * from "./LocalizeVoiceRequest";
|
|
11
|
+
export * from "./EmbeddingResponse";
|
|
12
|
+
export * from "./MixVoicesRequest";
|
|
13
|
+
export * from "./Weight";
|
|
14
|
+
export * from "./IdSpecifier";
|
|
15
|
+
export * from "./EmbeddingSpecifier";
|
|
16
|
+
export * from "./MixVoiceSpecifier";
|
|
17
|
+
export * from "./CloneMode";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,15 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const requestWithRetries_1 = require("./requestWithRetries");
|
|
19
|
-
function fetcherImpl(args) {
|
|
10
|
+
import { createRequestUrl } from "./createRequestUrl";
|
|
11
|
+
import { getFetchFn } from "./getFetchFn";
|
|
12
|
+
import { getRequestBody } from "./getRequestBody";
|
|
13
|
+
import { getResponseBody } from "./getResponseBody";
|
|
14
|
+
import { makeRequest } from "./makeRequest";
|
|
15
|
+
import { requestWithRetries } from "./requestWithRetries";
|
|
16
|
+
export function fetcherImpl(args) {
|
|
20
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
18
|
const headers = {};
|
|
22
19
|
if (args.body !== undefined && args.contentType != null) {
|
|
@@ -29,17 +26,17 @@ function fetcherImpl(args) {
|
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
}
|
|
32
|
-
const url =
|
|
33
|
-
let requestBody = yield
|
|
29
|
+
const url = createRequestUrl(args.url, args.queryParameters);
|
|
30
|
+
let requestBody = yield getRequestBody({
|
|
34
31
|
body: args.body,
|
|
35
32
|
type: args.requestType === "json" ? "json" : "other",
|
|
36
33
|
});
|
|
37
|
-
const fetchFn = yield
|
|
34
|
+
const fetchFn = yield getFetchFn();
|
|
38
35
|
try {
|
|
39
|
-
const response = yield
|
|
40
|
-
return
|
|
36
|
+
const response = yield requestWithRetries(() => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
return makeRequest(fetchFn, url, args.method, headers, requestBody, args.timeoutMs, args.abortSignal, args.withCredentials, args.duplex);
|
|
41
38
|
}), args.maxRetries);
|
|
42
|
-
let responseBody = yield
|
|
39
|
+
let responseBody = yield getResponseBody(response, args.responseType);
|
|
43
40
|
if (response.status >= 200 && response.status < 400) {
|
|
44
41
|
return {
|
|
45
42
|
ok: true,
|
|
@@ -95,5 +92,4 @@ function fetcherImpl(args) {
|
|
|
95
92
|
}
|
|
96
93
|
});
|
|
97
94
|
}
|
|
98
|
-
|
|
99
|
-
exports.fetcher = fetcherImpl;
|
|
95
|
+
export const fetcher = fetcherImpl;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.Supplier = void 0;
|
|
13
|
-
exports.Supplier = {
|
|
10
|
+
export const Supplier = {
|
|
14
11
|
get: (supplier) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
12
|
if (typeof supplier === "function") {
|
|
16
13
|
return supplier();
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.createRequestUrl = void 0;
|
|
7
|
-
const qs_1 = __importDefault(require("qs"));
|
|
8
|
-
function createRequestUrl(baseUrl, queryParameters) {
|
|
1
|
+
import qs from "qs";
|
|
2
|
+
export function createRequestUrl(baseUrl, queryParameters) {
|
|
9
3
|
return Object.keys(queryParameters !== null && queryParameters !== void 0 ? queryParameters : {}).length > 0
|
|
10
|
-
? `${baseUrl}?${
|
|
4
|
+
? `${baseUrl}?${qs.stringify(queryParameters, { arrayFormat: "repeat" })}`
|
|
11
5
|
: baseUrl;
|
|
12
6
|
}
|
|
13
|
-
exports.createRequestUrl = createRequestUrl;
|
|
@@ -1,27 +1,3 @@
|
|
|
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
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,21 +7,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
8
|
});
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
exports.getFetchFn = void 0;
|
|
36
|
-
const runtime_1 = require("../runtime");
|
|
10
|
+
import { RUNTIME } from "../runtime";
|
|
37
11
|
/**
|
|
38
12
|
* Returns a fetch function based on the runtime
|
|
39
13
|
*/
|
|
40
|
-
function getFetchFn() {
|
|
14
|
+
export function getFetchFn() {
|
|
41
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
16
|
// In Node.js 18+ environments, use native fetch
|
|
43
|
-
if (
|
|
17
|
+
if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
|
|
44
18
|
return fetch;
|
|
45
19
|
}
|
|
46
20
|
// In Node.js 18 or lower environments, the SDK always uses`node-fetch`.
|
|
47
|
-
if (
|
|
48
|
-
return (yield
|
|
21
|
+
if (RUNTIME.type === "node") {
|
|
22
|
+
return (yield import("node-fetch")).default;
|
|
49
23
|
}
|
|
50
24
|
// Otherwise the SDK uses global fetch if available,
|
|
51
25
|
// and falls back to node-fetch.
|
|
@@ -53,7 +27,6 @@ function getFetchFn() {
|
|
|
53
27
|
return fetch;
|
|
54
28
|
}
|
|
55
29
|
// Defaults to node `node-fetch` if global fetch isn't available
|
|
56
|
-
return (yield
|
|
30
|
+
return (yield import("node-fetch")).default;
|
|
57
31
|
});
|
|
58
32
|
}
|
|
59
|
-
exports.getFetchFn = getFetchFn;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getHeader = void 0;
|
|
4
|
-
function getHeader(headers, header) {
|
|
1
|
+
export function getHeader(headers, header) {
|
|
5
2
|
for (const [headerKey, headerValue] of Object.entries(headers)) {
|
|
6
3
|
if (headerKey.toLowerCase() === header.toLowerCase()) {
|
|
7
4
|
return headerValue;
|
|
@@ -9,4 +6,3 @@ function getHeader(headers, header) {
|
|
|
9
6
|
}
|
|
10
7
|
return undefined;
|
|
11
8
|
}
|
|
12
|
-
exports.getHeader = getHeader;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.getRequestBody = void 0;
|
|
13
|
-
function getRequestBody({ body, type }) {
|
|
10
|
+
export function getRequestBody({ body, type }) {
|
|
14
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
12
|
if (type.includes("json")) {
|
|
16
13
|
return JSON.stringify(body);
|
|
@@ -20,4 +17,3 @@ function getRequestBody({ body, type }) {
|
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
19
|
}
|
|
23
|
-
exports.getRequestBody = getRequestBody;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,10 +7,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const chooseStreamWrapper_1 = require("./stream-wrappers/chooseStreamWrapper");
|
|
14
|
-
function getResponseBody(response, responseType) {
|
|
10
|
+
import { chooseStreamWrapper } from "./stream-wrappers/chooseStreamWrapper";
|
|
11
|
+
export function getResponseBody(response, responseType) {
|
|
15
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
13
|
if (response.body != null && responseType === "blob") {
|
|
17
14
|
return yield response.blob();
|
|
@@ -20,7 +17,7 @@ function getResponseBody(response, responseType) {
|
|
|
20
17
|
return response.body;
|
|
21
18
|
}
|
|
22
19
|
else if (response.body != null && responseType === "streaming") {
|
|
23
|
-
return
|
|
20
|
+
return chooseStreamWrapper(response.body);
|
|
24
21
|
}
|
|
25
22
|
else if (response.body != null && responseType === "text") {
|
|
26
23
|
return yield response.text();
|
|
@@ -49,4 +46,3 @@ function getResponseBody(response, responseType) {
|
|
|
49
46
|
}
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
|
-
exports.getResponseBody = getResponseBody;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var Fetcher_1 = require("./Fetcher");
|
|
5
|
-
Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return Fetcher_1.fetcher; } });
|
|
6
|
-
var getHeader_1 = require("./getHeader");
|
|
7
|
-
Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_1.getHeader; } });
|
|
8
|
-
var Supplier_1 = require("./Supplier");
|
|
9
|
-
Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Supplier_1.Supplier; } });
|
|
1
|
+
export { fetcher } from "./Fetcher";
|
|
2
|
+
export { getHeader } from "./getHeader";
|
|
3
|
+
export { Supplier } from "./Supplier";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,15 +7,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const signals_1 = require("./signals");
|
|
14
|
-
const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
import { anySignal, getTimeoutSignal } from "./signals";
|
|
11
|
+
export const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abortSignal, withCredentials, duplex) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
12
|
const signals = [];
|
|
16
13
|
// Add timeout signal
|
|
17
14
|
let timeoutAbortId = undefined;
|
|
18
15
|
if (timeoutMs != null) {
|
|
19
|
-
const { signal, abortId } =
|
|
16
|
+
const { signal, abortId } = getTimeoutSignal(timeoutMs);
|
|
20
17
|
timeoutAbortId = abortId;
|
|
21
18
|
signals.push(signal);
|
|
22
19
|
}
|
|
@@ -24,7 +21,7 @@ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abor
|
|
|
24
21
|
if (abortSignal != null) {
|
|
25
22
|
signals.push(abortSignal);
|
|
26
23
|
}
|
|
27
|
-
let newSignals =
|
|
24
|
+
let newSignals = anySignal(signals);
|
|
28
25
|
const response = yield fetchFn(url, {
|
|
29
26
|
method: method,
|
|
30
27
|
headers,
|
|
@@ -39,4 +36,3 @@ const makeRequest = (fetchFn, url, method, headers, requestBody, timeoutMs, abor
|
|
|
39
36
|
}
|
|
40
37
|
return response;
|
|
41
38
|
});
|
|
42
|
-
exports.makeRequest = makeRequest;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,8 +7,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.requestWithRetries = void 0;
|
|
13
10
|
const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
14
11
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
15
12
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -19,7 +16,7 @@ function addJitter(delay) {
|
|
|
19
16
|
const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
|
|
20
17
|
return delay * jitterMultiplier;
|
|
21
18
|
}
|
|
22
|
-
function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
19
|
+
export function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
23
20
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
21
|
let response = yield requestFn();
|
|
25
22
|
for (let i = 0; i < maxRetries; ++i) {
|
|
@@ -38,4 +35,3 @@ function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
|
38
35
|
return response;
|
|
39
36
|
});
|
|
40
37
|
}
|
|
41
|
-
exports.requestWithRetries = requestWithRetries;
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.anySignal = exports.getTimeoutSignal = void 0;
|
|
4
1
|
const TIMEOUT = "timeout";
|
|
5
|
-
function getTimeoutSignal(timeoutMs) {
|
|
2
|
+
export function getTimeoutSignal(timeoutMs) {
|
|
6
3
|
const controller = new AbortController();
|
|
7
4
|
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
8
5
|
return { signal: controller.signal, abortId };
|
|
9
6
|
}
|
|
10
|
-
exports.getTimeoutSignal = getTimeoutSignal;
|
|
11
7
|
/**
|
|
12
8
|
* Returns an abort signal that is getting aborted when
|
|
13
9
|
* at least one of the specified abort signals is aborted.
|
|
14
10
|
*
|
|
15
11
|
* Requires at least node.js 18.
|
|
16
12
|
*/
|
|
17
|
-
function anySignal(...args) {
|
|
13
|
+
export function anySignal(...args) {
|
|
18
14
|
// Allowing signals to be passed either as array
|
|
19
15
|
// of signals or as multiple arguments.
|
|
20
16
|
const signals = (args.length === 1 && Array.isArray(args[0]) ? args[0] : args);
|
|
@@ -34,4 +30,3 @@ function anySignal(...args) {
|
|
|
34
30
|
}
|
|
35
31
|
return controller.signal;
|
|
36
32
|
}
|
|
37
|
-
exports.anySignal = anySignal;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.Node18UniversalStreamWrapper = void 0;
|
|
13
|
-
class Node18UniversalStreamWrapper {
|
|
10
|
+
export class Node18UniversalStreamWrapper {
|
|
14
11
|
constructor(readableStream) {
|
|
15
12
|
this.readableStream = readableStream;
|
|
16
13
|
this.reader = this.readableStream.getReader();
|
|
@@ -244,4 +241,3 @@ class Node18UniversalStreamWrapper {
|
|
|
244
241
|
};
|
|
245
242
|
}
|
|
246
243
|
}
|
|
247
|
-
exports.Node18UniversalStreamWrapper = Node18UniversalStreamWrapper;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -15,9 +14,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
|
15
14
|
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); }); }; }
|
|
16
15
|
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
16
|
};
|
|
18
|
-
|
|
19
|
-
exports.NodePre18StreamWrapper = void 0;
|
|
20
|
-
class NodePre18StreamWrapper {
|
|
17
|
+
export class NodePre18StreamWrapper {
|
|
21
18
|
constructor(readableStream) {
|
|
22
19
|
this.readableStream = readableStream;
|
|
23
20
|
}
|
|
@@ -121,4 +118,3 @@ class NodePre18StreamWrapper {
|
|
|
121
118
|
};
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
|
-
exports.NodePre18StreamWrapper = NodePre18StreamWrapper;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,9 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
8
|
});
|
|
10
9
|
};
|
|
11
|
-
|
|
12
|
-
exports.UndiciStreamWrapper = void 0;
|
|
13
|
-
class UndiciStreamWrapper {
|
|
10
|
+
export class UndiciStreamWrapper {
|
|
14
11
|
constructor(readableStream) {
|
|
15
12
|
this.readableStream = readableStream;
|
|
16
13
|
this.reader = this.readableStream.getReader();
|
|
@@ -226,4 +223,3 @@ class UndiciStreamWrapper {
|
|
|
226
223
|
};
|
|
227
224
|
}
|
|
228
225
|
}
|
|
229
|
-
exports.UndiciStreamWrapper = UndiciStreamWrapper;
|
|
@@ -1,27 +1,3 @@
|
|
|
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
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,20 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
8
|
});
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const runtime_1 = require("../../runtime");
|
|
37
|
-
function chooseStreamWrapper(responseBody) {
|
|
10
|
+
import { RUNTIME } from "../../runtime";
|
|
11
|
+
export function chooseStreamWrapper(responseBody) {
|
|
38
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (
|
|
40
|
-
return new (yield
|
|
13
|
+
if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
|
|
14
|
+
return new (yield import("./Node18UniversalStreamWrapper")).Node18UniversalStreamWrapper(responseBody);
|
|
41
15
|
}
|
|
42
|
-
else if (
|
|
43
|
-
return new (yield
|
|
16
|
+
else if (RUNTIME.type !== "node" && typeof fetch === "function") {
|
|
17
|
+
return new (yield import("./UndiciStreamWrapper")).UndiciStreamWrapper(responseBody);
|
|
44
18
|
}
|
|
45
19
|
else {
|
|
46
|
-
return new (yield
|
|
20
|
+
return new (yield import("./NodePre18StreamWrapper")).NodePre18StreamWrapper(responseBody);
|
|
47
21
|
}
|
|
48
22
|
});
|
|
49
23
|
}
|
|
50
|
-
exports.chooseStreamWrapper = chooseStreamWrapper;
|
|
@@ -1,27 +1,3 @@
|
|
|
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
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -31,19 +7,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
31
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
8
|
});
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
exports.WebFormData = exports.Node16FormData = exports.Node18FormData = exports.newFormData = void 0;
|
|
36
|
-
const runtime_1 = require("../runtime");
|
|
10
|
+
import { RUNTIME } from "../runtime";
|
|
37
11
|
function isNamedValue(value) {
|
|
38
12
|
return typeof value === "object" && value != null && "name" in value;
|
|
39
13
|
}
|
|
40
|
-
function newFormData() {
|
|
14
|
+
export function newFormData() {
|
|
41
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
16
|
let formdata;
|
|
43
|
-
if (
|
|
17
|
+
if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
|
|
44
18
|
formdata = new Node18FormData();
|
|
45
19
|
}
|
|
46
|
-
else if (
|
|
20
|
+
else if (RUNTIME.type === "node") {
|
|
47
21
|
formdata = new Node16FormData();
|
|
48
22
|
}
|
|
49
23
|
else {
|
|
@@ -53,14 +27,13 @@ function newFormData() {
|
|
|
53
27
|
return formdata;
|
|
54
28
|
});
|
|
55
29
|
}
|
|
56
|
-
exports.newFormData = newFormData;
|
|
57
30
|
/**
|
|
58
31
|
* Form Data Implementation for Node.js 18+
|
|
59
32
|
*/
|
|
60
|
-
class Node18FormData {
|
|
33
|
+
export class Node18FormData {
|
|
61
34
|
setup() {
|
|
62
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
this.fd = new (yield
|
|
36
|
+
this.fd = new (yield import("formdata-node")).FormData();
|
|
64
37
|
});
|
|
65
38
|
}
|
|
66
39
|
append(key, value) {
|
|
@@ -90,23 +63,22 @@ class Node18FormData {
|
|
|
90
63
|
}
|
|
91
64
|
getRequest() {
|
|
92
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
const encoder = new (yield
|
|
66
|
+
const encoder = new (yield import("form-data-encoder")).FormDataEncoder(this.fd);
|
|
94
67
|
return {
|
|
95
|
-
body: (yield
|
|
68
|
+
body: (yield import("readable-stream")).Readable.from(encoder),
|
|
96
69
|
headers: encoder.headers,
|
|
97
70
|
duplex: "half",
|
|
98
71
|
};
|
|
99
72
|
});
|
|
100
73
|
}
|
|
101
74
|
}
|
|
102
|
-
exports.Node18FormData = Node18FormData;
|
|
103
75
|
/**
|
|
104
76
|
* Form Data Implementation for Node.js 16-18
|
|
105
77
|
*/
|
|
106
|
-
class Node16FormData {
|
|
78
|
+
export class Node16FormData {
|
|
107
79
|
setup() {
|
|
108
80
|
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
-
this.fd = new (yield
|
|
81
|
+
this.fd = new (yield import("form-data")).default();
|
|
110
82
|
});
|
|
111
83
|
}
|
|
112
84
|
append(key, value) {
|
|
@@ -141,11 +113,10 @@ class Node16FormData {
|
|
|
141
113
|
};
|
|
142
114
|
}
|
|
143
115
|
}
|
|
144
|
-
exports.Node16FormData = Node16FormData;
|
|
145
116
|
/**
|
|
146
117
|
* Form Data Implementation for Web
|
|
147
118
|
*/
|
|
148
|
-
class WebFormData {
|
|
119
|
+
export class WebFormData {
|
|
149
120
|
setup() {
|
|
150
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
151
122
|
this.fd = new FormData();
|
|
@@ -171,4 +142,3 @@ class WebFormData {
|
|
|
171
142
|
};
|
|
172
143
|
}
|
|
173
144
|
}
|
|
174
|
-
exports.WebFormData = WebFormData;
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
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("./FormDataWrapper"), exports);
|
|
1
|
+
export * from "./FormDataWrapper";
|