@sfdxy/mule-lint 1.18.1 → 1.20.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 +164 -151
- package/dist/bin/mule-lint-mcp.js.map +1 -1
- package/dist/bin/mule-lint.js +2 -2
- package/dist/bin/mule-lint.js.map +1 -1
- package/dist/package.json +26 -15
- package/dist/src/core/ComplexityCalculator.d.ts.map +1 -1
- package/dist/src/core/ComplexityCalculator.js.map +1 -1
- package/dist/src/core/FileScanner.d.ts.map +1 -1
- package/dist/src/core/FileScanner.js.map +1 -1
- package/dist/src/core/MetricsAggregator.d.ts.map +1 -1
- package/dist/src/core/MetricsAggregator.js +1 -1
- package/dist/src/core/MetricsAggregator.js.map +1 -1
- package/dist/src/core/MetricsCollector.d.ts.map +1 -1
- package/dist/src/core/MetricsCollector.js +1 -2
- package/dist/src/core/MetricsCollector.js.map +1 -1
- package/dist/src/core/QualityGateEvaluator.d.ts.map +1 -1
- package/dist/src/core/QualityGateEvaluator.js.map +1 -1
- package/dist/src/core/XPathHelper.d.ts.map +1 -1
- package/dist/src/core/XPathHelper.js +0 -1
- package/dist/src/core/XPathHelper.js.map +1 -1
- package/dist/src/core/XmlParser.d.ts.map +1 -1
- package/dist/src/core/XmlParser.js.map +1 -1
- package/dist/src/core/YamlParser.d.ts.map +1 -1
- package/dist/src/core/YamlParser.js.map +1 -1
- package/dist/src/core/errors.js.map +1 -1
- package/dist/src/engine/LintEngine.d.ts +10 -0
- package/dist/src/engine/LintEngine.d.ts.map +1 -1
- package/dist/src/engine/LintEngine.js +68 -4
- package/dist/src/engine/LintEngine.js.map +1 -1
- package/dist/src/formatter/MuleXmlFormatter.d.ts.map +1 -1
- package/dist/src/formatter/MuleXmlFormatter.js +7 -1
- package/dist/src/formatter/MuleXmlFormatter.js.map +1 -1
- package/dist/src/formatter/index.d.ts +2 -2
- package/dist/src/formatter/index.d.ts.map +1 -1
- package/dist/src/formatter/index.js.map +1 -1
- package/dist/src/formatters/CsvFormatter.js.map +1 -1
- package/dist/src/formatters/HtmlFormatter.js +0 -1
- package/dist/src/formatters/HtmlFormatter.js.map +1 -1
- package/dist/src/formatters/JsonFormatter.d.ts.map +1 -1
- package/dist/src/formatters/JsonFormatter.js.map +1 -1
- package/dist/src/formatters/SarifFormatter.js.map +1 -1
- package/dist/src/formatters/TableFormatter.js.map +1 -1
- package/dist/src/formatters/html/components/Icons.js +1 -1
- package/dist/src/formatters/html/components/Icons.js.map +1 -1
- package/dist/src/formatters/html/components/MetricCard.d.ts.map +1 -1
- package/dist/src/formatters/html/components/MetricCard.js.map +1 -1
- package/dist/src/formatters/html/components/Modal.d.ts.map +1 -1
- package/dist/src/formatters/html/components/Modal.js.map +1 -1
- package/dist/src/formatters/html/components/RatingBadge.d.ts.map +1 -1
- package/dist/src/formatters/html/components/RatingBadge.js +6 -6
- package/dist/src/formatters/html/components/RatingBadge.js.map +1 -1
- package/dist/src/formatters/html/index.d.ts +2 -2
- package/dist/src/formatters/html/index.d.ts.map +1 -1
- package/dist/src/formatters/html/index.js.map +1 -1
- package/dist/src/formatters/html/scripts/charts.d.ts.map +1 -1
- package/dist/src/formatters/html/scripts/charts.js +45 -12
- package/dist/src/formatters/html/scripts/charts.js.map +1 -1
- package/dist/src/formatters/html/scripts/index.d.ts.map +1 -1
- package/dist/src/formatters/html/scripts/index.js.map +1 -1
- package/dist/src/formatters/html/scripts/renderer.d.ts.map +1 -1
- package/dist/src/formatters/html/scripts/renderer.js +175 -35
- package/dist/src/formatters/html/scripts/renderer.js.map +1 -1
- package/dist/src/formatters/html/sections/Header.d.ts.map +1 -1
- package/dist/src/formatters/html/sections/Header.js.map +1 -1
- package/dist/src/formatters/html/sections/LintSummary.d.ts.map +1 -1
- package/dist/src/formatters/html/sections/LintSummary.js.map +1 -1
- package/dist/src/formatters/html/sections/QualityRatings.js.map +1 -1
- package/dist/src/formatters/html/sections/Sidebar.d.ts.map +1 -1
- package/dist/src/formatters/html/sections/Sidebar.js.map +1 -1
- package/dist/src/formatters/html/styles/badges.d.ts.map +1 -1
- package/dist/src/formatters/html/styles/badges.js.map +1 -1
- package/dist/src/formatters/html/styles/index.d.ts.map +1 -1
- package/dist/src/formatters/html/styles/index.js.map +1 -1
- package/dist/src/formatters/html/theme.js.map +1 -1
- package/dist/src/formatters/html/views/Dashboard.js +5 -5
- package/dist/src/formatters/html/views/Dashboard.js.map +1 -1
- package/dist/src/formatters/html/views/IssuesView.d.ts.map +1 -1
- package/dist/src/formatters/html/views/IssuesView.js.map +1 -1
- package/dist/src/formatters/index.js.map +1 -1
- package/dist/src/mcp/index.d.ts.map +1 -1
- package/dist/src/mcp/index.js +0 -1
- package/dist/src/mcp/index.js.map +1 -1
- package/dist/src/mcp/prompts/index.js.map +1 -1
- package/dist/src/mcp/resources/index.js +30 -7
- package/dist/src/mcp/resources/index.js.map +1 -1
- package/dist/src/mcp/tools/formatMuleXml.d.ts.map +1 -1
- package/dist/src/mcp/tools/formatMuleXml.js +4 -13
- package/dist/src/mcp/tools/formatMuleXml.js.map +1 -1
- package/dist/src/mcp/tools/getRuleDetails.d.ts.map +1 -1
- package/dist/src/mcp/tools/getRuleDetails.js +1 -3
- package/dist/src/mcp/tools/getRuleDetails.js.map +1 -1
- package/dist/src/mcp/tools/runLintAnalysis.js +9 -9
- package/dist/src/mcp/tools/runLintAnalysis.js.map +1 -1
- package/dist/src/mcp/tools/validateSnippet.d.ts.map +1 -1
- package/dist/src/mcp/tools/validateSnippet.js.map +1 -1
- package/dist/src/quality/calculator.d.ts.map +1 -1
- package/dist/src/quality/calculator.js +1 -1
- package/dist/src/quality/calculator.js.map +1 -1
- package/dist/src/quality/index.d.ts.map +1 -1
- package/dist/src/quality/index.js.map +1 -1
- package/dist/src/quality/thresholds.js.map +1 -1
- package/dist/src/quality/types.d.ts.map +1 -1
- package/dist/src/rules/api-led/ApiLedRules.d.ts.map +1 -1
- package/dist/src/rules/api-led/ApiLedRules.js +6 -2
- package/dist/src/rules/api-led/ApiLedRules.js.map +1 -1
- package/dist/src/rules/api-led/SingleSystemSapiRule.d.ts.map +1 -1
- package/dist/src/rules/api-led/SingleSystemSapiRule.js.map +1 -1
- package/dist/src/rules/base/BaseRule.d.ts.map +1 -1
- package/dist/src/rules/base/BaseRule.js.map +1 -1
- package/dist/src/rules/base/ProjectRule.d.ts.map +1 -1
- package/dist/src/rules/base/ProjectRule.js.map +1 -1
- package/dist/src/rules/complexity/FlowComplexityRule.d.ts.map +1 -1
- package/dist/src/rules/complexity/FlowComplexityRule.js.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts +6 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.js +17 -3
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -1
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.d.ts.map +1 -1
- package/dist/src/rules/dataweave/Java17DWErrorHandlingRule.js.map +1 -1
- package/dist/src/rules/documentation/DisplayNameRule.d.ts.map +1 -1
- package/dist/src/rules/documentation/DisplayNameRule.js.map +1 -1
- package/dist/src/rules/documentation/FlowDescriptionRule.d.ts.map +1 -1
- package/dist/src/rules/documentation/FlowDescriptionRule.js.map +1 -1
- package/dist/src/rules/documentation/MissingDocNameRule.d.ts.map +1 -1
- package/dist/src/rules/documentation/MissingDocNameRule.js.map +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts +22 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/CorrelationIdRule.js +107 -6
- package/dist/src/rules/error-handling/CorrelationIdRule.js.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts +14 -2
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +40 -18
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts +5 -0
- package/dist/src/rules/error-handling/HttpStatusRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/HttpStatusRule.js +15 -0
- package/dist/src/rules/error-handling/HttpStatusRule.js.map +1 -1
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/MissingErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.js.map +1 -1
- package/dist/src/rules/experimental/ExperimentalRules.d.ts.map +1 -1
- package/dist/src/rules/experimental/ExperimentalRules.js +6 -2
- package/dist/src/rules/experimental/ExperimentalRules.js.map +1 -1
- package/dist/src/rules/governance/GovernanceRules.d.ts.map +1 -1
- package/dist/src/rules/governance/GovernanceRules.js.map +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.d.ts +28 -1
- package/dist/src/rules/http/HttpContentTypeRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpContentTypeRule.js +68 -7
- package/dist/src/rules/http/HttpContentTypeRule.js.map +1 -1
- package/dist/src/rules/http/HttpTimeoutRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpTimeoutRule.js.map +1 -1
- package/dist/src/rules/http/HttpUserAgentRule.d.ts.map +1 -1
- package/dist/src/rules/http/HttpUserAgentRule.js.map +1 -1
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/logging/ExcessiveLoggersRule.d.ts.map +1 -1
- package/dist/src/rules/logging/ExcessiveLoggersRule.js.map +1 -1
- package/dist/src/rules/logging/LoggerCategoryRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerCategoryRule.js.map +1 -1
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerInUntilSuccessfulRule.js.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -1
- package/dist/src/rules/logging/NewLoggingRules.d.ts.map +1 -1
- package/dist/src/rules/logging/NewLoggingRules.js.map +1 -1
- package/dist/src/rules/naming/FlowCasingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/FlowCasingRule.js.map +1 -1
- package/dist/src/rules/naming/FlowNamingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/FlowNamingRule.js +3 -1
- package/dist/src/rules/naming/FlowNamingRule.js.map +1 -1
- package/dist/src/rules/naming/VariableNamingRule.d.ts.map +1 -1
- package/dist/src/rules/naming/VariableNamingRule.js.map +1 -1
- package/dist/src/rules/operations/CommentedCodeRule.d.ts.map +1 -1
- package/dist/src/rules/operations/CommentedCodeRule.js.map +1 -1
- package/dist/src/rules/operations/UnusedFlowRule.d.ts +6 -1
- package/dist/src/rules/operations/UnusedFlowRule.d.ts.map +1 -1
- package/dist/src/rules/operations/UnusedFlowRule.js +23 -9
- package/dist/src/rules/operations/UnusedFlowRule.js.map +1 -1
- package/dist/src/rules/performance/AsyncErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/performance/AsyncErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/performance/ConnectionPoolingRule.d.ts +5 -0
- package/dist/src/rules/performance/ConnectionPoolingRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ConnectionPoolingRule.js +18 -5
- package/dist/src/rules/performance/ConnectionPoolingRule.js.map +1 -1
- package/dist/src/rules/performance/LargeChoiceBlockRule.d.ts.map +1 -1
- package/dist/src/rules/performance/LargeChoiceBlockRule.js.map +1 -1
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts +7 -0
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ReconnectionStrategyRule.js +15 -2
- package/dist/src/rules/performance/ReconnectionStrategyRule.js.map +1 -1
- package/dist/src/rules/performance/ScatterGatherRoutesRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ScatterGatherRoutesRule.js.map +1 -1
- package/dist/src/rules/security/EncryptionKeyInLogsRule.d.ts.map +1 -1
- package/dist/src/rules/security/EncryptionKeyInLogsRule.js.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -1
- package/dist/src/rules/security/HardcodedHttpRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedHttpRule.js +1 -9
- package/dist/src/rules/security/HardcodedHttpRule.js.map +1 -1
- package/dist/src/rules/security/InputValidationRule.d.ts.map +1 -1
- package/dist/src/rules/security/InputValidationRule.js +1 -3
- package/dist/src/rules/security/InputValidationRule.js.map +1 -1
- package/dist/src/rules/security/InsecureTlsRule.d.ts.map +1 -1
- package/dist/src/rules/security/InsecureTlsRule.js.map +1 -1
- package/dist/src/rules/security/RateLimitingRule.d.ts.map +1 -1
- package/dist/src/rules/security/RateLimitingRule.js.map +1 -1
- package/dist/src/rules/security/TlsVersionRule.d.ts.map +1 -1
- package/dist/src/rules/security/TlsVersionRule.js.map +1 -1
- package/dist/src/rules/standards/ApiKitValidationRule.d.ts.map +1 -1
- package/dist/src/rules/standards/ApiKitValidationRule.js.map +1 -1
- package/dist/src/rules/standards/AutoDiscoveryRule.d.ts.map +1 -1
- package/dist/src/rules/standards/AutoDiscoveryRule.js.map +1 -1
- package/dist/src/rules/standards/ChoiceAntiPatternRule.d.ts.map +1 -1
- package/dist/src/rules/standards/ChoiceAntiPatternRule.js.map +1 -1
- package/dist/src/rules/standards/CronExternalizedRule.d.ts.map +1 -1
- package/dist/src/rules/standards/CronExternalizedRule.js.map +1 -1
- package/dist/src/rules/standards/DeprecatedComponentRule.d.ts.map +1 -1
- package/dist/src/rules/standards/DeprecatedComponentRule.js.map +1 -1
- package/dist/src/rules/standards/DwlStandardsRule.d.ts.map +1 -1
- package/dist/src/rules/standards/DwlStandardsRule.js.map +1 -1
- package/dist/src/rules/standards/HttpPortPlaceholderRule.d.ts.map +1 -1
- package/dist/src/rules/standards/HttpPortPlaceholderRule.js.map +1 -1
- package/dist/src/rules/structure/StructureRules.d.ts +8 -1
- package/dist/src/rules/structure/StructureRules.d.ts.map +1 -1
- package/dist/src/rules/structure/StructureRules.js +11 -7
- package/dist/src/rules/structure/StructureRules.js.map +1 -1
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -1
- package/dist/src/rules/yaml/YamlRules.js +2 -7
- package/dist/src/rules/yaml/YamlRules.js.map +1 -1
- package/dist/src/types/Config.d.ts.map +1 -1
- package/dist/src/types/Config.js.map +1 -1
- package/dist/src/types/QualityGate.d.ts.map +1 -1
- package/dist/src/types/QualityGate.js.map +1 -1
- package/dist/src/types/Report.d.ts.map +1 -1
- package/dist/src/types/Rule.d.ts +22 -0
- package/dist/src/types/Rule.d.ts.map +1 -1
- package/docs/README.md +27 -27
- package/docs/best-practices/documentation-standards.md +20 -11
- package/docs/best-practices/folder-structure.md +16 -10
- package/docs/best-practices/mulesoft-best-practices.md +96 -94
- package/docs/best-practices/rules-catalog.md +422 -299
- package/docs/linter/architecture.md +70 -64
- package/docs/linter/extending.md +137 -128
- package/docs/linter/folder-structure.md +39 -38
- package/docs/linter/naming-conventions.md +80 -78
- package/docs/linter/rule-engine.md +306 -306
- package/docs/mcp-design.md +35 -21
- package/package.json +84 -73
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
## Table of Contents
|
|
8
8
|
|
|
9
9
|
### Linter-Enforced Practices
|
|
10
|
+
|
|
10
11
|
- [API-Led Connectivity](#api-led-connectivity)
|
|
11
12
|
- [Error Handling](#error-handling)
|
|
12
13
|
- [Logging Standards](#logging-standards)
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
- [Documentation Standards](#documentation-standards)
|
|
20
21
|
|
|
21
22
|
### General Developer Guidelines
|
|
23
|
+
|
|
22
24
|
- [Testing with MUnit](#testing-with-munit)
|
|
23
25
|
- [CI/CD Integration](#cicd-integration)
|
|
24
26
|
- [API Versioning](#api-versioning)
|
|
@@ -55,11 +57,11 @@ MuleSoft's API-Led Connectivity approach organizes APIs into three layers, each
|
|
|
55
57
|
|
|
56
58
|
### Layer Guidelines
|
|
57
59
|
|
|
58
|
-
| Layer
|
|
59
|
-
|
|
60
|
+
| Layer | Should Have | Should NOT Have |
|
|
61
|
+
| -------------- | ------------------------------------------------ | ---------------------------------------------- |
|
|
60
62
|
| **Experience** | HTTP listeners, channel-specific transformations | Direct database access, complex business logic |
|
|
61
|
-
| **Process**
|
|
62
|
-
| **System**
|
|
63
|
+
| **Process** | Flow-refs to other APIs, orchestration logic | Direct system connections, database queries |
|
|
64
|
+
| **System** | Database operations, HTTP requests to backends | Business logic, data aggregation |
|
|
63
65
|
|
|
64
66
|
### Example Flow Structure
|
|
65
67
|
|
|
@@ -121,16 +123,16 @@ output application/json
|
|
|
121
123
|
}]]></ee:set-payload>
|
|
122
124
|
</ee:transform>
|
|
123
125
|
</on-error-propagate>
|
|
124
|
-
|
|
126
|
+
|
|
125
127
|
<on-error-propagate type="APIKIT:NOT_FOUND">
|
|
126
128
|
<set-variable variableName="httpStatus" value="404"/>
|
|
127
129
|
<!-- ... -->
|
|
128
130
|
</on-error-propagate>
|
|
129
|
-
|
|
131
|
+
|
|
130
132
|
<!-- Catch-all for unexpected errors -->
|
|
131
133
|
<on-error-propagate>
|
|
132
134
|
<set-variable variableName="httpStatus" value="500"/>
|
|
133
|
-
<logger category="com.myorg.errors" level="ERROR"
|
|
135
|
+
<logger category="com.myorg.errors" level="ERROR"
|
|
134
136
|
message="#['Error: ' ++ error.description ++ ' | CorrelationId: ' ++ correlationId]"/>
|
|
135
137
|
<!-- ... -->
|
|
136
138
|
</on-error-propagate>
|
|
@@ -168,10 +170,10 @@ Use hierarchical category names:
|
|
|
168
170
|
|
|
169
171
|
```xml
|
|
170
172
|
<!-- ✅ Good - Hierarchical categories -->
|
|
171
|
-
<logger category="com.myorg.orders.api" level="INFO"
|
|
173
|
+
<logger category="com.myorg.orders.api" level="INFO"
|
|
172
174
|
message="#['Processing order: ' ++ vars.orderId]"/>
|
|
173
175
|
|
|
174
|
-
<logger category="com.myorg.orders.db" level="DEBUG"
|
|
176
|
+
<logger category="com.myorg.orders.db" level="DEBUG"
|
|
175
177
|
message="#['Query executed in ' ++ vars.queryTime ++ 'ms']"/>
|
|
176
178
|
```
|
|
177
179
|
|
|
@@ -232,12 +234,12 @@ Protect sensitive data and follow secure development practices.
|
|
|
232
234
|
```xml
|
|
233
235
|
<!-- ❌ Bad - Hardcoded credentials -->
|
|
234
236
|
<http:request-config host="api.example.com"
|
|
235
|
-
username="admin"
|
|
237
|
+
username="admin"
|
|
236
238
|
password="secret123"/>
|
|
237
239
|
|
|
238
240
|
<!-- ✅ Good - Property placeholders -->
|
|
239
241
|
<http:request-config host="${api.host}"
|
|
240
|
-
username="${api.username}"
|
|
242
|
+
username="${api.username}"
|
|
241
243
|
password="${secure::api.password}"/>
|
|
242
244
|
```
|
|
243
245
|
|
|
@@ -258,8 +260,8 @@ Use MuleSoft Secure Properties:
|
|
|
258
260
|
```yaml
|
|
259
261
|
# secure.yaml (encrypted)
|
|
260
262
|
api:
|
|
261
|
-
password:
|
|
262
|
-
clientSecret:
|
|
263
|
+
password: '![encryptedValue]'
|
|
264
|
+
clientSecret: '![encryptedValue]'
|
|
263
265
|
```
|
|
264
266
|
|
|
265
267
|
### TLS Configuration
|
|
@@ -272,7 +274,7 @@ api:
|
|
|
272
274
|
|
|
273
275
|
<!-- ✅ Good - Proper certificate validation -->
|
|
274
276
|
<tls:context name="Secure_TLS">
|
|
275
|
-
<tls:trust-store path="${tls.truststore.path}"
|
|
277
|
+
<tls:trust-store path="${tls.truststore.path}"
|
|
276
278
|
password="${secure::tls.truststore.password}"/>
|
|
277
279
|
</tls:context>
|
|
278
280
|
```
|
|
@@ -301,7 +303,7 @@ Async scopes don't propagate errors to parent flows:
|
|
|
301
303
|
<http:request config-ref="HTTP_Config" path="/webhook"/>
|
|
302
304
|
<error-handler>
|
|
303
305
|
<on-error-continue>
|
|
304
|
-
<logger category="com.myorg.async" level="ERROR"
|
|
306
|
+
<logger category="com.myorg.async" level="ERROR"
|
|
305
307
|
message="#['Async failed: ' ++ error.description]"/>
|
|
306
308
|
</on-error-continue>
|
|
307
309
|
</error-handler>
|
|
@@ -340,9 +342,9 @@ handlers[vars.status] default "default-handler-subflow"
|
|
|
340
342
|
|
|
341
343
|
```xml
|
|
342
344
|
<!-- ✅ Always set explicit timeouts -->
|
|
343
|
-
<http:request-config name="HTTP_Request_Config"
|
|
345
|
+
<http:request-config name="HTTP_Request_Config"
|
|
344
346
|
responseTimeout="30000">
|
|
345
|
-
<http:request-connection host="${api.host}"
|
|
347
|
+
<http:request-connection host="${api.host}"
|
|
346
348
|
port="${api.port}"/>
|
|
347
349
|
</http:request-config>
|
|
348
350
|
```
|
|
@@ -395,12 +397,12 @@ my-mule-project/
|
|
|
395
397
|
|
|
396
398
|
### File Organization Guidelines
|
|
397
399
|
|
|
398
|
-
| Guideline
|
|
399
|
-
|
|
400
|
-
| Flows per file
|
|
401
|
-
| File responsibility | One domain/feature per file
|
|
402
|
-
| Global configs
|
|
403
|
-
| Error handling
|
|
400
|
+
| Guideline | Recommendation |
|
|
401
|
+
| ------------------- | ----------------------------------- |
|
|
402
|
+
| Flows per file | Max 10 flows/sub-flows per XML file |
|
|
403
|
+
| File responsibility | One domain/feature per file |
|
|
404
|
+
| Global configs | Centralize in `global.xml` |
|
|
405
|
+
| Error handling | Separate `global-error-handler.xml` |
|
|
404
406
|
|
|
405
407
|
**Related Rules:** `MULE-802`, `MULE-803`, `MULE-804`
|
|
406
408
|
|
|
@@ -449,17 +451,17 @@ Create separate files for each environment:
|
|
|
449
451
|
```yaml
|
|
450
452
|
# dev.yaml
|
|
451
453
|
http:
|
|
452
|
-
host:
|
|
453
|
-
port:
|
|
454
|
+
host: '0.0.0.0'
|
|
455
|
+
port: '8081'
|
|
454
456
|
|
|
455
457
|
api:
|
|
456
458
|
orders:
|
|
457
|
-
baseUrl:
|
|
458
|
-
timeout:
|
|
459
|
+
baseUrl: 'http://localhost:8082/api'
|
|
460
|
+
timeout: '30000'
|
|
459
461
|
|
|
460
462
|
db:
|
|
461
|
-
host:
|
|
462
|
-
port:
|
|
463
|
+
host: 'localhost'
|
|
464
|
+
port: '5432'
|
|
463
465
|
```
|
|
464
466
|
|
|
465
467
|
### Property Naming
|
|
@@ -508,10 +510,10 @@ Write maintainable and reusable DataWeave code.
|
|
|
508
510
|
// src/main/resources/dwl/common.dwl
|
|
509
511
|
%dw 2.0
|
|
510
512
|
|
|
511
|
-
fun formatDate(date: DateTime) =
|
|
513
|
+
fun formatDate(date: DateTime) =
|
|
512
514
|
date as String {format: "yyyy-MM-dd"}
|
|
513
515
|
|
|
514
|
-
fun maskPII(value: String) =
|
|
516
|
+
fun maskPII(value: String) =
|
|
515
517
|
value[0 to 2] ++ "****" ++ value[-2 to -1]
|
|
516
518
|
|
|
517
519
|
fun toErrorResponse(error, correlationId: String) = {
|
|
@@ -525,6 +527,7 @@ fun toErrorResponse(error, correlationId: String) = {
|
|
|
525
527
|
### File Naming
|
|
526
528
|
|
|
527
529
|
Use kebab-case for DWL files:
|
|
530
|
+
|
|
528
531
|
- `transform-order.dwl`
|
|
529
532
|
- `validate-input.dwl`
|
|
530
533
|
- `common-utils.dwl`
|
|
@@ -540,16 +543,16 @@ Document for maintainability.
|
|
|
540
543
|
### Flow Documentation
|
|
541
544
|
|
|
542
545
|
```xml
|
|
543
|
-
<flow name="orders-api-create-order-flow"
|
|
544
|
-
doc:name="Create Order"
|
|
546
|
+
<flow name="orders-api-create-order-flow"
|
|
547
|
+
doc:name="Create Order"
|
|
545
548
|
doc:description="Creates a new order in the system. Validates input, checks inventory, and persists to database.">
|
|
546
549
|
```
|
|
547
550
|
|
|
548
551
|
### Component Documentation
|
|
549
552
|
|
|
550
553
|
```xml
|
|
551
|
-
<logger doc:name="Log Order Received"
|
|
552
|
-
category="com.myorg.orders"
|
|
554
|
+
<logger doc:name="Log Order Received"
|
|
555
|
+
category="com.myorg.orders"
|
|
553
556
|
message="#['Order received: ' ++ payload.orderId]"/>
|
|
554
557
|
|
|
555
558
|
<ee:transform doc:name="Transform to Database Format">
|
|
@@ -563,16 +566,16 @@ Document for maintainability.
|
|
|
563
566
|
|
|
564
567
|
## Quick Reference Card
|
|
565
568
|
|
|
566
|
-
| Practice
|
|
567
|
-
|
|
568
|
-
| **Error Handling** | Use global handler, set httpStatus
|
|
569
|
-
| **Logging**
|
|
570
|
-
| **Security**
|
|
571
|
-
| **Performance**
|
|
572
|
-
| **Naming**
|
|
573
|
-
| **Structure**
|
|
574
|
-
| **Config**
|
|
575
|
-
| **DataWeave**
|
|
569
|
+
| Practice | Do | Don't |
|
|
570
|
+
| ------------------ | ------------------------------------- | ------------------------------------- |
|
|
571
|
+
| **Error Handling** | Use global handler, set httpStatus | Catch `type="ANY"`, ignore errors |
|
|
572
|
+
| **Logging** | Use categories, log specific fields | Log `#[payload]`, log in retry loops |
|
|
573
|
+
| **Security** | Use `${property}`, encrypt secrets | Hardcode URLs, passwords, keys |
|
|
574
|
+
| **Performance** | Set timeouts, handle async errors | Unlimited retries, huge choice blocks |
|
|
575
|
+
| **Naming** | kebab-case flows, camelCase vars | Inconsistent casing, no suffixes |
|
|
576
|
+
| **Structure** | Separate files by domain | Monolithic XML files |
|
|
577
|
+
| **Config** | Environment-specific YAML files | Hardcoded values |
|
|
578
|
+
| **DataWeave** | External .dwl files, reusable modules | Large inline transforms |
|
|
576
579
|
|
|
577
580
|
---
|
|
578
581
|
|
|
@@ -588,11 +591,11 @@ MUnit is MuleSoft's native testing framework. Comprehensive testing is essential
|
|
|
588
591
|
|
|
589
592
|
### Test Coverage Goals
|
|
590
593
|
|
|
591
|
-
| Test Type
|
|
592
|
-
|
|
593
|
-
| Unit Tests
|
|
594
|
-
| Integration Tests
|
|
595
|
-
| Error Scenario Tests | All error handlers | Validate error responses
|
|
594
|
+
| Test Type | Coverage Target | Purpose |
|
|
595
|
+
| -------------------- | ------------------ | ------------------------------ |
|
|
596
|
+
| Unit Tests | 80%+ flow coverage | Validate individual flow logic |
|
|
597
|
+
| Integration Tests | All critical paths | Validate end-to-end scenarios |
|
|
598
|
+
| Error Scenario Tests | All error handlers | Validate error responses |
|
|
596
599
|
|
|
597
600
|
### MUnit Best Practices
|
|
598
601
|
|
|
@@ -600,12 +603,12 @@ MUnit is MuleSoft's native testing framework. Comprehensive testing is essential
|
|
|
600
603
|
<!-- test/munit/orders-api-test-suite.xml -->
|
|
601
604
|
<munit:test name="create-order-success-test"
|
|
602
605
|
description="Validates successful order creation">
|
|
603
|
-
|
|
606
|
+
|
|
604
607
|
<!-- Mock external dependencies -->
|
|
605
608
|
<munit:behavior>
|
|
606
609
|
<munit-tools:mock-when processor="http:request">
|
|
607
610
|
<munit-tools:with-attributes>
|
|
608
|
-
<munit-tools:with-attribute attributeName="config-ref"
|
|
611
|
+
<munit-tools:with-attribute attributeName="config-ref"
|
|
609
612
|
whereValue="Orders_HTTP_Config"/>
|
|
610
613
|
</munit-tools:with-attributes>
|
|
611
614
|
<munit-tools:then-return>
|
|
@@ -613,15 +616,15 @@ MUnit is MuleSoft's native testing framework. Comprehensive testing is essential
|
|
|
613
616
|
</munit-tools:then-return>
|
|
614
617
|
</munit-tools:mock-when>
|
|
615
618
|
</munit:behavior>
|
|
616
|
-
|
|
619
|
+
|
|
617
620
|
<!-- Execute -->
|
|
618
621
|
<munit:execution>
|
|
619
622
|
<flow-ref name="create-order-flow"/>
|
|
620
623
|
</munit:execution>
|
|
621
|
-
|
|
624
|
+
|
|
622
625
|
<!-- Assert -->
|
|
623
626
|
<munit:validation>
|
|
624
|
-
<munit-tools:assert-that expression="#[payload.orderId]"
|
|
627
|
+
<munit-tools:assert-that expression="#[payload.orderId]"
|
|
625
628
|
is="#[MunitTools::notNullValue()]"/>
|
|
626
629
|
</munit:validation>
|
|
627
630
|
</munit:test>
|
|
@@ -678,28 +681,28 @@ jobs:
|
|
|
678
681
|
runs-on: ubuntu-latest
|
|
679
682
|
steps:
|
|
680
683
|
- uses: actions/checkout@v4
|
|
681
|
-
|
|
684
|
+
|
|
682
685
|
- name: Set up JDK 11
|
|
683
686
|
uses: actions/setup-java@v3
|
|
684
687
|
with:
|
|
685
688
|
java-version: '11'
|
|
686
689
|
distribution: 'adopt'
|
|
687
|
-
|
|
690
|
+
|
|
688
691
|
- name: Cache Maven packages
|
|
689
692
|
uses: actions/cache@v3
|
|
690
693
|
with:
|
|
691
694
|
path: ~/.m2
|
|
692
695
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
|
693
|
-
|
|
696
|
+
|
|
694
697
|
- name: Build with Maven
|
|
695
698
|
run: mvn -B clean compile
|
|
696
|
-
|
|
699
|
+
|
|
697
700
|
- name: Run mule-lint
|
|
698
701
|
run: npx @sfdxy/mule-lint ./src/main/mule -f sarif -o lint-results.sarif
|
|
699
|
-
|
|
702
|
+
|
|
700
703
|
- name: Run MUnit tests
|
|
701
704
|
run: mvn -B test
|
|
702
|
-
|
|
705
|
+
|
|
703
706
|
- name: Upload SARIF results
|
|
704
707
|
uses: github/codeql-action/upload-sarif@v2
|
|
705
708
|
with:
|
|
@@ -708,12 +711,12 @@ jobs:
|
|
|
708
711
|
|
|
709
712
|
### Git Branch Strategy
|
|
710
713
|
|
|
711
|
-
| Branch
|
|
712
|
-
|
|
713
|
-
| `main`
|
|
714
|
-
| `develop`
|
|
715
|
-
| `feature/*` | New features
|
|
716
|
-
| `hotfix/*`
|
|
714
|
+
| Branch | Purpose | Deployment Target |
|
|
715
|
+
| ----------- | --------------------- | ----------------- |
|
|
716
|
+
| `main` | Production-ready code | Production |
|
|
717
|
+
| `develop` | Integration branch | QA/Staging |
|
|
718
|
+
| `feature/*` | New features | Development |
|
|
719
|
+
| `hotfix/*` | Production fixes | Production |
|
|
717
720
|
|
|
718
721
|
---
|
|
719
722
|
|
|
@@ -776,14 +779,14 @@ Development → QA → Staging → Production
|
|
|
776
779
|
|
|
777
780
|
### Deployment Checklist
|
|
778
781
|
|
|
779
|
-
| Item
|
|
780
|
-
|
|
781
|
-
| ✅ All tests pass
|
|
782
|
-
| ✅ Lint checks pass
|
|
783
|
-
| ✅ Properties configured | Environment YAML verified
|
|
784
|
-
| ✅ Secrets encrypted
|
|
785
|
-
| ✅ API Manager policies
|
|
786
|
-
| ✅ Monitoring configured | Dashboards and alerts ready
|
|
782
|
+
| Item | Description |
|
|
783
|
+
| ------------------------ | ----------------------------- |
|
|
784
|
+
| ✅ All tests pass | MUnit and integration tests |
|
|
785
|
+
| ✅ Lint checks pass | No errors from mule-lint |
|
|
786
|
+
| ✅ Properties configured | Environment YAML verified |
|
|
787
|
+
| ✅ Secrets encrypted | No plaintext credentials |
|
|
788
|
+
| ✅ API Manager policies | Authentication, rate limiting |
|
|
789
|
+
| ✅ Monitoring configured | Dashboards and alerts ready |
|
|
787
790
|
|
|
788
791
|
### Blue-Green Deployment
|
|
789
792
|
|
|
@@ -814,11 +817,11 @@ Production applications need comprehensive monitoring.
|
|
|
814
817
|
|
|
815
818
|
### The Three Pillars
|
|
816
819
|
|
|
817
|
-
| Pillar
|
|
818
|
-
|
|
819
|
-
| **Logs**
|
|
820
|
-
| **Metrics** | Anypoint Monitoring, Grafana
|
|
821
|
-
| **Traces**
|
|
820
|
+
| Pillar | Tool | Purpose |
|
|
821
|
+
| ----------- | -------------------------------- | ------------------------------ |
|
|
822
|
+
| **Logs** | Anypoint Monitoring, Splunk, ELK | Debug issues, audit trail |
|
|
823
|
+
| **Metrics** | Anypoint Monitoring, Grafana | Performance, health status |
|
|
824
|
+
| **Traces** | Anypoint Monitoring, Jaeger | Request flow, latency analysis |
|
|
822
825
|
|
|
823
826
|
### Key Metrics to Monitor
|
|
824
827
|
|
|
@@ -839,11 +842,11 @@ Business Metrics:
|
|
|
839
842
|
|
|
840
843
|
### Alerting Best Practices
|
|
841
844
|
|
|
842
|
-
| Alert Level
|
|
843
|
-
|
|
844
|
-
| **Critical** | Error rate > 10%, App down
|
|
845
|
-
| **Warning**
|
|
846
|
-
| **Info**
|
|
845
|
+
| Alert Level | Condition | Response |
|
|
846
|
+
| ------------ | -------------------------------- | -------------------------- |
|
|
847
|
+
| **Critical** | Error rate > 10%, App down | Immediate on-call response |
|
|
848
|
+
| **Warning** | Error rate > 5%, Latency > 5s | Investigate within 1 hour |
|
|
849
|
+
| **Info** | Unusual patterns, Resource > 70% | Review in daily standup |
|
|
847
850
|
|
|
848
851
|
### Correlation ID Pattern
|
|
849
852
|
|
|
@@ -851,7 +854,7 @@ Ensure correlation IDs flow through all systems:
|
|
|
851
854
|
|
|
852
855
|
```xml
|
|
853
856
|
<!-- Set correlation ID at entry point -->
|
|
854
|
-
<set-variable variableName="correlationId"
|
|
857
|
+
<set-variable variableName="correlationId"
|
|
855
858
|
value="#[correlationId default uuid()]"/>
|
|
856
859
|
|
|
857
860
|
<!-- Include in all outbound requests -->
|
|
@@ -862,7 +865,7 @@ Ensure correlation IDs flow through all systems:
|
|
|
862
865
|
</http:request>
|
|
863
866
|
|
|
864
867
|
<!-- Include in all log messages -->
|
|
865
|
-
<logger category="com.myorg"
|
|
868
|
+
<logger category="com.myorg"
|
|
866
869
|
message="#['[' ++ vars.correlationId ++ '] Processing request...']"/>
|
|
867
870
|
```
|
|
868
871
|
|
|
@@ -891,12 +894,11 @@ output application/json
|
|
|
891
894
|
|
|
892
895
|
This guide covers both linter-enforced practices and general developer guidelines:
|
|
893
896
|
|
|
894
|
-
| Category
|
|
895
|
-
|
|
896
|
-
| Code Quality | ✅ Naming, Structure, Complexity | Testing, Code Review
|
|
897
|
-
| Security
|
|
898
|
-
| Operations
|
|
899
|
-
| Architecture | ✅ API-Led patterns
|
|
897
|
+
| Category | Linter Enforced | General Guidelines |
|
|
898
|
+
| ------------ | -------------------------------- | ----------------------------- |
|
|
899
|
+
| Code Quality | ✅ Naming, Structure, Complexity | Testing, Code Review |
|
|
900
|
+
| Security | ✅ Hardcoded secrets, TLS | Secrets Management, IAM |
|
|
901
|
+
| Operations | ✅ Error handling, Logging | CI/CD, Monitoring, Deployment |
|
|
902
|
+
| Architecture | ✅ API-Led patterns | Versioning, Documentation |
|
|
900
903
|
|
|
901
904
|
For linter rule details, see the [Rules Catalog](rules-catalog.md).
|
|
902
|
-
|