@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,16 @@
|
|
|
1
|
+
import { Violation } from "./Violation";
|
|
2
|
+
|
|
3
|
+
export interface FlatViolation extends Omit<Violation, 'details'> {
|
|
4
|
+
flowFile: string;
|
|
5
|
+
flowName: string;
|
|
6
|
+
ruleId: string; // Canonical rule ID (e.g., "dml-in-loop")
|
|
7
|
+
ruleName: string; // Legacy class name (e.g., "DMLStatementInLoop")
|
|
8
|
+
severity: string;
|
|
9
|
+
message?: string; // Custom message overriding the default rule description
|
|
10
|
+
messageUrl?: string; // URL to custom documentation
|
|
11
|
+
dataType?: string;
|
|
12
|
+
locationX?: string;
|
|
13
|
+
locationY?: string;
|
|
14
|
+
connectsTo?: string;
|
|
15
|
+
expression?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import { XMLBuilder } from "fast-xml-parser";
|
|
2
|
+
import * as p from "path";
|
|
3
|
+
import { FlowElement } from "./FlowElement";
|
|
4
|
+
import { FlowMetadata } from "./FlowMetadata";
|
|
5
|
+
import { FlowNode } from "./FlowNode";
|
|
6
|
+
import { FlowResource } from "./FlowResource";
|
|
7
|
+
import { FlowVariable } from "./FlowVariable";
|
|
8
|
+
import { FlowGraph } from "./FlowGraph";
|
|
9
|
+
|
|
10
|
+
export class Flow {
|
|
11
|
+
/**
|
|
12
|
+
* Metadata Tags of Salesforce Flow Attributes
|
|
13
|
+
*/
|
|
14
|
+
public static readonly ATTRIBUTE_TAGS = [
|
|
15
|
+
"apiVersion",
|
|
16
|
+
"areMetricsLoggedToDataCloud",
|
|
17
|
+
"description",
|
|
18
|
+
"environments",
|
|
19
|
+
"fullName",
|
|
20
|
+
"interviewLabel",
|
|
21
|
+
"isAdditionalPermissionRequiredToRun",
|
|
22
|
+
"isTemplate",
|
|
23
|
+
"label",
|
|
24
|
+
"migratedFromWorkflowRuleName",
|
|
25
|
+
"processMetadataValues",
|
|
26
|
+
"processType",
|
|
27
|
+
"runInMode",
|
|
28
|
+
"segment",
|
|
29
|
+
"startElementReference",
|
|
30
|
+
"status",
|
|
31
|
+
"timeZoneSidKey",
|
|
32
|
+
"triggerOrder"
|
|
33
|
+
] as const;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Metadata Tags of Salesforce Flow Nodes
|
|
37
|
+
*/
|
|
38
|
+
public static readonly NODE_TAGS = [
|
|
39
|
+
"actionCalls",
|
|
40
|
+
"apexPluginCalls",
|
|
41
|
+
"assignments",
|
|
42
|
+
"collectionProcessors",
|
|
43
|
+
"decisions",
|
|
44
|
+
"loops",
|
|
45
|
+
"orchestratedStages",
|
|
46
|
+
"recordCreates",
|
|
47
|
+
"recordDeletes",
|
|
48
|
+
"recordLookups",
|
|
49
|
+
"recordUpdates",
|
|
50
|
+
"recordRollbacks",
|
|
51
|
+
"screens",
|
|
52
|
+
"steps",
|
|
53
|
+
"subflows",
|
|
54
|
+
"waits",
|
|
55
|
+
"transforms",
|
|
56
|
+
"customErrors",
|
|
57
|
+
] as const;
|
|
58
|
+
|
|
59
|
+
public static readonly RESOURCE_TAGS = ["textTemplates", "stages"] as const;
|
|
60
|
+
public static readonly VARIABLE_TAGS = ["choices", "constants", "dynamicChoiceSets", "formulas", "variables"] as const;
|
|
61
|
+
|
|
62
|
+
// Flow elements (excludes legacy start nodes)
|
|
63
|
+
public elements: FlowElement[] = [];
|
|
64
|
+
|
|
65
|
+
// Path properties
|
|
66
|
+
public fsPath?: string; // Resolved absolute path (Node.js only)
|
|
67
|
+
public uri?: string; // Input path (could be relative, absolute, or virtual)
|
|
68
|
+
|
|
69
|
+
// Flow metadata
|
|
70
|
+
public label: string = "";
|
|
71
|
+
public interviewLabel?: string;
|
|
72
|
+
public name: string = "unnamed";
|
|
73
|
+
public processMetadataValues?: any;
|
|
74
|
+
public processType: string = "AutoLaunchedFlow";
|
|
75
|
+
public type: string = ""; // Alias for processType (backward compatibility)
|
|
76
|
+
public status: string = "";
|
|
77
|
+
public triggerOrder?: number;
|
|
78
|
+
|
|
79
|
+
// Start-related properties
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Use startNode.element instead. Kept for backward compatibility.
|
|
82
|
+
*/
|
|
83
|
+
public start?: any;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Direct reference to first element (from XML attribute).
|
|
87
|
+
* Used in newer flows as an alternative to the start element.
|
|
88
|
+
*/
|
|
89
|
+
public startElementReference?: string;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Computed reference to the first element to execute.
|
|
93
|
+
* This is what rules should use for traversal.
|
|
94
|
+
*/
|
|
95
|
+
public startReference?: string;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Parsed FlowNode object of the start element.
|
|
99
|
+
* Contains trigger information and connectors.
|
|
100
|
+
* Access start element data via startNode.element
|
|
101
|
+
*/
|
|
102
|
+
public startNode?: FlowNode;
|
|
103
|
+
|
|
104
|
+
private _graph?: FlowGraph;
|
|
105
|
+
|
|
106
|
+
public get graph(): FlowGraph {
|
|
107
|
+
if (!this._graph) {
|
|
108
|
+
const flowNodes = this.elements.filter((e): e is FlowNode => e instanceof FlowNode);
|
|
109
|
+
this.startReference ||= this.findStart();
|
|
110
|
+
this._graph = new FlowGraph(flowNodes, this.startReference, this.startNode);
|
|
111
|
+
}
|
|
112
|
+
return this._graph;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Legacy/internal
|
|
116
|
+
public root?: any;
|
|
117
|
+
public xmldata: any;
|
|
118
|
+
|
|
119
|
+
constructor(path?: string, data?: unknown) {
|
|
120
|
+
if (path) {
|
|
121
|
+
this.uri = path;
|
|
122
|
+
|
|
123
|
+
if (typeof process !== 'undefined' && typeof process.cwd === 'function') {
|
|
124
|
+
this.fsPath = p.resolve(path);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let flowName = p.basename(p.basename(path), p.extname(path));
|
|
128
|
+
if (flowName.includes(".")) {
|
|
129
|
+
flowName = flowName.split(".")[0];
|
|
130
|
+
}
|
|
131
|
+
this.name = flowName || "unnamed";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (data) {
|
|
135
|
+
const hasFlowElement = typeof data === "object" && data !== null && "Flow" in data;
|
|
136
|
+
if (hasFlowElement) {
|
|
137
|
+
this.xmldata = (data as any).Flow;
|
|
138
|
+
} else {
|
|
139
|
+
this.xmldata = data;
|
|
140
|
+
}
|
|
141
|
+
this.preProcessNodes();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public static from(obj: Partial<Flow>): Flow {
|
|
146
|
+
if (obj instanceof Flow) {
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
const flow = Object.create(Flow.prototype);
|
|
150
|
+
Object.assign(flow, obj);
|
|
151
|
+
if (!flow.toXMLString) {
|
|
152
|
+
flow.toXMLString = () => '';
|
|
153
|
+
}
|
|
154
|
+
return flow;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public preProcessNodes() {
|
|
158
|
+
if (!this.xmldata) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// Extract top-level attributes
|
|
163
|
+
this.label = this.xmldata.label || "";
|
|
164
|
+
this.interviewLabel = this.xmldata.interviewLabel;
|
|
165
|
+
this.processType = this.xmldata.processType || "AutoLaunchedFlow";
|
|
166
|
+
this.type = this.processType;
|
|
167
|
+
this.processMetadataValues = this.xmldata.processMetadataValues;
|
|
168
|
+
this.startElementReference = this.xmldata.startElementReference;
|
|
169
|
+
this.status = this.xmldata.status || "Draft";
|
|
170
|
+
this.triggerOrder = this.xmldata.triggerOrder;
|
|
171
|
+
|
|
172
|
+
const allNodes: Array<FlowMetadata | FlowNode | FlowVariable | FlowResource> = [];
|
|
173
|
+
|
|
174
|
+
for (const nodeType in this.xmldata) {
|
|
175
|
+
// Skip xmlns and attributes
|
|
176
|
+
if (nodeType.startsWith("@_") || nodeType === "@xmlns") {
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const data = this.xmldata[nodeType];
|
|
181
|
+
|
|
182
|
+
// Handle start nodes separately - store in startNode property
|
|
183
|
+
if (nodeType === "start") {
|
|
184
|
+
if (Array.isArray(data) && data.length > 0) {
|
|
185
|
+
this.startNode = new FlowNode(data[0].name || "start", "start", data[0]);
|
|
186
|
+
} else if (!Array.isArray(data)) {
|
|
187
|
+
this.startNode = new FlowNode(data.name || "start", "start", data);
|
|
188
|
+
}
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Process other node types
|
|
193
|
+
if (Flow.ATTRIBUTE_TAGS.includes(nodeType as any)) {
|
|
194
|
+
this.processNodeType(data, nodeType, allNodes, FlowMetadata);
|
|
195
|
+
} else if (Flow.VARIABLE_TAGS.includes(nodeType as any)) {
|
|
196
|
+
this.processNodeType(data, nodeType, allNodes, FlowVariable);
|
|
197
|
+
} else if (Flow.NODE_TAGS.includes(nodeType as any)) {
|
|
198
|
+
this.processNodeType(data, nodeType, allNodes, FlowNode);
|
|
199
|
+
} else if (Flow.RESOURCE_TAGS.includes(nodeType as any)) {
|
|
200
|
+
this.processNodeType(data, nodeType, allNodes, FlowResource);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
this.elements = allNodes;
|
|
205
|
+
this.startReference = this.findStart();
|
|
206
|
+
|
|
207
|
+
// Build the connectivity graph
|
|
208
|
+
const flowNodes = allNodes.filter((e): e is FlowNode => e instanceof FlowNode);
|
|
209
|
+
this._graph = new FlowGraph(flowNodes, this.startReference, this.startNode);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public visualize(
|
|
213
|
+
format: 'mermaid' | 'plantuml' = 'mermaid',
|
|
214
|
+
options: {
|
|
215
|
+
includeDetails?: boolean;
|
|
216
|
+
includeMarkdownDocs?: boolean;
|
|
217
|
+
collapsedDetails?: boolean;
|
|
218
|
+
} = {}
|
|
219
|
+
): string {
|
|
220
|
+
if (format === 'mermaid') {
|
|
221
|
+
return this.graph.toMermaid({
|
|
222
|
+
...options,
|
|
223
|
+
flowMetadata: {
|
|
224
|
+
label: this.label,
|
|
225
|
+
processType: this.processType,
|
|
226
|
+
status: this.status,
|
|
227
|
+
description: this.xmldata?.description,
|
|
228
|
+
triggerType: this.startNode?.element?.['triggerType'],
|
|
229
|
+
object: this.startNode?.element?.['object'],
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
} else if (format === 'plantuml') {
|
|
233
|
+
return this.graph.toPlantUML();
|
|
234
|
+
}
|
|
235
|
+
throw new Error('Unsupported format');
|
|
236
|
+
}
|
|
237
|
+
private processNodeType<T extends FlowElement>(
|
|
238
|
+
data: any,
|
|
239
|
+
nodeType: string,
|
|
240
|
+
allNodes: FlowElement[],
|
|
241
|
+
NodeClass: new (name: string, subtype: string, data: any) => T
|
|
242
|
+
) {
|
|
243
|
+
if (Array.isArray(data)) {
|
|
244
|
+
for (const node of data) {
|
|
245
|
+
allNodes.push(new NodeClass(node.name, nodeType, node));
|
|
246
|
+
}
|
|
247
|
+
} else {
|
|
248
|
+
allNodes.push(new NodeClass(data.name, nodeType, data));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Find the name of the first element to execute.
|
|
254
|
+
* Priority order:
|
|
255
|
+
* 1. startElementReference (newer flows, direct XML attribute)
|
|
256
|
+
* 2. Start node connector (older flows, points to first element)
|
|
257
|
+
* 3. Start node scheduledPaths (async flows)
|
|
258
|
+
*/
|
|
259
|
+
private findStart(): string {
|
|
260
|
+
// Priority 1: Explicit startElementReference
|
|
261
|
+
if (this.startElementReference) {
|
|
262
|
+
return this.startElementReference;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Priority 2: Start node with regular connector
|
|
266
|
+
if (this.startNode && this.startNode.connectors && this.startNode.connectors.length > 0) {
|
|
267
|
+
const connector = this.startNode.connectors[0];
|
|
268
|
+
if (connector.reference) {
|
|
269
|
+
return connector.reference;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Priority 3: Start node with scheduledPaths (async flows)
|
|
274
|
+
if (this.startNode?.element) {
|
|
275
|
+
const scheduledPaths = this.startNode.element['scheduledPaths'];
|
|
276
|
+
if (scheduledPaths) {
|
|
277
|
+
const paths = Array.isArray(scheduledPaths) ? scheduledPaths : [scheduledPaths];
|
|
278
|
+
if (paths.length > 0 && paths[0]?.connector) {
|
|
279
|
+
const targetRef = paths[0].connector.targetReference;
|
|
280
|
+
if (targetRef) {
|
|
281
|
+
return targetRef;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// No valid start found
|
|
288
|
+
return "";
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public toXMLString(): string {
|
|
292
|
+
try {
|
|
293
|
+
return this.generateDoc();
|
|
294
|
+
} catch (exception) {
|
|
295
|
+
const errorMsg = exception instanceof Error ? exception.message : String(exception);
|
|
296
|
+
console.warn(`Unable to write xml, caught an error: ${errorMsg}`);
|
|
297
|
+
return "";
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
private generateDoc(): string {
|
|
302
|
+
const flowXmlNamespace = "http://soap.sforce.com/2006/04/metadata";
|
|
303
|
+
const builderOptions = {
|
|
304
|
+
attributeNamePrefix: "@_",
|
|
305
|
+
format: true,
|
|
306
|
+
ignoreAttributes: false,
|
|
307
|
+
suppressBooleanAttributes: false,
|
|
308
|
+
suppressEmptyNode: false
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
const builder = new XMLBuilder(builderOptions);
|
|
312
|
+
const xmldataWithNs = { ...this.xmldata };
|
|
313
|
+
|
|
314
|
+
if (!xmldataWithNs["@_xmlns"]) {
|
|
315
|
+
xmldataWithNs["@_xmlns"] = flowXmlNamespace;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (!xmldataWithNs["@_xmlns:xsi"]) {
|
|
319
|
+
xmldataWithNs["@_xmlns:xsi"] = "http://www.w3.org/2001/XMLSchema-instance";
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const rootObj = { Flow: xmldataWithNs };
|
|
323
|
+
return builder.build(rootObj);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MetaType } from "../enums/MetadataTypes";
|
|
2
|
+
import { FlowElement } from "./FlowElement";
|
|
3
|
+
|
|
4
|
+
export class FlowAttribute extends FlowElement {
|
|
5
|
+
public expression?: string;
|
|
6
|
+
|
|
7
|
+
constructor(name: string, subtype: string, expression?: string) {
|
|
8
|
+
super(MetaType.ATTRIBUTE, subtype, name); // No element passed, or pass {} if needed
|
|
9
|
+
this.expression = expression;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export class FlowElement {
|
|
2
|
+
public subtype: string;
|
|
3
|
+
public metaType: string;
|
|
4
|
+
public element: string | object[] | object = {};
|
|
5
|
+
public connectors?: object[];
|
|
6
|
+
public name: string;
|
|
7
|
+
public locationX?: string;
|
|
8
|
+
public locationY?: string;
|
|
9
|
+
|
|
10
|
+
constructor(metaType: string, subtype: string, name: string, element: string | object[] | object = {}) {
|
|
11
|
+
this.element = element;
|
|
12
|
+
this.subtype = subtype;
|
|
13
|
+
this.name = name;
|
|
14
|
+
this.metaType = metaType;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class FlowElementConnector {
|
|
2
|
+
public type: string;
|
|
3
|
+
public element: object = {};
|
|
4
|
+
public processed = false;
|
|
5
|
+
public alias: string;
|
|
6
|
+
public reference: string;
|
|
7
|
+
public childName: string;
|
|
8
|
+
public childOf: boolean;
|
|
9
|
+
public connectorTargetReference: FlowElementConnectorReference;
|
|
10
|
+
|
|
11
|
+
constructor(type: string, element: object, args) {
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.element = element;
|
|
14
|
+
this.childName = args.childName ? args.childName : undefined;
|
|
15
|
+
this.childOf = args.childOf ? args.childOf : undefined;
|
|
16
|
+
|
|
17
|
+
if (element && "targetReference" in element) {
|
|
18
|
+
this.reference = element.targetReference as string;
|
|
19
|
+
}
|
|
20
|
+
if (element && "connector" in element) {
|
|
21
|
+
this.connectorTargetReference = element.connector as FlowElementConnectorReference;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class FlowElementConnectorReference {
|
|
27
|
+
public targetReference: string;
|
|
28
|
+
}
|