import type * as lambda from "aws-lambda"; import * as Effect from "effect/Effect"; import * as Stream from "effect/Stream"; import * as Binding from "../../Binding.ts"; import type { Topic } from "./Topic.ts"; export type TopicNotification = lambda.SNSMessage; export interface TopicEventSourceProps { /** * Raw SNS subscription attributes for the Lambda subscription, such as * `FilterPolicy` or `RedrivePolicy`. */ attributes?: Record; } export class TopicEventSource extends Binding.Service< TopicEventSource, TopicEventSourceService >()("AWS.SNS.TopicEventSource") {} export type TopicEventSourceService = ( topic: Topic, props: TopicEventSourceProps, process: ( stream: Stream.Stream, ) => Effect.Effect, ) => Effect.Effect; export const notifications = ( topic: T, props: TopicEventSourceProps = {}, ) => ({ subscribe: ( process: ( stream: Stream.Stream, ) => Effect.Effect, ) => TopicEventSource.asEffect().pipe( Effect.flatMap((source) => source(topic, props, process)), ), });