@eventcatalog/core 5.0.0-beta.26 → 5.0.0-beta.28

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.
Files changed (42) hide show
  1. package/dist/analytics/analytics.cjs +1 -1
  2. package/dist/analytics/analytics.js +2 -2
  3. package/dist/analytics/log-build.cjs +89 -44
  4. package/dist/analytics/log-build.d.cts +2 -2
  5. package/dist/analytics/log-build.d.ts +2 -2
  6. package/dist/analytics/log-build.js +5 -4
  7. package/dist/analytics/studio-usage.cjs +90 -0
  8. package/dist/analytics/studio-usage.d.cts +5 -0
  9. package/dist/analytics/studio-usage.d.ts +5 -0
  10. package/dist/analytics/studio-usage.js +10 -0
  11. package/dist/{chunk-RFIXKATC.js → chunk-4G7FSRPN.js} +35 -42
  12. package/dist/chunk-CA6WCQ2T.js +54 -0
  13. package/dist/{chunk-M4TIQ4Z6.js → chunk-EUMQAONX.js} +1 -1
  14. package/dist/{chunk-O2ZA26FX.js → chunk-G46KUC6G.js} +4 -2
  15. package/dist/{chunk-MDWB5HLO.js → chunk-NKNOXQ62.js} +1 -1
  16. package/dist/{chunk-KHACCTW2.js → chunk-OX6TSVHY.js} +2 -2
  17. package/dist/{chunk-36RYTYT5.js → chunk-PD7KTSYN.js} +1 -1
  18. package/dist/{chunk-TMCBFXNE.js → chunk-QWFP2PDM.js} +1 -1
  19. package/dist/{chunk-LBHPRPYB.js → chunk-TDUUHSGF.js} +1 -1
  20. package/dist/{chunk-W4RMG6EP.js → chunk-VAL22T5Y.js} +12 -4
  21. package/dist/constants.cjs +1 -1
  22. package/dist/constants.js +1 -1
  23. package/dist/eventcatalog-config-file-utils.cjs +34 -41
  24. package/dist/eventcatalog-config-file-utils.d.cts +56 -58
  25. package/dist/eventcatalog-config-file-utils.d.ts +56 -58
  26. package/dist/eventcatalog-config-file-utils.js +1 -1
  27. package/dist/eventcatalog.cjs +281 -233
  28. package/dist/eventcatalog.js +15 -13
  29. package/dist/features.cjs +34 -41
  30. package/dist/features.js +2 -2
  31. package/dist/federation/federate.cjs +37 -44
  32. package/dist/federation/federate.js +4 -4
  33. package/dist/federation/source-provider.js +2 -2
  34. package/dist/generate.cjs +37 -42
  35. package/dist/generate.js +4 -4
  36. package/dist/resolve-catalog-dependencies.cjs +34 -41
  37. package/dist/resolve-catalog-dependencies.js +2 -2
  38. package/dist/utils/cli-logger.cjs +1 -1
  39. package/dist/utils/cli-logger.js +2 -2
  40. package/eventcatalog/integrations/config-loader.mjs +56 -58
  41. package/package.json +3 -3
  42. package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(analytics_exports);
36
36
  var import_os = __toESM(require("os"), 1);
37
37
 
38
38
  // package.json
39
- var version = "5.0.0-beta.26";
39
+ var version = "5.0.0-beta.28";
40
40
 
41
41
  // src/constants.ts
42
42
  var VERSION = version;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  raiseEvent
3
- } from "../chunk-TMCBFXNE.js";
3
+ } from "../chunk-QWFP2PDM.js";
4
4
  import "../chunk-CPW6G62V.js";
5
- import "../chunk-M4TIQ4Z6.js";
5
+ import "../chunk-EUMQAONX.js";
6
6
  export {
7
7
  raiseEvent
8
8
  };
@@ -45,65 +45,58 @@ var import_promises = require("fs/promises");
45
45
  var import_node_fs = require("fs");
46
46
  var import_node_path = __toESM(require("path"), 1);
47
47
  var import_node_url = require("url");
48
- var import_node_os = require("os");
48
+ var import_node_module = require("module");
49
49
  async function cleanup(projectDirectory) {
50
50
  const filePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.mjs");
51
51
  if ((0, import_node_fs.existsSync)(filePath)) {
52
52
  await (0, import_promises.rm)(filePath);
53
53
  }
54
54
  }
55
- var findNodeModulesDirectory = (directory) => {
56
- let currentDirectory = directory;
57
- while (true) {
58
- const nodeModulesDirectory = import_node_path.default.join(currentDirectory, "node_modules");
59
- if ((0, import_node_fs.existsSync)(nodeModulesDirectory)) {
60
- return nodeModulesDirectory;
61
- }
62
- const parentDirectory = import_node_path.default.dirname(currentDirectory);
63
- if (parentDirectory === currentDirectory) {
64
- return void 0;
65
- }
66
- currentDirectory = parentDirectory;
67
- }
55
+ var hidesConfigModuleTypeWarning = false;
56
+ var loads = 0;
57
+ var hideConfigModuleTypeWarning = () => {
58
+ if (hidesConfigModuleTypeWarning) return;
59
+ hidesConfigModuleTypeWarning = true;
60
+ const emitWarning = process.emitWarning;
61
+ process.emitWarning = function(warning, ...args) {
62
+ const code = typeof args[0] === "object" ? args[0]?.code : args[1];
63
+ const message = typeof warning === "string" ? warning : warning?.message;
64
+ if (code === "MODULE_TYPELESS_PACKAGE_JSON" && message?.includes("eventcatalog.config.js")) return;
65
+ return emitWarning.call(this, warning, ...args);
66
+ };
68
67
  };
69
- var linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
70
- const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
71
- if (!nodeModulesDirectory) {
72
- return;
73
- }
74
- await (0, import_promises.symlink)(nodeModulesDirectory, import_node_path.default.join(tempDir, "node_modules"), "dir");
68
+ var AS_MODULE_QUERY = "eventcatalog-config-as-module";
69
+ var loadsMarkedConfigsAsModules = false;
70
+ var loadMarkedConfigsAsModules = () => {
71
+ if (loadsMarkedConfigsAsModules) return;
72
+ loadsMarkedConfigsAsModules = true;
73
+ const hook = `export async function load(url, context, nextLoad) {
74
+ return nextLoad(url, url.includes('${AS_MODULE_QUERY}=') ? { ...context, format: 'module' } : context);
75
+ }`;
76
+ (0, import_node_module.register)(`data:text/javascript,${encodeURIComponent(hook)}`);
75
77
  };
76
- var createTemporaryConfigDirectory = async (projectDirectory) => {
77
- const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
78
- if (nodeModulesDirectory) {
79
- return (0, import_promises.mkdtemp)(import_node_path.default.join(nodeModulesDirectory, ".eventcatalog-config-"));
78
+ var isCommonJSPackage = async (projectDirectory) => {
79
+ try {
80
+ const packageJson = JSON.parse(await (0, import_promises.readFile)(import_node_path.default.join(projectDirectory, "package.json"), "utf-8"));
81
+ return packageJson?.type === "commonjs";
82
+ } catch {
83
+ return false;
80
84
  }
81
- const tempDir = await (0, import_promises.mkdtemp)(import_node_path.default.join((0, import_node_os.tmpdir)(), "eventcatalog-config-"));
82
- await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
83
- return tempDir;
84
85
  };
85
86
  var getEventCatalogConfigFile = async (projectDirectory) => {
86
- let tempDir;
87
87
  try {
88
- let configFilePath = import_node_path.default.join(projectDirectory, "eventcatalog.config.js");
89
- const filePath = import_node_path.default.join(projectDirectory, "package.json");
90
- const packageJson = JSON.parse(await (0, import_promises.readFile)(filePath, "utf-8"));
91
- if (packageJson?.type !== "module") {
92
- tempDir = await createTemporaryConfigDirectory(projectDirectory);
93
- configFilePath = import_node_path.default.join(tempDir, "eventcatalog.config.mjs");
94
- await (0, import_promises.copyFile)(import_node_path.default.join(projectDirectory, "eventcatalog.config.js"), configFilePath);
95
- }
96
- const configFileURL = `${(0, import_node_url.pathToFileURL)(configFilePath).href}?t=${Date.now()}`;
88
+ hideConfigModuleTypeWarning();
89
+ const asModule = await isCommonJSPackage(projectDirectory);
90
+ if (asModule) loadMarkedConfigsAsModules();
91
+ const configFileURL = (0, import_node_url.pathToFileURL)(import_node_path.default.join(projectDirectory, "eventcatalog.config.js")).href;
92
+ const query = `${asModule ? AS_MODULE_QUERY : "loaded"}=${Date.now()}-${loads++}`;
97
93
  const config = await import(
98
94
  /* @vite-ignore */
99
- configFileURL
95
+ `${configFileURL}?${query}`
100
96
  );
101
97
  return config.default;
102
98
  } finally {
103
99
  await cleanup(projectDirectory);
104
- if (tempDir) {
105
- await (0, import_promises.rm)(tempDir, { recursive: true, force: true });
106
- }
107
100
  }
108
101
  };
109
102
 
@@ -176,7 +169,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
176
169
  var import_os = __toESM(require("os"), 1);
177
170
 
178
171
  // package.json
179
- var version = "5.0.0-beta.26";
172
+ var version = "5.0.0-beta.28";
180
173
 
181
174
  // src/constants.ts
182
175
  var VERSION = version;
@@ -329,6 +322,55 @@ var getLicenseAnalytics = (license = { state: "none" }, tsd) => ({
329
322
  });
330
323
  var COLOURS = { bold: import_picocolors.default.bold, dim: import_picocolors.default.dim, link: (text) => import_picocolors.default.cyan(text) };
331
324
 
325
+ // src/analytics/studio-usage.js
326
+ var import_node_fs3 = __toESM(require("fs"), 1);
327
+ var import_node_path5 = __toESM(require("path"), 1);
328
+ var DAY_IN_MS3 = 24 * 60 * 60 * 1e3;
329
+ var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
330
+ var getStudioMode = (configFile) => {
331
+ const enabled = configFile.studio?.enabled;
332
+ if (enabled === false) return "off";
333
+ return configFile.output === "server" && enabled === true ? "server" : "dev";
334
+ };
335
+ var getStorageType = (configFile) => configFile.storage?.type || "memory";
336
+ var loadSqlite = () => {
337
+ const emitWarning = process.emitWarning;
338
+ process.emitWarning = function(warning, ...args) {
339
+ const type = typeof args[0] === "object" ? args[0]?.type : args[0];
340
+ const message = typeof warning === "string" ? warning : warning?.message;
341
+ if (type === "ExperimentalWarning" && message?.startsWith("SQLite")) return;
342
+ return emitWarning.call(this, warning, ...args);
343
+ };
344
+ try {
345
+ return process.getBuiltinModule?.("node:sqlite");
346
+ } catch {
347
+ return void 0;
348
+ } finally {
349
+ process.emitWarning = emitWarning;
350
+ }
351
+ };
352
+ var UNKNOWN = "canvases:unknown";
353
+ var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
354
+ if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
355
+ const file = import_node_path5.default.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
356
+ if (!import_node_fs3.default.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
357
+ let database;
358
+ try {
359
+ const sqlite = loadSqlite();
360
+ if (!sqlite?.DatabaseSync) return UNKNOWN;
361
+ database = new sqlite.DatabaseSync(file, { readOnly: true });
362
+ const canvases = database.prepare(
363
+ "SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
364
+ ).get(now - 7 * DAY_IN_MS3, now - 30 * DAY_IN_MS3);
365
+ const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
366
+ return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
367
+ } catch {
368
+ return UNKNOWN;
369
+ } finally {
370
+ database?.close();
371
+ }
372
+ };
373
+
332
374
  // src/analytics/log-build.js
333
375
  var isMCPEnabled = (configFile) => configFile.output === "server" && (configFile.mcp?.enabled ?? true);
334
376
  var getFeatures = async (configFile) => {
@@ -342,7 +384,9 @@ var getFeatures = async (configFile) => {
342
384
  environments: Array.isArray(configFile.environments) && configFile.environments.length > 0,
343
385
  output: configFile.output || "static",
344
386
  mcp,
345
- mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false)
387
+ mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false),
388
+ studio: getStudioMode(configFile),
389
+ storage: getStorageType(configFile)
346
390
  };
347
391
  };
348
392
  var getDirectoryProvider = (source) => {
@@ -443,7 +487,8 @@ var main = async (projectDir, { command = "build", license } = {}) => {
443
487
  generators: generatorNames.toString(),
444
488
  features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
445
489
  directorySources: serializeDirectorySources(configFile),
446
- resources: serializeCounts(resourceCounts)
490
+ resources: serializeCounts(resourceCounts),
491
+ studio: serializeStudioUsage(projectDir, configFile)
447
492
  },
448
493
  configFile
449
494
  );
@@ -3,10 +3,10 @@ import { L as LicenseStatus } from '../license-C1y-56bb.cjs';
3
3
  /**
4
4
  *
5
5
  * @param {string} projectDir
6
- * @param {{ command?: 'build' | 'dev', license?: import('../utils/license-status').LicenseStatus }} [options]
6
+ * @param {{ command?: 'build' | 'dev' | 'start', license?: import('../utils/license-status').LicenseStatus }} [options]
7
7
  */
8
8
  declare function main(projectDir: string, { command, license }?: {
9
- command?: "build" | "dev";
9
+ command?: "build" | "dev" | "start";
10
10
  license?: LicenseStatus;
11
11
  }): Promise<void>;
12
12
 
@@ -3,10 +3,10 @@ import { L as LicenseStatus } from '../license-C1y-56bb.js';
3
3
  /**
4
4
  *
5
5
  * @param {string} projectDir
6
- * @param {{ command?: 'build' | 'dev', license?: import('../utils/license-status').LicenseStatus }} [options]
6
+ * @param {{ command?: 'build' | 'dev' | 'start', license?: import('../utils/license-status').LicenseStatus }} [options]
7
7
  */
8
8
  declare function main(projectDir: string, { command, license }?: {
9
- command?: "build" | "dev";
9
+ command?: "build" | "dev" | "start";
10
10
  license?: LicenseStatus;
11
11
  }): Promise<void>;
12
12
 
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  log_build_default
3
- } from "../chunk-W4RMG6EP.js";
3
+ } from "../chunk-VAL22T5Y.js";
4
4
  import "../chunk-AWOO63ME.js";
5
5
  import "../chunk-ZAZHAVKB.js";
6
- import "../chunk-TMCBFXNE.js";
6
+ import "../chunk-CA6WCQ2T.js";
7
+ import "../chunk-QWFP2PDM.js";
7
8
  import "../chunk-CPW6G62V.js";
8
- import "../chunk-M4TIQ4Z6.js";
9
- import "../chunk-RFIXKATC.js";
9
+ import "../chunk-EUMQAONX.js";
10
+ import "../chunk-4G7FSRPN.js";
10
11
  export {
11
12
  log_build_default as default
12
13
  };
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/analytics/studio-usage.js
31
+ var studio_usage_exports = {};
32
+ __export(studio_usage_exports, {
33
+ getStorageType: () => getStorageType,
34
+ getStudioMode: () => getStudioMode,
35
+ serializeStudioUsage: () => serializeStudioUsage
36
+ });
37
+ module.exports = __toCommonJS(studio_usage_exports);
38
+ var import_node_fs = __toESM(require("fs"), 1);
39
+ var import_node_path = __toESM(require("path"), 1);
40
+ var DAY_IN_MS = 24 * 60 * 60 * 1e3;
41
+ var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
42
+ var getStudioMode = (configFile) => {
43
+ const enabled = configFile.studio?.enabled;
44
+ if (enabled === false) return "off";
45
+ return configFile.output === "server" && enabled === true ? "server" : "dev";
46
+ };
47
+ var getStorageType = (configFile) => configFile.storage?.type || "memory";
48
+ var loadSqlite = () => {
49
+ const emitWarning = process.emitWarning;
50
+ process.emitWarning = function(warning, ...args) {
51
+ const type = typeof args[0] === "object" ? args[0]?.type : args[0];
52
+ const message = typeof warning === "string" ? warning : warning?.message;
53
+ if (type === "ExperimentalWarning" && message?.startsWith("SQLite")) return;
54
+ return emitWarning.call(this, warning, ...args);
55
+ };
56
+ try {
57
+ return process.getBuiltinModule?.("node:sqlite");
58
+ } catch {
59
+ return void 0;
60
+ } finally {
61
+ process.emitWarning = emitWarning;
62
+ }
63
+ };
64
+ var UNKNOWN = "canvases:unknown";
65
+ var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
66
+ if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
67
+ const file = import_node_path.default.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
68
+ if (!import_node_fs.default.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
69
+ let database;
70
+ try {
71
+ const sqlite = loadSqlite();
72
+ if (!sqlite?.DatabaseSync) return UNKNOWN;
73
+ database = new sqlite.DatabaseSync(file, { readOnly: true });
74
+ const canvases = database.prepare(
75
+ "SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
76
+ ).get(now - 7 * DAY_IN_MS, now - 30 * DAY_IN_MS);
77
+ const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
78
+ return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
79
+ } catch {
80
+ return UNKNOWN;
81
+ } finally {
82
+ database?.close();
83
+ }
84
+ };
85
+ // Annotate the CommonJS export names for ESM import in node:
86
+ 0 && (module.exports = {
87
+ getStorageType,
88
+ getStudioMode,
89
+ serializeStudioUsage
90
+ });
@@ -0,0 +1,5 @@
1
+ declare function getStudioMode(configFile: any): "off" | "server" | "dev";
2
+ declare function getStorageType(configFile: any): any;
3
+ declare function serializeStudioUsage(projectDirectory: any, configFile: any, now?: number): string;
4
+
5
+ export { getStorageType, getStudioMode, serializeStudioUsage };
@@ -0,0 +1,5 @@
1
+ declare function getStudioMode(configFile: any): "off" | "server" | "dev";
2
+ declare function getStorageType(configFile: any): any;
3
+ declare function serializeStudioUsage(projectDirectory: any, configFile: any, now?: number): string;
4
+
5
+ export { getStorageType, getStudioMode, serializeStudioUsage };
@@ -0,0 +1,10 @@
1
+ import {
2
+ getStorageType,
3
+ getStudioMode,
4
+ serializeStudioUsage
5
+ } from "../chunk-CA6WCQ2T.js";
6
+ export {
7
+ getStorageType,
8
+ getStudioMode,
9
+ serializeStudioUsage
10
+ };
@@ -5,69 +5,62 @@ import { v4 as uuidV4 } from "uuid";
5
5
  import matter from "gray-matter";
6
6
 
7
7
  // eventcatalog/integrations/config-loader.mjs
8
- import { readFile, rm, copyFile, mkdtemp, symlink } from "fs/promises";
8
+ import { readFile, rm } from "fs/promises";
9
9
  import { existsSync } from "fs";
10
10
  import path from "path";
11
11
  import { pathToFileURL } from "url";
12
- import { tmpdir } from "os";
12
+ import { register } from "module";
13
13
  async function cleanup(projectDirectory) {
14
14
  const filePath = path.join(projectDirectory, "eventcatalog.config.mjs");
15
15
  if (existsSync(filePath)) {
16
16
  await rm(filePath);
17
17
  }
18
18
  }
19
- var findNodeModulesDirectory = (directory) => {
20
- let currentDirectory = directory;
21
- while (true) {
22
- const nodeModulesDirectory = path.join(currentDirectory, "node_modules");
23
- if (existsSync(nodeModulesDirectory)) {
24
- return nodeModulesDirectory;
25
- }
26
- const parentDirectory = path.dirname(currentDirectory);
27
- if (parentDirectory === currentDirectory) {
28
- return void 0;
29
- }
30
- currentDirectory = parentDirectory;
31
- }
19
+ var hidesConfigModuleTypeWarning = false;
20
+ var loads = 0;
21
+ var hideConfigModuleTypeWarning = () => {
22
+ if (hidesConfigModuleTypeWarning) return;
23
+ hidesConfigModuleTypeWarning = true;
24
+ const emitWarning = process.emitWarning;
25
+ process.emitWarning = function(warning, ...args) {
26
+ const code = typeof args[0] === "object" ? args[0]?.code : args[1];
27
+ const message = typeof warning === "string" ? warning : warning?.message;
28
+ if (code === "MODULE_TYPELESS_PACKAGE_JSON" && message?.includes("eventcatalog.config.js")) return;
29
+ return emitWarning.call(this, warning, ...args);
30
+ };
32
31
  };
33
- var linkNodeModulesIntoTempDirectory = async ({ projectDirectory, tempDir }) => {
34
- const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
35
- if (!nodeModulesDirectory) {
36
- return;
37
- }
38
- await symlink(nodeModulesDirectory, path.join(tempDir, "node_modules"), "dir");
32
+ var AS_MODULE_QUERY = "eventcatalog-config-as-module";
33
+ var loadsMarkedConfigsAsModules = false;
34
+ var loadMarkedConfigsAsModules = () => {
35
+ if (loadsMarkedConfigsAsModules) return;
36
+ loadsMarkedConfigsAsModules = true;
37
+ const hook = `export async function load(url, context, nextLoad) {
38
+ return nextLoad(url, url.includes('${AS_MODULE_QUERY}=') ? { ...context, format: 'module' } : context);
39
+ }`;
40
+ register(`data:text/javascript,${encodeURIComponent(hook)}`);
39
41
  };
40
- var createTemporaryConfigDirectory = async (projectDirectory) => {
41
- const nodeModulesDirectory = findNodeModulesDirectory(projectDirectory);
42
- if (nodeModulesDirectory) {
43
- return mkdtemp(path.join(nodeModulesDirectory, ".eventcatalog-config-"));
42
+ var isCommonJSPackage = async (projectDirectory) => {
43
+ try {
44
+ const packageJson = JSON.parse(await readFile(path.join(projectDirectory, "package.json"), "utf-8"));
45
+ return packageJson?.type === "commonjs";
46
+ } catch {
47
+ return false;
44
48
  }
45
- const tempDir = await mkdtemp(path.join(tmpdir(), "eventcatalog-config-"));
46
- await linkNodeModulesIntoTempDirectory({ projectDirectory, tempDir });
47
- return tempDir;
48
49
  };
49
50
  var getEventCatalogConfigFile = async (projectDirectory) => {
50
- let tempDir;
51
51
  try {
52
- let configFilePath = path.join(projectDirectory, "eventcatalog.config.js");
53
- const filePath = path.join(projectDirectory, "package.json");
54
- const packageJson = JSON.parse(await readFile(filePath, "utf-8"));
55
- if (packageJson?.type !== "module") {
56
- tempDir = await createTemporaryConfigDirectory(projectDirectory);
57
- configFilePath = path.join(tempDir, "eventcatalog.config.mjs");
58
- await copyFile(path.join(projectDirectory, "eventcatalog.config.js"), configFilePath);
59
- }
60
- const configFileURL = `${pathToFileURL(configFilePath).href}?t=${Date.now()}`;
52
+ hideConfigModuleTypeWarning();
53
+ const asModule = await isCommonJSPackage(projectDirectory);
54
+ if (asModule) loadMarkedConfigsAsModules();
55
+ const configFileURL = pathToFileURL(path.join(projectDirectory, "eventcatalog.config.js")).href;
56
+ const query = `${asModule ? AS_MODULE_QUERY : "loaded"}=${Date.now()}-${loads++}`;
61
57
  const config = await import(
62
58
  /* @vite-ignore */
63
- configFileURL
59
+ `${configFileURL}?${query}`
64
60
  );
65
61
  return config.default;
66
62
  } finally {
67
63
  await cleanup(projectDirectory);
68
- if (tempDir) {
69
- await rm(tempDir, { recursive: true, force: true });
70
- }
71
64
  }
72
65
  };
73
66
 
@@ -0,0 +1,54 @@
1
+ // src/analytics/studio-usage.js
2
+ import fs from "fs";
3
+ import path from "path";
4
+ var DAY_IN_MS = 24 * 60 * 60 * 1e3;
5
+ var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
6
+ var getStudioMode = (configFile) => {
7
+ const enabled = configFile.studio?.enabled;
8
+ if (enabled === false) return "off";
9
+ return configFile.output === "server" && enabled === true ? "server" : "dev";
10
+ };
11
+ var getStorageType = (configFile) => configFile.storage?.type || "memory";
12
+ var loadSqlite = () => {
13
+ const emitWarning = process.emitWarning;
14
+ process.emitWarning = function(warning, ...args) {
15
+ const type = typeof args[0] === "object" ? args[0]?.type : args[0];
16
+ const message = typeof warning === "string" ? warning : warning?.message;
17
+ if (type === "ExperimentalWarning" && message?.startsWith("SQLite")) return;
18
+ return emitWarning.call(this, warning, ...args);
19
+ };
20
+ try {
21
+ return process.getBuiltinModule?.("node:sqlite");
22
+ } catch {
23
+ return void 0;
24
+ } finally {
25
+ process.emitWarning = emitWarning;
26
+ }
27
+ };
28
+ var UNKNOWN = "canvases:unknown";
29
+ var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
30
+ if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
31
+ const file = path.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
32
+ if (!fs.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
33
+ let database;
34
+ try {
35
+ const sqlite = loadSqlite();
36
+ if (!sqlite?.DatabaseSync) return UNKNOWN;
37
+ database = new sqlite.DatabaseSync(file, { readOnly: true });
38
+ const canvases = database.prepare(
39
+ "SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
40
+ ).get(now - 7 * DAY_IN_MS, now - 30 * DAY_IN_MS);
41
+ const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
42
+ return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
43
+ } catch {
44
+ return UNKNOWN;
45
+ } finally {
46
+ database?.close();
47
+ }
48
+ };
49
+
50
+ export {
51
+ getStudioMode,
52
+ getStorageType,
53
+ serializeStudioUsage
54
+ };
@@ -1,5 +1,5 @@
1
1
  // package.json
2
- var version = "5.0.0-beta.26";
2
+ var version = "5.0.0-beta.28";
3
3
 
4
4
  // src/constants.ts
5
5
  var VERSION = version;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  logger
3
- } from "./chunk-LBHPRPYB.js";
3
+ } from "./chunk-TDUUHSGF.js";
4
4
  import {
5
5
  cleanup,
6
6
  getEventCatalogConfigFile
7
- } from "./chunk-RFIXKATC.js";
7
+ } from "./chunk-4G7FSRPN.js";
8
8
 
9
9
  // src/generate.js
10
10
  import path from "path";
@@ -54,10 +54,12 @@ var generate = async (PROJECT_DIRECTORY) => {
54
54
  for (const { plugin } of errors) {
55
55
  logger.error(` - ${plugin}`, "generator");
56
56
  }
57
+ process.exitCode = 1;
57
58
  }
58
59
  } catch (error) {
59
60
  console.error(error);
60
61
  await cleanup(PROJECT_DIRECTORY);
62
+ process.exitCode = 1;
61
63
  }
62
64
  };
63
65
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getEventCatalogConfigFile
3
- } from "./chunk-RFIXKATC.js";
3
+ } from "./chunk-4G7FSRPN.js";
4
4
 
5
5
  // src/features.ts
6
6
  import { join } from "path";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./chunk-5EPNFDT5.js";
7
7
  import {
8
8
  createFederationSourceProvider
9
- } from "./chunk-A2RZR3U4.js";
9
+ } from "./chunk-6K7XZAYI.js";
10
10
  import {
11
11
  createFederationContentCache
12
12
  } from "./chunk-R7Z5ALYI.js";
@@ -16,7 +16,7 @@ import {
16
16
  } from "./chunk-JJPB6EOZ.js";
17
17
  import {
18
18
  getEventCatalogConfigFile
19
- } from "./chunk-RFIXKATC.js";
19
+ } from "./chunk-4G7FSRPN.js";
20
20
 
21
21
  // src/federation/federate.ts
22
22
  import { createHash } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getEventCatalogConfigFile
3
- } from "./chunk-RFIXKATC.js";
3
+ } from "./chunk-4G7FSRPN.js";
4
4
 
5
5
  // src/resolve-catalog-dependencies.js
6
6
  import path from "path";
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-CPW6G62V.js";
5
5
  import {
6
6
  VERSION
7
- } from "./chunk-M4TIQ4Z6.js";
7
+ } from "./chunk-EUMQAONX.js";
8
8
 
9
9
  // src/analytics/analytics.js
10
10
  import os from "os";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  VERSION
3
- } from "./chunk-M4TIQ4Z6.js";
3
+ } from "./chunk-EUMQAONX.js";
4
4
 
5
5
  // src/utils/cli-logger.ts
6
6
  import pc from "picocolors";