@dads-framework/audit 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +69 -2
  3. package/dist/audit.tsbuildinfo +1 -0
  4. package/dist/index.d.ts +25 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +24 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/lib/actor/compose-subject-to-audit-actor.d.ts +32 -0
  9. package/dist/lib/actor/compose-subject-to-audit-actor.d.ts.map +1 -0
  10. package/dist/lib/actor/compose-subject-to-audit-actor.js +66 -0
  11. package/dist/lib/actor/compose-subject-to-audit-actor.js.map +1 -0
  12. package/dist/lib/audit-plugin.d.ts +21 -0
  13. package/dist/lib/audit-plugin.d.ts.map +1 -0
  14. package/dist/lib/audit-plugin.js +61 -0
  15. package/dist/lib/audit-plugin.js.map +1 -0
  16. package/dist/lib/client-diagnostics/client-diagnostic-event.ids.d.ts +5 -0
  17. package/dist/lib/client-diagnostics/client-diagnostic-event.ids.d.ts.map +1 -0
  18. package/dist/lib/client-diagnostics/client-diagnostic-event.ids.js +4 -0
  19. package/dist/lib/client-diagnostics/client-diagnostic-event.ids.js.map +1 -0
  20. package/dist/lib/client-diagnostics/client-diagnostics.route-handlers.d.ts +23 -0
  21. package/dist/lib/client-diagnostics/client-diagnostics.route-handlers.d.ts.map +1 -0
  22. package/dist/lib/client-diagnostics/client-diagnostics.route-handlers.js +27 -0
  23. package/dist/lib/client-diagnostics/client-diagnostics.route-handlers.js.map +1 -0
  24. package/dist/lib/client-diagnostics/client-diagnostics.routes.d.ts +18 -0
  25. package/dist/lib/client-diagnostics/client-diagnostics.routes.d.ts.map +1 -0
  26. package/dist/lib/client-diagnostics/client-diagnostics.routes.js +41 -0
  27. package/dist/lib/client-diagnostics/client-diagnostics.routes.js.map +1 -0
  28. package/dist/lib/client-diagnostics/logic/client-diagnostic-row.d.ts +30 -0
  29. package/dist/lib/client-diagnostics/logic/client-diagnostic-row.d.ts.map +1 -0
  30. package/dist/lib/client-diagnostics/logic/client-diagnostic-row.js +39 -0
  31. package/dist/lib/client-diagnostics/logic/client-diagnostic-row.js.map +1 -0
  32. package/dist/lib/client-diagnostics/record-client-diagnostics.d.ts +29 -0
  33. package/dist/lib/client-diagnostics/record-client-diagnostics.d.ts.map +1 -0
  34. package/dist/lib/client-diagnostics/record-client-diagnostics.js +40 -0
  35. package/dist/lib/client-diagnostics/record-client-diagnostics.js.map +1 -0
  36. package/dist/lib/compose-audit.d.ts +27 -0
  37. package/dist/lib/compose-audit.d.ts.map +1 -0
  38. package/dist/lib/compose-audit.js +38 -0
  39. package/dist/lib/compose-audit.js.map +1 -0
  40. package/dist/lib/database/attach-audit-trigger.d.ts +34 -0
  41. package/dist/lib/database/attach-audit-trigger.d.ts.map +1 -0
  42. package/dist/lib/database/attach-audit-trigger.js +40 -0
  43. package/dist/lib/database/attach-audit-trigger.js.map +1 -0
  44. package/dist/lib/database/audit-log-position.ids.d.ts +13 -0
  45. package/dist/lib/database/audit-log-position.ids.d.ts.map +1 -0
  46. package/dist/lib/database/audit-log-position.ids.js +11 -0
  47. package/dist/lib/database/audit-log-position.ids.js.map +1 -0
  48. package/dist/lib/database/audit-row-json.d.ts +10 -0
  49. package/dist/lib/database/audit-row-json.d.ts.map +1 -0
  50. package/dist/lib/database/audit-row-json.js +2 -0
  51. package/dist/lib/database/audit-row-json.js.map +1 -0
  52. package/dist/lib/database/audit-trigger-allowlist.d.ts +4 -0
  53. package/dist/lib/database/audit-trigger-allowlist.d.ts.map +1 -0
  54. package/dist/lib/database/audit-trigger-allowlist.js +8 -0
  55. package/dist/lib/database/audit-trigger-allowlist.js.map +1 -0
  56. package/dist/lib/database/configure-audit-triggers.d.ts +8 -0
  57. package/dist/lib/database/configure-audit-triggers.d.ts.map +1 -0
  58. package/dist/lib/database/configure-audit-triggers.js +27 -0
  59. package/dist/lib/database/configure-audit-triggers.js.map +1 -0
  60. package/dist/lib/database/configure-plugin-audit-triggers.d.ts +11 -0
  61. package/dist/lib/database/configure-plugin-audit-triggers.d.ts.map +1 -0
  62. package/dist/lib/database/configure-plugin-audit-triggers.js +23 -0
  63. package/dist/lib/database/configure-plugin-audit-triggers.js.map +1 -0
  64. package/dist/lib/database/generated-tables/audit-log.tables.d.ts +363 -0
  65. package/dist/lib/database/generated-tables/audit-log.tables.d.ts.map +1 -0
  66. package/dist/lib/database/generated-tables/audit-log.tables.js +53 -0
  67. package/dist/lib/database/generated-tables/audit-log.tables.js.map +1 -0
  68. package/dist/lib/database/generated-tables/client-diagnostic-events.tables.d.ts +376 -0
  69. package/dist/lib/database/generated-tables/client-diagnostic-events.tables.d.ts.map +1 -0
  70. package/dist/lib/database/generated-tables/client-diagnostic-events.tables.js +45 -0
  71. package/dist/lib/database/generated-tables/client-diagnostic-events.tables.js.map +1 -0
  72. package/dist/lib/database/generated-tables/known-fault-fingerprints.tables.d.ts +76 -0
  73. package/dist/lib/database/generated-tables/known-fault-fingerprints.tables.d.ts.map +1 -0
  74. package/dist/lib/database/generated-tables/known-fault-fingerprints.tables.js +32 -0
  75. package/dist/lib/database/generated-tables/known-fault-fingerprints.tables.js.map +1 -0
  76. package/dist/lib/database/generated-tables/request-log.tables.d.ts +678 -0
  77. package/dist/lib/database/generated-tables/request-log.tables.d.ts.map +1 -0
  78. package/dist/lib/database/generated-tables/request-log.tables.js +59 -0
  79. package/dist/lib/database/generated-tables/request-log.tables.js.map +1 -0
  80. package/dist/lib/database/migrations/20260910233455_audit.migration.d.ts +5 -0
  81. package/dist/lib/database/migrations/20260910233455_audit.migration.d.ts.map +1 -0
  82. package/dist/lib/database/migrations/20260910233455_audit.migration.js +304 -0
  83. package/dist/lib/database/migrations/20260910233455_audit.migration.js.map +1 -0
  84. package/dist/lib/database/readers/audit-log-reader.interface.d.ts +82 -0
  85. package/dist/lib/database/readers/audit-log-reader.interface.d.ts.map +1 -0
  86. package/dist/lib/database/readers/audit-log-reader.interface.js +10 -0
  87. package/dist/lib/database/readers/audit-log-reader.interface.js.map +1 -0
  88. package/dist/lib/database/readers/drizzle-audit-log-reader.d.ts +16 -0
  89. package/dist/lib/database/readers/drizzle-audit-log-reader.d.ts.map +1 -0
  90. package/dist/lib/database/readers/drizzle-audit-log-reader.js +197 -0
  91. package/dist/lib/database/readers/drizzle-audit-log-reader.js.map +1 -0
  92. package/dist/lib/database/readers/drizzle-fault-alert-reader.d.ts +36 -0
  93. package/dist/lib/database/readers/drizzle-fault-alert-reader.d.ts.map +1 -0
  94. package/dist/lib/database/readers/drizzle-fault-alert-reader.js +113 -0
  95. package/dist/lib/database/readers/drizzle-fault-alert-reader.js.map +1 -0
  96. package/dist/lib/database/readers/drizzle-request-log-reader.d.ts +16 -0
  97. package/dist/lib/database/readers/drizzle-request-log-reader.d.ts.map +1 -0
  98. package/dist/lib/database/readers/drizzle-request-log-reader.js +88 -0
  99. package/dist/lib/database/readers/drizzle-request-log-reader.js.map +1 -0
  100. package/dist/lib/database/readers/fault-alert-reader.interface.d.ts +73 -0
  101. package/dist/lib/database/readers/fault-alert-reader.interface.d.ts.map +1 -0
  102. package/dist/lib/database/readers/fault-alert-reader.interface.js +13 -0
  103. package/dist/lib/database/readers/fault-alert-reader.interface.js.map +1 -0
  104. package/dist/lib/database/readers/request-log-reader.interface.d.ts +64 -0
  105. package/dist/lib/database/readers/request-log-reader.interface.d.ts.map +1 -0
  106. package/dist/lib/database/readers/request-log-reader.interface.js +9 -0
  107. package/dist/lib/database/readers/request-log-reader.interface.js.map +1 -0
  108. package/dist/lib/database/testing/audited-fixture-tables.d.ts +14 -0
  109. package/dist/lib/database/testing/audited-fixture-tables.d.ts.map +1 -0
  110. package/dist/lib/database/testing/audited-fixture-tables.js +46 -0
  111. package/dist/lib/database/testing/audited-fixture-tables.js.map +1 -0
  112. package/dist/lib/database/writers/client-diagnostic-writer.interface.d.ts +20 -0
  113. package/dist/lib/database/writers/client-diagnostic-writer.interface.d.ts.map +1 -0
  114. package/dist/lib/database/writers/client-diagnostic-writer.interface.js +3 -0
  115. package/dist/lib/database/writers/client-diagnostic-writer.interface.js.map +1 -0
  116. package/dist/lib/database/writers/drizzle-client-diagnostic-writer.d.ts +11 -0
  117. package/dist/lib/database/writers/drizzle-client-diagnostic-writer.d.ts.map +1 -0
  118. package/dist/lib/database/writers/drizzle-client-diagnostic-writer.js +46 -0
  119. package/dist/lib/database/writers/drizzle-client-diagnostic-writer.js.map +1 -0
  120. package/dist/lib/database/writers/drizzle-request-log-writer.d.ts +9 -0
  121. package/dist/lib/database/writers/drizzle-request-log-writer.d.ts.map +1 -0
  122. package/dist/lib/database/writers/drizzle-request-log-writer.js +17 -0
  123. package/dist/lib/database/writers/drizzle-request-log-writer.js.map +1 -0
  124. package/dist/lib/database/writers/request-log-writer.interface.d.ts +17 -0
  125. package/dist/lib/database/writers/request-log-writer.interface.d.ts.map +1 -0
  126. package/dist/lib/database/writers/request-log-writer.interface.js +10 -0
  127. package/dist/lib/database/writers/request-log-writer.interface.js.map +1 -0
  128. package/dist/lib/fault-alerts/alert-new-faults.job.d.ts +48 -0
  129. package/dist/lib/fault-alerts/alert-new-faults.job.d.ts.map +1 -0
  130. package/dist/lib/fault-alerts/alert-new-faults.job.js +105 -0
  131. package/dist/lib/fault-alerts/alert-new-faults.job.js.map +1 -0
  132. package/dist/lib/fault-alerts/logic/describe-fault-line.d.ts +16 -0
  133. package/dist/lib/fault-alerts/logic/describe-fault-line.d.ts.map +1 -0
  134. package/dist/lib/fault-alerts/logic/describe-fault-line.js +21 -0
  135. package/dist/lib/fault-alerts/logic/describe-fault-line.js.map +1 -0
  136. package/dist/lib/fault-alerts/logic/summarize-new-faults.d.ts +51 -0
  137. package/dist/lib/fault-alerts/logic/summarize-new-faults.d.ts.map +1 -0
  138. package/dist/lib/fault-alerts/logic/summarize-new-faults.js +56 -0
  139. package/dist/lib/fault-alerts/logic/summarize-new-faults.js.map +1 -0
  140. package/dist/lib/fault-alerts/new-faults.email-template.d.ts +8 -0
  141. package/dist/lib/fault-alerts/new-faults.email-template.d.ts.map +1 -0
  142. package/dist/lib/fault-alerts/new-faults.email-template.js +66 -0
  143. package/dist/lib/fault-alerts/new-faults.email-template.js.map +1 -0
  144. package/dist/lib/jobs/prune-client-diagnostics.job.d.ts +25 -0
  145. package/dist/lib/jobs/prune-client-diagnostics.job.d.ts.map +1 -0
  146. package/dist/lib/jobs/prune-client-diagnostics.job.js +38 -0
  147. package/dist/lib/jobs/prune-client-diagnostics.job.js.map +1 -0
  148. package/dist/lib/jobs/prune-request-log.job.d.ts +23 -0
  149. package/dist/lib/jobs/prune-request-log.job.d.ts.map +1 -0
  150. package/dist/lib/jobs/prune-request-log.job.js +36 -0
  151. package/dist/lib/jobs/prune-request-log.job.js.map +1 -0
  152. package/dist/lib/jobs/retention-window.d.ts +3 -0
  153. package/dist/lib/jobs/retention-window.d.ts.map +1 -0
  154. package/dist/lib/jobs/retention-window.js +10 -0
  155. package/dist/lib/jobs/retention-window.js.map +1 -0
  156. package/dist/lib/request-log/insert-foreign-rows.d.ts +21 -0
  157. package/dist/lib/request-log/insert-foreign-rows.d.ts.map +1 -0
  158. package/dist/lib/request-log/insert-foreign-rows.js +86 -0
  159. package/dist/lib/request-log/insert-foreign-rows.js.map +1 -0
  160. package/dist/lib/request-log/postgres-request-log-sink.d.ts +64 -0
  161. package/dist/lib/request-log/postgres-request-log-sink.d.ts.map +1 -0
  162. package/dist/lib/request-log/postgres-request-log-sink.js +168 -0
  163. package/dist/lib/request-log/postgres-request-log-sink.js.map +1 -0
  164. package/dist/schema.d.ts +6 -0
  165. package/dist/schema.d.ts.map +1 -0
  166. package/dist/schema.js +5 -0
  167. package/dist/schema.js.map +1 -0
  168. package/dist/testing/audit-log-record.factory.d.ts +13 -0
  169. package/dist/testing/audit-log-record.factory.d.ts.map +1 -0
  170. package/dist/testing/audit-log-record.factory.js +46 -0
  171. package/dist/testing/audit-log-record.factory.js.map +1 -0
  172. package/dist/testing/audit-log.factory.d.ts +14 -0
  173. package/dist/testing/audit-log.factory.d.ts.map +1 -0
  174. package/dist/testing/audit-log.factory.js +30 -0
  175. package/dist/testing/audit-log.factory.js.map +1 -0
  176. package/dist/testing/index.d.ts +4 -0
  177. package/dist/testing/index.d.ts.map +1 -0
  178. package/dist/testing/index.js +5 -0
  179. package/dist/testing/index.js.map +1 -0
  180. package/dist/testing/request-log.factory.d.ts +13 -0
  181. package/dist/testing/request-log.factory.d.ts.map +1 -0
  182. package/dist/testing/request-log.factory.js +40 -0
  183. package/dist/testing/request-log.factory.js.map +1 -0
  184. package/package.json +67 -4
  185. package/src/lib/database/migrations/20260910233455_audit.migration.ts +345 -0
@@ -0,0 +1,25 @@
1
+ export { attachAuditTrigger, detachAuditTrigger, type AuditTriggerMigrationBuilder, type AuditTriggerOptions, } from "./lib/database/attach-audit-trigger.js";
2
+ export { up as installAuditSchemaV1 } from "./lib/database/migrations/20260910233455_audit.migration.js";
3
+ export { AUDIT_TRIGGER_ALLOWLIST, type AuditTriggerAllowlistEntry, } from "./lib/database/audit-trigger-allowlist.js";
4
+ export { AuditLogReader, type AuditLogCursor, type AuditLogRecord, type AuditLogRowFilter, type AuditLogScope, } from "./lib/database/readers/audit-log-reader.interface.js";
5
+ export { DrizzleAuditLogReader } from "./lib/database/readers/drizzle-audit-log-reader.js";
6
+ export { RequestLogReader, type RefusedRequest, type RefusedRequestFilter, type RequestLogCursor, type RequestLogEntry, } from "./lib/database/readers/request-log-reader.interface.js";
7
+ export { DrizzleRequestLogReader } from "./lib/database/readers/drizzle-request-log-reader.js";
8
+ export { type AuditLogPosition, parseAuditLogPosition, } from "./lib/database/audit-log-position.ids.js";
9
+ export { auditLog } from "./lib/database/generated-tables/audit-log.tables.js";
10
+ export { requestLog } from "./lib/database/generated-tables/request-log.tables.js";
11
+ export { clientDiagnosticEvents } from "./lib/database/generated-tables/client-diagnostic-events.tables.js";
12
+ export { knownFaultFingerprints } from "./lib/database/generated-tables/known-fault-fingerprints.tables.js";
13
+ export { insertForeignClientFaults, insertForeignRequestRows, type ForeignRowsHandle, } from "./lib/request-log/insert-foreign-rows.js";
14
+ export { PostgresRequestLogSink, type PostgresRequestLogSinkOptions, type RequestLogSinkLog, } from "./lib/request-log/postgres-request-log-sink.js";
15
+ export { composeSubjectToAuditActor, USER_SUBJECT_TYPE, type ActorForSubject, type ResolvedSubject, } from "./lib/actor/compose-subject-to-audit-actor.js";
16
+ export { ALERT_NEW_FAULTS_JOB, createAlertNewFaultsJob, type CreateAlertNewFaultsJobDeps, } from "./lib/fault-alerts/alert-new-faults.job.js";
17
+ export { newFaultsEmailTemplate } from "./lib/fault-alerts/new-faults.email-template.js";
18
+ export { DrizzleFaultAlertReader } from "./lib/database/readers/drizzle-fault-alert-reader.js";
19
+ export { type AlertedFault, FaultAlertReader, type FaultGroup, type FaultOrigin, } from "./lib/database/readers/fault-alert-reader.interface.js";
20
+ export { composeAudit, type AssembledAudit, type ComposeAuditDeps, } from "./lib/compose-audit.js";
21
+ export { configureAuditTriggers, type AuditTriggerConfiguration, } from "./lib/database/configure-audit-triggers.js";
22
+ export type { AuditScopeValues } from "./lib/database/audit-row-json.js";
23
+ export { auditDepsService, auditService, createAuditPlugin, type AuditPluginOptions, type AuditServices, } from "./lib/audit-plugin.js";
24
+ export { configurePluginAuditTriggers } from "./lib/database/configure-plugin-audit-triggers.js";
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,KAAK,4BAA4B,EACjC,KAAK,mBAAmB,GACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,EAAE,IAAI,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACzG,OAAO,EACL,uBAAuB,EACvB,KAAK,0BAA0B,GAChC,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,cAAc,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,GACnB,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EACL,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,GACrB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EACL,KAAK,gBAAgB,EACrB,qBAAqB,GACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,qDAAqD,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oEAAoE,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,oEAAoE,CAAC;AAC5G,OAAO,EACL,yBAAyB,EACzB,wBAAwB,EACxB,KAAK,iBAAiB,GACvB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,sBAAsB,EACtB,KAAK,6BAA6B,EAClC,KAAK,iBAAiB,GACvB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,KAAK,2BAA2B,GACjC,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EACL,KAAK,YAAY,EACjB,gBAAgB,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EACL,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,KAAK,yBAAyB,GAC/B,MAAM,4CAA4C,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,KAAK,kBAAkB,EACvB,KAAK,aAAa,GACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ export { attachAuditTrigger, detachAuditTrigger, } from "./lib/database/attach-audit-trigger.js";
2
+ export { up as installAuditSchemaV1 } from "./lib/database/migrations/20260910233455_audit.migration.js";
3
+ export { AUDIT_TRIGGER_ALLOWLIST, } from "./lib/database/audit-trigger-allowlist.js";
4
+ export { AuditLogReader, } from "./lib/database/readers/audit-log-reader.interface.js";
5
+ export { DrizzleAuditLogReader } from "./lib/database/readers/drizzle-audit-log-reader.js";
6
+ export { RequestLogReader, } from "./lib/database/readers/request-log-reader.interface.js";
7
+ export { DrizzleRequestLogReader } from "./lib/database/readers/drizzle-request-log-reader.js";
8
+ export { parseAuditLogPosition, } from "./lib/database/audit-log-position.ids.js";
9
+ export { auditLog } from "./lib/database/generated-tables/audit-log.tables.js";
10
+ export { requestLog } from "./lib/database/generated-tables/request-log.tables.js";
11
+ export { clientDiagnosticEvents } from "./lib/database/generated-tables/client-diagnostic-events.tables.js";
12
+ export { knownFaultFingerprints } from "./lib/database/generated-tables/known-fault-fingerprints.tables.js";
13
+ export { insertForeignClientFaults, insertForeignRequestRows, } from "./lib/request-log/insert-foreign-rows.js";
14
+ export { PostgresRequestLogSink, } from "./lib/request-log/postgres-request-log-sink.js";
15
+ export { composeSubjectToAuditActor, USER_SUBJECT_TYPE, } from "./lib/actor/compose-subject-to-audit-actor.js";
16
+ export { ALERT_NEW_FAULTS_JOB, createAlertNewFaultsJob, } from "./lib/fault-alerts/alert-new-faults.job.js";
17
+ export { newFaultsEmailTemplate } from "./lib/fault-alerts/new-faults.email-template.js";
18
+ export { DrizzleFaultAlertReader } from "./lib/database/readers/drizzle-fault-alert-reader.js";
19
+ export { FaultAlertReader, } from "./lib/database/readers/fault-alert-reader.interface.js";
20
+ export { composeAudit, } from "./lib/compose-audit.js";
21
+ export { configureAuditTriggers, } from "./lib/database/configure-audit-triggers.js";
22
+ export { auditDepsService, auditService, createAuditPlugin, } from "./lib/audit-plugin.js";
23
+ export { configurePluginAuditTriggers } from "./lib/database/configure-plugin-audit-triggers.js";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,kBAAkB,GAGnB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,EAAE,IAAI,oBAAoB,EAAE,MAAM,6DAA6D,CAAC;AACzG,OAAO,EACL,uBAAuB,GAExB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,cAAc,GAKf,MAAM,sDAAsD,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,OAAO,EACL,gBAAgB,GAKjB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EAEL,qBAAqB,GACtB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,qDAAqD,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,uDAAuD,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,oEAAoE,CAAC;AAC5G,OAAO,EAAE,sBAAsB,EAAE,MAAM,oEAAoE,CAAC;AAC5G,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,0CAA0C,CAAC;AAClD,OAAO,EACL,sBAAsB,GAGvB,MAAM,gDAAgD,CAAC;AACxD,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,GAGlB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,GAExB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iDAAiD,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,sDAAsD,CAAC;AAC/F,OAAO,EAEL,gBAAgB,GAGjB,MAAM,wDAAwD,CAAC;AAChE,OAAO,EACL,YAAY,GAGb,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,sBAAsB,GAEvB,MAAM,4CAA4C,CAAC;AAEpD,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,GAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Turns the authorization subject a request resolved into the actor the audit
3
+ * trail records. Pure: no I/O, no clock, no database.
4
+ *
5
+ * What every product shares lives here: the plain user mapping, the fail-safe
6
+ * for a subject kind this build does not recognize, and the `subject === null`
7
+ * path. Which OTHER subject kinds exist is a product's own knowledge — the
8
+ * wire names come from its access barrels — so a product composes its mapper
9
+ * from handlers keyed by those names instead of this kit importing them.
10
+ */
11
+ import type { AuditActor } from "@dads-framework/audit-actor";
12
+ import type { SubjectRef } from "@dads-framework/authorization";
13
+ import type { AuditActorForSubject } from "@dads-framework/http";
14
+ /** The `SubjectRef.type` of an ordinary human account. */
15
+ export declare const USER_SUBJECT_TYPE = "user";
16
+ /** What every mapping needs: the subject, who proved it, and the request. */
17
+ export type ResolvedSubject = {
18
+ readonly subject: SubjectRef;
19
+ /** The identity the credential proved, before any business actor swap. */
20
+ readonly authenticatedSubject: SubjectRef | null;
21
+ readonly requestId: string;
22
+ };
23
+ /** How one subject kind becomes the actor its writes are recorded under. */
24
+ export type ActorForSubject = (resolved: ResolvedSubject) => AuditActor;
25
+ /**
26
+ * Builds the mapping the HTTP kit calls, from one handler per subject kind the
27
+ * product knows, keyed by the wire name its access barrel defines. The plain
28
+ * `user` mapping is this kit's and is not replaceable; a type the table does
29
+ * not name takes the fail-safe below.
30
+ */
31
+ export declare function composeSubjectToAuditActor(actorForSubjectType: Readonly<Record<string, ActorForSubject>>, actorForRequest?: (input: Parameters<AuditActorForSubject>[0]) => AuditActor | undefined): AuditActorForSubject;
32
+ //# sourceMappingURL=compose-subject-to-audit-actor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-subject-to-audit-actor.d.ts","sourceRoot":"","sources":["../../../src/lib/actor/compose-subject-to-audit-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC,6EAA6E;AAC7E,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,0EAA0E;IAC1E,QAAQ,CAAC,oBAAoB,EAAE,UAAU,GAAG,IAAI,CAAC;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,4EAA4E;AAC5E,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,eAAe,KAAK,UAAU,CAAC;AAExE;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,EAC9D,eAAe,CAAC,EAAE,CAChB,KAAK,EAAE,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,KACvC,UAAU,GAAG,SAAS,GAC1B,oBAAoB,CAoBtB"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Turns the authorization subject a request resolved into the actor the audit
3
+ * trail records. Pure: no I/O, no clock, no database.
4
+ *
5
+ * What every product shares lives here: the plain user mapping, the fail-safe
6
+ * for a subject kind this build does not recognize, and the `subject === null`
7
+ * path. Which OTHER subject kinds exist is a product's own knowledge — the
8
+ * wire names come from its access barrels — so a product composes its mapper
9
+ * from handlers keyed by those names instead of this kit importing them.
10
+ */
11
+ /** The `SubjectRef.type` of an ordinary human account. */
12
+ export const USER_SUBJECT_TYPE = "user";
13
+ /**
14
+ * Builds the mapping the HTTP kit calls, from one handler per subject kind the
15
+ * product knows, keyed by the wire name its access barrel defines. The plain
16
+ * `user` mapping is this kit's and is not replaceable; a type the table does
17
+ * not name takes the fail-safe below.
18
+ */
19
+ export function composeSubjectToAuditActor(actorForSubjectType, actorForRequest) {
20
+ const actorForType = new Map([
21
+ ...Object.entries(actorForSubjectType),
22
+ [USER_SUBJECT_TYPE, userActor],
23
+ ]);
24
+ return (request) => {
25
+ const override = actorForRequest?.(request);
26
+ if (override !== undefined)
27
+ return override;
28
+ const { subject, authenticatedSubject, requestId } = request;
29
+ if (subject === null) {
30
+ return provenIdentityActor({ authenticatedSubject, requestId });
31
+ }
32
+ const actorFor = actorForType.get(subject.type);
33
+ const resolved = { subject, authenticatedSubject, requestId };
34
+ return actorFor === undefined
35
+ ? provenIdentityActor(resolved)
36
+ : actorFor(resolved);
37
+ };
38
+ }
39
+ /**
40
+ * A plain user, but only when the credential proved that same user. Any
41
+ * disagreement between the two falls back to the identity actually proven.
42
+ */
43
+ function userActor(resolved) {
44
+ const { subject, authenticatedSubject, requestId } = resolved;
45
+ const provenSameUser = authenticatedSubject?.type === USER_SUBJECT_TYPE &&
46
+ subject.id === authenticatedSubject.id;
47
+ return provenSameUser
48
+ ? { kind: "user", id: subject.id, requestId }
49
+ : provenIdentityActor(resolved);
50
+ }
51
+ /**
52
+ * Fail-safe. A subject type this build does not recognize — a new actor kind
53
+ * landing before the product's table learns it, or the two subjects
54
+ * disagreeing — still has to produce an actor, because returning nothing would
55
+ * make the trigger refuse a write that was properly authenticated. Attribute
56
+ * it to the identity the credential actually proved, and to `anonymous` only
57
+ * when no credential proved one.
58
+ */
59
+ function provenIdentityActor(proof) {
60
+ const { authenticatedSubject, requestId } = proof;
61
+ if (authenticatedSubject?.type === USER_SUBJECT_TYPE) {
62
+ return { kind: "user", id: authenticatedSubject.id, requestId };
63
+ }
64
+ return { kind: "anonymous", id: "", requestId };
65
+ }
66
+ //# sourceMappingURL=compose-subject-to-audit-actor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-subject-to-audit-actor.js","sourceRoot":"","sources":["../../../src/lib/actor/compose-subject-to-audit-actor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,0DAA0D;AAC1D,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAaxC;;;;;GAKG;AACH,MAAM,UAAU,0BAA0B,CACxC,mBAA8D,EAC9D,eAE2B;IAE3B,MAAM,YAAY,GAAG,IAAI,GAAG,CAA0B;QACpD,GAAG,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC;QACtC,CAAC,iBAAiB,EAAE,SAAS,CAAC;KAC/B,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,EAAE;QACjB,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAC,OAAO,CAAC,CAAC;QAC5C,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAC5C,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;QAC7D,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,OAAO,mBAAmB,CAAC,EAAE,oBAAoB,EAAE,SAAS,EAAE,CAAC,CAAC;QAClE,CAAC;QAED,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,CAAC;QAC9D,OAAO,QAAQ,KAAK,SAAS;YAC3B,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC;YAC/B,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACzB,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,SAAS,CAAC,QAAyB;IAC1C,MAAM,EAAE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAC;IAC9D,MAAM,cAAc,GAClB,oBAAoB,EAAE,IAAI,KAAK,iBAAiB;QAChD,OAAO,CAAC,EAAE,KAAK,oBAAoB,CAAC,EAAE,CAAC;IACzC,OAAO,cAAc;QACnB,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE;QAC7C,CAAC,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAAC,KAG5B;IACC,MAAM,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,KAAK,CAAC;IAClD,IAAI,oBAAoB,EAAE,IAAI,KAAK,iBAAiB,EAAE,CAAC;QACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,oBAAoB,CAAC,EAAE,EAAE,SAAS,EAAE,CAAC;IAClE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;AAClD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { type AuditSettings } from "@dads-framework/plugin";
2
+ import { type AssembledAudit, type ComposeAuditDeps } from "./compose-audit.js";
3
+ import type { AuditLogReader } from "./database/readers/audit-log-reader.interface.js";
4
+ import type { RequestLogReader } from "./database/readers/request-log-reader.interface.js";
5
+ type AuditRetention = Pick<ComposeAuditDeps, "requestLogRetentionDays" | "clientDiagnosticsRetentionDays">;
6
+ export type AuditPluginOptions = AuditRetention & AuditSettings;
7
+ export type AuditServices = {
8
+ readonly auditLog: AuditLogReader;
9
+ readonly requestLog: RequestLogReader;
10
+ };
11
+ type AuditPluginRuntime = AuditServices & AssembledAudit;
12
+ export declare const auditDepsService: import("@dads-framework/plugin").Service<"audit-dependencies", Omit<ComposeAuditDeps, "clientDiagnosticsRetentionDays" | "requestLogRetentionDays">>;
13
+ export declare const auditService: import("@dads-framework/plugin").Service<"audit", AuditServices>;
14
+ /** Declare the audit policy once, then select routes and jobs independently. */
15
+ export declare function createAuditPlugin(options: AuditPluginOptions): {
16
+ audit: import("@dads-framework/plugin").Plugin<"audit", "service:audit-dependencies", AuditPluginRuntime, never, never, never, "audit", never>;
17
+ routes: import("@dads-framework/plugin").Plugin<"audit-routes", "plugin:audit", undefined, import("@dads-framework/http").HttpRoute, never, never, never, never>;
18
+ jobs: import("@dads-framework/plugin").Plugin<"audit-jobs", "plugin:audit", undefined, never, import("@dads-framework/job-queue-core").JobDefinition, never, never, never>;
19
+ };
20
+ export {};
21
+ //# sourceMappingURL=audit-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-plugin.d.ts","sourceRoot":"","sources":["../../src/lib/audit-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAGvF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oDAAoD,CAAC;AAE3F,KAAK,cAAc,GAAG,IAAI,CACxB,gBAAgB,EAChB,yBAAyB,GAAG,gCAAgC,CAC7D,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,GAAG,aAAa,CAAC;AAEhE,MAAM,MAAM,aAAa,GAAG;IAC1B,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;CACvC,CAAC;AAEF,KAAK,kBAAkB,GAAG,aAAa,GAAG,cAAc,CAAC;AAEzD,eAAO,MAAM,gBAAgB,sJAGxB,CAAC;AAEN,eAAO,MAAM,YAAY,kEAAiD,CAAC;AAE3E,gFAAgF;AAChF,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB;;;;EA6D5D"}
@@ -0,0 +1,61 @@
1
+ import { fileURLToPath } from "node:url";
2
+ import { definePlugin, defineService, } from "@dads-framework/plugin";
3
+ import { composeAudit, } from "./compose-audit.js";
4
+ import { AUDIT_TRIGGER_ALLOWLIST } from "./database/audit-trigger-allowlist.js";
5
+ import { DrizzleAuditLogReader } from "./database/readers/drizzle-audit-log-reader.js";
6
+ import { DrizzleRequestLogReader } from "./database/readers/drizzle-request-log-reader.js";
7
+ export const auditDepsService = defineService("audit-dependencies").ofType();
8
+ export const auditService = defineService("audit").ofType();
9
+ /** Declare the audit policy once, then select routes and jobs independently. */
10
+ export function createAuditPlugin(options) {
11
+ const { requestLogRetentionDays, clientDiagnosticsRetentionDays } = options;
12
+ const audit = definePlugin({
13
+ name: "audit",
14
+ requires: [auditDepsService],
15
+ implements: auditService,
16
+ contributes: {
17
+ audit: {
18
+ untrackedTables: [
19
+ ...AUDIT_TRIGGER_ALLOWLIST,
20
+ ...(options.untrackedTables ?? []),
21
+ ],
22
+ scopes: (options.scopes ?? []).map(({ table, columns }) => ({
23
+ table,
24
+ columns: { ...columns },
25
+ })),
26
+ },
27
+ migrations: [
28
+ {
29
+ directory: fileURLToPath(new URL("../../src/lib/database/migrations/", import.meta.url)),
30
+ },
31
+ ],
32
+ },
33
+ setup: ({ use }) => {
34
+ const deps = use(auditDepsService);
35
+ const runtime = {
36
+ ...composeAudit({
37
+ ...deps,
38
+ requestLogRetentionDays,
39
+ clientDiagnosticsRetentionDays,
40
+ }),
41
+ auditLog: new DrizzleAuditLogReader(deps.db),
42
+ requestLog: new DrizzleRequestLogReader(deps.db),
43
+ };
44
+ return { provides: runtime };
45
+ },
46
+ });
47
+ return {
48
+ audit,
49
+ routes: definePlugin({
50
+ name: "audit-routes",
51
+ requires: [audit],
52
+ setup: ({ use }) => ({ routes: use(audit).routes }),
53
+ }),
54
+ jobs: definePlugin({
55
+ name: "audit-jobs",
56
+ requires: [audit],
57
+ setup: ({ use }) => ({ jobs: use(audit).jobs }),
58
+ }),
59
+ };
60
+ }
61
+ //# sourceMappingURL=audit-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit-plugin.js","sourceRoot":"","sources":["../../src/lib/audit-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EACL,YAAY,EACZ,aAAa,GAEd,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,YAAY,GAGb,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAEhF,OAAO,EAAE,qBAAqB,EAAE,MAAM,gDAAgD,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,kDAAkD,CAAC;AAiB3F,MAAM,CAAC,MAAM,gBAAgB,GAC3B,aAAa,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAEvC,CAAC;AAEN,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,EAAiB,CAAC;AAE3E,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,EAAE,uBAAuB,EAAE,8BAA8B,EAAE,GAAG,OAAO,CAAC;IAC5E,MAAM,KAAK,GAAG,YAAY,CAQxB;QACA,IAAI,EAAE,OAAO;QACb,QAAQ,EAAE,CAAC,gBAAgB,CAAC;QAC5B,UAAU,EAAE,YAAY;QACxB,WAAW,EAAE;YACX,KAAK,EAAE;gBACL,eAAe,EAAE;oBACf,GAAG,uBAAuB;oBAC1B,GAAG,CAAC,OAAO,CAAC,eAAe,IAAI,EAAE,CAAC;iBACnC;gBACD,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;oBAC1D,KAAK;oBACL,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE;iBACxB,CAAC,CAAC;aACJ;YACD,UAAU,EAAE;gBACV;oBACE,SAAS,EAAE,aAAa,CACtB,IAAI,GAAG,CAAC,oCAAoC,EAAE,OAAO,IAAI,CAAC,GAAG,CAAC,CAC/D;iBACF;aACF;SACF;QACD,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE;YACjB,MAAM,IAAI,GAAG,GAAG,CAAC,gBAAgB,CAAC,CAAC;YACnC,MAAM,OAAO,GAAuB;gBAClC,GAAG,YAAY,CAAC;oBACd,GAAG,IAAI;oBACP,uBAAuB;oBACvB,8BAA8B;iBAC/B,CAAC;gBACF,QAAQ,EAAE,IAAI,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC5C,UAAU,EAAE,IAAI,uBAAuB,CAAC,IAAI,CAAC,EAAE,CAAC;aACjD,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;QAC/B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,KAAK;QACL,MAAM,EAAE,YAAY,CAAC;YACnB,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;SACpD,CAAC;QACF,IAAI,EAAE,YAAY,CAAC;YACjB,IAAI,EAAE,YAAY;YAClB,QAAQ,EAAE,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;SAChD,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { z } from "zod";
2
+ /** The kit mints this on report (never client-supplied — see `clientDiagnosticRow`). */
3
+ export declare const clientDiagnosticEventIdSchema: z.core.$ZodBranded<z.ZodUUID, "ClientDiagnosticEventId", "out">;
4
+ export type ClientDiagnosticEventId = z.infer<typeof clientDiagnosticEventIdSchema>;
5
+ //# sourceMappingURL=client-diagnostic-event.ids.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostic-event.ids.d.ts","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostic-event.ids.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAI7B,wFAAwF;AACxF,eAAO,MAAM,6BAA6B,iEAGzC,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { entityIdSchema } from "@dads-framework/contract";
2
+ /** The kit mints this on report (never client-supplied — see `clientDiagnosticRow`). */
3
+ export const clientDiagnosticEventIdSchema = entityIdSchema("ClientDiagnosticEventId", "Client diagnostic event id");
4
+ //# sourceMappingURL=client-diagnostic-event.ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostic-event.ids.js","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostic-event.ids.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,wFAAwF;AACxF,MAAM,CAAC,MAAM,6BAA6B,GAAG,cAAc,CACzD,yBAAyB,EACzB,4BAA4B,CAC7B,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The handler behind the report route.
3
+ *
4
+ * It reads the actor out of the request's own audit context rather than off
5
+ * the body: the route is public, so identity on the wire is a claim, and the
6
+ * context is what the server actually established. An anonymous report is
7
+ * recorded as anonymous rather than refused — a fault on the login page is
8
+ * exactly the kind this exists to hear about.
9
+ */
10
+ import type { ReportClientDiagnosticsBody } from "@dads-framework/contract";
11
+ import type { RecordClientDiagnostics } from "./record-client-diagnostics.js";
12
+ /** What the handler needs from the request; `unknown` bodies never reach it. */
13
+ export type ClientDiagnosticsRequest = {
14
+ readonly body: ReportClientDiagnosticsBody;
15
+ };
16
+ export declare class ClientDiagnosticsRouteHandlers {
17
+ private readonly recorder;
18
+ constructor(recorder: RecordClientDiagnostics);
19
+ reportClientDiagnostics(request: ClientDiagnosticsRequest): Promise<{
20
+ readonly accepted: number;
21
+ }>;
22
+ }
23
+ //# sourceMappingURL=client-diagnostics.route-handlers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostics.route-handlers.d.ts","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostics.route-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAE9E,gFAAgF;AAChF,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,CAAC,IAAI,EAAE,2BAA2B,CAAC;CAC5C,CAAC;AAEF,qBAAa,8BAA8B;IAC7B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAArC,YAA6B,QAAQ,EAAE,uBAAuB,EAAI;IAE5D,uBAAuB,CAC3B,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CASxC;CACF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The handler behind the report route.
3
+ *
4
+ * It reads the actor out of the request's own audit context rather than off
5
+ * the body: the route is public, so identity on the wire is a claim, and the
6
+ * context is what the server actually established. An anonymous report is
7
+ * recorded as anonymous rather than refused — a fault on the login page is
8
+ * exactly the kind this exists to hear about.
9
+ */
10
+ import { currentAuditActor } from "@dads-framework/audit-actor";
11
+ export class ClientDiagnosticsRouteHandlers {
12
+ recorder;
13
+ constructor(recorder) {
14
+ this.recorder = recorder;
15
+ }
16
+ async reportClientDiagnostics(request) {
17
+ const actor = currentAuditActor();
18
+ return this.recorder.execute({
19
+ events: request.body.events,
20
+ actor: {
21
+ kind: actor?.kind ?? "anonymous",
22
+ id: actor?.id ?? "",
23
+ },
24
+ });
25
+ }
26
+ }
27
+ //# sourceMappingURL=client-diagnostics.route-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostics.route-handlers.js","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostics.route-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAUhE,MAAM,OAAO,8BAA8B;IACZ,QAAQ;IAArC,YAA6B,QAAiC;wBAAjC,QAAQ;IAA4B,CAAC;IAElE,KAAK,CAAC,uBAAuB,CAC3B,OAAiC;QAEjC,MAAM,KAAK,GAAG,iBAAiB,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC3B,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM;YAC3B,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK,EAAE,IAAI,IAAI,WAAW;gBAChC,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE;aACpB;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The one route a client reports a fault through.
3
+ *
4
+ * **Public on purpose.** The failures worth hearing about most are the ones
5
+ * that happen before or instead of a session: a login page that threw, a
6
+ * bundle that would not load, a router that could not reach the first screen.
7
+ * A route requiring a session would be deaf to exactly those.
8
+ *
9
+ * What makes a public write acceptable here is that it is bounded in every
10
+ * direction rather than trusted in any: the contract caps the batch and every
11
+ * field inside it, the body limit caps the request, the identity on the row
12
+ * is the server's own and never the report's, and the answer is a count
13
+ * rather than anything a caller could treat as a resource it owns.
14
+ */
15
+ import { type HttpRoute } from "@dads-framework/http";
16
+ import type { ClientDiagnosticsRouteHandlers } from "./client-diagnostics.route-handlers.js";
17
+ export declare function createClientDiagnosticsRoutes(handlers: ClientDiagnosticsRouteHandlers): HttpRoute[];
18
+ //# sourceMappingURL=client-diagnostics.routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostics.routes.d.ts","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostics.routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAIL,KAAK,SAAS,EACf,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAE7F,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,8BAA8B,GACvC,SAAS,EAAE,CAwBb"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * The one route a client reports a fault through.
3
+ *
4
+ * **Public on purpose.** The failures worth hearing about most are the ones
5
+ * that happen before or instead of a session: a login page that threw, a
6
+ * bundle that would not load, a router that could not reach the first screen.
7
+ * A route requiring a session would be deaf to exactly those.
8
+ *
9
+ * What makes a public write acceptable here is that it is bounded in every
10
+ * direction rather than trusted in any: the contract caps the batch and every
11
+ * field inside it, the body limit caps the request, the identity on the row
12
+ * is the server's own and never the report's, and the answer is a count
13
+ * rather than anything a caller could treat as a resource it owns.
14
+ */
15
+ import { postRoute, publicAccess, routeGroup, } from "@dads-framework/http";
16
+ import { reportClientDiagnosticsBodySchema, reportedClientDiagnosticsSchema, } from "@dads-framework/contract";
17
+ export function createClientDiagnosticsRoutes(handlers) {
18
+ // Bound here rather than in the handler module: handler modules hold
19
+ // methods in the route declaration, and a method handed to the
20
+ // router as a value would arrive without its `this`.
21
+ const reportClientDiagnostics = handlers.reportClientDiagnostics.bind(handlers);
22
+ return routeGroup("Client diagnostics", [
23
+ postRoute({
24
+ path: "/client-diagnostics",
25
+ summary: "Report faults a client hit that never became a request",
26
+ access: publicAccess(),
27
+ resourcePolicy: {
28
+ kind: "resource-free",
29
+ purpose: "append-only-telemetry",
30
+ },
31
+ body: reportClientDiagnosticsBodySchema,
32
+ response: reportedClientDiagnosticsSchema,
33
+ // 200, not 202: the batch is stored before the answer, and the answer
34
+ // says how many rows landed. `postRoute` admits 200 or 201, and 201
35
+ // would claim a resource the client has no way to address.
36
+ status: 200,
37
+ handler: reportClientDiagnostics,
38
+ }),
39
+ ]);
40
+ }
41
+ //# sourceMappingURL=client-diagnostics.routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostics.routes.js","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/client-diagnostics.routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,GAEX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,0BAA0B,CAAC;AAIlC,MAAM,UAAU,6BAA6B,CAC3C,QAAwC;IAExC,qEAAqE;IACrE,+DAA+D;IAC/D,qDAAqD;IACrD,MAAM,uBAAuB,GAC3B,QAAQ,CAAC,uBAAuB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO,UAAU,CAAC,oBAAoB,EAAE;QACtC,SAAS,CAAC;YACR,IAAI,EAAE,qBAAqB;YAC3B,OAAO,EAAE,wDAAwD;YACjE,MAAM,EAAE,YAAY,EAAE;YACtB,cAAc,EAAE;gBACd,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,uBAAuB;aACjC;YACD,IAAI,EAAE,iCAAiC;YACvC,QAAQ,EAAE,+BAA+B;YACzC,sEAAsE;YACtE,oEAAoE;YACpE,2DAA2D;YAC3D,MAAM,EAAE,GAAG;YACX,OAAO,EAAE,uBAAuB;SACjC,CAAC;KACH,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * One reported fault, as the table wants it.
3
+ *
4
+ * Pure on purpose: everything this decides is a rule about trust, and a rule
5
+ * about trust should be provable without a database. Three of them live here.
6
+ *
7
+ * - **The actor is the server's, never the client's.** A report arrives on a
8
+ * public route, so anything it claims about identity is a claim. The actor
9
+ * comes from the request's own context, which is why it is a parameter and
10
+ * not a field of the event.
11
+ * - **`occurredAt` is the client's clock and is kept as such.** It is useful
12
+ * (it orders a burst) and untrustworthy (a device can be hours out), so it
13
+ * is stored beside `recorded_at` rather than instead of it.
14
+ * - **The id is minted here.** A client-supplied id would let one page
15
+ * overwrite another's row, or collide on purpose.
16
+ */
17
+ import type { ClientDiagnosticEvent } from "@dads-framework/contract";
18
+ import type { ClientDiagnosticRow } from "../../database/writers/client-diagnostic-writer.interface.js";
19
+ import type { ClientDiagnosticEventId } from "../client-diagnostic-event.ids.js";
20
+ /** What the request knows that the report does not get to claim. */
21
+ export type ReportingActor = {
22
+ readonly kind: string;
23
+ readonly id: string;
24
+ };
25
+ export declare function clientDiagnosticRow(input: {
26
+ readonly event: ClientDiagnosticEvent;
27
+ readonly actor: ReportingActor;
28
+ readonly id: ClientDiagnosticEventId;
29
+ }): ClientDiagnosticRow;
30
+ //# sourceMappingURL=client-diagnostic-row.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostic-row.d.ts","sourceRoot":"","sources":["../../../../src/lib/client-diagnostics/logic/client-diagnostic-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8DAA8D,CAAC;AACxG,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAEjF,oEAAoE;AACpE,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,KAAK,EAAE,qBAAqB,CAAC;IACtC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,EAAE,uBAAuB,CAAC;CACtC,GAAG,mBAAmB,CAqBtB"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * One reported fault, as the table wants it.
3
+ *
4
+ * Pure on purpose: everything this decides is a rule about trust, and a rule
5
+ * about trust should be provable without a database. Three of them live here.
6
+ *
7
+ * - **The actor is the server's, never the client's.** A report arrives on a
8
+ * public route, so anything it claims about identity is a claim. The actor
9
+ * comes from the request's own context, which is why it is a parameter and
10
+ * not a field of the event.
11
+ * - **`occurredAt` is the client's clock and is kept as such.** It is useful
12
+ * (it orders a burst) and untrustworthy (a device can be hours out), so it
13
+ * is stored beside `recorded_at` rather than instead of it.
14
+ * - **The id is minted here.** A client-supplied id would let one page
15
+ * overwrite another's row, or collide on purpose.
16
+ */
17
+ export function clientDiagnosticRow(input) {
18
+ const { event } = input;
19
+ return {
20
+ id: input.id,
21
+ occurredAt: new Date(event.occurredAt),
22
+ fingerprint: event.fingerprint,
23
+ kind: event.kind,
24
+ severity: event.severity,
25
+ name: event.name,
26
+ message: event.message,
27
+ frames: event.frames,
28
+ breadcrumbs: event.breadcrumbs,
29
+ release: event.release,
30
+ // The envelope's own statement of which client it is; `unknown` when the
31
+ // report carried no context, which a very early failure legitimately may.
32
+ client: event.context?.client ?? "unknown",
33
+ requestId: event.requestId ?? null,
34
+ actorKind: input.actor.kind,
35
+ actorId: input.actor.id,
36
+ context: event.context ?? null,
37
+ };
38
+ }
39
+ //# sourceMappingURL=client-diagnostic-row.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-diagnostic-row.js","sourceRoot":"","sources":["../../../../src/lib/client-diagnostics/logic/client-diagnostic-row.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,MAAM,UAAU,mBAAmB,CAAC,KAInC;IACC,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IACxB,OAAO;QACL,EAAE,EAAE,KAAK,CAAC,EAAE;QACZ,UAAU,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;QACtC,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,QAAQ,EAAE,KAAK,CAAC,QAAQ;QACxB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,WAAW,EAAE,KAAK,CAAC,WAAW;QAC9B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,yEAAyE;QACzE,0EAA0E;QAC1E,MAAM,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,IAAI,SAAS;QAC1C,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,IAAI;QAClC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI;QAC3B,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE;QACvB,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Store a batch of reported client faults.
3
+ *
4
+ * The one rule worth stating at this level: **recording a fault may never
5
+ * become a second fault.** A client reporting an error is already having a bad
6
+ * time, and a report that fails to store must not answer 500 and invite a
7
+ * retry loop that reports the failure to report. The route answers with how
8
+ * many rows were stored; a storage failure is logged here and reported as
9
+ * zero accepted.
10
+ */
11
+ import type { ClientDiagnosticEvent } from "@dads-framework/contract";
12
+ import type { ClientDiagnosticWriter } from "../database/writers/client-diagnostic-writer.interface.js";
13
+ import { type ReportingActor } from "./logic/client-diagnostic-row.js";
14
+ /** The narrow logger this needs; the kit never holds a whole pino instance. */
15
+ export type ClientDiagnosticsLog = {
16
+ error(entry: object, message: string): void;
17
+ };
18
+ export declare class RecordClientDiagnostics {
19
+ private readonly writer;
20
+ private readonly log;
21
+ constructor(writer: ClientDiagnosticWriter, log: ClientDiagnosticsLog);
22
+ execute(input: {
23
+ readonly events: readonly ClientDiagnosticEvent[];
24
+ readonly actor: ReportingActor;
25
+ }): Promise<{
26
+ readonly accepted: number;
27
+ }>;
28
+ }
29
+ //# sourceMappingURL=record-client-diagnostics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-client-diagnostics.d.ts","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/record-client-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2DAA2D,CAAC;AAExG,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,kCAAkC,CAAC;AAE1C,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7C,CAAC;AAEF,qBAAa,uBAAuB;IAEhC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAFtB,YACmB,MAAM,EAAE,sBAAsB,EAC9B,GAAG,EAAE,oBAAoB,EACxC;IAEE,OAAO,CAAC,KAAK,EAAE;QACnB,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;QAClD,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;KAChC,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAqBzC;CACF"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Store a batch of reported client faults.
3
+ *
4
+ * The one rule worth stating at this level: **recording a fault may never
5
+ * become a second fault.** A client reporting an error is already having a bad
6
+ * time, and a report that fails to store must not answer 500 and invite a
7
+ * retry loop that reports the failure to report. The route answers with how
8
+ * many rows were stored; a storage failure is logged here and reported as
9
+ * zero accepted.
10
+ */
11
+ import { mintEntityId } from "@dads-framework/contract";
12
+ import { clientDiagnosticEventIdSchema } from "./client-diagnostic-event.ids.js";
13
+ import { clientDiagnosticRow, } from "./logic/client-diagnostic-row.js";
14
+ export class RecordClientDiagnostics {
15
+ writer;
16
+ log;
17
+ constructor(writer, log) {
18
+ this.writer = writer;
19
+ this.log = log;
20
+ }
21
+ async execute(input) {
22
+ const rows = input.events.map((event) => clientDiagnosticRow({
23
+ event,
24
+ actor: input.actor,
25
+ id: mintEntityId(clientDiagnosticEventIdSchema),
26
+ }));
27
+ try {
28
+ return { accepted: await this.writer.record(rows) };
29
+ }
30
+ catch (error) {
31
+ this.log.error({
32
+ event: "client-diagnostics.store-failed",
33
+ err: error,
34
+ events: rows.length,
35
+ }, "client diagnostics could not be stored");
36
+ return { accepted: 0 };
37
+ }
38
+ }
39
+ }
40
+ //# sourceMappingURL=record-client-diagnostics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"record-client-diagnostics.js","sourceRoot":"","sources":["../../../src/lib/client-diagnostics/record-client-diagnostics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIxD,OAAO,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACjF,OAAO,EACL,mBAAmB,GAEpB,MAAM,kCAAkC,CAAC;AAO1C,MAAM,OAAO,uBAAuB;IAEf,MAAM;IACN,GAAG;IAFtB,YACmB,MAA8B,EAC9B,GAAyB;sBADzB,MAAM;mBACN,GAAG;IACnB,CAAC;IAEJ,KAAK,CAAC,OAAO,CAAC,KAGb;QACC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACtC,mBAAmB,CAAC;YAClB,KAAK;YACL,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,EAAE,EAAE,YAAY,CAAC,6BAA6B,CAAC;SAChD,CAAC,CACH,CAAC;QACF,IAAI,CAAC;YACH,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;QACtD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,GAAG,CAAC,KAAK,CACZ;gBACE,KAAK,EAAE,iCAAiC;gBACxC,GAAG,EAAE,KAAK;gBACV,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB,EACD,wCAAwC,CACzC,CAAC;YACF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,27 @@
1
+ import type { Clock } from "@dads-framework/clock";
2
+ import type { HttpRoute } from "@dads-framework/http";
3
+ import type { JobDefinition, JobLog } from "@dads-framework/job-queue";
4
+ import type { DrizzleHandle } from "@dads-framework/postgres";
5
+ export type ComposeAuditDeps = {
6
+ readonly db: DrizzleHandle;
7
+ readonly clock: Clock;
8
+ readonly log: JobLog;
9
+ /** Days a `request_log` row survives before the daily prune job deletes it. */
10
+ readonly requestLogRetentionDays: number;
11
+ /** Days a reported client fault survives; shorter, because messages are free text. */
12
+ readonly clientDiagnosticsRetentionDays: number;
13
+ };
14
+ export type AssembledAudit = {
15
+ readonly jobs: readonly JobDefinition[];
16
+ readonly routes: readonly HttpRoute[];
17
+ };
18
+ /**
19
+ * Assembles the application's request retention, diagnostics retention, and
20
+ * diagnostic reporting route using its database, clock, and log.
21
+ *
22
+ * The client-diagnostics route lives here rather than in a domain because
23
+ * what it stores is the browser-side sibling of `request_log` — diagnostic
24
+ * exhaust with a retention clock, not any domain's business history.
25
+ */
26
+ export declare function composeAudit(deps: ComposeAuditDeps): AssembledAudit;
27
+ //# sourceMappingURL=compose-audit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose-audit.d.ts","sourceRoot":"","sources":["../../src/lib/compose-audit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAU9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,EAAE,aAAa,CAAC;IAC3B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,+EAA+E;IAC/E,QAAQ,CAAC,uBAAuB,EAAE,MAAM,CAAC;IACzC,sFAAsF;IACtF,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAC;CACjD,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,IAAI,EAAE,SAAS,aAAa,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;CACvC,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,gBAAgB,GAAG,cAAc,CAuBnE"}