@flow-scanner/lightning-flow-scanner-core 6.16.2 → 6.17.1
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/.husky/pre-commit +1 -0
- package/.husky/pre-push +1 -0
- package/.prettierignore +5 -0
- package/.swcrc +26 -0
- package/.turbo/turbo-build.log +17 -0
- package/.turbo/turbo-test.log +144 -0
- package/.turbo/turbo-vite$colon$dist.log +21 -0
- package/coverage/coverage-final.json +63 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +236 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/index.ts.html +238 -0
- package/coverage/lcov-report/src/main/adapters/RegexAdapter.ts.html +118 -0
- package/coverage/lcov-report/src/main/adapters/index.html +116 -0
- package/coverage/lcov-report/src/main/config/NodeIcons.ts.html +376 -0
- package/coverage/lcov-report/src/main/config/RuleRegistry.ts.html +646 -0
- package/coverage/lcov-report/src/main/config/VariableIcons.ts.html +253 -0
- package/coverage/lcov-report/src/main/config/index.html +146 -0
- package/coverage/lcov-report/src/main/enums/MetaType.ts.html +100 -0
- package/coverage/lcov-report/src/main/enums/MetadataType.ts.html +103 -0
- package/coverage/lcov-report/src/main/enums/MetadataTypes.ts.html +100 -0
- package/coverage/lcov-report/src/main/enums/index.html +116 -0
- package/coverage/lcov-report/src/main/interfaces/IRulesConfig.ts.html +133 -0
- package/coverage/lcov-report/src/main/interfaces/index.html +116 -0
- package/coverage/lcov-report/src/main/internals/index.html +116 -0
- package/coverage/lcov-report/src/main/internals/internals.ts.html +190 -0
- package/coverage/lcov-report/src/main/libs/BuildFlow.ts.html +127 -0
- package/coverage/lcov-report/src/main/libs/Compiler.ts.html +241 -0
- package/coverage/lcov-report/src/main/libs/ConvertFlowNodes.ts.html +97 -0
- package/coverage/lcov-report/src/main/libs/DynamicRule.ts.html +118 -0
- package/coverage/lcov-report/src/main/libs/ExportDetails.ts.html +256 -0
- package/coverage/lcov-report/src/main/libs/ExportDiagram.ts.html +331 -0
- package/coverage/lcov-report/src/main/libs/ExportSarif.ts.html +358 -0
- package/coverage/lcov-report/src/main/libs/FixFlows.ts.html +265 -0
- package/coverage/lcov-report/src/main/libs/GenerateMarkdown.ts.html +331 -0
- package/coverage/lcov-report/src/main/libs/GetRuleDefinitions.ts.html +274 -0
- package/coverage/lcov-report/src/main/libs/ParseFlows.ts.html +184 -0
- package/coverage/lcov-report/src/main/libs/RuleDocumentation.ts.html +190 -0
- package/coverage/lcov-report/src/main/libs/ScanFlows.ts.html +508 -0
- package/coverage/lcov-report/src/main/libs/exportAsDetails.ts.html +160 -0
- package/coverage/lcov-report/src/main/libs/exportAsSarif.ts.html +346 -0
- package/coverage/lcov-report/src/main/libs/index.html +251 -0
- package/coverage/lcov-report/src/main/models/FlatViolation.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/Flow.ts.html +1057 -0
- package/coverage/lcov-report/src/main/models/FlowAttribute.ts.html +115 -0
- package/coverage/lcov-report/src/main/models/FlowElement.ts.html +133 -0
- package/coverage/lcov-report/src/main/models/FlowElementConnector.ts.html +169 -0
- package/coverage/lcov-report/src/main/models/FlowGraph.ts.html +1672 -0
- package/coverage/lcov-report/src/main/models/FlowMetadata.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/FlowNode.ts.html +1252 -0
- package/coverage/lcov-report/src/main/models/FlowResource.ts.html +106 -0
- package/coverage/lcov-report/src/main/models/FlowType.ts.html +244 -0
- package/coverage/lcov-report/src/main/models/FlowVariable.ts.html +553 -0
- package/coverage/lcov-report/src/main/models/LoopRuleCommon.ts.html +235 -0
- package/coverage/lcov-report/src/main/models/ParsedFlow.ts.html +121 -0
- package/coverage/lcov-report/src/main/models/RuleCommon.ts.html +442 -0
- package/coverage/lcov-report/src/main/models/RuleResult.ts.html +172 -0
- package/coverage/lcov-report/src/main/models/ScanResult.ts.html +121 -0
- package/coverage/lcov-report/src/main/models/Violation.ts.html +316 -0
- package/coverage/lcov-report/src/main/models/index.html +341 -0
- package/coverage/lcov-report/src/main/rules/APIVersion.ts.html +361 -0
- package/coverage/lcov-report/src/main/rules/ActionCallsInLoop.ts.html +157 -0
- package/coverage/lcov-report/src/main/rules/AutoLayout.ts.html +220 -0
- package/coverage/lcov-report/src/main/rules/CopyAPIName.ts.html +175 -0
- package/coverage/lcov-report/src/main/rules/CyclomaticComplexity.ts.html +292 -0
- package/coverage/lcov-report/src/main/rules/DMLStatementInLoop.ts.html +163 -0
- package/coverage/lcov-report/src/main/rules/DuplicateDMLOperation.ts.html +334 -0
- package/coverage/lcov-report/src/main/rules/FlowDescription.ts.html +184 -0
- package/coverage/lcov-report/src/main/rules/FlowName.ts.html +229 -0
- package/coverage/lcov-report/src/main/rules/GetRecordAllFields.ts.html +280 -0
- package/coverage/lcov-report/src/main/rules/HardcodedId.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/HardcodedSecret.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/HardcodedUrl.ts.html +247 -0
- package/coverage/lcov-report/src/main/rules/InactiveFlow.ts.html +184 -0
- package/coverage/lcov-report/src/main/rules/MissingFaultPath.ts.html +397 -0
- package/coverage/lcov-report/src/main/rules/MissingFilterRecordTrigger.ts.html +229 -0
- package/coverage/lcov-report/src/main/rules/MissingMetadataDescription.ts.html +211 -0
- package/coverage/lcov-report/src/main/rules/MissingNullHandler.ts.html +460 -0
- package/coverage/lcov-report/src/main/rules/MissingRecordTriggerFilter.ts.html +235 -0
- package/coverage/lcov-report/src/main/rules/ProcessBuilder.ts.html +190 -0
- package/coverage/lcov-report/src/main/rules/RecordIdAsString.ts.html +274 -0
- package/coverage/lcov-report/src/main/rules/RecursiveAfterUpdate.ts.html +364 -0
- package/coverage/lcov-report/src/main/rules/SOQLQueryInLoop.ts.html +160 -0
- package/coverage/lcov-report/src/main/rules/SameRecordFieldUpdates.ts.html +283 -0
- package/coverage/lcov-report/src/main/rules/TransformInsteadOfLoop.ts.html +250 -0
- package/coverage/lcov-report/src/main/rules/TriggerOrder.ts.html +238 -0
- package/coverage/lcov-report/src/main/rules/UnconnectedElement.ts.html +178 -0
- package/coverage/lcov-report/src/main/rules/UnsafeRunningContext.ts.html +226 -0
- package/coverage/lcov-report/src/main/rules/UnusedVariable.ts.html +283 -0
- package/coverage/lcov-report/src/main/rules/index.html +521 -0
- package/coverage/lcov-report/src/main/store/DefaultRuleStore.ts.html +265 -0
- package/coverage/lcov-report/src/main/store/RuleRegistry.ts.html +118 -0
- package/coverage/lcov-report/src/main/store/index.html +116 -0
- package/coverage/lcov.info +6261 -0
- package/eslint.config.mjs +36 -0
- package/jest.config.cjs +32 -0
- package/jest.env-setup.js +101 -0
- package/lint-staged.config.mjs +8 -0
- package/out/main/config/RegexAdapter.d.ts +32 -0
- package/out/main/config/RegexAdapter.js +86 -0
- package/{main → out/main}/config/RuleRegistry.js +2 -0
- package/out/main/rules/FlowName.d.ts +15 -0
- package/{main → out/main}/rules/FlowName.js +24 -11
- package/out/main/rules/HardcodedId.d.ts +13 -0
- package/{main → out/main}/rules/HardcodedId.js +23 -4
- package/out/main/rules/HardcodedSecret.d.ts +13 -0
- package/out/main/rules/HardcodedSecret.js +101 -0
- package/{main → out/main}/rules/HardcodedUrl.d.ts +6 -0
- package/{main → out/main}/rules/HardcodedUrl.js +23 -5
- package/package.json +58 -8
- package/prettier.config.mjs +5 -0
- package/src/index.ts +52 -0
- package/src/main/config/NodeIcons.ts +98 -0
- package/src/main/config/RegexAdapter.ts +98 -0
- package/src/main/config/RuleRegistry.ts +188 -0
- package/src/main/config/VariableIcons.ts +57 -0
- package/src/main/enums/MetadataTypes.ts +6 -0
- package/src/main/interfaces/IExceptions.ts +6 -0
- package/src/main/interfaces/IRuleConfig.ts +6 -0
- package/src/main/interfaces/IRuleDefinition.ts +15 -0
- package/src/main/interfaces/IRuleOptions.ts +5 -0
- package/src/main/interfaces/IRulesConfig.ts +17 -0
- package/src/main/internals/internals.ts +35 -0
- package/src/main/libs/BuildFlow.ts +14 -0
- package/src/main/libs/Compiler.ts +53 -0
- package/src/main/libs/ExportDetails.ts +58 -0
- package/src/main/libs/ExportDiagram.ts +83 -0
- package/src/main/libs/ExportSarif.ts +92 -0
- package/src/main/libs/FixFlows.ts +61 -0
- package/src/main/libs/GetRuleDefinitions.ts +64 -0
- package/src/main/libs/ParseFlows.ts +34 -0
- package/src/main/libs/RuleDocumentation.ts +35 -0
- package/src/main/libs/ScanFlows.ts +142 -0
- package/src/main/models/FlatViolation.ts +16 -0
- package/src/main/models/Flow.ts +325 -0
- package/src/main/models/FlowAttribute.ts +11 -0
- package/src/main/models/FlowElement.ts +16 -0
- package/src/main/models/FlowElementConnector.ts +28 -0
- package/src/main/models/FlowGraph.ts +530 -0
- package/src/main/models/FlowMetadata.ts +8 -0
- package/src/main/models/FlowNode.ts +390 -0
- package/src/main/models/FlowResource.ts +8 -0
- package/src/main/models/FlowType.ts +53 -0
- package/src/main/models/FlowVariable.ts +157 -0
- package/src/main/models/LoopRuleCommon.ts +51 -0
- package/src/main/models/ParsedFlow.ts +13 -0
- package/src/main/models/RuleCommon.ts +120 -0
- package/src/main/models/RuleInfo.ts +54 -0
- package/src/main/models/RuleResult.ts +29 -0
- package/src/main/models/ScanResult.ts +12 -0
- package/src/main/models/Violation.ts +78 -0
- package/src/main/rules/APIVersion.ts +93 -0
- package/src/main/rules/ActionCallsInLoop.ts +25 -0
- package/src/main/rules/AutoLayout.ts +46 -0
- package/src/main/rules/CopyAPIName.ts +31 -0
- package/src/main/rules/CyclomaticComplexity.ts +70 -0
- package/src/main/rules/DMLStatementInLoop.ts +26 -0
- package/src/main/rules/DuplicateDMLOperation.ts +83 -0
- package/src/main/rules/FlowDescription.ts +34 -0
- package/src/main/rules/FlowName.ts +49 -0
- package/src/main/rules/GetRecordAllFields.ts +65 -0
- package/src/main/rules/HardcodedId.ts +51 -0
- package/src/main/rules/HardcodedSecret.ts +51 -0
- package/src/main/rules/HardcodedUrl.ts +54 -0
- package/src/main/rules/InactiveFlow.ts +33 -0
- package/src/main/rules/MissingFaultPath.ts +105 -0
- package/src/main/rules/MissingMetadataDescription.ts +42 -0
- package/src/main/rules/MissingNullHandler.ts +126 -0
- package/src/main/rules/MissingRecordTriggerFilter.ts +51 -0
- package/src/main/rules/ProcessBuilder.ts +35 -0
- package/src/main/rules/RecordIdAsString.ts +64 -0
- package/src/main/rules/RecursiveAfterUpdate.ts +94 -0
- package/src/main/rules/SOQLQueryInLoop.ts +26 -0
- package/src/main/rules/SameRecordFieldUpdates.ts +66 -0
- package/src/main/rules/TransformInsteadOfLoop.ts +56 -0
- package/src/main/rules/TriggerOrder.ts +51 -0
- package/src/main/rules/UnconnectedElement.ts +32 -0
- package/src/main/rules/UnsafeRunningContext.ts +47 -0
- package/src/main/rules/UnusedVariable.ts +66 -0
- package/stryker.config.mjs +23 -0
- package/tests/APIVersion.test.ts +87 -0
- package/tests/AutoLayout.test.ts +41 -0
- package/tests/Config.test.ts +122 -0
- package/tests/ConfigBetaMode.test.ts +26 -0
- package/tests/CopyAPIName.test.ts +45 -0
- package/tests/CyclomaticComplexity.test.ts +125 -0
- package/tests/DMLStatementInLoop.test.ts +32 -0
- package/tests/DuplicateDMLOperation.test.ts +43 -0
- package/tests/EnabledFalse.test.ts +63 -0
- package/tests/Exceptions.test.ts +815 -0
- package/tests/ExportSarif.test.ts +62 -0
- package/tests/FlowDescription.test.ts +44 -0
- package/tests/FlowDocumentation.test.ts +74 -0
- package/tests/FlowName.test.ts +61 -0
- package/tests/GetRecordElementAllFields.test.ts +182 -0
- package/tests/HardcodedId.test.ts +16 -0
- package/tests/HardcodedSecret.test.ts +32 -0
- package/tests/HardcodedUrl.test.ts +253 -0
- package/tests/InactiveFlow.test.ts +103 -0
- package/tests/MissingFaultPath.test.ts +52 -0
- package/tests/MissingMetadataDescription.test.ts +25 -0
- package/tests/MissingNullHandler.test.ts +45 -0
- package/tests/MissingRecordTriggerFilter.test.ts +54 -0
- package/tests/RecordIdAsString.test.ts +60 -0
- package/tests/RecursiveAfterUpdate.test.ts +183 -0
- package/tests/SOQLQueryInLoop.test.ts +33 -0
- package/tests/SameRecordFieldUpdates.test.ts +205 -0
- package/tests/SanityTest.test.ts +15 -0
- package/tests/TransformInsteadOfLoop.test.ts +33 -0
- package/tests/TriggerOrder.test.ts +112 -0
- package/tests/UnconnectedElement.test.ts +76 -0
- package/tests/UnsafeRunningContext.test.ts +46 -0
- package/tests/UnusedVariable.test.ts +59 -0
- package/tests/UnusedVariableExceptions.test.ts +87 -0
- package/tests/jsonfiles/MissingFaultPath_BeforeSave_Bypass.json +128 -0
- package/tests/jsonfiles/MissingFaultPath_WaitConditions.json +102 -0
- package/tests/jsonfiles/MissingFaultPath_WaitDate.json +88 -0
- package/tests/jsonfiles/MissingFaultPath_WaitDuration.json +90 -0
- package/tests/models/Flow.test.ts +107 -0
- package/tests/models/LoopRuleCommon.test.ts +246 -0
- package/tests/models/RuleCommon.test.ts +41 -0
- package/tsconfig.json +28 -0
- package/tsconfig.types.json +26 -0
- package/types/index.d.ts +27 -0
- package/types/index.d.ts.map +1 -0
- package/types/main/adapters/RegexAdapter.d.ts +33 -0
- package/types/main/adapters/RegexAdapter.d.ts.map +1 -0
- package/types/main/config/NodeIcons.d.ts +25 -0
- package/types/main/config/NodeIcons.d.ts.map +1 -0
- package/types/main/config/RegexAdapter.d.ts +33 -0
- package/types/main/config/RegexAdapter.d.ts.map +1 -0
- package/types/main/config/RuleRegistry.d.ts +23 -0
- package/types/main/config/RuleRegistry.d.ts.map +1 -0
- package/types/main/config/VariableIcons.d.ts +26 -0
- package/types/main/config/VariableIcons.d.ts.map +1 -0
- package/types/main/enums/MetadataTypes.d.ts +7 -0
- package/types/main/enums/MetadataTypes.d.ts.map +1 -0
- package/types/main/interfaces/IExceptions.d.ts +6 -0
- package/types/main/interfaces/IExceptions.d.ts.map +1 -0
- package/types/main/interfaces/IRuleConfig.d.ts +7 -0
- package/types/main/interfaces/IRuleConfig.d.ts.map +1 -0
- package/types/main/interfaces/IRuleDefinition.d.ts +18 -0
- package/types/main/interfaces/IRuleDefinition.d.ts.map +1 -0
- package/types/main/interfaces/IRuleOptions.d.ts +5 -0
- package/types/main/interfaces/IRuleOptions.d.ts.map +1 -0
- package/types/main/interfaces/IRulesConfig.d.ts +16 -0
- package/types/main/interfaces/IRulesConfig.d.ts.map +1 -0
- package/types/main/internals/internals.d.ts +19 -0
- package/types/main/internals/internals.d.ts.map +1 -0
- package/types/main/libs/BuildFlow.d.ts +2 -0
- package/types/main/libs/BuildFlow.d.ts.map +1 -0
- package/types/main/libs/Compiler.d.ts +8 -0
- package/types/main/libs/Compiler.d.ts.map +1 -0
- package/types/main/libs/ConvertFlowNodes.d.ts +2 -0
- package/types/main/libs/ConvertFlowNodes.d.ts.map +1 -0
- package/types/main/libs/DynamicRule.d.ts +5 -0
- package/types/main/libs/DynamicRule.d.ts.map +1 -0
- package/types/main/libs/ExportDetails.d.ts +4 -0
- package/types/main/libs/ExportDetails.d.ts.map +1 -0
- package/types/main/libs/ExportDiagram.d.ts +42 -0
- package/types/main/libs/ExportDiagram.d.ts.map +1 -0
- package/types/main/libs/ExportSarif.d.ts +3 -0
- package/types/main/libs/ExportSarif.d.ts.map +1 -0
- package/types/main/libs/FixFlows.d.ts +4 -0
- package/types/main/libs/FixFlows.d.ts.map +1 -0
- package/types/main/libs/GetRuleDefinitions.d.ts +5 -0
- package/types/main/libs/GetRuleDefinitions.d.ts.map +1 -0
- package/types/main/libs/ParseFlows.d.ts +3 -0
- package/types/main/libs/ParseFlows.d.ts.map +1 -0
- package/types/main/libs/RuleDocumentation.d.ts +21 -0
- package/types/main/libs/RuleDocumentation.d.ts.map +1 -0
- package/types/main/libs/ScanFlows.d.ts +5 -0
- package/types/main/libs/ScanFlows.d.ts.map +1 -0
- package/types/main/libs/exportAsDetails.d.ts +4 -0
- package/types/main/libs/exportAsDetails.d.ts.map +1 -0
- package/types/main/libs/exportAsSarif.d.ts +3 -0
- package/types/main/libs/exportAsSarif.d.ts.map +1 -0
- package/types/main/models/FlatViolation.d.ts +16 -0
- package/types/main/models/FlatViolation.d.ts.map +1 -0
- package/types/main/models/Flow.d.ts +70 -0
- package/types/main/models/Flow.d.ts.map +1 -0
- package/types/main/models/FlowAttribute.d.ts +6 -0
- package/types/main/models/FlowAttribute.d.ts.map +1 -0
- package/types/main/models/FlowElement.d.ts +11 -0
- package/types/main/models/FlowElement.d.ts.map +1 -0
- package/types/main/models/FlowElementConnector.d.ts +16 -0
- package/types/main/models/FlowElementConnector.d.ts.map +1 -0
- package/types/main/models/FlowGraph.d.ts +86 -0
- package/types/main/models/FlowGraph.d.ts.map +1 -0
- package/types/main/models/FlowMetadata.d.ts +5 -0
- package/types/main/models/FlowMetadata.d.ts.map +1 -0
- package/types/main/models/FlowNode.d.ts +66 -0
- package/types/main/models/FlowNode.d.ts.map +1 -0
- package/types/main/models/FlowResource.d.ts +5 -0
- package/types/main/models/FlowResource.d.ts.map +1 -0
- package/types/main/models/FlowType.d.ts +24 -0
- package/types/main/models/FlowType.d.ts.map +1 -0
- package/types/main/models/FlowVariable.d.ts +64 -0
- package/types/main/models/FlowVariable.d.ts.map +1 -0
- package/types/main/models/LoopRuleCommon.d.ts +15 -0
- package/types/main/models/LoopRuleCommon.d.ts.map +1 -0
- package/types/main/models/ParsedFlow.d.ts +8 -0
- package/types/main/models/ParsedFlow.d.ts.map +1 -0
- package/types/main/models/RuleCommon.d.ts +58 -0
- package/types/main/models/RuleCommon.d.ts.map +1 -0
- package/types/main/models/RuleInfo.d.ts +50 -0
- package/types/main/models/RuleInfo.d.ts.map +1 -0
- package/types/main/models/RuleResult.d.ts +15 -0
- package/types/main/models/RuleResult.d.ts.map +1 -0
- package/types/main/models/ScanResult.d.ts +8 -0
- package/types/main/models/ScanResult.d.ts.map +1 -0
- package/types/main/models/Violation.d.ts +12 -0
- package/types/main/models/Violation.d.ts.map +1 -0
- package/{main/rules/FlowName.d.ts → types/main/rules/APIVersion.d.ts} +2 -1
- package/types/main/rules/APIVersion.d.ts.map +1 -0
- package/types/main/rules/ActionCallsInLoop.d.ts +7 -0
- package/types/main/rules/ActionCallsInLoop.d.ts.map +1 -0
- package/types/main/rules/AutoLayout.d.ts +8 -0
- package/types/main/rules/AutoLayout.d.ts.map +1 -0
- package/types/main/rules/CopyAPIName.d.ts +8 -0
- package/types/main/rules/CopyAPIName.d.ts.map +1 -0
- package/types/main/rules/CyclomaticComplexity.d.ts +12 -0
- package/types/main/rules/CyclomaticComplexity.d.ts.map +1 -0
- package/types/main/rules/DMLStatementInLoop.d.ts +7 -0
- package/types/main/rules/DMLStatementInLoop.d.ts.map +1 -0
- package/types/main/rules/DuplicateDMLOperation.d.ts +9 -0
- package/types/main/rules/DuplicateDMLOperation.d.ts.map +1 -0
- package/{main/rules/HardcodedId.d.ts → types/main/rules/FlowDescription.d.ts} +2 -1
- package/types/main/rules/FlowDescription.d.ts.map +1 -0
- package/types/main/rules/FlowName.d.ts +16 -0
- package/types/main/rules/FlowName.d.ts.map +1 -0
- package/types/main/rules/GetRecordAllFields.d.ts +8 -0
- package/types/main/rules/GetRecordAllFields.d.ts.map +1 -0
- package/types/main/rules/HardcodedId.d.ts +14 -0
- package/types/main/rules/HardcodedId.d.ts.map +1 -0
- package/types/main/rules/HardcodedSecret.d.ts +14 -0
- package/types/main/rules/HardcodedSecret.d.ts.map +1 -0
- package/types/main/rules/HardcodedUrl.d.ts +14 -0
- package/types/main/rules/HardcodedUrl.d.ts.map +1 -0
- package/types/main/rules/InactiveFlow.d.ts +8 -0
- package/types/main/rules/InactiveFlow.d.ts.map +1 -0
- package/types/main/rules/MissingFaultPath.d.ts +15 -0
- package/types/main/rules/MissingFaultPath.d.ts.map +1 -0
- package/types/main/rules/MissingFilterRecordTrigger.d.ts +8 -0
- package/types/main/rules/MissingFilterRecordTrigger.d.ts.map +1 -0
- package/types/main/rules/MissingMetadataDescription.d.ts +8 -0
- package/types/main/rules/MissingMetadataDescription.d.ts.map +1 -0
- package/types/main/rules/MissingNullHandler.d.ts +8 -0
- package/types/main/rules/MissingNullHandler.d.ts.map +1 -0
- package/types/main/rules/MissingRecordTriggerFilter.d.ts +8 -0
- package/types/main/rules/MissingRecordTriggerFilter.d.ts.map +1 -0
- package/types/main/rules/ProcessBuilder.d.ts +8 -0
- package/types/main/rules/ProcessBuilder.d.ts.map +1 -0
- package/types/main/rules/RecordIdAsString.d.ts +8 -0
- package/types/main/rules/RecordIdAsString.d.ts.map +1 -0
- package/types/main/rules/RecursiveAfterUpdate.d.ts +9 -0
- package/types/main/rules/RecursiveAfterUpdate.d.ts.map +1 -0
- package/types/main/rules/SOQLQueryInLoop.d.ts +7 -0
- package/types/main/rules/SOQLQueryInLoop.d.ts.map +1 -0
- package/types/main/rules/SameRecordFieldUpdates.d.ts +9 -0
- package/types/main/rules/SameRecordFieldUpdates.d.ts.map +1 -0
- package/types/main/rules/TransformInsteadOfLoop.d.ts +8 -0
- package/types/main/rules/TransformInsteadOfLoop.d.ts.map +1 -0
- package/types/main/rules/TriggerOrder.d.ts +8 -0
- package/types/main/rules/TriggerOrder.d.ts.map +1 -0
- package/types/main/rules/UnconnectedElement.d.ts +8 -0
- package/types/main/rules/UnconnectedElement.d.ts.map +1 -0
- package/types/main/rules/UnsafeRunningContext.d.ts +8 -0
- package/types/main/rules/UnsafeRunningContext.d.ts.map +1 -0
- package/types/main/rules/UnusedVariable.d.ts +8 -0
- package/types/main/rules/UnusedVariable.d.ts.map +1 -0
- package/types/main/store/DefaultRuleStore.d.ts +3 -0
- package/types/main/store/DefaultRuleStore.d.ts.map +1 -0
- package/types/main/store/RuleRegistry.d.ts +23 -0
- package/types/main/store/RuleRegistry.d.ts.map +1 -0
- package/vite.config.ts +33 -0
- package/README.md +0 -635
- /package/{index.d.ts → out/index.d.ts} +0 -0
- /package/{index.js → out/index.js} +0 -0
- /package/{main → out/main}/config/NodeIcons.d.ts +0 -0
- /package/{main → out/main}/config/NodeIcons.js +0 -0
- /package/{main → out/main}/config/RuleRegistry.d.ts +0 -0
- /package/{main → out/main}/config/VariableIcons.d.ts +0 -0
- /package/{main → out/main}/config/VariableIcons.js +0 -0
- /package/{main → out/main}/enums/MetadataTypes.d.ts +0 -0
- /package/{main → out/main}/enums/MetadataTypes.js +0 -0
- /package/{main → out/main}/interfaces/IExceptions.d.ts +0 -0
- /package/{main → out/main}/interfaces/IExceptions.js +0 -0
- /package/{main → out/main}/interfaces/IRuleConfig.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleConfig.js +0 -0
- /package/{main → out/main}/interfaces/IRuleDefinition.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleDefinition.js +0 -0
- /package/{main → out/main}/interfaces/IRuleOptions.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRuleOptions.js +0 -0
- /package/{main → out/main}/interfaces/IRulesConfig.d.ts +0 -0
- /package/{main → out/main}/interfaces/IRulesConfig.js +0 -0
- /package/{main → out/main}/internals/internals.d.ts +0 -0
- /package/{main → out/main}/internals/internals.js +0 -0
- /package/{main → out/main}/libs/BuildFlow.d.ts +0 -0
- /package/{main → out/main}/libs/BuildFlow.js +0 -0
- /package/{main → out/main}/libs/Compiler.d.ts +0 -0
- /package/{main → out/main}/libs/Compiler.js +0 -0
- /package/{main → out/main}/libs/ExportDetails.d.ts +0 -0
- /package/{main → out/main}/libs/ExportDetails.js +0 -0
- /package/{main → out/main}/libs/ExportDiagram.d.ts +0 -0
- /package/{main → out/main}/libs/ExportDiagram.js +0 -0
- /package/{main → out/main}/libs/ExportSarif.d.ts +0 -0
- /package/{main → out/main}/libs/ExportSarif.js +0 -0
- /package/{main → out/main}/libs/FixFlows.d.ts +0 -0
- /package/{main → out/main}/libs/FixFlows.js +0 -0
- /package/{main → out/main}/libs/GetRuleDefinitions.d.ts +0 -0
- /package/{main → out/main}/libs/GetRuleDefinitions.js +0 -0
- /package/{main → out/main}/libs/ParseFlows.d.ts +0 -0
- /package/{main → out/main}/libs/ParseFlows.js +0 -0
- /package/{main → out/main}/libs/RuleDocumentation.d.ts +0 -0
- /package/{main → out/main}/libs/RuleDocumentation.js +0 -0
- /package/{main → out/main}/libs/ScanFlows.d.ts +0 -0
- /package/{main → out/main}/libs/ScanFlows.js +0 -0
- /package/{main → out/main}/models/FlatViolation.d.ts +0 -0
- /package/{main → out/main}/models/FlatViolation.js +0 -0
- /package/{main → out/main}/models/Flow.d.ts +0 -0
- /package/{main → out/main}/models/Flow.js +0 -0
- /package/{main → out/main}/models/FlowAttribute.d.ts +0 -0
- /package/{main → out/main}/models/FlowAttribute.js +0 -0
- /package/{main → out/main}/models/FlowElement.d.ts +0 -0
- /package/{main → out/main}/models/FlowElement.js +0 -0
- /package/{main → out/main}/models/FlowElementConnector.d.ts +0 -0
- /package/{main → out/main}/models/FlowElementConnector.js +0 -0
- /package/{main → out/main}/models/FlowGraph.d.ts +0 -0
- /package/{main → out/main}/models/FlowGraph.js +0 -0
- /package/{main → out/main}/models/FlowMetadata.d.ts +0 -0
- /package/{main → out/main}/models/FlowMetadata.js +0 -0
- /package/{main → out/main}/models/FlowNode.d.ts +0 -0
- /package/{main → out/main}/models/FlowNode.js +0 -0
- /package/{main → out/main}/models/FlowResource.d.ts +0 -0
- /package/{main → out/main}/models/FlowResource.js +0 -0
- /package/{main → out/main}/models/FlowType.d.ts +0 -0
- /package/{main → out/main}/models/FlowType.js +0 -0
- /package/{main → out/main}/models/FlowVariable.d.ts +0 -0
- /package/{main → out/main}/models/FlowVariable.js +0 -0
- /package/{main → out/main}/models/LoopRuleCommon.d.ts +0 -0
- /package/{main → out/main}/models/LoopRuleCommon.js +0 -0
- /package/{main → out/main}/models/ParsedFlow.d.ts +0 -0
- /package/{main → out/main}/models/ParsedFlow.js +0 -0
- /package/{main → out/main}/models/RuleCommon.d.ts +0 -0
- /package/{main → out/main}/models/RuleCommon.js +0 -0
- /package/{main → out/main}/models/RuleInfo.d.ts +0 -0
- /package/{main → out/main}/models/RuleInfo.js +0 -0
- /package/{main → out/main}/models/RuleResult.d.ts +0 -0
- /package/{main → out/main}/models/RuleResult.js +0 -0
- /package/{main → out/main}/models/ScanResult.d.ts +0 -0
- /package/{main → out/main}/models/ScanResult.js +0 -0
- /package/{main → out/main}/models/Violation.d.ts +0 -0
- /package/{main → out/main}/models/Violation.js +0 -0
- /package/{main → out/main}/rules/APIVersion.d.ts +0 -0
- /package/{main → out/main}/rules/APIVersion.js +0 -0
- /package/{main → out/main}/rules/ActionCallsInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/ActionCallsInLoop.js +0 -0
- /package/{main → out/main}/rules/AutoLayout.d.ts +0 -0
- /package/{main → out/main}/rules/AutoLayout.js +0 -0
- /package/{main → out/main}/rules/CopyAPIName.d.ts +0 -0
- /package/{main → out/main}/rules/CopyAPIName.js +0 -0
- /package/{main → out/main}/rules/CyclomaticComplexity.d.ts +0 -0
- /package/{main → out/main}/rules/CyclomaticComplexity.js +0 -0
- /package/{main → out/main}/rules/DMLStatementInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/DMLStatementInLoop.js +0 -0
- /package/{main → out/main}/rules/DuplicateDMLOperation.d.ts +0 -0
- /package/{main → out/main}/rules/DuplicateDMLOperation.js +0 -0
- /package/{main → out/main}/rules/FlowDescription.d.ts +0 -0
- /package/{main → out/main}/rules/FlowDescription.js +0 -0
- /package/{main → out/main}/rules/GetRecordAllFields.d.ts +0 -0
- /package/{main → out/main}/rules/GetRecordAllFields.js +0 -0
- /package/{main → out/main}/rules/InactiveFlow.d.ts +0 -0
- /package/{main → out/main}/rules/InactiveFlow.js +0 -0
- /package/{main → out/main}/rules/MissingFaultPath.d.ts +0 -0
- /package/{main → out/main}/rules/MissingFaultPath.js +0 -0
- /package/{main → out/main}/rules/MissingMetadataDescription.d.ts +0 -0
- /package/{main → out/main}/rules/MissingMetadataDescription.js +0 -0
- /package/{main → out/main}/rules/MissingNullHandler.d.ts +0 -0
- /package/{main → out/main}/rules/MissingNullHandler.js +0 -0
- /package/{main → out/main}/rules/MissingRecordTriggerFilter.d.ts +0 -0
- /package/{main → out/main}/rules/MissingRecordTriggerFilter.js +0 -0
- /package/{main → out/main}/rules/ProcessBuilder.d.ts +0 -0
- /package/{main → out/main}/rules/ProcessBuilder.js +0 -0
- /package/{main → out/main}/rules/RecordIdAsString.d.ts +0 -0
- /package/{main → out/main}/rules/RecordIdAsString.js +0 -0
- /package/{main → out/main}/rules/RecursiveAfterUpdate.d.ts +0 -0
- /package/{main → out/main}/rules/RecursiveAfterUpdate.js +0 -0
- /package/{main → out/main}/rules/SOQLQueryInLoop.d.ts +0 -0
- /package/{main → out/main}/rules/SOQLQueryInLoop.js +0 -0
- /package/{main → out/main}/rules/SameRecordFieldUpdates.d.ts +0 -0
- /package/{main → out/main}/rules/SameRecordFieldUpdates.js +0 -0
- /package/{main → out/main}/rules/TransformInsteadOfLoop.d.ts +0 -0
- /package/{main → out/main}/rules/TransformInsteadOfLoop.js +0 -0
- /package/{main → out/main}/rules/TriggerOrder.d.ts +0 -0
- /package/{main → out/main}/rules/TriggerOrder.js +0 -0
- /package/{main → out/main}/rules/UnconnectedElement.d.ts +0 -0
- /package/{main → out/main}/rules/UnconnectedElement.js +0 -0
- /package/{main → out/main}/rules/UnsafeRunningContext.d.ts +0 -0
- /package/{main → out/main}/rules/UnsafeRunningContext.js +0 -0
- /package/{main → out/main}/rules/UnusedVariable.d.ts +0 -0
- /package/{main → out/main}/rules/UnusedVariable.js +0 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
import { FlowNode } from "./FlowNode";
|
|
2
|
+
import { Compiler } from "../libs/Compiler";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* FlowGraph: Pre-computed connectivity cache built using Compiler.
|
|
6
|
+
* Built once during Flow.preProcessNodes() to avoid repeated traversals.
|
|
7
|
+
*
|
|
8
|
+
* Uses the existing Compiler to build the graph - no duplicate logic!
|
|
9
|
+
*/
|
|
10
|
+
export class FlowGraph {
|
|
11
|
+
// Fast lookups by element name
|
|
12
|
+
private nodeMap: Map<string, FlowNode> = new Map();
|
|
13
|
+
|
|
14
|
+
// Pre-computed sets for common queries (built using Compiler)
|
|
15
|
+
private reachableFromStart: Set<string> = new Set();
|
|
16
|
+
private elementsInLoop: Map<string, string> = new Map(); // element -> loop name
|
|
17
|
+
|
|
18
|
+
// Connector metadata (extracted during node processing)
|
|
19
|
+
private faultConnectors: Map<string, Set<string>> = new Map();
|
|
20
|
+
private normalConnectors: Map<string, Set<string>> = new Map();
|
|
21
|
+
private allConnectors: Map<string, Set<string>> = new Map();
|
|
22
|
+
private reverseConnectors: Map<string, Set<string>> = new Map();
|
|
23
|
+
|
|
24
|
+
constructor(nodes: FlowNode[], startReference?: string, startNode?: FlowNode) {
|
|
25
|
+
this.buildNodeMaps(nodes);
|
|
26
|
+
this.buildConnectorMaps(nodes);
|
|
27
|
+
|
|
28
|
+
// ALWAYS ensure START node edges exist
|
|
29
|
+
if (startNode) {
|
|
30
|
+
// Old flows: use explicit <start> element connectors
|
|
31
|
+
this.addStartNodeConnectors(startNode);
|
|
32
|
+
} else if (startReference) {
|
|
33
|
+
// New flows: direct edge from START to startElementReference
|
|
34
|
+
this.addStartEdgeFromReference(startReference);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
this.computeLoopBoundaries();
|
|
38
|
+
if (startReference) {
|
|
39
|
+
this.computeReachability(startReference);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Add START node connectors to the connector maps (for flows with explicit <start> element)
|
|
45
|
+
*/
|
|
46
|
+
private addStartNodeConnectors(startNode: FlowNode): void {
|
|
47
|
+
const startName = 'START';
|
|
48
|
+
|
|
49
|
+
this.faultConnectors.set(startName, new Set());
|
|
50
|
+
this.normalConnectors.set(startName, new Set());
|
|
51
|
+
this.allConnectors.set(startName, new Set());
|
|
52
|
+
|
|
53
|
+
if (!startNode.connectors || startNode.connectors.length === 0) return;
|
|
54
|
+
|
|
55
|
+
for (const connector of startNode.connectors) {
|
|
56
|
+
const targetRef = connector.connectorTargetReference?.targetReference ?? connector.reference;
|
|
57
|
+
if (!targetRef) continue;
|
|
58
|
+
|
|
59
|
+
// START node typically has normal connectors, not fault connectors
|
|
60
|
+
this.normalConnectors.get(startName)?.add(targetRef);
|
|
61
|
+
this.allConnectors.get(startName)?.add(targetRef);
|
|
62
|
+
|
|
63
|
+
// Build reverse map
|
|
64
|
+
if (!this.reverseConnectors.has(targetRef)) {
|
|
65
|
+
this.reverseConnectors.set(targetRef, new Set());
|
|
66
|
+
}
|
|
67
|
+
this.reverseConnectors.get(targetRef)?.add(startName);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Add START edge for newer flows that use startElementReference (no explicit <start> node)
|
|
73
|
+
*/
|
|
74
|
+
private addStartEdgeFromReference(startReference: string): void {
|
|
75
|
+
const startName = 'START';
|
|
76
|
+
|
|
77
|
+
this.faultConnectors.set(startName, new Set());
|
|
78
|
+
this.normalConnectors.set(startName, new Set());
|
|
79
|
+
this.allConnectors.set(startName, new Set());
|
|
80
|
+
|
|
81
|
+
// Direct edge: START --> first element
|
|
82
|
+
this.normalConnectors.get(startName)?.add(startReference);
|
|
83
|
+
this.allConnectors.get(startName)?.add(startReference);
|
|
84
|
+
|
|
85
|
+
// Build reverse map
|
|
86
|
+
if (!this.reverseConnectors.has(startReference)) {
|
|
87
|
+
this.reverseConnectors.set(startReference, new Set());
|
|
88
|
+
}
|
|
89
|
+
this.reverseConnectors.get(startReference)?.add(startName);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Build node map for O(1) lookups
|
|
94
|
+
*/
|
|
95
|
+
private buildNodeMaps(nodes: FlowNode[]): void {
|
|
96
|
+
for (const node of nodes) {
|
|
97
|
+
this.nodeMap.set(node.name, node);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Build connector maps by inspecting node connectors
|
|
103
|
+
*/
|
|
104
|
+
private buildConnectorMaps(nodes: FlowNode[]): void {
|
|
105
|
+
for (const node of nodes) {
|
|
106
|
+
this.faultConnectors.set(node.name, new Set());
|
|
107
|
+
this.normalConnectors.set(node.name, new Set());
|
|
108
|
+
this.allConnectors.set(node.name, new Set());
|
|
109
|
+
if (!node.connectors || node.connectors.length === 0) continue;
|
|
110
|
+
for (const connector of node.connectors) {
|
|
111
|
+
const targetRef = connector.connectorTargetReference?.targetReference ?? connector.reference;
|
|
112
|
+
if (!targetRef) continue;
|
|
113
|
+
// Categorize by connector type
|
|
114
|
+
if (connector.type === "faultConnector") {
|
|
115
|
+
this.faultConnectors.get(node.name)?.add(targetRef);
|
|
116
|
+
} else {
|
|
117
|
+
this.normalConnectors.get(node.name)?.add(targetRef);
|
|
118
|
+
}
|
|
119
|
+
this.allConnectors.get(node.name)?.add(targetRef);
|
|
120
|
+
// Build reverse map for "previous elements" queries
|
|
121
|
+
if (!this.reverseConnectors.has(targetRef)) {
|
|
122
|
+
this.reverseConnectors.set(targetRef, new Set());
|
|
123
|
+
}
|
|
124
|
+
this.reverseConnectors.get(targetRef)?.add(node.name);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Use Compiler to compute which elements are reachable from start.
|
|
131
|
+
* This reuses the existing IDDFS traversal logic!
|
|
132
|
+
*/
|
|
133
|
+
private computeReachability(startReference: string): void {
|
|
134
|
+
const compiler = new Compiler();
|
|
135
|
+
compiler.traverseFlow(startReference, (element) => {
|
|
136
|
+
this.reachableFromStart.add(element.name);
|
|
137
|
+
}, this.nodeMap, this.allConnectors);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Use Compiler to compute which elements are inside loops.
|
|
142
|
+
* Calls Compiler.traverseFlow() for each loop with endElementName.
|
|
143
|
+
*/
|
|
144
|
+
private computeLoopBoundaries(): void {
|
|
145
|
+
const loopNodes = Array.from(this.nodeMap.values()).filter(n => n.subtype === "loops");
|
|
146
|
+
for (const loopNode of loopNodes) {
|
|
147
|
+
// Find loop end (noMoreValuesConnector)
|
|
148
|
+
const loopEnd = (loopNode.element as any)?.noMoreValuesConnector?.targetReference ?? loopNode.name;
|
|
149
|
+
// Use Compiler to find all elements between loop start and end
|
|
150
|
+
const compiler = new Compiler();
|
|
151
|
+
compiler.traverseFlow(loopNode.name, (element) => {
|
|
152
|
+
this.elementsInLoop.set(element.name, loopNode.name);
|
|
153
|
+
}, this.nodeMap, this.allConnectors, loopEnd); // Pass endElementName to stop at loop boundary
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ========== PUBLIC QUERY API ==========
|
|
158
|
+
public isReachable(elementName: string): boolean {
|
|
159
|
+
return this.reachableFromStart.has(elementName);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public getReachableElements(): Set<string> {
|
|
163
|
+
return new Set(this.reachableFromStart);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public isInLoop(elementName: string): boolean {
|
|
167
|
+
return this.elementsInLoop.has(elementName);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public getContainingLoop(elementName: string): string | undefined {
|
|
171
|
+
return this.elementsInLoop.get(elementName);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public getLoopElements(loopName: string): Set<string> {
|
|
175
|
+
const result = new Set<string>();
|
|
176
|
+
for (const [element, loop] of this.elementsInLoop) {
|
|
177
|
+
if (loop === loopName) {
|
|
178
|
+
result.add(element);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return result;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
public hasFaultConnector(elementName: string): boolean {
|
|
185
|
+
const faults = this.faultConnectors.get(elementName);
|
|
186
|
+
return faults ? faults.size > 0 : false;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public getFaultTargets(elementName: string): string[] {
|
|
190
|
+
return Array.from(this.faultConnectors.get(elementName) || []);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public getNextElements(elementName: string): string[] {
|
|
194
|
+
return Array.from(this.normalConnectors.get(elementName) || []);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
public getAllNextElements(elementName: string): string[] {
|
|
198
|
+
return Array.from(this.allConnectors.get(elementName) || []);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
public getPreviousElements(elementName: string): string[] {
|
|
202
|
+
return Array.from(this.reverseConnectors.get(elementName) || []);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public getNode(elementName: string): FlowNode | undefined {
|
|
206
|
+
return this.nodeMap.get(elementName);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public isPartOfFaultHandling(elementName: string): boolean {
|
|
210
|
+
const previous = this.getPreviousElements(elementName);
|
|
211
|
+
return previous.some(prev => {
|
|
212
|
+
const faultTargets = this.faultConnectors.get(prev);
|
|
213
|
+
return faultTargets?.has(elementName) ?? false;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public getLoopNodes(): FlowNode[] {
|
|
218
|
+
return Array.from(this.nodeMap.values()).filter(n => n.subtype === "loops");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public forEachReachable(callback: (node: FlowNode) => void): void {
|
|
222
|
+
for (const elementName of this.reachableFromStart) {
|
|
223
|
+
const node = this.nodeMap.get(elementName);
|
|
224
|
+
if (node) {
|
|
225
|
+
callback(node);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Export the graph to Mermaid flowchart syntax with rich documentation.
|
|
233
|
+
*/
|
|
234
|
+
public toMermaid(options: {
|
|
235
|
+
includeDetails?: boolean;
|
|
236
|
+
includeMarkdownDocs?: boolean;
|
|
237
|
+
collapsedDetails?: boolean;
|
|
238
|
+
flowMetadata?: any;
|
|
239
|
+
} = {}): string {
|
|
240
|
+
let output = "";
|
|
241
|
+
|
|
242
|
+
const diagram = this.generateMermaidDiagram(options);
|
|
243
|
+
|
|
244
|
+
if (options.includeMarkdownDocs) {
|
|
245
|
+
output = this.generateFullMarkdownDoc(diagram, options);
|
|
246
|
+
} else {
|
|
247
|
+
output = `\`\`\`mermaid\n${diagram}\n\`\`\``;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return output;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
private generateMermaidDiagram(options: any): string {
|
|
254
|
+
let mermaid = 'flowchart TB\n';
|
|
255
|
+
|
|
256
|
+
// START node with flow metadata
|
|
257
|
+
mermaid += this.generateStartNode(options.flowMetadata) + '\n\n';
|
|
258
|
+
|
|
259
|
+
// Define nodes using FlowNode helper methods
|
|
260
|
+
for (const [name, node] of this.nodeMap) {
|
|
261
|
+
const icon = node.getIcon();
|
|
262
|
+
const typeLabel = node.getTypeLabel();
|
|
263
|
+
const summary = options.includeDetails ? node.getSummary() : '';
|
|
264
|
+
|
|
265
|
+
let label = `${icon} <em>${typeLabel}</em><br/>${node.label || node.name}`;
|
|
266
|
+
if (summary) {
|
|
267
|
+
label += `<br/><small>${summary}</small>`;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const shape = this.getNodeShape(node.subtype);
|
|
271
|
+
mermaid += ` ${name}${shape[0]}"${label}"${shape[1]}:::${node.subtype}\n`;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
mermaid += '\n';
|
|
275
|
+
mermaid += this.generateEdges() + '\n';
|
|
276
|
+
mermaid += this.generateLoopSubgraphs() + '\n';
|
|
277
|
+
mermaid += this.generateMermaidStyles();
|
|
278
|
+
|
|
279
|
+
return mermaid;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
private generateStartNode(flowMetadata?: any): string {
|
|
283
|
+
if (!flowMetadata) {
|
|
284
|
+
return 'START(["\uD83D\uDE80 <b>START</b>"]):::startClass';
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
let label = '\uD83D\uDE80 <b>START</b>'; // ROCKET
|
|
288
|
+
|
|
289
|
+
if (flowMetadata.processType === 'Flow') {
|
|
290
|
+
label += '<br/><b>Screen Flow</b>';
|
|
291
|
+
} else if (flowMetadata.processType === 'AutoLaunchedFlow') {
|
|
292
|
+
label += '<br/><b>AutoLaunched Flow</b>';
|
|
293
|
+
if (flowMetadata.triggerType) {
|
|
294
|
+
label += `<br/>Type: <b>${this.prettifyValue(flowMetadata.triggerType)}</b>`;
|
|
295
|
+
}
|
|
296
|
+
} else if (flowMetadata.object) {
|
|
297
|
+
label += `<br/><b>${flowMetadata.object}</b>`;
|
|
298
|
+
if (flowMetadata.triggerType) {
|
|
299
|
+
label += `<br/>Type: <b>${this.prettifyValue(flowMetadata.triggerType)}</b>`;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (flowMetadata.status) {
|
|
304
|
+
const statusIcon = flowMetadata.status === 'Active' ? '✅' : '⚠️';
|
|
305
|
+
label += `<br/>${statusIcon} ${flowMetadata.status}`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return `START(["${label}"]):::startClass`;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private getNodeShape(subtype: string): [string, string] {
|
|
312
|
+
const shapeMap: Record<string, [string, string]> = {
|
|
313
|
+
decisions: ['{', '}'],
|
|
314
|
+
loops: ['{{', '}}'],
|
|
315
|
+
collectionProcessors: ['{{', '}}'],
|
|
316
|
+
transforms: ['{{', '}}'],
|
|
317
|
+
screens: ['([', '])'],
|
|
318
|
+
recordCreates: ['[(', ')]'],
|
|
319
|
+
recordDeletes: ['[(', ')]'],
|
|
320
|
+
recordLookups: ['[(', ')]'],
|
|
321
|
+
recordUpdates: ['[(', ')]'],
|
|
322
|
+
subflows: ['[[', ']]'],
|
|
323
|
+
assignments: ['[\\', '/]'],
|
|
324
|
+
default: ['(', ')']
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
return shapeMap[subtype] || shapeMap.default;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
private generateEdges(): string {
|
|
331
|
+
let edges = '';
|
|
332
|
+
|
|
333
|
+
// Normal connectors
|
|
334
|
+
for (const [from, targets] of this.allConnectors) {
|
|
335
|
+
for (const to of targets) {
|
|
336
|
+
edges += ` ${from} --> ${to}\n`;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// Fault connectors (dashed)
|
|
341
|
+
for (const [from, faults] of this.faultConnectors) {
|
|
342
|
+
for (const to of faults) {
|
|
343
|
+
edges += ` ${from} -. Fault .-> ${to}\n`;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
// Add END nodes
|
|
348
|
+
const endNodes = this.findEndNodes();
|
|
349
|
+
for (const endNode of endNodes) {
|
|
350
|
+
edges += ` ${endNode}(( END )):::endClass\n`;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return edges;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private findEndNodes(): Set<string> {
|
|
357
|
+
const endNodes = new Set<string>();
|
|
358
|
+
|
|
359
|
+
for (const [from, targets] of this.allConnectors) {
|
|
360
|
+
for (const to of targets) {
|
|
361
|
+
// If target doesn't exist in nodeMap, it's an END
|
|
362
|
+
if (!this.nodeMap.has(to)) {
|
|
363
|
+
endNodes.add(to);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return endNodes;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
private generateLoopSubgraphs(): string {
|
|
372
|
+
let subgraphs = '';
|
|
373
|
+
|
|
374
|
+
for (const loopNode of this.getLoopNodes()) {
|
|
375
|
+
const loopElems = this.getLoopElements(loopNode.name);
|
|
376
|
+
if (loopElems.size > 0) {
|
|
377
|
+
subgraphs += ` subgraph "${loopNode.label || loopNode.name} Loop"\n`;
|
|
378
|
+
for (const elem of loopElems) {
|
|
379
|
+
subgraphs += ` ${elem}\n`;
|
|
380
|
+
}
|
|
381
|
+
subgraphs += ' end\n';
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return subgraphs;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
private generateMermaidStyles(): string {
|
|
389
|
+
const styles = {
|
|
390
|
+
actionCalls: { fill: '#D4E4FC', color: 'black' },
|
|
391
|
+
assignments: { fill: '#FBEED7', color: 'black' },
|
|
392
|
+
collectionProcessors: { fill: '#F0E3FA', color: 'black' },
|
|
393
|
+
customErrors: { fill: '#FFE9E9', color: 'black' },
|
|
394
|
+
decisions: { fill: '#FDEAF6', color: 'black' },
|
|
395
|
+
loops: { fill: '#FDEAF6', color: 'black' },
|
|
396
|
+
recordCreates: { fill: '#FFF8C9', color: 'black' },
|
|
397
|
+
recordDeletes: { fill: '#FFF8C9', color: 'black' },
|
|
398
|
+
recordLookups: { fill: '#EDEAFF', color: 'black' },
|
|
399
|
+
recordUpdates: { fill: '#FFF8C9', color: 'black' },
|
|
400
|
+
screens: { fill: '#DFF6FF', color: 'black' },
|
|
401
|
+
subflows: { fill: '#D4E4FC', color: 'black' },
|
|
402
|
+
transforms: { fill: '#FDEAF6', color: 'black' },
|
|
403
|
+
startClass: { fill: '#D9F2E6', color: 'black' },
|
|
404
|
+
endClass: { fill: '#F9BABA', color: 'black' },
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
let styleStr = '';
|
|
408
|
+
for (const [className, style] of Object.entries(styles)) {
|
|
409
|
+
styleStr += ` classDef ${className} fill:${style.fill},color:${style.color},stroke:#333,stroke-width:2px\n`;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return styleStr;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
private generateNodeDetailsMarkdown(collapsed: boolean): string {
|
|
416
|
+
let md = '## Flow Nodes Details\n\n';
|
|
417
|
+
|
|
418
|
+
if (collapsed) {
|
|
419
|
+
md += '<details><summary>NODE DETAILS (expand to view)</summary>\n\n';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
for (const [name, node] of this.nodeMap) {
|
|
423
|
+
md += `### ${name}\n\n`;
|
|
424
|
+
md += this.nodeToMarkdownTable(node);
|
|
425
|
+
md += '\n';
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
if (collapsed) {
|
|
429
|
+
md += '</details>\n\n';
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
return md;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
private nodeToMarkdownTable(node: FlowNode): string {
|
|
436
|
+
let table = '| Property | Value |\n|:---|:---|\n';
|
|
437
|
+
|
|
438
|
+
// Use typed properties from FlowNode
|
|
439
|
+
if (node.label) table += `| Label | ${node.label} |\n`;
|
|
440
|
+
table += `| Type | ${node.getTypeLabel()} |\n`;
|
|
441
|
+
|
|
442
|
+
// Type-specific properties (now type-safe!)
|
|
443
|
+
if (node.actionType) table += `| Action Type | ${this.prettifyValue(node.actionType)} |\n`;
|
|
444
|
+
if (node.actionName) table += `| Action Name | ${node.actionName} |\n`;
|
|
445
|
+
if (node.object) table += `| Object | ${node.object} |\n`;
|
|
446
|
+
if (node.flowName) table += `| Subflow | ${node.flowName} |\n`;
|
|
447
|
+
if (node.collectionReference) table += `| Collection | ${node.collectionReference} |\n`;
|
|
448
|
+
if (node.elementSubtype) table += `| Subtype | ${this.prettifyValue(node.elementSubtype)} |\n`;
|
|
449
|
+
|
|
450
|
+
// Decision rules
|
|
451
|
+
if (node.rules && node.rules.length > 0) {
|
|
452
|
+
table += `| Rules | ${node.rules.length} |\n`;
|
|
453
|
+
for (const rule of node.rules) {
|
|
454
|
+
const conditions = Array.isArray(rule.conditions) ? rule.conditions :
|
|
455
|
+
rule.conditions ? [rule.conditions] : [];
|
|
456
|
+
table += `| ↳ ${rule.label || rule.name} | ${conditions.length} condition(s) |\n`;
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Screen fields
|
|
461
|
+
if (node.fields && node.fields.length > 0) {
|
|
462
|
+
table += `| Fields | ${node.fields.length} |\n`;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (node.description) table += `| Description | ${node.description} |\n`;
|
|
466
|
+
if (node.faultConnector) table += `| Has Fault Handler | ✅ |\n`;
|
|
467
|
+
|
|
468
|
+
return table;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
private prettifyValue(value: string): string {
|
|
472
|
+
return value
|
|
473
|
+
.replace(/([A-Z])/g, ' $1')
|
|
474
|
+
.replace(/^./, str => str.toUpperCase())
|
|
475
|
+
.trim();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Generate full markdown documentation with diagram and node details
|
|
480
|
+
*/
|
|
481
|
+
private generateFullMarkdownDoc(diagram: string, options: any): string {
|
|
482
|
+
let md = '';
|
|
483
|
+
|
|
484
|
+
// Header with flow metadata would come from Flow class
|
|
485
|
+
md += '## Flow Diagram\n\n';
|
|
486
|
+
md += '```mermaid\n';
|
|
487
|
+
md += diagram;
|
|
488
|
+
md += '\n```\n\n';
|
|
489
|
+
|
|
490
|
+
// Node details section
|
|
491
|
+
if (options.includeDetails) {
|
|
492
|
+
md += this.generateNodeDetailsMarkdown(options.collapsedDetails);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
return md;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Export the graph to PlantUML syntax for UML-style diagrams.
|
|
500
|
+
* @returns PlantUML string.
|
|
501
|
+
*/
|
|
502
|
+
public toPlantUML(): string {
|
|
503
|
+
let plantuml = '@startuml\nskinparam activityBackgroundColor #D4E4FC\n'; // Basic styling
|
|
504
|
+
|
|
505
|
+
// Nodes
|
|
506
|
+
for (const [name, node] of this.nodeMap) {
|
|
507
|
+
plantuml += `activity "${node.subtype}: ${name}" as ${name}\n`;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// Edges
|
|
511
|
+
for (const [from, targets] of this.allConnectors) {
|
|
512
|
+
for (const to of targets) {
|
|
513
|
+
plantuml += `${from} --> ${to}\n`;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// Loops as groups
|
|
518
|
+
for (const loopNode of this.getLoopNodes()) {
|
|
519
|
+
plantuml += `partition "${loopNode.name} Loop" {\n`;
|
|
520
|
+
const loopElems = this.getLoopElements(loopNode.name);
|
|
521
|
+
for (const elem of loopElems) {
|
|
522
|
+
plantuml += ` ${elem}\n`;
|
|
523
|
+
}
|
|
524
|
+
plantuml += '}\n';
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
plantuml += '@enduml';
|
|
528
|
+
return plantuml;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { MetaType } from "../enums/MetadataTypes";
|
|
2
|
+
import { FlowElement } from "./FlowElement";
|
|
3
|
+
|
|
4
|
+
export class FlowMetadata extends FlowElement {
|
|
5
|
+
constructor(name: string, subtype: string, element: object) {
|
|
6
|
+
super(MetaType.ATTRIBUTE, subtype, name, element);
|
|
7
|
+
}
|
|
8
|
+
}
|