@cartesia/cartesia-js 2.0.3 → 2.0.4-alpha0

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 (134) hide show
  1. package/Client.d.ts +3 -0
  2. package/Client.js +11 -6
  3. package/api/resources/apiStatus/client/Client.js +1 -1
  4. package/api/resources/datasets/client/Client.d.ts +70 -0
  5. package/api/resources/datasets/client/Client.js +261 -0
  6. package/api/resources/datasets/client/index.d.ts +1 -0
  7. package/api/resources/datasets/client/index.js +17 -0
  8. package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
  9. package/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
  10. package/api/resources/datasets/client/requests/index.d.ts +1 -0
  11. package/api/resources/datasets/client/requests/index.js +2 -0
  12. package/api/resources/datasets/index.d.ts +2 -0
  13. package/api/resources/datasets/index.js +18 -0
  14. package/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
  15. package/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
  16. package/api/resources/datasets/types/Dataset.d.ts +8 -0
  17. package/api/resources/datasets/types/Dataset.js +5 -0
  18. package/api/resources/datasets/types/DatasetFile.d.ts +8 -0
  19. package/api/resources/datasets/types/DatasetFile.js +5 -0
  20. package/api/resources/datasets/types/FilePurpose.d.ts +7 -0
  21. package/api/resources/datasets/types/FilePurpose.js +9 -0
  22. package/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
  23. package/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
  24. package/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
  25. package/api/resources/datasets/types/PaginatedDatasets.js +5 -0
  26. package/api/resources/datasets/types/index.d.ts +6 -0
  27. package/api/resources/datasets/types/index.js +22 -0
  28. package/api/resources/index.d.ts +3 -0
  29. package/api/resources/index.js +4 -1
  30. package/api/resources/tts/client/Client.js +2 -2
  31. package/api/resources/voiceChanger/client/Client.js +2 -2
  32. package/api/resources/voices/client/Client.js +8 -8
  33. package/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
  34. package/api/resources/voices/types/LocalizeDialect.js +0 -8
  35. package/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
  36. package/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
  37. package/api/resources/voices/types/index.d.ts +1 -0
  38. package/api/resources/voices/types/index.js +1 -0
  39. package/core/index.d.ts +1 -1
  40. package/core/index.js +1 -1
  41. package/dist/Client.d.ts +3 -0
  42. package/dist/Client.js +11 -6
  43. package/dist/api/resources/apiStatus/client/Client.js +1 -1
  44. package/dist/api/resources/datasets/client/Client.d.ts +70 -0
  45. package/dist/api/resources/datasets/client/Client.js +261 -0
  46. package/dist/api/resources/datasets/client/index.d.ts +1 -0
  47. package/dist/api/resources/datasets/client/index.js +17 -0
  48. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +11 -0
  49. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +5 -0
  50. package/dist/api/resources/datasets/client/requests/index.d.ts +1 -0
  51. package/dist/api/resources/datasets/client/requests/index.js +2 -0
  52. package/dist/api/resources/datasets/index.d.ts +2 -0
  53. package/dist/api/resources/datasets/index.js +18 -0
  54. package/dist/api/resources/datasets/types/CreateDatasetRequest.d.ts +6 -0
  55. package/dist/api/resources/datasets/types/CreateDatasetRequest.js +5 -0
  56. package/dist/api/resources/datasets/types/Dataset.d.ts +8 -0
  57. package/dist/api/resources/datasets/types/Dataset.js +5 -0
  58. package/dist/api/resources/datasets/types/DatasetFile.d.ts +8 -0
  59. package/dist/api/resources/datasets/types/DatasetFile.js +5 -0
  60. package/dist/api/resources/datasets/types/FilePurpose.d.ts +7 -0
  61. package/dist/api/resources/datasets/types/FilePurpose.js +9 -0
  62. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +8 -0
  63. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.js +5 -0
  64. package/dist/api/resources/datasets/types/PaginatedDatasets.d.ts +8 -0
  65. package/dist/api/resources/datasets/types/PaginatedDatasets.js +5 -0
  66. package/dist/api/resources/datasets/types/index.d.ts +6 -0
  67. package/dist/api/resources/datasets/types/index.js +22 -0
  68. package/dist/api/resources/index.d.ts +3 -0
  69. package/dist/api/resources/index.js +4 -1
  70. package/dist/api/resources/tts/client/Client.js +2 -2
  71. package/dist/api/resources/voiceChanger/client/Client.js +2 -2
  72. package/dist/api/resources/voices/client/Client.js +8 -8
  73. package/dist/api/resources/voices/types/LocalizeDialect.d.ts +11 -11
  74. package/dist/api/resources/voices/types/LocalizeDialect.js +0 -8
  75. package/dist/api/resources/voices/types/LocalizeEnglishDialect.d.ts +11 -0
  76. package/dist/api/resources/voices/types/LocalizeEnglishDialect.js +13 -0
  77. package/dist/api/resources/voices/types/index.d.ts +1 -0
  78. package/dist/api/resources/voices/types/index.js +1 -0
  79. package/dist/core/index.d.ts +1 -1
  80. package/dist/core/index.js +1 -1
  81. package/dist/serialization/resources/datasets/index.d.ts +1 -0
  82. package/dist/serialization/resources/datasets/index.js +17 -0
  83. package/dist/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
  84. package/dist/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
  85. package/dist/serialization/resources/datasets/types/Dataset.d.ts +14 -0
  86. package/dist/serialization/resources/datasets/types/Dataset.js +35 -0
  87. package/dist/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
  88. package/dist/serialization/resources/datasets/types/DatasetFile.js +35 -0
  89. package/dist/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
  90. package/dist/serialization/resources/datasets/types/FilePurpose.js +31 -0
  91. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
  92. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
  93. package/dist/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
  94. package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
  95. package/dist/serialization/resources/datasets/types/index.d.ts +6 -0
  96. package/dist/serialization/resources/datasets/types/index.js +22 -0
  97. package/dist/serialization/resources/index.d.ts +2 -0
  98. package/dist/serialization/resources/index.js +3 -1
  99. package/dist/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
  100. package/dist/serialization/resources/voices/types/LocalizeDialect.js +2 -1
  101. package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
  102. package/dist/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
  103. package/dist/serialization/resources/voices/types/index.d.ts +1 -0
  104. package/dist/serialization/resources/voices/types/index.js +1 -0
  105. package/dist/version.d.ts +1 -1
  106. package/dist/version.js +1 -1
  107. package/package.json +1 -1
  108. package/reference.md +204 -0
  109. package/serialization/resources/datasets/index.d.ts +1 -0
  110. package/serialization/resources/datasets/index.js +17 -0
  111. package/serialization/resources/datasets/types/CreateDatasetRequest.d.ts +12 -0
  112. package/serialization/resources/datasets/types/CreateDatasetRequest.js +33 -0
  113. package/serialization/resources/datasets/types/Dataset.d.ts +14 -0
  114. package/serialization/resources/datasets/types/Dataset.js +35 -0
  115. package/serialization/resources/datasets/types/DatasetFile.d.ts +14 -0
  116. package/serialization/resources/datasets/types/DatasetFile.js +35 -0
  117. package/serialization/resources/datasets/types/FilePurpose.d.ts +10 -0
  118. package/serialization/resources/datasets/types/FilePurpose.js +31 -0
  119. package/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +14 -0
  120. package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +35 -0
  121. package/serialization/resources/datasets/types/PaginatedDatasets.d.ts +14 -0
  122. package/serialization/resources/datasets/types/PaginatedDatasets.js +35 -0
  123. package/serialization/resources/datasets/types/index.d.ts +6 -0
  124. package/serialization/resources/datasets/types/index.js +22 -0
  125. package/serialization/resources/index.d.ts +2 -0
  126. package/serialization/resources/index.js +3 -1
  127. package/serialization/resources/voices/types/LocalizeDialect.d.ts +2 -1
  128. package/serialization/resources/voices/types/LocalizeDialect.js +2 -1
  129. package/serialization/resources/voices/types/LocalizeEnglishDialect.d.ts +10 -0
  130. package/serialization/resources/voices/types/LocalizeEnglishDialect.js +31 -0
  131. package/serialization/resources/voices/types/index.d.ts +1 -0
  132. package/serialization/resources/voices/types/index.js +1 -0
  133. package/version.d.ts +1 -1
  134. package/version.js +1 -1
@@ -0,0 +1,261 @@
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 (mod) {
22
+ if (mod && mod.__esModule) return mod;
23
+ var result = {};
24
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
25
+ __setModuleDefault(result, mod);
26
+ return result;
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __importDefault = (this && this.__importDefault) || function (mod) {
38
+ return (mod && mod.__esModule) ? mod : { "default": mod };
39
+ };
40
+ Object.defineProperty(exports, "__esModule", { value: true });
41
+ exports.Datasets = void 0;
42
+ const environments = __importStar(require("../../../../environments"));
43
+ const core = __importStar(require("../../../../core"));
44
+ const url_join_1 = __importDefault(require("url-join"));
45
+ const serializers = __importStar(require("../../../../serialization/index"));
46
+ const errors = __importStar(require("../../../../errors/index"));
47
+ class Datasets {
48
+ constructor(_options = {}) {
49
+ this._options = _options;
50
+ }
51
+ /**
52
+ * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
53
+ *
54
+ * @example
55
+ * await client.datasets.list()
56
+ */
57
+ list(requestOptions) {
58
+ var _a, _b, _c, _d, _e;
59
+ return __awaiter(this, void 0, void 0, function* () {
60
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
61
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/datasets/"),
62
+ method: "GET",
63
+ headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
64
+ contentType: "application/json",
65
+ requestType: "json",
66
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
67
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
68
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
69
+ });
70
+ if (_response.ok) {
71
+ return serializers.PaginatedDatasets.parseOrThrow(_response.body, {
72
+ unrecognizedObjectKeys: "passthrough",
73
+ allowUnrecognizedUnionMembers: true,
74
+ allowUnrecognizedEnumValues: true,
75
+ skipValidation: true,
76
+ breadcrumbsPrefix: ["response"],
77
+ });
78
+ }
79
+ if (_response.error.reason === "status-code") {
80
+ throw new errors.CartesiaError({
81
+ statusCode: _response.error.statusCode,
82
+ body: _response.error.body,
83
+ });
84
+ }
85
+ switch (_response.error.reason) {
86
+ case "non-json":
87
+ throw new errors.CartesiaError({
88
+ statusCode: _response.error.statusCode,
89
+ body: _response.error.rawBody,
90
+ });
91
+ case "timeout":
92
+ throw new errors.CartesiaTimeoutError();
93
+ case "unknown":
94
+ throw new errors.CartesiaError({
95
+ message: _response.error.errorMessage,
96
+ });
97
+ }
98
+ });
99
+ }
100
+ /**
101
+ * @param {Cartesia.CreateDatasetRequest} request
102
+ * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
103
+ *
104
+ * @example
105
+ * await client.datasets.create({
106
+ * name: "string"
107
+ * })
108
+ */
109
+ create(request, requestOptions) {
110
+ var _a, _b, _c, _d, _e;
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
113
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/datasets/"),
114
+ method: "POST",
115
+ headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
116
+ contentType: "application/json",
117
+ requestType: "json",
118
+ body: serializers.CreateDatasetRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
119
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
120
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
121
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
122
+ });
123
+ if (_response.ok) {
124
+ return serializers.Dataset.parseOrThrow(_response.body, {
125
+ unrecognizedObjectKeys: "passthrough",
126
+ allowUnrecognizedUnionMembers: true,
127
+ allowUnrecognizedEnumValues: true,
128
+ skipValidation: true,
129
+ breadcrumbsPrefix: ["response"],
130
+ });
131
+ }
132
+ if (_response.error.reason === "status-code") {
133
+ throw new errors.CartesiaError({
134
+ statusCode: _response.error.statusCode,
135
+ body: _response.error.body,
136
+ });
137
+ }
138
+ switch (_response.error.reason) {
139
+ case "non-json":
140
+ throw new errors.CartesiaError({
141
+ statusCode: _response.error.statusCode,
142
+ body: _response.error.rawBody,
143
+ });
144
+ case "timeout":
145
+ throw new errors.CartesiaTimeoutError();
146
+ case "unknown":
147
+ throw new errors.CartesiaError({
148
+ message: _response.error.errorMessage,
149
+ });
150
+ }
151
+ });
152
+ }
153
+ /**
154
+ * @param {string} id
155
+ * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
156
+ *
157
+ * @example
158
+ * await client.datasets.listFiles("string")
159
+ */
160
+ listFiles(id, requestOptions) {
161
+ var _a, _b, _c, _d, _e;
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
164
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
165
+ method: "GET",
166
+ headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
167
+ contentType: "application/json",
168
+ requestType: "json",
169
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
170
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
171
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
172
+ });
173
+ if (_response.ok) {
174
+ return serializers.PaginatedDatasetFiles.parseOrThrow(_response.body, {
175
+ unrecognizedObjectKeys: "passthrough",
176
+ allowUnrecognizedUnionMembers: true,
177
+ allowUnrecognizedEnumValues: true,
178
+ skipValidation: true,
179
+ breadcrumbsPrefix: ["response"],
180
+ });
181
+ }
182
+ if (_response.error.reason === "status-code") {
183
+ throw new errors.CartesiaError({
184
+ statusCode: _response.error.statusCode,
185
+ body: _response.error.body,
186
+ });
187
+ }
188
+ switch (_response.error.reason) {
189
+ case "non-json":
190
+ throw new errors.CartesiaError({
191
+ statusCode: _response.error.statusCode,
192
+ body: _response.error.rawBody,
193
+ });
194
+ case "timeout":
195
+ throw new errors.CartesiaTimeoutError();
196
+ case "unknown":
197
+ throw new errors.CartesiaError({
198
+ message: _response.error.errorMessage,
199
+ });
200
+ }
201
+ });
202
+ }
203
+ /**
204
+ * @param {File | fs.ReadStream | Blob} file
205
+ * @param {string} id
206
+ * @param {Cartesia.UploadDatasetFileRequest} request
207
+ * @param {Datasets.RequestOptions} requestOptions - Request-specific configuration.
208
+ *
209
+ * @example
210
+ * await client.datasets.uploadFile(fs.createReadStream("/path/to/your/file"), "string", {})
211
+ */
212
+ uploadFile(file, id, request, requestOptions) {
213
+ var _a, _b, _c, _d, _e;
214
+ return __awaiter(this, void 0, void 0, function* () {
215
+ const _request = yield core.newFormData();
216
+ yield _request.appendFile("file", file);
217
+ yield _request.append("purpose", request.purpose);
218
+ const _maybeEncodedRequest = yield _request.getRequest();
219
+ const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
220
+ url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, `/datasets/${encodeURIComponent(id)}/files`),
221
+ method: "POST",
222
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
223
+ requestType: "file",
224
+ duplex: _maybeEncodedRequest.duplex,
225
+ body: _maybeEncodedRequest.body,
226
+ timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
227
+ maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
228
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
229
+ });
230
+ if (_response.ok) {
231
+ return;
232
+ }
233
+ if (_response.error.reason === "status-code") {
234
+ throw new errors.CartesiaError({
235
+ statusCode: _response.error.statusCode,
236
+ body: _response.error.body,
237
+ });
238
+ }
239
+ switch (_response.error.reason) {
240
+ case "non-json":
241
+ throw new errors.CartesiaError({
242
+ statusCode: _response.error.statusCode,
243
+ body: _response.error.rawBody,
244
+ });
245
+ case "timeout":
246
+ throw new errors.CartesiaTimeoutError();
247
+ case "unknown":
248
+ throw new errors.CartesiaError({
249
+ message: _response.error.errorMessage,
250
+ });
251
+ }
252
+ });
253
+ }
254
+ _getCustomAuthorizationHeaders() {
255
+ return __awaiter(this, void 0, void 0, function* () {
256
+ const apiKeyValue = yield core.Supplier.get(this._options.apiKey);
257
+ return { "X-API-Key": apiKeyValue };
258
+ });
259
+ }
260
+ }
261
+ exports.Datasets = Datasets;
@@ -0,0 +1 @@
1
+ export * from "./requests";
@@ -0,0 +1,17 @@
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("./requests"), exports);
@@ -0,0 +1,11 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ import * as Cartesia from "../../../../index";
5
+ /**
6
+ * @example
7
+ * {}
8
+ */
9
+ export interface UploadDatasetFileRequest {
10
+ purpose: Cartesia.FilePurpose;
11
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export { type UploadDatasetFileRequest } from "./UploadDatasetFileRequest";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export * from "./client";
@@ -0,0 +1,18 @@
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("./types"), exports);
18
+ __exportStar(require("./client"), exports);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export interface CreateDatasetRequest {
5
+ name: string;
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * This file was auto-generated by Fern from our API Definition.
3
+ */
4
+ export declare type FilePurpose = "fine_tune";
5
+ export declare const FilePurpose: {
6
+ readonly FineTune: "fine_tune";
7
+ };
@@ -0,0 +1,9 @@
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
+ };
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ /**
3
+ * This file was auto-generated by Fern from our API Definition.
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ export * from "./Dataset";
2
+ export * from "./CreateDatasetRequest";
3
+ export * from "./DatasetFile";
4
+ export * from "./FilePurpose";
5
+ export * from "./PaginatedDatasets";
6
+ export * from "./PaginatedDatasetFiles";
@@ -0,0 +1,22 @@
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,5 +1,7 @@
1
1
  export * as apiStatus from "./apiStatus";
2
2
  export * from "./apiStatus/types";
3
+ export * as datasets from "./datasets";
4
+ export * from "./datasets/types";
3
5
  export * as embedding from "./embedding";
4
6
  export * from "./embedding/types";
5
7
  export * as tts from "./tts";
@@ -8,5 +10,6 @@ export * as voiceChanger from "./voiceChanger";
8
10
  export * from "./voiceChanger/types";
9
11
  export * as voices from "./voices";
10
12
  export * from "./voices/types";
13
+ export * from "./datasets/client/requests";
11
14
  export * from "./voiceChanger/client/requests";
12
15
  export * from "./voices/client/requests";
@@ -26,9 +26,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
26
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.voices = exports.voiceChanger = exports.tts = exports.embedding = exports.apiStatus = void 0;
29
+ exports.voices = exports.voiceChanger = exports.tts = exports.embedding = exports.datasets = exports.apiStatus = void 0;
30
30
  exports.apiStatus = __importStar(require("./apiStatus"));
31
31
  __exportStar(require("./apiStatus/types"), exports);
32
+ exports.datasets = __importStar(require("./datasets"));
33
+ __exportStar(require("./datasets/types"), exports);
32
34
  exports.embedding = __importStar(require("./embedding"));
33
35
  __exportStar(require("./embedding/types"), exports);
34
36
  exports.tts = __importStar(require("./tts"));
@@ -37,5 +39,6 @@ exports.voiceChanger = __importStar(require("./voiceChanger"));
37
39
  __exportStar(require("./voiceChanger/types"), exports);
38
40
  exports.voices = __importStar(require("./voices"));
39
41
  __exportStar(require("./voices/types"), exports);
42
+ __exportStar(require("./datasets/client/requests"), exports);
40
43
  __exportStar(require("./voiceChanger/client/requests"), exports);
41
44
  __exportStar(require("./voices/client/requests"), exports);
@@ -54,7 +54,7 @@ class Tts {
54
54
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
55
55
  url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/bytes"),
56
56
  method: "POST",
57
- headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
57
+ headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
58
58
  contentType: "application/json",
59
59
  requestType: "json",
60
60
  body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -93,7 +93,7 @@ class Tts {
93
93
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
94
94
  url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/tts/sse"),
95
95
  method: "POST",
96
- headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
96
+ headers: Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())),
97
97
  contentType: "application/json",
98
98
  requestType: "json",
99
99
  body: serializers.TtsRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
@@ -71,7 +71,7 @@ class VoiceChanger {
71
71
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
72
72
  url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/bytes"),
73
73
  method: "POST",
74
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
74
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
75
75
  requestType: "file",
76
76
  duplex: _maybeEncodedRequest.duplex,
77
77
  body: _maybeEncodedRequest.body,
@@ -122,7 +122,7 @@ class VoiceChanger {
122
122
  const _response = yield ((_a = this._options.fetcher) !== null && _a !== void 0 ? _a : core.fetcher)({
123
123
  url: (0, url_join_1.default)((_b = (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.CartesiaEnvironment.Production, "/voice-changer/sse"),
124
124
  method: "POST",
125
- headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.3", "User-Agent": "@cartesia/cartesia-js/2.0.3", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
125
+ headers: Object.assign(Object.assign({ "Cartesia-Version": (_e = (_c = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.cartesiaVersion) !== null && _c !== void 0 ? _c : (_d = this._options) === null || _d === void 0 ? void 0 : _d.cartesiaVersion) !== null && _e !== void 0 ? _e : "2024-06-10", "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "@cartesia/cartesia-js", "X-Fern-SDK-Version": "2.0.4-alpha0", "User-Agent": "@cartesia/cartesia-js/2.0.4-alpha0", "X-Fern-Runtime": core.RUNTIME.type, "X-Fern-Runtime-Version": core.RUNTIME.version }, (yield this._getCustomAuthorizationHeaders())), _maybeEncodedRequest.headers),
126
126
  requestType: "file",
127
127
  duplex: _maybeEncodedRequest.duplex,
128
128
  body: _maybeEncodedRequest.body,