@zuplo/zudoku-plugin-monetization 0.0.45 → 0.0.46
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.mjs +19 -9
- package/dist/pricing-ui.d.mts +7 -7
- package/package.json +7 -6
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { D as formatDurationAdjective, E as formatDuration, O as formatDurationInterval, T as formatPrice, _ as formatPlanPrice, a as planHasDefaultTaxBehavior, b as sameEntitlementSet, c as getPlanPriceSchedule, d as PlanEntitlements, f as PlanPhaseHeader, l as PlanPriceTag, o as subscriptionTaxLegendSentence, p as EntitlementList, r as isCustomPlan, t as PricingTable, u as PlanPriceSchedule, w as formatMinorCurrencyAmount, x as categorizeRateCards, y as comparePlanEntitlements } from "./PricingTable-WkG2n7V-.mjs";
|
|
2
2
|
import { cn, createPlugin, joinUrl, throwIfProblemJson } from "zudoku";
|
|
3
3
|
import { AlertTriangleIcon, ArrowDownIcon, ArrowLeftRightIcon, ArrowUpIcon, BadgePercentIcon, CalendarIcon, CheckCheckIcon, CheckIcon, ChevronDownIcon, CircleSlashIcon, ClockIcon, CreditCardIcon, Grid2x2XIcon, HistoryIcon, InfoIcon, Loader2Icon, LockIcon, MoreVerticalIcon, RefreshCcw, RefreshCwIcon, Settings, ShieldIcon, StarsIcon, Trash2Icon, XIcon } from "zudoku/icons";
|
|
4
|
-
import { Link, Outlet, useLocation, useNavigate, useSearchParams } from "zudoku/router";
|
|
4
|
+
import { Link, Navigate, Outlet, useLocation, useNavigate, useSearchParams } from "zudoku/router";
|
|
5
5
|
import { useAuth, useZudoku } from "zudoku/hooks";
|
|
6
6
|
import { QueryClient, QueryClientProvider, queryOptions, useMutation, useQuery, useQueryClient, useSuspenseQuery } from "zudoku/react-query";
|
|
7
7
|
import { Button, ClientOnly, Head, Heading, Link as Link$1, Slot } from "zudoku/components";
|
|
@@ -98,7 +98,8 @@ const queryClient = new QueryClient({ defaultOptions: {
|
|
|
98
98
|
...q.meta?.request?.headers
|
|
99
99
|
}
|
|
100
100
|
});
|
|
101
|
-
const
|
|
101
|
+
const queryContext = q.meta?.context;
|
|
102
|
+
const response = await fetch(queryContext?.getAuthState().isAuthenticated ? await queryContext.signRequest(request) : request);
|
|
102
103
|
await throwIfProblemJson(response);
|
|
103
104
|
if (!response.ok) throw new Error("Failed to fetch request");
|
|
104
105
|
return response.json();
|
|
@@ -128,7 +129,8 @@ const queryClient = new QueryClient({ defaultOptions: {
|
|
|
128
129
|
...init.headers
|
|
129
130
|
}
|
|
130
131
|
});
|
|
131
|
-
const
|
|
132
|
+
const mutationContext = m.meta?.context;
|
|
133
|
+
const response = await fetch(mutationContext?.getAuthState().isAuthenticated ? await mutationContext.signRequest(request) : request);
|
|
132
134
|
await throwIfProblemJson(response);
|
|
133
135
|
if (!response.ok) {
|
|
134
136
|
const errorText = await response.text();
|
|
@@ -451,17 +453,13 @@ const useUrlUtils = () => {
|
|
|
451
453
|
};
|
|
452
454
|
//#endregion
|
|
453
455
|
//#region src/pages/CheckoutPage.tsx
|
|
454
|
-
const
|
|
455
|
-
const [searchParams] = useSearchParams();
|
|
456
|
-
const planId = searchParams.get("planId");
|
|
456
|
+
const CheckoutRedirect = ({ planId }) => {
|
|
457
457
|
const zudoku = useZudoku();
|
|
458
458
|
const auth = useAuth();
|
|
459
459
|
const { generateUrl } = useUrlUtils();
|
|
460
|
-
const deploymentName = useDeploymentName();
|
|
461
|
-
if (!planId) throw new Error(`missing planId in URL`);
|
|
462
460
|
const checkoutLink = useQuery({
|
|
463
461
|
queryKey: [
|
|
464
|
-
`/v3/zudoku-metering/${
|
|
462
|
+
`/v3/zudoku-metering/${useDeploymentName()}/stripe/checkout`,
|
|
465
463
|
planId,
|
|
466
464
|
auth.profile?.sub
|
|
467
465
|
],
|
|
@@ -499,6 +497,15 @@ const CheckoutPage = () => {
|
|
|
499
497
|
})
|
|
500
498
|
});
|
|
501
499
|
};
|
|
500
|
+
const CheckoutPage = () => {
|
|
501
|
+
const [searchParams] = useSearchParams();
|
|
502
|
+
const planId = searchParams.get("planId");
|
|
503
|
+
if (!planId) return /* @__PURE__ */ jsx(Navigate, {
|
|
504
|
+
to: "/pricing",
|
|
505
|
+
replace: true
|
|
506
|
+
});
|
|
507
|
+
return /* @__PURE__ */ jsx(CheckoutRedirect, { planId });
|
|
508
|
+
};
|
|
502
509
|
//#endregion
|
|
503
510
|
//#region src/pages/ManagePaymentPage.tsx
|
|
504
511
|
const ManagePaymentPage = () => {
|
|
@@ -2745,6 +2752,9 @@ const zuploMonetizationPlugin = createPlugin((options = {}) => ({
|
|
|
2745
2752
|
queryClient.prefetchQuery(pricingPageQuery(context));
|
|
2746
2753
|
if (context.getAuthState().isAuthenticated) queryClient.prefetchQuery(subscriptionsQuery(context));
|
|
2747
2754
|
},
|
|
2755
|
+
events: { auth: ({ prev, next }) => {
|
|
2756
|
+
if (prev.isAuthenticated && !next.isAuthenticated) queryClient.removeQueries();
|
|
2757
|
+
} },
|
|
2748
2758
|
getIdentities: async (context) => {
|
|
2749
2759
|
if (!context.getAuthState().isAuthenticated) return [];
|
|
2750
2760
|
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() ? [] : {
|
package/dist/pricing-ui.d.mts
CHANGED
|
@@ -139,7 +139,7 @@ declare const FeatureItem: ({
|
|
|
139
139
|
}: {
|
|
140
140
|
feature: Feature;
|
|
141
141
|
className?: string;
|
|
142
|
-
}) => import("react
|
|
142
|
+
}) => import("react").JSX.Element;
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region src/pricing-ui/PlanEntitlements.d.ts
|
|
145
145
|
/**
|
|
@@ -161,7 +161,7 @@ declare const PlanEntitlements: ({
|
|
|
161
161
|
billingCadence?: string;
|
|
162
162
|
units?: Record<string, string>;
|
|
163
163
|
itemClassName?: string;
|
|
164
|
-
}) => import("react
|
|
164
|
+
}) => import("react").JSX.Element;
|
|
165
165
|
//#endregion
|
|
166
166
|
//#region src/utils/formatPlanPrice.d.ts
|
|
167
167
|
type PlanPriceLabel = {
|
|
@@ -225,7 +225,7 @@ declare const PlanPriceSchedule: ({
|
|
|
225
225
|
billingCadence?: string;
|
|
226
226
|
size?: "sm" | "lg";
|
|
227
227
|
className?: string;
|
|
228
|
-
}) => import("react
|
|
228
|
+
}) => import("react").JSX.Element;
|
|
229
229
|
//#endregion
|
|
230
230
|
//#region src/pricing-ui/PlanPriceTag.d.ts
|
|
231
231
|
/**
|
|
@@ -253,7 +253,7 @@ declare const PlanPriceTag: ({
|
|
|
253
253
|
billingCadence?: string;
|
|
254
254
|
description?: boolean;
|
|
255
255
|
size?: "inline" | "lg";
|
|
256
|
-
}) => import("react
|
|
256
|
+
}) => import("react").JSX.Element;
|
|
257
257
|
//#endregion
|
|
258
258
|
//#region src/pricing-ui/PricingCard.d.ts
|
|
259
259
|
type PricingCardProps = {
|
|
@@ -269,7 +269,7 @@ declare const PricingCard: ({
|
|
|
269
269
|
units,
|
|
270
270
|
action,
|
|
271
271
|
className
|
|
272
|
-
}: PricingCardProps) => import("react
|
|
272
|
+
}: PricingCardProps) => import("react").JSX.Element | null;
|
|
273
273
|
//#endregion
|
|
274
274
|
//#region src/pricing-ui/PricingTable.d.ts
|
|
275
275
|
type PricingTableProps = {
|
|
@@ -319,7 +319,7 @@ declare const PricingTable: ({
|
|
|
319
319
|
showTaxLegend,
|
|
320
320
|
className,
|
|
321
321
|
cardClassName
|
|
322
|
-
}: PricingTableProps) => import("react
|
|
322
|
+
}: PricingTableProps) => import("react").JSX.Element;
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region src/pricing-ui/QuotaItem.d.ts
|
|
325
325
|
declare const QuotaItem: ({
|
|
@@ -328,7 +328,7 @@ declare const QuotaItem: ({
|
|
|
328
328
|
}: {
|
|
329
329
|
quota: Quota;
|
|
330
330
|
className?: string;
|
|
331
|
-
}) => import("react
|
|
331
|
+
}) => import("react").JSX.Element;
|
|
332
332
|
//#endregion
|
|
333
333
|
//#region src/utils/categorizeRateCards.d.ts
|
|
334
334
|
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.46",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -31,13 +31,14 @@
|
|
|
31
31
|
"@testing-library/dom": "10.4.1",
|
|
32
32
|
"@testing-library/jest-dom": "6.9.1",
|
|
33
33
|
"@testing-library/react": "16.3.2",
|
|
34
|
-
"@types/react": "19.2.
|
|
34
|
+
"@types/react": "19.2.17",
|
|
35
35
|
"@types/react-dom": "19.2.3",
|
|
36
|
+
"@typescript/native-preview": "7.0.0-dev.20260624.1",
|
|
36
37
|
"happy-dom": "20.10.2",
|
|
37
|
-
"react": "19.2.
|
|
38
|
-
"react-dom": "19.2.
|
|
38
|
+
"react": "19.2.7",
|
|
39
|
+
"react-dom": "19.2.7",
|
|
39
40
|
"tsdown": "0.22.0",
|
|
40
|
-
"zudoku": "0.
|
|
41
|
+
"zudoku": "0.82.3"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|
|
43
44
|
"react": ">=19.2.0",
|
|
@@ -52,6 +53,6 @@
|
|
|
52
53
|
"scripts": {
|
|
53
54
|
"build": "tsdown",
|
|
54
55
|
"dev": "tsdown --watch",
|
|
55
|
-
"typecheck": "
|
|
56
|
+
"typecheck": "tsgo --project tsconfig.json"
|
|
56
57
|
}
|
|
57
58
|
}
|