@uipath/maestro-builder-sdk 6.118.0 → 6.118.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.
@@ -575,6 +575,20 @@ export interface FlowNodeType<Spec> extends NodeType<Spec, FlowNodeContribution,
575
575
  * (`core/carried-connector-operation.ts`). Absent: never.
576
576
  */
577
577
  carriesFromFile?(node: unknown, library: NonNullable<SerializeOpts['library']>): boolean;
578
+ /**
579
+ * Whether `outputs` is an output declaration an earlier SDK wrote for this
580
+ * type at this version, and the SDK's bundle has since corrected. `outputs` is
581
+ * a saved node's `outputs` or its `definitions[]` entry's `outputDefinition`;
582
+ * the two have one shape (`{ output: { schema, ... }, ... }`).
583
+ *
584
+ * Compile derives both from the definition, so the author never writes them.
585
+ * When the original file holds a superseded one, merge writes the edited
586
+ * compile's node `outputs`, `variables.nodes` entries and definition instead
587
+ * of keeping the original's (merge-superseded-outputs.ts). Otherwise the merged
588
+ * file declares an output the node does not publish, and `flow validate` refuses
589
+ * the corrected reads of it. Omitted: never.
590
+ */
591
+ supersededOutputs?(outputs: unknown): boolean;
578
592
  /**
579
593
  * The node-level `model` every node of this type carries, whichever path emits
580
594
  * it — this type's `serialize`, or a `rawNode` of its definition. `'omit'`: none
@@ -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
- * and for `agent-embedded-edit`, which reports what merge did not carry.
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
- export declare function roundTripFindings(original: RtFlow, baseline: RtFlow, merged: RtFlow): MergeFinding[];
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
@@ -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
- export function roundTripFindings(original, baseline, merged) {
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
- ...(options.baseline ? roundTripFindings(original, options.baseline, result) : []),
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,67 @@ 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. The result publishes `ExtractionResult` (and `Taxonomy`).
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`. Its groups and fields are emitted as
30
+ * written, so each carries its own stable id (`x-uipath-field-group-id`,
31
+ * `x-uipath-field-id`).
32
+ *
33
+ * The output is a processed document: `version`, `type` (`'Extraction'`),
34
+ * `result`, `taxonomy` and `metadata` (run ids and the model configuration).
35
+ * `result.output` holds the extracted values, shaped like `outputSchema`: one
36
+ * property per field group, each holding its fields. `result.attribution`
37
+ * gives each value's page provenance and `result.traceContext` the run's ids.
38
+ * Read a value at `out('<step>', 'result.output.<group>.<field>')`.
39
+ *
40
+ * `check` verifies the processed document's fixed keys: a read of a key it
41
+ * does not have is `EXTRACT_READ_UNKNOWN_FIELD`. That includes
42
+ * `ExtractionResult`, the published-project extractor's shape
43
+ * ({@link ixpExtract}), not this node's. It does not check the group and field
44
+ * names under `result.output` against the taxonomy, so a misspelt field name
45
+ * there still passes.
46
+ *
47
+ * @example
48
+ * **Extract an invoice total and return it**
49
+ * ```ts
50
+ * flow('InvoiceTotal')
51
+ * .input({ invoiceFile: types.file })
52
+ * .output({ total: types.string })
53
+ * .step('extract', dynamicExtract({
54
+ * fileRef: input('invoiceFile'),
55
+ * schema: {
56
+ * prompt: 'Extract the invoice header. Values are on the page; do not compute them.',
57
+ * outputSchema: {
58
+ * type: 'object',
59
+ * additionalProperties: false,
60
+ * required: ['Invoice'],
61
+ * properties: {
62
+ * Invoice: {
63
+ * type: ['object', 'null'],
64
+ * description: 'The invoice header, which appears once per document.',
65
+ * additionalProperties: false,
66
+ * required: ['Total'],
67
+ * 'x-uipath-field-group-id': '3f9a1c2e-5b7d-4e8a-9c1f-2d6b8e0a4c13',
68
+ * properties: {
69
+ * Total: {
70
+ * $ref: '#/$defs/ft-monetary-quantity',
71
+ * description: 'The amount payable including tax.',
72
+ * 'x-uipath-field-id': '7c2e4a91-0d3b-4f6e-a8c5-1b9d3f7e2a64',
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
+ * ```
25
85
  *
26
86
  * @param inputs - The file reference, the inline extraction schema, and
27
87
  * optional page range / model settings.
@@ -22,7 +22,67 @@ 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. The result publishes `ExtractionResult` (and `Taxonomy`).
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`. Its groups and fields are emitted as
31
+ * written, so each carries its own stable id (`x-uipath-field-group-id`,
32
+ * `x-uipath-field-id`).
33
+ *
34
+ * The output is a processed document: `version`, `type` (`'Extraction'`),
35
+ * `result`, `taxonomy` and `metadata` (run ids and the model configuration).
36
+ * `result.output` holds the extracted values, shaped like `outputSchema`: one
37
+ * property per field group, each holding its fields. `result.attribution`
38
+ * gives each value's page provenance and `result.traceContext` the run's ids.
39
+ * Read a value at `out('<step>', 'result.output.<group>.<field>')`.
40
+ *
41
+ * `check` verifies the processed document's fixed keys: a read of a key it
42
+ * does not have is `EXTRACT_READ_UNKNOWN_FIELD`. That includes
43
+ * `ExtractionResult`, the published-project extractor's shape
44
+ * ({@link ixpExtract}), not this node's. It does not check the group and field
45
+ * names under `result.output` against the taxonomy, so a misspelt field name
46
+ * there still passes.
47
+ *
48
+ * @example
49
+ * **Extract an invoice total and return it**
50
+ * ```ts
51
+ * flow('InvoiceTotal')
52
+ * .input({ invoiceFile: types.file })
53
+ * .output({ total: types.string })
54
+ * .step('extract', dynamicExtract({
55
+ * fileRef: input('invoiceFile'),
56
+ * schema: {
57
+ * prompt: 'Extract the invoice header. Values are on the page; do not compute them.',
58
+ * outputSchema: {
59
+ * type: 'object',
60
+ * additionalProperties: false,
61
+ * required: ['Invoice'],
62
+ * properties: {
63
+ * Invoice: {
64
+ * type: ['object', 'null'],
65
+ * description: 'The invoice header, which appears once per document.',
66
+ * additionalProperties: false,
67
+ * required: ['Total'],
68
+ * 'x-uipath-field-group-id': '3f9a1c2e-5b7d-4e8a-9c1f-2d6b8e0a4c13',
69
+ * properties: {
70
+ * Total: {
71
+ * $ref: '#/$defs/ft-monetary-quantity',
72
+ * description: 'The amount payable including tax.',
73
+ * 'x-uipath-field-id': '7c2e4a91-0d3b-4f6e-a8c5-1b9d3f7e2a64',
74
+ * },
75
+ * },
76
+ * },
77
+ * },
78
+ * $defs: {
79
+ * 'ft-monetary-quantity': { title: 'Monetary Quantity', type: ['string', 'null'], format: 'monetary' },
80
+ * },
81
+ * },
82
+ * },
83
+ * }))
84
+ * .return({ total: out('extract', 'result.output.Invoice.Total') })
85
+ * ```
26
86
  *
27
87
  * @param inputs - The file reference, the inline extraction schema, and
28
88
  * optional page range / model settings.
@@ -12,9 +12,12 @@ import { jsonClone } from '../../../core/json-clone.js';
12
12
  import { declareKeys } from '../../../core/option-keys.js';
13
13
  import { stableId } from '../../../core/stable-id.js';
14
14
  import { buildDefaultSchemaDocument, buildScaffoldConfig } from './idp-processor.js';
15
+ import { checkExtractRead, isLegacyExtractOutputs } from './extract-output.js';
15
16
  export const DOCUMENT_DIAGNOSTICS = {
16
17
  DOC_NO_FILEREF: { severity: 'error', summary: 'no fileRef, so nothing to classify or extract from' },
17
18
  EXTRACT_SCHEMA_SHAPE: { severity: 'error', summary: 'a Dynamic Extract schema that is not an object' },
19
+ EXTRACT_READ_NOT_OUTPUT: { severity: 'error', summary: 'an Extract document step read outside output' },
20
+ EXTRACT_READ_UNKNOWN_FIELD: { severity: 'error', summary: 'an Extract document step read of a field the processed document does not have' },
18
21
  };
19
22
  function checkFileRef(inputs, verb, ctx) {
20
23
  const fr = inputs.fileRef;
@@ -328,5 +331,8 @@ export const dynamicExtractNodeType = {
328
331
  },
329
332
  // check collected no expressions for this kind before the port; unchanged by it.
330
333
  expressions: () => [],
331
- output: () => ({ kind: 'opaque' }),
334
+ // The processed document's fixed keys (`extract-output.ts`).
335
+ output: () => ({ kind: 'reader', read: checkExtractRead }),
336
+ // A file an SDK before #1987 compiled declares ExtractionResult; merge writes the processed document.
337
+ supersededOutputs: isLegacyExtractOutputs,
332
338
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.118.0",
3
+ "version": "6.118.1",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -124,5 +124,5 @@
124
124
  "@types/node": "^22.7.0",
125
125
  "esbuild": "^0.28.1"
126
126
  },
127
- "gitref": "9c219f2a52f548305c5576f25ed4266d23af9fdf"
127
+ "gitref": "0c0b4c5db91985dd7604ca295f9b32825d7a28bd"
128
128
  }