| 1 | import type * as frauddetector from "@distilled.cloud/aws/frauddetector"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { EventType } from "./EventType.ts"; |
| 5 | |
| 6 | /** |
| 7 | * The `eventTypeName` is injected by the binding from the bound event type; |
| 8 | * the `eventId` and optional `deleteAuditHistory` flag remain. |
| 9 | */ |
| 10 | export interface DeleteEventRequest extends Omit< |
| 11 | frauddetector.DeleteEventRequest, |
| 12 | "eventTypeName" |
| 13 | > {} |
| 14 | |
| 15 | /** |
| 16 | * Delete a stored event from Amazon Fraud Detector — the effectful erasure |
| 17 | * call made from a deployed Lambda or Task, e.g. to honor a data-deletion |
| 18 | * request. Set `deleteAuditHistory` to also remove the event's prediction |
| 19 | * history. |
| 20 | * |
| 21 | * ### Deleting Stored Events |
| 22 | * Provide the `DeleteEventHttp` implementation layer on the Function effect, |
| 23 | * bind the event type in the init phase, then call the returned client at |
| 24 | * runtime. The binding grants `frauddetector:DeleteEvent` on the event type |
| 25 | * and injects its `eventTypeName` automatically. |
| 26 | * |
| 27 | * **Example:** Delete from a Lambda |
| 28 | * ```typescript |
| 29 | * // init |
| 30 | * const deleteEvent = yield* FraudDetector.DeleteEvent(eventType); |
| 31 | * |
| 32 | * return { |
| 33 | * fetch: Effect.gen(function* () { |
| 34 | * // runtime |
| 35 | * yield* deleteEvent({ eventId: "order-123", deleteAuditHistory: true }); |
| 36 | * return HttpServerResponse.json({ ok: true }); |
| 37 | * }), |
| 38 | * }; |
| 39 | * // on the Function effect: |
| 40 | * // .pipe(Effect.provide(FraudDetector.DeleteEventHttp)) |
| 41 | * ``` |
| 42 | * |
| 43 | * @binding |
| 44 | */ |
| 45 | export interface DeleteEvent extends Binding.Service< |
| 46 | DeleteEvent, |
| 47 | "AWS.FraudDetector.DeleteEvent", |
| 48 | ( |
| 49 | eventType: EventType, |
| 50 | ) => Effect.Effect< |
| 51 | ( |
| 52 | request: DeleteEventRequest, |
| 53 | ) => Effect.Effect< |
| 54 | frauddetector.DeleteEventResult, |
| 55 | frauddetector.DeleteEventError |
| 56 | > |
| 57 | > |
| 58 | > {} |
| 59 | export const DeleteEvent = Binding.Service<DeleteEvent>( |
| 60 | "AWS.FraudDetector.DeleteEvent", |
| 61 | ); |