| 1 | import * as sns from "@distilled.cloud/aws/sns"; |
| 2 | import * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { PlatformApplication } from "./PlatformApplication.ts"; |
| 5 | |
| 6 | export interface PublishToEndpointRequest extends Omit< |
| 7 | sns.PublishInput, |
| 8 | "TopicArn" | "PhoneNumber" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `sns:Publish`. |
| 13 | * |
| 14 | * Runtime binding for `sns:Publish` targeting a mobile-push endpoint of a |
| 15 | * {@link PlatformApplication}: pass the device `TargetArn` returned by |
| 16 | * `CreatePlatformEndpoint`. |
| 17 | * Provide the `PublishToEndpointHttp` layer on the Function to implement the binding. |
| 18 | * ### Mobile Push |
| 19 | * **Example:** Push to a Device |
| 20 | * ```typescript |
| 21 | * const publishToEndpoint = yield* SNS.PublishToEndpoint(app); |
| 22 | * yield* publishToEndpoint({ |
| 23 | * TargetArn: endpointArn, |
| 24 | * Message: "hello", |
| 25 | * }); |
| 26 | * ``` |
| 27 | * |
| 28 | * @binding |
| 29 | */ |
| 30 | export interface PublishToEndpoint extends Binding.Service< |
| 31 | PublishToEndpoint, |
| 32 | "AWS.SNS.PublishToEndpoint", |
| 33 | ( |
| 34 | application: PlatformApplication, |
| 35 | ) => Effect.Effect< |
| 36 | ( |
| 37 | request: PublishToEndpointRequest, |
| 38 | ) => Effect.Effect<sns.PublishResponse, sns.PublishError> |
| 39 | > |
| 40 | > {} |
| 41 | |
| 42 | export const PublishToEndpoint = Binding.Service<PublishToEndpoint>( |
| 43 | "AWS.SNS.PublishToEndpoint", |
| 44 | ); |