@internxt/sdk 1.15.14 → 1.16.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 (38) hide show
  1. package/dist/auth/index.js +180 -262
  2. package/dist/auth/types.js +2 -22
  3. package/dist/drive/backups/index.js +34 -32
  4. package/dist/drive/payments/index.js +96 -149
  5. package/dist/drive/payments/object-storage.js +34 -36
  6. package/dist/drive/referrals/index.js +19 -17
  7. package/dist/drive/share/index.js +168 -235
  8. package/dist/drive/storage/index.js +213 -302
  9. package/dist/drive/trash/index.js +40 -84
  10. package/dist/drive/users/index.js +95 -140
  11. package/dist/mail/index.d.ts +124 -2
  12. package/dist/mail/index.js +170 -16
  13. package/dist/mail/types.d.ts +50 -0
  14. package/dist/mail/types.js +6 -0
  15. package/dist/meet/index.js +31 -99
  16. package/dist/misc/location/index.js +10 -50
  17. package/dist/network/download.js +38 -107
  18. package/dist/network/errors/codes.js +8 -24
  19. package/dist/network/errors/context.js +9 -26
  20. package/dist/network/errors/download.js +6 -24
  21. package/dist/network/errors/upload.js +21 -48
  22. package/dist/network/index.js +120 -277
  23. package/dist/network/types.js +3 -4
  24. package/dist/network/upload.js +63 -133
  25. package/dist/payments/checkout.js +57 -69
  26. package/dist/send/send.js +17 -27
  27. package/dist/shared/headers/index.js +56 -42
  28. package/dist/shared/http/client.js +95 -207
  29. package/dist/shared/http/retryWithBackoff.js +36 -110
  30. package/dist/shared/types/errors.js +37 -51
  31. package/dist/workspaces/index.js +224 -264
  32. package/package.json +14 -15
  33. package/dist/mail/api.d.ts +0 -126
  34. package/dist/mail/api.js +0 -288
  35. package/dist/mail/crypto.d.ts +0 -66
  36. package/dist/mail/crypto.js +0 -156
  37. package/dist/mail/mail.d.ts +0 -162
  38. package/dist/mail/mail.js +0 -382
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
3
  if (k2 === undefined) k2 = k;
15
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -43,122 +32,72 @@ var __importStar = (this && this.__importStar) || (function () {
43
32
  return result;
44
33
  };
45
34
  })();
46
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
47
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
48
- return new (P || (P = Promise))(function (resolve, reject) {
49
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
50
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
51
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
52
- step((generator = generator.apply(thisArg, _arguments || [])).next());
53
- });
54
- };
55
- var __generator = (this && this.__generator) || function (thisArg, body) {
56
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
57
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
58
- function verb(n) { return function (v) { return step([n, v]); }; }
59
- function step(op) {
60
- if (f) throw new TypeError("Generator is already executing.");
61
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
62
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
63
- if (y = 0, t) op = [op[0] & 2, t.value];
64
- switch (op[0]) {
65
- case 0: case 1: t = op; break;
66
- case 4: _.label++; return { value: op[1], done: false };
67
- case 5: _.label++; y = op[1]; op = [0]; continue;
68
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
69
- default:
70
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
71
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
72
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
73
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
74
- if (t[2]) _.ops.pop();
75
- _.trys.pop(); continue;
76
- }
77
- op = body.call(thisArg, _);
78
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
79
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
80
- }
81
- };
82
35
  Object.defineProperty(exports, "__esModule", { value: true });
83
36
  exports.Storage = exports.StorageTypes = void 0;
84
- var headers_1 = require("../../shared/headers");
85
- var client_1 = require("../../shared/http/client");
37
+ const headers_1 = require("../../shared/headers");
38
+ const client_1 = require("../../shared/http/client");
86
39
  exports.StorageTypes = __importStar(require("./types"));
87
- var Storage = /** @class */ (function () {
88
- function Storage(apiUrl, appDetails, apiSecurity) {
40
+ class Storage {
41
+ client;
42
+ appDetails;
43
+ apiSecurity;
44
+ static client(apiUrl, appDetails, apiSecurity) {
45
+ return new Storage(apiUrl, appDetails, apiSecurity);
46
+ }
47
+ constructor(apiUrl, appDetails, apiSecurity) {
89
48
  this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback, apiSecurity.retryOptions);
90
49
  this.appDetails = appDetails;
91
50
  this.apiSecurity = apiSecurity;
92
51
  }
93
- Storage.client = function (apiUrl, appDetails, apiSecurity) {
94
- return new Storage(apiUrl, appDetails, apiSecurity);
95
- };
96
52
  /**
97
53
  * Creates a new folder
98
54
  * @param payload
99
55
  */
100
- Storage.prototype.createFolder = function (payload) {
101
- var _a = this.client.postCancellable('/storage/folder', {
56
+ createFolder(payload) {
57
+ const { promise, requestCanceler } = this.client.postCancellable('/storage/folder', {
102
58
  parentFolderId: payload.parentFolderId,
103
59
  folderName: payload.folderName,
104
- }, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
60
+ }, this.headers());
105
61
  return [promise, requestCanceler];
106
- };
62
+ }
107
63
  /**
108
64
  * Creates a new folder
109
65
  * @param payload
110
66
  */
111
- Storage.prototype.createFolderByUuid = function (payload) {
112
- var _a = this.client.postCancellable('/folders', {
67
+ createFolderByUuid(payload) {
68
+ const { promise, requestCanceler } = this.client.postCancellable('/folders', {
113
69
  plainName: payload.plainName,
114
70
  parentFolderUuid: payload.parentFolderUuid,
115
- }, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
71
+ }, this.headers());
116
72
  return [promise, requestCanceler];
117
- };
73
+ }
118
74
  /**
119
75
  * Moves a specific folder to a new location
120
76
  * @param payload
121
77
  * @deprecated Use `moveFolderByUuid` instead.
122
78
  */
123
- Storage.prototype.moveFolder = function (payload) {
124
- return __awaiter(this, void 0, void 0, function () {
125
- return __generator(this, function (_a) {
126
- return [2 /*return*/, this.client.post('/storage/move/folder', {
127
- folderId: payload.folderId,
128
- destination: payload.destinationFolderId,
129
- }, this.headers())];
130
- });
131
- });
132
- };
79
+ async moveFolder(payload) {
80
+ return this.client.post('/storage/move/folder', {
81
+ folderId: payload.folderId,
82
+ destination: payload.destinationFolderId,
83
+ }, this.headers());
84
+ }
133
85
  /**
134
86
  * Moves a specific folder to a new location
135
87
  * @param payload
136
88
  */
137
- Storage.prototype.moveFolderByUuid = function (uuid, payload) {
138
- return __awaiter(this, void 0, void 0, function () {
139
- return __generator(this, function (_a) {
140
- return [2 /*return*/, this.client.patch("/folders/".concat(uuid), payload, this.headers())];
141
- });
142
- });
143
- };
89
+ async moveFolderByUuid(uuid, payload) {
90
+ return this.client.patch(`/folders/${uuid}`, payload, this.headers());
91
+ }
144
92
  /**
145
93
  * Updates the metadata of a folder
146
94
  * @param payload
147
95
  */
148
- Storage.prototype.updateFolder = function (payload) {
149
- return __awaiter(this, void 0, void 0, function () {
150
- return __generator(this, function (_a) {
151
- switch (_a.label) {
152
- case 0: return [4 /*yield*/, this.client.post("/storage/folder/".concat(payload.folderId, "/meta"), {
153
- metadata: payload.changes,
154
- }, this.headers())];
155
- case 1:
156
- _a.sent();
157
- return [2 /*return*/];
158
- }
159
- });
160
- });
161
- };
96
+ async updateFolder(payload) {
97
+ await this.client.post(`/storage/folder/${payload.folderId}/meta`, {
98
+ metadata: payload.changes,
99
+ }, this.headers());
100
+ }
162
101
  /**
163
102
  * Updates the name of a folder with the given UUID.
164
103
  *
@@ -168,22 +107,21 @@ var Storage = /** @class */ (function () {
168
107
  * @param {Token} [resourcesToken] - An optional token for authentication.
169
108
  * @return {Promise<void>} A promise that resolves when the folder name is successfully updated.
170
109
  */
171
- Storage.prototype.updateFolderNameWithUUID = function (payload, resourcesToken) {
172
- var folderUuid = payload.folderUuid, name = payload.name;
173
- return this.client.put("/folders/".concat(folderUuid, "/meta"), {
110
+ updateFolderNameWithUUID(payload, resourcesToken) {
111
+ const { folderUuid, name } = payload;
112
+ return this.client.put(`/folders/${folderUuid}/meta`, {
174
113
  plainName: name,
175
114
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
176
- };
115
+ }
177
116
  /**
178
117
  * Fetches & returns the contents of a specific folder
179
118
  * @param folderId
180
119
  */
181
- Storage.prototype.getFolderContent = function (folderId, trash) {
182
- if (trash === void 0) { trash = false; }
183
- var query = trash ? '/?trash=true' : '';
184
- var _a = this.client.getCancellable("/storage/v2/folder/".concat(folderId).concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
120
+ getFolderContent(folderId, trash = false) {
121
+ const query = trash ? '/?trash=true' : '';
122
+ const { promise, requestCanceler } = this.client.getCancellable(`/storage/v2/folder/${folderId}${query}`, this.headers());
185
123
  return [promise, requestCanceler];
186
- };
124
+ }
187
125
  /**
188
126
  * Fetches and returns the contents of a specific folder by its UUID.
189
127
  *
@@ -194,23 +132,22 @@ var Storage = /** @class */ (function () {
194
132
  * @param {boolean} [workspacesToken] - Token for accessing workspaces.
195
133
  * @return {[Promise<FetchFolderContentResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
196
134
  */
197
- Storage.prototype.getFolderContentByUuid = function (_a) {
198
- var folderUuid = _a.folderUuid, _b = _a.trash, trash = _b === void 0 ? false : _b, offset = _a.offset, limit = _a.limit, workspacesToken = _a.workspacesToken;
199
- var query = new URLSearchParams();
135
+ getFolderContentByUuid({ folderUuid, trash = false, offset, limit, workspacesToken, }) {
136
+ const query = new URLSearchParams();
200
137
  if (offset !== undefined)
201
138
  query.set('offset', String(offset));
202
139
  if (limit !== undefined)
203
140
  query.set('limit', String(limit));
204
141
  if (trash)
205
142
  query.set('trash', 'true');
206
- var customHeaders = workspacesToken
143
+ const customHeaders = workspacesToken
207
144
  ? {
208
145
  'x-internxt-workspace': workspacesToken,
209
146
  }
210
147
  : undefined;
211
- var _c = this.client.getCancellable("/folders/content/".concat(folderUuid, "?").concat(query), this.headers(customHeaders)), promise = _c.promise, requestCanceler = _c.requestCanceler;
148
+ const { promise, requestCanceler } = this.client.getCancellable(`/folders/content/${folderUuid}?${query}`, this.headers(customHeaders));
212
149
  return [promise, requestCanceler];
213
- };
150
+ }
214
151
  /**
215
152
  * Retrieves a file with the specified fileId along with the associated workspacesToken.
216
153
  *
@@ -218,15 +155,15 @@ var Storage = /** @class */ (function () {
218
155
  * @param {string} [workspacesToken] - Token for accessing workspaces.
219
156
  * @return {[Promise<FileMeta>, RequestCanceler]} A promise with FileMeta and a canceler for the request.
220
157
  */
221
- Storage.prototype.getFile = function (fileId, workspacesToken) {
222
- var customHeaders = workspacesToken
158
+ getFile(fileId, workspacesToken) {
159
+ const customHeaders = workspacesToken
223
160
  ? {
224
161
  'x-internxt-workspace': workspacesToken,
225
162
  }
226
163
  : undefined;
227
- var _a = this.client.getCancellable("/files/".concat(fileId, "/meta"), this.headers(customHeaders)), promise = _a.promise, requestCanceler = _a.requestCanceler;
164
+ const { promise, requestCanceler } = this.client.getCancellable(`/files/${fileId}/meta`, this.headers(customHeaders));
228
165
  return [promise, requestCanceler];
229
- };
166
+ }
230
167
  /**
231
168
  * Gets the files in a folder.
232
169
  *
@@ -237,19 +174,15 @@ var Storage = /** @class */ (function () {
237
174
  * @param {string} [order=ASC] - The order to be followed.
238
175
  * @returns {[Promise<FetchPaginatedFolderContentResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
239
176
  */
240
- Storage.prototype.getFolderFiles = function (folderId, offset, limit, sort, order) {
241
- if (offset === void 0) { offset = 0; }
242
- if (limit === void 0) { limit = 50; }
243
- if (sort === void 0) { sort = ''; }
244
- if (order === void 0) { order = ''; }
245
- var offsetQuery = "?offset=".concat(offset);
246
- var limitQuery = "&limit=".concat(limit);
247
- var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
248
- var orderQuery = order !== '' ? "&order=".concat(order) : '';
249
- var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
250
- var _a = this.client.getCancellable("folders/".concat(folderId, "/files/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
177
+ getFolderFiles(folderId, offset = 0, limit = 50, sort = '', order = '') {
178
+ const offsetQuery = `?offset=${offset}`;
179
+ const limitQuery = `&limit=${limit}`;
180
+ const sortQuery = sort !== '' ? `&sort=${sort}` : '';
181
+ const orderQuery = order !== '' ? `&order=${order}` : '';
182
+ const query = `${offsetQuery}${limitQuery}${sortQuery}${orderQuery}`;
183
+ const { promise, requestCanceler } = this.client.getCancellable(`folders/${folderId}/files/${query}`, this.headers());
251
184
  return [promise, requestCanceler];
252
- };
185
+ }
253
186
  /**
254
187
  * Gets the files in a folder by its UUID.
255
188
  *
@@ -260,19 +193,15 @@ var Storage = /** @class */ (function () {
260
193
  * @param {string} [order=ASC] - The order to be followed.
261
194
  * @returns {[Promise<FetchPaginatedFilesContent>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
262
195
  */
263
- Storage.prototype.getFolderFilesByUuid = function (folderUuid, offset, limit, sort, order) {
264
- if (offset === void 0) { offset = 0; }
265
- if (limit === void 0) { limit = 50; }
266
- if (sort === void 0) { sort = ''; }
267
- if (order === void 0) { order = ''; }
268
- var offsetQuery = "?offset=".concat(offset);
269
- var limitQuery = "&limit=".concat(limit);
270
- var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
271
- var orderQuery = order !== '' ? "&order=".concat(order) : '';
272
- var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
273
- var _a = this.client.getCancellable("folders/content/".concat(folderUuid, "/files/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
196
+ getFolderFilesByUuid(folderUuid, offset = 0, limit = 50, sort = '', order = '') {
197
+ const offsetQuery = `?offset=${offset}`;
198
+ const limitQuery = `&limit=${limit}`;
199
+ const sortQuery = sort !== '' ? `&sort=${sort}` : '';
200
+ const orderQuery = order !== '' ? `&order=${order}` : '';
201
+ const query = `${offsetQuery}${limitQuery}${sortQuery}${orderQuery}`;
202
+ const { promise, requestCanceler } = this.client.getCancellable(`folders/content/${folderUuid}/files/${query}`, this.headers());
274
203
  return [promise, requestCanceler];
275
- };
204
+ }
276
205
  /**
277
206
  * Gets the subfolders of a folder.
278
207
  *
@@ -283,19 +212,15 @@ var Storage = /** @class */ (function () {
283
212
  * @param {string} [order=ASC] - The order to be followed.
284
213
  * @returns {[Promise<FetchPaginatedFolderContentResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
285
214
  */
286
- Storage.prototype.getFolderFolders = function (folderId, offset, limit, sort, order) {
287
- if (offset === void 0) { offset = 0; }
288
- if (limit === void 0) { limit = 50; }
289
- if (sort === void 0) { sort = ''; }
290
- if (order === void 0) { order = ''; }
291
- var offsetQuery = "?offset=".concat(offset);
292
- var limitQuery = "&limit=".concat(limit);
293
- var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
294
- var orderQuery = order !== '' ? "&order=".concat(order) : '';
295
- var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
296
- var _a = this.client.getCancellable("folders/".concat(folderId, "/folders/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
215
+ getFolderFolders(folderId, offset = 0, limit = 50, sort = '', order = '') {
216
+ const offsetQuery = `?offset=${offset}`;
217
+ const limitQuery = `&limit=${limit}`;
218
+ const sortQuery = sort !== '' ? `&sort=${sort}` : '';
219
+ const orderQuery = order !== '' ? `&order=${order}` : '';
220
+ const query = `${offsetQuery}${limitQuery}${sortQuery}${orderQuery}`;
221
+ const { promise, requestCanceler } = this.client.getCancellable(`folders/${folderId}/folders/${query}`, this.headers());
297
222
  return [promise, requestCanceler];
298
- };
223
+ }
299
224
  /**
300
225
  * Gets the subfolders of a folder by its UUID.
301
226
  *
@@ -306,53 +231,49 @@ var Storage = /** @class */ (function () {
306
231
  * @param {string} [order=ASC] - The order to be followed.
307
232
  * @returns {[Promise<FetchPaginatedFoldersContent>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
308
233
  */
309
- Storage.prototype.getFolderFoldersByUuid = function (folderUuid, offset, limit, sort, order) {
310
- if (offset === void 0) { offset = 0; }
311
- if (limit === void 0) { limit = 50; }
312
- if (sort === void 0) { sort = ''; }
313
- if (order === void 0) { order = ''; }
314
- var offsetQuery = "?offset=".concat(offset);
315
- var limitQuery = "&limit=".concat(limit);
316
- var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
317
- var orderQuery = order !== '' ? "&order=".concat(order) : '';
318
- var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
319
- var _a = this.client.getCancellable("folders/content/".concat(folderUuid, "/folders/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
234
+ getFolderFoldersByUuid(folderUuid, offset = 0, limit = 50, sort = '', order = '') {
235
+ const offsetQuery = `?offset=${offset}`;
236
+ const limitQuery = `&limit=${limit}`;
237
+ const sortQuery = sort !== '' ? `&sort=${sort}` : '';
238
+ const orderQuery = order !== '' ? `&order=${order}` : '';
239
+ const query = `${offsetQuery}${limitQuery}${sortQuery}${orderQuery}`;
240
+ const { promise, requestCanceler } = this.client.getCancellable(`folders/content/${folderUuid}/folders/${query}`, this.headers());
320
241
  return [promise, requestCanceler];
321
- };
242
+ }
322
243
  /**
323
244
  * Removes a specific folder from the centralized persistence
324
245
  * @param folderId
325
246
  * @deprecated Use `deleteFolderByUuid` instead.
326
247
  */
327
- Storage.prototype.deleteFolder = function (folderId) {
328
- return this.client.delete("/storage/folder/".concat(folderId), this.headers());
329
- };
248
+ deleteFolder(folderId) {
249
+ return this.client.delete(`/storage/folder/${folderId}`, this.headers());
250
+ }
330
251
  /**
331
252
  * Deletes a folder from the storage system using its unique identifier (UUID).
332
253
  *
333
254
  * @param folderId - The UUID of the folder to be deleted.
334
255
  * @returns A promise that resolves with the response of the delete operation.
335
256
  */
336
- Storage.prototype.deleteFolderByUuid = function (folderId) {
337
- return this.client.delete("/folders/".concat(folderId), this.headers());
338
- };
257
+ deleteFolderByUuid(folderId) {
258
+ return this.client.delete(`/folders/${folderId}`, this.headers());
259
+ }
339
260
  /**
340
261
  * Returns the total size of a folder
341
262
  * @param folderId
342
263
  */
343
- Storage.prototype.getFolderSize = function (folderId) {
264
+ getFolderSize(folderId) {
344
265
  return this.client
345
- .get("/storage/folder/size/".concat(folderId), this.headers())
346
- .then(function (response) {
266
+ .get(`/storage/folder/size/${folderId}`, this.headers())
267
+ .then((response) => {
347
268
  return response.size;
348
269
  });
349
- };
270
+ }
350
271
  /**
351
272
  * Creates a new file entry
352
273
  * @param fileEntry
353
274
  * @deprecated Use `createFileEntryByUuid` instead.
354
275
  */
355
- Storage.prototype.createFileEntry = function (fileEntry, resourcesToken) {
276
+ createFileEntry(fileEntry, resourcesToken) {
356
277
  return this.client.post('/storage/file', {
357
278
  file: {
358
279
  fileId: fileEntry.id,
@@ -365,41 +286,43 @@ var Storage = /** @class */ (function () {
365
286
  encrypt_version: fileEntry.encrypt_version,
366
287
  },
367
288
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
368
- };
289
+ }
369
290
  /**
370
291
  * Creates a new file entry
371
292
  * @param fileEntry
372
293
  */
373
- Storage.prototype.createFileEntryByUuid = function (fileEntry, resourcesToken) {
294
+ createFileEntryByUuid(fileEntry, resourcesToken) {
374
295
  return this.client.post('/files', fileEntry, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
375
- };
296
+ }
376
297
  /**
377
298
  * Creates a new thumbnail entry
378
299
  * @param thumbnailEntry
379
300
  */
380
- Storage.prototype.createThumbnailEntry = function (thumbnailEntry, resourcesToken) {
301
+ createThumbnailEntry(thumbnailEntry, resourcesToken) {
381
302
  return this.client.post('/storage/thumbnail', {
382
303
  thumbnail: thumbnailEntry,
383
304
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
384
- };
305
+ }
385
306
  /**
386
307
  * Creates a new thumbnail entry using drive-server-wip
387
308
  * @param CreateThumbnailEntryPayload
388
309
  */
389
- Storage.prototype.createThumbnailEntryWithUUID = function (thumbnailEntry, resourcesToken) {
390
- return this.client.post('/files/thumbnail', __assign({}, thumbnailEntry), (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
391
- };
310
+ createThumbnailEntryWithUUID(thumbnailEntry, resourcesToken) {
311
+ return this.client.post('/files/thumbnail', {
312
+ ...thumbnailEntry,
313
+ }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
314
+ }
392
315
  /**
393
316
  * Updates the details of a file entry
394
317
  * @param payload
395
318
  */
396
- Storage.prototype.updateFile = function (payload, resourcesToken) {
397
- return this.client.post("/storage/file/".concat(payload.fileId, "/meta"), {
319
+ updateFile(payload, resourcesToken) {
320
+ return this.client.post(`/storage/file/${payload.fileId}/meta`, {
398
321
  metadata: payload.metadata,
399
322
  bucketId: payload.bucketId,
400
323
  relativePath: payload.destinationPath,
401
324
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
402
- };
325
+ }
403
326
  /**
404
327
  * Updates the name of a file with the given UUID.
405
328
  *
@@ -409,12 +332,12 @@ var Storage = /** @class */ (function () {
409
332
  * @param {string} [resourcesToken] - The token for accessing resources.
410
333
  * @return {Promise<void>} - A Promise that resolves when the file name is successfully updated.
411
334
  */
412
- Storage.prototype.updateFileNameWithUUID = function (payload, resourcesToken) {
413
- var fileUuid = payload.fileUuid, name = payload.name;
414
- return this.client.put("/files/".concat(fileUuid, "/meta"), {
335
+ updateFileNameWithUUID(payload, resourcesToken) {
336
+ const { fileUuid, name } = payload;
337
+ return this.client.put(`/files/${fileUuid}/meta`, {
415
338
  plainName: name,
416
339
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
417
- };
340
+ }
418
341
  /**
419
342
  * Updates the name and the type from a given file UUID.
420
343
  *
@@ -425,124 +348,116 @@ var Storage = /** @class */ (function () {
425
348
  * @param {string} [resourcesToken] - The token for accessing resources.
426
349
  * @return {Promise<void>} - A Promise that resolves when the file name is successfully updated.
427
350
  */
428
- Storage.prototype.updateFileMetaByUUID = function (fileUuid, payload, resourcesToken) {
429
- return this.client.put("/files/".concat(fileUuid, "/meta"), payload, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
430
- };
351
+ updateFileMetaByUUID(fileUuid, payload, resourcesToken) {
352
+ return this.client.put(`/files/${fileUuid}/meta`, payload, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
353
+ }
431
354
  /**
432
355
  * Deletes a specific file entry
433
356
  * @param payload
434
357
  * @deprecated Use `deleteFileByUuid` instead.
435
358
  */
436
- Storage.prototype.deleteFile = function (payload) {
437
- return this.client.delete("/storage/folder/".concat(payload.folderId, "/file/").concat(payload.fileId), this.headers());
438
- };
359
+ deleteFile(payload) {
360
+ return this.client.delete(`/storage/folder/${payload.folderId}/file/${payload.fileId}`, this.headers());
361
+ }
439
362
  /**
440
363
  * Deletes a file from the storage system using its unique identifier (UUID).
441
364
  *
442
365
  * @param fileId - The UUID of the file to be deleted.
443
366
  * @returns A promise that resolves with the response of the delete operation.
444
367
  */
445
- Storage.prototype.deleteFileByUuid = function (fileId) {
446
- return this.client.delete("/files/".concat(fileId), this.headers());
447
- };
368
+ deleteFileByUuid(fileId) {
369
+ return this.client.delete(`/files/${fileId}`, this.headers());
370
+ }
448
371
  /**
449
372
  * Updates the persisted path of a file entry
450
373
  * @param payload
451
374
  * @deprecated Use `moveFileByUuid` instead.
452
375
  */
453
- Storage.prototype.moveFile = function (payload) {
376
+ moveFile(payload) {
454
377
  return this.client.post('/storage/move/file', {
455
378
  fileId: payload.fileId,
456
379
  destination: payload.destination,
457
380
  relativePath: payload.destinationPath,
458
381
  bucketId: payload.bucketId,
459
382
  }, this.headers());
460
- };
383
+ }
461
384
  /**
462
385
  * Moves a specific file to a new location
463
386
  * @param payload
464
387
  */
465
- Storage.prototype.moveFileByUuid = function (uuid, payload) {
466
- return __awaiter(this, void 0, void 0, function () {
467
- return __generator(this, function (_a) {
468
- return [2 /*return*/, this.client.patch("/files/".concat(uuid), payload, this.headers())];
469
- });
470
- });
471
- };
388
+ async moveFileByUuid(uuid, payload) {
389
+ return this.client.patch(`/files/${uuid}`, payload, this.headers());
390
+ }
472
391
  /**
473
392
  * Returns a list of the n most recent files
474
393
  * @param limit
475
394
  * @deprecated use `getRecentFilesV2` call instead.
476
395
  */
477
- Storage.prototype.getRecentFiles = function (limit) {
478
- return this.client.get("/storage/recents?limit=".concat(limit), this.headers());
479
- };
396
+ getRecentFiles(limit) {
397
+ return this.client.get(`/storage/recents?limit=${limit}`, this.headers());
398
+ }
480
399
  /**
481
400
  * Returns a list of the n most recent files
482
401
  * @param limit
483
402
  */
484
- Storage.prototype.getRecentFilesV2 = function (limit) {
485
- return __awaiter(this, void 0, void 0, function () {
486
- return __generator(this, function (_a) {
487
- return [2 /*return*/, this.client.get("/files/recents?limit=".concat(limit), this.headers())];
488
- });
489
- });
490
- };
403
+ async getRecentFilesV2(limit) {
404
+ return this.client.get(`/files/recents?limit=${limit}`, this.headers());
405
+ }
491
406
  /**
492
407
  * Returns a list of items in trash
493
408
  */
494
- Storage.prototype.getTrash = function () {
495
- var _a = this.client.getCancellable('/storage/trash', this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
409
+ getTrash() {
410
+ const { promise, requestCanceler } = this.client.getCancellable('/storage/trash', this.headers());
496
411
  return [promise, requestCanceler];
497
- };
412
+ }
498
413
  /**
499
414
  * Add Items to Trash
500
415
  * @param payload
501
416
  */
502
- Storage.prototype.addItemsToTrash = function (payload) {
417
+ addItemsToTrash(payload) {
503
418
  return this.client.post('/storage/trash/add', {
504
419
  items: payload.items,
505
420
  }, this.headers());
506
- };
421
+ }
507
422
  /**
508
423
  * @returns whether the user has uploaded any files
509
424
  */
510
- Storage.prototype.hasUploadedFiles = function () {
425
+ hasUploadedFiles() {
511
426
  return this.client.get('/users/me/upload-status', this.headers());
512
- };
427
+ }
513
428
  /**
514
429
  * Returns a list of the n most recent files
515
430
  * @param limit
516
431
  */
517
- Storage.prototype.searchItemsByName = function (plain_name) {
518
- return this.client.post('/users/search', { plain_name: plain_name }, this.headers());
519
- };
432
+ searchItemsByName(plain_name) {
433
+ return this.client.post('/users/search', { plain_name }, this.headers());
434
+ }
520
435
  /**
521
436
  * Returns the current space usage of the user
522
437
  * @deprecated use `spaceUsageV2` call instead.
523
438
  */
524
- Storage.prototype.spaceUsage = function () {
439
+ spaceUsage() {
525
440
  return this.client.get('/usage', this.headers());
526
- };
441
+ }
527
442
  /**
528
443
  * Returns the current space usage of the user
529
444
  */
530
- Storage.prototype.spaceUsageV2 = function () {
445
+ spaceUsageV2() {
531
446
  return this.client.get('/users/usage', this.headers());
532
- };
447
+ }
533
448
  /**
534
449
  * Returns the current space limit for the user
535
450
  * @deprecated use `spaceLimitV2` call instead.
536
451
  */
537
- Storage.prototype.spaceLimit = function () {
452
+ spaceLimit() {
538
453
  return this.client.get('/limit', this.headers());
539
- };
454
+ }
540
455
  /**
541
456
  * Returns the current space limit for the user
542
457
  */
543
- Storage.prototype.spaceLimitV2 = function () {
458
+ spaceLimitV2() {
544
459
  return this.client.get('/users/limit', this.headers());
545
- };
460
+ }
546
461
  /**
547
462
  * Get global search items.
548
463
  *
@@ -551,26 +466,29 @@ var Storage = /** @class */ (function () {
551
466
  * @param {number} offset - The position of the first item to return (optional).
552
467
  * @returns {[Promise<SearchResultData>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
553
468
  */
554
- Storage.prototype.getGlobalSearchItems = function (search, workspaceId, offset) {
555
- var query = new URLSearchParams();
469
+ getGlobalSearchItems(search, workspaceId, offset) {
470
+ const query = new URLSearchParams();
556
471
  if (offset !== undefined)
557
472
  query.set('offset', String(offset));
558
- var _a = workspaceId
559
- ? this.client.getCancellable("workspaces/".concat(workspaceId, "/fuzzy/").concat(search, "?").concat(query), this.headers())
560
- : this.client.getCancellable("fuzzy/".concat(search, "?").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
473
+ const { promise, requestCanceler } = workspaceId
474
+ ? this.client.getCancellable(`workspaces/${workspaceId}/fuzzy/${search}?${query}`, this.headers())
475
+ : this.client.getCancellable(`fuzzy/${search}?${query}`, this.headers());
561
476
  return [promise, requestCanceler];
562
- };
477
+ }
563
478
  /**
564
479
  * Returns the needed headers for the module requests
565
480
  * @private
566
481
  */
567
- Storage.prototype.headers = function (customHeaders) {
568
- var customExtraHeaders = {};
482
+ headers(customHeaders) {
483
+ let customExtraHeaders = {};
569
484
  if (customHeaders) {
570
485
  customExtraHeaders = customHeaders;
571
486
  }
572
487
  if (this.appDetails.customHeaders) {
573
- customExtraHeaders = __assign(__assign({}, customExtraHeaders), this.appDetails.customHeaders);
488
+ customExtraHeaders = {
489
+ ...customExtraHeaders,
490
+ ...this.appDetails.customHeaders,
491
+ };
574
492
  }
575
493
  return (0, headers_1.headersWithToken)({
576
494
  clientName: this.appDetails.clientName,
@@ -580,16 +498,16 @@ var Storage = /** @class */ (function () {
580
498
  desktopToken: this.appDetails.desktopHeader,
581
499
  customHeaders: customExtraHeaders,
582
500
  });
583
- };
501
+ }
584
502
  /**
585
503
  * Gets the ancestors of a given folder UUID
586
504
  *
587
505
  * @param {string} uuid - UUID of the folder.
588
506
  * @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
589
507
  */
590
- Storage.prototype.getFolderAncestors = function (uuid) {
591
- return this.client.get("folders/".concat(uuid, "/ancestors"), this.headers());
592
- };
508
+ getFolderAncestors(uuid) {
509
+ return this.client.get(`folders/${uuid}/ancestors`, this.headers());
510
+ }
593
511
  /**
594
512
  * Gets the ancestors of an item with the given UUID and type in a Workspace
595
513
  *
@@ -598,41 +516,41 @@ var Storage = /** @class */ (function () {
598
516
  * @param {string} uuid - UUID of the item.
599
517
  * @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
600
518
  */
601
- Storage.prototype.getFolderAncestorsInWorkspace = function (workspaceId, itemType, uuid, resourcesToken) {
602
- return this.client.get("workspaces/".concat(workspaceId, "/").concat(itemType, "/").concat(uuid, "/ancestors"), (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
603
- };
519
+ getFolderAncestorsInWorkspace(workspaceId, itemType, uuid, resourcesToken) {
520
+ return this.client.get(`workspaces/${workspaceId}/${itemType}/${uuid}/ancestors`, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
521
+ }
604
522
  /**
605
523
  * Gets the meta of a given folder UUID
606
524
  *
607
525
  * @param {string} folderUUID - UUID of the folder.
608
526
  * @returns {Promise<FolderMeta>}
609
527
  */
610
- Storage.prototype.getFolderMeta = function (uuid, workspacesToken, resourcesToken) {
611
- var customHeaders = workspacesToken
528
+ getFolderMeta(uuid, workspacesToken, resourcesToken) {
529
+ const customHeaders = workspacesToken
612
530
  ? {
613
531
  'x-internxt-workspace': workspacesToken,
614
532
  }
615
533
  : undefined;
616
- return this.client.get("folders/".concat(uuid, "/meta"), (0, headers_1.addResourcesTokenToHeaders)(this.headers(customHeaders), resourcesToken));
617
- };
534
+ return this.client.get(`folders/${uuid}/meta`, (0, headers_1.addResourcesTokenToHeaders)(this.headers(customHeaders), resourcesToken));
535
+ }
618
536
  /**
619
537
  * Gets the stats of a given folder UUID
620
538
  *
621
539
  * @param {string} uuid - UUID of the folder.
622
540
  * @returns {Promise<FolderStatsResponse>}
623
541
  */
624
- Storage.prototype.getFolderStats = function (uuid) {
625
- return this.client.get("folders/".concat(uuid, "/stats"), this.headers());
626
- };
542
+ getFolderStats(uuid) {
543
+ return this.client.get(`folders/${uuid}/stats`, this.headers());
544
+ }
627
545
  /**
628
546
  * Gets the meta of a given folder Id
629
547
  *
630
548
  * @param {number} folderId - Id of the folder.
631
549
  * @returns {Promise<FolderMeta>}
632
550
  */
633
- Storage.prototype.getFolderMetaById = function (folderId) {
634
- return this.client.get("folders/".concat(folderId, "/metadata"), this.headers());
635
- };
551
+ getFolderMetaById(folderId) {
552
+ return this.client.get(`folders/${folderId}/metadata`, this.headers());
553
+ }
636
554
  /**
637
555
  * Replaces a file with a new one.
638
556
  *
@@ -640,86 +558,80 @@ var Storage = /** @class */ (function () {
640
558
  * @param {ReplaceFile} payload
641
559
  * @returns {Promise<DriveFileData>} - The replaced file data.
642
560
  */
643
- Storage.prototype.replaceFile = function (uuid, payload) {
644
- return this.client.put("/files/".concat(uuid), __assign({}, payload), this.headers());
645
- };
561
+ replaceFile(uuid, payload) {
562
+ return this.client.put(`/files/${uuid}`, { ...payload }, this.headers());
563
+ }
646
564
  /**
647
565
  * Checks the size limit for a file.
648
566
  *
649
567
  * @param {number} size - The size of the file to check.
650
568
  * @return {Promise<void>} - A promise that resolves when the size limit check is complete.
651
569
  */
652
- Storage.prototype.checkSizeLimit = function (size) {
653
- return __awaiter(this, void 0, void 0, function () {
654
- return __generator(this, function (_a) {
655
- return [2 /*return*/, this.client.post('/files/check-size-limit', {
656
- file: {
657
- size: size,
658
- },
659
- }, this.headers())];
660
- });
661
- });
662
- };
570
+ async checkSizeLimit(size) {
571
+ return this.client.post('/files/check-size-limit', {
572
+ file: {
573
+ size,
574
+ },
575
+ }, this.headers());
576
+ }
663
577
  /**
664
578
  * Retrieves the folder tree based on the UUID.
665
579
  *
666
580
  * @param {string} uuid - The UUID of the folder.
667
581
  * @return {Promise<FolderTreeResponse>} The promise containing the folder tree response.
668
582
  */
669
- Storage.prototype.getFolderTree = function (uuid) {
670
- return this.client.get("/folders/".concat(uuid, "/tree"), this.headers());
671
- };
583
+ getFolderTree(uuid) {
584
+ return this.client.get(`/folders/${uuid}/tree`, this.headers());
585
+ }
672
586
  /**
673
587
  * Checks if the given files already exist in the given folder.
674
588
  *
675
589
  * @param {CheckDuplicatedFilesPayload} payload - Payload containing the folder UUID and the list of files to check.
676
590
  * @return {Promise<CheckDuplicatedFilesResponse>} - Promise that contains the duplicated files in a list.
677
591
  */
678
- Storage.prototype.checkDuplicatedFiles = function (_a) {
679
- var folderUuid = _a.folderUuid, filesList = _a.filesList;
680
- return this.client.post("/folders/content/".concat(folderUuid, "/files/existence"), {
592
+ checkDuplicatedFiles({ folderUuid, filesList, }) {
593
+ return this.client.post(`/folders/content/${folderUuid}/files/existence`, {
681
594
  files: filesList,
682
595
  }, this.headers());
683
- };
596
+ }
684
597
  /**
685
598
  * Checks if the given folders names already exist in the given folder
686
599
  *
687
600
  * @param {CheckDuplicatedFolderPayload} payload - Payload containing the folder UUID and the list of folders to check.
688
601
  * @return {Promise<CheckDuplicatedFoldersResponse>} - Promise that contains the duplicated folders in a list.
689
602
  */
690
- Storage.prototype.checkDuplicatedFolders = function (_a) {
691
- var folderUuid = _a.folderUuid, folderNamesList = _a.folderNamesList;
692
- return this.client.post("/folders/content/".concat(folderUuid, "/folders/existence"), {
603
+ checkDuplicatedFolders({ folderUuid, folderNamesList, }) {
604
+ return this.client.post(`/folders/content/${folderUuid}/folders/existence`, {
693
605
  plainNames: folderNamesList,
694
606
  }, this.headers());
695
- };
607
+ }
696
608
  /**
697
609
  * Gets the folder meta from a given path (e.g. "/folder1/folder2")
698
610
  *
699
611
  * @param {string} folderPath - The path of the folder.
700
612
  * @returns {Promise<FolderMeta>} A promise that resolves the folder on that path.
701
613
  */
702
- Storage.prototype.getFolderByPath = function (folderPath) {
703
- return this.client.get("folders/meta?path=".concat(folderPath), this.headers());
704
- };
614
+ getFolderByPath(folderPath) {
615
+ return this.client.get(`folders/meta?path=${folderPath}`, this.headers());
616
+ }
705
617
  /**
706
618
  * Gets the file meta from a given path (e.g. "/folder1/folder2/file.png")
707
619
  *
708
620
  * @param {string} filePath - The path of the file.
709
621
  * @returns {Promise<FileMeta>} A promise that resolves the file on that path.
710
622
  */
711
- Storage.prototype.getFileByPath = function (filePath) {
712
- return this.client.get("files/meta?path=".concat(filePath), this.headers());
713
- };
623
+ getFileByPath(filePath) {
624
+ return this.client.get(`files/meta?path=${filePath}`, this.headers());
625
+ }
714
626
  /**
715
627
  * Gets all versions of a file
716
628
  *
717
629
  * @param {string} uuid - The UUID of the file.
718
630
  * @returns {Promise<FileVersion[]>} A promise that resolves with an array of file versions.
719
631
  */
720
- Storage.prototype.getFileVersions = function (uuid) {
721
- return this.client.get("/files/".concat(uuid, "/versions"), this.headers());
722
- };
632
+ getFileVersions(uuid) {
633
+ return this.client.get(`/files/${uuid}/versions`, this.headers());
634
+ }
723
635
  /**
724
636
  * Deletes a specific version of a file
725
637
  *
@@ -727,9 +639,9 @@ var Storage = /** @class */ (function () {
727
639
  * @param {string} versionId - The UUID of the version to delete.
728
640
  * @returns {Promise<void>} A promise that resolves when the version is deleted.
729
641
  */
730
- Storage.prototype.deleteFileVersion = function (uuid, versionId) {
731
- return this.client.delete("/files/".concat(uuid, "/versions/").concat(versionId), this.headers());
732
- };
642
+ deleteFileVersion(uuid, versionId) {
643
+ return this.client.delete(`/files/${uuid}/versions/${versionId}`, this.headers());
644
+ }
733
645
  /**
734
646
  * Restores a file to a specific version
735
647
  *
@@ -737,17 +649,16 @@ var Storage = /** @class */ (function () {
737
649
  * @param {string} versionId - The UUID of the version to restore.
738
650
  * @returns {Promise<RestoreFileVersionResponse>} A promise that resolves with the restored file.
739
651
  */
740
- Storage.prototype.restoreFileVersion = function (uuid, versionId) {
741
- return this.client.post("/files/".concat(uuid, "/versions/").concat(versionId, "/restore"), {}, this.headers());
742
- };
652
+ restoreFileVersion(uuid, versionId) {
653
+ return this.client.post(`/files/${uuid}/versions/${versionId}/restore`, {}, this.headers());
654
+ }
743
655
  /**
744
656
  * Gets the file version limits for the user
745
657
  *
746
658
  * @returns {Promise<FileLimitsResponse>} A promise that resolves with the file limits.
747
659
  */
748
- Storage.prototype.getFileVersionLimits = function () {
660
+ getFileVersionLimits() {
749
661
  return this.client.get('/files/limits', this.headers());
750
- };
751
- return Storage;
752
- }());
662
+ }
663
+ }
753
664
  exports.Storage = Storage;