@uipath/maestro-sdk 1.207.0-preview.327 → 1.207.0-preview.329

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.
@@ -113,6 +113,131 @@ var MANAGED_HTTP_KEYS = new Set([
113
113
  "query",
114
114
  "body"
115
115
  ]);
116
+ // src/bpmn-packaging/node-utils.ts
117
+ function extensionValues(element) {
118
+ return element.extensionElements?.values ?? [];
119
+ }
120
+ function childNodes(node) {
121
+ return node?.$children ?? [];
122
+ }
123
+ function required(value, label) {
124
+ if (!value?.trim()) {
125
+ throw new Error(`${label} is required.`);
126
+ }
127
+ return value.trim();
128
+ }
129
+ function allFlowElements(element) {
130
+ const result = [];
131
+ for (const child of element.flowElements ?? []) {
132
+ result.push(child, ...allFlowElements(child));
133
+ }
134
+ return result;
135
+ }
136
+ var CONNECTION_CONNECTOR_TYPES = new Set([
137
+ "Intsvc.ActivityExecution",
138
+ "Intsvc.EventTrigger",
139
+ "Intsvc.WaitForEvent"
140
+ ]);
141
+ var EXTERNAL_EXECUTION_TYPES = new Set([
142
+ "Intsvc.AsyncExecution",
143
+ "Intsvc.SyncAgentExecution",
144
+ "Intsvc.AsyncAgentExecution",
145
+ "Intsvc.AsyncWorkflowExecution",
146
+ "Intsvc.SyncWorkflowExecution"
147
+ ]);
148
+ var BINDING_NODE_TYPES = new Set([
149
+ ...CONNECTION_CONNECTOR_TYPES,
150
+ ...EXTERNAL_EXECUTION_TYPES,
151
+ "Intsvc.UnifiedHttpRequest"
152
+ ]);
153
+ function connectorNodes(process, types = CONNECTION_CONNECTOR_TYPES) {
154
+ return allFlowElements(process).flatMap((element) => {
155
+ const payload = extensionValues(element).find((node) => node.$type === "uipath:activity" || node.$type === "uipath:event");
156
+ const extensionType = childNodes(payload).find((node) => node.$type === "uipath:type")?.value;
157
+ if (extensionType === undefined || !types.has(extensionType)) {
158
+ return [];
159
+ }
160
+ const context = childNodes(payload).find((node) => node.$type === "uipath:context");
161
+ const values = new Map([...childNodes(context), ...childNodes(payload)].filter((node) => node.$type === "uipath:input" && node.name).map((node) => [
162
+ node.name,
163
+ node.value ?? node.$body
164
+ ]));
165
+ return [{ element, extensionType, values }];
166
+ });
167
+ }
168
+ var connectionReference = (values) => [values.get("connection"), values.get("connectionId")].find((value) => value?.trim());
169
+ var bindingIdOf = (value) => /^=bindings\.([A-Za-z_][\w.-]*)$/.exec(value ?? "")?.[1];
170
+ var rootBindingNodes = (process) => childNodes(extensionValues(process).find((node) => node.$type === "uipath:bindings")).filter((node) => node.$type === "uipath:binding");
171
+ var collaborationBindingNodes = (process) => (process.$parent?.rootElements ?? []).filter((element) => element.$type === "bpmn:Collaboration").flatMap(rootBindingNodes);
172
+ var connectionBindingNodes = (process) => rootBindingNodes(process).filter((node) => node.resource === "Connection" && node.propertyAttribute === "ConnectionId");
173
+
174
+ // src/bpmn-packaging/business-rule-resources.ts
175
+ var BUSINESS_RULE_RESOURCE = "BusinessRule";
176
+ var BUSINESS_RULE_TASK_TYPES = new Set([
177
+ "Orchestrator.BusinessRules"
178
+ ]);
179
+ var FOLDER_ATTRIBUTES = new Set([
180
+ "folderKey",
181
+ "folderPath"
182
+ ]);
183
+ function buildBusinessRuleResources(processes) {
184
+ const rows = new Map;
185
+ for (const process of processes) {
186
+ const bindings = [
187
+ ...rootBindingNodes(process),
188
+ ...collaborationBindingNodes(process)
189
+ ];
190
+ const ruleBindings = bindings.filter((binding) => binding.resource === BUSINESS_RULE_RESOURCE && binding.id && binding.resourceKey && !FOLDER_ATTRIBUTES.has(binding.propertyAttribute ?? ""));
191
+ if (ruleBindings.length === 0)
192
+ continue;
193
+ const tasks = connectorNodes(process, BUSINESS_RULE_TASK_TYPES);
194
+ for (const binding of ruleBindings) {
195
+ const key = binding.resourceKey;
196
+ if (rows.has(key))
197
+ continue;
198
+ const task = tasks.find((candidate) => [...candidate.values.values()].some((value) => bindingIdOf(value) === binding.id));
199
+ if (task === undefined)
200
+ continue;
201
+ rows.set(key, businessRuleRow(binding, task.element, resolve(task.values.get("name"), bindings), resolve(task.values.get("folderPath"), bindings)));
202
+ }
203
+ }
204
+ return [...rows.values()];
205
+ }
206
+ function resolve(value, bindings) {
207
+ const id = bindingIdOf(value);
208
+ const resolved = id === undefined ? value : bindings.find((binding) => binding.id === id)?.default;
209
+ return resolved?.startsWith("=") ? undefined : resolved;
210
+ }
211
+ function businessRuleRow(binding, task, name, folderPath) {
212
+ const key = binding.resourceKey;
213
+ const value = {};
214
+ if (folderPath) {
215
+ value.folderPath = {
216
+ defaultValue: folderPath,
217
+ isExpression: false,
218
+ displayName: "Folder path"
219
+ };
220
+ }
221
+ if (name) {
222
+ value.name = {
223
+ defaultValue: name,
224
+ isExpression: false,
225
+ displayName: "Business rule"
226
+ };
227
+ }
228
+ return {
229
+ resource: BUSINESS_RULE_RESOURCE,
230
+ key,
231
+ id: `${BUSINESS_RULE_RESOURCE}${key}`,
232
+ value,
233
+ metadata: {
234
+ ActivityName: task.name?.trim() || task.id || "",
235
+ BindingsVersion: BINDINGS_VERSION,
236
+ DisplayLabel: binding.name ?? ""
237
+ }
238
+ };
239
+ }
240
+
116
241
  // ../common/src/guid.ts
117
242
  var GUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
118
243
  function isGuid(value) {
@@ -10677,6 +10802,16 @@ var SCRIPT_RUNTIME_GLOBALS = new Set([
10677
10802
  "arguments",
10678
10803
  ...JINT_GLOBALS
10679
10804
  ]);
10805
+ var SCRIPT_ENVELOPE_NAMES = new Set(["vars", "metadata"]);
10806
+ var NON_BODY_INPUT_TARGETS = new Set([
10807
+ "bodyField",
10808
+ "header",
10809
+ "path",
10810
+ "query",
10811
+ "file",
10812
+ "pathParameters",
10813
+ "queryParameters"
10814
+ ]);
10680
10815
  var KNOWN_UIPATH_TAGS = new Set(SUPPORTED_UIPATH_EXTENSION_TAGS);
10681
10816
  var SCRIPT_TASK_INPUT_CONTRACT = {
10682
10817
  ...BPMN_SPEC.extensionTypes["BPMN.ScriptTask"],
@@ -10710,63 +10845,6 @@ function isIntsvcActivityExecutionV1(nodeVersion, workflowVersion) {
10710
10845
  return version === undefined || version === ACTIVITY_CONFIGURATION_V1;
10711
10846
  }
10712
10847
 
10713
- // src/bpmn-packaging/node-utils.ts
10714
- function extensionValues(element) {
10715
- return element.extensionElements?.values ?? [];
10716
- }
10717
- function childNodes(node) {
10718
- return node?.$children ?? [];
10719
- }
10720
- function required(value, label) {
10721
- if (!value?.trim()) {
10722
- throw new Error(`${label} is required.`);
10723
- }
10724
- return value.trim();
10725
- }
10726
- function allFlowElements(element) {
10727
- const result = [];
10728
- for (const child of element.flowElements ?? []) {
10729
- result.push(child, ...allFlowElements(child));
10730
- }
10731
- return result;
10732
- }
10733
- var CONNECTION_CONNECTOR_TYPES = new Set([
10734
- "Intsvc.ActivityExecution",
10735
- "Intsvc.EventTrigger",
10736
- "Intsvc.WaitForEvent"
10737
- ]);
10738
- var EXTERNAL_EXECUTION_TYPES = new Set([
10739
- "Intsvc.AsyncExecution",
10740
- "Intsvc.SyncAgentExecution",
10741
- "Intsvc.AsyncAgentExecution",
10742
- "Intsvc.AsyncWorkflowExecution",
10743
- "Intsvc.SyncWorkflowExecution"
10744
- ]);
10745
- var BINDING_NODE_TYPES = new Set([
10746
- ...CONNECTION_CONNECTOR_TYPES,
10747
- ...EXTERNAL_EXECUTION_TYPES,
10748
- "Intsvc.UnifiedHttpRequest"
10749
- ]);
10750
- function connectorNodes(process, types = CONNECTION_CONNECTOR_TYPES) {
10751
- return allFlowElements(process).flatMap((element) => {
10752
- const payload = extensionValues(element).find((node) => node.$type === "uipath:activity" || node.$type === "uipath:event");
10753
- const extensionType = childNodes(payload).find((node) => node.$type === "uipath:type")?.value;
10754
- if (extensionType === undefined || !types.has(extensionType)) {
10755
- return [];
10756
- }
10757
- const context = childNodes(payload).find((node) => node.$type === "uipath:context");
10758
- const values = new Map([...childNodes(context), ...childNodes(payload)].filter((node) => node.$type === "uipath:input" && node.name).map((node) => [
10759
- node.name,
10760
- node.value ?? node.$body
10761
- ]));
10762
- return [{ element, extensionType, values }];
10763
- });
10764
- }
10765
- var connectionReference = (values) => [values.get("connection"), values.get("connectionId")].find((value) => value?.trim());
10766
- var bindingIdOf = (value) => /^=bindings\.([A-Za-z_][\w.-]*)$/.exec(value ?? "")?.[1];
10767
- var rootBindingNodes = (process) => childNodes(extensionValues(process).find((node) => node.$type === "uipath:bindings")).filter((node) => node.$type === "uipath:binding");
10768
- var connectionBindingNodes = (process) => rootBindingNodes(process).filter((node) => node.resource === "Connection" && node.propertyAttribute === "ConnectionId");
10769
-
10770
10848
  // src/bpmn-packaging/connection-resources.ts
10771
10849
  function targetConnectorOf(body) {
10772
10850
  if (!body?.trim())
@@ -11062,14 +11140,17 @@ function buildBindingResources(processes, existingResources) {
11062
11140
  }
11063
11141
  }
11064
11142
  }
11065
- for (const resource of buildEntityResources(processes)) {
11143
+ for (const resource of [
11144
+ ...buildEntityResources(processes),
11145
+ ...buildBusinessRuleResources(processes)
11146
+ ]) {
11066
11147
  const id = resourceIdentity(resource);
11067
11148
  if (!generated.has(id))
11068
11149
  generated.set(id, resource);
11069
11150
  }
11070
11151
  const declared = declaredResourceKeys(processes);
11071
11152
  const sdkEntities = sdkEntityKeys(processes);
11072
- const merged = withConnections.filter((resource) => !isRebuiltRow(resource) || generated.has(resourceIdentity(resource)) || isScopedRow(resource) && declared.has(String(resource.key)) && !(resource.resource === "Entity" && sdkEntities.has(String(resource.key)))).map((resource) => {
11153
+ const merged = withConnections.filter((resource) => !isRebuiltRow(resource) || generated.has(resourceIdentity(resource)) || isScopedRow(resource) && declared.has(String(resource.key)) && resource.resource !== BUSINESS_RULE_RESOURCE && !(resource.resource === "Entity" && sdkEntities.has(String(resource.key)))).map((resource) => {
11073
11154
  const id = resourceIdentity(resource);
11074
11155
  const replacement = generated.get(id);
11075
11156
  if (replacement === undefined)
@@ -11081,8 +11162,9 @@ function buildBindingResources(processes, existingResources) {
11081
11162
  }
11082
11163
  var resourceIdentity = (resource) => `${String(resource.resource)}|${String(resource.key)}`;
11083
11164
  function isRebuiltRow(resource) {
11084
- if (resource.resource === "EventTrigger")
11165
+ if (resource.resource === "EventTrigger" || resource.resource === BUSINESS_RULE_RESOURCE) {
11085
11166
  return true;
11167
+ }
11086
11168
  const metadata = isJsonObject(resource.metadata) ? resource.metadata : undefined;
11087
11169
  if (typeof metadata?.NameFieldPath === "string")
11088
11170
  return true;
@@ -17361,4 +17443,4 @@ export {
17361
17443
  required
17362
17444
  };
17363
17445
 
17364
- //# debugId=A913D2BAA055828564756E2164756E21
17446
+ //# debugId=13A94A9AF7D79B9564756E2164756E21
@@ -11251,6 +11251,20 @@ var SCRIPT_RUNTIME_GLOBALS = new Set([
11251
11251
  "arguments",
11252
11252
  ...JINT_GLOBALS
11253
11253
  ]);
11254
+ var SCRIPT_ENVELOPE_NAMES = new Set(["vars", "metadata"]);
11255
+ var SCRIPT_TASK_EXTENSION_TYPE = "BPMN.ScriptTask";
11256
+ var SCRIPT_TYPE_SKIPS_SCRIPT = "SCRIPT_TYPE_SKIPS_SCRIPT";
11257
+ var SCRIPT_ARGS_ENVELOPE_MISSING = "SCRIPT_ARGS_ENVELOPE_MISSING";
11258
+ var MULTIPLE_BODY_INPUTS = "MULTIPLE_BODY_INPUTS";
11259
+ var NON_BODY_INPUT_TARGETS = new Set([
11260
+ "bodyField",
11261
+ "header",
11262
+ "path",
11263
+ "query",
11264
+ "file",
11265
+ "pathParameters",
11266
+ "queryParameters"
11267
+ ]);
11254
11268
  function parseScriptBody(body) {
11255
11269
  const [error, program] = catchError(() => parse(body, {
11256
11270
  ecmaVersion: "latest",
@@ -11261,7 +11275,7 @@ function parseScriptBody(body) {
11261
11275
  }
11262
11276
  function scriptArgsKeys(scriptTask) {
11263
11277
  const argsInput = findDescendants(scriptTask, (node) => node.name === "uipath:input" && node.attributes.name === "args")[0];
11264
- const body = argsInput?.text.trim();
11278
+ const body = engineInputValue(argsInput)?.trim();
11265
11279
  if (!body) {
11266
11280
  return new Set;
11267
11281
  }
@@ -11274,6 +11288,41 @@ function scriptArgsKeys(scriptTask) {
11274
11288
  }
11275
11289
  return new Set(Object.keys(parsed));
11276
11290
  }
11291
+ function engineInputValue(input) {
11292
+ return input?.cdata ?? input?.attributes.value;
11293
+ }
11294
+ function hasPlainTextArgs(scriptTask) {
11295
+ const argsInput = findDescendants(scriptTask, (node) => node.name === "uipath:input" && node.attributes.name === "args")[0];
11296
+ return argsInput !== undefined && engineInputValue(argsInput) === undefined && argsInput.text.trim() !== "";
11297
+ }
11298
+ function scriptVersionNumber(scriptTask) {
11299
+ const value = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value;
11300
+ const versionMatch = /^v(\d+)$/i.exec(value ?? "");
11301
+ return versionMatch ? Number(versionMatch[1]) : 1;
11302
+ }
11303
+ function scriptBody(scriptTask) {
11304
+ return findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0]?.text?.trim();
11305
+ }
11306
+ function typeofGuardedNames(program) {
11307
+ const guarded = new Set;
11308
+ const visit = (node) => {
11309
+ if (!node || typeof node !== "object") {
11310
+ return;
11311
+ }
11312
+ if (Array.isArray(node)) {
11313
+ node.forEach(visit);
11314
+ return;
11315
+ }
11316
+ const estree = node;
11317
+ const argument = estree.argument;
11318
+ if (estree.type === "UnaryExpression" && estree.operator === "typeof" && argument?.type === "Identifier") {
11319
+ guarded.add(argument.name);
11320
+ }
11321
+ Object.values(estree).forEach(visit);
11322
+ };
11323
+ visit(program);
11324
+ return guarded;
11325
+ }
11277
11326
  function isBindingTarget(node) {
11278
11327
  return node?.type === "Identifier" || node?.type === "ObjectPattern" || node?.type === "ArrayPattern";
11279
11328
  }
@@ -11623,8 +11672,27 @@ class BpmnValidateService {
11623
11672
  this.validateBareServiceTasks(file, definitions, diagnostics);
11624
11673
  this.validateScriptResponseWrapper(file, definitions, diagnostics);
11625
11674
  this.validateScriptTaskMigrationMarker(file, definitions, diagnostics);
11675
+ this.validateScriptTaskType(file, definitions, diagnostics);
11626
11676
  this.validateScriptBareVariables(file, definitions, diagnostics);
11627
11677
  }
11678
+ validateScriptTaskType(file, definitions, diagnostics) {
11679
+ for (const scriptTask of findDescendants(definitions, (node) => hasLocalName(node, "scriptTask"))) {
11680
+ if (!scriptBody(scriptTask)) {
11681
+ continue;
11682
+ }
11683
+ const skipsScript = findDescendants(scriptTask, (node) => node.name === "uipath:type").some((node) => node.attributes.value?.toLowerCase() === SCRIPT_TASK_EXTENSION_TYPE.toLowerCase());
11684
+ if (!skipsScript) {
11685
+ continue;
11686
+ }
11687
+ diagnostics.push({
11688
+ file,
11689
+ element: describeElement(scriptTask),
11690
+ ruleCode: SCRIPT_TYPE_SKIPS_SCRIPT,
11691
+ message: `Script task "${scriptTask.attributes.id ?? ""}" has uipath:type ${SCRIPT_TASK_EXTENSION_TYPE}, so the runtime skips its script: the task completes and every output reads back null.`,
11692
+ instruction: "Set the uipath:type value to BPMN.Variables and keep the args input and outputs."
11693
+ });
11694
+ }
11695
+ }
11628
11696
  validateScriptTaskMigrationMarker(file, definitions, diagnostics) {
11629
11697
  for (const processNode of findChildren(definitions, (node) => hasLocalName(node, "process"))) {
11630
11698
  const marker = findChildren(processNode, (node) => hasLocalName(node, "extensionElements")).flatMap((extensions) => childElements(extensions, "uipath:migrationVersion"))[0]?.attributes.version?.trim();
@@ -11634,8 +11702,7 @@ class BpmnValidateService {
11634
11702
  }
11635
11703
  for (const scriptTask of findDescendants(processNode, (node) => hasLocalName(node, "scriptTask"))) {
11636
11704
  const scriptVersion = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value;
11637
- const versionMatch = /^v(\d+)$/i.exec(scriptVersion ?? "");
11638
- if (!versionMatch || Number(versionMatch[1]) < 3) {
11705
+ if (scriptVersionNumber(scriptTask) < 3) {
11639
11706
  continue;
11640
11707
  }
11641
11708
  const hasScriptResponse = findDescendants(scriptTask, (node) => node.name === "uipath:output" && node.attributes.name === "scriptResponse").length > 0;
@@ -11893,14 +11960,11 @@ class BpmnValidateService {
11893
11960
  validateScriptResponseWrapper(file, root, diagnostics) {
11894
11961
  const scriptTasks = findDescendants(root, (node) => hasLocalName(node, "scriptTask"));
11895
11962
  for (const scriptTask of scriptTasks) {
11896
- const script = findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0];
11897
- const body = script?.text?.trim();
11963
+ const body = scriptBody(scriptTask);
11898
11964
  if (!body) {
11899
11965
  continue;
11900
11966
  }
11901
- const scriptVersion = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value ?? "v1";
11902
- const versionMatch = /^v(\d+)$/i.exec(scriptVersion);
11903
- if (!versionMatch || Number(versionMatch[1]) < 2) {
11967
+ if (scriptVersionNumber(scriptTask) < 2) {
11904
11968
  continue;
11905
11969
  }
11906
11970
  const program = parseScriptBody(body);
@@ -11953,8 +12017,7 @@ class BpmnValidateService {
11953
12017
  }
11954
12018
  validateScriptBareVariables(file, root, diagnostics) {
11955
12019
  for (const scriptTask of findDescendants(root, (node) => hasLocalName(node, "scriptTask"))) {
11956
- const scriptNode = findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0];
11957
- const body = scriptNode?.text?.trim();
12020
+ const body = scriptBody(scriptTask);
11958
12021
  if (!body) {
11959
12022
  continue;
11960
12023
  }
@@ -11963,7 +12026,19 @@ class BpmnValidateService {
11963
12026
  if (!provided || !program) {
11964
12027
  continue;
11965
12028
  }
11966
- const unresolved = [...collectFreeIdentifiers(program)].filter((name) => !SCRIPT_RUNTIME_GLOBALS.has(name) && !provided.has(name)).sort((a, b) => a.localeCompare(b));
12029
+ const allUnresolved = [...collectFreeIdentifiers(program)].filter((name) => !SCRIPT_RUNTIME_GLOBALS.has(name) && !provided.has(name)).sort((a, b) => a.localeCompare(b));
12030
+ const guarded = typeofGuardedNames(program);
12031
+ const unboundEnvelope = scriptVersionNumber(scriptTask) >= 2 ? allUnresolved.filter((name) => SCRIPT_ENVELOPE_NAMES.has(name) && !guarded.has(name)) : [];
12032
+ if (unboundEnvelope.length > 0) {
12033
+ diagnostics.push({
12034
+ file,
12035
+ element: describeElement(scriptTask),
12036
+ ruleCode: SCRIPT_ARGS_ENVELOPE_MISSING,
12037
+ message: `Script references ${unboundEnvelope.map((n) => `"${n}"`).join(", ")}, not provided by the script args envelope, so the run faults with a "not defined" error.`,
12038
+ instruction: hasPlainTextArgs(scriptTask) ? "The args input is a plain text node, and the engine reads only CDATA or the value attribute. Upgrade @uipath/maestro-builder-sdk to 6.47.3 or later and compile again, or wrap the args JSON in <![CDATA[...]]>." : 'Give the script task a BPMN.Variables uipath:mapping with <uipath:input name="args" type="json" target="bodyField"> holding {"vars":"=vars","metadata":"=metadata"}.'
12039
+ });
12040
+ }
12041
+ const unresolved = allUnresolved.filter((name) => !unboundEnvelope.includes(name));
11967
12042
  if (unresolved.length === 0) {
11968
12043
  continue;
11969
12044
  }
@@ -12343,6 +12418,9 @@ class BpmnValidateService {
12343
12418
  const directInputs = childElements(payload, "uipath:input");
12344
12419
  const actual = new Map(directInputs.map((input) => [input.attributes.name, input]));
12345
12420
  if (usesCanvasOwnedDynamicPayload(contract)) {
12421
+ if (payload.name === "uipath:activity") {
12422
+ this.validateSingleBodyInput(file, directInputs, owner, contract, diagnostics);
12423
+ }
12346
12424
  this.validateDynamicDirectInputs(file, directInputs, diagnostics);
12347
12425
  return;
12348
12426
  }
@@ -12497,6 +12575,24 @@ class BpmnValidateService {
12497
12575
  }
12498
12576
  validateTypedValue(file, actual, input.type, actual.text || actual.attributes.value, `input payload "${input.name}"`, diagnostics);
12499
12577
  }
12578
+ validateSingleBodyInput(file, directInputs, owner, contract, diagnostics) {
12579
+ const bodyInputs = directInputs.filter((input) => {
12580
+ const { name, type, target } = input.attributes;
12581
+ const hasValue = engineInputValue(input) !== undefined;
12582
+ return name !== undefined && type !== undefined && target !== undefined && hasValue && !NON_BODY_INPUT_TARGETS.has(target);
12583
+ });
12584
+ if (bodyInputs.length < 2) {
12585
+ return;
12586
+ }
12587
+ const names = bodyInputs.map((input) => `"${input.attributes.name ?? ""}"`).join(", ");
12588
+ diagnostics.push({
12589
+ file,
12590
+ element: describeElement(owner),
12591
+ ruleCode: MULTIPLE_BODY_INPUTS,
12592
+ message: `${contract.extensionType} has ${bodyInputs.length} inputs the runtime sends as the body (${names}). It keeps one body value, so only the last one is sent.`,
12593
+ instruction: 'Put every body field in one <uipath:input name="body" type="json" target="body"> holding the whole request object.'
12594
+ });
12595
+ }
12500
12596
  validateDynamicDirectInputs(file, directInputs, diagnostics) {
12501
12597
  for (const input of directInputs) {
12502
12598
  if (!hasAttributeValue(input, "name")) {
@@ -12921,7 +13017,9 @@ function parseXml(xml) {
12921
13017
  }
12922
13018
  const token = xml.slice(match.start, match.end);
12923
13019
  if (token.startsWith(CDATA_OPEN)) {
12924
- stack[stack.length - 1].text += match.cdata ?? "";
13020
+ const current = stack[stack.length - 1];
13021
+ current.text += match.cdata ?? "";
13022
+ current.cdata = (current.cdata ?? "") + (match.cdata ?? "");
12925
13023
  } else if (token.startsWith("</")) {
12926
13024
  const closeName = token.slice(2, -1).trim();
12927
13025
  if (stack.length <= 1) {
@@ -13529,4 +13627,4 @@ export {
13529
13627
  isIntsvcActivityExecutionV1
13530
13628
  };
13531
13629
 
13532
- //# debugId=9B199A072D7AD5BD64756E2164756E21
13630
+ //# debugId=D388432C4860B6DB64756E2164756E21
@@ -1121,7 +1121,7 @@ var init_package = __esm(() => {
1121
1121
  name: "@uipath/integrationservice-sdk",
1122
1122
  author: "UiPath",
1123
1123
  license: "SEE LICENSE IN LICENSE.txt",
1124
- version: "1.207.0-preview.327",
1124
+ version: "1.207.0-preview.329",
1125
1125
  repository: {
1126
1126
  type: "git",
1127
1127
  url: "https://github.com/UiPath/cli.git",
@@ -265184,4 +265184,4 @@ export {
265184
265184
  studioCatalogTypeCache
265185
265185
  };
265186
265186
 
265187
- //# debugId=7493A832B80836DF64756E2164756E21
265187
+ //# debugId=B46301058B80D93164756E2164756E21
package/dist/index.js CHANGED
@@ -144975,7 +144975,7 @@ var init_package = __esm(() => {
144975
144975
  name: "@uipath/integrationservice-sdk",
144976
144976
  author: "UiPath",
144977
144977
  license: "SEE LICENSE IN LICENSE.txt",
144978
- version: "1.207.0-preview.327",
144978
+ version: "1.207.0-preview.329",
144979
144979
  repository: {
144980
144980
  type: "git",
144981
144981
  url: "https://github.com/UiPath/cli.git",
@@ -280975,6 +280975,20 @@ var SCRIPT_RUNTIME_GLOBALS = new Set([
280975
280975
  "arguments",
280976
280976
  ...JINT_GLOBALS
280977
280977
  ]);
280978
+ var SCRIPT_ENVELOPE_NAMES = new Set(["vars", "metadata"]);
280979
+ var SCRIPT_TASK_EXTENSION_TYPE = "BPMN.ScriptTask";
280980
+ var SCRIPT_TYPE_SKIPS_SCRIPT = "SCRIPT_TYPE_SKIPS_SCRIPT";
280981
+ var SCRIPT_ARGS_ENVELOPE_MISSING = "SCRIPT_ARGS_ENVELOPE_MISSING";
280982
+ var MULTIPLE_BODY_INPUTS = "MULTIPLE_BODY_INPUTS";
280983
+ var NON_BODY_INPUT_TARGETS = new Set([
280984
+ "bodyField",
280985
+ "header",
280986
+ "path",
280987
+ "query",
280988
+ "file",
280989
+ "pathParameters",
280990
+ "queryParameters"
280991
+ ]);
280978
280992
  function parseScriptBody(body) {
280979
280993
  const [error, program] = catchError(() => parse(body, {
280980
280994
  ecmaVersion: "latest",
@@ -280985,7 +280999,7 @@ function parseScriptBody(body) {
280985
280999
  }
280986
281000
  function scriptArgsKeys(scriptTask) {
280987
281001
  const argsInput = findDescendants(scriptTask, (node) => node.name === "uipath:input" && node.attributes.name === "args")[0];
280988
- const body = argsInput?.text.trim();
281002
+ const body = engineInputValue(argsInput)?.trim();
280989
281003
  if (!body) {
280990
281004
  return new Set;
280991
281005
  }
@@ -280998,6 +281012,41 @@ function scriptArgsKeys(scriptTask) {
280998
281012
  }
280999
281013
  return new Set(Object.keys(parsed));
281000
281014
  }
281015
+ function engineInputValue(input) {
281016
+ return input?.cdata ?? input?.attributes.value;
281017
+ }
281018
+ function hasPlainTextArgs(scriptTask) {
281019
+ const argsInput = findDescendants(scriptTask, (node) => node.name === "uipath:input" && node.attributes.name === "args")[0];
281020
+ return argsInput !== undefined && engineInputValue(argsInput) === undefined && argsInput.text.trim() !== "";
281021
+ }
281022
+ function scriptVersionNumber(scriptTask) {
281023
+ const value = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value;
281024
+ const versionMatch = /^v(\d+)$/i.exec(value ?? "");
281025
+ return versionMatch ? Number(versionMatch[1]) : 1;
281026
+ }
281027
+ function scriptBody(scriptTask) {
281028
+ return findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0]?.text?.trim();
281029
+ }
281030
+ function typeofGuardedNames(program) {
281031
+ const guarded = new Set;
281032
+ const visit = (node) => {
281033
+ if (!node || typeof node !== "object") {
281034
+ return;
281035
+ }
281036
+ if (Array.isArray(node)) {
281037
+ node.forEach(visit);
281038
+ return;
281039
+ }
281040
+ const estree = node;
281041
+ const argument = estree.argument;
281042
+ if (estree.type === "UnaryExpression" && estree.operator === "typeof" && argument?.type === "Identifier") {
281043
+ guarded.add(argument.name);
281044
+ }
281045
+ Object.values(estree).forEach(visit);
281046
+ };
281047
+ visit(program);
281048
+ return guarded;
281049
+ }
281001
281050
  function isBindingTarget(node) {
281002
281051
  return node?.type === "Identifier" || node?.type === "ObjectPattern" || node?.type === "ArrayPattern";
281003
281052
  }
@@ -281347,8 +281396,27 @@ class BpmnValidateService {
281347
281396
  this.validateBareServiceTasks(file, definitions, diagnostics);
281348
281397
  this.validateScriptResponseWrapper(file, definitions, diagnostics);
281349
281398
  this.validateScriptTaskMigrationMarker(file, definitions, diagnostics);
281399
+ this.validateScriptTaskType(file, definitions, diagnostics);
281350
281400
  this.validateScriptBareVariables(file, definitions, diagnostics);
281351
281401
  }
281402
+ validateScriptTaskType(file, definitions, diagnostics) {
281403
+ for (const scriptTask of findDescendants(definitions, (node) => hasLocalName(node, "scriptTask"))) {
281404
+ if (!scriptBody(scriptTask)) {
281405
+ continue;
281406
+ }
281407
+ const skipsScript = findDescendants(scriptTask, (node) => node.name === "uipath:type").some((node) => node.attributes.value?.toLowerCase() === SCRIPT_TASK_EXTENSION_TYPE.toLowerCase());
281408
+ if (!skipsScript) {
281409
+ continue;
281410
+ }
281411
+ diagnostics.push({
281412
+ file,
281413
+ element: describeElement(scriptTask),
281414
+ ruleCode: SCRIPT_TYPE_SKIPS_SCRIPT,
281415
+ message: `Script task "${scriptTask.attributes.id ?? ""}" has uipath:type ${SCRIPT_TASK_EXTENSION_TYPE}, so the runtime skips its script: the task completes and every output reads back null.`,
281416
+ instruction: "Set the uipath:type value to BPMN.Variables and keep the args input and outputs."
281417
+ });
281418
+ }
281419
+ }
281352
281420
  validateScriptTaskMigrationMarker(file, definitions, diagnostics) {
281353
281421
  for (const processNode of findChildren(definitions, (node) => hasLocalName(node, "process"))) {
281354
281422
  const marker = findChildren(processNode, (node) => hasLocalName(node, "extensionElements")).flatMap((extensions) => childElements(extensions, "uipath:migrationVersion"))[0]?.attributes.version?.trim();
@@ -281358,8 +281426,7 @@ class BpmnValidateService {
281358
281426
  }
281359
281427
  for (const scriptTask of findDescendants(processNode, (node) => hasLocalName(node, "scriptTask"))) {
281360
281428
  const scriptVersion = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value;
281361
- const versionMatch = /^v(\d+)$/i.exec(scriptVersion ?? "");
281362
- if (!versionMatch || Number(versionMatch[1]) < 3) {
281429
+ if (scriptVersionNumber(scriptTask) < 3) {
281363
281430
  continue;
281364
281431
  }
281365
281432
  const hasScriptResponse = findDescendants(scriptTask, (node) => node.name === "uipath:output" && node.attributes.name === "scriptResponse").length > 0;
@@ -281617,14 +281684,11 @@ class BpmnValidateService {
281617
281684
  validateScriptResponseWrapper(file, root, diagnostics) {
281618
281685
  const scriptTasks = findDescendants(root, (node) => hasLocalName(node, "scriptTask"));
281619
281686
  for (const scriptTask of scriptTasks) {
281620
- const script = findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0];
281621
- const body = script?.text?.trim();
281687
+ const body = scriptBody(scriptTask);
281622
281688
  if (!body) {
281623
281689
  continue;
281624
281690
  }
281625
- const scriptVersion = findDescendants(scriptTask, (node) => node.name === "uipath:scriptVersion")[0]?.attributes.value ?? "v1";
281626
- const versionMatch = /^v(\d+)$/i.exec(scriptVersion);
281627
- if (!versionMatch || Number(versionMatch[1]) < 2) {
281691
+ if (scriptVersionNumber(scriptTask) < 2) {
281628
281692
  continue;
281629
281693
  }
281630
281694
  const program = parseScriptBody(body);
@@ -281677,8 +281741,7 @@ class BpmnValidateService {
281677
281741
  }
281678
281742
  validateScriptBareVariables(file, root, diagnostics) {
281679
281743
  for (const scriptTask of findDescendants(root, (node) => hasLocalName(node, "scriptTask"))) {
281680
- const scriptNode = findDescendants(scriptTask, (node) => hasLocalName(node, "script"))[0];
281681
- const body = scriptNode?.text?.trim();
281744
+ const body = scriptBody(scriptTask);
281682
281745
  if (!body) {
281683
281746
  continue;
281684
281747
  }
@@ -281687,7 +281750,19 @@ class BpmnValidateService {
281687
281750
  if (!provided || !program) {
281688
281751
  continue;
281689
281752
  }
281690
- const unresolved = [...collectFreeIdentifiers(program)].filter((name) => !SCRIPT_RUNTIME_GLOBALS.has(name) && !provided.has(name)).sort((a, b) => a.localeCompare(b));
281753
+ const allUnresolved = [...collectFreeIdentifiers(program)].filter((name) => !SCRIPT_RUNTIME_GLOBALS.has(name) && !provided.has(name)).sort((a, b) => a.localeCompare(b));
281754
+ const guarded = typeofGuardedNames(program);
281755
+ const unboundEnvelope = scriptVersionNumber(scriptTask) >= 2 ? allUnresolved.filter((name) => SCRIPT_ENVELOPE_NAMES.has(name) && !guarded.has(name)) : [];
281756
+ if (unboundEnvelope.length > 0) {
281757
+ diagnostics.push({
281758
+ file,
281759
+ element: describeElement(scriptTask),
281760
+ ruleCode: SCRIPT_ARGS_ENVELOPE_MISSING,
281761
+ message: `Script references ${unboundEnvelope.map((n) => `"${n}"`).join(", ")}, not provided by the script args envelope, so the run faults with a "not defined" error.`,
281762
+ instruction: hasPlainTextArgs(scriptTask) ? "The args input is a plain text node, and the engine reads only CDATA or the value attribute. Upgrade @uipath/maestro-builder-sdk to 6.47.3 or later and compile again, or wrap the args JSON in <![CDATA[...]]>." : 'Give the script task a BPMN.Variables uipath:mapping with <uipath:input name="args" type="json" target="bodyField"> holding {"vars":"=vars","metadata":"=metadata"}.'
281763
+ });
281764
+ }
281765
+ const unresolved = allUnresolved.filter((name) => !unboundEnvelope.includes(name));
281691
281766
  if (unresolved.length === 0) {
281692
281767
  continue;
281693
281768
  }
@@ -282067,6 +282142,9 @@ class BpmnValidateService {
282067
282142
  const directInputs = childElements(payload, "uipath:input");
282068
282143
  const actual = new Map(directInputs.map((input) => [input.attributes.name, input]));
282069
282144
  if (usesCanvasOwnedDynamicPayload(contract)) {
282145
+ if (payload.name === "uipath:activity") {
282146
+ this.validateSingleBodyInput(file, directInputs, owner, contract, diagnostics);
282147
+ }
282070
282148
  this.validateDynamicDirectInputs(file, directInputs, diagnostics);
282071
282149
  return;
282072
282150
  }
@@ -282221,6 +282299,24 @@ class BpmnValidateService {
282221
282299
  }
282222
282300
  validateTypedValue(file, actual, input.type, actual.text || actual.attributes.value, `input payload "${input.name}"`, diagnostics);
282223
282301
  }
282302
+ validateSingleBodyInput(file, directInputs, owner, contract, diagnostics) {
282303
+ const bodyInputs = directInputs.filter((input) => {
282304
+ const { name, type, target } = input.attributes;
282305
+ const hasValue = engineInputValue(input) !== undefined;
282306
+ return name !== undefined && type !== undefined && target !== undefined && hasValue && !NON_BODY_INPUT_TARGETS.has(target);
282307
+ });
282308
+ if (bodyInputs.length < 2) {
282309
+ return;
282310
+ }
282311
+ const names = bodyInputs.map((input) => `"${input.attributes.name ?? ""}"`).join(", ");
282312
+ diagnostics.push({
282313
+ file,
282314
+ element: describeElement(owner),
282315
+ ruleCode: MULTIPLE_BODY_INPUTS,
282316
+ message: `${contract.extensionType} has ${bodyInputs.length} inputs the runtime sends as the body (${names}). It keeps one body value, so only the last one is sent.`,
282317
+ instruction: 'Put every body field in one <uipath:input name="body" type="json" target="body"> holding the whole request object.'
282318
+ });
282319
+ }
282224
282320
  validateDynamicDirectInputs(file, directInputs, diagnostics) {
282225
282321
  for (const input of directInputs) {
282226
282322
  if (!hasAttributeValue(input, "name")) {
@@ -282645,7 +282741,9 @@ function parseXml(xml) {
282645
282741
  }
282646
282742
  const token = xml.slice(match.start, match.end);
282647
282743
  if (token.startsWith(CDATA_OPEN)) {
282648
- stack[stack.length - 1].text += match.cdata ?? "";
282744
+ const current = stack[stack.length - 1];
282745
+ current.text += match.cdata ?? "";
282746
+ current.cdata = (current.cdata ?? "") + (match.cdata ?? "");
282649
282747
  } else if (token.startsWith("</")) {
282650
282748
  const closeName = token.slice(2, -1).trim();
282651
282749
  if (stack.length <= 1) {
@@ -288653,4 +288751,4 @@ export {
288653
288751
  withPimsCall
288654
288752
  };
288655
288753
 
288656
- //# debugId=95328330B276CA0064756E2164756E21
288754
+ //# debugId=F7E350288F36525464756E2164756E21
@@ -144811,7 +144811,7 @@ var init_package = __esm(() => {
144811
144811
  name: "@uipath/integrationservice-sdk",
144812
144812
  author: "UiPath",
144813
144813
  license: "SEE LICENSE IN LICENSE.txt",
144814
- version: "1.207.0-preview.327",
144814
+ version: "1.207.0-preview.329",
144815
144815
  repository: {
144816
144816
  type: "git",
144817
144817
  url: "https://github.com/UiPath/cli.git",
@@ -264760,4 +264760,4 @@ export {
264760
264760
  shownRows
264761
264761
  };
264762
264762
 
264763
- //# debugId=B10224E86F70374164756E2164756E21
264763
+ //# debugId=27530336D905B2F864756E2164756E21
@@ -30482,4 +30482,4 @@ export {
30482
30482
  splitProcessKey
30483
30483
  };
30484
30484
 
30485
- //# debugId=10B7A02215AAF09964756E2164756E21
30485
+ //# debugId=04F272A0713B086D64756E2164756E21
@@ -7,8 +7,10 @@ import type { BpmnNode } from "./types.js";
7
7
  * its pickers bound and its Property bag), as Studio Web packages them
8
8
  * (PO.Frontend `getBindingResources`), plus an `Entity` row for each
9
9
  * folder-scoped entity a V1 Data Service task names through the builder SDK's
10
- * `Entity` binding pair (`buildEntityResources`). Those trigger, picker and Property
11
- * rows are rebuilt from the process each time, so an old one nothing produced
12
- * now is dropped; entries none of these manage are kept.
10
+ * `Entity` binding pair (`buildEntityResources`), and a `BusinessRule` row for
11
+ * each rule a business-rule task runs (`buildBusinessRuleResources`). Those
12
+ * trigger, picker, Property and business-rule rows are rebuilt from the process
13
+ * each time, so an old one nothing produced now is dropped; entries none of
14
+ * these manage are kept.
13
15
  */
14
16
  export declare function buildBindingResources(processes: BpmnNode[], existingResources: JsonObject[]): JsonObject[];
@@ -0,0 +1,18 @@
1
+ import type { JsonObject } from "./package-metadata.js";
2
+ import type { BpmnNode } from "./types.js";
3
+ /** The `bindings_v2.json` resource type of a business rule. */
4
+ export declare const BUSINESS_RULE_RESOURCE = "BusinessRule";
5
+ /**
6
+ * The `BusinessRule` rows for the rules the process's business-rule tasks run.
7
+ *
8
+ * A business-rule task (`Orchestrator.BusinessRules`, which the builder SDK
9
+ * writes for `.businessRule()`) names its rule through two root bindings,
10
+ * `resource="BusinessRule"`, `propertyAttribute` `name` and `folderPath`, one
11
+ * `resourceKey`, and its `name` / `folderPath` context inputs point at them.
12
+ * Studio Web packages one row per rule (resource key) whose name binding a
13
+ * node references, with the folder folded into its value (PO.Frontend
14
+ * `getBindingResources`, root-binding pass). A binding no task references gets
15
+ * no row. In a diagram with pools the bindings sit on the collaboration, so
16
+ * those count as the process's own.
17
+ */
18
+ export declare function buildBusinessRuleResources(processes: BpmnNode[]): JsonObject[];
@@ -42,5 +42,11 @@ export declare const connectionReference: (values: ReadonlyMap<string, string |
42
42
  export declare const bindingIdOf: (value: string | undefined) => string | undefined;
43
43
  /** The process's root `<uipath:binding>` entries. */
44
44
  export declare const rootBindingNodes: (process: BpmnNode) => UiPathNode[];
45
+ /**
46
+ * The root bindings on the collaborations beside the process. With pools in
47
+ * the diagram, Studio Web writes the root bindings on `bpmn:Collaboration`
48
+ * instead of the process (PO.Frontend `parent-element.ts` serializer).
49
+ */
50
+ export declare const collaborationBindingNodes: (process: BpmnNode) => UiPathNode[];
45
51
  /** The process's root `Connection` / `ConnectionId` bindings. */
46
52
  export declare const connectionBindingNodes: (process: BpmnNode) => UiPathNode[];
@@ -35,4 +35,6 @@ export interface BpmnNode {
35
35
  extensionElements?: {
36
36
  values?: UiPathNode[];
37
37
  };
38
+ /** The containing element bpmn-moddle sets on parse (a process's is its definitions). */
39
+ $parent?: BpmnNode;
38
40
  }
@@ -57,6 +57,7 @@ export declare class BpmnValidateService {
57
57
  validateProject(projectPath: string): Promise<BpmnValidationResult>;
58
58
  validateProjectBindings(projectPath: string): Promise<BpmnValidationResult>;
59
59
  private validateBpmnFile;
60
+ private validateScriptTaskType;
60
61
  private validateScriptTaskMigrationMarker;
61
62
  private recordJsonBindings;
62
63
  private recordInlineBindings;
@@ -91,6 +92,7 @@ export declare class BpmnValidateService {
91
92
  private validateInputs;
92
93
  private validateMergedInputs;
93
94
  private validateAdditionalInput;
95
+ private validateSingleBodyInput;
94
96
  private validateDynamicDirectInputs;
95
97
  private validateVariableMappingInputs;
96
98
  private validateOutput;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/maestro-sdk",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.207.0-preview.327",
5
+ "version": "1.207.0-preview.329",
6
6
  "description": "SDK for the UiPath Maestro (PIMS) API — process instance management.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -113,5 +113,5 @@
113
113
  "files": [
114
114
  "dist"
115
115
  ],
116
- "gitHead": "c60603941b8ddfa3c8b49502a43eb4474d1f6d08"
116
+ "gitHead": "69fdb2550ef462c0b226e9197a4be2ac63c316b9"
117
117
  }