@mmmnt/cli 0.6.1 → 0.6.2

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 CHANGED
@@ -59505,7 +59505,7 @@ var MomentGrammar = () => loadedMomentGrammar ?? (loadedMomentGrammar = loadGram
59505
59505
  "name": "STRING",
59506
59506
  "definition": {
59507
59507
  "$type": "RegexToken",
59508
- "regex": "/\\"[^\\"]*\\"/",
59508
+ "regex": "/\\"(\\\\\\\\.|[^\\"\\\\\\\\])*\\"/",
59509
59509
  "parenthesized": false
59510
59510
  },
59511
59511
  "fragment": false,
@@ -59599,9 +59599,6 @@ function buildMomentSequence(moment) {
59599
59599
  }
59600
59600
 
59601
59601
  // ../core/dist/validation/moment-validator.js
59602
- function unquote(s) {
59603
- return s.startsWith('"') && s.endsWith('"') ? s.slice(1, -1) : s;
59604
- }
59605
59602
  function aggregateBlocks(agg, events) {
59606
59603
  const blocks = [];
59607
59604
  for (const aggMember of agg.members) {
@@ -59635,7 +59632,7 @@ function buildCrossFileContext(file) {
59635
59632
  const declaredBuildingBlocks = /* @__PURE__ */ new Map();
59636
59633
  const declaredSagas = [];
59637
59634
  for (const ctx of file.contexts) {
59638
- const contextName = unquote(ctx.name);
59635
+ const contextName = ctx.name;
59639
59636
  declaredContextNames.push(contextName);
59640
59637
  const events = [];
59641
59638
  const blocks = [];
@@ -59704,7 +59701,7 @@ function collectSiblingNames(field) {
59704
59701
  function laneDeclaresEvent(lane, eventName, ctx) {
59705
59702
  if (!lane)
59706
59703
  return false;
59707
- const events = ctx.declaredEvents.get(unquote(lane.label)) ?? [];
59704
+ const events = ctx.declaredEvents.get(lane.label) ?? [];
59708
59705
  return events.includes(eventName);
59709
59706
  }
59710
59707
  function getMomentFromNode(node) {
@@ -59729,9 +59726,9 @@ var MomentValidator = class {
59729
59726
  // V12: Deprecated field replacement must exist as sibling field
59730
59727
  // =========================================================================
59731
59728
  checkDeprecatedReplacement(field, accept) {
59732
- if (!field.deprecation)
59729
+ if (field.deprecation?.replacement === void 0)
59733
59730
  return;
59734
- const replacement = field.deprecation.replacement.replace(/^"|"$/g, "");
59731
+ const replacement = field.deprecation.replacement;
59735
59732
  const siblings = collectSiblingNames(field);
59736
59733
  if (siblings === void 0)
59737
59734
  return;
@@ -59977,7 +59974,7 @@ var MomentValidator = class {
59977
59974
  for (const lane of flow.lanes) {
59978
59975
  if (lane.isBranch || lane.classification?.value === "External")
59979
59976
  continue;
59980
- if (!ctx.declaredContextNames.includes(lane.label.replace(/^"|"$/g, ""))) {
59977
+ if (!ctx.declaredContextNames.includes(lane.label)) {
59981
59978
  accept("error", "SP-01: Lane label does not match any declared context name.", {
59982
59979
  node: lane,
59983
59980
  property: "label"
@@ -60019,7 +60016,7 @@ var MomentValidator = class {
60019
60016
  const lane = flow.lanes.find((l) => l.id === node.laneId);
60020
60017
  if (!lane || lane.isBranch)
60021
60018
  return;
60022
- const contextName = lane.label.replace(/^"|"$/g, "");
60019
+ const contextName = lane.label;
60023
60020
  const blocks = ctx.declaredBuildingBlocks.get(contextName) ?? [];
60024
60021
  const blockNames = blocks.map((b) => b.name);
60025
60022
  if (!blockNames.includes(node.nodeName)) {
@@ -60057,7 +60054,7 @@ var MomentValidator = class {
60057
60054
  const lane = flow.lanes.find((l) => l.id === node.laneId);
60058
60055
  if (!lane || lane.isBranch)
60059
60056
  return;
60060
- const contextName = lane.label.replace(/^"|"$/g, "");
60057
+ const contextName = lane.label;
60061
60058
  const blocks = ctx.declaredBuildingBlocks.get(contextName) ?? [];
60062
60059
  const block2 = blocks.find((b) => b.name === node.nodeName);
60063
60060
  if (block2 && block2.kind !== "event") {
@@ -60077,7 +60074,7 @@ var MomentValidator = class {
60077
60074
  const lane = flow.lanes.find((l) => l.id === node.laneId);
60078
60075
  if (!lane || lane.isBranch)
60079
60076
  return;
60080
- const contextName = lane.label.replace(/^"|"$/g, "");
60077
+ const contextName = lane.label;
60081
60078
  const blocks = ctx.declaredBuildingBlocks.get(contextName) ?? [];
60082
60079
  const block2 = blocks.find((b) => b.name === node.nodeName);
60083
60080
  if (block2 && block2.kind !== "event") {
@@ -60562,12 +60559,6 @@ function bindRelayEvents(contexts) {
60562
60559
  }
60563
60560
 
60564
60561
  // ../core/dist/parser/ast-to-ir.js
60565
- function unquote2(s) {
60566
- if (s.startsWith('"') && s.endsWith('"')) {
60567
- return s.slice(1, -1);
60568
- }
60569
- return s;
60570
- }
60571
60562
  function astToIr(file, metadata) {
60572
60563
  const contexts = bindRelayEvents(file.contexts.map(transformContext));
60573
60564
  const nodeKindMap = buildNodeKindMap(contexts);
@@ -60575,7 +60566,7 @@ function astToIr(file, metadata) {
60575
60566
  const externals = (file.externals ?? []).map((e) => ({
60576
60567
  id: `ext-${e.name}`,
60577
60568
  name: e.name,
60578
- description: unquote2(e.description),
60569
+ description: e.description,
60579
60570
  ...gatewaysOf(e.gateways ?? [])
60580
60571
  }));
60581
60572
  const externalNames = new Set(externals.map((e) => e.name));
@@ -60633,7 +60624,7 @@ function collectContextMember(member, annotations, out) {
60633
60624
  }
60634
60625
  }
60635
60626
  function transformContext(ctx) {
60636
- const name = unquote2(ctx.name);
60627
+ const name = ctx.name;
60637
60628
  const members = emptyContextMembers();
60638
60629
  let pendingAnnotations = [];
60639
60630
  for (const member of ctx.members) {
@@ -60648,7 +60639,7 @@ function transformContext(ctx) {
60648
60639
  id: `ctx-${name}`,
60649
60640
  name,
60650
60641
  classification: ctx.classification?.value,
60651
- description: ctx.description ? unquote2(ctx.description) : void 0,
60642
+ description: ctx.description ? ctx.description : void 0,
60652
60643
  aggregates: members.aggregates,
60653
60644
  domainServices: members.domainServices,
60654
60645
  commands: members.commands,
@@ -60667,7 +60658,7 @@ function transformProjection(proj) {
60667
60658
  id: `proj-${proj.name}`,
60668
60659
  name: proj.name,
60669
60660
  sources: [...proj.sources],
60670
- ...proj.description ? { description: unquote2(proj.description) } : {},
60661
+ ...proj.description ? { description: proj.description } : {},
60671
60662
  fields: proj.fields.map(transformFieldDeclaration),
60672
60663
  ...gatewaysOf(proj.gateways)
60673
60664
  };
@@ -60678,7 +60669,7 @@ function transformGateway(gw) {
60678
60669
  name: gw.name,
60679
60670
  consumes: gw.consumes,
60680
60671
  produces: gw.produces,
60681
- ...gw.description ? { description: unquote2(gw.description) } : {}
60672
+ ...gw.description ? { description: gw.description } : {}
60682
60673
  };
60683
60674
  }
60684
60675
  function gatewaysOf(gateways) {
@@ -60690,35 +60681,34 @@ function transformQuery(query) {
60690
60681
  name: query.name,
60691
60682
  reads: [...query.reads],
60692
60683
  inputs: query.inputs.map(transformFieldDeclaration),
60693
- ...query.description ? { description: unquote2(query.description) } : {}
60684
+ ...query.description ? { description: query.description } : {}
60694
60685
  };
60695
60686
  }
60696
60687
  function transformRule(rule) {
60697
60688
  return rule.enforcer ? {
60698
60689
  id: rule.id,
60699
- description: unquote2(rule.description),
60690
+ description: rule.description,
60700
60691
  enforcedBy: rule.enforcer,
60701
60692
  enforcerKind: "declared"
60702
60693
  } : {
60703
60694
  id: rule.id,
60704
- description: unquote2(rule.description),
60705
- enforcedBy: unquote2(rule.enforcerText ?? ""),
60695
+ description: rule.description,
60696
+ enforcedBy: rule.enforcerText ?? "",
60706
60697
  enforcerKind: "external"
60707
60698
  };
60708
60699
  }
60709
60700
  function extractGlossary(ctx) {
60710
- const context = unquote2(ctx.name);
60711
- return ctx.members.filter(isTermDeclaration).map((t) => ({ term: unquote2(t.term), definition: unquote2(t.definition), context }));
60701
+ const context = ctx.name;
60702
+ return ctx.members.filter(isTermDeclaration).map((t) => ({ term: t.term, definition: t.definition, context }));
60712
60703
  }
60713
60704
  function transformAnnotation(ann) {
60714
- const raw = ann.value;
60715
60705
  return {
60716
60706
  name: ann.name,
60717
- value: raw.startsWith('"') ? unquote2(raw) : raw
60707
+ value: ann.value
60718
60708
  };
60719
60709
  }
60720
60710
  function transformAggregate(agg, annotations) {
60721
- const name = unquote2(agg.name);
60711
+ const name = agg.name;
60722
60712
  const commands = [];
60723
60713
  const events = [];
60724
60714
  const valueObjects = [];
@@ -60777,7 +60767,7 @@ function transformCommand(cmd, annotations) {
60777
60767
  function transformPrecondition(pre) {
60778
60768
  return {
60779
60769
  name: pre.name,
60780
- description: unquote2(pre.description)
60770
+ description: pre.description
60781
60771
  };
60782
60772
  }
60783
60773
  function transformEvent(evt, annotations) {
@@ -60805,8 +60795,8 @@ function transformFieldDeclaration(field) {
60805
60795
  };
60806
60796
  if ("deprecation" in field && field.deprecation) {
60807
60797
  result.deprecated = {
60808
- reason: unquote2(field.deprecation.reason),
60809
- replacement: unquote2(field.deprecation.replacement)
60798
+ reason: field.deprecation.reason,
60799
+ replacement: field.deprecation.replacement
60810
60800
  };
60811
60801
  }
60812
60802
  return result;
@@ -60814,7 +60804,7 @@ function transformFieldDeclaration(field) {
60814
60804
  function transformInvariant(inv, annotations) {
60815
60805
  return {
60816
60806
  id: inv.id,
60817
- description: unquote2(inv.description),
60807
+ description: inv.description,
60818
60808
  scope: inv.scope,
60819
60809
  ...annotations ? { annotations } : {}
60820
60810
  };
@@ -60826,7 +60816,7 @@ function transformService(svc, annotations) {
60826
60816
  ...annotations ? { annotations } : {},
60827
60817
  consumes: svc.consumes,
60828
60818
  produces: svc.produces,
60829
- description: unquote2(svc.description)
60819
+ description: svc.description
60830
60820
  };
60831
60821
  }
60832
60822
  function transformPolicy(pol, annotations) {
@@ -60835,7 +60825,7 @@ function transformPolicy(pol, annotations) {
60835
60825
  name: pol.name,
60836
60826
  ...annotations ? { annotations } : {},
60837
60827
  trigger: pol.trigger,
60838
- action: unquote2(pol.action),
60828
+ action: pol.action,
60839
60829
  chainsTo: pol.chainsTo,
60840
60830
  ...gatewaysOf(pol.gateways)
60841
60831
  };
@@ -60888,7 +60878,7 @@ function transformSaga(saga, annotations) {
60888
60878
  function buildLaneContextMap(flow) {
60889
60879
  const map2 = /* @__PURE__ */ new Map();
60890
60880
  for (const lane of flow.lanes) {
60891
- map2.set(lane.id, `ctx-${unquote2(lane.label)}`);
60881
+ map2.set(lane.id, `ctx-${lane.label}`);
60892
60882
  }
60893
60883
  return map2;
60894
60884
  }
@@ -60933,11 +60923,11 @@ function buildNodeLaneMap(flow) {
60933
60923
  return map2;
60934
60924
  }
60935
60925
  function transformFlow(flow, nodeKindMap) {
60936
- const name = unquote2(flow.name);
60926
+ const name = flow.name;
60937
60927
  const laneContextMap = buildLaneContextMap(flow);
60938
60928
  const lanes = flow.lanes.map((lane) => ({
60939
60929
  id: lane.id,
60940
- label: unquote2(lane.label),
60930
+ label: lane.label,
60941
60931
  contextId: laneContextMap.get(lane.id) ?? lane.id,
60942
60932
  classification: lane.classification?.value,
60943
60933
  isBranch: lane.isBranch ?? false
@@ -60945,14 +60935,14 @@ function transformFlow(flow, nodeKindMap) {
60945
60935
  return {
60946
60936
  id: `flow-${name}`,
60947
60937
  name,
60948
- description: flow.description ? unquote2(flow.description) : void 0,
60938
+ description: flow.description ? flow.description : void 0,
60949
60939
  lanes,
60950
60940
  moments: flow.moments.map((moment, idx) => transformMoment(moment, idx, laneContextMap, nodeKindMap)),
60951
60941
  connections: extractConnections(flow, laneContextMap)
60952
60942
  };
60953
60943
  }
60954
60944
  function transformMoment(moment, index, laneContextMap, nodeKindMap) {
60955
- const name = unquote2(moment.label);
60945
+ const name = moment.label;
60956
60946
  const contextEntries = moment.nodes.map((n) => transformNodeToEntry(n, laneContextMap, nodeKindMap));
60957
60947
  const branches = moment.whenBlocks.length > 0 ? moment.whenBlocks.map((wb) => transformWhenBlock(wb, laneContextMap, nodeKindMap)) : void 0;
60958
60948
  const hasTerminal = contextEntries.some((e) => e.terminal === true) || (branches?.some((b) => b.entries.some((e) => e.terminal === true)) ?? false);
@@ -61012,12 +61002,12 @@ function extractConnections(flow, laneContextMap) {
61012
61002
  };
61013
61003
  const momentLabelToId = /* @__PURE__ */ new Map();
61014
61004
  for (let momentIdx = 0; momentIdx < flow.moments.length; momentIdx++) {
61015
- const label = unquote2(flow.moments[momentIdx].label);
61005
+ const label = flow.moments[momentIdx].label;
61016
61006
  momentLabelToId.set(label, `moment-${momentIdx}-${label.replace(/\s+/g, "-")}`);
61017
61007
  }
61018
61008
  for (let momentIdx = 0; momentIdx < flow.moments.length; momentIdx++) {
61019
61009
  const moment = flow.moments[momentIdx];
61020
- const momentId = `moment-${momentIdx}-${unquote2(moment.label).replace(/\s+/g, "-")}`;
61010
+ const momentId = `moment-${momentIdx}-${moment.label.replace(/\s+/g, "-")}`;
61021
61011
  const processNode = (node, branchCondition) => {
61022
61012
  const branchFields = branchCondition ? { branchCondition } : {};
61023
61013
  if (node.crossing) {
@@ -61057,7 +61047,7 @@ function extractConnections(flow, laneContextMap) {
61057
61047
  ...branchFields
61058
61048
  });
61059
61049
  } else if (isReturnsTo(conn)) {
61060
- const targetLabel = unquote2(conn.frameLabel);
61050
+ const targetLabel = conn.frameLabel;
61061
61051
  connections.push({
61062
61052
  id: `conn-${connectionCounter++}`,
61063
61053
  sourceMomentId: momentId,
@@ -61109,7 +61099,7 @@ function extractRelationships(ctx, externalNames = /* @__PURE__ */ new Set()) {
61109
61099
  sourceContextId: endId(rel.source, externalNames),
61110
61100
  targetContextId: endId(rel.target, externalNames),
61111
61101
  relationshipType: rel.type,
61112
- contract: unquote2(rel.contract)
61102
+ contract: rel.contract
61113
61103
  });
61114
61104
  }
61115
61105
  }
@@ -63095,7 +63085,7 @@ var SiftSpecificationImporter = class {
63095
63085
  generateContextFile(block2) {
63096
63086
  const lines = [];
63097
63087
  const classification = block2.classification ? ` [${block2.classification}]` : "";
63098
- lines.push(`context "${block2.contextName}"${classification}`);
63088
+ lines.push(`context "${escapeMomentString(block2.contextName)}"${classification}`);
63099
63089
  lines.push("");
63100
63090
  for (const agg of block2.aggregates) {
63101
63091
  this.renderAggregate(lines, agg);
@@ -63103,7 +63093,7 @@ var SiftSpecificationImporter = class {
63103
63093
  return lines.join("\n");
63104
63094
  }
63105
63095
  renderAggregate(lines, agg) {
63106
- lines.push(` aggregate "${agg.name}"`);
63096
+ lines.push(` aggregate "${escapeMomentString(agg.name)}"`);
63107
63097
  lines.push(` identity ${agg.identityField.name}: ${agg.identityField.type}`);
63108
63098
  lines.push("");
63109
63099
  for (const cmd of agg.commands) {
@@ -63132,18 +63122,18 @@ var SiftSpecificationImporter = class {
63132
63122
  }
63133
63123
  generateFlowFile(event) {
63134
63124
  const lines = [];
63135
- lines.push(`flow "${event.flowName}"`);
63125
+ lines.push(`flow "${escapeMomentString(event.flowName)}"`);
63136
63126
  if (event.description) {
63137
- lines.push(` description "${event.description}"`);
63127
+ lines.push(` description "${escapeMomentString(event.description)}"`);
63138
63128
  }
63139
63129
  lines.push("");
63140
63130
  for (const lane of event.lanes) {
63141
63131
  const classification = lane.classification ? ` [${lane.classification}]` : "";
63142
- lines.push(` lane ${lane.id} "${lane.label}"${classification}`);
63132
+ lines.push(` lane ${lane.id} "${escapeMomentString(lane.label)}"${classification}`);
63143
63133
  }
63144
63134
  lines.push("");
63145
63135
  for (const frame of event.frames) {
63146
- lines.push(` moment "${frame.label}"`);
63136
+ lines.push(` moment "${escapeMomentString(frame.label)}"`);
63147
63137
  for (const node of frame.nodes) {
63148
63138
  let nodeLine = ` ${node.laneId}: ${node.nodeName}`;
63149
63139
  if (node.crossing) {
@@ -68146,7 +68136,7 @@ function parseServeArgs(argv) {
68146
68136
  positionals[0]
68147
68137
  );
68148
68138
  if ("success" in target) return target;
68149
- const rawPort = values.port ?? "4321";
68139
+ const rawPort = values.port === void 0 ? "4321" : String(values.port);
68150
68140
  const port = parseInt(rawPort, 10);
68151
68141
  if (!Number.isInteger(port) || port < 1 || port > 65535) {
68152
68142
  return { success: false, message: `Error: Invalid port "${rawPort}". Expected 1-65535.` };
@@ -71585,7 +71575,12 @@ async function runImportFromSift(argv) {
71585
71575
  if (!domainDir) return fail13("Usage: moment import --from-sift <.domain/ directory>");
71586
71576
  const resolvedDir = resolve22(domainDir);
71587
71577
  if (!existsSync22(resolvedDir)) return fail13(`Error: Directory not found: ${resolvedDir}`);
71588
- return executeImport(resolvedDir, values["output-dir"], values.json === true);
71578
+ const outputDir = values["output-dir"];
71579
+ return executeImport(
71580
+ resolvedDir,
71581
+ typeof outputDir === "string" ? outputDir : void 0,
71582
+ values.json === true
71583
+ );
71589
71584
  }
71590
71585
  function executeImport(domainDir, outputDir, asJson) {
71591
71586
  const reader = new SiftEventStreamReader();
@@ -71746,7 +71741,11 @@ async function runStatus(argv) {
71746
71741
  }
71747
71742
  sections.push(buildUpstreamSection(resolvedPath));
71748
71743
  const hasDrift = sections.some((s) => s.state === "drift" || s.state === "error");
71749
- return formatOutput(sections, hasDrift, values);
71744
+ return formatOutput(sections, hasDrift, {
71745
+ verbose: Boolean(values.verbose),
71746
+ quiet: Boolean(values.quiet),
71747
+ json: Boolean(values.json)
71748
+ });
71750
71749
  }
71751
71750
  function buildParseSection(parseResult) {
71752
71751
  if (parseResult.success) {
@@ -71885,14 +71884,15 @@ async function runReconcile(argv) {
71885
71884
  allowPositionals: true,
71886
71885
  strict: false
71887
71886
  });
71888
- const validation = validateArgs(values, positionals);
71887
+ const event = typeof values.event === "string" ? values.event : void 0;
71888
+ const validation = validateArgs({ local: Boolean(values.local), event }, positionals);
71889
71889
  if (validation) return validation;
71890
71890
  const resolvedPath = resolve24(positionals[0]);
71891
71891
  const parsed = await parseSpec(resolvedPath);
71892
71892
  if (!("ir" in parsed)) return parsed;
71893
71893
  const asJson = values.json === true;
71894
- if (values.event) {
71895
- return reconcileFromEvent(parsed.ir, resolvedPath, values.event, asJson);
71894
+ if (event) {
71895
+ return reconcileFromEvent(parsed.ir, resolvedPath, event, asJson);
71896
71896
  }
71897
71897
  return reconcileLocal(parsed.ir, resolvedPath, asJson);
71898
71898
  }