@uipath/maestro-builder-sdk 6.122.6 → 6.122.7

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.
@@ -59,8 +59,7 @@ export declare function activityFieldValues(values: Record<string, unknown>): Ma
59
59
  * kinds. That is a library update, which the saved copy outlives. A different
60
60
  * set of fields is the SDK's own builder changing (an older SDK's thinner
61
61
  * essential configuration, #1420; its missing `inputMetadata`, #1427; its flat
62
- * response schema, #1423), which compile repairs on purpose, so the saved copy
63
- * is not kept.
62
+ * response schema, #1423), which compile repairs on purpose.
64
63
  *
65
64
  * For instance a Slack task's `metadata` whose only difference is
66
65
  * `activityMetadata.activity.description` is a library update; one whose
@@ -91,7 +90,8 @@ export declare function comparesContextRow(bag: Record<string, any>, name: strin
91
90
  * the library described it as `"(Slack) Send a message to an individual user
92
91
  * in Slack."` keeps that description after a library that says `"Send a
93
92
  * message to an individual user in Slack."`. A body of another shape (an
94
- * older SDK's builder) is left to compile, which repairs it.
93
+ * older SDK's builder) is kept too: compile repairs it in place
94
+ * ({@link repairedMetadata}), keeping its values.
95
95
  * - An activity's `inputs` are recorded as compile writes them for the
96
96
  * unedited source, so a change compile makes to an input on purpose (an
97
97
  * older SDK's `sendAs`, written as the declared `send_as`, #1601) is not
@@ -128,6 +128,8 @@ export function activityFieldValues(values) {
128
128
  }
129
129
  return out;
130
130
  }
131
+ /** No key is library data in a `metadata` body: its whole shape is the builder's. */
132
+ const NO_DATA = new Set();
131
133
  /**
132
134
  * A value's shape: its keys, all the way down, with every leaf value left
133
135
  * out, so two values with the same fields and other text compare equal. An
@@ -156,15 +158,14 @@ function shape(value, opaque) {
156
158
  * kinds. That is a library update, which the saved copy outlives. A different
157
159
  * set of fields is the SDK's own builder changing (an older SDK's thinner
158
160
  * essential configuration, #1420; its missing `inputMetadata`, #1427; its flat
159
- * response schema, #1423), which compile repairs on purpose, so the saved copy
160
- * is not kept.
161
+ * response schema, #1423), which compile repairs on purpose.
161
162
  *
162
163
  * For instance a Slack task's `metadata` whose only difference is
163
164
  * `activityMetadata.activity.description` is a library update; one whose
164
165
  * configuration lacks `customFieldsRequestDetails` and `operation` is an older
165
166
  * SDK's.
166
167
  */
167
- export function onlyLibraryValuesDiffer(built, saved, opaque = new Set()) {
168
+ export function onlyLibraryValuesDiffer(built, saved, opaque = NO_DATA) {
168
169
  return stable(built) !== stable(saved) && shape(built, opaque) === shape(saved, opaque);
169
170
  }
170
171
  /** Whether two input value maps hold the same values, an input on one side only reading as empty. */
@@ -281,7 +282,8 @@ function sdkShaped(bag, context) {
281
282
  * the library described it as `"(Slack) Send a message to an individual user
282
283
  * in Slack."` keeps that description after a library that says `"Send a
283
284
  * message to an individual user in Slack."`. A body of another shape (an
284
- * older SDK's builder) is left to compile, which repairs it.
285
+ * older SDK's builder) is kept too: compile repairs it in place
286
+ * ({@link repairedMetadata}), keeping its values.
285
287
  * - An activity's `inputs` are recorded as compile writes them for the
286
288
  * unedited source, so a change compile makes to an input on purpose (an
287
289
  * older SDK's `sendAs`, written as the declared `send_as`, #1601) is not
@@ -300,7 +302,7 @@ export function savedConnectorContext(owner, bag, rebuild) {
300
302
  const rebuilt = rebuild?.();
301
303
  if (sdkShaped(bag, context)) {
302
304
  const body = context.find((row) => row.name === 'metadata').body;
303
- if (rebuilt?.metadata === undefined || !onlyLibraryValuesDiffer(rebuilt.metadata, body))
305
+ if (rebuilt?.metadata === undefined || stable(rebuilt.metadata) === stable(body))
304
306
  return undefined;
305
307
  }
306
308
  const inputs = inputValues(bag);
@@ -391,6 +393,60 @@ function unchanged(bag, entry, v2) {
391
393
  return false;
392
394
  return sameInputs(inputValues(bag), entry.inputs, connectorKind(bag));
393
395
  }
396
+ /**
397
+ * Keys whose value compile repairs even on an unedited element: an older SDK
398
+ * wrote the library version as `packageVersion`, which the platform writes as
399
+ * `"1.0.0"` (#1420).
400
+ */
401
+ const REPAIRED_VALUES = new Set(['packageVersion']);
402
+ /**
403
+ * `built` with each value the saved copy holds at the same place: the fields
404
+ * compile writes now, the values the element was saved with. An `=jsonString:`
405
+ * configuration is merged as the JSON it holds. A field only `saved` has is
406
+ * left out (compile no longer writes it); a field only `built` has is added.
407
+ */
408
+ function savedValuesIn(built, saved, key) {
409
+ if (key !== undefined && REPAIRED_VALUES.has(key))
410
+ return built;
411
+ if (typeof built === 'string' && typeof saved === 'string' && built.startsWith(JSON_STRING) && saved.startsWith(JSON_STRING)) {
412
+ try {
413
+ return `${JSON_STRING}${JSON.stringify(savedValuesIn(JSON.parse(built.slice(JSON_STRING.length)), JSON.parse(saved.slice(JSON_STRING.length))))}`;
414
+ }
415
+ catch {
416
+ return built;
417
+ }
418
+ }
419
+ if (isObject(built)) {
420
+ if (!isObject(saved))
421
+ return built;
422
+ return Object.fromEntries(Object.entries(built).map(([field, value]) => [field, field in saved ? savedValuesIn(value, saved[field], field) : value]));
423
+ }
424
+ if (Array.isArray(built)) {
425
+ if (!Array.isArray(saved) || saved.length !== built.length)
426
+ return built;
427
+ return built.map((item, at) => savedValuesIn(item, saved[at]));
428
+ }
429
+ if (isObject(saved) || Array.isArray(saved))
430
+ return built;
431
+ return saved;
432
+ }
433
+ /**
434
+ * The context to write back for an unedited element whose saved `metadata`
435
+ * an older SDK wrote in another shape than compile builds now (an essential
436
+ * configuration without the keys of the shared builder, #1434; no
437
+ * `inputMetadata`, #1427): compile's context, with the saved `metadata`
438
+ * values where compile writes the same field. That is the repair alone. A
439
+ * library update since is no edit, so the saved text stays. For instance, a
440
+ * Slack task an older SDK saved with `description: "(Slack) Send a message
441
+ * ..."` and an essential configuration with no `operation` comes back with
442
+ * `operation: "create"` added and the saved description.
443
+ */
444
+ function repairedMetadata(built, saved) {
445
+ const savedBody = saved.find((row) => row.name === 'metadata')?.body;
446
+ return built.map((row) => (row.name === 'metadata' && isObject(row.body) && isObject(savedBody)
447
+ ? { ...row, body: savedValuesIn(row.body, savedBody) }
448
+ : structuredClone(row)));
449
+ }
394
450
  /**
395
451
  * Write each saved connector context back onto the element compile built for
396
452
  * the same owner, while that element is unchanged ({@link unchanged}). Runs
@@ -404,8 +460,15 @@ export function applyConnectorContexts(result, entries) {
404
460
  const v2 = result.metadata?.intsvcActivityConfig === 'v2';
405
461
  for (const { key, bag } of caseConnectorOwners(result)) {
406
462
  const entry = byOwner.get(key);
407
- if (entry && unchanged(bag, entry, v2))
408
- bag.context = structuredClone(entry.context);
463
+ if (!entry || !unchanged(bag, entry, v2))
464
+ continue;
465
+ // A context an SDK wrote in another shape than compile builds now is an
466
+ // older SDK's: compile repairs it, keeping its values (`repairedMetadata`).
467
+ const built = Array.isArray(bag.context) ? bag.context.filter(isObject) : [];
468
+ const builtBody = built.find((row) => row.name === 'metadata')?.body;
469
+ const savedBody = entry.context.find((row) => row.name === 'metadata')?.body;
470
+ const olderSdk = sdkShaped(bag, entry.context) && builtBody !== undefined && shape(builtBody, NO_DATA) !== shape(savedBody, NO_DATA);
471
+ bag.context = olderSdk ? repairedMetadata(built, entry.context) : structuredClone(entry.context);
409
472
  }
410
473
  }
411
474
  /** Problems with a payload's `connectorContexts`, for `caseJsonPreservationErrors`. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.122.6",
3
+ "version": "6.122.7",
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",
@@ -126,5 +126,5 @@
126
126
  "@types/node": "^22.7.0",
127
127
  "esbuild": "^0.28.1"
128
128
  },
129
- "gitref": "f11a5901d050fbca10cffe4229d30be9ab1a4eb6"
129
+ "gitref": "830b4a8b5f25eb5f2ed3667f2283ab81b423b3c6"
130
130
  }