@voltro/plugin-billing 0.90.0 → 0.91.1
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 +131 -0
- package/THIRD-PARTY-NOTICES.md +22 -646
- package/dist/catalog.js +52 -52
- package/dist/index.d.ts +4 -1
- package/dist/index.js +251 -251
- package/dist/invoiceHistoryJournal.js +108 -108
- package/dist/invoiceHistoryProgress.js +107 -107
- package/dist/invoiceHistoryWork.js +103 -103
- package/dist/invoiceSnapshot.js +11 -11
- package/dist/invoiceStore.js +43 -43
- package/dist/paidInvoiceCoverage.js +13 -13
- package/dist/providers.js +35 -35
- package/dist/service.js +592 -592
- package/dist/stores.js +89 -89
- package/dist/stripeIdentity.js +17 -17
- package/dist/stripeInvoiceHistory.js +21 -21
- package/dist/stripeInvoicePayments.js +41 -41
- package/dist/stripeInvoiceSnapshot.js +17 -17
- package/dist/stripeProvider.js +74 -74
- package/dist/stripeRest.js +10 -10
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { BILLING_INVOICE_OBSERVATIONS_TABLE as
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
1
|
+
import { paidInvoiceCoverageInTransaction as e } from "./paidInvoiceCoverage.js";
|
|
2
|
+
import { captureSubscriptionObservation as t } from "./subscriptionObservation.js";
|
|
3
|
+
import { billingInvoicePaymentCorrectionsTable as n, billingInvoicePaymentHeadsTable as r } from "./invoicePaymentEpoch.js";
|
|
4
|
+
import { InvoicePaymentObservationSchema as i, assertInvoicePaymentObservation as a } from "./invoicePaymentObservation.js";
|
|
5
|
+
import { makeBillingEventDelivery as o } from "./eventDelivery.js";
|
|
6
|
+
import { BILLING_CUSTOMER_ACCOUNTS_TABLE as s, BILLING_CUSTOMER_CUSTODY_TABLE as c, billingCustomerAccountsTable as ee, billingCustomerCustodyTable as l } from "./customerStore.js";
|
|
7
|
+
import { buildEnforceInterceptor as te, evaluateEntitlement as u, requireEntitled as ne, requireEntitlement as d } from "./entitlement.js";
|
|
8
|
+
import { buildMeteringChangeTap as re, buildMeteringInterceptor as ie, hasCdcMeters as ae, runAutopilotFlush as oe, validateMeteringConfig as se } from "./metering.js";
|
|
9
|
+
import { BILLING_INVOICE_OBSERVATIONS_TABLE as ce, billingInvoiceObservationsTable as f, billingRetainedInvoiceObservationsTable as le } from "./invoiceStore.js";
|
|
10
|
+
import { buildPlanRegistry as ue, emptyPlanRegistry as de } from "./plans.js";
|
|
11
|
+
import { billingServiceLayer as fe, buildBillingService as pe, periodKey as me } from "./service.js";
|
|
12
|
+
import { dataStoreStores as he, isStaleStatusEvent as ge, memoryStores as p, selectCurrentSubscription as m } from "./stores.js";
|
|
13
|
+
import { BILLING_CUSTOMERS_TABLE as _e, BILLING_INVOICES_TABLE as ve, BILLING_SUBSCRIPTIONS_TABLE as ye, BILLING_USAGE_TABLE as be, billingCustomersTable as xe, billingInvoicesTable as Se, billingSubscriptionsTable as h, billingTables as Ce, billingUsageTable as we } from "./table.js";
|
|
14
|
+
import { BILLING_DUNNING_NOTICES_TABLE as Te, DEFAULT_DUNNING_STEPS as g, DEFAULT_GRACE_HOURS as _, DEFAULT_LOCKOUT as v, DUNNING_LOCK_STEP_ID as y, billingDunningNoticesTable as Ee, dataStoreDunningNoticeStore as b, defaultDunningEmail as x, dueSteps as S, dunningMailNotifier as De, episodeKeyOf as Oe, evaluateBillingEntitlement as C, graceEndOf as w, memoryDunningNoticeStore as T, resolveDunningConfig as ke } from "./dunning.js";
|
|
15
|
+
import { BILLING_FLUSH_CLAIMS_TABLE as Ae, billingFlushClaimsTable as je, claimFlushWindow as Me, flushWindowKey as Ne } from "./flushClaim.js";
|
|
16
|
+
import { assertBillingProductionReady as Pe, billingEgressOf as Fe, isProductionBoot as E, mockProvider as Ie, resolveProvider as Le } from "./providers.js";
|
|
17
|
+
import { BILLING_WEBHOOK_ID as D, BILLING_WEBHOOK_PATH as O, billingWebhookDescriptor as k, mountBillingWebhook as Re } from "./webhook.js";
|
|
18
|
+
import { billingRpcClientImports as ze, cancelSubscriptionDescriptor as Be, changePlanDescriptor as Ve, changeSeatsDescriptor as He, entitlementStatusDescriptor as Ue, invoicesDescriptor as We, operationStatusDescriptor as Ge, pendingOperationDescriptor as Ke, portalUrlDescriptor as qe, previewChangeDescriptor as Je, reportUsageDescriptor as Ye, resumeSubscriptionDescriptor as Xe, startCheckoutDescriptor as A, subscriptionDescriptor as Ze, syncDescriptor as Qe } from "./rpc.js";
|
|
19
|
+
import { BILLING_SUBSCRIPTION_WRITES_TABLE as $e, BILLING_SUBSCRIPTION_WRITE_HEADS_TABLE as et, billingSubscriptionWriteHeadsTable as j, billingSubscriptionWritesTable as M, dataStoreSubscriptionWriteStore as tt, isTerminalSubscriptionWrite as N } from "./subscriptionWriteStore.js";
|
|
20
|
+
import { BillingClosurePending as P, BillingError as F, BillingRequestStale as nt, BillingService as I, DEFAULT_PLAN as L, EntitlementExceeded as rt, SubscriptionLocked as it } from "./types.js";
|
|
21
|
+
import { STRIPE_DASHBOARD_REMINDERS as R, diffMeter as at, diffPortal as z, diffPrice as ot, diffProduct as B, diffRetiredMeter as V, diffRetiredPrice as H, diffRetiredProduct as U, diffTaxSettings as W, diffWebhook as G, portalParams as K, sellingReadiness as q } from "./catalog.js";
|
|
22
|
+
import { envOutRefusal as J, mergeEnvFile as st, openFindings as Y, parseProvisionArgs as ct, provisionStripeCatalog as lt, resolveProvisionKey as ut, runStripeProvision as dt } from "./provision.js";
|
|
23
|
+
import { STRIPE_API_VERSION as ft, StripeRestError as pt, formEncode as mt, redactStripeKeys as ht, stripeRest as gt } from "./stripeRest.js";
|
|
24
|
+
import { BILLING_CHECKOUT_OPERATIONS_TABLE as _t, billingCheckoutOperationsTable as vt, dataStoreCheckoutOperationStore as yt, memoryCheckoutOperationStore as bt } from "./checkoutStore.js";
|
|
25
|
+
import { BILLING_CLOSE_OPERATIONS_TABLE as xt, billingCloseOperationsTable as St, dataStoreBillingCloseStore as Ct, memoryBillingCloseStore as wt } from "./closeStore.js";
|
|
26
|
+
import { STRIPE_WEBHOOK_EVENTS as Tt, normalizeStripeEvent as Et, stripeProvider as Dt } from "./stripeProvider.js";
|
|
27
|
+
import { BILLING_USAGE_EVENTS_TABLE as Ot, billingUsageEventsTable as kt } from "./usageEvents.js";
|
|
28
|
+
import { BILLING_ACCOUNT_CUSTODY_INVENTORY_TABLES as At, BILLING_CUSTODY_INVENTORY_TABLES as jt, inspectBillingAccountCustody as Mt, inspectBillingCustody as Nt } from "./custodyInventory.js";
|
|
29
|
+
import { BILLING_INVOICE_HISTORY_PAGES_TABLE as Pt, BILLING_INVOICE_HISTORY_REFERENCES_TABLE as Ft, BILLING_INVOICE_HISTORY_WALKS_TABLE as It, billingInvoiceHistoryPagesTable as Lt, billingInvoiceHistoryReferencesTable as Rt, billingInvoiceHistoryWalksTable as zt, dataStoreInvoiceHistoryJournal as Bt } from "./invoiceHistoryJournal.js";
|
|
30
|
+
import { BILLING_INVOICE_HISTORY_WORK_TABLE as Vt, billingInvoiceHistoryWorkTable as Ht, dataStoreInvoiceHistoryWorkStore as Ut } from "./invoiceHistoryWork.js";
|
|
31
|
+
import { BILLING_INVOICE_HISTORY_DISPATCH_TABLE as Wt, BILLING_INVOICE_HISTORY_SCAN_ACCOUNTS_TABLE as Gt, billingInvoiceHistoryDispatchTable as Kt, billingInvoiceHistoryScanAccountsTable as qt, dataStoreInvoiceHistoryProgressStore as Jt } from "./invoiceHistoryProgress.js";
|
|
32
32
|
import { Effect as X } from "effect";
|
|
33
33
|
import { and as Yt, eq as Xt, registerRetention as Zt, retentionTtlMsFromEnv as Qt } from "@voltro/database";
|
|
34
34
|
import { dataStoreIdempotencyStore as $t } from "@voltro/runtime";
|
|
@@ -53,42 +53,42 @@ var Q = (e) => e === null ? null : {
|
|
|
53
53
|
secret: !0,
|
|
54
54
|
description: "Stripe webhook signing secret (whsec_…) for verifying webhook payloads."
|
|
55
55
|
}]), $ = "@voltro/plugin-billing", sn = (e = {}) => {
|
|
56
|
-
let
|
|
56
|
+
let t = process.env, n = ue(e.plans ?? {}), r = Le({
|
|
57
57
|
...e.provider === void 0 ? {} : { provider: e.provider },
|
|
58
58
|
...e.apiKey === void 0 ? {} : { apiKey: e.apiKey },
|
|
59
|
-
planForPriceId:
|
|
60
|
-
seatPricingForPriceId:
|
|
61
|
-
env:
|
|
62
|
-
}),
|
|
63
|
-
env:
|
|
59
|
+
planForPriceId: n.planForPriceId,
|
|
60
|
+
seatPricingForPriceId: n.seatPricingForPriceId,
|
|
61
|
+
env: t
|
|
62
|
+
}), i = e.webhookSecret ?? on.read("STRIPE_WEBHOOK_SECRET") ?? null, a = {
|
|
63
|
+
env: t,
|
|
64
64
|
providerOption: e.provider,
|
|
65
|
-
resolvedName:
|
|
66
|
-
webhookSecret:
|
|
65
|
+
resolvedName: r.name,
|
|
66
|
+
webhookSecret: i,
|
|
67
67
|
redirectOrigins: e.redirectOrigins
|
|
68
|
-
},
|
|
68
|
+
}, ee = ke(e.dunning, t);
|
|
69
69
|
Zt({
|
|
70
70
|
source: "plugin",
|
|
71
|
-
table:
|
|
71
|
+
table: be,
|
|
72
72
|
timeColumn: "updatedAt",
|
|
73
73
|
where: Yt(Xt("used", 0), Xt("reportedToProvider", 0)),
|
|
74
74
|
ttlMs: Qt(process.env.VOLTRO_BILLING_USAGE_TTL_HOURS, 9600),
|
|
75
75
|
label: "unused billing usage counters"
|
|
76
76
|
}), Zt({
|
|
77
77
|
source: "plugin",
|
|
78
|
-
table:
|
|
78
|
+
table: Ae,
|
|
79
79
|
timeColumn: "claimedAt",
|
|
80
80
|
ttlMs: Qt(process.env.VOLTRO_BILLING_FLUSH_CLAIM_TTL_HOURS, 1),
|
|
81
81
|
label: "billing flush claims"
|
|
82
82
|
}), Zt({
|
|
83
83
|
source: "plugin",
|
|
84
|
-
table:
|
|
84
|
+
table: Te,
|
|
85
85
|
timeColumn: "sentAt",
|
|
86
86
|
ttlMs: Qt(process.env.VOLTRO_BILLING_DUNNING_TTL_HOURS, 9600),
|
|
87
87
|
label: "billing dunning notices"
|
|
88
88
|
});
|
|
89
|
-
let { service:
|
|
90
|
-
provider:
|
|
91
|
-
plans:
|
|
89
|
+
let { service: l, holder: u } = pe({
|
|
90
|
+
provider: r,
|
|
91
|
+
plans: n,
|
|
92
92
|
...e.attempts === void 0 ? {} : { attempts: e.attempts },
|
|
93
93
|
...e.checkout === void 0 ? {} : { checkout: e.checkout },
|
|
94
94
|
...e.admit === void 0 ? {} : { admit: e.admit },
|
|
@@ -97,37 +97,37 @@ var Q = (e) => e === null ? null : {
|
|
|
97
97
|
...e.onEvent === void 0 ? {} : { onEvent: e.onEvent },
|
|
98
98
|
...e.resolveEntitlementLimit === void 0 ? {} : { resolveEntitlementLimit: e.resolveEntitlementLimit },
|
|
99
99
|
...e.invoiceHistoryHeadRescanMs === void 0 ? {} : { invoiceHistoryHeadRescanMs: e.invoiceHistoryHeadRescanMs },
|
|
100
|
-
dunning:
|
|
101
|
-
}),
|
|
100
|
+
dunning: ee
|
|
101
|
+
}), ne = fe(l), d, f = {
|
|
102
102
|
scope: Z({
|
|
103
103
|
base: $,
|
|
104
104
|
alias: e.alias,
|
|
105
105
|
instance: e.name
|
|
106
106
|
}),
|
|
107
107
|
store: () => {
|
|
108
|
-
if (
|
|
109
|
-
return
|
|
108
|
+
if (d === void 0) throw Error("Billing delivery requires the bound native store.");
|
|
109
|
+
return d;
|
|
110
110
|
}
|
|
111
|
-
},
|
|
112
|
-
provider:
|
|
113
|
-
service:
|
|
114
|
-
receipts:
|
|
111
|
+
}, le = o({
|
|
112
|
+
provider: r,
|
|
113
|
+
service: l,
|
|
114
|
+
receipts: f,
|
|
115
115
|
...e.onEvent === void 0 ? {} : { onEvent: e.onEvent }
|
|
116
|
-
}),
|
|
117
|
-
provider:
|
|
118
|
-
service:
|
|
119
|
-
receipts:
|
|
120
|
-
webhookSecret:
|
|
116
|
+
}), de = Re({
|
|
117
|
+
provider: r,
|
|
118
|
+
service: l,
|
|
119
|
+
receipts: f,
|
|
120
|
+
webhookSecret: i,
|
|
121
121
|
...e.onEvent === void 0 ? {} : { onEvent: e.onEvent },
|
|
122
122
|
onLateDelivery: () => {
|
|
123
|
-
|
|
123
|
+
Y();
|
|
124
124
|
}
|
|
125
|
-
}),
|
|
125
|
+
}), me = {
|
|
126
126
|
method: "POST",
|
|
127
|
-
path:
|
|
127
|
+
path: O,
|
|
128
128
|
originGuard: "exempt",
|
|
129
129
|
handle: async (e) => {
|
|
130
|
-
let t = await
|
|
130
|
+
let t = await de({
|
|
131
131
|
method: e.method,
|
|
132
132
|
path: e.path,
|
|
133
133
|
headers: e.headers,
|
|
@@ -140,63 +140,63 @@ var Q = (e) => e === null ? null : {
|
|
|
140
140
|
...t.headers === void 0 ? {} : { headers: { ...t.headers } }
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
-
},
|
|
143
|
+
}, ge = (e) => ({
|
|
144
144
|
...e,
|
|
145
|
-
execute: (
|
|
146
|
-
let
|
|
147
|
-
return
|
|
145
|
+
execute: (t, n) => {
|
|
146
|
+
let r = n.request.subject;
|
|
147
|
+
return r.type === "anonymous" || typeof r.tenantId != "string" || r.tenantId === "" ? X.fail(new F({
|
|
148
148
|
source: "billing",
|
|
149
149
|
message: "billing routes answer only a signed-in caller that belongs to a tenant",
|
|
150
150
|
transient: !1
|
|
151
|
-
})) : e.execute(
|
|
151
|
+
})) : e.execute(t, n);
|
|
152
152
|
}
|
|
153
|
-
}),
|
|
153
|
+
}), p = (e, t, n, r) => e.pipe(X.flatMap((e) => nn(r.request.subject, t.guards, n).pipe(X.flatMap((t) => t === null ? X.succeed(e) : X.fail(t))))), m = (e, t, n) => () => nn(n.request.subject, e.guards, t).pipe(X.flatMap((e) => e === null ? X.void : X.fail(new F({
|
|
154
154
|
source: "billing",
|
|
155
155
|
message: "Current billing authority is required.",
|
|
156
156
|
transient: !1
|
|
157
|
-
})))),
|
|
157
|
+
})))), _e = [
|
|
158
158
|
{
|
|
159
|
-
...
|
|
160
|
-
execute: (e,
|
|
161
|
-
let
|
|
162
|
-
return
|
|
163
|
-
tenantId:
|
|
164
|
-
plan:
|
|
165
|
-
successUrl:
|
|
166
|
-
cancelUrl:
|
|
167
|
-
...
|
|
168
|
-
authorize: () => nn(
|
|
159
|
+
...A,
|
|
160
|
+
execute: (e, t) => {
|
|
161
|
+
let n = e;
|
|
162
|
+
return p(l.startCheckout({
|
|
163
|
+
tenantId: t.request.subject.tenantId ?? "",
|
|
164
|
+
plan: n.plan,
|
|
165
|
+
successUrl: n.successUrl,
|
|
166
|
+
cancelUrl: n.cancelUrl,
|
|
167
|
+
...n.quantity === void 0 ? {} : { quantity: n.quantity },
|
|
168
|
+
authorize: () => nn(t.request.subject, A.guards, e).pipe(X.flatMap((e) => e === null ? X.void : X.fail(new F({
|
|
169
169
|
source: "billing",
|
|
170
170
|
message: "Current checkout authority could not be confirmed.",
|
|
171
171
|
transient: !1
|
|
172
172
|
}))))
|
|
173
|
-
}),
|
|
173
|
+
}), A, e, t);
|
|
174
174
|
}
|
|
175
175
|
},
|
|
176
176
|
{
|
|
177
|
-
...
|
|
177
|
+
...qe,
|
|
178
178
|
execute: (e, t) => {
|
|
179
179
|
let n = e;
|
|
180
|
-
return
|
|
180
|
+
return p(l.portalUrl(t.request.subject.tenantId ?? "", n.returnUrl), qe, e, t);
|
|
181
181
|
}
|
|
182
182
|
},
|
|
183
183
|
{
|
|
184
|
-
...
|
|
184
|
+
...Ze,
|
|
185
185
|
source: [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
ye,
|
|
187
|
+
s,
|
|
188
|
+
c
|
|
189
189
|
],
|
|
190
|
-
execute: (e, t) =>
|
|
190
|
+
execute: (e, t) => l.subscription(t.request.subject.tenantId ?? "").pipe(X.map((e) => ({ subscription: Q(e) })))
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
...
|
|
193
|
+
...Ue,
|
|
194
194
|
source: [
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
ye,
|
|
196
|
+
s,
|
|
197
|
+
c
|
|
198
198
|
],
|
|
199
|
-
execute: (e, t) =>
|
|
199
|
+
execute: (e, t) => l.entitlementStatus(t.request.subject.tenantId ?? "").pipe(X.map((e) => ({
|
|
200
200
|
plan: e.plan,
|
|
201
201
|
billedPlan: e.billedPlan,
|
|
202
202
|
status: e.status,
|
|
@@ -208,10 +208,10 @@ var Q = (e) => e === null ? null : {
|
|
|
208
208
|
})))
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
|
-
...
|
|
211
|
+
...Je,
|
|
212
212
|
execute: (e, t) => {
|
|
213
213
|
let n = e;
|
|
214
|
-
return
|
|
214
|
+
return l.previewChange(t.request.subject.tenantId ?? "", {
|
|
215
215
|
...n.plan === void 0 ? {} : { plan: n.plan },
|
|
216
216
|
...n.quantity === void 0 ? {} : { quantity: n.quantity }
|
|
217
217
|
}).pipe(X.map((e) => ({
|
|
@@ -223,74 +223,74 @@ var Q = (e) => e === null ? null : {
|
|
|
223
223
|
}
|
|
224
224
|
},
|
|
225
225
|
{
|
|
226
|
-
...
|
|
226
|
+
...We,
|
|
227
227
|
source: [
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
ce,
|
|
229
|
+
c,
|
|
230
|
+
s
|
|
231
231
|
],
|
|
232
|
-
execute: (e, t) =>
|
|
232
|
+
execute: (e, t) => l.invoices(t.request.subject.tenantId ?? "").pipe(X.map((e) => ({ invoices: e.map((e) => ({
|
|
233
233
|
...e,
|
|
234
234
|
createdAt: e.createdAt?.toISOString() ?? null
|
|
235
235
|
})) })))
|
|
236
236
|
},
|
|
237
237
|
{
|
|
238
|
-
...
|
|
238
|
+
...Ye,
|
|
239
239
|
execute: (e, t) => {
|
|
240
240
|
let n = e;
|
|
241
|
-
return
|
|
241
|
+
return l.reportUsage(t.request.subject.tenantId ?? "", n.key, n.quantity).pipe(X.map(() => ({ ok: !0 })));
|
|
242
242
|
}
|
|
243
243
|
},
|
|
244
244
|
{
|
|
245
|
-
...
|
|
245
|
+
...Ve,
|
|
246
246
|
execute: (e, t) => {
|
|
247
247
|
let n = e;
|
|
248
|
-
return
|
|
248
|
+
return p(l.changePlan(t.request.subject.tenantId ?? "", n.plan, void 0, m(Ve, e, t), n.requestId).pipe(X.map((e) => ({
|
|
249
249
|
plan: e.plan,
|
|
250
250
|
quantity: e.quantity,
|
|
251
251
|
prorationMinor: e.prorationMinor,
|
|
252
252
|
currency: e.currency
|
|
253
|
-
}))),
|
|
253
|
+
}))), Ve, e, t);
|
|
254
254
|
}
|
|
255
255
|
},
|
|
256
256
|
{
|
|
257
|
-
...
|
|
257
|
+
...He,
|
|
258
258
|
execute: (e, t) => {
|
|
259
259
|
let n = e;
|
|
260
|
-
return
|
|
260
|
+
return p(l.changeSeats(t.request.subject.tenantId ?? "", n.quantity, void 0, m(He, e, t), n.requestId).pipe(X.map((e) => ({
|
|
261
261
|
plan: e.plan,
|
|
262
262
|
quantity: e.quantity,
|
|
263
263
|
prorationMinor: e.prorationMinor,
|
|
264
264
|
currency: e.currency
|
|
265
|
-
}))),
|
|
265
|
+
}))), He, e, t);
|
|
266
266
|
}
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
|
-
...
|
|
270
|
-
execute: (e, t) =>
|
|
269
|
+
...Be,
|
|
270
|
+
execute: (e, t) => p(l.cancelSubscription(t.request.subject.tenantId ?? "", m(Be, e, t), e.requestId).pipe(X.map((e) => ({ subscription: Q(e) }))), Be, e, t)
|
|
271
271
|
},
|
|
272
272
|
{
|
|
273
|
-
...
|
|
274
|
-
execute: (e, t) =>
|
|
273
|
+
...Ge,
|
|
274
|
+
execute: (e, t) => p(l.subscriptionWriteStatus(t.request.subject.tenantId ?? "", e.requestId), Ge, e, t)
|
|
275
275
|
},
|
|
276
276
|
{
|
|
277
|
-
...
|
|
278
|
-
source: [
|
|
279
|
-
execute: (e, t) =>
|
|
277
|
+
...Ke,
|
|
278
|
+
source: [et, $e],
|
|
279
|
+
execute: (e, t) => p(l.pendingSubscriptionWrite(t.request.subject.tenantId ?? "").pipe(X.map((e) => ({ operation: e }))), Ke, e, t)
|
|
280
280
|
},
|
|
281
281
|
{
|
|
282
|
-
...
|
|
283
|
-
execute: (e, t) =>
|
|
282
|
+
...Qe,
|
|
283
|
+
execute: (e, t) => l.syncTenant(t.request.subject.tenantId ?? "").pipe(X.map((e) => ({ subscription: e === null ? null : Q(e) })))
|
|
284
284
|
},
|
|
285
285
|
{
|
|
286
|
-
...
|
|
287
|
-
execute: (e, t) =>
|
|
286
|
+
...Xe,
|
|
287
|
+
execute: (e, t) => p(l.resumeSubscription(t.request.subject.tenantId ?? "", m(Xe, e, t), e.requestId).pipe(X.map((e) => ({ subscription: Q(e) }))), Xe, e, t)
|
|
288
288
|
}
|
|
289
|
-
].map(
|
|
289
|
+
].map(ge), ve = (e, t) => ({
|
|
290
290
|
kind: "json",
|
|
291
291
|
status: e,
|
|
292
292
|
data: { error: t }
|
|
293
|
-
}),
|
|
293
|
+
}), xe = [{
|
|
294
294
|
method: "GET",
|
|
295
295
|
path: "/stats",
|
|
296
296
|
scope: "declaration",
|
|
@@ -298,11 +298,11 @@ var Q = (e) => e === null ? null : {
|
|
|
298
298
|
handler: () => X.succeed({
|
|
299
299
|
kind: "json",
|
|
300
300
|
data: {
|
|
301
|
-
provider:
|
|
302
|
-
supportsMeteredUsage:
|
|
303
|
-
plans:
|
|
301
|
+
provider: r.name,
|
|
302
|
+
supportsMeteredUsage: r.supportsMeteredUsage,
|
|
303
|
+
plans: n.planIds(),
|
|
304
304
|
enforce: e.enforce ? Object.keys(e.enforce) : [],
|
|
305
|
-
webhookPath:
|
|
305
|
+
webhookPath: O
|
|
306
306
|
}
|
|
307
307
|
})
|
|
308
308
|
}, {
|
|
@@ -310,57 +310,57 @@ var Q = (e) => e === null ? null : {
|
|
|
310
310
|
path: "/usage",
|
|
311
311
|
scope: "process",
|
|
312
312
|
description: "Pending (un-flushed) metered usage counters",
|
|
313
|
-
handler: () =>
|
|
313
|
+
handler: () => u.stores.usage.pending().pipe(X.map((e) => ({
|
|
314
314
|
kind: "json",
|
|
315
315
|
data: { usage: e }
|
|
316
|
-
})), X.catch((e) => X.succeed(
|
|
317
|
-
}],
|
|
316
|
+
})), X.catch((e) => X.succeed(ve(500, `${e.source} failed`))))
|
|
317
|
+
}], Se = [
|
|
318
318
|
{
|
|
319
|
-
schema:
|
|
319
|
+
schema: F,
|
|
320
320
|
import: {
|
|
321
321
|
module: "@voltro/plugin-billing/errors",
|
|
322
322
|
name: "BillingError"
|
|
323
323
|
}
|
|
324
324
|
},
|
|
325
325
|
{
|
|
326
|
-
schema:
|
|
326
|
+
schema: rt,
|
|
327
327
|
import: {
|
|
328
328
|
module: "@voltro/plugin-billing/errors",
|
|
329
329
|
name: "EntitlementExceeded"
|
|
330
330
|
}
|
|
331
331
|
},
|
|
332
332
|
{
|
|
333
|
-
schema:
|
|
333
|
+
schema: it,
|
|
334
334
|
import: {
|
|
335
335
|
module: "@voltro/plugin-billing/errors",
|
|
336
336
|
name: "SubscriptionLocked"
|
|
337
337
|
}
|
|
338
338
|
},
|
|
339
339
|
{
|
|
340
|
-
schema:
|
|
340
|
+
schema: nt,
|
|
341
341
|
import: {
|
|
342
342
|
module: "@voltro/plugin-billing/errors",
|
|
343
343
|
name: "BillingRequestStale"
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
|
-
],
|
|
347
|
-
|
|
348
|
-
let
|
|
349
|
-
claimChange: () =>
|
|
346
|
+
], h = e.enforce, we = h !== void 0 && Object.keys(h).length > 0 ? te(h, l) : void 0, g = e.metering;
|
|
347
|
+
g !== void 0 && se(g);
|
|
348
|
+
let _ = g !== void 0 && Object.keys(g).length > 0 ? ie(l, g) : void 0, v = g !== void 0 && ae(g), y = { claim: void 0 }, Ee = g === void 0 ? void 0 : re(l, g, {
|
|
349
|
+
claimChange: () => y.claim,
|
|
350
350
|
onUngated: () => {
|
|
351
351
|
X.runSync(X.logWarning("metering: CDC meters are accruing PER PROCESS — with N replicas a tenant is billed N times. The framework did not hand this plugin a change claimer (expected on the memory store; on a SQL store this is a bug worth reporting).").pipe(X.annotateLogs({ scope: "voltro:billing" })));
|
|
352
352
|
}
|
|
353
|
-
}),
|
|
354
|
-
if (!Number.isSafeInteger(
|
|
355
|
-
let
|
|
353
|
+
}), b = en([_, we].filter((e) => e !== void 0)), x, S = e.invoiceHistoryRecoveryIntervalMs ?? 6e4;
|
|
354
|
+
if (!Number.isSafeInteger(S) || S < 0 || S !== 0 && (S < 1e3 || S > 864e5)) throw TypeError("Invoice-history recovery requires 0 or a whole interval from one second through one day");
|
|
355
|
+
let De = r.listInvoiceHistory !== void 0 && r.fetchInvoiceSnapshot !== void 0, Oe = Z({
|
|
356
356
|
base: $,
|
|
357
357
|
alias: e.alias,
|
|
358
358
|
instance: e.name
|
|
359
|
-
}) + ".invoiceHistoryRecovery",
|
|
360
|
-
if (!
|
|
361
|
-
if (
|
|
362
|
-
let e =
|
|
363
|
-
let
|
|
359
|
+
}) + ".invoiceHistoryRecovery", C, w, T, E = 0, Ie = () => {
|
|
360
|
+
if (!V || x === void 0 || !De) return Promise.resolve();
|
|
361
|
+
if (T !== void 0) return T;
|
|
362
|
+
let e = u.stores, t = E, n = Promise.resolve().then(async () => {
|
|
363
|
+
let n = performance.now() + 3e4, r = {
|
|
364
364
|
passes: 0,
|
|
365
365
|
admittedPages: 0,
|
|
366
366
|
observed: 0,
|
|
@@ -369,98 +369,98 @@ var Q = (e) => e === null ? null : {
|
|
|
369
369
|
unconfirmed: 0
|
|
370
370
|
};
|
|
371
371
|
try {
|
|
372
|
-
for (let
|
|
373
|
-
if (!
|
|
374
|
-
let
|
|
375
|
-
if (
|
|
372
|
+
for (let i = 0; i < 8 && performance.now() < n; i++) {
|
|
373
|
+
if (!V || E !== t || u.stores !== e) return;
|
|
374
|
+
let n = await X.runPromise(l.reconcileInvoiceHistory());
|
|
375
|
+
if (r.passes++, r.admittedPages += n.admittedPages, r.observed += n.observed, r.deferred += n.deferred, r.busy += n.busy, r.unconfirmed += n.unconfirmed, n.kind === "idle" || n.kind === "contended") break;
|
|
376
376
|
}
|
|
377
|
-
if (
|
|
378
|
-
|
|
377
|
+
if (r.unconfirmed > 0) throw Error("Original invoice observations remain unconfirmed");
|
|
378
|
+
V && E === t && (r.admittedPages > 0 || r.observed > 0 || r.deferred > 0) && J.info("billing invoice-history recovery", r);
|
|
379
379
|
} catch {
|
|
380
|
-
throw
|
|
380
|
+
throw J.error("Billing invoice-history recovery remains retryable; native custody is retained.", r), new F({
|
|
381
381
|
source: "invoiceHistoryRecovery",
|
|
382
382
|
transient: !0,
|
|
383
383
|
message: "The bounded invoice-history recovery pass remains unconfirmed."
|
|
384
384
|
});
|
|
385
385
|
}
|
|
386
386
|
});
|
|
387
|
-
return
|
|
388
|
-
|
|
387
|
+
return T = n, n.then(() => {
|
|
388
|
+
T === n && (T = void 0);
|
|
389
389
|
}, () => {
|
|
390
|
-
|
|
391
|
-
}),
|
|
392
|
-
},
|
|
393
|
-
let e =
|
|
394
|
-
|
|
395
|
-
let t = (await Promise.allSettled([Promise.resolve().then(() => e?.stop()),
|
|
390
|
+
T === n && (T = void 0);
|
|
391
|
+
}), n;
|
|
392
|
+
}, D = async () => {
|
|
393
|
+
let e = w;
|
|
394
|
+
w = void 0, C = void 0, E++;
|
|
395
|
+
let t = (await Promise.allSettled([Promise.resolve().then(() => e?.stop()), T ?? Promise.resolve()])).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
396
396
|
if (t.length > 0) throw AggregateError(t, "Billing invoice-history work did not drain cleanly");
|
|
397
|
-
},
|
|
398
|
-
if (!
|
|
399
|
-
let e =
|
|
397
|
+
}, k = () => {
|
|
398
|
+
if (!V || x === void 0 || w !== void 0 || S === 0 || !De) return;
|
|
399
|
+
let e = C;
|
|
400
400
|
if (e?.workloads === void 0 || e.workloads.includes("schedules")) {
|
|
401
401
|
if (e?.scheduleCoordinated === void 0) throw Error("Automatic invoice-history recovery requires native coordinated schedule binding; configure 0 only with an explicit recovery driver");
|
|
402
|
-
|
|
402
|
+
w = e.scheduleCoordinated(Oe, S, Ie);
|
|
403
403
|
}
|
|
404
|
-
},
|
|
405
|
-
if (!Number.isSafeInteger(
|
|
406
|
-
let
|
|
404
|
+
}, j = e.subscriptionWriteRecoveryIntervalMs ?? 6e4;
|
|
405
|
+
if (!Number.isSafeInteger(j) || j < 0 || j !== 0 && (j < 1e3 || j > 864e5)) throw TypeError("Subscription-write recovery requires 0 or a whole interval from one second through one day");
|
|
406
|
+
let M = r.supportsNativeSubscriptionWrites === !0, tt = Z({
|
|
407
407
|
base: $,
|
|
408
408
|
alias: e.alias,
|
|
409
409
|
instance: e.name
|
|
410
|
-
}) + ".subscriptionWriteRecovery",
|
|
411
|
-
if (!
|
|
412
|
-
if (
|
|
413
|
-
let e =
|
|
414
|
-
let
|
|
410
|
+
}) + ".subscriptionWriteRecovery", N, P, I, L = 0, R = null, at = () => {
|
|
411
|
+
if (!V || x === void 0 || !M) return Promise.resolve();
|
|
412
|
+
if (I !== void 0) return I;
|
|
413
|
+
let e = u.stores, t = L, n = Promise.resolve().then(async () => {
|
|
414
|
+
let n = await X.runPromise(l.recoverSubscriptionWrites({
|
|
415
415
|
limit: 25,
|
|
416
|
-
afterTenantId:
|
|
416
|
+
afterTenantId: R
|
|
417
417
|
}));
|
|
418
|
-
|
|
418
|
+
L === t && u.stores === e && (R = n.nextAfter, (n.completed > 0 || n.withdrawn > 0 || n.pending > 0) && J.info("billing subscription-write recovery", { ...n }));
|
|
419
419
|
}).catch(() => {
|
|
420
|
-
throw
|
|
420
|
+
throw J.error("Billing subscription-write recovery remains retryable; native intents are retained.", {}), new F({
|
|
421
421
|
source: "subscriptionWriteRecovery",
|
|
422
422
|
transient: !0,
|
|
423
423
|
message: "The bounded subscription-write recovery pass remains unconfirmed."
|
|
424
424
|
});
|
|
425
425
|
});
|
|
426
|
-
return
|
|
427
|
-
|
|
426
|
+
return I = n, n.then(() => {
|
|
427
|
+
I === n && (I = void 0);
|
|
428
428
|
}, () => {
|
|
429
|
-
|
|
430
|
-
}),
|
|
431
|
-
},
|
|
432
|
-
let e =
|
|
433
|
-
|
|
434
|
-
let t = (await Promise.allSettled([Promise.resolve().then(() => e?.stop()),
|
|
429
|
+
I === n && (I = void 0);
|
|
430
|
+
}), n;
|
|
431
|
+
}, z = async () => {
|
|
432
|
+
let e = P;
|
|
433
|
+
P = void 0, N = void 0, L++, R = null;
|
|
434
|
+
let t = (await Promise.allSettled([Promise.resolve().then(() => e?.stop()), I ?? Promise.resolve()])).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
435
435
|
if (t.length > 0) throw AggregateError(t, "Billing subscription-write recovery did not drain cleanly");
|
|
436
|
-
},
|
|
437
|
-
if (!
|
|
438
|
-
let e =
|
|
436
|
+
}, ot = () => {
|
|
437
|
+
if (!V || x === void 0 || P !== void 0 || j === 0 || !M) return;
|
|
438
|
+
let e = N;
|
|
439
439
|
if (e?.workloads === void 0 || e.workloads.includes("schedules")) {
|
|
440
440
|
if (e?.scheduleCoordinated === void 0) throw Error("Automatic subscription-write recovery requires native coordinated schedule binding; configure 0 only with an explicit recovery driver");
|
|
441
|
-
|
|
441
|
+
P = e.scheduleCoordinated(tt, j, at);
|
|
442
442
|
}
|
|
443
|
-
},
|
|
443
|
+
}, B, V = !1, H = !1, U, W, G = null, K = !1, q, J = {
|
|
444
444
|
info: (e, t) => {
|
|
445
445
|
console.info(e, t ?? {});
|
|
446
446
|
},
|
|
447
447
|
error: (e, t) => {
|
|
448
448
|
console.error(e, t ?? {});
|
|
449
449
|
}
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
}, e),
|
|
454
|
-
},
|
|
455
|
-
let e =
|
|
456
|
-
if (!
|
|
457
|
-
if (
|
|
458
|
-
let t =
|
|
459
|
-
return t > 0 ? (
|
|
450
|
+
}, st = (e) => {
|
|
451
|
+
V && W === void 0 && (W = setTimeout(() => {
|
|
452
|
+
W = void 0, Y();
|
|
453
|
+
}, e), W.unref?.());
|
|
454
|
+
}, Y = () => {
|
|
455
|
+
let e = r.listUndeliveredEvents;
|
|
456
|
+
if (!V || x === void 0 || e === void 0) return Promise.resolve();
|
|
457
|
+
if (U !== void 0) return U;
|
|
458
|
+
let t = q === void 0 ? 0 : 6e4 - (performance.now() - q);
|
|
459
|
+
return t > 0 ? (st(t), Promise.resolve()) : (U = Promise.resolve().then(async () => {
|
|
460
460
|
let t = !1, n = 0, r = 0, i = 0, a = /* @__PURE__ */ new Set();
|
|
461
461
|
try {
|
|
462
|
-
for (let o = 0; o < 10 &&
|
|
463
|
-
let o =
|
|
462
|
+
for (let o = 0; o < 10 && V; o++) {
|
|
463
|
+
let o = G;
|
|
464
464
|
if (o !== null) {
|
|
465
465
|
if (a.has(o)) throw Error("The provider event cursor repeated.");
|
|
466
466
|
a.add(o);
|
|
@@ -471,45 +471,45 @@ var Q = (e) => e === null ? null : {
|
|
|
471
471
|
}));
|
|
472
472
|
if (!Array.isArray(s.events) || s.events.length > 100 || s.nextCursor !== null && (typeof s.nextCursor != "string" || !s.nextCursor || s.nextCursor !== s.events.at(-1)?.id || s.nextCursor === o)) throw Error("The provider event page did not supply a bounded advancing cursor.");
|
|
473
473
|
for (let e of s.events) {
|
|
474
|
-
if (!
|
|
474
|
+
if (!V) return;
|
|
475
475
|
try {
|
|
476
|
-
await X.runPromise(
|
|
476
|
+
await X.runPromise(le(e)) === "processed" ? n++ : r++;
|
|
477
477
|
} catch {
|
|
478
|
-
i++,
|
|
478
|
+
i++, K = !0, J.error("billing catch-up: delivery remains retryable", { eventId: e.id });
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
|
-
if (
|
|
482
|
-
t =
|
|
481
|
+
if (G = s.nextCursor, G === null) {
|
|
482
|
+
t = K, K = !1;
|
|
483
483
|
break;
|
|
484
484
|
}
|
|
485
485
|
t = !0;
|
|
486
486
|
}
|
|
487
|
-
|
|
487
|
+
J.info("billing catch-up", {
|
|
488
488
|
processed: n,
|
|
489
489
|
replayed: r,
|
|
490
490
|
failed: i,
|
|
491
|
-
continuation:
|
|
491
|
+
continuation: G !== null
|
|
492
492
|
});
|
|
493
493
|
} catch {
|
|
494
|
-
t = !0,
|
|
494
|
+
t = !0, J.error("billing catch-up failed; the current page will be retried");
|
|
495
495
|
} finally {
|
|
496
|
-
|
|
496
|
+
q = performance.now(), U = void 0, t && st(6e4);
|
|
497
497
|
}
|
|
498
|
-
}),
|
|
499
|
-
},
|
|
500
|
-
e !== void 0 && (
|
|
501
|
-
},
|
|
498
|
+
}), U);
|
|
499
|
+
}, ct = (e) => {
|
|
500
|
+
e !== void 0 && (J = e), !H && V && x !== void 0 && (H = !0, Y());
|
|
501
|
+
}, lt = [
|
|
502
502
|
"store:write",
|
|
503
503
|
"inspect:read",
|
|
504
504
|
"inspect:write",
|
|
505
505
|
"network:outbound:*",
|
|
506
|
-
...
|
|
506
|
+
...b === void 0 ? [] : [
|
|
507
507
|
"rpc:intercept:mutation",
|
|
508
508
|
"rpc:intercept:action",
|
|
509
509
|
"rpc:intercept:workflow"
|
|
510
510
|
],
|
|
511
|
-
...
|
|
512
|
-
...
|
|
511
|
+
..._ === void 0 ? [] : ["rpc:intercept:query"],
|
|
512
|
+
...v ? ["store:changes:read"] : []
|
|
513
513
|
];
|
|
514
514
|
return tn({
|
|
515
515
|
name: Z({
|
|
@@ -519,58 +519,58 @@ var Q = (e) => e === null ? null : {
|
|
|
519
519
|
}),
|
|
520
520
|
baseName: $,
|
|
521
521
|
description: "Billing — subscriptions, plans, entitlements + usage metering over a pluggable BillingProvider (Stripe + mock). Ships the BillingService, the requireEntitlement() in-handler guard + the enforce-map interceptor, the /billing/webhook receiver (riding @voltro/plugin-webhooks for signature + idempotency), and the _voltro_billing_* tables. Money is integer minor units.",
|
|
522
|
-
permissions:
|
|
522
|
+
permissions: lt,
|
|
523
523
|
declaredEnv: on.declared,
|
|
524
|
-
egress:
|
|
525
|
-
services:
|
|
526
|
-
routes:
|
|
527
|
-
rpcClientDescriptors:
|
|
528
|
-
httpRoutes: [
|
|
529
|
-
inspectEndpoints:
|
|
530
|
-
extendSchema: { tables: [...
|
|
531
|
-
errorSchemas:
|
|
532
|
-
...
|
|
533
|
-
interceptMutation:
|
|
534
|
-
interceptAction:
|
|
535
|
-
interceptWorkflow:
|
|
524
|
+
egress: Fe(r),
|
|
525
|
+
services: ne,
|
|
526
|
+
routes: _e,
|
|
527
|
+
rpcClientDescriptors: ze,
|
|
528
|
+
httpRoutes: [me],
|
|
529
|
+
inspectEndpoints: xe,
|
|
530
|
+
extendSchema: { tables: [...Ce(), je] },
|
|
531
|
+
errorSchemas: Se,
|
|
532
|
+
...b === void 0 ? {} : {
|
|
533
|
+
interceptMutation: b,
|
|
534
|
+
interceptAction: b,
|
|
535
|
+
interceptWorkflow: b
|
|
536
536
|
},
|
|
537
|
-
...
|
|
538
|
-
...
|
|
537
|
+
..._ === void 0 ? {} : { interceptQuery: _ },
|
|
538
|
+
...v ? { onChangeEvent: Ee } : {},
|
|
539
539
|
bindDataStore: async (e, t) => {
|
|
540
|
-
await Promise.all([
|
|
540
|
+
await Promise.all([D(), z()]), C = t, N = t, u.stores = he(e), x = e, d = $t(e), ct(), y.claim = t?.claimChange, k(), ot();
|
|
541
541
|
},
|
|
542
|
-
onActivate: (t) => (
|
|
542
|
+
onActivate: (t) => (Pe(a), X.sync(() => {
|
|
543
543
|
t.logger.info("billing active", {
|
|
544
|
-
provider:
|
|
545
|
-
plans:
|
|
546
|
-
enforce:
|
|
547
|
-
metering:
|
|
548
|
-
webhook:
|
|
544
|
+
provider: r.name,
|
|
545
|
+
plans: n.planIds().length,
|
|
546
|
+
enforce: h ? Object.keys(h).length : 0,
|
|
547
|
+
metering: g ? Object.keys(g).length : 0,
|
|
548
|
+
webhook: O,
|
|
549
549
|
redirectOrigins: e.redirectOrigins?.length ?? "any"
|
|
550
|
-
}),
|
|
551
|
-
let
|
|
552
|
-
if (
|
|
550
|
+
}), r.name === "stripe" && e.redirectOrigins === void 0 && t.logger.warn("billing: no redirectOrigins — checkout and portal accept any return URL; set billingPlugin({ redirectOrigins })", {});
|
|
551
|
+
let i = e.flushIntervalMs ?? 6e4, a = g, o = a !== void 0 && Object.keys(a).length > 0;
|
|
552
|
+
if (i > 0) {
|
|
553
553
|
let e = an();
|
|
554
|
-
|
|
555
|
-
let t =
|
|
554
|
+
B = setInterval(() => {
|
|
555
|
+
let t = x;
|
|
556
556
|
if (t === void 0) return;
|
|
557
|
-
let
|
|
557
|
+
let n = Date.now();
|
|
558
558
|
(async () => {
|
|
559
|
-
await
|
|
559
|
+
await Me(t, Ne(n, i), e, n) && await X.runPromise((o ? oe(l, t, a) : l.flushUsage()).pipe(X.catch(() => X.void)));
|
|
560
560
|
})();
|
|
561
|
-
},
|
|
561
|
+
}, i), B.unref?.();
|
|
562
562
|
}
|
|
563
|
-
|
|
563
|
+
V = !0, ct(t.logger), k(), ot();
|
|
564
564
|
})),
|
|
565
565
|
onDeactivate: () => X.promise(async () => {
|
|
566
|
-
|
|
566
|
+
V = !1, H = !1, W !== void 0 && (clearTimeout(W), W = void 0), B !== void 0 && (clearInterval(B), B = void 0);
|
|
567
567
|
let e = (await Promise.allSettled([
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
568
|
+
D(),
|
|
569
|
+
z(),
|
|
570
|
+
U ?? Promise.resolve()
|
|
571
571
|
])).flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
572
572
|
if (e.length > 0) throw AggregateError(e, "Billing recovery shutdown requires reconciliation");
|
|
573
573
|
})
|
|
574
574
|
});
|
|
575
575
|
};
|
|
576
|
-
export {
|
|
576
|
+
export { At as BILLING_ACCOUNT_CUSTODY_INVENTORY_TABLES, _t as BILLING_CHECKOUT_OPERATIONS_TABLE, xt as BILLING_CLOSE_OPERATIONS_TABLE, jt as BILLING_CUSTODY_INVENTORY_TABLES, _e as BILLING_CUSTOMERS_TABLE, s as BILLING_CUSTOMER_ACCOUNTS_TABLE, c as BILLING_CUSTOMER_CUSTODY_TABLE, Te as BILLING_DUNNING_NOTICES_TABLE, Ae as BILLING_FLUSH_CLAIMS_TABLE, ve as BILLING_INVOICES_TABLE, Wt as BILLING_INVOICE_HISTORY_DISPATCH_TABLE, Pt as BILLING_INVOICE_HISTORY_PAGES_TABLE, Ft as BILLING_INVOICE_HISTORY_REFERENCES_TABLE, Gt as BILLING_INVOICE_HISTORY_SCAN_ACCOUNTS_TABLE, It as BILLING_INVOICE_HISTORY_WALKS_TABLE, Vt as BILLING_INVOICE_HISTORY_WORK_TABLE, ce as BILLING_INVOICE_OBSERVATIONS_TABLE, ye as BILLING_SUBSCRIPTIONS_TABLE, $e as BILLING_SUBSCRIPTION_WRITES_TABLE, et as BILLING_SUBSCRIPTION_WRITE_HEADS_TABLE, Ot as BILLING_USAGE_EVENTS_TABLE, be as BILLING_USAGE_TABLE, D as BILLING_WEBHOOK_ID, O as BILLING_WEBHOOK_PATH, P as BillingClosurePending, F as BillingError, nt as BillingRequestStale, I as BillingService, g as DEFAULT_DUNNING_STEPS, _ as DEFAULT_GRACE_HOURS, v as DEFAULT_LOCKOUT, L as DEFAULT_PLAN, y as DUNNING_LOCK_STEP_ID, rt as EntitlementExceeded, i as InvoicePaymentObservationSchema, ft as STRIPE_API_VERSION, R as STRIPE_DASHBOARD_REMINDERS, Tt as STRIPE_WEBHOOK_EVENTS, pt as StripeRestError, it as SubscriptionLocked, Pe as assertBillingProductionReady, a as assertInvoicePaymentObservation, vt as billingCheckoutOperationsTable, St as billingCloseOperationsTable, ee as billingCustomerAccountsTable, l as billingCustomerCustodyTable, xe as billingCustomersTable, Ee as billingDunningNoticesTable, Fe as billingEgressOf, je as billingFlushClaimsTable, Kt as billingInvoiceHistoryDispatchTable, Lt as billingInvoiceHistoryPagesTable, Rt as billingInvoiceHistoryReferencesTable, qt as billingInvoiceHistoryScanAccountsTable, zt as billingInvoiceHistoryWalksTable, Ht as billingInvoiceHistoryWorkTable, f as billingInvoiceObservationsTable, n as billingInvoicePaymentCorrectionsTable, r as billingInvoicePaymentHeadsTable, Se as billingInvoicesTable, sn as billingPlugin, le as billingRetainedInvoiceObservationsTable, fe as billingServiceLayer, j as billingSubscriptionWriteHeadsTable, M as billingSubscriptionWritesTable, h as billingSubscriptionsTable, Ce as billingTables, kt as billingUsageEventsTable, we as billingUsageTable, k as billingWebhookDescriptor, pe as buildBillingService, te as buildEnforceInterceptor, ue as buildPlanRegistry, t as captureSubscriptionObservation, Me as claimFlushWindow, Ct as dataStoreBillingCloseStore, yt as dataStoreCheckoutOperationStore, b as dataStoreDunningNoticeStore, Bt as dataStoreInvoiceHistoryJournal, Jt as dataStoreInvoiceHistoryProgressStore, Ut as dataStoreInvoiceHistoryWorkStore, he as dataStoreStores, tt as dataStoreSubscriptionWriteStore, x as defaultDunningEmail, at as diffMeter, z as diffPortal, ot as diffPrice, B as diffProduct, V as diffRetiredMeter, H as diffRetiredPrice, U as diffRetiredProduct, W as diffTaxSettings, G as diffWebhook, S as dueSteps, De as dunningMailNotifier, de as emptyPlanRegistry, J as envOutRefusal, Oe as episodeKeyOf, C as evaluateBillingEntitlement, u as evaluateEntitlement, Ne as flushWindowKey, mt as formEncode, w as graceEndOf, Mt as inspectBillingAccountCustody, Nt as inspectBillingCustody, E as isProductionBoot, ge as isStaleStatusEvent, N as isTerminalSubscriptionWrite, wt as memoryBillingCloseStore, bt as memoryCheckoutOperationStore, T as memoryDunningNoticeStore, p as memoryStores, st as mergeEnvFile, Ie as mockProvider, Re as mountBillingWebhook, Et as normalizeStripeEvent, Y as openFindings, e as paidInvoiceCoverageInTransaction, ct as parseProvisionArgs, me as periodKey, K as portalParams, lt as provisionStripeCatalog, ht as redactStripeKeys, ne as requireEntitled, d as requireEntitlement, ke as resolveDunningConfig, Le as resolveProvider, ut as resolveProvisionKey, dt as runStripeProvision, m as selectCurrentSubscription, q as sellingReadiness, Dt as stripeProvider, gt as stripeRest };
|