@fantastic.dev/better-stripe 0.57.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +3 -1
  3. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +356 -50
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  5. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +162 -9
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  7. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +356 -50
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  9. package/dist/client/connect/payoutSyncTestHelpers.d.ts +162 -9
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  11. package/dist/client/usage/allowanceClient.d.ts +51 -0
  12. package/dist/client/usage/allowanceClient.d.ts.map +1 -0
  13. package/dist/client/usage/allowanceClient.js +64 -0
  14. package/dist/client/usage/allowanceClient.js.map +1 -0
  15. package/dist/client/usage/allowanceTerms.d.ts +64 -0
  16. package/dist/client/usage/allowanceTerms.d.ts.map +1 -0
  17. package/dist/client/usage/allowanceTerms.js +101 -0
  18. package/dist/client/usage/allowanceTerms.js.map +1 -0
  19. package/dist/client/usage/client.d.ts +2 -2
  20. package/dist/client/usage/client.d.ts.map +1 -1
  21. package/dist/client/usage/client.js +2 -2
  22. package/dist/client/usage/client.js.map +1 -1
  23. package/dist/client/usage/correctionClient.d.ts +33 -0
  24. package/dist/client/usage/correctionClient.d.ts.map +1 -0
  25. package/dist/client/usage/correctionClient.js +27 -0
  26. package/dist/client/usage/correctionClient.js.map +1 -0
  27. package/dist/client/usage/correctionEligibility.d.ts +4 -0
  28. package/dist/client/usage/correctionEligibility.d.ts.map +1 -0
  29. package/dist/client/usage/correctionEligibility.js +7 -0
  30. package/dist/client/usage/correctionEligibility.js.map +1 -0
  31. package/dist/client/usage/correctionInvoice.d.ts +9 -0
  32. package/dist/client/usage/correctionInvoice.d.ts.map +1 -0
  33. package/dist/client/usage/correctionInvoice.js +218 -0
  34. package/dist/client/usage/correctionInvoice.js.map +1 -0
  35. package/dist/client/usage/correctionInvoiceProof.d.ts +29 -0
  36. package/dist/client/usage/correctionInvoiceProof.d.ts.map +1 -0
  37. package/dist/client/usage/correctionInvoiceProof.js +41 -0
  38. package/dist/client/usage/correctionInvoiceProof.js.map +1 -0
  39. package/dist/client/usage/correctionProofs.d.ts +36 -0
  40. package/dist/client/usage/correctionProofs.d.ts.map +1 -0
  41. package/dist/client/usage/correctionProofs.js +41 -0
  42. package/dist/client/usage/correctionProofs.js.map +1 -0
  43. package/dist/client/usage/correctionProvider.d.ts +6 -0
  44. package/dist/client/usage/correctionProvider.d.ts.map +1 -0
  45. package/dist/client/usage/correctionProvider.js +243 -0
  46. package/dist/client/usage/correctionProvider.js.map +1 -0
  47. package/dist/client/usage/correctionRead.d.ts +27 -0
  48. package/dist/client/usage/correctionRead.d.ts.map +1 -0
  49. package/dist/client/usage/correctionRead.js +36 -0
  50. package/dist/client/usage/correctionRead.js.map +1 -0
  51. package/dist/client/usage/correctionTerms.d.ts +64 -0
  52. package/dist/client/usage/correctionTerms.d.ts.map +1 -0
  53. package/dist/client/usage/correctionTerms.js +65 -0
  54. package/dist/client/usage/correctionTerms.js.map +1 -0
  55. package/dist/client/usage/correctionTransport.fixtures.d.ts +37 -0
  56. package/dist/client/usage/correctionTransport.fixtures.d.ts.map +1 -0
  57. package/dist/client/usage/correctionTransport.fixtures.js +322 -0
  58. package/dist/client/usage/correctionTransport.fixtures.js.map +1 -0
  59. package/dist/client/usage/creditClient.d.ts +1 -1
  60. package/dist/client/usage/index.d.ts +4 -0
  61. package/dist/client/usage/index.d.ts.map +1 -1
  62. package/dist/client/usage/observationClient.d.ts +20 -0
  63. package/dist/client/usage/observationClient.d.ts.map +1 -1
  64. package/dist/client/usage/observationClient.js +20 -6
  65. package/dist/client/usage/observationClient.js.map +1 -1
  66. package/dist/client/usage/records.d.ts +1 -1
  67. package/dist/client/usage/records.d.ts.map +1 -1
  68. package/dist/client/usage/records.js.map +1 -1
  69. package/dist/client/usage/summary.d.ts +3 -0
  70. package/dist/client/usage/summary.d.ts.map +1 -1
  71. package/dist/client/usage/summary.js +9 -4
  72. package/dist/client/usage/summary.js.map +1 -1
  73. package/dist/client/usageExports.d.ts +4 -0
  74. package/dist/client/usageExports.d.ts.map +1 -1
  75. package/dist/component/_generated/api.d.ts +20 -0
  76. package/dist/component/_generated/api.d.ts.map +1 -1
  77. package/dist/component/_generated/api.js.map +1 -1
  78. package/dist/component/_generated/component.d.ts +324 -13
  79. package/dist/component/_generated/component.d.ts.map +1 -1
  80. package/dist/component/accountClosure/mutations.d.ts.map +1 -1
  81. package/dist/component/accountClosure/mutations.js +13 -0
  82. package/dist/component/accountClosure/mutations.js.map +1 -1
  83. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  84. package/dist/component/balanceFunding/mutations.d.ts +43 -43
  85. package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
  86. package/dist/component/earnings/triggers.d.ts +288 -10
  87. package/dist/component/earnings/triggers.d.ts.map +1 -1
  88. package/dist/component/schema.d.ts +162 -9
  89. package/dist/component/schema.js +7 -0
  90. package/dist/component/schema.js.map +1 -1
  91. package/dist/component/usage/mutations.d.ts.map +1 -1
  92. package/dist/component/usage/mutations.js +4 -0
  93. package/dist/component/usage/mutations.js.map +1 -1
  94. package/dist/component/usage/queries.d.ts +2 -2
  95. package/dist/component/usage/schema.d.ts +21 -15
  96. package/dist/component/usage/schema.d.ts.map +1 -1
  97. package/dist/component/usage/schema.js +4 -2
  98. package/dist/component/usage/schema.js.map +1 -1
  99. package/dist/component/usageAllowance/helpers.d.ts +78 -0
  100. package/dist/component/usageAllowance/helpers.d.ts.map +1 -0
  101. package/dist/component/usageAllowance/helpers.js +99 -0
  102. package/dist/component/usageAllowance/helpers.js.map +1 -0
  103. package/dist/component/usageAllowance/mutations.d.ts +37 -0
  104. package/dist/component/usageAllowance/mutations.d.ts.map +1 -0
  105. package/dist/component/usageAllowance/mutations.js +99 -0
  106. package/dist/component/usageAllowance/mutations.js.map +1 -0
  107. package/dist/component/usageAllowance/queries.d.ts +36 -0
  108. package/dist/component/usageAllowance/queries.d.ts.map +1 -0
  109. package/dist/component/usageAllowance/queries.js +122 -0
  110. package/dist/component/usageAllowance/queries.js.map +1 -0
  111. package/dist/component/usageAllowance/reservations.d.ts +25 -0
  112. package/dist/component/usageAllowance/reservations.d.ts.map +1 -0
  113. package/dist/component/usageAllowance/reservations.js +150 -0
  114. package/dist/component/usageAllowance/reservations.js.map +1 -0
  115. package/dist/component/usageAllowance/schema.d.ts +77 -0
  116. package/dist/component/usageAllowance/schema.d.ts.map +1 -0
  117. package/dist/component/usageAllowance/schema.js +32 -0
  118. package/dist/component/usageAllowance/schema.js.map +1 -0
  119. package/dist/component/usageCorrections/accounting.d.ts +5 -0
  120. package/dist/component/usageCorrections/accounting.d.ts.map +1 -0
  121. package/dist/component/usageCorrections/accounting.js +55 -0
  122. package/dist/component/usageCorrections/accounting.js.map +1 -0
  123. package/dist/component/usageCorrections/cancellation.d.ts +6 -0
  124. package/dist/component/usageCorrections/cancellation.d.ts.map +1 -0
  125. package/dist/component/usageCorrections/cancellation.js +29 -0
  126. package/dist/component/usageCorrections/cancellation.js.map +1 -0
  127. package/dist/component/usageCorrections/helpers.d.ts +60 -0
  128. package/dist/component/usageCorrections/helpers.d.ts.map +1 -0
  129. package/dist/component/usageCorrections/helpers.js +52 -0
  130. package/dist/component/usageCorrections/helpers.js.map +1 -0
  131. package/dist/component/usageCorrections/invoice.d.ts +38 -0
  132. package/dist/component/usageCorrections/invoice.d.ts.map +1 -0
  133. package/dist/component/usageCorrections/invoice.js +82 -0
  134. package/dist/component/usageCorrections/invoice.js.map +1 -0
  135. package/dist/component/usageCorrections/mutations.d.ts +121 -0
  136. package/dist/component/usageCorrections/mutations.d.ts.map +1 -0
  137. package/dist/component/usageCorrections/mutations.js +256 -0
  138. package/dist/component/usageCorrections/mutations.js.map +1 -0
  139. package/dist/component/usageCorrections/queries.d.ts +115 -0
  140. package/dist/component/usageCorrections/queries.d.ts.map +1 -0
  141. package/dist/component/usageCorrections/queries.js +84 -0
  142. package/dist/component/usageCorrections/queries.js.map +1 -0
  143. package/dist/component/usageCorrections/schema.d.ts +248 -0
  144. package/dist/component/usageCorrections/schema.d.ts.map +1 -0
  145. package/dist/component/usageCorrections/schema.js +74 -0
  146. package/dist/component/usageCorrections/schema.js.map +1 -0
  147. package/dist/component/usageCredits/queries.d.ts +1 -1
  148. package/dist/component/usageCredits/queries.d.ts.map +1 -1
  149. package/dist/component/usageCredits/queries.js +6 -0
  150. package/dist/component/usageCredits/queries.js.map +1 -1
  151. package/dist/component/usageCredits/schema.d.ts +5 -5
  152. package/dist/component/usageCredits/schema.d.ts.map +1 -1
  153. package/dist/component/usageCredits/schema.js +1 -1
  154. package/dist/component/usageCredits/schema.js.map +1 -1
  155. package/dist/component/usageDelivery/fields.d.ts +2 -2
  156. package/dist/component/usageDelivery/fields.d.ts.map +1 -1
  157. package/dist/component/usageDelivery/fields.js +1 -1
  158. package/dist/component/usageDelivery/fields.js.map +1 -1
  159. package/dist/component/usageDelivery/helpers.d.ts +7 -6
  160. package/dist/component/usageDelivery/helpers.d.ts.map +1 -1
  161. package/dist/component/usageDelivery/mutations.d.ts +6 -6
  162. package/dist/component/usageDelivery/mutations.d.ts.map +1 -1
  163. package/dist/component/usageDelivery/mutations.js +9 -1
  164. package/dist/component/usageDelivery/mutations.js.map +1 -1
  165. package/dist/component/usageDelivery/queries.d.ts +8 -6
  166. package/dist/component/usageDelivery/queries.d.ts.map +1 -1
  167. package/dist/component/usageDelivery/schema.d.ts +4 -4
  168. package/dist/component/usageDelivery/steps.d.ts +2 -2
  169. package/dist/component/usageDelivery/steps.js +1 -1
  170. package/dist/component/usageDelivery/steps.js.map +1 -1
  171. package/dist/component/usageObservations/queries.d.ts.map +1 -1
  172. package/dist/component/usageObservations/queries.js +4 -2
  173. package/dist/component/usageObservations/queries.js.map +1 -1
  174. package/dist/component/usageSubscriptions/retirement.d.ts.map +1 -1
  175. package/dist/component/usageSubscriptions/retirement.js +24 -2
  176. package/dist/component/usageSubscriptions/retirement.js.map +1 -1
  177. package/docs/README.md +4 -0
  178. package/docs/usage-corrections.md +249 -0
  179. package/docs/usage-limits.md +217 -0
  180. package/package.json +3 -1
  181. package/src/client/usage/allowanceClient.test.ts +93 -0
  182. package/src/client/usage/allowanceClient.ts +134 -0
  183. package/src/client/usage/allowanceTerms.test.ts +131 -0
  184. package/src/client/usage/allowanceTerms.ts +172 -0
  185. package/src/client/usage/client.ts +2 -2
  186. package/src/client/usage/correctionClient.test.ts +153 -0
  187. package/src/client/usage/correctionClient.ts +62 -0
  188. package/src/client/usage/correctionCredits.test.ts +156 -0
  189. package/src/client/usage/correctionEligibility.ts +14 -0
  190. package/src/client/usage/correctionInvoice.test.ts +127 -0
  191. package/src/client/usage/correctionInvoice.ts +269 -0
  192. package/src/client/usage/correctionInvoiceProof.ts +40 -0
  193. package/src/client/usage/correctionProofs.ts +40 -0
  194. package/src/client/usage/correctionProvider.ts +326 -0
  195. package/src/client/usage/correctionRead.ts +73 -0
  196. package/src/client/usage/correctionRecovery.test.ts +113 -0
  197. package/src/client/usage/correctionTerms.ts +98 -0
  198. package/src/client/usage/correctionTransport.fixtures.ts +372 -0
  199. package/src/client/usage/index.ts +19 -0
  200. package/src/client/usage/observationClient.ts +20 -6
  201. package/src/client/usage/records.ts +7 -1
  202. package/src/client/usage/summary.ts +12 -4
  203. package/src/client/usageExports.ts +19 -0
  204. package/src/component/_generated/api.ts +20 -0
  205. package/src/component/_generated/component.ts +423 -1
  206. package/src/component/accountClosure/mutations.ts +17 -0
  207. package/src/component/schema.ts +14 -0
  208. package/src/component/usage/allowance.test.ts +435 -0
  209. package/src/component/usage/mutations.ts +13 -0
  210. package/src/component/usage/schema.ts +6 -1
  211. package/src/component/usageAllowance/helpers.ts +137 -0
  212. package/src/component/usageAllowance/mutations.ts +139 -0
  213. package/src/component/usageAllowance/queries.ts +140 -0
  214. package/src/component/usageAllowance/reservations.ts +220 -0
  215. package/src/component/usageAllowance/schema.ts +37 -0
  216. package/src/component/usageCorrections/accounting.ts +79 -0
  217. package/src/component/usageCorrections/cancellation.ts +32 -0
  218. package/src/component/usageCorrections/corrections.test.ts +389 -0
  219. package/src/component/usageCorrections/helpers.ts +57 -0
  220. package/src/component/usageCorrections/invoice.ts +103 -0
  221. package/src/component/usageCorrections/mutations.ts +278 -0
  222. package/src/component/usageCorrections/queries.ts +94 -0
  223. package/src/component/usageCorrections/schema.ts +90 -0
  224. package/src/component/usageCredits/queries.ts +4 -0
  225. package/src/component/usageCredits/schema.ts +1 -0
  226. package/src/component/usageDelivery/fields.ts +1 -0
  227. package/src/component/usageDelivery/mutations.ts +8 -3
  228. package/src/component/usageDelivery/steps.ts +1 -1
  229. package/src/component/usageObservations/queries.ts +5 -2
  230. package/src/component/usageSubscriptions/retirement.ts +31 -2
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import { prepareUsageRecord } from "./records.js";
3
+ import { parseUsageQuantity } from "./contracts.js";
4
+ import { decimalFromScaled } from "./summary.js";
5
+ const seconds = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
6
+ const subscriptionSchema = z.strictObject({
7
+ subscriptionId: z.string().regex(/^sub_[a-zA-Z0-9]+$/),
8
+ subscriptionItemId: z.string().regex(/^si_[a-zA-Z0-9]+$/),
9
+ stripePriceId: z.string().regex(/^price_[a-zA-Z0-9]+$/),
10
+ period: z.strictObject({ start: seconds, end: seconds }),
11
+ interval: z.literal("month"),
12
+ });
13
+ export const usageLimitPolicySchema = z.strictObject({
14
+ reset: z.literal("billing_period"),
15
+ rollover: z.literal("none"),
16
+ entitled: z.boolean(),
17
+ overage: z.enum(["allow", "reject"]),
18
+ limit: z.discriminatedUnion("mode", [
19
+ z.strictObject({ mode: z.literal("none") }),
20
+ z.strictObject({ mode: z.enum(["soft", "hard"]), quantity: z.string() }),
21
+ ]),
22
+ });
23
+ export function allowanceBinding(input) {
24
+ const raw = z
25
+ .strictObject({
26
+ scope: z.unknown(),
27
+ binding: z.unknown(),
28
+ subscription: subscriptionSchema,
29
+ })
30
+ .parse(input);
31
+ const event = prepareUsageRecord({
32
+ scope: raw.scope,
33
+ binding: raw.binding,
34
+ sourceEventId: "validation",
35
+ quantity: "0",
36
+ occurredAt: 0,
37
+ });
38
+ if (event.binding.plan.model === "prepaid")
39
+ throw new Error("Use payment-backed prepaid credit accounting");
40
+ if (raw.subscription.period.end <= raw.subscription.period.start ||
41
+ raw.subscription.stripePriceId !== event.binding.stripePriceId)
42
+ throw new Error("Allowance subscription period/price mismatch");
43
+ return {
44
+ scope: event.scope,
45
+ binding: event.binding,
46
+ subscription: raw.subscription,
47
+ };
48
+ }
49
+ export function limitPolicy(input, binding) {
50
+ const policy = usageLimitPolicySchema.parse(input), precision = binding.binding.plan.unit.precision;
51
+ if (policy.limit.mode !== "none")
52
+ policy.limit.quantity = parseUsageQuantity(policy.limit.quantity, precision).quantity;
53
+ if (binding.binding.plan.model === "pay_as_you_go" &&
54
+ policy.overage === "reject")
55
+ throw new Error("Pay-as-you-go requires an explicit usage cap instead of an included allowance");
56
+ return policy;
57
+ }
58
+ export function allowanceStatus(binding, policy, row, observedAt) {
59
+ const plan = binding.binding.plan, precision = plan.unit.precision;
60
+ const consumed = BigInt(row.consumed), reserved = BigInt(row.reserved), total = consumed + reserved;
61
+ const included = plan.model === "included_overage"
62
+ ? BigInt(parseUsageQuantity(plan.includedQuantity, precision).scaledQuantity)
63
+ : 0n;
64
+ const overage = (quantity) => quantity > included ? quantity - included : 0n;
65
+ const quantity = (value) => decimalFromScaled(value, precision);
66
+ const cost = (value) => {
67
+ const [whole, fraction = ""] = plan.rate.unitAmountDecimal.split(".");
68
+ return {
69
+ amountDecimal: decimalFromScaled(overage(value) * BigInt(whole + fraction), precision + fraction.length),
70
+ currency: plan.rate.currency,
71
+ };
72
+ };
73
+ let hard = policy.limit.mode === "hard"
74
+ ? BigInt(parseUsageQuantity(policy.limit.quantity, precision).scaledQuantity)
75
+ : null;
76
+ if (policy.overage === "reject")
77
+ hard = hard === null || included < hard ? included : hard;
78
+ return {
79
+ revision: row.revision,
80
+ observedAt,
81
+ period: binding.subscription.period,
82
+ accepting: policy.entitled &&
83
+ observedAt >= binding.subscription.period.start &&
84
+ observedAt < binding.subscription.period.end - 60 &&
85
+ (hard === null || total < hard),
86
+ policy,
87
+ consumedQuantity: quantity(consumed),
88
+ reservedQuantity: quantity(reserved),
89
+ includedQuantity: quantity(included),
90
+ remainingIncludedQuantity: quantity(included > total ? included - total : 0n),
91
+ billableOverageQuantity: quantity(overage(consumed)),
92
+ softLimitReached: policy.limit.mode === "soft" &&
93
+ total >=
94
+ BigInt(parseUsageQuantity(policy.limit.quantity, precision).scaledQuantity),
95
+ hardLimitRemainingQuantity: hard === null ? null : quantity(hard > total ? hard - total : 0n),
96
+ committedEstimate: cost(consumed),
97
+ projectedEstimate: cost(total),
98
+ cashCollection: "none",
99
+ };
100
+ }
101
+ //# sourceMappingURL=allowanceTerms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"allowanceTerms.js","sourceRoot":"","sources":["../../../src/client/usage/allowanceTerms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAA4B,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAC5E,MAAM,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AAM,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,cAAc,CACpE;QACL,0BAA0B,EACxB,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;QACnE,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC;QACjC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC;QAC9B,cAAc,EAAE,MAAM;KACvB,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { UsageCreditClient } from "./creditClient.js";
1
+ import { UsageCorrectionClient } from "./correctionClient.js";
2
2
  import type { Component, RunCtx } from "../helpers.js";
3
3
  import { type PreparedUsageRecord, type UsageScope, type UsageDeliveryState } from "./records.js";
4
4
  import { type UsagePageRequest, type UsageSubscriptionBinding, type UsageReceipt } from "./boundaries.js";
@@ -18,7 +18,7 @@ export type UsageEventView = {
18
18
  delivery: UsageDeliveryState;
19
19
  };
20
20
  /** Trusted host facade. Authenticate and authorize each exact scope first. */
21
- export declare class UsageLedgerClient extends UsageCreditClient {
21
+ export declare class UsageLedgerClient extends UsageCorrectionClient {
22
22
  constructor(component: Component);
23
23
  record(ctx: RunCtx, opts: RecordUsageOptions): Promise<UsageReceipt>;
24
24
  get(ctx: RunCtx, opts: {
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client/usage/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,UAAU,EACf,KAAK,kBAAkB,EACxB,MAAM,cAAc,CAAC;AACtB,OAAO,EAEL,KAAK,gBAAgB,EACrB,KA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C;QAAC,IAAI,EAAE,gBAAgB,CAAA;KAAE;;;;OAe1E;CACF"}
@@ -1,4 +1,4 @@
1
- import { UsageCreditClient } from "./creditClient.js";
1
+ import { UsageCorrectionClient } from "./correctionClient.js";
2
2
  import { runMutationOrThrow } from "../helpers.js";
3
3
  import { componentRef } from "../webhooks/helpers.js";
4
4
  import { validateUsageRecordInput, } from "./records.js";
@@ -17,7 +17,7 @@ function decode({ event, delivery }) {
17
17
  };
18
18
  }
19
19
  /** Trusted host facade. Authenticate and authorize each exact scope first. */
20
- export class UsageLedgerClient extends UsageCreditClient {
20
+ export class UsageLedgerClient extends UsageCorrectionClient {
21
21
  constructor(component) {
22
22
  super(component);
23
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/client/usage/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,wBAAwB,GAIzB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,wBAAwB,GAIzB,MAAM,iBAAiB,CAAC;AAiBzB,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAc;IAC7C,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE,KAAK,CAAC,GAAG;YAClB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,QAAQ;SACnB;QACD,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAwB;QAC3D,YAAY,EAAE,IAAI,CAAC,KAAK,CACtB,KAAK,CAAC,gBAAgB,CACK;QAC7B,QAAQ;KACT,CAAC;AACJ,CAAC;AACD,8EAA8E;AAC9E,MAAM,OAAO,iBAAkB,SAAQ,iBA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AM,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAChC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAClD;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE;SAC9D,CACF,CAAoE,CAAC;QACtE,OAAO;YACL,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC;YAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc;YACpD,MAAM,EAAE,MAAM,CAAC,MAAM;SACtB,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ import type { UsageInvoiceCorrectionOptions } from "./correctionTerms.js";
2
+ import { type UsageScope } from "./records.js";
3
+ import type { UsagePeriod } from "./boundaries.js";
4
+ import { UsageAllowanceClient } from "./allowanceClient.js";
5
+ import type { RunCtx } from "../helpers.js";
6
+ import type { UsageCorrectionOptions } from "./correctionTerms.js";
7
+ import type { UsageDeliveryProviderOptions } from "./deliveryProvider.js";
8
+ /** Host authenticates and authorizes the actor and original activity before calling. */
9
+ export declare class UsageCorrectionClient extends UsageAllowanceClient {
10
+ getCorrection(ctx: RunCtx, input: {
11
+ scope: UsageScope;
12
+ eventId: string;
13
+ correctionId: string;
14
+ }): Promise<import("./correctionTerms.js").UsageCorrectionView | null>;
15
+ readCorrectionHistory(ctx: RunCtx, input: {
16
+ scope: UsageScope;
17
+ eventId: string;
18
+ limit: number;
19
+ cursor: string | null;
20
+ }): Promise<import("./correctionRead.js").UsageCorrectionHistoryPage>;
21
+ readCorrectionPeriodHistory(ctx: RunCtx, input: {
22
+ scope: UsageScope;
23
+ period: UsagePeriod;
24
+ limit: number;
25
+ cursor: string | null;
26
+ }): Promise<import("./correctionRead.js").UsageCorrectionHistoryPage>;
27
+ observeInvoiceCorrection(ctx: RunCtx, input: UsageInvoiceCorrectionOptions, options: UsageDeliveryProviderOptions): Promise<import("./correctionTerms.js").UsageCorrectionView | {
28
+ status: "held";
29
+ reason: string;
30
+ }>;
31
+ requestCorrection(ctx: RunCtx, input: UsageCorrectionOptions, options?: UsageDeliveryProviderOptions): Promise<import("./correctionTerms.js").UsageCorrectionView>;
32
+ }
33
+ //# sourceMappingURL=correctionClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionClient.d.ts","sourceRoot":"","sources":["../../../src/client/usage/correctionClient.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAE1E,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAI5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAC1E,wFAAwF;AACxF,qBAAa,qBAAsB,SAAQ,oBAAoB;IACvD,aAAa,CACjB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE;QAAE,KAAK,EAAE,UAAU,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,sEAOpE;IACD,qBAAqB,CACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE;QACL,KAAK,EAAE,UAAU,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,qEAGF;IACD,2BAA2B,CACzB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE;QACL,KAAK,EAAE,UAAU,CAAC;QAClB,MAAM,EAAE,WAAW,CAAC;QACpB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,qEAGF;IACD,wBAAwB,CACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,6BAA6B,EACpC,OAAO,EAAE,4BAA4B;;;OAGtC;IACD,iBAAiB,CACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,4BAAiC,+DAG3C;CACF"}
@@ -0,0 +1,27 @@
1
+ import { observeInvoiceCorrection } from "./correctionInvoice.js";
2
+ import { readCorrectionEvidence } from "./correctionRead.js";
3
+ import { scopeSchema } from "./records.js";
4
+ import { componentRef } from "../webhooks/helpers.js";
5
+ import { correctionView } from "./correctionTerms.js";
6
+ import { UsageAllowanceClient } from "./allowanceClient.js";
7
+ import { requestUsageCorrection } from "./correctionProvider.js";
8
+ /** Host authenticates and authorizes the actor and original activity before calling. */
9
+ export class UsageCorrectionClient extends UsageAllowanceClient {
10
+ async getCorrection(ctx, input) {
11
+ const row = (await ctx.runQuery(componentRef(this.component, "usageCorrections/queries/get"), { ...input, scope: scopeSchema.parse(input.scope) }));
12
+ return row ? correctionView(row) : null;
13
+ }
14
+ readCorrectionHistory(ctx, input) {
15
+ return readCorrectionEvidence(this.component, ctx, input);
16
+ }
17
+ readCorrectionPeriodHistory(ctx, input) {
18
+ return readCorrectionEvidence(this.component, ctx, input);
19
+ }
20
+ observeInvoiceCorrection(ctx, input, options) {
21
+ return observeInvoiceCorrection(this.component, ctx, input, options);
22
+ }
23
+ requestCorrection(ctx, input, options = {}) {
24
+ return requestUsageCorrection(this.component, ctx, input, options);
25
+ }
26
+ }
27
+ //# sourceMappingURL=correctionClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionClient.js","sourceRoot":"","s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,OAAO,CAAC,CAAC;IACvE,CAAC;IACD,iBAAiB,CACf,GAAW,EACX,KAA6B,EAC7B,OAAO,GAAiC,EAAE;QAE1C,OAAO,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { Doc } from "../../component/_generated/dataModel.js";
2
+ /** Local restoration requires proof that no native meter event was accepted. */
3
+ export declare function locallyCancelable(outbox: Pick<Doc<"usageOutbox">, "attempts" | "firstSendAt" | "receipt" | "state" | "reason">): boolean;
4
+ //# sourceMappingURL=correctionEligibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionEligibility.d.ts","sourceRoot":"","sources":["../../../src/client/usage/correctionEligibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,yCAAyC,CAAC;AACnE,gFAAgF;AAChF,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,IAAI,CACV,GAAG,CAAC,aAAa,CAAC,EAClB,UAAU,GAAG,aAAa,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAC5D,GACA,OAAO,CAMT"}
@@ -0,0 +1,7 @@
1
+ /** Local restoration requires proof that no native meter event was accepted. */
2
+ export function locallyCancelable(outbox) {
3
+ return (!outbox.receipt &&
4
+ ((outbox.attempts === 0 && outbox.firstSendAt === undefined) ||
5
+ (outbox.state === "rejected" && outbox.reason === "provider_rejected")));
6
+ }
7
+ //# sourceMappingURL=correctionEligibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionEligibility.js","sourceRoot":"","sources":["../../../src/client/usage/correctionEligibility.ts"],"names":[],"mappings":"AACA,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAC/B,MAGC;IAED,OAAO,CACL,CAAC,MAAM,CAAC,OAAO;QACf,CAAC,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,IAAI,MAAM,CAAC,WAAW,KAAK,SAAS,CAAC;YAC1D,CAAC,MAAM,CAAC,KAAK,KAAK,UAAU,IAAI,MAAM,CAAC,MAAM,KAAK,mBAAmB,CAAC,CAAC,CAC1E,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { Component, RunCtx } from "../helpers.js";
2
+ import type { UsageDeliveryProviderOptions } from "./deliveryProvider.js";
3
+ import { type UsageInvoiceCorrectionOptions } from "./correctionTerms.js";
4
+ /** Read-only provider adoption. The operator creates notes/refunds through existing authorized billing workflows. */
5
+ export declare function observeInvoiceCorrection(component: Component, ctx: RunCtx, input: UsageInvoiceCorrectionOptions, options: UsageDeliveryProviderOptions): Promise<import("./correctionTerms.js").UsageCorrectionView | {
6
+ status: "held";
7
+ reason: string;
8
+ }>;
9
+ //# sourceMappingURL=correctionInvoice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionInvoice.d.ts","sourceRoot":"","sources":["../../../src/client/usage/correctionInvoice.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAKvD,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAI1E,OAAO,EAGL,KAAK,6BAA6B,EACnC,MAAM,sBAAsB,CAAC;AAU9B,qHAAqH;AACrH,wBAAsB,wBAAwB,CAC5C,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,6BAA6B,EACpC,OAAO,EAAE,4BAA4B;YAyBzB,MAAM;;GAsNnB"}
@@ -0,0 +1,218 @@
1
+ import Stripe from "stripe";
2
+ import { runMutationOrThrow } from "../helpers.js";
3
+ import { componentRef } from "../webhooks/helpers.js";
4
+ import { verifyRealm } from "./catalogTypes.js";
5
+ import { subscriptionSnapshot } from "../../component/usage/helpers.js";
6
+ import { invoiceCorrectionOptions, correctionView, } from "./correctionTerms.js";
7
+ import { invoiceCorrectionProof } from "./correctionInvoiceProof.js";
8
+ import { referenceId, paymentReference, } from "../billing/invoicePaymentShared.js";
9
+ const requireProof = (valid) => {
10
+ if (!valid)
11
+ throw new Error("Native invoice correction requires reconciliation");
12
+ };
13
+ /** Read-only provider adoption. The operator creates notes/refunds through existing authorized billing workflows. */
14
+ export async function observeInvoiceCorrection(component, ctx, input, options) {
15
+ const opts = invoiceCorrectionOptions.parse(input);
16
+ const row = (await ctx.runQuery(componentRef(component, "usageCorrections/queries/get"), {
17
+ scope: opts.scope,
18
+ eventId: opts.eventId,
19
+ correctionId: opts.correctionId,
20
+ }));
21
+ if (!row)
22
+ throw new Error("Usage correction unavailable");
23
+ if (row.adjustmentJson) {
24
+ const pinned = invoiceCorrectionProof.parse(JSON.parse(row.adjustmentJson));
25
+ if (pinned.creditNoteId !== opts.creditNoteId ||
26
+ pinned.invoiceId !== opts.invoiceId ||
27
+ pinned.amount !== opts.amount)
28
+ throw new Error("Invoice adjustment replay conflict");
29
+ }
30
+ const record = JSON.parse(row.recordJson), sub = subscriptionSnapshot(row.subscriptionJson);
31
+ if (!options.stripeSecretKey || record.binding.plan.model === "prepaid")
32
+ return {
33
+ status: "held",
34
+ reason: record.binding.plan.model === "prepaid"
35
+ ? "prepaid_credit_reconciliation_required"
36
+ : "provider_unavailable",
37
+ };
38
+ const stripe = new Stripe(options.stripeSecretKey, {
39
+ apiVersion: record.binding.apiVersion,
40
+ maxNetworkRetries: 0,
41
+ timeout: 15000,
42
+ ...(options.httpClient ? { httpClient: options.httpClient } : {}),
43
+ });
44
+ let proof;
45
+ try {
46
+ await verifyRealm(stripe, {
47
+ stripeAccountId: record.scope.stripeAccountId,
48
+ livemode: record.scope.livemode,
49
+ });
50
+ const [note, invoice, customer] = await Promise.all([
51
+ stripe.creditNotes.retrieve(opts.creditNoteId),
52
+ stripe.invoices.retrieve(opts.invoiceId),
53
+ stripe.customers.retrieve(record.scope.customerAccount),
54
+ ]);
55
+ requireProof(!customer.deleted &&
56
+ customer.id === record.binding.stripeCustomerId &&
57
+ customer.customer_account === record.scope.customerAccount &&
58
+ customer.livemode === record.scope.livemode);
59
+ requireProof(note.id === opts.creditNoteId &&
60
+ note.object === "credit_note" &&
61
+ note.livemode === record.scope.livemode &&
62
+ note.customer_account === record.scope.customerAccount &&
63
+ referenceId(note.customer) === record.binding.stripeCustomerId &&
64
+ referenceId(note.invoice) === opts.invoiceId &&
65
+ (note.status === "issued" ||
66
+ (note.status === "void" &&
67
+ row.adjustmentJson &&
68
+ note.pre_payment_amount === note.amount &&
69
+ note.post_payment_amount === 0)) &&
70
+ note.currency === record.binding.plan.rate.currency &&
71
+ note.amount === opts.amount &&
72
+ note.total === note.amount &&
73
+ note.subtotal === note.amount &&
74
+ note.discount_amount === 0 &&
75
+ note.amount_shipping === 0 &&
76
+ Array.isArray(note.total_taxes) &&
77
+ note.total_taxes.length === 0 &&
78
+ note.customer_balance_transaction === null &&
79
+ (note.out_of_band_amount === null || note.out_of_band_amount === 0) &&
80
+ Array.isArray(note.pretax_credit_amounts) &&
81
+ note.pretax_credit_amounts.length === 0 &&
82
+ note.lines.has_more === false &&
83
+ note.lines.data.length === 1 &&
84
+ note.amount === note.pre_payment_amount + note.post_payment_amount);
85
+ requireProof(invoice.id === opts.invoiceId &&
86
+ invoice.livemode === record.scope.livemode &&
87
+ invoice.customer_account === record.scope.customerAccount &&
88
+ referenceId(invoice.customer) === record.binding.stripeCustomerId &&
89
+ invoice.currency === record.binding.plan.rate.currency &&
90
+ ["open", "paid"].includes(invoice.status ?? "") &&
91
+ referenceId(invoice.parent?.subscription_details?.subscription) ===
92
+ sub.subscriptionId &&
93
+ invoice.lines.has_more === false);
94
+ const noteLine = note.lines.data[0], line = invoice.lines.data.find((line) => line.id === noteLine.invoice_line_item);
95
+ requireProof(noteLine.type === "invoice_line_item" &&
96
+ noteLine.livemode === record.scope.livemode &&
97
+ noteLine.amount === opts.amount &&
98
+ noteLine.discount_amount === 0 &&
99
+ (noteLine.taxes === null ||
100
+ (Array.isArray(noteLine.taxes) && noteLine.taxes.length === 0)) &&
101
+ Array.isArray(noteLine.pretax_credit_amounts) &&
102
+ noteLine.pretax_credit_amounts.length === 0 &&
103
+ line &&
104
+ line.currency === record.binding.plan.rate.currency &&
105
+ line.amount >= opts.amount &&
106
+ line.pricing?.price_details?.price === record.binding.stripePriceId &&
107
+ line.parent?.subscription_item_details?.subscription_item ===
108
+ sub.subscriptionItemId &&
109
+ !line.parent?.subscription_item_details?.proration &&
110
+ line.period.start === sub.period.start &&
111
+ line.period.end === sub.period.end &&
112
+ Array.isArray(line.pretax_credit_amounts) &&
113
+ line.pretax_credit_amounts.length === 0);
114
+ let paymentIntentId = null, chargeId = null, refundId = null;
115
+ if (note.post_payment_amount > 0) {
116
+ requireProof(note.refunds.length === 1 &&
117
+ note.refunds[0].type === "refund" &&
118
+ note.refunds[0].amount_refunded === note.post_payment_amount);
119
+ refundId = referenceId(note.refunds[0].refund) ?? null;
120
+ requireProof(refundId);
121
+ const refund = await stripe.refunds.retrieve(refundId);
122
+ paymentIntentId = referenceId(refund.payment_intent) ?? null;
123
+ chargeId = referenceId(refund.charge) ?? null;
124
+ requireProof(refund.id === refundId &&
125
+ refund.status === "succeeded" &&
126
+ refund.amount === note.post_payment_amount &&
127
+ refund.currency === note.currency &&
128
+ paymentIntentId &&
129
+ chargeId);
130
+ const [payment, charge, payments] = await Promise.all([
131
+ stripe.paymentIntents.retrieve(paymentIntentId),
132
+ stripe.charges.retrieve(chargeId),
133
+ stripe.invoicePayments.list({
134
+ invoice: invoice.id,
135
+ status: "paid",
136
+ limit: 100,
137
+ }),
138
+ ]);
139
+ const references = payments.data.map(paymentReference);
140
+ requireProof(payments.has_more === false &&
141
+ references.some(({ invoicePayment: p }) => referenceId(p.invoice) === invoice.id &&
142
+ p.status === "paid" &&
143
+ p.currency === note.currency &&
144
+ p.amount_paid !== null &&
145
+ p.amount_paid >= refund.amount &&
146
+ p.payment.type === "payment_intent" &&
147
+ referenceId(p.payment.payment_intent) === paymentIntentId));
148
+ requireProof([
149
+ refund.amount,
150
+ payment.amount,
151
+ payment.amount_received,
152
+ charge.amount,
153
+ charge.amount_captured,
154
+ charge.amount_refunded,
155
+ ].every((value) => Number.isSafeInteger(value) && value >= 0));
156
+ requireProof(refund.object === "refund" &&
157
+ payment.object === "payment_intent" &&
158
+ charge.object === "charge" &&
159
+ charge.amount_captured === payment.amount_received &&
160
+ charge.amount_captured <= charge.amount &&
161
+ charge.amount_captured <= payment.amount &&
162
+ (!payment.customer ||
163
+ referenceId(payment.customer) ===
164
+ record.binding.stripeCustomerId) &&
165
+ referenceId(charge.customer) === referenceId(payment.customer));
166
+ requireProof(payment.id === paymentIntentId &&
167
+ payment.livemode === record.scope.livemode &&
168
+ payment.customer_account === record.scope.customerAccount &&
169
+ payment.status === "succeeded" &&
170
+ payment.currency === note.currency &&
171
+ referenceId(payment.latest_charge) === chargeId &&
172
+ payment.amount_received >= refund.amount &&
173
+ charge.id === chargeId &&
174
+ charge.payment_intent === paymentIntentId &&
175
+ charge.livemode === record.scope.livemode &&
176
+ charge.currency === note.currency &&
177
+ charge.paid &&
178
+ charge.captured &&
179
+ charge.status === "succeeded" &&
180
+ !charge.disputed &&
181
+ charge.amount_captured >= refund.amount &&
182
+ charge.amount_refunded >= refund.amount &&
183
+ charge.amount_refunded <= charge.amount_captured);
184
+ }
185
+ else
186
+ requireProof(note.refunds.length === 0);
187
+ proof = invoiceCorrectionProof.parse({
188
+ creditNoteStatus: note.status,
189
+ stripeAccountId: record.scope.stripeAccountId,
190
+ customerAccount: record.scope.customerAccount,
191
+ livemode: record.scope.livemode,
192
+ stripeCustomerId: record.binding.stripeCustomerId,
193
+ subscriptionId: sub.subscriptionId,
194
+ subscriptionItemId: sub.subscriptionItemId,
195
+ stripePriceId: record.binding.stripePriceId,
196
+ period: sub.period,
197
+ creditNoteId: note.id,
198
+ invoiceId: invoice.id,
199
+ invoiceLineId: line.id,
200
+ currency: note.currency,
201
+ amount: note.amount,
202
+ prePaymentAmount: note.pre_payment_amount,
203
+ postPaymentAmount: note.post_payment_amount,
204
+ paymentIntentId,
205
+ chargeId,
206
+ refundId,
207
+ });
208
+ }
209
+ catch {
210
+ return {
211
+ status: "held",
212
+ reason: "native_invoice_adjustment_unverified",
213
+ };
214
+ }
215
+ const saved = (await runMutationOrThrow(ctx, componentRef(component, "usageCorrections/mutations/adopt"), { key: row.key, proofJson: JSON.stringify(proof) }));
216
+ return correctionView(saved);
217
+ }
218
+ //# sourceMappingURL=correctionInvoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionInvoice.js","sourceRoot":"","sources":["../../../src/client/usage/correctionInvoice.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAKtD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EACL,wBAAwB,EACxB,cAAc,GAEf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EACL,WAAW,EACX,gBAAgB,GACjB,MAAM,oCAAoC,CAAC;AAC5C,MAAM,YAAY,GAAG,CAAC,KAAc,EAAE,EAAE;IACtC,IAAI,CAAC,KAAK;QACR,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AACzE,CAAC,CAAC;AACF,qHAAqH;AACrH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,SAAoB,EACpB,GAAW,EACX,KAAoC,EACpC,OAAqC;IAErC,MAAM,IAAI,GAAG,wBAAwB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAC7B,YAAY,CAAC,SAAS,E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eAAe;YACf,QAAQ;YACR,QAAQ;SACT,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,MAAM,EAAE,MAAe;YACvB,MAAM,EAAE,sCAAsC;SAC/C,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,CAAC,MAAM,kBAAkB,CACrC,GAAG,EACH,YAAY,CAAC,SAAS,EAAE,kCAAkC,CAAC,EAC3D,EAAE,GAAG,EAAE,GAAG,CAAC,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACnD,CAA4B,CAAC;IAC9B,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { z } from "zod";
2
+ export declare const invoiceCorrectionProof: z.ZodObject<{
3
+ creditNoteStatus: z.ZodEnum<{
4
+ issued: "issued";
5
+ void: "void";
6
+ }>;
7
+ stripeAccountId: z.ZodString;
8
+ livemode: z.ZodBoolean;
9
+ customerAccount: z.ZodString;
10
+ stripeCustomerId: z.ZodString;
11
+ subscriptionId: z.ZodString;
12
+ subscriptionItemId: z.ZodString;
13
+ stripePriceId: z.ZodString;
14
+ period: z.ZodObject<{
15
+ start: z.ZodNumber;
16
+ end: z.ZodNumber;
17
+ }, z.core.$strict>;
18
+ creditNoteId: z.ZodString;
19
+ invoiceId: z.ZodString;
20
+ invoiceLineId: z.ZodString;
21
+ currency: z.ZodString;
22
+ amount: z.ZodNumber;
23
+ prePaymentAmount: z.ZodNumber;
24
+ postPaymentAmount: z.ZodNumber;
25
+ paymentIntentId: z.ZodNullable<z.ZodString>;
26
+ chargeId: z.ZodNullable<z.ZodString>;
27
+ refundId: z.ZodNullable<z.ZodString>;
28
+ }, z.core.$strict>;
29
+ //# sourceMappingURL=correctionInvoiceProof.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionInvoiceProof.d.ts","sourceRoot":"","sources":["../../../src/client/usage/correctionInvoiceProof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;kBAsCjC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ export const invoiceCorrectionProof = z.strictObject({
3
+ creditNoteStatus: z.enum(["issued", "void"]),
4
+ stripeAccountId: z.string(),
5
+ livemode: z.boolean(),
6
+ customerAccount: z.string(),
7
+ stripeCustomerId: z.string(),
8
+ subscriptionId: z.string(),
9
+ subscriptionItemId: z.string(),
10
+ stripePriceId: z.string(),
11
+ period: z.strictObject({ start: z.number().int(), end: z.number().int() }),
12
+ creditNoteId: z
13
+ .string()
14
+ .regex(/^cn_[a-zA-Z0-9]+$/)
15
+ .max(100),
16
+ invoiceId: z
17
+ .string()
18
+ .regex(/^in_[a-zA-Z0-9]+$/)
19
+ .max(100),
20
+ invoiceLineId: z.string().max(100),
21
+ currency: z.string().regex(/^[a-z]{3}$/),
22
+ amount: z.number().int().positive().max(99999999),
23
+ prePaymentAmount: z.number().int().nonnegative(),
24
+ postPaymentAmount: z.number().int().nonnegative(),
25
+ paymentIntentId: z
26
+ .string()
27
+ .regex(/^pi_[a-zA-Z0-9]+$/)
28
+ .max(100)
29
+ .nullable(),
30
+ chargeId: z
31
+ .string()
32
+ .regex(/^ch_[a-zA-Z0-9]+$/)
33
+ .max(100)
34
+ .nullable(),
35
+ refundId: z
36
+ .string()
37
+ .regex(/^re_[a-zA-Z0-9]+$/)
38
+ .max(100)
39
+ .nullable(),
40
+ });
41
+ //# sourceMappingURL=correctionInvoiceProof.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"correctionInvoiceProof.js","sourceRoot":"","sources":["../../../src/client/usage/correctionInvoiceProof.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,CAAC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AAM,EAAE;SACR,KAAK,CAAC,mBAAmB,CAAC;SAC1B,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,KAAK,CAAC,mBAAmB,CAAC;SAC1B,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;IACb,QAAQ,EAAE,CAAC;SACR,MAAM,EAAE;SACR,KAAK,CAAC,mBAAmB,CAAC;SAC1B,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;CACd,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ export declare const correctionOutcome: z.ZodUnion<readonly [z.ZodObject<{
3
+ status: z.ZodEnum<{
4
+ complete: "complete";
5
+ pending: "pending";
6
+ }>;
7
+ eventName: z.ZodString;
8
+ identifier: z.ZodString;
9
+ livemode: z.ZodBoolean;
10
+ nativeAdjustmentId: z.ZodNullable<z.ZodString>;
11
+ creditBackingVerified: z.ZodBoolean;
12
+ billingSafe: z.ZodDefault<z.ZodBoolean>;
13
+ invoiceId: z.ZodOptional<z.ZodString>;
14
+ }, z.core.$strict>, z.ZodObject<{
15
+ status: z.ZodLiteral<"local_complete">;
16
+ creditBackingVerified: z.ZodLiteral<true>;
17
+ }, z.core.$strict>, z.ZodObject<{
18
+ status: z.ZodEnum<{
19
+ held: "held";
20
+ invoice_adjustment_required: "invoice_adjustment_required";
21
+ unsupported: "unsupported";
22
+ }>;
23
+ reason: z.ZodEnum<{
24
+ billing_period_closed: "billing_period_closed";
25
+ credit_backing_requires_reconciliation: "credit_backing_requires_reconciliation";
26
+ native_cancellation_expired: "native_cancellation_expired";
27
+ native_cancellation_rejected: "native_cancellation_rejected";
28
+ native_invoice_finalized: "native_invoice_finalized";
29
+ native_invoice_history_incomplete: "native_invoice_history_incomplete";
30
+ original_delivery_unresolved: "original_delivery_unresolved";
31
+ provider_outcome_unknown: "provider_outcome_unknown";
32
+ provider_unavailable: "provider_unavailable";
33
+ }>;
34
+ invoiceId: z.ZodOptional<z.ZodString>;
35
+ }, z.core.$strict>]>;
36
+ //# sourceMappingURL=correctionProofs.d.ts.map