@fantastic.dev/better-stripe 0.54.0 → 0.56.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 (282) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +264 -8
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +132 -4
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +264 -8
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +132 -4
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/index.d.ts +9 -0
  12. package/dist/client/index.d.ts.map +1 -1
  13. package/dist/client/index.js +1 -0
  14. package/dist/client/index.js.map +1 -1
  15. package/dist/client/usage/catalogPrices.d.ts +2 -0
  16. package/dist/client/usage/catalogPrices.d.ts.map +1 -1
  17. package/dist/client/usage/catalogPrices.js +15 -0
  18. package/dist/client/usage/catalogPrices.js.map +1 -1
  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/deliveryProvider.d.ts.map +1 -1
  24. package/dist/client/usage/deliveryProvider.js +26 -1
  25. package/dist/client/usage/deliveryProvider.js.map +1 -1
  26. package/dist/client/usage/index.d.ts +9 -0
  27. package/dist/client/usage/index.d.ts.map +1 -1
  28. package/dist/client/usage/index.js +1 -0
  29. package/dist/client/usage/index.js.map +1 -1
  30. package/dist/client/usage/invoiceObservation.d.ts +38 -0
  31. package/dist/client/usage/invoiceObservation.d.ts.map +1 -0
  32. package/dist/client/usage/invoiceObservation.js +157 -0
  33. package/dist/client/usage/invoiceObservation.js.map +1 -0
  34. package/dist/client/usage/observationClient.d.ts +83 -0
  35. package/dist/client/usage/observationClient.d.ts.map +1 -0
  36. package/dist/client/usage/observationClient.js +157 -0
  37. package/dist/client/usage/observationClient.js.map +1 -0
  38. package/dist/client/usage/observationTypes.d.ts +63 -0
  39. package/dist/client/usage/observationTypes.d.ts.map +1 -0
  40. package/dist/client/usage/observationTypes.js +59 -0
  41. package/dist/client/usage/observationTypes.js.map +1 -0
  42. package/dist/client/usage/providerObservation.d.ts +4 -0
  43. package/dist/client/usage/providerObservation.d.ts.map +1 -0
  44. package/dist/client/usage/providerObservation.js +96 -0
  45. package/dist/client/usage/providerObservation.js.map +1 -0
  46. package/dist/client/usage/reconciliation.d.ts +12 -0
  47. package/dist/client/usage/reconciliation.d.ts.map +1 -0
  48. package/dist/client/usage/reconciliation.js +48 -0
  49. package/dist/client/usage/reconciliation.js.map +1 -0
  50. package/dist/client/usage/subscription.fixtures.d.ts +118 -0
  51. package/dist/client/usage/subscription.fixtures.d.ts.map +1 -0
  52. package/dist/client/usage/subscription.fixtures.js +84 -0
  53. package/dist/client/usage/subscription.fixtures.js.map +1 -0
  54. package/dist/client/usage/subscriptionAbandonment.d.ts +8 -0
  55. package/dist/client/usage/subscriptionAbandonment.d.ts.map +1 -0
  56. package/dist/client/usage/subscriptionAbandonment.js +82 -0
  57. package/dist/client/usage/subscriptionAbandonment.js.map +1 -0
  58. package/dist/client/usage/subscriptionCancellation.d.ts +9 -0
  59. package/dist/client/usage/subscriptionCancellation.d.ts.map +1 -0
  60. package/dist/client/usage/subscriptionCancellation.js +39 -0
  61. package/dist/client/usage/subscriptionCancellation.js.map +1 -0
  62. package/dist/client/usage/subscriptionCheckout.d.ts +52 -0
  63. package/dist/client/usage/subscriptionCheckout.d.ts.map +1 -0
  64. package/dist/client/usage/subscriptionCheckout.js +94 -0
  65. package/dist/client/usage/subscriptionCheckout.js.map +1 -0
  66. package/dist/client/usage/subscriptionClient.d.ts +267 -0
  67. package/dist/client/usage/subscriptionClient.d.ts.map +1 -0
  68. package/dist/client/usage/subscriptionClient.js +93 -0
  69. package/dist/client/usage/subscriptionClient.js.map +1 -0
  70. package/dist/client/usage/subscriptionErrors.d.ts +5 -0
  71. package/dist/client/usage/subscriptionErrors.d.ts.map +1 -0
  72. package/dist/client/usage/subscriptionErrors.js +9 -0
  73. package/dist/client/usage/subscriptionErrors.js.map +1 -0
  74. package/dist/client/usage/subscriptionInvoiceSchema.d.ts +203 -0
  75. package/dist/client/usage/subscriptionInvoiceSchema.d.ts.map +1 -0
  76. package/dist/client/usage/subscriptionInvoiceSchema.js +108 -0
  77. package/dist/client/usage/subscriptionInvoiceSchema.js.map +1 -0
  78. package/dist/client/usage/subscriptionLifecycle.d.ts +80 -0
  79. package/dist/client/usage/subscriptionLifecycle.d.ts.map +1 -0
  80. package/dist/client/usage/subscriptionLifecycle.js +87 -0
  81. package/dist/client/usage/subscriptionLifecycle.js.map +1 -0
  82. package/dist/client/usage/subscriptionProvider.d.ts +111 -0
  83. package/dist/client/usage/subscriptionProvider.d.ts.map +1 -0
  84. package/dist/client/usage/subscriptionProvider.js +147 -0
  85. package/dist/client/usage/subscriptionProvider.js.map +1 -0
  86. package/dist/client/usage/subscriptionTerms.d.ts +161 -0
  87. package/dist/client/usage/subscriptionTerms.d.ts.map +1 -0
  88. package/dist/client/usage/subscriptionTerms.js +242 -0
  89. package/dist/client/usage/subscriptionTerms.js.map +1 -0
  90. package/dist/client/usage/subscriptionTransport.fixtures.d.ts +25 -0
  91. package/dist/client/usage/subscriptionTransport.fixtures.d.ts.map +1 -0
  92. package/dist/client/usage/subscriptionTransport.fixtures.js +203 -0
  93. package/dist/client/usage/subscriptionTransport.fixtures.js.map +1 -0
  94. package/dist/client/usage/summary.d.ts +50 -0
  95. package/dist/client/usage/summary.d.ts.map +1 -0
  96. package/dist/client/usage/summary.js +110 -0
  97. package/dist/client/usage/summary.js.map +1 -0
  98. package/dist/client/webhooks/processors.d.ts.map +1 -1
  99. package/dist/client/webhooks/processors.js +2 -0
  100. package/dist/client/webhooks/processors.js.map +1 -1
  101. package/dist/client/webhooks/usageSubscriptions.d.ts +5 -0
  102. package/dist/client/webhooks/usageSubscriptions.d.ts.map +1 -0
  103. package/dist/client/webhooks/usageSubscriptions.js +54 -0
  104. package/dist/client/webhooks/usageSubscriptions.js.map +1 -0
  105. package/dist/component/_generated/api.d.ts +22 -0
  106. package/dist/component/_generated/api.d.ts.map +1 -1
  107. package/dist/component/_generated/api.js.map +1 -1
  108. package/dist/component/_generated/component.d.ts +255 -5
  109. package/dist/component/_generated/component.d.ts.map +1 -1
  110. package/dist/component/accountClosure/mutations.d.ts.map +1 -1
  111. package/dist/component/accountClosure/mutations.js +10 -0
  112. package/dist/component/accountClosure/mutations.js.map +1 -1
  113. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  114. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  115. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  116. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  117. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  118. package/dist/component/earnings/triggers.d.ts +296 -22
  119. package/dist/component/earnings/triggers.d.ts.map +1 -1
  120. package/dist/component/payoutRelease/queries.d.ts +2 -2
  121. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  122. package/dist/component/refundHistory/queries.d.ts +1 -1
  123. package/dist/component/schema.d.ts +132 -4
  124. package/dist/component/schema.js +8 -0
  125. package/dist/component/schema.js.map +1 -1
  126. package/dist/component/usage/mutations.d.ts.map +1 -1
  127. package/dist/component/usage/mutations.js +5 -0
  128. package/dist/component/usage/mutations.js.map +1 -1
  129. package/dist/component/usage/queries.d.ts +2 -0
  130. package/dist/component/usage/queries.d.ts.map +1 -1
  131. package/dist/component/usage/schema.d.ts +21 -9
  132. package/dist/component/usage/schema.d.ts.map +1 -1
  133. package/dist/component/usage/schema.js +5 -1
  134. package/dist/component/usage/schema.js.map +1 -1
  135. package/dist/component/usageDelivery/fields.d.ts +4 -2
  136. package/dist/component/usageDelivery/fields.d.ts.map +1 -1
  137. package/dist/component/usageDelivery/fields.js +3 -1
  138. package/dist/component/usageDelivery/fields.js.map +1 -1
  139. package/dist/component/usageDelivery/helpers.d.ts +5 -3
  140. package/dist/component/usageDelivery/helpers.d.ts.map +1 -1
  141. package/dist/component/usageDelivery/mutations.d.ts +3 -3
  142. package/dist/component/usageDelivery/mutations.d.ts.map +1 -1
  143. package/dist/component/usageDelivery/mutations.js +8 -1
  144. package/dist/component/usageDelivery/mutations.js.map +1 -1
  145. package/dist/component/usageDelivery/queries.d.ts +19 -3
  146. package/dist/component/usageDelivery/queries.d.ts.map +1 -1
  147. package/dist/component/usageDelivery/queries.js +20 -3
  148. package/dist/component/usageDelivery/queries.js.map +1 -1
  149. package/dist/component/usageDelivery/schema.d.ts +2 -2
  150. package/dist/component/usageDelivery/steps.d.ts +1 -1
  151. package/dist/component/usageDelivery/steps.d.ts.map +1 -1
  152. package/dist/component/usageDelivery/steps.js +20 -2
  153. package/dist/component/usageDelivery/steps.js.map +1 -1
  154. package/dist/component/usageObservations/helpers.d.ts +38 -0
  155. package/dist/component/usageObservations/helpers.d.ts.map +1 -0
  156. package/dist/component/usageObservations/helpers.js +80 -0
  157. package/dist/component/usageObservations/helpers.js.map +1 -0
  158. package/dist/component/usageObservations/history.d.ts +6 -0
  159. package/dist/component/usageObservations/history.d.ts.map +1 -0
  160. package/dist/component/usageObservations/history.js +29 -0
  161. package/dist/component/usageObservations/history.js.map +1 -0
  162. package/dist/component/usageObservations/mutations.d.ts +6 -0
  163. package/dist/component/usageObservations/mutations.d.ts.map +1 -0
  164. package/dist/component/usageObservations/mutations.js +39 -0
  165. package/dist/component/usageObservations/mutations.js.map +1 -0
  166. package/dist/component/usageObservations/queries.d.ts +78 -0
  167. package/dist/component/usageObservations/queries.d.ts.map +1 -0
  168. package/dist/component/usageObservations/queries.js +131 -0
  169. package/dist/component/usageObservations/queries.js.map +1 -0
  170. package/dist/component/usageObservations/schema.d.ts +72 -0
  171. package/dist/component/usageObservations/schema.d.ts.map +1 -0
  172. package/dist/component/usageObservations/schema.js +29 -0
  173. package/dist/component/usageObservations/schema.js.map +1 -0
  174. package/dist/component/usageSubscriptions/abandonment.d.ts +4 -0
  175. package/dist/component/usageSubscriptions/abandonment.d.ts.map +1 -0
  176. package/dist/component/usageSubscriptions/abandonment.js +59 -0
  177. package/dist/component/usageSubscriptions/abandonment.js.map +1 -0
  178. package/dist/component/usageSubscriptions/acceptance.d.ts +11 -0
  179. package/dist/component/usageSubscriptions/acceptance.d.ts.map +1 -0
  180. package/dist/component/usageSubscriptions/acceptance.js +38 -0
  181. package/dist/component/usageSubscriptions/acceptance.js.map +1 -0
  182. package/dist/component/usageSubscriptions/helpers.d.ts +39 -0
  183. package/dist/component/usageSubscriptions/helpers.d.ts.map +1 -0
  184. package/dist/component/usageSubscriptions/helpers.js +28 -0
  185. package/dist/component/usageSubscriptions/helpers.js.map +1 -0
  186. package/dist/component/usageSubscriptions/history.d.ts +46 -0
  187. package/dist/component/usageSubscriptions/history.d.ts.map +1 -0
  188. package/dist/component/usageSubscriptions/history.js +46 -0
  189. package/dist/component/usageSubscriptions/history.js.map +1 -0
  190. package/dist/component/usageSubscriptions/mutations.d.ts +64 -0
  191. package/dist/component/usageSubscriptions/mutations.d.ts.map +1 -0
  192. package/dist/component/usageSubscriptions/mutations.js +252 -0
  193. package/dist/component/usageSubscriptions/mutations.js.map +1 -0
  194. package/dist/component/usageSubscriptions/queries.d.ts +81 -0
  195. package/dist/component/usageSubscriptions/queries.d.ts.map +1 -0
  196. package/dist/component/usageSubscriptions/queries.js +70 -0
  197. package/dist/component/usageSubscriptions/queries.js.map +1 -0
  198. package/dist/component/usageSubscriptions/retirement.d.ts +4 -0
  199. package/dist/component/usageSubscriptions/retirement.d.ts.map +1 -0
  200. package/dist/component/usageSubscriptions/retirement.js +80 -0
  201. package/dist/component/usageSubscriptions/retirement.js.map +1 -0
  202. package/dist/component/usageSubscriptions/schema.d.ts +191 -0
  203. package/dist/component/usageSubscriptions/schema.d.ts.map +1 -0
  204. package/dist/component/usageSubscriptions/schema.js +69 -0
  205. package/dist/component/usageSubscriptions/schema.js.map +1 -0
  206. package/dist/test.d.ts +6 -0
  207. package/dist/test.d.ts.map +1 -0
  208. package/dist/test.js +15 -0
  209. package/dist/test.js.map +1 -0
  210. package/docs/README.md +4 -0
  211. package/docs/evidence/native-metering/clock-finalization-run.json +129 -0
  212. package/docs/evidence/native-metering/clock-lag-run.json +111 -0
  213. package/docs/evidence/native-metering/paid-run.json +107 -0
  214. package/docs/evidence/native-metering/promotional-run.json +103 -0
  215. package/docs/metered-usage.md +14 -0
  216. package/docs/metering-setup.md +7 -1
  217. package/docs/usage-observations.md +152 -0
  218. package/docs/usage-subscriptions.md +278 -0
  219. package/package.json +5 -2
  220. package/src/client/index.ts +26 -0
  221. package/src/client/usage/catalogPrices.ts +21 -0
  222. package/src/client/usage/client.ts +2 -2
  223. package/src/client/usage/deliveryProvider.test.ts +70 -1
  224. package/src/client/usage/deliveryProvider.ts +43 -2
  225. package/src/client/usage/index.ts +27 -0
  226. package/src/client/usage/invoiceObservation.test.ts +195 -0
  227. package/src/client/usage/invoiceObservation.ts +203 -0
  228. package/src/client/usage/observationClient.ts +233 -0
  229. package/src/client/usage/observationTypes.ts +101 -0
  230. package/src/client/usage/providerObservation.test.ts +207 -0
  231. package/src/client/usage/providerObservation.ts +124 -0
  232. package/src/client/usage/reconciliation.test.ts +117 -0
  233. package/src/client/usage/reconciliation.ts +86 -0
  234. package/src/client/usage/subscription.fixtures.ts +84 -0
  235. package/src/client/usage/subscriptionAbandonment.test.ts +124 -0
  236. package/src/client/usage/subscriptionAbandonment.ts +116 -0
  237. package/src/client/usage/subscriptionCancellation.ts +90 -0
  238. package/src/client/usage/subscriptionCheckout.test.ts +31 -0
  239. package/src/client/usage/subscriptionCheckout.ts +152 -0
  240. package/src/client/usage/subscriptionClient.test.ts +316 -0
  241. package/src/client/usage/subscriptionClient.ts +204 -0
  242. package/src/client/usage/subscriptionErrors.ts +14 -0
  243. package/src/client/usage/subscriptionInvoiceSchema.ts +116 -0
  244. package/src/client/usage/subscriptionLifecycle.ts +165 -0
  245. package/src/client/usage/subscriptionProvider.test.ts +48 -0
  246. package/src/client/usage/subscriptionProvider.ts +247 -0
  247. package/src/client/usage/subscriptionTerms.test.ts +158 -0
  248. package/src/client/usage/subscriptionTerms.ts +294 -0
  249. package/src/client/usage/subscriptionTransport.fixtures.ts +241 -0
  250. package/src/client/usage/summary.test.ts +222 -0
  251. package/src/client/usage/summary.ts +188 -0
  252. package/src/client/webhooks/processors.ts +2 -0
  253. package/src/client/webhooks/usageSubscriptions.test.ts +162 -0
  254. package/src/client/webhooks/usageSubscriptions.ts +81 -0
  255. package/src/component/_generated/api.ts +22 -0
  256. package/src/component/_generated/component.ts +335 -0
  257. package/src/component/accountClosure/mutations.ts +12 -0
  258. package/src/component/schema.ts +16 -0
  259. package/src/component/usage/mutations.ts +5 -0
  260. package/src/component/usage/schema.ts +5 -1
  261. package/src/component/usageDelivery/fields.ts +3 -0
  262. package/src/component/usageDelivery/mutations.ts +26 -1
  263. package/src/component/usageDelivery/queries.ts +30 -3
  264. package/src/component/usageDelivery/steps.ts +61 -2
  265. package/src/component/usageObservations/helpers.ts +95 -0
  266. package/src/component/usageObservations/history.test.ts +87 -0
  267. package/src/component/usageObservations/history.ts +39 -0
  268. package/src/component/usageObservations/mutations.ts +39 -0
  269. package/src/component/usageObservations/queries.test.ts +162 -0
  270. package/src/component/usageObservations/queries.ts +145 -0
  271. package/src/component/usageObservations/schema.ts +40 -0
  272. package/src/component/usageSubscriptions/abandonment.ts +80 -0
  273. package/src/component/usageSubscriptions/acceptance.test.ts +122 -0
  274. package/src/component/usageSubscriptions/acceptance.ts +66 -0
  275. package/src/component/usageSubscriptions/helpers.ts +33 -0
  276. package/src/component/usageSubscriptions/history.test.ts +69 -0
  277. package/src/component/usageSubscriptions/history.ts +68 -0
  278. package/src/component/usageSubscriptions/mutations.test.ts +205 -0
  279. package/src/component/usageSubscriptions/mutations.ts +275 -0
  280. package/src/component/usageSubscriptions/queries.ts +78 -0
  281. package/src/component/usageSubscriptions/retirement.ts +105 -0
  282. package/src/component/usageSubscriptions/schema.ts +73 -0
@@ -1,4 +1,125 @@
1
1
  declare const _default: import("convex/server").SchemaDefinition<{
2
+ usageSubscriptionControls: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
+ cancelAtPeriodEnd: boolean;
4
+ firstAttemptAt: number;
5
+ intentKey: string;
6
+ key: string;
7
+ operationId: string;
8
+ resultJson?: string | undefined;
9
+ }, {
10
+ key: import("convex/values").VString<string, "required">;
11
+ intentKey: import("convex/values").VString<string, "required">;
12
+ operationId: import("convex/values").VString<string, "required">;
13
+ cancelAtPeriodEnd: import("convex/values").VBoolean<boolean, "required">;
14
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
15
+ resultJson: import("convex/values").VString<string | undefined, "optional">;
16
+ }, "required", "cancelAtPeriodEnd" | "firstAttemptAt" | "intentKey" | "key" | "operationId" | "resultJson">, {
17
+ by_key: ["key", "_creationTime"];
18
+ }, {}, {}>;
19
+ usageSubscriptionIntents: import("convex/server").TableDefinition<import("convex/values").VObject<{
20
+ abandonedId?: string | undefined;
21
+ checkoutId?: string | undefined;
22
+ controlKey?: string | undefined;
23
+ firstAttemptAt: number;
24
+ historyCount?: number | undefined;
25
+ key: string;
26
+ method: "checkout" | "direct";
27
+ providerId?: string | undefined;
28
+ retiredAt?: number | undefined;
29
+ retirementInvoiceId?: string | undefined;
30
+ scopeKey: string;
31
+ startedAt?: number | undefined;
32
+ termsJson: string;
33
+ viewJson?: string | undefined;
34
+ }, {
35
+ key: import("convex/values").VString<string, "required">;
36
+ scopeKey: import("convex/values").VString<string, "required">;
37
+ termsJson: import("convex/values").VString<string, "required">;
38
+ method: import("convex/values").VUnion<"checkout" | "direct", [import("convex/values").VLiteral<"direct", "required">, import("convex/values").VLiteral<"checkout", "required">], "required", never>;
39
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
40
+ providerId: import("convex/values").VString<string | undefined, "optional">;
41
+ checkoutId: import("convex/values").VString<string | undefined, "optional">;
42
+ viewJson: import("convex/values").VString<string | undefined, "optional">;
43
+ startedAt: import("convex/values").VFloat64<number | undefined, "optional">;
44
+ controlKey: import("convex/values").VString<string | undefined, "optional">;
45
+ historyCount: import("convex/values").VFloat64<number | undefined, "optional">;
46
+ retiredAt: import("convex/values").VFloat64<number | undefined, "optional">;
47
+ abandonedId: import("convex/values").VString<string | undefined, "optional">;
48
+ retirementInvoiceId: import("convex/values").VString<string | undefined, "optional">;
49
+ }, "required", "abandonedId" | "checkoutId" | "controlKey" | "firstAttemptAt" | "historyCount" | "key" | "method" | "providerId" | "retiredAt" | "retirementInvoiceId" | "scopeKey" | "startedAt" | "termsJson" | "viewJson">, {
50
+ by_key: ["key", "_creationTime"];
51
+ by_provider: ["providerId", "_creationTime"];
52
+ }, {}, {}>;
53
+ usageSubscriptionLocks: import("convex/server").TableDefinition<import("convex/values").VObject<{
54
+ customerAccount: string;
55
+ intentKey: string;
56
+ key: string;
57
+ stripeAccountId: string;
58
+ }, {
59
+ key: import("convex/values").VString<string, "required">;
60
+ intentKey: import("convex/values").VString<string, "required">;
61
+ stripeAccountId: import("convex/values").VString<string, "required">;
62
+ customerAccount: import("convex/values").VString<string, "required">;
63
+ }, "required", "customerAccount" | "intentKey" | "key" | "stripeAccountId">, {
64
+ by_key: ["key", "_creationTime"];
65
+ by_payer: ["customerAccount", "_creationTime"];
66
+ by_realm: ["stripeAccountId", "_creationTime"];
67
+ }, {}, {}>;
68
+ usageSubscriptionHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
69
+ fingerprint: string;
70
+ intentKey: string;
71
+ kind: "invoice" | "retirement" | "subscription";
72
+ observationJson: string;
73
+ resourceId: string;
74
+ startedAt: number;
75
+ }, {
76
+ intentKey: import("convex/values").VString<string, "required">;
77
+ kind: import("convex/values").VUnion<"invoice" | "retirement" | "subscription", [import("convex/values").VLiteral<"subscription", "required">, import("convex/values").VLiteral<"invoice", "required">, import("convex/values").VLiteral<"retirement", "required">], "required", never>;
78
+ resourceId: import("convex/values").VString<string, "required">;
79
+ fingerprint: import("convex/values").VString<string, "required">;
80
+ observationJson: import("convex/values").VString<string, "required">;
81
+ startedAt: import("convex/values").VFloat64<number, "required">;
82
+ }, "required", "fingerprint" | "intentKey" | "kind" | "observationJson" | "resourceId" | "startedAt">, {
83
+ by_fingerprint: ["fingerprint", "_creationTime"];
84
+ by_intent_kind: ["intentKey", "kind", "_creationTime"];
85
+ }, {}, {}>;
86
+ usageProviderObservations: import("convex/server").TableDefinition<import("convex/values").VObject<{
87
+ key: string;
88
+ observationJson: string;
89
+ scopeKey: string;
90
+ sourceJson: string;
91
+ startedAt: number;
92
+ }, {
93
+ key: import("convex/values").VString<string, "required">;
94
+ scopeKey: import("convex/values").VString<string, "required">;
95
+ sourceJson: import("convex/values").VString<string, "required">;
96
+ observationJson: import("convex/values").VString<string, "required">;
97
+ startedAt: import("convex/values").VFloat64<number, "required">;
98
+ }, "required", "key" | "observationJson" | "scopeKey" | "sourceJson" | "startedAt">, {
99
+ by_key: ["key", "_creationTime"];
100
+ }, {}, {}>;
101
+ usageDeliveryHistory: import("convex/server").TableDefinition<import("convex/values").VObject<{
102
+ attempt: number;
103
+ created?: number | undefined;
104
+ eventId: import("convex/values").GenericId<"usageEvents">;
105
+ identity: string;
106
+ phase: "accepted" | "held" | "rate_limited" | "rejected" | "resumed" | "retry_exhausted" | "started" | "unavailable" | "unknown" | "window_expired";
107
+ recordedAt: number;
108
+ scopeKey: string;
109
+ sequence: number;
110
+ }, {
111
+ scopeKey: import("convex/values").VString<string, "required">;
112
+ eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
113
+ sequence: import("convex/values").VFloat64<number, "required">;
114
+ attempt: import("convex/values").VFloat64<number, "required">;
115
+ phase: import("convex/values").VUnion<"accepted" | "held" | "rate_limited" | "rejected" | "resumed" | "retry_exhausted" | "started" | "unavailable" | "unknown" | "window_expired", [import("convex/values").VLiteral<"started", "required">, import("convex/values").VLiteral<"accepted", "required">, import("convex/values").VLiteral<"rate_limited", "required">, import("convex/values").VLiteral<"unavailable", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"rejected", "required">, import("convex/values").VLiteral<"held", "required">, import("convex/values").VLiteral<"resumed", "required">, import("convex/values").VLiteral<"window_expired", "required">, import("convex/values").VLiteral<"retry_exhausted", "required">], "required", never>;
116
+ identity: import("convex/values").VString<string, "required">;
117
+ recordedAt: import("convex/values").VFloat64<number, "required">;
118
+ created: import("convex/values").VFloat64<number | undefined, "optional">;
119
+ }, "required", "attempt" | "created" | "eventId" | "identity" | "phase" | "recordedAt" | "scopeKey" | "sequence">, {
120
+ by_event_identity: ["eventId", "identity", "_creationTime"];
121
+ by_event_sequence: ["eventId", "sequence", "_creationTime"];
122
+ }, {}, {}>;
2
123
  usageDeliveryLocks: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
124
  eventId?: import("convex/values").GenericId<"usageEvents"> | undefined;
4
125
  key: string;
@@ -29,6 +150,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
29
150
  }, "required", "code" | "dedupe" | "eventId" | "observedAt" | "providerEventId" | "scopeKey">, {
30
151
  by_dedupe: ["dedupe", "_creationTime"];
31
152
  by_event: ["eventId", "_creationTime"];
153
+ by_scope: ["scopeKey", "_creationTime"];
32
154
  }, {}, {}>;
33
155
  usageCatalog: import("convex/server").TableDefinition<import("convex/values").VObject<{
34
156
  firstAttemptAt: number;
@@ -59,8 +181,10 @@ declare const _default: import("convex/server").SchemaDefinition<{
59
181
  recordJson: string;
60
182
  reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
61
183
  scopeKey: string;
184
+ subscriptionId?: string | undefined;
62
185
  subscriptionJson: string;
63
186
  }, {
187
+ subscriptionId: import("convex/values").VString<string | undefined, "optional">;
64
188
  reservationId: import("convex/values").VId<import("convex/values").GenericId<"usageReservations"> | undefined, "optional">;
65
189
  scopeKey: import("convex/values").VString<string, "required">;
66
190
  identity: import("convex/values").VString<string, "required">;
@@ -68,8 +192,9 @@ declare const _default: import("convex/server").SchemaDefinition<{
68
192
  subscriptionJson: import("convex/values").VString<string, "required">;
69
193
  occurredAt: import("convex/values").VFloat64<number, "required">;
70
194
  acceptedAt: import("convex/values").VFloat64<number, "required">;
71
- }, "required", "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionJson">, {
195
+ }, "required", "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionId" | "subscriptionJson">, {
72
196
  by_identity: ["identity", "_creationTime"];
197
+ by_scope_subscription: ["scopeKey", "subscriptionId", "_creationTime"];
73
198
  by_scope_time: ["scopeKey", "occurredAt", "_creationTime"];
74
199
  }, {}, {}>;
75
200
  usageOutbox: import("convex/server").TableDefinition<import("convex/values").VObject<{
@@ -79,11 +204,12 @@ declare const _default: import("convex/server").SchemaDefinition<{
79
204
  eventId: import("convex/values").GenericId<"usageEvents">;
80
205
  firstSendAt?: number | undefined;
81
206
  held?: boolean | undefined;
207
+ historySequence?: number | undefined;
82
208
  leaseUntil?: number | undefined;
83
209
  nextAttemptAt: number;
84
210
  provider?: string | undefined;
85
211
  providerIdentifier: string;
86
- reason?: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
212
+ reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
87
213
  receipt?: {
88
214
  created: number;
89
215
  identifier: string;
@@ -92,13 +218,14 @@ declare const _default: import("convex/server").SchemaDefinition<{
92
218
  state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
93
219
  workflowId?: string | undefined;
94
220
  }, {
221
+ historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
95
222
  provider: import("convex/values").VString<string | undefined, "optional">;
96
223
  workflowId: import("convex/values").VString<string | undefined, "optional">;
97
224
  definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
98
225
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
99
226
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
100
227
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
101
- reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [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>;
228
+ 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>;
102
229
  receipt: import("convex/values").VObject<{
103
230
  created: number;
104
231
  identifier: string;
@@ -113,7 +240,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
113
240
  nextAttemptAt: import("convex/values").VFloat64<number, "required">;
114
241
  providerIdentifier: import("convex/values").VString<string, "required">;
115
242
  dispatch: import("convex/values").VString<string | undefined, "optional">;
116
- }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
243
+ }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
117
244
  by_event: ["eventId", "_creationTime"];
118
245
  by_provider_identifier: ["providerIdentifier", "_creationTime"];
119
246
  by_scope_state: ["scopeKey", "state", "_creationTime"];
@@ -144,6 +271,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
144
271
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents"> | undefined, "optional">;
145
272
  }, "required", "eventId" | "planJson" | "scaledQuantity" | "scopeKey" | "sourceEventId" | "state">, {
146
273
  by_scope_source: ["scopeKey", "sourceEventId", "_creationTime"];
274
+ by_scope_state: ["scopeKey", "state", "_creationTime"];
147
275
  }, {}, {}>;
148
276
  refundSyncClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
149
277
  acceptedAt?: number | undefined;
@@ -1,3 +1,5 @@
1
+ import { controlsTable as usageSubscriptionControls, intentsTable as usageSubscriptionIntents, locksTable as usageSubscriptionLocks, historyTable as usageSubscriptionHistory, } from "./usageSubscriptions/schema.js";
2
+ import { historyTable as usageDeliveryHistory, observationsTable as usageProviderObservations, } from "./usageObservations/schema.js";
1
3
  import { errorsTable as usageDeliveryErrors, locksTable as usageDeliveryLocks, } from "./usageDelivery/fields.js";
2
4
  import { claimsTable as refundSyncClaimsTable } from "./refundSync/schema.js";
3
5
  import { operationsTable as processingCostReconciliationOperations } from "./processingCostReconciliation/schema.js";
@@ -28,6 +30,12 @@ import { accountsTable } from "./core/schema";
28
30
  import { pricesTable, productsTable } from "./products/schema";
29
31
  import { webhookEventsTable } from "./webhooks/schema";
30
32
  export default defineSchema({
33
+ usageSubscriptionControls,
34
+ usageSubscriptionIntents,
35
+ usageSubscriptionLocks,
36
+ usageSubscriptionHistory,
37
+ usageProviderObservations,
38
+ usageDeliveryHistory,
31
39
  usageDeliveryLocks,
32
40
  usageDeliveryErrors,
33
41
  usageCatalog: usageCatalogTable,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,IAAI,mBAAmB,EAClC,UAAU,IAAI,kBAAkB,GACjC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,IAAI,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,eAAe,IAAI,sCAAsC,EAAE,MAAM,0CAA0C,CAAC;AACrH,OAAO,EACL,eAAe,IAAI,0BAA0B,EAC7C,aAAa,IAAI,wBAAwB,GAC1C,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,iBAAiB,IAAI,0BAA0B,EAC/C,eAAe,IAAI,wBAAwB,EAC3C,aAAa,IAAI,sBAAsB,GACxC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,GACzC,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oDAAoD,CAAC;AAClG,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,cAAc,EACd,gBAAgB,GACjB,M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BAAoB;IACrC,mBAAmB,EAAE,wBAAwB;IAC7C,OAAO;IACP,QAAQ,EAAE,aAAa;IACvB,eAAe,EAAE,oBAAoB;IAErC,WAAW;IACX,QAAQ,EAAE,aAAa;IACvB,MAAM,EAAE,WAAW;IAEnB,UAAU;IACV,aAAa,EAAE,kBAAkB;IACjC,gBAAgB,EAAE,qBAAqB;IACvC,QAAQ,EAAE,aAAa;IAEvB,UAAU;IACV,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,YAAY;IACrB,iBAAiB,EAAE,sBAAsB;IACzC,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,cAAc;IACzB,mBAAmB,EAAE,wBAAwB;IAE7C,WAAW;IACX,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/usage/mutations.ts"],"names":[],"mappings":"AAWA,4FAA4F;AAC5F,eAAO,MAAM,MAAM;;;;;;;;;;cA+CD,QAAQ;GA+ExB,CAAC"}
1
+ {"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/usage/mutations.ts"],"names":[],"mappings":"AAYA,4FAA4F;AAC5F,eAAO,MAAM,MAAM;;;;;;;;;;cA+CD,QAAQ;GAmFxB,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { managedBillingCutoff } from "../usageSubscriptions/acceptance.js";
1
2
  import { v } from "convex/values";
2
3
  import { mutation } from "../_generated/server.js";
3
4
  import { prepareUsageRecord, } from "../../client/usage/records.js";
@@ -52,6 +53,9 @@ export const record = mutation({
52
53
  };
53
54
  }
54
55
  const now = Math.floor(Date.now() / 1000);
56
+ const cutoff = await managedBillingCutoff(ctx, event, subscription);
57
+ if (cutoff !== null && now >= cutoff)
58
+ throw new Error("Managed usage billing period is closing or closed");
55
59
  if (event.occurredAt < now - 35 * 86400 || event.occurredAt > now + 300)
56
60
  throw new Error("Usage occurrence is outside the native delivery window");
57
61
  if (event.binding.stripePriceId !== subscription.stripePriceId ||
@@ -83,6 +87,7 @@ export const record = mutation({
83
87
  reservation.state !== "reserved"))
84
88
  throw new Error("Usage reservation does not match event");
85
89
  const eventId = await ctx.db.insert("usageEvents", {
90
+ subscriptionId: subscription.subscriptionId,
86
91
  reservationId: args.reservationId,
87
92
  scopeKey: key,
88
93
  identity: event.identity,
@@ -1 +1 @@
1
- {"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/usage/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EACL,kBAAkB,GAEnB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAE9D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;IAC7B,IAAI,EAAE;QACJ,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;QACrB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;QAC5B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;QAChC,aAAa,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC;QACpD,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KAC9B;IACD,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;QAChB,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC;QAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;QACpB,UAAU,EAAE,C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AU,EAAE,GAAG;YACf,QAAQ,EAAE,QAAiB;SAC5B,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -16,6 +16,7 @@ export declare const get: import("convex/server").RegisteredQuery<"public", {
16
16
  recordJson: string;
17
17
  reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
18
18
  scopeKey: string;
19
+ subscriptionId?: string | undefined;
19
20
  subscriptionJson: string;
20
21
  };
21
22
  delivery: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
@@ -54,6 +55,7 @@ export declare const read: import("convex/server").RegisteredQuery<"public", {
54
55
  recordJson: string;
55
56
  reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
56
57
  scopeKey: string;
58
+ subscriptionId?: string | undefined;
57
59
  subscriptionJson: string;
58
60
  };
59
61
  delivery: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/usage/queries.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;UAcd,CAAC;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCf,CAAC"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/usage/queries.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;UAcd,CAAC;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCf,CAAC"}
@@ -11,6 +11,7 @@ export declare const scopeValidator: import("convex/values").VObject<{
11
11
  }, "required", "customerAccount" | "livemode" | "meterId" | "stripeAccountId">;
12
12
  export declare const deliveryValidator: 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>;
13
13
  export declare const eventFields: {
14
+ subscriptionId: import("convex/values").VString<string | undefined, "optional">;
14
15
  reservationId: import("convex/values").VId<import("convex/values").GenericId<"usageReservations"> | undefined, "optional">;
15
16
  scopeKey: import("convex/values").VString<string, "required">;
16
17
  identity: import("convex/values").VString<string, "required">;
@@ -28,8 +29,10 @@ export declare const eventDoc: import("convex/values").VObject<{
28
29
  recordJson: string;
29
30
  reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
30
31
  scopeKey: string;
32
+ subscriptionId?: string | undefined;
31
33
  subscriptionJson: string;
32
34
  }, {
35
+ subscriptionId: import("convex/values").VString<string | undefined, "optional">;
33
36
  reservationId: import("convex/values").VId<import("convex/values").GenericId<"usageReservations"> | undefined, "optional">;
34
37
  scopeKey: import("convex/values").VString<string, "required">;
35
38
  identity: import("convex/values").VString<string, "required">;
@@ -39,7 +42,7 @@ export declare const eventDoc: import("convex/values").VObject<{
39
42
  acceptedAt: import("convex/values").VFloat64<number, "required">;
40
43
  _id: import("convex/values").VId<import("convex/values").GenericId<"usageEvents">, "required">;
41
44
  _creationTime: import("convex/values").VFloat64<number, "required">;
42
- }, "required", "_creationTime" | "_id" | "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionJson">;
45
+ }, "required", "_creationTime" | "_id" | "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionId" | "subscriptionJson">;
43
46
  export declare const usageEventsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
44
47
  acceptedAt: number;
45
48
  identity: string;
@@ -47,8 +50,10 @@ export declare const usageEventsTable: import("convex/server").TableDefinition<i
47
50
  recordJson: string;
48
51
  reservationId?: import("convex/values").GenericId<"usageReservations"> | undefined;
49
52
  scopeKey: string;
53
+ subscriptionId?: string | undefined;
50
54
  subscriptionJson: string;
51
55
  }, {
56
+ subscriptionId: import("convex/values").VString<string | undefined, "optional">;
52
57
  reservationId: import("convex/values").VId<import("convex/values").GenericId<"usageReservations"> | undefined, "optional">;
53
58
  scopeKey: import("convex/values").VString<string, "required">;
54
59
  identity: import("convex/values").VString<string, "required">;
@@ -56,18 +61,20 @@ export declare const usageEventsTable: import("convex/server").TableDefinition<i
56
61
  subscriptionJson: import("convex/values").VString<string, "required">;
57
62
  occurredAt: import("convex/values").VFloat64<number, "required">;
58
63
  acceptedAt: import("convex/values").VFloat64<number, "required">;
59
- }, "required", "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionJson">, {
64
+ }, "required", "acceptedAt" | "identity" | "occurredAt" | "recordJson" | "reservationId" | "scopeKey" | "subscriptionId" | "subscriptionJson">, {
60
65
  by_identity: ["identity", "_creationTime"];
66
+ by_scope_subscription: ["scopeKey", "subscriptionId", "_creationTime"];
61
67
  by_scope_time: ["scopeKey", "occurredAt", "_creationTime"];
62
68
  }, {}, {}>;
63
69
  export declare const outboxFields: {
70
+ historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
64
71
  provider: import("convex/values").VString<string | undefined, "optional">;
65
72
  workflowId: import("convex/values").VString<string | undefined, "optional">;
66
73
  definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
67
74
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
68
75
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
69
76
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
70
- reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [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>;
77
+ 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>;
71
78
  receipt: import("convex/values").VObject<{
72
79
  created: number;
73
80
  identifier: string;
@@ -92,11 +99,12 @@ export declare const outboxDoc: import("convex/values").VObject<{
92
99
  eventId: import("convex/values").GenericId<"usageEvents">;
93
100
  firstSendAt?: number | undefined;
94
101
  held?: boolean | undefined;
102
+ historySequence?: number | undefined;
95
103
  leaseUntil?: number | undefined;
96
104
  nextAttemptAt: number;
97
105
  provider?: string | undefined;
98
106
  providerIdentifier: string;
99
- reason?: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
107
+ reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
100
108
  receipt?: {
101
109
  created: number;
102
110
  identifier: string;
@@ -105,13 +113,14 @@ export declare const outboxDoc: import("convex/values").VObject<{
105
113
  state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
106
114
  workflowId?: string | undefined;
107
115
  }, {
116
+ historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
108
117
  provider: import("convex/values").VString<string | undefined, "optional">;
109
118
  workflowId: import("convex/values").VString<string | undefined, "optional">;
110
119
  definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
111
120
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
112
121
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
113
122
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
114
- reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [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>;
123
+ 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>;
115
124
  receipt: import("convex/values").VObject<{
116
125
  created: number;
117
126
  identifier: string;
@@ -128,7 +137,7 @@ export declare const outboxDoc: import("convex/values").VObject<{
128
137
  dispatch: import("convex/values").VString<string | undefined, "optional">;
129
138
  _id: import("convex/values").VId<import("convex/values").GenericId<"usageOutbox">, "required">;
130
139
  _creationTime: import("convex/values").VFloat64<number, "required">;
131
- }, "required", "_creationTime" | "_id" | "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">;
140
+ }, "required", "_creationTime" | "_id" | "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">;
132
141
  export declare const usageOutboxTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
133
142
  attempts: number;
134
143
  definitionVersion?: 1 | undefined;
@@ -136,11 +145,12 @@ export declare const usageOutboxTable: import("convex/server").TableDefinition<i
136
145
  eventId: import("convex/values").GenericId<"usageEvents">;
137
146
  firstSendAt?: number | undefined;
138
147
  held?: boolean | undefined;
148
+ historySequence?: number | undefined;
139
149
  leaseUntil?: number | undefined;
140
150
  nextAttemptAt: number;
141
151
  provider?: string | undefined;
142
152
  providerIdentifier: string;
143
- reason?: "administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
153
+ reason?: "administrative_hold" | "billing_period_closed" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined;
144
154
  receipt?: {
145
155
  created: number;
146
156
  identifier: string;
@@ -149,13 +159,14 @@ export declare const usageOutboxTable: import("convex/server").TableDefinition<i
149
159
  state: "held" | "provider_accepted" | "queued" | "rejected" | "sending" | "unknown";
150
160
  workflowId?: string | undefined;
151
161
  }, {
162
+ historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
152
163
  provider: import("convex/values").VString<string | undefined, "optional">;
153
164
  workflowId: import("convex/values").VString<string | undefined, "optional">;
154
165
  definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
155
166
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
156
167
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
157
168
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
158
- reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [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>;
169
+ 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>;
159
170
  receipt: import("convex/values").VObject<{
160
171
  created: number;
161
172
  identifier: string;
@@ -170,7 +181,7 @@ export declare const usageOutboxTable: import("convex/server").TableDefinition<i
170
181
  nextAttemptAt: import("convex/values").VFloat64<number, "required">;
171
182
  providerIdentifier: import("convex/values").VString<string, "required">;
172
183
  dispatch: import("convex/values").VString<string | undefined, "optional">;
173
- }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
184
+ }, "required", "attempts" | "definitionVersion" | "dispatch" | "eventId" | "firstSendAt" | "held" | "historySequence" | "leaseUntil" | "nextAttemptAt" | "provider" | "providerIdentifier" | "reason" | "receipt" | "receipt.created" | "receipt.identifier" | "scopeKey" | "state" | "workflowId">, {
174
185
  by_event: ["eventId", "_creationTime"];
175
186
  by_provider_identifier: ["providerIdentifier", "_creationTime"];
176
187
  by_scope_state: ["scopeKey", "state", "_creationTime"];
@@ -201,5 +212,6 @@ export declare const usageReservationsTable: import("convex/server").TableDefini
201
212
  eventId: import("convex/values").VId<import("convex/values").GenericId<"usageEvents"> | undefined, "optional">;
202
213
  }, "required", "eventId" | "planJson" | "scaledQuantity" | "scopeKey" | "sourceEventId" | "state">, {
203
214
  by_scope_source: ["scopeKey", "sourceEventId", "_creationTime"];
215
+ by_scope_state: ["scopeKey", "state", "_creationTime"];
204
216
  }, {}, {}>;
205
217
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/usage/schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;;;;8EAKzB,CAAC;AACH,eAAO,MAAM,iBAAiB,geAO7B,CAAC;AACF,eAAO,MAAM,WAAW;IACtB,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,gBAAgB;IAChB,UAAU;IACV,UAAU;CACX,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;qJAInB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;UAEwB,CAAC;AACtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;CASxB,CAAC;AACF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ySAIpB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIoB,CAAC;AAClD,eAAO,MAAM,uBAAuB;;;;;;;;UAGF,CAAC;AAInC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;UAWuB,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/usage/schema.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc;;;;;;;;;;8EAKzB,CAAC;AACH,eAAO,MAAM,iBAAiB,geAO7B,CAAC;AACF,eAAO,MAAM,WAAW;IACtB,cAAc;IACd,aAAa;IACb,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,gBAAgB;IAChB,UAAU;IACV,UAAU;CACX,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;wKAInB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;UAGwB,CAAC;AACtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;CASxB,CAAC;AACF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6TAIpB,CAAC;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAIoB,CAAC;AAClD,eAAO,MAAM,uBAAuB;;;;;;;;UAGF,CAAC;AAInC,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;UAac,CAAC"}
@@ -9,6 +9,7 @@ export const scopeValidator = v.object({
9
9
  });
10
10
  export const deliveryValidator = v.union(v.literal("queued"), v.literal("sending"), v.literal("provider_accepted"), v.literal("rejected"), v.literal("unknown"), v.literal("held"));
11
11
  export const eventFields = {
12
+ subscriptionId: v.optional(v.string()),
12
13
  reservationId: v.optional(v.id("usageReservations")),
13
14
  scopeKey: v.string(),
14
15
  identity: v.string(),
@@ -24,6 +25,7 @@ export const eventDoc = v.object({
24
25
  });
25
26
  export const usageEventsTable = defineTable(eventFields)
26
27
  .index("by_identity", ["identity"])
28
+ .index("by_scope_subscription", ["scopeKey", "subscriptionId"])
27
29
  .index("by_scope_time", ["scopeKey", "occurredAt"]);
28
30
  export const outboxFields = {
29
31
  ...deliveryFields,
@@ -59,5 +61,7 @@ export const usageReservationsTable = defineTable({
59
61
  scaledQuantity: v.string(),
60
62
  state: v.union(v.literal("reserved"), v.literal("committed"), v.literal("released")),
61
63
  eventId: v.optional(v.id("usageEvents")),
62
- }).index("by_scope_source", ["scopeKey", "sourceEventId"]);
64
+ })
65
+ .index("by_scope_source", ["scopeKey", "sourceEventId"])
66
+ .index("by_scope_state", ["scopeKey", "state"]);
63
67
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/usage/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;CACtB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CACtC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EACnB,CAAC,CA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AAgB,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC,CAAC"}
@@ -1,13 +1,14 @@
1
- export declare const reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy", [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">], "required", never>;
1
+ export declare const 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", [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">], "required", never>;
2
2
  export { usageDeliveryOutcomeValidator as outcome } from "../../client/usage/deliveryProtocol.js";
3
3
  export declare const deliveryFields: {
4
+ historySequence: import("convex/values").VFloat64<number | undefined, "optional">;
4
5
  provider: import("convex/values").VString<string | undefined, "optional">;
5
6
  workflowId: import("convex/values").VString<string | undefined, "optional">;
6
7
  definitionVersion: import("convex/values").VLiteral<1 | undefined, "optional">;
7
8
  firstSendAt: import("convex/values").VFloat64<number | undefined, "optional">;
8
9
  leaseUntil: import("convex/values").VFloat64<number | undefined, "optional">;
9
10
  held: import("convex/values").VBoolean<boolean | undefined, "optional">;
10
- reason: import("convex/values").VUnion<"administrative_hold" | "delivery_window_expired" | "provider_outcome_unknown" | "provider_rejected" | "provider_unavailable" | "rate_limited" | "retry_exhausted" | "scope_busy" | undefined, [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>;
11
+ 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>;
11
12
  receipt: import("convex/values").VObject<{
12
13
  created: number;
13
14
  identifier: string;
@@ -74,5 +75,6 @@ export declare const errorsTable: import("convex/server").TableDefinition<import
74
75
  }, "required", "code" | "dedupe" | "eventId" | "observedAt" | "providerEventId" | "scopeKey">, {
75
76
  by_dedupe: ["dedupe", "_creationTime"];
76
77
  by_event: ["eventId", "_creationTime"];
78
+ by_scope: ["scopeKey", "_creationTime"];
77
79
  }, {}, {}>;
78
80
  //# sourceMappingURL=fields.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/fields.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,owBASlB,CAAC;AACF,OAAO,EAAE,6BAA6B,IAAI,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAClG,eAAO,MAAM,cAAc;IACzB,QAAQ;IACR,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,UAAU;IACV,IAAI;IACJ,MAAM;IACN,OAAO;;;;;;;CAGR,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;UAKI,CAAC;AAE5B,eAAO,MAAM,SAAS,i9BAUrB,CAAC;AACF,eAAO,MAAM,WAAW;IACtB,QAAQ;IACR,OAAO;IACP,eAAe;IACf,IAAI;IACJ,UAAU;IACV,MAAM;CACP,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;uHAInB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;UAES,CAAC"}
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../../src/component/usageDelivery/fields.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,q2BAUlB,CAAC;AACF,OAAO,EAAE,6BAA6B,IAAI,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAClG,eAAO,MAAM,cAAc;IACzB,eAAe;IACf,QAAQ;IACR,UAAU;IACV,iBAAiB;IACjB,WAAW;IACX,UAAU;IACV,IAAI;IACJ,MAAM;IACN,OAAO;;;;;;;CAGR,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;UAKI,CAAC;AAE5B,eAAO,MAAM,SAAS,i9BAUrB,CAAC;AACF,eAAO,MAAM,WAAW;IACtB,QAAQ;IACR,OAAO;IACP,eAAe;IACf,IAAI;IACJ,UAAU;IACV,MAAM;CACP,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;uHAInB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;UAGS,CAAC"}
@@ -1,8 +1,9 @@
1
1
  import { defineTable } from "convex/server";
2
2
  import { v } from "convex/values";
3
- export const reason = v.union(v.literal("rate_limited"), v.literal("provider_unavailable"), v.literal("provider_outcome_unknown"), v.literal("provider_rejected"), v.literal("retry_exhausted"), v.literal("delivery_window_expired"), v.literal("scope_busy"), v.literal("administrative_hold"));
3
+ export const reason = v.union(v.literal("billing_period_closed"), v.literal("rate_limited"), v.literal("provider_unavailable"), v.literal("provider_outcome_unknown"), v.literal("provider_rejected"), v.literal("retry_exhausted"), v.literal("delivery_window_expired"), v.literal("scope_busy"), v.literal("administrative_hold"));
4
4
  export { usageDeliveryOutcomeValidator as outcome } from "../../client/usage/deliveryProtocol.js";
5
5
  export const deliveryFields = {
6
+ historySequence: v.optional(v.number()),
6
7
  provider: v.optional(v.string()),
7
8
  workflowId: v.optional(v.string()),
8
9
  definitionVersion: v.optional(v.literal(1)),
@@ -34,5 +35,6 @@ export const errorDoc = v.object({
34
35
  });
35
36
  export const errorsTable = defineTable(errorFields)
36
37
  .index("by_dedupe", ["dedupe"])
38
+ .index("by_scope", ["scopeKey"])
37
39
  .index("by_event", ["eventId"]);
38
40
  //# sourceMappingURL=fields.js.map