hume 0.2.7 → 0.3.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 (47) hide show
  1. package/Client.d.ts +11 -0
  2. package/Client.js +42 -7
  3. package/api/client/requests/ListJobsRequest.d.ts +9 -0
  4. package/api/types/index.d.ts +11 -11
  5. package/api/types/index.js +11 -11
  6. package/core/fetcher/APIResponse.d.ts +1 -0
  7. package/core/fetcher/Fetcher.d.ts +1 -4
  8. package/core/fetcher/Fetcher.js +52 -31
  9. package/core/fetcher/getHeader.d.ts +1 -0
  10. package/{dist/core/streaming-fetcher → core/fetcher}/getHeader.js +2 -2
  11. package/core/fetcher/index.d.ts +1 -0
  12. package/core/fetcher/index.js +3 -1
  13. package/core/index.d.ts +0 -1
  14. package/core/index.js +0 -1
  15. package/dist/Client.d.ts +11 -0
  16. package/dist/Client.js +42 -7
  17. package/dist/api/client/requests/ListJobsRequest.d.ts +9 -0
  18. package/dist/api/types/index.d.ts +11 -11
  19. package/dist/api/types/index.js +11 -11
  20. package/dist/core/fetcher/APIResponse.d.ts +1 -0
  21. package/dist/core/fetcher/Fetcher.d.ts +1 -4
  22. package/dist/core/fetcher/Fetcher.js +52 -31
  23. package/dist/core/fetcher/getHeader.d.ts +1 -0
  24. package/{core/streaming-fetcher → dist/core/fetcher}/getHeader.js +2 -2
  25. package/dist/core/fetcher/index.d.ts +1 -0
  26. package/dist/core/fetcher/index.js +3 -1
  27. package/dist/core/index.d.ts +0 -1
  28. package/dist/core/index.js +0 -1
  29. package/dist/serialization/types/index.d.ts +11 -11
  30. package/dist/serialization/types/index.js +11 -11
  31. package/package.json +6 -4
  32. package/serialization/types/index.d.ts +11 -11
  33. package/serialization/types/index.js +11 -11
  34. package/core/streaming-fetcher/Stream.d.ts +0 -14
  35. package/core/streaming-fetcher/Stream.js +0 -75
  36. package/core/streaming-fetcher/StreamingFetcher.d.ts +0 -24
  37. package/core/streaming-fetcher/StreamingFetcher.js +0 -58
  38. package/core/streaming-fetcher/getHeader.d.ts +0 -2
  39. package/core/streaming-fetcher/index.d.ts +0 -4
  40. package/core/streaming-fetcher/index.js +0 -9
  41. package/dist/core/streaming-fetcher/Stream.d.ts +0 -14
  42. package/dist/core/streaming-fetcher/Stream.js +0 -75
  43. package/dist/core/streaming-fetcher/StreamingFetcher.d.ts +0 -24
  44. package/dist/core/streaming-fetcher/StreamingFetcher.js +0 -58
  45. package/dist/core/streaming-fetcher/getHeader.d.ts +0 -2
  46. package/dist/core/streaming-fetcher/index.d.ts +0 -4
  47. package/dist/core/streaming-fetcher/index.js +0 -9
package/Client.d.ts CHANGED
@@ -21,6 +21,14 @@ export declare class HumeClient {
21
21
  constructor(_options: HumeClient.Options);
22
22
  /**
23
23
  * Sort and filter jobs.
24
+ *
25
+ * @example
26
+ * await hume.listJobs({
27
+ * status: Hume.Status.Queued,
28
+ * when: Hume.When.CreatedBefore,
29
+ * sortBy: Hume.SortBy.Created,
30
+ * direction: Hume.Direction.Asc
31
+ * })
24
32
  */
25
33
  listJobs(request?: Hume.ListJobsRequest, requestOptions?: HumeClient.RequestOptions): Promise<Hume.JobRequest[]>;
26
34
  /**
@@ -29,6 +37,9 @@ export declare class HumeClient {
29
37
  submitJob(request?: Hume.BaseRequest, requestOptions?: HumeClient.RequestOptions): Promise<Hume.JobId>;
30
38
  /**
31
39
  * Get the JSON predictions of a completed job.
40
+ *
41
+ * @example
42
+ * await hume.getJobPredictions("id")
32
43
  */
33
44
  getJobPredictions(id: string, requestOptions?: HumeClient.RequestOptions): Promise<Hume.SourceResult[]>;
34
45
  /**
package/Client.js CHANGED
@@ -50,6 +50,14 @@ class HumeClient {
50
50
  }
51
51
  /**
52
52
  * Sort and filter jobs.
53
+ *
54
+ * @example
55
+ * await hume.listJobs({
56
+ * status: Hume.Status.Queued,
57
+ * when: Hume.When.CreatedBefore,
58
+ * sortBy: Hume.SortBy.Created,
59
+ * direction: Hume.Direction.Asc
60
+ * })
53
61
  */
54
62
  listJobs(request = {}, requestOptions) {
55
63
  var _a;
@@ -86,7 +94,7 @@ class HumeClient {
86
94
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
87
95
  "X-Fern-Language": "JavaScript",
88
96
  "X-Fern-SDK-Name": "hume",
89
- "X-Fern-SDK-Version": "0.2.7",
97
+ "X-Fern-SDK-Version": "0.3.0",
90
98
  },
91
99
  contentType: "application/json",
92
100
  queryParameters: _queryParams,
@@ -135,7 +143,7 @@ class HumeClient {
135
143
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
136
144
  "X-Fern-Language": "JavaScript",
137
145
  "X-Fern-SDK-Name": "hume",
138
- "X-Fern-SDK-Version": "0.2.7",
146
+ "X-Fern-SDK-Version": "0.3.0",
139
147
  },
140
148
  contentType: "application/json",
141
149
  body: yield serializers.BaseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -173,6 +181,9 @@ class HumeClient {
173
181
  }
174
182
  /**
175
183
  * Get the JSON predictions of a completed job.
184
+ *
185
+ * @example
186
+ * await hume.getJobPredictions("id")
176
187
  */
177
188
  getJobPredictions(id, requestOptions) {
178
189
  var _a;
@@ -184,7 +195,7 @@ class HumeClient {
184
195
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
185
196
  "X-Fern-Language": "JavaScript",
186
197
  "X-Fern-SDK-Name": "hume",
187
- "X-Fern-SDK-Version": "0.2.7",
198
+ "X-Fern-SDK-Version": "0.3.0",
188
199
  },
189
200
  contentType: "application/json",
190
201
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -225,18 +236,42 @@ class HumeClient {
225
236
  getJobArtifacts(id, requestOptions) {
226
237
  var _a;
227
238
  return __awaiter(this, void 0, void 0, function* () {
228
- const _response = yield core.streamingFetcher({
239
+ const _response = yield core.fetcher({
229
240
  url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Default, `v0/batch/jobs/${id}/artifacts`),
230
241
  method: "GET",
231
242
  headers: {
232
243
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
233
244
  "X-Fern-Language": "JavaScript",
234
245
  "X-Fern-SDK-Name": "hume",
235
- "X-Fern-SDK-Version": "0.2.7",
246
+ "X-Fern-SDK-Version": "0.3.0",
236
247
  },
248
+ contentType: "application/json",
249
+ responseType: "streaming",
237
250
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
251
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
238
252
  });
239
- return _response.data;
253
+ if (_response.ok) {
254
+ return _response.body;
255
+ }
256
+ if (_response.error.reason === "status-code") {
257
+ throw new errors.HumeError({
258
+ statusCode: _response.error.statusCode,
259
+ body: _response.error.body,
260
+ });
261
+ }
262
+ switch (_response.error.reason) {
263
+ case "non-json":
264
+ throw new errors.HumeError({
265
+ statusCode: _response.error.statusCode,
266
+ body: _response.error.rawBody,
267
+ });
268
+ case "timeout":
269
+ throw new errors.HumeTimeoutError();
270
+ case "unknown":
271
+ throw new errors.HumeError({
272
+ message: _response.error.errorMessage,
273
+ });
274
+ }
240
275
  });
241
276
  }
242
277
  /**
@@ -252,7 +287,7 @@ class HumeClient {
252
287
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
253
288
  "X-Fern-Language": "JavaScript",
254
289
  "X-Fern-SDK-Name": "hume",
255
- "X-Fern-SDK-Version": "0.2.7",
290
+ "X-Fern-SDK-Version": "0.3.0",
256
291
  },
257
292
  contentType: "application/json",
258
293
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -2,6 +2,15 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Hume from "../..";
5
+ /**
6
+ * @example
7
+ * {
8
+ * status: Hume.Status.Queued,
9
+ * when: Hume.When.CreatedBefore,
10
+ * sortBy: Hume.SortBy.Created,
11
+ * direction: Hume.Direction.Asc
12
+ * }
13
+ */
5
14
  export interface ListJobsRequest {
6
15
  /**
7
16
  * The maximum number of jobs to include in the response.
@@ -62,28 +62,28 @@ export * from "./TranscriptionMetadata";
62
62
  export * from "./Url";
63
63
  export * from "./When";
64
64
  export * from "./Window";
65
- export * from "./ModelsInput";
66
- export * from "./ModelConfig";
67
65
  export * from "./FaceModelConfig";
68
66
  export * from "./LanguageConfig";
69
- export * from "./ModelResponse";
70
- export * from "./BurstResponse";
67
+ export * from "./ModelConfig";
68
+ export * from "./ModelsInput";
71
69
  export * from "./ModelsSuccessBurstPredictionsItem";
72
- export * from "./FaceResponse";
70
+ export * from "./BurstResponse";
73
71
  export * from "./ModelsSuccessFacePredictionsItem";
74
- export * from "./FacemeshResponse";
72
+ export * from "./FaceResponse";
75
73
  export * from "./ModelsSuccessFacemeshPredictionsItem";
76
- export * from "./LanguageResponse";
74
+ export * from "./FacemeshResponse";
77
75
  export * from "./ModelsSuccessLanguagePredictionsItem";
78
- export * from "./ProsodyResponse";
76
+ export * from "./LanguageResponse";
79
77
  export * from "./ModelsSuccessProsodyPredictionsItem";
78
+ export * from "./ProsodyResponse";
79
+ export * from "./ModelResponse";
80
80
  export * from "./ModelsError";
81
81
  export * from "./ModelsWarning";
82
- export * from "./EmotionEmbedding";
83
82
  export * from "./EmotionEmbeddingItem";
83
+ export * from "./EmotionEmbedding";
84
84
  export * from "./TimeRange";
85
85
  export * from "./TextPosition";
86
- export * from "./Sentiment";
87
86
  export * from "./SentimentItem";
88
- export * from "./Toxicity";
87
+ export * from "./Sentiment";
89
88
  export * from "./ToxicityItem";
89
+ export * from "./Toxicity";
@@ -78,28 +78,28 @@ __exportStar(require("./TranscriptionMetadata"), exports);
78
78
  __exportStar(require("./Url"), exports);
79
79
  __exportStar(require("./When"), exports);
80
80
  __exportStar(require("./Window"), exports);
81
- __exportStar(require("./ModelsInput"), exports);
82
- __exportStar(require("./ModelConfig"), exports);
83
81
  __exportStar(require("./FaceModelConfig"), exports);
84
82
  __exportStar(require("./LanguageConfig"), exports);
85
- __exportStar(require("./ModelResponse"), exports);
86
- __exportStar(require("./BurstResponse"), exports);
83
+ __exportStar(require("./ModelConfig"), exports);
84
+ __exportStar(require("./ModelsInput"), exports);
87
85
  __exportStar(require("./ModelsSuccessBurstPredictionsItem"), exports);
88
- __exportStar(require("./FaceResponse"), exports);
86
+ __exportStar(require("./BurstResponse"), exports);
89
87
  __exportStar(require("./ModelsSuccessFacePredictionsItem"), exports);
90
- __exportStar(require("./FacemeshResponse"), exports);
88
+ __exportStar(require("./FaceResponse"), exports);
91
89
  __exportStar(require("./ModelsSuccessFacemeshPredictionsItem"), exports);
92
- __exportStar(require("./LanguageResponse"), exports);
90
+ __exportStar(require("./FacemeshResponse"), exports);
93
91
  __exportStar(require("./ModelsSuccessLanguagePredictionsItem"), exports);
94
- __exportStar(require("./ProsodyResponse"), exports);
92
+ __exportStar(require("./LanguageResponse"), exports);
95
93
  __exportStar(require("./ModelsSuccessProsodyPredictionsItem"), exports);
94
+ __exportStar(require("./ProsodyResponse"), exports);
95
+ __exportStar(require("./ModelResponse"), exports);
96
96
  __exportStar(require("./ModelsError"), exports);
97
97
  __exportStar(require("./ModelsWarning"), exports);
98
- __exportStar(require("./EmotionEmbedding"), exports);
99
98
  __exportStar(require("./EmotionEmbeddingItem"), exports);
99
+ __exportStar(require("./EmotionEmbedding"), exports);
100
100
  __exportStar(require("./TimeRange"), exports);
101
101
  __exportStar(require("./TextPosition"), exports);
102
- __exportStar(require("./Sentiment"), exports);
103
102
  __exportStar(require("./SentimentItem"), exports);
104
- __exportStar(require("./Toxicity"), exports);
103
+ __exportStar(require("./Sentiment"), exports);
105
104
  __exportStar(require("./ToxicityItem"), exports);
105
+ __exportStar(require("./Toxicity"), exports);
@@ -2,6 +2,7 @@ export declare type APIResponse<Success, Failure> = SuccessfulResponse<Success>
2
2
  export interface SuccessfulResponse<T> {
3
3
  ok: true;
4
4
  body: T;
5
+ headers?: Record<string, any>;
5
6
  }
6
7
  export interface FailedResponse<T> {
7
8
  ok: false;
@@ -1,4 +1,3 @@
1
- import { AxiosAdapter } from "axios";
2
1
  import { APIResponse } from "./APIResponse";
3
2
  export declare type FetchFunction = <R = unknown>(args: Fetcher.Args) => Promise<APIResponse<R, Fetcher.Error>>;
4
3
  export declare namespace Fetcher {
@@ -12,9 +11,7 @@ export declare namespace Fetcher {
12
11
  timeoutMs?: number;
13
12
  maxRetries?: number;
14
13
  withCredentials?: boolean;
15
- responseType?: "json" | "blob";
16
- adapter?: AxiosAdapter;
17
- onUploadProgress?: (event: ProgressEvent) => void;
14
+ responseType?: "json" | "blob" | "streaming";
18
15
  }
19
16
  type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError;
20
17
  interface FailedStatusCodeError {
@@ -13,8 +13,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.fetcher = void 0;
16
- const axios_1 = __importDefault(require("axios"));
16
+ const form_data_1 = __importDefault(require("form-data"));
17
17
  const qs_1 = __importDefault(require("qs"));
18
+ if (typeof window === "undefined") {
19
+ global.fetch = require("node-fetch");
20
+ }
18
21
  const INITIAL_RETRY_DELAY = 1;
19
22
  const MAX_RETRY_DELAY = 60;
20
23
  const DEFAULT_MAX_RETRIES = 2;
@@ -32,60 +35,68 @@ function fetcherImpl(args) {
32
35
  }
33
36
  }
34
37
  }
38
+ const url = Object.keys((_a = args.queryParameters) !== null && _a !== void 0 ? _a : {}).length > 0
39
+ ? `${args.url}?${qs_1.default.stringify(args.queryParameters, { arrayFormat: "repeat" })}`
40
+ : args.url;
41
+ let body = undefined;
42
+ if (args.body instanceof form_data_1.default) {
43
+ // @ts-expect-error
44
+ body = args.body;
45
+ }
46
+ else {
47
+ body = JSON.stringify(args.body);
48
+ }
35
49
  const makeRequest = () => __awaiter(this, void 0, void 0, function* () {
36
- var _d;
37
- return yield (0, axios_1.default)({
38
- url: args.url,
39
- params: args.queryParameters,
40
- paramsSerializer: (params) => {
41
- return qs_1.default.stringify(params, { arrayFormat: "repeat" });
42
- },
50
+ const controller = new AbortController();
51
+ let abortId = undefined;
52
+ if (args.timeoutMs != null) {
53
+ abortId = setTimeout(() => controller.abort(), args.timeoutMs);
54
+ }
55
+ const response = yield fetch(url, {
43
56
  method: args.method,
44
57
  headers,
45
- data: args.body,
46
- validateStatus: () => true,
47
- transformResponse: (response) => response,
48
- timeout: args.timeoutMs,
49
- transitional: {
50
- clarifyTimeoutError: true,
51
- },
52
- withCredentials: args.withCredentials,
53
- adapter: args.adapter,
54
- onUploadProgress: args.onUploadProgress,
55
- maxBodyLength: Infinity,
56
- maxContentLength: Infinity,
57
- responseType: (_d = args.responseType) !== null && _d !== void 0 ? _d : "json",
58
+ body,
59
+ signal: controller.signal,
60
+ credentials: args.withCredentials ? "same-origin" : undefined,
58
61
  });
62
+ if (abortId != null) {
63
+ clearTimeout(abortId);
64
+ }
65
+ return response;
59
66
  });
60
67
  try {
61
68
  let response = yield makeRequest();
62
- for (let i = 0; i < ((_a = args.maxRetries) !== null && _a !== void 0 ? _a : DEFAULT_MAX_RETRIES); ++i) {
69
+ for (let i = 0; i < ((_b = args.maxRetries) !== null && _b !== void 0 ? _b : DEFAULT_MAX_RETRIES); ++i) {
63
70
  if (response.status === 408 ||
64
71
  response.status === 409 ||
65
72
  response.status === 429 ||
66
73
  response.status >= 500) {
67
74
  const delay = Math.min(INITIAL_RETRY_DELAY * Math.pow(i, 2), MAX_RETRY_DELAY);
68
- response = yield new Promise((resolve) => setTimeout(resolve, delay));
75
+ yield new Promise((resolve) => setTimeout(resolve, delay));
76
+ response = yield makeRequest();
69
77
  }
70
78
  else {
71
79
  break;
72
80
  }
73
81
  }
74
82
  let body;
75
- if (args.responseType === "blob") {
76
- body = response.data;
83
+ if (response.body != null && args.responseType === "blob") {
84
+ body = yield response.blob();
77
85
  }
78
- else if (response.data != null && response.data.length > 0) {
86
+ else if (response.body != null && args.responseType === "streaming") {
87
+ body = response.body;
88
+ }
89
+ else if (response.body != null) {
79
90
  try {
80
- body = (_b = JSON.parse(response.data)) !== null && _b !== void 0 ? _b : undefined;
91
+ body = yield response.json();
81
92
  }
82
- catch (_c) {
93
+ catch (err) {
83
94
  return {
84
95
  ok: false,
85
96
  error: {
86
97
  reason: "non-json",
87
98
  statusCode: response.status,
88
- rawBody: response.data,
99
+ rawBody: yield response.text(),
89
100
  },
90
101
  };
91
102
  }
@@ -94,6 +105,7 @@ function fetcherImpl(args) {
94
105
  return {
95
106
  ok: true,
96
107
  body: body,
108
+ headers: response.headers,
97
109
  };
98
110
  }
99
111
  else {
@@ -108,7 +120,7 @@ function fetcherImpl(args) {
108
120
  }
109
121
  }
110
122
  catch (error) {
111
- if (error.code === "ETIMEDOUT") {
123
+ if (error instanceof Error && error.name === "AbortError") {
112
124
  return {
113
125
  ok: false,
114
126
  error: {
@@ -116,11 +128,20 @@ function fetcherImpl(args) {
116
128
  },
117
129
  };
118
130
  }
131
+ else if (error instanceof Error) {
132
+ return {
133
+ ok: false,
134
+ error: {
135
+ reason: "unknown",
136
+ errorMessage: error.message,
137
+ },
138
+ };
139
+ }
119
140
  return {
120
141
  ok: false,
121
142
  error: {
122
143
  reason: "unknown",
123
- errorMessage: error.message,
144
+ errorMessage: JSON.stringify(error),
124
145
  },
125
146
  };
126
147
  }
@@ -0,0 +1 @@
1
+ export declare function getHeader(headers: Record<string, any>, header: string): string | undefined;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getHeader = void 0;
4
- function getHeader(response, header) {
5
- for (const [headerKey, headerValue] of Object.entries(response.headers)) {
4
+ function getHeader(headers, header) {
5
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
6
6
  if (headerKey.toLowerCase() === header.toLowerCase()) {
7
7
  return headerValue;
8
8
  }
@@ -1,4 +1,5 @@
1
1
  export type { APIResponse } from "./APIResponse";
2
2
  export { fetcher } from "./Fetcher";
3
3
  export type { Fetcher, FetchFunction } from "./Fetcher";
4
+ export { getHeader } from "./getHeader";
4
5
  export { Supplier } from "./Supplier";
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Supplier = exports.fetcher = void 0;
3
+ 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
+ var getHeader_1 = require("./getHeader");
7
+ Object.defineProperty(exports, "getHeader", { enumerable: true, get: function () { return getHeader_1.getHeader; } });
6
8
  var Supplier_1 = require("./Supplier");
7
9
  Object.defineProperty(exports, "Supplier", { enumerable: true, get: function () { return Supplier_1.Supplier; } });
package/core/index.d.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from "./fetcher";
2
- export * from "./streaming-fetcher";
3
2
  export * as serialization from "./schemas";
package/core/index.js CHANGED
@@ -28,5 +28,4 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.serialization = void 0;
30
30
  __exportStar(require("./fetcher"), exports);
31
- __exportStar(require("./streaming-fetcher"), exports);
32
31
  exports.serialization = __importStar(require("./schemas"));
package/dist/Client.d.ts CHANGED
@@ -21,6 +21,14 @@ export declare class HumeClient {
21
21
  constructor(_options: HumeClient.Options);
22
22
  /**
23
23
  * Sort and filter jobs.
24
+ *
25
+ * @example
26
+ * await hume.listJobs({
27
+ * status: Hume.Status.Queued,
28
+ * when: Hume.When.CreatedBefore,
29
+ * sortBy: Hume.SortBy.Created,
30
+ * direction: Hume.Direction.Asc
31
+ * })
24
32
  */
25
33
  listJobs(request?: Hume.ListJobsRequest, requestOptions?: HumeClient.RequestOptions): Promise<Hume.JobRequest[]>;
26
34
  /**
@@ -29,6 +37,9 @@ export declare class HumeClient {
29
37
  submitJob(request?: Hume.BaseRequest, requestOptions?: HumeClient.RequestOptions): Promise<Hume.JobId>;
30
38
  /**
31
39
  * Get the JSON predictions of a completed job.
40
+ *
41
+ * @example
42
+ * await hume.getJobPredictions("id")
32
43
  */
33
44
  getJobPredictions(id: string, requestOptions?: HumeClient.RequestOptions): Promise<Hume.SourceResult[]>;
34
45
  /**
package/dist/Client.js CHANGED
@@ -50,6 +50,14 @@ class HumeClient {
50
50
  }
51
51
  /**
52
52
  * Sort and filter jobs.
53
+ *
54
+ * @example
55
+ * await hume.listJobs({
56
+ * status: Hume.Status.Queued,
57
+ * when: Hume.When.CreatedBefore,
58
+ * sortBy: Hume.SortBy.Created,
59
+ * direction: Hume.Direction.Asc
60
+ * })
53
61
  */
54
62
  listJobs(request = {}, requestOptions) {
55
63
  var _a;
@@ -86,7 +94,7 @@ class HumeClient {
86
94
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
87
95
  "X-Fern-Language": "JavaScript",
88
96
  "X-Fern-SDK-Name": "hume",
89
- "X-Fern-SDK-Version": "0.2.7",
97
+ "X-Fern-SDK-Version": "0.3.0",
90
98
  },
91
99
  contentType: "application/json",
92
100
  queryParameters: _queryParams,
@@ -135,7 +143,7 @@ class HumeClient {
135
143
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
136
144
  "X-Fern-Language": "JavaScript",
137
145
  "X-Fern-SDK-Name": "hume",
138
- "X-Fern-SDK-Version": "0.2.7",
146
+ "X-Fern-SDK-Version": "0.3.0",
139
147
  },
140
148
  contentType: "application/json",
141
149
  body: yield serializers.BaseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -173,6 +181,9 @@ class HumeClient {
173
181
  }
174
182
  /**
175
183
  * Get the JSON predictions of a completed job.
184
+ *
185
+ * @example
186
+ * await hume.getJobPredictions("id")
176
187
  */
177
188
  getJobPredictions(id, requestOptions) {
178
189
  var _a;
@@ -184,7 +195,7 @@ class HumeClient {
184
195
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
185
196
  "X-Fern-Language": "JavaScript",
186
197
  "X-Fern-SDK-Name": "hume",
187
- "X-Fern-SDK-Version": "0.2.7",
198
+ "X-Fern-SDK-Version": "0.3.0",
188
199
  },
189
200
  contentType: "application/json",
190
201
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -225,18 +236,42 @@ class HumeClient {
225
236
  getJobArtifacts(id, requestOptions) {
226
237
  var _a;
227
238
  return __awaiter(this, void 0, void 0, function* () {
228
- const _response = yield core.streamingFetcher({
239
+ const _response = yield core.fetcher({
229
240
  url: (0, url_join_1.default)((_a = (yield core.Supplier.get(this._options.environment))) !== null && _a !== void 0 ? _a : environments.HumeEnvironment.Default, `v0/batch/jobs/${id}/artifacts`),
230
241
  method: "GET",
231
242
  headers: {
232
243
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
233
244
  "X-Fern-Language": "JavaScript",
234
245
  "X-Fern-SDK-Name": "hume",
235
- "X-Fern-SDK-Version": "0.2.7",
246
+ "X-Fern-SDK-Version": "0.3.0",
236
247
  },
248
+ contentType: "application/json",
249
+ responseType: "streaming",
237
250
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
251
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
238
252
  });
239
- return _response.data;
253
+ if (_response.ok) {
254
+ return _response.body;
255
+ }
256
+ if (_response.error.reason === "status-code") {
257
+ throw new errors.HumeError({
258
+ statusCode: _response.error.statusCode,
259
+ body: _response.error.body,
260
+ });
261
+ }
262
+ switch (_response.error.reason) {
263
+ case "non-json":
264
+ throw new errors.HumeError({
265
+ statusCode: _response.error.statusCode,
266
+ body: _response.error.rawBody,
267
+ });
268
+ case "timeout":
269
+ throw new errors.HumeTimeoutError();
270
+ case "unknown":
271
+ throw new errors.HumeError({
272
+ message: _response.error.errorMessage,
273
+ });
274
+ }
240
275
  });
241
276
  }
242
277
  /**
@@ -252,7 +287,7 @@ class HumeClient {
252
287
  "X-Hume-Api-Key": yield core.Supplier.get(this._options.apiKey),
253
288
  "X-Fern-Language": "JavaScript",
254
289
  "X-Fern-SDK-Name": "hume",
255
- "X-Fern-SDK-Version": "0.2.7",
290
+ "X-Fern-SDK-Version": "0.3.0",
256
291
  },
257
292
  contentType: "application/json",
258
293
  timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
@@ -2,6 +2,15 @@
2
2
  * This file was auto-generated by Fern from our API Definition.
3
3
  */
4
4
  import * as Hume from "../..";
5
+ /**
6
+ * @example
7
+ * {
8
+ * status: Hume.Status.Queued,
9
+ * when: Hume.When.CreatedBefore,
10
+ * sortBy: Hume.SortBy.Created,
11
+ * direction: Hume.Direction.Asc
12
+ * }
13
+ */
5
14
  export interface ListJobsRequest {
6
15
  /**
7
16
  * The maximum number of jobs to include in the response.
@@ -62,28 +62,28 @@ export * from "./TranscriptionMetadata";
62
62
  export * from "./Url";
63
63
  export * from "./When";
64
64
  export * from "./Window";
65
- export * from "./ModelsInput";
66
- export * from "./ModelConfig";
67
65
  export * from "./FaceModelConfig";
68
66
  export * from "./LanguageConfig";
69
- export * from "./ModelResponse";
70
- export * from "./BurstResponse";
67
+ export * from "./ModelConfig";
68
+ export * from "./ModelsInput";
71
69
  export * from "./ModelsSuccessBurstPredictionsItem";
72
- export * from "./FaceResponse";
70
+ export * from "./BurstResponse";
73
71
  export * from "./ModelsSuccessFacePredictionsItem";
74
- export * from "./FacemeshResponse";
72
+ export * from "./FaceResponse";
75
73
  export * from "./ModelsSuccessFacemeshPredictionsItem";
76
- export * from "./LanguageResponse";
74
+ export * from "./FacemeshResponse";
77
75
  export * from "./ModelsSuccessLanguagePredictionsItem";
78
- export * from "./ProsodyResponse";
76
+ export * from "./LanguageResponse";
79
77
  export * from "./ModelsSuccessProsodyPredictionsItem";
78
+ export * from "./ProsodyResponse";
79
+ export * from "./ModelResponse";
80
80
  export * from "./ModelsError";
81
81
  export * from "./ModelsWarning";
82
- export * from "./EmotionEmbedding";
83
82
  export * from "./EmotionEmbeddingItem";
83
+ export * from "./EmotionEmbedding";
84
84
  export * from "./TimeRange";
85
85
  export * from "./TextPosition";
86
- export * from "./Sentiment";
87
86
  export * from "./SentimentItem";
88
- export * from "./Toxicity";
87
+ export * from "./Sentiment";
89
88
  export * from "./ToxicityItem";
89
+ export * from "./Toxicity";