@uipath/maestro-builder-sdk 6.117.4 → 6.118.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,9 +10,14 @@
10
10
  import { toExpr } from '../../../core/expr.js';
11
11
  import { jsonClone } from '../../../core/json-clone.js';
12
12
  import { declareKeys } from '../../../core/option-keys.js';
13
+ import { stableId } from '../../../core/stable-id.js';
14
+ import { buildDefaultSchemaDocument, buildScaffoldConfig } from './idp-processor.js';
15
+ import { checkExtractRead, isLegacyExtractOutputs } from './extract-output.js';
13
16
  export const DOCUMENT_DIAGNOSTICS = {
14
17
  DOC_NO_FILEREF: { severity: 'error', summary: 'no fileRef, so nothing to classify or extract from' },
15
18
  EXTRACT_SCHEMA_SHAPE: { severity: 'error', summary: 'a Dynamic Extract schema that is not an object' },
19
+ EXTRACT_READ_NOT_OUTPUT: { severity: 'error', summary: 'an Extract document step read outside output' },
20
+ EXTRACT_READ_UNKNOWN_FIELD: { severity: 'error', summary: 'an Extract document step read of a field the processed document does not have' },
16
21
  };
17
22
  function checkFileRef(inputs, verb, ctx) {
18
23
  const fr = inputs.fileRef;
@@ -42,7 +47,7 @@ function liftPageRange(node) {
42
47
  * Absent: undefined. Present but not a plain object (an expression such as
43
48
  * `=js:vars.taxonomy`): reported as lossy, since the option takes an object only.
44
49
  */
45
- function liftObjectInput(node, key, ctx) {
50
+ function liftObjectInput(node, key, ctx, loss = classifyLoss) {
46
51
  const value = node.inputs?.[key];
47
52
  if (value === undefined)
48
53
  return undefined;
@@ -50,7 +55,7 @@ function liftObjectInput(node, key, ctx) {
50
55
  // sourceText is defined for a string and for an expression envelope.
51
56
  const text = ctx.sourceText(raw);
52
57
  if (text !== undefined || raw === null || typeof raw !== 'object' || Array.isArray(raw)) {
53
- ctx.lossy(classifyLoss(ctx, key, `is ${JSON.stringify(text ?? raw)}, not an object`));
58
+ ctx.lossy(loss(ctx, key, `is ${JSON.stringify(text ?? raw)}, not an object`));
54
59
  return undefined;
55
60
  }
56
61
  const fallback = ctx.definition()?.inputDefaults?.[key];
@@ -60,6 +65,10 @@ function classifyLoss(ctx, key, what) {
60
65
  return `classify step ${JSON.stringify(ctx.nodeId)}: ${key} ${what}, which documentClassify() cannot express, `
61
66
  + `so compile writes the definition's default instead.`;
62
67
  }
68
+ function extractLoss(ctx, key, what) {
69
+ return `extract step ${JSON.stringify(ctx.nodeId)}: ${key} ${what}, which dynamicExtract() cannot express, `
70
+ + `so compile writes the definition's default instead.`;
71
+ }
63
72
  const SCHEMA_KEYS = new Set(['generalInstructions', 'classes']);
64
73
  const CLASS_KEYS = new Set(['id', 'name', 'instructions']);
65
74
  const optionalString = (v) => v === undefined || typeof v === 'string';
@@ -99,7 +108,62 @@ function liftClassificationSchema(node, ctx) {
99
108
  }
100
109
  /** Every key of each factory's options (builder-sdk#1990); `tsc` holds each list to its type. */
101
110
  const CLASSIFY_OPTIONS = { inputs: declareKeys({ fileRef: true, pageRange: true, splitPages: true, modelConfig: true, classificationSchema: true }) };
102
- const DYNAMIC_EXTRACT_OPTIONS = { inputs: declareKeys({ fileRef: true, model: true, schema: true, pageRange: true, modelConfig: true }) };
111
+ const DYNAMIC_EXTRACT_OPTIONS = {
112
+ inputs: declareKeys({
113
+ fileRef: true, model: true, schema: true, pageRange: true, modelConfig: true,
114
+ processorKey: true, processorName: true, processorReadOnly: true, processorFolderPath: true,
115
+ }),
116
+ };
117
+ const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
118
+ /**
119
+ * The schema as the node stores it: a `{ prompt, outputSchema }` document with
120
+ * no `config` gets the one `nodes schema set` scaffolds from the model
121
+ * settings. Without it, packaging does not read the document as the Schema
122
+ * Editor's (`config`, `prompt` and `outputSchema` are what mark it) and the
123
+ * processor is built with no fields and no prompt. Any other value is written
124
+ * as given (`check` reports a non-object).
125
+ */
126
+ function withConfig(schema, modelConfig) {
127
+ if (!isObject(schema) || schema.config !== undefined || typeof schema.prompt !== 'string' || !isObject(schema.outputSchema))
128
+ return schema;
129
+ return { config: buildScaffoldConfig(modelConfig), ...schema };
130
+ }
131
+ /** The lifted schema without a `config` that is only the scaffold {@link withConfig} adds back. */
132
+ function withoutScaffoldConfig(schema, modelConfig) {
133
+ if (!isObject(schema) || JSON.stringify(schema.config) !== JSON.stringify(buildScaffoldConfig(modelConfig)))
134
+ return schema;
135
+ const { config: _scaffold, ...rest } = schema;
136
+ return rest;
137
+ }
138
+ /** A non-empty string input of the node, as the lift keeps it. */
139
+ function liftText(inputs, key, ctx) {
140
+ const v = ctx.plainValue(inputs[key]);
141
+ return typeof v === 'string' && v.trim() !== '' ? v : undefined;
142
+ }
143
+ /**
144
+ * The processor key compile mints for a step that names none: one per node,
145
+ * derived from the flow and the node, so a recompile keeps it (and the
146
+ * processor's resource file keeps matching it). `uip maestro flow nodes create`
147
+ * mints a random one instead; either is a key no other node holds.
148
+ */
149
+ function mintedProcessorKey(flowId, nodeId) {
150
+ return stableId(`${flowId}:${nodeId}:processorKey`);
151
+ }
152
+ /** `model`, as the lift reads it back: only a real deployment identity (both names non-empty). */
153
+ function liftModel(inputs, ctx) {
154
+ const nested = (inputs.model !== null && typeof inputs.model === 'object' ? inputs.model : {});
155
+ const pick = (key) => liftText(inputs, key, ctx)
156
+ ?? (typeof nested[key] === 'string' && nested[key].trim() !== '' ? nested[key] : undefined);
157
+ const modelName = pick('modelName');
158
+ const folderKey = pick('folderKey');
159
+ if (modelName === undefined || folderKey === undefined)
160
+ return undefined;
161
+ const extra = (key) => {
162
+ const v = liftText(inputs, key, ctx);
163
+ return v !== undefined ? { [key]: v } : {};
164
+ };
165
+ return { modelName, folderKey, ...extra('projectId'), ...extra('projectName'), ...extra('folderName'), ...extra('versionTag') };
166
+ }
103
167
  export const documentClassifyNodeType = {
104
168
  kind: 'documentClassify', typeName: 'uipath.document.classify', version: '1.0', factory: 'documentClassify',
105
169
  optionKeys: CLASSIFY_OPTIONS,
@@ -159,30 +223,52 @@ export const dynamicExtractNodeType = {
159
223
  serialize: ({ inputs }, ctx) => {
160
224
  const d = defaults('uipath.ixp.extract-document-builder', '1.0.0', ctx);
161
225
  const m = inputs.model;
226
+ const modelConfig = inputs.modelConfig !== undefined
227
+ ? { ...(d.modelConfig ?? {}), ...inputs.modelConfig }
228
+ : undefined;
229
+ // The processor (#1984). A read-only mirror and a processor published to the
230
+ // tenant name one the node does not author, so nothing is minted for them, as
231
+ // `nodes create` / `nodes provision` mint nothing for them.
232
+ const readOnly = inputs.processorReadOnly === true;
233
+ const folderPath = inputs.processorFolderPath !== undefined && inputs.processorFolderPath.trim() !== ''
234
+ ? inputs.processorFolderPath : undefined;
235
+ const processorKey = inputs.processorKey !== undefined && inputs.processorKey !== ''
236
+ ? inputs.processorKey
237
+ : readOnly || folderPath !== undefined ? undefined : mintedProcessorKey(ctx.flowId, ctx.nodeId);
162
238
  return {
163
239
  inputs: {
164
240
  ...d,
165
- // The deployment identity Studio Web's panel destructures — both the
166
- // nested `model` object and the flat mirrors the definition declares.
167
- model: { modelName: m.modelName, folderKey: m.folderKey },
168
- modelName: m.modelName,
169
- folderKey: m.folderKey,
170
- ...(m.projectId !== undefined ? { projectId: m.projectId } : {}),
171
- ...(m.projectName !== undefined ? { projectName: m.projectName } : {}),
172
- ...(m.folderName !== undefined ? { folderName: m.folderName } : {}),
173
- ...(m.versionTag !== undefined ? { versionTag: m.versionTag } : {}),
241
+ // A published deployment's identity, written only when the author still
242
+ // passes one (deprecated): the node does not read it.
243
+ ...(m !== undefined
244
+ ? {
245
+ model: { modelName: m.modelName, folderKey: m.folderKey },
246
+ modelName: m.modelName,
247
+ folderKey: m.folderKey,
248
+ ...(m.projectId !== undefined ? { projectId: m.projectId } : {}),
249
+ ...(m.projectName !== undefined ? { projectName: m.projectName } : {}),
250
+ ...(m.folderName !== undefined ? { folderName: m.folderName } : {}),
251
+ ...(m.versionTag !== undefined ? { versionTag: m.versionTag } : {}),
252
+ }
253
+ : {}),
174
254
  // A `uipath.ixp.*` fileRef must stay a PLAIN `=js:` string — the
175
255
  // platform reads it unwrapped (see migrate's UNWRAPPED_INPUTS).
176
256
  fileRef: ctx.render(toExpr(inputs.fileRef)),
177
257
  ...(inputs.pageRange !== undefined ? { pageRange: inputs.pageRange } : {}),
178
- ...(inputs.modelConfig !== undefined
179
- ? { modelConfig: { ...(d.modelConfig ?? {}), ...inputs.modelConfig } }
180
- : {}),
181
- ...(inputs.schema !== undefined ? { schemaDocument: inputs.schema } : {}),
258
+ ...(modelConfig !== undefined ? { modelConfig } : {}),
259
+ // No schema: the empty taxonomy `nodes create` seeds, so the node opens in
260
+ // the Schema Editor and its processor has a document to hold.
261
+ schemaDocument: inputs.schema !== undefined
262
+ ? withConfig(inputs.schema, modelConfig ?? d.modelConfig)
263
+ : buildDefaultSchemaDocument(modelConfig ?? d.modelConfig),
182
264
  // The definition's model declares `source: true`: the platform mints a
183
265
  // stable storage slot per instance; omit it and the node validates then
184
266
  // faults. Deterministic, like every other minted identity here.
185
267
  source: ctx.mint('source'),
268
+ ...(processorKey !== undefined ? { processorKey } : {}),
269
+ ...(inputs.processorName !== undefined && inputs.processorName.trim() !== '' ? { processorName: inputs.processorName } : {}),
270
+ ...(readOnly ? { processorReadOnly: true } : {}),
271
+ ...(folderPath !== undefined ? { processorFolderPath: folderPath } : {}),
186
272
  },
187
273
  // IxP instances must NOT carry the manifest's model block — the slim
188
274
  // { type, serviceType } lives only in definitions[] (product validate
@@ -192,14 +278,34 @@ export const dynamicExtractNodeType = {
192
278
  };
193
279
  },
194
280
  deserialize: (node, ctx) => {
281
+ const inputs = (node.inputs ?? {});
195
282
  const pageRange = liftPageRange(node);
196
- const schema = node.inputs?.schemaDocument;
283
+ const modelConfig = liftObjectInput(node, 'modelConfig', ctx, extractLoss);
284
+ const model = liftModel(inputs, ctx);
285
+ // The seeded empty taxonomy is what compile writes for no schema, so it is
286
+ // not printed; anything else is the author's.
287
+ const rawSchema = ctx.plainValue(inputs.schemaDocument);
288
+ const seeded = buildDefaultSchemaDocument(inputs.modelConfig);
289
+ const schema = rawSchema !== undefined && JSON.stringify(rawSchema) !== JSON.stringify(seeded)
290
+ ? withoutScaffoldConfig(rawSchema, inputs.modelConfig) : undefined;
291
+ // The processor a node already names is printed, so a recompile keeps it;
292
+ // only the key compile itself would mint for this node is left out.
293
+ const key = liftText(inputs, 'processorKey', ctx);
294
+ const keepKey = key !== undefined && !(ctx.stepName(ctx.nodeId) === ctx.nodeId && key === mintedProcessorKey(ctx.flowId, ctx.nodeId));
295
+ const processorName = liftText(inputs, 'processorName', ctx);
296
+ const processorFolderPath = liftText(inputs, 'processorFolderPath', ctx);
197
297
  return {
198
298
  kind: 'dynamicExtract',
199
299
  inputs: {
200
300
  fileRef: liftFileRef(node, ctx),
201
- ...(schema !== undefined ? { schema: schema } : {}),
301
+ ...(schema !== undefined ? { schema } : {}),
202
302
  ...(pageRange !== undefined ? { pageRange } : {}),
303
+ ...(modelConfig !== undefined ? { modelConfig } : {}),
304
+ ...(model !== undefined ? { model } : {}),
305
+ ...(keepKey ? { processorKey: key } : {}),
306
+ ...(processorName !== undefined ? { processorName } : {}),
307
+ ...(ctx.plainValue(inputs.processorReadOnly) === true ? { processorReadOnly: true } : {}),
308
+ ...(processorFolderPath !== undefined ? { processorFolderPath } : {}),
203
309
  },
204
310
  };
205
311
  },
@@ -209,6 +315,12 @@ export const dynamicExtractNodeType = {
209
315
  ['fileRef', ctx.value(inputs.fileRef)],
210
316
  ['schema', inputs.schema !== undefined ? ctx.json(inputs.schema) : undefined],
211
317
  ['pageRange', inputs.pageRange !== undefined ? ctx.string(inputs.pageRange) : undefined],
318
+ ['modelConfig', inputs.modelConfig !== undefined ? ctx.json(inputs.modelConfig) : undefined],
319
+ ['model', inputs.model !== undefined ? ctx.json(inputs.model) : undefined],
320
+ ['processorKey', inputs.processorKey !== undefined ? ctx.string(inputs.processorKey) : undefined],
321
+ ['processorName', inputs.processorName !== undefined ? ctx.string(inputs.processorName) : undefined],
322
+ ['processorReadOnly', inputs.processorReadOnly === true ? 'true' : undefined],
323
+ ['processorFolderPath', inputs.processorFolderPath !== undefined ? ctx.string(inputs.processorFolderPath) : undefined],
212
324
  ],
213
325
  }),
214
326
  check: ({ inputs }, ctx) => {
@@ -219,5 +331,8 @@ export const dynamicExtractNodeType = {
219
331
  },
220
332
  // check collected no expressions for this kind before the port; unchanged by it.
221
333
  expressions: () => [],
222
- output: () => ({ kind: 'opaque' }),
334
+ // The processed document's fixed keys (`extract-output.ts`).
335
+ output: () => ({ kind: 'reader', read: checkExtractRead }),
336
+ // A file an SDK before #1987 compiled declares ExtractionResult; merge writes the processed document.
337
+ supersededOutputs: isLegacyExtractOutputs,
223
338
  };
@@ -58,12 +58,17 @@ export interface DynamicExtractInputs {
58
58
  /** The document to extract from — a file reference. */
59
59
  fileRef: string | Expr;
60
60
  /**
61
- * The IXP model deployment the extraction runs against. Dynamic Extract
62
- * authors its SCHEMA inline, but execution still needs a model: Studio Web's
63
- * panel destructures `modelName` and `folderKey`, and the platform rejects an
64
- * instance without them.
61
+ * A published IXP deployment's identity. Optional, and not needed: the node
62
+ * runs the inline {@link DynamicExtractInputs.schema} through its IDP processor
63
+ * ({@link DynamicExtractInputs.processorKey}), and neither the platform nor
64
+ * Studio Web reads these fields for this node — `uip maestro flow nodes create`
65
+ * leaves them blank, and `uip maestro flow validate` exempts this node type from
66
+ * the deployed-model rule the published-model Extract node has.
67
+ *
68
+ * @deprecated Omit it. Accepted, and written to the node as before, so an
69
+ * existing flow compiles unchanged.
65
70
  */
66
- model: {
71
+ model?: {
67
72
  /** The deployment's model name, e.g. `'invoiceixp-cef0d447-ixp'`. */
68
73
  modelName: string;
69
74
  /** Folder key (GUID) the deployment lives in. */
@@ -78,16 +83,51 @@ export interface DynamicExtractInputs {
78
83
  versionTag?: string;
79
84
  };
80
85
  /**
81
- * The extraction schema (the node's inline taxonomy): a JSON-schema-shaped
82
- * document describing the fields to extract. This is the Dynamic Extract
83
- * node's defining input — authored inline rather than referencing a deployed
84
- * IXP project (use {@link ixpExtract} for those).
86
+ * The extraction schema (the node's inline taxonomy), emitted as the node's
87
+ * `schemaDocument`: `{ prompt, outputSchema }`, the shape
88
+ * `uip maestro flow nodes schema set` takes. Omit it for the empty taxonomy
89
+ * `nodes create` seeds (no field groups, the six default field types).
90
+ * Authored inline rather than referencing a deployed IXP project (use
91
+ * {@link ixpExtract} for those).
85
92
  */
86
93
  schema?: Record<string, unknown>;
87
94
  /** Page range to extract, e.g. `'1-3'`. Omit for the whole document. */
88
95
  pageRange?: string;
89
96
  /** Model configuration overrides; omit for the platform defaults. */
90
97
  modelConfig?: Record<string, unknown>;
98
+ /**
99
+ * The IDP processor the node extracts through — the solution resource that
100
+ * stores this node's taxonomy and model settings. Omit it: compile mints one
101
+ * per node (stable across recompiles: it is derived from the flow and the
102
+ * step), and inside a solution writes its resource file, as
103
+ * `uip maestro flow nodes create` does. Decompile writes the key a node
104
+ * already has, so a recompile keeps pointing at the same processor.
105
+ *
106
+ * Two steps must not name the same key: a processor holds one extraction,
107
+ * so `uip solution pack` refuses two nodes that author one.
108
+ */
109
+ processorKey?: string;
110
+ /**
111
+ * The processor's display name. Omit it: inside a solution, compile names a
112
+ * new processor after the step's label (`Extract invoice`, else
113
+ * `Extract invoice_1` when the solution already has one) and takes an existing
114
+ * processor's name from its resource file, which owns it.
115
+ */
116
+ processorName?: string;
117
+ /**
118
+ * The node only READS a processor another node defines (a mirror): compile
119
+ * mints no key and writes no resource file for it. Set with
120
+ * {@link DynamicExtractInputs.processorKey}, the authoring node's key.
121
+ */
122
+ processorReadOnly?: boolean;
123
+ /**
124
+ * The folder of a processor published to the tenant rather than one in the
125
+ * solution, e.g. `'Shared/Invoices'`. Set with
126
+ * {@link DynamicExtractInputs.processorKey} and
127
+ * {@link DynamicExtractInputs.processorName}; compile writes no resource file
128
+ * for it.
129
+ */
130
+ processorFolderPath?: string;
91
131
  }
92
132
  /**
93
133
  * Split an extractor's node type into the two GUIDs its tail packs.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.117.4",
3
+ "version": "6.118.1",
4
4
  "description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://docs.uipath.com/maestro",
@@ -124,5 +124,5 @@
124
124
  "@types/node": "^22.7.0",
125
125
  "esbuild": "^0.28.1"
126
126
  },
127
- "gitref": "1ad604ec9dcc3d513d4a32560f4fb268ba42bb09"
127
+ "gitref": "0c0b4c5db91985dd7604ca295f9b32825d7a28bd"
128
128
  }