sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ Translate/ TranslateDocument.ts

import type * as translate from "@distilled.cloud/aws/translate";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";

/**
 * Runtime binding for `translate:TranslateDocument` — synchronously
 * translate a whole document (plain text, HTML, or Word) between a source
 * and a target language.
 *
 * One of the two language codes must be `en` (English). The document
 * content and the translated result are sensitive blobs — the response's
 * `TranslatedDocument.Content` decodes as `Redacted<Uint8Array>`.
 *
 * ### Translating Documents
 * **Example:** Translate a plain-text document
 * ```typescript
 * // init
 * const translateDocument = yield* AWS.Translate.TranslateDocument();
 *
 * // runtime
 * const result = yield* translateDocument({
 *   Document: {
 *     Content: new TextEncoder().encode("Good morning!"),
 *     ContentType: "text/plain",
 *   },
 *   SourceLanguageCode: "en",
 *   TargetLanguageCode: "es",
 * });
 * const bytes = Redacted.value(result.TranslatedDocument.Content as Redacted.Redacted<Uint8Array>);
 * // new TextDecoder().decode(bytes) === "¡Buenos días!"
 * ```
 *
 * @binding
 */
export interface TranslateDocument extends Binding.Service<
  TranslateDocument,
  "AWS.Translate.TranslateDocument",
  () => Effect.Effect<
    (
      request: translate.TranslateDocumentRequest,
    ) => Effect.Effect<translate.TranslateDocumentResponse, translate.TranslateDocumentError>
  >
> {}
export const TranslateDocument = Binding.Service<TranslateDocument>(
  "AWS.Translate.TranslateDocument",
);