import * as rdc from "@distilled.cloud/cloudflare/r2-data-catalog"; import * as Redacted from "effect/Redacted"; import * as Provider from "../../Provider.ts"; import { Resource } from "../../Resource.ts"; import { CloudflareEnvironment } from "../CloudflareEnvironment.ts"; import type { Providers } from "../Providers.ts"; declare const TypeId: "Cloudflare.R2.DataCatalog"; type TypeId = typeof TypeId; /** * Whether a maintenance job (compaction or snapshot expiration) runs. */ export type MaintenanceState = "enabled" | "disabled"; /** * Target output file size, in MB, that catalog compaction rewrites small * files into. */ export type TargetSizeMb = "64" | "128" | "256" | "512"; /** * Catalog-level compaction maintenance settings. */ export type Compaction = { /** * Whether compaction runs for tables in this catalog. */ state?: MaintenanceState; /** * Target output file size, in MB. * @default "128" */ targetSizeMb?: TargetSizeMb; }; /** * Catalog-level snapshot expiration maintenance settings. */ export type SnapshotExpiration = { /** * Whether snapshot expiration runs for tables in this catalog. */ state?: MaintenanceState; /** * Maximum age a snapshot may reach before it is expired, expressed as a * duration string (e.g. `"7d"`). */ maxSnapshotAge?: string; /** * Minimum number of snapshots retained per table regardless of age. */ minSnapshotsToKeep?: number; }; export type DataCatalogProps = { /** * Name of the R2 bucket to enable the Iceberg data catalog on. The bucket * must already exist — pass `bucket.bucketName` from a `Cloudflare.R2.Bucket` * resource to order catalog-after-bucket. Changing the bucket replaces the * catalog (the old bucket's catalog is disabled; table data is untouched). */ bucketName: string; /** * Compaction maintenance configuration. Only the fields you specify are * enforced; omitted fields keep Cloudflare's defaults. */ compaction?: Compaction; /** * Snapshot expiration maintenance configuration. Only the fields you * specify are enforced; omitted fields keep Cloudflare's defaults. */ snapshotExpiration?: SnapshotExpiration; /** * Cloudflare API token (with R2 read/write access) the catalog uses to * run maintenance jobs against the bucket. Write-only: Cloudflare exposes * only `credentialStatus: "present" | "absent"`, never the token itself. * Maintenance jobs stay pending until a credential is provided. */ token?: Redacted.Redacted; }; export type DataCatalogAttributes = { /** * Unique identifier of the catalog (stable across disable/enable cycles). */ catalogId: string; /** * Catalog (warehouse) name, generated by Cloudflare as * `{accountId}_{bucketName}`. */ name: string; /** * Name of the R2 bucket backing the catalog. */ bucketName: string; /** * The Cloudflare account the catalog belongs to. */ accountId: string; /** * Catalog status. A reconciled catalog is always `active`. */ status: "active" | "inactive"; /** * Whether a maintenance credential is registered for this catalog. */ credentialStatus: "present" | "absent" | (string & {}); /** * Observed compaction maintenance configuration. */ compaction: { state: MaintenanceState; targetSizeMb: TargetSizeMb; } | undefined; /** * Observed snapshot expiration maintenance configuration. */ snapshotExpiration: { state: MaintenanceState; maxSnapshotAge: string; minSnapshotsToKeep: number; } | undefined; /** * Iceberg REST catalog URI for this warehouse — point PyIceberg, Spark, or * any Iceberg REST client at this endpoint. */ catalogUri: string; }; export type DataCatalog = Resource; /** * Apache Iceberg data catalog attached to a Cloudflare R2 bucket. * * R2 Data Catalog exposes an Iceberg REST catalog endpoint backed by an R2 * bucket, so engines like Spark, PyIceberg, and DuckDB can create and query * Iceberg tables stored in R2. The catalog is a singleton per bucket: this * resource enables it, keeps its maintenance configuration in sync, and * disables it on destroy (table data in the bucket is never deleted). * ### Enabling a catalog * **Example:** Enable the catalog on an R2 bucket * ```typescript * const bucket = yield* Cloudflare.R2.Bucket("LakehouseBucket"); * * const catalog = yield* Cloudflare.R2.R2DataCatalog("Lakehouse", { * bucketName: bucket.bucketName, * }); * * // Point any Iceberg REST client at the warehouse: * const uri = catalog.catalogUri; * const warehouse = catalog.name; * ``` * * ### Maintenance * **Example:** Configure compaction and snapshot expiration * ```typescript * const catalog = yield* Cloudflare.R2.R2DataCatalog("Lakehouse", { * bucketName: bucket.bucketName, * compaction: { state: "enabled", targetSizeMb: "256" }, * snapshotExpiration: { * state: "enabled", * maxSnapshotAge: "3d", * minSnapshotsToKeep: 5, * }, * }); * ``` * * **Example:** Register a maintenance credential * ```typescript * // Maintenance jobs need an API token with R2 read/write on the bucket. * const catalog = yield* Cloudflare.R2.R2DataCatalog("Lakehouse", { * bucketName: bucket.bucketName, * compaction: { state: "enabled" }, * token: maintenanceToken, // Redacted * }); * ``` * * @see https://developers.cloudflare.com/r2/data-catalog/ * * @resource * @product R2 Data Catalog * @category Storage & Databases */ export declare const DataCatalog: import("../../Resource.ts").ResourceClass; /** * Returns true if the given value is an R2DataCatalog resource. */ export declare const isDataCatalog: (value: unknown) => value is DataCatalog; export declare const DataCatalogProvider: () => import("effect/Layer").Layer, never, CloudflareEnvironment | rdc.CloudflareOpContext>; export {}; //# sourceMappingURL=DataCatalog.d.ts.map