|
4 | 4 | </a> |
5 | 5 | </p> |
6 | 6 |
|
7 | | -<p align="center"><i>A plug-and-play engine for Flow metadata in Node.js & browsers—with 20+ rules to catch unsafe contexts, loop queries, hardcoded IDs, and more.</i></p> |
| 7 | +<p align="center"><i>UMD-compatible Flow metadata engine for Node.js & browsers—20+ rules to catch common issues.</i></p> |
8 | 8 |
|
9 | | -- [Default Rules](#default-rules) |
10 | | -- [Configuration](#configuration) |
| 9 | +--- |
| 10 | + |
| 11 | +## Table of contens |
| 12 | + |
| 13 | +- **[Default Rules](#default-rules)** |
| 14 | +- **[Configuration](#configuration)** |
11 | 15 | - [Defining Severity Levels](#defining-severity-levels) |
12 | 16 | - [Configuring Expressions](#configuring-expressions) |
13 | 17 | - [Specifying Exceptions](#specifying-exceptions) |
14 | 18 | - [Include Beta Rules](#include-beta-rules) |
15 | | -- [Usage](#Usage) |
16 | | - - [Installation](#installation) |
17 | | - - [Core Functions](#core-functions) |
18 | | -- [Development](#development) |
| 19 | +- **[Usage](#Usage)** |
| 20 | + - [Examples](#examples) |
| 21 | + - [Functions](#core-functions) |
| 22 | +- **[Installation](#installation)** |
| 23 | +- **[Development](#development)** |
19 | 24 |
|
20 | 25 | --- |
21 | 26 |
|
|
24 | 29 | <p>📌 <strong>Tip:</strong> To link directly to a specific rule, use the full GitHub anchor link format. Example:</p> |
25 | 30 | <p><em><a href="https://github.com/Flow-Scanner/lightning-flow-scanner-core#unsafe-running-context">https://github.com/Flow-Scanner/lightning-flow-scanner-core#unsafe-running-context</a></em></i></p> |
26 | 31 |
|
27 | | -### Action Calls In Loop |
| 32 | +### Action Calls In Loop(Beta) |
28 | 33 |
|
29 | 34 | _[ActionCallsInLoop](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/rules/ActionCallsInLoop.ts)_ - To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls, utilizing a single action call containing a collection variable at the end of the loop. |
30 | 35 |
|
@@ -226,31 +231,62 @@ New rules are introduced in Beta mode before being added to the default ruleset. |
226 | 231 |
|
227 | 232 | ## Usage |
228 | 233 |
|
229 | | -### Installation |
| 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. |
230 | 235 |
|
231 | | -The Lightning Flow Scanner Core can be used as a dependency in Node.js and browser environments, or used as a standalone UMD module. To install: |
| 236 | +### Examples |
232 | 237 |
|
233 | | -```bash |
234 | | -npm install @flow-scanner/lightning-flow-scanner-core |
| 238 | +```js |
| 239 | +// Basic |
| 240 | +import { parse, scan } from "@flow-scanner/lightning-flow-scanner-core"; |
| 241 | +parse("flows/*.xml").then(scan); |
| 242 | + |
| 243 | +// Apply fixes automatically |
| 244 | +import { parse, scan, fix } from "@flow-scanner/lightning-flow-scanner-core"; |
| 245 | +parse("flows/*.xml").then(scan).then(fix); |
| 246 | + |
| 247 | +// Get SARIF output |
| 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)); |
235 | 253 | ``` |
236 | 254 |
|
237 | | -### Core Functions |
| 255 | +### Functions |
238 | 256 |
|
239 | 257 | #### [`getRules(ruleNames?: string[]): IRuleDefinition[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/GetRuleDefinitions.ts) |
240 | 258 |
|
241 | 259 | _Retrieves rule definitions used in the scanner._ |
242 | 260 |
|
243 | 261 | #### [`parse(selectedUris: any): Promise<ParsedFlow[]>`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/ParseFlows.ts) |
244 | 262 |
|
245 | | -_Parses metadata from selected Flow files._ |
| 263 | +_Loads Flow XML files into in-memory models._ |
246 | 264 |
|
247 | 265 | #### [`scan(parsedFlows: ParsedFlow[], ruleOptions?: IRulesConfig): ScanResult[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/ScanFlows.ts) |
248 | 266 |
|
249 | | -_Runs rules against parsed flows and returns scan results._ |
| 267 | +_Runs all enabled rules and returns detailed violations._ |
250 | 268 |
|
251 | 269 | #### [`fix(results: ScanResult[]): ScanResult[]`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/FixFlows.ts) |
252 | 270 |
|
253 | | -_Attempts to apply automatic fixes where available._ |
| 271 | +_Automatically applies available fixes(removing variables and unconnected elements)._ |
| 272 | + |
| 273 | +#### [`exportSarif(results: ScanResult[]): string`](https://github.com/Flow-Scanner/lightning-flow-scanner-core/tree/main/src/main/libs/ExportSarif.ts) |
| 274 | + |
| 275 | +_Generates SARIF output with paths and exact line numbers._ |
| 276 | + |
| 277 | +--- |
| 278 | + |
| 279 | +## Installation |
| 280 | + |
| 281 | +`lightning-flow-scanner-core` is published to **npm** only. |
| 282 | + |
| 283 | +[](https://www.npmjs.com/package/@flow-scanner/lightning-flow-scanner-core) |
| 284 | + |
| 285 | +**To install with npm:** |
| 286 | + |
| 287 | +```bash |
| 288 | +npm install @flow-scanner/lightning-flow-scanner-core |
| 289 | +``` |
254 | 290 |
|
255 | 291 | --- |
256 | 292 |
|
|
0 commit comments