@eventvisor/core 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.16.0](https://github.com/eventvisor/eventvisor/compare/v0.15.0...v0.16.0) (2025-11-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * rename handler assignment functions in custom generated code ([#35](https://github.com/eventvisor/eventvisor/issues/35)) ([92950a7](https://github.com/eventvisor/eventvisor/commit/92950a7a8efdf09ab04b49ece631fa5b6eb3753f))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.15.0](https://github.com/eventvisor/eventvisor/compare/v0.14.0...v0.15.0) (2025-11-07)
18
+
19
+
20
+ ### Features
21
+
22
+ * generate-code command ([#34](https://github.com/eventvisor/eventvisor/issues/34)) ([e776094](https://github.com/eventvisor/eventvisor/commit/e7760940da5f7913119e5e8c76cea2058e957970))
23
+
24
+
25
+
26
+
27
+
6
28
  # [0.14.0](https://github.com/eventvisor/eventvisor/compare/v0.13.0...v0.14.0) (2025-11-01)
7
29
 
8
30
  **Note:** Version bump only for package @eventvisor/core
@@ -7,6 +7,7 @@ const builder_1 = require("../builder");
7
7
  const tester_1 = require("../tester");
8
8
  const init_1 = require("../init");
9
9
  const catalog_1 = require("../catalog");
10
+ const generate_code_1 = require("../generate-code");
10
11
  exports.commonPlugins = [];
11
12
  exports.nonProjectPlugins = [init_1.initPlugin];
12
13
  exports.projectBasedPlugins = [
@@ -15,5 +16,6 @@ exports.projectBasedPlugins = [
15
16
  builder_1.buildPlugin,
16
17
  tester_1.testPlugin,
17
18
  catalog_1.catalogPlugin,
19
+ generate_code_1.generateCodePlugin,
18
20
  ];
19
21
  //# sourceMappingURL=plugins.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/cli/plugins.ts"],"names":[],"mappings":";;;AAEA,sCAAyC;AACzC,sCAAuC;AACvC,wCAAyC;AACzC,sCAAuC;AACvC,kCAAqC;AACrC,wCAA2C;AAE9B,QAAA,aAAa,GAAa,EAAE,CAAC;AAE7B,QAAA,iBAAiB,GAAa,CAAC,iBAAU,CAAC,CAAC;AAE3C,QAAA,mBAAmB,GAAa;IAC3C,qBAAY;IACZ,mBAAU;IACV,qBAAW;IACX,mBAAU;IACV,uBAAa;CACd,CAAC"}
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/cli/plugins.ts"],"names":[],"mappings":";;;AAEA,sCAAyC;AACzC,sCAAuC;AACvC,wCAAyC;AACzC,sCAAuC;AACvC,kCAAqC;AACrC,wCAA2C;AAC3C,oDAAsD;AAEzC,QAAA,aAAa,GAAa,EAAE,CAAC;AAE7B,QAAA,iBAAiB,GAAa,CAAC,iBAAU,CAAC,CAAC;AAE3C,QAAA,mBAAmB,GAAa;IAC3C,qBAAY;IACZ,mBAAU;IACV,qBAAW;IACX,mBAAU;IACV,uBAAa;IACb,kCAAkB;CACnB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { Dependencies } from "../dependencies";
2
+ import { Plugin } from "../cli";
3
+ export declare const ALLOWED_LANGUAGES_FOR_CODE_GENERATION: string[];
4
+ export interface GenerateCodeCLIOptions {
5
+ language: string;
6
+ outDir: string;
7
+ }
8
+ export declare function generateCodeForProject(deps: Dependencies, cliOptions: GenerateCodeCLIOptions): Promise<void>;
9
+ export declare const generateCodePlugin: Plugin;
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.generateCodePlugin = exports.ALLOWED_LANGUAGES_FOR_CODE_GENERATION = void 0;
37
+ exports.generateCodeForProject = generateCodeForProject;
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const typescript_1 = require("./typescript");
41
+ exports.ALLOWED_LANGUAGES_FOR_CODE_GENERATION = ["typescript"];
42
+ async function generateCodeForProject(deps, cliOptions) {
43
+ const { rootDirectoryPath } = deps;
44
+ if (!cliOptions.language) {
45
+ throw new Error("Option `--language` is required");
46
+ }
47
+ if (!cliOptions.outDir) {
48
+ throw new Error("Option `--out-dir` is required");
49
+ }
50
+ const absolutePath = path.resolve(rootDirectoryPath, cliOptions.outDir);
51
+ if (!fs.existsSync(absolutePath)) {
52
+ console.log(`Creating output directory: ${absolutePath}`);
53
+ fs.mkdirSync(absolutePath, { recursive: true });
54
+ }
55
+ if (!exports.ALLOWED_LANGUAGES_FOR_CODE_GENERATION.includes(cliOptions.language)) {
56
+ console.log(`Only these languages are supported: ${exports.ALLOWED_LANGUAGES_FOR_CODE_GENERATION.join(", ")}`);
57
+ throw new Error(`Language ${cliOptions.language} is not supported for code generation`);
58
+ }
59
+ if (cliOptions.language === "typescript") {
60
+ return await (0, typescript_1.generateTypeScriptCodeForProject)(deps, absolutePath);
61
+ }
62
+ throw new Error(`Language ${cliOptions.language} is not supported`);
63
+ }
64
+ exports.generateCodePlugin = {
65
+ command: "generate-code",
66
+ handler: async function ({ rootDirectoryPath, projectConfig, datasource, parsed }) {
67
+ try {
68
+ await generateCodeForProject({
69
+ rootDirectoryPath,
70
+ projectConfig,
71
+ datasource,
72
+ options: parsed,
73
+ }, {
74
+ language: parsed.language,
75
+ outDir: parsed.outDir,
76
+ });
77
+ }
78
+ catch (error) {
79
+ console.error(error.message);
80
+ return false;
81
+ }
82
+ },
83
+ examples: [
84
+ {
85
+ command: "generate-code --language typescript --out-dir src/generated",
86
+ description: "Generate TypeScript code for the project",
87
+ },
88
+ ],
89
+ };
90
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generate-code/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,wDAkCC;AAhDD,uCAAyB;AACzB,2CAA6B;AAE7B,6CAAgE;AAInD,QAAA,qCAAqC,GAAG,CAAC,YAAY,CAAC,CAAC;AAO7D,KAAK,UAAU,sBAAsB,CAC1C,IAAkB,EAClB,UAAkC;IAElC,MAAM,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IAEnC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,YAAY,GA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AAC;YAE7B,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IACD,QAAQ,EAAE;QACR;YACE,OAAO,EAAE,6DAA6D;YACtE,WAAW,EAAE,0CAA0C;SACxD;KACF;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { JSONSchema } from "@eventvisor/types";
2
+ export declare function generateInterface(schema: JSONSchema, interfaceName: string): string;
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateInterface = generateInterface;
4
+ function generateInterface(schema, interfaceName) {
5
+ function generateType(schema, indent = 0) {
6
+ const indentStr = " ".repeat(indent);
7
+ // Handle const
8
+ if (schema.const !== undefined) {
9
+ return JSON.stringify(schema.const);
10
+ }
11
+ // Handle enum
12
+ if (schema.enum && schema.enum.length > 0) {
13
+ const enumValues = schema.enum.map((val) => JSON.stringify(val));
14
+ return enumValues.join(" | ");
15
+ }
16
+ // Handle array
17
+ if (schema.type === "array") {
18
+ if (schema.items) {
19
+ if (Array.isArray(schema.items)) {
20
+ // Tuple type
21
+ const tupleTypes = schema.items.map((item) => generateType(item, indent));
22
+ return `[${tupleTypes.join(", ")}]`;
23
+ }
24
+ else {
25
+ // Array type
26
+ const itemType = generateType(schema.items, indent);
27
+ return `${itemType}[]`;
28
+ }
29
+ }
30
+ return "any[]";
31
+ }
32
+ // Handle object
33
+ if (schema.type === "object" || (schema.properties && !schema.type)) {
34
+ if (!schema.properties || Object.keys(schema.properties).length === 0) {
35
+ return "Record<string, any>";
36
+ }
37
+ const required = schema.required || [];
38
+ const properties = Object.entries(schema.properties).map(([key, propSchema]) => {
39
+ const isRequired = required.includes(key);
40
+ const optionalMarker = isRequired ? "" : "?";
41
+ const propType = generateType(propSchema, indent + 1);
42
+ return `${indentStr} ${key}${optionalMarker}: ${propType};`;
43
+ });
44
+ return `{\n${properties.join("\n")}\n${indentStr}}`;
45
+ }
46
+ // Handle primitives
47
+ switch (schema.type) {
48
+ case "string":
49
+ return "string";
50
+ case "number":
51
+ case "integer":
52
+ return "number";
53
+ case "boolean":
54
+ return "boolean";
55
+ case "null":
56
+ return "null";
57
+ default:
58
+ return "any";
59
+ }
60
+ }
61
+ const typeDefinition = generateType(schema);
62
+ // Use 'type' for primitives, arrays, tuples, enums, const, and Record types
63
+ // Use 'interface' for object types with properties
64
+ // Object types have property declarations (contain ': ' or '?: ' followed by type)
65
+ // Const objects are JSON stringified and don't have property declarations
66
+ const trimmed = typeDefinition.trim();
67
+ const isArrayType = trimmed.endsWith("[]");
68
+ const isObjectType = !isArrayType &&
69
+ trimmed.startsWith("{") &&
70
+ !trimmed.startsWith('{"') &&
71
+ (trimmed.includes(":\n") ||
72
+ trimmed.includes("?:\n") ||
73
+ trimmed.includes(": ") ||
74
+ trimmed.includes("?: "));
75
+ const declarationType = isObjectType ? "interface" : "type";
76
+ const separator = isObjectType ? " " : " = ";
77
+ const description = schema.description ? `/** ${schema.description} */\n` : "";
78
+ return `${description}export ${declarationType} ${interfaceName}${separator}${typeDefinition}`;
79
+ }
80
+ //# sourceMappingURL=generateInterface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateInterface.js","sourceRoot":"","sources":["../../../src/generate-code/typescript/generateInterface.ts"],"names":[],"mappings":";;AAEA,8CAsFC;AAtFD,SAAgB,iBAAiB,CAAC,MAAkB,EAAE,aAAqB;IACzE,SAAS,YAAY,CAAC,MAAkB,EAAE,SAAiB,CAAC;QAC1D,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEtC,eAAe;QACf,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;QAED,cAAc;QACd,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC1C,MAAM,UAAU,GAAG,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