emviz 0.5.0 → 0.7.0
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/app/assets/index-DIqrEizp.js +171 -0
- package/dist/app/assets/index-DbiIL9PS.css +1 -0
- package/dist/app/index.html +2 -2
- package/dist/feedback.d.ts +2 -0
- package/dist/feedback.d.ts.map +1 -1
- package/dist/gitSources.d.ts.map +1 -1
- package/dist/index.js +292 -30
- package/dist/index.js.map +4 -4
- package/package.json +3 -3
- package/dist/app/assets/index-BKXoiIr_.js +0 -171
- package/dist/app/assets/index-BYP_gny3.css +0 -1
package/dist/index.js
CHANGED
|
@@ -13115,12 +13115,217 @@ import { fileURLToPath } from "node:url";
|
|
|
13115
13115
|
|
|
13116
13116
|
// ../parser/dist/index.js
|
|
13117
13117
|
var import_fast_glob = __toESM(require_out4(), 1);
|
|
13118
|
-
var
|
|
13118
|
+
var import_yaml5 = __toESM(require_dist(), 1);
|
|
13119
13119
|
import fs2 from "node:fs";
|
|
13120
13120
|
import path2 from "node:path";
|
|
13121
13121
|
|
|
13122
|
-
// ../parser/dist/
|
|
13122
|
+
// ../parser/dist/features.js
|
|
13123
13123
|
var import_yaml = __toESM(require_dist(), 1);
|
|
13124
|
+
function record(value) {
|
|
13125
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
13126
|
+
}
|
|
13127
|
+
function identifier(value) {
|
|
13128
|
+
return typeof value === "string" && value.length > 0 && value.trim() === value;
|
|
13129
|
+
}
|
|
13130
|
+
function documentIssues(content, path8, kind) {
|
|
13131
|
+
let raw;
|
|
13132
|
+
try {
|
|
13133
|
+
raw = import_yaml.default.parse(content);
|
|
13134
|
+
} catch (error) {
|
|
13135
|
+
return [{ check: "F1", path: path8, message: `Invalid YAML: ${error instanceof Error ? error.message : String(error)}` }];
|
|
13136
|
+
}
|
|
13137
|
+
if (!record(raw))
|
|
13138
|
+
return [];
|
|
13139
|
+
const issues = [];
|
|
13140
|
+
if (raw.kind !== void 0 && raw.kind !== kind) {
|
|
13141
|
+
issues.push({ check: "F1", path: path8, message: `Expected kind "${kind}", received "${String(raw.kind)}".` });
|
|
13142
|
+
}
|
|
13143
|
+
if (raw.schema_version !== void 0 && raw.schema_version !== 1) {
|
|
13144
|
+
issues.push({ check: "F1", path: path8, message: `Unsupported schema_version "${String(raw.schema_version)}". Supported version is 1.` });
|
|
13145
|
+
}
|
|
13146
|
+
if (raw.kind === void 0 !== (raw.schema_version === void 0)) {
|
|
13147
|
+
issues.push({ check: "F1", path: path8, message: "kind and schema_version must be supplied together." });
|
|
13148
|
+
}
|
|
13149
|
+
return issues;
|
|
13150
|
+
}
|
|
13151
|
+
function parseFeatureFiles(files) {
|
|
13152
|
+
const stories = [];
|
|
13153
|
+
const timelines = [];
|
|
13154
|
+
const modelIssues = [];
|
|
13155
|
+
const featureIds = /* @__PURE__ */ new Set();
|
|
13156
|
+
for (const file of files) {
|
|
13157
|
+
const issue = (message) => modelIssues.push({ check: "F1", path: file.path, message });
|
|
13158
|
+
let raw;
|
|
13159
|
+
try {
|
|
13160
|
+
raw = import_yaml.default.parse(file.content);
|
|
13161
|
+
} catch (error) {
|
|
13162
|
+
issue(`Invalid feature YAML: ${error instanceof Error ? error.message : String(error)}`);
|
|
13163
|
+
continue;
|
|
13164
|
+
}
|
|
13165
|
+
if (!record(raw)) {
|
|
13166
|
+
issue("Feature document must be a mapping.");
|
|
13167
|
+
continue;
|
|
13168
|
+
}
|
|
13169
|
+
if (raw.kind !== "feature" || raw.schema_version !== 1) {
|
|
13170
|
+
issue('Feature document requires kind "feature" and schema_version 1.');
|
|
13171
|
+
continue;
|
|
13172
|
+
}
|
|
13173
|
+
if (!identifier(raw.id)) {
|
|
13174
|
+
issue("Feature requires a nonempty string id.");
|
|
13175
|
+
continue;
|
|
13176
|
+
}
|
|
13177
|
+
if (featureIds.has(raw.id)) {
|
|
13178
|
+
issue(`Duplicate feature id "${raw.id}".`);
|
|
13179
|
+
continue;
|
|
13180
|
+
}
|
|
13181
|
+
featureIds.add(raw.id);
|
|
13182
|
+
const featureIssueStart = modelIssues.length;
|
|
13183
|
+
if (!identifier(raw.name))
|
|
13184
|
+
issue("Feature name must be a nonempty string without surrounding whitespace.");
|
|
13185
|
+
const featureName = identifier(raw.name) ? raw.name : file.path;
|
|
13186
|
+
const localStories = /* @__PURE__ */ new Map();
|
|
13187
|
+
if (!Array.isArray(raw.stories)) {
|
|
13188
|
+
issue("Feature stories must be an array.");
|
|
13189
|
+
} else {
|
|
13190
|
+
for (const entry of raw.stories) {
|
|
13191
|
+
if (!record(entry) || !identifier(entry.id)) {
|
|
13192
|
+
issue("Each story requires a nonempty string id.");
|
|
13193
|
+
continue;
|
|
13194
|
+
}
|
|
13195
|
+
if (localStories.has(entry.id)) {
|
|
13196
|
+
issue(`Duplicate story id "${entry.id}".`);
|
|
13197
|
+
continue;
|
|
13198
|
+
}
|
|
13199
|
+
if (!identifier(entry.name))
|
|
13200
|
+
issue(`Story "${entry.id}" requires a nonempty name.`);
|
|
13201
|
+
const slices = [];
|
|
13202
|
+
if (!Array.isArray(entry.slices)) {
|
|
13203
|
+
issue(`Story "${entry.id}" slices must be an array.`);
|
|
13204
|
+
} else {
|
|
13205
|
+
for (const slice of entry.slices) {
|
|
13206
|
+
if (!identifier(slice) || slice.startsWith("/") || /^[A-Za-z]:/.test(slice) || slice.includes("\\") || slice.split("/").includes("..")) {
|
|
13207
|
+
issue(`Story "${entry.id}" slice references must be project-relative paths without parent traversal.`);
|
|
13208
|
+
continue;
|
|
13209
|
+
}
|
|
13210
|
+
const normalized = slice.split("/").filter((part) => part && part !== ".").join("/");
|
|
13211
|
+
if (!normalized) {
|
|
13212
|
+
issue(`Story "${entry.id}" slice reference must identify a file, not the project root.`);
|
|
13213
|
+
continue;
|
|
13214
|
+
}
|
|
13215
|
+
if (slices.includes(normalized))
|
|
13216
|
+
issue(`Story "${entry.id}" repeats slice "${normalized}".`);
|
|
13217
|
+
else
|
|
13218
|
+
slices.push(normalized);
|
|
13219
|
+
}
|
|
13220
|
+
}
|
|
13221
|
+
const story = {
|
|
13222
|
+
id: JSON.stringify([raw.id, entry.id]),
|
|
13223
|
+
localId: entry.id,
|
|
13224
|
+
featureName,
|
|
13225
|
+
name: identifier(entry.name) ? entry.name : entry.id,
|
|
13226
|
+
description: typeof entry.description === "string" ? entry.description : "",
|
|
13227
|
+
path: file.path,
|
|
13228
|
+
slices
|
|
13229
|
+
};
|
|
13230
|
+
localStories.set(entry.id, story);
|
|
13231
|
+
stories.push(story);
|
|
13232
|
+
}
|
|
13233
|
+
}
|
|
13234
|
+
if (modelIssues.length > featureIssueStart)
|
|
13235
|
+
continue;
|
|
13236
|
+
if (!Array.isArray(raw.timelines)) {
|
|
13237
|
+
issue("Feature timelines must be an array.");
|
|
13238
|
+
continue;
|
|
13239
|
+
}
|
|
13240
|
+
const timelineIds = /* @__PURE__ */ new Set();
|
|
13241
|
+
for (const entry of raw.timelines) {
|
|
13242
|
+
const issueStart = modelIssues.length;
|
|
13243
|
+
if (!record(entry) || !identifier(entry.id)) {
|
|
13244
|
+
issue("Each timeline requires a nonempty string id.");
|
|
13245
|
+
continue;
|
|
13246
|
+
}
|
|
13247
|
+
if (timelineIds.has(entry.id)) {
|
|
13248
|
+
issue(`Duplicate timeline id "${entry.id}".`);
|
|
13249
|
+
continue;
|
|
13250
|
+
}
|
|
13251
|
+
timelineIds.add(entry.id);
|
|
13252
|
+
if (!identifier(entry.name))
|
|
13253
|
+
issue(`Timeline "${entry.id}" requires a nonempty name.`);
|
|
13254
|
+
if (!Array.isArray(entry.steps) || entry.steps.length === 0) {
|
|
13255
|
+
issue(`Timeline "${entry.id}" steps must be a nonempty array.`);
|
|
13256
|
+
continue;
|
|
13257
|
+
}
|
|
13258
|
+
const steps = [];
|
|
13259
|
+
const stepIds = /* @__PURE__ */ new Set();
|
|
13260
|
+
const usedStories = /* @__PURE__ */ new Set();
|
|
13261
|
+
const usedSlices = /* @__PURE__ */ new Set();
|
|
13262
|
+
for (const step of entry.steps) {
|
|
13263
|
+
if (!record(step) || !identifier(step.id)) {
|
|
13264
|
+
issue(`Timeline "${entry.id}" requires a string id for every step.`);
|
|
13265
|
+
continue;
|
|
13266
|
+
}
|
|
13267
|
+
if (stepIds.has(step.id))
|
|
13268
|
+
issue(`Timeline "${entry.id}" repeats step id "${step.id}".`);
|
|
13269
|
+
stepIds.add(step.id);
|
|
13270
|
+
const story = typeof step.story === "string" ? localStories.get(step.story) : void 0;
|
|
13271
|
+
if (!story) {
|
|
13272
|
+
issue(`Timeline "${entry.id}" step "${step.id}" references unknown story "${String(step.story)}".`);
|
|
13273
|
+
continue;
|
|
13274
|
+
}
|
|
13275
|
+
if (usedStories.has(story.id))
|
|
13276
|
+
issue(`Timeline "${entry.id}" repeats story "${step.story}". Use separate timelines for alternative presentations.`);
|
|
13277
|
+
usedStories.add(story.id);
|
|
13278
|
+
for (const slice of story.slices) {
|
|
13279
|
+
if (usedSlices.has(slice))
|
|
13280
|
+
issue(`Timeline "${entry.id}" repeats slice "${slice}" across stories.`);
|
|
13281
|
+
usedSlices.add(slice);
|
|
13282
|
+
}
|
|
13283
|
+
const after = [];
|
|
13284
|
+
if (step.after !== void 0) {
|
|
13285
|
+
if (!Array.isArray(step.after) || !step.after.every(identifier)) {
|
|
13286
|
+
issue(`Timeline "${entry.id}" step "${step.id}" after must be an array of step ids.`);
|
|
13287
|
+
} else {
|
|
13288
|
+
for (const predecessor of step.after) {
|
|
13289
|
+
if (after.includes(predecessor))
|
|
13290
|
+
issue(`Step "${step.id}" repeats predecessor "${predecessor}".`);
|
|
13291
|
+
else
|
|
13292
|
+
after.push(predecessor);
|
|
13293
|
+
}
|
|
13294
|
+
}
|
|
13295
|
+
}
|
|
13296
|
+
steps.push({ id: step.id, storyId: story.id, after });
|
|
13297
|
+
}
|
|
13298
|
+
for (const step of steps) {
|
|
13299
|
+
for (const predecessor of step.after) {
|
|
13300
|
+
if (!stepIds.has(predecessor))
|
|
13301
|
+
issue(`Step "${step.id}" references unknown predecessor "${predecessor}".`);
|
|
13302
|
+
}
|
|
13303
|
+
}
|
|
13304
|
+
const pending = new Set(steps.map((step) => step.id));
|
|
13305
|
+
while (pending.size > 0) {
|
|
13306
|
+
const ready = steps.filter((step) => pending.has(step.id) && step.after.every((id) => !pending.has(id)));
|
|
13307
|
+
if (ready.length === 0) {
|
|
13308
|
+
issue(`Timeline "${entry.id}" contains a layout cycle involving ${[...pending].join(", ")}.`);
|
|
13309
|
+
break;
|
|
13310
|
+
}
|
|
13311
|
+
for (const step of ready)
|
|
13312
|
+
pending.delete(step.id);
|
|
13313
|
+
}
|
|
13314
|
+
if (modelIssues.length === issueStart) {
|
|
13315
|
+
timelines.push({
|
|
13316
|
+
id: JSON.stringify([raw.id, entry.id]),
|
|
13317
|
+
name: entry.name,
|
|
13318
|
+
path: file.path,
|
|
13319
|
+
steps
|
|
13320
|
+
});
|
|
13321
|
+
}
|
|
13322
|
+
}
|
|
13323
|
+
}
|
|
13324
|
+
return { stories, timelines, modelIssues };
|
|
13325
|
+
}
|
|
13326
|
+
|
|
13327
|
+
// ../parser/dist/actors.js
|
|
13328
|
+
var import_yaml2 = __toESM(require_dist(), 1);
|
|
13124
13329
|
var palette = ["#2563EB", "#7C3AED", "#0F766E", "#B45309", "#BE185D", "#4338CA", "#047857", "#9F1239"];
|
|
13125
13330
|
function actorColor(id) {
|
|
13126
13331
|
let hash = 0;
|
|
@@ -13153,7 +13358,7 @@ function loadActors(content, sourcePath, slices) {
|
|
|
13153
13358
|
if (content !== void 0) {
|
|
13154
13359
|
let raw;
|
|
13155
13360
|
try {
|
|
13156
|
-
raw =
|
|
13361
|
+
raw = import_yaml2.default.parse(content);
|
|
13157
13362
|
} catch (error) {
|
|
13158
13363
|
issue(`Invalid actor registry: ${error instanceof Error ? error.message : String(error)}`);
|
|
13159
13364
|
}
|
|
@@ -13244,7 +13449,7 @@ function graphIds(project) {
|
|
|
13244
13449
|
identities.set(base, keys);
|
|
13245
13450
|
};
|
|
13246
13451
|
for (const story of project.stories)
|
|
13247
|
-
register(storyId(story.path), [story.path]);
|
|
13452
|
+
register(storyId(story.id ?? story.path), [story.id ?? story.path]);
|
|
13248
13453
|
for (const event of project.events)
|
|
13249
13454
|
register(eventId(event.name), [event.name]);
|
|
13250
13455
|
for (const slice of project.slices) {
|
|
@@ -13282,11 +13487,11 @@ function buildGraph(project) {
|
|
|
13282
13487
|
edges.set(key, { id: key, kind, source, target, ...label === void 0 ? {} : { label } });
|
|
13283
13488
|
};
|
|
13284
13489
|
for (const story of project.stories) {
|
|
13285
|
-
const currentId = id(storyId(story.path), [story.path]);
|
|
13490
|
+
const currentId = id(storyId(story.id ?? story.path), [story.id ?? story.path]);
|
|
13286
13491
|
for (const slicePath of new Set(story.slices)) {
|
|
13287
13492
|
storyIdsBySlicePath.set(slicePath, [...storyIdsBySlicePath.get(slicePath) ?? [], currentId]);
|
|
13288
13493
|
}
|
|
13289
|
-
nodes.push({ id: currentId, type: "story", label: story.name, sourcePath: story.path, description: story.description });
|
|
13494
|
+
nodes.push({ id: currentId, type: "story", label: story.name, storyId: story.id, sourceName: story.localId, sourcePath: story.path, description: story.description });
|
|
13290
13495
|
}
|
|
13291
13496
|
for (const event of project.events) {
|
|
13292
13497
|
nodes.push({ id: eventNodeId(event.name), type: "event", label: event.name, sourceName: event.name, sourcePath: event.sourcePath, fields: event.fields, description: event.description });
|
|
@@ -13294,7 +13499,7 @@ function buildGraph(project) {
|
|
|
13294
13499
|
for (const slice of project.slices) {
|
|
13295
13500
|
const currentSliceId = id(sliceId(slice.path), [slice.path]);
|
|
13296
13501
|
const currentScreenId = id(screenId(slice.path), [slice.path]);
|
|
13297
|
-
const shared = { storyName: slice.storyName, sliceTitle: slice.title, sourcePath: slice.path, raw: slice.raw };
|
|
13502
|
+
const shared = { storyName: slice.storyName, storyId: slice.storyId, sliceTitle: slice.title, sourcePath: slice.path, raw: slice.raw };
|
|
13298
13503
|
nodes.push({ ...shared, id: currentSliceId, type: "slice", label: slice.title });
|
|
13299
13504
|
for (const story of storyIdsBySlicePath.get(slice.path) ?? []) {
|
|
13300
13505
|
connect("story-slice", story, currentSliceId);
|
|
@@ -13345,7 +13550,7 @@ function buildGraph(project) {
|
|
|
13345
13550
|
}
|
|
13346
13551
|
|
|
13347
13552
|
// ../parser/dist/config.js
|
|
13348
|
-
var
|
|
13553
|
+
var import_yaml3 = __toESM(require_dist(), 1);
|
|
13349
13554
|
import fs from "node:fs";
|
|
13350
13555
|
import path from "node:path";
|
|
13351
13556
|
function findProjectRoot(startDir) {
|
|
@@ -13369,7 +13574,7 @@ function readConfig(projectRoot) {
|
|
|
13369
13574
|
return parseConfig(fs.readFileSync(configPath, "utf8"));
|
|
13370
13575
|
}
|
|
13371
13576
|
function parseConfig(content) {
|
|
13372
|
-
const raw =
|
|
13577
|
+
const raw = import_yaml3.default.parse(content);
|
|
13373
13578
|
const eventModelDir = raw?.paths?.event_model_dir ?? "event-model";
|
|
13374
13579
|
const featuresDir = raw?.paths?.features_dir ?? "src/features";
|
|
13375
13580
|
const sliceExtension = raw?.paths?.slice_extension ?? ".slice.yaml";
|
|
@@ -13387,7 +13592,7 @@ function parseConfig(content) {
|
|
|
13387
13592
|
}
|
|
13388
13593
|
|
|
13389
13594
|
// ../parser/dist/browser.js
|
|
13390
|
-
var
|
|
13595
|
+
var import_yaml4 = __toESM(require_dist(), 1);
|
|
13391
13596
|
function normalizeRelativePath(filePath) {
|
|
13392
13597
|
const parts = [];
|
|
13393
13598
|
for (const part of filePath.replaceAll("\\", "/").split("/")) {
|
|
@@ -13408,7 +13613,7 @@ function asStringArray(value) {
|
|
|
13408
13613
|
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
13409
13614
|
}
|
|
13410
13615
|
function parseEventsText(sourcePath, content) {
|
|
13411
|
-
const raw =
|
|
13616
|
+
const raw = import_yaml4.default.parse(content);
|
|
13412
13617
|
const eventMap = raw?.events && typeof raw.events === "object" ? raw.events : raw ?? {};
|
|
13413
13618
|
return Object.entries(eventMap).map(([name, entry]) => ({
|
|
13414
13619
|
name,
|
|
@@ -13418,7 +13623,7 @@ function parseEventsText(sourcePath, content) {
|
|
|
13418
13623
|
}));
|
|
13419
13624
|
}
|
|
13420
13625
|
function parseStoryText(storyPath, content) {
|
|
13421
|
-
const raw =
|
|
13626
|
+
const raw = import_yaml4.default.parse(content);
|
|
13422
13627
|
return {
|
|
13423
13628
|
name: typeof raw?.name === "string" ? raw.name : basename(storyPath, ".yaml"),
|
|
13424
13629
|
description: typeof raw?.description === "string" ? raw.description : "",
|
|
@@ -13467,11 +13672,12 @@ function parseScreen(raw) {
|
|
|
13467
13672
|
};
|
|
13468
13673
|
}
|
|
13469
13674
|
function parseSliceText(slicePath, content, storyBySlice) {
|
|
13470
|
-
const raw =
|
|
13675
|
+
const raw = import_yaml4.default.parse(content);
|
|
13471
13676
|
return {
|
|
13472
13677
|
title: typeof raw?.slice === "string" ? raw.slice : basename(slicePath),
|
|
13473
13678
|
path: slicePath,
|
|
13474
|
-
storyName: storyBySlice.get(slicePath),
|
|
13679
|
+
storyName: storyBySlice.get(slicePath)?.name,
|
|
13680
|
+
storyId: storyBySlice.get(slicePath)?.id,
|
|
13475
13681
|
screen: parseScreen(raw?.screen),
|
|
13476
13682
|
commands: parseCommands(raw?.commands),
|
|
13477
13683
|
queries: parseQueries(raw?.queries),
|
|
@@ -13482,7 +13688,7 @@ function parseSliceText(slicePath, content, storyBySlice) {
|
|
|
13482
13688
|
function loadEventModelProjectFromFiles(files, options = {}) {
|
|
13483
13689
|
const normalizedFiles = new Map(files.map((file) => [normalizeRelativePath(file.path), file.content]));
|
|
13484
13690
|
const configContent = normalizedFiles.get(".event-modeling/config.yaml");
|
|
13485
|
-
const configRaw = configContent ?
|
|
13691
|
+
const configRaw = configContent ? import_yaml4.default.parse(configContent) : null;
|
|
13486
13692
|
const eventModelDir = configRaw?.paths?.event_model_dir ?? "event-model";
|
|
13487
13693
|
const featuresDir = configRaw?.paths?.features_dir ?? "event-model/features";
|
|
13488
13694
|
const sliceExtension = configRaw?.paths?.slice_extension ?? ".slice.yaml";
|
|
@@ -13493,16 +13699,28 @@ function loadEventModelProjectFromFiles(files, options = {}) {
|
|
|
13493
13699
|
if (eventsContent === void 0)
|
|
13494
13700
|
throw new Error(`Missing events file: ${eventsFile}`);
|
|
13495
13701
|
const events = parseEventsText(eventsFile, eventsContent);
|
|
13702
|
+
const featureData = parseFeatureFiles([...normalizedFiles.entries()].filter(([filePath]) => (featuresDir === "" || filePath.startsWith(`${featuresDir}/`)) && filePath.endsWith(".feature.yaml")).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([path8, content]) => ({ path: path8, content })));
|
|
13496
13703
|
const stories = [...normalizedFiles.entries()].filter(([filePath]) => filePath.split("/").slice(0, -1).join("/") === storiesDir && filePath.endsWith(".yaml")).sort(([a], [b]) => a.localeCompare(b)).map(([filePath, content]) => parseStoryText(filePath, content));
|
|
13704
|
+
stories.push(...featureData.stories);
|
|
13497
13705
|
const storyBySlice = /* @__PURE__ */ new Map();
|
|
13498
13706
|
for (const story of stories)
|
|
13499
13707
|
for (const slicePath of story.slices)
|
|
13500
|
-
storyBySlice.set(normalizeRelativePath(slicePath), story
|
|
13708
|
+
storyBySlice.set(normalizeRelativePath(slicePath), story);
|
|
13501
13709
|
const storySlicePaths = stories.flatMap((story) => story.slices.map(normalizeRelativePath));
|
|
13502
13710
|
const discoveredSlicePaths = [...normalizedFiles.keys()].filter((filePath) => (featuresDir === "" || filePath.startsWith(`${featuresDir}/`)) && filePath.endsWith(sliceExtension));
|
|
13503
13711
|
const slicePaths = [.../* @__PURE__ */ new Set([...storySlicePaths, ...discoveredSlicePaths])].sort();
|
|
13504
13712
|
const slices = slicePaths.filter((filePath) => normalizedFiles.has(filePath)).map((filePath) => parseSliceText(filePath, normalizedFiles.get(filePath) ?? "", storyBySlice));
|
|
13505
13713
|
const actorData = loadActors(normalizedFiles.get(actorsFile), actorsFile, slices);
|
|
13714
|
+
const sourceDocuments = [
|
|
13715
|
+
{ path: eventsFile, kind: "events" },
|
|
13716
|
+
...stories.filter((story) => !story.id).map((story) => ({ path: story.path, kind: "story" })),
|
|
13717
|
+
...slices.map((slice) => ({ path: slice.path, kind: "slice" })),
|
|
13718
|
+
...normalizedFiles.has(actorsFile) ? [{ path: actorsFile, kind: "actors" }] : []
|
|
13719
|
+
];
|
|
13720
|
+
const modelIssues = [
|
|
13721
|
+
...featureData.modelIssues,
|
|
13722
|
+
...sourceDocuments.flatMap((source) => documentIssues(normalizedFiles.get(source.path) ?? "", source.path, source.kind))
|
|
13723
|
+
];
|
|
13506
13724
|
const projectWithoutGraph = {
|
|
13507
13725
|
root: options.root ?? "browser-import",
|
|
13508
13726
|
config: {
|
|
@@ -13511,6 +13729,8 @@ function loadEventModelProjectFromFiles(files, options = {}) {
|
|
|
13511
13729
|
},
|
|
13512
13730
|
events,
|
|
13513
13731
|
stories,
|
|
13732
|
+
timelines: featureData.timelines,
|
|
13733
|
+
modelIssues,
|
|
13514
13734
|
slices,
|
|
13515
13735
|
...actorData
|
|
13516
13736
|
};
|
|
@@ -13541,7 +13761,7 @@ function resolveProjectPath(projectRoot, relativePath) {
|
|
|
13541
13761
|
return path2.resolve(projectRoot, relativePath);
|
|
13542
13762
|
}
|
|
13543
13763
|
function parseEventsText2(sourcePath, content) {
|
|
13544
|
-
const raw =
|
|
13764
|
+
const raw = import_yaml5.default.parse(content);
|
|
13545
13765
|
const eventMap = raw?.events && typeof raw.events === "object" ? raw.events : raw ?? {};
|
|
13546
13766
|
return Object.entries(eventMap).map(([name, entry]) => ({
|
|
13547
13767
|
name,
|
|
@@ -13555,7 +13775,7 @@ function parseEvents(projectRoot, eventsPath) {
|
|
|
13555
13775
|
return parseEventsText2(rel(projectRoot, absolutePath), fs2.readFileSync(absolutePath, "utf8"));
|
|
13556
13776
|
}
|
|
13557
13777
|
function parseStoryText2(storyPath, content) {
|
|
13558
|
-
const raw =
|
|
13778
|
+
const raw = import_yaml5.default.parse(content);
|
|
13559
13779
|
return {
|
|
13560
13780
|
name: typeof raw?.name === "string" ? raw.name : path2.basename(storyPath, ".yaml"),
|
|
13561
13781
|
description: typeof raw?.description === "string" ? raw.description : "",
|
|
@@ -13608,11 +13828,12 @@ function parseScreen2(raw) {
|
|
|
13608
13828
|
};
|
|
13609
13829
|
}
|
|
13610
13830
|
function parseSliceText2(slicePath, content, storyBySlice) {
|
|
13611
|
-
const raw =
|
|
13831
|
+
const raw = import_yaml5.default.parse(content);
|
|
13612
13832
|
return {
|
|
13613
13833
|
title: typeof raw?.slice === "string" ? raw.slice : path2.basename(slicePath),
|
|
13614
13834
|
path: slicePath,
|
|
13615
|
-
storyName: storyBySlice.get(slicePath),
|
|
13835
|
+
storyName: storyBySlice.get(slicePath)?.name,
|
|
13836
|
+
storyId: storyBySlice.get(slicePath)?.id,
|
|
13616
13837
|
screen: parseScreen2(raw?.screen),
|
|
13617
13838
|
commands: parseCommands2(raw?.commands),
|
|
13618
13839
|
queries: parseQueries2(raw?.queries),
|
|
@@ -13624,7 +13845,7 @@ function parseSlices(projectRoot, stories, sliceGlob) {
|
|
|
13624
13845
|
const storyBySlice = /* @__PURE__ */ new Map();
|
|
13625
13846
|
for (const story of stories) {
|
|
13626
13847
|
for (const slicePath of story.slices) {
|
|
13627
|
-
storyBySlice.set(slicePath, story
|
|
13848
|
+
storyBySlice.set(slicePath, story);
|
|
13628
13849
|
}
|
|
13629
13850
|
}
|
|
13630
13851
|
const storySlices = stories.flatMap((story) => story.slices);
|
|
@@ -13640,13 +13861,29 @@ function loadEventModelProject(startDir) {
|
|
|
13640
13861
|
const root = findProjectRoot(startDir);
|
|
13641
13862
|
const config = readConfig(root);
|
|
13642
13863
|
const events = parseEvents(root, config.paths.eventsFile);
|
|
13643
|
-
const
|
|
13864
|
+
const featureFiles = import_fast_glob.default.sync(path2.posix.join(config.paths.featuresDir, "**/*.feature.yaml"), {
|
|
13865
|
+
cwd: root,
|
|
13866
|
+
onlyFiles: true,
|
|
13867
|
+
ignore: ["node_modules/**", ".git/**", "dist/**", "build/**"]
|
|
13868
|
+
}).sort().map((filePath) => ({ path: filePath, content: fs2.readFileSync(resolveProjectPath(root, filePath), "utf8") }));
|
|
13869
|
+
const featureData = parseFeatureFiles(featureFiles);
|
|
13870
|
+
const stories = [...parseStories(root, config.paths.storiesDir), ...featureData.stories];
|
|
13644
13871
|
const slices = parseSlices(root, stories, path2.posix.join(config.paths.featuresDir, `**/*${config.paths.sliceExtension}`));
|
|
13645
13872
|
const actorsPath = config.paths.actorsFile ?? path2.posix.join(config.paths.eventModelDir, "actors.yaml");
|
|
13646
13873
|
const absoluteActorsPath = resolveProjectPath(root, actorsPath);
|
|
13647
13874
|
const actorsContent = fs2.existsSync(absoluteActorsPath) ? fs2.readFileSync(absoluteActorsPath, "utf8") : void 0;
|
|
13648
13875
|
const actorData = loadActors(actorsContent, actorsPath, slices);
|
|
13649
|
-
const
|
|
13876
|
+
const sourceDocuments = [
|
|
13877
|
+
{ path: config.paths.eventsFile, kind: "events" },
|
|
13878
|
+
...stories.filter((story) => !story.id).map((story) => ({ path: story.path, kind: "story" })),
|
|
13879
|
+
...slices.map((slice) => ({ path: slice.path, kind: "slice" })),
|
|
13880
|
+
...actorsContent === void 0 ? [] : [{ path: actorsPath, kind: "actors" }]
|
|
13881
|
+
];
|
|
13882
|
+
const modelIssues = [
|
|
13883
|
+
...featureData.modelIssues,
|
|
13884
|
+
...sourceDocuments.flatMap((source) => documentIssues(fs2.readFileSync(resolveProjectPath(root, source.path), "utf8"), source.path, source.kind))
|
|
13885
|
+
];
|
|
13886
|
+
const projectWithoutGraph = { root, config, events, stories, slices, timelines: featureData.timelines, modelIssues, ...actorData };
|
|
13650
13887
|
const graph = buildGraph(projectWithoutGraph);
|
|
13651
13888
|
return {
|
|
13652
13889
|
...projectWithoutGraph,
|
|
@@ -13672,6 +13909,19 @@ function materializeGitRef(ref, cwd = process.cwd()) {
|
|
|
13672
13909
|
maxBuffer: 20 * 1024 * 1024
|
|
13673
13910
|
});
|
|
13674
13911
|
const config = parseConfig(configText);
|
|
13912
|
+
for (const directory of [config.paths.featuresDir, config.paths.storiesDir]) {
|
|
13913
|
+
const normalized = path3.posix.normalize(directory);
|
|
13914
|
+
if (path3.isAbsolute(normalized) || normalized === ".." || normalized.startsWith("../")) {
|
|
13915
|
+
throw new Error("Model directories must stay inside the project directory.");
|
|
13916
|
+
}
|
|
13917
|
+
const tracked = execFileSync("git", ["ls-tree", "-r", "-z", "--name-only", ref, "--", normalized], {
|
|
13918
|
+
cwd,
|
|
13919
|
+
encoding: "utf8"
|
|
13920
|
+
}).split("\0").filter(Boolean);
|
|
13921
|
+
for (const file of tracked) {
|
|
13922
|
+
if ((file.endsWith(".yaml") || file.endsWith(config.paths.sliceExtension)) && !files.includes(file)) files.push(file);
|
|
13923
|
+
}
|
|
13924
|
+
}
|
|
13675
13925
|
const actorsFile = path3.posix.normalize(config.paths.actorsFile ?? path3.posix.join(config.paths.eventModelDir, "actors.yaml"));
|
|
13676
13926
|
if (path3.isAbsolute(actorsFile) || actorsFile === ".." || actorsFile.startsWith("../")) {
|
|
13677
13927
|
throw new Error("Actor registry must stay inside the project directory.");
|
|
@@ -13704,7 +13954,7 @@ import path4 from "node:path";
|
|
|
13704
13954
|
function selectorForNode(node) {
|
|
13705
13955
|
switch (node.type) {
|
|
13706
13956
|
case "story":
|
|
13707
|
-
return { name: node.label };
|
|
13957
|
+
return node.storyId ? { name: node.label, storyId: node.storyId } : { name: node.label };
|
|
13708
13958
|
case "slice":
|
|
13709
13959
|
return { slice: node.label };
|
|
13710
13960
|
case "screen":
|
|
@@ -13760,6 +14010,7 @@ function comparableNode(node) {
|
|
|
13760
14010
|
type: node.type,
|
|
13761
14011
|
label: node.label,
|
|
13762
14012
|
storyName: node.storyName,
|
|
14013
|
+
storyId: node.storyId,
|
|
13763
14014
|
sliceTitle: node.sliceTitle,
|
|
13764
14015
|
sourceName: node.sourceName,
|
|
13765
14016
|
actors: node.actors,
|
|
@@ -13799,6 +14050,8 @@ function cloneProject(project) {
|
|
|
13799
14050
|
events: project.events.map((event) => ({ ...event })),
|
|
13800
14051
|
actors: project.actors?.map((actor) => ({ ...actor })),
|
|
13801
14052
|
actorIssues: project.actorIssues?.map((issue) => ({ ...issue })),
|
|
14053
|
+
timelines: project.timelines?.map((timeline) => structuredClone(timeline)),
|
|
14054
|
+
modelIssues: project.modelIssues?.map((issue) => ({ ...issue })),
|
|
13802
14055
|
stories: project.stories.map((story) => ({ ...story, slices: [...story.slices] })),
|
|
13803
14056
|
slices: project.slices.map((slice) => ({
|
|
13804
14057
|
...slice,
|
|
@@ -13845,14 +14098,14 @@ function uniqueEdgeId(existingIds, id) {
|
|
|
13845
14098
|
return next;
|
|
13846
14099
|
}
|
|
13847
14100
|
function mergeRemovedModelContainers(merged, base) {
|
|
13848
|
-
const storyNames = new Set(merged.stories.map((story) => story.name));
|
|
14101
|
+
const storyNames = new Set(merged.stories.map((story) => story.id ?? story.name));
|
|
13849
14102
|
const slicePaths = new Set(merged.slices.map((slice) => slice.path));
|
|
13850
14103
|
const eventNames = new Set(merged.events.map((event) => event.name));
|
|
13851
14104
|
for (const story of base.stories) {
|
|
13852
|
-
if (storyNames.has(story.name))
|
|
14105
|
+
if (storyNames.has(story.id ?? story.name))
|
|
13853
14106
|
continue;
|
|
13854
14107
|
merged.stories.push({ ...story, slices: [...story.slices] });
|
|
13855
|
-
storyNames.add(story.name);
|
|
14108
|
+
storyNames.add(story.id ?? story.name);
|
|
13856
14109
|
}
|
|
13857
14110
|
for (const slice of base.slices) {
|
|
13858
14111
|
if (slicePaths.has(slice.path))
|
|
@@ -13903,6 +14156,7 @@ function buildGraphSidecar(project, existing) {
|
|
|
13903
14156
|
events: project.config.paths.eventsFile,
|
|
13904
14157
|
actors: project.config.paths.actorsFile,
|
|
13905
14158
|
stories: [`${project.config.paths.storiesDir}/**/*.yaml`],
|
|
14159
|
+
features: [`${project.config.paths.featuresDir}/**/*.feature.yaml`],
|
|
13906
14160
|
slices: [`${project.config.paths.featuresDir}/**/*${project.config.paths.sliceExtension}`]
|
|
13907
14161
|
},
|
|
13908
14162
|
nodes: Object.fromEntries(Object.entries(mergedNodes).sort(([a], [b]) => {
|
|
@@ -13923,6 +14177,8 @@ function diffEventModelProjects(base, target, labels = {}) {
|
|
|
13923
14177
|
return new Map(project.nodes.map((node) => {
|
|
13924
14178
|
if (node.type === "event")
|
|
13925
14179
|
return [node.id, nodeKey(node)];
|
|
14180
|
+
if (node.type === "story" && node.storyId)
|
|
14181
|
+
return [node.id, stableJson({ type: "story", storyId: node.storyId })];
|
|
13926
14182
|
const key = stableJson({ selector: nodeKey(node), sourcePath: node.sourcePath });
|
|
13927
14183
|
const occurrence = occurrences.get(key) ?? 0;
|
|
13928
14184
|
occurrences.set(key, occurrence + 1);
|
|
@@ -13993,6 +14249,8 @@ function diffEventModelProjects(base, target, labels = {}) {
|
|
|
13993
14249
|
diff: {
|
|
13994
14250
|
base: { label: labels.base ?? "base" },
|
|
13995
14251
|
target: { label: labels.target ?? "target" },
|
|
14252
|
+
previousTimelines: base.timelines ? structuredClone(base.timelines) : [],
|
|
14253
|
+
timelinesChanged: stableJson(base.timelines ?? []) !== stableJson(target.timelines ?? []),
|
|
13996
14254
|
previousGwtNodes,
|
|
13997
14255
|
previousNodes,
|
|
13998
14256
|
previousEdges,
|
|
@@ -14146,7 +14404,10 @@ function connectedComponentCount(project) {
|
|
|
14146
14404
|
return components;
|
|
14147
14405
|
}
|
|
14148
14406
|
function validateEventModelProject(project, snapshot) {
|
|
14149
|
-
const findings =
|
|
14407
|
+
const findings = [
|
|
14408
|
+
...(project.actorIssues ?? []).map((issue) => finding("error", "A1", issue.message, issue.path)),
|
|
14409
|
+
...(project.modelIssues ?? []).map((issue) => finding("error", issue.check, issue.message, issue.path))
|
|
14410
|
+
];
|
|
14150
14411
|
const eventNames = new Set(project.events.map((event) => event.name));
|
|
14151
14412
|
const produced = /* @__PURE__ */ new Map();
|
|
14152
14413
|
const consumed = /* @__PURE__ */ new Map();
|
|
@@ -14447,6 +14708,7 @@ function readSnapshot(target) {
|
|
|
14447
14708
|
};
|
|
14448
14709
|
walk(config.paths.storiesDir, false, ".yaml");
|
|
14449
14710
|
walk(config.paths.featuresDir, true, config.paths.sliceExtension);
|
|
14711
|
+
walk(config.paths.featuresDir, true, ".feature.yaml");
|
|
14450
14712
|
const preliminary = parseFiles(root, files, config);
|
|
14451
14713
|
for (const source of preliminary.stories.flatMap((story) => story.slices)) {
|
|
14452
14714
|
const key = sourceKey(root, source);
|
|
@@ -14496,7 +14758,7 @@ function gitBaseline(snapshot) {
|
|
|
14496
14758
|
const isStory = (path6.posix.dirname(key) === "." ? "" : path6.posix.dirname(key)) === config.paths.storiesDir && !path6.posix.basename(key).startsWith(".") && key.endsWith(".yaml");
|
|
14497
14759
|
const relative = config.paths.featuresDir ? key.slice(config.paths.featuresDir.length + 1) : key;
|
|
14498
14760
|
const ignored = relative.split("/").some((part) => part.startsWith(".")) || ["node_modules/", "dist/", "build/"].some((directory) => key.startsWith(directory));
|
|
14499
|
-
const isSlice = !ignored && (config.paths.featuresDir === "" || key.startsWith(config.paths.featuresDir + "/")) && key.endsWith(config.paths.sliceExtension);
|
|
14761
|
+
const isSlice = !ignored && (config.paths.featuresDir === "" || key.startsWith(config.paths.featuresDir + "/")) && (key.endsWith(config.paths.sliceExtension) || key.endsWith(".feature.yaml"));
|
|
14500
14762
|
if (isStory || isSlice) read(key);
|
|
14501
14763
|
}
|
|
14502
14764
|
const preliminary = parseFiles(root, files, config);
|
|
@@ -14536,7 +14798,7 @@ function parseBatch(body) {
|
|
|
14536
14798
|
return { clientBatchId, items };
|
|
14537
14799
|
}
|
|
14538
14800
|
function nodeIdentity(node) {
|
|
14539
|
-
return JSON.stringify([node.type, node.sourcePath, node.sourceName, node.label, node.sliceTitle]);
|
|
14801
|
+
return JSON.stringify([node.type, node.sourcePath, node.sourceName, node.label, node.sliceTitle, node.type === "story" ? node.storyId : void 0]);
|
|
14540
14802
|
}
|
|
14541
14803
|
function uniqueNodeIds(project) {
|
|
14542
14804
|
const ids = /* @__PURE__ */ new Map();
|