@sfdxy/mule-lint 1.20.0 → 1.22.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 +63 -17
- package/dist/package.json +1 -1
- package/dist/src/core/XPathHelper.d.ts.map +1 -1
- package/dist/src/core/XPathHelper.js +8 -0
- package/dist/src/core/XPathHelper.js.map +1 -1
- package/dist/src/engine/LintEngine.d.ts +22 -0
- package/dist/src/engine/LintEngine.d.ts.map +1 -1
- package/dist/src/engine/LintEngine.js +105 -18
- package/dist/src/engine/LintEngine.js.map +1 -1
- package/dist/src/mcp/prompts/index.d.ts +1 -1
- package/dist/src/mcp/prompts/index.d.ts.map +1 -1
- package/dist/src/mcp/prompts/index.js +62 -1
- package/dist/src/mcp/prompts/index.js.map +1 -1
- package/dist/src/mcp/resources/index.js +114 -16
- package/dist/src/mcp/resources/index.js.map +1 -1
- package/dist/src/mcp/tools/getRuleDetails.d.ts.map +1 -1
- package/dist/src/mcp/tools/getRuleDetails.js +30 -1
- package/dist/src/mcp/tools/getRuleDetails.js.map +1 -1
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.d.ts +22 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.js +43 -0
- package/dist/src/rules/api-led/ApikitConsoleProductionRule.js.map +1 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.d.ts +24 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.js +53 -0
- package/dist/src/rules/api-led/ApikitMainFlowStructureRule.js.map +1 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.d.ts +25 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.d.ts.map +1 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.js +59 -0
- package/dist/src/rules/api-led/ApikitStatusCodeVariableRule.js.map +1 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.d.ts +24 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.d.ts.map +1 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.js +58 -0
- package/dist/src/rules/connector/EventListenerNullGuardRule.js.map +1 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.d.ts +23 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.d.ts.map +1 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.js +52 -0
- package/dist/src/rules/connector/ReplayChannelConfigRule.js.map +1 -0
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts +11 -4
- package/dist/src/rules/dataweave/DataWeaveRules.d.ts.map +1 -1
- package/dist/src/rules/dataweave/DataWeaveRules.js +20 -20
- package/dist/src/rules/dataweave/DataWeaveRules.js.map +1 -1
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.d.ts +25 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.d.ts.map +1 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.js +63 -0
- package/dist/src/rules/dataweave/DuplicateTransformLogicRule.js.map +1 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.d.ts +24 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.js +65 -0
- package/dist/src/rules/error-handling/CatchAllLastRule.js.map +1 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.d.ts +28 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.js +70 -0
- package/dist/src/rules/error-handling/ErrorHandlerTypeCoverageRule.js.map +1 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.d.ts +23 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.d.ts.map +1 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.js +73 -0
- package/dist/src/rules/error-handling/ErrorResponseStructureRule.js.map +1 -0
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts +15 -3
- package/dist/src/rules/error-handling/GenericErrorRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GenericErrorRule.js +58 -18
- package/dist/src/rules/error-handling/GenericErrorRule.js.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts +14 -15
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js +59 -38
- package/dist/src/rules/error-handling/GlobalErrorHandlerRule.js.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.d.ts +5 -0
- package/dist/src/rules/error-handling/TryScopeRule.d.ts.map +1 -1
- package/dist/src/rules/error-handling/TryScopeRule.js +30 -7
- package/dist/src/rules/error-handling/TryScopeRule.js.map +1 -1
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.d.ts +27 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.d.ts.map +1 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.js +46 -0
- package/dist/src/rules/http/ConnectionIdleTimeoutRule.js.map +1 -0
- package/dist/src/rules/index.d.ts +1 -1
- package/dist/src/rules/index.d.ts.map +1 -1
- package/dist/src/rules/index.js +50 -8
- package/dist/src/rules/index.js.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts +15 -0
- package/dist/src/rules/logging/LoggerPayloadRule.d.ts.map +1 -1
- package/dist/src/rules/logging/LoggerPayloadRule.js +48 -4
- package/dist/src/rules/logging/LoggerPayloadRule.js.map +1 -1
- package/dist/src/rules/operations/FlowRefTargetExistsRule.d.ts +23 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.d.ts.map +1 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.js +58 -0
- package/dist/src/rules/operations/FlowRefTargetExistsRule.js.map +1 -0
- package/dist/src/rules/operations/UnusedFlowRule.d.ts +20 -0
- package/dist/src/rules/operations/UnusedFlowRule.d.ts.map +1 -1
- package/dist/src/rules/operations/UnusedFlowRule.js +73 -7
- package/dist/src/rules/operations/UnusedFlowRule.js.map +1 -1
- package/dist/src/rules/operations/UnusedVariableRule.d.ts +31 -0
- package/dist/src/rules/operations/UnusedVariableRule.d.ts.map +1 -0
- package/dist/src/rules/operations/UnusedVariableRule.js +103 -0
- package/dist/src/rules/operations/UnusedVariableRule.js.map +1 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.d.ts +28 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.d.ts.map +1 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.js +56 -0
- package/dist/src/rules/performance/ListenerReconnectForeverRule.js.map +1 -0
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts +7 -4
- package/dist/src/rules/performance/ReconnectionStrategyRule.d.ts.map +1 -1
- package/dist/src/rules/performance/ReconnectionStrategyRule.js +44 -24
- package/dist/src/rules/performance/ReconnectionStrategyRule.js.map +1 -1
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.d.ts +36 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.d.ts.map +1 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.js +124 -0
- package/dist/src/rules/security/ConnectorCredentialsSecuredRule.js.map +1 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts +4 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.d.ts.map +1 -1
- package/dist/src/rules/security/HardcodedCredentialsRule.js +15 -0
- package/dist/src/rules/security/HardcodedCredentialsRule.js.map +1 -1
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.d.ts +25 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.d.ts.map +1 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.js +59 -0
- package/dist/src/rules/security/SecurePropertiesEncryptionRule.js.map +1 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.d.ts +23 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.d.ts.map +1 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.js +45 -0
- package/dist/src/rules/security/SecurePropertiesKeyRule.js.map +1 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.d.ts +25 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.d.ts.map +1 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.js +63 -0
- package/dist/src/rules/security/TlsKeystorePasswordRule.js.map +1 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.d.ts +26 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.js +61 -0
- package/dist/src/rules/standards/ApikitRouteVariableConsistencyRule.js.map +1 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.d.ts +34 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.d.ts.map +1 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.js +76 -0
- package/dist/src/rules/standards/ConfigPropertiesOrderingRule.js.map +1 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.d.ts +25 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.d.ts.map +1 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.js +111 -0
- package/dist/src/rules/standards/MissingEnvPropertiesDeclarationRule.js.map +1 -0
- package/dist/src/rules/yaml/YamlRules.d.ts +6 -2
- package/dist/src/rules/yaml/YamlRules.d.ts.map +1 -1
- package/dist/src/rules/yaml/YamlRules.js +15 -11
- package/dist/src/rules/yaml/YamlRules.js.map +1 -1
- package/dist/src/types/Rule.d.ts +13 -0
- package/dist/src/types/Rule.d.ts.map +1 -1
- package/docs/README.md +87 -27
- package/docs/best-practices/ci-cd.md +135 -0
- package/docs/best-practices/connector-patterns.md +253 -0
- package/docs/best-practices/dataweave-patterns.md +370 -0
- package/docs/best-practices/deployment-2026.md +171 -0
- package/docs/best-practices/error-handling.md +277 -0
- package/docs/best-practices/event-driven-patterns.md +424 -0
- package/docs/best-practices/logging.md +163 -0
- package/docs/best-practices/mulesoft-best-practices.md +72 -865
- package/docs/best-practices/performance.md +273 -0
- package/docs/best-practices/rules-catalog.md +337 -29
- package/docs/best-practices/security.md +181 -0
- package/docs/best-practices/testing.md +190 -0
- package/docs/best-practices/variable-contracts.md +191 -0
- package/docs/linter/architecture.md +119 -64
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EventListenerNullGuardRule.js","sourceRoot":"","sources":["../../../../src/rules/connector/EventListenerNullGuardRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;;GAWG;AACH,MAAa,0BAA2B,SAAQ,mBAAQ;IACtD,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,2BAA2B,CAAC;IACnC,WAAW,GACT,oGAAoG,CAAC;IACvG,QAAQ,GAAG,MAAe,CAAC;IAC3B,QAAQ,GAAG,YAAqB,CAAC;IACjC,SAAS,GAAc,KAAK,CAAC;IAE7B,QAAQ,CAAC,GAAa,EAAE,QAA2B;QACjD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;QAE9C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;YAEvD,2EAA2E;YAC3E,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAC/B,0IAA0I,EAC1I,IAAI,CACL,CAAC;YAEF,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,SAAS;YACX,CAAC;YAED,yCAAyC;YACzC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,gCAAgC,EAAE,IAAI,CAAC,CAAC;YAEvE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,MAAM,aAAa,GAAG,SAAS,CAAC,WAAW,IAAI,EAAE,CAAC;gBAElD,8EAA8E;gBAC9E,yDAAyD;gBACzD,MAAM,eAAe,GAAG,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAC3D,MAAM,aAAa,GACjB,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC;oBACpC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC;oBAC/B,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;oBAC7B,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC;oBAC7B,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC;oBAC5B,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;gBAE1C,IAAI,eAAe,IAAI,CAAC,aAAa,EAAE,CAAC;oBACtC,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,WAAW,CACd,SAAS,EACT,0CAA0C,QAAQ,sDAAsD,EACxG;wBACE,UAAU,EACR,sJAAsJ;qBACzJ,CACF,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA7DD,gEA6DC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* SF-001: Salesforce Replay Channel Config
|
|
5
|
+
*
|
|
6
|
+
* Salesforce CDC (Change Data Capture) and Platform Event listeners should
|
|
7
|
+
* configure replay channel settings for message reliability. Without proper
|
|
8
|
+
* replay configuration, events can be lost if the application is restarted
|
|
9
|
+
* or temporarily disconnected.
|
|
10
|
+
*
|
|
11
|
+
* Looks for salesforce:replay-channel or similar replay configurations
|
|
12
|
+
* on Salesforce subscriber/listener elements.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ReplayChannelConfigRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "warning";
|
|
19
|
+
category: "operations";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ReplayChannelConfigRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayChannelConfigRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/connector/ReplayChannelConfigRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,uBAAwB,SAAQ,QAAQ;IACnD,EAAE,SAAY;IACd,IAAI,SAAsC;IAC1C,WAAW,SACiF;IAC5F,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,YAAY,CAAU;IACjC,SAAS,EAAE,SAAS,CAAS;IAE7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAmD9D"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReplayChannelConfigRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* SF-001: Salesforce Replay Channel Config
|
|
7
|
+
*
|
|
8
|
+
* Salesforce CDC (Change Data Capture) and Platform Event listeners should
|
|
9
|
+
* configure replay channel settings for message reliability. Without proper
|
|
10
|
+
* replay configuration, events can be lost if the application is restarted
|
|
11
|
+
* or temporarily disconnected.
|
|
12
|
+
*
|
|
13
|
+
* Looks for salesforce:replay-channel or similar replay configurations
|
|
14
|
+
* on Salesforce subscriber/listener elements.
|
|
15
|
+
*/
|
|
16
|
+
class ReplayChannelConfigRule extends BaseRule_1.BaseRule {
|
|
17
|
+
id = 'SF-001';
|
|
18
|
+
name = 'Salesforce Replay Channel Config';
|
|
19
|
+
description = 'Salesforce CDC/Platform Event listeners should configure replay channel for reliability';
|
|
20
|
+
severity = 'warning';
|
|
21
|
+
category = 'operations';
|
|
22
|
+
issueType = 'bug';
|
|
23
|
+
validate(doc, _context) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
// Find Salesforce subscribe elements (CDC/Platform Events)
|
|
26
|
+
const subscribers = [
|
|
27
|
+
...this.select('//*[local-name()="subscribe-channel" or local-name()="subscribe-topic"]', doc),
|
|
28
|
+
...this.select('//*[local-name()="replay-channel" or local-name()="replay-topic"]', doc),
|
|
29
|
+
];
|
|
30
|
+
// If we find replay-channel/replay-topic, that means replay IS configured — good
|
|
31
|
+
const hasReplayConfig = this.exists('//*[local-name()="replay-channel" or local-name()="replay-topic"]', doc);
|
|
32
|
+
// Find plain subscribe elements without replay
|
|
33
|
+
const plainSubscribers = this.select('//*[local-name()="subscribe-channel" or local-name()="subscribe-topic"]', doc);
|
|
34
|
+
if (plainSubscribers.length > 0 && !hasReplayConfig) {
|
|
35
|
+
for (const sub of plainSubscribers) {
|
|
36
|
+
const streamingChannel = this.getAttribute(sub, 'streamingChannel') ??
|
|
37
|
+
this.getAttribute(sub, 'channel') ??
|
|
38
|
+
'unknown';
|
|
39
|
+
issues.push(this.createIssue(sub, `Salesforce subscriber for "${streamingChannel}" has no replay channel configuration`, {
|
|
40
|
+
suggestion: 'Use salesforce:replay-channel instead of subscribe-channel, or configure Object Store-backed replay for CDC/Platform Event reliability',
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
// Also check for replay-channel that might be missing resumeFromLastReplay
|
|
45
|
+
if (subscribers.length === 0) {
|
|
46
|
+
return issues; // No Salesforce streaming elements in this file
|
|
47
|
+
}
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.ReplayChannelConfigRule = ReplayChannelConfigRule;
|
|
52
|
+
//# sourceMappingURL=ReplayChannelConfigRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplayChannelConfigRule.js","sourceRoot":"","sources":["../../../../src/rules/connector/ReplayChannelConfigRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;GAUG;AACH,MAAa,uBAAwB,SAAQ,mBAAQ;IACnD,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,kCAAkC,CAAC;IAC1C,WAAW,GACT,yFAAyF,CAAC;IAC5F,QAAQ,GAAG,SAAkB,CAAC;IAC9B,QAAQ,GAAG,YAAqB,CAAC;IACjC,SAAS,GAAc,KAAK,CAAC;IAE7B,QAAQ,CAAC,GAAa,EAAE,QAA2B;QACjD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,2DAA2D;QAC3D,MAAM,WAAW,GAAG;YAClB,GAAG,IAAI,CAAC,MAAM,CACZ,yEAAyE,EACzE,GAAG,CACJ;YACD,GAAG,IAAI,CAAC,MAAM,CAAC,mEAAmE,EAAE,GAAG,CAAC;SACzF,CAAC;QAEF,iFAAiF;QACjF,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CACjC,mEAAmE,EACnE,GAAG,CACJ,CAAC;QAEF,+CAA+C;QAC/C,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAClC,yEAAyE,EACzE,GAAG,CACJ,CAAC;QAEF,IAAI,gBAAgB,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,eAAe,EAAE,CAAC;YACpD,KAAK,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;gBACnC,MAAM,gBAAgB,GACpB,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,kBAAkB,CAAC;oBAC1C,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,SAAS,CAAC;oBACjC,SAAS,CAAC;gBAEZ,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,WAAW,CACd,GAAG,EACH,8BAA8B,gBAAgB,uCAAuC,EACrF;oBACE,UAAU,EACR,wIAAwI;iBAC3I,CACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,2EAA2E;QAC3E,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,MAAM,CAAC,CAAC,gDAAgD;QACjE,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5DD,0DA4DC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ValidationContext, Issue } from '../../types';
|
|
2
2
|
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
import { ProjectRule } from '../base/ProjectRule';
|
|
3
4
|
/**
|
|
4
5
|
* DW-001: External DWL for Complex Transforms
|
|
5
6
|
*
|
|
@@ -24,14 +25,17 @@ export declare class ExternalDwlRule extends BaseRule {
|
|
|
24
25
|
* exactly match the filename, and hyphens are not valid in DataWeave identifiers.
|
|
25
26
|
* Use the `exemptPaths` option to exclude module directories from this rule, or
|
|
26
27
|
* set `convention: "camelCase"` for projects that use DW modules extensively.
|
|
28
|
+
*
|
|
29
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
30
|
+
* N identical issues (one per XML file).
|
|
27
31
|
*/
|
|
28
|
-
export declare class DwlNamingRule extends
|
|
32
|
+
export declare class DwlNamingRule extends ProjectRule {
|
|
29
33
|
id: string;
|
|
30
34
|
name: string;
|
|
31
35
|
description: string;
|
|
32
36
|
severity: "info";
|
|
33
37
|
category: "dataweave";
|
|
34
|
-
|
|
38
|
+
protected validateProject(context: ValidationContext): Issue[];
|
|
35
39
|
private isValidDwlName;
|
|
36
40
|
/**
|
|
37
41
|
* Convert a filename to the target convention
|
|
@@ -43,14 +47,17 @@ export declare class DwlNamingRule extends BaseRule {
|
|
|
43
47
|
* DW-003: DWL Modules Usage
|
|
44
48
|
*
|
|
45
49
|
* Common DataWeave functions should be in reusable modules.
|
|
50
|
+
*
|
|
51
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
52
|
+
* N identical issues (one per XML file).
|
|
46
53
|
*/
|
|
47
|
-
export declare class DwlModulesRule extends
|
|
54
|
+
export declare class DwlModulesRule extends ProjectRule {
|
|
48
55
|
id: string;
|
|
49
56
|
name: string;
|
|
50
57
|
description: string;
|
|
51
58
|
severity: "info";
|
|
52
59
|
category: "dataweave";
|
|
53
|
-
|
|
60
|
+
protected validateProject(context: ValidationContext): Issue[];
|
|
54
61
|
private hasFile;
|
|
55
62
|
}
|
|
56
63
|
//# sourceMappingURL=DataWeaveRules.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataWeaveRules.d.ts","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DataWeaveRules.d.ts","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;IAC3C,EAAE,SAAY;IACd,IAAI,SAAyC;IAC7C,WAAW,SAA4D;IACvE,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,WAAW,CAAU;IAEhC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CA+B7D;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,aAAc,SAAQ,WAAW;IAC5C,EAAE,SAAY;IACd,IAAI,SAAqB;IACzB,WAAW,SAC8E;IACzF,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAEhC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IA8C9D,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,YAAY;CAiBrB;AAED;;;;;;;GAOG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,EAAE,SAAY;IACd,IAAI,SAAiB;IACrB,WAAW,SAAkD;IAC7D,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAEhC,SAAS,CAAC,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAqB9D,OAAO,CAAC,OAAO;CAQhB"}
|
|
@@ -37,6 +37,7 @@ exports.DwlModulesRule = exports.DwlNamingRule = exports.ExternalDwlRule = void
|
|
|
37
37
|
const fs = __importStar(require("fs"));
|
|
38
38
|
const path = __importStar(require("path"));
|
|
39
39
|
const BaseRule_1 = require("../base/BaseRule");
|
|
40
|
+
const ProjectRule_1 = require("../base/ProjectRule");
|
|
40
41
|
/**
|
|
41
42
|
* DW-001: External DWL for Complex Transforms
|
|
42
43
|
*
|
|
@@ -81,14 +82,17 @@ exports.ExternalDwlRule = ExternalDwlRule;
|
|
|
81
82
|
* exactly match the filename, and hyphens are not valid in DataWeave identifiers.
|
|
82
83
|
* Use the `exemptPaths` option to exclude module directories from this rule, or
|
|
83
84
|
* set `convention: "camelCase"` for projects that use DW modules extensively.
|
|
85
|
+
*
|
|
86
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
87
|
+
* N identical issues (one per XML file).
|
|
84
88
|
*/
|
|
85
|
-
class DwlNamingRule extends
|
|
89
|
+
class DwlNamingRule extends ProjectRule_1.ProjectRule {
|
|
86
90
|
id = 'DW-002';
|
|
87
91
|
name = 'DWL File Naming';
|
|
88
92
|
description = 'DataWeave files should follow consistent naming conventions (kebab-case recommended)';
|
|
89
93
|
severity = 'info';
|
|
90
94
|
category = 'dataweave';
|
|
91
|
-
|
|
95
|
+
validateProject(context) {
|
|
92
96
|
const issues = [];
|
|
93
97
|
const dwlDir = path.join(context.projectRoot, 'src/main/resources/dwl');
|
|
94
98
|
if (!fs.existsSync(dwlDir)) {
|
|
@@ -115,13 +119,9 @@ class DwlNamingRule extends BaseRule_1.BaseRule {
|
|
|
115
119
|
}
|
|
116
120
|
if (!this.isValidDwlName(basename, convention)) {
|
|
117
121
|
const suggestedName = this.toConvention(basename, convention);
|
|
118
|
-
issues.push({
|
|
119
|
-
line: 1,
|
|
120
|
-
message: `DWL file "${basename}.dwl" should use ${convention} naming`,
|
|
121
|
-
ruleId: this.id,
|
|
122
|
-
severity: this.severity,
|
|
122
|
+
issues.push(this.createProjectIssue(`DWL file "${basename}.dwl" should use ${convention} naming`, {
|
|
123
123
|
suggestion: `Rename to: ${suggestedName}.dwl`,
|
|
124
|
-
});
|
|
124
|
+
}));
|
|
125
125
|
}
|
|
126
126
|
}
|
|
127
127
|
return issues;
|
|
@@ -176,31 +176,31 @@ exports.DwlNamingRule = DwlNamingRule;
|
|
|
176
176
|
* DW-003: DWL Modules Usage
|
|
177
177
|
*
|
|
178
178
|
* Common DataWeave functions should be in reusable modules.
|
|
179
|
+
*
|
|
180
|
+
* This is a ProjectRule — it runs once per scan to avoid producing
|
|
181
|
+
* N identical issues (one per XML file).
|
|
179
182
|
*/
|
|
180
|
-
class DwlModulesRule extends
|
|
183
|
+
class DwlModulesRule extends ProjectRule_1.ProjectRule {
|
|
181
184
|
id = 'DW-003';
|
|
182
185
|
name = 'DWL Modules';
|
|
183
186
|
description = 'Project should have common DataWeave modules';
|
|
184
187
|
severity = 'info';
|
|
185
188
|
category = 'dataweave';
|
|
186
|
-
|
|
187
|
-
const issues = [];
|
|
189
|
+
validateProject(context) {
|
|
188
190
|
const dwlDir = path.join(context.projectRoot, 'src/main/resources/dwl');
|
|
189
191
|
if (!fs.existsSync(dwlDir)) {
|
|
190
|
-
return
|
|
192
|
+
return [];
|
|
191
193
|
}
|
|
192
194
|
const hasCommonModule = this.hasFile(dwlDir, 'common');
|
|
193
195
|
const hasUtilsModule = this.hasFile(dwlDir, 'utils');
|
|
194
196
|
if (!hasCommonModule && !hasUtilsModule) {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
suggestion: 'Create common.dwl or utils.dwl for reusable functions',
|
|
201
|
-
});
|
|
197
|
+
return [
|
|
198
|
+
this.createProjectIssue('No common/utils DWL module found', {
|
|
199
|
+
suggestion: 'Create common.dwl or utils.dwl for reusable functions',
|
|
200
|
+
}),
|
|
201
|
+
];
|
|
202
202
|
}
|
|
203
|
-
return
|
|
203
|
+
return [];
|
|
204
204
|
}
|
|
205
205
|
hasFile(dir, pattern) {
|
|
206
206
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataWeaveRules.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA4C;
|
|
1
|
+
{"version":3,"file":"DataWeaveRules.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DataWeaveRules.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,+CAA4C;AAC5C,qDAAkD;AAElD;;;;GAIG;AACH,MAAa,eAAgB,SAAQ,mBAAQ;IAC3C,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,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AAC,CAAC;QACvD,MAAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAErD,IAAI,CAAC,eAAe,IAAI,CAAC,cAAc,EAAE,CAAC;YACxC,OAAO;gBACL,IAAI,CAAC,kBAAkB,CAAC,kCAAkC,EAAE;oBAC1D,UAAU,EAAE,uDAAuD;iBACpE,CAAC;aACH,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC;IAEO,OAAO,CAAC,GAAW,EAAE,OAAe;QAC1C,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;YAClC,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AApCD,wCAoCC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* DW-005: Duplicate Transform Logic
|
|
5
|
+
*
|
|
6
|
+
* Flags flows that contain multiple DataWeave transform-message blocks
|
|
7
|
+
* with identical or near-identical body content. Duplicated transforms
|
|
8
|
+
* should be extracted into reusable .dwl modules under src/main/resources/dw/.
|
|
9
|
+
*
|
|
10
|
+
* This rule checks for duplicate ee:transform → ee:message → ee:set-payload
|
|
11
|
+
* content within the same file. It compares the text content of set-payload
|
|
12
|
+
* elements and flags exact duplicates.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DuplicateTransformLogicRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "info";
|
|
19
|
+
category: "dataweave";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
/** Minimum length of transform content to consider for duplication check */
|
|
22
|
+
private readonly MIN_CONTENT_LENGTH;
|
|
23
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=DuplicateTransformLogicRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateTransformLogicRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/dataweave/DuplicateTransformLogicRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,2BAA4B,SAAQ,QAAQ;IACvD,EAAE,SAAY;IACd,IAAI,SAA+B;IACnC,WAAW,SAC6E;IACxF,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,WAAW,CAAU;IAChC,SAAS,EAAE,SAAS,CAAgB;IAEpC,4EAA4E;IAC5E,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAM;IAEzC,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;CA0D9D"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DuplicateTransformLogicRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* DW-005: Duplicate Transform Logic
|
|
7
|
+
*
|
|
8
|
+
* Flags flows that contain multiple DataWeave transform-message blocks
|
|
9
|
+
* with identical or near-identical body content. Duplicated transforms
|
|
10
|
+
* should be extracted into reusable .dwl modules under src/main/resources/dw/.
|
|
11
|
+
*
|
|
12
|
+
* This rule checks for duplicate ee:transform → ee:message → ee:set-payload
|
|
13
|
+
* content within the same file. It compares the text content of set-payload
|
|
14
|
+
* elements and flags exact duplicates.
|
|
15
|
+
*/
|
|
16
|
+
class DuplicateTransformLogicRule extends BaseRule_1.BaseRule {
|
|
17
|
+
id = 'DW-005';
|
|
18
|
+
name = 'Duplicate Transform Logic';
|
|
19
|
+
description = 'Duplicate DataWeave transform blocks should be extracted into reusable .dwl modules';
|
|
20
|
+
severity = 'info';
|
|
21
|
+
category = 'dataweave';
|
|
22
|
+
issueType = 'code-smell';
|
|
23
|
+
/** Minimum length of transform content to consider for duplication check */
|
|
24
|
+
MIN_CONTENT_LENGTH = 20;
|
|
25
|
+
validate(doc, _context) {
|
|
26
|
+
const issues = [];
|
|
27
|
+
// Find all ee:transform → ee:set-payload elements
|
|
28
|
+
const transforms = this.select('//*[local-name()="transform"]/*[local-name()="message"]/*[local-name()="set-payload"]', doc);
|
|
29
|
+
// Also check top-level set-payload in transforms without message wrapper
|
|
30
|
+
const directTransforms = this.select('//*[local-name()="transform"]/*[local-name()="set-payload"]', doc);
|
|
31
|
+
const allPayloads = [...transforms, ...directTransforms];
|
|
32
|
+
// Collect transform content for duplication detection
|
|
33
|
+
const contentMap = new Map();
|
|
34
|
+
for (const payload of allPayloads) {
|
|
35
|
+
const content = (payload.textContent ?? '').trim();
|
|
36
|
+
// Skip short/trivial transforms and resource references
|
|
37
|
+
if (content.length < this.MIN_CONTENT_LENGTH) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (content.startsWith('${') || content.includes('readUrl')) {
|
|
41
|
+
continue; // Already using externalized DWL
|
|
42
|
+
}
|
|
43
|
+
const normalized = content.replace(/\s+/g, ' ');
|
|
44
|
+
const nodes = contentMap.get(normalized) ?? [];
|
|
45
|
+
nodes.push(payload);
|
|
46
|
+
contentMap.set(normalized, nodes);
|
|
47
|
+
}
|
|
48
|
+
// Flag duplicates
|
|
49
|
+
for (const [, nodes] of contentMap) {
|
|
50
|
+
if (nodes.length > 1) {
|
|
51
|
+
// Only flag the second and subsequent occurrences
|
|
52
|
+
for (let i = 1; i < nodes.length; i++) {
|
|
53
|
+
issues.push(this.createIssue(nodes[i], `Duplicate DataWeave transform logic found (${nodes.length} identical blocks in file)`, {
|
|
54
|
+
suggestion: 'Extract the shared DataWeave logic into a reusable .dwl file under src/main/resources/dw/ and reference it with readUrl("classpath://dw/transform.dwl")',
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return issues;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.DuplicateTransformLogicRule = DuplicateTransformLogicRule;
|
|
63
|
+
//# sourceMappingURL=DuplicateTransformLogicRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DuplicateTransformLogicRule.js","sourceRoot":"","sources":["../../../../src/rules/dataweave/DuplicateTransformLogicRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;;GAUG;AACH,MAAa,2BAA4B,SAAQ,mBAAQ;IACvD,EAAE,GAAG,QAAQ,CAAC;IACd,IAAI,GAAG,2BAA2B,CAAC;IACnC,WAAW,GACT,qFAAqF,CAAC;IACxF,QAAQ,GAAG,MAAe,CAAC;IAC3B,QAAQ,GAAG,WAAoB,CAAC;IAChC,SAAS,GAAc,YAAY,CAAC;IAEpC,4EAA4E;IAC3D,kBAAkB,GAAG,EAAE,CAAC;IAEzC,QAAQ,CAAC,GAAa,EAAE,QAA2B;QACjD,MAAM,MAAM,GAAY,EAAE,CAAC;QAE3B,kDAAkD;QAClD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAC5B,uFAAuF,EACvF,GAAG,CACJ,CAAC;QAEF,yEAAyE;QACzE,MAAM,gBAAgB,GAAG,IAAI,CAAC,MAAM,CAClC,6DAA6D,EAC7D,GAAG,CACJ,CAAC;QAEF,MAAM,WAAW,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,gBA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AC;IAChB,CAAC;CACF;AAtED,kEAsEC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* ERR-004: Catch-All Must Be Last
|
|
5
|
+
*
|
|
6
|
+
* When type="ANY" (or no type attribute — implicit catch-all) is used in
|
|
7
|
+
* an error handler, it must be the last on-error block. Placing a catch-all
|
|
8
|
+
* before specific error types makes those specific handlers unreachable.
|
|
9
|
+
*
|
|
10
|
+
* Real-world pattern from accelerators: type="ANY" is always the final
|
|
11
|
+
* on-error-propagate, typically mapping to HTTP 500.
|
|
12
|
+
*/
|
|
13
|
+
export declare class CatchAllLastRule extends BaseRule {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
severity: "error";
|
|
18
|
+
category: "error-handling";
|
|
19
|
+
issueType: IssueType;
|
|
20
|
+
private readonly CATCH_ALL_TYPES;
|
|
21
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
22
|
+
private findParentFlowName;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=CatchAllLastRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatchAllLastRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/CatchAllLastRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;GASG;AACH,qBAAa,gBAAiB,SAAQ,QAAQ;IAC5C,EAAE,SAAa;IACf,IAAI,SAA4B;IAChC,WAAW,SAC8E;IACzF,QAAQ,EAAG,OAAO,CAAU;IAC5B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAE7B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAuB;IAEvD,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;IAkD7D,OAAO,CAAC,kBAAkB;CAU3B"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CatchAllLastRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* ERR-004: Catch-All Must Be Last
|
|
7
|
+
*
|
|
8
|
+
* When type="ANY" (or no type attribute — implicit catch-all) is used in
|
|
9
|
+
* an error handler, it must be the last on-error block. Placing a catch-all
|
|
10
|
+
* before specific error types makes those specific handlers unreachable.
|
|
11
|
+
*
|
|
12
|
+
* Real-world pattern from accelerators: type="ANY" is always the final
|
|
13
|
+
* on-error-propagate, typically mapping to HTTP 500.
|
|
14
|
+
*/
|
|
15
|
+
class CatchAllLastRule extends BaseRule_1.BaseRule {
|
|
16
|
+
id = 'ERR-004';
|
|
17
|
+
name = 'Catch-All Must Be Last';
|
|
18
|
+
description = 'type="ANY" or implicit catch-all must be the last on-error block in an error handler';
|
|
19
|
+
severity = 'error';
|
|
20
|
+
category = 'error-handling';
|
|
21
|
+
issueType = 'bug';
|
|
22
|
+
CATCH_ALL_TYPES = ['ANY', 'MULE:ANY'];
|
|
23
|
+
validate(doc, _context) {
|
|
24
|
+
const issues = [];
|
|
25
|
+
const errorHandlers = this.select('//mule:error-handler', doc);
|
|
26
|
+
for (const handler of errorHandlers) {
|
|
27
|
+
// Collect all on-error-* children in document order
|
|
28
|
+
const children = this.select('./*[local-name()="on-error-continue" or local-name()="on-error-propagate"]', handler);
|
|
29
|
+
if (children.length <= 1) {
|
|
30
|
+
continue; // Single handler — nothing to check
|
|
31
|
+
}
|
|
32
|
+
// Check each child except the last
|
|
33
|
+
for (let i = 0; i < children.length - 1; i++) {
|
|
34
|
+
const child = children[i];
|
|
35
|
+
const typeAttr = this.getAttribute(child, 'type');
|
|
36
|
+
const isCatchAll = typeAttr === null ||
|
|
37
|
+
typeAttr === undefined ||
|
|
38
|
+
typeAttr.trim() === '' ||
|
|
39
|
+
this.CATCH_ALL_TYPES.includes(typeAttr.trim().toUpperCase());
|
|
40
|
+
if (isCatchAll) {
|
|
41
|
+
const handlerName = this.getAttribute(handler, 'name') ?? this.findParentFlowName(handler) ?? 'unnamed';
|
|
42
|
+
const blockType = child.nodeName.includes('continue')
|
|
43
|
+
? 'on-error-continue'
|
|
44
|
+
: 'on-error-propagate';
|
|
45
|
+
issues.push(this.createIssue(child, `Catch-all ${blockType}${typeAttr ? ` (type="${typeAttr}")` : ''} is not the last handler in "${handlerName}" — subsequent handlers are unreachable`, {
|
|
46
|
+
suggestion: 'Move the catch-all (type="ANY") block to be the last on-error handler',
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return issues;
|
|
52
|
+
}
|
|
53
|
+
findParentFlowName(node) {
|
|
54
|
+
let current = node.parentNode;
|
|
55
|
+
while (current) {
|
|
56
|
+
if (current.nodeName === 'flow' || current.nodeName === 'mule:flow') {
|
|
57
|
+
return current.getAttribute('name');
|
|
58
|
+
}
|
|
59
|
+
current = current.parentNode;
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.CatchAllLastRule = CatchAllLastRule;
|
|
65
|
+
//# sourceMappingURL=CatchAllLastRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CatchAllLastRule.js","sourceRoot":"","sources":["../../../../src/rules/error-handling/CatchAllLastRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5C;;;;;;;;;GASG;AACH,MAAa,gBAAiB,SAAQ,mBAAQ;IAC5C,EAAE,GAAG,SAAS,CAAC;IACf,IAAI,GAAG,wB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I,SAAS,CAAC;oBACtF,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;wBACnD,CAAC,CAAC,mBAAmB;wBACrB,CAAC,CAAC,oBAAoB,CAAC;oBAEzB,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,WAAW,CACd,KAAK,EACL,aAAa,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC,WAAW,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE,gCAAgC,WAAW,yCAAyC,EACpJ;wBACE,UAAU,EAAE,uEAAuE;qBACpF,CACF,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,kBAAkB,CAAC,IAAU;QACnC,IAAI,OAAO,GAAgB,IAAI,CAAC,UAAU,CAAC;QAC3C,OAAO,OAAO,EAAE,CAAC;YACf,IAAI,OAAO,CAAC,QAAQ,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;gBACpE,OAAQ,OAAmB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,CAAC;YACD,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;QAC/B,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAvED,4CAuEC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* ERR-002: Error Handler Type Coverage
|
|
5
|
+
*
|
|
6
|
+
* SAPI error handlers should cover the standard APIKit error types
|
|
7
|
+
* (BAD_REQUEST, NOT_FOUND, METHOD_NOT_ALLOWED, NOT_ACCEPTABLE,
|
|
8
|
+
* UNSUPPORTED_MEDIA_TYPE) when an APIKit router is present.
|
|
9
|
+
*
|
|
10
|
+
* Inspired by real-world accelerator patterns where both Salesforce and
|
|
11
|
+
* NetSuite SAPIs consistently cover these types for proper HTTP status
|
|
12
|
+
* code mapping.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ErrorHandlerTypeCoverageRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "warning";
|
|
19
|
+
category: "error-handling";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
/**
|
|
22
|
+
* Minimum set of APIKit error types that a well-structured SAPI should handle.
|
|
23
|
+
* These correspond to standard HTTP status codes that APIKit can generate.
|
|
24
|
+
*/
|
|
25
|
+
private readonly REQUIRED_APIKIT_TYPES;
|
|
26
|
+
validate(doc: Document, context: ValidationContext): Issue[];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=ErrorHandlerTypeCoverageRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandlerTypeCoverageRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/ErrorHandlerTypeCoverageRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;;;;GAUG;AACH,qBAAa,4BAA6B,SAAQ,QAAQ;IACxD,EAAE,SAAa;IACf,IAAI,SAAiC;IACrC,WAAW,SAAgF;IAC3F,QAAQ,EAAG,SAAS,CAAU;IAC9B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAE7B;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAMpC;IAEF,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAkD7D"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorHandlerTypeCoverageRule = void 0;
|
|
4
|
+
const BaseRule_1 = require("../base/BaseRule");
|
|
5
|
+
/**
|
|
6
|
+
* ERR-002: Error Handler Type Coverage
|
|
7
|
+
*
|
|
8
|
+
* SAPI error handlers should cover the standard APIKit error types
|
|
9
|
+
* (BAD_REQUEST, NOT_FOUND, METHOD_NOT_ALLOWED, NOT_ACCEPTABLE,
|
|
10
|
+
* UNSUPPORTED_MEDIA_TYPE) when an APIKit router is present.
|
|
11
|
+
*
|
|
12
|
+
* Inspired by real-world accelerator patterns where both Salesforce and
|
|
13
|
+
* NetSuite SAPIs consistently cover these types for proper HTTP status
|
|
14
|
+
* code mapping.
|
|
15
|
+
*/
|
|
16
|
+
class ErrorHandlerTypeCoverageRule extends BaseRule_1.BaseRule {
|
|
17
|
+
id = 'ERR-002';
|
|
18
|
+
name = 'Error Handler Type Coverage';
|
|
19
|
+
description = 'Error handlers in APIKit projects should cover standard APIKit error types';
|
|
20
|
+
severity = 'warning';
|
|
21
|
+
category = 'error-handling';
|
|
22
|
+
issueType = 'bug';
|
|
23
|
+
/**
|
|
24
|
+
* Minimum set of APIKit error types that a well-structured SAPI should handle.
|
|
25
|
+
* These correspond to standard HTTP status codes that APIKit can generate.
|
|
26
|
+
*/
|
|
27
|
+
REQUIRED_APIKIT_TYPES = [
|
|
28
|
+
'APIKIT:BAD_REQUEST',
|
|
29
|
+
'APIKIT:NOT_FOUND',
|
|
30
|
+
'APIKIT:METHOD_NOT_ALLOWED',
|
|
31
|
+
'APIKIT:NOT_ACCEPTABLE',
|
|
32
|
+
'APIKIT:UNSUPPORTED_MEDIA_TYPE',
|
|
33
|
+
];
|
|
34
|
+
validate(doc, context) {
|
|
35
|
+
const issues = [];
|
|
36
|
+
// Only apply when project has an APIKit router
|
|
37
|
+
if (context.projectContext && !context.projectContext.hasApikitRouter) {
|
|
38
|
+
return issues;
|
|
39
|
+
}
|
|
40
|
+
// Find named (global) error handlers — these are the ones that should
|
|
41
|
+
// have comprehensive coverage
|
|
42
|
+
const errorHandlers = this.select('//mule:error-handler[@name]', doc);
|
|
43
|
+
for (const handler of errorHandlers) {
|
|
44
|
+
const handlerName = this.getAttribute(handler, 'name') ?? 'unnamed';
|
|
45
|
+
// Collect all error types handled in this error-handler
|
|
46
|
+
const handledTypes = new Set();
|
|
47
|
+
const onErrorBlocks = [
|
|
48
|
+
...this.select('.//mule:on-error-continue[@type]', handler),
|
|
49
|
+
...this.select('.//mule:on-error-propagate[@type]', handler),
|
|
50
|
+
];
|
|
51
|
+
for (const block of onErrorBlocks) {
|
|
52
|
+
const typeAttr = this.getAttribute(block, 'type') ?? '';
|
|
53
|
+
// Types can be comma-separated (e.g., "SALESFORCE:CONNECTIVITY, HTTP:CONNECTIVITY")
|
|
54
|
+
for (const t of typeAttr.split(',')) {
|
|
55
|
+
handledTypes.add(t.trim().toUpperCase());
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Check which required types are missing
|
|
59
|
+
const missingTypes = this.REQUIRED_APIKIT_TYPES.filter((t) => !handledTypes.has(t));
|
|
60
|
+
if (missingTypes.length > 0) {
|
|
61
|
+
issues.push(this.createIssue(handler, `Error handler "${handlerName}" is missing coverage for: ${missingTypes.join(', ')}`, {
|
|
62
|
+
suggestion: 'Add on-error-propagate blocks for each APIKit error type to return correct HTTP status codes (400, 404, 405, 406, 415)',
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return issues;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ErrorHandlerTypeCoverageRule = ErrorHandlerTypeCoverageRule;
|
|
70
|
+
//# sourceMappingURL=ErrorHandlerTypeCoverageRule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandlerTypeCoverageRule.js","sourceRoot":"","sources":["../../../../src/rules/error-handling/ErrorHandlerTypeCoverageRule.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAE5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M,CAAC,IAAI,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;oBACpC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC;YAED,yCAAyC;YACzC,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAEpF,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,WAAW,CACd,OAAO,EACP,kBAAkB,WAAW,8BAA8B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EACpF;oBACE,UAAU,EACR,wHAAwH;iBAC3H,CACF,CACF,CAAC;YACJ,CAAC;QACH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAtED,oEAsEC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ValidationContext, Issue, IssueType } from '../../types';
|
|
2
|
+
import { BaseRule } from '../base/BaseRule';
|
|
3
|
+
/**
|
|
4
|
+
* ERR-003: Error Response Structure
|
|
5
|
+
*
|
|
6
|
+
* Error responses should include both a correlationId and a message field
|
|
7
|
+
* for effective debugging and traceability. Real-world accelerator projects
|
|
8
|
+
* consistently use a JSON envelope like:
|
|
9
|
+
* { correlationId: "...", error: "...", message: "..." }
|
|
10
|
+
*
|
|
11
|
+
* This rule checks that ee:set-payload elements inside error handlers
|
|
12
|
+
* contain both correlationId and message in their DataWeave body.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ErrorResponseStructureRule extends BaseRule {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
severity: "info";
|
|
19
|
+
category: "error-handling";
|
|
20
|
+
issueType: IssueType;
|
|
21
|
+
validate(doc: Document, _context: ValidationContext): Issue[];
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ErrorResponseStructureRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorResponseStructureRule.d.ts","sourceRoot":"","sources":["../../../../src/rules/error-handling/ErrorResponseStructureRule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAG5C;;;;;;;;;;GAUG;AACH,qBAAa,0BAA2B,SAAQ,QAAQ;IACtD,EAAE,SAAa;IACf,IAAI,SAA8B;IAClC,WAAW,SAAqE;IAChF,QAAQ,EAAG,MAAM,CAAU;IAC3B,QAAQ,EAAG,gBAAgB,CAAU;IACrC,SAAS,EAAE,SAAS,CAAS;IAE7B,QAAQ,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,iBAAiB,GAAG,KAAK,EAAE;CAyE9D"}
|