sf-flow-coverage 0.2.0 → 0.4.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/CHANGELOG.md +24 -0
- package/README.md +142 -17
- package/lib/commands/flowcov/gate.d.ts +1 -0
- package/lib/commands/flowcov/gate.js +15 -2
- package/lib/commands/flowcov/gate.js.map +1 -1
- package/lib/commands/flowcov/readiness.js +25 -3
- package/lib/commands/flowcov/readiness.js.map +1 -1
- package/lib/commands/flowcov/transform.d.ts +15 -0
- package/lib/commands/flowcov/transform.js +78 -0
- package/lib/commands/flowcov/transform.js.map +1 -0
- package/lib/core/apexTemplate.d.ts +16 -1
- package/lib/core/apexTemplate.js +462 -104
- package/lib/core/apexTemplate.js.map +1 -1
- package/lib/core/conditions.d.ts +107 -0
- package/lib/core/conditions.js +481 -0
- package/lib/core/conditions.js.map +1 -0
- package/lib/core/coverageCheck.d.ts +8 -0
- package/lib/core/coverageCheck.js +12 -0
- package/lib/core/coverageCheck.js.map +1 -0
- package/lib/core/coverageFormats.d.ts +7 -0
- package/lib/core/coverageFormats.js +77 -0
- package/lib/core/coverageFormats.js.map +1 -0
- package/lib/core/criteria.d.ts +40 -0
- package/lib/core/criteria.js +262 -0
- package/lib/core/criteria.js.map +1 -0
- package/lib/core/elementCoverage.d.ts +9 -0
- package/lib/core/elementCoverage.js +27 -0
- package/lib/core/elementCoverage.js.map +1 -0
- package/lib/core/flowElementLines.d.ts +13 -0
- package/lib/core/flowElementLines.js +44 -0
- package/lib/core/flowElementLines.js.map +1 -0
- package/lib/core/flowFingerprint.d.ts +37 -0
- package/lib/core/flowFingerprint.js +142 -0
- package/lib/core/flowFingerprint.js.map +1 -0
- package/lib/core/flowGraph.d.ts +144 -0
- package/lib/core/flowGraph.js +279 -0
- package/lib/core/flowGraph.js.map +1 -0
- package/lib/core/flowSettings.d.ts +16 -0
- package/lib/core/flowSettings.js +49 -0
- package/lib/core/flowSettings.js.map +1 -0
- package/lib/core/flowTypes.d.ts +6 -0
- package/lib/core/flowTypes.js +17 -0
- package/lib/core/flowTypes.js.map +1 -1
- package/lib/core/flowValues.d.ts +14 -0
- package/lib/core/flowValues.js +43 -0
- package/lib/core/flowValues.js.map +1 -0
- package/lib/core/flowXml.d.ts +1 -1
- package/lib/core/flowXml.js +6 -39
- package/lib/core/flowXml.js.map +1 -1
- package/lib/core/formula.d.ts +48 -0
- package/lib/core/formula.js +227 -0
- package/lib/core/formula.js.map +1 -0
- package/lib/core/gate.d.ts +10 -1
- package/lib/core/gate.js +64 -7
- package/lib/core/gate.js.map +1 -1
- package/lib/core/orgCoverageSource.d.ts +9 -0
- package/lib/core/orgCoverageSource.js +68 -12
- package/lib/core/orgCoverageSource.js.map +1 -1
- package/lib/core/readiness.d.ts +5 -0
- package/lib/core/readiness.js +24 -10
- package/lib/core/readiness.js.map +1 -1
- package/lib/core/requiredFields.d.ts +53 -3
- package/lib/core/requiredFields.js +158 -10
- package/lib/core/requiredFields.js.map +1 -1
- package/lib/core/scaffold.js +50 -4
- package/lib/core/scaffold.js.map +1 -1
- package/lib/core/toolingQuery.d.ts +5 -0
- package/lib/core/toolingQuery.js +9 -1
- package/lib/core/toolingQuery.js.map +1 -1
- package/lib/core/transform.d.ts +36 -0
- package/lib/core/transform.js +62 -0
- package/lib/core/transform.js.map +1 -0
- package/lib/core/types.d.ts +79 -1
- package/lib/index.d.ts +6 -1
- package/lib/index.js +3 -1
- package/lib/index.js.map +1 -1
- package/messages/flowcov.gate.md +19 -1
- package/messages/flowcov.readiness.md +4 -2
- package/messages/flowcov.scaffold.md +5 -1
- package/messages/flowcov.transform.md +33 -0
- package/oclif.manifest.json +113 -4
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { type Condition } from './conditions.js';
|
|
2
|
+
import { type FlowValue, type XmlRecord } from './flowValues.js';
|
|
3
|
+
import { type Expr } from './formula.js';
|
|
4
|
+
/**
|
|
5
|
+
* The parts of a Flow's elements that decide what a test can assert: which `$Record` fields and
|
|
6
|
+
* variables each element writes, which records it creates or looks up, how decisions branch,
|
|
7
|
+
* and where custom errors stop the save.
|
|
8
|
+
*/
|
|
9
|
+
export type FlowGraph = {
|
|
10
|
+
/** The element the start element connects to. */
|
|
11
|
+
start?: string;
|
|
12
|
+
nodes: Record<string, FlowNode>;
|
|
13
|
+
/** Formula resources by name, for decisions that read them. */
|
|
14
|
+
formulas: Record<string, Expr>;
|
|
15
|
+
};
|
|
16
|
+
/** A write to a field of the triggering record. */
|
|
17
|
+
export type FieldWrite = {
|
|
18
|
+
field: string;
|
|
19
|
+
value: FlowValue;
|
|
20
|
+
/** The element that writes it. */
|
|
21
|
+
element: string;
|
|
22
|
+
};
|
|
23
|
+
/** A write to a variable. */
|
|
24
|
+
export type VariableWrite = {
|
|
25
|
+
variable: string;
|
|
26
|
+
value: FlowValue;
|
|
27
|
+
element: string;
|
|
28
|
+
};
|
|
29
|
+
/** A record the Flow creates, with the fields it sets. */
|
|
30
|
+
export type RecordCreate = {
|
|
31
|
+
element: string;
|
|
32
|
+
object: string;
|
|
33
|
+
fields: Array<{
|
|
34
|
+
field: string;
|
|
35
|
+
value: FlowValue;
|
|
36
|
+
}>;
|
|
37
|
+
};
|
|
38
|
+
export type DecisionRule = {
|
|
39
|
+
name: string;
|
|
40
|
+
label: string;
|
|
41
|
+
condition: Condition;
|
|
42
|
+
next?: string;
|
|
43
|
+
};
|
|
44
|
+
export type FlowNode = {
|
|
45
|
+
kind: 'write';
|
|
46
|
+
name: string;
|
|
47
|
+
writes: FieldWrite[];
|
|
48
|
+
variables: VariableWrite[];
|
|
49
|
+
nexts: string[];
|
|
50
|
+
} | {
|
|
51
|
+
kind: 'decision';
|
|
52
|
+
name: string;
|
|
53
|
+
label: string;
|
|
54
|
+
rules: DecisionRule[];
|
|
55
|
+
defaultNext?: string;
|
|
56
|
+
defaultLabel: string;
|
|
57
|
+
nexts: string[];
|
|
58
|
+
} | {
|
|
59
|
+
kind: 'customError';
|
|
60
|
+
name: string;
|
|
61
|
+
message?: string;
|
|
62
|
+
nexts: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Get Records that stores its result in `output`. */
|
|
65
|
+
| {
|
|
66
|
+
kind: 'lookup';
|
|
67
|
+
name: string;
|
|
68
|
+
object: string;
|
|
69
|
+
output: string;
|
|
70
|
+
nexts: string[];
|
|
71
|
+
}
|
|
72
|
+
/** Create Records with its fields set one by one. */
|
|
73
|
+
| {
|
|
74
|
+
kind: 'create';
|
|
75
|
+
name: string;
|
|
76
|
+
create: RecordCreate;
|
|
77
|
+
nexts: string[];
|
|
78
|
+
}
|
|
79
|
+
/** Loops, waits, screens: a walk can't tell what happens past them. */
|
|
80
|
+
| {
|
|
81
|
+
kind: 'stop';
|
|
82
|
+
name: string;
|
|
83
|
+
nexts: string[];
|
|
84
|
+
} | {
|
|
85
|
+
kind: 'other';
|
|
86
|
+
name: string;
|
|
87
|
+
nexts: string[];
|
|
88
|
+
};
|
|
89
|
+
/** XML paths the parser must read as lists even when they hold one element. */
|
|
90
|
+
export declare const GRAPH_ARRAY_PATHS: string[];
|
|
91
|
+
/** Reads the element graph from a parsed `<Flow>` record. */
|
|
92
|
+
export declare function parseFlowGraph(flow: XmlRecord): FlowGraph;
|
|
93
|
+
/**
|
|
94
|
+
* What the test knows when the Flow runs, by reference (`$Record.Status__c`,
|
|
95
|
+
* `$Record__Prior.Status__c`, `myVariable`): an Apex literal, `null` for a known-empty value, and
|
|
96
|
+
* no entry for a value it can't know.
|
|
97
|
+
*/
|
|
98
|
+
export type FieldState = Map<string, string | null>;
|
|
99
|
+
/** Effects on one outcome of a decision the walk couldn't decide. */
|
|
100
|
+
export type UndecidedOutcome = {
|
|
101
|
+
label: string;
|
|
102
|
+
writes: FieldWrite[];
|
|
103
|
+
variables: VariableWrite[];
|
|
104
|
+
creates: RecordCreate[];
|
|
105
|
+
/** True when a custom error can stop the save on this outcome. */
|
|
106
|
+
customError: boolean;
|
|
107
|
+
};
|
|
108
|
+
/** A decision the walk took, and the rule it took (undefined for the default outcome). */
|
|
109
|
+
export type DecisionTaken = {
|
|
110
|
+
element: string;
|
|
111
|
+
rule?: DecisionRule;
|
|
112
|
+
};
|
|
113
|
+
export type FlowWalk = {
|
|
114
|
+
/** `$Record` writes certain to happen, in order. */
|
|
115
|
+
writes: FieldWrite[];
|
|
116
|
+
/** Variable writes certain to happen, in order. */
|
|
117
|
+
variables?: VariableWrite[];
|
|
118
|
+
/** Records the Flow is certain to create. */
|
|
119
|
+
creates?: RecordCreate[];
|
|
120
|
+
/** Decisions taken, in order. */
|
|
121
|
+
decisions?: DecisionTaken[];
|
|
122
|
+
/** A custom error certain to stop the save. */
|
|
123
|
+
customError?: {
|
|
124
|
+
element: string;
|
|
125
|
+
message?: string;
|
|
126
|
+
};
|
|
127
|
+
/** Where the walk stopped, and what each way on can do. */
|
|
128
|
+
undecided?: {
|
|
129
|
+
element: string;
|
|
130
|
+
outcomes: UndecidedOutcome[];
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
export type WalkOptions = {
|
|
134
|
+
/**
|
|
135
|
+
* Whether the org has no records of `object` the Flow could find. Apex tests see no org data,
|
|
136
|
+
* so this holds for data the test (and the Flow, before the lookup) doesn't create.
|
|
137
|
+
*/
|
|
138
|
+
emptyObject?(object: string): boolean;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Follows the Flow from its start for a record in the given state, through every decision the
|
|
142
|
+
* state decides, and reports what is certain to happen.
|
|
143
|
+
*/
|
|
144
|
+
export declare function walkFlow(graph: FlowGraph, initial: FieldState, options?: WalkOptions): FlowWalk;
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { conditionFromRule, evaluateCondition } from './conditions.js';
|
|
2
|
+
import { asArray, asRecord, parseFlowValue, text } from './flowValues.js';
|
|
3
|
+
import { parseFormula } from './formula.js';
|
|
4
|
+
const PASS_THROUGH_TYPES = [
|
|
5
|
+
'actionCalls',
|
|
6
|
+
'apexPluginCalls',
|
|
7
|
+
'collectionProcessors',
|
|
8
|
+
'recordDeletes',
|
|
9
|
+
'recordRollbacks',
|
|
10
|
+
'subflows',
|
|
11
|
+
'transforms',
|
|
12
|
+
];
|
|
13
|
+
const STOP_TYPES = ['loops', 'orchestratedStages', 'screens', 'steps', 'waits'];
|
|
14
|
+
/** XML paths the parser must read as lists even when they hold one element. */
|
|
15
|
+
export const GRAPH_ARRAY_PATHS = [
|
|
16
|
+
...[
|
|
17
|
+
...PASS_THROUGH_TYPES,
|
|
18
|
+
...STOP_TYPES,
|
|
19
|
+
'assignments',
|
|
20
|
+
'decisions',
|
|
21
|
+
'recordUpdates',
|
|
22
|
+
'recordCreates',
|
|
23
|
+
'recordLookups',
|
|
24
|
+
'customErrors',
|
|
25
|
+
'formulas',
|
|
26
|
+
].map((type) => `Flow.${type}`),
|
|
27
|
+
'Flow.assignments.assignmentItems',
|
|
28
|
+
'Flow.decisions.rules',
|
|
29
|
+
'Flow.decisions.rules.conditions',
|
|
30
|
+
'Flow.recordUpdates.inputAssignments',
|
|
31
|
+
'Flow.recordUpdates.filters',
|
|
32
|
+
'Flow.recordCreates.inputAssignments',
|
|
33
|
+
'Flow.customErrors.customErrorMessages',
|
|
34
|
+
];
|
|
35
|
+
const RECORD_FIELD = /^\$Record\.([A-Za-z][A-Za-z0-9_]*)$/;
|
|
36
|
+
const VARIABLE = /^[A-Za-z][A-Za-z0-9_]*$/;
|
|
37
|
+
const target = (connector) => text(asRecord(connector)?.targetReference);
|
|
38
|
+
/** Every element an element can continue to, apart from its fault path. */
|
|
39
|
+
function nextsOf(element) {
|
|
40
|
+
const nexts = [
|
|
41
|
+
target(element.connector),
|
|
42
|
+
target(element.defaultConnector),
|
|
43
|
+
target(element.nextValueConnector),
|
|
44
|
+
target(element.noMoreValuesConnector),
|
|
45
|
+
...asArray(element.rules).map((rule) => target(rule.connector)),
|
|
46
|
+
];
|
|
47
|
+
return nexts.filter((next) => !!next);
|
|
48
|
+
}
|
|
49
|
+
function parseAssignment(name, element) {
|
|
50
|
+
const writes = [];
|
|
51
|
+
const variables = [];
|
|
52
|
+
for (const item of asArray(element.assignmentItems)) {
|
|
53
|
+
const reference = text(item.assignToReference) ?? '';
|
|
54
|
+
const operator = text(item.operator) ?? 'Assign';
|
|
55
|
+
const parsed = parseFlowValue(asRecord(item.value));
|
|
56
|
+
// Add, Subtract and the like depend on the current value.
|
|
57
|
+
const value = operator === 'Assign' ? parsed : { rawValue: `${operator} ${parsed.rawValue ?? ''}`.trim() };
|
|
58
|
+
const field = RECORD_FIELD.exec(reference)?.[1];
|
|
59
|
+
if (field)
|
|
60
|
+
writes.push({ field, element: name, value });
|
|
61
|
+
else if (VARIABLE.test(reference))
|
|
62
|
+
variables.push({ variable: reference, element: name, value });
|
|
63
|
+
}
|
|
64
|
+
return { kind: 'write', name, writes, variables, nexts: nextsOf(element) };
|
|
65
|
+
}
|
|
66
|
+
/** Update Records on the triggering record: `$Record` itself, or the record whose Id is `$Record.Id`. */
|
|
67
|
+
function updatesRecord(element) {
|
|
68
|
+
if (text(element.inputReference) === '$Record')
|
|
69
|
+
return true;
|
|
70
|
+
const filters = asArray(element.filters);
|
|
71
|
+
return (filters.length === 1 &&
|
|
72
|
+
text(filters[0].field) === 'Id' &&
|
|
73
|
+
text(filters[0].operator) === 'EqualTo' &&
|
|
74
|
+
text(asRecord(filters[0].value)?.elementReference) === '$Record.Id');
|
|
75
|
+
}
|
|
76
|
+
function fieldAssignments(element) {
|
|
77
|
+
return asArray(element.inputAssignments).flatMap((assignment) => {
|
|
78
|
+
const field = text(assignment.field);
|
|
79
|
+
return field ? [{ field, value: parseFlowValue(asRecord(assignment.value)) }] : [];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function parseDecision(name, element) {
|
|
83
|
+
const rules = asArray(element.rules).map((rule) => {
|
|
84
|
+
const ruleName = text(rule.name) ?? '';
|
|
85
|
+
const conditions = asArray(rule.conditions).map((condition) => ({
|
|
86
|
+
left: text(condition.leftValueReference) ?? '',
|
|
87
|
+
operator: text(condition.operator) ?? '',
|
|
88
|
+
right: parseFlowValue(asRecord(condition.rightValue)),
|
|
89
|
+
}));
|
|
90
|
+
return {
|
|
91
|
+
name: ruleName,
|
|
92
|
+
label: text(rule.label) ?? ruleName,
|
|
93
|
+
condition: conditionFromRule(conditions, text(rule.conditionLogic)),
|
|
94
|
+
next: target(rule.connector),
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
return {
|
|
98
|
+
kind: 'decision',
|
|
99
|
+
name,
|
|
100
|
+
label: text(element.label) ?? name,
|
|
101
|
+
rules,
|
|
102
|
+
defaultNext: target(element.defaultConnector),
|
|
103
|
+
defaultLabel: text(element.defaultConnectorLabel) ?? 'Default Outcome',
|
|
104
|
+
nexts: nextsOf(element),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** Reads the element graph from a parsed `<Flow>` record. */
|
|
108
|
+
export function parseFlowGraph(flow) {
|
|
109
|
+
const nodes = {};
|
|
110
|
+
const each = (type, build) => {
|
|
111
|
+
for (const element of asArray(flow[type])) {
|
|
112
|
+
const name = text(element.name);
|
|
113
|
+
if (name)
|
|
114
|
+
nodes[name] = build(name, element);
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
each('assignments', parseAssignment);
|
|
118
|
+
each('recordUpdates', (name, element) => updatesRecord(element)
|
|
119
|
+
? {
|
|
120
|
+
kind: 'write',
|
|
121
|
+
name,
|
|
122
|
+
writes: fieldAssignments(element).map((a) => ({ ...a, element: name })),
|
|
123
|
+
variables: [],
|
|
124
|
+
nexts: nextsOf(element),
|
|
125
|
+
}
|
|
126
|
+
: { kind: 'other', name, nexts: nextsOf(element) });
|
|
127
|
+
each('recordCreates', (name, element) => {
|
|
128
|
+
const object = text(element.object);
|
|
129
|
+
// A create from a record variable doesn't say which fields it sets.
|
|
130
|
+
if (!object || text(element.inputReference))
|
|
131
|
+
return { kind: 'other', name, nexts: nextsOf(element) };
|
|
132
|
+
return {
|
|
133
|
+
kind: 'create',
|
|
134
|
+
name,
|
|
135
|
+
create: { element: name, object, fields: fieldAssignments(element) },
|
|
136
|
+
nexts: nextsOf(element),
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
each('recordLookups', (name, element) => {
|
|
140
|
+
const object = text(element.object);
|
|
141
|
+
const output = text(element.storeOutputAutomatically) === 'true' ? name : text(element.outputReference);
|
|
142
|
+
return object && output
|
|
143
|
+
? { kind: 'lookup', name, object, output, nexts: nextsOf(element) }
|
|
144
|
+
: { kind: 'other', name, nexts: nextsOf(element) };
|
|
145
|
+
});
|
|
146
|
+
each('decisions', parseDecision);
|
|
147
|
+
each('customErrors', (name, element) => ({
|
|
148
|
+
kind: 'customError',
|
|
149
|
+
name,
|
|
150
|
+
message: text(asArray(element.customErrorMessages)[0]?.errorMessage),
|
|
151
|
+
nexts: nextsOf(element),
|
|
152
|
+
}));
|
|
153
|
+
for (const type of PASS_THROUGH_TYPES)
|
|
154
|
+
each(type, (name, element) => ({ kind: 'other', name, nexts: nextsOf(element) }));
|
|
155
|
+
for (const type of STOP_TYPES)
|
|
156
|
+
each(type, (name, element) => ({ kind: 'stop', name, nexts: nextsOf(element) }));
|
|
157
|
+
const formulas = {};
|
|
158
|
+
for (const formula of asArray(flow.formulas)) {
|
|
159
|
+
const name = text(formula.name);
|
|
160
|
+
const expr = parseFormula(text(formula.expression) ?? '');
|
|
161
|
+
if (name && expr)
|
|
162
|
+
formulas[name] = expr;
|
|
163
|
+
}
|
|
164
|
+
return { start: target(asRecord(flow.start)?.connector), nodes, formulas };
|
|
165
|
+
}
|
|
166
|
+
/** Every write, create, and custom error reachable from `starts`, along any path. */
|
|
167
|
+
function reachable(graph, starts) {
|
|
168
|
+
const outcome = { writes: [], variables: [], creates: [], customError: false };
|
|
169
|
+
const seen = new Set();
|
|
170
|
+
const queue = starts.filter((s) => !!s);
|
|
171
|
+
while (queue.length > 0) {
|
|
172
|
+
const name = queue.shift();
|
|
173
|
+
if (seen.has(name))
|
|
174
|
+
continue;
|
|
175
|
+
seen.add(name);
|
|
176
|
+
const node = graph.nodes[name];
|
|
177
|
+
if (!node)
|
|
178
|
+
continue;
|
|
179
|
+
if (node.kind === 'write') {
|
|
180
|
+
outcome.writes.push(...node.writes);
|
|
181
|
+
outcome.variables.push(...node.variables);
|
|
182
|
+
}
|
|
183
|
+
if (node.kind === 'create')
|
|
184
|
+
outcome.creates.push(node.create);
|
|
185
|
+
if (node.kind === 'customError')
|
|
186
|
+
outcome.customError = true;
|
|
187
|
+
queue.push(...node.nexts);
|
|
188
|
+
}
|
|
189
|
+
return outcome;
|
|
190
|
+
}
|
|
191
|
+
function undecidedAt(graph, node) {
|
|
192
|
+
const outcomes = node.kind === 'decision'
|
|
193
|
+
? [
|
|
194
|
+
...node.rules.map((rule) => ({ label: rule.label, ...reachable(graph, [rule.next]) })),
|
|
195
|
+
{ label: node.defaultLabel, ...reachable(graph, [node.defaultNext]) },
|
|
196
|
+
]
|
|
197
|
+
: [{ label: `after ${node.name}`, ...reachable(graph, node.nexts) }];
|
|
198
|
+
return {
|
|
199
|
+
element: node.kind === 'decision' ? node.label : node.name,
|
|
200
|
+
outcomes: outcomes.filter((o) => o.writes.length + o.variables.length + o.creates.length > 0 || o.customError),
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Follows the Flow from its start for a record in the given state, through every decision the
|
|
205
|
+
* state decides, and reports what is certain to happen.
|
|
206
|
+
*/
|
|
207
|
+
export function walkFlow(graph, initial, options = {}) {
|
|
208
|
+
const state = new Map(initial);
|
|
209
|
+
const env = { get: (reference) => state.get(reference), formula: (name) => graph.formulas[name] };
|
|
210
|
+
const walk = {
|
|
211
|
+
writes: [],
|
|
212
|
+
variables: [],
|
|
213
|
+
creates: [],
|
|
214
|
+
decisions: [],
|
|
215
|
+
};
|
|
216
|
+
const created = new Set();
|
|
217
|
+
const set = (reference, value) => {
|
|
218
|
+
if (value.apexValue === undefined)
|
|
219
|
+
state.delete(reference);
|
|
220
|
+
else
|
|
221
|
+
state.set(reference, value.apexValue);
|
|
222
|
+
};
|
|
223
|
+
const seen = new Set();
|
|
224
|
+
let current = graph.start;
|
|
225
|
+
while (current && !seen.has(current)) {
|
|
226
|
+
seen.add(current);
|
|
227
|
+
const node = graph.nodes[current];
|
|
228
|
+
if (!node)
|
|
229
|
+
break;
|
|
230
|
+
switch (node.kind) {
|
|
231
|
+
case 'write':
|
|
232
|
+
for (const write of node.writes) {
|
|
233
|
+
walk.writes.push(write);
|
|
234
|
+
set(`$Record.${write.field}`, write.value);
|
|
235
|
+
}
|
|
236
|
+
for (const write of node.variables) {
|
|
237
|
+
walk.variables.push(write);
|
|
238
|
+
set(write.variable, write.value);
|
|
239
|
+
}
|
|
240
|
+
current = node.nexts[0];
|
|
241
|
+
break;
|
|
242
|
+
case 'create':
|
|
243
|
+
walk.creates.push(node.create);
|
|
244
|
+
created.add(node.create.object);
|
|
245
|
+
current = node.nexts[0];
|
|
246
|
+
break;
|
|
247
|
+
case 'lookup':
|
|
248
|
+
if (!created.has(node.object) && options.emptyObject?.(node.object))
|
|
249
|
+
state.set(node.output, null);
|
|
250
|
+
else
|
|
251
|
+
state.delete(node.output);
|
|
252
|
+
current = node.nexts[0];
|
|
253
|
+
break;
|
|
254
|
+
case 'customError':
|
|
255
|
+
return { ...walk, customError: { element: node.name, message: node.message } };
|
|
256
|
+
case 'decision': {
|
|
257
|
+
let taken;
|
|
258
|
+
for (const rule of node.rules) {
|
|
259
|
+
const result = evaluateCondition(rule.condition, env);
|
|
260
|
+
if (result === undefined)
|
|
261
|
+
return { ...walk, undecided: undecidedAt(graph, node) };
|
|
262
|
+
if (result) {
|
|
263
|
+
taken = rule;
|
|
264
|
+
break;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
walk.decisions.push({ element: node.name, rule: taken });
|
|
268
|
+
current = taken ? taken.next : node.defaultNext;
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
case 'stop':
|
|
272
|
+
return { ...walk, undecided: undecidedAt(graph, node) };
|
|
273
|
+
default:
|
|
274
|
+
current = node.nexts[0];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return walk;
|
|
278
|
+
}
|
|
279
|
+
//# sourceMappingURL=flowGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowGraph.js","sourceRoot":"","sources":["../../src/core/flowGraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,iBAAiB,EAAsB,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3G,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAkB,cAAc,EAAE,IAAI,EAAkB,MAAM,iBAAiB,CAAC;AAC1G,OAAO,EAAa,YAAY,EAAE,MAAM,cAAc,CAAC;AAmDvD,MAAM,kBAAkB,GAAG;IACzB,aAAa;IACb,iBAAiB;IACjB,sBAAsB;IACtB,eAAe;IACf,iBAAiB;IACjB,UAAU;IACV,YAAY;CACJ,CAAC;AAEX,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,CAAU,CAAC;AAEzF,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG;QACD,GAAG,kBAAkB;QACrB,GAAG,UAAU;QACb,aAAa;QACb,WAAW;QACX,eAAe;QACf,eAAe;QACf,eAAe;QACf,cAAc;QACd,UAAU;KACX,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,IAAI,EAAE,CAAC;IAC/B,kCAAkC;IAClC,sBAAsB;IACtB,iCAAiC;IACjC,qCAAqC;IACrC,4BAA4B;IAC5B,qCAAqC;IACrC,uCAAuC;CACxC,CAAC;AAEF,MAAM,YAAY,GAAG,qCAAqC,CAAC;AAC3D,MAAM,QAAQ,GAAG,yBAAyB,CAAC;AAE3C,MAAM,MAAM,GAAG,CAAC,SAAkB,EAAsB,EAAE,CAAC,IAA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,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;gBACzD,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC;gBAChD,MAAM;YACR,CAAC;YACD,KAAK,MAAM;gBACT,OAAO,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC;YAC1D;gBACE,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Reads one metadata component, as `connection.metadata.read(type, fullName)` does. */
|
|
2
|
+
export type MetadataRead = (type: string, fullName: string) => Promise<unknown>;
|
|
3
|
+
/**
|
|
4
|
+
* Whether "Deploy processes and flows as active" is on (`FlowSettings.enableFlowDeployAsActiveEnabled`).
|
|
5
|
+
* Undefined when the setting can't be read, for example without access to settings metadata.
|
|
6
|
+
*/
|
|
7
|
+
export declare function readDeployAsActive(read: MetadataRead): Promise<boolean | undefined>;
|
|
8
|
+
/** Runs a SOQL query against the org's data API (not the Tooling API). */
|
|
9
|
+
export type DataQuery = <T extends Record<string, unknown>>(soql: string) => Promise<T[]>;
|
|
10
|
+
/** Whether the org is a sandbox or scratch org. Undefined when it can't be read. */
|
|
11
|
+
export declare function readIsSandbox(query: DataQuery): Promise<boolean | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* What the setting means for the org, given whether coverage meets the threshold. The setting
|
|
14
|
+
* only affects production: sandboxes and scratch orgs deploy Flows with the status in their metadata.
|
|
15
|
+
*/
|
|
16
|
+
export declare function deployAsActiveAdvice(on: boolean, ready: boolean, threshold: number, sandbox?: boolean): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether "Deploy processes and flows as active" is on (`FlowSettings.enableFlowDeployAsActiveEnabled`).
|
|
3
|
+
* Undefined when the setting can't be read, for example without access to settings metadata.
|
|
4
|
+
*/
|
|
5
|
+
export async function readDeployAsActive(read) {
|
|
6
|
+
let settings;
|
|
7
|
+
try {
|
|
8
|
+
settings = await read('FlowSettings', 'Flow');
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
// The Metadata API returns some settings as booleans and others as "true"/"false" strings.
|
|
14
|
+
const value = settings
|
|
15
|
+
?.enableFlowDeployAsActiveEnabled;
|
|
16
|
+
if (value === true || value === 'true')
|
|
17
|
+
return true;
|
|
18
|
+
if (value === false || value === 'false')
|
|
19
|
+
return false;
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
/** Whether the org is a sandbox or scratch org. Undefined when it can't be read. */
|
|
23
|
+
export async function readIsSandbox(query) {
|
|
24
|
+
try {
|
|
25
|
+
const [org] = await query('SELECT IsSandbox FROM Organization');
|
|
26
|
+
return typeof org?.IsSandbox === 'boolean' ? org.IsSandbox : undefined;
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* What the setting means for the org, given whether coverage meets the threshold. The setting
|
|
34
|
+
* only affects production: sandboxes and scratch orgs deploy Flows with the status in their metadata.
|
|
35
|
+
*/
|
|
36
|
+
export function deployAsActiveAdvice(on, ready, threshold, sandbox = false) {
|
|
37
|
+
if (sandbox) {
|
|
38
|
+
return `Deploy processes and flows as active is ${on ? 'on' : 'off'} here, but it only affects deployments to production: sandboxes and scratch orgs deploy Flows with the status in their metadata. Check production with this command to see where it stands.`;
|
|
39
|
+
}
|
|
40
|
+
if (on) {
|
|
41
|
+
return ready
|
|
42
|
+
? 'Deploy processes and flows as active is on. Keep coverage at or above the threshold: deployments that include active Flows fail below it.'
|
|
43
|
+
: `Deploy processes and flows as active is on, but coverage is below ${threshold}%: deployments that include active Flows will fail until it is back up.`;
|
|
44
|
+
}
|
|
45
|
+
return ready
|
|
46
|
+
? 'Deploy processes and flows as active is off. The org has the coverage it needs: turn it on in Setup > Process Automation Settings.'
|
|
47
|
+
: `Deploy processes and flows as active is off. Reach ${threshold}% first, then turn it on in Setup > Process Automation Settings.`;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=flowSettings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowSettings.js","sourceRoot":"","sources":["../../src/core/flowSettings.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAkB;IACzD,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,2FAA2F;IAC3F,MAAM,KAAK,GAAI,QAAsE;QACnF,EAAE,+BAA+B,CAAC;IACpC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,IAAI,CAAC;IACpD,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACvD,OAAO,SAAS,CAAC;AACnB,CAAC;AAKD,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAgB;IAClD,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,KAAK,CAA0B,oCAAoC,CAAC,CAAC;QACzF,OAAO,OAAO,GAAG,EAAE,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;IACzE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAW,EAAE,KAAc,EAAE,SAAiB,EAAE,OAAO,GAAG,KAAK;IAClG,IAAI,OAAO,EAAE,CAAC;QACZ,OAAO,2CAA2C,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,6LAA6L,CAAC;IACnQ,CAAC;IACD,IAAI,EAAE,EAAE,CAAC;QACP,OAAO,KAAK;YACV,CAAC,CAAC,2IAA2I;YAC7I,CAAC,CAAC,qEAAqE,SAAS,yEAAyE,CAAC;IAC9J,CAAC;IACD,OAAO,KAAK;QACV,CAAC,CAAC,oIAAoI;QACtI,CAAC,CAAC,sDAAsD,SAAS,kEAAkE,CAAC;AACxI,CAAC"}
|
package/lib/core/flowTypes.d.ts
CHANGED
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const COUNTED_PROCESS_TYPES: readonly ['AutoLaunchedFlow', 'Workflow', 'CustomEvent', 'InvocableProcess'];
|
|
7
7
|
export declare const DEFAULT_THRESHOLD = 75;
|
|
8
|
+
/** True for Process Builder processes, which Salesforce no longer supports. */
|
|
9
|
+
export declare function isProcessBuilder(processType: string | undefined): boolean;
|
|
10
|
+
/** A readable name for a process type: `Process Builder (record change)` for `Workflow`, else the type itself. */
|
|
11
|
+
export declare function processTypeLabel(processType: string): string;
|
|
12
|
+
/** What to do about Process Builder processes instead of writing tests for them. */
|
|
13
|
+
export declare const PROCESS_BUILDER_ADVICE = "Salesforce no longer supports Process Builder. Migrate processes to Flows with the Migrate to Flow tool in Setup rather than writing tests for them; each migrated Flow still needs an Apex test.";
|
|
8
14
|
export declare function isCountedProcessType(processType: string | undefined): boolean;
|
|
9
15
|
export declare function qualifiedFlowName(developerName: string, namespacePrefix?: string | null): string;
|
|
10
16
|
/** Splits `ns__Flow_Name` into namespace and developer name. Flow names cannot contain `__`, so the first one is the separator. */
|
package/lib/core/flowTypes.js
CHANGED
|
@@ -5,6 +5,23 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export const COUNTED_PROCESS_TYPES = ['AutoLaunchedFlow', 'Workflow', 'CustomEvent', 'InvocableProcess'];
|
|
7
7
|
export const DEFAULT_THRESHOLD = 75;
|
|
8
|
+
/** Process Builder process types, with what starts each. */
|
|
9
|
+
const PROCESS_BUILDER_TYPES = {
|
|
10
|
+
workflow: 'record change',
|
|
11
|
+
customevent: 'platform event',
|
|
12
|
+
invocableprocess: 'invocable',
|
|
13
|
+
};
|
|
14
|
+
/** True for Process Builder processes, which Salesforce no longer supports. */
|
|
15
|
+
export function isProcessBuilder(processType) {
|
|
16
|
+
return !!processType && processType.toLowerCase() in PROCESS_BUILDER_TYPES;
|
|
17
|
+
}
|
|
18
|
+
/** A readable name for a process type: `Process Builder (record change)` for `Workflow`, else the type itself. */
|
|
19
|
+
export function processTypeLabel(processType) {
|
|
20
|
+
const trigger = PROCESS_BUILDER_TYPES[processType.toLowerCase()];
|
|
21
|
+
return trigger ? `Process Builder (${trigger})` : processType;
|
|
22
|
+
}
|
|
23
|
+
/** What to do about Process Builder processes instead of writing tests for them. */
|
|
24
|
+
export const PROCESS_BUILDER_ADVICE = 'Salesforce no longer supports Process Builder. Migrate processes to Flows with the Migrate to Flow tool in Setup rather than writing tests for them; each migrated Flow still needs an Apex test.';
|
|
8
25
|
export function isCountedProcessType(processType) {
|
|
9
26
|
if (!processType)
|
|
10
27
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flowTypes.js","sourceRoot":"","sources":["../../src/core/flowTypes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,kBAAkB,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,CAAU,CAAC;AAElH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,MAAM,UAAU,oBAAoB,CAAC,WAA+B;IAClE,IAAI,CAAC,WAAW;QAAE,OAAO,KAAK,CAAC;IAC/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CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;AACjG,CAAC;AAED,MAAM,SAAS,GAAG,iCAAiC,CAAC;AAEpD,6HAA6H;AAC7H,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Helpers for reading values out of Flow metadata XML parsed by fast-xml-parser. */
|
|
2
|
+
export type XmlRecord = Record<string, unknown>;
|
|
3
|
+
/** A Flow value (`<value>` or `<rightValue>`) as an Apex literal, when it is one, and as raw text. */
|
|
4
|
+
export type FlowValue = {
|
|
5
|
+
/** Apex literal for the value, when it can be expressed as one. */
|
|
6
|
+
apexValue?: string;
|
|
7
|
+
/** Raw value text, for TODO comments. */
|
|
8
|
+
rawValue?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function text(value: unknown): string | undefined;
|
|
11
|
+
export declare function asRecord(value: unknown): XmlRecord | undefined;
|
|
12
|
+
export declare function asArray(value: unknown): XmlRecord[];
|
|
13
|
+
export declare function escapeApexString(value: string): string;
|
|
14
|
+
export declare function parseFlowValue(value: XmlRecord | undefined): FlowValue;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Helpers for reading values out of Flow metadata XML parsed by fast-xml-parser. */
|
|
2
|
+
export function text(value) {
|
|
3
|
+
if (value === undefined || value === null)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (typeof value === 'string')
|
|
6
|
+
return value;
|
|
7
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
8
|
+
return String(value);
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
export function asRecord(value) {
|
|
12
|
+
return value && typeof value === 'object' && !Array.isArray(value) ? value : undefined;
|
|
13
|
+
}
|
|
14
|
+
export function asArray(value) {
|
|
15
|
+
return Array.isArray(value) ? value.filter((v) => !!asRecord(v)) : [];
|
|
16
|
+
}
|
|
17
|
+
export function escapeApexString(value) {
|
|
18
|
+
return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\r?\n/g, '\\n');
|
|
19
|
+
}
|
|
20
|
+
export function parseFlowValue(value) {
|
|
21
|
+
if (!value)
|
|
22
|
+
return {};
|
|
23
|
+
const stringValue = text(value.stringValue);
|
|
24
|
+
if (stringValue !== undefined)
|
|
25
|
+
return { apexValue: `'${escapeApexString(stringValue)}'`, rawValue: stringValue };
|
|
26
|
+
const booleanValue = text(value.booleanValue);
|
|
27
|
+
if (booleanValue !== undefined)
|
|
28
|
+
return { apexValue: booleanValue === 'true' ? 'true' : 'false', rawValue: booleanValue };
|
|
29
|
+
const numberValue = text(value.numberValue);
|
|
30
|
+
if (numberValue !== undefined && !Number.isNaN(Number(numberValue))) {
|
|
31
|
+
return { apexValue: numberValue, rawValue: numberValue };
|
|
32
|
+
}
|
|
33
|
+
const dateValue = text(value.dateValue);
|
|
34
|
+
if (dateValue !== undefined)
|
|
35
|
+
return { apexValue: `Date.valueOf('${escapeApexString(dateValue)}')`, rawValue: dateValue };
|
|
36
|
+
const dateTimeValue = text(value.dateTimeValue);
|
|
37
|
+
const dateTime = dateTimeValue && /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})/.exec(dateTimeValue);
|
|
38
|
+
if (dateTime)
|
|
39
|
+
return { apexValue: `Datetime.valueOfGmt('${dateTime[1]} ${dateTime[2]}')`, rawValue: dateTimeValue };
|
|
40
|
+
const raw = text(value.elementReference) ?? text(value.formulaExpression) ?? dateTimeValue;
|
|
41
|
+
return raw === undefined ? {} : { rawValue: raw };
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=flowValues.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flowValues.js","sourceRoot":"","sources":["../../src/core/flowValues.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAYrF,MAAM,UAAU,IAAI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AAE,CAAC;AACpD,CAAC"}
|
package/lib/core/flowXml.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FlowMetadata } from './types.js';
|
|
2
|
-
export
|
|
2
|
+
export { escapeApexString } from './flowValues.js';
|
|
3
3
|
/**
|
|
4
4
|
* Reads the parts of a Flow metadata file needed to judge whether it counts toward
|
|
5
5
|
* the deploy-as-active coverage requirement and to scaffold an Apex test for it.
|