@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":"TableAction.js","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableAction.ts"],"names":[],"mappings":""}
@@ -1,17 +0,0 @@
1
- import * as sdk from '../../../sdk';
2
- /**
3
- * V7 singleton row tracking the most recently observed chain tip.
4
- * Used by spendability checks and coinbase maturity calculations.
5
- */
6
- export interface TableChainTip extends sdk.EntityTimeStamp {
7
- created_at: Date;
8
- updated_at: Date;
9
- /** Always 1 — singleton enforced by storage layer */
10
- id: number;
11
- height: number;
12
- blockHash: string;
13
- merkleRoot?: string;
14
- /** Wall-clock of the observation */
15
- observedAt: Date;
16
- }
17
- //# sourceMappingURL=TableChainTip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableChainTip.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableChainTip.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,GAAG,CAAC,eAAe;IACxD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,oCAAoC;IACpC,UAAU,EAAE,IAAI,CAAA;CACjB"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TableChainTip.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableChainTip.js","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableChainTip.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- import * as sdk from '../../../sdk';
2
- /**
3
- * V7 lease record so at most one Monitor daemon owns a given task at a time.
4
- *
5
- * The Monitor acquires a lease by upserting `(taskName, ownerId, expiresAt)`
6
- * and renews periodically. Stale leases (`expiresAt < now`) may be claimed by
7
- * another instance.
8
- */
9
- export interface TableMonitorLease extends sdk.EntityTimeStamp {
10
- created_at: Date;
11
- updated_at: Date;
12
- /** Logical task name, e.g. 'proof-acquisition' */
13
- taskName: string;
14
- /** Stable identifier for the owning Monitor instance */
15
- ownerId: string;
16
- /** Lease expiry — claimants treat any row with expiresAt <= now() as free */
17
- expiresAt: Date;
18
- /** Monotonic counter incremented on each successful renew */
19
- renewCount: number;
20
- /** Optional free-text description of current activity */
21
- note?: string;
22
- }
23
- //# sourceMappingURL=TableMonitorLease.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableMonitorLease.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableMonitorLease.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;GAMG;AACH,MAAM,WAAW,iBAAkB,SAAQ,GAAG,CAAC,eAAe;IAC5D,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,OAAO,EAAE,MAAM,CAAA;IACf,6EAA6E;IAC7E,SAAS,EAAE,IAAI,CAAA;IACf,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,yDAAyD;IACzD,IAAI,CAAC,EAAE,MAAM,CAAA;CACd"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TableMonitorLease.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableMonitorLease.js","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableMonitorLease.ts"],"names":[],"mappings":""}
@@ -1,50 +0,0 @@
1
- import * as sdk from '../../../sdk';
2
- /**
3
- * V7 canonical per-txid table.
4
- *
5
- * Single source of truth for everything about a transaction on the network.
6
- * Merges the legacy `proven_tx_reqs` (broadcast queue + processing state) and
7
- * `proven_txs` (final Merkle proof) tables into one row per txid.
8
- *
9
- * Per-user metadata (description, labels, hidden, etc.) lives in `actions`.
10
- */
11
- export interface TableTransactionV7 extends sdk.EntityTimeStamp {
12
- created_at: Date;
13
- updated_at: Date;
14
- /** PK */
15
- transactionId: number;
16
- /** UNIQUE — Bitcoin txid, hex */
17
- txid: string;
18
- /** Granular FSM state (see ProcessingStatus) */
19
- processing: sdk.ProcessingStatus;
20
- /** Wall-clock of the most recent processing transition */
21
- processingChangedAt: Date;
22
- /** Wall-clock at which the next monitor pass should consider this row */
23
- nextActionAt?: Date;
24
- /** Cumulative network-service attempt count */
25
- attempts: number;
26
- /** Count of times this row has been reset for rebroadcast (circuit-breaker) */
27
- rebroadcastCycles: number;
28
- /** true once the row has reached a state implying successful broadcast */
29
- wasBroadcast: boolean;
30
- /** Application-supplied idempotency key (unique when present) */
31
- idempotencyKey?: string;
32
- /** Optional batch tag for grouped broadcast */
33
- batch?: string;
34
- rawTx?: number[];
35
- inputBeef?: number[];
36
- /** Merkle proof fields — populated on transition to `proven` */
37
- height?: number;
38
- merkleIndex?: number;
39
- merklePath?: number[];
40
- merkleRoot?: string;
41
- blockHash?: string;
42
- isCoinbase: boolean;
43
- lastProvider?: string;
44
- lastProviderStatus?: string;
45
- /** Reason a row is in `frozen` state, free text */
46
- frozenReason?: string;
47
- /** Optimistic concurrency token */
48
- rowVersion: number;
49
- }
50
- //# sourceMappingURL=TableTransactionV7.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableTransactionV7.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableTransactionV7.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAmB,SAAQ,GAAG,CAAC,eAAe;IAC7D,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,aAAa,EAAE,MAAM,CAAA;IACrB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,gDAAgD;IAChD,UAAU,EAAE,GAAG,CAAC,gBAAgB,CAAA;IAChC,0DAA0D;IAC1D,mBAAmB,EAAE,IAAI,CAAA;IACzB,yEAAyE;IACzE,YAAY,CAAC,EAAE,IAAI,CAAA;IACnB,+CAA+C;IAC/C,QAAQ,EAAE,MAAM,CAAA;IAChB,+EAA+E;IAC/E,iBAAiB,EAAE,MAAM,CAAA;IACzB,0EAA0E;IAC1E,YAAY,EAAE,OAAO,CAAA;IACrB,iEAAiE;IACjE,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,gEAAgE;IAChE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IACrB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,mDAAmD;IACnD,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TableTransactionV7.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableTransactionV7.js","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableTransactionV7.ts"],"names":[],"mappings":""}
@@ -1,26 +0,0 @@
1
- import * as sdk from '../../../sdk';
2
- /**
3
- * V7 per-event audit log for transactions and actions.
4
- *
5
- * Each row records a single observable event scoped to either a transaction
6
- * (per-txid) or an action (per-user) or both. Append-only.
7
- */
8
- export interface TableTxAudit extends sdk.EntityTimeStamp {
9
- created_at: Date;
10
- updated_at: Date;
11
- /** PK */
12
- auditId: number;
13
- /** FK -> transactions.transactionId, optional for action-only events */
14
- transactionId?: number;
15
- /** FK -> actions.actionId, optional for tx-only events */
16
- actionId?: number;
17
- /** Stable event identifier, e.g. 'processing.changed', 'proof.acquired' */
18
- event: string;
19
- /** Optional FSM source state for transitions */
20
- fromState?: string;
21
- /** Optional FSM target state for transitions */
22
- toState?: string;
23
- /** JSON-encoded event payload */
24
- detailsJson?: string;
25
- }
26
- //# sourceMappingURL=TableTxAudit.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableTxAudit.d.ts","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableTxAudit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAA;AAEnC;;;;;GAKG;AACH,MAAM,WAAW,YAAa,SAAQ,GAAG,CAAC,eAAe;IACvD,UAAU,EAAE,IAAI,CAAA;IAChB,UAAU,EAAE,IAAI,CAAA;IAChB,SAAS;IACT,OAAO,EAAE,MAAM,CAAA;IACf,wEAAwE;IACxE,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,2EAA2E;IAC3E,KAAK,EAAE,MAAM,CAAA;IACb,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gDAAgD;IAChD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=TableTxAudit.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TableTxAudit.js","sourceRoot":"","sources":["../../../../../src/storage/schema/tables/TableTxAudit.ts"],"names":[],"mappings":""}
@@ -1,35 +0,0 @@
1
- import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionV7 } from './tables';
2
- /**
3
- * Pure transformation helpers for the V7 schema backfill.
4
- *
5
- * These functions are deliberately storage-agnostic — they accept the legacy
6
- * rows and return the new shapes. A storage driver (Knex or IDB) is responsible
7
- * for reading the source rows and inserting the returned objects.
8
- *
9
- * No row in this module ever talks to the database; this keeps the
10
- * transformation under unit-test control and lets us run dry-run migrations.
11
- */
12
- /**
13
- * Merge a legacy `proven_tx_reqs` row together with an optional `proven_txs`
14
- * row into a single V7 `transactions` (transactions_v7) row.
15
- *
16
- * The proof fields come from `proven_txs` when present; otherwise they are
17
- * left undefined. Processing state is derived from the request's legacy status.
18
- */
19
- export declare function buildTransactionV7Row(req: TableProvenTxReq, proven: TableProvenTx | undefined, now?: Date): Omit<TableTransactionV7, 'transactionId'>;
20
- /**
21
- * Build a V7 `transactions` row from a legacy per-user `transactions` row when
22
- * no `proven_tx_reqs` entry exists (e.g. locally-created actions that never
23
- * reached the broadcast queue).
24
- *
25
- * Returns `undefined` when the legacy row has no txid — such rows belong to
26
- * incomplete actions and have no canonical V7 representation yet.
27
- */
28
- export declare function buildTransactionV7RowFromLegacyTx(tx: TableTransaction, now?: Date): Omit<TableTransactionV7, 'transactionId'> | undefined;
29
- /**
30
- * Build a V7 `actions` row from a legacy per-user `transactions` row.
31
- * The caller is responsible for resolving `transactionId` to the
32
- * newly-inserted `transactions_v7.transactionId`.
33
- */
34
- export declare function buildActionRow(legacy: TableTransaction, v7TransactionId: number, now?: Date): Omit<TableAction, 'actionId'>;
35
- //# sourceMappingURL=v7Backfill.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Backfill.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Backfill.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,UAAU,CAAA;AAEjB;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,gBAAgB,EACrB,MAAM,EAAE,aAAa,GAAG,SAAS,EACjC,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,CA2B3C;AAED;;;;;;;GAOG;AACH,wBAAgB,iCAAiC,CAC/C,EAAE,EAAE,gBAAgB,EACpB,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAAG,SAAS,CA2BvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,MAAM,EACvB,GAAG,GAAE,IAAiB,GACrB,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAgB/B"}
@@ -1,32 +0,0 @@
1
- import { IDBPDatabase, IDBPTransaction } from 'idb';
2
- import { StorageIdbSchema } from './StorageIdbSchema';
3
- import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionV7 } from './tables';
4
- import { V7BackfillDriver, V7BackfillStats } from './v7Backfill.runner';
5
- type IdbStoreName = keyof StorageIdbSchema;
6
- /**
7
- * IndexedDB driver for the V7 backfill.
8
- *
9
- * The orchestrator is driven entirely from this driver inside a single
10
- * `readwrite` transaction across the legacy + V7 stores. The streams cache
11
- * the keys up-front (`getAllKeys`) and then walk them one at a time so the
12
- * idb cursor lifetime does not span an external `await`.
13
- */
14
- export declare class V7IdbBackfillDriver implements V7BackfillDriver {
15
- private readonly trx;
16
- constructor(trx: IDBPTransaction<StorageIdbSchema, IdbStoreName[], 'readwrite'>);
17
- streamLegacyReqs(): AsyncIterable<{
18
- req: TableProvenTxReq;
19
- proven?: TableProvenTx;
20
- }>;
21
- streamLegacyTransactions(): AsyncIterable<TableTransaction>;
22
- upsertTransactionV7(row: Omit<TableTransactionV7, 'transactionId'>): Promise<number>;
23
- upsertAction(row: Omit<TableAction, 'actionId'>): Promise<number>;
24
- repointTxLabelMap(legacyTransactionId: number, actionId: number): Promise<void>;
25
- }
26
- /**
27
- * Convenience entry point that opens the required readwrite transaction and
28
- * runs the orchestrator against it.
29
- */
30
- export declare function runV7IdbBackfill(db: IDBPDatabase<StorageIdbSchema>, now?: Date): Promise<V7BackfillStats>;
31
- export {};
32
- //# sourceMappingURL=v7Backfill.idb.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Backfill.idb.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Backfill.idb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,KAAK,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAiB,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAEtF,KAAK,YAAY,GAAG,MAAM,gBAAgB,CAAA;AAW1C;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;IAExD,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,EAAE,eAAe,CAAC,gBAAgB,EAAE,YAAY,EAAE,EAAE,WAAW,CAAC;IAG9E,gBAAgB,IAAK,aAAa,CAAC;QAAE,GAAG,EAAE,gBAAgB,CAAC;QAAC,MAAM,CAAC,EAAE,aAAa,CAAA;KAAE,CAAC;IAYrF,wBAAwB,IAAK,aAAa,CAAC,gBAAgB,CAAC;IAS9D,mBAAmB,CAAE,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAarF,YAAY,CAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAalE,iBAAiB,CAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAWvF;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,EAAE,EAAE,YAAY,CAAC,gBAAgB,CAAC,EAClC,GAAG,GAAE,IAAiB,GACrB,OAAO,CAAC,eAAe,CAAC,CAM1B"}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.V7IdbBackfillDriver = void 0;
4
- exports.runV7IdbBackfill = runV7IdbBackfill;
5
- const v7Backfill_runner_1 = require("./v7Backfill.runner");
6
- const BACKFILL_STORES = [
7
- 'proven_tx_reqs',
8
- 'proven_txs',
9
- 'transactions',
10
- 'transactions_v7',
11
- 'actions',
12
- 'tx_labels_map'
13
- ];
14
- /**
15
- * IndexedDB driver for the V7 backfill.
16
- *
17
- * The orchestrator is driven entirely from this driver inside a single
18
- * `readwrite` transaction across the legacy + V7 stores. The streams cache
19
- * the keys up-front (`getAllKeys`) and then walk them one at a time so the
20
- * idb cursor lifetime does not span an external `await`.
21
- */
22
- class V7IdbBackfillDriver {
23
- constructor(trx) {
24
- this.trx = trx;
25
- }
26
- async *streamLegacyReqs() {
27
- const reqStore = this.trx.objectStore('proven_tx_reqs');
28
- const provenStore = this.trx.objectStore('proven_txs');
29
- const reqKeys = await reqStore.getAllKeys();
30
- for (const key of reqKeys) {
31
- const req = await reqStore.get(key);
32
- let proven;
33
- if (req.provenTxId != null)
34
- proven = await provenStore.get(req.provenTxId);
35
- yield { req, proven };
36
- }
37
- }
38
- async *streamLegacyTransactions() {
39
- const store = this.trx.objectStore('transactions');
40
- const keys = await store.getAllKeys();
41
- for (const key of keys) {
42
- const row = await store.get(key);
43
- yield row;
44
- }
45
- }
46
- async upsertTransactionV7(row) {
47
- const store = this.trx.objectStore('transactions_v7');
48
- const txidIndex = store.index('txid');
49
- const existing = await txidIndex.get(row.txid);
50
- if (existing != null) {
51
- const merged = { ...existing, ...row, transactionId: existing.transactionId };
52
- await store.put(merged);
53
- return existing.transactionId;
54
- }
55
- const newId = await store.add(row);
56
- return newId;
57
- }
58
- async upsertAction(row) {
59
- const store = this.trx.objectStore('actions');
60
- const idx = store.index('userId_transactionId');
61
- const existing = await idx.get([row.userId, row.transactionId]);
62
- if (existing != null) {
63
- const merged = { ...existing, ...row, actionId: existing.actionId };
64
- await store.put(merged);
65
- return existing.actionId;
66
- }
67
- const newId = await store.add(row);
68
- return newId;
69
- }
70
- async repointTxLabelMap(legacyTransactionId, actionId) {
71
- if (legacyTransactionId === actionId)
72
- return;
73
- const store = this.trx.objectStore('tx_labels_map');
74
- const idx = store.index('transactionId');
75
- const matches = await idx.getAll(legacyTransactionId);
76
- for (const m of matches) {
77
- const updated = { ...m, transactionId: actionId };
78
- await store.delete([m.txLabelId, legacyTransactionId]);
79
- await store.add(updated);
80
- }
81
- }
82
- }
83
- exports.V7IdbBackfillDriver = V7IdbBackfillDriver;
84
- /**
85
- * Convenience entry point that opens the required readwrite transaction and
86
- * runs the orchestrator against it.
87
- */
88
- async function runV7IdbBackfill(db, now = new Date()) {
89
- const trx = db.transaction(BACKFILL_STORES, 'readwrite');
90
- const driver = new V7IdbBackfillDriver(trx);
91
- const stats = await (0, v7Backfill_runner_1.runV7Backfill)(driver, now);
92
- await trx.done;
93
- return stats;
94
- }
95
- //# sourceMappingURL=v7Backfill.idb.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Backfill.idb.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Backfill.idb.ts"],"names":[],"mappings":";;;AAmGA,4CASC;AAnGD,2DAAsF;AAItF,MAAM,eAAe,GAAmB;IACtC,gBAAgC;IAChC,YAA4B;IAC5B,cAA8B;IAC9B,iBAAiC;IACjC,SAAyB;IACzB,eAA+B;CAChC,CAAA;AAED;;;;;;;GAOG;AACH,MAAa,mBAAmB;IAC9B,YACmB,GAAmE;QAAnE,QAAG,GAAH,GAAG,CAAgE;IACnF,CAAC;IAEJ,KAAK,CAAC,CAAE,gBAAgB;QACtB,MAAM,QAAQ,GAAI,IAAI,CAAC,GAAG,CAAC,WAAmB,CAAC,gBAAgB,CAAC,CAAA;QAChE,MAAM,WAAW,GAAI,IAAI,CAAC,GAAG,CAAC,WAAmB,CAAC,YAAY,CAAC,CAAA;QAC/D,MAAM,OAAO,GAAa,MAAM,QAAQ,CAAC,UAAU,EAAE,CAAA;QACrD,KAAK,MAAM,GAAG,IAAI,OAAO,EAAE,CAAC;YAC1B,MAAM,GAAG,GAAqB,MAAM,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;YACrD,IAAI,MAAiC,CAAA;YACrC,IAAI,GAAG,CAAC,UAAU,IAAI,IAAI;gBAAE,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;YAC1E,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;QACvB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAE,wBAAwB;QAC9B,MAAM,KAAK,GAAI,IAAI,CAAC,GAAG,CAAC,WAAmB,CAAC,cAAc,CAAC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Aa,EAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9C,MAAM,GAAG,CAAC,IAAI,CAAA;IACd,OAAO,KAAK,CAAA;AACd,CAAC"}
@@ -1,147 +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.buildTransactionV7Row = buildTransactionV7Row;
37
- exports.buildTransactionV7RowFromLegacyTx = buildTransactionV7RowFromLegacyTx;
38
- exports.buildActionRow = buildActionRow;
39
- const sdk = __importStar(require("../../sdk"));
40
- /**
41
- * Pure transformation helpers for the V7 schema backfill.
42
- *
43
- * These functions are deliberately storage-agnostic — they accept the legacy
44
- * rows and return the new shapes. A storage driver (Knex or IDB) is responsible
45
- * for reading the source rows and inserting the returned objects.
46
- *
47
- * No row in this module ever talks to the database; this keeps the
48
- * transformation under unit-test control and lets us run dry-run migrations.
49
- */
50
- /**
51
- * Merge a legacy `proven_tx_reqs` row together with an optional `proven_txs`
52
- * row into a single V7 `transactions` (transactions_v7) row.
53
- *
54
- * The proof fields come from `proven_txs` when present; otherwise they are
55
- * left undefined. Processing state is derived from the request's legacy status.
56
- */
57
- function buildTransactionV7Row(req, proven, now = new Date()) {
58
- var _a, _b, _c;
59
- const processing = sdk.provenTxReqStatusToProcessing(req.status);
60
- return {
61
- created_at: req.created_at,
62
- updated_at: now,
63
- txid: req.txid,
64
- processing,
65
- processingChangedAt: (_a = req.updated_at) !== null && _a !== void 0 ? _a : now,
66
- nextActionAt: undefined,
67
- attempts: (_b = req.attempts) !== null && _b !== void 0 ? _b : 0,
68
- rebroadcastCycles: (_c = req.rebroadcastAttempts) !== null && _c !== void 0 ? _c : 0,
69
- wasBroadcast: req.wasBroadcast === true,
70
- idempotencyKey: undefined,
71
- batch: req.batch,
72
- rawTx: req.rawTx,
73
- inputBeef: req.inputBEEF,
74
- height: proven === null || proven === void 0 ? void 0 : proven.height,
75
- merkleIndex: proven === null || proven === void 0 ? void 0 : proven.index,
76
- merklePath: proven === null || proven === void 0 ? void 0 : proven.merklePath,
77
- merkleRoot: proven === null || proven === void 0 ? void 0 : proven.merkleRoot,
78
- blockHash: proven === null || proven === void 0 ? void 0 : proven.blockHash,
79
- isCoinbase: false,
80
- lastProvider: undefined,
81
- lastProviderStatus: undefined,
82
- frozenReason: undefined,
83
- rowVersion: 0
84
- };
85
- }
86
- /**
87
- * Build a V7 `transactions` row from a legacy per-user `transactions` row when
88
- * no `proven_tx_reqs` entry exists (e.g. locally-created actions that never
89
- * reached the broadcast queue).
90
- *
91
- * Returns `undefined` when the legacy row has no txid — such rows belong to
92
- * incomplete actions and have no canonical V7 representation yet.
93
- */
94
- function buildTransactionV7RowFromLegacyTx(tx, now = new Date()) {
95
- var _a;
96
- if (tx.txid == null)
97
- return undefined;
98
- return {
99
- created_at: tx.created_at,
100
- updated_at: now,
101
- txid: tx.txid,
102
- processing: sdk.transactionStatusToProcessing(tx.status),
103
- processingChangedAt: (_a = tx.updated_at) !== null && _a !== void 0 ? _a : now,
104
- nextActionAt: undefined,
105
- attempts: 0,
106
- rebroadcastCycles: 0,
107
- wasBroadcast: false,
108
- idempotencyKey: undefined,
109
- batch: undefined,
110
- rawTx: tx.rawTx,
111
- inputBeef: tx.inputBEEF,
112
- height: undefined,
113
- merkleIndex: undefined,
114
- merklePath: undefined,
115
- merkleRoot: undefined,
116
- blockHash: undefined,
117
- isCoinbase: false,
118
- lastProvider: undefined,
119
- lastProviderStatus: undefined,
120
- frozenReason: undefined,
121
- rowVersion: 0
122
- };
123
- }
124
- /**
125
- * Build a V7 `actions` row from a legacy per-user `transactions` row.
126
- * The caller is responsible for resolving `transactionId` to the
127
- * newly-inserted `transactions_v7.transactionId`.
128
- */
129
- function buildActionRow(legacy, v7TransactionId, now = new Date()) {
130
- var _a;
131
- return {
132
- created_at: legacy.created_at,
133
- updated_at: now,
134
- userId: legacy.userId,
135
- transactionId: v7TransactionId,
136
- reference: legacy.reference,
137
- description: legacy.description,
138
- isOutgoing: legacy.isOutgoing,
139
- satoshisDelta: (_a = legacy.satoshis) !== null && _a !== void 0 ? _a : 0,
140
- userNosend: legacy.status === 'nosend',
141
- hidden: false,
142
- userAborted: legacy.status === 'failed',
143
- notifyJson: undefined,
144
- rowVersion: 0
145
- };
146
- }
147
- //# sourceMappingURL=v7Backfill.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Backfill.js","sourceRoot":"","sources":["../../../../src/storage/schema/v7Backfill.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,sDA+BC;AAUD,8EA8BC;AAOD,wCAoBC;AA7HD,+CAAgC;AAShC;;;;;;;;;GASG;AAEH;;;;;;GAMG;AACH,SAAgB,qBAAqB,CACnC,GAAqB,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;QACvC,UAAU,EAAE,SAAS;QACrB,UAAU,EAAE,CAAC;KACd,CAAA;AACH,CAAC"}
@@ -1,32 +0,0 @@
1
- import { Knex } from 'knex';
2
- import { TableAction, TableProvenTx, TableProvenTxReq, TableTransaction, TableTransactionV7 } from './tables';
3
- import { V7BackfillDriver, V7BackfillStats } from './v7Backfill.runner';
4
- /**
5
- * Knex driver for the V7 backfill.
6
- *
7
- * Reads from the legacy `proven_tx_reqs`, `proven_txs`, and `transactions`
8
- * tables, writes into the new `transactions_v7` and `actions` tables, and
9
- * re-points `tx_labels_map` rows to the new `actionId`.
10
- *
11
- * All work is performed against the `knex` (or transaction) handle passed in.
12
- * The caller is responsible for opening a transaction around the orchestrator
13
- * call when atomicity is desired.
14
- */
15
- export declare class V7KnexBackfillDriver implements V7BackfillDriver {
16
- private readonly knex;
17
- constructor(knex: Knex);
18
- streamLegacyReqs(): AsyncIterable<{
19
- req: TableProvenTxReq;
20
- proven?: TableProvenTx;
21
- }>;
22
- streamLegacyTransactions(): AsyncIterable<TableTransaction>;
23
- upsertTransactionV7(row: Omit<TableTransactionV7, 'transactionId'>): Promise<number>;
24
- upsertAction(row: Omit<TableAction, 'actionId'>): Promise<number>;
25
- repointTxLabelMap(legacyTransactionId: number, actionId: number): Promise<void>;
26
- }
27
- /**
28
- * Convenience entry point. Opens a Knex transaction and runs the orchestrator
29
- * inside it so that the entire backfill either succeeds or rolls back.
30
- */
31
- export declare function runV7KnexBackfill(knex: Knex, now?: Date): Promise<V7BackfillStats>;
32
- //# sourceMappingURL=v7Backfill.knex.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v7Backfill.knex.d.ts","sourceRoot":"","sources":["../../../../src/storage/schema/v7Backfill.knex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAC3B,OAAO,EACL,WAAW,EACX,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAiB,gBAAgB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAItF;;;;;;;;;;GAUG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI;IAEhC,gBAAgB,IAAK,aAAa,CAAC;QAAE,GAAG,EAAE,gBAAgB,CAAC;QAAC,MAAM,CAAC,EAAE,aAAa,CAAA;KAAE,CAAC;IA6DrF,wBAAwB,IAAK,aAAa,CAAC,gBAAgB,CAAC;IAiC9D,mBAAmB,CAAE,GAAG,EAAE,IAAI,CAAC,kBAAkB,EAAE,eAAe,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IAuDrF,YAAY,CAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;IA0ClE,iBAAiB,CAAE,mBAAmB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAMvF;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAE,IAAI,EAAE,IAAI,EAAE,GAAG,GAAE,IAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAKrG"}