@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,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EncryptionVersion = exports.FileStatus = void 0;
4
- var FileStatus;
5
- (function (FileStatus) {
6
- FileStatus["EXISTS"] = "EXISTS";
7
- FileStatus["TRASHED"] = "TRASHED";
8
- FileStatus["DELETED"] = "DELETED";
9
- })(FileStatus = exports.FileStatus || (exports.FileStatus = {}));
10
- var EncryptionVersion;
11
- (function (EncryptionVersion) {
12
- EncryptionVersion["Aes03"] = "03-aes";
13
- })(EncryptionVersion = exports.EncryptionVersion || (exports.EncryptionVersion = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EncryptionVersion = exports.FileStatus = void 0;
4
+ var FileStatus;
5
+ (function (FileStatus) {
6
+ FileStatus["EXISTS"] = "EXISTS";
7
+ FileStatus["TRASHED"] = "TRASHED";
8
+ FileStatus["DELETED"] = "DELETED";
9
+ })(FileStatus || (exports.FileStatus = FileStatus = {}));
10
+ var EncryptionVersion;
11
+ (function (EncryptionVersion) {
12
+ EncryptionVersion["Aes03"] = "03-aes";
13
+ })(EncryptionVersion || (exports.EncryptionVersion = EncryptionVersion = {}));
@@ -1,75 +1,75 @@
1
- import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
- import { FetchFolderContentResponse, FetchTrashContentResponse } from '../storage/types';
3
- import { AddItemsToTrashPayload, DeleteFilePayload, DeleteItemsPermanentlyByUUIDPayload, DeleteItemsPermanentlyPayload } from './types';
4
- export * as TrashTypes from './types';
5
- export declare class Trash {
6
- private readonly client;
7
- private readonly appDetails;
8
- private readonly apiSecurity;
9
- static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Trash;
10
- private constructor();
11
- /**
12
- * Removes a specific folder from the centralized persistence
13
- * @param folderId
14
- */
15
- deleteFolder(folderId: number): Promise<unknown>;
16
- /**
17
- * Deletes a specific file entry
18
- * @param payload
19
- */
20
- deleteFile(payload: DeleteFilePayload): Promise<unknown>;
21
- /**
22
- * Returns a list of items in trash
23
- */
24
- getTrash(): Promise<FetchFolderContentResponse>;
25
- /**
26
- * Retrieves a paginated list of trashed files or folders.
27
- * @param {number} limit - The number of items to retrieve per page.
28
- * @param {number} [offset=0] - The number of items to skip before beginning to return items.
29
- * @param {'files' | 'folders'} type - The type of content to retrieve.
30
- * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
31
- * If is not true it has to get a folderId in order to obtain the items or given folderId
32
- * @param {number} [folderId] - The ID of the folder to retrieve content from.
33
- * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
34
- */
35
- getTrashedFilesPaginated(limit: number, offset: number | undefined, type: 'files' | 'folders', root: boolean, folderId?: number): Promise<FetchTrashContentResponse>;
36
- /**
37
- * Retrieves a sorted list of trashed files or folders.
38
- * @param {number} limit - The number of items to retrieve per page.
39
- * @param {number} [offset=0] - The number of items to skip before beginning to return items.
40
- * @param {'files' | 'folders'} type - The type of content to retrieve.
41
- * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
42
- * If is not true it has to get a folderId in order to obtain the items or given folderId
43
- * @param {'plainName' | 'date'} [sort] - The ID of the folder to retrieve content from.
44
- * @param {'ASC' | 'DESC'} [order] - The ID of the folder to retrieve content from.
45
- * @param {number} [folderId] - The ID of the folder to retrieve content from.
46
- * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
47
- */
48
- getTrashedItemsSorted(limit: number, offset: number | undefined, type: 'files' | 'folders', root: boolean, sort: 'plainName' | 'updatedAt', order: 'ASC' | 'DESC', folderId?: number): Promise<FetchTrashContentResponse>;
49
- /**
50
- * Add Items to Trash
51
- * @param payload
52
- */
53
- addItemsToTrash(payload: AddItemsToTrashPayload): Promise<void>;
54
- /**
55
- * Removes all items from the trash
56
- */
57
- clearTrash(): Promise<void>;
58
- /**
59
- * Deletes trashed items permanently
60
- * @param payload
61
- */
62
- deleteItemsPermanently(payload: DeleteItemsPermanentlyPayload): Promise<unknown>;
63
- /**
64
- * Deletes trashed items permanently by UUID.
65
- *
66
- * @param {DeleteItemsPermanentlyByUUIDPayload} payload - The payload containing the items to be deleted.
67
- * @return {Promise<void>} A promise that resolves when the items are deleted permanently.
68
- */
69
- deleteItemsPermanentlyByUUID(payload: DeleteItemsPermanentlyByUUIDPayload): Promise<unknown>;
70
- /**
71
- * Returns the needed headers for the module requests
72
- * @private
73
- */
74
- private headers;
75
- }
1
+ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
+ import { FetchFolderContentResponse, FetchTrashContentResponse } from '../storage/types';
3
+ import { AddItemsToTrashPayload, DeleteFilePayload, DeleteItemsPermanentlyByUUIDPayload, DeleteItemsPermanentlyPayload } from './types';
4
+ export * as TrashTypes from './types';
5
+ export declare class Trash {
6
+ private readonly client;
7
+ private readonly appDetails;
8
+ private readonly apiSecurity;
9
+ static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Trash;
10
+ private constructor();
11
+ /**
12
+ * Removes a specific folder from the centralized persistence
13
+ * @param folderId
14
+ */
15
+ deleteFolder(folderId: number): Promise<unknown>;
16
+ /**
17
+ * Deletes a specific file entry
18
+ * @param payload
19
+ */
20
+ deleteFile(payload: DeleteFilePayload): Promise<unknown>;
21
+ /**
22
+ * Returns a list of items in trash
23
+ */
24
+ getTrash(): Promise<FetchFolderContentResponse>;
25
+ /**
26
+ * Retrieves a paginated list of trashed files or folders.
27
+ * @param {number} limit - The number of items to retrieve per page.
28
+ * @param {number} [offset=0] - The number of items to skip before beginning to return items.
29
+ * @param {'files' | 'folders'} type - The type of content to retrieve.
30
+ * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
31
+ * If is not true it has to get a folderId in order to obtain the items or given folderId
32
+ * @param {number} [folderId] - The ID of the folder to retrieve content from.
33
+ * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
34
+ */
35
+ getTrashedFilesPaginated(limit: number, offset: number | undefined, type: 'files' | 'folders', root: boolean, folderId?: number): Promise<FetchTrashContentResponse>;
36
+ /**
37
+ * Retrieves a sorted list of trashed files or folders.
38
+ * @param {number} limit - The number of items to retrieve per page.
39
+ * @param {number} [offset=0] - The number of items to skip before beginning to return items.
40
+ * @param {'files' | 'folders'} type - The type of content to retrieve.
41
+ * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
42
+ * If is not true it has to get a folderId in order to obtain the items or given folderId
43
+ * @param {'plainName' | 'date'} [sort] - The ID of the folder to retrieve content from.
44
+ * @param {'ASC' | 'DESC'} [order] - The ID of the folder to retrieve content from.
45
+ * @param {number} [folderId] - The ID of the folder to retrieve content from.
46
+ * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
47
+ */
48
+ getTrashedItemsSorted(limit: number, offset: number | undefined, type: 'files' | 'folders', root: boolean, sort: 'plainName' | 'updatedAt', order: 'ASC' | 'DESC', folderId?: number): Promise<FetchTrashContentResponse>;
49
+ /**
50
+ * Add Items to Trash
51
+ * @param payload
52
+ */
53
+ addItemsToTrash(payload: AddItemsToTrashPayload): Promise<void>;
54
+ /**
55
+ * Removes all items from the trash
56
+ */
57
+ clearTrash(): Promise<void>;
58
+ /**
59
+ * Deletes trashed items permanently
60
+ * @param payload
61
+ */
62
+ deleteItemsPermanently(payload: DeleteItemsPermanentlyPayload): Promise<unknown>;
63
+ /**
64
+ * Deletes trashed items permanently by UUID.
65
+ *
66
+ * @param {DeleteItemsPermanentlyByUUIDPayload} payload - The payload containing the items to be deleted.
67
+ * @return {Promise<void>} A promise that resolves when the items are deleted permanently.
68
+ */
69
+ deleteItemsPermanentlyByUUID(payload: DeleteItemsPermanentlyByUUIDPayload): Promise<unknown>;
70
+ /**
71
+ * Returns the needed headers for the module requests
72
+ * @private
73
+ */
74
+ private headers;
75
+ }
@@ -1,180 +1,184 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- var __generator = (this && this.__generator) || function (thisArg, body) {
31
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
32
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
33
- function verb(n) { return function (v) { return step([n, v]); }; }
34
- function step(op) {
35
- if (f) throw new TypeError("Generator is already executing.");
36
- while (_) try {
37
- 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;
38
- if (y = 0, t) op = [op[0] & 2, t.value];
39
- switch (op[0]) {
40
- case 0: case 1: t = op; break;
41
- case 4: _.label++; return { value: op[1], done: false };
42
- case 5: _.label++; y = op[1]; op = [0]; continue;
43
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
44
- default:
45
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
46
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
47
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
48
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
49
- if (t[2]) _.ops.pop();
50
- _.trys.pop(); continue;
51
- }
52
- op = body.call(thisArg, _);
53
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
54
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
55
- }
56
- };
57
- Object.defineProperty(exports, "__esModule", { value: true });
58
- exports.Trash = exports.TrashTypes = void 0;
59
- var headers_1 = require("../../shared/headers");
60
- var client_1 = require("../../shared/http/client");
61
- exports.TrashTypes = __importStar(require("./types"));
62
- var Trash = /** @class */ (function () {
63
- function Trash(apiUrl, appDetails, apiSecurity) {
64
- this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
65
- this.appDetails = appDetails;
66
- this.apiSecurity = apiSecurity;
67
- }
68
- Trash.client = function (apiUrl, appDetails, apiSecurity) {
69
- return new Trash(apiUrl, appDetails, apiSecurity);
70
- };
71
- /**
72
- * Removes a specific folder from the centralized persistence
73
- * @param folderId
74
- */
75
- Trash.prototype.deleteFolder = function (folderId) {
76
- return __awaiter(this, void 0, void 0, function () {
77
- return __generator(this, function (_a) {
78
- return [2 /*return*/, this.client.delete("/storage/folder/" + folderId, this.headers())];
79
- });
80
- });
81
- };
82
- /**
83
- * Deletes a specific file entry
84
- * @param payload
85
- */
86
- Trash.prototype.deleteFile = function (payload) {
87
- return __awaiter(this, void 0, void 0, function () {
88
- return __generator(this, function (_a) {
89
- return [2 /*return*/, this.client.delete("/storage/folder/" + payload.folderId + "/file/" + payload.fileId, this.headers())];
90
- });
91
- });
92
- };
93
- /**
94
- * Returns a list of items in trash
95
- */
96
- Trash.prototype.getTrash = function () {
97
- return this.client.get('/storage/trash', this.headers());
98
- };
99
- /**
100
- * Retrieves a paginated list of trashed files or folders.
101
- * @param {number} limit - The number of items to retrieve per page.
102
- * @param {number} [offset=0] - The number of items to skip before beginning to return items.
103
- * @param {'files' | 'folders'} type - The type of content to retrieve.
104
- * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
105
- * If is not true it has to get a folderId in order to obtain the items or given folderId
106
- * @param {number} [folderId] - The ID of the folder to retrieve content from.
107
- * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
108
- */
109
- Trash.prototype.getTrashedFilesPaginated = function (limit, offset, type, root, folderId) {
110
- if (offset === void 0) { offset = 0; }
111
- var endpoint = '/storage/trash/paginated';
112
- var folderIdQuery = folderId !== undefined ? "folderId=" + folderId + "&" : '';
113
- var url = endpoint + "?" + folderIdQuery + "limit=" + limit + "&offset=" + offset + "&type=" + type + "&root=" + root;
114
- return this.client.get(url, this.headers());
115
- };
116
- /**
117
- * Retrieves a sorted list of trashed files or folders.
118
- * @param {number} limit - The number of items to retrieve per page.
119
- * @param {number} [offset=0] - The number of items to skip before beginning to return items.
120
- * @param {'files' | 'folders'} type - The type of content to retrieve.
121
- * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
122
- * If is not true it has to get a folderId in order to obtain the items or given folderId
123
- * @param {'plainName' | 'date'} [sort] - The ID of the folder to retrieve content from.
124
- * @param {'ASC' | 'DESC'} [order] - The ID of the folder to retrieve content from.
125
- * @param {number} [folderId] - The ID of the folder to retrieve content from.
126
- * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
127
- */
128
- Trash.prototype.getTrashedItemsSorted = function (limit, offset, type, root, sort, order, folderId) {
129
- if (offset === void 0) { offset = 0; }
130
- var endpoint = '/storage/trash/paginated';
131
- var folderIdQuery = folderId !== undefined ? "folderId=" + folderId + "&" : '';
132
- var params = "limit=" + limit + "&offset=" + offset + "&type=" + type + "&root=" + root + "&sort=" + sort + "&order=" + order;
133
- var url = endpoint + "?" + folderIdQuery + params;
134
- return this.client.get(url, this.headers());
135
- };
136
- /**
137
- * Add Items to Trash
138
- * @param payload
139
- */
140
- Trash.prototype.addItemsToTrash = function (payload) {
141
- return this.client.post('/storage/trash/add', {
142
- items: payload.items,
143
- }, this.headers());
144
- };
145
- /**
146
- * Removes all items from the trash
147
- */
148
- Trash.prototype.clearTrash = function () {
149
- return this.client.delete('/storage/trash/all', this.headers());
150
- };
151
- /**
152
- * Deletes trashed items permanently
153
- * @param payload
154
- */
155
- Trash.prototype.deleteItemsPermanently = function (payload) {
156
- return this.client.delete('/storage/trash', this.headers(), {
157
- items: payload.items,
158
- });
159
- };
160
- /**
161
- * Deletes trashed items permanently by UUID.
162
- *
163
- * @param {DeleteItemsPermanentlyByUUIDPayload} payload - The payload containing the items to be deleted.
164
- * @return {Promise<void>} A promise that resolves when the items are deleted permanently.
165
- */
166
- Trash.prototype.deleteItemsPermanentlyByUUID = function (payload) {
167
- return this.client.delete('/storage/trash', this.headers(), {
168
- items: payload.items,
169
- });
170
- };
171
- /**
172
- * Returns the needed headers for the module requests
173
- * @private
174
- */
175
- Trash.prototype.headers = function () {
176
- return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, this.apiSecurity.workspaceToken);
177
- };
178
- return Trash;
179
- }());
180
- exports.Trash = Trash;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ 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);
36
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ 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;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
61
+ Object.defineProperty(exports, "__esModule", { value: true });
62
+ exports.Trash = exports.TrashTypes = void 0;
63
+ var headers_1 = require("../../shared/headers");
64
+ var client_1 = require("../../shared/http/client");
65
+ exports.TrashTypes = __importStar(require("./types"));
66
+ var Trash = /** @class */ (function () {
67
+ function Trash(apiUrl, appDetails, apiSecurity) {
68
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
69
+ this.appDetails = appDetails;
70
+ this.apiSecurity = apiSecurity;
71
+ }
72
+ Trash.client = function (apiUrl, appDetails, apiSecurity) {
73
+ return new Trash(apiUrl, appDetails, apiSecurity);
74
+ };
75
+ /**
76
+ * Removes a specific folder from the centralized persistence
77
+ * @param folderId
78
+ */
79
+ Trash.prototype.deleteFolder = function (folderId) {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ return __generator(this, function (_a) {
82
+ return [2 /*return*/, this.client.delete("/storage/folder/".concat(folderId), this.headers())];
83
+ });
84
+ });
85
+ };
86
+ /**
87
+ * Deletes a specific file entry
88
+ * @param payload
89
+ */
90
+ Trash.prototype.deleteFile = function (payload) {
91
+ return __awaiter(this, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ return [2 /*return*/, this.client.delete("/storage/folder/".concat(payload.folderId, "/file/").concat(payload.fileId), this.headers())];
94
+ });
95
+ });
96
+ };
97
+ /**
98
+ * Returns a list of items in trash
99
+ */
100
+ Trash.prototype.getTrash = function () {
101
+ return this.client.get('/storage/trash', this.headers());
102
+ };
103
+ /**
104
+ * Retrieves a paginated list of trashed files or folders.
105
+ * @param {number} limit - The number of items to retrieve per page.
106
+ * @param {number} [offset=0] - The number of items to skip before beginning to return items.
107
+ * @param {'files' | 'folders'} type - The type of content to retrieve.
108
+ * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
109
+ * If is not true it has to get a folderId in order to obtain the items or given folderId
110
+ * @param {number} [folderId] - The ID of the folder to retrieve content from.
111
+ * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
112
+ */
113
+ Trash.prototype.getTrashedFilesPaginated = function (limit, offset, type, root, folderId) {
114
+ if (offset === void 0) { offset = 0; }
115
+ var endpoint = '/storage/trash/paginated';
116
+ var folderIdQuery = folderId !== undefined ? "folderId=".concat(folderId, "&") : '';
117
+ var url = "".concat(endpoint, "?").concat(folderIdQuery, "limit=").concat(limit, "&offset=").concat(offset, "&type=").concat(type, "&root=").concat(root);
118
+ return this.client.get(url, this.headers());
119
+ };
120
+ /**
121
+ * Retrieves a sorted list of trashed files or folders.
122
+ * @param {number} limit - The number of items to retrieve per page.
123
+ * @param {number} [offset=0] - The number of items to skip before beginning to return items.
124
+ * @param {'files' | 'folders'} type - The type of content to retrieve.
125
+ * @param {boolean} root - A boolean indicating whether to retrieve content from the root folder.
126
+ * If is not true it has to get a folderId in order to obtain the items or given folderId
127
+ * @param {'plainName' | 'date'} [sort] - The ID of the folder to retrieve content from.
128
+ * @param {'ASC' | 'DESC'} [order] - The ID of the folder to retrieve content from.
129
+ * @param {number} [folderId] - The ID of the folder to retrieve content from.
130
+ * @returns {Promise<FetchTrashContentResponse>} - A promise that resolves with the paginated list of trashed content.
131
+ */
132
+ Trash.prototype.getTrashedItemsSorted = function (limit, offset, type, root, sort, order, folderId) {
133
+ if (offset === void 0) { offset = 0; }
134
+ var endpoint = '/storage/trash/paginated';
135
+ var folderIdQuery = folderId !== undefined ? "folderId=".concat(folderId, "&") : '';
136
+ var params = "limit=".concat(limit, "&offset=").concat(offset, "&type=").concat(type, "&root=").concat(root, "&sort=").concat(sort, "&order=").concat(order);
137
+ var url = "".concat(endpoint, "?").concat(folderIdQuery).concat(params);
138
+ return this.client.get(url, this.headers());
139
+ };
140
+ /**
141
+ * Add Items to Trash
142
+ * @param payload
143
+ */
144
+ Trash.prototype.addItemsToTrash = function (payload) {
145
+ return this.client.post('/storage/trash/add', {
146
+ items: payload.items,
147
+ }, this.headers());
148
+ };
149
+ /**
150
+ * Removes all items from the trash
151
+ */
152
+ Trash.prototype.clearTrash = function () {
153
+ return this.client.delete('/storage/trash/all', this.headers());
154
+ };
155
+ /**
156
+ * Deletes trashed items permanently
157
+ * @param payload
158
+ */
159
+ Trash.prototype.deleteItemsPermanently = function (payload) {
160
+ return this.client.delete('/storage/trash', this.headers(), {
161
+ items: payload.items,
162
+ });
163
+ };
164
+ /**
165
+ * Deletes trashed items permanently by UUID.
166
+ *
167
+ * @param {DeleteItemsPermanentlyByUUIDPayload} payload - The payload containing the items to be deleted.
168
+ * @return {Promise<void>} A promise that resolves when the items are deleted permanently.
169
+ */
170
+ Trash.prototype.deleteItemsPermanentlyByUUID = function (payload) {
171
+ return this.client.delete('/storage/trash', this.headers(), {
172
+ items: payload.items,
173
+ });
174
+ };
175
+ /**
176
+ * Returns the needed headers for the module requests
177
+ * @private
178
+ */
179
+ Trash.prototype.headers = function () {
180
+ return (0, headers_1.headersWithToken)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, this.apiSecurity.workspaceToken);
181
+ };
182
+ return Trash;
183
+ }());
184
+ exports.Trash = Trash;
@@ -1,29 +1,29 @@
1
- export interface AddItemsToTrashPayload {
2
- items: Array<{
3
- id?: string;
4
- uuid?: string;
5
- type: string;
6
- }>;
7
- }
8
- export interface DeleteFilePayload {
9
- fileId: number;
10
- folderId: number;
11
- }
12
- export interface DeleteItemsPermanentlyPayload {
13
- items: Array<{
14
- id: number;
15
- type: 'folder';
16
- } | {
17
- id: string;
18
- type: 'file';
19
- }>;
20
- }
21
- export interface DeleteItemsPermanentlyByUUIDPayload {
22
- items: Array<{
23
- uuid: string;
24
- type: 'folder';
25
- } | {
26
- uuid: string;
27
- type: 'file';
28
- }>;
29
- }
1
+ export interface AddItemsToTrashPayload {
2
+ items: Array<{
3
+ id?: string;
4
+ uuid?: string;
5
+ type: string;
6
+ }>;
7
+ }
8
+ export interface DeleteFilePayload {
9
+ fileId: number;
10
+ folderId: number;
11
+ }
12
+ export interface DeleteItemsPermanentlyPayload {
13
+ items: Array<{
14
+ id: number;
15
+ type: 'folder';
16
+ } | {
17
+ id: string;
18
+ type: 'file';
19
+ }>;
20
+ }
21
+ export interface DeleteItemsPermanentlyByUUIDPayload {
22
+ items: Array<{
23
+ uuid: string;
24
+ type: 'folder';
25
+ } | {
26
+ uuid: string;
27
+ type: 'file';
28
+ }>;
29
+ }