@internxt/sdk 1.4.79 → 1.6.3

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 (64) hide show
  1. package/dist/auth/index.d.ts +5 -0
  2. package/dist/auth/index.js +80 -12
  3. package/dist/auth/types.d.ts +17 -4
  4. package/dist/drive/backups/index.js +3 -3
  5. package/dist/drive/index.js +5 -1
  6. package/dist/drive/payments/index.d.ts +30 -17
  7. package/dist/drive/payments/index.js +78 -25
  8. package/dist/drive/payments/types.d.ts +67 -1
  9. package/dist/drive/payments/types.js +11 -6
  10. package/dist/drive/referrals/index.js +5 -1
  11. package/dist/drive/referrals/types.js +2 -2
  12. package/dist/drive/share/index.d.ts +1 -1
  13. package/dist/drive/share/index.js +49 -44
  14. package/dist/drive/share/types.d.ts +31 -29
  15. package/dist/drive/storage/index.d.ts +130 -10
  16. package/dist/drive/storage/index.js +253 -53
  17. package/dist/drive/storage/types.d.ts +107 -21
  18. package/dist/drive/storage/types.js +2 -2
  19. package/dist/drive/trash/index.d.ts +22 -2
  20. package/dist/drive/trash/index.js +44 -9
  21. package/dist/drive/trash/types.d.ts +9 -0
  22. package/dist/drive/users/index.d.ts +30 -3
  23. package/dist/drive/users/index.js +40 -6
  24. package/dist/drive/users/types.d.ts +16 -6
  25. package/dist/index.d.ts +3 -2
  26. package/dist/index.js +12 -7
  27. package/dist/network/download.js +5 -5
  28. package/dist/network/errors/codes.d.ts +1 -1
  29. package/dist/network/errors/context.d.ts +4 -4
  30. package/dist/network/errors/context.js +2 -2
  31. package/dist/network/errors/download.js +5 -1
  32. package/dist/network/errors/index.js +5 -1
  33. package/dist/network/errors/upload.js +5 -1
  34. package/dist/network/index.d.ts +2 -3
  35. package/dist/network/index.js +14 -9
  36. package/dist/network/types.d.ts +16 -16
  37. package/dist/network/types.js +2 -2
  38. package/dist/network/upload.js +8 -9
  39. package/dist/photos/devices/index.js +8 -8
  40. package/dist/photos/index.js +5 -1
  41. package/dist/photos/photos/index.js +26 -26
  42. package/dist/photos/shares/index.js +3 -3
  43. package/dist/photos/types.d.ts +14 -14
  44. package/dist/photos/types.js +3 -3
  45. package/dist/photos/users/index.js +2 -2
  46. package/dist/shared/headers/index.d.ts +9 -6
  47. package/dist/shared/headers/index.js +27 -18
  48. package/dist/shared/http/client.d.ts +1 -1
  49. package/dist/shared/http/client.js +4 -13
  50. package/dist/shared/http/types.d.ts +4 -4
  51. package/dist/shared/index.js +5 -1
  52. package/dist/shared/types/apiConnection.d.ts +2 -1
  53. package/dist/shared/types/appsumo.js +1 -1
  54. package/dist/shared/types/errors.d.ts +2 -1
  55. package/dist/shared/types/errors.js +2 -1
  56. package/dist/shared/types/userSettings.d.ts +17 -1
  57. package/dist/utils.js +2 -3
  58. package/dist/workspaces/index.d.ts +176 -0
  59. package/dist/workspaces/index.js +419 -0
  60. package/dist/workspaces/index.test.d.ts +1 -0
  61. package/dist/workspaces/index.test.js +908 -0
  62. package/dist/workspaces/types.d.ts +294 -0
  63. package/dist/workspaces/types.js +2 -0
  64. package/package.json +13 -13
@@ -12,7 +12,11 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
14
  if (k2 === undefined) k2 = k;
15
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
15
+ var desc = Object.getOwnPropertyDescriptor(m, k);
16
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
17
+ desc = { enumerable: true, get: function() { return m[k]; } };
18
+ }
19
+ Object.defineProperty(o, k2, desc);
16
20
  }) : (function(o, m, k, k2) {
17
21
  if (k2 === undefined) k2 = k;
18
22
  o[k2] = m[k];
@@ -39,12 +43,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
39
43
  });
40
44
  };
41
45
  var __generator = (this && this.__generator) || function (thisArg, body) {
42
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
43
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
46
+ 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);
47
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
44
48
  function verb(n) { return function (v) { return step([n, v]); }; }
45
49
  function step(op) {
46
50
  if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
48
52
  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;
49
53
  if (y = 0, t) op = [op[0] & 2, t.value];
50
54
  switch (op[0]) {
@@ -90,6 +94,17 @@ var Storage = /** @class */ (function () {
90
94
  }, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
91
95
  return [promise, requestCanceler];
92
96
  };
97
+ /**
98
+ * Creates a new folder
99
+ * @param payload
100
+ */
101
+ Storage.prototype.createFolderByUuid = function (payload) {
102
+ var _a = this.client.postCancellable('/folders', {
103
+ plainName: payload.plainName,
104
+ parentFolderUuid: payload.parentFolderUuid,
105
+ }, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
106
+ return [promise, requestCanceler];
107
+ };
93
108
  /**
94
109
  * Moves a specific folder to a new location
95
110
  * @param payload
@@ -111,7 +126,7 @@ var Storage = /** @class */ (function () {
111
126
  Storage.prototype.moveFolderByUuid = function (payload) {
112
127
  return __awaiter(this, void 0, void 0, function () {
113
128
  return __generator(this, function (_a) {
114
- return [2 /*return*/, this.client.patch("/folders/" + payload.folderUuid, {
129
+ return [2 /*return*/, this.client.patch("/folders/".concat(payload.folderUuid), {
115
130
  destinationFolder: payload.destinationFolderUuid,
116
131
  }, this.headers())];
117
132
  });
@@ -125,7 +140,7 @@ var Storage = /** @class */ (function () {
125
140
  return __awaiter(this, void 0, void 0, function () {
126
141
  return __generator(this, function (_a) {
127
142
  switch (_a.label) {
128
- case 0: return [4 /*yield*/, this.client.post("/storage/folder/" + payload.folderId + "/meta", {
143
+ case 0: return [4 /*yield*/, this.client.post("/storage/folder/".concat(payload.folderId, "/meta"), {
129
144
  metadata: payload.changes,
130
145
  }, this.headers())];
131
146
  case 1:
@@ -135,6 +150,21 @@ var Storage = /** @class */ (function () {
135
150
  });
136
151
  });
137
152
  };
153
+ /**
154
+ * Updates the name of a folder with the given UUID.
155
+ *
156
+ * @param {Object} payload - The payload containing the folder UUID and the new name.
157
+ * @param {string} payload.folderUuid - The UUID of the folder to update.
158
+ * @param {string} payload.name - The new name for the folder.
159
+ * @param {Token} [resourcesToken] - An optional token for authentication.
160
+ * @return {Promise<void>} A promise that resolves when the folder name is successfully updated.
161
+ */
162
+ Storage.prototype.updateFolderNameWithUUID = function (payload, resourcesToken) {
163
+ var folderUuid = payload.folderUuid, name = payload.name;
164
+ return this.client.put("/folders/".concat(folderUuid, "/meta"), {
165
+ plainName: name,
166
+ }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
167
+ };
138
168
  /**
139
169
  * Fetches & returns the contents of a specific folder
140
170
  * @param folderId
@@ -142,15 +172,50 @@ var Storage = /** @class */ (function () {
142
172
  Storage.prototype.getFolderContent = function (folderId, trash) {
143
173
  if (trash === void 0) { trash = false; }
144
174
  var query = trash ? '/?trash=true' : '';
145
- var _a = this.client.getCancellable("/storage/v2/folder/" + folderId + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
175
+ var _a = this.client.getCancellable("/storage/v2/folder/".concat(folderId).concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
146
176
  return [promise, requestCanceler];
147
177
  };
148
178
  /**
149
- * Returns metadata of a specific file
150
- * @param fileId
179
+ * Fetches and returns the contents of a specific folder by its UUID.
180
+ *
181
+ * @param {string} folderUuid - The UUID of the folder.
182
+ * @param {boolean} [trash=false] - Whether to include trash items in the response.
183
+ * @param {boolean} [offset] - The position of the first file to return.
184
+ * @param {boolean} [limit] - The max number of files to be returned.
185
+ * @param {boolean} [workspacesToken] - Token for accessing workspaces.
186
+ * @return {[Promise<FetchFolderContentResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
151
187
  */
152
- Storage.prototype.getFile = function (fileId) {
153
- var _a = this.client.getCancellable("/files/" + fileId + "/meta", this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
188
+ Storage.prototype.getFolderContentByUuid = function (_a) {
189
+ var folderUuid = _a.folderUuid, _b = _a.trash, trash = _b === void 0 ? false : _b, offset = _a.offset, limit = _a.limit, workspacesToken = _a.workspacesToken;
190
+ var query = new URLSearchParams();
191
+ if (offset !== undefined)
192
+ query.set('offset', String(offset));
193
+ if (limit !== undefined)
194
+ query.set('limit', String(limit));
195
+ if (trash)
196
+ query.set('trash', 'true');
197
+ var customHeaders = workspacesToken
198
+ ? {
199
+ 'x-internxt-workspace': workspacesToken,
200
+ }
201
+ : undefined;
202
+ var _c = this.client.getCancellable("/folders/content/".concat(folderUuid, "?").concat(query), this.headers(customHeaders)), promise = _c.promise, requestCanceler = _c.requestCanceler;
203
+ return [promise, requestCanceler];
204
+ };
205
+ /**
206
+ * Retrieves a file with the specified fileId along with the associated workspacesToken.
207
+ *
208
+ * @param {string} fileId - The ID of the file to retrieve.
209
+ * @param {string} [workspacesToken] - Token for accessing workspaces.
210
+ * @return {[Promise<FileMeta>, RequestCanceler]} A promise with FileMeta and a canceler for the request.
211
+ */
212
+ Storage.prototype.getFile = function (fileId, workspacesToken) {
213
+ var customHeaders = workspacesToken
214
+ ? {
215
+ 'x-internxt-workspace': workspacesToken,
216
+ }
217
+ : undefined;
218
+ var _a = this.client.getCancellable("/files/".concat(fileId, "/meta"), this.headers(customHeaders)), promise = _a.promise, requestCanceler = _a.requestCanceler;
154
219
  return [promise, requestCanceler];
155
220
  };
156
221
  /**
@@ -168,12 +233,12 @@ var Storage = /** @class */ (function () {
168
233
  if (limit === void 0) { limit = 50; }
169
234
  if (sort === void 0) { sort = ''; }
170
235
  if (order === void 0) { order = ''; }
171
- var offsetQuery = "?offset=" + offset;
172
- var limitQuery = "&limit=" + limit;
173
- var sortQuery = sort !== '' ? "&sort=" + sort : '';
174
- var orderQuery = order !== '' ? "&order=" + order : '';
175
- var query = "" + offsetQuery + limitQuery + sortQuery + orderQuery;
176
- var _a = this.client.getCancellable("folders/" + folderId + "/files/" + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
236
+ var offsetQuery = "?offset=".concat(offset);
237
+ var limitQuery = "&limit=".concat(limit);
238
+ var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
239
+ var orderQuery = order !== '' ? "&order=".concat(order) : '';
240
+ var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
241
+ var _a = this.client.getCancellable("folders/".concat(folderId, "/files/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
177
242
  return [promise, requestCanceler];
178
243
  };
179
244
  /**
@@ -191,12 +256,12 @@ var Storage = /** @class */ (function () {
191
256
  if (limit === void 0) { limit = 50; }
192
257
  if (sort === void 0) { sort = ''; }
193
258
  if (order === void 0) { order = ''; }
194
- var offsetQuery = "?offset=" + offset;
195
- var limitQuery = "&limit=" + limit;
196
- var sortQuery = sort !== '' ? "&sort=" + sort : '';
197
- var orderQuery = order !== '' ? "&order=" + order : '';
198
- var query = "" + offsetQuery + limitQuery + sortQuery + orderQuery;
199
- var _a = this.client.getCancellable("folders/content/" + folderUuid + "/files/" + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
259
+ var offsetQuery = "?offset=".concat(offset);
260
+ var limitQuery = "&limit=".concat(limit);
261
+ var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
262
+ var orderQuery = order !== '' ? "&order=".concat(order) : '';
263
+ var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
264
+ var _a = this.client.getCancellable("folders/content/".concat(folderUuid, "/files/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
200
265
  return [promise, requestCanceler];
201
266
  };
202
267
  /**
@@ -214,12 +279,12 @@ var Storage = /** @class */ (function () {
214
279
  if (limit === void 0) { limit = 50; }
215
280
  if (sort === void 0) { sort = ''; }
216
281
  if (order === void 0) { order = ''; }
217
- var offsetQuery = "?offset=" + offset;
218
- var limitQuery = "&limit=" + limit;
219
- var sortQuery = sort !== '' ? "&sort=" + sort : '';
220
- var orderQuery = order !== '' ? "&order=" + order : '';
221
- var query = "" + offsetQuery + limitQuery + sortQuery + orderQuery;
222
- var _a = this.client.getCancellable("folders/" + folderId + "/folders/" + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
282
+ var offsetQuery = "?offset=".concat(offset);
283
+ var limitQuery = "&limit=".concat(limit);
284
+ var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
285
+ var orderQuery = order !== '' ? "&order=".concat(order) : '';
286
+ var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
287
+ var _a = this.client.getCancellable("folders/".concat(folderId, "/folders/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
223
288
  return [promise, requestCanceler];
224
289
  };
225
290
  /**
@@ -237,12 +302,12 @@ var Storage = /** @class */ (function () {
237
302
  if (limit === void 0) { limit = 50; }
238
303
  if (sort === void 0) { sort = ''; }
239
304
  if (order === void 0) { order = ''; }
240
- var offsetQuery = "?offset=" + offset;
241
- var limitQuery = "&limit=" + limit;
242
- var sortQuery = sort !== '' ? "&sort=" + sort : '';
243
- var orderQuery = order !== '' ? "&order=" + order : '';
244
- var query = "" + offsetQuery + limitQuery + sortQuery + orderQuery;
245
- var _a = this.client.getCancellable("folders/content/" + folderUuid + "/folders/" + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
305
+ var offsetQuery = "?offset=".concat(offset);
306
+ var limitQuery = "&limit=".concat(limit);
307
+ var sortQuery = sort !== '' ? "&sort=".concat(sort) : '';
308
+ var orderQuery = order !== '' ? "&order=".concat(order) : '';
309
+ var query = "".concat(offsetQuery).concat(limitQuery).concat(sortQuery).concat(orderQuery);
310
+ var _a = this.client.getCancellable("folders/content/".concat(folderUuid, "/folders/").concat(query), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
246
311
  return [promise, requestCanceler];
247
312
  };
248
313
  /**
@@ -250,7 +315,7 @@ var Storage = /** @class */ (function () {
250
315
  * @param folderId
251
316
  */
252
317
  Storage.prototype.deleteFolder = function (folderId) {
253
- return this.client.delete("/storage/folder/" + folderId, this.headers());
318
+ return this.client.delete("/storage/folder/".concat(folderId), this.headers());
254
319
  };
255
320
  /**
256
321
  * Returns the total size of a folder
@@ -258,7 +323,7 @@ var Storage = /** @class */ (function () {
258
323
  */
259
324
  Storage.prototype.getFolderSize = function (folderId) {
260
325
  return this.client
261
- .get("/storage/folder/size/" + folderId, this.headers())
326
+ .get("/storage/folder/size/".concat(folderId), this.headers())
262
327
  .then(function (response) {
263
328
  return response.size;
264
329
  });
@@ -281,6 +346,22 @@ var Storage = /** @class */ (function () {
281
346
  },
282
347
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
283
348
  };
349
+ /**
350
+ * Creates a new file entry
351
+ * @param fileEntry
352
+ */
353
+ Storage.prototype.createFileEntryByUuid = function (fileEntry, resourcesToken) {
354
+ return this.client.post('/files', {
355
+ name: fileEntry.name,
356
+ bucket: fileEntry.bucket,
357
+ fileId: fileEntry.id,
358
+ encryptVersion: fileEntry.encrypt_version,
359
+ folderUuid: fileEntry.folder_id,
360
+ size: fileEntry.size,
361
+ plainName: fileEntry.plain_name,
362
+ type: fileEntry.type,
363
+ }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
364
+ };
284
365
  /**
285
366
  * Creates a new thumbnail entry
286
367
  * @param thumbnailEntry
@@ -295,18 +376,46 @@ var Storage = /** @class */ (function () {
295
376
  * @param payload
296
377
  */
297
378
  Storage.prototype.updateFile = function (payload, resourcesToken) {
298
- return this.client.post("/storage/file/" + payload.fileId + "/meta", {
379
+ return this.client.post("/storage/file/".concat(payload.fileId, "/meta"), {
299
380
  metadata: payload.metadata,
300
381
  bucketId: payload.bucketId,
301
382
  relativePath: payload.destinationPath,
302
383
  }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
303
384
  };
385
+ /**
386
+ * Updates the name of a file with the given UUID.
387
+ *
388
+ * @param {Object} payload - The payload containing the UUID and new name of the file.
389
+ * @param {string} payload.fileUuid - The UUID of the file.
390
+ * @param {string} payload.name - The new name of the file.
391
+ * @param {string} [resourcesToken] - The token for accessing resources.
392
+ * @return {Promise<void>} - A Promise that resolves when the file name is successfully updated.
393
+ */
394
+ Storage.prototype.updateFileNameWithUUID = function (payload, resourcesToken) {
395
+ var fileUuid = payload.fileUuid, name = payload.name;
396
+ return this.client.put("/files/".concat(fileUuid, "/meta"), {
397
+ plainName: name,
398
+ }, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
399
+ };
400
+ /**
401
+ * Updates the name and the type from a given file UUID.
402
+ *
403
+ * @param {Object} payload - The payload containing the UUID and the new properties of the file.
404
+ * @param {string} payload.fileUuid - The UUID of the file.
405
+ * @param {string} payload.name - The new name of the file.
406
+ * @param {string} payload.type - The new type of the file.
407
+ * @param {string} [resourcesToken] - The token for accessing resources.
408
+ * @return {Promise<void>} - A Promise that resolves when the file name is successfully updated.
409
+ */
410
+ Storage.prototype.updateFileMetaByUUID = function (fileUuid, payload, resourcesToken) {
411
+ return this.client.put("/files/".concat(fileUuid, "/meta"), payload, (0, headers_1.addResourcesTokenToHeaders)(this.headers(), resourcesToken));
412
+ };
304
413
  /**
305
414
  * Deletes a specific file entry
306
415
  * @param payload
307
416
  */
308
417
  Storage.prototype.deleteFile = function (payload) {
309
- return this.client.delete("/storage/folder/" + payload.folderId + "/file/" + payload.fileId, this.headers());
418
+ return this.client.delete("/storage/folder/".concat(payload.folderId, "/file/").concat(payload.fileId), this.headers());
310
419
  };
311
420
  /**
312
421
  * Updates the persisted path of a file entry
@@ -327,7 +436,7 @@ var Storage = /** @class */ (function () {
327
436
  Storage.prototype.moveFileByUuid = function (payload) {
328
437
  return __awaiter(this, void 0, void 0, function () {
329
438
  return __generator(this, function (_a) {
330
- return [2 /*return*/, this.client.patch("/files/" + payload.fileUuid, {
439
+ return [2 /*return*/, this.client.patch("/files/".concat(payload.fileUuid), {
331
440
  destinationFolder: payload.destinationFolderUuid,
332
441
  }, this.headers())];
333
442
  });
@@ -336,9 +445,21 @@ var Storage = /** @class */ (function () {
336
445
  /**
337
446
  * Returns a list of the n most recent files
338
447
  * @param limit
448
+ * @deprecated use `getRecentFilesV2` call instead.
339
449
  */
340
450
  Storage.prototype.getRecentFiles = function (limit) {
341
- return this.client.get("/storage/recents?limit=" + limit, this.headers());
451
+ return this.client.get("/storage/recents?limit=".concat(limit), this.headers());
452
+ };
453
+ /**
454
+ * Returns a list of the n most recent files
455
+ * @param limit
456
+ */
457
+ Storage.prototype.getRecentFilesV2 = function (limit) {
458
+ return __awaiter(this, void 0, void 0, function () {
459
+ return __generator(this, function (_a) {
460
+ return [2 /*return*/, this.client.get("/files/recents?limit=".concat(limit), this.headers())];
461
+ });
462
+ });
342
463
  };
343
464
  /**
344
465
  * Returns a list of items in trash
@@ -379,27 +500,33 @@ var Storage = /** @class */ (function () {
379
500
  * Get global search items.
380
501
  *
381
502
  * @param {string} search - The name of the item.
503
+ * @param {string} workspaceId - The ID of the workspace (optional).
382
504
  * @returns {[Promise<SearchResultData>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
383
505
  */
384
- Storage.prototype.getGlobalSearchItems = function (search) {
385
- var _a = this.client.getCancellable("fuzzy/" + search, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
506
+ Storage.prototype.getGlobalSearchItems = function (search, workspaceId) {
507
+ var _a = workspaceId
508
+ ? this.client.getCancellable("workspaces/".concat(workspaceId, "/fuzzy/").concat(search), this.headers())
509
+ : this.client.getCancellable("fuzzy/".concat(search), this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
386
510
  return [promise, requestCanceler];
387
511
  };
388
512
  /**
389
513
  * Returns the needed headers for the module requests
390
514
  * @private
391
515
  */
392
- Storage.prototype.headers = function () {
393
- return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token);
516
+ Storage.prototype.headers = function (customHeaders) {
517
+ var _a;
518
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, (_a = this.apiSecurity) === null || _a === void 0 ? void 0 : _a.workspaceToken, customHeaders);
394
519
  };
395
520
  /**
396
521
  * Gets the ancestors of a given folder UUID
397
522
  *
398
- * @param {string} folderUUID - UUID of the folder.
399
- * @returns {Promise<FolderAncestor[]>}
523
+ * @param {string} uuid - UUID of the folder.
524
+ * @param {boolean} [isShared=false] - Whether the folder is a shared item or not.
525
+ * @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
400
526
  */
401
- Storage.prototype.getFolderAncestors = function (uuid) {
402
- return this.client.get("folders/" + uuid + "/ancestors", this.headers());
527
+ Storage.prototype.getFolderAncestors = function (uuid, isShared) {
528
+ if (isShared === void 0) { isShared = false; }
529
+ return this.client.get("folders/".concat(uuid, "/ancestors?isSharedItem=").concat(isShared), this.headers());
403
530
  };
404
531
  /**
405
532
  * Gets the meta of a given folder UUID
@@ -407,8 +534,13 @@ var Storage = /** @class */ (function () {
407
534
  * @param {string} folderUUID - UUID of the folder.
408
535
  * @returns {Promise<FolderMeta>}
409
536
  */
410
- Storage.prototype.getFolderMeta = function (uuid) {
411
- return this.client.get("folders/" + uuid + "/meta", this.headers());
537
+ Storage.prototype.getFolderMeta = function (uuid, workspacesToken, resourcesToken) {
538
+ var customHeaders = workspacesToken
539
+ ? {
540
+ 'x-internxt-workspace': workspacesToken,
541
+ }
542
+ : undefined;
543
+ return this.client.get("folders/".concat(uuid, "/meta"), (0, headers_1.addResourcesTokenToHeaders)(this.headers(customHeaders), resourcesToken));
412
544
  };
413
545
  /**
414
546
  * Gets the meta of a given folder Id
@@ -417,7 +549,7 @@ var Storage = /** @class */ (function () {
417
549
  * @returns {Promise<FolderMeta>}
418
550
  */
419
551
  Storage.prototype.getFolderMetaById = function (folderId) {
420
- return this.client.get("folders/" + folderId + "/metadata", this.headers());
552
+ return this.client.get("folders/".concat(folderId, "/metadata"), this.headers());
421
553
  };
422
554
  /**
423
555
  * Replaces a file with a new one.
@@ -427,7 +559,75 @@ var Storage = /** @class */ (function () {
427
559
  * @returns {Promise<DriveFileData>} - The replaced file data.
428
560
  */
429
561
  Storage.prototype.replaceFile = function (uuid, payload) {
430
- return this.client.put("/files/" + uuid, __assign({}, payload), this.headers());
562
+ return this.client.put("/files/".concat(uuid), __assign({}, payload), this.headers());
563
+ };
564
+ /**
565
+ * Checks the size limit for a file.
566
+ *
567
+ * @param {number} size - The size of the file to check.
568
+ * @return {Promise<void>} - A promise that resolves when the size limit check is complete.
569
+ */
570
+ Storage.prototype.checkSizeLimit = function (size) {
571
+ return __awaiter(this, void 0, void 0, function () {
572
+ return __generator(this, function (_a) {
573
+ return [2 /*return*/, this.client.post('/files/check-size-limit', {
574
+ file: {
575
+ size: size,
576
+ },
577
+ }, this.headers())];
578
+ });
579
+ });
580
+ };
581
+ /**
582
+ * Retrieves the folder tree based on the UUID.
583
+ *
584
+ * @param {string} uuid - The UUID of the folder.
585
+ * @return {Promise<FolderTreeResponse>} The promise containing the folder tree response.
586
+ */
587
+ Storage.prototype.getFolderTree = function (uuid) {
588
+ return this.client.get("/folders/".concat(uuid, "/tree"), this.headers());
589
+ };
590
+ /**
591
+ * Checks if the given files already exist in the given folder.
592
+ *
593
+ * @param {CheckDuplicatedFilesPayload} payload - Payload containing the folder UUID and the list of files to check.
594
+ * @return {Promise<CheckDuplicatedFilesResponse>} - Promise that contains the duplicated files in a list.
595
+ */
596
+ Storage.prototype.checkDuplicatedFiles = function (_a) {
597
+ var folderUuid = _a.folderUuid, filesList = _a.filesList;
598
+ return this.client.post("/folders/content/".concat(folderUuid, "/files/existence"), {
599
+ files: filesList,
600
+ }, this.headers());
601
+ };
602
+ /**
603
+ * Checks if the given folders names already exist in the given folder
604
+ *
605
+ * @param {CheckDuplicatedFolderPayload} payload - Payload containing the folder UUID and the list of folders to check.
606
+ * @return {Promise<CheckDuplicatedFoldersResponse>} - Promise that contains the duplicated folders in a list.
607
+ */
608
+ Storage.prototype.checkDuplicatedFolders = function (_a) {
609
+ var folderUuid = _a.folderUuid, folderNamesList = _a.folderNamesList;
610
+ return this.client.post("/folders/content/".concat(folderUuid, "/folders/existence"), {
611
+ plainNames: folderNamesList,
612
+ }, this.headers());
613
+ };
614
+ /**
615
+ * Gets the folder meta from a given path (e.g. "/folder1/folder2")
616
+ *
617
+ * @param {string} folderPath - The path of the folder.
618
+ * @returns {Promise<FolderMeta>} A promise that resolves the folder on that path.
619
+ */
620
+ Storage.prototype.getFolderByPath = function (folderPath) {
621
+ return this.client.get("folders/meta?path=".concat(folderPath), this.headers());
622
+ };
623
+ /**
624
+ * Gets the file meta from a given path (e.g. "/folder1/folder2/file.png")
625
+ *
626
+ * @param {string} filePath - The path of the file.
627
+ * @returns {Promise<FileMeta>} A promise that resolves the file on that path.
628
+ */
629
+ Storage.prototype.getFileByPath = function (filePath) {
630
+ return this.client.get("files/meta?path=".concat(filePath), this.headers());
431
631
  };
432
632
  return Storage;
433
633
  }());