@cartesia/cartesia-js 2.1.4 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (442) hide show
  1. package/Client.d.ts +10 -6
  2. package/api/resources/apiStatus/client/Client.d.ts +4 -0
  3. package/api/resources/apiStatus/client/Client.js +21 -11
  4. package/api/resources/datasets/client/Client.d.ts +4 -1
  5. package/api/resources/datasets/client/Client.js +34 -24
  6. package/api/resources/datasets/types/FilePurpose.d.ts +1 -1
  7. package/api/resources/embedding/types/Embedding.d.ts +1 -1
  8. package/api/resources/index.js +17 -7
  9. package/api/resources/infill/client/Client.d.ts +6 -1
  10. package/api/resources/infill/client/Client.js +44 -23
  11. package/api/resources/infill/client/requests/InfillBytesRequest.d.ts +7 -3
  12. package/api/resources/tts/client/Client.js +21 -11
  13. package/api/resources/tts/types/ContextId.d.ts +1 -1
  14. package/api/resources/tts/types/Emotion.d.ts +1 -1
  15. package/api/resources/tts/types/FlushId.d.ts +9 -0
  16. package/api/resources/tts/types/FlushId.js +5 -0
  17. package/api/resources/tts/types/GenerationRequest.d.ts +5 -2
  18. package/api/resources/tts/types/NaturalSpecifier.d.ts +1 -1
  19. package/api/resources/tts/types/NumericalSpecifier.d.ts +1 -1
  20. package/api/resources/tts/types/OutputFormat.d.ts +1 -1
  21. package/api/resources/tts/types/RawEncoding.d.ts +1 -1
  22. package/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
  23. package/api/resources/tts/types/Speed.d.ts +1 -1
  24. package/api/resources/tts/types/SupportedLanguage.d.ts +1 -1
  25. package/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +1 -1
  26. package/api/resources/tts/types/WebSocketFlushDoneResponse.d.ts +8 -0
  27. package/api/resources/tts/types/WebSocketFlushDoneResponse.js +5 -0
  28. package/api/resources/tts/types/WebSocketRequest.d.ts +1 -1
  29. package/api/resources/tts/types/WebSocketResponse.d.ts +4 -1
  30. package/api/resources/tts/types/WebSocketTtsOutput.d.ts +2 -0
  31. package/api/resources/tts/types/index.d.ts +2 -0
  32. package/api/resources/tts/types/index.js +2 -0
  33. package/api/resources/voiceChanger/client/Client.d.ts +3 -4
  34. package/api/resources/voiceChanger/client/Client.js +23 -13
  35. package/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +1 -1
  36. package/api/resources/voiceChanger/types/StreamingResponse.d.ts +1 -1
  37. package/api/resources/voices/client/Client.d.ts +4 -1
  38. package/api/resources/voices/client/Client.js +55 -45
  39. package/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
  40. package/api/resources/voices/types/CloneMode.d.ts +1 -1
  41. package/api/resources/voices/types/Gender.d.ts +1 -1
  42. package/api/resources/voices/types/LocalizeDialect.d.ts +12 -4
  43. package/api/resources/voices/types/LocalizeEnglishDialect.d.ts +1 -1
  44. package/api/resources/voices/types/LocalizePortugueseDialect.d.ts +8 -0
  45. package/api/resources/voices/types/LocalizePortugueseDialect.js +10 -0
  46. package/api/resources/voices/types/LocalizeSpanishDialect.d.ts +8 -0
  47. package/api/resources/voices/types/LocalizeSpanishDialect.js +10 -0
  48. package/api/resources/voices/types/LocalizeTargetLanguage.d.ts +1 -1
  49. package/api/resources/voices/types/MixVoiceSpecifier.d.ts +1 -1
  50. package/api/resources/voices/types/VoiceId.d.ts +1 -1
  51. package/api/resources/voices/types/Weight.d.ts +1 -1
  52. package/api/resources/voices/types/index.d.ts +2 -0
  53. package/api/resources/voices/types/index.js +2 -0
  54. package/core/fetcher/APIResponse.d.ts +1 -1
  55. package/core/fetcher/Fetcher.d.ts +1 -1
  56. package/core/fetcher/Fetcher.js +2 -2
  57. package/core/fetcher/Supplier.d.ts +1 -1
  58. package/core/fetcher/createRequestUrl.d.ts +1 -1
  59. package/core/fetcher/createRequestUrl.js +1 -2
  60. package/core/fetcher/getFetchFn.js +18 -9
  61. package/core/fetcher/getHeader.js +1 -2
  62. package/core/fetcher/getRequestBody.js +5 -5
  63. package/core/fetcher/getResponseBody.js +1 -2
  64. package/core/fetcher/makeRequest.d.ts +1 -1
  65. package/core/fetcher/requestWithRetries.js +4 -5
  66. package/core/fetcher/signals.d.ts +0 -1
  67. package/core/fetcher/signals.js +2 -3
  68. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
  69. package/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
  70. package/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
  71. package/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
  72. package/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
  73. package/core/form-data-utils/FormDataWrapper.d.ts +4 -4
  74. package/core/form-data-utils/FormDataWrapper.js +22 -12
  75. package/core/index.js +17 -7
  76. package/core/json.d.ts +15 -0
  77. package/core/json.js +24 -0
  78. package/core/runtime/runtime.d.ts +1 -1
  79. package/core/runtime/runtime.js +51 -41
  80. package/core/schemas/Schema.d.ts +7 -5
  81. package/core/schemas/Schema.js +2 -0
  82. package/core/schemas/builders/bigint/bigint.d.ts +1 -1
  83. package/core/schemas/builders/bigint/bigint.js +22 -19
  84. package/core/schemas/builders/date/date.js +1 -2
  85. package/core/schemas/builders/enum/enum.js +1 -2
  86. package/core/schemas/builders/lazy/lazy.d.ts +1 -1
  87. package/core/schemas/builders/lazy/lazy.js +3 -4
  88. package/core/schemas/builders/lazy/lazyObject.js +1 -2
  89. package/core/schemas/builders/list/list.js +1 -2
  90. package/core/schemas/builders/literals/booleanLiteral.js +1 -2
  91. package/core/schemas/builders/literals/stringLiteral.js +1 -2
  92. package/core/schemas/builders/object/object.d.ts +1 -1
  93. package/core/schemas/builders/object/object.js +31 -3
  94. package/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +3 -3
  95. package/core/schemas/builders/object/objectWithoutOptionalProperties.js +1 -2
  96. package/core/schemas/builders/object/property.js +2 -3
  97. package/core/schemas/builders/object/types.d.ts +16 -11
  98. package/core/schemas/builders/object-like/getObjectLikeUtils.js +2 -3
  99. package/core/schemas/builders/object-like/types.d.ts +1 -1
  100. package/core/schemas/builders/record/record.js +2 -4
  101. package/core/schemas/builders/record/types.d.ts +2 -2
  102. package/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  103. package/core/schemas/builders/schema-utils/getSchemaUtils.js +67 -4
  104. package/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -2
  105. package/core/schemas/builders/set/set.js +1 -2
  106. package/core/schemas/builders/undiscriminated-union/types.d.ts +4 -4
  107. package/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +1 -2
  108. package/core/schemas/builders/union/discriminant.js +1 -2
  109. package/core/schemas/builders/union/types.d.ts +6 -6
  110. package/core/schemas/builders/union/union.d.ts +1 -1
  111. package/core/schemas/builders/union/union.js +1 -2
  112. package/core/schemas/utils/MaybePromise.d.ts +1 -1
  113. package/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +4 -4
  114. package/core/schemas/utils/createIdentitySchemaCreator.js +1 -2
  115. package/core/schemas/utils/entries.d.ts +1 -1
  116. package/core/schemas/utils/entries.js +1 -2
  117. package/core/schemas/utils/filterObject.d.ts +1 -1
  118. package/core/schemas/utils/filterObject.js +1 -2
  119. package/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -2
  120. package/core/schemas/utils/isPlainObject.js +1 -2
  121. package/core/schemas/utils/keys.d.ts +1 -1
  122. package/core/schemas/utils/keys.js +1 -2
  123. package/core/schemas/utils/maybeSkipValidation.js +1 -2
  124. package/core/schemas/utils/partition.js +1 -2
  125. package/core/streaming-fetcher/Stream.d.ts +0 -1
  126. package/core/streaming-fetcher/Stream.js +20 -21
  127. package/core/websocket/ws.d.ts +7 -7
  128. package/core/websocket/ws.js +17 -7
  129. package/dist/Client.d.ts +10 -6
  130. package/dist/api/resources/apiStatus/client/Client.d.ts +4 -0
  131. package/dist/api/resources/apiStatus/client/Client.js +21 -11
  132. package/dist/api/resources/datasets/client/Client.d.ts +4 -1
  133. package/dist/api/resources/datasets/client/Client.js +34 -24
  134. package/dist/api/resources/datasets/types/FilePurpose.d.ts +1 -1
  135. package/dist/api/resources/embedding/types/Embedding.d.ts +1 -1
  136. package/dist/api/resources/index.js +17 -7
  137. package/dist/api/resources/infill/client/Client.d.ts +6 -1
  138. package/dist/api/resources/infill/client/Client.js +44 -23
  139. package/dist/api/resources/infill/client/requests/InfillBytesRequest.d.ts +7 -3
  140. package/dist/api/resources/tts/client/Client.js +21 -11
  141. package/dist/api/resources/tts/types/ContextId.d.ts +1 -1
  142. package/dist/api/resources/tts/types/Emotion.d.ts +1 -1
  143. package/dist/api/resources/tts/types/FlushId.d.ts +9 -0
  144. package/dist/api/resources/tts/types/FlushId.js +5 -0
  145. package/dist/api/resources/tts/types/GenerationRequest.d.ts +5 -2
  146. package/dist/api/resources/tts/types/NaturalSpecifier.d.ts +1 -1
  147. package/dist/api/resources/tts/types/NumericalSpecifier.d.ts +1 -1
  148. package/dist/api/resources/tts/types/OutputFormat.d.ts +1 -1
  149. package/dist/api/resources/tts/types/RawEncoding.d.ts +1 -1
  150. package/dist/api/resources/tts/types/RawOutputFormat.d.ts +1 -0
  151. package/dist/api/resources/tts/types/Speed.d.ts +1 -1
  152. package/dist/api/resources/tts/types/SupportedLanguage.d.ts +1 -1
  153. package/dist/api/resources/tts/types/TtsRequestVoiceSpecifier.d.ts +1 -1
  154. package/dist/api/resources/tts/types/WebSocketFlushDoneResponse.d.ts +8 -0
  155. package/dist/api/resources/tts/types/WebSocketFlushDoneResponse.js +5 -0
  156. package/dist/api/resources/tts/types/WebSocketRequest.d.ts +1 -1
  157. package/dist/api/resources/tts/types/WebSocketResponse.d.ts +4 -1
  158. package/dist/api/resources/tts/types/WebSocketTtsOutput.d.ts +2 -0
  159. package/dist/api/resources/tts/types/index.d.ts +2 -0
  160. package/dist/api/resources/tts/types/index.js +2 -0
  161. package/dist/api/resources/voiceChanger/client/Client.d.ts +3 -4
  162. package/dist/api/resources/voiceChanger/client/Client.js +23 -13
  163. package/dist/api/resources/voiceChanger/types/OutputFormatContainer.d.ts +1 -1
  164. package/dist/api/resources/voiceChanger/types/StreamingResponse.d.ts +1 -1
  165. package/dist/api/resources/voices/client/Client.d.ts +4 -1
  166. package/dist/api/resources/voices/client/Client.js +55 -45
  167. package/dist/api/resources/voices/types/BaseVoiceId.d.ts +1 -1
  168. package/dist/api/resources/voices/types/CloneMode.d.ts +1 -1
  169. package/dist/api/resources/voices/types/Gender.d.ts +1 -1
  170. package/dist/api/resources/voices/types/LocalizeDialect.d.ts +12 -4
  171. package/dist/api/resources/voices/types/LocalizeEnglishDialect.d.ts +1 -1
  172. package/dist/api/resources/voices/types/LocalizePortugueseDialect.d.ts +8 -0
  173. package/dist/api/resources/voices/types/LocalizePortugueseDialect.js +10 -0
  174. package/dist/api/resources/voices/types/LocalizeSpanishDialect.d.ts +8 -0
  175. package/dist/api/resources/voices/types/LocalizeSpanishDialect.js +10 -0
  176. package/dist/api/resources/voices/types/LocalizeTargetLanguage.d.ts +1 -1
  177. package/dist/api/resources/voices/types/MixVoiceSpecifier.d.ts +1 -1
  178. package/dist/api/resources/voices/types/VoiceId.d.ts +1 -1
  179. package/dist/api/resources/voices/types/Weight.d.ts +1 -1
  180. package/dist/api/resources/voices/types/index.d.ts +2 -0
  181. package/dist/api/resources/voices/types/index.js +2 -0
  182. package/dist/core/fetcher/APIResponse.d.ts +1 -1
  183. package/dist/core/fetcher/Fetcher.d.ts +1 -1
  184. package/dist/core/fetcher/Fetcher.js +2 -2
  185. package/dist/core/fetcher/Supplier.d.ts +1 -1
  186. package/dist/core/fetcher/createRequestUrl.d.ts +1 -1
  187. package/dist/core/fetcher/createRequestUrl.js +1 -2
  188. package/dist/core/fetcher/getFetchFn.js +18 -9
  189. package/dist/core/fetcher/getHeader.js +1 -2
  190. package/dist/core/fetcher/getRequestBody.js +5 -5
  191. package/dist/core/fetcher/getResponseBody.js +1 -2
  192. package/dist/core/fetcher/makeRequest.d.ts +1 -1
  193. package/dist/core/fetcher/requestWithRetries.js +4 -5
  194. package/dist/core/fetcher/signals.d.ts +0 -1
  195. package/dist/core/fetcher/signals.js +2 -3
  196. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.d.ts +0 -1
  197. package/dist/core/fetcher/stream-wrappers/NodePre18StreamWrapper.js +6 -4
  198. package/dist/core/fetcher/stream-wrappers/UndiciStreamWrapper.d.ts +1 -1
  199. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.d.ts +1 -1
  200. package/dist/core/fetcher/stream-wrappers/chooseStreamWrapper.js +18 -9
  201. package/dist/core/form-data-utils/FormDataWrapper.d.ts +4 -4
  202. package/dist/core/form-data-utils/FormDataWrapper.js +22 -12
  203. package/dist/core/index.js +17 -7
  204. package/dist/core/json.d.ts +15 -0
  205. package/dist/core/json.js +24 -0
  206. package/dist/core/runtime/runtime.d.ts +1 -1
  207. package/dist/core/runtime/runtime.js +51 -41
  208. package/dist/core/schemas/Schema.d.ts +7 -5
  209. package/dist/core/schemas/Schema.js +2 -0
  210. package/dist/core/schemas/builders/bigint/bigint.d.ts +1 -1
  211. package/dist/core/schemas/builders/bigint/bigint.js +22 -19
  212. package/dist/core/schemas/builders/date/date.js +1 -2
  213. package/dist/core/schemas/builders/enum/enum.js +1 -2
  214. package/dist/core/schemas/builders/lazy/lazy.d.ts +1 -1
  215. package/dist/core/schemas/builders/lazy/lazy.js +3 -4
  216. package/dist/core/schemas/builders/lazy/lazyObject.js +1 -2
  217. package/dist/core/schemas/builders/list/list.js +1 -2
  218. package/dist/core/schemas/builders/literals/booleanLiteral.js +1 -2
  219. package/dist/core/schemas/builders/literals/stringLiteral.js +1 -2
  220. package/dist/core/schemas/builders/object/object.d.ts +1 -1
  221. package/dist/core/schemas/builders/object/object.js +31 -3
  222. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +3 -3
  223. package/dist/core/schemas/builders/object/objectWithoutOptionalProperties.js +1 -2
  224. package/dist/core/schemas/builders/object/property.js +2 -3
  225. package/dist/core/schemas/builders/object/types.d.ts +16 -11
  226. package/dist/core/schemas/builders/object-like/getObjectLikeUtils.js +2 -3
  227. package/dist/core/schemas/builders/object-like/types.d.ts +1 -1
  228. package/dist/core/schemas/builders/record/record.js +2 -4
  229. package/dist/core/schemas/builders/record/types.d.ts +2 -2
  230. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +4 -0
  231. package/dist/core/schemas/builders/schema-utils/getSchemaUtils.js +67 -4
  232. package/dist/core/schemas/builders/schema-utils/stringifyValidationErrors.js +1 -2
  233. package/dist/core/schemas/builders/set/set.js +1 -2
  234. package/dist/core/schemas/builders/undiscriminated-union/types.d.ts +4 -4
  235. package/dist/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +1 -2
  236. package/dist/core/schemas/builders/union/discriminant.js +1 -2
  237. package/dist/core/schemas/builders/union/types.d.ts +6 -6
  238. package/dist/core/schemas/builders/union/union.d.ts +1 -1
  239. package/dist/core/schemas/builders/union/union.js +1 -2
  240. package/dist/core/schemas/utils/MaybePromise.d.ts +1 -1
  241. package/dist/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +4 -4
  242. package/dist/core/schemas/utils/createIdentitySchemaCreator.js +1 -2
  243. package/dist/core/schemas/utils/entries.d.ts +1 -1
  244. package/dist/core/schemas/utils/entries.js +1 -2
  245. package/dist/core/schemas/utils/filterObject.d.ts +1 -1
  246. package/dist/core/schemas/utils/filterObject.js +1 -2
  247. package/dist/core/schemas/utils/getErrorMessageForIncorrectType.js +1 -2
  248. package/dist/core/schemas/utils/isPlainObject.js +1 -2
  249. package/dist/core/schemas/utils/keys.d.ts +1 -1
  250. package/dist/core/schemas/utils/keys.js +1 -2
  251. package/dist/core/schemas/utils/maybeSkipValidation.js +1 -2
  252. package/dist/core/schemas/utils/partition.js +1 -2
  253. package/dist/core/streaming-fetcher/Stream.d.ts +0 -1
  254. package/dist/core/streaming-fetcher/Stream.js +20 -21
  255. package/dist/core/websocket/ws.d.ts +7 -7
  256. package/dist/core/websocket/ws.js +17 -7
  257. package/dist/environments.d.ts +1 -1
  258. package/dist/errors/CartesiaError.js +2 -1
  259. package/dist/errors/CartesiaTimeoutError.d.ts +1 -1
  260. package/dist/errors/CartesiaTimeoutError.js +2 -2
  261. package/dist/index.js +17 -7
  262. package/dist/serialization/resources/apiStatus/types/ApiInfo.js +17 -7
  263. package/dist/serialization/resources/datasets/types/CreateDatasetRequest.js +17 -7
  264. package/dist/serialization/resources/datasets/types/Dataset.js +17 -7
  265. package/dist/serialization/resources/datasets/types/DatasetFile.js +17 -7
  266. package/dist/serialization/resources/datasets/types/FilePurpose.js +17 -7
  267. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +17 -7
  268. package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +17 -7
  269. package/dist/serialization/resources/embedding/types/Embedding.js +17 -7
  270. package/dist/serialization/resources/index.js +17 -7
  271. package/dist/serialization/resources/tts/types/CancelContextRequest.js +17 -7
  272. package/dist/serialization/resources/tts/types/ContextId.js +17 -7
  273. package/dist/serialization/resources/tts/types/Controls.js +17 -7
  274. package/dist/serialization/resources/tts/types/Emotion.js +17 -7
  275. package/dist/serialization/resources/tts/types/FlushId.d.ts +10 -0
  276. package/dist/serialization/resources/tts/types/FlushId.js +41 -0
  277. package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +3 -2
  278. package/dist/serialization/resources/tts/types/GenerationRequest.js +20 -9
  279. package/dist/serialization/resources/tts/types/Mp3OutputFormat.js +17 -7
  280. package/dist/serialization/resources/tts/types/NaturalSpecifier.js +17 -7
  281. package/dist/serialization/resources/tts/types/NumericalSpecifier.js +17 -7
  282. package/dist/serialization/resources/tts/types/OutputFormat.js +17 -7
  283. package/dist/serialization/resources/tts/types/PhonemeTimestamps.js +17 -7
  284. package/dist/serialization/resources/tts/types/RawEncoding.js +17 -7
  285. package/dist/serialization/resources/tts/types/RawOutputFormat.d.ts +1 -0
  286. package/dist/serialization/resources/tts/types/RawOutputFormat.js +18 -7
  287. package/dist/serialization/resources/tts/types/Speed.js +17 -7
  288. package/dist/serialization/resources/tts/types/SupportedLanguage.js +17 -7
  289. package/dist/serialization/resources/tts/types/TtsRequest.js +17 -7
  290. package/dist/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +17 -7
  291. package/dist/serialization/resources/tts/types/TtsRequestIdSpecifier.js +17 -7
  292. package/dist/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +17 -7
  293. package/dist/serialization/resources/tts/types/WavOutputFormat.js +17 -7
  294. package/dist/serialization/resources/tts/types/WebSocketBaseResponse.js +17 -7
  295. package/dist/serialization/resources/tts/types/WebSocketChunkResponse.js +17 -7
  296. package/dist/serialization/resources/tts/types/WebSocketDoneResponse.js +17 -7
  297. package/dist/serialization/resources/tts/types/WebSocketErrorResponse.js +17 -7
  298. package/dist/serialization/resources/tts/types/WebSocketFlushDoneResponse.d.ts +15 -0
  299. package/dist/serialization/resources/tts/types/WebSocketFlushDoneResponse.js +48 -0
  300. package/dist/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +17 -7
  301. package/dist/serialization/resources/tts/types/WebSocketRawOutputFormat.js +17 -7
  302. package/dist/serialization/resources/tts/types/WebSocketRequest.js +17 -7
  303. package/dist/serialization/resources/tts/types/WebSocketResponse.d.ts +5 -1
  304. package/dist/serialization/resources/tts/types/WebSocketResponse.js +19 -7
  305. package/dist/serialization/resources/tts/types/WebSocketStreamOptions.js +17 -7
  306. package/dist/serialization/resources/tts/types/WebSocketTimestampsResponse.js +17 -7
  307. package/dist/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +3 -0
  308. package/dist/serialization/resources/tts/types/WebSocketTtsOutput.js +20 -7
  309. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +17 -7
  310. package/dist/serialization/resources/tts/types/WordTimestamps.js +17 -7
  311. package/dist/serialization/resources/tts/types/index.d.ts +2 -0
  312. package/dist/serialization/resources/tts/types/index.js +2 -0
  313. package/dist/serialization/resources/voiceChanger/types/OutputFormatContainer.js +17 -7
  314. package/dist/serialization/resources/voiceChanger/types/StreamingResponse.js +17 -7
  315. package/dist/serialization/resources/voices/client/index.js +17 -7
  316. package/dist/serialization/resources/voices/client/list.js +17 -7
  317. package/dist/serialization/resources/voices/types/CloneMode.js +17 -7
  318. package/dist/serialization/resources/voices/types/CreateVoiceRequest.js +17 -7
  319. package/dist/serialization/resources/voices/types/EmbeddingResponse.js +17 -7
  320. package/dist/serialization/resources/voices/types/EmbeddingSpecifier.js +17 -7
  321. package/dist/serialization/resources/voices/types/Gender.js +17 -7
  322. package/dist/serialization/resources/voices/types/IdSpecifier.js +17 -7
  323. package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +3 -1
  324. package/dist/serialization/resources/voices/types/LocalizeDialect.js +24 -8
  325. package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.js +17 -7
  326. package/dist/serialization/resources/voices/types/LocalizePortugueseDialect.d.ts +10 -0
  327. package/dist/serialization/resources/voices/types/LocalizePortugueseDialect.js +41 -0
  328. package/dist/serialization/resources/voices/types/LocalizeSpanishDialect.d.ts +10 -0
  329. package/dist/serialization/resources/voices/types/LocalizeSpanishDialect.js +41 -0
  330. package/dist/serialization/resources/voices/types/LocalizeTargetLanguage.js +17 -7
  331. package/dist/serialization/resources/voices/types/LocalizeVoiceRequest.js +17 -7
  332. package/dist/serialization/resources/voices/types/MixVoiceSpecifier.js +17 -7
  333. package/dist/serialization/resources/voices/types/MixVoicesRequest.js +17 -7
  334. package/dist/serialization/resources/voices/types/UpdateVoiceRequest.js +17 -7
  335. package/dist/serialization/resources/voices/types/Voice.js +17 -7
  336. package/dist/serialization/resources/voices/types/VoiceId.js +17 -7
  337. package/dist/serialization/resources/voices/types/VoiceMetadata.js +17 -7
  338. package/dist/serialization/resources/voices/types/Weight.js +17 -7
  339. package/dist/serialization/resources/voices/types/index.d.ts +2 -0
  340. package/dist/serialization/resources/voices/types/index.js +2 -0
  341. package/dist/version.d.ts +1 -1
  342. package/dist/version.js +1 -1
  343. package/dist/wrapper/WebPlayer.js +1 -1
  344. package/dist/wrapper/Websocket.js +25 -15
  345. package/dist/wrapper/source.js +1 -1
  346. package/dist/wrapper/utils.d.ts +9 -9
  347. package/dist/wrapper/utils.js +10 -10
  348. package/environments.d.ts +1 -1
  349. package/errors/CartesiaError.js +2 -1
  350. package/errors/CartesiaTimeoutError.d.ts +1 -1
  351. package/errors/CartesiaTimeoutError.js +2 -2
  352. package/index.js +17 -7
  353. package/{jest.config.js → jest.config.mjs} +4 -1
  354. package/package.json +15 -16
  355. package/reference.md +4 -0
  356. package/scripts/rename-to-esm-files.js +115 -0
  357. package/serialization/resources/apiStatus/types/ApiInfo.js +17 -7
  358. package/serialization/resources/datasets/types/CreateDatasetRequest.js +17 -7
  359. package/serialization/resources/datasets/types/Dataset.js +17 -7
  360. package/serialization/resources/datasets/types/DatasetFile.js +17 -7
  361. package/serialization/resources/datasets/types/FilePurpose.js +17 -7
  362. package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +17 -7
  363. package/serialization/resources/datasets/types/PaginatedDatasets.js +17 -7
  364. package/serialization/resources/embedding/types/Embedding.js +17 -7
  365. package/serialization/resources/index.js +17 -7
  366. package/serialization/resources/tts/types/CancelContextRequest.js +17 -7
  367. package/serialization/resources/tts/types/ContextId.js +17 -7
  368. package/serialization/resources/tts/types/Controls.js +17 -7
  369. package/serialization/resources/tts/types/Emotion.js +17 -7
  370. package/serialization/resources/tts/types/FlushId.d.ts +10 -0
  371. package/serialization/resources/tts/types/FlushId.js +41 -0
  372. package/serialization/resources/tts/types/GenerationRequest.d.ts +3 -2
  373. package/serialization/resources/tts/types/GenerationRequest.js +20 -9
  374. package/serialization/resources/tts/types/Mp3OutputFormat.js +17 -7
  375. package/serialization/resources/tts/types/NaturalSpecifier.js +17 -7
  376. package/serialization/resources/tts/types/NumericalSpecifier.js +17 -7
  377. package/serialization/resources/tts/types/OutputFormat.js +17 -7
  378. package/serialization/resources/tts/types/PhonemeTimestamps.js +17 -7
  379. package/serialization/resources/tts/types/RawEncoding.js +17 -7
  380. package/serialization/resources/tts/types/RawOutputFormat.d.ts +1 -0
  381. package/serialization/resources/tts/types/RawOutputFormat.js +18 -7
  382. package/serialization/resources/tts/types/Speed.js +17 -7
  383. package/serialization/resources/tts/types/SupportedLanguage.js +17 -7
  384. package/serialization/resources/tts/types/TtsRequest.js +17 -7
  385. package/serialization/resources/tts/types/TtsRequestEmbeddingSpecifier.js +17 -7
  386. package/serialization/resources/tts/types/TtsRequestIdSpecifier.js +17 -7
  387. package/serialization/resources/tts/types/TtsRequestVoiceSpecifier.js +17 -7
  388. package/serialization/resources/tts/types/WavOutputFormat.js +17 -7
  389. package/serialization/resources/tts/types/WebSocketBaseResponse.js +17 -7
  390. package/serialization/resources/tts/types/WebSocketChunkResponse.js +17 -7
  391. package/serialization/resources/tts/types/WebSocketDoneResponse.js +17 -7
  392. package/serialization/resources/tts/types/WebSocketErrorResponse.js +17 -7
  393. package/serialization/resources/tts/types/WebSocketFlushDoneResponse.d.ts +15 -0
  394. package/serialization/resources/tts/types/WebSocketFlushDoneResponse.js +48 -0
  395. package/serialization/resources/tts/types/WebSocketPhonemeTimestampsResponse.js +17 -7
  396. package/serialization/resources/tts/types/WebSocketRawOutputFormat.js +17 -7
  397. package/serialization/resources/tts/types/WebSocketRequest.js +17 -7
  398. package/serialization/resources/tts/types/WebSocketResponse.d.ts +5 -1
  399. package/serialization/resources/tts/types/WebSocketResponse.js +19 -7
  400. package/serialization/resources/tts/types/WebSocketStreamOptions.js +17 -7
  401. package/serialization/resources/tts/types/WebSocketTimestampsResponse.js +17 -7
  402. package/serialization/resources/tts/types/WebSocketTtsOutput.d.ts +3 -0
  403. package/serialization/resources/tts/types/WebSocketTtsOutput.js +20 -7
  404. package/serialization/resources/tts/types/WebSocketTtsRequest.js +17 -7
  405. package/serialization/resources/tts/types/WordTimestamps.js +17 -7
  406. package/serialization/resources/tts/types/index.d.ts +2 -0
  407. package/serialization/resources/tts/types/index.js +2 -0
  408. package/serialization/resources/voiceChanger/types/OutputFormatContainer.js +17 -7
  409. package/serialization/resources/voiceChanger/types/StreamingResponse.js +17 -7
  410. package/serialization/resources/voices/client/index.js +17 -7
  411. package/serialization/resources/voices/client/list.js +17 -7
  412. package/serialization/resources/voices/types/CloneMode.js +17 -7
  413. package/serialization/resources/voices/types/CreateVoiceRequest.js +17 -7
  414. package/serialization/resources/voices/types/EmbeddingResponse.js +17 -7
  415. package/serialization/resources/voices/types/EmbeddingSpecifier.js +17 -7
  416. package/serialization/resources/voices/types/Gender.js +17 -7
  417. package/serialization/resources/voices/types/IdSpecifier.js +17 -7
  418. package/serialization/resources/voices/types/LocalizeDialect.d.ts +3 -1
  419. package/serialization/resources/voices/types/LocalizeDialect.js +24 -8
  420. package/serialization/resources/voices/types/LocalizeEnglishDialect.js +17 -7
  421. package/serialization/resources/voices/types/LocalizePortugueseDialect.d.ts +10 -0
  422. package/serialization/resources/voices/types/LocalizePortugueseDialect.js +41 -0
  423. package/serialization/resources/voices/types/LocalizeSpanishDialect.d.ts +10 -0
  424. package/serialization/resources/voices/types/LocalizeSpanishDialect.js +41 -0
  425. package/serialization/resources/voices/types/LocalizeTargetLanguage.js +17 -7
  426. package/serialization/resources/voices/types/LocalizeVoiceRequest.js +17 -7
  427. package/serialization/resources/voices/types/MixVoiceSpecifier.js +17 -7
  428. package/serialization/resources/voices/types/MixVoicesRequest.js +17 -7
  429. package/serialization/resources/voices/types/UpdateVoiceRequest.js +17 -7
  430. package/serialization/resources/voices/types/Voice.js +17 -7
  431. package/serialization/resources/voices/types/VoiceId.js +17 -7
  432. package/serialization/resources/voices/types/VoiceMetadata.js +17 -7
  433. package/serialization/resources/voices/types/Weight.js +17 -7
  434. package/serialization/resources/voices/types/index.d.ts +2 -0
  435. package/serialization/resources/voices/types/index.js +2 -0
  436. package/version.d.ts +1 -1
  437. package/version.js +1 -1
  438. package/wrapper/WebPlayer.js +1 -1
  439. package/wrapper/Websocket.js +25 -15
  440. package/wrapper/source.js +1 -1
  441. package/wrapper/utils.d.ts +9 -9
  442. package/wrapper/utils.js +10 -10
@@ -1,80 +1,85 @@
1
1
  "use strict";
2
- var _a, _b, _c, _d, _e;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.RUNTIME = void 0;
5
- /**
6
- * A constant that indicates whether the environment the code is running is a Web Browser.
7
- */
8
- const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
9
- /**
10
- * A constant that indicates whether the environment the code is running is a Web Worker.
11
- */
12
- const isWebWorker = typeof self === "object" &&
13
- // @ts-ignore
14
- typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
15
- (((_a = self.constructor) === null || _a === void 0 ? void 0 : _a.name) === "DedicatedWorkerGlobalScope" ||
16
- ((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "ServiceWorkerGlobalScope" ||
17
- ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "SharedWorkerGlobalScope");
18
- /**
19
- * A constant that indicates whether the environment the code is running is Deno.
20
- */
21
- const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
22
- /**
23
- * A constant that indicates whether the environment the code is running is Bun.sh.
24
- */
25
- const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
26
- /**
27
- * A constant that indicates whether the environment the code is running is Node.JS.
28
- */
29
- const isNode = typeof process !== "undefined" &&
30
- Boolean(process.version) &&
31
- Boolean((_d = process.versions) === null || _d === void 0 ? void 0 : _d.node) &&
32
- // Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
33
- !isDeno &&
34
- !isBun;
35
- /**
36
- * A constant that indicates whether the environment the code is running is in React-Native.
37
- * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
38
- */
39
- const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
40
- /**
41
- * A constant that indicates whether the environment the code is running is Cloudflare.
42
- * https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
43
- */
44
- const isCloudflare = typeof globalThis !== "undefined" && ((_e = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _e === void 0 ? void 0 : _e.userAgent) === "Cloudflare-Workers";
45
4
  /**
46
5
  * A constant that indicates which environment and version the SDK is running in.
47
6
  */
48
7
  exports.RUNTIME = evaluateRuntime();
49
8
  function evaluateRuntime() {
9
+ var _a, _b, _c, _d, _e;
10
+ /**
11
+ * A constant that indicates whether the environment the code is running is a Web Browser.
12
+ */
13
+ const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
50
14
  if (isBrowser) {
51
15
  return {
52
16
  type: "browser",
53
17
  version: window.navigator.userAgent,
54
18
  };
55
19
  }
20
+ /**
21
+ * A constant that indicates whether the environment the code is running is Cloudflare.
22
+ * https://developers.cloudflare.com/workers/runtime-apis/web-standards/#navigatoruseragent
23
+ */
24
+ const isCloudflare = typeof globalThis !== "undefined" && ((_a = globalThis === null || globalThis === void 0 ? void 0 : globalThis.navigator) === null || _a === void 0 ? void 0 : _a.userAgent) === "Cloudflare-Workers";
56
25
  if (isCloudflare) {
57
26
  return {
58
27
  type: "workerd",
59
28
  };
60
29
  }
30
+ /**
31
+ * A constant that indicates whether the environment the code is running is Edge Runtime.
32
+ * https://vercel.com/docs/functions/runtimes/edge-runtime#check-if-you're-running-on-the-edge-runtime
33
+ */
34
+ const isEdgeRuntime = typeof EdgeRuntime === "string";
35
+ if (isEdgeRuntime) {
36
+ return {
37
+ type: "edge-runtime",
38
+ };
39
+ }
40
+ /**
41
+ * A constant that indicates whether the environment the code is running is a Web Worker.
42
+ */
43
+ const isWebWorker = typeof self === "object" &&
44
+ // @ts-ignore
45
+ typeof (self === null || self === void 0 ? void 0 : self.importScripts) === "function" &&
46
+ (((_b = self.constructor) === null || _b === void 0 ? void 0 : _b.name) === "DedicatedWorkerGlobalScope" ||
47
+ ((_c = self.constructor) === null || _c === void 0 ? void 0 : _c.name) === "ServiceWorkerGlobalScope" ||
48
+ ((_d = self.constructor) === null || _d === void 0 ? void 0 : _d.name) === "SharedWorkerGlobalScope");
61
49
  if (isWebWorker) {
62
50
  return {
63
51
  type: "web-worker",
64
52
  };
65
53
  }
54
+ /**
55
+ * A constant that indicates whether the environment the code is running is Deno.
56
+ * FYI Deno spoofs process.versions.node, see https://deno.land/std@0.177.0/node/process.ts?s=versions
57
+ */
58
+ const isDeno = typeof Deno !== "undefined" && typeof Deno.version !== "undefined" && typeof Deno.version.deno !== "undefined";
66
59
  if (isDeno) {
67
60
  return {
68
61
  type: "deno",
69
62
  version: Deno.version.deno,
70
63
  };
71
64
  }
65
+ /**
66
+ * A constant that indicates whether the environment the code is running is Bun.sh.
67
+ */
68
+ const isBun = typeof Bun !== "undefined" && typeof Bun.version !== "undefined";
72
69
  if (isBun) {
73
70
  return {
74
71
  type: "bun",
75
72
  version: Bun.version,
76
73
  };
77
74
  }
75
+ /**
76
+ * A constant that indicates whether the environment the code is running is Node.JS.
77
+ */
78
+ const isNode = typeof process !== "undefined" &&
79
+ "version" in process &&
80
+ !!process.version &&
81
+ "versions" in process &&
82
+ !!((_e = process.versions) === null || _e === void 0 ? void 0 : _e.node);
78
83
  if (isNode) {
79
84
  return {
80
85
  type: "node",
@@ -82,6 +87,11 @@ function evaluateRuntime() {
82
87
  parsedVersion: Number(process.versions.node.split(".")[0]),
83
88
  };
84
89
  }
90
+ /**
91
+ * A constant that indicates whether the environment the code is running is in React-Native.
92
+ * https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Core/setUpNavigator.js
93
+ */
94
+ const isReactNative = typeof navigator !== "undefined" && (navigator === null || navigator === void 0 ? void 0 : navigator.product) === "ReactNative";
85
95
  if (isReactNative) {
86
96
  return {
87
97
  type: "react-native",
@@ -1,7 +1,7 @@
1
1
  import { SchemaUtils } from "./builders";
2
- export declare type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
3
- export declare type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
4
- export declare type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
2
+ export type Schema<Raw = unknown, Parsed = unknown> = BaseSchema<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
3
+ export type inferRaw<S extends Schema> = S extends Schema<infer Raw, any> ? Raw : never;
4
+ export type inferParsed<S extends Schema> = S extends Schema<any, infer Parsed> ? Parsed : never;
5
5
  export interface BaseSchema<Raw, Parsed> {
6
6
  parse: (raw: unknown, opts?: SchemaOptions) => MaybeValid<Parsed>;
7
7
  json: (parsed: unknown, opts?: SchemaOptions) => MaybeValid<Raw>;
@@ -24,10 +24,12 @@ export declare const SchemaType: {
24
24
  readonly SET: "set";
25
25
  readonly UNION: "union";
26
26
  readonly UNDISCRIMINATED_UNION: "undiscriminatedUnion";
27
+ readonly NULLABLE: "nullable";
27
28
  readonly OPTIONAL: "optional";
29
+ readonly OPTIONAL_NULLABLE: "optionalNullable";
28
30
  };
29
- export declare type SchemaType = typeof SchemaType[keyof typeof SchemaType];
30
- export declare type MaybeValid<T> = Valid<T> | Invalid;
31
+ export type SchemaType = (typeof SchemaType)[keyof typeof SchemaType];
32
+ export type MaybeValid<T> = Valid<T> | Invalid;
31
33
  export interface Valid<T> {
32
34
  ok: true;
33
35
  value: T;
@@ -18,5 +18,7 @@ exports.SchemaType = {
18
18
  SET: "set",
19
19
  UNION: "union",
20
20
  UNDISCRIMINATED_UNION: "undiscriminatedUnion",
21
+ NULLABLE: "nullable",
21
22
  OPTIONAL: "optional",
23
+ OPTIONAL_NULLABLE: "optionalNullable",
22
24
  };
@@ -1,2 +1,2 @@
1
1
  import { Schema } from "../../Schema";
2
- export declare function bigint(): Schema<string, bigint>;
2
+ export declare function bigint(): Schema<bigint | number, bigint>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.bigint = void 0;
3
+ exports.bigint = bigint;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
6
  const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
@@ -8,30 +8,30 @@ const schema_utils_1 = require("../schema-utils");
8
8
  function bigint() {
9
9
  const baseSchema = {
10
10
  parse: (raw, { breadcrumbsPrefix = [] } = {}) => {
11
- if (typeof raw !== "string") {
11
+ if (typeof raw === "bigint") {
12
12
  return {
13
- ok: false,
14
- errors: [
15
- {
16
- path: breadcrumbsPrefix,
17
- message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "string"),
18
- },
19
- ],
13
+ ok: true,
14
+ value: raw,
20
15
  };
21
16
  }
22
- return {
23
- ok: true,
24
- value: BigInt(raw),
25
- };
26
- },
27
- json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
28
- if (typeof bigint === "bigint") {
17
+ if (typeof raw === "number") {
29
18
  return {
30
19
  ok: true,
31
- value: bigint.toString(),
20
+ value: BigInt(raw),
32
21
  };
33
22
  }
34
- else {
23
+ return {
24
+ ok: false,
25
+ errors: [
26
+ {
27
+ path: breadcrumbsPrefix,
28
+ message: (0, getErrorMessageForIncorrectType_1.getErrorMessageForIncorrectType)(raw, "bigint | number"),
29
+ },
30
+ ],
31
+ };
32
+ },
33
+ json: (bigint, { breadcrumbsPrefix = [] } = {}) => {
34
+ if (typeof bigint !== "bigint") {
35
35
  return {
36
36
  ok: false,
37
37
  errors: [
@@ -42,9 +42,12 @@ function bigint() {
42
42
  ],
43
43
  };
44
44
  }
45
+ return {
46
+ ok: true,
47
+ value: bigint,
48
+ };
45
49
  },
46
50
  getType: () => Schema_1.SchemaType.BIGINT,
47
51
  };
48
52
  return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
49
53
  }
50
- exports.bigint = bigint;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.date = void 0;
3
+ exports.date = date;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
6
  const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
@@ -60,4 +60,3 @@ function date() {
60
60
  };
61
61
  return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
62
62
  }
63
- exports.date = date;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.enum_ = void 0;
3
+ exports.enum_ = enum_;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
6
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
@@ -36,4 +36,3 @@ function enum_(values) {
36
36
  });
37
37
  return schemaCreator();
38
38
  }
39
- exports.enum_ = enum_;
@@ -1,5 +1,5 @@
1
1
  import { BaseSchema, Schema } from "../../Schema";
2
- export declare type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
2
+ export type SchemaGetter<SchemaType extends Schema<any, any>> = () => SchemaType;
3
3
  export declare function lazy<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): Schema<Raw, Parsed>;
4
4
  export declare function constructLazyBaseSchema<Raw, Parsed>(getter: SchemaGetter<Schema<Raw, Parsed>>): BaseSchema<Raw, Parsed>;
5
5
  export declare function getMemoizedSchema<SchemaType extends Schema<any, any>>(getter: SchemaGetter<SchemaType>): SchemaType;
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMemoizedSchema = exports.constructLazyBaseSchema = exports.lazy = void 0;
3
+ exports.lazy = lazy;
4
+ exports.constructLazyBaseSchema = constructLazyBaseSchema;
5
+ exports.getMemoizedSchema = getMemoizedSchema;
4
6
  const schema_utils_1 = require("../schema-utils");
5
7
  function lazy(getter) {
6
8
  const baseSchema = constructLazyBaseSchema(getter);
7
9
  return Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema));
8
10
  }
9
- exports.lazy = lazy;
10
11
  function constructLazyBaseSchema(getter) {
11
12
  return {
12
13
  parse: (raw, opts) => getMemoizedSchema(getter).parse(raw, opts),
@@ -14,7 +15,6 @@ function constructLazyBaseSchema(getter) {
14
15
  getType: () => getMemoizedSchema(getter).getType(),
15
16
  };
16
17
  }
17
- exports.constructLazyBaseSchema = constructLazyBaseSchema;
18
18
  function getMemoizedSchema(getter) {
19
19
  const castedGetter = getter;
20
20
  if (castedGetter.__zurg_memoized == null) {
@@ -22,4 +22,3 @@ function getMemoizedSchema(getter) {
22
22
  }
23
23
  return castedGetter.__zurg_memoized;
24
24
  }
25
- exports.getMemoizedSchema = getMemoizedSchema;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lazyObject = void 0;
3
+ exports.lazyObject = lazyObject;
4
4
  const object_1 = require("../object");
5
5
  const object_like_1 = require("../object-like");
6
6
  const schema_utils_1 = require("../schema-utils");
@@ -9,4 +9,3 @@ function lazyObject(getter) {
9
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
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));
11
11
  }
12
- exports.lazyObject = lazyObject;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.list = void 0;
3
+ exports.list = list;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
6
  const maybeSkipValidation_1 = require("../../utils/maybeSkipValidation");
@@ -19,7 +19,6 @@ function list(schema) {
19
19
  };
20
20
  return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
21
21
  }
22
- exports.list = list;
23
22
  function validateAndTransformArray(value, transformItem) {
24
23
  if (!Array.isArray(value)) {
25
24
  return {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.booleanLiteral = void 0;
3
+ exports.booleanLiteral = booleanLiteral;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
6
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
@@ -26,4 +26,3 @@ function booleanLiteral(literal) {
26
26
  });
27
27
  return schemaCreator();
28
28
  }
29
- exports.booleanLiteral = booleanLiteral;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringLiteral = void 0;
3
+ exports.stringLiteral = stringLiteral;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const createIdentitySchemaCreator_1 = require("../../utils/createIdentitySchemaCreator");
6
6
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
@@ -26,4 +26,3 @@ function stringLiteral(literal) {
26
26
  });
27
27
  return schemaCreator();
28
28
  }
29
- exports.stringLiteral = stringLiteral;
@@ -1,3 +1,3 @@
1
- import { BaseObjectSchema, inferObjectSchemaFromPropertySchemas, ObjectUtils, PropertySchemas } from "./types";
1
+ import { BaseObjectSchema, ObjectUtils, PropertySchemas, inferObjectSchemaFromPropertySchemas } from "./types";
2
2
  export declare function object<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectSchemaFromPropertySchemas<T>;
3
3
  export declare function getObjectUtils<Raw, Parsed>(schema: BaseObjectSchema<Raw, Parsed>): ObjectUtils<Raw, Parsed>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getObjectUtils = exports.object = void 0;
3
+ exports.object = object;
4
+ exports.getObjectUtils = getObjectUtils;
4
5
  const Schema_1 = require("../../Schema");
5
6
  const entries_1 = require("../../utils/entries");
6
7
  const filterObject_1 = require("../../utils/filterObject");
@@ -104,7 +105,6 @@ function object(schemas) {
104
105
  };
105
106
  return Object.assign(Object.assign(Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
106
107
  }
107
- exports.object = object;
108
108
  function validateAndTransformObject({ value, requiredKeys, getProperty, unrecognizedObjectKeys = "fail", skipValidation = false, breadcrumbsPrefix = [], }) {
109
109
  if (!(0, isPlainObject_1.isPlainObject)(value)) {
110
110
  return {
@@ -194,9 +194,36 @@ function getObjectUtils(schema) {
194
194
  };
195
195
  return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
196
196
  },
197
+ passthrough: () => {
198
+ const baseSchema = {
199
+ _getParsedProperties: () => schema._getParsedProperties(),
200
+ _getRawProperties: () => schema._getRawProperties(),
201
+ parse: (raw, opts) => {
202
+ const transformed = schema.parse(raw, Object.assign(Object.assign({}, opts), { unrecognizedObjectKeys: "passthrough" }));
203
+ if (!transformed.ok) {
204
+ return transformed;
205
+ }
206
+ return {
207
+ ok: true,
208
+ value: Object.assign(Object.assign({}, raw), transformed.value),
209
+ };
210
+ },
211
+ json: (parsed, opts) => {
212
+ const transformed = schema.json(parsed, Object.assign(Object.assign({}, opts), { unrecognizedObjectKeys: "passthrough" }));
213
+ if (!transformed.ok) {
214
+ return transformed;
215
+ }
216
+ return {
217
+ ok: true,
218
+ value: Object.assign(Object.assign({}, parsed), transformed.value),
219
+ };
220
+ },
221
+ getType: () => Schema_1.SchemaType.OBJECT,
222
+ };
223
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, baseSchema), (0, schema_utils_1.getSchemaUtils)(baseSchema)), (0, object_like_1.getObjectLikeUtils)(baseSchema)), getObjectUtils(baseSchema));
224
+ },
197
225
  };
198
226
  }
199
- exports.getObjectUtils = getObjectUtils;
200
227
  function validateAndTransformExtendedObject({ extensionKeys, value, transformBase, transformExtension, }) {
201
228
  const extensionPropertiesSet = new Set(extensionKeys);
202
229
  const [extensionProperties, baseProperties] = (0, partition_1.partition)((0, keys_1.keys)(value), (key) => extensionPropertiesSet.has(key));
@@ -226,6 +253,7 @@ function isSchemaOptional(schema) {
226
253
  case Schema_1.SchemaType.ANY:
227
254
  case Schema_1.SchemaType.UNKNOWN:
228
255
  case Schema_1.SchemaType.OPTIONAL:
256
+ case Schema_1.SchemaType.OPTIONAL_NULLABLE:
229
257
  return true;
230
258
  default:
231
259
  return false;
@@ -1,6 +1,6 @@
1
- import { inferParsedPropertySchema, inferRawObjectFromPropertySchemas, ObjectSchema, PropertySchemas } from "./types";
1
+ import { ObjectSchema, PropertySchemas, inferParsedPropertySchema, inferRawObjectFromPropertySchemas } from "./types";
2
2
  export declare function objectWithoutOptionalProperties<ParsedKeys extends string, T extends PropertySchemas<ParsedKeys>>(schemas: T): inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T>;
3
- export declare type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T>>;
4
- export declare type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T extends PropertySchemas<keyof T>> = {
3
+ export type inferObjectWithoutOptionalPropertiesSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T>>;
4
+ export type inferParsedObjectWithoutOptionalPropertiesFromPropertySchemas<T extends PropertySchemas<keyof T>> = {
5
5
  [K in keyof T]: inferParsedPropertySchema<T[K]>;
6
6
  };
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.objectWithoutOptionalProperties = void 0;
3
+ exports.objectWithoutOptionalProperties = objectWithoutOptionalProperties;
4
4
  const object_1 = require("./object");
5
5
  function objectWithoutOptionalProperties(schemas) {
6
6
  return (0, object_1.object)(schemas);
7
7
  }
8
- exports.objectWithoutOptionalProperties = objectWithoutOptionalProperties;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isProperty = exports.property = void 0;
3
+ exports.property = property;
4
+ exports.isProperty = isProperty;
4
5
  function property(rawKey, valueSchema) {
5
6
  return {
6
7
  rawKey,
@@ -8,9 +9,7 @@ function property(rawKey, valueSchema) {
8
9
  isProperty: true,
9
10
  };
10
11
  }
11
- exports.property = property;
12
12
  function isProperty(maybeProperty) {
13
13
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
14
14
  return maybeProperty.isProperty;
15
15
  }
16
- exports.isProperty = isProperty;
@@ -1,26 +1,31 @@
1
- import { BaseSchema, inferParsed, inferRaw, Schema } from "../../Schema";
1
+ import { BaseSchema, Schema, inferParsed, inferRaw } from "../../Schema";
2
2
  import { addQuestionMarksToNullableProperties } from "../../utils/addQuestionMarksToNullableProperties";
3
3
  import { ObjectLikeUtils } from "../object-like";
4
4
  import { SchemaUtils } from "../schema-utils";
5
5
  import { Property } from "./property";
6
- export declare type ObjectSchema<Raw, Parsed> = BaseObjectSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed> & ObjectUtils<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
6
+ export type ObjectSchema<Raw, Parsed> = BaseObjectSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed> & ObjectUtils<Raw, Parsed> & SchemaUtils<Raw, Parsed>;
7
7
  export interface BaseObjectSchema<Raw, Parsed> extends BaseSchema<Raw, Parsed> {
8
8
  _getRawProperties: () => (keyof Raw)[];
9
9
  _getParsedProperties: () => (keyof Parsed)[];
10
10
  }
11
11
  export interface ObjectUtils<Raw, Parsed> {
12
12
  extend: <RawExtension, ParsedExtension>(schemas: ObjectSchema<RawExtension, ParsedExtension>) => ObjectSchema<Raw & RawExtension, Parsed & ParsedExtension>;
13
+ passthrough: () => ObjectSchema<Raw & {
14
+ [key: string]: unknown;
15
+ }, Parsed & {
16
+ [key: string]: unknown;
17
+ }>;
13
18
  }
14
- export declare type inferRawObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<infer Raw, any> ? Raw : never;
15
- export declare type inferParsedObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<any, infer Parsed> ? Parsed : never;
16
- export declare type inferObjectSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectFromPropertySchemas<T>>;
17
- export declare type inferRawObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
19
+ export type inferRawObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<infer Raw, any> ? Raw : never;
20
+ export type inferParsedObject<O extends ObjectSchema<any, any>> = O extends ObjectSchema<any, infer Parsed> ? Parsed : never;
21
+ export type inferObjectSchemaFromPropertySchemas<T extends PropertySchemas<keyof T>> = ObjectSchema<inferRawObjectFromPropertySchemas<T>, inferParsedObjectFromPropertySchemas<T>>;
22
+ export type inferRawObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
18
23
  [ParsedKey in keyof T as inferRawKey<ParsedKey, T[ParsedKey]>]: inferRawPropertySchema<T[ParsedKey]>;
19
24
  }>;
20
- export declare type inferParsedObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
25
+ export type inferParsedObjectFromPropertySchemas<T extends PropertySchemas<keyof T>> = addQuestionMarksToNullableProperties<{
21
26
  [K in keyof T]: inferParsedPropertySchema<T[K]>;
22
27
  }>;
23
- export declare type PropertySchemas<ParsedKeys extends string | number | symbol> = Record<ParsedKeys, Property<any, any, any> | Schema<any, any>>;
24
- export declare type inferRawPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, infer Raw, any> ? Raw : P extends Schema<any, any> ? inferRaw<P> : never;
25
- export declare type inferParsedPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, any, infer Parsed> ? Parsed : P extends Schema<any, any> ? inferParsed<P> : never;
26
- export declare type inferRawKey<ParsedKey extends string | number | symbol, P extends Property<any, any, any> | Schema<any, any>> = P extends Property<infer Raw, any, any> ? Raw : ParsedKey;
28
+ export type PropertySchemas<ParsedKeys extends string | number | symbol> = Record<ParsedKeys, Property<any, any, any> | Schema<any, any>>;
29
+ export type inferRawPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, infer Raw, any> ? Raw : P extends Schema<any, any> ? inferRaw<P> : never;
30
+ export type inferParsedPropertySchema<P extends Property<any, any, any> | Schema<any, any>> = P extends Property<any, any, infer Parsed> ? Parsed : P extends Schema<any, any> ? inferParsed<P> : never;
31
+ export type inferRawKey<ParsedKey extends string | number | symbol, P extends Property<any, any, any> | Schema<any, any>> = P extends Property<infer Raw, any, any> ? Raw : ParsedKey;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.withParsedProperties = exports.getObjectLikeUtils = void 0;
3
+ exports.getObjectLikeUtils = getObjectLikeUtils;
4
+ exports.withParsedProperties = withParsedProperties;
4
5
  const filterObject_1 = require("../../utils/filterObject");
5
6
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
6
7
  const isPlainObject_1 = require("../../utils/isPlainObject");
@@ -10,7 +11,6 @@ function getObjectLikeUtils(schema) {
10
11
  withParsedProperties: (properties) => withParsedProperties(schema, properties),
11
12
  };
12
13
  }
13
- exports.getObjectLikeUtils = getObjectLikeUtils;
14
14
  /**
15
15
  * object-like utils are defined in one file to resolve issues with circular imports
16
16
  */
@@ -51,4 +51,3 @@ function withParsedProperties(objectLike, properties) {
51
51
  };
52
52
  return Object.assign(Object.assign(Object.assign({}, objectSchema), (0, schema_utils_1.getSchemaUtils)(objectSchema)), getObjectLikeUtils(objectSchema));
53
53
  }
54
- exports.withParsedProperties = withParsedProperties;
@@ -1,5 +1,5 @@
1
1
  import { BaseSchema, Schema } from "../../Schema";
2
- export declare type ObjectLikeSchema<Raw, Parsed> = Schema<Raw, Parsed> & BaseSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed>;
2
+ export type ObjectLikeSchema<Raw, Parsed> = Schema<Raw, Parsed> & BaseSchema<Raw, Parsed> & ObjectLikeUtils<Raw, Parsed>;
3
3
  export interface ObjectLikeUtils<Raw, Parsed> {
4
4
  withParsedProperties: <T extends Record<string, any>>(properties: {
5
5
  [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]);
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.record = void 0;
3
+ exports.record = record;
4
4
  const Schema_1 = require("../../Schema");
5
5
  const entries_1 = require("../../utils/entries");
6
6
  const getErrorMessageForIncorrectType_1 = require("../../utils/getErrorMessageForIncorrectType");
@@ -43,7 +43,6 @@ function record(keySchema, valueSchema) {
43
43
  };
44
44
  return Object.assign(Object.assign({}, (0, maybeSkipValidation_1.maybeSkipValidation)(baseSchema)), (0, schema_utils_1.getSchemaUtils)(baseSchema));
45
45
  }
46
- exports.record = record;
47
46
  function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transformValue, breadcrumbsPrefix = [], }) {
48
47
  if (!(0, isPlainObject_1.isPlainObject)(value)) {
49
48
  return {
@@ -57,8 +56,7 @@ function validateAndTransformRecord({ value, isKeyNumeric, transformKey, transfo
57
56
  };
58
57
  }
59
58
  return (0, entries_1.entries)(value).reduce((accPromise, [stringKey, value]) => {
60
- // skip nullish keys
61
- if (value == null) {
59
+ if (value === undefined) {
62
60
  return accPromise;
63
61
  }
64
62
  const acc = accPromise;
@@ -1,4 +1,4 @@
1
1
  import { BaseSchema } from "../../Schema";
2
2
  import { SchemaUtils } from "../schema-utils";
3
- export declare type RecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> & SchemaUtils<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
4
- export declare type BaseRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseSchema<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
3
+ export type RecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseRecordSchema<RawKey, RawValue, ParsedKey, ParsedValue> & SchemaUtils<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
4
+ export type BaseRecordSchema<RawKey extends string | number, RawValue, ParsedKey extends string | number, ParsedValue> = BaseSchema<Record<RawKey, RawValue>, Record<ParsedKey, ParsedValue>>;
@@ -1,6 +1,8 @@
1
1
  import { BaseSchema, Schema, SchemaOptions } from "../../Schema";
2
2
  export interface SchemaUtils<Raw, Parsed> {
3
+ nullable: () => Schema<Raw | null, Parsed | null>;
3
4
  optional: () => Schema<Raw | null | undefined, Parsed | undefined>;
5
+ optionalNullable: () => Schema<Raw | null | undefined, Parsed | null | undefined>;
4
6
  transform: <Transformed>(transformer: SchemaTransformer<Parsed, Transformed>) => Schema<Raw, Transformed>;
5
7
  parseOrThrow: (raw: unknown, opts?: SchemaOptions) => Parsed;
6
8
  jsonOrThrow: (raw: unknown, opts?: SchemaOptions) => Raw;
@@ -13,5 +15,7 @@ export declare function getSchemaUtils<Raw, Parsed>(schema: BaseSchema<Raw, Pars
13
15
  /**
14
16
  * schema utils are defined in one file to resolve issues with circular imports
15
17
  */
18
+ export declare function nullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null, Parsed | null>;
16
19
  export declare function optional<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | undefined>;
20
+ export declare function optionalNullable<Raw, Parsed>(schema: BaseSchema<Raw, Parsed>): Schema<Raw | null | undefined, Parsed | null | undefined>;
17
21
  export declare function transform<Raw, Parsed, Transformed>(schema: BaseSchema<Raw, Parsed>, transformer: SchemaTransformer<Parsed, Transformed>): Schema<Raw, Transformed>;