@uipath/maestro-builder-sdk 6.95.6 → 6.96.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.
- package/dist/api-index.md +62 -62
- package/dist/api-members.md +287 -285
- package/dist/bpmn/bpmn-sdk.d.ts +20 -0
- package/dist/bpmn/check.js +26 -1
- package/dist/bpmn/decompile-stamp.d.ts +1 -10
- package/dist/bpmn/decompile-stamp.js +23 -34
- package/dist/bpmn/decompile.js +108 -24
- package/dist/bpmn/merge-cli.js +10 -12
- package/dist/bpmn/serialize.js +1 -1
- package/dist/bpmn/typed-node.d.ts +4 -1
- package/dist/bpmn/typed-node.js +32 -7
- package/dist/bpmn-api.md +2 -0
- package/dist/cli/commands/flow.js +8 -4
- package/dist/core/decompile-stamp.d.ts +43 -0
- package/dist/core/decompile-stamp.js +99 -0
- package/dist/core/refusals.d.ts +2 -0
- package/dist/core/refusals.js +2 -0
- package/dist/decompile-cli.js +23 -20
- package/dist/decompile-file.d.ts +16 -0
- package/dist/decompile-file.js +46 -0
- package/dist/decompile-stamp.d.ts +36 -0
- package/dist/decompile-stamp.js +84 -0
- package/dist/merge-cli.js +153 -16
- package/dist/merge-compile.d.ts +24 -6
- package/dist/merge-compile.js +25 -23
- package/package.json +4 -3
package/dist/bpmn/bpmn-sdk.d.ts
CHANGED
|
@@ -627,6 +627,26 @@ export interface ExtensionPayload {
|
|
|
627
627
|
type: string;
|
|
628
628
|
/** `uipath:output` rows, emitted exactly as given — see {@link TypedOutputRow}. */
|
|
629
629
|
outputRows: TypedOutputRow[];
|
|
630
|
+
/**
|
|
631
|
+
* The payload's own tag — `'uipath:activity'`, `'uipath:event'` or `'uipath:mapping'` —
|
|
632
|
+
* for a `type` the registry snapshot does not list.
|
|
633
|
+
*
|
|
634
|
+
* A decoration needs nothing from the registry but its tag, and a brownfield file
|
|
635
|
+
* already says which tag it used. Decompile writes this for an unlisted type, such
|
|
636
|
+
* as a case trigger's `None` (`{ type: 'None', tag: 'uipath:activity', outputRows }`),
|
|
637
|
+
* so the recompile writes the same element without a registry entry. Ignored for a
|
|
638
|
+
* type the snapshot lists: the snapshot's tag wins. Without it an unlisted type still
|
|
639
|
+
* refuses with `BPMN_TYPE_UNKNOWN`.
|
|
640
|
+
*
|
|
641
|
+
* With `tag` set, the `type` NAME is not checked against anything: a misspelled type
|
|
642
|
+
* compiles, and the platform only warns about it. That is the point for a type the
|
|
643
|
+
* file already carries, and a trap for a new node, so `check` warns
|
|
644
|
+
* (`PAYLOAD_TYPE_NOT_CHECKED`) on every payload that relies on it, naming the type.
|
|
645
|
+
* Do not copy `tag` from decompiled source onto a node you author.
|
|
646
|
+
*/
|
|
647
|
+
tag?: 'uipath:activity' | 'uipath:event' | 'uipath:mapping';
|
|
648
|
+
/** The `uipath:type` `version` attribute, when it is not `v1` — see `ActivityNodeOpts.typeVersion`. */
|
|
649
|
+
typeVersion?: string;
|
|
630
650
|
}
|
|
631
651
|
/**
|
|
632
652
|
* Options for `.startEvent()`. At most one of `message` / `timer` picks the
|
package/dist/bpmn/check.js
CHANGED
|
@@ -22,7 +22,7 @@ import { refreshConnectionDiagnostics } from './refresh-connections.js';
|
|
|
22
22
|
import { KNOWN_METHOD_SET } from './known-methods.js';
|
|
23
23
|
import { EQUALS_EXPR_DIALECT, checkConnectorLookups, checkConnectorResources, checkConnectorSchema, } from '../core/connector-checks.js';
|
|
24
24
|
import { checkEventResolution, checkEventSubscription, eventParamsFor, } from '../core/event-checks.js';
|
|
25
|
-
import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_TYPES, missingRequiredContext, missingRequiredInputs, platformEnforcesRequired, REGISTRY_GAPS, registryType, } from './typed-node.js';
|
|
25
|
+
import { bindingRequiredFields, CASE_RUNTIME_INTERNAL_TYPES, CONNECTOR_ACTIVITY_TYPES, missingRequiredContext, missingRequiredInputs, platformEnforcesRequired, isSnapshotType, REGISTRY_GAPS, registryType, } from './typed-node.js';
|
|
26
26
|
import { ownEntry } from '../core/own-entry.js';
|
|
27
27
|
import { MANAGED_HTTP_TYPE, isManagedHttpV2, managedHttpAbsoluteUrl, managedHttpMissing } from './managed-http.js';
|
|
28
28
|
import { connectorV2Missing, isConnectorV2 } from './connector.js';
|
|
@@ -129,6 +129,7 @@ export function check(built, opts = {}) {
|
|
|
129
129
|
checkConnectorRows(built, diags);
|
|
130
130
|
checkConnectors(built, opts, diags);
|
|
131
131
|
checkConnectorEvents(built, opts, diags);
|
|
132
|
+
checkCarriedPayloadTags(built, diags);
|
|
132
133
|
// A `.dataService()` entity's recorded row is the serializer's (`lowerDataServiceEntity`).
|
|
133
134
|
const { refusals, definitions, stoodIn } = serializerRefusals(built, opts, diags);
|
|
134
135
|
diags.push(...refusals);
|
|
@@ -1950,6 +1951,30 @@ inEventSubProcess = false) {
|
|
|
1950
1951
|
checkScope(n.nodes, n.flows, `subProcess "${n.id}"`, diags, false, n.triggeredByEvent === true);
|
|
1951
1952
|
}
|
|
1952
1953
|
}
|
|
1954
|
+
/**
|
|
1955
|
+
* A decoration payload that names a type the snapshot does not list and carries its own
|
|
1956
|
+
* `tag` (`ExtensionPayload.tag`). Compile then writes it without checking the type name,
|
|
1957
|
+
* so a typo (`Orchestrator.QueueItemAded`) compiles and the platform only warns. A
|
|
1958
|
+
* warning, not an error: decompile writes exactly this for a brownfield type such as a
|
|
1959
|
+
* case trigger's `None`, and that file must keep compiling. The warning makes the
|
|
1960
|
+
* unchecked name visible, so a copied pattern does not hide a typo.
|
|
1961
|
+
*/
|
|
1962
|
+
function checkCarriedPayloadTags(built, diags) {
|
|
1963
|
+
for (const n of allNodes(built.nodes)) {
|
|
1964
|
+
const payload = n.payload;
|
|
1965
|
+
if (!payload?.type || payload.tag === undefined || isSnapshotType(payload.type))
|
|
1966
|
+
continue;
|
|
1967
|
+
diags.push({
|
|
1968
|
+
level: 'warning',
|
|
1969
|
+
code: 'PAYLOAD_TYPE_NOT_CHECKED',
|
|
1970
|
+
message: `"${n.id}" carries extension type "${payload.type}" with its own tag ("${payload.tag}"); the registry snapshot ` +
|
|
1971
|
+
`does not list that type, so its name is not checked. That is expected for a type a brownfield file carries ` +
|
|
1972
|
+
`(decompile writes it); for a node you author, check the spelling with \`uip maestro bpmn registry search\` ` +
|
|
1973
|
+
`and drop \`tag\`.`,
|
|
1974
|
+
where: n.id,
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1953
1978
|
/**
|
|
1954
1979
|
* Whether this node serializes to a `bpmn:StartEvent`.
|
|
1955
1980
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { sourceDigest, STAMP_MARKER } from '../core/decompile-stamp.js';
|
|
1
2
|
/** What `bpmn decompile` records about the decompile, and `bpmn merge` reads back. */
|
|
2
3
|
export interface DecompileStamp {
|
|
3
4
|
/** The original's base name. */
|
|
@@ -13,16 +14,6 @@ export interface DecompileStamp {
|
|
|
13
14
|
/** Decompile was given `--keep-unused-bindings`. */
|
|
14
15
|
keepUnusedBindings: boolean;
|
|
15
16
|
}
|
|
16
|
-
/** The marker that starts the stamp line. */
|
|
17
|
-
export declare const STAMP_MARKER = "// @decompiled-from ";
|
|
18
|
-
/**
|
|
19
|
-
* The digest the stamp records: SHA-256, lowercase hex, of a source as decompile makes
|
|
20
|
-
* it (no stamp line), with the SDK import specifier replaced by a fixed one, so
|
|
21
|
-
* `--import` and the absolute entry merge decompiles against give the same digest.
|
|
22
|
-
*
|
|
23
|
-
* @param source - The decompiled source, before {@link stampSource}.
|
|
24
|
-
*/
|
|
25
|
-
export declare function sourceDigest(source: string): string;
|
|
26
17
|
/** The stamp line, without a line terminator. */
|
|
27
18
|
export declare function formatStamp(stamp: DecompileStamp): string;
|
|
28
19
|
/** `source` with the stamp line in front of it. */
|
|
@@ -34,35 +34,30 @@
|
|
|
34
34
|
* deletions and reverts them. The stamp lets merge check the first and reproduce the
|
|
35
35
|
* second, and merge refuses a source without one.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
|
|
39
|
-
import { commentText } from '../core/comment-text.js';
|
|
40
|
-
import { bytesToHex, sha256 } from '../core/sha.js';
|
|
41
|
-
/** The marker that starts the stamp line. */
|
|
42
|
-
export const STAMP_MARKER = '// @decompiled-from ';
|
|
43
|
-
/** The SDK import line of a decompiled source; `buildSource` (lift-verify.ts) rewrites the same line. */
|
|
44
|
-
const IMPORT_RE = /^(import\s*\{[^}]*\}\s*from\s*)["'][^"']+["'];/m;
|
|
45
|
-
/**
|
|
46
|
-
* The digest the stamp records: SHA-256, lowercase hex, of a source as decompile makes
|
|
47
|
-
* it (no stamp line), with the SDK import specifier replaced by a fixed one, so
|
|
48
|
-
* `--import` and the absolute entry merge decompiles against give the same digest.
|
|
37
|
+
* The line's shape, the digest and the line swap are shared with Flow
|
|
38
|
+
* (`core/decompile-stamp.ts`); the options are BPMN's.
|
|
49
39
|
*
|
|
50
|
-
*
|
|
40
|
+
* Nothing here prints; the CLIs do.
|
|
51
41
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
42
|
+
import { formatStampLine, readStampLine, replaceStampLine } from '../core/decompile-stamp.js';
|
|
43
|
+
export { sourceDigest, STAMP_MARKER } from '../core/decompile-stamp.js';
|
|
55
44
|
/** The stamp line, without a line terminator. */
|
|
56
45
|
export function formatStamp(stamp) {
|
|
57
|
-
return (
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
return formatStampLine({
|
|
47
|
+
file: stamp.file,
|
|
48
|
+
sha256: stamp.sha256,
|
|
49
|
+
options: [
|
|
50
|
+
`style=${stamp.style}`,
|
|
51
|
+
`connectors=${stamp.connectors}`,
|
|
52
|
+
...(stamp.keepFlowIds ? ['keep-flow-ids'] : []),
|
|
53
|
+
...(stamp.keepUnusedBindings ? ['keep-unused-bindings'] : []),
|
|
54
|
+
],
|
|
55
|
+
});
|
|
60
56
|
}
|
|
61
57
|
/** `source` with the stamp line in front of it. */
|
|
62
58
|
export function stampSource(source, stamp) {
|
|
63
59
|
return `${formatStamp(stamp)}\n${source}`;
|
|
64
60
|
}
|
|
65
|
-
const STAMP_RE = /^\/\/ @decompiled-from (.*) sha256:([0-9a-f]{64})((?: \S+)*)\s*$/;
|
|
66
61
|
/**
|
|
67
62
|
* Read the stamp from a `.bpmn.ts` source: the first line that starts with
|
|
68
63
|
* {@link STAMP_MARKER}.
|
|
@@ -71,22 +66,20 @@ const STAMP_RE = /^\/\/ @decompiled-from (.*) sha256:([0-9a-f]{64})((?: \S+)*)\s
|
|
|
71
66
|
* naming what is wrong with a stamp line that does not parse.
|
|
72
67
|
*/
|
|
73
68
|
export function readStamp(source) {
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
return
|
|
77
|
-
const
|
|
78
|
-
if (!match)
|
|
79
|
-
return { error: `the line does not read as \`${STAMP_MARKER}<file> sha256:<64 hex> <options>\`: ${line}` };
|
|
69
|
+
const read = readStampLine(source);
|
|
70
|
+
if (read === undefined || 'error' in read)
|
|
71
|
+
return read;
|
|
72
|
+
const { line } = read;
|
|
80
73
|
const stamp = {
|
|
81
|
-
file:
|
|
82
|
-
sha256:
|
|
74
|
+
file: read.file,
|
|
75
|
+
sha256: read.sha256,
|
|
83
76
|
style: 'explicit',
|
|
84
77
|
connectors: 'verbatim',
|
|
85
78
|
keepFlowIds: false,
|
|
86
79
|
keepUnusedBindings: false,
|
|
87
80
|
};
|
|
88
81
|
const seen = new Set();
|
|
89
|
-
for (const token of
|
|
82
|
+
for (const token of read.options) {
|
|
90
83
|
const [key, value] = token.split('=', 2);
|
|
91
84
|
if (seen.has(key))
|
|
92
85
|
return { error: `\`${key}\` appears twice: ${line}` };
|
|
@@ -120,9 +113,5 @@ export function restampSource(source, file, sha256) {
|
|
|
120
113
|
const stamp = readStamp(source);
|
|
121
114
|
if (stamp === undefined || 'error' in stamp)
|
|
122
115
|
return undefined;
|
|
123
|
-
|
|
124
|
-
const at = lines.findIndex((l) => l.startsWith(STAMP_MARKER));
|
|
125
|
-
const cr = lines[at]?.endsWith('\r') ? '\r' : '';
|
|
126
|
-
lines[at] = `${formatStamp({ ...stamp, file, sha256 })}${cr}`;
|
|
127
|
-
return lines.join('\n');
|
|
116
|
+
return replaceStampLine(source, formatStamp({ ...stamp, file, sha256 }));
|
|
128
117
|
}
|
package/dist/bpmn/decompile.js
CHANGED
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
import BpmnModdle from 'bpmn-moddle';
|
|
57
57
|
import { flattenConnectorBody } from '../core/connector-inputs.js';
|
|
58
58
|
import { createRequire } from 'node:module';
|
|
59
|
-
import { registryType, rowDeclaration } from './typed-node.js';
|
|
59
|
+
import { isSnapshotType, registryType, rowDeclaration } from './typed-node.js';
|
|
60
60
|
import { errorSchema, errorSchemaWithResponse } from './bpmn-sdk.js';
|
|
61
61
|
import { SCRIPT_ARGS_ENVELOPE, defaultScriptInputSchema } from './serialize.js';
|
|
62
62
|
import { BPMN_SCHEMA_VERSIONS } from './format-profile.js';
|
|
@@ -1012,19 +1012,21 @@ function listedSpec(type) {
|
|
|
1012
1012
|
* un-importable for a node the author may never touch.
|
|
1013
1013
|
*/
|
|
1014
1014
|
function artifactSpec(el, payload) {
|
|
1015
|
-
const
|
|
1016
|
-
const [ns, local] = tag.split(':');
|
|
1015
|
+
const def = (el.eventDefinitions ?? [])[0];
|
|
1017
1016
|
return {
|
|
1018
1017
|
element: el.$type,
|
|
1019
1018
|
// `uipath:Activity` is the moddle type; the spec spells the XML tag, `uipath:activity`.
|
|
1020
|
-
tag:
|
|
1019
|
+
tag: payloadTagOf(payload),
|
|
1021
1020
|
inputPattern: 'separateInputs',
|
|
1022
1021
|
inputName: null,
|
|
1023
1022
|
inputTarget: null,
|
|
1024
1023
|
context: [],
|
|
1025
1024
|
inputs: [],
|
|
1026
1025
|
output: null,
|
|
1027
|
-
|
|
1026
|
+
// A carried trigger's own definition, which `carriesUnlistedTrigger` has already
|
|
1027
|
+
// required to be bare: `bpmn:MessageEventDefinition` → `bpmn:messageEventDefinition`,
|
|
1028
|
+
// the spelling the snapshot uses.
|
|
1029
|
+
eventDefinition: def ? payloadTagOf(def) : null,
|
|
1028
1030
|
requiresDiscovery: false,
|
|
1029
1031
|
bindingPattern: 'none',
|
|
1030
1032
|
};
|
|
@@ -1040,18 +1042,43 @@ function emitSpec(spec) {
|
|
|
1040
1042
|
['context', '[]'],
|
|
1041
1043
|
['inputs', '[]'],
|
|
1042
1044
|
['output', 'null'],
|
|
1043
|
-
['eventDefinition', 'null'],
|
|
1045
|
+
['eventDefinition', spec.eventDefinition === null ? 'null' : tsText(spec.eventDefinition)],
|
|
1044
1046
|
['requiresDiscovery', 'false'],
|
|
1045
1047
|
['bindingPattern', tsText(spec.bindingPattern)],
|
|
1046
1048
|
]);
|
|
1047
1049
|
}
|
|
1050
|
+
/** The XML tag a moddle payload was written under: `uipath:Activity` → `uipath:activity`. */
|
|
1051
|
+
function payloadTagOf(payload) {
|
|
1052
|
+
const [ns, local] = String(payload.$type).split(':');
|
|
1053
|
+
return `${ns}:${local.charAt(0).toLowerCase()}${local.slice(1)}`;
|
|
1054
|
+
}
|
|
1055
|
+
/**
|
|
1056
|
+
* A payload that DECORATES its element, as the `payload` option (`ExtensionPayload`).
|
|
1057
|
+
*
|
|
1058
|
+
* For a type the registry does not list, the payload's own tag rides along (`tag`),
|
|
1059
|
+
* because that tag is the one thing the builder would otherwise ask the registry for.
|
|
1060
|
+
* A listed type leaves it out and keeps the snapshot's. The type version is written
|
|
1061
|
+
* only when it is not the builder's `v1`.
|
|
1062
|
+
*/
|
|
1063
|
+
function emitDecorationPayload(payload, type) {
|
|
1064
|
+
if (!payload || !type)
|
|
1065
|
+
return undefined;
|
|
1066
|
+
const version = payload.type?.version;
|
|
1067
|
+
return opts([
|
|
1068
|
+
['type', tsText(type)],
|
|
1069
|
+
['tag', isSnapshotType(type) ? undefined : tsText(payloadTagOf(payload))],
|
|
1070
|
+
['typeVersion', version && version !== 'v1' ? tsText(version) : undefined],
|
|
1071
|
+
['outputRows', emitOutputRows(payload) ?? '[]'],
|
|
1072
|
+
]);
|
|
1073
|
+
}
|
|
1048
1074
|
/**
|
|
1049
1075
|
* A node whose extension type the registry does not list — carried verbatim.
|
|
1050
1076
|
*
|
|
1051
1077
|
* Written as `.activity()` with the spec read off the artifact ({@link artifactSpec})
|
|
1052
1078
|
* and every row spelled out, so the recompile reproduces the element exactly and the
|
|
1053
|
-
* rest of the process stays editable.
|
|
1054
|
-
*
|
|
1079
|
+
* rest of the process stays editable. An event reaches here only when its payload holds
|
|
1080
|
+
* rows a decoration cannot carry, with a bare definition the spec reproduces
|
|
1081
|
+
* (`carriesUnlistedTrigger`); any other event keeps its own emitter.
|
|
1055
1082
|
*/
|
|
1056
1083
|
function emitUnlistedTypedNode(chain, el, payload, type) {
|
|
1057
1084
|
const id = el.id;
|
|
@@ -1692,7 +1719,7 @@ function renderHandler(plan, h, depth, indent) {
|
|
|
1692
1719
|
['id', b.id !== `${host}_${method}` ? tsText(b.id) : undefined],
|
|
1693
1720
|
['name', b.name !== undefined ? tsText(b.name) : undefined],
|
|
1694
1721
|
['interrupting', def !== 'error' && b.cancelActivity === false ? 'false' : undefined],
|
|
1695
|
-
['payload', payload
|
|
1722
|
+
['payload', emitDecorationPayload(payload, type)],
|
|
1696
1723
|
]);
|
|
1697
1724
|
const body = renderArmBody(plan, h.arm, depth, indent);
|
|
1698
1725
|
const args = [defExpr, ...(optsText !== EMPTY_OPTS ? [optsText] : []), ...(body ? [body] : [])];
|
|
@@ -1827,9 +1854,9 @@ function renderEventSubProcess(plan, sp, depth, indent) {
|
|
|
1827
1854
|
['startId', start.id !== `${sp.id}_start` ? tsText(start.id) : undefined],
|
|
1828
1855
|
['startName', start.name !== undefined ? tsText(start.name) : undefined],
|
|
1829
1856
|
['startEntryPointId', entryPointOption(start)],
|
|
1830
|
-
['startPayload',
|
|
1857
|
+
['startPayload', capture === undefined ? emitDecorationPayload(payload, type) : undefined],
|
|
1831
1858
|
['tags', tagsOf(sp)],
|
|
1832
|
-
['payload', spPayload
|
|
1859
|
+
['payload', emitDecorationPayload(spPayload, spType)],
|
|
1833
1860
|
]);
|
|
1834
1861
|
const vars = new Chain('');
|
|
1835
1862
|
emitVariablesInto(vars, sp, sp.id, capture !== undefined && captureDeclLooksDerived(sp, capture, start.id) ? new Set([capture]) : undefined);
|
|
@@ -2054,6 +2081,67 @@ function typeDescribesElement(kind, type) {
|
|
|
2054
2081
|
}
|
|
2055
2082
|
return !!element && localName(element).toLowerCase() === kind.toLowerCase();
|
|
2056
2083
|
}
|
|
2084
|
+
/**
|
|
2085
|
+
* Whether an event carries an extension type the registry does not list, with rows
|
|
2086
|
+
* only a typed node can hold — so it is emitted as `.activity()` with the spec read
|
|
2087
|
+
* off the element (`emitUnlistedTypedNode`) rather than as a decorated event.
|
|
2088
|
+
*
|
|
2089
|
+
* The case that forced it: a queue trigger, `Orchestrator.QueueItemAdded`, on a start
|
|
2090
|
+
* event of deployed processes. Neither the snapshot nor `uip maestro bpmn registry
|
|
2091
|
+
* search` lists it, yet `bpmn validate` accepts the file and it runs:
|
|
2092
|
+
*
|
|
2093
|
+
* <bpmn:startEvent id="s">
|
|
2094
|
+
* <uipath:event version="v1"><uipath:type value="Orchestrator.QueueItemAdded" version="v2" />
|
|
2095
|
+
* <uipath:context><uipath:input name="queueName" type="string" value="=bindings.q" /></uipath:context>
|
|
2096
|
+
* <uipath:output name="TransactionItem" type="jsonSchema" source="=response" var="item" />
|
|
2097
|
+
* </uipath:event>
|
|
2098
|
+
* <bpmn:messageEventDefinition />
|
|
2099
|
+
* </bpmn:startEvent>
|
|
2100
|
+
*
|
|
2101
|
+
* The decoration form (`payload: { type, outputRows }`) has no room for the context
|
|
2102
|
+
* rows, and the typed form needs the element, the tag and the definition — all of
|
|
2103
|
+
* which the file states. The typed form writes a definition with nothing in it, so
|
|
2104
|
+
* only a bare one (no reference, no body; an `id` is fine) is carried; anything else, and an
|
|
2105
|
+
* attribute `.activity()` cannot write (a boundary's host, a non-interrupting start),
|
|
2106
|
+
* refuses here instead of losing it.
|
|
2107
|
+
*
|
|
2108
|
+
* A payload with output rows alone stays a decoration, so the element keeps every
|
|
2109
|
+
* event option it has (`emitDecorationPayload` carries the tag).
|
|
2110
|
+
*/
|
|
2111
|
+
function carriesUnlistedTrigger(el, kind, payload, type) {
|
|
2112
|
+
if (!EVENT_KINDS.has(kind) || listedSpec(type))
|
|
2113
|
+
return false;
|
|
2114
|
+
const describes = (payload.context?.input?.length ?? 0) > 0 || payload.context?.inputSchema !== undefined || (payload.input?.length ?? 0) > 0;
|
|
2115
|
+
if (!describes)
|
|
2116
|
+
return false;
|
|
2117
|
+
const defs = el.eventDefinitions ?? [];
|
|
2118
|
+
// An `id` alone still counts as bare: the builder writes no definition id for any
|
|
2119
|
+
// event (`.startEvent({ message })` neither), and `bpmn merge` keeps the original's.
|
|
2120
|
+
const bare = defs.length === 0 || (defs.length === 1 && definitionIsBare(defs[0]));
|
|
2121
|
+
if (kind === 'boundaryEvent' || !bare || el.isInterrupting === false) {
|
|
2122
|
+
throw new Error(`${kind} "${el.id}" carries extension type "${type}", which the registry does not list, with context or input rows; ` +
|
|
2123
|
+
'only a non-boundary event with at most one bare event definition can carry them, so it is refused rather than written without them.');
|
|
2124
|
+
}
|
|
2125
|
+
return true;
|
|
2126
|
+
}
|
|
2127
|
+
/**
|
|
2128
|
+
* Whether an event definition says nothing but its kind (and, at most, its own id):
|
|
2129
|
+
* no reference (`messageRef`), no body (a timer's schedule), no foreign attribute.
|
|
2130
|
+
* Read through the moddle descriptor, because a resolved reference such as
|
|
2131
|
+
* `messageRef` is not an own key of the element.
|
|
2132
|
+
*/
|
|
2133
|
+
function definitionIsBare(def) {
|
|
2134
|
+
if (Object.keys(def.$attrs ?? {}).length)
|
|
2135
|
+
return false;
|
|
2136
|
+
for (const p of def.$descriptor?.properties ?? []) {
|
|
2137
|
+
if (p.name === 'id')
|
|
2138
|
+
continue;
|
|
2139
|
+
const v = def.get ? def.get(p.name) : def[p.name];
|
|
2140
|
+
if (v !== undefined && v !== null && !(Array.isArray(v) && v.length === 0))
|
|
2141
|
+
return false;
|
|
2142
|
+
}
|
|
2143
|
+
return true;
|
|
2144
|
+
}
|
|
2057
2145
|
/**
|
|
2058
2146
|
* An event element, with whatever payload it carries as an option on it.
|
|
2059
2147
|
*
|
|
@@ -2064,12 +2152,7 @@ function emitEvent(chain, el, kind, payload, type) {
|
|
|
2064
2152
|
// `outputRows` is the only payload shape an event carries in the corpus. A
|
|
2065
2153
|
// `context` or `input` row on one would mean the registry describes the element
|
|
2066
2154
|
// after all, which is the branch this function is not on.
|
|
2067
|
-
const eventPayload = payload
|
|
2068
|
-
? opts([
|
|
2069
|
-
['type', tsText(type)],
|
|
2070
|
-
['outputRows', emitOutputRows(payload) ?? '[]'],
|
|
2071
|
-
])
|
|
2072
|
-
: undefined;
|
|
2155
|
+
const eventPayload = emitDecorationPayload(payload, type);
|
|
2073
2156
|
if (kind === 'boundaryEvent') {
|
|
2074
2157
|
chain.add(`.boundaryEvent(${tsText(el.id)}, ${opts([
|
|
2075
2158
|
['name', el.name !== undefined ? tsText(el.name) : undefined],
|
|
@@ -2139,6 +2222,11 @@ function emitElement(chain, el, depth, indent) {
|
|
|
2139
2222
|
// ARE start events in the registry, so they keep the typed path and their context.
|
|
2140
2223
|
const elementWins = ELEMENT_OWNS.has(kind) && !typeDescribesElement(kind, type);
|
|
2141
2224
|
if (elementWins) {
|
|
2225
|
+
// An unlisted type whose payload carries context or input rows is not a
|
|
2226
|
+
// decoration: it describes the event (a queue trigger). Its rows and its bare
|
|
2227
|
+
// definition are all in the file, so it is carried like an unlisted task.
|
|
2228
|
+
if (payload && type && carriesUnlistedTrigger(el, kind, payload, type))
|
|
2229
|
+
return emitUnlistedTypedNode(chain, el, payload, type);
|
|
2142
2230
|
if (EVENT_KINDS.has(kind))
|
|
2143
2231
|
return emitEvent(chain, el, kind, payload, type);
|
|
2144
2232
|
if (kind === 'scriptTask')
|
|
@@ -2262,12 +2350,7 @@ function emitElement(chain, el, depth, indent) {
|
|
|
2262
2350
|
['name', el.name !== undefined ? tsText(el.name) : undefined],
|
|
2263
2351
|
[
|
|
2264
2352
|
'payload',
|
|
2265
|
-
spPayload
|
|
2266
|
-
? opts([
|
|
2267
|
-
['type', tsText(spType)],
|
|
2268
|
-
['outputRows', emitOutputRows(spPayload) ?? '[]'],
|
|
2269
|
-
])
|
|
2270
|
-
: undefined,
|
|
2353
|
+
emitDecorationPayload(spPayload, spType),
|
|
2271
2354
|
],
|
|
2272
2355
|
['triggeredByEvent', el.triggeredByEvent ? 'true' : undefined],
|
|
2273
2356
|
['loop', emitLoop(el)],
|
|
@@ -2789,7 +2872,8 @@ lifted = new Set()) {
|
|
|
2789
2872
|
// spelled out (`emitUnlistedTypedNode`), and those rows declare their variables on
|
|
2790
2873
|
// the way back in like any typed node's — so they are candidates too, wherever the
|
|
2791
2874
|
// typed path is the one that writes the element.
|
|
2792
|
-
const unlistedTyped = !!payload && !!type && type !== 'BPMN.Variables' && !
|
|
2875
|
+
const unlistedTyped = !!payload && !!type && type !== 'BPMN.Variables' && !listedSpec(type)
|
|
2876
|
+
&& (!ELEMENT_OWNS.has(localName(el.$type)) || carriesUnlistedTrigger(el, localName(el.$type), payload, type));
|
|
2793
2877
|
if (payload && type && (spelledOutScriptRows || unlistedTyped || (type !== 'BPMN.Variables' && typeDescribesElement(localName(el.$type), type)))) {
|
|
2794
2878
|
for (const row of payload.output ?? []) {
|
|
2795
2879
|
if (!row.var)
|
package/dist/bpmn/merge-cli.js
CHANGED
|
@@ -31,9 +31,12 @@
|
|
|
31
31
|
*
|
|
32
32
|
* After it writes over the original, merge decompiles the merged file the same way and
|
|
33
33
|
* rewrites the source's stamp with that digest, options kept, so the next
|
|
34
|
-
* edit-and-merge round on the same source passes the check
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* edit-and-merge round on the same source passes the check. It does so only after the
|
|
35
|
+
* check passed: under `--baseline` the original may hold changes the source lacks (a
|
|
36
|
+
* caller's baseline can keep them, as it should), and a stamp advanced over them would
|
|
37
|
+
* let the next round derive a baseline that has them and revert them. So the stamp
|
|
38
|
+
* stays, and the next round refuses until the source is decompiled again. With `-o`
|
|
39
|
+
* elsewhere the original and the stamp stay as they were.
|
|
37
40
|
*/
|
|
38
41
|
import { reportCompileRefusal, reportDiagnostics, reportResult } from '../cli-result.js';
|
|
39
42
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
@@ -239,14 +242,9 @@ export async function run(argv) {
|
|
|
239
242
|
const sides = await compileSides(argv, editedPath, originalPath, original, explicitBaseline, decompiled);
|
|
240
243
|
if (typeof sides === 'number')
|
|
241
244
|
return sides;
|
|
245
|
+
// `derive` is set only when the stamp check ran: under --baseline nothing showed
|
|
246
|
+
// that the source holds every change in the original, so the stamp is not advanced.
|
|
242
247
|
({ edited, baseline, derived, derive } = sides);
|
|
243
|
-
if (explicitBaseline !== undefined) {
|
|
244
|
-
// No stamp check under --baseline, but a readable stamp still says how to digest
|
|
245
|
-
// the merged file, so a merge written over the original restamps as it does without.
|
|
246
|
-
const stamp = readStamp(readFileSync(editedPath, 'utf8'));
|
|
247
|
-
if (stamp !== undefined && !('error' in stamp))
|
|
248
|
-
derive = stampedDecompile(stamp, openCliLibrary(argv));
|
|
249
|
-
}
|
|
250
248
|
}
|
|
251
249
|
else {
|
|
252
250
|
edited = readFileSync(editedPath, 'utf8');
|
|
@@ -262,8 +260,8 @@ export async function run(argv) {
|
|
|
262
260
|
// edit-and-merge round on the same source passes the check. The merged original is
|
|
263
261
|
// what the source, as it now stands, decompiles from; its digest is that of the merged
|
|
264
262
|
// file decompiled with the stamped options, which is what the next check derives.
|
|
265
|
-
// Written elsewhere, the original is unchanged and so is the stamp;
|
|
266
|
-
//
|
|
263
|
+
// Written elsewhere, the original is unchanged and so is the stamp; under --baseline
|
|
264
|
+
// the check did not run, so the stamp is not advanced (see the header).
|
|
267
265
|
let restamped = false;
|
|
268
266
|
if (derive && resolve(out) === resolve(originalPath)) {
|
|
269
267
|
const source = readFileSync(editedPath, 'utf8');
|
package/dist/bpmn/serialize.js
CHANGED
|
@@ -872,7 +872,7 @@ function attachExtensionPayload(ctx, el, payload) {
|
|
|
872
872
|
if (!payload)
|
|
873
873
|
return;
|
|
874
874
|
const ext = (el.extensionElements ??= ctx.m.create('bpmn:ExtensionElements', { values: [] }));
|
|
875
|
-
(ext.values ??= []).unshift(createExtensionPayload(ctx.m, payload.type, payload.outputRows));
|
|
875
|
+
(ext.values ??= []).unshift(createExtensionPayload(ctx.m, payload.type, payload.outputRows, { tag: payload.tag, typeVersion: payload.typeVersion }));
|
|
876
876
|
}
|
|
877
877
|
/**
|
|
878
878
|
* Attach what every ACTIVITY can carry — a retry policy and a multi-instance loop
|
|
@@ -451,7 +451,10 @@ export declare function verbatimOutputRows(m: BpmnModdle, rows: TypedOutputRow[]
|
|
|
451
451
|
* @param rows - Output rows, emitted verbatim.
|
|
452
452
|
* @returns The payload element, ready to go inside a `bpmn:ExtensionElements`.
|
|
453
453
|
*/
|
|
454
|
-
export declare function createExtensionPayload(m: BpmnModdle, type: string, rows: TypedOutputRow[]
|
|
454
|
+
export declare function createExtensionPayload(m: BpmnModdle, type: string, rows: TypedOutputRow[], carried?: {
|
|
455
|
+
tag?: string;
|
|
456
|
+
typeVersion?: string;
|
|
457
|
+
}): El;
|
|
455
458
|
/**
|
|
456
459
|
* The context fields this type requires to be a `=bindings.<id>` reference rather
|
|
457
460
|
* than a literal.
|
package/dist/bpmn/typed-node.js
CHANGED
|
@@ -655,19 +655,44 @@ export function verbatimOutputRows(m, rows) {
|
|
|
655
655
|
* @param rows - Output rows, emitted verbatim.
|
|
656
656
|
* @returns The payload element, ready to go inside a `bpmn:ExtensionElements`.
|
|
657
657
|
*/
|
|
658
|
-
export function createExtensionPayload(m, type, rows) {
|
|
659
|
-
const
|
|
660
|
-
if (!spec.tag) {
|
|
661
|
-
throw new CompileRefusal('BPMN_TYPE_NOT_AUTHORABLE', `extension type "${type}" has no tag in the registry snapshot; it cannot be authored.`);
|
|
662
|
-
}
|
|
658
|
+
export function createExtensionPayload(m, type, rows, carried) {
|
|
659
|
+
const tag = payloadTag(type, carried?.tag);
|
|
663
660
|
const payload = {
|
|
664
661
|
version: 'v1',
|
|
665
|
-
type: m.create('uipath:Type', { value: type, version: 'v1' }),
|
|
662
|
+
type: m.create('uipath:Type', { value: type, version: carried?.typeVersion ?? 'v1' }),
|
|
666
663
|
};
|
|
667
664
|
const out = verbatimOutputRows(m, rows);
|
|
668
665
|
if (out.length)
|
|
669
666
|
payload.output = out;
|
|
670
|
-
return m.create(moddleTypeOf(
|
|
667
|
+
return m.create(moddleTypeOf(tag), payload);
|
|
668
|
+
}
|
|
669
|
+
/** The three tags an extension payload is written under. */
|
|
670
|
+
const PAYLOAD_TAGS = new Set(['uipath:activity', 'uipath:event', 'uipath:mapping']);
|
|
671
|
+
/**
|
|
672
|
+
* The tag a decoration payload is written under: the snapshot's for a type it lists,
|
|
673
|
+
* else the tag the file carried, else whatever the registry says (which refuses an
|
|
674
|
+
* unknown type with `BPMN_TYPE_UNKNOWN`).
|
|
675
|
+
*
|
|
676
|
+
* A decoration needs nothing from the spec but its tag, so a type the snapshot lacks
|
|
677
|
+
* is fully described by the tag the file wrote it under — `uipath:type value="None"`
|
|
678
|
+
* inside a `uipath:activity` on a case trigger. The carried tag is the third source,
|
|
679
|
+
* after the snapshot and before the tenant: accepted, never demanded, and never
|
|
680
|
+
* allowed to override a type the snapshot knows. It is checked against the three
|
|
681
|
+
* tags that exist, so a typo still refuses instead of writing an element no reader
|
|
682
|
+
* knows.
|
|
683
|
+
*/
|
|
684
|
+
function payloadTag(type, carried) {
|
|
685
|
+
if (carried !== undefined && !isSnapshotType(type)) {
|
|
686
|
+
if (!PAYLOAD_TAGS.has(carried)) {
|
|
687
|
+
throw new CompileRefusal('BPMN_PAYLOAD_TAG_INVALID', `extension payload "${type}" carries tag "${carried}"; expected one of ${[...PAYLOAD_TAGS].join(', ')}.`);
|
|
688
|
+
}
|
|
689
|
+
return carried;
|
|
690
|
+
}
|
|
691
|
+
const spec = registryType(type);
|
|
692
|
+
if (!spec.tag) {
|
|
693
|
+
throw new CompileRefusal('BPMN_TYPE_NOT_AUTHORABLE', `extension type "${type}" has no tag in the registry snapshot; it cannot be authored.`);
|
|
694
|
+
}
|
|
695
|
+
return spec.tag;
|
|
671
696
|
}
|
|
672
697
|
/** Wrap a finished payload in its BPMN element. */
|
|
673
698
|
function finish(m, spec, id, name, payload) {
|
package/dist/bpmn-api.md
CHANGED
|
@@ -833,6 +833,8 @@ An extension payload carried by an element the payload does not describe.
|
|
|
833
833
|
|
|
834
834
|
- `ExtensionPayload.type: string` — The extension type, e.g. `'BPMN.Variables'` or `'uipath:Activity'`.
|
|
835
835
|
- `ExtensionPayload.outputRows: TypedOutputRow[]` — `uipath:output` rows, emitted exactly as given — see TypedOutputRow.
|
|
836
|
+
- `ExtensionPayload.tag?: 'uipath:activity' | 'uipath:event' | 'uipath:mapping'` — The payload's own tag — `'uipath:activity'`, `'uipath:event'` or `'uipath:mapping'` — for a `type` the registry snapshot…
|
|
837
|
+
- `ExtensionPayload.typeVersion?: string` — The `uipath:type` `version` attribute, when it is not `v1` — see `ActivityNodeOpts.typeVersion`.
|
|
836
838
|
|
|
837
839
|
### `GatewayKind`
|
|
838
840
|
|
|
@@ -121,12 +121,16 @@ export function registerFlowCommands(program) {
|
|
|
121
121
|
await invoke('flow decompile', () => import('../../decompile-cli.js'), argv);
|
|
122
122
|
});
|
|
123
123
|
flow.command('merge')
|
|
124
|
-
.description('Merge an edited flow with its original artifact.'
|
|
124
|
+
.description('Merge an edited flow with its original artifact. Given the edited .flow.ts source with the '
|
|
125
|
+
+ '`// @decompiled-from` stamp `flow decompile` writes, merge compiles it, derives the baseline from --original '
|
|
126
|
+
+ '(decompile, then compile) in memory with the decompile options the stamp records, and writes the result over '
|
|
127
|
+
+ '--original unless -o is given, so no intermediate .flow is needed. It refuses, writing nothing, when --original '
|
|
128
|
+
+ 'changed since the decompile. A source with no stamp merges as before.')
|
|
125
129
|
.argument('<edited>', 'edited .flow path, or the edited .flow.ts source (merge compiles it, tolerating untouched draft nodes)')
|
|
126
130
|
.option('--original <file>', '(required) original .flow path, the artifact to merge into')
|
|
127
|
-
.option('-o, --output <file>', 'merged output path')
|
|
128
|
-
.option('--baseline <file>', 'compiled pristine decompile')
|
|
129
|
-
.option('--baseline-from <file>', 'build the baseline from this original .flow (decompile + compile, tolerating draft nodes) instead of --baseline')
|
|
131
|
+
.option('-o, --output <file>', 'merged output path (default: merged.flow; for a stamped .flow.ts with no --baseline or --baseline-from, --original itself)')
|
|
132
|
+
.option('--baseline <file>', 'compiled pristine decompile (derived from --original for a stamped .flow.ts)')
|
|
133
|
+
.option('--baseline-from <file>', 'build the baseline from this original .flow (decompile + compile, tolerating draft nodes) instead of --baseline; checked against a stamped source')
|
|
130
134
|
.option('--library <dir>', 'connector library, for compiling with --baseline-from or a .flow.ts edited source')
|
|
131
135
|
.option('--bindings <file>', 'bindings.json, for the same compiles')
|
|
132
136
|
.option('--strict', 'refuse when the no-edit round trip (the baseline) differs from the original')
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** The marker that starts the stamp line. */
|
|
2
|
+
export declare const STAMP_MARKER = "// @decompiled-from ";
|
|
3
|
+
/** A stamp line, read or to write: the original, the digest, the family's option tokens. */
|
|
4
|
+
export interface StampLine {
|
|
5
|
+
/** The original's base name. */
|
|
6
|
+
file: string;
|
|
7
|
+
/** {@link sourceDigest} of the source decompile made of the original, lowercase hex. */
|
|
8
|
+
sha256: string;
|
|
9
|
+
/** The option tokens, `key=value` or `key`, in the order they are written. */
|
|
10
|
+
options: string[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The digest the stamp records: SHA-256, lowercase hex, of a source as decompile makes
|
|
14
|
+
* it (no stamp line), with the SDK import specifier replaced by a fixed one, so
|
|
15
|
+
* `--import` and the specifier merge decompiles against give the same digest.
|
|
16
|
+
*
|
|
17
|
+
* @param source - The decompiled source, before {@link stampSource}.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sourceDigest(source: string): string;
|
|
20
|
+
/** The stamp line, without a line terminator. */
|
|
21
|
+
export declare function formatStampLine(stamp: StampLine): string;
|
|
22
|
+
/** `source` with the stamp line in front of it. */
|
|
23
|
+
export declare function stampSource(source: string, stamp: StampLine): string;
|
|
24
|
+
/**
|
|
25
|
+
* Read the stamp line from a source: the first line that starts with
|
|
26
|
+
* {@link STAMP_MARKER}. The option tokens are returned as written; the family checks
|
|
27
|
+
* them.
|
|
28
|
+
*
|
|
29
|
+
* @returns The stamp and the line it was read from; `undefined` when the source has no
|
|
30
|
+
* stamp line; or `{ error }` when the line does not parse.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readStampLine(source: string): (StampLine & {
|
|
33
|
+
line: string;
|
|
34
|
+
}) | {
|
|
35
|
+
error: string;
|
|
36
|
+
} | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* `source` with its stamp line replaced by `line` (no terminator), the line ending kept.
|
|
39
|
+
* The family checks the old stamp first; this only swaps the text.
|
|
40
|
+
*
|
|
41
|
+
* @returns The new source, or `undefined` when `source` has no stamp line.
|
|
42
|
+
*/
|
|
43
|
+
export declare function replaceStampLine(source: string, line: string): string | undefined;
|