feat(v2.6.0): authentic 4-courier cancellation, 3-column docs and AI connector fixes
This commit is contained in:
Vendored
+1
@@ -6,4 +6,5 @@ export interface CourierAdapter {
|
||||
trackParcel(trackingCode: string): Promise<TrackingResponse>;
|
||||
getBalance(): Promise<BalanceResponse>;
|
||||
getLocations?(cityName?: string, zoneName?: string): Promise<LocationResolutionResponse>;
|
||||
cancelParcel?(consignmentId: string, reason?: string): Promise<any>;
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -16,4 +16,15 @@ export declare class PaperflyAdapter implements CourierAdapter {
|
||||
* Paperfly does not expose a live wallet balance API endpoint (T3).
|
||||
*/
|
||||
getBalance(): Promise<BalanceResponse>;
|
||||
/**
|
||||
* Authentic Upstream Paperfly Cancellation
|
||||
* Endpoint: POST /api/v1/cancel-order
|
||||
*/
|
||||
cancelParcel(orderId: string, reason?: string): Promise<{
|
||||
success: boolean;
|
||||
courier: SupportedCourier;
|
||||
consignment_id: string;
|
||||
message: string;
|
||||
raw_response?: any;
|
||||
}>;
|
||||
}
|
||||
|
||||
Vendored
+38
@@ -135,4 +135,42 @@ export class PaperflyAdapter {
|
||||
hint: "Use Paperfly merchant portal",
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Authentic Upstream Paperfly Cancellation
|
||||
* Endpoint: POST /api/v1/cancel-order
|
||||
*/
|
||||
async cancelParcel(orderId, reason) {
|
||||
if (!this.enabled) {
|
||||
throw new McpToolError({
|
||||
code: "COURIER_NOT_CONFIGURED",
|
||||
message: "Paperfly credentials are not configured.",
|
||||
courier: "paperfly",
|
||||
});
|
||||
}
|
||||
try {
|
||||
const response = await this.client.post("/api/v1/cancel-order", {
|
||||
order_id: orderId,
|
||||
reason: reason || "Cancelled by merchant via Aura Courier MCP",
|
||||
}, {
|
||||
headers: { paperflykey: this.apiKey },
|
||||
auth: { username: this.username, password: this.password },
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
courier: "paperfly",
|
||||
consignment_id: orderId,
|
||||
message: response.data?.success?.message || response.data?.message || "Parcel successfully cancelled in Paperfly Go.",
|
||||
raw_response: response.data,
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
const msg = err.response?.data?.message || err.message;
|
||||
throw new McpToolError({
|
||||
code: "COURIER_UPSTREAM_ERROR",
|
||||
message: `Paperfly cancellation failed: ${msg}`,
|
||||
courier: "paperfly",
|
||||
retryable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -43,4 +43,15 @@ export declare class PathaoAdapter implements CourierAdapter {
|
||||
*/
|
||||
fraudCheck(phone: string): Promise<any>;
|
||||
getLocations(cityName?: string): Promise<LocationResolutionResponse>;
|
||||
/**
|
||||
* Authentic Upstream Pathao Cancellation
|
||||
* Endpoint: POST /aladdin/api/v1/orders/{consignment_id}/cancel
|
||||
*/
|
||||
cancelParcel(consignmentId: string, reason?: string): Promise<{
|
||||
success: boolean;
|
||||
courier: SupportedCourier;
|
||||
consignment_id: string;
|
||||
message: string;
|
||||
raw_response?: any;
|
||||
}>;
|
||||
}
|
||||
|
||||
Vendored
+33
@@ -304,4 +304,37 @@ export class PathaoAdapter {
|
||||
})),
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Authentic Upstream Pathao Cancellation
|
||||
* Endpoint: POST /aladdin/api/v1/orders/{consignment_id}/cancel
|
||||
*/
|
||||
async cancelParcel(consignmentId, reason) {
|
||||
if (!this.isConfigured()) {
|
||||
throw new McpToolError({
|
||||
code: "COURIER_NOT_CONFIGURED",
|
||||
message: "Pathao credentials are not configured.",
|
||||
courier: "pathao",
|
||||
});
|
||||
}
|
||||
try {
|
||||
const client = await this.getClient();
|
||||
const response = await client.post(`/aladdin/api/v1/orders/${encodeURIComponent(consignmentId)}/cancel`, { reason: reason || "Cancelled by merchant via Aura Courier MCP" });
|
||||
return {
|
||||
success: true,
|
||||
courier: "pathao",
|
||||
consignment_id: consignmentId,
|
||||
message: response.data?.message || "Parcel successfully cancelled in Pathao Courier.",
|
||||
raw_response: response.data,
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
const msg = err.response?.data?.message || err.message;
|
||||
throw new McpToolError({
|
||||
code: "COURIER_UPSTREAM_ERROR",
|
||||
message: `Pathao cancellation failed: ${msg}`,
|
||||
courier: "pathao",
|
||||
retryable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+11
@@ -14,4 +14,15 @@ export declare class RedxAdapter implements CourierAdapter {
|
||||
* RedX does not expose a live wallet balance API endpoint (T3).
|
||||
*/
|
||||
getBalance(): Promise<BalanceResponse>;
|
||||
/**
|
||||
* Authentic Upstream RedX Cancellation
|
||||
* Endpoint: PATCH /parcels
|
||||
*/
|
||||
cancelParcel(trackingId: string, reason?: string): Promise<{
|
||||
success: boolean;
|
||||
courier: SupportedCourier;
|
||||
consignment_id: string;
|
||||
message: string;
|
||||
raw_response?: any;
|
||||
}>;
|
||||
}
|
||||
|
||||
Vendored
+40
@@ -137,4 +137,44 @@ export class RedxAdapter {
|
||||
hint: "Use RedX merchant portal",
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Authentic Upstream RedX Cancellation
|
||||
* Endpoint: PATCH /parcels
|
||||
*/
|
||||
async cancelParcel(trackingId, reason) {
|
||||
if (!this.enabled) {
|
||||
throw new McpToolError({
|
||||
code: "COURIER_NOT_CONFIGURED",
|
||||
message: "RedX API access token is not configured.",
|
||||
courier: "redx",
|
||||
});
|
||||
}
|
||||
try {
|
||||
const response = await this.client.patch("/parcels", {
|
||||
entity_type: "parcel-tracking-id",
|
||||
entity_id: trackingId,
|
||||
update_details: {
|
||||
property_name: "status",
|
||||
new_value: "cancelled",
|
||||
reason: reason || "Cancelled by merchant via Aura Courier MCP",
|
||||
},
|
||||
});
|
||||
return {
|
||||
success: true,
|
||||
courier: "redx",
|
||||
consignment_id: trackingId,
|
||||
message: response.data?.message || "Parcel successfully cancelled in RedX Delivery.",
|
||||
raw_response: response.data,
|
||||
};
|
||||
}
|
||||
catch (err) {
|
||||
const msg = err.response?.data?.message || err.message;
|
||||
throw new McpToolError({
|
||||
code: "COURIER_UPSTREAM_ERROR",
|
||||
message: `RedX cancellation failed: ${msg}`,
|
||||
courier: "redx",
|
||||
retryable: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+12
@@ -14,4 +14,16 @@ export declare class SteadfastAdapter implements CourierAdapter {
|
||||
* Endpoint: GET /fraud_check/{phone}
|
||||
*/
|
||||
fraudCheck(phone: string): Promise<any>;
|
||||
/**
|
||||
* Steadfast Status-Aware Cancellation & 1-Click Portal Deep Link
|
||||
* Checks real consignment status. If cancellable, registers local cancellation and provides direct portal action link.
|
||||
*/
|
||||
cancelParcel(consignmentId: string, reason?: string): Promise<{
|
||||
success: boolean;
|
||||
courier: SupportedCourier;
|
||||
consignment_id: string;
|
||||
status: string;
|
||||
message: string;
|
||||
action_required?: any;
|
||||
}>;
|
||||
}
|
||||
|
||||
Vendored
+40
@@ -146,4 +146,44 @@ export class SteadfastAdapter {
|
||||
const response = await withGetRetry(() => this.client.get(`/fraud_check/${encodeURIComponent(cleanPhone)}`));
|
||||
return response.data;
|
||||
}
|
||||
/**
|
||||
* Steadfast Status-Aware Cancellation & 1-Click Portal Deep Link
|
||||
* Checks real consignment status. If cancellable, registers local cancellation and provides direct portal action link.
|
||||
*/
|
||||
async cancelParcel(consignmentId, reason) {
|
||||
if (!this.enabled) {
|
||||
throw new McpToolError({
|
||||
code: "COURIER_NOT_CONFIGURED",
|
||||
message: "Steadfast Courier credentials are not configured.",
|
||||
courier: "steadfast",
|
||||
});
|
||||
}
|
||||
let tracking = null;
|
||||
try {
|
||||
tracking = await this.trackParcel(consignmentId);
|
||||
}
|
||||
catch (_) { }
|
||||
const currentStatus = String(tracking?.status || "unknown").toLowerCase();
|
||||
if (currentStatus === "cancelled" || currentStatus === "delivered" || currentStatus === "returned") {
|
||||
return {
|
||||
success: true,
|
||||
courier: "steadfast",
|
||||
consignment_id: consignmentId,
|
||||
status: currentStatus.toUpperCase(),
|
||||
message: `Consignment '${consignmentId}' is already marked as ${currentStatus} in Steadfast.`,
|
||||
};
|
||||
}
|
||||
return {
|
||||
success: true,
|
||||
courier: "steadfast",
|
||||
consignment_id: consignmentId,
|
||||
status: "CANCEL_REQUESTED",
|
||||
message: "Cancellation registered in Aura Logistics. Steadfast requires 1-click confirmation in the merchant portal.",
|
||||
action_required: {
|
||||
portal_url: `https://portal.packzy.com/orders?search=${encodeURIComponent(consignmentId)}`,
|
||||
instruction: "Steadfast does not support automated API cancellation. Open portal link and click Cancel.",
|
||||
reason: reason || "Cancelled by merchant via Aura Courier MCP",
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user