@cartesia/cartesia-js 2.1.10 → 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 (146) hide show
  1. package/Client.d.ts +3 -3
  2. package/Client.js +3 -3
  3. package/api/resources/apiStatus/client/Client.js +1 -1
  4. package/api/resources/auth/client/Client.d.ts +51 -0
  5. package/api/resources/auth/client/Client.js +126 -0
  6. package/api/resources/auth/client/index.d.ts +1 -0
  7. package/api/resources/auth/types/TokenGrant.d.ts +7 -0
  8. package/api/resources/auth/types/TokenRequest.d.ts +10 -0
  9. package/api/resources/auth/types/TokenResponse.d.ts +7 -0
  10. package/api/resources/auth/types/index.d.ts +3 -0
  11. package/{dist/api/resources/datasets/client → api/resources/auth/types}/index.js +3 -1
  12. package/api/resources/index.d.ts +2 -3
  13. package/api/resources/index.js +3 -4
  14. package/api/resources/infill/client/Client.js +1 -1
  15. package/api/resources/tts/types/FlushId.d.ts +2 -2
  16. package/api/resources/tts/types/GenerationRequest.d.ts +3 -1
  17. package/api/resources/tts/types/TtsRequest.d.ts +1 -1
  18. package/api/resources/tts/types/WebSocketTtsRequest.d.ts +2 -1
  19. package/api/resources/voices/client/Client.js +8 -8
  20. package/core/websocket/ws.d.ts +1 -0
  21. package/core/websocket/ws.js +1 -1
  22. package/dist/Client.d.ts +3 -3
  23. package/dist/Client.js +3 -3
  24. package/dist/api/resources/apiStatus/client/Client.js +1 -1
  25. package/dist/api/resources/auth/client/Client.d.ts +51 -0
  26. package/dist/api/resources/auth/client/Client.js +126 -0
  27. package/dist/api/resources/auth/client/index.d.ts +1 -0
  28. package/dist/api/resources/auth/types/TokenGrant.d.ts +7 -0
  29. package/dist/api/resources/auth/types/TokenRequest.d.ts +10 -0
  30. package/dist/api/resources/auth/types/TokenResponse.d.ts +7 -0
  31. package/dist/api/resources/auth/types/index.d.ts +3 -0
  32. package/{api/resources/datasets/client → dist/api/resources/auth/types}/index.js +3 -1
  33. package/dist/api/resources/index.d.ts +2 -3
  34. package/dist/api/resources/index.js +3 -4
  35. package/dist/api/resources/infill/client/Client.js +1 -1
  36. package/dist/api/resources/tts/types/FlushId.d.ts +2 -2
  37. package/dist/api/resources/tts/types/GenerationRequest.d.ts +3 -1
  38. package/dist/api/resources/tts/types/TtsRequest.d.ts +1 -1
  39. package/dist/api/resources/tts/types/WebSocketTtsRequest.d.ts +2 -1
  40. package/dist/api/resources/voices/client/Client.js +8 -8
  41. package/dist/core/websocket/ws.d.ts +1 -0
  42. package/dist/core/websocket/ws.js +1 -1
  43. package/dist/serialization/resources/{datasets/types/Dataset.d.ts → auth/types/TokenGrant.d.ts} +3 -5
  44. package/{serialization/resources/datasets/types/FilePurpose.js → dist/serialization/resources/auth/types/TokenGrant.js} +4 -2
  45. package/dist/serialization/resources/auth/types/TokenRequest.d.ts +14 -0
  46. package/dist/serialization/resources/{datasets/types/DatasetFile.js → auth/types/TokenRequest.js} +5 -5
  47. package/{serialization/resources/datasets/types/Dataset.d.ts → dist/serialization/resources/auth/types/TokenResponse.d.ts} +3 -5
  48. package/dist/serialization/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenResponse.js} +3 -3
  49. package/dist/serialization/resources/auth/types/index.d.ts +3 -0
  50. package/dist/serialization/resources/auth/types/index.js +19 -0
  51. package/dist/serialization/resources/index.d.ts +2 -2
  52. package/dist/serialization/resources/index.js +3 -3
  53. package/dist/serialization/resources/tts/types/GenerationRequest.d.ts +1 -0
  54. package/dist/serialization/resources/tts/types/GenerationRequest.js +1 -0
  55. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
  56. package/dist/serialization/resources/tts/types/WebSocketTtsRequest.js +1 -0
  57. package/dist/version.d.ts +1 -1
  58. package/dist/version.js +1 -1
  59. package/dist/wrapper/Websocket.js +8 -2
  60. package/package.json +1 -1
  61. package/reference.md +11 -81
  62. package/{dist/serialization/resources/datasets/types/CreateDatasetRequest.d.ts → serialization/resources/auth/types/TokenGrant.d.ts} +3 -3
  63. package/{dist/serialization/resources/datasets/types/FilePurpose.js → serialization/resources/auth/types/TokenGrant.js} +4 -2
  64. package/serialization/resources/auth/types/TokenRequest.d.ts +14 -0
  65. package/{dist/serialization/resources/datasets/types/Dataset.js → serialization/resources/auth/types/TokenRequest.js} +5 -5
  66. package/serialization/resources/{datasets/types/CreateDatasetRequest.d.ts → auth/types/TokenResponse.d.ts} +3 -3
  67. package/serialization/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenResponse.js} +3 -3
  68. package/serialization/resources/auth/types/index.d.ts +3 -0
  69. package/serialization/resources/auth/types/index.js +19 -0
  70. package/serialization/resources/index.d.ts +2 -2
  71. package/serialization/resources/index.js +3 -3
  72. package/serialization/resources/tts/types/GenerationRequest.d.ts +1 -0
  73. package/serialization/resources/tts/types/GenerationRequest.js +1 -0
  74. package/serialization/resources/tts/types/WebSocketTtsRequest.d.ts +1 -0
  75. package/serialization/resources/tts/types/WebSocketTtsRequest.js +1 -0
  76. package/version.d.ts +1 -1
  77. package/version.js +1 -1
  78. package/wrapper/Websocket.js +8 -2
  79. package/api/resources/datasets/client/Client.d.ts +0 -70
  80. package/api/resources/datasets/client/Client.js +0 -268
  81. package/api/resources/datasets/client/index.d.ts +0 -1
  82. package/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -7
  83. package/api/resources/datasets/client/requests/index.d.ts +0 -1
  84. package/api/resources/datasets/types/CreateDatasetRequest.d.ts +0 -6
  85. package/api/resources/datasets/types/Dataset.d.ts +0 -8
  86. package/api/resources/datasets/types/DatasetFile.d.ts +0 -8
  87. package/api/resources/datasets/types/FilePurpose.d.ts +0 -7
  88. package/api/resources/datasets/types/FilePurpose.js +0 -9
  89. package/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -8
  90. package/api/resources/datasets/types/PaginatedDatasets.d.ts +0 -8
  91. package/api/resources/datasets/types/index.d.ts +0 -6
  92. package/api/resources/datasets/types/index.js +0 -22
  93. package/dist/api/resources/datasets/client/Client.d.ts +0 -70
  94. package/dist/api/resources/datasets/client/Client.js +0 -268
  95. package/dist/api/resources/datasets/client/index.d.ts +0 -1
  96. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.d.ts +0 -7
  97. package/dist/api/resources/datasets/client/requests/UploadDatasetFileRequest.js +0 -5
  98. package/dist/api/resources/datasets/client/requests/index.d.ts +0 -1
  99. package/dist/api/resources/datasets/types/CreateDatasetRequest.d.ts +0 -6
  100. package/dist/api/resources/datasets/types/CreateDatasetRequest.js +0 -5
  101. package/dist/api/resources/datasets/types/Dataset.d.ts +0 -8
  102. package/dist/api/resources/datasets/types/Dataset.js +0 -5
  103. package/dist/api/resources/datasets/types/DatasetFile.d.ts +0 -8
  104. package/dist/api/resources/datasets/types/DatasetFile.js +0 -5
  105. package/dist/api/resources/datasets/types/FilePurpose.d.ts +0 -7
  106. package/dist/api/resources/datasets/types/FilePurpose.js +0 -9
  107. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -8
  108. package/dist/api/resources/datasets/types/PaginatedDatasetFiles.js +0 -5
  109. package/dist/api/resources/datasets/types/PaginatedDatasets.d.ts +0 -8
  110. package/dist/api/resources/datasets/types/PaginatedDatasets.js +0 -5
  111. package/dist/api/resources/datasets/types/index.d.ts +0 -6
  112. package/dist/api/resources/datasets/types/index.js +0 -22
  113. package/dist/serialization/resources/datasets/types/DatasetFile.d.ts +0 -14
  114. package/dist/serialization/resources/datasets/types/FilePurpose.d.ts +0 -10
  115. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -14
  116. package/dist/serialization/resources/datasets/types/PaginatedDatasetFiles.js +0 -45
  117. package/dist/serialization/resources/datasets/types/PaginatedDatasets.d.ts +0 -14
  118. package/dist/serialization/resources/datasets/types/PaginatedDatasets.js +0 -45
  119. package/dist/serialization/resources/datasets/types/index.d.ts +0 -6
  120. package/dist/serialization/resources/datasets/types/index.js +0 -22
  121. package/serialization/resources/datasets/types/Dataset.js +0 -45
  122. package/serialization/resources/datasets/types/DatasetFile.d.ts +0 -14
  123. package/serialization/resources/datasets/types/DatasetFile.js +0 -45
  124. package/serialization/resources/datasets/types/FilePurpose.d.ts +0 -10
  125. package/serialization/resources/datasets/types/PaginatedDatasetFiles.d.ts +0 -14
  126. package/serialization/resources/datasets/types/PaginatedDatasetFiles.js +0 -45
  127. package/serialization/resources/datasets/types/PaginatedDatasets.d.ts +0 -14
  128. package/serialization/resources/datasets/types/PaginatedDatasets.js +0 -45
  129. package/serialization/resources/datasets/types/index.d.ts +0 -6
  130. package/serialization/resources/datasets/types/index.js +0 -22
  131. /package/api/resources/{datasets/client/requests → auth/client}/index.js +0 -0
  132. /package/api/resources/{datasets → auth}/index.d.ts +0 -0
  133. /package/api/resources/{datasets → auth}/index.js +0 -0
  134. /package/api/resources/{datasets/client/requests/UploadDatasetFileRequest.js → auth/types/TokenGrant.js} +0 -0
  135. /package/api/resources/{datasets/types/CreateDatasetRequest.js → auth/types/TokenRequest.js} +0 -0
  136. /package/api/resources/{datasets/types/Dataset.js → auth/types/TokenResponse.js} +0 -0
  137. /package/dist/api/resources/{datasets/client/requests → auth/client}/index.js +0 -0
  138. /package/dist/api/resources/{datasets → auth}/index.d.ts +0 -0
  139. /package/dist/api/resources/{datasets → auth}/index.js +0 -0
  140. /package/{api/resources/datasets/types/DatasetFile.js → dist/api/resources/auth/types/TokenGrant.js} +0 -0
  141. /package/{api/resources/datasets/types/PaginatedDatasetFiles.js → dist/api/resources/auth/types/TokenRequest.js} +0 -0
  142. /package/{api/resources/datasets/types/PaginatedDatasets.js → dist/api/resources/auth/types/TokenResponse.js} +0 -0
  143. /package/dist/serialization/resources/{datasets → auth}/index.d.ts +0 -0
  144. /package/dist/serialization/resources/{datasets → auth}/index.js +0 -0
  145. /package/serialization/resources/{datasets → auth}/index.d.ts +0 -0
  146. /package/serialization/resources/{datasets → auth}/index.js +0 -0
@@ -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.10", "User-Agent": "@cartesia/cartesia-js/2.1.10", "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.10", "User-Agent": "@cartesia/cartesia-js/2.1.10", "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.10", "User-Agent": "@cartesia/cartesia-js/2.1.10", "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.10", "User-Agent": "@cartesia/cartesia-js/2.1.10", "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
- }