@flow-scanner/lightning-flow-scanner-core 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/CONTRIBUTING.md +30 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +314 -0
  4. package/SECURITY.md +26 -0
  5. package/assets/media/bannerslim.png +0 -0
  6. package/index.d.ts +21 -0
  7. package/index.js +83 -0
  8. package/main/interfaces/AdvancedRuleConfig.d.ts +11 -0
  9. package/main/interfaces/AdvancedRuleConfig.js +4 -0
  10. package/main/interfaces/AdvancedRuleDefintion.d.ts +5 -0
  11. package/main/interfaces/AdvancedRuleDefintion.js +4 -0
  12. package/main/interfaces/AdvancedSuppression.d.ts +21 -0
  13. package/main/interfaces/AdvancedSuppression.js +4 -0
  14. package/main/interfaces/AutoFixable.d.ts +10 -0
  15. package/main/interfaces/AutoFixable.js +4 -0
  16. package/main/interfaces/IExceptions.d.ts +5 -0
  17. package/main/interfaces/IExceptions.js +4 -0
  18. package/main/interfaces/IRuleConfig.d.ts +3 -0
  19. package/main/interfaces/IRuleConfig.js +4 -0
  20. package/main/interfaces/IRuleDefinition.d.ts +17 -0
  21. package/main/interfaces/IRuleDefinition.js +4 -0
  22. package/main/interfaces/IRuleOptions.d.ts +4 -0
  23. package/main/interfaces/IRuleOptions.js +4 -0
  24. package/main/interfaces/IRulesConfig.d.ts +8 -0
  25. package/main/interfaces/IRulesConfig.js +4 -0
  26. package/main/internals/internals.d.ts +17 -0
  27. package/main/internals/internals.js +64 -0
  28. package/main/libs/BuildFlow.d.ts +1 -0
  29. package/main/libs/BuildFlow.js +20 -0
  30. package/main/libs/Compiler.d.ts +8 -0
  31. package/main/libs/Compiler.js +70 -0
  32. package/main/libs/ConvertFlowNodes.d.ts +1 -0
  33. package/main/libs/ConvertFlowNodes.js +14 -0
  34. package/main/libs/DynamicRule.d.ts +5 -0
  35. package/main/libs/DynamicRule.js +19 -0
  36. package/main/libs/FixFlows.d.ts +3 -0
  37. package/main/libs/FixFlows.js +110 -0
  38. package/main/libs/GetRuleDefinitions.d.ts +5 -0
  39. package/main/libs/GetRuleDefinitions.js +81 -0
  40. package/main/libs/ParseFlows.d.ts +2 -0
  41. package/main/libs/ParseFlows.js +111 -0
  42. package/main/libs/Scan2.d.ts +3 -0
  43. package/main/libs/Scan2.js +124 -0
  44. package/main/libs/ScanFlows.d.ts +4 -0
  45. package/main/libs/ScanFlows.js +103 -0
  46. package/main/models/AdvancedRule.d.ts +44 -0
  47. package/main/models/AdvancedRule.js +84 -0
  48. package/main/models/Flow.d.ts +33 -0
  49. package/main/models/Flow.js +277 -0
  50. package/main/models/FlowAttribute.d.ts +7 -0
  51. package/main/models/FlowAttribute.js +34 -0
  52. package/main/models/FlowElement.d.ts +10 -0
  53. package/main/models/FlowElement.js +37 -0
  54. package/main/models/FlowElementConnector.d.ts +15 -0
  55. package/main/models/FlowElementConnector.js +50 -0
  56. package/main/models/FlowMetadata.d.ts +4 -0
  57. package/main/models/FlowMetadata.js +16 -0
  58. package/main/models/FlowNode.d.ts +10 -0
  59. package/main/models/FlowNode.js +169 -0
  60. package/main/models/FlowResource.d.ts +5 -0
  61. package/main/models/FlowResource.js +30 -0
  62. package/main/models/FlowType.d.ts +23 -0
  63. package/main/models/FlowType.js +80 -0
  64. package/main/models/FlowVariable.d.ts +6 -0
  65. package/main/models/FlowVariable.js +31 -0
  66. package/main/models/LoopRuleCommon.d.ts +9 -0
  67. package/main/models/LoopRuleCommon.js +48 -0
  68. package/main/models/ParsedFlow.d.ts +7 -0
  69. package/main/models/ParsedFlow.js +35 -0
  70. package/main/models/ResultDetails.d.ts +10 -0
  71. package/main/models/ResultDetails.js +57 -0
  72. package/main/models/RuleCommon.d.ts +19 -0
  73. package/main/models/RuleCommon.js +48 -0
  74. package/main/models/RuleInfo.d.ts +55 -0
  75. package/main/models/RuleInfo.js +61 -0
  76. package/main/models/RuleResult.d.ts +11 -0
  77. package/main/models/RuleResult.js +44 -0
  78. package/main/models/ScanResult.d.ts +7 -0
  79. package/main/models/ScanResult.js +31 -0
  80. package/main/rules/APIVersion.d.ts +8 -0
  81. package/main/rules/APIVersion.js +86 -0
  82. package/main/rules/ActionCallsInLoop.d.ts +6 -0
  83. package/main/rules/ActionCallsInLoop.js +38 -0
  84. package/main/rules/AutoLayout.d.ts +8 -0
  85. package/main/rules/AutoLayout.js +78 -0
  86. package/main/rules/CopyAPIName.d.ts +6 -0
  87. package/main/rules/CopyAPIName.js +82 -0
  88. package/main/rules/CyclomaticComplexity.d.ts +10 -0
  89. package/main/rules/CyclomaticComplexity.js +111 -0
  90. package/main/rules/DMLStatementInLoop.d.ts +6 -0
  91. package/main/rules/DMLStatementInLoop.js +37 -0
  92. package/main/rules/DuplicateDMLOperation.d.ts +8 -0
  93. package/main/rules/DuplicateDMLOperation.js +153 -0
  94. package/main/rules/FlowDescription.d.ts +6 -0
  95. package/main/rules/FlowDescription.js +76 -0
  96. package/main/rules/FlowName.d.ts +7 -0
  97. package/main/rules/FlowName.js +80 -0
  98. package/main/rules/GetRecordAllFields.d.ts +6 -0
  99. package/main/rules/GetRecordAllFields.js +101 -0
  100. package/main/rules/HardcodedId.d.ts +6 -0
  101. package/main/rules/HardcodedId.js +87 -0
  102. package/main/rules/HardcodedUrl.d.ts +6 -0
  103. package/main/rules/HardcodedUrl.js +50 -0
  104. package/main/rules/InactiveFlow.d.ts +6 -0
  105. package/main/rules/InactiveFlow.js +73 -0
  106. package/main/rules/MissingFaultPath.d.ts +12 -0
  107. package/main/rules/MissingFaultPath.js +161 -0
  108. package/main/rules/MissingNullHandler.d.ts +6 -0
  109. package/main/rules/MissingNullHandler.js +152 -0
  110. package/main/rules/ProcessBuilder.d.ts +8 -0
  111. package/main/rules/ProcessBuilder.js +77 -0
  112. package/main/rules/RecursiveAfterUpdate.d.ts +7 -0
  113. package/main/rules/RecursiveAfterUpdate.js +124 -0
  114. package/main/rules/SOQLQueryInLoop.d.ts +6 -0
  115. package/main/rules/SOQLQueryInLoop.js +35 -0
  116. package/main/rules/SameRecordFieldUpdates.d.ts +7 -0
  117. package/main/rules/SameRecordFieldUpdates.js +111 -0
  118. package/main/rules/TriggerOrder.d.ts +7 -0
  119. package/main/rules/TriggerOrder.js +101 -0
  120. package/main/rules/UnconnectedElement.d.ts +7 -0
  121. package/main/rules/UnconnectedElement.js +93 -0
  122. package/main/rules/UnsafeRunningContext.d.ts +6 -0
  123. package/main/rules/UnsafeRunningContext.js +86 -0
  124. package/main/rules/UnusedVariable.d.ts +6 -0
  125. package/main/rules/UnusedVariable.js +100 -0
  126. package/main/store/DefaultRuleStore.d.ts +2 -0
  127. package/main/store/DefaultRuleStore.js +68 -0
  128. package/package.json +88 -0
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ResultDetails", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ResultDetails;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ let ResultDetails = class ResultDetails {
25
+ constructor(violation){
26
+ _define_property(this, "violation", void 0);
27
+ _define_property(this, "name", void 0);
28
+ _define_property(this, "type", void 0);
29
+ _define_property(this, "metaType", void 0);
30
+ _define_property(this, "details", void 0);
31
+ this.violation = violation;
32
+ this.name = violation.name;
33
+ this.metaType = violation.metaType;
34
+ this.type = violation.subtype;
35
+ if (violation.metaType === "variable") {
36
+ const element = violation;
37
+ this.details = {
38
+ dataType: element.dataType
39
+ };
40
+ }
41
+ if (violation.metaType === "node") {
42
+ var _element_connectors;
43
+ const element = violation;
44
+ this.details = {
45
+ locationX: element.locationX,
46
+ locationY: element.locationY,
47
+ connectsTo: (_element_connectors = element.connectors) === null || _element_connectors === void 0 ? void 0 : _element_connectors.map((connector)=>connector.reference)
48
+ };
49
+ }
50
+ if (violation.metaType === "attribute") {
51
+ const element = violation;
52
+ this.details = {
53
+ expression: element.expression
54
+ };
55
+ }
56
+ }
57
+ };
@@ -0,0 +1,19 @@
1
+ import { RuleInfo } from "./RuleInfo";
2
+ export declare class RuleCommon {
3
+ autoFixable: boolean;
4
+ description: string;
5
+ docRefs: Array<{
6
+ label: string;
7
+ path: string;
8
+ }>;
9
+ isConfigurable: boolean;
10
+ label: any;
11
+ name: any;
12
+ severity?: any;
13
+ supportedTypes: string[];
14
+ suppressionElement?: string;
15
+ uri: any;
16
+ constructor(info: RuleInfo, optional?: {
17
+ severity?: string;
18
+ });
19
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RuleCommon", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RuleCommon;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ let RuleCommon = class RuleCommon {
25
+ constructor(info, optional){
26
+ _define_property(this, "autoFixable", void 0);
27
+ _define_property(this, "description", void 0);
28
+ _define_property(this, "docRefs", []);
29
+ _define_property(this, "isConfigurable", void 0);
30
+ _define_property(this, "label", void 0);
31
+ _define_property(this, "name", void 0);
32
+ _define_property(this, "severity", void 0);
33
+ _define_property(this, "supportedTypes", void 0);
34
+ _define_property(this, "suppressionElement", void 0);
35
+ _define_property(this, "uri", void 0);
36
+ this.name = info.name;
37
+ this.supportedTypes = info.supportedTypes;
38
+ this.label = info.label;
39
+ this.description = info.description;
40
+ this.uri = `https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/rules/${info.name}.ts`;
41
+ this.docRefs = info.docRefs;
42
+ this.isConfigurable = info.isConfigurable;
43
+ this.autoFixable = info.autoFixable;
44
+ var _optional_severity;
45
+ this.severity = (_optional_severity = optional === null || optional === void 0 ? void 0 : optional.severity) !== null && _optional_severity !== void 0 ? _optional_severity : "error";
46
+ this.suppressionElement = info.suppressionElement;
47
+ }
48
+ };
@@ -0,0 +1,55 @@
1
+ export type RuleDefinitionExpression = {
2
+ options?: {
3
+ expression?: unknown;
4
+ };
5
+ };
6
+ /**
7
+ * Represents a rule metadata; this contains properties to describe the rule
8
+ */
9
+ export declare class RuleInfo {
10
+ /**
11
+ * Indicates whether the rule can be automatically fixed.
12
+ * When the rule is autofixable, implement @see {AutoFixable}
13
+ */
14
+ autoFixable: boolean;
15
+ /**
16
+ * A human-readable description of the rule.
17
+ */
18
+ description: string;
19
+ /**
20
+ * An array of documentation references related to the rule.
21
+ */
22
+ docRefs: Array<{
23
+ label: string;
24
+ path: string;
25
+ }>;
26
+ /**
27
+ * Specifies if the rule's behavior can be configured.
28
+ * When configurable, execute should take in a second parameter @see RuleDefinitionExpression
29
+ * @example
30
+ * ```typescript
31
+ * public execute(flow: core.Flow, options?: { expression: string }): core.RuleResult {
32
+ * // your rule
33
+ * }
34
+ */
35
+ isConfigurable: boolean;
36
+ /**
37
+ * The display label for the rule.
38
+ * This property is being displayed on sf cli and on vsce
39
+ */
40
+ label: string;
41
+ /**
42
+ * The unique name identifier for the rule.
43
+ */
44
+ name: string;
45
+ /**
46
+ * The types supported by this rule (e.g., Flow, Process).
47
+ * Use defined types in @see FlowType
48
+ */
49
+ supportedTypes: string[];
50
+ /**
51
+ * (Optional) The element that can be used to suppress this rule.
52
+ * @see AdvancedSuppression
53
+ */
54
+ suppressionElement?: string;
55
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RuleInfo", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RuleInfo;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ let RuleInfo = class RuleInfo {
25
+ constructor(){
26
+ /**
27
+ * Indicates whether the rule can be automatically fixed.
28
+ * When the rule is autofixable, implement @see {AutoFixable}
29
+ */ _define_property(this, "autoFixable", void 0);
30
+ /**
31
+ * A human-readable description of the rule.
32
+ */ _define_property(this, "description", void 0);
33
+ /**
34
+ * An array of documentation references related to the rule.
35
+ */ _define_property(this, "docRefs", void 0);
36
+ /**
37
+ * Specifies if the rule's behavior can be configured.
38
+ * When configurable, execute should take in a second parameter @see RuleDefinitionExpression
39
+ * @example
40
+ * ```typescript
41
+ * public execute(flow: core.Flow, options?: { expression: string }): core.RuleResult {
42
+ * // your rule
43
+ * }
44
+ */ _define_property(this, "isConfigurable", void 0);
45
+ /**
46
+ * The display label for the rule.
47
+ * This property is being displayed on sf cli and on vsce
48
+ */ _define_property(this, "label", void 0);
49
+ /**
50
+ * The unique name identifier for the rule.
51
+ */ _define_property(this, "name", void 0);
52
+ /**
53
+ * The types supported by this rule (e.g., Flow, Process).
54
+ * Use defined types in @see FlowType
55
+ */ _define_property(this, "supportedTypes", void 0);
56
+ /**
57
+ * (Optional) The element that can be used to suppress this rule.
58
+ * @see AdvancedSuppression
59
+ */ _define_property(this, "suppressionElement", void 0);
60
+ }
61
+ };
@@ -0,0 +1,11 @@
1
+ import { IRuleDefinition } from "../interfaces/IRuleDefinition";
2
+ import { ResultDetails } from "./ResultDetails";
3
+ export declare class RuleResult {
4
+ occurs: boolean;
5
+ ruleName: string;
6
+ ruleDefinition: IRuleDefinition;
7
+ severity: string;
8
+ details: ResultDetails[];
9
+ errorMessage: string;
10
+ constructor(info: IRuleDefinition, details: ResultDetails[], errorMessage?: string);
11
+ }
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "RuleResult", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return RuleResult;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ let RuleResult = class RuleResult {
25
+ constructor(info, details, errorMessage){
26
+ _define_property(this, "occurs", void 0);
27
+ _define_property(this, "ruleName", void 0);
28
+ _define_property(this, "ruleDefinition", void 0);
29
+ _define_property(this, "severity", void 0);
30
+ _define_property(this, "details", []);
31
+ _define_property(this, "errorMessage", void 0);
32
+ this.ruleDefinition = info;
33
+ this.ruleName = info.name;
34
+ this.severity = info.severity ? info.severity : "error";
35
+ this.occurs = false;
36
+ this.details = details;
37
+ if (details.length > 0) {
38
+ this.occurs = true;
39
+ }
40
+ if (errorMessage) {
41
+ this.errorMessage = errorMessage;
42
+ }
43
+ }
44
+ };
@@ -0,0 +1,7 @@
1
+ import { Flow } from "./Flow";
2
+ import { RuleResult } from "./RuleResult";
3
+ export declare class ScanResult {
4
+ constructor(flow: Flow, ruleResults: RuleResult[]);
5
+ flow: Flow;
6
+ ruleResults: RuleResult[];
7
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ScanResult", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ScanResult;
9
+ }
10
+ });
11
+ function _define_property(obj, key, value) {
12
+ if (key in obj) {
13
+ Object.defineProperty(obj, key, {
14
+ value: value,
15
+ enumerable: true,
16
+ configurable: true,
17
+ writable: true
18
+ });
19
+ } else {
20
+ obj[key] = value;
21
+ }
22
+ return obj;
23
+ }
24
+ let ScanResult = class ScanResult {
25
+ constructor(flow, ruleResults){
26
+ _define_property(this, "flow", void 0);
27
+ _define_property(this, "ruleResults", void 0);
28
+ this.flow = flow;
29
+ this.ruleResults = ruleResults;
30
+ }
31
+ };
@@ -0,0 +1,8 @@
1
+ import * as core from "../internals/internals";
2
+ import { AdvancedRule } from "../models/AdvancedRule";
3
+ export declare class APIVersion extends AdvancedRule implements core.IRuleDefinition {
4
+ constructor();
5
+ execute(flow: core.Flow, options?: {
6
+ expression: string;
7
+ }): core.RuleResult;
8
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "APIVersion", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return APIVersion;
9
+ }
10
+ });
11
+ const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _AdvancedRule = require("../models/AdvancedRule");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {
35
+ __proto__: null
36
+ };
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ let APIVersion = class APIVersion extends _AdvancedRule.AdvancedRule {
55
+ execute(flow, options) {
56
+ let flowAPIVersionNumber = null;
57
+ if (flow.xmldata.apiVersion) {
58
+ const flowAPIVersion = flow.xmldata.apiVersion;
59
+ flowAPIVersionNumber = +flowAPIVersion;
60
+ }
61
+ const results = [];
62
+ if (!flowAPIVersionNumber) {
63
+ results.push(new _internals.ResultDetails(new _internals.FlowAttribute("API Version <49", "apiVersion", "<49")));
64
+ return new _internals.RuleResult(this, results);
65
+ }
66
+ if (options && options.expression) {
67
+ // eslint-disable-next-line sonarjs/code-eval
68
+ const isApiNumberMoreThanConfiguredExpression = new Function(`return ${flowAPIVersionNumber}${options.expression};`);
69
+ if (!isApiNumberMoreThanConfiguredExpression()) {
70
+ results.push(new _internals.ResultDetails(new _internals.FlowAttribute(`${flowAPIVersionNumber}`, "apiVersion", options.expression)));
71
+ }
72
+ }
73
+ return new _internals.RuleResult(this, results);
74
+ }
75
+ constructor(){
76
+ super({
77
+ name: "APIVersion",
78
+ label: "Outdated API Version",
79
+ description: "Introducing newer API components may lead to unexpected issues with older versions of Flows, as they might not align with the underlying mechanics. Starting from API version 50.0, the 'Api Version' attribute has been readily available on the Flow Object. To ensure smooth operation and reduce discrepancies between API versions, it is strongly advised to regularly update and maintain them.",
80
+ supportedTypes: _internals.FlowType.allTypes(),
81
+ docRefs: [],
82
+ isConfigurable: true,
83
+ autoFixable: false
84
+ });
85
+ }
86
+ };
@@ -0,0 +1,6 @@
1
+ import { IRuleDefinition } from "../internals/internals";
2
+ import { LoopRuleCommon } from "../models/LoopRuleCommon";
3
+ export declare class ActionCallsInLoop extends LoopRuleCommon implements IRuleDefinition {
4
+ constructor();
5
+ protected getStatementTypes(): string[];
6
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "ActionCallsInLoop", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return ActionCallsInLoop;
9
+ }
10
+ });
11
+ const _internals = require("../internals/internals");
12
+ const _LoopRuleCommon = require("../models/LoopRuleCommon");
13
+ let ActionCallsInLoop = class ActionCallsInLoop extends _LoopRuleCommon.LoopRuleCommon {
14
+ getStatementTypes() {
15
+ return [
16
+ "actionCalls",
17
+ "apexPluginCalls"
18
+ ];
19
+ }
20
+ constructor(){
21
+ super({
22
+ autoFixable: false,
23
+ description: "To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls, utilize a single action call containing a collection variable at the end of the loop.",
24
+ docRefs: [
25
+ {
26
+ label: "Invocable Method Considerations",
27
+ path: "https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm"
28
+ }
29
+ ],
30
+ isConfigurable: false,
31
+ label: "**Beta** Action Calls In Loop",
32
+ name: "ActionCallsInLoop",
33
+ supportedTypes: _internals.FlowType.backEndTypes
34
+ }, {
35
+ severity: "warning"
36
+ });
37
+ }
38
+ };
@@ -0,0 +1,8 @@
1
+ import * as core from "../internals/internals";
2
+ import { AdvancedRule } from "../models/AdvancedRule";
3
+ export declare class AutoLayout extends AdvancedRule implements core.IRuleDefinition {
4
+ constructor();
5
+ execute(flow: core.Flow, options?: {
6
+ expression: string;
7
+ }): core.RuleResult;
8
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "AutoLayout", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return AutoLayout;
9
+ }
10
+ });
11
+ const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _AdvancedRule = require("../models/AdvancedRule");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {
35
+ __proto__: null
36
+ };
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ let AutoLayout = class AutoLayout extends _AdvancedRule.AdvancedRule {
55
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
56
+ execute(flow, options) {
57
+ if (flow.processMetadataValues) {
58
+ var _CanvasMode_value;
59
+ const CanvasMode = flow.xmldata.processMetadataValues.find((mdv)=>mdv.name === "CanvasMode");
60
+ const autoLayout = CanvasMode.value && typeof CanvasMode.value === "object" && CanvasMode.value.stringValue && CanvasMode.value.stringValue === "AUTO_LAYOUT_CANVAS";
61
+ return !autoLayout ? new _internals.RuleResult(this, [
62
+ new _internals.ResultDetails(new _internals.FlowAttribute((_CanvasMode_value = CanvasMode.value) === null || _CanvasMode_value === void 0 ? void 0 : _CanvasMode_value.stringValue, "CanvasMode", "!== AUTO_LAYOUT_CANVAS"))
63
+ ]) : new _internals.RuleResult(this, []);
64
+ }
65
+ return new _internals.RuleResult(this, []);
66
+ }
67
+ constructor(){
68
+ super({
69
+ name: "AutoLayout",
70
+ label: "Auto-Layout Mode",
71
+ description: "With Canvas Mode set to Auto-Layout, Elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized thus saving you time.",
72
+ supportedTypes: _internals.FlowType.allTypes(),
73
+ docRefs: [],
74
+ isConfigurable: true,
75
+ autoFixable: false
76
+ });
77
+ }
78
+ };
@@ -0,0 +1,6 @@
1
+ import * as core from "../internals/internals";
2
+ import { AdvancedRule } from "../models/AdvancedRule";
3
+ export declare class CopyAPIName extends AdvancedRule implements core.IRuleDefinition {
4
+ constructor();
5
+ execute(flow: core.Flow): core.RuleResult;
6
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "CopyAPIName", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return CopyAPIName;
9
+ }
10
+ });
11
+ const _internals = /*#__PURE__*/ _interop_require_wildcard(require("../internals/internals"));
12
+ const _AdvancedRule = require("../models/AdvancedRule");
13
+ function _getRequireWildcardCache(nodeInterop) {
14
+ if (typeof WeakMap !== "function") return null;
15
+ var cacheBabelInterop = new WeakMap();
16
+ var cacheNodeInterop = new WeakMap();
17
+ return (_getRequireWildcardCache = function(nodeInterop) {
18
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
19
+ })(nodeInterop);
20
+ }
21
+ function _interop_require_wildcard(obj, nodeInterop) {
22
+ if (!nodeInterop && obj && obj.__esModule) {
23
+ return obj;
24
+ }
25
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
26
+ return {
27
+ default: obj
28
+ };
29
+ }
30
+ var cache = _getRequireWildcardCache(nodeInterop);
31
+ if (cache && cache.has(obj)) {
32
+ return cache.get(obj);
33
+ }
34
+ var newObj = {
35
+ __proto__: null
36
+ };
37
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
38
+ for(var key in obj){
39
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
40
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
41
+ if (desc && (desc.get || desc.set)) {
42
+ Object.defineProperty(newObj, key, desc);
43
+ } else {
44
+ newObj[key] = obj[key];
45
+ }
46
+ }
47
+ }
48
+ newObj.default = obj;
49
+ if (cache) {
50
+ cache.set(obj, newObj);
51
+ }
52
+ return newObj;
53
+ }
54
+ let CopyAPIName = class CopyAPIName extends _AdvancedRule.AdvancedRule {
55
+ execute(flow) {
56
+ const flowElements = flow.elements.filter((node)=>node instanceof _internals.FlowNode);
57
+ const copyOfElements = [];
58
+ for (const element of flowElements){
59
+ // eslint-disable-next-line sonarjs/concise-regex
60
+ const copyOf = new RegExp("Copy_[0-9]+_of_[A-Za-z0-9]+").test(element.name);
61
+ if (copyOf) {
62
+ copyOfElements.push(element);
63
+ }
64
+ }
65
+ const results = [];
66
+ for (const det of copyOfElements){
67
+ results.push(new _internals.ResultDetails(det));
68
+ }
69
+ return new _internals.RuleResult(this, results);
70
+ }
71
+ constructor(){
72
+ super({
73
+ name: "CopyAPIName",
74
+ label: "Copy API Name",
75
+ description: "Maintaining multiple elements with a similar name, like 'Copy_X_Of_Element,' can diminish the overall readability of your Flow. When copying and pasting these elements, it's crucial to remember to update the API name of the newly created copy.",
76
+ supportedTypes: _internals.FlowType.allTypes(),
77
+ docRefs: [],
78
+ isConfigurable: false,
79
+ autoFixable: false
80
+ });
81
+ }
82
+ };
@@ -0,0 +1,10 @@
1
+ import { AdvancedRule } from "../models/AdvancedRule";
2
+ import * as core from "../internals/internals";
3
+ export declare class CyclomaticComplexity extends AdvancedRule implements core.IRuleDefinition {
4
+ constructor();
5
+ private defaultThreshold;
6
+ private cyclomaticComplexityUnit;
7
+ execute(flow: core.Flow, options?: {
8
+ threshold: number;
9
+ }): core.RuleResult;
10
+ }