@internxt/sdk 1.4.76

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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -0
  3. package/dist/auth/index.d.ts +81 -0
  4. package/dist/auth/index.js +233 -0
  5. package/dist/auth/types.d.ts +43 -0
  6. package/dist/auth/types.js +26 -0
  7. package/dist/drive/backups/index.d.ts +18 -0
  8. package/dist/drive/backups/index.js +40 -0
  9. package/dist/drive/backups/types.d.ts +27 -0
  10. package/dist/drive/backups/types.js +2 -0
  11. package/dist/drive/index.d.ts +7 -0
  12. package/dist/drive/index.js +19 -0
  13. package/dist/drive/payments/index.d.ts +40 -0
  14. package/dist/drive/payments/index.js +91 -0
  15. package/dist/drive/payments/types.d.ts +104 -0
  16. package/dist/drive/payments/types.js +32 -0
  17. package/dist/drive/referrals/index.d.ts +19 -0
  18. package/dist/drive/referrals/index.js +51 -0
  19. package/dist/drive/referrals/types.d.ts +21 -0
  20. package/dist/drive/referrals/types.js +18 -0
  21. package/dist/drive/share/index.d.ts +74 -0
  22. package/dist/drive/share/index.js +156 -0
  23. package/dist/drive/share/types.d.ts +78 -0
  24. package/dist/drive/share/types.js +2 -0
  25. package/dist/drive/storage/index.d.ts +93 -0
  26. package/dist/drive/storage/index.js +243 -0
  27. package/dist/drive/storage/types.d.ts +174 -0
  28. package/dist/drive/storage/types.js +7 -0
  29. package/dist/drive/trash/index.d.ts +44 -0
  30. package/dist/drive/trash/index.js +132 -0
  31. package/dist/drive/trash/types.d.ts +19 -0
  32. package/dist/drive/trash/types.js +2 -0
  33. package/dist/drive/users/index.d.ts +67 -0
  34. package/dist/drive/users/index.js +123 -0
  35. package/dist/drive/users/types.d.ts +21 -0
  36. package/dist/drive/users/types.js +2 -0
  37. package/dist/index.d.ts +5 -0
  38. package/dist/index.js +30 -0
  39. package/dist/network/download.d.ts +8 -0
  40. package/dist/network/download.js +123 -0
  41. package/dist/network/errors/codes.d.ts +24 -0
  42. package/dist/network/errors/codes.js +48 -0
  43. package/dist/network/errors/context.d.ts +35 -0
  44. package/dist/network/errors/context.js +39 -0
  45. package/dist/network/errors/download.d.ts +4 -0
  46. package/dist/network/errors/download.js +48 -0
  47. package/dist/network/errors/index.d.ts +3 -0
  48. package/dist/network/errors/index.js +15 -0
  49. package/dist/network/errors/upload.d.ts +13 -0
  50. package/dist/network/errors/upload.js +78 -0
  51. package/dist/network/index.d.ts +71 -0
  52. package/dist/network/index.js +310 -0
  53. package/dist/network/types.d.ts +102 -0
  54. package/dist/network/types.js +18 -0
  55. package/dist/network/upload.d.ts +4 -0
  56. package/dist/network/upload.js +159 -0
  57. package/dist/photos/devices/index.d.ts +10 -0
  58. package/dist/photos/devices/index.js +79 -0
  59. package/dist/photos/index.d.ts +17 -0
  60. package/dist/photos/index.js +52 -0
  61. package/dist/photos/photos/index.d.ts +60 -0
  62. package/dist/photos/photos/index.js +225 -0
  63. package/dist/photos/shares/index.d.ts +8 -0
  64. package/dist/photos/shares/index.js +34 -0
  65. package/dist/photos/types.d.ts +154 -0
  66. package/dist/photos/types.js +19 -0
  67. package/dist/photos/users/index.d.ts +7 -0
  68. package/dist/photos/users/index.js +46 -0
  69. package/dist/shared/headers/index.d.ts +45 -0
  70. package/dist/shared/headers/index.js +71 -0
  71. package/dist/shared/http/client.d.ts +78 -0
  72. package/dist/shared/http/client.js +166 -0
  73. package/dist/shared/http/types.d.ts +7 -0
  74. package/dist/shared/http/types.js +2 -0
  75. package/dist/shared/index.d.ts +1 -0
  76. package/dist/shared/index.js +13 -0
  77. package/dist/shared/types/apiConnection.d.ts +12 -0
  78. package/dist/shared/types/apiConnection.js +2 -0
  79. package/dist/shared/types/appsumo.d.ts +16 -0
  80. package/dist/shared/types/appsumo.js +12 -0
  81. package/dist/shared/types/errors.d.ts +4 -0
  82. package/dist/shared/types/errors.js +27 -0
  83. package/dist/shared/types/teams.d.ts +9 -0
  84. package/dist/shared/types/teams.js +2 -0
  85. package/dist/shared/types/userSettings.d.ts +27 -0
  86. package/dist/shared/types/userSettings.js +2 -0
  87. package/dist/utils.d.ts +3 -0
  88. package/dist/utils.js +25 -0
  89. package/package.json +53 -0
@@ -0,0 +1,243 @@
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.Storage = exports.StorageTypes = void 0;
59
+ var headers_1 = require("../../shared/headers");
60
+ var client_1 = require("../../shared/http/client");
61
+ exports.StorageTypes = __importStar(require("./types"));
62
+ var Storage = /** @class */ (function () {
63
+ function Storage(apiUrl, appDetails, apiSecurity) {
64
+ this.client = client_1.HttpClient.create(apiUrl, apiSecurity.unauthorizedCallback);
65
+ this.appDetails = appDetails;
66
+ this.apiSecurity = apiSecurity;
67
+ }
68
+ Storage.client = function (apiUrl, appDetails, apiSecurity) {
69
+ return new Storage(apiUrl, appDetails, apiSecurity);
70
+ };
71
+ /**
72
+ * Creates a new folder
73
+ * @param payload
74
+ */
75
+ Storage.prototype.createFolder = function (payload) {
76
+ var _a = this.client.postCancellable('/storage/folder', {
77
+ parentFolderId: payload.parentFolderId,
78
+ folderName: payload.folderName,
79
+ }, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
80
+ return [promise, requestCanceler];
81
+ };
82
+ /**
83
+ * Moves a specific folder to a new location
84
+ * @param payload
85
+ */
86
+ Storage.prototype.moveFolder = function (payload) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ return __generator(this, function (_a) {
89
+ return [2 /*return*/, this.client.post('/storage/move/folder', {
90
+ folderId: payload.folderId,
91
+ destination: payload.destinationFolderId,
92
+ }, this.headers())];
93
+ });
94
+ });
95
+ };
96
+ /**
97
+ * Updates the metadata of a folder
98
+ * @param payload
99
+ */
100
+ Storage.prototype.updateFolder = function (payload) {
101
+ return __awaiter(this, void 0, void 0, function () {
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0: return [4 /*yield*/, this.client.post("/storage/folder/" + payload.folderId + "/meta", {
105
+ metadata: payload.changes,
106
+ }, this.headers())];
107
+ case 1:
108
+ _a.sent();
109
+ return [2 /*return*/];
110
+ }
111
+ });
112
+ });
113
+ };
114
+ /**
115
+ * Fetches & returns the contents of a specific folder
116
+ * @param folderId
117
+ */
118
+ Storage.prototype.getFolderContent = function (folderId, trash) {
119
+ if (trash === void 0) { trash = false; }
120
+ var query = trash ? '/?trash=true' : '';
121
+ var _a = this.client.getCancellable("/storage/v2/folder/" + folderId + query, this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
122
+ return [promise, requestCanceler];
123
+ };
124
+ /**
125
+ * Removes a specific folder from the centralized persistence
126
+ * @param folderId
127
+ */
128
+ Storage.prototype.deleteFolder = function (folderId) {
129
+ return this.client.delete("/storage/folder/" + folderId, this.headers());
130
+ };
131
+ /**
132
+ * Returns the total size of a folder
133
+ * @param folderId
134
+ */
135
+ Storage.prototype.getFolderSize = function (folderId) {
136
+ return this.client
137
+ .get("/storage/folder/size/" + folderId, this.headers())
138
+ .then(function (response) {
139
+ return response.size;
140
+ });
141
+ };
142
+ /**
143
+ * Creates a new file entry
144
+ * @param fileEntry
145
+ */
146
+ Storage.prototype.createFileEntry = function (fileEntry) {
147
+ return this.client.post('/storage/file', {
148
+ file: {
149
+ fileId: fileEntry.id,
150
+ type: fileEntry.type,
151
+ bucket: fileEntry.bucket,
152
+ size: fileEntry.size,
153
+ folder_id: fileEntry.folder_id,
154
+ name: fileEntry.name,
155
+ plain_name: fileEntry.plain_name,
156
+ encrypt_version: fileEntry.encrypt_version,
157
+ },
158
+ }, this.headers());
159
+ };
160
+ /**
161
+ * Creates a new thumbnail entry
162
+ * @param thumbnailEntry
163
+ */
164
+ Storage.prototype.createThumbnailEntry = function (thumbnailEntry) {
165
+ return this.client.post('/storage/thumbnail', {
166
+ thumbnail: thumbnailEntry,
167
+ }, this.headers());
168
+ };
169
+ /**
170
+ * Updates the details of a file entry
171
+ * @param payload
172
+ */
173
+ Storage.prototype.updateFile = function (payload) {
174
+ return this.client.post("/storage/file/" + payload.fileId + "/meta", {
175
+ metadata: payload.metadata,
176
+ bucketId: payload.bucketId,
177
+ relativePath: payload.destinationPath,
178
+ }, this.headers());
179
+ };
180
+ /**
181
+ * Deletes a specific file entry
182
+ * @param payload
183
+ */
184
+ Storage.prototype.deleteFile = function (payload) {
185
+ return this.client.delete("/storage/folder/" + payload.folderId + "/file/" + payload.fileId, this.headers());
186
+ };
187
+ /**
188
+ * Updates the persisted path of a file entry
189
+ * @param payload
190
+ */
191
+ Storage.prototype.moveFile = function (payload) {
192
+ return this.client.post('/storage/move/file', {
193
+ fileId: payload.fileId,
194
+ destination: payload.destination,
195
+ relativePath: payload.destinationPath,
196
+ bucketId: payload.bucketId,
197
+ }, this.headers());
198
+ };
199
+ /**
200
+ * Returns a list of the n most recent files
201
+ * @param limit
202
+ */
203
+ Storage.prototype.getRecentFiles = function (limit) {
204
+ return this.client.get("/storage/recents?limit=" + limit, this.headers());
205
+ };
206
+ /**
207
+ * Returns a list of items in trash
208
+ */
209
+ Storage.prototype.getTrash = function () {
210
+ var _a = this.client.getCancellable('/storage/trash', this.headers()), promise = _a.promise, requestCanceler = _a.requestCanceler;
211
+ return [promise, requestCanceler];
212
+ };
213
+ /**
214
+ * Add Items to Trash
215
+ * @param payload
216
+ */
217
+ Storage.prototype.addItemsToTrash = function (payload) {
218
+ return this.client.post('/storage/trash/add', {
219
+ items: payload.items,
220
+ }, this.headers());
221
+ };
222
+ /**
223
+ * Returns the current space usage of the user
224
+ */
225
+ Storage.prototype.spaceUsage = function () {
226
+ return this.client.get('/usage', this.headers());
227
+ };
228
+ /**
229
+ * Returns the current space limit for the user
230
+ */
231
+ Storage.prototype.spaceLimit = function () {
232
+ return this.client.get('/limit', this.headers());
233
+ };
234
+ /**
235
+ * Returns the needed headers for the module requests
236
+ * @private
237
+ */
238
+ Storage.prototype.headers = function () {
239
+ return (0, headers_1.headersWithTokenAndMnemonic)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, this.apiSecurity.mnemonic);
240
+ };
241
+ return Storage;
242
+ }());
243
+ exports.Storage = Storage;
@@ -0,0 +1,174 @@
1
+ export interface DriveFolderData {
2
+ id: number;
3
+ bucket: string | null;
4
+ color: string | null;
5
+ createdAt: string;
6
+ deleted: boolean;
7
+ encrypt_version: string | null;
8
+ icon: string | null;
9
+ iconId: number | null;
10
+ icon_id: number | null;
11
+ name: string;
12
+ plain_name: string;
13
+ parentId: number | null;
14
+ parent_id: number | null;
15
+ updatedAt: string;
16
+ userId: number;
17
+ user_id: number;
18
+ }
19
+ export interface DriveFileData {
20
+ bucket: string;
21
+ createdAt: string;
22
+ created_at: string;
23
+ deleted: boolean;
24
+ deletedAt: null;
25
+ encrypt_version: string;
26
+ fileId: string;
27
+ folderId: number;
28
+ folder_id: number;
29
+ id: number;
30
+ name: string;
31
+ plain_name: string;
32
+ size: number;
33
+ type: string;
34
+ updatedAt: string;
35
+ thumbnails: Array<Thumbnail>;
36
+ currentThumbnail: Thumbnail | null;
37
+ }
38
+ export interface Thumbnail {
39
+ id: number;
40
+ file_id: number;
41
+ max_width: number;
42
+ max_height: number;
43
+ type: string;
44
+ size: number;
45
+ bucket_id: string;
46
+ bucket_file: string;
47
+ encrypt_version: string;
48
+ urlObject?: string;
49
+ }
50
+ export interface FolderChild {
51
+ bucket: string;
52
+ color: string;
53
+ createdAt: string;
54
+ encrypt_version: string;
55
+ icon: string;
56
+ iconId: number | null;
57
+ icon_id: number | null;
58
+ id: number;
59
+ name: string;
60
+ plain_name: string;
61
+ parentId: number;
62
+ parent_id: number;
63
+ updatedAt: string;
64
+ userId: number;
65
+ user_id: number;
66
+ }
67
+ export interface FetchFolderContentResponse {
68
+ bucket: string;
69
+ children: FolderChild[];
70
+ color: string;
71
+ createdAt: string;
72
+ encrypt_version: string;
73
+ files: DriveFileData[];
74
+ icon: string;
75
+ id: number;
76
+ name: string;
77
+ plain_name: string;
78
+ parentId: number;
79
+ parent_id: number;
80
+ updatedAt: string;
81
+ userId: number;
82
+ user_id: number;
83
+ }
84
+ export declare enum EncryptionVersion {
85
+ Aes03 = "03-aes"
86
+ }
87
+ export interface FileEntry {
88
+ id: string;
89
+ type: string;
90
+ size: number;
91
+ name: string;
92
+ plain_name: string;
93
+ bucket: string;
94
+ folder_id: number;
95
+ encrypt_version: EncryptionVersion;
96
+ }
97
+ export interface ThumbnailEntry {
98
+ file_id: number;
99
+ max_width: number;
100
+ max_height: number;
101
+ type: string;
102
+ size: number;
103
+ bucket_id: string;
104
+ bucket_file: string;
105
+ encrypt_version: EncryptionVersion;
106
+ }
107
+ export interface CreateFolderPayload {
108
+ parentFolderId: number;
109
+ folderName: string;
110
+ }
111
+ export interface CreateFolderResponse {
112
+ bucket: string;
113
+ id: number;
114
+ name: string;
115
+ plain_name: string;
116
+ parentId: number;
117
+ createdAt: string;
118
+ updatedAt: string;
119
+ userId: number;
120
+ }
121
+ export interface MoveFolderPayload {
122
+ folderId: number;
123
+ destinationFolderId: number;
124
+ }
125
+ export interface MoveFolderResponse {
126
+ item: DriveFolderData;
127
+ destination: number;
128
+ moved: boolean;
129
+ }
130
+ export interface UpdateFolderMetadataPayload {
131
+ folderId: number;
132
+ changes: {
133
+ itemName?: string;
134
+ color?: string;
135
+ icon?: string;
136
+ };
137
+ }
138
+ export interface UpdateFilePayload {
139
+ fileId: string;
140
+ bucketId: string;
141
+ destinationPath: string;
142
+ metadata: {
143
+ itemName?: string;
144
+ };
145
+ }
146
+ export interface DeleteFilePayload {
147
+ fileId: number;
148
+ folderId: number;
149
+ }
150
+ export interface MoveFilePayload {
151
+ fileId: string;
152
+ destination: number;
153
+ destinationPath: string;
154
+ bucketId: string;
155
+ }
156
+ export interface MoveFileResponse {
157
+ item: DriveFileData;
158
+ destination: number;
159
+ moved: boolean;
160
+ }
161
+ export declare type UsageResponse = {
162
+ _id: string;
163
+ } & {
164
+ [k in 'drive' | 'backups' | 'total']: number;
165
+ };
166
+ export interface FetchLimitResponse {
167
+ maxSpaceBytes: number;
168
+ }
169
+ export interface AddItemsToTrashPayload {
170
+ items: Array<{
171
+ id: string;
172
+ type: string;
173
+ }>;
174
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EncryptionVersion = void 0;
4
+ var EncryptionVersion;
5
+ (function (EncryptionVersion) {
6
+ EncryptionVersion["Aes03"] = "03-aes";
7
+ })(EncryptionVersion = exports.EncryptionVersion || (exports.EncryptionVersion = {}));
@@ -0,0 +1,44 @@
1
+ import { AddItemsToTrashPayload, DeleteFilePayload, DeleteItemsPermanentlyPayload } from './types';
2
+ import { FetchFolderContentResponse } from '../storage/types';
3
+ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
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
+ * Add Items to Trash
27
+ * @param payload
28
+ */
29
+ addItemsToTrash(payload: AddItemsToTrashPayload): Promise<unknown>;
30
+ /**
31
+ * Removes all items from the trash
32
+ */
33
+ clearTrash(): Promise<void>;
34
+ /**
35
+ * Deletes trashed items permanently
36
+ * @param payload
37
+ */
38
+ deleteItemsPermanently(payload: DeleteItemsPermanentlyPayload): Promise<unknown>;
39
+ /**
40
+ * Returns the needed headers for the module requests
41
+ * @private
42
+ */
43
+ private headers;
44
+ }
@@ -0,0 +1,132 @@
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
+ * Add Items to Trash
101
+ * @param payload
102
+ */
103
+ Trash.prototype.addItemsToTrash = function (payload) {
104
+ return this.client.post('/storage/trash/add', {
105
+ items: payload.items,
106
+ }, this.headers());
107
+ };
108
+ /**
109
+ * Removes all items from the trash
110
+ */
111
+ Trash.prototype.clearTrash = function () {
112
+ return this.client.delete('/storage/trash/all', this.headers());
113
+ };
114
+ /**
115
+ * Deletes trashed items permanently
116
+ * @param payload
117
+ */
118
+ Trash.prototype.deleteItemsPermanently = function (payload) {
119
+ return this.client.delete('/storage/trash', this.headers(), {
120
+ items: payload.items,
121
+ });
122
+ };
123
+ /**
124
+ * Returns the needed headers for the module requests
125
+ * @private
126
+ */
127
+ Trash.prototype.headers = function () {
128
+ return (0, headers_1.headersWithTokenAndMnemonic)(this.appDetails.clientName, this.appDetails.clientVersion, this.apiSecurity.token, this.apiSecurity.mnemonic);
129
+ };
130
+ return Trash;
131
+ }());
132
+ exports.Trash = Trash;
@@ -0,0 +1,19 @@
1
+ export interface AddItemsToTrashPayload {
2
+ items: Array<{
3
+ id: string;
4
+ type: string;
5
+ }>;
6
+ }
7
+ export interface DeleteFilePayload {
8
+ fileId: number;
9
+ folderId: number;
10
+ }
11
+ export interface DeleteItemsPermanentlyPayload {
12
+ items: Array<{
13
+ id: number;
14
+ type: 'folder';
15
+ } | {
16
+ id: string;
17
+ type: 'file';
18
+ }>;
19
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,67 @@
1
+ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
2
+ import { ChangePasswordPayload, FriendInvite, InitializeUserResponse, UpdateProfilePayload } from './types';
3
+ import { UserSettings } from '../../shared/types/userSettings';
4
+ export * as UserTypes from './types';
5
+ export declare class Users {
6
+ private readonly client;
7
+ private readonly appDetails;
8
+ private readonly apiSecurity;
9
+ static client(apiUrl: ApiUrl, appDetails: AppDetails, apiSecurity: ApiSecurity): Users;
10
+ private constructor();
11
+ /**
12
+ * Sends an invitation to the specified email
13
+ * @param email
14
+ */
15
+ sendInvitation(email: string): Promise<void>;
16
+ /**
17
+ * Initialize basic state of user and returns data after registration process
18
+ * @param email
19
+ * @param mnemonic
20
+ */
21
+ initialize(email: string, mnemonic: string): Promise<InitializeUserResponse>;
22
+ /**
23
+ * Returns fresh data of the user
24
+ */
25
+ refreshUser(): Promise<{
26
+ user: UserSettings;
27
+ token: string;
28
+ }>;
29
+ /**
30
+ * Updates the authentication credentials
31
+ * @param payload
32
+ */
33
+ changePassword(payload: ChangePasswordPayload): Promise<unknown>;
34
+ /**
35
+ * Updates a user profile
36
+ * @param payload
37
+ */
38
+ updateProfile(payload: UpdateProfilePayload): Promise<void>;
39
+ /**
40
+ * Updates a user avatar
41
+ * @param payload
42
+ */
43
+ updateAvatar(payload: {
44
+ avatar: Blob;
45
+ }): Promise<{
46
+ avatar: string;
47
+ }>;
48
+ /**
49
+ * Delete current user avatar
50
+ */
51
+ deleteAvatar(): Promise<void>;
52
+ /**
53
+ * Gets all friend invites created by this user
54
+ */
55
+ getFriendInvites(): Promise<FriendInvite[]>;
56
+ /**
57
+ * Sends verification email
58
+ */
59
+ sendVerificationEmail(): Promise<void>;
60
+ /**
61
+ * Verifies user email
62
+ */
63
+ verifyEmail(payload: {
64
+ verificationToken: string;
65
+ }): Promise<void>;
66
+ private headers;
67
+ }