@uipath/flow-tool 0.2.0 → 0.9.1
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/packager-tool.js +60673 -26342
- package/dist/services/flow-validate-service.d.ts +74 -0
- package/dist/services/node-validators/connector-validator.d.ts +10 -0
- package/dist/services/node-validators/index.d.ts +8 -0
- package/dist/services/node-validators/types.d.ts +47 -0
- package/dist/services/node-validators/workflow-rule-types.d.ts +89 -0
- package/dist/tool.js +241274 -108589
- package/dist/validation.d.ts +14 -0
- package/dist/validation.js +103440 -0
- package/package.json +23 -15
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type FlowNodeValidator, type ValidationIssue } from "./node-validators/index.js";
|
|
2
|
+
import type { WorkflowGovernanceEnforcements, WorkflowValidationRule } from "./node-validators/workflow-rule-types.js";
|
|
3
|
+
interface FlowValidateResult {
|
|
4
|
+
success: boolean;
|
|
5
|
+
filePath: string;
|
|
6
|
+
issues: ValidationIssue[];
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Optional hooks callers can use to extend validation without editing this
|
|
10
|
+
* service. See `packages/flow-tool/src/services/node-validators/types.ts`
|
|
11
|
+
* and `@uipath/flow-schema`'s `ValidationRule` for the two contribution
|
|
12
|
+
* layers.
|
|
13
|
+
*/
|
|
14
|
+
export interface FlowValidateOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Extra workflow-scoped rules appended after `builtInRules` and
|
|
17
|
+
* `conditionExpressionRule`. Authored against the structural shape
|
|
18
|
+
* of `@uipath/flow-schema`'s `ValidationRule` — either directly or
|
|
19
|
+
* via the locally-declared `WorkflowValidationRule` which avoids
|
|
20
|
+
* pulling flow-schema's declarations into the consumer's type graph.
|
|
21
|
+
*/
|
|
22
|
+
extraRules?: WorkflowValidationRule[];
|
|
23
|
+
/**
|
|
24
|
+
* Extra per-node validators appended after `defaultNodeValidators`.
|
|
25
|
+
*/
|
|
26
|
+
extraNodeValidators?: FlowNodeValidator[];
|
|
27
|
+
/**
|
|
28
|
+
* Governance enforcement data fetched from the platform API. When
|
|
29
|
+
* provided, the built-in `governanceRule` in `@uipath/flow-schema`
|
|
30
|
+
* validates agent nodes against these constraints (temperature,
|
|
31
|
+
* max tokens, HITL).
|
|
32
|
+
*/
|
|
33
|
+
governanceEnforcements?: WorkflowGovernanceEnforcements;
|
|
34
|
+
/**
|
|
35
|
+
* Available model names fetched from the platform API. When provided,
|
|
36
|
+
* the governance rule validates that agent node model selections are
|
|
37
|
+
* in this allow-list.
|
|
38
|
+
*/
|
|
39
|
+
availableModelNames?: string[];
|
|
40
|
+
}
|
|
41
|
+
export declare class FlowValidateService {
|
|
42
|
+
private readonly fs;
|
|
43
|
+
private readonly extraRules;
|
|
44
|
+
private readonly nodeValidators;
|
|
45
|
+
private readonly governanceEnforcements?;
|
|
46
|
+
private readonly availableModelNames?;
|
|
47
|
+
constructor(options?: FlowValidateOptions);
|
|
48
|
+
execute(flowFilePath: string): Promise<number>;
|
|
49
|
+
validateFile(flowFilePath: string): Promise<FlowValidateResult>;
|
|
50
|
+
private validateGraph;
|
|
51
|
+
private validateEdgeReferences;
|
|
52
|
+
private validateNodeTypeDefinitions;
|
|
53
|
+
private validateUniqueIds;
|
|
54
|
+
/** Uniqueness check for `variables.globals` IDs; called once per scope (root + each subflow). */
|
|
55
|
+
private validateGlobalVariableUniqueness;
|
|
56
|
+
/**
|
|
57
|
+
* Check that every edge references handles declared in the source/target
|
|
58
|
+
* node manifests, and that no handle exceeds its maxConnections constraint.
|
|
59
|
+
*
|
|
60
|
+
* Scope is deliberately narrow: we don't reproduce the canvas's full
|
|
61
|
+
* `validateConnection` (allowedTargets / forbiddenTargets / category
|
|
62
|
+
* constraints) because those fields are not guaranteed to round-trip
|
|
63
|
+
* through serialized manifests. If a node's whole definition is missing
|
|
64
|
+
* we skip — the "no matching definition" warning already covers that.
|
|
65
|
+
*/
|
|
66
|
+
private validateEdgeHandles;
|
|
67
|
+
/**
|
|
68
|
+
* Apply each configured `FlowNodeValidator` to every node. The default
|
|
69
|
+
* set ships with `connectorNodeValidator` (IS SDK structural check);
|
|
70
|
+
* callers can append more via `FlowValidateOptions.extraNodeValidators`.
|
|
71
|
+
*/
|
|
72
|
+
private runNodeValidators;
|
|
73
|
+
}
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FlowNodeValidator } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Default node validator for `uipath.connector.*` nodes (activities and
|
|
4
|
+
* triggers). Maps node inputs into a `ConnectorValidationContext` and
|
|
5
|
+
* delegates to `validateIntSvcNode` from `@uipath/integrationservice-sdk`.
|
|
6
|
+
*
|
|
7
|
+
* Structural-only (no network) — matches today's CLI behavior before
|
|
8
|
+
* pluggability was introduced.
|
|
9
|
+
*/
|
|
10
|
+
export declare const connectorNodeValidator: FlowNodeValidator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FlowNodeValidator } from "./types.js";
|
|
2
|
+
export { connectorNodeValidator } from "./connector-validator.js";
|
|
3
|
+
export type { FlowNodeValidator, FlowValidatorContext, FlowValidatorNode, ValidationIssue, ValidationIssueSeverity, } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Validators applied by default in `FlowValidateService`. Downstream tools
|
|
6
|
+
* can extend this via `FlowValidateOptions.extraNodeValidators`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const defaultNodeValidators: readonly FlowNodeValidator[];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contribution surface for node-type-scoped validators in `uip flow validate`.
|
|
3
|
+
*
|
|
4
|
+
* A `FlowNodeValidator` runs once per node during the validate pass and emits
|
|
5
|
+
* zero or more `ValidationIssue`s. This is the second pluggability layer of
|
|
6
|
+
* flow validation — the first being graph-wide `ValidationRule`s exported by
|
|
7
|
+
* `@uipath/flow-schema`, which are authored against `WorkflowValidationContext`
|
|
8
|
+
* rather than a single node.
|
|
9
|
+
*
|
|
10
|
+
* Use this interface when the check you want is naturally per-node (inspecting
|
|
11
|
+
* `inputs`, checking a selector format, enforcing a connector-detail shape).
|
|
12
|
+
* Use `ValidationRule` from `@uipath/flow-schema` when the check spans nodes
|
|
13
|
+
* or needs the full graph (trigger counts, edge topology, variable scoping).
|
|
14
|
+
*
|
|
15
|
+
* Validators are pure functions — no network calls, no filesystem access.
|
|
16
|
+
*/
|
|
17
|
+
export type ValidationIssueSeverity = "error" | "warning";
|
|
18
|
+
export interface ValidationIssue {
|
|
19
|
+
/** Dot path into the flow, e.g. `nodes[foo].inputs.detail`. */
|
|
20
|
+
path: string;
|
|
21
|
+
message: string;
|
|
22
|
+
severity: ValidationIssueSeverity;
|
|
23
|
+
}
|
|
24
|
+
/** The projection of a node that validators receive. */
|
|
25
|
+
export interface FlowValidatorNode {
|
|
26
|
+
id: string;
|
|
27
|
+
type: string;
|
|
28
|
+
typeVersion?: string;
|
|
29
|
+
inputs?: Record<string, unknown>;
|
|
30
|
+
outputs?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
/** Graph-level context available to validators (definitions, etc.). */
|
|
33
|
+
export interface FlowValidatorContext {
|
|
34
|
+
definitions: ReadonlyArray<{
|
|
35
|
+
nodeType: string;
|
|
36
|
+
version: string;
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export interface FlowNodeValidator {
|
|
41
|
+
/** Stable identifier for logging / telemetry. */
|
|
42
|
+
id: string;
|
|
43
|
+
/** Gate called once per node. Return true to apply `validate`. */
|
|
44
|
+
appliesTo(node: FlowValidatorNode): boolean;
|
|
45
|
+
/** Return zero or more issues for this node. */
|
|
46
|
+
validate(node: FlowValidatorNode, context: FlowValidatorContext): ValidationIssue[];
|
|
47
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local re-declarations of `@uipath/flow-schema` validation types that
|
|
3
|
+
* flow-tool's public `.d.ts` would otherwise reference.
|
|
4
|
+
*
|
|
5
|
+
* Why this file exists: `@uipath/flow-schema`'s published declarations
|
|
6
|
+
* (`dist/index.d.ts`) import from `@uipath/apollo-wind` and
|
|
7
|
+
* `@uipath/apollo-react/canvas`, neither of which are declared in its
|
|
8
|
+
* own `dependencies`/`peerDependencies`. A downstream consumer of
|
|
9
|
+
* `@uipath/flow-tool/validation` compiling with `skipLibCheck: false`
|
|
10
|
+
* hits TS2307 the moment TypeScript loads the flow-schema module —
|
|
11
|
+
* even on a type-only import.
|
|
12
|
+
*
|
|
13
|
+
* The shapes below mirror `@uipath/flow-schema/src/validation/types.ts`
|
|
14
|
+
* verbatim. TypeScript's structural typing keeps a flow-schema
|
|
15
|
+
* `ValidationRule` / `ValidationError` / `WorkflowValidationContext`
|
|
16
|
+
* assignable to these local equivalents (and vice versa), so this
|
|
17
|
+
* compat layer is zero-friction for rule authors who already import
|
|
18
|
+
* from `@uipath/flow-schema`.
|
|
19
|
+
*/
|
|
20
|
+
export type WorkflowValidationSeverity = "critical" | "error" | "warning" | "info";
|
|
21
|
+
export type WorkflowValidationLayer = "field" | "node" | "workflow";
|
|
22
|
+
export interface WorkflowValidationError {
|
|
23
|
+
code: string;
|
|
24
|
+
message: string;
|
|
25
|
+
severity: WorkflowValidationSeverity;
|
|
26
|
+
nodeId: string;
|
|
27
|
+
fieldPath?: string;
|
|
28
|
+
layer: WorkflowValidationLayer;
|
|
29
|
+
subflowNodeId?: string;
|
|
30
|
+
subflowLabel?: string;
|
|
31
|
+
drillPath?: string[];
|
|
32
|
+
publishOnly?: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface WorkflowSerializedNode {
|
|
35
|
+
id: string;
|
|
36
|
+
type: string;
|
|
37
|
+
data: Record<string, unknown>;
|
|
38
|
+
}
|
|
39
|
+
export interface WorkflowSerializedEdge {
|
|
40
|
+
id: string;
|
|
41
|
+
source: string;
|
|
42
|
+
sourceHandle: string | null;
|
|
43
|
+
target: string;
|
|
44
|
+
targetHandle: string | null;
|
|
45
|
+
}
|
|
46
|
+
export interface WorkflowSerializedHandleConfig {
|
|
47
|
+
id: string;
|
|
48
|
+
type: "source" | "target";
|
|
49
|
+
handleType: string;
|
|
50
|
+
label?: string;
|
|
51
|
+
constraints?: {
|
|
52
|
+
minConnections?: number;
|
|
53
|
+
maxConnections?: number;
|
|
54
|
+
severity?: WorkflowValidationSeverity;
|
|
55
|
+
validationMessage?: string;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export interface WorkflowSerializedManifest {
|
|
59
|
+
nodeType: string;
|
|
60
|
+
version: string;
|
|
61
|
+
category?: string;
|
|
62
|
+
display?: {
|
|
63
|
+
label: string;
|
|
64
|
+
};
|
|
65
|
+
handleConfiguration: Array<{
|
|
66
|
+
handles: WorkflowSerializedHandleConfig[];
|
|
67
|
+
}>;
|
|
68
|
+
inputDefinition?: Record<string, unknown>;
|
|
69
|
+
tags?: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface WorkflowGovernanceEnforcements {
|
|
72
|
+
maxTokens: number;
|
|
73
|
+
maxTemperature: number;
|
|
74
|
+
policyName: string;
|
|
75
|
+
shouldEnforceHumanInTheLoop?: boolean;
|
|
76
|
+
}
|
|
77
|
+
export interface WorkflowValidationContext {
|
|
78
|
+
nodes: WorkflowSerializedNode[];
|
|
79
|
+
edges: WorkflowSerializedEdge[];
|
|
80
|
+
manifests: Map<string, WorkflowSerializedManifest>;
|
|
81
|
+
outputVariableIds?: string[];
|
|
82
|
+
governanceEnforcements?: WorkflowGovernanceEnforcements;
|
|
83
|
+
availableModelNames?: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface WorkflowValidationRule {
|
|
86
|
+
id: string;
|
|
87
|
+
severity: WorkflowValidationSeverity;
|
|
88
|
+
validate: (ctx: WorkflowValidationContext) => WorkflowValidationError[];
|
|
89
|
+
}
|