@salesforce/metadata-plugins 1.10.0 → 1.11.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/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/plugins/agent/ui/assets/index-BpnirPMA.js +71 -0
- package/dist/plugins/agent/ui/index.html +1 -1
- package/dist/plugins/flexipage/ui/assets/index-DJj6fJsw.js +48 -0
- package/dist/plugins/flexipage/ui/index.html +1 -1
- package/dist/plugins/flow/ui/assets/index-B-Cn56iR.js +48 -0
- package/dist/plugins/flow/ui/index.html +1 -1
- package/dist/plugins/flowintent/FlowIntentParser.d.ts +56 -0
- package/dist/plugins/flowintent/FlowIntentParser.d.ts.map +1 -0
- package/dist/plugins/flowintent/FlowIntentParser.js +144 -0
- package/dist/plugins/flowintent/FlowIntentVisualizer.d.ts +41 -0
- package/dist/plugins/flowintent/FlowIntentVisualizer.d.ts.map +1 -0
- package/dist/plugins/flowintent/FlowIntentVisualizer.js +43 -0
- package/dist/plugins/flowintent/types/IntentFlow.d.ts +139 -0
- package/dist/plugins/flowintent/types/IntentFlow.d.ts.map +1 -0
- package/dist/plugins/flowintent/types/IntentFlow.js +89 -0
- package/dist/plugins/flowintent/types/analyzeFlowBuilderGraph.d.ts +42 -0
- package/dist/plugins/flowintent/types/analyzeFlowBuilderGraph.d.ts.map +1 -0
- package/dist/plugins/flowintent/types/analyzeFlowBuilderGraph.js +226 -0
- package/dist/plugins/flowintent/types/analyzeIntentFlowGraph.d.ts +27 -0
- package/dist/plugins/flowintent/types/analyzeIntentFlowGraph.d.ts.map +1 -0
- package/dist/plugins/flowintent/types/analyzeIntentFlowGraph.js +80 -0
- package/dist/plugins/flowintent/types/index.d.ts +17 -0
- package/dist/plugins/flowintent/types/index.d.ts.map +1 -0
- package/dist/plugins/flowintent/types/index.js +16 -0
- package/dist/plugins/flowintent/types/validateIntentFlow.d.ts +32 -0
- package/dist/plugins/flowintent/types/validateIntentFlow.d.ts.map +1 -0
- package/dist/plugins/flowintent/types/validateIntentFlow.js +438 -0
- package/dist/plugins/flowintent/ui/assets/index-BkuUZejF.js +48 -0
- package/dist/plugins/flowintent/ui/assets/index-Di3MtBl5.css +1 -0
- package/dist/plugins/flowintent/ui/index.html +18 -0
- package/dist/plugins/permissionset/ui/assets/index-BCcTde0G.js +48 -0
- package/dist/plugins/permissionset/ui/index.html +1 -1
- package/dist/plugins/schema/ui/assets/index-BBcLTTbn.js +70 -0
- package/dist/plugins/schema/ui/index.html +1 -1
- package/dist/shared/bootstrap/createPluginApp.d.ts +14 -10
- package/dist/shared/bootstrap/createPluginApp.d.ts.map +1 -1
- package/dist/shared/bootstrap/createPluginApp.js +78 -17
- package/dist/shared/components/FlowIcons.d.ts +107 -0
- package/dist/shared/components/FlowIcons.d.ts.map +1 -0
- package/dist/shared/components/FlowIcons.js +243 -0
- package/package.json +3 -3
- package/dist/plugins/agent/ui/assets/index-C_Q6Mc2L.js +0 -71
- package/dist/plugins/flexipage/ui/assets/index-CuJYcAx_.js +0 -48
- package/dist/plugins/flow/ui/assets/index-OhJU6yxp.js +0 -48
- package/dist/plugins/permissionset/ui/assets/index-CMInRbR2.js +0 -48
- package/dist/plugins/schema/ui/assets/index-CWvLR0Fz.js +0 -70
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import { analyzeIntentFlowGraph } from './analyzeIntentFlowGraph.js';
|
|
8
|
+
function reachableNodes(start, adjacency) {
|
|
9
|
+
const distance = new Map([[start, 0]]);
|
|
10
|
+
const queue = [start];
|
|
11
|
+
for (let cursor = 0; cursor < queue.length; cursor += 1) {
|
|
12
|
+
const current = queue[cursor];
|
|
13
|
+
for (const next of adjacency.get(current) ?? []) {
|
|
14
|
+
if (!distance.has(next)) {
|
|
15
|
+
distance.set(next, (distance.get(current) ?? 0) + 1);
|
|
16
|
+
queue.push(next);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return distance;
|
|
21
|
+
}
|
|
22
|
+
/** Find the first common continuation of a branching node's paths. */
|
|
23
|
+
function findBranchMerge(outcomes, adjacency, topologicalIndex) {
|
|
24
|
+
if (outcomes.length < 2) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const distances = outcomes.map((edge) => reachableNodes(edge.to, adjacency));
|
|
28
|
+
const candidates = [...distances[0].keys()].filter((id) => distances.every((distance) => distance.has(id)));
|
|
29
|
+
const summaries = candidates.map((id) => {
|
|
30
|
+
let maxDistance = 0;
|
|
31
|
+
let totalDistance = 0;
|
|
32
|
+
for (const distance of distances) {
|
|
33
|
+
const value = distance.get(id);
|
|
34
|
+
maxDistance = Math.max(maxDistance, value);
|
|
35
|
+
totalDistance += value;
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
id,
|
|
39
|
+
maxDistance,
|
|
40
|
+
totalDistance,
|
|
41
|
+
topologicalIndex: topologicalIndex.get(id) ?? 0,
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
summaries.sort((a, b) => a.maxDistance - b.maxDistance ||
|
|
45
|
+
a.totalDistance - b.totalDistance ||
|
|
46
|
+
a.topologicalIndex - b.topologicalIndex);
|
|
47
|
+
return summaries[0]?.id;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Translate flat IntentFlow edges into the path roles used by Flow Builder's
|
|
51
|
+
* structural renderer. This internal model does not alter the payload shape.
|
|
52
|
+
*/
|
|
53
|
+
export function analyzeFlowBuilderGraph(flow) {
|
|
54
|
+
const nodesById = new Map(flow.nodes.map((node) => [node.id, node]));
|
|
55
|
+
const outgoingByNode = new Map(flow.nodes.map((node) => [node.id, []]));
|
|
56
|
+
const incomingByNode = new Map(flow.nodes.map((node) => [node.id, []]));
|
|
57
|
+
const indexedEdges = flow.edges.map((edge, index) => ({
|
|
58
|
+
...edge,
|
|
59
|
+
index,
|
|
60
|
+
kind: edge.kind ?? 'sequence',
|
|
61
|
+
}));
|
|
62
|
+
for (const edge of indexedEdges) {
|
|
63
|
+
outgoingByNode.get(edge.from)?.push(edge);
|
|
64
|
+
incomingByNode.get(edge.to)?.push(edge);
|
|
65
|
+
}
|
|
66
|
+
const graph = analyzeIntentFlowGraph(flow.nodes.map((node) => node.id), indexedEdges);
|
|
67
|
+
const topologicalIndex = new Map(graph.topologicalOrder.map((id, index) => [id, index]));
|
|
68
|
+
const loopReturnSourcesByNode = new Map();
|
|
69
|
+
for (const node of flow.nodes.filter((candidate) => candidate.type === 'loop')) {
|
|
70
|
+
loopReturnSourcesByNode.set(node.id, (incomingByNode.get(node.id) ?? [])
|
|
71
|
+
.filter((edge) => edge.kind === 'loop-back')
|
|
72
|
+
.map((edge) => edge.from));
|
|
73
|
+
}
|
|
74
|
+
const isLoopBodyEdge = (edge) => (loopReturnSourcesByNode.get(edge.from) ?? []).some((returnSource) => returnSource === edge.to ||
|
|
75
|
+
reachableNodes(edge.to, graph.nonLoopAdjacency).has(returnSource));
|
|
76
|
+
// Flow Builder gives loop bodies and fault paths their own execution
|
|
77
|
+
// contexts. A path that crosses one of those boundaries remains valid, but
|
|
78
|
+
// it is represented as a GoTo rather than a structural branch or merge.
|
|
79
|
+
const contextByNode = new Map();
|
|
80
|
+
const crossContextEdgeIndexes = new Set();
|
|
81
|
+
const contextEdges = (nodeId) => [...(outgoingByNode.get(nodeId) ?? [])]
|
|
82
|
+
.filter((edge) => edge.kind !== 'loop-back')
|
|
83
|
+
.sort((a, b) => Number(a.kind === 'fault') - Number(b.kind === 'fault') || a.index - b.index);
|
|
84
|
+
const visitContext = (nodeId, context) => {
|
|
85
|
+
if (contextByNode.has(nodeId)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
contextByNode.set(nodeId, context);
|
|
89
|
+
const stack = [
|
|
90
|
+
{ nodeId, context, outgoing: contextEdges(nodeId), nextEdgeIndex: 0 },
|
|
91
|
+
];
|
|
92
|
+
while (stack.length > 0) {
|
|
93
|
+
const frame = stack[stack.length - 1];
|
|
94
|
+
const edge = frame.outgoing[frame.nextEdgeIndex];
|
|
95
|
+
if (!edge) {
|
|
96
|
+
stack.pop();
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
frame.nextEdgeIndex += 1;
|
|
100
|
+
const source = nodesById.get(frame.nodeId);
|
|
101
|
+
const nextContext = edge.kind === 'fault'
|
|
102
|
+
? `${frame.context}|fault:${edge.from}:${edge.index}`
|
|
103
|
+
: source?.type === 'loop' && isLoopBodyEdge(edge)
|
|
104
|
+
? `${frame.context}|loop:${edge.from}`
|
|
105
|
+
: frame.context;
|
|
106
|
+
const targetContext = contextByNode.get(edge.to);
|
|
107
|
+
if (targetContext === undefined) {
|
|
108
|
+
contextByNode.set(edge.to, nextContext);
|
|
109
|
+
stack.push({
|
|
110
|
+
nodeId: edge.to,
|
|
111
|
+
context: nextContext,
|
|
112
|
+
outgoing: contextEdges(edge.to),
|
|
113
|
+
nextEdgeIndex: 0,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
else if (targetContext !== nextContext) {
|
|
117
|
+
crossContextEdgeIndexes.add(edge.index);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
const start = flow.nodes.find((node) => node.type === 'start');
|
|
122
|
+
if (start) {
|
|
123
|
+
visitContext(start.id, 'root');
|
|
124
|
+
}
|
|
125
|
+
const mergeGraph = analyzeIntentFlowGraph(flow.nodes.map((node) => node.id), indexedEdges.filter((edge) => !crossContextEdgeIndexes.has(edge.index)));
|
|
126
|
+
const mergeByBranchingNode = new Map();
|
|
127
|
+
const mergeOwnerByNode = new Map();
|
|
128
|
+
for (const node of flow.nodes) {
|
|
129
|
+
if (node.type !== 'decision' && node.type !== 'start') {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const outcomes = (outgoingByNode.get(node.id) ?? []).filter((edge) => node.type === 'decision' || edge.kind !== 'fault');
|
|
133
|
+
const merge = findBranchMerge(outcomes, mergeGraph.nonLoopAdjacency, topologicalIndex);
|
|
134
|
+
if (merge) {
|
|
135
|
+
mergeByBranchingNode.set(node.id, merge);
|
|
136
|
+
const currentOwner = mergeOwnerByNode.get(merge);
|
|
137
|
+
if (currentOwner === undefined ||
|
|
138
|
+
(topologicalIndex.get(node.id) ?? Number.POSITIVE_INFINITY) <
|
|
139
|
+
(topologicalIndex.get(currentOwner) ?? Number.POSITIVE_INFINITY)) {
|
|
140
|
+
mergeOwnerByNode.set(merge, node.id);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const [branchingNodeId, mergeId] of mergeByBranchingNode) {
|
|
145
|
+
if (mergeOwnerByNode.get(mergeId) !== branchingNodeId) {
|
|
146
|
+
mergeByBranchingNode.delete(branchingNodeId);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const roleByEdgeIndex = new Map();
|
|
150
|
+
for (const edge of indexedEdges) {
|
|
151
|
+
const source = nodesById.get(edge.from);
|
|
152
|
+
if (edge.kind === 'loop-back') {
|
|
153
|
+
roleByEdgeIndex.set(edge.index, 'loop-back');
|
|
154
|
+
}
|
|
155
|
+
else if (edge.kind === 'fault') {
|
|
156
|
+
roleByEdgeIndex.set(edge.index, 'fault');
|
|
157
|
+
}
|
|
158
|
+
else if (source?.type === 'start') {
|
|
159
|
+
roleByEdgeIndex.set(edge.index, 'start-path');
|
|
160
|
+
}
|
|
161
|
+
else if (source?.type === 'decision' && edge.kind === 'branch') {
|
|
162
|
+
roleByEdgeIndex.set(edge.index, 'decision-outcome');
|
|
163
|
+
}
|
|
164
|
+
else if (source?.type === 'loop') {
|
|
165
|
+
roleByEdgeIndex.set(edge.index, isLoopBodyEdge(edge) ? 'loop-for-each' : 'loop-after-last');
|
|
166
|
+
}
|
|
167
|
+
else {
|
|
168
|
+
roleByEdgeIndex.set(edge.index, 'next');
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
const mergeTailEdgeIndexes = new Set();
|
|
172
|
+
for (const [mergeId, branchingNodeId] of mergeOwnerByNode) {
|
|
173
|
+
const branchingNode = nodesById.get(branchingNodeId);
|
|
174
|
+
const outcomes = (outgoingByNode.get(branchingNodeId) ?? []).filter((edge) => branchingNode?.type === 'start' || edge.kind === 'branch');
|
|
175
|
+
const outcomeReachability = outcomes.map((edge) => reachableNodes(edge.to, mergeGraph.nonLoopAdjacency));
|
|
176
|
+
for (const edge of incomingByNode.get(mergeId) ?? []) {
|
|
177
|
+
if (edge.kind !== 'loop-back' &&
|
|
178
|
+
!crossContextEdgeIndexes.has(edge.index) &&
|
|
179
|
+
outcomeReachability.some((reachable) => reachable.has(edge.from))) {
|
|
180
|
+
mergeTailEdgeIndexes.add(edge.index);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
for (const edgeIndex of crossContextEdgeIndexes) {
|
|
185
|
+
roleByEdgeIndex.set(edgeIndex, 'go-to');
|
|
186
|
+
}
|
|
187
|
+
const isFaultContext = (context) => context?.includes('|fault:') ?? false;
|
|
188
|
+
const faultPathEdgeIndexes = new Set();
|
|
189
|
+
for (const edge of indexedEdges) {
|
|
190
|
+
// Flow Builder styles a connector according to the execution scope that
|
|
191
|
+
// emits it. A GoTo leaving a fault subtree therefore remains a fault
|
|
192
|
+
// connector even when its target is structurally owned by another scope.
|
|
193
|
+
if (edge.kind === 'fault' || isFaultContext(contextByNode.get(edge.from))) {
|
|
194
|
+
faultPathEdgeIndexes.add(edge.index);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// A Flow Builder node has one structural predecessor. Additional incoming
|
|
198
|
+
// paths that are not a decision merge become GoTo connectors.
|
|
199
|
+
for (const [, incoming] of incomingByNode) {
|
|
200
|
+
const forward = incoming.filter((edge) => edge.kind !== 'loop-back');
|
|
201
|
+
if (forward.length < 2 || forward.some((edge) => mergeTailEdgeIndexes.has(edge.index))) {
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
const structuralCandidates = forward.filter((edge) => roleByEdgeIndex.get(edge.index) !== 'go-to');
|
|
205
|
+
const structural = [...(structuralCandidates.length > 0 ? structuralCandidates : forward)].sort((a, b) => (topologicalIndex.get(a.from) ?? 0) - (topologicalIndex.get(b.from) ?? 0) ||
|
|
206
|
+
a.index - b.index)[0];
|
|
207
|
+
for (const edge of forward) {
|
|
208
|
+
if (edge.index !== structural.index) {
|
|
209
|
+
roleByEdgeIndex.set(edge.index, 'go-to');
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
nodesById,
|
|
215
|
+
outgoingByNode,
|
|
216
|
+
incomingByNode,
|
|
217
|
+
topologicalOrder: graph.topologicalOrder,
|
|
218
|
+
mergeByBranchingNode,
|
|
219
|
+
mergeOwnerByNode,
|
|
220
|
+
roleByEdgeIndex,
|
|
221
|
+
mergeTailEdgeIndexes,
|
|
222
|
+
contextByNode,
|
|
223
|
+
crossContextEdgeIndexes,
|
|
224
|
+
faultPathEdgeIndexes,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import type { EdgeKind } from './IntentFlow.js';
|
|
8
|
+
export interface IntentFlowGraphEdge {
|
|
9
|
+
from: string;
|
|
10
|
+
to: string;
|
|
11
|
+
kind?: EdgeKind;
|
|
12
|
+
}
|
|
13
|
+
export interface IntentFlowGraphAnalysis {
|
|
14
|
+
nonLoopAdjacency: Map<string, string[]>;
|
|
15
|
+
indegree: Map<string, number>;
|
|
16
|
+
topologicalOrder: string[];
|
|
17
|
+
depthByNode: Map<string, number>;
|
|
18
|
+
hasNonLoopCycle: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Analyze the forward graph. Explicit loop-back edges never establish rank,
|
|
22
|
+
* reachability, or acyclicity; they are validated against this result later.
|
|
23
|
+
*/
|
|
24
|
+
export declare function analyzeIntentFlowGraph(nodeIds: readonly string[], edges: readonly IntentFlowGraphEdge[]): IntentFlowGraphAnalysis;
|
|
25
|
+
/** True only when at least one directed forward edge connects `from` to `to`. */
|
|
26
|
+
export declare function hasDirectedPath(adjacency: ReadonlyMap<string, readonly string[]>, from: string, to: string): boolean;
|
|
27
|
+
//# sourceMappingURL=analyzeIntentFlowGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"analyzeIntentFlowGraph.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flowintent/types/analyzeIntentFlowGraph.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB;AAED,MAAM,WAAW,uBAAuB;IACtC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,KAAK,EAAE,SAAS,mBAAmB,EAAE,GACpC,uBAAuB,CA6DzB;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAC7B,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EACjD,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,GACT,OAAO,CAeT"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Analyze the forward graph. Explicit loop-back edges never establish rank,
|
|
9
|
+
* reachability, or acyclicity; they are validated against this result later.
|
|
10
|
+
*/
|
|
11
|
+
export function analyzeIntentFlowGraph(nodeIds, edges) {
|
|
12
|
+
const nodeOrder = new Map(nodeIds.map((id, index) => [id, index]));
|
|
13
|
+
const adjacencySets = new Map();
|
|
14
|
+
const indegree = new Map();
|
|
15
|
+
for (const id of nodeIds) {
|
|
16
|
+
adjacencySets.set(id, new Set());
|
|
17
|
+
indegree.set(id, 0);
|
|
18
|
+
}
|
|
19
|
+
for (const edge of edges) {
|
|
20
|
+
if (edge.kind === 'loop-back' ||
|
|
21
|
+
!adjacencySets.has(edge.from) ||
|
|
22
|
+
!adjacencySets.has(edge.to) ||
|
|
23
|
+
adjacencySets.get(edge.from).has(edge.to)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
adjacencySets.get(edge.from).add(edge.to);
|
|
27
|
+
indegree.set(edge.to, indegree.get(edge.to) + 1);
|
|
28
|
+
}
|
|
29
|
+
const nonLoopAdjacency = new Map();
|
|
30
|
+
for (const id of nodeIds) {
|
|
31
|
+
nonLoopAdjacency.set(id, [...(adjacencySets.get(id) ?? [])].sort((a, b) => (nodeOrder.get(a) ?? 0) - (nodeOrder.get(b) ?? 0)));
|
|
32
|
+
}
|
|
33
|
+
const remainingIndegree = new Map(indegree);
|
|
34
|
+
const depthByNode = new Map();
|
|
35
|
+
const queue = [];
|
|
36
|
+
for (const id of nodeIds) {
|
|
37
|
+
if ((remainingIndegree.get(id) ?? 0) === 0) {
|
|
38
|
+
depthByNode.set(id, 0);
|
|
39
|
+
queue.push(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const topologicalOrder = [];
|
|
43
|
+
for (let cursor = 0; cursor < queue.length; cursor += 1) {
|
|
44
|
+
const id = queue[cursor];
|
|
45
|
+
topologicalOrder.push(id);
|
|
46
|
+
const sourceDepth = depthByNode.get(id) ?? 0;
|
|
47
|
+
for (const target of nonLoopAdjacency.get(id) ?? []) {
|
|
48
|
+
depthByNode.set(target, Math.max(depthByNode.get(target) ?? 0, sourceDepth + 1));
|
|
49
|
+
const nextIndegree = (remainingIndegree.get(target) ?? 0) - 1;
|
|
50
|
+
remainingIndegree.set(target, nextIndegree);
|
|
51
|
+
if (nextIndegree === 0) {
|
|
52
|
+
queue.push(target);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
nonLoopAdjacency,
|
|
58
|
+
indegree,
|
|
59
|
+
topologicalOrder,
|
|
60
|
+
depthByNode,
|
|
61
|
+
hasNonLoopCycle: topologicalOrder.length !== nodeIds.length,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** True only when at least one directed forward edge connects `from` to `to`. */
|
|
65
|
+
export function hasDirectedPath(adjacency, from, to) {
|
|
66
|
+
const seen = new Set([from]);
|
|
67
|
+
const queue = [...(adjacency.get(from) ?? [])];
|
|
68
|
+
for (let cursor = 0; cursor < queue.length; cursor += 1) {
|
|
69
|
+
const current = queue[cursor];
|
|
70
|
+
if (current === to) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
if (seen.has(current)) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
seen.add(current);
|
|
77
|
+
queue.push(...(adjacency.get(current) ?? []));
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Re-exports for the vendored IntentFlow contract. Consumers in this package
|
|
9
|
+
* should import from `./types` (or a relative path to it) rather than reach
|
|
10
|
+
* into the individual files, so a future re-publish of the contract package
|
|
11
|
+
* can flip this barrel back to a single `export * from '@salesforce/...';` in
|
|
12
|
+
* one place.
|
|
13
|
+
*/
|
|
14
|
+
export { FLOW_INTENT_PLUGIN_ID, FLOW_TYPES, INTENT_NODE_TYPES, EDGE_KINDS, type FlowType, type EdgeKind, type IntentNodeType, type IntentFlowNode, type IntentFlowEdge, type IntentFlowGroup, type IntentFlow, type FlowIntentEmptyStateData, type FlowIntentViewData, isFlowIntentEmptyStateData, } from './IntentFlow.js';
|
|
15
|
+
export { validateIntentFlow, isIntentFlow, assertIntentFlow, IntentFlowValidationFailure, type IntentFlowValidationError, type IntentFlowValidationResult, } from './validateIntentFlow.js';
|
|
16
|
+
export { analyzeIntentFlowGraph, hasDirectedPath, type IntentFlowGraphAnalysis, type IntentFlowGraphEdge, } from './analyzeIntentFlowGraph.js';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flowintent/types/index.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;GAMG;AAEH,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,UAAU,EACf,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,2BAA2B,EAC3B,KAAK,yBAAyB,EAC9B,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,GACzB,MAAM,6BAA6B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Re-exports for the vendored IntentFlow contract. Consumers in this package
|
|
9
|
+
* should import from `./types` (or a relative path to it) rather than reach
|
|
10
|
+
* into the individual files, so a future re-publish of the contract package
|
|
11
|
+
* can flip this barrel back to a single `export * from '@salesforce/...';` in
|
|
12
|
+
* one place.
|
|
13
|
+
*/
|
|
14
|
+
export { FLOW_INTENT_PLUGIN_ID, FLOW_TYPES, INTENT_NODE_TYPES, EDGE_KINDS, isFlowIntentEmptyStateData, } from './IntentFlow.js';
|
|
15
|
+
export { validateIntentFlow, isIntentFlow, assertIntentFlow, IntentFlowValidationFailure, } from './validateIntentFlow.js';
|
|
16
|
+
export { analyzeIntentFlowGraph, hasDirectedPath, } from './analyzeIntentFlowGraph.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import { type IntentFlow } from './IntentFlow.js';
|
|
8
|
+
export interface IntentFlowValidationError {
|
|
9
|
+
path: string;
|
|
10
|
+
code: string;
|
|
11
|
+
/** Content-free description suitable for logs and cross-extension failures. */
|
|
12
|
+
message: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IntentFlowValidationResult {
|
|
15
|
+
valid: boolean;
|
|
16
|
+
errors: IntentFlowValidationError[];
|
|
17
|
+
warnings: IntentFlowValidationError[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Content-free failure raised by {@link assertIntentFlow}. The full validation
|
|
21
|
+
* result remains local to the validator; callers receive only the fixed code
|
|
22
|
+
* vocabulary and the total number of errors, which are safe for telemetry.
|
|
23
|
+
*/
|
|
24
|
+
export declare class IntentFlowValidationFailure extends Error {
|
|
25
|
+
readonly codes: readonly string[];
|
|
26
|
+
readonly errorCount: number;
|
|
27
|
+
constructor(errors: readonly IntentFlowValidationError[]);
|
|
28
|
+
}
|
|
29
|
+
export declare function validateIntentFlow(value: unknown): IntentFlowValidationResult;
|
|
30
|
+
export declare function isIntentFlow(value: unknown): value is IntentFlow;
|
|
31
|
+
export declare function assertIntentFlow(value: unknown): IntentFlow;
|
|
32
|
+
//# sourceMappingURL=validateIntentFlow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validateIntentFlow.d.ts","sourceRoot":"","sources":["../../../../src/plugins/flowintent/types/validateIntentFlow.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,EAKL,KAAK,UAAU,EAChB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,+EAA+E;IAC/E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,yBAAyB,EAAE,CAAC;IACpC,QAAQ,EAAE,yBAAyB,EAAE,CAAC;CACvC;AAED;;;;GAIG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,SAAgB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEhB,MAAM,EAAE,SAAS,yBAAyB,EAAE;CAOhE;AA+ED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAmY7E;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAM3D"}
|