@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,100 @@
1
+ /**
2
+ * Vendored [Standard Schema v1](https://standardschema.dev) types (type-only,
3
+ * zero runtime) plus the action-map helpers that give `record()` its compile-time
4
+ * typing (ADR 0012). Any compliant validator works: valibot, zod, arktype,
5
+ * effect schema, …
6
+ *
7
+ * @module
8
+ */
9
+ import type { AuditOutcome, JsonObject, JsonValue } from "./schema.ts";
10
+ /** The Standard Schema v1 interface (vendored, type-only). */
11
+ export interface StandardSchemaV1<Input = unknown, Output = Input> {
12
+ readonly "~standard": StandardSchemaV1.Props<Input, Output>;
13
+ }
14
+ export declare namespace StandardSchemaV1 {
15
+ interface Props<Input = unknown, Output = Input> {
16
+ readonly version: 1;
17
+ readonly vendor: string;
18
+ readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
19
+ readonly types?: Types<Input, Output> | undefined;
20
+ }
21
+ type Result<Output> = SuccessResult<Output> | FailureResult;
22
+ interface SuccessResult<Output> {
23
+ readonly value: Output;
24
+ readonly issues?: undefined;
25
+ }
26
+ interface FailureResult {
27
+ readonly issues: ReadonlyArray<Issue>;
28
+ }
29
+ interface Issue {
30
+ readonly message: string;
31
+ readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
32
+ }
33
+ interface PathSegment {
34
+ readonly key: PropertyKey;
35
+ }
36
+ interface Types<Input = unknown, Output = Input> {
37
+ readonly input: Input;
38
+ readonly output: Output;
39
+ }
40
+ type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
41
+ type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
42
+ }
43
+ /** One action's definition in code. */
44
+ export interface ActionSpec<TMetadata extends StandardSchemaV1 | undefined = StandardSchemaV1 | undefined> {
45
+ /** Validator for `metadata` (any Standard Schema). Omit for untyped metadata. */
46
+ metadata?: TMetadata;
47
+ description?: string;
48
+ /** UI grouping label. */
49
+ group?: string;
50
+ /** Target types this action carries (documentation; enforced when `strictTargets`). */
51
+ targets?: string[];
52
+ /** JSON-Schema-ish description of `metadata` for the UI catalog. */
53
+ schema?: JsonValue;
54
+ /** Default outcome when the caller does not pass one. */
55
+ outcome?: AuditOutcome;
56
+ deprecated?: boolean;
57
+ }
58
+ /** A map of action name → spec. */
59
+ export type ActionMap = Record<string, ActionSpec>;
60
+ /** The `metadata` input type of one action. */
61
+ export type ActionMetadataInput<TSpec> = TSpec extends ActionSpec<infer S> ? S extends StandardSchemaV1 ? StandardSchemaV1.InferInput<S> : JsonObject : JsonObject;
62
+ /**
63
+ * Declare the typed action catalog. Identity at runtime; preserves the literal
64
+ * types so `core.record()` can infer action names and metadata shapes.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * import * as v from "valibot";
69
+ * import { createAuditCore, defineActions } from "@xtandard/audit";
70
+ *
71
+ * const actions = defineActions({
72
+ * "invoice.paid": {
73
+ * metadata: v.object({ invoiceId: v.string(), amount: v.number() }),
74
+ * targets: ["invoice"],
75
+ * description: "An invoice was paid",
76
+ * },
77
+ * "member.removed": { targets: ["user"] },
78
+ * });
79
+ *
80
+ * const audit = createAuditCore({ storage, actions });
81
+ * await audit.record({
82
+ * tenant: "acme",
83
+ * action: "invoice.paid", // ← autocompletes; typos are compile errors
84
+ * actor: { id: "user_1" },
85
+ * metadata: { invoiceId: "inv_1", amount: 4200 }, // ← typed
86
+ * });
87
+ * ```
88
+ */
89
+ export declare function defineActions<const T extends ActionMap>(actions: T): T;
90
+ /** Run a Standard Schema validator; returns the output or the issue messages. */
91
+ export declare function runStandardSchema<T>(schema: StandardSchemaV1<unknown, T>, value: unknown): Promise<{
92
+ ok: true;
93
+ value: T;
94
+ } | {
95
+ ok: false;
96
+ issues: {
97
+ path: string;
98
+ message: string;
99
+ }[];
100
+ }>;
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Storage contracts. The base {@link AuditStorage} is intentionally tiny —
3
+ * four async methods — so users can bring their own backend. Optional
4
+ * capabilities (watch, transactions, compare-and-swap, and the audit-specific
5
+ * native event log) are separate interfaces that adapters may implement and the
6
+ * core feature-detects (ADR 0005).
7
+ *
8
+ * @module
9
+ */
10
+ import type { AuditEvent } from "../schema.ts";
11
+ import type { NormalizedQuery } from "../query.ts";
12
+ /** The minimal key/value contract every storage backend must satisfy. */
13
+ export interface AuditStorage {
14
+ /** Read a value, or `null` if absent. */
15
+ getItem<T>(key: string): Promise<T | null>;
16
+ /** Write a value (overwriting any existing). */
17
+ setItem<T>(key: string, value: T): Promise<void>;
18
+ /** Delete a key (no-op if absent). */
19
+ removeItem(key: string): Promise<void>;
20
+ /** List all keys beginning with `prefix`. */
21
+ getKeys(prefix: string): Promise<string[]>;
22
+ }
23
+ /** A storage change event delivered to {@link WatchableAuditStorage.watch} callbacks. */
24
+ export interface StorageChangeEvent {
25
+ type: "update" | "remove";
26
+ key: string;
27
+ }
28
+ /** Storage that can push change notifications (e.g. Redis pub/sub, fs.watch). */
29
+ export interface WatchableAuditStorage extends AuditStorage {
30
+ /**
31
+ * Subscribe to changes under `prefix`. Resolves to an unsubscribe function.
32
+ */
33
+ watch(prefix: string, callback: (event: StorageChangeEvent) => void): Promise<() => void>;
34
+ }
35
+ /** Storage that supports atomic multi-key transactions. */
36
+ export interface TransactionalAuditStorage extends AuditStorage {
37
+ transaction<T>(callback: (tx: AuditStorage) => Promise<T>): Promise<T>;
38
+ }
39
+ /** Storage that supports optimistic concurrency via compare-and-swap. */
40
+ export interface CompareAndSwapAuditStorage extends AuditStorage {
41
+ compareAndSwap<T>(input: {
42
+ key: string;
43
+ expected: T | null;
44
+ next: T;
45
+ }): Promise<boolean>;
46
+ }
47
+ /**
48
+ * Thrown by {@link EventLogStorage.appendEvents} when the tenant's chain moved
49
+ * underneath the writer (another process appended first). The core re-reads the
50
+ * head, re-chains the batch, and retries.
51
+ */
52
+ export declare class ChainConflictError extends Error {
53
+ constructor(tenant: string, expectedSeq: number);
54
+ }
55
+ /**
56
+ * Storage that stores and queries audit events **natively** (indexes, SQL
57
+ * `WHERE`, Mongo filters) instead of through the generic KV index fallback in
58
+ * the core (ADR 0005). Control data (catalog, heads, checkpoints, cursors) still
59
+ * lives in the KV methods.
60
+ *
61
+ * Contract:
62
+ * - `appendEvents` is atomic per call: either every event is stored or none,
63
+ * and it throws {@link ChainConflictError} when an event with the same
64
+ * `(tenant, seq)` exists or the tenant's last seq is not `expectedSeq`.
65
+ * - `queryEvents` honours every {@link NormalizedQuery} filter, sorts by
66
+ * `(occurredAt, id)` in `query.order`, starts strictly after `query.after`,
67
+ * and returns at most `query.limit` items plus whether more exist.
68
+ */
69
+ export interface EventLogStorage extends AuditStorage {
70
+ appendEvents(tenant: string, events: AuditEvent[], options: {
71
+ expectedSeq: number;
72
+ }): Promise<void>;
73
+ getEvent(tenant: string, id: string): Promise<AuditEvent | null>;
74
+ /** The event with the highest seq for the tenant, or null. */
75
+ lastEvent(tenant: string): Promise<AuditEvent | null>;
76
+ /** Events with `seq > afterSeq` ascending by seq, at most `limit`. */
77
+ eventsBySeq(tenant: string, options: {
78
+ afterSeq: number;
79
+ limit: number;
80
+ }): Promise<AuditEvent[]>;
81
+ queryEvents(query: NormalizedQuery): Promise<{
82
+ items: AuditEvent[];
83
+ hasMore: boolean;
84
+ }>;
85
+ /** Replace a stored event in place (same tenant/id/seq) — used by erasure. */
86
+ replaceEvent(event: AuditEvent): Promise<void>;
87
+ /** Delete every event of the tenant with `seq <= throughSeq`; resolves to the count removed. */
88
+ deleteEventsThrough(tenant: string, throughSeq: number): Promise<number>;
89
+ /** Count retained events (all tenants when `tenant` is omitted). */
90
+ countEvents(tenant?: string): Promise<number>;
91
+ /** Distinct tenants that have events. */
92
+ listEventTenants(): Promise<string[]>;
93
+ }
94
+ /** Runtime feature-detection: does this storage implement `watch`? */
95
+ export declare function isWatchable(storage: AuditStorage): storage is WatchableAuditStorage;
96
+ /** Runtime feature-detection: does this storage implement `transaction`? */
97
+ export declare function isTransactional(storage: AuditStorage): storage is TransactionalAuditStorage;
98
+ /** Runtime feature-detection: does this storage implement `compareAndSwap`? */
99
+ export declare function isCompareAndSwap(storage: AuditStorage): storage is CompareAndSwapAuditStorage;
100
+ /** Runtime feature-detection: does this storage implement the native event log? */
101
+ export declare function hasEventLog(storage: AuditStorage): storage is EventLogStorage;
102
+ /**
103
+ * Helper for adapters whose subpath requires an optional peer dependency. Throws
104
+ * a clear, actionable error when the peer is missing.
105
+ */
106
+ export declare function requirePeer(name: string, subpath: string): never;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Streaming (ADR 0008): push events — and signed checkpoints — to SIEMs and
3
+ * sinks by **reading the log**, not by queueing on the record path.
4
+ *
5
+ * Each stream keeps one cursor per tenant (`aud/streams/{name}/cursors/{tenant}`
6
+ * = the last seq the sink acknowledged). A tick reads the next batch with
7
+ * `eventsBySeq`, applies the stream's filter, calls `sink.send`, and advances
8
+ * the cursor only after the sink resolved. At-least-once: sinks dedupe on
9
+ * `event.id`. Failures back off exponentially per (stream, tenant); nothing is
10
+ * dropped — the cursor simply does not move. Retention will not prune past the
11
+ * slowest cursor (the runner registers a retention floor on the core).
12
+ *
13
+ * @module
14
+ */
15
+ import type { AuditCore } from "./core.ts";
16
+ import type { AuditCheckpoint, AuditDuration, AuditEvent, AuditQuery } from "./schema.ts";
17
+ import type { ActionMap } from "./standard-schema.ts";
18
+ /** One item a sink receives. */
19
+ export type StreamItem = {
20
+ kind: "event";
21
+ event: AuditEvent;
22
+ } | {
23
+ kind: "checkpoint";
24
+ checkpoint: AuditCheckpoint;
25
+ };
26
+ /** A batch for one tenant. */
27
+ export interface StreamBatch {
28
+ stream: string;
29
+ tenant: string;
30
+ items: StreamItem[];
31
+ }
32
+ /**
33
+ * A destination. `send` must resolve only once the batch is durably accepted
34
+ * (2xx, flushed, …) and throw otherwise — the cursor advances on resolve.
35
+ */
36
+ export interface AuditSink {
37
+ /** Short kind label for the UI (`"http"`, `"datadog"`, …). */
38
+ readonly kind: string;
39
+ send(batch: StreamBatch): Promise<void>;
40
+ /** Optional cleanup on runner stop. */
41
+ close?(): Promise<void>;
42
+ }
43
+ /** A stream definition. */
44
+ export interface StreamDefinition {
45
+ /** Unique name; the cursor key. Allowed: `a-z A-Z 0-9 . _ -`. */
46
+ name: string;
47
+ sink: AuditSink;
48
+ /** Only these tenants (default: all). */
49
+ tenants?: string[];
50
+ /** Only events matching this query's filters (tenant/pagination fields are ignored). */
51
+ filter?: Omit<AuditQuery, "tenant" | "limit" | "cursor" | "order">;
52
+ /** Also stream signed checkpoints (default `true`). */
53
+ checkpoints?: boolean;
54
+ /** Max items per `send`. Default 100. */
55
+ batchSize?: number;
56
+ /**
57
+ * Where the stream starts the first time it runs: `"beginning"` (replay every retained log)
58
+ * or `"now"` (tenants that already exist start at their current head; tenants created later
59
+ * are streamed from their first event). Default `"now"`.
60
+ */
61
+ startFrom?: "beginning" | "now";
62
+ }
63
+ /** Persisted per-tenant cursor state. */
64
+ export interface StreamCursor {
65
+ /** Last acknowledged seq. */
66
+ seq: number;
67
+ /** Last checkpoint id acknowledged (checkpoints are streamed in id order). */
68
+ checkpointId?: string;
69
+ failures: number;
70
+ lastError?: string;
71
+ lastErrorAt?: string;
72
+ nextAttemptAt?: string;
73
+ lastDeliveredAt?: string;
74
+ }
75
+ /** Runtime status of one stream (the admin UI's Streams view). */
76
+ export interface StreamStatus {
77
+ name: string;
78
+ kind: string;
79
+ tenants: {
80
+ tenant: string;
81
+ cursor: number;
82
+ headSeq: number;
83
+ lag: number;
84
+ failures: number;
85
+ lastError?: string;
86
+ lastErrorAt?: string;
87
+ nextAttemptAt?: string;
88
+ lastDeliveredAt?: string;
89
+ }[];
90
+ }
91
+ /** Options for {@link createStreamRunner}. */
92
+ export interface StreamRunnerOptions {
93
+ streams: StreamDefinition[];
94
+ /** Tick interval. Default `"2s"`. */
95
+ interval?: AuditDuration;
96
+ /** Max backoff between failed attempts. Default `"10m"`. */
97
+ maxBackoff?: AuditDuration;
98
+ /** Lease duration when several processes run streams (needs compare-and-swap storage). Default `"30s"`. */
99
+ lease?: AuditDuration;
100
+ /** Called on every failed send. Default `console.warn`. */
101
+ onError?: (error: unknown, info: {
102
+ stream: string;
103
+ tenant: string;
104
+ }) => void;
105
+ }
106
+ /** A started (or startable) stream runner. */
107
+ export interface StreamRunner {
108
+ start(): void;
109
+ stop(): Promise<void>;
110
+ /** Run one pass over every stream and tenant now (tests, cron triggers). */
111
+ tick(): Promise<void>;
112
+ status(): Promise<StreamStatus[]>;
113
+ /** Clear a tenant's backoff so the next tick retries immediately. */
114
+ retry(stream: string, tenant?: string): Promise<void>;
115
+ readonly streams: readonly StreamDefinition[];
116
+ }
117
+ /**
118
+ * Create a stream runner over a core. The panel creates and starts one when
119
+ * given `streams`; call `start()` yourself otherwise (timers are `unref`ed).
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { createStreamRunner } from "@xtandard/audit";
124
+ * import { httpSink } from "@xtandard/audit/sinks/http";
125
+ *
126
+ * const runner = createStreamRunner(audit, {
127
+ * streams: [{ name: "siem", sink: httpSink({ url: "https://siem.example/ingest" }) }],
128
+ * });
129
+ * runner.start();
130
+ * ```
131
+ */
132
+ export declare function createStreamRunner<A extends ActionMap>(core: AuditCore<A>, options: StreamRunnerOptions): StreamRunner;
133
+ /** A sink that calls your function (tests, custom destinations). */
134
+ export declare function callbackSink(send: (batch: StreamBatch) => void | Promise<void>, kind?: string): AuditSink;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Transforms run on every event **before** it is chained and stored, so the
3
+ * hash covers exactly what is kept: redact, mask, hash, or omit sensitive
4
+ * values. Ported from `drizzle-audit`'s transforms, generalized from row columns
5
+ * to dotted paths over the whole event (ADR 0009).
6
+ *
7
+ * Paths address the event: `"metadata.password"`, `"context.ip"`,
8
+ * `"actor.email"`, `"targets.*.name"` (`*` matches any key or array index).
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createAuditCore, redact, mask, hashValue, omit } from "@xtandard/audit";
13
+ *
14
+ * const audit = createAuditCore({
15
+ * storage,
16
+ * transforms: [
17
+ * redact("metadata.password", "metadata.token"),
18
+ * mask("actor.email"),
19
+ * hashValue("context.ip"),
20
+ * omit("metadata.rawRequest"),
21
+ * ],
22
+ * });
23
+ * ```
24
+ *
25
+ * @module
26
+ */
27
+ import type { AuditEvent } from "./schema.ts";
28
+ /** The event shape transforms see: fully resolved, not yet chained. */
29
+ export type TransformableEvent = Omit<AuditEvent, "integrity" | "seq" | "recordedAt"> & {
30
+ recordedAt?: string;
31
+ };
32
+ /** A transform: sync or async, returns the (possibly new) event. */
33
+ export type AuditTransform = (event: TransformableEvent) => TransformableEvent | Promise<TransformableEvent>;
34
+ /** Replacement value used by {@link redact}. */
35
+ export declare const REDACTED = "[REDACTED]";
36
+ /** Replace the values at `paths` with `"[REDACTED]"`. */
37
+ export declare function redact(...paths: string[]): AuditTransform;
38
+ /** Remove the values at `paths` entirely. */
39
+ export declare function omit(...paths: string[]): AuditTransform;
40
+ /**
41
+ * Partially mask string values: emails become `j***@e***.com`, short strings
42
+ * `****`, longer strings keep their last four characters.
43
+ */
44
+ export declare function mask(...paths: string[]): AuditTransform;
45
+ /** The masking used by {@link mask}. */
46
+ export declare function maskValue(str: string): string;
47
+ /**
48
+ * Replace values with a SHA-256 digest (`sha256:…`). Pass a `salt` (a secret)
49
+ * to keep low-entropy values (emails, IPs) from being confirmed by brute force;
50
+ * equal inputs still produce equal digests, so you can correlate without storing.
51
+ */
52
+ export declare function hashValue(paths: string | string[], options?: {
53
+ salt?: string;
54
+ }): AuditTransform;
55
+ /** Run transforms in order. */
56
+ export declare function applyTransforms(event: TransformableEvent, transforms: readonly AuditTransform[]): Promise<TransformableEvent>;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Runtime validation for record inputs and control-plane inputs, built on
3
+ * `valibot` (like the sibling packages). Action-specific `metadata` is validated
4
+ * separately by the host's Standard Schema validators (ADR 0012).
5
+ *
6
+ * @module
7
+ */
8
+ /** Allowed characters for tenant keys. */
9
+ export declare const TENANT_REGEX: RegExp;
10
+ /** Allowed characters for action names (`invoice.paid`, `member:role_changed`). */
11
+ export declare const ACTION_REGEX: RegExp;
12
+ /** Maximum serialized size of one event's free-form sections, in bytes. Default for `maxEventBytes`. */
13
+ export declare const DEFAULT_MAX_EVENT_BYTES = 65536;
14
+ /** A single validation problem with a dotted path into the offending data. */
15
+ export interface ValidationIssue {
16
+ path: string;
17
+ message: string;
18
+ }
19
+ /** Result of the `validate*` functions. */
20
+ export interface ValidationResult {
21
+ valid: boolean;
22
+ errors: ValidationIssue[];
23
+ }
24
+ /** Raised by {@link assertValid} when an input fails validation. Maps to HTTP 422. */
25
+ export declare class ValidationError extends Error {
26
+ readonly errors: ValidationIssue[];
27
+ constructor(errors: ValidationIssue[]);
28
+ }
29
+ /** Throw a {@link ValidationError} when `result` is invalid. */
30
+ export declare function assertValid(result: ValidationResult): void;
31
+ /** Validate a tenant key. */
32
+ export declare function validateTenant(tenant: unknown, basePath?: string): ValidationResult;
33
+ /**
34
+ * Validate the structure of a record input (not the action's metadata schema).
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { validateEventInput } from "@xtandard/audit";
39
+ *
40
+ * validateEventInput({ tenant: "acme", action: "invoice.paid", actor: { id: "u_1" } }).valid; // true
41
+ * ```
42
+ */
43
+ export declare function validateEventInput(input: unknown, options?: {
44
+ maxEventBytes?: number;
45
+ basePath?: string;
46
+ }): ValidationResult;
47
+ /** Validate an action catalog entry. */
48
+ export declare function validateActionDefinition(input: unknown, basePath?: string): ValidationResult;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Canonical JSON serialization: object keys sorted recursively, no whitespace,
3
+ * so two values that are structurally equal produce byte-identical output
4
+ * regardless of key insertion order or storage round-trips (Postgres `jsonb`
5
+ * and some BSON paths reorder keys).
6
+ *
7
+ * This is the byte format the integrity hashes are computed over (ADR 0004).
8
+ * For the value shapes audit events allow — strings, finite numbers, booleans,
9
+ * null, arrays, plain objects — it matches RFC 8785 (JCS) for integers and
10
+ * strings; non-finite numbers are rejected rather than silently becoming `null`.
11
+ *
12
+ * @module
13
+ */
14
+ import type { JsonValue } from "./schema.ts";
15
+ /**
16
+ * Serialize a JSON value with object keys sorted lexicographically at every
17
+ * depth. Arrays keep their order; `undefined` inside objects is dropped exactly
18
+ * as `JSON.stringify` would. Throws on non-finite numbers.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * canonicalStringify({ b: 1, a: 2 }) === canonicalStringify({ a: 2, b: 1 }); // true
23
+ * ```
24
+ */
25
+ export declare function canonicalStringify(value: JsonValue | undefined): string;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Ambient request context (ADR 0013): open a scope per request with the actor,
3
+ * tenant, IP, user agent and request id, and every `record()` inside it picks
4
+ * them up — no threading through call sites. Pattern borrowed from
5
+ * `drizzle-audit`'s context.
6
+ *
7
+ * Uses `node:async_hooks` `AsyncLocalStorage` (Bun, Node, Deno, Cloudflare
8
+ * Workers with `nodejs_compat`). Framework adapters wrap this in an
9
+ * `auditContext()` middleware.
10
+ *
11
+ * Import from `@xtandard/audit/context`.
12
+ *
13
+ * @module context
14
+ */
15
+ import type { AuditActor, AuditContext } from "./schema.ts";
16
+ /** What a request scope carries. */
17
+ export interface AuditScope {
18
+ /** Default actor for events recorded in this scope. */
19
+ actor?: AuditActor;
20
+ /** Default tenant for events recorded in this scope. */
21
+ tenant?: string;
22
+ /** Request context merged under each event's explicit `context`. */
23
+ context?: AuditContext;
24
+ }
25
+ /** The current scope, or `null` outside any scope. Never throws. */
26
+ export declare function getAuditContext(): AuditScope | null;
27
+ /**
28
+ * Run `fn` inside a scope. Nested scopes inherit and override the outer one
29
+ * (`context` keys merge).
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * import { runWithAuditContext } from "@xtandard/audit/context";
34
+ *
35
+ * await runWithAuditContext({ actor: { id: user.id }, tenant: user.orgId }, () =>
36
+ * audit.record({ action: "invoice.paid", metadata: { invoiceId } }),
37
+ * );
38
+ * ```
39
+ */
40
+ export declare function runWithAuditContext<T>(scope: AuditScope, fn: () => T): T;
41
+ /**
42
+ * Patch the current scope for the rest of the current async execution
43
+ * (`enterWith` semantics) — for middleware that cannot wrap `next()`, or to
44
+ * attach the actor once auth resolves.
45
+ */
46
+ export declare function setAuditContext(patch: AuditScope): void;
47
+ /** Options for {@link auditContextFromRequest}. */
48
+ export interface RequestContextOptions {
49
+ /**
50
+ * Trust proxy headers (`x-forwarded-for`, `cf-connecting-ip`, `x-real-ip`,
51
+ * `fly-client-ip`) for the client IP. Default `true` — set `false` when the
52
+ * app is reachable directly, or clients can spoof their IP.
53
+ */
54
+ trustProxy?: boolean;
55
+ /** Header carrying the request id. Default: `x-request-id`, then `cf-ray`. */
56
+ requestIdHeader?: string;
57
+ /** Fallback IP when no header carries one (e.g. Bun's `server.requestIP`). */
58
+ ip?: string;
59
+ }
60
+ /** Extract `{ ip, userAgent, requestId }` from a web-standard Request. */
61
+ export declare function auditContextFromRequest(request: Request, options?: RequestContextOptions): AuditContext;