@uipath/maestro-builder-sdk 6.81.0 → 6.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-index.md +85 -84
- package/dist/api-members.md +277 -266
- package/dist/case/case-sdk.d.ts +90 -1
- package/dist/case/case-sdk.js +51 -3
- package/dist/case/check.js +20 -3
- package/dist/case/decompile-document-extraction.d.ts +17 -0
- package/dist/case/decompile-document-extraction.js +76 -0
- package/dist/case/decompile.d.ts +6 -0
- package/dist/case/decompile.js +26 -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/http-request.d.ts +0 -26
- package/dist/case/http-request.js +58 -3
- package/dist/case/preserve.d.ts +7 -0
- package/dist/case/preserve.js +6 -0
- package/dist/case/script.js +3 -2
- package/dist/case/serialize.js +121 -5
- package/dist/core/refusals.d.ts +9 -0
- package/dist/core/refusals.js +17 -0
- package/package.json +2 -2
|
@@ -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
|
+
}
|
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* case/http-request — the Case `http-request` task: a call through Integration
|
|
3
|
-
* Service's generic HTTP connector, in the shape the Case Designer saves.
|
|
4
|
-
*
|
|
5
|
-
* Read from three alpha Designer saves (2026-10-13, UiPath/cli
|
|
6
|
-
* `packages/case-tool/tests/fixtures/http-request/designer-saved.json`) and the
|
|
7
|
-
* CLI's writer for them, `sdd convert` (`services/sdd-convert/http-request.ts`
|
|
8
|
-
* at UiPath/cli b37f32997c), which was read from PO.Frontend 35d579f94.
|
|
9
|
-
*
|
|
10
|
-
* The task is always the HTTP connector's own activity (`uipath-uipath-http`,
|
|
11
|
-
* `POST /http-request`, the fixed identity in `core/managed-http.ts` that Flow
|
|
12
|
-
* and BPMN share). What a person configures is the request, which rides in the
|
|
13
|
-
* `body` input's `body`: `authentication`, `method`, `url` (manual) or `path`
|
|
14
|
-
* (connector), `headers`, `query`, `body`. Two modes:
|
|
15
|
-
* - manual: the request goes to `url` as written, with no connection; the task
|
|
16
|
-
* names the plan's one `ImplicitConnection` binding;
|
|
17
|
-
* - connector: the request reuses a connection's authentication
|
|
18
|
-
* (`targetConnector`), and `path` is relative to that connector's base URL.
|
|
19
|
-
* The task carries the connection's `ConnectionId` and `folderKey`
|
|
20
|
-
* bindings, which are also at the root.
|
|
21
|
-
*
|
|
22
|
-
* Its refusals follow the check/compile contract: {@link httpRequestRefusal} is
|
|
23
|
-
* what compile cannot write as authored (`lowering`), and `serialize` throws
|
|
24
|
-
* it; {@link httpRequestLint} is what compile writes as authored and only
|
|
25
|
-
* `check` reports (`lint`).
|
|
26
|
-
*/
|
|
27
1
|
import type { CaseHttpRequestSpec, HttpRequestMethod, TaskOutputBinding } from './case-sdk.js';
|
|
28
2
|
/**
|
|
29
3
|
* The Designer's `metadata` context entry body, copied byte for byte from
|
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case/http-request — the Case `http-request` task: a call through Integration
|
|
3
|
+
* Service's generic HTTP connector, in the shape the Case Designer saves.
|
|
4
|
+
*
|
|
5
|
+
* Read from three alpha Designer saves (2026-10-13, UiPath/cli
|
|
6
|
+
* `packages/case-tool/tests/fixtures/http-request/designer-saved.json`) and the
|
|
7
|
+
* CLI's writer for them, `sdd convert` (`services/sdd-convert/http-request.ts`
|
|
8
|
+
* at UiPath/cli b37f32997c), which was read from PO.Frontend 35d579f94.
|
|
9
|
+
*
|
|
10
|
+
* The task is always the HTTP connector's own activity (`uipath-uipath-http`,
|
|
11
|
+
* `POST /http-request`, the fixed identity in `core/managed-http.ts` that Flow
|
|
12
|
+
* and BPMN share). What a person configures is the request, which rides in the
|
|
13
|
+
* `body` input's `body`: `authentication`, `method`, `url` (manual) or `path`
|
|
14
|
+
* (connector), `headers`, `query`, `body`. Two modes:
|
|
15
|
+
* - manual: the request goes to `url` as written, with no connection; the task
|
|
16
|
+
* names the plan's one `ImplicitConnection` binding;
|
|
17
|
+
* - connector: the request reuses a connection's authentication
|
|
18
|
+
* (`targetConnector`), and `path` is relative to that connector's base URL.
|
|
19
|
+
* The task carries the connection's `ConnectionId` and `folderKey`
|
|
20
|
+
* bindings, which are also at the root.
|
|
21
|
+
*
|
|
22
|
+
* Its refusals follow the check/compile contract: {@link httpRequestRefusal} is
|
|
23
|
+
* what compile cannot write as authored (`lowering`), and `serialize` throws
|
|
24
|
+
* it; {@link httpRequestLint} is what compile writes as authored and only
|
|
25
|
+
* `check` reports (`lint`).
|
|
26
|
+
*/
|
|
27
|
+
import { parse } from 'acorn';
|
|
1
28
|
import { MANAGED_HTTP_CONNECTOR_KEY, MANAGED_HTTP_ENDPOINT, MANAGED_HTTP_ENDPOINT_METHOD, MANAGED_HTTP_OBJECT_NAME, } from '../core/managed-http.js';
|
|
2
29
|
import { taskOutputRefs } from './task-output-ref.js';
|
|
3
30
|
import metadata from './http-request-metadata.json' with { type: 'json' };
|
|
@@ -107,7 +134,8 @@ export function httpRequestRefusal(owner, spec) {
|
|
|
107
134
|
if (leaf !== undefined)
|
|
108
135
|
return {
|
|
109
136
|
code: 'HTTP_REQUEST_BODY_EXPRESSION',
|
|
110
|
-
message: `${owner} body has the value ${JSON.stringify(leaf)}, an \`=\` expression compile cannot write as a JavaScript value inside the body
|
|
137
|
+
message: `${owner} body has the value ${JSON.stringify(leaf)}, an \`=\` expression compile cannot write as a JavaScript value inside the body: `
|
|
138
|
+
+ 'a body value must be a reference, or `=js:` followed by exactly one JavaScript expression (not a statement, nor code that does not parse).',
|
|
111
139
|
suggestion: "Write the value as `=js:<expression>` (for example '=js:vars.amount * 2'), as a reference (`=vars.amount`), "
|
|
112
140
|
+ "or as another task's output (`=${taskOutput('Stage', 'Task', 'body')}`).",
|
|
113
141
|
};
|
|
@@ -138,16 +166,43 @@ function isTaskOutputReference(text) {
|
|
|
138
166
|
const refs = taskOutputRefs(text);
|
|
139
167
|
return refs.length === 1 && refs[0].index === 0 && DOTTED_TAIL.test(text.slice(refs[0].whole.length));
|
|
140
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* `code` parenthesized as one JavaScript expression, `(<code>\n)`, or
|
|
171
|
+
* `undefined` when it is not exactly one. The parentheses close on a new line,
|
|
172
|
+
* so a trailing `// comment` ends before them instead of swallowing the rest of
|
|
173
|
+
* the body. acorn reads the result as the CLI's strict check does (`ecmaVersion:
|
|
174
|
+
* 'latest'`, `sourceType: 'script'`), and it must be a single parenthesized
|
|
175
|
+
* expression spanning the whole text: a statement (`vars.a; vars.b`), code that
|
|
176
|
+
* closes the parentheses early (`a), (b`), or an unterminated comment does not
|
|
177
|
+
* parse as one and is refused (`HTTP_REQUEST_BODY_EXPRESSION`).
|
|
178
|
+
*/
|
|
179
|
+
function oneExpression(code) {
|
|
180
|
+
const text = `(${code}\n)`;
|
|
181
|
+
let program;
|
|
182
|
+
try {
|
|
183
|
+
program = parse(text, { ecmaVersion: 'latest', sourceType: 'script', preserveParens: true });
|
|
184
|
+
}
|
|
185
|
+
catch {
|
|
186
|
+
return undefined;
|
|
187
|
+
}
|
|
188
|
+
const [statement] = program.body;
|
|
189
|
+
if (program.body.length !== 1 || statement.type !== 'ExpressionStatement')
|
|
190
|
+
return undefined;
|
|
191
|
+
const { expression } = statement;
|
|
192
|
+
return expression.type === 'ParenthesizedExpression' && expression.start === 0 && expression.end === text.length
|
|
193
|
+
? text
|
|
194
|
+
: undefined;
|
|
195
|
+
}
|
|
141
196
|
/**
|
|
142
197
|
* The JavaScript an `=` leaf of an object body stands for: `=js:<code>` is the
|
|
143
|
-
* code, parenthesized; `=<reference>` is the reference, a `taskOutput()`
|
|
198
|
+
* code, parenthesized as one expression ({@link oneExpression}); `=<reference>` is the reference, a `taskOutput()`
|
|
144
199
|
* marker included. `undefined` for any other `=` text, which compile refuses
|
|
145
200
|
* (`HTTP_REQUEST_BODY_EXPRESSION`).
|
|
146
201
|
*/
|
|
147
202
|
function leafCode(value) {
|
|
148
203
|
if (value.startsWith('=js:')) {
|
|
149
204
|
const code = value.slice('=js:'.length).trim();
|
|
150
|
-
return code === '' ? undefined :
|
|
205
|
+
return code === '' ? undefined : oneExpression(code);
|
|
151
206
|
}
|
|
152
207
|
const reference = value.slice(1).trim();
|
|
153
208
|
return REFERENCE.test(reference) || isTaskOutputReference(reference) ? reference : undefined;
|
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`);
|
package/dist/case/script.js
CHANGED
|
@@ -11,8 +11,9 @@ export const CASE_SCRIPT_RUNTIME = {
|
|
|
11
11
|
global: 'vars', param: 'vars', holds: 'the case variables', reads: 'variable', example: 'amount',
|
|
12
12
|
// `validate` reports a `vars.<name>` that names nothing (CASE_MGMT_REFERENCE_UNBOUND,
|
|
13
13
|
// an error on the default profile, measured at uip 1.206.0), and it reads a script
|
|
14
|
-
// body like any other plan text. `check` runs the same rule
|
|
15
|
-
//
|
|
14
|
+
// body like any other plan text. `check` runs the same rule through its port in
|
|
15
|
+
// `case/plan-check/` and reports CASE_MGMT_REFERENCE_UNBOUND on a script body too
|
|
16
|
+
// (pinned in `case-script.test.ts`); this task adds no second copy of it.
|
|
16
17
|
checkedBy: "`uip maestro case validate`'s variable reference check (CASE_MGMT_REFERENCE_UNBOUND)",
|
|
17
18
|
},
|
|
18
19
|
{
|