@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
@@ -9,6 +9,156 @@ export declare const scope: {
9
9
  };
10
10
  export declare function setup(amounts?: number[], currency?: string): Promise<{
11
11
  t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
12
+ usageCorrectionClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
13
+ key: string;
14
+ operationKey: string;
15
+ proofJson: string;
16
+ }, {
17
+ key: import("convex/values").VString<string, "required">;
18
+ operationKey: import("convex/values").VString<string, "required">;
19
+ proofJson: import("convex/values").VString<string, "required">;
20
+ }, "required", "key" | "operationKey" | "proofJson">, {
21
+ by_key: ["key", "_creationTime"];
22
+ }, {}, {}>;
23
+ usageCorrections: import("convex/server").TableDefinition<import("convex/values").VObject<{
24
+ adjustmentJson?: string | undefined;
25
+ attempt: number;
26
+ attemptedAt?: number | undefined;
27
+ cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
28
+ correctionId: string;
29
+ creditNoteId?: string | undefined;
30
+ customerAccount?: string | undefined;
31
+ eventId: import("convex/values").GenericId<"usageEvents">;
32
+ firstAttemptAt: number;
33
+ historyCount: number;
34
+ inputJson: string;
35
+ invoiceId?: string | undefined;
36
+ key: string;
37
+ leaseUntil?: number | undefined;
38
+ nativeAdjustmentId?: string | undefined;
39
+ nativeCreditNoteStatus?: "issued" | "void" | undefined;
40
+ nativeStatus?: "complete" | "pending" | undefined;
41
+ observedAt?: number | undefined;
42
+ quantity: string;
43
+ reason: string;
44
+ recordJson: string;
45
+ refundId?: string | undefined;
46
+ resolution?: "event_cancellation" | "invoice_credit" | undefined;
47
+ restoredQuantity: string;
48
+ scaledQuantity: string;
49
+ scopeKey: string;
50
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
51
+ stripeAccountId?: string | undefined;
52
+ subscriptionJson: string;
53
+ }, {
54
+ stripeAccountId: import("convex/values").VString<string | undefined, "optional">;
55
+ customerAccount: import("convex/values").VString<string | undefined, "optional">;
56
+ observedAt: import("convex/values").VFloat64<number | undefined, "optional">;
57
+ nativeCreditNoteStatus: import("convex/values").VUnion<"issued" | "void" | undefined, [import("convex/values").VLiteral<"issued", "required">, import("convex/values").VLiteral<"void", "required">], "optional", never>;
58
+ resolution: import("convex/values").VUnion<"event_cancellation" | "invoice_credit" | undefined, [import("convex/values").VLiteral<"event_cancellation", "required">, import("convex/values").VLiteral<"invoice_credit", "required">], "optional", never>;
59
+ adjustmentJson: import("convex/values").VString<string | undefined, "optional">;
60
+ key: import("convex/values").VString<string, "required">;
61
+ scopeKey: import("convex/values").VString<string, "required">;
62
+ eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
63
+ correctionId: import("convex/values").VString<string, "required">;
64
+ inputJson: import("convex/values").VString<string, "required">;
65
+ recordJson: import("convex/values").VString<string, "required">;
66
+ subscriptionJson: import("convex/values").VString<string, "required">;
67
+ quantity: import("convex/values").VString<string, "required">;
68
+ scaledQuantity: import("convex/values").VString<string, "required">;
69
+ state: import("convex/values").VUnion<"confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported", [import("convex/values").VLiteral<"requested", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"confirmed", "required">, import("convex/values").VLiteral<"held", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"invoice_adjustment_required", "required">], "required", never>;
70
+ reason: import("convex/values").VString<string, "required">;
71
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
72
+ attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
73
+ leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
74
+ attempt: import("convex/values").VFloat64<number, "required">;
75
+ nativeAdjustmentId: import("convex/values").VString<string | undefined, "optional">;
76
+ nativeStatus: import("convex/values").VUnion<"complete" | "pending" | undefined, [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"complete", "required">], "optional", never>;
77
+ invoiceId: import("convex/values").VString<string | undefined, "optional">;
78
+ creditNoteId: import("convex/values").VString<string | undefined, "optional">;
79
+ refundId: import("convex/values").VString<string | undefined, "optional">;
80
+ cashConsequence: import("convex/values").VUnion<"none" | "operator_resolution_required" | "verified_external_adjustment", [import("convex/values").VLiteral<"none", "required">, import("convex/values").VLiteral<"operator_resolution_required", "required">, import("convex/values").VLiteral<"verified_external_adjustment", "required">], "required", never>;
81
+ restoredQuantity: import("convex/values").VString<string, "required">;
82
+ historyCount: import("convex/values").VFloat64<number, "required">;
83
+ }, "required", "adjustmentJson" | "attempt" | "attemptedAt" | "cashConsequence" | "correctionId" | "creditNoteId" | "customerAccount" | "eventId" | "firstAttemptAt" | "historyCount" | "inputJson" | "invoiceId" | "key" | "leaseUntil" | "nativeAdjustmentId" | "nativeCreditNoteStatus" | "nativeStatus" | "observedAt" | "quantity" | "reason" | "recordJson" | "refundId" | "resolution" | "restoredQuantity" | "scaledQuantity" | "scopeKey" | "state" | "stripeAccountId" | "subscriptionJson">, {
84
+ by_event: ["eventId", "_creationTime"];
85
+ by_key: ["key", "_creationTime"];
86
+ by_payer_state: ["customerAccount", "state", "_creationTime"];
87
+ by_realm_state: ["stripeAccountId", "state", "_creationTime"];
88
+ by_scope: ["scopeKey", "_creationTime"];
89
+ by_scope_state: ["scopeKey", "state", "_creationTime"];
90
+ }, {}, {}>;
91
+ usageCorrectionHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
92
+ at: number;
93
+ eventId: import("convex/values").GenericId<"usageEvents">;
94
+ evidenceJson: string;
95
+ key: string;
96
+ occurredAt?: number | undefined;
97
+ reason: string;
98
+ recordJson: string;
99
+ scopeKey: string;
100
+ sequence: number;
101
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
102
+ subscriptionJson: string;
103
+ }, {
104
+ key: import("convex/values").VString<string, "required">;
105
+ scopeKey: import("convex/values").VString<string, "required">;
106
+ eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
107
+ sequence: import("convex/values").VFloat64<number, "required">;
108
+ state: import("convex/values").VUnion<"confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported", [import("convex/values").VLiteral<"requested", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"confirmed", "required">, import("convex/values").VLiteral<"held", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"invoice_adjustment_required", "required">], "required", never>;
109
+ reason: import("convex/values").VString<string, "required">;
110
+ recordJson: import("convex/values").VString<string, "required">;
111
+ subscriptionJson: import("convex/values").VString<string, "required">;
112
+ evidenceJson: import("convex/values").VString<string, "required">;
113
+ occurredAt: import("convex/values").VFloat64<number | undefined, "optional">;
114
+ at: import("convex/values").VFloat64<number, "required">;
115
+ }, "required", "at" | "eventId" | "evidenceJson" | "key" | "occurredAt" | "reason" | "recordJson" | "scopeKey" | "sequence" | "state" | "subscriptionJson">, {
116
+ by_event: ["eventId", "_creationTime"];
117
+ by_scope_occurrence: ["scopeKey", "occurredAt", "_creationTime"];
118
+ by_scope_time: ["scopeKey", "at", "_creationTime"];
119
+ }, {}, {}>;
120
+ usageAllowancePolicies: import("convex/server").TableDefinition<import("convex/values").VObject<{
121
+ bindingJson: string;
122
+ consumed: string;
123
+ end: number;
124
+ historyCount: number;
125
+ key: string;
126
+ nativeKey: string;
127
+ policyJson: string;
128
+ reserved: string;
129
+ revision: number;
130
+ scopeKey: string;
131
+ start: number;
132
+ }, {
133
+ key: import("convex/values").VString<string, "required">;
134
+ nativeKey: import("convex/values").VString<string, "required">;
135
+ scopeKey: import("convex/values").VString<string, "required">;
136
+ bindingJson: import("convex/values").VString<string, "required">;
137
+ start: import("convex/values").VFloat64<number, "required">;
138
+ end: import("convex/values").VFloat64<number, "required">;
139
+ policyJson: import("convex/values").VString<string, "required">;
140
+ revision: import("convex/values").VFloat64<number, "required">;
141
+ consumed: import("convex/values").VString<string, "required">;
142
+ reserved: import("convex/values").VString<string, "required">;
143
+ historyCount: import("convex/values").VFloat64<number, "required">;
144
+ }, "required", "bindingJson" | "consumed" | "end" | "historyCount" | "key" | "nativeKey" | "policyJson" | "reserved" | "revision" | "scopeKey" | "start">, {
145
+ by_key: ["key", "_creationTime"];
146
+ by_native_start: ["nativeKey", "start", "_creationTime"];
147
+ by_scope_start: ["scopeKey", "start", "_creationTime"];
148
+ }, {}, {}>;
149
+ usageAllowanceHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
150
+ at: number;
151
+ evidenceJson: string;
152
+ key: string;
153
+ kind: "commit" | "correction" | "policy" | "release" | "reservation";
154
+ }, {
155
+ key: import("convex/values").VString<string, "required">;
156
+ 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>;
157
+ evidenceJson: import("convex/values").VString<string, "required">;
158
+ at: import("convex/values").VFloat64<number, "required">;
159
+ }, "required", "at" | "evidenceJson" | "key" | "kind">, {
160
+ by_key: ["key", "_creationTime"];
161
+ }, {}, {}>;
12
162
  usageSubscriptionControls: import("convex/server").TableDefinition<import("convex/values").VObject<{
13
163
  cancelAtPeriodEnd: boolean;
14
164
  firstAttemptAt: number;
@@ -210,6 +360,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
210
360
  }, {}, {}>;
211
361
  usageOutbox: import("convex/server").TableDefinition<import("convex/values").VObject<{
212
362
  attempts: number;
363
+ correctionKey?: string | undefined;
213
364
  definitionVersion?: 1 | undefined;
214
365
  dispatch?: string | undefined;
215
366
  eventId: import("convex/values").GenericId<"usageEvents">;
@@ -220,13 +371,13 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
220
371
  nextAttemptAt: number;
221
372
  provider?: string | undefined;
222
373
  providerIdentifier: string;
223
- reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
374
+ reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | "usage_canceled" | undefined;
224
375
  receipt?: {
225
376
  created: number;
226
377
  identifier: string;
227
378
  } | undefined;
228
379
  scopeKey: string;
229
- state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
380
+ state: "canceled" | "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
230
381
  workflowId?: string | undefined;
231
382
  }, {
232
383
  historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
@@ -236,7 +387,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
236
387
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
237
388
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
238
389
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
239
- reason: import("convex/values").VUnion<"administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [import("convex/values").VLiteral<"billing_period_closed", "required">, import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "optional", never>;
390
+ reason: import("convex/values").VUnion<"administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | "usage_canceled" | undefined, [import("convex/values").VLiteral<"usage_canceled", "required">, import("convex/values").VLiteral<"billing_period_closed", "required">, import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "optional", never>;
240
391
  receipt: import("convex/values").VObject<{
241
392
  created: number;
242
393
  identifier: string;
@@ -244,14 +395,15 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
244
395
  identifier: import("convex/values").VString<string, "required">;
245
396
  created: import("convex/values").VFloat64<number, "required">;
246
397
  }, "optional", "created" | "identifier">;
398
+ correctionKey: import("convex/values").VString<string | undefined, "optional">;
247
399
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
248
400
  scopeKey: import("convex/values").VString<string, "required">;
249
- state: import("convex/values").VUnion<"held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown", [import("convex/values").VLiteral<"queued", "required">, import("convex/values").VLiteral<"sending", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"rejected", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
401
+ state: import("convex/values").VUnion<"canceled" | "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown", [import("convex/values").VLiteral<"queued", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"sending", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"rejected", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
250
402
  attempts: import("convex/values").VFloat64<number, "required">;
251
403
  nextAttemptAt: import("convex/values").VFloat64<number, "required">;
252
404
  providerIdentifier: import("convex/values").VString<string, "required">;
253
405
  dispatch: import("convex/values").VString<string | undefined, "optional">;
254
- }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
406
+ }, "required", "attempts" | "correctionKey" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
255
407
  by_event: ["eventId", "_creationTime"];
256
408
  by_provider_identifier: ["providerIdentifier", "_creationTime"];
257
409
  by_scope_state: ["scopeKey", "state", "_creationTime"];
@@ -268,7 +420,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
268
420
  }, {}, {}>;
269
421
  usageReservations: import("convex/server").TableDefinition<import("convex/values").VObject<{
270
422
  accountKey?: string | undefined;
271
- accountingKind?: "prepaid" | undefined;
423
+ accountingKind?: "allowance" | "prepaid" | undefined;
272
424
  allocationsJson?: string | undefined;
273
425
  eventId?: import("convex/values").GenericId<"usageEvents"> | undefined;
274
426
  inputJson?: string | undefined;
@@ -286,13 +438,14 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
286
438
  scaledQuantity: import("convex/values").VString<string, "required">;
287
439
  state: import("convex/values").VUnion<"committed" | "released" | "reserved", [import("convex/values").VLiteral<"reserved", "required">, import("convex/values").VLiteral<"committed", "required">, import("convex/values").VLiteral<"released", "required">], "required", never>;
288
440
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents"> | undefined, "optional">;
289
- accountingKind: import("convex/values").VLiteral<"prepaid" | undefined, "optional">;
441
+ accountingKind: import("convex/values").VUnion<"allowance" | "prepaid" | undefined, [import("convex/values").VLiteral<"prepaid", "required">, import("convex/values").VLiteral<"allowance", "required">], "optional", never>;
290
442
  accountKey: import("convex/values").VString<string | undefined, "optional">;
291
443
  inputJson: import("convex/values").VString<string | undefined, "optional">;
292
444
  subscriptionJson: import("convex/values").VString<string | undefined, "optional">;
293
445
  allocationsJson: import("convex/values").VString<string | undefined, "optional">;
294
446
  releaseReason: import("convex/values").VString<string | undefined, "optional">;
295
447
  }, "required", "accountKey" | "accountingKind" | "allocationsJson" | "eventId" | "inputJson" | "planJson" | "releaseReason" | "scaledQuantity" | "scopeKey" | "sourceEventId" | "state" | "subscriptionJson">, {
448
+ by_account_state: ["accountKey", "state", "_creationTime"];
296
449
  by_scope_source: ["scopeKey", "sourceEventId", "_creationTime"];
297
450
  by_scope_state: ["scopeKey", "state", "_creationTime"];
298
451
  }, {}, {}>;
@@ -406,13 +559,13 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
406
559
  at: number;
407
560
  evidenceJson: string;
408
561
  fingerprint: string;
409
- kind: "closure" | "commit" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation";
562
+ kind: "closure" | "commit" | "correction" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation";
410
563
  purchaseKey?: string | undefined;
411
564
  sourceKey: string;
412
565
  }, {
413
566
  accountKey: import("convex/values").VString<string, "required">;
414
567
  purchaseKey: import("convex/values").VString<string | undefined, "optional">;
415
- kind: import("convex/values").VUnion<"closure" | "commit" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation", [import("convex/values").VLiteral<"purchase", "required">, import("convex/values").VLiteral<"payment", "required">, import("convex/values").VLiteral<"grant", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"observation", "required">, import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"closure", "required">], "required", never>;
568
+ kind: import("convex/values").VUnion<"closure" | "commit" | "correction" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation", [import("convex/values").VLiteral<"purchase", "required">, import("convex/values").VLiteral<"payment", "required">, import("convex/values").VLiteral<"grant", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"observation", "required">, import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"closure", "required">, import("convex/values").VLiteral<"correction", "required">], "required", never>;
416
569
  sourceKey: import("convex/values").VString<string, "required">;
417
570
  fingerprint: import("convex/values").VString<string, "required">;
418
571
  evidenceJson: import("convex/values").VString<string, "required">;
@@ -1482,6 +1635,14 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1482
1635
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
1483
1636
  requestKey: string;
1484
1637
  result?: {
1638
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1639
+ retryable: false;
1640
+ status: "conflict";
1641
+ } | {
1642
+ reason: "policy_invalid";
1643
+ retryable: false;
1644
+ status: "rejected";
1645
+ } | {
1485
1646
  operation: {
1486
1647
  accountId: string;
1487
1648
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1492,14 +1653,6 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1492
1653
  } | {
1493
1654
  enabled: boolean;
1494
1655
  status: "unchanged";
1495
- } | {
1496
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1497
- retryable: false;
1498
- status: "conflict";
1499
- } | {
1500
- reason: "policy_invalid";
1501
- retryable: false;
1502
- status: "rejected";
1503
1656
  } | {
1504
1657
  reason: "provider_pending";
1505
1658
  retryable: true;
@@ -1510,6 +1663,14 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1510
1663
  payload: import("convex/values").VString<string, "required">;
1511
1664
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
1512
1665
  result: import("convex/values").VUnion<{
1666
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
1667
+ retryable: false;
1668
+ status: "conflict";
1669
+ } | {
1670
+ reason: "policy_invalid";
1671
+ retryable: false;
1672
+ status: "rejected";
1673
+ } | {
1513
1674
  operation: {
1514
1675
  accountId: string;
1515
1676
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -1520,14 +1681,6 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
1520
1681
  } | {
1521
1682
  enabled: boolean;
1522
1683
  status: "unchanged";
1523
- } | {
1524
- reason: "identity_changed" | "revision_changed" | "scope_busy";
1525
- retryable: false;
1526
- status: "conflict";
1527
- } | {
1528
- reason: "policy_invalid";
1529
- retryable: false;
1530
- status: "rejected";
1531
1684
  } | {
1532
1685
  reason: "provider_pending";
1533
1686
  retryable: true;
@@ -3829,6 +3982,156 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
3829
3982
  }>;
3830
3983
  export declare function historical(currency?: string): Promise<{
3831
3984
  t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
3985
+ usageCorrectionClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
3986
+ key: string;
3987
+ operationKey: string;
3988
+ proofJson: string;
3989
+ }, {
3990
+ key: import("convex/values").VString<string, "required">;
3991
+ operationKey: import("convex/values").VString<string, "required">;
3992
+ proofJson: import("convex/values").VString<string, "required">;
3993
+ }, "required", "key" | "operationKey" | "proofJson">, {
3994
+ by_key: ["key", "_creationTime"];
3995
+ }, {}, {}>;
3996
+ usageCorrections: import("convex/server").TableDefinition<import("convex/values").VObject<{
3997
+ adjustmentJson?: string | undefined;
3998
+ attempt: number;
3999
+ attemptedAt?: number | undefined;
4000
+ cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
4001
+ correctionId: string;
4002
+ creditNoteId?: string | undefined;
4003
+ customerAccount?: string | undefined;
4004
+ eventId: import("convex/values").GenericId<"usageEvents">;
4005
+ firstAttemptAt: number;
4006
+ historyCount: number;
4007
+ inputJson: string;
4008
+ invoiceId?: string | undefined;
4009
+ key: string;
4010
+ leaseUntil?: number | undefined;
4011
+ nativeAdjustmentId?: string | undefined;
4012
+ nativeCreditNoteStatus?: "issued" | "void" | undefined;
4013
+ nativeStatus?: "complete" | "pending" | undefined;
4014
+ observedAt?: number | undefined;
4015
+ quantity: string;
4016
+ reason: string;
4017
+ recordJson: string;
4018
+ refundId?: string | undefined;
4019
+ resolution?: "event_cancellation" | "invoice_credit" | undefined;
4020
+ restoredQuantity: string;
4021
+ scaledQuantity: string;
4022
+ scopeKey: string;
4023
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
4024
+ stripeAccountId?: string | undefined;
4025
+ subscriptionJson: string;
4026
+ }, {
4027
+ stripeAccountId: import("convex/values").VString<string | undefined, "optional">;
4028
+ customerAccount: import("convex/values").VString<string | undefined, "optional">;
4029
+ observedAt: import("convex/values").VFloat64<number | undefined, "optional">;
4030
+ nativeCreditNoteStatus: import("convex/values").VUnion<"issued" | "void" | undefined, [import("convex/values").VLiteral<"issued", "required">, import("convex/values").VLiteral<"void", "required">], "optional", never>;
4031
+ resolution: import("convex/values").VUnion<"event_cancellation" | "invoice_credit" | undefined, [import("convex/values").VLiteral<"event_cancellation", "required">, import("convex/values").VLiteral<"invoice_credit", "required">], "optional", never>;
4032
+ adjustmentJson: import("convex/values").VString<string | undefined, "optional">;
4033
+ key: import("convex/values").VString<string, "required">;
4034
+ scopeKey: import("convex/values").VString<string, "required">;
4035
+ eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
4036
+ correctionId: import("convex/values").VString<string, "required">;
4037
+ inputJson: import("convex/values").VString<string, "required">;
4038
+ recordJson: import("convex/values").VString<string, "required">;
4039
+ subscriptionJson: import("convex/values").VString<string, "required">;
4040
+ quantity: import("convex/values").VString<string, "required">;
4041
+ scaledQuantity: import("convex/values").VString<string, "required">;
4042
+ state: import("convex/values").VUnion<"confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported", [import("convex/values").VLiteral<"requested", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"confirmed", "required">, import("convex/values").VLiteral<"held", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"invoice_adjustment_required", "required">], "required", never>;
4043
+ reason: import("convex/values").VString<string, "required">;
4044
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
4045
+ attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
4046
+ leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
4047
+ attempt: import("convex/values").VFloat64<number, "required">;
4048
+ nativeAdjustmentId: import("convex/values").VString<string | undefined, "optional">;
4049
+ nativeStatus: import("convex/values").VUnion<"complete" | "pending" | undefined, [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"complete", "required">], "optional", never>;
4050
+ invoiceId: import("convex/values").VString<string | undefined, "optional">;
4051
+ creditNoteId: import("convex/values").VString<string | undefined, "optional">;
4052
+ refundId: import("convex/values").VString<string | undefined, "optional">;
4053
+ cashConsequence: import("convex/values").VUnion<"none" | "operator_resolution_required" | "verified_external_adjustment", [import("convex/values").VLiteral<"none", "required">, import("convex/values").VLiteral<"operator_resolution_required", "required">, import("convex/values").VLiteral<"verified_external_adjustment", "required">], "required", never>;
4054
+ restoredQuantity: import("convex/values").VString<string, "required">;
4055
+ historyCount: import("convex/values").VFloat64<number, "required">;
4056
+ }, "required", "adjustmentJson" | "attempt" | "attemptedAt" | "cashConsequence" | "correctionId" | "creditNoteId" | "customerAccount" | "eventId" | "firstAttemptAt" | "historyCount" | "inputJson" | "invoiceId" | "key" | "leaseUntil" | "nativeAdjustmentId" | "nativeCreditNoteStatus" | "nativeStatus" | "observedAt" | "quantity" | "reason" | "recordJson" | "refundId" | "resolution" | "restoredQuantity" | "scaledQuantity" | "scopeKey" | "state" | "stripeAccountId" | "subscriptionJson">, {
4057
+ by_event: ["eventId", "_creationTime"];
4058
+ by_key: ["key", "_creationTime"];
4059
+ by_payer_state: ["customerAccount", "state", "_creationTime"];
4060
+ by_realm_state: ["stripeAccountId", "state", "_creationTime"];
4061
+ by_scope: ["scopeKey", "_creationTime"];
4062
+ by_scope_state: ["scopeKey", "state", "_creationTime"];
4063
+ }, {}, {}>;
4064
+ usageCorrectionHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
4065
+ at: number;
4066
+ eventId: import("convex/values").GenericId<"usageEvents">;
4067
+ evidenceJson: string;
4068
+ key: string;
4069
+ occurredAt?: number | undefined;
4070
+ reason: string;
4071
+ recordJson: string;
4072
+ scopeKey: string;
4073
+ sequence: number;
4074
+ state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
4075
+ subscriptionJson: string;
4076
+ }, {
4077
+ key: import("convex/values").VString<string, "required">;
4078
+ scopeKey: import("convex/values").VString<string, "required">;
4079
+ eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
4080
+ sequence: import("convex/values").VFloat64<number, "required">;
4081
+ state: import("convex/values").VUnion<"confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported", [import("convex/values").VLiteral<"requested", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"confirmed", "required">, import("convex/values").VLiteral<"held", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"invoice_adjustment_required", "required">], "required", never>;
4082
+ reason: import("convex/values").VString<string, "required">;
4083
+ recordJson: import("convex/values").VString<string, "required">;
4084
+ subscriptionJson: import("convex/values").VString<string, "required">;
4085
+ evidenceJson: import("convex/values").VString<string, "required">;
4086
+ occurredAt: import("convex/values").VFloat64<number | undefined, "optional">;
4087
+ at: import("convex/values").VFloat64<number, "required">;
4088
+ }, "required", "at" | "eventId" | "evidenceJson" | "key" | "occurredAt" | "reason" | "recordJson" | "scopeKey" | "sequence" | "state" | "subscriptionJson">, {
4089
+ by_event: ["eventId", "_creationTime"];
4090
+ by_scope_occurrence: ["scopeKey", "occurredAt", "_creationTime"];
4091
+ by_scope_time: ["scopeKey", "at", "_creationTime"];
4092
+ }, {}, {}>;
4093
+ usageAllowancePolicies: import("convex/server").TableDefinition<import("convex/values").VObject<{
4094
+ bindingJson: string;
4095
+ consumed: string;
4096
+ end: number;
4097
+ historyCount: number;
4098
+ key: string;
4099
+ nativeKey: string;
4100
+ policyJson: string;
4101
+ reserved: string;
4102
+ revision: number;
4103
+ scopeKey: string;
4104
+ start: number;
4105
+ }, {
4106
+ key: import("convex/values").VString<string, "required">;
4107
+ nativeKey: import("convex/values").VString<string, "required">;
4108
+ scopeKey: import("convex/values").VString<string, "required">;
4109
+ bindingJson: import("convex/values").VString<string, "required">;
4110
+ start: import("convex/values").VFloat64<number, "required">;
4111
+ end: import("convex/values").VFloat64<number, "required">;
4112
+ policyJson: import("convex/values").VString<string, "required">;
4113
+ revision: import("convex/values").VFloat64<number, "required">;
4114
+ consumed: import("convex/values").VString<string, "required">;
4115
+ reserved: import("convex/values").VString<string, "required">;
4116
+ historyCount: import("convex/values").VFloat64<number, "required">;
4117
+ }, "required", "bindingJson" | "consumed" | "end" | "historyCount" | "key" | "nativeKey" | "policyJson" | "reserved" | "revision" | "scopeKey" | "start">, {
4118
+ by_key: ["key", "_creationTime"];
4119
+ by_native_start: ["nativeKey", "start", "_creationTime"];
4120
+ by_scope_start: ["scopeKey", "start", "_creationTime"];
4121
+ }, {}, {}>;
4122
+ usageAllowanceHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
4123
+ at: number;
4124
+ evidenceJson: string;
4125
+ key: string;
4126
+ kind: "commit" | "correction" | "policy" | "release" | "reservation";
4127
+ }, {
4128
+ key: import("convex/values").VString<string, "required">;
4129
+ 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>;
4130
+ evidenceJson: import("convex/values").VString<string, "required">;
4131
+ at: import("convex/values").VFloat64<number, "required">;
4132
+ }, "required", "at" | "evidenceJson" | "key" | "kind">, {
4133
+ by_key: ["key", "_creationTime"];
4134
+ }, {}, {}>;
3832
4135
  usageSubscriptionControls: import("convex/server").TableDefinition<import("convex/values").VObject<{
3833
4136
  cancelAtPeriodEnd: boolean;
3834
4137
  firstAttemptAt: number;
@@ -4030,6 +4333,7 @@ export declare function historical(currency?: string): Promise<{
4030
4333
  }, {}, {}>;
4031
4334
  usageOutbox: import("convex/server").TableDefinition<import("convex/values").VObject<{
4032
4335
  attempts: number;
4336
+ correctionKey?: string | undefined;
4033
4337
  definitionVersion?: 1 | undefined;
4034
4338
  dispatch?: string | undefined;
4035
4339
  eventId: import("convex/values").GenericId<"usageEvents">;
@@ -4040,13 +4344,13 @@ export declare function historical(currency?: string): Promise<{
4040
4344
  nextAttemptAt: number;
4041
4345
  provider?: string | undefined;
4042
4346
  providerIdentifier: string;
4043
- reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
4347
+ reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | "usage_canceled" | undefined;
4044
4348
  receipt?: {
4045
4349
  created: number;
4046
4350
  identifier: string;
4047
4351
  } | undefined;
4048
4352
  scopeKey: string;
4049
- state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
4353
+ state: "canceled" | "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
4050
4354
  workflowId?: string | undefined;
4051
4355
  }, {
4052
4356
  historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
@@ -4056,7 +4360,7 @@ export declare function historical(currency?: string): Promise<{
4056
4360
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
4057
4361
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
4058
4362
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
4059
- reason: import("convex/values").VUnion<"administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [import("convex/values").VLiteral<"billing_period_closed", "required">, import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "optional", never>;
4363
+ reason: import("convex/values").VUnion<"administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | "usage_canceled" | undefined, [import("convex/values").VLiteral<"usage_canceled", "required">, import("convex/values").VLiteral<"billing_period_closed", "required">, import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"provider_unavailable", "required">, import("convex/values").VLiteral<"provider_outcome_unknown", "required">, import("convex/values").VLiteral<"provider_rejected", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">, import("convex/values").VLiteral<"delivery_window_expired", "required">, import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"administrative_hold", "required">], "optional", never>;
4060
4364
  receipt: import("convex/values").VObject<{
4061
4365
  created: number;
4062
4366
  identifier: string;
@@ -4064,14 +4368,15 @@ export declare function historical(currency?: string): Promise<{
4064
4368
  identifier: import("convex/values").VString<string, "required">;
4065
4369
  created: import("convex/values").VFloat64<number, "required">;
4066
4370
  }, "optional", "created" | "identifier">;
4371
+ correctionKey: import("convex/values").VString<string | undefined, "optional">;
4067
4372
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
4068
4373
  scopeKey: import("convex/values").VString<string, "required">;
4069
- state: import("convex/values").VUnion<"held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown", [import("convex/values").VLiteral<"queued", "required">, import("convex/values").VLiteral<"sending", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"rejected", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
4374
+ state: import("convex/values").VUnion<"canceled" | "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown", [import("convex/values").VLiteral<"queued", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"sending", "required">, import("convex/values").VLiteral<"provider_accepted", "required">, import("convex/values").VLiteral<"rejected", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"held", "required">], "required", never>;
4070
4375
  attempts: import("convex/values").VFloat64<number, "required">;
4071
4376
  nextAttemptAt: import("convex/values").VFloat64<number, "required">;
4072
4377
  providerIdentifier: import("convex/values").VString<string, "required">;
4073
4378
  dispatch: import("convex/values").VString<string | undefined, "optional">;
4074
- }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
4379
+ }, "required", "attempts" | "correctionKey" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
4075
4380
  by_event: ["eventId", "_creationTime"];
4076
4381
  by_provider_identifier: ["providerIdentifier", "_creationTime"];
4077
4382
  by_scope_state: ["scopeKey", "state", "_creationTime"];
@@ -4088,7 +4393,7 @@ export declare function historical(currency?: string): Promise<{
4088
4393
  }, {}, {}>;
4089
4394
  usageReservations: import("convex/server").TableDefinition<import("convex/values").VObject<{
4090
4395
  accountKey?: string | undefined;
4091
- accountingKind?: "prepaid" | undefined;
4396
+ accountingKind?: "allowance" | "prepaid" | undefined;
4092
4397
  allocationsJson?: string | undefined;
4093
4398
  eventId?: import("convex/values").GenericId<"usageEvents"> | undefined;
4094
4399
  inputJson?: string | undefined;
@@ -4106,13 +4411,14 @@ export declare function historical(currency?: string): Promise<{
4106
4411
  scaledQuantity: import("convex/values").VString<string, "required">;
4107
4412
  state: import("convex/values").VUnion<"committed" | "released" | "reserved", [import("convex/values").VLiteral<"reserved", "required">, import("convex/values").VLiteral<"committed", "required">, import("convex/values").VLiteral<"released", "required">], "required", never>;
4108
4413
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents"> | undefined, "optional">;
4109
- accountingKind: import("convex/values").VLiteral<"prepaid" | undefined, "optional">;
4414
+ accountingKind: import("convex/values").VUnion<"allowance" | "prepaid" | undefined, [import("convex/values").VLiteral<"prepaid", "required">, import("convex/values").VLiteral<"allowance", "required">], "optional", never>;
4110
4415
  accountKey: import("convex/values").VString<string | undefined, "optional">;
4111
4416
  inputJson: import("convex/values").VString<string | undefined, "optional">;
4112
4417
  subscriptionJson: import("convex/values").VString<string | undefined, "optional">;
4113
4418
  allocationsJson: import("convex/values").VString<string | undefined, "optional">;
4114
4419
  releaseReason: import("convex/values").VString<string | undefined, "optional">;
4115
4420
  }, "required", "accountKey" | "accountingKind" | "allocationsJson" | "eventId" | "inputJson" | "planJson" | "releaseReason" | "scaledQuantity" | "scopeKey" | "sourceEventId" | "state" | "subscriptionJson">, {
4421
+ by_account_state: ["accountKey", "state", "_creationTime"];
4116
4422
  by_scope_source: ["scopeKey", "sourceEventId", "_creationTime"];
4117
4423
  by_scope_state: ["scopeKey", "state", "_creationTime"];
4118
4424
  }, {}, {}>;
@@ -4226,13 +4532,13 @@ export declare function historical(currency?: string): Promise<{
4226
4532
  at: number;
4227
4533
  evidenceJson: string;
4228
4534
  fingerprint: string;
4229
- kind: "closure" | "commit" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation";
4535
+ kind: "closure" | "commit" | "correction" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation";
4230
4536
  purchaseKey?: string | undefined;
4231
4537
  sourceKey: string;
4232
4538
  }, {
4233
4539
  accountKey: import("convex/values").VString<string, "required">;
4234
4540
  purchaseKey: import("convex/values").VString<string | undefined, "optional">;
4235
- kind: import("convex/values").VUnion<"closure" | "commit" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation", [import("convex/values").VLiteral<"purchase", "required">, import("convex/values").VLiteral<"payment", "required">, import("convex/values").VLiteral<"grant", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"observation", "required">, import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"closure", "required">], "required", never>;
4541
+ kind: import("convex/values").VUnion<"closure" | "commit" | "correction" | "grant" | "observation" | "payment" | "purchase" | "recovery" | "release" | "reservation", [import("convex/values").VLiteral<"purchase", "required">, import("convex/values").VLiteral<"payment", "required">, import("convex/values").VLiteral<"grant", "required">, import("convex/values").VLiteral<"reservation", "required">, import("convex/values").VLiteral<"commit", "required">, import("convex/values").VLiteral<"release", "required">, import("convex/values").VLiteral<"observation", "required">, import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"closure", "required">, import("convex/values").VLiteral<"correction", "required">], "required", never>;
4236
4542
  sourceKey: import("convex/values").VString<string, "required">;
4237
4543
  fingerprint: import("convex/values").VString<string, "required">;
4238
4544
  evidenceJson: import("convex/values").VString<string, "required">;
@@ -5302,6 +5608,14 @@ export declare function historical(currency?: string): Promise<{
5302
5608
  preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
5303
5609
  requestKey: string;
5304
5610
  result?: {
5611
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
5612
+ retryable: false;
5613
+ status: "conflict";
5614
+ } | {
5615
+ reason: "policy_invalid";
5616
+ retryable: false;
5617
+ status: "rejected";
5618
+ } | {
5305
5619
  operation: {
5306
5620
  accountId: string;
5307
5621
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -5312,14 +5626,6 @@ export declare function historical(currency?: string): Promise<{
5312
5626
  } | {
5313
5627
  enabled: boolean;
5314
5628
  status: "unchanged";
5315
- } | {
5316
- reason: "identity_changed" | "revision_changed" | "scope_busy";
5317
- retryable: false;
5318
- status: "conflict";
5319
- } | {
5320
- reason: "policy_invalid";
5321
- retryable: false;
5322
- status: "rejected";
5323
5629
  } | {
5324
5630
  reason: "provider_pending";
5325
5631
  retryable: true;
@@ -5330,6 +5636,14 @@ export declare function historical(currency?: string): Promise<{
5330
5636
  payload: import("convex/values").VString<string, "required">;
5331
5637
  preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
5332
5638
  result: import("convex/values").VUnion<{
5639
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
5640
+ retryable: false;
5641
+ status: "conflict";
5642
+ } | {
5643
+ reason: "policy_invalid";
5644
+ retryable: false;
5645
+ status: "rejected";
5646
+ } | {
5333
5647
  operation: {
5334
5648
  accountId: string;
5335
5649
  operationId: import("convex/values").GenericId<"balanceFundingOperations">;
@@ -5340,14 +5654,6 @@ export declare function historical(currency?: string): Promise<{
5340
5654
  } | {
5341
5655
  enabled: boolean;
5342
5656
  status: "unchanged";
5343
- } | {
5344
- reason: "identity_changed" | "revision_changed" | "scope_busy";
5345
- retryable: false;
5346
- status: "conflict";
5347
- } | {
5348
- reason: "policy_invalid";
5349
- retryable: false;
5350
- status: "rejected";
5351
5657
  } | {
5352
5658
  reason: "provider_pending";
5353
5659
  retryable: true;