@sfdxy/mule-lint 1.4.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 +413 -0
- package/dist/bin/mule-lint.d.ts +3 -0
- package/dist/bin/mule-lint.d.ts.map +1 -0
- package/dist/bin/mule-lint.js +123 -0
- package/dist/bin/mule-lint.js.map +1 -0
- package/dist/src/core/ComplexityCalculator.d.ts +42 -0
- package/dist/src/core/ComplexityCalculator.d.ts.map +1 -0
- package/dist/src/core/ComplexityCalculator.js +123 -0
- package/dist/src/core/ComplexityCalculator.js.map +1 -0
- package/dist/src/core/FileScanner.d.ts +58 -0
- package/dist/src/core/FileScanner.d.ts.map +1 -0
- package/dist/src/core/FileScanner.js +161 -0
- package/dist/src/core/FileScanner.js.map +1 -0
- package/dist/src/core/XPathHelper.d.ts +81 -0
- package/dist/src/core/XPathHelper.d.ts.map +1 -0
- package/dist/src/core/XPathHelper.js +229 -0
- package/dist/src/core/XPathHelper.js.map +1 -0
- package/dist/src/core/XmlParser.d.ts +38 -0
- package/dist/src/core/XmlParser.d.ts.map +1 -0
- package/dist/src/core/XmlParser.js +131 -0
- package/dist/src/core/XmlParser.js.map +1 -0
- package/dist/src/core/YamlParser.d.ts +30 -0
- package/dist/src/core/YamlParser.d.ts.map +1 -0
- package/dist/src/core/YamlParser.js +120 -0
- package/dist/src/core/YamlParser.js.map +1 -0
- package/dist/src/core/index.d.ts +4 -0
- package/dist/src/core/index.d.ts.map +1 -0
- package/dist/src/core/index.js +21 -0
- package/dist/src/core/index.js.map +1 -0
- package/dist/src/engine/LintEngine.d.ts +60 -0
- package/dist/src/engine/LintEngine.d.ts.map +1 -0
- package/dist/src/engine/LintEngine.js +271 -0
- package/dist/src/engine/LintEngine.js.map +1 -0
- package/dist/src/engine/index.d.ts +2 -0
- package/dist/src/engine/index.d.ts.map +1 -0
- package/dist/src/engine/index.js +18 -0
- package/dist/src/engine/index.js.map +1 -0
- package/dist/src/formatters/JsonFormatter.d.ts +18 -0
- package/dist/src/formatters/JsonFormatter.d.ts.map +1 -0
- package/dist/src/formatters/JsonFormatter.js +45 -0
- package/dist/src/formatters/JsonFormatter.js.map +1 -0
- package/dist/src/formatters/SarifFormatter.d.ts +8 -0
- package/dist/src/formatters/SarifFormatter.d.ts.map +1 -0
- package/dist/src/formatters/SarifFormatter.js +115 -0
- package/dist/src/formatters/SarifFormatter.js.map +1 -0
- package/dist/src/formatters/TableFormatter.d.ts +10 -0
- package/dist/src/formatters/TableFormatter.d.ts.map +1 -0
- package/dist/src/formatters/TableFormatter.js +100 -0
- package/dist/src/formatters/TableFormatter.js.map +1 -0
- package/dist/src/formatters/index.d.ts +10 -0
- package/dist/src/formatters/index.d.ts.map +1 -0
- package/dist/src/formatters/index.js +42 -0
- package/dist/src/formatters/index.js.map +1 -0
- package/dist/src/index.d.ts +6 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +28 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/rules/api-led/ApiLedRules.d.ts +42 -0
- package/dist/src/rules/api-led/ApiLedRules.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApiLedRules.js +95 -0
- package/dist/src/rules/api-led/ApiLedRules.js.map +1 -0
- package/dist/src/rules/base/BaseRule.d.ts +89 -0
- package/dist/src/rules/base/BaseRule.d.ts.map +1 -0
- package/dist/src/rules/base/BaseRule.js +137 -0
- package/dist/src/rules/base/BaseRule.js.map +1 -0
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts +18 -0
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts.map +1 -0
- package/dist/src/rules/complexity/FlowComplexityRule.js +58 -0
- package/dist/src/rules/complexity/FlowComplexityRule.js.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts +45 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.js +168 -0
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts +16 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts.map +1 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.js +33 -0
- package/dist/src/rules/documentation/FlowDescriptionRule.js.map +1 -0
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts +17 -0
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts.map +1 -0
- package/dist/src/rules/documentation/MissingDocNameRule.js +44 -0
- package/dist/src/rules/documentation/MissingDocNameRule.js.map +1 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts +26 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.js +86 -0
- package/dist/src/rules/error-handling/CorrelationIdRule.js.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts +22 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.js +51 -0
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts +17 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +77 -0
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts +21 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js +57 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js.map +1 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts +17 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js +51 -0
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/experimental/ExperimentalRules.d.ts +43 -0
- package/dist/src/rules/experimental/ExperimentalRules.d.ts.map +1 -0
- package/dist/src/rules/experimental/ExperimentalRules.js +92 -0
- package/dist/src/rules/experimental/ExperimentalRules.js.map +1 -0
- package/dist/src/rules/http/HttpContentTypeRule.d.ts +17 -0
- package/dist/src/rules/http/HttpContentTypeRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpContentTypeRule.js +50 -0
- package/dist/src/rules/http/HttpContentTypeRule.js.map +1 -0
- package/dist/src/rules/http/HttpTimeoutRule.d.ts +16 -0
- package/dist/src/rules/http/HttpTimeoutRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpTimeoutRule.js +33 -0
- package/dist/src/rules/http/HttpTimeoutRule.js.map +1 -0
- package/dist/src/rules/http/HttpUserAgentRule.d.ts +17 -0
- package/dist/src/rules/http/HttpUserAgentRule.d.ts.map +1 -0
- package/dist/src/rules/http/HttpUserAgentRule.js +48 -0
- package/dist/src/rules/http/HttpUserAgentRule.js.map +1 -0
- package/dist/src/rules/index.d.ts +45 -0
- package/dist/src/rules/index.d.ts.map +1 -0
- package/dist/src/rules/index.js +205 -0
- package/dist/src/rules/index.js.map +1 -0
- package/dist/src/rules/logging/LoggerCategoryRule.d.ts +21 -0
- package/dist/src/rules/logging/LoggerCategoryRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerCategoryRule.js +61 -0
- package/dist/src/rules/logging/LoggerCategoryRule.js.map +1 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.d.ts +16 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js +29 -0
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js.map +1 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts +17 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -0
- package/dist/src/rules/logging/LoggerPayloadRule.js +39 -0
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -0
- package/dist/src/rules/naming/FlowCasingRule.d.ts +18 -0
- package/dist/src/rules/naming/FlowCasingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/FlowCasingRule.js +40 -0
- package/dist/src/rules/naming/FlowCasingRule.js.map +1 -0
- package/dist/src/rules/naming/FlowNamingRule.d.ts +17 -0
- package/dist/src/rules/naming/FlowNamingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/FlowNamingRule.js +60 -0
- package/dist/src/rules/naming/FlowNamingRule.js.map +1 -0
- package/dist/src/rules/naming/VariableNamingRule.d.ts +18 -0
- package/dist/src/rules/naming/VariableNamingRule.d.ts.map +1 -0
- package/dist/src/rules/naming/VariableNamingRule.js +39 -0
- package/dist/src/rules/naming/VariableNamingRule.js.map +1 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts +16 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts.map +1 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js +34 -0
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js.map +1 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts +16 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts.map +1 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.js +32 -0
- package/dist/src/rules/performance/LargeChoiceBlockRule.js.map +1 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts +16 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts.map +1 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js +32 -0
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts +19 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js +66 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedHttpRule.d.ts +33 -0
- package/dist/src/rules/security/HardcodedHttpRule.d.ts.map +1 -0
- package/dist/src/rules/security/HardcodedHttpRule.js +108 -0
- package/dist/src/rules/security/HardcodedHttpRule.js.map +1 -0
- package/dist/src/rules/security/InsecureTlsRule.d.ts +16 -0
- package/dist/src/rules/security/InsecureTlsRule.d.ts.map +1 -0
- package/dist/src/rules/security/InsecureTlsRule.js +36 -0
- package/dist/src/rules/security/InsecureTlsRule.js.map +1 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts +17 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js +43 -0
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js.map +1 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts +17 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts.map +1 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.js +37 -0
- package/dist/src/rules/standards/DeprecatedComponentRule.js.map +1 -0
- package/dist/src/rules/standards/DwlStandardsRule.d.ts +22 -0
- package/dist/src/rules/standards/DwlStandardsRule.d.ts.map +1 -0
- package/dist/src/rules/standards/DwlStandardsRule.js +90 -0
- package/dist/src/rules/standards/DwlStandardsRule.js.map +1 -0
- package/dist/src/rules/structure/StructureRules.d.ts +45 -0
- package/dist/src/rules/structure/StructureRules.d.ts.map +1 -0
- package/dist/src/rules/structure/StructureRules.js +163 -0
- package/dist/src/rules/structure/StructureRules.js.map +1 -0
- package/dist/src/rules/yaml/YamlRules.d.ts +46 -0
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -0
- package/dist/src/rules/yaml/YamlRules.js +226 -0
- package/dist/src/rules/yaml/YamlRules.js.map +1 -0
- package/dist/src/types/Config.d.ts +50 -0
- package/dist/src/types/Config.d.ts.map +1 -0
- package/dist/src/types/Config.js +18 -0
- package/dist/src/types/Config.js.map +1 -0
- package/dist/src/types/Report.d.ts +47 -0
- package/dist/src/types/Report.d.ts.map +1 -0
- package/dist/src/types/Report.js +3 -0
- package/dist/src/types/Report.js.map +1 -0
- package/dist/src/types/Rule.d.ts +76 -0
- package/dist/src/types/Rule.d.ts.map +1 -0
- package/dist/src/types/Rule.js +3 -0
- package/dist/src/types/Rule.js.map +1 -0
- package/dist/src/types/index.d.ts +4 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/index.js +21 -0
- package/dist/src/types/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComplexityCalculator = void 0;
|
|
4
|
+
const XPathHelper_1 = require("./XPathHelper");
|
|
5
|
+
/**
|
|
6
|
+
* Calculates cyclomatic complexity for Mule flows
|
|
7
|
+
*
|
|
8
|
+
* Complexity = 1 + (number of decision points)
|
|
9
|
+
*
|
|
10
|
+
* Decision points in Mule XML:
|
|
11
|
+
* - <choice> with N <when> clauses = N decision points
|
|
12
|
+
* - <until-successful> = 1 decision point
|
|
13
|
+
* - <foreach> = 1 decision point
|
|
14
|
+
* - <scatter-gather> = 1 decision point (parallel execution)
|
|
15
|
+
* - <try> = 1 decision point
|
|
16
|
+
*/
|
|
17
|
+
class ComplexityCalculator {
|
|
18
|
+
/**
|
|
19
|
+
* Calculate cyclomatic complexity for a flow element
|
|
20
|
+
*/
|
|
21
|
+
static calculateFlowComplexity(flowNode) {
|
|
22
|
+
let complexity = 1; // Base complexity
|
|
23
|
+
const details = [];
|
|
24
|
+
// Count choice/when clauses
|
|
25
|
+
const whenClauses = this.selectNodes('.//mule:when', flowNode);
|
|
26
|
+
if (whenClauses.length > 0) {
|
|
27
|
+
complexity += whenClauses.length;
|
|
28
|
+
details.push({
|
|
29
|
+
type: 'choice/when',
|
|
30
|
+
count: whenClauses.length,
|
|
31
|
+
contribution: whenClauses.length
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
// Count until-successful
|
|
35
|
+
const untilSuccessful = this.selectNodes('.//mule:until-successful', flowNode);
|
|
36
|
+
if (untilSuccessful.length > 0) {
|
|
37
|
+
complexity += untilSuccessful.length;
|
|
38
|
+
details.push({
|
|
39
|
+
type: 'until-successful',
|
|
40
|
+
count: untilSuccessful.length,
|
|
41
|
+
contribution: untilSuccessful.length
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
// Count foreach
|
|
45
|
+
const foreach = this.selectNodes('.//mule:foreach', flowNode);
|
|
46
|
+
if (foreach.length > 0) {
|
|
47
|
+
complexity += foreach.length;
|
|
48
|
+
details.push({
|
|
49
|
+
type: 'foreach',
|
|
50
|
+
count: foreach.length,
|
|
51
|
+
contribution: foreach.length
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Count scatter-gather
|
|
55
|
+
const scatterGather = this.selectNodes('.//mule:scatter-gather', flowNode);
|
|
56
|
+
if (scatterGather.length > 0) {
|
|
57
|
+
complexity += scatterGather.length;
|
|
58
|
+
details.push({
|
|
59
|
+
type: 'scatter-gather',
|
|
60
|
+
count: scatterGather.length,
|
|
61
|
+
contribution: scatterGather.length
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Count try scopes
|
|
65
|
+
const tryScopes = this.selectNodes('.//mule:try', flowNode);
|
|
66
|
+
if (tryScopes.length > 0) {
|
|
67
|
+
complexity += tryScopes.length;
|
|
68
|
+
details.push({
|
|
69
|
+
type: 'try',
|
|
70
|
+
count: tryScopes.length,
|
|
71
|
+
contribution: tryScopes.length
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// Count on-error handlers (each error type adds complexity)
|
|
75
|
+
const errorHandlers = this.selectNodes('.//mule:on-error-continue | .//mule:on-error-propagate', flowNode);
|
|
76
|
+
if (errorHandlers.length > 0) {
|
|
77
|
+
complexity += errorHandlers.length;
|
|
78
|
+
details.push({
|
|
79
|
+
type: 'error-handler',
|
|
80
|
+
count: errorHandlers.length,
|
|
81
|
+
contribution: errorHandlers.length
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
complexity,
|
|
86
|
+
details,
|
|
87
|
+
rating: this.getRating(complexity)
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get complexity rating
|
|
92
|
+
*/
|
|
93
|
+
static getRating(complexity) {
|
|
94
|
+
if (complexity <= 10)
|
|
95
|
+
return 'low';
|
|
96
|
+
if (complexity <= 20)
|
|
97
|
+
return 'moderate';
|
|
98
|
+
return 'high';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Helper to select nodes using XPath with Mule namespace
|
|
102
|
+
*/
|
|
103
|
+
static selectNodes(xpath, contextNode) {
|
|
104
|
+
const select = require('xpath').useNamespaces({
|
|
105
|
+
'mule': 'http://www.mulesoft.org/schema/mule/core'
|
|
106
|
+
});
|
|
107
|
+
try {
|
|
108
|
+
const doc = contextNode.ownerDocument || contextNode;
|
|
109
|
+
return select(xpath, contextNode);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Get the line number for a node
|
|
117
|
+
*/
|
|
118
|
+
static getNodeLine(node) {
|
|
119
|
+
return (0, XPathHelper_1.getLineNumber)(node);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.ComplexityCalculator = ComplexityCalculator;
|
|
123
|
+
//# sourceMappingURL=ComplexityCalculator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComplexityCalculator.js","sourceRoot":"","sources":["../../../src/core/ComplexityCalculator.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAE9C;;;;;;;;;;;GAWG;AACH,MAAa,oBAAoB;IAC7B;;OAEG;IACH,MAAM,CAAC,uBAAuB,CAAC,QAAc;QACzC,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC,kBAAk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EG;IACK,MAAM,CAAC,WAAW,CAAC,KAAa,EAAE,WAAiB;QACvD,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC;YAC1C,MAAM,EAAE,0CAA0C;SACrD,CAAC,CAAC;QAEH,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,WAAW,CAAC,aAAa,IAAI,WAAW,CAAC;YACrD,OAAO,MAAM,CAAC,KAAK,EAAE,WAAW,CAAW,CAAC;QAChD,CAAC;QAAC,MAAM,CAAC;YACL,OAAO,EAAE,CAAC;QACd,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,WAAW,CAAC,IAAU;QACzB,OAAO,IAAA,2BAAa,EAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;CACJ;AAhHD,oDAgHC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for file scanning
|
|
3
|
+
*/
|
|
4
|
+
export interface ScanOptions {
|
|
5
|
+
/** Glob patterns for files to include */
|
|
6
|
+
include: string[];
|
|
7
|
+
/** Glob patterns for files to exclude */
|
|
8
|
+
exclude: string[];
|
|
9
|
+
/** Maximum depth to traverse */
|
|
10
|
+
maxDepth?: number;
|
|
11
|
+
/** Follow symbolic links */
|
|
12
|
+
followSymlinks?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Default scan options for Mule projects
|
|
16
|
+
*/
|
|
17
|
+
export declare const DEFAULT_SCAN_OPTIONS: ScanOptions;
|
|
18
|
+
/**
|
|
19
|
+
* Information about a scanned file
|
|
20
|
+
*/
|
|
21
|
+
export interface ScannedFile {
|
|
22
|
+
/** Absolute path to the file */
|
|
23
|
+
absolutePath: string;
|
|
24
|
+
/** Path relative to the scan root */
|
|
25
|
+
relativePath: string;
|
|
26
|
+
/** File size in bytes */
|
|
27
|
+
size: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Scan a directory for XML files
|
|
31
|
+
*
|
|
32
|
+
* @param rootPath - Root directory to scan
|
|
33
|
+
* @param options - Scan options (include/exclude patterns)
|
|
34
|
+
* @returns Array of scanned file info
|
|
35
|
+
*/
|
|
36
|
+
export declare function scanDirectory(rootPath: string, options?: Partial<ScanOptions>): Promise<ScannedFile[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Synchronous version of scanDirectory
|
|
39
|
+
*/
|
|
40
|
+
export declare function scanDirectorySync(rootPath: string, options?: Partial<ScanOptions>): ScannedFile[];
|
|
41
|
+
/**
|
|
42
|
+
* Read file content
|
|
43
|
+
*/
|
|
44
|
+
export declare function readFileContent(filePath: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Check if file exists
|
|
47
|
+
*/
|
|
48
|
+
export declare function fileExists(filePath: string): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Get the Mule project source directory
|
|
51
|
+
* Returns the path if it exists, null otherwise
|
|
52
|
+
*/
|
|
53
|
+
export declare function getMuleSourceDir(projectRoot: string): string | null;
|
|
54
|
+
/**
|
|
55
|
+
* Get the resources directory
|
|
56
|
+
*/
|
|
57
|
+
export declare function getResourcesDir(projectRoot: string): string | null;
|
|
58
|
+
//# sourceMappingURL=FileScanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileScanner.d.ts","sourceRoot":"","sources":["../../../src/core/FileScanner.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,yCAAyC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,yCAAyC;IACzC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gCAAgC;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,cAAc,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,EAAE,WASlC,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GACnC,OAAO,CAAC,WAAW,EAAE,CAAC,CAmCxB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC7B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAO,CAAC,WAAW,CAAM,GACnC,WAAW,EAAE,CAmCf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEpD;AAID;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGnE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGlE"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DEFAULT_SCAN_OPTIONS = void 0;
|
|
40
|
+
exports.scanDirectory = scanDirectory;
|
|
41
|
+
exports.scanDirectorySync = scanDirectorySync;
|
|
42
|
+
exports.readFileContent = readFileContent;
|
|
43
|
+
exports.fileExists = fileExists;
|
|
44
|
+
exports.getMuleSourceDir = getMuleSourceDir;
|
|
45
|
+
exports.getResourcesDir = getResourcesDir;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
49
|
+
/**
|
|
50
|
+
* Default scan options for Mule projects
|
|
51
|
+
*/
|
|
52
|
+
exports.DEFAULT_SCAN_OPTIONS = {
|
|
53
|
+
include: ['**/*.xml'],
|
|
54
|
+
exclude: [
|
|
55
|
+
'**/target/**',
|
|
56
|
+
'**/node_modules/**',
|
|
57
|
+
'**/.git/**',
|
|
58
|
+
'**/*.munit.xml',
|
|
59
|
+
],
|
|
60
|
+
followSymlinks: false,
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Scan a directory for XML files
|
|
64
|
+
*
|
|
65
|
+
* @param rootPath - Root directory to scan
|
|
66
|
+
* @param options - Scan options (include/exclude patterns)
|
|
67
|
+
* @returns Array of scanned file info
|
|
68
|
+
*/
|
|
69
|
+
async function scanDirectory(rootPath, options = {}) {
|
|
70
|
+
const opts = { ...exports.DEFAULT_SCAN_OPTIONS, ...options };
|
|
71
|
+
const absoluteRoot = path.resolve(rootPath);
|
|
72
|
+
// Verify root exists and is a directory
|
|
73
|
+
if (!fs.existsSync(absoluteRoot)) {
|
|
74
|
+
throw new Error(`Path does not exist: ${absoluteRoot}`);
|
|
75
|
+
}
|
|
76
|
+
const stats = fs.statSync(absoluteRoot);
|
|
77
|
+
// If it's a single file, return just that file
|
|
78
|
+
if (stats.isFile()) {
|
|
79
|
+
return [{
|
|
80
|
+
absolutePath: absoluteRoot,
|
|
81
|
+
relativePath: path.basename(absoluteRoot),
|
|
82
|
+
size: stats.size,
|
|
83
|
+
}];
|
|
84
|
+
}
|
|
85
|
+
// Use fast-glob for directory scanning
|
|
86
|
+
const files = await (0, fast_glob_1.default)(opts.include, {
|
|
87
|
+
cwd: absoluteRoot,
|
|
88
|
+
absolute: true,
|
|
89
|
+
ignore: opts.exclude,
|
|
90
|
+
followSymbolicLinks: opts.followSymlinks,
|
|
91
|
+
onlyFiles: true,
|
|
92
|
+
deep: opts.maxDepth,
|
|
93
|
+
});
|
|
94
|
+
return files.map(filePath => ({
|
|
95
|
+
absolutePath: filePath,
|
|
96
|
+
relativePath: path.relative(absoluteRoot, filePath),
|
|
97
|
+
size: fs.statSync(filePath).size,
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Synchronous version of scanDirectory
|
|
102
|
+
*/
|
|
103
|
+
function scanDirectorySync(rootPath, options = {}) {
|
|
104
|
+
const opts = { ...exports.DEFAULT_SCAN_OPTIONS, ...options };
|
|
105
|
+
const absoluteRoot = path.resolve(rootPath);
|
|
106
|
+
// Verify root exists
|
|
107
|
+
if (!fs.existsSync(absoluteRoot)) {
|
|
108
|
+
throw new Error(`Path does not exist: ${absoluteRoot}`);
|
|
109
|
+
}
|
|
110
|
+
const stats = fs.statSync(absoluteRoot);
|
|
111
|
+
// If it's a single file, return just that file
|
|
112
|
+
if (stats.isFile()) {
|
|
113
|
+
return [{
|
|
114
|
+
absolutePath: absoluteRoot,
|
|
115
|
+
relativePath: path.basename(absoluteRoot),
|
|
116
|
+
size: stats.size,
|
|
117
|
+
}];
|
|
118
|
+
}
|
|
119
|
+
// Use fast-glob sync for directory scanning
|
|
120
|
+
const files = fast_glob_1.default.sync(opts.include, {
|
|
121
|
+
cwd: absoluteRoot,
|
|
122
|
+
absolute: true,
|
|
123
|
+
ignore: opts.exclude,
|
|
124
|
+
followSymbolicLinks: opts.followSymlinks,
|
|
125
|
+
onlyFiles: true,
|
|
126
|
+
deep: opts.maxDepth,
|
|
127
|
+
});
|
|
128
|
+
return files.map(filePath => ({
|
|
129
|
+
absolutePath: filePath,
|
|
130
|
+
relativePath: path.relative(absoluteRoot, filePath),
|
|
131
|
+
size: fs.statSync(filePath).size,
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Read file content
|
|
136
|
+
*/
|
|
137
|
+
function readFileContent(filePath) {
|
|
138
|
+
return fs.readFileSync(filePath, 'utf-8');
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Check if file exists
|
|
142
|
+
*/
|
|
143
|
+
function fileExists(filePath) {
|
|
144
|
+
return fs.existsSync(filePath);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Get the Mule project source directory
|
|
148
|
+
* Returns the path if it exists, null otherwise
|
|
149
|
+
*/
|
|
150
|
+
function getMuleSourceDir(projectRoot) {
|
|
151
|
+
const muleDir = path.join(projectRoot, 'src', 'main', 'mule');
|
|
152
|
+
return fs.existsSync(muleDir) ? muleDir : null;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get the resources directory
|
|
156
|
+
*/
|
|
157
|
+
function getResourcesDir(projectRoot) {
|
|
158
|
+
const resourcesDir = path.join(projectRoot, 'src', 'main', 'resources');
|
|
159
|
+
return fs.existsSync(resourcesDir) ? resourcesDir : null;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=FileScanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileScanner.js","sourceRoot":"","sources":["../../../src/core/FileScanner.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,sCAsCC;AAKD,8CAsCC;AAKD,0CAEC;AAKD,gCAEC;AAQD,4CAGC;AAKD,0CAGC;AArKD,uCAAyB;AACzB,2CAA6B;AAC7B,0DAA2B;AAgB3B;;GAEG;AACU,QAAA,oBAAoB,GAAgB;IAC7C,OAAO,EAAE,CAAC,UAAU,CAAC;IACrB,OAAO,EAAE;QACL,cAAc;QACd,oBAAoB;QACpB,YAAY;QACZ,gBAAgB;KACnB;IACD,cAAc,EAAE,KAAK;CACxB,CAAC;AAcF;;;;;;GAMG;AACI,KAAK,UAAU,aAAa,CAC/B,QAAgB,EAChB,UAAgC,EAAE;IAElC,MAAM,IAAI,GAAgB,EAAE,GAAG,4BAAoB,EAAE,GAAG,OAAO,EAAE,CAAC;IAClE,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5C,wCAAwC;IACxC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,wBAAwB,YAAY,EAAE,CAAC,CAAC;IAC5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IAC9D,OAAO,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC;AACnD,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,WAAmB;IAC/C,MAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IACxE,OAAO,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MuleSoft XML namespace mappings
|
|
3
|
+
* These are the standard namespaces used in Mule 4 applications
|
|
4
|
+
*/
|
|
5
|
+
export declare const MULE_NAMESPACES: Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* Helper class for namespace-aware XPath queries on Mule XML documents
|
|
8
|
+
*/
|
|
9
|
+
export declare class XPathHelper {
|
|
10
|
+
private static instance;
|
|
11
|
+
private readonly select;
|
|
12
|
+
private constructor();
|
|
13
|
+
/**
|
|
14
|
+
* Get singleton instance
|
|
15
|
+
*/
|
|
16
|
+
static getInstance(customNamespaces?: Record<string, string>): XPathHelper;
|
|
17
|
+
/**
|
|
18
|
+
* Reset the singleton instance (useful for testing)
|
|
19
|
+
*/
|
|
20
|
+
static reset(): void;
|
|
21
|
+
/**
|
|
22
|
+
* Execute XPath query and return matching nodes
|
|
23
|
+
* @param expression - XPath expression (can use namespace prefixes like mule:flow)
|
|
24
|
+
* @param context - Document or Node to query
|
|
25
|
+
* @returns Array of matching nodes
|
|
26
|
+
*/
|
|
27
|
+
selectNodes(expression: string, context: Document | Node): Node[];
|
|
28
|
+
/**
|
|
29
|
+
* Execute XPath query and return first matching node
|
|
30
|
+
* @param expression - XPath expression
|
|
31
|
+
* @param context - Document or Node to query
|
|
32
|
+
* @returns First matching node or null
|
|
33
|
+
*/
|
|
34
|
+
selectNode(expression: string, context: Document | Node): Node | null;
|
|
35
|
+
/**
|
|
36
|
+
* Execute XPath query and return string value
|
|
37
|
+
* @param expression - XPath expression
|
|
38
|
+
* @param context - Document or Node to query
|
|
39
|
+
* @returns String value or null
|
|
40
|
+
*/
|
|
41
|
+
selectString(expression: string, context: Document | Node): string | null;
|
|
42
|
+
/**
|
|
43
|
+
* Check if any nodes match the XPath expression
|
|
44
|
+
* @param expression - XPath expression
|
|
45
|
+
* @param context - Document or Node to query
|
|
46
|
+
* @returns true if at least one node matches
|
|
47
|
+
*/
|
|
48
|
+
exists(expression: string, context: Document | Node): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Count nodes matching the XPath expression
|
|
51
|
+
* @param expression - XPath expression
|
|
52
|
+
* @param context - Document or Node to query
|
|
53
|
+
* @returns Number of matching nodes
|
|
54
|
+
*/
|
|
55
|
+
count(expression: string, context: Document | Node): number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Utility functions for working with XML nodes
|
|
59
|
+
*/
|
|
60
|
+
export declare function getAttribute(node: Node, attrName: string): string | null;
|
|
61
|
+
/**
|
|
62
|
+
* Get line number from a parsed node (xmldom stores this)
|
|
63
|
+
*/
|
|
64
|
+
export declare function getLineNumber(node: Node): number;
|
|
65
|
+
/**
|
|
66
|
+
* Get column number from a parsed node
|
|
67
|
+
*/
|
|
68
|
+
export declare function getColumnNumber(node: Node): number | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Check if a node has a specific attribute
|
|
71
|
+
*/
|
|
72
|
+
export declare function hasAttribute(node: Node, attrName: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Get the local name of a node (without namespace prefix)
|
|
75
|
+
*/
|
|
76
|
+
export declare function getLocalName(node: Node): string;
|
|
77
|
+
/**
|
|
78
|
+
* Get text content of a node
|
|
79
|
+
*/
|
|
80
|
+
export declare function getTextContent(node: Node): string;
|
|
81
|
+
//# sourceMappingURL=XPathHelper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AAgB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,SAAS,CAG9D;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAGlE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAG/C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.XPathHelper = exports.MULE_NAMESPACES = void 0;
|
|
37
|
+
exports.getAttribute = getAttribute;
|
|
38
|
+
exports.getLineNumber = getLineNumber;
|
|
39
|
+
exports.getColumnNumber = getColumnNumber;
|
|
40
|
+
exports.hasAttribute = hasAttribute;
|
|
41
|
+
exports.getLocalName = getLocalName;
|
|
42
|
+
exports.getTextContent = getTextContent;
|
|
43
|
+
const xpath = __importStar(require("xpath"));
|
|
44
|
+
// DOM types from global lib.dom (used by @xmldom/xmldom)
|
|
45
|
+
// Note: @xmldom/xmldom uses standard DOM interfaces
|
|
46
|
+
/**
|
|
47
|
+
* MuleSoft XML namespace mappings
|
|
48
|
+
* These are the standard namespaces used in Mule 4 applications
|
|
49
|
+
*/
|
|
50
|
+
exports.MULE_NAMESPACES = {
|
|
51
|
+
// Core Mule
|
|
52
|
+
'mule': 'http://www.mulesoft.org/schema/mule/core',
|
|
53
|
+
// HTTP Connector
|
|
54
|
+
'http': 'http://www.mulesoft.org/schema/mule/http',
|
|
55
|
+
'https': 'http://www.mulesoft.org/schema/mule/https',
|
|
56
|
+
// DataWeave / EE
|
|
57
|
+
'ee': 'http://www.mulesoft.org/schema/mule/ee/core',
|
|
58
|
+
// Documentation
|
|
59
|
+
'doc': 'http://www.mulesoft.org/schema/mule/documentation',
|
|
60
|
+
// Security / TLS
|
|
61
|
+
'tls': 'http://www.mulesoft.org/schema/mule/tls',
|
|
62
|
+
'secure-properties': 'http://www.mulesoft.org/schema/mule/secure-properties',
|
|
63
|
+
// Database
|
|
64
|
+
'db': 'http://www.mulesoft.org/schema/mule/db',
|
|
65
|
+
// File connectors
|
|
66
|
+
'file': 'http://www.mulesoft.org/schema/mule/file',
|
|
67
|
+
'sftp': 'http://www.mulesoft.org/schema/mule/sftp',
|
|
68
|
+
'ftp': 'http://www.mulesoft.org/schema/mule/ftp',
|
|
69
|
+
// Messaging
|
|
70
|
+
'vm': 'http://www.mulesoft.org/schema/mule/vm',
|
|
71
|
+
'jms': 'http://www.mulesoft.org/schema/mule/jms',
|
|
72
|
+
'amqp': 'http://www.mulesoft.org/schema/mule/amqp',
|
|
73
|
+
// API
|
|
74
|
+
'apikit': 'http://www.mulesoft.org/schema/mule/mule-apikit',
|
|
75
|
+
'api-gateway': 'http://www.mulesoft.org/schema/mule/api-gateway',
|
|
76
|
+
// Object Store
|
|
77
|
+
'os': 'http://www.mulesoft.org/schema/mule/os',
|
|
78
|
+
// Batch
|
|
79
|
+
'batch': 'http://www.mulesoft.org/schema/mule/batch',
|
|
80
|
+
// Salesforce
|
|
81
|
+
'salesforce': 'http://www.mulesoft.org/schema/mule/salesforce',
|
|
82
|
+
// Email
|
|
83
|
+
'email': 'http://www.mulesoft.org/schema/mule/email',
|
|
84
|
+
// Validation
|
|
85
|
+
'validation': 'http://www.mulesoft.org/schema/mule/validation',
|
|
86
|
+
// Scripting
|
|
87
|
+
'scripting': 'http://www.mulesoft.org/schema/mule/scripting',
|
|
88
|
+
// Java
|
|
89
|
+
'java': 'http://www.mulesoft.org/schema/mule/java',
|
|
90
|
+
// Sockets
|
|
91
|
+
'sockets': 'http://www.mulesoft.org/schema/mule/sockets',
|
|
92
|
+
// Web Service Consumer
|
|
93
|
+
'wsc': 'http://www.mulesoft.org/schema/mule/wsc',
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Helper class for namespace-aware XPath queries on Mule XML documents
|
|
97
|
+
*/
|
|
98
|
+
class XPathHelper {
|
|
99
|
+
static instance;
|
|
100
|
+
select;
|
|
101
|
+
constructor(customNamespaces) {
|
|
102
|
+
const namespaces = { ...exports.MULE_NAMESPACES, ...customNamespaces };
|
|
103
|
+
this.select = xpath.useNamespaces(namespaces);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Get singleton instance
|
|
107
|
+
*/
|
|
108
|
+
static getInstance(customNamespaces) {
|
|
109
|
+
if (!XPathHelper.instance) {
|
|
110
|
+
XPathHelper.instance = new XPathHelper(customNamespaces);
|
|
111
|
+
}
|
|
112
|
+
return XPathHelper.instance;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Reset the singleton instance (useful for testing)
|
|
116
|
+
*/
|
|
117
|
+
static reset() {
|
|
118
|
+
XPathHelper.instance = undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Execute XPath query and return matching nodes
|
|
122
|
+
* @param expression - XPath expression (can use namespace prefixes like mule:flow)
|
|
123
|
+
* @param context - Document or Node to query
|
|
124
|
+
* @returns Array of matching nodes
|
|
125
|
+
*/
|
|
126
|
+
selectNodes(expression, context) {
|
|
127
|
+
try {
|
|
128
|
+
const result = this.select(expression, context);
|
|
129
|
+
if (Array.isArray(result)) {
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
console.error(`XPath error for expression "${expression}":`, error);
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Execute XPath query and return first matching node
|
|
141
|
+
* @param expression - XPath expression
|
|
142
|
+
* @param context - Document or Node to query
|
|
143
|
+
* @returns First matching node or null
|
|
144
|
+
*/
|
|
145
|
+
selectNode(expression, context) {
|
|
146
|
+
const nodes = this.selectNodes(expression, context);
|
|
147
|
+
return nodes.length > 0 ? nodes[0] : null;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Execute XPath query and return string value
|
|
151
|
+
* @param expression - XPath expression
|
|
152
|
+
* @param context - Document or Node to query
|
|
153
|
+
* @returns String value or null
|
|
154
|
+
*/
|
|
155
|
+
selectString(expression, context) {
|
|
156
|
+
try {
|
|
157
|
+
const result = this.select(`string(${expression})`, context);
|
|
158
|
+
return typeof result === 'string' && result.length > 0 ? result : null;
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Check if any nodes match the XPath expression
|
|
166
|
+
* @param expression - XPath expression
|
|
167
|
+
* @param context - Document or Node to query
|
|
168
|
+
* @returns true if at least one node matches
|
|
169
|
+
*/
|
|
170
|
+
exists(expression, context) {
|
|
171
|
+
return this.selectNodes(expression, context).length > 0;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Count nodes matching the XPath expression
|
|
175
|
+
* @param expression - XPath expression
|
|
176
|
+
* @param context - Document or Node to query
|
|
177
|
+
* @returns Number of matching nodes
|
|
178
|
+
*/
|
|
179
|
+
count(expression, context) {
|
|
180
|
+
return this.selectNodes(expression, context).length;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
exports.XPathHelper = XPathHelper;
|
|
184
|
+
/**
|
|
185
|
+
* Utility functions for working with XML nodes
|
|
186
|
+
*/
|
|
187
|
+
function getAttribute(node, attrName) {
|
|
188
|
+
const element = node;
|
|
189
|
+
if (element.getAttribute) {
|
|
190
|
+
const value = element.getAttribute(attrName);
|
|
191
|
+
return value || null;
|
|
192
|
+
}
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Get line number from a parsed node (xmldom stores this)
|
|
197
|
+
*/
|
|
198
|
+
function getLineNumber(node) {
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
200
|
+
return node.lineNumber ?? 1;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Get column number from a parsed node
|
|
204
|
+
*/
|
|
205
|
+
function getColumnNumber(node) {
|
|
206
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
207
|
+
return node.columnNumber;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Check if a node has a specific attribute
|
|
211
|
+
*/
|
|
212
|
+
function hasAttribute(node, attrName) {
|
|
213
|
+
const element = node;
|
|
214
|
+
return element.hasAttribute?.(attrName) ?? false;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Get the local name of a node (without namespace prefix)
|
|
218
|
+
*/
|
|
219
|
+
function getLocalName(node) {
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
|
221
|
+
return node.localName ?? node.nodeName;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Get text content of a node
|
|
225
|
+
*/
|
|
226
|
+
function getTextContent(node) {
|
|
227
|
+
return node.textContent ?? '';
|
|
228
|
+
}
|
|
229
|
+
//# sourceMappingURL=XPathHelper.js.map
|