@parmana/shared 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 (417) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +8 -0
  3. package/README.md +16 -2
  4. package/dist/.tsbuildinfo +1 -0
  5. package/dist/config/ApiKeyEntry.d.ts +97 -0
  6. package/dist/config/ApiKeyEntry.d.ts.map +1 -0
  7. package/dist/config/ApiKeyEntry.js +2 -0
  8. package/dist/config/ApiKeyEntry.js.map +1 -0
  9. package/dist/config/Config.d.ts +202 -0
  10. package/dist/config/Config.d.ts.map +1 -0
  11. package/dist/config/Config.js +172 -0
  12. package/dist/config/Config.js.map +1 -0
  13. package/dist/config/ConfigLoader.d.ts +5 -0
  14. package/dist/config/ConfigLoader.d.ts.map +1 -0
  15. package/dist/config/ConfigLoader.js +8 -0
  16. package/dist/config/ConfigLoader.js.map +1 -0
  17. package/dist/config/ConfigUtils.d.ts +6 -0
  18. package/dist/config/ConfigUtils.d.ts.map +1 -0
  19. package/dist/config/ConfigUtils.js +8 -0
  20. package/dist/config/ConfigUtils.js.map +1 -0
  21. package/dist/config/ConfigValidation.d.ts +30 -0
  22. package/dist/config/ConfigValidation.d.ts.map +1 -0
  23. package/dist/config/ConfigValidation.js +170 -0
  24. package/dist/config/ConfigValidation.js.map +1 -0
  25. package/dist/config/CryptoAlgorithms.d.ts +42 -0
  26. package/dist/config/CryptoAlgorithms.d.ts.map +1 -0
  27. package/dist/config/CryptoAlgorithms.js +42 -0
  28. package/dist/config/CryptoAlgorithms.js.map +1 -0
  29. package/dist/config/KeyProviders.d.ts +9 -0
  30. package/dist/config/KeyProviders.d.ts.map +1 -0
  31. package/dist/config/KeyProviders.js +8 -0
  32. package/dist/config/KeyProviders.js.map +1 -0
  33. package/dist/config/SecretsProviders.d.ts +6 -0
  34. package/dist/config/SecretsProviders.d.ts.map +1 -0
  35. package/dist/config/SecretsProviders.js +5 -0
  36. package/dist/config/SecretsProviders.js.map +1 -0
  37. package/dist/config/StorageProviders.d.ts +18 -0
  38. package/dist/config/StorageProviders.d.ts.map +1 -0
  39. package/dist/config/StorageProviders.js +20 -0
  40. package/dist/config/StorageProviders.js.map +1 -0
  41. package/dist/config/TrustProfiles.d.ts +5 -0
  42. package/dist/config/TrustProfiles.d.ts.map +1 -0
  43. package/dist/config/TrustProfiles.js +4 -0
  44. package/dist/config/TrustProfiles.js.map +1 -0
  45. package/dist/config/index.d.ts +11 -0
  46. package/dist/config/index.d.ts.map +1 -0
  47. package/dist/config/index.js +11 -0
  48. package/dist/config/index.js.map +1 -0
  49. package/dist/domain/approval-artifact.d.ts +136 -0
  50. package/dist/domain/approval-artifact.d.ts.map +1 -0
  51. package/dist/domain/approval-artifact.js +2 -0
  52. package/dist/domain/approval-artifact.js.map +1 -0
  53. package/dist/domain/approval-issuer.d.ts +52 -0
  54. package/dist/domain/approval-issuer.d.ts.map +1 -0
  55. package/dist/domain/approval-issuer.js +2 -0
  56. package/dist/domain/approval-issuer.js.map +1 -0
  57. package/dist/domain/authority-grant.d.ts +54 -0
  58. package/dist/domain/authority-grant.d.ts.map +1 -0
  59. package/dist/domain/authority-grant.js +2 -0
  60. package/dist/domain/authority-grant.js.map +1 -0
  61. package/dist/domain/authority.d.ts +42 -0
  62. package/dist/domain/authority.d.ts.map +1 -0
  63. package/dist/domain/authority.js +11 -0
  64. package/dist/domain/authority.js.map +1 -0
  65. package/dist/domain/authorization.d.ts +54 -0
  66. package/dist/domain/authorization.d.ts.map +1 -0
  67. package/dist/domain/authorization.js +2 -0
  68. package/dist/domain/authorization.js.map +1 -0
  69. package/dist/domain/business-signal-source.d.ts +52 -0
  70. package/dist/domain/business-signal-source.d.ts.map +1 -0
  71. package/dist/domain/business-signal-source.js +2 -0
  72. package/dist/domain/business-signal-source.js.map +1 -0
  73. package/dist/domain/business-transaction.d.ts +99 -0
  74. package/dist/domain/business-transaction.d.ts.map +1 -0
  75. package/dist/domain/business-transaction.js +16 -0
  76. package/dist/domain/business-transaction.js.map +1 -0
  77. package/dist/domain/business-validation.d.ts +177 -0
  78. package/dist/domain/business-validation.d.ts.map +1 -0
  79. package/dist/domain/business-validation.js +60 -0
  80. package/dist/domain/business-validation.js.map +1 -0
  81. package/dist/domain/challenge-record.d.ts +181 -0
  82. package/dist/domain/challenge-record.d.ts.map +1 -0
  83. package/dist/domain/challenge-record.js +2 -0
  84. package/dist/domain/challenge-record.js.map +1 -0
  85. package/dist/domain/decision.d.ts +89 -0
  86. package/dist/domain/decision.d.ts.map +1 -0
  87. package/dist/domain/decision.js +9 -0
  88. package/dist/domain/decision.js.map +1 -0
  89. package/dist/domain/evidence-anchor.d.ts +54 -0
  90. package/dist/domain/evidence-anchor.d.ts.map +1 -0
  91. package/dist/domain/evidence-anchor.js +2 -0
  92. package/dist/domain/evidence-anchor.js.map +1 -0
  93. package/dist/domain/executable-content.d.ts +45 -0
  94. package/dist/domain/executable-content.d.ts.map +1 -0
  95. package/dist/domain/executable-content.js +39 -0
  96. package/dist/domain/executable-content.js.map +1 -0
  97. package/dist/domain/execution-audit-event.d.ts +65 -0
  98. package/dist/domain/execution-audit-event.d.ts.map +1 -0
  99. package/dist/domain/execution-audit-event.js +2 -0
  100. package/dist/domain/execution-audit-event.js.map +1 -0
  101. package/dist/domain/execution-authorization.d.ts +224 -0
  102. package/dist/domain/execution-authorization.d.ts.map +1 -0
  103. package/dist/domain/execution-authorization.js +2 -0
  104. package/dist/domain/execution-authorization.js.map +1 -0
  105. package/dist/domain/execution-evidence.d.ts +38 -0
  106. package/dist/domain/execution-evidence.d.ts.map +1 -0
  107. package/dist/domain/execution-evidence.js +2 -0
  108. package/dist/domain/execution-evidence.js.map +1 -0
  109. package/dist/domain/execution-intent.d.ts +92 -0
  110. package/dist/domain/execution-intent.d.ts.map +1 -0
  111. package/dist/domain/execution-intent.js +2 -0
  112. package/dist/domain/execution-intent.js.map +1 -0
  113. package/dist/domain/execution-metadata.d.ts +8 -0
  114. package/dist/domain/execution-metadata.d.ts.map +1 -0
  115. package/dist/domain/execution-metadata.js +2 -0
  116. package/dist/domain/execution-metadata.js.map +1 -0
  117. package/dist/domain/execution-outcome-store.d.ts +49 -0
  118. package/dist/domain/execution-outcome-store.d.ts.map +1 -0
  119. package/dist/domain/execution-outcome-store.js +10 -0
  120. package/dist/domain/execution-outcome-store.js.map +1 -0
  121. package/dist/domain/execution-result.d.ts +49 -0
  122. package/dist/domain/execution-result.d.ts.map +1 -0
  123. package/dist/domain/execution-result.js +2 -0
  124. package/dist/domain/execution-result.js.map +1 -0
  125. package/dist/domain/execution-trust-record.d.ts +142 -0
  126. package/dist/domain/execution-trust-record.d.ts.map +1 -0
  127. package/dist/domain/execution-trust-record.js +2 -0
  128. package/dist/domain/execution-trust-record.js.map +1 -0
  129. package/dist/domain/execution.d.ts +108 -0
  130. package/dist/domain/execution.d.ts.map +1 -0
  131. package/dist/domain/execution.js +18 -0
  132. package/dist/domain/execution.js.map +1 -0
  133. package/dist/domain/external-connector.d.ts +68 -0
  134. package/dist/domain/external-connector.d.ts.map +1 -0
  135. package/dist/domain/external-connector.js +2 -0
  136. package/dist/domain/external-connector.js.map +1 -0
  137. package/dist/domain/index.d.ts +37 -0
  138. package/dist/domain/index.d.ts.map +1 -0
  139. package/dist/domain/index.js +37 -0
  140. package/dist/domain/index.js.map +1 -0
  141. package/dist/domain/intent.d.ts +66 -0
  142. package/dist/domain/intent.d.ts.map +1 -0
  143. package/dist/domain/intent.js +2 -0
  144. package/dist/domain/intent.js.map +1 -0
  145. package/dist/domain/metadata.d.ts +53 -0
  146. package/dist/domain/metadata.d.ts.map +1 -0
  147. package/dist/domain/metadata.js +11 -0
  148. package/dist/domain/metadata.js.map +1 -0
  149. package/dist/domain/override.d.ts +39 -0
  150. package/dist/domain/override.d.ts.map +1 -0
  151. package/dist/domain/override.js +2 -0
  152. package/dist/domain/override.js.map +1 -0
  153. package/dist/domain/pending-policy-change.d.ts +109 -0
  154. package/dist/domain/pending-policy-change.d.ts.map +1 -0
  155. package/dist/domain/pending-policy-change.js +12 -0
  156. package/dist/domain/pending-policy-change.js.map +1 -0
  157. package/dist/domain/policy-change-approval-record.d.ts +81 -0
  158. package/dist/domain/policy-change-approval-record.d.ts.map +1 -0
  159. package/dist/domain/policy-change-approval-record.js +2 -0
  160. package/dist/domain/policy-change-approval-record.js.map +1 -0
  161. package/dist/domain/policy-change-step-up-authorization.d.ts +97 -0
  162. package/dist/domain/policy-change-step-up-authorization.d.ts.map +1 -0
  163. package/dist/domain/policy-change-step-up-authorization.js +2 -0
  164. package/dist/domain/policy-change-step-up-authorization.js.map +1 -0
  165. package/dist/domain/policy-reference.d.ts +58 -0
  166. package/dist/domain/policy-reference.d.ts.map +1 -0
  167. package/dist/domain/policy-reference.js +2 -0
  168. package/dist/domain/policy-reference.js.map +1 -0
  169. package/dist/domain/receipt.d.ts +72 -0
  170. package/dist/domain/receipt.d.ts.map +1 -0
  171. package/dist/domain/receipt.js +2 -0
  172. package/dist/domain/receipt.js.map +1 -0
  173. package/dist/domain/refusal-record.d.ts +110 -0
  174. package/dist/domain/refusal-record.d.ts.map +1 -0
  175. package/dist/domain/refusal-record.js +2 -0
  176. package/dist/domain/refusal-record.js.map +1 -0
  177. package/dist/domain/release-approval.d.ts +14 -0
  178. package/dist/domain/release-approval.d.ts.map +1 -0
  179. package/dist/domain/release-approval.js +2 -0
  180. package/dist/domain/release-approval.js.map +1 -0
  181. package/dist/domain/signals.d.ts +10 -0
  182. package/dist/domain/signals.d.ts.map +1 -0
  183. package/dist/domain/signals.js +2 -0
  184. package/dist/domain/signals.js.map +1 -0
  185. package/dist/domain/signature-entry.d.ts +23 -0
  186. package/dist/domain/signature-entry.d.ts.map +1 -0
  187. package/dist/domain/signature-entry.js +2 -0
  188. package/dist/domain/signature-entry.js.map +1 -0
  189. package/dist/domain/signature.d.ts +26 -0
  190. package/dist/domain/signature.d.ts.map +1 -0
  191. package/dist/domain/signature.js +2 -0
  192. package/dist/domain/signature.js.map +1 -0
  193. package/dist/domain/unsigned-execution-trust-record.d.ts +7 -0
  194. package/dist/domain/unsigned-execution-trust-record.d.ts.map +1 -0
  195. package/dist/domain/unsigned-execution-trust-record.js +2 -0
  196. package/dist/domain/unsigned-execution-trust-record.js.map +1 -0
  197. package/dist/domain/verification.d.ts +48 -0
  198. package/dist/domain/verification.d.ts.map +1 -0
  199. package/dist/domain/verification.js +9 -0
  200. package/dist/domain/verification.js.map +1 -0
  201. package/dist/errors/approval-issuer-change-not-found-error.d.ts +9 -0
  202. package/dist/errors/approval-issuer-change-not-found-error.d.ts.map +1 -0
  203. package/dist/errors/approval-issuer-change-not-found-error.js +11 -0
  204. package/dist/errors/approval-issuer-change-not-found-error.js.map +1 -0
  205. package/dist/errors/authority-grant-change-not-found-error.d.ts +9 -0
  206. package/dist/errors/authority-grant-change-not-found-error.d.ts.map +1 -0
  207. package/dist/errors/authority-grant-change-not-found-error.js +11 -0
  208. package/dist/errors/authority-grant-change-not-found-error.js.map +1 -0
  209. package/dist/errors/authority-required-error.d.ts +5 -0
  210. package/dist/errors/authority-required-error.d.ts.map +1 -0
  211. package/dist/errors/authority-required-error.js +7 -0
  212. package/dist/errors/authority-required-error.js.map +1 -0
  213. package/dist/errors/authorization-no-longer-valid-error.d.ts +19 -0
  214. package/dist/errors/authorization-no-longer-valid-error.d.ts.map +1 -0
  215. package/dist/errors/authorization-no-longer-valid-error.js +23 -0
  216. package/dist/errors/authorization-no-longer-valid-error.js.map +1 -0
  217. package/dist/errors/authorization-required-error.d.ts +5 -0
  218. package/dist/errors/authorization-required-error.d.ts.map +1 -0
  219. package/dist/errors/authorization-required-error.js +7 -0
  220. package/dist/errors/authorization-required-error.js.map +1 -0
  221. package/dist/errors/business-signal-source-change-not-found-error.d.ts +9 -0
  222. package/dist/errors/business-signal-source-change-not-found-error.d.ts.map +1 -0
  223. package/dist/errors/business-signal-source-change-not-found-error.js +11 -0
  224. package/dist/errors/business-signal-source-change-not-found-error.js.map +1 -0
  225. package/dist/errors/business-transaction-not-found-error.d.ts +5 -0
  226. package/dist/errors/business-transaction-not-found-error.d.ts.map +1 -0
  227. package/dist/errors/business-transaction-not-found-error.js +7 -0
  228. package/dist/errors/business-transaction-not-found-error.js.map +1 -0
  229. package/dist/errors/challenge-record-not-found-error.d.ts +9 -0
  230. package/dist/errors/challenge-record-not-found-error.d.ts.map +1 -0
  231. package/dist/errors/challenge-record-not-found-error.js +11 -0
  232. package/dist/errors/challenge-record-not-found-error.js.map +1 -0
  233. package/dist/errors/conflict-error.d.ts +5 -0
  234. package/dist/errors/conflict-error.d.ts.map +1 -0
  235. package/dist/errors/conflict-error.js +7 -0
  236. package/dist/errors/conflict-error.js.map +1 -0
  237. package/dist/errors/connector-not-registered-error.d.ts +21 -0
  238. package/dist/errors/connector-not-registered-error.d.ts.map +1 -0
  239. package/dist/errors/connector-not-registered-error.js +24 -0
  240. package/dist/errors/connector-not-registered-error.js.map +1 -0
  241. package/dist/errors/decision-not-approved-error.d.ts +5 -0
  242. package/dist/errors/decision-not-approved-error.d.ts.map +1 -0
  243. package/dist/errors/decision-not-approved-error.js +7 -0
  244. package/dist/errors/decision-not-approved-error.js.map +1 -0
  245. package/dist/errors/duplicate-business-transaction-error.d.ts +26 -0
  246. package/dist/errors/duplicate-business-transaction-error.d.ts.map +1 -0
  247. package/dist/errors/duplicate-business-transaction-error.js +28 -0
  248. package/dist/errors/duplicate-business-transaction-error.js.map +1 -0
  249. package/dist/errors/external-connector-change-not-found-error.d.ts +9 -0
  250. package/dist/errors/external-connector-change-not-found-error.d.ts.map +1 -0
  251. package/dist/errors/external-connector-change-not-found-error.js +11 -0
  252. package/dist/errors/external-connector-change-not-found-error.js.map +1 -0
  253. package/dist/errors/forbidden-error.d.ts +5 -0
  254. package/dist/errors/forbidden-error.d.ts.map +1 -0
  255. package/dist/errors/forbidden-error.js +7 -0
  256. package/dist/errors/forbidden-error.js.map +1 -0
  257. package/dist/errors/index.d.ts +30 -0
  258. package/dist/errors/index.d.ts.map +1 -0
  259. package/dist/errors/index.js +30 -0
  260. package/dist/errors/index.js.map +1 -0
  261. package/dist/errors/intent-required-error.d.ts +5 -0
  262. package/dist/errors/intent-required-error.d.ts.map +1 -0
  263. package/dist/errors/intent-required-error.js +7 -0
  264. package/dist/errors/intent-required-error.js.map +1 -0
  265. package/dist/errors/non-human-caller-denied-error.d.ts +10 -0
  266. package/dist/errors/non-human-caller-denied-error.d.ts.map +1 -0
  267. package/dist/errors/non-human-caller-denied-error.js +12 -0
  268. package/dist/errors/non-human-caller-denied-error.js.map +1 -0
  269. package/dist/errors/nonce-already-consumed-error.d.ts +26 -0
  270. package/dist/errors/nonce-already-consumed-error.d.ts.map +1 -0
  271. package/dist/errors/nonce-already-consumed-error.js +29 -0
  272. package/dist/errors/nonce-already-consumed-error.js.map +1 -0
  273. package/dist/errors/outcome-unknown-error.d.ts +15 -0
  274. package/dist/errors/outcome-unknown-error.d.ts.map +1 -0
  275. package/dist/errors/outcome-unknown-error.js +19 -0
  276. package/dist/errors/outcome-unknown-error.js.map +1 -0
  277. package/dist/errors/override-not-allowed-error.d.ts +5 -0
  278. package/dist/errors/override-not-allowed-error.d.ts.map +1 -0
  279. package/dist/errors/override-not-allowed-error.js +7 -0
  280. package/dist/errors/override-not-allowed-error.js.map +1 -0
  281. package/dist/errors/parmana-error.d.ts +15 -0
  282. package/dist/errors/parmana-error.d.ts.map +1 -0
  283. package/dist/errors/parmana-error.js +21 -0
  284. package/dist/errors/parmana-error.js.map +1 -0
  285. package/dist/errors/pending-policy-change-not-found-error.d.ts +9 -0
  286. package/dist/errors/pending-policy-change-not-found-error.d.ts.map +1 -0
  287. package/dist/errors/pending-policy-change-not-found-error.js +11 -0
  288. package/dist/errors/pending-policy-change-not-found-error.js.map +1 -0
  289. package/dist/errors/policy-not-found-error.d.ts +5 -0
  290. package/dist/errors/policy-not-found-error.d.ts.map +1 -0
  291. package/dist/errors/policy-not-found-error.js +7 -0
  292. package/dist/errors/policy-not-found-error.js.map +1 -0
  293. package/dist/errors/receipt-generation-error.d.ts +5 -0
  294. package/dist/errors/receipt-generation-error.d.ts.map +1 -0
  295. package/dist/errors/receipt-generation-error.js +7 -0
  296. package/dist/errors/receipt-generation-error.js.map +1 -0
  297. package/dist/errors/same-actor-cannot-approve-own-change-error.d.ts +12 -0
  298. package/dist/errors/same-actor-cannot-approve-own-change-error.d.ts.map +1 -0
  299. package/dist/errors/same-actor-cannot-approve-own-change-error.js +15 -0
  300. package/dist/errors/same-actor-cannot-approve-own-change-error.js.map +1 -0
  301. package/dist/errors/step-up-authorization-invalid-error.d.ts +25 -0
  302. package/dist/errors/step-up-authorization-invalid-error.d.ts.map +1 -0
  303. package/dist/errors/step-up-authorization-invalid-error.js +28 -0
  304. package/dist/errors/step-up-authorization-invalid-error.js.map +1 -0
  305. package/dist/errors/trust-chain-validation-error.d.ts +5 -0
  306. package/dist/errors/trust-chain-validation-error.d.ts.map +1 -0
  307. package/dist/errors/trust-chain-validation-error.js +7 -0
  308. package/dist/errors/trust-chain-validation-error.js.map +1 -0
  309. package/dist/errors/unauthorized-error.d.ts +5 -0
  310. package/dist/errors/unauthorized-error.d.ts.map +1 -0
  311. package/dist/errors/unauthorized-error.js +7 -0
  312. package/dist/errors/unauthorized-error.js.map +1 -0
  313. package/dist/errors/validation-error.d.ts +5 -0
  314. package/dist/errors/validation-error.d.ts.map +1 -0
  315. package/dist/errors/validation-error.js +7 -0
  316. package/dist/errors/validation-error.js.map +1 -0
  317. package/dist/errors/verification-failed-error.d.ts +5 -0
  318. package/dist/errors/verification-failed-error.d.ts.map +1 -0
  319. package/dist/errors/verification-failed-error.js +7 -0
  320. package/dist/errors/verification-failed-error.js.map +1 -0
  321. package/dist/gateway/GatewayAuthentication.d.ts +8 -0
  322. package/dist/gateway/GatewayAuthentication.d.ts.map +1 -0
  323. package/dist/gateway/GatewayAuthentication.js +2 -0
  324. package/dist/gateway/GatewayAuthentication.js.map +1 -0
  325. package/dist/gateway/GatewayAuthenticationClaims.d.ts +10 -0
  326. package/dist/gateway/GatewayAuthenticationClaims.d.ts.map +1 -0
  327. package/dist/gateway/GatewayAuthenticationClaims.js +2 -0
  328. package/dist/gateway/GatewayAuthenticationClaims.js.map +1 -0
  329. package/dist/gateway/GatewayAuthenticationPayload.d.ts +15 -0
  330. package/dist/gateway/GatewayAuthenticationPayload.d.ts.map +1 -0
  331. package/dist/gateway/GatewayAuthenticationPayload.js +2 -0
  332. package/dist/gateway/GatewayAuthenticationPayload.js.map +1 -0
  333. package/dist/gateway/SignedGatewayAuthentication.d.ts +9 -0
  334. package/dist/gateway/SignedGatewayAuthentication.d.ts.map +1 -0
  335. package/dist/gateway/SignedGatewayAuthentication.js +2 -0
  336. package/dist/gateway/SignedGatewayAuthentication.js.map +1 -0
  337. package/dist/gateway/index.d.ts +4 -0
  338. package/dist/gateway/index.d.ts.map +1 -0
  339. package/dist/gateway/index.js +4 -0
  340. package/dist/gateway/index.js.map +1 -0
  341. package/dist/index.d.ts +19 -0
  342. package/dist/index.d.ts.map +1 -0
  343. package/dist/index.js +19 -0
  344. package/dist/index.js.map +1 -0
  345. package/dist/logging/Logger.d.ts +65 -0
  346. package/dist/logging/Logger.d.ts.map +1 -0
  347. package/dist/logging/Logger.js +97 -0
  348. package/dist/logging/Logger.js.map +1 -0
  349. package/dist/network/externalEndpointAddress.d.ts +48 -0
  350. package/dist/network/externalEndpointAddress.d.ts.map +1 -0
  351. package/dist/network/externalEndpointAddress.js +147 -0
  352. package/dist/network/externalEndpointAddress.js.map +1 -0
  353. package/dist/repositories/approval-issuer-repository.d.ts +31 -0
  354. package/dist/repositories/approval-issuer-repository.d.ts.map +1 -0
  355. package/dist/repositories/approval-issuer-repository.js +2 -0
  356. package/dist/repositories/approval-issuer-repository.js.map +1 -0
  357. package/dist/repositories/authority-grant-repository.d.ts +22 -0
  358. package/dist/repositories/authority-grant-repository.d.ts.map +1 -0
  359. package/dist/repositories/authority-grant-repository.js +2 -0
  360. package/dist/repositories/authority-grant-repository.js.map +1 -0
  361. package/dist/repositories/business-signal-source-repository.d.ts +17 -0
  362. package/dist/repositories/business-signal-source-repository.d.ts.map +1 -0
  363. package/dist/repositories/business-signal-source-repository.js +2 -0
  364. package/dist/repositories/business-signal-source-repository.js.map +1 -0
  365. package/dist/repositories/business-transaction-repository.d.ts +34 -0
  366. package/dist/repositories/business-transaction-repository.d.ts.map +1 -0
  367. package/dist/repositories/business-transaction-repository.js +2 -0
  368. package/dist/repositories/business-transaction-repository.js.map +1 -0
  369. package/dist/repositories/challenge-record-repository.d.ts +67 -0
  370. package/dist/repositories/challenge-record-repository.d.ts.map +1 -0
  371. package/dist/repositories/challenge-record-repository.js +76 -0
  372. package/dist/repositories/challenge-record-repository.js.map +1 -0
  373. package/dist/repositories/execution-intent-repository.d.ts +38 -0
  374. package/dist/repositories/execution-intent-repository.d.ts.map +1 -0
  375. package/dist/repositories/execution-intent-repository.js +2 -0
  376. package/dist/repositories/execution-intent-repository.js.map +1 -0
  377. package/dist/repositories/execution-trust-record-repository.d.ts +62 -0
  378. package/dist/repositories/execution-trust-record-repository.d.ts.map +1 -0
  379. package/dist/repositories/execution-trust-record-repository.js +2 -0
  380. package/dist/repositories/execution-trust-record-repository.js.map +1 -0
  381. package/dist/repositories/external-connector-repository.d.ts +37 -0
  382. package/dist/repositories/external-connector-repository.d.ts.map +1 -0
  383. package/dist/repositories/external-connector-repository.js +2 -0
  384. package/dist/repositories/external-connector-repository.js.map +1 -0
  385. package/dist/repositories/handbook-download-lead-repository.d.ts +18 -0
  386. package/dist/repositories/handbook-download-lead-repository.d.ts.map +1 -0
  387. package/dist/repositories/handbook-download-lead-repository.js +2 -0
  388. package/dist/repositories/handbook-download-lead-repository.js.map +1 -0
  389. package/dist/repositories/index.d.ts +14 -0
  390. package/dist/repositories/index.d.ts.map +1 -0
  391. package/dist/repositories/index.js +14 -0
  392. package/dist/repositories/index.js.map +1 -0
  393. package/dist/repositories/pending-policy-change-repository.d.ts +72 -0
  394. package/dist/repositories/pending-policy-change-repository.d.ts.map +1 -0
  395. package/dist/repositories/pending-policy-change-repository.js +46 -0
  396. package/dist/repositories/pending-policy-change-repository.js.map +1 -0
  397. package/dist/repositories/policy-change-approval-record-repository.d.ts +39 -0
  398. package/dist/repositories/policy-change-approval-record-repository.d.ts.map +1 -0
  399. package/dist/repositories/policy-change-approval-record-repository.js +2 -0
  400. package/dist/repositories/policy-change-approval-record-repository.js.map +1 -0
  401. package/dist/repositories/policy-repository.d.ts +15 -0
  402. package/dist/repositories/policy-repository.d.ts.map +1 -0
  403. package/dist/repositories/policy-repository.js +2 -0
  404. package/dist/repositories/policy-repository.js.map +1 -0
  405. package/dist/repositories/refusal-record-repository.d.ts +13 -0
  406. package/dist/repositories/refusal-record-repository.d.ts.map +1 -0
  407. package/dist/repositories/refusal-record-repository.js +2 -0
  408. package/dist/repositories/refusal-record-repository.js.map +1 -0
  409. package/dist/types/Json.d.ts +7 -0
  410. package/dist/types/Json.d.ts.map +1 -0
  411. package/dist/types/Json.js +2 -0
  412. package/dist/types/Json.js.map +1 -0
  413. package/dist/utils/normalize-policy.d.ts +16 -0
  414. package/dist/utils/normalize-policy.d.ts.map +1 -0
  415. package/dist/utils/normalize-policy.js +10 -0
  416. package/dist/utils/normalize-policy.js.map +1 -0
  417. package/package.json +39 -4
@@ -0,0 +1,97 @@
1
+ import { loadConfig } from "../config/Config.js";
2
+ /**
3
+ * Minimal structured logger, gating output on LOG_LEVEL
4
+ * (config.logging.level, read in Config.ts).
5
+ *
6
+ * Closes a gap identified in the 2026-09-10 production-readiness pass:
7
+ * LOG_LEVEL was already read into config, but nothing in the codebase
8
+ * gated any output on it -- every console.* call site fired
9
+ * unconditionally regardless of what LOG_LEVEL was set to, and log
10
+ * shape was whatever each call site happened to pass (a bare string
11
+ * here, a structured object there). This gives every call site a
12
+ * shared, level-aware, structured shape without introducing an
13
+ * external logging dependency.
14
+ *
15
+ * Deliberately NOT a wholesale replacement for every console.* call in
16
+ * the codebase in one pass -- see the migrated call sites (this
17
+ * package's own consumers in packages/api/src/bootstrap/) for the
18
+ * pattern; remaining call sites can move to this incrementally.
19
+ */
20
+ const LEVELS = {
21
+ debug: 10,
22
+ info: 20,
23
+ warn: 30,
24
+ error: 40,
25
+ };
26
+ function isLogLevel(value) {
27
+ return value in LEVELS;
28
+ }
29
+ /**
30
+ * Resolves the configured minimum level. An unrecognized LOG_LEVEL
31
+ * value (typo, stale config) falls back to "info" rather than
32
+ * throwing -- logging configuration should never be able to crash
33
+ * startup; getting the level wrong just means slightly wrong log
34
+ * verbosity, not a refused boot.
35
+ */
36
+ function resolveMinLevel(configuredLevel) {
37
+ return isLogLevel(configuredLevel) ? configuredLevel : "info";
38
+ }
39
+ /**
40
+ * Creates a Logger gated on the given LOG_LEVEL string (pass
41
+ * loadConfig().logging.level at the call site -- this function takes
42
+ * the resolved string, not process.env, so it stays easy to test and
43
+ * has no implicit dependency on when Config.ts's own env read runs).
44
+ *
45
+ * Output shape: one JSON object per line to stdout (debug/info) or
46
+ * stderr (warn/error) -- level and a timestamp are added automatically,
47
+ * `event` (required) and any additional fields come from the call
48
+ * site, mirroring the { event: "...", ...details } shape most existing
49
+ * console.warn/console.error call sites in this codebase already use
50
+ * by convention, just enforced and level-gated here rather than ad hoc.
51
+ */
52
+ export function createLogger(configuredLevel) {
53
+ const minLevel = LEVELS[resolveMinLevel(configuredLevel)];
54
+ function log(level, fields) {
55
+ if (LEVELS[level] < minLevel) {
56
+ return;
57
+ }
58
+ const line = JSON.stringify({
59
+ level,
60
+ timestamp: new Date().toISOString(),
61
+ ...fields,
62
+ });
63
+ if (LEVELS[level] >= LEVELS.warn) {
64
+ console.error(line);
65
+ }
66
+ else {
67
+ console.log(line);
68
+ }
69
+ }
70
+ return {
71
+ debug: (fields) => log("debug", fields),
72
+ info: (fields) => log("info", fields),
73
+ warn: (fields) => log("warn", fields),
74
+ error: (fields) => log("error", fields),
75
+ };
76
+ }
77
+ let sharedLogger;
78
+ /**
79
+ * Lazy, process-wide singleton Logger, built from loadConfig().logging.
80
+ * level on first use -- the same lazy-singleton shape this codebase's
81
+ * other composition roots already use (KeyBootstrap.create(),
82
+ * CryptoBootstrap.create(), PostgresPoolFactory.create()). Exists so a
83
+ * call site can log without threading a Logger instance through every
84
+ * function signature between it and wherever the app is composed --
85
+ * `import { getLogger } from "@parmana/shared"; getLogger().warn(...)`.
86
+ *
87
+ * loadConfig() itself is only called the first time a call site
88
+ * actually logs (not merely by importing @parmana/shared), same as
89
+ * every other lazy singleton in this file's neighborhood.
90
+ */
91
+ export function getLogger() {
92
+ if (!sharedLogger) {
93
+ sharedLogger = createLogger(loadConfig().logging.level);
94
+ }
95
+ return sharedLogger;
96
+ }
97
+ //# sourceMappingURL=Logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/logging/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;;;;;;;;;;;;GAiBG;AAEH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,EAAE;IACT,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE;IACR,KAAK,EAAE,EAAE;CACD,CAAC;AAIX,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,KAAK,IAAI,MAAM,CAAC;AACzB,CAAC;AAED;;;;;;GAMG;AACH,SAAS,eAAe,CAAC,eAAuB;IAC9C,OAAO,UAAU,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,MAAM,CAAC;AAChE,CAAC;AAcD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,eAAuB;IAClD,MAAM,QAAQ,GAAG,MAAM,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC;IAE1D,SAAS,GAAG,CAAC,KAAe,EAAE,MAAiB;QAC7C,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,CAAC;YAC7B,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;YAC1B,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,GAAG,MAAM;SACV,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;YACjC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACtB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO;QACL,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;QACvC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;QACrC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;QACrC,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC;KACxC,CAAC;AACJ,CAAC;AAED,IAAI,YAAgC,CAAC;AAErC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,SAAS;IACvB,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,YAAY,GAAG,YAAY,CAAC,UAAU,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Address checks for an external connector endpoint (ADR-0013,
3
+ * Security: SSRF).
4
+ *
5
+ * Parmana makes an HTTPS request to a URL an operator entered, so the
6
+ * URL is checked when it is registered and the address it resolves to
7
+ * is checked again at every release: a DNS change cannot point a
8
+ * registered endpoint inside Parmana's network.
9
+ */
10
+ export declare const MAX_ENDPOINT_URL_LENGTH = 2048;
11
+ export interface ResolvedAddress {
12
+ readonly address: string;
13
+ readonly family: 4 | 6;
14
+ }
15
+ /**
16
+ * Resolves a host name to every address it has. The default is the
17
+ * system resolver; tests pass their own.
18
+ */
19
+ export type EndpointAddressLookup = (hostname: string) => Promise<readonly ResolvedAddress[]>;
20
+ export declare const systemEndpointAddressLookup: EndpointAddressLookup;
21
+ export type EndpointUrlCheck = {
22
+ readonly ok: true;
23
+ readonly url: URL;
24
+ } | {
25
+ readonly ok: false;
26
+ readonly reason: string;
27
+ };
28
+ /**
29
+ * The checks that need no network: an absolute https URL with a host
30
+ * name (not an IP literal, not localhost, at least one dot), no user
31
+ * name or password, no fragment. On success, url.href is the form to
32
+ * store: it is the audience of every release to this endpoint.
33
+ */
34
+ export declare function checkEndpointUrl(value: unknown): EndpointUrlCheck;
35
+ export declare function isPublicAddress(address: string): boolean;
36
+ export declare class ExternalEndpointAddressError extends Error {
37
+ constructor(message: string);
38
+ }
39
+ /**
40
+ * Resolves the endpoint's host and returns its addresses, or throws
41
+ * ExternalEndpointAddressError when it does not resolve or when ANY
42
+ * address it resolves to is not public. Refusing on any, not only the
43
+ * first, is deliberate: the caller connects to one of the returned
44
+ * addresses, never to the name again, so a second lookup cannot answer
45
+ * differently.
46
+ */
47
+ export declare function resolvePublicEndpointAddresses(url: URL, lookup?: EndpointAddressLookup): Promise<readonly ResolvedAddress[]>;
48
+ //# sourceMappingURL=externalEndpointAddress.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalEndpointAddress.d.ts","sourceRoot":"","sources":["../../src/network/externalEndpointAddress.ts"],"names":[],"mappings":"AAGA;;;;;;;;GAQG;AAEH,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAkD5C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAClC,QAAQ,EAAE,MAAM,KACb,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC;AAEzC,eAAO,MAAM,2BAA2B,EAAE,qBAKvC,CAAC;AAEJ,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAAE,GACxC;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAuDjE;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAQxD;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAED;;;;;;;GAOG;AACH,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,MAAM,GAAE,qBAAmD,GAC1D,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CA2BrC"}
@@ -0,0 +1,147 @@
1
+ import { promises as dns } from "node:dns";
2
+ import net from "node:net";
3
+ /**
4
+ * Address checks for an external connector endpoint (ADR-0013,
5
+ * Security: SSRF).
6
+ *
7
+ * Parmana makes an HTTPS request to a URL an operator entered, so the
8
+ * URL is checked when it is registered and the address it resolves to
9
+ * is checked again at every release: a DNS change cannot point a
10
+ * registered endpoint inside Parmana's network.
11
+ */
12
+ export const MAX_ENDPOINT_URL_LENGTH = 2048;
13
+ /**
14
+ * Addresses Parmana never sends a release to: private, loopback, link
15
+ * local, shared (carrier grade NAT), multicast, reserved and
16
+ * documentation ranges, in IPv4 and IPv6.
17
+ */
18
+ const NON_PUBLIC = new net.BlockList();
19
+ for (const [network, prefix] of [
20
+ ["0.0.0.0", 8],
21
+ ["10.0.0.0", 8],
22
+ ["100.64.0.0", 10],
23
+ ["127.0.0.0", 8],
24
+ ["169.254.0.0", 16],
25
+ ["172.16.0.0", 12],
26
+ ["192.0.0.0", 24],
27
+ ["192.0.2.0", 24],
28
+ ["192.88.99.0", 24],
29
+ ["192.168.0.0", 16],
30
+ ["198.18.0.0", 15],
31
+ ["198.51.100.0", 24],
32
+ ["203.0.113.0", 24],
33
+ ["224.0.0.0", 4],
34
+ ["240.0.0.0", 4],
35
+ ]) {
36
+ NON_PUBLIC.addSubnet(network, prefix, "ipv4");
37
+ }
38
+ // No rule for IPv4 mapped IPv6 (::ffff:0:0/96): BlockList already
39
+ // checks a mapped address against the IPv4 rules above, and a rule for
40
+ // the whole range would also match every plain IPv4 address.
41
+ for (const [network, prefix] of [
42
+ ["::", 128],
43
+ ["::1", 128],
44
+ ["64:ff9b::", 96],
45
+ ["64:ff9b:1::", 48],
46
+ ["100::", 64],
47
+ ["2001::", 23],
48
+ ["2001:db8::", 32],
49
+ ["2002::", 16],
50
+ ["fc00::", 7],
51
+ ["fe80::", 10],
52
+ ["fec0::", 10],
53
+ ["ff00::", 8],
54
+ ]) {
55
+ NON_PUBLIC.addSubnet(network, prefix, "ipv6");
56
+ }
57
+ export const systemEndpointAddressLookup = async (hostname) => (await dns.lookup(hostname, { all: true, verbatim: true })).map(({ address, family }) => ({ address, family: family === 6 ? 6 : 4 }));
58
+ /**
59
+ * The checks that need no network: an absolute https URL with a host
60
+ * name (not an IP literal, not localhost, at least one dot), no user
61
+ * name or password, no fragment. On success, url.href is the form to
62
+ * store: it is the audience of every release to this endpoint.
63
+ */
64
+ export function checkEndpointUrl(value) {
65
+ if (typeof value !== "string" || value.length > MAX_ENDPOINT_URL_LENGTH) {
66
+ return {
67
+ ok: false,
68
+ reason: `endpointUrl must be a string of at most ${MAX_ENDPOINT_URL_LENGTH} characters.`,
69
+ };
70
+ }
71
+ let url;
72
+ try {
73
+ url = new URL(value);
74
+ }
75
+ catch {
76
+ return { ok: false, reason: "endpointUrl is not an absolute URL." };
77
+ }
78
+ if (url.protocol !== "https:") {
79
+ return { ok: false, reason: "endpointUrl must use https." };
80
+ }
81
+ if (url.username !== "" || url.password !== "") {
82
+ return {
83
+ ok: false,
84
+ reason: "endpointUrl must not carry a user name or password.",
85
+ };
86
+ }
87
+ if (url.hash !== "") {
88
+ return { ok: false, reason: "endpointUrl must not carry a fragment." };
89
+ }
90
+ const hostname = url.hostname.toLowerCase();
91
+ if (hostname.startsWith("[") || net.isIP(hostname) !== 0) {
92
+ return {
93
+ ok: false,
94
+ reason: "endpointUrl must name a host, not an IP address.",
95
+ };
96
+ }
97
+ const bare = hostname.endsWith(".") ? hostname.slice(0, -1) : hostname;
98
+ if (bare === "localhost" ||
99
+ bare.endsWith(".localhost") ||
100
+ !bare.includes(".")) {
101
+ return {
102
+ ok: false,
103
+ reason: "endpointUrl must name a public host with a domain, not localhost or a single label name.",
104
+ };
105
+ }
106
+ return { ok: true, url };
107
+ }
108
+ export function isPublicAddress(address) {
109
+ const family = net.isIP(address);
110
+ if (family === 0) {
111
+ return false;
112
+ }
113
+ return !NON_PUBLIC.check(address, family === 6 ? "ipv6" : "ipv4");
114
+ }
115
+ export class ExternalEndpointAddressError extends Error {
116
+ constructor(message) {
117
+ super(message);
118
+ this.name = "ExternalEndpointAddressError";
119
+ }
120
+ }
121
+ /**
122
+ * Resolves the endpoint's host and returns its addresses, or throws
123
+ * ExternalEndpointAddressError when it does not resolve or when ANY
124
+ * address it resolves to is not public. Refusing on any, not only the
125
+ * first, is deliberate: the caller connects to one of the returned
126
+ * addresses, never to the name again, so a second lookup cannot answer
127
+ * differently.
128
+ */
129
+ export async function resolvePublicEndpointAddresses(url, lookup = systemEndpointAddressLookup) {
130
+ let addresses;
131
+ try {
132
+ addresses = await lookup(url.hostname);
133
+ }
134
+ catch {
135
+ throw new ExternalEndpointAddressError(`The endpoint host '${url.hostname}' does not resolve.`);
136
+ }
137
+ if (addresses.length === 0) {
138
+ throw new ExternalEndpointAddressError(`The endpoint host '${url.hostname}' does not resolve.`);
139
+ }
140
+ const refused = addresses.filter(({ address }) => !isPublicAddress(address));
141
+ if (refused.length > 0) {
142
+ throw new ExternalEndpointAddressError(`The endpoint host '${url.hostname}' resolves to an address that is not public ` +
143
+ `(${refused.map(({ address }) => address).join(", ")}).`);
144
+ }
145
+ return addresses;
146
+ }
147
+ //# sourceMappingURL=externalEndpointAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"externalEndpointAddress.js","sourceRoot":"","sources":["../../src/network/externalEndpointAddress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,GAAG,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;AAEvC,KAAK,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI;IAC9B,CAAC,SAAS,EAAE,CAAC,CAAC;IACd,CAAC,UAAU,EAAE,CAAC,CAAC;IACf,CAAC,YAAY,EAAE,EAAE,CAAC;IAClB,CAAC,WAAW,EAAE,CAAC,CAAC;IAChB,CAAC,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC,YAAY,EAAE,EAAE,CAAC;IAClB,CAAC,WAAW,EAAE,EAAE,CAAC;IACjB,CAAC,WAAW,EAAE,EAAE,CAAC;IACjB,CAAC,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC,YAAY,EAAE,EAAE,CAAC;IAClB,CAAC,cAAc,EAAE,EAAE,CAAC;IACpB,CAAC,aAAa,EAAE,EAAE,CAAC;IACnB,CAAC,WAAW,EAAE,CAAC,CAAC;IAChB,CAAC,WAAW,EAAE,CAAC,CAAC;CACR,EAAE,CAAC;IACX,UAAU,CAAC,SAAS,CAAC,OAAO,E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AAC,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAE7E,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,4BAA4B,CACpC,sBAAsB,GAAG,CAAC,QAAQ,8CAA8C;YAC9E,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAC3D,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { ApprovalIssuerChange, ApprovalIssuerRecord } from "../domain/approval-issuer.js";
2
+ /**
3
+ * Approver keys added through maker checker, and the changes that add
4
+ * or revoke them.
5
+ */
6
+ export interface ApprovalIssuerRepository {
7
+ findIssuer(approverId: string, keyId: string): Promise<ApprovalIssuerRecord | null>;
8
+ listIssuers(): Promise<readonly ApprovalIssuerRecord[]>;
9
+ /**
10
+ * Stores a new PENDING_APPROVAL change. Throws ConflictError when
11
+ * another change for the same approver and key is still pending.
12
+ */
13
+ createChange(change: ApprovalIssuerChange): Promise<ApprovalIssuerChange>;
14
+ findChange(changeId: string): Promise<ApprovalIssuerChange | null>;
15
+ listChanges(status?: ApprovalIssuerChange["status"]): Promise<readonly ApprovalIssuerChange[]>;
16
+ /**
17
+ * Resolves a pending change to APPROVED and applies it, in one step:
18
+ * add inserts the key, revoke marks it revoked. Throws
19
+ * ApprovalIssuerChangeNotFoundError for an unknown id, and
20
+ * ConflictError when the change is no longer pending, the key to add
21
+ * already exists, or the key to revoke does not exist or is already
22
+ * revoked. Nothing is written when it throws.
23
+ */
24
+ approveChange(changeId: string, approvedBy: string, at: Date): Promise<ApprovalIssuerChange>;
25
+ /**
26
+ * Resolves a pending change to REJECTED. Throws as approveChange does
27
+ * for an unknown or already resolved change.
28
+ */
29
+ rejectChange(changeId: string, rejectedBy: string, rejectionReason: string, at: Date): Promise<ApprovalIssuerChange>;
30
+ }
31
+ //# sourceMappingURL=approval-issuer-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-issuer-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/approval-issuer-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,wBAAwB;IACvC,UAAU,CACR,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAExC,WAAW,IAAI,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;IAExD;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE1E,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAEnE,WAAW,CACT,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;IAE5C;;;;;;;OAOG;IACH,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC;;;OAGG;IACH,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=approval-issuer-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-issuer-repository.js","sourceRoot":"","sources":["../../src/repositories/approval-issuer-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import type { AuthorityGrant, AuthorityGrantChange } from "../domain/authority-grant.js";
2
+ /**
3
+ * Authority grants and the changes that make and revoke them (RFC-0023
4
+ * phase 3). Only approveChange touches grants, and it applies the change
5
+ * and resolves it in one step. At most one active grant and one pending
6
+ * change exist per caller and capability.
7
+ */
8
+ export interface AuthorityGrantRepository {
9
+ /**
10
+ * The active (not revoked) grant for this caller and capability, or
11
+ * null. It may have expired or not yet begun: the caller decides what
12
+ * that means.
13
+ */
14
+ findActive(callerId: string, capability: string): Promise<AuthorityGrant | null>;
15
+ listGrants(): Promise<readonly AuthorityGrant[]>;
16
+ createChange(change: AuthorityGrantChange): Promise<AuthorityGrantChange>;
17
+ findChange(changeId: string): Promise<AuthorityGrantChange | null>;
18
+ listChanges(status?: AuthorityGrantChange["status"]): Promise<readonly AuthorityGrantChange[]>;
19
+ approveChange(changeId: string, approvedBy: string, at: Date): Promise<AuthorityGrantChange>;
20
+ rejectChange(changeId: string, rejectedBy: string, rejectionReason: string, at: Date): Promise<AuthorityGrantChange>;
21
+ }
22
+ //# sourceMappingURL=authority-grant-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-grant-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/authority-grant-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,UAAU,CACR,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAElC,UAAU,IAAI,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAAC;IAEjD,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAE1E,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC,CAAC;IAEnE,WAAW,CACT,MAAM,CAAC,EAAE,oBAAoB,CAAC,QAAQ,CAAC,GACtC,OAAO,CAAC,SAAS,oBAAoB,EAAE,CAAC,CAAC;IAE5C,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,oBAAoB,CAAC,CAAC;IAEjC,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=authority-grant-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-grant-repository.js","sourceRoot":"","sources":["../../src/repositories/authority-grant-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,17 @@
1
+ import type { BusinessSignalSourceChange, BusinessSignalSourceRegistration } from "../domain/business-signal-source.js";
2
+ /**
3
+ * Business signal sources and the changes that register and revoke them
4
+ * (RFC-0023 phase 2). Only approveChange touches registrations, and it
5
+ * applies the change and resolves it in one step. At most one active
6
+ * registration and one pending change exist per name.
7
+ */
8
+ export interface BusinessSignalSourceRepository {
9
+ findActive(name: string): Promise<BusinessSignalSourceRegistration | null>;
10
+ listRegistrations(): Promise<readonly BusinessSignalSourceRegistration[]>;
11
+ createChange(change: BusinessSignalSourceChange): Promise<BusinessSignalSourceChange>;
12
+ findChange(changeId: string): Promise<BusinessSignalSourceChange | null>;
13
+ listChanges(status?: BusinessSignalSourceChange["status"]): Promise<readonly BusinessSignalSourceChange[]>;
14
+ approveChange(changeId: string, approvedBy: string, at: Date): Promise<BusinessSignalSourceChange>;
15
+ rejectChange(changeId: string, rejectedBy: string, rejectionReason: string, at: Date): Promise<BusinessSignalSourceChange>;
16
+ }
17
+ //# sourceMappingURL=business-signal-source-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-signal-source-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/business-signal-source-repository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAC1B,gCAAgC,EACjC,MAAM,qCAAqC,CAAC;AAE7C;;;;;GAKG;AACH,MAAM,WAAW,8BAA8B;IAC7C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gCAAgC,GAAG,IAAI,CAAC,CAAC;IAE3E,iBAAiB,IAAI,OAAO,CAAC,SAAS,gCAAgC,EAAE,CAAC,CAAC;IAE1E,YAAY,CACV,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEvC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,GAAG,IAAI,CAAC,CAAC;IAEzE,WAAW,CACT,MAAM,CAAC,EAAE,0BAA0B,CAAC,QAAQ,CAAC,GAC5C,OAAO,CAAC,SAAS,0BAA0B,EAAE,CAAC,CAAC;IAElD,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAEvC,YAAY,CACV,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,EAAE,EAAE,IAAI,GACP,OAAO,CAAC,0BAA0B,CAAC,CAAC;CACxC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=business-signal-source-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-signal-source-repository.js","sourceRoot":"","sources":["../../src/repositories/business-signal-source-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,34 @@
1
+ import { BusinessTransaction } from "../domain/index.js";
2
+ /**
3
+ * Repository for Business Transactions.
4
+ *
5
+ * Implementations may use PostgreSQL, Supabase,
6
+ * DynamoDB, etc.
7
+ */
8
+ export interface BusinessTransactionRepository {
9
+ /**
10
+ * Creates a new Business Transaction. Insert-if-absent: an
11
+ * implementation MUST atomically reject a businessTransactionId
12
+ * that already exists by throwing DuplicateBusinessTransactionError
13
+ * (@parmana/shared), rather than silently overwriting it or
14
+ * relying on a separate exists()-then-create() check at the call
15
+ * site, which cannot be atomic (see G-1,
16
+ * docs/VERIFICATION-GAPS.md). Every implementation must surface
17
+ * the same error type for a duplicate, so callers cannot behave
18
+ * differently depending on the backing store.
19
+ */
20
+ create(transaction: BusinessTransaction): Promise<BusinessTransaction>;
21
+ /**
22
+ * Finds a Business Transaction.
23
+ */
24
+ findById(businessTransactionId: string): Promise<BusinessTransaction | null>;
25
+ /**
26
+ * Checks whether a Business Transaction exists.
27
+ */
28
+ exists(businessTransactionId: string): Promise<boolean>;
29
+ /**
30
+ * Lists Business Transactions.
31
+ */
32
+ list(page: number, pageSize: number): Promise<readonly BusinessTransaction[]>;
33
+ }
34
+ //# sourceMappingURL=business-transaction-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-transaction-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/business-transaction-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,WAAW,EAAE,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEvE;;OAEG;IACH,QAAQ,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAE7E;;OAEG;IACH,MAAM,CAAC,qBAAqB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAExD;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC;CAC/E"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=business-transaction-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"business-transaction-repository.js","sourceRoot":"","sources":["../../src/repositories/business-transaction-repository.ts"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ import { ChallengeRecord, ChallengeRecordDisclosure, ChallengeRecordFinding, ChallengeRecordInvestigationStep, ChallengeRecordOutcome, ChallengeRecordStatus } from "../domain/index.js";
2
+ /**
3
+ * One append-only operation against an existing ChallengeRecord
4
+ * (RFC-0022). Exactly one of these per `append()` call — never a
5
+ * partial-record patch — so every mutation is an explicit,
6
+ * individually reviewable step, matching investigationSteps' own
7
+ * one-entry-at-a-time shape.
8
+ */
9
+ export type ChallengeRecordAppendOperation = {
10
+ readonly kind: "investigation-step";
11
+ readonly step: ChallengeRecordInvestigationStep;
12
+ } | {
13
+ readonly kind: "status";
14
+ readonly status: ChallengeRecordStatus;
15
+ } | {
16
+ readonly kind: "finding";
17
+ readonly finding: ChallengeRecordFinding;
18
+ } | {
19
+ readonly kind: "outcome";
20
+ readonly outcome: ChallengeRecordOutcome;
21
+ } | {
22
+ readonly kind: "disclosure";
23
+ readonly disclosure: ChallengeRecordDisclosure;
24
+ };
25
+ /**
26
+ * Repository for Challenge Records (RFC-0022).
27
+ *
28
+ * Unlike RefusalRecordRepository (a single terminal write per
29
+ * transaction), a ChallengeRecord is investigated over real time:
30
+ * `create` starts it, `append` extends it. `append` never accepts a
31
+ * full replacement record — only one of ChallengeRecordAppendOperation's
32
+ * variants — so implementations can enforce append-only semantics
33
+ * (investigationSteps only ever grows; status only ever moves
34
+ * forward; finding/outcome/disclosure are each immutable once set) at
35
+ * the repository boundary, not merely by caller convention. See
36
+ * `applyChallengeRecordAppend`, which every implementation should
37
+ * route through to keep that enforcement identical across backends.
38
+ */
39
+ export interface ChallengeRecordRepository {
40
+ create(record: ChallengeRecord): Promise<ChallengeRecord>;
41
+ /**
42
+ * Applies one append-only operation to an existing Challenge
43
+ * Record and returns the updated record. Throws
44
+ * ChallengeRecordNotFoundError if no record exists for the given
45
+ * id, or ConflictError if the operation would violate append-only
46
+ * semantics (see `applyChallengeRecordAppend`).
47
+ */
48
+ append(challengeRecordId: string, operation: ChallengeRecordAppendOperation): Promise<ChallengeRecord>;
49
+ findById(challengeRecordId: string): Promise<ChallengeRecord | null>;
50
+ list(): Promise<readonly ChallengeRecord[]>;
51
+ }
52
+ /**
53
+ * Pure, backend-independent enforcement of ChallengeRecord's
54
+ * append-only rules (RFC-0022 § Proposal 1): investigationSteps only
55
+ * grows; status only moves strictly forward (open -> investigating ->
56
+ * resolved), never backward or in place; finding/outcome/disclosure
57
+ * are each set at most once. Every ChallengeRecordRepository
58
+ * implementation should call this rather than re-implementing the
59
+ * same checks, so the enforcement is identical across backends (the
60
+ * same reasoning `isUniqueViolation` gave for a shared mapping across
61
+ * MemoryBusinessTransactionRepository / SupabaseBusinessTransactionRepository).
62
+ *
63
+ * Throws ConflictError, never silently drops or overwrites, on any
64
+ * violation.
65
+ */
66
+ export declare function applyChallengeRecordAppend(record: ChallengeRecord, operation: ChallengeRecordAppendOperation, appliedAt: Date): ChallengeRecord;
67
+ //# sourceMappingURL=challenge-record-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"challenge-record-repository.d.ts","sourceRoot":"","sources":["../../src/repositories/challenge-record-repository.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,sBAAsB,EACtB,gCAAgC,EAChC,sBAAsB,EACtB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAI5B;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GACtC;IACE,QAAQ,CAAC,IAAI,EAAE,oBAAoB,CAAC;IACpC,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAC;CACjD,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAA;CAAE,GACtE;IACE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,yBAAyB,CAAC;CAChD,CAAC;AAEN;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE1D;;;;;;OAMG;IACH,MAAM,CACJ,iBAAiB,EAAE,MAAM,EACzB,SAAS,EAAE,8BAA8B,GACxC,OAAO,CAAC,eAAe,CAAC,CAAC;IAE5B,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAErE,IAAI,IAAI,OAAO,CAAC,SAAS,eAAe,EAAE,CAAC,CAAC;CAC7C;AAaD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,EACvB,SAAS,EAAE,8BAA8B,EACzC,SAAS,EAAE,IAAI,GACd,eAAe,CAkEjB"}
@@ -0,0 +1,76 @@
1
+ import { ConflictError } from "../errors/index.js";
2
+ /**
3
+ * Forward-only lifecycle order a `status` append operation must
4
+ * respect. Index position, not the string values, is what "forward"
5
+ * means here.
6
+ */
7
+ const CHALLENGE_RECORD_STATUS_ORDER = [
8
+ "open",
9
+ "investigating",
10
+ "resolved",
11
+ ];
12
+ /**
13
+ * Pure, backend-independent enforcement of ChallengeRecord's
14
+ * append-only rules (RFC-0022 § Proposal 1): investigationSteps only
15
+ * grows; status only moves strictly forward (open -> investigating ->
16
+ * resolved), never backward or in place; finding/outcome/disclosure
17
+ * are each set at most once. Every ChallengeRecordRepository
18
+ * implementation should call this rather than re-implementing the
19
+ * same checks, so the enforcement is identical across backends (the
20
+ * same reasoning `isUniqueViolation` gave for a shared mapping across
21
+ * MemoryBusinessTransactionRepository / SupabaseBusinessTransactionRepository).
22
+ *
23
+ * Throws ConflictError, never silently drops or overwrites, on any
24
+ * violation.
25
+ */
26
+ export function applyChallengeRecordAppend(record, operation, appliedAt) {
27
+ switch (operation.kind) {
28
+ case "investigation-step":
29
+ return {
30
+ ...record,
31
+ investigationSteps: [...record.investigationSteps, operation.step],
32
+ updatedAt: appliedAt,
33
+ };
34
+ case "status": {
35
+ const currentIndex = CHALLENGE_RECORD_STATUS_ORDER.indexOf(record.status);
36
+ const nextIndex = CHALLENGE_RECORD_STATUS_ORDER.indexOf(operation.status);
37
+ if (nextIndex <= currentIndex) {
38
+ throw new ConflictError(`Challenge Record '${record.challengeRecordId}' status cannot move from ` +
39
+ `'${record.status}' to '${operation.status}' -- status only ever moves forward ` +
40
+ "(open -> investigating -> resolved), never backward or in place. A challenge " +
41
+ "believed resolved that needs reopening should become a new ChallengeRecord " +
42
+ "linked via 'supersedes', not a status change on this one.");
43
+ }
44
+ return { ...record, status: operation.status, updatedAt: appliedAt };
45
+ }
46
+ case "finding": {
47
+ if (record.finding !== undefined) {
48
+ throw new ConflictError(`Challenge Record '${record.challengeRecordId}' already has a finding recorded ` +
49
+ `('${record.finding.outcome}') -- finding is immutable once set. A correction ` +
50
+ "should become a new ChallengeRecord linked via 'supersedes', not an edit here.");
51
+ }
52
+ return { ...record, finding: operation.finding, updatedAt: appliedAt };
53
+ }
54
+ case "outcome": {
55
+ if (record.outcome !== undefined) {
56
+ throw new ConflictError(`Challenge Record '${record.challengeRecordId}' already has an outcome recorded ` +
57
+ "-- outcome is immutable once set. A correction should become a new " +
58
+ "ChallengeRecord linked via 'supersedes', not an edit here.");
59
+ }
60
+ return { ...record, outcome: operation.outcome, updatedAt: appliedAt };
61
+ }
62
+ case "disclosure": {
63
+ if (record.disclosure !== undefined) {
64
+ throw new ConflictError(`Challenge Record '${record.challengeRecordId}' already has a disclosure recorded ` +
65
+ "-- disclosure is immutable once set. A correction should become a new " +
66
+ "ChallengeRecord linked via 'supersedes', not an edit here.");
67
+ }
68
+ return {
69
+ ...record,
70
+ disclosure: operation.disclosure,
71
+ updatedAt: appliedAt,
72
+ };
73
+ }
74
+ }
75
+ }
76
+ //# sourceMappingURL=challenge-record-repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"challenge-record-repository.js","sourceRoot":"","sources":["../../src/repositories/challenge-record-repository.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAwDnD;;;;GAIG;AACH,MAAM,6BAA6B,GAAqC;IACtE,MAAM;IACN,eAAe;IACf,UAAU;CACX,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,0BAA0B,CACxC,MAAuB,EACvB,SAAyC,EACzC,SAAe;IAEf,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,oBAAoB;YACvB,OAAO;gBACL,GAAG,MAAM;gBACT,kBAAkB,EAAE,CAAC,GAAG,MAAM,CAAC,kBAAkB,EAAE,SAAS,CAAC,IAAI,CAAC;gBAClE,SAAS,EAAE,SAAS;aACrB,CAAC;QAEJ,KAAK,QAAQ,EAAE,CAAC;YACd,MAAM,YAAY,GAAG,6BAA6B,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC1E,MAAM,SAAS,GAAG,6BAA6B,CAAC,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YAE1E,IAAI,SAAS,IAAI,YAAY,EAAE,CAAC;gBAC9B,MAAM,IAAI,aAAa,CACrB,qBAAqB,MAAM,CAAC,iBAAiB,4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