hardis-formula 1.0.0
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 +98 -0
- package/messages/hardis-formula.evaluate.md +89 -0
- package/oclif.lock +13933 -0
- package/oclif.manifest.json +4 -0
- package/package.json +193 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# hardis-formula
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/hardis-formula) [](https://npmjs.org/package/hardis-formula) [](https://raw.githubusercontent.com/salesforcecli/hardis-formula/main/LICENSE.txt)
|
|
4
|
+
|
|
5
|
+
# summary
|
|
6
|
+
|
|
7
|
+
Evaluates a Salesforce formula against one or more records and returns the result for each.
|
|
8
|
+
|
|
9
|
+
This extension is only possible because of the following awesome opensource projects:
|
|
10
|
+
|
|
11
|
+
- [Formulon](https://github.com/leifg/formulon)
|
|
12
|
+
- [SFDX Hardis](https://github.com/hardisgroupcom/sfdx-hardis)
|
|
13
|
+
|
|
14
|
+
# description
|
|
15
|
+
|
|
16
|
+
Evaluates a Salesforce formula against one or more records and returns the result for each.
|
|
17
|
+
|
|
18
|
+
This command uses [Formulon](https://github.com/leifg/formulon) to parse and evaluate Salesforce formulas entirely offline, no org connection required.
|
|
19
|
+
|
|
20
|
+
Key features:
|
|
21
|
+
|
|
22
|
+
- **Multi-record evaluation:** Supply multiple records (each as a variable map) to evaluate the same formula against all of them in one shot.
|
|
23
|
+
- **Inline or file input:** Provide the formula and records directly as CLI flags, or point to a JSON file that contains both.
|
|
24
|
+
- **Error transparency:** Formulon errors (wrong argument count, type mismatches, etc.) are surfaced per record rather than aborting the whole run.
|
|
25
|
+
|
|
26
|
+
### Input JSON file format
|
|
27
|
+
|
|
28
|
+
When using \`--inputfile\`, the file must be a JSON object with the following shape:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"formula": "IF(IsActive**c, Amount**c * 1.1, Amount**c)",
|
|
33
|
+
"records": [
|
|
34
|
+
{
|
|
35
|
+
"IsActive**c": { "type": "literal", "dataType": "checkbox", "value": true },
|
|
36
|
+
"Amount**c": { "type": "literal", "dataType": "number", "value": 200, "options": { "length": 6, "scale": 2 } }
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"IsActive**c": { "type": "literal", "dataType": "checkbox", "value": false },
|
|
40
|
+
"Amount__c": { "type": "literal", "dataType": "number", "value": 150, "options": { "length": 6, "scale": 2 } }
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Each entry in \`records\` is a map of **field API name → Formulon variable descriptor**.
|
|
47
|
+
The variable descriptor shape is:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"type": "literal",
|
|
52
|
+
"dataType": "<text|number|checkbox|date|time|datetime|geolocation|null>",
|
|
53
|
+
"value": <js-native-value>,
|
|
54
|
+
"options": { }
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
# flags.formula.summary
|
|
59
|
+
|
|
60
|
+
Salesforce formula to evaluate.
|
|
61
|
+
|
|
62
|
+
# flags.formula.description
|
|
63
|
+
|
|
64
|
+
Ignored when --inputfile is provided.
|
|
65
|
+
|
|
66
|
+
# flags.records.summary
|
|
67
|
+
|
|
68
|
+
JSON array of record variable maps.
|
|
69
|
+
|
|
70
|
+
# flags.records.description
|
|
71
|
+
|
|
72
|
+
Each element represents one record. Ignored when --inputfile is provided.
|
|
73
|
+
|
|
74
|
+
# flags.inputfile.summary
|
|
75
|
+
|
|
76
|
+
Path to a JSON file containing "formula" and "records".
|
|
77
|
+
|
|
78
|
+
# flags.inputfile.description
|
|
79
|
+
|
|
80
|
+
When supplied, --formula and --records are ignored.
|
|
81
|
+
|
|
82
|
+
# flags.debug.summary
|
|
83
|
+
|
|
84
|
+
Activate debug mode (more logs)
|
|
85
|
+
|
|
86
|
+
# examples
|
|
87
|
+
|
|
88
|
+
- Run a formula without variables:
|
|
89
|
+
|
|
90
|
+
<%= config.bin %> <%= command.id %> --formula 'IF(TRUE, "Yes", "No")'
|
|
91
|
+
|
|
92
|
+
- Run a formula with variables and multiple records:
|
|
93
|
+
|
|
94
|
+
<%= config.bin %> <%= command.id %> --formula 'Amount\_\_c \* 2' --records '[{"Amount**c":{"type":"literal" "dataType":"number","value":100,"options":{"length":6,"scale":2}}}]
|
|
95
|
+
|
|
96
|
+
- Run a formula from a JSON file:
|
|
97
|
+
|
|
98
|
+
<%= config.bin %> <%= command.id %> --inputfile ./my-formula.json
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# summary
|
|
2
|
+
|
|
3
|
+
Evaluates a Salesforce formula against one or more records and returns the result for each.
|
|
4
|
+
|
|
5
|
+
# description
|
|
6
|
+
|
|
7
|
+
Evaluates a Salesforce formula against one or more records and returns the result for each.
|
|
8
|
+
|
|
9
|
+
This command uses [Formulon](https://github.com/leifg/formulon) to parse and evaluate Salesforce formulas entirely offline, no org connection required.
|
|
10
|
+
|
|
11
|
+
Key features:
|
|
12
|
+
|
|
13
|
+
- **Multi-record evaluation:** Supply multiple records (each as a variable map) to evaluate the same formula against all of them in one shot.
|
|
14
|
+
- **Inline or file input:** Provide the formula and records directly as CLI flags, or point to a JSON file that contains both.
|
|
15
|
+
- **Error transparency:** Formulon errors (wrong argument count, type mismatches, etc.) are surfaced per record rather than aborting the whole run.
|
|
16
|
+
|
|
17
|
+
### Input JSON file format
|
|
18
|
+
|
|
19
|
+
When using \`--inputfile\`, the file must be a JSON object with the following shape:
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"formula": "IF(IsActive**c, Amount**c * 1.1, Amount**c)",
|
|
24
|
+
"records": [
|
|
25
|
+
{
|
|
26
|
+
"IsActive**c": { "type": "literal", "dataType": "checkbox", "value": true },
|
|
27
|
+
"Amount**c": { "type": "literal", "dataType": "number", "value": 200, "options": { "length": 6, "scale": 2 } }
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"IsActive**c": { "type": "literal", "dataType": "checkbox", "value": false },
|
|
31
|
+
"Amount__c": { "type": "literal", "dataType": "number", "value": 150, "options": { "length": 6, "scale": 2 } }
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Each entry in \`records\` is a map of **field API name → Formulon variable descriptor**.
|
|
38
|
+
The variable descriptor shape is:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"type": "literal",
|
|
43
|
+
"dataType": "<text|number|checkbox|date|time|datetime|geolocation|null>",
|
|
44
|
+
"value": <js-native-value>,
|
|
45
|
+
"options": { }
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
# flags.formula.summary
|
|
50
|
+
|
|
51
|
+
Salesforce formula to evaluate.
|
|
52
|
+
|
|
53
|
+
# flags.formula.description
|
|
54
|
+
|
|
55
|
+
Ignored when --inputfile is provided.
|
|
56
|
+
|
|
57
|
+
# flags.records.summary
|
|
58
|
+
|
|
59
|
+
JSON array of record variable maps.
|
|
60
|
+
|
|
61
|
+
# flags.records.description
|
|
62
|
+
|
|
63
|
+
Each element represents one record. Ignored when --inputfile is provided.
|
|
64
|
+
|
|
65
|
+
# flags.inputfile.summary
|
|
66
|
+
|
|
67
|
+
Path to a JSON file containing "formula" and "records".
|
|
68
|
+
|
|
69
|
+
# flags.inputfile.description
|
|
70
|
+
|
|
71
|
+
When supplied, --formula and --records are ignored.
|
|
72
|
+
|
|
73
|
+
# flags.debug.summary
|
|
74
|
+
|
|
75
|
+
Activate debug mode (more logs)
|
|
76
|
+
|
|
77
|
+
# examples
|
|
78
|
+
|
|
79
|
+
- Run a formula without variables:
|
|
80
|
+
|
|
81
|
+
<%= config.bin %> <%= command.id %> --formula 'IF(TRUE, "Yes", "No")'
|
|
82
|
+
|
|
83
|
+
- Run a formula with variables and multiple records:
|
|
84
|
+
|
|
85
|
+
<%= config.bin %> <%= command.id %> --formula 'Amount\_\_c \* 2' --records '[{"Amount**c":{"type":"literal" "dataType":"number","value":100,"options":{"length":6,"scale":2}}}]
|
|
86
|
+
|
|
87
|
+
- Run a formula from a JSON file:
|
|
88
|
+
|
|
89
|
+
<%= config.bin %> <%= command.id %> --inputfile ./my-formula.json
|