@uipath/maestro-builder-sdk 6.117.3 → 6.118.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.
@@ -10,6 +10,8 @@
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';
13
15
  export const DOCUMENT_DIAGNOSTICS = {
14
16
  DOC_NO_FILEREF: { severity: 'error', summary: 'no fileRef, so nothing to classify or extract from' },
15
17
  EXTRACT_SCHEMA_SHAPE: { severity: 'error', summary: 'a Dynamic Extract schema that is not an object' },
@@ -42,7 +44,7 @@ function liftPageRange(node) {
42
44
  * Absent: undefined. Present but not a plain object (an expression such as
43
45
  * `=js:vars.taxonomy`): reported as lossy, since the option takes an object only.
44
46
  */
45
- function liftObjectInput(node, key, ctx) {
47
+ function liftObjectInput(node, key, ctx, loss = classifyLoss) {
46
48
  const value = node.inputs?.[key];
47
49
  if (value === undefined)
48
50
  return undefined;
@@ -50,7 +52,7 @@ function liftObjectInput(node, key, ctx) {
50
52
  // sourceText is defined for a string and for an expression envelope.
51
53
  const text = ctx.sourceText(raw);
52
54
  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`));
55
+ ctx.lossy(loss(ctx, key, `is ${JSON.stringify(text ?? raw)}, not an object`));
54
56
  return undefined;
55
57
  }
56
58
  const fallback = ctx.definition()?.inputDefaults?.[key];
@@ -60,6 +62,10 @@ function classifyLoss(ctx, key, what) {
60
62
  return `classify step ${JSON.stringify(ctx.nodeId)}: ${key} ${what}, which documentClassify() cannot express, `
61
63
  + `so compile writes the definition's default instead.`;
62
64
  }
65
+ function extractLoss(ctx, key, what) {
66
+ return `extract step ${JSON.stringify(ctx.nodeId)}: ${key} ${what}, which dynamicExtract() cannot express, `
67
+ + `so compile writes the definition's default instead.`;
68
+ }
63
69
  const SCHEMA_KEYS = new Set(['generalInstructions', 'classes']);
64
70
  const CLASS_KEYS = new Set(['id', 'name', 'instructions']);
65
71
  const optionalString = (v) => v === undefined || typeof v === 'string';
@@ -99,7 +105,62 @@ function liftClassificationSchema(node, ctx) {
99
105
  }
100
106
  /** Every key of each factory's options (builder-sdk#1990); `tsc` holds each list to its type. */
101
107
  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 }) };
108
+ const DYNAMIC_EXTRACT_OPTIONS = {
109
+ inputs: declareKeys({
110
+ fileRef: true, model: true, schema: true, pageRange: true, modelConfig: true,
111
+ processorKey: true, processorName: true, processorReadOnly: true, processorFolderPath: true,
112
+ }),
113
+ };
114
+ const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
115
+ /**
116
+ * The schema as the node stores it: a `{ prompt, outputSchema }` document with
117
+ * no `config` gets the one `nodes schema set` scaffolds from the model
118
+ * settings. Without it, packaging does not read the document as the Schema
119
+ * Editor's (`config`, `prompt` and `outputSchema` are what mark it) and the
120
+ * processor is built with no fields and no prompt. Any other value is written
121
+ * as given (`check` reports a non-object).
122
+ */
123
+ function withConfig(schema, modelConfig) {
124
+ if (!isObject(schema) || schema.config !== undefined || typeof schema.prompt !== 'string' || !isObject(schema.outputSchema))
125
+ return schema;
126
+ return { config: buildScaffoldConfig(modelConfig), ...schema };
127
+ }
128
+ /** The lifted schema without a `config` that is only the scaffold {@link withConfig} adds back. */
129
+ function withoutScaffoldConfig(schema, modelConfig) {
130
+ if (!isObject(schema) || JSON.stringify(schema.config) !== JSON.stringify(buildScaffoldConfig(modelConfig)))
131
+ return schema;
132
+ const { config: _scaffold, ...rest } = schema;
133
+ return rest;
134
+ }
135
+ /** A non-empty string input of the node, as the lift keeps it. */
136
+ function liftText(inputs, key, ctx) {
137
+ const v = ctx.plainValue(inputs[key]);
138
+ return typeof v === 'string' && v.trim() !== '' ? v : undefined;
139
+ }
140
+ /**
141
+ * The processor key compile mints for a step that names none: one per node,
142
+ * derived from the flow and the node, so a recompile keeps it (and the
143
+ * processor's resource file keeps matching it). `uip maestro flow nodes create`
144
+ * mints a random one instead; either is a key no other node holds.
145
+ */
146
+ function mintedProcessorKey(flowId, nodeId) {
147
+ return stableId(`${flowId}:${nodeId}:processorKey`);
148
+ }
149
+ /** `model`, as the lift reads it back: only a real deployment identity (both names non-empty). */
150
+ function liftModel(inputs, ctx) {
151
+ const nested = (inputs.model !== null && typeof inputs.model === 'object' ? inputs.model : {});
152
+ const pick = (key) => liftText(inputs, key, ctx)
153
+ ?? (typeof nested[key] === 'string' && nested[key].trim() !== '' ? nested[key] : undefined);
154
+ const modelName = pick('modelName');
155
+ const folderKey = pick('folderKey');
156
+ if (modelName === undefined || folderKey === undefined)
157
+ return undefined;
158
+ const extra = (key) => {
159
+ const v = liftText(inputs, key, ctx);
160
+ return v !== undefined ? { [key]: v } : {};
161
+ };
162
+ return { modelName, folderKey, ...extra('projectId'), ...extra('projectName'), ...extra('folderName'), ...extra('versionTag') };
163
+ }
103
164
  export const documentClassifyNodeType = {
104
165
  kind: 'documentClassify', typeName: 'uipath.document.classify', version: '1.0', factory: 'documentClassify',
105
166
  optionKeys: CLASSIFY_OPTIONS,
@@ -159,30 +220,52 @@ export const dynamicExtractNodeType = {
159
220
  serialize: ({ inputs }, ctx) => {
160
221
  const d = defaults('uipath.ixp.extract-document-builder', '1.0.0', ctx);
161
222
  const m = inputs.model;
223
+ const modelConfig = inputs.modelConfig !== undefined
224
+ ? { ...(d.modelConfig ?? {}), ...inputs.modelConfig }
225
+ : undefined;
226
+ // The processor (#1984). A read-only mirror and a processor published to the
227
+ // tenant name one the node does not author, so nothing is minted for them, as
228
+ // `nodes create` / `nodes provision` mint nothing for them.
229
+ const readOnly = inputs.processorReadOnly === true;
230
+ const folderPath = inputs.processorFolderPath !== undefined && inputs.processorFolderPath.trim() !== ''
231
+ ? inputs.processorFolderPath : undefined;
232
+ const processorKey = inputs.processorKey !== undefined && inputs.processorKey !== ''
233
+ ? inputs.processorKey
234
+ : readOnly || folderPath !== undefined ? undefined : mintedProcessorKey(ctx.flowId, ctx.nodeId);
162
235
  return {
163
236
  inputs: {
164
237
  ...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 } : {}),
238
+ // A published deployment's identity, written only when the author still
239
+ // passes one (deprecated): the node does not read it.
240
+ ...(m !== undefined
241
+ ? {
242
+ model: { modelName: m.modelName, folderKey: m.folderKey },
243
+ modelName: m.modelName,
244
+ folderKey: m.folderKey,
245
+ ...(m.projectId !== undefined ? { projectId: m.projectId } : {}),
246
+ ...(m.projectName !== undefined ? { projectName: m.projectName } : {}),
247
+ ...(m.folderName !== undefined ? { folderName: m.folderName } : {}),
248
+ ...(m.versionTag !== undefined ? { versionTag: m.versionTag } : {}),
249
+ }
250
+ : {}),
174
251
  // A `uipath.ixp.*` fileRef must stay a PLAIN `=js:` string — the
175
252
  // platform reads it unwrapped (see migrate's UNWRAPPED_INPUTS).
176
253
  fileRef: ctx.render(toExpr(inputs.fileRef)),
177
254
  ...(inputs.pageRange !== undefined ? { pageRange: inputs.pageRange } : {}),
178
- ...(inputs.modelConfig !== undefined
179
- ? { modelConfig: { ...(d.modelConfig ?? {}), ...inputs.modelConfig } }
180
- : {}),
181
- ...(inputs.schema !== undefined ? { schemaDocument: inputs.schema } : {}),
255
+ ...(modelConfig !== undefined ? { modelConfig } : {}),
256
+ // No schema: the empty taxonomy `nodes create` seeds, so the node opens in
257
+ // the Schema Editor and its processor has a document to hold.
258
+ schemaDocument: inputs.schema !== undefined
259
+ ? withConfig(inputs.schema, modelConfig ?? d.modelConfig)
260
+ : buildDefaultSchemaDocument(modelConfig ?? d.modelConfig),
182
261
  // The definition's model declares `source: true`: the platform mints a
183
262
  // stable storage slot per instance; omit it and the node validates then
184
263
  // faults. Deterministic, like every other minted identity here.
185
264
  source: ctx.mint('source'),
265
+ ...(processorKey !== undefined ? { processorKey } : {}),
266
+ ...(inputs.processorName !== undefined && inputs.processorName.trim() !== '' ? { processorName: inputs.processorName } : {}),
267
+ ...(readOnly ? { processorReadOnly: true } : {}),
268
+ ...(folderPath !== undefined ? { processorFolderPath: folderPath } : {}),
186
269
  },
187
270
  // IxP instances must NOT carry the manifest's model block — the slim
188
271
  // { type, serviceType } lives only in definitions[] (product validate
@@ -192,14 +275,34 @@ export const dynamicExtractNodeType = {
192
275
  };
193
276
  },
194
277
  deserialize: (node, ctx) => {
278
+ const inputs = (node.inputs ?? {});
195
279
  const pageRange = liftPageRange(node);
196
- const schema = node.inputs?.schemaDocument;
280
+ const modelConfig = liftObjectInput(node, 'modelConfig', ctx, extractLoss);
281
+ const model = liftModel(inputs, ctx);
282
+ // The seeded empty taxonomy is what compile writes for no schema, so it is
283
+ // not printed; anything else is the author's.
284
+ const rawSchema = ctx.plainValue(inputs.schemaDocument);
285
+ const seeded = buildDefaultSchemaDocument(inputs.modelConfig);
286
+ const schema = rawSchema !== undefined && JSON.stringify(rawSchema) !== JSON.stringify(seeded)
287
+ ? withoutScaffoldConfig(rawSchema, inputs.modelConfig) : undefined;
288
+ // The processor a node already names is printed, so a recompile keeps it;
289
+ // only the key compile itself would mint for this node is left out.
290
+ const key = liftText(inputs, 'processorKey', ctx);
291
+ const keepKey = key !== undefined && !(ctx.stepName(ctx.nodeId) === ctx.nodeId && key === mintedProcessorKey(ctx.flowId, ctx.nodeId));
292
+ const processorName = liftText(inputs, 'processorName', ctx);
293
+ const processorFolderPath = liftText(inputs, 'processorFolderPath', ctx);
197
294
  return {
198
295
  kind: 'dynamicExtract',
199
296
  inputs: {
200
297
  fileRef: liftFileRef(node, ctx),
201
- ...(schema !== undefined ? { schema: schema } : {}),
298
+ ...(schema !== undefined ? { schema } : {}),
202
299
  ...(pageRange !== undefined ? { pageRange } : {}),
300
+ ...(modelConfig !== undefined ? { modelConfig } : {}),
301
+ ...(model !== undefined ? { model } : {}),
302
+ ...(keepKey ? { processorKey: key } : {}),
303
+ ...(processorName !== undefined ? { processorName } : {}),
304
+ ...(ctx.plainValue(inputs.processorReadOnly) === true ? { processorReadOnly: true } : {}),
305
+ ...(processorFolderPath !== undefined ? { processorFolderPath } : {}),
203
306
  },
204
307
  };
205
308
  },
@@ -209,6 +312,12 @@ export const dynamicExtractNodeType = {
209
312
  ['fileRef', ctx.value(inputs.fileRef)],
210
313
  ['schema', inputs.schema !== undefined ? ctx.json(inputs.schema) : undefined],
211
314
  ['pageRange', inputs.pageRange !== undefined ? ctx.string(inputs.pageRange) : undefined],
315
+ ['modelConfig', inputs.modelConfig !== undefined ? ctx.json(inputs.modelConfig) : undefined],
316
+ ['model', inputs.model !== undefined ? ctx.json(inputs.model) : undefined],
317
+ ['processorKey', inputs.processorKey !== undefined ? ctx.string(inputs.processorKey) : undefined],
318
+ ['processorName', inputs.processorName !== undefined ? ctx.string(inputs.processorName) : undefined],
319
+ ['processorReadOnly', inputs.processorReadOnly === true ? 'true' : undefined],
320
+ ['processorFolderPath', inputs.processorFolderPath !== undefined ? ctx.string(inputs.processorFolderPath) : undefined],
212
321
  ],
213
322
  }),
214
323
  check: ({ inputs }, ctx) => {
@@ -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.3",
3
+ "version": "6.118.0",
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": "2f1c37585eefb238a5ee2c95533b12b07e3f9a9a"
127
+ "gitref": "9c219f2a52f548305c5576f25ed4266d23af9fdf"
128
128
  }