@flow-scanner/lightning-flow-scanner-core 6.1.1 → 6.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
  </a>
5
5
  </p>
6
6
 
7
- <p align="center"><i>UMD-compatible Flow metadata engine for Node.js & browsers—20+ rules to catch common issues.</i></p>
7
+ <p align="center"><i>UMD-compatible Flow metadata engine for Node.js & browsers—20+ rules to catch issues.</i></p>
8
8
 
9
9
  ---
10
10
 
@@ -18,7 +18,7 @@
18
18
  - [Include Beta Rules](#include-beta-rules)
19
19
  - **[Usage](#Usage)**
20
20
  - [Examples](#examples)
21
- - [Functions](#core-functions)
21
+ - [Functions](#functions)
22
22
  - **[Installation](#installation)**
23
23
  - **[Development](#development)**
24
24
 
@@ -143,7 +143,7 @@ It is recommended to set up configuration and define:
143
143
  }
144
144
  ```
145
145
 
146
- Using the rules section of your configurations, you can specify the list of rules to be run. Furthermore, you can define the severity and configure expressions of rules. To include rules currently that are currently in beta, set `betarules` to true. Below is a breakdown of the available attributes of rule configuration:
146
+ Using the rules section of your configurations, you can specify the list of rules to be run. Furthermore, you can define the severity and configure expressions of rules. Below is a breakdown of the available attributes of rule configuration:
147
147
 
148
148
  ```json
149
149
  {
@@ -182,11 +182,11 @@ Some rules have additional attributes to configure, such as the expression, that
182
182
  "rules": {
183
183
  "APIVersion": {
184
184
  "severity": "error",
185
- "expression": "===58"
185
+ "expression": "===58" // comparison operator
186
186
  },
187
187
  "FlowName": {
188
188
  "severity": "note",
189
- "expression": "[A-Za-z0-9]"
189
+ "expression": "[A-Za-z0-9]" // regular expression
190
190
  }
191
191
  }
192
192
  }
@@ -231,7 +231,7 @@ New rules are introduced in Beta mode before being added to the default ruleset.
231
231
 
232
232
  ## Usage
233
233
 
234
- The Lightning Flow Scanner Core can be used as a dependency in Node.js and browser environments, or used as a standalone UMD module.
234
+ `lightning-flow-scanner-core` can be used as a dependency in Node.js and browser environments, or as a standalone UMD module.
235
235
 
236
236
  ### Examples
237
237
 
@@ -240,16 +240,13 @@ The Lightning Flow Scanner Core can be used as a dependency in Node.js and brows
240
240
  import { parse, scan } from "@flow-scanner/lightning-flow-scanner-core";
241
241
  parse("flows/*.xml").then(scan);
242
242
 
243
- // Apply fixes automatically
243
+ // Apply available patches
244
244
  import { parse, scan, fix } from "@flow-scanner/lightning-flow-scanner-core";
245
245
  parse("flows/*.xml").then(scan).then(fix);
246
246
 
247
247
  // Get SARIF output
248
248
  import { parse, scan, exportSarif } from "@flow-scanner/lightning-flow-scanner-core";
249
- parse("flows/*.xml")
250
- .then(scan)
251
- .then(exportSarif)
252
- .then((sarif) => save("results.sarif", sarif));
249
+ parse("flows/*.xml").then(scan).then(exportSarif); //.then((sarif) => save("results.sarif", sarif));
253
250
 
254
251
  // Browser Usage (Tooling API)
255
252
  const { Flow, scan } = window.lightningflowscanner;
@@ -258,8 +255,7 @@ const results = scan(
258
255
  metadataRes.records.map((r) => ({
259
256
  uri: `/services/data/v60.0/tooling/sobjects/Flow/${r.Id}`,
260
257
  flow: new Flow(r.FullName, r.Metadata),
261
- })),
262
- optionsForScan
258
+ })) //, optionsForScan
263
259
  );
264
260
  ```
265
261
 
@@ -281,9 +277,13 @@ _Runs all enabled rules and returns detailed violations._
281
277
 
282
278
  _Automatically applies available fixes(removing variables and unconnected elements)._
283
279
 
284
- #### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/ExportSarif.ts)
280
+ #### [`exportDetails(results: ScanResult[]): FlatViolation[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportDetails.ts)
285
281
 
286
- _Generates SARIF output with paths and exact line numbers._
282
+ _Get flattened output of violations only._
283
+
284
+ #### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/exportSarif.ts)
285
+
286
+ _Get SARIF output including exact line numbers of violations._
287
287
 
288
288
  ---
289
289
 
@@ -336,26 +336,24 @@ npm install @flow-scanner/lightning-flow-scanner-core
336
336
  ```
337
337
 
338
338
  5. Test as local dependency(Optional):
339
- To test changes to the core module in the VS Code extension or SF CLI plugin locally, run:
339
+ To test changes to the core module locally, run:
340
340
 
341
341
  ```bash
342
342
  npm run link
343
343
  ```
344
344
 
345
- b) Go to the dependent project (VSX or SF CLI) and use:
345
+ b) Go to the dependent project (e.g. VSX or CLI) and use:
346
346
 
347
347
  ```bash
348
348
  npm link @flow-scanner/lightning-flow-scanner-core
349
349
  ```
350
350
 
351
- Your local core module will now replace the installed dependency and update automatically on rebuild.
351
+ Your local module will now replace any installed version and update on rebuild.
352
352
 
353
353
  6. Create a standalone UMD Module(Optional):
354
354
 
355
355
  ```bash
356
- npm run vite:dist
356
+ npm run vite:dist // creates UMD at`dist/lightning-flow-scanner-core.umd.js`.
357
357
  ```
358
358
 
359
- The resulting file will be available in the `dist` directory as `lightning-flow-scanner-core.umd.js`.
360
-
361
359
  ###### Want to help improve Lightning Flow Scanner? See our [Contributing Guidelines](https://github.com/Flow-Scanner/lightning-flow-scanner-core/blob/main/CONTRIBUTING.md).
package/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  import type { IRuleDefinition } from "./main/interfaces/IRuleDefinition";
2
2
  import type { IRulesConfig } from "./main/interfaces/IRulesConfig";
3
3
  import { Compiler } from "./main/libs/Compiler";
4
- import { exportSarif } from "./main/libs/ExportSarif";
4
+ import { exportDetails } from "./main/libs/exportAsDetails";
5
+ import { exportSarif } from "./main/libs/exportAsSarif";
5
6
  import { fix } from "./main/libs/FixFlows";
6
7
  import { getBetaRules, getRules } from "./main/libs/GetRuleDefinitions";
7
8
  import { parse } from "./main/libs/ParseFlows";
@@ -18,5 +19,5 @@ import { ParsedFlow } from "./main/models/ParsedFlow";
18
19
  import { ResultDetails } from "./main/models/ResultDetails";
19
20
  import { RuleResult } from "./main/models/RuleResult";
20
21
  import { ScanResult } from "./main/models/ScanResult";
21
- export { AdvancedRule, Compiler, exportSarif, fix, Flow, FlowAttribute, FlowElement, FlowNode, FlowResource, FlowType, FlowVariable, getBetaRules, getRules, parse, ParsedFlow, ResultDetails, RuleResult, scan, ScanResult, };
22
+ export { AdvancedRule, Compiler, exportDetails, exportSarif, fix, Flow, FlowAttribute, FlowElement, FlowNode, FlowResource, FlowType, FlowVariable, getBetaRules, getRules, parse, ParsedFlow, ResultDetails, RuleResult, scan, ScanResult, };
22
23
  export type { IRuleDefinition, IRulesConfig };
package/index.js CHANGED
@@ -48,8 +48,11 @@ _export(exports, {
48
48
  get ScanResult () {
49
49
  return _ScanResult.ScanResult;
50
50
  },
51
+ get exportDetails () {
52
+ return _exportAsDetails.exportDetails;
53
+ },
51
54
  get exportSarif () {
52
- return _ExportSarif.exportSarif;
55
+ return _exportAsSarif.exportSarif;
53
56
  },
54
57
  get fix () {
55
58
  return _FixFlows.fix;
@@ -68,7 +71,8 @@ _export(exports, {
68
71
  }
69
72
  });
70
73
  const _Compiler = require("./main/libs/Compiler");
71
- const _ExportSarif = require("./main/libs/ExportSarif");
74
+ const _exportAsDetails = require("./main/libs/exportAsDetails");
75
+ const _exportAsSarif = require("./main/libs/exportAsSarif");
72
76
  const _FixFlows = require("./main/libs/FixFlows");
73
77
  const _GetRuleDefinitions = require("./main/libs/GetRuleDefinitions");
74
78
  const _ParseFlows = require("./main/libs/ParseFlows");
@@ -0,0 +1,16 @@
1
+ import { ScanResult } from "../models/ScanResult";
2
+ export interface FlatViolation {
3
+ connectsTo?: string;
4
+ dataType?: string;
5
+ expression?: string;
6
+ flowFile: string;
7
+ flowName: string;
8
+ locationX?: string;
9
+ locationY?: string;
10
+ metaType: string;
11
+ name: string;
12
+ ruleName: string;
13
+ severity: string;
14
+ type: string;
15
+ }
16
+ export declare function exportDetails(results: ScanResult[]): FlatViolation[];
@@ -0,0 +1,43 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "exportDetails", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return exportDetails;
9
+ }
10
+ });
11
+ function exportDetails(results) {
12
+ const violations = [];
13
+ for (const result of results){
14
+ const flow = result.flow;
15
+ const flowName = flow.label || flow.name;
16
+ const flowFile = flow.fsPath ? flow.fsPath.replace(/\\/g, "/") : `${flow.name}.flow-meta.xml`;
17
+ for (const rule of result.ruleResults){
18
+ var _rule_details;
19
+ if (!rule.occurs || !((_rule_details = rule.details) === null || _rule_details === void 0 ? void 0 : _rule_details.length)) continue;
20
+ const ruleName = rule.ruleDefinition.label || rule.ruleName;
21
+ var _rule_severity;
22
+ const severity = (_rule_severity = rule.severity) !== null && _rule_severity !== void 0 ? _rule_severity : "error";
23
+ for (const detail of rule.details){
24
+ const d = detail.details || {};
25
+ violations.push({
26
+ connectsTo: Array.isArray(d.connectsTo) ? d.connectsTo.join("; ") : d.connectsTo,
27
+ dataType: d.dataType,
28
+ expression: d.expression,
29
+ flowFile,
30
+ flowName,
31
+ locationX: d.locationX,
32
+ locationY: d.locationY,
33
+ metaType: detail.metaType,
34
+ name: detail.name,
35
+ ruleName,
36
+ severity,
37
+ type: detail.type
38
+ });
39
+ }
40
+ }
41
+ }
42
+ return violations;
43
+ }
@@ -1,4 +1,3 @@
1
- // src/main/libs/exportSarif.ts
2
1
  "use strict";
3
2
  Object.defineProperty(exports, "__esModule", {
4
3
  value: true
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flow-scanner/lightning-flow-scanner-core",
3
3
  "description": "A lightweight, purpose-built engine for parsing and analyzing Salesforce Flow metadata in Node.js or browser environments. Scan, validate, and optimize Flow automations for security risks, best practices, governor limits, and performance bottlenecks.",
4
- "version": "6.1.1",
4
+ "version": "6.1.5",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "engines": {