@eventcatalog/sdk 2.14.0 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -61,10 +61,30 @@ function serializeBaseFields(resource, indent = " ") {
61
61
  }
62
62
  return lines.join("\n");
63
63
  }
64
- function resolveMessageType(catalogDir, id) {
65
- if ((0, import_glob.globSync)(`**/events/${id}/index.{md,mdx}`, { cwd: catalogDir }).length > 0) return "event";
66
- if ((0, import_glob.globSync)(`**/commands/${id}/index.{md,mdx}`, { cwd: catalogDir }).length > 0) return "command";
67
- if ((0, import_glob.globSync)(`**/queries/${id}/index.{md,mdx}`, { cwd: catalogDir }).length > 0) return "query";
64
+ function buildMessageTypeIndex(catalogDir) {
65
+ const index = /* @__PURE__ */ new Map();
66
+ const types = ["events", "commands", "queries"];
67
+ const typeMap = { events: "event", commands: "command", queries: "query" };
68
+ for (const type of types) {
69
+ const matches = (0, import_glob.globSync)(`**/${type}/*/index.{md,mdx}`, { cwd: catalogDir });
70
+ for (const match of matches) {
71
+ const parts = match.replace(/\\/g, "/").split("/");
72
+ const typeIdx = parts.lastIndexOf(type);
73
+ if (typeIdx !== -1 && typeIdx + 1 < parts.length) {
74
+ const id = parts[typeIdx + 1];
75
+ if (!index.has(id)) index.set(id, typeMap[type]);
76
+ }
77
+ }
78
+ }
79
+ return index;
80
+ }
81
+ function resolveMessageType(catalogDirOrIndex, id) {
82
+ if (typeof catalogDirOrIndex !== "string") {
83
+ return catalogDirOrIndex.get(id);
84
+ }
85
+ if ((0, import_glob.globSync)(`**/events/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "event";
86
+ if ((0, import_glob.globSync)(`**/commands/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "command";
87
+ if ((0, import_glob.globSync)(`**/queries/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "query";
68
88
  return void 0;
69
89
  }
70
90
  function serializeChannelRef(channel) {
@@ -72,10 +92,10 @@ function serializeChannelRef(channel) {
72
92
  if (channel.version) ref += `@${channel.version}`;
73
93
  return ref;
74
94
  }
75
- function serializeMessagePointers(items, direction, catalogDir, indent = " ") {
95
+ function serializeMessagePointers(items, direction, catalogDirOrIndex, indent = " ") {
76
96
  const lines = [];
77
97
  for (const item of items) {
78
- const msgType = resolveMessageType(catalogDir, item.id);
98
+ const msgType = resolveMessageType(catalogDirOrIndex, item.id);
79
99
  if (!msgType) continue;
80
100
  let ref = `${item.id}`;
81
101
  if (item.version) ref += `@${item.version}`;
@@ -107,6 +127,7 @@ ${body}
107
127
  // src/dsl/service.ts
108
128
  async function serviceToDSL(resource, options, getMessageFn) {
109
129
  const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
130
+ const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
110
131
  const parts = [];
111
132
  if (hydrate && getMessageFn) {
112
133
  const allMessages = [...resource.sends || [], ...resource.receives || []];
@@ -114,7 +135,7 @@ async function serviceToDSL(resource, options, getMessageFn) {
114
135
  const key = `${msg.id}@${msg.version || "latest"}`;
115
136
  if (_seen.has(key)) continue;
116
137
  _seen.add(key);
117
- const msgType = resolveMessageType(catalogDir, msg.id);
138
+ const msgType = resolveMessageType(msgIndex, msg.id);
118
139
  if (!msgType) continue;
119
140
  const msgResource = await getMessageFn(msg.id, msg.version);
120
141
  if (msgResource) {
@@ -126,11 +147,11 @@ async function serviceToDSL(resource, options, getMessageFn) {
126
147
  const baseFields = serializeBaseFields(resource);
127
148
  if (baseFields) lines.push(baseFields);
128
149
  if (resource.sends && resource.sends.length > 0) {
129
- const sendsStr = serializeMessagePointers(resource.sends, "sends", catalogDir);
150
+ const sendsStr = serializeMessagePointers(resource.sends, "sends", msgIndex);
130
151
  if (sendsStr) lines.push(sendsStr);
131
152
  }
132
153
  if (resource.receives && resource.receives.length > 0) {
133
- const recvStr = serializeMessagePointers(resource.receives, "receives", catalogDir);
154
+ const recvStr = serializeMessagePointers(resource.receives, "receives", msgIndex);
134
155
  if (recvStr) lines.push(recvStr);
135
156
  }
136
157
  if (resource.writesTo && resource.writesTo.length > 0) {
@@ -243,6 +264,7 @@ async function hydrateChannelsFromMessages(messages, resolvers, seen, parts) {
243
264
  }
244
265
  async function buildDomainBody(resource, options, resolvers, keyword) {
245
266
  const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
267
+ const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
246
268
  const topLevelParts = [];
247
269
  if (hydrate && resolvers) {
248
270
  if (resource.services && resource.services.length > 0 && resolvers.getService) {
@@ -255,7 +277,7 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
255
277
  await hydrateOwners(svc.owners, resolvers, _seen, topLevelParts);
256
278
  const svcMessages = [...svc.sends || [], ...svc.receives || []];
257
279
  await hydrateChannelsFromMessages(svcMessages, resolvers, _seen, topLevelParts);
258
- const svcDsl = await serviceToDSL(svc, { catalogDir, hydrate: true, _seen }, resolvers.getMessage);
280
+ const svcDsl = await serviceToDSL(svc, { catalogDir, hydrate: true, _seen, _msgIndex: msgIndex }, resolvers.getMessage);
259
281
  topLevelParts.push(svcDsl);
260
282
  }
261
283
  }
@@ -267,7 +289,7 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
267
289
  const key = `${msg.id}@${msg.version || "latest"}`;
268
290
  if (_seen.has(key)) continue;
269
291
  _seen.add(key);
270
- const msgType = resolveMessageType(catalogDir, msg.id);
292
+ const msgType = resolveMessageType(msgIndex, msg.id);
271
293
  if (!msgType) continue;
272
294
  const msgResource = await resolvers.getMessage(msg.id, msg.version);
273
295
  if (msgResource) {
@@ -287,11 +309,11 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
287
309
  }
288
310
  }
289
311
  if (resource.sends && resource.sends.length > 0) {
290
- const sendsStr = serializeMessagePointers(resource.sends, "sends", catalogDir);
312
+ const sendsStr = serializeMessagePointers(resource.sends, "sends", msgIndex);
291
313
  if (sendsStr) lines.push(sendsStr);
292
314
  }
293
315
  if (resource.receives && resource.receives.length > 0) {
294
- const recvStr = serializeMessagePointers(resource.receives, "receives", catalogDir);
316
+ const recvStr = serializeMessagePointers(resource.receives, "receives", msgIndex);
295
317
  if (recvStr) lines.push(recvStr);
296
318
  }
297
319
  if (resource.domains && resource.domains.length > 0) {
@@ -303,7 +325,12 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
303
325
  const subDomain = await resolvers.getDomain(subRef.id, subRef.version);
304
326
  if (subDomain) {
305
327
  await hydrateOwners(subDomain.owners, resolvers, _seen, topLevelParts);
306
- const sub = await buildDomainBody(subDomain, { catalogDir, hydrate, _seen }, resolvers, "subdomain");
328
+ const sub = await buildDomainBody(
329
+ subDomain,
330
+ { catalogDir, hydrate, _seen, _msgIndex: msgIndex },
331
+ resolvers,
332
+ "subdomain"
333
+ );
307
334
  topLevelParts.push(...sub.topLevelParts);
308
335
  const indented = sub.block.split("\n").map((line) => ` ${line}`).join("\n");
309
336
  lines.push(indented);
@@ -325,15 +352,16 @@ ${body}
325
352
  }
326
353
  async function domainToDSL(resource, options, resolvers) {
327
354
  const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
328
- const result = await buildDomainBody(resource, { catalogDir, hydrate, _seen }, resolvers, "domain");
355
+ const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
356
+ const result = await buildDomainBody(resource, { catalogDir, hydrate, _seen, _msgIndex: msgIndex }, resolvers, "domain");
329
357
  const parts = [...result.topLevelParts, result.block];
330
358
  return parts.join("\n\n");
331
359
  }
332
360
 
333
361
  // src/dsl/index.ts
334
- function getMessage(resolvers, catalogDir) {
362
+ function getMessage(resolvers, msgIndex) {
335
363
  return async (id, version) => {
336
- const msgType = resolveMessageType(catalogDir, id);
364
+ const msgType = resolveMessageType(msgIndex, id);
337
365
  if (!msgType) return void 0;
338
366
  switch (msgType) {
339
367
  case "event":
@@ -382,6 +410,7 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
382
410
  const resources = Array.isArray(resource) ? resource : [resource];
383
411
  const seen = /* @__PURE__ */ new Set();
384
412
  const parts = [];
413
+ const msgIndex = buildMessageTypeIndex(catalogDir);
385
414
  for (const res of resources) {
386
415
  const key = `${options.type}:${res.id}@${res.version || "latest"}`;
387
416
  if (seen.has(key)) continue;
@@ -403,8 +432,8 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
403
432
  parts.push(
404
433
  await serviceToDSL(
405
434
  res,
406
- { catalogDir, hydrate: options.hydrate, _seen: seen },
407
- getMessage(resolvers, catalogDir)
435
+ { catalogDir, hydrate: options.hydrate, _seen: seen, _msgIndex: msgIndex },
436
+ getMessage(resolvers, msgIndex)
408
437
  )
409
438
  );
410
439
  break;
@@ -415,11 +444,11 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
415
444
  parts.push(
416
445
  await domainToDSL(
417
446
  res,
418
- { catalogDir, hydrate: options.hydrate, _seen: seen },
447
+ { catalogDir, hydrate: options.hydrate, _seen: seen, _msgIndex: msgIndex },
419
448
  {
420
449
  getService: resolvers.getService,
421
450
  getDomain: resolvers.getDomain,
422
- getMessage: getMessage(resolvers, catalogDir),
451
+ getMessage: getMessage(resolvers, msgIndex),
423
452
  getChannel: resolvers.getChannel,
424
453
  getTeam: resolvers.getTeam,
425
454
  getUser: resolvers.getUser
@@ -443,39 +472,147 @@ var import_fs_extra = require("fs-extra");
443
472
  var import_node_path = require("path");
444
473
  var import_gray_matter = __toESM(require("gray-matter"));
445
474
  var import_semver = require("semver");
475
+ var _fileIndexCache = null;
476
+ var _fileIndexCatalogDir = null;
477
+ var _matterCache = null;
478
+ var _filePathToIdCache = null;
479
+ var _fileIndexMtimeMs = 0;
480
+ function toCanonicalPath(inputPath) {
481
+ return (0, import_node_path.normalize)((0, import_node_path.resolve)(inputPath));
482
+ }
483
+ function buildFileCache(catalogDir) {
484
+ const canonicalCatalogDir = toCanonicalPath(catalogDir);
485
+ const files = (0, import_glob2.globSync)("**/index.{md,mdx}", {
486
+ cwd: canonicalCatalogDir,
487
+ ignore: ["node_modules/**"],
488
+ absolute: true,
489
+ nodir: true
490
+ }).map(import_node_path.normalize);
491
+ const index = /* @__PURE__ */ new Map();
492
+ const matterResults = /* @__PURE__ */ new Map();
493
+ const pathToId = /* @__PURE__ */ new Map();
494
+ for (const file of files) {
495
+ const content = import_node_fs.default.readFileSync(file, "utf-8");
496
+ const parsed = (0, import_gray_matter.default)(content);
497
+ matterResults.set(file, parsed);
498
+ const id = parsed.data.id;
499
+ if (!id) continue;
500
+ const resourceId = String(id);
501
+ const version = parsed.data.version || "";
502
+ const isVersioned = file.includes("versioned");
503
+ const entry = { path: file, id: resourceId, version: String(version), isVersioned };
504
+ pathToId.set(file, resourceId);
505
+ const existing = index.get(resourceId);
506
+ if (existing) {
507
+ existing.push(entry);
508
+ } else {
509
+ index.set(resourceId, [entry]);
510
+ }
511
+ }
512
+ _fileIndexCache = index;
513
+ _fileIndexCatalogDir = canonicalCatalogDir;
514
+ _matterCache = matterResults;
515
+ _filePathToIdCache = pathToId;
516
+ try {
517
+ _fileIndexMtimeMs = import_node_fs.default.statSync(canonicalCatalogDir).mtimeMs;
518
+ } catch {
519
+ _fileIndexMtimeMs = 0;
520
+ }
521
+ }
522
+ function ensureFileCache(catalogDir) {
523
+ const canonicalCatalogDir = toCanonicalPath(catalogDir);
524
+ if (!_fileIndexCache || _fileIndexCatalogDir !== canonicalCatalogDir) {
525
+ buildFileCache(catalogDir);
526
+ return;
527
+ }
528
+ try {
529
+ const currentMtime = import_node_fs.default.statSync(canonicalCatalogDir).mtimeMs;
530
+ if (currentMtime !== _fileIndexMtimeMs) {
531
+ buildFileCache(catalogDir);
532
+ }
533
+ } catch {
534
+ buildFileCache(catalogDir);
535
+ }
536
+ }
537
+ function invalidateFileCache() {
538
+ _fileIndexCache = null;
539
+ _fileIndexCatalogDir = null;
540
+ _matterCache = null;
541
+ _filePathToIdCache = null;
542
+ }
543
+ function upsertFileCacheEntry(catalogDir, filePath, rawContent) {
544
+ const canonicalCatalogDir = toCanonicalPath(catalogDir);
545
+ if (!_fileIndexCache || !_matterCache || !_filePathToIdCache || _fileIndexCatalogDir !== canonicalCatalogDir) {
546
+ return;
547
+ }
548
+ const normalizedPath = toCanonicalPath(filePath);
549
+ const parsed = (0, import_gray_matter.default)(rawContent);
550
+ const previousId = _filePathToIdCache.get(normalizedPath);
551
+ if (previousId) {
552
+ const previousEntries = _fileIndexCache.get(previousId) || [];
553
+ const nextEntries = previousEntries.filter((entry2) => entry2.path !== normalizedPath);
554
+ if (nextEntries.length === 0) {
555
+ _fileIndexCache.delete(previousId);
556
+ } else {
557
+ _fileIndexCache.set(previousId, nextEntries);
558
+ }
559
+ _filePathToIdCache.delete(normalizedPath);
560
+ }
561
+ _matterCache.set(normalizedPath, parsed);
562
+ const id = parsed.data.id;
563
+ if (!id) {
564
+ _filePathToIdCache.delete(normalizedPath);
565
+ return;
566
+ }
567
+ const resourceId = String(id);
568
+ const entry = {
569
+ path: normalizedPath,
570
+ id: resourceId,
571
+ version: String(parsed.data.version || ""),
572
+ isVersioned: normalizedPath.includes(`${import_node_path.sep}versioned${import_node_path.sep}`)
573
+ };
574
+ const entries = _fileIndexCache.get(resourceId) || [];
575
+ entries.push(entry);
576
+ _fileIndexCache.set(resourceId, entries);
577
+ _filePathToIdCache.set(normalizedPath, resourceId);
578
+ try {
579
+ _fileIndexMtimeMs = import_node_fs.default.statSync(canonicalCatalogDir).mtimeMs;
580
+ } catch {
581
+ }
582
+ }
583
+ function cachedMatterRead(filePath) {
584
+ if (_matterCache) {
585
+ const cached = _matterCache.get(filePath);
586
+ if (cached) return cached;
587
+ }
588
+ return import_gray_matter.default.read(filePath);
589
+ }
446
590
  var versionExists = async (catalogDir, id, version) => {
447
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
448
- const matchedFiles = await searchFilesForId(files, id, version) || [];
449
- return matchedFiles.length > 0;
591
+ ensureFileCache(catalogDir);
592
+ const entries = _fileIndexCache.get(id);
593
+ if (!entries) return false;
594
+ return entries.some((e) => e.version === version);
450
595
  };
451
596
  var findFileById = async (catalogDir, id, version) => {
452
- const files = await getFiles(`${catalogDir}/**/index.{md,mdx}`);
453
- const matchedFiles = await searchFilesForId(files, id) || [];
454
- const latestVersion = matchedFiles.find((path6) => !path6.includes("versioned"));
455
- if (!version) {
456
- return latestVersion;
457
- }
458
- const parsedFiles = matchedFiles.map((path6) => {
459
- const { data } = import_gray_matter.default.read(path6);
460
- return { ...data, path: path6 };
461
- });
462
- if (version === "latest") {
463
- return latestVersion;
464
- }
465
- const exactMatch = parsedFiles.find((c) => c.version === version);
466
- if (exactMatch) {
467
- return exactMatch.path;
468
- }
597
+ ensureFileCache(catalogDir);
598
+ const entries = _fileIndexCache.get(id);
599
+ if (!entries || entries.length === 0) return void 0;
600
+ const latestEntry = entries.find((e) => !e.isVersioned);
601
+ if (!version || version === "latest") {
602
+ return latestEntry?.path;
603
+ }
604
+ const exactMatch = entries.find((e) => e.version === version);
605
+ if (exactMatch) return exactMatch.path;
469
606
  const semverRange = (0, import_semver.validRange)(version);
470
607
  if (semverRange) {
471
- const match = parsedFiles.filter((c) => {
608
+ const match = entries.find((e) => {
472
609
  try {
473
- return (0, import_semver.satisfies)(c.version, semverRange);
474
- } catch (error) {
610
+ return (0, import_semver.satisfies)(e.version, semverRange);
611
+ } catch {
475
612
  return false;
476
613
  }
477
614
  });
478
- return match.length > 0 ? match[0].path : void 0;
615
+ return match?.path;
479
616
  }
480
617
  return void 0;
481
618
  };
@@ -591,6 +728,7 @@ var versionResource = async (catalogDir, id) => {
591
728
  })
592
729
  );
593
730
  });
731
+ invalidateFileCache();
594
732
  };
595
733
  var writeResource = async (catalogDir, resource, options = {
596
734
  path: "",
@@ -630,6 +768,7 @@ var writeResource = async (catalogDir, resource, options = {
630
768
  }
631
769
  const document = import_gray_matter2.default.stringify(markdown.trim(), frontmatter);
632
770
  import_node_fs2.default.writeFileSync(lockPath, document);
771
+ upsertFileCacheEntry(catalogDir, lockPath, document);
633
772
  } finally {
634
773
  await (0, import_proper_lockfile.unlock)(lockPath).catch(() => {
635
774
  });
@@ -639,7 +778,7 @@ var getResource = async (catalogDir, id, version, options, filePath) => {
639
778
  const attachSchema = options?.attachSchema || false;
640
779
  const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
641
780
  if (!file || !import_node_fs2.default.existsSync(file)) return;
642
- const { data, content } = import_gray_matter2.default.read(file);
781
+ const { data, content } = cachedMatterRead(file);
643
782
  if (attachSchema && data?.schemaPath) {
644
783
  const resourceDirectory = (0, import_path.dirname)(file);
645
784
  const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
@@ -690,7 +829,7 @@ var getResources = async (catalogDir, {
690
829
  const files = await getFiles(filePattern, [ignoreList, ...ignore]);
691
830
  if (files.length === 0) return;
692
831
  return files.map((file) => {
693
- const { data, content } = import_gray_matter2.default.read(file);
832
+ const { data, content } = cachedMatterRead(file);
694
833
  if (attachSchema && data?.schemaPath) {
695
834
  const resourceDirectory = (0, import_path.dirname)(file);
696
835
  const pathToSchema = (0, import_path.join)(resourceDirectory, data.schemaPath);
@@ -731,6 +870,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
731
870
  })
732
871
  );
733
872
  }
873
+ invalidateFileCache();
734
874
  };
735
875
  var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
736
876
  for (let i = 0; i < maxRetries; i++) {
@@ -796,6 +936,7 @@ var writeEventToService = (directory) => async (event, service, options = { path
796
936
  };
797
937
  var rmEvent = (directory) => async (path6) => {
798
938
  await import_promises2.default.rm((0, import_node_path4.join)(directory, path6), { recursive: true });
939
+ invalidateFileCache();
799
940
  };
800
941
  var rmEventById = (directory) => async (id, version, persistFiles) => {
801
942
  await rmResourceById(directory, id, version, { type: "event", persistFiles });
@@ -832,6 +973,7 @@ var writeCommandToService = (directory) => async (command, service, options = {
832
973
  };
833
974
  var rmCommand = (directory) => async (path6) => {
834
975
  await import_promises3.default.rm((0, import_node_path5.join)(directory, path6), { recursive: true });
976
+ invalidateFileCache();
835
977
  };
836
978
  var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
837
979
  var versionCommand = (directory) => async (id) => versionResource(directory, id);
@@ -866,6 +1008,7 @@ var writeQueryToService = (directory) => async (query, service, options = { path
866
1008
  };
867
1009
  var rmQuery = (directory) => async (path6) => {
868
1010
  await import_promises4.default.rm((0, import_node_path6.join)(directory, path6), { recursive: true });
1011
+ invalidateFileCache();
869
1012
  };
870
1013
  var rmQueryById = (directory) => async (id, version, persistFiles) => {
871
1014
  await rmResourceById(directory, id, version, { type: "query", persistFiles });
@@ -931,6 +1074,7 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
931
1074
  var versionService = (directory) => async (id) => versionResource(directory, id);
932
1075
  var rmService = (directory) => async (path6) => {
933
1076
  await import_promises5.default.rm((0, import_node_path7.join)(directory, path6), { recursive: true });
1077
+ invalidateFileCache();
934
1078
  };
935
1079
  var rmServiceById = (directory) => async (id, version, persistFiles) => {
936
1080
  await rmResourceById(directory, id, version, { type: "service", persistFiles });
@@ -1107,6 +1251,7 @@ var writeDomain = (directory) => async (domain, options = {
1107
1251
  var versionDomain = (directory) => async (id) => versionResource(directory, id);
1108
1252
  var rmDomain = (directory) => async (path6) => {
1109
1253
  await import_promises6.default.rm((0, import_node_path8.join)(directory, path6), { recursive: true });
1254
+ invalidateFileCache();
1110
1255
  };
1111
1256
  var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
1112
1257
  var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
@@ -1238,6 +1383,7 @@ var getChannels = (directory) => async (options) => getResources(directory, { ty
1238
1383
  var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
1239
1384
  var rmChannel = (directory) => async (path6) => {
1240
1385
  await import_promises7.default.rm((0, import_node_path9.join)(directory, path6), { recursive: true });
1386
+ invalidateFileCache();
1241
1387
  };
1242
1388
  var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
1243
1389
  var versionChannel = (directory) => async (id) => versionResource(directory, id);
@@ -1410,10 +1556,12 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
1410
1556
  import_node_fs4.default.mkdirSync(import_node_path11.default.dirname(fullPath), { recursive: true });
1411
1557
  const document = import_gray_matter5.default.stringify(customDoc.markdown.trim(), rest);
1412
1558
  import_node_fs4.default.writeFileSync(fullPath, document);
1559
+ invalidateFileCache();
1413
1560
  };
1414
1561
  var rmCustomDoc = (directory) => async (filePath) => {
1415
1562
  const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
1416
1563
  await import_promises8.default.rm((0, import_node_path11.join)(directory, withExtension), { recursive: true });
1564
+ invalidateFileCache();
1417
1565
  };
1418
1566
 
1419
1567
  // src/teams.ts
@@ -1465,9 +1613,11 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
1465
1613
  const document = import_gray_matter6.default.stringify(markdown, frontmatter);
1466
1614
  import_node_fs5.default.mkdirSync((0, import_node_path12.join)(catalogDir, ""), { recursive: true });
1467
1615
  import_node_fs5.default.writeFileSync((0, import_node_path12.join)(catalogDir, "", `${resource.id}.mdx`), document);
1616
+ invalidateFileCache();
1468
1617
  };
1469
1618
  var rmUserById = (catalogDir) => async (id) => {
1470
1619
  import_node_fs5.default.rmSync((0, import_node_path12.join)(catalogDir, `${id}.mdx`), { recursive: true });
1620
+ invalidateFileCache();
1471
1621
  };
1472
1622
 
1473
1623
  // src/teams.ts
@@ -1507,9 +1657,11 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
1507
1657
  const document = import_gray_matter7.default.stringify(markdown, frontmatter);
1508
1658
  import_node_fs6.default.mkdirSync((0, import_node_path13.join)(catalogDir, ""), { recursive: true });
1509
1659
  import_node_fs6.default.writeFileSync((0, import_node_path13.join)(catalogDir, "", `${resource.id}.mdx`), document);
1660
+ invalidateFileCache();
1510
1661
  };
1511
1662
  var rmTeamById = (catalogDir) => async (id) => {
1512
1663
  await import_promises9.default.rm((0, import_node_path13.join)(catalogDir, `${id}.mdx`), { recursive: true });
1664
+ invalidateFileCache();
1513
1665
  };
1514
1666
  var getOwnersForResource = (catalogDir) => async (id, version) => {
1515
1667
  const resource = await getResource(catalogDir, id, version);
@@ -1639,6 +1791,7 @@ var writeEntity = (directory) => async (entity, options = {
1639
1791
  }) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
1640
1792
  var rmEntity = (directory) => async (path6) => {
1641
1793
  await import_promises10.default.rm((0, import_node_path16.join)(directory, path6), { recursive: true });
1794
+ invalidateFileCache();
1642
1795
  };
1643
1796
  var rmEntityById = (directory) => async (id, version, persistFiles) => {
1644
1797
  await rmResourceById(directory, id, version, { type: "entity", persistFiles });
@@ -1662,6 +1815,7 @@ var writeContainer = (directory) => async (data, options = {
1662
1815
  var versionContainer = (directory) => async (id) => versionResource(directory, id);
1663
1816
  var rmContainer = (directory) => async (path6) => {
1664
1817
  await import_promises11.default.rm((0, import_node_path17.join)(directory, path6), { recursive: true });
1818
+ invalidateFileCache();
1665
1819
  };
1666
1820
  var rmContainerById = (directory) => async (id, version, persistFiles) => {
1667
1821
  await rmResourceById(directory, id, version, { type: "container", persistFiles });
@@ -1709,6 +1863,7 @@ var writeDataProductToDomain = (directory) => async (dataProduct, domain, option
1709
1863
  };
1710
1864
  var rmDataProduct = (directory) => async (path6) => {
1711
1865
  await import_promises12.default.rm((0, import_node_path18.join)(directory, path6), { recursive: true });
1866
+ invalidateFileCache();
1712
1867
  };
1713
1868
  var rmDataProductById = (directory) => async (id, version, persistFiles) => {
1714
1869
  await rmResourceById(directory, id, version, { type: "data-product", persistFiles });
@@ -1732,6 +1887,7 @@ var writeDiagram = (directory) => async (diagram, options = {
1732
1887
  }) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
1733
1888
  var rmDiagram = (directory) => async (path6) => {
1734
1889
  await import_promises13.default.rm((0, import_node_path19.join)(directory, path6), { recursive: true });
1890
+ invalidateFileCache();
1735
1891
  };
1736
1892
  var rmDiagramById = (directory) => async (id, version, persistFiles) => {
1737
1893
  await rmResourceById(directory, id, version, { type: "diagram", persistFiles });