@uipath/maestro-builder-sdk 6.70.0 → 6.70.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.
@@ -0,0 +1,80 @@
1
+ import { ownEntry } from './own-entry.js';
2
+ const LOCATIONS = { body: 'body', query: 'query', path: 'path' };
3
+ const TYPES = {
4
+ string: 'string', boolean: 'boolean', number: 'number', integer: 'number', array: 'array', object: 'object',
5
+ };
6
+ /**
7
+ * Why `fields` cannot be carried, or `undefined` when it can.
8
+ *
9
+ * For instance `[{ name: 'bodyFormat', location: 'header' }]` is refused: a
10
+ * header is no slot the connector wire has.
11
+ */
12
+ export function carriedConnectorFieldsRefusal(fields, where) {
13
+ if (fields === undefined)
14
+ return undefined;
15
+ if (!Array.isArray(fields))
16
+ return `${where}: carriedFields must be an array of { name, location, type? } fields.`;
17
+ const seen = new Set();
18
+ for (const field of fields) {
19
+ const f = field;
20
+ if (!f || typeof f !== 'object' || typeof f.name !== 'string' || !f.name)
21
+ return `${where}: a carried field must name itself with a non-empty string.`;
22
+ if (typeof f.location !== 'string' || ownEntry(LOCATIONS, f.location) === undefined)
23
+ return `${where}: carried field "${f.name}" has location ${JSON.stringify(f.location)}; expected "body", "query" or "path".`;
24
+ if (f.type !== undefined && (typeof f.type !== 'string' || !Object.values(TYPES).includes(f.type)))
25
+ return `${where}: carried field "${f.name}" has type ${JSON.stringify(f.type)}; expected "string", "number", "boolean", "array" or "object".`;
26
+ const extra = Object.keys(f).find((key) => key !== 'name' && key !== 'location' && key !== 'type');
27
+ if (extra !== undefined)
28
+ return `${where}: carried field "${f.name}" has unsupported key "${extra}".`;
29
+ if (seen.has(f.name))
30
+ return `${where}: carried field "${f.name}" is listed twice.`;
31
+ seen.add(f.name);
32
+ }
33
+ return undefined;
34
+ }
35
+ /**
36
+ * `rc` with each carried field the library does not declare appended to its
37
+ * fields, as an optional input. A name the library declares keeps the library's
38
+ * declaration. `fields` must have passed {@link carriedConnectorFieldsRefusal}.
39
+ */
40
+ export function withCarriedFields(rc, fields) {
41
+ if (!fields?.length)
42
+ return rc;
43
+ const known = new Set(rc.fields.map((f) => f.name));
44
+ const added = fields
45
+ .filter((f) => !known.has(f.name))
46
+ .map((f) => ({ name: f.name, location: f.location, required: false, ...(f.type !== undefined ? { type: f.type } : {}) }));
47
+ return added.length ? { ...rc, fields: [...rc.fields, ...added] } : rc;
48
+ }
49
+ /**
50
+ * The fields a saved activity configuration declares that `rc` does not, as
51
+ * decompile carries them: from `optionalConfiguration.fieldsContainer.inputFields`,
52
+ * request fields only, in the saved order. Empty when the configuration has no
53
+ * field list (an SDK-compiled plan writes the essential half only), or every
54
+ * saved field is in the library. A saved field on a slot the connector wire has
55
+ * no place for (a `header`) is not carried.
56
+ *
57
+ * @param configuration - The parsed `=jsonString:` configuration blob.
58
+ */
59
+ export function savedFieldsMissingFromLibrary(configuration, rc) {
60
+ const inputFields = configuration
61
+ ?.optionalConfiguration?.fieldsContainer?.inputFields;
62
+ if (!Array.isArray(inputFields))
63
+ return [];
64
+ const known = new Set(rc.fields.map((f) => f.name));
65
+ const out = [];
66
+ for (const raw of inputFields) {
67
+ if (!raw || typeof raw !== 'object')
68
+ continue;
69
+ const f = raw;
70
+ if (typeof f.name !== 'string' || !f.name || known.has(f.name) || f.request === false)
71
+ continue;
72
+ const location = typeof f.fieldLocation === 'string' ? ownEntry(LOCATIONS, f.fieldLocation) : undefined;
73
+ if (!location)
74
+ continue;
75
+ known.add(f.name);
76
+ const type = typeof f.type === 'string' ? ownEntry(TYPES, f.type) : undefined;
77
+ out.push({ name: f.name, location, ...(type !== undefined ? { type } : {}) });
78
+ }
79
+ return out;
80
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.70.0",
3
+ "version": "6.70.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",
@@ -100,5 +100,5 @@
100
100
  "@types/node": "^22.7.0",
101
101
  "esbuild": "^0.28.1"
102
102
  },
103
- "gitref": "990446f9254b96a4cb0cbfc1a3ec7f99deaabe5e"
103
+ "gitref": "d1531fbce30cd3d2a88997dd8c65be6ef046e5ed"
104
104
  }