@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.
@@ -4,6 +4,7 @@ import { type ConnectorDescriptor, type TriggerDescriptor } from '../core/connec
4
4
  import type { CarriedConnectorField } from '../core/carried-connector-fields.js';
5
5
  export type { CarriedConnectorField, CarriedFieldLocation } from '../core/carried-connector-fields.js';
6
6
  export { preserveCaseJson } from './preserve.js';
7
+ export type { PreservedDocumentExtractionData } from './document-extraction-saved.js';
7
8
  export type { CaseJsonPreservation, PreservedActionDataFields, PreservedCaseNode, PreservedConnectorConfiguration, PreservedMetadataKey, PreservedSubscriptionFilter, PreservedTaskFields, PreservedVariableLane } from './preserve.js';
8
9
  export { CaseBuildError } from './case-expr-check.js';
9
10
  export type { CaseLocatedDiagnostic } from './case-expr-check.js';
@@ -422,7 +423,7 @@ export interface BuiltCaseExitCondition {
422
423
  marksCaseComplete?: boolean;
423
424
  rules: CaseRule[][];
424
425
  }
425
- 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' | 'script' | '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';
426
427
  /**
427
428
  * Task kinds that the Case schema permits as unresolved skeletons: the
428
429
  * published-resource kinds, `action` (a human task whose Action App or form is
@@ -582,6 +583,52 @@ export interface HttpRequestConnector {
582
583
  /** The symbolic folder binding of that connection. */
583
584
  folder: string;
584
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
+ }
585
632
  /**
586
633
  * The external agent's or automation's `executionType`, as Integration Service
587
634
  * reports it for the connector object.
@@ -866,6 +913,10 @@ export interface BuiltTask {
866
913
  connector?: ConnectorSpecData;
867
914
  /** Descriptor-resolved external agent/workflow configuration. */
868
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;
869
920
  /** script task: the body. */
870
921
  script?: CaseScriptSpec;
871
922
  /** http-request task: the request. */
@@ -1127,6 +1178,8 @@ declare class TaskBuilder {
1127
1178
  private _action?;
1128
1179
  private _connector?;
1129
1180
  private _external?;
1181
+ private _documentExtraction?;
1182
+ private _documentExtractionSaved?;
1130
1183
  private _script?;
1131
1184
  private _http?;
1132
1185
  private _timer?;
@@ -1374,6 +1427,42 @@ declare class TaskBuilder {
1374
1427
  * @returns This builder, so calls chain.
1375
1428
  */
1376
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;
1377
1466
  /**
1378
1467
  * A script task: a JavaScript body the engine runs, reading case state
1379
1468
  * through `vars` (the case variables) and `metadata` (the instance metadata).
@@ -243,6 +243,8 @@ class TaskBuilder {
243
243
  _action;
244
244
  _connector;
245
245
  _external;
246
+ _documentExtraction;
247
+ _documentExtractionSaved;
246
248
  _script;
247
249
  _http;
248
250
  _timer;
@@ -508,6 +510,50 @@ class TaskBuilder {
508
510
  this._timer = spec;
509
511
  return this;
510
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
+ }
511
557
  /**
512
558
  * A script task: a JavaScript body the engine runs, reading case state
513
559
  * through `vars` (the case variables) and `metadata` (the instance metadata).
@@ -758,9 +804,9 @@ class TaskBuilder {
758
804
  // more row after them, as `uip maestro case sdd convert` and `case splice`
759
805
  // write an SDD row `app_id -> postAppId`.
760
806
  const REF_IO = new Set(['process', 'agent', 'rpa', 'api-workflow', 'case-management', 'flow-process', 'function', 'business-rule']);
761
- // A script task writes its two outputs, an http-request task the activity's
762
- // four; an extract maps one to a variable.
763
- const CONNECTOR_OUTPUTS = new Set(['connector', 'wait-for-connector', 'script', 'http-request']);
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']);
764
810
  if (this._inputs && !REF_IO.has(this._kind))
765
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().`);
766
812
  // Which rows a kind accepts depends on the row: an extract reads the task's
@@ -792,6 +838,8 @@ class TaskBuilder {
792
838
  action: this._action,
793
839
  connector: this._connector,
794
840
  external: this._external,
841
+ documentExtraction: this._documentExtraction,
842
+ ...(this._documentExtractionSaved ? { documentExtractionSaved: true } : {}),
795
843
  script: this._script,
796
844
  http: this._http,
797
845
  timer: this._timer,
@@ -3,6 +3,8 @@ 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';
6
8
  import { scriptLint } from './script.js';
7
9
  import { httpRequestLint } from './http-request.js';
8
10
  import { checkRuleSemantics } from './check-rule-semantics.js';
@@ -209,6 +211,18 @@ export function check(built, opts = {}) {
209
211
  refStage(r, 'case-exit');
210
212
  refPlacement(r, 'case-exit', 'case-exit');
211
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
+ }
212
226
  // A script body compile writes as authored but a person should fix (lint).
213
227
  for (const stage of built.stages)
214
228
  for (const lane of stage.lanes)
@@ -365,10 +379,13 @@ function checkSla(sla, where, diags) {
365
379
  });
366
380
  if (e.notify.length === 0)
367
381
  diags.push({ level: 'warning', code: 'ESCALATION_NO_RECIPIENTS', message: `${where}: an escalation notifies no one (empty notify).`, where });
368
- // An `<UNRESOLVED: …>` target passes `validate` but names no one, so the
369
- // escalation notifies nobody until the id is filled in.
382
+ // An `<UNRESOLVED…>` target passes `validate` but names no one, so the
383
+ // escalation notifies nobody until the id is filled in. The test is the one
384
+ // CASE_MGMT_ESCALATION_RECIPIENT_LITERAL skips on (plan-check/rules/sla.ts),
385
+ // so the two split every non-GUID target with no gap: `<UNRESOLVED>`,
386
+ // `<UNRESOLVED: …>` and a marker mid-string all land here.
370
387
  for (const r of e.notify)
371
- if (/^<UNRESOLVED:/.test(r.target.trim()))
388
+ if (r.target.includes('<UNRESOLVED'))
372
389
  diags.push({
373
390
  level: 'warning',
374
391
  code: 'ESCALATION_RECIPIENT_UNRESOLVED',
@@ -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
+ }
@@ -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[];
@@ -3,6 +3,8 @@ 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';
6
8
  import { isScriptOwnOutput, liftScript } from './decompile-script.js';
7
9
  import { isHttpRequestOwnOutput, liftHttpRequest } from './decompile-http-request.js';
8
10
  import { savedHttpRequestMetadata } from './http-request.js';
@@ -1095,6 +1097,15 @@ function emitTaskKind(task, refs, library) {
1095
1097
  }
1096
1098
  if (kind === 'execute-connector-activity')
1097
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
+ }
1098
1109
  if (kind === 'script') {
1099
1110
  const lifted = liftScript(`script task "${task.displayName ?? task.id ?? '?'}"`, (data ?? {}));
1100
1111
  const options = opts([
@@ -1337,6 +1348,15 @@ function taskOutputRows(task) {
1337
1348
  plan = customOnly(actionFormOutputs(task));
1338
1349
  else if (kind === 'wait-for-timer')
1339
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
+ };
1340
1360
  // A script task writes its two rows itself; one it maps to a case variable is lifted too.
1341
1361
  else if (kind === 'script')
1342
1362
  plan = {
@@ -2313,6 +2333,7 @@ export function collectPreservation(plan) {
2313
2333
  const httpRequestMetadata = [];
2314
2334
  const omitTaskElementIds = [];
2315
2335
  const actionDataFields = [];
2336
+ const documentExtractionData = [];
2316
2337
  const omitStagePositions = [];
2317
2338
  const stageDataFields = [];
2318
2339
  const generation = schemaGeneration(plan);
@@ -2343,6 +2364,9 @@ export function collectPreservation(plan) {
2343
2364
  // The Designer's half of a connector task's configuration, which compile
2344
2365
  // does not rebuild: its saved field list is what the next decompile
2345
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 });
2346
2370
  // An action task's Designer-owned data fields (preserve.ts).
2347
2371
  if (task.type === 'action' && task.data && typeof task.data === 'object') {
2348
2372
  const carried = Object.fromEntries(Object.entries(task.data).filter(([name]) => PRESERVED_ACTION_DATA_KEYS.has(name)));
@@ -2389,6 +2413,8 @@ export function collectPreservation(plan) {
2389
2413
  preservation.omitTaskElementIds = omitTaskElementIds;
2390
2414
  if (actionDataFields.length)
2391
2415
  preservation.actionDataFields = actionDataFields;
2416
+ if (documentExtractionData.length)
2417
+ preservation.documentExtractionData = documentExtractionData;
2392
2418
  if (omitStagePositions.length)
2393
2419
  preservation.omitStagePositions = omitStagePositions;
2394
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;