@malloy-publisher/server 0.0.235 → 0.0.237

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.
Files changed (319) hide show
  1. package/dist/app/api-doc.yaml +83 -27
  2. package/dist/app/assets/{EnvironmentPage-BsAnavYN.js → EnvironmentPage-DaP6CpgK.js} +1 -1
  3. package/dist/app/assets/{HomePage-CADE138j.js → HomePage-C9yNw3iu.js} +1 -1
  4. package/dist/app/assets/{LightMode-Cfh7KzN8.js → LightMode-Be4-G-dX.js} +1 -1
  5. package/dist/app/assets/{MainPage-CO3pRlnV.js → MainPage-J_rU2SgI.js} +2 -2
  6. package/dist/app/assets/{MaterializationsPage-p9YjkRXZ.js → MaterializationsPage-DHgPI4MO.js} +1 -1
  7. package/dist/app/assets/ModelPage-BzXfjTu5.js +1 -0
  8. package/dist/app/assets/{PackagePage-e4kN75YR.js → PackagePage-ByoSTLJ4.js} +1 -1
  9. package/dist/app/assets/RouteError-CrSeKN2r.js +1 -0
  10. package/dist/app/assets/{ThemeEditorPage-CciagFTq.js → ThemeEditorPage-Btxnmhtk.js} +1 -1
  11. package/dist/app/assets/{WorkbookPage-DNWmkCXa.js → WorkbookPage-D6JLPnWO.js} +1 -1
  12. package/dist/app/assets/{core-Rj_4rRnA.es-BZyvITuO.js → core-BSRgt1mG.es-Bc_D2Lq4.js} +1 -1
  13. package/dist/app/assets/{index-CH2AcDzc.js → index-BRijWj6K.js} +15 -15
  14. package/dist/app/assets/{index-DQa463gC.js → index-BX4D94xw.js} +1 -1
  15. package/dist/app/assets/{index-VBbcc8s6.js → index-Cvy0xtb7.js} +1 -1
  16. package/dist/app/assets/{index-DQpV7MyA.js → index-DMAhIJNC.js} +1 -1
  17. package/dist/app/index.html +1 -1
  18. package/dist/package_load_worker.mjs +59 -20
  19. package/dist/server.mjs +1342 -616
  20. package/package.json +8 -2
  21. package/.eslintrc.json +0 -44
  22. package/.prettierignore +0 -1
  23. package/.prettierrc +0 -4
  24. package/build.ts +0 -97
  25. package/dist/app/assets/ModelPage-C1OSTv-x.js +0 -1
  26. package/dist/app/assets/RouteError-CzbfOkng.js +0 -1
  27. package/eslint.config.mjs +0 -76
  28. package/k6-tests/README.md +0 -144
  29. package/k6-tests/bun.lock +0 -797
  30. package/k6-tests/load-test/load-test-crud-connections.ts +0 -263
  31. package/k6-tests/load-test/load-test-crud-packages.ts +0 -461
  32. package/k6-tests/load-test/load-test-crud-projects.ts +0 -160
  33. package/k6-tests/load-test/load-test-crud.ts +0 -142
  34. package/k6-tests/load-test/load-test.ts +0 -784
  35. package/k6-tests/package.json +0 -27
  36. package/k6-tests/scripts/run-with-otel.sh +0 -50
  37. package/k6-tests/smoke-test/smoke-test.ts +0 -158
  38. package/k6-tests/tsconfig.json +0 -29
  39. package/k6-tests/utils/client_factory.ts +0 -128
  40. package/k6-tests/utils/common.ts +0 -489
  41. package/k6-tests/utils/logger.ts +0 -62
  42. package/k6-tests/utils/types.d.ts +0 -35
  43. package/malloy_mcp.dxt +0 -0
  44. package/publisher.config.example.bigquery.json +0 -33
  45. package/publisher.config.example.duckdb.json +0 -23
  46. package/publisher.config.json +0 -23
  47. package/scripts/bake-duckdb-extensions.js +0 -110
  48. package/src/config.spec.ts +0 -1535
  49. package/src/config.theme.spec.ts +0 -178
  50. package/src/config.ts +0 -1142
  51. package/src/constants.ts +0 -105
  52. package/src/controller/compile.controller.ts +0 -40
  53. package/src/controller/connection.controller.spec.ts +0 -849
  54. package/src/controller/connection.controller.ts +0 -901
  55. package/src/controller/database.controller.ts +0 -24
  56. package/src/controller/materialization.controller.spec.ts +0 -293
  57. package/src/controller/materialization.controller.ts +0 -319
  58. package/src/controller/model.controller.ts +0 -164
  59. package/src/controller/package.controller.spec.ts +0 -273
  60. package/src/controller/package.controller.ts +0 -306
  61. package/src/controller/query.controller.ts +0 -152
  62. package/src/controller/theme.controller.ts +0 -83
  63. package/src/controller/watch-mode.controller.ts +0 -243
  64. package/src/data_styles.ts +0 -71
  65. package/src/default-publisher.config.json +0 -23
  66. package/src/ducklake_version.spec.ts +0 -163
  67. package/src/ducklake_version.ts +0 -153
  68. package/src/errors.spec.ts +0 -119
  69. package/src/errors.ts +0 -237
  70. package/src/filter_deprecation.spec.ts +0 -64
  71. package/src/filter_deprecation.ts +0 -42
  72. package/src/health.spec.ts +0 -123
  73. package/src/health.ts +0 -233
  74. package/src/heap_check.spec.ts +0 -144
  75. package/src/heap_check.ts +0 -144
  76. package/src/instrumentation.ts +0 -214
  77. package/src/json_utils.spec.ts +0 -51
  78. package/src/json_utils.ts +0 -33
  79. package/src/logger.spec.ts +0 -210
  80. package/src/logger.ts +0 -251
  81. package/src/malloy_pin_prereqs.spec.ts +0 -25
  82. package/src/materialization_metrics.spec.ts +0 -169
  83. package/src/materialization_metrics.ts +0 -346
  84. package/src/mcp/error_messages.spec.ts +0 -35
  85. package/src/mcp/error_messages.ts +0 -183
  86. package/src/mcp/handler_utils.spec.ts +0 -108
  87. package/src/mcp/handler_utils.ts +0 -251
  88. package/src/mcp/mcp_constants.ts +0 -6
  89. package/src/mcp/query_envelope.spec.ts +0 -229
  90. package/src/mcp/query_envelope.ts +0 -240
  91. package/src/mcp/server.protocol.spec.ts +0 -250
  92. package/src/mcp/server.ts +0 -87
  93. package/src/mcp/skills/build_skills_bundle.spec.ts +0 -51
  94. package/src/mcp/skills/build_skills_bundle.ts +0 -176
  95. package/src/mcp/skills/skills_bundle.json +0 -1
  96. package/src/mcp/skills/skills_bundle.spec.ts +0 -171
  97. package/src/mcp/tool_response.spec.ts +0 -108
  98. package/src/mcp/tool_response.ts +0 -138
  99. package/src/mcp/tools/compile_tool.spec.ts +0 -315
  100. package/src/mcp/tools/compile_tool.ts +0 -208
  101. package/src/mcp/tools/docs_search/build_docs_index.ts +0 -132
  102. package/src/mcp/tools/docs_search/malloy_docs_index.json +0 -1
  103. package/src/mcp/tools/docs_search_tool.spec.ts +0 -32
  104. package/src/mcp/tools/docs_search_tool.ts +0 -128
  105. package/src/mcp/tools/embedding_index.spec.ts +0 -1236
  106. package/src/mcp/tools/embedding_index.ts +0 -808
  107. package/src/mcp/tools/execute_query_tool.spec.ts +0 -294
  108. package/src/mcp/tools/execute_query_tool.ts +0 -316
  109. package/src/mcp/tools/get_context_eval.ts +0 -275
  110. package/src/mcp/tools/get_context_tool.spec.ts +0 -592
  111. package/src/mcp/tools/get_context_tool.ts +0 -585
  112. package/src/mcp/tools/reload_package_tool.spec.ts +0 -232
  113. package/src/mcp/tools/reload_package_tool.ts +0 -132
  114. package/src/mcp_config.spec.ts +0 -919
  115. package/src/mcp_config.ts +0 -425
  116. package/src/oom_guards.integration.spec.ts +0 -269
  117. package/src/package_load/package_load_pool.spec.ts +0 -252
  118. package/src/package_load/package_load_pool.ts +0 -931
  119. package/src/package_load/package_load_worker.ts +0 -1034
  120. package/src/package_load/protocol.ts +0 -364
  121. package/src/package_load/rpc_wait_accountant.spec.ts +0 -109
  122. package/src/package_load/rpc_wait_accountant.ts +0 -76
  123. package/src/package_load_metrics.spec.ts +0 -114
  124. package/src/package_load_metrics.ts +0 -127
  125. package/src/path_safety.spec.ts +0 -158
  126. package/src/path_safety.ts +0 -146
  127. package/src/pg_helpers.spec.ts +0 -223
  128. package/src/pg_helpers.ts +0 -52
  129. package/src/query_cap_metrics.spec.ts +0 -89
  130. package/src/query_cap_metrics.ts +0 -116
  131. package/src/query_concurrency.spec.ts +0 -247
  132. package/src/query_concurrency.ts +0 -237
  133. package/src/query_metadata_metrics.ts +0 -49
  134. package/src/query_param_utils.ts +0 -29
  135. package/src/query_timeout.spec.ts +0 -224
  136. package/src/query_timeout.ts +0 -179
  137. package/src/runtime/publisher.js +0 -328
  138. package/src/server-old.ts +0 -988
  139. package/src/server.ts +0 -2059
  140. package/src/service/annotations.spec.ts +0 -118
  141. package/src/service/annotations.ts +0 -91
  142. package/src/service/authorize.spec.ts +0 -154
  143. package/src/service/authorize.ts +0 -498
  144. package/src/service/authorize_integration.spec.ts +0 -2041
  145. package/src/service/build_plan.spec.ts +0 -685
  146. package/src/service/build_plan.ts +0 -797
  147. package/src/service/compile_authorize.spec.ts +0 -85
  148. package/src/service/compile_fragment_techniques.spec.ts +0 -156
  149. package/src/service/connection.spec.ts +0 -2360
  150. package/src/service/connection.ts +0 -2187
  151. package/src/service/connection_config.spec.ts +0 -734
  152. package/src/service/connection_config.ts +0 -899
  153. package/src/service/connection_federation.spec.ts +0 -184
  154. package/src/service/connection_fingerprint.spec.ts +0 -102
  155. package/src/service/connection_service.spec.ts +0 -711
  156. package/src/service/connection_service.ts +0 -291
  157. package/src/service/cron_evaluator.spec.ts +0 -79
  158. package/src/service/cron_evaluator.ts +0 -105
  159. package/src/service/db_utils.spec.ts +0 -1085
  160. package/src/service/db_utils.ts +0 -1502
  161. package/src/service/duckdb_instance_isolation.spec.ts +0 -137
  162. package/src/service/ducklake_lazy_attach.spec.ts +0 -110
  163. package/src/service/embedding_provider.spec.ts +0 -329
  164. package/src/service/embedding_provider.ts +0 -236
  165. package/src/service/environment.ts +0 -2191
  166. package/src/service/environment_admission.spec.ts +0 -344
  167. package/src/service/environment_compile.spec.ts +0 -197
  168. package/src/service/environment_store.spec.ts +0 -2274
  169. package/src/service/environment_store.ts +0 -2434
  170. package/src/service/environment_store_anchoring.spec.ts +0 -107
  171. package/src/service/environment_store_clone.spec.ts +0 -350
  172. package/src/service/explore_visibility.spec.ts +0 -434
  173. package/src/service/exports_probe.spec.ts +0 -107
  174. package/src/service/extension_fetch_policy.spec.ts +0 -256
  175. package/src/service/filter.spec.ts +0 -458
  176. package/src/service/filter.ts +0 -341
  177. package/src/service/filter_bypass.spec.ts +0 -418
  178. package/src/service/filter_integration.spec.ts +0 -1004
  179. package/src/service/freshness.spec.ts +0 -183
  180. package/src/service/freshness.ts +0 -112
  181. package/src/service/gcs_s3_utils.ts +0 -427
  182. package/src/service/given.ts +0 -105
  183. package/src/service/givens_integration.spec.ts +0 -219
  184. package/src/service/manifest_loader.spec.ts +0 -189
  185. package/src/service/manifest_loader.ts +0 -156
  186. package/src/service/materialization_build_session.spec.ts +0 -435
  187. package/src/service/materialization_build_session.ts +0 -681
  188. package/src/service/materialization_config_validation.spec.ts +0 -99
  189. package/src/service/materialization_config_validation.ts +0 -120
  190. package/src/service/materialization_eligibility.spec.ts +0 -158
  191. package/src/service/materialization_eligibility.ts +0 -305
  192. package/src/service/materialization_schedule_surface.spec.ts +0 -256
  193. package/src/service/materialization_scheduler.spec.ts +0 -289
  194. package/src/service/materialization_scheduler.ts +0 -304
  195. package/src/service/materialization_serve_transform.spec.ts +0 -1003
  196. package/src/service/materialization_serve_transform.ts +0 -779
  197. package/src/service/materialization_service.spec.ts +0 -2373
  198. package/src/service/materialization_service.ts +0 -2342
  199. package/src/service/materialization_test_fixtures.ts +0 -249
  200. package/src/service/model.spec.ts +0 -1157
  201. package/src/service/model.ts +0 -3370
  202. package/src/service/model_limits.spec.ts +0 -209
  203. package/src/service/model_limits.ts +0 -131
  204. package/src/service/model_storage_serve.spec.ts +0 -193
  205. package/src/service/model_storage_serve_joins.spec.ts +0 -193
  206. package/src/service/package.spec.ts +0 -612
  207. package/src/service/package.ts +0 -1799
  208. package/src/service/package_manifest.spec.ts +0 -230
  209. package/src/service/package_manifest.ts +0 -241
  210. package/src/service/package_memory_governor.spec.ts +0 -173
  211. package/src/service/package_memory_governor.ts +0 -233
  212. package/src/service/package_quote_bound_tables.spec.ts +0 -171
  213. package/src/service/package_race.spec.ts +0 -208
  214. package/src/service/package_reload_safety.spec.ts +0 -193
  215. package/src/service/package_rollback.spec.ts +0 -190
  216. package/src/service/package_worker_path.spec.ts +0 -645
  217. package/src/service/path_injection.spec.ts +0 -39
  218. package/src/service/persist_annotation_validation.spec.ts +0 -89
  219. package/src/service/persist_annotation_validation.ts +0 -59
  220. package/src/service/persistence_policy.spec.ts +0 -374
  221. package/src/service/proxy.spec.ts +0 -414
  222. package/src/service/proxy.ts +0 -248
  223. package/src/service/query_boundary.spec.ts +0 -470
  224. package/src/service/query_metadata.spec.ts +0 -408
  225. package/src/service/query_metadata.ts +0 -492
  226. package/src/service/query_metadata_identity.spec.ts +0 -149
  227. package/src/service/query_text.spec.ts +0 -79
  228. package/src/service/query_text.ts +0 -43
  229. package/src/service/quoting.spec.ts +0 -135
  230. package/src/service/quoting.ts +0 -78
  231. package/src/service/resolve_environment.ts +0 -15
  232. package/src/service/restricted_mode.spec.ts +0 -299
  233. package/src/service/source_extraction.ts +0 -225
  234. package/src/service/theme_store.ts +0 -199
  235. package/src/storage/DatabaseInterface.ts +0 -198
  236. package/src/storage/StorageManager.ts +0 -113
  237. package/src/storage/duckdb/ConnectionRepository.ts +0 -143
  238. package/src/storage/duckdb/DuckDBConnection.ts +0 -123
  239. package/src/storage/duckdb/DuckDBRepository.ts +0 -208
  240. package/src/storage/duckdb/EnvironmentRepository.ts +0 -148
  241. package/src/storage/duckdb/MaterializationRepository.spec.ts +0 -191
  242. package/src/storage/duckdb/MaterializationRepository.ts +0 -336
  243. package/src/storage/duckdb/PackageRepository.ts +0 -135
  244. package/src/storage/duckdb/schema.ts +0 -229
  245. package/src/stream_helpers.spec.ts +0 -280
  246. package/src/stream_helpers.ts +0 -162
  247. package/src/telemetry.ts +0 -20
  248. package/src/test_helpers/metrics_harness.ts +0 -166
  249. package/src/theme_key_parity.spec.ts +0 -57
  250. package/src/utils.ts +0 -29
  251. package/tests/fixtures/authorize-compile/model.malloy +0 -9
  252. package/tests/fixtures/authorize-compile/publisher.json +0 -4
  253. package/tests/fixtures/html-pages-nopublic/model.malloy +0 -1
  254. package/tests/fixtures/html-pages-nopublic/publisher.json +0 -5
  255. package/tests/fixtures/html-pages-test/data.csv +0 -3
  256. package/tests/fixtures/html-pages-test/public/assets/app.css +0 -3
  257. package/tests/fixtures/html-pages-test/public/barehtml.html +0 -4
  258. package/tests/fixtures/html-pages-test/public/bodymeta.html +0 -8
  259. package/tests/fixtures/html-pages-test/public/data.json +0 -1
  260. package/tests/fixtures/html-pages-test/public/fitcomment.html +0 -11
  261. package/tests/fixtures/html-pages-test/public/index.html +0 -9
  262. package/tests/fixtures/html-pages-test/public/nohead.html +0 -8
  263. package/tests/fixtures/html-pages-test/public/notfit.html +0 -13
  264. package/tests/fixtures/html-pages-test/public/slides.html +0 -12
  265. package/tests/fixtures/html-pages-test/public/sub/page2.html +0 -9
  266. package/tests/fixtures/html-pages-test/public/unterminated.html +0 -10
  267. package/tests/fixtures/html-pages-test/publisher.json +0 -5
  268. package/tests/fixtures/html-pages-test/report.malloy +0 -1
  269. package/tests/fixtures/persist-multi-level/data/orders.csv +0 -5
  270. package/tests/fixtures/persist-multi-level/multi_level.malloy +0 -18
  271. package/tests/fixtures/persist-multi-level/publisher.json +0 -5
  272. package/tests/fixtures/persist-schedule-test/data/orders.csv +0 -5
  273. package/tests/fixtures/persist-schedule-test/persist_schedule_test.malloy +0 -11
  274. package/tests/fixtures/persist-schedule-test/publisher.json +0 -7
  275. package/tests/fixtures/persist-schedule-warn-test/data/orders.csv +0 -5
  276. package/tests/fixtures/persist-schedule-warn-test/persist_warn_test.malloy +0 -11
  277. package/tests/fixtures/persist-schedule-warn-test/publisher.json +0 -6
  278. package/tests/fixtures/persist-test/data/orders.csv +0 -5
  279. package/tests/fixtures/persist-test/persist_test.malloy +0 -11
  280. package/tests/fixtures/persist-test/publisher.json +0 -5
  281. package/tests/fixtures/publisher.config.json +0 -15
  282. package/tests/fixtures/query-givens/data/orders.csv +0 -7
  283. package/tests/fixtures/query-givens/model.malloy +0 -34
  284. package/tests/fixtures/query-givens/publisher.json +0 -5
  285. package/tests/fixtures/xlsx/database.xlsx +0 -0
  286. package/tests/harness/mcp_test_setup.ts +0 -332
  287. package/tests/harness/rest_e2e.ts +0 -68
  288. package/tests/integration/authorize/compile_authorize_http.integration.spec.ts +0 -92
  289. package/tests/integration/concurrent_package/concurrent_package.integration.spec.ts +0 -280
  290. package/tests/integration/duckdb_storage/duckdb_storage.integration.spec.ts +0 -138
  291. package/tests/integration/first_boot/readiness_line.integration.spec.ts +0 -177
  292. package/tests/integration/html_pages/html_pages.integration.spec.ts +0 -440
  293. package/tests/integration/legacy_routes/legacy_routes.integration.spec.ts +0 -259
  294. package/tests/integration/materialization/environment_list.integration.spec.ts +0 -133
  295. package/tests/integration/materialization/freshness_gate.integration.spec.ts +0 -292
  296. package/tests/integration/materialization/manifest_binding.integration.spec.ts +0 -430
  297. package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +0 -441
  298. package/tests/integration/materialization/orchestrated_rebind.integration.spec.ts +0 -150
  299. package/tests/integration/materialization/reference_manifest.integration.spec.ts +0 -251
  300. package/tests/integration/materialization/schedule_edit.integration.spec.ts +0 -126
  301. package/tests/integration/materialization/scheduler.integration.spec.ts +0 -200
  302. package/tests/integration/materialization/scheduler_recovery.integration.spec.ts +0 -172
  303. package/tests/integration/materialization/scheduler_transitions.integration.spec.ts +0 -256
  304. package/tests/integration/materialization/scheduler_wiring.integration.spec.ts +0 -143
  305. package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +0 -438
  306. package/tests/integration/mcp/mcp_get_context_semantic.integration.spec.ts +0 -235
  307. package/tests/integration/mcp/mcp_transport.integration.spec.ts +0 -98
  308. package/tests/integration/query_givens/query_givens.integration.spec.ts +0 -146
  309. package/tests/integration/query_givens/query_givens_authorize.integration.spec.ts +0 -121
  310. package/tests/integration/sdk_givens/sdk_givens.integration.spec.ts +0 -110
  311. package/tests/integration/watch-mode/watch_mode.integration.spec.ts +0 -421
  312. package/tests/unit/controller/theme.controller.spec.ts +0 -141
  313. package/tests/unit/duckdb/attached_databases.test.ts +0 -1243
  314. package/tests/unit/duckdb/duckdb_connection.test.ts +0 -181
  315. package/tests/unit/duckdb/legacy_schema_migration.test.ts +0 -197
  316. package/tests/unit/duckdb/repositories.test.ts +0 -208
  317. package/tests/unit/ducklake/ducklake.test.ts +0 -952
  318. package/tests/unit/service/theme_store.spec.ts +0 -139
  319. package/tsconfig.json +0 -32
@@ -1,952 +0,0 @@
1
- import { DuckDBConnection } from "@malloydata/db-duckdb";
2
- import { afterEach, beforeEach, describe, expect, it } from "bun:test";
3
- import fs from "fs/promises";
4
- import path from "path";
5
- import { components } from "../../../src/api";
6
- import {
7
- createEnvironmentConnections,
8
- deleteDuckLakeConnectionFile,
9
- testConnectionConfig,
10
- } from "../../../src/service/connection";
11
- import {
12
- getSchemasForConnection,
13
- listTablesForSchema,
14
- } from "../../../src/service/db_utils";
15
-
16
- type ApiConnection = components["schemas"]["Connection"];
17
-
18
- const hasPostgresCredentials = () =>
19
- !!(
20
- process.env.POSTGRES_TEST_HOST &&
21
- process.env.POSTGRES_TEST_USER &&
22
- process.env.POSTGRES_TEST_PASSWORD
23
- );
24
-
25
- const hasS3Credentials = () =>
26
- !!(
27
- process.env.S3_TEST_ACCESS_KEY_ID && process.env.S3_TEST_SECRET_ACCESS_KEY
28
- );
29
-
30
- const hasGCSCredentials = () =>
31
- !!(process.env.GCS_TEST_KEY_ID && process.env.GCS_TEST_SECRET);
32
-
33
- describe("DuckLake Connection Tests", () => {
34
- const testProjectPath = path.join(process.cwd(), "test-project-ducklake");
35
- let createdConnections: DuckDBConnection[] = [];
36
-
37
- beforeEach(async () => {
38
- await fs.mkdir(testProjectPath, { recursive: true });
39
- });
40
-
41
- afterEach(async () => {
42
- // Close all connections
43
- for (const conn of createdConnections) {
44
- try {
45
- await conn.close();
46
- } catch (error) {
47
- console.warn("Error closing connection:", error);
48
- }
49
- }
50
- createdConnections = [];
51
-
52
- // Clean up DuckLake database files from testProjectPath
53
- try {
54
- const files = await fs.readdir(testProjectPath);
55
- for (const file of files) {
56
- if (file.endsWith("_ducklake.duckdb")) {
57
- await fs.rm(path.join(testProjectPath, file), { force: true });
58
- }
59
- }
60
- } catch (error) {
61
- // Ignore cleanup errors
62
- }
63
-
64
- // Clean up DuckLake database files from process.cwd() (created by testConnectionConfig)
65
- // testConnectionConfig creates files in process.cwd() instead of testProjectPath
66
- try {
67
- const cwdFiles = await fs.readdir(process.cwd());
68
- for (const file of cwdFiles) {
69
- if (file.endsWith("_ducklake.duckdb")) {
70
- const filePath = path.join(process.cwd(), file);
71
- // Only delete test files, not production files
72
- if (file.includes("_test") || file.includes("invalid")) {
73
- await fs.rm(filePath, { force: true });
74
- }
75
- }
76
- }
77
- } catch (_error) {
78
- // Ignore cleanup errors (file might not exist or already deleted)
79
- }
80
-
81
- // Clean up test directory
82
- const maxRetries = 5;
83
- const delay = 100;
84
- let lastError: unknown;
85
-
86
- for (let attempt = 0; attempt < maxRetries; attempt++) {
87
- try {
88
- await fs.rm(testProjectPath, { recursive: true, force: true });
89
- return;
90
- } catch (error) {
91
- lastError = error;
92
- const errnoError = error as NodeJS.ErrnoException;
93
- if (errnoError.code !== "EBUSY") throw error;
94
- if (attempt < maxRetries - 1) {
95
- await new Promise((resolve) =>
96
- setTimeout(resolve, delay * Math.pow(2, attempt)),
97
- );
98
- }
99
- }
100
- }
101
-
102
- if ((lastError as NodeJS.ErrnoError).code !== "EBUSY") {
103
- throw lastError;
104
- }
105
- });
106
-
107
- describe("Connection Creation", () => {
108
- it(
109
- "should create DuckLake connection with S3 storage",
110
- async () => {
111
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
112
- console.log(
113
- "Skipping: PostgreSQL and S3 credentials not configured",
114
- );
115
- return;
116
- }
117
-
118
- const ducklakeConnection: ApiConnection = {
119
- name: "ducklake_s3_test",
120
- type: "ducklake",
121
- ducklakeConnection: {
122
- catalog: {
123
- postgresConnection: {
124
- host: process.env.POSTGRES_TEST_HOST,
125
- port: parseInt(
126
- process.env.POSTGRES_TEST_PORT || "5432",
127
- ),
128
- userName: process.env.POSTGRES_TEST_USER!,
129
- password: process.env.POSTGRES_TEST_PASSWORD!,
130
- databaseName: process.env.POSTGRES_TEST_DATABASE,
131
- },
132
- },
133
- storage: {
134
- bucketUrl:
135
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
136
- s3Connection: {
137
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
138
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
139
- region: process.env.S3_TEST_REGION || "us-east-1",
140
- },
141
- },
142
- },
143
- };
144
-
145
- const { malloyConnections, apiConnections } =
146
- await createEnvironmentConnections(
147
- [ducklakeConnection],
148
- testProjectPath,
149
- );
150
-
151
- expect(malloyConnections.size).toBe(1);
152
- expect(apiConnections.length).toBe(1);
153
-
154
- const connection = malloyConnections.get(
155
- "ducklake_s3_test",
156
- ) as DuckDBConnection;
157
- expect(connection).toBeDefined();
158
- createdConnections.push(connection);
159
-
160
- // Verify DuckLake database is attached
161
- const databases = await connection.runSQL("SHOW DATABASES");
162
- const dbNames = databases.rows.map((row) => Object.values(row)[0]);
163
- expect(dbNames).toContain("ducklake_s3_test");
164
-
165
- // Verify database file was created
166
- const dbPath = path.join(
167
- testProjectPath,
168
- "ducklake_s3_test_ducklake.duckdb",
169
- );
170
- const exists = await fs
171
- .access(dbPath)
172
- .then(() => true)
173
- .catch(() => false);
174
- expect(exists).toBe(true);
175
- },
176
- { timeout: 30000 },
177
- );
178
-
179
- it(
180
- "should create DuckLake connection with GCS storage",
181
- async () => {
182
- if (!hasPostgresCredentials() || !hasGCSCredentials()) {
183
- console.log(
184
- "Skipping: PostgreSQL and GCS credentials not configured",
185
- );
186
- return;
187
- }
188
-
189
- const ducklakeConnection: ApiConnection = {
190
- name: "ducklake_gcs_test",
191
- type: "ducklake",
192
- ducklakeConnection: {
193
- catalog: {
194
- postgresConnection: {
195
- host: process.env.POSTGRES_TEST_HOST,
196
- port: parseInt(
197
- process.env.POSTGRES_TEST_PORT || "5432",
198
- ),
199
- userName: process.env.POSTGRES_TEST_USER!,
200
- password: process.env.POSTGRES_TEST_PASSWORD!,
201
- databaseName: process.env.POSTGRES_TEST_DATABASE,
202
- },
203
- },
204
- storage: {
205
- bucketUrl:
206
- process.env.GCS_TEST_BUCKET_URL || "gs://test-bucket",
207
- gcsConnection: {
208
- keyId: process.env.GCS_TEST_KEY_ID!,
209
- secret: process.env.GCS_TEST_SECRET!,
210
- },
211
- },
212
- },
213
- };
214
-
215
- const { malloyConnections } = await createEnvironmentConnections(
216
- [ducklakeConnection],
217
- testProjectPath,
218
- );
219
-
220
- const connection = malloyConnections.get(
221
- "ducklake_gcs_test",
222
- ) as DuckDBConnection;
223
- expect(connection).toBeDefined();
224
- createdConnections.push(connection);
225
-
226
- // Verify DuckLake database is attached
227
- const databases = await connection.runSQL("SHOW DATABASES");
228
- const dbNames = databases.rows.map((row) => Object.values(row)[0]);
229
- expect(dbNames).toContain("ducklake_gcs_test");
230
- },
231
- { timeout: 30000 },
232
- );
233
-
234
- it(
235
- "should load required extensions for DuckLake",
236
- async () => {
237
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
238
- console.log(
239
- "Skipping: PostgreSQL and S3 credentials not configured",
240
- );
241
- return;
242
- }
243
-
244
- const ducklakeConnection: ApiConnection = {
245
- name: "ducklake_extensions_test",
246
- type: "ducklake",
247
- ducklakeConnection: {
248
- catalog: {
249
- postgresConnection: {
250
- host: process.env.POSTGRES_TEST_HOST,
251
- port: parseInt(
252
- process.env.POSTGRES_TEST_PORT || "5432",
253
- ),
254
- userName: process.env.POSTGRES_TEST_USER!,
255
- password: process.env.POSTGRES_TEST_PASSWORD!,
256
- databaseName: process.env.POSTGRES_TEST_DATABASE,
257
- },
258
- },
259
- storage: {
260
- bucketUrl:
261
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
262
- s3Connection: {
263
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
264
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
265
- region: process.env.S3_TEST_REGION || "us-east-1",
266
- },
267
- },
268
- },
269
- };
270
-
271
- const { malloyConnections } = await createEnvironmentConnections(
272
- [ducklakeConnection],
273
- testProjectPath,
274
- );
275
-
276
- const connection = malloyConnections.get(
277
- "ducklake_extensions_test",
278
- ) as DuckDBConnection;
279
- createdConnections.push(connection);
280
-
281
- // Verify required extensions are loaded
282
- const extensions = await connection.runSQL(
283
- "SELECT extension_name FROM duckdb_extensions() WHERE loaded = true",
284
- );
285
- const extensionNames = extensions.rows.map(
286
- (row) => Object.values(row)[0] as string,
287
- );
288
-
289
- // DuckLake requires these extensions
290
- expect(extensionNames).toContain("ducklake");
291
- expect(extensionNames).toContain("postgres_scanner");
292
- expect(extensionNames).toContain("httpfs");
293
- },
294
- { timeout: 30000 },
295
- );
296
- });
297
-
298
- describe("Schema Operations", () => {
299
- it(
300
- "should list schemas from DuckLake connection",
301
- async () => {
302
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
303
- console.log(
304
- "Skipping: PostgreSQL and S3 credentials not configured",
305
- );
306
- return;
307
- }
308
-
309
- const ducklakeConnection: ApiConnection = {
310
- name: "ducklake_schemas_test",
311
- type: "ducklake",
312
- ducklakeConnection: {
313
- catalog: {
314
- postgresConnection: {
315
- host: process.env.POSTGRES_TEST_HOST,
316
- port: parseInt(
317
- process.env.POSTGRES_TEST_PORT || "5432",
318
- ),
319
- userName: process.env.POSTGRES_TEST_USER!,
320
- password: process.env.POSTGRES_TEST_PASSWORD!,
321
- databaseName: process.env.POSTGRES_TEST_DATABASE,
322
- },
323
- },
324
- storage: {
325
- bucketUrl:
326
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
327
- s3Connection: {
328
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
329
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
330
- region: process.env.S3_TEST_REGION || "us-east-1",
331
- },
332
- },
333
- },
334
- };
335
-
336
- const { malloyConnections } = await createEnvironmentConnections(
337
- [ducklakeConnection],
338
- testProjectPath,
339
- );
340
-
341
- const connection = malloyConnections.get(
342
- "ducklake_schemas_test",
343
- ) as DuckDBConnection;
344
- createdConnections.push(connection);
345
-
346
- // Test schema listing using db_utils
347
- const schemas = await getSchemasForConnection(
348
- ducklakeConnection,
349
- connection,
350
- );
351
- expect(schemas).toBeDefined();
352
- expect(Array.isArray(schemas)).toBe(true);
353
-
354
- // Also test direct SQL query
355
- const result = await connection.runSQL(
356
- `SELECT DISTINCT schema_name FROM information_schema.schemata WHERE catalog_name = 'ducklake_schemas_test' ORDER BY schema_name`,
357
- );
358
- expect(result.rows).toBeDefined();
359
- expect(result.rows.length).toBeGreaterThanOrEqual(0);
360
- },
361
- { timeout: 30000 },
362
- );
363
- });
364
-
365
- describe("Table Operations", () => {
366
- it(
367
- "should list tables from DuckLake schema",
368
- async () => {
369
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
370
- console.log(
371
- "Skipping: PostgreSQL and S3 credentials not configured",
372
- );
373
- return;
374
- }
375
-
376
- const ducklakeConnection: ApiConnection = {
377
- name: "ducklake_tables_test",
378
- type: "ducklake",
379
- ducklakeConnection: {
380
- catalog: {
381
- postgresConnection: {
382
- host: process.env.POSTGRES_TEST_HOST,
383
- port: parseInt(
384
- process.env.POSTGRES_TEST_PORT || "5432",
385
- ),
386
- userName: process.env.POSTGRES_TEST_USER!,
387
- password: process.env.POSTGRES_TEST_PASSWORD!,
388
- databaseName: process.env.POSTGRES_TEST_DATABASE,
389
- },
390
- },
391
- storage: {
392
- bucketUrl:
393
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
394
- s3Connection: {
395
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
396
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
397
- region: process.env.S3_TEST_REGION || "us-east-1",
398
- },
399
- },
400
- },
401
- };
402
-
403
- const { malloyConnections } = await createEnvironmentConnections(
404
- [ducklakeConnection],
405
- testProjectPath,
406
- );
407
-
408
- const connection = malloyConnections.get(
409
- "ducklake_tables_test",
410
- ) as DuckDBConnection;
411
- createdConnections.push(connection);
412
-
413
- // Get schemas first
414
- const schemas = await getSchemasForConnection(
415
- ducklakeConnection,
416
- connection,
417
- );
418
- if (schemas.length === 0) {
419
- console.log("No schemas found, skipping table listing test");
420
- return;
421
- }
422
-
423
- // Test table listing for first schema
424
- const schemaName = schemas[0].name!;
425
- const tables = await listTablesForSchema(
426
- ducklakeConnection,
427
- schemaName,
428
- connection,
429
- );
430
- expect(tables).toBeDefined();
431
- expect(Array.isArray(tables)).toBe(true);
432
- },
433
- { timeout: 30000 },
434
- );
435
-
436
- it(
437
- "should handle table path prefixing correctly",
438
- async () => {
439
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
440
- console.log(
441
- "Skipping: PostgreSQL and S3 credentials not configured",
442
- );
443
- return;
444
- }
445
-
446
- const ducklakeConnection: ApiConnection = {
447
- name: "ducklake_prefix_test",
448
- type: "ducklake",
449
- ducklakeConnection: {
450
- catalog: {
451
- postgresConnection: {
452
- host: process.env.POSTGRES_TEST_HOST,
453
- port: parseInt(
454
- process.env.POSTGRES_TEST_PORT || "5432",
455
- ),
456
- userName: process.env.POSTGRES_TEST_USER!,
457
- password: process.env.POSTGRES_TEST_PASSWORD!,
458
- databaseName: process.env.POSTGRES_TEST_DATABASE,
459
- },
460
- },
461
- storage: {
462
- bucketUrl:
463
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
464
- s3Connection: {
465
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
466
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
467
- region: process.env.S3_TEST_REGION || "us-east-1",
468
- },
469
- },
470
- },
471
- };
472
-
473
- const { malloyConnections } = await createEnvironmentConnections(
474
- [ducklakeConnection],
475
- testProjectPath,
476
- );
477
-
478
- const connection = malloyConnections.get(
479
- "ducklake_prefix_test",
480
- ) as DuckDBConnection;
481
- createdConnections.push(connection);
482
-
483
- // Test that connection name is used as catalog prefix
484
- // DuckLake tables should be accessible as connectionName.schemaName.tableName
485
- const result = await connection.runSQL(
486
- `SELECT catalog_name, schema_name FROM information_schema.schemata WHERE catalog_name = 'ducklake_prefix_test' LIMIT 1`,
487
- );
488
- expect(result.rows).toBeDefined();
489
- },
490
- { timeout: 30000 },
491
- );
492
- });
493
-
494
- describe("Query Operations", () => {
495
- it(
496
- "should execute queries against DuckLake database",
497
- async () => {
498
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
499
- console.log(
500
- "Skipping: PostgreSQL and S3 credentials not configured",
501
- );
502
- return;
503
- }
504
-
505
- const ducklakeConnection: ApiConnection = {
506
- name: "ducklake_query_test",
507
- type: "ducklake",
508
- ducklakeConnection: {
509
- catalog: {
510
- postgresConnection: {
511
- host: process.env.POSTGRES_TEST_HOST,
512
- port: parseInt(
513
- process.env.POSTGRES_TEST_PORT || "5432",
514
- ),
515
- userName: process.env.POSTGRES_TEST_USER!,
516
- password: process.env.POSTGRES_TEST_PASSWORD!,
517
- databaseName: process.env.POSTGRES_TEST_DATABASE,
518
- },
519
- },
520
- storage: {
521
- bucketUrl:
522
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
523
- s3Connection: {
524
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
525
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
526
- region: process.env.S3_TEST_REGION || "us-east-1",
527
- },
528
- },
529
- },
530
- };
531
-
532
- const { malloyConnections } = await createEnvironmentConnections(
533
- [ducklakeConnection],
534
- testProjectPath,
535
- );
536
-
537
- const connection = malloyConnections.get(
538
- "ducklake_query_test",
539
- ) as DuckDBConnection;
540
- createdConnections.push(connection);
541
-
542
- // Test basic query
543
- const result = await connection.runSQL(
544
- `SELECT schema_name FROM information_schema.schemata WHERE catalog_name = 'ducklake_query_test' LIMIT 1`,
545
- );
546
- expect(result.rows).toBeDefined();
547
- expect(Array.isArray(result.rows)).toBe(true);
548
- },
549
- { timeout: 30000 },
550
- );
551
- });
552
-
553
- describe("Error Handling", () => {
554
- it("should throw error if DuckLake catalog connection is missing", async () => {
555
- await expect(
556
- createEnvironmentConnections(
557
- [
558
- {
559
- name: "ducklake_no_catalog",
560
- type: "ducklake",
561
- ducklakeConnection: {
562
- storage: {
563
- bucketUrl: "s3://test-bucket",
564
- s3Connection: {
565
- accessKeyId: "test",
566
- secretAccessKey: "test",
567
- },
568
- },
569
- },
570
- } as ApiConnection,
571
- ],
572
- testProjectPath,
573
- ),
574
- ).rejects.toThrow(/PostgreSQL connection configuration is required/);
575
- });
576
-
577
- it("should throw error if DuckLake storage bucketUrl is missing", async () => {
578
- await expect(
579
- createEnvironmentConnections(
580
- [
581
- {
582
- name: "ducklake_no_bucket",
583
- type: "ducklake",
584
- ducklakeConnection: {
585
- catalog: {
586
- postgresConnection: {
587
- host: "localhost",
588
- port: 5432,
589
- userName: "test",
590
- password: "test",
591
- databaseName: "test",
592
- },
593
- },
594
- storage: {
595
- s3Connection: {
596
- accessKeyId: "test",
597
- secretAccessKey: "test",
598
- },
599
- },
600
- },
601
- } as ApiConnection,
602
- ],
603
- testProjectPath,
604
- ),
605
- ).rejects.toThrow(/Storage bucketUrl is required/);
606
- });
607
-
608
- it("should throw error if DuckLake connection config is missing", async () => {
609
- await expect(
610
- createEnvironmentConnections(
611
- [
612
- {
613
- name: "ducklake_missing_config",
614
- type: "ducklake",
615
- },
616
- ],
617
- testProjectPath,
618
- ),
619
- ).rejects.toThrow(/DuckLake connection configuration is missing/);
620
- });
621
-
622
- it("should handle already attached database gracefully", async () => {
623
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
624
- console.log(
625
- "Skipping: PostgreSQL and S3 credentials not configured",
626
- );
627
- return;
628
- }
629
-
630
- const ducklakeConnection: ApiConnection = {
631
- name: "ducklake_duplicate_test",
632
- type: "ducklake",
633
- ducklakeConnection: {
634
- catalog: {
635
- postgresConnection: {
636
- host: process.env.POSTGRES_TEST_HOST,
637
- port: parseInt(process.env.POSTGRES_TEST_PORT || "5432"),
638
- userName: process.env.POSTGRES_TEST_USER!,
639
- password: process.env.POSTGRES_TEST_PASSWORD!,
640
- databaseName: process.env.POSTGRES_TEST_DATABASE,
641
- },
642
- },
643
- storage: {
644
- bucketUrl:
645
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
646
- s3Connection: {
647
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
648
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
649
- region: process.env.S3_TEST_REGION || "us-east-1",
650
- },
651
- },
652
- },
653
- };
654
-
655
- // Create connection twice - second should handle already attached gracefully
656
- const { malloyConnections: conn1 } =
657
- await createEnvironmentConnections(
658
- [ducklakeConnection],
659
- testProjectPath,
660
- );
661
- const connection1 = conn1.get(
662
- "ducklake_duplicate_test",
663
- ) as DuckDBConnection;
664
- createdConnections.push(connection1);
665
-
666
- const { malloyConnections: conn2 } =
667
- await createEnvironmentConnections(
668
- [ducklakeConnection],
669
- testProjectPath,
670
- );
671
- const connection2 = conn2.get(
672
- "ducklake_duplicate_test",
673
- ) as DuckDBConnection;
674
- createdConnections.push(connection2);
675
-
676
- expect(connection1).toBeDefined();
677
- expect(connection2).toBeDefined();
678
- });
679
- });
680
-
681
- describe("Database File Management", () => {
682
- it(
683
- "should create database file with correct naming pattern",
684
- async () => {
685
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
686
- console.log(
687
- "Skipping: PostgreSQL and S3 credentials not configured",
688
- );
689
- return;
690
- }
691
-
692
- const ducklakeConnection: ApiConnection = {
693
- name: "ducklake_file_test",
694
- type: "ducklake",
695
- ducklakeConnection: {
696
- catalog: {
697
- postgresConnection: {
698
- host: process.env.POSTGRES_TEST_HOST,
699
- port: parseInt(
700
- process.env.POSTGRES_TEST_PORT || "5432",
701
- ),
702
- userName: process.env.POSTGRES_TEST_USER!,
703
- password: process.env.POSTGRES_TEST_PASSWORD!,
704
- databaseName: process.env.POSTGRES_TEST_DATABASE,
705
- },
706
- },
707
- storage: {
708
- bucketUrl:
709
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
710
- s3Connection: {
711
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
712
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
713
- region: process.env.S3_TEST_REGION || "us-east-1",
714
- },
715
- },
716
- },
717
- };
718
-
719
- const { malloyConnections } = await createEnvironmentConnections(
720
- [ducklakeConnection],
721
- testProjectPath,
722
- );
723
-
724
- const connection = malloyConnections.get(
725
- "ducklake_file_test",
726
- ) as DuckDBConnection;
727
- createdConnections.push(connection);
728
-
729
- // Verify database file follows naming pattern: {connectionName}_ducklake.duckdb
730
- const dbPath = path.join(
731
- testProjectPath,
732
- "ducklake_file_test_ducklake.duckdb",
733
- );
734
- const exists = await fs
735
- .access(dbPath)
736
- .then(() => true)
737
- .catch(() => false);
738
- expect(exists).toBe(true);
739
- },
740
- { timeout: 30000 },
741
- );
742
-
743
- it("should delete DuckLake connection file", async () => {
744
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
745
- console.log(
746
- "Skipping: PostgreSQL and S3 credentials not configured",
747
- );
748
- return;
749
- }
750
-
751
- const ducklakeConnection: ApiConnection = {
752
- name: "ducklake_delete_test",
753
- type: "ducklake",
754
- ducklakeConnection: {
755
- catalog: {
756
- postgresConnection: {
757
- host: process.env.POSTGRES_TEST_HOST,
758
- port: parseInt(process.env.POSTGRES_TEST_PORT || "5432"),
759
- userName: process.env.POSTGRES_TEST_USER!,
760
- password: process.env.POSTGRES_TEST_PASSWORD!,
761
- databaseName: process.env.POSTGRES_TEST_DATABASE,
762
- },
763
- },
764
- storage: {
765
- bucketUrl:
766
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
767
- s3Connection: {
768
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
769
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
770
- region: process.env.S3_TEST_REGION || "us-east-1",
771
- },
772
- },
773
- },
774
- };
775
-
776
- const { malloyConnections } = await createEnvironmentConnections(
777
- [ducklakeConnection],
778
- testProjectPath,
779
- );
780
-
781
- const connection = malloyConnections.get(
782
- "ducklake_delete_test",
783
- ) as DuckDBConnection;
784
- await connection.close();
785
- createdConnections = createdConnections.filter(
786
- (c) => c !== connection,
787
- );
788
-
789
- // Delete the file
790
- await deleteDuckLakeConnectionFile(
791
- "ducklake_delete_test",
792
- testProjectPath,
793
- );
794
-
795
- // Verify file is deleted
796
- const dbPath = path.join(
797
- testProjectPath,
798
- "ducklake_delete_test_ducklake.duckdb",
799
- );
800
- const exists = await fs
801
- .access(dbPath)
802
- .then(() => true)
803
- .catch(() => false);
804
- expect(exists).toBe(false);
805
- });
806
-
807
- it("should handle deletion of non-existent file gracefully", async () => {
808
- // Should not throw error if file doesn't exist
809
- // The function catches ENOENT errors internally, so this should complete without throwing
810
- await expect(
811
- deleteDuckLakeConnectionFile(
812
- "nonexistent_connection",
813
- testProjectPath,
814
- ),
815
- ).resolves.toBeUndefined();
816
- });
817
- });
818
-
819
- describe("Connection Testing", () => {
820
- it(
821
- "should test DuckLake connection configuration",
822
- async () => {
823
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
824
- console.log(
825
- "Skipping: PostgreSQL and S3 credentials not configured",
826
- );
827
- return;
828
- }
829
-
830
- const result = await testConnectionConfig({
831
- name: "ducklake_test_config",
832
- type: "ducklake",
833
- ducklakeConnection: {
834
- catalog: {
835
- postgresConnection: {
836
- host: process.env.POSTGRES_TEST_HOST,
837
- port: parseInt(
838
- process.env.POSTGRES_TEST_PORT || "5432",
839
- ),
840
- userName: process.env.POSTGRES_TEST_USER!,
841
- password: process.env.POSTGRES_TEST_PASSWORD!,
842
- databaseName: process.env.POSTGRES_TEST_DATABASE,
843
- },
844
- },
845
- storage: {
846
- bucketUrl:
847
- process.env.S3_TEST_BUCKET_URL || "s3://test-bucket",
848
- s3Connection: {
849
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
850
- secretAccessKey: process.env.S3_TEST_SECRET_ACCESS_KEY!,
851
- region: process.env.S3_TEST_REGION || "us-east-1",
852
- },
853
- },
854
- },
855
- });
856
-
857
- expect(result.status).toBe("ok");
858
- expect(result.errorMessage).toBe("");
859
- },
860
- { timeout: 30000 },
861
- );
862
-
863
- it(
864
- "should fail test for invalid DuckLake configuration",
865
- async () => {
866
- const result = await testConnectionConfig({
867
- name: "ducklake_invalid_test",
868
- type: "ducklake",
869
- ducklakeConnection: {
870
- catalog: {
871
- postgresConnection: {
872
- host: "invalid-host",
873
- port: 5432,
874
- userName: "invalid",
875
- password: "invalid",
876
- databaseName: "invalid",
877
- },
878
- },
879
- storage: {
880
- bucketUrl: "s3://invalid-bucket",
881
- s3Connection: {
882
- accessKeyId: "invalid",
883
- secretAccessKey: "invalid",
884
- },
885
- },
886
- },
887
- });
888
-
889
- expect(result.status).toBe("failed");
890
- expect(result.errorMessage).toBeDefined();
891
- expect(result.errorMessage.length).toBeGreaterThan(0);
892
- },
893
- { timeout: 30000 },
894
- );
895
- });
896
-
897
- describe("Connection Attributes", () => {
898
- it(
899
- "should return correct attributes for DuckLake connection",
900
- async () => {
901
- if (!hasPostgresCredentials() || !hasS3Credentials()) {
902
- console.log(
903
- "Skipping: PostgreSQL and S3 credentials not configured",
904
- );
905
- return;
906
- }
907
-
908
- const { apiConnections } = await createEnvironmentConnections(
909
- [
910
- {
911
- name: "ducklake_attrs_test",
912
- type: "ducklake",
913
- ducklakeConnection: {
914
- catalog: {
915
- postgresConnection: {
916
- host: process.env.POSTGRES_TEST_HOST,
917
- port: parseInt(
918
- process.env.POSTGRES_TEST_PORT || "5432",
919
- ),
920
- userName: process.env.POSTGRES_TEST_USER!,
921
- password: process.env.POSTGRES_TEST_PASSWORD!,
922
- databaseName: process.env.POSTGRES_TEST_DATABASE,
923
- },
924
- },
925
- storage: {
926
- bucketUrl:
927
- process.env.S3_TEST_BUCKET_URL ||
928
- "s3://test-bucket",
929
- s3Connection: {
930
- accessKeyId: process.env.S3_TEST_ACCESS_KEY_ID!,
931
- secretAccessKey:
932
- process.env.S3_TEST_SECRET_ACCESS_KEY!,
933
- region: process.env.S3_TEST_REGION || "us-east-1",
934
- },
935
- },
936
- },
937
- },
938
- ],
939
- testProjectPath,
940
- );
941
-
942
- const connection = apiConnections[0];
943
- expect(connection.attributes).toBeDefined();
944
- expect(connection.attributes?.dialectName).toBe("duckdb");
945
- expect(typeof connection.attributes?.canPersist).toBe("boolean");
946
- expect(typeof connection.attributes?.canStream).toBe("boolean");
947
- expect(typeof connection.attributes?.isPool).toBe("boolean");
948
- },
949
- { timeout: 30000 },
950
- );
951
- });
952
- });