sqlew 5.0.8 → 5.2.0

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 (499) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +19 -10
  3. package/dist/adapters/auth/auth-factory.d.ts +2 -81
  4. package/dist/adapters/auth/auth-factory.d.ts.map +1 -1
  5. package/dist/adapters/auth/auth-factory.js +2 -82
  6. package/dist/adapters/auth/auth-factory.js.map +1 -1
  7. package/dist/adapters/auth/base-auth-provider.d.ts +18 -303
  8. package/dist/adapters/auth/base-auth-provider.d.ts.map +1 -1
  9. package/dist/adapters/auth/base-auth-provider.js +2 -104
  10. package/dist/adapters/auth/base-auth-provider.js.map +1 -1
  11. package/dist/adapters/auth/direct-auth-provider.d.ts +4 -348
  12. package/dist/adapters/auth/direct-auth-provider.d.ts.map +1 -1
  13. package/dist/adapters/auth/direct-auth-provider.js +6 -356
  14. package/dist/adapters/auth/direct-auth-provider.js.map +1 -1
  15. package/dist/adapters/base-adapter.d.ts +31 -598
  16. package/dist/adapters/base-adapter.d.ts.map +1 -1
  17. package/dist/adapters/base-adapter.js +10 -458
  18. package/dist/adapters/base-adapter.js.map +1 -1
  19. package/dist/adapters/index.d.ts +1 -11
  20. package/dist/adapters/index.d.ts.map +1 -1
  21. package/dist/adapters/index.js +1 -11
  22. package/dist/adapters/index.js.map +1 -1
  23. package/dist/adapters/mysql-adapter.d.ts +15 -541
  24. package/dist/adapters/mysql-adapter.d.ts.map +1 -1
  25. package/dist/adapters/mysql-adapter.js +24 -561
  26. package/dist/adapters/mysql-adapter.js.map +1 -1
  27. package/dist/adapters/postgresql-adapter.d.ts +15 -203
  28. package/dist/adapters/postgresql-adapter.d.ts.map +1 -1
  29. package/dist/adapters/postgresql-adapter.js +24 -223
  30. package/dist/adapters/postgresql-adapter.js.map +1 -1
  31. package/dist/adapters/sqlite-adapter.d.ts +4 -28
  32. package/dist/adapters/sqlite-adapter.d.ts.map +1 -1
  33. package/dist/adapters/sqlite-adapter.js +4 -32
  34. package/dist/adapters/sqlite-adapter.js.map +1 -1
  35. package/dist/adapters/types.d.ts +1 -4
  36. package/dist/adapters/types.d.ts.map +1 -1
  37. package/dist/backend/backend-factory.d.ts +3 -3
  38. package/dist/backend/backend-factory.js +3 -3
  39. package/dist/backend/local-backend.d.ts.map +1 -1
  40. package/dist/backend/local-backend.js +0 -5
  41. package/dist/backend/local-backend.js.map +1 -1
  42. package/dist/cli/db-export.d.ts.map +1 -1
  43. package/dist/cli/db-export.js +54 -32
  44. package/dist/cli/db-export.js.map +1 -1
  45. package/dist/cli/db-import.d.ts.map +1 -1
  46. package/dist/cli/db-import.js +32 -31
  47. package/dist/cli/db-import.js.map +1 -1
  48. package/dist/cli/hooks/on-exit-plan.d.ts.map +1 -1
  49. package/dist/cli/hooks/on-exit-plan.js +42 -1
  50. package/dist/cli/hooks/on-exit-plan.js.map +1 -1
  51. package/dist/cli/hooks/on-prompt.d.ts.map +1 -1
  52. package/dist/cli/hooks/on-prompt.js +5 -0
  53. package/dist/cli/hooks/on-prompt.js.map +1 -1
  54. package/dist/cli/hooks/plan-processor.d.ts.map +1 -1
  55. package/dist/cli/hooks/plan-processor.js +16 -2
  56. package/dist/cli/hooks/plan-processor.js.map +1 -1
  57. package/dist/cli/hooks/stdin-parser.d.ts +41 -0
  58. package/dist/cli/hooks/stdin-parser.d.ts.map +1 -1
  59. package/dist/cli/hooks/stdin-parser.js +140 -4
  60. package/dist/cli/hooks/stdin-parser.js.map +1 -1
  61. package/dist/cli/hooks/track-plan.d.ts +13 -0
  62. package/dist/cli/hooks/track-plan.d.ts.map +1 -1
  63. package/dist/cli/hooks/track-plan.js +58 -3
  64. package/dist/cli/hooks/track-plan.js.map +1 -1
  65. package/dist/cli.d.ts.map +1 -1
  66. package/dist/cli.js +1 -12
  67. package/dist/cli.js.map +1 -1
  68. package/dist/config/cloud-config-loader.d.ts +8 -8
  69. package/dist/config/cloud-config-loader.d.ts.map +1 -1
  70. package/dist/config/cloud-config-loader.js +12 -12
  71. package/dist/config/cloud-config-loader.js.map +1 -1
  72. package/dist/config/global-config.d.ts +24 -46
  73. package/dist/config/global-config.d.ts.map +1 -1
  74. package/dist/config/global-config.js +174 -56
  75. package/dist/config/global-config.js.map +1 -1
  76. package/dist/config/loader.d.ts +1 -18
  77. package/dist/config/loader.d.ts.map +1 -1
  78. package/dist/config/loader.js +1 -89
  79. package/dist/config/loader.js.map +1 -1
  80. package/dist/config/types.d.ts +2 -64
  81. package/dist/config/types.d.ts.map +1 -1
  82. package/dist/config/types.js +0 -18
  83. package/dist/config/types.js.map +1 -1
  84. package/dist/database/index.d.ts +1 -2
  85. package/dist/database/index.d.ts.map +1 -1
  86. package/dist/database/index.js +1 -3
  87. package/dist/database/index.js.map +1 -1
  88. package/dist/database/migrations/v4/20251126000001_v4_migrate_data.d.ts.map +1 -1
  89. package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js +2 -1
  90. package/dist/database/migrations/v4/20251126000001_v4_migrate_data.js.map +1 -1
  91. package/dist/database/operations/queries.d.ts +0 -4
  92. package/dist/database/operations/queries.d.ts.map +1 -1
  93. package/dist/database/operations/queries.js +0 -8
  94. package/dist/database/operations/queries.js.map +1 -1
  95. package/dist/index.d.ts +1 -1
  96. package/dist/index.js +2 -2
  97. package/dist/index.js.map +1 -1
  98. package/dist/init-rules.d.ts.map +1 -1
  99. package/dist/init-rules.js +0 -1
  100. package/dist/init-rules.js.map +1 -1
  101. package/dist/knexfile.d.ts.map +1 -1
  102. package/dist/knexfile.js +2 -1
  103. package/dist/knexfile.js.map +1 -1
  104. package/dist/migration/local-to-global.d.ts +19 -0
  105. package/dist/migration/local-to-global.d.ts.map +1 -0
  106. package/dist/migration/local-to-global.js +133 -0
  107. package/dist/migration/local-to-global.js.map +1 -0
  108. package/dist/saas-connector/client/types.d.ts +1 -1
  109. package/dist/saas-connector/client/types.d.ts.map +1 -1
  110. package/dist/schema.js +1 -1
  111. package/dist/server/setup.d.ts.map +1 -1
  112. package/dist/server/setup.js +15 -7
  113. package/dist/server/setup.js.map +1 -1
  114. package/dist/tests/backend/backend-factory.test.js +2 -2
  115. package/dist/tests/backend/backend-factory.test.js.map +1 -1
  116. package/dist/tests/docker/native/constraint-operations.test.d.ts +2 -17
  117. package/dist/tests/docker/native/constraint-operations.test.d.ts.map +1 -1
  118. package/dist/tests/docker/native/constraint-operations.test.js +3 -82
  119. package/dist/tests/docker/native/constraint-operations.test.js.map +1 -1
  120. package/dist/tests/docker/native/db-init.d.ts +3 -34
  121. package/dist/tests/docker/native/db-init.d.ts.map +1 -1
  122. package/dist/tests/docker/native/db-init.js +15 -77
  123. package/dist/tests/docker/native/db-init.js.map +1 -1
  124. package/dist/tests/docker/native/decision-operations.test.d.ts +2 -10
  125. package/dist/tests/docker/native/decision-operations.test.d.ts.map +1 -1
  126. package/dist/tests/docker/native/decision-operations.test.js +2 -84
  127. package/dist/tests/docker/native/decision-operations.test.js.map +1 -1
  128. package/dist/tests/docker/native/help-system.test.d.ts +2 -5
  129. package/dist/tests/docker/native/help-system.test.d.ts.map +1 -1
  130. package/dist/tests/docker/native/help-system.test.js +2 -47
  131. package/dist/tests/docker/native/help-system.test.js.map +1 -1
  132. package/dist/tests/docker/native/suggest-tool.test.d.ts +3 -11
  133. package/dist/tests/docker/native/suggest-tool.test.d.ts.map +1 -1
  134. package/dist/tests/docker/native/suggest-tool.test.js +3 -60
  135. package/dist/tests/docker/native/suggest-tool.test.js.map +1 -1
  136. package/dist/tests/docker/native/test-harness.d.ts +2 -23
  137. package/dist/tests/docker/native/test-harness.d.ts.map +1 -1
  138. package/dist/tests/docker/native/test-harness.js +5 -59
  139. package/dist/tests/docker/native/test-harness.js.map +1 -1
  140. package/dist/tests/feature/decision/analytics.test.js +2 -1
  141. package/dist/tests/feature/decision/analytics.test.js.map +1 -1
  142. package/dist/tests/feature/decision/batch-validation-comprehensive.test.js +2 -7
  143. package/dist/tests/feature/decision/batch-validation-comprehensive.test.js.map +1 -1
  144. package/dist/tests/feature/decision/batch-validation.test.js +2 -1
  145. package/dist/tests/feature/decision/batch-validation.test.js.map +1 -1
  146. package/dist/tests/integration/auto-trigger-suggestions.test.js +4 -37
  147. package/dist/tests/integration/auto-trigger-suggestions.test.js.map +1 -1
  148. package/dist/tests/integration/hybrid-similarity-detection.test.js +2 -1
  149. package/dist/tests/integration/hybrid-similarity-detection.test.js.map +1 -1
  150. package/dist/tests/integration/json-export-import.test.d.ts.map +1 -0
  151. package/dist/tests/integration/json-export-import.test.js.map +1 -0
  152. package/dist/tests/unit/case-insensitive-validator.test.d.ts +0 -7
  153. package/dist/tests/unit/case-insensitive-validator.test.d.ts.map +1 -1
  154. package/dist/tests/unit/case-insensitive-validator.test.js +0 -22
  155. package/dist/tests/unit/case-insensitive-validator.test.js.map +1 -1
  156. package/dist/tests/unit/config/cloud-config-loader.test.js +4 -2
  157. package/dist/tests/unit/config/cloud-config-loader.test.js.map +1 -1
  158. package/dist/tests/unit/config/global-db-migration.test.d.ts +12 -0
  159. package/dist/tests/unit/config/global-db-migration.test.d.ts.map +1 -0
  160. package/dist/tests/unit/config/global-db-migration.test.js +117 -0
  161. package/dist/tests/unit/config/global-db-migration.test.js.map +1 -0
  162. package/dist/tests/unit/constraint-scorer.test.d.ts +2 -7
  163. package/dist/tests/unit/constraint-scorer.test.d.ts.map +1 -1
  164. package/dist/tests/unit/constraint-scorer.test.js +2 -28
  165. package/dist/tests/unit/constraint-scorer.test.js.map +1 -1
  166. package/dist/tests/unit/hooks/grok-hook-normalization.test.d.ts +9 -0
  167. package/dist/tests/unit/hooks/grok-hook-normalization.test.d.ts.map +1 -0
  168. package/dist/tests/unit/hooks/grok-hook-normalization.test.js +98 -0
  169. package/dist/tests/unit/hooks/grok-hook-normalization.test.js.map +1 -0
  170. package/dist/tests/unit/hooks/grok-plan-template-injection.test.d.ts +7 -0
  171. package/dist/tests/unit/hooks/grok-plan-template-injection.test.d.ts.map +1 -0
  172. package/dist/tests/unit/hooks/grok-plan-template-injection.test.js +55 -0
  173. package/dist/tests/unit/hooks/grok-plan-template-injection.test.js.map +1 -0
  174. package/dist/tests/unit/universal-knex.test.js +9 -0
  175. package/dist/tests/unit/universal-knex.test.js.map +1 -1
  176. package/dist/tests/unit/validation/parameter-validation.test.js +0 -24
  177. package/dist/tests/unit/validation/parameter-validation.test.js.map +1 -1
  178. package/dist/tests/utils/db-config.d.ts.map +1 -1
  179. package/dist/tests/utils/db-config.js +0 -9
  180. package/dist/tests/utils/db-config.js.map +1 -1
  181. package/dist/tests/utils/db-import.d.ts.map +1 -1
  182. package/dist/tests/utils/db-import.js +0 -3
  183. package/dist/tests/utils/db-import.js.map +1 -1
  184. package/dist/tests/utils/db-schema.d.ts.map +1 -1
  185. package/dist/tests/utils/db-schema.js +48 -51
  186. package/dist/tests/utils/db-schema.js.map +1 -1
  187. package/dist/tests/utils/db-seeding.d.ts.map +1 -1
  188. package/dist/tests/utils/db-seeding.js +0 -3
  189. package/dist/tests/utils/db-seeding.js.map +1 -1
  190. package/dist/tests/utils/index.d.ts +0 -1
  191. package/dist/tests/utils/index.d.ts.map +1 -1
  192. package/dist/tests/utils/index.js +0 -2
  193. package/dist/tests/utils/index.js.map +1 -1
  194. package/dist/tests/utils/test-helpers.d.ts +6 -76
  195. package/dist/tests/utils/test-helpers.d.ts.map +1 -1
  196. package/dist/tests/utils/test-helpers.js +56 -162
  197. package/dist/tests/utils/test-helpers.js.map +1 -1
  198. package/dist/tests/utils/test-lifecycle.d.ts +2 -28
  199. package/dist/tests/utils/test-lifecycle.d.ts.map +1 -1
  200. package/dist/tests/utils/test-lifecycle.js +2 -31
  201. package/dist/tests/utils/test-lifecycle.js.map +1 -1
  202. package/dist/tools/context/index.d.ts +0 -1
  203. package/dist/tools/context/index.d.ts.map +1 -1
  204. package/dist/tools/context/index.js +0 -2
  205. package/dist/tools/context/index.js.map +1 -1
  206. package/dist/tools/context/types.d.ts +1 -1
  207. package/dist/tools/context/types.d.ts.map +1 -1
  208. package/dist/types/actions.d.ts +6 -29
  209. package/dist/types/actions.d.ts.map +1 -1
  210. package/dist/types/actions.js +1 -2
  211. package/dist/types/actions.js.map +1 -1
  212. package/dist/types/constraint/params.d.ts +24 -1
  213. package/dist/types/constraint/params.d.ts.map +1 -1
  214. package/dist/types/constraint/params.js +3 -0
  215. package/dist/types/constraint/params.js.map +1 -1
  216. package/dist/types/constraint/responses.d.ts +18 -1
  217. package/dist/types/constraint/responses.d.ts.map +1 -1
  218. package/dist/types/constraint/responses.js +3 -0
  219. package/dist/types/constraint/responses.js.map +1 -1
  220. package/dist/types/decision/batch.d.ts +2 -5
  221. package/dist/types/decision/batch.d.ts.map +1 -1
  222. package/dist/types/decision/batch.js +3 -3
  223. package/dist/types/decision/batch.js.map +1 -1
  224. package/dist/types/decision/params.d.ts +7 -4
  225. package/dist/types/decision/params.d.ts.map +1 -1
  226. package/dist/types/decision/responses.d.ts +49 -35
  227. package/dist/types/decision/responses.d.ts.map +1 -1
  228. package/dist/types/decision/templates.d.ts +2 -18
  229. package/dist/types/decision/templates.d.ts.map +1 -1
  230. package/dist/types/decision/templates.js +3 -3
  231. package/dist/types/decision/templates.js.map +1 -1
  232. package/dist/types/enums.d.ts +11 -13
  233. package/dist/types/enums.d.ts.map +1 -1
  234. package/dist/types/enums.js +5 -13
  235. package/dist/types/enums.js.map +1 -1
  236. package/dist/types/import-export.d.ts +7 -30
  237. package/dist/types/import-export.d.ts.map +1 -1
  238. package/dist/types/import-export.js +1 -2
  239. package/dist/types/import-export.js.map +1 -1
  240. package/dist/types/index.d.ts +18 -22
  241. package/dist/types/index.d.ts.map +1 -1
  242. package/dist/types/index.js +4 -32
  243. package/dist/types/index.js.map +1 -1
  244. package/dist/types/master-entities.d.ts +1 -10
  245. package/dist/types/master-entities.d.ts.map +1 -1
  246. package/dist/types/master-entities.js +1 -2
  247. package/dist/types/master-entities.js.map +1 -1
  248. package/dist/types/transaction-entities.d.ts +2 -21
  249. package/dist/types/transaction-entities.d.ts.map +1 -1
  250. package/dist/types/transaction-entities.js +1 -1
  251. package/dist/types/validation.d.ts +1 -16
  252. package/dist/types/validation.d.ts.map +1 -1
  253. package/dist/types/validation.js +1 -2
  254. package/dist/types/validation.js.map +1 -1
  255. package/dist/types/view-entities.d.ts +3 -12
  256. package/dist/types/view-entities.d.ts.map +1 -1
  257. package/dist/types/view-entities.js +1 -1
  258. package/dist/types.d.ts +4 -718
  259. package/dist/types.d.ts.map +1 -1
  260. package/dist/types.js +5 -39
  261. package/dist/types.js.map +1 -1
  262. package/dist/utils/parameter-validator.d.ts +2 -2
  263. package/dist/utils/parameter-validator.d.ts.map +1 -1
  264. package/dist/utils/parameter-validator.js.map +1 -1
  265. package/dist/utils/path-normalize.d.ts +23 -0
  266. package/dist/utils/path-normalize.d.ts.map +1 -0
  267. package/dist/utils/path-normalize.js +38 -0
  268. package/dist/utils/path-normalize.js.map +1 -0
  269. package/dist/utils/project-root.d.ts +6 -3
  270. package/dist/utils/project-root.d.ts.map +1 -1
  271. package/dist/utils/project-root.js +11 -3
  272. package/dist/utils/project-root.js.map +1 -1
  273. package/dist/watcher/base-watcher.d.ts +0 -4
  274. package/dist/watcher/base-watcher.d.ts.map +1 -1
  275. package/dist/watcher/base-watcher.js +11 -22
  276. package/dist/watcher/base-watcher.js.map +1 -1
  277. package/docs/CLI_USAGE.md +27 -107
  278. package/docs/CONFIGURATION.md +10 -5
  279. package/docs/DATABASE_AUTH.md +3 -3
  280. package/docs/HOOKS_GUIDE.md +40 -6
  281. package/docs/MIGRATION_TO_SAAS.md +2 -2
  282. package/docs/SHARED_DATABASE.md +108 -0
  283. package/package.json +4 -3
  284. package/dist/adapters/auth/auth-types.d.ts +0 -30
  285. package/dist/adapters/auth/auth-types.d.ts.map +0 -1
  286. package/dist/adapters/auth/auth-types.js +0 -30
  287. package/dist/adapters/auth/auth-types.js.map +0 -1
  288. package/dist/cli/db-dump.d.ts +0 -36
  289. package/dist/cli/db-dump.d.ts.map +0 -1
  290. package/dist/cli/db-dump.js +0 -384
  291. package/dist/cli/db-dump.js.map +0 -1
  292. package/dist/database/config/config-ops.d.ts +0 -42
  293. package/dist/database/config/config-ops.d.ts.map +0 -1
  294. package/dist/database/config/config-ops.js +0 -102
  295. package/dist/database/config/config-ops.js.map +0 -1
  296. package/dist/formatters/adr-formatter.d.ts +0 -22
  297. package/dist/formatters/adr-formatter.d.ts.map +0 -1
  298. package/dist/formatters/adr-formatter.js +0 -127
  299. package/dist/formatters/adr-formatter.js.map +0 -1
  300. package/dist/formatters/confluence-formatter.d.ts +0 -26
  301. package/dist/formatters/confluence-formatter.d.ts.map +0 -1
  302. package/dist/formatters/confluence-formatter.js +0 -129
  303. package/dist/formatters/confluence-formatter.js.map +0 -1
  304. package/dist/formatters/index.d.ts +0 -34
  305. package/dist/formatters/index.d.ts.map +0 -1
  306. package/dist/formatters/index.js +0 -57
  307. package/dist/formatters/index.js.map +0 -1
  308. package/dist/formatters/markdown-formatter.d.ts +0 -16
  309. package/dist/formatters/markdown-formatter.d.ts.map +0 -1
  310. package/dist/formatters/markdown-formatter.js +0 -110
  311. package/dist/formatters/markdown-formatter.js.map +0 -1
  312. package/dist/formatters/notion-formatter.d.ts +0 -29
  313. package/dist/formatters/notion-formatter.d.ts.map +0 -1
  314. package/dist/formatters/notion-formatter.js +0 -177
  315. package/dist/formatters/notion-formatter.js.map +0 -1
  316. package/dist/formatters/types.d.ts +0 -31
  317. package/dist/formatters/types.d.ts.map +0 -1
  318. package/dist/formatters/types.js +0 -6
  319. package/dist/formatters/types.js.map +0 -1
  320. package/dist/tests/database/sql-dump/converters.test.d.ts +0 -7
  321. package/dist/tests/database/sql-dump/converters.test.d.ts.map +0 -1
  322. package/dist/tests/database/sql-dump/converters.test.js +0 -314
  323. package/dist/tests/database/sql-dump/converters.test.js.map +0 -1
  324. package/dist/tests/database/sql-dump/default-conversions.test.d.ts +0 -8
  325. package/dist/tests/database/sql-dump/default-conversions.test.d.ts.map +0 -1
  326. package/dist/tests/database/sql-dump/default-conversions.test.js +0 -141
  327. package/dist/tests/database/sql-dump/default-conversions.test.js.map +0 -1
  328. package/dist/tests/database/sql-dump/table-ordering.test.d.ts +0 -27
  329. package/dist/tests/database/sql-dump/table-ordering.test.d.ts.map +0 -1
  330. package/dist/tests/database/sql-dump/table-ordering.test.js +0 -284
  331. package/dist/tests/database/sql-dump/table-ordering.test.js.map +0 -1
  332. package/dist/tests/database/sql-dump/type-conversion.test.d.ts +0 -8
  333. package/dist/tests/database/sql-dump/type-conversion.test.d.ts.map +0 -1
  334. package/dist/tests/database/sql-dump/type-conversion.test.js +0 -361
  335. package/dist/tests/database/sql-dump/type-conversion.test.js.map +0 -1
  336. package/dist/tests/docker/cross-database.test.d.ts +0 -21
  337. package/dist/tests/docker/cross-database.test.d.ts.map +0 -1
  338. package/dist/tests/docker/cross-database.test.js +0 -308
  339. package/dist/tests/docker/cross-database.test.js.map +0 -1
  340. package/dist/tests/docker/dump-import.test.d.ts +0 -15
  341. package/dist/tests/docker/dump-import.test.d.ts.map +0 -1
  342. package/dist/tests/docker/dump-import.test.js +0 -424
  343. package/dist/tests/docker/dump-import.test.js.map +0 -1
  344. package/dist/tests/docker/fk-constraints.test.d.ts +0 -13
  345. package/dist/tests/docker/fk-constraints.test.d.ts.map +0 -1
  346. package/dist/tests/docker/fk-constraints.test.js +0 -381
  347. package/dist/tests/docker/fk-constraints.test.js.map +0 -1
  348. package/dist/tests/docker/indexes.test.d.ts +0 -12
  349. package/dist/tests/docker/indexes.test.d.ts.map +0 -1
  350. package/dist/tests/docker/indexes.test.js +0 -250
  351. package/dist/tests/docker/indexes.test.js.map +0 -1
  352. package/dist/tests/docker/integration.test.d.ts +0 -16
  353. package/dist/tests/docker/integration.test.d.ts.map +0 -1
  354. package/dist/tests/docker/integration.test.js +0 -323
  355. package/dist/tests/docker/integration.test.js.map +0 -1
  356. package/dist/tests/docker/multi-project-migration.test.d.ts +0 -17
  357. package/dist/tests/docker/multi-project-migration.test.d.ts.map +0 -1
  358. package/dist/tests/docker/multi-project-migration.test.js +0 -394
  359. package/dist/tests/docker/multi-project-migration.test.js.map +0 -1
  360. package/dist/tests/docker/schema-migration.test.d.ts +0 -8
  361. package/dist/tests/docker/schema-migration.test.d.ts.map +0 -1
  362. package/dist/tests/docker/schema-migration.test.js +0 -98
  363. package/dist/tests/docker/schema-migration.test.js.map +0 -1
  364. package/dist/tests/integration/e2e-workflow1-debug.test.d.ts +0 -5
  365. package/dist/tests/integration/e2e-workflow1-debug.test.d.ts.map +0 -1
  366. package/dist/tests/integration/e2e-workflow1-debug.test.js +0 -85
  367. package/dist/tests/integration/e2e-workflow1-debug.test.js.map +0 -1
  368. package/dist/tests/integration/suggest-simple.test.d.ts +0 -5
  369. package/dist/tests/integration/suggest-simple.test.d.ts.map +0 -1
  370. package/dist/tests/integration/suggest-simple.test.js +0 -90
  371. package/dist/tests/integration/suggest-simple.test.js.map +0 -1
  372. package/dist/tests/migrations/test-all-versions-real.d.ts +0 -8
  373. package/dist/tests/migrations/test-all-versions-real.d.ts.map +0 -1
  374. package/dist/tests/migrations/test-all-versions-real.js +0 -236
  375. package/dist/tests/migrations/test-all-versions-real.js.map +0 -1
  376. package/dist/tests/migrations/test-all-versions.d.ts +0 -14
  377. package/dist/tests/migrations/test-all-versions.d.ts.map +0 -1
  378. package/dist/tests/migrations/test-all-versions.js +0 -519
  379. package/dist/tests/migrations/test-all-versions.js.map +0 -1
  380. package/dist/tests/migrations/v4/v4-fresh-install.test.d.ts +0 -7
  381. package/dist/tests/migrations/v4/v4-fresh-install.test.d.ts.map +0 -1
  382. package/dist/tests/migrations/v4/v4-fresh-install.test.js +0 -168
  383. package/dist/tests/migrations/v4/v4-fresh-install.test.js.map +0 -1
  384. package/dist/tests/migrations/v4/v4-migrate-data.test.d.ts +0 -13
  385. package/dist/tests/migrations/v4/v4-migrate-data.test.d.ts.map +0 -1
  386. package/dist/tests/migrations/v4/v4-migrate-data.test.js +0 -264
  387. package/dist/tests/migrations/v4/v4-migrate-data.test.js.map +0 -1
  388. package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts +0 -2
  389. package/dist/tests/unit/utils/case-insensitive-validator.test.d.ts.map +0 -1
  390. package/dist/tests/unit/utils/case-insensitive-validator.test.js +0 -97
  391. package/dist/tests/unit/utils/case-insensitive-validator.test.js.map +0 -1
  392. package/dist/tests/utils/json-export-import.test.d.ts.map +0 -1
  393. package/dist/tests/utils/json-export-import.test.js.map +0 -1
  394. package/dist/tests/utils/task-helpers.d.ts +0 -67
  395. package/dist/tests/utils/task-helpers.d.ts.map +0 -1
  396. package/dist/tests/utils/task-helpers.js +0 -134
  397. package/dist/tests/utils/task-helpers.js.map +0 -1
  398. package/dist/tools/context/actions/export.d.ts +0 -35
  399. package/dist/tools/context/actions/export.d.ts.map +0 -1
  400. package/dist/tools/context/actions/export.js +0 -93
  401. package/dist/tools/context/actions/export.js.map +0 -1
  402. package/dist/types/file/params.d.ts +0 -40
  403. package/dist/types/file/params.d.ts.map +0 -1
  404. package/dist/types/file/params.js +0 -6
  405. package/dist/types/file/params.js.map +0 -1
  406. package/dist/types/file/responses.d.ts +0 -2
  407. package/dist/types/file/responses.d.ts.map +0 -1
  408. package/dist/types/file/responses.js +0 -2
  409. package/dist/types/file/responses.js.map +0 -1
  410. package/dist/types/task/params.d.ts +0 -173
  411. package/dist/types/task/params.d.ts.map +0 -1
  412. package/dist/types/task/params.js +0 -8
  413. package/dist/types/task/params.js.map +0 -1
  414. package/dist/types/task/responses.d.ts +0 -334
  415. package/dist/types/task/responses.d.ts.map +0 -1
  416. package/dist/types/task/responses.js +0 -8
  417. package/dist/types/task/responses.js.map +0 -1
  418. package/dist/utils/sql-dump/core/dependency-sort.d.ts +0 -16
  419. package/dist/utils/sql-dump/core/dependency-sort.d.ts.map +0 -1
  420. package/dist/utils/sql-dump/core/dependency-sort.js +0 -105
  421. package/dist/utils/sql-dump/core/dependency-sort.js.map +0 -1
  422. package/dist/utils/sql-dump/core/generate-dump.d.ts +0 -13
  423. package/dist/utils/sql-dump/core/generate-dump.d.ts.map +0 -1
  424. package/dist/utils/sql-dump/core/generate-dump.js +0 -201
  425. package/dist/utils/sql-dump/core/generate-dump.js.map +0 -1
  426. package/dist/utils/sql-dump/core/index-export.d.ts +0 -10
  427. package/dist/utils/sql-dump/core/index-export.d.ts.map +0 -1
  428. package/dist/utils/sql-dump/core/index-export.js +0 -173
  429. package/dist/utils/sql-dump/core/index-export.js.map +0 -1
  430. package/dist/utils/sql-dump/core/sequence-reset.d.ts +0 -6
  431. package/dist/utils/sql-dump/core/sequence-reset.d.ts.map +0 -1
  432. package/dist/utils/sql-dump/core/sequence-reset.js +0 -28
  433. package/dist/utils/sql-dump/core/sequence-reset.js.map +0 -1
  434. package/dist/utils/sql-dump/core/table-export.d.ts +0 -2
  435. package/dist/utils/sql-dump/core/table-export.d.ts.map +0 -1
  436. package/dist/utils/sql-dump/core/table-export.js +0 -4
  437. package/dist/utils/sql-dump/core/table-export.js.map +0 -1
  438. package/dist/utils/sql-dump/core/view-export.d.ts +0 -2
  439. package/dist/utils/sql-dump/core/view-export.d.ts.map +0 -1
  440. package/dist/utils/sql-dump/core/view-export.js +0 -4
  441. package/dist/utils/sql-dump/core/view-export.js.map +0 -1
  442. package/dist/utils/sql-dump/formatters/bulk-insert.d.ts +0 -14
  443. package/dist/utils/sql-dump/formatters/bulk-insert.d.ts.map +0 -1
  444. package/dist/utils/sql-dump/formatters/bulk-insert.js +0 -177
  445. package/dist/utils/sql-dump/formatters/bulk-insert.js.map +0 -1
  446. package/dist/utils/sql-dump/formatters/identifiers.d.ts +0 -6
  447. package/dist/utils/sql-dump/formatters/identifiers.d.ts.map +0 -1
  448. package/dist/utils/sql-dump/formatters/identifiers.js +0 -16
  449. package/dist/utils/sql-dump/formatters/identifiers.js.map +0 -1
  450. package/dist/utils/sql-dump/formatters/value-formatter.d.ts +0 -14
  451. package/dist/utils/sql-dump/formatters/value-formatter.d.ts.map +0 -1
  452. package/dist/utils/sql-dump/formatters/value-formatter.js +0 -281
  453. package/dist/utils/sql-dump/formatters/value-formatter.js.map +0 -1
  454. package/dist/utils/sql-dump/generators/controls.d.ts +0 -10
  455. package/dist/utils/sql-dump/generators/controls.d.ts.map +0 -1
  456. package/dist/utils/sql-dump/generators/controls.js +0 -36
  457. package/dist/utils/sql-dump/generators/controls.js.map +0 -1
  458. package/dist/utils/sql-dump/generators/headers.d.ts +0 -6
  459. package/dist/utils/sql-dump/generators/headers.d.ts.map +0 -1
  460. package/dist/utils/sql-dump/generators/headers.js +0 -19
  461. package/dist/utils/sql-dump/generators/headers.js.map +0 -1
  462. package/dist/utils/sql-dump/index.d.ts +0 -14
  463. package/dist/utils/sql-dump/index.d.ts.map +0 -1
  464. package/dist/utils/sql-dump/index.js +0 -16
  465. package/dist/utils/sql-dump/index.js.map +0 -1
  466. package/dist/utils/sql-dump/schema/indexes.d.ts +0 -20
  467. package/dist/utils/sql-dump/schema/indexes.d.ts.map +0 -1
  468. package/dist/utils/sql-dump/schema/indexes.js +0 -108
  469. package/dist/utils/sql-dump/schema/indexes.js.map +0 -1
  470. package/dist/utils/sql-dump/schema/primary-keys.d.ts +0 -6
  471. package/dist/utils/sql-dump/schema/primary-keys.d.ts.map +0 -1
  472. package/dist/utils/sql-dump/schema/primary-keys.js +0 -41
  473. package/dist/utils/sql-dump/schema/primary-keys.js.map +0 -1
  474. package/dist/utils/sql-dump/schema/tables.d.ts +0 -15
  475. package/dist/utils/sql-dump/schema/tables.d.ts.map +0 -1
  476. package/dist/utils/sql-dump/schema/tables.js +0 -518
  477. package/dist/utils/sql-dump/schema/tables.js.map +0 -1
  478. package/dist/utils/sql-dump/schema/views.d.ts +0 -11
  479. package/dist/utils/sql-dump/schema/views.d.ts.map +0 -1
  480. package/dist/utils/sql-dump/schema/views.js +0 -116
  481. package/dist/utils/sql-dump/schema/views.js.map +0 -1
  482. package/dist/utils/sql-dump/types.d.ts +0 -10
  483. package/dist/utils/sql-dump/types.d.ts.map +0 -1
  484. package/dist/utils/sql-dump/types.js +0 -3
  485. package/dist/utils/sql-dump/types.js.map +0 -1
  486. package/dist/utils/sql-dump-converters.d.ts +0 -188
  487. package/dist/utils/sql-dump-converters.d.ts.map +0 -1
  488. package/dist/utils/sql-dump-converters.js +0 -315
  489. package/dist/utils/sql-dump-converters.js.map +0 -1
  490. package/dist/watcher/gitignore-parser.d.ts +0 -70
  491. package/dist/watcher/gitignore-parser.d.ts.map +0 -1
  492. package/dist/watcher/gitignore-parser.js +0 -195
  493. package/dist/watcher/gitignore-parser.js.map +0 -1
  494. package/dist/watcher/index.d.ts +0 -9
  495. package/dist/watcher/index.d.ts.map +0 -1
  496. package/dist/watcher/index.js +0 -8
  497. package/dist/watcher/index.js.map +0 -1
  498. /package/dist/tests/{utils → integration}/json-export-import.test.d.ts +0 -0
  499. /package/dist/tests/{utils → integration}/json-export-import.test.js +0 -0
package/CHANGELOG.md CHANGED
@@ -7,6 +7,62 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ---
9
9
 
10
+ ## [5.2.0] - 2026-06-11
11
+
12
+ ### Added
13
+
14
+ **Grok Build support (sqlew-plugin v5.2.0)**
15
+
16
+ Unified Plan-to-ADR support for Grok Build alongside Claude Code via a single sqlew-plugin install. No separate sqlew-grok adapter required.
17
+
18
+ - **`normalizeHookInput()`** — Translates Grok hook payloads (`hookEventName`, `toolName`, `sessionId`, `workspaceRoot`) to canonical Claude-shaped `HookInput`. Claude payloads pass through unchanged.
19
+ - **`computeGrokPlanPath()`** — Resolves per-session plan file at `~/.grok/sessions/<encodeURIComponent(cwd)>/<sessionId>/plan.md`.
20
+ - **`injectGrokPlanTemplate()`** — Appends Decision/Constraint template to `plan.md` on `enter_plan_mode` (file side-effect). Grok ignores passive hook stdout; skills auto-invocation is unreliable.
21
+ - **`GROK_WORKSPACE_ROOT`** — Added to `determineProjectRoot()` for MCP server project root resolution.
22
+ - **Grok `sendBlock()` compat** — PreToolUse deny hooks emit `{"decision":"deny","reason":"..."}` on stdout for Grok (in addition to exit 2 + stderr for Claude Code).
23
+ - **Unit tests** — `grok-hook-normalization.test.ts`, `grok-plan-template-injection.test.ts`.
24
+
25
+ ### Changed
26
+
27
+ - **`on-prompt`** — Early return for Grok client (`UserPromptSubmit` stdout is ignored on Grok).
28
+ - **`on-exit-plan` / `track-plan`** — Record `CurrentPlanInfo.plan_path` for Grok; always re-resolve from `session_id` on exit.
29
+ - **`plan-processor`** — Prefer explicit `plan_path` over legacy Claude global plans resolver.
30
+ - **`docs/HOOKS_GUIDE.md`** — Replaced sqlew-grok adapter instructions with `grok plugin install sqlew-io/sqlew-plugin --trust` workflow.
31
+
32
+ ### Plugin Changes (sqlew-plugin v5.2.0)
33
+
34
+ - Hook matchers: `enter_plan_mode` / `exit_plan_mode` alongside Claude tool names
35
+ - Skills: Grok-specific plan mode guidance (`sqlew-plan-guidance`, `sqlew-decision-format`)
36
+
37
+ ---
38
+
39
+ ## [5.1.0] - 2026-03-07
40
+
41
+ ### Changed
42
+
43
+ **📁 `.sqlew.env` relocated to `~/.config/sqlew/.sqlew.env`**
44
+
45
+ The cloud API key file (`~/.sqlew.env`) has been moved to `~/.config/sqlew/.sqlew.env` to align with the v5.1 unified global config path. Automatic migration copies the old file and deletes it (API key security: no stale copies). `saveCachedProjectId()` now calls `ensureGlobalConfigDir()` for directory safety.
46
+
47
+ **🔒 db:export Project Scope Auto-Detection (Security)**
48
+
49
+ `db:export` no longer exports all projects by default. With the global shared database (v5.1.0), the default "export everything" behavior risked leaking other projects' decision data.
50
+
51
+ - **Auto-detect**: Project name resolved from `.sqlew/config.toml` `[project].name` when no `project=` option is given
52
+ - **Explicit all**: `project=all` required to export all projects (escape hatch)
53
+ - **Error on ambiguity**: If no project name is found (no CLI arg, no config.toml), the command exits with an actionable error message
54
+ - **Breaking change**: Previously, omitting `project=` exported all projects silently
55
+
56
+ ### Resolution Priority
57
+
58
+ ```
59
+ 1. CLI argument: project=<name> (highest)
60
+ 2. config.toml: [project].name
61
+ 3. Error exit (lowest)
62
+ ```
63
+
64
+ ---
65
+
10
66
  ## [5.0.6] - 2026-02-14
11
67
 
12
68
  ### Changed
package/README.md CHANGED
@@ -58,6 +58,16 @@ The plugin automatically configures MCP server, Skills (Plan Mode guidance), and
58
58
 
59
59
  See [sqlew-codex](https://github.com/sqlew-io/sqlew-codex) for Codex CLI integration.
60
60
 
61
+ #### Grok Build (Plugin)
62
+
63
+ ```bash
64
+ npm install -g sqlew
65
+ grok plugin install sqlew-io/sqlew-plugin --trust
66
+ grok plugin update
67
+ ```
68
+
69
+ The plugin configures MCP server, Skills (plan mode guidance), and Hooks (automatic decision capture on `exit_plan_mode`). See [Hooks Guide](docs/HOOKS_GUIDE.md) for setup details and caveats (do not duplicate hooks in `~/.grok/hooks/` or `config.toml`).
70
+
61
71
  #### Manual
62
72
 
63
73
  Add to `.mcp.json` in your project root:
@@ -72,7 +82,7 @@ Add to `.mcp.json` in your project root:
72
82
  }
73
83
  ```
74
84
 
75
- The database (`.sqlew/sqlew.db`) and config (`.sqlew/config.toml`) are auto-created on first run.
85
+ The database (`~/.config/sqlew/sqlew-shared.db`) and config are auto-created on first run. See [Shared Database](docs/SHARED_DATABASE.md) for details.
76
86
 
77
87
  ### 3. Just use Plan Mode!
78
88
 
@@ -86,7 +96,7 @@ No special commands needed — just plan your work normally, and sqlew captures
86
96
  - **Fast Queries** — 2-50ms retrieval via SQL, even with thousands of decisions
87
97
  - **Duplicate Detection** — Three-tier similarity scoring (0-100) prevents redundant decisions
88
98
  - **Constraint Tracking** — Architectural rules and principles as first-class entities
89
- - **Auto-Capture** — Hooks automatically record decisions from Plan Mode (Claude Code plugin)
99
+ - **Auto-Capture** — Hooks automatically record decisions from Plan Mode (Claude Code and Grok Build via sqlew-plugin)
90
100
  - **Multi-Database** — SQLite (default), PostgreSQL, MySQL/MariaDB, or Cloud
91
101
  - **Git Worktree Ready** — Each worktree shares the same context database
92
102
 
@@ -99,7 +109,7 @@ Connect to [sqlew.io](https://sqlew.io) for team-shared decisions:
99
109
  Visit [sqlew.io](https://sqlew.io) and save your API key:
100
110
 
101
111
  ```bash
102
- # ~/.sqlew.env (shared across all projects)
112
+ # ~/.config/sqlew/.sqlew.env (shared across all projects)
103
113
  SQLEW_API_KEY=your-api-key
104
114
  ```
105
115
 
@@ -142,7 +152,7 @@ name = "your-project-name"
142
152
  |-------|-------------|
143
153
  | [ADR Concepts](docs/ADR_CONCEPTS.md) | Architecture Decision Records explained |
144
154
  | [Configuration](docs/CONFIGURATION.md) | Config file setup, database options |
145
- | [Hooks Guide](docs/HOOKS_GUIDE.md) | Claude Code Hooks integration |
155
+ | [Hooks Guide](docs/HOOKS_GUIDE.md) | Claude Code, Codex, and Grok Build integration |
146
156
  | [Cross Database](docs/CROSS_DATABASE.md) | Multi-database support |
147
157
  | [CLI Usage](docs/CLI_USAGE.md) | Database migration, export/import |
148
158
 
@@ -163,16 +173,15 @@ Support development via [GitHub Sponsors](https://github.com/sponsors/sqlew-io).
163
173
 
164
174
  ## Version
165
175
 
166
- Current version: **5.0.8**
176
+ Current version: **5.2.0**
167
177
 
168
178
  See [CHANGELOG.md](CHANGELOG.md) for release history.
169
179
 
170
- **What's New in v5.0.8:**
180
+ **What's New in v5.2.0:**
171
181
 
172
- - **PR ADR enforcement** — PreToolUse Hook blocks `gh pr create` without ADR markers, file-grouped format
173
- - **Codex CLI support** — Works beyond Claude Code via [sqlew-codex](https://github.com/sqlew-io/sqlew-codex)
174
- - **Plugin-first architecture** — Simplified setup via sqlew-plugin
175
- - **Cloud backend** — Connect to [sqlew.io](https://sqlew.io) for team-shared decisions
182
+ - **Grok Build support** — Plan-to-ADR via [sqlew-plugin](https://github.com/sqlew-io/sqlew-plugin) (`grok plugin install sqlew-io/sqlew-plugin --trust`)
183
+ - **Grok plan.md injection** — Decision/Constraint template appended on `enter_plan_mode`
184
+ - **Hook normalization** — Single CLI hook handlers work under both Claude Code and Grok Build
176
185
 
177
186
  ## License
178
187
 
@@ -1,86 +1,7 @@
1
- /**
2
- * @fileoverview Authentication Provider Factory
3
- *
4
- * Factory module for creating appropriate authentication providers based on database configuration.
5
- * Supports direct connections and future IAM-based authentication.
6
- *
7
- * **Note:** SSH tunneling is not supported. Users must set up SSH tunnels manually.
8
- *
9
- * @module adapters/auth/auth-factory
10
- */
11
1
  import { BaseAuthProvider } from './base-auth-provider.js';
12
2
  import type { DatabaseConfig } from '../../config/types.js';
13
- /**
14
- * Create an authentication provider based on database configuration.
15
- *
16
- * Provider selection logic:
17
- * - SQLite: Returns null (no authentication needed for file-based database)
18
- * - MySQL/PostgreSQL: Returns DirectAuthProvider
19
- *
20
- * @param config - Database configuration
21
- * @returns Authentication provider instance or null for SQLite
22
- * @throws Error if database type is invalid
23
- *
24
- * @example
25
- * // Direct connection
26
- * const config: DatabaseConfig = {
27
- * type: 'mysql',
28
- * connection: {
29
- * host: 'localhost',
30
- * port: 3306,
31
- * database: 'mydb'
32
- * },
33
- * auth: {
34
- * type: 'direct',
35
- * user: 'dbuser',
36
- * password: 'dbpass'
37
- * }
38
- * };
39
- * const provider = createAuthProvider(config);
40
- * // Returns DirectAuthProvider instance
41
- *
42
- * @example
43
- * // Connection via manual SSH tunnel
44
- * // Step 1: Set up tunnel manually:
45
- * // ssh -L 3307:db.internal.company.com:3306 user@bastion.example.com
46
- * // Step 2: Configure to use localhost:
47
- * const config: DatabaseConfig = {
48
- * type: 'mysql',
49
- * connection: {
50
- * host: 'localhost', // Tunnel endpoint
51
- * port: 3307, // Forwarded port
52
- * database: 'mydb'
53
- * },
54
- * auth: {
55
- * type: 'direct',
56
- * user: 'dbuser',
57
- * password: 'dbpass'
58
- * }
59
- * };
60
- * const provider = createAuthProvider(config);
61
- * // Returns DirectAuthProvider for localhost connection
62
- *
63
- * @example
64
- * // SQLite (no authentication)
65
- * const sqliteConfig: DatabaseConfig = {
66
- * type: 'sqlite',
67
- * path: './data.db'
68
- * };
69
- * const provider = createAuthProvider(sqliteConfig);
70
- * // Returns null
71
- */
3
+ /** Create an authentication provider based on database configuration. */
72
4
  export declare function createAuthProvider(config: DatabaseConfig): BaseAuthProvider | null;
73
- /**
74
- * Check if database type requires authentication.
75
- *
76
- * @param config - Database configuration
77
- * @returns True if authentication is required (MySQL/PostgreSQL)
78
- *
79
- * @example
80
- * if (requiresAuthentication(config)) {
81
- * const provider = createAuthProvider(config);
82
- * await provider!.authenticate();
83
- * }
84
- */
5
+ /** Check if database type requires authentication. */
85
6
  export declare function requiresAuthentication(config: DatabaseConfig): boolean;
86
7
  //# sourceMappingURL=auth-factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth-factory.d.ts","sourceRoot":"","sources":["../../../src/adapters/auth/auth-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG,IAAI,CAmBlF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEtE"}
1
+ {"version":3,"file":"auth-factory.d.ts","sourceRoot":"","sources":["../../../src/adapters/auth/auth-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,yEAAyE;AACzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,gBAAgB,GAAG,IAAI,CAkBlF;AAED,sDAAsD;AACtD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAEtE"}
@@ -1,73 +1,5 @@
1
- /**
2
- * @fileoverview Authentication Provider Factory
3
- *
4
- * Factory module for creating appropriate authentication providers based on database configuration.
5
- * Supports direct connections and future IAM-based authentication.
6
- *
7
- * **Note:** SSH tunneling is not supported. Users must set up SSH tunnels manually.
8
- *
9
- * @module adapters/auth/auth-factory
10
- */
11
1
  import { DirectAuthProvider } from './direct-auth-provider.js';
12
- /**
13
- * Create an authentication provider based on database configuration.
14
- *
15
- * Provider selection logic:
16
- * - SQLite: Returns null (no authentication needed for file-based database)
17
- * - MySQL/PostgreSQL: Returns DirectAuthProvider
18
- *
19
- * @param config - Database configuration
20
- * @returns Authentication provider instance or null for SQLite
21
- * @throws Error if database type is invalid
22
- *
23
- * @example
24
- * // Direct connection
25
- * const config: DatabaseConfig = {
26
- * type: 'mysql',
27
- * connection: {
28
- * host: 'localhost',
29
- * port: 3306,
30
- * database: 'mydb'
31
- * },
32
- * auth: {
33
- * type: 'direct',
34
- * user: 'dbuser',
35
- * password: 'dbpass'
36
- * }
37
- * };
38
- * const provider = createAuthProvider(config);
39
- * // Returns DirectAuthProvider instance
40
- *
41
- * @example
42
- * // Connection via manual SSH tunnel
43
- * // Step 1: Set up tunnel manually:
44
- * // ssh -L 3307:db.internal.company.com:3306 user@bastion.example.com
45
- * // Step 2: Configure to use localhost:
46
- * const config: DatabaseConfig = {
47
- * type: 'mysql',
48
- * connection: {
49
- * host: 'localhost', // Tunnel endpoint
50
- * port: 3307, // Forwarded port
51
- * database: 'mydb'
52
- * },
53
- * auth: {
54
- * type: 'direct',
55
- * user: 'dbuser',
56
- * password: 'dbpass'
57
- * }
58
- * };
59
- * const provider = createAuthProvider(config);
60
- * // Returns DirectAuthProvider for localhost connection
61
- *
62
- * @example
63
- * // SQLite (no authentication)
64
- * const sqliteConfig: DatabaseConfig = {
65
- * type: 'sqlite',
66
- * path: './data.db'
67
- * };
68
- * const provider = createAuthProvider(sqliteConfig);
69
- * // Returns null
70
- */
2
+ /** Create an authentication provider based on database configuration. */
71
3
  export function createAuthProvider(config) {
72
4
  // Validate database type
73
5
  if (!config.type) {
@@ -82,21 +14,9 @@ export function createAuthProvider(config) {
82
14
  return null;
83
15
  }
84
16
  // MySQL/PostgreSQL use direct authentication
85
- // (Users must set up SSH tunnels manually if needed)
86
17
  return new DirectAuthProvider(config);
87
18
  }
88
- /**
89
- * Check if database type requires authentication.
90
- *
91
- * @param config - Database configuration
92
- * @returns True if authentication is required (MySQL/PostgreSQL)
93
- *
94
- * @example
95
- * if (requiresAuthentication(config)) {
96
- * const provider = createAuthProvider(config);
97
- * await provider!.authenticate();
98
- * }
99
- */
19
+ /** Check if database type requires authentication. */
100
20
  export function requiresAuthentication(config) {
101
21
  return config.type !== 'sqlite';
102
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auth-factory.js","sourceRoot":"","sources":["../../../src/adapters/auth/auth-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,yBAAyB;IACzB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,IAAI,qBAAqB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,kDAAkD;IAClD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,qDAAqD;IACrD,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC"}
1
+ {"version":3,"file":"auth-factory.js","sourceRoot":"","sources":["../../../src/adapters/auth/auth-factory.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAG/D,yEAAyE;AACzE,MAAM,UAAU,kBAAkB,CAAC,MAAsB;IACvD,yBAAyB;IACzB,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAChE,CAAC;IAED,MAAM,UAAU,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;IACnD,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,0BAA0B,MAAM,CAAC,IAAI,qBAAqB,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrG,CAAC;IAED,kDAAkD;IAClD,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,6CAA6C;IAC7C,OAAO,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;AACxC,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,sBAAsB,CAAC,MAAsB;IAC3D,OAAO,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC"}
@@ -1,327 +1,42 @@
1
- /**
2
- * @fileoverview Base authentication provider for sqlew's multi-RDBMS authentication system.
3
- *
4
- * This module provides the foundation for all authentication providers, enabling support for:
5
- * - SSH tunneling (v3.7.0)
6
- * - Direct connections (v3.7.0)
7
- * - AWS IAM authentication (v3.8.0+)
8
- * - GCP IAM authentication (v3.8.0+)
9
- *
10
- * @module adapters/auth/base-auth-provider
11
- * @since v3.7.0
12
- */
13
1
  import type { DatabaseConfig } from '../../config/types.js';
14
- /**
15
- * Connection parameters used to establish database connections.
16
- *
17
- * These parameters are returned by authentication providers after processing
18
- * credentials, setting up tunnels, or obtaining temporary tokens.
19
- *
20
- * @interface ConnectionParams
21
- * @example
22
- * // Direct connection
23
- * {
24
- * host: 'postgres.example.com',
25
- * port: 5432,
26
- * database: 'mydb',
27
- * user: 'admin',
28
- * password: 'secret123'
29
- * }
30
- *
31
- * @example
32
- * // SSH tunnel connection
33
- * {
34
- * host: '127.0.0.1',
35
- * port: 54321, // Local tunnel port
36
- * database: 'mydb',
37
- * user: 'admin',
38
- * password: 'secret123'
39
- * }
40
- *
41
- * @example
42
- * // AWS IAM authentication
43
- * {
44
- * host: 'db.region.rds.amazonaws.com',
45
- * port: 5432,
46
- * database: 'mydb',
47
- * user: 'iam_user',
48
- * password: 'temporary_token_generated_by_aws',
49
- * ssl: {
50
- * ca: '/path/to/rds-ca-bundle.pem',
51
- * rejectUnauthorized: true
52
- * }
53
- * }
54
- */
2
+ /** Connection parameters returned by authentication providers. */
55
3
  export interface ConnectionParams {
56
- /**
57
- * Database host address.
58
- * For direct connections: remote host address.
59
- * For SSH tunnels: '127.0.0.1' (localhost).
60
- * For cloud IAM: cloud provider's database endpoint.
61
- */
4
+ /** Database host address. */
62
5
  host: string;
63
- /**
64
- * Database port number.
65
- * For direct connections: remote database port.
66
- * For SSH tunnels: local tunnel port.
67
- * For cloud IAM: cloud provider's database port.
68
- */
6
+ /** Database port number. */
69
7
  port: number;
70
- /**
71
- * Target database name.
72
- */
8
+ /** Target database name. */
73
9
  database: string;
74
- /**
75
- * Database user/username.
76
- * For IAM authentication: IAM role or user identifier.
77
- */
10
+ /** Database user/username. */
78
11
  user: string;
79
- /**
80
- * Database password or authentication token.
81
- * Optional for IAM-based authentication where tokens are generated dynamically.
82
- * For AWS/GCP IAM: temporary authentication token.
83
- */
12
+ /** Database password or authentication token. */
84
13
  password?: string;
85
- /**
86
- * SSL/TLS configuration for encrypted connections.
87
- * Required for most cloud providers (AWS RDS, GCP Cloud SQL).
88
- */
14
+ /** SSL/TLS configuration for encrypted connections. */
89
15
  ssl?: {
90
- /**
91
- * Certificate Authority (CA) certificate.
92
- * Path to PEM file or certificate content.
93
- */
16
+ /** Certificate Authority (CA) certificate. */
94
17
  ca?: string;
95
- /**
96
- * Client certificate for mutual TLS.
97
- * Path to PEM file or certificate content.
98
- */
18
+ /** Client certificate for mutual TLS. */
99
19
  cert?: string;
100
- /**
101
- * Client private key for mutual TLS.
102
- * Path to PEM file or key content.
103
- */
20
+ /** Client private key for mutual TLS. */
104
21
  key?: string;
105
- /**
106
- * Whether to reject unauthorized certificates.
107
- * Set to false for self-signed certificates (not recommended for production).
108
- */
22
+ /** Whether to reject unauthorized certificates. */
109
23
  rejectUnauthorized?: boolean;
110
24
  };
111
- /**
112
- * Database-specific connection parameters.
113
- *
114
- * Examples:
115
- * - PostgreSQL: { statement_timeout: 30000, application_name: 'mcp-sqlew' }
116
- * - MySQL: { connectTimeout: 10000, multipleStatements: false }
117
- * - SQL Server: { requestTimeout: 30000, encrypt: true }
118
- */
25
+ /** Database-specific additional connection parameters. */
119
26
  additionalParams?: Record<string, any>;
120
27
  }
121
- /**
122
- * Abstract base class for all authentication providers.
123
- *
124
- * This class establishes the contract that all authentication providers must implement,
125
- * ensuring consistent behavior across different authentication methods.
126
- *
127
- * **Supported Authentication Methods:**
128
- * - `DirectAuthProvider`: Standard username/password authentication
129
- * - `SshAuthProvider`: SSH tunneling with key-based or password authentication
130
- * - `AwsIamAuthProvider`: AWS RDS IAM database authentication
131
- * - `GcpIamAuthProvider`: GCP Cloud SQL IAM authentication
132
- *
133
- * **Authentication Flow:**
134
- * 1. Provider instantiation with DatabaseConfig
135
- * 2. `validate()` - Verify configuration is valid
136
- * 3. `authenticate()` - Process credentials and return ConnectionParams
137
- * 4. Database connection using returned params
138
- * 5. `cleanup()` - Release resources when connection closes
139
- *
140
- * @abstract
141
- * @class BaseAuthProvider
142
- *
143
- * @example
144
- * // Implementing a custom authentication provider
145
- * class CustomAuthProvider extends BaseAuthProvider {
146
- * async authenticate(): Promise<ConnectionParams> {
147
- * // Implement custom authentication logic
148
- * return {
149
- * host: this.config.connection.host,
150
- * port: this.config.connection.port,
151
- * database: this.config.connection.database,
152
- * user: this.config.auth.user,
153
- * password: await this.getCustomPassword()
154
- * };
155
- * }
156
- *
157
- * getAuthMethod(): string {
158
- * return 'Custom Authentication';
159
- * }
160
- *
161
- * async cleanup(): Promise<void> {
162
- * // Clean up any resources
163
- * }
164
- *
165
- * validate(): void {
166
- * if (!this.config.auth.user) {
167
- * throw new Error('User is required for custom authentication');
168
- * }
169
- * }
170
- * }
171
- *
172
- * @example
173
- * // Using an authentication provider
174
- * const provider = new DirectAuthProvider(config);
175
- * provider.validate();
176
- * const connParams = await provider.authenticate();
177
- * const connection = await createConnection(connParams);
178
- * // ... use connection ...
179
- * await connection.close();
180
- * await provider.cleanup();
181
- */
28
+ /** Abstract base class for all authentication providers. */
182
29
  export declare abstract class BaseAuthProvider {
183
- /**
184
- * Database configuration containing connection and authentication settings.
185
- * Accessible to child classes for implementing authentication logic.
186
- *
187
- * @protected
188
- * @readonly
189
- */
30
+ /** @protected */
190
31
  protected readonly config: DatabaseConfig;
191
- /**
192
- * Creates a new authentication provider instance.
193
- *
194
- * @param {DatabaseConfig} config - Database configuration object
195
- *
196
- * @example
197
- * const provider = new SshAuthProvider({
198
- * type: 'postgres',
199
- * connection: {
200
- * host: 'db.internal',
201
- * port: 5432,
202
- * database: 'production'
203
- * },
204
- * auth: {
205
- * type: 'ssh',
206
- * ssh: {
207
- * host: 'bastion.example.com',
208
- * port: 22,
209
- * user: 'deploy',
210
- * privateKey: '/path/to/key.pem'
211
- * }
212
- * }
213
- * });
214
- */
215
32
  constructor(config: DatabaseConfig);
216
- /**
217
- * Authenticates and returns connection parameters for database connection.
218
- *
219
- * This method handles the authentication process specific to each provider:
220
- * - **Direct**: Returns credentials as-is
221
- * - **SSH**: Establishes tunnel, returns localhost connection params
222
- * - **AWS IAM**: Generates temporary token, returns params with SSL config
223
- * - **GCP IAM**: Obtains OAuth token, returns params with cloud SQL proxy
224
- *
225
- * @abstract
226
- * @returns {Promise<ConnectionParams>} Connection parameters for database client
227
- *
228
- * @throws {Error} When authentication fails or credentials are invalid
229
- *
230
- * @example
231
- * // Direct authentication
232
- * const params = await directProvider.authenticate();
233
- * // Returns: { host: 'db.example.com', port: 5432, user: 'admin', password: 'secret' }
234
- *
235
- * @example
236
- * // SSH tunnel authentication
237
- * const params = await sshProvider.authenticate();
238
- * // Returns: { host: '127.0.0.1', port: 54321, user: 'admin', password: 'secret' }
239
- * // Note: Tunnel is active until cleanup() is called
240
- *
241
- * @example
242
- * // AWS IAM authentication
243
- * const params = await awsProvider.authenticate();
244
- * // Returns: { host: 'db.region.rds.amazonaws.com', user: 'iam_user',
245
- * // password: 'temp_token_xyz', ssl: { ca: '...' } }
246
- */
33
+ /** Authenticates and returns connection parameters. @abstract */
247
34
  abstract authenticate(): Promise<ConnectionParams>;
248
- /**
249
- * Returns a human-readable name for this authentication method.
250
- *
251
- * Used for logging, error messages, and telemetry.
252
- *
253
- * @abstract
254
- * @returns {string} Authentication method name
255
- *
256
- * @example
257
- * directProvider.getAuthMethod(); // Returns: "Direct"
258
- * sshProvider.getAuthMethod(); // Returns: "SSH Tunnel"
259
- * awsProvider.getAuthMethod(); // Returns: "AWS IAM"
260
- * gcpProvider.getAuthMethod(); // Returns: "GCP IAM"
261
- */
35
+ /** Returns a human-readable name for this authentication method. @abstract */
262
36
  abstract getAuthMethod(): string;
263
- /**
264
- * Releases resources allocated during authentication.
265
- *
266
- * This method MUST be called when the database connection is closed to prevent
267
- * resource leaks. Different providers handle cleanup differently:
268
- *
269
- * - **Direct**: No-op (no resources to clean)
270
- * - **SSH**: Closes SSH tunnel and releases local port
271
- * - **AWS IAM**: Invalidates cached tokens (if applicable)
272
- * - **GCP IAM**: Closes Cloud SQL proxy connection
273
- *
274
- * @abstract
275
- * @returns {Promise<void>}
276
- *
277
- * @throws {Error} If cleanup fails (should be caught and logged, not propagated)
278
- *
279
- * @example
280
- * try {
281
- * await provider.cleanup();
282
- * } catch (error) {
283
- * console.error('Cleanup failed:', error);
284
- * // Connection is closed, log error but don't throw
285
- * }
286
- */
37
+ /** Releases resources allocated during authentication. @abstract */
287
38
  abstract cleanup(): Promise<void>;
288
- /**
289
- * Validates the authentication configuration.
290
- *
291
- * This method checks that all required configuration parameters are present
292
- * and valid BEFORE attempting authentication. It should be called immediately
293
- * after provider instantiation to fail fast on configuration errors.
294
- *
295
- * **Validation Examples:**
296
- * - **Direct**: Verify host, port, user, password are present
297
- * - **SSH**: Verify SSH host, SSH user, privateKey/password, target credentials
298
- * - **AWS IAM**: Verify region, IAM role/user, AWS credentials available
299
- * - **GCP IAM**: Verify project ID, service account, GCP credentials available
300
- *
301
- * @abstract
302
- * @returns {void}
303
- *
304
- * @throws {Error} If configuration is invalid or incomplete
305
- *
306
- * @example
307
- * try {
308
- * provider.validate();
309
- * } catch (error) {
310
- * console.error('Invalid configuration:', error.message);
311
- * // Fix configuration before proceeding
312
- * }
313
- *
314
- * @example
315
- * // Validation in SSH provider
316
- * validate(): void {
317
- * if (!this.config.auth.ssh?.host) {
318
- * throw new Error('SSH host is required for SSH authentication');
319
- * }
320
- * if (!this.config.auth.ssh.privateKey && !this.config.auth.ssh.password) {
321
- * throw new Error('SSH privateKey or password is required');
322
- * }
323
- * }
324
- */
39
+ /** Validates the authentication configuration. @abstract */
325
40
  abstract validate(): void;
326
41
  }
327
42
  //# sourceMappingURL=base-auth-provider.d.ts.map