@useatlas/create 0.0.2 → 0.0.3

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 (296) hide show
  1. package/README.md +4 -18
  2. package/index.ts +191 -31
  3. package/package.json +1 -1
  4. package/templates/docker/.env.example +3 -3
  5. package/templates/docker/Dockerfile.sidecar +28 -0
  6. package/templates/docker/bin/__tests__/plugin-cli.test.ts +9 -9
  7. package/templates/docker/bin/atlas.ts +108 -44
  8. package/templates/docker/data/demo-semantic/catalog.yml +51 -27
  9. package/templates/docker/data/demo-semantic/entities/accounts.yml +95 -103
  10. package/templates/docker/data/demo-semantic/entities/companies.yml +88 -152
  11. package/templates/docker/data/demo-semantic/entities/people.yml +82 -95
  12. package/templates/docker/data/demo-semantic/glossary.yml +104 -8
  13. package/templates/docker/data/demo-semantic/metrics/accounts.yml +62 -23
  14. package/templates/docker/data/demo-semantic/metrics/companies.yml +52 -78
  15. package/templates/docker/docker-compose.yml +1 -1
  16. package/templates/docker/docs/deploy.md +2 -39
  17. package/templates/docker/package.json +17 -1
  18. package/templates/docker/semantic/catalog.yml +62 -3
  19. package/templates/docker/semantic/entities/accounts.yml +162 -0
  20. package/templates/docker/semantic/entities/companies.yml +143 -0
  21. package/templates/docker/semantic/entities/people.yml +132 -0
  22. package/templates/docker/semantic/glossary.yml +116 -4
  23. package/templates/docker/semantic/metrics/accounts.yml +77 -0
  24. package/templates/docker/semantic/metrics/companies.yml +63 -0
  25. package/templates/docker/sidecar/Dockerfile +5 -6
  26. package/templates/docker/sidecar/railway.json +1 -2
  27. package/templates/docker/src/api/__tests__/admin.test.ts +7 -7
  28. package/templates/docker/src/api/__tests__/health-plugin.test.ts +7 -0
  29. package/templates/docker/src/api/__tests__/health.test.ts +30 -8
  30. package/templates/docker/src/api/routes/admin.ts +549 -8
  31. package/templates/docker/src/api/routes/chat.ts +5 -20
  32. package/templates/docker/src/api/routes/health.ts +39 -27
  33. package/templates/docker/src/api/routes/openapi.ts +1329 -74
  34. package/templates/docker/src/api/routes/query.ts +2 -1
  35. package/templates/docker/src/api/server.ts +27 -0
  36. package/templates/docker/src/app/api/[...route]/route.ts +2 -2
  37. package/templates/docker/src/app/globals.css +13 -12
  38. package/templates/docker/src/app/layout.tsx +9 -2
  39. package/templates/docker/src/components/ui/alert-dialog.tsx +196 -0
  40. package/templates/docker/src/components/ui/badge.tsx +48 -0
  41. package/templates/docker/src/components/ui/button.tsx +64 -0
  42. package/templates/docker/src/components/ui/card.tsx +92 -0
  43. package/templates/docker/src/components/ui/collapsible.tsx +33 -0
  44. package/templates/docker/src/components/ui/command.tsx +184 -0
  45. package/templates/docker/src/components/ui/dialog.tsx +158 -0
  46. package/templates/docker/src/components/ui/dropdown-menu.tsx +257 -0
  47. package/templates/docker/src/components/ui/input.tsx +21 -0
  48. package/templates/docker/src/components/ui/scroll-area.tsx +58 -0
  49. package/templates/docker/src/components/ui/select.tsx +190 -0
  50. package/templates/docker/src/components/ui/separator.tsx +28 -0
  51. package/templates/docker/src/components/ui/sheet.tsx +143 -0
  52. package/templates/docker/src/components/ui/sidebar.tsx +726 -0
  53. package/templates/docker/src/components/ui/skeleton.tsx +13 -0
  54. package/templates/docker/src/components/ui/table.tsx +116 -0
  55. package/templates/docker/src/components/ui/tabs.tsx +91 -0
  56. package/templates/docker/src/components/ui/toggle-group.tsx +83 -0
  57. package/templates/docker/src/components/ui/toggle.tsx +47 -0
  58. package/templates/docker/src/components/ui/tooltip.tsx +57 -0
  59. package/templates/docker/src/hooks/use-mobile.ts +19 -0
  60. package/templates/docker/src/lib/__tests__/agent-cache.test.ts +2 -0
  61. package/templates/docker/src/lib/__tests__/agent-dialect.test.ts +17 -0
  62. package/templates/docker/src/lib/__tests__/agent-health-annotations.test.ts +2 -0
  63. package/templates/docker/src/lib/__tests__/agent-integration.test.ts +2 -0
  64. package/templates/docker/src/lib/__tests__/config.test.ts +69 -19
  65. package/templates/docker/src/lib/__tests__/plugin-aware-validation.test.ts +321 -0
  66. package/templates/docker/src/lib/__tests__/providers.test.ts +32 -1
  67. package/templates/docker/src/lib/__tests__/startup-actions.test.ts +9 -0
  68. package/templates/docker/src/lib/__tests__/startup-first-run.test.ts +429 -0
  69. package/templates/docker/src/lib/__tests__/startup.test.ts +5 -0
  70. package/templates/docker/src/lib/agent-query.ts +5 -23
  71. package/templates/docker/src/lib/agent.ts +32 -112
  72. package/templates/docker/src/lib/auth/__tests__/migrate.test.ts +5 -3
  73. package/templates/docker/src/lib/auth/middleware.ts +30 -4
  74. package/templates/docker/src/lib/auth/migrate.ts +97 -0
  75. package/templates/docker/src/lib/auth/server.ts +12 -1
  76. package/templates/docker/src/lib/config.ts +37 -39
  77. package/templates/docker/src/lib/db/__tests__/connection.test.ts +89 -14
  78. package/templates/docker/src/lib/db/__tests__/registry-health.test.ts +1 -18
  79. package/templates/docker/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -19
  80. package/templates/docker/src/lib/db/__tests__/registry.test.ts +11 -208
  81. package/templates/docker/src/lib/db/connection.ts +87 -265
  82. package/templates/docker/src/lib/db/internal.ts +6 -1
  83. package/templates/docker/src/lib/plugins/__tests__/hooks-integration.test.ts +3 -1
  84. package/templates/docker/src/lib/plugins/__tests__/hooks.test.ts +2 -2
  85. package/templates/docker/src/lib/plugins/__tests__/migrate.test.ts +355 -1
  86. package/templates/docker/src/lib/plugins/__tests__/registry.test.ts +32 -5
  87. package/templates/docker/src/lib/plugins/__tests__/wiring.test.ts +228 -14
  88. package/templates/docker/src/lib/plugins/index.ts +4 -1
  89. package/templates/docker/src/lib/plugins/migrate.ts +103 -0
  90. package/templates/docker/src/lib/plugins/registry.ts +12 -6
  91. package/templates/docker/src/lib/plugins/wiring.ts +113 -4
  92. package/templates/docker/src/lib/providers.ts +6 -1
  93. package/templates/docker/src/lib/security.ts +24 -0
  94. package/templates/docker/src/lib/semantic.ts +2 -0
  95. package/templates/docker/src/lib/sidecar-types.ts +12 -1
  96. package/templates/docker/src/lib/startup.ts +71 -101
  97. package/templates/docker/src/lib/tools/__tests__/custom-validation.test.ts +2 -0
  98. package/templates/docker/src/lib/tools/__tests__/explore-nsjail.test.ts +32 -18
  99. package/templates/docker/src/lib/tools/__tests__/explore-plugin.test.ts +14 -14
  100. package/templates/docker/src/lib/tools/__tests__/explore-sidecar.test.ts +5 -3
  101. package/templates/docker/src/lib/tools/__tests__/python-nsjail.test.ts +515 -0
  102. package/templates/docker/src/lib/tools/__tests__/python-sandbox.test.ts +397 -0
  103. package/templates/docker/src/lib/tools/__tests__/python-sidecar.test.ts +365 -0
  104. package/templates/docker/src/lib/tools/__tests__/python.test.ts +331 -0
  105. package/templates/docker/src/lib/tools/__tests__/registry-actions.test.ts +1 -13
  106. package/templates/docker/src/lib/tools/__tests__/registry.test.ts +38 -31
  107. package/templates/docker/src/lib/tools/__tests__/sql-audit.test.ts +2 -0
  108. package/templates/docker/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +2 -0
  109. package/templates/docker/src/lib/tools/__tests__/sql-ratelimit.test.ts +2 -0
  110. package/templates/docker/src/lib/tools/__tests__/sql.test.ts +5 -308
  111. package/templates/docker/src/lib/tools/explore-nsjail.ts +17 -12
  112. package/templates/docker/src/lib/tools/explore-sidecar.ts +25 -0
  113. package/templates/docker/src/lib/tools/explore.ts +28 -32
  114. package/templates/docker/src/lib/tools/python-nsjail.ts +396 -0
  115. package/templates/docker/src/lib/tools/python-sandbox.ts +476 -0
  116. package/templates/docker/src/lib/tools/python-sidecar.ts +150 -0
  117. package/templates/docker/src/lib/tools/python.ts +367 -0
  118. package/templates/docker/src/lib/tools/registry.ts +49 -22
  119. package/templates/docker/src/lib/tools/sql.ts +88 -88
  120. package/templates/docker/src/types/vercel-sandbox.d.ts +7 -0
  121. package/templates/docker/src/ui/components/admin/admin-layout.tsx +77 -8
  122. package/templates/docker/src/ui/components/admin/admin-sidebar.tsx +25 -17
  123. package/templates/docker/src/ui/components/admin/change-password-dialog.tsx +128 -0
  124. package/templates/docker/src/ui/components/admin/entity-detail.tsx +3 -3
  125. package/templates/docker/src/ui/components/admin/semantic-file-tree.tsx +159 -0
  126. package/templates/docker/src/ui/components/atlas-chat.tsx +64 -12
  127. package/templates/docker/src/ui/components/chart/result-chart.tsx +25 -15
  128. package/templates/docker/src/ui/components/chat/markdown.tsx +88 -42
  129. package/templates/docker/src/ui/components/chat/python-result-card.tsx +244 -0
  130. package/templates/docker/src/ui/components/chat/sql-block.tsx +39 -15
  131. package/templates/docker/src/ui/components/chat/sql-result-card.tsx +6 -1
  132. package/templates/docker/src/ui/components/chat/tool-part.tsx +12 -3
  133. package/templates/docker/src/ui/components/chat/typing-indicator.tsx +5 -2
  134. package/templates/docker/src/ui/components/conversations/conversation-item.tsx +25 -20
  135. package/templates/docker/src/ui/context.tsx +1 -1
  136. package/templates/docker/src/ui/hooks/use-conversations.ts +3 -3
  137. package/templates/docker/src/ui/hooks/use-dark-mode.ts +17 -10
  138. package/templates/docker/tsconfig.json +2 -2
  139. package/templates/nextjs-standalone/.env.example +1 -1
  140. package/templates/nextjs-standalone/bin/__tests__/plugin-cli.test.ts +9 -9
  141. package/templates/nextjs-standalone/bin/atlas.ts +108 -44
  142. package/templates/nextjs-standalone/data/demo-semantic/catalog.yml +51 -27
  143. package/templates/nextjs-standalone/data/demo-semantic/entities/accounts.yml +95 -103
  144. package/templates/nextjs-standalone/data/demo-semantic/entities/companies.yml +88 -152
  145. package/templates/nextjs-standalone/data/demo-semantic/entities/people.yml +82 -95
  146. package/templates/nextjs-standalone/data/demo-semantic/glossary.yml +104 -8
  147. package/templates/nextjs-standalone/data/demo-semantic/metrics/accounts.yml +62 -23
  148. package/templates/nextjs-standalone/data/demo-semantic/metrics/companies.yml +52 -78
  149. package/templates/nextjs-standalone/docs/deploy.md +2 -39
  150. package/templates/nextjs-standalone/package.json +11 -2
  151. package/templates/nextjs-standalone/scripts/migrate-auth.ts +25 -0
  152. package/templates/nextjs-standalone/scripts/seed-demo.ts +94 -0
  153. package/templates/nextjs-standalone/semantic/catalog.yml +62 -3
  154. package/templates/nextjs-standalone/semantic/entities/accounts.yml +162 -0
  155. package/templates/nextjs-standalone/semantic/entities/companies.yml +143 -0
  156. package/templates/nextjs-standalone/semantic/entities/people.yml +132 -0
  157. package/templates/nextjs-standalone/semantic/glossary.yml +116 -4
  158. package/templates/nextjs-standalone/semantic/metrics/accounts.yml +77 -0
  159. package/templates/nextjs-standalone/semantic/metrics/companies.yml +63 -0
  160. package/templates/nextjs-standalone/src/api/__tests__/admin.test.ts +7 -7
  161. package/templates/nextjs-standalone/src/api/__tests__/health-plugin.test.ts +7 -0
  162. package/templates/nextjs-standalone/src/api/__tests__/health.test.ts +30 -8
  163. package/templates/nextjs-standalone/src/api/routes/admin.ts +549 -8
  164. package/templates/nextjs-standalone/src/api/routes/chat.ts +5 -20
  165. package/templates/nextjs-standalone/src/api/routes/health.ts +39 -27
  166. package/templates/nextjs-standalone/src/api/routes/openapi.ts +1329 -74
  167. package/templates/nextjs-standalone/src/api/routes/query.ts +2 -1
  168. package/templates/nextjs-standalone/src/api/server.ts +27 -0
  169. package/templates/nextjs-standalone/src/app/api/[...route]/route.ts +2 -2
  170. package/templates/nextjs-standalone/src/app/globals.css +13 -12
  171. package/templates/nextjs-standalone/src/app/layout.tsx +9 -2
  172. package/templates/nextjs-standalone/src/components/ui/alert-dialog.tsx +196 -0
  173. package/templates/nextjs-standalone/src/components/ui/badge.tsx +48 -0
  174. package/templates/nextjs-standalone/src/components/ui/button.tsx +64 -0
  175. package/templates/nextjs-standalone/src/components/ui/card.tsx +92 -0
  176. package/templates/nextjs-standalone/src/components/ui/collapsible.tsx +33 -0
  177. package/templates/nextjs-standalone/src/components/ui/command.tsx +184 -0
  178. package/templates/nextjs-standalone/src/components/ui/dialog.tsx +158 -0
  179. package/templates/nextjs-standalone/src/components/ui/dropdown-menu.tsx +257 -0
  180. package/templates/nextjs-standalone/src/components/ui/input.tsx +21 -0
  181. package/templates/nextjs-standalone/src/components/ui/scroll-area.tsx +58 -0
  182. package/templates/nextjs-standalone/src/components/ui/select.tsx +190 -0
  183. package/templates/nextjs-standalone/src/components/ui/separator.tsx +28 -0
  184. package/templates/nextjs-standalone/src/components/ui/sheet.tsx +143 -0
  185. package/templates/nextjs-standalone/src/components/ui/sidebar.tsx +726 -0
  186. package/templates/nextjs-standalone/src/components/ui/skeleton.tsx +13 -0
  187. package/templates/nextjs-standalone/src/components/ui/table.tsx +116 -0
  188. package/templates/nextjs-standalone/src/components/ui/tabs.tsx +91 -0
  189. package/templates/nextjs-standalone/src/components/ui/toggle-group.tsx +83 -0
  190. package/templates/nextjs-standalone/src/components/ui/toggle.tsx +47 -0
  191. package/templates/nextjs-standalone/src/components/ui/tooltip.tsx +57 -0
  192. package/templates/nextjs-standalone/src/hooks/use-mobile.ts +19 -0
  193. package/templates/nextjs-standalone/src/lib/__tests__/agent-cache.test.ts +2 -0
  194. package/templates/nextjs-standalone/src/lib/__tests__/agent-dialect.test.ts +17 -0
  195. package/templates/nextjs-standalone/src/lib/__tests__/agent-health-annotations.test.ts +2 -0
  196. package/templates/nextjs-standalone/src/lib/__tests__/agent-integration.test.ts +2 -0
  197. package/templates/nextjs-standalone/src/lib/__tests__/config.test.ts +69 -19
  198. package/templates/nextjs-standalone/src/lib/__tests__/plugin-aware-validation.test.ts +321 -0
  199. package/templates/nextjs-standalone/src/lib/__tests__/providers.test.ts +32 -1
  200. package/templates/nextjs-standalone/src/lib/__tests__/startup-actions.test.ts +9 -0
  201. package/templates/nextjs-standalone/src/lib/__tests__/startup-first-run.test.ts +429 -0
  202. package/templates/nextjs-standalone/src/lib/__tests__/startup.test.ts +5 -0
  203. package/templates/nextjs-standalone/src/lib/agent-query.ts +5 -23
  204. package/templates/nextjs-standalone/src/lib/agent.ts +32 -112
  205. package/templates/nextjs-standalone/src/lib/auth/__tests__/migrate.test.ts +5 -3
  206. package/templates/nextjs-standalone/src/lib/auth/middleware.ts +30 -4
  207. package/templates/nextjs-standalone/src/lib/auth/migrate.ts +97 -0
  208. package/templates/nextjs-standalone/src/lib/auth/server.ts +12 -1
  209. package/templates/nextjs-standalone/src/lib/config.ts +37 -39
  210. package/templates/nextjs-standalone/src/lib/db/__tests__/connection.test.ts +89 -14
  211. package/templates/nextjs-standalone/src/lib/db/__tests__/registry-health.test.ts +1 -18
  212. package/templates/nextjs-standalone/src/lib/db/__tests__/registry-pool-limits.test.ts +0 -19
  213. package/templates/nextjs-standalone/src/lib/db/__tests__/registry.test.ts +11 -208
  214. package/templates/nextjs-standalone/src/lib/db/connection.ts +87 -265
  215. package/templates/nextjs-standalone/src/lib/db/internal.ts +6 -1
  216. package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks-integration.test.ts +3 -1
  217. package/templates/nextjs-standalone/src/lib/plugins/__tests__/hooks.test.ts +2 -2
  218. package/templates/nextjs-standalone/src/lib/plugins/__tests__/migrate.test.ts +355 -1
  219. package/templates/nextjs-standalone/src/lib/plugins/__tests__/registry.test.ts +32 -5
  220. package/templates/nextjs-standalone/src/lib/plugins/__tests__/wiring.test.ts +228 -14
  221. package/templates/nextjs-standalone/src/lib/plugins/index.ts +4 -1
  222. package/templates/nextjs-standalone/src/lib/plugins/migrate.ts +103 -0
  223. package/templates/nextjs-standalone/src/lib/plugins/registry.ts +12 -6
  224. package/templates/nextjs-standalone/src/lib/plugins/wiring.ts +113 -4
  225. package/templates/nextjs-standalone/src/lib/providers.ts +6 -1
  226. package/templates/nextjs-standalone/src/lib/security.ts +24 -0
  227. package/templates/nextjs-standalone/src/lib/semantic.ts +2 -0
  228. package/templates/nextjs-standalone/src/lib/sidecar-types.ts +12 -1
  229. package/templates/nextjs-standalone/src/lib/startup.ts +71 -101
  230. package/templates/nextjs-standalone/src/lib/tools/__tests__/custom-validation.test.ts +2 -0
  231. package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-nsjail.test.ts +32 -18
  232. package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-plugin.test.ts +14 -14
  233. package/templates/nextjs-standalone/src/lib/tools/__tests__/explore-sidecar.test.ts +5 -3
  234. package/templates/nextjs-standalone/src/lib/tools/__tests__/python-nsjail.test.ts +515 -0
  235. package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sandbox.test.ts +397 -0
  236. package/templates/nextjs-standalone/src/lib/tools/__tests__/python-sidecar.test.ts +365 -0
  237. package/templates/nextjs-standalone/src/lib/tools/__tests__/python.test.ts +331 -0
  238. package/templates/nextjs-standalone/src/lib/tools/__tests__/registry-actions.test.ts +1 -13
  239. package/templates/nextjs-standalone/src/lib/tools/__tests__/registry.test.ts +38 -31
  240. package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-audit.test.ts +2 -0
  241. package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-connection-whitelist.test.ts +2 -0
  242. package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-ratelimit.test.ts +2 -0
  243. package/templates/nextjs-standalone/src/lib/tools/__tests__/sql.test.ts +5 -308
  244. package/templates/nextjs-standalone/src/lib/tools/explore-nsjail.ts +17 -12
  245. package/templates/nextjs-standalone/src/lib/tools/explore-sidecar.ts +25 -0
  246. package/templates/nextjs-standalone/src/lib/tools/explore.ts +28 -32
  247. package/templates/nextjs-standalone/src/lib/tools/python-nsjail.ts +396 -0
  248. package/templates/nextjs-standalone/src/lib/tools/python-sandbox.ts +476 -0
  249. package/templates/nextjs-standalone/src/lib/tools/python-sidecar.ts +150 -0
  250. package/templates/nextjs-standalone/src/lib/tools/python.ts +367 -0
  251. package/templates/nextjs-standalone/src/lib/tools/registry.ts +49 -22
  252. package/templates/nextjs-standalone/src/lib/tools/sql.ts +88 -88
  253. package/templates/nextjs-standalone/src/ui/components/admin/admin-layout.tsx +77 -8
  254. package/templates/nextjs-standalone/src/ui/components/admin/admin-sidebar.tsx +25 -17
  255. package/templates/nextjs-standalone/src/ui/components/admin/change-password-dialog.tsx +128 -0
  256. package/templates/nextjs-standalone/src/ui/components/admin/entity-detail.tsx +3 -3
  257. package/templates/nextjs-standalone/src/ui/components/admin/semantic-file-tree.tsx +159 -0
  258. package/templates/nextjs-standalone/src/ui/components/atlas-chat.tsx +64 -12
  259. package/templates/nextjs-standalone/src/ui/components/chart/result-chart.tsx +25 -15
  260. package/templates/nextjs-standalone/src/ui/components/chat/markdown.tsx +88 -42
  261. package/templates/nextjs-standalone/src/ui/components/chat/python-result-card.tsx +244 -0
  262. package/templates/nextjs-standalone/src/ui/components/chat/sql-block.tsx +39 -15
  263. package/templates/nextjs-standalone/src/ui/components/chat/sql-result-card.tsx +6 -1
  264. package/templates/nextjs-standalone/src/ui/components/chat/tool-part.tsx +12 -3
  265. package/templates/nextjs-standalone/src/ui/components/chat/typing-indicator.tsx +5 -2
  266. package/templates/nextjs-standalone/src/ui/components/conversations/conversation-item.tsx +25 -20
  267. package/templates/nextjs-standalone/src/ui/context.tsx +1 -1
  268. package/templates/nextjs-standalone/src/ui/hooks/use-conversations.ts +3 -3
  269. package/templates/nextjs-standalone/src/ui/hooks/use-dark-mode.ts +17 -10
  270. package/templates/nextjs-standalone/tsconfig.json +0 -1
  271. package/templates/nextjs-standalone/vercel.json +4 -1
  272. package/templates/docker/render.yaml +0 -34
  273. package/templates/docker/semantic/entities/.gitkeep +0 -0
  274. package/templates/docker/semantic/metrics/.gitkeep +0 -0
  275. package/templates/docker/src/lib/db/__tests__/duckdb.test.ts +0 -141
  276. package/templates/docker/src/lib/db/__tests__/salesforce.test.ts +0 -339
  277. package/templates/docker/src/lib/db/__tests__/snowflake.test.ts +0 -217
  278. package/templates/docker/src/lib/db/duckdb.ts +0 -122
  279. package/templates/docker/src/lib/db/salesforce.ts +0 -342
  280. package/templates/docker/src/lib/tools/__tests__/salesforce-tool.test.ts +0 -154
  281. package/templates/docker/src/lib/tools/__tests__/soql-validation.test.ts +0 -303
  282. package/templates/docker/src/lib/tools/__tests__/sql-duckdb.test.ts +0 -233
  283. package/templates/docker/src/lib/tools/salesforce.ts +0 -138
  284. package/templates/docker/src/lib/tools/soql-validation.ts +0 -172
  285. package/templates/nextjs-standalone/semantic/entities/.gitkeep +0 -0
  286. package/templates/nextjs-standalone/semantic/metrics/.gitkeep +0 -0
  287. package/templates/nextjs-standalone/src/lib/db/__tests__/duckdb.test.ts +0 -141
  288. package/templates/nextjs-standalone/src/lib/db/__tests__/salesforce.test.ts +0 -339
  289. package/templates/nextjs-standalone/src/lib/db/__tests__/snowflake.test.ts +0 -217
  290. package/templates/nextjs-standalone/src/lib/db/duckdb.ts +0 -122
  291. package/templates/nextjs-standalone/src/lib/db/salesforce.ts +0 -342
  292. package/templates/nextjs-standalone/src/lib/tools/__tests__/salesforce-tool.test.ts +0 -154
  293. package/templates/nextjs-standalone/src/lib/tools/__tests__/soql-validation.test.ts +0 -303
  294. package/templates/nextjs-standalone/src/lib/tools/__tests__/sql-duckdb.test.ts +0 -233
  295. package/templates/nextjs-standalone/src/lib/tools/salesforce.ts +0 -138
  296. package/templates/nextjs-standalone/src/lib/tools/soql-validation.ts +0 -172
@@ -1,28 +1,95 @@
1
1
  /**
2
- * Tests for detectDBType from connection.ts.
2
+ * Tests for detectDBType and resolveDatasourceUrl from connection.ts.
3
3
  *
4
4
  * sql.test.ts registers a global mock.module for @/lib/db/connection which
5
5
  * persists across bun's test runner. To test the real implementation, we
6
6
  * import the source file via a cache-busting query string that bypasses the mock.
7
7
  */
8
- import { describe, it, expect, beforeEach } from "bun:test";
8
+ import { describe, it, expect, beforeEach, afterEach } from "bun:test";
9
9
  import { resolve } from "path";
10
10
 
11
11
  const modulePath = resolve(__dirname, "../connection.ts");
12
12
  const mod = await import(`${modulePath}?t=${Date.now()}`);
13
- const detectDBType = mod.detectDBType as (url?: string) => "postgres" | "mysql" | "duckdb";
13
+ const detectDBType = mod.detectDBType as (url?: string) => "postgres" | "mysql";
14
+ const resolveDatasourceUrl = mod.resolveDatasourceUrl as () => string | undefined;
14
15
 
15
- describe("detectDBType", () => {
16
- const origDatabaseUrl = process.env.ATLAS_DATASOURCE_URL;
16
+ // Env vars touched by tests — save/restore
17
+ const MANAGED_VARS = [
18
+ "ATLAS_DATASOURCE_URL",
19
+ "ATLAS_DEMO_DATA",
20
+ "DATABASE_URL",
21
+ "DATABASE_URL_UNPOOLED",
22
+ ] as const;
23
+ const savedEnv: Record<string, string | undefined> = {};
24
+
25
+ function saveEnv() {
26
+ for (const key of MANAGED_VARS) savedEnv[key] = process.env[key];
27
+ }
28
+
29
+ function restoreEnv() {
30
+ for (const key of MANAGED_VARS) {
31
+ if (savedEnv[key] !== undefined) process.env[key] = savedEnv[key];
32
+ else delete process.env[key];
33
+ }
34
+ }
35
+
36
+ describe("resolveDatasourceUrl", () => {
37
+ beforeEach(() => {
38
+ saveEnv();
39
+ for (const key of MANAGED_VARS) delete process.env[key];
40
+ });
41
+
42
+ afterEach(restoreEnv);
43
+
44
+ it("returns ATLAS_DATASOURCE_URL when set", () => {
45
+ process.env.ATLAS_DATASOURCE_URL = "postgresql://explicit@localhost/db";
46
+ expect(resolveDatasourceUrl()).toBe("postgresql://explicit@localhost/db");
47
+ });
48
+
49
+ it("returns ATLAS_DATASOURCE_URL even when ATLAS_DEMO_DATA=true", () => {
50
+ process.env.ATLAS_DATASOURCE_URL = "postgresql://explicit@localhost/db";
51
+ process.env.ATLAS_DEMO_DATA = "true";
52
+ process.env.DATABASE_URL = "postgresql://fallback@localhost/db";
53
+ expect(resolveDatasourceUrl()).toBe("postgresql://explicit@localhost/db");
54
+ });
55
+
56
+ it("returns DATABASE_URL_UNPOOLED when ATLAS_DEMO_DATA=true and both fallbacks set", () => {
57
+ process.env.ATLAS_DEMO_DATA = "true";
58
+ process.env.DATABASE_URL_UNPOOLED = "postgresql://unpooled@localhost/db";
59
+ process.env.DATABASE_URL = "postgresql://pooled@localhost/db";
60
+ expect(resolveDatasourceUrl()).toBe("postgresql://unpooled@localhost/db");
61
+ });
17
62
 
63
+ it("returns DATABASE_URL when ATLAS_DEMO_DATA=true and only DATABASE_URL set", () => {
64
+ process.env.ATLAS_DEMO_DATA = "true";
65
+ process.env.DATABASE_URL = "postgresql://pooled@localhost/db";
66
+ expect(resolveDatasourceUrl()).toBe("postgresql://pooled@localhost/db");
67
+ });
68
+
69
+ it("returns undefined when nothing is configured", () => {
70
+ expect(resolveDatasourceUrl()).toBeUndefined();
71
+ });
72
+
73
+ it("returns undefined when ATLAS_DEMO_DATA is not exactly 'true'", () => {
74
+ process.env.ATLAS_DEMO_DATA = "TRUE";
75
+ process.env.DATABASE_URL = "postgresql://fallback@localhost/db";
76
+ expect(resolveDatasourceUrl()).toBeUndefined();
77
+ });
78
+
79
+ it("returns undefined when ATLAS_DEMO_DATA=true but no DATABASE_URL vars set", () => {
80
+ process.env.ATLAS_DEMO_DATA = "true";
81
+ expect(resolveDatasourceUrl()).toBeUndefined();
82
+ });
83
+ });
84
+
85
+ describe("detectDBType", () => {
18
86
  beforeEach(() => {
19
- if (origDatabaseUrl !== undefined) {
20
- process.env.ATLAS_DATASOURCE_URL = origDatabaseUrl;
21
- } else {
22
- delete process.env.ATLAS_DATASOURCE_URL;
23
- }
87
+ saveEnv();
88
+ for (const key of MANAGED_VARS) delete process.env[key];
24
89
  });
25
90
 
91
+ afterEach(restoreEnv);
92
+
26
93
  it("detects postgresql:// as postgres", () => {
27
94
  expect(detectDBType("postgresql://user:pass@localhost:5432/db")).toBe("postgres");
28
95
  });
@@ -53,12 +120,20 @@ describe("detectDBType", () => {
53
120
  expect(() => detectDBType("")).toThrow("No database URL provided");
54
121
  });
55
122
 
56
- it("detects duckdb:// as duckdb", () => {
57
- expect(detectDBType("duckdb://:memory:")).toBe("duckdb");
123
+ it("throws for non-core adapter URLs with plugin migration hint", () => {
124
+ expect(() => detectDBType("duckdb://:memory:")).toThrow("now a plugin");
125
+ expect(() => detectDBType("clickhouse://localhost:8123/default")).toThrow("now a plugin");
126
+ expect(() => detectDBType("snowflake://user:pass@account/db")).toThrow("now a plugin");
127
+ expect(() => detectDBType("salesforce://user:pass@login.salesforce.com")).toThrow("now a plugin");
128
+ });
129
+
130
+ it("suggests correct plugin name for TLS scheme variants", () => {
131
+ expect(() => detectDBType("clickhouses://localhost:8443/default")).toThrow("@useatlas/clickhouse");
58
132
  });
59
133
 
60
- it("detects duckdb://path as duckdb", () => {
61
- expect(detectDBType("duckdb:///tmp/test.duckdb")).toBe("duckdb");
134
+ it("includes the detected scheme in the error message", () => {
135
+ expect(() => detectDBType("duckdb://:memory:")).toThrow("duckdb://");
136
+ expect(() => detectDBType("clickhouse://localhost")).toThrow("clickhouse://");
62
137
  });
63
138
 
64
139
  it("unrecognized URL throws an error", () => {
@@ -24,24 +24,7 @@ mock.module("mysql2/promise", () => ({
24
24
  }),
25
25
  }));
26
26
 
27
- mock.module("@duckdb/node-api", () => ({
28
- DuckDBInstance: {
29
- async create() {
30
- return {
31
- async connect() {
32
- return {
33
- async runAndReadAll() {
34
- return { columnNames: () => [], getRowObjects: () => [] };
35
- },
36
- async run() {},
37
- async close() {},
38
- };
39
- },
40
- async close() {},
41
- };
42
- },
43
- },
44
- }));
27
+ // Note: DuckDB mock removed adapter is now a plugin.
45
28
 
46
29
  // Cache-busting import
47
30
  const connModPath = resolve(__dirname, "../connection.ts");
@@ -26,25 +26,6 @@ mock.module("mysql2/promise", () => ({
26
26
  }),
27
27
  }));
28
28
 
29
- mock.module("@duckdb/node-api", () => ({
30
- DuckDBInstance: {
31
- async create() {
32
- return {
33
- async connect() {
34
- return {
35
- async runAndReadAll() {
36
- return { columnNames: () => [], getRowObjects: () => [] };
37
- },
38
- async run() {},
39
- async close() {},
40
- };
41
- },
42
- async close() {},
43
- };
44
- },
45
- },
46
- }));
47
-
48
29
  // Cache-busting import
49
30
  const connModPath = resolve(__dirname, "../connection.ts");
50
31
  const connMod = await import(`${connModPath}?t=${Date.now()}`);
@@ -40,70 +40,8 @@ mock.module("mysql2/promise", () => ({
40
40
  }),
41
41
  }));
42
42
 
43
- // ClickHouse mock with spies to capture arguments
44
- let lastCreateClientOpts: Record<string, unknown> | null = null;
45
- let lastQueryOpts: Record<string, unknown> | null = null;
46
- let mockJsonResponse: { meta: { name: string }[]; data: Record<string, unknown>[] } = {
47
- meta: [],
48
- data: [],
49
- };
50
-
51
- mock.module("@clickhouse/client", () => ({
52
- createClient: (opts: Record<string, unknown>) => {
53
- lastCreateClientOpts = opts;
54
- return {
55
- async query(qOpts: Record<string, unknown>) {
56
- lastQueryOpts = qOpts;
57
- return {
58
- async json() {
59
- return mockJsonResponse;
60
- },
61
- };
62
- },
63
- async close() {},
64
- };
65
- },
66
- }));
67
-
68
- mock.module("@duckdb/node-api", () => ({
69
- DuckDBInstance: {
70
- async create() {
71
- return {
72
- async connect() {
73
- return {
74
- async runAndReadAll() {
75
- return {
76
- columnNames: () => [],
77
- getRowObjects: () => [],
78
- };
79
- },
80
- async run() {},
81
- async close() {},
82
- };
83
- },
84
- async close() {},
85
- };
86
- },
87
- },
88
- }));
89
-
90
- mock.module("snowflake-sdk", () => ({
91
- configure: () => {},
92
- createPool: () => ({
93
- use: async (fn: (conn: unknown) => Promise<unknown>) => {
94
- const mockConn = {
95
- execute: (opts: { sqlText: string; complete: (err: null, stmt: unknown, rows: unknown[]) => void }) => {
96
- opts.complete(null, {
97
- getColumns: () => [],
98
- }, []);
99
- },
100
- };
101
- return fn(mockConn);
102
- },
103
- drain: async () => {},
104
- clear: async () => {},
105
- }),
106
- }));
43
+ // Note: ClickHouse, DuckDB, Snowflake adapter mocks removed — those
44
+ // adapters are now plugins. See plugins/{clickhouse,duckdb,snowflake}-datasource/.
107
45
 
108
46
  // Cache-busting import to get a fresh module instance
109
47
  const connModPath = resolve(__dirname, "../connection.ts");
@@ -113,7 +51,6 @@ const ConnectionRegistry = connMod.ConnectionRegistry as typeof import("../conne
113
51
  const connections = connMod.connections as import("../connection").ConnectionRegistry;
114
52
  const getDB = connMod.getDB as typeof import("../connection").getDB;
115
53
  const detectDBType = connMod.detectDBType as typeof import("../connection").detectDBType;
116
- const rewriteClickHouseUrl = connMod.rewriteClickHouseUrl as typeof import("../connection").rewriteClickHouseUrl;
117
54
 
118
55
  // Import semantic module with cache-busting too
119
56
  const semModPath = resolve(__dirname, "../../semantic.ts");
@@ -129,9 +66,6 @@ describe("ConnectionRegistry", () => {
129
66
  connections._reset();
130
67
  delete process.env.ATLAS_DATASOURCE_URL;
131
68
  delete process.env.ATLAS_SCHEMA;
132
- lastCreateClientOpts = null;
133
- lastQueryOpts = null;
134
- mockJsonResponse = { meta: [], data: [] };
135
69
  });
136
70
 
137
71
  afterEach(() => {
@@ -284,28 +218,10 @@ describe("ConnectionRegistry", () => {
284
218
  expect(connections.get("my")).toBeDefined();
285
219
  });
286
220
 
287
- it("creates clickhouse connection for clickhouse:// URLs", () => {
288
- connections.register("ch", {
289
- url: "clickhouse://user:pass@localhost:8123/default",
290
- });
291
- const conn = connections.get("ch");
292
- expect(conn).toBeDefined();
293
- expect(conn.query).toBeFunction();
294
- expect(conn.close).toBeFunction();
295
- });
296
-
297
- it("creates snowflake connection for snowflake:// URLs", () => {
298
- connections.register("sf", {
299
- url: "snowflake://user:pass@account123/mydb/myschema?warehouse=WH",
300
- });
301
- expect(connections.get("sf")).toBeDefined();
302
- });
303
-
304
- it("creates duckdb connection for duckdb:// URLs", () => {
305
- connections.register("dk", {
306
- url: "duckdb://:memory:",
307
- });
308
- expect(connections.get("dk")).toBeDefined();
221
+ it("throws for non-core adapter URLs with plugin migration hint", () => {
222
+ expect(() => connections.register("ch", { url: "clickhouse://user:pass@localhost:8123/default" })).toThrow("plugin");
223
+ expect(() => connections.register("sf", { url: "snowflake://user:pass@account123/mydb" })).toThrow("plugin");
224
+ expect(() => connections.register("dk", { url: "duckdb://:memory:" })).toThrow("plugin");
309
225
  });
310
226
 
311
227
  it("throws for unrecognized URL scheme", () => {
@@ -335,21 +251,12 @@ describe("ConnectionRegistry", () => {
335
251
  expect(connections.getDBType("my")).toBe("mysql");
336
252
  });
337
253
 
338
- it("returns correct type for clickhouse connection", () => {
339
- connections.register("ch", { url: "clickhouse://user:pass@localhost:8123/default" });
254
+ it("returns correct type for plugin-registered connection", async () => {
255
+ const conn = { async query() { return { columns: [], rows: [] }; }, async close() {} };
256
+ await connections.registerDirect("ch", conn, "clickhouse");
340
257
  expect(connections.getDBType("ch")).toBe("clickhouse");
341
258
  });
342
259
 
343
- it("returns correct type for snowflake connection", () => {
344
- connections.register("sf", { url: "snowflake://user:pass@account123/mydb/myschema?warehouse=WH" });
345
- expect(connections.getDBType("sf")).toBe("snowflake");
346
- });
347
-
348
- it("returns correct type for duckdb connection", () => {
349
- connections.register("dk", { url: "duckdb://:memory:" });
350
- expect(connections.getDBType("dk")).toBe("duckdb");
351
- });
352
-
353
260
  it("throws for unregistered connection ID", () => {
354
261
  expect(() => connections.getDBType("nonexistent")).toThrow(
355
262
  'Connection "nonexistent" is not registered.'
@@ -426,10 +333,6 @@ describe("ConnectionRegistry", () => {
426
333
  });
427
334
 
428
335
  describe("detectDBType", () => {
429
- it("returns 'clickhouse' for clickhouse:// URLs", () => {
430
- expect(detectDBType("clickhouse://user:pass@localhost:8123/default")).toBe("clickhouse");
431
- });
432
-
433
336
  it("returns 'postgres' for postgresql:// URLs", () => {
434
337
  expect(detectDBType("postgresql://user:pass@localhost:5432/db")).toBe("postgres");
435
338
  });
@@ -438,8 +341,8 @@ describe("ConnectionRegistry", () => {
438
341
  expect(detectDBType("mysql://user:pass@localhost:3306/db")).toBe("mysql");
439
342
  });
440
343
 
441
- it("returns 'duckdb' for duckdb:// URLs", () => {
442
- expect(detectDBType("duckdb://:memory:")).toBe("duckdb");
344
+ it("throws for non-core URL schemes with plugin suggestion", () => {
345
+ expect(() => detectDBType("clickhouse://user:pass@localhost:8123/default")).toThrow("plugin");
443
346
  });
444
347
 
445
348
  it("throws for unsupported URL scheme", () => {
@@ -447,106 +350,6 @@ describe("ConnectionRegistry", () => {
447
350
  });
448
351
  });
449
352
 
450
- describe("ClickHouse adapter", () => {
451
- it("passes readonly: 1 and max_execution_time in query settings", async () => {
452
- connections.register("ch", {
453
- url: "clickhouse://user:pass@localhost:8123/default",
454
- });
455
- const conn = connections.get("ch");
456
- await conn.query("SELECT 1", 30000);
457
-
458
- expect(lastQueryOpts).toBeDefined();
459
- const settings = (lastQueryOpts as Record<string, unknown>)
460
- .clickhouse_settings as Record<string, unknown>;
461
- expect(settings.readonly).toBe(1);
462
- expect(settings.max_execution_time).toBe(Math.ceil(30000 / 1000));
463
- });
464
-
465
- it("computes max_execution_time correctly from timeout", async () => {
466
- connections.register("ch", {
467
- url: "clickhouse://user:pass@localhost:8123/default",
468
- });
469
- const conn = connections.get("ch");
470
- // 7500ms → ceil(7.5) = 8 seconds
471
- await conn.query("SELECT 1", 7500);
472
-
473
- const settings = (lastQueryOpts as Record<string, unknown>)
474
- .clickhouse_settings as Record<string, unknown>;
475
- expect(settings.max_execution_time).toBe(8);
476
- });
477
-
478
- it("rewrites clickhouse:// URL to http:// for createClient", () => {
479
- connections.register("ch", {
480
- url: "clickhouse://user:pass@host:8123/db",
481
- });
482
-
483
- expect(lastCreateClientOpts).toBeDefined();
484
- expect((lastCreateClientOpts as Record<string, unknown>).url).toBe(
485
- "http://user:pass@host:8123/db"
486
- );
487
- });
488
-
489
- it("rewrites clickhouses:// URL to https:// for createClient", () => {
490
- connections.register("chs", {
491
- url: "clickhouses://user:pass@host:8443/db",
492
- });
493
-
494
- expect(lastCreateClientOpts).toBeDefined();
495
- expect((lastCreateClientOpts as Record<string, unknown>).url).toBe(
496
- "https://user:pass@host:8443/db"
497
- );
498
- });
499
-
500
- it("extracts columns and rows from ClickHouse JSON response", async () => {
501
- mockJsonResponse = {
502
- meta: [{ name: "id" }, { name: "name" }],
503
- data: [{ id: 1, name: "test" }],
504
- };
505
-
506
- connections.register("ch", {
507
- url: "clickhouse://user:pass@localhost:8123/default",
508
- });
509
- const conn = connections.get("ch");
510
- const result = await conn.query("SELECT id, name FROM companies");
511
-
512
- expect(result.columns).toEqual(["id", "name"]);
513
- expect(result.rows).toEqual([{ id: 1, name: "test" }]);
514
- });
515
-
516
- it("describe() reports dbType as 'clickhouse' with description", () => {
517
- connections.register("ch", {
518
- url: "clickhouse://user:pass@localhost:8123/default",
519
- description: "Analytics warehouse",
520
- });
521
-
522
- const meta = connections.describe();
523
- const chMeta = meta.find((m) => m.id === "ch");
524
- expect(chMeta).toBeDefined();
525
- expect(chMeta!.dbType).toBe("clickhouse");
526
- expect(chMeta!.description).toBe("Analytics warehouse");
527
- });
528
- });
529
-
530
- describe("rewriteClickHouseUrl", () => {
531
- it("rewrites clickhouse:// to http://", () => {
532
- expect(rewriteClickHouseUrl("clickhouse://user:pass@host:8123/db")).toBe(
533
- "http://user:pass@host:8123/db"
534
- );
535
- });
536
-
537
- it("rewrites clickhouses:// to https://", () => {
538
- expect(rewriteClickHouseUrl("clickhouses://user:pass@host:8443/db")).toBe(
539
- "https://user:pass@host:8443/db"
540
- );
541
- });
542
- });
543
-
544
- describe("detectDBType — ClickHouse schemes", () => {
545
- it("returns 'clickhouse' for clickhouses:// URLs", () => {
546
- expect(detectDBType("clickhouses://user:pass@host:8443/db")).toBe("clickhouse");
547
- });
548
- });
549
-
550
353
  describe("constructor creates independent instances", () => {
551
354
  it("new ConnectionRegistry is independent", () => {
552
355
  const reg = new ConnectionRegistry();