hume 0.11.1 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.mock/definition/empathic-voice/__package__.yml +24 -0
  2. package/.mock/definition/empathic-voice/configs.yml +2 -0
  3. package/.mock/definition/tts/__package__.yml +28 -0
  4. package/.mock/fern.config.json +1 -1
  5. package/Client.d.ts +11 -7
  6. package/Client.js +54 -6
  7. package/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
  8. package/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
  9. package/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +4 -2
  10. package/api/resources/empathicVoice/resources/chatGroups/client/Client.js +74 -40
  11. package/api/resources/empathicVoice/resources/chats/client/Client.d.ts +2 -1
  12. package/api/resources/empathicVoice/resources/chats/client/Client.js +55 -30
  13. package/api/resources/empathicVoice/resources/configs/client/Client.d.ts +14 -7
  14. package/api/resources/empathicVoice/resources/configs/client/Client.js +134 -64
  15. package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
  16. package/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
  17. package/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +10 -5
  18. package/api/resources/empathicVoice/resources/customVoices/client/Client.js +88 -41
  19. package/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +16 -8
  20. package/api/resources/empathicVoice/resources/prompts/client/Client.js +133 -62
  21. package/api/resources/empathicVoice/resources/tools/client/Client.d.ts +14 -7
  22. package/api/resources/empathicVoice/resources/tools/client/Client.js +134 -64
  23. package/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
  24. package/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
  25. package/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
  26. package/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
  27. package/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
  28. package/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
  29. package/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  30. package/api/resources/empathicVoice/types/index.d.ts +2 -0
  31. package/api/resources/empathicVoice/types/index.js +2 -0
  32. package/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +12 -6
  33. package/api/resources/expressionMeasurement/resources/batch/client/Client.js +89 -38
  34. package/api/resources/tts/client/Client.d.ts +24 -18
  35. package/api/resources/tts/client/Client.js +84 -46
  36. package/api/resources/tts/client/index.d.ts +1 -1
  37. package/api/resources/tts/client/index.js +15 -0
  38. package/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  39. package/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  40. package/api/resources/tts/client/requests/index.d.ts +1 -0
  41. package/api/resources/tts/client/requests/index.js +2 -0
  42. package/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  43. package/api/resources/tts/errors/BadRequestError.js +2 -1
  44. package/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  45. package/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  46. package/api/resources/tts/resources/voices/client/Client.d.ts +4 -2
  47. package/api/resources/tts/resources/voices/client/Client.js +45 -22
  48. package/api/resources/tts/types/Snippet.d.ts +2 -0
  49. package/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  50. package/core/fetcher/APIResponse.d.ts +10 -0
  51. package/core/fetcher/Fetcher.js +7 -0
  52. package/core/fetcher/Headers.d.ts +2 -0
  53. package/core/fetcher/Headers.js +84 -0
  54. package/core/fetcher/HttpResponsePromise.d.ts +58 -0
  55. package/core/fetcher/HttpResponsePromise.js +103 -0
  56. package/core/fetcher/RawResponse.d.ts +29 -0
  57. package/core/fetcher/RawResponse.js +44 -0
  58. package/core/fetcher/index.d.ts +3 -0
  59. package/core/fetcher/index.js +7 -1
  60. package/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  61. package/core/form-data-utils/FormDataWrapper.js +48 -9
  62. package/core/pagination/Page.d.ts +5 -2
  63. package/core/pagination/Page.js +5 -2
  64. package/core/pagination/Pageable.d.ts +2 -0
  65. package/dist/Client.d.ts +11 -7
  66. package/dist/Client.js +54 -6
  67. package/dist/api/resources/empathicVoice/errors/BadRequestError.d.ts +2 -1
  68. package/dist/api/resources/empathicVoice/errors/BadRequestError.js +2 -1
  69. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.d.ts +4 -2
  70. package/dist/api/resources/empathicVoice/resources/chatGroups/client/Client.js +74 -40
  71. package/dist/api/resources/empathicVoice/resources/chats/client/Client.d.ts +2 -1
  72. package/dist/api/resources/empathicVoice/resources/chats/client/Client.js +55 -30
  73. package/dist/api/resources/empathicVoice/resources/configs/client/Client.d.ts +14 -7
  74. package/dist/api/resources/empathicVoice/resources/configs/client/Client.js +134 -64
  75. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +1 -0
  76. package/dist/api/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +1 -0
  77. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.d.ts +10 -5
  78. package/dist/api/resources/empathicVoice/resources/customVoices/client/Client.js +88 -41
  79. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.d.ts +16 -8
  80. package/dist/api/resources/empathicVoice/resources/prompts/client/Client.js +133 -62
  81. package/dist/api/resources/empathicVoice/resources/tools/client/Client.d.ts +14 -7
  82. package/dist/api/resources/empathicVoice/resources/tools/client/Client.js +134 -64
  83. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.d.ts +12 -0
  84. package/dist/api/resources/empathicVoice/types/PostedNudgeSpec.js +5 -0
  85. package/dist/api/resources/empathicVoice/types/ReturnConfig.d.ts +1 -0
  86. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +12 -0
  87. package/dist/api/resources/empathicVoice/types/ReturnNudgeSpec.js +5 -0
  88. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +2 -1
  89. package/dist/api/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  90. package/dist/api/resources/empathicVoice/types/index.d.ts +2 -0
  91. package/dist/api/resources/empathicVoice/types/index.js +2 -0
  92. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.d.ts +12 -6
  93. package/dist/api/resources/expressionMeasurement/resources/batch/client/Client.js +89 -38
  94. package/dist/api/resources/tts/client/Client.d.ts +24 -18
  95. package/dist/api/resources/tts/client/Client.js +84 -46
  96. package/dist/api/resources/tts/client/index.d.ts +1 -1
  97. package/dist/api/resources/tts/client/index.js +15 -0
  98. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.d.ts +36 -0
  99. package/dist/api/resources/tts/client/requests/SynthesizeJsonRequest.js +5 -0
  100. package/dist/api/resources/tts/client/requests/index.d.ts +1 -0
  101. package/dist/api/resources/tts/client/requests/index.js +2 -0
  102. package/dist/api/resources/tts/errors/BadRequestError.d.ts +2 -1
  103. package/dist/api/resources/tts/errors/BadRequestError.js +2 -1
  104. package/dist/api/resources/tts/errors/UnprocessableEntityError.d.ts +2 -1
  105. package/dist/api/resources/tts/errors/UnprocessableEntityError.js +2 -1
  106. package/dist/api/resources/tts/resources/voices/client/Client.d.ts +4 -2
  107. package/dist/api/resources/tts/resources/voices/client/Client.js +45 -22
  108. package/dist/api/resources/tts/types/Snippet.d.ts +2 -0
  109. package/dist/api/resources/tts/types/SnippetAudioChunk.d.ts +2 -0
  110. package/dist/core/fetcher/APIResponse.d.ts +10 -0
  111. package/dist/core/fetcher/Fetcher.js +7 -0
  112. package/dist/core/fetcher/Headers.d.ts +2 -0
  113. package/dist/core/fetcher/Headers.js +84 -0
  114. package/dist/core/fetcher/HttpResponsePromise.d.ts +58 -0
  115. package/dist/core/fetcher/HttpResponsePromise.js +103 -0
  116. package/dist/core/fetcher/RawResponse.d.ts +29 -0
  117. package/dist/core/fetcher/RawResponse.js +44 -0
  118. package/dist/core/fetcher/index.d.ts +3 -0
  119. package/dist/core/fetcher/index.js +7 -1
  120. package/dist/core/form-data-utils/FormDataWrapper.d.ts +3 -0
  121. package/dist/core/form-data-utils/FormDataWrapper.js +48 -9
  122. package/dist/core/pagination/Page.d.ts +5 -2
  123. package/dist/core/pagination/Page.js +5 -2
  124. package/dist/core/pagination/Pageable.d.ts +2 -0
  125. package/dist/errors/HumeError.d.ts +7 -2
  126. package/dist/errors/HumeError.js +10 -10
  127. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  128. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  129. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  130. package/dist/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  131. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  132. package/dist/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  133. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  134. package/dist/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  135. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  136. package/dist/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  137. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  138. package/dist/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  139. package/dist/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  140. package/dist/serialization/resources/empathicVoice/types/index.js +2 -0
  141. package/dist/serialization/resources/tts/types/Snippet.d.ts +1 -0
  142. package/dist/serialization/resources/tts/types/Snippet.js +1 -0
  143. package/dist/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  144. package/dist/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  145. package/dist/version.d.ts +1 -1
  146. package/dist/version.js +1 -1
  147. package/dist/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  148. package/dist/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  149. package/dist/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
  150. package/errors/HumeError.d.ts +7 -2
  151. package/errors/HumeError.js +10 -10
  152. package/package.json +3 -2
  153. package/reference.md +17 -15
  154. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.d.ts +2 -0
  155. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfig.js +2 -0
  156. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.d.ts +2 -0
  157. package/serialization/resources/empathicVoice/resources/configs/client/requests/PostedConfigVersion.js +2 -0
  158. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.d.ts +13 -0
  159. package/serialization/resources/empathicVoice/types/PostedNudgeSpec.js +44 -0
  160. package/serialization/resources/empathicVoice/types/ReturnConfig.d.ts +2 -0
  161. package/serialization/resources/empathicVoice/types/ReturnConfig.js +2 -0
  162. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.d.ts +13 -0
  163. package/serialization/resources/empathicVoice/types/ReturnNudgeSpec.js +44 -0
  164. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.d.ts +1 -1
  165. package/serialization/resources/empathicVoice/types/WebhookEventChatStatus.js +1 -0
  166. package/serialization/resources/empathicVoice/types/index.d.ts +2 -0
  167. package/serialization/resources/empathicVoice/types/index.js +2 -0
  168. package/serialization/resources/tts/types/Snippet.d.ts +1 -0
  169. package/serialization/resources/tts/types/Snippet.js +1 -0
  170. package/serialization/resources/tts/types/SnippetAudioChunk.d.ts +1 -0
  171. package/serialization/resources/tts/types/SnippetAudioChunk.js +1 -0
  172. package/version.d.ts +1 -1
  173. package/version.js +1 -1
  174. package/wrapper/expressionMeasurement/ExpressionMeasurementClient.js +2 -0
  175. package/wrapper/expressionMeasurement/batch/BatchClient.d.ts +2 -1
  176. package/wrapper/expressionMeasurement/batch/BatchClient.js +43 -17
@@ -74,7 +74,7 @@ class Voices {
74
74
  */
75
75
  list(request, requestOptions) {
76
76
  return __awaiter(this, void 0, void 0, function* () {
77
- const list = (request) => __awaiter(this, void 0, void 0, function* () {
77
+ const list = core.HttpResponsePromise.interceptFunction((request) => __awaiter(this, void 0, void 0, function* () {
78
78
  var _a, _b, _c;
79
79
  const { provider, pageNumber, pageSize, ascendingOrder } = request;
80
80
  const _queryParams = {};
@@ -93,7 +93,7 @@ class Voices {
93
93
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
94
94
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/voices"),
95
95
  method: "GET",
96
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
96
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
97
97
  contentType: "application/json",
98
98
  queryParameters: _queryParams,
99
99
  requestType: "json",
@@ -102,12 +102,15 @@ class Voices {
102
102
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
103
103
  });
104
104
  if (_response.ok) {
105
- return serializers.tts.ReturnPagedVoices.parseOrThrow(_response.body, {
106
- unrecognizedObjectKeys: "passthrough",
107
- allowUnrecognizedUnionMembers: true,
108
- allowUnrecognizedEnumValues: true,
109
- breadcrumbsPrefix: ["response"],
110
- });
105
+ return {
106
+ data: serializers.tts.ReturnPagedVoices.parseOrThrow(_response.body, {
107
+ unrecognizedObjectKeys: "passthrough",
108
+ allowUnrecognizedUnionMembers: true,
109
+ allowUnrecognizedEnumValues: true,
110
+ breadcrumbsPrefix: ["response"],
111
+ }),
112
+ rawResponse: _response.rawResponse,
113
+ };
111
114
  }
112
115
  if (_response.error.reason === "status-code") {
113
116
  switch (_response.error.statusCode) {
@@ -117,11 +120,12 @@ class Voices {
117
120
  allowUnrecognizedUnionMembers: true,
118
121
  allowUnrecognizedEnumValues: true,
119
122
  breadcrumbsPrefix: ["response"],
120
- }));
123
+ }), _response.rawResponse);
121
124
  default:
122
125
  throw new errors.HumeError({
123
126
  statusCode: _response.error.statusCode,
124
127
  body: _response.error.body,
128
+ rawResponse: _response.rawResponse,
125
129
  });
126
130
  }
127
131
  }
@@ -130,18 +134,22 @@ class Voices {
130
134
  throw new errors.HumeError({
131
135
  statusCode: _response.error.statusCode,
132
136
  body: _response.error.rawBody,
137
+ rawResponse: _response.rawResponse,
133
138
  });
134
139
  case "timeout":
135
140
  throw new errors.HumeTimeoutError("Timeout exceeded when calling GET /v0/tts/voices.");
136
141
  case "unknown":
137
142
  throw new errors.HumeError({
138
143
  message: _response.error.errorMessage,
144
+ rawResponse: _response.rawResponse,
139
145
  });
140
146
  }
141
- });
147
+ }));
142
148
  let _offset = (request === null || request === void 0 ? void 0 : request.pageNumber) != null ? request === null || request === void 0 ? void 0 : request.pageNumber : 0;
149
+ const dataWithRawResponse = yield list(request).withRawResponse();
143
150
  return new core.Pageable({
144
- response: yield list(request),
151
+ response: dataWithRawResponse.data,
152
+ rawResponse: dataWithRawResponse.rawResponse,
145
153
  hasNextPage: (response) => { var _a; return ((_a = response === null || response === void 0 ? void 0 : response.voicesPage) !== null && _a !== void 0 ? _a : []).length > 0; },
146
154
  getItems: (response) => { var _a; return (_a = response === null || response === void 0 ? void 0 : response.voicesPage) !== null && _a !== void 0 ? _a : []; },
147
155
  loadPage: (_response) => {
@@ -168,12 +176,15 @@ class Voices {
168
176
  * })
169
177
  */
170
178
  create(request, requestOptions) {
179
+ return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
180
+ }
181
+ __create(request, requestOptions) {
171
182
  return __awaiter(this, void 0, void 0, function* () {
172
183
  var _a, _b, _c;
173
184
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
174
185
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/voices"),
175
186
  method: "POST",
176
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
187
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
177
188
  contentType: "application/json",
178
189
  requestType: "json",
179
190
  body: serializers.tts.PostedVoice.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -182,12 +193,15 @@ class Voices {
182
193
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
183
194
  });
184
195
  if (_response.ok) {
185
- return serializers.tts.ReturnVoice.parseOrThrow(_response.body, {
186
- unrecognizedObjectKeys: "passthrough",
187
- allowUnrecognizedUnionMembers: true,
188
- allowUnrecognizedEnumValues: true,
189
- breadcrumbsPrefix: ["response"],
190
- });
196
+ return {
197
+ data: serializers.tts.ReturnVoice.parseOrThrow(_response.body, {
198
+ unrecognizedObjectKeys: "passthrough",
199
+ allowUnrecognizedUnionMembers: true,
200
+ allowUnrecognizedEnumValues: true,
201
+ breadcrumbsPrefix: ["response"],
202
+ }),
203
+ rawResponse: _response.rawResponse,
204
+ };
191
205
  }
192
206
  if (_response.error.reason === "status-code") {
193
207
  switch (_response.error.statusCode) {
@@ -197,11 +211,12 @@ class Voices {
197
211
  allowUnrecognizedUnionMembers: true,
198
212
  allowUnrecognizedEnumValues: true,
199
213
  breadcrumbsPrefix: ["response"],
200
- }));
214
+ }), _response.rawResponse);
201
215
  default:
202
216
  throw new errors.HumeError({
203
217
  statusCode: _response.error.statusCode,
204
218
  body: _response.error.body,
219
+ rawResponse: _response.rawResponse,
205
220
  });
206
221
  }
207
222
  }
@@ -210,12 +225,14 @@ class Voices {
210
225
  throw new errors.HumeError({
211
226
  statusCode: _response.error.statusCode,
212
227
  body: _response.error.rawBody,
228
+ rawResponse: _response.rawResponse,
213
229
  });
214
230
  case "timeout":
215
231
  throw new errors.HumeTimeoutError("Timeout exceeded when calling POST /v0/tts/voices.");
216
232
  case "unknown":
217
233
  throw new errors.HumeError({
218
234
  message: _response.error.errorMessage,
235
+ rawResponse: _response.rawResponse,
219
236
  });
220
237
  }
221
238
  });
@@ -234,6 +251,9 @@ class Voices {
234
251
  * })
235
252
  */
236
253
  delete(request, requestOptions) {
254
+ return core.HttpResponsePromise.fromPromise(this.__delete(request, requestOptions));
255
+ }
256
+ __delete(request, requestOptions) {
237
257
  return __awaiter(this, void 0, void 0, function* () {
238
258
  var _a, _b, _c;
239
259
  const { name } = request;
@@ -242,7 +262,7 @@ class Voices {
242
262
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
243
263
  url: (0, url_join_1.default)((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.HumeEnvironment.Production, "v0/tts/voices"),
244
264
  method: "DELETE",
245
- headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.1", "User-Agent": "hume/0.11.1", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
265
+ headers: Object.assign(Object.assign({ "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "hume", "X-Fern-SDK-Version": "0.11.2", "User-Agent": "hume/0.11.2", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
246
266
  contentType: "application/json",
247
267
  queryParameters: _queryParams,
248
268
  requestType: "json",
@@ -251,7 +271,7 @@ class Voices {
251
271
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
252
272
  });
253
273
  if (_response.ok) {
254
- return;
274
+ return { data: undefined, rawResponse: _response.rawResponse };
255
275
  }
256
276
  if (_response.error.reason === "status-code") {
257
277
  switch (_response.error.statusCode) {
@@ -261,11 +281,12 @@ class Voices {
261
281
  allowUnrecognizedUnionMembers: true,
262
282
  allowUnrecognizedEnumValues: true,
263
283
  breadcrumbsPrefix: ["response"],
264
- }));
284
+ }), _response.rawResponse);
265
285
  default:
266
286
  throw new errors.HumeError({
267
287
  statusCode: _response.error.statusCode,
268
288
  body: _response.error.body,
289
+ rawResponse: _response.rawResponse,
269
290
  });
270
291
  }
271
292
  }
@@ -274,12 +295,14 @@ class Voices {
274
295
  throw new errors.HumeError({
275
296
  statusCode: _response.error.statusCode,
276
297
  body: _response.error.rawBody,
298
+ rawResponse: _response.rawResponse,
277
299
  });
278
300
  case "timeout":
279
301
  throw new errors.HumeTimeoutError("Timeout exceeded when calling DELETE /v0/tts/voices.");
280
302
  case "unknown":
281
303
  throw new errors.HumeError({
282
304
  message: _response.error.errorMessage,
305
+ rawResponse: _response.rawResponse,
283
306
  });
284
307
  }
285
308
  });
@@ -10,6 +10,8 @@ export interface Snippet {
10
10
  id: string;
11
11
  /** The text for this **Snippet**. */
12
12
  text: string;
13
+ /** The transcribed text of the generated audio. It is only present if `instant_mode` is set to `false`. */
14
+ transcribedText?: string;
13
15
  /** The index of the utterance in the request this snippet corresponds to. */
14
16
  utteranceIndex?: number;
15
17
  }
@@ -14,6 +14,8 @@ export interface SnippetAudioChunk {
14
14
  snippetId: string;
15
15
  /** The text of the parent snippet that this chunk corresponds to. */
16
16
  text: string;
17
+ /** The transcribed text of the generated audio of the parent snippet that this chunk corresponds to. It is only present if `instant_mode` is set to `false`. */
18
+ transcribedText?: string;
17
19
  /** The index of the utterance in the request that the parent snippet of this chunk corresponds to. */
18
20
  utteranceIndex?: number;
19
21
  }
@@ -1,10 +1,20 @@
1
+ import { RawResponse } from "./RawResponse";
2
+ /**
3
+ * The response of an API call.
4
+ * It is a successful response or a failed response.
5
+ */
1
6
  export type APIResponse<Success, Failure> = SuccessfulResponse<Success> | FailedResponse<Failure>;
2
7
  export interface SuccessfulResponse<T> {
3
8
  ok: true;
4
9
  body: T;
10
+ /**
11
+ * @deprecated Use `rawResponse` instead
12
+ */
5
13
  headers?: Record<string, any>;
14
+ rawResponse: RawResponse;
6
15
  }
7
16
  export interface FailedResponse<T> {
8
17
  ok: false;
9
18
  error: T;
19
+ rawResponse: RawResponse;
10
20
  }
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.fetcher = void 0;
13
13
  exports.fetcherImpl = fetcherImpl;
14
14
  const json_1 = require("../json");
15
+ const RawResponse_1 = require("./RawResponse");
15
16
  const createRequestUrl_1 = require("./createRequestUrl");
16
17
  const getFetchFn_1 = require("./getFetchFn");
17
18
  const getRequestBody_1 = require("./getRequestBody");
@@ -47,6 +48,7 @@ function fetcherImpl(args) {
47
48
  ok: true,
48
49
  body: responseBody,
49
50
  headers: response.headers,
51
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
50
52
  };
51
53
  }
52
54
  else {
@@ -57,6 +59,7 @@ function fetcherImpl(args) {
57
59
  statusCode: response.status,
58
60
  body: responseBody,
59
61
  },
62
+ rawResponse: (0, RawResponse_1.toRawResponse)(response),
60
63
  };
61
64
  }
62
65
  }
@@ -68,6 +71,7 @@ function fetcherImpl(args) {
68
71
  reason: "unknown",
69
72
  errorMessage: "The user aborted a request",
70
73
  },
74
+ rawResponse: RawResponse_1.abortRawResponse,
71
75
  };
72
76
  }
73
77
  else if (error instanceof Error && error.name === "AbortError") {
@@ -76,6 +80,7 @@ function fetcherImpl(args) {
76
80
  error: {
77
81
  reason: "timeout",
78
82
  },
83
+ rawResponse: RawResponse_1.abortRawResponse,
79
84
  };
80
85
  }
81
86
  else if (error instanceof Error) {
@@ -85,6 +90,7 @@ function fetcherImpl(args) {
85
90
  reason: "unknown",
86
91
  errorMessage: error.message,
87
92
  },
93
+ rawResponse: RawResponse_1.unknownRawResponse,
88
94
  };
89
95
  }
90
96
  return {
@@ -93,6 +99,7 @@ function fetcherImpl(args) {
93
99
  reason: "unknown",
94
100
  errorMessage: (0, json_1.toJson)(error),
95
101
  },
102
+ rawResponse: RawResponse_1.unknownRawResponse,
96
103
  };
97
104
  }
98
105
  });
@@ -0,0 +1,2 @@
1
+ declare let Headers: typeof globalThis.Headers;
2
+ export { Headers };
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Headers = void 0;
4
+ let Headers;
5
+ if (typeof globalThis.Headers !== "undefined") {
6
+ exports.Headers = Headers = globalThis.Headers;
7
+ }
8
+ else {
9
+ exports.Headers = Headers = class Headers {
10
+ constructor(init) {
11
+ this.headers = new Map();
12
+ if (init) {
13
+ if (init instanceof Headers) {
14
+ init.forEach((value, key) => this.append(key, value));
15
+ }
16
+ else if (Array.isArray(init)) {
17
+ for (const [key, value] of init) {
18
+ if (typeof key === "string" && typeof value === "string") {
19
+ this.append(key, value);
20
+ }
21
+ else {
22
+ throw new TypeError("Each header entry must be a [string, string] tuple");
23
+ }
24
+ }
25
+ }
26
+ else {
27
+ for (const [key, value] of Object.entries(init)) {
28
+ if (typeof value === "string") {
29
+ this.append(key, value);
30
+ }
31
+ else {
32
+ throw new TypeError("Header values must be strings");
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+ append(name, value) {
39
+ const key = name.toLowerCase();
40
+ const existing = this.headers.get(key) || [];
41
+ this.headers.set(key, [...existing, value]);
42
+ }
43
+ delete(name) {
44
+ const key = name.toLowerCase();
45
+ this.headers.delete(key);
46
+ }
47
+ get(name) {
48
+ const key = name.toLowerCase();
49
+ const values = this.headers.get(key);
50
+ return values ? values.join(", ") : null;
51
+ }
52
+ has(name) {
53
+ const key = name.toLowerCase();
54
+ return this.headers.has(key);
55
+ }
56
+ set(name, value) {
57
+ const key = name.toLowerCase();
58
+ this.headers.set(key, [value]);
59
+ }
60
+ forEach(callbackfn, thisArg) {
61
+ const boundCallback = thisArg ? callbackfn.bind(thisArg) : callbackfn;
62
+ this.headers.forEach((values, key) => boundCallback(values.join(", "), key, this));
63
+ }
64
+ getSetCookie() {
65
+ return this.headers.get("set-cookie") || [];
66
+ }
67
+ *entries() {
68
+ for (const [key, values] of this.headers.entries()) {
69
+ yield [key, values.join(", ")];
70
+ }
71
+ }
72
+ *keys() {
73
+ yield* this.headers.keys();
74
+ }
75
+ *values() {
76
+ for (const values of this.headers.values()) {
77
+ yield values.join(", ");
78
+ }
79
+ }
80
+ [Symbol.iterator]() {
81
+ return this.entries();
82
+ }
83
+ };
84
+ }
@@ -0,0 +1,58 @@
1
+ import { WithRawResponse } from "./RawResponse";
2
+ /**
3
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
4
+ */
5
+ export declare class HttpResponsePromise<T> extends Promise<T> {
6
+ private innerPromise;
7
+ private unwrappedPromise;
8
+ private constructor();
9
+ /**
10
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
11
+ *
12
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
13
+ * @param args - Arguments to pass to the function.
14
+ * @returns An `HttpResponsePromise` instance.
15
+ */
16
+ static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
17
+ /**
18
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
19
+ *
20
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
21
+ * @returns A function that returns an `HttpResponsePromise` instance.
22
+ */
23
+ static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
24
+ /**
25
+ * Creates an `HttpResponsePromise` from an existing promise.
26
+ *
27
+ * @param promise - A promise resolving to a `WithRawResponse` object.
28
+ * @returns An `HttpResponsePromise` instance.
29
+ */
30
+ static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
31
+ /**
32
+ * Creates an `HttpResponsePromise` from an executor function.
33
+ *
34
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
35
+ * @returns An `HttpResponsePromise` instance.
36
+ */
37
+ static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
38
+ /**
39
+ * Creates an `HttpResponsePromise` from a resolved result.
40
+ *
41
+ * @param result - A `WithRawResponse` object to resolve immediately.
42
+ * @returns An `HttpResponsePromise` instance.
43
+ */
44
+ static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
45
+ private unwrap;
46
+ /** @inheritdoc */
47
+ then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
48
+ /** @inheritdoc */
49
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
50
+ /** @inheritdoc */
51
+ finally(onfinally?: (() => void) | null): Promise<T>;
52
+ /**
53
+ * Retrieves the data and raw response.
54
+ *
55
+ * @returns A promise resolving to a `WithRawResponse` object.
56
+ */
57
+ withRawResponse(): Promise<WithRawResponse<T>>;
58
+ }
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.HttpResponsePromise = void 0;
13
+ /**
14
+ * A promise that returns the parsed response and lets you retrieve the raw response too.
15
+ */
16
+ class HttpResponsePromise extends Promise {
17
+ constructor(promise) {
18
+ // Initialize with a no-op to avoid premature parsing
19
+ super((resolve) => {
20
+ resolve(undefined);
21
+ });
22
+ this.innerPromise = promise;
23
+ }
24
+ /**
25
+ * Creates an `HttpResponsePromise` from a function that returns a promise.
26
+ *
27
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
28
+ * @param args - Arguments to pass to the function.
29
+ * @returns An `HttpResponsePromise` instance.
30
+ */
31
+ static fromFunction(fn, ...args) {
32
+ return new HttpResponsePromise(fn(...args));
33
+ }
34
+ /**
35
+ * Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
36
+ *
37
+ * @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
38
+ * @returns A function that returns an `HttpResponsePromise` instance.
39
+ */
40
+ static interceptFunction(fn) {
41
+ return (...args) => {
42
+ return HttpResponsePromise.fromPromise(fn(...args));
43
+ };
44
+ }
45
+ /**
46
+ * Creates an `HttpResponsePromise` from an existing promise.
47
+ *
48
+ * @param promise - A promise resolving to a `WithRawResponse` object.
49
+ * @returns An `HttpResponsePromise` instance.
50
+ */
51
+ static fromPromise(promise) {
52
+ return new HttpResponsePromise(promise);
53
+ }
54
+ /**
55
+ * Creates an `HttpResponsePromise` from an executor function.
56
+ *
57
+ * @param executor - A function that takes resolve and reject callbacks to create a promise.
58
+ * @returns An `HttpResponsePromise` instance.
59
+ */
60
+ static fromExecutor(executor) {
61
+ const promise = new Promise(executor);
62
+ return new HttpResponsePromise(promise);
63
+ }
64
+ /**
65
+ * Creates an `HttpResponsePromise` from a resolved result.
66
+ *
67
+ * @param result - A `WithRawResponse` object to resolve immediately.
68
+ * @returns An `HttpResponsePromise` instance.
69
+ */
70
+ static fromResult(result) {
71
+ const promise = Promise.resolve(result);
72
+ return new HttpResponsePromise(promise);
73
+ }
74
+ unwrap() {
75
+ if (!this.unwrappedPromise) {
76
+ this.unwrappedPromise = this.innerPromise.then(({ data }) => data);
77
+ }
78
+ return this.unwrappedPromise;
79
+ }
80
+ /** @inheritdoc */
81
+ then(onfulfilled, onrejected) {
82
+ return this.unwrap().then(onfulfilled, onrejected);
83
+ }
84
+ /** @inheritdoc */
85
+ catch(onrejected) {
86
+ return this.unwrap().catch(onrejected);
87
+ }
88
+ /** @inheritdoc */
89
+ finally(onfinally) {
90
+ return this.unwrap().finally(onfinally);
91
+ }
92
+ /**
93
+ * Retrieves the data and raw response.
94
+ *
95
+ * @returns A promise resolving to a `WithRawResponse` object.
96
+ */
97
+ withRawResponse() {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ return yield this.innerPromise;
100
+ });
101
+ }
102
+ }
103
+ exports.HttpResponsePromise = HttpResponsePromise;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The raw response from the fetch call excluding the body.
3
+ */
4
+ export type RawResponse = Omit<{
5
+ [K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
6
+ }, "ok" | "body" | "bodyUsed">;
7
+ /**
8
+ * A raw response indicating that the request was aborted.
9
+ */
10
+ export declare const abortRawResponse: RawResponse;
11
+ /**
12
+ * A raw response indicating an unknown error.
13
+ */
14
+ export declare const unknownRawResponse: RawResponse;
15
+ /**
16
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
17
+ * excluding the `body` and `bodyUsed` fields.
18
+ *
19
+ * @param response - The `RawResponse` object to convert.
20
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
21
+ */
22
+ export declare function toRawResponse(response: Response): RawResponse;
23
+ /**
24
+ * Creates a `RawResponse` from a standard `Response` object.
25
+ */
26
+ export interface WithRawResponse<T> {
27
+ readonly data: T;
28
+ readonly rawResponse: RawResponse;
29
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.unknownRawResponse = exports.abortRawResponse = void 0;
4
+ exports.toRawResponse = toRawResponse;
5
+ const Headers_1 = require("./Headers");
6
+ /**
7
+ * A raw response indicating that the request was aborted.
8
+ */
9
+ exports.abortRawResponse = {
10
+ headers: new Headers_1.Headers(),
11
+ redirected: false,
12
+ status: 499,
13
+ statusText: "Client Closed Request",
14
+ type: "error",
15
+ url: "",
16
+ };
17
+ /**
18
+ * A raw response indicating an unknown error.
19
+ */
20
+ exports.unknownRawResponse = {
21
+ headers: new Headers_1.Headers(),
22
+ redirected: false,
23
+ status: 0,
24
+ statusText: "Unknown Error",
25
+ type: "error",
26
+ url: "",
27
+ };
28
+ /**
29
+ * Converts a `RawResponse` object into a `RawResponse` by extracting its properties,
30
+ * excluding the `body` and `bodyUsed` fields.
31
+ *
32
+ * @param response - The `RawResponse` object to convert.
33
+ * @returns A `RawResponse` object containing the extracted properties of the input response.
34
+ */
35
+ function toRawResponse(response) {
36
+ return {
37
+ headers: response.headers,
38
+ redirected: response.redirected,
39
+ status: response.status,
40
+ statusText: response.statusText,
41
+ type: response.type,
42
+ url: response.url,
43
+ };
44
+ }
@@ -3,3 +3,6 @@ export { fetcher } from "./Fetcher";
3
3
  export type { Fetcher, FetchFunction } from "./Fetcher";
4
4
  export { getHeader } from "./getHeader";
5
5
  export { Supplier } from "./Supplier";
6
+ export { abortRawResponse, toRawResponse, unknownRawResponse } from "./RawResponse";
7
+ export type { RawResponse, WithRawResponse } from "./RawResponse";
8
+ export { HttpResponsePromise } from "./HttpResponsePromise";
@@ -1,9 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Supplier = exports.getHeader = exports.fetcher = void 0;
3
+ exports.HttpResponsePromise = exports.unknownRawResponse = exports.toRawResponse = exports.abortRawResponse = exports.Supplier = exports.getHeader = exports.fetcher = void 0;
4
4
  var Fetcher_1 = require("./Fetcher");
5
5
  Object.defineProperty(exports, "fetcher", { enumerable: true, get: function () { return Fetcher_1.fetcher; } });
6
6
  var getHeader_1 = require("./getHeader");
7
7
  Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_1.getHeader; } });
8
8
  var Supplier_1 = require("./Supplier");
9
9
  Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Supplier_1.Supplier; } });
10
+ var RawResponse_1 = require("./RawResponse");
11
+ Object.defineProperty(exports, "abortRawResponse", { enumerable: true, get: function () { return RawResponse_1.abortRawResponse; } });
12
+ Object.defineProperty(exports, "toRawResponse", { enumerable: true, get: function () { return RawResponse_1.toRawResponse; } });
13
+ Object.defineProperty(exports, "unknownRawResponse", { enumerable: true, get: function () { return RawResponse_1.unknownRawResponse; } });
14
+ var HttpResponsePromise_1 = require("./HttpResponsePromise");
15
+ Object.defineProperty(exports, "HttpResponsePromise", { enumerable: true, get: function () { return HttpResponsePromise_1.HttpResponsePromise; } });