@carrierllc/mcp 0.2.14 → 0.2.16
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 +26 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -938,17 +938,8 @@ function registerAllTools(server2, ctx) {
|
|
|
938
938
|
accountForSubs: account_for_subs
|
|
939
939
|
});
|
|
940
940
|
}
|
|
941
|
-
const cache = /* @__PURE__ */ new Map();
|
|
942
|
-
const sub = await resolveSubscriberByIccid(ctx.env, token2, iccid, cache);
|
|
943
|
-
const subscriberId = sub.id ?? sub.subscriberId;
|
|
944
|
-
if (subscriberId === void 0) {
|
|
945
|
-
return {
|
|
946
|
-
isError: true,
|
|
947
|
-
content: [{ type: "text", text: `Error: Could not resolve subscriberId for ICCID ${iccid}` }]
|
|
948
|
-
};
|
|
949
|
-
}
|
|
950
941
|
return ocsCall(ctx.env, token2, "affectPackageToSubscriber", {
|
|
951
|
-
subscriber:
|
|
942
|
+
subscriber: { iccid },
|
|
952
943
|
packageTemplateId
|
|
953
944
|
});
|
|
954
945
|
}
|
|
@@ -5390,8 +5381,20 @@ import {
|
|
|
5390
5381
|
function sessionKey(sub, wizardId) {
|
|
5391
5382
|
return `app-session:${sub}:${wizardId}`;
|
|
5392
5383
|
}
|
|
5384
|
+
var inMemorySessions = /* @__PURE__ */ new Map();
|
|
5385
|
+
function pruneExpired() {
|
|
5386
|
+
const now = Date.now();
|
|
5387
|
+
for (const [key, val] of inMemorySessions.entries()) {
|
|
5388
|
+
if (val.expiresAt < now) inMemorySessions.delete(key);
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5393
5391
|
async function loadWizardSession(env, sub, wizardId) {
|
|
5394
|
-
const
|
|
5392
|
+
const key = sessionKey(sub, wizardId);
|
|
5393
|
+
if (!env.CARRIER_USERS) {
|
|
5394
|
+
pruneExpired();
|
|
5395
|
+
return inMemorySessions.get(key)?.session ?? null;
|
|
5396
|
+
}
|
|
5397
|
+
const raw = await env.CARRIER_USERS.get(key);
|
|
5395
5398
|
if (!raw) return null;
|
|
5396
5399
|
try {
|
|
5397
5400
|
return JSON.parse(raw);
|
|
@@ -5400,14 +5403,20 @@ async function loadWizardSession(env, sub, wizardId) {
|
|
|
5400
5403
|
}
|
|
5401
5404
|
}
|
|
5402
5405
|
async function saveWizardSession(env, sub, wizardId, session) {
|
|
5403
|
-
|
|
5404
|
-
|
|
5405
|
-
|
|
5406
|
-
|
|
5407
|
-
|
|
5406
|
+
const key = sessionKey(sub, wizardId);
|
|
5407
|
+
if (!env.CARRIER_USERS) {
|
|
5408
|
+
inMemorySessions.set(key, { session, expiresAt: Date.now() + 6e5 });
|
|
5409
|
+
return;
|
|
5410
|
+
}
|
|
5411
|
+
await env.CARRIER_USERS.put(key, JSON.stringify(session), { expirationTtl: 600 });
|
|
5408
5412
|
}
|
|
5409
5413
|
async function deleteWizardSession(env, sub, wizardId) {
|
|
5410
|
-
|
|
5414
|
+
const key = sessionKey(sub, wizardId);
|
|
5415
|
+
if (!env.CARRIER_USERS) {
|
|
5416
|
+
inMemorySessions.delete(key);
|
|
5417
|
+
return;
|
|
5418
|
+
}
|
|
5419
|
+
await env.CARRIER_USERS.delete(key);
|
|
5411
5420
|
}
|
|
5412
5421
|
|
|
5413
5422
|
// src/apps/provisioning-wizard.ts
|