@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.
- package/CHANGELOG.md +12 -0
- package/README.md +3 -1
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +356 -50
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +162 -9
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +356 -50
- package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +162 -9
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/usage/allowanceClient.d.ts +51 -0
- package/dist/client/usage/allowanceClient.d.ts.map +1 -0
- package/dist/client/usage/allowanceClient.js +64 -0
- package/dist/client/usage/allowanceClient.js.map +1 -0
- package/dist/client/usage/allowanceTerms.d.ts +64 -0
- package/dist/client/usage/allowanceTerms.d.ts.map +1 -0
- package/dist/client/usage/allowanceTerms.js +101 -0
- package/dist/client/usage/allowanceTerms.js.map +1 -0
- package/dist/client/usage/client.d.ts +2 -2
- package/dist/client/usage/client.d.ts.map +1 -1
- package/dist/client/usage/client.js +2 -2
- package/dist/client/usage/client.js.map +1 -1
- package/dist/client/usage/correctionClient.d.ts +33 -0
- package/dist/client/usage/correctionClient.d.ts.map +1 -0
- package/dist/client/usage/correctionClient.js +27 -0
- package/dist/client/usage/correctionClient.js.map +1 -0
- package/dist/client/usage/correctionEligibility.d.ts +4 -0
- package/dist/client/usage/correctionEligibility.d.ts.map +1 -0
- package/dist/client/usage/correctionEligibility.js +7 -0
- package/dist/client/usage/correctionEligibility.js.map +1 -0
- package/dist/client/usage/correctionInvoice.d.ts +9 -0
- package/dist/client/usage/correctionInvoice.d.ts.map +1 -0
- package/dist/client/usage/correctionInvoice.js +218 -0
- package/dist/client/usage/correctionInvoice.js.map +1 -0
- package/dist/client/usage/correctionInvoiceProof.d.ts +29 -0
- package/dist/client/usage/correctionInvoiceProof.d.ts.map +1 -0
- package/dist/client/usage/correctionInvoiceProof.js +41 -0
- package/dist/client/usage/correctionInvoiceProof.js.map +1 -0
- package/dist/client/usage/correctionProofs.d.ts +36 -0
- package/dist/client/usage/correctionProofs.d.ts.map +1 -0
- package/dist/client/usage/correctionProofs.js +41 -0
- package/dist/client/usage/correctionProofs.js.map +1 -0
- package/dist/client/usage/correctionProvider.d.ts +6 -0
- package/dist/client/usage/correctionProvider.d.ts.map +1 -0
- package/dist/client/usage/correctionProvider.js +243 -0
- package/dist/client/usage/correctionProvider.js.map +1 -0
- package/dist/client/usage/correctionRead.d.ts +27 -0
- package/dist/client/usage/correctionRead.d.ts.map +1 -0
- package/dist/client/usage/correctionRead.js +36 -0
- package/dist/client/usage/correctionRead.js.map +1 -0
- package/dist/client/usage/correctionTerms.d.ts +64 -0
- package/dist/client/usage/correctionTerms.d.ts.map +1 -0
- package/dist/client/usage/correctionTerms.js +65 -0
- package/dist/client/usage/correctionTerms.js.map +1 -0
- package/dist/client/usage/correctionTransport.fixtures.d.ts +37 -0
- package/dist/client/usage/correctionTransport.fixtures.d.ts.map +1 -0
- package/dist/client/usage/correctionTransport.fixtures.js +322 -0
- package/dist/client/usage/correctionTransport.fixtures.js.map +1 -0
- package/dist/client/usage/creditClient.d.ts +1 -1
- package/dist/client/usage/index.d.ts +4 -0
- package/dist/client/usage/index.d.ts.map +1 -1
- package/dist/client/usage/observationClient.d.ts +20 -0
- package/dist/client/usage/observationClient.d.ts.map +1 -1
- package/dist/client/usage/observationClient.js +20 -6
- package/dist/client/usage/observationClient.js.map +1 -1
- package/dist/client/usage/records.d.ts +1 -1
- package/dist/client/usage/records.d.ts.map +1 -1
- package/dist/client/usage/records.js.map +1 -1
- package/dist/client/usage/summary.d.ts +3 -0
- package/dist/client/usage/summary.d.ts.map +1 -1
- package/dist/client/usage/summary.js +9 -4
- package/dist/client/usage/summary.js.map +1 -1
- package/dist/client/usageExports.d.ts +4 -0
- package/dist/client/usageExports.d.ts.map +1 -1
- package/dist/component/_generated/api.d.ts +20 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +324 -13
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/accountClosure/mutations.d.ts.map +1 -1
- package/dist/component/accountClosure/mutations.js +13 -0
- package/dist/component/accountClosure/mutations.js.map +1 -1
- package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
- package/dist/component/balanceFunding/mutations.d.ts +43 -43
- package/dist/component/balanceFunding/workflowValidators.d.ts +16 -16
- package/dist/component/earnings/triggers.d.ts +288 -10
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/schema.d.ts +162 -9
- package/dist/component/schema.js +7 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/usage/mutations.d.ts.map +1 -1
- package/dist/component/usage/mutations.js +4 -0
- package/dist/component/usage/mutations.js.map +1 -1
- package/dist/component/usage/queries.d.ts +2 -2
- package/dist/component/usage/schema.d.ts +21 -15
- package/dist/component/usage/schema.d.ts.map +1 -1
- package/dist/component/usage/schema.js +4 -2
- package/dist/component/usage/schema.js.map +1 -1
- package/dist/component/usageAllowance/helpers.d.ts +78 -0
- package/dist/component/usageAllowance/helpers.d.ts.map +1 -0
- package/dist/component/usageAllowance/helpers.js +99 -0
- package/dist/component/usageAllowance/helpers.js.map +1 -0
- package/dist/component/usageAllowance/mutations.d.ts +37 -0
- package/dist/component/usageAllowance/mutations.d.ts.map +1 -0
- package/dist/component/usageAllowance/mutations.js +99 -0
- package/dist/component/usageAllowance/mutations.js.map +1 -0
- package/dist/component/usageAllowance/queries.d.ts +36 -0
- package/dist/component/usageAllowance/queries.d.ts.map +1 -0
- package/dist/component/usageAllowance/queries.js +122 -0
- package/dist/component/usageAllowance/queries.js.map +1 -0
- package/dist/component/usageAllowance/reservations.d.ts +25 -0
- package/dist/component/usageAllowance/reservations.d.ts.map +1 -0
- package/dist/component/usageAllowance/reservations.js +150 -0
- package/dist/component/usageAllowance/reservations.js.map +1 -0
- package/dist/component/usageAllowance/schema.d.ts +77 -0
- package/dist/component/usageAllowance/schema.d.ts.map +1 -0
- package/dist/component/usageAllowance/schema.js +32 -0
- package/dist/component/usageAllowance/schema.js.map +1 -0
- package/dist/component/usageCorrections/accounting.d.ts +5 -0
- package/dist/component/usageCorrections/accounting.d.ts.map +1 -0
- package/dist/component/usageCorrections/accounting.js +55 -0
- package/dist/component/usageCorrections/accounting.js.map +1 -0
- package/dist/component/usageCorrections/cancellation.d.ts +6 -0
- package/dist/component/usageCorrections/cancellation.d.ts.map +1 -0
- package/dist/component/usageCorrections/cancellation.js +29 -0
- package/dist/component/usageCorrections/cancellation.js.map +1 -0
- package/dist/component/usageCorrections/helpers.d.ts +60 -0
- package/dist/component/usageCorrections/helpers.d.ts.map +1 -0
- package/dist/component/usageCorrections/helpers.js +52 -0
- package/dist/component/usageCorrections/helpers.js.map +1 -0
- package/dist/component/usageCorrections/invoice.d.ts +38 -0
- package/dist/component/usageCorrections/invoice.d.ts.map +1 -0
- package/dist/component/usageCorrections/invoice.js +82 -0
- package/dist/component/usageCorrections/invoice.js.map +1 -0
- package/dist/component/usageCorrections/mutations.d.ts +121 -0
- package/dist/component/usageCorrections/mutations.d.ts.map +1 -0
- package/dist/component/usageCorrections/mutations.js +256 -0
- package/dist/component/usageCorrections/mutations.js.map +1 -0
- package/dist/component/usageCorrections/queries.d.ts +115 -0
- package/dist/component/usageCorrections/queries.d.ts.map +1 -0
- package/dist/component/usageCorrections/queries.js +84 -0
- package/dist/component/usageCorrections/queries.js.map +1 -0
- package/dist/component/usageCorrections/schema.d.ts +248 -0
- package/dist/component/usageCorrections/schema.d.ts.map +1 -0
- package/dist/component/usageCorrections/schema.js +74 -0
- package/dist/component/usageCorrections/schema.js.map +1 -0
- package/dist/component/usageCredits/queries.d.ts +1 -1
- package/dist/component/usageCredits/queries.d.ts.map +1 -1
- package/dist/component/usageCredits/queries.js +6 -0
- package/dist/component/usageCredits/queries.js.map +1 -1
- package/dist/component/usageCredits/schema.d.ts +5 -5
- package/dist/component/usageCredits/schema.d.ts.map +1 -1
- package/dist/component/usageCredits/schema.js +1 -1
- package/dist/component/usageCredits/schema.js.map +1 -1
- package/dist/component/usageDelivery/fields.d.ts +2 -2
- package/dist/component/usageDelivery/fields.d.ts.map +1 -1
- package/dist/component/usageDelivery/fields.js +1 -1
- package/dist/component/usageDelivery/fields.js.map +1 -1
- package/dist/component/usageDelivery/helpers.d.ts +7 -6
- package/dist/component/usageDelivery/helpers.d.ts.map +1 -1
- package/dist/component/usageDelivery/mutations.d.ts +6 -6
- package/dist/component/usageDelivery/mutations.d.ts.map +1 -1
- package/dist/component/usageDelivery/mutations.js +9 -1
- package/dist/component/usageDelivery/mutations.js.map +1 -1
- package/dist/component/usageDelivery/queries.d.ts +8 -6
- package/dist/component/usageDelivery/queries.d.ts.map +1 -1
- package/dist/component/usageDelivery/schema.d.ts +4 -4
- package/dist/component/usageDelivery/steps.d.ts +2 -2
- package/dist/component/usageDelivery/steps.js +1 -1
- package/dist/component/usageDelivery/steps.js.map +1 -1
- package/dist/component/usageObservations/queries.d.ts.map +1 -1
- package/dist/component/usageObservations/queries.js +4 -2
- package/dist/component/usageObservations/queries.js.map +1 -1
- package/dist/component/usageSubscriptions/retirement.d.ts.map +1 -1
- package/dist/component/usageSubscriptions/retirement.js +24 -2
- package/dist/component/usageSubscriptions/retirement.js.map +1 -1
- package/docs/README.md +4 -0
- package/docs/usage-corrections.md +249 -0
- package/docs/usage-limits.md +217 -0
- package/package.json +3 -1
- package/src/client/usage/allowanceClient.test.ts +93 -0
- package/src/client/usage/allowanceClient.ts +134 -0
- package/src/client/usage/allowanceTerms.test.ts +131 -0
- package/src/client/usage/allowanceTerms.ts +172 -0
- package/src/client/usage/client.ts +2 -2
- package/src/client/usage/correctionClient.test.ts +153 -0
- package/src/client/usage/correctionClient.ts +62 -0
- package/src/client/usage/correctionCredits.test.ts +156 -0
- package/src/client/usage/correctionEligibility.ts +14 -0
- package/src/client/usage/correctionInvoice.test.ts +127 -0
- package/src/client/usage/correctionInvoice.ts +269 -0
- package/src/client/usage/correctionInvoiceProof.ts +40 -0
- package/src/client/usage/correctionProofs.ts +40 -0
- package/src/client/usage/correctionProvider.ts +326 -0
- package/src/client/usage/correctionRead.ts +73 -0
- package/src/client/usage/correctionRecovery.test.ts +113 -0
- package/src/client/usage/correctionTerms.ts +98 -0
- package/src/client/usage/correctionTransport.fixtures.ts +372 -0
- package/src/client/usage/index.ts +19 -0
- package/src/client/usage/observationClient.ts +20 -6
- package/src/client/usage/records.ts +7 -1
- package/src/client/usage/summary.ts +12 -4
- package/src/client/usageExports.ts +19 -0
- package/src/component/_generated/api.ts +20 -0
- package/src/component/_generated/component.ts +423 -1
- package/src/component/accountClosure/mutations.ts +17 -0
- package/src/component/schema.ts +14 -0
- package/src/component/usage/allowance.test.ts +435 -0
- package/src/component/usage/mutations.ts +13 -0
- package/src/component/usage/schema.ts +6 -1
- package/src/component/usageAllowance/helpers.ts +137 -0
- package/src/component/usageAllowance/mutations.ts +139 -0
- package/src/component/usageAllowance/queries.ts +140 -0
- package/src/component/usageAllowance/reservations.ts +220 -0
- package/src/component/usageAllowance/schema.ts +37 -0
- package/src/component/usageCorrections/accounting.ts +79 -0
- package/src/component/usageCorrections/cancellation.ts +32 -0
- package/src/component/usageCorrections/corrections.test.ts +389 -0
- package/src/component/usageCorrections/helpers.ts +57 -0
- package/src/component/usageCorrections/invoice.ts +103 -0
- package/src/component/usageCorrections/mutations.ts +278 -0
- package/src/component/usageCorrections/queries.ts +94 -0
- package/src/component/usageCorrections/schema.ts +90 -0
- package/src/component/usageCredits/queries.ts +4 -0
- package/src/component/usageCredits/schema.ts +1 -0
- package/src/component/usageDelivery/fields.ts +1 -0
- package/src/component/usageDelivery/mutations.ts +8 -3
- package/src/component/usageDelivery/steps.ts +1 -1
- package/src/component/usageObservations/queries.ts +5 -2
- package/src/component/usageSubscriptions/retirement.ts +31 -2
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { json, canonical, operation, history, view } from "./helpers.js";
|
|
2
|
+
import { invoiceCorrectionProof } from "../../client/usage/correctionInvoiceProof.js";
|
|
3
|
+
import { subscriptionSnapshot } from "../usage/helpers.js";
|
|
4
|
+
export async function adoptInvoiceCorrection(ctx, args) {
|
|
5
|
+
const row = await operation(ctx, args.key), proof = invoiceCorrectionProof.parse(json(args.proofJson)), proofJson = canonical({ ...proof, creditNoteStatus: "issued" });
|
|
6
|
+
if ((row.leaseUntil ?? 0) > Date.now() / 1000)
|
|
7
|
+
throw new Error("Active native correction attempt must finish before financial adoption");
|
|
8
|
+
const event = JSON.parse(row.recordJson), sub = subscriptionSnapshot(row.subscriptionJson);
|
|
9
|
+
if (proof.stripeAccountId !== event.scope.stripeAccountId ||
|
|
10
|
+
proof.livemode !== event.scope.livemode ||
|
|
11
|
+
proof.customerAccount !== event.scope.customerAccount ||
|
|
12
|
+
proof.stripeCustomerId !== event.binding.stripeCustomerId ||
|
|
13
|
+
proof.subscriptionId !== sub.subscriptionId ||
|
|
14
|
+
proof.subscriptionItemId !== sub.subscriptionItemId ||
|
|
15
|
+
proof.stripePriceId !== event.binding.stripePriceId ||
|
|
16
|
+
proof.period.start !== sub.period.start ||
|
|
17
|
+
proof.period.end !== sub.period.end ||
|
|
18
|
+
proof.currency !== event.binding.plan.rate.currency ||
|
|
19
|
+
proof.amount !== proof.prePaymentAmount + proof.postPaymentAmount ||
|
|
20
|
+
(proof.postPaymentAmount > 0 &&
|
|
21
|
+
(!proof.refundId || !proof.paymentIntentId || !proof.chargeId)))
|
|
22
|
+
throw new Error("Invoice correction provenance mismatch");
|
|
23
|
+
if (row.adjustmentJson) {
|
|
24
|
+
if (row.adjustmentJson !== proofJson)
|
|
25
|
+
throw new Error("Invoice adjustment replay conflict");
|
|
26
|
+
if (row.nativeCreditNoteStatus === "void" ||
|
|
27
|
+
row.nativeCreditNoteStatus === proof.creditNoteStatus)
|
|
28
|
+
return row;
|
|
29
|
+
}
|
|
30
|
+
if ((row.state === "confirmed" && !row.adjustmentJson) ||
|
|
31
|
+
event.binding.plan.model === "prepaid")
|
|
32
|
+
throw new Error("Invoice credit cannot restore native usage or prepaid units");
|
|
33
|
+
for (const source of [
|
|
34
|
+
proof.creditNoteId,
|
|
35
|
+
...(proof.refundId ? [proof.refundId] : []),
|
|
36
|
+
]) {
|
|
37
|
+
const key = canonical([
|
|
38
|
+
event.scope.stripeAccountId,
|
|
39
|
+
event.scope.livemode,
|
|
40
|
+
source,
|
|
41
|
+
]);
|
|
42
|
+
const prior = await ctx.db
|
|
43
|
+
.query("usageCorrectionClaims")
|
|
44
|
+
.withIndex("by_key", (q) => q.eq("key", key))
|
|
45
|
+
.unique();
|
|
46
|
+
if (prior &&
|
|
47
|
+
(prior.operationKey !== row.key || prior.proofJson !== proofJson))
|
|
48
|
+
throw new Error("Native financial adjustment already claimed");
|
|
49
|
+
if (!prior)
|
|
50
|
+
await ctx.db.insert("usageCorrectionClaims", {
|
|
51
|
+
key,
|
|
52
|
+
operationKey: row.key,
|
|
53
|
+
proofJson,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
57
|
+
state: "confirmed",
|
|
58
|
+
resolution: "invoice_credit",
|
|
59
|
+
reason: proof.creditNoteStatus === "void"
|
|
60
|
+
? "native_invoice_credit_voided"
|
|
61
|
+
: "verified_native_invoice_credit",
|
|
62
|
+
nativeCreditNoteStatus: proof.creditNoteStatus,
|
|
63
|
+
creditNoteId: proof.creditNoteId,
|
|
64
|
+
invoiceId: proof.invoiceId,
|
|
65
|
+
refundId: proof.refundId ?? undefined,
|
|
66
|
+
adjustmentJson: proofJson,
|
|
67
|
+
cashConsequence: proof.creditNoteStatus === "void"
|
|
68
|
+
? "none"
|
|
69
|
+
: "verified_external_adjustment",
|
|
70
|
+
restoredQuantity: "0",
|
|
71
|
+
leaseUntil: 0,
|
|
72
|
+
});
|
|
73
|
+
const saved = await operation(ctx, row.key);
|
|
74
|
+
await history(ctx, saved, {
|
|
75
|
+
proof,
|
|
76
|
+
result: view(saved),
|
|
77
|
+
usageTreatment: "retain_original_consumption",
|
|
78
|
+
cashCollection: "none",
|
|
79
|
+
});
|
|
80
|
+
return operation(ctx, row.key);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=invoice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoice.js","sourceRoot":"","sources":["../../../src/component/usageCorrections/invoice.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAgB,EAChB,IAAwC;IAExC,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EACxC,KAAK,GAAG,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EAC1D,SAAS,GAAG,SAAS,CAAC,EAAE,GAAG,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,CAAC,CAAC;IAClE,IAAI,CAAC,GAAG,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI;QAC3C,MAAM,IAAI,KAAK,CACb,wEAAwE,CACzE,CAAC;IACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAwB,EAC7D,GAAG,G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BAAgB;QAC5B,MAAM,EACJ,KAAK,CAAC,gBAAgB,KAAK,MAAM;YAC/B,CAAC,CAAC,8BAA8B;YAChC,CAAC,CAAC,gCAAgC;QACtC,sBAAsB,EAAE,KAAK,CAAC,gBAAgB;QAC9C,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,SAAS;QACrC,cAAc,EAAE,SAAS;QACzB,eAAe,EACb,KAAK,CAAC,gBAAgB,KAAK,MAAM;YAC/B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,8BAA8B;QACpC,gBAAgB,EAAE,GAAG;QACrB,UAAU,EAAE,CAAC;KACd,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;QACxB,KAAK;QACL,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;QACnB,cAAc,EAAE,6BAA6B;QAC7C,cAAc,EAAE,MAAM;KACvB,CAAC,CAAC;IACH,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;AACjC,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export declare const prepare: import("convex/server").RegisteredMutation<"public", {
|
|
2
|
+
inputJson: string;
|
|
3
|
+
}, Promise<{
|
|
4
|
+
_creationTime: number;
|
|
5
|
+
_id: import("convex/values").GenericId<"usageCorrections">;
|
|
6
|
+
adjustmentJson?: string | undefined;
|
|
7
|
+
attempt: number;
|
|
8
|
+
attemptedAt?: number | undefined;
|
|
9
|
+
cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
|
|
10
|
+
correctionId: string;
|
|
11
|
+
creditNoteId?: string | undefined;
|
|
12
|
+
customerAccount?: string | undefined;
|
|
13
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
14
|
+
firstAttemptAt: number;
|
|
15
|
+
historyCount: number;
|
|
16
|
+
inputJson: string;
|
|
17
|
+
invoiceId?: string | undefined;
|
|
18
|
+
key: string;
|
|
19
|
+
leaseUntil?: number | undefined;
|
|
20
|
+
nativeAdjustmentId?: string | undefined;
|
|
21
|
+
nativeCreditNoteStatus?: "issued" | "void" | undefined;
|
|
22
|
+
nativeStatus?: "complete" | "pending" | undefined;
|
|
23
|
+
observedAt?: number | undefined;
|
|
24
|
+
quantity: string;
|
|
25
|
+
reason: string;
|
|
26
|
+
recordJson: string;
|
|
27
|
+
refundId?: string | undefined;
|
|
28
|
+
resolution?: "event_cancellation" | "invoice_credit" | undefined;
|
|
29
|
+
restoredQuantity: string;
|
|
30
|
+
scaledQuantity: string;
|
|
31
|
+
scopeKey: string;
|
|
32
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
33
|
+
stripeAccountId?: string | undefined;
|
|
34
|
+
subscriptionJson: string;
|
|
35
|
+
}>>;
|
|
36
|
+
export declare const claim: import("convex/server").RegisteredMutation<"public", {
|
|
37
|
+
key: string;
|
|
38
|
+
}, Promise<{
|
|
39
|
+
kind: "done";
|
|
40
|
+
attempt: number;
|
|
41
|
+
} | {
|
|
42
|
+
kind: "busy";
|
|
43
|
+
attempt: number;
|
|
44
|
+
} | {
|
|
45
|
+
kind: "ready";
|
|
46
|
+
attempt: number;
|
|
47
|
+
}>>;
|
|
48
|
+
export declare const save: import("convex/server").RegisteredMutation<"public", {
|
|
49
|
+
attempt: number;
|
|
50
|
+
key: string;
|
|
51
|
+
outcomeJson: string;
|
|
52
|
+
}, Promise<{
|
|
53
|
+
_creationTime: number;
|
|
54
|
+
_id: import("convex/values").GenericId<"usageCorrections">;
|
|
55
|
+
adjustmentJson?: string | undefined;
|
|
56
|
+
attempt: number;
|
|
57
|
+
attemptedAt?: number | undefined;
|
|
58
|
+
cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
|
|
59
|
+
correctionId: string;
|
|
60
|
+
creditNoteId?: string | undefined;
|
|
61
|
+
customerAccount?: string | undefined;
|
|
62
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
63
|
+
firstAttemptAt: number;
|
|
64
|
+
historyCount: number;
|
|
65
|
+
inputJson: string;
|
|
66
|
+
invoiceId?: string | undefined;
|
|
67
|
+
key: string;
|
|
68
|
+
leaseUntil?: number | undefined;
|
|
69
|
+
nativeAdjustmentId?: string | undefined;
|
|
70
|
+
nativeCreditNoteStatus?: "issued" | "void" | undefined;
|
|
71
|
+
nativeStatus?: "complete" | "pending" | undefined;
|
|
72
|
+
observedAt?: number | undefined;
|
|
73
|
+
quantity: string;
|
|
74
|
+
reason: string;
|
|
75
|
+
recordJson: string;
|
|
76
|
+
refundId?: string | undefined;
|
|
77
|
+
resolution?: "event_cancellation" | "invoice_credit" | undefined;
|
|
78
|
+
restoredQuantity: string;
|
|
79
|
+
scaledQuantity: string;
|
|
80
|
+
scopeKey: string;
|
|
81
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
82
|
+
stripeAccountId?: string | undefined;
|
|
83
|
+
subscriptionJson: string;
|
|
84
|
+
}>>;
|
|
85
|
+
export declare const adopt: import("convex/server").RegisteredMutation<"public", {
|
|
86
|
+
key: string;
|
|
87
|
+
proofJson: string;
|
|
88
|
+
}, Promise<{
|
|
89
|
+
_creationTime: number;
|
|
90
|
+
_id: import("convex/values").GenericId<"usageCorrections">;
|
|
91
|
+
adjustmentJson?: string | undefined;
|
|
92
|
+
attempt: number;
|
|
93
|
+
attemptedAt?: number | undefined;
|
|
94
|
+
cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
|
|
95
|
+
correctionId: string;
|
|
96
|
+
creditNoteId?: string | undefined;
|
|
97
|
+
customerAccount?: string | undefined;
|
|
98
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
99
|
+
firstAttemptAt: number;
|
|
100
|
+
historyCount: number;
|
|
101
|
+
inputJson: string;
|
|
102
|
+
invoiceId?: string | undefined;
|
|
103
|
+
key: string;
|
|
104
|
+
leaseUntil?: number | undefined;
|
|
105
|
+
nativeAdjustmentId?: string | undefined;
|
|
106
|
+
nativeCreditNoteStatus?: "issued" | "void" | undefined;
|
|
107
|
+
nativeStatus?: "complete" | "pending" | undefined;
|
|
108
|
+
observedAt?: number | undefined;
|
|
109
|
+
quantity: string;
|
|
110
|
+
reason: string;
|
|
111
|
+
recordJson: string;
|
|
112
|
+
refundId?: string | undefined;
|
|
113
|
+
resolution?: "event_cancellation" | "invoice_credit" | undefined;
|
|
114
|
+
restoredQuantity: string;
|
|
115
|
+
scaledQuantity: string;
|
|
116
|
+
scopeKey: string;
|
|
117
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
118
|
+
stripeAccountId?: string | undefined;
|
|
119
|
+
subscriptionJson: string;
|
|
120
|
+
}>>;
|
|
121
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/mutations.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyGlB,CAAC;AAEH,eAAO,MAAM,KAAK;;;UAiBG,MAAM;;;UAEN,MAAM;;;UAmCR,OAAO;;GAExB,CAAC;AACH,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgGf,CAAC;AAEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAIhB,CAAC"}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { locallyCancelable } from "../../client/usage/correctionEligibility.js";
|
|
2
|
+
import { adoptInvoiceCorrection } from "./invoice.js";
|
|
3
|
+
import { closureByStripeId } from "../accountClosure/helpers.js";
|
|
4
|
+
import { correctionOutcome } from "../../client/usage/correctionProofs.js";
|
|
5
|
+
import { v } from "convex/values";
|
|
6
|
+
import { mutation } from "../_generated/server.js";
|
|
7
|
+
import { read } from "../usageDelivery/helpers.js";
|
|
8
|
+
import { parseUsageQuantity } from "../../client/usage/contracts.js";
|
|
9
|
+
import { input, operation, history, view, json } from "./helpers.js";
|
|
10
|
+
import { restore } from "./accounting.js";
|
|
11
|
+
import { operationDoc } from "./schema.js";
|
|
12
|
+
export const prepare = mutation({
|
|
13
|
+
args: { inputJson: v.string() },
|
|
14
|
+
returns: operationDoc,
|
|
15
|
+
handler: async (ctx, args) => {
|
|
16
|
+
const original = await input(args.inputJson), { event, outbox, record } = await read(ctx, {
|
|
17
|
+
scope: original.request.scope,
|
|
18
|
+
eventId: original.request
|
|
19
|
+
.eventId,
|
|
20
|
+
});
|
|
21
|
+
const prior = await ctx.db
|
|
22
|
+
.query("usageCorrections")
|
|
23
|
+
.withIndex("by_key", (q) => q.eq("key", original.key))
|
|
24
|
+
.unique();
|
|
25
|
+
if (prior) {
|
|
26
|
+
if (prior.inputJson !== original.inputJson)
|
|
27
|
+
throw new Error("Usage correction replay conflict");
|
|
28
|
+
return prior;
|
|
29
|
+
}
|
|
30
|
+
for (const account of [
|
|
31
|
+
record.scope.stripeAccountId,
|
|
32
|
+
record.scope.customerAccount,
|
|
33
|
+
])
|
|
34
|
+
if (await closureByStripeId(ctx, account))
|
|
35
|
+
throw new Error("Account closure prevents new usage correction");
|
|
36
|
+
const quantity = parseUsageQuantity(original.request.quantity ?? record.quantity, record.binding.plan.unit.precision);
|
|
37
|
+
if (BigInt(quantity.scaledQuantity) > BigInt(record.scaledQuantity) ||
|
|
38
|
+
quantity.scaledQuantity === "0")
|
|
39
|
+
throw new Error("Invalid usage correction quantity");
|
|
40
|
+
const rows = await ctx.db
|
|
41
|
+
.query("usageCorrections")
|
|
42
|
+
.withIndex("by_event", (q) => q.eq("eventId", event._id))
|
|
43
|
+
.take(101);
|
|
44
|
+
if (rows.length >= 100)
|
|
45
|
+
throw new Error("Retained event correction quota exhausted");
|
|
46
|
+
const partial = quantity.scaledQuantity !== record.scaledQuantity;
|
|
47
|
+
if (!partial &&
|
|
48
|
+
rows.some((row) => row.scaledQuantity === record.scaledQuantity &&
|
|
49
|
+
row.state !== "unsupported"))
|
|
50
|
+
throw new Error("Original usage already has a correction operation");
|
|
51
|
+
const unsent = locallyCancelable(outbox);
|
|
52
|
+
const prepaid = record.binding.plan.model === "prepaid";
|
|
53
|
+
const state = partial
|
|
54
|
+
? "unsupported"
|
|
55
|
+
: unsent && !prepaid
|
|
56
|
+
? "confirmed"
|
|
57
|
+
: "requested";
|
|
58
|
+
const reason = partial
|
|
59
|
+
? "partial_event_requires_replacement_or_invoice_adjustment"
|
|
60
|
+
: state === "confirmed"
|
|
61
|
+
? outbox.state === "rejected"
|
|
62
|
+
? "canceled_after_delivery_rejection"
|
|
63
|
+
: "canceled_before_delivery"
|
|
64
|
+
: unsent
|
|
65
|
+
? "credit_backing_verification_required"
|
|
66
|
+
: "native_cancellation_required";
|
|
67
|
+
const id = await ctx.db.insert("usageCorrections", {
|
|
68
|
+
stripeAccountId: record.scope.stripeAccountId,
|
|
69
|
+
customerAccount: record.scope.customerAccount,
|
|
70
|
+
key: original.key,
|
|
71
|
+
scopeKey: original.scopeKey,
|
|
72
|
+
eventId: event._id,
|
|
73
|
+
correctionId: original.request.correctionId,
|
|
74
|
+
inputJson: original.inputJson,
|
|
75
|
+
recordJson: event.recordJson,
|
|
76
|
+
subscriptionJson: event.subscriptionJson,
|
|
77
|
+
quantity: quantity.quantity,
|
|
78
|
+
scaledQuantity: quantity.scaledQuantity,
|
|
79
|
+
state,
|
|
80
|
+
reason,
|
|
81
|
+
firstAttemptAt: Math.floor(Date.now() / 1000),
|
|
82
|
+
attempt: 0,
|
|
83
|
+
restoredQuantity: state === "confirmed" ? quantity.quantity : "0",
|
|
84
|
+
historyCount: 0,
|
|
85
|
+
cashConsequence: "none",
|
|
86
|
+
});
|
|
87
|
+
const row = (await ctx.db.get("usageCorrections", id));
|
|
88
|
+
if (!partial) {
|
|
89
|
+
await ctx.db.patch("usageOutbox", outbox._id, {
|
|
90
|
+
held: true,
|
|
91
|
+
correctionKey: row.key,
|
|
92
|
+
...(state === "confirmed"
|
|
93
|
+
? { state: "canceled", reason: "usage_canceled" }
|
|
94
|
+
: {}),
|
|
95
|
+
});
|
|
96
|
+
if (state === "confirmed")
|
|
97
|
+
await restore(ctx, row, event);
|
|
98
|
+
}
|
|
99
|
+
await history(ctx, row, {
|
|
100
|
+
request: original.request,
|
|
101
|
+
providerIdentifier: outbox.providerIdentifier,
|
|
102
|
+
originalReceipt: outbox.receipt ?? null,
|
|
103
|
+
result: view(row),
|
|
104
|
+
});
|
|
105
|
+
return operation(ctx, row.key);
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
export const claim = mutation({
|
|
109
|
+
args: { key: v.string() },
|
|
110
|
+
returns: v.object({
|
|
111
|
+
kind: v.union(v.literal("ready"), v.literal("busy"), v.literal("done")),
|
|
112
|
+
attempt: v.number(),
|
|
113
|
+
}),
|
|
114
|
+
handler: async (ctx, args) => {
|
|
115
|
+
const row = await operation(ctx, args.key), now = Math.floor(Date.now() / 1000);
|
|
116
|
+
if ([
|
|
117
|
+
"confirmed",
|
|
118
|
+
"unsupported",
|
|
119
|
+
"provider_accepted",
|
|
120
|
+
"invoice_adjustment_required",
|
|
121
|
+
].includes(row.state))
|
|
122
|
+
return { kind: "done", attempt: row.attempt };
|
|
123
|
+
if ((row.leaseUntil ?? 0) > now)
|
|
124
|
+
return { kind: "busy", attempt: row.attempt };
|
|
125
|
+
const source = await read(ctx, {
|
|
126
|
+
scope: JSON.parse(row.inputJson).scope,
|
|
127
|
+
eventId: row.eventId,
|
|
128
|
+
});
|
|
129
|
+
const neverDelivered = locallyCancelable(source.outbox);
|
|
130
|
+
if (!neverDelivered &&
|
|
131
|
+
row.attemptedAt !== undefined &&
|
|
132
|
+
now - row.attemptedAt >= 23 * 3600) {
|
|
133
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
134
|
+
state: "held",
|
|
135
|
+
reason: "native_retry_window_expired",
|
|
136
|
+
leaseUntil: 0,
|
|
137
|
+
});
|
|
138
|
+
await history(ctx, row, { safeRetryWindowExpired: true });
|
|
139
|
+
return { kind: "done", attempt: row.attempt };
|
|
140
|
+
}
|
|
141
|
+
const originalScope = JSON.parse(row.recordJson).scope;
|
|
142
|
+
for (const account of [
|
|
143
|
+
originalScope.stripeAccountId,
|
|
144
|
+
originalScope.customerAccount,
|
|
145
|
+
])
|
|
146
|
+
if (await closureByStripeId(ctx, account))
|
|
147
|
+
throw new Error("Account closure prevents correction provider operation");
|
|
148
|
+
const attempt = row.attempt + 1;
|
|
149
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
150
|
+
attempt,
|
|
151
|
+
attemptedAt: row.attemptedAt ?? now,
|
|
152
|
+
leaseUntil: now + 900,
|
|
153
|
+
});
|
|
154
|
+
await history(ctx, row, { phase: "attempt", attempt });
|
|
155
|
+
return { kind: "ready", attempt };
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
export const save = mutation({
|
|
159
|
+
args: { key: v.string(), attempt: v.number(), outcomeJson: v.string() },
|
|
160
|
+
returns: operationDoc,
|
|
161
|
+
handler: async (ctx, args) => {
|
|
162
|
+
const row = await operation(ctx, args.key);
|
|
163
|
+
if (row.state === "confirmed")
|
|
164
|
+
return row;
|
|
165
|
+
if (row.attempt !== args.attempt || row.attemptedAt === undefined)
|
|
166
|
+
throw new Error("Stale correction receipt");
|
|
167
|
+
const result = correctionOutcome.parse(json(args.outcomeJson));
|
|
168
|
+
const request = JSON.parse(row.inputJson), { event, outbox, record } = await read(ctx, {
|
|
169
|
+
scope: request.scope,
|
|
170
|
+
eventId: row.eventId,
|
|
171
|
+
});
|
|
172
|
+
if (outbox.correctionKey !== row.key)
|
|
173
|
+
throw new Error("Correction outbox identity mismatch");
|
|
174
|
+
if (result.status === "pending" || result.status === "complete") {
|
|
175
|
+
if (!outbox.receipt ||
|
|
176
|
+
outbox.receipt.identifier !== result.identifier ||
|
|
177
|
+
result.identifier !== outbox.providerIdentifier ||
|
|
178
|
+
result.eventName !== record.binding.eventName ||
|
|
179
|
+
result.livemode !== record.scope.livemode)
|
|
180
|
+
throw new Error("Native correction receipt scope mismatch");
|
|
181
|
+
const confirm = result.status === "complete" &&
|
|
182
|
+
result.billingSafe &&
|
|
183
|
+
(record.binding.plan.model !== "prepaid" ||
|
|
184
|
+
result.creditBackingVerified);
|
|
185
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
186
|
+
state: confirm
|
|
187
|
+
? "confirmed"
|
|
188
|
+
: result.status === "pending"
|
|
189
|
+
? "provider_accepted"
|
|
190
|
+
: !result.billingSafe
|
|
191
|
+
? "invoice_adjustment_required"
|
|
192
|
+
: "held",
|
|
193
|
+
reason: confirm
|
|
194
|
+
? "native_cancellation_complete"
|
|
195
|
+
: result.status === "pending"
|
|
196
|
+
? "native_cancellation_pending"
|
|
197
|
+
: !result.billingSafe
|
|
198
|
+
? "native_invoice_finalized_or_unresolved"
|
|
199
|
+
: "credit_backing_requires_reconciliation",
|
|
200
|
+
invoiceId: result.invoiceId,
|
|
201
|
+
cashConsequence: result.status === "complete" && !result.billingSafe
|
|
202
|
+
? "operator_resolution_required"
|
|
203
|
+
: "none",
|
|
204
|
+
nativeStatus: result.status,
|
|
205
|
+
nativeAdjustmentId: result.nativeAdjustmentId ?? undefined,
|
|
206
|
+
leaseUntil: 0,
|
|
207
|
+
restoredQuantity: confirm ? row.quantity : "0",
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
else if (result.status === "local_complete") {
|
|
211
|
+
if (!locallyCancelable(outbox) || record.binding.plan.model !== "prepaid")
|
|
212
|
+
throw new Error("Unsent credit correction provenance mismatch");
|
|
213
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
214
|
+
state: "confirmed",
|
|
215
|
+
reason: outbox.state === "rejected"
|
|
216
|
+
? "canceled_after_delivery_rejection"
|
|
217
|
+
: "canceled_before_delivery",
|
|
218
|
+
leaseUntil: 0,
|
|
219
|
+
restoredQuantity: row.quantity,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
else if ("reason" in result) {
|
|
223
|
+
await ctx.db.patch("usageCorrections", row._id, {
|
|
224
|
+
state: result.status,
|
|
225
|
+
reason: result.reason,
|
|
226
|
+
invoiceId: result.invoiceId,
|
|
227
|
+
leaseUntil: 0,
|
|
228
|
+
cashConsequence: result.status === "invoice_adjustment_required"
|
|
229
|
+
? "operator_resolution_required"
|
|
230
|
+
: "none",
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
const saved = await operation(ctx, row.key);
|
|
234
|
+
if (saved.state === "confirmed") {
|
|
235
|
+
await restore(ctx, row, event);
|
|
236
|
+
await ctx.db.patch("usageOutbox", outbox._id, {
|
|
237
|
+
state: "canceled",
|
|
238
|
+
held: true,
|
|
239
|
+
reason: "usage_canceled",
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
await history(ctx, saved, {
|
|
243
|
+
attempt: args.attempt,
|
|
244
|
+
providerIdentifier: outbox.providerIdentifier,
|
|
245
|
+
outcome: result,
|
|
246
|
+
result: view(saved),
|
|
247
|
+
});
|
|
248
|
+
return operation(ctx, row.key);
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
export const adopt = mutation({
|
|
252
|
+
args: { key: v.string(), proofJson: v.string() },
|
|
253
|
+
returns: operationDoc,
|
|
254
|
+
handler: adoptInvoiceCorrection,
|
|
255
|
+
});
|
|
256
|
+
//# sourceMappingURL=mutations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.js","sourceRoot":"","sources":["../../../src/component/usageCorrections/mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;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AAE,KAAK,CAAC,CAAC;YAC/B,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,CAAC,GAAG,EAAE;gBAC5C,KAAK,EAAE,UAAU;gBACjB,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,gBAAgB;aACzB,CAAC,CAAC;QACL,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE;YACxB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,kBAAkB,EAAE,MAAM,CAAC,kBAAkB;YAC7C,OAAO,EAAE,MAAM;YACf,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;SACpB,CAAC,CAAC;QACH,OAAO,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,QAAQ,CAAC;IAC5B,IAAI,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE;IAChD,OAAO,EAAE,YAAY;IACrB,OAAO,EAAE,sBAAsB;CAChC,CAAC,CAAC"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export declare const readHistory: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
3
|
+
paginationOpts: {
|
|
4
|
+
id?: number;
|
|
5
|
+
endCursor?: string | null;
|
|
6
|
+
maximumRowsRead?: number;
|
|
7
|
+
maximumBytesRead?: number;
|
|
8
|
+
numItems: number;
|
|
9
|
+
cursor: string | null;
|
|
10
|
+
};
|
|
11
|
+
scope: {
|
|
12
|
+
customerAccount: string;
|
|
13
|
+
livemode: boolean;
|
|
14
|
+
meterId: string;
|
|
15
|
+
stripeAccountId: string;
|
|
16
|
+
};
|
|
17
|
+
}, Promise<import("convex/server").PaginationResult<{
|
|
18
|
+
_creationTime: number;
|
|
19
|
+
_id: import("convex/values").GenericId<"usageCorrectionHistory">;
|
|
20
|
+
at: number;
|
|
21
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
22
|
+
evidenceJson: string;
|
|
23
|
+
key: string;
|
|
24
|
+
occurredAt?: number | undefined;
|
|
25
|
+
reason: string;
|
|
26
|
+
recordJson: string;
|
|
27
|
+
scopeKey: string;
|
|
28
|
+
sequence: number;
|
|
29
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
30
|
+
subscriptionJson: string;
|
|
31
|
+
}>>>;
|
|
32
|
+
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
33
|
+
correctionId: string;
|
|
34
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
35
|
+
scope: {
|
|
36
|
+
customerAccount: string;
|
|
37
|
+
livemode: boolean;
|
|
38
|
+
meterId: string;
|
|
39
|
+
stripeAccountId: string;
|
|
40
|
+
};
|
|
41
|
+
}, Promise<{
|
|
42
|
+
_creationTime: number;
|
|
43
|
+
_id: import("convex/values").GenericId<"usageCorrections">;
|
|
44
|
+
adjustmentJson?: string | undefined;
|
|
45
|
+
attempt: number;
|
|
46
|
+
attemptedAt?: number | undefined;
|
|
47
|
+
cashConsequence: "none" | "operator_resolution_required" | "verified_external_adjustment";
|
|
48
|
+
correctionId: string;
|
|
49
|
+
creditNoteId?: string | undefined;
|
|
50
|
+
customerAccount?: string | undefined;
|
|
51
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
52
|
+
firstAttemptAt: number;
|
|
53
|
+
historyCount: number;
|
|
54
|
+
inputJson: string;
|
|
55
|
+
invoiceId?: string | undefined;
|
|
56
|
+
key: string;
|
|
57
|
+
leaseUntil?: number | undefined;
|
|
58
|
+
nativeAdjustmentId?: string | undefined;
|
|
59
|
+
nativeCreditNoteStatus?: "issued" | "void" | undefined;
|
|
60
|
+
nativeStatus?: "complete" | "pending" | undefined;
|
|
61
|
+
observedAt?: number | undefined;
|
|
62
|
+
quantity: string;
|
|
63
|
+
reason: string;
|
|
64
|
+
recordJson: string;
|
|
65
|
+
refundId?: string | undefined;
|
|
66
|
+
resolution?: "event_cancellation" | "invoice_credit" | undefined;
|
|
67
|
+
restoredQuantity: string;
|
|
68
|
+
scaledQuantity: string;
|
|
69
|
+
scopeKey: string;
|
|
70
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
71
|
+
stripeAccountId?: string | undefined;
|
|
72
|
+
subscriptionJson: string;
|
|
73
|
+
} | null>>;
|
|
74
|
+
export declare const periodHistory: import("convex/server").RegisteredQuery<"public", {
|
|
75
|
+
paginationOpts: {
|
|
76
|
+
id?: number;
|
|
77
|
+
endCursor?: string | null;
|
|
78
|
+
maximumRowsRead?: number;
|
|
79
|
+
maximumBytesRead?: number;
|
|
80
|
+
numItems: number;
|
|
81
|
+
cursor: string | null;
|
|
82
|
+
};
|
|
83
|
+
period: {
|
|
84
|
+
end: number;
|
|
85
|
+
start: number;
|
|
86
|
+
};
|
|
87
|
+
scope: {
|
|
88
|
+
customerAccount: string;
|
|
89
|
+
livemode: boolean;
|
|
90
|
+
meterId: string;
|
|
91
|
+
stripeAccountId: string;
|
|
92
|
+
};
|
|
93
|
+
}, Promise<{
|
|
94
|
+
page: {
|
|
95
|
+
_creationTime: number;
|
|
96
|
+
_id: import("convex/values").GenericId<"usageCorrectionHistory">;
|
|
97
|
+
at: number;
|
|
98
|
+
eventId: import("convex/values").GenericId<"usageEvents">;
|
|
99
|
+
evidenceJson: string;
|
|
100
|
+
key: string;
|
|
101
|
+
occurredAt?: number | undefined;
|
|
102
|
+
reason: string;
|
|
103
|
+
recordJson: string;
|
|
104
|
+
scopeKey: string;
|
|
105
|
+
sequence: number;
|
|
106
|
+
state: "confirmed" | "held" | "invoice_adjustment_required" | "provider_accepted" | "requested" | "unsupported";
|
|
107
|
+
subscriptionJson: string;
|
|
108
|
+
}[];
|
|
109
|
+
isDone: boolean;
|
|
110
|
+
continueCursor: import("convex/server").Cursor;
|
|
111
|
+
splitCursor?: import("convex/server").Cursor | null;
|
|
112
|
+
pageStatus?: "SplitRecommended" | "SplitRequired" | null;
|
|
113
|
+
legacyHistoryMissing: boolean;
|
|
114
|
+
}>>;
|
|
115
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/usageCorrections/queries.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAqBtB,CAAC;AAEH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAcd,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCxB,CAAC"}
|