@fantastic.dev/better-stripe 0.57.0 → 0.59.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 (230) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +356 -50
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +162 -9
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +356 -50
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +162 -9
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/usage/allowanceClient.d.ts +51 -0
  12. package/dist/client/usage/allowanceClient.d.ts.map +1 -0
  13. package/dist/client/usage/allowanceClient.js +64 -0
  14. package/dist/client/usage/allowanceClient.js.map +1 -0
  15. package/dist/client/usage/allowanceTerms.d.ts +64 -0
  16. package/dist/client/usage/allowanceTerms.d.ts.map +1 -0
  17. package/dist/client/usage/allowanceTerms.js +101 -0
  18. package/dist/client/usage/allowanceTerms.js.map +1 -0
  19. package/dist/client/usage/client.d.ts +2 -2
  20. package/dist/client/usage/client.d.ts.map +1 -1
  21. package/dist/client/usage/client.js +2 -2
  22. package/dist/client/usage/client.js.map +1 -1
  23. package/dist/client/usage/correctionClient.d.ts +33 -0
  24. package/dist/client/usage/correctionClient.d.ts.map +1 -0
  25. package/dist/client/usage/correctionClient.js +27 -0
  26. package/dist/client/usage/correctionClient.js.map +1 -0
  27. package/dist/client/usage/correctionEligibility.d.ts +4 -0
  28. package/dist/client/usage/correctionEligibility.d.ts.map +1 -0
  29. package/dist/client/usage/correctionEligibility.js +7 -0
  30. package/dist/client/usage/correctionEligibility.js.map +1 -0
  31. package/dist/client/usage/correctionInvoice.d.ts +9 -0
  32. package/dist/client/usage/correctionInvoice.d.ts.map +1 -0
  33. package/dist/client/usage/correctionInvoice.js +218 -0
  34. package/dist/client/usage/correctionInvoice.js.map +1 -0
  35. package/dist/client/usage/correctionInvoiceProof.d.ts +29 -0
  36. package/dist/client/usage/correctionInvoiceProof.d.ts.map +1 -0
  37. package/dist/client/usage/correctionInvoiceProof.js +41 -0
  38. package/dist/client/usage/correctionInvoiceProof.js.map +1 -0
  39. package/dist/client/usage/correctionProofs.d.ts +36 -0
  40. package/dist/client/usage/correctionProofs.d.ts.map +1 -0
  41. package/dist/client/usage/correctionProofs.js +41 -0
  42. package/dist/client/usage/correctionProofs.js.map +1 -0
  43. package/dist/client/usage/correctionProvider.d.ts +6 -0
  44. package/dist/client/usage/correctionProvider.d.ts.map +1 -0
  45. package/dist/client/usage/correctionProvider.js +243 -0
  46. package/dist/client/usage/correctionProvider.js.map +1 -0
  47. package/dist/client/usage/correctionRead.d.ts +27 -0
  48. package/dist/client/usage/correctionRead.d.ts.map +1 -0
  49. package/dist/client/usage/correctionRead.js +36 -0
  50. package/dist/client/usage/correctionRead.js.map +1 -0
  51. package/dist/client/usage/correctionTerms.d.ts +64 -0
  52. package/dist/client/usage/correctionTerms.d.ts.map +1 -0
  53. package/dist/client/usage/correctionTerms.js +65 -0
  54. package/dist/client/usage/correctionTerms.js.map +1 -0
  55. package/dist/client/usage/correctionTransport.fixtures.d.ts +37 -0
  56. package/dist/client/usage/correctionTransport.fixtures.d.ts.map +1 -0
  57. package/dist/client/usage/correctionTransport.fixtures.js +322 -0
  58. package/dist/client/usage/correctionTransport.fixtures.js.map +1 -0
  59. package/dist/client/usage/creditClient.d.ts +1 -1
  60. package/dist/client/usage/index.d.ts +4 -0
  61. package/dist/client/usage/index.d.ts.map +1 -1
  62. package/dist/client/usage/observationClient.d.ts +20 -0
  63. package/dist/client/usage/observationClient.d.ts.map +1 -1
  64. package/dist/client/usage/observationClient.js +20 -6
  65. package/dist/client/usage/observationClient.js.map +1 -1
  66. package/dist/client/usage/records.d.ts +1 -1
  67. package/dist/client/usage/records.d.ts.map +1 -1
  68. package/dist/client/usage/records.js.map +1 -1
  69. package/dist/client/usage/summary.d.ts +3 -0
  70. package/dist/client/usage/summary.d.ts.map +1 -1
  71. package/dist/client/usage/summary.js +9 -4
  72. package/dist/client/usage/summary.js.map +1 -1
  73. package/dist/client/usageExports.d.ts +4 -0
  74. package/dist/client/usageExports.d.ts.map +1 -1
  75. package/dist/component/_generated/api.d.ts +20 -0
  76. package/dist/component/_generated/api.d.ts.map +1 -1
  77. package/dist/component/_generated/api.js.map +1 -1
  78. package/dist/component/_generated/component.d.ts +324 -13
  79. package/dist/component/_generated/component.d.ts.map +1 -1
  80. package/dist/component/accountClosure/mutations.d.ts.map +1 -1
  81. package/dist/component/accountClosure/mutations.js +13 -0
  82. package/dist/component/accountClosure/mutations.js.map +1 -1
  83. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  84. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  85. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  86. package/dist/component/earnings/triggers.d.ts +288 -10
  87. package/dist/component/earnings/triggers.d.ts.map +1 -1
  88. package/dist/component/schema.d.ts +162 -9
  89. package/dist/component/schema.js +7 -0
  90. package/dist/component/schema.js.map +1 -1
  91. package/dist/component/usage/mutations.d.ts.map +1 -1
  92. package/dist/component/usage/mutations.js +4 -0
  93. package/dist/component/usage/mutations.js.map +1 -1
  94. package/dist/component/usage/queries.d.ts +2 -2
  95. package/dist/component/usage/schema.d.ts +21 -15
  96. package/dist/component/usage/schema.d.ts.map +1 -1
  97. package/dist/component/usage/schema.js +4 -2
  98. package/dist/component/usage/schema.js.map +1 -1
  99. package/dist/component/usageAllowance/helpers.d.ts +78 -0
  100. package/dist/component/usageAllowance/helpers.d.ts.map +1 -0
  101. package/dist/component/usageAllowance/helpers.js +99 -0
  102. package/dist/component/usageAllowance/helpers.js.map +1 -0
  103. package/dist/component/usageAllowance/mutations.d.ts +37 -0
  104. package/dist/component/usageAllowance/mutations.d.ts.map +1 -0
  105. package/dist/component/usageAllowance/mutations.js +99 -0
  106. package/dist/component/usageAllowance/mutations.js.map +1 -0
  107. package/dist/component/usageAllowance/queries.d.ts +36 -0
  108. package/dist/component/usageAllowance/queries.d.ts.map +1 -0
  109. package/dist/component/usageAllowance/queries.js +122 -0
  110. package/dist/component/usageAllowance/queries.js.map +1 -0
  111. package/dist/component/usageAllowance/reservations.d.ts +25 -0
  112. package/dist/component/usageAllowance/reservations.d.ts.map +1 -0
  113. package/dist/component/usageAllowance/reservations.js +150 -0
  114. package/dist/component/usageAllowance/reservations.js.map +1 -0
  115. package/dist/component/usageAllowance/schema.d.ts +77 -0
  116. package/dist/component/usageAllowance/schema.d.ts.map +1 -0
  117. package/dist/component/usageAllowance/schema.js +32 -0
  118. package/dist/component/usageAllowance/schema.js.map +1 -0
  119. package/dist/component/usageCorrections/accounting.d.ts +5 -0
  120. package/dist/component/usageCorrections/accounting.d.ts.map +1 -0
  121. package/dist/component/usageCorrections/accounting.js +55 -0
  122. package/dist/component/usageCorrections/accounting.js.map +1 -0
  123. package/dist/component/usageCorrections/cancellation.d.ts +6 -0
  124. package/dist/component/usageCorrections/cancellation.d.ts.map +1 -0
  125. package/dist/component/usageCorrections/cancellation.js +29 -0
  126. package/dist/component/usageCorrections/cancellation.js.map +1 -0
  127. package/dist/component/usageCorrections/helpers.d.ts +60 -0
  128. package/dist/component/usageCorrections/helpers.d.ts.map +1 -0
  129. package/dist/component/usageCorrections/helpers.js +52 -0
  130. package/dist/component/usageCorrections/helpers.js.map +1 -0
  131. package/dist/component/usageCorrections/invoice.d.ts +38 -0
  132. package/dist/component/usageCorrections/invoice.d.ts.map +1 -0
  133. package/dist/component/usageCorrections/invoice.js +82 -0
  134. package/dist/component/usageCorrections/invoice.js.map +1 -0
  135. package/dist/component/usageCorrections/mutations.d.ts +121 -0
  136. package/dist/component/usageCorrections/mutations.d.ts.map +1 -0
  137. package/dist/component/usageCorrections/mutations.js +256 -0
  138. package/dist/component/usageCorrections/mutations.js.map +1 -0
  139. package/dist/component/usageCorrections/queries.d.ts +115 -0
  140. package/dist/component/usageCorrections/queries.d.ts.map +1 -0
  141. package/dist/component/usageCorrections/queries.js +84 -0
  142. package/dist/component/usageCorrections/queries.js.map +1 -0
  143. package/dist/component/usageCorrections/schema.d.ts +248 -0
  144. package/dist/component/usageCorrections/schema.d.ts.map +1 -0
  145. package/dist/component/usageCorrections/schema.js +74 -0
  146. package/dist/component/usageCorrections/schema.js.map +1 -0
  147. package/dist/component/usageCredits/queries.d.ts +1 -1
  148. package/dist/component/usageCredits/queries.d.ts.map +1 -1
  149. package/dist/component/usageCredits/queries.js +6 -0
  150. package/dist/component/usageCredits/queries.js.map +1 -1
  151. package/dist/component/usageCredits/schema.d.ts +5 -5
  152. package/dist/component/usageCredits/schema.d.ts.map +1 -1
  153. package/dist/component/usageCredits/schema.js +1 -1
  154. package/dist/component/usageCredits/schema.js.map +1 -1
  155. package/dist/component/usageDelivery/fields.d.ts +2 -2
  156. package/dist/component/usageDelivery/fields.d.ts.map +1 -1
  157. package/dist/component/usageDelivery/fields.js +1 -1
  158. package/dist/component/usageDelivery/fields.js.map +1 -1
  159. package/dist/component/usageDelivery/helpers.d.ts +7 -6
  160. package/dist/component/usageDelivery/helpers.d.ts.map +1 -1
  161. package/dist/component/usageDelivery/mutations.d.ts +6 -6
  162. package/dist/component/usageDelivery/mutations.d.ts.map +1 -1
  163. package/dist/component/usageDelivery/mutations.js +9 -1
  164. package/dist/component/usageDelivery/mutations.js.map +1 -1
  165. package/dist/component/usageDelivery/queries.d.ts +8 -6
  166. package/dist/component/usageDelivery/queries.d.ts.map +1 -1
  167. package/dist/component/usageDelivery/schema.d.ts +4 -4
  168. package/dist/component/usageDelivery/steps.d.ts +2 -2
  169. package/dist/component/usageDelivery/steps.js +1 -1
  170. package/dist/component/usageDelivery/steps.js.map +1 -1
  171. package/dist/component/usageObservations/queries.d.ts.map +1 -1
  172. package/dist/component/usageObservations/queries.js +4 -2
  173. package/dist/component/usageObservations/queries.js.map +1 -1
  174. package/dist/component/usageSubscriptions/retirement.d.ts.map +1 -1
  175. package/dist/component/usageSubscriptions/retirement.js +24 -2
  176. package/dist/component/usageSubscriptions/retirement.js.map +1 -1
  177. package/docs/README.md +4 -0
  178. package/docs/usage-corrections.md +249 -0
  179. package/docs/usage-limits.md +217 -0
  180. package/package.json +3 -1
  181. package/src/client/usage/allowanceClient.test.ts +93 -0
  182. package/src/client/usage/allowanceClient.ts +134 -0
  183. package/src/client/usage/allowanceTerms.test.ts +131 -0
  184. package/src/client/usage/allowanceTerms.ts +172 -0
  185. package/src/client/usage/client.ts +2 -2
  186. package/src/client/usage/correctionClient.test.ts +153 -0
  187. package/src/client/usage/correctionClient.ts +62 -0
  188. package/src/client/usage/correctionCredits.test.ts +156 -0
  189. package/src/client/usage/correctionEligibility.ts +14 -0
  190. package/src/client/usage/correctionInvoice.test.ts +127 -0
  191. package/src/client/usage/correctionInvoice.ts +269 -0
  192. package/src/client/usage/correctionInvoiceProof.ts +40 -0
  193. package/src/client/usage/correctionProofs.ts +40 -0
  194. package/src/client/usage/correctionProvider.ts +326 -0
  195. package/src/client/usage/correctionRead.ts +73 -0
  196. package/src/client/usage/correctionRecovery.test.ts +113 -0
  197. package/src/client/usage/correctionTerms.ts +98 -0
  198. package/src/client/usage/correctionTransport.fixtures.ts +372 -0
  199. package/src/client/usage/index.ts +19 -0
  200. package/src/client/usage/observationClient.ts +20 -6
  201. package/src/client/usage/records.ts +7 -1
  202. package/src/client/usage/summary.ts +12 -4
  203. package/src/client/usageExports.ts +19 -0
  204. package/src/component/_generated/api.ts +20 -0
  205. package/src/component/_generated/component.ts +423 -1
  206. package/src/component/accountClosure/mutations.ts +17 -0
  207. package/src/component/schema.ts +14 -0
  208. package/src/component/usage/allowance.test.ts +435 -0
  209. package/src/component/usage/mutations.ts +13 -0
  210. package/src/component/usage/schema.ts +6 -1
  211. package/src/component/usageAllowance/helpers.ts +137 -0
  212. package/src/component/usageAllowance/mutations.ts +139 -0
  213. package/src/component/usageAllowance/queries.ts +140 -0
  214. package/src/component/usageAllowance/reservations.ts +220 -0
  215. package/src/component/usageAllowance/schema.ts +37 -0
  216. package/src/component/usageCorrections/accounting.ts +79 -0
  217. package/src/component/usageCorrections/cancellation.ts +32 -0
  218. package/src/component/usageCorrections/corrections.test.ts +389 -0
  219. package/src/component/usageCorrections/helpers.ts +57 -0
  220. package/src/component/usageCorrections/invoice.ts +103 -0
  221. package/src/component/usageCorrections/mutations.ts +278 -0
  222. package/src/component/usageCorrections/queries.ts +94 -0
  223. package/src/component/usageCorrections/schema.ts +90 -0
  224. package/src/component/usageCredits/queries.ts +4 -0
  225. package/src/component/usageCredits/schema.ts +1 -0
  226. package/src/component/usageDelivery/fields.ts +1 -0
  227. package/src/component/usageDelivery/mutations.ts +8 -3
  228. package/src/component/usageDelivery/steps.ts +1 -1
  229. package/src/component/usageObservations/queries.ts +5 -2
  230. package/src/component/usageSubscriptions/retirement.ts +31 -2
@@ -0,0 +1,150 @@
1
+ import { prepareUsageRecord, } from "../../client/usage/records.js";
2
+ import { allowanceStatus, limitPolicy, } from "../../client/usage/allowanceTerms.js";
3
+ import { parseUsageQuantity } from "../../client/usage/contracts.js";
4
+ import { subscriptionSnapshot, scopeKey } from "../usage/helpers.js";
5
+ import { terms, json, canonical, policyRow, active, history, overlapping, scopeOverlap, configuredScope, } from "./helpers.js";
6
+ export async function reserve(ctx, inputJson, subscriptionJson) {
7
+ const event = prepareUsageRecord(json(inputJson)), subscription = subscriptionSnapshot(subscriptionJson), original = terms({
8
+ scope: event.scope,
9
+ binding: event.binding,
10
+ subscription,
11
+ });
12
+ const input = canonical(event), sub = canonical(subscription);
13
+ const prior = await ctx.db
14
+ .query("usageReservations")
15
+ .withIndex("by_scope_source", (q) => q
16
+ .eq("scopeKey", original.scopeKey)
17
+ .eq("sourceEventId", event.sourceEventId))
18
+ .unique();
19
+ if (prior) {
20
+ if (prior.accountingKind !== "allowance" ||
21
+ prior.inputJson !== input ||
22
+ prior.subscriptionJson !== sub)
23
+ throw new Error("Allowance reservation replay conflict");
24
+ return {
25
+ reservationId: prior._id,
26
+ state: prior.state,
27
+ revision: Number(prior.allocationsJson),
28
+ };
29
+ }
30
+ const accepted = await ctx.db
31
+ .query("usageEvents")
32
+ .withIndex("by_identity", (q) => q.eq("identity", event.identity))
33
+ .unique();
34
+ if (accepted)
35
+ throw new Error("Accepted usage cannot be reserved again");
36
+ const row = await policyRow(ctx, original.key);
37
+ if (!row || row.bindingJson !== original.bindingJson)
38
+ throw new Error("Allowance policy unavailable");
39
+ await active(ctx, original.binding, event);
40
+ const policy = limitPolicy(JSON.parse(row.policyJson), original.binding), status = allowanceStatus(original.binding, policy, row, Math.floor(Date.now() / 1000));
41
+ if (!policy.entitled)
42
+ return {
43
+ state: "denied",
44
+ reason: "not_entitled",
45
+ revision: row.revision,
46
+ };
47
+ if (status.hardLimitRemainingQuantity !== null &&
48
+ BigInt(event.scaledQuantity) >
49
+ BigInt(parseUsageQuantity(status.hardLimitRemainingQuantity, event.binding.plan.unit.precision).scaledQuantity))
50
+ return {
51
+ state: "denied",
52
+ reason: "hard_limit",
53
+ revision: row.revision,
54
+ };
55
+ const reserved = BigInt(row.reserved) + BigInt(event.scaledQuantity);
56
+ if (reserved + BigInt(row.consumed) > 999999999999999999n)
57
+ throw new Error("Allowance accounting quantity bound exceeded");
58
+ const reservationId = await ctx.db.insert("usageReservations", {
59
+ scopeKey: original.scopeKey,
60
+ sourceEventId: event.sourceEventId,
61
+ planJson: JSON.stringify(event.binding.plan),
62
+ scaledQuantity: event.scaledQuantity,
63
+ state: "reserved",
64
+ accountingKind: "allowance",
65
+ accountKey: row.key,
66
+ inputJson: input,
67
+ subscriptionJson: sub,
68
+ allocationsJson: String(row.revision),
69
+ });
70
+ await ctx.db.patch("usageAllowancePolicies", row._id, {
71
+ reserved: reserved.toString(),
72
+ });
73
+ await history(ctx, row, "reservation", {
74
+ reservationId,
75
+ event,
76
+ subscription,
77
+ revision: row.revision,
78
+ });
79
+ return { reservationId, state: "reserved", revision: row.revision };
80
+ }
81
+ export async function requireReservation(ctx, event, subscription, reservation) {
82
+ if (event.binding.plan.model === "prepaid")
83
+ return;
84
+ const original = terms({
85
+ scope: event.scope,
86
+ binding: event.binding,
87
+ subscription,
88
+ });
89
+ const row = (await overlapping(ctx, original.nativeKey, subscription.period)) ??
90
+ (await scopeOverlap(ctx, original.scopeKey, subscription.period));
91
+ if (!row && (await configuredScope(ctx, original)))
92
+ throw new Error("New allowance period requires policy configuration and reservation");
93
+ if (row &&
94
+ (row.bindingJson !== original.bindingJson ||
95
+ !reservation ||
96
+ reservation.accountingKind !== "allowance" ||
97
+ reservation.accountKey !== row.key))
98
+ throw new Error("Matching allowance reservation required");
99
+ }
100
+ export async function commit(ctx, reservation, event, subscription, eventId) {
101
+ if (reservation.accountingKind !== "allowance" ||
102
+ !reservation.accountKey ||
103
+ reservation.inputJson !== canonical(event) ||
104
+ reservation.subscriptionJson !== canonical(subscription))
105
+ throw new Error("Allowance reservation provenance mismatch");
106
+ const row = await policyRow(ctx, reservation.accountKey);
107
+ if (!row || BigInt(row.reserved) < BigInt(reservation.scaledQuantity))
108
+ throw new Error("Allowance reservation backing unavailable");
109
+ await ctx.db.patch("usageAllowancePolicies", row._id, {
110
+ reserved: (BigInt(row.reserved) - BigInt(reservation.scaledQuantity)).toString(),
111
+ consumed: (BigInt(row.consumed) + BigInt(reservation.scaledQuantity)).toString(),
112
+ });
113
+ await history(ctx, row, "commit", {
114
+ reservationId: reservation._id,
115
+ eventId,
116
+ revision: Number(reservation.allocationsJson),
117
+ scaledQuantity: reservation.scaledQuantity,
118
+ });
119
+ }
120
+ export async function release(ctx, scope, reservationId, reason) {
121
+ const row = await ctx.db.get("usageReservations", reservationId);
122
+ if (!row ||
123
+ row.scopeKey !== scopeKey(scope) ||
124
+ row.accountingKind !== "allowance" ||
125
+ !row.accountKey)
126
+ throw new Error("Allowance reservation unavailable");
127
+ if (row.state === "committed" || row.eventId)
128
+ throw new Error("Committed usage requires an auditable correction");
129
+ if (row.state === "released") {
130
+ if (row.releaseReason !== reason)
131
+ throw new Error("Allowance release replay conflict");
132
+ return;
133
+ }
134
+ const policy = await policyRow(ctx, row.accountKey);
135
+ if (!policy || BigInt(policy.reserved) < BigInt(row.scaledQuantity))
136
+ throw new Error("Allowance reservation invariant violated");
137
+ await ctx.db.patch("usageAllowancePolicies", policy._id, {
138
+ reserved: (BigInt(policy.reserved) - BigInt(row.scaledQuantity)).toString(),
139
+ });
140
+ await ctx.db.patch("usageReservations", row._id, {
141
+ state: "released",
142
+ releaseReason: reason,
143
+ });
144
+ await history(ctx, policy, "release", {
145
+ reservationId,
146
+ reason,
147
+ scaledQuantity: row.scaledQuantity,
148
+ });
149
+ }
150
+ //# sourceMappingURL=reservations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reservations.js","sourceRoot":"","sources":["../../../src/component/usageAllowance/reservations.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,kBAAkB,GAGnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,eAAe,EACf,WAAW,GACZ,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,KAAK,EACL,IAAI,EACJ,SAAS,EACT,SAAS,EACT,MAAM,EACN,OAAO,EACP,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,GAAgB,EAChB,SAAiB,EACjB,gBAAwB;IAExB,MAAM,KAAK,GAAG,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAC/C,YAAY,GAAG,oBAAoB,CAAC,gB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,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC9D,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,wBAAwB,EAAE,MAAM,CAAC,GAAG,EAAE;QACvD,QAAQ,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE;KAC5E,CAAC,CAAC;IACH,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,GAAG,EAAE;QAC/C,KAAK,EAAE,UAAU;QACjB,aAAa,EAAE,MAAM;KACtB,CAAC,CAAC;IACH,MAAM,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE;QACpC,aAAa;QACb,MAAM;QACN,cAAc,EAAE,GAAG,CAAC,cAAc;KACnC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,77 @@
1
+ export declare const fields: {
2
+ key: import("convex/values").VString<string, "required">;
3
+ nativeKey: import("convex/values").VString<string, "required">;
4
+ scopeKey: import("convex/values").VString<string, "required">;
5
+ bindingJson: import("convex/values").VString<string, "required">;
6
+ start: import("convex/values").VFloat64<number, "required">;
7
+ end: import("convex/values").VFloat64<number, "required">;
8
+ policyJson: import("convex/values").VString<string, "required">;
9
+ revision: import("convex/values").VFloat64<number, "required">;
10
+ consumed: import("convex/values").VString<string, "required">;
11
+ reserved: import("convex/values").VString<string, "required">;
12
+ historyCount: import("convex/values").VFloat64<number, "required">;
13
+ };
14
+ export declare const policiesTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
15
+ bindingJson: string;
16
+ consumed: string;
17
+ end: number;
18
+ historyCount: number;
19
+ key: string;
20
+ nativeKey: string;
21
+ policyJson: string;
22
+ reserved: string;
23
+ revision: number;
24
+ scopeKey: string;
25
+ start: number;
26
+ }, {
27
+ key: import("convex/values").VString<string, "required">;
28
+ nativeKey: import("convex/values").VString<string, "required">;
29
+ scopeKey: import("convex/values").VString<string, "required">;
30
+ bindingJson: import("convex/values").VString<string, "required">;
31
+ start: import("convex/values").VFloat64<number, "required">;
32
+ end: import("convex/values").VFloat64<number, "required">;
33
+ policyJson: import("convex/values").VString<string, "required">;
34
+ revision: import("convex/values").VFloat64<number, "required">;
35
+ consumed: import("convex/values").VString<string, "required">;
36
+ reserved: import("convex/values").VString<string, "required">;
37
+ historyCount: import("convex/values").VFloat64<number, "required">;
38
+ }, "required", "bindingJson" | "consumed" | "end" | "historyCount" | "key" | "nativeKey" | "policyJson" | "reserved" | "revision" | "scopeKey" | "start">, {
39
+ by_key: ["key", "_creationTime"];
40
+ by_native_start: ["nativeKey", "start", "_creationTime"];
41
+ by_scope_start: ["scopeKey", "start", "_creationTime"];
42
+ }, {}, {}>;
43
+ export declare const historyFields: {
44
+ key: import("convex/values").VString<string, "required">;
45
+ kind: import("convex/values").VUnion<"commit" | "correction" | "policy" | "release" | "reservation", [import("convex/values").VLiteral<"policy", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"correction", "required">], "required", never>;
46
+ evidenceJson: import("convex/values").VString<string, "required">;
47
+ at: import("convex/values").VFloat64<number, "required">;
48
+ };
49
+ export declare const historyDoc: import("convex/values").VObject<{
50
+ _creationTime: number;
51
+ _id: import("convex/values").GenericId<"usageAllowanceHistory">;
52
+ at: number;
53
+ evidenceJson: string;
54
+ key: string;
55
+ kind: "commit" | "correction" | "policy" | "release" | "reservation";
56
+ }, {
57
+ key: import("convex/values").VString<string, "required">;
58
+ kind: import("convex/values").VUnion<"commit" | "correction" | "policy" | "release" | "reservation", [import("convex/values").VLiteral<"policy", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"correction", "required">], "required", never>;
59
+ evidenceJson: import("convex/values").VString<string, "required">;
60
+ at: import("convex/values").VFloat64<number, "required">;
61
+ _id: import("convex/values").VId<import("convex/values").GenericId<"usageAllowanceHistory">, "required">;
62
+ _creationTime: import("convex/values").VFloat64<number, "required">;
63
+ }, "required", "_creationTime" | "_id" | "at" | "evidenceJson" | "key" | "kind">;
64
+ export declare const historyTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
65
+ at: number;
66
+ evidenceJson: string;
67
+ key: string;
68
+ kind: "commit" | "correction" | "policy" | "release" | "reservation";
69
+ }, {
70
+ key: import("convex/values").VString<string, "required">;
71
+ kind: import("convex/values").VUnion<"commit" | "correction" | "policy" | "release" | "reservation", [import("convex/values").VLiteral<"policy", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"correction", "required">], "required", never>;
72
+ evidenceJson: import("convex/values").VString<string, "required">;
73
+ at: import("convex/values").VFloat64<number, "required">;
74
+ }, "required", "at" | "evidenceJson" | "key" | "kind">, {
75
+ by_key: ["key", "_creationTime"];
76
+ }, {}, {}>;
77
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/usageAllowance/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;IACjB,GAAG;IACH,SAAS;IACT,QAAQ;IACR,WAAW;IACX,KAAK;IACL,GAAG;IACH,UAAU;IACV,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,YAAY;CACb,CAAC;AACF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAGuB,CAAC;AAClD,eAAO,MAAM,aAAa;IACxB,GAAG;IACH,IAAI;IAOJ,YAAY;IACZ,EAAE;CACH,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;gFAIrB,CAAC;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;UAAsD,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ export const fields = {
4
+ key: v.string(),
5
+ nativeKey: v.string(),
6
+ scopeKey: v.string(),
7
+ bindingJson: v.string(),
8
+ start: v.number(),
9
+ end: v.number(),
10
+ policyJson: v.string(),
11
+ revision: v.number(),
12
+ consumed: v.string(),
13
+ reserved: v.string(),
14
+ historyCount: v.number(),
15
+ };
16
+ export const policiesTable = defineTable(fields)
17
+ .index("by_key", ["key"])
18
+ .index("by_native_start", ["nativeKey", "start"])
19
+ .index("by_scope_start", ["scopeKey", "start"]);
20
+ export const historyFields = {
21
+ key: v.string(),
22
+ kind: v.union(v.literal("policy"), v.literal("reservation"), v.literal("commit"), v.literal("release"), v.literal("correction")),
23
+ evidenceJson: v.string(),
24
+ at: v.number(),
25
+ };
26
+ export const historyDoc = v.object({
27
+ _id: v.id("usageAllowanceHistory"),
28
+ _creationTime: v.number(),
29
+ ...historyFields,
30
+ });
31
+ export const historyTable = defineTable(historyFields).index("by_key", ["key"]);
32
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/usageAllowance/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACv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AAa,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { MutationCtx } from "../_generated/server.js";
2
+ import type { Doc } from "../_generated/dataModel.js";
3
+ /** Called only for a full proven cancellation, in the same transaction as the terminal receipt. */
4
+ export declare function restore(ctx: MutationCtx, correction: Doc<"usageCorrections">, event: Doc<"usageEvents">): Promise<void>;
5
+ //# sourceMappingURL=accounting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounting.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/accounting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAOtD,mGAAmG;AACnG,wBAAsB,OAAO,CAC3B,GAAG,EAAE,WAAW,EAChB,UAAU,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACnC,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,iBAkE1B"}
@@ -0,0 +1,55 @@
1
+ import { creditAllocations } from "../usageCredits/reservations.js";
2
+ import { account, history as creditHistory } from "../usageCredits/helpers.js";
3
+ import { policyRow, history as allowanceHistory, } from "../usageAllowance/helpers.js";
4
+ /** Called only for a full proven cancellation, in the same transaction as the terminal receipt. */
5
+ export async function restore(ctx, correction, event) {
6
+ if (!event.reservationId)
7
+ return;
8
+ const reservation = await ctx.db.get("usageReservations", event.reservationId);
9
+ if (!reservation ||
10
+ reservation.state !== "committed" ||
11
+ reservation.eventId !== event._id ||
12
+ reservation.scopeKey !== correction.scopeKey ||
13
+ reservation.scaledQuantity !== correction.scaledQuantity)
14
+ throw new Error("Correction reservation provenance mismatch");
15
+ if (reservation.accountingKind === "allowance") {
16
+ const policy = await policyRow(ctx, reservation.accountKey);
17
+ if (!policy || BigInt(policy.consumed) < BigInt(correction.scaledQuantity))
18
+ throw new Error("Correction allowance backing unavailable");
19
+ await ctx.db.patch("usageAllowancePolicies", policy._id, {
20
+ consumed: (BigInt(policy.consumed) - BigInt(correction.scaledQuantity)).toString(),
21
+ });
22
+ await allowanceHistory(ctx, policy, "correction", {
23
+ correctionKey: correction.key,
24
+ eventId: event._id,
25
+ scaledQuantity: correction.scaledQuantity,
26
+ cashCollection: "none",
27
+ });
28
+ }
29
+ else if (reservation.accountingKind === "prepaid") {
30
+ const ledger = await account(ctx, reservation.accountKey);
31
+ if (ledger.closed || ledger.frozenReason)
32
+ throw new Error("Correction credit account requires reconciliation");
33
+ const allocations = creditAllocations.parse(JSON.parse(reservation.allocationsJson));
34
+ for (const allocation of allocations) {
35
+ const grant = await ctx.db.get("usageCreditGrants", allocation.grantId);
36
+ if (!grant ||
37
+ grant.accountKey !== ledger.key ||
38
+ grant.frozen ||
39
+ grant.nativeExpired ||
40
+ (grant.expiresAt !== null && grant.expiresAt <= Date.now() / 1000) ||
41
+ BigInt(grant.consumed) < BigInt(allocation.quantity))
42
+ throw new Error("Correction original credit backing unavailable");
43
+ await ctx.db.patch("usageCreditGrants", grant._id, {
44
+ consumed: (BigInt(grant.consumed) - BigInt(allocation.quantity)).toString(),
45
+ available: (BigInt(grant.available) + BigInt(allocation.quantity)).toString(),
46
+ });
47
+ }
48
+ await creditHistory(ctx, ledger.key, "correction", correction.key, {
49
+ eventId: event._id,
50
+ allocations,
51
+ cashCollection: "none",
52
+ });
53
+ }
54
+ }
55
+ //# sourceMappingURL=accounting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounting.js","sourceRoot":"","sources":["../../../src/component/usageCorrections/accounting.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EACL,SAAS,EACT,OAAO,IAAI,gBAAgB,GAC5B,MAAM,8BAA8B,CAAC;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AAC,QAAQ,CAAC,CACtD,CAAC,QAAQ,EAAE;aACb,CAAC,CAAC;QACL,CAAC;QACD,MAAM,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,UAAU,CAAC,GAAG,EAAE;YACjE,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,WAAW;YACX,cAAc,EAAE,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { QueryCtx } from "../_generated/server.js";
2
+ import type { Doc } from "../_generated/dataModel.js";
3
+ /** Never treat an unproven terminal projection as canceled billable quantity. */
4
+ export declare function verifiedCancellation(ctx: QueryCtx, event: Doc<"usageEvents">, outbox: Doc<"usageOutbox"> | null): Promise<"confirmed" | "none" | "unverified">;
5
+ export declare const unresolvedCorrectionStates: readonly ["requested", "provider_accepted", "held", "invoice_adjustment_required"];
6
+ //# sourceMappingURL=cancellation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellation.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/cancellation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AACtD,iFAAiF;AACjF,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,QAAQ,EACb,KAAK,EAAE,GAAG,CAAC,aAAa,CAAC,EACzB,MAAM,EAAE,GAAG,CAAC,aAAa,CAAC,GAAG,IAAI,gDAmBlC;AACD,eAAO,MAAM,0BAA0B,YACrC,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,6BAA6B,CACrB,CAAC"}
@@ -0,0 +1,29 @@
1
+ /** Never treat an unproven terminal projection as canceled billable quantity. */
2
+ export async function verifiedCancellation(ctx, event, outbox) {
3
+ if (outbox?.state !== "canceled")
4
+ return "none";
5
+ if (!outbox.correctionKey)
6
+ return "unverified";
7
+ const correction = await ctx.db
8
+ .query("usageCorrections")
9
+ .withIndex("by_key", (q) => q.eq("key", outbox.correctionKey))
10
+ .unique();
11
+ const record = JSON.parse(event.recordJson);
12
+ return correction?.state === "confirmed" &&
13
+ correction.resolution !== "invoice_credit" &&
14
+ correction.eventId === event._id &&
15
+ correction.scopeKey === event.scopeKey &&
16
+ correction.recordJson === event.recordJson &&
17
+ correction.subscriptionJson === event.subscriptionJson &&
18
+ correction.scaledQuantity === record.scaledQuantity &&
19
+ correction.restoredQuantity === record.quantity
20
+ ? "confirmed"
21
+ : "unverified";
22
+ }
23
+ export const unresolvedCorrectionStates = [
24
+ "requested",
25
+ "provider_accepted",
26
+ "held",
27
+ "invoice_adjustment_required",
28
+ ];
29
+ //# sourceMappingURL=cancellation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cancellation.js","sourceRoot":"","sources":["../../../src/component/usageCorrections/cancellation.ts"],"names":[],"mappings":"AAEA,iFAAiF;AACjF,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,GAAa,EACb,KAAyB,EACzB,MAAiC;IAEjC,IAAI,MAAM,EAAE,KAAK,KAAK,UAAU;QAAE,OAAO,MAAe,CAAC;IACzD,IAAI,CAAC,MAAM,CAAC,aAAa;QAAE,OAAO,YAAqB,CAAC;IACxD,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,EAAE;SAC5B,KAAK,CAAC,kBAAkB,CAAC;SACzB,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,aAAc,CAAC,CAAC;SAC9D,MAAM,EAAE,CAAC;IACZ,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC5C,OAAO,UAAU,EAAE,KAAK,KAAK,WAAW;QACtC,UAAU,CAAC,UAAU,KAAK,gBAAgB;QAC1C,UAAU,CAAC,OAAO,KAAK,KAAK,CAAC,GAAG;QAChC,UAAU,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ;QACtC,UAAU,CAAC,UAAU,KAAK,KAAK,CAAC,UAAU;QAC1C,UAAU,CAAC,gBAAgB,KAAK,KAAK,CAAC,gBAAgB;QACtD,UAAU,CAAC,cAAc,KAAK,MAAM,CAAC,cAAc;QACnD,UAAU,CAAC,gBAAgB,KAAK,MAAM,CAAC,QAAQ;QAC/C,CAAC,CAAE,WAAqB;QACxB,CAAC,CAAE,YAAsB,CAAC;AAC9B,CAAC;AACD,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,WAAW;IACX,mBAAmB;IACnB,MAAM;IACN,6BAA6B;CACrB,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { Value } from "convex/values";
2
+ import type { MutationCtx, QueryCtx } from "../_generated/server.js";
3
+ import type { Doc } from "../_generated/dataModel.js";
4
+ export declare const canonical: (value: Value) => string;
5
+ export declare function json(text: string): unknown;
6
+ export declare function input(text: string): Promise<{
7
+ request: {
8
+ scope: {
9
+ stripeAccountId: string;
10
+ customerAccount: string;
11
+ meterId: string;
12
+ livemode: boolean;
13
+ };
14
+ eventId: string;
15
+ correctionId: string;
16
+ actor: string;
17
+ reason: string;
18
+ operation: "cancel";
19
+ quantity?: string | undefined;
20
+ };
21
+ inputJson: string;
22
+ scopeKey: string;
23
+ key: string;
24
+ }>;
25
+ export declare function operation(ctx: QueryCtx, key: string): Promise<{
26
+ _creationTime: number;
27
+ _id: import("convex/values").GenericId<"usageCorrections">;
28
+ adjustmentJson?: string | undefined;
29
+ attempt: number;
30
+ attemptedAt?: number | undefined;
31
+ cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
32
+ correctionId: string;
33
+ creditNoteId?: string | undefined;
34
+ customerAccount?: string | undefined;
35
+ eventId: import("convex/values").GenericId<"usageEvents">;
36
+ firstAttemptAt: number;
37
+ historyCount: number;
38
+ inputJson: string;
39
+ invoiceId?: string | undefined;
40
+ key: string;
41
+ leaseUntil?: number | undefined;
42
+ nativeAdjustmentId?: string | undefined;
43
+ nativeCreditNoteStatus?: "issued" | "void" | undefined;
44
+ nativeStatus?: "complete" | "pending" | undefined;
45
+ observedAt?: number | undefined;
46
+ quantity: string;
47
+ reason: string;
48
+ recordJson: string;
49
+ refundId?: string | undefined;
50
+ resolution?: "event_cancellation" | "invoice_credit" | undefined;
51
+ restoredQuantity: string;
52
+ scaledQuantity: string;
53
+ scopeKey: string;
54
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
55
+ stripeAccountId?: string | undefined;
56
+ subscriptionJson: string;
57
+ }>;
58
+ export { correctionView as view } from "../../client/usage/correctionTerms.js";
59
+ export declare function history(ctx: MutationCtx, original: Doc<"usageCorrections">, evidence: Value): Promise<void>;
60
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAItD,eAAO,MAAM,SAAS,UAAW,KAAK,WAAwC,CAAC;AAC/E,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAGJ,OAAO,CACnC;AACD,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM;;;;;;;;;;;;;;;;;;GAQvC;AACD,wBAAsB,SAAS,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAOzD;AACD,OAAO,EAAE,cAAc,IAAI,IAAI,EAAE,MAAM,uCAAuC,CAAC;AAC/E,wBAAsB,OAAO,CAC3B,GAAG,EAAE,WAAW,EAChB,QAAQ,EAAE,GAAG,CAAC,kBAAkB,CAAC,EACjC,QAAQ,EAAE,KAAK,iBAsBhB"}
@@ -0,0 +1,52 @@
1
+ import { convexToJson } from "convex/values";
2
+ import { correctionRequest } from "../../client/usage/correctionTerms.js";
3
+ import { canonicalFingerprint } from "../operationEvidence/canonical.js";
4
+ import { scopeKey } from "../usage/helpers.js";
5
+ export const canonical = (value) => JSON.stringify(convexToJson(value));
6
+ export function json(text) {
7
+ if (new TextEncoder().encode(text).length > 8192)
8
+ throw new Error("Correction payload exceeds size limit");
9
+ return JSON.parse(text);
10
+ }
11
+ export async function input(text) {
12
+ const request = correctionRequest.parse(json(text));
13
+ return {
14
+ request,
15
+ inputJson: canonical(request),
16
+ scopeKey: scopeKey(request.scope),
17
+ key: await canonicalFingerprint([request.scope, request.correctionId]),
18
+ };
19
+ }
20
+ export async function operation(ctx, key) {
21
+ const row = await ctx.db
22
+ .query("usageCorrections")
23
+ .withIndex("by_key", (q) => q.eq("key", key))
24
+ .unique();
25
+ if (!row)
26
+ throw new Error("Usage correction unavailable");
27
+ return row;
28
+ }
29
+ export { correctionView as view } from "../../client/usage/correctionTerms.js";
30
+ export async function history(ctx, original, evidence) {
31
+ const row = await operation(ctx, original.key);
32
+ if (row.historyCount >= 1000)
33
+ throw new Error("Correction history quota exhausted");
34
+ await ctx.db.insert("usageCorrectionHistory", {
35
+ key: row.key,
36
+ scopeKey: row.scopeKey,
37
+ eventId: row.eventId,
38
+ sequence: row.historyCount + 1,
39
+ state: row.state,
40
+ reason: row.reason,
41
+ recordJson: row.recordJson,
42
+ subscriptionJson: row.subscriptionJson,
43
+ evidenceJson: canonical(evidence),
44
+ occurredAt: JSON.parse(row.recordJson).occurredAt,
45
+ at: Math.floor(Date.now() / 1000),
46
+ });
47
+ await ctx.db.patch("usageCorrections", row._id, {
48
+ historyCount: row.historyCount + 1,
49
+ observedAt: Math.floor(Date.now() / 1000),
50
+ });
51
+ }
52
+ //# sourceMappingURL=helpers.js.map
@@ -0,0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AC,YAAY,GAAG,CAAC;QAClC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;KAC1C,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { MutationCtx } from "../_generated/server.js";
2
+ export declare function adoptInvoiceCorrection(ctx: MutationCtx, args: {
3
+ key: string;
4
+ proofJson: string;
5
+ }): Promise<{
6
+ _creationTime: number;
7
+ _id: import("convex/values").GenericId<"usageCorrections">;
8
+ adjustmentJson?: string | undefined;
9
+ attempt: number;
10
+ attemptedAt?: number | undefined;
11
+ cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
12
+ correctionId: string;
13
+ creditNoteId?: string | undefined;
14
+ customerAccount?: string | undefined;
15
+ eventId: import("convex/values").GenericId<"usageEvents">;
16
+ firstAttemptAt: number;
17
+ historyCount: number;
18
+ inputJson: string;
19
+ invoiceId?: string | undefined;
20
+ key: string;
21
+ leaseUntil?: number | undefined;
22
+ nativeAdjustmentId?: string | undefined;
23
+ nativeCreditNoteStatus?: "issued" | "void" | undefined;
24
+ nativeStatus?: "complete" | "pending" | undefined;
25
+ observedAt?: number | undefined;
26
+ quantity: string;
27
+ reason: string;
28
+ recordJson: string;
29
+ refundId?: string | undefined;
30
+ resolution?: "event_cancellation" | "invoice_credit" | undefined;
31
+ restoredQuantity: string;
32
+ scaledQuantity: string;
33
+ scopeKey: string;
34
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
35
+ stripeAccountId?: string | undefined;
36
+ subscriptionJson: string;
37
+ }>;
38
+ //# sourceMappingURL=invoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/invoice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAK3D,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+FzC"}