@eventcatalog/core 5.0.0-beta.27 → 5.0.0-beta.29
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/analytics/analytics.cjs +1 -1
- package/dist/analytics/analytics.js +2 -2
- package/dist/analytics/log-build.cjs +57 -3
- package/dist/analytics/log-build.d.cts +2 -2
- package/dist/analytics/log-build.d.ts +2 -2
- package/dist/analytics/log-build.js +5 -4
- package/dist/analytics/studio-usage.cjs +90 -0
- package/dist/analytics/studio-usage.d.cts +5 -0
- package/dist/analytics/studio-usage.d.ts +5 -0
- package/dist/analytics/studio-usage.js +10 -0
- package/dist/{chunk-ILPH363P.js → chunk-34VU2X7H.js} +1 -1
- package/dist/{chunk-I6CBMGUM.js → chunk-3RDV4HXA.js} +1 -1
- package/dist/{chunk-P5IFIKG6.js → chunk-4IREUUHE.js} +12 -4
- package/dist/{chunk-AWOO63ME.js → chunk-AD7CL772.js} +11 -4
- package/dist/{chunk-EFBDR7JJ.js → chunk-B4OOUG5I.js} +1 -1
- package/dist/chunk-CA6WCQ2T.js +54 -0
- package/dist/{chunk-QJ7KKN2D.js → chunk-OX6TSVHY.js} +1 -1
- package/dist/{chunk-YGUOLT7F.js → chunk-ZK7Q7XDV.js} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.js +1 -1
- package/dist/eventcatalog.cjs +246 -186
- package/dist/eventcatalog.js +12 -10
- package/dist/federation/federate.js +3 -3
- package/dist/federation/source-provider.js +2 -2
- package/dist/generate.cjs +1 -1
- package/dist/generate.js +3 -3
- package/dist/utils/cli-logger.cjs +1 -1
- package/dist/utils/cli-logger.js +2 -2
- package/dist/utils/license-status.cjs +11 -4
- package/dist/utils/license-status.d.cts +3 -2
- package/dist/utils/license-status.d.ts +3 -2
- package/dist/utils/license-status.js +1 -1
- package/eventcatalog/src/components/MDX/NodeGraph/AstroNodeGraph.tsx +19 -2
- package/eventcatalog/src/components/Settings/AssistantSettingsForm.tsx +53 -48
- package/eventcatalog/src/components/Settings/GeneralSettingsForm.tsx +183 -178
- package/eventcatalog/src/components/Settings/LicenseSettings.tsx +140 -31
- package/eventcatalog/src/components/Settings/LlmAccessSettingsForm.tsx +40 -35
- package/eventcatalog/src/components/Settings/LogoUpload.tsx +1 -1
- package/eventcatalog/src/components/Settings/McpSettingsForm.tsx +9 -8
- package/eventcatalog/src/components/Settings/Row.tsx +7 -4
- package/eventcatalog/src/components/Settings/SettingsShared.tsx +3 -3
- package/eventcatalog/src/components/TrialBadge.astro +20 -9
- package/eventcatalog/src/layouts/SettingsLayout.astro +2 -2
- package/eventcatalog/src/pages/settings/license.astro +9 -1
- package/eventcatalog/src/utils/license.ts +1 -1
- package/eventcatalog/src/utils/trial.ts +13 -0
- package/package.json +3 -3
- package/dist/{chunk-A2RZR3U4.js → chunk-6K7XZAYI.js} +3 -3
|
@@ -169,7 +169,7 @@ var verifyRequiredFieldsAreInCatalogConfigFile = async (projectDirectory) => {
|
|
|
169
169
|
var import_os = __toESM(require("os"), 1);
|
|
170
170
|
|
|
171
171
|
// package.json
|
|
172
|
-
var version = "5.0.0-beta.
|
|
172
|
+
var version = "5.0.0-beta.29";
|
|
173
173
|
|
|
174
174
|
// src/constants.ts
|
|
175
175
|
var VERSION = version;
|
|
@@ -294,6 +294,7 @@ var import_license2 = require("@eventcatalog/license");
|
|
|
294
294
|
|
|
295
295
|
// eventcatalog/src/utils/trial.ts
|
|
296
296
|
var TRIAL_LENGTH_DAYS = 60;
|
|
297
|
+
var FREE_USE_NOTE = "Under $10M revenue and $10M raised, an individual or an open-source project? You qualify for Free Use; get a free key at eventcatalog.cloud.";
|
|
297
298
|
var DAY_IN_MS = 24 * 60 * 60 * 1e3;
|
|
298
299
|
var getTrialStatus = (tsd, now = Date.now()) => {
|
|
299
300
|
if (typeof tsd !== "number" || !Number.isFinite(tsd) || tsd <= 0) return;
|
|
@@ -321,6 +322,56 @@ var getLicenseAnalytics = (license = { state: "none" }, tsd) => ({
|
|
|
321
322
|
trialExpiry: getTrialStatus(tsd)?.endsAt.getTime()
|
|
322
323
|
});
|
|
323
324
|
var COLOURS = { bold: import_picocolors.default.bold, dim: import_picocolors.default.dim, link: (text) => import_picocolors.default.cyan(text) };
|
|
325
|
+
var FREE_USE_LINES = FREE_USE_NOTE.split(/(?<=\?) /);
|
|
326
|
+
|
|
327
|
+
// src/analytics/studio-usage.js
|
|
328
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
329
|
+
var import_node_path5 = __toESM(require("path"), 1);
|
|
330
|
+
var DAY_IN_MS3 = 24 * 60 * 60 * 1e3;
|
|
331
|
+
var DEFAULT_DATABASE_PATH = ".eventcatalog/eventcatalog.db";
|
|
332
|
+
var getStudioMode = (configFile) => {
|
|
333
|
+
const enabled = configFile.studio?.enabled;
|
|
334
|
+
if (enabled === false) return "off";
|
|
335
|
+
return configFile.output === "server" && enabled === true ? "server" : "dev";
|
|
336
|
+
};
|
|
337
|
+
var getStorageType = (configFile) => configFile.storage?.type || "memory";
|
|
338
|
+
var loadSqlite = () => {
|
|
339
|
+
const emitWarning = process.emitWarning;
|
|
340
|
+
process.emitWarning = function(warning, ...args) {
|
|
341
|
+
const type = typeof args[0] === "object" ? args[0]?.type : args[0];
|
|
342
|
+
const message = typeof warning === "string" ? warning : warning?.message;
|
|
343
|
+
if (type === "ExperimentalWarning" && message?.startsWith("SQLite")) return;
|
|
344
|
+
return emitWarning.call(this, warning, ...args);
|
|
345
|
+
};
|
|
346
|
+
try {
|
|
347
|
+
return process.getBuiltinModule?.("node:sqlite");
|
|
348
|
+
} catch {
|
|
349
|
+
return void 0;
|
|
350
|
+
} finally {
|
|
351
|
+
process.emitWarning = emitWarning;
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
var UNKNOWN = "canvases:unknown";
|
|
355
|
+
var serializeStudioUsage = (projectDirectory, configFile, now = Date.now()) => {
|
|
356
|
+
if (getStudioMode(configFile) === "off" || getStorageType(configFile) !== "sqlite") return UNKNOWN;
|
|
357
|
+
const file = import_node_path5.default.resolve(projectDirectory, configFile.storage.path ?? DEFAULT_DATABASE_PATH);
|
|
358
|
+
if (!import_node_fs3.default.existsSync(file)) return "canvases:0,changed7d:0,changed30d:0,deleted:0";
|
|
359
|
+
let database;
|
|
360
|
+
try {
|
|
361
|
+
const sqlite = loadSqlite();
|
|
362
|
+
if (!sqlite?.DatabaseSync) return UNKNOWN;
|
|
363
|
+
database = new sqlite.DatabaseSync(file, { readOnly: true });
|
|
364
|
+
const canvases = database.prepare(
|
|
365
|
+
"SELECT COUNT(*) AS total, SUM(updated_at >= ?) AS changed7d, SUM(updated_at >= ?) AS changed30d FROM studio_canvases"
|
|
366
|
+
).get(now - 7 * DAY_IN_MS3, now - 30 * DAY_IN_MS3);
|
|
367
|
+
const { deleted } = database.prepare("SELECT COUNT(*) AS deleted FROM studio_deleted_canvases").get();
|
|
368
|
+
return `canvases:${canvases.total},changed7d:${canvases.changed7d ?? 0},changed30d:${canvases.changed30d ?? 0},deleted:${deleted}`;
|
|
369
|
+
} catch {
|
|
370
|
+
return UNKNOWN;
|
|
371
|
+
} finally {
|
|
372
|
+
database?.close();
|
|
373
|
+
}
|
|
374
|
+
};
|
|
324
375
|
|
|
325
376
|
// src/analytics/log-build.js
|
|
326
377
|
var isMCPEnabled = (configFile) => configFile.output === "server" && (configFile.mcp?.enabled ?? true);
|
|
@@ -335,7 +386,9 @@ var getFeatures = async (configFile) => {
|
|
|
335
386
|
environments: Array.isArray(configFile.environments) && configFile.environments.length > 0,
|
|
336
387
|
output: configFile.output || "static",
|
|
337
388
|
mcp,
|
|
338
|
-
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false)
|
|
389
|
+
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false),
|
|
390
|
+
studio: getStudioMode(configFile),
|
|
391
|
+
storage: getStorageType(configFile)
|
|
339
392
|
};
|
|
340
393
|
};
|
|
341
394
|
var getDirectoryProvider = (source) => {
|
|
@@ -436,7 +489,8 @@ var main = async (projectDir, { command = "build", license } = {}) => {
|
|
|
436
489
|
generators: generatorNames.toString(),
|
|
437
490
|
features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
|
|
438
491
|
directorySources: serializeDirectorySources(configFile),
|
|
439
|
-
resources: serializeCounts(resourceCounts)
|
|
492
|
+
resources: serializeCounts(resourceCounts),
|
|
493
|
+
studio: serializeStudioUsage(projectDir, configFile)
|
|
440
494
|
},
|
|
441
495
|
configFile
|
|
442
496
|
);
|
|
@@ -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,11 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
log_build_default
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-4IREUUHE.js";
|
|
4
|
+
import "../chunk-AD7CL772.js";
|
|
5
5
|
import "../chunk-ZAZHAVKB.js";
|
|
6
|
-
import "../chunk-
|
|
6
|
+
import "../chunk-CA6WCQ2T.js";
|
|
7
|
+
import "../chunk-B4OOUG5I.js";
|
|
7
8
|
import "../chunk-CPW6G62V.js";
|
|
8
|
-
import "../chunk-
|
|
9
|
+
import "../chunk-ZK7Q7XDV.js";
|
|
9
10
|
import "../chunk-4G7FSRPN.js";
|
|
10
11
|
export {
|
|
11
12
|
log_build_default as default
|
|
@@ -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 };
|
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getLicenseAnalytics
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AD7CL772.js";
|
|
4
4
|
import {
|
|
5
5
|
countResources,
|
|
6
6
|
hashCatalogContent,
|
|
7
7
|
serializeCounts
|
|
8
8
|
} from "./chunk-ZAZHAVKB.js";
|
|
9
|
+
import {
|
|
10
|
+
getStorageType,
|
|
11
|
+
getStudioMode,
|
|
12
|
+
serializeStudioUsage
|
|
13
|
+
} from "./chunk-CA6WCQ2T.js";
|
|
9
14
|
import {
|
|
10
15
|
raiseEvent
|
|
11
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-B4OOUG5I.js";
|
|
12
17
|
import {
|
|
13
18
|
TELEMETRY_REQUEST_TIMEOUT_MS,
|
|
14
19
|
isTelemetryDisabled
|
|
@@ -31,7 +36,9 @@ var getFeatures = async (configFile) => {
|
|
|
31
36
|
environments: Array.isArray(configFile.environments) && configFile.environments.length > 0,
|
|
32
37
|
output: configFile.output || "static",
|
|
33
38
|
mcp,
|
|
34
|
-
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false)
|
|
39
|
+
mcpAuth: mcp && (configFile.mcp?.auth?.enabled ?? false),
|
|
40
|
+
studio: getStudioMode(configFile),
|
|
41
|
+
storage: getStorageType(configFile)
|
|
35
42
|
};
|
|
36
43
|
};
|
|
37
44
|
var getDirectoryProvider = (source) => {
|
|
@@ -132,7 +139,8 @@ var main = async (projectDir, { command = "build", license } = {}) => {
|
|
|
132
139
|
generators: generatorNames.toString(),
|
|
133
140
|
features: Object.keys(features).map((feature) => `${feature}:${features[feature]}`).join(","),
|
|
134
141
|
directorySources: serializeDirectorySources(configFile),
|
|
135
|
-
resources: serializeCounts(resourceCounts)
|
|
142
|
+
resources: serializeCounts(resourceCounts),
|
|
143
|
+
studio: serializeStudioUsage(projectDir, configFile)
|
|
136
144
|
},
|
|
137
145
|
configFile
|
|
138
146
|
);
|
|
@@ -7,6 +7,9 @@ import { isEventCatalogScaleEnabled, isEventCatalogStarterEnabled } from "@event
|
|
|
7
7
|
var TRIAL_LENGTH_DAYS = 60;
|
|
8
8
|
var LICENSE_FAQ_URL = "https://www.eventcatalog.dev/license-faq";
|
|
9
9
|
var LICENSE_RENEW_URL = "https://eventcatalog.cloud";
|
|
10
|
+
var BUY_BUSINESS_URL = "https://www.eventcatalog.dev/buy?source=cli";
|
|
11
|
+
var PRICING_URL = "https://www.eventcatalog.dev/pricing";
|
|
12
|
+
var FREE_USE_NOTE = "Under $10M revenue and $10M raised, an individual or an open-source project? You qualify for Free Use; get a free key at eventcatalog.cloud.";
|
|
10
13
|
var DAY_IN_MS = 24 * 60 * 60 * 1e3;
|
|
11
14
|
var getTrialStatus = (tsd, now = Date.now()) => {
|
|
12
15
|
if (typeof tsd !== "number" || !Number.isFinite(tsd) || tsd <= 0) return;
|
|
@@ -125,15 +128,17 @@ var formatDate = (date) => date.toLocaleDateString(void 0, { dateStyle: "medium"
|
|
|
125
128
|
var formatDays = (days) => `${days} ${days === 1 ? "day" : "days"}`;
|
|
126
129
|
var PLAIN = { bold: (text) => text, dim: (text) => text, link: (text) => text };
|
|
127
130
|
var COLOURS = { bold: pc.bold, dim: pc.dim, link: (text) => pc.cyan(text) };
|
|
128
|
-
var render = ({ headline, rows, links }, colours) => {
|
|
131
|
+
var render = ({ headline, rows, links, note }, colours) => {
|
|
129
132
|
const width = Math.max(0, ...[...rows, ...links].map(([label]) => label.length));
|
|
130
133
|
const row = ([label, value]) => `${colours.dim(label.padEnd(width))} ${value}`;
|
|
131
134
|
return [
|
|
132
135
|
colours.bold(headline),
|
|
133
136
|
...rows.length ? ["", ...rows.map(row)] : [],
|
|
134
|
-
...links.length ? ["", ...links.map(([label, url]) => row([label, colours.link(url)]))] : []
|
|
137
|
+
...links.length ? ["", ...links.map(([label, url]) => row([label, colours.link(url)]))] : [],
|
|
138
|
+
...note?.length ? ["", ...note.map(colours.dim)] : []
|
|
135
139
|
].join("\n");
|
|
136
140
|
};
|
|
141
|
+
var FREE_USE_LINES = FREE_USE_NOTE.split(/(?<=\?) /);
|
|
137
142
|
var message = (content) => ({
|
|
138
143
|
...content,
|
|
139
144
|
text: render(content, PLAIN)
|
|
@@ -180,7 +185,8 @@ var getLicenseStatusMessage = (license, tsd, now = Date.now()) => {
|
|
|
180
185
|
color: trial.ended ? "yellow" : "green",
|
|
181
186
|
headline: trial.ended ? "Your EventCatalog trial has ended" : `You're on the ${TRIAL_LENGTH_DAYS}-day EventCatalog trial`,
|
|
182
187
|
rows: trialRows,
|
|
183
|
-
links: trial.ended ? [["Get a license", LICENSE_RENEW_URL], licensing] : [licensing]
|
|
188
|
+
links: trial.ended ? [["Get a license", LICENSE_RENEW_URL], ["Buy Business", BUY_BUSINESS_URL], licensing] : [["Buy a license", PRICING_URL], licensing],
|
|
189
|
+
note: trial.ended ? FREE_USE_LINES : void 0
|
|
184
190
|
});
|
|
185
191
|
}
|
|
186
192
|
if (license.state === "expired") {
|
|
@@ -194,7 +200,8 @@ var getLicenseStatusMessage = (license, tsd, now = Date.now()) => {
|
|
|
194
200
|
title: "EventCatalog license",
|
|
195
201
|
color: "yellow",
|
|
196
202
|
headline: "Your commercial license has expired",
|
|
197
|
-
|
|
203
|
+
// A catalog has a license or is on the trial: an expired license is renewed, not replaced by the trial
|
|
204
|
+
rows: [...licensedTo, ...expiredOn],
|
|
198
205
|
links: [renew, licensing]
|
|
199
206
|
});
|
|
200
207
|
}
|
|
@@ -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
|
+
};
|
package/dist/constants.cjs
CHANGED