@voxslopuli/teamdynamix-mcp 0.4.2 → 0.5.0
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/README.md +42 -0
- package/index.js +483 -852
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,205 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
WorkspaceWatchService
|
|
4
|
+
} from "./chunk-XSNNBHPV.js";
|
|
5
|
+
import {
|
|
6
|
+
LedgerCorruptError,
|
|
7
|
+
defaultLedgerPath,
|
|
8
|
+
emptyLedger,
|
|
9
|
+
loadLedger
|
|
10
|
+
} from "./chunk-GTVZKRFG.js";
|
|
11
|
+
import {
|
|
12
|
+
CHARACTER_LIMIT,
|
|
13
|
+
LOG_LEVEL,
|
|
14
|
+
SERVER_NAME,
|
|
15
|
+
SERVER_NAME_OVERRIDE,
|
|
16
|
+
SERVER_VERSION,
|
|
17
|
+
SERVER_VERSION_OVERRIDE,
|
|
18
|
+
TEAMDYNAMIX_TOOL_PREFIX,
|
|
19
|
+
assertDeleteToolsEnabled,
|
|
20
|
+
assertWriteToolsEnabled,
|
|
21
|
+
createConfiguredTeamDynamixClient,
|
|
22
|
+
getTeamDynamixConfig,
|
|
23
|
+
getTeamDynamixConfigStatus
|
|
24
|
+
} from "./chunk-MARAUVWU.js";
|
|
2
25
|
|
|
3
26
|
// src/index.ts
|
|
4
27
|
import { McpServer as McpServer2 } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
28
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
29
|
|
|
7
|
-
// src/config.ts
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
|
|
10
|
-
// package.json
|
|
11
|
-
var package_default = {
|
|
12
|
-
name: "@voxslopuli/teamdynamix-mcp",
|
|
13
|
-
version: "0.4.2",
|
|
14
|
-
private: false,
|
|
15
|
-
description: "A production-ready TypeScript MCP server for TeamDynamix",
|
|
16
|
-
keywords: [
|
|
17
|
-
"mcp",
|
|
18
|
-
"model context protocol",
|
|
19
|
-
"server",
|
|
20
|
-
"tdx",
|
|
21
|
-
"teamdynamix",
|
|
22
|
-
"typescript"
|
|
23
|
-
],
|
|
24
|
-
homepage: "https://github.com/voxslopuli/teamdynamix-mcp",
|
|
25
|
-
bugs: {
|
|
26
|
-
url: "https://github.com/voxslopuli/teamdynamix-mcp/issues"
|
|
27
|
-
},
|
|
28
|
-
license: "MIT",
|
|
29
|
-
author: "Grand Slopulissimo <slopulissimo@voxslopuli.org>",
|
|
30
|
-
repository: {
|
|
31
|
-
type: "git",
|
|
32
|
-
url: "git+https://github.com/voxslopuli/teamdynamix-mcp.git"
|
|
33
|
-
},
|
|
34
|
-
bin: "dist/index.js",
|
|
35
|
-
type: "module",
|
|
36
|
-
main: "dist/index.js",
|
|
37
|
-
scripts: {
|
|
38
|
-
build: "tsup",
|
|
39
|
-
postbuild: "node scripts/write-dist-package.js",
|
|
40
|
-
dev: "tsx watch src/index.ts",
|
|
41
|
-
"docs:build": "node scripts/prepare-docs-public.js && vitepress build docs",
|
|
42
|
-
"docs:dev": "vitepress dev docs",
|
|
43
|
-
"docs:preview": "vitepress preview docs",
|
|
44
|
-
format: "oxfmt . --write",
|
|
45
|
-
"format:check": "oxfmt . --check",
|
|
46
|
-
lint: "oxlint .",
|
|
47
|
-
"lint:fix": "oxlint . --fix",
|
|
48
|
-
prepare: "husky",
|
|
49
|
-
start: "node dist/index.js",
|
|
50
|
-
test: "vitest run",
|
|
51
|
-
"test:coverage": "vitest run --coverage",
|
|
52
|
-
typecheck: "tsc --noEmit"
|
|
53
|
-
},
|
|
54
|
-
dependencies: {
|
|
55
|
-
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
56
|
-
"@voxslopuli/teamdynamix-ts": "^0.2.0",
|
|
57
|
-
tablemark: "^4.1.0",
|
|
58
|
-
zod: "^4.6.2"
|
|
59
|
-
},
|
|
60
|
-
devDependencies: {
|
|
61
|
-
"@octokit/rest": "^22.0.1",
|
|
62
|
-
"@types/node": "25.9.2",
|
|
63
|
-
"@vitest/coverage-v8": "^5.0.0",
|
|
64
|
-
husky: "^9.1.7",
|
|
65
|
-
"lint-staged": "^17.5.1",
|
|
66
|
-
ora: "^9.4.1",
|
|
67
|
-
oxfmt: "^0.67.0",
|
|
68
|
-
oxlint: "^1.82.0",
|
|
69
|
-
tsup: "^8.5.1",
|
|
70
|
-
tsx: "^4.23.13",
|
|
71
|
-
typescript: "6.0.3",
|
|
72
|
-
vite: "8.3.0",
|
|
73
|
-
vitepress: "^1.6.4",
|
|
74
|
-
vitest: "5.0.0",
|
|
75
|
-
zx: "^8.8.5"
|
|
76
|
-
},
|
|
77
|
-
"lint-staged": {
|
|
78
|
-
"*.{ts,mts,cts,js,mjs,cjs}": [
|
|
79
|
-
"oxlint --fix --no-error-on-unmatched-pattern",
|
|
80
|
-
"oxfmt --no-error-on-unmatched-pattern --write"
|
|
81
|
-
],
|
|
82
|
-
"*.{json,yaml,yml,md}": [
|
|
83
|
-
"oxfmt --no-error-on-unmatched-pattern --write"
|
|
84
|
-
]
|
|
85
|
-
},
|
|
86
|
-
packageManager: "pnpm@10.32.1",
|
|
87
|
-
pnpm: {
|
|
88
|
-
overrides: {
|
|
89
|
-
hono: ">=4.12.18",
|
|
90
|
-
"@hono/node-server": ">=1.19.13"
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
mcpName: "io.github.selfagency/teamdynamix-mcp"
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// src/constants.ts
|
|
97
|
-
var SERVER_NAME = "teamdynamix-mcp";
|
|
98
|
-
var SERVER_VERSION = package_default.version;
|
|
99
|
-
var CHARACTER_LIMIT = 25e3;
|
|
100
|
-
var TEAMDYNAMIX_TOOL_PREFIX = "teamdynamix";
|
|
101
|
-
var TEAMDYNAMIX_DEFAULT_TIMEOUT_MS = 3e4;
|
|
102
|
-
var TEAMDYNAMIX_DEFAULT_MAX_RETRIES = 2;
|
|
103
|
-
var TEAMDYNAMIX_MAX_RETRY_ATTEMPTS = 5;
|
|
104
|
-
|
|
105
|
-
// src/config.ts
|
|
106
|
-
var SERVER_NAME_OVERRIDE = process.env["MCP_SERVER_NAME"]?.trim() || void 0;
|
|
107
|
-
var SERVER_VERSION_OVERRIDE = process.env["MCP_SERVER_VERSION"]?.trim() || void 0;
|
|
108
|
-
var validLogLevels = ["debug", "info", "warn", "error"];
|
|
109
|
-
var logLevelSchema = z.enum(validLogLevels);
|
|
110
|
-
var parsedLogLevel = logLevelSchema.safeParse(process.env["MCP_LOG_LEVEL"]?.trim());
|
|
111
|
-
var LOG_LEVEL = parsedLogLevel.success ? parsedLogLevel.data : "info";
|
|
112
|
-
function normalizeOptionalString(value) {
|
|
113
|
-
const normalized = value?.trim();
|
|
114
|
-
return normalized ? normalized : void 0;
|
|
115
|
-
}
|
|
116
|
-
function normalizeOptionalNumber(value) {
|
|
117
|
-
if (!value?.trim()) {
|
|
118
|
-
return void 0;
|
|
119
|
-
}
|
|
120
|
-
const parsed = Number.parseInt(value, 10);
|
|
121
|
-
return Number.isFinite(parsed) && parsed > 0 ? parsed : void 0;
|
|
122
|
-
}
|
|
123
|
-
function normalizeBoolean(value, defaultValue) {
|
|
124
|
-
if (!value) {
|
|
125
|
-
return defaultValue;
|
|
126
|
-
}
|
|
127
|
-
const normalized = value.trim().toLowerCase();
|
|
128
|
-
if (normalized === "true") return true;
|
|
129
|
-
if (normalized === "false") return false;
|
|
130
|
-
return defaultValue;
|
|
131
|
-
}
|
|
132
|
-
function normalizeNumberWithDefault(value, defaultValue, minimum) {
|
|
133
|
-
if (!value?.trim()) {
|
|
134
|
-
return defaultValue;
|
|
135
|
-
}
|
|
136
|
-
const parsed = Number.parseInt(value, 10);
|
|
137
|
-
return Number.isFinite(parsed) && parsed >= minimum ? parsed : defaultValue;
|
|
138
|
-
}
|
|
139
|
-
function normalizeTeamDynamixBaseUrl(value) {
|
|
140
|
-
const normalized = normalizeOptionalString(value);
|
|
141
|
-
return normalized ? normalized.replace(/\/+$/, "") : void 0;
|
|
142
|
-
}
|
|
143
|
-
function validateHttpsBaseUrl(value) {
|
|
144
|
-
if (!value) return void 0;
|
|
145
|
-
const schema = z.string().url().refine((url) => url.startsWith("https://"), {
|
|
146
|
-
message: "TEAMDYNAMIX_BASE_URL must be an https URL."
|
|
147
|
-
});
|
|
148
|
-
const parsed = schema.safeParse(value);
|
|
149
|
-
if (!parsed.success) {
|
|
150
|
-
throw new Error(parsed.error.issues[0]?.message ?? "Invalid TEAMDYNAMIX_BASE_URL.");
|
|
151
|
-
}
|
|
152
|
-
return value;
|
|
153
|
-
}
|
|
154
|
-
function normalizeTeamDynamixAuthMode(value) {
|
|
155
|
-
return value?.trim().toLowerCase() === "admin" ? "admin" : "standard";
|
|
156
|
-
}
|
|
157
|
-
function getTeamDynamixConfig() {
|
|
158
|
-
const baseUrl = validateHttpsBaseUrl(normalizeTeamDynamixBaseUrl(process.env["TEAMDYNAMIX_BASE_URL"]));
|
|
159
|
-
const maxRetries = normalizeNumberWithDefault(
|
|
160
|
-
process.env["TEAMDYNAMIX_MAX_RETRIES"],
|
|
161
|
-
TEAMDYNAMIX_DEFAULT_MAX_RETRIES,
|
|
162
|
-
0
|
|
163
|
-
);
|
|
164
|
-
if (maxRetries > 5) {
|
|
165
|
-
throw new Error(`TEAMDYNAMIX_MAX_RETRIES must be between 0 and ${TEAMDYNAMIX_MAX_RETRY_ATTEMPTS}.`);
|
|
166
|
-
}
|
|
167
|
-
return {
|
|
168
|
-
baseUrl,
|
|
169
|
-
authMode: normalizeTeamDynamixAuthMode(process.env["TEAMDYNAMIX_AUTH_MODE"]),
|
|
170
|
-
username: normalizeOptionalString(process.env["TEAMDYNAMIX_USERNAME"]),
|
|
171
|
-
password: normalizeOptionalString(process.env["TEAMDYNAMIX_PASSWORD"]),
|
|
172
|
-
beid: normalizeOptionalString(process.env["TEAMDYNAMIX_BEID"]),
|
|
173
|
-
webServicesKey: normalizeOptionalString(process.env["TEAMDYNAMIX_WEB_SERVICES_KEY"]),
|
|
174
|
-
defaultTicketAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_TICKET_APP_ID"]),
|
|
175
|
-
defaultAssetAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_ASSET_APP_ID"]),
|
|
176
|
-
defaultKnowledgeBaseAppId: normalizeOptionalNumber(process.env["TEAMDYNAMIX_DEFAULT_KB_APP_ID"]),
|
|
177
|
-
timeoutMs: normalizeNumberWithDefault(process.env["TEAMDYNAMIX_TIMEOUT_MS"], TEAMDYNAMIX_DEFAULT_TIMEOUT_MS, 1e3),
|
|
178
|
-
maxRetries,
|
|
179
|
-
enableWriteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_WRITE_TOOLS"], false),
|
|
180
|
-
enableAdminTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_ADMIN_TOOLS"], false),
|
|
181
|
-
enableDeleteTools: normalizeBoolean(process.env["TEAMDYNAMIX_ENABLE_DELETE_TOOLS"], false)
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function getTeamDynamixConfigStatus(config = getTeamDynamixConfig()) {
|
|
185
|
-
const missing = /* @__PURE__ */ new Set();
|
|
186
|
-
if (!config.baseUrl) {
|
|
187
|
-
missing.add("TEAMDYNAMIX_BASE_URL");
|
|
188
|
-
}
|
|
189
|
-
if (config.authMode === "admin") {
|
|
190
|
-
if (!config.beid) missing.add("TEAMDYNAMIX_BEID");
|
|
191
|
-
if (!config.webServicesKey) missing.add("TEAMDYNAMIX_WEB_SERVICES_KEY");
|
|
192
|
-
} else {
|
|
193
|
-
if (!config.username) missing.add("TEAMDYNAMIX_USERNAME");
|
|
194
|
-
if (!config.password) missing.add("TEAMDYNAMIX_PASSWORD");
|
|
195
|
-
}
|
|
196
|
-
return {
|
|
197
|
-
configured: missing.size === 0,
|
|
198
|
-
missing: [...missing],
|
|
199
|
-
authMode: config.authMode
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
|
-
|
|
203
30
|
// src/resources/teamdynamix.resources.ts
|
|
204
31
|
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
205
32
|
|
|
@@ -223,629 +50,229 @@ function redactTeamDynamixConfig(config) {
|
|
|
223
50
|
}
|
|
224
51
|
|
|
225
52
|
// src/tools/teamdynamix.domain-gateways.tools.ts
|
|
226
|
-
import { z as
|
|
53
|
+
import { z as z3 } from "zod";
|
|
227
54
|
|
|
228
55
|
// src/schemas/teamdynamix/index.ts
|
|
229
|
-
import { z as
|
|
56
|
+
import { z as z2 } from "zod";
|
|
230
57
|
|
|
231
58
|
// src/schemas/index.ts
|
|
232
|
-
import { z
|
|
233
|
-
var ResponseFormatSchema =
|
|
234
|
-
var TextTransformModeSchema =
|
|
59
|
+
import { z } from "zod";
|
|
60
|
+
var ResponseFormatSchema = z.enum(["markdown", "json"]).default("markdown").describe("Output format for the response.");
|
|
61
|
+
var TextTransformModeSchema = z.enum(["uppercase", "lowercase", "trim", "slug"]).describe("Transformation mode to apply to the input text.");
|
|
235
62
|
|
|
236
63
|
// src/schemas/teamdynamix/index.ts
|
|
237
|
-
var TeamDynamixAppIdSchema =
|
|
238
|
-
var IsoDateSchema =
|
|
64
|
+
var TeamDynamixAppIdSchema = z2.number().int().positive().describe("TeamDynamix application ID.");
|
|
65
|
+
var IsoDateSchema = z2.string().regex(
|
|
239
66
|
/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/,
|
|
240
67
|
"Must be a valid ISO 8601 date string."
|
|
241
68
|
);
|
|
242
|
-
var TeamDynamixGuidSchema =
|
|
69
|
+
var TeamDynamixGuidSchema = z2.string().uuid().describe("TeamDynamix GUID identifier.");
|
|
243
70
|
var TeamDynamixResponseFormatSchema = ResponseFormatSchema;
|
|
244
|
-
var TicketSearchSchema =
|
|
245
|
-
Keywords:
|
|
246
|
-
MaxResults:
|
|
247
|
-
StatusIDs:
|
|
248
|
-
TypeIDs:
|
|
249
|
-
PriorityIDs:
|
|
250
|
-
UrgencyIDs:
|
|
251
|
-
ImpactIDs:
|
|
252
|
-
AccountIDs:
|
|
253
|
-
ResponsibleGroupIDs:
|
|
254
|
-
ResponsibleUids:
|
|
255
|
-
RequestorUids:
|
|
71
|
+
var TicketSearchSchema = z2.object({
|
|
72
|
+
Keywords: z2.string().max(500).optional().describe("Full-text search term."),
|
|
73
|
+
MaxResults: z2.number().int().min(1).max(1e3).optional().default(50).describe("Maximum results to return (1\u20131000)."),
|
|
74
|
+
StatusIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket status IDs."),
|
|
75
|
+
TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket type IDs."),
|
|
76
|
+
PriorityIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket priority IDs."),
|
|
77
|
+
UrgencyIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket urgency IDs."),
|
|
78
|
+
ImpactIDs: z2.array(z2.number().int()).optional().describe("Filter by ticket impact IDs."),
|
|
79
|
+
AccountIDs: z2.array(z2.number().int()).optional().describe("Filter by account/department IDs."),
|
|
80
|
+
ResponsibleGroupIDs: z2.array(z2.number().int()).optional().describe("Filter by responsible group IDs."),
|
|
81
|
+
ResponsibleUids: z2.array(z2.string().uuid()).optional().describe("Filter by responsible user GUIDs."),
|
|
82
|
+
RequestorUids: z2.array(z2.string().uuid()).optional().describe("Filter by requestor user GUIDs."),
|
|
256
83
|
CreatedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for creation date filter."),
|
|
257
84
|
CreatedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for creation date filter."),
|
|
258
85
|
ModifiedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for last-modified filter."),
|
|
259
86
|
ModifiedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for last-modified filter."),
|
|
260
87
|
ClosedDateFrom: IsoDateSchema.optional().describe("ISO 8601 start date for closed date filter."),
|
|
261
88
|
ClosedDateTo: IsoDateSchema.optional().describe("ISO 8601 end date for closed date filter."),
|
|
262
|
-
SortBy:
|
|
263
|
-
SortOrder:
|
|
89
|
+
SortBy: z2.string().max(100).optional().describe("Field name to sort results by."),
|
|
90
|
+
SortOrder: z2.enum(["A", "D"]).optional().describe("Sort order: A = ascending, D = descending.")
|
|
264
91
|
});
|
|
265
|
-
var TicketCreateSchema =
|
|
266
|
-
TypeID:
|
|
267
|
-
Title:
|
|
268
|
-
AccountID:
|
|
269
|
-
StatusID:
|
|
270
|
-
PriorityID:
|
|
271
|
-
UrgencyID:
|
|
272
|
-
ImpactID:
|
|
273
|
-
SourceID:
|
|
274
|
-
Description:
|
|
275
|
-
RequestorUID:
|
|
276
|
-
ResponsibleUID:
|
|
277
|
-
ResponsibleGroupID:
|
|
278
|
-
FormID:
|
|
279
|
-
Attributes:
|
|
280
|
-
|
|
281
|
-
ID:
|
|
282
|
-
Value:
|
|
92
|
+
var TicketCreateSchema = z2.object({
|
|
93
|
+
TypeID: z2.number().int().positive().describe("Ticket type ID."),
|
|
94
|
+
Title: z2.string().min(1).max(500).describe("Ticket title/subject."),
|
|
95
|
+
AccountID: z2.number().int().positive().optional().describe("Account/department ID."),
|
|
96
|
+
StatusID: z2.number().int().nonnegative().optional().describe("Initial ticket status ID."),
|
|
97
|
+
PriorityID: z2.number().int().nonnegative().optional().describe("Ticket priority ID."),
|
|
98
|
+
UrgencyID: z2.number().int().nonnegative().optional().describe("Ticket urgency ID."),
|
|
99
|
+
ImpactID: z2.number().int().nonnegative().optional().describe("Ticket impact ID."),
|
|
100
|
+
SourceID: z2.number().int().nonnegative().optional().describe("Ticket source ID."),
|
|
101
|
+
Description: z2.string().max(65535).optional().describe("Full description/body of the ticket (HTML supported)."),
|
|
102
|
+
RequestorUID: z2.string().uuid().optional().describe("GUID of the requestor."),
|
|
103
|
+
ResponsibleUID: z2.string().uuid().optional().describe("GUID of the responsible technician."),
|
|
104
|
+
ResponsibleGroupID: z2.number().int().positive().optional().describe("Responsible group ID."),
|
|
105
|
+
FormID: z2.number().int().positive().optional().describe("Ticket form ID."),
|
|
106
|
+
Attributes: z2.array(
|
|
107
|
+
z2.object({
|
|
108
|
+
ID: z2.number().int(),
|
|
109
|
+
Value: z2.string()
|
|
283
110
|
})
|
|
284
111
|
).optional().describe("Custom attribute values.")
|
|
285
112
|
});
|
|
286
|
-
var TicketPatchSchema =
|
|
287
|
-
TicketID:
|
|
288
|
-
Attributes:
|
|
113
|
+
var TicketPatchSchema = z2.object({
|
|
114
|
+
TicketID: z2.number().int().positive().describe("Ticket ID to update."),
|
|
115
|
+
Attributes: z2.record(z2.string().max(100), z2.string().max(65535)).refine((obj) => Object.keys(obj).length <= 50, { message: "Attributes may contain at most 50 fields per update." }).describe(
|
|
289
116
|
'Fields to update as key/value pairs. Keys must be valid ticket field names (e.g. "StatusID", "Title", "ResponsibleUID"). Maximum 50 fields per update.'
|
|
290
117
|
),
|
|
291
|
-
NotifyRequestor:
|
|
292
|
-
NotifyResponsible:
|
|
293
|
-
Comments:
|
|
294
|
-
IsPrivate:
|
|
295
|
-
});
|
|
296
|
-
var TicketCommentSchema = z3.object({
|
|
297
|
-
TicketID: z3.number().int().positive().describe("Ticket ID to comment on."),
|
|
298
|
-
Body: z3.string().min(1).max(65535).describe("Comment body (HTML supported)."),
|
|
299
|
-
IsPrivate: z3.boolean().optional().default(false).describe("Whether this comment is private."),
|
|
300
|
-
NotifyRequestor: z3.boolean().optional().default(false).describe("Notify the requestor."),
|
|
301
|
-
NotifyResponsible: z3.boolean().optional().default(false).describe("Notify the responsible technician.")
|
|
302
|
-
});
|
|
303
|
-
var UserSearchSchema = z3.object({
|
|
304
|
-
SearchText: z3.string().max(500).optional().describe("Name, username, or email to search for."),
|
|
305
|
-
IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
|
|
306
|
-
IsEmployee: z3.boolean().optional().describe("Filter to employees only."),
|
|
307
|
-
AppID: z3.number().int().positive().optional().describe("Scope search to a specific application."),
|
|
308
|
-
MaxResults: z3.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
|
|
309
|
-
});
|
|
310
|
-
var GroupSearchSchema = z3.object({
|
|
311
|
-
NameLike: z3.string().max(500).optional().describe("Partial group name to search."),
|
|
312
|
-
IsActive: z3.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
|
|
313
|
-
AppID: z3.number().int().positive().optional().describe("Scope search to a specific application.")
|
|
118
|
+
NotifyRequestor: z2.boolean().optional().default(false).describe("Notify the requestor of the change."),
|
|
119
|
+
NotifyResponsible: z2.boolean().optional().default(false).describe("Notify the responsible technician of the change."),
|
|
120
|
+
Comments: z2.string().max(65535).optional().describe("Comment to attach to this update."),
|
|
121
|
+
IsPrivate: z2.boolean().optional().default(false).describe("Whether the comment is private.")
|
|
314
122
|
});
|
|
315
|
-
var
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
123
|
+
var TicketCommentSchema = z2.object({
|
|
124
|
+
TicketID: z2.number().int().positive().describe("Ticket ID to comment on."),
|
|
125
|
+
Body: z2.string().min(1).max(65535).describe("Comment body (HTML supported)."),
|
|
126
|
+
IsPrivate: z2.boolean().optional().default(false).describe("Whether this comment is private."),
|
|
127
|
+
NotifyRequestor: z2.boolean().optional().default(false).describe("Notify the requestor."),
|
|
128
|
+
NotifyResponsible: z2.boolean().optional().default(false).describe("Notify the responsible technician.")
|
|
320
129
|
});
|
|
321
|
-
var
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
130
|
+
var UserSearchSchema = z2.object({
|
|
131
|
+
SearchText: z2.string().max(500).optional().describe("Name, username, or email to search for."),
|
|
132
|
+
AccountIDs: z2.array(z2.number().int()).optional().describe("Filter by account IDs (default account only)."),
|
|
133
|
+
AlternateID: z2.string().optional().describe("Filter by alternate ID."),
|
|
134
|
+
AppName: z2.string().optional().describe("Filter by system-defined application name."),
|
|
135
|
+
AuthenticationUserName: z2.string().optional().describe("Exact-match authentication username (max one result)."),
|
|
136
|
+
ExternalID: z2.string().optional().describe("Filter by external ID."),
|
|
137
|
+
IsActive: z2.boolean().optional().describe("Filter by active (true) or inactive (false) users."),
|
|
138
|
+
IsConfidential: z2.boolean().optional().describe("Filter by confidential status."),
|
|
139
|
+
IsEmployee: z2.boolean().optional().describe("Filter to employees only."),
|
|
140
|
+
MaxResults: z2.number().int().min(1).max(1e3).optional().describe("Maximum results (1-1000)."),
|
|
141
|
+
PhoneNumber: z2.string().optional().describe("Filter by phone number."),
|
|
142
|
+
ReferenceIDs: z2.array(z2.string()).optional().describe("Filter by user reference IDs (GUIDs)."),
|
|
143
|
+
SecurityRoleID: z2.number().int().optional().describe("Filter by security role ID."),
|
|
144
|
+
UserName: z2.string().optional().describe("Filter by username.")
|
|
145
|
+
}).strict();
|
|
146
|
+
var GroupSearchSchema = z2.object({
|
|
147
|
+
NameLike: z2.string().max(500).optional().describe("Partial group name to search."),
|
|
148
|
+
IsActive: z2.boolean().optional().describe("Filter by active (true) or inactive (false) groups."),
|
|
149
|
+
AssociatedAppID: z2.number().int().positive().optional().describe("Filter by associated application ID."),
|
|
150
|
+
HasAppID: z2.boolean().optional().describe("Filter to groups with (true) or without (false) an associated application."),
|
|
151
|
+
HasSystemAppName: z2.boolean().optional().describe("Filter to groups with (true) or without (false) a system app name.")
|
|
152
|
+
}).strict();
|
|
153
|
+
var KbArticleSearchSchema = z2.object({
|
|
154
|
+
SearchText: z2.string().max(500).optional().describe("Full-text search within articles."),
|
|
155
|
+
AuthorUID: z2.string().uuid().optional().describe("Filter by author GUID."),
|
|
156
|
+
CategoryID: z2.number().int().positive().optional().describe("Filter by KB category ID."),
|
|
157
|
+
CustomAttributes: z2.array(z2.record(z2.string(), z2.unknown())).optional().describe("Filter by custom attributes."),
|
|
158
|
+
IncludeArticleBodies: z2.boolean().optional().describe("Include article bodies in results."),
|
|
159
|
+
IncludeShortcuts: z2.boolean().optional().describe("Include shortcuts in results."),
|
|
160
|
+
IsPublic: z2.boolean().optional().describe("Filter by public visibility."),
|
|
161
|
+
IsPublished: z2.boolean().optional().describe("Filter to published articles only."),
|
|
162
|
+
ReturnCount: z2.number().int().min(1).max(500).optional().describe("Maximum results (1-500)."),
|
|
163
|
+
Status: z2.number().int().optional().describe("Filter by article status ID.")
|
|
164
|
+
}).strict();
|
|
165
|
+
var AssetSearchSchema = z2.object({
|
|
166
|
+
SerialLike: z2.string().max(200).optional().describe("Partial serial number to match."),
|
|
167
|
+
TagLike: z2.string().max(200).optional().describe("Partial asset tag to match."),
|
|
168
|
+
SearchText: z2.string().max(500).optional().describe("General text search across asset fields."),
|
|
169
|
+
StatusIDs: z2.array(z2.number().int()).optional().describe("Filter by asset status IDs."),
|
|
170
|
+
OwnerUID: z2.string().uuid().optional().describe("Filter by asset owner GUID."),
|
|
171
|
+
UsingDepartmentID: z2.number().int().positive().optional().describe("Filter by using department ID."),
|
|
172
|
+
MaxResults: z2.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
|
|
329
173
|
});
|
|
330
|
-
var ServiceSearchSchema =
|
|
331
|
-
SearchText:
|
|
332
|
-
IsActive:
|
|
333
|
-
CategoryID:
|
|
334
|
-
MaxResults:
|
|
174
|
+
var ServiceSearchSchema = z2.object({
|
|
175
|
+
SearchText: z2.string().max(500).optional().describe("Full-text search across service fields."),
|
|
176
|
+
IsActive: z2.boolean().optional().describe("Filter to active services only."),
|
|
177
|
+
CategoryID: z2.number().int().positive().optional().describe("Filter by service category ID."),
|
|
178
|
+
MaxResults: z2.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
|
|
335
179
|
});
|
|
336
|
-
var ProjectSearchSchema =
|
|
337
|
-
NameLike:
|
|
338
|
-
TypeIDs:
|
|
339
|
-
IsActive:
|
|
340
|
-
ManagerUID:
|
|
341
|
-
MaxResults:
|
|
180
|
+
var ProjectSearchSchema = z2.object({
|
|
181
|
+
NameLike: z2.string().max(500).optional().describe("Partial project name to search."),
|
|
182
|
+
TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by project type IDs."),
|
|
183
|
+
IsActive: z2.boolean().optional().describe("Filter to active projects."),
|
|
184
|
+
ManagerUID: z2.string().uuid().optional().describe("Filter by project manager GUID."),
|
|
185
|
+
MaxResults: z2.number().int().min(1).max(500).optional().default(25).describe("Maximum results (1\u2013500).")
|
|
342
186
|
});
|
|
343
|
-
var TicketTaskCreateSchema =
|
|
344
|
-
TicketID:
|
|
345
|
-
Title:
|
|
346
|
-
Description:
|
|
347
|
-
IsActive:
|
|
348
|
-
AssignedUID:
|
|
349
|
-
AssignedGroupID:
|
|
350
|
-
EstimatedMinutes:
|
|
187
|
+
var TicketTaskCreateSchema = z2.object({
|
|
188
|
+
TicketID: z2.number().int().positive().describe("Parent ticket ID."),
|
|
189
|
+
Title: z2.string().min(1).max(500).describe("Task title."),
|
|
190
|
+
Description: z2.string().max(65535).optional().describe("Task description."),
|
|
191
|
+
IsActive: z2.boolean().optional().default(true).describe("Whether the task is active."),
|
|
192
|
+
AssignedUID: z2.string().uuid().optional().describe("GUID of the assigned user."),
|
|
193
|
+
AssignedGroupID: z2.number().int().positive().optional().describe("Assigned group ID."),
|
|
194
|
+
EstimatedMinutes: z2.number().int().nonnegative().optional().describe("Estimated minutes to complete."),
|
|
351
195
|
StartDate: IsoDateSchema.optional().describe("Task start date (ISO 8601)."),
|
|
352
196
|
EndDate: IsoDateSchema.optional().describe("Task due date (ISO 8601).")
|
|
353
197
|
});
|
|
354
|
-
var KbArticleCreateSchema =
|
|
355
|
-
Subject:
|
|
356
|
-
Body:
|
|
357
|
-
Summary:
|
|
358
|
-
CategoryID:
|
|
359
|
-
IsPublished:
|
|
360
|
-
Tags:
|
|
198
|
+
var KbArticleCreateSchema = z2.object({
|
|
199
|
+
Subject: z2.string().min(1).max(500).describe("Article title/subject."),
|
|
200
|
+
Body: z2.string().min(1).max(5e5).describe("Article body content (HTML supported)."),
|
|
201
|
+
Summary: z2.string().max(2e3).optional().describe("Short article summary."),
|
|
202
|
+
CategoryID: z2.number().int().positive().optional().describe("KB category ID."),
|
|
203
|
+
IsPublished: z2.boolean().optional().default(false).describe("Whether to publish the article immediately."),
|
|
204
|
+
Tags: z2.string().max(1e3).optional().describe("Comma-separated tags for the article.")
|
|
361
205
|
});
|
|
362
206
|
var KbArticleUpdateSchema = KbArticleCreateSchema.partial().extend({
|
|
363
|
-
ArticleID:
|
|
207
|
+
ArticleID: z2.number().int().positive().describe("KB article ID to update.")
|
|
364
208
|
});
|
|
365
|
-
var CiSearchSchema =
|
|
366
|
-
SearchText:
|
|
367
|
-
TypeIDs:
|
|
368
|
-
OwnerUID:
|
|
369
|
-
MaxResults:
|
|
209
|
+
var CiSearchSchema = z2.object({
|
|
210
|
+
SearchText: z2.string().max(500).optional().describe("Full-text search across CI fields."),
|
|
211
|
+
TypeIDs: z2.array(z2.number().int()).optional().describe("Filter by CI type IDs."),
|
|
212
|
+
OwnerUID: z2.string().uuid().optional().describe("Filter by owner GUID."),
|
|
213
|
+
MaxResults: z2.number().int().min(1).max(1e3).optional().default(25).describe("Maximum results (1\u20131000).")
|
|
370
214
|
});
|
|
371
|
-
var CustomAttributeComponentIdSchema =
|
|
215
|
+
var CustomAttributeComponentIdSchema = z2.number().int().positive().describe(
|
|
372
216
|
"TeamDynamix component ID for the attribute context. Common values: 9 = Ticket, 27 = Asset, 63 = KB Article, 31 = Person."
|
|
373
217
|
);
|
|
374
|
-
var ProjectIssueCreateSchema =
|
|
375
|
-
Title:
|
|
376
|
-
Description:
|
|
377
|
-
AssignedUID:
|
|
378
|
-
StatusID:
|
|
379
|
-
PriorityID:
|
|
218
|
+
var ProjectIssueCreateSchema = z2.object({
|
|
219
|
+
Title: z2.string().min(1).max(500).describe("Issue title."),
|
|
220
|
+
Description: z2.string().max(65535).optional().describe("Issue description."),
|
|
221
|
+
AssignedUID: z2.string().uuid().optional().describe("GUID of the assigned user."),
|
|
222
|
+
StatusID: z2.number().int().nonnegative().optional().describe("Issue status ID."),
|
|
223
|
+
PriorityID: z2.number().int().nonnegative().optional().describe("Issue priority ID."),
|
|
380
224
|
DueDate: IsoDateSchema.optional().describe("Issue due date (ISO 8601).")
|
|
381
225
|
});
|
|
382
|
-
var ProjectRiskCreateSchema =
|
|
383
|
-
Title:
|
|
384
|
-
Description:
|
|
385
|
-
AssignedUID:
|
|
386
|
-
StatusID:
|
|
387
|
-
Probability:
|
|
388
|
-
Impact:
|
|
226
|
+
var ProjectRiskCreateSchema = z2.object({
|
|
227
|
+
Title: z2.string().min(1).max(500).describe("Risk title."),
|
|
228
|
+
Description: z2.string().max(65535).optional().describe("Risk description."),
|
|
229
|
+
AssignedUID: z2.string().uuid().optional().describe("GUID of the risk owner."),
|
|
230
|
+
StatusID: z2.number().int().nonnegative().optional().describe("Risk status ID."),
|
|
231
|
+
Probability: z2.number().int().min(1).max(100).optional().describe("Probability percentage (1\u2013100)."),
|
|
232
|
+
Impact: z2.number().int().min(1).max(5).optional().describe("Impact level (1 = low, 5 = critical)."),
|
|
389
233
|
DueDate: IsoDateSchema.optional().describe("Risk resolution due date (ISO 8601).")
|
|
390
234
|
});
|
|
391
|
-
var TimeEntryQuerySchema =
|
|
235
|
+
var TimeEntryQuerySchema = z2.object({
|
|
392
236
|
StartDate: IsoDateSchema.describe("Start date for time entries query (ISO 8601 date, e.g. 2026-01-01)."),
|
|
393
237
|
EndDate: IsoDateSchema.describe("End date for time entries query (ISO 8601 date, e.g. 2026-01-31).")
|
|
394
238
|
});
|
|
395
|
-
var TeamDynamixEntitySchema =
|
|
396
|
-
var TeamDynamixNamedEntitySchema =
|
|
397
|
-
ID:
|
|
398
|
-
Name:
|
|
399
|
-
}).catchall(
|
|
239
|
+
var TeamDynamixEntitySchema = z2.record(z2.string(), z2.unknown()).describe("Base TeamDynamix entity with flexible additional fields");
|
|
240
|
+
var TeamDynamixNamedEntitySchema = z2.object({
|
|
241
|
+
ID: z2.number().int().positive("ID must be a positive integer"),
|
|
242
|
+
Name: z2.string().optional()
|
|
243
|
+
}).catchall(z2.unknown()).describe("TeamDynamix entity with ID and optional Name");
|
|
400
244
|
var TeamDynamixApplicationSchema = TeamDynamixNamedEntitySchema.extend({
|
|
401
|
-
Name:
|
|
245
|
+
Name: z2.string().optional()
|
|
402
246
|
}).describe("TeamDynamix Application entity");
|
|
403
247
|
var TeamDynamixTicketSchema = TeamDynamixNamedEntitySchema.extend({
|
|
404
|
-
Title:
|
|
405
|
-
Description:
|
|
406
|
-
StatusID:
|
|
407
|
-
TypeID:
|
|
248
|
+
Title: z2.string().optional(),
|
|
249
|
+
Description: z2.string().optional(),
|
|
250
|
+
StatusID: z2.number().int().optional(),
|
|
251
|
+
TypeID: z2.number().int().optional()
|
|
408
252
|
}).describe("TeamDynamix Ticket entity");
|
|
409
253
|
var TeamDynamixKbArticleSchema = TeamDynamixNamedEntitySchema.extend({
|
|
410
|
-
Subject:
|
|
411
|
-
Body:
|
|
412
|
-
IsPublished:
|
|
254
|
+
Subject: z2.string().optional(),
|
|
255
|
+
Body: z2.string().optional(),
|
|
256
|
+
IsPublished: z2.boolean().optional()
|
|
413
257
|
}).describe("TeamDynamix Knowledge Base Article entity");
|
|
414
258
|
var TeamDynamixAssetSchema = TeamDynamixNamedEntitySchema.extend({
|
|
415
|
-
Tag:
|
|
416
|
-
StatusID:
|
|
259
|
+
Tag: z2.string().optional(),
|
|
260
|
+
StatusID: z2.number().int().optional()
|
|
417
261
|
}).describe("TeamDynamix Asset entity");
|
|
418
262
|
var TeamDynamixProjectSchema = TeamDynamixNamedEntitySchema.extend({
|
|
419
|
-
Status:
|
|
263
|
+
Status: z2.string().optional()
|
|
420
264
|
}).describe("TeamDynamix Project entity");
|
|
421
265
|
var TeamDynamixGroupSchema = TeamDynamixNamedEntitySchema.extend({
|
|
422
|
-
Description:
|
|
266
|
+
Description: z2.string().optional()
|
|
423
267
|
}).describe("TeamDynamix Group entity");
|
|
424
|
-
var TeamDynamixUserSchema =
|
|
425
|
-
UID:
|
|
426
|
-
FullName:
|
|
427
|
-
Email:
|
|
428
|
-
IsActive:
|
|
429
|
-
}).catchall(
|
|
430
|
-
var TeamDynamixListResponseSchema =
|
|
431
|
-
var TeamDynamixSingleResponseSchema =
|
|
432
|
-
|
|
433
|
-
// src/client/sdk-client.factory.ts
|
|
434
|
-
import { existsSync } from "fs";
|
|
435
|
-
import { createRequire } from "module";
|
|
436
|
-
import { dirname, resolve } from "path";
|
|
437
|
-
import { fileURLToPath } from "url";
|
|
438
|
-
import { createTeamDynamixClient, loginWithPassword, loginWithServiceAccount } from "@voxslopuli/teamdynamix-ts";
|
|
439
|
-
var cachedSpecPath;
|
|
440
|
-
function resolveSdkSpecPath() {
|
|
441
|
-
const override = process.env["TEAMDYNAMIX_SPEC_PATH"]?.trim();
|
|
442
|
-
if (override) return override;
|
|
443
|
-
if (cachedSpecPath) return cachedSpecPath;
|
|
444
|
-
try {
|
|
445
|
-
const require2 = createRequire(fileURLToPath(import.meta.url));
|
|
446
|
-
const entryPath = require2.resolve("@voxslopuli/teamdynamix-ts");
|
|
447
|
-
const pkgRoot = dirname(entryPath);
|
|
448
|
-
const candidates = [
|
|
449
|
-
resolve(pkgRoot, "dist/generated/openapi.json"),
|
|
450
|
-
resolve(pkgRoot, "generated/openapi.json"),
|
|
451
|
-
resolve(pkgRoot, "src/generated/openapi.json")
|
|
452
|
-
];
|
|
453
|
-
cachedSpecPath = candidates.find((p) => existsSync(p));
|
|
454
|
-
return cachedSpecPath;
|
|
455
|
-
} catch {
|
|
456
|
-
return void 0;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
function createTokenProvider(config, tenant) {
|
|
460
|
-
if (config.authMode === "admin") {
|
|
461
|
-
if (!config.beid || !config.webServicesKey) {
|
|
462
|
-
throw new Error("BEID and WebServicesKey are required for admin authentication");
|
|
463
|
-
}
|
|
464
|
-
return loginWithServiceAccount({
|
|
465
|
-
tenant,
|
|
466
|
-
baseUrl: config.baseUrl,
|
|
467
|
-
beid: config.beid,
|
|
468
|
-
webServicesKey: config.webServicesKey
|
|
469
|
-
});
|
|
470
|
-
}
|
|
471
|
-
if (!config.username || !config.password) {
|
|
472
|
-
throw new Error("Username and password are required for standard authentication");
|
|
473
|
-
}
|
|
474
|
-
return loginWithPassword({
|
|
475
|
-
tenant,
|
|
476
|
-
baseUrl: config.baseUrl,
|
|
477
|
-
username: config.username,
|
|
478
|
-
password: config.password
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
function extractTenant(baseUrl) {
|
|
482
|
-
const normalized = baseUrl.replace(/\/+$/, "").replace(/\/TDWebApi$/, "");
|
|
483
|
-
const withoutProtocol = normalized.replace(/^https?:\/\//, "");
|
|
484
|
-
const parts = withoutProtocol.split("/");
|
|
485
|
-
return parts[0] ?? "";
|
|
486
|
-
}
|
|
487
|
-
function buildSdkConfig(config, tenant, tokenProvider) {
|
|
488
|
-
return {
|
|
489
|
-
tenant,
|
|
490
|
-
tokenProvider,
|
|
491
|
-
environment: config.baseUrl?.includes("sandbox") ? "sandbox" : "production",
|
|
492
|
-
baseUrl: config.baseUrl,
|
|
493
|
-
timeoutMs: config.timeoutMs,
|
|
494
|
-
runtimeValidationMode: "fail-open",
|
|
495
|
-
...resolveSdkSpecPath() ? { specPath: resolveSdkSpecPath() } : {},
|
|
496
|
-
retryPolicy: {
|
|
497
|
-
maxRetries: config.maxRetries
|
|
498
|
-
}
|
|
499
|
-
};
|
|
500
|
-
}
|
|
501
|
-
async function createMcpSdkClient(config) {
|
|
502
|
-
const tenant = extractTenant(config.baseUrl ?? "");
|
|
503
|
-
const tokenProvider = createTokenProvider(config, tenant);
|
|
504
|
-
const sdkConfig = buildSdkConfig(config, tenant, tokenProvider);
|
|
505
|
-
const { client } = await createTeamDynamixClient(sdkConfig);
|
|
506
|
-
return client;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// src/services/teamdynamix/client.factory.ts
|
|
510
|
-
var TICKET_SEARCH_FIELD_MAP = {
|
|
511
|
-
ResponsibleGroupIDs: "ResponsibilityGroupIDs",
|
|
512
|
-
ResponsibleGroupID: "ResponsibilityGroupID",
|
|
513
|
-
ResponsibleGroups: "ResponsibilityGroupIDs"
|
|
514
|
-
};
|
|
515
|
-
function mapTicketSearchBody(body) {
|
|
516
|
-
const mapped = {};
|
|
517
|
-
for (const [key, value] of Object.entries(body)) {
|
|
518
|
-
if (value === void 0) continue;
|
|
519
|
-
mapped[TICKET_SEARCH_FIELD_MAP[key] ?? key] = value;
|
|
520
|
-
}
|
|
521
|
-
return mapped;
|
|
522
|
-
}
|
|
523
|
-
var UnifiedTeamDynamixClient = class _UnifiedTeamDynamixClient {
|
|
524
|
-
constructor(config) {
|
|
525
|
-
this.config = config;
|
|
526
|
-
}
|
|
527
|
-
config;
|
|
528
|
-
sdkPromise = null;
|
|
529
|
-
sdk() {
|
|
530
|
-
this.sdkPromise ??= createMcpSdkClient(this.config);
|
|
531
|
-
return this.sdkPromise;
|
|
532
|
-
}
|
|
533
|
-
//
|
|
534
|
-
// Discovery
|
|
535
|
-
//
|
|
536
|
-
getCurrentUser() {
|
|
537
|
-
return this.sdk().then((s) => s.discovery.authGetuser());
|
|
538
|
-
}
|
|
539
|
-
listApplications() {
|
|
540
|
-
return this.sdk().then((s) => s.discovery.applications());
|
|
541
|
-
}
|
|
542
|
-
//
|
|
543
|
-
// Tickets
|
|
544
|
-
//
|
|
545
|
-
getTicket(appId, ticketId) {
|
|
546
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsId({ params: { path: { appId, id: ticketId } } }));
|
|
547
|
-
}
|
|
548
|
-
searchTickets(appId, body) {
|
|
549
|
-
return this.sdk().then(async (s) => {
|
|
550
|
-
const { data, error } = await s.POST("/api/{appId}/tickets/search", {
|
|
551
|
-
params: { path: { appId } },
|
|
552
|
-
body: mapTicketSearchBody(body)
|
|
553
|
-
});
|
|
554
|
-
if (error) {
|
|
555
|
-
throw new Error(`Ticket search failed: ${JSON.stringify(error)}`);
|
|
556
|
-
}
|
|
557
|
-
return Array.isArray(data) ? data : [];
|
|
558
|
-
});
|
|
559
|
-
}
|
|
560
|
-
listTicketTypes(appId) {
|
|
561
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsTypes({ params: { path: { appId } } }));
|
|
562
|
-
}
|
|
563
|
-
listTicketPriorities(appId) {
|
|
564
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsPriorities({ params: { path: { appId } } }));
|
|
565
|
-
}
|
|
566
|
-
listTicketUrgencies(appId) {
|
|
567
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsUrgencies({ params: { path: { appId } } }));
|
|
568
|
-
}
|
|
569
|
-
listTicketImpacts(appId) {
|
|
570
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsImpacts({ params: { path: { appId } } }));
|
|
571
|
-
}
|
|
572
|
-
listTicketSources(appId) {
|
|
573
|
-
return this.sdk().then((s) => s.tickets.appIdTicketsSources({ params: { path: { appId } } }));
|
|
574
|
-
}
|
|
575
|
-
/**
|
|
576
|
-
* Upper bound on feed entries we'll fetch replies for. The TDX API allows 60
|
|
577
|
-
* requests/60s; the feed call itself plus one fetch per entry must stay under it.
|
|
578
|
-
*/
|
|
579
|
-
static DEFAULT_REPLIES_ENTRY_LIMIT = 10;
|
|
580
|
-
async getTicketFeed(appId, ticketId, opts = {}) {
|
|
581
|
-
const s = await this.sdk();
|
|
582
|
-
const feed = await s.tickets.appIdTicketsIdFeed({ params: { path: { appId, id: ticketId } } });
|
|
583
|
-
const entries = Array.isArray(feed) ? feed : [];
|
|
584
|
-
const limit = opts.repliesEntryLimit ?? _UnifiedTeamDynamixClient.DEFAULT_REPLIES_ENTRY_LIMIT;
|
|
585
|
-
const missing = entries.filter(
|
|
586
|
-
(e) => typeof e.RepliesCount === "number" && e.RepliesCount > 0 && (!Array.isArray(e.Replies) || e.Replies.length === 0) && typeof e.ID !== "undefined"
|
|
587
|
-
);
|
|
588
|
-
for (const entry of missing.slice(0, limit)) {
|
|
589
|
-
const target = entry;
|
|
590
|
-
const { data, error } = await s.GET("/api/feed/{id}", {
|
|
591
|
-
params: { path: { id: target.ID } }
|
|
592
|
-
});
|
|
593
|
-
if (error) {
|
|
594
|
-
const detail = typeof error === "string" ? error : JSON.stringify(error);
|
|
595
|
-
throw new Error(`Failed to fetch replies for feed entry ${target.ID} (GET /api/feed/{id}): ${detail}`);
|
|
596
|
-
}
|
|
597
|
-
if (data && Array.isArray(data.Replies)) {
|
|
598
|
-
target.Replies = data.Replies;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
return entries;
|
|
602
|
-
}
|
|
603
|
-
//
|
|
604
|
-
// Ticket Relationships
|
|
605
|
-
//
|
|
606
|
-
getTicketTasks(appId, ticketId) {
|
|
607
|
-
return this.sdk().then(
|
|
608
|
-
(s) => s.ticketRelationships.appIdTicketsTicketIdTasks({ params: { path: { appId, ticketId } } })
|
|
609
|
-
);
|
|
610
|
-
}
|
|
611
|
-
createTicketTask(appId, ticketId, body) {
|
|
612
|
-
return this.sdk().then((s) => s.ticketRelationships.createTicketTask({ appId, ticketId, body }));
|
|
613
|
-
}
|
|
614
|
-
listTicketAssets(appId, ticketId) {
|
|
615
|
-
return this.sdk().then(
|
|
616
|
-
(s) => s.ticketRelationships.appIdTicketsIdAssets({ params: { path: { appId, id: ticketId } } })
|
|
617
|
-
);
|
|
618
|
-
}
|
|
619
|
-
addTicketAsset(appId, ticketId, assetId) {
|
|
620
|
-
return this.sdk().then((s) => s.ticketRelationships.addTicketAsset({ appId, ticketId, assetId }));
|
|
621
|
-
}
|
|
622
|
-
removeTicketAsset(appId, ticketId, assetId) {
|
|
623
|
-
return this.sdk().then((s) => {
|
|
624
|
-
s.ticketRelationships.removeTicketAsset({ appId, ticketId, assetId, confirm: true });
|
|
625
|
-
});
|
|
626
|
-
}
|
|
627
|
-
getTicketContacts(appId, ticketId) {
|
|
628
|
-
return this.sdk().then(
|
|
629
|
-
(s) => s.ticketRelationships.appIdTicketsIdContacts({ params: { path: { appId, id: ticketId } } })
|
|
630
|
-
);
|
|
631
|
-
}
|
|
632
|
-
addTicketContact(appId, ticketId, contactUid) {
|
|
633
|
-
return this.sdk().then((s) => s.ticketRelationships.addTicketContact({ appId, ticketId, contactUid }));
|
|
634
|
-
}
|
|
635
|
-
removeTicketContact(appId, ticketId, contactUid) {
|
|
636
|
-
return this.sdk().then((s) => {
|
|
637
|
-
s.ticketRelationships.removeTicketContact({ appId, ticketId, contactUid, confirm: true });
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
//
|
|
641
|
-
// People
|
|
642
|
-
//
|
|
643
|
-
getUser(uid) {
|
|
644
|
-
return this.sdk().then((s) => s.people.peopleUid({ params: { path: { uid } } }));
|
|
645
|
-
}
|
|
646
|
-
searchUsers(body) {
|
|
647
|
-
const searchText = typeof body["SearchText"] === "string" ? body["SearchText"] : "";
|
|
648
|
-
return this.sdk().then((s) => s.people.peopleLookup({ body: { SearchText: searchText } }));
|
|
649
|
-
}
|
|
650
|
-
getGroup(groupId) {
|
|
651
|
-
return this.sdk().then((s) => s.people.groupsId({ params: { path: { id: groupId } } }));
|
|
652
|
-
}
|
|
653
|
-
searchGroups(_body) {
|
|
654
|
-
return this.sdk().then((s) => s.people.searchGroups({ body: {} }));
|
|
655
|
-
}
|
|
656
|
-
getGroupMembers(groupId) {
|
|
657
|
-
return this.sdk().then((s) => s.people.groupsIdMembers({ params: { path: { id: groupId } } }));
|
|
658
|
-
}
|
|
659
|
-
//
|
|
660
|
-
// Knowledge Base
|
|
661
|
-
//
|
|
662
|
-
getKbArticle(appId, articleId) {
|
|
663
|
-
return this.sdk().then((s) => s.knowledgeBase.appIdKnowledgebaseId({ params: { path: { appId, id: articleId } } }));
|
|
664
|
-
}
|
|
665
|
-
searchKbArticles(appId, body) {
|
|
666
|
-
const keyword = typeof body["SearchText"] === "string" ? body["SearchText"] : "";
|
|
667
|
-
return this.sdk().then((s) => s.knowledgeBase.appIdKnowledgebaseId({ params: { path: { appId, id: 0 } } })).then(
|
|
668
|
-
(r) => Array.isArray(r) ? r.filter((item) => {
|
|
669
|
-
const s = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
|
|
670
|
-
return keyword ? s.includes(keyword.toLowerCase()) : true;
|
|
671
|
-
}) : []
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
listKbCategories(appId) {
|
|
675
|
-
return this.sdk().then(
|
|
676
|
-
(s) => s.knowledgeBase.appIdKnowledgebaseCategories({ params: { path: { appId } } })
|
|
677
|
-
);
|
|
678
|
-
}
|
|
679
|
-
//
|
|
680
|
-
// Assets
|
|
681
|
-
//
|
|
682
|
-
getAsset(appId, assetId) {
|
|
683
|
-
return this.sdk().then((s) => s.assets.appIdAssetsId({ params: { path: { appId, id: assetId } } }));
|
|
684
|
-
}
|
|
685
|
-
searchAssets(appId, _body) {
|
|
686
|
-
return this.sdk().then((s) => s.assets.appIdAssetsFeed({ params: { path: { appId } } }));
|
|
687
|
-
}
|
|
688
|
-
listAssetStatuses(appId) {
|
|
689
|
-
return this.sdk().then((s) => s.assets.appIdAssetsStatuses({ params: { path: { appId } } }));
|
|
690
|
-
}
|
|
691
|
-
listProductModels(appId) {
|
|
692
|
-
return this.sdk().then((s) => s.assets.appIdAssetsModels({ params: { path: { appId } } }));
|
|
693
|
-
}
|
|
694
|
-
listVendors(appId) {
|
|
695
|
-
return this.sdk().then((s) => s.cmdb.appIdAssetsVendors({ params: { path: { appId } } }));
|
|
696
|
-
}
|
|
697
|
-
//
|
|
698
|
-
// CMDB
|
|
699
|
-
//
|
|
700
|
-
getConfigurationItem(appId, ciId) {
|
|
701
|
-
return this.sdk().then((s) => s.cmdb.appIdCmdbId({ params: { path: { appId, id: ciId } } }));
|
|
702
|
-
}
|
|
703
|
-
searchConfigurationItems(appId, _body) {
|
|
704
|
-
return this.sdk().then((s) => s.cmdb.appIdCmdbSearches({ params: { path: { appId } } }));
|
|
705
|
-
}
|
|
706
|
-
listCiTypes(appId) {
|
|
707
|
-
return this.sdk().then((s) => s.cmdb.appIdCmdbTypes({ params: { path: { appId } } }));
|
|
708
|
-
}
|
|
709
|
-
listCiRelationshipTypes() {
|
|
710
|
-
return this.sdk().then((s) => s.cmdb.appIdCmdbRelationshiptypes());
|
|
711
|
-
}
|
|
712
|
-
//
|
|
713
|
-
// Services
|
|
714
|
-
//
|
|
715
|
-
listServiceCatalog(appId) {
|
|
716
|
-
return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } }));
|
|
717
|
-
}
|
|
718
|
-
getService(appId, serviceId) {
|
|
719
|
-
return this.sdk().then((s) => s.services.appIdServicesId({ params: { path: { appId, id: serviceId } } }));
|
|
720
|
-
}
|
|
721
|
-
searchServices(appId, body) {
|
|
722
|
-
const keyword = typeof body["Keyword"] === "string" ? body["Keyword"] : "";
|
|
723
|
-
return this.sdk().then((s) => s.services.appIdServices({ params: { path: { appId } } })).then((r) => {
|
|
724
|
-
if (!Array.isArray(r)) return [];
|
|
725
|
-
if (!keyword) return r;
|
|
726
|
-
const lower = keyword.toLowerCase();
|
|
727
|
-
return r.filter((item) => {
|
|
728
|
-
const text = typeof item === "object" && item !== null ? JSON.stringify(item).toLowerCase() : "";
|
|
729
|
-
return text.includes(lower);
|
|
730
|
-
});
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
listServiceCategories(appId) {
|
|
734
|
-
return this.sdk().then((s) => s.services.appIdServicesCategories({ params: { path: { appId } } }));
|
|
735
|
-
}
|
|
736
|
-
//
|
|
737
|
-
// Projects
|
|
738
|
-
//
|
|
739
|
-
getProject(projectId) {
|
|
740
|
-
return this.sdk().then((s) => s.projects.projectsId({ params: { path: { id: projectId } } }));
|
|
741
|
-
}
|
|
742
|
-
searchProjects(_body) {
|
|
743
|
-
return this.sdk().then((s) => s.projects.projectsFeed());
|
|
744
|
-
}
|
|
745
|
-
listProjectTypes() {
|
|
746
|
-
return this.sdk().then((s) => s.projects.projectsTypes());
|
|
747
|
-
}
|
|
748
|
-
getProjectPlans(projectId) {
|
|
749
|
-
return this.sdk().then(
|
|
750
|
-
(s) => s.projects.projectsProjectIDPlansPlanID({ params: { path: { id: projectId } } })
|
|
751
|
-
);
|
|
752
|
-
}
|
|
753
|
-
getProjectIssues(projectId) {
|
|
754
|
-
return this.sdk().then(
|
|
755
|
-
(s) => s.projects.projectsProjectIdIssuesCategories({ params: { path: { id: projectId } } })
|
|
756
|
-
);
|
|
757
|
-
}
|
|
758
|
-
getProjectRisks(projectId) {
|
|
759
|
-
return this.sdk().then(
|
|
760
|
-
(s) => s.projects.projectsProjectIdRisksCategories({ params: { path: { id: projectId } } })
|
|
761
|
-
);
|
|
762
|
-
}
|
|
763
|
-
//
|
|
764
|
-
// Time
|
|
765
|
-
//
|
|
766
|
-
listTimeTypes() {
|
|
767
|
-
return this.sdk().then((s) => s.time.timeTypes());
|
|
768
|
-
}
|
|
769
|
-
getMyTimeEntries(_startDate, _endDate) {
|
|
770
|
-
return this.sdk().then((s) => s.time.timeId({ params: { path: { id: 0 } } }));
|
|
771
|
-
}
|
|
772
|
-
//
|
|
773
|
-
// Reference Data
|
|
774
|
-
//
|
|
775
|
-
listAccounts(_appId) {
|
|
776
|
-
return this.sdk().then((s) => s.referenceData.accounts());
|
|
777
|
-
}
|
|
778
|
-
getAccount(accountId) {
|
|
779
|
-
return this.sdk().then((s) => s.referenceData.accountsId({ params: { path: { id: accountId } } }));
|
|
780
|
-
}
|
|
781
|
-
listLocations() {
|
|
782
|
-
return this.sdk().then((s) => s.referenceData.locations());
|
|
783
|
-
}
|
|
784
|
-
listFunctionalRoles() {
|
|
785
|
-
return this.sdk().then((s) => s.referenceData.securityrolesPermissions());
|
|
786
|
-
}
|
|
787
|
-
listCustomAttributes(_componentId, _appId, _associatedTypeId) {
|
|
788
|
-
return this.sdk().then((s) => s.referenceData.attributesCustom());
|
|
789
|
-
}
|
|
790
|
-
listTicketStatuses(appId) {
|
|
791
|
-
return this.sdk().then((s) => s.referenceData.appIdTicketsStatuses({ params: { path: { appId } } }));
|
|
792
|
-
}
|
|
793
|
-
//
|
|
794
|
-
// Mutations
|
|
795
|
-
//
|
|
796
|
-
createTicket(appId, body, _notifyRequestor, _notifyResponsible) {
|
|
797
|
-
return this.sdk().then((s) => s.tickets.createTicket({ appId, body }));
|
|
798
|
-
}
|
|
799
|
-
updateTicket(appId, ticketId, body, _notifyRequestor, _notifyResponsible, _comments, _isPrivate) {
|
|
800
|
-
return this.sdk().then((s) => s.tickets.updateTicket({ appId, ticketId, body }));
|
|
801
|
-
}
|
|
802
|
-
addTicketComment(appId, ticketId, body, _isPrivate, _notifyRequestor, _notifyResponsible) {
|
|
803
|
-
return this.sdk().then((s) => s.tickets.addTicketComment({ appId, ticketId, body: { Body: body } }));
|
|
804
|
-
}
|
|
805
|
-
createKbArticle(appId, body) {
|
|
806
|
-
return this.sdk().then((s) => s.knowledgeBase.createArticle({ appId, body }));
|
|
807
|
-
}
|
|
808
|
-
updateKbArticle(appId, articleId, body) {
|
|
809
|
-
return this.sdk().then((s) => s.knowledgeBase.updateArticle({ appId, articleId, body }));
|
|
810
|
-
}
|
|
811
|
-
createProjectIssue(_projectId, body) {
|
|
812
|
-
return this.sdk().then((s) => s.projects.createIssue({ body }));
|
|
813
|
-
}
|
|
814
|
-
createProjectRisk(_projectId, body) {
|
|
815
|
-
return this.sdk().then((s) => s.projects.createRisk({ body }));
|
|
816
|
-
}
|
|
817
|
-
//
|
|
818
|
-
// Delete mutations (confirm:true required for all)
|
|
819
|
-
//
|
|
820
|
-
deleteAsset(appId, assetId) {
|
|
821
|
-
return this.sdk().then((s) => s.assets.deleteAsset({ appId, assetId, confirm: true }));
|
|
822
|
-
}
|
|
823
|
-
deleteConfigurationItem(appId, ciId) {
|
|
824
|
-
return this.sdk().then((s) => s.cmdb.deleteConfigurationItem({ appId, configurationItemId: ciId, confirm: true }));
|
|
825
|
-
}
|
|
826
|
-
deleteService(appId, serviceId) {
|
|
827
|
-
return this.sdk().then((s) => s.services.deleteService({ appId, serviceId, confirm: true }));
|
|
828
|
-
}
|
|
829
|
-
deleteServiceCategory(appId, categoryId) {
|
|
830
|
-
return this.sdk().then((s) => s.services.deleteServiceCategory({ appId, categoryId, confirm: true }));
|
|
831
|
-
}
|
|
832
|
-
deleteTimeEntry(timeEntryId) {
|
|
833
|
-
return this.sdk().then((s) => s.time.deleteTimeEntry({ timeEntryId, confirm: true }));
|
|
834
|
-
}
|
|
835
|
-
};
|
|
836
|
-
function createConfiguredTeamDynamixClient() {
|
|
837
|
-
return new UnifiedTeamDynamixClient(getTeamDynamixConfig());
|
|
838
|
-
}
|
|
839
|
-
function assertWriteToolsEnabled(config) {
|
|
840
|
-
if (!config.enableWriteTools) {
|
|
841
|
-
throw new Error("Write tools are disabled. Set TEAMDYNAMIX_ENABLE_WRITE_TOOLS=true in your environment.");
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
function assertDeleteToolsEnabled(config) {
|
|
845
|
-
if (!config.enableDeleteTools) {
|
|
846
|
-
throw new Error("Delete tools are disabled. Set TEAMDYNAMIX_ENABLE_DELETE_TOOLS=true in your environment.");
|
|
847
|
-
}
|
|
848
|
-
}
|
|
268
|
+
var TeamDynamixUserSchema = z2.object({
|
|
269
|
+
UID: z2.string({ error: "User UID is required" }),
|
|
270
|
+
FullName: z2.string().optional(),
|
|
271
|
+
Email: z2.string().email().optional(),
|
|
272
|
+
IsActive: z2.boolean().optional()
|
|
273
|
+
}).catchall(z2.unknown()).describe("TeamDynamix User entity");
|
|
274
|
+
var TeamDynamixListResponseSchema = z2.array(z2.record(z2.string(), z2.unknown())).describe("Array of TeamDynamix entities");
|
|
275
|
+
var TeamDynamixSingleResponseSchema = z2.record(z2.string(), z2.unknown()).describe("Single TeamDynamix entity response");
|
|
849
276
|
|
|
850
277
|
// src/services/teamdynamix/render.service.ts
|
|
851
278
|
import { tablemark } from "tablemark";
|
|
@@ -959,13 +386,13 @@ function truncateMarkdown(markdown, limit) {
|
|
|
959
386
|
}
|
|
960
387
|
|
|
961
388
|
// src/tools/teamdynamix.domain-gateways.tools.ts
|
|
962
|
-
var teamdynamixDiscoveryActionSchema =
|
|
389
|
+
var teamdynamixDiscoveryActionSchema = z3.enum([
|
|
963
390
|
"server_status",
|
|
964
391
|
"get_current_user",
|
|
965
392
|
"list_applications",
|
|
966
393
|
"list_ticket_statuses"
|
|
967
394
|
]);
|
|
968
|
-
var teamdynamixTicketActionSchema =
|
|
395
|
+
var teamdynamixTicketActionSchema = z3.enum([
|
|
969
396
|
"list_ticket_types",
|
|
970
397
|
"list_ticket_priorities",
|
|
971
398
|
"list_ticket_urgencies",
|
|
@@ -978,7 +405,7 @@ var teamdynamixTicketActionSchema = z4.enum([
|
|
|
978
405
|
"add_ticket_comment",
|
|
979
406
|
"get_ticket_feed"
|
|
980
407
|
]);
|
|
981
|
-
var teamdynamixTicketRelationshipActionSchema =
|
|
408
|
+
var teamdynamixTicketRelationshipActionSchema = z3.enum([
|
|
982
409
|
"get_ticket_tasks",
|
|
983
410
|
"create_ticket_task",
|
|
984
411
|
"list_ticket_assets",
|
|
@@ -988,28 +415,28 @@ var teamdynamixTicketRelationshipActionSchema = z4.enum([
|
|
|
988
415
|
"add_ticket_contact",
|
|
989
416
|
"remove_ticket_contact"
|
|
990
417
|
]);
|
|
991
|
-
var teamdynamixPeopleActionSchema =
|
|
418
|
+
var teamdynamixPeopleActionSchema = z3.enum([
|
|
992
419
|
"get_user",
|
|
993
420
|
"search_users",
|
|
994
421
|
"get_group",
|
|
995
422
|
"search_groups",
|
|
996
423
|
"get_group_members"
|
|
997
424
|
]);
|
|
998
|
-
var teamdynamixKnowledgeBaseActionSchema =
|
|
425
|
+
var teamdynamixKnowledgeBaseActionSchema = z3.enum([
|
|
999
426
|
"get_kb_article",
|
|
1000
427
|
"search_kb_articles",
|
|
1001
428
|
"list_kb_categories",
|
|
1002
429
|
"create_kb_article",
|
|
1003
430
|
"update_kb_article"
|
|
1004
431
|
]);
|
|
1005
|
-
var teamdynamixAssetsActionSchema =
|
|
432
|
+
var teamdynamixAssetsActionSchema = z3.enum([
|
|
1006
433
|
"get_asset",
|
|
1007
434
|
"search_assets",
|
|
1008
435
|
"list_asset_statuses",
|
|
1009
436
|
"list_product_models",
|
|
1010
437
|
"delete_asset"
|
|
1011
438
|
]);
|
|
1012
|
-
var teamdynamixCmdbActionSchema =
|
|
439
|
+
var teamdynamixCmdbActionSchema = z3.enum([
|
|
1013
440
|
"get_ci",
|
|
1014
441
|
"search_cis",
|
|
1015
442
|
"list_ci_types",
|
|
@@ -1017,7 +444,7 @@ var teamdynamixCmdbActionSchema = z4.enum([
|
|
|
1017
444
|
"list_vendors",
|
|
1018
445
|
"delete_ci"
|
|
1019
446
|
]);
|
|
1020
|
-
var teamdynamixServicesActionSchema =
|
|
447
|
+
var teamdynamixServicesActionSchema = z3.enum([
|
|
1021
448
|
"list_services",
|
|
1022
449
|
"get_service",
|
|
1023
450
|
"search_services",
|
|
@@ -1025,7 +452,7 @@ var teamdynamixServicesActionSchema = z4.enum([
|
|
|
1025
452
|
"delete_service",
|
|
1026
453
|
"delete_service_category"
|
|
1027
454
|
]);
|
|
1028
|
-
var teamdynamixProjectsActionSchema =
|
|
455
|
+
var teamdynamixProjectsActionSchema = z3.enum([
|
|
1029
456
|
"get_project",
|
|
1030
457
|
"search_projects",
|
|
1031
458
|
"list_project_types",
|
|
@@ -1035,15 +462,15 @@ var teamdynamixProjectsActionSchema = z4.enum([
|
|
|
1035
462
|
"create_project_issue",
|
|
1036
463
|
"create_project_risk"
|
|
1037
464
|
]);
|
|
1038
|
-
var teamdynamixTimeActionSchema =
|
|
1039
|
-
var teamdynamixReferenceDataActionSchema =
|
|
465
|
+
var teamdynamixTimeActionSchema = z3.enum(["list_time_types", "get_my_time_entries"]);
|
|
466
|
+
var teamdynamixReferenceDataActionSchema = z3.enum([
|
|
1040
467
|
"list_accounts",
|
|
1041
468
|
"get_account",
|
|
1042
469
|
"list_locations",
|
|
1043
470
|
"list_functional_roles",
|
|
1044
471
|
"list_custom_attributes"
|
|
1045
472
|
]);
|
|
1046
|
-
var gatewayPayloadSchema =
|
|
473
|
+
var gatewayPayloadSchema = z3.record(z3.string(), z3.unknown()).default({});
|
|
1047
474
|
function messageFromError(error) {
|
|
1048
475
|
return error instanceof Error ? error.message : String(error);
|
|
1049
476
|
}
|
|
@@ -1188,7 +615,7 @@ function registerTeamDynamixDiscoveryGateway(server2) {
|
|
|
1188
615
|
return toSuccessResponse({ count: applications.length, applications }, response_format);
|
|
1189
616
|
}
|
|
1190
617
|
case "list_ticket_statuses": {
|
|
1191
|
-
const parsed = parsePayload(
|
|
618
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
|
|
1192
619
|
const config = getTeamDynamixConfig();
|
|
1193
620
|
const effectiveAppId = parsed.app_id ?? config.defaultTicketAppId;
|
|
1194
621
|
if (!effectiveAppId) {
|
|
@@ -1224,33 +651,33 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1224
651
|
const client = createConfiguredTeamDynamixClient();
|
|
1225
652
|
switch (action) {
|
|
1226
653
|
case "list_ticket_types": {
|
|
1227
|
-
const parsed = parsePayload(
|
|
654
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1228
655
|
const types = await client.listTicketTypes(parsed.app_id);
|
|
1229
656
|
return toSuccessResponse({ appId: parsed.app_id, types }, response_format);
|
|
1230
657
|
}
|
|
1231
658
|
case "list_ticket_priorities": {
|
|
1232
|
-
const parsed = parsePayload(
|
|
659
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1233
660
|
const priorities = await client.listTicketPriorities(parsed.app_id);
|
|
1234
661
|
return toSuccessResponse({ appId: parsed.app_id, priorities }, response_format);
|
|
1235
662
|
}
|
|
1236
663
|
case "list_ticket_urgencies": {
|
|
1237
|
-
const parsed = parsePayload(
|
|
664
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1238
665
|
const urgencies = await client.listTicketUrgencies(parsed.app_id);
|
|
1239
666
|
return toSuccessResponse({ appId: parsed.app_id, urgencies }, response_format);
|
|
1240
667
|
}
|
|
1241
668
|
case "list_ticket_impacts": {
|
|
1242
|
-
const parsed = parsePayload(
|
|
669
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1243
670
|
const impacts = await client.listTicketImpacts(parsed.app_id);
|
|
1244
671
|
return toSuccessResponse({ appId: parsed.app_id, impacts }, response_format);
|
|
1245
672
|
}
|
|
1246
673
|
case "list_ticket_sources": {
|
|
1247
|
-
const parsed = parsePayload(
|
|
674
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1248
675
|
const sources = await client.listTicketSources(parsed.app_id);
|
|
1249
676
|
return toSuccessResponse({ appId: parsed.app_id, sources }, response_format);
|
|
1250
677
|
}
|
|
1251
678
|
case "get_ticket": {
|
|
1252
679
|
const parsed = parsePayload(
|
|
1253
|
-
|
|
680
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
|
|
1254
681
|
payload,
|
|
1255
682
|
action
|
|
1256
683
|
);
|
|
@@ -1259,7 +686,7 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1259
686
|
}
|
|
1260
687
|
case "search_tickets": {
|
|
1261
688
|
const parsed = parsePayload(
|
|
1262
|
-
|
|
689
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, search: TicketSearchSchema }),
|
|
1263
690
|
payload,
|
|
1264
691
|
action
|
|
1265
692
|
);
|
|
@@ -1268,11 +695,11 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1268
695
|
}
|
|
1269
696
|
case "create_ticket": {
|
|
1270
697
|
const parsed = parsePayload(
|
|
1271
|
-
|
|
698
|
+
z3.object({
|
|
1272
699
|
app_id: TeamDynamixAppIdSchema,
|
|
1273
700
|
ticket: TicketCreateSchema,
|
|
1274
|
-
notify_requestor:
|
|
1275
|
-
notify_responsible:
|
|
701
|
+
notify_requestor: z3.boolean().optional().default(false),
|
|
702
|
+
notify_responsible: z3.boolean().optional().default(false)
|
|
1276
703
|
}),
|
|
1277
704
|
payload,
|
|
1278
705
|
action
|
|
@@ -1288,7 +715,7 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1288
715
|
}
|
|
1289
716
|
case "update_ticket": {
|
|
1290
717
|
const parsed = parsePayload(
|
|
1291
|
-
|
|
718
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, patch: TicketPatchSchema }),
|
|
1292
719
|
payload,
|
|
1293
720
|
action
|
|
1294
721
|
);
|
|
@@ -1306,7 +733,7 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1306
733
|
}
|
|
1307
734
|
case "add_ticket_comment": {
|
|
1308
735
|
const parsed = parsePayload(
|
|
1309
|
-
|
|
736
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, comment: TicketCommentSchema }),
|
|
1310
737
|
payload,
|
|
1311
738
|
action
|
|
1312
739
|
);
|
|
@@ -1323,7 +750,7 @@ function registerTeamDynamixTicketsGateway(server2) {
|
|
|
1323
750
|
}
|
|
1324
751
|
case "get_ticket_feed": {
|
|
1325
752
|
const parsed = parsePayload(
|
|
1326
|
-
|
|
753
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
|
|
1327
754
|
payload,
|
|
1328
755
|
action
|
|
1329
756
|
);
|
|
@@ -1359,7 +786,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1359
786
|
switch (action) {
|
|
1360
787
|
case "get_ticket_tasks": {
|
|
1361
788
|
const parsed = parsePayload(
|
|
1362
|
-
|
|
789
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
|
|
1363
790
|
payload,
|
|
1364
791
|
action
|
|
1365
792
|
);
|
|
@@ -1371,7 +798,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1371
798
|
}
|
|
1372
799
|
case "create_ticket_task": {
|
|
1373
800
|
const parsed = parsePayload(
|
|
1374
|
-
|
|
801
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, task: TicketTaskCreateSchema }),
|
|
1375
802
|
payload,
|
|
1376
803
|
action
|
|
1377
804
|
);
|
|
@@ -1385,7 +812,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1385
812
|
}
|
|
1386
813
|
case "list_ticket_assets": {
|
|
1387
814
|
const parsed = parsePayload(
|
|
1388
|
-
|
|
815
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
|
|
1389
816
|
payload,
|
|
1390
817
|
action
|
|
1391
818
|
);
|
|
@@ -1397,10 +824,10 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1397
824
|
}
|
|
1398
825
|
case "add_ticket_asset": {
|
|
1399
826
|
const parsed = parsePayload(
|
|
1400
|
-
|
|
827
|
+
z3.object({
|
|
1401
828
|
app_id: TeamDynamixAppIdSchema,
|
|
1402
|
-
ticket_id:
|
|
1403
|
-
asset_id:
|
|
829
|
+
ticket_id: z3.number().int().positive(),
|
|
830
|
+
asset_id: z3.number().int().positive()
|
|
1404
831
|
}),
|
|
1405
832
|
payload,
|
|
1406
833
|
action
|
|
@@ -1411,11 +838,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1411
838
|
}
|
|
1412
839
|
case "remove_ticket_asset": {
|
|
1413
840
|
const parsed = parsePayload(
|
|
1414
|
-
|
|
841
|
+
z3.object({
|
|
1415
842
|
app_id: TeamDynamixAppIdSchema,
|
|
1416
|
-
ticket_id:
|
|
1417
|
-
asset_id:
|
|
1418
|
-
confirm:
|
|
843
|
+
ticket_id: z3.number().int().positive(),
|
|
844
|
+
asset_id: z3.number().int().positive(),
|
|
845
|
+
confirm: z3.literal(true)
|
|
1419
846
|
}),
|
|
1420
847
|
payload,
|
|
1421
848
|
action
|
|
@@ -1434,7 +861,7 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1434
861
|
}
|
|
1435
862
|
case "get_ticket_contacts": {
|
|
1436
863
|
const parsed = parsePayload(
|
|
1437
|
-
|
|
864
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ticket_id: z3.number().int().positive() }),
|
|
1438
865
|
payload,
|
|
1439
866
|
action
|
|
1440
867
|
);
|
|
@@ -1446,9 +873,9 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1446
873
|
}
|
|
1447
874
|
case "add_ticket_contact": {
|
|
1448
875
|
const parsed = parsePayload(
|
|
1449
|
-
|
|
876
|
+
z3.object({
|
|
1450
877
|
app_id: TeamDynamixAppIdSchema,
|
|
1451
|
-
ticket_id:
|
|
878
|
+
ticket_id: z3.number().int().positive(),
|
|
1452
879
|
contact_uid: TeamDynamixGuidSchema
|
|
1453
880
|
}),
|
|
1454
881
|
payload,
|
|
@@ -1460,11 +887,11 @@ function registerTeamDynamixTicketRelationshipsGateway(server2) {
|
|
|
1460
887
|
}
|
|
1461
888
|
case "remove_ticket_contact": {
|
|
1462
889
|
const parsed = parsePayload(
|
|
1463
|
-
|
|
890
|
+
z3.object({
|
|
1464
891
|
app_id: TeamDynamixAppIdSchema,
|
|
1465
|
-
ticket_id:
|
|
892
|
+
ticket_id: z3.number().int().positive(),
|
|
1466
893
|
contact_uid: TeamDynamixGuidSchema,
|
|
1467
|
-
confirm:
|
|
894
|
+
confirm: z3.literal(true)
|
|
1468
895
|
}),
|
|
1469
896
|
payload,
|
|
1470
897
|
action
|
|
@@ -1506,27 +933,27 @@ function registerTeamDynamixPeopleGateway(server2) {
|
|
|
1506
933
|
const client = createConfiguredTeamDynamixClient();
|
|
1507
934
|
switch (action) {
|
|
1508
935
|
case "get_user": {
|
|
1509
|
-
const parsed = parsePayload(
|
|
936
|
+
const parsed = parsePayload(z3.object({ uid: TeamDynamixGuidSchema }), payload, action);
|
|
1510
937
|
const user = await client.getUser(parsed.uid);
|
|
1511
938
|
return toSuccessResponse(user, response_format);
|
|
1512
939
|
}
|
|
1513
940
|
case "search_users": {
|
|
1514
|
-
const parsed = parsePayload(
|
|
941
|
+
const parsed = parsePayload(z3.object({ search: UserSearchSchema }), payload, action);
|
|
1515
942
|
const users = await client.searchUsers(parsed.search);
|
|
1516
943
|
return toSuccessResponse({ count: users.length, users }, response_format);
|
|
1517
944
|
}
|
|
1518
945
|
case "get_group": {
|
|
1519
|
-
const parsed = parsePayload(
|
|
946
|
+
const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
|
|
1520
947
|
const group = await client.getGroup(parsed.group_id);
|
|
1521
948
|
return toSuccessResponse(group, response_format);
|
|
1522
949
|
}
|
|
1523
950
|
case "search_groups": {
|
|
1524
|
-
const parsed = parsePayload(
|
|
951
|
+
const parsed = parsePayload(z3.object({ search: GroupSearchSchema }), payload, action);
|
|
1525
952
|
const groups = await client.searchGroups(parsed.search);
|
|
1526
953
|
return toSuccessResponse({ count: groups.length, groups }, response_format);
|
|
1527
954
|
}
|
|
1528
955
|
case "get_group_members": {
|
|
1529
|
-
const parsed = parsePayload(
|
|
956
|
+
const parsed = parsePayload(z3.object({ group_id: z3.number().int().positive() }), payload, action);
|
|
1530
957
|
const members = await client.getGroupMembers(parsed.group_id);
|
|
1531
958
|
return toSuccessResponse({ groupId: parsed.group_id, count: members.length, members }, response_format);
|
|
1532
959
|
}
|
|
@@ -1556,7 +983,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
|
|
|
1556
983
|
switch (action) {
|
|
1557
984
|
case "get_kb_article": {
|
|
1558
985
|
const parsed = parsePayload(
|
|
1559
|
-
|
|
986
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, article_id: z3.number().int().positive() }),
|
|
1560
987
|
payload,
|
|
1561
988
|
action
|
|
1562
989
|
);
|
|
@@ -1565,7 +992,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
|
|
|
1565
992
|
}
|
|
1566
993
|
case "search_kb_articles": {
|
|
1567
994
|
const parsed = parsePayload(
|
|
1568
|
-
|
|
995
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, search: KbArticleSearchSchema }),
|
|
1569
996
|
payload,
|
|
1570
997
|
action
|
|
1571
998
|
);
|
|
@@ -1573,13 +1000,13 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
|
|
|
1573
1000
|
return toSuccessResponse({ appId: parsed.app_id, count: articles.length, articles }, response_format);
|
|
1574
1001
|
}
|
|
1575
1002
|
case "list_kb_categories": {
|
|
1576
|
-
const parsed = parsePayload(
|
|
1003
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1577
1004
|
const categories = await client.listKbCategories(parsed.app_id);
|
|
1578
1005
|
return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
|
|
1579
1006
|
}
|
|
1580
1007
|
case "create_kb_article": {
|
|
1581
1008
|
const parsed = parsePayload(
|
|
1582
|
-
|
|
1009
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleCreateSchema }),
|
|
1583
1010
|
payload,
|
|
1584
1011
|
action
|
|
1585
1012
|
);
|
|
@@ -1589,7 +1016,7 @@ function registerTeamDynamixKnowledgeBaseGateway(server2) {
|
|
|
1589
1016
|
}
|
|
1590
1017
|
case "update_kb_article": {
|
|
1591
1018
|
const parsed = parsePayload(
|
|
1592
|
-
|
|
1019
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, article: KbArticleUpdateSchema }),
|
|
1593
1020
|
payload,
|
|
1594
1021
|
action
|
|
1595
1022
|
);
|
|
@@ -1624,7 +1051,7 @@ function registerTeamDynamixAssetsGateway(server2) {
|
|
|
1624
1051
|
switch (action) {
|
|
1625
1052
|
case "get_asset": {
|
|
1626
1053
|
const parsed = parsePayload(
|
|
1627
|
-
|
|
1054
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, asset_id: z3.number().int().positive() }),
|
|
1628
1055
|
payload,
|
|
1629
1056
|
action
|
|
1630
1057
|
);
|
|
@@ -1633,7 +1060,7 @@ function registerTeamDynamixAssetsGateway(server2) {
|
|
|
1633
1060
|
}
|
|
1634
1061
|
case "search_assets": {
|
|
1635
1062
|
const parsed = parsePayload(
|
|
1636
|
-
|
|
1063
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, search: AssetSearchSchema }),
|
|
1637
1064
|
payload,
|
|
1638
1065
|
action
|
|
1639
1066
|
);
|
|
@@ -1641,21 +1068,21 @@ function registerTeamDynamixAssetsGateway(server2) {
|
|
|
1641
1068
|
return toSuccessResponse({ appId: parsed.app_id, count: assets.length, assets }, response_format);
|
|
1642
1069
|
}
|
|
1643
1070
|
case "list_asset_statuses": {
|
|
1644
|
-
const parsed = parsePayload(
|
|
1071
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1645
1072
|
const statuses = await client.listAssetStatuses(parsed.app_id);
|
|
1646
1073
|
return toSuccessResponse({ appId: parsed.app_id, count: statuses.length, statuses }, response_format);
|
|
1647
1074
|
}
|
|
1648
1075
|
case "list_product_models": {
|
|
1649
|
-
const parsed = parsePayload(
|
|
1076
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1650
1077
|
const models = await client.listProductModels(parsed.app_id);
|
|
1651
1078
|
return toSuccessResponse({ appId: parsed.app_id, count: models.length, models }, response_format);
|
|
1652
1079
|
}
|
|
1653
1080
|
case "delete_asset": {
|
|
1654
1081
|
const parsed = parsePayload(
|
|
1655
|
-
|
|
1082
|
+
z3.object({
|
|
1656
1083
|
app_id: TeamDynamixAppIdSchema,
|
|
1657
|
-
asset_id:
|
|
1658
|
-
confirm:
|
|
1084
|
+
asset_id: z3.number().int().positive(),
|
|
1085
|
+
confirm: z3.literal(true)
|
|
1659
1086
|
}),
|
|
1660
1087
|
payload,
|
|
1661
1088
|
action
|
|
@@ -1693,7 +1120,7 @@ function registerTeamDynamixCmdbGateway(server2) {
|
|
|
1693
1120
|
switch (action) {
|
|
1694
1121
|
case "get_ci": {
|
|
1695
1122
|
const parsed = parsePayload(
|
|
1696
|
-
|
|
1123
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, ci_id: z3.number().int().positive() }),
|
|
1697
1124
|
payload,
|
|
1698
1125
|
action
|
|
1699
1126
|
);
|
|
@@ -1702,7 +1129,7 @@ function registerTeamDynamixCmdbGateway(server2) {
|
|
|
1702
1129
|
}
|
|
1703
1130
|
case "search_cis": {
|
|
1704
1131
|
const parsed = parsePayload(
|
|
1705
|
-
|
|
1132
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, search: CiSearchSchema }),
|
|
1706
1133
|
payload,
|
|
1707
1134
|
action
|
|
1708
1135
|
);
|
|
@@ -1713,7 +1140,7 @@ function registerTeamDynamixCmdbGateway(server2) {
|
|
|
1713
1140
|
return toSuccessResponse({ appId: parsed.app_id, count: results.length, results }, response_format);
|
|
1714
1141
|
}
|
|
1715
1142
|
case "list_ci_types": {
|
|
1716
|
-
const parsed = parsePayload(
|
|
1143
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1717
1144
|
const types = await client.listCiTypes(parsed.app_id);
|
|
1718
1145
|
return toSuccessResponse({ appId: parsed.app_id, count: types.length, types }, response_format);
|
|
1719
1146
|
}
|
|
@@ -1722,16 +1149,16 @@ function registerTeamDynamixCmdbGateway(server2) {
|
|
|
1722
1149
|
return toSuccessResponse({ count: types.length, types }, response_format);
|
|
1723
1150
|
}
|
|
1724
1151
|
case "list_vendors": {
|
|
1725
|
-
const parsed = parsePayload(
|
|
1152
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1726
1153
|
const vendors = await client.listVendors(parsed.app_id);
|
|
1727
1154
|
return toSuccessResponse({ appId: parsed.app_id, count: vendors.length, vendors }, response_format);
|
|
1728
1155
|
}
|
|
1729
1156
|
case "delete_ci": {
|
|
1730
1157
|
const parsed = parsePayload(
|
|
1731
|
-
|
|
1158
|
+
z3.object({
|
|
1732
1159
|
app_id: TeamDynamixAppIdSchema,
|
|
1733
|
-
ci_id:
|
|
1734
|
-
confirm:
|
|
1160
|
+
ci_id: z3.number().int().positive(),
|
|
1161
|
+
confirm: z3.literal(true)
|
|
1735
1162
|
}),
|
|
1736
1163
|
payload,
|
|
1737
1164
|
action
|
|
@@ -1765,13 +1192,13 @@ function registerTeamDynamixServicesGateway(server2) {
|
|
|
1765
1192
|
const client = createConfiguredTeamDynamixClient();
|
|
1766
1193
|
switch (action) {
|
|
1767
1194
|
case "list_services": {
|
|
1768
|
-
const parsed = parsePayload(
|
|
1195
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1769
1196
|
const services = await client.listServiceCatalog(parsed.app_id);
|
|
1770
1197
|
return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
|
|
1771
1198
|
}
|
|
1772
1199
|
case "get_service": {
|
|
1773
1200
|
const parsed = parsePayload(
|
|
1774
|
-
|
|
1201
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, service_id: z3.number().int().positive() }),
|
|
1775
1202
|
payload,
|
|
1776
1203
|
action
|
|
1777
1204
|
);
|
|
@@ -1780,7 +1207,7 @@ function registerTeamDynamixServicesGateway(server2) {
|
|
|
1780
1207
|
}
|
|
1781
1208
|
case "search_services": {
|
|
1782
1209
|
const parsed = parsePayload(
|
|
1783
|
-
|
|
1210
|
+
z3.object({ app_id: TeamDynamixAppIdSchema, search: ServiceSearchSchema }),
|
|
1784
1211
|
payload,
|
|
1785
1212
|
action
|
|
1786
1213
|
);
|
|
@@ -1788,16 +1215,16 @@ function registerTeamDynamixServicesGateway(server2) {
|
|
|
1788
1215
|
return toSuccessResponse({ appId: parsed.app_id, count: services.length, services }, response_format);
|
|
1789
1216
|
}
|
|
1790
1217
|
case "list_service_categories": {
|
|
1791
|
-
const parsed = parsePayload(
|
|
1218
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema }), payload, action);
|
|
1792
1219
|
const categories = await client.listServiceCategories(parsed.app_id);
|
|
1793
1220
|
return toSuccessResponse({ appId: parsed.app_id, count: categories.length, categories }, response_format);
|
|
1794
1221
|
}
|
|
1795
1222
|
case "delete_service": {
|
|
1796
1223
|
const parsed = parsePayload(
|
|
1797
|
-
|
|
1224
|
+
z3.object({
|
|
1798
1225
|
app_id: TeamDynamixAppIdSchema,
|
|
1799
|
-
service_id:
|
|
1800
|
-
confirm:
|
|
1226
|
+
service_id: z3.number().int().positive(),
|
|
1227
|
+
confirm: z3.literal(true)
|
|
1801
1228
|
}),
|
|
1802
1229
|
payload,
|
|
1803
1230
|
action
|
|
@@ -1811,10 +1238,10 @@ function registerTeamDynamixServicesGateway(server2) {
|
|
|
1811
1238
|
}
|
|
1812
1239
|
case "delete_service_category": {
|
|
1813
1240
|
const parsed = parsePayload(
|
|
1814
|
-
|
|
1241
|
+
z3.object({
|
|
1815
1242
|
app_id: TeamDynamixAppIdSchema,
|
|
1816
|
-
category_id:
|
|
1817
|
-
confirm:
|
|
1243
|
+
category_id: z3.number().int().positive(),
|
|
1244
|
+
confirm: z3.literal(true)
|
|
1818
1245
|
}),
|
|
1819
1246
|
payload,
|
|
1820
1247
|
action
|
|
@@ -1851,12 +1278,12 @@ function registerTeamDynamixProjectsGateway(server2) {
|
|
|
1851
1278
|
const client = createConfiguredTeamDynamixClient();
|
|
1852
1279
|
switch (action) {
|
|
1853
1280
|
case "get_project": {
|
|
1854
|
-
const parsed = parsePayload(
|
|
1281
|
+
const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
|
|
1855
1282
|
const project = await client.getProject(parsed.project_id);
|
|
1856
1283
|
return toSuccessResponse(project, response_format);
|
|
1857
1284
|
}
|
|
1858
1285
|
case "search_projects": {
|
|
1859
|
-
const parsed = parsePayload(
|
|
1286
|
+
const parsed = parsePayload(z3.object({ search: ProjectSearchSchema }), payload, action);
|
|
1860
1287
|
const projects = await client.searchProjects(parsed.search);
|
|
1861
1288
|
return toSuccessResponse({ count: projects.length, projects }, response_format);
|
|
1862
1289
|
}
|
|
@@ -1865,23 +1292,23 @@ function registerTeamDynamixProjectsGateway(server2) {
|
|
|
1865
1292
|
return toSuccessResponse({ count: types.length, types }, response_format);
|
|
1866
1293
|
}
|
|
1867
1294
|
case "get_project_plans": {
|
|
1868
|
-
const parsed = parsePayload(
|
|
1295
|
+
const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
|
|
1869
1296
|
const plans = await client.getProjectPlans(parsed.project_id);
|
|
1870
1297
|
return toSuccessResponse({ projectId: parsed.project_id, count: plans.length, plans }, response_format);
|
|
1871
1298
|
}
|
|
1872
1299
|
case "get_project_issues": {
|
|
1873
|
-
const parsed = parsePayload(
|
|
1300
|
+
const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
|
|
1874
1301
|
const issues = await client.getProjectIssues(parsed.project_id);
|
|
1875
1302
|
return toSuccessResponse({ projectId: parsed.project_id, count: issues.length, issues }, response_format);
|
|
1876
1303
|
}
|
|
1877
1304
|
case "get_project_risks": {
|
|
1878
|
-
const parsed = parsePayload(
|
|
1305
|
+
const parsed = parsePayload(z3.object({ project_id: z3.number().int().positive() }), payload, action);
|
|
1879
1306
|
const risks = await client.getProjectRisks(parsed.project_id);
|
|
1880
1307
|
return toSuccessResponse({ projectId: parsed.project_id, count: risks.length, risks }, response_format);
|
|
1881
1308
|
}
|
|
1882
1309
|
case "create_project_issue": {
|
|
1883
1310
|
const parsed = parsePayload(
|
|
1884
|
-
|
|
1311
|
+
z3.object({ project_id: z3.number().int().positive(), issue: ProjectIssueCreateSchema }),
|
|
1885
1312
|
payload,
|
|
1886
1313
|
action
|
|
1887
1314
|
);
|
|
@@ -1891,7 +1318,7 @@ function registerTeamDynamixProjectsGateway(server2) {
|
|
|
1891
1318
|
}
|
|
1892
1319
|
case "create_project_risk": {
|
|
1893
1320
|
const parsed = parsePayload(
|
|
1894
|
-
|
|
1321
|
+
z3.object({ project_id: z3.number().int().positive(), risk: ProjectRiskCreateSchema }),
|
|
1895
1322
|
payload,
|
|
1896
1323
|
action
|
|
1897
1324
|
);
|
|
@@ -1928,7 +1355,7 @@ function registerTeamDynamixTimeGateway(server2) {
|
|
|
1928
1355
|
return toSuccessResponse({ count: types.length, types }, response_format);
|
|
1929
1356
|
}
|
|
1930
1357
|
case "get_my_time_entries": {
|
|
1931
|
-
const parsed = parsePayload(
|
|
1358
|
+
const parsed = parsePayload(z3.object({ query: TimeEntryQuerySchema }), payload, action);
|
|
1932
1359
|
const entries = await client.getMyTimeEntries(parsed.query.StartDate, parsed.query.EndDate);
|
|
1933
1360
|
return toSuccessResponse({ count: entries.length, entries }, response_format);
|
|
1934
1361
|
}
|
|
@@ -1957,12 +1384,12 @@ function registerTeamDynamixReferenceDataGateway(server2) {
|
|
|
1957
1384
|
const client = createConfiguredTeamDynamixClient();
|
|
1958
1385
|
switch (action) {
|
|
1959
1386
|
case "list_accounts": {
|
|
1960
|
-
const parsed = parsePayload(
|
|
1387
|
+
const parsed = parsePayload(z3.object({ app_id: TeamDynamixAppIdSchema.optional() }), payload, action);
|
|
1961
1388
|
const accounts = await client.listAccounts(parsed.app_id);
|
|
1962
1389
|
return toSuccessResponse({ count: accounts.length, accounts }, response_format);
|
|
1963
1390
|
}
|
|
1964
1391
|
case "get_account": {
|
|
1965
|
-
const parsed = parsePayload(
|
|
1392
|
+
const parsed = parsePayload(z3.object({ account_id: z3.number().int().positive() }), payload, action);
|
|
1966
1393
|
const account = await client.getAccount(parsed.account_id);
|
|
1967
1394
|
return toSuccessResponse(account, response_format);
|
|
1968
1395
|
}
|
|
@@ -1976,10 +1403,10 @@ function registerTeamDynamixReferenceDataGateway(server2) {
|
|
|
1976
1403
|
}
|
|
1977
1404
|
case "list_custom_attributes": {
|
|
1978
1405
|
const parsed = parsePayload(
|
|
1979
|
-
|
|
1406
|
+
z3.object({
|
|
1980
1407
|
component_id: CustomAttributeComponentIdSchema,
|
|
1981
1408
|
app_id: TeamDynamixAppIdSchema.optional(),
|
|
1982
|
-
associated_type_id:
|
|
1409
|
+
associated_type_id: z3.number().int().positive().optional()
|
|
1983
1410
|
}),
|
|
1984
1411
|
payload,
|
|
1985
1412
|
action
|
|
@@ -2084,12 +1511,188 @@ function registerTeamDynamixResources(server2) {
|
|
|
2084
1511
|
);
|
|
2085
1512
|
}
|
|
2086
1513
|
|
|
1514
|
+
// src/tools/teamdynamix.watch.tools.ts
|
|
1515
|
+
import { z as z4 } from "zod";
|
|
1516
|
+
var WatchKindSchema = z4.enum(["mine", "watching", "waiting-on-others"]);
|
|
1517
|
+
var BallSchema = z4.enum(["us", "them"]);
|
|
1518
|
+
function messageFromError2(error) {
|
|
1519
|
+
return error instanceof Error ? error.message : String(error);
|
|
1520
|
+
}
|
|
1521
|
+
async function withService(responseFormat, fn) {
|
|
1522
|
+
try {
|
|
1523
|
+
const client = createConfiguredTeamDynamixClient();
|
|
1524
|
+
const ledgerPath = defaultLedgerPath();
|
|
1525
|
+
let ledger;
|
|
1526
|
+
try {
|
|
1527
|
+
ledger = await loadLedger(ledgerPath);
|
|
1528
|
+
} catch (cause) {
|
|
1529
|
+
if (cause instanceof LedgerCorruptError) throw cause;
|
|
1530
|
+
ledger = emptyLedger();
|
|
1531
|
+
}
|
|
1532
|
+
const svc = new WorkspaceWatchService(ledger, ledgerPath, client);
|
|
1533
|
+
const data = await fn(svc);
|
|
1534
|
+
return {
|
|
1535
|
+
content: [{ type: "text", text: render(data, responseFormat) }],
|
|
1536
|
+
structuredContent: data
|
|
1537
|
+
};
|
|
1538
|
+
} catch (error) {
|
|
1539
|
+
return { content: [{ type: "text", text: `Error: ${messageFromError2(error)}` }], isError: true };
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
function registerTeamDynamixWatchTools(server2) {
|
|
1543
|
+
const readOnly = { readOnlyHint: true, idempotentHint: false, destructiveHint: false, openWorldHint: true };
|
|
1544
|
+
server2.registerTool(
|
|
1545
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_check`,
|
|
1546
|
+
{
|
|
1547
|
+
title: "Watch Check",
|
|
1548
|
+
description: "Diff pass over the watch ledger: sweeps queue searches per app, deep-fetches only changed tickets, and returns classified deltas (status, new-entry, hidden-reply, ownership, sla, hold-window).",
|
|
1549
|
+
inputSchema: {
|
|
1550
|
+
tickets: z4.array(z4.number().int().positive()).optional().describe("Restrict the check to these ticket IDs."),
|
|
1551
|
+
response_format: TeamDynamixResponseFormatSchema
|
|
1552
|
+
},
|
|
1553
|
+
annotations: { ...readOnly }
|
|
1554
|
+
},
|
|
1555
|
+
async ({ tickets, response_format }) => withService(response_format, (svc) => svc.check({ tickets }))
|
|
1556
|
+
);
|
|
1557
|
+
server2.registerTool(
|
|
1558
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_status`,
|
|
1559
|
+
{
|
|
1560
|
+
title: "Watch Status",
|
|
1561
|
+
description: "Ledger summary (counts, ball-in-court, pending-triage queue, oldest freshness) without any TDX calls.",
|
|
1562
|
+
inputSchema: { response_format: TeamDynamixResponseFormatSchema },
|
|
1563
|
+
annotations: { ...readOnly, idempotentHint: true, openWorldHint: false }
|
|
1564
|
+
},
|
|
1565
|
+
async ({ response_format }) => withService(response_format, async (svc) => ({
|
|
1566
|
+
...await svc.status(),
|
|
1567
|
+
pendingTriage: svc.pendingTriage()
|
|
1568
|
+
}))
|
|
1569
|
+
);
|
|
1570
|
+
server2.registerTool(
|
|
1571
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_sweep`,
|
|
1572
|
+
{
|
|
1573
|
+
title: "Watch Sweep",
|
|
1574
|
+
description: "Cheap sweep: one queue search per configured app, client-side team restriction (TEAMDYNAMIX_TICKET_GROUP_IDS), ledger freshness, and pending-triage queue maintenance (changed + new-unassigned tickets). No deep fetches.",
|
|
1575
|
+
inputSchema: { response_format: TeamDynamixResponseFormatSchema },
|
|
1576
|
+
annotations: { ...readOnly }
|
|
1577
|
+
},
|
|
1578
|
+
async ({ response_format }) => withService(response_format, (svc) => svc.sweep())
|
|
1579
|
+
);
|
|
1580
|
+
server2.registerTool(
|
|
1581
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_triage`,
|
|
1582
|
+
{
|
|
1583
|
+
title: "Watch Triage Queue",
|
|
1584
|
+
description: "Local triage queue (never calls TDX). op=queue lists pending tickets needing background triage; op=done removes a ticket after the agent has reviewed it and updated notes.",
|
|
1585
|
+
inputSchema: {
|
|
1586
|
+
op: z4.enum(["queue", "done"]),
|
|
1587
|
+
ticket_id: z4.number().int().positive().optional().describe("Required for op=done."),
|
|
1588
|
+
response_format: TeamDynamixResponseFormatSchema
|
|
1589
|
+
},
|
|
1590
|
+
annotations: { ...readOnly, openWorldHint: false }
|
|
1591
|
+
},
|
|
1592
|
+
async ({
|
|
1593
|
+
op,
|
|
1594
|
+
ticket_id,
|
|
1595
|
+
response_format
|
|
1596
|
+
}) => withService(response_format, async (svc) => {
|
|
1597
|
+
if (op === "queue") return { pending: svc.pendingTriage() };
|
|
1598
|
+
if (ticket_id === void 0) throw new Error("op=done requires ticket_id.");
|
|
1599
|
+
return await svc.markTriaged(ticket_id);
|
|
1600
|
+
})
|
|
1601
|
+
);
|
|
1602
|
+
server2.registerTool(
|
|
1603
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_register`,
|
|
1604
|
+
{
|
|
1605
|
+
title: "Watch Register",
|
|
1606
|
+
description: "Add/update a ledger row when a ticket is claimed, re-scoped, or swept in. Never calls TDX.",
|
|
1607
|
+
inputSchema: {
|
|
1608
|
+
app_id: z4.number().int().positive().describe("Ticketing application ID."),
|
|
1609
|
+
id: z4.number().int().positive().describe("Ticket ID."),
|
|
1610
|
+
kind: WatchKindSchema.describe("Lane: mine, watching, or waiting-on-others."),
|
|
1611
|
+
title: z4.string().max(200).optional().describe("Short title (stored locally only)."),
|
|
1612
|
+
district: z4.string().max(100).optional().describe("District/lane label."),
|
|
1613
|
+
ball: BallSchema.optional().describe("Manual ball-in-court override (survives auto-inference)."),
|
|
1614
|
+
next_action: z4.string().max(500).optional().describe("Next action note."),
|
|
1615
|
+
response_format: TeamDynamixResponseFormatSchema
|
|
1616
|
+
},
|
|
1617
|
+
annotations: { ...readOnly, openWorldHint: false }
|
|
1618
|
+
},
|
|
1619
|
+
async ({
|
|
1620
|
+
app_id,
|
|
1621
|
+
id,
|
|
1622
|
+
kind,
|
|
1623
|
+
title,
|
|
1624
|
+
district,
|
|
1625
|
+
ball,
|
|
1626
|
+
next_action,
|
|
1627
|
+
response_format
|
|
1628
|
+
}) => withService(
|
|
1629
|
+
response_format,
|
|
1630
|
+
(svc) => svc.register({ appId: app_id, id, kind, title, district, ball, nextAction: next_action })
|
|
1631
|
+
)
|
|
1632
|
+
);
|
|
1633
|
+
server2.registerTool(
|
|
1634
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_archive`,
|
|
1635
|
+
{
|
|
1636
|
+
title: "Watch Archive",
|
|
1637
|
+
description: "Move a confirmed-closed row to the archive section. Memory (notes) is preserved. Never calls TDX.",
|
|
1638
|
+
inputSchema: {
|
|
1639
|
+
id: z4.number().int().positive().describe("Ticket ID."),
|
|
1640
|
+
outcome: z4.string().max(200).optional().describe("Resolution outcome label."),
|
|
1641
|
+
response_format: TeamDynamixResponseFormatSchema
|
|
1642
|
+
},
|
|
1643
|
+
annotations: { ...readOnly, openWorldHint: false }
|
|
1644
|
+
},
|
|
1645
|
+
async ({ id, outcome, response_format }) => withService(response_format, (svc) => svc.archive({ id, outcome }))
|
|
1646
|
+
);
|
|
1647
|
+
server2.registerTool(
|
|
1648
|
+
`${TEAMDYNAMIX_TOOL_PREFIX}_watch_notes`,
|
|
1649
|
+
{
|
|
1650
|
+
title: "Watch Notes",
|
|
1651
|
+
description: "Local-only notes attached to ledgered tickets \u2014 the server's own memory. Never written to TDX. op: add | update | delete | list.",
|
|
1652
|
+
inputSchema: {
|
|
1653
|
+
op: z4.enum(["add", "update", "delete", "list"]),
|
|
1654
|
+
app_id: z4.number().int().positive().optional(),
|
|
1655
|
+
ticket_id: z4.number().int().positive().optional(),
|
|
1656
|
+
note_id: z4.string().optional(),
|
|
1657
|
+
text: z4.string().max(4e3).optional(),
|
|
1658
|
+
response_format: TeamDynamixResponseFormatSchema
|
|
1659
|
+
},
|
|
1660
|
+
annotations: { ...readOnly, openWorldHint: false }
|
|
1661
|
+
},
|
|
1662
|
+
async ({
|
|
1663
|
+
op,
|
|
1664
|
+
app_id,
|
|
1665
|
+
ticket_id,
|
|
1666
|
+
note_id,
|
|
1667
|
+
text,
|
|
1668
|
+
response_format
|
|
1669
|
+
}) => withService(response_format, async (svc) => {
|
|
1670
|
+
switch (op) {
|
|
1671
|
+
case "add":
|
|
1672
|
+
if (app_id === void 0 || ticket_id === void 0 || !text) {
|
|
1673
|
+
throw new Error("op=add requires app_id, ticket_id, and text.");
|
|
1674
|
+
}
|
|
1675
|
+
return svc.notesAdd({ appId: app_id, ticketId: ticket_id, text });
|
|
1676
|
+
case "update":
|
|
1677
|
+
if (!note_id || !text) throw new Error("op=update requires note_id and text.");
|
|
1678
|
+
return svc.notesUpdate({ noteId: note_id, text });
|
|
1679
|
+
case "delete":
|
|
1680
|
+
if (!note_id) throw new Error("op=delete requires note_id.");
|
|
1681
|
+
return svc.notesDelete({ noteId: note_id });
|
|
1682
|
+
case "list":
|
|
1683
|
+
return svc.notesList({ appId: app_id, ticketId: ticket_id });
|
|
1684
|
+
}
|
|
1685
|
+
})
|
|
1686
|
+
);
|
|
1687
|
+
}
|
|
1688
|
+
|
|
2087
1689
|
// src/index.ts
|
|
2088
1690
|
var server = new McpServer2({
|
|
2089
1691
|
name: SERVER_NAME_OVERRIDE ?? SERVER_NAME,
|
|
2090
1692
|
version: SERVER_VERSION_OVERRIDE ?? SERVER_VERSION
|
|
2091
1693
|
});
|
|
2092
1694
|
registerTeamDynamixDomainGatewayTools(server);
|
|
1695
|
+
registerTeamDynamixWatchTools(server);
|
|
2093
1696
|
registerTeamDynamixResources(server);
|
|
2094
1697
|
async function main() {
|
|
2095
1698
|
console.error(`[teamdynamix-mcp] log level: ${LOG_LEVEL}`);
|
|
@@ -2097,9 +1700,37 @@ async function main() {
|
|
|
2097
1700
|
const config = getTeamDynamixConfig();
|
|
2098
1701
|
console.error(`[teamdynamix-mcp] sanitized config: ${JSON.stringify(redactTeamDynamixConfig(config))}`);
|
|
2099
1702
|
}
|
|
1703
|
+
startWatchSweepTimer();
|
|
2100
1704
|
const transport = new StdioServerTransport();
|
|
2101
1705
|
await server.connect(transport);
|
|
2102
1706
|
}
|
|
1707
|
+
function startWatchSweepTimer() {
|
|
1708
|
+
const secs = Number(process.env["TEAMDYNAMIX_WATCH_SWEEP_SECS"] ?? 0);
|
|
1709
|
+
if (!Number.isFinite(secs) || secs <= 0) return;
|
|
1710
|
+
const timer = setInterval(() => {
|
|
1711
|
+
import("./watch.store-TMX6RTON.js").then(async ({ loadLedger: loadLedger2, saveLedger, emptyLedger: emptyLedger2, defaultLedgerPath: defaultLedgerPath2, LedgerCorruptError: LedgerCorruptError2 }) => {
|
|
1712
|
+
const { createConfiguredTeamDynamixClient: createConfiguredTeamDynamixClient2 } = await import("./client.service-B22MXWP4.js");
|
|
1713
|
+
const { WorkspaceWatchService: WorkspaceWatchService2 } = await import("./watch.service-D367V6RC.js");
|
|
1714
|
+
const ledgerPath = defaultLedgerPath2();
|
|
1715
|
+
let ledger;
|
|
1716
|
+
try {
|
|
1717
|
+
ledger = await loadLedger2(ledgerPath);
|
|
1718
|
+
} catch (cause) {
|
|
1719
|
+
if (cause instanceof LedgerCorruptError2) throw cause;
|
|
1720
|
+
ledger = emptyLedger2();
|
|
1721
|
+
}
|
|
1722
|
+
const client = await createConfiguredTeamDynamixClient2();
|
|
1723
|
+
const svc = new WorkspaceWatchService2(ledger, ledgerPath, client);
|
|
1724
|
+
const result = await svc.sweep();
|
|
1725
|
+
console.error(`[teamdynamix-mcp] watch sweep: ${JSON.stringify(result)}`);
|
|
1726
|
+
}).catch((cause) => {
|
|
1727
|
+
console.error(
|
|
1728
|
+
`[teamdynamix-mcp] watch sweep failed: ${cause instanceof Error ? cause.message : String(cause)}`
|
|
1729
|
+
);
|
|
1730
|
+
});
|
|
1731
|
+
}, secs * 1e3);
|
|
1732
|
+
timer.unref();
|
|
1733
|
+
}
|
|
2103
1734
|
main().catch((error) => {
|
|
2104
1735
|
const message = error instanceof Error ? error.message : String(error);
|
|
2105
1736
|
console.error(`Server startup failed: ${message}`);
|