sailfork / t3code-github / .repos/ alchemy-effect/ packages/ gcp/ src/ Bigtable/ GetTable.ts

import type * as bigtable from "@distilled.cloud/gcp/bigtableadmin_v2";
import * as Binding from "alchemy/Binding";
import type { RuntimeContext } from "alchemy/RuntimeContext";
import type * as Effect from "effect/Effect";
import type { Table } from "./Table.ts";

export interface GetTableRequest extends Omit<bigtable.GetProjectsInstancesTablesRequest, "name"> {}

/**
 * Runtime binding for Bigtable Admin `tables.get`.
 *
 * Bind this operation to a {@link Table} in a Function/Action init
 * phase. Provide {@link GetTableHttp}.
 *
 * ### Observing Tables
 * **Example:** Read the bound table
 * ```typescript
 * const getTable = yield* GCP.Bigtable.GetTable(users);
 * const live = yield* getTable({ view: "SCHEMA_VIEW" });
 * ```
 *
 * @binding
 * @category Bigtable
 */
export interface GetTable extends Binding.Service<
  GetTable,
  "GCP.Bigtable.GetTable",
  (
    table: Table,
  ) => Effect.Effect<
    (
      request?: GetTableRequest,
    ) => Effect.Effect<bigtable.Table, bigtable.GetProjectsInstancesTablesError, RuntimeContext>
  >
> {}

export const GetTable = Binding.Service<GetTable>("GCP.Bigtable.GetTable");