narai-primitives 2.0.0-rc.1

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 (440) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +64 -0
  3. package/dist/config/bootstrap.d.ts +28 -0
  4. package/dist/config/bootstrap.d.ts.map +1 -0
  5. package/dist/config/bootstrap.js +80 -0
  6. package/dist/config/bootstrap.js.map +1 -0
  7. package/dist/config/index.d.ts +13 -0
  8. package/dist/config/index.d.ts.map +1 -0
  9. package/dist/config/index.js +12 -0
  10. package/dist/config/index.js.map +1 -0
  11. package/dist/config/load.d.ts +37 -0
  12. package/dist/config/load.d.ts.map +1 -0
  13. package/dist/config/load.js +99 -0
  14. package/dist/config/load.js.map +1 -0
  15. package/dist/config/resolve.d.ts +23 -0
  16. package/dist/config/resolve.d.ts.map +1 -0
  17. package/dist/config/resolve.js +198 -0
  18. package/dist/config/resolve.js.map +1 -0
  19. package/dist/config/secrets.d.ts +20 -0
  20. package/dist/config/secrets.d.ts.map +1 -0
  21. package/dist/config/secrets.js +43 -0
  22. package/dist/config/secrets.js.map +1 -0
  23. package/dist/config/types.d.ts +104 -0
  24. package/dist/config/types.d.ts.map +1 -0
  25. package/dist/config/types.js +11 -0
  26. package/dist/config/types.js.map +1 -0
  27. package/dist/connectors/aws/cli.d.ts +3 -0
  28. package/dist/connectors/aws/cli.d.ts.map +1 -0
  29. package/dist/connectors/aws/cli.js +27 -0
  30. package/dist/connectors/aws/cli.js.map +1 -0
  31. package/dist/connectors/aws/index.d.ts +27 -0
  32. package/dist/connectors/aws/index.d.ts.map +1 -0
  33. package/dist/connectors/aws/index.js +281 -0
  34. package/dist/connectors/aws/index.js.map +1 -0
  35. package/dist/connectors/aws/lib/aws_client.d.ts +140 -0
  36. package/dist/connectors/aws/lib/aws_client.d.ts.map +1 -0
  37. package/dist/connectors/aws/lib/aws_client.js +196 -0
  38. package/dist/connectors/aws/lib/aws_client.js.map +1 -0
  39. package/dist/connectors/aws/lib/aws_error.d.ts +10 -0
  40. package/dist/connectors/aws/lib/aws_error.d.ts.map +1 -0
  41. package/dist/connectors/aws/lib/aws_error.js +15 -0
  42. package/dist/connectors/aws/lib/aws_error.js.map +1 -0
  43. package/dist/connectors/confluence/cli.d.ts +3 -0
  44. package/dist/connectors/confluence/cli.d.ts.map +1 -0
  45. package/dist/connectors/confluence/cli.js +24 -0
  46. package/dist/connectors/confluence/cli.js.map +1 -0
  47. package/dist/connectors/confluence/index.d.ts +15 -0
  48. package/dist/connectors/confluence/index.d.ts.map +1 -0
  49. package/dist/connectors/confluence/index.js +295 -0
  50. package/dist/connectors/confluence/index.js.map +1 -0
  51. package/dist/connectors/confluence/lib/confluence_client.d.ts +135 -0
  52. package/dist/connectors/confluence/lib/confluence_client.d.ts.map +1 -0
  53. package/dist/connectors/confluence/lib/confluence_client.js +329 -0
  54. package/dist/connectors/confluence/lib/confluence_client.js.map +1 -0
  55. package/dist/connectors/confluence/lib/confluence_error.d.ts +13 -0
  56. package/dist/connectors/confluence/lib/confluence_error.d.ts.map +1 -0
  57. package/dist/connectors/confluence/lib/confluence_error.js +19 -0
  58. package/dist/connectors/confluence/lib/confluence_error.js.map +1 -0
  59. package/dist/connectors/db/cli.d.ts +5 -0
  60. package/dist/connectors/db/cli.d.ts.map +1 -0
  61. package/dist/connectors/db/cli.js +34 -0
  62. package/dist/connectors/db/cli.js.map +1 -0
  63. package/dist/connectors/db/config.d.ts +18 -0
  64. package/dist/connectors/db/config.d.ts.map +1 -0
  65. package/dist/connectors/db/config.js +142 -0
  66. package/dist/connectors/db/config.js.map +1 -0
  67. package/dist/connectors/db/connector.d.ts +31 -0
  68. package/dist/connectors/db/connector.d.ts.map +1 -0
  69. package/dist/connectors/db/connector.js +175 -0
  70. package/dist/connectors/db/connector.js.map +1 -0
  71. package/dist/connectors/db/dispatcher.d.ts +36 -0
  72. package/dist/connectors/db/dispatcher.d.ts.map +1 -0
  73. package/dist/connectors/db/dispatcher.js +597 -0
  74. package/dist/connectors/db/dispatcher.js.map +1 -0
  75. package/dist/connectors/db/index.d.ts +22 -0
  76. package/dist/connectors/db/index.d.ts.map +1 -0
  77. package/dist/connectors/db/index.js +26 -0
  78. package/dist/connectors/db/index.js.map +1 -0
  79. package/dist/connectors/db/lib/audit.d.ts +32 -0
  80. package/dist/connectors/db/lib/audit.d.ts.map +1 -0
  81. package/dist/connectors/db/lib/audit.js +130 -0
  82. package/dist/connectors/db/lib/audit.js.map +1 -0
  83. package/dist/connectors/db/lib/connection.d.ts +61 -0
  84. package/dist/connectors/db/lib/connection.d.ts.map +1 -0
  85. package/dist/connectors/db/lib/connection.js +326 -0
  86. package/dist/connectors/db/lib/connection.js.map +1 -0
  87. package/dist/connectors/db/lib/credentials.d.ts +60 -0
  88. package/dist/connectors/db/lib/credentials.d.ts.map +1 -0
  89. package/dist/connectors/db/lib/credentials.js +117 -0
  90. package/dist/connectors/db/lib/credentials.js.map +1 -0
  91. package/dist/connectors/db/lib/drivers/base.d.ts +83 -0
  92. package/dist/connectors/db/lib/drivers/base.d.ts.map +1 -0
  93. package/dist/connectors/db/lib/drivers/base.js +46 -0
  94. package/dist/connectors/db/lib/drivers/base.js.map +1 -0
  95. package/dist/connectors/db/lib/drivers/dynamodb.d.ts +108 -0
  96. package/dist/connectors/db/lib/drivers/dynamodb.d.ts.map +1 -0
  97. package/dist/connectors/db/lib/drivers/dynamodb.js +468 -0
  98. package/dist/connectors/db/lib/drivers/dynamodb.js.map +1 -0
  99. package/dist/connectors/db/lib/drivers/mongodb.d.ts +60 -0
  100. package/dist/connectors/db/lib/drivers/mongodb.d.ts.map +1 -0
  101. package/dist/connectors/db/lib/drivers/mongodb.js +371 -0
  102. package/dist/connectors/db/lib/drivers/mongodb.js.map +1 -0
  103. package/dist/connectors/db/lib/drivers/mysql.d.ts +45 -0
  104. package/dist/connectors/db/lib/drivers/mysql.d.ts.map +1 -0
  105. package/dist/connectors/db/lib/drivers/mysql.js +265 -0
  106. package/dist/connectors/db/lib/drivers/mysql.js.map +1 -0
  107. package/dist/connectors/db/lib/drivers/oracle.d.ts +53 -0
  108. package/dist/connectors/db/lib/drivers/oracle.d.ts.map +1 -0
  109. package/dist/connectors/db/lib/drivers/oracle.js +350 -0
  110. package/dist/connectors/db/lib/drivers/oracle.js.map +1 -0
  111. package/dist/connectors/db/lib/drivers/postgresql.d.ts +65 -0
  112. package/dist/connectors/db/lib/drivers/postgresql.d.ts.map +1 -0
  113. package/dist/connectors/db/lib/drivers/postgresql.js +294 -0
  114. package/dist/connectors/db/lib/drivers/postgresql.js.map +1 -0
  115. package/dist/connectors/db/lib/drivers/register.d.ts +16 -0
  116. package/dist/connectors/db/lib/drivers/register.d.ts.map +1 -0
  117. package/dist/connectors/db/lib/drivers/register.js +111 -0
  118. package/dist/connectors/db/lib/drivers/register.js.map +1 -0
  119. package/dist/connectors/db/lib/drivers/sqlite.d.ts +11 -0
  120. package/dist/connectors/db/lib/drivers/sqlite.d.ts.map +1 -0
  121. package/dist/connectors/db/lib/drivers/sqlite.js +147 -0
  122. package/dist/connectors/db/lib/drivers/sqlite.js.map +1 -0
  123. package/dist/connectors/db/lib/drivers/sqlserver.d.ts +58 -0
  124. package/dist/connectors/db/lib/drivers/sqlserver.d.ts.map +1 -0
  125. package/dist/connectors/db/lib/drivers/sqlserver.js +274 -0
  126. package/dist/connectors/db/lib/drivers/sqlserver.js.map +1 -0
  127. package/dist/connectors/db/lib/environments.d.ts +68 -0
  128. package/dist/connectors/db/lib/environments.d.ts.map +1 -0
  129. package/dist/connectors/db/lib/environments.js +53 -0
  130. package/dist/connectors/db/lib/environments.js.map +1 -0
  131. package/dist/connectors/db/lib/index.d.ts +28 -0
  132. package/dist/connectors/db/lib/index.d.ts.map +1 -0
  133. package/dist/connectors/db/lib/index.js +30 -0
  134. package/dist/connectors/db/lib/index.js.map +1 -0
  135. package/dist/connectors/db/lib/plugin_config.d.ts +64 -0
  136. package/dist/connectors/db/lib/plugin_config.d.ts.map +1 -0
  137. package/dist/connectors/db/lib/plugin_config.js +287 -0
  138. package/dist/connectors/db/lib/plugin_config.js.map +1 -0
  139. package/dist/connectors/db/lib/policy.d.ts +162 -0
  140. package/dist/connectors/db/lib/policy.d.ts.map +1 -0
  141. package/dist/connectors/db/lib/policy.js +581 -0
  142. package/dist/connectors/db/lib/policy.js.map +1 -0
  143. package/dist/connectors/db/lib/query.d.ts +22 -0
  144. package/dist/connectors/db/lib/query.d.ts.map +1 -0
  145. package/dist/connectors/db/lib/query.js +93 -0
  146. package/dist/connectors/db/lib/query.js.map +1 -0
  147. package/dist/connectors/db/lib/schema.d.ts +13 -0
  148. package/dist/connectors/db/lib/schema.d.ts.map +1 -0
  149. package/dist/connectors/db/lib/schema.js +80 -0
  150. package/dist/connectors/db/lib/schema.js.map +1 -0
  151. package/dist/connectors/gcp/cli.d.ts +3 -0
  152. package/dist/connectors/gcp/cli.d.ts.map +1 -0
  153. package/dist/connectors/gcp/cli.js +24 -0
  154. package/dist/connectors/gcp/cli.js.map +1 -0
  155. package/dist/connectors/gcp/index.d.ts +24 -0
  156. package/dist/connectors/gcp/index.d.ts.map +1 -0
  157. package/dist/connectors/gcp/index.js +205 -0
  158. package/dist/connectors/gcp/index.js.map +1 -0
  159. package/dist/connectors/gcp/lib/gcp_client.d.ts +88 -0
  160. package/dist/connectors/gcp/lib/gcp_client.d.ts.map +1 -0
  161. package/dist/connectors/gcp/lib/gcp_client.js +434 -0
  162. package/dist/connectors/gcp/lib/gcp_client.js.map +1 -0
  163. package/dist/connectors/gcp/lib/gcp_error.d.ts +10 -0
  164. package/dist/connectors/gcp/lib/gcp_error.d.ts.map +1 -0
  165. package/dist/connectors/gcp/lib/gcp_error.js +15 -0
  166. package/dist/connectors/gcp/lib/gcp_error.js.map +1 -0
  167. package/dist/connectors/github/cli.d.ts +3 -0
  168. package/dist/connectors/github/cli.d.ts.map +1 -0
  169. package/dist/connectors/github/cli.js +23 -0
  170. package/dist/connectors/github/cli.js.map +1 -0
  171. package/dist/connectors/github/index.d.ts +23 -0
  172. package/dist/connectors/github/index.d.ts.map +1 -0
  173. package/dist/connectors/github/index.js +462 -0
  174. package/dist/connectors/github/index.js.map +1 -0
  175. package/dist/connectors/github/lib/github_client.d.ts +181 -0
  176. package/dist/connectors/github/lib/github_client.d.ts.map +1 -0
  177. package/dist/connectors/github/lib/github_client.js +383 -0
  178. package/dist/connectors/github/lib/github_client.js.map +1 -0
  179. package/dist/connectors/github/lib/github_error.d.ts +11 -0
  180. package/dist/connectors/github/lib/github_error.d.ts.map +1 -0
  181. package/dist/connectors/github/lib/github_error.js +17 -0
  182. package/dist/connectors/github/lib/github_error.js.map +1 -0
  183. package/dist/connectors/jira/cli.d.ts +3 -0
  184. package/dist/connectors/jira/cli.d.ts.map +1 -0
  185. package/dist/connectors/jira/cli.js +24 -0
  186. package/dist/connectors/jira/cli.js.map +1 -0
  187. package/dist/connectors/jira/index.d.ts +13 -0
  188. package/dist/connectors/jira/index.d.ts.map +1 -0
  189. package/dist/connectors/jira/index.js +287 -0
  190. package/dist/connectors/jira/index.js.map +1 -0
  191. package/dist/connectors/jira/lib/adf.d.ts +25 -0
  192. package/dist/connectors/jira/lib/adf.d.ts.map +1 -0
  193. package/dist/connectors/jira/lib/adf.js +105 -0
  194. package/dist/connectors/jira/lib/adf.js.map +1 -0
  195. package/dist/connectors/jira/lib/jira_client.d.ts +143 -0
  196. package/dist/connectors/jira/lib/jira_client.d.ts.map +1 -0
  197. package/dist/connectors/jira/lib/jira_client.js +355 -0
  198. package/dist/connectors/jira/lib/jira_client.js.map +1 -0
  199. package/dist/connectors/jira/lib/jira_error.d.ts +11 -0
  200. package/dist/connectors/jira/lib/jira_error.d.ts.map +1 -0
  201. package/dist/connectors/jira/lib/jira_error.js +17 -0
  202. package/dist/connectors/jira/lib/jira_error.js.map +1 -0
  203. package/dist/connectors/notion/cli.d.ts +3 -0
  204. package/dist/connectors/notion/cli.d.ts.map +1 -0
  205. package/dist/connectors/notion/cli.js +22 -0
  206. package/dist/connectors/notion/cli.js.map +1 -0
  207. package/dist/connectors/notion/index.d.ts +20 -0
  208. package/dist/connectors/notion/index.d.ts.map +1 -0
  209. package/dist/connectors/notion/index.js +317 -0
  210. package/dist/connectors/notion/index.js.map +1 -0
  211. package/dist/connectors/notion/lib/notion_client.d.ts +117 -0
  212. package/dist/connectors/notion/lib/notion_client.d.ts.map +1 -0
  213. package/dist/connectors/notion/lib/notion_client.js +377 -0
  214. package/dist/connectors/notion/lib/notion_client.js.map +1 -0
  215. package/dist/connectors/notion/lib/notion_error.d.ts +12 -0
  216. package/dist/connectors/notion/lib/notion_error.d.ts.map +1 -0
  217. package/dist/connectors/notion/lib/notion_error.js +18 -0
  218. package/dist/connectors/notion/lib/notion_error.js.map +1 -0
  219. package/dist/hub/cli.d.ts +4 -0
  220. package/dist/hub/cli.d.ts.map +1 -0
  221. package/dist/hub/cli.js +93 -0
  222. package/dist/hub/cli.js.map +1 -0
  223. package/dist/hub/dispatch.d.ts +33 -0
  224. package/dist/hub/dispatch.d.ts.map +1 -0
  225. package/dist/hub/dispatch.js +297 -0
  226. package/dist/hub/dispatch.js.map +1 -0
  227. package/dist/hub/index.d.ts +9 -0
  228. package/dist/hub/index.d.ts.map +1 -0
  229. package/dist/hub/index.js +215 -0
  230. package/dist/hub/index.js.map +1 -0
  231. package/dist/hub/plan.d.ts +24 -0
  232. package/dist/hub/plan.d.ts.map +1 -0
  233. package/dist/hub/plan.js +103 -0
  234. package/dist/hub/plan.js.map +1 -0
  235. package/dist/hub/types.d.ts +65 -0
  236. package/dist/hub/types.d.ts.map +1 -0
  237. package/dist/hub/types.js +3 -0
  238. package/dist/hub/types.js.map +1 -0
  239. package/dist/toolkit/_optional.d.ts +14 -0
  240. package/dist/toolkit/_optional.d.ts.map +1 -0
  241. package/dist/toolkit/_optional.js +96 -0
  242. package/dist/toolkit/_optional.js.map +1 -0
  243. package/dist/toolkit/agent_cli.d.ts +33 -0
  244. package/dist/toolkit/agent_cli.d.ts.map +1 -0
  245. package/dist/toolkit/agent_cli.js +62 -0
  246. package/dist/toolkit/agent_cli.js.map +1 -0
  247. package/dist/toolkit/agent_resolver.d.ts +46 -0
  248. package/dist/toolkit/agent_resolver.d.ts.map +1 -0
  249. package/dist/toolkit/agent_resolver.js +78 -0
  250. package/dist/toolkit/agent_resolver.js.map +1 -0
  251. package/dist/toolkit/audit/events.d.ts +45 -0
  252. package/dist/toolkit/audit/events.d.ts.map +1 -0
  253. package/dist/toolkit/audit/events.js +8 -0
  254. package/dist/toolkit/audit/events.js.map +1 -0
  255. package/dist/toolkit/audit/writer.d.ts +16 -0
  256. package/dist/toolkit/audit/writer.d.ts.map +1 -0
  257. package/dist/toolkit/audit/writer.js +73 -0
  258. package/dist/toolkit/audit/writer.js.map +1 -0
  259. package/dist/toolkit/cli/usage-report.d.ts +3 -0
  260. package/dist/toolkit/cli/usage-report.d.ts.map +1 -0
  261. package/dist/toolkit/cli/usage-report.js +76 -0
  262. package/dist/toolkit/cli/usage-report.js.map +1 -0
  263. package/dist/toolkit/connector.d.ts +142 -0
  264. package/dist/toolkit/connector.d.ts.map +1 -0
  265. package/dist/toolkit/connector.js +593 -0
  266. package/dist/toolkit/connector.js.map +1 -0
  267. package/dist/toolkit/extract_binary.d.ts +45 -0
  268. package/dist/toolkit/extract_binary.d.ts.map +1 -0
  269. package/dist/toolkit/extract_binary.js +342 -0
  270. package/dist/toolkit/extract_binary.js.map +1 -0
  271. package/dist/toolkit/extract_multimodal.d.ts +22 -0
  272. package/dist/toolkit/extract_multimodal.d.ts.map +1 -0
  273. package/dist/toolkit/extract_multimodal.js +209 -0
  274. package/dist/toolkit/extract_multimodal.js.map +1 -0
  275. package/dist/toolkit/fetch_attachment.d.ts +21 -0
  276. package/dist/toolkit/fetch_attachment.d.ts.map +1 -0
  277. package/dist/toolkit/fetch_attachment.js +169 -0
  278. package/dist/toolkit/fetch_attachment.js.map +1 -0
  279. package/dist/toolkit/fetch_helper.d.ts +47 -0
  280. package/dist/toolkit/fetch_helper.d.ts.map +1 -0
  281. package/dist/toolkit/fetch_helper.js +124 -0
  282. package/dist/toolkit/fetch_helper.js.map +1 -0
  283. package/dist/toolkit/guardrail.d.ts +63 -0
  284. package/dist/toolkit/guardrail.d.ts.map +1 -0
  285. package/dist/toolkit/guardrail.js +166 -0
  286. package/dist/toolkit/guardrail.js.map +1 -0
  287. package/dist/toolkit/hardship/curate.d.ts +47 -0
  288. package/dist/toolkit/hardship/curate.d.ts.map +1 -0
  289. package/dist/toolkit/hardship/curate.js +113 -0
  290. package/dist/toolkit/hardship/curate.js.map +1 -0
  291. package/dist/toolkit/hardship/patterns.d.ts +32 -0
  292. package/dist/toolkit/hardship/patterns.d.ts.map +1 -0
  293. package/dist/toolkit/hardship/patterns.js +98 -0
  294. package/dist/toolkit/hardship/patterns.js.map +1 -0
  295. package/dist/toolkit/hardship/preamble.d.ts +13 -0
  296. package/dist/toolkit/hardship/preamble.d.ts.map +1 -0
  297. package/dist/toolkit/hardship/preamble.js +47 -0
  298. package/dist/toolkit/hardship/preamble.js.map +1 -0
  299. package/dist/toolkit/hardship/read.d.ts +34 -0
  300. package/dist/toolkit/hardship/read.d.ts.map +1 -0
  301. package/dist/toolkit/hardship/read.js +116 -0
  302. package/dist/toolkit/hardship/read.js.map +1 -0
  303. package/dist/toolkit/hardship/record.d.ts +43 -0
  304. package/dist/toolkit/hardship/record.d.ts.map +1 -0
  305. package/dist/toolkit/hardship/record.js +74 -0
  306. package/dist/toolkit/hardship/record.js.map +1 -0
  307. package/dist/toolkit/hardship/scope.d.ts +20 -0
  308. package/dist/toolkit/hardship/scope.d.ts.map +1 -0
  309. package/dist/toolkit/hardship/scope.js +56 -0
  310. package/dist/toolkit/hardship/scope.js.map +1 -0
  311. package/dist/toolkit/index.d.ts +42 -0
  312. package/dist/toolkit/index.d.ts.map +1 -0
  313. package/dist/toolkit/index.js +51 -0
  314. package/dist/toolkit/index.js.map +1 -0
  315. package/dist/toolkit/plugin/curate-cmd.d.ts +22 -0
  316. package/dist/toolkit/plugin/curate-cmd.d.ts.map +1 -0
  317. package/dist/toolkit/plugin/curate-cmd.js +72 -0
  318. package/dist/toolkit/plugin/curate-cmd.js.map +1 -0
  319. package/dist/toolkit/plugin/prefs.d.ts +15 -0
  320. package/dist/toolkit/plugin/prefs.d.ts.map +1 -0
  321. package/dist/toolkit/plugin/prefs.js +78 -0
  322. package/dist/toolkit/plugin/prefs.js.map +1 -0
  323. package/dist/toolkit/plugin/reminder.d.ts +28 -0
  324. package/dist/toolkit/plugin/reminder.d.ts.map +1 -0
  325. package/dist/toolkit/plugin/reminder.js +103 -0
  326. package/dist/toolkit/plugin/reminder.js.map +1 -0
  327. package/dist/toolkit/policy/approval.d.ts +24 -0
  328. package/dist/toolkit/policy/approval.d.ts.map +1 -0
  329. package/dist/toolkit/policy/approval.js +56 -0
  330. package/dist/toolkit/policy/approval.js.map +1 -0
  331. package/dist/toolkit/policy/config.d.ts +38 -0
  332. package/dist/toolkit/policy/config.d.ts.map +1 -0
  333. package/dist/toolkit/policy/config.js +172 -0
  334. package/dist/toolkit/policy/config.js.map +1 -0
  335. package/dist/toolkit/policy/gate.d.ts +28 -0
  336. package/dist/toolkit/policy/gate.d.ts.map +1 -0
  337. package/dist/toolkit/policy/gate.js +126 -0
  338. package/dist/toolkit/policy/gate.js.map +1 -0
  339. package/dist/toolkit/policy/types.d.ts +106 -0
  340. package/dist/toolkit/policy/types.d.ts.map +1 -0
  341. package/dist/toolkit/policy/types.js +22 -0
  342. package/dist/toolkit/policy/types.js.map +1 -0
  343. package/dist/toolkit/security_check.d.ts +15 -0
  344. package/dist/toolkit/security_check.d.ts.map +1 -0
  345. package/dist/toolkit/security_check.js +109 -0
  346. package/dist/toolkit/security_check.js.map +1 -0
  347. package/dist/toolkit/usage/aggregate-cross-session.d.ts +36 -0
  348. package/dist/toolkit/usage/aggregate-cross-session.d.ts.map +1 -0
  349. package/dist/toolkit/usage/aggregate-cross-session.js +142 -0
  350. package/dist/toolkit/usage/aggregate-cross-session.js.map +1 -0
  351. package/dist/toolkit/usage/aggregate.d.ts +4 -0
  352. package/dist/toolkit/usage/aggregate.d.ts.map +1 -0
  353. package/dist/toolkit/usage/aggregate.js +105 -0
  354. package/dist/toolkit/usage/aggregate.js.map +1 -0
  355. package/dist/toolkit/usage/index.d.ts +11 -0
  356. package/dist/toolkit/usage/index.d.ts.map +1 -0
  357. package/dist/toolkit/usage/index.js +7 -0
  358. package/dist/toolkit/usage/index.js.map +1 -0
  359. package/dist/toolkit/usage/parse.d.ts +5 -0
  360. package/dist/toolkit/usage/parse.d.ts.map +1 -0
  361. package/dist/toolkit/usage/parse.js +19 -0
  362. package/dist/toolkit/usage/parse.js.map +1 -0
  363. package/dist/toolkit/usage/record.d.ts +8 -0
  364. package/dist/toolkit/usage/record.d.ts.map +1 -0
  365. package/dist/toolkit/usage/record.js +18 -0
  366. package/dist/toolkit/usage/record.js.map +1 -0
  367. package/dist/toolkit/usage/retention.d.ts +6 -0
  368. package/dist/toolkit/usage/retention.d.ts.map +1 -0
  369. package/dist/toolkit/usage/retention.js +71 -0
  370. package/dist/toolkit/usage/retention.js.map +1 -0
  371. package/dist/toolkit/usage/tokenize.d.ts +11 -0
  372. package/dist/toolkit/usage/tokenize.d.ts.map +1 -0
  373. package/dist/toolkit/usage/tokenize.js +24 -0
  374. package/dist/toolkit/usage/tokenize.js.map +1 -0
  375. package/dist/toolkit/usage/types.d.ts +34 -0
  376. package/dist/toolkit/usage/types.d.ts.map +1 -0
  377. package/dist/toolkit/usage/types.js +2 -0
  378. package/dist/toolkit/usage/types.js.map +1 -0
  379. package/package.json +124 -0
  380. package/plugin-hooks/session-summary.mjs +138 -0
  381. package/plugin-hooks/stale-summarize.mjs +70 -0
  382. package/plugin-hooks/usage-record.mjs +112 -0
  383. package/plugins/aws-agent/.claude-plugin/plugin.json +6 -0
  384. package/plugins/aws-agent/README.md +46 -0
  385. package/plugins/aws-agent/bin/aws-agent +22 -0
  386. package/plugins/aws-agent/commands/aws-agent.md +6 -0
  387. package/plugins/aws-agent/hooks/hooks.json +49 -0
  388. package/plugins/aws-agent/hooks/reminder.mjs +16 -0
  389. package/plugins/aws-agent/package.json +9 -0
  390. package/plugins/aws-agent/skills/aws-agent/SKILL.md +70 -0
  391. package/plugins/confluence-agent/.claude-plugin/plugin.json +6 -0
  392. package/plugins/confluence-agent/README.md +15 -0
  393. package/plugins/confluence-agent/bin/confluence-agent +17 -0
  394. package/plugins/confluence-agent/commands/confluence-agent.md +6 -0
  395. package/plugins/confluence-agent/hooks/hooks.json +49 -0
  396. package/plugins/confluence-agent/hooks/reminder.mjs +25 -0
  397. package/plugins/confluence-agent/package.json +8 -0
  398. package/plugins/confluence-agent/skills/confluence-agent/SKILL.md +40 -0
  399. package/plugins/db-agent/.claude-plugin/plugin.json +20 -0
  400. package/plugins/db-agent/README.md +13 -0
  401. package/plugins/db-agent/bin/db-agent +17 -0
  402. package/plugins/db-agent/commands/db-agent.md +6 -0
  403. package/plugins/db-agent/hooks/db-guard.mjs +110 -0
  404. package/plugins/db-agent/hooks/guardrails.json +26 -0
  405. package/plugins/db-agent/hooks/hooks.json +61 -0
  406. package/plugins/db-agent/hooks/reminder.mjs +16 -0
  407. package/plugins/db-agent/package.json +8 -0
  408. package/plugins/db-agent/skills/db-agent/SKILL.md +50 -0
  409. package/plugins/gcp-agent/.claude-plugin/plugin.json +6 -0
  410. package/plugins/gcp-agent/README.md +31 -0
  411. package/plugins/gcp-agent/bin/gcp-agent +18 -0
  412. package/plugins/gcp-agent/commands/gcp-agent.md +6 -0
  413. package/plugins/gcp-agent/hooks/hooks.json +49 -0
  414. package/plugins/gcp-agent/hooks/reminder.mjs +16 -0
  415. package/plugins/gcp-agent/package.json +9 -0
  416. package/plugins/gcp-agent/skills/gcp-agent/SKILL.md +54 -0
  417. package/plugins/github-agent/.claude-plugin/plugin.json +6 -0
  418. package/plugins/github-agent/README.md +13 -0
  419. package/plugins/github-agent/bin/github-agent +17 -0
  420. package/plugins/github-agent/commands/github-agent.md +6 -0
  421. package/plugins/github-agent/hooks/hooks.json +49 -0
  422. package/plugins/github-agent/hooks/reminder.mjs +16 -0
  423. package/plugins/github-agent/package.json +8 -0
  424. package/plugins/github-agent/skills/github-agent/SKILL.md +41 -0
  425. package/plugins/jira-agent/.claude-plugin/plugin.json +6 -0
  426. package/plugins/jira-agent/README.md +15 -0
  427. package/plugins/jira-agent/bin/jira-agent +17 -0
  428. package/plugins/jira-agent/commands/jira-agent.md +6 -0
  429. package/plugins/jira-agent/hooks/hooks.json +49 -0
  430. package/plugins/jira-agent/hooks/reminder.mjs +16 -0
  431. package/plugins/jira-agent/package.json +8 -0
  432. package/plugins/jira-agent/skills/jira-agent/SKILL.md +37 -0
  433. package/plugins/notion-agent/.claude-plugin/plugin.json +6 -0
  434. package/plugins/notion-agent/README.md +23 -0
  435. package/plugins/notion-agent/bin/notion-agent +17 -0
  436. package/plugins/notion-agent/commands/notion-agent.md +6 -0
  437. package/plugins/notion-agent/hooks/hooks.json +49 -0
  438. package/plugins/notion-agent/hooks/reminder.mjs +17 -0
  439. package/plugins/notion-agent/package.json +8 -0
  440. package/plugins/notion-agent/skills/notion-agent/SKILL.md +48 -0
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @narai/db-agent-connector — public API barrel.
3
+ *
4
+ * Default export: a ready-to-use `Connector` built on
5
+ * `@narai/connector-toolkit`. Use `import connector from "narai-primitives/db"`
6
+ * and call `connector.fetch(action, params)` / `connector.main(argv)`.
7
+ *
8
+ * Legacy surface: `fetch(action, params)` is re-exported from the internal
9
+ * dispatcher for programmatic callers that want the pre-framework envelope
10
+ * shape (`{status: "ok"|"denied"|..., rows, columns, ...}`). The framework
11
+ * connector translates that into the canonical envelope at the boundary.
12
+ */
13
+ import { buildDbConnector } from "./connector.js";
14
+ const connector = buildDbConnector();
15
+ export default connector;
16
+ export const { main, fetch, validActions } = connector;
17
+ export { buildDbConnector };
18
+ // Legacy dispatcher surface (pre-2.0 envelope shape, still useful for
19
+ // programmatic callers embedding the DB policy gate directly).
20
+ export { fetch as dispatcherFetch, VALID_ACTIONS, HELP_TEXT, } from "./dispatcher.js";
21
+ export * from "./lib/index.js";
22
+ // Selective re-export to avoid `CredentialProvider` name clash with the
23
+ // legacy class in `lib/credentials.ts`.
24
+ export { registerProvider, getProvider, clearProviders, listProviders, resolveSecret, FileProvider, EnvVarProvider, KeychainProvider, CloudSecretsProvider, parseCredentialRef, KNOWN_PROVIDERS, } from "@narai/credential-providers";
25
+ export { parseConfig, ConfigFileNotFoundError, } from "./config.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connectors/db/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAC;AACrC,eAAe,SAAS,CAAC;AACzB,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,SAAS,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,sEAAsE;AACtE,+DAA+D;AAC/D,OAAO,EACL,KAAK,IAAI,eAAe,EACxB,aAAa,EACb,SAAS,GAIV,MAAM,iBAAiB,CAAC;AAEzB,cAAc,gBAAgB,CAAC;AAE/B,wEAAwE;AACxE,wCAAwC;AACxC,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,GAKhB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EAEX,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Enable audit logging to `path` (JSONL file).
3
+ * If `sessionId` is not provided, a random 12-char hex string is generated.
4
+ */
5
+ export declare function enableAudit(filePath: string, sessionId?: string | null): void;
6
+ /** Disable audit logging and clear state. */
7
+ export declare function disableAudit(): void;
8
+ export interface LogQueryParams {
9
+ env: string;
10
+ query: string;
11
+ status: string;
12
+ row_count: number;
13
+ execution_time_ms: number;
14
+ error?: string | null;
15
+ context?: string | null;
16
+ }
17
+ export declare function scrubSqlSecrets(sql: string): string;
18
+ /** Log a query execution event. */
19
+ export declare function logQuery(params: LogQueryParams): void;
20
+ export interface LogEventParams {
21
+ event_type: string;
22
+ details?: Record<string, unknown> | null;
23
+ }
24
+ /** Log a non-query event (e.g. connect, schema_inspect). */
25
+ export declare function logEvent(params: LogEventParams): void;
26
+ /** Internal: state snapshot exposed only for tests. */
27
+ export declare function _auditState(): {
28
+ enabled: boolean;
29
+ path: string | null;
30
+ sessionId: string | null;
31
+ };
32
+ //# sourceMappingURL=audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../../../src/connectors/db/lib/audit.ts"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAQ7E;AAED,6CAA6C;AAC7C,wBAAgB,YAAY,IAAI,IAAI,CAInC;AAiCD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAgBD,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAInD;AAED,mCAAmC;AACnC,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAmBrD;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC1C;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAUrD;AAED,uDAAuD;AACvD,wBAAgB,WAAW,IAAI;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAMA"}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * audit.ts — Audit logging for wiki_db (JSONL format, non-failing).
3
+ *
4
+ * Mirrors `audit.py`:
5
+ * - Module-level state holds `enabled`, `path`, and `session_id`.
6
+ * - `enableAudit` / `disableAudit` toggle the state.
7
+ * - `logQuery` / `logEvent` append a single JSON line each; errors are
8
+ * swallowed so logging never raises into the caller.
9
+ *
10
+ * JSONL format parity: JSON.stringify uses compact separators (",", ":"),
11
+ * which matches Python's `json.dumps(record)` output byte-for-byte for
12
+ * dict+string+number payloads. Keys appear in insertion order in both
13
+ * languages.
14
+ */
15
+ import * as crypto from "node:crypto";
16
+ import * as fs from "node:fs";
17
+ // Module-level state
18
+ const _state = {
19
+ enabled: false,
20
+ path: null,
21
+ sessionId: null,
22
+ };
23
+ /**
24
+ * Enable audit logging to `path` (JSONL file).
25
+ * If `sessionId` is not provided, a random 12-char hex string is generated.
26
+ */
27
+ export function enableAudit(filePath, sessionId) {
28
+ _state.enabled = true;
29
+ _state.path = filePath;
30
+ _state.sessionId =
31
+ sessionId !== undefined && sessionId !== null
32
+ ? sessionId
33
+ // Python: secrets.token_hex(6) → 12 hex chars.
34
+ : crypto.randomBytes(6).toString("hex");
35
+ }
36
+ /** Disable audit logging and clear state. */
37
+ export function disableAudit() {
38
+ _state.enabled = false;
39
+ _state.path = null;
40
+ _state.sessionId = null;
41
+ }
42
+ /** Append a JSON record to the audit file. Never raises.
43
+ *
44
+ * Uses JSON.stringify (compact form) so each record fits on one line.
45
+ */
46
+ function _writeRecord(record) {
47
+ if (!_state.enabled || _state.path === null)
48
+ return;
49
+ try {
50
+ // fs.appendFileSync creates the file if missing but NOT parent dirs,
51
+ // matching Python's `open(path, "a")` semantics.
52
+ fs.appendFileSync(_state.path, JSON.stringify(record) + "\n", "utf-8");
53
+ }
54
+ catch {
55
+ // best-effort, same as Python's `except OSError: pass`
56
+ }
57
+ }
58
+ /**
59
+ * Python-compatible ISO-8601 UTC timestamp with trailing "Z".
60
+ *
61
+ * Python's `datetime.datetime.utcnow().isoformat() + "Z"` produces a
62
+ * format like `"2026-04-12T10:55:50.123456"` (microseconds) + `"Z"`.
63
+ * JS's `Date().toISOString()` yields `"2026-04-12T10:55:50.123Z"`
64
+ * (millisecond precision). Both are valid ISO-8601 so downstream parsers
65
+ * accept them; the test only checks for the key's presence.
66
+ */
67
+ function _isoTimestamp() {
68
+ // Strip trailing Z that toISOString includes, then re-append to match
69
+ // Python's explicit `+ "Z"` composition.
70
+ const iso = new Date().toISOString();
71
+ return iso.endsWith("Z") ? iso : iso + "Z";
72
+ }
73
+ /**
74
+ * Mask values of common credential-bearing identifiers in a SQL string.
75
+ *
76
+ * Catches `password='…'`, `token="…"`, `api_key='…'`, etc. so that
77
+ * read-only queries against the user's own DB don't persist embedded
78
+ * credentials to events.jsonl. Intentionally only handles complete
79
+ * single/double-quoted literals — partial or concatenated literals are
80
+ * out of scope.
81
+ */
82
+ const _SENSITIVE_LITERAL_SQUOTE_RE = /\b(password|passwd|pwd|token|api[_-]?key|secret|access[_-]?key|auth)\s*=\s*'[^']*'/gi;
83
+ const _SENSITIVE_LITERAL_DQUOTE_RE = /\b(password|passwd|pwd|token|api[_-]?key|secret|access[_-]?key|auth)\s*=\s*"[^"]*"/gi;
84
+ export function scrubSqlSecrets(sql) {
85
+ return sql
86
+ .replace(_SENSITIVE_LITERAL_SQUOTE_RE, (_m, key) => `${key}='[REDACTED]'`)
87
+ .replace(_SENSITIVE_LITERAL_DQUOTE_RE, (_m, key) => `${key}="[REDACTED]"`);
88
+ }
89
+ /** Log a query execution event. */
90
+ export function logQuery(params) {
91
+ const record = {
92
+ event_type: "query",
93
+ timestamp: _isoTimestamp(),
94
+ session_id: _state.sessionId,
95
+ env: params.env,
96
+ // Scrub before truncate so a credential split by truncation can't leak.
97
+ query: scrubSqlSecrets(params.query).slice(0, 2000),
98
+ status: params.status,
99
+ row_count: params.row_count,
100
+ execution_time_ms: params.execution_time_ms,
101
+ };
102
+ if (params.error !== undefined && params.error !== null) {
103
+ record["error"] = params.error;
104
+ }
105
+ if (params.context !== undefined && params.context !== null) {
106
+ record["context"] = params.context;
107
+ }
108
+ _writeRecord(record);
109
+ }
110
+ /** Log a non-query event (e.g. connect, schema_inspect). */
111
+ export function logEvent(params) {
112
+ const record = {
113
+ event_type: params.event_type,
114
+ timestamp: _isoTimestamp(),
115
+ session_id: _state.sessionId,
116
+ };
117
+ if (params.details !== undefined && params.details !== null) {
118
+ record["details"] = params.details;
119
+ }
120
+ _writeRecord(record);
121
+ }
122
+ /** Internal: state snapshot exposed only for tests. */
123
+ export function _auditState() {
124
+ return {
125
+ enabled: _state.enabled,
126
+ path: _state.path,
127
+ sessionId: _state.sessionId,
128
+ };
129
+ }
130
+ //# sourceMappingURL=audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["../../../../src/connectors/db/lib/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAE9B,qBAAqB;AACrB,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,KAAgB;IACzB,IAAI,EAAE,IAAqB;IAC3B,SAAS,EAAE,IAAqB;CACjC,CAAC;AAEF;;;GAGG;AACH,MA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AAE,aAAa,EAAE;QAC1B,UAAU,EAAE,MAAM,CAAC,SAAS;KAC7B,CAAC;IACF,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,KAAK,IAAI,EAAE,CAAC;QAC5D,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;IACrC,CAAC;IACD,YAAY,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,WAAW;IAKzB,OAAO;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,SAAS,EAAE,MAAM,CAAC,SAAS;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ import { DatabaseDriver } from "./drivers/base.js";
2
+ /**
3
+ * Returns a concrete `DatabaseDriver` for a given environment's config.
4
+ *
5
+ * For pool-aware drivers (Phase E: pg, mysql, mssql, mongo, dynamo) the
6
+ * factory is expected to return a driver that wraps a connection pool
7
+ * internally — one driver instance per environment, reused across calls.
8
+ */
9
+ export type DriverFactory = (envConfig: Record<string, unknown>) => DatabaseDriver;
10
+ /** Register a factory under a driver name (e.g. "sqlite", "postgresql"). */
11
+ export declare function registerDriverFactory(name: string, factory: DriverFactory): void;
12
+ /** Remove all registered factories (test helper). */
13
+ export declare function clearDriverFactories(): void;
14
+ /** Return registered driver names (test helper). */
15
+ export declare function listDriverFactories(): string[];
16
+ /** A handle returned by {@link getConnection}. */
17
+ export interface Connection {
18
+ /** The environment name this handle was opened for. */
19
+ envName: string;
20
+ /** Driver-native connection object (opaque). */
21
+ native: unknown;
22
+ /** Driver used to create this connection (used by release/healthCheck). */
23
+ driver: DatabaseDriver;
24
+ }
25
+ /**
26
+ * Obtain a connection for the named environment. Creates the driver and
27
+ * pool lazily on first call. Returns a handle that must be passed to
28
+ * {@link releaseConnection} when done.
29
+ *
30
+ * G-CONN-AWAIT: async drivers (pg, mysql, mssql, mongo, dynamo) return
31
+ * a Promise from `connect()`. We await the resolved handle before
32
+ * registering it in `openConnections` so identity-based lookups in
33
+ * `releaseConnection`/`shutdownAll` match the same object the caller
34
+ * holds. `Promise.resolve(x)` no-ops on the sync SQLite path.
35
+ */
36
+ export declare function getConnection(envName: string): Promise<Connection>;
37
+ /** Release a connection back to its pool (closes native handle). */
38
+ export declare function releaseConnection(envName: string, conn: Connection): void;
39
+ /**
40
+ * Cheap liveness check. Returns `true` on success, `false` on any error.
41
+ *
42
+ * Preference order:
43
+ * 1. `driver.healthCheck(native)` — Phase E drivers use engine-appropriate
44
+ * probes (Mongo `ping`, DynamoDB `ListTables`, etc.) that `SELECT 1`
45
+ * cannot express.
46
+ * 2. `driver.executeReadAsync(..., "SELECT 1", ...)` — SQL drivers.
47
+ * 3. `driver.executeRead(..., "SELECT 1", ...)` — legacy sync path
48
+ * (SQLite, mocked test drivers).
49
+ */
50
+ export declare function healthCheck(envName: string): Promise<boolean>;
51
+ /**
52
+ * Close every pool and drop the registry. Awaits each driver's
53
+ * `shutdown()` so native connection pools (pg.Pool, mysql2 pool,
54
+ * mssql.ConnectionPool, MongoClient) are fully drained before we return.
55
+ */
56
+ export declare function shutdownAll(): Promise<void>;
57
+ /** Return whether a pool exists for the given env (test helper). */
58
+ export declare function _hasPool(envName: string): boolean;
59
+ /** Return the number of open connections in a pool (test helper). */
60
+ export declare function _openCount(envName: string): number;
61
+ //# sourceMappingURL=connection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/connectors/db/lib/connection.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAQnD;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC/B,cAAc,CAAC;AAIpB,4EAA4E;AAC5E,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,GACrB,IAAI,CAEN;AAED,qDAAqD;AACrD,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED,oDAAoD;AACpD,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CAE9C;AAWD,kDAAkD;AAClD,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,MAAM,EAAE,OAAO,CAAC;IAChB,2EAA2E;IAC3E,MAAM,EAAE,cAAc,CAAC;CACxB;AAqDD;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAcxE;AAED,oEAAoE;AACpE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAoBzE;AAuBD;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA2BnE;AAED;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAyBjD;AA2ID,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAElD"}
@@ -0,0 +1,326 @@
1
+ /**
2
+ * connection.ts — Connection-pool registry keyed by environment name.
3
+ *
4
+ * Wraps driver-native connection pools behind a uniform acquire/release
5
+ * API. For Phase F the only shipped driver is `SQLiteDriver` (no native
6
+ * pool; each `getConnection()` opens a fresh handle and `release` closes
7
+ * it). Phase E drivers (pg, mysql, mssql, mongo, dynamo) will register
8
+ * themselves with pool-aware factories via {@link registerDriverFactory}.
9
+ *
10
+ * Shutdown:
11
+ * - `shutdownAll()` closes every driver in the registry.
12
+ * - We register `SIGINT`, `SIGTERM`, and `exit` handlers the first time
13
+ * `getConnection()` is called, so long-running scripts release their
14
+ * pools on process teardown.
15
+ */
16
+ import { getEnvironment } from "./environments.js";
17
+ import { logEvent } from "./audit.js";
18
+ import { parseCredentialRef, resolveSecret } from "@narai/credential-providers";
19
+ const _driverFactories = new Map();
20
+ /** Register a factory under a driver name (e.g. "sqlite", "postgresql"). */
21
+ export function registerDriverFactory(name, factory) {
22
+ _driverFactories.set(name, factory);
23
+ }
24
+ /** Remove all registered factories (test helper). */
25
+ export function clearDriverFactories() {
26
+ _driverFactories.clear();
27
+ }
28
+ /** Return registered driver names (test helper). */
29
+ export function listDriverFactories() {
30
+ return [..._driverFactories.keys()];
31
+ }
32
+ const _pools = new Map();
33
+ // ---------------------------------------------------------------------------
34
+ // Lifecycle handlers
35
+ // ---------------------------------------------------------------------------
36
+ let _handlersInstalled = false;
37
+ function _installShutdownHandlers() {
38
+ if (_handlersInstalled)
39
+ return;
40
+ _handlersInstalled = true;
41
+ // `exit` fires once per process; make the cleanup best-effort and
42
+ // synchronous where possible so pools are released before Node exits.
43
+ process.on("exit", () => {
44
+ try {
45
+ _shutdownAllSync();
46
+ }
47
+ catch {
48
+ /* best-effort */
49
+ }
50
+ });
51
+ // Signals: flush pools so native connections release promptly, then
52
+ // leave the exit decision to the host. Calling `process.exit()` here
53
+ // would clobber any user-installed SIGINT/SIGTERM handler in an
54
+ // application that embeds wiki_db, so we deliberately do not do that.
55
+ // Node's default behavior (exit with 128+signum when no other listener
56
+ // calls `preventDefault`-equivalent) still applies when no handler
57
+ // keeps the process alive.
58
+ for (const sig of ["SIGINT", "SIGTERM"]) {
59
+ process.on(sig, () => {
60
+ try {
61
+ _shutdownAllSync();
62
+ }
63
+ catch {
64
+ /* best-effort */
65
+ }
66
+ });
67
+ }
68
+ }
69
+ // ---------------------------------------------------------------------------
70
+ // Pool operations
71
+ // ---------------------------------------------------------------------------
72
+ /**
73
+ * Obtain a connection for the named environment. Creates the driver and
74
+ * pool lazily on first call. Returns a handle that must be passed to
75
+ * {@link releaseConnection} when done.
76
+ *
77
+ * G-CONN-AWAIT: async drivers (pg, mysql, mssql, mongo, dynamo) return
78
+ * a Promise from `connect()`. We await the resolved handle before
79
+ * registering it in `openConnections` so identity-based lookups in
80
+ * `releaseConnection`/`shutdownAll` match the same object the caller
81
+ * holds. `Promise.resolve(x)` no-ops on the sync SQLite path.
82
+ */
83
+ export async function getConnection(envName) {
84
+ _installShutdownHandlers();
85
+ let entry = _pools.get(envName);
86
+ if (entry === undefined) {
87
+ entry = await _buildPoolAsync(envName);
88
+ _pools.set(envName, entry);
89
+ }
90
+ const envCfg = _resolveEnvConfig(envName);
91
+ const resolvedCfg = await _resolveCredentials(envCfg);
92
+ const native = await Promise.resolve(entry.driver.connect(resolvedCfg));
93
+ entry.openConnections.add(native);
94
+ return { envName, native, driver: entry.driver };
95
+ }
96
+ /** Release a connection back to its pool (closes native handle). */
97
+ export function releaseConnection(envName, conn) {
98
+ const entry = _pools.get(envName);
99
+ if (entry === undefined)
100
+ return;
101
+ if (!entry.openConnections.has(conn.native))
102
+ return;
103
+ entry.openConnections.delete(conn.native);
104
+ try {
105
+ entry.driver.close(conn.native);
106
+ }
107
+ catch {
108
+ /* best-effort */
109
+ }
110
+ // A5 (G-DB-AUDIT extension): emit `connection_released` so the audit
111
+ // trail of a schema or query call has a clean lifecycle marker —
112
+ // `[pool_created, schema_inspect, connection_released]` rather than
113
+ // just `[pool_created]`. logEvent is best-effort and silently no-ops
114
+ // when audit isn't enabled, so the new emit is safe in every code
115
+ // path that releases a pooled connection.
116
+ logEvent({
117
+ event_type: "connection_released",
118
+ details: { env: envName },
119
+ });
120
+ }
121
+ /**
122
+ * Cheap liveness check. Returns `true` on success, `false` on any error.
123
+ *
124
+ * Preference order:
125
+ * 1. `driver.healthCheck(native)` — Phase E drivers use engine-appropriate
126
+ * probes (Mongo `ping`, DynamoDB `ListTables`, etc.) that `SELECT 1`
127
+ * cannot express.
128
+ * 2. `driver.executeReadAsync(..., "SELECT 1", ...)` — SQL drivers.
129
+ * 3. `driver.executeRead(..., "SELECT 1", ...)` — legacy sync path
130
+ * (SQLite, mocked test drivers).
131
+ */
132
+ export async function healthCheck(envName) {
133
+ let conn = null;
134
+ try {
135
+ conn = await getConnection(envName);
136
+ const driverHealthCheck = conn.driver.healthCheck;
137
+ if (typeof driverHealthCheck === "function") {
138
+ return Boolean(await driverHealthCheck.call(conn.driver, conn.native));
139
+ }
140
+ const asyncHook = conn.driver.executeReadAsync;
141
+ if (typeof asyncHook === "function") {
142
+ const result = await asyncHook.call(conn.driver, conn.native, "SELECT 1", [], 1, 5000);
143
+ return result.status === "success";
144
+ }
145
+ const result = conn.driver.executeRead(conn.native, "SELECT 1", [], 1, 5000);
146
+ return result.status === "success";
147
+ }
148
+ catch {
149
+ return false;
150
+ }
151
+ finally {
152
+ if (conn !== null)
153
+ releaseConnection(envName, conn);
154
+ }
155
+ }
156
+ /**
157
+ * Close every pool and drop the registry. Awaits each driver's
158
+ * `shutdown()` so native connection pools (pg.Pool, mysql2 pool,
159
+ * mssql.ConnectionPool, MongoClient) are fully drained before we return.
160
+ */
161
+ export async function shutdownAll() {
162
+ const drains = [];
163
+ for (const entry of _pools.values()) {
164
+ for (const native of [...entry.openConnections]) {
165
+ try {
166
+ entry.driver.close(native);
167
+ }
168
+ catch {
169
+ /* best-effort */
170
+ }
171
+ }
172
+ entry.openConnections.clear();
173
+ const shutdownFn = entry.driver.shutdown;
174
+ if (typeof shutdownFn === "function") {
175
+ try {
176
+ const result = shutdownFn.call(entry.driver);
177
+ if (result instanceof Promise) {
178
+ drains.push(result.catch(() => undefined));
179
+ }
180
+ }
181
+ catch {
182
+ /* best-effort */
183
+ }
184
+ }
185
+ }
186
+ _pools.clear();
187
+ await Promise.all(drains);
188
+ }
189
+ /**
190
+ * Synchronous variant used from the `exit` handler (Node's `exit` event
191
+ * is strictly synchronous — we cannot await there). We still call each
192
+ * driver's `shutdown()` fire-and-forget so pool teardown starts; any
193
+ * rejected promises get an empty catch handler attached so they do not
194
+ * crash the exiting process.
195
+ */
196
+ function _shutdownAllSync() {
197
+ for (const entry of _pools.values()) {
198
+ for (const native of [...entry.openConnections]) {
199
+ try {
200
+ entry.driver.close(native);
201
+ }
202
+ catch {
203
+ /* best-effort */
204
+ }
205
+ }
206
+ entry.openConnections.clear();
207
+ const shutdownFn = entry.driver.shutdown;
208
+ if (typeof shutdownFn === "function") {
209
+ try {
210
+ const result = shutdownFn.call(entry.driver);
211
+ if (result instanceof Promise) {
212
+ result.catch(() => undefined);
213
+ }
214
+ }
215
+ catch {
216
+ /* best-effort */
217
+ }
218
+ }
219
+ }
220
+ _pools.clear();
221
+ }
222
+ // ---------------------------------------------------------------------------
223
+ // Helpers
224
+ // ---------------------------------------------------------------------------
225
+ async function _buildPoolAsync(envName) {
226
+ const envCfg = _resolveEnvConfig(envName);
227
+ const driverName = _driverName(envCfg);
228
+ // Lazy-load the driver module (and its optional heavy dep) on first use.
229
+ // Imported here to avoid a static dependency cycle between connection.ts
230
+ // and drivers/register.ts (register.ts imports `registerDriverFactory`
231
+ // from this module).
232
+ const { ensureDriver } = await import("./drivers/register.js");
233
+ await ensureDriver(driverName);
234
+ const factory = _driverFactories.get(driverName);
235
+ if (factory === undefined) {
236
+ throw new Error(`connection: no driver factory registered for '${driverName}'. ` +
237
+ `Registered: [${[..._driverFactories.keys()].join(", ") || "none"}]`);
238
+ }
239
+ const driver = factory(envCfg);
240
+ // G-DB-AUDIT: emit `pool_created` once per environment (this function is
241
+ // only invoked on the first getConnection() for a given envName).
242
+ logEvent({
243
+ event_type: "pool_created",
244
+ details: { env: envName, driver: driverName },
245
+ });
246
+ return { envName, driver, openConnections: new Set() };
247
+ }
248
+ /**
249
+ * Resolve an environment's config. If the env is registered via
250
+ * `environments.registerEnvironment`, we return that; otherwise we throw
251
+ * a clear error.
252
+ *
253
+ * Returned shape is a plain record so driver factories can consume it
254
+ * without importing `EnvironmentConfig` directly. Any `extras` stored on
255
+ * the env record (plugin-config path: user, password, ssl, region,
256
+ * endpoint, url, pool, ...) are spread on top of the legacy named fields
257
+ * so driver-specific knobs flow through to `driver.connect()`.
258
+ */
259
+ function _resolveEnvConfig(envName) {
260
+ const env = getEnvironment(envName);
261
+ const base = {
262
+ host: env.host,
263
+ port: env.port,
264
+ database: env.database,
265
+ schema: env.schema,
266
+ approval_mode: env.approval_mode,
267
+ driver: env.driver,
268
+ };
269
+ if (env.extras !== undefined) {
270
+ for (const [k, v] of Object.entries(env.extras)) {
271
+ base[k] = v;
272
+ }
273
+ }
274
+ return base;
275
+ }
276
+ function _driverName(envCfg) {
277
+ const d = envCfg["driver"];
278
+ return typeof d === "string" ? d : "postgresql";
279
+ }
280
+ /**
281
+ * Walk a resolved env config and expand credential references of the form
282
+ * `provider:key` into their resolved secret value. Currently handles the
283
+ * `env_var` provider inline (common case) and defers to `resolveSecret` for
284
+ * others. Plain strings with no recognized prefix pass through unchanged.
285
+ */
286
+ async function _resolveCredentials(envCfg) {
287
+ const out = {};
288
+ for (const [k, v] of Object.entries(envCfg)) {
289
+ if (typeof v !== "string") {
290
+ out[k] = v;
291
+ continue;
292
+ }
293
+ const ref = parseCredentialRef(v);
294
+ if (ref === null) {
295
+ out[k] = v;
296
+ continue;
297
+ }
298
+ if (ref.provider === "env_var") {
299
+ const resolved = process.env[ref.key];
300
+ out[k] = resolved ?? v;
301
+ continue;
302
+ }
303
+ try {
304
+ const resolved = await resolveSecret(ref.key, { provider: ref.provider });
305
+ out[k] = resolved ?? v;
306
+ }
307
+ catch {
308
+ // Secret backend threw — keep the literal reference so the driver's
309
+ // connect() surfaces an auth error instead of silently mis-configuring.
310
+ out[k] = v;
311
+ }
312
+ }
313
+ return out;
314
+ }
315
+ // ---------------------------------------------------------------------------
316
+ // Introspection helpers (tests)
317
+ // ---------------------------------------------------------------------------
318
+ /** Return whether a pool exists for the given env (test helper). */
319
+ export function _hasPool(envName) {
320
+ return _pools.has(envName);
321
+ }
322
+ /** Return the number of open connections in a pool (test helper). */
323
+ export function _openCount(envName) {
324
+ return _pools.get(envName)?.openConnections.size ?? 0;
325
+ }
326
+ //# sourceMappingURL=connection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../../src/connectors/db/lib/connection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAiBhF,MAAM,gBAAgB,GAA+B,IAAI,GAAG,EAAE,CAAC;AAE/D,4EAA4E;AAC5E,MAAM,UAAU,qBAAqB,CACnC,IAAY,EACZ,OAAsB;IAEtB,gBAAgB,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED,qDAAqD;AACrD,MAAM,UAAU,oBAAoB;IAClC,gBAAgB,CAAC,KAAK,EAAE,CAAC;AAC3B,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,mBAAmB;IACjC,OAAO,CAAC,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;AACtC,CAAC;AA4BD,MAAM,MAAM,GAA2B,IAAI,GAAG,EAAE,CAAC;AAEjD,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAE/B,SAAS,wBAAwB;IAC/B,IAAI,kBAAkB;QAAE,OAAO;IAC/B,kBAAkB,GAAG,IAAI,CAAC;IAE1B,kEAAkE;IAClE,sEAAsE;IACtE,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACtB,IAAI,CAAC;YACH,gBAAgB,EAAE,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,iBAAiB;QACnB,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,oE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