| 1 | import type * as b2bi from "@distilled.cloud/aws/b2bi"; |
| 2 | import type * as Effect from "effect/Effect"; |
| 3 | import * as Binding from "../../Binding.ts"; |
| 4 | import type { Transformer } from "./Transformer.ts"; |
| 5 | |
| 6 | export interface StartTransformerJobRequest extends Omit< |
| 7 | b2bi.StartTransformerJobRequest, |
| 8 | "transformerId" |
| 9 | > {} |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for `b2bi:StartTransformerJob`. |
| 13 | * |
| 14 | * Runs an asynchronous transformer job against an EDI document in S3 — the |
| 15 | * bound {@link Transformer} (which must be `active`) parses and maps the |
| 16 | * `inputFile` and writes the result to `outputLocation`. Poll the returned |
| 17 | * `transformerJobId` with {@link GetTransformerJob}. B2BI accesses the S3 |
| 18 | * locations with its service principal, so the buckets need a bucket policy |
| 19 | * granting `b2bi.amazonaws.com` read/write access. Provide the |
| 20 | * implementation with `Effect.provide(AWS.B2BI.StartTransformerJobHttp)`. |
| 21 | * ### Running Transformer Jobs |
| 22 | * **Example:** Transform an EDI Document in S3 |
| 23 | * ```typescript |
| 24 | * // init — grants b2bi:StartTransformerJob on the transformer |
| 25 | * const startTransformerJob = yield* AWS.B2BI.StartTransformerJob(transformer); |
| 26 | * |
| 27 | * // runtime |
| 28 | * const { transformerJobId } = yield* startTransformerJob({ |
| 29 | * inputFile: { bucketName: "my-edi-bucket", key: "inbound/order.edi" }, |
| 30 | * outputLocation: { bucketName: "my-edi-bucket", key: "output/" }, |
| 31 | * }); |
| 32 | * ``` |
| 33 | * |
| 34 | * @binding |
| 35 | */ |
| 36 | export interface StartTransformerJob extends Binding.Service< |
| 37 | StartTransformerJob, |
| 38 | "AWS.B2BI.StartTransformerJob", |
| 39 | ( |
| 40 | transformer: Transformer, |
| 41 | ) => Effect.Effect< |
| 42 | ( |
| 43 | request: StartTransformerJobRequest, |
| 44 | ) => Effect.Effect< |
| 45 | b2bi.StartTransformerJobResponse, |
| 46 | b2bi.StartTransformerJobError |
| 47 | > |
| 48 | > |
| 49 | > {} |
| 50 | export const StartTransformerJob = Binding.Service<StartTransformerJob>( |
| 51 | "AWS.B2BI.StartTransformerJob", |
| 52 | ); |