@zuplo/zudoku-plugin-monetization 0.0.37 → 0.0.39
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.d.mts +1 -3
- package/dist/index.mjs +75 -128
- package/dist/pricing-ui.d.mts +5 -6
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import * as _$zudoku from "zudoku";
|
|
2
|
-
|
|
3
1
|
//#region src/MonetizationContext.d.ts
|
|
4
2
|
interface MonetizationConfig {
|
|
5
3
|
pricing?: {
|
|
@@ -11,6 +9,6 @@ interface MonetizationConfig {
|
|
|
11
9
|
}
|
|
12
10
|
//#endregion
|
|
13
11
|
//#region src/ZuploMonetizationPlugin.d.ts
|
|
14
|
-
declare const zuploMonetizationPlugin: (options?: MonetizationConfig | undefined) =>
|
|
12
|
+
declare const zuploMonetizationPlugin: (options?: MonetizationConfig | undefined) => import("zudoku").ZudokuPlugin;
|
|
15
13
|
//#endregion
|
|
16
14
|
export { zuploMonetizationPlugin };
|
package/dist/index.mjs
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { _ as formatDuration, a as subscriptionTaxLegendSentence, c as getPriceFromPlan, f as categorizeRateCards, g as formatPrice, h as formatMinorCurrencyAmount, i as planHasDefaultTaxBehavior, l as PlanEntitlements, m as formatStaticEntitlementConfig, p as formatTieredPriceBreakdown, t as PricingTable, v as formatDurationAdjective, y as formatDurationInterval } from "./PricingTable-Dsbd3E2Q.mjs";
|
|
2
|
-
import { Suspense, createContext, use, useEffect, useMemo, useState } from "react";
|
|
3
2
|
import { cn, createPlugin, joinUrl, throwIfProblemJson } from "zudoku";
|
|
4
3
|
import { AlertTriangleIcon, ArrowDownIcon, ArrowLeftRightIcon, ArrowUpIcon, CalendarIcon, CheckCheckIcon, CheckIcon, CircleSlashIcon, ClockIcon, CreditCardIcon, Grid2x2XIcon, InfoIcon, Loader2Icon, LockIcon, MoreVerticalIcon, RefreshCcw, RefreshCwIcon, Settings, ShieldIcon, StarsIcon, Trash2Icon, XIcon } from "zudoku/icons";
|
|
5
4
|
import { Button, ClientOnly, Head, Heading, Link, Slot } from "zudoku/components";
|
|
6
5
|
import { useAuth, useZudoku } from "zudoku/hooks";
|
|
7
|
-
import { QueryClient, QueryClientProvider, useMutation, useQuery, useQueryClient, useSuspenseQuery } from "zudoku/react-query";
|
|
6
|
+
import { QueryClient, QueryClientProvider, queryOptions, useMutation, useQuery, useQueryClient, useSuspenseQuery } from "zudoku/react-query";
|
|
8
7
|
import { Link as Link$1, Outlet, useLocation, useNavigate, useSearchParams } from "zudoku/router";
|
|
9
8
|
import { Alert, AlertAction, AlertDescription, AlertTitle } from "zudoku/ui/Alert";
|
|
10
9
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "zudoku/ui/Card";
|
|
11
10
|
import { Separator } from "zudoku/ui/Separator";
|
|
11
|
+
import { createContext, use, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { Button as Button$1 } from "zudoku/ui/Button";
|
|
14
|
-
import { Skeleton } from "zudoku/ui/Skeleton";
|
|
15
14
|
import { DismissibleAlert, DismissibleAlertAction } from "zudoku/ui/DismissibleAlert";
|
|
16
15
|
import { ActionButton } from "zudoku/ui/ActionButton";
|
|
17
16
|
import { Item, ItemContent, ItemDescription, ItemMedia, ItemTitle } from "zudoku/ui/Item";
|
|
@@ -443,26 +442,34 @@ const ManagePaymentPage = () => {
|
|
|
443
442
|
});
|
|
444
443
|
};
|
|
445
444
|
//#endregion
|
|
445
|
+
//#region src/queries.ts
|
|
446
|
+
const getDeploymentName = (context) => {
|
|
447
|
+
const deploymentName = context.env.ZUPLO_PUBLIC_DEPLOYMENT_NAME;
|
|
448
|
+
if (!deploymentName) throw new Error("ZUPLO_PUBLIC_DEPLOYMENT_NAME is not set");
|
|
449
|
+
return deploymentName;
|
|
450
|
+
};
|
|
451
|
+
const pricingPageQuery = (context) => queryOptions({
|
|
452
|
+
queryKey: [`/v3/zudoku-metering/${getDeploymentName(context)}/pricing-page`],
|
|
453
|
+
meta: { context: context.getAuthState().isAuthenticated ? context : void 0 }
|
|
454
|
+
});
|
|
455
|
+
const subscriptionsQuery = (context) => queryOptions({
|
|
456
|
+
queryKey: [`/v3/zudoku-metering/${getDeploymentName(context)}/subscriptions`],
|
|
457
|
+
meta: { context }
|
|
458
|
+
});
|
|
459
|
+
//#endregion
|
|
446
460
|
//#region src/hooks/usePlans.ts
|
|
447
461
|
const usePlans = () => {
|
|
448
|
-
|
|
449
|
-
const auth = useAuth();
|
|
450
|
-
return useSuspenseQuery({
|
|
451
|
-
queryKey: [`/v3/zudoku-metering/${useDeploymentName()}/pricing-page`],
|
|
452
|
-
meta: { context: auth.isAuthenticated ? zudoku : void 0 }
|
|
453
|
-
});
|
|
462
|
+
return useSuspenseQuery(pricingPageQuery(useZudoku()));
|
|
454
463
|
};
|
|
455
464
|
//#endregion
|
|
456
465
|
//#region src/pages/PricingPage.tsx
|
|
457
466
|
const PricingPage = () => {
|
|
458
467
|
const { pricing } = useMonetizationConfig();
|
|
459
468
|
const zudoku = useZudoku();
|
|
460
|
-
const deploymentName = useDeploymentName();
|
|
461
469
|
const auth = useAuth();
|
|
462
470
|
const { data: pricingTable } = usePlans();
|
|
463
471
|
const { data: subscriptions = { items: [] } } = useQuery({
|
|
464
|
-
|
|
465
|
-
queryKey: [`/v3/zudoku-metering/${deploymentName}/subscriptions`],
|
|
472
|
+
...subscriptionsQuery(zudoku),
|
|
466
473
|
enabled: auth.isAuthenticated
|
|
467
474
|
});
|
|
468
475
|
const isSubscribed = subscriptions.items.some((subscription) => ["active", "canceled"].includes(subscription.status));
|
|
@@ -510,33 +517,6 @@ const PricingPage = () => {
|
|
|
510
517
|
});
|
|
511
518
|
};
|
|
512
519
|
//#endregion
|
|
513
|
-
//#region src/pages/PricingPageSkeleton.tsx
|
|
514
|
-
const PricingPageSkeleton = () => /* @__PURE__ */ jsxs("div", {
|
|
515
|
-
className: "w-full px-4 pt-(--padding-content-top) pb-(--padding-content-bottom)",
|
|
516
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
517
|
-
className: "text-center space-y-4 mb-12",
|
|
518
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-48 mx-auto" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-96 mx-auto" })]
|
|
519
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
520
|
-
className: "w-full grid grid-cols-1 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))] justify-center gap-2",
|
|
521
|
-
children: [
|
|
522
|
-
1,
|
|
523
|
-
2,
|
|
524
|
-
3
|
|
525
|
-
].map((i) => /* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsxs(CardHeader, {
|
|
526
|
-
className: "space-y-3",
|
|
527
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-6 w-24" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-32" })]
|
|
528
|
-
}), /* @__PURE__ */ jsxs(CardContent, {
|
|
529
|
-
className: "space-y-3",
|
|
530
|
-
children: [
|
|
531
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }),
|
|
532
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-full" }),
|
|
533
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-3/4" }),
|
|
534
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-10 w-full mt-4" })
|
|
535
|
-
]
|
|
536
|
-
})] }, i))
|
|
537
|
-
})]
|
|
538
|
-
});
|
|
539
|
-
//#endregion
|
|
540
520
|
//#region src/pages/SubscriptionChangeConfirmPage.tsx
|
|
541
521
|
const SubscriptionChangeConfirmPage = () => {
|
|
542
522
|
const [search] = useSearchParams();
|
|
@@ -695,11 +675,9 @@ const SubscriptionChangeConfirmPage = () => {
|
|
|
695
675
|
};
|
|
696
676
|
//#endregion
|
|
697
677
|
//#region src/hooks/useSubscriptions.ts
|
|
698
|
-
const useSubscriptions = (
|
|
699
|
-
const zudoku = useZudoku();
|
|
678
|
+
const useSubscriptions = () => {
|
|
700
679
|
return useSuspenseQuery({
|
|
701
|
-
|
|
702
|
-
meta: { context: zudoku },
|
|
680
|
+
...subscriptionsQuery(useZudoku()),
|
|
703
681
|
select: (data) => ({
|
|
704
682
|
...data,
|
|
705
683
|
items: [...data.items].sort((a, b) => {
|
|
@@ -1346,6 +1324,7 @@ const comparePlans = (currentPlan, targetPlan, currentIndex, targetIndex, units)
|
|
|
1346
1324
|
return {
|
|
1347
1325
|
plan: targetPlan,
|
|
1348
1326
|
isUpgrade,
|
|
1327
|
+
isNewerVersion: false,
|
|
1349
1328
|
quotaChanges,
|
|
1350
1329
|
featureChanges
|
|
1351
1330
|
};
|
|
@@ -1356,6 +1335,14 @@ const ChangeIndicator = ({ change }) => {
|
|
|
1356
1335
|
return /* @__PURE__ */ jsx(CheckIcon, { className: "w-4 h-4 text-green-600 shrink-0" });
|
|
1357
1336
|
};
|
|
1358
1337
|
const isPrivatePlan = (plan) => plan.metadata?.zuplo_private_plan === "true";
|
|
1338
|
+
const planVersion = (plan) => plan.version ?? 1;
|
|
1339
|
+
const isNewerPlanVersion = (subscribedPlan, target) => target.key === subscribedPlan.key && planVersion(target) > planVersion(subscribedPlan);
|
|
1340
|
+
/** Baseline for comparisons: catalog entry when present, else subscription plan. */
|
|
1341
|
+
const resolvePlanForComparison = (subscribedPlan, catalogItems) => catalogItems?.find((p) => p.id === subscribedPlan.id) ?? subscribedPlan;
|
|
1342
|
+
const resolveIsUpgrade = ({ target, targetIndex, subscribedPlan, currentIndex }) => {
|
|
1343
|
+
if (target.key === subscribedPlan.key) return planVersion(target) > planVersion(subscribedPlan);
|
|
1344
|
+
return targetIndex > currentIndex;
|
|
1345
|
+
};
|
|
1359
1346
|
const modeLabelMap = {
|
|
1360
1347
|
upgrade: "Upgrade",
|
|
1361
1348
|
downgrade: "Downgrade",
|
|
@@ -1376,10 +1363,17 @@ const PlanComparisonItem = ({ comparison, subscriptionId, mode, onRequestChange,
|
|
|
1376
1363
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1377
1364
|
className: "flex items-center justify-between mb-3",
|
|
1378
1365
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
1379
|
-
className: "flex items-baseline gap-2",
|
|
1380
|
-
children: [/* @__PURE__ */
|
|
1381
|
-
className: "
|
|
1382
|
-
children:
|
|
1366
|
+
className: "flex items-baseline gap-2 flex-wrap",
|
|
1367
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
1368
|
+
className: "flex items-center gap-2",
|
|
1369
|
+
children: [/* @__PURE__ */ jsx("h4", {
|
|
1370
|
+
className: "font-semibold text-foreground",
|
|
1371
|
+
children: comparison.plan.name
|
|
1372
|
+
}), comparison.isNewerVersion && /* @__PURE__ */ jsx(Badge, {
|
|
1373
|
+
variant: "outline",
|
|
1374
|
+
className: "rounded-full border-primary/30 bg-primary/10 text-primary font-medium",
|
|
1375
|
+
children: "New version"
|
|
1376
|
+
})]
|
|
1383
1377
|
}), isCustom ? /* @__PURE__ */ jsx("span", {
|
|
1384
1378
|
className: "text-primary font-medium",
|
|
1385
1379
|
children: "Custom"
|
|
@@ -1544,35 +1538,35 @@ const SwitchPlanModal = ({ subscription, children }) => {
|
|
|
1544
1538
|
window.location.href = data.url;
|
|
1545
1539
|
}
|
|
1546
1540
|
});
|
|
1547
|
-
const
|
|
1541
|
+
const subscribedPlan = subscription.plan;
|
|
1548
1542
|
const { upgrades, downgrades, privatePlans } = useMemo(() => {
|
|
1549
|
-
|
|
1543
|
+
const catalogItems = plansData?.items;
|
|
1544
|
+
if (!catalogItems?.length) return {
|
|
1550
1545
|
upgrades: [],
|
|
1551
1546
|
downgrades: [],
|
|
1552
1547
|
privatePlans: []
|
|
1553
1548
|
};
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
privatePlans: []
|
|
1570
|
-
};
|
|
1571
|
-
}
|
|
1572
|
-
const currentIndex = plansData.items.findIndex((p) => p.id === currentPlan.id);
|
|
1573
|
-
const allComparisons = plansData.items.filter((p) => p.id !== currentPlan.id).map((plan) => {
|
|
1574
|
-
return comparePlans(currentPlan, plan, currentIndex, plansData.items.indexOf(plan), pricing?.units);
|
|
1549
|
+
const planForComparison = resolvePlanForComparison(subscribedPlan, catalogItems);
|
|
1550
|
+
const currentIndex = catalogItems.some((p) => p.id === subscribedPlan.id) ? catalogItems.findIndex((p) => p.id === subscribedPlan.id) : -1;
|
|
1551
|
+
const subscribedIsPrivate = isPrivatePlan(subscribedPlan);
|
|
1552
|
+
const allComparisons = catalogItems.flatMap((plan, targetIndex) => {
|
|
1553
|
+
if (plan.id === subscribedPlan.id) return [];
|
|
1554
|
+
return [{
|
|
1555
|
+
...comparePlans(planForComparison, plan, currentIndex, targetIndex, pricing?.units),
|
|
1556
|
+
isUpgrade: resolveIsUpgrade({
|
|
1557
|
+
target: plan,
|
|
1558
|
+
targetIndex,
|
|
1559
|
+
subscribedPlan,
|
|
1560
|
+
currentIndex
|
|
1561
|
+
}),
|
|
1562
|
+
isNewerVersion: isNewerPlanVersion(subscribedPlan, plan)
|
|
1563
|
+
}];
|
|
1575
1564
|
});
|
|
1565
|
+
if (subscribedIsPrivate) return {
|
|
1566
|
+
upgrades: allComparisons.filter((c) => !isPrivatePlan(c.plan)),
|
|
1567
|
+
downgrades: [],
|
|
1568
|
+
privatePlans: allComparisons.filter((c) => isPrivatePlan(c.plan))
|
|
1569
|
+
};
|
|
1576
1570
|
return {
|
|
1577
1571
|
upgrades: allComparisons.filter((c) => c.isUpgrade && !isPrivatePlan(c.plan)),
|
|
1578
1572
|
downgrades: allComparisons.filter((c) => !c.isUpgrade && !isPrivatePlan(c.plan)),
|
|
@@ -1580,7 +1574,7 @@ const SwitchPlanModal = ({ subscription, children }) => {
|
|
|
1580
1574
|
};
|
|
1581
1575
|
}, [
|
|
1582
1576
|
plansData?.items,
|
|
1583
|
-
|
|
1577
|
+
subscribedPlan,
|
|
1584
1578
|
pricing?.units
|
|
1585
1579
|
]);
|
|
1586
1580
|
return /* @__PURE__ */ jsxs(Dialog, {
|
|
@@ -1611,18 +1605,11 @@ const SwitchPlanModal = ({ subscription, children }) => {
|
|
|
1611
1605
|
children: switchPlanMutation.error.message
|
|
1612
1606
|
})
|
|
1613
1607
|
}),
|
|
1614
|
-
|
|
1615
|
-
variant: "outline",
|
|
1616
|
-
children: /* @__PURE__ */ jsxs(ItemContent, { children: [/* @__PURE__ */ jsx(ItemTitle, { children: "Current Plan" }), /* @__PURE__ */ jsx(ItemDescription, {
|
|
1617
|
-
className: "text-lg font-bold",
|
|
1618
|
-
children: currentPlan.name
|
|
1619
|
-
})] })
|
|
1620
|
-
}),
|
|
1621
|
-
!currentPlan && /* @__PURE__ */ jsx(Item, {
|
|
1608
|
+
/* @__PURE__ */ jsx(Item, {
|
|
1622
1609
|
variant: "outline",
|
|
1623
1610
|
children: /* @__PURE__ */ jsxs(ItemContent, { children: [/* @__PURE__ */ jsx(ItemTitle, { children: "Current Plan" }), /* @__PURE__ */ jsx(ItemDescription, {
|
|
1624
1611
|
className: "text-lg font-bold",
|
|
1625
|
-
children:
|
|
1612
|
+
children: subscribedPlan.name
|
|
1626
1613
|
})] })
|
|
1627
1614
|
}),
|
|
1628
1615
|
upgrades.length > 0 && /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsxs("div", {
|
|
@@ -2316,7 +2303,7 @@ const SubscriptionItem = ({ subscription, isSelected, isExpired }) => {
|
|
|
2316
2303
|
//#region src/pages/SubscriptionsPage.tsx
|
|
2317
2304
|
const SubscriptionsPage = () => {
|
|
2318
2305
|
const deploymentName = useDeploymentName();
|
|
2319
|
-
const { data } = useSubscriptions(
|
|
2306
|
+
const { data } = useSubscriptions();
|
|
2320
2307
|
const [searchParams] = useSearchParams();
|
|
2321
2308
|
const subscriptionId = searchParams.get("subscriptionId");
|
|
2322
2309
|
const subscriptions = data?.items ?? [];
|
|
@@ -2357,39 +2344,6 @@ const SubscriptionsPage = () => {
|
|
|
2357
2344
|
});
|
|
2358
2345
|
};
|
|
2359
2346
|
//#endregion
|
|
2360
|
-
//#region src/pages/SubscriptionsPageSkeleton.tsx
|
|
2361
|
-
const SubscriptionsPageSkeleton = () => /* @__PURE__ */ jsx("div", {
|
|
2362
|
-
className: "w-full pt-(--padding-content-top) pb-(--padding-content-bottom)",
|
|
2363
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
2364
|
-
className: "max-w-4xl space-y-8",
|
|
2365
|
-
children: [
|
|
2366
|
-
/* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-56 mb-2" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-80" })] }),
|
|
2367
|
-
/* @__PURE__ */ jsx("div", {
|
|
2368
|
-
className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-3",
|
|
2369
|
-
children: [1, 2].map((i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-20 rounded-lg" }, i))
|
|
2370
|
-
}),
|
|
2371
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2372
|
-
className: "space-y-4",
|
|
2373
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-16" }), /* @__PURE__ */ jsxs(Card, { children: [/* @__PURE__ */ jsx(CardHeader, { children: /* @__PURE__ */ jsx(Skeleton, { className: "h-5 w-32" }) }), /* @__PURE__ */ jsxs(CardContent, {
|
|
2374
|
-
className: "space-y-2",
|
|
2375
|
-
children: [
|
|
2376
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2377
|
-
className: "flex justify-between",
|
|
2378
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-20" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-4 w-24" })]
|
|
2379
|
-
}),
|
|
2380
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-2 w-full" }),
|
|
2381
|
-
/* @__PURE__ */ jsx(Skeleton, { className: "h-3 w-48" })
|
|
2382
|
-
]
|
|
2383
|
-
})] })]
|
|
2384
|
-
}),
|
|
2385
|
-
/* @__PURE__ */ jsxs("div", {
|
|
2386
|
-
className: "space-y-4",
|
|
2387
|
-
children: [/* @__PURE__ */ jsx(Skeleton, { className: "h-7 w-20" }), /* @__PURE__ */ jsx(Skeleton, { className: "h-12 rounded-lg" })]
|
|
2388
|
-
})
|
|
2389
|
-
]
|
|
2390
|
-
})
|
|
2391
|
-
});
|
|
2392
|
-
//#endregion
|
|
2393
2347
|
//#region src/ZuploMonetizationPlugin.tsx
|
|
2394
2348
|
const PRICING_PATH = "/pricing";
|
|
2395
2349
|
const zuploMonetizationPlugin = createPlugin((options = {}) => ({
|
|
@@ -2400,13 +2354,12 @@ const zuploMonetizationPlugin = createPlugin((options = {}) => ({
|
|
|
2400
2354
|
to: PRICING_PATH
|
|
2401
2355
|
}] }
|
|
2402
2356
|
}),
|
|
2357
|
+
initialize: (context) => {
|
|
2358
|
+
queryClient.prefetchQuery(pricingPageQuery(context));
|
|
2359
|
+
if (context.getAuthState().isAuthenticated) queryClient.prefetchQuery(subscriptionsQuery(context));
|
|
2360
|
+
},
|
|
2403
2361
|
getIdentities: async (context) => {
|
|
2404
|
-
|
|
2405
|
-
if (!deploymentName) throw new Error("ZUPLO_PUBLIC_DEPLOYMENT_NAME is not set");
|
|
2406
|
-
return (await queryClient.fetchQuery({
|
|
2407
|
-
queryKey: [`/v3/zudoku-metering/${deploymentName}/subscriptions`],
|
|
2408
|
-
meta: { context }
|
|
2409
|
-
})).items.flatMap((sub) => sub.status !== "active" ? [] : sub.consumer.apiKeys.flatMap((apiKey) => apiKey.expiresOn && new Date(apiKey.expiresOn) < /* @__PURE__ */ new Date() ? [] : {
|
|
2362
|
+
return (await queryClient.fetchQuery(subscriptionsQuery(context))).items.flatMap((sub) => sub.status !== "active" ? [] : sub.consumer.apiKeys.flatMap((apiKey) => apiKey.expiresOn && new Date(apiKey.expiresOn) < /* @__PURE__ */ new Date() ? [] : {
|
|
2410
2363
|
label: `${sub.name} (****${apiKey.key.slice(-5)})`,
|
|
2411
2364
|
id: apiKey.id,
|
|
2412
2365
|
authorizeRequest: async (request) => {
|
|
@@ -2452,16 +2405,10 @@ const zuploMonetizationPlugin = createPlugin((options = {}) => ({
|
|
|
2452
2405
|
element: /* @__PURE__ */ jsx(ZuploMonetizationWrapper, { options }),
|
|
2453
2406
|
children: [{
|
|
2454
2407
|
path: PRICING_PATH,
|
|
2455
|
-
element: /* @__PURE__ */ jsx(
|
|
2456
|
-
fallback: /* @__PURE__ */ jsx(PricingPageSkeleton, {}),
|
|
2457
|
-
children: /* @__PURE__ */ jsx(PricingPage, {})
|
|
2458
|
-
})
|
|
2408
|
+
element: /* @__PURE__ */ jsx(PricingPage, {})
|
|
2459
2409
|
}, {
|
|
2460
2410
|
path: "/subscriptions",
|
|
2461
|
-
element: /* @__PURE__ */ jsx(
|
|
2462
|
-
fallback: /* @__PURE__ */ jsx(SubscriptionsPageSkeleton, {}),
|
|
2463
|
-
children: /* @__PURE__ */ jsx(SubscriptionsPage, {})
|
|
2464
|
-
})
|
|
2411
|
+
element: /* @__PURE__ */ jsx(SubscriptionsPage, {})
|
|
2465
2412
|
}]
|
|
2466
2413
|
}];
|
|
2467
2414
|
},
|
package/dist/pricing-ui.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
2
|
|
|
4
3
|
//#region src/types/PlanType.d.ts
|
|
5
4
|
type EntitlementTemplate = MeteredEntitlementTemplate | StaticEntitlementTemplate | BooleanEntitlementTemplate;
|
|
@@ -141,7 +140,7 @@ declare const FeatureItem: ({
|
|
|
141
140
|
}: {
|
|
142
141
|
feature: Feature;
|
|
143
142
|
className?: string;
|
|
144
|
-
}) =>
|
|
143
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
145
144
|
//#endregion
|
|
146
145
|
//#region src/pricing-ui/PlanEntitlements.d.ts
|
|
147
146
|
declare const PlanEntitlements: ({
|
|
@@ -156,7 +155,7 @@ declare const PlanEntitlements: ({
|
|
|
156
155
|
billingCadence?: string;
|
|
157
156
|
units?: Record<string, string>;
|
|
158
157
|
itemClassName?: string;
|
|
159
|
-
}) =>
|
|
158
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
160
159
|
//#endregion
|
|
161
160
|
//#region src/pricing-ui/PricingCard.d.ts
|
|
162
161
|
type PricingCardProps = {
|
|
@@ -174,7 +173,7 @@ declare const PricingCard: ({
|
|
|
174
173
|
units,
|
|
175
174
|
action,
|
|
176
175
|
className
|
|
177
|
-
}: PricingCardProps) =>
|
|
176
|
+
}: PricingCardProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
178
177
|
//#endregion
|
|
179
178
|
//#region src/pricing-ui/PricingTable.d.ts
|
|
180
179
|
type PricingTableProps = {
|
|
@@ -226,7 +225,7 @@ declare const PricingTable: ({
|
|
|
226
225
|
showTaxLegend,
|
|
227
226
|
className,
|
|
228
227
|
cardClassName
|
|
229
|
-
}: PricingTableProps) =>
|
|
228
|
+
}: PricingTableProps) => import("react/jsx-runtime").JSX.Element;
|
|
230
229
|
//#endregion
|
|
231
230
|
//#region src/pricing-ui/QuotaItem.d.ts
|
|
232
231
|
declare const QuotaItem: ({
|
|
@@ -235,7 +234,7 @@ declare const QuotaItem: ({
|
|
|
235
234
|
}: {
|
|
236
235
|
quota: Quota;
|
|
237
236
|
className?: string;
|
|
238
|
-
}) =>
|
|
237
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
239
238
|
//#endregion
|
|
240
239
|
//#region src/utils/categorizeRateCards.d.ts
|
|
241
240
|
declare const categorizeRateCards: (rateCards: RateCard[], options?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zuplo/zudoku-plugin-monetization",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"happy-dom": "20.9.0",
|
|
37
37
|
"react": "19.2.5",
|
|
38
38
|
"react-dom": "19.2.5",
|
|
39
|
-
"tsdown": "0.
|
|
40
|
-
"zudoku": "0.
|
|
39
|
+
"tsdown": "0.22.0",
|
|
40
|
+
"zudoku": "0.78.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": ">=19.2.0",
|