{"version":3,"sources":["../src/errors/IcebergError.ts","../src/utils/url.ts","../src/http/createFetchClient.ts","../src/utils/idempotency-key.ts","../src/catalog/namespaces.ts","../src/catalog/tables.ts","../src/catalog/IcebergRestCatalog.ts","../src/catalog/types.ts","../spec-pin.json","../src/spec-version.ts"],"names":["namespaceToPath","resolvePrefix"],"mappings":";AASO,IAAM,YAAA,GAAN,cAA2B,KAAA,CAAM;AAAA,EAOtC,WAAA,CACE,SACA,IAAA,EAMA;AACA,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,cAAA;AACZ,IAAA,IAAA,CAAK,SAAS,IAAA,CAAK,MAAA;AACnB,IAAA,IAAA,CAAK,cAAc,IAAA,CAAK,WAAA;AACxB,IAAA,IAAA,CAAK,cAAc,IAAA,CAAK,WAAA;AACxB,IAAA,IAAA,CAAK,UAAU,IAAA,CAAK,OAAA;AAKpB,IAAA,IAAA,CAAK,oBAAA,GAAuB,KAAK,WAAA,KAAgB,6BAAA;AAAA,EACnD;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,GAAsB;AACpB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,UAAA,GAAsB;AACpB,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AAAA;AAAA;AAAA;AAAA,EAKA,uBAAA,GAAmC;AACjC,IAAA,OAAO,KAAK,MAAA,KAAW,GAAA;AAAA,EACzB;AACF;;;AC1DO,SAAS,QAAA,CACd,OAAA,EACA,IAAA,EACA,KAAA,EACQ;AACR,EAAA,MAAM,GAAA,GAAM,IAAI,GAAA,CAAI,IAAA,EAAM,OAAO,CAAA;AAEjC,EAAA,IAAI,KAAA,EAAO;AACT,IAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,MAAA,IAAI,UAAU,MAAA,EA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,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,QAAA,CAAS,KAAA,CAAM,CAAC,GAAG,EAAE;AAAA,GAC/B;AACF;AAKO,SAAS,cAAc,IAAA,EAAuB;AACnD,EAAA,OAAO,aAAA,CAAc,KAAK,IAAI,CAAA;AAChC;AAKO,SAAS,YAAY,IAAA,EAAuB;AACjD,EAAA,OAAO,WAAA,CAAY,KAAK,IAAI,CAAA;AAC9B;AAWO,SAAS,UAAA,CAAW,GAAW,CAAA,EAAoB;AAExD,EAAA,MAAM,QAAA,GAAW,iBAAiB,CAAC,CAAA;AACnC,EAAA,MAAM,QAAA,GAAW,iBAAiB,CAAC,CAAA;AACnC,EAAA,IAAI,YAAY,QAAA,EAAU;AACxB,IAAA,OAAO,SAAS,SAAA,KAAc,QAAA,CAAS,SAAA,IAAa,QAAA,CAAS,UAAU,QAAA,CAAS,KAAA;AAAA,EAClF;AAGA,EAAA,MAAM,MAAA,GAAS,eAAe,CAAC,CAAA;AAC/B,EAAA,MAAM,MAAA,GAAS,eAAe,CAAC,CAAA;AAC/B,EAAA,IAAI,UAAU,MAAA,EAAQ;AACpB,IAAA,OAAO,MAAA,CAAO,WAAW,MAAA,CAAO,MAAA;AAAA,EAClC;AAGA,EAAA,OAAO,CAAA,KAAM,CAAA;AACf;AA6hBO,SAAS,iBAAiB,QAAA,EAAkD;AACjF,EAAA,OAAO,QAAA,CAAS,OAAA,CAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,EAAE,WAAW,CAAA,KAAM,QAAA,CAAS,mBAAmB,CAAC,CAAA;AACtF;;;AClpBA,IAAA,gBAAA,GAAA;AAAA,EACE,GAAA,EAAO,2BAET,CAAA;;;ACOO,IAAM,wBAAgC,gBAAA,CAAI;AAK1C,IAAM,qBAAA,GAAgC,CAAA,iDAAA,EAAoD,gBAAA,CAAI,GAAG,CAAA,oCAAA","file":"index.mjs","sourcesContent":["export interface IcebergErrorResponse {\n  error: {\n    message: string\n    type: string\n    code: number\n    stack?: string[]\n  }\n}\n\nexport class IcebergError extends Error {\n  readonly status: number\n  readonly icebergType?: string\n  readonly icebergCode?: number\n  readonly details?: unknown\n  readonly isCommitStateUnknown: boolean\n\n  constructor(\n    message: string,\n    opts: {\n      status: number\n      icebergType?: string\n      icebergCode?: number\n      details?: unknown\n    }\n  ) {\n    super(message)\n    this.name = 'IcebergError'\n    this.status = opts.status\n    this.icebergType = opts.icebergType\n    this.icebergCode = opts.icebergCode\n    this.details = opts.details\n\n    // Detect CommitStateUnknownException by exact type match. The previous\n    // `includes('CommitState')` substring check would false-positive on\n    // unrelated exception types and is not a thing the spec defines.\n    this.isCommitStateUnknown = opts.icebergType === 'CommitStateUnknownException'\n  }\n\n  /**\n   * Returns true if the error is a 404 Not Found error.\n   */\n  isNotFound(): boolean {\n    return this.status === 404\n  }\n\n  /**\n   * Returns true if the error is a 409 Conflict error.\n   */\n  isConflict(): boolean {\n    return this.status === 409\n  }\n\n  /**\n   * Returns true if the error is a 419 Authentication Timeout error.\n   */\n  isAuthenticationTimeout(): boolean {\n    return this.status === 419\n  }\n}\n","export function buildUrl(\n  baseUrl: string,\n  path: string,\n  query?: Record<string, string | undefined>\n): string {\n  const url = new URL(path, baseUrl)\n\n  if (query) {\n    for (const [key, value] of Object.entries(query)) {\n      if (value !== undefined) {\n        url.searchParams.set(key, value)\n      }\n    }\n  }\n\n  return url.toString()\n}\n","import { IcebergError, type IcebergErrorResponse } from '../errors/IcebergError'\nimport { buildUrl } from '../utils/url'\nimport type { AuthConfig, HttpClient, HttpRequest, HttpResponse } from './types'\n\nasync function buildAuthHeaders(auth?: AuthConfig): Promise<Record<string, string>> {\n  if (!auth || auth.type === 'none') {\n    return {}\n  }\n\n  if (auth.type === 'bearer') {\n    return { Authorization: `Bearer ${auth.token}` }\n  }\n\n  if (auth.type === 'header') {\n    return { [auth.name]: auth.value }\n  }\n\n  if (auth.type === 'custom') {\n    return await auth.getHeaders()\n  }\n\n  return {}\n}\n\nexport function createFetchClient(options: {\n  baseUrl: string\n  auth?: AuthConfig\n  fetchImpl?: typeof fetch\n}): HttpClient {\n  const fetchFn = options.fetchImpl ?? globalThis.fetch\n\n  return {\n    async request<T>({\n      method,\n      path,\n      query,\n      body,\n      headers,\n    }: HttpRequest): Promise<HttpResponse<T>> {\n      const url = buildUrl(options.baseUrl, path, query)\n      const authHeaders = await buildAuthHeaders(options.auth)\n\n      let res: Response\n      try {\n        res = await fetchFn(url, {\n          method,\n          headers: {\n            ...(body ? { 'Content-Type': 'application/json' } : {}),\n            ...authHeaders,\n            ...headers,\n          },\n          body: body ? JSON.stringify(body) : undefined,\n        })\n      } catch (err) {\n        // Network-level failure (DNS, TLS, offline, AbortError, …). Surface\n        // it as IcebergError with status: 0 so consumers can rely on a single\n        // error class for everything from the client.\n        if (err instanceof IcebergError) throw err\n        const message = err instanceof Error ? err.message : String(err)\n        throw new IcebergError(`Network request failed: ${message}`, {\n          status: 0,\n          details: err,\n        })\n      }\n\n      // 304 Not Modified is a valid response for conditional GETs (If-None-Match).\n      // Return early so callers can detect it without throwing.\n      if (res.status === 304) {\n        return { status: 304, headers: res.headers, data: undefined as T }\n      }\n\n      const text = await res.text()\n      const isJson = (res.headers.get('content-type') || '').includes('application/json')\n      const data = isJson && text ? (JSON.parse(text) as T) : (text as T)\n\n      if (!res.ok) {\n        const errBody = isJson ? (data as IcebergErrorResponse) : undefined\n        const errorDetail = errBody?.error\n        throw new IcebergError(errorDetail?.message ?? `Request failed with status ${res.status}`, {\n          status: res.status,\n          icebergType: errorDetail?.type,\n          icebergCode: errorDetail?.code,\n          details: errBody,\n        })\n      }\n\n      return { status: res.status, headers: res.headers, data: data as T }\n    },\n  }\n}\n","/**\n * Generate an RFC 9562 UUIDv7 string.\n *\n * The Iceberg REST spec defines `Idempotency-Key` as a UUID format,\n * with the example payloads showing UUIDv7 (timestamp-prefixed). UUIDv7\n * is preferred because keys are roughly time-orderable, which makes\n * server-side dedup windows simpler to reason about.\n *\n * Layout (RFC 9562 §5.7):\n *   48-bit unix-ms timestamp | 4-bit version (0111) | 12-bit rand_a\n *   2-bit variant (10) | 62-bit rand_b\n */\nexport function generateIdempotencyKey(): string {\n  const ms = BigInt(Date.now())\n  const bytes = new Uint8Array(16)\n\n  // 48 bits of unix-ms timestamp (big-endian)\n  bytes[0] = Number((ms >> 40n) & 0xffn)\n  bytes[1] = Number((ms >> 32n) & 0xffn)\n  bytes[2] = Number((ms >> 24n) & 0xffn)\n  bytes[3] = Number((ms >> 16n) & 0xffn)\n  bytes[4] = Number((ms >> 8n) & 0xffn)\n  bytes[5] = Number(ms & 0xffn)\n\n  // 10 bytes of randomness\n  const rand = new Uint8Array(10)\n  cryptoRandom(rand)\n  bytes.set(rand, 6)\n\n  // Version (0111) in the high nibble of byte 6\n  bytes[6] = (bytes[6] & 0x0f) | 0x70\n  // Variant (10) in the high two bits of byte 8\n  bytes[8] = (bytes[8] & 0x3f) | 0x80\n\n  return formatUUID(bytes)\n}\n\nfunction formatUUID(b: Uint8Array): string {\n  const hex: string[] = []\n  for (let i = 0; i < 16; i++) {\n    hex.push(b[i].toString(16).padStart(2, '0'))\n  }\n  return `${hex.slice(0, 4).join('')}-${hex.slice(4, 6).join('')}-${hex.slice(6, 8).join('')}-${hex.slice(8, 10).join('')}-${hex.slice(10, 16).join('')}`\n}\n\nfunction cryptoRandom(buf: Uint8Array): void {\n  const c =\n    typeof globalThis.crypto !== 'undefined' &&\n    typeof globalThis.crypto.getRandomValues === 'function'\n      ? globalThis.crypto\n      : undefined\n  if (c) {\n    c.getRandomValues(buf)\n    return\n  }\n  // Fallback: should not happen in supported environments (Node 20+, modern browsers).\n  for (let i = 0; i < buf.length; i++) {\n    buf[i] = Math.floor(Math.random() * 256)\n  }\n}\n","import type { HttpClient } from '../http/types'\nimport { IcebergError } from '../errors/IcebergError'\nimport { generateIdempotencyKey } from '../utils/idempotency-key'\nimport type {\n  CreateNamespaceRequest,\n  CreateNamespaceResponse,\n  GetNamespaceResponse,\n  ListNamespacesOptions,\n  ListNamespacesResponse,\n  ListNamespacesResult,\n  NamespaceIdentifier,\n  NamespaceMetadata,\n  UpdateNamespacePropertiesRequest,\n  UpdateNamespacePropertiesResponse,\n} from './types'\n\n/**\n * Encode a multipart namespace for use as a single URL path segment.\n *\n * Each part is encoded with `encodeURIComponent` (so `/`, `?`, `#`, `%` etc.\n * inside a part survive intact), and parts are joined with the literal `%1F`\n * separator the spec calls for. Note: relying on the URL constructor to\n * encode a raw `\\x1F` byte does the right thing for the separator but does\n * NOT encode `/`, `?`, `#`, `%` inside a part — hence the per-part\n * `encodeURIComponent` here.\n *\n * For the `parent` *query* parameter (not path), the raw `\\x1F` join is the\n * correct input — `URLSearchParams.set` percent-encodes it to `%1F` and\n * pre-encoding would double-encode the `%` to `%25`.\n */\nfunction namespaceToPath(namespace: string[]): string {\n  return namespace.map(encodeURIComponent).join('%1F')\n}\n\nfunction namespaceToParentQuery(namespace: string[]): string {\n  // Raw 0x1F — URLSearchParams encodes to %1F. Do NOT pre-encode parts here.\n  return namespace.join('\\x1F')\n}\n\n/**\n * A prefix resolver. Operations classes accept this so the catalog can defer\n * the choice of path prefix until /v1/config has been fetched (the spec\n * recommends warehouse → server-returned `prefix` over hardcoded names).\n *\n * For simple usage and tests, pass a string and it'll be wrapped automatically.\n */\nexport type PrefixResolver = string | (() => string | Promise<string>)\n\nasync function resolvePrefix(p: PrefixResolver): Promise<string> {\n  return typeof p === 'string' ? p : p()\n}\n\nexport class NamespaceOperations {\n  constructor(\n    private readonly client: HttpClient,\n    private readonly prefix: PrefixResolver = ''\n  ) {}\n\n  async listNamespaces(options: ListNamespacesOptions = {}): Promise<ListNamespacesResult> {\n    const prefix = await resolvePrefix(this.prefix)\n\n    const query: Record<string, string | undefined> = {}\n    if (options.parent) query.parent = namespaceToParentQuery(options.parent.namespace)\n    if (options.pageToken !== undefined) query.pageToken = options.pageToken\n    if (options.pageSize !== undefined) query.pageSize = String(options.pageSize)\n    const hasQuery = Object.keys(query).some((k) => query[k] !== undefined)\n\n    const response = await this.client.request<ListNamespacesResponse>({\n      method: 'GET',\n      path: `${prefix}/namespaces`,\n      query: hasQuery ? query : undefined,\n    })\n\n    return {\n      namespaces: (response.data.namespaces ?? []).map((ns) => ({ namespace: ns })),\n      nextPageToken: response.data['next-page-token'] ?? undefined,\n    }\n  }\n\n  async createNamespace(\n    id: NamespaceIdentifier,\n    metadata?: NamespaceMetadata\n  ): Promise<CreateNamespaceResponse> {\n    const prefix = await resolvePrefix(this.prefix)\n    const request: CreateNamespaceRequest = {\n      namespace: id.namespace,\n      properties: metadata?.properties,\n    }\n\n    const response = await this.client.request<CreateNamespaceResponse>({\n      method: 'POST',\n      path: `${prefix}/namespaces`,\n      body: request,\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n\n    return response.data\n  }\n\n  async dropNamespace(id: NamespaceIdentifier): Promise<void> {\n    const prefix = await resolvePrefix(this.prefix)\n    await this.client.request<void>({\n      method: 'DELETE',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}`,\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n  }\n\n  async loadNamespaceMetadata(id: NamespaceIdentifier): Promise<NamespaceMetadata> {\n    const prefix = await resolvePrefix(this.prefix)\n    const response = await this.client.request<GetNamespaceResponse>({\n      method: 'GET',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}`,\n    })\n\n    return {\n      properties: response.data.properties ?? {},\n    }\n  }\n\n  async namespaceExists(id: NamespaceIdentifier): Promise<boolean> {\n    const prefix = await resolvePrefix(this.prefix)\n    try {\n      await this.client.request<void>({\n        method: 'HEAD',\n        path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}`,\n      })\n      return true\n    } catch (error) {\n      if (error instanceof IcebergError && error.status === 404) {\n        return false\n      }\n      throw error\n    }\n  }\n\n  async updateNamespaceProperties(\n    id: NamespaceIdentifier,\n    request: UpdateNamespacePropertiesRequest\n  ): Promise<UpdateNamespacePropertiesResponse> {\n    const prefix = await resolvePrefix(this.prefix)\n    const response = await this.client.request<UpdateNamespacePropertiesResponse>({\n      method: 'POST',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}/properties`,\n      body: request,\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n    return response.data\n  }\n\n  async createNamespaceIfNotExists(\n    id: NamespaceIdentifier,\n    metadata?: NamespaceMetadata\n  ): Promise<CreateNamespaceResponse | void> {\n    try {\n      return await this.createNamespace(id, metadata)\n    } catch (error) {\n      if (error instanceof IcebergError && error.status === 409) {\n        return\n      }\n      throw error\n    }\n  }\n}\n","import type { HttpClient } from '../http/types'\nimport { IcebergError } from '../errors/IcebergError'\nimport { generateIdempotencyKey } from '../utils/idempotency-key'\nimport type { PrefixResolver } from './namespaces'\nimport type {\n  CommitTableRequest,\n  CommitTableResponse,\n  CreateTableRequest,\n  DropTableRequest,\n  ListTablesOptions,\n  ListTablesResponse,\n  ListTablesResult,\n  LoadTableOptions,\n  LoadTableResponse,\n  LoadTableResultWithEtag,\n  NamespaceIdentifier,\n  RegisterTableRequest,\n  RenameTableRequest,\n  TableIdentifier,\n  TableMetadata,\n  UpdateTableRequest,\n} from './types'\n\nfunction namespaceToPath(namespace: string[]): string {\n  return namespace.map(encodeURIComponent).join('%1F')\n}\n\nfunction tableSegment(name: string): string {\n  return encodeURIComponent(name)\n}\n\nasync function resolvePrefix(p: PrefixResolver): Promise<string> {\n  return typeof p === 'string' ? p : p()\n}\n\nexport class TableOperations {\n  constructor(\n    private readonly client: HttpClient,\n    private readonly prefix: PrefixResolver = '',\n    private readonly accessDelegation?: string\n  ) {}\n\n  async listTables(\n    namespace: NamespaceIdentifier,\n    options: ListTablesOptions = {}\n  ): Promise<ListTablesResult> {\n    const prefix = await resolvePrefix(this.prefix)\n    const query: Record<string, string | undefined> = {}\n    if (options.pageToken !== undefined) query.pageToken = options.pageToken\n    if (options.pageSize !== undefined) query.pageSize = String(options.pageSize)\n    const hasQuery = Object.keys(query).some((k) => query[k] !== undefined)\n\n    const response = await this.client.request<ListTablesResponse>({\n      method: 'GET',\n      path: `${prefix}/namespaces/${namespaceToPath(namespace.namespace)}/tables`,\n      query: hasQuery ? query : undefined,\n    })\n\n    return {\n      identifiers: response.data.identifiers ?? [],\n      nextPageToken: response.data['next-page-token'] ?? undefined,\n    }\n  }\n\n  async createTable(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<TableMetadata> {\n    const result = await this.createTableResult(namespace, request)\n    return result.metadata\n  }\n\n  /**\n   * Spec-aligned `LoadTableResult` wrapper for create. Returns the full server\n   * response (metadata, metadata-location, config, storage-credentials) plus\n   * the captured ETag header. Use this when `accessDelegation` is set so the\n   * server-vended credentials are reachable.\n   */\n  async createTableResult(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<LoadTableResultWithEtag> {\n    const prefix = await resolvePrefix(this.prefix)\n    const headers: Record<string, string> = { 'Idempotency-Key': generateIdempotencyKey() }\n    if (this.accessDelegation) {\n      headers['X-Iceberg-Access-Delegation'] = this.accessDelegation\n    }\n\n    const response = await this.client.request<LoadTableResponse>({\n      method: 'POST',\n      path: `${prefix}/namespaces/${namespaceToPath(namespace.namespace)}/tables`,\n      body: request,\n      headers,\n    })\n\n    return {\n      ...response.data,\n      etag: response.headers.get('etag'),\n    }\n  }\n\n  async updateTable(\n    id: TableIdentifier,\n    request: UpdateTableRequest\n  ): Promise<CommitTableResponse> {\n    const prefix = await resolvePrefix(this.prefix)\n    const response = await this.client.request<LoadTableResponse>({\n      method: 'POST',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${tableSegment(id.name)}`,\n      body: request,\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n\n    const metadataLocation = response.data['metadata-location']\n    if (!metadataLocation) {\n      // Spec requires both `metadata` and `metadata-location` on\n      // CommitTableResponse. A 200 without `metadata-location` means the\n      // server is misbehaving; surface it instead of silently returning ''.\n      throw new IcebergError(\n        'Server returned 200 without required `metadata-location` field on CommitTableResponse',\n        { status: response.status, details: response.data }\n      )\n    }\n\n    return {\n      'metadata-location': metadataLocation,\n      metadata: response.data.metadata,\n    }\n  }\n\n  /** Spec-aligned alias for {@link updateTable}. */\n  async commitTable(\n    id: TableIdentifier,\n    request: CommitTableRequest\n  ): Promise<CommitTableResponse> {\n    return this.updateTable(id, request)\n  }\n\n  async dropTable(id: TableIdentifier, options?: DropTableRequest): Promise<void> {\n    const prefix = await resolvePrefix(this.prefix)\n    await this.client.request<void>({\n      method: 'DELETE',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${tableSegment(id.name)}`,\n      query: { purgeRequested: String(options?.purge ?? false) },\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n  }\n\n  async loadTable(id: TableIdentifier): Promise<TableMetadata>\n  async loadTable(id: TableIdentifier, options: LoadTableOptions): Promise<TableMetadata | null>\n  async loadTable(id: TableIdentifier, options?: LoadTableOptions): Promise<TableMetadata | null> {\n    const result = await this.loadTableResult(id, options)\n    return result ? result.metadata : null\n  }\n\n  /**\n   * Spec-aligned `LoadTableResult` wrapper. Returns the full server response\n   * (metadata, metadata-location, config, storage-credentials) plus the captured\n   * ETag header. Returns `null` when an `ifNoneMatch` was supplied and the server\n   * answered 304.\n   */\n  async loadTableResult(\n    id: TableIdentifier,\n    options?: LoadTableOptions\n  ): Promise<LoadTableResultWithEtag | null> {\n    const prefix = await resolvePrefix(this.prefix)\n    const headers: Record<string, string> = {}\n    if (this.accessDelegation) {\n      headers['X-Iceberg-Access-Delegation'] = this.accessDelegation\n    }\n    if (options?.ifNoneMatch) {\n      headers['If-None-Match'] = options.ifNoneMatch\n    }\n    const query: Record<string, string | undefined> = {}\n    if (options?.snapshots) query.snapshots = options.snapshots\n\n    const response = await this.client.request<LoadTableResponse>({\n      method: 'GET',\n      path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${tableSegment(id.name)}`,\n      headers,\n      query: Object.keys(query).length ? query : undefined,\n    })\n\n    if (response.status === 304) {\n      return null\n    }\n\n    return {\n      ...response.data,\n      etag: response.headers.get('etag'),\n    }\n  }\n\n  async tableExists(id: TableIdentifier): Promise<boolean> {\n    const prefix = await resolvePrefix(this.prefix)\n    const headers: Record<string, string> = {}\n    if (this.accessDelegation) {\n      headers['X-Iceberg-Access-Delegation'] = this.accessDelegation\n    }\n\n    try {\n      await this.client.request<void>({\n        method: 'HEAD',\n        path: `${prefix}/namespaces/${namespaceToPath(id.namespace)}/tables/${tableSegment(id.name)}`,\n        headers,\n      })\n      return true\n    } catch (error) {\n      if (error instanceof IcebergError && error.status === 404) {\n        return false\n      }\n      throw error\n    }\n  }\n\n  async registerTable(\n    namespace: NamespaceIdentifier,\n    request: RegisterTableRequest\n  ): Promise<TableMetadata> {\n    const result = await this.registerTableResult(namespace, request)\n    return result.metadata\n  }\n\n  async registerTableResult(\n    namespace: NamespaceIdentifier,\n    request: RegisterTableRequest\n  ): Promise<LoadTableResultWithEtag> {\n    const prefix = await resolvePrefix(this.prefix)\n    const headers: Record<string, string> = { 'Idempotency-Key': generateIdempotencyKey() }\n    if (this.accessDelegation) {\n      headers['X-Iceberg-Access-Delegation'] = this.accessDelegation\n    }\n    const response = await this.client.request<LoadTableResponse>({\n      method: 'POST',\n      path: `${prefix}/namespaces/${namespaceToPath(namespace.namespace)}/register`,\n      body: request,\n      headers,\n    })\n    return {\n      ...response.data,\n      etag: response.headers.get('etag'),\n    }\n  }\n\n  async renameTable(request: RenameTableRequest): Promise<void> {\n    const prefix = await resolvePrefix(this.prefix)\n    await this.client.request<void>({\n      method: 'POST',\n      path: `${prefix}/tables/rename`,\n      body: request,\n      headers: { 'Idempotency-Key': generateIdempotencyKey() },\n    })\n  }\n\n  async createTableIfNotExists(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<TableMetadata> {\n    try {\n      return await this.createTable(namespace, request)\n    } catch (error) {\n      if (error instanceof IcebergError && error.status === 409) {\n        return await this.loadTable({ namespace: namespace.namespace, name: request.name })\n      }\n      throw error\n    }\n  }\n}\n","import { createFetchClient } from '../http/createFetchClient'\nimport type { AuthConfig, HttpClient } from '../http/types'\nimport { NamespaceOperations } from './namespaces'\nimport { TableOperations } from './tables'\nimport type {\n  CatalogConfig,\n  CommitTableRequest,\n  CommitTableResponse,\n  CreateNamespaceResponse,\n  CreateTableRequest,\n  DropTableRequest,\n  ListNamespacesOptions,\n  ListNamespacesResult,\n  ListTablesOptions,\n  ListTablesResult,\n  LoadTableOptions,\n  LoadTableResultWithEtag,\n  NamespaceIdentifier,\n  NamespaceMetadata,\n  RegisterTableRequest,\n  RenameTableRequest,\n  TableIdentifier,\n  TableMetadata,\n  UpdateNamespacePropertiesRequest,\n  UpdateNamespacePropertiesResponse,\n  UpdateTableRequest,\n} from './types'\n\n/**\n * Access delegation mechanisms supported by the Iceberg REST Catalog.\n *\n * - `vended-credentials`: Server provides temporary credentials for data access\n * - `remote-signing`: Server signs requests on behalf of the client\n */\nexport type AccessDelegation = 'vended-credentials' | 'remote-signing'\n\n/**\n * Configuration options for the Iceberg REST Catalog client.\n */\nexport interface IcebergRestCatalogOptions {\n  /** Base URL of the Iceberg REST Catalog API */\n  baseUrl: string\n  /**\n   * Warehouse identifier. The client passes this to `GET /v1/config?warehouse=…`\n   * on first use; the server-returned `overrides.prefix` is then used for all\n   * subsequent requests. This is the spec-recommended way to address a warehouse\n   * (e.g., a Cloudflare R2 bucket) and replaces the older `catalogName` flow.\n   */\n  warehouse?: string\n  /**\n   * Alias for {@link warehouse} kept for backward compatibility. If both are\n   * set, `warehouse` wins.\n   */\n  catalogName?: string\n  /** Authentication configuration */\n  auth?: AuthConfig\n  /** Custom fetch implementation (defaults to globalThis.fetch) */\n  fetch?: typeof fetch\n  /**\n   * Access delegation mechanisms to request from the server.\n   * When specified, the X-Iceberg-Access-Delegation header will be sent\n   * with supported operations (createTable, loadTable).\n   *\n   * @example ['vended-credentials']\n   * @example ['vended-credentials', 'remote-signing']\n   */\n  accessDelegation?: AccessDelegation[]\n}\n\n/**\n * Client for interacting with an Apache Iceberg REST Catalog.\n *\n * This class provides methods for managing namespaces and tables in an Iceberg catalog.\n * It handles authentication, request formatting, and error handling automatically.\n *\n * @example\n * ```typescript\n * const catalog = new IcebergRestCatalog({\n *   baseUrl: 'https://my-catalog.example.com',\n *   warehouse: 'my-warehouse',\n *   auth: { type: 'bearer', token: process.env.ICEBERG_TOKEN }\n * });\n *\n * // First call lazily fetches /v1/config?warehouse=my-warehouse\n * await catalog.createNamespace({ namespace: ['analytics'] });\n * ```\n */\nexport class IcebergRestCatalog {\n  private readonly client: HttpClient\n  private readonly namespaceOps: NamespaceOperations\n  private readonly tableOps: TableOperations\n  private readonly accessDelegation?: string\n  private readonly warehouse?: string\n\n  private prefixPromise?: Promise<string>\n  private cachedConfigPromise?: Promise<CatalogConfig>\n\n  /**\n   * Creates a new Iceberg REST Catalog client.\n   *\n   * @param options - Configuration options for the catalog client\n   */\n  constructor(options: IcebergRestCatalogOptions) {\n    const baseUrl = options.baseUrl.endsWith('/') ? options.baseUrl : `${options.baseUrl}/`\n\n    this.warehouse = options.warehouse ?? options.catalogName\n\n    this.client = createFetchClient({\n      baseUrl,\n      auth: options.auth,\n      fetchImpl: options.fetch,\n    })\n\n    // Format accessDelegation as comma-separated string per spec\n    this.accessDelegation = options.accessDelegation?.join(',')\n\n    const getPrefix = () => this.resolvePrefix()\n    this.namespaceOps = new NamespaceOperations(this.client, getPrefix)\n    this.tableOps = new TableOperations(this.client, getPrefix, this.accessDelegation)\n  }\n\n  /**\n   * Fetch and cache the server's catalog configuration. Subsequent calls return\n   * the same object. Calling this is optional — operations will trigger it\n   * lazily on first use.\n   *\n   * Caches the in-flight promise (not just the resolved value) so concurrent\n   * first-callers don't all fire their own `/v1/config` request.\n   */\n  async loadConfig(): Promise<CatalogConfig> {\n    if (!this.cachedConfigPromise) {\n      const query: Record<string, string | undefined> = {}\n      if (this.warehouse !== undefined) query.warehouse = this.warehouse\n      this.cachedConfigPromise = this.client\n        .request<CatalogConfig>({\n          method: 'GET',\n          path: 'v1/config',\n          query: Object.keys(query).length ? query : undefined,\n        })\n        .then((response) => response.data)\n        .catch((err) => {\n          // Don't cache failures — the next caller deserves to try again.\n          this.cachedConfigPromise = undefined\n          throw err\n        })\n    }\n    return this.cachedConfigPromise\n  }\n\n  private async resolvePrefix(): Promise<string> {\n    if (!this.prefixPromise) {\n      this.prefixPromise = this.computePrefix()\n    }\n    return this.prefixPromise\n  }\n\n  private async computePrefix(): Promise<string> {\n    if (this.warehouse === undefined) {\n      // No warehouse → no /config call. Use plain `v1` prefix.\n      return 'v1'\n    }\n    try {\n      const config = await this.loadConfig()\n      const serverPrefix = config.overrides?.prefix ?? config.defaults?.prefix\n      return serverPrefix ? `v1/${serverPrefix}` : `v1/${this.warehouse}`\n    } catch {\n      // /config is optional in some deployments; fall back to using the\n      // warehouse as a literal path segment (matches the legacy catalogName\n      // behavior).\n      return `v1/${this.warehouse}`\n    }\n  }\n\n  /**\n   * Lists all namespaces in the catalog.\n   *\n   * @returns Paginated namespace list with optional `nextPageToken`\n   *\n   * @example\n   * ```typescript\n   * const { namespaces } = await catalog.listNamespaces();\n   *\n   * // List children under a parent\n   * const { namespaces: children } = await catalog.listNamespaces({\n   *   parent: { namespace: ['analytics'] },\n   * });\n   *\n   * // Paginate\n   * const page1 = await catalog.listNamespaces({ pageSize: 100 });\n   * const page2 = await catalog.listNamespaces({ pageSize: 100, pageToken: page1.nextPageToken });\n   * ```\n   */\n  async listNamespaces(options: ListNamespacesOptions = {}): Promise<ListNamespacesResult> {\n    return this.namespaceOps.listNamespaces(options)\n  }\n\n  /**\n   * Creates a new namespace in the catalog.\n   */\n  async createNamespace(\n    id: NamespaceIdentifier,\n    metadata?: NamespaceMetadata\n  ): Promise<CreateNamespaceResponse> {\n    return this.namespaceOps.createNamespace(id, metadata)\n  }\n\n  /**\n   * Drops a namespace from the catalog.\n   *\n   * The namespace must be empty (contain no tables) before it can be dropped.\n   */\n  async dropNamespace(id: NamespaceIdentifier): Promise<void> {\n    await this.namespaceOps.dropNamespace(id)\n  }\n\n  /**\n   * Loads metadata for a namespace.\n   */\n  async loadNamespaceMetadata(id: NamespaceIdentifier): Promise<NamespaceMetadata> {\n    return this.namespaceOps.loadNamespaceMetadata(id)\n  }\n\n  /**\n   * Set or remove properties on a namespace.\n   */\n  async updateNamespaceProperties(\n    id: NamespaceIdentifier,\n    request: UpdateNamespacePropertiesRequest\n  ): Promise<UpdateNamespacePropertiesResponse> {\n    return this.namespaceOps.updateNamespaceProperties(id, request)\n  }\n\n  /**\n   * Lists tables in a namespace.\n   *\n   * @returns Paginated table list with optional `nextPageToken`\n   */\n  async listTables(\n    namespace: NamespaceIdentifier,\n    options: ListTablesOptions = {}\n  ): Promise<ListTablesResult> {\n    return this.tableOps.listTables(namespace, options)\n  }\n\n  /**\n   * Creates a new table in the catalog.\n   */\n  async createTable(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<TableMetadata> {\n    return this.tableOps.createTable(namespace, request)\n  }\n\n  /**\n   * Spec-aligned `LoadTableResult` wrapper for create. Returns the full server\n   * response (metadata, metadata-location, server `config`, `storage-credentials`)\n   * plus the captured ETag. Use this when `accessDelegation` is set so the\n   * server-vended credentials are reachable.\n   */\n  async createTableResult(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<LoadTableResultWithEtag> {\n    return this.tableOps.createTableResult(namespace, request)\n  }\n\n  /**\n   * Commit updates to a table using the spec-aligned `{ requirements, updates }` shape.\n   *\n   * @example\n   * ```typescript\n   * await catalog.updateTable(\n   *   { namespace: ['analytics'], name: 'events' },\n   *   {\n   *     requirements: [],\n   *     updates: [{ action: 'set-properties', updates: { 'read.split.target-size': '134217728' } }],\n   *   },\n   * );\n   * ```\n   */\n  async updateTable(\n    id: TableIdentifier,\n    request: UpdateTableRequest\n  ): Promise<CommitTableResponse> {\n    return this.tableOps.updateTable(id, request)\n  }\n\n  /** Spec-aligned alias for {@link updateTable}. */\n  async commitTable(\n    id: TableIdentifier,\n    request: CommitTableRequest\n  ): Promise<CommitTableResponse> {\n    return this.tableOps.commitTable(id, request)\n  }\n\n  /**\n   * Drops a table from the catalog.\n   */\n  async dropTable(id: TableIdentifier, options?: DropTableRequest): Promise<void> {\n    await this.tableOps.dropTable(id, options)\n  }\n\n  /**\n   * Loads metadata for a table.\n   *\n   * Pass `ifNoneMatch` (a previous ETag) to perform a conditional GET. If the\n   * server returns 304 Not Modified, the method returns `null`.\n   */\n  async loadTable(id: TableIdentifier): Promise<TableMetadata>\n  async loadTable(id: TableIdentifier, options: LoadTableOptions): Promise<TableMetadata | null>\n  async loadTable(id: TableIdentifier, options?: LoadTableOptions): Promise<TableMetadata | null> {\n    return options ? this.tableOps.loadTable(id, options) : this.tableOps.loadTable(id)\n  }\n\n  /**\n   * Spec-aligned `LoadTableResult` wrapper, including server `config`,\n   * `storage-credentials`, and the response `ETag`. Returns `null` on 304.\n   */\n  async loadTableResult(\n    id: TableIdentifier,\n    options?: LoadTableOptions\n  ): Promise<LoadTableResultWithEtag | null> {\n    return this.tableOps.loadTableResult(id, options)\n  }\n\n  /**\n   * Checks if a namespace exists in the catalog.\n   */\n  async namespaceExists(id: NamespaceIdentifier): Promise<boolean> {\n    return this.namespaceOps.namespaceExists(id)\n  }\n\n  /**\n   * Checks if a table exists in the catalog.\n   */\n  async tableExists(id: TableIdentifier): Promise<boolean> {\n    return this.tableOps.tableExists(id)\n  }\n\n  /**\n   * Creates a namespace if it does not exist.\n   */\n  async createNamespaceIfNotExists(\n    id: NamespaceIdentifier,\n    metadata?: NamespaceMetadata\n  ): Promise<CreateNamespaceResponse | void> {\n    return this.namespaceOps.createNamespaceIfNotExists(id, metadata)\n  }\n\n  /**\n   * Creates a table if it does not exist.\n   */\n  async createTableIfNotExists(\n    namespace: NamespaceIdentifier,\n    request: CreateTableRequest\n  ): Promise<TableMetadata> {\n    return this.tableOps.createTableIfNotExists(namespace, request)\n  }\n\n  /**\n   * Register an existing metadata file as a table in the given namespace.\n   */\n  async registerTable(\n    namespace: NamespaceIdentifier,\n    request: RegisterTableRequest\n  ): Promise<TableMetadata> {\n    return this.tableOps.registerTable(namespace, request)\n  }\n\n  /**\n   * Spec-aligned `LoadTableResult` wrapper for register.\n   */\n  async registerTableResult(\n    namespace: NamespaceIdentifier,\n    request: RegisterTableRequest\n  ): Promise<LoadTableResultWithEtag> {\n    return this.tableOps.registerTableResult(namespace, request)\n  }\n\n  /**\n   * Rename a table. Servers may or may not support cross-namespace renames.\n   */\n  async renameTable(request: RenameTableRequest): Promise<void> {\n    return this.tableOps.renameTable(request)\n  }\n}\n","export interface NamespaceIdentifier {\n  namespace: string[]\n}\n\nexport interface NamespaceMetadata {\n  properties: Record<string, string>\n}\n\nexport interface TableIdentifier {\n  namespace: string[]\n  name: string\n}\n\n/**\n * Primitive types in Iceberg - all represented as strings.\n * Parameterized types use string format: decimal(precision,scale) and fixed[length]\n *\n * Note: The OpenAPI spec defines PrimitiveType as `type: string`, so any string is valid.\n * We include known types for autocomplete, plus a catch-all for flexibility.\n */\nexport type PrimitiveType =\n  | 'boolean'\n  | 'int'\n  | 'long'\n  | 'float'\n  | 'double'\n  | 'string'\n  | 'timestamp'\n  | 'date'\n  | 'time'\n  | 'timestamptz'\n  | 'uuid'\n  | 'binary'\n  | `decimal(${number},${number})`\n  | `fixed[${number}]`\n  | (string & {}) // catch-all for any format (e.g., \"decimal(10, 2)\" with spaces) and future types\n\n/**\n * Regex patterns for parsing parameterized types.\n * These allow flexible whitespace matching.\n */\nconst DECIMAL_REGEX = /^decimal\\s*\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)$/\nconst FIXED_REGEX = /^fixed\\s*\\[\\s*(\\d+)\\s*\\]$/\n\n/**\n * Parse a decimal type string into its components.\n * Handles any whitespace formatting (e.g., \"decimal(10,2)\", \"decimal(10, 2)\", \"decimal( 10 , 2 )\").\n *\n * @param type - The type string to parse\n * @returns Object with precision and scale, or null if not a valid decimal type\n */\nexport function parseDecimalType(type: string): { precision: number; scale: number } | null {\n  const match = type.match(DECIMAL_REGEX)\n  if (!match) return null\n  return {\n    precision: parseInt(match[1], 10),\n    scale: parseInt(match[2], 10),\n  }\n}\n\n/**\n * Parse a fixed type string into its length.\n * Handles any whitespace formatting (e.g., \"fixed[16]\", \"fixed[ 16 ]\").\n *\n * @param type - The type string to parse\n * @returns Object with length, or null if not a valid fixed type\n */\nexport function parseFixedType(type: string): { length: number } | null {\n  const match = type.match(FIXED_REGEX)\n  if (!match) return null\n  return {\n    length: parseInt(match[1], 10),\n  }\n}\n\n/**\n * Check if a type string is a decimal type.\n */\nexport function isDecimalType(type: string): boolean {\n  return DECIMAL_REGEX.test(type)\n}\n\n/**\n * Check if a type string is a fixed type.\n */\nexport function isFixedType(type: string): boolean {\n  return FIXED_REGEX.test(type)\n}\n\n/**\n * Compare two Iceberg type strings for equality, ignoring whitespace differences.\n * This is useful when comparing types from user input vs catalog responses,\n * as catalogs may normalize whitespace differently.\n *\n * @param a - First type string\n * @param b - Second type string\n * @returns true if the types are equivalent\n */\nexport function typesEqual(a: string, b: string): boolean {\n  // For decimal types, compare parsed values\n  const decimalA = parseDecimalType(a)\n  const decimalB = parseDecimalType(b)\n  if (decimalA && decimalB) {\n    return decimalA.precision === decimalB.precision && decimalA.scale === decimalB.scale\n  }\n\n  // For fixed types, compare parsed values\n  const fixedA = parseFixedType(a)\n  const fixedB = parseFixedType(b)\n  if (fixedA && fixedB) {\n    return fixedA.length === fixedB.length\n  }\n\n  // For other types, direct string comparison\n  return a === b\n}\n\n/**\n * Struct type - a nested structure containing fields.\n * Used for nested records within a field.\n */\nexport interface StructType {\n  type: 'struct'\n  fields: StructField[]\n}\n\n/**\n * List type - an array of elements.\n */\nexport interface ListType {\n  type: 'list'\n  'element-id': number\n  element: IcebergType\n  'element-required': boolean\n}\n\n/**\n * Map type - a key-value mapping.\n */\nexport interface MapType {\n  type: 'map'\n  'key-id': number\n  key: IcebergType\n  'value-id': number\n  value: IcebergType\n  'value-required': boolean\n}\n\n/**\n * Union of all Iceberg types.\n * Can be a primitive type (string) or a complex type (struct, list, map).\n */\nexport type IcebergType = PrimitiveType | StructType | ListType | MapType\n\n/**\n * Primitive type values for default values.\n * Represents the possible values for initial-default and write-default.\n */\nexport type PrimitiveTypeValue = boolean | number | string\n\n/**\n * A field within a struct (used in nested StructType).\n */\nexport interface StructField {\n  id: number\n  name: string\n  type: IcebergType\n  required: boolean\n  doc?: string\n  'initial-default'?: PrimitiveTypeValue\n  'write-default'?: PrimitiveTypeValue\n}\n\n/**\n * A field within a table schema (top-level).\n * Equivalent to StructField but kept for backwards compatibility.\n */\nexport interface TableField {\n  id: number\n  name: string\n  type: IcebergType\n  required: boolean\n  doc?: string\n  'initial-default'?: PrimitiveTypeValue\n  'write-default'?: PrimitiveTypeValue\n}\n\nexport interface TableSchema {\n  type: 'struct'\n  fields: TableField[]\n  'schema-id'?: number\n  'identifier-field-ids'?: number[]\n}\n\nexport interface PartitionField {\n  'source-id': number\n  'field-id'?: number\n  name: string\n  transform: string\n}\n\nexport interface PartitionSpec {\n  'spec-id'?: number\n  fields: PartitionField[]\n}\n\nexport interface SortField {\n  'source-id': number\n  transform: string\n  direction: 'asc' | 'desc'\n  'null-order': 'nulls-first' | 'nulls-last'\n}\n\nexport interface SortOrder {\n  'order-id': number\n  fields: SortField[]\n}\n\nexport interface SnapshotReference {\n  type: 'tag' | 'branch'\n  'snapshot-id': number\n  'max-ref-age-ms'?: number\n  'max-snapshot-age-ms'?: number\n  'min-snapshots-to-keep'?: number\n}\n\nexport interface Snapshot {\n  'snapshot-id': number\n  'parent-snapshot-id'?: number\n  'sequence-number'?: number\n  'timestamp-ms': number\n  'manifest-list': string\n  summary: { operation: 'append' | 'replace' | 'overwrite' | 'delete'; [key: string]: string }\n  'schema-id'?: number\n  'first-row-id'?: number\n  'added-rows'?: number\n}\n\nexport interface BlobMetadata {\n  type: string\n  'snapshot-id': number\n  'sequence-number': number\n  fields: number[]\n  properties?: Record<string, string>\n}\n\nexport interface StatisticsFile {\n  'snapshot-id': number\n  'statistics-path': string\n  'file-size-in-bytes': number\n  'file-footer-size-in-bytes': number\n  'blob-metadata': BlobMetadata[]\n}\n\nexport interface PartitionStatisticsFile {\n  'snapshot-id': number\n  'statistics-path': string\n  'file-size-in-bytes': number\n}\n\nexport interface EncryptedKey {\n  'key-id': string\n  'encrypted-key-metadata': string\n  'encrypted-by-id'?: string\n  properties?: Record<string, string>\n}\n\nexport interface CreateTableRequest {\n  name: string\n  schema: TableSchema\n  location?: string\n  'partition-spec'?: PartitionSpec\n  'write-order'?: SortOrder\n  properties?: Record<string, string>\n  'stage-create'?: boolean\n}\n\nexport interface RegisterTableRequest {\n  name: string\n  'metadata-location': string\n  overwrite?: boolean\n}\n\nexport interface RenameTableRequest {\n  source: TableIdentifier\n  destination: TableIdentifier\n}\n\n/**\n * Spec-aligned table commit request shape: requirements + updates arrays.\n * Used by `updateTable` / `commitTable`.\n *\n * Both `requirements` and `updates` are required by the spec — pass an empty\n * array if there are no preconditions to assert.\n */\nexport interface CommitTableRequest {\n  identifier?: TableIdentifier\n  requirements: TableRequirement[]\n  updates: TableUpdate[]\n}\n\n/**\n * @deprecated Use `CommitTableRequest` (with `updates` and optional `requirements`) instead.\n * This alias is kept for callers migrating from 0.x; new code should use the spec-aligned shape.\n */\nexport type UpdateTableRequest = CommitTableRequest\n\n/* ===== TableUpdate discriminated union (per OpenAPI spec) ===== */\n\nexport interface AssignUUIDUpdate {\n  action: 'assign-uuid'\n  uuid: string\n}\n\nexport interface UpgradeFormatVersionUpdate {\n  action: 'upgrade-format-version'\n  'format-version': number\n}\n\nexport interface AddSchemaUpdate {\n  action: 'add-schema'\n  schema: TableSchema\n  /** @deprecated server-managed; included for backward compat with older catalogs */\n  'last-column-id'?: number\n}\n\nexport interface SetCurrentSchemaUpdate {\n  action: 'set-current-schema'\n  'schema-id': number\n}\n\nexport interface AddPartitionSpecUpdate {\n  action: 'add-spec'\n  spec: PartitionSpec\n}\n\nexport interface SetDefaultSpecUpdate {\n  action: 'set-default-spec'\n  'spec-id': number\n}\n\nexport interface AddSortOrderUpdate {\n  action: 'add-sort-order'\n  'sort-order': SortOrder\n}\n\nexport interface SetDefaultSortOrderUpdate {\n  action: 'set-default-sort-order'\n  'sort-order-id': number\n}\n\nexport interface AddSnapshotUpdate {\n  action: 'add-snapshot'\n  snapshot: Snapshot\n}\n\nexport interface SetSnapshotRefUpdate extends SnapshotReference {\n  action: 'set-snapshot-ref'\n  'ref-name': string\n}\n\nexport interface RemoveSnapshotsUpdate {\n  action: 'remove-snapshots'\n  'snapshot-ids': number[]\n}\n\nexport interface RemoveSnapshotRefUpdate {\n  action: 'remove-snapshot-ref'\n  'ref-name': string\n}\n\nexport interface SetLocationUpdate {\n  action: 'set-location'\n  location: string\n}\n\nexport interface SetPropertiesUpdate {\n  action: 'set-properties'\n  updates: Record<string, string>\n}\n\nexport interface RemovePropertiesUpdate {\n  action: 'remove-properties'\n  removals: string[]\n}\n\nexport interface SetStatisticsUpdate {\n  action: 'set-statistics'\n  statistics: StatisticsFile\n  /** @deprecated derive from `statistics.snapshot-id` */\n  'snapshot-id'?: number\n}\n\nexport interface RemoveStatisticsUpdate {\n  action: 'remove-statistics'\n  'snapshot-id': number\n}\n\nexport interface SetPartitionStatisticsUpdate {\n  action: 'set-partition-statistics'\n  'partition-statistics': PartitionStatisticsFile\n}\n\nexport interface RemovePartitionStatisticsUpdate {\n  action: 'remove-partition-statistics'\n  'snapshot-id': number\n}\n\nexport interface RemovePartitionSpecsUpdate {\n  action: 'remove-partition-specs'\n  'spec-ids': number[]\n}\n\nexport interface RemoveSchemasUpdate {\n  action: 'remove-schemas'\n  'schema-ids': number[]\n}\n\nexport interface AddEncryptionKeyUpdate {\n  action: 'add-encryption-key'\n  'encryption-key': EncryptedKey\n}\n\nexport interface RemoveEncryptionKeyUpdate {\n  action: 'remove-encryption-key'\n  'key-id': string\n}\n\nexport type TableUpdate =\n  | AssignUUIDUpdate\n  | UpgradeFormatVersionUpdate\n  | AddSchemaUpdate\n  | SetCurrentSchemaUpdate\n  | AddPartitionSpecUpdate\n  | SetDefaultSpecUpdate\n  | AddSortOrderUpdate\n  | SetDefaultSortOrderUpdate\n  | AddSnapshotUpdate\n  | SetSnapshotRefUpdate\n  | RemoveSnapshotsUpdate\n  | RemoveSnapshotRefUpdate\n  | SetLocationUpdate\n  | SetPropertiesUpdate\n  | RemovePropertiesUpdate\n  | SetStatisticsUpdate\n  | RemoveStatisticsUpdate\n  | SetPartitionStatisticsUpdate\n  | RemovePartitionStatisticsUpdate\n  | RemovePartitionSpecsUpdate\n  | RemoveSchemasUpdate\n  | AddEncryptionKeyUpdate\n  | RemoveEncryptionKeyUpdate\n\n/* ===== TableRequirement discriminated union (per OpenAPI spec) ===== */\n\nexport interface AssertCreate {\n  type: 'assert-create'\n}\n\nexport interface AssertTableUUID {\n  type: 'assert-table-uuid'\n  uuid: string\n}\n\nexport interface AssertRefSnapshotId {\n  type: 'assert-ref-snapshot-id'\n  ref: string\n  'snapshot-id': number | null\n}\n\nexport interface AssertLastAssignedFieldId {\n  type: 'assert-last-assigned-field-id'\n  'last-assigned-field-id': number\n}\n\nexport interface AssertCurrentSchemaId {\n  type: 'assert-current-schema-id'\n  'current-schema-id': number\n}\n\nexport interface AssertLastAssignedPartitionId {\n  type: 'assert-last-assigned-partition-id'\n  'last-assigned-partition-id': number\n}\n\nexport interface AssertDefaultSpecId {\n  type: 'assert-default-spec-id'\n  'default-spec-id': number\n}\n\nexport interface AssertDefaultSortOrderId {\n  type: 'assert-default-sort-order-id'\n  'default-sort-order-id': number\n}\n\nexport type TableRequirement =\n  | AssertCreate\n  | AssertTableUUID\n  | AssertRefSnapshotId\n  | AssertLastAssignedFieldId\n  | AssertCurrentSchemaId\n  | AssertLastAssignedPartitionId\n  | AssertDefaultSpecId\n  | AssertDefaultSortOrderId\n\nexport interface DropTableRequest {\n  purge?: boolean\n}\n\nexport interface TableMetadata {\n  'format-version': number\n  'table-uuid': string\n  location?: string\n  'last-updated-ms'?: number\n  'last-column-id'?: number\n  schemas: TableSchema[]\n  'current-schema-id': number\n  'partition-specs': PartitionSpec[]\n  'default-spec-id'?: number\n  'last-partition-id'?: number\n  'sort-orders': SortOrder[]\n  'default-sort-order-id'?: number\n  properties: Record<string, string>\n  'metadata-location'?: string\n  'current-snapshot-id'?: number\n  snapshots?: Snapshot[]\n  'snapshot-log'?: { 'snapshot-id': number; 'timestamp-ms': number }[]\n  'metadata-log'?: { 'metadata-file': string; 'timestamp-ms': number }[]\n  refs?: Record<string, SnapshotReference>\n  'last-sequence-number'?: number\n  'next-row-id'?: number\n  statistics?: StatisticsFile[]\n  'partition-statistics'?: PartitionStatisticsFile[]\n  'encryption-keys'?: EncryptedKey[]\n  /** Optional name field returned by some catalogs */\n  name?: string\n}\n\nexport interface StorageCredential {\n  prefix: string\n  config: Record<string, string>\n}\n\nexport interface CreateNamespaceRequest {\n  namespace: string[]\n  properties?: Record<string, string>\n}\n\nexport interface CreateNamespaceResponse {\n  namespace: string[]\n  properties?: Record<string, string>\n}\n\nexport interface GetNamespaceResponse {\n  namespace: string[]\n  properties?: Record<string, string> | null\n}\n\nexport interface UpdateNamespacePropertiesRequest {\n  removals?: string[]\n  updates?: Record<string, string>\n}\n\nexport interface UpdateNamespacePropertiesResponse {\n  updated: string[]\n  removed: string[]\n  missing?: string[] | null\n}\n\nexport interface ListNamespacesResponse {\n  namespaces?: string[][]\n  'next-page-token'?: string | null\n}\n\nexport interface ListTablesResponse {\n  identifiers?: TableIdentifier[]\n  'next-page-token'?: string | null\n}\n\n/**\n * Spec-aligned LoadTableResult (named LoadTableResponse here for backward compat).\n * Returned by GET /tables/{t}, POST /tables, and POST /tables/{t} (commit).\n */\nexport interface LoadTableResponse {\n  metadata: TableMetadata\n  'metadata-location'?: string\n  config?: Record<string, string>\n  'storage-credentials'?: StorageCredential[]\n}\n\nexport type LoadTableResult = LoadTableResponse\n\nexport interface CommitTableResponse {\n  'metadata-location': string\n  metadata: TableMetadata\n}\n\n/**\n * Catalog configuration as returned by GET /v1/config?warehouse=...\n *\n * Servers can use `overrides.prefix` to direct subsequent requests to a\n * server-specific path prefix (e.g., the warehouse identifier), which is\n * the recommended pattern over hard-coded `catalogName` configuration.\n */\nexport interface CatalogConfig {\n  defaults: Record<string, string>\n  overrides: Record<string, string>\n  endpoints?: string[]\n  'idempotency-key-lifetime'?: string\n}\n\n/* ===== Method options ===== */\n\nexport interface ListNamespacesOptions {\n  parent?: NamespaceIdentifier\n  pageToken?: string\n  pageSize?: number\n}\n\nexport interface ListTablesOptions {\n  pageToken?: string\n  pageSize?: number\n}\n\nexport interface ListNamespacesResult {\n  namespaces: NamespaceIdentifier[]\n  nextPageToken?: string\n}\n\nexport interface ListTablesResult {\n  identifiers: TableIdentifier[]\n  nextPageToken?: string\n}\n\nexport interface LoadTableOptions {\n  /** ETag value from a previous response; server returns 304 (and we return null) if unchanged. */\n  ifNoneMatch?: string\n  /**\n   * Which snapshots the server should include in the returned metadata.\n   * - `'all'`: return every snapshot currently valid for the table\n   * - `'refs'`: only snapshots referenced by branches or tags\n   * Default if omitted is `'all'` per spec.\n   */\n  snapshots?: 'all' | 'refs'\n}\n\nexport interface LoadTableResultWithEtag extends LoadTableResponse {\n  etag: string | null\n}\n\n/**\n * Gets the current (active) schema from table metadata.\n *\n * @param metadata - Table metadata containing schemas array and current-schema-id\n * @returns The current table schema, or undefined if not found\n */\nexport function getCurrentSchema(metadata: TableMetadata): TableSchema | undefined {\n  return metadata.schemas.find((s) => s['schema-id'] === metadata['current-schema-id'])\n}\n","{\n  \"tag\": \"apache-iceberg-1.11.0-rc1\",\n  \"_comment\": \"Single source of truth for the Iceberg REST OpenAPI version this client tracks. Re-exported as ICEBERG_REST_SPEC_TAG, used by scripts/spec-source.mjs and test/spec-conformance/load-spec.ts to fetch the YAML at build/test time. Bump together with a release. Note: bumped from 1.10.0 to 1.11.0-rc1 because the client emits Idempotency-Key headers which were not part of 1.10.0 — the spec-conformance tests would reject the implementation against the older tag.\"\n}\n","import pin from '../spec-pin.json' with { type: 'json' }\n\n/**\n * Git tag of `apache/iceberg` that this client is aligned to. The\n * spec-conformance test suite fetches and validates against the OpenAPI YAML\n * from this exact ref, so types, request bodies, and response handling here\n * match the spec at this version.\n *\n * @example 'apache-iceberg-1.10.0'\n */\nexport const ICEBERG_REST_SPEC_TAG: string = pin.tag\n\n/**\n * Direct link to the OpenAPI YAML this client tracks.\n */\nexport const ICEBERG_REST_SPEC_URL: string = `https://raw.githubusercontent.com/apache/iceberg/${pin.tag}/open-api/rest-catalog-open-api.yaml`\n"]}