@cartesia/cartesia-js 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.js +13 -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/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.js +41 -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.js +4 -1
- 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.js +33 -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.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.js +13 -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/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.js +41 -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.js +4 -1
- 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.js +33 -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.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/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.js +39 -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.js +28 -2
- 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.js +33 -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/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/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.js +39 -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.js +28 -2
- 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.js +33 -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
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
1
25
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
26
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
27
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -7,17 +31,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
31
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
32
|
});
|
|
9
33
|
};
|
|
10
|
-
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.WebFormData = exports.Node16FormData = exports.Node18FormData = exports.newFormData = void 0;
|
|
36
|
+
const runtime_1 = require("../runtime");
|
|
11
37
|
function isNamedValue(value) {
|
|
12
38
|
return typeof value === "object" && value != null && "name" in value;
|
|
13
39
|
}
|
|
14
|
-
|
|
40
|
+
function newFormData() {
|
|
15
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
42
|
let formdata;
|
|
17
|
-
if (RUNTIME.type === "node" && RUNTIME.parsedVersion != null && RUNTIME.parsedVersion >= 18) {
|
|
43
|
+
if (runtime_1.RUNTIME.type === "node" && runtime_1.RUNTIME.parsedVersion != null && runtime_1.RUNTIME.parsedVersion >= 18) {
|
|
18
44
|
formdata = new Node18FormData();
|
|
19
45
|
}
|
|
20
|
-
else if (RUNTIME.type === "node") {
|
|
46
|
+
else if (runtime_1.RUNTIME.type === "node") {
|
|
21
47
|
formdata = new Node16FormData();
|
|
22
48
|
}
|
|
23
49
|
else {
|
|
@@ -27,13 +53,14 @@ export function newFormData() {
|
|
|
27
53
|
return formdata;
|
|
28
54
|
});
|
|
29
55
|
}
|
|
56
|
+
exports.newFormData = newFormData;
|
|
30
57
|
/**
|
|
31
58
|
* Form Data Implementation for Node.js 18+
|
|
32
59
|
*/
|
|
33
|
-
|
|
60
|
+
class Node18FormData {
|
|
34
61
|
setup() {
|
|
35
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
this.fd = new (yield
|
|
63
|
+
this.fd = new (yield Promise.resolve().then(() => __importStar(require("formdata-node")))).FormData();
|
|
37
64
|
});
|
|
38
65
|
}
|
|
39
66
|
append(key, value) {
|
|
@@ -63,22 +90,23 @@ export class Node18FormData {
|
|
|
63
90
|
}
|
|
64
91
|
getRequest() {
|
|
65
92
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
-
const encoder = new (yield
|
|
93
|
+
const encoder = new (yield Promise.resolve().then(() => __importStar(require("form-data-encoder")))).FormDataEncoder(this.fd);
|
|
67
94
|
return {
|
|
68
|
-
body: (yield
|
|
95
|
+
body: (yield Promise.resolve().then(() => __importStar(require("readable-stream")))).Readable.from(encoder),
|
|
69
96
|
headers: encoder.headers,
|
|
70
97
|
duplex: "half",
|
|
71
98
|
};
|
|
72
99
|
});
|
|
73
100
|
}
|
|
74
101
|
}
|
|
102
|
+
exports.Node18FormData = Node18FormData;
|
|
75
103
|
/**
|
|
76
104
|
* Form Data Implementation for Node.js 16-18
|
|
77
105
|
*/
|
|
78
|
-
|
|
106
|
+
class Node16FormData {
|
|
79
107
|
setup() {
|
|
80
108
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
this.fd = new (yield
|
|
109
|
+
this.fd = new (yield Promise.resolve().then(() => __importStar(require("form-data")))).default();
|
|
82
110
|
});
|
|
83
111
|
}
|
|
84
112
|
append(key, value) {
|
|
@@ -113,10 +141,11 @@ export class Node16FormData {
|
|
|
113
141
|
};
|
|
114
142
|
}
|
|
115
143
|
}
|
|
144
|
+
exports.Node16FormData = Node16FormData;
|
|
116
145
|
/**
|
|
117
146
|
* Form Data Implementation for Web
|
|
118
147
|
*/
|
|
119
|
-
|
|
148
|
+
class WebFormData {
|
|
120
149
|
setup() {
|
|
121
150
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
151
|
this.fd = new FormData();
|
|
@@ -142,3 +171,4 @@ export class WebFormData {
|
|
|
142
171
|
};
|
|
143
172
|
}
|
|
144
173
|
}
|
|
174
|
+
exports.WebFormData = WebFormData;
|
|
@@ -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("./FormDataWrapper"), exports);
|
package/core/index.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.serialization = void 0;
|
|
30
|
+
__exportStar(require("./fetcher"), exports);
|
|
31
|
+
__exportStar(require("./runtime"), exports);
|
|
32
|
+
__exportStar(require("./streaming-fetcher"), exports);
|
|
33
|
+
__exportStar(require("./form-data-utils"), exports);
|
|
34
|
+
exports.serialization = __importStar(require("./schemas"));
|
package/core/runtime/index.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIME = void 0;
|
|
4
|
+
var runtime_1 = require("./runtime");
|
|
5
|
+
Object.defineProperty(exports, "RUNTIME", { enumerable: true, get: function () { return runtime_1.RUNTIME; } });
|
package/core/runtime/runtime.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var _a, _b, _c, _d, _e;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.RUNTIME = void 0;
|
|
2
5
|
/**
|
|
3
6
|
* A constant that indicates whether the environment the code is running is a Web Browser.
|
|
4
7
|
*/
|
|
@@ -42,7 +45,7 @@ const isCloudflare = typeof globalThis !== "undefined" && ((_e = globalThis ===
|
|
|
42
45
|
/**
|
|
43
46
|
* A constant that indicates which environment and version the SDK is running in.
|
|
44
47
|
*/
|
|
45
|
-
|
|
48
|
+
exports.RUNTIME = evaluateRuntime();
|
|
46
49
|
function evaluateRuntime() {
|
|
47
50
|
if (isBrowser) {
|
|
48
51
|
return {
|
package/core/schemas/Schema.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bigint = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
|
+
const schema_utils_1 = require("../schema-utils");
|
|
8
|
+
function bigint() {
|
|
6
9
|
const baseSchema = {
|
|
7
10
|
parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
|
|
8
11
|
if (typeof raw !== "string") {
|
|
@@ -11,7 +14,7 @@ export function bigint() {
|
|
|
11
14
|
errors: [
|
|
12
15
|
{
|
|
13
16
|
path: breadcrumbsPrefix,
|
|
14
|
-
message: getErrorMessageForIncorrectType(raw, "string"),
|
|
17
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
|
|
15
18
|
},
|
|
16
19
|
],
|
|
17
20
|
};
|
|
@@ -34,13 +37,14 @@ export function bigint() {
|
|
|
34
37
|
errors: [
|
|
35
38
|
{
|
|
36
39
|
path: breadcrumbsPrefix,
|
|
37
|
-
message: getErrorMessageForIncorrectType(bigint, "bigint"),
|
|
40
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(bigint, "bigint"),
|
|
38
41
|
},
|
|
39
42
|
],
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
},
|
|
43
|
-
getType: () => SchemaType.BIGINT,
|
|
46
|
+
getType: () => Schema_1.SchemaType.BIGINT,
|
|
44
47
|
};
|
|
45
|
-
return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
|
|
48
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
46
49
|
}
|
|
50
|
+
exports.bigint = bigint;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.bigint = void 0;
|
|
4
|
+
var bigint_1 = require("./bigint");
|
|
5
|
+
Object.defineProperty(exports, "bigint", { enumerable: true, get: function () { return bigint_1.bigint; } });
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.date = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
|
+
const schema_utils_1 = require("../schema-utils");
|
|
5
8
|
// https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime
|
|
6
9
|
const ISO_8601_REGEX = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
|
|
7
|
-
|
|
10
|
+
function date() {
|
|
8
11
|
const baseSchema = {
|
|
9
12
|
parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
|
|
10
13
|
if (typeof raw !== "string") {
|
|
@@ -13,7 +16,7 @@ export function date() {
|
|
|
13
16
|
errors: [
|
|
14
17
|
{
|
|
15
18
|
path: breadcrumbsPrefix,
|
|
16
|
-
message: getErrorMessageForIncorrectType(raw, "string"),
|
|
19
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
|
|
17
20
|
},
|
|
18
21
|
],
|
|
19
22
|
};
|
|
@@ -24,7 +27,7 @@ export function date() {
|
|
|
24
27
|
errors: [
|
|
25
28
|
{
|
|
26
29
|
path: breadcrumbsPrefix,
|
|
27
|
-
message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string"),
|
|
30
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "ISO 8601 date string"),
|
|
28
31
|
},
|
|
29
32
|
],
|
|
30
33
|
};
|
|
@@ -47,13 +50,14 @@ export function date() {
|
|
|
47
50
|
errors: [
|
|
48
51
|
{
|
|
49
52
|
path: breadcrumbsPrefix,
|
|
50
|
-
message: getErrorMessageForIncorrectType(date, "Date object"),
|
|
53
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(date, "Date object"),
|
|
51
54
|
},
|
|
52
55
|
],
|
|
53
56
|
};
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
|
-
getType: () => SchemaType.DATE,
|
|
59
|
+
getType: () => Schema_1.SchemaType.DATE,
|
|
57
60
|
};
|
|
58
|
-
return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
|
|
61
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
59
62
|
}
|
|
63
|
+
exports.date = date;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.date = void 0;
|
|
4
|
+
var date_1 = require("./date");
|
|
5
|
+
Object.defineProperty(exports, "date", { enumerable: true, get: function () { return date_1.date; } });
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enum_ = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function enum_(values) {
|
|
5
8
|
const validValues = new Set(values);
|
|
6
|
-
const schemaCreator = createIdentitySchemaCreator(SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
|
|
9
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ENUM, (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => {
|
|
7
10
|
if (typeof value !== "string") {
|
|
8
11
|
return {
|
|
9
12
|
ok: false,
|
|
10
13
|
errors: [
|
|
11
14
|
{
|
|
12
15
|
path: breadcrumbsPrefix,
|
|
13
|
-
message: getErrorMessageForIncorrectType(value, "string"),
|
|
16
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "string"),
|
|
14
17
|
},
|
|
15
18
|
],
|
|
16
19
|
};
|
|
@@ -21,7 +24,7 @@ export function enum_(values) {
|
|
|
21
24
|
errors: [
|
|
22
25
|
{
|
|
23
26
|
path: breadcrumbsPrefix,
|
|
24
|
-
message: getErrorMessageForIncorrectType(value, "enum"),
|
|
27
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "enum"),
|
|
25
28
|
},
|
|
26
29
|
],
|
|
27
30
|
};
|
|
@@ -33,3 +36,4 @@ export function enum_(values) {
|
|
|
33
36
|
});
|
|
34
37
|
return schemaCreator();
|
|
35
38
|
}
|
|
39
|
+
exports.enum_ = enum_;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enum_ = void 0;
|
|
4
|
+
var enum_1 = require("./enum");
|
|
5
|
+
Object.defineProperty(exports, "enum_", { enumerable: true, get: function () { return enum_1.enum_; } });
|
|
@@ -1,14 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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("./bigint"), exports);
|
|
18
|
+
__exportStar(require("./date"), exports);
|
|
19
|
+
__exportStar(require("./enum"), exports);
|
|
20
|
+
__exportStar(require("./lazy"), exports);
|
|
21
|
+
__exportStar(require("./list"), exports);
|
|
22
|
+
__exportStar(require("./literals"), exports);
|
|
23
|
+
__exportStar(require("./object"), exports);
|
|
24
|
+
__exportStar(require("./object-like"), exports);
|
|
25
|
+
__exportStar(require("./primitives"), exports);
|
|
26
|
+
__exportStar(require("./record"), exports);
|
|
27
|
+
__exportStar(require("./schema-utils"), exports);
|
|
28
|
+
__exportStar(require("./set"), exports);
|
|
29
|
+
__exportStar(require("./undiscriminated-union"), exports);
|
|
30
|
+
__exportStar(require("./union"), exports);
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyObject = exports.lazy = void 0;
|
|
4
|
+
var lazy_1 = require("./lazy");
|
|
5
|
+
Object.defineProperty(exports, "lazy", { enumerable: true, get: function () { return lazy_1.lazy; } });
|
|
6
|
+
var lazyObject_1 = require("./lazyObject");
|
|
7
|
+
Object.defineProperty(exports, "lazyObject", { enumerable: true, get: function () { return lazyObject_1.lazyObject; } });
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0;
|
|
4
|
+
const schema_utils_1 = require("../schema-utils");
|
|
5
|
+
function lazy(getter) {
|
|
3
6
|
const baseSchema = constructLazyBaseSchema(getter);
|
|
4
|
-
return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
|
|
7
|
+
return Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
5
8
|
}
|
|
6
|
-
|
|
9
|
+
exports.lazy = lazy;
|
|
10
|
+
function constructLazyBaseSchema(getter) {
|
|
7
11
|
return {
|
|
8
12
|
parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
|
|
9
13
|
json: (parsed, opts) => getMemoizedSchema(getter).json(parsed, opts),
|
|
10
14
|
getType: () => getMemoizedSchema(getter).getType(),
|
|
11
15
|
};
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
exports.constructLazyBaseSchema = constructLazyBaseSchema;
|
|
18
|
+
function getMemoizedSchema(getter) {
|
|
14
19
|
const castedGetter = getter;
|
|
15
20
|
if (castedGetter.__zurg_memoized == null) {
|
|
16
21
|
castedGetter.__zurg_memoized = getter();
|
|
17
22
|
}
|
|
18
23
|
return castedGetter.__zurg_memoized;
|
|
19
24
|
}
|
|
25
|
+
exports.getMemoizedSchema = getMemoizedSchema;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyObject = void 0;
|
|
4
|
+
const object_1 = require("../object");
|
|
5
|
+
const object_like_1 = require("../object-like");
|
|
6
|
+
const schema_utils_1 = require("../schema-utils");
|
|
7
|
+
const lazy_1 = require("./lazy");
|
|
8
|
+
function lazyObject(getter) {
|
|
9
|
+
const baseSchema = Object.assign(Object.assign({}, (0, lazy_1.constructLazyBaseSchema)(getter)), { _getRawProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getRawProperties(), _getParsedProperties: () => (0, lazy_1.getMemoizedSchema)(getter)._getParsedProperties() });
|
|
10
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), (0, object_1.getObjectUtils)(baseSchema));
|
|
8
11
|
}
|
|
12
|
+
exports.lazyObject = lazyObject;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = void 0;
|
|
4
|
+
var list_1 = require("./list");
|
|
5
|
+
Object.defineProperty(exports, "list", { enumerable: true, get: function () { return list_1.list; } });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.list = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
6
|
+
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
7
|
+
const schema_utils_1 = require("../schema-utils");
|
|
8
|
+
function list(schema) {
|
|
6
9
|
const baseSchema = {
|
|
7
10
|
parse: (raw, opts) => validateAndTransformArray(raw, (item, index) => {
|
|
8
11
|
var _a;
|
|
@@ -12,17 +15,18 @@ export function list(schema) {
|
|
|
12
15
|
var _a;
|
|
13
16
|
return schema.json(item, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `[${index}]`] }));
|
|
14
17
|
}),
|
|
15
|
-
getType: () => SchemaType.LIST,
|
|
18
|
+
getType: () => Schema_1.SchemaType.LIST,
|
|
16
19
|
};
|
|
17
|
-
return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
|
|
20
|
+
return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
|
|
18
21
|
}
|
|
22
|
+
exports.list = list;
|
|
19
23
|
function validateAndTransformArray(value, transformItem) {
|
|
20
24
|
if (!Array.isArray(value)) {
|
|
21
25
|
return {
|
|
22
26
|
ok: false,
|
|
23
27
|
errors: [
|
|
24
28
|
{
|
|
25
|
-
message: getErrorMessageForIncorrectType(value, "list"),
|
|
29
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, "list"),
|
|
26
30
|
path: [],
|
|
27
31
|
},
|
|
28
32
|
],
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanLiteral = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function booleanLiteral(literal) {
|
|
8
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
6
9
|
if (value === literal) {
|
|
7
10
|
return {
|
|
8
11
|
ok: true,
|
|
@@ -15,7 +18,7 @@ export function booleanLiteral(literal) {
|
|
|
15
18
|
errors: [
|
|
16
19
|
{
|
|
17
20
|
path: breadcrumbsPrefix,
|
|
18
|
-
message: getErrorMessageForIncorrectType(value, `${literal.toString()}`),
|
|
21
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `${literal.toString()}`),
|
|
19
22
|
},
|
|
20
23
|
],
|
|
21
24
|
};
|
|
@@ -23,3 +26,4 @@ export function booleanLiteral(literal) {
|
|
|
23
26
|
});
|
|
24
27
|
return schemaCreator();
|
|
25
28
|
}
|
|
29
|
+
exports.booleanLiteral = booleanLiteral;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanLiteral = exports.stringLiteral = void 0;
|
|
4
|
+
var stringLiteral_1 = require("./stringLiteral");
|
|
5
|
+
Object.defineProperty(exports, "stringLiteral", { enumerable: true, get: function () { return stringLiteral_1.stringLiteral; } });
|
|
6
|
+
var booleanLiteral_1 = require("./booleanLiteral");
|
|
7
|
+
Object.defineProperty(exports, "booleanLiteral", { enumerable: true, get: function () { return booleanLiteral_1.booleanLiteral; } });
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stringLiteral = void 0;
|
|
4
|
+
const Schema_1 = require("../../Schema");
|
|
5
|
+
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
+
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
+
function stringLiteral(literal) {
|
|
8
|
+
const schemaCreator = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING_LITERAL, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
6
9
|
if (value === literal) {
|
|
7
10
|
return {
|
|
8
11
|
ok: true,
|
|
@@ -15,7 +18,7 @@ export function stringLiteral(literal) {
|
|
|
15
18
|
errors: [
|
|
16
19
|
{
|
|
17
20
|
path: breadcrumbsPrefix,
|
|
18
|
-
message: getErrorMessageForIncorrectType(value, `"${literal}"`),
|
|
21
|
+
message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(value, `"${literal}"`),
|
|
19
22
|
},
|
|
20
23
|
],
|
|
21
24
|
};
|
|
@@ -23,3 +26,4 @@ export function stringLiteral(literal) {
|
|
|
23
26
|
});
|
|
24
27
|
return schemaCreator();
|
|
25
28
|
}
|
|
29
|
+
exports.stringLiteral = stringLiteral;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.property = exports.isProperty = exports.objectWithoutOptionalProperties = exports.object = exports.getObjectUtils = void 0;
|
|
4
|
+
var object_1 = require("./object");
|
|
5
|
+
Object.defineProperty(exports, "getObjectUtils", { enumerable: true, get: function () { return object_1.getObjectUtils; } });
|
|
6
|
+
Object.defineProperty(exports, "object", { enumerable: true, get: function () { return object_1.object; } });
|
|
7
|
+
var objectWithoutOptionalProperties_1 = require("./objectWithoutOptionalProperties");
|
|
8
|
+
Object.defineProperty(exports, "objectWithoutOptionalProperties", { enumerable: true, get: function () { return objectWithoutOptionalProperties_1.objectWithoutOptionalProperties; } });
|
|
9
|
+
var property_1 = require("./property");
|
|
10
|
+
Object.defineProperty(exports, "isProperty", { enumerable: true, get: function () { return property_1.isProperty; } });
|
|
11
|
+
Object.defineProperty(exports, "property", { enumerable: true, get: function () { return property_1.property; } });
|