@mmmnt/cli 0.9.0 → 0.10.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/moment.mjs +262 -6
- package/dist/moment.mjs.map +3 -3
- package/package.json +9 -9
package/dist/moment.mjs
CHANGED
|
@@ -55439,6 +55439,9 @@ var PolicyDeclaration = {
|
|
|
55439
55439
|
$type: "PolicyDeclaration",
|
|
55440
55440
|
action: "action",
|
|
55441
55441
|
chainsTo: "chainsTo",
|
|
55442
|
+
conditionAfter: "conditionAfter",
|
|
55443
|
+
conditionField: "conditionField",
|
|
55444
|
+
conditionValue: "conditionValue",
|
|
55442
55445
|
gateways: "gateways",
|
|
55443
55446
|
name: "name",
|
|
55444
55447
|
trigger: "trigger"
|
|
@@ -56130,6 +56133,18 @@ var MomentAstReflection = class extends AbstractAstReflection {
|
|
|
56130
56133
|
chainsTo: {
|
|
56131
56134
|
name: PolicyDeclaration.chainsTo
|
|
56132
56135
|
},
|
|
56136
|
+
conditionAfter: {
|
|
56137
|
+
name: PolicyDeclaration.conditionAfter,
|
|
56138
|
+
optional: true
|
|
56139
|
+
},
|
|
56140
|
+
conditionField: {
|
|
56141
|
+
name: PolicyDeclaration.conditionField,
|
|
56142
|
+
optional: true
|
|
56143
|
+
},
|
|
56144
|
+
conditionValue: {
|
|
56145
|
+
name: PolicyDeclaration.conditionValue,
|
|
56146
|
+
optional: true
|
|
56147
|
+
},
|
|
56133
56148
|
gateways: {
|
|
56134
56149
|
name: PolicyDeclaration.gateways,
|
|
56135
56150
|
defaultValue: [],
|
|
@@ -58059,6 +58074,66 @@ var MomentGrammar = () => loadedMomentGrammar ?? (loadedMomentGrammar = loadGram
|
|
|
58059
58074
|
"arguments": []
|
|
58060
58075
|
}
|
|
58061
58076
|
},
|
|
58077
|
+
{
|
|
58078
|
+
"$type": "Group",
|
|
58079
|
+
"elements": [
|
|
58080
|
+
{
|
|
58081
|
+
"$type": "Keyword",
|
|
58082
|
+
"value": "when"
|
|
58083
|
+
},
|
|
58084
|
+
{
|
|
58085
|
+
"$type": "Assignment",
|
|
58086
|
+
"feature": "conditionField",
|
|
58087
|
+
"operator": "=",
|
|
58088
|
+
"terminal": {
|
|
58089
|
+
"$type": "RuleCall",
|
|
58090
|
+
"rule": {
|
|
58091
|
+
"$ref": "#/rules@50"
|
|
58092
|
+
},
|
|
58093
|
+
"arguments": []
|
|
58094
|
+
}
|
|
58095
|
+
},
|
|
58096
|
+
{
|
|
58097
|
+
"$type": "Keyword",
|
|
58098
|
+
"value": "="
|
|
58099
|
+
},
|
|
58100
|
+
{
|
|
58101
|
+
"$type": "Assignment",
|
|
58102
|
+
"feature": "conditionValue",
|
|
58103
|
+
"operator": "=",
|
|
58104
|
+
"terminal": {
|
|
58105
|
+
"$type": "RuleCall",
|
|
58106
|
+
"rule": {
|
|
58107
|
+
"$ref": "#/rules@10"
|
|
58108
|
+
},
|
|
58109
|
+
"arguments": []
|
|
58110
|
+
}
|
|
58111
|
+
}
|
|
58112
|
+
],
|
|
58113
|
+
"cardinality": "?"
|
|
58114
|
+
},
|
|
58115
|
+
{
|
|
58116
|
+
"$type": "Group",
|
|
58117
|
+
"elements": [
|
|
58118
|
+
{
|
|
58119
|
+
"$type": "Keyword",
|
|
58120
|
+
"value": "after"
|
|
58121
|
+
},
|
|
58122
|
+
{
|
|
58123
|
+
"$type": "Assignment",
|
|
58124
|
+
"feature": "conditionAfter",
|
|
58125
|
+
"operator": "=",
|
|
58126
|
+
"terminal": {
|
|
58127
|
+
"$type": "RuleCall",
|
|
58128
|
+
"rule": {
|
|
58129
|
+
"$ref": "#/rules@56"
|
|
58130
|
+
},
|
|
58131
|
+
"arguments": []
|
|
58132
|
+
}
|
|
58133
|
+
}
|
|
58134
|
+
],
|
|
58135
|
+
"cardinality": "?"
|
|
58136
|
+
},
|
|
58062
58137
|
{
|
|
58063
58138
|
"$type": "Keyword",
|
|
58064
58139
|
"value": "action"
|
|
@@ -59222,6 +59297,10 @@ var MomentGrammar = () => loadedMomentGrammar ?? (loadedMomentGrammar = loadGram
|
|
|
59222
59297
|
{
|
|
59223
59298
|
"$type": "Keyword",
|
|
59224
59299
|
"value": "outcome"
|
|
59300
|
+
},
|
|
59301
|
+
{
|
|
59302
|
+
"$type": "Keyword",
|
|
59303
|
+
"value": "after"
|
|
59225
59304
|
}
|
|
59226
59305
|
]
|
|
59227
59306
|
},
|
|
@@ -59777,6 +59856,10 @@ var MomentGrammar = () => loadedMomentGrammar ?? (loadedMomentGrammar = loadGram
|
|
|
59777
59856
|
{
|
|
59778
59857
|
"$type": "Keyword",
|
|
59779
59858
|
"value": "outcome"
|
|
59859
|
+
},
|
|
59860
|
+
{
|
|
59861
|
+
"$type": "Keyword",
|
|
59862
|
+
"value": "after"
|
|
59780
59863
|
}
|
|
59781
59864
|
]
|
|
59782
59865
|
},
|
|
@@ -61061,6 +61144,76 @@ function validateMultiEvent(ir, options = {}) {
|
|
|
61061
61144
|
];
|
|
61062
61145
|
}
|
|
61063
61146
|
|
|
61147
|
+
// ../core/dist/validation/policy-condition.js
|
|
61148
|
+
function placedOrder(flow) {
|
|
61149
|
+
return flow.moments.flatMap((m) => [
|
|
61150
|
+
...m.contextEntries.map((e) => e.nodeName),
|
|
61151
|
+
...(m.branches ?? []).flatMap((b) => b.entries.map((e) => e.nodeName))
|
|
61152
|
+
]);
|
|
61153
|
+
}
|
|
61154
|
+
function someFlowPlacesBefore(flows, cause, trigger) {
|
|
61155
|
+
let triggerPlaced = false;
|
|
61156
|
+
for (const flow of flows) {
|
|
61157
|
+
const order = placedOrder(flow);
|
|
61158
|
+
const firstCause = order.indexOf(cause);
|
|
61159
|
+
const lastTrigger = order.lastIndexOf(trigger);
|
|
61160
|
+
if (lastTrigger >= 0)
|
|
61161
|
+
triggerPlaced = true;
|
|
61162
|
+
if (firstCause >= 0 && lastTrigger > firstCause)
|
|
61163
|
+
return { reached: true, triggerPlaced };
|
|
61164
|
+
}
|
|
61165
|
+
return { reached: false, triggerPlaced };
|
|
61166
|
+
}
|
|
61167
|
+
function fieldsByEvent(ir) {
|
|
61168
|
+
const events = /* @__PURE__ */ new Map();
|
|
61169
|
+
for (const ctx of ir.contexts)
|
|
61170
|
+
for (const e of ctx.events) {
|
|
61171
|
+
const fields = events.get(e.name) ?? /* @__PURE__ */ new Set();
|
|
61172
|
+
for (const f of e.fields ?? [])
|
|
61173
|
+
fields.add(f.name);
|
|
61174
|
+
events.set(e.name, fields);
|
|
61175
|
+
}
|
|
61176
|
+
return events;
|
|
61177
|
+
}
|
|
61178
|
+
function v49(p, events) {
|
|
61179
|
+
const c = p.condition;
|
|
61180
|
+
const fields = events.get(p.trigger);
|
|
61181
|
+
if (c?.field === void 0 || fields === void 0 || fields.has(c.field))
|
|
61182
|
+
return [];
|
|
61183
|
+
return [
|
|
61184
|
+
{
|
|
61185
|
+
ruleId: "V49",
|
|
61186
|
+
message: `Policy '${p.name}' reacts when '${c.field}' of '${p.trigger}' is '${c.equals ?? ""}', but '${p.trigger}' has no field '${c.field}'.`
|
|
61187
|
+
}
|
|
61188
|
+
];
|
|
61189
|
+
}
|
|
61190
|
+
function v50v51(p, events, flows) {
|
|
61191
|
+
const after = p.condition?.after;
|
|
61192
|
+
if (after === void 0)
|
|
61193
|
+
return [];
|
|
61194
|
+
if (!events.has(after))
|
|
61195
|
+
return [
|
|
61196
|
+
{
|
|
61197
|
+
ruleId: "V50",
|
|
61198
|
+
message: `Policy '${p.name}' reacts after '${after}', which is no declared event.`
|
|
61199
|
+
}
|
|
61200
|
+
];
|
|
61201
|
+
const { reached, triggerPlaced } = someFlowPlacesBefore(flows, after, p.trigger);
|
|
61202
|
+
if (!triggerPlaced || reached)
|
|
61203
|
+
return [];
|
|
61204
|
+
return [
|
|
61205
|
+
{
|
|
61206
|
+
ruleId: "V51",
|
|
61207
|
+
severity: "warning",
|
|
61208
|
+
message: `Policy '${p.name}' reacts to '${p.trigger}' after '${after}', but no flow places '${after}' before '${p.trigger}'; the condition is never met.`
|
|
61209
|
+
}
|
|
61210
|
+
];
|
|
61211
|
+
}
|
|
61212
|
+
function validatePolicyConditions(ir) {
|
|
61213
|
+
const events = fieldsByEvent(ir);
|
|
61214
|
+
return ir.contexts.flatMap((ctx) => ctx.policies.filter((p) => p.condition !== void 0).flatMap((p) => [...v49(p, events), ...v50v51(p, events, ir.flows ?? [])]));
|
|
61215
|
+
}
|
|
61216
|
+
|
|
61064
61217
|
// ../core/dist/validation/palette-conformance.js
|
|
61065
61218
|
function namesOf2(ir) {
|
|
61066
61219
|
const contexts = ir.contexts;
|
|
@@ -61314,6 +61467,7 @@ function validatePaletteConformance(ir, options = {}) {
|
|
|
61314
61467
|
...v41v42Placements(ir, commands),
|
|
61315
61468
|
...v43(ir),
|
|
61316
61469
|
...validateMultiEvent(ir, options),
|
|
61470
|
+
...validatePolicyConditions(ir),
|
|
61317
61471
|
...(ir.externals ?? []).flatMap((e) => gatewayFindings(`external '${e.name}'`, e.gateways ?? [], known))
|
|
61318
61472
|
];
|
|
61319
61473
|
}
|
|
@@ -61623,6 +61777,12 @@ function transformPolicy(pol, annotations) {
|
|
|
61623
61777
|
trigger: pol.trigger,
|
|
61624
61778
|
action: pol.action,
|
|
61625
61779
|
chainsTo: pol.chainsTo,
|
|
61780
|
+
...pol.conditionField !== void 0 || pol.conditionAfter !== void 0 ? {
|
|
61781
|
+
condition: {
|
|
61782
|
+
...pol.conditionField !== void 0 ? { field: pol.conditionField, equals: pol.conditionValue } : {},
|
|
61783
|
+
...pol.conditionAfter !== void 0 ? { after: pol.conditionAfter } : {}
|
|
61784
|
+
}
|
|
61785
|
+
} : {},
|
|
61626
61786
|
...gatewaysOf(pol.gateways)
|
|
61627
61787
|
};
|
|
61628
61788
|
}
|
|
@@ -64219,7 +64379,11 @@ function validateCrossFileReferences(ir) {
|
|
|
64219
64379
|
}
|
|
64220
64380
|
|
|
64221
64381
|
// ../core/dist/project/project-loader.js
|
|
64222
|
-
var
|
|
64382
|
+
var FIRST_COMPLETENESS_RULE = 22;
|
|
64383
|
+
var isCompletenessRule = (d) => {
|
|
64384
|
+
const n = /^V(\d+)$/.exec(d.ruleId ?? "")?.[1];
|
|
64385
|
+
return n !== void 0 && Number(n) >= FIRST_COMPLETENESS_RULE;
|
|
64386
|
+
};
|
|
64223
64387
|
var ProjectLoader = class {
|
|
64224
64388
|
parser;
|
|
64225
64389
|
constructor(parser) {
|
|
@@ -64850,6 +65014,7 @@ function multiEventPlacements(steps, commandOf) {
|
|
|
64850
65014
|
}
|
|
64851
65015
|
|
|
64852
65016
|
// ../derive/dist/engine/simulation-scenario-generator.js
|
|
65017
|
+
var BRANCH_KEY = "$branch";
|
|
64853
65018
|
function resolveNodeKind(nodeName, contextId, contextMap, declaredKind) {
|
|
64854
65019
|
const ctx = contextMap.get(contextId);
|
|
64855
65020
|
if (!ctx)
|
|
@@ -65118,6 +65283,7 @@ function generateEvents(nodes, flow, contextMap, sessionId, correlationId, baseT
|
|
|
65118
65283
|
const eventIds = nodes.map((_, i) => `evt-${String(i + 1).padStart(3, "0")}`);
|
|
65119
65284
|
const placements2 = placementsOf(nodes, contextMap);
|
|
65120
65285
|
const commandOfEvent = new Map(placements2.flatMap((p) => p.events.map((k) => [k, p.command])));
|
|
65286
|
+
const conditioned = policyConditionedOccurrences(nodes, flow, contextMap);
|
|
65121
65287
|
for (let i = 0; i < nodes.length; i++) {
|
|
65122
65288
|
const node = nodes[i];
|
|
65123
65289
|
const recordedBy = commandOfEvent.get(i);
|
|
@@ -65127,6 +65293,7 @@ function generateEvents(nodes, flow, contextMap, sessionId, correlationId, baseT
|
|
|
65127
65293
|
const eventType = resolveEventType(node, effectiveKind);
|
|
65128
65294
|
const productSource = resolveProductSource(node, effectiveKind, contextMap);
|
|
65129
65295
|
const payload = buildPayload(node, effectiveKind, contextMap, flow);
|
|
65296
|
+
applyPolicyConditions(payload, i, node, conditioned, contextMap);
|
|
65130
65297
|
const whenState = placements2.find((p) => p.command === i)?.whenState;
|
|
65131
65298
|
if (whenState !== void 0)
|
|
65132
65299
|
payload.whenState = whenState;
|
|
@@ -65144,6 +65311,89 @@ function generateEvents(nodes, flow, contextMap, sessionId, correlationId, baseT
|
|
|
65144
65311
|
}
|
|
65145
65312
|
return events;
|
|
65146
65313
|
}
|
|
65314
|
+
function guardedPolicies(contextMap) {
|
|
65315
|
+
const byTrigger = /* @__PURE__ */ new Map();
|
|
65316
|
+
for (const ctx of contextMap.values())
|
|
65317
|
+
for (const policy of ctx.policies) {
|
|
65318
|
+
if (policy.condition?.field === void 0)
|
|
65319
|
+
continue;
|
|
65320
|
+
byTrigger.set(policy.trigger, [...byTrigger.get(policy.trigger) ?? [], policy]);
|
|
65321
|
+
}
|
|
65322
|
+
return byTrigger;
|
|
65323
|
+
}
|
|
65324
|
+
function policyConditionedOccurrences(nodes, flow, contextMap) {
|
|
65325
|
+
const guarded = guardedPolicies(contextMap);
|
|
65326
|
+
const named = /* @__PURE__ */ new Map();
|
|
65327
|
+
if (guarded.size === 0)
|
|
65328
|
+
return named;
|
|
65329
|
+
nodes.forEach((node, index) => {
|
|
65330
|
+
for (const conn of flow.connections) {
|
|
65331
|
+
if (!isCausationConnectionFor(conn, node))
|
|
65332
|
+
continue;
|
|
65333
|
+
const triggerName = conn.sourceNodeName ?? conn.eventId.replace(/^evt-/, "");
|
|
65334
|
+
const policies = (guarded.get(triggerName) ?? []).filter((p) => p.chainsTo === node.nodeName);
|
|
65335
|
+
if (policies.length === 0)
|
|
65336
|
+
continue;
|
|
65337
|
+
for (let j = index - 1; j >= 0; j--) {
|
|
65338
|
+
if (nodes[j].nodeName !== triggerName)
|
|
65339
|
+
continue;
|
|
65340
|
+
named.set(j, [...named.get(j) ?? [], ...policies]);
|
|
65341
|
+
break;
|
|
65342
|
+
}
|
|
65343
|
+
}
|
|
65344
|
+
});
|
|
65345
|
+
return named;
|
|
65346
|
+
}
|
|
65347
|
+
function typedValue(type, value) {
|
|
65348
|
+
if (type === "number" && value.trim() !== "" && !Number.isNaN(Number(value)))
|
|
65349
|
+
return Number(value);
|
|
65350
|
+
if (type === "boolean" && (value === "true" || value === "false"))
|
|
65351
|
+
return value === "true";
|
|
65352
|
+
return value;
|
|
65353
|
+
}
|
|
65354
|
+
function otherThan(value) {
|
|
65355
|
+
if (typeof value === "number")
|
|
65356
|
+
return value + 1;
|
|
65357
|
+
if (typeof value === "boolean")
|
|
65358
|
+
return !value;
|
|
65359
|
+
return `${String(value)}-other`;
|
|
65360
|
+
}
|
|
65361
|
+
function guardedField(policy, payload) {
|
|
65362
|
+
const field = policy.condition?.field;
|
|
65363
|
+
return field !== void 0 && field in payload ? field : void 0;
|
|
65364
|
+
}
|
|
65365
|
+
function declaredValue(evt, policy) {
|
|
65366
|
+
const field = policy.condition?.field ?? "";
|
|
65367
|
+
const type = evt.fields.find((f) => f.name === field)?.type ?? "";
|
|
65368
|
+
return typedValue(type, policy.condition?.equals ?? "");
|
|
65369
|
+
}
|
|
65370
|
+
function moveOffDeclared(payload, guarded, evt, fixed) {
|
|
65371
|
+
for (const policy of guarded) {
|
|
65372
|
+
const field = guardedField(policy, payload);
|
|
65373
|
+
if (field === void 0 || fixed.has(field))
|
|
65374
|
+
continue;
|
|
65375
|
+
const declared = declaredValue(evt, policy);
|
|
65376
|
+
if (payload[field] === declared)
|
|
65377
|
+
payload[field] = otherThan(declared);
|
|
65378
|
+
}
|
|
65379
|
+
}
|
|
65380
|
+
function applyPolicyConditions(payload, index, node, conditioned, contextMap) {
|
|
65381
|
+
const ctx = contextMap.get(node.contextId);
|
|
65382
|
+
const evt = ctx ? findEvent(ctx, node.nodeName) : void 0;
|
|
65383
|
+
if (!evt)
|
|
65384
|
+
return;
|
|
65385
|
+
const guarded = [...contextMap.values()].flatMap((c) => c.policies.filter((p) => p.trigger === node.nodeName && p.condition?.field !== void 0));
|
|
65386
|
+
const naming = conditioned.get(index) ?? [];
|
|
65387
|
+
const fixed = /* @__PURE__ */ new Set();
|
|
65388
|
+
for (const policy of guarded.filter((p) => naming.includes(p))) {
|
|
65389
|
+
const field = guardedField(policy, payload);
|
|
65390
|
+
if (field === void 0 || fixed.has(field))
|
|
65391
|
+
continue;
|
|
65392
|
+
payload[field] = declaredValue(evt, policy);
|
|
65393
|
+
fixed.add(field);
|
|
65394
|
+
}
|
|
65395
|
+
moveOffDeclared(payload, guarded, evt, fixed);
|
|
65396
|
+
}
|
|
65147
65397
|
function findCausationEvents(node, allNodes, flow, eventIds, currentIndex, recordedBy) {
|
|
65148
65398
|
const causation = [];
|
|
65149
65399
|
for (const conn of flow.connections) {
|
|
@@ -65220,11 +65470,16 @@ function buildPayload(node, effectiveKind, contextMap, flow) {
|
|
|
65220
65470
|
}
|
|
65221
65471
|
}
|
|
65222
65472
|
addContractFields(payload, node, flow);
|
|
65223
|
-
|
|
65224
|
-
payload.outcome = node.outcome;
|
|
65225
|
-
}
|
|
65473
|
+
stampBranch(payload, node);
|
|
65226
65474
|
return payload;
|
|
65227
65475
|
}
|
|
65476
|
+
function stampBranch(payload, node) {
|
|
65477
|
+
if (node.outcome === void 0)
|
|
65478
|
+
return;
|
|
65479
|
+
payload[BRANCH_KEY] = node.outcome;
|
|
65480
|
+
if (!("outcome" in payload))
|
|
65481
|
+
payload.outcome = node.outcome;
|
|
65482
|
+
}
|
|
65228
65483
|
function addContractFields(payload, node, flow) {
|
|
65229
65484
|
for (const conn of flow.connections) {
|
|
65230
65485
|
if (conn.connectionType !== "crosses-to")
|
|
@@ -65604,7 +65859,8 @@ function generatePolicyDefinitions(ir) {
|
|
|
65604
65859
|
contextId: context.id,
|
|
65605
65860
|
trigger: policy.trigger,
|
|
65606
65861
|
...policy.action ? { actionDescription: policy.action } : {},
|
|
65607
|
-
chainsTo: normalizeChainsTo(policy.chainsTo)
|
|
65862
|
+
chainsTo: normalizeChainsTo(policy.chainsTo),
|
|
65863
|
+
...policy.condition ? { condition: { ...policy.condition } } : {}
|
|
65608
65864
|
});
|
|
65609
65865
|
}
|
|
65610
65866
|
}
|
|
@@ -66418,7 +66674,7 @@ function buildBranchPredicates(flow) {
|
|
|
66418
66674
|
routes[branch.condition] = branch.condition;
|
|
66419
66675
|
}
|
|
66420
66676
|
predicates[moment.id] = {
|
|
66421
|
-
field:
|
|
66677
|
+
field: BRANCH_KEY,
|
|
66422
66678
|
defaultRoute: moment.branches[0].condition,
|
|
66423
66679
|
routes
|
|
66424
66680
|
};
|