@memberjunction/storage 2.30.0 → 2.32.0

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 (37) hide show
  1. package/dist/drivers/AWSFileStorage.d.ts +26 -1
  2. package/dist/drivers/AWSFileStorage.d.ts.map +1 -1
  3. package/dist/drivers/AWSFileStorage.js +287 -13
  4. package/dist/drivers/AWSFileStorage.js.map +1 -1
  5. package/dist/drivers/AzureFileStorage.d.ts +22 -1
  6. package/dist/drivers/AzureFileStorage.d.ts.map +1 -1
  7. package/dist/drivers/AzureFileStorage.js +264 -20
  8. package/dist/drivers/AzureFileStorage.js.map +1 -1
  9. package/dist/drivers/BoxFileStorage.d.ts +73 -0
  10. package/dist/drivers/BoxFileStorage.d.ts.map +1 -0
  11. package/dist/drivers/BoxFileStorage.js +517 -0
  12. package/dist/drivers/BoxFileStorage.js.map +1 -0
  13. package/dist/drivers/DropboxFileStorage.d.ts +73 -0
  14. package/dist/drivers/DropboxFileStorage.d.ts.map +1 -0
  15. package/dist/drivers/DropboxFileStorage.js +463 -0
  16. package/dist/drivers/DropboxFileStorage.js.map +1 -0
  17. package/dist/drivers/GoogleDriveFileStorage.d.ts +73 -0
  18. package/dist/drivers/GoogleDriveFileStorage.d.ts.map +1 -0
  19. package/dist/drivers/GoogleDriveFileStorage.js +542 -0
  20. package/dist/drivers/GoogleDriveFileStorage.js.map +1 -0
  21. package/dist/drivers/GoogleFileStorage.d.ts +20 -1
  22. package/dist/drivers/GoogleFileStorage.d.ts.map +1 -1
  23. package/dist/drivers/GoogleFileStorage.js +215 -2
  24. package/dist/drivers/GoogleFileStorage.js.map +1 -1
  25. package/dist/drivers/SharePointFileStorage.d.ts +81 -0
  26. package/dist/drivers/SharePointFileStorage.d.ts.map +1 -0
  27. package/dist/drivers/SharePointFileStorage.js +490 -0
  28. package/dist/drivers/SharePointFileStorage.js.map +1 -0
  29. package/dist/generic/FileStorageBase.d.ts +119 -0
  30. package/dist/generic/FileStorageBase.d.ts.map +1 -1
  31. package/dist/generic/FileStorageBase.js +18 -1
  32. package/dist/generic/FileStorageBase.js.map +1 -1
  33. package/dist/index.d.ts +4 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +4 -0
  36. package/dist/index.js.map +1 -1
  37. package/package.json +12 -4
@@ -0,0 +1,490 @@
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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
23
+ };
24
+ var __importStar = (this && this.__importStar) || function (mod) {
25
+ if (mod && mod.__esModule) return mod;
26
+ var result = {};
27
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
+ __setModuleDefault(result, mod);
29
+ return result;
30
+ };
31
+ var __metadata = (this && this.__metadata) || function (k, v) {
32
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
+ };
34
+ Object.defineProperty(exports, "__esModule", { value: true });
35
+ exports.SharePointFileStorage = void 0;
36
+ const microsoft_graph_client_1 = require("@microsoft/microsoft-graph-client");
37
+ const global_1 = require("@memberjunction/global");
38
+ const env = __importStar(require("env-var"));
39
+ const mime = __importStar(require("mime-types"));
40
+ const FileStorageBase_1 = require("../generic/FileStorageBase");
41
+ /**
42
+ * Simple implementation of AuthenticationProvider that uses client credentials flow
43
+ */
44
+ class ClientCredentialsAuthProvider {
45
+ constructor(clientId, clientSecret, tenantId) {
46
+ this.accessToken = null;
47
+ this.tokenExpiration = null;
48
+ this.clientId = clientId;
49
+ this.clientSecret = clientSecret;
50
+ this.tenantId = tenantId;
51
+ this.tokenEndpoint = `https://login.microsoftonline.com/${tenantId}/oauth2/v2.0/token`;
52
+ }
53
+ /**
54
+ * Get access token for the specified resource
55
+ */
56
+ async getAccessToken() {
57
+ if (this.accessToken && this.tokenExpiration && this.tokenExpiration > new Date()) {
58
+ return this.accessToken;
59
+ }
60
+ const data = new URLSearchParams({
61
+ client_id: this.clientId,
62
+ scope: 'https://graph.microsoft.com/.default',
63
+ client_secret: this.clientSecret,
64
+ grant_type: 'client_credentials'
65
+ });
66
+ const response = await fetch(this.tokenEndpoint, {
67
+ method: 'POST',
68
+ headers: {
69
+ 'Content-Type': 'application/x-www-form-urlencoded'
70
+ },
71
+ body: data
72
+ });
73
+ if (!response.ok) {
74
+ throw new Error(`Failed to get access token: ${response.statusText}`);
75
+ }
76
+ const json = await response.json();
77
+ this.accessToken = json.access_token;
78
+ // Set token expiration time (subtract 5 minutes as a buffer)
79
+ const expiresIn = json.expires_in || 3600;
80
+ this.tokenExpiration = new Date(Date.now() + (expiresIn - 300) * 1000);
81
+ return this.accessToken;
82
+ }
83
+ }
84
+ let SharePointFileStorage = class SharePointFileStorage extends FileStorageBase_1.FileStorageBase {
85
+ constructor() {
86
+ super();
87
+ this.providerName = 'SharePoint';
88
+ const clientId = env.get('STORAGE_SHAREPOINT_CLIENT_ID').required().asString();
89
+ const clientSecret = env.get('STORAGE_SHAREPOINT_CLIENT_SECRET').required().asString();
90
+ const tenantId = env.get('STORAGE_SHAREPOINT_TENANT_ID').required().asString();
91
+ this._siteId = env.get('STORAGE_SHAREPOINT_SITE_ID').required().asString();
92
+ this._driveId = env.get('STORAGE_SHAREPOINT_DRIVE_ID').required().asString();
93
+ // Optionally set a root folder within the SharePoint drive
94
+ this._rootFolderId = env.get('STORAGE_SHAREPOINT_ROOT_FOLDER_ID').asString();
95
+ // Initialize Graph client with auth provider
96
+ const authProvider = new ClientCredentialsAuthProvider(clientId, clientSecret, tenantId);
97
+ this._client = microsoft_graph_client_1.Client.initWithMiddleware({
98
+ authProvider: authProvider
99
+ });
100
+ }
101
+ /**
102
+ * Get the parent item ID for a given path
103
+ *
104
+ * @param path The path to get the parent folder for
105
+ * @returns The parent folder ID
106
+ */
107
+ async _getParentFolderIdByPath(path) {
108
+ if (!path || path === '/' || path === '') {
109
+ return this._rootFolderId || 'root';
110
+ }
111
+ const pathParts = path.split('/').filter(p => p);
112
+ let currentFolderId = this._rootFolderId || 'root';
113
+ for (let i = 0; i < pathParts.length; i++) {
114
+ const folderName = pathParts[i];
115
+ const result = await this._client.api(`/drives/${this._driveId}/items/${currentFolderId}/children`)
116
+ .filter(`name eq '${folderName}' and folder ne null`)
117
+ .get();
118
+ if (!result.value || result.value.length === 0) {
119
+ throw new Error(`Folder not found: ${folderName}`);
120
+ }
121
+ currentFolderId = result.value[0].id;
122
+ }
123
+ return currentFolderId;
124
+ }
125
+ /**
126
+ * Get an item by path
127
+ *
128
+ * @param path The path of the item
129
+ * @returns The item
130
+ */
131
+ async _getItemByPath(path) {
132
+ if (!path || path === '/' || path === '') {
133
+ const itemId = this._rootFolderId || 'root';
134
+ return this._client.api(`/drives/${this._driveId}/items/${itemId}`).get();
135
+ }
136
+ // Normalize path
137
+ const normalizedPath = path.startsWith('/') ? path.substring(1) : path;
138
+ try {
139
+ // Try to get the item directly by path
140
+ const driveRoot = this._rootFolderId ?
141
+ `/drives/${this._driveId}/items/${this._rootFolderId}` :
142
+ `/drives/${this._driveId}/root`;
143
+ return await this._client.api(`${driveRoot}:/${normalizedPath}`).get();
144
+ }
145
+ catch (error) {
146
+ console.error('Error getting item by path', { path, error });
147
+ throw error;
148
+ }
149
+ }
150
+ /**
151
+ * Convert a SharePoint item to a StorageObjectMetadata object
152
+ */
153
+ _itemToMetadata(item) {
154
+ const isDirectory = !!item.folder;
155
+ const parentPath = item.parentReference?.path?.split(':').pop() || '';
156
+ // Remove any root folder prefix from the parent path if present
157
+ let path = parentPath;
158
+ if (this._rootFolderId && path.startsWith(`/drives/${this._driveId}/items/${this._rootFolderId}`)) {
159
+ path = path.replace(`/drives/${this._driveId}/items/${this._rootFolderId}`, '');
160
+ }
161
+ // Ensure path starts with / and remove leading slash for storage format
162
+ path = path.startsWith('/') ? path.substring(1) : path;
163
+ // For full paths, combine parent path with name
164
+ const fullPath = path ? `${path}/${item.name}` : item.name;
165
+ return {
166
+ name: item.name,
167
+ path,
168
+ fullPath,
169
+ size: item.size || 0,
170
+ contentType: item.file?.mimeType || mime.lookup(item.name) || 'application/octet-stream',
171
+ lastModified: new Date(item.lastModifiedDateTime),
172
+ isDirectory,
173
+ etag: item.eTag,
174
+ customMetadata: {}
175
+ };
176
+ }
177
+ /**
178
+ * Create a pre-authenticated upload URL is not directly supported in SharePoint/OneDrive
179
+ */
180
+ async CreatePreAuthUploadUrl(objectName) {
181
+ // SharePoint doesn't provide a way to get pre-authenticated upload URLs like S3
182
+ // Instead, we'll use the PutObject method for actual uploads
183
+ this.throwUnsupportedOperationError('CreatePreAuthUploadUrl');
184
+ }
185
+ /**
186
+ * Create a pre-authenticated download URL for an object
187
+ */
188
+ async CreatePreAuthDownloadUrl(objectName) {
189
+ try {
190
+ const item = await this._getItemByPath(objectName);
191
+ // Request a download URL - this is a time-limited URL
192
+ const downloadUrl = await this._client.api(`/drives/${this._driveId}/items/${item.id}/createLink`)
193
+ .post({
194
+ type: 'view',
195
+ scope: 'anonymous',
196
+ expirationDateTime: new Date(Date.now() + 10 * 60 * 1000).toISOString() // 10 minutes
197
+ });
198
+ return downloadUrl.link.webUrl;
199
+ }
200
+ catch (error) {
201
+ console.error('Error creating pre-auth download URL', { objectName, error });
202
+ throw new Error(`Failed to create download URL for: ${objectName}`);
203
+ }
204
+ }
205
+ /**
206
+ * Move an object from one location to another
207
+ */
208
+ async MoveObject(oldObjectName, newObjectName) {
209
+ try {
210
+ // Get the old item
211
+ const item = await this._getItemByPath(oldObjectName);
212
+ // Parse the new path to get the new parent folder and name
213
+ const newPathParts = newObjectName.split('/');
214
+ const newName = newPathParts.pop() || '';
215
+ const newParentPath = newPathParts.join('/');
216
+ // Get the new parent folder ID
217
+ const parentFolderId = await this._getParentFolderIdByPath(newParentPath);
218
+ // Move the item
219
+ await this._client.api(`/drives/${this._driveId}/items/${item.id}`)
220
+ .update({
221
+ name: newName,
222
+ parentReference: {
223
+ id: parentFolderId
224
+ }
225
+ });
226
+ return true;
227
+ }
228
+ catch (error) {
229
+ console.error('Error moving object', { oldObjectName, newObjectName, error });
230
+ return false;
231
+ }
232
+ }
233
+ /**
234
+ * Delete an object
235
+ */
236
+ async DeleteObject(objectName) {
237
+ try {
238
+ const item = await this._getItemByPath(objectName);
239
+ // Delete the item
240
+ await this._client.api(`/drives/${this._driveId}/items/${item.id}`)
241
+ .delete();
242
+ return true;
243
+ }
244
+ catch (error) {
245
+ // Check if it's a "not found" error, which we'll consider a success for idempotency
246
+ if (error.statusCode === 404) {
247
+ return true;
248
+ }
249
+ console.error('Error deleting object', { objectName, error });
250
+ return false;
251
+ }
252
+ }
253
+ /**
254
+ * List objects in a given directory
255
+ */
256
+ async ListObjects(prefix, delimiter) {
257
+ try {
258
+ // Get the folder ID
259
+ const folder = await this._getItemByPath(prefix);
260
+ // List children
261
+ const children = await this._client.api(`/drives/${this._driveId}/items/${folder.id}/children`).get();
262
+ const objects = [];
263
+ const prefixes = [];
264
+ for (const item of children.value) {
265
+ if (item.folder) {
266
+ // This is a folder/directory
267
+ const folderPath = prefix ?
268
+ (prefix.endsWith('/') ? `${prefix}${item.name}` : `${prefix}/${item.name}`) :
269
+ item.name;
270
+ prefixes.push(`${folderPath}/`);
271
+ }
272
+ // Add all items as objects (including folders)
273
+ objects.push(this._itemToMetadata(item));
274
+ }
275
+ return { objects, prefixes };
276
+ }
277
+ catch (error) {
278
+ console.error('Error listing objects', { prefix, error });
279
+ return { objects: [], prefixes: [] };
280
+ }
281
+ }
282
+ /**
283
+ * Create a directory
284
+ */
285
+ async CreateDirectory(directoryPath) {
286
+ try {
287
+ // Remove trailing slash if present
288
+ const normalizedPath = directoryPath.endsWith('/') ?
289
+ directoryPath.substring(0, directoryPath.length - 1) :
290
+ directoryPath;
291
+ // Parse the path to get the parent folder and new folder name
292
+ const pathParts = normalizedPath.split('/');
293
+ const folderName = pathParts.pop() || '';
294
+ const parentPath = pathParts.join('/');
295
+ // Get the parent folder ID
296
+ const parentFolderId = await this._getParentFolderIdByPath(parentPath);
297
+ // Create the folder
298
+ await this._client.api(`/drives/${this._driveId}/items/${parentFolderId}/children`)
299
+ .post({
300
+ name: folderName,
301
+ folder: {},
302
+ '@microsoft.graph.conflictBehavior': 'fail'
303
+ });
304
+ return true;
305
+ }
306
+ catch (error) {
307
+ console.error('Error creating directory', { directoryPath, error });
308
+ return false;
309
+ }
310
+ }
311
+ /**
312
+ * Delete a directory and optionally its contents
313
+ */
314
+ async DeleteDirectory(directoryPath, recursive = false) {
315
+ try {
316
+ // Remove trailing slash if present
317
+ const normalizedPath = directoryPath.endsWith('/') ?
318
+ directoryPath.substring(0, directoryPath.length - 1) :
319
+ directoryPath;
320
+ const folder = await this._getItemByPath(normalizedPath);
321
+ if (!recursive) {
322
+ // Check if folder is empty
323
+ const children = await this._client.api(`/drives/${this._driveId}/items/${folder.id}/children`).get();
324
+ if (children.value && children.value.length > 0) {
325
+ throw new Error('Directory is not empty');
326
+ }
327
+ }
328
+ // Delete the folder (SharePoint will delete recursively by default)
329
+ await this._client.api(`/drives/${this._driveId}/items/${folder.id}`)
330
+ .delete();
331
+ return true;
332
+ }
333
+ catch (error) {
334
+ console.error('Error deleting directory', { directoryPath, recursive, error });
335
+ return false;
336
+ }
337
+ }
338
+ /**
339
+ * Get object metadata
340
+ */
341
+ async GetObjectMetadata(objectName) {
342
+ try {
343
+ const item = await this._getItemByPath(objectName);
344
+ return this._itemToMetadata(item);
345
+ }
346
+ catch (error) {
347
+ console.error('Error getting object metadata', { objectName, error });
348
+ throw new Error(`Object not found: ${objectName}`);
349
+ }
350
+ }
351
+ /**
352
+ * Get an object's contents
353
+ */
354
+ async GetObject(objectName) {
355
+ try {
356
+ const item = await this._getItemByPath(objectName);
357
+ // Get the content
358
+ const response = await fetch(item['@microsoft.graph.downloadUrl']);
359
+ if (!response.ok) {
360
+ throw new Error(`Failed to download item: ${response.statusText}`);
361
+ }
362
+ // Convert response to buffer
363
+ const arrayBuffer = await response.arrayBuffer();
364
+ return Buffer.from(arrayBuffer);
365
+ }
366
+ catch (error) {
367
+ console.error('Error getting object', { objectName, error });
368
+ throw new Error(`Failed to get object: ${objectName}`);
369
+ }
370
+ }
371
+ /**
372
+ * Upload an object directly
373
+ */
374
+ async PutObject(objectName, data, contentType, metadata) {
375
+ try {
376
+ // Parse the path to get the parent folder and filename
377
+ const pathParts = objectName.split('/');
378
+ const fileName = pathParts.pop() || '';
379
+ const parentPath = pathParts.join('/');
380
+ // Get the parent folder ID
381
+ const parentFolderId = await this._getParentFolderIdByPath(parentPath);
382
+ // Determine content type
383
+ const effectiveContentType = contentType || mime.lookup(objectName) || 'application/octet-stream';
384
+ if (data.length < 4 * 1024 * 1024) {
385
+ // For small files (< 4MB), use simple upload
386
+ await this._client.api(`/drives/${this._driveId}/items/${parentFolderId}:/${fileName}:/content`)
387
+ .put(data);
388
+ }
389
+ else {
390
+ // For larger files, use upload session
391
+ // Create upload session
392
+ const uploadSession = await this._client.api(`/drives/${this._driveId}/items/${parentFolderId}:/${fileName}:/createUploadSession`)
393
+ .post({
394
+ item: {
395
+ '@microsoft.graph.conflictBehavior': 'replace'
396
+ }
397
+ });
398
+ // Upload the file in chunks (could be improved with parallel uploads)
399
+ const maxChunkSize = 60 * 1024 * 1024; // 60 MB chunks
400
+ for (let i = 0; i < data.length; i += maxChunkSize) {
401
+ const chunk = data.slice(i, Math.min(i + maxChunkSize, data.length));
402
+ const contentRange = `bytes ${i}-${i + chunk.length - 1}/${data.length}`;
403
+ await fetch(uploadSession.uploadUrl, {
404
+ method: 'PUT',
405
+ headers: {
406
+ 'Content-Length': chunk.length.toString(),
407
+ 'Content-Range': contentRange
408
+ },
409
+ body: chunk
410
+ });
411
+ }
412
+ }
413
+ return true;
414
+ }
415
+ catch (error) {
416
+ console.error('Error putting object', { objectName, error });
417
+ return false;
418
+ }
419
+ }
420
+ /**
421
+ * Copy an object
422
+ */
423
+ async CopyObject(sourceObjectName, destinationObjectName) {
424
+ try {
425
+ // Get source item
426
+ const sourceItem = await this._getItemByPath(sourceObjectName);
427
+ // Parse destination path
428
+ const destPathParts = destinationObjectName.split('/');
429
+ const destName = destPathParts.pop() || '';
430
+ const destParentPath = destPathParts.join('/');
431
+ // Get destination parent folder ID
432
+ const destParentId = await this._getParentFolderIdByPath(destParentPath);
433
+ // Create a copy
434
+ await this._client.api(`/drives/${this._driveId}/items/${sourceItem.id}/copy`)
435
+ .post({
436
+ parentReference: {
437
+ id: destParentId
438
+ },
439
+ name: destName
440
+ });
441
+ return true;
442
+ }
443
+ catch (error) {
444
+ console.error('Error copying object', { sourceObjectName, destinationObjectName, error });
445
+ return false;
446
+ }
447
+ }
448
+ /**
449
+ * Check if an object exists
450
+ */
451
+ async ObjectExists(objectName) {
452
+ try {
453
+ await this._getItemByPath(objectName);
454
+ return true;
455
+ }
456
+ catch (error) {
457
+ if (error.statusCode === 404) {
458
+ return false;
459
+ }
460
+ console.error('Error checking if object exists', { objectName, error });
461
+ return false;
462
+ }
463
+ }
464
+ /**
465
+ * Check if a directory exists
466
+ */
467
+ async DirectoryExists(directoryPath) {
468
+ try {
469
+ // Remove trailing slash if present
470
+ const normalizedPath = directoryPath.endsWith('/') ?
471
+ directoryPath.substring(0, directoryPath.length - 1) :
472
+ directoryPath;
473
+ const item = await this._getItemByPath(normalizedPath);
474
+ return !!item.folder;
475
+ }
476
+ catch (error) {
477
+ if (error.statusCode === 404) {
478
+ return false;
479
+ }
480
+ console.error('Error checking if directory exists', { directoryPath, error });
481
+ return false;
482
+ }
483
+ }
484
+ };
485
+ exports.SharePointFileStorage = SharePointFileStorage;
486
+ exports.SharePointFileStorage = SharePointFileStorage = __decorate([
487
+ (0, global_1.RegisterClass)(FileStorageBase_1.FileStorageBase, 'SharePoint Storage'),
488
+ __metadata("design:paramtypes", [])
489
+ ], SharePointFileStorage);
490
+ //# sourceMappingURL=SharePointFileStorage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SharePointFileStorage.js","sourceRoot":"","sources":["../../src/drivers/SharePointFileStorage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8EAA2D;AAE3D,mDAAuD;AACvD,6CAA+B;AAC/B,iDAAmC;AACnC,gEAMoC;AAEpC;;GAEG;AACH,MAAM,6BAA6B;IAQjC,YAAY,QAAgB,EAAE,YAAoB,EAAE,QAAgB;QAH5D,gBAAW,GAAkB,IAAI,CAAC;QAClC,oBAAe,GAAgB,IAAI,CAAC;QAG1C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,aAAa,GAAG,qCAAqC,QAAQ,oBAAoB,CAAC;IACzF,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc;QACzB,IAAI,IAAI,CAAC,W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,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9E,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF,CAAA;AAndY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,sBAAa,EAAC,iCAAe,EAAE,oBAAoB,CAAC;;GACxC,qBAAqB,CAmdjC"}
@@ -1,12 +1,44 @@
1
+ /// <reference types="node" />
1
2
  export type CreatePreAuthUploadUrlPayload = {
2
3
  UploadUrl: string;
3
4
  ProviderKey?: string | undefined;
4
5
  };
6
+ export type StorageObjectMetadata = {
7
+ name: string;
8
+ path: string;
9
+ fullPath: string;
10
+ size: number;
11
+ contentType: string;
12
+ lastModified: Date;
13
+ isDirectory: boolean;
14
+ etag?: string;
15
+ cacheControl?: string;
16
+ customMetadata?: Record<string, string>;
17
+ };
18
+ export type StorageListResult = {
19
+ objects: StorageObjectMetadata[];
20
+ prefixes: string[];
21
+ };
22
+ /**
23
+ * Error thrown when a method is not supported by a storage provider
24
+ */
25
+ export declare class UnsupportedOperationError extends Error {
26
+ constructor(methodName: string, providerName: string);
27
+ }
5
28
  /**
6
29
  * Represents an abstract base class for file storage. Provides methods for creating pre-authorized upload and download URLs, as well as deleting objects. This
7
30
  * interface is implemented in specific driver classes for each storage provider.
8
31
  */
9
32
  export declare abstract class FileStorageBase {
33
+ /**
34
+ * The name of this storage provider, used in error messages
35
+ */
36
+ protected abstract readonly providerName: string;
37
+ /**
38
+ * Helper method to throw an UnsupportedOperationError
39
+ * @param methodName The name of the method that is not supported
40
+ */
41
+ protected throwUnsupportedOperationError(methodName: string): never;
10
42
  /**
11
43
  * This method is designed to generate a pre-authenticated URL for uploading files to a storage provider. It abstracts over different storage providers,
12
44
  * allowing for a unified interface to obtain upload URLs, regardless of the underlying provider's specifics. The method takes the name of the file (or
@@ -140,5 +172,92 @@ export declare abstract class FileStorageBase {
140
172
  * deletion process.
141
173
  */
142
174
  abstract DeleteObject(objectName: string): Promise<boolean>;
175
+ /**
176
+ * Lists objects in a storage provider's system with the given prefix path.
177
+ *
178
+ * This method returns a list of objects and prefixes (directories) under the specified path.
179
+ * The method supports a hierarchical directory-like structure through the use of prefixes
180
+ * that can represent "folders" within the storage.
181
+ *
182
+ * @param prefix - The path prefix to list objects from. Use "/" for the root, or paths like "documents/"
183
+ * for specific directories.
184
+ * @param delimiter - The character used to group keys. Typically "/" is used to simulate directory structure.
185
+ * Defaults to "/".
186
+ * @returns A Promise that resolves to a StorageListResult containing both objects and prefixes (directories).
187
+ */
188
+ abstract ListObjects(prefix: string, delimiter?: string): Promise<StorageListResult>;
189
+ /**
190
+ * Creates a directory in the storage system.
191
+ *
192
+ * For storage systems that don't natively support directories, this may create a zero-byte object with
193
+ * a trailing delimiter to simulate a directory. For systems with native directory support, this will
194
+ * create an actual directory.
195
+ *
196
+ * @param directoryPath - The path of the directory to create. Should end with a delimiter (typically "/").
197
+ * @returns A Promise that resolves to a boolean indicating success.
198
+ */
199
+ abstract CreateDirectory(directoryPath: string): Promise<boolean>;
200
+ /**
201
+ * Deletes a directory and optionally all of its contents recursively.
202
+ *
203
+ * @param directoryPath - The path of the directory to delete.
204
+ * @param recursive - If true, deletes all contents recursively. If false and the directory is not empty,
205
+ * the operation will fail. Defaults to false.
206
+ * @returns A Promise that resolves to a boolean indicating success.
207
+ */
208
+ abstract DeleteDirectory(directoryPath: string, recursive?: boolean): Promise<boolean>;
209
+ /**
210
+ * Retrieves metadata for a specific object without downloading its contents.
211
+ *
212
+ * @param objectName - The name of the object to retrieve metadata for.
213
+ * @returns A Promise that resolves to a StorageObjectMetadata object containing the metadata.
214
+ * If the object does not exist, the promise will be rejected.
215
+ */
216
+ abstract GetObjectMetadata(objectName: string): Promise<StorageObjectMetadata>;
217
+ /**
218
+ * Downloads an object's content as a Buffer.
219
+ *
220
+ * @param objectName - The name of the object to download.
221
+ * @returns A Promise that resolves to a Buffer containing the object's data.
222
+ * If the object does not exist, the promise will be rejected.
223
+ */
224
+ abstract GetObject(objectName: string): Promise<Buffer>;
225
+ /**
226
+ * Uploads object data to the storage provider.
227
+ *
228
+ * This is a direct upload method that doesn't use a pre-authorized URL.
229
+ *
230
+ * @param objectName - The name to assign to the uploaded object.
231
+ * @param data - The Buffer containing the data to upload.
232
+ * @param contentType - Optional MIME type of the content.
233
+ * @param metadata - Optional custom metadata to associate with the object.
234
+ * @returns A Promise that resolves to a boolean indicating success.
235
+ */
236
+ abstract PutObject(objectName: string, data: Buffer, contentType?: string, metadata?: Record<string, string>): Promise<boolean>;
237
+ /**
238
+ * Copies an object within the storage system.
239
+ *
240
+ * Unlike MoveObject which removes the source object, this creates a copy while
241
+ * leaving the original intact.
242
+ *
243
+ * @param sourceObjectName - The name of the object to copy.
244
+ * @param destinationObjectName - The name to assign to the copied object.
245
+ * @returns A Promise that resolves to a boolean indicating success.
246
+ */
247
+ abstract CopyObject(sourceObjectName: string, destinationObjectName: string): Promise<boolean>;
248
+ /**
249
+ * Checks if an object exists in the storage system.
250
+ *
251
+ * @param objectName - The name of the object to check.
252
+ * @returns A Promise that resolves to a boolean indicating if the object exists.
253
+ */
254
+ abstract ObjectExists(objectName: string): Promise<boolean>;
255
+ /**
256
+ * Checks if a directory exists in the storage system.
257
+ *
258
+ * @param directoryPath - The path of the directory to check.
259
+ * @returns A Promise that resolves to a boolean indicating if the directory exists.
260
+ */
261
+ abstract DirectoryExists(directoryPath: string): Promise<boolean>;
143
262
  }
144
263
  //# sourceMappingURL=FileStorageBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileStorageBase.d.ts","sourceRoot":"","sources":["../../src/generic/FileStorageBase.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAClC,CAAC;AAEF;;;GAGG;AACH,8BAAsB,eAAe;IACnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;aACa,sBAAsB,CAAC,UAAU,E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