@cartesia/cartesia-js 2.1.9 → 2.2.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 (159) hide show
  1. package/Client.d.ts +3 -3
  2. package/Client.js +3 -3
  3. package/README.md +3 -3
  4. package/api/resources/apiStatus/client/Client.js +1 -1
  5. package/api/resources/auth/client/Client.d.ts +51 -0
  6. package/api/resources/auth/client/Client.js +126 -0
  7. package/api/resources/auth/client/index.d.ts +1 -0
  8. package/api/resources/auth/types/TokenGrant.d.ts +7 -0
  9. package/api/resources/auth/types/TokenRequest.d.ts +10 -0
  10. package/api/resources/auth/types/TokenResponse.d.ts +7 -0
  11. package/api/resources/auth/types/index.d.ts +3 -0
  12. package/{dist/api/resources/datasets/client → api/resources/auth/types}/index.js +3 -1
  13. package/api/resources/index.d.ts +2 -3
  14. package/api/resources/index.js +3 -4
  15. package/api/resources/infill/client/Client.d.ts +1 -1
  16. package/api/resources/infill/client/Client.js +2 -2
  17. package/api/resources/infill/client/requests/InfillBytesRequest.d.ts +2 -2
  18. package/api/resources/tts/types/Emotion.d.ts +6 -1
  19. package/api/resources/tts/types/Emotion.js +5 -0
  20. package/api/resources/tts/types/FlushId.d.ts +2 -2
  21. package/api/resources/tts/types/GenerationRequest.d.ts +3 -1
  22. package/api/resources/tts/types/TtsRequest.d.ts +1 -1
  23. package/api/resources/tts/types/WebSocketTtsRequest.d.ts +2 -1
  24. package/api/resources/voices/client/Client.js +8 -8
  25. package/core/websocket/ws.d.ts +1 -0
  26. package/core/websocket/ws.js +1 -1
  27. package/dist/Client.d.ts +3 -3
  28. package/dist/Client.js +3 -3
  29. package/dist/api/resources/apiStatus/client/Client.js +1 -1
  30. package/dist/api/resources/auth/client/Client.d.ts +51 -0
  31. package/dist/api/resources/auth/client/Client.js +126 -0
  32. package/dist/api/resources/auth/client/index.d.ts +1 -0
  33. package/dist/api/resources/auth/types/TokenGrant.d.ts +7 -0
  34. package/dist/api/resources/auth/types/TokenRequest.d.ts +10 -0
  35. package/dist/api/resources/auth/types/TokenResponse.d.ts +7 -0
  36. package/dist/api/resources/auth/types/index.d.ts +3 -0
  37. package/{api/resources/datasets/client → dist/api/resources/auth/types}/index.js +3 -1
  38. package/dist/api/resources/index.d.ts +2 -3
  39. package/dist/api/resources/index.js +3 -4
  40. package/dist/api/resources/infill/client/Client.d.ts +1 -1
  41. package/dist/api/resources/infill/client/Client.js +2 -2
  42. package/dist/api/resources/infill/client/requests/InfillBytesRequest.d.ts +2 -2
  43. package/dist/api/resources/tts/types/Emotion.d.ts +6 -1
  44. package/dist/api/resources/tts/types/Emotion.js +5 -0
  45. package/dist/api/resources/tts/types/FlushId.d.ts +2 -2
  46. package/dist/api/resources/tts/types/GenerationRequest.d.ts +3 -1
  47. package/dist/api/resources/tts/types/TtsRequest.d.ts +1 -1
  48. package/dist/api/resources/tts/types/WebSocketTtsRequest.d.ts +2 -1
  49. package/dist/api/resources/voices/client/Client.js +8 -8
  50. package/dist/core/websocket/ws.d.ts +1 -0
  51. package/dist/core/websocket/ws.js +1 -1
  52. package/dist/serialization/resources/{datasets/types/Dataset.d.ts → auth/types/TokenGrant.d.ts} +3 -5
  53. package/{serialization/resources/datasets/types/FilePurpose.js → dist/serialization/resources/auth/types/TokenGrant.js} +4 -2
  54. package/dist/serialization/resources/auth/types/TokenRequest.d.ts +14 -0
  55. package/dist/serialization/resources/{datasets/types/DatasetFile.js → auth/types/TokenRequest.js} +5 -5
  56. package/{serialization/resources/datasets/types/Dataset.d.ts → dist/serialization/resources/auth/types/TokenResponse.d.ts} +3 -5
  57. package/dist/serialization/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenResponse.js} +3 -3
  58. package/dist/serialization/resources/auth/types/index.d.ts +3 -0
  59. package/dist/serialization/resources/auth/types/index.js +19 -0
  60. package/dist/serialization/resources/index.d.ts +2 -2
  61. package/dist/serialization/resources/index.js +3 -3
  62. package/dist/serialization/resources/tts/types/Emotion.d.ts +1 -1
  63. package/dist/serialization/resources/tts/types/Emotion.js +5 -0
  64. package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +1 -0
  65. package/dist/serialization/resources/tts/types/GenerationRequest.js +1 -0
  66. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
  67. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +1 -0
  68. package/dist/version.d.ts +1 -1
  69. package/dist/version.js +1 -1
  70. package/dist/wrapper/Websocket.js +8 -2
  71. package/package.json +1 -1
  72. package/reference.md +15 -85
  73. package/{dist/serialization/resources/datasets/types/CreateDatasetRequest.d.ts → serialization/resources/auth/types/TokenGrant.d.ts} +3 -3
  74. package/{dist/serialization/resources/datasets/types/FilePurpose.js → serialization/resources/auth/types/TokenGrant.js} +4 -2
  75. package/serialization/resources/auth/types/TokenRequest.d.ts +14 -0
  76. package/{dist/serialization/resources/datasets/types/Dataset.js → serialization/resources/auth/types/TokenRequest.js} +5 -5
  77. package/serialization/resources/{datasets/types/CreateDatasetRequest.d.ts → auth/types/TokenResponse.d.ts} +3 -3
  78. package/serialization/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenResponse.js} +3 -3
  79. package/serialization/resources/auth/types/index.d.ts +3 -0
  80. package/serialization/resources/auth/types/index.js +19 -0
  81. package/serialization/resources/index.d.ts +2 -2
  82. package/serialization/resources/index.js +3 -3
  83. package/serialization/resources/tts/types/Emotion.d.ts +1 -1
  84. package/serialization/resources/tts/types/Emotion.js +5 -0
  85. package/serialization/resources/tts/types/GenerationRequest.d.ts +1 -0
  86. package/serialization/resources/tts/types/GenerationRequest.js +1 -0
  87. package/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
  88. package/serialization/resources/tts/types/WebSocketTtsRequest.js +1 -0
  89. package/version.d.ts +1 -1
  90. package/version.js +1 -1
  91. package/wrapper/Websocket.js +8 -2
  92. package/api/resources/datasets/client/Client.d.ts +0 -70
  93. package/api/resources/datasets/client/Client.js +0 -268
  94. package/api/resources/datasets/client/index.d.ts +0 -1
  95. package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -7
  96. package/api/resources/datasets/client/requests/index.d.ts +0 -1
  97. package/api/resources/datasets/types/CreateDatasetRequest.d.ts +0 -6
  98. package/api/resources/datasets/types/Dataset.d.ts +0 -8
  99. package/api/resources/datasets/types/DatasetFile.d.ts +0 -8
  100. package/api/resources/datasets/types/FilePurpose.d.ts +0 -7
  101. package/api/resources/datasets/types/FilePurpose.js +0 -9
  102. package/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -8
  103. package/api/resources/datasets/types/PaginatedDatasets.d.ts +0 -8
  104. package/api/resources/datasets/types/index.d.ts +0 -6
  105. package/api/resources/datasets/types/index.js +0 -22
  106. package/dist/api/resources/datasets/client/Client.d.ts +0 -70
  107. package/dist/api/resources/datasets/client/Client.js +0 -268
  108. package/dist/api/resources/datasets/client/index.d.ts +0 -1
  109. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -7
  110. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +0 -5
  111. package/dist/api/resources/datasets/client/requests/index.d.ts +0 -1
  112. package/dist/api/resources/datasets/types/CreateDatasetRequest.d.ts +0 -6
  113. package/dist/api/resources/datasets/types/CreateDatasetRequest.js +0 -5
  114. package/dist/api/resources/datasets/types/Dataset.d.ts +0 -8
  115. package/dist/api/resources/datasets/types/Dataset.js +0 -5
  116. package/dist/api/resources/datasets/types/DatasetFile.d.ts +0 -8
  117. package/dist/api/resources/datasets/types/DatasetFile.js +0 -5
  118. package/dist/api/resources/datasets/types/FilePurpose.d.ts +0 -7
  119. package/dist/api/resources/datasets/types/FilePurpose.js +0 -9
  120. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -8
  121. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.js +0 -5
  122. package/dist/api/resources/datasets/types/PaginatedDatasets.d.ts +0 -8
  123. package/dist/api/resources/datasets/types/PaginatedDatasets.js +0 -5
  124. package/dist/api/resources/datasets/types/index.d.ts +0 -6
  125. package/dist/api/resources/datasets/types/index.js +0 -22
  126. package/dist/serialization/resources/datasets/types/DatasetFile.d.ts +0 -14
  127. package/dist/serialization/resources/datasets/types/FilePurpose.d.ts +0 -10
  128. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -14
  129. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +0 -45
  130. package/dist/serialization/resources/datasets/types/PaginatedDatasets.d.ts +0 -14
  131. package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +0 -45
  132. package/dist/serialization/resources/datasets/types/index.d.ts +0 -6
  133. package/dist/serialization/resources/datasets/types/index.js +0 -22
  134. package/serialization/resources/datasets/types/Dataset.js +0 -45
  135. package/serialization/resources/datasets/types/DatasetFile.d.ts +0 -14
  136. package/serialization/resources/datasets/types/DatasetFile.js +0 -45
  137. package/serialization/resources/datasets/types/FilePurpose.d.ts +0 -10
  138. package/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -14
  139. package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +0 -45
  140. package/serialization/resources/datasets/types/PaginatedDatasets.d.ts +0 -14
  141. package/serialization/resources/datasets/types/PaginatedDatasets.js +0 -45
  142. package/serialization/resources/datasets/types/index.d.ts +0 -6
  143. package/serialization/resources/datasets/types/index.js +0 -22
  144. /package/api/resources/{datasets/client/requests → auth/client}/index.js +0 -0
  145. /package/api/resources/{datasets → auth}/index.d.ts +0 -0
  146. /package/api/resources/{datasets → auth}/index.js +0 -0
  147. /package/api/resources/{datasets/client/requests/UploadDatasetFileRequest.js → auth/types/TokenGrant.js} +0 -0
  148. /package/api/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenRequest.js} +0 -0
  149. /package/api/resources/{datasets/types/Dataset.js → auth/types/TokenResponse.js} +0 -0
  150. /package/dist/api/resources/{datasets/client/requests → auth/client}/index.js +0 -0
  151. /package/dist/api/resources/{datasets → auth}/index.d.ts +0 -0
  152. /package/dist/api/resources/{datasets → auth}/index.js +0 -0
  153. /package/{api/resources/datasets/types/DatasetFile.js → dist/api/resources/auth/types/TokenGrant.js} +0 -0
  154. /package/{api/resources/datasets/types/PaginatedDatasetFiles.js → dist/api/resources/auth/types/TokenRequest.js} +0 -0
  155. /package/{api/resources/datasets/types/PaginatedDatasets.js → dist/api/resources/auth/types/TokenResponse.js} +0 -0
  156. /package/dist/serialization/resources/{datasets → auth}/index.d.ts +0 -0
  157. /package/dist/serialization/resources/{datasets → auth}/index.js +0 -0
  158. /package/serialization/resources/{datasets → auth}/index.d.ts +0 -0
  159. /package/serialization/resources/{datasets → auth}/index.js +0 -0
@@ -17,6 +17,7 @@ export declare namespace WebSocketTtsRequest {
17
17
  language?: string | null;
18
18
  add_timestamps?: boolean | null;
19
19
  add_phoneme_timestamps?: boolean | null;
20
+ use_original_timestamps?: boolean | null;
20
21
  continue?: boolean | null;
21
22
  context_id?: string | null;
22
23
  }
@@ -49,6 +49,7 @@ exports.WebSocketTtsRequest = core.serialization.object({
49
49
  language: core.serialization.string().optional(),
50
50
  addTimestamps: core.serialization.property("add_timestamps", core.serialization.boolean().optional()),
51
51
  addPhonemeTimestamps: core.serialization.property("add_phoneme_timestamps", core.serialization.boolean().optional()),
52
+ useOriginalTimestamps: core.serialization.property("use_original_timestamps", core.serialization.boolean().optional()),
52
53
  continue: core.serialization.boolean().optional(),
53
54
  contextId: core.serialization.property("context_id", core.serialization.string().optional()),
54
55
  });
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.1.9";
1
+ export declare const SDK_VERSION = "2.2.0";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "2.1.9";
4
+ exports.SDK_VERSION = "2.2.0";
@@ -181,9 +181,15 @@ class Websocket {
181
181
  var _a;
182
182
  const baseUrl = ((_a = (yield core.Supplier.get(this.options.environment))) !== null && _a !== void 0 ? _a : environments.CartesiaEnvironment.Production).replace(/^https?:\/\//, "");
183
183
  const params = {
184
- api_key: yield core.Supplier.get(this.options.apiKey),
185
- cartesia_version: this.options.cartesiaVersion,
184
+ cartesia_version: this.options.cartesiaVersion || "2024-06-10",
186
185
  };
186
+ const apiKey = yield core.Supplier.get(this.options.apiKey);
187
+ if (apiKey) {
188
+ params.api_key = apiKey;
189
+ }
190
+ else if (options.accessToken) {
191
+ params.access_token = options.accessToken;
192
+ }
187
193
  return `wss://${baseUrl}/tts/websocket${qs_1.default.stringify(params, { addQueryPrefix: true })}`;
188
194
  }), undefined, options);
189
195
  this.socket.reconnect();
@@ -1,70 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as environments from "../../../../environments";
5
- import * as core from "../../../../core";
6
- import * as Cartesia from "../../../index";
7
- import * as fs from "fs";
8
- import { Blob } from "buffer";
9
- export declare namespace Datasets {
10
- interface Options {
11
- environment?: core.Supplier<environments.CartesiaEnvironment | string>;
12
- /** Specify a custom URL to connect the client to. */
13
- baseUrl?: core.Supplier<string>;
14
- apiKey?: core.Supplier<string | undefined>;
15
- /** Override the Cartesia-Version header */
16
- cartesiaVersion?: "2024-06-10";
17
- fetcher?: core.FetchFunction;
18
- }
19
- interface RequestOptions {
20
- /** The maximum time to wait for a response in seconds. */
21
- timeoutInSeconds?: number;
22
- /** The number of times to retry the request. Defaults to 2. */
23
- maxRetries?: number;
24
- /** A hook to abort the request. */
25
- abortSignal?: AbortSignal;
26
- /** Override the Cartesia-Version header */
27
- cartesiaVersion?: "2024-06-10";
28
- /** Additional headers to include in the request. */
29
- headers?: Record<string, string>;
30
- }
31
- }
32
- export declare class Datasets {
33
- protected readonly _options: Datasets.Options;
34
- constructor(_options?: Datasets.Options);
35
- /**
36
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
37
- *
38
- * @example
39
- * await client.datasets.list()
40
- */
41
- list(requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasets>;
42
- /**
43
- * @param {Cartesia.CreateDatasetRequest} request
44
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
45
- *
46
- * @example
47
- * await client.datasets.create({
48
- * name: "name"
49
- * })
50
- */
51
- create(request: Cartesia.CreateDatasetRequest, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.Dataset>;
52
- /**
53
- * @param {string} id
54
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
55
- *
56
- * @example
57
- * await client.datasets.listFiles("id")
58
- */
59
- listFiles(id: string, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasetFiles>;
60
- /**
61
- * @param {File | fs.ReadStream | Blob} file
62
- * @param {string} id
63
- * @param {Cartesia.UploadDatasetFileRequest} request
64
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
65
- */
66
- uploadFile(file: File | fs.ReadStream | Blob, id: string, request: Cartesia.UploadDatasetFileRequest, requestOptions?: Datasets.RequestOptions): Promise<void>;
67
- protected _getCustomAuthorizationHeaders(): Promise<{
68
- "X-API-Key": string | undefined;
69
- }>;
70
- }
@@ -1,268 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
17
- Object.defineProperty(o, "default", { enumerable: true, value: v });
18
- }) : function(o, v) {
19
- o["default"] = v;
20
- });
21
- var __importStar = (this && this.__importStar) || (function () {
22
- var ownKeys = function(o) {
23
- ownKeys = Object.getOwnPropertyNames || function (o) {
24
- var ar = [];
25
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
26
- return ar;
27
- };
28
- return ownKeys(o);
29
- };
30
- return function (mod) {
31
- if (mod && mod.__esModule) return mod;
32
- var result = {};
33
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
34
- __setModuleDefault(result, mod);
35
- return result;
36
- };
37
- })();
38
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
39
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
- return new (P || (P = Promise))(function (resolve, reject) {
41
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
- step((generator = generator.apply(thisArg, _arguments || [])).next());
45
- });
46
- };
47
- var __importDefault = (this && this.__importDefault) || function (mod) {
48
- return (mod && mod.__esModule) ? mod : { "default": mod };
49
- };
50
- Object.defineProperty(exports, "__esModule", { value: true });
51
- exports.Datasets = void 0;
52
- const environments = __importStar(require("../../../../environments"));
53
- const core = __importStar(require("../../../../core"));
54
- const url_join_1 = __importDefault(require("url-join"));
55
- const serializers = __importStar(require("../../../../serialization/index"));
56
- const errors = __importStar(require("../../../../errors/index"));
57
- class Datasets {
58
- constructor(_options = {}) {
59
- this._options = _options;
60
- }
61
- /**
62
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
63
- *
64
- * @example
65
- * await client.datasets.list()
66
- */
67
- list(requestOptions) {
68
- return __awaiter(this, void 0, void 0, function* () {
69
- var _a, _b, _c, _d, _e, _f;
70
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
71
- 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.CartesiaEnvironment.Production, "/datasets/"),
72
- method: "GET",
73
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.9", "User-Agent": "@cartesia/cartesia-js/2.1.9", "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),
74
- contentType: "application/json",
75
- requestType: "json",
76
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
77
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
78
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
79
- });
80
- if (_response.ok) {
81
- return serializers.PaginatedDatasets.parseOrThrow(_response.body, {
82
- unrecognizedObjectKeys: "passthrough",
83
- allowUnrecognizedUnionMembers: true,
84
- allowUnrecognizedEnumValues: true,
85
- skipValidation: true,
86
- breadcrumbsPrefix: ["response"],
87
- });
88
- }
89
- if (_response.error.reason === "status-code") {
90
- throw new errors.CartesiaError({
91
- statusCode: _response.error.statusCode,
92
- body: _response.error.body,
93
- });
94
- }
95
- switch (_response.error.reason) {
96
- case "non-json":
97
- throw new errors.CartesiaError({
98
- statusCode: _response.error.statusCode,
99
- body: _response.error.rawBody,
100
- });
101
- case "timeout":
102
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling GET /datasets/.");
103
- case "unknown":
104
- throw new errors.CartesiaError({
105
- message: _response.error.errorMessage,
106
- });
107
- }
108
- });
109
- }
110
- /**
111
- * @param {Cartesia.CreateDatasetRequest} request
112
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
113
- *
114
- * @example
115
- * await client.datasets.create({
116
- * name: "name"
117
- * })
118
- */
119
- create(request, requestOptions) {
120
- return __awaiter(this, void 0, void 0, function* () {
121
- var _a, _b, _c, _d, _e, _f;
122
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
123
- 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.CartesiaEnvironment.Production, "/datasets/"),
124
- method: "POST",
125
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.9", "User-Agent": "@cartesia/cartesia-js/2.1.9", "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),
126
- contentType: "application/json",
127
- requestType: "json",
128
- body: serializers.CreateDatasetRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
129
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
130
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
131
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
132
- });
133
- if (_response.ok) {
134
- return serializers.Dataset.parseOrThrow(_response.body, {
135
- unrecognizedObjectKeys: "passthrough",
136
- allowUnrecognizedUnionMembers: true,
137
- allowUnrecognizedEnumValues: true,
138
- skipValidation: true,
139
- breadcrumbsPrefix: ["response"],
140
- });
141
- }
142
- if (_response.error.reason === "status-code") {
143
- throw new errors.CartesiaError({
144
- statusCode: _response.error.statusCode,
145
- body: _response.error.body,
146
- });
147
- }
148
- switch (_response.error.reason) {
149
- case "non-json":
150
- throw new errors.CartesiaError({
151
- statusCode: _response.error.statusCode,
152
- body: _response.error.rawBody,
153
- });
154
- case "timeout":
155
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /datasets/.");
156
- case "unknown":
157
- throw new errors.CartesiaError({
158
- message: _response.error.errorMessage,
159
- });
160
- }
161
- });
162
- }
163
- /**
164
- * @param {string} id
165
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
166
- *
167
- * @example
168
- * await client.datasets.listFiles("id")
169
- */
170
- listFiles(id, requestOptions) {
171
- return __awaiter(this, void 0, void 0, function* () {
172
- var _a, _b, _c, _d, _e, _f;
173
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
174
- 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.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
175
- method: "GET",
176
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.9", "User-Agent": "@cartesia/cartesia-js/2.1.9", "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
- contentType: "application/json",
178
- requestType: "json",
179
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
180
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
181
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
182
- });
183
- if (_response.ok) {
184
- return serializers.PaginatedDatasetFiles.parseOrThrow(_response.body, {
185
- unrecognizedObjectKeys: "passthrough",
186
- allowUnrecognizedUnionMembers: true,
187
- allowUnrecognizedEnumValues: true,
188
- skipValidation: true,
189
- breadcrumbsPrefix: ["response"],
190
- });
191
- }
192
- if (_response.error.reason === "status-code") {
193
- throw new errors.CartesiaError({
194
- statusCode: _response.error.statusCode,
195
- body: _response.error.body,
196
- });
197
- }
198
- switch (_response.error.reason) {
199
- case "non-json":
200
- throw new errors.CartesiaError({
201
- statusCode: _response.error.statusCode,
202
- body: _response.error.rawBody,
203
- });
204
- case "timeout":
205
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling GET /datasets/{id}/files.");
206
- case "unknown":
207
- throw new errors.CartesiaError({
208
- message: _response.error.errorMessage,
209
- });
210
- }
211
- });
212
- }
213
- /**
214
- * @param {File | fs.ReadStream | Blob} file
215
- * @param {string} id
216
- * @param {Cartesia.UploadDatasetFileRequest} request
217
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
218
- */
219
- uploadFile(file, id, request, requestOptions) {
220
- return __awaiter(this, void 0, void 0, function* () {
221
- var _a, _b, _c, _d, _e, _f;
222
- const _request = yield core.newFormData();
223
- yield _request.appendFile("file", file);
224
- _request.append("purpose", serializers.FilePurpose.jsonOrThrow(request.purpose, { unrecognizedObjectKeys: "strip" }));
225
- const _maybeEncodedRequest = yield _request.getRequest();
226
- const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
227
- 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.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
228
- method: "POST",
229
- headers: Object.assign(Object.assign(Object.assign({ "Cartesia-Version": (_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.cartesiaVersion) !== null && _f !== void 0 ? _f : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.1.9", "User-Agent": "@cartesia/cartesia-js/2.1.9", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
230
- requestType: "file",
231
- duplex: _maybeEncodedRequest.duplex,
232
- body: _maybeEncodedRequest.body,
233
- timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
234
- maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
235
- abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
236
- });
237
- if (_response.ok) {
238
- return;
239
- }
240
- if (_response.error.reason === "status-code") {
241
- throw new errors.CartesiaError({
242
- statusCode: _response.error.statusCode,
243
- body: _response.error.body,
244
- });
245
- }
246
- switch (_response.error.reason) {
247
- case "non-json":
248
- throw new errors.CartesiaError({
249
- statusCode: _response.error.statusCode,
250
- body: _response.error.rawBody,
251
- });
252
- case "timeout":
253
- throw new errors.CartesiaTimeoutError("Timeout exceeded when calling POST /datasets/{id}/files.");
254
- case "unknown":
255
- throw new errors.CartesiaError({
256
- message: _response.error.errorMessage,
257
- });
258
- }
259
- });
260
- }
261
- _getCustomAuthorizationHeaders() {
262
- return __awaiter(this, void 0, void 0, function* () {
263
- const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
264
- return { "X-API-Key": apiKeyValue };
265
- });
266
- }
267
- }
268
- exports.Datasets = Datasets;
@@ -1 +0,0 @@
1
- export * from "./requests";
@@ -1,7 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Cartesia from "../../../../index";
5
- export interface UploadDatasetFileRequest {
6
- purpose: Cartesia.FilePurpose;
7
- }
@@ -1 +0,0 @@
1
- export { type UploadDatasetFileRequest } from "./UploadDatasetFileRequest";
@@ -1,6 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface CreateDatasetRequest {
5
- name: string;
6
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface Dataset {
5
- id: string;
6
- name: string;
7
- createdAt: string;
8
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export interface DatasetFile {
5
- id: string;
6
- filename: string;
7
- createdAt: string;
8
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- export type FilePurpose = "fine_tune";
5
- export declare const FilePurpose: {
6
- readonly FineTune: "fine_tune";
7
- };
@@ -1,9 +0,0 @@
1
- "use strict";
2
- /**
3
- * This file was auto-generated by Fern from our API Definition.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FilePurpose = void 0;
7
- exports.FilePurpose = {
8
- FineTune: "fine_tune",
9
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Cartesia from "../../../index";
5
- export interface PaginatedDatasetFiles {
6
- data: Cartesia.DatasetFile[];
7
- hasMore: boolean;
8
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as Cartesia from "../../../index";
5
- export interface PaginatedDatasets {
6
- data: Cartesia.Dataset[];
7
- hasMore: boolean;
8
- }
@@ -1,6 +0,0 @@
1
- export * from "./Dataset";
2
- export * from "./CreateDatasetRequest";
3
- export * from "./DatasetFile";
4
- export * from "./FilePurpose";
5
- export * from "./PaginatedDatasets";
6
- export * from "./PaginatedDatasetFiles";
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./Dataset"), exports);
18
- __exportStar(require("./CreateDatasetRequest"), exports);
19
- __exportStar(require("./DatasetFile"), exports);
20
- __exportStar(require("./FilePurpose"), exports);
21
- __exportStar(require("./PaginatedDatasets"), exports);
22
- __exportStar(require("./PaginatedDatasetFiles"), exports);
@@ -1,70 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as environments from "../../../../environments";
5
- import * as core from "../../../../core";
6
- import * as Cartesia from "../../../index";
7
- import * as fs from "fs";
8
- import { Blob } from "buffer";
9
- export declare namespace Datasets {
10
- interface Options {
11
- environment?: core.Supplier<environments.CartesiaEnvironment | string>;
12
- /** Specify a custom URL to connect the client to. */
13
- baseUrl?: core.Supplier<string>;
14
- apiKey?: core.Supplier<string | undefined>;
15
- /** Override the Cartesia-Version header */
16
- cartesiaVersion?: "2024-06-10";
17
- fetcher?: core.FetchFunction;
18
- }
19
- interface RequestOptions {
20
- /** The maximum time to wait for a response in seconds. */
21
- timeoutInSeconds?: number;
22
- /** The number of times to retry the request. Defaults to 2. */
23
- maxRetries?: number;
24
- /** A hook to abort the request. */
25
- abortSignal?: AbortSignal;
26
- /** Override the Cartesia-Version header */
27
- cartesiaVersion?: "2024-06-10";
28
- /** Additional headers to include in the request. */
29
- headers?: Record<string, string>;
30
- }
31
- }
32
- export declare class Datasets {
33
- protected readonly _options: Datasets.Options;
34
- constructor(_options?: Datasets.Options);
35
- /**
36
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
37
- *
38
- * @example
39
- * await client.datasets.list()
40
- */
41
- list(requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasets>;
42
- /**
43
- * @param {Cartesia.CreateDatasetRequest} request
44
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
45
- *
46
- * @example
47
- * await client.datasets.create({
48
- * name: "name"
49
- * })
50
- */
51
- create(request: Cartesia.CreateDatasetRequest, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.Dataset>;
52
- /**
53
- * @param {string} id
54
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
55
- *
56
- * @example
57
- * await client.datasets.listFiles("id")
58
- */
59
- listFiles(id: string, requestOptions?: Datasets.RequestOptions): Promise<Cartesia.PaginatedDatasetFiles>;
60
- /**
61
- * @param {File | fs.ReadStream | Blob} file
62
- * @param {string} id
63
- * @param {Cartesia.UploadDatasetFileRequest} request
64
- * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
65
- */
66
- uploadFile(file: File | fs.ReadStream | Blob, id: string, request: Cartesia.UploadDatasetFileRequest, requestOptions?: Datasets.RequestOptions): Promise<void>;
67
- protected _getCustomAuthorizationHeaders(): Promise<{
68
- "X-API-Key": string | undefined;
69
- }>;
70
- }