@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,251 @@
1
+ //#region src/schema.d.ts
2
+ /**
3
+ * Core type definitions for `@xtandard/audit`.
4
+ *
5
+ * This module is **types only** — no runtime code beyond tiny guards and
6
+ * constants, no dependencies. It is safe to import from the record hot path and
7
+ * the zero-dependency verifier. Runtime validation (which pulls in `valibot`)
8
+ * lives in {@link ./validation}.
9
+ *
10
+ * Import from `@xtandard/audit/schema` (also re-exported by the root).
11
+ *
12
+ * @module schema
13
+ */
14
+ /** JSON-serializable value, used for metadata, context, and catalog schemas. */
15
+ type JsonValue = string | number | boolean | null | JsonValue[] | {
16
+ [key: string]: JsonValue | undefined;
17
+ };
18
+ /**
19
+ * A JSON object (the shape of `metadata`, `context`, and actor/target
20
+ * metadata). `undefined` members are allowed for ergonomics and dropped on
21
+ * serialization, exactly like `JSON.stringify`.
22
+ */
23
+ type JsonObject = {
24
+ [key: string]: JsonValue | undefined;
25
+ };
26
+ /**
27
+ * A duration for configuration options: either milliseconds as a number, or a
28
+ * human-friendly string such as `"5s"`, `"30m"`, `"2h"`, `"90d"`. Parsed by
29
+ * {@link ./duration.durationToMs}.
30
+ */
31
+ type AuditDuration = number | `${number}${"ms" | "s" | "m" | "h" | "d"}`;
32
+ /** Current schema version for stored records. */
33
+ declare const SCHEMA_VERSION: 1;
34
+ /** Who performed the action. `id` is required; everything else is presentational. */
35
+ interface AuditActor {
36
+ /** Stable identifier of the actor in the host's system (user id, API key id, …). */
37
+ id: string;
38
+ /** Kind of actor, e.g. `"user"`, `"api_key"`, `"system"`, `"support"`. Default `"user"`. */
39
+ type?: string;
40
+ /** Display name. */
41
+ name?: string;
42
+ /** Email, when the actor is a person. */
43
+ email?: string;
44
+ /** Arbitrary extra attributes. */
45
+ metadata?: JsonObject;
46
+ }
47
+ /** A resource the action was performed on. */
48
+ interface AuditTarget {
49
+ /** Resource kind, e.g. `"invoice"`, `"user"`, `"team"`. */
50
+ type: string;
51
+ /** Stable identifier of the resource. */
52
+ id: string;
53
+ /** Display name. */
54
+ name?: string;
55
+ /** Arbitrary extra attributes. */
56
+ metadata?: JsonObject;
57
+ }
58
+ /**
59
+ * Where the action came from. Well-known keys are typed; any other JSON key is
60
+ * allowed (e.g. `sessionId`, `apiVersion`).
61
+ */
62
+ interface AuditContext {
63
+ /** Client IP address. */
64
+ ip?: string;
65
+ /** Client user agent. */
66
+ userAgent?: string;
67
+ /** Correlation id of the request that caused the event. */
68
+ requestId?: string;
69
+ /** Human-readable location (e.g. from GeoIP), if the host resolves one. */
70
+ location?: string;
71
+ [key: string]: JsonValue | undefined;
72
+ }
73
+ /** Outcome of the audited action. */
74
+ type AuditOutcome = "success" | "failure";
75
+ /**
76
+ * The privacy-bearing sections of an event. Each is hashed separately (salted
77
+ * with the event id) so it can be erased without breaking the chain (ADR 0004,
78
+ * ADR 0011).
79
+ */
80
+ type AuditSection = "actor" | "targets" | "context" | "metadata" | "description";
81
+ /** All sections, in canonical order. */
82
+ declare const AUDIT_SECTIONS: readonly AuditSection[];
83
+ /** Marker that replaces the content of an erased section. */
84
+ declare const ERASED_MARKER: {
85
+ readonly $erased: true;
86
+ };
87
+ /** The tamper-evidence block carried by every stored event (ADR 0004). */
88
+ interface AuditIntegrity {
89
+ /** Integrity format version. */
90
+ v: 1;
91
+ /** The previous event's `hash` in this tenant's chain (genesis for `seq` 1, or the prune base). */
92
+ prevHash: string;
93
+ /** This event's chain hash: SHA-256 over the canonical header. */
94
+ hash: string;
95
+ /** Per-section digests, salted with the event id. */
96
+ digests: Record<AuditSection, string>;
97
+ /** Sections erased after the fact (their content is the erasure marker; digests are kept). */
98
+ erased?: AuditSection[];
99
+ }
100
+ /** A stored, chained audit event. */
101
+ interface AuditEvent {
102
+ /** `evt_` + 26-char time-sortable id (ADR 0010). */
103
+ id: string;
104
+ /** The tenant (customer organization) the event belongs to. */
105
+ tenant: string;
106
+ /** Position in the tenant's chain: contiguous from 1. */
107
+ seq: number;
108
+ /** What happened, e.g. `"invoice.paid"`, `"member.role_changed"`. */
109
+ action: string;
110
+ /** ISO-8601: when it happened (caller-supplied, or record time). */
111
+ occurredAt: string;
112
+ /** ISO-8601: when the log accepted it. */
113
+ recordedAt: string;
114
+ actor: AuditActor;
115
+ targets: AuditTarget[];
116
+ context: AuditContext;
117
+ /** Action-specific data (typed per action via `defineActions`). */
118
+ metadata: JsonObject;
119
+ outcome?: AuditOutcome;
120
+ /** Optional human-readable sentence ("Alice changed Bob's role to admin"). */
121
+ description?: string;
122
+ integrity: AuditIntegrity;
123
+ }
124
+ /**
125
+ * What callers pass to `record()`. Everything the log derives itself (`seq`,
126
+ * `recordedAt`, `integrity`) is omitted; `id` and `occurredAt` are optional.
127
+ */
128
+ interface AuditEventInput<TAction extends string = string, TMetadata = JsonObject> {
129
+ /** Supply your own id for idempotent re-recording (same id + same content = no-op). */
130
+ id?: string;
131
+ tenant: string;
132
+ action: TAction;
133
+ /** ISO-8601 or `Date`. Defaults to now. */
134
+ occurredAt?: string | Date;
135
+ /** Defaults to the ambient request context's actor (see `@xtandard/audit/context`). */
136
+ actor?: AuditActor;
137
+ targets?: AuditTarget[];
138
+ /** Merged over the ambient request context (explicit keys win). */
139
+ context?: AuditContext;
140
+ metadata?: TMetadata;
141
+ outcome?: AuditOutcome;
142
+ description?: string;
143
+ }
144
+ /** A signed chain head (ADR 0004). */
145
+ interface AuditCheckpoint {
146
+ /** Checkpoint format version. */
147
+ v: 1;
148
+ /** `chk_` + time-sortable id. */
149
+ id: string;
150
+ tenant: string;
151
+ /**
152
+ * `"head"`: signs the chain head at `seq`. `"base"`: anchors a pruned prefix —
153
+ * `hash` is the hash of the last pruned event, i.e. the `prevHash` the first
154
+ * retained event must carry.
155
+ */
156
+ kind: "head" | "base";
157
+ seq: number;
158
+ hash: string;
159
+ /** ISO-8601 creation time. */
160
+ at: string;
161
+ /** Signing key id (matches a key in the JWKS). */
162
+ keyId: string;
163
+ /** Signature algorithm. */
164
+ alg: "Ed25519" | "HS256";
165
+ /** base64url signature over the canonical checkpoint minus `signature`. */
166
+ signature: string;
167
+ }
168
+ /** The current head of one tenant's chain. */
169
+ interface ChainHead {
170
+ tenant: string;
171
+ /** Last assigned seq (0 when empty). */
172
+ seq: number;
173
+ /** Hash of the event at `seq` (genesis when empty). */
174
+ hash: string;
175
+ /** First retained seq after pruning (1 when never pruned). */
176
+ baseSeq?: number;
177
+ /** `prevHash` of the first retained event (genesis when never pruned). */
178
+ baseHash?: string;
179
+ /** ISO-8601 time of the last append. */
180
+ updatedAt?: string;
181
+ }
182
+ /** Tenant summary for listings. */
183
+ interface AuditTenant {
184
+ key: string;
185
+ /** Events currently retained. */
186
+ count?: number;
187
+ head: ChainHead;
188
+ /** ISO-8601 time of the first event ever recorded. */
189
+ createdAt?: string;
190
+ }
191
+ /** Action catalog entry (documentation + UI; schemas live in code, ADR 0012). */
192
+ interface ActionDefinition {
193
+ /** Dot-delimited name, e.g. `"invoice.paid"`. Allowed: `a-z A-Z 0-9 . _ - :`. */
194
+ name: string;
195
+ description?: string;
196
+ /** UI grouping label (e.g. `"Billing"`). */
197
+ group?: string;
198
+ /** Target types this action is expected to carry. Documentation only. */
199
+ targets?: string[];
200
+ /** JSON-Schema-ish description of `metadata`, for the UI. Documentation only. */
201
+ schema?: JsonValue;
202
+ /** Flagged in the UI; still recordable. */
203
+ deprecated?: boolean;
204
+ /** Where this entry came from: `"code"` (`defineActions`) or `"ui"`. */
205
+ source?: "code" | "ui";
206
+ createdAt?: string;
207
+ updatedAt?: string;
208
+ }
209
+ /**
210
+ * The query model (ADR 0007). All filters are AND-ed; list-valued filters are
211
+ * OR-ed within themselves.
212
+ */
213
+ interface AuditQuery {
214
+ /** Restrict to one tenant. Forced for portal principals. */
215
+ tenant?: string;
216
+ /** Exact action names, or families with a trailing `*` (`"invoice.*"`). */
217
+ actions?: string[];
218
+ /** Exclude these names / families. */
219
+ excludeActions?: string[];
220
+ actorId?: string;
221
+ actorType?: string;
222
+ targetType?: string;
223
+ targetId?: string;
224
+ outcome?: AuditOutcome;
225
+ /** Inclusive lower bound on `occurredAt` (ISO-8601). */
226
+ from?: string;
227
+ /** Exclusive upper bound on `occurredAt` (ISO-8601). */
228
+ to?: string;
229
+ /** Case-insensitive substring over action, actor, targets, description, metadata. */
230
+ search?: string;
231
+ /** Sort by `(occurredAt, id)`. Default `"desc"` (newest first). */
232
+ order?: "desc" | "asc";
233
+ /** Page size. Default 50, max 500. */
234
+ limit?: number;
235
+ /** Opaque keyset cursor from a previous page's `pageInfo.endCursor`. */
236
+ cursor?: string;
237
+ }
238
+ /**
239
+ * One page of results — the `@xtandard/lib` `Paginated<T>` envelope shape, so a
240
+ * host can feed it to `createPaginator({ fetchCursor })` unchanged (ADR 0007).
241
+ */
242
+ interface AuditPage<T = AuditEvent> {
243
+ items: T[];
244
+ pageInfo: {
245
+ hasNextPage: boolean;
246
+ endCursor: string | null;
247
+ };
248
+ }
249
+ //#endregion
250
+ export { ERASED_MARKER as _, AuditContext as a, SCHEMA_VERSION as b, AuditEventInput as c, AuditPage as d, AuditQuery as f, ChainHead as g, AuditTenant as h, AuditCheckpoint as i, AuditIntegrity as l, AuditTarget as m, ActionDefinition as n, AuditDuration as o, AuditSection as p, AuditActor as r, AuditEvent as s, AUDIT_SECTIONS as t, AuditOutcome as u, JsonObject as v, JsonValue as y };
251
+ //# sourceMappingURL=schema-DmU7Wp0F.d.mts.map
@@ -0,0 +1,20 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/schema.ts
3
+ /** Current schema version for stored records. */
4
+ const SCHEMA_VERSION = 1;
5
+ /** All sections, in canonical order. */
6
+ const AUDIT_SECTIONS = [
7
+ "actor",
8
+ "targets",
9
+ "context",
10
+ "metadata",
11
+ "description"
12
+ ];
13
+ /** Marker that replaces the content of an erased section. */
14
+ const ERASED_MARKER = { $erased: true };
15
+ //#endregion
16
+ exports.AUDIT_SECTIONS = AUDIT_SECTIONS;
17
+ exports.ERASED_MARKER = ERASED_MARKER;
18
+ exports.SCHEMA_VERSION = SCHEMA_VERSION;
19
+
20
+ //# sourceMappingURL=schema.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.cjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/**\n * Core type definitions for `@xtandard/audit`.\n *\n * This module is **types only** — no runtime code beyond tiny guards and\n * constants, no dependencies. It is safe to import from the record hot path and\n * the zero-dependency verifier. Runtime validation (which pulls in `valibot`)\n * lives in {@link ./validation}.\n *\n * Import from `@xtandard/audit/schema` (also re-exported by the root).\n *\n * @module schema\n */\n\n/** JSON-serializable value, used for metadata, context, and catalog schemas. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue | undefined };\n\n/**\n * A JSON object (the shape of `metadata`, `context`, and actor/target\n * metadata). `undefined` members are allowed for ergonomics and dropped on\n * serialization, exactly like `JSON.stringify`.\n */\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\n/**\n * A duration for configuration options: either milliseconds as a number, or a\n * human-friendly string such as `\"5s\"`, `\"30m\"`, `\"2h\"`, `\"90d\"`. Parsed by\n * {@link ./duration.durationToMs}.\n */\nexport type AuditDuration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** Current schema version for stored records. */\nexport const SCHEMA_VERSION = 1 as const;\n\n/** Who performed the action. `id` is required; everything else is presentational. */\nexport interface AuditActor {\n /** Stable identifier of the actor in the host's system (user id, API key id, …). */\n id: string;\n /** Kind of actor, e.g. `\"user\"`, `\"api_key\"`, `\"system\"`, `\"support\"`. Default `\"user\"`. */\n type?: string;\n /** Display name. */\n name?: string;\n /** Email, when the actor is a person. */\n email?: string;\n /** Arbitrary extra attributes. */\n metadata?: JsonObject;\n}\n\n/** A resource the action was performed on. */\nexport interface AuditTarget {\n /** Resource kind, e.g. `\"invoice\"`, `\"user\"`, `\"team\"`. */\n type: string;\n /** Stable identifier of the resource. */\n id: string;\n /** Display name. */\n name?: string;\n /** Arbitrary extra attributes. */\n metadata?: JsonObject;\n}\n\n/**\n * Where the action came from. Well-known keys are typed; any other JSON key is\n * allowed (e.g. `sessionId`, `apiVersion`).\n */\nexport interface AuditContext {\n /** Client IP address. */\n ip?: string;\n /** Client user agent. */\n userAgent?: string;\n /** Correlation id of the request that caused the event. */\n requestId?: string;\n /** Human-readable location (e.g. from GeoIP), if the host resolves one. */\n location?: string;\n [key: string]: JsonValue | undefined;\n}\n\n/** Outcome of the audited action. */\nexport type AuditOutcome = \"success\" | \"failure\";\n\n/**\n * The privacy-bearing sections of an event. Each is hashed separately (salted\n * with the event id) so it can be erased without breaking the chain (ADR 0004,\n * ADR 0011).\n */\nexport type AuditSection = \"actor\" | \"targets\" | \"context\" | \"metadata\" | \"description\";\n\n/** All sections, in canonical order. */\nexport const AUDIT_SECTIONS: readonly AuditSection[] = [\n \"actor\",\n \"targets\",\n \"context\",\n \"metadata\",\n \"description\",\n] as const;\n\n/** Marker that replaces the content of an erased section. */\nexport const ERASED_MARKER = { $erased: true } as const;\n\n/** The tamper-evidence block carried by every stored event (ADR 0004). */\nexport interface AuditIntegrity {\n /** Integrity format version. */\n v: 1;\n /** The previous event's `hash` in this tenant's chain (genesis for `seq` 1, or the prune base). */\n prevHash: string;\n /** This event's chain hash: SHA-256 over the canonical header. */\n hash: string;\n /** Per-section digests, salted with the event id. */\n digests: Record<AuditSection, string>;\n /** Sections erased after the fact (their content is the erasure marker; digests are kept). */\n erased?: AuditSection[];\n}\n\n/** A stored, chained audit event. */\nexport interface AuditEvent {\n /** `evt_` + 26-char time-sortable id (ADR 0010). */\n id: string;\n /** The tenant (customer organization) the event belongs to. */\n tenant: string;\n /** Position in the tenant's chain: contiguous from 1. */\n seq: number;\n /** What happened, e.g. `\"invoice.paid\"`, `\"member.role_changed\"`. */\n action: string;\n /** ISO-8601: when it happened (caller-supplied, or record time). */\n occurredAt: string;\n /** ISO-8601: when the log accepted it. */\n recordedAt: string;\n actor: AuditActor;\n targets: AuditTarget[];\n context: AuditContext;\n /** Action-specific data (typed per action via `defineActions`). */\n metadata: JsonObject;\n outcome?: AuditOutcome;\n /** Optional human-readable sentence (\"Alice changed Bob's role to admin\"). */\n description?: string;\n integrity: AuditIntegrity;\n}\n\n/**\n * What callers pass to `record()`. Everything the log derives itself (`seq`,\n * `recordedAt`, `integrity`) is omitted; `id` and `occurredAt` are optional.\n */\nexport interface AuditEventInput<TAction extends string = string, TMetadata = JsonObject> {\n /** Supply your own id for idempotent re-recording (same id + same content = no-op). */\n id?: string;\n tenant: string;\n action: TAction;\n /** ISO-8601 or `Date`. Defaults to now. */\n occurredAt?: string | Date;\n /** Defaults to the ambient request context's actor (see `@xtandard/audit/context`). */\n actor?: AuditActor;\n targets?: AuditTarget[];\n /** Merged over the ambient request context (explicit keys win). */\n context?: AuditContext;\n metadata?: TMetadata;\n outcome?: AuditOutcome;\n description?: string;\n}\n\n/** A signed chain head (ADR 0004). */\nexport interface AuditCheckpoint {\n /** Checkpoint format version. */\n v: 1;\n /** `chk_` + time-sortable id. */\n id: string;\n tenant: string;\n /**\n * `\"head\"`: signs the chain head at `seq`. `\"base\"`: anchors a pruned prefix —\n * `hash` is the hash of the last pruned event, i.e. the `prevHash` the first\n * retained event must carry.\n */\n kind: \"head\" | \"base\";\n seq: number;\n hash: string;\n /** ISO-8601 creation time. */\n at: string;\n /** Signing key id (matches a key in the JWKS). */\n keyId: string;\n /** Signature algorithm. */\n alg: \"Ed25519\" | \"HS256\";\n /** base64url signature over the canonical checkpoint minus `signature`. */\n signature: string;\n}\n\n/** The current head of one tenant's chain. */\nexport interface ChainHead {\n tenant: string;\n /** Last assigned seq (0 when empty). */\n seq: number;\n /** Hash of the event at `seq` (genesis when empty). */\n hash: string;\n /** First retained seq after pruning (1 when never pruned). */\n baseSeq?: number;\n /** `prevHash` of the first retained event (genesis when never pruned). */\n baseHash?: string;\n /** ISO-8601 time of the last append. */\n updatedAt?: string;\n}\n\n/** Tenant summary for listings. */\nexport interface AuditTenant {\n key: string;\n /** Events currently retained. */\n count?: number;\n head: ChainHead;\n /** ISO-8601 time of the first event ever recorded. */\n createdAt?: string;\n}\n\n/** Action catalog entry (documentation + UI; schemas live in code, ADR 0012). */\nexport interface ActionDefinition {\n /** Dot-delimited name, e.g. `\"invoice.paid\"`. Allowed: `a-z A-Z 0-9 . _ - :`. */\n name: string;\n description?: string;\n /** UI grouping label (e.g. `\"Billing\"`). */\n group?: string;\n /** Target types this action is expected to carry. Documentation only. */\n targets?: string[];\n /** JSON-Schema-ish description of `metadata`, for the UI. Documentation only. */\n schema?: JsonValue;\n /** Flagged in the UI; still recordable. */\n deprecated?: boolean;\n /** Where this entry came from: `\"code\"` (`defineActions`) or `\"ui\"`. */\n source?: \"code\" | \"ui\";\n createdAt?: string;\n updatedAt?: string;\n}\n\n/**\n * The query model (ADR 0007). All filters are AND-ed; list-valued filters are\n * OR-ed within themselves.\n */\nexport interface AuditQuery {\n /** Restrict to one tenant. Forced for portal principals. */\n tenant?: string;\n /** Exact action names, or families with a trailing `*` (`\"invoice.*\"`). */\n actions?: string[];\n /** Exclude these names / families. */\n excludeActions?: string[];\n actorId?: string;\n actorType?: string;\n targetType?: string;\n targetId?: string;\n outcome?: AuditOutcome;\n /** Inclusive lower bound on `occurredAt` (ISO-8601). */\n from?: string;\n /** Exclusive upper bound on `occurredAt` (ISO-8601). */\n to?: string;\n /** Case-insensitive substring over action, actor, targets, description, metadata. */\n search?: string;\n /** Sort by `(occurredAt, id)`. Default `\"desc\"` (newest first). */\n order?: \"desc\" | \"asc\";\n /** Page size. Default 50, max 500. */\n limit?: number;\n /** Opaque keyset cursor from a previous page's `pageInfo.endCursor`. */\n cursor?: string;\n}\n\n/**\n * One page of results — the `@xtandard/lib` `Paginated<T>` envelope shape, so a\n * host can feed it to `createPaginator({ fetchCursor })` unchanged (ADR 0007).\n */\nexport interface AuditPage<T = AuditEvent> {\n items: T[];\n pageInfo: {\n hasNextPage: boolean;\n endCursor: string | null;\n };\n}\n"],"mappings":";;;AAqCA,MAAa,iBAAiB;;AAuD9B,MAAa,iBAA0C;CACrD;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,gBAAgB,EAAE,SAAS,KAAK"}
@@ -0,0 +1,2 @@
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
+ export { AUDIT_SECTIONS, ActionDefinition, AuditActor, AuditCheckpoint, AuditContext, AuditDuration, AuditEvent, AuditEventInput, AuditIntegrity, AuditOutcome, AuditPage, AuditQuery, AuditSection, AuditTarget, AuditTenant, ChainHead, ERASED_MARKER, JsonObject, JsonValue, SCHEMA_VERSION };
@@ -0,0 +1,2 @@
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
+ export { AUDIT_SECTIONS, ActionDefinition, AuditActor, AuditCheckpoint, AuditContext, AuditDuration, AuditEvent, AuditEventInput, AuditIntegrity, AuditOutcome, AuditPage, AuditQuery, AuditSection, AuditTarget, AuditTenant, ChainHead, ERASED_MARKER, JsonObject, JsonValue, SCHEMA_VERSION };
@@ -0,0 +1,17 @@
1
+ //#region src/schema.ts
2
+ /** Current schema version for stored records. */
3
+ const SCHEMA_VERSION = 1;
4
+ /** All sections, in canonical order. */
5
+ const AUDIT_SECTIONS = [
6
+ "actor",
7
+ "targets",
8
+ "context",
9
+ "metadata",
10
+ "description"
11
+ ];
12
+ /** Marker that replaces the content of an erased section. */
13
+ const ERASED_MARKER = { $erased: true };
14
+ //#endregion
15
+ export { AUDIT_SECTIONS, ERASED_MARKER, SCHEMA_VERSION };
16
+
17
+ //# sourceMappingURL=schema.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.mjs","names":[],"sources":["../src/schema.ts"],"sourcesContent":["/**\n * Core type definitions for `@xtandard/audit`.\n *\n * This module is **types only** — no runtime code beyond tiny guards and\n * constants, no dependencies. It is safe to import from the record hot path and\n * the zero-dependency verifier. Runtime validation (which pulls in `valibot`)\n * lives in {@link ./validation}.\n *\n * Import from `@xtandard/audit/schema` (also re-exported by the root).\n *\n * @module schema\n */\n\n/** JSON-serializable value, used for metadata, context, and catalog schemas. */\nexport type JsonValue =\n | string\n | number\n | boolean\n | null\n | JsonValue[]\n | { [key: string]: JsonValue | undefined };\n\n/**\n * A JSON object (the shape of `metadata`, `context`, and actor/target\n * metadata). `undefined` members are allowed for ergonomics and dropped on\n * serialization, exactly like `JSON.stringify`.\n */\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\n/**\n * A duration for configuration options: either milliseconds as a number, or a\n * human-friendly string such as `\"5s\"`, `\"30m\"`, `\"2h\"`, `\"90d\"`. Parsed by\n * {@link ./duration.durationToMs}.\n */\nexport type AuditDuration = number | `${number}${\"ms\" | \"s\" | \"m\" | \"h\" | \"d\"}`;\n\n/** Current schema version for stored records. */\nexport const SCHEMA_VERSION = 1 as const;\n\n/** Who performed the action. `id` is required; everything else is presentational. */\nexport interface AuditActor {\n /** Stable identifier of the actor in the host's system (user id, API key id, …). */\n id: string;\n /** Kind of actor, e.g. `\"user\"`, `\"api_key\"`, `\"system\"`, `\"support\"`. Default `\"user\"`. */\n type?: string;\n /** Display name. */\n name?: string;\n /** Email, when the actor is a person. */\n email?: string;\n /** Arbitrary extra attributes. */\n metadata?: JsonObject;\n}\n\n/** A resource the action was performed on. */\nexport interface AuditTarget {\n /** Resource kind, e.g. `\"invoice\"`, `\"user\"`, `\"team\"`. */\n type: string;\n /** Stable identifier of the resource. */\n id: string;\n /** Display name. */\n name?: string;\n /** Arbitrary extra attributes. */\n metadata?: JsonObject;\n}\n\n/**\n * Where the action came from. Well-known keys are typed; any other JSON key is\n * allowed (e.g. `sessionId`, `apiVersion`).\n */\nexport interface AuditContext {\n /** Client IP address. */\n ip?: string;\n /** Client user agent. */\n userAgent?: string;\n /** Correlation id of the request that caused the event. */\n requestId?: string;\n /** Human-readable location (e.g. from GeoIP), if the host resolves one. */\n location?: string;\n [key: string]: JsonValue | undefined;\n}\n\n/** Outcome of the audited action. */\nexport type AuditOutcome = \"success\" | \"failure\";\n\n/**\n * The privacy-bearing sections of an event. Each is hashed separately (salted\n * with the event id) so it can be erased without breaking the chain (ADR 0004,\n * ADR 0011).\n */\nexport type AuditSection = \"actor\" | \"targets\" | \"context\" | \"metadata\" | \"description\";\n\n/** All sections, in canonical order. */\nexport const AUDIT_SECTIONS: readonly AuditSection[] = [\n \"actor\",\n \"targets\",\n \"context\",\n \"metadata\",\n \"description\",\n] as const;\n\n/** Marker that replaces the content of an erased section. */\nexport const ERASED_MARKER = { $erased: true } as const;\n\n/** The tamper-evidence block carried by every stored event (ADR 0004). */\nexport interface AuditIntegrity {\n /** Integrity format version. */\n v: 1;\n /** The previous event's `hash` in this tenant's chain (genesis for `seq` 1, or the prune base). */\n prevHash: string;\n /** This event's chain hash: SHA-256 over the canonical header. */\n hash: string;\n /** Per-section digests, salted with the event id. */\n digests: Record<AuditSection, string>;\n /** Sections erased after the fact (their content is the erasure marker; digests are kept). */\n erased?: AuditSection[];\n}\n\n/** A stored, chained audit event. */\nexport interface AuditEvent {\n /** `evt_` + 26-char time-sortable id (ADR 0010). */\n id: string;\n /** The tenant (customer organization) the event belongs to. */\n tenant: string;\n /** Position in the tenant's chain: contiguous from 1. */\n seq: number;\n /** What happened, e.g. `\"invoice.paid\"`, `\"member.role_changed\"`. */\n action: string;\n /** ISO-8601: when it happened (caller-supplied, or record time). */\n occurredAt: string;\n /** ISO-8601: when the log accepted it. */\n recordedAt: string;\n actor: AuditActor;\n targets: AuditTarget[];\n context: AuditContext;\n /** Action-specific data (typed per action via `defineActions`). */\n metadata: JsonObject;\n outcome?: AuditOutcome;\n /** Optional human-readable sentence (\"Alice changed Bob's role to admin\"). */\n description?: string;\n integrity: AuditIntegrity;\n}\n\n/**\n * What callers pass to `record()`. Everything the log derives itself (`seq`,\n * `recordedAt`, `integrity`) is omitted; `id` and `occurredAt` are optional.\n */\nexport interface AuditEventInput<TAction extends string = string, TMetadata = JsonObject> {\n /** Supply your own id for idempotent re-recording (same id + same content = no-op). */\n id?: string;\n tenant: string;\n action: TAction;\n /** ISO-8601 or `Date`. Defaults to now. */\n occurredAt?: string | Date;\n /** Defaults to the ambient request context's actor (see `@xtandard/audit/context`). */\n actor?: AuditActor;\n targets?: AuditTarget[];\n /** Merged over the ambient request context (explicit keys win). */\n context?: AuditContext;\n metadata?: TMetadata;\n outcome?: AuditOutcome;\n description?: string;\n}\n\n/** A signed chain head (ADR 0004). */\nexport interface AuditCheckpoint {\n /** Checkpoint format version. */\n v: 1;\n /** `chk_` + time-sortable id. */\n id: string;\n tenant: string;\n /**\n * `\"head\"`: signs the chain head at `seq`. `\"base\"`: anchors a pruned prefix —\n * `hash` is the hash of the last pruned event, i.e. the `prevHash` the first\n * retained event must carry.\n */\n kind: \"head\" | \"base\";\n seq: number;\n hash: string;\n /** ISO-8601 creation time. */\n at: string;\n /** Signing key id (matches a key in the JWKS). */\n keyId: string;\n /** Signature algorithm. */\n alg: \"Ed25519\" | \"HS256\";\n /** base64url signature over the canonical checkpoint minus `signature`. */\n signature: string;\n}\n\n/** The current head of one tenant's chain. */\nexport interface ChainHead {\n tenant: string;\n /** Last assigned seq (0 when empty). */\n seq: number;\n /** Hash of the event at `seq` (genesis when empty). */\n hash: string;\n /** First retained seq after pruning (1 when never pruned). */\n baseSeq?: number;\n /** `prevHash` of the first retained event (genesis when never pruned). */\n baseHash?: string;\n /** ISO-8601 time of the last append. */\n updatedAt?: string;\n}\n\n/** Tenant summary for listings. */\nexport interface AuditTenant {\n key: string;\n /** Events currently retained. */\n count?: number;\n head: ChainHead;\n /** ISO-8601 time of the first event ever recorded. */\n createdAt?: string;\n}\n\n/** Action catalog entry (documentation + UI; schemas live in code, ADR 0012). */\nexport interface ActionDefinition {\n /** Dot-delimited name, e.g. `\"invoice.paid\"`. Allowed: `a-z A-Z 0-9 . _ - :`. */\n name: string;\n description?: string;\n /** UI grouping label (e.g. `\"Billing\"`). */\n group?: string;\n /** Target types this action is expected to carry. Documentation only. */\n targets?: string[];\n /** JSON-Schema-ish description of `metadata`, for the UI. Documentation only. */\n schema?: JsonValue;\n /** Flagged in the UI; still recordable. */\n deprecated?: boolean;\n /** Where this entry came from: `\"code\"` (`defineActions`) or `\"ui\"`. */\n source?: \"code\" | \"ui\";\n createdAt?: string;\n updatedAt?: string;\n}\n\n/**\n * The query model (ADR 0007). All filters are AND-ed; list-valued filters are\n * OR-ed within themselves.\n */\nexport interface AuditQuery {\n /** Restrict to one tenant. Forced for portal principals. */\n tenant?: string;\n /** Exact action names, or families with a trailing `*` (`\"invoice.*\"`). */\n actions?: string[];\n /** Exclude these names / families. */\n excludeActions?: string[];\n actorId?: string;\n actorType?: string;\n targetType?: string;\n targetId?: string;\n outcome?: AuditOutcome;\n /** Inclusive lower bound on `occurredAt` (ISO-8601). */\n from?: string;\n /** Exclusive upper bound on `occurredAt` (ISO-8601). */\n to?: string;\n /** Case-insensitive substring over action, actor, targets, description, metadata. */\n search?: string;\n /** Sort by `(occurredAt, id)`. Default `\"desc\"` (newest first). */\n order?: \"desc\" | \"asc\";\n /** Page size. Default 50, max 500. */\n limit?: number;\n /** Opaque keyset cursor from a previous page's `pageInfo.endCursor`. */\n cursor?: string;\n}\n\n/**\n * One page of results — the `@xtandard/lib` `Paginated<T>` envelope shape, so a\n * host can feed it to `createPaginator({ fetchCursor })` unchanged (ADR 0007).\n */\nexport interface AuditPage<T = AuditEvent> {\n items: T[];\n pageInfo: {\n hasNextPage: boolean;\n endCursor: string | null;\n };\n}\n"],"mappings":";;AAqCA,MAAa,iBAAiB;;AAuD9B,MAAa,iBAA0C;CACrD;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,gBAAgB,EAAE,SAAS,KAAK"}
@@ -0,0 +1,20 @@
1
+ import { n as StreamBatch } from "./streams-DU0_gvI8.mjs";
2
+
3
+ //#region src/sinks/shared.d.ts
4
+ /** The `fetch` shape sinks call (inject one for tests, proxies, or custom agents). */
5
+ type SinkFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
6
+ /**
7
+ * Thrown by an HTTP-based sink when the destination answered non-2xx (or a
8
+ * 2xx with an error payload, e.g. Splunk's `code != 0`). The stream runner
9
+ * records `message` as the cursor's `lastError` and backs off.
10
+ */
11
+ declare class SinkHttpError extends Error {
12
+ readonly status: number;
13
+ readonly body: string;
14
+ constructor(kind: string, status: number, body: string);
15
+ }
16
+ /** Static headers, or a (possibly async) function resolved per request (rotating tokens). */
17
+ type SinkHeaders = Record<string, string> | ((batch: StreamBatch) => Record<string, string> | Promise<Record<string, string>>);
18
+ //#endregion
19
+ export { SinkHeaders as n, SinkHttpError as r, SinkFetch as t };
20
+ //# sourceMappingURL=shared-CJOyJKqT.d.mts.map
@@ -0,0 +1,100 @@
1
+ /** Max characters of a rejecting response body kept in the error message. */
2
+ const ERROR_BODY_LIMIT = 500;
3
+ /**
4
+ * Thrown by an HTTP-based sink when the destination answered non-2xx (or a
5
+ * 2xx with an error payload, e.g. Splunk's `code != 0`). The stream runner
6
+ * records `message` as the cursor's `lastError` and backs off.
7
+ */
8
+ var SinkHttpError = class extends Error {
9
+ status;
10
+ body;
11
+ constructor(kind, status, body) {
12
+ const snippet = body.length > ERROR_BODY_LIMIT ? `${body.slice(0, ERROR_BODY_LIMIT)}…` : body;
13
+ super(`${kind} sink: HTTP ${status}${snippet ? ` — ${snippet}` : ""}`);
14
+ this.name = "SinkHttpError";
15
+ this.status = status;
16
+ this.body = body;
17
+ }
18
+ };
19
+ /**
20
+ * POST/PUT with a timeout. Resolves with the response when it is 2xx; throws
21
+ * {@link SinkHttpError} otherwise, and a timeout error when the destination
22
+ * does not answer within `timeoutMs`.
23
+ */
24
+ async function sendRequest(kind, url, init, options) {
25
+ const doFetch = options.fetch ?? ((input, i) => globalThis.fetch(input, i));
26
+ const timeoutMs = options.timeoutMs ?? 1e4;
27
+ const controller = new AbortController();
28
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
29
+ let response;
30
+ try {
31
+ response = await doFetch(url, {
32
+ ...init,
33
+ signal: controller.signal
34
+ });
35
+ } catch (err) {
36
+ if (controller.signal.aborted) throw new Error(`${kind} sink: timed out after ${timeoutMs} ms`);
37
+ throw err;
38
+ } finally {
39
+ clearTimeout(timer);
40
+ }
41
+ if (!response.ok) {
42
+ const body = await response.text().catch(() => "");
43
+ throw new SinkHttpError(kind, response.status, body);
44
+ }
45
+ return response;
46
+ }
47
+ /** Resolve {@link SinkHeaders} for one batch. */
48
+ async function resolveHeaders(headers, batch) {
49
+ if (!headers) return {};
50
+ return typeof headers === "function" ? headers(batch) : headers;
51
+ }
52
+ /** The id of an item: the event id or the checkpoint id. */
53
+ function itemId(item) {
54
+ return item.kind === "event" ? item.event.id : item.checkpoint.id;
55
+ }
56
+ /** When the item happened: `occurredAt` for events, `at` for checkpoints (ISO-8601). */
57
+ function itemTime(item) {
58
+ return item.kind === "event" ? item.event.occurredAt : item.checkpoint.at;
59
+ }
60
+ /**
61
+ * The default event-type name of an item: `audit.<action>` for events,
62
+ * `audit.checkpoint` for checkpoints.
63
+ */
64
+ function defaultItemType(item) {
65
+ return item.kind === "event" ? `audit.${item.event.action}` : "audit.checkpoint";
66
+ }
67
+ /** UTF-8 byte length of a string. */
68
+ function byteLength(text) {
69
+ return new TextEncoder().encode(text).length;
70
+ }
71
+ /**
72
+ * Split serialized entries into chunks that respect both a count and a byte
73
+ * budget (each chunk's `bytes` is the sum of its entries' lengths plus
74
+ * `separatorBytes` between them). A single entry larger than `maxBytes` gets
75
+ * a chunk of its own — the destination decides (truncate or reject).
76
+ */
77
+ function chunkSerialized(entries, limits) {
78
+ const sep = limits.separatorBytes ?? 1;
79
+ const overhead = limits.overheadBytes ?? 0;
80
+ const chunks = [];
81
+ let current = [];
82
+ let bytes = overhead;
83
+ for (const entry of entries) {
84
+ const size = byteLength(entry);
85
+ const added = current.length === 0 ? size : size + sep;
86
+ if (current.length > 0 && (current.length >= limits.maxEntries || bytes + added > limits.maxBytes)) {
87
+ chunks.push(current);
88
+ current = [];
89
+ bytes = overhead;
90
+ }
91
+ bytes += current.length === 0 ? size : size + sep;
92
+ current.push(entry);
93
+ }
94
+ if (current.length > 0) chunks.push(current);
95
+ return chunks;
96
+ }
97
+ //#endregion
98
+ export { itemTime as a, itemId as i, chunkSerialized as n, resolveHeaders as o, defaultItemType as r, sendRequest as s, SinkHttpError as t };
99
+
100
+ //# sourceMappingURL=shared-DSDY-V0n.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-DSDY-V0n.mjs","names":[],"sources":["../src/sinks/shared.ts"],"sourcesContent":["/**\n * Shared plumbing for the official sinks (ADR 0008): a timed `fetch`, the\n * error a sink throws on a rejected batch, and small item helpers.\n *\n * Internal — each sink is its own subpath (`@xtandard/audit/sinks/<name>`).\n *\n * @module\n */\n\nimport type { StreamBatch, StreamItem } from \"../streams.ts\";\n\n/** The `fetch` shape sinks call (inject one for tests, proxies, or custom agents). */\nexport type SinkFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;\n\n/** Default request timeout for HTTP sinks. */\nexport const DEFAULT_TIMEOUT_MS = 10_000;\n\n/** Max characters of a rejecting response body kept in the error message. */\nconst ERROR_BODY_LIMIT = 500;\n\n/**\n * Thrown by an HTTP-based sink when the destination answered non-2xx (or a\n * 2xx with an error payload, e.g. Splunk's `code != 0`). The stream runner\n * records `message` as the cursor's `lastError` and backs off.\n */\nexport class SinkHttpError extends Error {\n readonly status: number;\n readonly body: string;\n constructor(kind: string, status: number, body: string) {\n const snippet = body.length > ERROR_BODY_LIMIT ? `${body.slice(0, ERROR_BODY_LIMIT)}…` : body;\n super(`${kind} sink: HTTP ${status}${snippet ? ` — ${snippet}` : \"\"}`);\n this.name = \"SinkHttpError\";\n this.status = status;\n this.body = body;\n }\n}\n\n/**\n * POST/PUT with a timeout. Resolves with the response when it is 2xx; throws\n * {@link SinkHttpError} otherwise, and a timeout error when the destination\n * does not answer within `timeoutMs`.\n */\nexport async function sendRequest(\n kind: string,\n url: string,\n init: RequestInit,\n options: { fetch?: SinkFetch; timeoutMs?: number },\n): Promise<Response> {\n const doFetch = options.fetch ?? ((input, i) => globalThis.fetch(input, i));\n const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n const controller = new AbortController();\n const timer = setTimeout(() => controller.abort(), timeoutMs);\n let response: Response;\n try {\n response = await doFetch(url, { ...init, signal: controller.signal });\n } catch (err) {\n if (controller.signal.aborted) throw new Error(`${kind} sink: timed out after ${timeoutMs} ms`);\n throw err;\n } finally {\n clearTimeout(timer);\n }\n if (!response.ok) {\n const body = await response.text().catch(() => \"\");\n throw new SinkHttpError(kind, response.status, body);\n }\n return response;\n}\n\n/** Static headers, or a (possibly async) function resolved per request (rotating tokens). */\nexport type SinkHeaders =\n | Record<string, string>\n | ((batch: StreamBatch) => Record<string, string> | Promise<Record<string, string>>);\n\n/** Resolve {@link SinkHeaders} for one batch. */\nexport async function resolveHeaders(\n headers: SinkHeaders | undefined,\n batch: StreamBatch,\n): Promise<Record<string, string>> {\n if (!headers) return {};\n return typeof headers === \"function\" ? headers(batch) : headers;\n}\n\n/** The id of an item: the event id or the checkpoint id. */\nexport function itemId(item: StreamItem): string {\n return item.kind === \"event\" ? item.event.id : item.checkpoint.id;\n}\n\n/** The tenant of an item. */\nexport function itemTenant(item: StreamItem): string {\n return item.kind === \"event\" ? item.event.tenant : item.checkpoint.tenant;\n}\n\n/** When the item happened: `occurredAt` for events, `at` for checkpoints (ISO-8601). */\nexport function itemTime(item: StreamItem): string {\n return item.kind === \"event\" ? item.event.occurredAt : item.checkpoint.at;\n}\n\n/**\n * The default event-type name of an item: `audit.<action>` for events,\n * `audit.checkpoint` for checkpoints.\n */\nexport function defaultItemType(item: StreamItem): string {\n return item.kind === \"event\" ? `audit.${item.event.action}` : \"audit.checkpoint\";\n}\n\n/** UTF-8 byte length of a string. */\nexport function byteLength(text: string): number {\n return new TextEncoder().encode(text).length;\n}\n\n/**\n * Split serialized entries into chunks that respect both a count and a byte\n * budget (each chunk's `bytes` is the sum of its entries' lengths plus\n * `separatorBytes` between them). A single entry larger than `maxBytes` gets\n * a chunk of its own — the destination decides (truncate or reject).\n */\nexport function chunkSerialized(\n entries: string[],\n limits: { maxEntries: number; maxBytes: number; separatorBytes?: number; overheadBytes?: number },\n): string[][] {\n const sep = limits.separatorBytes ?? 1;\n const overhead = limits.overheadBytes ?? 0;\n const chunks: string[][] = [];\n let current: string[] = [];\n let bytes = overhead;\n for (const entry of entries) {\n const size = byteLength(entry);\n const added = current.length === 0 ? size : size + sep;\n if (\n current.length > 0 &&\n (current.length >= limits.maxEntries || bytes + added > limits.maxBytes)\n ) {\n chunks.push(current);\n current = [];\n bytes = overhead;\n }\n bytes += current.length === 0 ? size : size + sep;\n current.push(entry);\n }\n if (current.length > 0) chunks.push(current);\n return chunks;\n}\n"],"mappings":";AAkBA,MAAM,mBAAmB;;;;;;AAOzB,IAAa,gBAAb,cAAmC,MAAM;CACvC;CACA;CACA,YAAY,MAAc,QAAgB,MAAc;EACtD,MAAM,UAAU,KAAK,SAAS,mBAAmB,GAAG,KAAK,MAAM,GAAG,gBAAgB,EAAE,KAAK;EACzF,MAAM,GAAG,KAAK,cAAc,SAAS,UAAU,MAAM,YAAY,IAAI;EACrE,KAAK,OAAO;EACZ,KAAK,SAAS;EACd,KAAK,OAAO;CACd;AACF;;;;;;AAOA,eAAsB,YACpB,MACA,KACA,MACA,SACmB;CACnB,MAAM,UAAU,QAAQ,WAAW,OAAO,MAAM,WAAW,MAAM,OAAO,CAAC;CACzE,MAAM,YAAY,QAAQ,aAAA;CAC1B,MAAM,aAAa,IAAI,gBAAgB;CACvC,MAAM,QAAQ,iBAAiB,WAAW,MAAM,GAAG,SAAS;CAC5D,IAAI;CACJ,IAAI;EACF,WAAW,MAAM,QAAQ,KAAK;GAAE,GAAG;GAAM,QAAQ,WAAW;EAAO,CAAC;CACtE,SAAS,KAAK;EACZ,IAAI,WAAW,OAAO,SAAS,MAAM,IAAI,MAAM,GAAG,KAAK,yBAAyB,UAAU,IAAI;EAC9F,MAAM;CACR,UAAU;EACR,aAAa,KAAK;CACpB;CACA,IAAI,CAAC,SAAS,IAAI;EAChB,MAAM,OAAO,MAAM,SAAS,KAAK,EAAE,YAAY,EAAE;EACjD,MAAM,IAAI,cAAc,MAAM,SAAS,QAAQ,IAAI;CACrD;CACA,OAAO;AACT;;AAQA,eAAsB,eACpB,SACA,OACiC;CACjC,IAAI,CAAC,SAAS,OAAO,CAAC;CACtB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,IAAI;AAC1D;;AAGA,SAAgB,OAAO,MAA0B;CAC/C,OAAO,KAAK,SAAS,UAAU,KAAK,MAAM,KAAK,KAAK,WAAW;AACjE;;AAQA,SAAgB,SAAS,MAA0B;CACjD,OAAO,KAAK,SAAS,UAAU,KAAK,MAAM,aAAa,KAAK,WAAW;AACzE;;;;;AAMA,SAAgB,gBAAgB,MAA0B;CACxD,OAAO,KAAK,SAAS,UAAU,SAAS,KAAK,MAAM,WAAW;AAChE;;AAGA,SAAgB,WAAW,MAAsB;CAC/C,OAAO,IAAI,YAAY,EAAE,OAAO,IAAI,EAAE;AACxC;;;;;;;AAQA,SAAgB,gBACd,SACA,QACY;CACZ,MAAM,MAAM,OAAO,kBAAkB;CACrC,MAAM,WAAW,OAAO,iBAAiB;CACzC,MAAM,SAAqB,CAAC;CAC5B,IAAI,UAAoB,CAAC;CACzB,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,OAAO,WAAW,KAAK;EAC7B,MAAM,QAAQ,QAAQ,WAAW,IAAI,OAAO,OAAO;EACnD,IACE,QAAQ,SAAS,MAChB,QAAQ,UAAU,OAAO,cAAc,QAAQ,QAAQ,OAAO,WAC/D;GACA,OAAO,KAAK,OAAO;GACnB,UAAU,CAAC;GACX,QAAQ;EACV;EACA,SAAS,QAAQ,WAAW,IAAI,OAAO,OAAO;EAC9C,QAAQ,KAAK,KAAK;CACpB;CACA,IAAI,QAAQ,SAAS,GAAG,OAAO,KAAK,OAAO;CAC3C,OAAO;AACT"}
@@ -0,0 +1,20 @@
1
+ import { n as StreamBatch } from "./streams-CRuxOYcb.cjs";
2
+
3
+ //#region src/sinks/shared.d.ts
4
+ /** The `fetch` shape sinks call (inject one for tests, proxies, or custom agents). */
5
+ type SinkFetch = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
6
+ /**
7
+ * Thrown by an HTTP-based sink when the destination answered non-2xx (or a
8
+ * 2xx with an error payload, e.g. Splunk's `code != 0`). The stream runner
9
+ * records `message` as the cursor's `lastError` and backs off.
10
+ */
11
+ declare class SinkHttpError extends Error {
12
+ readonly status: number;
13
+ readonly body: string;
14
+ constructor(kind: string, status: number, body: string);
15
+ }
16
+ /** Static headers, or a (possibly async) function resolved per request (rotating tokens). */
17
+ type SinkHeaders = Record<string, string> | ((batch: StreamBatch) => Record<string, string> | Promise<Record<string, string>>);
18
+ //#endregion
19
+ export { SinkHeaders as n, SinkHttpError as r, SinkFetch as t };
20
+ //# sourceMappingURL=shared-EANCdRqn.d.cts.map
@@ -0,0 +1,141 @@
1
+ /** Max characters of a rejecting response body kept in the error message. */
2
+ const ERROR_BODY_LIMIT = 500;
3
+ /**
4
+ * Thrown by an HTTP-based sink when the destination answered non-2xx (or a
5
+ * 2xx with an error payload, e.g. Splunk's `code != 0`). The stream runner
6
+ * records `message` as the cursor's `lastError` and backs off.
7
+ */
8
+ var SinkHttpError = class extends Error {
9
+ status;
10
+ body;
11
+ constructor(kind, status, body) {
12
+ const snippet = body.length > ERROR_BODY_LIMIT ? `${body.slice(0, ERROR_BODY_LIMIT)}…` : body;
13
+ super(`${kind} sink: HTTP ${status}${snippet ? ` — ${snippet}` : ""}`);
14
+ this.name = "SinkHttpError";
15
+ this.status = status;
16
+ this.body = body;
17
+ }
18
+ };
19
+ /**
20
+ * POST/PUT with a timeout. Resolves with the response when it is 2xx; throws
21
+ * {@link SinkHttpError} otherwise, and a timeout error when the destination
22
+ * does not answer within `timeoutMs`.
23
+ */
24
+ async function sendRequest(kind, url, init, options) {
25
+ const doFetch = options.fetch ?? ((input, i) => globalThis.fetch(input, i));
26
+ const timeoutMs = options.timeoutMs ?? 1e4;
27
+ const controller = new AbortController();
28
+ const timer = setTimeout(() => controller.abort(), timeoutMs);
29
+ let response;
30
+ try {
31
+ response = await doFetch(url, {
32
+ ...init,
33
+ signal: controller.signal
34
+ });
35
+ } catch (err) {
36
+ if (controller.signal.aborted) throw new Error(`${kind} sink: timed out after ${timeoutMs} ms`);
37
+ throw err;
38
+ } finally {
39
+ clearTimeout(timer);
40
+ }
41
+ if (!response.ok) {
42
+ const body = await response.text().catch(() => "");
43
+ throw new SinkHttpError(kind, response.status, body);
44
+ }
45
+ return response;
46
+ }
47
+ /** Resolve {@link SinkHeaders} for one batch. */
48
+ async function resolveHeaders(headers, batch) {
49
+ if (!headers) return {};
50
+ return typeof headers === "function" ? headers(batch) : headers;
51
+ }
52
+ /** The id of an item: the event id or the checkpoint id. */
53
+ function itemId(item) {
54
+ return item.kind === "event" ? item.event.id : item.checkpoint.id;
55
+ }
56
+ /** When the item happened: `occurredAt` for events, `at` for checkpoints (ISO-8601). */
57
+ function itemTime(item) {
58
+ return item.kind === "event" ? item.event.occurredAt : item.checkpoint.at;
59
+ }
60
+ /**
61
+ * The default event-type name of an item: `audit.<action>` for events,
62
+ * `audit.checkpoint` for checkpoints.
63
+ */
64
+ function defaultItemType(item) {
65
+ return item.kind === "event" ? `audit.${item.event.action}` : "audit.checkpoint";
66
+ }
67
+ /** UTF-8 byte length of a string. */
68
+ function byteLength(text) {
69
+ return new TextEncoder().encode(text).length;
70
+ }
71
+ /**
72
+ * Split serialized entries into chunks that respect both a count and a byte
73
+ * budget (each chunk's `bytes` is the sum of its entries' lengths plus
74
+ * `separatorBytes` between them). A single entry larger than `maxBytes` gets
75
+ * a chunk of its own — the destination decides (truncate or reject).
76
+ */
77
+ function chunkSerialized(entries, limits) {
78
+ const sep = limits.separatorBytes ?? 1;
79
+ const overhead = limits.overheadBytes ?? 0;
80
+ const chunks = [];
81
+ let current = [];
82
+ let bytes = overhead;
83
+ for (const entry of entries) {
84
+ const size = byteLength(entry);
85
+ const added = current.length === 0 ? size : size + sep;
86
+ if (current.length > 0 && (current.length >= limits.maxEntries || bytes + added > limits.maxBytes)) {
87
+ chunks.push(current);
88
+ current = [];
89
+ bytes = overhead;
90
+ }
91
+ bytes += current.length === 0 ? size : size + sep;
92
+ current.push(entry);
93
+ }
94
+ if (current.length > 0) chunks.push(current);
95
+ return chunks;
96
+ }
97
+ //#endregion
98
+ Object.defineProperty(exports, "SinkHttpError", {
99
+ enumerable: true,
100
+ get: function() {
101
+ return SinkHttpError;
102
+ }
103
+ });
104
+ Object.defineProperty(exports, "chunkSerialized", {
105
+ enumerable: true,
106
+ get: function() {
107
+ return chunkSerialized;
108
+ }
109
+ });
110
+ Object.defineProperty(exports, "defaultItemType", {
111
+ enumerable: true,
112
+ get: function() {
113
+ return defaultItemType;
114
+ }
115
+ });
116
+ Object.defineProperty(exports, "itemId", {
117
+ enumerable: true,
118
+ get: function() {
119
+ return itemId;
120
+ }
121
+ });
122
+ Object.defineProperty(exports, "itemTime", {
123
+ enumerable: true,
124
+ get: function() {
125
+ return itemTime;
126
+ }
127
+ });
128
+ Object.defineProperty(exports, "resolveHeaders", {
129
+ enumerable: true,
130
+ get: function() {
131
+ return resolveHeaders;
132
+ }
133
+ });
134
+ Object.defineProperty(exports, "sendRequest", {
135
+ enumerable: true,
136
+ get: function() {
137
+ return sendRequest;
138
+ }
139
+ });
140
+
141
+ //# sourceMappingURL=shared-OOAq-U4S.cjs.map