@internxt/sdk 1.4.77 → 1.5.25

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 +122 -122
  2. package/dist/auth/index.js +310 -310
  3. package/dist/auth/types.d.ts +54 -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 +19 -19
  11. package/dist/drive/payments/index.d.ts +71 -53
  12. package/dist/drive/payments/index.js +208 -153
  13. package/dist/drive/payments/types.d.ts +176 -114
  14. package/dist/drive/payments/types.js +37 -32
  15. package/dist/drive/referrals/index.d.ts +19 -19
  16. package/dist/drive/referrals/index.js +50 -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 +540 -539
  21. package/dist/drive/share/types.d.ts +360 -358
  22. package/dist/drive/share/types.js +2 -2
  23. package/dist/drive/storage/index.d.ts +315 -195
  24. package/dist/drive/storage/index.js +630 -434
  25. package/dist/drive/storage/types.d.ts +473 -394
  26. package/dist/drive/storage/types.js +13 -13
  27. package/dist/drive/trash/index.d.ts +75 -55
  28. package/dist/drive/trash/index.js +180 -149
  29. package/dist/drive/trash/types.d.ts +29 -20
  30. package/dist/drive/trash/types.js +2 -2
  31. package/dist/drive/users/index.d.ts +135 -108
  32. package/dist/drive/users/index.js +204 -174
  33. package/dist/drive/users/types.d.ts +51 -43
  34. package/dist/drive/users/types.js +2 -2
  35. package/dist/index.d.ts +6 -5
  36. package/dist/index.js +31 -30
  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 +48 -48
  45. package/dist/network/errors/index.d.ts +3 -3
  46. package/dist/network/errors/index.js +15 -15
  47. package/dist/network/errors/upload.d.ts +13 -13
  48. package/dist/network/errors/upload.js +78 -78
  49. package/dist/network/index.d.ts +70 -71
  50. package/dist/network/index.js +311 -310
  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 +159 -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 +52 -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 -18
  68. package/dist/shared/headers/index.js +79 -69
  69. package/dist/shared/http/client.d.ts +85 -85
  70. package/dist/shared/http/client.js +172 -181
  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 +13 -13
  75. package/dist/shared/types/apiConnection.d.ts +12 -11
  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 -4
  80. package/dist/shared/types/errors.js +28 -27
  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 +29 -27
  84. package/dist/shared/types/userSettings.js +2 -2
  85. package/dist/utils.d.ts +3 -3
  86. package/dist/utils.js +25 -25
  87. package/dist/workspaces/index.d.ts +176 -0
  88. package/dist/workspaces/index.js +415 -0
  89. package/dist/workspaces/index.test.d.ts +1 -0
  90. package/dist/workspaces/index.test.js +903 -0
  91. package/dist/workspaces/types.d.ts +291 -0
  92. package/dist/workspaces/types.js +2 -0
  93. package/package.json +1 -1
@@ -1,539 +1,540 @@
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
- ];
496
- if (password) {
497
- return headers_1.headersWithTokenAndPassword.apply(void 0, __spreadArray(__spreadArray([], args, false), [password], false));
498
- }
499
- return headers_1.headersWithToken.apply(void 0, args);
500
- };
501
- /**
502
- * Returns the needed headers for the module requests
503
- * @private
504
- */
505
- Share.prototype.basicHeaders = function () {
506
- return (0, headers_1.basicHeaders)(this.appDetails.clientName, this.appDetails.clientVersion);
507
- };
508
- /**
509
- * Used to send the password in shares
510
- * @private
511
- */
512
- Share.prototype.basicHeadersWithPassword = function (password) {
513
- return (0, headers_1.basicHeadersWithPassword)(this.appDetails.clientName, this.appDetails.clientVersion, password);
514
- };
515
- /**
516
- * Get request headers with optional authorization token.
517
- *
518
- * @param {string} [token] - Optional authorization token.
519
- * @returns {Object} - Request headers object.
520
- */
521
- Share.prototype.getRequestHeaders = function (token) {
522
- var headers = __assign({}, this.headers());
523
- if (token) {
524
- headers.Authorization = 'Bearer ' + token;
525
- }
526
- return headers;
527
- };
528
- /**
529
- * Gets the size of a shared folder given sharing id
530
- *
531
- * @param {string} sharingId - Sharing ID.
532
- * @returns {Promise<SharedFolderSize>}
533
- */
534
- Share.prototype.getSharedFolderSize = function (id) {
535
- return this.client.get("sharings/public/" + id + "/folder/size", this.headers());
536
- };
537
- return Share;
538
- }());
539
- 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
+ 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;