@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/case-sdk.d.ts
CHANGED
|
@@ -1,28 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* case-sdk — a fluent builder for UiPath Case Management plans (`caseplan.json`,
|
|
3
|
-
* schema V32).
|
|
4
|
-
*
|
|
5
|
-
* Like the Flow builder, this constructs a plain description of a case — its
|
|
6
|
-
* stages, the tasks inside them, and the entry/exit *conditions* that drive
|
|
7
|
-
* transitions — which `serialize()` turns into a real `caseplan.json`. A case is
|
|
8
|
-
* a hierarchy (stages → tasks), not a graph: there are **no edges**; flow
|
|
9
|
-
* between stages is expressed entirely through conditions (see `rule()`).
|
|
10
|
-
*
|
|
11
|
-
* This first cut is **reference-mode**: a task points at an already-published
|
|
12
|
-
* process/agent/rpa/workflow by name + folder. (Embedding an inline flow/bpmn
|
|
13
|
-
* body in a task is a later phase.) The builder uses callback closures for
|
|
14
|
-
* nesting, matching the Flow SDK's `.branch(name, cond, b => …)` style — so a
|
|
15
|
-
* `casePlan()` only ever exposes case methods, and each nested builder only its
|
|
16
|
-
* own.
|
|
17
|
-
*
|
|
18
|
-
* `casePlan` (not `case`) is the entry point: `case` is a reserved word.
|
|
19
|
-
*/
|
|
20
1
|
import type { TypeDesc } from '../core/expr.js';
|
|
21
2
|
import { type ActionSpec, type ConnectorOpts, type CaseEventFilter, type EventSubscription, type TriggerOptions } from '../core/actions.js';
|
|
22
3
|
import { type ConnectorDescriptor, type TriggerDescriptor } from '../core/connectors.js';
|
|
23
4
|
import type { CarriedConnectorField } from '../core/carried-connector-fields.js';
|
|
24
5
|
export type { CarriedConnectorField, CarriedFieldLocation } from '../core/carried-connector-fields.js';
|
|
25
6
|
export { preserveCaseJson } from './preserve.js';
|
|
7
|
+
export type { PreservedDocumentExtractionData } from './document-extraction-saved.js';
|
|
26
8
|
export type { CaseJsonPreservation, PreservedActionDataFields, PreservedCaseNode, PreservedConnectorConfiguration, PreservedMetadataKey, PreservedSubscriptionFilter, PreservedTaskFields, PreservedVariableLane } from './preserve.js';
|
|
27
9
|
export { CaseBuildError } from './case-expr-check.js';
|
|
28
10
|
export type { CaseLocatedDiagnostic } from './case-expr-check.js';
|
|
@@ -441,7 +423,7 @@ export interface BuiltCaseExitCondition {
|
|
|
441
423
|
marksCaseComplete?: boolean;
|
|
442
424
|
rules: CaseRule[][];
|
|
443
425
|
}
|
|
444
|
-
export type TaskKind = 'process' | 'agent' | 'rpa' | 'api-workflow' | 'case-management' | 'flow-process' | 'function' | 'business-rule' | 'external-agent' | 'external-workflow' | 'action' | 'connector' | 'wait-for-timer' | 'wait-for-connector' | 'http-request';
|
|
426
|
+
export type TaskKind = 'process' | 'agent' | 'rpa' | 'api-workflow' | 'case-management' | 'flow-process' | 'function' | 'business-rule' | 'external-agent' | 'external-workflow' | 'action' | 'connector' | 'wait-for-timer' | 'wait-for-connector' | 'document-extraction' | 'script' | 'http-request';
|
|
445
427
|
/**
|
|
446
428
|
* Task kinds that the Case schema permits as unresolved skeletons: the
|
|
447
429
|
* published-resource kinds, `action` (a human task whose Action App or form is
|
|
@@ -529,6 +511,24 @@ export interface CaseConnectorOpts extends ConnectorOpts {
|
|
|
529
511
|
*/
|
|
530
512
|
carriedFields?: readonly CarriedConnectorField[];
|
|
531
513
|
}
|
|
514
|
+
/** Options for a script task (`.script()`): the schemas the Designer keeps on its two outputs. */
|
|
515
|
+
export interface CaseScriptOptions {
|
|
516
|
+
/**
|
|
517
|
+
* The JSON schema of what the body returns, written as `scriptResponse`'s
|
|
518
|
+
* `_jsonSchema`. The Designer infers it from the body when it saves the plan;
|
|
519
|
+
* decompile carries the one it saved, so a recompile keeps it.
|
|
520
|
+
*/
|
|
521
|
+
responseSchema?: Record<string, unknown>;
|
|
522
|
+
/** The JSON schema of the `Error` output, which a Designer-saved task may carry. A new task has none. */
|
|
523
|
+
errorSchema?: Record<string, unknown>;
|
|
524
|
+
}
|
|
525
|
+
/** A built script task: the body as it runs (no leading `=`), and how it was authored. */
|
|
526
|
+
export interface CaseScriptSpec extends CaseScriptOptions {
|
|
527
|
+
/** The JavaScript body, as the engine runs it. */
|
|
528
|
+
body: string;
|
|
529
|
+
/** Whether the body was lowered from a TypeScript function (so the compiler checked it). */
|
|
530
|
+
fromFunction: boolean;
|
|
531
|
+
}
|
|
532
532
|
/** A method the HTTP request activity offers. */
|
|
533
533
|
export type HttpRequestMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
|
|
534
534
|
/**
|
|
@@ -583,6 +583,52 @@ export interface HttpRequestConnector {
|
|
|
583
583
|
/** The symbolic folder binding of that connection. */
|
|
584
584
|
folder: string;
|
|
585
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* A document-extraction task's IXP deployment and inputs (`.documentExtraction()`).
|
|
588
|
+
* The deployment's values come from the tenant: `uip ixp deployments list
|
|
589
|
+
* <project-name>` (the IXP project's Name, not its Title) gives `model`
|
|
590
|
+
* (DeploymentName), `deployment` (DeploymentTitle) and `folderKey`
|
|
591
|
+
* (FolderKey). `uip solution resources list --kind IxpDeployment --source
|
|
592
|
+
* remote` lists every IXP deployment on the tenant; the row whose `Name` is the
|
|
593
|
+
* DeploymentTitle and whose `FolderKey` matches gives `deploymentKey` (Key) and
|
|
594
|
+
* `folder` (Folder).
|
|
595
|
+
*/
|
|
596
|
+
export interface CaseDocumentExtractionSpec {
|
|
597
|
+
/**
|
|
598
|
+
* The deployment's title (DeploymentTitle), e.g. `Invoice Model`: the model's display name and its binding's default.
|
|
599
|
+
*
|
|
600
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_DEPLOYMENT `check` reports a blank one: no binding names the model.
|
|
601
|
+
*/
|
|
602
|
+
deployment: string;
|
|
603
|
+
/** The deployment's name (DeploymentName, `<slug>-<hash>-ixp`), which the task runs: `.documentExtraction()`'s first argument. */
|
|
604
|
+
model: string;
|
|
605
|
+
/**
|
|
606
|
+
* The deployment's folder key (FolderKey).
|
|
607
|
+
*
|
|
608
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_FOLDER_KEY `check` reports a missing one: the task packs to a placeholder.
|
|
609
|
+
*/
|
|
610
|
+
folderKey?: string;
|
|
611
|
+
/**
|
|
612
|
+
* The deployment's folder path, e.g. `Shared`.
|
|
613
|
+
*
|
|
614
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_FOLDER `check` reports a missing or blank one: the folder is unnamed.
|
|
615
|
+
*/
|
|
616
|
+
folder?: string;
|
|
617
|
+
/**
|
|
618
|
+
* The deployment's solution resource key (Key).
|
|
619
|
+
*
|
|
620
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_DEPLOYMENT_KEY compile refuses a missing one: the binding would have no key.
|
|
621
|
+
*/
|
|
622
|
+
deploymentKey?: string;
|
|
623
|
+
/**
|
|
624
|
+
* The document: usually a file case variable, `=vars.invoice`.
|
|
625
|
+
*
|
|
626
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_FILE `check` reports a missing one.
|
|
627
|
+
*/
|
|
628
|
+
file?: string;
|
|
629
|
+
/** The pages to read, e.g. `1-2`; all of them when omitted. */
|
|
630
|
+
pageRange?: string;
|
|
631
|
+
}
|
|
586
632
|
/**
|
|
587
633
|
* The external agent's or automation's `executionType`, as Integration Service
|
|
588
634
|
* reports it for the connector object.
|
|
@@ -867,6 +913,12 @@ export interface BuiltTask {
|
|
|
867
913
|
connector?: ConnectorSpecData;
|
|
868
914
|
/** Descriptor-resolved external agent/workflow configuration. */
|
|
869
915
|
external?: ExternalTaskSpecData;
|
|
916
|
+
/** document-extraction task: the deployment and the document. */
|
|
917
|
+
documentExtraction?: CaseDocumentExtractionSpec;
|
|
918
|
+
/** document-extraction task carried as saved (`.savedDocumentExtraction()`): its `data` is the preserved one. */
|
|
919
|
+
documentExtractionSaved?: true;
|
|
920
|
+
/** script task: the body. */
|
|
921
|
+
script?: CaseScriptSpec;
|
|
870
922
|
/** http-request task: the request. */
|
|
871
923
|
http?: CaseHttpRequestSpec;
|
|
872
924
|
timer?: TimerSpecData;
|
|
@@ -1126,6 +1178,9 @@ declare class TaskBuilder {
|
|
|
1126
1178
|
private _action?;
|
|
1127
1179
|
private _connector?;
|
|
1128
1180
|
private _external?;
|
|
1181
|
+
private _documentExtraction?;
|
|
1182
|
+
private _documentExtractionSaved?;
|
|
1183
|
+
private _script?;
|
|
1129
1184
|
private _http?;
|
|
1130
1185
|
private _timer?;
|
|
1131
1186
|
private _waitConnector?;
|
|
@@ -1372,6 +1427,72 @@ declare class TaskBuilder {
|
|
|
1372
1427
|
* @returns This builder, so calls chain.
|
|
1373
1428
|
*/
|
|
1374
1429
|
waitForTimer(spec: TimerSpecData): this;
|
|
1430
|
+
/**
|
|
1431
|
+
* A document-extraction task: a document run through a deployed IXP model.
|
|
1432
|
+
* The task writes two outputs: what the model extracts, as `output`
|
|
1433
|
+
* (`=result`), and `error`. Map the extraction to a case variable with
|
|
1434
|
+
* `.outputs({ extracted: '=result' })`.
|
|
1435
|
+
*
|
|
1436
|
+
* ```ts
|
|
1437
|
+
* t.documentExtraction('invoice-model-0a1b2c3d-ixp', {
|
|
1438
|
+
* deployment: 'Invoice Model', folderKey: '<FolderKey>', folder: 'Shared', deploymentKey: '<Key>',
|
|
1439
|
+
* file: '=vars.invoice',
|
|
1440
|
+
* }).outputs({ extracted: '=result' })
|
|
1441
|
+
* ```
|
|
1442
|
+
*
|
|
1443
|
+
* @param model - The deployment's name (DeploymentName, `<slug>-<hash>-ixp`), from `uip ixp deployments list <project-name>` (the IXP project's Name, not its Title).
|
|
1444
|
+
* @param spec - The rest of the deployment (from the tenant) and the document to read.
|
|
1445
|
+
* @returns This builder, so calls chain.
|
|
1446
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_MODEL `check` reports a blank model: the task packs to a placeholder.
|
|
1447
|
+
*/
|
|
1448
|
+
documentExtraction(model: string, spec: Omit<CaseDocumentExtractionSpec, 'model'>): this;
|
|
1449
|
+
/**
|
|
1450
|
+
* A document-extraction task in the older, flat shape (`data.name` +
|
|
1451
|
+
* `folderPath`, no Designer `context`), written back exactly as saved.
|
|
1452
|
+
*
|
|
1453
|
+
* @remarks
|
|
1454
|
+
* Decompile writes this for such a task, and puts its `data` in the
|
|
1455
|
+
* `preserveCaseJson(...)` payload (`documentExtractionData`): the shape
|
|
1456
|
+
* names no model, folder key or deployment key, so it cannot be lifted to
|
|
1457
|
+
* `.documentExtraction()` without inventing them. Do not write this call by
|
|
1458
|
+
* hand. To edit the task, re-save it in the Case Designer and decompile again,
|
|
1459
|
+
* or replace it with `.documentExtraction(model, spec)`.
|
|
1460
|
+
*
|
|
1461
|
+
* @returns This builder, so calls chain.
|
|
1462
|
+
* @enforcedBy DOCUMENT_EXTRACTION_OLDER_SHAPE `check` warns that the task is carried as saved and a re-save upgrades it.
|
|
1463
|
+
* @enforcedBy DOCUMENT_EXTRACTION_SAVED_DATA compile refuses it without its preserved data, or with `.outputs()`.
|
|
1464
|
+
*/
|
|
1465
|
+
savedDocumentExtraction(): this;
|
|
1466
|
+
/**
|
|
1467
|
+
* A script task: a JavaScript body the engine runs, reading case state
|
|
1468
|
+
* through `vars` (the case variables) and `metadata` (the instance metadata).
|
|
1469
|
+
* The task writes two outputs: what the body returns, as `scriptResponse`
|
|
1470
|
+
* (`=result.response`), and `Error`. Map the return to a case variable with
|
|
1471
|
+
* `.outputs({ scriptResult: '=result.response' })`.
|
|
1472
|
+
*
|
|
1473
|
+
* Pass a TypeScript function and the compiler checks the body like the rest
|
|
1474
|
+
* of the module. It is never called: its body, exactly as written, becomes
|
|
1475
|
+
* the script, and its parameters are renamed to the runtime's `vars` and
|
|
1476
|
+
* `metadata` (take neither, `vars` alone, or both). It may read only what the
|
|
1477
|
+
* engine gives a script (the ES2020 built-ins and `console`), so a module
|
|
1478
|
+
* constant, an import or a library is refused, because in the run it would be
|
|
1479
|
+
* a `ReferenceError`.
|
|
1480
|
+
*
|
|
1481
|
+
* ```ts
|
|
1482
|
+
* .task('Double', (t) => t.script((vars: { amount: number }) => ({ total: vars.amount * 2 }))
|
|
1483
|
+
* .outputs({ scriptResult: '=result.response' }))
|
|
1484
|
+
* ```
|
|
1485
|
+
*
|
|
1486
|
+
* A string is the body as written, unchecked by the compiler.
|
|
1487
|
+
*
|
|
1488
|
+
* @param body - The script, as a function of the case variables and the instance metadata (or of fewer), or its JavaScript text.
|
|
1489
|
+
* @param options - The schemas the Designer keeps on the two outputs, which decompile carries.
|
|
1490
|
+
* @returns This builder, so calls chain.
|
|
1491
|
+
* @enforcedBy SCRIPT_FUNCTION_UNLOWERABLE A function that cannot be a script body is refused at the call.
|
|
1492
|
+
* @enforcedBy SCRIPT_TASK_NO_BODY `check` reports a blank body.
|
|
1493
|
+
* @enforcedBy SCRIPT_BODY_SYNTAX `check` reports a string body that does not parse as JavaScript.
|
|
1494
|
+
*/
|
|
1495
|
+
script<V, M = unknown>(body: ((vars: V, metadata: M) => unknown) | string, options?: CaseScriptOptions): this;
|
|
1375
1496
|
/**
|
|
1376
1497
|
* An HTTP request through Integration Service's generic HTTP connector, the
|
|
1377
1498
|
* Case Designer's HTTP request task. The task writes four outputs, `code`,
|
package/dist/case/case-sdk.js
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case-sdk — a fluent builder for UiPath Case Management plans (`caseplan.json`,
|
|
3
|
+
* schema V32).
|
|
4
|
+
*
|
|
5
|
+
* Like the Flow builder, this constructs a plain description of a case — its
|
|
6
|
+
* stages, the tasks inside them, and the entry/exit *conditions* that drive
|
|
7
|
+
* transitions — which `serialize()` turns into a real `caseplan.json`. A case is
|
|
8
|
+
* a hierarchy (stages → tasks), not a graph: there are **no edges**; flow
|
|
9
|
+
* between stages is expressed entirely through conditions (see `rule()`).
|
|
10
|
+
*
|
|
11
|
+
* This first cut is **reference-mode**: a task points at an already-published
|
|
12
|
+
* process/agent/rpa/workflow by name + folder. (Embedding an inline flow/bpmn
|
|
13
|
+
* body in a task is a later phase.) The builder uses callback closures for
|
|
14
|
+
* nesting, matching the Flow SDK's `.branch(name, cond, b => …)` style — so a
|
|
15
|
+
* `casePlan()` only ever exposes case methods, and each nested builder only its
|
|
16
|
+
* own.
|
|
17
|
+
*
|
|
18
|
+
* `casePlan` (not `case`) is the entry point: `case` is a reserved word.
|
|
19
|
+
*/
|
|
20
|
+
import { lowerScriptFunction } from '../core/script-function.js';
|
|
21
|
+
import { CASE_SCRIPT_RUNTIME } from './script.js';
|
|
1
22
|
import { ACTION_PASSTHROUGH_SETTINGS } from './action-settings.js';
|
|
2
23
|
import { connector as makeConnector, subscriptionFrom, } from '../core/actions.js';
|
|
3
24
|
import { isTriggerDescriptor } from '../core/connectors.js';
|
|
@@ -222,6 +243,9 @@ class TaskBuilder {
|
|
|
222
243
|
_action;
|
|
223
244
|
_connector;
|
|
224
245
|
_external;
|
|
246
|
+
_documentExtraction;
|
|
247
|
+
_documentExtractionSaved;
|
|
248
|
+
_script;
|
|
225
249
|
_http;
|
|
226
250
|
_timer;
|
|
227
251
|
_waitConnector;
|
|
@@ -486,6 +510,88 @@ class TaskBuilder {
|
|
|
486
510
|
this._timer = spec;
|
|
487
511
|
return this;
|
|
488
512
|
}
|
|
513
|
+
/**
|
|
514
|
+
* A document-extraction task: a document run through a deployed IXP model.
|
|
515
|
+
* The task writes two outputs: what the model extracts, as `output`
|
|
516
|
+
* (`=result`), and `error`. Map the extraction to a case variable with
|
|
517
|
+
* `.outputs({ extracted: '=result' })`.
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* t.documentExtraction('invoice-model-0a1b2c3d-ixp', {
|
|
521
|
+
* deployment: 'Invoice Model', folderKey: '<FolderKey>', folder: 'Shared', deploymentKey: '<Key>',
|
|
522
|
+
* file: '=vars.invoice',
|
|
523
|
+
* }).outputs({ extracted: '=result' })
|
|
524
|
+
* ```
|
|
525
|
+
*
|
|
526
|
+
* @param model - The deployment's name (DeploymentName, `<slug>-<hash>-ixp`), from `uip ixp deployments list <project-name>` (the IXP project's Name, not its Title).
|
|
527
|
+
* @param spec - The rest of the deployment (from the tenant) and the document to read.
|
|
528
|
+
* @returns This builder, so calls chain.
|
|
529
|
+
* @enforcedBy DOCUMENT_EXTRACTION_NO_MODEL `check` reports a blank model: the task packs to a placeholder.
|
|
530
|
+
*/
|
|
531
|
+
documentExtraction(model, spec) {
|
|
532
|
+
this.setKind('document-extraction');
|
|
533
|
+
this._documentExtraction = { ...spec, model };
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* A document-extraction task in the older, flat shape (`data.name` +
|
|
538
|
+
* `folderPath`, no Designer `context`), written back exactly as saved.
|
|
539
|
+
*
|
|
540
|
+
* @remarks
|
|
541
|
+
* Decompile writes this for such a task, and puts its `data` in the
|
|
542
|
+
* `preserveCaseJson(...)` payload (`documentExtractionData`): the shape
|
|
543
|
+
* names no model, folder key or deployment key, so it cannot be lifted to
|
|
544
|
+
* `.documentExtraction()` without inventing them. Do not write this call by
|
|
545
|
+
* hand. To edit the task, re-save it in the Case Designer and decompile again,
|
|
546
|
+
* or replace it with `.documentExtraction(model, spec)`.
|
|
547
|
+
*
|
|
548
|
+
* @returns This builder, so calls chain.
|
|
549
|
+
* @enforcedBy DOCUMENT_EXTRACTION_OLDER_SHAPE `check` warns that the task is carried as saved and a re-save upgrades it.
|
|
550
|
+
* @enforcedBy DOCUMENT_EXTRACTION_SAVED_DATA compile refuses it without its preserved data, or with `.outputs()`.
|
|
551
|
+
*/
|
|
552
|
+
savedDocumentExtraction() {
|
|
553
|
+
this.setKind('document-extraction');
|
|
554
|
+
this._documentExtractionSaved = true;
|
|
555
|
+
return this;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* A script task: a JavaScript body the engine runs, reading case state
|
|
559
|
+
* through `vars` (the case variables) and `metadata` (the instance metadata).
|
|
560
|
+
* The task writes two outputs: what the body returns, as `scriptResponse`
|
|
561
|
+
* (`=result.response`), and `Error`. Map the return to a case variable with
|
|
562
|
+
* `.outputs({ scriptResult: '=result.response' })`.
|
|
563
|
+
*
|
|
564
|
+
* Pass a TypeScript function and the compiler checks the body like the rest
|
|
565
|
+
* of the module. It is never called: its body, exactly as written, becomes
|
|
566
|
+
* the script, and its parameters are renamed to the runtime's `vars` and
|
|
567
|
+
* `metadata` (take neither, `vars` alone, or both). It may read only what the
|
|
568
|
+
* engine gives a script (the ES2020 built-ins and `console`), so a module
|
|
569
|
+
* constant, an import or a library is refused, because in the run it would be
|
|
570
|
+
* a `ReferenceError`.
|
|
571
|
+
*
|
|
572
|
+
* ```ts
|
|
573
|
+
* .task('Double', (t) => t.script((vars: { amount: number }) => ({ total: vars.amount * 2 }))
|
|
574
|
+
* .outputs({ scriptResult: '=result.response' }))
|
|
575
|
+
* ```
|
|
576
|
+
*
|
|
577
|
+
* A string is the body as written, unchecked by the compiler.
|
|
578
|
+
*
|
|
579
|
+
* @param body - The script, as a function of the case variables and the instance metadata (or of fewer), or its JavaScript text.
|
|
580
|
+
* @param options - The schemas the Designer keeps on the two outputs, which decompile carries.
|
|
581
|
+
* @returns This builder, so calls chain.
|
|
582
|
+
* @enforcedBy SCRIPT_FUNCTION_UNLOWERABLE A function that cannot be a script body is refused at the call.
|
|
583
|
+
* @enforcedBy SCRIPT_TASK_NO_BODY `check` reports a blank body.
|
|
584
|
+
* @enforcedBy SCRIPT_BODY_SYNTAX `check` reports a string body that does not parse as JavaScript.
|
|
585
|
+
*/
|
|
586
|
+
script(body, options = {}) {
|
|
587
|
+
this.setKind('script');
|
|
588
|
+
const fromFunction = typeof body === 'function';
|
|
589
|
+
const text = fromFunction
|
|
590
|
+
? lowerScriptFunction(body, CASE_SCRIPT_RUNTIME, `task "${this._name}": .script(${body.name || 'function'})`)
|
|
591
|
+
: body;
|
|
592
|
+
this._script = { body: text, fromFunction, ...options };
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
489
595
|
/**
|
|
490
596
|
* An HTTP request through Integration Service's generic HTTP connector, the
|
|
491
597
|
* Case Designer's HTTP request task. The task writes four outputs, `code`,
|
|
@@ -698,8 +804,9 @@ class TaskBuilder {
|
|
|
698
804
|
// more row after them, as `uip maestro case sdd convert` and `case splice`
|
|
699
805
|
// write an SDD row `app_id -> postAppId`.
|
|
700
806
|
const REF_IO = new Set(['process', 'agent', 'rpa', 'api-workflow', 'case-management', 'flow-process', 'function', 'business-rule']);
|
|
701
|
-
//
|
|
702
|
-
|
|
807
|
+
// A document extraction and a script task write their two outputs, an
|
|
808
|
+
// http-request task the activity's four; an extract maps one to a variable.
|
|
809
|
+
const CONNECTOR_OUTPUTS = new Set(['connector', 'wait-for-connector', 'document-extraction', 'script', 'http-request']);
|
|
703
810
|
if (this._inputs && !REF_IO.has(this._kind))
|
|
704
811
|
throw new CompileRefusal('TASK_INPUTS_UNSUPPORTED', `task "${this._name}": .inputs() is only supported on reference-mode tasks (process/agent/rpa/api-workflow/case-management/flow-process/function/business-rule), not "${this._kind}". A connector task takes its inputs in .connector() / .waitForConnector().`);
|
|
705
812
|
// Which rows a kind accepts depends on the row: an extract reads the task's
|
|
@@ -731,6 +838,9 @@ class TaskBuilder {
|
|
|
731
838
|
action: this._action,
|
|
732
839
|
connector: this._connector,
|
|
733
840
|
external: this._external,
|
|
841
|
+
documentExtraction: this._documentExtraction,
|
|
842
|
+
...(this._documentExtractionSaved ? { documentExtractionSaved: true } : {}),
|
|
843
|
+
script: this._script,
|
|
734
844
|
http: this._http,
|
|
735
845
|
timer: this._timer,
|
|
736
846
|
waitConnector: this._waitConnector,
|
package/dist/case/check.js
CHANGED
|
@@ -3,6 +3,9 @@ import { CASE_FORMAT_PROFILE, CASE_SCHEMA_VERSIONS, authoredCaseVersion } from '
|
|
|
3
3
|
import { schemaVersionRefusal } from '../schema-version.js';
|
|
4
4
|
import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, checkConnectorSchema, } from '../core/connector-checks.js';
|
|
5
5
|
import { isConnectorPlaceholder } from './connector-placeholder.js';
|
|
6
|
+
import { documentExtractionLint } from './document-extraction.js';
|
|
7
|
+
import { savedDocumentExtractionLint } from './document-extraction-saved.js';
|
|
8
|
+
import { scriptLint } from './script.js';
|
|
6
9
|
import { httpRequestLint } from './http-request.js';
|
|
7
10
|
import { checkRuleSemantics } from './check-rule-semantics.js';
|
|
8
11
|
import { serialize } from './serialize.js';
|
|
@@ -208,6 +211,25 @@ export function check(built, opts = {}) {
|
|
|
208
211
|
refStage(r, 'case-exit');
|
|
209
212
|
refPlacement(r, 'case-exit', 'case-exit');
|
|
210
213
|
}
|
|
214
|
+
// A document extraction compile writes as authored but cannot run (lint).
|
|
215
|
+
for (const stage of built.stages)
|
|
216
|
+
for (const lane of stage.lanes)
|
|
217
|
+
for (const t of lane)
|
|
218
|
+
if (t.kind === 'document-extraction' && t.documentExtraction)
|
|
219
|
+
for (const f of documentExtractionLint(`Document extraction task "${t.name}"`, t.documentExtraction))
|
|
220
|
+
diags.push({ level: 'error', code: f.code, message: f.message, ...(f.suggestion ? { suggestion: f.suggestion } : {}), where: t.name });
|
|
221
|
+
else if (t.kind === 'document-extraction' && t.documentExtractionSaved) {
|
|
222
|
+
// The older shape, carried as saved: it runs, but nothing in it is editable.
|
|
223
|
+
const f = savedDocumentExtractionLint(`Document extraction task "${t.name}"`);
|
|
224
|
+
diags.push({ level: 'warning', code: f.code, message: f.message, suggestion: f.suggestion, where: t.name });
|
|
225
|
+
}
|
|
226
|
+
// A script body compile writes as authored but a person should fix (lint).
|
|
227
|
+
for (const stage of built.stages)
|
|
228
|
+
for (const lane of stage.lanes)
|
|
229
|
+
for (const t of lane)
|
|
230
|
+
if (t.kind === 'script' && t.script)
|
|
231
|
+
for (const f of scriptLint(`Script task "${t.name}"`, t.script))
|
|
232
|
+
diags.push({ level: 'error', code: f.code, message: f.message, ...(f.suggestion ? { suggestion: f.suggestion } : {}), where: t.name });
|
|
211
233
|
// An HTTP request compile writes as authored but a person should fix (lint;
|
|
212
234
|
// what it cannot write is the serializer's, through collect mode).
|
|
213
235
|
for (const stage of built.stages)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case/decompile-document-extraction — the decompile half of the Case
|
|
3
|
+
* `document-extraction` task (`./document-extraction.ts` holds the shape
|
|
4
|
+
* compile writes). It lifts a saved task's `data` to the `.documentExtraction()`
|
|
5
|
+
* spec that compiles back to it, and throws, naming the field, on anything a
|
|
6
|
+
* recompile would not write back. Decompile-side, so its refusals are plain
|
|
7
|
+
* Errors (FB017 scopes it out by name). The two outputs' schemas are not
|
|
8
|
+
* lifted: compile writes the Designer's, and a saved one that differs is refused.
|
|
9
|
+
*/
|
|
10
|
+
import type { CaseDocumentExtractionSpec } from './case-sdk.js';
|
|
11
|
+
export declare function liftDocumentExtraction(owner: string, data: Record<string, unknown>, binding: (id: string) => Record<string, unknown> | undefined): CaseDocumentExtractionSpec;
|
|
12
|
+
/** One of the task's own output rows, which compile writes itself; a custom row is never one. */
|
|
13
|
+
export declare function isDocumentExtractionOwnOutput(row: {
|
|
14
|
+
custom?: unknown;
|
|
15
|
+
name?: unknown;
|
|
16
|
+
source?: unknown;
|
|
17
|
+
}): boolean;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { DOCUMENT_EXTRACTION_CONTEXT, DOCUMENT_EXTRACTION_NAME, DOCUMENT_EXTRACTION_OUTPUTS, DOCUMENT_EXTRACTION_RESOURCE, DOCUMENT_EXTRACTION_SERVICE_TYPE, DOCUMENT_EXTRACTION_VERSION, } from './document-extraction.js';
|
|
2
|
+
export function liftDocumentExtraction(owner, data, binding) {
|
|
3
|
+
const fail = (why) => {
|
|
4
|
+
throw new Error(`${owner} ${why}`);
|
|
5
|
+
};
|
|
6
|
+
const unknown = Object.keys(data).find((k) => !['name', 'serviceType', 'context', 'inputs', 'outputs', 'version'].includes(k));
|
|
7
|
+
if (unknown)
|
|
8
|
+
fail(`has unsupported data field "${unknown}".`);
|
|
9
|
+
if (data.name !== DOCUMENT_EXTRACTION_NAME)
|
|
10
|
+
fail(`has name ${JSON.stringify(data.name ?? null)}; compile writes "${DOCUMENT_EXTRACTION_NAME}".`);
|
|
11
|
+
if (data.serviceType !== DOCUMENT_EXTRACTION_SERVICE_TYPE)
|
|
12
|
+
fail(`has serviceType ${JSON.stringify(data.serviceType ?? null)}; it is "${DOCUMENT_EXTRACTION_SERVICE_TYPE}".`);
|
|
13
|
+
if (data.version !== DOCUMENT_EXTRACTION_VERSION)
|
|
14
|
+
fail(`has version ${JSON.stringify(data.version ?? null)}; compile writes "${DOCUMENT_EXTRACTION_VERSION}".`);
|
|
15
|
+
const context = Array.isArray(data.context) ? data.context : fail('has no context array.');
|
|
16
|
+
const names = context.map((row) => String(row?.name ?? ''));
|
|
17
|
+
if (names.join(',') !== DOCUMENT_EXTRACTION_CONTEXT.join(','))
|
|
18
|
+
fail(`has context ${JSON.stringify(names)}; compile writes ${DOCUMENT_EXTRACTION_CONTEXT.join(', ')}, in that order.`);
|
|
19
|
+
const value = (name) => context.find((row) => row.name === name)?.value;
|
|
20
|
+
const text = (name) => {
|
|
21
|
+
const v = value(name);
|
|
22
|
+
if (v === null)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (typeof v !== 'string')
|
|
25
|
+
fail(`context ${name} must be text or null.`);
|
|
26
|
+
return v;
|
|
27
|
+
};
|
|
28
|
+
if (value('digitizationMode') !== 'fileUpload')
|
|
29
|
+
fail(`has digitizationMode ${JSON.stringify(value('digitizationMode'))}; compile writes "fileUpload".`);
|
|
30
|
+
// The deployment's title is its binding's default; the binding's key is the solution key.
|
|
31
|
+
const nameRef = text('name') ?? '';
|
|
32
|
+
let deployment = text('modelDisplayName') ?? '';
|
|
33
|
+
if (nameRef !== '') {
|
|
34
|
+
if (!nameRef.startsWith('=bindings.'))
|
|
35
|
+
fail('context name must reference a root binding.');
|
|
36
|
+
const row = binding(nameRef.slice('=bindings.'.length));
|
|
37
|
+
if (!row)
|
|
38
|
+
fail(`context name references missing root binding "${nameRef.slice('=bindings.'.length)}".`);
|
|
39
|
+
if (row.resource !== DOCUMENT_EXTRACTION_RESOURCE)
|
|
40
|
+
fail(`context name references a ${String(row.resource)} binding; it is an ixpDeployment one.`);
|
|
41
|
+
if (row.default !== deployment)
|
|
42
|
+
fail(`binding default ${JSON.stringify(row.default)} is not the modelDisplayName ${JSON.stringify(deployment)}; compile writes one title to both.`);
|
|
43
|
+
if (row.resourceKey !== text('solutionResourceKey'))
|
|
44
|
+
fail('binding resourceKey is not the solutionResourceKey; compile writes one key to both.');
|
|
45
|
+
}
|
|
46
|
+
else if (deployment.trim() !== '')
|
|
47
|
+
fail('has a modelDisplayName but no deployment binding; compile binds every deployment it names.');
|
|
48
|
+
deployment ||= '';
|
|
49
|
+
const inputs = Array.isArray(data.inputs) ? data.inputs : [];
|
|
50
|
+
if (inputs.map((row) => row.name).join(',') !== 'fileRef,pageRange')
|
|
51
|
+
fail(`has inputs ${JSON.stringify(inputs.map((row) => row.name))}; compile writes fileRef and pageRange.`);
|
|
52
|
+
const outputs = (Array.isArray(data.outputs) ? data.outputs : []);
|
|
53
|
+
const own = outputs.filter((o) => o.custom !== true);
|
|
54
|
+
if (own.map((o) => `${String(o.name)}:${String(o.source)}`).join(',') !== DOCUMENT_EXTRACTION_OUTPUTS.map((o) => `${o.name}:${o.source}`).join(','))
|
|
55
|
+
fail(`has outputs ${JSON.stringify(own.map((o) => o.name))}; a document extraction writes output (=result) and error (=Error), in that order.`);
|
|
56
|
+
for (const [i, row] of own.entries()) {
|
|
57
|
+
const schema = DOCUMENT_EXTRACTION_OUTPUTS[i].schema;
|
|
58
|
+
if (JSON.stringify(row._jsonSchema) !== JSON.stringify(schema) || JSON.stringify(row.body) !== JSON.stringify(schema))
|
|
59
|
+
fail(`output "${String(row.name)}" carries a schema compile does not write; it writes the Designer's.`);
|
|
60
|
+
}
|
|
61
|
+
const fileValue = String(inputs[0].value ?? '');
|
|
62
|
+
const pages = String(inputs[1].value ?? '');
|
|
63
|
+
return {
|
|
64
|
+
deployment,
|
|
65
|
+
model: text('modelName') ?? '',
|
|
66
|
+
...(text('folderKey') !== undefined ? { folderKey: text('folderKey') } : {}),
|
|
67
|
+
...(text('folderName') !== undefined ? { folder: text('folderName') } : {}),
|
|
68
|
+
...(text('solutionResourceKey') !== undefined ? { deploymentKey: text('solutionResourceKey') } : {}),
|
|
69
|
+
...(fileValue !== '' ? { file: fileValue } : {}),
|
|
70
|
+
...(pages !== '' ? { pageRange: pages } : {}),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** One of the task's own output rows, which compile writes itself; a custom row is never one. */
|
|
74
|
+
export function isDocumentExtractionOwnOutput(row) {
|
|
75
|
+
return row.custom !== true && DOCUMENT_EXTRACTION_OUTPUTS.some((o) => o.name === row.name && o.source === row.source);
|
|
76
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* case/decompile-script — the decompile half of the Case `script` task
|
|
3
|
+
* (`./script.ts` holds the shape compile writes). It lifts a saved task's
|
|
4
|
+
* `data` to the `.script()` call that compiles back to it, and throws, naming
|
|
5
|
+
* the field, on anything a recompile would not write back. Decompile-side, so
|
|
6
|
+
* its refusals are plain Errors (FB017 scopes it out by name).
|
|
7
|
+
*
|
|
8
|
+
* The body is lifted as a string, exactly as stored: printing it as a typed
|
|
9
|
+
* function, as Flow's decompile can (`printAsFunction`), is a follow-up.
|
|
10
|
+
*/
|
|
11
|
+
import type { CaseScriptOptions } from './case-sdk.js';
|
|
12
|
+
/** What a script task's `data` lifts to: the body and the schemas the Designer kept on its outputs. */
|
|
13
|
+
export interface LiftedScript {
|
|
14
|
+
body: string;
|
|
15
|
+
options: CaseScriptOptions;
|
|
16
|
+
}
|
|
17
|
+
export declare function liftScript(owner: string, data: Record<string, unknown>): LiftedScript;
|
|
18
|
+
/** One of the task's own output rows, which compile writes itself; a custom row is never one. */
|
|
19
|
+
export declare function isScriptOwnOutput(row: {
|
|
20
|
+
custom?: unknown;
|
|
21
|
+
name?: unknown;
|
|
22
|
+
source?: unknown;
|
|
23
|
+
}): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SCRIPT_INPUTS, SCRIPT_OUTPUTS, scriptBody } from './script.js';
|
|
2
|
+
/** The output-row fields compile writes, per output; any other is refused. */
|
|
3
|
+
const OWN_FIELDS = new Map([
|
|
4
|
+
['scriptResponse', new Set(['name', 'type', 'source', 'id', 'var', 'value', 'elementId', 'target', 'originalVar', '_jsonSchema'])],
|
|
5
|
+
['Error', new Set(['name', 'displayName', 'type', 'source', 'id', 'var', 'value', 'elementId', 'target', 'originalVar', '_jsonSchema', 'body'])],
|
|
6
|
+
]);
|
|
7
|
+
export function liftScript(owner, data) {
|
|
8
|
+
const fail = (why) => {
|
|
9
|
+
throw new Error(`${owner} ${why}`);
|
|
10
|
+
};
|
|
11
|
+
const unknown = Object.keys(data).find((k) => !['script', 'inputs', 'outputs'].includes(k));
|
|
12
|
+
if (unknown)
|
|
13
|
+
fail(`has unsupported data field "${unknown}".`);
|
|
14
|
+
if (typeof data.script !== 'string')
|
|
15
|
+
fail('has no script body.');
|
|
16
|
+
const inputs = Array.isArray(data.inputs) ? data.inputs : [];
|
|
17
|
+
if (JSON.stringify(inputs) !== JSON.stringify(SCRIPT_INPUTS))
|
|
18
|
+
fail(`has inputs ${JSON.stringify(inputs)}; a script task's are exactly vars = "=vars" and metadata = "=metadata", which compile writes.`);
|
|
19
|
+
const outputs = (Array.isArray(data.outputs) ? data.outputs : []);
|
|
20
|
+
const own = outputs.filter((o) => o.custom !== true);
|
|
21
|
+
if (own.map((o) => `${String(o.name)}:${String(o.source)}`).join(',') !== SCRIPT_OUTPUTS.map((o) => `${o.name}:${o.source}`).join(','))
|
|
22
|
+
fail(`has outputs ${JSON.stringify(own.map((o) => o.name))}; a script task writes scriptResponse (=result.response) and Error (=Error), in that order.`);
|
|
23
|
+
const options = {};
|
|
24
|
+
for (const row of own) {
|
|
25
|
+
const name = String(row.name);
|
|
26
|
+
const fields = OWN_FIELDS.get(name) ?? new Set();
|
|
27
|
+
const odd = Object.keys(row).find((k) => !fields.has(k));
|
|
28
|
+
if (odd)
|
|
29
|
+
fail(`output "${name}" has field "${odd}", which compile does not write.`);
|
|
30
|
+
if (row.type !== 'jsonSchema')
|
|
31
|
+
fail(`output "${name}" has type ${JSON.stringify(row.type)}; it is "jsonSchema".`);
|
|
32
|
+
const schema = row._jsonSchema;
|
|
33
|
+
if (schema !== undefined && (typeof schema !== 'object' || schema === null || Array.isArray(schema)))
|
|
34
|
+
fail(`output "${name}" has a _jsonSchema that is not an object.`);
|
|
35
|
+
if (name === 'scriptResponse' && schema !== undefined)
|
|
36
|
+
options.responseSchema = schema;
|
|
37
|
+
if (name === 'Error') {
|
|
38
|
+
// Compile writes an Error schema as the Designer keeps it: `_jsonSchema`, `body` and `displayName`, together.
|
|
39
|
+
const carried = [schema !== undefined, row.body !== undefined, row.displayName === 'Error'];
|
|
40
|
+
if (carried.some(Boolean) && !carried.every(Boolean))
|
|
41
|
+
fail('output "Error" carries part of a schema; compile writes _jsonSchema, body and displayName together.');
|
|
42
|
+
if (schema !== undefined && JSON.stringify(schema) !== JSON.stringify(row.body))
|
|
43
|
+
fail('output "Error" has a body that is not its _jsonSchema; compile writes the one schema to both.');
|
|
44
|
+
if (schema !== undefined)
|
|
45
|
+
options.errorSchema = schema;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { body: scriptBody(String(data.script)), options };
|
|
49
|
+
}
|
|
50
|
+
/** One of the task's own output rows, which compile writes itself; a custom row is never one. */
|
|
51
|
+
export function isScriptOwnOutput(row) {
|
|
52
|
+
return row.custom !== true && SCRIPT_OUTPUTS.some((o) => o.name === row.name && o.source === row.source);
|
|
53
|
+
}
|
package/dist/case/decompile.d.ts
CHANGED
|
@@ -302,6 +302,12 @@ type Preservation = {
|
|
|
302
302
|
app?: boolean;
|
|
303
303
|
saved?: Record<string, unknown>;
|
|
304
304
|
}>;
|
|
305
|
+
documentExtractionData?: Array<{
|
|
306
|
+
stage: string;
|
|
307
|
+
lane: number;
|
|
308
|
+
task: string;
|
|
309
|
+
data: Record<string, unknown>;
|
|
310
|
+
}>;
|
|
305
311
|
identities?: unknown;
|
|
306
312
|
bindings?: Record<string, unknown>[];
|
|
307
313
|
resourceWires?: PreservedResourceWire[];
|