@fruggr/zendesk-mcp-server 2.22.0 → 2.22.2

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.
Files changed (2) hide show
  1. package/dist/index.js +19 -8
  2. package/package.json +4 -3
package/dist/index.js CHANGED
@@ -1388,17 +1388,24 @@ const formatMacro = (macro) => {
1388
1388
  ...actions.map(formatMacroAction)
1389
1389
  ].filter(Boolean).join("\n");
1390
1390
  };
1391
- const minutesUntil = (iso) => {
1391
+ const minutesUntil = (iso, now) => {
1392
1392
  const t = Date.parse(iso);
1393
- return Number.isNaN(t) ? null : Math.round((t - Date.now()) / 6e4);
1393
+ return Number.isNaN(t) ? null : Math.round((t - now) / 6e4);
1394
1394
  };
1395
- const formatSlaMetric = (m) => {
1395
+ const STAGES_WITHOUT_LIVE_DEADLINE = /* @__PURE__ */ new Set([
1396
+ "paused",
1397
+ "achieved",
1398
+ "fulfilled"
1399
+ ]);
1400
+ const hasRunningStage = (m) => !STAGES_WITHOUT_LIVE_DEADLINE.has(m.stage);
1401
+ const hasPendingDeadline = (m) => hasRunningStage(m) && typeof m.breach_at === "string";
1402
+ const formatSlaMetric = (m, now) => {
1396
1403
  const stage = m.stage ?? "unknown";
1397
1404
  const due = m.breach_at ?? null;
1398
1405
  const parts = [`- **${m.metric}** — ${stage}`];
1399
1406
  if (due) {
1400
- const remaining = minutesUntil(due);
1401
- if (stage === "paused" || stage === "achieved" || stage === "fulfilled" || remaining == null) parts.push(`due ${due}`);
1407
+ const remaining = minutesUntil(due, now);
1408
+ if (!hasRunningStage(m) || remaining == null) parts.push(`due ${due}`);
1402
1409
  else if (remaining < 0) parts.push(`due ${due} — breached (${Math.abs(remaining)} min overdue)`);
1403
1410
  else parts.push(`due ${due} — ${remaining} min remaining`);
1404
1411
  }
@@ -1406,10 +1413,14 @@ const formatSlaMetric = (m) => {
1406
1413
  };
1407
1414
  const formatSlaBlock = (entry) => {
1408
1415
  if (!entry?.policy_metrics || entry.policy_metrics.length === 0) return "";
1416
+ const now = Date.now();
1409
1417
  const lines = ["### SLA"];
1410
- const futureBreaches = entry.policy_metrics.map((m) => m.breach_at).map((d) => d ? Date.parse(d) : NaN).filter((t) => !Number.isNaN(t) && t > Date.now());
1411
- if (futureBreaches.length > 0) lines.push(`- **Next breach**: ${new Date(Math.min(...futureBreaches)).toISOString()}`);
1412
- for (const m of entry.policy_metrics) lines.push(formatSlaMetric(m));
1418
+ const soonest = entry.policy_metrics.filter(hasPendingDeadline).map((m) => ({
1419
+ due: m.breach_at,
1420
+ at: Date.parse(m.breach_at)
1421
+ })).filter((d) => !Number.isNaN(d.at) && d.at > now).reduce((best, d) => best && best.at <= d.at ? best : d, void 0);
1422
+ if (soonest) lines.push(`- **Next breach**: ${soonest.due}`);
1423
+ for (const m of entry.policy_metrics) lines.push(formatSlaMetric(m, now));
1413
1424
  return `\n\n${lines.join("\n")}`;
1414
1425
  };
1415
1426
  const withName = (id, names) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fruggr/zendesk-mcp-server",
3
- "version": "2.22.0",
3
+ "version": "2.22.2",
4
4
  "mcpName": "io.github.fruggr/zendesk-mcp-server",
5
5
  "description": "Deep Zendesk MCP server for your AI assistant: search, draft, update and translate Help Center articles and manage Support tickets end to end — comments, triage and image attachments.",
6
6
  "type": "module",
@@ -26,6 +26,7 @@
26
26
  "test:watch": "vitest watch",
27
27
  "test:coverage": "vitest run --coverage",
28
28
  "test:mutation": "stryker run",
29
+ "test:mutation:canary": "node scripts/mutation-canary.mjs",
29
30
  "test:mutation:diff": "node scripts/mutation-scope.mjs diff",
30
31
  "test:mutation:summary": "node scripts/mutation-scope.mjs summary",
31
32
  "test:smoke": "pnpm build && node scripts/smoke-test.mjs",
@@ -101,7 +102,7 @@
101
102
  "@tsconfig/strictest": "^2.0.8",
102
103
  "@types/hast": "^3.0.4",
103
104
  "@types/node": "^22.15.0",
104
- "@vitest/coverage-v8": "^4.1.0",
105
+ "@vitest/coverage-v8": "^5.0.0",
105
106
  "conventional-changelog-conventionalcommits": "^10.2.1",
106
107
  "lefthook": "^2.1.10",
107
108
  "msw": "^2.12.13",
@@ -111,6 +112,6 @@
111
112
  "tsx": "^4.21.0",
112
113
  "typescript": "^7.0.0",
113
114
  "typescript-legacy": "npm:typescript@6.0.3",
114
- "vitest": "^4.1.0"
115
+ "vitest": "^5.0.0"
115
116
  }
116
117
  }