@uipath/maestro-builder-sdk 6.80.0 → 6.82.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 +82 -79
- package/dist/api-members.md +267 -250
- package/dist/case/case-sdk.d.ts +141 -20
- package/dist/case/case-sdk.js +112 -2
- package/dist/case/check.js +22 -0
- package/dist/case/decompile-document-extraction.d.ts +17 -0
- package/dist/case/decompile-document-extraction.js +76 -0
- package/dist/case/decompile-script.d.ts +23 -0
- package/dist/case/decompile-script.js +53 -0
- package/dist/case/decompile.d.ts +6 -0
- package/dist/case/decompile.js +41 -0
- package/dist/case/document-extraction-output-schema.json +132 -0
- package/dist/case/document-extraction-saved.d.ts +24 -0
- package/dist/case/document-extraction-saved.js +64 -0
- package/dist/case/document-extraction.d.ts +119 -0
- package/dist/case/document-extraction.js +161 -0
- package/dist/case/load.js +12 -0
- package/dist/case/preserve.d.ts +7 -0
- package/dist/case/preserve.js +6 -0
- package/dist/case/script.d.ts +75 -0
- package/dist/case/script.js +124 -0
- package/dist/case/serialize.js +174 -17
- package/dist/core/refusals.d.ts +11 -0
- package/dist/core/refusals.js +22 -0
- package/dist/core/script-engine.d.ts +34 -0
- package/dist/core/script-engine.js +48 -0
- package/dist/nodes/script/flow/runtime.d.ts +1 -1
- package/dist/nodes/script/flow/runtime.js +5 -35
- package/dist/script-function-scope.js +44 -6
- package/package.json +2 -2
package/dist/case/decompile.js
CHANGED
|
@@ -3,6 +3,9 @@ import { cachedFieldValues, connectorTaskIdentity, savedOptionalConfiguration }
|
|
|
3
3
|
import { commentText } from '../core/comment-text.js';
|
|
4
4
|
import { implicitInArgTrigger } from './in-arg-binding.js';
|
|
5
5
|
import { tsLiteral, tsNumber } from '../core/ts-literal.js';
|
|
6
|
+
import { isDocumentExtractionOwnOutput, liftDocumentExtraction } from './decompile-document-extraction.js';
|
|
7
|
+
import { isOlderDocumentExtractionData } from './document-extraction-saved.js';
|
|
8
|
+
import { isScriptOwnOutput, liftScript } from './decompile-script.js';
|
|
6
9
|
import { isHttpRequestOwnOutput, liftHttpRequest } from './decompile-http-request.js';
|
|
7
10
|
import { savedHttpRequestMetadata } from './http-request.js';
|
|
8
11
|
import { CASE_FORMAT_PROFILE, CASE_SCHEMA_VERSIONS } from './format-profile.js';
|
|
@@ -1094,6 +1097,23 @@ function emitTaskKind(task, refs, library) {
|
|
|
1094
1097
|
}
|
|
1095
1098
|
if (kind === 'execute-connector-activity')
|
|
1096
1099
|
return connectorCall(task, refs, library);
|
|
1100
|
+
// The older, flat shape is carried as saved (`documentExtractionData`): it
|
|
1101
|
+
// names no model, folder key or deployment key to lift.
|
|
1102
|
+
if (kind === 'document-extraction' && isOlderDocumentExtractionData(data))
|
|
1103
|
+
return '.savedDocumentExtraction()';
|
|
1104
|
+
if (kind === 'document-extraction') {
|
|
1105
|
+
const spec = liftDocumentExtraction(`document-extraction task "${task.displayName ?? task.id ?? '?'}"`, (data ?? {}), (id) => refs.bindingById.get(id));
|
|
1106
|
+
const { model, ...rest } = spec;
|
|
1107
|
+
return `.documentExtraction(${tsLiteral(model)}, ${tsLiteral(rest)})`;
|
|
1108
|
+
}
|
|
1109
|
+
if (kind === 'script') {
|
|
1110
|
+
const lifted = liftScript(`script task "${task.displayName ?? task.id ?? '?'}"`, (data ?? {}));
|
|
1111
|
+
const options = opts([
|
|
1112
|
+
['responseSchema', lifted.options.responseSchema !== undefined ? tsLiteral(lifted.options.responseSchema) : undefined],
|
|
1113
|
+
['errorSchema', lifted.options.errorSchema !== undefined ? tsLiteral(lifted.options.errorSchema) : undefined],
|
|
1114
|
+
]);
|
|
1115
|
+
return `.script(${tsLiteral(lifted.body)}${options ? `, ${options}` : ''})`;
|
|
1116
|
+
}
|
|
1097
1117
|
if (kind === 'http-request') {
|
|
1098
1118
|
const spec = liftHttpRequest(`http-request task "${task.displayName ?? task.id ?? '?'}"`, (data ?? {}), {
|
|
1099
1119
|
binding: (id) => refs.bindingById.get(id),
|
|
@@ -1328,6 +1348,21 @@ function taskOutputRows(task) {
|
|
|
1328
1348
|
plan = customOnly(actionFormOutputs(task));
|
|
1329
1349
|
else if (kind === 'wait-for-timer')
|
|
1330
1350
|
plan = customOnly([]);
|
|
1351
|
+
// A carried older-shape task writes its saved rows back itself.
|
|
1352
|
+
else if (kind === 'document-extraction' && isOlderDocumentExtractionData(task.data))
|
|
1353
|
+
plan = split(() => true);
|
|
1354
|
+
// A document extraction writes its two rows itself; one it maps to a case variable is lifted too.
|
|
1355
|
+
else if (kind === 'document-extraction')
|
|
1356
|
+
plan = {
|
|
1357
|
+
lifted: rows.filter((row) => row.custom === true || (isDocumentExtractionOwnOutput(row) && row.var !== row.id)),
|
|
1358
|
+
rebuilt: rows.filter(isDocumentExtractionOwnOutput),
|
|
1359
|
+
};
|
|
1360
|
+
// A script task writes its two rows itself; one it maps to a case variable is lifted too.
|
|
1361
|
+
else if (kind === 'script')
|
|
1362
|
+
plan = {
|
|
1363
|
+
lifted: rows.filter((row) => row.custom === true || (isScriptOwnOutput(row) && row.var !== row.id)),
|
|
1364
|
+
rebuilt: rows.filter(isScriptOwnOutput),
|
|
1365
|
+
};
|
|
1331
1366
|
// An HTTP request writes its four rows itself; a row it maps to a case variable is lifted too.
|
|
1332
1367
|
else if (kind === 'http-request')
|
|
1333
1368
|
plan = {
|
|
@@ -2298,6 +2333,7 @@ export function collectPreservation(plan) {
|
|
|
2298
2333
|
const httpRequestMetadata = [];
|
|
2299
2334
|
const omitTaskElementIds = [];
|
|
2300
2335
|
const actionDataFields = [];
|
|
2336
|
+
const documentExtractionData = [];
|
|
2301
2337
|
const omitStagePositions = [];
|
|
2302
2338
|
const stageDataFields = [];
|
|
2303
2339
|
const generation = schemaGeneration(plan);
|
|
@@ -2328,6 +2364,9 @@ export function collectPreservation(plan) {
|
|
|
2328
2364
|
// The Designer's half of a connector task's configuration, which compile
|
|
2329
2365
|
// does not rebuild: its saved field list is what the next decompile
|
|
2330
2366
|
// carries `carriedFields` from (#1362).
|
|
2367
|
+
// An older-shape document extraction's data, carried verbatim (document-extraction-saved.ts).
|
|
2368
|
+
if (task.type === 'document-extraction' && isOlderDocumentExtractionData(task.data))
|
|
2369
|
+
documentExtractionData.push({ stage: label, lane: laneIndex, task: task.displayName ?? '', data: task.data });
|
|
2331
2370
|
// An action task's Designer-owned data fields (preserve.ts).
|
|
2332
2371
|
if (task.type === 'action' && task.data && typeof task.data === 'object') {
|
|
2333
2372
|
const carried = Object.fromEntries(Object.entries(task.data).filter(([name]) => PRESERVED_ACTION_DATA_KEYS.has(name)));
|
|
@@ -2374,6 +2413,8 @@ export function collectPreservation(plan) {
|
|
|
2374
2413
|
preservation.omitTaskElementIds = omitTaskElementIds;
|
|
2375
2414
|
if (actionDataFields.length)
|
|
2376
2415
|
preservation.actionDataFields = actionDataFields;
|
|
2416
|
+
if (documentExtractionData.length)
|
|
2417
|
+
preservation.documentExtractionData = documentExtractionData;
|
|
2377
2418
|
if (omitStagePositions.length)
|
|
2378
2419
|
preservation.omitStagePositions = omitStagePositions;
|
|
2379
2420
|
if (stageDataFields.length)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"type": "object",
|
|
4
|
+
"properties": {
|
|
5
|
+
"ExtractionResult": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"DocumentId": {
|
|
9
|
+
"type": "string"
|
|
10
|
+
},
|
|
11
|
+
"ResultsVersion": {
|
|
12
|
+
"type": "integer"
|
|
13
|
+
},
|
|
14
|
+
"ResultsDocument": {
|
|
15
|
+
"type": "object",
|
|
16
|
+
"properties": {
|
|
17
|
+
"Bounds": {
|
|
18
|
+
"type": "object",
|
|
19
|
+
"properties": {
|
|
20
|
+
"PageCount": {
|
|
21
|
+
"type": "integer"
|
|
22
|
+
},
|
|
23
|
+
"PageRange": {
|
|
24
|
+
"type": "string"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"Language": {
|
|
29
|
+
"type": "string"
|
|
30
|
+
},
|
|
31
|
+
"DocumentGroup": {
|
|
32
|
+
"type": "string"
|
|
33
|
+
},
|
|
34
|
+
"DocumentCategory": {
|
|
35
|
+
"type": "string"
|
|
36
|
+
},
|
|
37
|
+
"DocumentTypeId": {
|
|
38
|
+
"type": "string"
|
|
39
|
+
},
|
|
40
|
+
"DocumentTypeName": {
|
|
41
|
+
"type": "string"
|
|
42
|
+
},
|
|
43
|
+
"Fields": {
|
|
44
|
+
"type": "array",
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"properties": {
|
|
48
|
+
"FieldId": {
|
|
49
|
+
"type": "string"
|
|
50
|
+
},
|
|
51
|
+
"FieldName": {
|
|
52
|
+
"type": "string"
|
|
53
|
+
},
|
|
54
|
+
"FieldType": {
|
|
55
|
+
"type": "string"
|
|
56
|
+
},
|
|
57
|
+
"Value": {
|
|
58
|
+
"type": "string"
|
|
59
|
+
},
|
|
60
|
+
"UnformattedValue": {
|
|
61
|
+
"type": "string"
|
|
62
|
+
},
|
|
63
|
+
"Confidence": {
|
|
64
|
+
"type": "number"
|
|
65
|
+
},
|
|
66
|
+
"IsMissing": {
|
|
67
|
+
"type": "boolean"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"Tables": {
|
|
73
|
+
"type": "array",
|
|
74
|
+
"items": {
|
|
75
|
+
"type": "object"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"ExtractorPayloads": {
|
|
81
|
+
"type": "object"
|
|
82
|
+
},
|
|
83
|
+
"BusinessrulesResults": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"items": {
|
|
86
|
+
"type": "object"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
"Taxonomy": {
|
|
92
|
+
"type": "object",
|
|
93
|
+
"properties": {
|
|
94
|
+
"DataContractVersion": {
|
|
95
|
+
"type": "string"
|
|
96
|
+
},
|
|
97
|
+
"DocumentTypes": {
|
|
98
|
+
"type": "array",
|
|
99
|
+
"items": {
|
|
100
|
+
"type": "object",
|
|
101
|
+
"properties": {
|
|
102
|
+
"DocumentTypeId": {
|
|
103
|
+
"type": "string"
|
|
104
|
+
},
|
|
105
|
+
"Group": {
|
|
106
|
+
"type": "string"
|
|
107
|
+
},
|
|
108
|
+
"Category": {
|
|
109
|
+
"type": "string"
|
|
110
|
+
},
|
|
111
|
+
"Name": {
|
|
112
|
+
"type": "string"
|
|
113
|
+
},
|
|
114
|
+
"OptionalUniqueIdentifier": {
|
|
115
|
+
"type": "string"
|
|
116
|
+
},
|
|
117
|
+
"TypeField": {
|
|
118
|
+
"type": "object"
|
|
119
|
+
},
|
|
120
|
+
"Fields": {
|
|
121
|
+
"type": "array",
|
|
122
|
+
"items": {
|
|
123
|
+
"type": "object"
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DocumentExtractionFinding } from './document-extraction.js';
|
|
2
|
+
/** Whether a document-extraction task's saved `data` is the older shape, which is carried rather than lifted. */
|
|
3
|
+
export declare function isOlderDocumentExtractionData(data: unknown): data is Record<string, unknown>;
|
|
4
|
+
/** One carried task's saved `data`, located the way the other per-task lanes are. */
|
|
5
|
+
export interface PreservedDocumentExtractionData {
|
|
6
|
+
/** Stage label used to find the rebuilt task. */
|
|
7
|
+
stage: string;
|
|
8
|
+
/** Zero-based task lane. */
|
|
9
|
+
lane: number;
|
|
10
|
+
/** Task display name used to find the rebuilt task. */
|
|
11
|
+
task: string;
|
|
12
|
+
/** The task's `data` as saved, verbatim. */
|
|
13
|
+
data: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
/** What `check` says about a carried task (`lint`, a warning): it runs as saved, and a re-save upgrades it. */
|
|
16
|
+
export declare function savedDocumentExtractionLint(owner: string): DocumentExtractionFinding;
|
|
17
|
+
/**
|
|
18
|
+
* The carried `data` for a `.savedDocumentExtraction()` task, cloned, or the
|
|
19
|
+
* refusal: the task names no saved data (the payload was dropped or the task
|
|
20
|
+
* renamed), or it maps outputs, which the saved rows already are.
|
|
21
|
+
*/
|
|
22
|
+
export declare function savedDocumentExtractionData(owner: string, entries: readonly PreservedDocumentExtractionData[] | undefined, stage: string, task: string, hasOutputs: boolean): Record<string, unknown>;
|
|
23
|
+
/** Why a payload's `documentExtractionData` entry cannot stand, or `undefined`. */
|
|
24
|
+
export declare function preservedDocumentExtractionDataError(entry: PreservedDocumentExtractionData): string | undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case/document-extraction-saved — the older, flat document-extraction task,
|
|
3
|
+
* carried as saved.
|
|
4
|
+
*
|
|
5
|
+
* Production plans (all five with this task in the brownfield corpus) save an
|
|
6
|
+
* older `data` shape: `{ name, serviceType: "IxpExtraction", folderPath,
|
|
7
|
+
* inputs, outputs }`, the deployment named by `name` + `folderPath`, with no
|
|
8
|
+
* Designer `context`. Variants seen in the repo's probes spell `serviceType`
|
|
9
|
+
* `IXP.DocumentExtraction`, or carry a partial `context` beside `folderPath`.
|
|
10
|
+
*
|
|
11
|
+
* That `data` has no `modelName`, `folderKey` or `deploymentKey`, so it cannot
|
|
12
|
+
* be lifted to `.documentExtraction(model, spec)` without inventing them.
|
|
13
|
+
* Decompile writes `.savedDocumentExtraction()` instead, and puts the task's
|
|
14
|
+
* `data` in the `preserveCaseJson(...)` payload (`documentExtractionData`);
|
|
15
|
+
* compile writes it back byte for byte, its bindings travelling in
|
|
16
|
+
* `readBindings` as any read row does. `check` warns
|
|
17
|
+
* (DOCUMENT_EXTRACTION_OLDER_SHAPE) that a Designer re-save upgrades it.
|
|
18
|
+
*/
|
|
19
|
+
import { CompileRefusal } from '../core/compile-refusal.js';
|
|
20
|
+
/** The `serviceType` spellings of the older shape: production saves and an early probe. */
|
|
21
|
+
const OLDER_SERVICE_TYPES = new Set(['IxpExtraction', 'IXP.DocumentExtraction']);
|
|
22
|
+
/** Whether a document-extraction task's saved `data` is the older shape, which is carried rather than lifted. */
|
|
23
|
+
export function isOlderDocumentExtractionData(data) {
|
|
24
|
+
if (!data || typeof data !== 'object' || Array.isArray(data))
|
|
25
|
+
return false;
|
|
26
|
+
const d = data;
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(d, 'folderPath') || OLDER_SERVICE_TYPES.has(String(d.serviceType));
|
|
28
|
+
}
|
|
29
|
+
/** What `check` says about a carried task (`lint`, a warning): it runs as saved, and a re-save upgrades it. */
|
|
30
|
+
export function savedDocumentExtractionLint(owner) {
|
|
31
|
+
return {
|
|
32
|
+
code: 'DOCUMENT_EXTRACTION_OLDER_SHAPE',
|
|
33
|
+
message: `${owner} is the older document-extraction shape (the deployment named by name + folderPath, no Designer context). `
|
|
34
|
+
+ 'Compile writes it back exactly as saved; the SDK cannot edit its deployment or outputs.',
|
|
35
|
+
suggestion: 'To edit it, re-save the task in the Case Designer, which writes the current shape, and decompile again; '
|
|
36
|
+
+ "or replace it with .documentExtraction(model, { deployment, folderKey, deploymentKey, file }), reading model, deployment and folderKey from "
|
|
37
|
+
+ "'uip ixp deployments list <IXP project Name, not its Title> --output json', and deploymentKey and folder from the row of "
|
|
38
|
+
+ "'uip solution resources list --kind IxpDeployment --source remote --output json' whose Name is the deployment and whose FolderKey matches.",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The carried `data` for a `.savedDocumentExtraction()` task, cloned, or the
|
|
43
|
+
* refusal: the task names no saved data (the payload was dropped or the task
|
|
44
|
+
* renamed), or it maps outputs, which the saved rows already are.
|
|
45
|
+
*/
|
|
46
|
+
export function savedDocumentExtractionData(owner, entries, stage, task, hasOutputs) {
|
|
47
|
+
if (hasOutputs)
|
|
48
|
+
throw new CompileRefusal('DOCUMENT_EXTRACTION_SAVED_DATA', `${owner} is carried as saved, and its saved output rows are written as they are; .outputs() cannot add to them.`, 'Drop .outputs(), or re-author the task with .documentExtraction(model, spec) and map its outputs there.');
|
|
49
|
+
const entry = (entries ?? []).find((e) => e.stage === stage && e.task === task);
|
|
50
|
+
if (!entry)
|
|
51
|
+
throw new CompileRefusal('DOCUMENT_EXTRACTION_SAVED_DATA', `${owner} is .savedDocumentExtraction(), but the preserveCaseJson(...) payload carries no documentExtractionData entry for stage "${stage}", task "${task}".`, 'Keep the payload decompile wrote (and the stage and task names it records), or re-author the task with .documentExtraction(model, spec).');
|
|
52
|
+
return structuredClone(entry.data);
|
|
53
|
+
}
|
|
54
|
+
/** Why a payload's `documentExtractionData` entry cannot stand, or `undefined`. */
|
|
55
|
+
export function preservedDocumentExtractionDataError(entry) {
|
|
56
|
+
const where = `preserved document-extraction data of task "${entry?.stage}/${entry?.task}"`;
|
|
57
|
+
if (!entry || typeof entry.stage !== 'string' || typeof entry.task !== 'string')
|
|
58
|
+
return `${where} must name its stage and task`;
|
|
59
|
+
if (!Number.isInteger(entry.lane) || entry.lane < 0)
|
|
60
|
+
return `${where} has lane "${entry.lane}", not a non-negative integer`;
|
|
61
|
+
if (!isOlderDocumentExtractionData(entry.data))
|
|
62
|
+
return `${where} is not the older shape (folderPath, or serviceType IxpExtraction / IXP.DocumentExtraction); only that shape is carried`;
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case/document-extraction — the Case `document-extraction` task: a document
|
|
3
|
+
* run through a deployed IXP model, written as the Case Designer saves it.
|
|
4
|
+
*
|
|
5
|
+
* Read from an alpha Designer save (2026-10-16, schema 32.0.4; UiPath/cli
|
|
6
|
+
* `packages/case-tool/tests/fixtures/document-extraction/designer-saved.json`)
|
|
7
|
+
* and the CLI's writer, `sdd convert` (`services/sdd-convert/document-extraction.ts`
|
|
8
|
+
* at UiPath/cli b37f32997c). With ids masked the two agree on every `data`
|
|
9
|
+
* field and on the binding.
|
|
10
|
+
*
|
|
11
|
+
* The task's `data`:
|
|
12
|
+
* - `name` "Document extraction", `serviceType` "IXP.Extraction", `version` "v2";
|
|
13
|
+
* - `context`: the deployment, in the Designer's order. `solutionResourceKey`
|
|
14
|
+
* (the deployment's solution key), `name` (a reference to its `ixpDeployment`
|
|
15
|
+
* name binding), `folderKey`, `folderName`, `modelName` (the deployment's
|
|
16
|
+
* DeploymentName, `<slug>-<hash>-ixp`), `modelDisplayName` (its
|
|
17
|
+
* DeploymentTitle) and `digitizationMode` "fileUpload";
|
|
18
|
+
* - `inputs`: `fileRef` (the document, required) and `pageRange`;
|
|
19
|
+
* - `outputs`: what the model extracts, as `output` (`=result`), and `error`.
|
|
20
|
+
*
|
|
21
|
+
* The keys are tenant values. `uip ixp deployments list <project-name>`, given
|
|
22
|
+
* the IXP project's Name (not its Title, which is `not_found`), gives
|
|
23
|
+
* DeploymentName, DeploymentTitle and FolderKey, and no folder path. `uip
|
|
24
|
+
* solution resources list --kind IxpDeployment --source remote` lists every
|
|
25
|
+
* IXP deployment on the tenant: the row whose `Name` is the DeploymentTitle and
|
|
26
|
+
* whose `FolderKey` matches gives `Key` (the deploymentKey) and `Folder` (the
|
|
27
|
+
* folder path). `sdd resolve` does not resolve them. Without `folderKey` or `modelName` the task packs to a placeholder that
|
|
28
|
+
* never runs, and `validate` says nothing about a missing `folderKey`, so
|
|
29
|
+
* `check` does ({@link documentExtractionLint}). Without `deploymentKey` the
|
|
30
|
+
* binding cannot be written, so compile refuses it ({@link documentExtractionRefusal}).
|
|
31
|
+
*/
|
|
32
|
+
import type { CaseDocumentExtractionSpec, TaskOutputBinding } from './case-sdk.js';
|
|
33
|
+
/**
|
|
34
|
+
* The `output` row's schema, copied byte for byte from UiPath/cli
|
|
35
|
+
* `packages/case-tool/src/services/sdd-convert/document-extraction-output-schema.json`
|
|
36
|
+
* (last changed in 8810e5a8d1, 2026-10-19; read at b37f32997c). The Designer
|
|
37
|
+
* save carries the same schema. `case-document-extraction.test.ts` pins its hash.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DOCUMENT_EXTRACTION_OUTPUT_SCHEMA: Readonly<Record<string, unknown>>;
|
|
40
|
+
export declare const DOCUMENT_EXTRACTION_OUTPUT_SCHEMA_PROVENANCE: {
|
|
41
|
+
readonly repo: "UiPath/cli";
|
|
42
|
+
readonly path: "packages/case-tool/src/services/sdd-convert/document-extraction-output-schema.json";
|
|
43
|
+
readonly commit: "8810e5a8d193ade16b06bf0b5df23af5dc5b9593";
|
|
44
|
+
readonly sha256: "6d1e5b7b65f290bb458b9068f9000c86525557ab25d70a4b86a44a42a1e31358";
|
|
45
|
+
};
|
|
46
|
+
export declare const DOCUMENT_EXTRACTION_SERVICE_TYPE = "IXP.Extraction";
|
|
47
|
+
export declare const DOCUMENT_EXTRACTION_NAME = "Document extraction";
|
|
48
|
+
export declare const DOCUMENT_EXTRACTION_VERSION = "v2";
|
|
49
|
+
export declare const DOCUMENT_EXTRACTION_RESOURCE = "ixpDeployment";
|
|
50
|
+
/** The task's two outputs, in the Designer's order. */
|
|
51
|
+
export declare const DOCUMENT_EXTRACTION_OUTPUTS: readonly [{
|
|
52
|
+
readonly name: "output";
|
|
53
|
+
readonly displayName: "Output";
|
|
54
|
+
readonly source: "=result";
|
|
55
|
+
readonly schema: Readonly<Record<string, unknown>>;
|
|
56
|
+
}, {
|
|
57
|
+
readonly name: "error";
|
|
58
|
+
readonly displayName: "Error";
|
|
59
|
+
readonly source: "=Error";
|
|
60
|
+
readonly schema: {
|
|
61
|
+
type: string;
|
|
62
|
+
properties: {
|
|
63
|
+
code: {
|
|
64
|
+
type: string;
|
|
65
|
+
};
|
|
66
|
+
message: {
|
|
67
|
+
type: string;
|
|
68
|
+
};
|
|
69
|
+
detail: {
|
|
70
|
+
type: string;
|
|
71
|
+
};
|
|
72
|
+
category: {
|
|
73
|
+
type: string;
|
|
74
|
+
};
|
|
75
|
+
status: {
|
|
76
|
+
type: string;
|
|
77
|
+
};
|
|
78
|
+
element: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
}];
|
|
84
|
+
/** The context row names, in the Designer's order: decompile lifts exactly these. */
|
|
85
|
+
export declare const DOCUMENT_EXTRACTION_CONTEXT: readonly string[];
|
|
86
|
+
/** A refusal or finding `check` and `serialize` share. */
|
|
87
|
+
export interface DocumentExtractionFinding {
|
|
88
|
+
code: string;
|
|
89
|
+
message: string;
|
|
90
|
+
suggestion?: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* What `check` says about a task compile writes as authored (`lint`): the
|
|
94
|
+
* values without which the task cannot run, which `validate` misses or reports
|
|
95
|
+
* against the wrong thing.
|
|
96
|
+
*/
|
|
97
|
+
export declare function documentExtractionLint(owner: string, spec: CaseDocumentExtractionSpec): DocumentExtractionFinding[];
|
|
98
|
+
/**
|
|
99
|
+
* Why compile cannot write `spec` (`lowering`), or `undefined`: a deployment
|
|
100
|
+
* with no `deploymentKey` would be bound by a binding with no `resourceKey`,
|
|
101
|
+
* which `validate` rejects (as a schema migration failure,
|
|
102
|
+
* CASE_MGMT_FIELD_TYPE_MISMATCH) and decompile cannot read back.
|
|
103
|
+
*/
|
|
104
|
+
export declare function documentExtractionRefusal(owner: string, spec: CaseDocumentExtractionSpec): DocumentExtractionFinding | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Which output an `.outputs()` row writes to a case variable: its `source` is
|
|
107
|
+
* one of the two, once each; or the refusal (`lowering`: no row to write).
|
|
108
|
+
*/
|
|
109
|
+
export declare function documentExtractionOutputMappings(owner: string, outputs: readonly TaskOutputBinding[] | undefined): Map<string, string> | DocumentExtractionFinding;
|
|
110
|
+
/** The context rows, in the Designer's order; `name` is the binding reference, or `""` without a deployment. */
|
|
111
|
+
export declare function documentExtractionContext(spec: CaseDocumentExtractionSpec, nameRef: string): Record<string, unknown>[];
|
|
112
|
+
/** The two inputs, with the `v` ids the caller mints. */
|
|
113
|
+
export declare function documentExtractionInputs(spec: CaseDocumentExtractionSpec, elementId: string, mint: (name: string) => string): Record<string, unknown>[];
|
|
114
|
+
/**
|
|
115
|
+
* The two output rows, each claimed a document-unique id; a mapped output
|
|
116
|
+
* writes the case variable the author named instead, keeping its id as
|
|
117
|
+
* `originalVar`, as the Designer saves an arrow row (`output -> extracted`).
|
|
118
|
+
*/
|
|
119
|
+
export declare function documentExtractionOutputs(elementId: string, claim: (base: string) => string, mappings: ReadonlyMap<string, string>): Record<string, unknown>[];
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import outputSchema from './document-extraction-output-schema.json' with { type: 'json' };
|
|
2
|
+
/**
|
|
3
|
+
* The `output` row's schema, copied byte for byte from UiPath/cli
|
|
4
|
+
* `packages/case-tool/src/services/sdd-convert/document-extraction-output-schema.json`
|
|
5
|
+
* (last changed in 8810e5a8d1, 2026-10-19; read at b37f32997c). The Designer
|
|
6
|
+
* save carries the same schema. `case-document-extraction.test.ts` pins its hash.
|
|
7
|
+
*/
|
|
8
|
+
export const DOCUMENT_EXTRACTION_OUTPUT_SCHEMA = outputSchema;
|
|
9
|
+
export const DOCUMENT_EXTRACTION_OUTPUT_SCHEMA_PROVENANCE = {
|
|
10
|
+
repo: 'UiPath/cli',
|
|
11
|
+
path: 'packages/case-tool/src/services/sdd-convert/document-extraction-output-schema.json',
|
|
12
|
+
commit: '8810e5a8d193ade16b06bf0b5df23af5dc5b9593',
|
|
13
|
+
sha256: '6d1e5b7b65f290bb458b9068f9000c86525557ab25d70a4b86a44a42a1e31358',
|
|
14
|
+
};
|
|
15
|
+
export const DOCUMENT_EXTRACTION_SERVICE_TYPE = 'IXP.Extraction';
|
|
16
|
+
export const DOCUMENT_EXTRACTION_NAME = 'Document extraction';
|
|
17
|
+
export const DOCUMENT_EXTRACTION_VERSION = 'v2';
|
|
18
|
+
export const DOCUMENT_EXTRACTION_RESOURCE = 'ixpDeployment';
|
|
19
|
+
/** The `error` row's schema, as the Designer and the CLI write it. */
|
|
20
|
+
const ERROR_SCHEMA = {
|
|
21
|
+
type: 'object',
|
|
22
|
+
properties: {
|
|
23
|
+
code: { type: 'string' }, message: { type: 'string' }, detail: { type: 'string' },
|
|
24
|
+
category: { type: 'string' }, status: { type: 'number' }, element: { type: 'string' },
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/** The task's two outputs, in the Designer's order. */
|
|
28
|
+
export const DOCUMENT_EXTRACTION_OUTPUTS = [
|
|
29
|
+
{ name: 'output', displayName: 'Output', source: '=result', schema: DOCUMENT_EXTRACTION_OUTPUT_SCHEMA },
|
|
30
|
+
{ name: 'error', displayName: 'Error', source: '=Error', schema: ERROR_SCHEMA },
|
|
31
|
+
];
|
|
32
|
+
/** The context row names, in the Designer's order: decompile lifts exactly these. */
|
|
33
|
+
export const DOCUMENT_EXTRACTION_CONTEXT = [
|
|
34
|
+
'solutionResourceKey', 'name', 'folderKey', 'folderName', 'modelName', 'modelDisplayName', 'digitizationMode',
|
|
35
|
+
];
|
|
36
|
+
const blank = (value) => value === undefined || value.trim() === '';
|
|
37
|
+
/**
|
|
38
|
+
* What `check` says about a task compile writes as authored (`lint`): the
|
|
39
|
+
* values without which the task cannot run, which `validate` misses or reports
|
|
40
|
+
* against the wrong thing.
|
|
41
|
+
*/
|
|
42
|
+
export function documentExtractionLint(owner, spec) {
|
|
43
|
+
const found = [];
|
|
44
|
+
// The IXP project's Name: a Title is `not_found` (a tenant run, UiPath/skills#4452).
|
|
45
|
+
const LIST = "uip ixp deployments list <IXP project Name, not its Title> --output json";
|
|
46
|
+
if (blank(spec.model))
|
|
47
|
+
found.push({
|
|
48
|
+
code: 'DOCUMENT_EXTRACTION_NO_MODEL',
|
|
49
|
+
message: `${owner} names no model, so it packs to a placeholder that never runs.`,
|
|
50
|
+
suggestion: `Pass model: the deployment's DeploymentName (\`<slug>-<hash>-ixp\`), from '${LIST}'.`,
|
|
51
|
+
});
|
|
52
|
+
if (blank(spec.deployment))
|
|
53
|
+
found.push({
|
|
54
|
+
code: 'DOCUMENT_EXTRACTION_NO_DEPLOYMENT',
|
|
55
|
+
message: `${owner} names no deployment, so compile writes no ixpDeployment binding and nothing binds the model the task runs.`,
|
|
56
|
+
suggestion: `Pass deployment: the deployment's DeploymentTitle, from '${LIST}'.`,
|
|
57
|
+
});
|
|
58
|
+
if (blank(spec.folderKey))
|
|
59
|
+
found.push({
|
|
60
|
+
code: 'DOCUMENT_EXTRACTION_NO_FOLDER_KEY',
|
|
61
|
+
message: `${owner} has no folderKey, so it packs to a placeholder that never runs. \`uip maestro case validate\` does not report this.`,
|
|
62
|
+
suggestion: `Pass folderKey: the deployment's FolderKey, from '${LIST}'.`,
|
|
63
|
+
});
|
|
64
|
+
// `uip maestro case sdd convert` reports a missing Folder Path as unresolved,
|
|
65
|
+
// as it does a missing FolderKey, and writes folderName null.
|
|
66
|
+
if (blank(spec.folder))
|
|
67
|
+
found.push({
|
|
68
|
+
code: 'DOCUMENT_EXTRACTION_NO_FOLDER',
|
|
69
|
+
message: `${owner} names no folder, so context.folderName is written empty: the folder the deployment is deployed to is unnamed. `
|
|
70
|
+
+ "`uip maestro case sdd convert` reports the same gap as unresolved.",
|
|
71
|
+
suggestion: "Pass folder: the deployment's folder path, from the row of 'uip solution resources list --kind IxpDeployment --source remote --output json' whose Name is the deployment and whose FolderKey matches (its Folder).",
|
|
72
|
+
});
|
|
73
|
+
if (blank(spec.file))
|
|
74
|
+
found.push({
|
|
75
|
+
code: 'DOCUMENT_EXTRACTION_NO_FILE',
|
|
76
|
+
message: `${owner} reads no file, so the model has nothing to extract from.`,
|
|
77
|
+
suggestion: "Pass file: the document, usually a file case variable (file: '=vars.invoice').",
|
|
78
|
+
});
|
|
79
|
+
return found;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Why compile cannot write `spec` (`lowering`), or `undefined`: a deployment
|
|
83
|
+
* with no `deploymentKey` would be bound by a binding with no `resourceKey`,
|
|
84
|
+
* which `validate` rejects (as a schema migration failure,
|
|
85
|
+
* CASE_MGMT_FIELD_TYPE_MISMATCH) and decompile cannot read back.
|
|
86
|
+
*/
|
|
87
|
+
export function documentExtractionRefusal(owner, spec) {
|
|
88
|
+
if (spec.deployment.trim() === '' || !blank(spec.deploymentKey))
|
|
89
|
+
return undefined;
|
|
90
|
+
return {
|
|
91
|
+
code: 'DOCUMENT_EXTRACTION_NO_DEPLOYMENT_KEY',
|
|
92
|
+
message: `${owner} has no deploymentKey, so its ixpDeployment binding would have no resourceKey, which the platform rejects and the solution cannot resolve.`,
|
|
93
|
+
suggestion: "Pass deploymentKey: the Key of the row of 'uip solution resources list --kind IxpDeployment --source remote --output json' whose Name is the deployment's title and whose FolderKey matches.",
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Which output an `.outputs()` row writes to a case variable: its `source` is
|
|
98
|
+
* one of the two, once each; or the refusal (`lowering`: no row to write).
|
|
99
|
+
*/
|
|
100
|
+
export function documentExtractionOutputMappings(owner, outputs) {
|
|
101
|
+
const bySource = new Map();
|
|
102
|
+
for (const o of outputs ?? []) {
|
|
103
|
+
if (o.custom)
|
|
104
|
+
continue;
|
|
105
|
+
if (!DOCUMENT_EXTRACTION_OUTPUTS.some((row) => row.source === o.source))
|
|
106
|
+
return {
|
|
107
|
+
code: 'DOCUMENT_EXTRACTION_OUTPUT',
|
|
108
|
+
message: `${owner} output "${o.var}" reads ${JSON.stringify(o.source)}; a document extraction has two outputs: `
|
|
109
|
+
+ `${DOCUMENT_EXTRACTION_OUTPUTS.map((row) => row.source).join(' and ')}.`,
|
|
110
|
+
suggestion: "Map the extraction to a case variable, .outputs({ extracted: '=result' }), and read its fields as extracted.<field>.",
|
|
111
|
+
};
|
|
112
|
+
if (bySource.has(o.source))
|
|
113
|
+
return { code: 'DOCUMENT_EXTRACTION_OUTPUT', message: `${owner} writes ${o.source} to two variables, "${bySource.get(o.source)}" and "${o.var}".` };
|
|
114
|
+
bySource.set(o.source, o.var);
|
|
115
|
+
}
|
|
116
|
+
return bySource;
|
|
117
|
+
}
|
|
118
|
+
/** The context rows, in the Designer's order; `name` is the binding reference, or `""` without a deployment. */
|
|
119
|
+
export function documentExtractionContext(spec, nameRef) {
|
|
120
|
+
const row = (name, value) => ({ name, type: 'string', value });
|
|
121
|
+
const or = (value) => (value === undefined ? null : value);
|
|
122
|
+
return [
|
|
123
|
+
row('solutionResourceKey', or(spec.deploymentKey)),
|
|
124
|
+
row('name', nameRef),
|
|
125
|
+
row('folderKey', or(spec.folderKey)),
|
|
126
|
+
row('folderName', or(spec.folder)),
|
|
127
|
+
row('modelName', or(spec.model)),
|
|
128
|
+
row('modelDisplayName', or(spec.deployment)),
|
|
129
|
+
row('digitizationMode', 'fileUpload'),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
/** The two inputs, with the `v` ids the caller mints. */
|
|
133
|
+
export function documentExtractionInputs(spec, elementId, mint) {
|
|
134
|
+
const file = mint('fileRef');
|
|
135
|
+
const pages = mint('pageRange');
|
|
136
|
+
return [
|
|
137
|
+
{ name: 'fileRef', displayName: 'File', type: 'file', value: spec.file ?? '', required: true, id: file, var: file, elementId },
|
|
138
|
+
{ name: 'pageRange', displayName: 'Page range', type: 'string', value: spec.pageRange ?? '', id: pages, var: pages, elementId },
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The two output rows, each claimed a document-unique id; a mapped output
|
|
143
|
+
* writes the case variable the author named instead, keeping its id as
|
|
144
|
+
* `originalVar`, as the Designer saves an arrow row (`output -> extracted`).
|
|
145
|
+
*/
|
|
146
|
+
export function documentExtractionOutputs(elementId, claim, mappings) {
|
|
147
|
+
return DOCUMENT_EXTRACTION_OUTPUTS.map((row) => {
|
|
148
|
+
const id = claim(row.name);
|
|
149
|
+
const variable = mappings.get(row.source);
|
|
150
|
+
const out = {
|
|
151
|
+
name: row.name, displayName: row.displayName, type: 'jsonSchema', source: row.source,
|
|
152
|
+
_jsonSchema: structuredClone(row.schema), id, var: variable ?? id, value: variable ?? id, elementId,
|
|
153
|
+
};
|
|
154
|
+
if (variable !== undefined) {
|
|
155
|
+
out.target = `=${id}`;
|
|
156
|
+
out.originalVar = id;
|
|
157
|
+
}
|
|
158
|
+
out.body = structuredClone(row.schema);
|
|
159
|
+
return out;
|
|
160
|
+
});
|
|
161
|
+
}
|
package/dist/case/load.js
CHANGED
|
@@ -4,6 +4,8 @@ import { resolve } from 'node:path';
|
|
|
4
4
|
import { existsSync, statSync } from 'node:fs';
|
|
5
5
|
import { useThisSdkForAuthoredSource } from '../sdk-resolve.js';
|
|
6
6
|
import { CompileRefusal } from '../core/compile-refusal.js';
|
|
7
|
+
import { scriptFunctionLowerings } from '../core/script-function.js';
|
|
8
|
+
import { scriptFunctionScopeProblem } from '../script-function-scope.js';
|
|
7
9
|
/**
|
|
8
10
|
* Resolve a user argument (a `.ts` path or a BaseName) to a case source file.
|
|
9
11
|
*
|
|
@@ -24,6 +26,7 @@ export function resolveCaseFile(arg) {
|
|
|
24
26
|
}
|
|
25
27
|
export async function loadBuiltCase(file) {
|
|
26
28
|
useThisSdkForAuthoredSource();
|
|
29
|
+
const firstLowering = scriptFunctionLowerings().length;
|
|
27
30
|
const mod = await import(pathToFileURL(file).href);
|
|
28
31
|
const exp = mod.default ?? mod.casePlan ?? mod.case;
|
|
29
32
|
if (!exp)
|
|
@@ -31,5 +34,14 @@ export async function loadBuiltCase(file) {
|
|
|
31
34
|
const built = typeof exp.build === 'function' ? exp.build() : exp;
|
|
32
35
|
if (!built || !Array.isArray(built.stages))
|
|
33
36
|
throw new CompileRefusal('CASE_EXPORT_NOT_BUILT', `${file} default export is not a built case. Did you call .build()?`);
|
|
37
|
+
// A `.script(fn)` function was lowered from its own text, which cannot show a
|
|
38
|
+
// name it takes from its module; this source can (script-function-scope.ts),
|
|
39
|
+
// as Flow's loader does. Only a case that lowered one pays for the program.
|
|
40
|
+
const lowered = scriptFunctionLowerings().slice(firstLowering);
|
|
41
|
+
if (lowered.length > 0) {
|
|
42
|
+
const problem = scriptFunctionScopeProblem(file, lowered);
|
|
43
|
+
if (problem)
|
|
44
|
+
throw new CompileRefusal('SCRIPT_FUNCTION_SCOPE', problem);
|
|
45
|
+
}
|
|
34
46
|
return built;
|
|
35
47
|
}
|
package/dist/case/preserve.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ReadEventFilter } from '../core/event-filters.js';
|
|
|
3
3
|
import { Bindings } from '../core/bindings.js';
|
|
4
4
|
import type { BindingsView } from '../core/binding-messages.js';
|
|
5
5
|
import { type PreservedResourceWire } from './resource-wire.js';
|
|
6
|
+
import { type PreservedDocumentExtractionData } from './document-extraction-saved.js';
|
|
6
7
|
export type PreservedVariableLane = 'inputs' | 'outputs' | 'inputOutputs';
|
|
7
8
|
/**
|
|
8
9
|
* A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
|
|
@@ -339,6 +340,12 @@ export interface CaseJsonPreservation {
|
|
|
339
340
|
* fields), and the quick form's `inputSchema`. No builder call writes either.
|
|
340
341
|
*/
|
|
341
342
|
actionDataFields?: PreservedActionDataFields[];
|
|
343
|
+
/**
|
|
344
|
+
* Each older, flat document-extraction task's `data`, verbatim
|
|
345
|
+
* (case/document-extraction-saved.ts). Its source is `.savedDocumentExtraction()`,
|
|
346
|
+
* and compile writes this `data` back as saved.
|
|
347
|
+
*/
|
|
348
|
+
documentExtractionData?: PreservedDocumentExtractionData[];
|
|
342
349
|
/**
|
|
343
350
|
* How each subscription with an expression-valued filter spelled it, when not
|
|
344
351
|
* the way compile writes a new one (`CaseFilterSpelling` in
|
package/dist/case/preserve.js
CHANGED
|
@@ -2,6 +2,7 @@ import { stableId } from '../core/stable-id.js';
|
|
|
2
2
|
import { Bindings } from '../core/bindings.js';
|
|
3
3
|
import { bindingIdCandidates, offlineBindingLabel } from './ids.js';
|
|
4
4
|
import { resourceBindingSeed, resourceWireError } from './resource-wire.js';
|
|
5
|
+
import { preservedDocumentExtractionDataError } from './document-extraction-saved.js';
|
|
5
6
|
/**
|
|
6
7
|
* A preserved `inputs[]` / `outputs[]` slot id copied verbatim from its name is
|
|
7
8
|
* the STRICT_FORMAL_ARG_ID defect, not an identity to keep; the minted id stands.
|
|
@@ -320,6 +321,11 @@ export function caseJsonPreservationErrors(payload) {
|
|
|
320
321
|
else if (TASK_KEYS.has(field))
|
|
321
322
|
errors.push(`task "${entry.task}" field "${field}" is owned by the typed Case serializer`);
|
|
322
323
|
}
|
|
324
|
+
for (const entry of payload.documentExtractionData ?? []) {
|
|
325
|
+
const error = preservedDocumentExtractionDataError(entry);
|
|
326
|
+
if (error)
|
|
327
|
+
errors.push(error);
|
|
328
|
+
}
|
|
323
329
|
for (const entry of payload.actionDataFields ?? []) {
|
|
324
330
|
if (!Number.isInteger(entry.lane) || entry.lane < 0)
|
|
325
331
|
errors.push(`preserved action data lane "${entry.lane}" is not a non-negative integer`);
|