@lukoweb/apitogo-plugin-dev-portal-billing 0.1.50 → 0.1.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/index.mjs +76 -27
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { Alert, AlertAction, AlertDescription } from "@lukoweb/apitogo/ui/Alert"
|
|
|
12
12
|
import { Button as Button$1 } from "@lukoweb/apitogo/ui/Button";
|
|
13
13
|
import { Secret } from "@lukoweb/apitogo/ui/Secret.js";
|
|
14
14
|
import { Value } from "@lukoweb/apitogo/ui/Value.js";
|
|
15
|
+
import { isAuthenticationEnabled, readEffectiveManifest, resolveManifestEnv } from "@lukoweb/apitogo/local-manifest";
|
|
15
16
|
|
|
16
17
|
//#region src/utils/dev-portal-api.ts
|
|
17
18
|
const DEV_PORTAL_PLACEHOLDER_API_URL = "https://dp-example.azurecontainerapps.io";
|
|
@@ -324,17 +325,16 @@ const AccountPlansPage = () => {
|
|
|
324
325
|
" ",
|
|
325
326
|
/* @__PURE__ */ jsx("code", {
|
|
326
327
|
className: "rounded bg-muted px-1.5 py-0.5",
|
|
327
|
-
children: "apitogo.json"
|
|
328
|
+
children: "apitogo.config.json"
|
|
328
329
|
}),
|
|
329
330
|
` `,
|
|
330
|
-
"(
|
|
331
|
+
"(overridable via",
|
|
331
332
|
" ",
|
|
332
333
|
/* @__PURE__ */ jsx("code", {
|
|
333
334
|
className: "rounded bg-muted px-1.5 py-0.5",
|
|
334
|
-
children: "
|
|
335
|
+
children: ".env"
|
|
335
336
|
}),
|
|
336
|
-
" "
|
|
337
|
-
"overrides). Subscribe and unsubscribe activate after the portal is published."
|
|
337
|
+
"). Subscribe and unsubscribe activate after the portal is published."
|
|
338
338
|
]
|
|
339
339
|
}) : null,
|
|
340
340
|
cancelMutation.isError ? /* @__PURE__ */ jsx("div", {
|
|
@@ -765,17 +765,22 @@ const PricingPage = () => {
|
|
|
765
765
|
" ",
|
|
766
766
|
/* @__PURE__ */ jsx("code", {
|
|
767
767
|
className: "rounded bg-muted px-1.5 py-0.5",
|
|
768
|
-
children: "apitogo.json"
|
|
768
|
+
children: "apitogo.config.json"
|
|
769
769
|
}),
|
|
770
770
|
` `,
|
|
771
|
-
"(
|
|
771
|
+
"(overridable via",
|
|
772
772
|
" ",
|
|
773
773
|
/* @__PURE__ */ jsx("code", {
|
|
774
774
|
className: "rounded bg-muted px-1.5 py-0.5",
|
|
775
|
-
children: "
|
|
775
|
+
children: ".env"
|
|
776
776
|
}),
|
|
777
777
|
" ",
|
|
778
|
-
"
|
|
778
|
+
"with ",
|
|
779
|
+
/* @__PURE__ */ jsx("code", {
|
|
780
|
+
className: "rounded bg-muted px-1.5 py-0.5",
|
|
781
|
+
children: "APITOGO_CONFIG_*"
|
|
782
|
+
}),
|
|
783
|
+
"). Checkout activates after the portal is published."
|
|
779
784
|
]
|
|
780
785
|
}) : null,
|
|
781
786
|
isLoading ? /* @__PURE__ */ jsx("p", {
|
|
@@ -800,7 +805,7 @@ const PricingPage = () => {
|
|
|
800
805
|
" ",
|
|
801
806
|
/* @__PURE__ */ jsx("code", {
|
|
802
807
|
className: "rounded bg-muted px-1.5 py-0.5",
|
|
803
|
-
children: "apitogo.json"
|
|
808
|
+
children: "apitogo.config.json"
|
|
804
809
|
}),
|
|
805
810
|
" ",
|
|
806
811
|
"and set",
|
|
@@ -939,6 +944,33 @@ const SubscriptionsPage = () => {
|
|
|
939
944
|
});
|
|
940
945
|
};
|
|
941
946
|
|
|
947
|
+
//#endregion
|
|
948
|
+
//#region src/utils/auth-config.ts
|
|
949
|
+
const LOGIN_NAV_PATH = "/signin";
|
|
950
|
+
async function resolveAuthenticationNavEnabled(config) {
|
|
951
|
+
if (config.__meta?.authenticationEnabled !== void 0) return config.__meta.authenticationEnabled;
|
|
952
|
+
if (manifestCatalog?.authenticationEnabled === true) return true;
|
|
953
|
+
return isAuthenticationEnabled(await readEffectiveManifest(config.__meta?.rootDir ?? process.cwd(), resolveManifestEnv(process.env.NODE_ENV === "production" ? "production" : "development")));
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
//#endregion
|
|
957
|
+
//#region src/utils/navigation-auth.ts
|
|
958
|
+
function withoutLoginNavigation(items) {
|
|
959
|
+
if (!items?.length) return [];
|
|
960
|
+
return items.map((item) => {
|
|
961
|
+
if (typeof item === "string") return item;
|
|
962
|
+
if ("to" in item && item.to === LOGIN_NAV_PATH) return null;
|
|
963
|
+
if (item.items?.length) {
|
|
964
|
+
const filteredItems = withoutLoginNavigation(item.items);
|
|
965
|
+
return {
|
|
966
|
+
...item,
|
|
967
|
+
items: filteredItems
|
|
968
|
+
};
|
|
969
|
+
}
|
|
970
|
+
return item;
|
|
971
|
+
}).filter((item) => item !== null);
|
|
972
|
+
}
|
|
973
|
+
|
|
942
974
|
//#endregion
|
|
943
975
|
//#region src/utils/navigation-plans.ts
|
|
944
976
|
function withoutPricingNavigation(items) {
|
|
@@ -958,32 +990,49 @@ function withoutPricingNavigation(items) {
|
|
|
958
990
|
}
|
|
959
991
|
|
|
960
992
|
//#endregion
|
|
961
|
-
//#region src/
|
|
962
|
-
function
|
|
963
|
-
return
|
|
993
|
+
//#region src/utils/header-navigation.ts
|
|
994
|
+
function hasHeaderLink(navigation, path) {
|
|
995
|
+
return navigation.some((item) => "to" in item && item.to === path);
|
|
964
996
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
if (
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
997
|
+
function buildDevPortalHeaderNavigation({ navigation, pricingEnabled, authNavEnabled }) {
|
|
998
|
+
let items = [...navigation ?? []];
|
|
999
|
+
if (!pricingEnabled) items = withoutPricingNavigation(items);
|
|
1000
|
+
else if (!hasHeaderLink(items, PRICING_PATH)) items = [...items, {
|
|
1001
|
+
label: "Pricing",
|
|
1002
|
+
to: PRICING_PATH,
|
|
1003
|
+
display: "anon"
|
|
1004
|
+
}];
|
|
1005
|
+
if (!authNavEnabled) items = withoutLoginNavigation(items);
|
|
1006
|
+
else if (!hasHeaderLink(items, LOGIN_NAV_PATH)) items = [...items, {
|
|
1007
|
+
label: "Login",
|
|
1008
|
+
to: LOGIN_NAV_PATH,
|
|
1009
|
+
display: "anon"
|
|
1010
|
+
}];
|
|
1011
|
+
return items;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
//#endregion
|
|
1015
|
+
//#region src/DevPortalBillingPlugin.tsx
|
|
1016
|
+
function resolvePricingEnabled(config) {
|
|
1017
|
+
if (config.__meta?.pricingEnabled !== void 0) return config.__meta.pricingEnabled;
|
|
971
1018
|
return isPreviewPricingEnabled();
|
|
972
1019
|
}
|
|
973
1020
|
const devPortalBillingPlugin = createPlugin((options = {}) => ({
|
|
974
1021
|
transformConfig: async ({ config, merge }) => {
|
|
975
|
-
|
|
976
|
-
|
|
1022
|
+
const pricingEnabled = resolvePricingEnabled(config);
|
|
1023
|
+
const authNavEnabled = !!config.authentication && await resolveAuthenticationNavEnabled(config);
|
|
1024
|
+
const headerNavigation = buildDevPortalHeaderNavigation({
|
|
1025
|
+
navigation: config.header?.navigation,
|
|
1026
|
+
pricingEnabled,
|
|
1027
|
+
authNavEnabled
|
|
1028
|
+
});
|
|
1029
|
+
return merge({
|
|
1030
|
+
navigation: pricingEnabled ? config.navigation : withoutPricingNavigation(config.navigation),
|
|
977
1031
|
header: {
|
|
978
1032
|
...config.header,
|
|
979
|
-
navigation:
|
|
1033
|
+
navigation: headerNavigation
|
|
980
1034
|
}
|
|
981
1035
|
});
|
|
982
|
-
return merge({ header: { navigation: [...config.header?.navigation ?? [], {
|
|
983
|
-
label: "Pricing",
|
|
984
|
-
to: PRICING_PATH,
|
|
985
|
-
display: "anon"
|
|
986
|
-
}] } });
|
|
987
1036
|
},
|
|
988
1037
|
getProfileMenuItems: () => [{
|
|
989
1038
|
label: "My Subscriptions",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukoweb/apitogo-plugin-dev-portal-billing",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.51",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/zuplo/zudoku",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"react": "19.2.4",
|
|
47
47
|
"react-dom": "19.2.4",
|
|
48
48
|
"tsdown": "0.20.3",
|
|
49
|
-
"@lukoweb/apitogo": "0.1.
|
|
49
|
+
"@lukoweb/apitogo": "0.1.51"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">=19.2.0",
|