@crypto512/jicon-mcp 2.3.25 → 2.3.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/confluence/formatters.d.ts +10 -0
- package/dist/confluence/formatters.d.ts.map +1 -1
- package/dist/confluence/formatters.js +72 -4
- package/dist/confluence/formatters.js.map +1 -1
- package/dist/confluence/tools.d.ts.map +1 -1
- package/dist/confluence/tools.js +18 -5
- package/dist/confluence/tools.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/session/context.d.ts +7 -0
- package/dist/session/context.d.ts.map +1 -1
- package/dist/session/context.js +10 -0
- package/dist/session/context.js.map +1 -1
- package/dist/session/index.d.ts +1 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +2 -0
- package/dist/session/index.js.map +1 -1
- package/dist/session/manager.d.ts +2 -0
- package/dist/session/manager.d.ts.map +1 -1
- package/dist/session/manager.js +5 -0
- package/dist/session/manager.js.map +1 -1
- package/dist/tempo/client.d.ts +0 -14
- package/dist/tempo/client.d.ts.map +1 -1
- package/dist/tempo/client.js +0 -57
- package/dist/tempo/client.js.map +1 -1
- package/dist/tempo/tools.d.ts.map +1 -1
- package/dist/tempo/tools.js +16 -9
- package/dist/tempo/tools.js.map +1 -1
- package/dist/transport/http.d.ts.map +1 -1
- package/dist/transport/http.js +1 -0
- package/dist/transport/http.js.map +1 -1
- package/dist/utils/user-resolver.d.ts +38 -0
- package/dist/utils/user-resolver.d.ts.map +1 -0
- package/dist/utils/user-resolver.js +96 -0
- package/dist/utils/user-resolver.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared user display name resolver
|
|
3
|
+
*
|
|
4
|
+
* Resolves Jira userkeys/usernames to display names via Jira REST API.
|
|
5
|
+
* Session-scoped cache ensures each user is resolved at most once per session,
|
|
6
|
+
* shared across Tempo and Confluence tools.
|
|
7
|
+
*/
|
|
8
|
+
import { debug } from "./logger.js";
|
|
9
|
+
export class UserResolver {
|
|
10
|
+
cache = new Map();
|
|
11
|
+
fullCache = new Map();
|
|
12
|
+
http;
|
|
13
|
+
constructor(http) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve a single userkey/username to display name
|
|
18
|
+
* Tries username lookup first, falls back to key lookup (for JIRAUSER/hex format)
|
|
19
|
+
*/
|
|
20
|
+
async resolveUserDisplayName(userKey) {
|
|
21
|
+
if (this.cache.has(userKey)) {
|
|
22
|
+
return this.cache.get(userKey);
|
|
23
|
+
}
|
|
24
|
+
const resolved = await this.resolveUser(userKey);
|
|
25
|
+
return resolved.displayName;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a single userkey/username to full user info (username + displayName)
|
|
29
|
+
*/
|
|
30
|
+
async resolveUser(userKey) {
|
|
31
|
+
if (this.fullCache.has(userKey)) {
|
|
32
|
+
return this.fullCache.get(userKey);
|
|
33
|
+
}
|
|
34
|
+
let resolved = { username: userKey, displayName: userKey };
|
|
35
|
+
try {
|
|
36
|
+
const user = await this.http.get(`/rest/api/2/user?username=${encodeURIComponent(userKey)}`);
|
|
37
|
+
resolved = {
|
|
38
|
+
username: user.name || userKey,
|
|
39
|
+
displayName: user.displayName || user.name || userKey,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
try {
|
|
44
|
+
const user = await this.http.get(`/rest/api/2/user?key=${encodeURIComponent(userKey)}`);
|
|
45
|
+
resolved = {
|
|
46
|
+
username: user.name || userKey,
|
|
47
|
+
displayName: user.displayName || user.name || userKey,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
debug(`User lookup failed for key: ${userKey}, using as-is`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
this.cache.set(userKey, resolved.displayName);
|
|
55
|
+
this.fullCache.set(userKey, resolved);
|
|
56
|
+
return resolved;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Resolve multiple userkeys to display names in parallel
|
|
60
|
+
* Uses persistent cache to avoid repeated API calls
|
|
61
|
+
*/
|
|
62
|
+
async resolveUserDisplayNames(userKeys) {
|
|
63
|
+
const uniqueKeys = [...new Set(userKeys.filter(Boolean))];
|
|
64
|
+
const result = new Map();
|
|
65
|
+
const uncachedKeys = uniqueKeys.filter(key => !this.cache.has(key));
|
|
66
|
+
// Resolve in parallel batches of 5 to avoid rate limiting
|
|
67
|
+
const batchSize = 5;
|
|
68
|
+
for (let i = 0; i < uncachedKeys.length; i += batchSize) {
|
|
69
|
+
const batch = uncachedKeys.slice(i, i + batchSize);
|
|
70
|
+
await Promise.all(batch.map(key => this.resolveUser(key)));
|
|
71
|
+
}
|
|
72
|
+
for (const key of uniqueKeys) {
|
|
73
|
+
result.set(key, this.cache.get(key) || key);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Resolve multiple userkeys to full user info (username + displayName)
|
|
79
|
+
* Used by Confluence to produce @username (Display Name) in plain text
|
|
80
|
+
*/
|
|
81
|
+
async resolveUsers(userKeys) {
|
|
82
|
+
const uniqueKeys = [...new Set(userKeys.filter(Boolean))];
|
|
83
|
+
const result = new Map();
|
|
84
|
+
const uncachedKeys = uniqueKeys.filter(key => !this.fullCache.has(key));
|
|
85
|
+
const batchSize = 5;
|
|
86
|
+
for (let i = 0; i < uncachedKeys.length; i += batchSize) {
|
|
87
|
+
const batch = uncachedKeys.slice(i, i + batchSize);
|
|
88
|
+
await Promise.all(batch.map(key => this.resolveUser(key)));
|
|
89
|
+
}
|
|
90
|
+
for (const key of uniqueKeys) {
|
|
91
|
+
result.set(key, this.fullCache.get(key) || { username: key, displayName: key });
|
|
92
|
+
}
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=user-resolver.js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