@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,31 +1,31 @@
1
1
  import type Emittery from "emittery";
2
2
  import type { OutputFormat, RawEncoding, WebSocketResponse } from "../api";
3
- export declare type EmitteryCallbacks<T> = {
3
+ export type EmitteryCallbacks<T> = {
4
4
  on: Emittery<T>["on"];
5
5
  off: Emittery<T>["off"];
6
6
  once: Emittery<T>["once"];
7
7
  events: Emittery<T>["events"];
8
8
  };
9
- export declare type ConnectionEventData = {
9
+ export type ConnectionEventData = {
10
10
  open: never;
11
11
  close: never;
12
12
  };
13
- export declare type SourceEventData = {
13
+ export type SourceEventData = {
14
14
  enqueue: never;
15
15
  close: never;
16
16
  wait: never;
17
17
  read: never;
18
18
  };
19
- export declare type TypedArray = Float32Array | Int16Array | Uint8Array;
20
- export declare type Sentinel = null;
21
- export declare type Chunk = string | Sentinel;
22
- export declare type WebSocketOptions = {
19
+ export type TypedArray = Float32Array | Int16Array | Uint8Array;
20
+ export type Sentinel = null;
21
+ export type Chunk = string | Sentinel;
22
+ export type WebSocketOptions = {
23
23
  container?: string;
24
24
  encoding?: string;
25
25
  sampleRate: number;
26
26
  };
27
- export declare type Language = "en" | "es" | "fr" | "de" | "ja" | "zh" | "pt" | (string & {});
28
- export declare type EncodingInfo = {
27
+ export type Language = "en" | "es" | "fr" | "de" | "ja" | "zh" | "pt" | (string & {});
28
+ export type EncodingInfo = {
29
29
  arrayType: Float32ArrayConstructor | Int16ArrayConstructor | Uint8ArrayConstructor;
30
30
  bytesPerElement: number;
31
31
  };
@@ -3,7 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getEmitteryCallbacks = exports.isComplete = exports.filterSentinel = exports.isSentinel = exports.getSentinel = exports.createMessageHandlerForContextId = exports.playAudioBuffer = exports.base64ToArray = exports.resolveOutputFormat = exports.ENCODING_MAP = void 0;
6
+ exports.ENCODING_MAP = void 0;
7
+ exports.resolveOutputFormat = resolveOutputFormat;
8
+ exports.base64ToArray = base64ToArray;
9
+ exports.playAudioBuffer = playAudioBuffer;
10
+ exports.createMessageHandlerForContextId = createMessageHandlerForContextId;
11
+ exports.getSentinel = getSentinel;
12
+ exports.isSentinel = isSentinel;
13
+ exports.filterSentinel = filterSentinel;
14
+ exports.isComplete = isComplete;
15
+ exports.getEmitteryCallbacks = getEmitteryCallbacks;
7
16
  const base64_js_1 = __importDefault(require("base64-js"));
8
17
  exports.ENCODING_MAP = {
9
18
  pcm_f32le: { arrayType: Float32Array, bytesPerElement: 4 },
@@ -44,7 +53,6 @@ function resolveOutputFormat(container, encoding, sampleRate) {
44
53
  throw new Error(`Unsupported container type: ${container}`);
45
54
  }
46
55
  }
47
- exports.resolveOutputFormat = resolveOutputFormat;
48
56
  /**
49
57
  * Convert base64-encoded audio buffer(s) to a TypedArray.
50
58
  *
@@ -66,7 +74,6 @@ function base64ToArray(b64, encoding) {
66
74
  }
67
75
  return result;
68
76
  }
69
- exports.base64ToArray = base64ToArray;
70
77
  /**
71
78
  * Schedule an audio buffer to play at a given time in the passed context.
72
79
  *
@@ -89,7 +96,6 @@ function playAudioBuffer(floats, context, startAt, sampleRate) {
89
96
  };
90
97
  });
91
98
  }
92
- exports.playAudioBuffer = playAudioBuffer;
93
99
  /**
94
100
  * Unwraps a chunk of audio data from a message event and calls the
95
101
  * handler with it if the context ID matches.
@@ -118,7 +124,6 @@ function createMessageHandlerForContextId(contextId, handler) {
118
124
  handler({ chunk, message: event.data, data: message });
119
125
  };
120
126
  }
121
- exports.createMessageHandlerForContextId = createMessageHandlerForContextId;
122
127
  /**
123
128
  * Get a sentinel value that indicates the end of a stream.
124
129
  * @returns A sentinel value to indicate the end of a stream.
@@ -126,7 +131,6 @@ exports.createMessageHandlerForContextId = createMessageHandlerForContextId;
126
131
  function getSentinel() {
127
132
  return null;
128
133
  }
129
- exports.getSentinel = getSentinel;
130
134
  /**
131
135
  * Check if a chunk is a sentinel value (i.e. null).
132
136
  *
@@ -136,7 +140,6 @@ exports.getSentinel = getSentinel;
136
140
  function isSentinel(x) {
137
141
  return x === getSentinel();
138
142
  }
139
- exports.isSentinel = isSentinel;
140
143
  /**
141
144
  * Filter out null values from a collection.
142
145
  *
@@ -146,7 +149,6 @@ exports.isSentinel = isSentinel;
146
149
  function filterSentinel(collection) {
147
150
  return collection.filter((x) => !isSentinel(x));
148
151
  }
149
- exports.filterSentinel = filterSentinel;
150
152
  /**
151
153
  * Check if an array of chunks is complete by testing if the last chunk is a sentinel
152
154
  * value (i.e. null).
@@ -156,7 +158,6 @@ exports.filterSentinel = filterSentinel;
156
158
  function isComplete(chunks) {
157
159
  return isSentinel(chunks[chunks.length - 1]);
158
160
  }
159
- exports.isComplete = isComplete;
160
161
  /**
161
162
  * Get user-facing emitter callbacks for an Emittery instance.
162
163
  * @param emitter The Emittery instance to get callbacks for.
@@ -170,4 +171,3 @@ function getEmitteryCallbacks(emitter) {
170
171
  events: emitter.events.bind(emitter),
171
172
  };
172
173
  }
173
- exports.getEmitteryCallbacks = getEmitteryCallbacks;
package/environments.d.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  export declare const CartesiaEnvironment: {
5
5
  readonly Production: "https://api.cartesia.ai";
6
6
  };
7
- export declare type CartesiaEnvironment = typeof CartesiaEnvironment.Production;
7
+ export type CartesiaEnvironment = typeof CartesiaEnvironment.Production;
@@ -4,6 +4,7 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CartesiaError = void 0;
7
+ const json_1 = require("../core/json");
7
8
  class CartesiaError extends Error {
8
9
  constructor({ message, statusCode, body }) {
9
10
  super(buildMessage({ message, statusCode, body }));
@@ -26,7 +27,7 @@ function buildMessage({ message, statusCode, body, }) {
26
27
  lines.push(`Status code: ${statusCode.toString()}`);
27
28
  }
28
29
  if (body != null) {
29
- lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`);
30
+ lines.push(`Body: ${(0, json_1.toJson)(body, undefined, 2)}`);
30
31
  }
31
32
  return lines.join("\n");
32
33
  }
@@ -2,5 +2,5 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  export declare class CartesiaTimeoutError extends Error {
5
- constructor();
5
+ constructor(message: string);
6
6
  }
@@ -5,8 +5,8 @@
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.CartesiaTimeoutError = void 0;
7
7
  class CartesiaTimeoutError extends Error {
8
- constructor() {
9
- super("Timeout");
8
+ constructor(message) {
9
+ super(message);
10
10
  Object.setPrototypeOf(this, CartesiaTimeoutError.prototype);
11
11
  }
12
12
  }
package/index.js CHANGED
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.CartesiaTimeoutError = exports.CartesiaError = exports.CartesiaEnvironment = exports.WebPlayer = exports.CartesiaClient = exports.Cartesia = void 0;
27
37
  exports.Cartesia = __importStar(require("./api"));
@@ -1,5 +1,8 @@
1
1
  /** @type {import('jest').Config} */
2
- module.exports = {
2
+ export default {
3
3
  preset: "ts-jest",
4
4
  testEnvironment: "node",
5
+ moduleNameMapper: {
6
+ "(.+)\.js$": "$1",
7
+ },
5
8
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartesia/cartesia-js",
3
- "version": "2.1.4",
3
+ "version": "2.1.5",
4
4
  "private": false,
5
5
  "repository": "https://github.com/cartesia-ai/cartesia-js",
6
6
  "main": "./index.js",
@@ -15,8 +15,8 @@
15
15
  "url-join": "4.0.1",
16
16
  "form-data": "^4.0.0",
17
17
  "formdata-node": "^6.0.3",
18
- "node-fetch": "2.7.0",
19
- "qs": "6.11.2",
18
+ "node-fetch": "^2.7.0",
19
+ "qs": "^6.13.1",
20
20
  "readable-stream": "^4.5.2",
21
21
  "form-data-encoder": "^4.0.2",
22
22
  "emittery": "^0.13.1",
@@ -25,19 +25,18 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/url-join": "4.0.1",
28
- "@types/qs": "6.9.8",
29
- "@types/node-fetch": "2.6.9",
30
- "@types/readable-stream": "^4.0.15",
31
- "fetch-mock-jest": "^1.5.1",
32
- "webpack": "^5.94.0",
33
- "ts-loader": "^9.3.1",
34
- "jest": "29.7.0",
35
- "@types/jest": "29.5.5",
36
- "ts-jest": "29.1.1",
37
- "jest-environment-jsdom": "29.7.0",
38
- "@types/node": "17.0.33",
39
- "prettier": "2.7.1",
40
- "typescript": "4.6.4",
28
+ "@types/qs": "^6.9.17",
29
+ "@types/node-fetch": "^2.6.12",
30
+ "@types/readable-stream": "^4.0.18",
31
+ "webpack": "^5.97.1",
32
+ "ts-loader": "^9.5.1",
33
+ "jest": "^29.7.0",
34
+ "@types/jest": "^29.5.14",
35
+ "ts-jest": "^29.1.1",
36
+ "jest-environment-jsdom": "^29.7.0",
37
+ "@types/node": "^18.19.70",
38
+ "prettier": "^3.4.2",
39
+ "typescript": "~5.7.2",
41
40
  "@types/ws": "^8.5.13"
42
41
  },
43
42
  "browser": {
package/reference.md CHANGED
@@ -262,6 +262,8 @@ await client.datasets.uploadFile(fs.createReadStream("/path/to/your/file"), "str
262
262
 
263
263
  Generate audio that smoothly connects two existing audio segments. This is useful for inserting new speech between existing speech segments while maintaining natural transitions.
264
264
 
265
+ The cost is 1 credit per character of the infill text plus a fixed cost of 300 credits.
266
+
265
267
  Only the `sonic-preview` model is supported for infill at this time.
266
268
 
267
269
  At least one of `left_audio` or `right_audio` must be provided.
@@ -288,6 +290,8 @@ await client.infill.bytes(fs.createReadStream("/path/to/your/file"), fs.createRe
288
290
  outputFormatContainer: "mp3",
289
291
  outputFormatSampleRate: 44100,
290
292
  outputFormatBitRate: 128000,
293
+ voiceExperimentalControlsSpeed: "slowest",
294
+ voiceExperimentalControlsEmotion: ["surprise:high", "curiosity:high"],
291
295
  });
292
296
  ```
293
297
 
@@ -0,0 +1,115 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require("fs").promises;
4
+ const path = require("path");
5
+
6
+ const extensionMap = {
7
+ ".js": ".mjs",
8
+ ".d.ts": ".d.mts",
9
+ };
10
+ const oldExtensions = Object.keys(extensionMap);
11
+
12
+ async function findFiles(rootPath) {
13
+ const files = [];
14
+
15
+ async function scan(directory) {
16
+ const entries = await fs.readdir(directory, { withFileTypes: true });
17
+
18
+ for (const entry of entries) {
19
+ const fullPath = path.join(directory, entry.name);
20
+
21
+ if (entry.isDirectory()) {
22
+ if (entry.name !== "node_modules" && !entry.name.startsWith(".")) {
23
+ await scan(fullPath);
24
+ }
25
+ } else if (entry.isFile()) {
26
+ if (oldExtensions.some((ext) => entry.name.endsWith(ext))) {
27
+ files.push(fullPath);
28
+ }
29
+ }
30
+ }
31
+ }
32
+
33
+ await scan(rootPath);
34
+ return files;
35
+ }
36
+
37
+ async function updateFiles(files) {
38
+ const updatedFiles = [];
39
+ for (const file of files) {
40
+ const updated = await updateFileContents(file);
41
+ updatedFiles.push(updated);
42
+ }
43
+
44
+ console.log(`Updated imports in ${updatedFiles.length} files.`);
45
+ }
46
+
47
+ async function updateFileContents(file) {
48
+ const content = await fs.readFile(file, "utf8");
49
+
50
+ let newContent = content;
51
+ // Update each extension type defined in the map
52
+ for (const [oldExt, newExt] of Object.entries(extensionMap)) {
53
+ const regex = new RegExp(`(import|export)(.+from\\s+['"])(\\.\\.?\\/[^'"]+)(\\${oldExt})(['"])`, "g");
54
+ newContent = newContent.replace(regex, `$1$2$3${newExt}$5`);
55
+ }
56
+
57
+ if (content !== newContent) {
58
+ await fs.writeFile(file, newContent, "utf8");
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+
64
+ async function renameFiles(files) {
65
+ let counter = 0;
66
+ for (const file of files) {
67
+ const ext = oldExtensions.find((ext) => file.endsWith(ext));
68
+ const newExt = extensionMap[ext];
69
+
70
+ if (newExt) {
71
+ const newPath = file.slice(0, -ext.length) + newExt;
72
+ await fs.rename(file, newPath);
73
+ counter++;
74
+ }
75
+ }
76
+
77
+ console.log(`Renamed ${counter} files.`);
78
+ }
79
+
80
+ async function main() {
81
+ try {
82
+ const targetDir = process.argv[2];
83
+ if (!targetDir) {
84
+ console.error("Please provide a target directory");
85
+ process.exit(1);
86
+ }
87
+
88
+ const targetPath = path.resolve(targetDir);
89
+ const targetStats = await fs.stat(targetPath);
90
+
91
+ if (!targetStats.isDirectory()) {
92
+ console.error("The provided path is not a directory");
93
+ process.exit(1);
94
+ }
95
+
96
+ console.log(`Scanning directory: ${targetDir}`);
97
+
98
+ const files = await findFiles(targetDir);
99
+
100
+ if (files.length === 0) {
101
+ console.log("No matching files found.");
102
+ process.exit(0);
103
+ }
104
+
105
+ console.log(`Found ${files.length} files.`);
106
+ await updateFiles(files);
107
+ await renameFiles(files);
108
+ console.log("\nDone!");
109
+ } catch (error) {
110
+ console.error("An error occurred:", error.message);
111
+ process.exit(1);
112
+ }
113
+ }
114
+
115
+ main();
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.ApiInfo = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.CreateDatasetRequest = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.Dataset = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.DatasetFile = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.FilePurpose = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.PaginatedDatasetFiles = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.PaginatedDatasets = void 0;
30
40
  const core = __importStar(require("../../../../core"));
@@ -18,13 +18,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
18
18
  }) : function(o, v) {
19
19
  o["default"] = v;
20
20
  });
21
- var __importStar = (this && this.__importStar) || function (mod) {
22
- if (mod && mod.__esModule) return mod;
23
- var result = {};
24
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
- __setModuleDefault(result, mod);
26
- return result;
27
- };
21
+ var __importStar = (this && this.__importStar) || (function () {
22
+ var ownKeys = function(o) {
23
+ ownKeys = Object.getOwnPropertyNames || function (o) {
24
+ var ar = [];
25
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
+ return ar;
27
+ };
28
+ return ownKeys(o);
29
+ };
30
+ return function (mod) {
31
+ if (mod && mod.__esModule) return mod;
32
+ var result = {};
33
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
+ __setModuleDefault(result, mod);
35
+ return result;
36
+ };
37
+ })();
28
38
  Object.defineProperty(exports, "__esModule", { value: true });
29
39
  exports.Embedding = void 0;
30
40
  const core = __importStar(require("../../../../core"));