@moonbase.sh/storefront-api 3.10.0 → 3.11.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/dist/index.cjs +68 -1
- package/dist/index.d.cts +994 -2
- package/dist/index.d.ts +994 -2
- package/dist/index.js +68 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1295,7 +1295,7 @@ var ProductEndpoints = class {
|
|
|
1295
1295
|
var import_zod15 = require("zod");
|
|
1296
1296
|
|
|
1297
1297
|
// package.json
|
|
1298
|
-
var version = "3.
|
|
1298
|
+
var version = "3.11.0";
|
|
1299
1299
|
|
|
1300
1300
|
// src/utils/client.ts
|
|
1301
1301
|
function buildClientHeader(sdk) {
|
|
@@ -1451,6 +1451,10 @@ var MoonbaseApi = class {
|
|
|
1451
1451
|
var schemas_exports8 = {};
|
|
1452
1452
|
__export(schemas_exports8, {
|
|
1453
1453
|
milestoneProgressSchema: () => milestoneProgressSchema,
|
|
1454
|
+
pendingPlanChangeSchema: () => pendingPlanChangeSchema,
|
|
1455
|
+
pricingOptionSchema: () => pricingOptionSchema,
|
|
1456
|
+
subscriptionPlanOptionSchema: () => subscriptionPlanOptionSchema,
|
|
1457
|
+
subscriptionPlanOptionsSchema: () => subscriptionPlanOptionsSchema,
|
|
1454
1458
|
subscriptionSchema: () => subscriptionSchema
|
|
1455
1459
|
});
|
|
1456
1460
|
var import_zod14 = require("zod");
|
|
@@ -1660,6 +1664,33 @@ var milestoneProgressSchema = import_zod14.z.object({
|
|
|
1660
1664
|
toNormalizedCycleNumber: import_zod14.z.number(),
|
|
1661
1665
|
events: import_zod14.z.record(import_zod14.z.coerce.number(), milestoneProgressEventSchema.array())
|
|
1662
1666
|
});
|
|
1667
|
+
var pricingOptionSchema = import_zod14.z.object({
|
|
1668
|
+
id: import_zod14.z.string(),
|
|
1669
|
+
name: import_zod14.z.string(),
|
|
1670
|
+
cycleLength: import_zod14.z.nativeEnum(CycleLength)
|
|
1671
|
+
});
|
|
1672
|
+
var pendingPlanChangeSchema = import_zod14.z.object({
|
|
1673
|
+
option: pricingOptionSchema,
|
|
1674
|
+
// The renewal that starts the new plan and charges `nextTotal`.
|
|
1675
|
+
takesEffectAt: import_zod14.z.coerce.date(),
|
|
1676
|
+
nextTotal: orderTotalSchema,
|
|
1677
|
+
// Whether everything the subscription gets off now (discount, offer, coupons) still applies on the new plan.
|
|
1678
|
+
keepsDiscount: import_zod14.z.boolean(),
|
|
1679
|
+
scheduledAt: import_zod14.z.coerce.date()
|
|
1680
|
+
});
|
|
1681
|
+
var subscriptionPlanOptionSchema = import_zod14.z.object({
|
|
1682
|
+
option: pricingOptionSchema,
|
|
1683
|
+
// What the next renewal charges on this plan. For the plan it is on, its normal renewal.
|
|
1684
|
+
nextTotal: orderTotalSchema,
|
|
1685
|
+
takesEffectAt: import_zod14.z.coerce.date(),
|
|
1686
|
+
keepsDiscount: import_zod14.z.boolean(),
|
|
1687
|
+
current: import_zod14.z.boolean(),
|
|
1688
|
+
scheduled: import_zod14.z.boolean()
|
|
1689
|
+
});
|
|
1690
|
+
var subscriptionPlanOptionsSchema = import_zod14.z.object({
|
|
1691
|
+
unavailable: import_zod14.z.string().nullish(),
|
|
1692
|
+
plans: subscriptionPlanOptionSchema.array()
|
|
1693
|
+
});
|
|
1663
1694
|
var subscriptionSchema = import_zod14.z.object({
|
|
1664
1695
|
id: import_zod14.z.string(),
|
|
1665
1696
|
status: import_zod14.z.nativeEnum(SubscriptionStatus),
|
|
@@ -1674,6 +1705,10 @@ var subscriptionSchema = import_zod14.z.object({
|
|
|
1674
1705
|
paymentMethod: import_zod14.z.string().optional(),
|
|
1675
1706
|
milestoneProgress: milestoneProgressSchema.nullish(),
|
|
1676
1707
|
embeddedUpdatePaymentUrl: import_zod14.z.string().optional(),
|
|
1708
|
+
// Older backends send neither, and one this version can't read is dropped rather than failing
|
|
1709
|
+
// the whole subscription.
|
|
1710
|
+
pricingOption: pricingOptionSchema.nullish().catch(void 0),
|
|
1711
|
+
pendingChange: pendingPlanChangeSchema.nullish().catch(void 0),
|
|
1677
1712
|
content: import_zod14.z.discriminatedUnion("type", [
|
|
1678
1713
|
import_zod14.z.object({
|
|
1679
1714
|
type: import_zod14.z.literal("Product"),
|
|
@@ -1717,6 +1752,38 @@ var SubscriptionEndpoints = class {
|
|
|
1717
1752
|
});
|
|
1718
1753
|
return response.data;
|
|
1719
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* The plans the subscription can switch to when its current period ends, each with what the
|
|
1757
|
+
* next renewal would charge on it. The plan it is on comes first. When it can't switch,
|
|
1758
|
+
* `unavailable` says why, ready to show to the customer.
|
|
1759
|
+
*/
|
|
1760
|
+
async getPlanOptions(subscriptionId) {
|
|
1761
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-options`, subscriptionPlanOptionsSchema);
|
|
1762
|
+
return response.data;
|
|
1763
|
+
}
|
|
1764
|
+
/**
|
|
1765
|
+
* Switches the subscription to another plan when its current period ends. Nothing is charged
|
|
1766
|
+
* now: the next renewal charges the new plan and starts its cycle. Until then the customer can
|
|
1767
|
+
* switch again, and passing the plan it is on keeps that plan. Returns the updated subscription,
|
|
1768
|
+
* with the switch in `pendingChange`.
|
|
1769
|
+
*/
|
|
1770
|
+
async changePlan(subscriptionId, variationId) {
|
|
1771
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
|
|
1772
|
+
method: "POST",
|
|
1773
|
+
body: { variationId }
|
|
1774
|
+
});
|
|
1775
|
+
return response.data;
|
|
1776
|
+
}
|
|
1777
|
+
/**
|
|
1778
|
+
* Keeps the subscription on its current plan, dropping a switch scheduled with `changePlan`.
|
|
1779
|
+
* Returns the updated subscription.
|
|
1780
|
+
*/
|
|
1781
|
+
async cancelPlanChange(subscriptionId) {
|
|
1782
|
+
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/plan-change`, subscriptionSchema, {
|
|
1783
|
+
method: "DELETE"
|
|
1784
|
+
});
|
|
1785
|
+
return response.data;
|
|
1786
|
+
}
|
|
1720
1787
|
async renew(subscriptionId, returnUrl, embedded) {
|
|
1721
1788
|
const response = await this.api.authenticatedFetch(`/api/customer/inventory/subscriptions/${subscriptionId}/renew?redirect=false&return=${returnUrl}&embedded=${embedded ? "true" : "false"}`, import_zod15.z.object({
|
|
1722
1789
|
location: import_zod15.z.string()
|