@valoranchi/riot-client 0.4.0 → 0.6.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.
Files changed (156) hide show
  1. package/README.md +15 -0
  2. package/dist/RiotClient.d.ts +4 -1
  3. package/dist/RiotClient.d.ts.map +1 -1
  4. package/dist/RiotClient.js +7 -1
  5. package/dist/RiotClient.js.map +1 -1
  6. package/dist/analysis/wishlist.d.ts +5 -0
  7. package/dist/analysis/wishlist.d.ts.map +1 -0
  8. package/dist/analysis/wishlist.js +122 -0
  9. package/dist/analysis/wishlist.js.map +1 -0
  10. package/dist/catalogue/Catalogue.d.ts +1 -0
  11. package/dist/catalogue/Catalogue.d.ts.map +1 -1
  12. package/dist/catalogue/Catalogue.js +11 -0
  13. package/dist/catalogue/Catalogue.js.map +1 -1
  14. package/dist/cli.d.ts +10 -9
  15. package/dist/cli.d.ts.map +1 -1
  16. package/dist/cli.js +205 -36
  17. package/dist/cli.js.map +1 -1
  18. package/dist/client/AccountService.d.ts.map +1 -1
  19. package/dist/client/AccountService.js.map +1 -1
  20. package/dist/client/ClientContext.d.ts +4 -0
  21. package/dist/client/ClientContext.d.ts.map +1 -1
  22. package/dist/client/ClientContext.js.map +1 -1
  23. package/dist/client/OfficialService.d.ts +35 -0
  24. package/dist/client/OfficialService.d.ts.map +1 -0
  25. package/dist/client/OfficialService.js +141 -0
  26. package/dist/client/OfficialService.js.map +1 -0
  27. package/dist/client/StoreService.d.ts +6 -1
  28. package/dist/client/StoreService.d.ts.map +1 -1
  29. package/dist/client/StoreService.js +87 -5
  30. package/dist/client/StoreService.js.map +1 -1
  31. package/dist/client/api.d.ts +32 -1
  32. package/dist/client/api.d.ts.map +1 -1
  33. package/dist/dashboardLauncher.d.ts +12 -0
  34. package/dist/dashboardLauncher.d.ts.map +1 -0
  35. package/dist/dashboardLauncher.js +94 -0
  36. package/dist/dashboardLauncher.js.map +1 -0
  37. package/dist/errors.d.ts +12 -2
  38. package/dist/errors.d.ts.map +1 -1
  39. package/dist/errors.js +20 -3
  40. package/dist/errors.js.map +1 -1
  41. package/dist/formatError.d.ts +10 -0
  42. package/dist/formatError.d.ts.map +1 -0
  43. package/dist/formatError.js +29 -0
  44. package/dist/formatError.js.map +1 -0
  45. package/dist/index.d.ts +7 -5
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +5 -3
  48. package/dist/index.js.map +1 -1
  49. package/dist/mcp/McpServer.d.ts +21 -0
  50. package/dist/mcp/McpServer.d.ts.map +1 -0
  51. package/dist/mcp/McpServer.js +135 -0
  52. package/dist/mcp/McpServer.js.map +1 -0
  53. package/dist/mcp/index.d.ts +4 -0
  54. package/dist/mcp/index.d.ts.map +1 -0
  55. package/dist/mcp/index.js +3 -0
  56. package/dist/mcp/index.js.map +1 -0
  57. package/dist/mcp/tools.d.ts +9 -0
  58. package/dist/mcp/tools.d.ts.map +1 -0
  59. package/dist/mcp/tools.js +83 -0
  60. package/dist/mcp/tools.js.map +1 -0
  61. package/dist/mcp/types.d.ts +46 -0
  62. package/dist/mcp/types.d.ts.map +1 -0
  63. package/dist/mcp/types.js +2 -0
  64. package/dist/mcp/types.js.map +1 -0
  65. package/dist/model/index.d.ts +45 -0
  66. package/dist/model/index.d.ts.map +1 -1
  67. package/dist/official/OfficialApi.d.ts +35 -0
  68. package/dist/official/OfficialApi.d.ts.map +1 -0
  69. package/dist/official/OfficialApi.js +148 -0
  70. package/dist/official/OfficialApi.js.map +1 -0
  71. package/dist/official/OfficialMatchAdapter.d.ts +11 -0
  72. package/dist/official/OfficialMatchAdapter.d.ts.map +1 -0
  73. package/dist/official/OfficialMatchAdapter.js +157 -0
  74. package/dist/official/OfficialMatchAdapter.js.map +1 -0
  75. package/dist/official/RateLimiter.d.ts +20 -0
  76. package/dist/official/RateLimiter.d.ts.map +1 -0
  77. package/dist/official/RateLimiter.js +56 -0
  78. package/dist/official/RateLimiter.js.map +1 -0
  79. package/dist/official/types.d.ts +214 -0
  80. package/dist/official/types.d.ts.map +1 -0
  81. package/dist/official/types.js +2 -0
  82. package/dist/official/types.js.map +1 -0
  83. package/dist/raw.d.ts +4 -0
  84. package/dist/raw.d.ts.map +1 -1
  85. package/dist/raw.js +4 -0
  86. package/dist/raw.js.map +1 -1
  87. package/dist/riot/HttpGateway.d.ts.map +1 -1
  88. package/dist/riot/HttpGateway.js +9 -2
  89. package/dist/riot/HttpGateway.js.map +1 -1
  90. package/dist/riot/ResponseCache.d.ts +2 -0
  91. package/dist/riot/ResponseCache.d.ts.map +1 -1
  92. package/dist/riot/ResponseCache.js +8 -2
  93. package/dist/riot/ResponseCache.js.map +1 -1
  94. package/dist/serve/dashboard/dashboardCss.d.ts +2 -0
  95. package/dist/serve/dashboard/dashboardCss.d.ts.map +1 -0
  96. package/dist/serve/dashboard/dashboardCss.js +634 -0
  97. package/dist/serve/dashboard/dashboardCss.js.map +1 -0
  98. package/dist/serve/dashboard/dashboardHtml.d.ts +2 -0
  99. package/dist/serve/dashboard/dashboardHtml.d.ts.map +1 -0
  100. package/dist/serve/dashboard/dashboardHtml.js +95 -0
  101. package/dist/serve/dashboard/dashboardHtml.js.map +1 -0
  102. package/dist/serve/dashboard/dashboardJs.d.ts +2 -0
  103. package/dist/serve/dashboard/dashboardJs.d.ts.map +1 -0
  104. package/dist/serve/dashboard/dashboardJs.js +668 -0
  105. package/dist/serve/dashboard/dashboardJs.js.map +1 -0
  106. package/dist/serve/dashboard/index.d.ts +4 -0
  107. package/dist/serve/dashboard/index.d.ts.map +1 -0
  108. package/dist/serve/dashboard/index.js +4 -0
  109. package/dist/serve/dashboard/index.js.map +1 -0
  110. package/dist/serve/index.d.ts +2 -1
  111. package/dist/serve/index.d.ts.map +1 -1
  112. package/dist/serve/index.js +1 -0
  113. package/dist/serve/index.js.map +1 -1
  114. package/dist/serve/indexHtml.d.ts.map +1 -1
  115. package/dist/serve/indexHtml.js +1 -0
  116. package/dist/serve/indexHtml.js.map +1 -1
  117. package/dist/serve/openapi.d.ts.map +1 -1
  118. package/dist/serve/openapi.js +11 -0
  119. package/dist/serve/openapi.js.map +1 -1
  120. package/dist/serve/routes.d.ts +4 -2
  121. package/dist/serve/routes.d.ts.map +1 -1
  122. package/dist/serve/routes.js +434 -0
  123. package/dist/serve/routes.js.map +1 -1
  124. package/dist/serve/security.d.ts +6 -0
  125. package/dist/serve/security.d.ts.map +1 -0
  126. package/dist/serve/security.js +65 -0
  127. package/dist/serve/security.js.map +1 -0
  128. package/dist/serve/server.d.ts.map +1 -1
  129. package/dist/serve/server.js +38 -5
  130. package/dist/serve/server.js.map +1 -1
  131. package/dist/serve/types.d.ts +8 -0
  132. package/dist/serve/types.d.ts.map +1 -1
  133. package/dist/version.d.ts +2 -0
  134. package/dist/version.d.ts.map +1 -0
  135. package/dist/version.js +12 -0
  136. package/dist/version.js.map +1 -0
  137. package/dist/watch/StoreWatcher.d.ts +27 -0
  138. package/dist/watch/StoreWatcher.d.ts.map +1 -0
  139. package/dist/watch/StoreWatcher.js +116 -0
  140. package/dist/watch/StoreWatcher.js.map +1 -0
  141. package/dist/watch/WebhookNotifier.d.ts +8 -0
  142. package/dist/watch/WebhookNotifier.d.ts.map +1 -0
  143. package/dist/watch/WebhookNotifier.js +42 -0
  144. package/dist/watch/WebhookNotifier.js.map +1 -0
  145. package/dist/watch/index.d.ts +9 -3
  146. package/dist/watch/index.d.ts.map +1 -1
  147. package/dist/watch/index.js +12 -1
  148. package/dist/watch/index.js.map +1 -1
  149. package/dist/watch/types.d.ts +17 -1
  150. package/dist/watch/types.d.ts.map +1 -1
  151. package/package.json +1 -1
  152. package/schema/OfficialAccount.json +25 -0
  153. package/schema/OfficialProfile.json +354 -0
  154. package/schema/Wishlist.json +35 -0
  155. package/schema/WishlistCheck.json +67 -0
  156. package/schema/WishlistHit.json +51 -0
@@ -0,0 +1,94 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createRequire } from "node:module";
3
+ export function isSea() {
4
+ try {
5
+ const req = createRequire(import.meta.url);
6
+ const sea = req("node:sea");
7
+ return typeof sea?.isSea === "function" && sea.isSea();
8
+ }
9
+ catch {
10
+ return false;
11
+ }
12
+ }
13
+ export function shouldLaunchDashboard(options) {
14
+ return options.argsLength === 0 && options.isSea;
15
+ }
16
+ export function openBrowser(url) {
17
+ try {
18
+ const platform = process.platform;
19
+ if (platform === "win32") {
20
+ const child = spawn("cmd", ["/c", "start", "", url], {
21
+ windowsHide: true,
22
+ stdio: "ignore",
23
+ detached: true,
24
+ });
25
+ child.on("error", () => { });
26
+ child.unref();
27
+ }
28
+ else if (platform === "darwin") {
29
+ const child = spawn("open", [url], {
30
+ stdio: "ignore",
31
+ detached: true,
32
+ });
33
+ child.on("error", () => { });
34
+ child.unref();
35
+ }
36
+ else {
37
+ const child = spawn("xdg-open", [url], {
38
+ stdio: "ignore",
39
+ detached: true,
40
+ });
41
+ child.on("error", () => { });
42
+ child.unref();
43
+ }
44
+ }
45
+ catch {
46
+ // Failures only print the URL
47
+ }
48
+ }
49
+ export function printDashboardBanner(url) {
50
+ process.stdout.write(`
51
+ ==================================================
52
+ Valoranchi Dashboard
53
+ ${url}
54
+ ==================================================
55
+ Keep this window open. Close it to stop the server.
56
+
57
+ `);
58
+ }
59
+ export async function startDashboardServer(client, startPort = 47800, maxAttempts = 10) {
60
+ let lastError;
61
+ for (let offset = 0; offset <= maxAttempts; offset++) {
62
+ const port = startPort + offset;
63
+ try {
64
+ return await client.serve({ port, host: "127.0.0.1", allowRemote: false });
65
+ }
66
+ catch (err) {
67
+ const code = err?.code;
68
+ if (code === "EADDRINUSE") {
69
+ lastError = err;
70
+ continue;
71
+ }
72
+ throw err;
73
+ }
74
+ }
75
+ throw lastError;
76
+ }
77
+ export async function runDashboard(client) {
78
+ const server = await startDashboardServer(client, 47800, 10);
79
+ printDashboardBanner(server.url);
80
+ openBrowser(server.url);
81
+ await new Promise((resolve) => {
82
+ const onSignal = () => {
83
+ process.off("SIGINT", onSignal);
84
+ process.off("SIGTERM", onSignal);
85
+ resolve();
86
+ };
87
+ process.on("SIGINT", onSignal);
88
+ process.on("SIGTERM", onSignal);
89
+ });
90
+ await server.close();
91
+ await client.close();
92
+ return 0;
93
+ }
94
+ //# sourceMappingURL=dashboardLauncher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dashboardLauncher.js","sourceRoot":"","sources":["../src/dashboardLauncher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAI5C,MAAM,UAAU,KAAK;IACnB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,GAAG,CAAC,UAAU,CAA8B,CAAC;QACzD,OAAO,OAAO,GAAG,EAAE,KAAK,KAAK,UAAU,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;IACzD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,OAA+C;IACnF,OAAO,OAAO,CAAC,UAAU,KAAK,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC;QAClC,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE;gBACnD,WAAW,EAAE,IAAI;gBACjB,KAAK,EAAE,QAAQ;gBACf,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;YAC5B,KAAK,C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QAAC,OAAO,GAAY,EAAE,CAAC;YACtB,MAAM,IAAI,GAAI,GAAyB,EAAE,IAAI,CAAC;YAC9C,IAAI,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC1B,SAAS,GAAG,GAAG,CAAC;gBAChB,SAAS;YACX,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,MAAM,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAkB;IACnD,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;IAC7D,oBAAoB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACjC,WAAW,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAExB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAClC,MAAM,QAAQ,GAAG,GAAG,EAAE;YACpB,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;YACjC,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QACF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC/B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACrB,OAAO,CAAC,CAAC;AACX,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -12,12 +12,22 @@ export declare class RegionUnknownError extends RiotClientError {
12
12
  constructor(message?: string);
13
13
  }
14
14
  export declare class ForbiddenHostError extends RiotClientError {
15
- constructor(host: string);
15
+ constructor(host: string, message?: string);
16
+ }
17
+ export declare class ForbiddenOriginError extends RiotClientError {
18
+ constructor(origin?: string);
19
+ }
20
+ export declare class UnsupportedMediaTypeError extends RiotClientError {
21
+ constructor(contentType?: string);
16
22
  }
17
23
  export declare class RiotApiError extends RiotClientError {
18
24
  readonly status: number;
19
25
  readonly url: string;
20
- constructor(status: number, rawUrl: string, message?: string);
26
+ readonly retryAfterSeconds?: number;
27
+ constructor(status: number, rawUrl: string, message?: string, retryAfterSeconds?: number);
28
+ }
29
+ export declare class OfficialApiKeyMissingError extends RiotClientError {
30
+ constructor(message?: string);
21
31
  }
22
32
  export declare class ValidationError extends RiotClientError {
23
33
  readonly reason: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAK1C;AAED,qBAAa,yBAA0B,SAAQ,eAAe;gBAChD,OAAO,SAA+B;CAGnD;AAED,qBAAa,uBAAwB,SAAQ,eAAe;gBAC9C,OAAO,SAAiC;CAGrD;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,OAAO,SAAuC;CAG3D;AAED,qBAAa,kBAAmB,SAAQ,eAAe;gBACzC,IAAI,EAAE,MAAM;CAGzB;AAED,qBAAa,YAAa,SAAQ,eAAe;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;gBAET,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;CAS7D;AAED,qBAAa,eAAgB,SAAQ,eAAe;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGxC,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAA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AAO,CAAC,CAAC;gBAGxC,MAAM,EAAE,MAAM,EACd,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAWpC"}
package/dist/errors.js CHANGED
@@ -22,18 +22,35 @@ export class RegionUnknownError extends RiotClientError {
22
22
  }
23
23
  }
24
24
  export class ForbiddenHostError extends RiotClientError {
25
- constructor(host) {
26
- super(`Host '${host}' is not allowed to receive Riot credentials`, "FORBIDDEN_HOST");
25
+ constructor(host, message) {
26
+ super(message ?? `Host '${host}' is not allowed to receive Riot credentials`, "FORBIDDEN_HOST");
27
+ }
28
+ }
29
+ export class ForbiddenOriginError extends RiotClientError {
30
+ constructor(origin) {
31
+ super(origin ? `Origin '${origin}' is not allowed` : "Origin is not allowed", "FORBIDDEN_ORIGIN");
32
+ }
33
+ }
34
+ export class UnsupportedMediaTypeError extends RiotClientError {
35
+ constructor(contentType) {
36
+ super(`Unsupported media type: ${contentType ?? "none"}. Expected application/json`, "UNSUPPORTED_MEDIA_TYPE");
27
37
  }
28
38
  }
29
39
  export class RiotApiError extends RiotClientError {
30
40
  status;
31
41
  url;
32
- constructor(status, rawUrl, message) {
42
+ retryAfterSeconds;
43
+ constructor(status, rawUrl, message, retryAfterSeconds) {
33
44
  const sanitizedUrl = rawUrl.split("?")[0];
34
45
  super(message ?? `Riot API request to ${sanitizedUrl} failed with status ${status}`, "RIOT_API_ERROR");
35
46
  this.status = status;
36
47
  this.url = sanitizedUrl;
48
+ this.retryAfterSeconds = retryAfterSeconds;
49
+ }
50
+ }
51
+ export class OfficialApiKeyMissingError extends RiotClientError {
52
+ constructor(message = "Official Riot API key is missing") {
53
+ super(message, "OFFICIAL_API_KEY_MISSING");
37
54
  }
38
55
  }
39
56
  export class ValidationError extends RiotClientError {
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],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,MAAc,EACd,gBAAmD,EACnD,OAAiC;QAEjC,MAAM,OAAO,GAAG,OAAO,gBAAgB,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,MAAM,CAAC;QACjF,MAAM,YAAY,GAChB,OAAO,gBAAgB,KAAK,QAAQ,IAAI,gBAAgB,KAAK,IAAI;YAC/D,CAAC,CAAC,gBAAgB;YAClB,CAAC,CAAC,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;QACtB,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,YAAY,CAAC;IAC9B,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ export interface FormattedError {
2
+ error: {
3
+ code: string;
4
+ message: string;
5
+ reason?: string;
6
+ details?: Record<string, unknown>;
7
+ };
8
+ }
9
+ export declare function formatError(error: unknown): FormattedError;
10
+ //# sourceMappingURL=formatError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatError.d.ts","sourceRoot":"","sources":["../src/formatError.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACnC,CAAC;CACH;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CA0B1D"}
@@ -0,0 +1,29 @@
1
+ import { RiotClientError, ValidationError } from "./errors.js";
2
+ export function formatError(error) {
3
+ if (error instanceof ValidationError) {
4
+ return {
5
+ error: {
6
+ code: error.code,
7
+ reason: error.reason,
8
+ message: error.message,
9
+ details: error.details,
10
+ },
11
+ };
12
+ }
13
+ if (error instanceof RiotClientError) {
14
+ return {
15
+ error: {
16
+ code: error.code,
17
+ message: error.message,
18
+ },
19
+ };
20
+ }
21
+ const message = error instanceof Error ? error.message : String(error);
22
+ return {
23
+ error: {
24
+ code: "UNKNOWN_ERROR",
25
+ message,
26
+ },
27
+ };
28
+ }
29
+ //# sourceMappingURL=formatError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatError.js","sourceRoot":"","sources":["../src/formatError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAW/D,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QACrC,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;SACF,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QACrC,OAAO;YACL,KAAK,EAAE;gBACL,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB;SACF,CAAC;IACJ,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE,eAAe;YACrB,OAAO;SACR;KACF,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,15 +1,16 @@
1
1
  export { defaultResponseCacheDir } from "./riot/ResponseCache.js";
2
2
  export { defaultCatalogueDir } from "./catalogue/CatalogueStore.js";
3
3
  export { RiotClient, type RiotClientOptions, type LoadoutChange, type LoadoutGunChange, type PartyActionRequest, } from "./RiotClient.js";
4
- export type { AccountApi, LocalRawApi, MatchesApi, PartyApi, RiotRawApi, SocialApi, StoreApi, } from "./client/api.js";
4
+ export type { AccountApi, LocalRawApi, MatchesApi, OfficialApi, PartyApi, RiotRawApi, SocialApi, StoreApi, } from "./client/api.js";
5
5
  export { PartyValidator, type PartyAction } from "./client/PartyValidator.js";
6
6
  export { RiotEvents, toFriendRequest, type RiotEventMap } from "./events/RiotEvents.js";
7
7
  export { TypedEmitter } from "./events/TypedEmitter.js";
8
- export { FriendsWatcher, MatchWatcher, formatPresenceActivity, type FriendsWatcherOptions, type MatchWatcherOptions, type WatchApi, type MatchWatchEventMap, type MatchWatchItem, type FriendsWatchEventMap, type FriendsWatchItem, } from "./watch/index.js";
9
- export { createRiotServer, httpStatusForError, isLoopback, buildOpenApiSpec, renderIndexHtml, handleSse, CONFIRM_GATED_ROUTES, ROUTE_DEFINITIONS, dispatchApiRoute, type RouteDefinition, type ServeOptions, type ServerInstance, } from "./serve/index.js";
8
+ export { FriendsWatcher, MatchWatcher, StoreWatcher, WebhookNotifier, formatPresenceActivity, type FriendsWatcherOptions, type MatchWatcherOptions, type StoreWatcherOptions, type WatchApi, type MatchWatchEventMap, type MatchWatchItem, type FriendsWatchEventMap, type FriendsWatchItem, type StoreWatchEventMap, type StoreWatchItem, } from "./watch/index.js";
9
+ export { createRiotServer, httpStatusForError, isLoopback, buildOpenApiSpec, renderIndexHtml, renderDashboardHtml, renderDashboardCss, renderDashboardJs, handleSse, CONFIRM_GATED_ROUTES, ROUTE_DEFINITIONS, dispatchApiRoute, type RouteDefinition, type RouteParam, type ServeOptions, type ServerInstance, } from "./serve/index.js";
10
+ export { McpServer, getMcpTools, executeMcpTool, McpError, type McpServerOptions, type McpTool, type McpToolInputSchema, type McpToolProperty, type McpToolResult, type McpTextContent, } from "./mcp/index.js";
10
11
  export { RiotSocket, parseFrame, type RiotFrame, type RiotEventType, type RiotSocketOptions, type RiotSocketCredentials, } from "./local/RiotSocket.js";
11
- export { ForbiddenHostError, RegionUnknownError, RiotApiError, RiotClientError, RiotClientNotReadyError, RiotClientNotRunningError, ValidationError, } from "./errors.js";
12
- export type { AccessoryOffer, Agent, BlockedPlayer, Bundle, BundleItem, Conversation, Cost, DailyOffer, Friend, FriendRequest, Image, LiveMatch, LiveMatchPlayer, Loadout, LoadoutGun, Match, MatchPlayer, MatchRound, MatchSummary, Message, Mmr, NightMarketOffer, OwnedAgent, OwnedBuddy, OwnedCard, OwnedChroma, OwnedItems, OwnedSkin, OwnedSkinLevel, OwnedSpray, OwnedTitle, OwnedWeapon, Party, PartyMember, Player, PresenceState, RadianiteOffer, Rank, RankChange, RatingTrend, PerformanceSummary, PlayerAssessment, LoadoutDiff, LoadoutDiffItem, CollectionValue, CollectionValueGroup, CollectionValueItem, StoreHistory, StoreHistoryDay, StoreSeen, MatchSyncResult, Store, StoreItem, Tier, ValorantPresence, Wallet, } from "./model/index.js";
12
+ export { ForbiddenHostError, ForbiddenOriginError, OfficialApiKeyMissingError, RegionUnknownError, RiotApiError, RiotClientError, RiotClientNotReadyError, RiotClientNotRunningError, UnsupportedMediaTypeError, ValidationError, } from "./errors.js";
13
+ export type { AccessoryOffer, Agent, BlockedPlayer, Bundle, BundleItem, CatalogSkin, Conversation, Cost, DailyOffer, Friend, FriendRequest, Image, LiveMatch, LiveMatchPlayer, Loadout, LoadoutGun, Match, MatchPlayer, MatchRound, MatchSummary, Message, Mmr, NightMarketOffer, OfficialAccount, OfficialProfile, OwnedAgent, OwnedBuddy, OwnedCard, OwnedChroma, OwnedItems, OwnedSkin, OwnedSkinLevel, OwnedSpray, OwnedTitle, OwnedWeapon, Party, PartyMember, Player, PresenceState, RadianiteOffer, Rank, RankChange, RatingTrend, PerformanceSummary, PlayerAssessment, LoadoutDiff, LoadoutDiffItem, CollectionValue, CollectionValueGroup, CollectionValueItem, StoreHistory, StoreHistoryDay, StoreSeen, MatchSyncResult, Store, StoreItem, Tier, ValorantPresence, Wallet, Wishlist, WishlistCheck, WishlistEntry, WishlistHit, } from "./model/index.js";
13
14
  export { ratingTrend } from "./analysis/ratingTrend.js";
14
15
  export { performanceSummary } from "./analysis/performanceSummary.js";
15
16
  export { playerAssessment } from "./analysis/playerAssessment.js";
@@ -17,4 +18,5 @@ export { diffLoadout, exportLoadout } from "./analysis/loadoutDiff.js";
17
18
  export { collectionValue } from "./analysis/collectionValue.js";
18
19
  export { recordStoreRotation, querySkinSeen, loadStoreHistory, saveStoreHistory, } from "./analysis/storeHistory.js";
19
20
  export { loadKnownMatches, saveKnownMatches, syncMatches } from "./analysis/matchSync.js";
21
+ export { loadWishlist, saveWishlist, wishlistHits } from "./analysis/wishlist.js";
20
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,QAAQ,EACR,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,cAAc,EACd,YAAY,EACZ,sBAAsB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,GACtB,M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AU,EACV,WAAW,EACX,KAAK,EACL,WAAW,EACX,MAAM,EACN,aAAa,EACb,cAAc,EACd,IAAI,EACJ,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,SAAS,EACT,eAAe,EACf,KAAK,EACL,SAAS,EACT,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,QAAQ,EACR,aAAa,EACb,aAAa,EACb,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACvE,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EACL,mBAAmB,EACnB,aAAa,EACb,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -4,10 +4,11 @@ export { RiotClient, } from "./RiotClient.js";
4
4
  export { PartyValidator } from "./client/PartyValidator.js";
5
5
  export { RiotEvents, toFriendRequest } from "./events/RiotEvents.js";
6
6
  export { TypedEmitter } from "./events/TypedEmitter.js";
7
- export { FriendsWatcher, MatchWatcher, formatPresenceActivity, } from "./watch/index.js";
8
- export { createRiotServer, httpStatusForError, isLoopback, buildOpenApiSpec, renderIndexHtml, handleSse, CONFIRM_GATED_ROUTES, ROUTE_DEFINITIONS, dispatchApiRoute, } from "./serve/index.js";
7
+ export { FriendsWatcher, MatchWatcher, StoreWatcher, WebhookNotifier, formatPresenceActivity, } from "./watch/index.js";
8
+ export { createRiotServer, httpStatusForError, isLoopback, buildOpenApiSpec, renderIndexHtml, renderDashboardHtml, renderDashboardCss, renderDashboardJs, handleSse, CONFIRM_GATED_ROUTES, ROUTE_DEFINITIONS, dispatchApiRoute, } from "./serve/index.js";
9
+ export { McpServer, getMcpTools, executeMcpTool, McpError, } from "./mcp/index.js";
9
10
  export { RiotSocket, parseFrame, } from "./local/RiotSocket.js";
10
- export { ForbiddenHostError, RegionUnknownError, RiotApiError, RiotClientError, RiotClientNotReadyError, RiotClientNotRunningError, ValidationError, } from "./errors.js";
11
+ export { ForbiddenHostError, ForbiddenOriginError, OfficialApiKeyMissingError, RegionUnknownError, RiotApiError, RiotClientError, RiotClientNotReadyError, RiotClientNotRunningError, UnsupportedMediaTypeError, ValidationError, } from "./errors.js";
11
12
  export { ratingTrend } from "./analysis/ratingTrend.js";
12
13
  export { performanceSummary } from "./analysis/performanceSummary.js";
13
14
  export { playerAssessment } from "./analysis/playerAssessment.js";
@@ -15,4 +16,5 @@ export { diffLoadout, exportLoadout } from "./analysis/loadoutDiff.js";
15
16
  export { collectionValue } from "./analysis/collectionValue.js";
16
17
  export { recordStoreRotation, querySkinSeen, loadStoreHistory, saveStoreHistory, } from "./analysis/storeHistory.js";
17
18
  export { loadKnownMatches, saveKnownMatches, syncMatches } from "./analysis/matchSync.js";
19
+ export { loadWishlist, saveWishlist, wishlistHits } from "./analysis/wishlist.js";
18
20
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EACL,UAAU,GAKX,MAAM,iBAAiB,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AAE,MAAM,yBAAyB,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { RiotClient } from "../RiotClient.js";
2
+ import type { McpServerOptions } from "./types.js";
3
+ export declare class McpServer {
4
+ private readonly client;
5
+ private readonly input;
6
+ private readonly output;
7
+ private readonly version;
8
+ private rl?;
9
+ private startPromise?;
10
+ private resolveClose?;
11
+ constructor(client: RiotClient, options?: McpServerOptions);
12
+ start(): Promise<void>;
13
+ close(): void;
14
+ private sendResponse;
15
+ private handleInitialize;
16
+ private handleToolsCall;
17
+ private dispatchRequest;
18
+ private handleMessage;
19
+ handleLine(line: string): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=McpServer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpServer.d.ts","sourceRoot":"","sources":["../../src/mcp/McpServer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAmC,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAYpF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwB;IAC/C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,EAAE,CAAC,CAAqB;IAChC,OAAO,CAAC,YAAY,CAAC,CAAgB;IACrC,OAAO,CAAC,YAAY,CAAC,CAAa;gBAEtB,MAAM,EAAE,UAAU,EAAE,OAAO,GAAE,gBAAqB;IAO9D,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwBtB,KAAK,IAAI,IAAI;IAKb,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,gBAAgB;YAcV,eAAe;YASf,eAAe;YAef,aAAa;IA6BrB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAqB9C"}
@@ -0,0 +1,135 @@
1
+ import readline from "node:readline";
2
+ import { PACKAGE_VERSION } from "../version.js";
3
+ import { executeMcpTool, getMcpTools, McpError } from "./tools.js";
4
+ const SUPPORTED_PROTOCOL_VERSIONS = new Set(["2025-06-18", "2025-03-26", "2024-11-05"]);
5
+ const DEFAULT_PROTOCOL_VERSION = "2025-06-18";
6
+ function resolveProtocolVersion(clientVersion) {
7
+ if (typeof clientVersion === "string" && SUPPORTED_PROTOCOL_VERSIONS.has(clientVersion)) {
8
+ return clientVersion;
9
+ }
10
+ return DEFAULT_PROTOCOL_VERSION;
11
+ }
12
+ export class McpServer {
13
+ client;
14
+ input;
15
+ output;
16
+ version;
17
+ rl;
18
+ startPromise;
19
+ resolveClose;
20
+ constructor(client, options = {}) {
21
+ this.client = client;
22
+ this.input = options.input ?? process.stdin;
23
+ this.output = options.output ?? process.stdout;
24
+ this.version = options.version ?? PACKAGE_VERSION;
25
+ }
26
+ start() {
27
+ if (this.startPromise)
28
+ return this.startPromise;
29
+ this.startPromise = new Promise((resolve) => {
30
+ this.resolveClose = resolve;
31
+ });
32
+ const rl = readline.createInterface({
33
+ input: this.input,
34
+ terminal: false,
35
+ });
36
+ this.rl = rl;
37
+ rl.on("line", (line) => {
38
+ void this.handleLine(line);
39
+ });
40
+ rl.on("close", () => {
41
+ this.resolveClose?.();
42
+ });
43
+ return this.startPromise;
44
+ }
45
+ close() {
46
+ this.rl?.close();
47
+ this.resolveClose?.();
48
+ }
49
+ sendResponse(response) {
50
+ this.output.write(`${JSON.stringify(response)}\n`);
51
+ }
52
+ handleInitialize(params) {
53
+ const protocolVersion = resolveProtocolVersion(params?.protocolVersion);
54
+ return {
55
+ protocolVersion,
56
+ capabilities: {
57
+ tools: {},
58
+ },
59
+ serverInfo: {
60
+ name: "valoranchi-riot-client",
61
+ version: this.version,
62
+ },
63
+ };
64
+ }
65
+ async handleToolsCall(params) {
66
+ const toolName = params?.name;
67
+ if (typeof toolName !== "string" || !toolName) {
68
+ throw new McpError(-32602, "Tool name is required");
69
+ }
70
+ const toolArgs = params.arguments ?? {};
71
+ return executeMcpTool(this.client, toolName, toolArgs);
72
+ }
73
+ async dispatchRequest(req) {
74
+ switch (req.method) {
75
+ case "initialize":
76
+ return this.handleInitialize(req.params);
77
+ case "ping":
78
+ return {};
79
+ case "tools/list":
80
+ return { tools: getMcpTools() };
81
+ case "tools/call":
82
+ return await this.handleToolsCall(req.params);
83
+ default:
84
+ throw new McpError(-32601, `Method not found: ${req.method}`);
85
+ }
86
+ }
87
+ async handleMessage(rawMessage) {
88
+ const req = rawMessage;
89
+ if (req.id === undefined || req.method === "notifications/initialized") {
90
+ return null;
91
+ }
92
+ const id = req.id ?? null;
93
+ try {
94
+ const result = await this.dispatchRequest(req);
95
+ return { jsonrpc: "2.0", id, result };
96
+ }
97
+ catch (error) {
98
+ if (error instanceof McpError) {
99
+ return {
100
+ jsonrpc: "2.0",
101
+ id,
102
+ error: { code: error.code, message: error.message },
103
+ };
104
+ }
105
+ const message = error instanceof Error ? error.message : String(error);
106
+ return {
107
+ jsonrpc: "2.0",
108
+ id,
109
+ error: { code: -32603, message },
110
+ };
111
+ }
112
+ }
113
+ async handleLine(line) {
114
+ const trimmed = line.trim();
115
+ if (!trimmed)
116
+ return;
117
+ let message;
118
+ try {
119
+ message = JSON.parse(trimmed);
120
+ }
121
+ catch {
122
+ this.sendResponse({
123
+ jsonrpc: "2.0",
124
+ id: null,
125
+ error: { code: -32700, message: "Parse error" },
126
+ });
127
+ return;
128
+ }
129
+ const response = await this.handleMessage(message);
130
+ if (response) {
131
+ this.sendResponse(response);
132
+ }
133
+ }
134
+ }
135
+ //# sourceMappingURL=McpServer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpServer.js","sourceRoot":"","sources":["../../src/mcp/McpServer.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eA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AAO,EAAE,KAAK,CAAC,OAAO,EAAE;iBACpD,CAAC;YACJ,CAAC;YACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACvE,OAAO;gBACL,OAAO,EAAE,KAAK;gBACd,EAAE;gBACF,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE;aACjC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO;YAAE,OAAO;QAErB,IAAI,OAAgC,CAAC;QACrC,IAAI,CAAC;YACH,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA4B,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,YAAY,CAAC;gBAChB,OAAO,EAAE,KAAK;gBACd,EAAE,EAAE,IAAI;gBACR,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE;aAChD,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACnD,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ export { McpServer } from "./McpServer.js";
2
+ export { getMcpTools, executeMcpTool, McpError } from "./tools.js";
3
+ export type { McpServerOptions, McpTool, McpToolInputSchema, McpToolProperty, McpToolResult, McpTextContent, JsonRpcRequest, JsonRpcResponse, JsonRpcError, } from "./types.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnE,YAAY,EACV,gBAAgB,EAChB,OAAO,EACP,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,GACb,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { McpServer } from "./McpServer.js";
2
+ export { getMcpTools, executeMcpTool, McpError } from "./tools.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { RiotClient } from "../RiotClient.js";
2
+ import type { McpTool, McpToolResult } from "./types.js";
3
+ export declare class McpError extends Error {
4
+ readonly code: number;
5
+ constructor(code: number, message: string);
6
+ }
7
+ export declare function getMcpTools(): McpTool[];
8
+ export declare function executeMcpTool(client: RiotClient, name: string, args?: Record<string, unknown>): Promise<McpToolResult>;
9
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGnD,OAAO,KAAK,EAAE,OAAO,EAAuC,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9F,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAqCD,wBAAgB,WAAW,IAAI,OAAO,EAAE,CAMvC;AAgBD,wBAAsB,cAAc,CAClC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,GACjC,OAAO,CAAC,aAAa,CAAC,CA+BxB"}
@@ -0,0 +1,83 @@
1
+ import { RiotClientError } from "../errors.js";
2
+ import { formatError } from "../formatError.js";
3
+ import { CONFIRM_GATED_ROUTES, ROUTE_DEFINITIONS, dispatchApiRoute } from "../serve/index.js";
4
+ export class McpError extends Error {
5
+ code;
6
+ constructor(code, message) {
7
+ super(message);
8
+ this.name = "McpError";
9
+ this.code = code;
10
+ }
11
+ }
12
+ function buildToolInputSchema(route) {
13
+ const properties = {};
14
+ const required = [];
15
+ if (route.params) {
16
+ for (const param of route.params) {
17
+ properties[param.name] = {
18
+ type: param.type,
19
+ description: param.description,
20
+ };
21
+ if (param.required) {
22
+ required.push(param.name);
23
+ }
24
+ }
25
+ }
26
+ return {
27
+ type: "object",
28
+ properties,
29
+ ...(required.length > 0 ? { required } : {}),
30
+ };
31
+ }
32
+ function isReadOnlyRoute(route) {
33
+ if (route.method !== "GET")
34
+ return false;
35
+ if (route.isConfirmGated || route.alias)
36
+ return false;
37
+ return !CONFIRM_GATED_ROUTES.has(`${route.namespace}/${route.action}`);
38
+ }
39
+ const READ_ONLY_ROUTES = ROUTE_DEFINITIONS.filter(isReadOnlyRoute);
40
+ const TOOL_MAP = new Map(READ_ONLY_ROUTES.map((route) => [`${route.namespace}_${route.action}`, route]));
41
+ export function getMcpTools() {
42
+ return READ_ONLY_ROUTES.map((route) => ({
43
+ name: `${route.namespace}_${route.action}`,
44
+ description: route.summary,
45
+ inputSchema: buildToolInputSchema(route),
46
+ }));
47
+ }
48
+ function isPlainObject(value) {
49
+ return typeof value === "object" && value !== null && !Array.isArray(value);
50
+ }
51
+ function stringifyArgs(args) {
52
+ const result = {};
53
+ for (const [key, value] of Object.entries(args)) {
54
+ if (value !== undefined && value !== null) {
55
+ result[key] = String(value);
56
+ }
57
+ }
58
+ return result;
59
+ }
60
+ export async function executeMcpTool(client, name, args = {}) {
61
+ const route = TOOL_MAP.get(name);
62
+ if (!route) {
63
+ throw new McpError(-32602, `Unknown tool: ${name}`);
64
+ }
65
+ const stringifiedArgs = stringifyArgs(args);
66
+ try {
67
+ const result = await dispatchApiRoute(client, route.namespace, route.action, stringifiedArgs, {}, { method: "GET", headers: {} });
68
+ return {
69
+ content: [{ type: "text", text: JSON.stringify(result ?? null) }],
70
+ ...(isPlainObject(result) ? { structuredContent: result } : {}),
71
+ };
72
+ }
73
+ catch (error) {
74
+ if (error instanceof RiotClientError) {
75
+ return {
76
+ isError: true,
77
+ content: [{ type: "text", text: JSON.stringify(formatError(error)) }],
78
+ };
79
+ }
80
+ throw error;
81
+ }
82
+ }
83
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI9F,MAAM,OAAO,QAAS,SAAQ,KAAK;IACxB,IAAI,CAAS;IAEtB,YAAY,IAAY,EAAE,OAAe;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,SAAS,oBAAoB,CAAC,KAAsB;IAClD,MAAM,UAAU,GAAoC,EAAE,CAAC;IACvD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,IAAI,KAAK,CAAC,MAAM,EAA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