| 1 | import * as Effect from "effect/Effect"; |
| 2 | import type { BucketNotification } from "./BucketNotifications.ts"; |
| 3 | import type { S3EventType, S3Record } from "./S3Event.ts"; |
| 4 | |
| 5 | export const normalizeBucketNotification = (record: S3Record) => |
| 6 | Effect.sync((): BucketNotification => ({ |
| 7 | type: `s3:${record.eventName.replace(/^s3:/, "")}` as S3EventType, |
| 8 | bucket: record.s3.bucket.name, |
| 9 | key: decodeURIComponent(record.s3.object.key.replace(/\+/g, " ")), |
| 10 | size: record.s3.object.size, |
| 11 | eTag: record.s3.object.eTag, |
| 12 | versionId: record.s3.object.versionId ?? undefined, |
| 13 | sequencer: record.s3.object.sequencer, |
| 14 | })); |