| 1 | import type * as featurestore from "@distilled.cloud/aws/sagemaker-featurestore-runtime"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { FeatureGroup } from "./FeatureGroup.ts"; |
| 5 | |
| 6 | export interface BatchWriteRecordEntry extends Omit< |
| 7 | featurestore.BatchWriteRecordEntry, |
| 8 | "FeatureGroupName" |
| 9 | > {} |
| 10 | |
| 11 | export interface BatchWriteRecordRequest { |
| 12 | /** |
| 13 | * The records to ingest into the bound feature group. Each entry may set |
| 14 | * its own `TargetStores` / `TtlDuration`. |
| 15 | */ |
| 16 | Entries: BatchWriteRecordEntry[]; |
| 17 | /** |
| 18 | * Request-level TTL applied to entries that do not specify their own. |
| 19 | */ |
| 20 | TtlDuration?: featurestore.TtlDuration; |
| 21 | } |
| 22 | |
| 23 | /** |
| 24 | * Runtime binding for `sagemaker:BatchWriteRecord` — bulk-ingest records |
| 25 | * into a `FeatureGroup`'s online (and offline) store in one call. |
| 26 | * |
| 27 | * Bind this operation to a `FeatureGroup` inside a function runtime to get a |
| 28 | * callable that automatically scopes every entry to the bound feature group. |
| 29 | * Per-record failures come back in the response's `Errors` / |
| 30 | * `UnprocessedEntries` rather than failing the whole call. |
| 31 | * ### Writing Records |
| 32 | * **Example:** Batch-Write Records |
| 33 | * ```typescript |
| 34 | * // init |
| 35 | * const batchWriteRecord = yield* AWS.SageMaker.BatchWriteRecord(featureGroup); |
| 36 | * |
| 37 | * // runtime |
| 38 | * const { Errors } = yield* batchWriteRecord({ |
| 39 | * Entries: [ |
| 40 | * { |
| 41 | * Record: [ |
| 42 | * { FeatureName: "user_id", ValueAsString: "user-1" }, |
| 43 | * { FeatureName: "event_time", ValueAsString: new Date().toISOString() }, |
| 44 | * { FeatureName: "clicks", ValueAsString: "1" }, |
| 45 | * ], |
| 46 | * }, |
| 47 | * ], |
| 48 | * }); |
| 49 | * ``` |
| 50 | * |
| 51 | * @binding |
| 52 | */ |
| 53 | export interface BatchWriteRecord extends Binding.Service< |
| 54 | BatchWriteRecord, |
| 55 | "AWS.SageMaker.BatchWriteRecord", |
| 56 | <F extends FeatureGroup>( |
| 57 | featureGroup: F, |
| 58 | ) => Effect.Effect< |
| 59 | ( |
| 60 | request: BatchWriteRecordRequest, |
| 61 | ) => Effect.Effect< |
| 62 | featurestore.BatchWriteRecordResponse, |
| 63 | featurestore.BatchWriteRecordError |
| 64 | > |
| 65 | > |
| 66 | > {} |
| 67 | export const BatchWriteRecord = Binding.Service<BatchWriteRecord>( |
| 68 | "AWS.SageMaker.BatchWriteRecord", |
| 69 | ); |