@dvmkit/sdk 0.1.0-rc.1 → 0.1.0-rc.3

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 (42) hide show
  1. package/README.md +10 -2
  2. package/dist/{revenue-reporter-M35KP6V7.js → chunk-2ABMGUDS.js} +78 -2
  3. package/dist/chunk-5SO7ZVOH.js +375 -0
  4. package/dist/chunk-66HGCPBU.js +25 -0
  5. package/dist/{chunk-KQAJVVZT.js → chunk-AZBXSXQT.js} +27 -287
  6. package/dist/chunk-C2DC4FKR.js +21424 -0
  7. package/dist/{chunk-H25M54MI.js → chunk-C3MTFLC6.js} +16 -0
  8. package/dist/{chunk-NTK5DJ6R.js → chunk-EXHBXA4U.js} +11 -1
  9. package/dist/chunk-FT7IM66W.js +1557 -0
  10. package/dist/{chunk-KXWROQGK.js → chunk-FUJ36YDV.js} +1 -24
  11. package/dist/{tempo-charge-store-6GJEMNUU.js → chunk-JZWELPFH.js} +1 -0
  12. package/dist/{chunk-RPXHKMYE.js → chunk-LWUR4CGG.js} +348 -34
  13. package/dist/chunk-RHP3BRTH.js +1090 -0
  14. package/dist/{tempo-session-store-FTEEGZXA.js → chunk-RU7SXHLO.js} +2 -1
  15. package/dist/{chunk-7IH5SG2A.js → chunk-TKA6ZP4M.js} +62 -41
  16. package/dist/chunk-TVI4V7GF.js +283 -0
  17. package/dist/chunk-X3IKFWJA.js +754 -0
  18. package/dist/{chunk-DCNT4PJS.js → chunk-XY5Y5REG.js} +6 -258
  19. package/dist/chunk-XYTSDAPH.js +232 -0
  20. package/dist/chunk-YD3TZNXV.js +1042 -0
  21. package/dist/{credit-ledger-EDMEZSA2.js → credit-ledger-ED6JXKVD.js} +2 -2
  22. package/dist/credit-menu-DONAtGVf.d.ts +5076 -0
  23. package/dist/{ssrf-BdHsrrIb.d.ts → fx-Bq4cvn16.d.ts} +37 -119
  24. package/dist/index.d.ts +8 -66
  25. package/dist/index.js +11 -219
  26. package/dist/internal/index.d.ts +5745 -0
  27. package/dist/internal/index.js +6379 -0
  28. package/dist/{job-store-C5n6bhap.d.ts → job-store-m2pYmvbr.d.ts} +1772 -31
  29. package/dist/{memory-credit-ledger-7TTZDSRS.js → memory-credit-ledger-XJ5VQEVP.js} +3 -3
  30. package/dist/payout-reporter-3UB5WRCV.js +13 -0
  31. package/dist/revenue-reporter-JIKUPXOK.js +7 -0
  32. package/dist/server/index.d.ts +14 -3530
  33. package/dist/server/index.js +327 -20636
  34. package/dist/ssrf-DbFkpDv0.d.ts +118 -0
  35. package/dist/tempo-charge-store-RIFTALZK.js +8 -0
  36. package/dist/tempo-session-store-DALMRIWN.js +11 -0
  37. package/dist/testing/index.d.ts +3 -2
  38. package/dist/testing/index.js +3 -2
  39. package/dist/usd-DjVAPMlf.d.ts +97 -0
  40. package/dist/x402-5EVIUSEP.js +81 -0
  41. package/package.json +6 -2
  42. package/dist/x402-35VLYFKZ.js +0 -1272
@@ -11,6 +11,21 @@ function isTransportError(err) {
11
11
  if (typeof code === "string" && /^[0-9A-Z]{5}$/.test(code)) return false;
12
12
  return typeof msg === "string" && msg.includes("Connection terminated") || code === "ECONNRESET" || code === "ENOTFOUND";
13
13
  }
14
+ async function withInitRetry(fn, label, delays = [1e3, 4e3, 15e3]) {
15
+ for (let attempt = 0; ; attempt++) {
16
+ try {
17
+ await fn();
18
+ return;
19
+ } catch (err) {
20
+ if (!isTransportError(err) || attempt >= delays.length) throw err;
21
+ const wait = delays[attempt];
22
+ console.warn(
23
+ `[${label}] DB init attempt ${attempt + 1} failed (${err.message}), retrying in ${wait / 1e3}s`
24
+ );
25
+ await new Promise((resolve) => setTimeout(resolve, wait));
26
+ }
27
+ }
28
+ }
14
29
  var POSTGRES_APPLICATION_NAME_MAX_BYTES = 63;
15
30
  function formatPostgresApplicationName(label, machineId = process.env.FLY_MACHINE_ID) {
16
31
  const machineSuffix = machineId ? `@${machineId}` : "";
@@ -144,6 +159,7 @@ function truncateUtf8(value, maxBytes) {
144
159
 
145
160
  export {
146
161
  withPostgresRecoveryContext,
162
+ withInitRetry,
147
163
  applyRetryToPool,
148
164
  withPostgresTransactionRecovery
149
165
  };
@@ -15,7 +15,7 @@ import {
15
15
  lotOwedSats,
16
16
  netOwedSats,
17
17
  x402SettlementPending
18
- } from "./chunk-RPXHKMYE.js";
18
+ } from "./chunk-LWUR4CGG.js";
19
19
 
20
20
  // src/sdk/server/memory-credit-ledger.ts
21
21
  import { randomUUID } from "crypto";
@@ -702,6 +702,16 @@ var MemoryCreditLedger = class {
702
702
  const observedAt = evidence.observedAt ?? Date.now();
703
703
  for (const credit of this.credits.values()) {
704
704
  if (credit.x402ChannelId !== channelId) continue;
705
+ const hasLiability = credit.balanceMicro > 0 || [...credit.drains.values()].some(
706
+ (drain) => drain.status === "pending" || drain.status === "parked"
707
+ );
708
+ if (!hasLiability) {
709
+ if (credit.status === "unbacked") {
710
+ credit.status = "active";
711
+ this.x402Losses.delete(credit.creditId);
712
+ }
713
+ continue;
714
+ }
705
715
  if (credit.status === "unbacked") continue;
706
716
  const consumedServiceMicro = [...credit.draws.values()].filter((draw) => draw.status === "settled").reduce((sum, draw) => sum + draw.amountMicro, 0);
707
717
  this.x402Losses.set(credit.creditId, {