@hamak/smart-data-dico 1.12.6 → 1.13.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.
@@ -19143,18 +19143,18 @@ var require_router = __commonJS({
19143
19143
  var toString2 = Object.prototype.toString;
19144
19144
  var proto = module.exports = function(options2) {
19145
19145
  var opts = options2 || {};
19146
- function router28(req, res, next) {
19147
- router28.handle(req, res, next);
19148
- }
19149
- __name(router28, "router");
19150
- setPrototypeOf(router28, proto);
19151
- router28.params = {};
19152
- router28._params = [];
19153
- router28.caseSensitive = opts.caseSensitive;
19154
- router28.mergeParams = opts.mergeParams;
19155
- router28.strict = opts.strict;
19156
- router28.stack = [];
19157
- return router28;
19146
+ function router29(req, res, next) {
19147
+ router29.handle(req, res, next);
19148
+ }
19149
+ __name(router29, "router");
19150
+ setPrototypeOf(router29, proto);
19151
+ router29.params = {};
19152
+ router29._params = [];
19153
+ router29.caseSensitive = opts.caseSensitive;
19154
+ router29.mergeParams = opts.mergeParams;
19155
+ router29.strict = opts.strict;
19156
+ router29.stack = [];
19157
+ return router29;
19158
19158
  };
19159
19159
  proto.param = /* @__PURE__ */ __name(function param(name21, fn) {
19160
19160
  if (typeof name21 === "function") {
@@ -22278,7 +22278,7 @@ var require_application = __commonJS({
22278
22278
  "backend/node_modules/express/lib/application.js"(exports, module) {
22279
22279
  "use strict";
22280
22280
  var finalhandler = require_finalhandler();
22281
- var Router32 = require_router();
22281
+ var Router33 = require_router();
22282
22282
  var methods = require_methods();
22283
22283
  var middleware = require_init();
22284
22284
  var query = require_query();
@@ -22343,7 +22343,7 @@ var require_application = __commonJS({
22343
22343
  }, "defaultConfiguration");
22344
22344
  app2.lazyrouter = /* @__PURE__ */ __name(function lazyrouter() {
22345
22345
  if (!this._router) {
22346
- this._router = new Router32({
22346
+ this._router = new Router33({
22347
22347
  caseSensitive: this.enabled("case sensitive routing"),
22348
22348
  strict: this.enabled("strict routing")
22349
22349
  });
@@ -22352,17 +22352,17 @@ var require_application = __commonJS({
22352
22352
  }
22353
22353
  }, "lazyrouter");
22354
22354
  app2.handle = /* @__PURE__ */ __name(function handle(req, res, callback) {
22355
- var router28 = this._router;
22355
+ var router29 = this._router;
22356
22356
  var done = callback || finalhandler(req, res, {
22357
22357
  env: this.get("env"),
22358
22358
  onerror: logerror.bind(this)
22359
22359
  });
22360
- if (!router28) {
22360
+ if (!router29) {
22361
22361
  debug2("no routes defined on app");
22362
22362
  done();
22363
22363
  return;
22364
22364
  }
22365
- router28.handle(req, res, done);
22365
+ router29.handle(req, res, done);
22366
22366
  }, "handle");
22367
22367
  app2.use = /* @__PURE__ */ __name(function use(fn) {
22368
22368
  var offset = 0;
@@ -22382,15 +22382,15 @@ var require_application = __commonJS({
22382
22382
  throw new TypeError("app.use() requires a middleware function");
22383
22383
  }
22384
22384
  this.lazyrouter();
22385
- var router28 = this._router;
22385
+ var router29 = this._router;
22386
22386
  fns.forEach(function(fn2) {
22387
22387
  if (!fn2 || !fn2.handle || !fn2.set) {
22388
- return router28.use(path14, fn2);
22388
+ return router29.use(path14, fn2);
22389
22389
  }
22390
22390
  debug2(".use app under %s", path14);
22391
22391
  fn2.mountpath = path14;
22392
22392
  fn2.parent = this;
22393
- router28.use(path14, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
22393
+ router29.use(path14, /* @__PURE__ */ __name(function mounted_app(req, res, next) {
22394
22394
  var orig = req.app;
22395
22395
  fn2.handle(req, res, function(err) {
22396
22396
  setPrototypeOf(req, orig.request);
@@ -24275,7 +24275,7 @@ var require_express = __commonJS({
24275
24275
  var mixin = require_merge_descriptors();
24276
24276
  var proto = require_application();
24277
24277
  var Route = require_route();
24278
- var Router32 = require_router();
24278
+ var Router33 = require_router();
24279
24279
  var req = require_request();
24280
24280
  var res = require_response();
24281
24281
  exports = module.exports = createApplication;
@@ -24299,7 +24299,7 @@ var require_express = __commonJS({
24299
24299
  exports.request = req;
24300
24300
  exports.response = res;
24301
24301
  exports.Route = Route;
24302
- exports.Router = Router32;
24302
+ exports.Router = Router33;
24303
24303
  exports.json = bodyParser2.json;
24304
24304
  exports.query = require_query();
24305
24305
  exports.raw = bodyParser2.raw;
@@ -43798,7 +43798,7 @@ var init_git_service = __esm({
43798
43798
  // backend/node_modules/@hamak/ui-remote-git-fs-backend/dist/routes/git-routes.js
43799
43799
  function createGitRoutes(config3) {
43800
43800
  const { gitService, debug: debug2 } = config3;
43801
- const router28 = (0, import_express2.Router)();
43801
+ const router29 = (0, import_express2.Router)();
43802
43802
  const log2 = /* @__PURE__ */ __name((message, ...args) => {
43803
43803
  if (debug2) {
43804
43804
  console.log(`[git-routes] ${message}`, ...args);
@@ -43812,21 +43812,21 @@ function createGitRoutes(config3) {
43812
43812
  const extractPath = /* @__PURE__ */ __name((req) => {
43813
43813
  return req.params[0] || "";
43814
43814
  }, "extractPath");
43815
- router28.get("/:workspaceId/status/*", asyncHandler(async (req, res) => {
43815
+ router29.get("/:workspaceId/status/*", asyncHandler(async (req, res) => {
43816
43816
  const { workspaceId } = req.params;
43817
43817
  const path14 = extractPath(req);
43818
43818
  log2("Status request", { workspaceId, path: path14 });
43819
43819
  const status = await gitService.getStatus(workspaceId, path14);
43820
43820
  res.json(status);
43821
43821
  }));
43822
- router28.get("/:workspaceId/branches/*", asyncHandler(async (req, res) => {
43822
+ router29.get("/:workspaceId/branches/*", asyncHandler(async (req, res) => {
43823
43823
  const { workspaceId } = req.params;
43824
43824
  const path14 = extractPath(req);
43825
43825
  log2("List branches request", { workspaceId, path: path14 });
43826
43826
  const branches = await gitService.listBranches(workspaceId, path14);
43827
43827
  res.json(branches);
43828
43828
  }));
43829
- router28.post("/:workspaceId/checkout/*", asyncHandler(async (req, res) => {
43829
+ router29.post("/:workspaceId/checkout/*", asyncHandler(async (req, res) => {
43830
43830
  const { workspaceId } = req.params;
43831
43831
  const path14 = extractPath(req);
43832
43832
  const { branch, create } = req.body;
@@ -43840,7 +43840,7 @@ function createGitRoutes(config3) {
43840
43840
  await gitService.checkout(workspaceId, path14, branch, create);
43841
43841
  res.json({ success: true, branch });
43842
43842
  }));
43843
- router28.post("/:workspaceId/branch/*", asyncHandler(async (req, res) => {
43843
+ router29.post("/:workspaceId/branch/*", asyncHandler(async (req, res) => {
43844
43844
  const { workspaceId } = req.params;
43845
43845
  const path14 = extractPath(req);
43846
43846
  const { branch, startPoint } = req.body;
@@ -43854,7 +43854,7 @@ function createGitRoutes(config3) {
43854
43854
  await gitService.createBranch(workspaceId, path14, branch, startPoint);
43855
43855
  res.json({ success: true, branch });
43856
43856
  }));
43857
- router28.post("/:workspaceId/stage/*", asyncHandler(async (req, res) => {
43857
+ router29.post("/:workspaceId/stage/*", asyncHandler(async (req, res) => {
43858
43858
  const { workspaceId } = req.params;
43859
43859
  const path14 = extractPath(req);
43860
43860
  const { files } = req.body;
@@ -43862,7 +43862,7 @@ function createGitRoutes(config3) {
43862
43862
  await gitService.stage(workspaceId, path14, files);
43863
43863
  res.json({ success: true });
43864
43864
  }));
43865
- router28.post("/:workspaceId/unstage/*", asyncHandler(async (req, res) => {
43865
+ router29.post("/:workspaceId/unstage/*", asyncHandler(async (req, res) => {
43866
43866
  const { workspaceId } = req.params;
43867
43867
  const path14 = extractPath(req);
43868
43868
  const { files } = req.body;
@@ -43870,7 +43870,7 @@ function createGitRoutes(config3) {
43870
43870
  await gitService.unstage(workspaceId, path14, files);
43871
43871
  res.json({ success: true });
43872
43872
  }));
43873
- router28.post("/:workspaceId/commit/*", asyncHandler(async (req, res) => {
43873
+ router29.post("/:workspaceId/commit/*", asyncHandler(async (req, res) => {
43874
43874
  const { workspaceId } = req.params;
43875
43875
  const path14 = extractPath(req);
43876
43876
  const { message } = req.body;
@@ -43884,7 +43884,7 @@ function createGitRoutes(config3) {
43884
43884
  const result = await gitService.commit(workspaceId, path14, message);
43885
43885
  res.json(result);
43886
43886
  }));
43887
- router28.post("/:workspaceId/pull/*", asyncHandler(async (req, res) => {
43887
+ router29.post("/:workspaceId/pull/*", asyncHandler(async (req, res) => {
43888
43888
  const { workspaceId } = req.params;
43889
43889
  const path14 = extractPath(req);
43890
43890
  const { remote, branch } = req.body;
@@ -43892,7 +43892,7 @@ function createGitRoutes(config3) {
43892
43892
  const result = await gitService.pull(workspaceId, path14, remote, branch);
43893
43893
  res.json(result);
43894
43894
  }));
43895
- router28.post("/:workspaceId/push/*", asyncHandler(async (req, res) => {
43895
+ router29.post("/:workspaceId/push/*", asyncHandler(async (req, res) => {
43896
43896
  const { workspaceId } = req.params;
43897
43897
  const path14 = extractPath(req);
43898
43898
  const { remote, branch } = req.body;
@@ -43900,7 +43900,7 @@ function createGitRoutes(config3) {
43900
43900
  await gitService.push(workspaceId, path14, remote, branch);
43901
43901
  res.json({ success: true });
43902
43902
  }));
43903
- router28.post("/:workspaceId/fetch/*", asyncHandler(async (req, res) => {
43903
+ router29.post("/:workspaceId/fetch/*", asyncHandler(async (req, res) => {
43904
43904
  const { workspaceId } = req.params;
43905
43905
  const path14 = extractPath(req);
43906
43906
  const { remote } = req.body;
@@ -43908,7 +43908,7 @@ function createGitRoutes(config3) {
43908
43908
  await gitService.fetch(workspaceId, path14, remote);
43909
43909
  res.json({ success: true });
43910
43910
  }));
43911
- router28.get("/:workspaceId/diff/*", asyncHandler(async (req, res) => {
43911
+ router29.get("/:workspaceId/diff/*", asyncHandler(async (req, res) => {
43912
43912
  const { workspaceId } = req.params;
43913
43913
  const path14 = extractPath(req);
43914
43914
  const { file: file2, staged } = req.query;
@@ -43916,7 +43916,7 @@ function createGitRoutes(config3) {
43916
43916
  const result = await gitService.diff(workspaceId, path14, file2, staged === "true");
43917
43917
  res.json(result);
43918
43918
  }));
43919
- router28.get("/:workspaceId/log/*", asyncHandler(async (req, res) => {
43919
+ router29.get("/:workspaceId/log/*", asyncHandler(async (req, res) => {
43920
43920
  const { workspaceId } = req.params;
43921
43921
  const path14 = extractPath(req);
43922
43922
  const { maxCount, file: file2 } = req.query;
@@ -43924,21 +43924,21 @@ function createGitRoutes(config3) {
43924
43924
  const result = await gitService.log(workspaceId, path14, maxCount ? parseInt(maxCount, 10) : void 0, file2);
43925
43925
  res.json(result);
43926
43926
  }));
43927
- router28.get("/:workspaceId/is-repo/*", asyncHandler(async (req, res) => {
43927
+ router29.get("/:workspaceId/is-repo/*", asyncHandler(async (req, res) => {
43928
43928
  const { workspaceId } = req.params;
43929
43929
  const path14 = extractPath(req);
43930
43930
  log2("Is repo request", { workspaceId, path: path14 });
43931
43931
  const isRepo = await gitService.isRepo(workspaceId, path14);
43932
43932
  res.json({ isRepo });
43933
43933
  }));
43934
- router28.get("/:workspaceId/repo-root/*", asyncHandler(async (req, res) => {
43934
+ router29.get("/:workspaceId/repo-root/*", asyncHandler(async (req, res) => {
43935
43935
  const { workspaceId } = req.params;
43936
43936
  const path14 = extractPath(req);
43937
43937
  log2("Repo root request", { workspaceId, path: path14 });
43938
43938
  const repoRoot = await gitService.getRepoRoot(workspaceId, path14);
43939
43939
  res.json({ repoRoot });
43940
43940
  }));
43941
- return router28;
43941
+ return router29;
43942
43942
  }
43943
43943
  function gitErrorHandler(err, req, res, next) {
43944
43944
  console.error("[git-routes] Error:", err);
@@ -44196,10 +44196,12 @@ __export(fileOperations_exports, {
44196
44196
  deleteAction: () => deleteAction,
44197
44197
  deleteCaseFile: () => deleteCaseFile,
44198
44198
  deleteEntityFile: () => deleteEntityFile,
44199
+ deleteEvent: () => deleteEvent,
44199
44200
  deleteStateMachine: () => deleteStateMachine,
44200
44201
  ensureDirectoryStructure: () => ensureDirectoryStructure,
44201
44202
  ensurePackageDirectoryStructure: () => ensurePackageDirectoryStructure,
44202
44203
  findActionOwner: () => findActionOwner,
44204
+ findEventOwner: () => findEventOwner,
44203
44205
  findStateMachineOwner: () => findStateMachineOwner,
44204
44206
  getAllRelationships: () => getAllRelationships,
44205
44207
  getPackagePath: () => getPackagePath,
@@ -44220,11 +44222,14 @@ __export(fileOperations_exports, {
44220
44222
  normalizeEntityMetadata: () => normalizeEntityMetadata,
44221
44223
  parseSectionsFromString: () => parseSectionsFromString,
44222
44224
  readActionsForEntity: () => readActionsForEntity,
44225
+ readActionsForPackage: () => readActionsForPackage,
44223
44226
  readCaseFile: () => readCaseFile,
44224
44227
  readCaseRules: () => readCaseRules,
44225
44228
  readComments: () => readComments,
44226
44229
  readEntityFile: () => readEntityFile,
44227
44230
  readEntityRules: () => readEntityRules,
44231
+ readEventsForEntity: () => readEventsForEntity,
44232
+ readEventsForPackage: () => readEventsForPackage,
44228
44233
  readGlobalRules: () => readGlobalRules,
44229
44234
  readPackageRules: () => readPackageRules,
44230
44235
  readRelationshipsFile: () => readRelationshipsFile,
@@ -44236,6 +44241,7 @@ __export(fileOperations_exports, {
44236
44241
  writeDictionaryMetadata: () => writeDictionaryMetadata,
44237
44242
  writeEntityFile: () => writeEntityFile,
44238
44243
  writeEntityRules: () => writeEntityRules,
44244
+ writeEvent: () => writeEvent,
44239
44245
  writeGlobalRules: () => writeGlobalRules,
44240
44246
  writePackageRules: () => writePackageRules,
44241
44247
  writeRelationshipsFile: () => writeRelationshipsFile,
@@ -44374,11 +44380,11 @@ async function listMicroservices() {
44374
44380
  function parseSectionsFromString(raw, label, filename) {
44375
44381
  try {
44376
44382
  const parsed = import_yaml.default.parse(raw);
44377
- if (!parsed) return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [] };
44383
+ if (!parsed) return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44378
44384
  if (typeof parsed === "object" && !Array.isArray(parsed) && typeof parsed.uuid === "string" && Array.isArray(parsed.attributes)) {
44379
- return { entities: [parsed], relationships: [], rules: [], cases: [], actions: [], stateMachines: [] };
44385
+ return { entities: [parsed], relationships: [], rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44380
44386
  }
44381
- if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && ("entities" in parsed || "relationships" in parsed || "rules" in parsed || "cases" in parsed || "perspectives" in parsed || "actions" in parsed || "stateMachines" in parsed)) {
44387
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed) && ("entities" in parsed || "relationships" in parsed || "rules" in parsed || "cases" in parsed || "perspectives" in parsed || "actions" in parsed || "stateMachines" in parsed || "events" in parsed)) {
44382
44388
  let cases = [];
44383
44389
  if (Array.isArray(parsed.cases)) {
44384
44390
  cases = parsed.cases;
@@ -44392,27 +44398,28 @@ function parseSectionsFromString(raw, label, filename) {
44392
44398
  rules: Array.isArray(parsed.rules) ? parsed.rules : [],
44393
44399
  cases,
44394
44400
  actions: Array.isArray(parsed.actions) ? parsed.actions : [],
44395
- stateMachines: Array.isArray(parsed.stateMachines) ? parsed.stateMachines : []
44401
+ stateMachines: Array.isArray(parsed.stateMachines) ? parsed.stateMachines : [],
44402
+ events: Array.isArray(parsed.events) ? parsed.events : []
44396
44403
  };
44397
44404
  }
44398
44405
  if (Array.isArray(parsed) && filename) {
44399
44406
  if (filename === "relationships.yaml") {
44400
- return { entities: [], relationships: parsed, rules: [], cases: [], actions: [], stateMachines: [] };
44407
+ return { entities: [], relationships: parsed, rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44401
44408
  }
44402
44409
  if (filename === "rules.yaml" || filename.endsWith(".rules.yaml")) {
44403
- return { entities: [], relationships: [], rules: parsed, cases: [], actions: [], stateMachines: [] };
44410
+ return { entities: [], relationships: [], rules: parsed, cases: [], actions: [], stateMachines: [], events: [] };
44404
44411
  }
44405
44412
  }
44406
- return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [] };
44413
+ return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44407
44414
  } catch (e) {
44408
44415
  logger.warn(`Failed to parse YAML: ${label}: ${e}`);
44409
- return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [] };
44416
+ return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44410
44417
  }
44411
44418
  }
44412
44419
  async function parseSectionsFromStorage(p, label) {
44413
44420
  const content = await readOrNull(p);
44414
44421
  if (content === null) {
44415
- return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [] };
44422
+ return { entities: [], relationships: [], rules: [], cases: [], actions: [], stateMachines: [], events: [] };
44416
44423
  }
44417
44424
  const filename = path4.basename(String(p));
44418
44425
  return parseSectionsFromString(content, label, filename);
@@ -44426,6 +44433,7 @@ function mergePackageSections(packageName, parsed) {
44426
44433
  cases: [],
44427
44434
  actions: [],
44428
44435
  stateMachines: [],
44436
+ events: [],
44429
44437
  ownership: {
44430
44438
  entityByName: /* @__PURE__ */ new Map(),
44431
44439
  entityByUuid: /* @__PURE__ */ new Map(),
@@ -44434,6 +44442,8 @@ function mergePackageSections(packageName, parsed) {
44434
44442
  caseByUuid: /* @__PURE__ */ new Map(),
44435
44443
  actionByUuid: /* @__PURE__ */ new Map(),
44436
44444
  stateMachineByUuid: /* @__PURE__ */ new Map(),
44445
+ eventByUuid: /* @__PURE__ */ new Map(),
44446
+ eventByName: /* @__PURE__ */ new Map(),
44437
44447
  actionByOwnerAndName: /* @__PURE__ */ new Map(),
44438
44448
  stateMachineByOwnerAndName: /* @__PURE__ */ new Map()
44439
44449
  }
@@ -44529,6 +44539,24 @@ function mergePackageSections(packageName, parsed) {
44529
44539
  model.ownership.stateMachineByOwnerAndName.set(ownerNameKey, label);
44530
44540
  model.stateMachines.push(sm);
44531
44541
  }
44542
+ for (const event of sections.events || []) {
44543
+ if (!event?.uuid || !event?.name) continue;
44544
+ const byUuid = model.ownership.eventByUuid.get(event.uuid);
44545
+ if (byUuid) {
44546
+ throw new Error(
44547
+ `Duplicate event uuid '${event.uuid}' in package '${packageName}': ${byUuid} and ${label}`
44548
+ );
44549
+ }
44550
+ const byName = model.ownership.eventByName.get(event.name);
44551
+ if (byName) {
44552
+ throw new Error(
44553
+ `Duplicate event name '${event.name}' in package '${packageName}': ${byName} and ${label}`
44554
+ );
44555
+ }
44556
+ model.ownership.eventByUuid.set(event.uuid, label);
44557
+ model.ownership.eventByName.set(event.name, label);
44558
+ model.events.push(event);
44559
+ }
44532
44560
  }
44533
44561
  return model;
44534
44562
  }
@@ -44543,6 +44571,7 @@ async function writeSectionsToStorage(p, sections) {
44543
44571
  if (sections.cases.length > 0) payload.cases = sections.cases;
44544
44572
  if (sections.actions.length > 0) payload.actions = sections.actions;
44545
44573
  if (sections.stateMachines.length > 0) payload.stateMachines = sections.stateMachines;
44574
+ if (sections.events.length > 0) payload.events = sections.events;
44546
44575
  const pkgSeg = String(p).replace(/^\/+/, "").split("/")[0];
44547
44576
  if (pkgSeg) invalidatePackageCache(pkgSeg);
44548
44577
  if (Object.keys(payload).length === 0) {
@@ -44667,7 +44696,8 @@ async function writeEntityFile(entity, packageName) {
44667
44696
  rules: [],
44668
44697
  cases: [],
44669
44698
  actions: [],
44670
- stateMachines: []
44699
+ stateMachines: [],
44700
+ events: []
44671
44701
  });
44672
44702
  logger.info(`Entity written to new file: ${String(newFilePath)}`);
44673
44703
  await commitChanges(String(newFilePath), `Added entity: ${entity.name} (${entity.uuid})`);
@@ -45129,6 +45159,14 @@ async function findActionOwner(actionUuid) {
45129
45159
  }
45130
45160
  return null;
45131
45161
  }
45162
+ async function readActionsForPackage(packageName) {
45163
+ try {
45164
+ const model = await loadPackage(packageName);
45165
+ return model.actions;
45166
+ } catch {
45167
+ return [];
45168
+ }
45169
+ }
45132
45170
  async function readActionsForEntity(entityUuid) {
45133
45171
  const packages = await listPackages();
45134
45172
  const result = [];
@@ -45180,7 +45218,8 @@ async function writeAction(action, packageName) {
45180
45218
  rules: [],
45181
45219
  cases: [],
45182
45220
  actions: [action],
45183
- stateMachines: []
45221
+ stateMachines: [],
45222
+ events: []
45184
45223
  });
45185
45224
  await commitChanges(String(newFilePath), `Added action: ${action.name} (${action.uuid})`);
45186
45225
  return { ok: true, physicalPath: String(newFilePath) };
@@ -45206,6 +45245,107 @@ async function deleteAction(uuid3) {
45206
45245
  return { ok: false };
45207
45246
  }
45208
45247
  }
45248
+ async function findEventOwner(eventUuid) {
45249
+ const packages = await listPackages();
45250
+ for (const pkg of packages) {
45251
+ const files = await listPackageYamlFilePaths(pkg);
45252
+ for (const f of files) {
45253
+ const s = await parseSectionsFromStorage(f, String(f));
45254
+ if (s.events.some((e) => e.uuid === eventUuid)) {
45255
+ return { packageName: pkg, filePath: String(f) };
45256
+ }
45257
+ }
45258
+ }
45259
+ return null;
45260
+ }
45261
+ async function readEventsForPackage(packageName) {
45262
+ try {
45263
+ const model = await loadPackage(packageName);
45264
+ return model.events;
45265
+ } catch {
45266
+ return [];
45267
+ }
45268
+ }
45269
+ async function readEventsForEntity(entityUuid) {
45270
+ const packages = await listPackages();
45271
+ const result = [];
45272
+ for (const pkg of packages) {
45273
+ try {
45274
+ const model = await loadPackage(pkg);
45275
+ result.push(...model.events.filter((e) => e.ownerRef === entityUuid));
45276
+ } catch {
45277
+ }
45278
+ }
45279
+ return result;
45280
+ }
45281
+ async function writeEvent(event, packageName) {
45282
+ try {
45283
+ await ensurePackageDirectoryStructure(packageName);
45284
+ const files = await listPackageYamlFilePaths(packageName);
45285
+ let ownerFile = null;
45286
+ let ownerSections = null;
45287
+ for (const f of files) {
45288
+ const s = await parseSectionsFromStorage(f, String(f));
45289
+ if (s.events.some((e) => e.uuid === event.uuid)) {
45290
+ ownerFile = f;
45291
+ ownerSections = s;
45292
+ break;
45293
+ }
45294
+ }
45295
+ if (ownerFile && ownerSections) {
45296
+ ownerSections.events = ownerSections.events.filter((e) => e.uuid !== event.uuid);
45297
+ ownerSections.events.push(event);
45298
+ await writeSectionsToStorage(ownerFile, ownerSections);
45299
+ await commitChanges(String(ownerFile), `Updated event: ${event.name} (${event.uuid})`);
45300
+ return { ok: true, physicalPath: String(ownerFile) };
45301
+ }
45302
+ if (event.ownerRef) {
45303
+ const entityModel = await loadPackage(packageName);
45304
+ const ownerEntityFile = entityModel.ownership.entityByUuid.get(event.ownerRef);
45305
+ if (ownerEntityFile) {
45306
+ const filePath = pathOf(ownerEntityFile);
45307
+ const s = await parseSectionsFromStorage(filePath, ownerEntityFile);
45308
+ s.events = s.events.filter((e) => e.uuid !== event.uuid);
45309
+ s.events.push(event);
45310
+ await writeSectionsToStorage(filePath, s);
45311
+ await commitChanges(ownerEntityFile, `Added event: ${event.name} (${event.uuid})`);
45312
+ return { ok: true, physicalPath: ownerEntityFile };
45313
+ }
45314
+ }
45315
+ const newFilePath = pathOf(`${packageName}/${sanitizeFsName(event.name)}.events.yaml`);
45316
+ await writeSectionsToStorage(newFilePath, {
45317
+ entities: [],
45318
+ relationships: [],
45319
+ rules: [],
45320
+ cases: [],
45321
+ actions: [],
45322
+ stateMachines: [],
45323
+ events: [event]
45324
+ });
45325
+ await commitChanges(String(newFilePath), `Added event: ${event.name} (${event.uuid})`);
45326
+ return { ok: true, physicalPath: String(newFilePath) };
45327
+ } catch (error48) {
45328
+ logger.error(`Error writing event: ${error48}`);
45329
+ return { ok: false };
45330
+ }
45331
+ }
45332
+ async function deleteEvent(uuid3) {
45333
+ try {
45334
+ const owner = await findEventOwner(uuid3);
45335
+ if (!owner) return { ok: false };
45336
+ const ownerPath = pathOf(owner.filePath);
45337
+ const s = await parseSectionsFromStorage(ownerPath, owner.filePath);
45338
+ const before = s.events.length;
45339
+ s.events = s.events.filter((e) => e.uuid !== uuid3);
45340
+ if (s.events.length === before) return { ok: false };
45341
+ await writeSectionsToStorage(ownerPath, s);
45342
+ await commitChanges(owner.filePath, `Deleted event ${uuid3}`);
45343
+ return { ok: true, physicalPath: owner.filePath };
45344
+ } catch (error48) {
45345
+ logger.error(`Error deleting event ${uuid3}: ${error48}`);
45346
+ return { ok: false };
45347
+ }
45348
+ }
45209
45349
  async function findStateMachineOwner(smUuid) {
45210
45350
  const packages = await listPackages();
45211
45351
  for (const pkg of packages) {
@@ -45270,7 +45410,8 @@ async function writeStateMachine(sm, packageName) {
45270
45410
  rules: [],
45271
45411
  cases: [],
45272
45412
  actions: [],
45273
- stateMachines: [sm]
45413
+ stateMachines: [sm],
45414
+ events: []
45274
45415
  });
45275
45416
  await commitChanges(String(newFilePath), `Added stateMachine: ${sm.name} (${sm.uuid})`);
45276
45417
  return { ok: true, physicalPath: String(newFilePath) };
@@ -45378,9 +45519,15 @@ var init_fileOperations = __esm({
45378
45519
  __name(writeDictionaryMetadata, "writeDictionaryMetadata");
45379
45520
  __name(listAllDictionaries, "listAllDictionaries");
45380
45521
  __name(findActionOwner, "findActionOwner");
45522
+ __name(readActionsForPackage, "readActionsForPackage");
45381
45523
  __name(readActionsForEntity, "readActionsForEntity");
45382
45524
  __name(writeAction, "writeAction");
45383
45525
  __name(deleteAction, "deleteAction");
45526
+ __name(findEventOwner, "findEventOwner");
45527
+ __name(readEventsForPackage, "readEventsForPackage");
45528
+ __name(readEventsForEntity, "readEventsForEntity");
45529
+ __name(writeEvent, "writeEvent");
45530
+ __name(deleteEvent, "deleteEvent");
45384
45531
  __name(findStateMachineOwner, "findStateMachineOwner");
45385
45532
  __name(readStateMachinesForEntity, "readStateMachinesForEntity");
45386
45533
  __name(writeStateMachine, "writeStateMachine");
@@ -115147,22 +115294,22 @@ var chat_routes_exports = {};
115147
115294
  __export(chat_routes_exports, {
115148
115295
  default: () => chat_routes_default
115149
115296
  });
115150
- var import_express18, router17, chat_routes_default;
115297
+ var import_express19, router18, chat_routes_default;
115151
115298
  var init_chat_routes = __esm({
115152
115299
  "backend/src/routes/ai/chat.routes.ts"() {
115153
115300
  "use strict";
115154
- import_express18 = __toESM(require_express2(), 1);
115301
+ import_express19 = __toESM(require_express2(), 1);
115155
115302
  init_aiController();
115156
- router17 = (0, import_express18.Router)();
115157
- router17.post("/api/ai/chat", aiChat);
115158
- router17.post("/api/ai/chat/approve", aiChatApprove);
115159
- router17.get("/api/ai/status", aiStatus);
115160
- router17.get("/api/ai/config", aiGetConfig);
115161
- router17.post("/api/ai/config", aiSaveConfig);
115162
- router17.get("/api/ai/tools", aiTools);
115163
- router17.get("/api/ai/mentions/search", aiMentionsSearch);
115164
- router17.post("/api/ai/test-tools", aiTestTools);
115165
- chat_routes_default = router17;
115303
+ router18 = (0, import_express19.Router)();
115304
+ router18.post("/api/ai/chat", aiChat);
115305
+ router18.post("/api/ai/chat/approve", aiChatApprove);
115306
+ router18.get("/api/ai/status", aiStatus);
115307
+ router18.get("/api/ai/config", aiGetConfig);
115308
+ router18.post("/api/ai/config", aiSaveConfig);
115309
+ router18.get("/api/ai/tools", aiTools);
115310
+ router18.get("/api/ai/mentions/search", aiMentionsSearch);
115311
+ router18.post("/api/ai/test-tools", aiTestTools);
115312
+ chat_routes_default = router18;
115166
115313
  }
115167
115314
  });
115168
115315
 
@@ -115171,19 +115318,19 @@ var conversation_routes_exports = {};
115171
115318
  __export(conversation_routes_exports, {
115172
115319
  default: () => conversation_routes_default
115173
115320
  });
115174
- var import_express19, router18, conversation_routes_default;
115321
+ var import_express20, router19, conversation_routes_default;
115175
115322
  var init_conversation_routes = __esm({
115176
115323
  "backend/src/routes/ai/conversation.routes.ts"() {
115177
115324
  "use strict";
115178
- import_express19 = __toESM(require_express2(), 1);
115325
+ import_express20 = __toESM(require_express2(), 1);
115179
115326
  init_aiController();
115180
- router18 = (0, import_express19.Router)();
115181
- router18.get("/api/ai/conversations", listConversations);
115182
- router18.get("/api/ai/conversations/:id", getConversation);
115183
- router18.post("/api/ai/conversations", saveConversation);
115184
- router18.patch("/api/ai/conversations/:id", patchConversation);
115185
- router18.delete("/api/ai/conversations/:id", deleteConversation);
115186
- conversation_routes_default = router18;
115327
+ router19 = (0, import_express20.Router)();
115328
+ router19.get("/api/ai/conversations", listConversations);
115329
+ router19.get("/api/ai/conversations/:id", getConversation);
115330
+ router19.post("/api/ai/conversations", saveConversation);
115331
+ router19.patch("/api/ai/conversations/:id", patchConversation);
115332
+ router19.delete("/api/ai/conversations/:id", deleteConversation);
115333
+ conversation_routes_default = router19;
115187
115334
  }
115188
115335
  });
115189
115336
 
@@ -115192,19 +115339,19 @@ var prompt_routes_exports = {};
115192
115339
  __export(prompt_routes_exports, {
115193
115340
  default: () => prompt_routes_default
115194
115341
  });
115195
- var import_express20, router19, prompt_routes_default;
115342
+ var import_express21, router20, prompt_routes_default;
115196
115343
  var init_prompt_routes = __esm({
115197
115344
  "backend/src/routes/ai/prompt.routes.ts"() {
115198
115345
  "use strict";
115199
- import_express20 = __toESM(require_express2(), 1);
115346
+ import_express21 = __toESM(require_express2(), 1);
115200
115347
  init_aiController();
115201
- router19 = (0, import_express20.Router)();
115202
- router19.get("/api/ai/prompts", listPrompts);
115203
- router19.get("/api/ai/prompts/:id", getPrompt);
115204
- router19.post("/api/ai/prompts", createPrompt);
115205
- router19.put("/api/ai/prompts/:id", updatePrompt);
115206
- router19.delete("/api/ai/prompts/:id", deletePrompt);
115207
- prompt_routes_default = router19;
115348
+ router20 = (0, import_express21.Router)();
115349
+ router20.get("/api/ai/prompts", listPrompts);
115350
+ router20.get("/api/ai/prompts/:id", getPrompt);
115351
+ router20.post("/api/ai/prompts", createPrompt);
115352
+ router20.put("/api/ai/prompts/:id", updatePrompt);
115353
+ router20.delete("/api/ai/prompts/:id", deletePrompt);
115354
+ prompt_routes_default = router20;
115208
115355
  }
115209
115356
  });
115210
115357
 
@@ -115240,19 +115387,19 @@ function mergeMaskedRecord(incoming, existing) {
115240
115387
  }
115241
115388
  return out;
115242
115389
  }
115243
- var import_express21, router20, MASK, looksLikeEnvRef, mcp_routes_default;
115390
+ var import_express22, router21, MASK, looksLikeEnvRef, mcp_routes_default;
115244
115391
  var init_mcp_routes = __esm({
115245
115392
  "backend/src/routes/ai/mcp.routes.ts"() {
115246
115393
  "use strict";
115247
- import_express21 = __toESM(require_express2(), 1);
115394
+ import_express22 = __toESM(require_express2(), 1);
115248
115395
  init_mcpClientRegistry();
115249
- router20 = (0, import_express21.Router)();
115396
+ router21 = (0, import_express22.Router)();
115250
115397
  MASK = "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022";
115251
115398
  looksLikeEnvRef = /* @__PURE__ */ __name((v) => /\$\{[^}]+\}/.test(v), "looksLikeEnvRef");
115252
115399
  __name(maskRecord, "maskRecord");
115253
115400
  __name(maskConnection, "maskConnection");
115254
115401
  __name(mergeMaskedRecord, "mergeMaskedRecord");
115255
- router20.get("/api/ai/mcp/connections", (_req, res) => {
115402
+ router21.get("/api/ai/mcp/connections", (_req, res) => {
115256
115403
  try {
115257
115404
  const connections = mcpClientRegistry.getConnections().map(maskConnection);
115258
115405
  res.json({ data: connections });
@@ -115261,7 +115408,7 @@ var init_mcp_routes = __esm({
115261
115408
  res.status(500).json({ error: msg });
115262
115409
  }
115263
115410
  });
115264
- router20.post("/api/ai/mcp/connections", (req, res) => {
115411
+ router21.post("/api/ai/mcp/connections", (req, res) => {
115265
115412
  try {
115266
115413
  const body = req.body;
115267
115414
  const errors = mcpClientRegistry.validateConnection(body);
@@ -115281,7 +115428,7 @@ var init_mcp_routes = __esm({
115281
115428
  res.status(500).json({ error: msg });
115282
115429
  }
115283
115430
  });
115284
- router20.delete("/api/ai/mcp/connections/:id", (req, res) => {
115431
+ router21.delete("/api/ai/mcp/connections/:id", (req, res) => {
115285
115432
  try {
115286
115433
  const { id } = req.params;
115287
115434
  const deleted = mcpClientRegistry.deleteConnection(id);
@@ -115294,7 +115441,7 @@ var init_mcp_routes = __esm({
115294
115441
  res.status(500).json({ error: msg });
115295
115442
  }
115296
115443
  });
115297
- router20.post("/api/ai/mcp/connections/:id/test", async (req, res) => {
115444
+ router21.post("/api/ai/mcp/connections/:id/test", async (req, res) => {
115298
115445
  try {
115299
115446
  const { id } = req.params;
115300
115447
  const result = await mcpClientRegistry.testConnection(id);
@@ -115308,7 +115455,7 @@ var init_mcp_routes = __esm({
115308
115455
  res.status(500).json({ error: msg });
115309
115456
  }
115310
115457
  });
115311
- mcp_routes_default = router20;
115458
+ mcp_routes_default = router21;
115312
115459
  }
115313
115460
  });
115314
115461
 
@@ -115487,16 +115634,16 @@ var init_workspace_manager = __esm({
115487
115634
  });
115488
115635
 
115489
115636
  // backend/node_modules/@hamak/filesystem-server-impl/dist/routing/file-router.js
115490
- var import_express29, FileRouter;
115637
+ var import_express30, FileRouter;
115491
115638
  var init_file_router = __esm({
115492
115639
  "backend/node_modules/@hamak/filesystem-server-impl/dist/routing/file-router.js"() {
115493
- import_express29 = __toESM(require_express2(), 1);
115640
+ import_express30 = __toESM(require_express2(), 1);
115494
115641
  FileRouter = class {
115495
115642
  static {
115496
115643
  __name(this, "FileRouter");
115497
115644
  }
115498
115645
  constructor(workspaceManager2, options2) {
115499
- this.router = (0, import_express29.Router)();
115646
+ this.router = (0, import_express30.Router)();
115500
115647
  this.workspaceManager = workspaceManager2;
115501
115648
  this.enricherRegistry = options2?.enricherRegistry;
115502
115649
  this.initializeRoutes();
@@ -115623,7 +115770,7 @@ var init_file_router = __esm({
115623
115770
 
115624
115771
  // backend/node_modules/@hamak/filesystem-server-impl/dist/routing/create-router.js
115625
115772
  function createFileSystemRouter(workspaceManager2, config3) {
115626
- const app2 = (0, import_express30.Router)();
115773
+ const app2 = (0, import_express31.Router)();
115627
115774
  if (config3.enableCors ?? DEFAULT_FILESYSTEM_SERVER_CONFIG.enableCors) {
115628
115775
  app2.use((0, import_cors.default)());
115629
115776
  }
@@ -115633,10 +115780,10 @@ function createFileSystemRouter(workspaceManager2, config3) {
115633
115780
  app2.use(mountPath, fileRouter2.router);
115634
115781
  return app2;
115635
115782
  }
115636
- var import_express30, import_cors, import_body_parser;
115783
+ var import_express31, import_cors, import_body_parser;
115637
115784
  var init_create_router = __esm({
115638
115785
  "backend/node_modules/@hamak/filesystem-server-impl/dist/routing/create-router.js"() {
115639
- import_express30 = __toESM(require_express2(), 1);
115786
+ import_express31 = __toESM(require_express2(), 1);
115640
115787
  import_cors = __toESM(require_lib3(), 1);
115641
115788
  import_body_parser = __toESM(require_body_parser(), 1);
115642
115789
  init_dist9();
@@ -155345,8 +155492,8 @@ function respondError(res, err, fallbackStatus = 500) {
155345
155492
  res.status(fallbackStatus).json({ error: message });
155346
155493
  }
155347
155494
  function createLogicalFsRouter() {
155348
- const router28 = (0, import_express31.Router)();
155349
- router28.get("/:workspace/files/*", async (req, res) => {
155495
+ const router29 = (0, import_express32.Router)();
155496
+ router29.get("/:workspace/files/*", async (req, res) => {
155350
155497
  try {
155351
155498
  const ws = wsId(req.params.workspace);
155352
155499
  const projection = getProjection(ws);
@@ -155364,7 +155511,7 @@ function createLogicalFsRouter() {
155364
155511
  respondError(res, err);
155365
155512
  }
155366
155513
  });
155367
- router28.get("/:workspace/read/*", async (req, res) => {
155514
+ router29.get("/:workspace/read/*", async (req, res) => {
155368
155515
  try {
155369
155516
  const ws = wsId(req.params.workspace);
155370
155517
  const projection = getProjection(ws);
@@ -155408,9 +155555,9 @@ function createLogicalFsRouter() {
155408
155555
  respondError(res, err);
155409
155556
  }
155410
155557
  }, "writeHandler");
155411
- router28.put("/:workspace/put/*", writeHandler);
155412
- router28.post("/:workspace/post/*", writeHandler);
155413
- router28.delete("/:workspace/delete/*", async (req, res) => {
155558
+ router29.put("/:workspace/put/*", writeHandler);
155559
+ router29.post("/:workspace/post/*", writeHandler);
155560
+ router29.delete("/:workspace/delete/*", async (req, res) => {
155414
155561
  try {
155415
155562
  const ws = wsId(req.params.workspace);
155416
155563
  const projection = getProjection(ws);
@@ -155422,7 +155569,7 @@ function createLogicalFsRouter() {
155422
155569
  respondError(res, err);
155423
155570
  }
155424
155571
  });
155425
- router28.get("/:workspace/by-uuid/:uuid", (req, res) => {
155572
+ router29.get("/:workspace/by-uuid/:uuid", (req, res) => {
155426
155573
  try {
155427
155574
  const ws = wsId(req.params.workspace);
155428
155575
  const index = getUuidIndex(ws);
@@ -155437,13 +155584,13 @@ function createLogicalFsRouter() {
155437
155584
  respondError(res, err);
155438
155585
  }
155439
155586
  });
155440
- return router28;
155587
+ return router29;
155441
155588
  }
155442
- var import_express31;
155589
+ var import_express32;
155443
155590
  var init_logicalFsRouter = __esm({
155444
155591
  "backend/src/routes/logicalFsRouter.ts"() {
155445
155592
  "use strict";
155446
- import_express31 = __toESM(require_express2(), 1);
155593
+ import_express32 = __toESM(require_express2(), 1);
155447
155594
  init_types();
155448
155595
  init_ProjectionRegistry();
155449
155596
  init_UuidIndex();
@@ -155454,7 +155601,7 @@ var init_logicalFsRouter = __esm({
155454
155601
  });
155455
155602
 
155456
155603
  // backend/src/server.ts
155457
- var import_express32 = __toESM(require_express2(), 1);
155604
+ var import_express33 = __toESM(require_express2(), 1);
155458
155605
  var import_cors2 = __toESM(require_lib3(), 1);
155459
155606
  var import_dotenv2 = __toESM(require_main(), 1);
155460
155607
  import fs5 from "fs";
@@ -155462,7 +155609,7 @@ import path13 from "path";
155462
155609
  import os3 from "os";
155463
155610
 
155464
155611
  // backend/src/routes/index.ts
155465
- var import_express28 = __toESM(require_express2(), 1);
155612
+ var import_express29 = __toESM(require_express2(), 1);
155466
155613
 
155467
155614
  // backend/src/routes/auth.routes.ts
155468
155615
  var import_express = __toESM(require_express2(), 1);
@@ -155640,7 +155787,7 @@ router.get("/api/auth/me", verifyToken, getCurrentUser);
155640
155787
  var auth_routes_default = router;
155641
155788
 
155642
155789
  // backend/src/routes/data-dictionary/index.ts
155643
- var import_express17 = __toESM(require_express2(), 1);
155790
+ var import_express18 = __toESM(require_express2(), 1);
155644
155791
 
155645
155792
  // backend/src/routes/data-dictionary/package.routes.ts
155646
155793
  var import_express3 = __toESM(require_express2(), 1);
@@ -161605,6 +161752,7 @@ var FLOW_STEP_KINDS = /* @__PURE__ */ new Set([
161605
161752
  "wait",
161606
161753
  "callExternal"
161607
161754
  ]);
161755
+ var ACTION_KINDS = /* @__PURE__ */ new Set(["command", "query"]);
161608
161756
 
161609
161757
  // backend/src/services/actionService.ts
161610
161758
  init_fileOperations();
@@ -161632,11 +161780,39 @@ function checkInvokeRefs(steps, knownActionUuids, pathPrefix, errors) {
161632
161780
  }
161633
161781
  }
161634
161782
  __name(checkInvokeRefs, "checkInvokeRefs");
161635
- function validateAction(action, knownActionUuids) {
161783
+ function checkEventRefs(steps, knownEventUuids, pathPrefix, errors) {
161784
+ for (let i = 0; i < steps.length; i++) {
161785
+ const step = steps[i];
161786
+ const path14 = `${pathPrefix}[${i}]`;
161787
+ if (step.kind === "emitEvent" || step.kind === "wait") {
161788
+ if (step.eventRef && !knownEventUuids.has(step.eventRef)) {
161789
+ errors.push({
161790
+ field: `${path14}.eventRef`,
161791
+ message: `${step.kind} references unknown event UUID '${step.eventRef}' at ${path14}`
161792
+ });
161793
+ }
161794
+ } else if (step.kind === "branch") {
161795
+ if (step.then && step.then.length > 0) {
161796
+ checkEventRefs(step.then, knownEventUuids, `${path14}.then`, errors);
161797
+ }
161798
+ if (step.else && step.else.length > 0) {
161799
+ checkEventRefs(step.else, knownEventUuids, `${path14}.else`, errors);
161800
+ }
161801
+ }
161802
+ }
161803
+ }
161804
+ __name(checkEventRefs, "checkEventRefs");
161805
+ function validateAction(action, knownActionUuids, knownEventUuids) {
161636
161806
  const errors = [];
161637
161807
  if (!action.uuid) errors.push({ field: "uuid", message: "uuid is required" });
161638
161808
  if (!action.name) errors.push({ field: "name", message: "name is required" });
161639
161809
  if (!action.ownerRef) errors.push({ field: "ownerRef", message: "ownerRef is required" });
161810
+ if (action.actionKind !== void 0 && !ACTION_KINDS.has(action.actionKind)) {
161811
+ errors.push({
161812
+ field: "actionKind",
161813
+ message: `Invalid actionKind '${action.actionKind}'. Must be one of: ${[...ACTION_KINDS].join(", ")}`
161814
+ });
161815
+ }
161640
161816
  if (action.params && action.params.length > 0) {
161641
161817
  const names = action.params.map((p) => p.name);
161642
161818
  const unique = new Set(names);
@@ -161661,6 +161837,9 @@ function validateAction(action, knownActionUuids) {
161661
161837
  if (knownActionUuids !== void 0) {
161662
161838
  checkInvokeRefs(action.flow, knownActionUuids, "flow", errors);
161663
161839
  }
161840
+ if (knownEventUuids !== void 0) {
161841
+ checkEventRefs(action.flow, knownEventUuids, "flow", errors);
161842
+ }
161664
161843
  }
161665
161844
  return errors;
161666
161845
  }
@@ -161669,12 +161848,15 @@ var ActionService = class {
161669
161848
  static {
161670
161849
  __name(this, "ActionService");
161671
161850
  }
161672
- /** List all actions. Optionally filter by ownerRef (entity UUID). */
161851
+ /** List all actions. Optionally filter by ownerRef (entity UUID) or package. */
161673
161852
  async list(filters = {}) {
161674
161853
  try {
161675
161854
  if (filters.ownerRef) {
161676
161855
  return await readActionsForEntity(filters.ownerRef);
161677
161856
  }
161857
+ if (filters.packageName) {
161858
+ return await readActionsForPackage(filters.packageName);
161859
+ }
161678
161860
  const packages = await listPackages();
161679
161861
  const result = [];
161680
161862
  for (const pkg of packages) {
@@ -161710,6 +161892,7 @@ var ActionService = class {
161710
161892
  description: data.description,
161711
161893
  ownerRef: data.ownerRef || "",
161712
161894
  internal: data.internal ?? false,
161895
+ actionKind: data.actionKind,
161713
161896
  params: data.params ?? [],
161714
161897
  returns: data.returns,
161715
161898
  flow: data.flow ?? [],
@@ -161722,7 +161905,8 @@ var ActionService = class {
161722
161905
  }
161723
161906
  const knownActionUuids = new Set(packageModel.ownership.actionByUuid.keys());
161724
161907
  knownActionUuids.add(action.uuid);
161725
- const errors = validateAction(action, knownActionUuids);
161908
+ const knownEventUuids = new Set(packageModel.ownership.eventByUuid.keys());
161909
+ const errors = validateAction(action, knownActionUuids, knownEventUuids);
161726
161910
  if (errors.length > 0) return { errors };
161727
161911
  const result = await writeAction(action, packageName);
161728
161912
  if (!result.ok) {
@@ -161748,7 +161932,8 @@ var ActionService = class {
161748
161932
  }
161749
161933
  const knownActionUuids = new Set(packageModel.ownership.actionByUuid.keys());
161750
161934
  knownActionUuids.add(uuid3);
161751
- const errors = validateAction(updated, knownActionUuids);
161935
+ const knownEventUuids = new Set(packageModel.ownership.eventByUuid.keys());
161936
+ const errors = validateAction(updated, knownActionUuids, knownEventUuids);
161752
161937
  if (errors.length > 0) return { errors };
161753
161938
  const result = await writeAction(updated, packageName);
161754
161939
  if (!result.ok) {
@@ -161779,6 +161964,16 @@ var actionService = new ActionService();
161779
161964
 
161780
161965
  // backend/src/controllers/actionController.ts
161781
161966
  init_logger();
161967
+ var listActions = /* @__PURE__ */ __name(async (req, res) => {
161968
+ try {
161969
+ const packageName = typeof req.query.package === "string" ? req.query.package : void 0;
161970
+ const actions = await actionService.list({ packageName });
161971
+ res.json({ message: "Success", data: actions });
161972
+ } catch (error48) {
161973
+ logger.error("Error listing actions", error48);
161974
+ res.status(500).json({ message: "Error listing actions", error: error48 });
161975
+ }
161976
+ }, "listActions");
161782
161977
  var listActionsForEntity = /* @__PURE__ */ __name(async (req, res) => {
161783
161978
  try {
161784
161979
  const actions = await actionService.list({ ownerRef: req.params.uuid });
@@ -161839,15 +162034,229 @@ var deleteAction2 = /* @__PURE__ */ __name(async (req, res) => {
161839
162034
  // backend/src/routes/data-dictionary/action.routes.ts
161840
162035
  var router14 = (0, import_express15.Router)();
161841
162036
  router14.get("/api/entities/:uuid/actions", listActionsForEntity);
162037
+ router14.get("/api/actions", listActions);
161842
162038
  router14.get("/api/actions/:uuid", getAction);
161843
162039
  router14.post("/api/actions", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), createAction);
161844
162040
  router14.put("/api/actions/:uuid", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), updateAction);
161845
162041
  router14.delete("/api/actions/:uuid", authorizeJwt(["admin" /* ADMIN */]), deleteAction2);
161846
162042
  var action_routes_default = router14;
161847
162043
 
161848
- // backend/src/routes/data-dictionary/state-machine.routes.ts
162044
+ // backend/src/routes/data-dictionary/event.routes.ts
161849
162045
  var import_express16 = __toESM(require_express2(), 1);
161850
162046
 
162047
+ // backend/src/services/eventService.ts
162048
+ init_fileOperations();
162049
+ init_uuid();
162050
+ init_logger();
162051
+ function validateEvent(event) {
162052
+ const errors = [];
162053
+ if (!event.uuid) errors.push({ field: "uuid", message: "uuid is required" });
162054
+ if (!event.name) errors.push({ field: "name", message: "name is required" });
162055
+ if (event.payload && event.payload.length > 0) {
162056
+ const names = event.payload.map((a) => a.name);
162057
+ if (new Set(names).size !== names.length) {
162058
+ errors.push({ field: "payload", message: "Event payload attributes must have unique names" });
162059
+ }
162060
+ for (const a of event.payload) {
162061
+ if (!a.name) errors.push({ field: "payload", message: "Each payload attribute must have a name" });
162062
+ }
162063
+ }
162064
+ return errors;
162065
+ }
162066
+ __name(validateEvent, "validateEvent");
162067
+ var EventService = class {
162068
+ static {
162069
+ __name(this, "EventService");
162070
+ }
162071
+ /**
162072
+ * List events. Filter by `ownerRef` (entity UUID) or `packageName`; with no
162073
+ * filter, scan all packages.
162074
+ */
162075
+ async list(filters = {}) {
162076
+ try {
162077
+ if (filters.ownerRef) return await readEventsForEntity(filters.ownerRef);
162078
+ if (filters.packageName) return await readEventsForPackage(filters.packageName);
162079
+ const packages = await listPackages();
162080
+ const result = [];
162081
+ for (const pkg of packages) {
162082
+ const model = await loadPackage(pkg);
162083
+ result.push(...model.events);
162084
+ }
162085
+ return result;
162086
+ } catch (error48) {
162087
+ logger.error(`Error listing events: ${error48}`);
162088
+ return [];
162089
+ }
162090
+ }
162091
+ /** Get one event by UUID. */
162092
+ async getByUuid(uuid3) {
162093
+ try {
162094
+ const owner = await findEventOwner(uuid3);
162095
+ if (!owner) return null;
162096
+ const model = await loadPackage(owner.packageName);
162097
+ return model.events.find((e) => e.uuid === uuid3) ?? null;
162098
+ } catch (error48) {
162099
+ logger.error(`Error getting event ${uuid3}: ${error48}`);
162100
+ return null;
162101
+ }
162102
+ }
162103
+ /**
162104
+ * Create a new event. The target package is derived from `ownerRef` (the
162105
+ * owning entity's package) or an explicit `packageName`.
162106
+ */
162107
+ async create(data) {
162108
+ const event = {
162109
+ uuid: data.uuid || generateUUID(),
162110
+ name: data.name || "",
162111
+ description: data.description,
162112
+ ownerRef: data.ownerRef || void 0,
162113
+ payload: data.payload ?? void 0,
162114
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
162115
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
162116
+ };
162117
+ const resolved = await this.resolveTargetPackage(event.ownerRef, data.packageName);
162118
+ if ("errors" in resolved) return resolved;
162119
+ const packageName = resolved.packageName;
162120
+ const errors = validateEvent(event);
162121
+ const model = await loadPackage(packageName);
162122
+ if (model.events.some((e) => e.name === event.name && e.uuid !== event.uuid)) {
162123
+ errors.push({ field: "name", message: `An event named '${event.name}' already exists in package '${packageName}'` });
162124
+ }
162125
+ if (errors.length > 0) return { errors };
162126
+ const result = await writeEvent(event, packageName);
162127
+ if (!result.ok) return { errors: [{ field: "_", message: "Failed to persist event" }] };
162128
+ return event;
162129
+ }
162130
+ /** Update an existing event. */
162131
+ async update(uuid3, data) {
162132
+ const owner = await findEventOwner(uuid3);
162133
+ if (!owner) return null;
162134
+ const existing = (await loadPackage(owner.packageName)).events.find((e) => e.uuid === uuid3);
162135
+ if (!existing) return null;
162136
+ const updated = {
162137
+ ...existing,
162138
+ ...data,
162139
+ uuid: uuid3,
162140
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
162141
+ };
162142
+ const errors = validateEvent(updated);
162143
+ const model = await loadPackage(owner.packageName);
162144
+ if (model.events.some((e) => e.name === updated.name && e.uuid !== uuid3)) {
162145
+ errors.push({ field: "name", message: `An event named '${updated.name}' already exists in package '${owner.packageName}'` });
162146
+ }
162147
+ if (errors.length > 0) return { errors };
162148
+ const result = await writeEvent(updated, owner.packageName);
162149
+ if (!result.ok) return { errors: [{ field: "_", message: "Failed to persist event" }] };
162150
+ return updated;
162151
+ }
162152
+ /** Delete an event by UUID. */
162153
+ async delete(uuid3) {
162154
+ const result = await deleteEvent(uuid3);
162155
+ return result.ok;
162156
+ }
162157
+ /** Resolve the package a new event should be written to. */
162158
+ async resolveTargetPackage(ownerRef, explicitPackage) {
162159
+ const packages = await listPackages();
162160
+ if (ownerRef) {
162161
+ for (const pkg of packages) {
162162
+ const model = await loadPackage(pkg);
162163
+ if (model.ownership.entityByUuid.has(ownerRef)) return { packageName: pkg };
162164
+ }
162165
+ return { errors: [{ field: "ownerRef", message: `Entity '${ownerRef}' not found in any package` }] };
162166
+ }
162167
+ if (explicitPackage) {
162168
+ if (!packages.includes(explicitPackage)) {
162169
+ return { errors: [{ field: "packageName", message: `Package '${explicitPackage}' not found` }] };
162170
+ }
162171
+ return { packageName: explicitPackage };
162172
+ }
162173
+ return { errors: [{ field: "ownerRef", message: "Either ownerRef (entity) or packageName is required" }] };
162174
+ }
162175
+ };
162176
+ var eventService = new EventService();
162177
+
162178
+ // backend/src/controllers/eventController.ts
162179
+ init_logger();
162180
+ var listEvents = /* @__PURE__ */ __name(async (req, res) => {
162181
+ try {
162182
+ const packageName = typeof req.query.package === "string" ? req.query.package : void 0;
162183
+ const events = await eventService.list({ packageName });
162184
+ res.json({ message: "Success", data: events });
162185
+ } catch (error48) {
162186
+ logger.error("Error listing events", error48);
162187
+ res.status(500).json({ message: "Error listing events", error: error48 });
162188
+ }
162189
+ }, "listEvents");
162190
+ var listEventsForEntity = /* @__PURE__ */ __name(async (req, res) => {
162191
+ try {
162192
+ const events = await eventService.list({ ownerRef: req.params.uuid });
162193
+ res.json({ message: "Success", data: events });
162194
+ } catch (error48) {
162195
+ logger.error("Error listing events for entity", error48);
162196
+ res.status(500).json({ message: "Error listing events for entity", error: error48 });
162197
+ }
162198
+ }, "listEventsForEntity");
162199
+ var getEvent = /* @__PURE__ */ __name(async (req, res) => {
162200
+ try {
162201
+ const event = await eventService.getByUuid(req.params.uuid);
162202
+ if (!event) return res.status(404).json({ message: "Event not found" });
162203
+ res.json({ message: "Success", data: event });
162204
+ } catch (error48) {
162205
+ logger.error("Error fetching event", error48);
162206
+ res.status(500).json({ message: "Error fetching event", error: error48 });
162207
+ }
162208
+ }, "getEvent");
162209
+ var createEvent = /* @__PURE__ */ __name(async (req, res) => {
162210
+ try {
162211
+ const result = await eventService.create(req.body);
162212
+ if ("errors" in result) {
162213
+ return res.status(400).json({ message: "Failed to create event", errors: result.errors });
162214
+ }
162215
+ res.status(201).json({ message: "Event created successfully", data: result });
162216
+ } catch (error48) {
162217
+ logger.error("Error creating event", error48);
162218
+ res.status(500).json({ message: "Error creating event", error: error48 });
162219
+ }
162220
+ }, "createEvent");
162221
+ var updateEvent = /* @__PURE__ */ __name(async (req, res) => {
162222
+ try {
162223
+ const result = await eventService.update(req.params.uuid, req.body);
162224
+ if (result === null) {
162225
+ return res.status(404).json({ message: "Event not found" });
162226
+ }
162227
+ if ("errors" in result) {
162228
+ return res.status(400).json({ message: "Failed to update event", errors: result.errors });
162229
+ }
162230
+ res.json({ message: "Event updated successfully", data: result });
162231
+ } catch (error48) {
162232
+ logger.error("Error updating event", error48);
162233
+ res.status(500).json({ message: "Error updating event", error: error48 });
162234
+ }
162235
+ }, "updateEvent");
162236
+ var deleteEvent2 = /* @__PURE__ */ __name(async (req, res) => {
162237
+ try {
162238
+ const ok2 = await eventService.delete(req.params.uuid);
162239
+ if (!ok2) return res.status(404).json({ message: "Event not found" });
162240
+ res.json({ message: "Event deleted successfully" });
162241
+ } catch (error48) {
162242
+ logger.error("Error deleting event", error48);
162243
+ res.status(500).json({ message: "Error deleting event", error: error48 });
162244
+ }
162245
+ }, "deleteEvent");
162246
+
162247
+ // backend/src/routes/data-dictionary/event.routes.ts
162248
+ var router15 = (0, import_express16.Router)();
162249
+ router15.get("/api/events", listEvents);
162250
+ router15.get("/api/entities/:uuid/events", listEventsForEntity);
162251
+ router15.get("/api/events/:uuid", getEvent);
162252
+ router15.post("/api/events", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), createEvent);
162253
+ router15.put("/api/events/:uuid", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), updateEvent);
162254
+ router15.delete("/api/events/:uuid", authorizeJwt(["admin" /* ADMIN */]), deleteEvent2);
162255
+ var event_routes_default = router15;
162256
+
162257
+ // backend/src/routes/data-dictionary/state-machine.routes.ts
162258
+ var import_express17 = __toESM(require_express2(), 1);
162259
+
161851
162260
  // backend/src/services/stateMachineService.ts
161852
162261
  init_fileOperations();
161853
162262
  init_uuid();
@@ -162096,59 +162505,60 @@ var deleteStateMachine2 = /* @__PURE__ */ __name(async (req, res) => {
162096
162505
  }, "deleteStateMachine");
162097
162506
 
162098
162507
  // backend/src/routes/data-dictionary/state-machine.routes.ts
162099
- var router15 = (0, import_express16.Router)();
162100
- router15.get("/api/entities/:uuid/state-machines", listStateMachinesForEntity);
162101
- router15.get("/api/state-machines/:uuid", getStateMachine);
162102
- router15.post("/api/state-machines", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), createStateMachine);
162103
- router15.put("/api/state-machines/:uuid", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), updateStateMachine);
162104
- router15.delete("/api/state-machines/:uuid", authorizeJwt(["admin" /* ADMIN */]), deleteStateMachine2);
162105
- var state_machine_routes_default = router15;
162508
+ var router16 = (0, import_express17.Router)();
162509
+ router16.get("/api/entities/:uuid/state-machines", listStateMachinesForEntity);
162510
+ router16.get("/api/state-machines/:uuid", getStateMachine);
162511
+ router16.post("/api/state-machines", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), createStateMachine);
162512
+ router16.put("/api/state-machines/:uuid", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), updateStateMachine);
162513
+ router16.delete("/api/state-machines/:uuid", authorizeJwt(["admin" /* ADMIN */]), deleteStateMachine2);
162514
+ var state_machine_routes_default = router16;
162106
162515
 
162107
162516
  // backend/src/routes/data-dictionary/index.ts
162108
- var router16 = (0, import_express17.Router)();
162109
- router16.use(package_routes_default);
162110
- router16.use(relationship_routes_default);
162111
- router16.use(entity_routes_default);
162112
- router16.use(stereotype_routes_default);
162113
- router16.use(case_routes_default);
162114
- router16.use(rule_routes_default);
162115
- router16.use(integrity_routes_default);
162116
- router16.use(model_metadata_routes_default);
162117
- router16.use(dico_config_routes_default);
162118
- router16.use(diff_routes_default);
162119
- router16.use(import_export_routes_default);
162120
- router16.use(publish_routes_default);
162121
- router16.use(action_routes_default);
162122
- router16.use(state_machine_routes_default);
162123
- var data_dictionary_default = router16;
162517
+ var router17 = (0, import_express18.Router)();
162518
+ router17.use(package_routes_default);
162519
+ router17.use(relationship_routes_default);
162520
+ router17.use(entity_routes_default);
162521
+ router17.use(stereotype_routes_default);
162522
+ router17.use(case_routes_default);
162523
+ router17.use(rule_routes_default);
162524
+ router17.use(integrity_routes_default);
162525
+ router17.use(model_metadata_routes_default);
162526
+ router17.use(dico_config_routes_default);
162527
+ router17.use(diff_routes_default);
162528
+ router17.use(import_export_routes_default);
162529
+ router17.use(publish_routes_default);
162530
+ router17.use(action_routes_default);
162531
+ router17.use(event_routes_default);
162532
+ router17.use(state_machine_routes_default);
162533
+ var data_dictionary_default = router17;
162124
162534
 
162125
162535
  // backend/src/routes/ai/index.ts
162126
- var import_express22 = __toESM(require_express2(), 1);
162127
- var router21 = (0, import_express22.Router)();
162536
+ var import_express23 = __toESM(require_express2(), 1);
162537
+ var router22 = (0, import_express23.Router)();
162128
162538
  (async () => {
162129
162539
  try {
162130
162540
  const chatRoutes = (await Promise.resolve().then(() => (init_chat_routes(), chat_routes_exports))).default;
162131
162541
  const conversationRoutes = (await Promise.resolve().then(() => (init_conversation_routes(), conversation_routes_exports))).default;
162132
162542
  const promptRoutes = (await Promise.resolve().then(() => (init_prompt_routes(), prompt_routes_exports))).default;
162133
162543
  const mcpRoutes = (await Promise.resolve().then(() => (init_mcp_routes(), mcp_routes_exports))).default;
162134
- router21.use(chatRoutes);
162135
- router21.use(conversationRoutes);
162136
- router21.use(promptRoutes);
162137
- router21.use(mcpRoutes);
162544
+ router22.use(chatRoutes);
162545
+ router22.use(conversationRoutes);
162546
+ router22.use(promptRoutes);
162547
+ router22.use(mcpRoutes);
162138
162548
  } catch {
162139
162549
  }
162140
162550
  })();
162141
- var ai_default = router21;
162551
+ var ai_default = router22;
162142
162552
 
162143
162553
  // backend/src/routes/search.routes.ts
162144
- var import_express23 = __toESM(require_express2(), 1);
162145
- var router22 = (0, import_express23.Router)();
162146
- router22.get("/api/entities/flat", getFlatEntitiesAndAttributes);
162147
- router22.get("/api/search", searchEntities);
162148
- var search_routes_default = router22;
162554
+ var import_express24 = __toESM(require_express2(), 1);
162555
+ var router23 = (0, import_express24.Router)();
162556
+ router23.get("/api/entities/flat", getFlatEntitiesAndAttributes);
162557
+ router23.get("/api/search", searchEntities);
162558
+ var search_routes_default = router23;
162149
162559
 
162150
162560
  // backend/src/routes/visualization.routes.ts
162151
- var import_express24 = __toESM(require_express2(), 1);
162561
+ var import_express25 = __toESM(require_express2(), 1);
162152
162562
 
162153
162563
  // backend/src/controllers/diagramController.ts
162154
162564
  init_diagramService();
@@ -162277,21 +162687,21 @@ var DiagramController = class {
162277
162687
  var diagramController = new DiagramController();
162278
162688
 
162279
162689
  // backend/src/routes/visualization.routes.ts
162280
- var router23 = (0, import_express24.Router)();
162281
- router23.get("/api/graph/:service", getGraphData);
162282
- router23.get("/api/entities/:uuid/impact", getImpactAnalysis);
162283
- router23.get("/api/entities/:uuid/lineage", getLineage);
162284
- router23.get("/api/diagrams", diagramController.listDiagramLayouts.bind(diagramController));
162285
- router23.post("/api/diagrams", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), diagramController.saveDiagramLayout.bind(diagramController));
162286
- router23.get("/api/diagrams/:id", diagramController.loadDiagramLayout.bind(diagramController));
162287
- router23.put("/api/diagrams/:id", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), diagramController.updateDiagramLayout.bind(diagramController));
162288
- router23.delete("/api/diagrams/:id", authorizeJwt(["admin" /* ADMIN */]), diagramController.deleteDiagramLayout.bind(diagramController));
162289
- var visualization_routes_default = router23;
162690
+ var router24 = (0, import_express25.Router)();
162691
+ router24.get("/api/graph/:service", getGraphData);
162692
+ router24.get("/api/entities/:uuid/impact", getImpactAnalysis);
162693
+ router24.get("/api/entities/:uuid/lineage", getLineage);
162694
+ router24.get("/api/diagrams", diagramController.listDiagramLayouts.bind(diagramController));
162695
+ router24.post("/api/diagrams", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), diagramController.saveDiagramLayout.bind(diagramController));
162696
+ router24.get("/api/diagrams/:id", diagramController.loadDiagramLayout.bind(diagramController));
162697
+ router24.put("/api/diagrams/:id", authorizeJwt(["admin" /* ADMIN */, "editor" /* EDITOR */]), diagramController.updateDiagramLayout.bind(diagramController));
162698
+ router24.delete("/api/diagrams/:id", authorizeJwt(["admin" /* ADMIN */]), diagramController.deleteDiagramLayout.bind(diagramController));
162699
+ var visualization_routes_default = router24;
162290
162700
 
162291
162701
  // backend/src/routes/status.routes.ts
162292
- var import_express25 = __toESM(require_express2(), 1);
162293
- var router24 = (0, import_express25.Router)();
162294
- router24.get("/api/status", (req, res) => {
162702
+ var import_express26 = __toESM(require_express2(), 1);
162703
+ var router25 = (0, import_express26.Router)();
162704
+ router25.get("/api/status", (req, res) => {
162295
162705
  const profile = process.env.PROFILE || "local";
162296
162706
  res.json({
162297
162707
  status: "operational",
@@ -162301,17 +162711,17 @@ router24.get("/api/status", (req, res) => {
162301
162711
  auth: profile === "local" ? "none" : "jwt"
162302
162712
  });
162303
162713
  });
162304
- var status_routes_default = router24;
162714
+ var status_routes_default = router25;
162305
162715
 
162306
162716
  // backend/src/routes/project.routes.ts
162307
- var import_express26 = __toESM(require_express2(), 1);
162717
+ var import_express27 = __toESM(require_express2(), 1);
162308
162718
  init_config();
162309
162719
  import fs2 from "fs";
162310
162720
  import path9 from "path";
162311
162721
  import os2 from "os";
162312
162722
  init_appDir();
162313
162723
  init_logger();
162314
- var router25 = (0, import_express26.Router)();
162724
+ var router26 = (0, import_express27.Router)();
162315
162725
  var RESTART_EXIT_CODE = 75;
162316
162726
  function applyProjectSwitch(req, res, dataDir, message) {
162317
162727
  if (process.env.SDD_MANAGED === "1") {
@@ -162354,7 +162764,7 @@ function applyProjectSwitch(req, res, dataDir, message) {
162354
162764
  res.json({ message, data: { path: dataDir, name: path9.basename(path9.dirname(dataDir)) }, restarting: false });
162355
162765
  }
162356
162766
  __name(applyProjectSwitch, "applyProjectSwitch");
162357
- router25.get("/api/filesystem/browse", (req, res) => {
162767
+ router26.get("/api/filesystem/browse", (req, res) => {
162358
162768
  if (config.profile !== "local") {
162359
162769
  return res.status(403).json({ message: "Filesystem browsing is only available in local mode" });
162360
162770
  }
@@ -162379,7 +162789,7 @@ router25.get("/api/filesystem/browse", (req, res) => {
162379
162789
  res.status(500).json({ message: `Failed to read directory: ${e}` });
162380
162790
  }
162381
162791
  });
162382
- router25.get("/api/project", (req, res) => {
162792
+ router26.get("/api/project", (req, res) => {
162383
162793
  const dataDir = config.dataDir;
162384
162794
  const isOpen = fs2.existsSync(path9.join(dataDir, "dico.config.json"));
162385
162795
  res.json({
@@ -162391,7 +162801,7 @@ router25.get("/api/project", (req, res) => {
162391
162801
  }
162392
162802
  });
162393
162803
  });
162394
- router25.get("/api/project/status", async (_req, res) => {
162804
+ router26.get("/api/project/status", async (_req, res) => {
162395
162805
  try {
162396
162806
  const { versionService: versionService2 } = await Promise.resolve().then(() => (init_versionService(), versionService_exports));
162397
162807
  const status = await versionService2.getWorkingTreeStatus();
@@ -162400,7 +162810,7 @@ router25.get("/api/project/status", async (_req, res) => {
162400
162810
  res.status(500).json({ message: `Failed to read project status: ${e}` });
162401
162811
  }
162402
162812
  });
162403
- router25.post("/api/project/open", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162813
+ router26.post("/api/project/open", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162404
162814
  if (config.profile !== "local") {
162405
162815
  return res.status(403).json({ message: "Project switching is only available in local mode" });
162406
162816
  }
@@ -162420,7 +162830,7 @@ router25.post("/api/project/open", authorizeJwt(["admin" /* ADMIN */]), (req, re
162420
162830
  }
162421
162831
  applyProjectSwitch(req, res, dataDir, `Project opened: ${dataDir}`);
162422
162832
  });
162423
- router25.post("/api/project/close", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162833
+ router26.post("/api/project/close", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162424
162834
  if (config.profile !== "local") {
162425
162835
  return res.status(403).json({ message: "Project switching is only available in local mode" });
162426
162836
  }
@@ -162428,7 +162838,7 @@ router25.post("/api/project/close", authorizeJwt(["admin" /* ADMIN */]), (req, r
162428
162838
  if (!fs2.existsSync(emptyDir)) fs2.mkdirSync(emptyDir, { recursive: true });
162429
162839
  applyProjectSwitch(req, res, emptyDir, "Project closed");
162430
162840
  });
162431
- router25.post("/api/project/init", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162841
+ router26.post("/api/project/init", authorizeJwt(["admin" /* ADMIN */]), (req, res) => {
162432
162842
  if (config.profile !== "local") {
162433
162843
  return res.status(403).json({ message: "Project initialization is only available in local mode" });
162434
162844
  }
@@ -162454,10 +162864,10 @@ router25.post("/api/project/init", authorizeJwt(["admin" /* ADMIN */]), (req, re
162454
162864
  res.status(500).json({ message: `Failed to initialize project: ${e}` });
162455
162865
  }
162456
162866
  });
162457
- var project_routes_default = router25;
162867
+ var project_routes_default = router26;
162458
162868
 
162459
162869
  // backend/src/routes/orm.routes.ts
162460
- var import_express27 = __toESM(require_express2(), 1);
162870
+ var import_express28 = __toESM(require_express2(), 1);
162461
162871
 
162462
162872
  // backend/src/models/ormVocabulary.ts
162463
162873
  var ORM_PREFIX = "orm.";
@@ -162520,23 +162930,23 @@ var ORM_FLAG_KEYS = new Set(
162520
162930
  );
162521
162931
 
162522
162932
  // backend/src/routes/orm.routes.ts
162523
- var router26 = (0, import_express27.Router)();
162524
- router26.get("/api/orm/vocabulary", (_req, res) => {
162933
+ var router27 = (0, import_express28.Router)();
162934
+ router27.get("/api/orm/vocabulary", (_req, res) => {
162525
162935
  res.json({ data: { prefix: ORM_PREFIX, scopes: ORM_VOCABULARY } });
162526
162936
  });
162527
- var orm_routes_default = router26;
162937
+ var orm_routes_default = router27;
162528
162938
 
162529
162939
  // backend/src/routes/index.ts
162530
- var router27 = (0, import_express28.Router)();
162531
- router27.use(status_routes_default);
162532
- router27.use(auth_routes_default);
162533
- router27.use(search_routes_default);
162534
- router27.use(visualization_routes_default);
162535
- router27.use(project_routes_default);
162536
- router27.use(orm_routes_default);
162537
- router27.use(data_dictionary_default);
162538
- router27.use(ai_default);
162539
- var routes_default = router27;
162940
+ var router28 = (0, import_express29.Router)();
162941
+ router28.use(status_routes_default);
162942
+ router28.use(auth_routes_default);
162943
+ router28.use(search_routes_default);
162944
+ router28.use(visualization_routes_default);
162945
+ router28.use(project_routes_default);
162946
+ router28.use(orm_routes_default);
162947
+ router28.use(data_dictionary_default);
162948
+ router28.use(ai_default);
162949
+ var routes_default = router28;
162540
162950
 
162541
162951
  // backend/src/server.ts
162542
162952
  init_logger();
@@ -163075,7 +163485,7 @@ if (process.env.SDD_DEV === "1") {
163075
163485
  } catch {
163076
163486
  }
163077
163487
  }
163078
- var app = (0, import_express32.default)();
163488
+ var app = (0, import_express33.default)();
163079
163489
  var port = config.port;
163080
163490
  app.use((0, import_cors2.default)());
163081
163491
  app.use((req, res, next) => {
@@ -163092,7 +163502,7 @@ app.use((req, res, next) => {
163092
163502
  });
163093
163503
  next();
163094
163504
  });
163095
- app.use(import_express32.default.json());
163505
+ app.use(import_express33.default.json());
163096
163506
  if (!config.isProduction) {
163097
163507
  app.get("/", (req, res) => {
163098
163508
  res.json({ message: "Welcome to the Data Dictionary Management System API" });
@@ -163210,7 +163620,7 @@ if (config.isProduction) {
163210
163620
  }
163211
163621
  });
163212
163622
  if (publicDir) {
163213
- app.use(import_express32.default.static(publicDir));
163623
+ app.use(import_express33.default.static(publicDir));
163214
163624
  app.get("*", (req, res, next) => {
163215
163625
  if (req.path.startsWith("/api") || req.path.startsWith("/fs") || req.path.startsWith("/api-docs") || req.path.includes(".")) {
163216
163626
  return next();