@bsv/wallet-toolbox 2.1.25 → 2.1.27

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 (206) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +8 -17
  3. package/docs/client.md +1671 -989
  4. package/docs/monitor.md +34 -19
  5. package/docs/services.md +303 -279
  6. package/docs/setup.md +24 -24
  7. package/docs/storage.md +864 -199
  8. package/docs/wallet.md +5285 -10988
  9. package/out/src/Wallet.d.ts +46 -2
  10. package/out/src/Wallet.d.ts.map +1 -1
  11. package/out/src/Wallet.js +65 -4
  12. package/out/src/Wallet.js.map +1 -1
  13. package/out/src/__tests/CWIStyleWalletManager.test.js +3 -2
  14. package/out/src/__tests/CWIStyleWalletManager.test.js.map +1 -1
  15. package/out/src/__tests/ShamirWalletManager.test.js +4 -0
  16. package/out/src/__tests/ShamirWalletManager.test.js.map +1 -1
  17. package/out/src/__tests/WalletPermissionsManager.callbacks.test.js +9 -17
  18. package/out/src/__tests/WalletPermissionsManager.callbacks.test.js.map +1 -1
  19. package/out/src/__tests/WalletPermissionsManager.checks.test.js +4 -4
  20. package/out/src/__tests/WalletPermissionsManager.checks.test.js.map +1 -1
  21. package/out/src/__tests/WalletPermissionsManager.encryption.test.js +8 -8
  22. package/out/src/__tests/WalletPermissionsManager.encryption.test.js.map +1 -1
  23. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts +2 -1
  24. package/out/src/__tests/WalletPermissionsManager.fixtures.d.ts.map +1 -1
  25. package/out/src/__tests/WalletPermissionsManager.fixtures.js +7 -5
  26. package/out/src/__tests/WalletPermissionsManager.fixtures.js.map +1 -1
  27. package/out/src/__tests/WalletPermissionsManager.flows.test.js +14 -14
  28. package/out/src/__tests/WalletPermissionsManager.flows.test.js.map +1 -1
  29. package/out/src/__tests/WalletPermissionsManager.initialization.test.js +4 -4
  30. package/out/src/__tests/WalletPermissionsManager.initialization.test.js.map +1 -1
  31. package/out/src/__tests/WalletPermissionsManager.pmodules.test.js +4 -4
  32. package/out/src/__tests/WalletPermissionsManager.pmodules.test.js.map +1 -1
  33. package/out/src/__tests/WalletPermissionsManager.proxying.test.js +6 -5
  34. package/out/src/__tests/WalletPermissionsManager.proxying.test.js.map +1 -1
  35. package/out/src/__tests/WalletPermissionsManager.tokens.test.js +2 -1
  36. package/out/src/__tests/WalletPermissionsManager.tokens.test.js.map +1 -1
  37. package/out/src/entropy/EntropyCollector.js.map +1 -1
  38. package/out/src/mockchain/MockChainMigrations.d.ts.map +1 -1
  39. package/out/src/mockchain/MockChainStorage.js +3 -3
  40. package/out/src/mockchain/MockChainStorage.js.map +1 -1
  41. package/out/src/mockchain/MockMiner.js +1 -1
  42. package/out/src/mockchain/MockMiner.js.map +1 -1
  43. package/out/src/mockchain/MockServices.js +14 -13
  44. package/out/src/mockchain/MockServices.js.map +1 -1
  45. package/out/src/monitor/Monitor.js +8 -6
  46. package/out/src/monitor/Monitor.js.map +1 -1
  47. package/out/src/monitor/MonitorDaemon.d.ts.map +1 -1
  48. package/out/src/monitor/MonitorDaemon.js +11 -13
  49. package/out/src/monitor/MonitorDaemon.js.map +1 -1
  50. package/out/src/sdk/PrivilegedKeyManager.d.ts.map +1 -1
  51. package/out/src/sdk/PrivilegedKeyManager.js +6 -3
  52. package/out/src/sdk/PrivilegedKeyManager.js.map +1 -1
  53. package/out/src/sdk/WalletError.d.ts.map +1 -1
  54. package/out/src/sdk/WalletError.js +19 -18
  55. package/out/src/sdk/WalletError.js.map +1 -1
  56. package/out/src/sdk/WalletErrorFromJson.js +1 -1
  57. package/out/src/sdk/WalletErrorFromJson.js.map +1 -1
  58. package/out/src/sdk/WalletStorage.interfaces.d.ts +59 -59
  59. package/out/src/sdk/WalletStorage.interfaces.d.ts.map +1 -1
  60. package/out/src/services/ServiceCollection.d.ts.map +1 -1
  61. package/out/src/services/ServiceCollection.js +3 -4
  62. package/out/src/services/ServiceCollection.js.map +1 -1
  63. package/out/src/services/Services.d.ts.map +1 -1
  64. package/out/src/services/Services.js +27 -25
  65. package/out/src/services/Services.js.map +1 -1
  66. package/out/src/storage/StorageIdb.d.ts.map +1 -1
  67. package/out/src/storage/StorageIdb.js +99 -94
  68. package/out/src/storage/StorageIdb.js.map +1 -1
  69. package/out/src/storage/StorageKnex.d.ts +1 -1
  70. package/out/src/storage/StorageKnex.d.ts.map +1 -1
  71. package/out/src/storage/StorageKnex.js +159 -156
  72. package/out/src/storage/StorageKnex.js.map +1 -1
  73. package/out/src/storage/StorageProvider.d.ts.map +1 -1
  74. package/out/src/storage/StorageProvider.js +35 -31
  75. package/out/src/storage/StorageProvider.js.map +1 -1
  76. package/out/src/storage/StorageReader.js +7 -7
  77. package/out/src/storage/StorageReader.js.map +1 -1
  78. package/out/src/storage/StorageReaderWriter.d.ts +0 -1
  79. package/out/src/storage/StorageReaderWriter.d.ts.map +1 -1
  80. package/out/src/storage/StorageReaderWriter.js +0 -3
  81. package/out/src/storage/StorageReaderWriter.js.map +1 -1
  82. package/out/src/storage/StorageSyncReader.js +1 -1
  83. package/out/src/storage/StorageSyncReader.js.map +1 -1
  84. package/out/src/storage/WalletStorageManager.d.ts.map +1 -1
  85. package/out/src/storage/WalletStorageManager.js +22 -21
  86. package/out/src/storage/WalletStorageManager.js.map +1 -1
  87. package/out/src/storage/index.all.d.ts +3 -0
  88. package/out/src/storage/index.all.d.ts.map +1 -1
  89. package/out/src/storage/index.all.js +3 -0
  90. package/out/src/storage/index.all.js.map +1 -1
  91. package/out/src/storage/index.client.d.ts +3 -0
  92. package/out/src/storage/index.client.d.ts.map +1 -1
  93. package/out/src/storage/index.client.js +3 -0
  94. package/out/src/storage/index.client.js.map +1 -1
  95. package/out/src/storage/index.mobile.d.ts +3 -0
  96. package/out/src/storage/index.mobile.d.ts.map +1 -1
  97. package/out/src/storage/index.mobile.js +3 -0
  98. package/out/src/storage/index.mobile.js.map +1 -1
  99. package/out/src/storage/portable/index.d.ts +55 -0
  100. package/out/src/storage/portable/index.d.ts.map +1 -0
  101. package/out/src/storage/portable/index.js +830 -0
  102. package/out/src/storage/portable/index.js.map +1 -0
  103. package/out/src/storage/storageProviderHelpers.js +2 -2
  104. package/out/src/storage/storageProviderHelpers.js.map +1 -1
  105. package/out/src/utility/Format.d.ts.map +1 -1
  106. package/out/src/utility/Format.js +10 -45
  107. package/out/src/utility/Format.js.map +1 -1
  108. package/out/src/utility/ScriptTemplateBRC29.d.ts.map +1 -1
  109. package/out/src/utility/ScriptTemplateBRC29.js +3 -2
  110. package/out/src/utility/ScriptTemplateBRC29.js.map +1 -1
  111. package/out/src/utility/brc114ActionTimeLabels.js +1 -1
  112. package/out/src/utility/brc114ActionTimeLabels.js.map +1 -1
  113. package/out/src/utility/identityUtils.d.ts +12 -6
  114. package/out/src/utility/identityUtils.d.ts.map +1 -1
  115. package/out/src/utility/identityUtils.js +83 -35
  116. package/out/src/utility/identityUtils.js.map +1 -1
  117. package/out/src/utility/index.all.d.ts +1 -0
  118. package/out/src/utility/index.all.d.ts.map +1 -1
  119. package/out/src/utility/index.all.js +1 -0
  120. package/out/src/utility/index.all.js.map +1 -1
  121. package/out/src/utility/index.client.d.ts +1 -0
  122. package/out/src/utility/index.client.d.ts.map +1 -1
  123. package/out/src/utility/index.client.js +1 -0
  124. package/out/src/utility/index.client.js.map +1 -1
  125. package/out/src/utility/stampLog.js +3 -3
  126. package/out/src/utility/stampLog.js.map +1 -1
  127. package/out/src/utility/utilityHelpers.buffer.js +1 -1
  128. package/out/src/utility/utilityHelpers.buffer.js.map +1 -1
  129. package/out/src/utility/utilityHelpers.d.ts.map +1 -1
  130. package/out/src/utility/utilityHelpers.js +2 -2
  131. package/out/src/utility/utilityHelpers.js.map +1 -1
  132. package/out/src/wab-client/WABClient.d.ts +2 -2
  133. package/out/src/wab-client/WABClient.d.ts.map +1 -1
  134. package/package.json +2 -2
  135. package/out/src/storage/schema/__tests/v7Backfill.runner.test.d.ts +0 -2
  136. package/out/src/storage/schema/__tests/v7Backfill.runner.test.d.ts.map +0 -1
  137. package/out/src/storage/schema/__tests/v7Backfill.runner.test.js +0 -148
  138. package/out/src/storage/schema/__tests/v7Backfill.runner.test.js.map +0 -1
  139. package/out/src/storage/schema/__tests/v7Backfill.test.d.ts +0 -2
  140. package/out/src/storage/schema/__tests/v7Backfill.test.d.ts.map +0 -1
  141. package/out/src/storage/schema/__tests/v7Backfill.test.js +0 -96
  142. package/out/src/storage/schema/__tests/v7Backfill.test.js.map +0 -1
  143. package/out/src/storage/schema/__tests/v7Fsm.test.d.ts +0 -2
  144. package/out/src/storage/schema/__tests/v7Fsm.test.d.ts.map +0 -1
  145. package/out/src/storage/schema/__tests/v7Fsm.test.js +0 -42
  146. package/out/src/storage/schema/__tests/v7Fsm.test.js.map +0 -1
  147. package/out/src/storage/schema/__tests/v7Spendability.test.d.ts +0 -2
  148. package/out/src/storage/schema/__tests/v7Spendability.test.d.ts.map +0 -1
  149. package/out/src/storage/schema/__tests/v7Spendability.test.js +0 -29
  150. package/out/src/storage/schema/__tests/v7Spendability.test.js.map +0 -1
  151. package/out/src/storage/schema/tables/TableAction.d.ts +0 -38
  152. package/out/src/storage/schema/tables/TableAction.d.ts.map +0 -1
  153. package/out/src/storage/schema/tables/TableAction.js +0 -3
  154. package/out/src/storage/schema/tables/TableAction.js.map +0 -1
  155. package/out/src/storage/schema/tables/TableChainTip.d.ts +0 -17
  156. package/out/src/storage/schema/tables/TableChainTip.d.ts.map +0 -1
  157. package/out/src/storage/schema/tables/TableChainTip.js +0 -3
  158. package/out/src/storage/schema/tables/TableChainTip.js.map +0 -1
  159. package/out/src/storage/schema/tables/TableMonitorLease.d.ts +0 -23
  160. package/out/src/storage/schema/tables/TableMonitorLease.d.ts.map +0 -1
  161. package/out/src/storage/schema/tables/TableMonitorLease.js +0 -3
  162. package/out/src/storage/schema/tables/TableMonitorLease.js.map +0 -1
  163. package/out/src/storage/schema/tables/TableTransactionV7.d.ts +0 -50
  164. package/out/src/storage/schema/tables/TableTransactionV7.d.ts.map +0 -1
  165. package/out/src/storage/schema/tables/TableTransactionV7.js +0 -3
  166. package/out/src/storage/schema/tables/TableTransactionV7.js.map +0 -1
  167. package/out/src/storage/schema/tables/TableTxAudit.d.ts +0 -26
  168. package/out/src/storage/schema/tables/TableTxAudit.d.ts.map +0 -1
  169. package/out/src/storage/schema/tables/TableTxAudit.js +0 -3
  170. package/out/src/storage/schema/tables/TableTxAudit.js.map +0 -1
  171. package/out/src/storage/schema/v7Backfill.d.ts +0 -35
  172. package/out/src/storage/schema/v7Backfill.d.ts.map +0 -1
  173. package/out/src/storage/schema/v7Backfill.idb.d.ts +0 -32
  174. package/out/src/storage/schema/v7Backfill.idb.d.ts.map +0 -1
  175. package/out/src/storage/schema/v7Backfill.idb.js +0 -95
  176. package/out/src/storage/schema/v7Backfill.idb.js.map +0 -1
  177. package/out/src/storage/schema/v7Backfill.js +0 -147
  178. package/out/src/storage/schema/v7Backfill.js.map +0 -1
  179. package/out/src/storage/schema/v7Backfill.knex.d.ts +0 -32
  180. package/out/src/storage/schema/v7Backfill.knex.d.ts.map +0 -1
  181. package/out/src/storage/schema/v7Backfill.knex.js +0 -240
  182. package/out/src/storage/schema/v7Backfill.knex.js.map +0 -1
  183. package/out/src/storage/schema/v7Backfill.runner.d.ts +0 -63
  184. package/out/src/storage/schema/v7Backfill.runner.d.ts.map +0 -1
  185. package/out/src/storage/schema/v7Backfill.runner.js +0 -62
  186. package/out/src/storage/schema/v7Backfill.runner.js.map +0 -1
  187. package/out/src/storage/schema/v7Crud.d.ts +0 -39
  188. package/out/src/storage/schema/v7Crud.d.ts.map +0 -1
  189. package/out/src/storage/schema/v7Crud.js +0 -203
  190. package/out/src/storage/schema/v7Crud.js.map +0 -1
  191. package/out/src/storage/schema/v7Fsm.d.ts +0 -27
  192. package/out/src/storage/schema/v7Fsm.d.ts.map +0 -1
  193. package/out/src/storage/schema/v7Fsm.js +0 -108
  194. package/out/src/storage/schema/v7Fsm.js.map +0 -1
  195. package/out/src/storage/schema/v7MonitorLease.d.ts +0 -57
  196. package/out/src/storage/schema/v7MonitorLease.d.ts.map +0 -1
  197. package/out/src/storage/schema/v7MonitorLease.js +0 -101
  198. package/out/src/storage/schema/v7MonitorLease.js.map +0 -1
  199. package/out/src/storage/schema/v7Spendability.d.ts +0 -45
  200. package/out/src/storage/schema/v7Spendability.d.ts.map +0 -1
  201. package/out/src/storage/schema/v7Spendability.js +0 -52
  202. package/out/src/storage/schema/v7Spendability.js.map +0 -1
  203. package/out/src/storage/schema/v7TxAudit.d.ts +0 -33
  204. package/out/src/storage/schema/v7TxAudit.d.ts.map +0 -1
  205. package/out/src/storage/schema/v7TxAudit.js +0 -64
  206. package/out/src/storage/schema/v7TxAudit.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Crud.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Crud.ts"],"names":[],"mappings":";;AAUA,0DAGC;AAGD,8CAGC;AAGD,kDASC;AAYD,oDAiCC;AAGD,gCAOC;AAED,oCAuBC;AAGD,kCAGC;AAGD,kCAyBC;AA1ID,2CAAuD;AAEvD,oFAAoF;AAC7E,KAAK,UAAU,uBAAuB,CAAE,IAAU,EAAE,IAAY;IACrE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;IACjE,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;AACzD,CAAC;AAED,iDAAiD;AAC1C,KAAK,UAAU,iBAAiB,CAAE,IAAU,EAAE,aAAqB;IACxE,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAC,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,CAAA;IAC1E,OAAO,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,GA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,EAAE,GAAG,CAAC,MAAM;QAClB,aAAa,EAAE,GAAG,CAAC,aAAa;QAChC,SAAS,EAAE,GAAG,CAAC,SAAS;QACxB,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU;QAC5B,aAAa,EAAE,GAAG,CAAC,cAAc;QACjC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,WAAW;QAC7B,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM;QACpB,WAAW,EAAE,CAAC,CAAC,GAAG,CAAC,YAAY;QAC/B,UAAU,EAAE,MAAA,GAAG,CAAC,WAAW,mCAAI,SAAS;QACxC,UAAU,EAAE,GAAG,CAAC,WAAW;KAC5B,CAAA;AACH,CAAC;AAED,SAAS,cAAc,CAAE,GAAQ;;IAC/B,OAAO;QACL,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;QACpC,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;QACpC,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,MAAM,EAAE,GAAG,CAAC,MAAM;QAClB,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,UAAU,EAAE,MAAA,GAAG,CAAC,WAAW,mCAAI,SAAS;QACxC,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC;KACtC,CAAA;AACH,CAAC"}
@@ -1,27 +0,0 @@
1
- import * as sdk from '../../sdk';
2
- export interface FsmTransitionResult {
3
- ok: boolean;
4
- reason?: string;
5
- }
6
- /**
7
- * Returns true when `from -> to` is a permitted V7 processing transition.
8
- * Identity transitions (`from === to`) are always allowed — they represent a
9
- * status refresh without state change.
10
- */
11
- export declare function isValidProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): boolean;
12
- /**
13
- * As `isValidProcessingTransition` but returns a structured result with a
14
- * human-readable reason for any rejection. Useful for `tx_audit` payloads.
15
- */
16
- export declare function validateProcessingTransition(from: sdk.ProcessingStatus, to: sdk.ProcessingStatus): FsmTransitionResult;
17
- /** Snapshot of the transition table for documentation + tests. */
18
- export declare function processingTransitionMap(): Readonly<Record<sdk.ProcessingStatus, readonly sdk.ProcessingStatus[]>>;
19
- /**
20
- * True when the given state implies the transaction has been seen / accepted
21
- * by at least one network provider — the precondition for output spendability
22
- * in §4.
23
- */
24
- export declare function isProcessingSpendable(s: sdk.ProcessingStatus): boolean;
25
- /** True when the state is terminal (no further automatic transitions). */
26
- export declare function isProcessingTerminal(s: sdk.ProcessingStatus): boolean;
27
- //# sourceMappingURL=v7Fsm.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Fsm.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Fsm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AA+BhC,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,OAAO,CAGT;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,GACvB,mBAAmB,CAMrB;AAED,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAK,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,SAAS,GAAG,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAElH;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEvE;AAED,0EAA0E;AAC1E,wBAAgB,oBAAoB,CAAE,CAAC,EAAE,GAAG,CAAC,gBAAgB,GAAG,OAAO,CAEtE"}
@@ -1,108 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.isValidProcessingTransition = isValidProcessingTransition;
37
- exports.validateProcessingTransition = validateProcessingTransition;
38
- exports.processingTransitionMap = processingTransitionMap;
39
- exports.isProcessingSpendable = isProcessingSpendable;
40
- exports.isProcessingTerminal = isProcessingTerminal;
41
- const sdk = __importStar(require("../../sdk"));
42
- /**
43
- * V7 processing-state machine.
44
- *
45
- * Maps each `ProcessingStatus` to the set of states it may legally transition
46
- * to. Terminal states (`proven`, `invalid`, `doubleSpend`) have no outgoing
47
- * transitions except via the `unfail` operator override.
48
- *
49
- * The transition table is intentionally permissive — the goal is to *reject
50
- * impossible* moves (e.g. `queued -> proven` without ever broadcasting) rather
51
- * than to enumerate the happy path. Stateful preconditions (proof present,
52
- * provider acknowledged) are enforced at the call site.
53
- */
54
- const TRANSITIONS = {
55
- queued: ['sending', 'sent', 'nosend', 'frozen', 'nonfinal', 'invalid'],
56
- sending: ['sent', 'seen', 'seen_multi', 'invalid', 'doubleSpend', 'frozen', 'queued'],
57
- sent: ['seen', 'seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend', 'frozen', 'sending'],
58
- seen: ['seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen'],
59
- seen_multi: ['unconfirmed', 'proven', 'invalid', 'doubleSpend', 'reorging', 'frozen'],
60
- unconfirmed: ['proven', 'invalid', 'reorging', 'frozen', 'seen', 'seen_multi'],
61
- proven: ['reorging'],
62
- reorging: ['proven', 'seen', 'seen_multi', 'unconfirmed', 'invalid', 'doubleSpend', 'frozen'],
63
- invalid: ['unfail'],
64
- doubleSpend: ['unfail'],
65
- unfail: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'proven', 'invalid', 'doubleSpend'],
66
- frozen: ['queued', 'sending', 'sent', 'seen', 'seen_multi', 'unconfirmed', 'invalid', 'doubleSpend'],
67
- nosend: ['queued', 'sent', 'seen', 'invalid', 'frozen'],
68
- nonfinal: ['queued', 'sending', 'sent', 'invalid', 'frozen']
69
- };
70
- /**
71
- * Returns true when `from -> to` is a permitted V7 processing transition.
72
- * Identity transitions (`from === to`) are always allowed — they represent a
73
- * status refresh without state change.
74
- */
75
- function isValidProcessingTransition(from, to) {
76
- if (from === to)
77
- return true;
78
- return TRANSITIONS[from].includes(to);
79
- }
80
- /**
81
- * As `isValidProcessingTransition` but returns a structured result with a
82
- * human-readable reason for any rejection. Useful for `tx_audit` payloads.
83
- */
84
- function validateProcessingTransition(from, to) {
85
- if (isValidProcessingTransition(from, to))
86
- return { ok: true };
87
- return {
88
- ok: false,
89
- reason: `illegal transition ${from} -> ${to}; legal next: ${TRANSITIONS[from].join(', ')}`
90
- };
91
- }
92
- /** Snapshot of the transition table for documentation + tests. */
93
- function processingTransitionMap() {
94
- return TRANSITIONS;
95
- }
96
- /**
97
- * True when the given state implies the transaction has been seen / accepted
98
- * by at least one network provider — the precondition for output spendability
99
- * in §4.
100
- */
101
- function isProcessingSpendable(s) {
102
- return sdk.ProcessingSpendableStatus.includes(s);
103
- }
104
- /** True when the state is terminal (no further automatic transitions). */
105
- function isProcessingTerminal(s) {
106
- return sdk.ProcessingTerminalStatus.includes(s);
107
- }
108
- //# sourceMappingURL=v7Fsm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Fsm.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Fsm.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,kEAMC;AAMD,oEASC;AAGD,0DAEC;AAOD,sDAEC;AAGD,oDAEC;AAjFD,+CAAgC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,GAAyD;IACxE,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;IACtE,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,CAAC;IACrF,IAAI,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,CAAC;IACpG,IAAI,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IAC7F,UAAU,EAAE,CAAC,aAAa,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IACrF,WAAW,EAAE,CAAC,QAAQ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AC,IAAI,CAAC,EAAE;KAC3F,CAAA;AACH,CAAC;AAED,kEAAkE;AAClE,SAAgB,uBAAuB;IACrC,OAAO,WAAW,CAAA;AACpB,CAAC;AAED;;;;GAIG;AACH,SAAgB,qBAAqB,CAAE,CAAuB;IAC5D,OAAO,GAAG,CAAC,yBAAyB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAClD,CAAC;AAED,0EAA0E;AAC1E,SAAgB,oBAAoB,CAAE,CAAuB;IAC3D,OAAO,GAAG,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AACjD,CAAC"}
@@ -1,57 +0,0 @@
1
- import { Knex } from 'knex';
2
- import { TableMonitorLease } from './tables';
3
- /**
4
- * V7 monitor lease primitive.
5
- *
6
- * A `monitor_lease` row records the owner that may currently execute a named
7
- * task. Acquisition is opportunistic: a Monitor calls `tryClaimLease()` to
8
- * insert or take over a stale row; if it succeeds it owns the task until
9
- * `expiresAt`. While running it calls `renewLease()` to extend the deadline.
10
- * On clean shutdown it calls `releaseLease()`.
11
- *
12
- * The Knex driver expresses claim + takeover as a single conditional UPDATE
13
- * so that two contending Monitors cannot both believe they own the task — at
14
- * most one row write will succeed per (task, expiry) pair.
15
- */
16
- export interface MonitorLeaseClaim {
17
- taskName: string;
18
- ownerId: string;
19
- ttlMs: number;
20
- note?: string;
21
- }
22
- export interface MonitorLeaseRenew {
23
- taskName: string;
24
- ownerId: string;
25
- ttlMs: number;
26
- note?: string;
27
- }
28
- export interface MonitorLeaseRelease {
29
- taskName: string;
30
- ownerId: string;
31
- }
32
- export interface MonitorLeaseResult {
33
- acquired: boolean;
34
- lease?: TableMonitorLease;
35
- }
36
- /**
37
- * Try to claim a lease on `taskName`. Succeeds iff:
38
- * - no row exists for the task, OR
39
- * - the existing row has `expiresAt <= now`, OR
40
- * - the existing row's `ownerId` already equals the requested owner.
41
- *
42
- * On success the row is upserted with `expiresAt = now + ttlMs` and
43
- * `renewCount = renewCount + 1` (0 for fresh rows).
44
- */
45
- export declare function tryClaimLease(knex: Knex, claim: MonitorLeaseClaim, now?: Date): Promise<MonitorLeaseResult>;
46
- /**
47
- * Extend the current owner's lease. Fails (returns `acquired: false`) when the
48
- * row does not exist, is owned by someone else, or has already expired.
49
- */
50
- export declare function renewLease(knex: Knex, renew: MonitorLeaseRenew, now?: Date): Promise<MonitorLeaseResult>;
51
- /**
52
- * Release the lease (no-op when not owned by the caller).
53
- * The row is deleted so subsequent claimants do not see an inherited
54
- * `renew_count`.
55
- */
56
- export declare function releaseLease(knex: Knex, release: MonitorLeaseRelease): Promise<boolean>;
57
- //# sourceMappingURL=v7MonitorLease.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7MonitorLease.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7MonitorLease.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAE5C;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,CAAC,EAAE,iBAAiB,CAAA;CAC1B;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,iBAAiB,EACxB,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAmC7B;AAED;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,iBAAiB,EACxB,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,kBAAkB,CAAC,CAkB7B;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CAK9F"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryClaimLease = tryClaimLease;
4
- exports.renewLease = renewLease;
5
- exports.releaseLease = releaseLease;
6
- /**
7
- * Try to claim a lease on `taskName`. Succeeds iff:
8
- * - no row exists for the task, OR
9
- * - the existing row has `expiresAt <= now`, OR
10
- * - the existing row's `ownerId` already equals the requested owner.
11
- *
12
- * On success the row is upserted with `expiresAt = now + ttlMs` and
13
- * `renewCount = renewCount + 1` (0 for fresh rows).
14
- */
15
- async function tryClaimLease(knex, claim, now = new Date()) {
16
- const expiresAt = new Date(now.getTime() + claim.ttlMs);
17
- return await knex.transaction(async (trx) => {
18
- var _a, _b;
19
- const existing = await trx('monitor_lease').where({ task_name: claim.taskName }).forUpdate().first();
20
- const canClaim = existing == null ||
21
- new Date(existing.expires_at).getTime() <= now.getTime() ||
22
- existing.owner_id === claim.ownerId;
23
- if (!canClaim)
24
- return { acquired: false };
25
- if (existing == null) {
26
- await trx('monitor_lease').insert({
27
- task_name: claim.taskName,
28
- owner_id: claim.ownerId,
29
- expires_at: expiresAt,
30
- renew_count: 0,
31
- note: (_a = claim.note) !== null && _a !== void 0 ? _a : null,
32
- created_at: now,
33
- updated_at: now
34
- });
35
- }
36
- else {
37
- await trx('monitor_lease')
38
- .where({ task_name: claim.taskName })
39
- .update({
40
- owner_id: claim.ownerId,
41
- expires_at: expiresAt,
42
- renew_count: existing.owner_id === claim.ownerId ? existing.renew_count + 1 : 0,
43
- note: (_b = claim.note) !== null && _b !== void 0 ? _b : existing.note,
44
- updated_at: now
45
- });
46
- }
47
- const row = await trx('monitor_lease').where({ task_name: claim.taskName }).first();
48
- return { acquired: true, lease: mapRow(row) };
49
- });
50
- }
51
- /**
52
- * Extend the current owner's lease. Fails (returns `acquired: false`) when the
53
- * row does not exist, is owned by someone else, or has already expired.
54
- */
55
- async function renewLease(knex, renew, now = new Date()) {
56
- const expiresAt = new Date(now.getTime() + renew.ttlMs);
57
- return await knex.transaction(async (trx) => {
58
- var _a;
59
- const existing = await trx('monitor_lease').where({ task_name: renew.taskName }).forUpdate().first();
60
- if (existing == null)
61
- return { acquired: false };
62
- if (existing.owner_id !== renew.ownerId)
63
- return { acquired: false };
64
- if (new Date(existing.expires_at).getTime() <= now.getTime())
65
- return { acquired: false };
66
- await trx('monitor_lease')
67
- .where({ task_name: renew.taskName })
68
- .update({
69
- expires_at: expiresAt,
70
- renew_count: existing.renew_count + 1,
71
- note: (_a = renew.note) !== null && _a !== void 0 ? _a : existing.note,
72
- updated_at: now
73
- });
74
- const row = await trx('monitor_lease').where({ task_name: renew.taskName }).first();
75
- return { acquired: true, lease: mapRow(row) };
76
- });
77
- }
78
- /**
79
- * Release the lease (no-op when not owned by the caller).
80
- * The row is deleted so subsequent claimants do not see an inherited
81
- * `renew_count`.
82
- */
83
- async function releaseLease(knex, release) {
84
- const deleted = await knex('monitor_lease')
85
- .where({ task_name: release.taskName, owner_id: release.ownerId })
86
- .delete();
87
- return deleted > 0;
88
- }
89
- function mapRow(row) {
90
- var _a;
91
- return {
92
- created_at: new Date(row.created_at),
93
- updated_at: new Date(row.updated_at),
94
- taskName: row.task_name,
95
- ownerId: row.owner_id,
96
- expiresAt: new Date(row.expires_at),
97
- renewCount: row.renew_count,
98
- note: (_a = row.note) !== null && _a !== void 0 ? _a : undefined
99
- };
100
- }
101
- //# sourceMappingURL=v7MonitorLease.js.map
@@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AAC;QACpC,UAAU,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;QACpC,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,OAAO,EAAE,GAAG,CAAC,QAAQ;QACrB,SAAS,EAAE,IAAI,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;QACnC,UAAU,EAAE,GAAG,CAAC,WAAW;QAC3B,IAAI,EAAE,MAAA,GAAG,CAAC,IAAI,mCAAI,SAAS;KAC5B,CAAA;AACH,CAAC"}
@@ -1,45 +0,0 @@
1
- import * as sdk from '../../sdk';
2
- import { TableChainTip, TableOutput, TableTransactionV7 } from './tables';
3
- /**
4
- * Per-output inputs for the V7 spendability check.
5
- *
6
- * Only the fields needed by §4 of PROD_REQ_V7_TS.md are required; callers are
7
- * free to pass full rows. `spentBy` is the legacy `outputs.spentBy` column;
8
- * coinbase fields use the names introduced in §2.3.
9
- */
10
- export interface SpendabilityOutputInput {
11
- spentBy?: number | null;
12
- lockingScript?: number[] | null;
13
- isCoinbase?: boolean;
14
- maturesAtHeight?: number | null;
15
- }
16
- export interface SpendabilityTxInput {
17
- processing: sdk.ProcessingStatus;
18
- }
19
- export interface SpendabilityTipInput {
20
- height: number;
21
- }
22
- /**
23
- * Pure implementation of the §4 spendability rule:
24
- *
25
- * ```
26
- * spendable = (transactions.processing IN ('sent','seen','seen_multi','unconfirmed','proven'))
27
- * AND outputs.spent_by IS NULL
28
- * AND outputs.locking_script IS NOT NULL
29
- * AND (NOT outputs.is_coinbase OR outputs.matures_at_height <= chain_tip.height)
30
- * ```
31
- *
32
- * The function never reads from storage — call sites are responsible for
33
- * loading the matching transaction row and chain tip. This keeps the rule
34
- * testable in isolation and lets the refresh helpers batch loads efficiently.
35
- */
36
- export declare function isOutputSpendable(out: SpendabilityOutputInput, tx: SpendabilityTxInput, tip: SpendabilityTipInput | undefined): boolean;
37
- /**
38
- * Convenience wrapper that takes whole table rows and forwards to the pure
39
- * predicate. Returns `false` when the matching transaction row is missing.
40
- */
41
- export declare function isTableOutputSpendable(out: TableOutput & {
42
- isCoinbase?: boolean;
43
- maturesAtHeight?: number | null;
44
- }, tx: TableTransactionV7 | undefined, tip: TableChainTip | undefined): boolean;
45
- //# sourceMappingURL=v7Spendability.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Spendability.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Spendability.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAGzE;;;;;;GAMG;AACH,MAAM,WAAW,uBAAuB;IACtC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,aAAa,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAC/B,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAA;CACjC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,uBAAuB,EAC5B,EAAE,EAAE,mBAAmB,EACvB,GAAG,EAAE,oBAAoB,GAAG,SAAS,GACpC,OAAO,CAUT;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,WAAW,GAAG;IAAE,UAAU,CAAC,EAAE,OAAO,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC5E,EAAE,EAAE,kBAAkB,GAAG,SAAS,EAClC,GAAG,EAAE,aAAa,GAAG,SAAS,GAC7B,OAAO,CAYT"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isOutputSpendable = isOutputSpendable;
4
- exports.isTableOutputSpendable = isTableOutputSpendable;
5
- const v7Fsm_1 = require("./v7Fsm");
6
- /**
7
- * Pure implementation of the §4 spendability rule:
8
- *
9
- * ```
10
- * spendable = (transactions.processing IN ('sent','seen','seen_multi','unconfirmed','proven'))
11
- * AND outputs.spent_by IS NULL
12
- * AND outputs.locking_script IS NOT NULL
13
- * AND (NOT outputs.is_coinbase OR outputs.matures_at_height <= chain_tip.height)
14
- * ```
15
- *
16
- * The function never reads from storage — call sites are responsible for
17
- * loading the matching transaction row and chain tip. This keeps the rule
18
- * testable in isolation and lets the refresh helpers batch loads efficiently.
19
- */
20
- function isOutputSpendable(out, tx, tip) {
21
- if (!(0, v7Fsm_1.isProcessingSpendable)(tx.processing))
22
- return false;
23
- if (out.spentBy != null)
24
- return false;
25
- if (out.lockingScript == null)
26
- return false;
27
- if (out.isCoinbase === true) {
28
- if (tip == null)
29
- return false;
30
- if (out.maturesAtHeight == null)
31
- return false;
32
- if (out.maturesAtHeight > tip.height)
33
- return false;
34
- }
35
- return true;
36
- }
37
- /**
38
- * Convenience wrapper that takes whole table rows and forwards to the pure
39
- * predicate. Returns `false` when the matching transaction row is missing.
40
- */
41
- function isTableOutputSpendable(out, tx, tip) {
42
- var _a, _b, _c;
43
- if (tx === undefined)
44
- return false;
45
- return isOutputSpendable({
46
- spentBy: (_a = out.spentBy) !== null && _a !== void 0 ? _a : null,
47
- lockingScript: (_b = out.lockingScript) !== null && _b !== void 0 ? _b : null,
48
- isCoinbase: out.isCoinbase === true,
49
- maturesAtHeight: (_c = out.maturesAtHeight) !== null && _c !== void 0 ? _c : null
50
- }, { processing: tx.processing }, tip != null ? { height: tip.height } : undefined);
51
- }
52
- //# sourceMappingURL=v7Spendability.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Spendability.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Spendability.ts"],"names":[],"mappings":";;AAwCA,8CAcC;AAMD,wDAgB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
- import * as sdk from '../../sdk';
3
- import { TableTxAudit } from './tables';
4
- /**
5
- * V7 append-only audit log writer.
6
- *
7
- * Each call inserts one `tx_audit` row. Events should be small, stable
8
- * identifiers (e.g. `processing.changed`, `proof.acquired`, `lease.claimed`).
9
- * Payload is stored as a JSON-encoded string so downstream consumers may add
10
- * shape over time without a migration.
11
- */
12
- export interface AuditEvent {
13
- transactionId?: number;
14
- actionId?: number;
15
- event: string;
16
- fromState?: sdk.ProcessingStatus;
17
- toState?: sdk.ProcessingStatus;
18
- details?: Record<string, unknown>;
19
- }
20
- export declare function appendTxAudit(knex: Knex, ev: AuditEvent, now?: Date): Promise<number>;
21
- /**
22
- * Convenience helper for processing transitions. Validates the move first;
23
- * on rejection it still records the attempt with `event = 'processing.rejected'`
24
- * so the audit trail captures impossible transitions for later diagnosis.
25
- *
26
- * Returns `true` when the transition is legal (audit row written with
27
- * `processing.changed`) and `false` when rejected (audit row written with
28
- * `processing.rejected`).
29
- */
30
- export declare function auditProcessingTransition(knex: Knex, transactionId: number, from: sdk.ProcessingStatus, to: sdk.ProcessingStatus, details?: Record<string, unknown>, now?: Date): Promise<boolean>;
31
- /** Read all audit rows for a transaction, oldest first. Useful for tests. */
32
- export declare function listAuditForTransaction(knex: Knex, transactionId: number): Promise<TableTxAudit[]>;
33
- //# sourceMappingURL=v7TxAudit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7TxAudit.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7TxAudit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,KAAK,GAAG,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAGvC;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAA;IAChC,OAAO,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAA;IAC9B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAClC;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,UAAU,EACd,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,MAAM,CAAC,CAejB;AAED;;;;;;;;GAQG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,IAAI,EACV,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,GAAG,CAAC,gBAAgB,EAC1B,EAAE,EAAE,GAAG,CAAC,gBAAgB,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,OAAO,CAAC,CAclB;AAED,6EAA6E;AAC7E,wBAAsB,uBAAuB,CAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAGzG"}
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.appendTxAudit = appendTxAudit;
4
- exports.auditProcessingTransition = auditProcessingTransition;
5
- exports.listAuditForTransaction = listAuditForTransaction;
6
- const v7Fsm_1 = require("./v7Fsm");
7
- async function appendTxAudit(knex, ev, now = new Date()) {
8
- var _a, _b, _c, _d;
9
- const detailsJson = ev.details != null ? JSON.stringify(ev.details) : null;
10
- const [id] = await knex('tx_audit').insert({
11
- transactionId: (_a = ev.transactionId) !== null && _a !== void 0 ? _a : null,
12
- actionId: (_b = ev.actionId) !== null && _b !== void 0 ? _b : null,
13
- event: ev.event,
14
- from_state: (_c = ev.fromState) !== null && _c !== void 0 ? _c : null,
15
- to_state: (_d = ev.toState) !== null && _d !== void 0 ? _d : null,
16
- details_json: detailsJson,
17
- created_at: now,
18
- updated_at: now
19
- });
20
- if (typeof id === 'number')
21
- return id;
22
- const row = await knex('tx_audit').orderBy('auditId', 'desc').first('auditId');
23
- return row.auditId;
24
- }
25
- /**
26
- * Convenience helper for processing transitions. Validates the move first;
27
- * on rejection it still records the attempt with `event = 'processing.rejected'`
28
- * so the audit trail captures impossible transitions for later diagnosis.
29
- *
30
- * Returns `true` when the transition is legal (audit row written with
31
- * `processing.changed`) and `false` when rejected (audit row written with
32
- * `processing.rejected`).
33
- */
34
- async function auditProcessingTransition(knex, transactionId, from, to, details, now = new Date()) {
35
- const v = (0, v7Fsm_1.validateProcessingTransition)(from, to);
36
- await appendTxAudit(knex, {
37
- transactionId,
38
- event: v.ok ? 'processing.changed' : 'processing.rejected',
39
- fromState: from,
40
- toState: to,
41
- details: v.ok ? details : { ...(details !== null && details !== void 0 ? details : {}), reason: v.reason }
42
- }, now);
43
- return v.ok;
44
- }
45
- /** Read all audit rows for a transaction, oldest first. Useful for tests. */
46
- async function listAuditForTransaction(knex, transactionId) {
47
- const rows = await knex('tx_audit').where({ transactionId }).orderBy('auditId');
48
- return rows.map(mapRow);
49
- }
50
- function mapRow(row) {
51
- var _a, _b, _c, _d, _e;
52
- return {
53
- created_at: new Date(row.created_at),
54
- updated_at: new Date(row.updated_at),
55
- auditId: row.auditId,
56
- transactionId: (_a = row.transactionId) !== null && _a !== void 0 ? _a : undefined,
57
- actionId: (_b = row.actionId) !== null && _b !== void 0 ? _b : undefined,
58
- event: row.event,
59
- fromState: (_c = row.from_state) !== null && _c !== void 0 ? _c : undefined,
60
- toState: (_d = row.to_state) !== null && _d !== void 0 ? _d : undefined,
61
- detailsJson: (_e = row.details_json) !== null && _e !== void 0 ? _e : undefined
62
- };
63
- }
64
- //# sourceMappingURL=v7TxAudit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7TxAudit.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7TxAudit.ts"],"names":[],"mappings":";;AAsB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