1import type * as Firehose from "@distilled.cloud/aws/firehose";
2import type * as Effect from "effect/Effect";
3import * as Binding from "../../Binding.ts";
4import type { DeliveryStream } from "./DeliveryStream.ts";
5
6export interface PutRecordRequest extends Omit<
7 Firehose.PutRecordInput,
8 "DeliveryStreamName"
9> {}
10
11/**
12 * Writes a single data record into a Firehose delivery stream.
13 *
14 * Grants `firehose:PutRecord` on the bound delivery stream. The data blob
15 * can be up to 1,000 KiB; Firehose buffers records before delivering them to
16 * the destination, so use a delimiter (e.g. `\n`) to disambiguate records.
17 * ### Putting Records
18 * **Example:** Put a record from a handler
19 * ```typescript
20 * // init
21 * const putRecord = yield* AWS.Firehose.PutRecord(deliveryStream);
22 *
23 * return {
24 * fetch: Effect.gen(function* () {
25 * // runtime
26 * const response = yield* putRecord({
27 * Record: { Data: new TextEncoder().encode("hello\n") },
28 * });
29 * return HttpServerResponse.json({ recordId: response.RecordId });
30 * }),
31 * };
32 * ```
33 *
34 * @binding
35 */
36export interface PutRecord extends Binding.Service<
37 PutRecord,
38 "AWS.Firehose.PutRecord",
39 (
40 deliveryStream: DeliveryStream,
41 ) => Effect.Effect<
42 (
43 request: PutRecordRequest,
44 ) => Effect.Effect<Firehose.PutRecordOutput, Firehose.PutRecordError>
45 >
46> {}
47
48export const PutRecord = Binding.Service<PutRecord>("AWS.Firehose.PutRecord");