@cartesia/cartesia-js 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Client.js +9 -13
- package/api/index.js +1 -17
- package/api/resources/apiStatus/client/Client.js +6 -33
- package/api/resources/apiStatus/client/index.js +1 -2
- package/api/resources/apiStatus/index.js +2 -18
- package/api/resources/apiStatus/types/ApiInfo.js +1 -2
- package/api/resources/apiStatus/types/index.js +1 -17
- package/api/resources/embedding/index.js +1 -17
- package/api/resources/embedding/types/Embedding.js +1 -2
- package/api/resources/embedding/types/index.js +1 -17
- package/api/resources/index.js +12 -41
- package/api/resources/tts/client/Client.js +10 -40
- package/api/resources/tts/client/index.js +1 -2
- package/api/resources/tts/index.js +2 -18
- package/api/resources/tts/types/CancelContextRequest.js +1 -2
- package/api/resources/tts/types/ContextId.js +1 -2
- package/api/resources/tts/types/Controls.js +1 -2
- package/api/resources/tts/types/Emotion.js +1 -4
- package/api/resources/tts/types/GenerationRequest.js +1 -2
- package/api/resources/tts/types/Mp3OutputFormat.js +1 -2
- package/api/resources/tts/types/NaturalSpecifier.js +1 -4
- package/api/resources/tts/types/NumericalSpecifier.js +1 -2
- package/api/resources/tts/types/OutputFormat.js +1 -2
- package/api/resources/tts/types/RawEncoding.js +1 -4
- package/api/resources/tts/types/RawOutputFormat.js +1 -2
- package/api/resources/tts/types/Speed.js +1 -2
- package/api/resources/tts/types/SupportedLanguage.js +1 -4
- package/api/resources/tts/types/TtsRequest.js +1 -2
- package/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +1 -2
- package/api/resources/tts/types/TtsRequestIdSpecifier.js +1 -2
- package/api/resources/tts/types/TtsRequestVoiceSpecifier.js +1 -2
- package/api/resources/tts/types/WavOutputFormat.js +1 -2
- package/api/resources/tts/types/WebSocketBaseResponse.js +1 -2
- package/api/resources/tts/types/WebSocketChunkResponse.js +1 -2
- package/api/resources/tts/types/WebSocketDoneResponse.js +1 -2
- package/api/resources/tts/types/WebSocketErrorResponse.js +1 -2
- package/api/resources/tts/types/WebSocketRawOutputFormat.js +1 -2
- package/api/resources/tts/types/WebSocketRequest.js +1 -2
- package/api/resources/tts/types/WebSocketResponse.js +1 -2
- package/api/resources/tts/types/WebSocketStreamOptions.js +1 -2
- package/api/resources/tts/types/WebSocketTimestampsResponse.js +1 -2
- package/api/resources/tts/types/WebSocketTtsOutput.js +1 -2
- package/api/resources/tts/types/WebSocketTtsRequest.js +1 -2
- package/api/resources/tts/types/WordTimestamps.js +1 -2
- package/api/resources/tts/types/index.js +30 -46
- package/api/resources/voiceChanger/client/Client.js +10 -40
- package/api/resources/voiceChanger/client/index.js +1 -17
- package/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +1 -2
- package/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +1 -2
- package/api/resources/voiceChanger/client/requests/index.js +1 -2
- package/api/resources/voiceChanger/index.js +2 -18
- package/api/resources/voiceChanger/types/OutputFormatContainer.js +1 -4
- package/api/resources/voiceChanger/types/StreamingResponse.js +1 -2
- package/api/resources/voiceChanger/types/index.js +2 -18
- package/api/resources/voices/client/Client.js +22 -52
- package/api/resources/voices/client/index.js +1 -17
- package/api/resources/voices/client/requests/CloneVoiceRequest.js +1 -2
- package/api/resources/voices/client/requests/index.js +1 -2
- package/api/resources/voices/index.js +2 -18
- package/api/resources/voices/types/BaseVoiceId.js +1 -2
- package/api/resources/voices/types/CloneMode.js +1 -4
- package/api/resources/voices/types/CreateVoiceRequest.js +1 -2
- package/api/resources/voices/types/EmbeddingResponse.js +1 -2
- package/api/resources/voices/types/EmbeddingSpecifier.js +1 -2
- package/api/resources/voices/types/Gender.js +1 -4
- package/api/resources/voices/types/IdSpecifier.js +1 -2
- package/api/resources/voices/types/LocalizeDialect.js +1 -4
- package/api/resources/voices/types/LocalizeTargetLanguage.js +1 -4
- package/api/resources/voices/types/LocalizeVoiceRequest.js +1 -2
- package/api/resources/voices/types/MixVoiceSpecifier.js +1 -2
- package/api/resources/voices/types/MixVoicesRequest.js +1 -2
- package/api/resources/voices/types/UpdateVoiceRequest.js +1 -2
- package/api/resources/voices/types/Voice.js +1 -2
- package/api/resources/voices/types/VoiceId.js +1 -2
- package/api/resources/voices/types/VoiceMetadata.js +1 -2
- package/api/resources/voices/types/Weight.js +1 -2
- package/api/resources/voices/types/index.js +17 -33
- package/core/fetcher/APIResponse.js +1 -2
- package/core/fetcher/Fetcher.js +14 -18
- package/core/fetcher/Supplier.js +1 -4
- package/core/fetcher/createRequestUrl.js +3 -10
- package/core/fetcher/getFetchFn.js +6 -33
- package/core/fetcher/getHeader.js +1 -5
- package/core/fetcher/getRequestBody.js +1 -5
- package/core/fetcher/getResponseBody.js +3 -7
- package/core/fetcher/index.js +3 -9
- package/core/fetcher/makeRequest.js +4 -8
- package/core/fetcher/requestWithRetries.js +1 -5
- package/core/fetcher/signals.js +2 -7
- package/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +1 -5
- package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +7 -34
- package/core/form-data-utils/FormDataWrapper.js +11 -41
- package/core/form-data-utils/index.js +1 -17
- package/core/index.js +5 -34
- package/core/runtime/index.js +1 -5
- package/core/runtime/runtime.js +1 -4
- package/core/schemas/Schema.js +1 -4
- package/core/schemas/builders/bigint/bigint.js +9 -13
- package/core/schemas/builders/bigint/index.js +1 -5
- package/core/schemas/builders/date/date.js +10 -14
- package/core/schemas/builders/date/index.js +1 -5
- package/core/schemas/builders/enum/enum.js +7 -11
- package/core/schemas/builders/enum/index.js +1 -5
- package/core/schemas/builders/index.js +14 -30
- package/core/schemas/builders/lazy/index.js +2 -7
- package/core/schemas/builders/lazy/lazy.js +5 -11
- package/core/schemas/builders/lazy/lazyObject.js +7 -11
- package/core/schemas/builders/list/index.js +1 -5
- package/core/schemas/builders/list/list.js +8 -12
- package/core/schemas/builders/literals/booleanLiteral.js +6 -10
- package/core/schemas/builders/literals/index.js +2 -7
- package/core/schemas/builders/literals/stringLiteral.js +6 -10
- package/core/schemas/builders/object/index.js +3 -11
- package/core/schemas/builders/object/object.js +33 -38
- package/core/schemas/builders/object/objectWithoutOptionalProperties.js +3 -7
- package/core/schemas/builders/object/property.js +2 -7
- package/core/schemas/builders/object/types.js +1 -2
- package/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -15
- package/core/schemas/builders/object-like/index.js +1 -6
- package/core/schemas/builders/object-like/types.js +1 -2
- package/core/schemas/builders/primitives/any.js +3 -6
- package/core/schemas/builders/primitives/boolean.js +5 -8
- package/core/schemas/builders/primitives/index.js +5 -13
- package/core/schemas/builders/primitives/number.js +5 -8
- package/core/schemas/builders/primitives/string.js +5 -8
- package/core/schemas/builders/primitives/unknown.js +3 -6
- package/core/schemas/builders/record/index.js +1 -5
- package/core/schemas/builders/record/record.js +14 -18
- package/core/schemas/builders/record/types.js +1 -2
- package/core/schemas/builders/schema-utils/JsonError.js +3 -7
- package/core/schemas/builders/schema-utils/ParseError.js +3 -7
- package/core/schemas/builders/schema-utils/getSchemaUtils.js +9 -15
- package/core/schemas/builders/schema-utils/index.js +3 -11
- package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -5
- package/core/schemas/builders/set/index.js +1 -5
- package/core/schemas/builders/set/set.js +10 -14
- package/core/schemas/builders/undiscriminated-union/index.js +1 -5
- package/core/schemas/builders/undiscriminated-union/types.js +1 -2
- package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +6 -10
- package/core/schemas/builders/union/discriminant.js +1 -5
- package/core/schemas/builders/union/index.js +2 -7
- package/core/schemas/builders/union/types.js +1 -2
- package/core/schemas/builders/union/union.js +14 -18
- package/core/schemas/index.js +1 -17
- package/core/schemas/utils/MaybePromise.js +1 -2
- package/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -2
- package/core/schemas/utils/createIdentitySchemaCreator.js +4 -8
- package/core/schemas/utils/entries.js +1 -5
- package/core/schemas/utils/filterObject.js +1 -5
- package/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -5
- package/core/schemas/utils/isPlainObject.js +1 -5
- package/core/schemas/utils/keys.js +1 -5
- package/core/schemas/utils/maybeSkipValidation.js +1 -5
- package/core/schemas/utils/partition.js +1 -5
- package/core/streaming-fetcher/Stream.js +4 -9
- package/core/streaming-fetcher/index.js +1 -5
- package/core/websocket/events.js +3 -9
- package/core/websocket/index.js +1 -17
- package/core/websocket/ws.js +6 -33
- package/dist/Client.js +9 -13
- package/dist/api/index.js +1 -17
- package/dist/api/resources/apiStatus/client/Client.js +6 -33
- package/dist/api/resources/apiStatus/client/index.js +1 -2
- package/dist/api/resources/apiStatus/index.js +2 -18
- package/dist/api/resources/apiStatus/types/ApiInfo.js +1 -2
- package/dist/api/resources/apiStatus/types/index.js +1 -17
- package/dist/api/resources/embedding/index.js +1 -17
- package/dist/api/resources/embedding/types/Embedding.js +1 -2
- package/dist/api/resources/embedding/types/index.js +1 -17
- package/dist/api/resources/index.js +12 -41
- package/dist/api/resources/tts/client/Client.js +10 -40
- package/dist/api/resources/tts/client/index.js +1 -2
- package/dist/api/resources/tts/index.js +2 -18
- package/dist/api/resources/tts/types/CancelContextRequest.js +1 -2
- package/dist/api/resources/tts/types/ContextId.js +1 -2
- package/dist/api/resources/tts/types/Controls.js +1 -2
- package/dist/api/resources/tts/types/Emotion.js +1 -4
- package/dist/api/resources/tts/types/GenerationRequest.js +1 -2
- package/dist/api/resources/tts/types/Mp3OutputFormat.js +1 -2
- package/dist/api/resources/tts/types/NaturalSpecifier.js +1 -4
- package/dist/api/resources/tts/types/NumericalSpecifier.js +1 -2
- package/dist/api/resources/tts/types/OutputFormat.js +1 -2
- package/dist/api/resources/tts/types/RawEncoding.js +1 -4
- package/dist/api/resources/tts/types/RawOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/Speed.js +1 -2
- package/dist/api/resources/tts/types/SupportedLanguage.js +1 -4
- package/dist/api/resources/tts/types/TtsRequest.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestEmbeddingSpecifier.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestIdSpecifier.js +1 -2
- package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.js +1 -2
- package/dist/api/resources/tts/types/WavOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/WebSocketBaseResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketChunkResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketDoneResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketErrorResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketRawOutputFormat.js +1 -2
- package/dist/api/resources/tts/types/WebSocketRequest.js +1 -2
- package/dist/api/resources/tts/types/WebSocketResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketStreamOptions.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTimestampsResponse.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTtsOutput.js +1 -2
- package/dist/api/resources/tts/types/WebSocketTtsRequest.js +1 -2
- package/dist/api/resources/tts/types/WordTimestamps.js +1 -2
- package/dist/api/resources/tts/types/index.js +30 -46
- package/dist/api/resources/voiceChanger/client/Client.js +10 -40
- package/dist/api/resources/voiceChanger/client/index.js +1 -17
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerBytesRequest.js +1 -2
- package/dist/api/resources/voiceChanger/client/requests/VoiceChangerSseRequest.js +1 -2
- package/dist/api/resources/voiceChanger/client/requests/index.js +1 -2
- package/dist/api/resources/voiceChanger/index.js +2 -18
- package/dist/api/resources/voiceChanger/types/OutputFormatContainer.js +1 -4
- package/dist/api/resources/voiceChanger/types/StreamingResponse.js +1 -2
- package/dist/api/resources/voiceChanger/types/index.js +2 -18
- package/dist/api/resources/voices/client/Client.js +22 -52
- package/dist/api/resources/voices/client/index.js +1 -17
- package/dist/api/resources/voices/client/requests/CloneVoiceRequest.js +1 -2
- package/dist/api/resources/voices/client/requests/index.js +1 -2
- package/dist/api/resources/voices/index.js +2 -18
- package/dist/api/resources/voices/types/BaseVoiceId.js +1 -2
- package/dist/api/resources/voices/types/CloneMode.js +1 -4
- package/dist/api/resources/voices/types/CreateVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/EmbeddingResponse.js +1 -2
- package/dist/api/resources/voices/types/EmbeddingSpecifier.js +1 -2
- package/dist/api/resources/voices/types/Gender.js +1 -4
- package/dist/api/resources/voices/types/IdSpecifier.js +1 -2
- package/dist/api/resources/voices/types/LocalizeDialect.js +1 -4
- package/dist/api/resources/voices/types/LocalizeTargetLanguage.js +1 -4
- package/dist/api/resources/voices/types/LocalizeVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/MixVoiceSpecifier.js +1 -2
- package/dist/api/resources/voices/types/MixVoicesRequest.js +1 -2
- package/dist/api/resources/voices/types/UpdateVoiceRequest.js +1 -2
- package/dist/api/resources/voices/types/Voice.js +1 -2
- package/dist/api/resources/voices/types/VoiceId.js +1 -2
- package/dist/api/resources/voices/types/VoiceMetadata.js +1 -2
- package/dist/api/resources/voices/types/Weight.js +1 -2
- package/dist/api/resources/voices/types/index.js +17 -33
- package/dist/core/fetcher/APIResponse.js +1 -2
- package/dist/core/fetcher/Fetcher.js +14 -18
- package/dist/core/fetcher/Supplier.js +1 -4
- package/dist/core/fetcher/createRequestUrl.js +3 -10
- package/dist/core/fetcher/getFetchFn.js +6 -33
- package/dist/core/fetcher/getHeader.js +1 -5
- package/dist/core/fetcher/getRequestBody.js +1 -5
- package/dist/core/fetcher/getResponseBody.js +3 -7
- package/dist/core/fetcher/index.js +3 -9
- package/dist/core/fetcher/makeRequest.js +4 -8
- package/dist/core/fetcher/requestWithRetries.js +1 -5
- package/dist/core/fetcher/signals.js +2 -7
- package/dist/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.js +1 -5
- package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +7 -34
- package/dist/core/form-data-utils/FormDataWrapper.js +11 -41
- package/dist/core/form-data-utils/index.js +1 -17
- package/dist/core/index.js +5 -34
- package/dist/core/runtime/index.js +1 -5
- package/dist/core/runtime/runtime.js +1 -4
- package/dist/core/schemas/Schema.js +1 -4
- package/dist/core/schemas/builders/bigint/bigint.js +9 -13
- package/dist/core/schemas/builders/bigint/index.js +1 -5
- package/dist/core/schemas/builders/date/date.js +10 -14
- package/dist/core/schemas/builders/date/index.js +1 -5
- package/dist/core/schemas/builders/enum/enum.js +7 -11
- package/dist/core/schemas/builders/enum/index.js +1 -5
- package/dist/core/schemas/builders/index.js +14 -30
- package/dist/core/schemas/builders/lazy/index.js +2 -7
- package/dist/core/schemas/builders/lazy/lazy.js +5 -11
- package/dist/core/schemas/builders/lazy/lazyObject.js +7 -11
- package/dist/core/schemas/builders/list/index.js +1 -5
- package/dist/core/schemas/builders/list/list.js +8 -12
- package/dist/core/schemas/builders/literals/booleanLiteral.js +6 -10
- package/dist/core/schemas/builders/literals/index.js +2 -7
- package/dist/core/schemas/builders/literals/stringLiteral.js +6 -10
- package/dist/core/schemas/builders/object/index.js +3 -11
- package/dist/core/schemas/builders/object/object.js +33 -38
- package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +3 -7
- package/dist/core/schemas/builders/object/property.js +2 -7
- package/dist/core/schemas/builders/object/types.js +1 -2
- package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +10 -15
- package/dist/core/schemas/builders/object-like/index.js +1 -6
- package/dist/core/schemas/builders/object-like/types.js +1 -2
- package/dist/core/schemas/builders/primitives/any.js +3 -6
- package/dist/core/schemas/builders/primitives/boolean.js +5 -8
- package/dist/core/schemas/builders/primitives/index.js +5 -13
- package/dist/core/schemas/builders/primitives/number.js +5 -8
- package/dist/core/schemas/builders/primitives/string.js +5 -8
- package/dist/core/schemas/builders/primitives/unknown.js +3 -6
- package/dist/core/schemas/builders/record/index.js +1 -5
- package/dist/core/schemas/builders/record/record.js +14 -18
- package/dist/core/schemas/builders/record/types.js +1 -2
- package/dist/core/schemas/builders/schema-utils/JsonError.js +3 -7
- package/dist/core/schemas/builders/schema-utils/ParseError.js +3 -7
- package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +9 -15
- package/dist/core/schemas/builders/schema-utils/index.js +3 -11
- package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -5
- package/dist/core/schemas/builders/set/index.js +1 -5
- package/dist/core/schemas/builders/set/set.js +10 -14
- package/dist/core/schemas/builders/undiscriminated-union/index.js +1 -5
- package/dist/core/schemas/builders/undiscriminated-union/types.js +1 -2
- package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +6 -10
- package/dist/core/schemas/builders/union/discriminant.js +1 -5
- package/dist/core/schemas/builders/union/index.js +2 -7
- package/dist/core/schemas/builders/union/types.js +1 -2
- package/dist/core/schemas/builders/union/union.js +14 -18
- package/dist/core/schemas/index.js +1 -17
- package/dist/core/schemas/utils/MaybePromise.js +1 -2
- package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.js +1 -2
- package/dist/core/schemas/utils/createIdentitySchemaCreator.js +4 -8
- package/dist/core/schemas/utils/entries.js +1 -5
- package/dist/core/schemas/utils/filterObject.js +1 -5
- package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -5
- package/dist/core/schemas/utils/isPlainObject.js +1 -5
- package/dist/core/schemas/utils/keys.js +1 -5
- package/dist/core/schemas/utils/maybeSkipValidation.js +1 -5
- package/dist/core/schemas/utils/partition.js +1 -5
- package/dist/core/streaming-fetcher/Stream.js +4 -9
- package/dist/core/streaming-fetcher/index.js +1 -5
- package/dist/core/websocket/events.js +3 -9
- package/dist/core/websocket/index.js +1 -17
- package/dist/core/websocket/ws.js +6 -33
- package/dist/environments.js +1 -4
- package/dist/errors/CartesiaError.js +1 -5
- package/dist/errors/CartesiaTimeoutError.js +1 -5
- package/dist/errors/index.js +2 -7
- package/dist/index.js +4 -34
- package/dist/serialization/index.js +1 -17
- package/dist/serialization/resources/apiStatus/index.js +1 -17
- package/dist/serialization/resources/apiStatus/types/ApiInfo.js +2 -28
- package/dist/serialization/resources/apiStatus/types/index.js +1 -17
- package/dist/serialization/resources/embedding/index.js +1 -17
- package/dist/serialization/resources/embedding/types/Embedding.js +2 -28
- package/dist/serialization/resources/embedding/types/index.js +1 -17
- package/dist/serialization/resources/index.js +10 -39
- package/dist/serialization/resources/tts/index.js +1 -17
- package/dist/serialization/resources/tts/types/CancelContextRequest.js +4 -30
- package/dist/serialization/resources/tts/types/ContextId.js +2 -28
- package/dist/serialization/resources/tts/types/Controls.js +6 -32
- package/dist/serialization/resources/tts/types/Emotion.js +2 -28
- package/dist/serialization/resources/tts/types/GenerationRequest.js +10 -36
- package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +2 -28
- package/dist/serialization/resources/tts/types/NaturalSpecifier.js +2 -28
- package/dist/serialization/resources/tts/types/NumericalSpecifier.js +2 -28
- package/dist/serialization/resources/tts/types/OutputFormat.js +8 -34
- package/dist/serialization/resources/tts/types/RawEncoding.js +2 -28
- package/dist/serialization/resources/tts/types/RawOutputFormat.js +4 -30
- package/dist/serialization/resources/tts/types/Speed.js +4 -30
- package/dist/serialization/resources/tts/types/SupportedLanguage.js +2 -28
- package/dist/serialization/resources/tts/types/TtsRequest.js +8 -34
- package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +6 -32
- package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +6 -32
- package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +4 -30
- package/dist/serialization/resources/tts/types/WavOutputFormat.js +3 -29
- package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +3 -29
- package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketRequest.js +4 -30
- package/dist/serialization/resources/tts/types/WebSocketResponse.js +10 -36
- package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +2 -28
- package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +6 -32
- package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +6 -32
- package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +6 -32
- package/dist/serialization/resources/tts/types/WordTimestamps.js +2 -28
- package/dist/serialization/resources/tts/types/index.js +30 -46
- package/dist/serialization/resources/voiceChanger/index.js +1 -17
- package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +2 -28
- package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +8 -34
- package/dist/serialization/resources/voiceChanger/types/index.js +2 -18
- package/dist/serialization/resources/voices/client/index.js +1 -27
- package/dist/serialization/resources/voices/client/list.js +3 -29
- package/dist/serialization/resources/voices/index.js +2 -18
- package/dist/serialization/resources/voices/types/BaseVoiceId.js +2 -5
- package/dist/serialization/resources/voices/types/CloneMode.js +2 -28
- package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +8 -34
- package/dist/serialization/resources/voices/types/EmbeddingResponse.js +4 -30
- package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +6 -32
- package/dist/serialization/resources/voices/types/Gender.js +2 -28
- package/dist/serialization/resources/voices/types/IdSpecifier.js +6 -32
- package/dist/serialization/resources/voices/types/LocalizeDialect.js +2 -28
- package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +2 -28
- package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +10 -36
- package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +4 -30
- package/dist/serialization/resources/voices/types/MixVoicesRequest.js +4 -30
- package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +2 -28
- package/dist/serialization/resources/voices/types/Voice.js +10 -36
- package/dist/serialization/resources/voices/types/VoiceId.js +2 -28
- package/dist/serialization/resources/voices/types/VoiceMetadata.js +6 -32
- package/dist/serialization/resources/voices/types/Weight.js +2 -28
- package/dist/serialization/resources/voices/types/index.js +17 -33
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -4
- package/dist/wrapper/Client.js +4 -8
- package/dist/wrapper/StreamingTTSClient.js +4 -11
- package/dist/wrapper/WebPlayer.js +3 -7
- package/dist/wrapper/Websocket.js +23 -52
- package/dist/wrapper/source.js +5 -11
- package/dist/wrapper/utils.js +13 -28
- package/environments.js +1 -4
- package/errors/CartesiaError.js +1 -5
- package/errors/CartesiaTimeoutError.js +1 -5
- package/errors/index.js +2 -7
- package/index.js +4 -34
- package/package.json +3 -2
- package/serialization/index.js +1 -17
- package/serialization/resources/apiStatus/index.js +1 -17
- package/serialization/resources/apiStatus/types/ApiInfo.js +2 -28
- package/serialization/resources/apiStatus/types/index.js +1 -17
- package/serialization/resources/embedding/index.js +1 -17
- package/serialization/resources/embedding/types/Embedding.js +2 -28
- package/serialization/resources/embedding/types/index.js +1 -17
- package/serialization/resources/index.js +10 -39
- package/serialization/resources/tts/index.js +1 -17
- package/serialization/resources/tts/types/CancelContextRequest.js +4 -30
- package/serialization/resources/tts/types/ContextId.js +2 -28
- package/serialization/resources/tts/types/Controls.js +6 -32
- package/serialization/resources/tts/types/Emotion.js +2 -28
- package/serialization/resources/tts/types/GenerationRequest.js +10 -36
- package/serialization/resources/tts/types/Mp3OutputFormat.js +2 -28
- package/serialization/resources/tts/types/NaturalSpecifier.js +2 -28
- package/serialization/resources/tts/types/NumericalSpecifier.js +2 -28
- package/serialization/resources/tts/types/OutputFormat.js +8 -34
- package/serialization/resources/tts/types/RawEncoding.js +2 -28
- package/serialization/resources/tts/types/RawOutputFormat.js +4 -30
- package/serialization/resources/tts/types/Speed.js +4 -30
- package/serialization/resources/tts/types/SupportedLanguage.js +2 -28
- package/serialization/resources/tts/types/TtsRequest.js +8 -34
- package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +6 -32
- package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +6 -32
- package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +4 -30
- package/serialization/resources/tts/types/WavOutputFormat.js +3 -29
- package/serialization/resources/tts/types/WebSocketBaseResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketChunkResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketDoneResponse.js +3 -29
- package/serialization/resources/tts/types/WebSocketErrorResponse.js +4 -30
- package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +4 -30
- package/serialization/resources/tts/types/WebSocketRequest.js +4 -30
- package/serialization/resources/tts/types/WebSocketResponse.js +10 -36
- package/serialization/resources/tts/types/WebSocketStreamOptions.js +2 -28
- package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +6 -32
- package/serialization/resources/tts/types/WebSocketTtsOutput.js +6 -32
- package/serialization/resources/tts/types/WebSocketTtsRequest.js +6 -32
- package/serialization/resources/tts/types/WordTimestamps.js +2 -28
- package/serialization/resources/tts/types/index.js +30 -46
- package/serialization/resources/voiceChanger/index.js +1 -17
- package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +2 -28
- package/serialization/resources/voiceChanger/types/StreamingResponse.js +8 -34
- package/serialization/resources/voiceChanger/types/index.js +2 -18
- package/serialization/resources/voices/client/index.js +1 -27
- package/serialization/resources/voices/client/list.js +3 -29
- package/serialization/resources/voices/index.js +2 -18
- package/serialization/resources/voices/types/BaseVoiceId.js +2 -5
- package/serialization/resources/voices/types/CloneMode.js +2 -28
- package/serialization/resources/voices/types/CreateVoiceRequest.js +8 -34
- package/serialization/resources/voices/types/EmbeddingResponse.js +4 -30
- package/serialization/resources/voices/types/EmbeddingSpecifier.js +6 -32
- package/serialization/resources/voices/types/Gender.js +2 -28
- package/serialization/resources/voices/types/IdSpecifier.js +6 -32
- package/serialization/resources/voices/types/LocalizeDialect.js +2 -28
- package/serialization/resources/voices/types/LocalizeTargetLanguage.js +2 -28
- package/serialization/resources/voices/types/LocalizeVoiceRequest.js +10 -36
- package/serialization/resources/voices/types/MixVoiceSpecifier.js +4 -30
- package/serialization/resources/voices/types/MixVoicesRequest.js +4 -30
- package/serialization/resources/voices/types/UpdateVoiceRequest.js +2 -28
- package/serialization/resources/voices/types/Voice.js +10 -36
- package/serialization/resources/voices/types/VoiceId.js +2 -28
- package/serialization/resources/voices/types/VoiceMetadata.js +6 -32
- package/serialization/resources/voices/types/Weight.js +2 -28
- package/serialization/resources/voices/types/index.js +17 -33
- package/version.d.ts +1 -1
- package/version.js +1 -4
- package/wrapper/Client.js +4 -8
- package/wrapper/StreamingTTSClient.js +4 -11
- package/wrapper/WebPlayer.js +3 -7
- package/wrapper/Websocket.js +23 -52
- package/wrapper/source.js +5 -11
- package/wrapper/utils.js +13 -28
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const schema_utils_1 = require("../schema-utils");
|
|
14
|
-
const property_1 = require("./property");
|
|
15
|
-
function object(schemas) {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { entries } from "../../utils/entries";
|
|
3
|
+
import { filterObject } from "../../utils/filterObject";
|
|
4
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
5
|
+
import { isPlainObject } from "../../utils/isPlainObject";
|
|
6
|
+
import { keys } from "../../utils/keys";
|
|
7
|
+
import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
|
|
8
|
+
import { partition } from "../../utils/partition";
|
|
9
|
+
import { getObjectLikeUtils } from "../object-like";
|
|
10
|
+
import { getSchemaUtils } from "../schema-utils";
|
|
11
|
+
import { isProperty } from "./property";
|
|
12
|
+
export function object(schemas) {
|
|
16
13
|
const baseSchema = {
|
|
17
|
-
_getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) =>
|
|
18
|
-
_getParsedProperties: () =>
|
|
14
|
+
_getRawProperties: () => Object.entries(schemas).map(([parsedKey, propertySchema]) => isProperty(propertySchema) ? propertySchema.rawKey : parsedKey),
|
|
15
|
+
_getParsedProperties: () => keys(schemas),
|
|
19
16
|
parse: (raw, opts) => {
|
|
20
17
|
const rawKeyToProperty = {};
|
|
21
18
|
const requiredKeys = [];
|
|
22
|
-
for (const [parsedKey, schemaOrObjectProperty] of
|
|
23
|
-
const rawKey =
|
|
24
|
-
const valueSchema =
|
|
19
|
+
for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
|
|
20
|
+
const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey;
|
|
21
|
+
const valueSchema = isProperty(schemaOrObjectProperty)
|
|
25
22
|
? schemaOrObjectProperty.valueSchema
|
|
26
23
|
: schemaOrObjectProperty;
|
|
27
24
|
const property = {
|
|
@@ -58,8 +55,8 @@ function object(schemas) {
|
|
|
58
55
|
},
|
|
59
56
|
json: (parsed, opts) => {
|
|
60
57
|
const requiredKeys = [];
|
|
61
|
-
for (const [parsedKey, schemaOrObjectProperty] of
|
|
62
|
-
const valueSchema =
|
|
58
|
+
for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) {
|
|
59
|
+
const valueSchema = isProperty(schemaOrObjectProperty)
|
|
63
60
|
? schemaOrObjectProperty.valueSchema
|
|
64
61
|
: schemaOrObjectProperty;
|
|
65
62
|
if (isSchemaRequired(valueSchema)) {
|
|
@@ -75,7 +72,7 @@ function object(schemas) {
|
|
|
75
72
|
if (property == null) {
|
|
76
73
|
return undefined;
|
|
77
74
|
}
|
|
78
|
-
if (
|
|
75
|
+
if (isProperty(property)) {
|
|
79
76
|
return {
|
|
80
77
|
transformedKey: property.rawKey,
|
|
81
78
|
transform: (propertyValue) => {
|
|
@@ -100,19 +97,18 @@ function object(schemas) {
|
|
|
100
97
|
omitUndefined: opts === null || opts === void 0 ? void 0 : opts.omitUndefined,
|
|
101
98
|
});
|
|
102
99
|
},
|
|
103
|
-
getType: () =>
|
|
100
|
+
getType: () => SchemaType.OBJECT,
|
|
104
101
|
};
|
|
105
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({},
|
|
102
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema)), getObjectLikeUtils(baseSchema)), getObjectUtils(baseSchema));
|
|
106
103
|
}
|
|
107
|
-
exports.object = object;
|
|
108
104
|
function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
|
|
109
|
-
if (!
|
|
105
|
+
if (!isPlainObject(value)) {
|
|
110
106
|
return {
|
|
111
107
|
ok: false,
|
|
112
108
|
errors: [
|
|
113
109
|
{
|
|
114
110
|
path: breadcrumbsPrefix,
|
|
115
|
-
message:
|
|
111
|
+
message: getErrorMessageForIncorrectType(value, "object"),
|
|
116
112
|
},
|
|
117
113
|
],
|
|
118
114
|
};
|
|
@@ -168,7 +164,7 @@ function validateAndTransformObject({ value, requiredKeys, getProperty, unrecogn
|
|
|
168
164
|
};
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
|
-
function getObjectUtils(schema) {
|
|
167
|
+
export function getObjectUtils(schema) {
|
|
172
168
|
return {
|
|
173
169
|
extend: (extension) => {
|
|
174
170
|
const baseSchema = {
|
|
@@ -190,18 +186,17 @@ function getObjectUtils(schema) {
|
|
|
190
186
|
transformExtension: (parsedExtension) => extension.json(parsedExtension, opts),
|
|
191
187
|
});
|
|
192
188
|
},
|
|
193
|
-
getType: () =>
|
|
189
|
+
getType: () => SchemaType.OBJECT,
|
|
194
190
|
};
|
|
195
|
-
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema),
|
|
191
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema)), getObjectLikeUtils(baseSchema)), getObjectUtils(baseSchema));
|
|
196
192
|
},
|
|
197
193
|
};
|
|
198
194
|
}
|
|
199
|
-
exports.getObjectUtils = getObjectUtils;
|
|
200
195
|
function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
|
|
201
196
|
const extensionPropertiesSet = new Set(extensionKeys);
|
|
202
|
-
const [extensionProperties, baseProperties] =
|
|
203
|
-
const transformedBase = transformBase(
|
|
204
|
-
const transformedExtension = transformExtension(
|
|
197
|
+
const [extensionProperties, baseProperties] = partition(keys(value), (key) => extensionPropertiesSet.has(key));
|
|
198
|
+
const transformedBase = transformBase(filterObject(value, baseProperties));
|
|
199
|
+
const transformedExtension = transformExtension(filterObject(value, extensionProperties));
|
|
205
200
|
if (transformedBase.ok && transformedExtension.ok) {
|
|
206
201
|
return {
|
|
207
202
|
ok: true,
|
|
@@ -223,9 +218,9 @@ function isSchemaRequired(schema) {
|
|
|
223
218
|
}
|
|
224
219
|
function isSchemaOptional(schema) {
|
|
225
220
|
switch (schema.getType()) {
|
|
226
|
-
case
|
|
227
|
-
case
|
|
228
|
-
case
|
|
221
|
+
case SchemaType.ANY:
|
|
222
|
+
case SchemaType.UNKNOWN:
|
|
223
|
+
case SchemaType.OPTIONAL:
|
|
229
224
|
return true;
|
|
230
225
|
default:
|
|
231
226
|
return false;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const object_1 = require("./object");
|
|
5
|
-
function objectWithoutOptionalProperties(schemas) {
|
|
6
|
-
return (0, object_1.object)(schemas);
|
|
1
|
+
import { object } from "./object";
|
|
2
|
+
export function objectWithoutOptionalProperties(schemas) {
|
|
3
|
+
return object(schemas);
|
|
7
4
|
}
|
|
8
|
-
exports.objectWithoutOptionalProperties = objectWithoutOptionalProperties;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isProperty = exports.property = void 0;
|
|
4
|
-
function property(rawKey, valueSchema) {
|
|
1
|
+
export function property(rawKey, valueSchema) {
|
|
5
2
|
return {
|
|
6
3
|
rawKey,
|
|
7
4
|
valueSchema,
|
|
8
5
|
isProperty: true,
|
|
9
6
|
};
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
function isProperty(maybeProperty) {
|
|
8
|
+
export function isProperty(maybeProperty) {
|
|
13
9
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
14
10
|
return maybeProperty.isProperty;
|
|
15
11
|
}
|
|
16
|
-
exports.isProperty = isProperty;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const isPlainObject_1 = require("../../utils/isPlainObject");
|
|
7
|
-
const schema_utils_1 = require("../schema-utils");
|
|
8
|
-
function getObjectLikeUtils(schema) {
|
|
1
|
+
import { filterObject } from "../../utils/filterObject";
|
|
2
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
3
|
+
import { isPlainObject } from "../../utils/isPlainObject";
|
|
4
|
+
import { getSchemaUtils } from "../schema-utils";
|
|
5
|
+
export function getObjectLikeUtils(schema) {
|
|
9
6
|
return {
|
|
10
7
|
withParsedProperties: (properties) => withParsedProperties(schema, properties),
|
|
11
8
|
};
|
|
12
9
|
}
|
|
13
|
-
exports.getObjectLikeUtils = getObjectLikeUtils;
|
|
14
10
|
/**
|
|
15
11
|
* object-like utils are defined in one file to resolve issues with circular imports
|
|
16
12
|
*/
|
|
17
|
-
function withParsedProperties(objectLike, properties) {
|
|
13
|
+
export function withParsedProperties(objectLike, properties) {
|
|
18
14
|
const objectSchema = {
|
|
19
15
|
parse: (raw, opts) => {
|
|
20
16
|
const parsedObject = objectLike.parse(raw, opts);
|
|
@@ -31,24 +27,23 @@ function withParsedProperties(objectLike, properties) {
|
|
|
31
27
|
},
|
|
32
28
|
json: (parsed, opts) => {
|
|
33
29
|
var _a;
|
|
34
|
-
if (!
|
|
30
|
+
if (!isPlainObject(parsed)) {
|
|
35
31
|
return {
|
|
36
32
|
ok: false,
|
|
37
33
|
errors: [
|
|
38
34
|
{
|
|
39
35
|
path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [],
|
|
40
|
-
message:
|
|
36
|
+
message: getErrorMessageForIncorrectType(parsed, "object"),
|
|
41
37
|
},
|
|
42
38
|
],
|
|
43
39
|
};
|
|
44
40
|
}
|
|
45
41
|
// strip out added properties
|
|
46
42
|
const addedPropertyKeys = new Set(Object.keys(properties));
|
|
47
|
-
const parsedWithoutAddedProperties =
|
|
43
|
+
const parsedWithoutAddedProperties = filterObject(parsed, Object.keys(parsed).filter((key) => !addedPropertyKeys.has(key)));
|
|
48
44
|
return objectLike.json(parsedWithoutAddedProperties, opts);
|
|
49
45
|
},
|
|
50
46
|
getType: () => objectLike.getType(),
|
|
51
47
|
};
|
|
52
|
-
return Object.assign(Object.assign(Object.assign({}, objectSchema),
|
|
48
|
+
return Object.assign(Object.assign(Object.assign({}, objectSchema), getSchemaUtils(objectSchema)), getObjectLikeUtils(objectSchema));
|
|
53
49
|
}
|
|
54
|
-
exports.withParsedProperties = withParsedProperties;
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.withParsedProperties = exports.getObjectLikeUtils = void 0;
|
|
4
|
-
var getObjectLikeUtils_1 = require("./getObjectLikeUtils");
|
|
5
|
-
Object.defineProperty(exports, "getObjectLikeUtils", { enumerable: true, get: function () { return getObjectLikeUtils_1.getObjectLikeUtils; } });
|
|
6
|
-
Object.defineProperty(exports, "withParsedProperties", { enumerable: true, get: function () { return getObjectLikeUtils_1.withParsedProperties; } });
|
|
1
|
+
export { getObjectLikeUtils, withParsedProperties } from "./getObjectLikeUtils";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Schema_1 = require("../../Schema");
|
|
5
|
-
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
exports.any = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.ANY, (value) => ({ ok: true, value }));
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator";
|
|
3
|
+
export const any = createIdentitySchemaCreator(SchemaType.ANY, (value) => ({ ok: true, value }));
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
-
exports.boolean = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.BOOLEAN, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator";
|
|
3
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
4
|
+
export const boolean = createIdentitySchemaCreator(SchemaType.BOOLEAN, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
8
5
|
if (typeof value === "boolean") {
|
|
9
6
|
return {
|
|
10
7
|
ok: true,
|
|
@@ -17,7 +14,7 @@ exports.boolean = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)
|
|
|
17
14
|
errors: [
|
|
18
15
|
{
|
|
19
16
|
path: breadcrumbsPrefix,
|
|
20
|
-
message:
|
|
17
|
+
message: getErrorMessageForIncorrectType(value, "boolean"),
|
|
21
18
|
},
|
|
22
19
|
],
|
|
23
20
|
};
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var boolean_1 = require("./boolean");
|
|
7
|
-
Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return boolean_1.boolean; } });
|
|
8
|
-
var number_1 = require("./number");
|
|
9
|
-
Object.defineProperty(exports, "number", { enumerable: true, get: function () { return number_1.number; } });
|
|
10
|
-
var string_1 = require("./string");
|
|
11
|
-
Object.defineProperty(exports, "string", { enumerable: true, get: function () { return string_1.string; } });
|
|
12
|
-
var unknown_1 = require("./unknown");
|
|
13
|
-
Object.defineProperty(exports, "unknown", { enumerable: true, get: function () { return unknown_1.unknown; } });
|
|
1
|
+
export { any } from "./any";
|
|
2
|
+
export { boolean } from "./boolean";
|
|
3
|
+
export { number } from "./number";
|
|
4
|
+
export { string } from "./string";
|
|
5
|
+
export { unknown } from "./unknown";
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
-
exports.number = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.NUMBER, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator";
|
|
3
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
4
|
+
export const number = createIdentitySchemaCreator(SchemaType.NUMBER, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
8
5
|
if (typeof value === "number") {
|
|
9
6
|
return {
|
|
10
7
|
ok: true,
|
|
@@ -17,7 +14,7 @@ exports.number = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(
|
|
|
17
14
|
errors: [
|
|
18
15
|
{
|
|
19
16
|
path: breadcrumbsPrefix,
|
|
20
|
-
message:
|
|
17
|
+
message: getErrorMessageForIncorrectType(value, "number"),
|
|
21
18
|
},
|
|
22
19
|
],
|
|
23
20
|
};
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
|
|
7
|
-
exports.string = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.STRING, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator";
|
|
3
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
4
|
+
export const string = createIdentitySchemaCreator(SchemaType.STRING, (value, { breadcrumbsPrefix = [] } = {}) => {
|
|
8
5
|
if (typeof value === "string") {
|
|
9
6
|
return {
|
|
10
7
|
ok: true,
|
|
@@ -17,7 +14,7 @@ exports.string = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(
|
|
|
17
14
|
errors: [
|
|
18
15
|
{
|
|
19
16
|
path: breadcrumbsPrefix,
|
|
20
|
-
message:
|
|
17
|
+
message: getErrorMessageForIncorrectType(value, "string"),
|
|
21
18
|
},
|
|
22
19
|
],
|
|
23
20
|
};
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Schema_1 = require("../../Schema");
|
|
5
|
-
const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
|
|
6
|
-
exports.unknown = (0, createIdentitySchemaCreator_1.createIdentitySchemaCreator)(Schema_1.SchemaType.UNKNOWN, (value) => ({ ok: true, value }));
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator";
|
|
3
|
+
export const unknown = createIdentitySchemaCreator(SchemaType.UNKNOWN, (value) => ({ ok: true, value }));
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.record = void 0;
|
|
4
|
-
var record_1 = require("./record");
|
|
5
|
-
Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
|
|
1
|
+
export { record } from "./record";
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
|
|
9
|
-
const schema_utils_1 = require("../schema-utils");
|
|
10
|
-
function record(keySchema, valueSchema) {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { entries } from "../../utils/entries";
|
|
3
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
4
|
+
import { isPlainObject } from "../../utils/isPlainObject";
|
|
5
|
+
import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
|
|
6
|
+
import { getSchemaUtils } from "../schema-utils";
|
|
7
|
+
export function record(keySchema, valueSchema) {
|
|
11
8
|
const baseSchema = {
|
|
12
9
|
parse: (raw, opts) => {
|
|
13
10
|
return validateAndTransformRecord({
|
|
14
11
|
value: raw,
|
|
15
|
-
isKeyNumeric: keySchema.getType() ===
|
|
12
|
+
isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
|
|
16
13
|
transformKey: (key) => {
|
|
17
14
|
var _a;
|
|
18
15
|
return keySchema.parse(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
|
|
@@ -27,7 +24,7 @@ function record(keySchema, valueSchema) {
|
|
|
27
24
|
json: (parsed, opts) => {
|
|
28
25
|
return validateAndTransformRecord({
|
|
29
26
|
value: parsed,
|
|
30
|
-
isKeyNumeric: keySchema.getType() ===
|
|
27
|
+
isKeyNumeric: keySchema.getType() === SchemaType.NUMBER,
|
|
31
28
|
transformKey: (key) => {
|
|
32
29
|
var _a;
|
|
33
30
|
return keySchema.json(key, Object.assign(Object.assign({}, opts), { breadcrumbsPrefix: [...((_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : []), `${key} (key)`] }));
|
|
@@ -39,24 +36,23 @@ function record(keySchema, valueSchema) {
|
|
|
39
36
|
breadcrumbsPrefix: opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix,
|
|
40
37
|
});
|
|
41
38
|
},
|
|
42
|
-
getType: () =>
|
|
39
|
+
getType: () => SchemaType.RECORD,
|
|
43
40
|
};
|
|
44
|
-
return Object.assign(Object.assign({},
|
|
41
|
+
return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
|
|
45
42
|
}
|
|
46
|
-
exports.record = record;
|
|
47
43
|
function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) {
|
|
48
|
-
if (!
|
|
44
|
+
if (!isPlainObject(value)) {
|
|
49
45
|
return {
|
|
50
46
|
ok: false,
|
|
51
47
|
errors: [
|
|
52
48
|
{
|
|
53
49
|
path: breadcrumbsPrefix,
|
|
54
|
-
message:
|
|
50
|
+
message: getErrorMessageForIncorrectType(value, "object"),
|
|
55
51
|
},
|
|
56
52
|
],
|
|
57
53
|
};
|
|
58
54
|
}
|
|
59
|
-
return
|
|
55
|
+
return entries(value).reduce((accPromise, [stringKey, value]) => {
|
|
60
56
|
// skip nullish keys
|
|
61
57
|
if (value == null) {
|
|
62
58
|
return accPromise;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.JsonError = void 0;
|
|
4
|
-
const stringifyValidationErrors_1 = require("./stringifyValidationErrors");
|
|
5
|
-
class JsonError extends Error {
|
|
1
|
+
import { stringifyValidationError } from "./stringifyValidationErrors";
|
|
2
|
+
export class JsonError extends Error {
|
|
6
3
|
constructor(errors) {
|
|
7
|
-
super(errors.map(
|
|
4
|
+
super(errors.map(stringifyValidationError).join("; "));
|
|
8
5
|
this.errors = errors;
|
|
9
6
|
Object.setPrototypeOf(this, JsonError.prototype);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.JsonError = JsonError;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ParseError = void 0;
|
|
4
|
-
const stringifyValidationErrors_1 = require("./stringifyValidationErrors");
|
|
5
|
-
class ParseError extends Error {
|
|
1
|
+
import { stringifyValidationError } from "./stringifyValidationErrors";
|
|
2
|
+
export class ParseError extends Error {
|
|
6
3
|
constructor(errors) {
|
|
7
|
-
super(errors.map(
|
|
4
|
+
super(errors.map(stringifyValidationError).join("; "));
|
|
8
5
|
this.errors = errors;
|
|
9
6
|
Object.setPrototypeOf(this, ParseError.prototype);
|
|
10
7
|
}
|
|
11
8
|
}
|
|
12
|
-
exports.ParseError = ParseError;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const JsonError_1 = require("./JsonError");
|
|
6
|
-
const ParseError_1 = require("./ParseError");
|
|
7
|
-
function getSchemaUtils(schema) {
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { JsonError } from "./JsonError";
|
|
3
|
+
import { ParseError } from "./ParseError";
|
|
4
|
+
export function getSchemaUtils(schema) {
|
|
8
5
|
return {
|
|
9
6
|
optional: () => optional(schema),
|
|
10
7
|
transform: (transformer) => transform(schema, transformer),
|
|
@@ -13,22 +10,21 @@ function getSchemaUtils(schema) {
|
|
|
13
10
|
if (parsed.ok) {
|
|
14
11
|
return parsed.value;
|
|
15
12
|
}
|
|
16
|
-
throw new
|
|
13
|
+
throw new ParseError(parsed.errors);
|
|
17
14
|
},
|
|
18
15
|
jsonOrThrow: (parsed, opts) => {
|
|
19
16
|
const raw = schema.json(parsed, opts);
|
|
20
17
|
if (raw.ok) {
|
|
21
18
|
return raw.value;
|
|
22
19
|
}
|
|
23
|
-
throw new
|
|
20
|
+
throw new JsonError(raw.errors);
|
|
24
21
|
},
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
|
-
exports.getSchemaUtils = getSchemaUtils;
|
|
28
24
|
/**
|
|
29
25
|
* schema utils are defined in one file to resolve issues with circular imports
|
|
30
26
|
*/
|
|
31
|
-
function optional(schema) {
|
|
27
|
+
export function optional(schema) {
|
|
32
28
|
const baseSchema = {
|
|
33
29
|
parse: (raw, opts) => {
|
|
34
30
|
if (raw == null) {
|
|
@@ -54,12 +50,11 @@ function optional(schema) {
|
|
|
54
50
|
}
|
|
55
51
|
return schema.json(parsed, opts);
|
|
56
52
|
},
|
|
57
|
-
getType: () =>
|
|
53
|
+
getType: () => SchemaType.OPTIONAL,
|
|
58
54
|
};
|
|
59
55
|
return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
function transform(schema, transformer) {
|
|
57
|
+
export function transform(schema, transformer) {
|
|
63
58
|
const baseSchema = {
|
|
64
59
|
parse: (raw, opts) => {
|
|
65
60
|
const parsed = schema.parse(raw, opts);
|
|
@@ -79,4 +74,3 @@ function transform(schema, transformer) {
|
|
|
79
74
|
};
|
|
80
75
|
return Object.assign(Object.assign({}, baseSchema), getSchemaUtils(baseSchema));
|
|
81
76
|
}
|
|
82
|
-
exports.transform = transform;
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var getSchemaUtils_1 = require("./getSchemaUtils");
|
|
5
|
-
Object.defineProperty(exports, "getSchemaUtils", { enumerable: true, get: function () { return getSchemaUtils_1.getSchemaUtils; } });
|
|
6
|
-
Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return getSchemaUtils_1.optional; } });
|
|
7
|
-
Object.defineProperty(exports, "transform", { enumerable: true, get: function () { return getSchemaUtils_1.transform; } });
|
|
8
|
-
var JsonError_1 = require("./JsonError");
|
|
9
|
-
Object.defineProperty(exports, "JsonError", { enumerable: true, get: function () { return JsonError_1.JsonError; } });
|
|
10
|
-
var ParseError_1 = require("./ParseError");
|
|
11
|
-
Object.defineProperty(exports, "ParseError", { enumerable: true, get: function () { return ParseError_1.ParseError; } });
|
|
1
|
+
export { getSchemaUtils, optional, transform } from "./getSchemaUtils";
|
|
2
|
+
export { JsonError } from "./JsonError";
|
|
3
|
+
export { ParseError } from "./ParseError";
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyValidationError = void 0;
|
|
4
|
-
function stringifyValidationError(error) {
|
|
1
|
+
export function stringifyValidationError(error) {
|
|
5
2
|
if (error.path.length === 0) {
|
|
6
3
|
return error.message;
|
|
7
4
|
}
|
|
8
5
|
return `${error.path.join(" -> ")}: ${error.message}`;
|
|
9
6
|
}
|
|
10
|
-
exports.stringifyValidationError = stringifyValidationError;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const schema_utils_1 = require("../schema-utils");
|
|
9
|
-
function set(schema) {
|
|
10
|
-
const listSchema = (0, list_1.list)(schema);
|
|
1
|
+
import { SchemaType } from "../../Schema";
|
|
2
|
+
import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType";
|
|
3
|
+
import { maybeSkipValidation } from "../../utils/maybeSkipValidation";
|
|
4
|
+
import { list } from "../list";
|
|
5
|
+
import { getSchemaUtils } from "../schema-utils";
|
|
6
|
+
export function set(schema) {
|
|
7
|
+
const listSchema = list(schema);
|
|
11
8
|
const baseSchema = {
|
|
12
9
|
parse: (raw, opts) => {
|
|
13
10
|
const parsedList = listSchema.parse(raw, opts);
|
|
@@ -29,7 +26,7 @@ function set(schema) {
|
|
|
29
26
|
errors: [
|
|
30
27
|
{
|
|
31
28
|
path: (_a = opts === null || opts === void 0 ? void 0 : opts.breadcrumbsPrefix) !== null && _a !== void 0 ? _a : [],
|
|
32
|
-
message:
|
|
29
|
+
message: getErrorMessageForIncorrectType(parsed, "Set"),
|
|
33
30
|
},
|
|
34
31
|
],
|
|
35
32
|
};
|
|
@@ -37,8 +34,7 @@ function set(schema) {
|
|
|
37
34
|
const jsonList = listSchema.json([...parsed], opts);
|
|
38
35
|
return jsonList;
|
|
39
36
|
},
|
|
40
|
-
getType: () =>
|
|
37
|
+
getType: () => SchemaType.SET,
|
|
41
38
|
};
|
|
42
|
-
return Object.assign(Object.assign({},
|
|
39
|
+
return Object.assign(Object.assign({}, maybeSkipValidation(baseSchema)), getSchemaUtils(baseSchema));
|
|
43
40
|
}
|
|
44
|
-
exports.set = set;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.undiscriminatedUnion = void 0;
|
|
4
|
-
var undiscriminatedUnion_1 = require("./undiscriminatedUnion");
|
|
5
|
-
Object.defineProperty(exports, "undiscriminatedUnion", { enumerable: true, get: function () { return undiscriminatedUnion_1.undiscriminatedUnion; } });
|
|
1
|
+
export { undiscriminatedUnion } from "./undiscriminatedUnion";
|