sailfork / t3code-github / .repos/ alchemy-effect/ packages/ aws/ src/ QApps/ CreatePresignedUrl.ts

import type * as qapps from "@distilled.cloud/aws/qapps";
import * as Binding from "alchemy/Binding";
import type * as Effect from "effect/Effect";
import type { QApp } from "./QApp.ts";

/**
 * Request for {@link CreatePresignedUrl} — `instanceId` and `appId` are injected from the bound Q App.
 */
export interface CreatePresignedUrlRequest extends Omit<
  qapps.CreatePresignedUrlInput,
  "instanceId" | "appId"
> {}

/**
 * Runtime binding for `qapps:CreatePresignedUrl`.
 *
 * Creates a presigned upload URL for a file-upload card of the bound Q App. Provide the implementation with
 * `Effect.provide(AWS.QApps.CreatePresignedUrlHttp)`.
 * ### Files
 * **Example:** Create a Presigned Upload URL
 * ```typescript
 * // init — bind the operation to the Q App
 * const createPresignedUrl = yield* AWS.QApps.CreatePresignedUrl(app);
 *
 * // runtime
 * const upload = yield* createPresignedUrl({
 *   cardId,
 *   fileContentsSha256,
 *   fileName: "report.pdf",
 *   scope: "SESSION",
 *   sessionId,
 * });
 * console.log(upload.presignedUrl);
 * ```
 *
 * @binding
 */
export interface CreatePresignedUrl extends Binding.Service<
  CreatePresignedUrl,
  "AWS.QApps.CreatePresignedUrl",
  (
    app: QApp,
  ) => Effect.Effect<
    (
      request: CreatePresignedUrlRequest,
    ) => Effect.Effect<qapps.CreatePresignedUrlOutput, qapps.CreatePresignedUrlError>
  >
> {}

export const CreatePresignedUrl = Binding.Service<CreatePresignedUrl>(
  "AWS.QApps.CreatePresignedUrl",
);