@crypto512/jicon-mcp 1.3.0 → 2.0.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 (160) hide show
  1. package/README.md +68 -85
  2. package/TOOL_LIST.md +704 -87
  3. package/dist/config/constants.d.ts +18 -7
  4. package/dist/config/constants.d.ts.map +1 -1
  5. package/dist/config/constants.js +21 -8
  6. package/dist/config/constants.js.map +1 -1
  7. package/dist/config/loader.d.ts +11 -11
  8. package/dist/config/loader.d.ts.map +1 -1
  9. package/dist/config/loader.js +53 -93
  10. package/dist/config/loader.js.map +1 -1
  11. package/dist/config/types.d.ts +3 -6
  12. package/dist/config/types.d.ts.map +1 -1
  13. package/dist/config/types.js +2 -4
  14. package/dist/config/types.js.map +1 -1
  15. package/dist/confluence/formatters.js +1 -1
  16. package/dist/confluence/formatters.js.map +1 -1
  17. package/dist/confluence/tools.d.ts +4 -0
  18. package/dist/confluence/tools.d.ts.map +1 -1
  19. package/dist/confluence/tools.js +180 -125
  20. package/dist/confluence/tools.js.map +1 -1
  21. package/dist/index.js +17 -26
  22. package/dist/index.js.map +1 -1
  23. package/dist/jira/formatters.d.ts +1 -0
  24. package/dist/jira/formatters.d.ts.map +1 -1
  25. package/dist/jira/formatters.js +13 -12
  26. package/dist/jira/formatters.js.map +1 -1
  27. package/dist/jira/tools.d.ts +4 -0
  28. package/dist/jira/tools.d.ts.map +1 -1
  29. package/dist/jira/tools.js +189 -50
  30. package/dist/jira/tools.js.map +1 -1
  31. package/dist/permissions/tool-registry.d.ts +2 -2
  32. package/dist/permissions/tool-registry.d.ts.map +1 -1
  33. package/dist/permissions/tool-registry.js +4 -2
  34. package/dist/permissions/tool-registry.js.map +1 -1
  35. package/dist/permissions/write-home-validator.d.ts.map +1 -1
  36. package/dist/permissions/write-home-validator.js +13 -3
  37. package/dist/permissions/write-home-validator.js.map +1 -1
  38. package/dist/tempo/defaults.d.ts +17 -0
  39. package/dist/tempo/defaults.d.ts.map +1 -0
  40. package/dist/tempo/defaults.js +26 -0
  41. package/dist/tempo/defaults.js.map +1 -0
  42. package/dist/tempo/tools.d.ts +5 -0
  43. package/dist/tempo/tools.d.ts.map +1 -1
  44. package/dist/tempo/tools.js +108 -34
  45. package/dist/tempo/tools.js.map +1 -1
  46. package/dist/utils/buffer-pipeline/index.d.ts +30 -0
  47. package/dist/utils/buffer-pipeline/index.d.ts.map +1 -0
  48. package/dist/utils/buffer-pipeline/index.js +317 -0
  49. package/dist/utils/buffer-pipeline/index.js.map +1 -0
  50. package/dist/utils/buffer-pipeline/output/csv.d.ts +20 -0
  51. package/dist/utils/buffer-pipeline/output/csv.d.ts.map +1 -0
  52. package/dist/utils/buffer-pipeline/output/csv.js +117 -0
  53. package/dist/utils/buffer-pipeline/output/csv.js.map +1 -0
  54. package/dist/utils/buffer-pipeline/output/json.d.ts +16 -0
  55. package/dist/utils/buffer-pipeline/output/json.d.ts.map +1 -0
  56. package/dist/utils/buffer-pipeline/output/json.js +48 -0
  57. package/dist/utils/buffer-pipeline/output/json.js.map +1 -0
  58. package/dist/utils/buffer-pipeline/output/markdown.d.ts +15 -0
  59. package/dist/utils/buffer-pipeline/output/markdown.d.ts.map +1 -0
  60. package/dist/utils/buffer-pipeline/output/markdown.js +105 -0
  61. package/dist/utils/buffer-pipeline/output/markdown.js.map +1 -0
  62. package/dist/utils/buffer-pipeline/output/xhtml-list.d.ts +16 -0
  63. package/dist/utils/buffer-pipeline/output/xhtml-list.d.ts.map +1 -0
  64. package/dist/utils/buffer-pipeline/output/xhtml-list.js +81 -0
  65. package/dist/utils/buffer-pipeline/output/xhtml-list.js.map +1 -0
  66. package/dist/utils/buffer-pipeline/output/xhtml-table.d.ts +15 -0
  67. package/dist/utils/buffer-pipeline/output/xhtml-table.d.ts.map +1 -0
  68. package/dist/utils/buffer-pipeline/output/xhtml-table.js +176 -0
  69. package/dist/utils/buffer-pipeline/output/xhtml-table.js.map +1 -0
  70. package/dist/utils/buffer-pipeline/schema.d.ts +1878 -0
  71. package/dist/utils/buffer-pipeline/schema.d.ts.map +1 -0
  72. package/dist/utils/buffer-pipeline/schema.js +168 -0
  73. package/dist/utils/buffer-pipeline/schema.js.map +1 -0
  74. package/dist/utils/buffer-pipeline/stages/filter.d.ts +32 -0
  75. package/dist/utils/buffer-pipeline/stages/filter.d.ts.map +1 -0
  76. package/dist/utils/buffer-pipeline/stages/filter.js +208 -0
  77. package/dist/utils/buffer-pipeline/stages/filter.js.map +1 -0
  78. package/dist/utils/buffer-pipeline/stages/format.d.ts +45 -0
  79. package/dist/utils/buffer-pipeline/stages/format.d.ts.map +1 -0
  80. package/dist/utils/buffer-pipeline/stages/format.js +160 -0
  81. package/dist/utils/buffer-pipeline/stages/format.js.map +1 -0
  82. package/dist/utils/buffer-pipeline/stages/group-by.d.ts +25 -0
  83. package/dist/utils/buffer-pipeline/stages/group-by.d.ts.map +1 -0
  84. package/dist/utils/buffer-pipeline/stages/group-by.js +190 -0
  85. package/dist/utils/buffer-pipeline/stages/group-by.js.map +1 -0
  86. package/dist/utils/buffer-pipeline/stages/select.d.ts +54 -0
  87. package/dist/utils/buffer-pipeline/stages/select.d.ts.map +1 -0
  88. package/dist/utils/buffer-pipeline/stages/select.js +228 -0
  89. package/dist/utils/buffer-pipeline/stages/select.js.map +1 -0
  90. package/dist/utils/buffer-pipeline/stages/sort.d.ts +20 -0
  91. package/dist/utils/buffer-pipeline/stages/sort.d.ts.map +1 -0
  92. package/dist/utils/buffer-pipeline/stages/sort.js +96 -0
  93. package/dist/utils/buffer-pipeline/stages/sort.js.map +1 -0
  94. package/dist/utils/buffer-pipeline/types.d.ts +277 -0
  95. package/dist/utils/buffer-pipeline/types.d.ts.map +1 -0
  96. package/dist/utils/buffer-pipeline/types.js +8 -0
  97. package/dist/utils/buffer-pipeline/types.js.map +1 -0
  98. package/dist/utils/buffer-tools.d.ts +749 -19
  99. package/dist/utils/buffer-tools.d.ts.map +1 -1
  100. package/dist/utils/buffer-tools.js +738 -491
  101. package/dist/utils/buffer-tools.js.map +1 -1
  102. package/dist/utils/content-buffer.d.ts +55 -4
  103. package/dist/utils/content-buffer.d.ts.map +1 -1
  104. package/dist/utils/content-buffer.js +107 -9
  105. package/dist/utils/content-buffer.js.map +1 -1
  106. package/dist/utils/jicon-help.d.ts +1 -1
  107. package/dist/utils/jicon-help.d.ts.map +1 -1
  108. package/dist/utils/jicon-help.js +253 -28
  109. package/dist/utils/jicon-help.js.map +1 -1
  110. package/dist/utils/json-structure.d.ts +121 -0
  111. package/dist/utils/json-structure.d.ts.map +1 -0
  112. package/dist/utils/json-structure.js +637 -0
  113. package/dist/utils/json-structure.js.map +1 -0
  114. package/dist/utils/plantuml/include-expander.d.ts +31 -30
  115. package/dist/utils/plantuml/include-expander.d.ts.map +1 -1
  116. package/dist/utils/plantuml/include-expander.js +167 -133
  117. package/dist/utils/plantuml/include-expander.js.map +1 -1
  118. package/dist/utils/plantuml/index.d.ts +3 -3
  119. package/dist/utils/plantuml/index.d.ts.map +1 -1
  120. package/dist/utils/plantuml/index.js +4 -4
  121. package/dist/utils/plantuml/index.js.map +1 -1
  122. package/dist/utils/plantuml/service.d.ts +13 -24
  123. package/dist/utils/plantuml/service.d.ts.map +1 -1
  124. package/dist/utils/plantuml/service.js +49 -99
  125. package/dist/utils/plantuml/service.js.map +1 -1
  126. package/dist/utils/plantuml/tools.d.ts.map +1 -1
  127. package/dist/utils/plantuml/tools.js +33 -72
  128. package/dist/utils/plantuml/tools.js.map +1 -1
  129. package/dist/utils/plantuml/types.d.ts +1 -35
  130. package/dist/utils/plantuml/types.d.ts.map +1 -1
  131. package/dist/utils/plantuml/types.js +1 -11
  132. package/dist/utils/plantuml/types.js.map +1 -1
  133. package/dist/utils/plantuml/validation-helper.d.ts +1 -1
  134. package/dist/utils/plantuml/validation-helper.js +12 -12
  135. package/dist/utils/plantuml/validation-helper.js.map +1 -1
  136. package/dist/utils/response-formatter.d.ts +61 -6
  137. package/dist/utils/response-formatter.d.ts.map +1 -1
  138. package/dist/utils/response-formatter.js +174 -91
  139. package/dist/utils/response-formatter.js.map +1 -1
  140. package/dist/utils/url-tools.d.ts.map +1 -1
  141. package/dist/utils/url-tools.js +22 -0
  142. package/dist/utils/url-tools.js.map +1 -1
  143. package/dist/utils/xhtml/error-locator.js +2 -2
  144. package/dist/utils/xhtml/error-locator.js.map +1 -1
  145. package/dist/utils/xhtml/index.d.ts +1 -1
  146. package/dist/utils/xhtml/index.d.ts.map +1 -1
  147. package/dist/utils/xhtml/index.js +1 -1
  148. package/dist/utils/xhtml/index.js.map +1 -1
  149. package/dist/utils/xhtml/parser.d.ts +34 -5
  150. package/dist/utils/xhtml/parser.d.ts.map +1 -1
  151. package/dist/utils/xhtml/parser.js +66 -11
  152. package/dist/utils/xhtml/parser.js.map +1 -1
  153. package/dist/utils/xhtml/plantuml.d.ts.map +1 -1
  154. package/dist/utils/xhtml/plantuml.js +5 -3
  155. package/dist/utils/xhtml/plantuml.js.map +1 -1
  156. package/dist/utils/xhtml/serializer.d.ts.map +1 -1
  157. package/dist/utils/xhtml/serializer.js +12 -15
  158. package/dist/utils/xhtml/serializer.js.map +1 -1
  159. package/package.json +12 -4
  160. package/crypto512-jicon-mcp-1.3.0.tgz +0 -0
@@ -1,47 +1,48 @@
1
1
  /**
2
- * PlantUML Include Expander
2
+ * PlantUML Include Converter
3
3
  *
4
- * Expands !include directives by fetching whitelisted URLs client-side.
5
- * This bypasses PlantUML server SSRF restrictions for trusted stdlib libraries.
6
- */
7
- export declare const ALLOWED_INCLUDE_URLS: string[];
8
- /**
9
- * Expand !include directives in PlantUML code
4
+ * Converts !include directives from GitHub URLs to PlantUML stdlib syntax.
5
+ * This enables diagrams to work with PlantUML's built-in standard library
6
+ * without requiring HTTP fetching.
10
7
  *
11
- * Only expands URLs that match the whitelist.
12
- * Recursively expands nested includes up to MAX_DEPTH.
8
+ * Example: !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
9
+ * -> !include <C4/C4_Context>
13
10
  */
14
- export declare function expandIncludes(code: string, depth?: number): Promise<string>;
15
11
  /**
16
- * Expand PlantUML includes within XHTML content
17
- *
18
- * Finds all PlantUML macros in XHTML and expands !include directives
19
- * in their CDATA content before sending to Confluence.
12
+ * Error thrown when an HTTP include URL cannot be converted to stdlib syntax.
20
13
  */
21
- export declare function expandPlantUmlInXhtml(xhtml: string): Promise<string>;
14
+ export declare class IncludeConversionError extends Error {
15
+ readonly url: string;
16
+ readonly suggestion: string;
17
+ constructor(url: string, suggestion: string);
18
+ }
22
19
  /**
23
- * Clear the include cache
20
+ * Convert a GitHub URL to PlantUML stdlib syntax if possible.
21
+ * Returns null if the URL doesn't match any known pattern.
24
22
  */
25
- export declare function clearIncludeCache(): void;
23
+ export declare function urlToStdlib(url: string): string | null;
26
24
  /**
27
- * Get cache statistics (for debugging)
25
+ * Find all HTTP include URLs in PlantUML code that cannot be converted.
26
+ * Returns an array of unconvertible URLs.
28
27
  */
29
- export declare function getIncludeCacheStats(): {
30
- size: number;
31
- urls: string[];
32
- };
28
+ export declare function findUnconvertibleIncludes(code: string): string[];
33
29
  /**
34
- * Collapse expanded includes back to !include/!includeurl directives
30
+ * Convert !include directives from GitHub URLs to stdlib syntax.
31
+ * Throws IncludeConversionError if any HTTP URL cannot be converted.
35
32
  *
36
- * Reverses the expansion by finding the marker comments and replacing
37
- * the entire block with the original include directive.
33
+ * @param code - PlantUML code with !include directives
34
+ * @returns PlantUML code with converted includes
35
+ * @throws IncludeConversionError if an HTTP URL cannot be converted
38
36
  */
39
- export declare function collapseExpandedIncludes(code: string): string;
37
+ export declare function convertIncludes(code: string): string;
40
38
  /**
41
- * Collapse expanded includes within XHTML content
39
+ * Convert PlantUML includes within XHTML content.
40
+ * Throws IncludeConversionError if any HTTP URL cannot be converted.
41
+ *
42
+ * Finds all PlantUML macros in XHTML and converts !include directives
43
+ * in their CDATA content.
42
44
  *
43
- * Finds all PlantUML macros in XHTML and collapses expanded includes
44
- * back to !include directives when reading from Confluence.
45
+ * @throws IncludeConversionError if an HTTP URL cannot be converted
45
46
  */
46
- export declare function collapseExpandedIncludesInXhtml(xhtml: string): string;
47
+ export declare function convertPlantUmlIncludesInXhtml(xhtml: string): string;
47
48
  //# sourceMappingURL=include-expander.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"include-expander.d.ts","sourceRoot":"","sources":["../../../src/utils/plantuml/include-expander.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,oBAAoB,UAIhC,CAAC;AA8CF;;;;;GAKG;AACH,wBAAsB,cAAc,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,MAAU,GAChB,OAAO,CAAC,MAAM,CAAC,CAwCjB;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CA6B1E;AAED;;GAEG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,CAKvE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM7D;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAwBrE"}
1
+ {"version":3,"file":"include-expander.d.ts","sourceRoot":"","sources":["../../../src/utils/plantuml/include-expander.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;aAE7B,GAAG,EAAE,MAAM;aACX,UAAU,EAAE,MAAM;gBADlB,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM;CASrC;AAiHD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQtD;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAahE;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAmBpD;AAED;;;;;;;;GAQG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6BpE"}
@@ -1,168 +1,202 @@
1
1
  /**
2
- * PlantUML Include Expander
2
+ * PlantUML Include Converter
3
3
  *
4
- * Expands !include directives by fetching whitelisted URLs client-side.
5
- * This bypasses PlantUML server SSRF restrictions for trusted stdlib libraries.
4
+ * Converts !include directives from GitHub URLs to PlantUML stdlib syntax.
5
+ * This enables diagrams to work with PlantUML's built-in standard library
6
+ * without requiring HTTP fetching.
7
+ *
8
+ * Example: !include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
9
+ * -> !include <C4/C4_Context>
6
10
  */
7
- // Whitelisted URL prefixes - only these are allowed
8
- export const ALLOWED_INCLUDE_URLS = [
9
- "https://raw.githubusercontent.com/plantuml-stdlib/", // C4, Azure, Kubernetes, etc.
10
- "https://raw.githubusercontent.com/plantuml/", // Official stdlib
11
- "https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/", // AWS icons
12
- ];
13
- const MAX_DEPTH = 5; // Maximum recursion depth for nested includes
14
- const MAX_SIZE = 100_000; // 100KB max per include file
15
- const FETCH_TIMEOUT = 5000; // 5 second timeout per fetch
16
- // In-memory cache (cleared on process restart)
17
- const cache = new Map();
18
11
  /**
19
- * Check if a URL is in the whitelist
12
+ * Error thrown when an HTTP include URL cannot be converted to stdlib syntax.
20
13
  */
21
- function isAllowedUrl(url) {
22
- return ALLOWED_INCLUDE_URLS.some((prefix) => url.startsWith(prefix));
14
+ export class IncludeConversionError extends Error {
15
+ url;
16
+ suggestion;
17
+ constructor(url, suggestion) {
18
+ super(`Cannot convert include URL to stdlib syntax: ${url}\n\n` +
19
+ `The PlantUML server cannot fetch external URLs. You must use PlantUML's built-in stdlib syntax.\n\n` +
20
+ `${suggestion}`);
21
+ this.url = url;
22
+ this.suggestion = suggestion;
23
+ this.name = "IncludeConversionError";
24
+ }
23
25
  }
24
26
  /**
25
- * Fetch an include file with caching
27
+ * URL pattern to stdlib mapping rules.
28
+ * Order matters - more specific patterns should come first.
26
29
  */
27
- async function fetchInclude(url) {
28
- // Return cached content if available
29
- if (cache.has(url)) {
30
- return cache.get(url);
31
- }
32
- const response = await fetch(url, {
33
- signal: AbortSignal.timeout(FETCH_TIMEOUT),
34
- });
35
- if (!response.ok) {
36
- throw new Error(`Failed to fetch include ${url}: ${response.status}`);
37
- }
38
- const content = await response.text();
39
- if (content.length > MAX_SIZE) {
40
- throw new Error(`Include file too large (${content.length} bytes): ${url}`);
41
- }
42
- // Cache the content
43
- cache.set(url, content);
44
- return content;
45
- }
30
+ const STDLIB_MAPPINGS = [
31
+ // C4-PlantUML: plantuml-stdlib/C4-PlantUML/*/C4_*.puml -> <C4/C4_*>
32
+ {
33
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/plantuml-stdlib\/C4-PlantUML\/[^/]+\/(.+)\.puml$/,
34
+ transform: (m) => `<C4/${m[1]}>`,
35
+ },
36
+ // AWS Icons (awslabs): awslabs/aws-icons-for-plantuml/*/dist/* -> <awslib/*>
37
+ {
38
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/awslabs\/aws-icons-for-plantuml\/[^/]+\/dist\/(.+)\.puml$/,
39
+ transform: (m) => `<awslib/${m[1]}>`,
40
+ },
41
+ // Azure: plantuml-stdlib/Azure-PlantUML/*/* -> <azure/*>
42
+ {
43
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/plantuml-stdlib\/Azure-PlantUML\/[^/]+\/(.+)\.puml$/,
44
+ transform: (m) => `<azure/${m[1]}>`,
45
+ },
46
+ // Kubernetes: plantuml-stdlib/plantuml-kubernetes-sprites/*/* -> <kubernetes/*>
47
+ {
48
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/plantuml-stdlib\/plantuml-kubernetes-sprites\/[^/]+\/(.+)\.puml$/,
49
+ transform: (m) => `<kubernetes/${m[1]}>`,
50
+ },
51
+ // ArchiMate: plantuml/plantuml-stdlib/master/stdlib/archimate/* -> <archimate/*>
52
+ {
53
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/plantuml\/plantuml-stdlib\/[^/]+\/stdlib\/archimate\/(.+)\.puml$/,
54
+ transform: (m) => `<archimate/${m[1]}>`,
55
+ },
56
+ // Generic plantuml-stdlib libraries (fallback for other stdlib repos)
57
+ {
58
+ pattern: /^https:\/\/raw\.githubusercontent\.com\/plantuml-stdlib\/([^/]+)\/[^/]+\/(.+)\.puml$/,
59
+ transform: (m) => {
60
+ // Map known library names to their stdlib equivalents
61
+ const libMap = {
62
+ "Cloudogu-Icons": "cloudogu",
63
+ "EIP-PlantUML": "eip",
64
+ "gilbarbara-plantuml-sprites": "logos",
65
+ "tupadr3-plantuml-sprites": "tupadr3",
66
+ "office-plantuml": "office",
67
+ };
68
+ const lib = libMap[m[1]] || m[1].toLowerCase();
69
+ return `<${lib}/${m[2]}>`;
70
+ },
71
+ },
72
+ ];
46
73
  /**
47
- * Expand !include directives in PlantUML code
48
- *
49
- * Only expands URLs that match the whitelist.
50
- * Recursively expands nested includes up to MAX_DEPTH.
74
+ * Generate a helpful suggestion for fixing an unconvertible include URL.
51
75
  */
52
- export async function expandIncludes(code, depth = 0) {
53
- // Prevent infinite recursion
54
- if (depth > MAX_DEPTH) {
55
- return code;
76
+ function getSuggestionForUrl(url) {
77
+ // Check if it looks like a known library but wrong format
78
+ if (url.includes("C4-PlantUML") || url.includes("C4_")) {
79
+ return (`For C4 diagrams, use the stdlib syntax:\n` +
80
+ ` !include <C4/C4_Context>\n` +
81
+ ` !include <C4/C4_Container>\n` +
82
+ ` !include <C4/C4_Component>\n` +
83
+ ` !include <C4/C4_Deployment>\n` +
84
+ ` !include <C4/C4_Dynamic>`);
56
85
  }
57
- // Match !include and !includeurl directives with HTTP(S) URLs
58
- const includePattern = /^(\s*)(!include(?:url)?)\s+(https?:\/\/\S+)/gm;
59
- const matches = [...code.matchAll(includePattern)];
60
- if (matches.length === 0) {
61
- return code;
86
+ if (url.includes("aws-icons") || url.includes("awslabs")) {
87
+ return (`For AWS diagrams, use the stdlib syntax:\n` +
88
+ ` !include <awslib/AWSCommon>\n` +
89
+ ` !include <awslib/AWSSimplified>\n` +
90
+ ` !include <awslib/Compute/EC2>\n` +
91
+ ` !include <awslib/Storage/SimpleStorageService>`);
62
92
  }
63
- let result = code;
64
- for (const match of matches) {
65
- const [fullMatch, indent, directive, url] = match;
66
- // Skip non-whitelisted URLs
67
- if (!isAllowedUrl(url)) {
68
- continue;
69
- }
70
- try {
71
- const content = await fetchInclude(url);
72
- // Recursively expand nested includes
73
- const expanded = await expandIncludes(content, depth + 1);
74
- // Wrap expanded content in comments with original include line preserved
75
- // This allows easy removal by deleting from opening to closing comment
76
- const wrapped = `${indent}' <<<< EXPANDED: ${directive} ${url}\n${expanded}\n${indent}' >>>> END EXPANDED`;
77
- result = result.replace(fullMatch, wrapped);
78
- }
79
- catch (error) {
80
- // Re-throw with context
81
- const message = error instanceof Error ? error.message : String(error);
82
- throw new Error(`Failed to expand include: ${message}`);
83
- }
93
+ if (url.includes("Azure") || url.includes("azure")) {
94
+ return (`For Azure diagrams, use the stdlib syntax:\n` +
95
+ ` !include <azure/AzureCommon>\n` +
96
+ ` !include <azure/Compute/VirtualMachine>\n` +
97
+ ` !include <azure/Storage/StorageAccounts>`);
84
98
  }
85
- return result;
99
+ if (url.includes("kubernetes") || url.includes("k8s")) {
100
+ return (`For Kubernetes diagrams, use the stdlib syntax:\n` +
101
+ ` !include <kubernetes/k8s>`);
102
+ }
103
+ // Generic suggestion
104
+ return (`Supported stdlib libraries:\n` +
105
+ ` - C4: !include <C4/C4_Context>\n` +
106
+ ` - AWS: !include <awslib/AWSCommon>\n` +
107
+ ` - Azure: !include <azure/AzureCommon>\n` +
108
+ ` - Kubernetes: !include <kubernetes/k8s>\n` +
109
+ ` - ArchiMate: !include <archimate/Archimate>\n\n` +
110
+ `If you need a custom library, you must inline the definitions directly in your diagram.`);
86
111
  }
87
112
  /**
88
- * Expand PlantUML includes within XHTML content
89
- *
90
- * Finds all PlantUML macros in XHTML and expands !include directives
91
- * in their CDATA content before sending to Confluence.
113
+ * Convert a GitHub URL to PlantUML stdlib syntax if possible.
114
+ * Returns null if the URL doesn't match any known pattern.
92
115
  */
93
- export async function expandPlantUmlInXhtml(xhtml) {
94
- // Match PlantUML macro CDATA content
95
- const macroPattern = /(<ac:plain-text-body><!\[CDATA\[)([\s\S]*?)(\]\]><\/ac:plain-text-body>)/g;
96
- const matches = [...xhtml.matchAll(macroPattern)];
97
- if (matches.length === 0) {
98
- return xhtml;
99
- }
100
- let result = xhtml;
101
- for (const match of matches) {
102
- const [fullMatch, prefix, code, suffix] = match;
103
- // Only process if contains !include or !includeurl
104
- if (code.includes("!include")) { // matches both !include and !includeurl
105
- try {
106
- const expanded = await expandIncludes(code);
107
- result = result.replace(fullMatch, prefix + expanded + suffix);
108
- }
109
- catch (error) {
110
- // Log error but don't fail - let Confluence show the error
111
- console.error("PlantUML include expansion failed:", error);
112
- }
116
+ export function urlToStdlib(url) {
117
+ for (const mapping of STDLIB_MAPPINGS) {
118
+ const match = url.match(mapping.pattern);
119
+ if (match) {
120
+ return mapping.transform(match);
113
121
  }
114
122
  }
115
- return result;
123
+ return null;
116
124
  }
117
125
  /**
118
- * Clear the include cache
126
+ * Find all HTTP include URLs in PlantUML code that cannot be converted.
127
+ * Returns an array of unconvertible URLs.
119
128
  */
120
- export function clearIncludeCache() {
121
- cache.clear();
122
- }
123
- /**
124
- * Get cache statistics (for debugging)
125
- */
126
- export function getIncludeCacheStats() {
127
- return {
128
- size: cache.size,
129
- urls: [...cache.keys()],
130
- };
129
+ export function findUnconvertibleIncludes(code) {
130
+ const includePattern = /^(\s*)(!include(?:url)?)\s+(https?:\/\/\S+)/gm;
131
+ const unconvertible = [];
132
+ let match;
133
+ while ((match = includePattern.exec(code)) !== null) {
134
+ const url = match[3];
135
+ if (urlToStdlib(url) === null) {
136
+ unconvertible.push(url);
137
+ }
138
+ }
139
+ return unconvertible;
131
140
  }
132
141
  /**
133
- * Collapse expanded includes back to !include/!includeurl directives
142
+ * Convert !include directives from GitHub URLs to stdlib syntax.
143
+ * Throws IncludeConversionError if any HTTP URL cannot be converted.
134
144
  *
135
- * Reverses the expansion by finding the marker comments and replacing
136
- * the entire block with the original include directive.
145
+ * @param code - PlantUML code with !include directives
146
+ * @returns PlantUML code with converted includes
147
+ * @throws IncludeConversionError if an HTTP URL cannot be converted
137
148
  */
138
- export function collapseExpandedIncludes(code) {
139
- // Pattern matches: ' <<<< EXPANDED: !include[url] URL\n...content...\n' >>>> END EXPANDED
140
- // The indent is captured to handle different nesting levels
141
- const pattern = /^(\s*)' <<<< EXPANDED: (!include(?:url)? \S+)\n[\s\S]*?\n\1' >>>> END EXPANDED/gm;
142
- return code.replace(pattern, "$1$2");
149
+ export function convertIncludes(code) {
150
+ // First, check for unconvertible URLs
151
+ const unconvertible = findUnconvertibleIncludes(code);
152
+ if (unconvertible.length > 0) {
153
+ const url = unconvertible[0];
154
+ throw new IncludeConversionError(url, getSuggestionForUrl(url));
155
+ }
156
+ // All URLs are convertible, proceed with conversion
157
+ const includePattern = /^(\s*)(!include(?:url)?)\s+(https?:\/\/\S+)/gm;
158
+ return code.replace(includePattern, (fullMatch, indent, _directive, url) => {
159
+ const stdlibPath = urlToStdlib(url);
160
+ if (stdlibPath) {
161
+ return `${indent}!include ${stdlibPath}`;
162
+ }
163
+ // This shouldn't happen since we checked above, but keep for safety
164
+ return fullMatch;
165
+ });
143
166
  }
144
167
  /**
145
- * Collapse expanded includes within XHTML content
168
+ * Convert PlantUML includes within XHTML content.
169
+ * Throws IncludeConversionError if any HTTP URL cannot be converted.
170
+ *
171
+ * Finds all PlantUML macros in XHTML and converts !include directives
172
+ * in their CDATA content.
146
173
  *
147
- * Finds all PlantUML macros in XHTML and collapses expanded includes
148
- * back to !include directives when reading from Confluence.
174
+ * @throws IncludeConversionError if an HTTP URL cannot be converted
149
175
  */
150
- export function collapseExpandedIncludesInXhtml(xhtml) {
176
+ export function convertPlantUmlIncludesInXhtml(xhtml) {
151
177
  // Match PlantUML macro CDATA content
152
178
  const macroPattern = /(<ac:plain-text-body><!\[CDATA\[)([\s\S]*?)(\]\]><\/ac:plain-text-body>)/g;
153
- const matches = [...xhtml.matchAll(macroPattern)];
154
- if (matches.length === 0) {
155
- return xhtml;
156
- }
157
- let result = xhtml;
158
- for (const match of matches) {
159
- const [fullMatch, prefix, code, suffix] = match;
160
- // Only process if contains expansion markers
161
- if (code.includes("' <<<< EXPANDED:")) {
162
- const collapsed = collapseExpandedIncludes(code);
163
- result = result.replace(fullMatch, prefix + collapsed + suffix);
179
+ // First pass: check for unconvertible includes in all macros
180
+ let match;
181
+ while ((match = macroPattern.exec(xhtml)) !== null) {
182
+ const code = match[2];
183
+ if (code.includes("!include") && code.includes("http")) {
184
+ const unconvertible = findUnconvertibleIncludes(code);
185
+ if (unconvertible.length > 0) {
186
+ const url = unconvertible[0];
187
+ throw new IncludeConversionError(url, getSuggestionForUrl(url));
188
+ }
164
189
  }
165
190
  }
166
- return result;
191
+ // Reset regex for second pass
192
+ macroPattern.lastIndex = 0;
193
+ // Second pass: convert all includes
194
+ return xhtml.replace(macroPattern, (fullMatch, prefix, code, suffix) => {
195
+ if (code.includes("!include") && code.includes("http")) {
196
+ const converted = convertIncludes(code);
197
+ return prefix + converted + suffix;
198
+ }
199
+ return fullMatch;
200
+ });
167
201
  }
168
202
  //# sourceMappingURL=include-expander.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"include-expander.js","sourceRoot":"","sources":["../../../src/utils/plantuml/include-expander.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oDAAoD;AACpD,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACl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,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;KACxB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,IAAY;IACnD,0FAA0F;IAC1F,4DAA4D;IAC5D,MAAM,OAAO,GACX,kFAAkF,CAAC;IACrF,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AACvC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAa;IAC3D,qCAAqC;IACrC,MAAM,YAAY,GAChB,2EAA2E,CAAC;IAE9E,MAAM,OAAO,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAElD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,MAAM,GAAG,KAAK,CAAC;IAEnB,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,KAAK,CAAC;QAEhD,6CAA6C;QAC7C,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACtC,MAAM,SAAS,GAAG,wBAAwB,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
1
+ {"version":3,"file":"include-expander.js","sourceRoot":"","sources":["../../../src/utils/plantuml/include-expander.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAE7B;IACA;IAFlB,YACkB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D,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;YACxC,OAAO,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;QACrC,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * PlantUML Module Exports
3
3
  *
4
- * Docker-based PlantUML validation and rendering service.
4
+ * PlantUML validation and rendering service using external PlantUML server.
5
5
  */
6
6
  export * from "./types.js";
7
- export { validate, render, isAvailable, getStatus, shutdown, configure, normalizePlantUml, detectDiagramType, initializePlantUml, getUnavailableReason, expandPlantUmlInXhtml, collapseExpandedIncludesInXhtml, ALLOWED_INCLUDE_URLS, } from "./service.js";
8
- export { startContainer, stopContainer, ensureContainer, getContainerState, isContainerHealthy, cleanupOrphanedContainers, } from "./docker-manager.js";
7
+ export { validate, render, isAvailable, getStatus, shutdown, normalizePlantUml, detectDiagramType, initializePlantUml, getUnavailableReason, convertPlantUmlIncludesInXhtml, } from "./service.js";
8
+ export { IncludeConversionError } from "./include-expander.js";
9
9
  export { PlantUmlClient, encodePlantUml } from "./client.js";
10
10
  export { createPlantUmlTools, PLANTUML_TOOLS } from "./tools.js";
11
11
  export { validatePlantUmlWithFallback, type PlantUmlValidation, type PlantUmlValidationResult, type PlantUmlValidationError, } from "./validation-helper.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/plantuml/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjE,OAAO,EACL,4BAA4B,EAC5B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/plantuml/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AAGtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAGjE,OAAO,EACL,4BAA4B,EAC5B,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,GAC7B,MAAM,wBAAwB,CAAC"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * PlantUML Module Exports
3
3
  *
4
- * Docker-based PlantUML validation and rendering service.
4
+ * PlantUML validation and rendering service using external PlantUML server.
5
5
  */
6
6
  // Types
7
7
  export * from "./types.js";
8
8
  // Service (main API)
9
- export { validate, render, isAvailable, getStatus, shutdown, configure, normalizePlantUml, detectDiagramType, initializePlantUml, getUnavailableReason, expandPlantUmlInXhtml, collapseExpandedIncludesInXhtml, ALLOWED_INCLUDE_URLS, } from "./service.js";
10
- // Docker manager (for lifecycle control)
11
- export { startContainer, stopContainer, ensureContainer, getContainerState, isContainerHealthy, cleanupOrphanedContainers, } from "./docker-manager.js";
9
+ export { validate, render, isAvailable, getStatus, shutdown, normalizePlantUml, detectDiagramType, initializePlantUml, getUnavailableReason, convertPlantUmlIncludesInXhtml, } from "./service.js";
10
+ // Include converter error (for error handling in tools)
11
+ export { IncludeConversionError } from "./include-expander.js";
12
12
  // HTTP client (for direct access if needed)
13
13
  export { PlantUmlClient, encodePlantUml } from "./client.js";
14
14
  // MCP Tools
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/plantuml/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,qBAAqB;AACrB,OAAO,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAEtB,yCAAyC;AACzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAE7B,4CAA4C;AAC5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY;AACZ,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,0CAA0C;AAC1C,OAAO,EACL,4BAA4B,GAI7B,MAAM,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/plantuml/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,qBAAqB;AACrB,OAAO,EACL,QAAQ,EACR,MAAM,EACN,WAAW,EACX,SAAS,EACT,QAAQ,EACR,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,8BAA8B,GAC/B,MAAM,cAAc,CAAC;AAEtB,wDAAwD;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,4CAA4C;AAC5C,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,YAAY;AACZ,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE,0CAA0C;AAC1C,OAAO,EACL,4BAA4B,GAI7B,MAAM,wBAAwB,CAAC"}
@@ -2,29 +2,21 @@
2
2
  * PlantUML Service
3
3
  *
4
4
  * Unified service facade for PlantUML operations.
5
- * Handles eager container initialization at MCP startup and provides high-level API.
6
- * Does NOT auto-restart if container dies - requires MCP restart.
5
+ * Connects to an external PlantUML server configured via JICON_PLANTUML_SERVER_URL.
7
6
  */
8
7
  import { normalizePlantUml, detectDiagramType } from "./client.js";
9
- import type { PlantUmlConfig, PlantUmlValidationResult, PlantUmlRenderResult, RenderFormat } from "./types.js";
8
+ import type { PlantUmlValidationResult, PlantUmlRenderResult, RenderFormat } from "./types.js";
10
9
  /**
11
- * Configure the PlantUML service
12
- */
13
- export declare function configure(config: PlantUmlConfig & {
14
- includeExpansion?: boolean;
15
- }): void;
16
- /**
17
- * Initialize PlantUML service at MCP startup.
18
- * Returns success/failure status. Does not throw.
10
+ * Initialize PlantUML service with external server URL.
11
+ * Called at MCP startup.
19
12
  */
20
13
  export declare function initializePlantUml(options?: {
21
- disabled?: boolean;
14
+ serverUrl?: string;
22
15
  }): Promise<{
23
16
  success: boolean;
24
17
  disabled?: boolean;
25
18
  error?: string;
26
- containerId?: string;
27
- port?: number;
19
+ serverUrl?: string;
28
20
  }>;
29
21
  /**
30
22
  * Check if PlantUML service can be used.
@@ -33,16 +25,16 @@ export declare function initializePlantUml(options?: {
33
25
  export declare function getUnavailableReason(): string | null;
34
26
  /**
35
27
  * Validate PlantUML syntax
36
- * Expands !include directives for validation but returns original code
28
+ * Converts !include URLs to stdlib syntax for validation but returns original code
37
29
  */
38
30
  export declare function validate(code: string): Promise<PlantUmlValidationResult>;
39
31
  /**
40
32
  * Render PlantUML diagram to specified format
41
- * Expands !include directives before rendering
33
+ * Converts !include URLs to stdlib syntax before rendering
42
34
  */
43
35
  export declare function render(code: string, format: RenderFormat): Promise<PlantUmlRenderResult>;
44
36
  /**
45
- * Check if PlantUML service is available (container running and healthy)
37
+ * Check if PlantUML service is available
46
38
  */
47
39
  export declare function isAvailable(): boolean;
48
40
  /**
@@ -51,20 +43,17 @@ export declare function isAvailable(): boolean;
51
43
  export declare function getStatus(): {
52
44
  available: boolean;
53
45
  disabled?: boolean;
54
- startupFailed?: boolean;
55
- containerDied?: boolean;
46
+ serverDied?: boolean;
56
47
  error?: string;
57
- containerId?: string;
58
- port?: number;
59
- baseUrl?: string;
48
+ serverUrl?: string;
60
49
  };
61
50
  /**
62
- * Shutdown the PlantUML service (stop container)
51
+ * Shutdown the PlantUML service (cleanup client)
63
52
  */
64
53
  export declare function shutdown(): Promise<void>;
65
54
  /**
66
55
  * Re-export utility functions for convenience
67
56
  */
68
57
  export { normalizePlantUml, detectDiagramType };
69
- export { expandPlantUmlInXhtml, collapseExpandedIncludesInXhtml, ALLOWED_INCLUDE_URLS, } from "./include-expander.js";
58
+ export { convertPlantUmlIncludesInXhtml } from "./include-expander.js";
70
59
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/utils/plantuml/service.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAkB,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,KAAK,EACV,cAAc,EACd,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACb,MAAM,YAAY,CAAC;AAsBpB;;GAEG;AACH,wBAAgB,SAAS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