diff --git a/src/api/storage/v0/storage.test.ts b/src/api/storage/v0/storage.test.ts index 42b2d57c..688d7339 100644 --- a/src/api/storage/v0/storage.test.ts +++ b/src/api/storage/v0/storage.test.ts @@ -450,11 +450,7 @@ describe('bucket notification', () => { }); beforeAll(async () => { - await bucket('test-bucket').on( - BucketNotificationType.Write, - 'test.png', - mockFn - ); + await bucket('test-bucket').on('write', 'test.png', mockFn); }); it('should create a new FaasClient', () => { @@ -464,7 +460,7 @@ describe('bucket notification', () => { it('should provide Faas with BucketNotificationWorkerOptions', () => { const expectedOpts = new BucketNotificationWorkerOptions( 'test-bucket', - BucketNotificationType.Write, + 'write', 'test.png' ); expect(faas.Faas).toBeCalledWith(expectedOpts); @@ -481,11 +477,7 @@ describe('bucket notification', () => { }); beforeAll(async () => { - await bucket('test-bucket').on( - BucketNotificationType.Delete, - 'test.png', - mockFn - ); + await bucket('test-bucket').on('delete', 'test.png', mockFn); }); it('should create a new FaasClient', () => { @@ -495,7 +487,7 @@ describe('bucket notification', () => { it('should provide Faas with BucketNotificationWorkerOptions', () => { const expectedOpts = new BucketNotificationWorkerOptions( 'test-bucket', - BucketNotificationType.Delete, + 'delete', 'test.png' ); expect(faas.Faas).toBeCalledWith(expectedOpts); @@ -526,7 +518,7 @@ describe('file notification', () => { let bucketResource: Bucket; beforeAll(async () => { bucketResource = bucket('test-bucket-create').for('reading'); - await bucketResource.on(BucketNotificationType.Write, 'test.png', mockFn); + await bucketResource.on('write', 'test.png', mockFn); }); afterAll(() => { @@ -544,7 +536,7 @@ describe('file notification', () => { it('should provide Faas with FileNotificationWorkerOptions', () => { const expectedOpts = new FileNotificationWorkerOptions( bucketResource, - BucketNotificationType.Write, + 'write', 'test.png' ); expect(faas.Faas).toBeCalledWith(expectedOpts); @@ -559,11 +551,7 @@ describe('file notification', () => { let bucketResource: Bucket; beforeAll(async () => { bucketResource = bucket('test-bucket-delete').for('reading'); - await bucketResource.on( - BucketNotificationType.Delete, - 'test.png', - mockFn - ); + await bucketResource.on('delete', 'test.png', mockFn); }); afterAll(() => { @@ -581,7 +569,7 @@ describe('file notification', () => { it('should provide Faas with FileNotificationWorkerOptions', () => { const expectedOpts = new FileNotificationWorkerOptions( bucketResource, - BucketNotificationType.Delete, + 'delete', 'test.png' ); expect(faas.Faas).toBeCalledWith(expectedOpts); diff --git a/src/resources/bucket.ts b/src/resources/bucket.ts index e496c9fb..8c85d284 100644 --- a/src/resources/bucket.ts +++ b/src/resources/bucket.ts @@ -34,10 +34,7 @@ type BucketPermission = 'reading' | 'writing' | 'deleting'; const everything: BucketPermission[] = ['reading', 'writing', 'deleting']; -export enum BucketNotificationType { - Write, - Delete, -} +export type BucketNotificationType = 'write' | 'delete'; export class BucketNotificationWorkerOptions { public readonly bucket: string; @@ -57,9 +54,9 @@ export class BucketNotificationWorkerOptions { static toGrpcEvent(notificationType: BucketNotificationType): 0 | 1 | 2 { switch (notificationType) { - case BucketNotificationType.Write: + case 'write': return ProtoBucketNotificationType.CREATED; - case BucketNotificationType.Delete: + case 'delete': return ProtoBucketNotificationType.DELETED; default: throw new Error(`notification type ${notificationType} is unsupported`);