@lukoweb/apitogo-plugin-dev-portal-billing 0.1.49 → 0.1.50
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 -75
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -12,8 +12,6 @@ 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 { access, readFile } from "node:fs/promises";
|
|
16
|
-
import path from "node:path";
|
|
17
15
|
|
|
18
16
|
//#region src/utils/dev-portal-api.ts
|
|
19
17
|
const DEV_PORTAL_PLACEHOLDER_API_URL = "https://dp-example.azurecontainerapps.io";
|
|
@@ -941,62 +939,6 @@ const SubscriptionsPage = () => {
|
|
|
941
939
|
});
|
|
942
940
|
};
|
|
943
941
|
|
|
944
|
-
//#endregion
|
|
945
|
-
//#region src/utils/manifest-pricing.ts
|
|
946
|
-
const APITOGO_MANIFEST_BASE_FILENAME = "apitogo.json";
|
|
947
|
-
const APITOGO_MANIFEST_ENV_FILES = {
|
|
948
|
-
development: "apitogo.local.json",
|
|
949
|
-
production: "apitogo.prod.json"
|
|
950
|
-
};
|
|
951
|
-
async function fileExists(filePath) {
|
|
952
|
-
try {
|
|
953
|
-
await access(filePath);
|
|
954
|
-
return true;
|
|
955
|
-
} catch {
|
|
956
|
-
return false;
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
async function readManifestFile(filePath) {
|
|
960
|
-
try {
|
|
961
|
-
const raw = await readFile(filePath, "utf8");
|
|
962
|
-
return JSON.parse(raw);
|
|
963
|
-
} catch {
|
|
964
|
-
return null;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
function mergeManifest(base, override) {
|
|
968
|
-
if (!base) return override;
|
|
969
|
-
if (!override) return base;
|
|
970
|
-
return {
|
|
971
|
-
...base,
|
|
972
|
-
...override,
|
|
973
|
-
pricing: {
|
|
974
|
-
...base.pricing,
|
|
975
|
-
...override.pricing
|
|
976
|
-
}
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
async function readEffectiveManifest(rootDir, mode) {
|
|
980
|
-
const resolvedRoot = path.resolve(rootDir);
|
|
981
|
-
const env = mode === "production" ? "production" : "development";
|
|
982
|
-
const basePath = path.join(resolvedRoot, APITOGO_MANIFEST_BASE_FILENAME);
|
|
983
|
-
const overridePath = path.join(resolvedRoot, APITOGO_MANIFEST_ENV_FILES[env]);
|
|
984
|
-
const hasBase = await fileExists(basePath);
|
|
985
|
-
const hasOverride = await fileExists(overridePath);
|
|
986
|
-
if (!hasBase) {
|
|
987
|
-
const legacy = await readManifestFile(path.join(resolvedRoot, APITOGO_MANIFEST_ENV_FILES.development));
|
|
988
|
-
if (legacy) return legacy;
|
|
989
|
-
if (hasOverride) return readManifestFile(overridePath);
|
|
990
|
-
return null;
|
|
991
|
-
}
|
|
992
|
-
const base = await readManifestFile(basePath);
|
|
993
|
-
if (!hasOverride) return base;
|
|
994
|
-
return mergeManifest(base, await readManifestFile(overridePath));
|
|
995
|
-
}
|
|
996
|
-
async function manifestPricingEnabled(rootDir, mode = "development") {
|
|
997
|
-
return (await readEffectiveManifest(rootDir, mode))?.pricing?.enabled === true;
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
942
|
//#endregion
|
|
1001
943
|
//#region src/utils/navigation-plans.ts
|
|
1002
944
|
function withoutPricingNavigation(items) {
|
|
@@ -1017,10 +959,15 @@ function withoutPricingNavigation(items) {
|
|
|
1017
959
|
|
|
1018
960
|
//#endregion
|
|
1019
961
|
//#region src/DevPortalBillingPlugin.tsx
|
|
962
|
+
function isNodeRuntime() {
|
|
963
|
+
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
964
|
+
}
|
|
1020
965
|
async function resolvePricingEnabled(config) {
|
|
1021
|
-
const
|
|
1022
|
-
|
|
1023
|
-
|
|
966
|
+
const rootDir = config.__meta?.rootDir;
|
|
967
|
+
if (rootDir && isNodeRuntime()) {
|
|
968
|
+
const { isPricingEnabled, readEffectiveManifest, resolveManifestEnv } = await import("@lukoweb/apitogo/local-manifest");
|
|
969
|
+
return isPricingEnabled(await readEffectiveManifest(rootDir, resolveManifestEnv(config.__meta?.mode ?? "development")));
|
|
970
|
+
}
|
|
1024
971
|
return isPreviewPricingEnabled();
|
|
1025
972
|
}
|
|
1026
973
|
const devPortalBillingPlugin = createPlugin((options = {}) => ({
|
|
@@ -1051,8 +998,15 @@ const devPortalBillingPlugin = createPlugin((options = {}) => ({
|
|
|
1051
998
|
category: "middle",
|
|
1052
999
|
weight: 26
|
|
1053
1000
|
}],
|
|
1054
|
-
getRoutes: () => {
|
|
1055
|
-
|
|
1001
|
+
getRoutes: () => [{
|
|
1002
|
+
element: /* @__PURE__ */ jsx(DevPortalBillingWrapper, { options }),
|
|
1003
|
+
handle: { layout: "none" },
|
|
1004
|
+
children: [
|
|
1005
|
+
{
|
|
1006
|
+
path: PRICING_PATH,
|
|
1007
|
+
handle: { layout: "default" },
|
|
1008
|
+
element: /* @__PURE__ */ jsx(PricingPage, {})
|
|
1009
|
+
},
|
|
1056
1010
|
{
|
|
1057
1011
|
path: CHECKOUT_PATH,
|
|
1058
1012
|
handle: { layout: "default" },
|
|
@@ -1068,18 +1022,8 @@ const devPortalBillingPlugin = createPlugin((options = {}) => ({
|
|
|
1068
1022
|
handle: { layout: "default" },
|
|
1069
1023
|
element: /* @__PURE__ */ jsx(CredentialsPage, {})
|
|
1070
1024
|
}
|
|
1071
|
-
]
|
|
1072
|
-
|
|
1073
|
-
path: PRICING_PATH,
|
|
1074
|
-
handle: { layout: "default" },
|
|
1075
|
-
element: /* @__PURE__ */ jsx(PricingPage, {})
|
|
1076
|
-
});
|
|
1077
|
-
return [{
|
|
1078
|
-
element: /* @__PURE__ */ jsx(DevPortalBillingWrapper, { options }),
|
|
1079
|
-
handle: { layout: "none" },
|
|
1080
|
-
children
|
|
1081
|
-
}];
|
|
1082
|
-
},
|
|
1025
|
+
]
|
|
1026
|
+
}],
|
|
1083
1027
|
getProtectedRoutes: () => [
|
|
1084
1028
|
CHECKOUT_PATH,
|
|
1085
1029
|
SUBSCRIPTIONS_PATH,
|
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.50",
|
|
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.50"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": ">=19.2.0",
|