@internxt/sdk 1.5.25 → 1.6.4

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 (93) hide show
  1. package/dist/auth/index.d.ts +127 -122
  2. package/dist/auth/index.js +378 -310
  3. package/dist/auth/types.d.ts +65 -54
  4. package/dist/auth/types.js +26 -26
  5. package/dist/drive/backups/index.d.ts +18 -18
  6. package/dist/drive/backups/index.js +40 -40
  7. package/dist/drive/backups/types.d.ts +27 -27
  8. package/dist/drive/backups/types.js +2 -2
  9. package/dist/drive/index.d.ts +7 -7
  10. package/dist/drive/index.js +23 -19
  11. package/dist/drive/payments/index.d.ts +66 -71
  12. package/dist/drive/payments/index.js +206 -208
  13. package/dist/drive/payments/types.d.ts +180 -176
  14. package/dist/drive/payments/types.js +37 -37
  15. package/dist/drive/referrals/index.d.ts +19 -19
  16. package/dist/drive/referrals/index.js +54 -50
  17. package/dist/drive/referrals/types.d.ts +21 -21
  18. package/dist/drive/referrals/types.js +18 -18
  19. package/dist/drive/share/index.d.ts +319 -319
  20. package/dist/drive/share/index.js +544 -540
  21. package/dist/drive/share/types.d.ts +360 -360
  22. package/dist/drive/share/types.js +2 -2
  23. package/dist/drive/storage/index.d.ts +315 -315
  24. package/dist/drive/storage/index.js +634 -630
  25. package/dist/drive/storage/types.d.ts +480 -473
  26. package/dist/drive/storage/types.js +13 -13
  27. package/dist/drive/trash/index.d.ts +75 -75
  28. package/dist/drive/trash/index.js +184 -180
  29. package/dist/drive/trash/types.d.ts +29 -29
  30. package/dist/drive/trash/types.js +2 -2
  31. package/dist/drive/users/index.d.ts +135 -135
  32. package/dist/drive/users/index.js +208 -204
  33. package/dist/drive/users/types.d.ts +53 -51
  34. package/dist/drive/users/types.js +2 -2
  35. package/dist/index.d.ts +6 -6
  36. package/dist/index.js +35 -31
  37. package/dist/network/download.d.ts +8 -8
  38. package/dist/network/download.js +123 -123
  39. package/dist/network/errors/codes.d.ts +24 -24
  40. package/dist/network/errors/codes.js +48 -48
  41. package/dist/network/errors/context.d.ts +35 -35
  42. package/dist/network/errors/context.js +39 -39
  43. package/dist/network/errors/download.d.ts +4 -4
  44. package/dist/network/errors/download.js +52 -48
  45. package/dist/network/errors/index.d.ts +3 -3
  46. package/dist/network/errors/index.js +19 -15
  47. package/dist/network/errors/upload.d.ts +13 -13
  48. package/dist/network/errors/upload.js +82 -78
  49. package/dist/network/index.d.ts +70 -70
  50. package/dist/network/index.js +315 -311
  51. package/dist/network/types.d.ts +102 -102
  52. package/dist/network/types.js +18 -18
  53. package/dist/network/upload.d.ts +4 -4
  54. package/dist/network/upload.js +158 -159
  55. package/dist/photos/devices/index.d.ts +10 -10
  56. package/dist/photos/devices/index.js +79 -79
  57. package/dist/photos/index.d.ts +17 -17
  58. package/dist/photos/index.js +56 -52
  59. package/dist/photos/photos/index.d.ts +60 -60
  60. package/dist/photos/photos/index.js +225 -225
  61. package/dist/photos/shares/index.d.ts +8 -8
  62. package/dist/photos/shares/index.js +34 -34
  63. package/dist/photos/types.d.ts +154 -154
  64. package/dist/photos/types.js +19 -19
  65. package/dist/photos/users/index.d.ts +7 -7
  66. package/dist/photos/users/index.js +46 -46
  67. package/dist/shared/headers/index.d.ts +21 -21
  68. package/dist/shared/headers/index.js +78 -79
  69. package/dist/shared/http/client.d.ts +85 -85
  70. package/dist/shared/http/client.js +172 -172
  71. package/dist/shared/http/types.d.ts +7 -7
  72. package/dist/shared/http/types.js +2 -2
  73. package/dist/shared/index.d.ts +1 -1
  74. package/dist/shared/index.js +17 -13
  75. package/dist/shared/types/apiConnection.d.ts +12 -12
  76. package/dist/shared/types/apiConnection.js +2 -2
  77. package/dist/shared/types/appsumo.d.ts +16 -16
  78. package/dist/shared/types/appsumo.js +12 -12
  79. package/dist/shared/types/errors.d.ts +5 -5
  80. package/dist/shared/types/errors.js +28 -28
  81. package/dist/shared/types/teams.d.ts +9 -9
  82. package/dist/shared/types/teams.js +2 -2
  83. package/dist/shared/types/userSettings.d.ts +43 -29
  84. package/dist/shared/types/userSettings.js +2 -2
  85. package/dist/utils.d.ts +3 -3
  86. package/dist/utils.js +24 -25
  87. package/dist/workspaces/index.d.ts +176 -176
  88. package/dist/workspaces/index.js +419 -415
  89. package/dist/workspaces/index.test.d.ts +1 -1
  90. package/dist/workspaces/index.test.js +908 -903
  91. package/dist/workspaces/types.d.ts +294 -291
  92. package/dist/workspaces/types.js +2 -2
  93. package/package.json +13 -13
@@ -1,540 +1,544 @@
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
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
16
- }) : (function(o, m, k, k2) {
17
- if (k2 === undefined) k2 = k;
18
- o[k2] = m[k];
19
- }));
20
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
- Object.defineProperty(o, "default", { enumerable: true, value: v });
22
- }) : function(o, v) {
23
- o["default"] = v;
24
- });
25
- var __importStar = (this && this.__importStar) || function (mod) {
26
- if (mod && mod.__esModule) return mod;
27
- var result = {};
28
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
29
- __setModuleDefault(result, mod);
30
- return result;
31
- };
32
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
33
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
34
- return new (P || (P = Promise))(function (resolve, reject) {
35
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
37
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
38
- step((generator = generator.apply(thisArg, _arguments || [])).next());
39
- });
40
- };
41
- 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;
44
- function verb(n) { return function (v) { return step([n, v]); }; }
45
- function step(op) {
46
- if (f) throw new TypeError("Generator is already executing.");
47
- while (_) try {
48
- 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
- if (y = 0, t) op = [op[0] & 2, t.value];
50
- switch (op[0]) {
51
- case 0: case 1: t = op; break;
52
- case 4: _.label++; return { value: op[1], done: false };
53
- case 5: _.label++; y = op[1]; op = [0]; continue;
54
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
55
- default:
56
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
57
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
58
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
59
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
60
- if (t[2]) _.ops.pop();
61
- _.trys.pop(); continue;
62
- }
63
- op = body.call(thisArg, _);
64
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
65
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
66
- }
67
- };
68
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
69
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
70
- if (ar || !(i in from)) {
71
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
72
- ar[i] = from[i];
73
- }
74
- }
75
- return to.concat(ar || Array.prototype.slice.call(from));
76
- };
77
- Object.defineProperty(exports, "__esModule", { value: true });
78
- exports.Share = exports.ShareTypes = void 0;
79
- var headers_1 = require("../../shared/headers");
80
- var client_1 = require("../../shared/http/client");
81
- exports.ShareTypes = __importStar(require("./types"));
82
- var Share = /** @class */ (function () {
83
- function Share(apiUrl, appDetails, apiSecurity) {
84
- this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
85
- this.appDetails = appDetails;
86
- this.apiSecurity = apiSecurity;
87
- }
88
- Share.client = function (apiUrl, appDetails, apiSecurity) {
89
- return new Share(apiUrl, appDetails, apiSecurity);
90
- };
91
- /**
92
- * Fetches the list of shared items
93
- */
94
- Share.prototype.getShareLinks = function (page, perPage, orderBy) {
95
- if (page === void 0) { page = 0; }
96
- if (perPage === void 0) { perPage = 50; }
97
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
98
- return this.client.get("/storage/share/list?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
99
- };
100
- /**
101
- * Creates a new link to share a file or folder
102
- * @param payload
103
- */
104
- Share.prototype.createShareLink = function (payload) {
105
- var types = ['file', 'folder'];
106
- if (!types.includes(payload.type)) {
107
- throw new Error('Invalid type');
108
- }
109
- return this.client.post("/storage/share/" + payload.type + "/" + payload.itemId, {
110
- timesValid: payload.timesValid,
111
- encryptedMnemonic: payload.encryptedMnemonic,
112
- itemToken: payload.itemToken,
113
- bucket: payload.bucket,
114
- encryptedCode: payload.encryptedCode,
115
- plainPassword: payload.plainPassword,
116
- }, this.headers());
117
- };
118
- /**
119
- * Update share link
120
- * @param payload
121
- */
122
- Share.prototype.updateShareLink = function (payload) {
123
- return this.client.put("/storage/share/" + payload.itemId, {
124
- plainPassword: payload.plainPassword,
125
- }, this.headers());
126
- };
127
- /**
128
- * Delete share link by id
129
- * @param payload
130
- */
131
- Share.prototype.deleteShareLink = function (shareId) {
132
- return this.client.delete("/storage/share/" + shareId, this.headers());
133
- };
134
- /**
135
- * Increment share view by token
136
- * @param token
137
- */
138
- Share.prototype.incrementShareViewByToken = function (token) {
139
- return this.client.put("/storage/share/" + token + "/view", {}, this.headers());
140
- };
141
- /**
142
- * Fetches data of a shared file
143
- * @param token
144
- */
145
- Share.prototype.getShareLink = function (token, password) {
146
- var headers = password ? this.basicHeadersWithPassword(password) : this.basicHeaders();
147
- return this.client.get("/storage/share/" + token, headers);
148
- };
149
- /**
150
- * Fetches paginated folders or files of a specific share link
151
- * @param payload
152
- */
153
- Share.prototype.getShareLinkDirectory = function (payload) {
154
- var types = ['file', 'folder'];
155
- if (!types.includes(payload.type)) {
156
- throw new Error('Invalid type');
157
- }
158
- var headers = this.basicHeaders();
159
- if (payload.password) {
160
- headers = this.basicHeadersWithPassword(payload.password);
161
- }
162
- return this.client.get("/storage/share/down/" + payload.type + "s?token=" + payload.token + "&folderId=" + payload.folderId + "&parentId=" + payload.parentId + "&page=" + payload.page + "&perPage=" + payload.perPage + (payload.code ? '&code=' + payload.code : ''), headers);
163
- };
164
- Share.prototype.getShareDomains = function () {
165
- return this.client.get('/storage/share/domains', this.headers());
166
- };
167
- /**
168
- * Get size of folder in share links
169
- * @param payload
170
- */
171
- Share.prototype.getShareLinkFolderSize = function (payload) {
172
- return this.client.get("/storage/share/" + payload.itemId + "/folder/" + payload.folderId + "/size", this.basicHeaders());
173
- };
174
- /**
175
- * Fetches all folders shared by a user.
176
- *
177
- * @param {number} page - The page number for pagination.
178
- * @param {number} perPage - The number of items per page for pagination.
179
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
180
- * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
181
- */
182
- Share.prototype.getSentSharedFolders = function (page, perPage, orderBy) {
183
- if (page === void 0) { page = 0; }
184
- if (perPage === void 0) { perPage = 50; }
185
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
186
- return this.client.get("sharings/shared-by-me/folders?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
187
- };
188
- /**
189
- * Fetches folders shared with a user.
190
- *
191
- * @param {number} page - The page number for pagination.
192
- * @param {number} perPage - The number of items per page for pagination.
193
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
194
- * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
195
- */
196
- Share.prototype.getReceivedSharedFolders = function (page, perPage, orderBy) {
197
- if (page === void 0) { page = 0; }
198
- if (perPage === void 0) { perPage = 50; }
199
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
200
- return this.client.get("sharings/shared-with-me/folders?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
201
- };
202
- /**
203
- * Fetches all shared folders.
204
- *
205
- * @param {number} page - The page number for pagination.
206
- * @param {number} perPage - The number of items per page for pagination.
207
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
208
- * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
209
- */
210
- Share.prototype.getAllSharedFolders = function (page, perPage, orderBy) {
211
- if (page === void 0) { page = 0; }
212
- if (perPage === void 0) { perPage = 50; }
213
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
214
- return this.client.get("sharings/folders?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
215
- };
216
- /**
217
- * Fetches all shared files.
218
- *
219
- * @param {number} page - The page number for pagination.
220
- * @param {number} perPage - The number of items per page for pagination.
221
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
222
- * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
223
- */
224
- Share.prototype.getAllSharedFiles = function (page, perPage, orderBy) {
225
- if (page === void 0) { page = 0; }
226
- if (perPage === void 0) { perPage = 50; }
227
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
228
- return this.client.get("sharings/files?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
229
- };
230
- /**
231
- * Get all users with access to a shared folder.
232
- *
233
- * @param {string} folderUUID - The UUID of the folder.
234
- * @param {number} page - The page number for pagination.
235
- * @param {number} perPage - The number of items per page for pagination.
236
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
237
- * @returns {Promise<{ users: SharedFolderUser[] }>} A promise containing the list of users with access to the folder.
238
- */
239
- Share.prototype.getSharedFolderUsers = function (folderUUID, page, perPage, orderBy) {
240
- if (page === void 0) { page = 0; }
241
- if (perPage === void 0) { perPage = 50; }
242
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
243
- return this.client.get("sharings/shared-with/" + folderUUID + "?page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
244
- };
245
- /**
246
- * Get shared folder content
247
- * @param {string} sharedFolderId - The UUID of the shared folder.
248
- * @param {string} type - The item type for the query folders/files
249
- * @param {string} token - Key that enables invited users to navigate the folders
250
- * @param {number} page - The page number for pagination.
251
- * @param {number} perPage - The number of items per page for pagination.
252
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
253
- */
254
- Share.prototype.getSharedFolderContent = function (sharedFolderId, type, token, page, perPage, orderBy) {
255
- if (page === void 0) { page = 0; }
256
- if (perPage === void 0) { perPage = 50; }
257
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
258
- return this.client.get("sharings/items/" + sharedFolderId + "/" + type + "?token=" + token + "&page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
259
- };
260
- /**
261
- * Get public shared folder content
262
- * @param {string} sharedFolderId - The UUID of the shared folder.
263
- * @param {string} type - The item type for the query folders/files
264
- * @param {string} token - Key that enables invited users to navigate the folders
265
- * @param {number} page - The page number for pagination.
266
- * @param {number} perPage - The number of items per page for pagination.
267
- * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
268
- */
269
- Share.prototype.getPublicSharedFolderContent = function (sharedFolderId, type, token, page, perPage, code, orderBy) {
270
- if (page === void 0) { page = 0; }
271
- if (perPage === void 0) { perPage = 50; }
272
- if (code === void 0) { code = ''; }
273
- var orderByQueryParam = orderBy ? "&orderBy=" + orderBy : '';
274
- return this.client.get(
275
- // eslint-disable-next-line max-len
276
- "sharings/public/items/" + sharedFolderId + "/" + type + "?token=" + token + "&code=" + code + "&page=" + page + "&perPage=" + perPage + orderByQueryParam, this.headers());
277
- };
278
- /**
279
- * Get the role of a user on a folder.
280
- *
281
- * @param {string} options.sharingId - The unique identifier of the sharing.
282
- * @returns {Promise<Role>} A promise containing the role of the current user in the sharing.
283
- */
284
- Share.prototype.getUserRole = function (sharingId) {
285
- return this.client.get("sharings/" + sharingId + "/role", this.headers());
286
- };
287
- /**
288
- * Update the role of a user on a folder.
289
- *
290
- * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
291
- * @param {string} options.sharingId - The unique identifier of the user to whom we will update the role.
292
- * @param {string} options.newRoleId - The new role Id.
293
- * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
294
- */
295
- Share.prototype.updateUserRole = function (_a) {
296
- var sharingId = _a.sharingId, newRoleId = _a.newRoleId;
297
- return this.client.put("sharings/" + sharingId + "/role", {
298
- roleId: newRoleId,
299
- }, this.headers());
300
- };
301
- /**
302
- * Remove user from shared folder.
303
- *
304
- * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
305
- * @param {string} options.itemType - The unique identifier of the folder.
306
- * @param {string} options.itemId - The identifier of the role to assign to the user.
307
- * @param {string} options.userId - The role Id how we want to delete.
308
- * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
309
- */
310
- Share.prototype.removeUserRole = function (_a) {
311
- var itemType = _a.itemType, itemId = _a.itemId, userId = _a.userId;
312
- return this.client.delete("sharings/" + itemType + "/" + itemId + "/users/" + userId, this.headers());
313
- };
314
- /**
315
- * Get private folder data.
316
- *
317
- * @param {string} itemId - The itemId of the folder.
318
- * @param {string} itemType - The itemType of the folder (file | folder).
319
- * @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
320
- */
321
- Share.prototype.getSharedFolderInvitations = function (_a) {
322
- var itemId = _a.itemId, itemType = _a.itemType;
323
- return this.client.get("sharings/" + itemType + "/" + itemId + "/invites", this.headers());
324
- };
325
- /**
326
- * Get all invitations for a user.
327
- * @param limit - The number of items per page for pagination.
328
- * @param offset - The page number for pagination.
329
- * @returns {Promise<invites: any>} A promise containing the list of invitations.
330
- */
331
- Share.prototype.getSharedFolderInvitationsAsInvitedUser = function (_a) {
332
- var limit = _a.limit, offset = _a.offset;
333
- return this.client.get("sharings/invites?limit=" + limit + "&offset=" + offset, this.headers());
334
- };
335
- /**
336
- * Share a private folder with a user.
337
- *
338
- * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
339
- * @param {string} options.itemId - The id of the item to share.
340
- * @param {string} options.itemType - The type of the item to share (folder | file).
341
- * @param {string} options.sharedWith - The email address of the user to share the folder with.
342
- * @param {string} options.encryptionKey - Owner\'s encryption key encrypted with the invited user\'s public key. This field should not be empty if the invitation type is "OWNER".
343
- * @param {string} options.encryptionAlgorithm - Encryption algorithm used to encrypt the encryption key. This field should not be empty if the invitation type is "OWNER".
344
- * @param {string} options.type - Owner's encryption key encrypted with the invited user's public key.
345
- * @param {string} options.roleId - The id of the role to assign to the user.
346
- * @param {string} options.notifyUser - If it has to notify the users
347
- * @param {string} options.notificationMessage - Message of the notificacion
348
- *
349
- *
350
- * @returns {Promise<SharingInvite>} A promise that resolves when the folder is shared with the user.
351
- */
352
- Share.prototype.inviteUserToSharedFolder = function (createInviteDto) {
353
- return this.client.post('sharings/invites/send', __assign(__assign({}, createInviteDto), { type: 'OWNER' }), this.headers());
354
- };
355
- /**
356
- * Create a sharing.
357
- */
358
- Share.prototype.createSharing = function (createSharingPayload) {
359
- return this.client.post('sharings', __assign({}, createSharingPayload), this.headers());
360
- };
361
- /**
362
- * Get sharing meta with code
363
- */
364
- Share.prototype.getSharingMeta = function (sharingId, code, password) {
365
- var extraHeaders = password ? { 'x-share-password': password } : {};
366
- return this.client.get("sharings/" + sharingId + "/meta?code=" + code, __assign(__assign({}, this.headers()), extraHeaders));
367
- };
368
- /**
369
- * Add/edit sharing Password
370
- * @param {string} sharingId - id of sharing.
371
- * @param {string} encryptedPassword - password encrypted with CODE as key
372
- * @returns {Promise<SharingMeta>} A promise that returns the sharing info with the new encrypted password
373
- */
374
- Share.prototype.saveSharingPassword = function (sharingId, encryptedPassword) {
375
- return this.client.patch("sharings/" + sharingId + "/password", {
376
- encryptedPassword: encryptedPassword,
377
- }, this.headers());
378
- };
379
- /**
380
- * Remove password protection from sharing
381
- * @param {string} sharingId - id of sharing.
382
- * @returns {Promise<void>} A promise that resolves when password was successfully deleted.
383
- */
384
- Share.prototype.removeSharingPassword = function (sharingId) {
385
- return this.client.delete("sharings/" + sharingId + "/password", this.headers());
386
- };
387
- /**
388
- * Get public information of the item shared.
389
- * @param {string} sharingId - id of sharing.
390
- * @returns {Promise<PublicSharedItemInfo>} A promise that returns data of the public shared item.
391
- */
392
- Share.prototype.getPublicSharedItemInfo = function (sharingId) {
393
- return this.client.get("sharings/public/" + sharingId + "/item", this.headers());
394
- };
395
- /**
396
- * Request access to shared folder.
397
- */
398
- Share.prototype.requestUserToSharedFolder = function (createInviteDto) {
399
- return this.client.post('sharings/invites/send', __assign(__assign({}, createInviteDto), { type: 'SELF' }), this.headers());
400
- };
401
- /**
402
- * Check if the expirationDate of invite is valid.
403
- * @param {string} invitationId - The id of the invitation.
404
-
405
- * @returns {Promise<{uuid: string}>} A promise returning the uuid of the invitation if valid.
406
- */
407
- Share.prototype.validateInviteExpiration = function (invitationId) {
408
- return this.client.get("sharings/invites/" + invitationId + "/validate", this.headers());
409
- };
410
- /**
411
- * Share a private folder with a user.
412
- * @param {string} invitationId - The id of the invitation.
413
- * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
414
- * @param {string} options.encryptionKey - The encryption key (just in case the invitation is a request).
415
- * @param {string} options.itemType - The encryption algorithm (just in case the invitation is a request).
416
-
417
- * @returns {Promise<void>} A promise that resolves when the folder is shared with the user.
418
- */
419
- Share.prototype.acceptSharedFolderInvite = function (_a) {
420
- var invitationId = _a.invitationId, acceptInvite = _a.acceptInvite, token = _a.token;
421
- var headers = this.getRequestHeaders(token);
422
- return this.client.post("sharings/invites/" + invitationId + "/accept", {
423
- acceptInvite: acceptInvite,
424
- }, headers);
425
- };
426
- /**
427
- * Change Sharing Mode.
428
- * @param {string} options.itemType - folder | file
429
- * @param {string} options.itemId - id of folder or file
430
- * @param {string} options.sharingType - New Sharing type.
431
-
432
- * @returns {Promise<void>} A promise that resolves when sharing mode has been updated.
433
- */
434
- Share.prototype.updateSharingType = function (_a) {
435
- var itemId = _a.itemId, itemType = _a.itemType, sharingType = _a.sharingType;
436
- var headers = this.headers();
437
- return this.client.put("sharings/" + itemType + "/" + itemId + "/type", {
438
- sharingType: sharingType,
439
- }, headers);
440
- };
441
- /**
442
- * Get Sharing type
443
- * @param {string} options.itemType - folder | file
444
- * @param {string} options.itemId - id of folder or file
445
- * @returns {Promise<SharingMeta>} A promise that returns the sharing data.
446
- */
447
- Share.prototype.getSharingType = function (_a) {
448
- var itemId = _a.itemId, itemType = _a.itemType;
449
- var headers = this.headers();
450
- return this.client.get("sharings/" + itemType + "/" + itemId + "/type", headers);
451
- };
452
- Share.prototype.declineSharedFolderInvite = function (invitationId, token) {
453
- var headers = this.getRequestHeaders(token);
454
- return this.client.delete("sharings/invites/" + invitationId, headers);
455
- };
456
- /**
457
- * Fetches roles for sharing items.
458
- *
459
- * @returns {Promise<PrivateSharingRolesResponse>} A promise containing the list of sharing roles.
460
- */
461
- Share.prototype.getSharingRoles = function () {
462
- return this.client.get('/sharings/roles', this.headers());
463
- };
464
- Share.prototype.getAllAccessUsers = function (_a) {
465
- var itemType = _a.itemType, folderId = _a.folderId;
466
- return this.client.get("sharings/shared-with/" + itemType + "/" + folderId, this.headers());
467
- };
468
- /**
469
- * Stop sharing folder
470
- * @param {string} itemType - Type of the sharing to delete
471
- * @param {string} itemId - Id of the sharing to delete
472
- * @returns
473
- */
474
- Share.prototype.stopSharingFolder = function (itemType, itemId) {
475
- return __awaiter(this, void 0, void 0, function () {
476
- return __generator(this, function (_a) {
477
- switch (_a.label) {
478
- case 0: return [4 /*yield*/, this.client.delete("sharings/" + itemType + "/" + itemId, this.headers())];
479
- case 1:
480
- _a.sent();
481
- return [2 /*return*/];
482
- }
483
- });
484
- });
485
- };
486
- /**
487
- * Returns the needed headers for the module requests
488
- * @private
489
- */
490
- Share.prototype.headers = function (password) {
491
- var args = [
492
- this.appDetails.clientName,
493
- this.appDetails.clientVersion,
494
- this.apiSecurity.token,
495
- this.apiSecurity.workspaceToken,
496
- ];
497
- if (password) {
498
- return headers_1.headersWithTokenAndPassword.apply(void 0, __spreadArray(__spreadArray([], args, false), [password], false));
499
- }
500
- return headers_1.headersWithToken.apply(void 0, args);
501
- };
502
- /**
503
- * Returns the needed headers for the module requests
504
- * @private
505
- */
506
- Share.prototype.basicHeaders = function () {
507
- return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
508
- };
509
- /**
510
- * Used to send the password in shares
511
- * @private
512
- */
513
- Share.prototype.basicHeadersWithPassword = function (password) {
514
- return (0, headers_1.basicHeadersWithPassword)(this.appDetails.clientName, this.appDetails.clientVersion, password);
515
- };
516
- /**
517
- * Get request headers with optional authorization token.
518
- *
519
- * @param {string} [token] - Optional authorization token.
520
- * @returns {Object} - Request headers object.
521
- */
522
- Share.prototype.getRequestHeaders = function (token) {
523
- var headers = __assign({}, this.headers());
524
- if (token) {
525
- headers.Authorization = 'Bearer ' + token;
526
- }
527
- return headers;
528
- };
529
- /**
530
- * Gets the size of a shared folder given sharing id
531
- *
532
- * @param {string} sharingId - Sharing ID.
533
- * @returns {Promise<SharedFolderSize>}
534
- */
535
- Share.prototype.getSharedFolderSize = function (id) {
536
- return this.client.get("sharings/public/" + id + "/folder/size", this.headers());
537
- };
538
- return Share;
539
- }());
540
- exports.Share = Share;
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
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = 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);
20
+ }) : (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ o[k2] = m[k];
23
+ }));
24
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
25
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
26
+ }) : function(o, v) {
27
+ o["default"] = v;
28
+ });
29
+ var __importStar = (this && this.__importStar) || function (mod) {
30
+ if (mod && mod.__esModule) return mod;
31
+ var result = {};
32
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
33
+ __setModuleDefault(result, mod);
34
+ return result;
35
+ };
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ var __generator = (this && this.__generator) || function (thisArg, body) {
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;
48
+ function verb(n) { return function (v) { return step([n, v]); }; }
49
+ function step(op) {
50
+ if (f) throw new TypeError("Generator is already executing.");
51
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
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;
53
+ if (y = 0, t) op = [op[0] & 2, t.value];
54
+ switch (op[0]) {
55
+ case 0: case 1: t = op; break;
56
+ case 4: _.label++; return { value: op[1], done: false };
57
+ case 5: _.label++; y = op[1]; op = [0]; continue;
58
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
59
+ default:
60
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
61
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
62
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
63
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
64
+ if (t[2]) _.ops.pop();
65
+ _.trys.pop(); continue;
66
+ }
67
+ op = body.call(thisArg, _);
68
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
69
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
70
+ }
71
+ };
72
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
73
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
74
+ if (ar || !(i in from)) {
75
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
76
+ ar[i] = from[i];
77
+ }
78
+ }
79
+ return to.concat(ar || Array.prototype.slice.call(from));
80
+ };
81
+ Object.defineProperty(exports, "__esModule", { value: true });
82
+ exports.Share = exports.ShareTypes = void 0;
83
+ var headers_1 = require("../../shared/headers");
84
+ var client_1 = require("../../shared/http/client");
85
+ exports.ShareTypes = __importStar(require("./types"));
86
+ var Share = /** @class */ (function () {
87
+ function Share(apiUrl, appDetails, apiSecurity) {
88
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
89
+ this.appDetails = appDetails;
90
+ this.apiSecurity = apiSecurity;
91
+ }
92
+ Share.client = function (apiUrl, appDetails, apiSecurity) {
93
+ return new Share(apiUrl, appDetails, apiSecurity);
94
+ };
95
+ /**
96
+ * Fetches the list of shared items
97
+ */
98
+ Share.prototype.getShareLinks = function (page, perPage, orderBy) {
99
+ if (page === void 0) { page = 0; }
100
+ if (perPage === void 0) { perPage = 50; }
101
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
102
+ return this.client.get("/storage/share/list?page=".concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
103
+ };
104
+ /**
105
+ * Creates a new link to share a file or folder
106
+ * @param payload
107
+ */
108
+ Share.prototype.createShareLink = function (payload) {
109
+ var types = ['file', 'folder'];
110
+ if (!types.includes(payload.type)) {
111
+ throw new Error('Invalid type');
112
+ }
113
+ return this.client.post("/storage/share/".concat(payload.type, "/").concat(payload.itemId), {
114
+ timesValid: payload.timesValid,
115
+ encryptedMnemonic: payload.encryptedMnemonic,
116
+ itemToken: payload.itemToken,
117
+ bucket: payload.bucket,
118
+ encryptedCode: payload.encryptedCode,
119
+ plainPassword: payload.plainPassword,
120
+ }, this.headers());
121
+ };
122
+ /**
123
+ * Update share link
124
+ * @param payload
125
+ */
126
+ Share.prototype.updateShareLink = function (payload) {
127
+ return this.client.put("/storage/share/".concat(payload.itemId), {
128
+ plainPassword: payload.plainPassword,
129
+ }, this.headers());
130
+ };
131
+ /**
132
+ * Delete share link by id
133
+ * @param payload
134
+ */
135
+ Share.prototype.deleteShareLink = function (shareId) {
136
+ return this.client.delete("/storage/share/".concat(shareId), this.headers());
137
+ };
138
+ /**
139
+ * Increment share view by token
140
+ * @param token
141
+ */
142
+ Share.prototype.incrementShareViewByToken = function (token) {
143
+ return this.client.put("/storage/share/".concat(token, "/view"), {}, this.headers());
144
+ };
145
+ /**
146
+ * Fetches data of a shared file
147
+ * @param token
148
+ */
149
+ Share.prototype.getShareLink = function (token, password) {
150
+ var headers = password ? this.basicHeadersWithPassword(password) : this.basicHeaders();
151
+ return this.client.get("/storage/share/".concat(token), headers);
152
+ };
153
+ /**
154
+ * Fetches paginated folders or files of a specific share link
155
+ * @param payload
156
+ */
157
+ Share.prototype.getShareLinkDirectory = function (payload) {
158
+ var types = ['file', 'folder'];
159
+ if (!types.includes(payload.type)) {
160
+ throw new Error('Invalid type');
161
+ }
162
+ var headers = this.basicHeaders();
163
+ if (payload.password) {
164
+ headers = this.basicHeadersWithPassword(payload.password);
165
+ }
166
+ return this.client.get("/storage/share/down/".concat(payload.type, "s?token=").concat(payload.token, "&folderId=").concat(payload.folderId, "&parentId=").concat(payload.parentId, "&page=").concat(payload.page, "&perPage=").concat(payload.perPage).concat(payload.code ? '&code=' + payload.code : ''), headers);
167
+ };
168
+ Share.prototype.getShareDomains = function () {
169
+ return this.client.get('/storage/share/domains', this.headers());
170
+ };
171
+ /**
172
+ * Get size of folder in share links
173
+ * @param payload
174
+ */
175
+ Share.prototype.getShareLinkFolderSize = function (payload) {
176
+ return this.client.get("/storage/share/".concat(payload.itemId, "/folder/").concat(payload.folderId, "/size"), this.basicHeaders());
177
+ };
178
+ /**
179
+ * Fetches all folders shared by a user.
180
+ *
181
+ * @param {number} page - The page number for pagination.
182
+ * @param {number} perPage - The number of items per page for pagination.
183
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
184
+ * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
185
+ */
186
+ Share.prototype.getSentSharedFolders = function (page, perPage, orderBy) {
187
+ if (page === void 0) { page = 0; }
188
+ if (perPage === void 0) { perPage = 50; }
189
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
190
+ return this.client.get("sharings/shared-by-me/folders?page=".concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
191
+ };
192
+ /**
193
+ * Fetches folders shared with a user.
194
+ *
195
+ * @param {number} page - The page number for pagination.
196
+ * @param {number} perPage - The number of items per page for pagination.
197
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
198
+ * @returns {Promise<ListPrivateSharedFoldersResponse>} A promise containing the list of shared folders.
199
+ */
200
+ Share.prototype.getReceivedSharedFolders = function (page, perPage, orderBy) {
201
+ if (page === void 0) { page = 0; }
202
+ if (perPage === void 0) { perPage = 50; }
203
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
204
+ return this.client.get("sharings/shared-with-me/folders?page=".concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
205
+ };
206
+ /**
207
+ * Fetches all shared folders.
208
+ *
209
+ * @param {number} page - The page number for pagination.
210
+ * @param {number} perPage - The number of items per page for pagination.
211
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
212
+ * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
213
+ */
214
+ Share.prototype.getAllSharedFolders = function (page, perPage, orderBy) {
215
+ if (page === void 0) { page = 0; }
216
+ if (perPage === void 0) { perPage = 50; }
217
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
218
+ return this.client.get("sharings/folders?page=".concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
219
+ };
220
+ /**
221
+ * Fetches all shared files.
222
+ *
223
+ * @param {number} page - The page number for pagination.
224
+ * @param {number} perPage - The number of items per page for pagination.
225
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
226
+ * @returns {Promise<ListAllSharedFoldersResponse>} A promise containing the list of shared folders.
227
+ */
228
+ Share.prototype.getAllSharedFiles = function (page, perPage, orderBy) {
229
+ if (page === void 0) { page = 0; }
230
+ if (perPage === void 0) { perPage = 50; }
231
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
232
+ return this.client.get("sharings/files?page=".concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
233
+ };
234
+ /**
235
+ * Get all users with access to a shared folder.
236
+ *
237
+ * @param {string} folderUUID - The UUID of the folder.
238
+ * @param {number} page - The page number for pagination.
239
+ * @param {number} perPage - The number of items per page for pagination.
240
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
241
+ * @returns {Promise<{ users: SharedFolderUser[] }>} A promise containing the list of users with access to the folder.
242
+ */
243
+ Share.prototype.getSharedFolderUsers = function (folderUUID, page, perPage, orderBy) {
244
+ if (page === void 0) { page = 0; }
245
+ if (perPage === void 0) { perPage = 50; }
246
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
247
+ return this.client.get("sharings/shared-with/".concat(folderUUID, "?page=").concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
248
+ };
249
+ /**
250
+ * Get shared folder content
251
+ * @param {string} sharedFolderId - The UUID of the shared folder.
252
+ * @param {string} type - The item type for the query folders/files
253
+ * @param {string} token - Key that enables invited users to navigate the folders
254
+ * @param {number} page - The page number for pagination.
255
+ * @param {number} perPage - The number of items per page for pagination.
256
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
257
+ */
258
+ Share.prototype.getSharedFolderContent = function (sharedFolderId, type, token, page, perPage, orderBy) {
259
+ if (page === void 0) { page = 0; }
260
+ if (perPage === void 0) { perPage = 50; }
261
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
262
+ return this.client.get("sharings/items/".concat(sharedFolderId, "/").concat(type, "?token=").concat(token, "&page=").concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
263
+ };
264
+ /**
265
+ * Get public shared folder content
266
+ * @param {string} sharedFolderId - The UUID of the shared folder.
267
+ * @param {string} type - The item type for the query folders/files
268
+ * @param {string} token - Key that enables invited users to navigate the folders
269
+ * @param {number} page - The page number for pagination.
270
+ * @param {number} perPage - The number of items per page for pagination.
271
+ * @param {string} [orderBy] - The optional order criteria (e.g., 'views:ASC', 'createdAt:DESC').
272
+ */
273
+ Share.prototype.getPublicSharedFolderContent = function (sharedFolderId, type, token, page, perPage, code, orderBy) {
274
+ if (page === void 0) { page = 0; }
275
+ if (perPage === void 0) { perPage = 50; }
276
+ if (code === void 0) { code = ''; }
277
+ var orderByQueryParam = orderBy ? "&orderBy=".concat(orderBy) : '';
278
+ return this.client.get(
279
+ // eslint-disable-next-line max-len
280
+ "sharings/public/items/".concat(sharedFolderId, "/").concat(type, "?token=").concat(token, "&code=").concat(code, "&page=").concat(page, "&perPage=").concat(perPage).concat(orderByQueryParam), this.headers());
281
+ };
282
+ /**
283
+ * Get the role of a user on a folder.
284
+ *
285
+ * @param {string} options.sharingId - The unique identifier of the sharing.
286
+ * @returns {Promise<Role>} A promise containing the role of the current user in the sharing.
287
+ */
288
+ Share.prototype.getUserRole = function (sharingId) {
289
+ return this.client.get("sharings/".concat(sharingId, "/role"), this.headers());
290
+ };
291
+ /**
292
+ * Update the role of a user on a folder.
293
+ *
294
+ * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
295
+ * @param {string} options.sharingId - The unique identifier of the user to whom we will update the role.
296
+ * @param {string} options.newRoleId - The new role Id.
297
+ * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
298
+ */
299
+ Share.prototype.updateUserRole = function (_a) {
300
+ var sharingId = _a.sharingId, newRoleId = _a.newRoleId;
301
+ return this.client.put("sharings/".concat(sharingId, "/role"), {
302
+ roleId: newRoleId,
303
+ }, this.headers());
304
+ };
305
+ /**
306
+ * Remove user from shared folder.
307
+ *
308
+ * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder.
309
+ * @param {string} options.itemType - The unique identifier of the folder.
310
+ * @param {string} options.itemId - The identifier of the role to assign to the user.
311
+ * @param {string} options.userId - The role Id how we want to delete.
312
+ * @returns {Promise<UpdateRoleFolderResponse>} A promise that resolves when the user's role is updated.
313
+ */
314
+ Share.prototype.removeUserRole = function (_a) {
315
+ var itemType = _a.itemType, itemId = _a.itemId, userId = _a.userId;
316
+ return this.client.delete("sharings/".concat(itemType, "/").concat(itemId, "/users/").concat(userId), this.headers());
317
+ };
318
+ /**
319
+ * Get private folder data.
320
+ *
321
+ * @param {string} itemId - The itemId of the folder.
322
+ * @param {string} itemType - The itemType of the folder (file | folder).
323
+ * @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
324
+ */
325
+ Share.prototype.getSharedFolderInvitations = function (_a) {
326
+ var itemId = _a.itemId, itemType = _a.itemType;
327
+ return this.client.get("sharings/".concat(itemType, "/").concat(itemId, "/invites"), this.headers());
328
+ };
329
+ /**
330
+ * Get all invitations for a user.
331
+ * @param limit - The number of items per page for pagination.
332
+ * @param offset - The page number for pagination.
333
+ * @returns {Promise<invites: any>} A promise containing the list of invitations.
334
+ */
335
+ Share.prototype.getSharedFolderInvitationsAsInvitedUser = function (_a) {
336
+ var limit = _a.limit, offset = _a.offset;
337
+ return this.client.get("sharings/invites?limit=".concat(limit, "&offset=").concat(offset), this.headers());
338
+ };
339
+ /**
340
+ * Share a private folder with a user.
341
+ *
342
+ * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
343
+ * @param {string} options.itemId - The id of the item to share.
344
+ * @param {string} options.itemType - The type of the item to share (folder | file).
345
+ * @param {string} options.sharedWith - The email address of the user to share the folder with.
346
+ * @param {string} options.encryptionKey - Owner\'s encryption key encrypted with the invited user\'s public key. This field should not be empty if the invitation type is "OWNER".
347
+ * @param {string} options.encryptionAlgorithm - Encryption algorithm used to encrypt the encryption key. This field should not be empty if the invitation type is "OWNER".
348
+ * @param {string} options.type - Owner's encryption key encrypted with the invited user's public key.
349
+ * @param {string} options.roleId - The id of the role to assign to the user.
350
+ * @param {string} options.notifyUser - If it has to notify the users
351
+ * @param {string} options.notificationMessage - Message of the notificacion
352
+ *
353
+ *
354
+ * @returns {Promise<SharingInvite>} A promise that resolves when the folder is shared with the user.
355
+ */
356
+ Share.prototype.inviteUserToSharedFolder = function (createInviteDto) {
357
+ return this.client.post('sharings/invites/send', __assign(__assign({}, createInviteDto), { type: 'OWNER' }), this.headers());
358
+ };
359
+ /**
360
+ * Create a sharing.
361
+ */
362
+ Share.prototype.createSharing = function (createSharingPayload) {
363
+ return this.client.post('sharings', __assign({}, createSharingPayload), this.headers());
364
+ };
365
+ /**
366
+ * Get sharing meta with code
367
+ */
368
+ Share.prototype.getSharingMeta = function (sharingId, code, password) {
369
+ var extraHeaders = password ? { 'x-share-password': password } : {};
370
+ return this.client.get("sharings/".concat(sharingId, "/meta?code=").concat(code), __assign(__assign({}, this.headers()), extraHeaders));
371
+ };
372
+ /**
373
+ * Add/edit sharing Password
374
+ * @param {string} sharingId - id of sharing.
375
+ * @param {string} encryptedPassword - password encrypted with CODE as key
376
+ * @returns {Promise<SharingMeta>} A promise that returns the sharing info with the new encrypted password
377
+ */
378
+ Share.prototype.saveSharingPassword = function (sharingId, encryptedPassword) {
379
+ return this.client.patch("sharings/".concat(sharingId, "/password"), {
380
+ encryptedPassword: encryptedPassword,
381
+ }, this.headers());
382
+ };
383
+ /**
384
+ * Remove password protection from sharing
385
+ * @param {string} sharingId - id of sharing.
386
+ * @returns {Promise<void>} A promise that resolves when password was successfully deleted.
387
+ */
388
+ Share.prototype.removeSharingPassword = function (sharingId) {
389
+ return this.client.delete("sharings/".concat(sharingId, "/password"), this.headers());
390
+ };
391
+ /**
392
+ * Get public information of the item shared.
393
+ * @param {string} sharingId - id of sharing.
394
+ * @returns {Promise<PublicSharedItemInfo>} A promise that returns data of the public shared item.
395
+ */
396
+ Share.prototype.getPublicSharedItemInfo = function (sharingId) {
397
+ return this.client.get("sharings/public/".concat(sharingId, "/item"), this.headers());
398
+ };
399
+ /**
400
+ * Request access to shared folder.
401
+ */
402
+ Share.prototype.requestUserToSharedFolder = function (createInviteDto) {
403
+ return this.client.post('sharings/invites/send', __assign(__assign({}, createInviteDto), { type: 'SELF' }), this.headers());
404
+ };
405
+ /**
406
+ * Check if the expirationDate of invite is valid.
407
+ * @param {string} invitationId - The id of the invitation.
408
+
409
+ * @returns {Promise<{uuid: string}>} A promise returning the uuid of the invitation if valid.
410
+ */
411
+ Share.prototype.validateInviteExpiration = function (invitationId) {
412
+ return this.client.get("sharings/invites/".concat(invitationId, "/validate"), this.headers());
413
+ };
414
+ /**
415
+ * Share a private folder with a user.
416
+ * @param {string} invitationId - The id of the invitation.
417
+ * @param {ShareFolderWithUserPayload} options - The options for sharing the private folder with a user.
418
+ * @param {string} options.encryptionKey - The encryption key (just in case the invitation is a request).
419
+ * @param {string} options.itemType - The encryption algorithm (just in case the invitation is a request).
420
+
421
+ * @returns {Promise<void>} A promise that resolves when the folder is shared with the user.
422
+ */
423
+ Share.prototype.acceptSharedFolderInvite = function (_a) {
424
+ var invitationId = _a.invitationId, acceptInvite = _a.acceptInvite, token = _a.token;
425
+ var headers = this.getRequestHeaders(token);
426
+ return this.client.post("sharings/invites/".concat(invitationId, "/accept"), {
427
+ acceptInvite: acceptInvite,
428
+ }, headers);
429
+ };
430
+ /**
431
+ * Change Sharing Mode.
432
+ * @param {string} options.itemType - folder | file
433
+ * @param {string} options.itemId - id of folder or file
434
+ * @param {string} options.sharingType - New Sharing type.
435
+
436
+ * @returns {Promise<void>} A promise that resolves when sharing mode has been updated.
437
+ */
438
+ Share.prototype.updateSharingType = function (_a) {
439
+ var itemId = _a.itemId, itemType = _a.itemType, sharingType = _a.sharingType;
440
+ var headers = this.headers();
441
+ return this.client.put("sharings/".concat(itemType, "/").concat(itemId, "/type"), {
442
+ sharingType: sharingType,
443
+ }, headers);
444
+ };
445
+ /**
446
+ * Get Sharing type
447
+ * @param {string} options.itemType - folder | file
448
+ * @param {string} options.itemId - id of folder or file
449
+ * @returns {Promise<SharingMeta>} A promise that returns the sharing data.
450
+ */
451
+ Share.prototype.getSharingType = function (_a) {
452
+ var itemId = _a.itemId, itemType = _a.itemType;
453
+ var headers = this.headers();
454
+ return this.client.get("sharings/".concat(itemType, "/").concat(itemId, "/type"), headers);
455
+ };
456
+ Share.prototype.declineSharedFolderInvite = function (invitationId, token) {
457
+ var headers = this.getRequestHeaders(token);
458
+ return this.client.delete("sharings/invites/".concat(invitationId), headers);
459
+ };
460
+ /**
461
+ * Fetches roles for sharing items.
462
+ *
463
+ * @returns {Promise<PrivateSharingRolesResponse>} A promise containing the list of sharing roles.
464
+ */
465
+ Share.prototype.getSharingRoles = function () {
466
+ return this.client.get('/sharings/roles', this.headers());
467
+ };
468
+ Share.prototype.getAllAccessUsers = function (_a) {
469
+ var itemType = _a.itemType, folderId = _a.folderId;
470
+ return this.client.get("sharings/shared-with/".concat(itemType, "/").concat(folderId), this.headers());
471
+ };
472
+ /**
473
+ * Stop sharing folder
474
+ * @param {string} itemType - Type of the sharing to delete
475
+ * @param {string} itemId - Id of the sharing to delete
476
+ * @returns
477
+ */
478
+ Share.prototype.stopSharingFolder = function (itemType, itemId) {
479
+ return __awaiter(this, void 0, void 0, function () {
480
+ return __generator(this, function (_a) {
481
+ switch (_a.label) {
482
+ case 0: return [4 /*yield*/, this.client.delete("sharings/".concat(itemType, "/").concat(itemId), this.headers())];
483
+ case 1:
484
+ _a.sent();
485
+ return [2 /*return*/];
486
+ }
487
+ });
488
+ });
489
+ };
490
+ /**
491
+ * Returns the needed headers for the module requests
492
+ * @private
493
+ */
494
+ Share.prototype.headers = function (password) {
495
+ var args = [
496
+ this.appDetails.clientName,
497
+ this.appDetails.clientVersion,
498
+ this.apiSecurity.token,
499
+ this.apiSecurity.workspaceToken,
500
+ ];
501
+ if (password) {
502
+ return headers_1.headersWithTokenAndPassword.apply(void 0, __spreadArray(__spreadArray([], args, false), [password], false));
503
+ }
504
+ return headers_1.headersWithToken.apply(void 0, args);
505
+ };
506
+ /**
507
+ * Returns the needed headers for the module requests
508
+ * @private
509
+ */
510
+ Share.prototype.basicHeaders = function () {
511
+ return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
512
+ };
513
+ /**
514
+ * Used to send the password in shares
515
+ * @private
516
+ */
517
+ Share.prototype.basicHeadersWithPassword = function (password) {
518
+ return (0, headers_1.basicHeadersWithPassword)(this.appDetails.clientName, this.appDetails.clientVersion, password);
519
+ };
520
+ /**
521
+ * Get request headers with optional authorization token.
522
+ *
523
+ * @param {string} [token] - Optional authorization token.
524
+ * @returns {Object} - Request headers object.
525
+ */
526
+ Share.prototype.getRequestHeaders = function (token) {
527
+ var headers = __assign({}, this.headers());
528
+ if (token) {
529
+ headers.Authorization = 'Bearer ' + token;
530
+ }
531
+ return headers;
532
+ };
533
+ /**
534
+ * Gets the size of a shared folder given sharing id
535
+ *
536
+ * @param {string} sharingId - Sharing ID.
537
+ * @returns {Promise<SharedFolderSize>}
538
+ */
539
+ Share.prototype.getSharedFolderSize = function (id) {
540
+ return this.client.get("sharings/public/".concat(id, "/folder/size"), this.headers());
541
+ };
542
+ return Share;
543
+ }());
544
+ exports.Share = Share;