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, 03:37 UTC
| 1 | import * as Kinesis from "@distilled.cloud/aws/kinesis"; |
| 2 | import * as Binding from "alchemy/Binding"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import type { Stream } from "./Stream.ts"; |
| 5 | |
| 6 | export interface PutRecordRequest extends Omit<Kinesis.PutRecordInput, "StreamName"> {} |
| 7 | |
| 8 | /** |
| 9 | * Runtime binding for `kinesis:PutRecord`. |
| 10 | * |
| 11 | * Bind this operation to a `Stream` in the function's init phase to get a |
| 12 | * callable that writes single records — the stream name is injected |
| 13 | * automatically and `kinesis:PutRecord` is granted on the stream. Provide the |
| 14 | * implementation with `Effect.provide(AWS.Kinesis.PutRecordHttp)`. |
| 15 | * ### Writing Records |
| 16 | * **Example:** Put a Record from a Handler |
| 17 | * ```typescript |
| 18 | * export default MyFunction.make( |
| 19 | * { main: import.meta.url, functionUrl: true }, |
| 20 | * Effect.gen(function* () { |
| 21 | * const stream = yield* AWS.Kinesis.Stream("OrdersStream"); |
| 22 | * // init — bind the operation to the stream |
| 23 | * const putRecord = yield* AWS.Kinesis.PutRecord(stream); |
| 24 | * |
| 25 | * return { |
| 26 | * fetch: Effect.gen(function* () { |
| 27 | * // runtime — write a record |
| 28 | * yield* putRecord({ |
| 29 | * PartitionKey: "order-123", |
| 30 | * Data: new TextEncoder().encode(JSON.stringify({ orderId: "123" })), |
| 31 | * }); |
| 32 | * return HttpServerResponse.text("sent"); |
| 33 | * }).pipe(Effect.orDie), |
| 34 | * }; |
| 35 | * }).pipe(Effect.provide(AWS.Kinesis.PutRecordHttp)), |
| 36 | * ); |
| 37 | * ``` |
| 38 | * |
| 39 | * @binding |
| 40 | */ |
| 41 | export interface PutRecord extends Binding.Service< |
| 42 | PutRecord, |
| 43 | "AWS.Kinesis.PutRecord", |
| 44 | ( |
| 45 | stream: Stream, |
| 46 | ) => Effect.Effect< |
| 47 | (request: PutRecordRequest) => Effect.Effect<Kinesis.PutRecordOutput, Kinesis.PutRecordError> |
| 48 | > |
| 49 | > {} |
| 50 | |
| 51 | export const PutRecord = Binding.Service<PutRecord>("AWS.Kinesis.PutRecord"); |