@cartesia/cartesia-js 2.0.2 → 2.0.4-alpha0
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 +3 -0
- package/Client.js +18 -9
- package/README.md +1 -5
- package/api/index.js +17 -1
- package/api/resources/apiStatus/client/Client.js +33 -6
- package/api/resources/apiStatus/client/index.js +2 -1
- package/api/resources/apiStatus/index.js +18 -2
- package/api/resources/apiStatus/types/ApiInfo.js +2 -1
- package/api/resources/apiStatus/types/index.js +17 -1
- package/api/resources/datasets/client/Client.d.ts +70 -0
- package/api/resources/datasets/client/Client.js +261 -0
- package/api/resources/datasets/client/index.d.ts +1 -0
- package/api/resources/datasets/client/index.js +17 -0
- package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
- package/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
- package/api/resources/datasets/client/requests/index.d.ts +1 -0
- package/api/resources/datasets/client/requests/index.js +2 -0
- package/api/resources/datasets/index.d.ts +2 -0
- package/api/resources/datasets/index.js +18 -0
- package/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
- package/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
- package/api/resources/datasets/types/Dataset.d.ts +8 -0
- package/api/resources/datasets/types/Dataset.js +5 -0
- package/api/resources/datasets/types/DatasetFile.d.ts +8 -0
- package/api/resources/datasets/types/DatasetFile.js +5 -0
- package/api/resources/datasets/types/FilePurpose.d.ts +7 -0
- package/api/resources/datasets/types/FilePurpose.js +9 -0
- package/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
- package/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
- package/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
- package/api/resources/datasets/types/PaginatedDatasets.js +5 -0
- package/api/resources/datasets/types/index.d.ts +6 -0
- package/api/resources/datasets/types/index.js +22 -0
- package/api/resources/embedding/index.js +17 -1
- package/api/resources/embedding/types/Embedding.js +2 -1
- package/api/resources/embedding/types/index.js +17 -1
- package/api/resources/index.d.ts +3 -0
- package/api/resources/index.js +44 -12
- package/api/resources/tts/client/Client.js +40 -10
- package/api/resources/tts/client/index.js +2 -1
- package/api/resources/tts/index.js +18 -2
- package/api/resources/tts/types/CancelContextRequest.js +2 -1
- package/api/resources/tts/types/ContextId.js +2 -1
- package/api/resources/tts/types/Controls.js +2 -1
- package/api/resources/tts/types/Emotion.js +4 -1
- package/api/resources/tts/types/GenerationRequest.js +2 -1
- package/api/resources/tts/types/Mp3OutputFormat.js +2 -1
- package/api/resources/tts/types/NaturalSpecifier.js +4 -1
- package/api/resources/tts/types/NumericalSpecifier.js +2 -1
- package/api/resources/tts/types/OutputFormat.js +2 -1
- package/api/resources/tts/types/RawEncoding.js +4 -1
- package/api/resources/tts/types/RawOutputFormat.js +2 -1
- package/api/resources/tts/types/Speed.js +2 -1
- package/api/resources/tts/types/SupportedLanguage.js +4 -1
- package/api/resources/tts/types/TtsRequest.js +2 -1
- package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +2 -1
- package/api/resources/tts/types/TtsRequestIdSpecifier.js +2 -1
- package/api/resources/tts/types/TtsRequestVoiceSpecifier.js +2 -1
- package/api/resources/tts/types/WavOutputFormat.js +2 -1
- package/api/resources/tts/types/WebSocketBaseResponse.js +2 -1
- package/api/resources/tts/types/WebSocketChunkResponse.js +2 -1
- package/api/resources/tts/types/WebSocketDoneResponse.js +2 -1
- package/api/resources/tts/types/WebSocketErrorResponse.js +2 -1
- package/api/resources/tts/types/WebSocketRawOutputFormat.js +2 -1
- package/api/resources/tts/types/WebSocketRequest.js +2 -1
- package/api/resources/tts/types/WebSocketResponse.js +2 -1
- package/api/resources/tts/types/WebSocketStreamOptions.js +2 -1
- package/api/resources/tts/types/WebSocketTimestampsResponse.js +2 -1
- package/api/resources/tts/types/WebSocketTtsOutput.js +2 -1
- package/api/resources/tts/types/WebSocketTtsRequest.js +2 -1
- package/api/resources/tts/types/WordTimestamps.js +2 -1
- package/api/resources/tts/types/index.js +46 -30
- package/api/resources/voiceChanger/client/Client.js +40 -10
- package/api/resources/voiceChanger/client/index.js +17 -1
- package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +2 -1
- package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +2 -1
- package/api/resources/voiceChanger/client/requests/index.js +2 -1
- package/api/resources/voiceChanger/index.js +18 -2
- package/api/resources/voiceChanger/types/OutputFormatContainer.js +4 -1
- package/api/resources/voiceChanger/types/StreamingResponse.js +2 -1
- package/api/resources/voiceChanger/types/index.js +18 -2
- package/api/resources/voices/client/Client.js +52 -22
- package/api/resources/voices/client/index.js +17 -1
- package/api/resources/voices/client/requests/CloneVoiceRequest.js +2 -1
- package/api/resources/voices/client/requests/index.js +2 -1
- package/api/resources/voices/index.js +18 -2
- package/api/resources/voices/types/BaseVoiceId.js +2 -1
- package/api/resources/voices/types/CloneMode.js +4 -1
- package/api/resources/voices/types/CreateVoiceRequest.js +2 -1
- package/api/resources/voices/types/EmbeddingResponse.js +2 -1
- package/api/resources/voices/types/EmbeddingSpecifier.js +2 -1
- package/api/resources/voices/types/Gender.js +4 -1
- package/api/resources/voices/types/IdSpecifier.js +2 -1
- package/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
- package/api/resources/voices/types/LocalizeDialect.js +2 -7
- package/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
- package/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
- package/api/resources/voices/types/LocalizeTargetLanguage.js +4 -1
- package/api/resources/voices/types/LocalizeVoiceRequest.js +2 -1
- package/api/resources/voices/types/MixVoiceSpecifier.js +2 -1
- package/api/resources/voices/types/MixVoicesRequest.js +2 -1
- package/api/resources/voices/types/UpdateVoiceRequest.js +2 -1
- package/api/resources/voices/types/Voice.js +2 -1
- package/api/resources/voices/types/VoiceId.js +2 -1
- package/api/resources/voices/types/VoiceMetadata.js +2 -1
- package/api/resources/voices/types/Weight.js +2 -1
- package/api/resources/voices/types/index.d.ts +1 -0
- package/api/resources/voices/types/index.js +34 -17
- package/core/fetcher/APIResponse.js +2 -1
- package/core/fetcher/Fetcher.js +18 -14
- package/core/fetcher/Supplier.js +4 -1
- package/core/fetcher/createRequestUrl.js +10 -3
- package/core/fetcher/getFetchFn.js +33 -6
- package/core/fetcher/getHeader.js +5 -1
- package/core/fetcher/getRequestBody.js +5 -1
- package/core/fetcher/getResponseBody.js +7 -3
- package/core/fetcher/index.js +9 -3
- package/core/fetcher/makeRequest.js +8 -4
- package/core/fetcher/requestWithRetries.js +5 -1
- package/core/fetcher/signals.js +7 -2
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +5 -1
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +34 -7
- package/core/form-data-utils/FormDataWrapper.js +41 -11
- package/core/form-data-utils/index.js +17 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +34 -5
- package/core/runtime/index.js +5 -1
- package/core/runtime/runtime.js +4 -1
- package/core/schemas/Schema.js +4 -1
- package/core/schemas/builders/bigint/bigint.js +13 -9
- package/core/schemas/builders/bigint/index.js +5 -1
- package/core/schemas/builders/date/date.js +14 -10
- package/core/schemas/builders/date/index.js +5 -1
- package/core/schemas/builders/enum/enum.js +11 -7
- package/core/schemas/builders/enum/index.js +5 -1
- package/core/schemas/builders/index.js +30 -14
- package/core/schemas/builders/lazy/index.js +7 -2
- package/core/schemas/builders/lazy/lazy.js +11 -5
- package/core/schemas/builders/lazy/lazyObject.js +11 -7
- package/core/schemas/builders/list/index.js +5 -1
- package/core/schemas/builders/list/list.js +12 -8
- package/core/schemas/builders/literals/booleanLiteral.js +10 -6
- package/core/schemas/builders/literals/index.js +7 -2
- package/core/schemas/builders/literals/stringLiteral.js +10 -6
- package/core/schemas/builders/object/index.js +11 -3
- package/core/schemas/builders/object/object.js +38 -33
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -3
- package/core/schemas/builders/object/property.js +7 -2
- package/core/schemas/builders/object/types.js +2 -1
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +15 -10
- package/core/schemas/builders/object-like/index.js +6 -1
- package/core/schemas/builders/object-like/types.js +2 -1
- package/core/schemas/builders/primitives/any.js +6 -3
- package/core/schemas/builders/primitives/boolean.js +8 -5
- package/core/schemas/builders/primitives/index.js +13 -5
- package/core/schemas/builders/primitives/number.js +8 -5
- package/core/schemas/builders/primitives/string.js +8 -5
- package/core/schemas/builders/primitives/unknown.js +6 -3
- package/core/schemas/builders/record/index.js +5 -1
- package/core/schemas/builders/record/record.js +18 -14
- package/core/schemas/builders/record/types.js +2 -1
- package/core/schemas/builders/schema-utils/JsonError.js +7 -3
- package/core/schemas/builders/schema-utils/ParseError.js +7 -3
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +15 -9
- package/core/schemas/builders/schema-utils/index.js +11 -3
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +5 -1
- package/core/schemas/builders/set/index.js +5 -1
- package/core/schemas/builders/set/set.js +14 -10
- package/core/schemas/builders/undiscriminated-union/index.js +5 -1
- package/core/schemas/builders/undiscriminated-union/types.js +2 -1
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +10 -6
- package/core/schemas/builders/union/discriminant.js +5 -1
- package/core/schemas/builders/union/index.js +7 -2
- package/core/schemas/builders/union/types.js +2 -1
- package/core/schemas/builders/union/union.js +18 -14
- package/core/schemas/index.js +17 -1
- package/core/schemas/utils/MaybePromise.js +2 -1
- package/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -1
- package/core/schemas/utils/createIdentitySchemaCreator.js +8 -4
- package/core/schemas/utils/entries.js +5 -1
- package/core/schemas/utils/filterObject.js +5 -1
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +5 -1
- package/core/schemas/utils/isPlainObject.js +5 -1
- package/core/schemas/utils/keys.js +5 -1
- package/core/schemas/utils/maybeSkipValidation.js +5 -1
- package/core/schemas/utils/partition.js +5 -1
- package/core/streaming-fetcher/Stream.js +9 -4
- package/core/streaming-fetcher/index.js +5 -1
- package/core/websocket/events.js +9 -3
- package/core/websocket/index.js +17 -1
- package/core/websocket/ws.js +33 -6
- package/dist/Client.d.ts +3 -0
- package/dist/Client.js +18 -9
- package/dist/api/index.js +17 -1
- package/dist/api/resources/apiStatus/client/Client.js +33 -6
- package/dist/api/resources/apiStatus/client/index.js +2 -1
- package/dist/api/resources/apiStatus/index.js +18 -2
- package/dist/api/resources/apiStatus/types/ApiInfo.js +2 -1
- package/dist/api/resources/apiStatus/types/index.js +17 -1
- package/dist/api/resources/datasets/client/Client.d.ts +70 -0
- package/dist/api/resources/datasets/client/Client.js +261 -0
- package/dist/api/resources/datasets/client/index.d.ts +1 -0
- package/dist/api/resources/datasets/client/index.js +17 -0
- package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
- package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
- package/dist/api/resources/datasets/client/requests/index.d.ts +1 -0
- package/dist/api/resources/datasets/client/requests/index.js +2 -0
- package/dist/api/resources/datasets/index.d.ts +2 -0
- package/dist/api/resources/datasets/index.js +18 -0
- package/dist/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
- package/dist/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
- package/dist/api/resources/datasets/types/Dataset.d.ts +8 -0
- package/dist/api/resources/datasets/types/Dataset.js +5 -0
- package/dist/api/resources/datasets/types/DatasetFile.d.ts +8 -0
- package/dist/api/resources/datasets/types/DatasetFile.js +5 -0
- package/dist/api/resources/datasets/types/FilePurpose.d.ts +7 -0
- package/dist/api/resources/datasets/types/FilePurpose.js +9 -0
- package/dist/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
- package/dist/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
- package/dist/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
- package/dist/api/resources/datasets/types/PaginatedDatasets.js +5 -0
- package/dist/api/resources/datasets/types/index.d.ts +6 -0
- package/dist/api/resources/datasets/types/index.js +22 -0
- package/dist/api/resources/embedding/index.js +17 -1
- package/dist/api/resources/embedding/types/Embedding.js +2 -1
- package/dist/api/resources/embedding/types/index.js +17 -1
- package/dist/api/resources/index.d.ts +3 -0
- package/dist/api/resources/index.js +44 -12
- package/dist/api/resources/tts/client/Client.js +40 -10
- package/dist/api/resources/tts/client/index.js +2 -1
- package/dist/api/resources/tts/index.js +18 -2
- package/dist/api/resources/tts/types/CancelContextRequest.js +2 -1
- package/dist/api/resources/tts/types/ContextId.js +2 -1
- package/dist/api/resources/tts/types/Controls.js +2 -1
- package/dist/api/resources/tts/types/Emotion.js +4 -1
- package/dist/api/resources/tts/types/GenerationRequest.js +2 -1
- package/dist/api/resources/tts/types/Mp3OutputFormat.js +2 -1
- package/dist/api/resources/tts/types/NaturalSpecifier.js +4 -1
- package/dist/api/resources/tts/types/NumericalSpecifier.js +2 -1
- package/dist/api/resources/tts/types/OutputFormat.js +2 -1
- package/dist/api/resources/tts/types/RawEncoding.js +4 -1
- package/dist/api/resources/tts/types/RawOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/Speed.js +2 -1
- package/dist/api/resources/tts/types/SupportedLanguage.js +4 -1
- package/dist/api/resources/tts/types/TtsRequest.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestIdSpecifier.js +2 -1
- package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.js +2 -1
- package/dist/api/resources/tts/types/WavOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/WebSocketBaseResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketChunkResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketDoneResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketErrorResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketRawOutputFormat.js +2 -1
- package/dist/api/resources/tts/types/WebSocketRequest.js +2 -1
- package/dist/api/resources/tts/types/WebSocketResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketStreamOptions.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTimestampsResponse.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTtsOutput.js +2 -1
- package/dist/api/resources/tts/types/WebSocketTtsRequest.js +2 -1
- package/dist/api/resources/tts/types/WordTimestamps.js +2 -1
- package/dist/api/resources/tts/types/index.js +46 -30
- package/dist/api/resources/voiceChanger/client/Client.js +40 -10
- package/dist/api/resources/voiceChanger/client/index.js +17 -1
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +2 -1
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +2 -1
- package/dist/api/resources/voiceChanger/client/requests/index.js +2 -1
- package/dist/api/resources/voiceChanger/index.js +18 -2
- package/dist/api/resources/voiceChanger/types/OutputFormatContainer.js +4 -1
- package/dist/api/resources/voiceChanger/types/StreamingResponse.js +2 -1
- package/dist/api/resources/voiceChanger/types/index.js +18 -2
- package/dist/api/resources/voices/client/Client.js +52 -22
- package/dist/api/resources/voices/client/index.js +17 -1
- package/dist/api/resources/voices/client/requests/CloneVoiceRequest.js +2 -1
- package/dist/api/resources/voices/client/requests/index.js +2 -1
- package/dist/api/resources/voices/index.js +18 -2
- package/dist/api/resources/voices/types/BaseVoiceId.js +2 -1
- package/dist/api/resources/voices/types/CloneMode.js +4 -1
- package/dist/api/resources/voices/types/CreateVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/EmbeddingResponse.js +2 -1
- package/dist/api/resources/voices/types/EmbeddingSpecifier.js +2 -1
- package/dist/api/resources/voices/types/Gender.js +4 -1
- package/dist/api/resources/voices/types/IdSpecifier.js +2 -1
- package/dist/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
- package/dist/api/resources/voices/types/LocalizeDialect.js +2 -7
- package/dist/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
- package/dist/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
- package/dist/api/resources/voices/types/LocalizeTargetLanguage.js +4 -1
- package/dist/api/resources/voices/types/LocalizeVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/MixVoiceSpecifier.js +2 -1
- package/dist/api/resources/voices/types/MixVoicesRequest.js +2 -1
- package/dist/api/resources/voices/types/UpdateVoiceRequest.js +2 -1
- package/dist/api/resources/voices/types/Voice.js +2 -1
- package/dist/api/resources/voices/types/VoiceId.js +2 -1
- package/dist/api/resources/voices/types/VoiceMetadata.js +2 -1
- package/dist/api/resources/voices/types/Weight.js +2 -1
- package/dist/api/resources/voices/types/index.d.ts +1 -0
- package/dist/api/resources/voices/types/index.js +34 -17
- package/dist/core/fetcher/APIResponse.js +2 -1
- package/dist/core/fetcher/Fetcher.js +18 -14
- package/dist/core/fetcher/Supplier.js +4 -1
- package/dist/core/fetcher/createRequestUrl.js +10 -3
- package/dist/core/fetcher/getFetchFn.js +33 -6
- package/dist/core/fetcher/getHeader.js +5 -1
- package/dist/core/fetcher/getRequestBody.js +5 -1
- package/dist/core/fetcher/getResponseBody.js +7 -3
- package/dist/core/fetcher/index.js +9 -3
- package/dist/core/fetcher/makeRequest.js +8 -4
- package/dist/core/fetcher/requestWithRetries.js +5 -1
- package/dist/core/fetcher/signals.js +7 -2
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +5 -1
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +34 -7
- package/dist/core/form-data-utils/FormDataWrapper.js +41 -11
- package/dist/core/form-data-utils/index.js +17 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +34 -5
- package/dist/core/runtime/index.js +5 -1
- package/dist/core/runtime/runtime.js +4 -1
- package/dist/core/schemas/Schema.js +4 -1
- package/dist/core/schemas/builders/bigint/bigint.js +13 -9
- package/dist/core/schemas/builders/bigint/index.js +5 -1
- package/dist/core/schemas/builders/date/date.js +14 -10
- package/dist/core/schemas/builders/date/index.js +5 -1
- package/dist/core/schemas/builders/enum/enum.js +11 -7
- package/dist/core/schemas/builders/enum/index.js +5 -1
- package/dist/core/schemas/builders/index.js +30 -14
- package/dist/core/schemas/builders/lazy/index.js +7 -2
- package/dist/core/schemas/builders/lazy/lazy.js +11 -5
- package/dist/core/schemas/builders/lazy/lazyObject.js +11 -7
- package/dist/core/schemas/builders/list/index.js +5 -1
- package/dist/core/schemas/builders/list/list.js +12 -8
- package/dist/core/schemas/builders/literals/booleanLiteral.js +10 -6
- package/dist/core/schemas/builders/literals/index.js +7 -2
- package/dist/core/schemas/builders/literals/stringLiteral.js +10 -6
- package/dist/core/schemas/builders/object/index.js +11 -3
- package/dist/core/schemas/builders/object/object.js +38 -33
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -3
- package/dist/core/schemas/builders/object/property.js +7 -2
- package/dist/core/schemas/builders/object/types.js +2 -1
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +15 -10
- package/dist/core/schemas/builders/object-like/index.js +6 -1
- package/dist/core/schemas/builders/object-like/types.js +2 -1
- package/dist/core/schemas/builders/primitives/any.js +6 -3
- package/dist/core/schemas/builders/primitives/boolean.js +8 -5
- package/dist/core/schemas/builders/primitives/index.js +13 -5
- package/dist/core/schemas/builders/primitives/number.js +8 -5
- package/dist/core/schemas/builders/primitives/string.js +8 -5
- package/dist/core/schemas/builders/primitives/unknown.js +6 -3
- package/dist/core/schemas/builders/record/index.js +5 -1
- package/dist/core/schemas/builders/record/record.js +18 -14
- package/dist/core/schemas/builders/record/types.js +2 -1
- package/dist/core/schemas/builders/schema-utils/JsonError.js +7 -3
- package/dist/core/schemas/builders/schema-utils/ParseError.js +7 -3
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +15 -9
- package/dist/core/schemas/builders/schema-utils/index.js +11 -3
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +5 -1
- package/dist/core/schemas/builders/set/index.js +5 -1
- package/dist/core/schemas/builders/set/set.js +14 -10
- package/dist/core/schemas/builders/undiscriminated-union/index.js +5 -1
- package/dist/core/schemas/builders/undiscriminated-union/types.js +2 -1
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +10 -6
- package/dist/core/schemas/builders/union/discriminant.js +5 -1
- package/dist/core/schemas/builders/union/index.js +7 -2
- package/dist/core/schemas/builders/union/types.js +2 -1
- package/dist/core/schemas/builders/union/union.js +18 -14
- package/dist/core/schemas/index.js +17 -1
- package/dist/core/schemas/utils/MaybePromise.js +2 -1
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -1
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +8 -4
- package/dist/core/schemas/utils/entries.js +5 -1
- package/dist/core/schemas/utils/filterObject.js +5 -1
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +5 -1
- package/dist/core/schemas/utils/isPlainObject.js +5 -1
- package/dist/core/schemas/utils/keys.js +5 -1
- package/dist/core/schemas/utils/maybeSkipValidation.js +5 -1
- package/dist/core/schemas/utils/partition.js +5 -1
- package/dist/core/streaming-fetcher/Stream.js +9 -4
- package/dist/core/streaming-fetcher/index.js +5 -1
- package/dist/core/websocket/events.js +9 -3
- package/dist/core/websocket/index.js +17 -1
- package/dist/core/websocket/ws.js +33 -6
- package/dist/environments.js +4 -1
- package/dist/errors/CartesiaError.js +5 -1
- package/dist/errors/CartesiaTimeoutError.js +5 -1
- package/dist/errors/index.js +7 -2
- package/dist/index.js +34 -4
- package/dist/serialization/index.js +17 -1
- package/dist/serialization/resources/apiStatus/index.js +17 -1
- package/dist/serialization/resources/apiStatus/types/ApiInfo.js +28 -2
- package/dist/serialization/resources/apiStatus/types/index.js +17 -1
- package/dist/serialization/resources/datasets/index.d.ts +1 -0
- package/dist/serialization/resources/datasets/index.js +17 -0
- package/dist/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
- package/dist/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
- package/dist/serialization/resources/datasets/types/Dataset.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/Dataset.js +35 -0
- package/dist/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/DatasetFile.js +35 -0
- package/dist/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
- package/dist/serialization/resources/datasets/types/FilePurpose.js +31 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
- package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
- package/dist/serialization/resources/datasets/types/index.d.ts +6 -0
- package/dist/serialization/resources/datasets/types/index.js +22 -0
- package/dist/serialization/resources/embedding/index.js +17 -1
- package/dist/serialization/resources/embedding/types/Embedding.js +28 -2
- package/dist/serialization/resources/embedding/types/index.js +17 -1
- package/dist/serialization/resources/index.d.ts +2 -0
- package/dist/serialization/resources/index.js +41 -10
- package/dist/serialization/resources/tts/index.js +17 -1
- package/dist/serialization/resources/tts/types/CancelContextRequest.js +30 -4
- package/dist/serialization/resources/tts/types/ContextId.js +28 -2
- package/dist/serialization/resources/tts/types/Controls.js +32 -6
- package/dist/serialization/resources/tts/types/Emotion.js +28 -2
- package/dist/serialization/resources/tts/types/GenerationRequest.js +36 -10
- package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +28 -2
- package/dist/serialization/resources/tts/types/NaturalSpecifier.js +28 -2
- package/dist/serialization/resources/tts/types/NumericalSpecifier.js +28 -2
- package/dist/serialization/resources/tts/types/OutputFormat.js +34 -8
- package/dist/serialization/resources/tts/types/RawEncoding.js +28 -2
- package/dist/serialization/resources/tts/types/RawOutputFormat.js +30 -4
- package/dist/serialization/resources/tts/types/Speed.js +30 -4
- package/dist/serialization/resources/tts/types/SupportedLanguage.js +28 -2
- package/dist/serialization/resources/tts/types/TtsRequest.js +34 -8
- package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +32 -6
- package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +32 -6
- package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +30 -4
- package/dist/serialization/resources/tts/types/WavOutputFormat.js +29 -3
- package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +29 -3
- package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketRequest.js +30 -4
- package/dist/serialization/resources/tts/types/WebSocketResponse.js +36 -10
- package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +28 -2
- package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +32 -6
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +32 -6
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +32 -6
- package/dist/serialization/resources/tts/types/WordTimestamps.js +28 -2
- package/dist/serialization/resources/tts/types/index.js +46 -30
- package/dist/serialization/resources/voiceChanger/index.js +17 -1
- package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +28 -2
- package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +34 -8
- package/dist/serialization/resources/voiceChanger/types/index.js +18 -2
- package/dist/serialization/resources/voices/client/index.js +27 -1
- package/dist/serialization/resources/voices/client/list.js +29 -3
- package/dist/serialization/resources/voices/index.js +18 -2
- package/dist/serialization/resources/voices/types/BaseVoiceId.js +5 -2
- package/dist/serialization/resources/voices/types/CloneMode.js +28 -2
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +34 -8
- package/dist/serialization/resources/voices/types/EmbeddingResponse.js +30 -4
- package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +32 -6
- package/dist/serialization/resources/voices/types/Gender.js +28 -2
- package/dist/serialization/resources/voices/types/IdSpecifier.js +32 -6
- package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
- package/dist/serialization/resources/voices/types/LocalizeDialect.js +29 -2
- package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
- package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
- package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +28 -2
- package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +36 -10
- package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +30 -4
- package/dist/serialization/resources/voices/types/MixVoicesRequest.js +30 -4
- package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +28 -2
- package/dist/serialization/resources/voices/types/Voice.js +36 -10
- package/dist/serialization/resources/voices/types/VoiceId.js +28 -2
- package/dist/serialization/resources/voices/types/VoiceMetadata.js +32 -6
- package/dist/serialization/resources/voices/types/Weight.js +28 -2
- package/dist/serialization/resources/voices/types/index.d.ts +1 -0
- package/dist/serialization/resources/voices/types/index.js +34 -17
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -1
- package/dist/wrapper/Client.js +8 -4
- package/dist/wrapper/StreamingTTSClient.js +11 -4
- package/dist/wrapper/WebPlayer.js +7 -3
- package/dist/wrapper/Websocket.d.ts +7 -24
- package/dist/wrapper/Websocket.js +101 -71
- package/dist/wrapper/source.d.ts +5 -4
- package/dist/wrapper/source.js +12 -6
- package/dist/wrapper/utils.js +28 -13
- package/environments.js +4 -1
- package/errors/CartesiaError.js +5 -1
- package/errors/CartesiaTimeoutError.js +5 -1
- package/errors/index.js +7 -2
- package/index.js +34 -4
- package/package.json +2 -2
- package/reference.md +204 -0
- package/serialization/index.js +17 -1
- package/serialization/resources/apiStatus/index.js +17 -1
- package/serialization/resources/apiStatus/types/ApiInfo.js +28 -2
- package/serialization/resources/apiStatus/types/index.js +17 -1
- package/serialization/resources/datasets/index.d.ts +1 -0
- package/serialization/resources/datasets/index.js +17 -0
- package/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
- package/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
- package/serialization/resources/datasets/types/Dataset.d.ts +14 -0
- package/serialization/resources/datasets/types/Dataset.js +35 -0
- package/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
- package/serialization/resources/datasets/types/DatasetFile.js +35 -0
- package/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
- package/serialization/resources/datasets/types/FilePurpose.js +31 -0
- package/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
- package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
- package/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
- package/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
- package/serialization/resources/datasets/types/index.d.ts +6 -0
- package/serialization/resources/datasets/types/index.js +22 -0
- package/serialization/resources/embedding/index.js +17 -1
- package/serialization/resources/embedding/types/Embedding.js +28 -2
- package/serialization/resources/embedding/types/index.js +17 -1
- package/serialization/resources/index.d.ts +2 -0
- package/serialization/resources/index.js +41 -10
- package/serialization/resources/tts/index.js +17 -1
- package/serialization/resources/tts/types/CancelContextRequest.js +30 -4
- package/serialization/resources/tts/types/ContextId.js +28 -2
- package/serialization/resources/tts/types/Controls.js +32 -6
- package/serialization/resources/tts/types/Emotion.js +28 -2
- package/serialization/resources/tts/types/GenerationRequest.js +36 -10
- package/serialization/resources/tts/types/Mp3OutputFormat.js +28 -2
- package/serialization/resources/tts/types/NaturalSpecifier.js +28 -2
- package/serialization/resources/tts/types/NumericalSpecifier.js +28 -2
- package/serialization/resources/tts/types/OutputFormat.js +34 -8
- package/serialization/resources/tts/types/RawEncoding.js +28 -2
- package/serialization/resources/tts/types/RawOutputFormat.js +30 -4
- package/serialization/resources/tts/types/Speed.js +30 -4
- package/serialization/resources/tts/types/SupportedLanguage.js +28 -2
- package/serialization/resources/tts/types/TtsRequest.js +34 -8
- package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +32 -6
- package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +32 -6
- package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +30 -4
- package/serialization/resources/tts/types/WavOutputFormat.js +29 -3
- package/serialization/resources/tts/types/WebSocketBaseResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketChunkResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketDoneResponse.js +29 -3
- package/serialization/resources/tts/types/WebSocketErrorResponse.js +30 -4
- package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +30 -4
- package/serialization/resources/tts/types/WebSocketRequest.js +30 -4
- package/serialization/resources/tts/types/WebSocketResponse.js +36 -10
- package/serialization/resources/tts/types/WebSocketStreamOptions.js +28 -2
- package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +32 -6
- package/serialization/resources/tts/types/WebSocketTtsOutput.js +32 -6
- package/serialization/resources/tts/types/WebSocketTtsRequest.js +32 -6
- package/serialization/resources/tts/types/WordTimestamps.js +28 -2
- package/serialization/resources/tts/types/index.js +46 -30
- package/serialization/resources/voiceChanger/index.js +17 -1
- package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +28 -2
- package/serialization/resources/voiceChanger/types/StreamingResponse.js +34 -8
- package/serialization/resources/voiceChanger/types/index.js +18 -2
- package/serialization/resources/voices/client/index.js +27 -1
- package/serialization/resources/voices/client/list.js +29 -3
- package/serialization/resources/voices/index.js +18 -2
- package/serialization/resources/voices/types/BaseVoiceId.js +5 -2
- package/serialization/resources/voices/types/CloneMode.js +28 -2
- package/serialization/resources/voices/types/CreateVoiceRequest.js +34 -8
- package/serialization/resources/voices/types/EmbeddingResponse.js +30 -4
- package/serialization/resources/voices/types/EmbeddingSpecifier.js +32 -6
- package/serialization/resources/voices/types/Gender.js +28 -2
- package/serialization/resources/voices/types/IdSpecifier.js +32 -6
- package/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
- package/serialization/resources/voices/types/LocalizeDialect.js +29 -2
- package/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
- package/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
- package/serialization/resources/voices/types/LocalizeTargetLanguage.js +28 -2
- package/serialization/resources/voices/types/LocalizeVoiceRequest.js +36 -10
- package/serialization/resources/voices/types/MixVoiceSpecifier.js +30 -4
- package/serialization/resources/voices/types/MixVoicesRequest.js +30 -4
- package/serialization/resources/voices/types/UpdateVoiceRequest.js +28 -2
- package/serialization/resources/voices/types/Voice.js +36 -10
- package/serialization/resources/voices/types/VoiceId.js +28 -2
- package/serialization/resources/voices/types/VoiceMetadata.js +32 -6
- package/serialization/resources/voices/types/Weight.js +28 -2
- package/serialization/resources/voices/types/index.d.ts +1 -0
- package/serialization/resources/voices/types/index.js +34 -17
- package/version.d.ts +1 -1
- package/version.js +4 -1
- package/wrapper/Client.js +8 -4
- package/wrapper/StreamingTTSClient.js +11 -4
- package/wrapper/WebPlayer.js +7 -3
- package/wrapper/Websocket.d.ts +7 -24
- package/wrapper/Websocket.js +101 -71
- package/wrapper/source.d.ts +5 -4
- package/wrapper/source.js +12 -6
- package/wrapper/utils.js +28 -13
package/Client.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import * as environments from "./environments";
|
|
5
5
|
import * as core from "./core";
|
|
6
6
|
import { ApiStatus } from "./api/resources/apiStatus/client/Client";
|
|
7
|
+
import { Datasets } from "./api/resources/datasets/client/Client";
|
|
7
8
|
import { Tts } from "./api/resources/tts/client/Client";
|
|
8
9
|
import { VoiceChanger } from "./api/resources/voiceChanger/client/Client";
|
|
9
10
|
import { Voices } from "./api/resources/voices/client/Client";
|
|
@@ -31,6 +32,8 @@ export declare class CartesiaClient {
|
|
|
31
32
|
constructor(_options?: CartesiaClient.Options);
|
|
32
33
|
protected _apiStatus: ApiStatus | undefined;
|
|
33
34
|
get apiStatus(): ApiStatus;
|
|
35
|
+
protected _datasets: Datasets | undefined;
|
|
36
|
+
get datasets(): Datasets;
|
|
34
37
|
protected _tts: Tts | undefined;
|
|
35
38
|
get tts(): Tts;
|
|
36
39
|
protected _voiceChanger: VoiceChanger | undefined;
|
package/Client.js
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.CartesiaClient = void 0;
|
|
7
|
+
const Client_1 = require("./api/resources/apiStatus/client/Client");
|
|
8
|
+
const Client_2 = require("./api/resources/datasets/client/Client");
|
|
9
|
+
const Client_3 = require("./api/resources/tts/client/Client");
|
|
10
|
+
const Client_4 = require("./api/resources/voiceChanger/client/Client");
|
|
11
|
+
const Client_5 = require("./api/resources/voices/client/Client");
|
|
12
|
+
class CartesiaClient {
|
|
9
13
|
constructor(_options = {}) {
|
|
10
14
|
this._options = _options;
|
|
11
15
|
}
|
|
12
16
|
get apiStatus() {
|
|
13
17
|
var _a;
|
|
14
|
-
return ((_a = this._apiStatus) !== null && _a !== void 0 ? _a : (this._apiStatus = new ApiStatus(this._options)));
|
|
18
|
+
return ((_a = this._apiStatus) !== null && _a !== void 0 ? _a : (this._apiStatus = new Client_1.ApiStatus(this._options)));
|
|
19
|
+
}
|
|
20
|
+
get datasets() {
|
|
21
|
+
var _a;
|
|
22
|
+
return ((_a = this._datasets) !== null && _a !== void 0 ? _a : (this._datasets = new Client_2.Datasets(this._options)));
|
|
15
23
|
}
|
|
16
24
|
get tts() {
|
|
17
25
|
var _a;
|
|
18
|
-
return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Tts(this._options)));
|
|
26
|
+
return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_3.Tts(this._options)));
|
|
19
27
|
}
|
|
20
28
|
get voiceChanger() {
|
|
21
29
|
var _a;
|
|
22
|
-
return ((_a = this._voiceChanger) !== null && _a !== void 0 ? _a : (this._voiceChanger = new VoiceChanger(this._options)));
|
|
30
|
+
return ((_a = this._voiceChanger) !== null && _a !== void 0 ? _a : (this._voiceChanger = new Client_4.VoiceChanger(this._options)));
|
|
23
31
|
}
|
|
24
32
|
get voices() {
|
|
25
33
|
var _a;
|
|
26
|
-
return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Voices(this._options)));
|
|
34
|
+
return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Client_5.Voices(this._options)));
|
|
27
35
|
}
|
|
28
36
|
}
|
|
37
|
+
exports.CartesiaClient = CartesiaClient;
|
package/README.md
CHANGED
|
@@ -58,11 +58,7 @@ const websocket = cartesia.tts.websocket({
|
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
try {
|
|
61
|
-
await websocket.connect(
|
|
62
|
-
// If using Node.js, you can pass a custom WebSocket constructor, such as from `ws`.
|
|
63
|
-
// This is not needed for browser usage, so you can call connect() without any arguments.
|
|
64
|
-
WebSocket: WS,
|
|
65
|
-
});
|
|
61
|
+
await websocket.connect();
|
|
66
62
|
} catch (error) {
|
|
67
63
|
console.error(`Failed to connect to Cartesia: ${error}`);
|
|
68
64
|
}
|
package/api/index.js
CHANGED
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./resources"), exports);
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* This file was auto-generated by Fern from our API Definition.
|
|
3
4
|
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
4
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -10,11 +34,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
34
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
35
|
});
|
|
12
36
|
};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.ApiStatus = void 0;
|
|
39
|
+
const environments = __importStar(require("../../../../environments"));
|
|
40
|
+
const core = __importStar(require("../../../../core"));
|
|
41
|
+
const serializers = __importStar(require("../../../../serialization/index"));
|
|
42
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
43
|
+
class ApiStatus {
|
|
18
44
|
constructor(_options = {}) {
|
|
19
45
|
this._options = _options;
|
|
20
46
|
}
|
|
@@ -30,7 +56,7 @@ export class ApiStatus {
|
|
|
30
56
|
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
31
57
|
url: (_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production,
|
|
32
58
|
method: "GET",
|
|
33
|
-
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.
|
|
59
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
34
60
|
contentType: "application/json",
|
|
35
61
|
requestType: "json",
|
|
36
62
|
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
@@ -74,3 +100,4 @@ export class ApiStatus {
|
|
|
74
100
|
});
|
|
75
101
|
}
|
|
76
102
|
}
|
|
103
|
+
exports.ApiStatus = ApiStatus;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ApiInfo"), exports);
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="node" />
|
|
5
|
+
import * as environments from "../../../../environments";
|
|
6
|
+
import * as core from "../../../../core";
|
|
7
|
+
import * as Cartesia from "../../../index";
|
|
8
|
+
import * as fs from "fs";
|
|
9
|
+
import { Blob } from "buffer";
|
|
10
|
+
export declare namespace Datasets {
|
|
11
|
+
interface Options {
|
|
12
|
+
environment?: core.Supplier<environments.CartesiaEnvironment | string>;
|
|
13
|
+
apiKey?: core.Supplier<string | undefined>;
|
|
14
|
+
/** Override the Cartesia-Version header */
|
|
15
|
+
cartesiaVersion?: "2024-06-10";
|
|
16
|
+
fetcher?: core.FetchFunction;
|
|
17
|
+
}
|
|
18
|
+
interface RequestOptions {
|
|
19
|
+
/** The maximum time to wait for a response in seconds. */
|
|
20
|
+
timeoutInSeconds?: number;
|
|
21
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
22
|
+
maxRetries?: number;
|
|
23
|
+
/** A hook to abort the request. */
|
|
24
|
+
abortSignal?: AbortSignal;
|
|
25
|
+
/** Override the Cartesia-Version header */
|
|
26
|
+
cartesiaVersion?: "2024-06-10";
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export declare class Datasets {
|
|
30
|
+
protected readonly _options: Datasets.Options;
|
|
31
|
+
constructor(_options?: Datasets.Options);
|
|
32
|
+
/**
|
|
33
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* await client.datasets.list()
|
|
37
|
+
*/
|
|
38
|
+
list(requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasets>;
|
|
39
|
+
/**
|
|
40
|
+
* @param {Cartesia.CreateDatasetRequest} request
|
|
41
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* await client.datasets.create({
|
|
45
|
+
* name: "string"
|
|
46
|
+
* })
|
|
47
|
+
*/
|
|
48
|
+
create(request: Cartesia.CreateDatasetRequest, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.Dataset>;
|
|
49
|
+
/**
|
|
50
|
+
* @param {string} id
|
|
51
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* await client.datasets.listFiles("string")
|
|
55
|
+
*/
|
|
56
|
+
listFiles(id: string, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasetFiles>;
|
|
57
|
+
/**
|
|
58
|
+
* @param {File | fs.ReadStream | Blob} file
|
|
59
|
+
* @param {string} id
|
|
60
|
+
* @param {Cartesia.UploadDatasetFileRequest} request
|
|
61
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* await client.datasets.uploadFile(fs.createReadStream("/path/to/your/file"), "string", {})
|
|
65
|
+
*/
|
|
66
|
+
uploadFile(file: File | fs.ReadStream | Blob, id: string, request: Cartesia.UploadDatasetFileRequest, requestOptions?: Datasets.RequestOptions): Promise<void>;
|
|
67
|
+
protected _getCustomAuthorizationHeaders(): Promise<{
|
|
68
|
+
"X-API-Key": string | undefined;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
38
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
39
|
+
};
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.Datasets = void 0;
|
|
42
|
+
const environments = __importStar(require("../../../../environments"));
|
|
43
|
+
const core = __importStar(require("../../../../core"));
|
|
44
|
+
const url_join_1 = __importDefault(require("url-join"));
|
|
45
|
+
const serializers = __importStar(require("../../../../serialization/index"));
|
|
46
|
+
const errors = __importStar(require("../../../../errors/index"));
|
|
47
|
+
class Datasets {
|
|
48
|
+
constructor(_options = {}) {
|
|
49
|
+
this._options = _options;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* await client.datasets.list()
|
|
56
|
+
*/
|
|
57
|
+
list(requestOptions) {
|
|
58
|
+
var _a, _b, _c, _d, _e;
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
61
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/datasets/"),
|
|
62
|
+
method: "GET",
|
|
63
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
64
|
+
contentType: "application/json",
|
|
65
|
+
requestType: "json",
|
|
66
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
67
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
68
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
69
|
+
});
|
|
70
|
+
if (_response.ok) {
|
|
71
|
+
return serializers.PaginatedDatasets.parseOrThrow(_response.body, {
|
|
72
|
+
unrecognizedObjectKeys: "passthrough",
|
|
73
|
+
allowUnrecognizedUnionMembers: true,
|
|
74
|
+
allowUnrecognizedEnumValues: true,
|
|
75
|
+
skipValidation: true,
|
|
76
|
+
breadcrumbsPrefix: ["response"],
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
if (_response.error.reason === "status-code") {
|
|
80
|
+
throw new errors.CartesiaError({
|
|
81
|
+
statusCode: _response.error.statusCode,
|
|
82
|
+
body: _response.error.body,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
switch (_response.error.reason) {
|
|
86
|
+
case "non-json":
|
|
87
|
+
throw new errors.CartesiaError({
|
|
88
|
+
statusCode: _response.error.statusCode,
|
|
89
|
+
body: _response.error.rawBody,
|
|
90
|
+
});
|
|
91
|
+
case "timeout":
|
|
92
|
+
throw new errors.CartesiaTimeoutError();
|
|
93
|
+
case "unknown":
|
|
94
|
+
throw new errors.CartesiaError({
|
|
95
|
+
message: _response.error.errorMessage,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* @param {Cartesia.CreateDatasetRequest} request
|
|
102
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* await client.datasets.create({
|
|
106
|
+
* name: "string"
|
|
107
|
+
* })
|
|
108
|
+
*/
|
|
109
|
+
create(request, requestOptions) {
|
|
110
|
+
var _a, _b, _c, _d, _e;
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
113
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/datasets/"),
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
116
|
+
contentType: "application/json",
|
|
117
|
+
requestType: "json",
|
|
118
|
+
body: serializers.CreateDatasetRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
|
|
119
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
120
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
121
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
122
|
+
});
|
|
123
|
+
if (_response.ok) {
|
|
124
|
+
return serializers.Dataset.parseOrThrow(_response.body, {
|
|
125
|
+
unrecognizedObjectKeys: "passthrough",
|
|
126
|
+
allowUnrecognizedUnionMembers: true,
|
|
127
|
+
allowUnrecognizedEnumValues: true,
|
|
128
|
+
skipValidation: true,
|
|
129
|
+
breadcrumbsPrefix: ["response"],
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
if (_response.error.reason === "status-code") {
|
|
133
|
+
throw new errors.CartesiaError({
|
|
134
|
+
statusCode: _response.error.statusCode,
|
|
135
|
+
body: _response.error.body,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
switch (_response.error.reason) {
|
|
139
|
+
case "non-json":
|
|
140
|
+
throw new errors.CartesiaError({
|
|
141
|
+
statusCode: _response.error.statusCode,
|
|
142
|
+
body: _response.error.rawBody,
|
|
143
|
+
});
|
|
144
|
+
case "timeout":
|
|
145
|
+
throw new errors.CartesiaTimeoutError();
|
|
146
|
+
case "unknown":
|
|
147
|
+
throw new errors.CartesiaError({
|
|
148
|
+
message: _response.error.errorMessage,
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* @param {string} id
|
|
155
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* await client.datasets.listFiles("string")
|
|
159
|
+
*/
|
|
160
|
+
listFiles(id, requestOptions) {
|
|
161
|
+
var _a, _b, _c, _d, _e;
|
|
162
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
163
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
164
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
|
|
165
|
+
method: "GET",
|
|
166
|
+
headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
|
|
167
|
+
contentType: "application/json",
|
|
168
|
+
requestType: "json",
|
|
169
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
170
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
171
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
172
|
+
});
|
|
173
|
+
if (_response.ok) {
|
|
174
|
+
return serializers.PaginatedDatasetFiles.parseOrThrow(_response.body, {
|
|
175
|
+
unrecognizedObjectKeys: "passthrough",
|
|
176
|
+
allowUnrecognizedUnionMembers: true,
|
|
177
|
+
allowUnrecognizedEnumValues: true,
|
|
178
|
+
skipValidation: true,
|
|
179
|
+
breadcrumbsPrefix: ["response"],
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (_response.error.reason === "status-code") {
|
|
183
|
+
throw new errors.CartesiaError({
|
|
184
|
+
statusCode: _response.error.statusCode,
|
|
185
|
+
body: _response.error.body,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
switch (_response.error.reason) {
|
|
189
|
+
case "non-json":
|
|
190
|
+
throw new errors.CartesiaError({
|
|
191
|
+
statusCode: _response.error.statusCode,
|
|
192
|
+
body: _response.error.rawBody,
|
|
193
|
+
});
|
|
194
|
+
case "timeout":
|
|
195
|
+
throw new errors.CartesiaTimeoutError();
|
|
196
|
+
case "unknown":
|
|
197
|
+
throw new errors.CartesiaError({
|
|
198
|
+
message: _response.error.errorMessage,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* @param {File | fs.ReadStream | Blob} file
|
|
205
|
+
* @param {string} id
|
|
206
|
+
* @param {Cartesia.UploadDatasetFileRequest} request
|
|
207
|
+
* @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* await client.datasets.uploadFile(fs.createReadStream("/path/to/your/file"), "string", {})
|
|
211
|
+
*/
|
|
212
|
+
uploadFile(file, id, request, requestOptions) {
|
|
213
|
+
var _a, _b, _c, _d, _e;
|
|
214
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
+
const _request = yield core.newFormData();
|
|
216
|
+
yield _request.appendFile("file", file);
|
|
217
|
+
yield _request.append("purpose", request.purpose);
|
|
218
|
+
const _maybeEncodedRequest = yield _request.getRequest();
|
|
219
|
+
const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
|
|
220
|
+
url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
|
|
221
|
+
method: "POST",
|
|
222
|
+
headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
|
|
223
|
+
requestType: "file",
|
|
224
|
+
duplex: _maybeEncodedRequest.duplex,
|
|
225
|
+
body: _maybeEncodedRequest.body,
|
|
226
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
227
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
228
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
229
|
+
});
|
|
230
|
+
if (_response.ok) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (_response.error.reason === "status-code") {
|
|
234
|
+
throw new errors.CartesiaError({
|
|
235
|
+
statusCode: _response.error.statusCode,
|
|
236
|
+
body: _response.error.body,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
switch (_response.error.reason) {
|
|
240
|
+
case "non-json":
|
|
241
|
+
throw new errors.CartesiaError({
|
|
242
|
+
statusCode: _response.error.statusCode,
|
|
243
|
+
body: _response.error.rawBody,
|
|
244
|
+
});
|
|
245
|
+
case "timeout":
|
|
246
|
+
throw new errors.CartesiaTimeoutError();
|
|
247
|
+
case "unknown":
|
|
248
|
+
throw new errors.CartesiaError({
|
|
249
|
+
message: _response.error.errorMessage,
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
_getCustomAuthorizationHeaders() {
|
|
255
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
256
|
+
const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
|
|
257
|
+
return { "X-API-Key": apiKeyValue };
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.Datasets = Datasets;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./requests"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { type UploadDatasetFileRequest } from "./UploadDatasetFileRequest";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./client"), exports);
|