@xtandard/audit 0.0.0-stage → 0.1.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 (423) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +386 -2
  3. package/bin/xtandard-audit.mjs +3 -0
  4. package/dist/basic-DU_nPrWV.mjs +176 -0
  5. package/dist/basic-DU_nPrWV.mjs.map +1 -0
  6. package/dist/basic-hcXnMF9X.cjs +199 -0
  7. package/dist/basic-hcXnMF9X.cjs.map +1 -0
  8. package/dist/canonical-BOgkrX9_.d.cts +17 -0
  9. package/dist/canonical-CL7gfwhb.d.mts +17 -0
  10. package/dist/chunk-D7D4PA-g.mjs +13 -0
  11. package/dist/cli.cjs +773 -0
  12. package/dist/cli.cjs.map +1 -0
  13. package/dist/cli.d.cts +46 -0
  14. package/dist/cli.d.mts +46 -0
  15. package/dist/cli.mjs +762 -0
  16. package/dist/cli.mjs.map +1 -0
  17. package/dist/context-BtR9k9Mt.d.mts +52 -0
  18. package/dist/context-CJM87uG8.d.cts +52 -0
  19. package/dist/context-shared-AgBWIRUQ.d.mts +29 -0
  20. package/dist/context-shared-CUq3cSpV.d.cts +29 -0
  21. package/dist/context-shared-CupikwQo.mjs +39 -0
  22. package/dist/context-shared-CupikwQo.mjs.map +1 -0
  23. package/dist/context-shared-X2ulHHSB.cjs +44 -0
  24. package/dist/context-shared-X2ulHHSB.cjs.map +1 -0
  25. package/dist/context.cjs +82 -0
  26. package/dist/context.cjs.map +1 -0
  27. package/dist/context.d.cts +2 -0
  28. package/dist/context.d.mts +2 -0
  29. package/dist/context.mjs +78 -0
  30. package/dist/context.mjs.map +1 -0
  31. package/dist/contract-BljSE-Hx.mjs +33 -0
  32. package/dist/contract-BljSE-Hx.mjs.map +1 -0
  33. package/dist/contract-BmwHIiMR.d.mts +150 -0
  34. package/dist/contract-CWJSYoJl.d.cts +150 -0
  35. package/dist/contract-Cht05WYQ.d.mts +159 -0
  36. package/dist/contract-CqYQzB6e.d.cts +49 -0
  37. package/dist/contract-DYvBNdnR.cjs +74 -0
  38. package/dist/contract-DYvBNdnR.cjs.map +1 -0
  39. package/dist/contract-DlTo4u2t.d.cts +30 -0
  40. package/dist/contract-DlTo4u2t.d.mts +30 -0
  41. package/dist/contract-DsVL5-gy.cjs +50 -0
  42. package/dist/contract-DsVL5-gy.cjs.map +1 -0
  43. package/dist/contract-isM9SjjQ.mjs +39 -0
  44. package/dist/contract-isM9SjjQ.mjs.map +1 -0
  45. package/dist/contract-pU3wGFmo.d.cts +159 -0
  46. package/dist/contract-yPNuFnVy.d.mts +49 -0
  47. package/dist/core-C0ceVOTk.d.cts +513 -0
  48. package/dist/core-CTr7dw0v.cjs +1725 -0
  49. package/dist/core-CTr7dw0v.cjs.map +1 -0
  50. package/dist/core-IdGEbYdM.mjs +1541 -0
  51. package/dist/core-IdGEbYdM.mjs.map +1 -0
  52. package/dist/core-KtEHRScZ.d.mts +513 -0
  53. package/dist/core.cjs +9 -0
  54. package/dist/core.d.cts +2 -0
  55. package/dist/core.d.mts +2 -0
  56. package/dist/core.mjs +2 -0
  57. package/dist/create-fetch-handler-1pXSEhGi.d.cts +311 -0
  58. package/dist/create-fetch-handler-BwQQ_IWf.mjs +2156 -0
  59. package/dist/create-fetch-handler-BwQQ_IWf.mjs.map +1 -0
  60. package/dist/create-fetch-handler-D8cTMVX9.cjs +2232 -0
  61. package/dist/create-fetch-handler-D8cTMVX9.cjs.map +1 -0
  62. package/dist/create-fetch-handler-zioPVS18.d.mts +311 -0
  63. package/dist/elysia-shared-C7geKqPP.mjs +55 -0
  64. package/dist/elysia-shared-C7geKqPP.mjs.map +1 -0
  65. package/dist/elysia-shared-DT4bfekR.d.cts +20 -0
  66. package/dist/elysia-shared-DXyAyGz_.cjs +66 -0
  67. package/dist/elysia-shared-DXyAyGz_.cjs.map +1 -0
  68. package/dist/elysia-shared-DoL5ab52.d.mts +20 -0
  69. package/dist/entry-auth-basic.cjs +5 -0
  70. package/dist/entry-auth-basic.d.cts +83 -0
  71. package/dist/entry-auth-basic.d.mts +83 -0
  72. package/dist/entry-auth-basic.mjs +2 -0
  73. package/dist/entry-auth-delegated.cjs +28 -0
  74. package/dist/entry-auth-delegated.cjs.map +1 -0
  75. package/dist/entry-auth-delegated.d.cts +36 -0
  76. package/dist/entry-auth-delegated.d.mts +36 -0
  77. package/dist/entry-auth-delegated.mjs +27 -0
  78. package/dist/entry-auth-delegated.mjs.map +1 -0
  79. package/dist/entry-auth-none.cjs +4 -0
  80. package/dist/entry-auth-none.d.cts +25 -0
  81. package/dist/entry-auth-none.d.mts +25 -0
  82. package/dist/entry-auth-none.mjs +2 -0
  83. package/dist/entry-authorization-delegated.cjs +28 -0
  84. package/dist/entry-authorization-delegated.cjs.map +1 -0
  85. package/dist/entry-authorization-delegated.d.cts +32 -0
  86. package/dist/entry-authorization-delegated.d.mts +32 -0
  87. package/dist/entry-authorization-delegated.mjs +27 -0
  88. package/dist/entry-authorization-delegated.mjs.map +1 -0
  89. package/dist/entry-authorization-none.cjs +3 -0
  90. package/dist/entry-authorization-none.d.cts +18 -0
  91. package/dist/entry-authorization-none.d.mts +18 -0
  92. package/dist/entry-authorization-none.mjs +2 -0
  93. package/dist/entry-authorization-roles.cjs +8 -0
  94. package/dist/entry-authorization-roles.d.cts +64 -0
  95. package/dist/entry-authorization-roles.d.mts +64 -0
  96. package/dist/entry-authorization-roles.mjs +3 -0
  97. package/dist/entry-bun.cjs +55 -0
  98. package/dist/entry-bun.cjs.map +1 -0
  99. package/dist/entry-bun.d.cts +29 -0
  100. package/dist/entry-bun.d.mts +29 -0
  101. package/dist/entry-bun.mjs +52 -0
  102. package/dist/entry-bun.mjs.map +1 -0
  103. package/dist/entry-drizzle-audit.cjs +191 -0
  104. package/dist/entry-drizzle-audit.cjs.map +1 -0
  105. package/dist/entry-drizzle-audit.d.cts +118 -0
  106. package/dist/entry-drizzle-audit.d.mts +118 -0
  107. package/dist/entry-drizzle-audit.mjs +186 -0
  108. package/dist/entry-drizzle-audit.mjs.map +1 -0
  109. package/dist/entry-drizzle-mysql.cjs +75 -0
  110. package/dist/entry-drizzle-mysql.cjs.map +1 -0
  111. package/dist/entry-drizzle-mysql.d.cts +42 -0
  112. package/dist/entry-drizzle-mysql.d.mts +42 -0
  113. package/dist/entry-drizzle-mysql.mjs +71 -0
  114. package/dist/entry-drizzle-mysql.mjs.map +1 -0
  115. package/dist/entry-drizzle-pg.cjs +82 -0
  116. package/dist/entry-drizzle-pg.cjs.map +1 -0
  117. package/dist/entry-drizzle-pg.d.cts +48 -0
  118. package/dist/entry-drizzle-pg.d.mts +48 -0
  119. package/dist/entry-drizzle-pg.mjs +78 -0
  120. package/dist/entry-drizzle-pg.mjs.map +1 -0
  121. package/dist/entry-drizzle-sqlite.cjs +71 -0
  122. package/dist/entry-drizzle-sqlite.cjs.map +1 -0
  123. package/dist/entry-drizzle-sqlite.d.cts +37 -0
  124. package/dist/entry-drizzle-sqlite.d.mts +37 -0
  125. package/dist/entry-drizzle-sqlite.mjs +67 -0
  126. package/dist/entry-drizzle-sqlite.mjs.map +1 -0
  127. package/dist/entry-elysia.cjs +112 -0
  128. package/dist/entry-elysia.cjs.map +1 -0
  129. package/dist/entry-elysia.d.cts +710 -0
  130. package/dist/entry-elysia.d.mts +710 -0
  131. package/dist/entry-elysia.mjs +109 -0
  132. package/dist/entry-elysia.mjs.map +1 -0
  133. package/dist/entry-elysia2.cjs +101 -0
  134. package/dist/entry-elysia2.cjs.map +1 -0
  135. package/dist/entry-elysia2.d.cts +905 -0
  136. package/dist/entry-elysia2.d.mts +905 -0
  137. package/dist/entry-elysia2.mjs +98 -0
  138. package/dist/entry-elysia2.mjs.map +1 -0
  139. package/dist/entry-express.cjs +90 -0
  140. package/dist/entry-express.cjs.map +1 -0
  141. package/dist/entry-express.d.cts +24 -0
  142. package/dist/entry-express.d.mts +24 -0
  143. package/dist/entry-express.mjs +88 -0
  144. package/dist/entry-express.mjs.map +1 -0
  145. package/dist/entry-hono.cjs +36 -0
  146. package/dist/entry-hono.cjs.map +1 -0
  147. package/dist/entry-hono.d.cts +24 -0
  148. package/dist/entry-hono.d.mts +24 -0
  149. package/dist/entry-hono.mjs +34 -0
  150. package/dist/entry-hono.mjs.map +1 -0
  151. package/dist/entry-hooks-log.cjs +22 -0
  152. package/dist/entry-hooks-log.cjs.map +1 -0
  153. package/dist/entry-hooks-log.d.cts +23 -0
  154. package/dist/entry-hooks-log.d.mts +23 -0
  155. package/dist/entry-hooks-log.mjs +21 -0
  156. package/dist/entry-hooks-log.mjs.map +1 -0
  157. package/dist/entry-sinks-console.cjs +43 -0
  158. package/dist/entry-sinks-console.cjs.map +1 -0
  159. package/dist/entry-sinks-console.d.cts +26 -0
  160. package/dist/entry-sinks-console.d.mts +26 -0
  161. package/dist/entry-sinks-console.mjs +41 -0
  162. package/dist/entry-sinks-console.mjs.map +1 -0
  163. package/dist/entry-sinks-datadog.cjs +97 -0
  164. package/dist/entry-sinks-datadog.cjs.map +1 -0
  165. package/dist/entry-sinks-datadog.d.cts +66 -0
  166. package/dist/entry-sinks-datadog.d.mts +66 -0
  167. package/dist/entry-sinks-datadog.mjs +91 -0
  168. package/dist/entry-sinks-datadog.mjs.map +1 -0
  169. package/dist/entry-sinks-file.cjs +100 -0
  170. package/dist/entry-sinks-file.cjs.map +1 -0
  171. package/dist/entry-sinks-file.d.cts +70 -0
  172. package/dist/entry-sinks-file.d.mts +70 -0
  173. package/dist/entry-sinks-file.mjs +97 -0
  174. package/dist/entry-sinks-file.mjs.map +1 -0
  175. package/dist/entry-sinks-http.cjs +63 -0
  176. package/dist/entry-sinks-http.cjs.map +1 -0
  177. package/dist/entry-sinks-http.d.cts +55 -0
  178. package/dist/entry-sinks-http.d.mts +55 -0
  179. package/dist/entry-sinks-http.mjs +60 -0
  180. package/dist/entry-sinks-http.mjs.map +1 -0
  181. package/dist/entry-sinks-s3.cjs +115 -0
  182. package/dist/entry-sinks-s3.cjs.map +1 -0
  183. package/dist/entry-sinks-s3.d.cts +79 -0
  184. package/dist/entry-sinks-s3.d.mts +79 -0
  185. package/dist/entry-sinks-s3.mjs +112 -0
  186. package/dist/entry-sinks-s3.mjs.map +1 -0
  187. package/dist/entry-sinks-splunk.cjs +80 -0
  188. package/dist/entry-sinks-splunk.cjs.map +1 -0
  189. package/dist/entry-sinks-splunk.d.cts +58 -0
  190. package/dist/entry-sinks-splunk.d.mts +58 -0
  191. package/dist/entry-sinks-splunk.mjs +77 -0
  192. package/dist/entry-sinks-splunk.mjs.map +1 -0
  193. package/dist/entry-sinks-webhook.cjs +130 -0
  194. package/dist/entry-sinks-webhook.cjs.map +1 -0
  195. package/dist/entry-sinks-webhook.d.cts +69 -0
  196. package/dist/entry-sinks-webhook.d.mts +69 -0
  197. package/dist/entry-sinks-webhook.mjs +125 -0
  198. package/dist/entry-sinks-webhook.mjs.map +1 -0
  199. package/dist/entry-sinks-xtandard-webhooks.cjs +64 -0
  200. package/dist/entry-sinks-xtandard-webhooks.cjs.map +1 -0
  201. package/dist/entry-sinks-xtandard-webhooks.d.cts +64 -0
  202. package/dist/entry-sinks-xtandard-webhooks.d.mts +64 -0
  203. package/dist/entry-sinks-xtandard-webhooks.mjs +63 -0
  204. package/dist/entry-sinks-xtandard-webhooks.mjs.map +1 -0
  205. package/dist/entry-storage-cloudflare-kv.cjs +47 -0
  206. package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
  207. package/dist/entry-storage-cloudflare-kv.d.cts +42 -0
  208. package/dist/entry-storage-cloudflare-kv.d.mts +42 -0
  209. package/dist/entry-storage-cloudflare-kv.mjs +46 -0
  210. package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
  211. package/dist/entry-storage-drizzle.cjs +228 -0
  212. package/dist/entry-storage-drizzle.cjs.map +1 -0
  213. package/dist/entry-storage-drizzle.d.cts +43 -0
  214. package/dist/entry-storage-drizzle.d.mts +43 -0
  215. package/dist/entry-storage-drizzle.mjs +227 -0
  216. package/dist/entry-storage-drizzle.mjs.map +1 -0
  217. package/dist/entry-storage-file.cjs +175 -0
  218. package/dist/entry-storage-file.cjs.map +1 -0
  219. package/dist/entry-storage-file.d.cts +41 -0
  220. package/dist/entry-storage-file.d.mts +41 -0
  221. package/dist/entry-storage-file.mjs +171 -0
  222. package/dist/entry-storage-file.mjs.map +1 -0
  223. package/dist/entry-storage-libsql.cjs +133 -0
  224. package/dist/entry-storage-libsql.cjs.map +1 -0
  225. package/dist/entry-storage-libsql.d.cts +60 -0
  226. package/dist/entry-storage-libsql.d.mts +60 -0
  227. package/dist/entry-storage-libsql.mjs +132 -0
  228. package/dist/entry-storage-libsql.mjs.map +1 -0
  229. package/dist/entry-storage-memory.cjs +3 -0
  230. package/dist/entry-storage-memory.d.cts +2 -0
  231. package/dist/entry-storage-memory.d.mts +2 -0
  232. package/dist/entry-storage-memory.mjs +2 -0
  233. package/dist/entry-storage-mongodb.cjs +306 -0
  234. package/dist/entry-storage-mongodb.cjs.map +1 -0
  235. package/dist/entry-storage-mongodb.d.cts +65 -0
  236. package/dist/entry-storage-mongodb.d.mts +65 -0
  237. package/dist/entry-storage-mongodb.mjs +304 -0
  238. package/dist/entry-storage-mongodb.mjs.map +1 -0
  239. package/dist/entry-storage-postgres.cjs +261 -0
  240. package/dist/entry-storage-postgres.cjs.map +1 -0
  241. package/dist/entry-storage-postgres.d.cts +66 -0
  242. package/dist/entry-storage-postgres.d.mts +66 -0
  243. package/dist/entry-storage-postgres.mjs +260 -0
  244. package/dist/entry-storage-postgres.mjs.map +1 -0
  245. package/dist/entry-storage-redis.cjs +223 -0
  246. package/dist/entry-storage-redis.cjs.map +1 -0
  247. package/dist/entry-storage-redis.d.cts +77 -0
  248. package/dist/entry-storage-redis.d.mts +77 -0
  249. package/dist/entry-storage-redis.mjs +221 -0
  250. package/dist/entry-storage-redis.mjs.map +1 -0
  251. package/dist/entry-storage-sqlite.cjs +85 -0
  252. package/dist/entry-storage-sqlite.cjs.map +1 -0
  253. package/dist/entry-storage-sqlite.d.cts +40 -0
  254. package/dist/entry-storage-sqlite.d.mts +40 -0
  255. package/dist/entry-storage-sqlite.mjs +84 -0
  256. package/dist/entry-storage-sqlite.mjs.map +1 -0
  257. package/dist/entry-storage-unstorage.cjs +57 -0
  258. package/dist/entry-storage-unstorage.cjs.map +1 -0
  259. package/dist/entry-storage-unstorage.d.cts +29 -0
  260. package/dist/entry-storage-unstorage.d.mts +29 -0
  261. package/dist/entry-storage-unstorage.mjs +56 -0
  262. package/dist/entry-storage-unstorage.mjs.map +1 -0
  263. package/dist/export-B9S-JeYl.mjs +239 -0
  264. package/dist/export-B9S-JeYl.mjs.map +1 -0
  265. package/dist/export-BZq0KCCn.d.mts +70 -0
  266. package/dist/export-DYfMd-ep.cjs +280 -0
  267. package/dist/export-DYfMd-ep.cjs.map +1 -0
  268. package/dist/export-Dh8T8I1p.d.cts +70 -0
  269. package/dist/index.cjs +279 -0
  270. package/dist/index.cjs.map +1 -0
  271. package/dist/index.d.cts +286 -0
  272. package/dist/index.d.mts +284 -0
  273. package/dist/index.mjs +177 -0
  274. package/dist/index.mjs.map +1 -0
  275. package/dist/integrity-BHhjTBNk.cjs +614 -0
  276. package/dist/integrity-BHhjTBNk.cjs.map +1 -0
  277. package/dist/integrity-kfY2DNAi.mjs +483 -0
  278. package/dist/integrity-kfY2DNAi.mjs.map +1 -0
  279. package/dist/memory-CfykUo9W.cjs +155 -0
  280. package/dist/memory-CfykUo9W.cjs.map +1 -0
  281. package/dist/memory-DrR-Tlbf.d.mts +28 -0
  282. package/dist/memory-GG2Nba1D.mjs +150 -0
  283. package/dist/memory-GG2Nba1D.mjs.map +1 -0
  284. package/dist/memory-HpFdlMR_.d.cts +28 -0
  285. package/dist/none-Be7r6kHH.cjs +33 -0
  286. package/dist/none-Be7r6kHH.cjs.map +1 -0
  287. package/dist/none-CGmIIbI8.cjs +49 -0
  288. package/dist/none-CGmIIbI8.cjs.map +1 -0
  289. package/dist/none-CkV5mZsB.mjs +33 -0
  290. package/dist/none-CkV5mZsB.mjs.map +1 -0
  291. package/dist/none-DBeBeU0Z.mjs +23 -0
  292. package/dist/none-DBeBeU0Z.mjs.map +1 -0
  293. package/dist/query-ChGGtlA7.cjs +243 -0
  294. package/dist/query-ChGGtlA7.cjs.map +1 -0
  295. package/dist/query-LvZbyi37.mjs +172 -0
  296. package/dist/query-LvZbyi37.mjs.map +1 -0
  297. package/dist/react.css +1 -0
  298. package/dist/react.js +31936 -0
  299. package/dist/recorder-B3dG3jbd.d.mts +64 -0
  300. package/dist/recorder-CGY7HK29.d.cts +64 -0
  301. package/dist/roles-BARtYLSX.cjs +112 -0
  302. package/dist/roles-BARtYLSX.cjs.map +1 -0
  303. package/dist/roles-D7Pg89IJ.mjs +83 -0
  304. package/dist/roles-D7Pg89IJ.mjs.map +1 -0
  305. package/dist/schema-DmU7Wp0F.d.cts +251 -0
  306. package/dist/schema-DmU7Wp0F.d.mts +251 -0
  307. package/dist/schema.cjs +20 -0
  308. package/dist/schema.cjs.map +1 -0
  309. package/dist/schema.d.cts +2 -0
  310. package/dist/schema.d.mts +2 -0
  311. package/dist/schema.mjs +17 -0
  312. package/dist/schema.mjs.map +1 -0
  313. package/dist/shared-CJOyJKqT.d.mts +20 -0
  314. package/dist/shared-DSDY-V0n.mjs +100 -0
  315. package/dist/shared-DSDY-V0n.mjs.map +1 -0
  316. package/dist/shared-EANCdRqn.d.cts +20 -0
  317. package/dist/shared-OOAq-U4S.cjs +141 -0
  318. package/dist/shared-OOAq-U4S.cjs.map +1 -0
  319. package/dist/sql-B7b6HzGy.cjs +280 -0
  320. package/dist/sql-B7b6HzGy.cjs.map +1 -0
  321. package/dist/sql-COjPyn3F.mjs +209 -0
  322. package/dist/sql-COjPyn3F.mjs.map +1 -0
  323. package/dist/sqlite-event-log-BnoG8eos.cjs +184 -0
  324. package/dist/sqlite-event-log-BnoG8eos.cjs.map +1 -0
  325. package/dist/sqlite-event-log-nXmS2DS_.mjs +179 -0
  326. package/dist/sqlite-event-log-nXmS2DS_.mjs.map +1 -0
  327. package/dist/streams-CRuxOYcb.d.cts +124 -0
  328. package/dist/streams-DU0_gvI8.d.mts +124 -0
  329. package/dist/table-BcarDd10.d.cts +48 -0
  330. package/dist/table-BcarDd10.d.mts +48 -0
  331. package/dist/testing.cjs +189 -0
  332. package/dist/testing.cjs.map +1 -0
  333. package/dist/testing.d.cts +103 -0
  334. package/dist/testing.d.mts +103 -0
  335. package/dist/testing.mjs +185 -0
  336. package/dist/testing.mjs.map +1 -0
  337. package/dist/types-elysia2/adapters/bun.d.ts +47 -0
  338. package/dist/types-elysia2/adapters/context-shared.d.ts +40 -0
  339. package/dist/types-elysia2/adapters/elysia-shared.d.ts +36 -0
  340. package/dist/types-elysia2/adapters/elysia2.d.ts +588 -0
  341. package/dist/types-elysia2/auth/contract.d.ts +26 -0
  342. package/dist/types-elysia2/authorization/contract.d.ts +54 -0
  343. package/dist/types-elysia2/canonical.d.ts +25 -0
  344. package/dist/types-elysia2/context.d.ts +61 -0
  345. package/dist/types-elysia2/core.d.ts +232 -0
  346. package/dist/types-elysia2/duration.d.ts +26 -0
  347. package/dist/types-elysia2/entry-elysia2.d.ts +10 -0
  348. package/dist/types-elysia2/event-log.d.ts +33 -0
  349. package/dist/types-elysia2/export.d.ts +77 -0
  350. package/dist/types-elysia2/hooks/contract.d.ts +177 -0
  351. package/dist/types-elysia2/id.d.ts +27 -0
  352. package/dist/types-elysia2/integrity.d.ts +193 -0
  353. package/dist/types-elysia2/keys.d.ts +91 -0
  354. package/dist/types-elysia2/portal.d.ts +137 -0
  355. package/dist/types-elysia2/query.d.ts +88 -0
  356. package/dist/types-elysia2/schema.d.ts +247 -0
  357. package/dist/types-elysia2/server/base-path.d.ts +15 -0
  358. package/dist/types-elysia2/server/cors.d.ts +36 -0
  359. package/dist/types-elysia2/server/create-fetch-handler.d.ts +140 -0
  360. package/dist/types-elysia2/server/openapi.d.ts +25 -0
  361. package/dist/types-elysia2/server/render-index-html.d.ts +18 -0
  362. package/dist/types-elysia2/server/routes.d.ts +83 -0
  363. package/dist/types-elysia2/server/static-assets.d.ts +13 -0
  364. package/dist/types-elysia2/standard-schema.d.ts +100 -0
  365. package/dist/types-elysia2/storage/contract.d.ts +106 -0
  366. package/dist/types-elysia2/streams.d.ts +134 -0
  367. package/dist/types-elysia2/transforms.d.ts +56 -0
  368. package/dist/types-elysia2/validation.d.ts +48 -0
  369. package/dist/types-react/canonical.d.ts +25 -0
  370. package/dist/types-react/context.d.ts +61 -0
  371. package/dist/types-react/core.d.ts +232 -0
  372. package/dist/types-react/duration.d.ts +26 -0
  373. package/dist/types-react/event-log.d.ts +33 -0
  374. package/dist/types-react/hooks/contract.d.ts +177 -0
  375. package/dist/types-react/id.d.ts +27 -0
  376. package/dist/types-react/integrity.d.ts +193 -0
  377. package/dist/types-react/keys.d.ts +91 -0
  378. package/dist/types-react/query.d.ts +88 -0
  379. package/dist/types-react/react.d.ts +114 -0
  380. package/dist/types-react/schema.d.ts +247 -0
  381. package/dist/types-react/standard-schema.d.ts +100 -0
  382. package/dist/types-react/storage/contract.d.ts +106 -0
  383. package/dist/types-react/streams.d.ts +134 -0
  384. package/dist/types-react/transforms.d.ts +56 -0
  385. package/dist/types-react/ui/App.d.ts +36 -0
  386. package/dist/types-react/ui/api.d.ts +61 -0
  387. package/dist/types-react/ui/components/ActionFilter.d.ts +17 -0
  388. package/dist/types-react/ui/components/ExportMenu.d.ts +13 -0
  389. package/dist/types-react/ui/components/JsonCodeEditor.d.ts +12 -0
  390. package/dist/types-react/ui/components/ThemeToggle.d.ts +2 -0
  391. package/dist/types-react/ui/components/Toast.d.ts +16 -0
  392. package/dist/types-react/ui/components/audit-bits.d.ts +91 -0
  393. package/dist/types-react/ui/components/integrity-bits.d.ts +19 -0
  394. package/dist/types-react/ui/components/primitives.d.ts +50 -0
  395. package/dist/types-react/ui/components/ui-bits.d.ts +22 -0
  396. package/dist/types-react/ui/lib/filters.d.ts +70 -0
  397. package/dist/types-react/ui/lib/format.d.ts +82 -0
  398. package/dist/types-react/ui/lib/nav-guard.d.ts +20 -0
  399. package/dist/types-react/ui/lib/portal-container.d.ts +24 -0
  400. package/dist/types-react/ui/lib/utils.d.ts +3 -0
  401. package/dist/types-react/ui/theme.d.ts +40 -0
  402. package/dist/types-react/ui/types.d.ts +67 -0
  403. package/dist/types-react/ui/views/ActionsView.d.ts +10 -0
  404. package/dist/types-react/ui/views/EventDrawer.d.ts +15 -0
  405. package/dist/types-react/ui/views/EventsView.d.ts +10 -0
  406. package/dist/types-react/ui/views/IntegrityView.d.ts +10 -0
  407. package/dist/types-react/ui/views/OverviewView.d.ts +9 -0
  408. package/dist/types-react/ui/views/StreamsView.d.ts +10 -0
  409. package/dist/types-react/ui/views/TenantsView.d.ts +6 -0
  410. package/dist/types-react/validation.d.ts +48 -0
  411. package/dist/ui/assets/favicon-BSj8MPnj.svg +11 -0
  412. package/dist/ui/assets/index-B-qrQSOM.css +1 -0
  413. package/dist/ui/assets/index-CemlP5hR.js +244 -0
  414. package/dist/ui/index.html +15 -0
  415. package/dist/validation-DFrLESZD.mjs +150 -0
  416. package/dist/validation-DFrLESZD.mjs.map +1 -0
  417. package/dist/validation-lb0YXrxx.cjs +235 -0
  418. package/dist/validation-lb0YXrxx.cjs.map +1 -0
  419. package/dist/verify.cjs +14 -0
  420. package/dist/verify.d.cts +5 -0
  421. package/dist/verify.d.mts +5 -0
  422. package/dist/verify.mjs +3 -0
  423. package/package.json +610 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","names":["getAuditContext","newId","validateEventInput"],"sources":["../src/recorder.ts","../src/version.ts","../src/storage/watch.ts"],"sourcesContent":["/**\n * The buffered recorder (ADR 0002): fire-and-forget recording for hot paths\n * that must not wait on the database, without ever dropping an event silently.\n *\n * - `record()` validates **synchronously** (structural checks — programmer\n * errors throw at the call site) and enqueues; it returns immediately.\n * - Batches flush per tenant when `batchSize` is reached or every\n * `flushIntervalMs`, through `core.recordMany` (one chain append per tenant).\n * - A failed batch is retried with exponential backoff (`retry`). When retries\n * are exhausted the batch goes to `fallback` (if any) **and** `onError`\n * fires; without a fallback it stays queued for the next flush.\n * - The queue is bounded by `maxQueue`; past it `record()` throws\n * {@link RecorderOverflowError} — backpressure instead of silent loss.\n * - `flush()` drains now; `close()` stops the timer and drains (call it on\n * shutdown). A hard crash can lose what is still in memory — use\n * `core.record` (or a durable `fallback`) where that is unacceptable.\n *\n * @module\n */\n\nimport type { AuditCore, RecordInput } from \"./core.ts\";\nimport type { AuditEvent } from \"./schema.ts\";\nimport type { ActionMap } from \"./standard-schema.ts\";\nimport { getAuditContext } from \"./context.ts\";\nimport { newId } from \"./id.ts\";\nimport { assertValid, validateEventInput } from \"./validation.ts\";\n\n/** Thrown by {@link Recorder.record} when the queue is full. */\nexport class RecorderOverflowError extends Error {\n constructor(maxQueue: number) {\n super(`Audit recorder queue is full (${maxQueue} events); events are not being persisted`);\n this.name = \"RecorderOverflowError\";\n }\n}\n\n/** Where batches go when storage keeps failing (e.g. a JSONL file, stderr, a queue). */\nexport interface RecorderFallback {\n write(inputs: RecordInput[], error: unknown): void | Promise<void>;\n}\n\n/** Options for {@link createRecorder}. */\nexport interface RecorderOptions {\n /** Flush when this many events are queued. Default 100. */\n batchSize?: number;\n /** Flush at least this often. Default 1000 ms. */\n flushIntervalMs?: number;\n /** Max events held in memory. Default 10 000. */\n maxQueue?: number;\n /** Retries per batch before giving up to the fallback. Default `{ attempts: 3, baseDelayMs: 200 }`. */\n retry?: { attempts?: number; baseDelayMs?: number };\n /** Receives batches that exhausted their retries. */\n fallback?: RecorderFallback;\n /** Called for every batch that exhausted its retries (always, fallback or not). */\n onError?: (error: unknown, inputs: RecordInput[]) => void;\n /** Called after each committed batch. */\n onFlush?: (events: AuditEvent[]) => void;\n}\n\n/** A buffered recorder over a core. */\nexport interface Recorder<A extends ActionMap = ActionMap> {\n /** Enqueue an event. Throws synchronously on invalid input or overflow. */\n record(input: RecordInput<A>): void;\n /** Flush everything queued now. Resolves when the queue is drained (or parked). */\n flush(): Promise<void>;\n /** Stop the timer and flush. */\n close(): Promise<void>;\n /** Events waiting to be persisted. */\n readonly pending: number;\n}\n\nconst sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms));\n\n/**\n * Create a buffered recorder.\n *\n * @example\n * ```ts\n * import { createAuditCore, createRecorder } from \"@xtandard/audit\";\n *\n * const audit = createAuditCore({ storage });\n * const recorder = createRecorder(audit, {\n * batchSize: 200,\n * onError: (err, batch) => logger.error({ err, lost: batch.length }, \"audit backlog\"),\n * });\n *\n * recorder.record({ tenant: \"acme\", action: \"user.login\", actor: { id: \"u_1\" } });\n * process.on(\"SIGTERM\", () => recorder.close());\n * ```\n */\nexport function createRecorder<A extends ActionMap>(\n core: AuditCore<A>,\n options: RecorderOptions = {},\n): Recorder<A> {\n const batchSize = options.batchSize ?? 100;\n const intervalMs = options.flushIntervalMs ?? 1000;\n const maxQueue = options.maxQueue ?? 10_000;\n const attempts = options.retry?.attempts ?? 3;\n const baseDelayMs = options.retry?.baseDelayMs ?? 200;\n\n let queue: RecordInput<A>[] = [];\n let flushing: Promise<void> | null = null;\n let closed = false;\n const timer = setInterval(() => void flush(), intervalMs);\n (timer as { unref?: () => void }).unref?.();\n\n async function persist(batch: RecordInput<A>[]): Promise<void> {\n let lastError: unknown;\n for (let i = 0; i <= attempts; i++) {\n try {\n const events = await core.recordMany(batch);\n options.onFlush?.(events);\n return;\n } catch (err) {\n lastError = err;\n if (i < attempts) await sleep(baseDelayMs * 2 ** i);\n }\n }\n options.onError?.(lastError, batch as RecordInput[]);\n if (options.fallback) {\n await options.fallback.write(batch as RecordInput[], lastError);\n } else {\n // Park it back at the front: retried on the next flush, bounded by maxQueue.\n queue = [...batch, ...queue];\n throw lastError;\n }\n }\n\n async function drain(): Promise<void> {\n while (queue.length > 0) {\n const batch = queue.slice(0, batchSize);\n queue = queue.slice(batch.length);\n try {\n await persist(batch);\n } catch {\n return; // parked; try again next tick\n }\n }\n }\n\n function flush(): Promise<void> {\n if (!flushing) {\n flushing = drain().finally(() => {\n flushing = null;\n });\n }\n return flushing;\n }\n\n return {\n record(input) {\n if (closed) throw new Error(\"Audit recorder is closed\");\n if (queue.length >= maxQueue) throw new RecorderOverflowError(maxQueue);\n // Resolve ambient context now: the flush runs outside the caller's async scope.\n const scope = getAuditContext();\n const raw = input as RecordInput;\n const resolved = {\n ...raw,\n ...(raw.tenant === undefined && scope?.tenant ? { tenant: scope.tenant } : {}),\n ...(raw.actor === undefined && scope?.actor ? { actor: scope.actor } : {}),\n ...(scope?.context ? { context: { ...scope.context, ...raw.context } } : {}),\n occurredAt: raw.occurredAt ?? new Date(),\n // An id fixed at enqueue time makes retries and fallback replays idempotent: a batch\n // that partially committed (recordMany commits per tenant) is not duplicated.\n id: raw.id ?? newId(\"evt\"),\n };\n assertValid(validateEventInput(resolved));\n queue.push(resolved as RecordInput<A>);\n if (queue.length >= batchSize) void flush();\n },\n flush,\n async close() {\n closed = true;\n clearInterval(timer);\n await flush();\n },\n get pending() {\n return queue.length;\n },\n };\n}\n","/**\n * Package version, used for the default dispatcher `user-agent`. Bumped by the\n * release flow alongside `package.json`.\n *\n * @module\n */\n\n/** The published package version. */\nexport const VERSION = \"0.1.1\";\n","/**\n * Composable change-notifications. `watch` is **orthogonal** to which storage\n * you use, so rather than bake it into each adapter, {@link withWatch} wraps\n * *any* {@link AuditStorage} with a {@link WatchSubscribe} source you provide\n * — Postgres `LISTEN`/`NOTIFY`, Redis pub/sub, an ORM after-write hook, a\n * websocket, an `EventEmitter`, etc.\n *\n * This gives `watch` to adapters that don't implement it themselves (postgres,\n * drizzle, mongodb, unstorage, cloudflare-kv, …), driven by whatever change\n * signal your infrastructure already has.\n *\n * @example\n * ```ts\n * import { withWatch } from \"@xtandard/audit\";\n * import { createDrizzleStorage } from \"@xtandard/audit/storage/drizzle\";\n *\n * const storage = withWatch(createDrizzleStorage({ db, table }), (notify) => {\n * const sub = redis.subscribe(\"audit-changes\", (m) => notify(m.key));\n * return () => sub.unsubscribe();\n * });\n * ```\n *\n * @module\n */\n\nimport type { StorageChangeEvent, WatchableAuditStorage, AuditStorage } from \"./contract.ts\";\n\n/**\n * A change source. Called with a `notify` callback — wire your source to invoke\n * it (optionally with the changed key) on every change — and return an\n * unsubscribe function (sync or async).\n */\nexport type WatchSubscribe = (\n notify: (key?: string) => void,\n) => (() => void | Promise<void>) | Promise<() => void | Promise<void>>;\n\n/**\n * Wrap a storage so it implements {@link WatchableAuditStorage} using\n * `subscribe` as the change source. The wrapper delegates all reads/writes to\n * `storage` and only adds `watch`; keys not under the watched `prefix` are\n * filtered out. A notification without a key is delivered as a change to the\n * prefix itself (enough to trigger a refresh).\n */\nexport function withWatch<S extends AuditStorage>(\n storage: S,\n subscribe: WatchSubscribe,\n): S & WatchableAuditStorage {\n const watchable = Object.create(storage) as S & WatchableAuditStorage;\n watchable.watch = (prefix, callback) => {\n const notify = (key?: string): void => {\n if (key !== undefined && key !== \"\" && !key.startsWith(prefix)) return;\n callback({\n type: \"update\",\n key: key && key !== \"\" ? key : prefix,\n } satisfies StorageChangeEvent);\n };\n return Promise.resolve(subscribe(notify));\n };\n return watchable;\n}\n\n/**\n * A dedicated notification client for {@link pgListenNotify} — satisfied by a\n * `pg` `Client`. `Pool` won't do (it rotates connections); use a `Client` you\n * `connect()`.\n */\nexport interface PgNotificationClient {\n query(sql: string): Promise<unknown>;\n on(event: \"notification\", listener: (msg: { channel: string; payload?: string }) => void): void;\n removeListener(\n event: \"notification\",\n listener: (msg: { channel: string; payload?: string }) => void,\n ): void;\n}\n\n/**\n * A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with\n * {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration\n * owns the trigger that `pg_notify`s `channel` with the changed key as payload;\n * this only `LISTEN`s.\n *\n * @example\n * ```ts\n * import { Client } from \"pg\";\n * const listener = new Client({ connectionString: process.env.DATABASE_URL });\n * await listener.connect();\n * const storage = withWatch(base, pgListenNotify(listener, \"xtandard_audit\"));\n * ```\n */\nexport function pgListenNotify(\n client: PgNotificationClient,\n channel = \"xtandard_audit\",\n): WatchSubscribe {\n return async (notify) => {\n const listener = (msg: { channel: string; payload?: string }): void => {\n if (msg.channel === channel) notify(msg.payload);\n };\n client.on(\"notification\", listener);\n await client.query(`LISTEN \"${channel.replace(/\"/g, '\"\"')}\"`);\n return async () => {\n client.removeListener(\"notification\", listener);\n await client.query(`UNLISTEN \"${channel.replace(/\"/g, '\"\"')}\"`);\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA4BA,IAAa,wBAAb,cAA2C,MAAM;CAC/C,YAAY,UAAkB;EAC5B,MAAM,iCAAiC,SAAS,yCAAyC;EACzF,KAAK,OAAO;CACd;AACF;AAqCA,MAAM,SAAS,OAAe,IAAI,SAAe,MAAM,WAAW,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;AAmBxE,SAAgB,eACd,MACA,UAA2B,CAAC,GACf;CACb,MAAM,YAAY,QAAQ,aAAa;CACvC,MAAM,aAAa,QAAQ,mBAAmB;CAC9C,MAAM,WAAW,QAAQ,YAAY;CACrC,MAAM,WAAW,QAAQ,OAAO,YAAY;CAC5C,MAAM,cAAc,QAAQ,OAAO,eAAe;CAElD,IAAI,QAA0B,CAAC;CAC/B,IAAI,WAAiC;CACrC,IAAI,SAAS;CACb,MAAM,QAAQ,kBAAkB,KAAK,MAAM,GAAG,UAAU;CACxD,MAAkC,QAAQ;CAE1C,eAAe,QAAQ,OAAwC;EAC7D,IAAI;EACJ,KAAK,IAAI,IAAI,GAAG,KAAK,UAAU,KAC7B,IAAI;GACF,MAAM,SAAS,MAAM,KAAK,WAAW,KAAK;GAC1C,QAAQ,UAAU,MAAM;GACxB;EACF,SAAS,KAAK;GACZ,YAAY;GACZ,IAAI,IAAI,UAAU,MAAM,MAAM,cAAc,KAAK,CAAC;EACpD;EAEF,QAAQ,UAAU,WAAW,KAAsB;EACnD,IAAI,QAAQ,UACV,MAAM,QAAQ,SAAS,MAAM,OAAwB,SAAS;OACzD;GAEL,QAAQ,CAAC,GAAG,OAAO,GAAG,KAAK;GAC3B,MAAM;EACR;CACF;CAEA,eAAe,QAAuB;EACpC,OAAO,MAAM,SAAS,GAAG;GACvB,MAAM,QAAQ,MAAM,MAAM,GAAG,SAAS;GACtC,QAAQ,MAAM,MAAM,MAAM,MAAM;GAChC,IAAI;IACF,MAAM,QAAQ,KAAK;GACrB,QAAQ;IACN;GACF;EACF;CACF;CAEA,SAAS,QAAuB;EAC9B,IAAI,CAAC,UACH,WAAW,MAAM,EAAE,cAAc;GAC/B,WAAW;EACb,CAAC;EAEH,OAAO;CACT;CAEA,OAAO;EACL,OAAO,OAAO;GACZ,IAAI,QAAQ,MAAM,IAAI,MAAM,0BAA0B;GACtD,IAAI,MAAM,UAAU,UAAU,MAAM,IAAI,sBAAsB,QAAQ;GAEtE,MAAM,QAAQA,gBAAAA,gBAAgB;GAC9B,MAAM,MAAM;GACZ,MAAM,WAAW;IACf,GAAG;IACH,GAAI,IAAI,WAAW,KAAA,KAAa,OAAO,SAAS,EAAE,QAAQ,MAAM,OAAO,IAAI,CAAC;IAC5E,GAAI,IAAI,UAAU,KAAA,KAAa,OAAO,QAAQ,EAAE,OAAO,MAAM,MAAM,IAAI,CAAC;IACxE,GAAI,OAAO,UAAU,EAAE,SAAS;KAAE,GAAG,MAAM;KAAS,GAAG,IAAI;IAAQ,EAAE,IAAI,CAAC;IAC1E,YAAY,IAAI,8BAAc,IAAI,KAAK;IAGvC,IAAI,IAAI,MAAMC,aAAAA,MAAM,KAAK;GAC3B;GACA,mBAAA,YAAYC,mBAAAA,mBAAmB,QAAQ,CAAC;GACxC,MAAM,KAAK,QAA0B;GACrC,IAAI,MAAM,UAAU,WAAW,MAAW;EAC5C;EACA;EACA,MAAM,QAAQ;GACZ,SAAS;GACT,cAAc,KAAK;GACnB,MAAM,MAAM;EACd;EACA,IAAI,UAAU;GACZ,OAAO,MAAM;EACf;CACF;AACF;;;;;;;;;;AC3KA,MAAa,UAAU;;;;;;;;;;ACmCvB,SAAgB,UACd,SACA,WAC2B;CAC3B,MAAM,YAAY,OAAO,OAAO,OAAO;CACvC,UAAU,SAAS,QAAQ,aAAa;EACtC,MAAM,UAAU,QAAuB;GACrC,IAAI,QAAQ,KAAA,KAAa,QAAQ,MAAM,CAAC,IAAI,WAAW,MAAM,GAAG;GAChE,SAAS;IACP,MAAM;IACN,KAAK,OAAO,QAAQ,KAAK,MAAM;GACjC,CAA8B;EAChC;EACA,OAAO,QAAQ,QAAQ,UAAU,MAAM,CAAC;CAC1C;CACA,OAAO;AACT;;;;;;;;;;;;;;;AA8BA,SAAgB,eACd,QACA,UAAU,kBACM;CAChB,OAAO,OAAO,WAAW;EACvB,MAAM,YAAY,QAAqD;GACrE,IAAI,IAAI,YAAY,SAAS,OAAO,IAAI,OAAO;EACjD;EACA,OAAO,GAAG,gBAAgB,QAAQ;EAClC,MAAM,OAAO,MAAM,WAAW,QAAQ,QAAQ,MAAM,MAAI,EAAE,EAAE;EAC5D,OAAO,YAAY;GACjB,OAAO,eAAe,gBAAgB,QAAQ;GAC9C,MAAM,OAAO,MAAM,aAAa,QAAQ,QAAQ,MAAM,MAAI,EAAE,EAAE;EAChE;CACF;AACF"}
@@ -0,0 +1,286 @@
1
+ import { _ as ERASED_MARKER, a as AuditContext, b as SCHEMA_VERSION, c as AuditEventInput, d as AuditPage, f as AuditQuery, g as ChainHead, h as AuditTenant, i as AuditCheckpoint, l as AuditIntegrity, m as AuditTarget, n as ActionDefinition, o as AuditDuration, p as AuditSection, r as AuditActor, s as AuditEvent, t as AUDIT_SECTIONS, u as AuditOutcome, v as JsonObject, y as JsonValue } from "./schema-DmU7Wp0F.cjs";
2
+ import { _ as QueryPosition, a as StorageChangeEvent, b as matchesQuery, c as hasEventLog, d as isWatchable, f as requirePeer, g as QueryError, h as NormalizedQuery, i as EventLogStorage, l as isCompareAndSwap, m as MAX_QUERY_LIMIT, n as ChainConflictError, o as TransactionalAuditStorage, p as DEFAULT_QUERY_LIMIT, r as CompareAndSwapAuditStorage, s as WatchableAuditStorage, t as AuditStorage, u as isTransactional, v as decodeCursor, x as normalizeQuery, y as encodeCursor } from "./contract-CWJSYoJl.cjs";
3
+ import { $ as verifyCheckpointSignature, A as defineActions, B as computeDigests, C as maskValue, D as ActionMetadataInput, E as ActionMap, F as VerifyChainOptions, G as hmacVerificationKey, H as ed25519VerificationKey, I as VerifyIssue, J as sealEvent, K as keysFromJwks, L as VerifyIssueKind, M as AuditSigner, N as AuditVerificationKey, O as ActionSpec, P as GENESIS_HASH, Q as verifyChain, R as VerifyReport, S as mask, T as redact, U as generateSigningKeyPair, V as ed25519Signer, W as hmacSigner, X as sha256, Y as sectionDigest, Z as signCheckpoint, _ as AuditTransform, a as ConflictError, b as applyTransforms, c as PruneResult, d as RetentionOptions, et as verifyEvent, f as RetentionRule, g as eraseSections, h as createAuditCore, i as CheckpointOptions, j as runStandardSchema, k as StandardSchemaV1, l as ReadonlyError, m as SignerRequiredError, n as AuditCore, nt as createKvEventLog, o as EraseInput, p as SELF_AUDIT_ACTIONS, q as sealChain, r as AuditCoreOptions, rt as resolveEventLog, s as NotFoundError, t as ActorOptions, tt as EventLog, u as RecordInput, v as REDACTED, w as omit, x as hashValue, y as TransformableEvent, z as chainHeader } from "./core-C0ceVOTk.cjs";
4
+ import { a as BeforeEvent, c as HookDeniedError, d as normalizeHooks, f as runAfter, i as AuditHooksInput, l as HookErrorReporter, n as AfterEventType, o as BeforeEventType, p as runBefore, r as AuditHooks, s as HookActor, t as AfterEvent, u as defaultHookErrorReporter } from "./contract-pU3wGFmo.cjs";
5
+ import { a as StreamItem, c as StreamStatus, i as StreamDefinition, l as callbackSink, n as StreamBatch, o as StreamRunner, r as StreamCursor, s as StreamRunnerOptions, t as AuditSink, u as createStreamRunner } from "./streams-CRuxOYcb.cjs";
6
+ import { n as Principal, t as AuthProvider } from "./contract-DlTo4u2t.cjs";
7
+ import { a as AuthorizeInput, i as AuthorizationProvider, n as AuditAction, o as MUTATING_ACTIONS, r as AuditResource, s as isMutatingAction, t as ALL_ACTIONS } from "./contract-CqYQzB6e.cjs";
8
+ import { _ as verifyPortalToken, a as PanelConfig, c as PortalFilter, d as PortalTokenOptions, f as ScopedQuery, g as scopeQueryToPortal, h as portalCanSee, i as AuditPortalOptions, l as PortalGrant, m as intersectActions, n as CreateFetchHandlerResult, o as DEFAULT_PORTAL_ACTIONS, p as createPortalToken, r as createFetchHandler, s as PORTAL_TOKEN_PREFIX, t as AuditPanelOptions, u as PortalTokenError, v as AuditCorsOptions } from "./create-fetch-handler-1pXSEhGi.cjs";
9
+ import { a as ExportOptions, c as eventToCsvRow, d as verifyBundle, i as ExportFormat, l as exportEvents, n as CSV_COLUMNS, o as ParsedBundle, r as EXPORT_CONTENT_TYPES, s as csvCell, t as BundleHeader, u as parseBundle } from "./export-Dh8T8I1p.cjs";
10
+ import { a as createRecorder, i as RecorderOverflowError, n as RecorderFallback, r as RecorderOptions, t as Recorder } from "./recorder-CGY7HK29.cjs";
11
+ import { t as canonicalStringify } from "./canonical-BOgkrX9_.cjs";
12
+
13
+ //#region \0rolldown/runtime.js
14
+ //#endregion
15
+ //#region src/id.d.ts
16
+ /**
17
+ * Time-sortable ids (ADR 0010): `{prefix}_` + 26 Crockford base32 characters —
18
+ * 48 bits of unix milliseconds followed by 80 random bits, ULID-compatible.
19
+ * Monotonic within a process: ids minted in the same millisecond increment the
20
+ * random part, so lexicographic order equals creation order. Zero dependencies.
21
+ *
22
+ * @module
23
+ */
24
+ /** Prefixes for the generated id kinds. */
25
+ type IdPrefix = "evt" | "chk";
26
+ /**
27
+ * Generate a new id, e.g. `newId("evt")` → `"evt_01JD…"`.
28
+ *
29
+ * @example
30
+ * ```ts
31
+ * import { newId } from "@xtandard/audit";
32
+ *
33
+ * const id = newId("evt"); // "evt_01JD3Z…" — sorts by creation time
34
+ * ```
35
+ */
36
+ declare function newId(prefix: IdPrefix, ms?: number): string;
37
+ /** Regex an id of the given prefix must match. */
38
+ declare function idPattern(prefix: IdPrefix): RegExp;
39
+ /** Decode the millisecond timestamp embedded in a time-sortable id, or `null`. */
40
+ declare function idTime(id: string): number | null;
41
+ //#endregion
42
+ //#region src/duration.d.ts
43
+ /**
44
+ * Convert a {@link AuditDuration} (`5000`, `"5s"`, `"30m"`, `"2h"`, `"5d"`)
45
+ * to milliseconds. Throws on malformed strings or negative numbers.
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * import { durationToMs } from "@xtandard/audit";
50
+ *
51
+ * durationToMs("5m"); // 300000
52
+ * durationToMs(250); // 250
53
+ * ```
54
+ */
55
+ declare function durationToMs(duration: AuditDuration): number;
56
+ declare namespace keys_d_exports {
57
+ export { ROOT, actionIndexPrefix, actionKey, actionsKey, actorIndexPrefix, checkpointKey, checkpointsPrefix, decodeSegment, eventIdKey, eventKey, eventsPrefix, headKey, indexLeaf, indexRoot, lastSegment, padMs, padSeq, parseEventKey, parseIndexLeaf, streamCursorKey, streamCursorsPrefix, streamLeaseKey, streamMetaKey, targetIndexPrefix, tenantPrefix, tenantsKey, timeIndexPrefix };
58
+ }
59
+ /**
60
+ * Storage key layout for `@xtandard/audit`.
61
+ *
62
+ * Control data always lives in these KV keys. Events live here too on drivers
63
+ * without the native {@link ./storage/contract.EventLogStorage} capability (the
64
+ * generic fallback, ADR 0005). Pure string helpers — no dependencies.
65
+ *
66
+ * ```txt
67
+ * aud/tenants -> string[] index
68
+ * aud/actions -> string[] index (catalog)
69
+ * aud/actions/{name} -> ActionDefinition
70
+ * aud/t/{tenant}/head -> ChainHead
71
+ * aud/t/{tenant}/checkpoints/{chk id} -> AuditCheckpoint (time-sortable id)
72
+ * aud/streams/{stream}/cursors/{tenant} -> StreamCursor
73
+ * aud/streams/{stream}/meta -> { startedAt }
74
+ * aud/streams/{stream}/lease -> StreamLease
75
+ *
76
+ * — generic event log (KV fallback only) —
77
+ * aud/t/{tenant}/events/{seq 12} -> AuditEvent
78
+ * aud/t/{tenant}/ids/{event id} -> seq
79
+ * aud/t/{tenant}/ix/time/{ms 13}~{id} -> seq
80
+ * aud/t/{tenant}/ix/actor/{actorId}/{ms 13}~{id} -> seq
81
+ * aud/t/{tenant}/ix/action/{action}/{ms 13}~{id} -> seq
82
+ * aud/t/{tenant}/ix/target/{type}/{id}/{ms 13}~{id} -> seq
83
+ * ```
84
+ *
85
+ * Zero-padded numbers make lexicographic key order equal numeric order, so a
86
+ * sorted `getKeys` scan yields events by seq (or by occurredAt for the `ix/`
87
+ * indexes) on every backend. Free-form segments (tenant, actor id, action,
88
+ * target type/id) are `encodeURIComponent`-escaped so `/` and `~` cannot break
89
+ * the layout.
90
+ *
91
+ * @module
92
+ */
93
+ /** Root namespace segment for all keys. */
94
+ declare const ROOT = "aud";
95
+ /** Zero-pad a seq to 12 digits. */
96
+ declare const padSeq: (seq: number) => string;
97
+ /** Zero-pad epoch millis to 13 digits. */
98
+ declare const padMs: (ms: number) => string;
99
+ /** Index of all tenant keys. */
100
+ declare const tenantsKey: () => string;
101
+ /** Action catalog index. */
102
+ declare const actionsKey: () => string;
103
+ /** One action catalog entry. */
104
+ declare const actionKey: (name: string) => string;
105
+ /** Prefix under which everything belonging to one tenant lives. */
106
+ declare const tenantPrefix: (tenant: string) => string;
107
+ /** The tenant's chain head. */
108
+ declare const headKey: (tenant: string) => string;
109
+ /** Prefix of the tenant's checkpoints. */
110
+ declare const checkpointsPrefix: (tenant: string) => string;
111
+ /** One checkpoint. */
112
+ declare const checkpointKey: (tenant: string, id: string) => string;
113
+ /** Prefix of a stream's per-tenant cursors. */
114
+ declare const streamCursorsPrefix: (stream: string) => string;
115
+ /** One stream cursor. */
116
+ declare const streamCursorKey: (stream: string, tenant: string) => string;
117
+ /** A stream's metadata (first-run marker). */
118
+ declare const streamMetaKey: (stream: string) => string;
119
+ /** A stream's runner lease. */
120
+ declare const streamLeaseKey: (stream: string) => string;
121
+ /** Prefix of the tenant's events (by seq). */
122
+ declare const eventsPrefix: (tenant: string) => string;
123
+ /** One event, keyed by seq. */
124
+ declare const eventKey: (tenant: string, seq: number) => string;
125
+ /** Event id → seq. */
126
+ declare const eventIdKey: (tenant: string, id: string) => string;
127
+ /** Prefix of a tenant's secondary indexes. */
128
+ declare const indexRoot: (tenant: string) => string;
129
+ /** Time index prefix. */
130
+ declare const timeIndexPrefix: (tenant: string) => string;
131
+ /** Actor index prefix. */
132
+ declare const actorIndexPrefix: (tenant: string, actorId: string) => string;
133
+ /** Action index prefix. */
134
+ declare const actionIndexPrefix: (tenant: string, action: string) => string;
135
+ /** Target index prefix. */
136
+ declare const targetIndexPrefix: (tenant: string, type: string, id: string) => string;
137
+ /** The `{ms}~{id}` leaf of every index key. */
138
+ declare const indexLeaf: (occurredAtMs: number, id: string) => string;
139
+ /** Parse an index key's leaf back into `(occurredAtMs, id)`. */
140
+ declare const parseIndexLeaf: (key: string) => {
141
+ ms: number;
142
+ id: string;
143
+ } | null;
144
+ /** Parse a seq from an event key. */
145
+ declare const parseEventKey: (key: string) => number | null;
146
+ /** Extract the trailing segment from a key. */
147
+ declare const lastSegment: (key: string) => string;
148
+ /** Decode an escaped key segment. */
149
+ declare const decodeSegment: (segment: string) => string;
150
+ //#endregion
151
+ //#region src/version.d.ts
152
+ /**
153
+ * Package version, used for the default dispatcher `user-agent`. Bumped by the
154
+ * release flow alongside `package.json`.
155
+ *
156
+ * @module
157
+ */
158
+ /** The published package version. */
159
+ declare const VERSION = "0.1.1";
160
+ //#endregion
161
+ //#region src/storage/watch.d.ts
162
+ /**
163
+ * A change source. Called with a `notify` callback — wire your source to invoke
164
+ * it (optionally with the changed key) on every change — and return an
165
+ * unsubscribe function (sync or async).
166
+ */
167
+ type WatchSubscribe = (notify: (key?: string) => void) => (() => void | Promise<void>) | Promise<() => void | Promise<void>>;
168
+ /**
169
+ * Wrap a storage so it implements {@link WatchableAuditStorage} using
170
+ * `subscribe` as the change source. The wrapper delegates all reads/writes to
171
+ * `storage` and only adds `watch`; keys not under the watched `prefix` are
172
+ * filtered out. A notification without a key is delivered as a change to the
173
+ * prefix itself (enough to trigger a refresh).
174
+ */
175
+ declare function withWatch<S extends AuditStorage>(storage: S, subscribe: WatchSubscribe): S & WatchableAuditStorage;
176
+ /**
177
+ * A dedicated notification client for {@link pgListenNotify} — satisfied by a
178
+ * `pg` `Client`. `Pool` won't do (it rotates connections); use a `Client` you
179
+ * `connect()`.
180
+ */
181
+ interface PgNotificationClient {
182
+ query(sql: string): Promise<unknown>;
183
+ on(event: "notification", listener: (msg: {
184
+ channel: string;
185
+ payload?: string;
186
+ }) => void): void;
187
+ removeListener(event: "notification", listener: (msg: {
188
+ channel: string;
189
+ payload?: string;
190
+ }) => void): void;
191
+ }
192
+ /**
193
+ * A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with
194
+ * {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration
195
+ * owns the trigger that `pg_notify`s `channel` with the changed key as payload;
196
+ * this only `LISTEN`s.
197
+ *
198
+ * @example
199
+ * ```ts
200
+ * import { Client } from "pg";
201
+ * const listener = new Client({ connectionString: process.env.DATABASE_URL });
202
+ * await listener.connect();
203
+ * const storage = withWatch(base, pgListenNotify(listener, "xtandard_audit"));
204
+ * ```
205
+ */
206
+ declare function pgListenNotify(client: PgNotificationClient, channel?: string): WatchSubscribe;
207
+ //#endregion
208
+ //#region src/validation.d.ts
209
+ /**
210
+ * Runtime validation for record inputs and control-plane inputs, built on
211
+ * `valibot` (like the sibling packages). Action-specific `metadata` is validated
212
+ * separately by the host's Standard Schema validators (ADR 0012).
213
+ *
214
+ * @module
215
+ */
216
+ /** Allowed characters for tenant keys. */
217
+ declare const TENANT_REGEX: RegExp;
218
+ /** Allowed characters for action names (`invoice.paid`, `member:role_changed`). */
219
+ declare const ACTION_REGEX: RegExp;
220
+ /** Maximum serialized size of one event's free-form sections, in bytes. Default for `maxEventBytes`. */
221
+ declare const DEFAULT_MAX_EVENT_BYTES = 65536;
222
+ /** A single validation problem with a dotted path into the offending data. */
223
+ interface ValidationIssue {
224
+ path: string;
225
+ message: string;
226
+ }
227
+ /** Result of the `validate*` functions. */
228
+ interface ValidationResult {
229
+ valid: boolean;
230
+ errors: ValidationIssue[];
231
+ }
232
+ /** Raised by {@link assertValid} when an input fails validation. Maps to HTTP 422. */
233
+ declare class ValidationError extends Error {
234
+ readonly errors: ValidationIssue[];
235
+ constructor(errors: ValidationIssue[]);
236
+ }
237
+ /** Throw a {@link ValidationError} when `result` is invalid. */
238
+ declare function assertValid(result: ValidationResult): void;
239
+ /** Validate a tenant key. */
240
+ declare function validateTenant(tenant: unknown, basePath?: string): ValidationResult;
241
+ /**
242
+ * Validate the structure of a record input (not the action's metadata schema).
243
+ *
244
+ * @example
245
+ * ```ts
246
+ * import { validateEventInput } from "@xtandard/audit";
247
+ *
248
+ * validateEventInput({ tenant: "acme", action: "invoice.paid", actor: { id: "u_1" } }).valid; // true
249
+ * ```
250
+ */
251
+ declare function validateEventInput(input: unknown, options?: {
252
+ maxEventBytes?: number;
253
+ basePath?: string;
254
+ }): ValidationResult;
255
+ /** Validate an action catalog entry. */
256
+ declare function validateActionDefinition(input: unknown, basePath?: string): ValidationResult;
257
+ //#endregion
258
+ //#region src/server/openapi.d.ts
259
+ /**
260
+ * OpenAPI 3.1 description of the panel's JSON API (`docs/HTTP_API.md`).
261
+ *
262
+ * Exposed two ways, mirroring the sibling panels:
263
+ * - served at `GET {basePath}/api/openapi.json` for standalone tools (Scalar,
264
+ * Swagger UI, Postman, codegen);
265
+ * - returned by `createFetchHandler(...).openapi()` so you can MERGE it into
266
+ * your host app's OpenAPI document (e.g. Elysia `@elysiajs/openapi`
267
+ * `references`, or Hono's OpenAPI).
268
+ *
269
+ * Hand-authored — no generation dependency (flags precedent).
270
+ *
271
+ * @module
272
+ */
273
+ /** Options for {@link buildOpenApiDocument}. */
274
+ interface OpenApiOptions {
275
+ /** Mount prefix used in the `servers` url (e.g. `"/audit"`). */
276
+ basePath?: string;
277
+ /** Document title. */
278
+ title?: string;
279
+ /** Document version (defaults to the package's API version). */
280
+ version?: string;
281
+ }
282
+ /** Build the OpenAPI 3.1 document for the panel API. Pure — safe to call anywhere. */
283
+ declare function buildOpenApiDocument(options?: OpenApiOptions): Record<string, unknown>;
284
+ //#endregion
285
+ export { ACTION_REGEX, ALL_ACTIONS, AUDIT_SECTIONS, ActionDefinition, type ActionMap, type ActionMetadataInput, type ActionSpec, ActorOptions, type AfterEvent, type AfterEventType, type AuditAction, AuditActor, AuditCheckpoint, AuditContext, AuditCore, AuditCoreOptions, type AuditCorsOptions, AuditDuration, AuditEvent, AuditEventInput, type AuditHooks, type AuditHooksInput, AuditIntegrity, AuditOutcome, AuditPage, type AuditPanelOptions, type AuditPortalOptions, AuditQuery, type AuditResource, AuditSection, type AuditSigner, type AuditSink, type AuditStorage, AuditTarget, AuditTenant, type AuditTransform, type AuditVerificationKey, type AuthProvider, type AuthorizationProvider, type AuthorizeInput, type BeforeEvent, type BeforeEventType, type BundleHeader, CSV_COLUMNS, ChainConflictError, ChainHead, CheckpointOptions, type CompareAndSwapAuditStorage, ConflictError, type CreateFetchHandlerResult, DEFAULT_MAX_EVENT_BYTES, DEFAULT_PORTAL_ACTIONS, DEFAULT_QUERY_LIMIT, ERASED_MARKER, EXPORT_CONTENT_TYPES, EraseInput, type EventLog, type EventLogStorage, type ExportFormat, type ExportOptions, GENESIS_HASH, type HookActor, HookDeniedError, type HookErrorReporter, type IdPrefix, JsonObject, JsonValue, MAX_QUERY_LIMIT, MUTATING_ACTIONS, type NormalizedQuery, NotFoundError, type OpenApiOptions, PORTAL_TOKEN_PREFIX, type PanelConfig, type ParsedBundle, type PgNotificationClient, type PortalFilter, type PortalGrant, PortalTokenError, type PortalTokenOptions, type Principal, PruneResult, QueryError, type QueryPosition, REDACTED, ReadonlyError, RecordInput, type Recorder, type RecorderFallback, type RecorderOptions, RecorderOverflowError, RetentionOptions, RetentionRule, SCHEMA_VERSION, SELF_AUDIT_ACTIONS, type ScopedQuery, SignerRequiredError, type StandardSchemaV1, type StorageChangeEvent, type StreamBatch, type StreamCursor, type StreamDefinition, type StreamItem, type StreamRunner, type StreamRunnerOptions, type StreamStatus, TENANT_REGEX, type TransactionalAuditStorage, type TransformableEvent, VERSION, ValidationError, type ValidationIssue, type ValidationResult, type VerifyChainOptions, type VerifyIssue, type VerifyIssueKind, type VerifyReport, type WatchSubscribe, type WatchableAuditStorage, applyTransforms, assertValid, buildOpenApiDocument, callbackSink, canonicalStringify, chainHeader, computeDigests, createAuditCore, createFetchHandler, createKvEventLog, createPortalToken, createRecorder, createStreamRunner, csvCell, decodeCursor, defaultHookErrorReporter, defineActions, durationToMs, ed25519Signer, ed25519VerificationKey, encodeCursor, eraseSections, eventToCsvRow, exportEvents, generateSigningKeyPair, hasEventLog, hashValue, hmacSigner, hmacVerificationKey, idPattern, idTime, intersectActions, isCompareAndSwap, isMutatingAction, isTransactional, isWatchable, keys_d_exports as keys, keysFromJwks, mask, maskValue, matchesQuery, newId, normalizeHooks, normalizeQuery, omit, parseBundle, pgListenNotify, portalCanSee, redact, requirePeer, resolveEventLog, runAfter, runBefore, runStandardSchema, scopeQueryToPortal, sealChain, sealEvent, sectionDigest, sha256, signCheckpoint, validateActionDefinition, validateEventInput, validateTenant, verifyBundle, verifyChain, verifyCheckpointSignature, verifyEvent, verifyPortalToken, withWatch };
286
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1,284 @@
1
+ import { _ as ERASED_MARKER, a as AuditContext, b as SCHEMA_VERSION, c as AuditEventInput, d as AuditPage, f as AuditQuery, g as ChainHead, h as AuditTenant, i as AuditCheckpoint, l as AuditIntegrity, m as AuditTarget, n as ActionDefinition, o as AuditDuration, p as AuditSection, r as AuditActor, s as AuditEvent, t as AUDIT_SECTIONS, u as AuditOutcome, v as JsonObject, y as JsonValue } from "./schema-DmU7Wp0F.mjs";
2
+ import { _ as QueryPosition, a as StorageChangeEvent, b as matchesQuery, c as hasEventLog, d as isWatchable, f as requirePeer, g as QueryError, h as NormalizedQuery, i as EventLogStorage, l as isCompareAndSwap, m as MAX_QUERY_LIMIT, n as ChainConflictError, o as TransactionalAuditStorage, p as DEFAULT_QUERY_LIMIT, r as CompareAndSwapAuditStorage, s as WatchableAuditStorage, t as AuditStorage, u as isTransactional, v as decodeCursor, x as normalizeQuery, y as encodeCursor } from "./contract-BmwHIiMR.mjs";
3
+ import { $ as verifyCheckpointSignature, A as defineActions, B as computeDigests, C as maskValue, D as ActionMetadataInput, E as ActionMap, F as VerifyChainOptions, G as hmacVerificationKey, H as ed25519VerificationKey, I as VerifyIssue, J as sealEvent, K as keysFromJwks, L as VerifyIssueKind, M as AuditSigner, N as AuditVerificationKey, O as ActionSpec, P as GENESIS_HASH, Q as verifyChain, R as VerifyReport, S as mask, T as redact, U as generateSigningKeyPair, V as ed25519Signer, W as hmacSigner, X as sha256, Y as sectionDigest, Z as signCheckpoint, _ as AuditTransform, a as ConflictError, b as applyTransforms, c as PruneResult, d as RetentionOptions, et as verifyEvent, f as RetentionRule, g as eraseSections, h as createAuditCore, i as CheckpointOptions, j as runStandardSchema, k as StandardSchemaV1, l as ReadonlyError, m as SignerRequiredError, n as AuditCore, nt as createKvEventLog, o as EraseInput, p as SELF_AUDIT_ACTIONS, q as sealChain, r as AuditCoreOptions, rt as resolveEventLog, s as NotFoundError, t as ActorOptions, tt as EventLog, u as RecordInput, v as REDACTED, w as omit, x as hashValue, y as TransformableEvent, z as chainHeader } from "./core-KtEHRScZ.mjs";
4
+ import { a as BeforeEvent, c as HookDeniedError, d as normalizeHooks, f as runAfter, i as AuditHooksInput, l as HookErrorReporter, n as AfterEventType, o as BeforeEventType, p as runBefore, r as AuditHooks, s as HookActor, t as AfterEvent, u as defaultHookErrorReporter } from "./contract-Cht05WYQ.mjs";
5
+ import { a as StreamItem, c as StreamStatus, i as StreamDefinition, l as callbackSink, n as StreamBatch, o as StreamRunner, r as StreamCursor, s as StreamRunnerOptions, t as AuditSink, u as createStreamRunner } from "./streams-DU0_gvI8.mjs";
6
+ import { n as Principal, t as AuthProvider } from "./contract-DlTo4u2t.mjs";
7
+ import { a as AuthorizeInput, i as AuthorizationProvider, n as AuditAction, o as MUTATING_ACTIONS, r as AuditResource, s as isMutatingAction, t as ALL_ACTIONS } from "./contract-yPNuFnVy.mjs";
8
+ import { _ as verifyPortalToken, a as PanelConfig, c as PortalFilter, d as PortalTokenOptions, f as ScopedQuery, g as scopeQueryToPortal, h as portalCanSee, i as AuditPortalOptions, l as PortalGrant, m as intersectActions, n as CreateFetchHandlerResult, o as DEFAULT_PORTAL_ACTIONS, p as createPortalToken, r as createFetchHandler, s as PORTAL_TOKEN_PREFIX, t as AuditPanelOptions, u as PortalTokenError, v as AuditCorsOptions } from "./create-fetch-handler-zioPVS18.mjs";
9
+ import { a as ExportOptions, c as eventToCsvRow, d as verifyBundle, i as ExportFormat, l as exportEvents, n as CSV_COLUMNS, o as ParsedBundle, r as EXPORT_CONTENT_TYPES, s as csvCell, t as BundleHeader, u as parseBundle } from "./export-BZq0KCCn.mjs";
10
+ import { a as createRecorder, i as RecorderOverflowError, n as RecorderFallback, r as RecorderOptions, t as Recorder } from "./recorder-B3dG3jbd.mjs";
11
+ import { t as canonicalStringify } from "./canonical-CL7gfwhb.mjs";
12
+
13
+ //#region src/id.d.ts
14
+ /**
15
+ * Time-sortable ids (ADR 0010): `{prefix}_` + 26 Crockford base32 characters —
16
+ * 48 bits of unix milliseconds followed by 80 random bits, ULID-compatible.
17
+ * Monotonic within a process: ids minted in the same millisecond increment the
18
+ * random part, so lexicographic order equals creation order. Zero dependencies.
19
+ *
20
+ * @module
21
+ */
22
+ /** Prefixes for the generated id kinds. */
23
+ type IdPrefix = "evt" | "chk";
24
+ /**
25
+ * Generate a new id, e.g. `newId("evt")` → `"evt_01JD…"`.
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * import { newId } from "@xtandard/audit";
30
+ *
31
+ * const id = newId("evt"); // "evt_01JD3Z…" — sorts by creation time
32
+ * ```
33
+ */
34
+ declare function newId(prefix: IdPrefix, ms?: number): string;
35
+ /** Regex an id of the given prefix must match. */
36
+ declare function idPattern(prefix: IdPrefix): RegExp;
37
+ /** Decode the millisecond timestamp embedded in a time-sortable id, or `null`. */
38
+ declare function idTime(id: string): number | null;
39
+ //#endregion
40
+ //#region src/duration.d.ts
41
+ /**
42
+ * Convert a {@link AuditDuration} (`5000`, `"5s"`, `"30m"`, `"2h"`, `"5d"`)
43
+ * to milliseconds. Throws on malformed strings or negative numbers.
44
+ *
45
+ * @example
46
+ * ```ts
47
+ * import { durationToMs } from "@xtandard/audit";
48
+ *
49
+ * durationToMs("5m"); // 300000
50
+ * durationToMs(250); // 250
51
+ * ```
52
+ */
53
+ declare function durationToMs(duration: AuditDuration): number;
54
+ declare namespace keys_d_exports {
55
+ export { ROOT, actionIndexPrefix, actionKey, actionsKey, actorIndexPrefix, checkpointKey, checkpointsPrefix, decodeSegment, eventIdKey, eventKey, eventsPrefix, headKey, indexLeaf, indexRoot, lastSegment, padMs, padSeq, parseEventKey, parseIndexLeaf, streamCursorKey, streamCursorsPrefix, streamLeaseKey, streamMetaKey, targetIndexPrefix, tenantPrefix, tenantsKey, timeIndexPrefix };
56
+ }
57
+ /**
58
+ * Storage key layout for `@xtandard/audit`.
59
+ *
60
+ * Control data always lives in these KV keys. Events live here too on drivers
61
+ * without the native {@link ./storage/contract.EventLogStorage} capability (the
62
+ * generic fallback, ADR 0005). Pure string helpers — no dependencies.
63
+ *
64
+ * ```txt
65
+ * aud/tenants -> string[] index
66
+ * aud/actions -> string[] index (catalog)
67
+ * aud/actions/{name} -> ActionDefinition
68
+ * aud/t/{tenant}/head -> ChainHead
69
+ * aud/t/{tenant}/checkpoints/{chk id} -> AuditCheckpoint (time-sortable id)
70
+ * aud/streams/{stream}/cursors/{tenant} -> StreamCursor
71
+ * aud/streams/{stream}/meta -> { startedAt }
72
+ * aud/streams/{stream}/lease -> StreamLease
73
+ *
74
+ * — generic event log (KV fallback only) —
75
+ * aud/t/{tenant}/events/{seq 12} -> AuditEvent
76
+ * aud/t/{tenant}/ids/{event id} -> seq
77
+ * aud/t/{tenant}/ix/time/{ms 13}~{id} -> seq
78
+ * aud/t/{tenant}/ix/actor/{actorId}/{ms 13}~{id} -> seq
79
+ * aud/t/{tenant}/ix/action/{action}/{ms 13}~{id} -> seq
80
+ * aud/t/{tenant}/ix/target/{type}/{id}/{ms 13}~{id} -> seq
81
+ * ```
82
+ *
83
+ * Zero-padded numbers make lexicographic key order equal numeric order, so a
84
+ * sorted `getKeys` scan yields events by seq (or by occurredAt for the `ix/`
85
+ * indexes) on every backend. Free-form segments (tenant, actor id, action,
86
+ * target type/id) are `encodeURIComponent`-escaped so `/` and `~` cannot break
87
+ * the layout.
88
+ *
89
+ * @module
90
+ */
91
+ /** Root namespace segment for all keys. */
92
+ declare const ROOT = "aud";
93
+ /** Zero-pad a seq to 12 digits. */
94
+ declare const padSeq: (seq: number) => string;
95
+ /** Zero-pad epoch millis to 13 digits. */
96
+ declare const padMs: (ms: number) => string;
97
+ /** Index of all tenant keys. */
98
+ declare const tenantsKey: () => string;
99
+ /** Action catalog index. */
100
+ declare const actionsKey: () => string;
101
+ /** One action catalog entry. */
102
+ declare const actionKey: (name: string) => string;
103
+ /** Prefix under which everything belonging to one tenant lives. */
104
+ declare const tenantPrefix: (tenant: string) => string;
105
+ /** The tenant's chain head. */
106
+ declare const headKey: (tenant: string) => string;
107
+ /** Prefix of the tenant's checkpoints. */
108
+ declare const checkpointsPrefix: (tenant: string) => string;
109
+ /** One checkpoint. */
110
+ declare const checkpointKey: (tenant: string, id: string) => string;
111
+ /** Prefix of a stream's per-tenant cursors. */
112
+ declare const streamCursorsPrefix: (stream: string) => string;
113
+ /** One stream cursor. */
114
+ declare const streamCursorKey: (stream: string, tenant: string) => string;
115
+ /** A stream's metadata (first-run marker). */
116
+ declare const streamMetaKey: (stream: string) => string;
117
+ /** A stream's runner lease. */
118
+ declare const streamLeaseKey: (stream: string) => string;
119
+ /** Prefix of the tenant's events (by seq). */
120
+ declare const eventsPrefix: (tenant: string) => string;
121
+ /** One event, keyed by seq. */
122
+ declare const eventKey: (tenant: string, seq: number) => string;
123
+ /** Event id → seq. */
124
+ declare const eventIdKey: (tenant: string, id: string) => string;
125
+ /** Prefix of a tenant's secondary indexes. */
126
+ declare const indexRoot: (tenant: string) => string;
127
+ /** Time index prefix. */
128
+ declare const timeIndexPrefix: (tenant: string) => string;
129
+ /** Actor index prefix. */
130
+ declare const actorIndexPrefix: (tenant: string, actorId: string) => string;
131
+ /** Action index prefix. */
132
+ declare const actionIndexPrefix: (tenant: string, action: string) => string;
133
+ /** Target index prefix. */
134
+ declare const targetIndexPrefix: (tenant: string, type: string, id: string) => string;
135
+ /** The `{ms}~{id}` leaf of every index key. */
136
+ declare const indexLeaf: (occurredAtMs: number, id: string) => string;
137
+ /** Parse an index key's leaf back into `(occurredAtMs, id)`. */
138
+ declare const parseIndexLeaf: (key: string) => {
139
+ ms: number;
140
+ id: string;
141
+ } | null;
142
+ /** Parse a seq from an event key. */
143
+ declare const parseEventKey: (key: string) => number | null;
144
+ /** Extract the trailing segment from a key. */
145
+ declare const lastSegment: (key: string) => string;
146
+ /** Decode an escaped key segment. */
147
+ declare const decodeSegment: (segment: string) => string;
148
+ //#endregion
149
+ //#region src/version.d.ts
150
+ /**
151
+ * Package version, used for the default dispatcher `user-agent`. Bumped by the
152
+ * release flow alongside `package.json`.
153
+ *
154
+ * @module
155
+ */
156
+ /** The published package version. */
157
+ declare const VERSION = "0.1.1";
158
+ //#endregion
159
+ //#region src/storage/watch.d.ts
160
+ /**
161
+ * A change source. Called with a `notify` callback — wire your source to invoke
162
+ * it (optionally with the changed key) on every change — and return an
163
+ * unsubscribe function (sync or async).
164
+ */
165
+ type WatchSubscribe = (notify: (key?: string) => void) => (() => void | Promise<void>) | Promise<() => void | Promise<void>>;
166
+ /**
167
+ * Wrap a storage so it implements {@link WatchableAuditStorage} using
168
+ * `subscribe` as the change source. The wrapper delegates all reads/writes to
169
+ * `storage` and only adds `watch`; keys not under the watched `prefix` are
170
+ * filtered out. A notification without a key is delivered as a change to the
171
+ * prefix itself (enough to trigger a refresh).
172
+ */
173
+ declare function withWatch<S extends AuditStorage>(storage: S, subscribe: WatchSubscribe): S & WatchableAuditStorage;
174
+ /**
175
+ * A dedicated notification client for {@link pgListenNotify} — satisfied by a
176
+ * `pg` `Client`. `Pool` won't do (it rotates connections); use a `Client` you
177
+ * `connect()`.
178
+ */
179
+ interface PgNotificationClient {
180
+ query(sql: string): Promise<unknown>;
181
+ on(event: "notification", listener: (msg: {
182
+ channel: string;
183
+ payload?: string;
184
+ }) => void): void;
185
+ removeListener(event: "notification", listener: (msg: {
186
+ channel: string;
187
+ payload?: string;
188
+ }) => void): void;
189
+ }
190
+ /**
191
+ * A {@link WatchSubscribe} backed by Postgres `LISTEN`/`NOTIFY`. Pair with
192
+ * {@link withWatch} for the postgres or drizzle-over-pg adapters. Your migration
193
+ * owns the trigger that `pg_notify`s `channel` with the changed key as payload;
194
+ * this only `LISTEN`s.
195
+ *
196
+ * @example
197
+ * ```ts
198
+ * import { Client } from "pg";
199
+ * const listener = new Client({ connectionString: process.env.DATABASE_URL });
200
+ * await listener.connect();
201
+ * const storage = withWatch(base, pgListenNotify(listener, "xtandard_audit"));
202
+ * ```
203
+ */
204
+ declare function pgListenNotify(client: PgNotificationClient, channel?: string): WatchSubscribe;
205
+ //#endregion
206
+ //#region src/validation.d.ts
207
+ /**
208
+ * Runtime validation for record inputs and control-plane inputs, built on
209
+ * `valibot` (like the sibling packages). Action-specific `metadata` is validated
210
+ * separately by the host's Standard Schema validators (ADR 0012).
211
+ *
212
+ * @module
213
+ */
214
+ /** Allowed characters for tenant keys. */
215
+ declare const TENANT_REGEX: RegExp;
216
+ /** Allowed characters for action names (`invoice.paid`, `member:role_changed`). */
217
+ declare const ACTION_REGEX: RegExp;
218
+ /** Maximum serialized size of one event's free-form sections, in bytes. Default for `maxEventBytes`. */
219
+ declare const DEFAULT_MAX_EVENT_BYTES = 65536;
220
+ /** A single validation problem with a dotted path into the offending data. */
221
+ interface ValidationIssue {
222
+ path: string;
223
+ message: string;
224
+ }
225
+ /** Result of the `validate*` functions. */
226
+ interface ValidationResult {
227
+ valid: boolean;
228
+ errors: ValidationIssue[];
229
+ }
230
+ /** Raised by {@link assertValid} when an input fails validation. Maps to HTTP 422. */
231
+ declare class ValidationError extends Error {
232
+ readonly errors: ValidationIssue[];
233
+ constructor(errors: ValidationIssue[]);
234
+ }
235
+ /** Throw a {@link ValidationError} when `result` is invalid. */
236
+ declare function assertValid(result: ValidationResult): void;
237
+ /** Validate a tenant key. */
238
+ declare function validateTenant(tenant: unknown, basePath?: string): ValidationResult;
239
+ /**
240
+ * Validate the structure of a record input (not the action's metadata schema).
241
+ *
242
+ * @example
243
+ * ```ts
244
+ * import { validateEventInput } from "@xtandard/audit";
245
+ *
246
+ * validateEventInput({ tenant: "acme", action: "invoice.paid", actor: { id: "u_1" } }).valid; // true
247
+ * ```
248
+ */
249
+ declare function validateEventInput(input: unknown, options?: {
250
+ maxEventBytes?: number;
251
+ basePath?: string;
252
+ }): ValidationResult;
253
+ /** Validate an action catalog entry. */
254
+ declare function validateActionDefinition(input: unknown, basePath?: string): ValidationResult;
255
+ //#endregion
256
+ //#region src/server/openapi.d.ts
257
+ /**
258
+ * OpenAPI 3.1 description of the panel's JSON API (`docs/HTTP_API.md`).
259
+ *
260
+ * Exposed two ways, mirroring the sibling panels:
261
+ * - served at `GET {basePath}/api/openapi.json` for standalone tools (Scalar,
262
+ * Swagger UI, Postman, codegen);
263
+ * - returned by `createFetchHandler(...).openapi()` so you can MERGE it into
264
+ * your host app's OpenAPI document (e.g. Elysia `@elysiajs/openapi`
265
+ * `references`, or Hono's OpenAPI).
266
+ *
267
+ * Hand-authored — no generation dependency (flags precedent).
268
+ *
269
+ * @module
270
+ */
271
+ /** Options for {@link buildOpenApiDocument}. */
272
+ interface OpenApiOptions {
273
+ /** Mount prefix used in the `servers` url (e.g. `"/audit"`). */
274
+ basePath?: string;
275
+ /** Document title. */
276
+ title?: string;
277
+ /** Document version (defaults to the package's API version). */
278
+ version?: string;
279
+ }
280
+ /** Build the OpenAPI 3.1 document for the panel API. Pure — safe to call anywhere. */
281
+ declare function buildOpenApiDocument(options?: OpenApiOptions): Record<string, unknown>;
282
+ //#endregion
283
+ export { ACTION_REGEX, ALL_ACTIONS, AUDIT_SECTIONS, ActionDefinition, type ActionMap, type ActionMetadataInput, type ActionSpec, ActorOptions, type AfterEvent, type AfterEventType, type AuditAction, AuditActor, AuditCheckpoint, AuditContext, AuditCore, AuditCoreOptions, type AuditCorsOptions, AuditDuration, AuditEvent, AuditEventInput, type AuditHooks, type AuditHooksInput, AuditIntegrity, AuditOutcome, AuditPage, type AuditPanelOptions, type AuditPortalOptions, AuditQuery, type AuditResource, AuditSection, type AuditSigner, type AuditSink, type AuditStorage, AuditTarget, AuditTenant, type AuditTransform, type AuditVerificationKey, type AuthProvider, type AuthorizationProvider, type AuthorizeInput, type BeforeEvent, type BeforeEventType, type BundleHeader, CSV_COLUMNS, ChainConflictError, ChainHead, CheckpointOptions, type CompareAndSwapAuditStorage, ConflictError, type CreateFetchHandlerResult, DEFAULT_MAX_EVENT_BYTES, DEFAULT_PORTAL_ACTIONS, DEFAULT_QUERY_LIMIT, ERASED_MARKER, EXPORT_CONTENT_TYPES, EraseInput, type EventLog, type EventLogStorage, type ExportFormat, type ExportOptions, GENESIS_HASH, type HookActor, HookDeniedError, type HookErrorReporter, type IdPrefix, JsonObject, JsonValue, MAX_QUERY_LIMIT, MUTATING_ACTIONS, type NormalizedQuery, NotFoundError, type OpenApiOptions, PORTAL_TOKEN_PREFIX, type PanelConfig, type ParsedBundle, type PgNotificationClient, type PortalFilter, type PortalGrant, PortalTokenError, type PortalTokenOptions, type Principal, PruneResult, QueryError, type QueryPosition, REDACTED, ReadonlyError, RecordInput, type Recorder, type RecorderFallback, type RecorderOptions, RecorderOverflowError, RetentionOptions, RetentionRule, SCHEMA_VERSION, SELF_AUDIT_ACTIONS, type ScopedQuery, SignerRequiredError, type StandardSchemaV1, type StorageChangeEvent, type StreamBatch, type StreamCursor, type StreamDefinition, type StreamItem, type StreamRunner, type StreamRunnerOptions, type StreamStatus, TENANT_REGEX, type TransactionalAuditStorage, type TransformableEvent, VERSION, ValidationError, type ValidationIssue, type ValidationResult, type VerifyChainOptions, type VerifyIssue, type VerifyIssueKind, type VerifyReport, type WatchSubscribe, type WatchableAuditStorage, applyTransforms, assertValid, buildOpenApiDocument, callbackSink, canonicalStringify, chainHeader, computeDigests, createAuditCore, createFetchHandler, createKvEventLog, createPortalToken, createRecorder, createStreamRunner, csvCell, decodeCursor, defaultHookErrorReporter, defineActions, durationToMs, ed25519Signer, ed25519VerificationKey, encodeCursor, eraseSections, eventToCsvRow, exportEvents, generateSigningKeyPair, hasEventLog, hashValue, hmacSigner, hmacVerificationKey, idPattern, idTime, intersectActions, isCompareAndSwap, isMutatingAction, isTransactional, isWatchable, keys_d_exports as keys, keysFromJwks, mask, maskValue, matchesQuery, newId, normalizeHooks, normalizeQuery, omit, parseBundle, pgListenNotify, portalCanSee, redact, requirePeer, resolveEventLog, runAfter, runBefore, runStandardSchema, scopeQueryToPortal, sealChain, sealEvent, sectionDigest, sha256, signCheckpoint, validateActionDefinition, validateEventInput, validateTenant, verifyBundle, verifyChain, verifyCheckpointSignature, verifyEvent, verifyPortalToken, withWatch };
284
+ //# sourceMappingURL=index.d.mts.map