@base44-preview/sdk 0.8.31-pr.178.837440f → 0.8.31-pr.178.8fbfe3b
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/dist/modules/accounts.js
CHANGED
|
@@ -75,23 +75,8 @@ export function createAccountsModule(axios, appId) {
|
|
|
75
75
|
return axios.get(`${base}/${id}/billing/plans`);
|
|
76
76
|
},
|
|
77
77
|
async getSubscription(accountId) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// resolves the active account id — fetch it once and reuse it.
|
|
81
|
-
const mine = await axios.get(`${base}/me`);
|
|
82
|
-
const id = (_b = (_a = accountId !== null && accountId !== void 0 ? accountId : getStoredActiveAccountId(appId)) !== null && _a !== void 0 ? _a : mine.active_account_id) !== null && _b !== void 0 ? _b : undefined;
|
|
83
|
-
if (!id) {
|
|
84
|
-
throw new Error("No active account: pass an accountId, or have the user select or create an account first.");
|
|
85
|
-
}
|
|
86
|
-
const plans = await axios.get(`${base}/${id}/billing/plans`);
|
|
87
|
-
const account = (_c = mine.accounts.find((a) => a.id === id)) !== null && _c !== void 0 ? _c : null;
|
|
88
|
-
const planId = (_d = account === null || account === void 0 ? void 0 : account.plan_id) !== null && _d !== void 0 ? _d : null;
|
|
89
|
-
return {
|
|
90
|
-
account_id: id,
|
|
91
|
-
plan_id: planId,
|
|
92
|
-
billing_status: (_e = account === null || account === void 0 ? void 0 : account.billing_status) !== null && _e !== void 0 ? _e : "none",
|
|
93
|
-
plan: planId ? (_f = plans.find((p) => p.id === planId)) !== null && _f !== void 0 ? _f : null : null,
|
|
94
|
-
};
|
|
78
|
+
const id = await resolveAccountId(accountId);
|
|
79
|
+
return axios.get(`${base}/${id}/billing/subscription`);
|
|
95
80
|
},
|
|
96
81
|
async startCheckout(accountIdOrParams, maybeParams) {
|
|
97
82
|
const explicitId = typeof accountIdOrParams === "string" ? accountIdOrParams : undefined;
|
|
@@ -68,8 +68,18 @@ export interface AccountSubscription {
|
|
|
68
68
|
plan_id: string | null;
|
|
69
69
|
/** Lifecycle status: "none" | "active" | "past_due" | "canceled". */
|
|
70
70
|
billing_status: string;
|
|
71
|
-
/** The
|
|
71
|
+
/** The payment rail backing the subscription, or `null`. */
|
|
72
|
+
billing_provider: string | null;
|
|
73
|
+
/** The current plan, or `null` when the account has no subscription. */
|
|
72
74
|
plan: AccountPlan | null;
|
|
75
|
+
/** When the current paid period ends / renews (ISO 8601), or `null`. */
|
|
76
|
+
current_period_end: string | null;
|
|
77
|
+
/** True when the subscription will not renew at period end. */
|
|
78
|
+
cancel_at_period_end: boolean;
|
|
79
|
+
/** When the subscription was canceled (ISO 8601), or `null`. */
|
|
80
|
+
canceled_at: string | null;
|
|
81
|
+
/** When the subscription started (ISO 8601), or `null`. */
|
|
82
|
+
started_at: string | null;
|
|
73
83
|
}
|
|
74
84
|
/**
|
|
75
85
|
* The accounts module — manage multi-tenancy ("Accounts") from inside the app.
|