@uipath/maestro-builder-sdk 6.118.0 → 6.119.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/api-index.md +2 -2
- package/dist/check.d.ts +0 -10
- package/dist/check.js +70 -8
- package/dist/compile-cli.js +12 -1
- package/dist/core/refusals.d.ts +10 -0
- package/dist/core/refusals.js +10 -0
- package/dist/core-definitions.json +178 -1637
- package/dist/flow-node-type.d.ts +21 -0
- package/dist/merge-cli.js +4 -0
- package/dist/merge-roundtrip.d.ts +8 -3
- package/dist/merge-roundtrip.js +7 -1
- package/dist/merge-superseded-outputs.d.ts +12 -0
- package/dist/merge-superseded-outputs.js +111 -0
- package/dist/merge.d.ts +10 -0
- package/dist/merge.js +13 -1
- package/dist/nodes/document/flow/extract-output.d.ts +61 -0
- package/dist/nodes/document/flow/extract-output.js +87 -0
- package/dist/nodes/document/flow/factories.d.ts +60 -1
- package/dist/nodes/document/flow/factories.js +60 -1
- package/dist/nodes/document/flow/node-type.js +91 -6
- package/dist/nodes/document/flow/taxonomy-check.d.ts +36 -0
- package/dist/nodes/document/flow/taxonomy-check.js +207 -0
- package/dist/nodes/document/flow/taxonomy.d.ts +92 -0
- package/dist/nodes/document/flow/taxonomy.js +301 -0
- package/dist/serialize.d.ts +17 -0
- package/dist/serialize.js +17 -0
- package/package.json +2 -2
package/dist/flow-node-type.d.ts
CHANGED
|
@@ -179,6 +179,13 @@ export interface FlowSerializeContext {
|
|
|
179
179
|
* pair) or must pick an id that is not taken; add entries through `bind`.
|
|
180
180
|
*/
|
|
181
181
|
readonly bindings: ReadonlyMap<string, Readonly<Record<string, unknown>>>;
|
|
182
|
+
/**
|
|
183
|
+
* The node this step had in the `.flow` the compile overwrites
|
|
184
|
+
* (`SerializeOpts.overwrites`): same id, same type; undefined when there is none.
|
|
185
|
+
*/
|
|
186
|
+
overwrittenNode(): unknown;
|
|
187
|
+
/** Report an informational line about what was written (`SerializeOpts.note`). */
|
|
188
|
+
note(message: string, data?: unknown): void;
|
|
182
189
|
/**
|
|
183
190
|
* A symbolic `connection` or `folder` label resolved through the flow's
|
|
184
191
|
* bindings.json, as a connector step's is: a self-referential label throws the
|
|
@@ -575,6 +582,20 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
|
|
|
575
582
|
* (`core/carried-connector-operation.ts`). Absent: never.
|
|
576
583
|
*/
|
|
577
584
|
carriesFromFile?(node: unknown, library: NonNullable<SerializeOpts['library']>): boolean;
|
|
585
|
+
/**
|
|
586
|
+
* Whether `outputs` is an output declaration an earlier SDK wrote for this
|
|
587
|
+
* type at this version, and the SDK's bundle has since corrected. `outputs` is
|
|
588
|
+
* a saved node's `outputs` or its `definitions[]` entry's `outputDefinition`;
|
|
589
|
+
* the two have one shape (`{ output: { schema, ... }, ... }`).
|
|
590
|
+
*
|
|
591
|
+
* Compile derives both from the definition, so the author never writes them.
|
|
592
|
+
* When the original file holds a superseded one, merge writes the edited
|
|
593
|
+
* compile's node `outputs`, `variables.nodes` entries and definition instead
|
|
594
|
+
* of keeping the original's (merge-superseded-outputs.ts). Otherwise the merged
|
|
595
|
+
* file declares an output the node does not publish, and `flow validate` refuses
|
|
596
|
+
* the corrected reads of it. Omitted: never.
|
|
597
|
+
*/
|
|
598
|
+
supersededOutputs?(outputs: unknown): boolean;
|
|
578
599
|
/**
|
|
579
600
|
* The node-level `model` every node of this type carries, whichever path emits
|
|
580
601
|
* it — this type's `serialize`, or a `rawNode` of its definition. `'omit'`: none
|
package/dist/merge-cli.js
CHANGED
|
@@ -424,8 +424,12 @@ export async function run(argv) {
|
|
|
424
424
|
if (editedIsSource) {
|
|
425
425
|
// The edited source gets what `compile` gives it: check() with the same
|
|
426
426
|
// options, and the serializer's warnings (CONNECTION_STUB, ...) printed.
|
|
427
|
+
// It compiles over the original, as `compile` over the same file does: a
|
|
428
|
+
// step reads the node it had there (`SerializeOpts.overwrites`), so an
|
|
429
|
+
// idless Extract taxonomy keeps the ids the saved .flow has (#1985).
|
|
427
430
|
const compiled = await compileSourceDraftTolerant(resolve(editedPath), {
|
|
428
431
|
...compileOpts,
|
|
432
|
+
overwrites: original,
|
|
429
433
|
warn: (w) => console.error(` ⚠ [${w.code}] ${w.message}`),
|
|
430
434
|
});
|
|
431
435
|
edited = compiled.flow;
|
|
@@ -33,13 +33,14 @@ interface RtFlow {
|
|
|
33
33
|
/** One difference, or one inconsistency in the merged file. */
|
|
34
34
|
export interface MergeFinding {
|
|
35
35
|
/** Which comparison found it. */
|
|
36
|
-
kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit';
|
|
36
|
+
kind: 'node-removed' | 'node-added' | 'node-type' | 'implicit-end' | 'edge-handle-renamed' | 'edge-rewired' | 'edge-removed' | 'edge-added' | 'handle-ids' | 'binding-removed' | 'binding-added' | 'variable-added' | 'variable-changed' | 'undeclared-handle' | 'duplicate-binding' | 'agent-sidecar' | 'agent-storage' | 'agent-prompt-input' | 'agent-embedded-edit' | 'outputs-superseded';
|
|
37
37
|
/** The finding, phrased for the author, naming the node, edge or row. */
|
|
38
38
|
message: string;
|
|
39
39
|
/**
|
|
40
40
|
* Whether `strict` refuses the merge over it. False for `implicit-end` and
|
|
41
41
|
* `binding-removed`, which leave the merged file doing what the original does,
|
|
42
|
-
*
|
|
42
|
+
* for `agent-embedded-edit`, which reports what merge did not carry, and for
|
|
43
|
+
* `outputs-superseded`, which reports a declaration merge corrected.
|
|
43
44
|
*/
|
|
44
45
|
refuses: boolean;
|
|
45
46
|
}
|
|
@@ -57,7 +58,11 @@ export interface MergeFinding {
|
|
|
57
58
|
* @param merged - The merged file, before it is written.
|
|
58
59
|
* @returns One finding per difference, in a stable order.
|
|
59
60
|
*/
|
|
60
|
-
|
|
61
|
+
/**
|
|
62
|
+
* `correctedVariables` are root `variables.nodes` ids merge rewrote on purpose
|
|
63
|
+
* (merge-superseded-outputs.ts), so they are not reported as a rewrite here.
|
|
64
|
+
*/
|
|
65
|
+
export declare function roundTripFindings(original: RtFlow, baseline: RtFlow, merged: RtFlow, correctedVariables?: ReadonlySet<string>): MergeFinding[];
|
|
61
66
|
/**
|
|
62
67
|
* Inconsistencies in the merged file that come from mixing its sources: a root
|
|
63
68
|
* edge leaving a handle its source node does not declare, and two binding rows
|
package/dist/merge-roundtrip.js
CHANGED
|
@@ -110,7 +110,11 @@ function bindingText(b) {
|
|
|
110
110
|
* @param merged - The merged file, before it is written.
|
|
111
111
|
* @returns One finding per difference, in a stable order.
|
|
112
112
|
*/
|
|
113
|
-
|
|
113
|
+
/**
|
|
114
|
+
* `correctedVariables` are root `variables.nodes` ids merge rewrote on purpose
|
|
115
|
+
* (merge-superseded-outputs.ts), so they are not reported as a rewrite here.
|
|
116
|
+
*/
|
|
117
|
+
export function roundTripFindings(original, baseline, merged, correctedVariables = new Set()) {
|
|
114
118
|
const out = [];
|
|
115
119
|
const origDefs = defsOf(original);
|
|
116
120
|
const baseDefs = defsOf(baseline);
|
|
@@ -299,6 +303,8 @@ export function roundTripFindings(original, baseline, merged) {
|
|
|
299
303
|
const ov = o.get(id);
|
|
300
304
|
if (mv === undefined || stableJson(mv) !== stableJson(bv) || (ov !== undefined && stableJson(ov) === stableJson(bv)))
|
|
301
305
|
continue;
|
|
306
|
+
if (section === 'nodes' && correctedVariables.has(id))
|
|
307
|
+
continue;
|
|
302
308
|
if (ov === undefined) {
|
|
303
309
|
out.push({ kind: 'variable-added', refuses, message: `the round trip adds variables.${section} "${id}"; merge will write it${tail}.` });
|
|
304
310
|
continue;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MergeFinding } from './merge-roundtrip.js';
|
|
2
|
+
import { type AnyFlow } from './edit-scope.js';
|
|
3
|
+
/**
|
|
4
|
+
* Replace, in `merged` (mutated), each superseded node output declaration and
|
|
5
|
+
* definition with the edited compile's. Returns the findings and the ids of the
|
|
6
|
+
* ROOT `variables.nodes` entries it rewrote, which the round-trip check must not
|
|
7
|
+
* report as a rewrite the author did not make.
|
|
8
|
+
*/
|
|
9
|
+
export declare function replaceSupersededOutputs(merged: AnyFlow, edited: AnyFlow): {
|
|
10
|
+
findings: MergeFinding[];
|
|
11
|
+
rootVariables: Set<string>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* merge-superseded-outputs — write the corrected output declaration of a node
|
|
3
|
+
* whose original an older SDK compiled with a wrong one.
|
|
4
|
+
*
|
|
5
|
+
* A node's `outputs`, its `variables.nodes` entries and its `definitions[]`
|
|
6
|
+
* entry are derived: compile writes all three from the node type's definition,
|
|
7
|
+
* and the author never writes them. So merge normally keeps the original's
|
|
8
|
+
* (withEdits and merge-variables.ts keep a field the author did not change;
|
|
9
|
+
* the original's definition wins on conflict, as the tenant-resolved authority).
|
|
10
|
+
*
|
|
11
|
+
* That is wrong when the SDK's own bundle was wrong when the original was
|
|
12
|
+
* compiled and has since been corrected. For instance, before #1987 the bundle
|
|
13
|
+
* declared Extract document's output as `ExtractionResult` and `Taxonomy`, while
|
|
14
|
+
* the node publishes a processed document (`result.output.<group>.<field>`, ...).
|
|
15
|
+
* An author fixes the read `$vars.extract.output.ExtractionResult` to
|
|
16
|
+
* `$vars.extract.output.result.output.Invoice.Total` and merges. Keeping the
|
|
17
|
+
* original's declaration, the merged file says the output has no `result`, and
|
|
18
|
+
* `flow validate` warns `Property 'result' does not exist on type 'Extract_Output'`,
|
|
19
|
+
* while a fresh compile of the same source validates clean.
|
|
20
|
+
*
|
|
21
|
+
* A node type names the declarations it superseded (`FlowNodeType.supersededOutputs`).
|
|
22
|
+
* For a merged node whose `outputs` is one of them, merge takes the edited
|
|
23
|
+
* compile's `outputs` and the scope's `variables.nodes` entries bound to the
|
|
24
|
+
* node; for a merged definition whose `outputDefinition` is one, the edited
|
|
25
|
+
* compile's definition of the same `(nodeType, version)`. Only an edited node or
|
|
26
|
+
* definition at the same type and version, whose own declaration is not
|
|
27
|
+
* superseded, is taken. Each replacement is reported, never refused: the merged
|
|
28
|
+
* file then declares what the node publishes.
|
|
29
|
+
*/
|
|
30
|
+
import { jsonClone } from './core/json-clone.js';
|
|
31
|
+
import { isRecord } from './core/node-envelope.js';
|
|
32
|
+
import { FLOW_NODE_TYPES } from './flow-node-registry.js';
|
|
33
|
+
import { byId } from './edit-scope.js';
|
|
34
|
+
/** The registered type's `supersededOutputs` at exactly this version, if it declares one. */
|
|
35
|
+
function supersededRule(type, version) {
|
|
36
|
+
if (typeof type !== 'string' || typeof version !== 'string')
|
|
37
|
+
return undefined;
|
|
38
|
+
const entry = FLOW_NODE_TYPES.byTypeName(type);
|
|
39
|
+
if (!entry || !Object.hasOwn(entry.type.versions, version))
|
|
40
|
+
return undefined;
|
|
41
|
+
return entry.type.versions[version].supersededOutputs;
|
|
42
|
+
}
|
|
43
|
+
function nodeEntries(variables) {
|
|
44
|
+
const list = isRecord(variables) ? variables.nodes : undefined;
|
|
45
|
+
return Array.isArray(list) ? list : undefined;
|
|
46
|
+
}
|
|
47
|
+
const boundTo = (entry, nodeId) => isRecord(entry) && isRecord(entry.binding) && entry.binding.nodeId === nodeId;
|
|
48
|
+
/**
|
|
49
|
+
* Replace, in `merged` (mutated), each superseded node output declaration and
|
|
50
|
+
* definition with the edited compile's. Returns the findings and the ids of the
|
|
51
|
+
* ROOT `variables.nodes` entries it rewrote, which the round-trip check must not
|
|
52
|
+
* report as a rewrite the author did not make.
|
|
53
|
+
*/
|
|
54
|
+
export function replaceSupersededOutputs(merged, edited) {
|
|
55
|
+
const findings = [];
|
|
56
|
+
const rootVariables = new Set();
|
|
57
|
+
const scopes = [
|
|
58
|
+
['', merged, edited],
|
|
59
|
+
...Object.keys(merged.subflows ?? {}).map((key) => [key, merged.subflows[key], edited.subflows?.[key]]),
|
|
60
|
+
];
|
|
61
|
+
for (const [key, into, from] of scopes) {
|
|
62
|
+
if (!into?.nodes || !from)
|
|
63
|
+
continue;
|
|
64
|
+
const editedNodes = byId(from.nodes);
|
|
65
|
+
for (const node of into.nodes) {
|
|
66
|
+
const superseded = supersededRule(node.type, node.typeVersion);
|
|
67
|
+
const e = editedNodes.get(node.id);
|
|
68
|
+
if (!superseded || !superseded(node.outputs) || !e || e.type !== node.type || e.typeVersion !== node.typeVersion)
|
|
69
|
+
continue;
|
|
70
|
+
if (e.outputs === undefined || superseded(e.outputs))
|
|
71
|
+
continue;
|
|
72
|
+
node.outputs = jsonClone(e.outputs);
|
|
73
|
+
const entries = nodeEntries(into.variables);
|
|
74
|
+
const editedEntries = new Map((nodeEntries(from.variables) ?? []).filter((v) => boundTo(v, node.id)).map((v) => [v.id, v]));
|
|
75
|
+
if (entries) {
|
|
76
|
+
into.variables.nodes = entries.map((v) => {
|
|
77
|
+
const replacement = boundTo(v, node.id) ? editedEntries.get(v.id) : undefined;
|
|
78
|
+
if (replacement === undefined)
|
|
79
|
+
return v;
|
|
80
|
+
if (key === '')
|
|
81
|
+
rootVariables.add(v.id);
|
|
82
|
+
return jsonClone(replacement);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
const where = key === '' ? '' : ` in subflow "${key}"`;
|
|
86
|
+
findings.push({
|
|
87
|
+
kind: 'outputs-superseded',
|
|
88
|
+
refuses: false,
|
|
89
|
+
message: `node "${node.id}"${where} (${node.type}@${node.typeVersion}) declared an output an earlier SDK wrote wrongly; `
|
|
90
|
+
+ 'merge wrote the edited compile\'s outputs and variables.nodes entries, which declare what the node publishes.',
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
const editedDefs = new Map((edited.definitions ?? []).map((d) => [`${String(d.nodeType)}@${String(d.version)}`, d]));
|
|
95
|
+
merged.definitions = merged.definitions?.map((d) => {
|
|
96
|
+
const superseded = supersededRule(d.nodeType, d.version);
|
|
97
|
+
if (!superseded?.(d.outputDefinition))
|
|
98
|
+
return d;
|
|
99
|
+
const e = editedDefs.get(`${String(d.nodeType)}@${String(d.version)}`);
|
|
100
|
+
if (e === undefined || superseded(e.outputDefinition))
|
|
101
|
+
return d;
|
|
102
|
+
findings.push({
|
|
103
|
+
kind: 'outputs-superseded',
|
|
104
|
+
refuses: false,
|
|
105
|
+
message: `the original's definition of ${String(d.nodeType)}@${String(d.version)} declares an output an earlier SDK wrote wrongly; `
|
|
106
|
+
+ 'merge wrote the edited compile\'s definition.',
|
|
107
|
+
});
|
|
108
|
+
return jsonClone(e);
|
|
109
|
+
});
|
|
110
|
+
return { findings, rootVariables };
|
|
111
|
+
}
|
package/dist/merge.d.ts
CHANGED
|
@@ -82,6 +82,13 @@
|
|
|
82
82
|
* checked for an edge that leaves a handle its kept source node does not
|
|
83
83
|
* declare. See merge-roundtrip.ts.
|
|
84
84
|
*
|
|
85
|
+
* ## A superseded output declaration is replaced
|
|
86
|
+
*
|
|
87
|
+
* A node's `outputs`, `variables.nodes` entries and definition are derived from
|
|
88
|
+
* its type's definition, so merge keeps the original's. Where an older SDK
|
|
89
|
+
* wrote them wrongly and the node type says so (`supersededOutputs`), merge
|
|
90
|
+
* writes the edited compile's instead. See merge-superseded-outputs.ts.
|
|
91
|
+
*
|
|
85
92
|
* ## An embedded agent stays embedded
|
|
86
93
|
*
|
|
87
94
|
* An agent node whose original carries its prompts and model on the node is
|
|
@@ -114,6 +121,9 @@ export interface MergeOptions {
|
|
|
114
121
|
* the same id, because the edit took the SDK's version;
|
|
115
122
|
* - a merged edge whose `sourcePort` is not a handle its source node declares,
|
|
116
123
|
* and two merged binding rows for the same resource property;
|
|
124
|
+
* - a node output declaration or definition an older SDK wrote wrongly, which
|
|
125
|
+
* merge replaced with the edited compile's (merge-superseded-outputs.ts);
|
|
126
|
+
* never refused;
|
|
117
127
|
* - an edited agent whose original carries its prompts and model on the node
|
|
118
128
|
* (embedded): merge keeps them and applies only the node change, so a prompt
|
|
119
129
|
* or model edit in the source is not carried. Under `strict` it refuses a
|
package/dist/merge.js
CHANGED
|
@@ -82,6 +82,13 @@
|
|
|
82
82
|
* checked for an edge that leaves a handle its kept source node does not
|
|
83
83
|
* declare. See merge-roundtrip.ts.
|
|
84
84
|
*
|
|
85
|
+
* ## A superseded output declaration is replaced
|
|
86
|
+
*
|
|
87
|
+
* A node's `outputs`, `variables.nodes` entries and definition are derived from
|
|
88
|
+
* its type's definition, so merge keeps the original's. Where an older SDK
|
|
89
|
+
* wrote them wrongly and the node type says so (`supersededOutputs`), merge
|
|
90
|
+
* writes the edited compile's instead. See merge-superseded-outputs.ts.
|
|
91
|
+
*
|
|
85
92
|
* ## An embedded agent stays embedded
|
|
86
93
|
*
|
|
87
94
|
* An agent node whose original carries its prompts and model on the node is
|
|
@@ -97,6 +104,7 @@ import { placeAddedNodes, stripPlaceholderFlag, unplacedRule } from './node-plac
|
|
|
97
104
|
import { mergeAgentSidecars } from './merge-sidecars.js';
|
|
98
105
|
import { embeddedAgentFindings, isEmbeddedAgent, mergeEmbeddedAgentNode } from './merge-embedded-agent.js';
|
|
99
106
|
import { mergeObject, mergeVariables, stableJson } from './merge-variables.js';
|
|
107
|
+
import { replaceSupersededOutputs } from './merge-superseded-outputs.js';
|
|
100
108
|
import { byId, isKept, nodeUnchanged, subflowsTakenFromEdited } from './edit-scope.js';
|
|
101
109
|
export { MergeRefusedError } from './merge-roundtrip.js';
|
|
102
110
|
/**
|
|
@@ -624,10 +632,14 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
624
632
|
if (options.baseline && edited.version !== undefined && edited.version !== options.baseline.version) {
|
|
625
633
|
result.version = edited.version;
|
|
626
634
|
}
|
|
635
|
+
// ── Output declarations an older SDK wrote wrongly: the edited compile's,
|
|
636
|
+
// not the original's (merge-superseded-outputs.ts). ──
|
|
637
|
+
const superseded = replaceSupersededOutputs(result, edited);
|
|
627
638
|
// ── What the no-edit round trip changed, and what mixing sources broke. ──
|
|
628
639
|
// The caller warns them, or refuses under strict (`reportOrRefuse`).
|
|
629
640
|
const findings = [
|
|
630
|
-
...
|
|
641
|
+
...superseded.findings,
|
|
642
|
+
...(options.baseline ? roundTripFindings(original, options.baseline, result, superseded.rootVariables) : []),
|
|
631
643
|
...mergedFileFindings(result, original),
|
|
632
644
|
];
|
|
633
645
|
const agentFindings = (authored) => embeddedAgentFindings(!!options.baseline, [
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the Extract document node (`uipath.ixp.extract-document-builder`,
|
|
3
|
+
* `dynamicExtract()`) publishes, and the rule that checks a read of it.
|
|
4
|
+
*
|
|
5
|
+
* The output is a processed document, the shape flow-core's IxP mapper
|
|
6
|
+
* declares (`buildExtractDocumentBuilderNode`):
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* $vars.extract.output
|
|
10
|
+
* .version, .type the contract version and 'Extraction'
|
|
11
|
+
* .result.output.<group>.<field> the extracted values, shaped like the taxonomy
|
|
12
|
+
* .result.attribution['/<pointer>'] where each value was read on the page
|
|
13
|
+
* .result.traceContext.{traceId, spanId, folderKey}
|
|
14
|
+
* .taxonomy the schema the run extracted against
|
|
15
|
+
* .metadata.{pipelineRunId, folderKey, traceId, spanId, modelConfig}
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The rule checks the fixed keys only. The group and field names under
|
|
19
|
+
* `result.output` come from the author's taxonomy and are not checked.
|
|
20
|
+
*/
|
|
21
|
+
import type { OutputPathRead } from '../../../core/nodes/node-type.js';
|
|
22
|
+
/**
|
|
23
|
+
* One level of the output, as a read sees it: `leaf` is a scalar, `open` is an
|
|
24
|
+
* object the definition gives no closed key list for (any key may be read), and
|
|
25
|
+
* an object lists the keys that exist.
|
|
26
|
+
*/
|
|
27
|
+
export type ReadShape = 'leaf' | 'open' | {
|
|
28
|
+
readonly [key: string]: ReadShape;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* The processed document's keys, level by level. An object schema with
|
|
32
|
+
* `properties` is a closed level; one without (`result.output`, `taxonomy`, and
|
|
33
|
+
* `result.attribution`, keyed by JSON Pointer such as `'/Net pay'`) is open.
|
|
34
|
+
* One level is open although its schema lists properties: `metadata.modelConfig`
|
|
35
|
+
* "grows with the processor: read the keys you know and tolerate the rest" (its
|
|
36
|
+
* own description). `tests/document-processing.test.ts` derives this table from
|
|
37
|
+
* the bundled `outputDefinition` by the same rule and holds the two equal, so
|
|
38
|
+
* they cannot drift apart.
|
|
39
|
+
*/
|
|
40
|
+
export declare const EXTRACT_OUTPUT_SHAPE: {
|
|
41
|
+
readonly [key: string]: ReadShape;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Whether `outputs` (a node's `outputs`, or its definition's `outputDefinition`)
|
|
45
|
+
* is the declaration the SDK bundled for this node before #1987: the
|
|
46
|
+
* published-project extractor's `ExtractionResult` and `Taxonomy`. A file an
|
|
47
|
+
* older SDK compiled carries it in three places: the node's `outputs`, its
|
|
48
|
+
* `variables.nodes` entry and its `definitions[]` entry. The processed document
|
|
49
|
+
* has no `ExtractionResult` key, so the test cannot match a current declaration.
|
|
50
|
+
* Merge replaces it (`supersededOutputs`, merge-superseded-outputs.ts).
|
|
51
|
+
*/
|
|
52
|
+
export declare function isLegacyExtractOutputs(outputs: unknown): boolean;
|
|
53
|
+
/**
|
|
54
|
+
* A read of a `dynamicExtract()` step's output: `out('<step>', '<path>')`.
|
|
55
|
+
*
|
|
56
|
+
* Only `output` (and the `error` envelope, which `check` handles before this
|
|
57
|
+
* rule) exists on the step. Under `output`, each segment of the path must name
|
|
58
|
+
* a key of {@link EXTRACT_OUTPUT_SHAPE} until it reaches an open level or a
|
|
59
|
+
* scalar; past that nothing is checked. A miss is undefined at run time.
|
|
60
|
+
*/
|
|
61
|
+
export declare function checkExtractRead({ node: name, field, rest, reader: step }: OutputPathRead, report: (code: string, message: string, suggestion?: string) => void): void;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { nearestName } from '../../../core/edit-distance.js';
|
|
2
|
+
import { ownEntry } from '../../../core/own-entry.js';
|
|
3
|
+
/**
|
|
4
|
+
* The processed document's keys, level by level. An object schema with
|
|
5
|
+
* `properties` is a closed level; one without (`result.output`, `taxonomy`, and
|
|
6
|
+
* `result.attribution`, keyed by JSON Pointer such as `'/Net pay'`) is open.
|
|
7
|
+
* One level is open although its schema lists properties: `metadata.modelConfig`
|
|
8
|
+
* "grows with the processor: read the keys you know and tolerate the rest" (its
|
|
9
|
+
* own description). `tests/document-processing.test.ts` derives this table from
|
|
10
|
+
* the bundled `outputDefinition` by the same rule and holds the two equal, so
|
|
11
|
+
* they cannot drift apart.
|
|
12
|
+
*/
|
|
13
|
+
export const EXTRACT_OUTPUT_SHAPE = {
|
|
14
|
+
version: 'leaf',
|
|
15
|
+
type: 'leaf',
|
|
16
|
+
result: {
|
|
17
|
+
output: 'open',
|
|
18
|
+
attribution: 'open',
|
|
19
|
+
traceContext: { traceId: 'leaf', spanId: 'leaf', folderKey: 'leaf' },
|
|
20
|
+
},
|
|
21
|
+
taxonomy: 'open',
|
|
22
|
+
metadata: { pipelineRunId: 'leaf', folderKey: 'leaf', traceId: 'leaf', spanId: 'leaf', modelConfig: 'open' },
|
|
23
|
+
};
|
|
24
|
+
/** The published-project extractor's (`ixpExtract()`) top-level keys, a common wrong read here. */
|
|
25
|
+
const IXP_PROJECT_KEYS = new Set(['ExtractionResult', 'Taxonomy']);
|
|
26
|
+
/**
|
|
27
|
+
* Whether `outputs` (a node's `outputs`, or its definition's `outputDefinition`)
|
|
28
|
+
* is the declaration the SDK bundled for this node before #1987: the
|
|
29
|
+
* published-project extractor's `ExtractionResult` and `Taxonomy`. A file an
|
|
30
|
+
* older SDK compiled carries it in three places: the node's `outputs`, its
|
|
31
|
+
* `variables.nodes` entry and its `definitions[]` entry. The processed document
|
|
32
|
+
* has no `ExtractionResult` key, so the test cannot match a current declaration.
|
|
33
|
+
* Merge replaces it (`supersededOutputs`, merge-superseded-outputs.ts).
|
|
34
|
+
*/
|
|
35
|
+
export function isLegacyExtractOutputs(outputs) {
|
|
36
|
+
const properties = outputs?.output?.schema?.properties;
|
|
37
|
+
return typeof properties === 'object' && properties !== null && Object.hasOwn(properties, 'ExtractionResult');
|
|
38
|
+
}
|
|
39
|
+
const list = (keys) => keys.map((k) => `"${k}"`).join(', ');
|
|
40
|
+
/**
|
|
41
|
+
* A read of a `dynamicExtract()` step's output: `out('<step>', '<path>')`.
|
|
42
|
+
*
|
|
43
|
+
* Only `output` (and the `error` envelope, which `check` handles before this
|
|
44
|
+
* rule) exists on the step. Under `output`, each segment of the path must name
|
|
45
|
+
* a key of {@link EXTRACT_OUTPUT_SHAPE} until it reaches an open level or a
|
|
46
|
+
* scalar; past that nothing is checked. A miss is undefined at run time.
|
|
47
|
+
*/
|
|
48
|
+
export function checkExtractRead({ node: name, field, rest, reader: step }, report) {
|
|
49
|
+
if (field === undefined || field === 'error')
|
|
50
|
+
return;
|
|
51
|
+
if (field !== 'output') {
|
|
52
|
+
report('EXTRACT_READ_NOT_OUTPUT', `Extract document step "${name}" publishes its result under "output", but `
|
|
53
|
+
+ `"$vars.${name}.${field}" (read in "${step}") asks for "${field}", which is undefined at run time.`, `out('${name}', 'result.output')`);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const segments = rest.replace(/^\./, '').split('.').filter((s) => s !== '');
|
|
57
|
+
let level = EXTRACT_OUTPUT_SHAPE;
|
|
58
|
+
for (const [i, segment] of segments.entries()) {
|
|
59
|
+
if (level === 'leaf' || level === 'open')
|
|
60
|
+
return;
|
|
61
|
+
const next = ownEntry(level, segment);
|
|
62
|
+
if (next !== undefined) {
|
|
63
|
+
level = next;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
const at = ['output', ...segments.slice(0, i)].join('.');
|
|
67
|
+
const read = `$vars.${name}.${at}.${segment}`;
|
|
68
|
+
const keys = Object.keys(level);
|
|
69
|
+
if (i === 0 && IXP_PROJECT_KEYS.has(segment)) {
|
|
70
|
+
report('EXTRACT_READ_UNKNOWN_FIELD', `"${read}" (read in "${step}") is the published-project extractor's `
|
|
71
|
+
+ `(ixpExtract()) output shape, not Extract document's. Step "${name}" publishes a processed document `
|
|
72
|
+
+ `(${list(keys)}); the extracted values are at "result.output", one property per taxonomy field. `
|
|
73
|
+
+ 'This read is undefined at run time.', `out('${name}', 'result.output')`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const nearest = nearestName(segment, keys);
|
|
77
|
+
// At the top, a name that is no envelope key is most likely a taxonomy field read one level too high.
|
|
78
|
+
const suggestion = nearest !== undefined
|
|
79
|
+
? `out('${name}', '${[...segments.slice(0, i), nearest].join('.')}')`
|
|
80
|
+
: i === 0 ? `out('${name}', 'result.output.${segment}')` : undefined;
|
|
81
|
+
report('EXTRACT_READ_UNKNOWN_FIELD', `"${read}" (read in "${step}") is not a field of Extract document step `
|
|
82
|
+
+ `"${name}"'s output. "${at}" has ${list(keys)}`
|
|
83
|
+
+ (i === 0 ? '; the extracted values are at "result.output", one property per taxonomy field' : '')
|
|
84
|
+
+ '. This read is undefined at run time.', suggestion);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -21,7 +21,66 @@ export declare function documentClassify(inputs: DocumentClassifyInputs): Action
|
|
|
21
21
|
* Extract fields from a document with an INLINE schema — Dynamic Extract
|
|
22
22
|
* (`uipath.ixp.extract-document-builder`), the newer of the two extraction
|
|
23
23
|
* shapes. No deployed IXP project is referenced: the extraction schema rides
|
|
24
|
-
* the node.
|
|
24
|
+
* the node.
|
|
25
|
+
*
|
|
26
|
+
* @remarks
|
|
27
|
+
* `schema` is the extraction taxonomy: `prompt` (the instructions) and
|
|
28
|
+
* `outputSchema`, whose `properties` are the field groups and whose `$defs`
|
|
29
|
+
* are the field types the fields `$ref`. Write it without ids or closing
|
|
30
|
+
* keys: compile gives every field group its `x-uipath-field-group-id`, every
|
|
31
|
+
* field its `x-uipath-field-id` and every nested group (`Invoice > Lines`)
|
|
32
|
+
* its parent's id, and closes the objects (`required` lists every property,
|
|
33
|
+
* `additionalProperties: false`), as `uip maestro flow nodes schema set` does.
|
|
34
|
+
* An id the source carries is kept. A missing one is the one the `.flow` being
|
|
35
|
+
* overwritten has for the same entry, or else one minted from the entry's
|
|
36
|
+
* place, so a recompile gives the same id.
|
|
37
|
+
*
|
|
38
|
+
* The output is a processed document: `version`, `type` (`'Extraction'`),
|
|
39
|
+
* `result`, `taxonomy` and `metadata` (run ids and the model configuration).
|
|
40
|
+
* `result.output` holds the extracted values, shaped like `outputSchema`: one
|
|
41
|
+
* property per field group, each holding its fields. `result.attribution`
|
|
42
|
+
* gives each value's page provenance and `result.traceContext` the run's ids.
|
|
43
|
+
* Read a value at `out('<step>', 'result.output.<group>.<field>')`.
|
|
44
|
+
*
|
|
45
|
+
* `check` verifies the processed document's fixed keys: a read of a key it
|
|
46
|
+
* does not have is `EXTRACT_READ_UNKNOWN_FIELD`. That includes
|
|
47
|
+
* `ExtractionResult`, the published-project extractor's shape
|
|
48
|
+
* ({@link ixpExtract}), not this node's. It does not check the group and field
|
|
49
|
+
* names under `result.output` against the taxonomy, so a misspelt field name
|
|
50
|
+
* there still passes.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* **Extract an invoice total and return it**
|
|
54
|
+
* ```ts
|
|
55
|
+
* flow('InvoiceTotal')
|
|
56
|
+
* .input({ invoiceFile: types.file })
|
|
57
|
+
* .output({ total: types.string })
|
|
58
|
+
* .step('extract', dynamicExtract({
|
|
59
|
+
* fileRef: input('invoiceFile'),
|
|
60
|
+
* schema: {
|
|
61
|
+
* prompt: 'Extract the invoice header. Values are on the page; do not compute them.',
|
|
62
|
+
* outputSchema: {
|
|
63
|
+
* type: 'object',
|
|
64
|
+
* properties: {
|
|
65
|
+
* Invoice: {
|
|
66
|
+
* type: ['object', 'null'],
|
|
67
|
+
* description: 'The invoice header, which appears once per document.',
|
|
68
|
+
* properties: {
|
|
69
|
+
* Total: {
|
|
70
|
+
* $ref: '#/$defs/ft-monetary-quantity',
|
|
71
|
+
* description: 'The amount payable including tax.',
|
|
72
|
+
* },
|
|
73
|
+
* },
|
|
74
|
+
* },
|
|
75
|
+
* },
|
|
76
|
+
* $defs: {
|
|
77
|
+
* 'ft-monetary-quantity': { title: 'Monetary Quantity', type: ['string', 'null'], format: 'monetary' },
|
|
78
|
+
* },
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* }))
|
|
82
|
+
* .return({ total: out('extract', 'result.output.Invoice.Total') })
|
|
83
|
+
* ```
|
|
25
84
|
*
|
|
26
85
|
* @param inputs - The file reference, the inline extraction schema, and
|
|
27
86
|
* optional page range / model settings.
|
|
@@ -22,7 +22,66 @@ export function documentClassify(inputs) {
|
|
|
22
22
|
* Extract fields from a document with an INLINE schema — Dynamic Extract
|
|
23
23
|
* (`uipath.ixp.extract-document-builder`), the newer of the two extraction
|
|
24
24
|
* shapes. No deployed IXP project is referenced: the extraction schema rides
|
|
25
|
-
* the node.
|
|
25
|
+
* the node.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* `schema` is the extraction taxonomy: `prompt` (the instructions) and
|
|
29
|
+
* `outputSchema`, whose `properties` are the field groups and whose `$defs`
|
|
30
|
+
* are the field types the fields `$ref`. Write it without ids or closing
|
|
31
|
+
* keys: compile gives every field group its `x-uipath-field-group-id`, every
|
|
32
|
+
* field its `x-uipath-field-id` and every nested group (`Invoice > Lines`)
|
|
33
|
+
* its parent's id, and closes the objects (`required` lists every property,
|
|
34
|
+
* `additionalProperties: false`), as `uip maestro flow nodes schema set` does.
|
|
35
|
+
* An id the source carries is kept. A missing one is the one the `.flow` being
|
|
36
|
+
* overwritten has for the same entry, or else one minted from the entry's
|
|
37
|
+
* place, so a recompile gives the same id.
|
|
38
|
+
*
|
|
39
|
+
* The output is a processed document: `version`, `type` (`'Extraction'`),
|
|
40
|
+
* `result`, `taxonomy` and `metadata` (run ids and the model configuration).
|
|
41
|
+
* `result.output` holds the extracted values, shaped like `outputSchema`: one
|
|
42
|
+
* property per field group, each holding its fields. `result.attribution`
|
|
43
|
+
* gives each value's page provenance and `result.traceContext` the run's ids.
|
|
44
|
+
* Read a value at `out('<step>', 'result.output.<group>.<field>')`.
|
|
45
|
+
*
|
|
46
|
+
* `check` verifies the processed document's fixed keys: a read of a key it
|
|
47
|
+
* does not have is `EXTRACT_READ_UNKNOWN_FIELD`. That includes
|
|
48
|
+
* `ExtractionResult`, the published-project extractor's shape
|
|
49
|
+
* ({@link ixpExtract}), not this node's. It does not check the group and field
|
|
50
|
+
* names under `result.output` against the taxonomy, so a misspelt field name
|
|
51
|
+
* there still passes.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* **Extract an invoice total and return it**
|
|
55
|
+
* ```ts
|
|
56
|
+
* flow('InvoiceTotal')
|
|
57
|
+
* .input({ invoiceFile: types.file })
|
|
58
|
+
* .output({ total: types.string })
|
|
59
|
+
* .step('extract', dynamicExtract({
|
|
60
|
+
* fileRef: input('invoiceFile'),
|
|
61
|
+
* schema: {
|
|
62
|
+
* prompt: 'Extract the invoice header. Values are on the page; do not compute them.',
|
|
63
|
+
* outputSchema: {
|
|
64
|
+
* type: 'object',
|
|
65
|
+
* properties: {
|
|
66
|
+
* Invoice: {
|
|
67
|
+
* type: ['object', 'null'],
|
|
68
|
+
* description: 'The invoice header, which appears once per document.',
|
|
69
|
+
* properties: {
|
|
70
|
+
* Total: {
|
|
71
|
+
* $ref: '#/$defs/ft-monetary-quantity',
|
|
72
|
+
* description: 'The amount payable including tax.',
|
|
73
|
+
* },
|
|
74
|
+
* },
|
|
75
|
+
* },
|
|
76
|
+
* },
|
|
77
|
+
* $defs: {
|
|
78
|
+
* 'ft-monetary-quantity': { title: 'Monetary Quantity', type: ['string', 'null'], format: 'monetary' },
|
|
79
|
+
* },
|
|
80
|
+
* },
|
|
81
|
+
* },
|
|
82
|
+
* }))
|
|
83
|
+
* .return({ total: out('extract', 'result.output.Invoice.Total') })
|
|
84
|
+
* ```
|
|
26
85
|
*
|
|
27
86
|
* @param inputs - The file reference, the inline extraction schema, and
|
|
28
87
|
* optional page range / model settings.
|