@humeai/audio-decisions 0.0.0-stage → 0.1.0

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 (896) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +411 -2
  3. package/dist/cjs/BaseClient.d.ts +54 -0
  4. package/dist/cjs/BaseClient.js +77 -0
  5. package/dist/cjs/Client.d.ts +29 -0
  6. package/dist/cjs/Client.js +88 -0
  7. package/dist/cjs/api/errors/BadRequestError.d.ts +7 -0
  8. package/dist/cjs/api/errors/BadRequestError.js +54 -0
  9. package/dist/cjs/api/errors/ContentTooLargeError.d.ts +7 -0
  10. package/dist/cjs/api/errors/ContentTooLargeError.js +54 -0
  11. package/dist/cjs/api/errors/ForbiddenError.d.ts +7 -0
  12. package/dist/cjs/api/errors/ForbiddenError.js +54 -0
  13. package/dist/cjs/api/errors/InternalServerError.d.ts +7 -0
  14. package/dist/cjs/api/errors/InternalServerError.js +54 -0
  15. package/dist/cjs/api/errors/NotFoundError.d.ts +7 -0
  16. package/dist/cjs/api/errors/NotFoundError.js +54 -0
  17. package/dist/cjs/api/errors/PaymentRequiredError.d.ts +7 -0
  18. package/dist/cjs/api/errors/PaymentRequiredError.js +54 -0
  19. package/dist/cjs/api/errors/ServiceUnavailableError.d.ts +7 -0
  20. package/dist/cjs/api/errors/ServiceUnavailableError.js +54 -0
  21. package/dist/cjs/api/errors/TooManyRequestsError.d.ts +7 -0
  22. package/dist/cjs/api/errors/TooManyRequestsError.js +54 -0
  23. package/dist/cjs/api/errors/UnauthorizedError.d.ts +7 -0
  24. package/dist/cjs/api/errors/UnauthorizedError.js +54 -0
  25. package/dist/cjs/api/errors/UnsupportedMediaTypeError.d.ts +7 -0
  26. package/dist/cjs/api/errors/UnsupportedMediaTypeError.js +54 -0
  27. package/dist/cjs/api/errors/index.d.ts +10 -0
  28. package/dist/cjs/api/errors/index.js +26 -0
  29. package/dist/cjs/api/index.d.ts +3 -0
  30. package/dist/cjs/api/index.js +19 -0
  31. package/dist/cjs/api/resources/decisions/client/Client.d.ts +284 -0
  32. package/dist/cjs/api/resources/decisions/client/Client.js +564 -0
  33. package/dist/cjs/api/resources/decisions/client/index.d.ts +1 -0
  34. package/dist/cjs/api/resources/decisions/client/index.js +17 -0
  35. package/dist/cjs/api/resources/decisions/client/requests/DecisionsUpload.d.ts +118 -0
  36. package/dist/cjs/api/resources/decisions/client/requests/DecisionsUpload.js +3 -0
  37. package/dist/cjs/api/resources/decisions/client/requests/InputTokensRequest.d.ts +44 -0
  38. package/dist/cjs/api/resources/decisions/client/requests/InputTokensRequest.js +3 -0
  39. package/dist/cjs/api/resources/decisions/client/requests/index.d.ts +2 -0
  40. package/dist/cjs/api/resources/decisions/client/requests/index.js +2 -0
  41. package/dist/cjs/api/resources/decisions/exports.d.ts +2 -0
  42. package/dist/cjs/api/resources/decisions/exports.js +21 -0
  43. package/dist/cjs/api/resources/decisions/index.d.ts +1 -0
  44. package/dist/cjs/api/resources/decisions/index.js +17 -0
  45. package/dist/cjs/api/resources/index.d.ts +4 -0
  46. package/dist/cjs/api/resources/index.js +43 -0
  47. package/dist/cjs/api/resources/runs/client/Client.d.ts +60 -0
  48. package/dist/cjs/api/resources/runs/client/Client.js +306 -0
  49. package/dist/cjs/api/resources/runs/client/index.d.ts +1 -0
  50. package/dist/cjs/api/resources/runs/client/index.js +17 -0
  51. package/dist/cjs/api/resources/runs/client/requests/GetRunsRequest.d.ts +10 -0
  52. package/dist/cjs/api/resources/runs/client/requests/GetRunsRequest.js +3 -0
  53. package/dist/cjs/api/resources/runs/client/requests/ListRunsRequest.d.ts +19 -0
  54. package/dist/cjs/api/resources/runs/client/requests/ListRunsRequest.js +3 -0
  55. package/dist/cjs/api/resources/runs/client/requests/index.d.ts +2 -0
  56. package/dist/cjs/api/resources/runs/client/requests/index.js +2 -0
  57. package/dist/cjs/api/resources/runs/exports.d.ts +2 -0
  58. package/dist/cjs/api/resources/runs/exports.js +21 -0
  59. package/dist/cjs/api/resources/runs/index.d.ts +1 -0
  60. package/dist/cjs/api/resources/runs/index.js +17 -0
  61. package/dist/cjs/api/types/Answer.d.ts +19 -0
  62. package/dist/cjs/api/types/Answer.js +3 -0
  63. package/dist/cjs/api/types/Answers.d.ts +7 -0
  64. package/dist/cjs/api/types/Answers.js +3 -0
  65. package/dist/cjs/api/types/ChoiceAnswer.d.ts +11 -0
  66. package/dist/cjs/api/types/ChoiceAnswer.js +3 -0
  67. package/dist/cjs/api/types/ChoiceQuestion.d.ts +10 -0
  68. package/dist/cjs/api/types/ChoiceQuestion.js +3 -0
  69. package/dist/cjs/api/types/Criterion.d.ts +9 -0
  70. package/dist/cjs/api/types/Criterion.js +3 -0
  71. package/dist/cjs/api/types/DecisionsRequest.d.ts +9 -0
  72. package/dist/cjs/api/types/DecisionsRequest.js +3 -0
  73. package/dist/cjs/api/types/DecisionsResponse.d.ts +10 -0
  74. package/dist/cjs/api/types/DecisionsResponse.js +3 -0
  75. package/dist/cjs/api/types/ErrorCode.d.ts +58 -0
  76. package/dist/cjs/api/types/ErrorCode.js +61 -0
  77. package/dist/cjs/api/types/ErrorType.d.ts +5 -0
  78. package/dist/cjs/api/types/ErrorType.js +8 -0
  79. package/dist/cjs/api/types/Error_.d.ts +15 -0
  80. package/dist/cjs/api/types/Error_.js +3 -0
  81. package/dist/cjs/api/types/GatewayError.d.ts +9 -0
  82. package/dist/cjs/api/types/GatewayError.js +3 -0
  83. package/dist/cjs/api/types/InputTokensResponse.d.ts +7 -0
  84. package/dist/cjs/api/types/InputTokensResponse.js +3 -0
  85. package/dist/cjs/api/types/Moment.d.ts +11 -0
  86. package/dist/cjs/api/types/Moment.js +3 -0
  87. package/dist/cjs/api/types/MomentAnswer.d.ts +8 -0
  88. package/dist/cjs/api/types/MomentAnswer.js +3 -0
  89. package/dist/cjs/api/types/MomentQuestion.d.ts +7 -0
  90. package/dist/cjs/api/types/MomentQuestion.js +3 -0
  91. package/dist/cjs/api/types/NoulAnswer.d.ts +7 -0
  92. package/dist/cjs/api/types/NoulAnswer.js +3 -0
  93. package/dist/cjs/api/types/NoulCriteria.d.ts +9 -0
  94. package/dist/cjs/api/types/NoulCriteria.js +3 -0
  95. package/dist/cjs/api/types/NoulQuestion.d.ts +9 -0
  96. package/dist/cjs/api/types/NoulQuestion.js +3 -0
  97. package/dist/cjs/api/types/Question.d.ts +19 -0
  98. package/dist/cjs/api/types/Question.js +3 -0
  99. package/dist/cjs/api/types/Questions.d.ts +7 -0
  100. package/dist/cjs/api/types/Questions.js +3 -0
  101. package/dist/cjs/api/types/Received.d.ts +7 -0
  102. package/dist/cjs/api/types/Received.js +3 -0
  103. package/dist/cjs/api/types/Run.d.ts +18 -0
  104. package/dist/cjs/api/types/Run.js +3 -0
  105. package/dist/cjs/api/types/RunReceived.d.ts +9 -0
  106. package/dist/cjs/api/types/RunReceived.js +3 -0
  107. package/dist/cjs/api/types/RunStatus.d.ts +6 -0
  108. package/dist/cjs/api/types/RunStatus.js +9 -0
  109. package/dist/cjs/api/types/RunSummary.d.ts +16 -0
  110. package/dist/cjs/api/types/RunSummary.js +3 -0
  111. package/dist/cjs/api/types/RunsPage.d.ts +10 -0
  112. package/dist/cjs/api/types/RunsPage.js +3 -0
  113. package/dist/cjs/api/types/ScoreAnswer.d.ts +13 -0
  114. package/dist/cjs/api/types/ScoreAnswer.js +3 -0
  115. package/dist/cjs/api/types/ScoreQuestion.d.ts +9 -0
  116. package/dist/cjs/api/types/ScoreQuestion.js +3 -0
  117. package/dist/cjs/api/types/index.d.ts +28 -0
  118. package/dist/cjs/api/types/index.js +44 -0
  119. package/dist/cjs/audio-helpers/bytes.d.ts +6 -0
  120. package/dist/cjs/audio-helpers/bytes.js +38 -0
  121. package/dist/cjs/audio-helpers/checks.d.ts +2 -0
  122. package/dist/cjs/audio-helpers/checks.js +25 -0
  123. package/dist/cjs/audio-helpers/chunks.d.ts +160 -0
  124. package/dist/cjs/audio-helpers/chunks.js +350 -0
  125. package/dist/cjs/audio-helpers/downmix.d.ts +17 -0
  126. package/dist/cjs/audio-helpers/downmix.js +291 -0
  127. package/dist/cjs/audio-helpers/errors.d.ts +4 -0
  128. package/dist/cjs/audio-helpers/errors.js +12 -0
  129. package/dist/cjs/audio-helpers/files.d.ts +27 -0
  130. package/dist/cjs/audio-helpers/files.js +178 -0
  131. package/dist/cjs/audio-helpers/index.d.ts +4 -0
  132. package/dist/cjs/audio-helpers/index.js +11 -0
  133. package/dist/cjs/audio-helpers/integers.d.ts +3 -0
  134. package/dist/cjs/audio-helpers/integers.js +26 -0
  135. package/dist/cjs/audio-helpers/mp3.d.ts +24 -0
  136. package/dist/cjs/audio-helpers/mp3.js +245 -0
  137. package/dist/cjs/audio-helpers/results.d.ts +74 -0
  138. package/dist/cjs/audio-helpers/results.js +187 -0
  139. package/dist/cjs/audio-helpers/wav.d.ts +21 -0
  140. package/dist/cjs/audio-helpers/wav.js +167 -0
  141. package/dist/cjs/auth/HeaderAuthProvider.d.ts +20 -0
  142. package/dist/cjs/auth/HeaderAuthProvider.js +83 -0
  143. package/dist/cjs/auth/index.d.ts +1 -0
  144. package/dist/cjs/auth/index.js +5 -0
  145. package/dist/cjs/core/auth/AuthProvider.d.ts +8 -0
  146. package/dist/cjs/core/auth/AuthProvider.js +9 -0
  147. package/dist/cjs/core/auth/AuthRequest.d.ts +9 -0
  148. package/dist/cjs/core/auth/AuthRequest.js +2 -0
  149. package/dist/cjs/core/auth/BasicAuth.d.ts +8 -0
  150. package/dist/cjs/core/auth/BasicAuth.js +33 -0
  151. package/dist/cjs/core/auth/BearerToken.d.ts +7 -0
  152. package/dist/cjs/core/auth/BearerToken.js +16 -0
  153. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +5 -0
  154. package/dist/cjs/core/auth/NoOpAuthProvider.js +9 -0
  155. package/dist/cjs/core/auth/index.d.ts +5 -0
  156. package/dist/cjs/core/auth/index.js +11 -0
  157. package/dist/cjs/core/base64.d.ts +2 -0
  158. package/dist/cjs/core/base64.js +26 -0
  159. package/dist/cjs/core/exports.d.ts +2 -0
  160. package/dist/cjs/core/exports.js +18 -0
  161. package/dist/cjs/core/fetcher/APIResponse.d.ts +20 -0
  162. package/dist/cjs/core/fetcher/APIResponse.js +2 -0
  163. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +19 -0
  164. package/dist/cjs/core/fetcher/BinaryResponse.js +17 -0
  165. package/dist/cjs/core/fetcher/EndpointMetadata.d.ts +13 -0
  166. package/dist/cjs/core/fetcher/EndpointMetadata.js +2 -0
  167. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +12 -0
  168. package/dist/cjs/core/fetcher/EndpointSupplier.js +22 -0
  169. package/dist/cjs/core/fetcher/Fetcher.d.ts +56 -0
  170. package/dist/cjs/core/fetcher/Fetcher.js +275 -0
  171. package/dist/cjs/core/fetcher/Headers.d.ts +2 -0
  172. package/dist/cjs/core/fetcher/Headers.js +84 -0
  173. package/dist/cjs/core/fetcher/HttpResponsePromise.d.ts +58 -0
  174. package/dist/cjs/core/fetcher/HttpResponsePromise.js +103 -0
  175. package/dist/cjs/core/fetcher/RawResponse.d.ts +29 -0
  176. package/dist/cjs/core/fetcher/RawResponse.js +44 -0
  177. package/dist/cjs/core/fetcher/Supplier.d.ts +4 -0
  178. package/dist/cjs/core/fetcher/Supplier.js +22 -0
  179. package/dist/cjs/core/fetcher/createRequestUrl.d.ts +1 -0
  180. package/dist/cjs/core/fetcher/createRequestUrl.js +8 -0
  181. package/dist/cjs/core/fetcher/getErrorResponseBody.d.ts +1 -0
  182. package/dist/cjs/core/fetcher/getErrorResponseBody.js +58 -0
  183. package/dist/cjs/core/fetcher/getFetchFn.d.ts +1 -0
  184. package/dist/cjs/core/fetcher/getFetchFn.js +17 -0
  185. package/dist/cjs/core/fetcher/getHeader.d.ts +1 -0
  186. package/dist/cjs/core/fetcher/getHeader.js +11 -0
  187. package/dist/cjs/core/fetcher/getRequestBody.d.ts +7 -0
  188. package/dist/cjs/core/fetcher/getRequestBody.js +27 -0
  189. package/dist/cjs/core/fetcher/getResponseBody.d.ts +17 -0
  190. package/dist/cjs/core/fetcher/getResponseBody.js +85 -0
  191. package/dist/cjs/core/fetcher/index.d.ts +13 -0
  192. package/dist/cjs/core/fetcher/index.js +19 -0
  193. package/dist/cjs/core/fetcher/makePassthroughRequest.d.ts +49 -0
  194. package/dist/cjs/core/fetcher/makePassthroughRequest.js +173 -0
  195. package/dist/cjs/core/fetcher/makeRequest.d.ts +11 -0
  196. package/dist/cjs/core/fetcher/makeRequest.js +94 -0
  197. package/dist/cjs/core/fetcher/redactUrl.d.ts +2 -0
  198. package/dist/cjs/core/fetcher/redactUrl.js +88 -0
  199. package/dist/cjs/core/fetcher/requestWithRetries.d.ts +1 -0
  200. package/dist/cjs/core/fetcher/requestWithRetries.js +91 -0
  201. package/dist/cjs/core/fetcher/signals.d.ts +6 -0
  202. package/dist/cjs/core/fetcher/signals.js +33 -0
  203. package/dist/cjs/core/file/exports.d.ts +1 -0
  204. package/dist/cjs/core/file/exports.js +2 -0
  205. package/dist/cjs/core/file/file.d.ts +10 -0
  206. package/dist/cjs/core/file/file.js +225 -0
  207. package/dist/cjs/core/file/index.d.ts +2 -0
  208. package/dist/cjs/core/file/index.js +18 -0
  209. package/dist/cjs/core/file/types.d.ts +66 -0
  210. package/dist/cjs/core/file/types.js +2 -0
  211. package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
  212. package/dist/cjs/core/form-data-utils/FormDataWrapper.js +192 -0
  213. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
  214. package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
  215. package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
  216. package/dist/cjs/core/form-data-utils/index.js +20 -0
  217. package/dist/cjs/core/headers.d.ts +2 -0
  218. package/dist/cjs/core/headers.js +31 -0
  219. package/dist/cjs/core/index.d.ts +9 -0
  220. package/dist/cjs/core/index.js +48 -0
  221. package/dist/cjs/core/json.d.ts +15 -0
  222. package/dist/cjs/core/json.js +24 -0
  223. package/dist/cjs/core/logging/exports.d.ts +18 -0
  224. package/dist/cjs/core/logging/exports.js +45 -0
  225. package/dist/cjs/core/logging/index.d.ts +1 -0
  226. package/dist/cjs/core/logging/index.js +17 -0
  227. package/dist/cjs/core/logging/logger.d.ts +126 -0
  228. package/dist/cjs/core/logging/logger.js +144 -0
  229. package/dist/cjs/core/requestBody.d.ts +12 -0
  230. package/dist/cjs/core/requestBody.js +26 -0
  231. package/dist/cjs/core/runtime/index.d.ts +1 -0
  232. package/dist/cjs/core/runtime/index.js +6 -0
  233. package/dist/cjs/core/runtime/runtime.d.ts +28 -0
  234. package/dist/cjs/core/runtime/runtime.js +176 -0
  235. package/dist/cjs/core/schemas/Schema.d.ts +88 -0
  236. package/dist/cjs/core/schemas/Schema.js +25 -0
  237. package/dist/cjs/core/schemas/builders/bigint/bigint.d.ts +2 -0
  238. package/dist/cjs/core/schemas/builders/bigint/bigint.js +53 -0
  239. package/dist/cjs/core/schemas/builders/bigint/index.d.ts +1 -0
  240. package/dist/cjs/core/schemas/builders/bigint/index.js +5 -0
  241. package/dist/cjs/core/schemas/builders/date/date.d.ts +2 -0
  242. package/dist/cjs/core/schemas/builders/date/date.js +62 -0
  243. package/dist/cjs/core/schemas/builders/date/index.d.ts +1 -0
  244. package/dist/cjs/core/schemas/builders/date/index.js +5 -0
  245. package/dist/cjs/core/schemas/builders/enum/enum.d.ts +3 -0
  246. package/dist/cjs/core/schemas/builders/enum/enum.js +45 -0
  247. package/dist/cjs/core/schemas/builders/enum/index.d.ts +1 -0
  248. package/dist/cjs/core/schemas/builders/enum/index.js +6 -0
  249. package/dist/cjs/core/schemas/builders/index.d.ts +14 -0
  250. package/dist/cjs/core/schemas/builders/index.js +30 -0
  251. package/dist/cjs/core/schemas/builders/lazy/index.d.ts +3 -0
  252. package/dist/cjs/core/schemas/builders/lazy/index.js +7 -0
  253. package/dist/cjs/core/schemas/builders/lazy/lazy.d.ts +5 -0
  254. package/dist/cjs/core/schemas/builders/lazy/lazy.js +24 -0
  255. package/dist/cjs/core/schemas/builders/lazy/lazyObject.d.ts +3 -0
  256. package/dist/cjs/core/schemas/builders/lazy/lazyObject.js +11 -0
  257. package/dist/cjs/core/schemas/builders/list/index.d.ts +1 -0
  258. package/dist/cjs/core/schemas/builders/list/index.js +5 -0
  259. package/dist/cjs/core/schemas/builders/list/list.d.ts +2 -0
  260. package/dist/cjs/core/schemas/builders/list/list.js +49 -0
  261. package/dist/cjs/core/schemas/builders/literals/booleanLiteral.d.ts +2 -0
  262. package/dist/cjs/core/schemas/builders/literals/booleanLiteral.js +28 -0
  263. package/dist/cjs/core/schemas/builders/literals/index.d.ts +2 -0
  264. package/dist/cjs/core/schemas/builders/literals/index.js +7 -0
  265. package/dist/cjs/core/schemas/builders/literals/stringLiteral.d.ts +2 -0
  266. package/dist/cjs/core/schemas/builders/literals/stringLiteral.js +28 -0
  267. package/dist/cjs/core/schemas/builders/object/index.d.ts +6 -0
  268. package/dist/cjs/core/schemas/builders/object/index.js +11 -0
  269. package/dist/cjs/core/schemas/builders/object/object.d.ts +3 -0
  270. package/dist/cjs/core/schemas/builders/object/object.js +354 -0
  271. package/dist/cjs/core/schemas/builders/object/objectWithoutOptionalProperties.d.ts +6 -0
  272. package/dist/cjs/core/schemas/builders/object/objectWithoutOptionalProperties.js +7 -0
  273. package/dist/cjs/core/schemas/builders/object/property.d.ts +8 -0
  274. package/dist/cjs/core/schemas/builders/object/property.js +15 -0
  275. package/dist/cjs/core/schemas/builders/object/types.d.ts +31 -0
  276. package/dist/cjs/core/schemas/builders/object/types.js +2 -0
  277. package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.d.ts +9 -0
  278. package/dist/cjs/core/schemas/builders/object-like/getObjectLikeUtils.js +60 -0
  279. package/dist/cjs/core/schemas/builders/object-like/index.d.ts +2 -0
  280. package/dist/cjs/core/schemas/builders/object-like/index.js +6 -0
  281. package/dist/cjs/core/schemas/builders/object-like/types.d.ts +7 -0
  282. package/dist/cjs/core/schemas/builders/object-like/types.js +2 -0
  283. package/dist/cjs/core/schemas/builders/primitives/any.d.ts +2 -0
  284. package/dist/cjs/core/schemas/builders/primitives/any.js +9 -0
  285. package/dist/cjs/core/schemas/builders/primitives/boolean.d.ts +2 -0
  286. package/dist/cjs/core/schemas/builders/primitives/boolean.js +25 -0
  287. package/dist/cjs/core/schemas/builders/primitives/index.d.ts +6 -0
  288. package/dist/cjs/core/schemas/builders/primitives/index.js +15 -0
  289. package/dist/cjs/core/schemas/builders/primitives/never.d.ts +2 -0
  290. package/dist/cjs/core/schemas/builders/primitives/never.js +14 -0
  291. package/dist/cjs/core/schemas/builders/primitives/number.d.ts +2 -0
  292. package/dist/cjs/core/schemas/builders/primitives/number.js +25 -0
  293. package/dist/cjs/core/schemas/builders/primitives/string.d.ts +2 -0
  294. package/dist/cjs/core/schemas/builders/primitives/string.js +25 -0
  295. package/dist/cjs/core/schemas/builders/primitives/unknown.d.ts +2 -0
  296. package/dist/cjs/core/schemas/builders/primitives/unknown.js +6 -0
  297. package/dist/cjs/core/schemas/builders/record/index.d.ts +2 -0
  298. package/dist/cjs/core/schemas/builders/record/index.js +6 -0
  299. package/dist/cjs/core/schemas/builders/record/record.d.ts +4 -0
  300. package/dist/cjs/core/schemas/builders/record/record.js +131 -0
  301. package/dist/cjs/core/schemas/builders/record/types.d.ts +6 -0
  302. package/dist/cjs/core/schemas/builders/record/types.js +2 -0
  303. package/dist/cjs/core/schemas/builders/schema-utils/JsonError.d.ts +5 -0
  304. package/dist/cjs/core/schemas/builders/schema-utils/JsonError.js +13 -0
  305. package/dist/cjs/core/schemas/builders/schema-utils/ParseError.d.ts +5 -0
  306. package/dist/cjs/core/schemas/builders/schema-utils/ParseError.js +13 -0
  307. package/dist/cjs/core/schemas/builders/schema-utils/getSchemaUtils.d.ts +21 -0
  308. package/dist/cjs/core/schemas/builders/schema-utils/getSchemaUtils.js +145 -0
  309. package/dist/cjs/core/schemas/builders/schema-utils/index.d.ts +4 -0
  310. package/dist/cjs/core/schemas/builders/schema-utils/index.js +11 -0
  311. package/dist/cjs/core/schemas/builders/schema-utils/stringifyValidationErrors.d.ts +2 -0
  312. package/dist/cjs/core/schemas/builders/schema-utils/stringifyValidationErrors.js +9 -0
  313. package/dist/cjs/core/schemas/builders/set/index.d.ts +1 -0
  314. package/dist/cjs/core/schemas/builders/set/index.js +5 -0
  315. package/dist/cjs/core/schemas/builders/set/set.d.ts +2 -0
  316. package/dist/cjs/core/schemas/builders/set/set.js +43 -0
  317. package/dist/cjs/core/schemas/builders/undiscriminated-union/index.d.ts +2 -0
  318. package/dist/cjs/core/schemas/builders/undiscriminated-union/index.js +5 -0
  319. package/dist/cjs/core/schemas/builders/undiscriminated-union/types.d.ts +4 -0
  320. package/dist/cjs/core/schemas/builders/undiscriminated-union/types.js +2 -0
  321. package/dist/cjs/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.ts +3 -0
  322. package/dist/cjs/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.js +39 -0
  323. package/dist/cjs/core/schemas/builders/union/discriminant.d.ts +5 -0
  324. package/dist/cjs/core/schemas/builders/union/discriminant.js +9 -0
  325. package/dist/cjs/core/schemas/builders/union/index.d.ts +4 -0
  326. package/dist/cjs/core/schemas/builders/union/index.js +7 -0
  327. package/dist/cjs/core/schemas/builders/union/types.d.ts +13 -0
  328. package/dist/cjs/core/schemas/builders/union/types.js +2 -0
  329. package/dist/cjs/core/schemas/builders/union/union.d.ts +4 -0
  330. package/dist/cjs/core/schemas/builders/union/union.js +126 -0
  331. package/dist/cjs/core/schemas/index.d.ts +2 -0
  332. package/dist/cjs/core/schemas/index.js +17 -0
  333. package/dist/cjs/core/schemas/utils/MaybePromise.d.ts +1 -0
  334. package/dist/cjs/core/schemas/utils/MaybePromise.js +2 -0
  335. package/dist/cjs/core/schemas/utils/addQuestionMarksToNullableProperties.d.ts +7 -0
  336. package/dist/cjs/core/schemas/utils/addQuestionMarksToNullableProperties.js +2 -0
  337. package/dist/cjs/core/schemas/utils/createIdentitySchemaCreator.d.ts +2 -0
  338. package/dist/cjs/core/schemas/utils/createIdentitySchemaCreator.js +15 -0
  339. package/dist/cjs/core/schemas/utils/entries.d.ts +1 -0
  340. package/dist/cjs/core/schemas/utils/entries.js +6 -0
  341. package/dist/cjs/core/schemas/utils/filterObject.d.ts +1 -0
  342. package/dist/cjs/core/schemas/utils/filterObject.js +13 -0
  343. package/dist/cjs/core/schemas/utils/getErrorMessageForIncorrectType.d.ts +1 -0
  344. package/dist/cjs/core/schemas/utils/getErrorMessageForIncorrectType.js +27 -0
  345. package/dist/cjs/core/schemas/utils/isPlainObject.d.ts +1 -0
  346. package/dist/cjs/core/schemas/utils/isPlainObject.js +15 -0
  347. package/dist/cjs/core/schemas/utils/keys.d.ts +1 -0
  348. package/dist/cjs/core/schemas/utils/keys.js +6 -0
  349. package/dist/cjs/core/schemas/utils/maybeSkipValidation.d.ts +2 -0
  350. package/dist/cjs/core/schemas/utils/maybeSkipValidation.js +27 -0
  351. package/dist/cjs/core/schemas/utils/partition.d.ts +1 -0
  352. package/dist/cjs/core/schemas/utils/partition.js +15 -0
  353. package/dist/cjs/core/url/QueryStringBuilder.d.ts +47 -0
  354. package/dist/cjs/core/url/QueryStringBuilder.js +83 -0
  355. package/dist/cjs/core/url/encodePathParam.d.ts +3 -0
  356. package/dist/cjs/core/url/encodePathParam.js +27 -0
  357. package/dist/cjs/core/url/index.d.ts +4 -0
  358. package/dist/cjs/core/url/index.js +11 -0
  359. package/dist/cjs/core/url/join.d.ts +1 -0
  360. package/dist/cjs/core/url/join.js +68 -0
  361. package/dist/cjs/core/url/qs.d.ts +7 -0
  362. package/dist/cjs/core/url/qs.js +76 -0
  363. package/dist/cjs/environments.d.ts +4 -0
  364. package/dist/cjs/environments.js +7 -0
  365. package/dist/cjs/errors/DecisionsError.d.ts +15 -0
  366. package/dist/cjs/errors/DecisionsError.js +53 -0
  367. package/dist/cjs/errors/DecisionsTimeoutError.d.ts +6 -0
  368. package/dist/cjs/errors/DecisionsTimeoutError.js +52 -0
  369. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
  370. package/dist/cjs/errors/handleNonStatusCodeError.js +68 -0
  371. package/dist/cjs/errors/index.d.ts +2 -0
  372. package/dist/cjs/errors/index.js +7 -0
  373. package/dist/cjs/exports.d.ts +1 -0
  374. package/dist/cjs/exports.js +17 -0
  375. package/dist/cjs/index.d.ts +7 -0
  376. package/dist/cjs/index.js +49 -0
  377. package/dist/cjs/serialization/index.d.ts +2 -0
  378. package/dist/cjs/serialization/index.js +18 -0
  379. package/dist/cjs/serialization/resources/decisions/client/index.d.ts +1 -0
  380. package/dist/cjs/serialization/resources/decisions/client/index.js +17 -0
  381. package/dist/cjs/serialization/resources/decisions/client/requests/InputTokensRequest.d.ts +12 -0
  382. package/dist/cjs/serialization/resources/decisions/client/requests/InputTokensRequest.js +44 -0
  383. package/dist/cjs/serialization/resources/decisions/client/requests/index.d.ts +1 -0
  384. package/dist/cjs/serialization/resources/decisions/client/requests/index.js +5 -0
  385. package/dist/cjs/serialization/resources/decisions/index.d.ts +1 -0
  386. package/dist/cjs/serialization/resources/decisions/index.js +17 -0
  387. package/dist/cjs/serialization/resources/index.d.ts +2 -0
  388. package/dist/cjs/serialization/resources/index.js +41 -0
  389. package/dist/cjs/serialization/types/Answer.d.ts +23 -0
  390. package/dist/cjs/serialization/types/Answer.js +53 -0
  391. package/dist/cjs/serialization/types/Answers.d.ts +10 -0
  392. package/dist/cjs/serialization/types/Answers.js +40 -0
  393. package/dist/cjs/serialization/types/ChoiceAnswer.d.ts +11 -0
  394. package/dist/cjs/serialization/types/ChoiceAnswer.js +43 -0
  395. package/dist/cjs/serialization/types/ChoiceQuestion.d.ts +11 -0
  396. package/dist/cjs/serialization/types/ChoiceQuestion.js +43 -0
  397. package/dist/cjs/serialization/types/Criterion.d.ts +10 -0
  398. package/dist/cjs/serialization/types/Criterion.js +42 -0
  399. package/dist/cjs/serialization/types/DecisionsRequest.d.ts +11 -0
  400. package/dist/cjs/serialization/types/DecisionsRequest.js +43 -0
  401. package/dist/cjs/serialization/types/DecisionsResponse.d.ts +13 -0
  402. package/dist/cjs/serialization/types/DecisionsResponse.js +45 -0
  403. package/dist/cjs/serialization/types/ErrorCode.d.ts +7 -0
  404. package/dist/cjs/serialization/types/ErrorCode.js +54 -0
  405. package/dist/cjs/serialization/types/ErrorType.d.ts +7 -0
  406. package/dist/cjs/serialization/types/ErrorType.js +39 -0
  407. package/dist/cjs/serialization/types/Error_.d.ts +15 -0
  408. package/dist/cjs/serialization/types/Error_.js +47 -0
  409. package/dist/cjs/serialization/types/GatewayError.d.ts +10 -0
  410. package/dist/cjs/serialization/types/GatewayError.js +42 -0
  411. package/dist/cjs/serialization/types/InputTokensResponse.d.ts +9 -0
  412. package/dist/cjs/serialization/types/InputTokensResponse.js +41 -0
  413. package/dist/cjs/serialization/types/Moment.d.ts +11 -0
  414. package/dist/cjs/serialization/types/Moment.js +43 -0
  415. package/dist/cjs/serialization/types/MomentAnswer.d.ts +10 -0
  416. package/dist/cjs/serialization/types/MomentAnswer.js +42 -0
  417. package/dist/cjs/serialization/types/MomentQuestion.d.ts +9 -0
  418. package/dist/cjs/serialization/types/MomentQuestion.js +41 -0
  419. package/dist/cjs/serialization/types/NoulAnswer.d.ts +9 -0
  420. package/dist/cjs/serialization/types/NoulAnswer.js +41 -0
  421. package/dist/cjs/serialization/types/NoulCriteria.d.ts +10 -0
  422. package/dist/cjs/serialization/types/NoulCriteria.js +42 -0
  423. package/dist/cjs/serialization/types/NoulQuestion.d.ts +11 -0
  424. package/dist/cjs/serialization/types/NoulQuestion.js +43 -0
  425. package/dist/cjs/serialization/types/Question.d.ts +23 -0
  426. package/dist/cjs/serialization/types/Question.js +53 -0
  427. package/dist/cjs/serialization/types/Questions.d.ts +10 -0
  428. package/dist/cjs/serialization/types/Questions.js +40 -0
  429. package/dist/cjs/serialization/types/Received.d.ts +9 -0
  430. package/dist/cjs/serialization/types/Received.js +41 -0
  431. package/dist/cjs/serialization/types/Run.d.ts +18 -0
  432. package/dist/cjs/serialization/types/Run.js +50 -0
  433. package/dist/cjs/serialization/types/RunReceived.d.ts +10 -0
  434. package/dist/cjs/serialization/types/RunReceived.js +42 -0
  435. package/dist/cjs/serialization/types/RunStatus.d.ts +7 -0
  436. package/dist/cjs/serialization/types/RunStatus.js +39 -0
  437. package/dist/cjs/serialization/types/RunSummary.d.ts +16 -0
  438. package/dist/cjs/serialization/types/RunSummary.js +48 -0
  439. package/dist/cjs/serialization/types/RunsPage.d.ts +11 -0
  440. package/dist/cjs/serialization/types/RunsPage.js +43 -0
  441. package/dist/cjs/serialization/types/ScoreAnswer.d.ts +12 -0
  442. package/dist/cjs/serialization/types/ScoreAnswer.js +44 -0
  443. package/dist/cjs/serialization/types/ScoreQuestion.d.ts +10 -0
  444. package/dist/cjs/serialization/types/ScoreQuestion.js +42 -0
  445. package/dist/cjs/serialization/types/index.d.ts +28 -0
  446. package/dist/cjs/serialization/types/index.js +44 -0
  447. package/dist/cjs/version.d.ts +1 -0
  448. package/dist/cjs/version.js +4 -0
  449. package/dist/esm/BaseClient.d.mts +54 -0
  450. package/dist/esm/BaseClient.mjs +40 -0
  451. package/dist/esm/Client.d.mts +29 -0
  452. package/dist/esm/Client.mjs +51 -0
  453. package/dist/esm/api/errors/BadRequestError.d.mts +7 -0
  454. package/dist/esm/api/errors/BadRequestError.mjs +17 -0
  455. package/dist/esm/api/errors/ContentTooLargeError.d.mts +7 -0
  456. package/dist/esm/api/errors/ContentTooLargeError.mjs +17 -0
  457. package/dist/esm/api/errors/ForbiddenError.d.mts +7 -0
  458. package/dist/esm/api/errors/ForbiddenError.mjs +17 -0
  459. package/dist/esm/api/errors/InternalServerError.d.mts +7 -0
  460. package/dist/esm/api/errors/InternalServerError.mjs +17 -0
  461. package/dist/esm/api/errors/NotFoundError.d.mts +7 -0
  462. package/dist/esm/api/errors/NotFoundError.mjs +17 -0
  463. package/dist/esm/api/errors/PaymentRequiredError.d.mts +7 -0
  464. package/dist/esm/api/errors/PaymentRequiredError.mjs +17 -0
  465. package/dist/esm/api/errors/ServiceUnavailableError.d.mts +7 -0
  466. package/dist/esm/api/errors/ServiceUnavailableError.mjs +17 -0
  467. package/dist/esm/api/errors/TooManyRequestsError.d.mts +7 -0
  468. package/dist/esm/api/errors/TooManyRequestsError.mjs +17 -0
  469. package/dist/esm/api/errors/UnauthorizedError.d.mts +7 -0
  470. package/dist/esm/api/errors/UnauthorizedError.mjs +17 -0
  471. package/dist/esm/api/errors/UnsupportedMediaTypeError.d.mts +7 -0
  472. package/dist/esm/api/errors/UnsupportedMediaTypeError.mjs +17 -0
  473. package/dist/esm/api/errors/index.d.mts +10 -0
  474. package/dist/esm/api/errors/index.mjs +10 -0
  475. package/dist/esm/api/index.d.mts +3 -0
  476. package/dist/esm/api/index.mjs +3 -0
  477. package/dist/esm/api/resources/decisions/client/Client.d.mts +284 -0
  478. package/dist/esm/api/resources/decisions/client/Client.mjs +527 -0
  479. package/dist/esm/api/resources/decisions/client/index.d.mts +1 -0
  480. package/dist/esm/api/resources/decisions/client/index.mjs +1 -0
  481. package/dist/esm/api/resources/decisions/client/requests/DecisionsUpload.d.mts +118 -0
  482. package/dist/esm/api/resources/decisions/client/requests/DecisionsUpload.mjs +2 -0
  483. package/dist/esm/api/resources/decisions/client/requests/InputTokensRequest.d.mts +44 -0
  484. package/dist/esm/api/resources/decisions/client/requests/InputTokensRequest.mjs +2 -0
  485. package/dist/esm/api/resources/decisions/client/requests/index.d.mts +2 -0
  486. package/dist/esm/api/resources/decisions/client/requests/index.mjs +1 -0
  487. package/dist/esm/api/resources/decisions/exports.d.mts +2 -0
  488. package/dist/esm/api/resources/decisions/exports.mjs +3 -0
  489. package/dist/esm/api/resources/decisions/index.d.mts +1 -0
  490. package/dist/esm/api/resources/decisions/index.mjs +1 -0
  491. package/dist/esm/api/resources/index.d.mts +4 -0
  492. package/dist/esm/api/resources/index.mjs +4 -0
  493. package/dist/esm/api/resources/runs/client/Client.d.mts +60 -0
  494. package/dist/esm/api/resources/runs/client/Client.mjs +269 -0
  495. package/dist/esm/api/resources/runs/client/index.d.mts +1 -0
  496. package/dist/esm/api/resources/runs/client/index.mjs +1 -0
  497. package/dist/esm/api/resources/runs/client/requests/GetRunsRequest.d.mts +10 -0
  498. package/dist/esm/api/resources/runs/client/requests/GetRunsRequest.mjs +2 -0
  499. package/dist/esm/api/resources/runs/client/requests/ListRunsRequest.d.mts +19 -0
  500. package/dist/esm/api/resources/runs/client/requests/ListRunsRequest.mjs +2 -0
  501. package/dist/esm/api/resources/runs/client/requests/index.d.mts +2 -0
  502. package/dist/esm/api/resources/runs/client/requests/index.mjs +1 -0
  503. package/dist/esm/api/resources/runs/exports.d.mts +2 -0
  504. package/dist/esm/api/resources/runs/exports.mjs +3 -0
  505. package/dist/esm/api/resources/runs/index.d.mts +1 -0
  506. package/dist/esm/api/resources/runs/index.mjs +1 -0
  507. package/dist/esm/api/types/Answer.d.mts +19 -0
  508. package/dist/esm/api/types/Answer.mjs +2 -0
  509. package/dist/esm/api/types/Answers.d.mts +7 -0
  510. package/dist/esm/api/types/Answers.mjs +2 -0
  511. package/dist/esm/api/types/ChoiceAnswer.d.mts +11 -0
  512. package/dist/esm/api/types/ChoiceAnswer.mjs +2 -0
  513. package/dist/esm/api/types/ChoiceQuestion.d.mts +10 -0
  514. package/dist/esm/api/types/ChoiceQuestion.mjs +2 -0
  515. package/dist/esm/api/types/Criterion.d.mts +9 -0
  516. package/dist/esm/api/types/Criterion.mjs +2 -0
  517. package/dist/esm/api/types/DecisionsRequest.d.mts +9 -0
  518. package/dist/esm/api/types/DecisionsRequest.mjs +2 -0
  519. package/dist/esm/api/types/DecisionsResponse.d.mts +10 -0
  520. package/dist/esm/api/types/DecisionsResponse.mjs +2 -0
  521. package/dist/esm/api/types/ErrorCode.d.mts +58 -0
  522. package/dist/esm/api/types/ErrorCode.mjs +58 -0
  523. package/dist/esm/api/types/ErrorType.d.mts +5 -0
  524. package/dist/esm/api/types/ErrorType.mjs +5 -0
  525. package/dist/esm/api/types/Error_.d.mts +15 -0
  526. package/dist/esm/api/types/Error_.mjs +2 -0
  527. package/dist/esm/api/types/GatewayError.d.mts +9 -0
  528. package/dist/esm/api/types/GatewayError.mjs +2 -0
  529. package/dist/esm/api/types/InputTokensResponse.d.mts +7 -0
  530. package/dist/esm/api/types/InputTokensResponse.mjs +2 -0
  531. package/dist/esm/api/types/Moment.d.mts +11 -0
  532. package/dist/esm/api/types/Moment.mjs +2 -0
  533. package/dist/esm/api/types/MomentAnswer.d.mts +8 -0
  534. package/dist/esm/api/types/MomentAnswer.mjs +2 -0
  535. package/dist/esm/api/types/MomentQuestion.d.mts +7 -0
  536. package/dist/esm/api/types/MomentQuestion.mjs +2 -0
  537. package/dist/esm/api/types/NoulAnswer.d.mts +7 -0
  538. package/dist/esm/api/types/NoulAnswer.mjs +2 -0
  539. package/dist/esm/api/types/NoulCriteria.d.mts +9 -0
  540. package/dist/esm/api/types/NoulCriteria.mjs +2 -0
  541. package/dist/esm/api/types/NoulQuestion.d.mts +9 -0
  542. package/dist/esm/api/types/NoulQuestion.mjs +2 -0
  543. package/dist/esm/api/types/Question.d.mts +19 -0
  544. package/dist/esm/api/types/Question.mjs +2 -0
  545. package/dist/esm/api/types/Questions.d.mts +7 -0
  546. package/dist/esm/api/types/Questions.mjs +2 -0
  547. package/dist/esm/api/types/Received.d.mts +7 -0
  548. package/dist/esm/api/types/Received.mjs +2 -0
  549. package/dist/esm/api/types/Run.d.mts +18 -0
  550. package/dist/esm/api/types/Run.mjs +2 -0
  551. package/dist/esm/api/types/RunReceived.d.mts +9 -0
  552. package/dist/esm/api/types/RunReceived.mjs +2 -0
  553. package/dist/esm/api/types/RunStatus.d.mts +6 -0
  554. package/dist/esm/api/types/RunStatus.mjs +6 -0
  555. package/dist/esm/api/types/RunSummary.d.mts +16 -0
  556. package/dist/esm/api/types/RunSummary.mjs +2 -0
  557. package/dist/esm/api/types/RunsPage.d.mts +10 -0
  558. package/dist/esm/api/types/RunsPage.mjs +2 -0
  559. package/dist/esm/api/types/ScoreAnswer.d.mts +13 -0
  560. package/dist/esm/api/types/ScoreAnswer.mjs +2 -0
  561. package/dist/esm/api/types/ScoreQuestion.d.mts +9 -0
  562. package/dist/esm/api/types/ScoreQuestion.mjs +2 -0
  563. package/dist/esm/api/types/index.d.mts +28 -0
  564. package/dist/esm/api/types/index.mjs +28 -0
  565. package/dist/esm/audio-helpers/bytes.d.mts +6 -0
  566. package/dist/esm/audio-helpers/bytes.mjs +32 -0
  567. package/dist/esm/audio-helpers/checks.d.mts +2 -0
  568. package/dist/esm/audio-helpers/checks.mjs +21 -0
  569. package/dist/esm/audio-helpers/chunks.d.mts +160 -0
  570. package/dist/esm/audio-helpers/chunks.mjs +346 -0
  571. package/dist/esm/audio-helpers/downmix.d.mts +17 -0
  572. package/dist/esm/audio-helpers/downmix.mjs +287 -0
  573. package/dist/esm/audio-helpers/errors.d.mts +4 -0
  574. package/dist/esm/audio-helpers/errors.mjs +8 -0
  575. package/dist/esm/audio-helpers/files.d.mts +27 -0
  576. package/dist/esm/audio-helpers/files.mjs +173 -0
  577. package/dist/esm/audio-helpers/index.d.mts +4 -0
  578. package/dist/esm/audio-helpers/index.mjs +5 -0
  579. package/dist/esm/audio-helpers/integers.d.mts +3 -0
  580. package/dist/esm/audio-helpers/integers.mjs +21 -0
  581. package/dist/esm/audio-helpers/mp3.d.mts +24 -0
  582. package/dist/esm/audio-helpers/mp3.mjs +239 -0
  583. package/dist/esm/audio-helpers/results.d.mts +74 -0
  584. package/dist/esm/audio-helpers/results.mjs +181 -0
  585. package/dist/esm/audio-helpers/wav.d.mts +21 -0
  586. package/dist/esm/audio-helpers/wav.mjs +161 -0
  587. package/dist/esm/auth/HeaderAuthProvider.d.mts +20 -0
  588. package/dist/esm/auth/HeaderAuthProvider.mjs +46 -0
  589. package/dist/esm/auth/index.d.mts +1 -0
  590. package/dist/esm/auth/index.mjs +1 -0
  591. package/dist/esm/core/auth/AuthProvider.d.mts +8 -0
  592. package/dist/esm/core/auth/AuthProvider.mjs +6 -0
  593. package/dist/esm/core/auth/AuthRequest.d.mts +9 -0
  594. package/dist/esm/core/auth/AuthRequest.mjs +1 -0
  595. package/dist/esm/core/auth/BasicAuth.d.mts +8 -0
  596. package/dist/esm/core/auth/BasicAuth.mjs +30 -0
  597. package/dist/esm/core/auth/BearerToken.d.mts +7 -0
  598. package/dist/esm/core/auth/BearerToken.mjs +13 -0
  599. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +5 -0
  600. package/dist/esm/core/auth/NoOpAuthProvider.mjs +5 -0
  601. package/dist/esm/core/auth/index.d.mts +5 -0
  602. package/dist/esm/core/auth/index.mjs +4 -0
  603. package/dist/esm/core/base64.d.mts +2 -0
  604. package/dist/esm/core/base64.mjs +22 -0
  605. package/dist/esm/core/exports.d.mts +2 -0
  606. package/dist/esm/core/exports.mjs +2 -0
  607. package/dist/esm/core/fetcher/APIResponse.d.mts +20 -0
  608. package/dist/esm/core/fetcher/APIResponse.mjs +1 -0
  609. package/dist/esm/core/fetcher/BinaryResponse.d.mts +19 -0
  610. package/dist/esm/core/fetcher/BinaryResponse.mjs +14 -0
  611. package/dist/esm/core/fetcher/EndpointMetadata.d.mts +13 -0
  612. package/dist/esm/core/fetcher/EndpointMetadata.mjs +1 -0
  613. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +12 -0
  614. package/dist/esm/core/fetcher/EndpointSupplier.mjs +19 -0
  615. package/dist/esm/core/fetcher/Fetcher.d.mts +56 -0
  616. package/dist/esm/core/fetcher/Fetcher.mjs +271 -0
  617. package/dist/esm/core/fetcher/Headers.d.mts +2 -0
  618. package/dist/esm/core/fetcher/Headers.mjs +82 -0
  619. package/dist/esm/core/fetcher/HttpResponsePromise.d.mts +58 -0
  620. package/dist/esm/core/fetcher/HttpResponsePromise.mjs +99 -0
  621. package/dist/esm/core/fetcher/RawResponse.d.mts +29 -0
  622. package/dist/esm/core/fetcher/RawResponse.mjs +40 -0
  623. package/dist/esm/core/fetcher/Supplier.d.mts +4 -0
  624. package/dist/esm/core/fetcher/Supplier.mjs +19 -0
  625. package/dist/esm/core/fetcher/createRequestUrl.d.mts +1 -0
  626. package/dist/esm/core/fetcher/createRequestUrl.mjs +5 -0
  627. package/dist/esm/core/fetcher/getErrorResponseBody.d.mts +1 -0
  628. package/dist/esm/core/fetcher/getErrorResponseBody.mjs +55 -0
  629. package/dist/esm/core/fetcher/getFetchFn.d.mts +1 -0
  630. package/dist/esm/core/fetcher/getFetchFn.mjs +14 -0
  631. package/dist/esm/core/fetcher/getHeader.d.mts +1 -0
  632. package/dist/esm/core/fetcher/getHeader.mjs +8 -0
  633. package/dist/esm/core/fetcher/getRequestBody.d.mts +7 -0
  634. package/dist/esm/core/fetcher/getRequestBody.mjs +24 -0
  635. package/dist/esm/core/fetcher/getResponseBody.d.mts +17 -0
  636. package/dist/esm/core/fetcher/getResponseBody.mjs +81 -0
  637. package/dist/esm/core/fetcher/index.d.mts +13 -0
  638. package/dist/esm/core/fetcher/index.mjs +7 -0
  639. package/dist/esm/core/fetcher/makePassthroughRequest.d.mts +49 -0
  640. package/dist/esm/core/fetcher/makePassthroughRequest.mjs +170 -0
  641. package/dist/esm/core/fetcher/makeRequest.d.mts +11 -0
  642. package/dist/esm/core/fetcher/makeRequest.mjs +87 -0
  643. package/dist/esm/core/fetcher/redactUrl.d.mts +2 -0
  644. package/dist/esm/core/fetcher/redactUrl.mjs +84 -0
  645. package/dist/esm/core/fetcher/requestWithRetries.d.mts +1 -0
  646. package/dist/esm/core/fetcher/requestWithRetries.mjs +88 -0
  647. package/dist/esm/core/fetcher/signals.d.mts +6 -0
  648. package/dist/esm/core/fetcher/signals.mjs +28 -0
  649. package/dist/esm/core/file/exports.d.mts +1 -0
  650. package/dist/esm/core/file/exports.mjs +1 -0
  651. package/dist/esm/core/file/file.d.mts +10 -0
  652. package/dist/esm/core/file/file.mjs +188 -0
  653. package/dist/esm/core/file/index.d.mts +2 -0
  654. package/dist/esm/core/file/index.mjs +2 -0
  655. package/dist/esm/core/file/types.d.mts +66 -0
  656. package/dist/esm/core/file/types.mjs +1 -0
  657. package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
  658. package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +154 -0
  659. package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
  660. package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
  661. package/dist/esm/core/form-data-utils/index.d.mts +2 -0
  662. package/dist/esm/core/form-data-utils/index.mjs +2 -0
  663. package/dist/esm/core/headers.d.mts +2 -0
  664. package/dist/esm/core/headers.mjs +27 -0
  665. package/dist/esm/core/index.d.mts +9 -0
  666. package/dist/esm/core/index.mjs +9 -0
  667. package/dist/esm/core/json.d.mts +15 -0
  668. package/dist/esm/core/json.mjs +19 -0
  669. package/dist/esm/core/logging/exports.d.mts +18 -0
  670. package/dist/esm/core/logging/exports.mjs +9 -0
  671. package/dist/esm/core/logging/index.d.mts +1 -0
  672. package/dist/esm/core/logging/index.mjs +1 -0
  673. package/dist/esm/core/logging/logger.d.mts +126 -0
  674. package/dist/esm/core/logging/logger.mjs +138 -0
  675. package/dist/esm/core/requestBody.d.mts +12 -0
  676. package/dist/esm/core/requestBody.mjs +23 -0
  677. package/dist/esm/core/runtime/index.d.mts +1 -0
  678. package/dist/esm/core/runtime/index.mjs +1 -0
  679. package/dist/esm/core/runtime/runtime.d.mts +28 -0
  680. package/dist/esm/core/runtime/runtime.mjs +172 -0
  681. package/dist/esm/core/schemas/Schema.d.mts +88 -0
  682. package/dist/esm/core/schemas/Schema.mjs +22 -0
  683. package/dist/esm/core/schemas/builders/bigint/bigint.d.mts +2 -0
  684. package/dist/esm/core/schemas/builders/bigint/bigint.mjs +50 -0
  685. package/dist/esm/core/schemas/builders/bigint/index.d.mts +1 -0
  686. package/dist/esm/core/schemas/builders/bigint/index.mjs +1 -0
  687. package/dist/esm/core/schemas/builders/date/date.d.mts +2 -0
  688. package/dist/esm/core/schemas/builders/date/date.mjs +59 -0
  689. package/dist/esm/core/schemas/builders/date/index.d.mts +1 -0
  690. package/dist/esm/core/schemas/builders/date/index.mjs +1 -0
  691. package/dist/esm/core/schemas/builders/enum/enum.d.mts +3 -0
  692. package/dist/esm/core/schemas/builders/enum/enum.mjs +41 -0
  693. package/dist/esm/core/schemas/builders/enum/index.d.mts +1 -0
  694. package/dist/esm/core/schemas/builders/enum/index.mjs +1 -0
  695. package/dist/esm/core/schemas/builders/index.d.mts +14 -0
  696. package/dist/esm/core/schemas/builders/index.mjs +14 -0
  697. package/dist/esm/core/schemas/builders/lazy/index.d.mts +3 -0
  698. package/dist/esm/core/schemas/builders/lazy/index.mjs +2 -0
  699. package/dist/esm/core/schemas/builders/lazy/lazy.d.mts +5 -0
  700. package/dist/esm/core/schemas/builders/lazy/lazy.mjs +19 -0
  701. package/dist/esm/core/schemas/builders/lazy/lazyObject.d.mts +3 -0
  702. package/dist/esm/core/schemas/builders/lazy/lazyObject.mjs +8 -0
  703. package/dist/esm/core/schemas/builders/list/index.d.mts +1 -0
  704. package/dist/esm/core/schemas/builders/list/index.mjs +1 -0
  705. package/dist/esm/core/schemas/builders/list/list.d.mts +2 -0
  706. package/dist/esm/core/schemas/builders/list/list.mjs +46 -0
  707. package/dist/esm/core/schemas/builders/literals/booleanLiteral.d.mts +2 -0
  708. package/dist/esm/core/schemas/builders/literals/booleanLiteral.mjs +25 -0
  709. package/dist/esm/core/schemas/builders/literals/index.d.mts +2 -0
  710. package/dist/esm/core/schemas/builders/literals/index.mjs +2 -0
  711. package/dist/esm/core/schemas/builders/literals/stringLiteral.d.mts +2 -0
  712. package/dist/esm/core/schemas/builders/literals/stringLiteral.mjs +25 -0
  713. package/dist/esm/core/schemas/builders/object/index.d.mts +6 -0
  714. package/dist/esm/core/schemas/builders/object/index.mjs +3 -0
  715. package/dist/esm/core/schemas/builders/object/object.d.mts +3 -0
  716. package/dist/esm/core/schemas/builders/object/object.mjs +350 -0
  717. package/dist/esm/core/schemas/builders/object/objectWithoutOptionalProperties.d.mts +6 -0
  718. package/dist/esm/core/schemas/builders/object/objectWithoutOptionalProperties.mjs +4 -0
  719. package/dist/esm/core/schemas/builders/object/property.d.mts +8 -0
  720. package/dist/esm/core/schemas/builders/object/property.mjs +11 -0
  721. package/dist/esm/core/schemas/builders/object/types.d.mts +31 -0
  722. package/dist/esm/core/schemas/builders/object/types.mjs +1 -0
  723. package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.d.mts +9 -0
  724. package/dist/esm/core/schemas/builders/object-like/getObjectLikeUtils.mjs +56 -0
  725. package/dist/esm/core/schemas/builders/object-like/index.d.mts +2 -0
  726. package/dist/esm/core/schemas/builders/object-like/index.mjs +1 -0
  727. package/dist/esm/core/schemas/builders/object-like/types.d.mts +7 -0
  728. package/dist/esm/core/schemas/builders/object-like/types.mjs +1 -0
  729. package/dist/esm/core/schemas/builders/primitives/any.d.mts +2 -0
  730. package/dist/esm/core/schemas/builders/primitives/any.mjs +6 -0
  731. package/dist/esm/core/schemas/builders/primitives/boolean.d.mts +2 -0
  732. package/dist/esm/core/schemas/builders/primitives/boolean.mjs +22 -0
  733. package/dist/esm/core/schemas/builders/primitives/index.d.mts +6 -0
  734. package/dist/esm/core/schemas/builders/primitives/index.mjs +6 -0
  735. package/dist/esm/core/schemas/builders/primitives/never.d.mts +2 -0
  736. package/dist/esm/core/schemas/builders/primitives/never.mjs +11 -0
  737. package/dist/esm/core/schemas/builders/primitives/number.d.mts +2 -0
  738. package/dist/esm/core/schemas/builders/primitives/number.mjs +22 -0
  739. package/dist/esm/core/schemas/builders/primitives/string.d.mts +2 -0
  740. package/dist/esm/core/schemas/builders/primitives/string.mjs +22 -0
  741. package/dist/esm/core/schemas/builders/primitives/unknown.d.mts +2 -0
  742. package/dist/esm/core/schemas/builders/primitives/unknown.mjs +3 -0
  743. package/dist/esm/core/schemas/builders/record/index.d.mts +2 -0
  744. package/dist/esm/core/schemas/builders/record/index.mjs +1 -0
  745. package/dist/esm/core/schemas/builders/record/record.d.mts +4 -0
  746. package/dist/esm/core/schemas/builders/record/record.mjs +127 -0
  747. package/dist/esm/core/schemas/builders/record/types.d.mts +6 -0
  748. package/dist/esm/core/schemas/builders/record/types.mjs +1 -0
  749. package/dist/esm/core/schemas/builders/schema-utils/JsonError.d.mts +5 -0
  750. package/dist/esm/core/schemas/builders/schema-utils/JsonError.mjs +9 -0
  751. package/dist/esm/core/schemas/builders/schema-utils/ParseError.d.mts +5 -0
  752. package/dist/esm/core/schemas/builders/schema-utils/ParseError.mjs +9 -0
  753. package/dist/esm/core/schemas/builders/schema-utils/getSchemaUtils.d.mts +21 -0
  754. package/dist/esm/core/schemas/builders/schema-utils/getSchemaUtils.mjs +138 -0
  755. package/dist/esm/core/schemas/builders/schema-utils/index.d.mts +4 -0
  756. package/dist/esm/core/schemas/builders/schema-utils/index.mjs +3 -0
  757. package/dist/esm/core/schemas/builders/schema-utils/stringifyValidationErrors.d.mts +2 -0
  758. package/dist/esm/core/schemas/builders/schema-utils/stringifyValidationErrors.mjs +6 -0
  759. package/dist/esm/core/schemas/builders/set/index.d.mts +1 -0
  760. package/dist/esm/core/schemas/builders/set/index.mjs +1 -0
  761. package/dist/esm/core/schemas/builders/set/set.d.mts +2 -0
  762. package/dist/esm/core/schemas/builders/set/set.mjs +40 -0
  763. package/dist/esm/core/schemas/builders/undiscriminated-union/index.d.mts +2 -0
  764. package/dist/esm/core/schemas/builders/undiscriminated-union/index.mjs +1 -0
  765. package/dist/esm/core/schemas/builders/undiscriminated-union/types.d.mts +4 -0
  766. package/dist/esm/core/schemas/builders/undiscriminated-union/types.mjs +1 -0
  767. package/dist/esm/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.d.mts +3 -0
  768. package/dist/esm/core/schemas/builders/undiscriminated-union/undiscriminatedUnion.mjs +36 -0
  769. package/dist/esm/core/schemas/builders/union/discriminant.d.mts +5 -0
  770. package/dist/esm/core/schemas/builders/union/discriminant.mjs +6 -0
  771. package/dist/esm/core/schemas/builders/union/index.d.mts +4 -0
  772. package/dist/esm/core/schemas/builders/union/index.mjs +2 -0
  773. package/dist/esm/core/schemas/builders/union/types.d.mts +13 -0
  774. package/dist/esm/core/schemas/builders/union/types.mjs +1 -0
  775. package/dist/esm/core/schemas/builders/union/union.d.mts +4 -0
  776. package/dist/esm/core/schemas/builders/union/union.mjs +123 -0
  777. package/dist/esm/core/schemas/index.d.mts +2 -0
  778. package/dist/esm/core/schemas/index.mjs +1 -0
  779. package/dist/esm/core/schemas/utils/MaybePromise.d.mts +1 -0
  780. package/dist/esm/core/schemas/utils/MaybePromise.mjs +1 -0
  781. package/dist/esm/core/schemas/utils/addQuestionMarksToNullableProperties.d.mts +7 -0
  782. package/dist/esm/core/schemas/utils/addQuestionMarksToNullableProperties.mjs +1 -0
  783. package/dist/esm/core/schemas/utils/createIdentitySchemaCreator.d.mts +2 -0
  784. package/dist/esm/core/schemas/utils/createIdentitySchemaCreator.mjs +12 -0
  785. package/dist/esm/core/schemas/utils/entries.d.mts +1 -0
  786. package/dist/esm/core/schemas/utils/entries.mjs +3 -0
  787. package/dist/esm/core/schemas/utils/filterObject.d.mts +1 -0
  788. package/dist/esm/core/schemas/utils/filterObject.mjs +10 -0
  789. package/dist/esm/core/schemas/utils/getErrorMessageForIncorrectType.d.mts +1 -0
  790. package/dist/esm/core/schemas/utils/getErrorMessageForIncorrectType.mjs +24 -0
  791. package/dist/esm/core/schemas/utils/isPlainObject.d.mts +1 -0
  792. package/dist/esm/core/schemas/utils/isPlainObject.mjs +12 -0
  793. package/dist/esm/core/schemas/utils/keys.d.mts +1 -0
  794. package/dist/esm/core/schemas/utils/keys.mjs +3 -0
  795. package/dist/esm/core/schemas/utils/maybeSkipValidation.d.mts +2 -0
  796. package/dist/esm/core/schemas/utils/maybeSkipValidation.mjs +24 -0
  797. package/dist/esm/core/schemas/utils/partition.d.mts +1 -0
  798. package/dist/esm/core/schemas/utils/partition.mjs +12 -0
  799. package/dist/esm/core/url/QueryStringBuilder.d.mts +47 -0
  800. package/dist/esm/core/url/QueryStringBuilder.mjs +80 -0
  801. package/dist/esm/core/url/encodePathParam.d.mts +3 -0
  802. package/dist/esm/core/url/encodePathParam.mjs +24 -0
  803. package/dist/esm/core/url/index.d.mts +4 -0
  804. package/dist/esm/core/url/index.mjs +4 -0
  805. package/dist/esm/core/url/join.d.mts +1 -0
  806. package/dist/esm/core/url/join.mjs +65 -0
  807. package/dist/esm/core/url/qs.d.mts +7 -0
  808. package/dist/esm/core/url/qs.mjs +73 -0
  809. package/dist/esm/environments.d.mts +4 -0
  810. package/dist/esm/environments.mjs +4 -0
  811. package/dist/esm/errors/DecisionsError.d.mts +15 -0
  812. package/dist/esm/errors/DecisionsError.mjs +49 -0
  813. package/dist/esm/errors/DecisionsTimeoutError.d.mts +6 -0
  814. package/dist/esm/errors/DecisionsTimeoutError.mjs +15 -0
  815. package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
  816. package/dist/esm/errors/handleNonStatusCodeError.mjs +32 -0
  817. package/dist/esm/errors/index.d.mts +2 -0
  818. package/dist/esm/errors/index.mjs +2 -0
  819. package/dist/esm/exports.d.mts +1 -0
  820. package/dist/esm/exports.mjs +1 -0
  821. package/dist/esm/index.d.mts +7 -0
  822. package/dist/esm/index.mjs +6 -0
  823. package/dist/esm/serialization/index.d.mts +2 -0
  824. package/dist/esm/serialization/index.mjs +2 -0
  825. package/dist/esm/serialization/resources/decisions/client/index.d.mts +1 -0
  826. package/dist/esm/serialization/resources/decisions/client/index.mjs +1 -0
  827. package/dist/esm/serialization/resources/decisions/client/requests/InputTokensRequest.d.mts +12 -0
  828. package/dist/esm/serialization/resources/decisions/client/requests/InputTokensRequest.mjs +8 -0
  829. package/dist/esm/serialization/resources/decisions/client/requests/index.d.mts +1 -0
  830. package/dist/esm/serialization/resources/decisions/client/requests/index.mjs +1 -0
  831. package/dist/esm/serialization/resources/decisions/index.d.mts +1 -0
  832. package/dist/esm/serialization/resources/decisions/index.mjs +1 -0
  833. package/dist/esm/serialization/resources/index.d.mts +2 -0
  834. package/dist/esm/serialization/resources/index.mjs +2 -0
  835. package/dist/esm/serialization/types/Answer.d.mts +23 -0
  836. package/dist/esm/serialization/types/Answer.mjs +17 -0
  837. package/dist/esm/serialization/types/Answers.d.mts +10 -0
  838. package/dist/esm/serialization/types/Answers.mjs +4 -0
  839. package/dist/esm/serialization/types/ChoiceAnswer.d.mts +11 -0
  840. package/dist/esm/serialization/types/ChoiceAnswer.mjs +7 -0
  841. package/dist/esm/serialization/types/ChoiceQuestion.d.mts +11 -0
  842. package/dist/esm/serialization/types/ChoiceQuestion.mjs +7 -0
  843. package/dist/esm/serialization/types/Criterion.d.mts +10 -0
  844. package/dist/esm/serialization/types/Criterion.mjs +6 -0
  845. package/dist/esm/serialization/types/DecisionsRequest.d.mts +11 -0
  846. package/dist/esm/serialization/types/DecisionsRequest.mjs +7 -0
  847. package/dist/esm/serialization/types/DecisionsResponse.d.mts +13 -0
  848. package/dist/esm/serialization/types/DecisionsResponse.mjs +9 -0
  849. package/dist/esm/serialization/types/ErrorCode.d.mts +7 -0
  850. package/dist/esm/serialization/types/ErrorCode.mjs +18 -0
  851. package/dist/esm/serialization/types/ErrorType.d.mts +7 -0
  852. package/dist/esm/serialization/types/ErrorType.mjs +3 -0
  853. package/dist/esm/serialization/types/Error_.d.mts +15 -0
  854. package/dist/esm/serialization/types/Error_.mjs +11 -0
  855. package/dist/esm/serialization/types/GatewayError.d.mts +10 -0
  856. package/dist/esm/serialization/types/GatewayError.mjs +6 -0
  857. package/dist/esm/serialization/types/InputTokensResponse.d.mts +9 -0
  858. package/dist/esm/serialization/types/InputTokensResponse.mjs +5 -0
  859. package/dist/esm/serialization/types/Moment.d.mts +11 -0
  860. package/dist/esm/serialization/types/Moment.mjs +7 -0
  861. package/dist/esm/serialization/types/MomentAnswer.d.mts +10 -0
  862. package/dist/esm/serialization/types/MomentAnswer.mjs +6 -0
  863. package/dist/esm/serialization/types/MomentQuestion.d.mts +9 -0
  864. package/dist/esm/serialization/types/MomentQuestion.mjs +5 -0
  865. package/dist/esm/serialization/types/NoulAnswer.d.mts +9 -0
  866. package/dist/esm/serialization/types/NoulAnswer.mjs +5 -0
  867. package/dist/esm/serialization/types/NoulCriteria.d.mts +10 -0
  868. package/dist/esm/serialization/types/NoulCriteria.mjs +6 -0
  869. package/dist/esm/serialization/types/NoulQuestion.d.mts +11 -0
  870. package/dist/esm/serialization/types/NoulQuestion.mjs +7 -0
  871. package/dist/esm/serialization/types/Question.d.mts +23 -0
  872. package/dist/esm/serialization/types/Question.mjs +17 -0
  873. package/dist/esm/serialization/types/Questions.d.mts +10 -0
  874. package/dist/esm/serialization/types/Questions.mjs +4 -0
  875. package/dist/esm/serialization/types/Received.d.mts +9 -0
  876. package/dist/esm/serialization/types/Received.mjs +5 -0
  877. package/dist/esm/serialization/types/Run.d.mts +18 -0
  878. package/dist/esm/serialization/types/Run.mjs +14 -0
  879. package/dist/esm/serialization/types/RunReceived.d.mts +10 -0
  880. package/dist/esm/serialization/types/RunReceived.mjs +6 -0
  881. package/dist/esm/serialization/types/RunStatus.d.mts +7 -0
  882. package/dist/esm/serialization/types/RunStatus.mjs +3 -0
  883. package/dist/esm/serialization/types/RunSummary.d.mts +16 -0
  884. package/dist/esm/serialization/types/RunSummary.mjs +12 -0
  885. package/dist/esm/serialization/types/RunsPage.d.mts +11 -0
  886. package/dist/esm/serialization/types/RunsPage.mjs +7 -0
  887. package/dist/esm/serialization/types/ScoreAnswer.d.mts +12 -0
  888. package/dist/esm/serialization/types/ScoreAnswer.mjs +8 -0
  889. package/dist/esm/serialization/types/ScoreQuestion.d.mts +10 -0
  890. package/dist/esm/serialization/types/ScoreQuestion.mjs +6 -0
  891. package/dist/esm/serialization/types/index.d.mts +28 -0
  892. package/dist/esm/serialization/types/index.mjs +28 -0
  893. package/dist/esm/version.d.mts +1 -0
  894. package/dist/esm/version.mjs +1 -0
  895. package/package.json +115 -5
  896. package/reference.md +327 -0
@@ -0,0 +1,350 @@
1
+ "use strict";
2
+ // Maintained by hand and listed in .fernignore, so SDK regeneration leaves it in place.
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
13
+ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
14
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
15
+ var g = generator.apply(thisArg, _arguments || []), i, q = [];
16
+ return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
17
+ function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
18
+ function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
19
+ function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
20
+ function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
21
+ function fulfill(value) { resume("next", value); }
22
+ function reject(value) { resume("throw", value); }
23
+ function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.iterAudioChunks = iterAudioChunks;
27
+ exports.prepareChunks = prepareChunks;
28
+ const checks_js_1 = require("./checks.js");
29
+ const downmix_js_1 = require("./downmix.js");
30
+ const errors_js_1 = require("./errors.js");
31
+ const files_js_1 = require("./files.js");
32
+ const integers_js_1 = require("./integers.js");
33
+ const mp3_js_1 = require("./mp3.js");
34
+ const wav_js_1 = require("./wav.js");
35
+ // The Decisions API accepts audio up to 5 minutes long.
36
+ const MAX_CHUNK_MS = 300000;
37
+ // The API accepts a request body of up to this many bytes, its JSON part and multipart headers included.
38
+ const MAX_REQUEST_BYTES = 25000000;
39
+ // The rest is left for the JSON part and multipart headers, so a chunk this size is accepted with any
40
+ // common request.
41
+ const MAX_CHUNK_BYTES = 24000000;
42
+ const SPLITS = ["even", "fixed"];
43
+ /**
44
+ * Splits a recording, or part of one, into chunks short enough for the Decisions API.
45
+ *
46
+ * `maxChunkMs` is the longest a chunk can be, and `split` decides how the recording is divided:
47
+ *
48
+ * 1. "even", the default, cuts the fewest chunks that fit, of equal length, so that the last chunk
49
+ * is not a short remainder: 10 minutes and 1 second at a `maxChunkMs` of 300000 is cut into 3
50
+ * chunks of about 200 seconds.
51
+ * 2. "fixed" makes every chunk `maxChunkMs` long except the last, which holds what remains: the
52
+ * same recording is cut into 2 chunks of 5 minutes and 1 of 1 second. The last chunk is billed
53
+ * for its context and questions like any other, however short it is. Use it when chunks must be
54
+ * the same length across recordings.
55
+ *
56
+ * No chunk is empty. Cuts fall where the format allows, as described below, so `startMs` and
57
+ * `endMs` on each chunk give where it actually starts and ends.
58
+ *
59
+ * The model hears audio at 16 kHz in one channel: the API resamples and mixes down every file
60
+ * before the model hears it. A WAV file is mixed down the same way before it is cut, by default, so
61
+ * that the chunks are smaller to upload while the model hears the same audio. `downmixStrategy`
62
+ * describes how. MP3 files are cut as they are, because they are already compressed.
63
+ *
64
+ * The whole recording is read into memory, mixed down and checked before the first chunk is
65
+ * produced, so that a file that cannot be split is rejected before any chunk is. The options are
66
+ * checked by this call, and the file when iteration starts, so errors about the file are thrown by
67
+ * the first `next()`. The mixdown runs on the calling thread, taking several seconds for an hour of
68
+ * audio above 16 kHz, and pauses regularly to let other work run. Each chunk's `data` is a copy, made
69
+ * as the chunk is produced, so keeping every chunk holds the recording in memory twice.
70
+ *
71
+ * Apart from the WAV mixdown `downmixStrategy` asks for, the audio is copied as it is, never decoded
72
+ * or re-encoded, so cuts fall where the format allows:
73
+ *
74
+ * 1. A WAV file is cut between samples, after the mixdown. With "fixed", a cut can fall up to one
75
+ * sample before `startMs` plus a whole multiple of `maxChunkMs`, so the cuts stay on that grid.
76
+ * Each chunk is a new WAV file in the sample format of the mixed-down audio, holding only its
77
+ * audio; other chunks in the file, such as metadata, are left out.
78
+ * 2. An MP3 file is cut between frames, which last 24 to 72 ms depending on the sample rate, so
79
+ * chunks can differ in length by a frame, and a "fixed" chunk can be up to one frame shorter
80
+ * than `maxChunkMs`. `startMs` and `endMs` move to the nearest frame boundary. A frame can store
81
+ * part of its audio data in the frames before it, and its sound continues from the frame before,
82
+ * so each chunk also starts with the frames its first new frame needs to decode exactly. That is
83
+ * usually a few frames, and up to about 2 seconds at the lowest bitrates. Those frames count
84
+ * toward `maxChunkMs` and repeat the end of the previous chunk, or start before `startMs`. Each
85
+ * chunk holds only the recording's frames; tags, and the header frame that states the whole
86
+ * file's length, are left out. When that header frame has a LAME tag, as files from LAME and
87
+ * ffmpeg do, it states the silence the encoder added at each end, which players skip. Times are
88
+ * then measured from where a player starts the whole file, so the first chunk starts before 0,
89
+ * by about 25 ms for a typical 44.1 kHz file, and the last ends where the player stops.
90
+ *
91
+ * @param file The recording, an MP3 or WAV file, in any form `create` accepts. MP3 files of MPEG-1,
92
+ * 2 and 2.5 layer III are supported, except free format. WAV files of integer PCM (8, 16, 24 or
93
+ * 32-bit) and floating point (32 or 64-bit) are supported, with either the basic or the extensible
94
+ * WAV header. A stream is read from where it is to its end. `{ path }` needs file system access,
95
+ * which browsers do not have.
96
+ * @param options How to cut the recording.
97
+ * @returns The chunks in order. Their times are measured from the start of the recording, not from
98
+ * `startMs`.
99
+ *
100
+ * @throws {TypeError} From this call, if `maxChunkMs`, `startMs` or `endMs` is not a safe integer, or
101
+ * `file` is a string, which is not read as a path.
102
+ * @throws {RangeError} From this call, if `split` is not "even" or "fixed", `downmixStrategy` is not
103
+ * "mix", "first_channel" or "none", `maxChunkMs` is out of range, or `startMs` and `endMs` do not
104
+ * select a range. From iteration, if `startMs` and `endMs` do
105
+ * not select audio within the recording, `maxChunkMs` is too long with "fixed" for a WAV chunk to
106
+ * fit the API's size limit, or too short for an MP3 chunk to hold a new frame and the frames it
107
+ * needs.
108
+ * @throws {UnsupportedAudioError} From iteration, if the recording is empty or not a file this helper supports, such
109
+ * as a compressed WAV or RF64 file. Any damage to an MP3 file is found before the first chunk, so no
110
+ * chunk is produced from a file that cannot be read to the end.
111
+ *
112
+ * @example
113
+ * import { iterAudioChunks } from "@humeai/audio-decisions/audio-helpers";
114
+ *
115
+ * for await (const chunk of iterAudioChunks({ path: "call.wav" }, { maxChunkMs: 60_000 })) {
116
+ * console.log(chunk.index, chunk.startMs, chunk.endMs, chunk.data.length);
117
+ * }
118
+ */
119
+ function iterAudioChunks(file, options) {
120
+ return produceChunks(prepareChunks(file, options));
121
+ }
122
+ function produceChunks(planRecording) {
123
+ return __asyncGenerator(this, arguments, function* produceChunks_1() {
124
+ for (const chunk of (yield __await(planRecording())).chunks) {
125
+ yield yield __await({ index: chunk.index, startMs: chunk.startMs, endMs: chunk.endMs, data: chunk.build() });
126
+ }
127
+ });
128
+ }
129
+ /**
130
+ * Checks `options` and `file`, and returns a function that reads the file, mixes it down and plans
131
+ * the chunks `iterAudioChunks` gives, without copying any chunk's data. The function rejects with a
132
+ * DecisionsError if `signal` aborts during the mixdown.
133
+ */
134
+ function prepareChunks(file, options) {
135
+ const checked = checkChunkOptions(options);
136
+ (0, files_js_1.checkFile)(file);
137
+ // A generator that read the file itself would keep the recording in memory for the whole job, even
138
+ // after a WAV file is mixed down into a smaller copy.
139
+ return (signal) => __awaiter(this, void 0, void 0, function* () {
140
+ const { data, filename, contentType } = yield (0, files_js_1.readFile)(file);
141
+ return { filename, contentType, chunks: yield planAudioChunks(data, checked, signal) };
142
+ });
143
+ }
144
+ function checkChunkOptions(options) {
145
+ const split = (0, checks_js_1.checkChoice)("split", options.split === undefined ? "even" : options.split, SPLITS);
146
+ const downmixStrategy = (0, downmix_js_1.checkDownmixStrategy)(options.downmixStrategy);
147
+ const maxChunkMs = (0, checks_js_1.checkInteger)("maxChunkMs", options.maxChunkMs);
148
+ if (maxChunkMs < 1 || maxChunkMs > MAX_CHUNK_MS) {
149
+ throw new RangeError(`maxChunkMs must be between 1 and ${MAX_CHUNK_MS}, got ${maxChunkMs}.`);
150
+ }
151
+ const startMs = options.startMs === undefined ? 0 : (0, checks_js_1.checkInteger)("startMs", options.startMs);
152
+ if (startMs < 0) {
153
+ throw new RangeError(`startMs must not be negative, got ${startMs}.`);
154
+ }
155
+ const endMs = options.endMs === undefined ? undefined : (0, checks_js_1.checkInteger)("endMs", options.endMs);
156
+ if (endMs !== undefined && endMs <= startMs) {
157
+ throw new RangeError(`endMs must be greater than startMs, got ${endMs}.`);
158
+ }
159
+ return { maxChunkMs, startMs, endMs, split, downmixStrategy };
160
+ }
161
+ function planAudioChunks(data, options, signal) {
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ var _a;
164
+ if ((0, wav_js_1.isWav)(data)) {
165
+ const wav = (0, wav_js_1.parseWav)(data);
166
+ const mixed = (_a = (yield (0, downmix_js_1.downmixWav)(data, wav, options.downmixStrategy, signal))) !== null && _a !== void 0 ? _a : { data, wav };
167
+ return wavChunks(mixed.data, mixed.wav, options);
168
+ }
169
+ if ((0, mp3_js_1.isMp3)(data)) {
170
+ return mp3Chunks(data, (0, mp3_js_1.parseMp3)(data), options);
171
+ }
172
+ throw new errors_js_1.UnsupportedAudioError("Unsupported audio format. Only MP3 and WAV files can be split into chunks.");
173
+ });
174
+ }
175
+ /** The first and last positions of the range `startMs` and `endMs` select from `length` positions. */
176
+ function selectRange(length, msAt, positionAt, startMs, endMs) {
177
+ if (length === 0) {
178
+ throw new errors_js_1.UnsupportedAudioError("The audio is empty.");
179
+ }
180
+ // The longest range allowed ends at the duration that the final chunk reports.
181
+ // A recording shorter than half a millisecond has a duration of 0 ms but still starts at 0.
182
+ const durationMs = msAt(length);
183
+ if (startMs > 0 && startMs >= durationMs) {
184
+ throw new RangeError(`startMs must be less than the recording's duration of ${durationMs} ms, got ${startMs}.`);
185
+ }
186
+ if (endMs !== undefined && endMs > durationMs) {
187
+ throw new RangeError(`endMs must not exceed the recording's duration of ${durationMs} ms, got ${endMs}.`);
188
+ }
189
+ // The duration is rounded to the millisecond, so it can fall short of the final position. An MP3
190
+ // recording can start and end partway through a frame, so its first and last frames are kept whole.
191
+ const first = startMs === 0 ? 0 : positionAt(startMs);
192
+ const last = endMs === undefined || endMs >= durationMs ? length : Math.min(positionAt(endMs), length);
193
+ return [first, last];
194
+ }
195
+ function wavChunks(data, wav, { maxChunkMs, startMs, endMs, split }) {
196
+ const msAt = (sample) => toMs(sample, wav.sampleRate);
197
+ const [first, last] = selectRange(wav.sampleCount, msAt, (ms) => toSample(ms, wav.sampleRate), startMs, endMs);
198
+ // When maxChunkMs is not a whole number of samples, a chunk can be up to one sample longer.
199
+ const longest = (0, integers_js_1.ceilDiv)(maxChunkMs * wav.sampleRate, 1000);
200
+ const fitting = wavSamplesThatFit(wav);
201
+ let cuts;
202
+ if (split === "even") {
203
+ cuts = evenWavCuts(first, last, Math.min(longest, fitting));
204
+ }
205
+ else {
206
+ checkWavSize(wav, Math.min(longest, last - first), fitting);
207
+ cuts = fixedWavCuts(wav, maxChunkMs, startMs, first, last);
208
+ }
209
+ return plan(cuts, msAt, (start, end) => (0, wav_js_1.wavChunk)(data, wav, start, end));
210
+ }
211
+ function wavSamplesThatFit(wav) {
212
+ // An MP3 chunk needs no such limit: at the highest bitrate, 5 minutes of MP3 is about 12 MB.
213
+ // The header holds the RIFF, fmt and data chunk headers, and the data can need a padding byte.
214
+ const headerBytes = 28 + wav.fmt.length + 1;
215
+ return (0, integers_js_1.floorDiv)(MAX_CHUNK_BYTES - headerBytes, wav.frameBytes);
216
+ }
217
+ function checkWavSize(wav, longest, fitting) {
218
+ if (longest <= fitting) {
219
+ return;
220
+ }
221
+ const fittingMs = (0, integers_js_1.floorDiv)(fitting * 1000, wav.sampleRate);
222
+ throw new RangeError(`maxChunkMs must be at most ${fittingMs} for this WAV file with split="fixed", so that the request for` +
223
+ ` each chunk fits within the API limit of ${MAX_REQUEST_BYTES.toLocaleString("en-US")} bytes.` +
224
+ ` split="even" cuts shorter chunks that fit instead, and mono or stereo audio mixed down with` +
225
+ ` downmixStrategy="mix" fits 5-minute chunks.`);
226
+ }
227
+ function mp3Chunks(data, mp3, { maxChunkMs, startMs, endMs, split }) {
228
+ const msAt = (frame) => mp3TimeMs(mp3, frame);
229
+ const [first, last] = selectRange(mp3.frameCount, msAt, (ms) => frameAt(mp3, ms), startMs, endMs);
230
+ // Rounding down keeps every chunk within maxChunkMs, so a maxChunkMs of 300000 stays within the
231
+ // API's limit.
232
+ const framesPerChunk = (0, integers_js_1.floorDiv)(maxChunkMs * mp3.sampleRate, 1000 * mp3.samplesPerFrame);
233
+ const frameMs = framesMs(mp3, 1);
234
+ if (framesPerChunk === 0) {
235
+ throw new RangeError(`maxChunkMs must be at least ${frameMs} ms, the length of one frame of this MP3 file.`);
236
+ }
237
+ if (last <= first) {
238
+ throw new RangeError(`startMs and endMs must be at least ${frameMs} ms apart, the length of one frame of this MP3 file.`);
239
+ }
240
+ // A chunk that could hold only the frames needed before its first new frame would never advance.
241
+ // Filling fails only when this check does, which also rejects a maxChunkMs that happens to work
242
+ // for this range's cuts but not for every frame in it.
243
+ let neededBefore = 0;
244
+ for (let frame = first; frame < last; frame++) {
245
+ neededBefore = Math.max(neededBefore, (0, mp3_js_1.framesNeededBefore)(mp3, frame));
246
+ }
247
+ const filled = fillMp3Chunks(mp3, framesPerChunk, first, last);
248
+ if (filled === undefined || framesPerChunk <= neededBefore) {
249
+ throw new RangeError(`maxChunkMs must be at least ${framesMs(mp3, neededBefore + 1)} ms for this MP3 file. Its frames` +
250
+ ` need up to ${neededBefore} frames before them to decode, and a chunk must hold those along with` +
251
+ " at least one new frame.");
252
+ }
253
+ const cuts = split === "even" ? evenMp3Cuts(mp3, filled, framesPerChunk, first, last) : filled;
254
+ return plan(cuts, msAt, (start, end) => (0, mp3_js_1.mp3Chunk)(data, mp3, start, end));
255
+ }
256
+ function frameAt(mp3, ms) {
257
+ // Times given by the caller are often ones a chunk reported, which are rounded to the
258
+ // millisecond, so they move to the nearest frame boundary rather than the one before.
259
+ return (0, integers_js_1.roundDiv)(ms * mp3.sampleRate + 1000 * mp3.leadingSamples, 1000 * mp3.samplesPerFrame);
260
+ }
261
+ function framesMs(mp3, frames) {
262
+ return (0, integers_js_1.ceilDiv)(frames * mp3.samplesPerFrame * 1000, mp3.sampleRate);
263
+ }
264
+ function mp3TimeMs(mp3, frame) {
265
+ // Times are measured from where a player starts the recording, after the samples the encoder and
266
+ // decoder add, so the first chunk can start before 0 ms. The player also stops before the
267
+ // samples added at the end.
268
+ return toMs(Math.min(frame * mp3.samplesPerFrame, mp3.endSample) - mp3.leadingSamples, mp3.sampleRate);
269
+ }
270
+ function evenMp3Cuts(mp3, filled, framesPerChunk, first, last) {
271
+ // Filling every chunk gives the fewest chunks but can leave a short last chunk. The shortest
272
+ // chunk length that needs no more chunks than that shares the frames out evenly instead.
273
+ let cuts = filled;
274
+ let low = 1;
275
+ let high = framesPerChunk;
276
+ while (low < high) {
277
+ const middle = Math.floor((low + high) / 2);
278
+ const shorter = fillMp3Chunks(mp3, middle, first, last);
279
+ if (shorter !== undefined && shorter.length <= cuts.length) {
280
+ cuts = shorter;
281
+ high = middle;
282
+ }
283
+ else {
284
+ low = middle + 1;
285
+ }
286
+ }
287
+ return cuts;
288
+ }
289
+ /** Cuts chunks of `framesPerChunk` frames, or undefined when a chunk cannot hold a new frame. */
290
+ function fillMp3Chunks(mp3, framesPerChunk, first, last) {
291
+ const cuts = [];
292
+ let next = first;
293
+ while (next < last) {
294
+ // Without the frames before it, the first new frame decodes wrongly. They repeat the end of
295
+ // the previous chunk.
296
+ const start = next - (0, mp3_js_1.framesNeededBefore)(mp3, next);
297
+ if (start + framesPerChunk <= next) {
298
+ return undefined;
299
+ }
300
+ const end = Math.min(start + framesPerChunk, last);
301
+ cuts.push([start, end]);
302
+ next = end;
303
+ }
304
+ return cuts;
305
+ }
306
+ function* evenWavCuts(first, last, longest) {
307
+ const length = last - first;
308
+ const count = (0, integers_js_1.ceilDiv)(length, longest);
309
+ // Chunk i starts at first + floor(length * i / count). That product can pass
310
+ // Number.MAX_SAFE_INTEGER, so the cuts are stepped by the quotient and carry the remainder.
311
+ const step = (0, integers_js_1.floorDiv)(length, count);
312
+ const extra = length - step * count;
313
+ let start = first;
314
+ let remainder = 0;
315
+ for (let index = 0; index < count; index++) {
316
+ let end = start + step;
317
+ remainder += extra;
318
+ if (remainder >= count) {
319
+ remainder -= count;
320
+ end += 1;
321
+ }
322
+ yield [start, end];
323
+ start = end;
324
+ }
325
+ }
326
+ function* fixedWavCuts(wav, maxChunkMs, startMs, first, last) {
327
+ let start = first;
328
+ let index = 0;
329
+ while (start < last) {
330
+ // Each cut is computed from startMs rather than from the previous cut, so rounding does not
331
+ // accumulate.
332
+ const end = Math.min(toSample(startMs + (index + 1) * maxChunkMs, wav.sampleRate), last);
333
+ yield [start, end];
334
+ index += 1;
335
+ start = end;
336
+ }
337
+ }
338
+ function* plan(cuts, msAt, build) {
339
+ let index = 0;
340
+ for (const [start, end] of cuts) {
341
+ yield { index, startMs: msAt(start), endMs: msAt(end), build: () => build(start, end) };
342
+ index += 1;
343
+ }
344
+ }
345
+ function toSample(ms, sampleRate) {
346
+ return (0, integers_js_1.floorDiv)(ms * sampleRate, 1000);
347
+ }
348
+ function toMs(sample, sampleRate) {
349
+ return (0, integers_js_1.roundDiv)(sample * 1000, sampleRate);
350
+ }
@@ -0,0 +1,17 @@
1
+ import { type WavAudio } from "./wav.js";
2
+ declare const STRATEGIES: readonly ["mix", "first_channel", "none"];
3
+ /** How a WAV file is mixed down before it is sent: "mix", "first_channel", or "none" to send it as it is. */
4
+ export type DownmixStrategy = (typeof STRATEGIES)[number];
5
+ interface Downmixed {
6
+ readonly data: Uint8Array;
7
+ readonly wav: WavAudio;
8
+ }
9
+ export declare function checkDownmixStrategy(strategy?: unknown): DownmixStrategy;
10
+ /**
11
+ * The samples of `wav` mixed down by `strategy` into one channel, with a description of them, or
12
+ * undefined when the file is best sent as it is: the API would mix it the same way and converting it
13
+ * would not make it smaller. Resampled audio is at most MODEL_SAMPLE_RATE, in 32-bit floating point.
14
+ * Rejects with a DecisionsError once `signal` aborts.
15
+ */
16
+ export declare function downmixWav(data: Uint8Array, wav: WavAudio, strategy: DownmixStrategy, signal?: AbortSignal): Promise<Downmixed | undefined>;
17
+ export {};
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ // Maintained by hand and listed in .fernignore, so SDK regeneration leaves it in place.
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.checkDownmixStrategy = checkDownmixStrategy;
14
+ exports.downmixWav = downmixWav;
15
+ const RawResponse_js_1 = require("../core/fetcher/RawResponse.js");
16
+ const DecisionsError_js_1 = require("../errors/DecisionsError.js");
17
+ const bytes_js_1 = require("./bytes.js");
18
+ const checks_js_1 = require("./checks.js");
19
+ const integers_js_1 = require("./integers.js");
20
+ const wav_js_1 = require("./wav.js");
21
+ const STRATEGIES = ["mix", "first_channel", "none"];
22
+ // The model hears audio at this rate, in one channel.
23
+ const MODEL_SAMPLE_RATE = 16000;
24
+ // Front left and front right.
25
+ const STEREO_MASK = 0x3;
26
+ // The settings of ffmpeg's default resampler, which the API uses before the model hears the audio, so
27
+ // audio resampled here reaches the model as it would have without this step.
28
+ const FILTER_SIZE = 32;
29
+ const CUTOFF = 0.97;
30
+ const KAISER_BETA = 9;
31
+ // A ratio of rates that would need more phases than this gets this many instead, and an output
32
+ // between two phases is interpolated linearly between them.
33
+ const MAX_PHASES = 1024;
34
+ // Outputs computed together. Each needs a filter's length of input, so this bounds the memory used.
35
+ const BLOCK = 8192;
36
+ // The mixdown runs on the calling thread, so it lets other work run after about this long.
37
+ const YIELD_MS = 50;
38
+ function checkDownmixStrategy(strategy = "mix") {
39
+ return (0, checks_js_1.checkChoice)("downmixStrategy", strategy, STRATEGIES);
40
+ }
41
+ /**
42
+ * The samples of `wav` mixed down by `strategy` into one channel, with a description of them, or
43
+ * undefined when the file is best sent as it is: the API would mix it the same way and converting it
44
+ * would not make it smaller. Resampled audio is at most MODEL_SAMPLE_RATE, in 32-bit floating point.
45
+ * Rejects with a DecisionsError once `signal` aborts.
46
+ */
47
+ function downmixWav(data, wav, strategy, signal) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ // ffmpeg weighs channels by the speakers in the header's channel mask and leaves out the LFE
50
+ // channel, and it refuses some two-channel masks, so only audio it mixes by adding the channels at
51
+ // equal weight is mixed here. Anything else is sent as it is for the API to mix.
52
+ if (strategy === "none" || (strategy === "mix" && !mixesEvenly(wav))) {
53
+ return undefined;
54
+ }
55
+ const sampleRate = Math.min(wav.sampleRate, MODEL_SAMPLE_RATE);
56
+ const count = (0, integers_js_1.ceilDiv)(wav.sampleCount * sampleRate, wav.sampleRate);
57
+ // The API converts every sample to 32-bit floating point, so writing that loses nothing and cannot
58
+ // clip, but it is larger than some recordings that the API would convert just the same.
59
+ const converted = (0, wav_js_1.samplesWav)({ channels: 1, sampleRate, sampleWidth: 4, isFloat: true, sampleCount: count });
60
+ const unchangedBytes = wav.sampleCount * wav.frameBytes;
61
+ const copyBytes = wav.sampleCount * wav.sampleWidth;
62
+ const convertedBytes = count * converted.frameBytes;
63
+ // The API would mix every channel, so the first is taken out even when that is not smaller.
64
+ const picksChannel = strategy === "first_channel" && wav.channels > 1;
65
+ if (!picksChannel && convertedBytes >= unchangedBytes) {
66
+ return undefined;
67
+ }
68
+ // A copy of the channel's samples is exact, so it is preferred whenever it is no larger.
69
+ if (picksChannel && copyBytes <= convertedBytes) {
70
+ const picked = new Uint8Array(copyBytes);
71
+ yield paced(copyFirstChannel(data, wav, picked), signal);
72
+ const { sampleWidth, isFloat, sampleCount } = wav;
73
+ return {
74
+ data: picked,
75
+ wav: (0, wav_js_1.samplesWav)({ channels: 1, sampleRate: wav.sampleRate, sampleWidth, isFloat, sampleCount }),
76
+ };
77
+ }
78
+ const read = monoReader(data, wav, strategy === "mix" && wav.channels === 2);
79
+ const out = new Uint8Array(convertedBytes);
80
+ const view = (0, bytes_js_1.dataView)(out);
81
+ // Integer samples are scaled to the range -1 to 1, as ffmpeg does.
82
+ const fullScale = wav.isFloat ? 1 : Math.pow(2, (wav.sampleWidth * 8 - 1));
83
+ const write = (output, value) => view.setFloat32(output * 4, value / fullScale, true);
84
+ yield paced(sampleRate === wav.sampleRate
85
+ ? copySamples(read, write, count)
86
+ : resample(read, write, wav.sampleCount, wav.sampleRate, sampleRate, count), signal);
87
+ return { data: out, wav: converted };
88
+ });
89
+ }
90
+ function mixesEvenly({ channels, channelMask }) {
91
+ return channels === 1 || (channels === 2 && (channelMask === 0 || channelMask === STEREO_MASK));
92
+ }
93
+ function* copyFirstChannel(data, wav, picked) {
94
+ const { dataStart, frameBytes, sampleWidth, sampleCount } = wav;
95
+ for (let start = 0; start < sampleCount; start += BLOCK) {
96
+ const end = Math.min(start + BLOCK, sampleCount);
97
+ for (let sample = start; sample < end; sample++) {
98
+ const from = dataStart + sample * frameBytes;
99
+ const to = sample * sampleWidth;
100
+ for (let byte = 0; byte < sampleWidth; byte++) {
101
+ picked[to + byte] = data[from + byte];
102
+ }
103
+ }
104
+ yield;
105
+ }
106
+ }
107
+ function* copySamples(read, write, count) {
108
+ for (let start = 0; start < count; start += BLOCK) {
109
+ const end = Math.min(start + BLOCK, count);
110
+ for (let output = start; output < end; output++) {
111
+ write(output, read(output));
112
+ }
113
+ yield;
114
+ }
115
+ }
116
+ function* resample(read, write, length, fromRate, toRate, count) {
117
+ const phases = Math.min(toRate / gcd(fromRate, toRate), MAX_PHASES);
118
+ const interpolates = (phases * fromRate) % toRate !== 0;
119
+ const factor = (toRate * CUTOFF) / fromRate;
120
+ // ffmpeg rounds the filter length up to an even number.
121
+ let taps = Math.ceil(FILTER_SIZE / factor);
122
+ taps += taps % 2;
123
+ const center = (taps - 1) >> 1;
124
+ const bank = filterBank(phases, factor, taps, interpolates);
125
+ // Output k lies k * fromRate / toRate inputs in, which is `steps(k)` phases. With the ratio's exact
126
+ // phases, every output falls on a phase, and otherwise the remainder places it between two. k is
127
+ // split at toRate so that no product passes Number.MAX_SAFE_INTEGER.
128
+ const phaseStep = fromRate * phases;
129
+ const steps = (output) => (0, integers_js_1.floorDiv)(output, toRate) * phaseStep + (0, integers_js_1.floorDiv)((output % toRate) * phaseStep, toRate);
130
+ let segment = new Float64Array(0);
131
+ for (let start = 0; start < count; start += BLOCK) {
132
+ const end = Math.min(start + BLOCK, count);
133
+ const low = (0, integers_js_1.floorDiv)(steps(start), phases) - center;
134
+ const inputs = (0, integers_js_1.floorDiv)(steps(end - 1), phases) - center + taps - low;
135
+ if (segment.length < inputs) {
136
+ segment = new Float64Array(inputs);
137
+ }
138
+ for (let index = 0; index < inputs; index++) {
139
+ segment[index] = read(reflect(low + index, length));
140
+ }
141
+ for (let output = start; output < end; output++) {
142
+ const position = steps(output);
143
+ const first = (0, integers_js_1.floorDiv)(position, phases);
144
+ const offset = first - center - low;
145
+ const row = (position - first * phases) * taps;
146
+ let sample = 0;
147
+ for (let tap = 0; tap < taps; tap++) {
148
+ sample += segment[offset + tap] * bank[row + tap];
149
+ }
150
+ if (interpolates) {
151
+ let following = 0;
152
+ for (let tap = 0; tap < taps; tap++) {
153
+ following += segment[offset + tap] * bank[row + taps + tap];
154
+ }
155
+ const remainder = ((output % toRate) * phaseStep) % toRate;
156
+ sample += (following - sample) * (remainder / toRate);
157
+ }
158
+ write(output, sample);
159
+ }
160
+ yield;
161
+ }
162
+ }
163
+ function reflect(position, length) {
164
+ // ffmpeg reflects the audio at both ends, so the first and last outputs match its own.
165
+ let reflected = Math.abs(position);
166
+ if (reflected >= length) {
167
+ reflected = 2 * length - 1 - reflected;
168
+ }
169
+ return Math.min(Math.max(reflected, 0), length - 1);
170
+ }
171
+ /**
172
+ * A Kaiser-windowed sinc low-pass filter for each phase, built the way swresample builds its own, one
173
+ * row of `taps` after another, followed by the phase that ends an interpolation when `interpolates`.
174
+ */
175
+ function filterBank(phases, factor, taps, interpolates) {
176
+ const center = (taps - 1) >> 1;
177
+ const bank = new Float64Array((phases + (interpolates ? 1 : 0)) * taps);
178
+ for (let phase = 0; phase < phases; phase++) {
179
+ for (let tap = 0; tap < taps; tap++) {
180
+ const x = Math.PI * (tap - center - phase / phases) * factor;
181
+ const sinc = x === 0 ? 1 : Math.sin(x) / x;
182
+ const ratio = (2 * x) / (factor * taps * Math.PI);
183
+ bank[phase * taps + tap] = sinc * besselI0(KAISER_BETA * Math.sqrt(Math.max(1 - ratio * ratio, 0)));
184
+ }
185
+ }
186
+ // Every phase is scaled by the first phase's sum, as swresample does, so a constant level is kept.
187
+ let sum = 0;
188
+ for (let tap = 0; tap < taps; tap++) {
189
+ sum += bank[tap];
190
+ }
191
+ for (let index = 0; index < phases * taps; index++) {
192
+ bank[index] /= sum;
193
+ }
194
+ if (interpolates) {
195
+ // swresample builds the phase that ends an interpolation by moving the first phase one tap later
196
+ // in its buffer, whose length is padded to a multiple of 8. The tap that falls off the end, zero
197
+ // unless the filter needs no padding, wraps around to the start.
198
+ const last = phases * taps;
199
+ bank[last] = taps % 8 === 0 ? bank[taps - 1] : 0;
200
+ bank.set(bank.subarray(0, taps - 1), last + 1);
201
+ }
202
+ return bank;
203
+ }
204
+ function besselI0(x) {
205
+ // The power series converges within a few dozen terms for the window's arguments, which are at
206
+ // most KAISER_BETA.
207
+ const quarterSquare = (x * x) / 4;
208
+ let sum = 1;
209
+ let term = 1;
210
+ for (let k = 1; term > sum * Number.EPSILON; k++) {
211
+ term *= quarterSquare / (k * k);
212
+ sum += term;
213
+ }
214
+ return sum;
215
+ }
216
+ function monoReader(data, wav, mixes) {
217
+ const read = sampleReader(data, wav);
218
+ const { dataStart, frameBytes, sampleWidth } = wav;
219
+ if (mixes) {
220
+ // ffmpeg adds the two channels at -3 dB each when it writes floating point, as the API does.
221
+ return (sample) => {
222
+ const offset = dataStart + sample * frameBytes;
223
+ return (read(offset) + read(offset + sampleWidth)) * Math.SQRT1_2;
224
+ };
225
+ }
226
+ return (sample) => read(dataStart + sample * frameBytes);
227
+ }
228
+ function sampleReader(data, wav) {
229
+ const view = (0, bytes_js_1.dataView)(data);
230
+ if (wav.isFloat) {
231
+ return wav.sampleWidth === 4
232
+ ? (offset) => view.getFloat32(offset, true)
233
+ : (offset) => view.getFloat64(offset, true);
234
+ }
235
+ switch (wav.sampleWidth) {
236
+ case 1:
237
+ // 8-bit WAV samples are unsigned, centered on 128.
238
+ return (offset) => data[offset] - 128;
239
+ case 2:
240
+ return (offset) => view.getInt16(offset, true);
241
+ case 3:
242
+ // Shifting the top byte into the sign bit and back sign-extends the sample.
243
+ return (offset) => ((data[offset] | (data[offset + 1] << 8) | (data[offset + 2] << 16)) << 8) >> 8;
244
+ default:
245
+ return (offset) => view.getInt32(offset, true);
246
+ }
247
+ }
248
+ /** Runs `work` a block at a time, letting other work run about every YIELD_MS. */
249
+ function paced(work, signal) {
250
+ return __awaiter(this, void 0, void 0, function* () {
251
+ throwIfAborted(signal);
252
+ let resumed = Date.now();
253
+ while (!work.next().done) {
254
+ if (Date.now() - resumed >= YIELD_MS) {
255
+ yield nextTask();
256
+ throwIfAborted(signal);
257
+ resumed = Date.now();
258
+ }
259
+ }
260
+ });
261
+ }
262
+ function throwIfAborted(signal) {
263
+ if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
264
+ // The error the client throws when it aborts a request, so that an abort is caught the same
265
+ // way wherever it lands.
266
+ throw new DecisionsError_js_1.DecisionsError({
267
+ message: "The user aborted a request",
268
+ rawResponse: RawResponse_js_1.abortRawResponse,
269
+ cause: signal.reason,
270
+ });
271
+ }
272
+ }
273
+ function nextTask() {
274
+ // A promise alone would not let timers or I/O run, and browsers delay a nested setTimeout by at
275
+ // least 4 ms, which adds up over a long mixdown.
276
+ if (typeof setImmediate === "function") {
277
+ return new Promise((resolve) => setImmediate(() => resolve()));
278
+ }
279
+ return new Promise((resolve) => {
280
+ const channel = new MessageChannel();
281
+ channel.port1.onmessage = () => {
282
+ // A port with a message handler keeps Node's event loop alive until it is closed.
283
+ channel.port1.close();
284
+ resolve();
285
+ };
286
+ channel.port2.postMessage(undefined);
287
+ });
288
+ }
289
+ function gcd(a, b) {
290
+ return b === 0 ? a : gcd(b, a % b);
291
+ }
@@ -0,0 +1,4 @@
1
+ /** The recording cannot be split into chunks, because it is empty or not a file the helpers support. */
2
+ export declare class UnsupportedAudioError extends Error {
3
+ constructor(message: string);
4
+ }