@lukoweb/apitogo-plugin-dev-portal-billing 0.2.50 → 0.2.51
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/{AccountPlansPage-DTVIVeRh.mjs → AccountPlansPage-BEDZbyAS.mjs} +1 -1
- package/dist/{CredentialsPage-BOVn3PpF.mjs → CredentialsPage-D9voniJR.mjs} +4 -4
- package/dist/{SubscriptionsPage-29Xs4XvM.mjs → SubscriptionsPage-Bo5D3K1x.mjs} +1 -1
- package/dist/{UsagePage-U27bvmbF.mjs → UsagePage-CK6p01Ut.mjs} +1 -1
- package/dist/{account-links-BUeCO2Du.mjs → account-links-Dg4ugnGW.mjs} +3 -2
- package/dist/{demo-session-B6WAunKV.mjs → demo-session-rN2Gj4lM.mjs} +2 -1
- package/dist/index.d.mts +19 -2
- package/dist/index.mjs +26 -9
- package/dist/{useMySubscriptions-Bdo2HFrP.mjs → useMySubscriptions-B4iV7zFs.mjs} +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c as isActiveSubscription, n as useDevPortalPreviewMode, p as parseManifestPlans, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
2
2
|
import { t as PricingCard } from "./PricingCard-D-owYlf3.mjs";
|
|
3
3
|
import { n as useDevPortalBillingConfig } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
4
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
4
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-B4iV7zFs.mjs";
|
|
5
5
|
import { t as usePlans } from "./usePlans-DVGt2Myv.mjs";
|
|
6
6
|
import { Head } from "@lukoweb/apitogo/components";
|
|
7
7
|
import { CreditCardIcon } from "@lukoweb/apitogo/icons";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as ACCOUNT_PLANS_PATH } from "./paths-ujy9wjVK.mjs";
|
|
2
2
|
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
3
3
|
import { n as useDevPortalBillingConfig } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
4
|
-
import { r as createDemoCredentials } from "./demo-session-
|
|
5
|
-
import { a as useApiKeys, n as apiReferencePath, r as ApiKeysPanel } from "./account-links-
|
|
4
|
+
import { r as createDemoCredentials, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-rN2Gj4lM.mjs";
|
|
5
|
+
import { a as useApiKeys, n as apiReferencePath, r as ApiKeysPanel } from "./account-links-Dg4ugnGW.mjs";
|
|
6
6
|
import { t as ChoosePlanNotice } from "./ChoosePlanNotice-DITJNrh1.mjs";
|
|
7
7
|
import { Head } from "@lukoweb/apitogo/components";
|
|
8
8
|
import { KeyRoundIcon } from "@lukoweb/apitogo/icons";
|
|
@@ -58,10 +58,10 @@ const CredentialsPage = () => {
|
|
|
58
58
|
const isDemoSession = useIsDemoSession();
|
|
59
59
|
const { data: credentials, isLoading, error } = useCredentials();
|
|
60
60
|
const { data: apiKeys, isLoading: keysLoading, error: keysError } = useApiKeys();
|
|
61
|
-
const { gatewayBaseUrl: configuredGatewayBaseUrl, links } = useDevPortalBillingConfig();
|
|
61
|
+
const { gatewayBaseUrl: configuredGatewayBaseUrl, links, keyHeader: configuredKeyHeader } = useDevPortalBillingConfig();
|
|
62
62
|
const apiReferenceLink = apiReferencePath(links);
|
|
63
63
|
const gatewayBaseUrl = credentials?.gatewayBaseUrl?.trim() || apiKeys?.gatewayBaseUrl?.trim() || configuredGatewayBaseUrl?.trim() || zudokuConfig.__meta?.gatewayBaseUrl?.trim() || null;
|
|
64
|
-
const header = apiKeys?.header
|
|
64
|
+
const header = configuredKeyHeader?.trim() || apiKeys?.header || DEMO_GATEWAY_KEY_HEADER;
|
|
65
65
|
const plans = apiKeys?.plans ?? [];
|
|
66
66
|
return /* @__PURE__ */ jsxs("div", {
|
|
67
67
|
className: "mx-auto max-w-screen-lg px-4 pb-16 pt-(--padding-content-top) lg:px-8",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { i as CREDENTIALS_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-ujy9wjVK.mjs";
|
|
2
2
|
import { c as isActiveSubscription, i as formatBillingPeriod, m as parseMonthlyQuotaCalls, o as formatPlanPrice, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
3
3
|
import { n as useDevPortalBillingConfig } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
4
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
4
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-B4iV7zFs.mjs";
|
|
5
5
|
import { t as usePlans } from "./usePlans-DVGt2Myv.mjs";
|
|
6
6
|
import { t as useUsage } from "./useUsage-DOUibue4.mjs";
|
|
7
7
|
import { i as hasPaymentProvider, r as checkoutConfirmingText } from "./billing-state-DjUXQYSr.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as isActiveSubscription, h as parseQuotaPeriodDays, m as parseMonthlyQuotaCalls } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
2
2
|
import "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
3
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
3
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-B4iV7zFs.mjs";
|
|
4
4
|
import { t as usePlans } from "./usePlans-DVGt2Myv.mjs";
|
|
5
5
|
import { t as useUsage } from "./useUsage-DOUibue4.mjs";
|
|
6
6
|
import { Head } from "@lukoweb/apitogo/components";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
2
2
|
import { n as useDevPortalBillingConfig } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
3
|
-
import { n as createDemoApiKeys, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-
|
|
3
|
+
import { n as createDemoApiKeys, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-rN2Gj4lM.mjs";
|
|
4
4
|
import { Spinner } from "@lukoweb/apitogo/components";
|
|
5
5
|
import { KeyRoundIcon, TrashIcon } from "@lukoweb/apitogo/icons";
|
|
6
6
|
import { useState } from "react";
|
|
@@ -115,6 +115,7 @@ function useApiKeys() {
|
|
|
115
115
|
function useCreateApiKey() {
|
|
116
116
|
const apiBaseUrl = useDevPortalApiBaseUrl();
|
|
117
117
|
const queryClient = useQueryClient();
|
|
118
|
+
const { keyHeader } = useDevPortalBillingConfig();
|
|
118
119
|
return useMutation({
|
|
119
120
|
mutationFn: async ({ name, planSku }) => {
|
|
120
121
|
if (!apiBaseUrl) throw new Error("Dev portal API is not configured.");
|
|
@@ -137,7 +138,7 @@ function useCreateApiKey() {
|
|
|
137
138
|
onSuccess: async (created) => {
|
|
138
139
|
rememberPlaygroundKey({
|
|
139
140
|
...created,
|
|
140
|
-
header: queryClient.getQueryData(apiKeysQueryKey(apiBaseUrl))?.header
|
|
141
|
+
header: keyHeader?.trim() || queryClient.getQueryData(apiKeysQueryKey(apiBaseUrl))?.header
|
|
141
142
|
});
|
|
142
143
|
await queryClient.invalidateQueries({ queryKey: apiKeysQueryKey(apiBaseUrl) });
|
|
143
144
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
//#region src/utils/demo-session.ts
|
|
2
2
|
const DEMO_SUBSCRIPTION_KEY = "demo-subscription-key";
|
|
3
|
-
|
|
3
|
+
/** The platform gateway's default key header (API-120). */
|
|
4
|
+
const DEMO_GATEWAY_KEY_HEADER = "X-API-Key";
|
|
4
5
|
const DEMO_MAX_KEYS = 5;
|
|
5
6
|
function resolveDemoPlans(plans) {
|
|
6
7
|
if (plans && plans.length > 0) return plans.map((plan) => ({
|
package/dist/index.d.mts
CHANGED
|
@@ -53,7 +53,12 @@ type DevPortalBillingConfig = {
|
|
|
53
53
|
api?: string;
|
|
54
54
|
}; /** Address of the plans backend; the portal's generated wrapper passes it. The plans request starts from it early. */
|
|
55
55
|
apiBaseUrl?: string; /** Live gateway URL (publish bake or explicit plugin option). */
|
|
56
|
-
gatewayBaseUrl?: string | null;
|
|
56
|
+
gatewayBaseUrl?: string | null;
|
|
57
|
+
/**
|
|
58
|
+
* The header API users send their key in, as the portal build knows it from the gateway config. Wins over the plans
|
|
59
|
+
* backend's answer, which only knows the platform default.
|
|
60
|
+
*/
|
|
61
|
+
keyHeader?: string; /** Local preview plan catalog (from `apitogo.config.json` `plans`). */
|
|
57
62
|
previewPlans?: Array<{
|
|
58
63
|
sku: string;
|
|
59
64
|
displayName: string;
|
|
@@ -236,6 +241,18 @@ declare function useCreateApiKey(): _tanstack_react_query0.UseMutationResult<Dev
|
|
|
236
241
|
}, unknown>;
|
|
237
242
|
declare function useRevokeApiKey(): _tanstack_react_query0.UseMutationResult<void, Error, string, unknown>;
|
|
238
243
|
//#endregion
|
|
244
|
+
//#region src/hooks/useGatewayCall.d.ts
|
|
245
|
+
/** How a caller reaches the API: the gateway address and the header the key goes in. */
|
|
246
|
+
type GatewayCall = {
|
|
247
|
+
/** The gateway's base URL, without a trailing slash; null before the gateway is deployed. */baseUrl: string | null; /** The header API users send their key in. */
|
|
248
|
+
keyHeader: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* The real gateway address and key header, as the portal build knows them (API-120), so a page's code sample works
|
|
252
|
+
* when a visitor pastes it with their key.
|
|
253
|
+
*/
|
|
254
|
+
declare function useGatewayCall(): GatewayCall;
|
|
255
|
+
//#endregion
|
|
239
256
|
//#region src/hooks/usePlans.d.ts
|
|
240
257
|
declare function usePlans(): UseQueryResult<DevPortalPlanCatalog>;
|
|
241
258
|
//#endregion
|
|
@@ -258,4 +275,4 @@ declare const toPlansPreviewItems: (plans: DevPortalPlan[]) => PlansPreviewItem[
|
|
|
258
275
|
*/
|
|
259
276
|
declare const usePlansPreview: () => PlansPreviewItem[];
|
|
260
277
|
//#endregion
|
|
261
|
-
export { ACCOUNT_PLANS_PATH, API_KEY_CAP_REACHED, AccountPlansPage, ApiKeysPanel, CHECKOUT_PATH, CONTACT_SALES_PATH, CREDENTIALS_PATH, type DevPortalPlan, type DevPortalPlanCatalog, OverviewDashboardPage, PRICING_PATH, type PlansPreviewItem, SUBSCRIPTIONS_PATH, USAGE_PATH, devPortalBillingPlugin, toPlansPreviewItems, useApiKeys, useCreateApiKey, usePlans, usePlansPreview, useRevokeApiKey };
|
|
278
|
+
export { ACCOUNT_PLANS_PATH, API_KEY_CAP_REACHED, AccountPlansPage, ApiKeysPanel, CHECKOUT_PATH, CONTACT_SALES_PATH, CREDENTIALS_PATH, type DevPortalPlan, type DevPortalPlanCatalog, type GatewayCall, OverviewDashboardPage, PRICING_PATH, type PlansPreviewItem, SUBSCRIPTIONS_PATH, USAGE_PATH, devPortalBillingPlugin, toPlansPreviewItems, useApiKeys, useCreateApiKey, useGatewayCall, usePlans, usePlansPreview, useRevokeApiKey };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { t as AccountPlansPage } from "./AccountPlansPage-
|
|
1
|
+
import { t as AccountPlansPage } from "./AccountPlansPage-BEDZbyAS.mjs";
|
|
2
2
|
import { a as LOGIN_NAV_PATH, c as USAGE_PATH, i as CREDENTIALS_PATH, n as CHECKOUT_PATH, o as PRICING_PATH, r as CONTACT_SALES_PATH, s as SUBSCRIPTIONS_PATH, t as ACCOUNT_PLANS_PATH } from "./paths-ujy9wjVK.mjs";
|
|
3
3
|
import { a as formatPlanDisplayPrice, c as isActiveSubscription, f as listPlanFeatureLines, g as pickFeaturedPlanSku, p as parseManifestPlans, s as formatPlanPriceUnit, y as resolveDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
4
4
|
import "./PricingCard-D-owYlf3.mjs";
|
|
5
|
-
import { t as DevPortalBillingProvider } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
6
|
-
import { t as
|
|
5
|
+
import { n as useDevPortalBillingConfig, t as DevPortalBillingProvider } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
6
|
+
import { t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-rN2Gj4lM.mjs";
|
|
7
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-B4iV7zFs.mjs";
|
|
7
8
|
import { n as startPlansPrefetch, t as usePlans } from "./usePlans-DVGt2Myv.mjs";
|
|
8
|
-
import { a as useApiKeys, c as playgroundKeyIdentities, i as API_KEY_CAP_REACHED, o as useCreateApiKey, r as ApiKeysPanel, s as useRevokeApiKey, t as accountLayoutProps } from "./account-links-
|
|
9
|
+
import { a as useApiKeys, c as playgroundKeyIdentities, i as API_KEY_CAP_REACHED, o as useCreateApiKey, r as ApiKeysPanel, s as useRevokeApiKey, t as accountLayoutProps } from "./account-links-Dg4ugnGW.mjs";
|
|
9
10
|
import { n as useUsageRecent, t as useUsage } from "./useUsage-DOUibue4.mjs";
|
|
10
11
|
import { t as isPreviewPricingEnabled } from "./pricing-config-CfhRX9tk.mjs";
|
|
11
12
|
import { Head, Link } from "@lukoweb/apitogo/components";
|
|
@@ -13,6 +14,7 @@ import { ArrowRightIcon, KeyRoundIcon, StarsIcon } from "@lukoweb/apitogo/icons"
|
|
|
13
14
|
import { Outlet } from "@lukoweb/apitogo/router";
|
|
14
15
|
import { Suspense, lazy } from "react";
|
|
15
16
|
import manifestCatalog from "virtual:apitogo-local-manifest";
|
|
17
|
+
import zudokuConfig from "virtual:zudoku-config";
|
|
16
18
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
17
19
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
18
20
|
import { Button as Button$1 } from "@lukoweb/apitogo/ui/Button.js";
|
|
@@ -363,13 +365,13 @@ async function getSignedInIdentities(apiBaseUrl, fetchImpl = fetch) {
|
|
|
363
365
|
|
|
364
366
|
//#endregion
|
|
365
367
|
//#region src/DevPortalBillingPlugin.tsx
|
|
366
|
-
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-
|
|
368
|
+
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-BEDZbyAS.mjs").then((n) => n.n));
|
|
367
369
|
const CheckoutPage = lazy(() => import("./CheckoutPage-6nFq9GKO.mjs"));
|
|
368
370
|
const ContactSalesPage = lazy(() => import("./ContactSalesPage-Imh39E8z.mjs"));
|
|
369
|
-
const CredentialsPage = lazy(() => import("./CredentialsPage-
|
|
371
|
+
const CredentialsPage = lazy(() => import("./CredentialsPage-D9voniJR.mjs"));
|
|
370
372
|
const PricingPage = lazy(() => import("./PricingPage-BTPQ-ntp.mjs"));
|
|
371
|
-
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-
|
|
372
|
-
const UsagePage = lazy(() => import("./UsagePage-
|
|
373
|
+
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-Bo5D3K1x.mjs"));
|
|
374
|
+
const UsagePage = lazy(() => import("./UsagePage-CK6p01Ut.mjs"));
|
|
373
375
|
function resolvePricingEnabled(config) {
|
|
374
376
|
if (config.__meta?.pricingEnabled !== void 0) return config.__meta.pricingEnabled;
|
|
375
377
|
return isPreviewPricingEnabled();
|
|
@@ -474,6 +476,21 @@ const devPortalBillingPlugin = createPlugin((options = {}) => {
|
|
|
474
476
|
};
|
|
475
477
|
});
|
|
476
478
|
|
|
479
|
+
//#endregion
|
|
480
|
+
//#region src/hooks/useGatewayCall.ts
|
|
481
|
+
/**
|
|
482
|
+
* The real gateway address and key header, as the portal build knows them (API-120), so a page's code sample works
|
|
483
|
+
* when a visitor pastes it with their key.
|
|
484
|
+
*/
|
|
485
|
+
function useGatewayCall() {
|
|
486
|
+
const { gatewayBaseUrl, keyHeader } = useDevPortalBillingConfig();
|
|
487
|
+
const baseUrl = gatewayBaseUrl?.trim() || zudokuConfig.__meta?.gatewayBaseUrl?.trim() || "";
|
|
488
|
+
return {
|
|
489
|
+
baseUrl: baseUrl ? baseUrl.replace(/\/+$/, "") : null,
|
|
490
|
+
keyHeader: keyHeader?.trim() || DEMO_GATEWAY_KEY_HEADER
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
|
|
477
494
|
//#endregion
|
|
478
495
|
//#region src/hooks/usePlansPreview.ts
|
|
479
496
|
/** Maps plans to landing `PlansPreviewSection` cards, highlighting the same plan as /pricing. */
|
|
@@ -499,4 +516,4 @@ const usePlansPreview = () => {
|
|
|
499
516
|
};
|
|
500
517
|
|
|
501
518
|
//#endregion
|
|
502
|
-
export { ACCOUNT_PLANS_PATH, API_KEY_CAP_REACHED, AccountPlansPage, ApiKeysPanel, CHECKOUT_PATH, CONTACT_SALES_PATH, CREDENTIALS_PATH, OverviewDashboardPage, PRICING_PATH, SUBSCRIPTIONS_PATH, USAGE_PATH, devPortalBillingPlugin, toPlansPreviewItems, useApiKeys, useCreateApiKey, usePlans, usePlansPreview, useRevokeApiKey };
|
|
519
|
+
export { ACCOUNT_PLANS_PATH, API_KEY_CAP_REACHED, AccountPlansPage, ApiKeysPanel, CHECKOUT_PATH, CONTACT_SALES_PATH, CREDENTIALS_PATH, OverviewDashboardPage, PRICING_PATH, SUBSCRIPTIONS_PATH, USAGE_PATH, devPortalBillingPlugin, toPlansPreviewItems, useApiKeys, useCreateApiKey, useGatewayCall, usePlans, usePlansPreview, useRevokeApiKey };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as useDevPortalPreviewMode, r as useIsDemoSession, t as useDevPortalApiBaseUrl } from "./useDevPortalApiBaseUrl-Dk00H8xy.mjs";
|
|
2
2
|
import { n as useDevPortalBillingConfig } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
3
|
-
import { i as createDemoMeResponse } from "./demo-session-
|
|
3
|
+
import { i as createDemoMeResponse } from "./demo-session-rN2Gj4lM.mjs";
|
|
4
4
|
import { useQuery } from "@lukoweb/apitogo/react-query";
|
|
5
5
|
import { useAuth } from "@lukoweb/apitogo/hooks";
|
|
6
6
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukoweb/apitogo-plugin-dev-portal-billing",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.51",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"react": "19.2.4",
|
|
47
47
|
"react-dom": "19.2.4",
|
|
48
48
|
"tsdown": "0.20.3",
|
|
49
|
-
"@lukoweb/apitogo": "0.2.
|
|
50
|
-
"@lukoweb/apitogo-module-user-panel": "0.2.
|
|
49
|
+
"@lukoweb/apitogo": "0.2.51",
|
|
50
|
+
"@lukoweb/apitogo-module-user-panel": "0.2.51"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=19.2.0",
|