@cartesia/cartesia-js 2.1.3 → 2.1.5
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.d.ts +12 -5
- package/Client.js +11 -6
- package/api/resources/apiStatus/client/Client.d.ts +4 -0
- package/api/resources/apiStatus/client/Client.js +21 -11
- package/api/resources/datasets/client/Client.d.ts +4 -1
- package/api/resources/datasets/client/Client.js +34 -24
- package/api/resources/datasets/types/FilePurpose.d.ts +1 -1
- package/api/resources/embedding/types/Embedding.d.ts +1 -1
- package/api/resources/index.d.ts +2 -0
- package/api/resources/index.js +20 -8
- package/api/resources/infill/client/Client.d.ts +49 -0
- package/api/resources/infill/client/Client.js +148 -0
- package/api/resources/infill/client/index.d.ts +1 -0
- package/api/resources/infill/client/index.js +17 -0
- package/api/resources/infill/client/requests/InfillBytesRequest.d.ts +71 -0
- package/api/resources/infill/client/requests/InfillBytesRequest.js +5 -0
- package/api/resources/infill/client/requests/index.d.ts +1 -0
- package/api/resources/infill/client/requests/index.js +2 -0
- package/api/resources/infill/index.d.ts +1 -0
- package/api/resources/infill/index.js +17 -0
- package/api/resources/tts/client/Client.js +21 -11
- package/api/resources/tts/types/ContextId.d.ts +1 -1
- package/api/resources/tts/types/Emotion.d.ts +5 -1
- package/api/resources/tts/types/Emotion.js +4 -0
- package/api/resources/tts/types/FlushId.d.ts +9 -0
- package/api/resources/tts/types/FlushId.js +5 -0
- package/api/resources/tts/types/GenerationRequest.d.ts +7 -2
- package/api/resources/tts/types/NaturalSpecifier.d.ts +1 -1
- package/api/resources/tts/types/NumericalSpecifier.d.ts +1 -1
- package/api/resources/tts/types/OutputFormat.d.ts +1 -1
- package/api/resources/tts/types/PhonemeTimestamps.d.ts +8 -0
- package/api/resources/tts/types/PhonemeTimestamps.js +5 -0
- package/api/resources/tts/types/RawEncoding.d.ts +1 -1
- package/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
- package/api/resources/tts/types/Speed.d.ts +1 -1
- package/api/resources/tts/types/SupportedLanguage.d.ts +1 -1
- package/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +1 -1
- package/api/resources/tts/types/WebSocketFlushDoneResponse.d.ts +8 -0
- package/api/resources/tts/types/WebSocketFlushDoneResponse.js +5 -0
- package/api/resources/tts/types/WebSocketPhonemeTimestampsResponse.d.ts +7 -0
- package/api/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +5 -0
- package/api/resources/tts/types/WebSocketRequest.d.ts +1 -1
- package/api/resources/tts/types/WebSocketResponse.d.ts +7 -1
- package/api/resources/tts/types/WebSocketTtsOutput.d.ts +3 -0
- package/api/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
- package/api/resources/tts/types/index.d.ts +4 -0
- package/api/resources/tts/types/index.js +4 -0
- package/api/resources/voiceChanger/client/Client.d.ts +3 -4
- package/api/resources/voiceChanger/client/Client.js +23 -13
- package/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +1 -1
- package/api/resources/voiceChanger/types/StreamingResponse.d.ts +1 -1
- package/api/resources/voices/client/Client.d.ts +5 -3
- package/api/resources/voices/client/Client.js +56 -47
- package/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
- package/api/resources/voices/types/CloneMode.d.ts +1 -1
- package/api/resources/voices/types/CreateVoiceRequest.d.ts +0 -1
- package/api/resources/voices/types/Gender.d.ts +1 -1
- package/api/resources/voices/types/LocalizeDialect.d.ts +12 -4
- package/api/resources/voices/types/LocalizeEnglishDialect.d.ts +1 -1
- package/api/resources/voices/types/LocalizePortugueseDialect.d.ts +8 -0
- package/api/resources/voices/types/LocalizePortugueseDialect.js +10 -0
- package/api/resources/voices/types/LocalizeSpanishDialect.d.ts +8 -0
- package/api/resources/voices/types/LocalizeSpanishDialect.js +10 -0
- package/api/resources/voices/types/LocalizeTargetLanguage.d.ts +1 -1
- package/api/resources/voices/types/MixVoiceSpecifier.d.ts +1 -1
- package/api/resources/voices/types/Voice.d.ts +0 -1
- package/api/resources/voices/types/VoiceId.d.ts +1 -1
- package/api/resources/voices/types/Weight.d.ts +1 -1
- package/api/resources/voices/types/index.d.ts +2 -0
- package/api/resources/voices/types/index.js +2 -0
- package/core/fetcher/APIResponse.d.ts +1 -1
- package/core/fetcher/Fetcher.d.ts +1 -1
- package/core/fetcher/Fetcher.js +2 -2
- package/core/fetcher/Supplier.d.ts +1 -1
- package/core/fetcher/createRequestUrl.d.ts +1 -1
- package/core/fetcher/createRequestUrl.js +1 -2
- package/core/fetcher/getFetchFn.js +18 -9
- package/core/fetcher/getHeader.js +1 -2
- package/core/fetcher/getRequestBody.js +5 -5
- package/core/fetcher/getResponseBody.js +1 -2
- package/core/fetcher/makeRequest.d.ts +1 -1
- package/core/fetcher/requestWithRetries.js +4 -5
- package/core/fetcher/signals.d.ts +0 -1
- package/core/fetcher/signals.js +2 -3
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
- package/core/form-data-utils/FormDataWrapper.d.ts +4 -4
- package/core/form-data-utils/FormDataWrapper.js +22 -12
- package/core/index.js +17 -7
- package/core/json.d.ts +15 -0
- package/core/json.js +24 -0
- package/core/runtime/runtime.d.ts +1 -1
- package/core/runtime/runtime.js +51 -41
- package/core/schemas/Schema.d.ts +7 -5
- package/core/schemas/Schema.js +2 -0
- package/core/schemas/builders/bigint/bigint.d.ts +1 -1
- package/core/schemas/builders/bigint/bigint.js +22 -19
- package/core/schemas/builders/date/date.js +1 -2
- package/core/schemas/builders/enum/enum.js +1 -2
- package/core/schemas/builders/lazy/lazy.d.ts +1 -1
- package/core/schemas/builders/lazy/lazy.js +3 -4
- package/core/schemas/builders/lazy/lazyObject.js +1 -2
- package/core/schemas/builders/list/list.js +1 -2
- package/core/schemas/builders/literals/booleanLiteral.js +1 -2
- package/core/schemas/builders/literals/stringLiteral.js +1 -2
- package/core/schemas/builders/object/object.d.ts +1 -1
- package/core/schemas/builders/object/object.js +31 -3
- package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +3 -3
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +1 -2
- package/core/schemas/builders/object/property.js +2 -3
- package/core/schemas/builders/object/types.d.ts +16 -11
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +2 -3
- package/core/schemas/builders/object-like/types.d.ts +1 -1
- package/core/schemas/builders/record/record.js +2 -4
- package/core/schemas/builders/record/types.d.ts +2 -2
- package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +67 -4
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -2
- package/core/schemas/builders/set/set.js +1 -2
- package/core/schemas/builders/undiscriminated-union/types.d.ts +4 -4
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +1 -2
- package/core/schemas/builders/union/discriminant.js +1 -2
- package/core/schemas/builders/union/types.d.ts +6 -6
- package/core/schemas/builders/union/union.d.ts +1 -1
- package/core/schemas/builders/union/union.js +1 -2
- package/core/schemas/utils/MaybePromise.d.ts +1 -1
- package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +4 -4
- package/core/schemas/utils/createIdentitySchemaCreator.js +1 -2
- package/core/schemas/utils/entries.d.ts +1 -1
- package/core/schemas/utils/entries.js +1 -2
- package/core/schemas/utils/filterObject.d.ts +1 -1
- package/core/schemas/utils/filterObject.js +1 -2
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -2
- package/core/schemas/utils/isPlainObject.js +1 -2
- package/core/schemas/utils/keys.d.ts +1 -1
- package/core/schemas/utils/keys.js +1 -2
- package/core/schemas/utils/maybeSkipValidation.js +1 -2
- package/core/schemas/utils/partition.js +1 -2
- package/core/streaming-fetcher/Stream.d.ts +0 -1
- package/core/streaming-fetcher/Stream.js +20 -21
- package/core/websocket/ws.d.ts +7 -7
- package/core/websocket/ws.js +17 -7
- package/dist/Client.d.ts +12 -5
- package/dist/Client.js +11 -6
- package/dist/api/resources/apiStatus/client/Client.d.ts +4 -0
- package/dist/api/resources/apiStatus/client/Client.js +21 -11
- package/dist/api/resources/datasets/client/Client.d.ts +4 -1
- package/dist/api/resources/datasets/client/Client.js +34 -24
- package/dist/api/resources/datasets/types/FilePurpose.d.ts +1 -1
- package/dist/api/resources/embedding/types/Embedding.d.ts +1 -1
- package/dist/api/resources/index.d.ts +2 -0
- package/dist/api/resources/index.js +20 -8
- package/dist/api/resources/infill/client/Client.d.ts +49 -0
- package/dist/api/resources/infill/client/Client.js +148 -0
- package/dist/api/resources/infill/client/index.d.ts +1 -0
- package/dist/api/resources/infill/client/index.js +17 -0
- package/dist/api/resources/infill/client/requests/InfillBytesRequest.d.ts +71 -0
- package/dist/api/resources/infill/client/requests/InfillBytesRequest.js +5 -0
- package/dist/api/resources/infill/client/requests/index.d.ts +1 -0
- package/dist/api/resources/infill/client/requests/index.js +2 -0
- package/dist/api/resources/infill/index.d.ts +1 -0
- package/dist/api/resources/infill/index.js +17 -0
- package/dist/api/resources/tts/client/Client.js +21 -11
- package/dist/api/resources/tts/types/ContextId.d.ts +1 -1
- package/dist/api/resources/tts/types/Emotion.d.ts +5 -1
- package/dist/api/resources/tts/types/Emotion.js +4 -0
- package/dist/api/resources/tts/types/FlushId.d.ts +9 -0
- package/dist/api/resources/tts/types/FlushId.js +5 -0
- package/dist/api/resources/tts/types/GenerationRequest.d.ts +7 -2
- package/dist/api/resources/tts/types/NaturalSpecifier.d.ts +1 -1
- package/dist/api/resources/tts/types/NumericalSpecifier.d.ts +1 -1
- package/dist/api/resources/tts/types/OutputFormat.d.ts +1 -1
- package/dist/api/resources/tts/types/PhonemeTimestamps.d.ts +8 -0
- package/dist/api/resources/tts/types/PhonemeTimestamps.js +5 -0
- package/dist/api/resources/tts/types/RawEncoding.d.ts +1 -1
- package/dist/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
- package/dist/api/resources/tts/types/Speed.d.ts +1 -1
- package/dist/api/resources/tts/types/SupportedLanguage.d.ts +1 -1
- package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +1 -1
- package/dist/api/resources/tts/types/WebSocketFlushDoneResponse.d.ts +8 -0
- package/dist/api/resources/tts/types/WebSocketFlushDoneResponse.js +5 -0
- package/dist/api/resources/tts/types/WebSocketPhonemeTimestampsResponse.d.ts +7 -0
- package/dist/api/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +5 -0
- package/dist/api/resources/tts/types/WebSocketRequest.d.ts +1 -1
- package/dist/api/resources/tts/types/WebSocketResponse.d.ts +7 -1
- package/dist/api/resources/tts/types/WebSocketTtsOutput.d.ts +3 -0
- package/dist/api/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
- package/dist/api/resources/tts/types/index.d.ts +4 -0
- package/dist/api/resources/tts/types/index.js +4 -0
- package/dist/api/resources/voiceChanger/client/Client.d.ts +3 -4
- package/dist/api/resources/voiceChanger/client/Client.js +23 -13
- package/dist/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +1 -1
- package/dist/api/resources/voiceChanger/types/StreamingResponse.d.ts +1 -1
- package/dist/api/resources/voices/client/Client.d.ts +5 -3
- package/dist/api/resources/voices/client/Client.js +56 -47
- package/dist/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
- package/dist/api/resources/voices/types/CloneMode.d.ts +1 -1
- package/dist/api/resources/voices/types/CreateVoiceRequest.d.ts +0 -1
- package/dist/api/resources/voices/types/Gender.d.ts +1 -1
- package/dist/api/resources/voices/types/LocalizeDialect.d.ts +12 -4
- package/dist/api/resources/voices/types/LocalizeEnglishDialect.d.ts +1 -1
- package/dist/api/resources/voices/types/LocalizePortugueseDialect.d.ts +8 -0
- package/dist/api/resources/voices/types/LocalizePortugueseDialect.js +10 -0
- package/dist/api/resources/voices/types/LocalizeSpanishDialect.d.ts +8 -0
- package/dist/api/resources/voices/types/LocalizeSpanishDialect.js +10 -0
- package/dist/api/resources/voices/types/LocalizeTargetLanguage.d.ts +1 -1
- package/dist/api/resources/voices/types/MixVoiceSpecifier.d.ts +1 -1
- package/dist/api/resources/voices/types/Voice.d.ts +0 -1
- package/dist/api/resources/voices/types/VoiceId.d.ts +1 -1
- package/dist/api/resources/voices/types/Weight.d.ts +1 -1
- package/dist/api/resources/voices/types/index.d.ts +2 -0
- package/dist/api/resources/voices/types/index.js +2 -0
- package/dist/core/fetcher/APIResponse.d.ts +1 -1
- package/dist/core/fetcher/Fetcher.d.ts +1 -1
- package/dist/core/fetcher/Fetcher.js +2 -2
- package/dist/core/fetcher/Supplier.d.ts +1 -1
- package/dist/core/fetcher/createRequestUrl.d.ts +1 -1
- package/dist/core/fetcher/createRequestUrl.js +1 -2
- package/dist/core/fetcher/getFetchFn.js +18 -9
- package/dist/core/fetcher/getHeader.js +1 -2
- package/dist/core/fetcher/getRequestBody.js +5 -5
- package/dist/core/fetcher/getResponseBody.js +1 -2
- package/dist/core/fetcher/makeRequest.d.ts +1 -1
- package/dist/core/fetcher/requestWithRetries.js +4 -5
- package/dist/core/fetcher/signals.d.ts +0 -1
- package/dist/core/fetcher/signals.js +2 -3
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
- package/dist/core/form-data-utils/FormDataWrapper.d.ts +4 -4
- package/dist/core/form-data-utils/FormDataWrapper.js +22 -12
- package/dist/core/index.js +17 -7
- package/dist/core/json.d.ts +15 -0
- package/dist/core/json.js +24 -0
- package/dist/core/runtime/runtime.d.ts +1 -1
- package/dist/core/runtime/runtime.js +51 -41
- package/dist/core/schemas/Schema.d.ts +7 -5
- package/dist/core/schemas/Schema.js +2 -0
- package/dist/core/schemas/builders/bigint/bigint.d.ts +1 -1
- package/dist/core/schemas/builders/bigint/bigint.js +22 -19
- package/dist/core/schemas/builders/date/date.js +1 -2
- package/dist/core/schemas/builders/enum/enum.js +1 -2
- package/dist/core/schemas/builders/lazy/lazy.d.ts +1 -1
- package/dist/core/schemas/builders/lazy/lazy.js +3 -4
- package/dist/core/schemas/builders/lazy/lazyObject.js +1 -2
- package/dist/core/schemas/builders/list/list.js +1 -2
- package/dist/core/schemas/builders/literals/booleanLiteral.js +1 -2
- package/dist/core/schemas/builders/literals/stringLiteral.js +1 -2
- package/dist/core/schemas/builders/object/object.d.ts +1 -1
- package/dist/core/schemas/builders/object/object.js +31 -3
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +3 -3
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +1 -2
- package/dist/core/schemas/builders/object/property.js +2 -3
- package/dist/core/schemas/builders/object/types.d.ts +16 -11
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +2 -3
- package/dist/core/schemas/builders/object-like/types.d.ts +1 -1
- package/dist/core/schemas/builders/record/record.js +2 -4
- package/dist/core/schemas/builders/record/types.d.ts +2 -2
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +67 -4
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -2
- package/dist/core/schemas/builders/set/set.js +1 -2
- package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -4
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +1 -2
- package/dist/core/schemas/builders/union/discriminant.js +1 -2
- package/dist/core/schemas/builders/union/types.d.ts +6 -6
- package/dist/core/schemas/builders/union/union.d.ts +1 -1
- package/dist/core/schemas/builders/union/union.js +1 -2
- package/dist/core/schemas/utils/MaybePromise.d.ts +1 -1
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +4 -4
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +1 -2
- package/dist/core/schemas/utils/entries.d.ts +1 -1
- package/dist/core/schemas/utils/entries.js +1 -2
- package/dist/core/schemas/utils/filterObject.d.ts +1 -1
- package/dist/core/schemas/utils/filterObject.js +1 -2
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -2
- package/dist/core/schemas/utils/isPlainObject.js +1 -2
- package/dist/core/schemas/utils/keys.d.ts +1 -1
- package/dist/core/schemas/utils/keys.js +1 -2
- package/dist/core/schemas/utils/maybeSkipValidation.js +1 -2
- package/dist/core/schemas/utils/partition.js +1 -2
- package/dist/core/streaming-fetcher/Stream.d.ts +0 -1
- package/dist/core/streaming-fetcher/Stream.js +20 -21
- package/dist/core/websocket/ws.d.ts +7 -7
- package/dist/core/websocket/ws.js +17 -7
- package/dist/environments.d.ts +1 -1
- package/dist/errors/CartesiaError.js +2 -1
- package/dist/errors/CartesiaTimeoutError.d.ts +1 -1
- package/dist/errors/CartesiaTimeoutError.js +2 -2
- package/dist/index.js +17 -7
- package/dist/serialization/resources/apiStatus/types/ApiInfo.js +17 -7
- package/dist/serialization/resources/datasets/types/CreateDatasetRequest.js +17 -7
- package/dist/serialization/resources/datasets/types/Dataset.js +17 -7
- package/dist/serialization/resources/datasets/types/DatasetFile.js +17 -7
- package/dist/serialization/resources/datasets/types/FilePurpose.js +17 -7
- package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +17 -7
- package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +17 -7
- package/dist/serialization/resources/embedding/types/Embedding.js +17 -7
- package/dist/serialization/resources/index.js +17 -7
- package/dist/serialization/resources/tts/types/CancelContextRequest.js +17 -7
- package/dist/serialization/resources/tts/types/ContextId.js +17 -7
- package/dist/serialization/resources/tts/types/Controls.js +17 -7
- package/dist/serialization/resources/tts/types/Emotion.d.ts +1 -1
- package/dist/serialization/resources/tts/types/Emotion.js +21 -7
- package/dist/serialization/resources/tts/types/FlushId.d.ts +10 -0
- package/dist/serialization/resources/tts/types/FlushId.js +41 -0
- package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +4 -2
- package/dist/serialization/resources/tts/types/GenerationRequest.js +21 -9
- package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +17 -7
- package/dist/serialization/resources/tts/types/NaturalSpecifier.js +17 -7
- package/dist/serialization/resources/tts/types/NumericalSpecifier.js +17 -7
- package/dist/serialization/resources/tts/types/OutputFormat.js +17 -7
- package/dist/serialization/resources/tts/types/PhonemeTimestamps.d.ts +14 -0
- package/dist/serialization/resources/tts/types/PhonemeTimestamps.js +45 -0
- package/dist/serialization/resources/tts/types/RawEncoding.js +17 -7
- package/dist/serialization/resources/tts/types/RawOutputFormat.d.ts +1 -0
- package/dist/serialization/resources/tts/types/RawOutputFormat.js +18 -7
- package/dist/serialization/resources/tts/types/Speed.js +17 -7
- package/dist/serialization/resources/tts/types/SupportedLanguage.js +17 -7
- package/dist/serialization/resources/tts/types/TtsRequest.js +17 -7
- package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +17 -7
- package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +17 -7
- package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +17 -7
- package/dist/serialization/resources/tts/types/WavOutputFormat.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketFlushDoneResponse.d.ts +15 -0
- package/dist/serialization/resources/tts/types/WebSocketFlushDoneResponse.js +48 -0
- package/dist/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.d.ts +14 -0
- package/dist/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +47 -0
- package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketRequest.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketResponse.d.ts +9 -1
- package/dist/serialization/resources/tts/types/WebSocketResponse.js +21 -7
- package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +17 -7
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +5 -0
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +22 -7
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +18 -7
- package/dist/serialization/resources/tts/types/WordTimestamps.js +17 -7
- package/dist/serialization/resources/tts/types/index.d.ts +4 -0
- package/dist/serialization/resources/tts/types/index.js +4 -0
- package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +17 -7
- package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +17 -7
- package/dist/serialization/resources/voices/client/index.js +17 -7
- package/dist/serialization/resources/voices/client/list.js +17 -7
- package/dist/serialization/resources/voices/types/CloneMode.js +17 -7
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.d.ts +0 -2
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +17 -9
- package/dist/serialization/resources/voices/types/EmbeddingResponse.js +17 -7
- package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +17 -7
- package/dist/serialization/resources/voices/types/Gender.js +17 -7
- package/dist/serialization/resources/voices/types/IdSpecifier.js +17 -7
- package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +3 -1
- package/dist/serialization/resources/voices/types/LocalizeDialect.js +24 -8
- package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.js +17 -7
- package/dist/serialization/resources/voices/types/LocalizePortugueseDialect.d.ts +10 -0
- package/dist/serialization/resources/voices/types/LocalizePortugueseDialect.js +41 -0
- package/dist/serialization/resources/voices/types/LocalizeSpanishDialect.d.ts +10 -0
- package/dist/serialization/resources/voices/types/LocalizeSpanishDialect.js +41 -0
- package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +17 -7
- package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +17 -7
- package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +17 -7
- package/dist/serialization/resources/voices/types/MixVoicesRequest.js +17 -7
- package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +17 -7
- package/dist/serialization/resources/voices/types/Voice.d.ts +0 -2
- package/dist/serialization/resources/voices/types/Voice.js +17 -9
- package/dist/serialization/resources/voices/types/VoiceId.js +17 -7
- package/dist/serialization/resources/voices/types/VoiceMetadata.js +17 -7
- package/dist/serialization/resources/voices/types/Weight.js +17 -7
- package/dist/serialization/resources/voices/types/index.d.ts +2 -0
- package/dist/serialization/resources/voices/types/index.js +2 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/wrapper/WebPlayer.js +1 -1
- package/dist/wrapper/Websocket.js +25 -15
- package/dist/wrapper/source.js +1 -1
- package/dist/wrapper/utils.d.ts +9 -9
- package/dist/wrapper/utils.js +10 -10
- package/environments.d.ts +1 -1
- package/errors/CartesiaError.js +2 -1
- package/errors/CartesiaTimeoutError.d.ts +1 -1
- package/errors/CartesiaTimeoutError.js +2 -2
- package/index.js +17 -7
- package/{jest.config.js → jest.config.mjs} +4 -1
- package/package.json +15 -16
- package/reference.md +97 -1
- package/scripts/rename-to-esm-files.js +115 -0
- package/serialization/resources/apiStatus/types/ApiInfo.js +17 -7
- package/serialization/resources/datasets/types/CreateDatasetRequest.js +17 -7
- package/serialization/resources/datasets/types/Dataset.js +17 -7
- package/serialization/resources/datasets/types/DatasetFile.js +17 -7
- package/serialization/resources/datasets/types/FilePurpose.js +17 -7
- package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +17 -7
- package/serialization/resources/datasets/types/PaginatedDatasets.js +17 -7
- package/serialization/resources/embedding/types/Embedding.js +17 -7
- package/serialization/resources/index.js +17 -7
- package/serialization/resources/tts/types/CancelContextRequest.js +17 -7
- package/serialization/resources/tts/types/ContextId.js +17 -7
- package/serialization/resources/tts/types/Controls.js +17 -7
- package/serialization/resources/tts/types/Emotion.d.ts +1 -1
- package/serialization/resources/tts/types/Emotion.js +21 -7
- package/serialization/resources/tts/types/FlushId.d.ts +10 -0
- package/serialization/resources/tts/types/FlushId.js +41 -0
- package/serialization/resources/tts/types/GenerationRequest.d.ts +4 -2
- package/serialization/resources/tts/types/GenerationRequest.js +21 -9
- package/serialization/resources/tts/types/Mp3OutputFormat.js +17 -7
- package/serialization/resources/tts/types/NaturalSpecifier.js +17 -7
- package/serialization/resources/tts/types/NumericalSpecifier.js +17 -7
- package/serialization/resources/tts/types/OutputFormat.js +17 -7
- package/serialization/resources/tts/types/PhonemeTimestamps.d.ts +14 -0
- package/serialization/resources/tts/types/PhonemeTimestamps.js +45 -0
- package/serialization/resources/tts/types/RawEncoding.js +17 -7
- package/serialization/resources/tts/types/RawOutputFormat.d.ts +1 -0
- package/serialization/resources/tts/types/RawOutputFormat.js +18 -7
- package/serialization/resources/tts/types/Speed.js +17 -7
- package/serialization/resources/tts/types/SupportedLanguage.js +17 -7
- package/serialization/resources/tts/types/TtsRequest.js +17 -7
- package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +17 -7
- package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +17 -7
- package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +17 -7
- package/serialization/resources/tts/types/WavOutputFormat.js +17 -7
- package/serialization/resources/tts/types/WebSocketBaseResponse.js +17 -7
- package/serialization/resources/tts/types/WebSocketChunkResponse.js +17 -7
- package/serialization/resources/tts/types/WebSocketDoneResponse.js +17 -7
- package/serialization/resources/tts/types/WebSocketErrorResponse.js +17 -7
- package/serialization/resources/tts/types/WebSocketFlushDoneResponse.d.ts +15 -0
- package/serialization/resources/tts/types/WebSocketFlushDoneResponse.js +48 -0
- package/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.d.ts +14 -0
- package/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +47 -0
- package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +17 -7
- package/serialization/resources/tts/types/WebSocketRequest.js +17 -7
- package/serialization/resources/tts/types/WebSocketResponse.d.ts +9 -1
- package/serialization/resources/tts/types/WebSocketResponse.js +21 -7
- package/serialization/resources/tts/types/WebSocketStreamOptions.js +17 -7
- package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +17 -7
- package/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +5 -0
- package/serialization/resources/tts/types/WebSocketTtsOutput.js +22 -7
- package/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
- package/serialization/resources/tts/types/WebSocketTtsRequest.js +18 -7
- package/serialization/resources/tts/types/WordTimestamps.js +17 -7
- package/serialization/resources/tts/types/index.d.ts +4 -0
- package/serialization/resources/tts/types/index.js +4 -0
- package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +17 -7
- package/serialization/resources/voiceChanger/types/StreamingResponse.js +17 -7
- package/serialization/resources/voices/client/index.js +17 -7
- package/serialization/resources/voices/client/list.js +17 -7
- package/serialization/resources/voices/types/CloneMode.js +17 -7
- package/serialization/resources/voices/types/CreateVoiceRequest.d.ts +0 -2
- package/serialization/resources/voices/types/CreateVoiceRequest.js +17 -9
- package/serialization/resources/voices/types/EmbeddingResponse.js +17 -7
- package/serialization/resources/voices/types/EmbeddingSpecifier.js +17 -7
- package/serialization/resources/voices/types/Gender.js +17 -7
- package/serialization/resources/voices/types/IdSpecifier.js +17 -7
- package/serialization/resources/voices/types/LocalizeDialect.d.ts +3 -1
- package/serialization/resources/voices/types/LocalizeDialect.js +24 -8
- package/serialization/resources/voices/types/LocalizeEnglishDialect.js +17 -7
- package/serialization/resources/voices/types/LocalizePortugueseDialect.d.ts +10 -0
- package/serialization/resources/voices/types/LocalizePortugueseDialect.js +41 -0
- package/serialization/resources/voices/types/LocalizeSpanishDialect.d.ts +10 -0
- package/serialization/resources/voices/types/LocalizeSpanishDialect.js +41 -0
- package/serialization/resources/voices/types/LocalizeTargetLanguage.js +17 -7
- package/serialization/resources/voices/types/LocalizeVoiceRequest.js +17 -7
- package/serialization/resources/voices/types/MixVoiceSpecifier.js +17 -7
- package/serialization/resources/voices/types/MixVoicesRequest.js +17 -7
- package/serialization/resources/voices/types/UpdateVoiceRequest.js +17 -7
- package/serialization/resources/voices/types/Voice.d.ts +0 -2
- package/serialization/resources/voices/types/Voice.js +17 -9
- package/serialization/resources/voices/types/VoiceId.js +17 -7
- package/serialization/resources/voices/types/VoiceMetadata.js +17 -7
- package/serialization/resources/voices/types/Weight.js +17 -7
- package/serialization/resources/voices/types/index.d.ts +2 -0
- package/serialization/resources/voices/types/index.js +2 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/wrapper/WebPlayer.js +1 -1
- package/wrapper/Websocket.js +25 -15
- package/wrapper/source.js +1 -1
- package/wrapper/utils.d.ts +9 -9
- package/wrapper/utils.js +10 -10
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.requestWithRetries =
|
|
12
|
+
exports.requestWithRetries = requestWithRetries;
|
|
13
13
|
const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
14
14
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
15
15
|
const DEFAULT_MAX_RETRIES = 2;
|
|
@@ -19,11 +19,11 @@ function addJitter(delay) {
|
|
|
19
19
|
const jitterMultiplier = 1 + (Math.random() * 2 - 1) * JITTER_FACTOR;
|
|
20
20
|
return delay * jitterMultiplier;
|
|
21
21
|
}
|
|
22
|
-
function requestWithRetries(
|
|
23
|
-
return __awaiter(this,
|
|
22
|
+
function requestWithRetries(requestFn_1) {
|
|
23
|
+
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
24
24
|
let response = yield requestFn();
|
|
25
25
|
for (let i = 0; i < maxRetries; ++i) {
|
|
26
|
-
if ([408,
|
|
26
|
+
if ([408, 429].includes(response.status) || response.status >= 500) {
|
|
27
27
|
// Calculate base delay using exponential backoff (in milliseconds)
|
|
28
28
|
const baseDelay = Math.min(INITIAL_RETRY_DELAY * Math.pow(2, i), MAX_RETRY_DELAY);
|
|
29
29
|
// Add jitter to the delay
|
|
@@ -38,4 +38,3 @@ function requestWithRetries(requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
|
38
38
|
return response;
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
exports.requestWithRetries = requestWithRetries;
|
package/core/fetcher/signals.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getTimeoutSignal = getTimeoutSignal;
|
|
4
|
+
exports.anySignal = anySignal;
|
|
4
5
|
const TIMEOUT = "timeout";
|
|
5
6
|
function getTimeoutSignal(timeoutMs) {
|
|
6
7
|
const controller = new AbortController();
|
|
7
8
|
const abortId = setTimeout(() => controller.abort(TIMEOUT), timeoutMs);
|
|
8
9
|
return { signal: controller.signal, abortId };
|
|
9
10
|
}
|
|
10
|
-
exports.getTimeoutSignal = getTimeoutSignal;
|
|
11
11
|
/**
|
|
12
12
|
* Returns an abort signal that is getting aborted when
|
|
13
13
|
* at least one of the specified abort signals is aborted.
|
|
@@ -34,4 +34,3 @@ function anySignal(...args) {
|
|
|
34
34
|
}
|
|
35
35
|
return controller.signal;
|
|
36
36
|
}
|
|
37
|
-
exports.anySignal = anySignal;
|
|
@@ -76,21 +76,23 @@ class NodePre18StreamWrapper {
|
|
|
76
76
|
this.encoding = encoding;
|
|
77
77
|
}
|
|
78
78
|
text() {
|
|
79
|
-
var e_1, _a;
|
|
80
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
var _a, e_1, _b, _c;
|
|
81
81
|
const chunks = [];
|
|
82
82
|
const encoder = new TextEncoder();
|
|
83
83
|
this.readableStream.setEncoding((this.encoding || "utf-8"));
|
|
84
84
|
try {
|
|
85
|
-
for (var
|
|
86
|
-
|
|
85
|
+
for (var _d = true, _e = __asyncValues(this.readableStream), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
86
|
+
_c = _f.value;
|
|
87
|
+
_d = false;
|
|
88
|
+
const chunk = _c;
|
|
87
89
|
chunks.push(encoder.encode(chunk));
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
93
|
finally {
|
|
92
94
|
try {
|
|
93
|
-
if (
|
|
95
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
94
96
|
}
|
|
95
97
|
finally { if (e_1) throw e_1.error; }
|
|
96
98
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StreamWrapper } from "./chooseStreamWrapper";
|
|
2
|
-
|
|
2
|
+
type EventCallback = (data?: any) => void;
|
|
3
3
|
export declare class UndiciStreamWrapper<ReadFormat extends Uint8Array | Uint16Array | Uint32Array> implements StreamWrapper<UndiciStreamWrapper<ReadFormat> | WritableStream<ReadFormat>, ReadFormat> {
|
|
4
4
|
private readableStream;
|
|
5
5
|
private reader;
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,7 +42,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
42
|
});
|
|
33
43
|
};
|
|
34
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.chooseStreamWrapper =
|
|
45
|
+
exports.chooseStreamWrapper = chooseStreamWrapper;
|
|
36
46
|
const runtime_1 = require("../../runtime");
|
|
37
47
|
function chooseStreamWrapper(responseBody) {
|
|
38
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -47,4 +57,3 @@ function chooseStreamWrapper(responseBody) {
|
|
|
47
57
|
}
|
|
48
58
|
});
|
|
49
59
|
}
|
|
50
|
-
exports.chooseStreamWrapper = chooseStreamWrapper;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type MaybePromise<T> = Promise<T> | T;
|
|
2
2
|
interface FormDataRequest<Body> {
|
|
3
3
|
body: Body;
|
|
4
4
|
headers: Record<string, string>;
|
|
@@ -11,7 +11,7 @@ export interface CrossPlatformFormData {
|
|
|
11
11
|
getRequest(): MaybePromise<FormDataRequest<unknown>>;
|
|
12
12
|
}
|
|
13
13
|
export declare function newFormData(): Promise<CrossPlatformFormData>;
|
|
14
|
-
export
|
|
14
|
+
export type Node18FormDataFd = {
|
|
15
15
|
append(name: string, value: unknown, fileName?: string): void;
|
|
16
16
|
} | undefined;
|
|
17
17
|
/**
|
|
@@ -24,7 +24,7 @@ export declare class Node18FormData implements CrossPlatformFormData {
|
|
|
24
24
|
appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
|
|
25
25
|
getRequest(): Promise<FormDataRequest<unknown>>;
|
|
26
26
|
}
|
|
27
|
-
export
|
|
27
|
+
export type Node16FormDataFd = {
|
|
28
28
|
append(name: string, value: unknown, options?: string | {
|
|
29
29
|
header?: string | Headers;
|
|
30
30
|
knownLength?: number;
|
|
@@ -44,7 +44,7 @@ export declare class Node16FormData implements CrossPlatformFormData {
|
|
|
44
44
|
appendFile(key: string, value: unknown, fileName?: string): Promise<void>;
|
|
45
45
|
getRequest(): FormDataRequest<Node16FormDataFd>;
|
|
46
46
|
}
|
|
47
|
-
export
|
|
47
|
+
export type WebFormDataFd = {
|
|
48
48
|
append(name: string, value: string | Blob, fileName?: string): void;
|
|
49
49
|
} | undefined;
|
|
50
50
|
/**
|
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
36
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
37
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -32,7 +42,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
32
42
|
});
|
|
33
43
|
};
|
|
34
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.WebFormData = exports.Node16FormData = exports.Node18FormData =
|
|
45
|
+
exports.WebFormData = exports.Node16FormData = exports.Node18FormData = void 0;
|
|
46
|
+
exports.newFormData = newFormData;
|
|
36
47
|
const runtime_1 = require("../runtime");
|
|
37
48
|
function isNamedValue(value) {
|
|
38
49
|
return typeof value === "object" && value != null && "name" in value;
|
|
@@ -53,7 +64,6 @@ function newFormData() {
|
|
|
53
64
|
return formdata;
|
|
54
65
|
});
|
|
55
66
|
}
|
|
56
|
-
exports.newFormData = newFormData;
|
|
57
67
|
/**
|
|
58
68
|
* Form Data Implementation for Node.js 18+
|
|
59
69
|
*/
|
|
@@ -68,8 +78,8 @@ class Node18FormData {
|
|
|
68
78
|
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
69
79
|
}
|
|
70
80
|
appendFile(key, value, fileName) {
|
|
71
|
-
var _a, _b;
|
|
72
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
var _a, _b;
|
|
73
83
|
if (fileName == null && isNamedValue(value)) {
|
|
74
84
|
fileName = value.name;
|
|
75
85
|
}
|
|
@@ -114,8 +124,8 @@ class Node16FormData {
|
|
|
114
124
|
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
115
125
|
}
|
|
116
126
|
appendFile(key, value, fileName) {
|
|
117
|
-
var _a, _b;
|
|
118
127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
var _a, _b;
|
|
119
129
|
if (fileName == null && isNamedValue(value)) {
|
|
120
130
|
fileName = value.name;
|
|
121
131
|
}
|
|
@@ -156,8 +166,8 @@ class WebFormData {
|
|
|
156
166
|
(_a = this.fd) === null || _a === void 0 ? void 0 : _a.append(key, value);
|
|
157
167
|
}
|
|
158
168
|
appendFile(key, value, fileName) {
|
|
159
|
-
var _a;
|
|
160
169
|
return __awaiter(this, void 0, void 0, function* () {
|
|
170
|
+
var _a;
|
|
161
171
|
if (fileName == null && isNamedValue(value)) {
|
|
162
172
|
fileName = value.name;
|
|
163
173
|
}
|
package/core/index.js
CHANGED
|
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
18
18
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
19
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
20
|
};
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
39
|
exports.serialization = void 0;
|
|
30
40
|
__exportStar(require("./fetcher"), exports);
|
package/core/json.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize a value to JSON
|
|
3
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
4
|
+
* @param replacer A function that transforms the results.
|
|
5
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
6
|
+
* @returns JSON string
|
|
7
|
+
*/
|
|
8
|
+
export declare const toJson: (value: unknown, replacer?: (this: unknown, key: string, value: unknown) => unknown, space?: string | number) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Parse JSON string to object, array, or other type
|
|
11
|
+
* @param text A valid JSON string.
|
|
12
|
+
* @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
13
|
+
* @returns Parsed object, array, or other type
|
|
14
|
+
*/
|
|
15
|
+
export declare function fromJson<T = unknown>(text: string, reviver?: (this: unknown, key: string, value: unknown) => unknown): T;
|
package/core/json.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toJson = void 0;
|
|
4
|
+
exports.fromJson = fromJson;
|
|
5
|
+
/**
|
|
6
|
+
* Serialize a value to JSON
|
|
7
|
+
* @param value A JavaScript value, usually an object or array, to be converted.
|
|
8
|
+
* @param replacer A function that transforms the results.
|
|
9
|
+
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
|
10
|
+
* @returns JSON string
|
|
11
|
+
*/
|
|
12
|
+
const toJson = (value, replacer, space) => {
|
|
13
|
+
return JSON.stringify(value, replacer, space);
|
|
14
|
+
};
|
|
15
|
+
exports.toJson = toJson;
|
|
16
|
+
/**
|
|
17
|
+
* Parse JSON string to object, array, or other type
|
|
18
|
+
* @param text A valid JSON string.
|
|
19
|
+
* @param reviver A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is.
|
|
20
|
+
* @returns Parsed object, array, or other type
|
|
21
|
+
*/
|
|
22
|
+
function fromJson(text, reviver) {
|
|
23
|
+
return JSON.parse(text, reviver);
|
|
24
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export declare const RUNTIME: Runtime;
|
|
5
5
|
export interface Runtime {
|
|
6
|
-
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd";
|
|
6
|
+
type: "browser" | "web-worker" | "deno" | "bun" | "node" | "react-native" | "unknown" | "workerd" | "edge-runtime";
|
|
7
7
|
version?: string;
|
|
8
8
|
parsedVersion?: number;
|
|
9
9
|
}
|
package/core/runtime/runtime.js
CHANGED
|
@@ -1,80 +1,85 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a, _b, _c, _d, _e;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.RUNTIME = void 0;
|
|
5
|
-
/**
|
|
6
|
-
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
7
|
-
*/
|
|
8
|
-
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
9
|
-
/**
|
|
10
|
-
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
11
|
-
*/
|
|
12
|
-
const isWebWorker = typeof self === "object" &&
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
15
|
-
(((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
|
|
16
|
-
((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
|
|
17
|
-
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
|
|
18
|
-
/**
|
|
19
|
-
* A constant that indicates whether the environment the code is running is Deno.
|
|
20
|
-
*/
|
|
21
|
-
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
22
|
-
/**
|
|
23
|
-
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
24
|
-
*/
|
|
25
|
-
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
26
|
-
/**
|
|
27
|
-
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
28
|
-
*/
|
|
29
|
-
const isNode = typeof process !== "undefined" &&
|
|
30
|
-
Boolean(process.version) &&
|
|
31
|
-
Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
|
|
32
|
-
// Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
33
|
-
!isDeno &&
|
|
34
|
-
!isBun;
|
|
35
|
-
/**
|
|
36
|
-
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
37
|
-
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
38
|
-
*/
|
|
39
|
-
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
40
|
-
/**
|
|
41
|
-
* A constant that indicates whether the environment the code is running is Cloudflare.
|
|
42
|
-
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
|
|
43
|
-
*/
|
|
44
|
-
const isCloudflare = typeof globalThis !== "undefined" && ((_e = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _e === void 0 ? void 0 : _e.userAgent) === "Cloudflare-Workers";
|
|
45
4
|
/**
|
|
46
5
|
* A constant that indicates which environment and version the SDK is running in.
|
|
47
6
|
*/
|
|
48
7
|
exports.RUNTIME = evaluateRuntime();
|
|
49
8
|
function evaluateRuntime() {
|
|
9
|
+
var _a, _b, _c, _d, _e;
|
|
10
|
+
/**
|
|
11
|
+
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
12
|
+
*/
|
|
13
|
+
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
50
14
|
if (isBrowser) {
|
|
51
15
|
return {
|
|
52
16
|
type: "browser",
|
|
53
17
|
version: window.navigator.userAgent,
|
|
54
18
|
};
|
|
55
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* A constant that indicates whether the environment the code is running is Cloudflare.
|
|
22
|
+
* https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
|
|
23
|
+
*/
|
|
24
|
+
const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === "Cloudflare-Workers";
|
|
56
25
|
if (isCloudflare) {
|
|
57
26
|
return {
|
|
58
27
|
type: "workerd",
|
|
59
28
|
};
|
|
60
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A constant that indicates whether the environment the code is running is Edge Runtime.
|
|
32
|
+
* https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime
|
|
33
|
+
*/
|
|
34
|
+
const isEdgeRuntime = typeof EdgeRuntime === "string";
|
|
35
|
+
if (isEdgeRuntime) {
|
|
36
|
+
return {
|
|
37
|
+
type: "edge-runtime",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A constant that indicates whether the environment the code is running is a Web Worker.
|
|
42
|
+
*/
|
|
43
|
+
const isWebWorker = typeof self === "object" &&
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
|
|
46
|
+
(((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" ||
|
|
47
|
+
((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "ServiceWorkerGlobalScope" ||
|
|
48
|
+
((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) === "SharedWorkerGlobalScope");
|
|
61
49
|
if (isWebWorker) {
|
|
62
50
|
return {
|
|
63
51
|
type: "web-worker",
|
|
64
52
|
};
|
|
65
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* A constant that indicates whether the environment the code is running is Deno.
|
|
56
|
+
* FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
|
|
57
|
+
*/
|
|
58
|
+
const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
|
|
66
59
|
if (isDeno) {
|
|
67
60
|
return {
|
|
68
61
|
type: "deno",
|
|
69
62
|
version: Deno.version.deno,
|
|
70
63
|
};
|
|
71
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* A constant that indicates whether the environment the code is running is Bun.sh.
|
|
67
|
+
*/
|
|
68
|
+
const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
|
|
72
69
|
if (isBun) {
|
|
73
70
|
return {
|
|
74
71
|
type: "bun",
|
|
75
72
|
version: Bun.version,
|
|
76
73
|
};
|
|
77
74
|
}
|
|
75
|
+
/**
|
|
76
|
+
* A constant that indicates whether the environment the code is running is Node.JS.
|
|
77
|
+
*/
|
|
78
|
+
const isNode = typeof process !== "undefined" &&
|
|
79
|
+
"version" in process &&
|
|
80
|
+
!!process.version &&
|
|
81
|
+
"versions" in process &&
|
|
82
|
+
!!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
|
|
78
83
|
if (isNode) {
|
|
79
84
|
return {
|
|
80
85
|
type: "node",
|
|
@@ -82,6 +87,11 @@ function evaluateRuntime() {
|
|
|
82
87
|
parsedVersion: Number(process.versions.node.split(".")[0]),
|
|
83
88
|
};
|
|
84
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* A constant that indicates whether the environment the code is running is in React-Native.
|
|
92
|
+
* https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
|
|
93
|
+
*/
|
|
94
|
+
const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
|
|
85
95
|
if (isReactNative) {
|
|
86
96
|
return {
|
|
87
97
|
type: "react-native",
|
package/core/schemas/Schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SchemaUtils } from "./builders";
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
|
|
3
|
+
export type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
|
|
4
|
+
export type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
|
|
5
5
|
export interface BaseSchema<Raw, Parsed> {
|
|
6
6
|
parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid<Parsed>;
|
|
7
7
|
json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid<Raw>;
|
|
@@ -24,10 +24,12 @@ export declare const SchemaType: {
|
|
|
24
24
|
readonly SET: "set";
|
|
25
25
|
readonly UNION: "union";
|
|
26
26
|
readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion";
|
|
27
|
+
readonly NULLABLE: "nullable";
|
|
27
28
|
readonly OPTIONAL: "optional";
|
|
29
|
+
readonly OPTIONAL_NULLABLE: "optionalNullable";
|
|
28
30
|
};
|
|
29
|
-
export
|
|
30
|
-
export
|
|
31
|
+
export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
|
|
32
|
+
export type MaybeValid<T> = Valid<T> | Invalid;
|
|
31
33
|
export interface Valid<T> {
|
|
32
34
|
ok: true;
|
|
33
35
|
value: T;
|
package/core/schemas/Schema.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Schema } from "../../Schema";
|
|
2
|
-
export declare function bigint(): Schema<
|
|
2
|
+
export declare function bigint(): Schema<bigint | number, bigint>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bigint =
|
|
3
|
+
exports.bigint = bigint;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
6
|
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
@@ -8,30 +8,30 @@ const schema_utils_1 = require("../schema-utils");
|
|
|
8
8
|
function bigint() {
|
|
9
9
|
const baseSchema = {
|
|
10
10
|
parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
|
|
11
|
-
if (typeof raw
|
|
11
|
+
if (typeof raw === "bigint") {
|
|
12
12
|
return {
|
|
13
|
-
ok:
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
path: breadcrumbsPrefix,
|
|
17
|
-
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
|
|
18
|
-
},
|
|
19
|
-
],
|
|
13
|
+
ok: true,
|
|
14
|
+
value: raw,
|
|
20
15
|
};
|
|
21
16
|
}
|
|
22
|
-
|
|
23
|
-
ok: true,
|
|
24
|
-
value: BigInt(raw),
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
|
|
28
|
-
if (typeof bigint === "bigint") {
|
|
17
|
+
if (typeof raw === "number") {
|
|
29
18
|
return {
|
|
30
19
|
ok: true,
|
|
31
|
-
value:
|
|
20
|
+
value: BigInt(raw),
|
|
32
21
|
};
|
|
33
22
|
}
|
|
34
|
-
|
|
23
|
+
return {
|
|
24
|
+
ok: false,
|
|
25
|
+
errors: [
|
|
26
|
+
{
|
|
27
|
+
path: breadcrumbsPrefix,
|
|
28
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "bigint | number"),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
|
|
34
|
+
if (typeof bigint !== "bigint") {
|
|
35
35
|
return {
|
|
36
36
|
ok: false,
|
|
37
37
|
errors: [
|
|
@@ -42,9 +42,12 @@ function bigint() {
|
|
|
42
42
|
],
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
return {
|
|
46
|
+
ok: true,
|
|
47
|
+
value: bigint,
|
|
48
|
+
};
|
|
45
49
|
},
|
|
46
50
|
getType: () => Schema_1.SchemaType.BIGINT,
|
|
47
51
|
};
|
|
48
52
|
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
49
53
|
}
|
|
50
|
-
exports.bigint = bigint;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.date =
|
|
3
|
+
exports.date = date;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
6
|
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
@@ -60,4 +60,3 @@ function date() {
|
|
|
60
60
|
};
|
|
61
61
|
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
62
62
|
}
|
|
63
|
-
exports.date = date;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enum_ =
|
|
3
|
+
exports.enum_ = enum_;
|
|
4
4
|
const Schema_1 = require("../../Schema");
|
|
5
5
|
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
6
|
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
@@ -36,4 +36,3 @@ function enum_(values) {
|
|
|
36
36
|
});
|
|
37
37
|
return schemaCreator();
|
|
38
38
|
}
|
|
39
|
-
exports.enum_ = enum_;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BaseSchema, Schema } from "../../Schema";
|
|
2
|
-
export
|
|
2
|
+
export type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
|
|
3
3
|
export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
|
|
4
4
|
export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
|
|
5
5
|
export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
|