@remit/storage-service 0.0.14 → 0.0.15

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.
@@ -289,6 +289,9 @@ export const createFilesystemStorageService = (basePath, uploadUrls) => {
289
289
  await pipeline(body, createWriteStream(fullPath));
290
290
  return key;
291
291
  },
292
+ deleteExportArchive: (accountConfigId, exportRequestId) => rm(join(basePath, buildExportArchiveKey(accountConfigId, exportRequestId)), {
293
+ force: true,
294
+ }),
292
295
  getPresignedDownloadUrl: (_key, _expiresInSeconds) => {
293
296
  throw new Error("getPresignedDownloadUrl is not supported on the filesystem backend");
294
297
  },
@@ -342,6 +342,12 @@ export const createS3StorageService = (client, bucketName) => {
342
342
  });
343
343
  return key;
344
344
  };
345
+ const deleteExportArchive = async (accountConfigId, exportRequestId) => {
346
+ await client.send(new DeleteObjectCommand({
347
+ Bucket: bucketName,
348
+ Key: buildExportArchiveKey(accountConfigId, exportRequestId),
349
+ }));
350
+ };
345
351
  const getPresignedDownloadUrl = (key, expiresInSeconds) => getSignedUrl(client, new GetObjectCommand({ Bucket: bucketName, Key: key }), { expiresIn: expiresInSeconds });
346
352
  return {
347
353
  storeMessageBody,
@@ -365,6 +371,7 @@ export const createS3StorageService = (client, bucketName) => {
365
371
  exists,
366
372
  delete: del,
367
373
  storeExportArchiveStream,
374
+ deleteExportArchive,
368
375
  getPresignedDownloadUrl,
369
376
  };
370
377
  };
package/dist/storage.d.ts CHANGED
@@ -197,6 +197,11 @@ export interface StorageService {
197
197
  * storage key, which `getPresignedDownloadUrl` can then sign.
198
198
  */
199
199
  storeExportArchiveStream(accountConfigId: string, exportRequestId: string, body: Readable): Promise<string>;
200
+ /**
201
+ * Delete the export archive of the given config + request. Deleting a
202
+ * missing archive is a no-op.
203
+ */
204
+ deleteExportArchive(accountConfigId: string, exportRequestId: string): Promise<void>;
200
205
  /**
201
206
  * Generate a presigned URL that grants temporary GET access to a raw S3 key.
202
207
  * Use for export archives — the key must already exist in the bucket.
package/dist/storage.js CHANGED
@@ -214,6 +214,9 @@ export const createMockStorageService = () => {
214
214
  storage.set(`mock://${key}`, Buffer.concat(chunks));
215
215
  return key;
216
216
  },
217
+ deleteExportArchive: async (accountConfigId, exportRequestId) => {
218
+ storage.delete(`mock://${buildExportArchiveKey(accountConfigId, exportRequestId)}`);
219
+ },
217
220
  getPresignedDownloadUrl: async (key, _expiresInSeconds) => `mock://presigned/${key}`,
218
221
  };
219
222
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/storage-service",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",