@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.d.mts +46 -11
- package/dist/index.d.ts +46 -11
- package/dist/index.js +203 -47
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +204 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -2
package/dist/index.mjs
CHANGED
|
@@ -27,10 +27,30 @@ function serializeBaseFields(resource, indent = " ") {
|
|
|
27
27
|
}
|
|
28
28
|
return lines.join("\n");
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
function buildMessageTypeIndex(catalogDir) {
|
|
31
|
+
const index = /* @__PURE__ */ new Map();
|
|
32
|
+
const types = ["events", "commands", "queries"];
|
|
33
|
+
const typeMap = { events: "event", commands: "command", queries: "query" };
|
|
34
|
+
for (const type of types) {
|
|
35
|
+
const matches = globSync(`**/${type}/*/index.{md,mdx}`, { cwd: catalogDir });
|
|
36
|
+
for (const match of matches) {
|
|
37
|
+
const parts = match.replace(/\\/g, "/").split("/");
|
|
38
|
+
const typeIdx = parts.lastIndexOf(type);
|
|
39
|
+
if (typeIdx !== -1 && typeIdx + 1 < parts.length) {
|
|
40
|
+
const id = parts[typeIdx + 1];
|
|
41
|
+
if (!index.has(id)) index.set(id, typeMap[type]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return index;
|
|
46
|
+
}
|
|
47
|
+
function resolveMessageType(catalogDirOrIndex, id) {
|
|
48
|
+
if (typeof catalogDirOrIndex !== "string") {
|
|
49
|
+
return catalogDirOrIndex.get(id);
|
|
50
|
+
}
|
|
51
|
+
if (globSync(`**/events/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "event";
|
|
52
|
+
if (globSync(`**/commands/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "command";
|
|
53
|
+
if (globSync(`**/queries/${id}/index.{md,mdx}`, { cwd: catalogDirOrIndex }).length > 0) return "query";
|
|
34
54
|
return void 0;
|
|
35
55
|
}
|
|
36
56
|
function serializeChannelRef(channel) {
|
|
@@ -38,10 +58,10 @@ function serializeChannelRef(channel) {
|
|
|
38
58
|
if (channel.version) ref += `@${channel.version}`;
|
|
39
59
|
return ref;
|
|
40
60
|
}
|
|
41
|
-
function serializeMessagePointers(items, direction,
|
|
61
|
+
function serializeMessagePointers(items, direction, catalogDirOrIndex, indent = " ") {
|
|
42
62
|
const lines = [];
|
|
43
63
|
for (const item of items) {
|
|
44
|
-
const msgType = resolveMessageType(
|
|
64
|
+
const msgType = resolveMessageType(catalogDirOrIndex, item.id);
|
|
45
65
|
if (!msgType) continue;
|
|
46
66
|
let ref = `${item.id}`;
|
|
47
67
|
if (item.version) ref += `@${item.version}`;
|
|
@@ -73,6 +93,7 @@ ${body}
|
|
|
73
93
|
// src/dsl/service.ts
|
|
74
94
|
async function serviceToDSL(resource, options, getMessageFn) {
|
|
75
95
|
const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
|
|
96
|
+
const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
|
|
76
97
|
const parts = [];
|
|
77
98
|
if (hydrate && getMessageFn) {
|
|
78
99
|
const allMessages = [...resource.sends || [], ...resource.receives || []];
|
|
@@ -80,7 +101,7 @@ async function serviceToDSL(resource, options, getMessageFn) {
|
|
|
80
101
|
const key = `${msg.id}@${msg.version || "latest"}`;
|
|
81
102
|
if (_seen.has(key)) continue;
|
|
82
103
|
_seen.add(key);
|
|
83
|
-
const msgType = resolveMessageType(
|
|
104
|
+
const msgType = resolveMessageType(msgIndex, msg.id);
|
|
84
105
|
if (!msgType) continue;
|
|
85
106
|
const msgResource = await getMessageFn(msg.id, msg.version);
|
|
86
107
|
if (msgResource) {
|
|
@@ -92,11 +113,11 @@ async function serviceToDSL(resource, options, getMessageFn) {
|
|
|
92
113
|
const baseFields = serializeBaseFields(resource);
|
|
93
114
|
if (baseFields) lines.push(baseFields);
|
|
94
115
|
if (resource.sends && resource.sends.length > 0) {
|
|
95
|
-
const sendsStr = serializeMessagePointers(resource.sends, "sends",
|
|
116
|
+
const sendsStr = serializeMessagePointers(resource.sends, "sends", msgIndex);
|
|
96
117
|
if (sendsStr) lines.push(sendsStr);
|
|
97
118
|
}
|
|
98
119
|
if (resource.receives && resource.receives.length > 0) {
|
|
99
|
-
const recvStr = serializeMessagePointers(resource.receives, "receives",
|
|
120
|
+
const recvStr = serializeMessagePointers(resource.receives, "receives", msgIndex);
|
|
100
121
|
if (recvStr) lines.push(recvStr);
|
|
101
122
|
}
|
|
102
123
|
if (resource.writesTo && resource.writesTo.length > 0) {
|
|
@@ -209,6 +230,7 @@ async function hydrateChannelsFromMessages(messages, resolvers, seen, parts) {
|
|
|
209
230
|
}
|
|
210
231
|
async function buildDomainBody(resource, options, resolvers, keyword) {
|
|
211
232
|
const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
|
|
233
|
+
const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
|
|
212
234
|
const topLevelParts = [];
|
|
213
235
|
if (hydrate && resolvers) {
|
|
214
236
|
if (resource.services && resource.services.length > 0 && resolvers.getService) {
|
|
@@ -221,7 +243,7 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
|
|
|
221
243
|
await hydrateOwners(svc.owners, resolvers, _seen, topLevelParts);
|
|
222
244
|
const svcMessages = [...svc.sends || [], ...svc.receives || []];
|
|
223
245
|
await hydrateChannelsFromMessages(svcMessages, resolvers, _seen, topLevelParts);
|
|
224
|
-
const svcDsl = await serviceToDSL(svc, { catalogDir, hydrate: true, _seen }, resolvers.getMessage);
|
|
246
|
+
const svcDsl = await serviceToDSL(svc, { catalogDir, hydrate: true, _seen, _msgIndex: msgIndex }, resolvers.getMessage);
|
|
225
247
|
topLevelParts.push(svcDsl);
|
|
226
248
|
}
|
|
227
249
|
}
|
|
@@ -233,7 +255,7 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
|
|
|
233
255
|
const key = `${msg.id}@${msg.version || "latest"}`;
|
|
234
256
|
if (_seen.has(key)) continue;
|
|
235
257
|
_seen.add(key);
|
|
236
|
-
const msgType = resolveMessageType(
|
|
258
|
+
const msgType = resolveMessageType(msgIndex, msg.id);
|
|
237
259
|
if (!msgType) continue;
|
|
238
260
|
const msgResource = await resolvers.getMessage(msg.id, msg.version);
|
|
239
261
|
if (msgResource) {
|
|
@@ -253,11 +275,11 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
|
|
|
253
275
|
}
|
|
254
276
|
}
|
|
255
277
|
if (resource.sends && resource.sends.length > 0) {
|
|
256
|
-
const sendsStr = serializeMessagePointers(resource.sends, "sends",
|
|
278
|
+
const sendsStr = serializeMessagePointers(resource.sends, "sends", msgIndex);
|
|
257
279
|
if (sendsStr) lines.push(sendsStr);
|
|
258
280
|
}
|
|
259
281
|
if (resource.receives && resource.receives.length > 0) {
|
|
260
|
-
const recvStr = serializeMessagePointers(resource.receives, "receives",
|
|
282
|
+
const recvStr = serializeMessagePointers(resource.receives, "receives", msgIndex);
|
|
261
283
|
if (recvStr) lines.push(recvStr);
|
|
262
284
|
}
|
|
263
285
|
if (resource.domains && resource.domains.length > 0) {
|
|
@@ -269,7 +291,12 @@ async function buildDomainBody(resource, options, resolvers, keyword) {
|
|
|
269
291
|
const subDomain = await resolvers.getDomain(subRef.id, subRef.version);
|
|
270
292
|
if (subDomain) {
|
|
271
293
|
await hydrateOwners(subDomain.owners, resolvers, _seen, topLevelParts);
|
|
272
|
-
const sub = await buildDomainBody(
|
|
294
|
+
const sub = await buildDomainBody(
|
|
295
|
+
subDomain,
|
|
296
|
+
{ catalogDir, hydrate, _seen, _msgIndex: msgIndex },
|
|
297
|
+
resolvers,
|
|
298
|
+
"subdomain"
|
|
299
|
+
);
|
|
273
300
|
topLevelParts.push(...sub.topLevelParts);
|
|
274
301
|
const indented = sub.block.split("\n").map((line) => ` ${line}`).join("\n");
|
|
275
302
|
lines.push(indented);
|
|
@@ -291,15 +318,16 @@ ${body}
|
|
|
291
318
|
}
|
|
292
319
|
async function domainToDSL(resource, options, resolvers) {
|
|
293
320
|
const { catalogDir, hydrate = false, _seen = /* @__PURE__ */ new Set() } = options;
|
|
294
|
-
const
|
|
321
|
+
const msgIndex = options._msgIndex || buildMessageTypeIndex(catalogDir);
|
|
322
|
+
const result = await buildDomainBody(resource, { catalogDir, hydrate, _seen, _msgIndex: msgIndex }, resolvers, "domain");
|
|
295
323
|
const parts = [...result.topLevelParts, result.block];
|
|
296
324
|
return parts.join("\n\n");
|
|
297
325
|
}
|
|
298
326
|
|
|
299
327
|
// src/dsl/index.ts
|
|
300
|
-
function getMessage(resolvers,
|
|
328
|
+
function getMessage(resolvers, msgIndex) {
|
|
301
329
|
return async (id, version) => {
|
|
302
|
-
const msgType = resolveMessageType(
|
|
330
|
+
const msgType = resolveMessageType(msgIndex, id);
|
|
303
331
|
if (!msgType) return void 0;
|
|
304
332
|
switch (msgType) {
|
|
305
333
|
case "event":
|
|
@@ -348,6 +376,7 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
|
|
|
348
376
|
const resources = Array.isArray(resource) ? resource : [resource];
|
|
349
377
|
const seen = /* @__PURE__ */ new Set();
|
|
350
378
|
const parts = [];
|
|
379
|
+
const msgIndex = buildMessageTypeIndex(catalogDir);
|
|
351
380
|
for (const res of resources) {
|
|
352
381
|
const key = `${options.type}:${res.id}@${res.version || "latest"}`;
|
|
353
382
|
if (seen.has(key)) continue;
|
|
@@ -369,8 +398,8 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
|
|
|
369
398
|
parts.push(
|
|
370
399
|
await serviceToDSL(
|
|
371
400
|
res,
|
|
372
|
-
{ catalogDir, hydrate: options.hydrate, _seen: seen },
|
|
373
|
-
getMessage(resolvers,
|
|
401
|
+
{ catalogDir, hydrate: options.hydrate, _seen: seen, _msgIndex: msgIndex },
|
|
402
|
+
getMessage(resolvers, msgIndex)
|
|
374
403
|
)
|
|
375
404
|
);
|
|
376
405
|
break;
|
|
@@ -381,11 +410,11 @@ var toDSL = (catalogDir, resolvers) => async (resource, options) => {
|
|
|
381
410
|
parts.push(
|
|
382
411
|
await domainToDSL(
|
|
383
412
|
res,
|
|
384
|
-
{ catalogDir, hydrate: options.hydrate, _seen: seen },
|
|
413
|
+
{ catalogDir, hydrate: options.hydrate, _seen: seen, _msgIndex: msgIndex },
|
|
385
414
|
{
|
|
386
415
|
getService: resolvers.getService,
|
|
387
416
|
getDomain: resolvers.getDomain,
|
|
388
|
-
getMessage: getMessage(resolvers,
|
|
417
|
+
getMessage: getMessage(resolvers, msgIndex),
|
|
389
418
|
getChannel: resolvers.getChannel,
|
|
390
419
|
getTeam: resolvers.getTeam,
|
|
391
420
|
getUser: resolvers.getUser
|
|
@@ -406,42 +435,150 @@ import { join as join3 } from "path";
|
|
|
406
435
|
import { globSync as globSync2 } from "glob";
|
|
407
436
|
import fsSync from "fs";
|
|
408
437
|
import { copy } from "fs-extra";
|
|
409
|
-
import { join, dirname, normalize, resolve, relative } from "path";
|
|
438
|
+
import { join, dirname, normalize, sep as pathSeparator, resolve, relative } from "path";
|
|
410
439
|
import matter from "gray-matter";
|
|
411
440
|
import { satisfies, validRange } from "semver";
|
|
441
|
+
var _fileIndexCache = null;
|
|
442
|
+
var _fileIndexCatalogDir = null;
|
|
443
|
+
var _matterCache = null;
|
|
444
|
+
var _filePathToIdCache = null;
|
|
445
|
+
var _fileIndexMtimeMs = 0;
|
|
446
|
+
function toCanonicalPath(inputPath) {
|
|
447
|
+
return normalize(resolve(inputPath));
|
|
448
|
+
}
|
|
449
|
+
function buildFileCache(catalogDir) {
|
|
450
|
+
const canonicalCatalogDir = toCanonicalPath(catalogDir);
|
|
451
|
+
const files = globSync2("**/index.{md,mdx}", {
|
|
452
|
+
cwd: canonicalCatalogDir,
|
|
453
|
+
ignore: ["node_modules/**"],
|
|
454
|
+
absolute: true,
|
|
455
|
+
nodir: true
|
|
456
|
+
}).map(normalize);
|
|
457
|
+
const index = /* @__PURE__ */ new Map();
|
|
458
|
+
const matterResults = /* @__PURE__ */ new Map();
|
|
459
|
+
const pathToId = /* @__PURE__ */ new Map();
|
|
460
|
+
for (const file of files) {
|
|
461
|
+
const content = fsSync.readFileSync(file, "utf-8");
|
|
462
|
+
const parsed = matter(content);
|
|
463
|
+
matterResults.set(file, parsed);
|
|
464
|
+
const id = parsed.data.id;
|
|
465
|
+
if (!id) continue;
|
|
466
|
+
const resourceId = String(id);
|
|
467
|
+
const version = parsed.data.version || "";
|
|
468
|
+
const isVersioned = file.includes("versioned");
|
|
469
|
+
const entry = { path: file, id: resourceId, version: String(version), isVersioned };
|
|
470
|
+
pathToId.set(file, resourceId);
|
|
471
|
+
const existing = index.get(resourceId);
|
|
472
|
+
if (existing) {
|
|
473
|
+
existing.push(entry);
|
|
474
|
+
} else {
|
|
475
|
+
index.set(resourceId, [entry]);
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
_fileIndexCache = index;
|
|
479
|
+
_fileIndexCatalogDir = canonicalCatalogDir;
|
|
480
|
+
_matterCache = matterResults;
|
|
481
|
+
_filePathToIdCache = pathToId;
|
|
482
|
+
try {
|
|
483
|
+
_fileIndexMtimeMs = fsSync.statSync(canonicalCatalogDir).mtimeMs;
|
|
484
|
+
} catch {
|
|
485
|
+
_fileIndexMtimeMs = 0;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
function ensureFileCache(catalogDir) {
|
|
489
|
+
const canonicalCatalogDir = toCanonicalPath(catalogDir);
|
|
490
|
+
if (!_fileIndexCache || _fileIndexCatalogDir !== canonicalCatalogDir) {
|
|
491
|
+
buildFileCache(catalogDir);
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
try {
|
|
495
|
+
const currentMtime = fsSync.statSync(canonicalCatalogDir).mtimeMs;
|
|
496
|
+
if (currentMtime !== _fileIndexMtimeMs) {
|
|
497
|
+
buildFileCache(catalogDir);
|
|
498
|
+
}
|
|
499
|
+
} catch {
|
|
500
|
+
buildFileCache(catalogDir);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
function invalidateFileCache() {
|
|
504
|
+
_fileIndexCache = null;
|
|
505
|
+
_fileIndexCatalogDir = null;
|
|
506
|
+
_matterCache = null;
|
|
507
|
+
_filePathToIdCache = null;
|
|
508
|
+
}
|
|
509
|
+
function upsertFileCacheEntry(catalogDir, filePath, rawContent) {
|
|
510
|
+
const canonicalCatalogDir = toCanonicalPath(catalogDir);
|
|
511
|
+
if (!_fileIndexCache || !_matterCache || !_filePathToIdCache || _fileIndexCatalogDir !== canonicalCatalogDir) {
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
514
|
+
const normalizedPath = toCanonicalPath(filePath);
|
|
515
|
+
const parsed = matter(rawContent);
|
|
516
|
+
const previousId = _filePathToIdCache.get(normalizedPath);
|
|
517
|
+
if (previousId) {
|
|
518
|
+
const previousEntries = _fileIndexCache.get(previousId) || [];
|
|
519
|
+
const nextEntries = previousEntries.filter((entry2) => entry2.path !== normalizedPath);
|
|
520
|
+
if (nextEntries.length === 0) {
|
|
521
|
+
_fileIndexCache.delete(previousId);
|
|
522
|
+
} else {
|
|
523
|
+
_fileIndexCache.set(previousId, nextEntries);
|
|
524
|
+
}
|
|
525
|
+
_filePathToIdCache.delete(normalizedPath);
|
|
526
|
+
}
|
|
527
|
+
_matterCache.set(normalizedPath, parsed);
|
|
528
|
+
const id = parsed.data.id;
|
|
529
|
+
if (!id) {
|
|
530
|
+
_filePathToIdCache.delete(normalizedPath);
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const resourceId = String(id);
|
|
534
|
+
const entry = {
|
|
535
|
+
path: normalizedPath,
|
|
536
|
+
id: resourceId,
|
|
537
|
+
version: String(parsed.data.version || ""),
|
|
538
|
+
isVersioned: normalizedPath.includes(`${pathSeparator}versioned${pathSeparator}`)
|
|
539
|
+
};
|
|
540
|
+
const entries = _fileIndexCache.get(resourceId) || [];
|
|
541
|
+
entries.push(entry);
|
|
542
|
+
_fileIndexCache.set(resourceId, entries);
|
|
543
|
+
_filePathToIdCache.set(normalizedPath, resourceId);
|
|
544
|
+
try {
|
|
545
|
+
_fileIndexMtimeMs = fsSync.statSync(canonicalCatalogDir).mtimeMs;
|
|
546
|
+
} catch {
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
function cachedMatterRead(filePath) {
|
|
550
|
+
if (_matterCache) {
|
|
551
|
+
const cached = _matterCache.get(filePath);
|
|
552
|
+
if (cached) return cached;
|
|
553
|
+
}
|
|
554
|
+
return matter.read(filePath);
|
|
555
|
+
}
|
|
412
556
|
var versionExists = async (catalogDir, id, version) => {
|
|
413
|
-
|
|
414
|
-
const
|
|
415
|
-
|
|
557
|
+
ensureFileCache(catalogDir);
|
|
558
|
+
const entries = _fileIndexCache.get(id);
|
|
559
|
+
if (!entries) return false;
|
|
560
|
+
return entries.some((e) => e.version === version);
|
|
416
561
|
};
|
|
417
562
|
var findFileById = async (catalogDir, id, version) => {
|
|
418
|
-
|
|
419
|
-
const
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
});
|
|
428
|
-
if (version === "latest") {
|
|
429
|
-
return latestVersion;
|
|
430
|
-
}
|
|
431
|
-
const exactMatch = parsedFiles.find((c) => c.version === version);
|
|
432
|
-
if (exactMatch) {
|
|
433
|
-
return exactMatch.path;
|
|
434
|
-
}
|
|
563
|
+
ensureFileCache(catalogDir);
|
|
564
|
+
const entries = _fileIndexCache.get(id);
|
|
565
|
+
if (!entries || entries.length === 0) return void 0;
|
|
566
|
+
const latestEntry = entries.find((e) => !e.isVersioned);
|
|
567
|
+
if (!version || version === "latest") {
|
|
568
|
+
return latestEntry?.path;
|
|
569
|
+
}
|
|
570
|
+
const exactMatch = entries.find((e) => e.version === version);
|
|
571
|
+
if (exactMatch) return exactMatch.path;
|
|
435
572
|
const semverRange = validRange(version);
|
|
436
573
|
if (semverRange) {
|
|
437
|
-
const match =
|
|
574
|
+
const match = entries.find((e) => {
|
|
438
575
|
try {
|
|
439
|
-
return satisfies(
|
|
440
|
-
} catch
|
|
576
|
+
return satisfies(e.version, semverRange);
|
|
577
|
+
} catch {
|
|
441
578
|
return false;
|
|
442
579
|
}
|
|
443
580
|
});
|
|
444
|
-
return match
|
|
581
|
+
return match?.path;
|
|
445
582
|
}
|
|
446
583
|
return void 0;
|
|
447
584
|
};
|
|
@@ -557,6 +694,7 @@ var versionResource = async (catalogDir, id) => {
|
|
|
557
694
|
})
|
|
558
695
|
);
|
|
559
696
|
});
|
|
697
|
+
invalidateFileCache();
|
|
560
698
|
};
|
|
561
699
|
var writeResource = async (catalogDir, resource, options = {
|
|
562
700
|
path: "",
|
|
@@ -596,6 +734,7 @@ var writeResource = async (catalogDir, resource, options = {
|
|
|
596
734
|
}
|
|
597
735
|
const document = matter2.stringify(markdown.trim(), frontmatter);
|
|
598
736
|
fsSync2.writeFileSync(lockPath, document);
|
|
737
|
+
upsertFileCacheEntry(catalogDir, lockPath, document);
|
|
599
738
|
} finally {
|
|
600
739
|
await unlock(lockPath).catch(() => {
|
|
601
740
|
});
|
|
@@ -605,7 +744,7 @@ var getResource = async (catalogDir, id, version, options, filePath) => {
|
|
|
605
744
|
const attachSchema = options?.attachSchema || false;
|
|
606
745
|
const file = filePath || (id ? await findFileById(catalogDir, id, version) : void 0);
|
|
607
746
|
if (!file || !fsSync2.existsSync(file)) return;
|
|
608
|
-
const { data, content } =
|
|
747
|
+
const { data, content } = cachedMatterRead(file);
|
|
609
748
|
if (attachSchema && data?.schemaPath) {
|
|
610
749
|
const resourceDirectory = dirname2(file);
|
|
611
750
|
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
@@ -656,7 +795,7 @@ var getResources = async (catalogDir, {
|
|
|
656
795
|
const files = await getFiles(filePattern, [ignoreList, ...ignore]);
|
|
657
796
|
if (files.length === 0) return;
|
|
658
797
|
return files.map((file) => {
|
|
659
|
-
const { data, content } =
|
|
798
|
+
const { data, content } = cachedMatterRead(file);
|
|
660
799
|
if (attachSchema && data?.schemaPath) {
|
|
661
800
|
const resourceDirectory = dirname2(file);
|
|
662
801
|
const pathToSchema = join2(resourceDirectory, data.schemaPath);
|
|
@@ -697,6 +836,7 @@ var rmResourceById = async (catalogDir, id, version, options) => {
|
|
|
697
836
|
})
|
|
698
837
|
);
|
|
699
838
|
}
|
|
839
|
+
invalidateFileCache();
|
|
700
840
|
};
|
|
701
841
|
var waitForFileRemoval = async (path6, maxRetries = 50, delay = 10) => {
|
|
702
842
|
for (let i = 0; i < maxRetries; i++) {
|
|
@@ -762,6 +902,7 @@ var writeEventToService = (directory) => async (event, service, options = { path
|
|
|
762
902
|
};
|
|
763
903
|
var rmEvent = (directory) => async (path6) => {
|
|
764
904
|
await fs2.rm(join3(directory, path6), { recursive: true });
|
|
905
|
+
invalidateFileCache();
|
|
765
906
|
};
|
|
766
907
|
var rmEventById = (directory) => async (id, version, persistFiles) => {
|
|
767
908
|
await rmResourceById(directory, id, version, { type: "event", persistFiles });
|
|
@@ -798,6 +939,7 @@ var writeCommandToService = (directory) => async (command, service, options = {
|
|
|
798
939
|
};
|
|
799
940
|
var rmCommand = (directory) => async (path6) => {
|
|
800
941
|
await fs3.rm(join4(directory, path6), { recursive: true });
|
|
942
|
+
invalidateFileCache();
|
|
801
943
|
};
|
|
802
944
|
var rmCommandById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "command", persistFiles });
|
|
803
945
|
var versionCommand = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -832,6 +974,7 @@ var writeQueryToService = (directory) => async (query, service, options = { path
|
|
|
832
974
|
};
|
|
833
975
|
var rmQuery = (directory) => async (path6) => {
|
|
834
976
|
await fs4.rm(join5(directory, path6), { recursive: true });
|
|
977
|
+
invalidateFileCache();
|
|
835
978
|
};
|
|
836
979
|
var rmQueryById = (directory) => async (id, version, persistFiles) => {
|
|
837
980
|
await rmResourceById(directory, id, version, { type: "query", persistFiles });
|
|
@@ -897,6 +1040,7 @@ var writeServiceToDomain = (directory) => async (service, domain, options = { pa
|
|
|
897
1040
|
var versionService = (directory) => async (id) => versionResource(directory, id);
|
|
898
1041
|
var rmService = (directory) => async (path6) => {
|
|
899
1042
|
await fs5.rm(join6(directory, path6), { recursive: true });
|
|
1043
|
+
invalidateFileCache();
|
|
900
1044
|
};
|
|
901
1045
|
var rmServiceById = (directory) => async (id, version, persistFiles) => {
|
|
902
1046
|
await rmResourceById(directory, id, version, { type: "service", persistFiles });
|
|
@@ -1073,6 +1217,7 @@ var writeDomain = (directory) => async (domain, options = {
|
|
|
1073
1217
|
var versionDomain = (directory) => async (id) => versionResource(directory, id);
|
|
1074
1218
|
var rmDomain = (directory) => async (path6) => {
|
|
1075
1219
|
await fs6.rm(join7(directory, path6), { recursive: true });
|
|
1220
|
+
invalidateFileCache();
|
|
1076
1221
|
};
|
|
1077
1222
|
var rmDomainById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "domain", persistFiles });
|
|
1078
1223
|
var addFileToDomain = (directory) => async (id, file, version) => addFileToResource(directory, id, file, version);
|
|
@@ -1204,6 +1349,7 @@ var getChannels = (directory) => async (options) => getResources(directory, { ty
|
|
|
1204
1349
|
var writeChannel = (directory) => async (channel, options = { path: "" }) => writeResource(directory, { ...channel }, { ...options, type: "channel" });
|
|
1205
1350
|
var rmChannel = (directory) => async (path6) => {
|
|
1206
1351
|
await fs7.rm(join8(directory, path6), { recursive: true });
|
|
1352
|
+
invalidateFileCache();
|
|
1207
1353
|
};
|
|
1208
1354
|
var rmChannelById = (directory) => async (id, version, persistFiles) => rmResourceById(directory, id, version, { type: "channel", persistFiles });
|
|
1209
1355
|
var versionChannel = (directory) => async (id) => versionResource(directory, id);
|
|
@@ -1376,10 +1522,12 @@ var writeCustomDoc = (directory) => async (customDoc, options = { path: "" }) =>
|
|
|
1376
1522
|
fsSync4.mkdirSync(path3.dirname(fullPath), { recursive: true });
|
|
1377
1523
|
const document = matter5.stringify(customDoc.markdown.trim(), rest);
|
|
1378
1524
|
fsSync4.writeFileSync(fullPath, document);
|
|
1525
|
+
invalidateFileCache();
|
|
1379
1526
|
};
|
|
1380
1527
|
var rmCustomDoc = (directory) => async (filePath) => {
|
|
1381
1528
|
const withExtension = filePath.endsWith(".mdx") ? filePath : `${filePath}.mdx`;
|
|
1382
1529
|
await fs8.rm(join10(directory, withExtension), { recursive: true });
|
|
1530
|
+
invalidateFileCache();
|
|
1383
1531
|
};
|
|
1384
1532
|
|
|
1385
1533
|
// src/teams.ts
|
|
@@ -1431,9 +1579,11 @@ var writeUser = (catalogDir) => async (user, options = {}) => {
|
|
|
1431
1579
|
const document = matter6.stringify(markdown, frontmatter);
|
|
1432
1580
|
fsSync5.mkdirSync(join11(catalogDir, ""), { recursive: true });
|
|
1433
1581
|
fsSync5.writeFileSync(join11(catalogDir, "", `${resource.id}.mdx`), document);
|
|
1582
|
+
invalidateFileCache();
|
|
1434
1583
|
};
|
|
1435
1584
|
var rmUserById = (catalogDir) => async (id) => {
|
|
1436
1585
|
fsSync5.rmSync(join11(catalogDir, `${id}.mdx`), { recursive: true });
|
|
1586
|
+
invalidateFileCache();
|
|
1437
1587
|
};
|
|
1438
1588
|
|
|
1439
1589
|
// src/teams.ts
|
|
@@ -1473,9 +1623,11 @@ var writeTeam = (catalogDir) => async (team, options = {}) => {
|
|
|
1473
1623
|
const document = matter7.stringify(markdown, frontmatter);
|
|
1474
1624
|
fsSync6.mkdirSync(join12(catalogDir, ""), { recursive: true });
|
|
1475
1625
|
fsSync6.writeFileSync(join12(catalogDir, "", `${resource.id}.mdx`), document);
|
|
1626
|
+
invalidateFileCache();
|
|
1476
1627
|
};
|
|
1477
1628
|
var rmTeamById = (catalogDir) => async (id) => {
|
|
1478
1629
|
await fs9.rm(join12(catalogDir, `${id}.mdx`), { recursive: true });
|
|
1630
|
+
invalidateFileCache();
|
|
1479
1631
|
};
|
|
1480
1632
|
var getOwnersForResource = (catalogDir) => async (id, version) => {
|
|
1481
1633
|
const resource = await getResource(catalogDir, id, version);
|
|
@@ -1605,6 +1757,7 @@ var writeEntity = (directory) => async (entity, options = {
|
|
|
1605
1757
|
}) => writeResource(directory, { ...entity }, { ...options, type: "entity" });
|
|
1606
1758
|
var rmEntity = (directory) => async (path6) => {
|
|
1607
1759
|
await fs11.rm(join14(directory, path6), { recursive: true });
|
|
1760
|
+
invalidateFileCache();
|
|
1608
1761
|
};
|
|
1609
1762
|
var rmEntityById = (directory) => async (id, version, persistFiles) => {
|
|
1610
1763
|
await rmResourceById(directory, id, version, { type: "entity", persistFiles });
|
|
@@ -1628,6 +1781,7 @@ var writeContainer = (directory) => async (data, options = {
|
|
|
1628
1781
|
var versionContainer = (directory) => async (id) => versionResource(directory, id);
|
|
1629
1782
|
var rmContainer = (directory) => async (path6) => {
|
|
1630
1783
|
await fs12.rm(join15(directory, path6), { recursive: true });
|
|
1784
|
+
invalidateFileCache();
|
|
1631
1785
|
};
|
|
1632
1786
|
var rmContainerById = (directory) => async (id, version, persistFiles) => {
|
|
1633
1787
|
await rmResourceById(directory, id, version, { type: "container", persistFiles });
|
|
@@ -1675,6 +1829,7 @@ var writeDataProductToDomain = (directory) => async (dataProduct, domain, option
|
|
|
1675
1829
|
};
|
|
1676
1830
|
var rmDataProduct = (directory) => async (path6) => {
|
|
1677
1831
|
await fs13.rm(join16(directory, path6), { recursive: true });
|
|
1832
|
+
invalidateFileCache();
|
|
1678
1833
|
};
|
|
1679
1834
|
var rmDataProductById = (directory) => async (id, version, persistFiles) => {
|
|
1680
1835
|
await rmResourceById(directory, id, version, { type: "data-product", persistFiles });
|
|
@@ -1698,6 +1853,7 @@ var writeDiagram = (directory) => async (diagram, options = {
|
|
|
1698
1853
|
}) => writeResource(directory, { ...diagram }, { ...options, type: "diagram" });
|
|
1699
1854
|
var rmDiagram = (directory) => async (path6) => {
|
|
1700
1855
|
await fs14.rm(join17(directory, path6), { recursive: true });
|
|
1856
|
+
invalidateFileCache();
|
|
1701
1857
|
};
|
|
1702
1858
|
var rmDiagramById = (directory) => async (id, version, persistFiles) => {
|
|
1703
1859
|
await rmResourceById(directory, id, version, { type: "diagram", persistFiles });
|