@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 53 lines 1.78 KB
Raw
1 import type * as frauddetector from "@distilled.cloud/aws/frauddetector";
2 import * as Binding from "alchemy/Binding";
3 import type * as Effect from "effect/Effect";
4 import type { EventType } from "./EventType.ts";
5
6 /**
7 * The `eventTypeName` is injected by the binding from the bound event type;
8 * only the `eventId` remains.
9 */
10 export interface GetEventRequest extends Omit<frauddetector.GetEventRequest, "eventTypeName"> {}
11
12 /**
13 * Read a stored event (its entities and variable values) back from Amazon
14 * Fraud Detector — the effectful lookup call made from a deployed Lambda or
15 * Task. Events are stored by `SendEvent` or by predictions on an event type
16 * with ingestion enabled.
17 *
18 * ### Reading Stored Events
19 * Provide the `GetEventHttp` implementation layer on the Function effect,
20 * bind the event type in the init phase, then call the returned client at
21 * runtime. The binding grants `frauddetector:GetEvent` on the event type and
22 * injects its `eventTypeName` automatically.
23 *
24 * **Example:** Read from a Lambda
25 * ```typescript
26 * // init
27 * const getEvent = yield* FraudDetector.GetEvent(eventType);
28 *
29 * return {
30 * fetch: Effect.gen(function* () {
31 * // runtime
32 * const { event } = yield* getEvent({ eventId: "order-123" });
33 * return HttpServerResponse.json({ variables: event?.eventVariables });
34 * }),
35 * };
36 * // on the Function effect:
37 * // .pipe(Effect.provide(FraudDetector.GetEventHttp))
38 * ```
39 *
40 * @binding
41 */
42 export interface GetEvent extends Binding.Service<
43 GetEvent,
44 "AWS.FraudDetector.GetEvent",
45 (
46 eventType: EventType,
47 ) => Effect.Effect<
48 (
49 request: GetEventRequest,
50 ) => Effect.Effect<frauddetector.GetEventResult, frauddetector.GetEventError>
51 >
52 > {}
53 export const GetEvent = Binding.Service<GetEvent>("AWS.FraudDetector.GetEvent");