@useairfoil/effect-iceberg 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,207 +1,25 @@
1
- # @useairfoil/effect-iceberg
1
+ # Effect Iceberg
2
2
 
3
- Effect wrapper for [`iceberg-js`](https://github.com/supabase/iceberg-js), the Apache Iceberg REST Catalog client.
4
-
5
- This package provides an Effect service, layers, accessors, and typed errors around `iceberg-js`. It does not replace the `iceberg-js` API or type surface. Import Apache Iceberg domain types directly from `iceberg-js`.
3
+ This package gives an Effect API for the `iceberg-js` REST catalog client.
6
4
 
7
5
  ## Install
8
6
 
9
- ```sh
10
- pnpm add @useairfoil/effect-iceberg iceberg-js effect
11
- ```
12
-
13
- `iceberg-js` and `effect` are peer dependencies so your application owns their versions.
14
-
15
- ## Imports
16
-
17
- ```typescript
18
- import { IcebergCatalog, IcebergError } from "@useairfoil/effect-iceberg";
19
- import type { CreateTableRequest, TableIdentifier } from "iceberg-js";
20
- ```
21
-
22
- `@useairfoil/effect-iceberg` exports wrapper modules only:
23
-
24
- - `IcebergCatalog` contains the service tag, constructors, layers, and accessor functions.
25
- - `IcebergError` contains the Effect error type and mapper for failures from `iceberg-js`.
26
-
27
- Use `iceberg-js` directly for catalog options, request/response types, metadata types, table update unions, and helpers.
28
-
29
- ## Layer
30
-
31
- Create a layer from normal `iceberg-js` catalog options:
32
-
33
- ```typescript
34
- import { IcebergCatalog } from "@useairfoil/effect-iceberg";
35
-
36
- const IcebergLive = IcebergCatalog.layer({
37
- baseUrl: "https://catalog.example.com",
38
- warehouse: "warehouse",
39
- auth: { type: "bearer", token: process.env.ICEBERG_TOKEN ?? "" },
40
- accessDelegation: ["vended-credentials"],
41
- });
42
- ```
43
-
44
- Or build a layer from Effect `Config` values:
45
-
46
- ```typescript
47
- import { Config } from "effect";
48
- import { IcebergCatalog } from "@useairfoil/effect-iceberg";
49
- import type { AuthConfig } from "iceberg-js";
50
-
51
- const IcebergLive = IcebergCatalog.layerConfig({
52
- baseUrl: Config.string("ICEBERG_REST_URL"),
53
- warehouse: Config.string("ICEBERG_WAREHOUSE"),
54
- auth: Config.string("ICEBERG_TOKEN").pipe(
55
- Config.map((token): AuthConfig => ({ type: "bearer", token })),
56
- ),
57
- });
7
+ ```bash
8
+ pnpm add @useairfoil/effect-iceberg effect@^4 iceberg-js
58
9
  ```
59
10
 
60
11
  ## Usage
61
12
 
62
- Use the accessor functions for most application code. They read the `IcebergCatalog` service from the Effect context and delegate to the underlying `iceberg-js` client.
63
-
64
- ```typescript
65
- import { Effect } from "effect";
13
+ ```ts
66
14
  import { IcebergCatalog } from "@useairfoil/effect-iceberg";
67
- import type { TableIdentifier } from "iceberg-js";
68
-
69
- const IcebergLive = IcebergCatalog.layer({
70
- baseUrl: "https://catalog.example.com",
71
- warehouse: "warehouse",
72
- auth: { type: "bearer", token: process.env.ICEBERG_TOKEN ?? "" },
73
- });
74
-
75
- const program = Effect.gen(function* () {
76
- const id: TableIdentifier = { namespace: ["analytics"], name: "events" };
77
- return yield* IcebergCatalog.loadTable(id);
78
- });
79
-
80
- await Effect.runPromise(program.pipe(Effect.provide(IcebergLive)));
81
- ```
82
-
83
- ## Catalog Operations
84
-
85
- The `IcebergCatalog` module mirrors the public `iceberg-js` `IcebergRestCatalog` methods as Effect accessors:
86
-
87
- ```typescript
88
- const program = Effect.gen(function* () {
89
- const namespaces = yield* IcebergCatalog.listNamespaces();
90
-
91
- const tables = yield* IcebergCatalog.listTables({ namespace: ["analytics"] });
92
-
93
- const table = yield* IcebergCatalog.loadTable({
94
- namespace: ["analytics"],
95
- name: "events",
96
- });
97
-
98
- return { namespaces, tables, table };
99
- });
100
- ```
101
-
102
- Create tables with request types from `iceberg-js`:
103
-
104
- ```typescript
105
- import type { CreateTableRequest } from "iceberg-js";
106
-
107
- const request: CreateTableRequest = {
108
- name: "events",
109
- schema: {
110
- type: "struct",
111
- "schema-id": 0,
112
- fields: [{ id: 1, name: "id", type: "string", required: true }],
113
- },
114
- };
115
-
116
- const program = Effect.gen(function* () {
117
- return yield* IcebergCatalog.createTable({ namespace: ["analytics"] }, request);
118
- });
119
- ```
120
-
121
- Use `loadTableResult`, `createTableResult`, or `registerTableResult` when you need the full spec-aligned result, including server config, storage credentials, metadata location, and ETag:
122
-
123
- ```typescript
124
- const program = Effect.gen(function* () {
125
- const result = yield* IcebergCatalog.loadTableResult({
126
- namespace: ["analytics"],
127
- name: "events",
128
- });
129
-
130
- if (result) {
131
- console.log(result.etag);
132
- console.log(result["storage-credentials"]);
133
- }
134
-
135
- return result;
136
- });
137
- ```
138
-
139
- Conditional table loads return `null` when the server responds with `304 Not Modified`:
140
-
141
- ```typescript
142
- const program = Effect.gen(function* () {
143
- return yield* IcebergCatalog.loadTable(
144
- { namespace: ["analytics"], name: "events" },
145
- { ifNoneMatch: "abc123" },
146
- );
147
- });
148
- ```
149
-
150
- ## Service Access
151
-
152
- For advanced use cases, access the service directly. This is useful when you want the underlying `iceberg-js` client or want to call several methods from one service value.
153
-
154
- ```typescript
155
- const program = Effect.gen(function* () {
156
- const catalog = yield* IcebergCatalog.IcebergCatalog;
157
- const client = catalog.getCatalogClient();
158
-
159
- yield* catalog.loadConfig();
160
- return client;
161
- });
162
- ```
163
-
164
- ## Errors
165
-
166
- Failures thrown by `iceberg-js` are mapped to `IcebergError.IcebergError`. The wrapper preserves the important Iceberg fields: HTTP `status`, Iceberg exception `type` / `code`, `details`, and `isCommitStateUnknown`.
167
-
168
- ```typescript
169
15
  import { Effect } from "effect";
170
- import { IcebergError } from "@useairfoil/effect-iceberg";
171
16
 
172
- const handled = program.pipe(
173
- Effect.catchTag("IcebergError", (error: IcebergError.IcebergError) =>
174
- Effect.succeed({ status: error.status, type: error.icebergType }),
17
+ const namespaces = IcebergCatalog.listNamespaces().pipe(
18
+ Effect.provide(
19
+ IcebergCatalog.layer({
20
+ baseUrl: "https://catalog.example.com",
21
+ warehouse: "warehouse",
22
+ }),
175
23
  ),
176
24
  );
177
25
  ```
178
-
179
- You can also inspect commit-state ambiguity from the Iceberg REST spec:
180
-
181
- ```typescript
182
- const safeCommit = IcebergCatalog.commitTable(id, request).pipe(
183
- Effect.catchTag("IcebergError", (error) => {
184
- if (error.isCommitStateUnknown) {
185
- return Effect.fail(error);
186
- }
187
- return Effect.fail(error);
188
- }),
189
- );
190
- ```
191
-
192
- ## Direct `iceberg-js` Types
193
-
194
- Keep domain types close to `iceberg-js`:
195
-
196
- ```typescript
197
- import type {
198
- CommitTableRequest,
199
- LoadTableResultWithEtag,
200
- NamespaceIdentifier,
201
- TableIdentifier,
202
- TableMetadata,
203
- TableUpdate,
204
- } from "iceberg-js";
205
- ```
206
-
207
- This keeps your application aligned with the exact `iceberg-js` version you install, while `@useairfoil/effect-iceberg` provides the Effect integration layer.
@@ -1,13 +1,9 @@
1
1
  import { Config, Context, Effect, Layer } from "effect";
2
2
  import { CatalogConfig, CommitTableRequest, CommitTableResponse, CreateNamespaceResponse, CreateTableRequest, DropTableRequest, IcebergRestCatalog, IcebergRestCatalogOptions, ListNamespacesOptions, ListNamespacesResult, ListTablesOptions, ListTablesResult, LoadTableOptions, LoadTableResultWithEtag, NamespaceIdentifier, NamespaceMetadata, RegisterTableRequest, RenameTableRequest, TableIdentifier, TableMetadata, UpdateNamespacePropertiesRequest, UpdateNamespacePropertiesResponse, UpdateTableRequest } from "iceberg-js";
3
- import * as effect_Types0 from "effect/Types";
4
- import * as effect_Cause0 from "effect/Cause";
5
-
6
- //#region src/errors.d.ts
7
3
  declare namespace errors_d_exports {
8
4
  export { IcebergError$1 as IcebergError, mapIcebergError };
9
5
  }
10
- declare const IcebergError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }>) => effect_Cause0.YieldableError & {
6
+ declare const IcebergError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
11
7
  readonly _tag: "IcebergError";
12
8
  } & Readonly<A>;
13
9
  /** Error type used by the Effect wrapper around `iceberg-js`. */
@@ -130,4 +126,4 @@ declare const layer: (options: IcebergRestCatalogOptions) => Layer.Layer<Iceberg
130
126
  declare const layerConfig: (config: Config.Wrap<IcebergRestCatalogOptions>) => Layer.Layer<IcebergCatalog, Config.ConfigError>;
131
127
  //#endregion
132
128
  export { catalog_d_exports as IcebergCatalog, errors_d_exports as IcebergError };
133
- //# sourceMappingURL=index.d.ts.map
129
+ //# sourceMappingURL=index.d.mts.map
@@ -1,9 +1,8 @@
1
- import { t as __export } from "./chunk-Bp6m_JJh.js";
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Config, Context, Data, Effect, Layer } from "effect";
3
3
  import { IcebergError, IcebergRestCatalog } from "iceberg-js";
4
-
5
4
  //#region src/errors.ts
6
- var errors_exports = /* @__PURE__ */ __export({
5
+ var errors_exports = /* @__PURE__ */ __exportAll({
7
6
  IcebergError: () => IcebergError$1,
8
7
  mapIcebergError: () => mapIcebergError
9
8
  });
@@ -25,10 +24,9 @@ const mapIcebergError = (error) => {
25
24
  cause: error
26
25
  });
27
26
  };
28
-
29
27
  //#endregion
30
28
  //#region src/catalog.ts
31
- var catalog_exports = /* @__PURE__ */ __export({
29
+ var catalog_exports = /* @__PURE__ */ __exportAll({
32
30
  IcebergCatalog: () => IcebergCatalog,
33
31
  commitTable: () => commitTable,
34
32
  createNamespace: () => createNamespace,
@@ -65,7 +63,7 @@ const tryCatalog = (evaluate) => Effect.tryPromise({
65
63
  /** Creates an `IcebergCatalog` service from `iceberg-js` catalog options. */
66
64
  const make = (options) => {
67
65
  const catalog = new IcebergRestCatalog(options);
68
- function loadTable$1(id, loadOptions) {
66
+ function loadTable(id, loadOptions) {
69
67
  return tryCatalog(() => loadOptions === void 0 ? catalog.loadTable(id) : catalog.loadTable(id, loadOptions));
70
68
  }
71
69
  return IcebergCatalog.of({
@@ -82,7 +80,7 @@ const make = (options) => {
82
80
  updateTable: (id, request) => tryCatalog(() => catalog.updateTable(id, request)),
83
81
  commitTable: (id, request) => tryCatalog(() => catalog.commitTable(id, request)),
84
82
  dropTable: (id, dropOptions) => tryCatalog(() => catalog.dropTable(id, dropOptions)),
85
- loadTable: loadTable$1,
83
+ loadTable,
86
84
  loadTableResult: (id, loadOptions) => tryCatalog(() => catalog.loadTableResult(id, loadOptions)),
87
85
  namespaceExists: (id) => tryCatalog(() => catalog.namespaceExists(id)),
88
86
  tableExists: (id) => tryCatalog(() => catalog.tableExists(id)),
@@ -122,9 +120,10 @@ const renameTable = (request) => Effect.flatMap(service, (catalog) => catalog.re
122
120
  const layer = (options) => Layer.succeed(IcebergCatalog)(make(options));
123
121
  /** Creates an `IcebergCatalog` layer from Effect `Config` values. */
124
122
  const layerConfig = (config) => Layer.effect(IcebergCatalog, Effect.gen(function* () {
125
- return make(yield* Config.unwrap(config));
123
+ const options = yield* Config.unwrap(config);
124
+ return make(options);
126
125
  }));
127
-
128
126
  //#endregion
129
127
  export { catalog_exports as IcebergCatalog, errors_exports as IcebergError };
130
- //# sourceMappingURL=index.js.map
128
+
129
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["IcebergError","IcebergJsError"],"sources":["../src/errors.ts","../src/catalog.ts"],"sourcesContent":["import { Data } from \"effect\";\nimport { IcebergError as IcebergJsError } from \"iceberg-js\";\n\n/** Error type used by the Effect wrapper around `iceberg-js`. */\nexport class IcebergError extends Data.TaggedError(\"IcebergError\")<{\n readonly message: string;\n readonly status?: number;\n readonly icebergType?: string;\n readonly icebergCode?: number;\n readonly details?: unknown;\n readonly isCommitStateUnknown?: boolean;\n readonly cause?: unknown;\n}> {}\n\n/** Maps errors thrown by `iceberg-js` into `IcebergError`. */\nexport const mapIcebergError = (error: unknown): IcebergError => {\n if (error instanceof IcebergJsError) {\n return new IcebergError({\n message: error.message,\n status: error.status,\n icebergType: error.icebergType,\n icebergCode: error.icebergCode,\n details: error.details,\n isCommitStateUnknown: error.isCommitStateUnknown,\n cause: error,\n });\n }\n\n return new IcebergError({\n message: error instanceof Error ? error.message : String(error),\n cause: error,\n });\n};\n","import type {\n CatalogConfig,\n CommitTableRequest,\n CommitTableResponse,\n CreateNamespaceResponse,\n CreateTableRequest,\n DropTableRequest,\n IcebergRestCatalogOptions,\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 \"iceberg-js\";\n\nimport { Config, Context, Effect, Layer } from \"effect\";\nimport { IcebergRestCatalog } from \"iceberg-js\";\n\nimport type { IcebergError } from \"./errors\";\n\nimport { mapIcebergError } from \"./errors\";\n\nexport interface Service {\n /**\n * Returns the underlying `iceberg-js` catalog client.\n *\n * Use this for advanced cases that need direct access to the Promise-based API.\n */\n readonly getCatalogClient: () => IcebergRestCatalog;\n\n /**\n * Fetch and cache the server's catalog configuration. Calling this is optional;\n * catalog operations trigger it lazily when a warehouse is configured.\n */\n readonly loadConfig: () => Effect.Effect<CatalogConfig, IcebergError>;\n\n /** Lists all namespaces in the catalog. */\n readonly listNamespaces: (\n options?: ListNamespacesOptions,\n ) => Effect.Effect<ListNamespacesResult, IcebergError>;\n\n /** Creates a new namespace in the catalog. */\n readonly createNamespace: (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n ) => Effect.Effect<CreateNamespaceResponse, IcebergError>;\n\n /**\n * Drops a namespace from the catalog.\n *\n * The namespace must be empty before it can be dropped.\n */\n readonly dropNamespace: (id: NamespaceIdentifier) => Effect.Effect<void, IcebergError>;\n\n /** Loads metadata for a namespace. */\n readonly loadNamespaceMetadata: (\n id: NamespaceIdentifier,\n ) => Effect.Effect<NamespaceMetadata, IcebergError>;\n\n /** Sets or removes properties on a namespace. */\n readonly updateNamespaceProperties: (\n id: NamespaceIdentifier,\n request: UpdateNamespacePropertiesRequest,\n ) => Effect.Effect<UpdateNamespacePropertiesResponse, IcebergError>;\n\n /** Lists tables in a namespace. */\n readonly listTables: (\n namespace: NamespaceIdentifier,\n options?: ListTablesOptions,\n ) => Effect.Effect<ListTablesResult, IcebergError>;\n\n /** Creates a new table in the catalog. */\n readonly createTable: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /**\n * Creates a table and returns the full spec-aligned `LoadTableResult`, including\n * server config, storage credentials, and the response ETag.\n */\n readonly createTableResult: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<LoadTableResultWithEtag, IcebergError>;\n\n /** Commits updates to a table using the spec-aligned `{ requirements, updates }` shape. */\n readonly updateTable: (\n id: TableIdentifier,\n request: UpdateTableRequest,\n ) => Effect.Effect<CommitTableResponse, IcebergError>;\n\n /** Spec-aligned alias for `updateTable`. */\n readonly commitTable: (\n id: TableIdentifier,\n request: CommitTableRequest,\n ) => Effect.Effect<CommitTableResponse, IcebergError>;\n\n /** Drops a table from the catalog. */\n readonly dropTable: (\n id: TableIdentifier,\n options?: DropTableRequest,\n ) => Effect.Effect<void, IcebergError>;\n\n /**\n * Loads metadata for a table.\n *\n * Pass `ifNoneMatch` in options to perform a conditional GET. If the server\n * returns 304 Not Modified, the result is `null`.\n */\n readonly loadTable: {\n (id: TableIdentifier): Effect.Effect<TableMetadata, IcebergError>;\n (\n id: TableIdentifier,\n options: LoadTableOptions,\n ): Effect.Effect<TableMetadata | null, IcebergError>;\n };\n\n /**\n * Loads the full spec-aligned `LoadTableResult`, including server config,\n * storage credentials, and the response ETag. Returns `null` on 304.\n */\n readonly loadTableResult: (\n id: TableIdentifier,\n options?: LoadTableOptions,\n ) => Effect.Effect<LoadTableResultWithEtag | null, IcebergError>;\n\n /** Checks if a namespace exists in the catalog. */\n readonly namespaceExists: (id: NamespaceIdentifier) => Effect.Effect<boolean, IcebergError>;\n\n /** Checks if a table exists in the catalog. */\n readonly tableExists: (id: TableIdentifier) => Effect.Effect<boolean, IcebergError>;\n\n /** Creates a namespace if it does not exist. */\n readonly createNamespaceIfNotExists: (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n ) => Effect.Effect<CreateNamespaceResponse | void, IcebergError>;\n\n /** Creates a table if it does not exist. */\n readonly createTableIfNotExists: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /** Registers an existing metadata file as a table in the given namespace. */\n readonly registerTable: (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /** Returns the full spec-aligned `LoadTableResult` for `registerTable`. */\n readonly registerTableResult: (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n ) => Effect.Effect<LoadTableResultWithEtag, IcebergError>;\n\n /** Renames a table. Servers may or may not support cross-namespace renames. */\n readonly renameTable: (request: RenameTableRequest) => Effect.Effect<void, IcebergError>;\n}\n\n/** Service for the Effect wrapper around `iceberg-js`'s `IcebergRestCatalog`. */\nexport class IcebergCatalog extends Context.Service<IcebergCatalog, Service>()(\n \"@useairfoil/effect-iceberg/IcebergCatalog\",\n) {}\n\nconst tryCatalog = <A>(evaluate: () => Promise<A>): Effect.Effect<A, IcebergError> =>\n Effect.tryPromise({\n try: evaluate,\n catch: mapIcebergError,\n });\n\n/** Creates an `IcebergCatalog` service from `iceberg-js` catalog options. */\nexport const make = (options: IcebergRestCatalogOptions): Service => {\n const catalog = new IcebergRestCatalog(options);\n\n function loadTable(id: TableIdentifier): Effect.Effect<TableMetadata, IcebergError>;\n function loadTable(\n id: TableIdentifier,\n loadOptions: LoadTableOptions,\n ): Effect.Effect<TableMetadata | null, IcebergError>;\n function loadTable(id: TableIdentifier, loadOptions?: LoadTableOptions) {\n return tryCatalog(() =>\n loadOptions === undefined ? catalog.loadTable(id) : catalog.loadTable(id, loadOptions),\n );\n }\n\n return IcebergCatalog.of({\n getCatalogClient: () => catalog,\n loadConfig: () => tryCatalog(() => catalog.loadConfig()),\n\n listNamespaces: (listOptions) => tryCatalog(() => catalog.listNamespaces(listOptions)),\n createNamespace: (id, metadata) => tryCatalog(() => catalog.createNamespace(id, metadata)),\n dropNamespace: (id) => tryCatalog(() => catalog.dropNamespace(id)),\n loadNamespaceMetadata: (id) => tryCatalog(() => catalog.loadNamespaceMetadata(id)),\n updateNamespaceProperties: (id, request) =>\n tryCatalog(() => catalog.updateNamespaceProperties(id, request)),\n\n listTables: (namespace, listOptions) =>\n tryCatalog(() => catalog.listTables(namespace, listOptions)),\n createTable: (namespace, request) => tryCatalog(() => catalog.createTable(namespace, request)),\n createTableResult: (namespace, request) =>\n tryCatalog(() => catalog.createTableResult(namespace, request)),\n updateTable: (id, request) => tryCatalog(() => catalog.updateTable(id, request)),\n commitTable: (id, request) => tryCatalog(() => catalog.commitTable(id, request)),\n dropTable: (id, dropOptions) => tryCatalog(() => catalog.dropTable(id, dropOptions)),\n loadTable,\n loadTableResult: (id, loadOptions) =>\n tryCatalog(() => catalog.loadTableResult(id, loadOptions)),\n namespaceExists: (id) => tryCatalog(() => catalog.namespaceExists(id)),\n tableExists: (id) => tryCatalog(() => catalog.tableExists(id)),\n createNamespaceIfNotExists: (id, metadata) =>\n tryCatalog(() => catalog.createNamespaceIfNotExists(id, metadata)),\n createTableIfNotExists: (namespace, request) =>\n tryCatalog(() => catalog.createTableIfNotExists(namespace, request)),\n registerTable: (namespace, request) =>\n tryCatalog(() => catalog.registerTable(namespace, request)),\n registerTableResult: (namespace, request) =>\n tryCatalog(() => catalog.registerTableResult(namespace, request)),\n renameTable: (request) => tryCatalog(() => catalog.renameTable(request)),\n });\n};\n\nconst service = Effect.service(IcebergCatalog);\n\nexport const getCatalogClient: Effect.Effect<IcebergRestCatalog, never, IcebergCatalog> =\n Effect.map(service, (catalog) => catalog.getCatalogClient());\n\nexport const loadConfig: Effect.Effect<CatalogConfig, IcebergError, IcebergCatalog> =\n Effect.flatMap(service, (catalog) => catalog.loadConfig());\n\nexport const listNamespaces = (\n options?: ListNamespacesOptions,\n): Effect.Effect<ListNamespacesResult, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.listNamespaces(options));\n\nexport const createNamespace = (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n): Effect.Effect<CreateNamespaceResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createNamespace(id, metadata));\n\nexport const dropNamespace = (\n id: NamespaceIdentifier,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.dropNamespace(id));\n\nexport const loadNamespaceMetadata = (\n id: NamespaceIdentifier,\n): Effect.Effect<NamespaceMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.loadNamespaceMetadata(id));\n\nexport const updateNamespaceProperties = (\n id: NamespaceIdentifier,\n request: UpdateNamespacePropertiesRequest,\n): Effect.Effect<UpdateNamespacePropertiesResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.updateNamespaceProperties(id, request));\n\nexport const listTables = (\n namespace: NamespaceIdentifier,\n options?: ListTablesOptions,\n): Effect.Effect<ListTablesResult, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.listTables(namespace, options));\n\nexport const createTable = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTable(namespace, request));\n\nexport const createTableResult = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<LoadTableResultWithEtag, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTableResult(namespace, request));\n\nexport const updateTable = (\n id: TableIdentifier,\n request: UpdateTableRequest,\n): Effect.Effect<CommitTableResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.updateTable(id, request));\n\nexport const commitTable = (\n id: TableIdentifier,\n request: CommitTableRequest,\n): Effect.Effect<CommitTableResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.commitTable(id, request));\n\nexport const dropTable = (\n id: TableIdentifier,\n options?: DropTableRequest,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.dropTable(id, options));\n\nexport function loadTable(\n id: TableIdentifier,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog>;\nexport function loadTable(\n id: TableIdentifier,\n options: LoadTableOptions,\n): Effect.Effect<TableMetadata | null, IcebergError, IcebergCatalog>;\nexport function loadTable(id: TableIdentifier, options?: LoadTableOptions) {\n return Effect.flatMap(service, (catalog) =>\n options === undefined ? catalog.loadTable(id) : catalog.loadTable(id, options),\n );\n}\n\nexport const loadTableResult = (\n id: TableIdentifier,\n options?: LoadTableOptions,\n): Effect.Effect<LoadTableResultWithEtag | null, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.loadTableResult(id, options));\n\nexport const namespaceExists = (\n id: NamespaceIdentifier,\n): Effect.Effect<boolean, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.namespaceExists(id));\n\nexport const tableExists = (\n id: TableIdentifier,\n): Effect.Effect<boolean, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.tableExists(id));\n\nexport const createNamespaceIfNotExists = (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n): Effect.Effect<CreateNamespaceResponse | void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createNamespaceIfNotExists(id, metadata));\n\nexport const createTableIfNotExists = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTableIfNotExists(namespace, request));\n\nexport const registerTable = (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.registerTable(namespace, request));\n\nexport const registerTableResult = (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n): Effect.Effect<LoadTableResultWithEtag, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.registerTableResult(namespace, request));\n\nexport const renameTable = (\n request: RenameTableRequest,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.renameTable(request));\n\n/** Creates an `IcebergCatalog` layer from concrete `iceberg-js` catalog options. */\nexport const layer = (options: IcebergRestCatalogOptions): Layer.Layer<IcebergCatalog> =>\n Layer.succeed(IcebergCatalog)(make(options));\n\n/** Creates an `IcebergCatalog` layer from Effect `Config` values. */\nexport const layerConfig = (\n config: Config.Wrap<IcebergRestCatalogOptions>,\n): Layer.Layer<IcebergCatalog, Config.ConfigError> =>\n Layer.effect(\n IcebergCatalog,\n Effect.gen(function* () {\n const options = yield* Config.unwrap(config);\n return make(options);\n }),\n );\n"],"mappings":";;;;;;;;;AAIA,IAAaA,iBAAb,cAAkC,KAAK,YAAY,cAAc,CAAC,CAQ/D,CAAC;;AAGJ,MAAa,mBAAmB,UAAiC;CAC/D,IAAI,iBAAiBC,cACnB,OAAO,IAAID,eAAa;EACtB,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,aAAa,MAAM;EACnB,aAAa,MAAM;EACnB,SAAS,MAAM;EACf,sBAAsB,MAAM;EAC5B,OAAO;CACT,CAAC;CAGH,OAAO,IAAIA,eAAa;EACtB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EAC9D,OAAO;CACT,C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AC;;AAG7C,MAAa,eACX,WAEA,MAAM,OACJ,gBACA,OAAO,IAAI,aAAa;CACtB,MAAM,UAAU,OAAO,OAAO,OAAO,MAAM;CAC3C,OAAO,KAAK,OAAO;AACrB,CAAC,CACH"}
@@ -1,13 +1,13 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __defProp = Object.defineProperty;
3
- var __export = (all) => {
3
+ var __exportAll = (all, no_symbols) => {
4
4
  let target = {};
5
5
  for (var name in all) __defProp(target, name, {
6
6
  get: all[name],
7
7
  enumerable: true
8
8
  });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
9
10
  return target;
10
11
  };
11
-
12
12
  //#endregion
13
- export { __export as t };
13
+ export { __exportAll as t };
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@useairfoil/effect-iceberg",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "keywords": [
5
5
  "effect",
6
6
  "iceberg"
7
7
  ],
8
- "repository": "useairfoil/typescript-sdk",
8
+ "repository": "useairfoil/connector-kit",
9
9
  "files": [
10
10
  "dist",
11
11
  "src",
12
12
  "README.md"
13
13
  ],
14
14
  "type": "module",
15
- "main": "./dist/index.js",
16
- "types": "./dist/index.d.ts",
15
+ "main": "./dist/index.mjs",
16
+ "types": "./dist/index.d.mts",
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./dist/index.d.ts",
20
- "import": "./dist/index.js",
21
- "default": "./dist/index.js"
19
+ "types": "./dist/index.d.mts",
20
+ "import": "./dist/index.mjs",
21
+ "default": "./dist/index.mjs"
22
22
  }
23
23
  },
24
24
  "scripts": {
@@ -28,15 +28,15 @@
28
28
  "typecheck": "tsc --noEmit"
29
29
  },
30
30
  "devDependencies": {
31
- "@effect/vitest": "^4.0.0-rc.108",
31
+ "@effect/vitest": "^4.0.7",
32
32
  "@types/node": "^24.2.0",
33
- "effect": "^4.0.0-rc.108",
33
+ "effect": "^4.0.7",
34
34
  "iceberg-js": "^1.0.0",
35
- "tsdown": "^0.15.6",
36
- "vitest": "^4.1.0"
35
+ "tsdown": "^0.23.0",
36
+ "vitest": "^5.0.3"
37
37
  },
38
38
  "peerDependencies": {
39
- "effect": "^4.0.0-rc.108",
39
+ "effect": "^4.0.7",
40
40
  "iceberg-js": "^1.0.0"
41
41
  },
42
42
  "peerDependenciesMeta": {
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["IcebergError","IcebergJsError","loadTable","getCatalogClient: Effect.Effect<IcebergRestCatalog, never, IcebergCatalog>","loadConfig: Effect.Effect<CatalogConfig, IcebergError, IcebergCatalog>"],"sources":["../src/errors.ts","../src/catalog.ts"],"sourcesContent":["import { Data } from \"effect\";\nimport { IcebergError as IcebergJsError } from \"iceberg-js\";\n\n/** Error type used by the Effect wrapper around `iceberg-js`. */\nexport class IcebergError extends Data.TaggedError(\"IcebergError\")<{\n readonly message: string;\n readonly status?: number;\n readonly icebergType?: string;\n readonly icebergCode?: number;\n readonly details?: unknown;\n readonly isCommitStateUnknown?: boolean;\n readonly cause?: unknown;\n}> {}\n\n/** Maps errors thrown by `iceberg-js` into `IcebergError`. */\nexport const mapIcebergError = (error: unknown): IcebergError => {\n if (error instanceof IcebergJsError) {\n return new IcebergError({\n message: error.message,\n status: error.status,\n icebergType: error.icebergType,\n icebergCode: error.icebergCode,\n details: error.details,\n isCommitStateUnknown: error.isCommitStateUnknown,\n cause: error,\n });\n }\n\n return new IcebergError({\n message: error instanceof Error ? error.message : String(error),\n cause: error,\n });\n};\n","import type {\n CatalogConfig,\n CommitTableRequest,\n CommitTableResponse,\n CreateNamespaceResponse,\n CreateTableRequest,\n DropTableRequest,\n IcebergRestCatalogOptions,\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 \"iceberg-js\";\n\nimport { Config, Context, Effect, Layer } from \"effect\";\nimport { IcebergRestCatalog } from \"iceberg-js\";\n\nimport type { IcebergError } from \"./errors\";\n\nimport { mapIcebergError } from \"./errors\";\n\nexport interface Service {\n /**\n * Returns the underlying `iceberg-js` catalog client.\n *\n * Use this for advanced cases that need direct access to the Promise-based API.\n */\n readonly getCatalogClient: () => IcebergRestCatalog;\n\n /**\n * Fetch and cache the server's catalog configuration. Calling this is optional;\n * catalog operations trigger it lazily when a warehouse is configured.\n */\n readonly loadConfig: () => Effect.Effect<CatalogConfig, IcebergError>;\n\n /** Lists all namespaces in the catalog. */\n readonly listNamespaces: (\n options?: ListNamespacesOptions,\n ) => Effect.Effect<ListNamespacesResult, IcebergError>;\n\n /** Creates a new namespace in the catalog. */\n readonly createNamespace: (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n ) => Effect.Effect<CreateNamespaceResponse, IcebergError>;\n\n /**\n * Drops a namespace from the catalog.\n *\n * The namespace must be empty before it can be dropped.\n */\n readonly dropNamespace: (id: NamespaceIdentifier) => Effect.Effect<void, IcebergError>;\n\n /** Loads metadata for a namespace. */\n readonly loadNamespaceMetadata: (\n id: NamespaceIdentifier,\n ) => Effect.Effect<NamespaceMetadata, IcebergError>;\n\n /** Sets or removes properties on a namespace. */\n readonly updateNamespaceProperties: (\n id: NamespaceIdentifier,\n request: UpdateNamespacePropertiesRequest,\n ) => Effect.Effect<UpdateNamespacePropertiesResponse, IcebergError>;\n\n /** Lists tables in a namespace. */\n readonly listTables: (\n namespace: NamespaceIdentifier,\n options?: ListTablesOptions,\n ) => Effect.Effect<ListTablesResult, IcebergError>;\n\n /** Creates a new table in the catalog. */\n readonly createTable: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /**\n * Creates a table and returns the full spec-aligned `LoadTableResult`, including\n * server config, storage credentials, and the response ETag.\n */\n readonly createTableResult: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<LoadTableResultWithEtag, IcebergError>;\n\n /** Commits updates to a table using the spec-aligned `{ requirements, updates }` shape. */\n readonly updateTable: (\n id: TableIdentifier,\n request: UpdateTableRequest,\n ) => Effect.Effect<CommitTableResponse, IcebergError>;\n\n /** Spec-aligned alias for `updateTable`. */\n readonly commitTable: (\n id: TableIdentifier,\n request: CommitTableRequest,\n ) => Effect.Effect<CommitTableResponse, IcebergError>;\n\n /** Drops a table from the catalog. */\n readonly dropTable: (\n id: TableIdentifier,\n options?: DropTableRequest,\n ) => Effect.Effect<void, IcebergError>;\n\n /**\n * Loads metadata for a table.\n *\n * Pass `ifNoneMatch` in options to perform a conditional GET. If the server\n * returns 304 Not Modified, the result is `null`.\n */\n readonly loadTable: {\n (id: TableIdentifier): Effect.Effect<TableMetadata, IcebergError>;\n (\n id: TableIdentifier,\n options: LoadTableOptions,\n ): Effect.Effect<TableMetadata | null, IcebergError>;\n };\n\n /**\n * Loads the full spec-aligned `LoadTableResult`, including server config,\n * storage credentials, and the response ETag. Returns `null` on 304.\n */\n readonly loadTableResult: (\n id: TableIdentifier,\n options?: LoadTableOptions,\n ) => Effect.Effect<LoadTableResultWithEtag | null, IcebergError>;\n\n /** Checks if a namespace exists in the catalog. */\n readonly namespaceExists: (id: NamespaceIdentifier) => Effect.Effect<boolean, IcebergError>;\n\n /** Checks if a table exists in the catalog. */\n readonly tableExists: (id: TableIdentifier) => Effect.Effect<boolean, IcebergError>;\n\n /** Creates a namespace if it does not exist. */\n readonly createNamespaceIfNotExists: (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n ) => Effect.Effect<CreateNamespaceResponse | void, IcebergError>;\n\n /** Creates a table if it does not exist. */\n readonly createTableIfNotExists: (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /** Registers an existing metadata file as a table in the given namespace. */\n readonly registerTable: (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n ) => Effect.Effect<TableMetadata, IcebergError>;\n\n /** Returns the full spec-aligned `LoadTableResult` for `registerTable`. */\n readonly registerTableResult: (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n ) => Effect.Effect<LoadTableResultWithEtag, IcebergError>;\n\n /** Renames a table. Servers may or may not support cross-namespace renames. */\n readonly renameTable: (request: RenameTableRequest) => Effect.Effect<void, IcebergError>;\n}\n\n/** Service for the Effect wrapper around `iceberg-js`'s `IcebergRestCatalog`. */\nexport class IcebergCatalog extends Context.Service<IcebergCatalog, Service>()(\n \"@useairfoil/effect-iceberg/IcebergCatalog\",\n) {}\n\nconst tryCatalog = <A>(evaluate: () => Promise<A>): Effect.Effect<A, IcebergError> =>\n Effect.tryPromise({\n try: evaluate,\n catch: mapIcebergError,\n });\n\n/** Creates an `IcebergCatalog` service from `iceberg-js` catalog options. */\nexport const make = (options: IcebergRestCatalogOptions): Service => {\n const catalog = new IcebergRestCatalog(options);\n\n function loadTable(id: TableIdentifier): Effect.Effect<TableMetadata, IcebergError>;\n function loadTable(\n id: TableIdentifier,\n loadOptions: LoadTableOptions,\n ): Effect.Effect<TableMetadata | null, IcebergError>;\n function loadTable(id: TableIdentifier, loadOptions?: LoadTableOptions) {\n return tryCatalog(() =>\n loadOptions === undefined ? catalog.loadTable(id) : catalog.loadTable(id, loadOptions),\n );\n }\n\n return IcebergCatalog.of({\n getCatalogClient: () => catalog,\n loadConfig: () => tryCatalog(() => catalog.loadConfig()),\n\n listNamespaces: (listOptions) => tryCatalog(() => catalog.listNamespaces(listOptions)),\n createNamespace: (id, metadata) => tryCatalog(() => catalog.createNamespace(id, metadata)),\n dropNamespace: (id) => tryCatalog(() => catalog.dropNamespace(id)),\n loadNamespaceMetadata: (id) => tryCatalog(() => catalog.loadNamespaceMetadata(id)),\n updateNamespaceProperties: (id, request) =>\n tryCatalog(() => catalog.updateNamespaceProperties(id, request)),\n\n listTables: (namespace, listOptions) =>\n tryCatalog(() => catalog.listTables(namespace, listOptions)),\n createTable: (namespace, request) => tryCatalog(() => catalog.createTable(namespace, request)),\n createTableResult: (namespace, request) =>\n tryCatalog(() => catalog.createTableResult(namespace, request)),\n updateTable: (id, request) => tryCatalog(() => catalog.updateTable(id, request)),\n commitTable: (id, request) => tryCatalog(() => catalog.commitTable(id, request)),\n dropTable: (id, dropOptions) => tryCatalog(() => catalog.dropTable(id, dropOptions)),\n loadTable,\n loadTableResult: (id, loadOptions) =>\n tryCatalog(() => catalog.loadTableResult(id, loadOptions)),\n namespaceExists: (id) => tryCatalog(() => catalog.namespaceExists(id)),\n tableExists: (id) => tryCatalog(() => catalog.tableExists(id)),\n createNamespaceIfNotExists: (id, metadata) =>\n tryCatalog(() => catalog.createNamespaceIfNotExists(id, metadata)),\n createTableIfNotExists: (namespace, request) =>\n tryCatalog(() => catalog.createTableIfNotExists(namespace, request)),\n registerTable: (namespace, request) =>\n tryCatalog(() => catalog.registerTable(namespace, request)),\n registerTableResult: (namespace, request) =>\n tryCatalog(() => catalog.registerTableResult(namespace, request)),\n renameTable: (request) => tryCatalog(() => catalog.renameTable(request)),\n });\n};\n\nconst service = Effect.service(IcebergCatalog);\n\nexport const getCatalogClient: Effect.Effect<IcebergRestCatalog, never, IcebergCatalog> =\n Effect.map(service, (catalog) => catalog.getCatalogClient());\n\nexport const loadConfig: Effect.Effect<CatalogConfig, IcebergError, IcebergCatalog> =\n Effect.flatMap(service, (catalog) => catalog.loadConfig());\n\nexport const listNamespaces = (\n options?: ListNamespacesOptions,\n): Effect.Effect<ListNamespacesResult, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.listNamespaces(options));\n\nexport const createNamespace = (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n): Effect.Effect<CreateNamespaceResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createNamespace(id, metadata));\n\nexport const dropNamespace = (\n id: NamespaceIdentifier,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.dropNamespace(id));\n\nexport const loadNamespaceMetadata = (\n id: NamespaceIdentifier,\n): Effect.Effect<NamespaceMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.loadNamespaceMetadata(id));\n\nexport const updateNamespaceProperties = (\n id: NamespaceIdentifier,\n request: UpdateNamespacePropertiesRequest,\n): Effect.Effect<UpdateNamespacePropertiesResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.updateNamespaceProperties(id, request));\n\nexport const listTables = (\n namespace: NamespaceIdentifier,\n options?: ListTablesOptions,\n): Effect.Effect<ListTablesResult, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.listTables(namespace, options));\n\nexport const createTable = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTable(namespace, request));\n\nexport const createTableResult = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<LoadTableResultWithEtag, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTableResult(namespace, request));\n\nexport const updateTable = (\n id: TableIdentifier,\n request: UpdateTableRequest,\n): Effect.Effect<CommitTableResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.updateTable(id, request));\n\nexport const commitTable = (\n id: TableIdentifier,\n request: CommitTableRequest,\n): Effect.Effect<CommitTableResponse, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.commitTable(id, request));\n\nexport const dropTable = (\n id: TableIdentifier,\n options?: DropTableRequest,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.dropTable(id, options));\n\nexport function loadTable(\n id: TableIdentifier,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog>;\nexport function loadTable(\n id: TableIdentifier,\n options: LoadTableOptions,\n): Effect.Effect<TableMetadata | null, IcebergError, IcebergCatalog>;\nexport function loadTable(id: TableIdentifier, options?: LoadTableOptions) {\n return Effect.flatMap(service, (catalog) =>\n options === undefined ? catalog.loadTable(id) : catalog.loadTable(id, options),\n );\n}\n\nexport const loadTableResult = (\n id: TableIdentifier,\n options?: LoadTableOptions,\n): Effect.Effect<LoadTableResultWithEtag | null, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.loadTableResult(id, options));\n\nexport const namespaceExists = (\n id: NamespaceIdentifier,\n): Effect.Effect<boolean, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.namespaceExists(id));\n\nexport const tableExists = (\n id: TableIdentifier,\n): Effect.Effect<boolean, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.tableExists(id));\n\nexport const createNamespaceIfNotExists = (\n id: NamespaceIdentifier,\n metadata?: NamespaceMetadata,\n): Effect.Effect<CreateNamespaceResponse | void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createNamespaceIfNotExists(id, metadata));\n\nexport const createTableIfNotExists = (\n namespace: NamespaceIdentifier,\n request: CreateTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.createTableIfNotExists(namespace, request));\n\nexport const registerTable = (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n): Effect.Effect<TableMetadata, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.registerTable(namespace, request));\n\nexport const registerTableResult = (\n namespace: NamespaceIdentifier,\n request: RegisterTableRequest,\n): Effect.Effect<LoadTableResultWithEtag, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.registerTableResult(namespace, request));\n\nexport const renameTable = (\n request: RenameTableRequest,\n): Effect.Effect<void, IcebergError, IcebergCatalog> =>\n Effect.flatMap(service, (catalog) => catalog.renameTable(request));\n\n/** Creates an `IcebergCatalog` layer from concrete `iceberg-js` catalog options. */\nexport const layer = (options: IcebergRestCatalogOptions): Layer.Layer<IcebergCatalog> =>\n Layer.succeed(IcebergCatalog)(make(options));\n\n/** Creates an `IcebergCatalog` layer from Effect `Config` values. */\nexport const layerConfig = (\n config: Config.Wrap<IcebergRestCatalogOptions>,\n): Layer.Layer<IcebergCatalog, Config.ConfigError> =>\n Layer.effect(\n IcebergCatalog,\n Effect.gen(function* () {\n const options = yield* Config.unwrap(config);\n return make(options);\n }),\n );\n"],"mappings":";;;;;;;;;;AAIA,IAAaA,iBAAb,cAAkC,KAAK,YAAY,eAAe,CAQ/D;;AAGH,MAAa,mBAAmB,UAAiC;AAC/D,KAAI,iBAAiBC,aACnB,QAAO,IAAID,eAAa;EACtB,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,aAAa,MAAM;EACnB,aAAa,MAAM;EACnB,SAAS,MAAM;EACf,sBAAsB,MAAM;EAC5B,OAAO;EACR,CAAC;AAGJ,QAAO,IAAIA,eAAa;EACtB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;EAC/D,OAAO;EACR,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC6IJ,IAAa,iBAAb,cAAoC,QAAQ,SAAkC,CAC5E,4CACD,CAAC;AAEF,MAAM,cAAiB,aACrB,OAAO,WAAW;CAChB,KAAK;CACL,OAAO;CACR,CAAC;;AAGJ,MAAa,QAAQ,YAAgD;CACnE,MAAM,UAAU,IAAI,mBAAmB,QAAQ;CAO/C,SAASE,YAAU,IAAqB,aAAgC;AACtE,SAAO,iBACL,gBAAgB,SAAY,QAAQ,UAAU,GAAG,GAAG,QAAQ,UAAU,IAAI,YAAY,CACvF;;AAGH,QAAO,eAAe,GAAG;EACvB,wBAAwB;EACxB,kBAAkB,iBAAiB,QAA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