Directory-submission readiness: add MCP tool annotations (title + readOnlyHint/destructiveHint), /privacy policy route + README Privacy Policy section, bump to 2.3.2
This commit is contained in:
Vendored
+10
-41
@@ -1,20 +1,19 @@
|
||||
import { SteadfastAdapter } from "./adapters/steadfast.js";
|
||||
import { PathaoAdapter } from "./adapters/pathao.js";
|
||||
import { RedXAdapter } from "./adapters/redx.js";
|
||||
import { PaperflyAdapter } from "./adapters/paperfly.js";
|
||||
import { FraudRiskEngine } from "./adapters/fraud_engine.js";
|
||||
import { RedxAdapter } from "./adapters/redx.js";
|
||||
import { PaperflyAdapter } from "./adapters/paperfly.js";
|
||||
import { loadConfig } from "./config.js";
|
||||
export class CourierRegistry {
|
||||
adapters = new Map();
|
||||
constructor() {
|
||||
const config = loadConfig();
|
||||
constructor(config = loadConfig()) {
|
||||
const steadfast = new SteadfastAdapter(config.steadfast.apiKey, config.steadfast.secretKey, config.steadfast.baseUrl);
|
||||
this.adapters.set("steadfast", steadfast);
|
||||
const pathao = new PathaoAdapter(config.pathao.clientId, config.pathao.clientSecret, config.pathao.username, config.pathao.password, config.pathao.storeId, config.pathao.baseUrl);
|
||||
this.adapters.set("pathao", pathao);
|
||||
const redx = new RedXAdapter(config.redx.apiToken, config.redx.baseUrl);
|
||||
const redx = new RedxAdapter(config.redx.apiToken, config.redx.baseUrl, config.redx.pickupStoreId);
|
||||
this.adapters.set("redx", redx);
|
||||
const paperfly = new PaperflyAdapter(config.paperfly.user, config.paperfly.pass, config.paperfly.key, config.paperfly.baseUrl);
|
||||
const paperfly = new PaperflyAdapter(config.paperfly.apiKey, config.paperfly.username, config.paperfly.password, config.paperfly.storeName, config.paperfly.baseUrl);
|
||||
this.adapters.set("paperfly", paperfly);
|
||||
}
|
||||
listCouriers() {
|
||||
@@ -36,7 +35,7 @@ export class CourierRegistry {
|
||||
courierName = req.courier;
|
||||
}
|
||||
else {
|
||||
// Smart routing heuristic across all 4 couriers
|
||||
// Smart routing heuristic
|
||||
const addr = req.recipient_address.toLowerCase();
|
||||
if (addr.includes("dhaka") &&
|
||||
(addr.includes("gulshan") ||
|
||||
@@ -44,26 +43,10 @@ export class CourierRegistry {
|
||||
addr.includes("dhanmondi") ||
|
||||
addr.includes("uttara") ||
|
||||
addr.includes("mirpur"))) {
|
||||
if (this.adapters.get("pathao")?.isConfigured()) {
|
||||
courierName = "pathao";
|
||||
}
|
||||
else if (this.adapters.get("redx")?.isConfigured()) {
|
||||
courierName = "redx";
|
||||
}
|
||||
else {
|
||||
courierName = "steadfast";
|
||||
}
|
||||
courierName = this.adapters.get("pathao")?.isConfigured() ? "pathao" : "steadfast";
|
||||
}
|
||||
else {
|
||||
if (this.adapters.get("steadfast")?.isConfigured()) {
|
||||
courierName = "steadfast";
|
||||
}
|
||||
else if (this.adapters.get("paperfly")?.isConfigured()) {
|
||||
courierName = "paperfly";
|
||||
}
|
||||
else {
|
||||
courierName = "steadfast";
|
||||
}
|
||||
courierName = "steadfast";
|
||||
}
|
||||
}
|
||||
const adapter = this.getAdapter(courierName);
|
||||
@@ -73,26 +56,12 @@ export class CourierRegistry {
|
||||
if (courierName) {
|
||||
return await this.getAdapter(courierName).trackParcel(trackingCode);
|
||||
}
|
||||
// Smart fallback across available configured adapters
|
||||
const order = ["steadfast", "pathao", "redx", "paperfly"];
|
||||
let lastError = null;
|
||||
for (const c of order) {
|
||||
const adapter = this.adapters.get(c);
|
||||
if (adapter && adapter.isConfigured()) {
|
||||
try {
|
||||
return await adapter.trackParcel(trackingCode);
|
||||
}
|
||||
catch (e) {
|
||||
lastError = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Default fallback to Steadfast
|
||||
// Default try Steadfast first
|
||||
try {
|
||||
return await this.getAdapter("steadfast").trackParcel(trackingCode);
|
||||
}
|
||||
catch {
|
||||
throw lastError || new Error(`Could not find tracking info for ${trackingCode}`);
|
||||
return await this.getAdapter("pathao").trackParcel(trackingCode);
|
||||
}
|
||||
}
|
||||
async getBalance(courierName) {
|
||||
|
||||
Reference in New Issue
Block a user