@lukoweb/apitogo-plugin-dev-portal-billing 0.2.42 → 0.2.44
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-wrL7BtXu.mjs → AccountPlansPage-DTVIVeRh.mjs} +1 -1
- package/dist/{CredentialsPage-BdSCmTR9.mjs → CredentialsPage-BOVn3PpF.mjs} +2 -2
- package/dist/{SubscriptionsPage-CIiPzK64.mjs → SubscriptionsPage-29Xs4XvM.mjs} +1 -1
- package/dist/{UsagePage-Xz2KEk2B.mjs → UsagePage-U27bvmbF.mjs} +1 -1
- package/dist/{account-links-CH6HyjOb.mjs → account-links-BUeCO2Du.mjs} +72 -4
- package/dist/{demo-session-Cez740bi.mjs → demo-session-B6WAunKV.mjs} +1 -1
- package/dist/index.mjs +8 -8
- package/dist/{useMySubscriptions-BFe0t1Ru.mjs → useMySubscriptions-Bdo2HFrP.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-Bdo2HFrP.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 {
|
|
5
|
-
import { a as useApiKeys, n as apiReferencePath, r as ApiKeysPanel } from "./account-links-
|
|
4
|
+
import { r as createDemoCredentials } from "./demo-session-B6WAunKV.mjs";
|
|
5
|
+
import { a as useApiKeys, n as apiReferencePath, r as ApiKeysPanel } from "./account-links-BUeCO2Du.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";
|
|
@@ -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-Bdo2HFrP.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-Bdo2HFrP.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 {
|
|
3
|
+
import { n as createDemoApiKeys, t as DEMO_GATEWAY_KEY_HEADER } from "./demo-session-B6WAunKV.mjs";
|
|
4
4
|
import { Spinner } from "@lukoweb/apitogo/components";
|
|
5
5
|
import { KeyRoundIcon, TrashIcon } from "@lukoweb/apitogo/icons";
|
|
6
6
|
import { useState } from "react";
|
|
@@ -13,6 +13,65 @@ import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, D
|
|
|
13
13
|
import { Input } from "@lukoweb/apitogo/ui/Input.js";
|
|
14
14
|
import { Secret } from "@lukoweb/apitogo/ui/Secret.js";
|
|
15
15
|
|
|
16
|
+
//#region src/utils/playground-key.ts
|
|
17
|
+
const STORAGE_KEY = "apitogo-playground-api-key";
|
|
18
|
+
const PLAYGROUND_KEY_IDENTITY_ID = "api-key";
|
|
19
|
+
const storage = () => {
|
|
20
|
+
try {
|
|
21
|
+
return typeof localStorage === "undefined" ? void 0 : localStorage;
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Remembers a key the moment it is created: the plans backend shows a key's secret only then, so this is the one
|
|
28
|
+
* chance to offer it to the playground later. Only the last key is kept, in this browser only.
|
|
29
|
+
*/
|
|
30
|
+
function rememberPlaygroundKey(entry) {
|
|
31
|
+
if (!entry.key) return;
|
|
32
|
+
const value = {
|
|
33
|
+
id: entry.id,
|
|
34
|
+
key: entry.key,
|
|
35
|
+
header: entry.header || DEMO_GATEWAY_KEY_HEADER,
|
|
36
|
+
keyPrefix: entry.keyPrefix
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
storage()?.setItem(STORAGE_KEY, JSON.stringify(value));
|
|
40
|
+
} catch {}
|
|
41
|
+
}
|
|
42
|
+
function readPlaygroundKey() {
|
|
43
|
+
try {
|
|
44
|
+
const raw = storage()?.getItem(STORAGE_KEY);
|
|
45
|
+
if (!raw) return void 0;
|
|
46
|
+
const parsed = JSON.parse(raw);
|
|
47
|
+
return parsed.id && parsed.key && parsed.header && parsed.keyPrefix ? parsed : void 0;
|
|
48
|
+
} catch {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** A revoked key stops working, so it is no longer offered. */
|
|
53
|
+
function forgetPlaygroundKey(keyId) {
|
|
54
|
+
if (readPlaygroundKey()?.id !== keyId) return;
|
|
55
|
+
try {
|
|
56
|
+
storage()?.removeItem(STORAGE_KEY);
|
|
57
|
+
} catch {}
|
|
58
|
+
}
|
|
59
|
+
/** The "Try it" identity for the remembered key, sent in the gateway's key header. */
|
|
60
|
+
function playgroundKeyIdentities() {
|
|
61
|
+
const remembered = readPlaygroundKey();
|
|
62
|
+
if (!remembered) return [];
|
|
63
|
+
return [{
|
|
64
|
+
id: PLAYGROUND_KEY_IDENTITY_ID,
|
|
65
|
+
label: `Your API key (${remembered.keyPrefix}…)`,
|
|
66
|
+
authorizationFields: { headers: [remembered.header] },
|
|
67
|
+
authorizeRequest: (request) => {
|
|
68
|
+
request.headers.set(remembered.header, remembered.key);
|
|
69
|
+
return request;
|
|
70
|
+
}
|
|
71
|
+
}];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//#endregion
|
|
16
75
|
//#region src/hooks/useApiKeys.ts
|
|
17
76
|
/** Thrown when the developer has hit their plan's per-developer key cap. */
|
|
18
77
|
const API_KEY_CAP_REACHED = "API_KEY_CAP_REACHED";
|
|
@@ -75,7 +134,11 @@ function useCreateApiKey() {
|
|
|
75
134
|
if (!response.ok) throw new Error(await readProblemDetail(response) ?? "Failed to create API key.");
|
|
76
135
|
return await response.json();
|
|
77
136
|
},
|
|
78
|
-
onSuccess: async () => {
|
|
137
|
+
onSuccess: async (created) => {
|
|
138
|
+
rememberPlaygroundKey({
|
|
139
|
+
...created,
|
|
140
|
+
header: queryClient.getQueryData(apiKeysQueryKey(apiBaseUrl))?.header
|
|
141
|
+
});
|
|
79
142
|
await queryClient.invalidateQueries({ queryKey: apiKeysQueryKey(apiBaseUrl) });
|
|
80
143
|
}
|
|
81
144
|
});
|
|
@@ -93,7 +156,8 @@ function useRevokeApiKey() {
|
|
|
93
156
|
});
|
|
94
157
|
if (!response.ok && response.status !== 204) throw new Error(await readProblemDetail(response) ?? "Failed to revoke API key.");
|
|
95
158
|
},
|
|
96
|
-
onSuccess: async () => {
|
|
159
|
+
onSuccess: async (_result, keyId) => {
|
|
160
|
+
forgetPlaygroundKey(keyId);
|
|
97
161
|
await queryClient.invalidateQueries({ queryKey: apiKeysQueryKey(apiBaseUrl) });
|
|
98
162
|
}
|
|
99
163
|
});
|
|
@@ -172,6 +236,10 @@ const ApiKeysPanel = ({ plan, header, readOnly = false }) => {
|
|
|
172
236
|
newKey?.key ? /* @__PURE__ */ jsxs(Alert, { children: [
|
|
173
237
|
/* @__PURE__ */ jsx(KeyRoundIcon, { size: 16 }),
|
|
174
238
|
/* @__PURE__ */ jsx(AlertTitle, { children: "Copy your new key now — it is shown only once." }),
|
|
239
|
+
/* @__PURE__ */ jsx("p", {
|
|
240
|
+
className: "mt-1 text-sm text-muted-foreground",
|
|
241
|
+
children: "In this browser, the API reference's “Try it” also offers it under Authentication."
|
|
242
|
+
}),
|
|
175
243
|
/* @__PURE__ */ jsxs("div", {
|
|
176
244
|
className: "mt-3 space-y-3",
|
|
177
245
|
children: [/* @__PURE__ */ jsx(Secret, {
|
|
@@ -300,4 +368,4 @@ function apiReferencePath(links) {
|
|
|
300
368
|
}
|
|
301
369
|
|
|
302
370
|
//#endregion
|
|
303
|
-
export { useApiKeys as a, API_KEY_CAP_REACHED as i, apiReferencePath as n, useCreateApiKey as o, ApiKeysPanel as r, useRevokeApiKey as s, accountLayoutProps as t };
|
|
371
|
+
export { useApiKeys as a, playgroundKeyIdentities as c, API_KEY_CAP_REACHED as i, apiReferencePath as n, useCreateApiKey as o, ApiKeysPanel as r, useRevokeApiKey as s, accountLayoutProps as t };
|
|
@@ -62,4 +62,4 @@ function createDemoApiKeys(plans) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
//#endregion
|
|
65
|
-
export {
|
|
65
|
+
export { createDemoMeResponse as i, createDemoApiKeys as n, createDemoCredentials as r, DEMO_GATEWAY_KEY_HEADER as t };
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as AccountPlansPage } from "./AccountPlansPage-
|
|
1
|
+
import { t as AccountPlansPage } from "./AccountPlansPage-DTVIVeRh.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
5
|
import { t as DevPortalBillingProvider } from "./DevPortalBillingContext-CR83s4LO.mjs";
|
|
6
|
-
import { t as useMySubscriptions } from "./useMySubscriptions-
|
|
6
|
+
import { t as useMySubscriptions } from "./useMySubscriptions-Bdo2HFrP.mjs";
|
|
7
7
|
import { n as startPlansPrefetch, t as usePlans } from "./usePlans-DVGt2Myv.mjs";
|
|
8
|
-
import { a as useApiKeys, i as API_KEY_CAP_REACHED, o as useCreateApiKey, r as ApiKeysPanel, s as useRevokeApiKey, t as accountLayoutProps } from "./account-links-
|
|
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-BUeCO2Du.mjs";
|
|
9
9
|
import { n as useUsageRecent, t as useUsage } from "./useUsage-DOUibue4.mjs";
|
|
10
10
|
import { t as isPreviewPricingEnabled } from "./pricing-config-CfhRX9tk.mjs";
|
|
11
11
|
import { Head, Link } from "@lukoweb/apitogo/components";
|
|
@@ -363,13 +363,13 @@ async function getSignedInIdentities(apiBaseUrl, fetchImpl = fetch) {
|
|
|
363
363
|
|
|
364
364
|
//#endregion
|
|
365
365
|
//#region src/DevPortalBillingPlugin.tsx
|
|
366
|
-
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-
|
|
366
|
+
const AccountPlansPage$1 = lazy(() => import("./AccountPlansPage-DTVIVeRh.mjs").then((n) => n.n));
|
|
367
367
|
const CheckoutPage = lazy(() => import("./CheckoutPage-6nFq9GKO.mjs"));
|
|
368
368
|
const ContactSalesPage = lazy(() => import("./ContactSalesPage-Imh39E8z.mjs"));
|
|
369
|
-
const CredentialsPage = lazy(() => import("./CredentialsPage-
|
|
369
|
+
const CredentialsPage = lazy(() => import("./CredentialsPage-BOVn3PpF.mjs"));
|
|
370
370
|
const PricingPage = lazy(() => import("./PricingPage-BTPQ-ntp.mjs"));
|
|
371
|
-
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-
|
|
372
|
-
const UsagePage = lazy(() => import("./UsagePage-
|
|
371
|
+
const SubscriptionsPage = lazy(() => import("./SubscriptionsPage-29Xs4XvM.mjs"));
|
|
372
|
+
const UsagePage = lazy(() => import("./UsagePage-U27bvmbF.mjs"));
|
|
373
373
|
function resolvePricingEnabled(config) {
|
|
374
374
|
if (config.__meta?.pricingEnabled !== void 0) return config.__meta.pricingEnabled;
|
|
375
375
|
return isPreviewPricingEnabled();
|
|
@@ -394,7 +394,7 @@ const devPortalBillingPlugin = createPlugin((options = {}) => {
|
|
|
394
394
|
}
|
|
395
395
|
});
|
|
396
396
|
},
|
|
397
|
-
getIdentities: () => getSignedInIdentities(resolveDevPortalApiBaseUrl(options.apiBaseUrl)),
|
|
397
|
+
getIdentities: async () => [...playgroundKeyIdentities(), ...await getSignedInIdentities(resolveDevPortalApiBaseUrl(options.apiBaseUrl))],
|
|
398
398
|
getProfileMenuItems: () => [{
|
|
399
399
|
label: "My Subscriptions",
|
|
400
400
|
path: SUBSCRIPTIONS_PATH,
|
|
@@ -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 {
|
|
3
|
+
import { i as createDemoMeResponse } from "./demo-session-B6WAunKV.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.44",
|
|
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.44",
|
|
50
|
+
"@lukoweb/apitogo-module-user-panel": "0.2.44"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
53
|
"react": ">=19.2.0",
|