@carrierllc/mcp 0.2.10 → 0.2.12
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.js +39 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2984,6 +2984,38 @@ async function safeCall(env, token2, method, params = {}) {
|
|
|
2984
2984
|
return { data: null, error: err2 instanceof Error ? err2.message : String(err2) };
|
|
2985
2985
|
}
|
|
2986
2986
|
}
|
|
2987
|
+
async function fetchActiveSubscribers(env, token2, accountId, resellerId) {
|
|
2988
|
+
let accountIds;
|
|
2989
|
+
if (accountId !== void 0) {
|
|
2990
|
+
accountIds = [accountId];
|
|
2991
|
+
} else {
|
|
2992
|
+
const accountsResult = await safeCall(
|
|
2993
|
+
env,
|
|
2994
|
+
token2,
|
|
2995
|
+
"listResellerAccount",
|
|
2996
|
+
{ resellerId }
|
|
2997
|
+
);
|
|
2998
|
+
if (accountsResult.error) return { data: null, error: accountsResult.error };
|
|
2999
|
+
const reseller = accountsResult.data?.reseller ?? [];
|
|
3000
|
+
accountIds = reseller.flatMap((r) => (r.account ?? []).map((a) => a.id));
|
|
3001
|
+
if (accountIds.length === 0) return { data: [], error: null };
|
|
3002
|
+
}
|
|
3003
|
+
const aggregated = [];
|
|
3004
|
+
for (const acctId of accountIds) {
|
|
3005
|
+
const subResult = await safeCall(
|
|
3006
|
+
env,
|
|
3007
|
+
token2,
|
|
3008
|
+
"listSubscriber",
|
|
3009
|
+
{ accountId: acctId }
|
|
3010
|
+
);
|
|
3011
|
+
if (subResult.error) return { data: null, error: subResult.error };
|
|
3012
|
+
const raw = subResult.data;
|
|
3013
|
+
const list = Array.isArray(raw) ? raw : raw?.subscriberList ?? [];
|
|
3014
|
+
aggregated.push(...list);
|
|
3015
|
+
}
|
|
3016
|
+
const active = aggregated.filter((s) => String(s.status ?? "").toUpperCase() === "ACTIVE");
|
|
3017
|
+
return { data: active, error: null };
|
|
3018
|
+
}
|
|
2987
3019
|
function formatBytes(bytes) {
|
|
2988
3020
|
if (bytes === 0) return "0 B";
|
|
2989
3021
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
@@ -3582,18 +3614,11 @@ All accounts healthy.`);
|
|
|
3582
3614
|
}, async ({ accountId, limit: sampleLimit }) => {
|
|
3583
3615
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
3584
3616
|
const maxSample = sampleLimit ?? 50;
|
|
3585
|
-
const
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
safeCall(ctx.env, token2, "
|
|
3589
|
-
getDefaultResellerId(ctx.env, token2)
|
|
3617
|
+
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
3618
|
+
const [subsResult, steeringResult] = await Promise.all([
|
|
3619
|
+
fetchActiveSubscribers(ctx.env, token2, accountId, resellerId),
|
|
3620
|
+
safeCall(ctx.env, token2, "listSteeringList", resellerId)
|
|
3590
3621
|
]);
|
|
3591
|
-
const steeringResult = await safeCall(
|
|
3592
|
-
ctx.env,
|
|
3593
|
-
token2,
|
|
3594
|
-
"listSteeringList",
|
|
3595
|
-
resellerId
|
|
3596
|
-
);
|
|
3597
3622
|
if (subsResult.error) return result(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
3598
3623
|
const sections = [`# Network Coverage Audit
|
|
3599
3624
|
`];
|
|
@@ -3785,11 +3810,10 @@ ${networksSorted.length} different networks in ${country} \u2014 possible steeri
|
|
|
3785
3810
|
const token2 = await ctx.getUserToken(ctx.props.sub);
|
|
3786
3811
|
const sampleSize = maxLimit ?? 100;
|
|
3787
3812
|
const threshold = thresholdPct ?? 80;
|
|
3788
|
-
const
|
|
3789
|
-
|
|
3790
|
-
const subsResult = await safeCall(ctx.env, token2, "listSubscriber", subParams);
|
|
3813
|
+
const resellerId = await getDefaultResellerId(ctx.env, token2);
|
|
3814
|
+
const subsResult = await fetchActiveSubscribers(ctx.env, token2, accountId, resellerId);
|
|
3791
3815
|
if (subsResult.error) return result(`Failed to fetch subscribers: ${subsResult.error}`, true);
|
|
3792
|
-
if (!subsResult.data ||
|
|
3816
|
+
if (!subsResult.data || subsResult.data.length === 0) return result("No subscribers found", true);
|
|
3793
3817
|
const sections = [`# High Cost Subscriber Report
|
|
3794
3818
|
`];
|
|
3795
3819
|
const now = /* @__PURE__ */ new Date();
|