@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
@@ -0,0 +1,80 @@
1
+ import { retirementProof } from "../../client/usage/subscriptionInvoiceSchema.js";
2
+ import { scopeKey } from "../usage/helpers.js";
3
+ import { jsonTerms } from "./helpers.js";
4
+ import { appendSnapshot } from "./history.js";
5
+ export async function retireEnrollment(ctx, intent, proofJson) {
6
+ if (new TextEncoder().encode(proofJson).length > 4096)
7
+ throw new Error("Retirement evidence exceeds size limit");
8
+ const proof = retirementProof.parse(JSON.parse(proofJson)), { terms } = jsonTerms(intent.termsJson), first = terms.meters[0];
9
+ const view = intent.viewJson
10
+ ? JSON.parse(intent.viewJson)
11
+ : null;
12
+ if (!view ||
13
+ view.status !== "canceled" ||
14
+ proof.subscriptionId !== intent.providerId ||
15
+ proof.stripeAccountId !== first.scope.stripeAccountId ||
16
+ proof.customerAccount !== first.scope.customerAccount ||
17
+ proof.stripeCustomerId !== first.binding.stripeCustomerId ||
18
+ proof.livemode !== first.scope.livemode ||
19
+ proof.periodEnd < Math.max(...view.items.map((item) => item.period.end)) ||
20
+ proof.finalizedAt < proof.periodEnd)
21
+ throw new Error("Enrollment retirement requires canceled subscription and finalized period-end invoice");
22
+ if (intent.retirementInvoiceId) {
23
+ if (intent.retirementInvoiceId !== proof.invoiceId)
24
+ throw new Error("Retirement invoice replay conflict");
25
+ return;
26
+ }
27
+ if (intent.controlKey)
28
+ throw new Error("Cancellation command is still pending");
29
+ for (const meter of terms.meters) {
30
+ const key = scopeKey(meter.scope);
31
+ for (const state of [
32
+ "queued",
33
+ "sending",
34
+ "unknown",
35
+ "held",
36
+ "rejected",
37
+ ]) {
38
+ const pending = await ctx.db
39
+ .query("usageOutbox")
40
+ .withIndex("by_scope_state", (q) => q.eq("scopeKey", key).eq("state", state))
41
+ .take(1);
42
+ if (pending.length)
43
+ throw new Error("Enrollment has unresolved usage delivery");
44
+ }
45
+ const reservations = await ctx.db
46
+ .query("usageReservations")
47
+ .withIndex("by_scope_state", (q) => q.eq("scopeKey", key).eq("state", "reserved"))
48
+ .take(1);
49
+ const errors = await ctx.db
50
+ .query("usageDeliveryErrors")
51
+ .withIndex("by_scope", (q) => q.eq("scopeKey", key))
52
+ .take(1);
53
+ if (reservations.length || errors.length)
54
+ throw new Error("Enrollment has pending reservations or validation errors");
55
+ }
56
+ await appendSnapshot(ctx, intent, "retirement", intent.providerId, {
57
+ proof,
58
+ creditTreatment: "retain_original_terms",
59
+ billingReconciliation: "required",
60
+ }, Date.now());
61
+ for (const { scope, binding } of terms.meters) {
62
+ const key = JSON.stringify([
63
+ scope.stripeAccountId,
64
+ scope.livemode,
65
+ binding.stripeCustomerId,
66
+ scope.meterId,
67
+ ]);
68
+ const lock = await ctx.db
69
+ .query("usageSubscriptionLocks")
70
+ .withIndex("by_key", (q) => q.eq("key", key))
71
+ .unique();
72
+ if (lock?.intentKey === intent.key)
73
+ await ctx.db.delete("usageSubscriptionLocks", lock._id);
74
+ }
75
+ await ctx.db.patch("usageSubscriptionIntents", intent._id, {
76
+ retiredAt: Math.floor(Date.now() / 1000),
77
+ retirementInvoiceId: proof.invoiceId,
78
+ });
79
+ }
80
+ //# sourceMappingURL=retirement.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retirement.js","sourceRoot":"","sources":["../../../src/component/usageSubscriptions/retirement.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,MAAM,CAAC,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AAC;AACL,CAAC"}
@@ -0,0 +1,191 @@
1
+ export declare const method: import("convex/values").VUnion<"checkout" | "direct", [import("convex/values").VLiteral<"direct", "required">, import("convex/values").VLiteral<"checkout", "required">], "required", never>;
2
+ export declare const intentFields: {
3
+ key: import("convex/values").VString<string, "required">;
4
+ scopeKey: import("convex/values").VString<string, "required">;
5
+ termsJson: import("convex/values").VString<string, "required">;
6
+ method: import("convex/values").VUnion<"checkout" | "direct", [import("convex/values").VLiteral<"direct", "required">, import("convex/values").VLiteral<"checkout", "required">], "required", never>;
7
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
8
+ providerId: import("convex/values").VString<string | undefined, "optional">;
9
+ checkoutId: import("convex/values").VString<string | undefined, "optional">;
10
+ viewJson: import("convex/values").VString<string | undefined, "optional">;
11
+ startedAt: import("convex/values").VFloat64<number | undefined, "optional">;
12
+ controlKey: import("convex/values").VString<string | undefined, "optional">;
13
+ historyCount: import("convex/values").VFloat64<number | undefined, "optional">;
14
+ retiredAt: import("convex/values").VFloat64<number | undefined, "optional">;
15
+ abandonedId: import("convex/values").VString<string | undefined, "optional">;
16
+ retirementInvoiceId: import("convex/values").VString<string | undefined, "optional">;
17
+ };
18
+ export declare const intentDoc: import("convex/values").VObject<{
19
+ _creationTime: number;
20
+ _id: import("convex/values").GenericId<"usageSubscriptionIntents">;
21
+ abandonedId?: string | undefined;
22
+ checkoutId?: string | undefined;
23
+ controlKey?: string | undefined;
24
+ firstAttemptAt: number;
25
+ historyCount?: number | undefined;
26
+ key: string;
27
+ method: "checkout" | "direct";
28
+ providerId?: string | undefined;
29
+ retiredAt?: number | undefined;
30
+ retirementInvoiceId?: string | undefined;
31
+ scopeKey: string;
32
+ startedAt?: number | undefined;
33
+ termsJson: string;
34
+ viewJson?: string | undefined;
35
+ }, {
36
+ key: import("convex/values").VString<string, "required">;
37
+ scopeKey: import("convex/values").VString<string, "required">;
38
+ termsJson: import("convex/values").VString<string, "required">;
39
+ method: import("convex/values").VUnion<"checkout" | "direct", [import("convex/values").VLiteral<"direct", "required">, import("convex/values").VLiteral<"checkout", "required">], "required", never>;
40
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
41
+ providerId: import("convex/values").VString<string | undefined, "optional">;
42
+ checkoutId: import("convex/values").VString<string | undefined, "optional">;
43
+ viewJson: import("convex/values").VString<string | undefined, "optional">;
44
+ startedAt: import("convex/values").VFloat64<number | undefined, "optional">;
45
+ controlKey: import("convex/values").VString<string | undefined, "optional">;
46
+ historyCount: import("convex/values").VFloat64<number | undefined, "optional">;
47
+ retiredAt: import("convex/values").VFloat64<number | undefined, "optional">;
48
+ abandonedId: import("convex/values").VString<string | undefined, "optional">;
49
+ retirementInvoiceId: import("convex/values").VString<string | undefined, "optional">;
50
+ _id: import("convex/values").VId<import("convex/values").GenericId<"usageSubscriptionIntents">, "required">;
51
+ _creationTime: import("convex/values").VFloat64<number, "required">;
52
+ }, "required", "_creationTime" | "_id" | "abandonedId" | "checkoutId" | "controlKey" | "firstAttemptAt" | "historyCount" | "key" | "method" | "providerId" | "retiredAt" | "retirementInvoiceId" | "scopeKey" | "startedAt" | "termsJson" | "viewJson">;
53
+ export declare const intentsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
54
+ abandonedId?: string | undefined;
55
+ checkoutId?: string | undefined;
56
+ controlKey?: string | undefined;
57
+ firstAttemptAt: number;
58
+ historyCount?: number | undefined;
59
+ key: string;
60
+ method: "checkout" | "direct";
61
+ providerId?: string | undefined;
62
+ retiredAt?: number | undefined;
63
+ retirementInvoiceId?: string | undefined;
64
+ scopeKey: string;
65
+ startedAt?: number | undefined;
66
+ termsJson: string;
67
+ viewJson?: string | undefined;
68
+ }, {
69
+ key: import("convex/values").VString<string, "required">;
70
+ scopeKey: import("convex/values").VString<string, "required">;
71
+ termsJson: import("convex/values").VString<string, "required">;
72
+ method: import("convex/values").VUnion<"checkout" | "direct", [import("convex/values").VLiteral<"direct", "required">, import("convex/values").VLiteral<"checkout", "required">], "required", never>;
73
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
74
+ providerId: import("convex/values").VString<string | undefined, "optional">;
75
+ checkoutId: import("convex/values").VString<string | undefined, "optional">;
76
+ viewJson: import("convex/values").VString<string | undefined, "optional">;
77
+ startedAt: import("convex/values").VFloat64<number | undefined, "optional">;
78
+ controlKey: import("convex/values").VString<string | undefined, "optional">;
79
+ historyCount: import("convex/values").VFloat64<number | undefined, "optional">;
80
+ retiredAt: import("convex/values").VFloat64<number | undefined, "optional">;
81
+ abandonedId: import("convex/values").VString<string | undefined, "optional">;
82
+ retirementInvoiceId: import("convex/values").VString<string | undefined, "optional">;
83
+ }, "required", "abandonedId" | "checkoutId" | "controlKey" | "firstAttemptAt" | "historyCount" | "key" | "method" | "providerId" | "retiredAt" | "retirementInvoiceId" | "scopeKey" | "startedAt" | "termsJson" | "viewJson">, {
84
+ by_key: ["key", "_creationTime"];
85
+ by_provider: ["providerId", "_creationTime"];
86
+ }, {}, {}>;
87
+ export declare const locksTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
88
+ customerAccount: string;
89
+ intentKey: string;
90
+ key: string;
91
+ stripeAccountId: string;
92
+ }, {
93
+ key: import("convex/values").VString<string, "required">;
94
+ intentKey: import("convex/values").VString<string, "required">;
95
+ stripeAccountId: import("convex/values").VString<string, "required">;
96
+ customerAccount: import("convex/values").VString<string, "required">;
97
+ }, "required", "customerAccount" | "intentKey" | "key" | "stripeAccountId">, {
98
+ by_key: ["key", "_creationTime"];
99
+ by_payer: ["customerAccount", "_creationTime"];
100
+ by_realm: ["stripeAccountId", "_creationTime"];
101
+ }, {}, {}>;
102
+ export declare const historyFields: {
103
+ intentKey: import("convex/values").VString<string, "required">;
104
+ 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>;
105
+ resourceId: import("convex/values").VString<string, "required">;
106
+ fingerprint: import("convex/values").VString<string, "required">;
107
+ observationJson: import("convex/values").VString<string, "required">;
108
+ startedAt: import("convex/values").VFloat64<number, "required">;
109
+ };
110
+ export declare const historyDoc: import("convex/values").VObject<{
111
+ _creationTime: number;
112
+ _id: import("convex/values").GenericId<"usageSubscriptionHistory">;
113
+ fingerprint: string;
114
+ intentKey: string;
115
+ kind: "invoice" | "retirement" | "subscription";
116
+ observationJson: string;
117
+ resourceId: string;
118
+ startedAt: number;
119
+ }, {
120
+ intentKey: import("convex/values").VString<string, "required">;
121
+ 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>;
122
+ resourceId: import("convex/values").VString<string, "required">;
123
+ fingerprint: import("convex/values").VString<string, "required">;
124
+ observationJson: import("convex/values").VString<string, "required">;
125
+ startedAt: import("convex/values").VFloat64<number, "required">;
126
+ _id: import("convex/values").VId<import("convex/values").GenericId<"usageSubscriptionHistory">, "required">;
127
+ _creationTime: import("convex/values").VFloat64<number, "required">;
128
+ }, "required", "_creationTime" | "_id" | "fingerprint" | "intentKey" | "kind" | "observationJson" | "resourceId" | "startedAt">;
129
+ export declare const historyTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
130
+ fingerprint: string;
131
+ intentKey: string;
132
+ kind: "invoice" | "retirement" | "subscription";
133
+ observationJson: string;
134
+ resourceId: string;
135
+ startedAt: number;
136
+ }, {
137
+ intentKey: import("convex/values").VString<string, "required">;
138
+ 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>;
139
+ resourceId: import("convex/values").VString<string, "required">;
140
+ fingerprint: import("convex/values").VString<string, "required">;
141
+ observationJson: import("convex/values").VString<string, "required">;
142
+ startedAt: import("convex/values").VFloat64<number, "required">;
143
+ }, "required", "fingerprint" | "intentKey" | "kind" | "observationJson" | "resourceId" | "startedAt">, {
144
+ by_fingerprint: ["fingerprint", "_creationTime"];
145
+ by_intent_kind: ["intentKey", "kind", "_creationTime"];
146
+ }, {}, {}>;
147
+ export declare const controlFields: {
148
+ key: import("convex/values").VString<string, "required">;
149
+ intentKey: import("convex/values").VString<string, "required">;
150
+ operationId: import("convex/values").VString<string, "required">;
151
+ cancelAtPeriodEnd: import("convex/values").VBoolean<boolean, "required">;
152
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
153
+ resultJson: import("convex/values").VString<string | undefined, "optional">;
154
+ };
155
+ export declare const controlDoc: import("convex/values").VObject<{
156
+ _creationTime: number;
157
+ _id: import("convex/values").GenericId<"usageSubscriptionControls">;
158
+ cancelAtPeriodEnd: boolean;
159
+ firstAttemptAt: number;
160
+ intentKey: string;
161
+ key: string;
162
+ operationId: string;
163
+ resultJson?: string | undefined;
164
+ }, {
165
+ key: import("convex/values").VString<string, "required">;
166
+ intentKey: import("convex/values").VString<string, "required">;
167
+ operationId: import("convex/values").VString<string, "required">;
168
+ cancelAtPeriodEnd: import("convex/values").VBoolean<boolean, "required">;
169
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
170
+ resultJson: import("convex/values").VString<string | undefined, "optional">;
171
+ _id: import("convex/values").VId<import("convex/values").GenericId<"usageSubscriptionControls">, "required">;
172
+ _creationTime: import("convex/values").VFloat64<number, "required">;
173
+ }, "required", "_creationTime" | "_id" | "cancelAtPeriodEnd" | "firstAttemptAt" | "intentKey" | "key" | "operationId" | "resultJson">;
174
+ export declare const controlsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
175
+ cancelAtPeriodEnd: boolean;
176
+ firstAttemptAt: number;
177
+ intentKey: string;
178
+ key: string;
179
+ operationId: string;
180
+ resultJson?: string | undefined;
181
+ }, {
182
+ key: import("convex/values").VString<string, "required">;
183
+ intentKey: import("convex/values").VString<string, "required">;
184
+ operationId: import("convex/values").VString<string, "required">;
185
+ cancelAtPeriodEnd: import("convex/values").VBoolean<boolean, "required">;
186
+ firstAttemptAt: import("convex/values").VFloat64<number, "required">;
187
+ resultJson: import("convex/values").VString<string | undefined, "optional">;
188
+ }, "required", "cancelAtPeriodEnd" | "firstAttemptAt" | "intentKey" | "key" | "operationId" | "resultJson">, {
189
+ by_key: ["key", "_creationTime"];
190
+ }, {}, {}>;
191
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/usageSubscriptions/schema.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,8LAAsD,CAAC;AAC1E,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;CAexB,CAAC;AACF,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uPAIpB,CAAC;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAEc,CAAC;AACxC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;UAQkB,CAAC;AAC1C,eAAO,MAAM,aAAa;IACxB,SAAS;IACT,IAAI;IAKJ,UAAU;IACV,WAAW;IACX,eAAe;IACf,SAAS;CACV,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;+HAIrB,CAAC;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;UAEwB,CAAC;AAElD,eAAO,MAAM,aAAa;IACxB,GAAG;IACH,SAAS;IACT,WAAW;IACX,iBAAiB;IACjB,cAAc;IACd,UAAU;CACX,CAAC;AACF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;qIAIrB,CAAC;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;UAExB,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { defineTable } from "convex/server";
2
+ import { v } from "convex/values";
3
+ export const method = v.union(v.literal("direct"), v.literal("checkout"));
4
+ export const intentFields = {
5
+ key: v.string(),
6
+ scopeKey: v.string(),
7
+ termsJson: v.string(),
8
+ method,
9
+ firstAttemptAt: v.number(),
10
+ providerId: v.optional(v.string()),
11
+ checkoutId: v.optional(v.string()),
12
+ viewJson: v.optional(v.string()),
13
+ startedAt: v.optional(v.number()),
14
+ controlKey: v.optional(v.string()),
15
+ historyCount: v.optional(v.number()),
16
+ retiredAt: v.optional(v.number()),
17
+ abandonedId: v.optional(v.string()),
18
+ retirementInvoiceId: v.optional(v.string()),
19
+ };
20
+ export const intentDoc = v.object({
21
+ _id: v.id("usageSubscriptionIntents"),
22
+ _creationTime: v.number(),
23
+ ...intentFields,
24
+ });
25
+ export const intentsTable = defineTable(intentFields)
26
+ .index("by_key", ["key"])
27
+ .index("by_provider", ["providerId"]);
28
+ export const locksTable = defineTable({
29
+ key: v.string(),
30
+ intentKey: v.string(),
31
+ stripeAccountId: v.string(),
32
+ customerAccount: v.string(),
33
+ })
34
+ .index("by_key", ["key"])
35
+ .index("by_realm", ["stripeAccountId"])
36
+ .index("by_payer", ["customerAccount"]);
37
+ export const historyFields = {
38
+ intentKey: v.string(),
39
+ kind: v.union(v.literal("subscription"), v.literal("invoice"), v.literal("retirement")),
40
+ resourceId: v.string(),
41
+ fingerprint: v.string(),
42
+ observationJson: v.string(),
43
+ startedAt: v.number(),
44
+ };
45
+ export const historyDoc = v.object({
46
+ _id: v.id("usageSubscriptionHistory"),
47
+ _creationTime: v.number(),
48
+ ...historyFields,
49
+ });
50
+ export const historyTable = defineTable(historyFields)
51
+ .index("by_fingerprint", ["fingerprint"])
52
+ .index("by_intent_kind", ["intentKey", "kind"]);
53
+ export const controlFields = {
54
+ key: v.string(),
55
+ intentKey: v.string(),
56
+ operationId: v.string(),
57
+ cancelAtPeriodEnd: v.boolean(),
58
+ firstAttemptAt: v.number(),
59
+ resultJson: v.optional(v.string()),
60
+ };
61
+ export const controlDoc = v.object({
62
+ _id: v.id("usageSubscriptionControls"),
63
+ _creationTime: v.number(),
64
+ ...controlFields,
65
+ });
66
+ export const controlsTable = defineTable(controlFields).index("by_key", [
67
+ "key",
68
+ ]);
69
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/usageSubscriptions/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;AAC1E,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,MAAM;IACN,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAClC,YAAY,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACpC,SAAS,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,mBAAmB,EA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AE,CAAC,CAAC,MAAM,EAAE;CACtB,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,0BAA0B,CAAC;IACrC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,GAAG,aAAa;CACjB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC,aAAa,CAAC;KACnD,KAAK,CAAC,gBAAgB,EAAE,CAAC,aAAa,CAAC,CAAC;KACxC,KAAK,CAAC,gBAAgB,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;IACf,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;IACvB,iBAAiB,EAAE,CAAC,CAAC,OAAO,EAAE;IAC9B,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,UAAU,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACnC,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,2BAA2B,CAAC;IACtC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;IACzB,GAAG,aAAa;CACjB,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE;IACtE,KAAK;CACN,CAAC,CAAC"}
package/dist/test.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import schema from "./component/schema";
2
+ export { schema };
3
+ export declare const modules: {
4
+ [k: string]: () => Promise<unknown>;
5
+ };
6
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,CAAC;AAalB,eAAO,MAAM,OAAO;;CAKnB,CAAC"}
package/dist/test.js ADDED
@@ -0,0 +1,15 @@
1
+ import schema from "./component/schema";
2
+ export { schema };
3
+ // Load Convex functions during fixture import so the first action does not
4
+ // spend its execution timeout compiling the function graph.
5
+ const functionModules = import.meta.glob([
6
+ "./component/**/*.ts",
7
+ "!./component/**/*.test.*",
8
+ "!./component/**/*.fixtures.ts",
9
+ "!./component/**/convex.config.*",
10
+ ], { eager: true });
11
+ export const modules = Object.fromEntries(Object.entries(functionModules).map(([path, module]) => [
12
+ path,
13
+ () => Promise.resolve(module),
14
+ ]));
15
+ //# sourceMappingURL=test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,OAAO,EAAE,MAAM,EAAE,CAAC;AAElB,2EAA2E;AAC3E,4DAA4D;AAC5D,MAAM,eAAe,GAAG,OAAO,IAAI,CAAC,IAAI,CACtC;IACE,qBAAqB;IACrB,0BAA0B;IAC1B,+BAA+B;IAC/B,iCAAiC;CAClC,EACD,EAAE,KAAK,EAAE,IAAI,EAAE,CAChB,CAAC;AACF,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,WAAW,CACvC,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;IACtD,IAAI;IACJ,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;CAC9B,CAAC,CACH,CAAC"}
package/docs/README.md CHANGED
@@ -62,3 +62,7 @@ Start with the [native Stripe setup guide](metering-setup.md), then read the
62
62
  [Native usage catalog](usage-catalog.md) covers provisioning, immutable versions and typed price observations.
63
63
 
64
64
  [Durable native delivery](usage-delivery.md) explains host actions, bounded retries, operational holds and asynchronous errors.
65
+
66
+ [Usage observations and reconciliation](usage-observations.md) covers exact summaries, paginated audit history, native freshness and invoice observations.
67
+
68
+ [Managed metered subscriptions and invoice lifecycle](usage-subscriptions.md) covers all three models, Checkout, renewal, closeout and native test clocks.
@@ -0,0 +1,129 @@
1
+ {
2
+ "apiVersion": "2026-09-30.endive",
3
+ "observedAt": "2026-10-18T08:16:50.149Z",
4
+ "models": [
5
+ {
6
+ "model": "pay_as_you_go",
7
+ "catalogCreated": true,
8
+ "eventAccepted": true,
9
+ "aggregatedQuantity": 15,
10
+ "aggregationVerified": true,
11
+ "duplicateRetryVerified": true,
12
+ "invoiceIdentityVerified": true,
13
+ "previewTotal": 30,
14
+ "currency": "usd",
15
+ "paymentVerified": false,
16
+ "creditPurchaseVerified": false,
17
+ "invoiceFinalizationVerified": true,
18
+ "finalizedTotal": 30,
19
+ "finalizedCurrency": "usd",
20
+ "finalizedAmountVerified": true,
21
+ "finalizedPaymentEvidence": "not_resolved"
22
+ },
23
+ {
24
+ "model": "included_overage",
25
+ "catalogCreated": true,
26
+ "eventAccepted": true,
27
+ "aggregatedQuantity": 15,
28
+ "aggregationVerified": true,
29
+ "duplicateRetryVerified": true,
30
+ "invoiceIdentityVerified": true,
31
+ "previewTotal": 10,
32
+ "currency": "usd",
33
+ "paymentVerified": false,
34
+ "creditPurchaseVerified": false,
35
+ "invoiceFinalizationVerified": true,
36
+ "finalizedTotal": 10,
37
+ "finalizedCurrency": "usd",
38
+ "finalizedAmountVerified": true,
39
+ "finalizedPaymentEvidence": "not_resolved"
40
+ },
41
+ {
42
+ "model": "prepaid",
43
+ "catalogCreated": true,
44
+ "eventAccepted": true,
45
+ "aggregatedQuantity": 15,
46
+ "aggregationVerified": true,
47
+ "duplicateRetryVerified": true,
48
+ "invoiceIdentityVerified": true,
49
+ "previewTotal": 0,
50
+ "currency": "usd",
51
+ "paymentVerified": true,
52
+ "creditPurchaseVerified": true,
53
+ "invoiceFinalizationVerified": true,
54
+ "finalizedTotal": 0,
55
+ "finalizedCurrency": "usd",
56
+ "finalizedAmountVerified": true,
57
+ "finalizedPaymentEvidence": "not_resolved"
58
+ }
59
+ ],
60
+ "cleanup": [
61
+ {
62
+ "kind": "credit",
63
+ "success": true
64
+ },
65
+ {
66
+ "kind": "test-payment-refund",
67
+ "success": true
68
+ },
69
+ {
70
+ "kind": "subscription",
71
+ "success": true
72
+ },
73
+ {
74
+ "kind": "price",
75
+ "success": true
76
+ },
77
+ {
78
+ "kind": "product",
79
+ "success": true
80
+ },
81
+ {
82
+ "kind": "meter",
83
+ "success": true
84
+ },
85
+ {
86
+ "kind": "subscription",
87
+ "success": true
88
+ },
89
+ {
90
+ "kind": "price",
91
+ "success": true
92
+ },
93
+ {
94
+ "kind": "product",
95
+ "success": true
96
+ },
97
+ {
98
+ "kind": "meter",
99
+ "success": true
100
+ },
101
+ {
102
+ "kind": "subscription",
103
+ "success": true
104
+ },
105
+ {
106
+ "kind": "price",
107
+ "success": true
108
+ },
109
+ {
110
+ "kind": "product",
111
+ "success": true
112
+ },
113
+ {
114
+ "kind": "meter",
115
+ "success": true
116
+ },
117
+ {
118
+ "kind": "test-clock",
119
+ "success": true
120
+ }
121
+ ],
122
+ "payerMappingVerified": true,
123
+ "testClock": {
124
+ "ingestedBeforeAdvance": true,
125
+ "advanced": true,
126
+ "ready": true,
127
+ "advancementDoesNotProveIngestion": true
128
+ }
129
+ }
@@ -0,0 +1,111 @@
1
+ {
2
+ "apiVersion": "2026-09-30.endive",
3
+ "observedAt": "2026-10-18T08:08:03.167Z",
4
+ "models": [
5
+ {
6
+ "model": "pay_as_you_go",
7
+ "catalogCreated": true,
8
+ "eventAccepted": true,
9
+ "aggregatedQuantity": 15,
10
+ "aggregationVerified": true,
11
+ "duplicateRetryVerified": true,
12
+ "invoiceIdentityVerified": true,
13
+ "previewTotal": 30,
14
+ "currency": "usd",
15
+ "paymentVerified": false,
16
+ "creditPurchaseVerified": false,
17
+ "invoiceFinalizationVerified": false
18
+ },
19
+ {
20
+ "model": "included_overage",
21
+ "catalogCreated": true,
22
+ "eventAccepted": true,
23
+ "aggregatedQuantity": 15,
24
+ "aggregationVerified": true,
25
+ "duplicateRetryVerified": true,
26
+ "invoiceIdentityVerified": true,
27
+ "previewTotal": 10,
28
+ "currency": "usd",
29
+ "paymentVerified": false,
30
+ "creditPurchaseVerified": false,
31
+ "invoiceFinalizationVerified": false
32
+ },
33
+ {
34
+ "model": "prepaid",
35
+ "catalogCreated": true,
36
+ "eventAccepted": true,
37
+ "aggregatedQuantity": 0,
38
+ "aggregationVerified": false,
39
+ "duplicateRetryVerified": false,
40
+ "invoiceIdentityVerified": true,
41
+ "previewTotal": 0,
42
+ "currency": "usd",
43
+ "paymentVerified": true,
44
+ "creditPurchaseVerified": true,
45
+ "invoiceFinalizationVerified": false
46
+ }
47
+ ],
48
+ "cleanup": [
49
+ {
50
+ "kind": "credit",
51
+ "success": true
52
+ },
53
+ {
54
+ "kind": "test-payment-refund",
55
+ "success": true
56
+ },
57
+ {
58
+ "kind": "subscription",
59
+ "success": true
60
+ },
61
+ {
62
+ "kind": "price",
63
+ "success": true
64
+ },
65
+ {
66
+ "kind": "product",
67
+ "success": true
68
+ },
69
+ {
70
+ "kind": "meter",
71
+ "success": true
72
+ },
73
+ {
74
+ "kind": "subscription",
75
+ "success": true
76
+ },
77
+ {
78
+ "kind": "price",
79
+ "success": true
80
+ },
81
+ {
82
+ "kind": "product",
83
+ "success": true
84
+ },
85
+ {
86
+ "kind": "meter",
87
+ "success": true
88
+ },
89
+ {
90
+ "kind": "subscription",
91
+ "success": true
92
+ },
93
+ {
94
+ "kind": "price",
95
+ "success": true
96
+ },
97
+ {
98
+ "kind": "product",
99
+ "success": true
100
+ },
101
+ {
102
+ "kind": "meter",
103
+ "success": true
104
+ },
105
+ {
106
+ "kind": "test-clock",
107
+ "success": true
108
+ }
109
+ ],
110
+ "payerMappingVerified": true
111
+ }