@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,5 +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 });
@@ -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,5 +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 });
@@ -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,5 +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 });
@@ -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,5 +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 });
@@ -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,5 +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 });
@@ -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,5 +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 });
@@ -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,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../../../index";
5
- import * as Cartesia from "../../../../api/index";
6
- import * as core from "../../../../core";
7
- export declare const DatasetFile: core.serialization.ObjectSchema<serializers.DatasetFile.Raw, Cartesia.DatasetFile>;
8
- export declare namespace DatasetFile {
9
- interface Raw {
10
- id: string;
11
- filename: string;
12
- created_at: string;
13
- }
14
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../../../index";
5
- import * as Cartesia from "../../../../api/index";
6
- import * as core from "../../../../core";
7
- export declare const FilePurpose: core.serialization.Schema<serializers.FilePurpose.Raw, Cartesia.FilePurpose>;
8
- export declare namespace FilePurpose {
9
- type Raw = "fine_tune";
10
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../../../index";
5
- import * as Cartesia from "../../../../api/index";
6
- import * as core from "../../../../core";
7
- import { DatasetFile } from "./DatasetFile";
8
- export declare const PaginatedDatasetFiles: core.serialization.ObjectSchema<serializers.PaginatedDatasetFiles.Raw, Cartesia.PaginatedDatasetFiles>;
9
- export declare namespace PaginatedDatasetFiles {
10
- interface Raw {
11
- data: DatasetFile.Raw[];
12
- has_more: boolean;
13
- }
14
- }
@@ -1,45 +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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.PaginatedDatasetFiles = void 0;
40
- const core = __importStar(require("../../../../core"));
41
- const DatasetFile_1 = require("./DatasetFile");
42
- exports.PaginatedDatasetFiles = core.serialization.object({
43
- data: core.serialization.list(DatasetFile_1.DatasetFile),
44
- hasMore: core.serialization.property("has_more", core.serialization.boolean()),
45
- });
@@ -1,14 +0,0 @@
1
- /**
2
- * This file was auto-generated by Fern from our API Definition.
3
- */
4
- import * as serializers from "../../../index";
5
- import * as Cartesia from "../../../../api/index";
6
- import * as core from "../../../../core";
7
- import { Dataset } from "./Dataset";
8
- export declare const PaginatedDatasets: core.serialization.ObjectSchema<serializers.PaginatedDatasets.Raw, Cartesia.PaginatedDatasets>;
9
- export declare namespace PaginatedDatasets {
10
- interface Raw {
11
- data: Dataset.Raw[];
12
- has_more: boolean;
13
- }
14
- }
@@ -1,45 +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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.PaginatedDatasets = void 0;
40
- const core = __importStar(require("../../../../core"));
41
- const Dataset_1 = require("./Dataset");
42
- exports.PaginatedDatasets = core.serialization.object({
43
- data: core.serialization.list(Dataset_1.Dataset),
44
- hasMore: core.serialization.property("has_more", core.serialization.boolean()),
45
- });
@@ -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);