@genesislcap/event-type-codegen 14.489.0-canary.FUI-2574 → 14.494.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/kotlin-parse-utils.d.ts +20 -0
- package/dist/kotlin-parse-utils.d.ts.map +1 -0
- package/dist/kotlin-parse-utils.js +55 -0
- package/dist/kotlin-parse-utils.js.map +1 -0
- package/dist/parse-dao.d.ts.map +1 -1
- package/dist/parse-dao.js +6 -55
- package/dist/parse-dao.js.map +1 -1
- package/dist/parse-kotlin.d.ts.map +1 -1
- package/dist/parse-kotlin.js +5 -41
- package/dist/parse-kotlin.js.map +1 -1
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +33 -6
- package/dist/render.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +4 -2
- package/src/kotlin-parse-utils.ts +65 -0
- package/src/parse-dao.ts +4 -60
- package/src/parse-kotlin.ts +4 -40
- package/src/render.ts +37 -6
- package/test/fixtures/client-out/genesis-event-types.ts +54 -0
- package/test/fixtures/golden/genesis-event-types.ts +54 -0
- package/test/fixtures/mini-server/generated-dao/global/genesis/gen/dao/Trade.kt +7 -1
- package/test/fixtures/mini-server/src/main/kotlin/com/example/Handlers.kt +7 -0
- package/test/fixtures/mini-server/src/main/kotlin/com/example/dto/Samples.kt +20 -0
- package/test/generate.test.ts +28 -1
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,wBAAwB,EAAE,cAAc,EAAa,MAAM,SAAS,CAAC;AA4CnF,MAAM,MAAM,yBAAyB,GAAG;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,wBAAwB,CAAC;IAClC,cAAc,CAAC,EAAE;QAAE,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAsDhC;AAED,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -34,7 +34,9 @@ const collectFiles = (root, patterns, options) => {
|
|
|
34
34
|
files.add((0, node_path_1.join)(root, match));
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
// Stable order so last/first-wins merges (DTOs, DAOs, enums) are reproducible
|
|
38
|
+
// across machines/filesystems — glob/Set iteration order is not.
|
|
39
|
+
return [...files].sort((a, b) => a.localeCompare(b));
|
|
38
40
|
};
|
|
39
41
|
const mergeTypeMaps = (primary, secondary) => {
|
|
40
42
|
const merged = new Map(secondary);
|
|
@@ -65,7 +67,7 @@ function generateEventTypes(options) {
|
|
|
65
67
|
includeBuildDirs: true,
|
|
66
68
|
}),
|
|
67
69
|
];
|
|
68
|
-
const uniqueDaoFiles = [...new Set(daoFiles)];
|
|
70
|
+
const uniqueDaoFiles = [...new Set(daoFiles)].sort((a, b) => a.localeCompare(b));
|
|
69
71
|
const customDtos = (0, parse_kotlin_1.parseDtosFromSources)(dtoFiles);
|
|
70
72
|
const generatedDaos = (0, parse_dao_1.parseGeneratedDaosFromSources)(uniqueDaoFiles);
|
|
71
73
|
const generatedEnums = (0, parse_enums_1.parseGeneratedEnumsFromSources)(uniqueDaoFiles);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AA4DA,gDAwDC;;AApHD,qCAA+C;AAC/C,+CAAoD;AACpD,yCAAmD;AACnD,qCAAkC;AAElC,qCAAmD;AACnD,2CAA4D;AAC5D,+CAA+D;AAC/D,iDAAgF;AAChF,qCAAgD;AAGhD,MAAM,aAAa,GAAG,CAAC,QAAgB,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAE3F,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAE,EAAE;IACjD,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,aAAa,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC;AAC7E,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CACnB,IAAY,EACZ,QAAkB,EAClB,OAAwC,EACxC,EAAE;IACF,MAAM,KAAK,GAAG,IAAI,GAAG,EAAU,CAAC;IAChC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,OAAO,EAAE;YAChC,GAAG,EAAE,IAAI;YACT,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,IAAI,IAAI,KAAK,cAAc;oBAAE,OAAO,IAAI,CAAC;gBACzC,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,gBAAgB,CAAA,IAAI,IAAI,KAAK,OAAO;oBAAE,OAAO,IAAI,CAAC;gBAChE,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC,CAAC;QACH,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;YA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B,EAAC,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;QAE9E,MAAM,IAAA,gBAAK,EAAC,IAAA,mBAAO,EAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,MAAM,IAAA,oBAAS,EAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;QAE9C,iBAAO,CAAC,IAAI,CACV,qBAAqB,UAAU,KAAK,MAAM,CAAC,MAAM,YAAY,UAAU,CAAC,IAAI,UAAU,aAAa,CAAC,IAAI,kBAAkB,CAC3H,CAAC;QAEF,OAAO;YACL,UAAU;YACV,UAAU,EAAE,MAAM,CAAC,MAAM;YACzB,QAAQ,EAAE,IAAI,CAAC,IAAI;YACnB,aAAa,EAAE,QAAQ,CAAC,MAAM;SAC/B,CAAC;IACJ,CAAC;CAAA;AAED,kDAAwB;AACxB,mCAAmD;AAA1C,iHAAA,uBAAuB,OAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KotlinProperty } from './types';
|
|
2
|
+
/** Strip Kotlin line and block comments from source before structural parsing. */
|
|
3
|
+
export declare const stripKotlinComments: (content: string) => string;
|
|
4
|
+
/**
|
|
5
|
+
* Strip annotations including use-site targets (field:/param:/get: prefixes).
|
|
6
|
+
* Nested call args in annotations are not fully balanced (secondary limitation).
|
|
7
|
+
*/
|
|
8
|
+
export declare const stripKotlinAnnotations: (segment: string) => string;
|
|
9
|
+
/** Split a constructor/parameter list on top-level commas (respecting nested brackets). */
|
|
10
|
+
export declare const splitTopLevelArgs: (body: string) => string[];
|
|
11
|
+
export type ParseKotlinPropertyOptions = {
|
|
12
|
+
/** Allow bare ctor params without val/var (sequenced PKs in generated DAOs). */
|
|
13
|
+
allowBareParams?: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Parse a Kotlin constructor / data-class property segment into a wire-facing property.
|
|
17
|
+
* Accepts optional public modifier and use-site-stripped annotations.
|
|
18
|
+
*/
|
|
19
|
+
export declare const parseKotlinProperty: (segment: string, options?: ParseKotlinPropertyOptions) => KotlinProperty | null;
|
|
20
|
+
//# sourceMappingURL=kotlin-parse-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin-parse-utils.d.ts","sourceRoot":"","sources":["../src/kotlin-parse-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,kFAAkF;AAClF,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,MACa,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,SAAS,MAAM,KAAG,MAI9C,CAAC;AAEZ,2FAA2F;AAC3F,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,KAAG,MAAM,EAgBtD,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG;IACvC,gFAAgF;IAChF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,UAAS,0BAA+B,KACvC,cAAc,GAAG,IAiBnB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseKotlinProperty = exports.splitTopLevelArgs = exports.stripKotlinAnnotations = exports.stripKotlinComments = void 0;
|
|
4
|
+
/** Strip Kotlin line and block comments from source before structural parsing. */
|
|
5
|
+
const stripKotlinComments = (content) => content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
6
|
+
exports.stripKotlinComments = stripKotlinComments;
|
|
7
|
+
/**
|
|
8
|
+
* Strip annotations including use-site targets (field:/param:/get: prefixes).
|
|
9
|
+
* Nested call args in annotations are not fully balanced (secondary limitation).
|
|
10
|
+
*/
|
|
11
|
+
const stripKotlinAnnotations = (segment) => segment
|
|
12
|
+
.replace(/@(?:\w+:)?[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
13
|
+
.replace(/\s+/g, ' ')
|
|
14
|
+
.trim();
|
|
15
|
+
exports.stripKotlinAnnotations = stripKotlinAnnotations;
|
|
16
|
+
/** Split a constructor/parameter list on top-level commas (respecting nested brackets). */
|
|
17
|
+
const splitTopLevelArgs = (body) => {
|
|
18
|
+
const parts = [];
|
|
19
|
+
let depth = 0;
|
|
20
|
+
let current = '';
|
|
21
|
+
for (const ch of body) {
|
|
22
|
+
if (ch === '(' || ch === '<' || ch === '[')
|
|
23
|
+
depth += 1;
|
|
24
|
+
if (ch === ')' || ch === '>' || ch === ']')
|
|
25
|
+
depth -= 1;
|
|
26
|
+
if (ch === ',' && depth === 0) {
|
|
27
|
+
parts.push(current.trim());
|
|
28
|
+
current = '';
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
current += ch;
|
|
32
|
+
}
|
|
33
|
+
if (current.trim())
|
|
34
|
+
parts.push(current.trim());
|
|
35
|
+
return parts;
|
|
36
|
+
};
|
|
37
|
+
exports.splitTopLevelArgs = splitTopLevelArgs;
|
|
38
|
+
/**
|
|
39
|
+
* Parse a Kotlin constructor / data-class property segment into a wire-facing property.
|
|
40
|
+
* Accepts optional public modifier and use-site-stripped annotations.
|
|
41
|
+
*/
|
|
42
|
+
const parseKotlinProperty = (segment, options = {}) => {
|
|
43
|
+
const cleaned = (0, exports.stripKotlinAnnotations)(segment);
|
|
44
|
+
const propertyMatch = cleaned.match(/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
45
|
+
const match = propertyMatch !== null && propertyMatch !== void 0 ? propertyMatch : (options.allowBareParams ? cleaned.match(/^(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/) : null);
|
|
46
|
+
if (!match)
|
|
47
|
+
return null;
|
|
48
|
+
const name = match[1];
|
|
49
|
+
let kotlinType = match[2].trim();
|
|
50
|
+
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
51
|
+
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
52
|
+
return { name, kotlinType, optional };
|
|
53
|
+
};
|
|
54
|
+
exports.parseKotlinProperty = parseKotlinProperty;
|
|
55
|
+
//# sourceMappingURL=kotlin-parse-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kotlin-parse-utils.js","sourceRoot":"","sources":["../src/kotlin-parse-utils.ts"],"names":[],"mappings":";;;AAEA,kFAAkF;AAC3E,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC7D,OAAO,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;AADvD,QAAA,mBAAmB,uBACoC;AAEpE;;;GAGG;AACI,MAAM,sBAAsB,GAAG,CAAC,OAAe,EAAU,EAAE,CAChE,OAAO;KACJ,OAAO,CAAC,4DAA4D,EAAE,GAAG,CAAC;KAC1E,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;KACpB,IAAI,EAAE,CAAC;AAJC,QAAA,sBAAsB,0BAIvB;AAEZ,2FAA2F;AACpF,MAAM,iBAAiB,GAAG,CAAC,IAAY,EAAY,EAAE;IAC1D,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,OAAO,GAAG,EAAE,CAAC;IACjB,KAAK,MAAM,EAAE,IAAI,IAAI,EAAE,CAAC;QACtB,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG;YAAE,KAAK,IAAI,CAAC,CAAC;QACvD,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG;YAAE,KAAK,I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EAAE,CAAC;AACxC,CAAC,CAAC;AApBW,QAAA,mBAAmB,uBAoB9B"}
|
package/dist/parse-dao.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-dao.d.ts","sourceRoot":"","sources":["../src/parse-dao.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-dao.d.ts","sourceRoot":"","sources":["../src/parse-dao.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAkB,MAAM,SAAS,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GAAI,UAAU,MAAM,KAAG,OAG3D,CAAC;AAUF;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,SAAS,EAyCvF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,GAAI,SAAS,MAAM,EAAE,UAAU,MAAM,KAAG,SAAS,EAmCxF,CAAC;AAEF,eAAO,MAAM,6BAA6B,GAAI,OAAO,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAmBpF,CAAC"}
|
package/dist/parse-dao.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseGeneratedDaosFromSources = exports.extractGeneratedDaoEntities = exports.extractGeneratedDaoIndices = exports.isGeneratedDaoEntityFile = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
+
const kotlin_parse_utils_1 = require("./kotlin-parse-utils");
|
|
5
6
|
/**
|
|
6
7
|
* Generated Genesis DAO entities use a primary constructor with annotated
|
|
7
8
|
* `public var` parameters (and sometimes bare params for sequenced PKs).
|
|
@@ -12,55 +13,6 @@ const isGeneratedDaoEntityFile = (filePath) => {
|
|
|
12
13
|
return /\/gen\/dao\/[^/]+\.kt$/i.test(normalized);
|
|
13
14
|
};
|
|
14
15
|
exports.isGeneratedDaoEntityFile = isGeneratedDaoEntityFile;
|
|
15
|
-
const stripKotlinAnnotations = (segment) => segment
|
|
16
|
-
.replace(/@[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
17
|
-
.replace(/\s+/g, ' ')
|
|
18
|
-
.trim();
|
|
19
|
-
const splitTopLevelArgs = (body) => {
|
|
20
|
-
const parts = [];
|
|
21
|
-
let depth = 0;
|
|
22
|
-
let current = '';
|
|
23
|
-
for (const ch of body) {
|
|
24
|
-
if (ch === '(' || ch === '<' || ch === '[')
|
|
25
|
-
depth += 1;
|
|
26
|
-
if (ch === ')' || ch === '>' || ch === ']')
|
|
27
|
-
depth -= 1;
|
|
28
|
-
if (ch === ',' && depth === 0) {
|
|
29
|
-
parts.push(current.trim());
|
|
30
|
-
current = '';
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
current += ch;
|
|
34
|
-
}
|
|
35
|
-
if (current.trim())
|
|
36
|
-
parts.push(current.trim());
|
|
37
|
-
return parts;
|
|
38
|
-
};
|
|
39
|
-
const parseDaoConstructorProperty = (segment) => {
|
|
40
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
41
|
-
// Prefer property syntax: (public) var/val name: Type
|
|
42
|
-
const propertyMatch = cleaned.match(/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
43
|
-
// Bare ctor param used for sequenced PKs: tradeId: String? = null
|
|
44
|
-
const bareMatch = propertyMatch !== null && propertyMatch !== void 0 ? propertyMatch : cleaned.match(/^(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
45
|
-
if (!bareMatch)
|
|
46
|
-
return null;
|
|
47
|
-
const name = bareMatch[1];
|
|
48
|
-
let kotlinType = bareMatch[2].trim();
|
|
49
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
50
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
51
|
-
return { name, kotlinType, optional };
|
|
52
|
-
};
|
|
53
|
-
const parseIndexDataClassProperty = (segment) => {
|
|
54
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
55
|
-
const match = cleaned.match(/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
56
|
-
if (!match)
|
|
57
|
-
return null;
|
|
58
|
-
const name = match[1];
|
|
59
|
-
let kotlinType = match[2].trim();
|
|
60
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
61
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
62
|
-
return { name, kotlinType, optional };
|
|
63
|
-
};
|
|
64
16
|
const KOTLIN_FILE_EXTENSION = '.kt';
|
|
65
17
|
const entityNameFromDaoFile = (filePath) => {
|
|
66
18
|
const base = filePath.replace(/\\/g, '/').split('/').pop();
|
|
@@ -98,8 +50,8 @@ const extractGeneratedDaoIndices = (content, filePath) => {
|
|
|
98
50
|
if (closeIndex === -1)
|
|
99
51
|
continue;
|
|
100
52
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
101
|
-
const properties = splitTopLevelArgs(body)
|
|
102
|
-
.map(
|
|
53
|
+
const properties = (0, kotlin_parse_utils_1.splitTopLevelArgs)(body)
|
|
54
|
+
.map((segment) => (0, kotlin_parse_utils_1.parseKotlinProperty)(segment))
|
|
103
55
|
.filter((p) => p != null);
|
|
104
56
|
if (properties.length === 0)
|
|
105
57
|
continue;
|
|
@@ -141,8 +93,8 @@ const extractGeneratedDaoEntities = (content, filePath) => {
|
|
|
141
93
|
if (closeIndex === -1)
|
|
142
94
|
continue;
|
|
143
95
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
144
|
-
const properties = splitTopLevelArgs(body)
|
|
145
|
-
.map(
|
|
96
|
+
const properties = (0, kotlin_parse_utils_1.splitTopLevelArgs)(body)
|
|
97
|
+
.map((segment) => (0, kotlin_parse_utils_1.parseKotlinProperty)(segment, { allowBareParams: true }))
|
|
146
98
|
.filter((p) => p != null);
|
|
147
99
|
if (properties.length > 0) {
|
|
148
100
|
results.push({ name, properties, filePath });
|
|
@@ -156,8 +108,7 @@ const parseGeneratedDaosFromSources = (files) => {
|
|
|
156
108
|
for (const filePath of files) {
|
|
157
109
|
if (!(0, exports.isGeneratedDaoEntityFile)(filePath))
|
|
158
110
|
continue;
|
|
159
|
-
const
|
|
160
|
-
const content = rawContent.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
111
|
+
const content = (0, kotlin_parse_utils_1.stripKotlinComments)((0, node_fs_1.readFileSync)(filePath, 'utf8'));
|
|
161
112
|
for (const entity of (0, exports.extractGeneratedDaoEntities)(content, filePath)) {
|
|
162
113
|
if (!daos.has(entity.name)) {
|
|
163
114
|
daos.set(entity.name, entity);
|
package/dist/parse-dao.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-dao.js","sourceRoot":"","sources":["../src/parse-dao.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;
|
|
1
|
+
{"version":3,"file":"parse-dao.js","sourceRoot":"","sources":["../src/parse-dao.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,6DAAmG;AAGnG;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,CAAC,QAAgB,EAAW,EAAE;IACpE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAChD,OAAO,yBAAyB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACpD,CAAC,CAAC;AAHW,QAAA,wBAAwB,4BAGnC;AAEF,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC,MAAM,qBAAqB,GAAG,CAAC,QAAgB,EAAiB,EAAE;IAChE,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,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AC;YAAE,SAAS;QAClD,MAAM,OAAO,GAAG,IAAA,wCAAmB,EAAC,IAAA,sBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;QACpE,KAAK,MAAM,MAAM,IAAI,IAAA,mCAA2B,EAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YACpE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC3B,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAA,kCAA0B,EAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC;YAClE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC1B,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAnBW,QAAA,6BAA6B,iCAmBxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-kotlin.d.ts","sourceRoot":"","sources":["../src/parse-kotlin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"parse-kotlin.d.ts","sourceRoot":"","sources":["../src/parse-kotlin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAkBzF,QAAA,MAAM,gBAAgB,QAAsE,CAAC;AAE7F,QAAA,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,cAAc,EAAE,CAAA;CAAE,EAkC3F,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,OAAO,MAAM,EAAE,KAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAe3E,CAAC;AAeF,eAAO,MAAM,wBAAwB,GACnC,OAAO,MAAM,EAAE,EACf,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,KAC3B;IAAE,MAAM,EAAE,aAAa,EAAE,CAAC;IAAC,QAAQ,EAAE,eAAe,EAAE,CAAA;CAwDxD,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5B,QAAO,aAAyB,KAC/B,MAoBF,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
|
package/dist/parse-kotlin.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DATA_CLASS_START = exports.extractDataClasses = exports.kotlinTypeToTs = exports.parseHandlersFromSources = exports.parseDtosFromSources = void 0;
|
|
4
4
|
const node_fs_1 = require("node:fs");
|
|
5
|
+
const kotlin_parse_utils_1 = require("./kotlin-parse-utils");
|
|
5
6
|
const naming_1 = require("./naming");
|
|
6
7
|
const parse_enums_1 = require("./parse-enums");
|
|
7
8
|
const PRIMITIVE_TS = {
|
|
@@ -21,41 +22,6 @@ const PRIMITIVE_TS = {
|
|
|
21
22
|
};
|
|
22
23
|
const DATA_CLASS_START = /^\s*(?:data\s+)?class\s+(\w+)\s*(?:\([^)]*\))?\s*(?:\([^)]*\)|\{)/;
|
|
23
24
|
exports.DATA_CLASS_START = DATA_CLASS_START;
|
|
24
|
-
const splitTopLevelArgs = (body) => {
|
|
25
|
-
const parts = [];
|
|
26
|
-
let depth = 0;
|
|
27
|
-
let current = '';
|
|
28
|
-
for (const ch of body) {
|
|
29
|
-
if (ch === '(' || ch === '<' || ch === '[')
|
|
30
|
-
depth += 1;
|
|
31
|
-
if (ch === ')' || ch === '>' || ch === ']')
|
|
32
|
-
depth -= 1;
|
|
33
|
-
if (ch === ',' && depth === 0) {
|
|
34
|
-
parts.push(current.trim());
|
|
35
|
-
current = '';
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
current += ch;
|
|
39
|
-
}
|
|
40
|
-
if (current.trim())
|
|
41
|
-
parts.push(current.trim());
|
|
42
|
-
return parts;
|
|
43
|
-
};
|
|
44
|
-
const stripKotlinAnnotations = (segment) => segment
|
|
45
|
-
.replace(/@[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
46
|
-
.replace(/\s+/g, ' ')
|
|
47
|
-
.trim();
|
|
48
|
-
const parseProperty = (segment) => {
|
|
49
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
50
|
-
const match = cleaned.match(/^(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
51
|
-
if (!match)
|
|
52
|
-
return null;
|
|
53
|
-
const name = match[1];
|
|
54
|
-
let kotlinType = match[2].trim();
|
|
55
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
56
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
57
|
-
return { name, kotlinType, optional };
|
|
58
|
-
};
|
|
59
25
|
const extractDataClasses = (content) => {
|
|
60
26
|
const results = [];
|
|
61
27
|
const classRegex = /(?:^|\n)\s*(?:data\s+)?class\s+(\w+)\s*\(/gm;
|
|
@@ -80,8 +46,8 @@ const extractDataClasses = (content) => {
|
|
|
80
46
|
if (closeIndex === -1)
|
|
81
47
|
continue;
|
|
82
48
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
83
|
-
const properties = splitTopLevelArgs(body)
|
|
84
|
-
.map(
|
|
49
|
+
const properties = (0, kotlin_parse_utils_1.splitTopLevelArgs)(body)
|
|
50
|
+
.map((segment) => (0, kotlin_parse_utils_1.parseKotlinProperty)(segment))
|
|
85
51
|
.filter((p) => p != null);
|
|
86
52
|
if (properties.length > 0) {
|
|
87
53
|
results.push({ name, properties });
|
|
@@ -93,8 +59,7 @@ exports.extractDataClasses = extractDataClasses;
|
|
|
93
59
|
const parseDtosFromSources = (files) => {
|
|
94
60
|
const dtos = new Map();
|
|
95
61
|
for (const filePath of files) {
|
|
96
|
-
const
|
|
97
|
-
const content = rawContent.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
62
|
+
const content = (0, kotlin_parse_utils_1.stripKotlinComments)((0, node_fs_1.readFileSync)(filePath, 'utf8'));
|
|
98
63
|
for (const parsed of extractDataClasses(content)) {
|
|
99
64
|
dtos.set(parsed.name, {
|
|
100
65
|
name: parsed.name,
|
|
@@ -123,8 +88,7 @@ const parseHandlersFromSources = (files, dtos) => {
|
|
|
123
88
|
const unmapped = [];
|
|
124
89
|
const seenEvents = new Set();
|
|
125
90
|
for (const filePath of files) {
|
|
126
|
-
const
|
|
127
|
-
const stripped = content.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
91
|
+
const stripped = (0, kotlin_parse_utils_1.stripKotlinComments)((0, node_fs_1.readFileSync)(filePath, 'utf8'));
|
|
128
92
|
const tryMatch = (regex) => {
|
|
129
93
|
let handlerMatch;
|
|
130
94
|
regex.lastIndex = 0;
|
package/dist/parse-kotlin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-kotlin.js","sourceRoot":"","sources":["../src/parse-kotlin.ts"],"names":[],"mappings":";;;AAAA,qCAAuC;AAEvC,qCAA8D;AAC9D,+CAAkD;AAIlD,MAAM,YAAY,GAA2B;IAC3C,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,QAAQ;IACf,IAAI,EAAE,QAAQ;IACd,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,SAAS;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AK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":"AAKA,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AA6GzE,eAAO,MAAM,oBAAoB,GAC/B,QAAQ,aAAa,EAAE,EACvB,UAAU,eAAe,EAAE,EAC3B,MAAM,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAC5B,QAAO,aAAyB,KAC/B,MA2BF,CAAC"}
|
package/dist/render.js
CHANGED
|
@@ -4,6 +4,33 @@ exports.renderEventTypesFile = void 0;
|
|
|
4
4
|
const naming_1 = require("./naming");
|
|
5
5
|
const parse_enums_1 = require("./parse-enums");
|
|
6
6
|
const parse_kotlin_1 = require("./parse-kotlin");
|
|
7
|
+
const kotlinTypeRoot = (kotlinType) => {
|
|
8
|
+
const listMatch = kotlinType.match(/^(?:List|MutableList|Set|MutableSet)<(.+)>$/);
|
|
9
|
+
if (listMatch) {
|
|
10
|
+
return kotlinTypeRoot(listMatch[1].trim());
|
|
11
|
+
}
|
|
12
|
+
return kotlinType.replace(/\?$/, '').trim();
|
|
13
|
+
};
|
|
14
|
+
/** Handler inputs plus any nested custom DTOs referenced from their properties. */
|
|
15
|
+
const expandUsedDtoNames = (mapped, dtos) => {
|
|
16
|
+
const used = new Set();
|
|
17
|
+
const visit = (dtoName) => {
|
|
18
|
+
if (used.has(dtoName) || !dtos.has(dtoName))
|
|
19
|
+
return;
|
|
20
|
+
used.add(dtoName);
|
|
21
|
+
const dto = dtos.get(dtoName);
|
|
22
|
+
for (const prop of dto.properties) {
|
|
23
|
+
const nested = kotlinTypeRoot(prop.kotlinType);
|
|
24
|
+
if (dtos.has(nested)) {
|
|
25
|
+
visit(nested);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
for (const handler of mapped) {
|
|
30
|
+
visit(handler.inputType);
|
|
31
|
+
}
|
|
32
|
+
return used;
|
|
33
|
+
};
|
|
7
34
|
const renderInterface = (dto, dtos, enums) => {
|
|
8
35
|
const interfaceName = (0, naming_1.handlerInputToDetailsInterfaceName)(dto.name);
|
|
9
36
|
const lines = dto.properties.map((prop) => {
|
|
@@ -48,14 +75,14 @@ const renderEnumExports = (enums, usedEnumNames) => {
|
|
|
48
75
|
}
|
|
49
76
|
return blocks.length > 0 ? `${blocks.join('\n\n')}\n\n` : '';
|
|
50
77
|
};
|
|
51
|
-
const collectUsedEnumNames = (
|
|
78
|
+
const collectUsedEnumNames = (usedDtoNames, dtos, enums) => {
|
|
52
79
|
const used = new Set();
|
|
53
|
-
for (const
|
|
54
|
-
const dto = dtos.get(
|
|
80
|
+
for (const dtoName of usedDtoNames) {
|
|
81
|
+
const dto = dtos.get(dtoName);
|
|
55
82
|
if (!dto)
|
|
56
83
|
continue;
|
|
57
84
|
for (const prop of dto.properties) {
|
|
58
|
-
const ref = (0, parse_enums_1.kotlinEnumTypeRef)(prop.kotlinType, enums);
|
|
85
|
+
const ref = (0, parse_enums_1.kotlinEnumTypeRef)(kotlinTypeRoot(prop.kotlinType), enums);
|
|
59
86
|
if (ref)
|
|
60
87
|
used.add(ref);
|
|
61
88
|
}
|
|
@@ -63,13 +90,13 @@ const collectUsedEnumNames = (mapped, dtos, enums) => {
|
|
|
63
90
|
return used;
|
|
64
91
|
};
|
|
65
92
|
const renderEventTypesFile = (mapped, unmapped, dtos, enums = new Map()) => {
|
|
66
|
-
const usedDtos =
|
|
93
|
+
const usedDtos = expandUsedDtoNames(mapped, dtos);
|
|
67
94
|
const interfaces = [...usedDtos]
|
|
68
95
|
.map((name) => dtos.get(name))
|
|
69
96
|
.filter((dto) => dto != null)
|
|
70
97
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
71
98
|
.map((dto) => renderInterface(dto, dtos, enums));
|
|
72
|
-
const usedEnumNames = collectUsedEnumNames(
|
|
99
|
+
const usedEnumNames = collectUsedEnumNames(usedDtos, dtos, enums);
|
|
73
100
|
const enumExports = renderEnumExports(enums, usedEnumNames);
|
|
74
101
|
const mapEntries = mapped.map((m) => ` ${m.eventName}: ${m.detailsInterface};`).join('\n');
|
|
75
102
|
const eventClasses = renderEventClasses(mapped);
|
package/dist/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../src/render.ts"],"names":[],"mappings":";;;AAAA,qCAIkB;AAClB,+CAAsE;AACtE,iDAAgD;AAGhD,MAAM,eAAe,GAAG,CACtB,GAAc,EACd,IAA4B,EAC5B,KAAoB,EACZ,EAAE;IACV,MAAM,aAAa,GAAG,IAAA,2CAAkC,EAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACxC,MAAM,QAAQ,GAAG,IAAA,kCAAyB,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAA,6BAAc,EAAC,IAAI,CAAC,UAAU,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,OAAO,KAAK,QAAQ,GAAG,QAAQ,KAAK,MAAM,GAAG,CAAC;IAChD,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAoB,aAAa,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;AACvE,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAuB,EAAU,EAAE;IAC7D,IAAI,MAAM,CAAC,MAA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O;;EAEP,qBAAqB,CAAC,QAAQ,CAAC,GAAG,qBAAqB,GAAG,WAAW,GAAG,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;;;EAG/F,UAAU;;;;EAIV,YAAY,CAAC,CAAC,CAAC,KAAK,YAAY,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAC9C,CAAC,CAAC;AAhCW,QAAA,oBAAoB,wBAgC/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/event-type-codegen",
|
|
3
3
|
"description": "Build-time TypeScript codegen from Kotlin event handler DTOs",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.494.0",
|
|
5
5
|
"license": "SEE LICENSE IN license.txt",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"consola": "^3.0.2"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@genesislcap/foundation-testing": "14.
|
|
24
|
+
"@genesislcap/foundation-testing": "14.494.0",
|
|
25
25
|
"@types/node": "^22.10.2",
|
|
26
26
|
"tsx": "^4.7.0",
|
|
27
27
|
"uvu": "0.5.4"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "df845b67dcc681aa3775bdc87b9d91b404791868"
|
|
38
38
|
}
|
package/src/index.ts
CHANGED
|
@@ -36,7 +36,9 @@ const collectFiles = (
|
|
|
36
36
|
files.add(join(root, match));
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
// Stable order so last/first-wins merges (DTOs, DAOs, enums) are reproducible
|
|
40
|
+
// across machines/filesystems — glob/Set iteration order is not.
|
|
41
|
+
return [...files].sort((a, b) => a.localeCompare(b));
|
|
40
42
|
};
|
|
41
43
|
|
|
42
44
|
const mergeTypeMaps = (
|
|
@@ -88,7 +90,7 @@ export async function generateEventTypes(
|
|
|
88
90
|
includeBuildDirs: true,
|
|
89
91
|
}),
|
|
90
92
|
];
|
|
91
|
-
const uniqueDaoFiles = [...new Set(daoFiles)];
|
|
93
|
+
const uniqueDaoFiles = [...new Set(daoFiles)].sort((a, b) => a.localeCompare(b));
|
|
92
94
|
|
|
93
95
|
const customDtos = parseDtosFromSources(dtoFiles);
|
|
94
96
|
const generatedDaos = parseGeneratedDaosFromSources(uniqueDaoFiles);
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { KotlinProperty } from './types';
|
|
2
|
+
|
|
3
|
+
/** Strip Kotlin line and block comments from source before structural parsing. */
|
|
4
|
+
export const stripKotlinComments = (content: string): string =>
|
|
5
|
+
content.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Strip annotations including use-site targets (field:/param:/get: prefixes).
|
|
9
|
+
* Nested call args in annotations are not fully balanced (secondary limitation).
|
|
10
|
+
*/
|
|
11
|
+
export const stripKotlinAnnotations = (segment: string): string =>
|
|
12
|
+
segment
|
|
13
|
+
.replace(/@(?:\w+:)?[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
14
|
+
.replace(/\s+/g, ' ')
|
|
15
|
+
.trim();
|
|
16
|
+
|
|
17
|
+
/** Split a constructor/parameter list on top-level commas (respecting nested brackets). */
|
|
18
|
+
export const splitTopLevelArgs = (body: string): string[] => {
|
|
19
|
+
const parts: string[] = [];
|
|
20
|
+
let depth = 0;
|
|
21
|
+
let current = '';
|
|
22
|
+
for (const ch of body) {
|
|
23
|
+
if (ch === '(' || ch === '<' || ch === '[') depth += 1;
|
|
24
|
+
if (ch === ')' || ch === '>' || ch === ']') depth -= 1;
|
|
25
|
+
if (ch === ',' && depth === 0) {
|
|
26
|
+
parts.push(current.trim());
|
|
27
|
+
current = '';
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
current += ch;
|
|
31
|
+
}
|
|
32
|
+
if (current.trim()) parts.push(current.trim());
|
|
33
|
+
return parts;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ParseKotlinPropertyOptions = {
|
|
37
|
+
/** Allow bare ctor params without val/var (sequenced PKs in generated DAOs). */
|
|
38
|
+
allowBareParams?: boolean;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Parse a Kotlin constructor / data-class property segment into a wire-facing property.
|
|
43
|
+
* Accepts optional public modifier and use-site-stripped annotations.
|
|
44
|
+
*/
|
|
45
|
+
export const parseKotlinProperty = (
|
|
46
|
+
segment: string,
|
|
47
|
+
options: ParseKotlinPropertyOptions = {},
|
|
48
|
+
): KotlinProperty | null => {
|
|
49
|
+
const cleaned = stripKotlinAnnotations(segment);
|
|
50
|
+
const propertyMatch = cleaned.match(
|
|
51
|
+
/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/,
|
|
52
|
+
);
|
|
53
|
+
const match =
|
|
54
|
+
propertyMatch ??
|
|
55
|
+
(options.allowBareParams ? cleaned.match(/^(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/) : null);
|
|
56
|
+
|
|
57
|
+
if (!match) return null;
|
|
58
|
+
|
|
59
|
+
const name = match[1];
|
|
60
|
+
let kotlinType = match[2].trim();
|
|
61
|
+
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
62
|
+
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
63
|
+
|
|
64
|
+
return { name, kotlinType, optional };
|
|
65
|
+
};
|
package/src/parse-dao.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
|
|
3
|
+
import { parseKotlinProperty, splitTopLevelArgs, stripKotlinComments } from './kotlin-parse-utils';
|
|
3
4
|
import type { KotlinDto, KotlinProperty } from './types';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -12,62 +13,6 @@ export const isGeneratedDaoEntityFile = (filePath: string): boolean => {
|
|
|
12
13
|
return /\/gen\/dao\/[^/]+\.kt$/i.test(normalized);
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
const stripKotlinAnnotations = (segment: string): string =>
|
|
16
|
-
segment
|
|
17
|
-
.replace(/@[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
18
|
-
.replace(/\s+/g, ' ')
|
|
19
|
-
.trim();
|
|
20
|
-
|
|
21
|
-
const splitTopLevelArgs = (body: string): string[] => {
|
|
22
|
-
const parts: string[] = [];
|
|
23
|
-
let depth = 0;
|
|
24
|
-
let current = '';
|
|
25
|
-
for (const ch of body) {
|
|
26
|
-
if (ch === '(' || ch === '<' || ch === '[') depth += 1;
|
|
27
|
-
if (ch === ')' || ch === '>' || ch === ']') depth -= 1;
|
|
28
|
-
if (ch === ',' && depth === 0) {
|
|
29
|
-
parts.push(current.trim());
|
|
30
|
-
current = '';
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
current += ch;
|
|
34
|
-
}
|
|
35
|
-
if (current.trim()) parts.push(current.trim());
|
|
36
|
-
return parts;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const parseDaoConstructorProperty = (segment: string): KotlinProperty | null => {
|
|
40
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
41
|
-
// Prefer property syntax: (public) var/val name: Type
|
|
42
|
-
const propertyMatch = cleaned.match(
|
|
43
|
-
/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/,
|
|
44
|
-
);
|
|
45
|
-
// Bare ctor param used for sequenced PKs: tradeId: String? = null
|
|
46
|
-
const bareMatch = propertyMatch ?? cleaned.match(/^(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
47
|
-
|
|
48
|
-
if (!bareMatch) return null;
|
|
49
|
-
|
|
50
|
-
const name = bareMatch[1];
|
|
51
|
-
let kotlinType = bareMatch[2].trim();
|
|
52
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
53
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
54
|
-
|
|
55
|
-
return { name, kotlinType, optional };
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const parseIndexDataClassProperty = (segment: string): KotlinProperty | null => {
|
|
59
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
60
|
-
const match = cleaned.match(/^(?:public\s+)?(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
61
|
-
if (!match) return null;
|
|
62
|
-
|
|
63
|
-
const name = match[1];
|
|
64
|
-
let kotlinType = match[2].trim();
|
|
65
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
66
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
67
|
-
|
|
68
|
-
return { name, kotlinType, optional };
|
|
69
|
-
};
|
|
70
|
-
|
|
71
16
|
const KOTLIN_FILE_EXTENSION = '.kt';
|
|
72
17
|
|
|
73
18
|
const entityNameFromDaoFile = (filePath: string): string | null => {
|
|
@@ -107,7 +52,7 @@ export const extractGeneratedDaoIndices = (content: string, filePath: string): K
|
|
|
107
52
|
|
|
108
53
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
109
54
|
const properties = splitTopLevelArgs(body)
|
|
110
|
-
.map(
|
|
55
|
+
.map((segment) => parseKotlinProperty(segment))
|
|
111
56
|
.filter((p): p is KotlinProperty => p != null);
|
|
112
57
|
|
|
113
58
|
if (properties.length === 0) continue;
|
|
@@ -152,7 +97,7 @@ export const extractGeneratedDaoEntities = (content: string, filePath: string):
|
|
|
152
97
|
|
|
153
98
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
154
99
|
const properties = splitTopLevelArgs(body)
|
|
155
|
-
.map(
|
|
100
|
+
.map((segment) => parseKotlinProperty(segment, { allowBareParams: true }))
|
|
156
101
|
.filter((p): p is KotlinProperty => p != null);
|
|
157
102
|
|
|
158
103
|
if (properties.length > 0) {
|
|
@@ -168,8 +113,7 @@ export const parseGeneratedDaosFromSources = (files: string[]): Map<string, Kotl
|
|
|
168
113
|
|
|
169
114
|
for (const filePath of files) {
|
|
170
115
|
if (!isGeneratedDaoEntityFile(filePath)) continue;
|
|
171
|
-
const
|
|
172
|
-
const content = rawContent.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
116
|
+
const content = stripKotlinComments(readFileSync(filePath, 'utf8'));
|
|
173
117
|
for (const entity of extractGeneratedDaoEntities(content, filePath)) {
|
|
174
118
|
if (!daos.has(entity.name)) {
|
|
175
119
|
daos.set(entity.name, entity);
|
package/src/parse-kotlin.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
2
|
|
|
3
|
+
import { parseKotlinProperty, splitTopLevelArgs, stripKotlinComments } from './kotlin-parse-utils';
|
|
3
4
|
import { handlerInputToDetailsInterfaceName } from './naming';
|
|
4
5
|
import { kotlinEnumTypeRef } from './parse-enums';
|
|
5
6
|
import type { KotlinEnumMap } from './parse-enums';
|
|
@@ -23,41 +24,6 @@ const PRIMITIVE_TS: Record<string, string> = {
|
|
|
23
24
|
|
|
24
25
|
const DATA_CLASS_START = /^\s*(?:data\s+)?class\s+(\w+)\s*(?:\([^)]*\))?\s*(?:\([^)]*\)|\{)/;
|
|
25
26
|
|
|
26
|
-
const splitTopLevelArgs = (body: string): string[] => {
|
|
27
|
-
const parts: string[] = [];
|
|
28
|
-
let depth = 0;
|
|
29
|
-
let current = '';
|
|
30
|
-
for (const ch of body) {
|
|
31
|
-
if (ch === '(' || ch === '<' || ch === '[') depth += 1;
|
|
32
|
-
if (ch === ')' || ch === '>' || ch === ']') depth -= 1;
|
|
33
|
-
if (ch === ',' && depth === 0) {
|
|
34
|
-
parts.push(current.trim());
|
|
35
|
-
current = '';
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
current += ch;
|
|
39
|
-
}
|
|
40
|
-
if (current.trim()) parts.push(current.trim());
|
|
41
|
-
return parts;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const stripKotlinAnnotations = (segment: string): string =>
|
|
45
|
-
segment
|
|
46
|
-
.replace(/@[A-Za-z_][\w.]*(?:\s*<[^>]*>)?(?:\s*\([^)]*\))?/g, ' ')
|
|
47
|
-
.replace(/\s+/g, ' ')
|
|
48
|
-
.trim();
|
|
49
|
-
|
|
50
|
-
const parseProperty = (segment: string): KotlinProperty | null => {
|
|
51
|
-
const cleaned = stripKotlinAnnotations(segment);
|
|
52
|
-
const match = cleaned.match(/^(?:val|var)\s+(\w+)\s*:\s*([^=]+?)(?:\s*=\s*.+)?$/);
|
|
53
|
-
if (!match) return null;
|
|
54
|
-
const name = match[1];
|
|
55
|
-
let kotlinType = match[2].trim();
|
|
56
|
-
const optional = kotlinType.endsWith('?') || cleaned.includes('=');
|
|
57
|
-
kotlinType = kotlinType.replace(/\?$/, '').trim();
|
|
58
|
-
return { name, kotlinType, optional };
|
|
59
|
-
};
|
|
60
|
-
|
|
61
27
|
const extractDataClasses = (content: string): { name: string; properties: KotlinProperty[] }[] => {
|
|
62
28
|
const results: { name: string; properties: KotlinProperty[] }[] = [];
|
|
63
29
|
const classRegex = /(?:^|\n)\s*(?:data\s+)?class\s+(\w+)\s*\(/gm;
|
|
@@ -83,7 +49,7 @@ const extractDataClasses = (content: string): { name: string; properties: Kotlin
|
|
|
83
49
|
|
|
84
50
|
const body = content.slice(openParenIndex + 1, closeIndex);
|
|
85
51
|
const properties = splitTopLevelArgs(body)
|
|
86
|
-
.map(
|
|
52
|
+
.map((segment) => parseKotlinProperty(segment))
|
|
87
53
|
.filter((p): p is KotlinProperty => p != null);
|
|
88
54
|
|
|
89
55
|
if (properties.length > 0) {
|
|
@@ -98,8 +64,7 @@ export const parseDtosFromSources = (files: string[]): Map<string, KotlinDto> =>
|
|
|
98
64
|
const dtos = new Map<string, KotlinDto>();
|
|
99
65
|
|
|
100
66
|
for (const filePath of files) {
|
|
101
|
-
const
|
|
102
|
-
const content = rawContent.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, '');
|
|
67
|
+
const content = stripKotlinComments(readFileSync(filePath, 'utf8'));
|
|
103
68
|
for (const parsed of extractDataClasses(content)) {
|
|
104
69
|
dtos.set(parsed.name, {
|
|
105
70
|
name: parsed.name,
|
|
@@ -134,8 +99,7 @@ export const parseHandlersFromSources = (
|
|
|
134
99
|
const seenEvents = new Set<string>();
|
|
135
100
|
|
|
136
101
|
for (const filePath of files) {
|
|
137
|
-
const
|
|
138
|
-
const stripped = content.replace(/\/\*[\s\S]*?\*\//g, '');
|
|
102
|
+
const stripped = stripKotlinComments(readFileSync(filePath, 'utf8'));
|
|
139
103
|
|
|
140
104
|
const tryMatch = (regex: RegExp) => {
|
|
141
105
|
let handlerMatch: RegExpExecArray | null;
|
package/src/render.ts
CHANGED
|
@@ -7,6 +7,37 @@ import { kotlinEnumTypeRef, type KotlinEnumMap } from './parse-enums';
|
|
|
7
7
|
import { kotlinTypeToTs } from './parse-kotlin';
|
|
8
8
|
import type { KotlinDto, MappedHandler, UnmappedHandler } from './types';
|
|
9
9
|
|
|
10
|
+
const kotlinTypeRoot = (kotlinType: string): string => {
|
|
11
|
+
const listMatch = kotlinType.match(/^(?:List|MutableList|Set|MutableSet)<(.+)>$/);
|
|
12
|
+
if (listMatch) {
|
|
13
|
+
return kotlinTypeRoot(listMatch[1].trim());
|
|
14
|
+
}
|
|
15
|
+
return kotlinType.replace(/\?$/, '').trim();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/** Handler inputs plus any nested custom DTOs referenced from their properties. */
|
|
19
|
+
const expandUsedDtoNames = (mapped: MappedHandler[], dtos: Map<string, KotlinDto>): Set<string> => {
|
|
20
|
+
const used = new Set<string>();
|
|
21
|
+
|
|
22
|
+
const visit = (dtoName: string) => {
|
|
23
|
+
if (used.has(dtoName) || !dtos.has(dtoName)) return;
|
|
24
|
+
used.add(dtoName);
|
|
25
|
+
const dto = dtos.get(dtoName)!;
|
|
26
|
+
for (const prop of dto.properties) {
|
|
27
|
+
const nested = kotlinTypeRoot(prop.kotlinType);
|
|
28
|
+
if (dtos.has(nested)) {
|
|
29
|
+
visit(nested);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
for (const handler of mapped) {
|
|
35
|
+
visit(handler.inputType);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return used;
|
|
39
|
+
};
|
|
40
|
+
|
|
10
41
|
const renderInterface = (
|
|
11
42
|
dto: KotlinDto,
|
|
12
43
|
dtos: Map<string, KotlinDto>,
|
|
@@ -67,16 +98,16 @@ const renderEnumExports = (enums: KotlinEnumMap, usedEnumNames: Set<string>): st
|
|
|
67
98
|
};
|
|
68
99
|
|
|
69
100
|
const collectUsedEnumNames = (
|
|
70
|
-
|
|
101
|
+
usedDtoNames: Set<string>,
|
|
71
102
|
dtos: Map<string, KotlinDto>,
|
|
72
103
|
enums: KotlinEnumMap,
|
|
73
104
|
): Set<string> => {
|
|
74
105
|
const used = new Set<string>();
|
|
75
|
-
for (const
|
|
76
|
-
const dto = dtos.get(
|
|
106
|
+
for (const dtoName of usedDtoNames) {
|
|
107
|
+
const dto = dtos.get(dtoName);
|
|
77
108
|
if (!dto) continue;
|
|
78
109
|
for (const prop of dto.properties) {
|
|
79
|
-
const ref = kotlinEnumTypeRef(prop.kotlinType, enums);
|
|
110
|
+
const ref = kotlinEnumTypeRef(kotlinTypeRoot(prop.kotlinType), enums);
|
|
80
111
|
if (ref) used.add(ref);
|
|
81
112
|
}
|
|
82
113
|
}
|
|
@@ -89,14 +120,14 @@ export const renderEventTypesFile = (
|
|
|
89
120
|
dtos: Map<string, KotlinDto>,
|
|
90
121
|
enums: KotlinEnumMap = new Map(),
|
|
91
122
|
): string => {
|
|
92
|
-
const usedDtos =
|
|
123
|
+
const usedDtos = expandUsedDtoNames(mapped, dtos);
|
|
93
124
|
const interfaces = [...usedDtos]
|
|
94
125
|
.map((name) => dtos.get(name))
|
|
95
126
|
.filter((dto): dto is KotlinDto => dto != null)
|
|
96
127
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
97
128
|
.map((dto) => renderInterface(dto, dtos, enums));
|
|
98
129
|
|
|
99
|
-
const usedEnumNames = collectUsedEnumNames(
|
|
130
|
+
const usedEnumNames = collectUsedEnumNames(usedDtos, dtos, enums);
|
|
100
131
|
const enumExports = renderEnumExports(enums, usedEnumNames);
|
|
101
132
|
|
|
102
133
|
const mapEntries = mapped.map((m) => ` ${m.eventName}: ${m.detailsInterface};`).join('\n');
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
import { GenesisEvent } from '@genesislcap/foundation-comms';
|
|
9
9
|
|
|
10
|
+
export const Priority = {
|
|
11
|
+
LOW: 'LOW',
|
|
12
|
+
HIGH: 'HIGH',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type Priority = (typeof Priority)[keyof typeof Priority];
|
|
16
|
+
|
|
10
17
|
export const Side = {
|
|
11
18
|
BUY: 'BUY',
|
|
12
19
|
SELL: 'SELL',
|
|
@@ -14,6 +21,26 @@ export const Side = {
|
|
|
14
21
|
|
|
15
22
|
export type Side = (typeof Side)[keyof typeof Side];
|
|
16
23
|
|
|
24
|
+
export interface AmendCellInputDetails {
|
|
25
|
+
MAX_SIZE: number;
|
|
26
|
+
MAX_INSTRUMENT_SCORE: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AnnotatedInputDetails {
|
|
30
|
+
COUNTERPARTY_ID: string;
|
|
31
|
+
NAME: string;
|
|
32
|
+
IGNORED_HINT?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BulkSideInputDetails {
|
|
36
|
+
PRIORITIES: Priority[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ChargeAmendInputDetails {
|
|
40
|
+
CHARGE_ADDITION_ID: string;
|
|
41
|
+
CELLS: AmendCellInputDetails[];
|
|
42
|
+
}
|
|
43
|
+
|
|
17
44
|
export interface FooInputDetails {
|
|
18
45
|
FOO_ID: string;
|
|
19
46
|
BAR_ID?: string;
|
|
@@ -43,7 +70,10 @@ export interface TradeByIdDetails {
|
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
export interface EventDetailsMap {
|
|
73
|
+
EVENT_ANNOTATED: AnnotatedInputDetails;
|
|
46
74
|
EVENT_BAR_BAZ: NestedInputDetails;
|
|
75
|
+
EVENT_BULK_SIDE: BulkSideInputDetails;
|
|
76
|
+
EVENT_CHARGE_AMEND: ChargeAmendInputDetails;
|
|
47
77
|
EVENT_CONTEXT_FOO: FooInputDetails;
|
|
48
78
|
EVENT_DAO_HANDLER: InstrumentByIdDetails;
|
|
49
79
|
EVENT_FOO: FooInputDetails;
|
|
@@ -53,6 +83,14 @@ export interface EventDetailsMap {
|
|
|
53
83
|
|
|
54
84
|
export type GenesisEventName = keyof EventDetailsMap;
|
|
55
85
|
|
|
86
|
+
export class EventAnnotated extends GenesisEvent<'EVENT_ANNOTATED', AnnotatedInputDetails> {
|
|
87
|
+
readonly MESSAGE_TYPE = 'EVENT_ANNOTATED' as const;
|
|
88
|
+
|
|
89
|
+
constructor(details: AnnotatedInputDetails) {
|
|
90
|
+
super(details);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
56
94
|
export class EventBarBaz extends GenesisEvent<'EVENT_BAR_BAZ', NestedInputDetails> {
|
|
57
95
|
readonly MESSAGE_TYPE = 'EVENT_BAR_BAZ' as const;
|
|
58
96
|
|
|
@@ -61,6 +99,22 @@ export class EventBarBaz extends GenesisEvent<'EVENT_BAR_BAZ', NestedInputDetail
|
|
|
61
99
|
}
|
|
62
100
|
}
|
|
63
101
|
|
|
102
|
+
export class EventBulkSide extends GenesisEvent<'EVENT_BULK_SIDE', BulkSideInputDetails> {
|
|
103
|
+
readonly MESSAGE_TYPE = 'EVENT_BULK_SIDE' as const;
|
|
104
|
+
|
|
105
|
+
constructor(details: BulkSideInputDetails) {
|
|
106
|
+
super(details);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class EventChargeAmend extends GenesisEvent<'EVENT_CHARGE_AMEND', ChargeAmendInputDetails> {
|
|
111
|
+
readonly MESSAGE_TYPE = 'EVENT_CHARGE_AMEND' as const;
|
|
112
|
+
|
|
113
|
+
constructor(details: ChargeAmendInputDetails) {
|
|
114
|
+
super(details);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
64
118
|
export class EventContextFoo extends GenesisEvent<'EVENT_CONTEXT_FOO', FooInputDetails> {
|
|
65
119
|
readonly MESSAGE_TYPE = 'EVENT_CONTEXT_FOO' as const;
|
|
66
120
|
|
|
@@ -7,6 +7,13 @@
|
|
|
7
7
|
|
|
8
8
|
import { GenesisEvent } from '@genesislcap/foundation-comms';
|
|
9
9
|
|
|
10
|
+
export const Priority = {
|
|
11
|
+
LOW: 'LOW',
|
|
12
|
+
HIGH: 'HIGH',
|
|
13
|
+
} as const;
|
|
14
|
+
|
|
15
|
+
export type Priority = (typeof Priority)[keyof typeof Priority];
|
|
16
|
+
|
|
10
17
|
export const Side = {
|
|
11
18
|
BUY: 'BUY',
|
|
12
19
|
SELL: 'SELL',
|
|
@@ -14,6 +21,26 @@ export const Side = {
|
|
|
14
21
|
|
|
15
22
|
export type Side = (typeof Side)[keyof typeof Side];
|
|
16
23
|
|
|
24
|
+
export interface AmendCellInputDetails {
|
|
25
|
+
MAX_SIZE: number;
|
|
26
|
+
MAX_INSTRUMENT_SCORE: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface AnnotatedInputDetails {
|
|
30
|
+
COUNTERPARTY_ID: string;
|
|
31
|
+
NAME: string;
|
|
32
|
+
IGNORED_HINT?: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface BulkSideInputDetails {
|
|
36
|
+
PRIORITIES: Priority[];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ChargeAmendInputDetails {
|
|
40
|
+
CHARGE_ADDITION_ID: string;
|
|
41
|
+
CELLS: AmendCellInputDetails[];
|
|
42
|
+
}
|
|
43
|
+
|
|
17
44
|
export interface FooInputDetails {
|
|
18
45
|
FOO_ID: string;
|
|
19
46
|
BAR_ID?: string;
|
|
@@ -43,7 +70,10 @@ export interface TradeByIdDetails {
|
|
|
43
70
|
}
|
|
44
71
|
|
|
45
72
|
export interface EventDetailsMap {
|
|
73
|
+
EVENT_ANNOTATED: AnnotatedInputDetails;
|
|
46
74
|
EVENT_BAR_BAZ: NestedInputDetails;
|
|
75
|
+
EVENT_BULK_SIDE: BulkSideInputDetails;
|
|
76
|
+
EVENT_CHARGE_AMEND: ChargeAmendInputDetails;
|
|
47
77
|
EVENT_CONTEXT_FOO: FooInputDetails;
|
|
48
78
|
EVENT_DAO_HANDLER: InstrumentByIdDetails;
|
|
49
79
|
EVENT_FOO: FooInputDetails;
|
|
@@ -53,6 +83,14 @@ export interface EventDetailsMap {
|
|
|
53
83
|
|
|
54
84
|
export type GenesisEventName = keyof EventDetailsMap;
|
|
55
85
|
|
|
86
|
+
export class EventAnnotated extends GenesisEvent<'EVENT_ANNOTATED', AnnotatedInputDetails> {
|
|
87
|
+
readonly MESSAGE_TYPE = 'EVENT_ANNOTATED' as const;
|
|
88
|
+
|
|
89
|
+
constructor(details: AnnotatedInputDetails) {
|
|
90
|
+
super(details);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
56
94
|
export class EventBarBaz extends GenesisEvent<'EVENT_BAR_BAZ', NestedInputDetails> {
|
|
57
95
|
readonly MESSAGE_TYPE = 'EVENT_BAR_BAZ' as const;
|
|
58
96
|
|
|
@@ -61,6 +99,22 @@ export class EventBarBaz extends GenesisEvent<'EVENT_BAR_BAZ', NestedInputDetail
|
|
|
61
99
|
}
|
|
62
100
|
}
|
|
63
101
|
|
|
102
|
+
export class EventBulkSide extends GenesisEvent<'EVENT_BULK_SIDE', BulkSideInputDetails> {
|
|
103
|
+
readonly MESSAGE_TYPE = 'EVENT_BULK_SIDE' as const;
|
|
104
|
+
|
|
105
|
+
constructor(details: BulkSideInputDetails) {
|
|
106
|
+
super(details);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export class EventChargeAmend extends GenesisEvent<'EVENT_CHARGE_AMEND', ChargeAmendInputDetails> {
|
|
111
|
+
readonly MESSAGE_TYPE = 'EVENT_CHARGE_AMEND' as const;
|
|
112
|
+
|
|
113
|
+
constructor(details: ChargeAmendInputDetails) {
|
|
114
|
+
super(details);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
64
118
|
export class EventContextFoo extends GenesisEvent<'EVENT_CONTEXT_FOO', FooInputDetails> {
|
|
65
119
|
readonly MESSAGE_TYPE = 'EVENT_CONTEXT_FOO' as const;
|
|
66
120
|
|
|
@@ -15,7 +15,7 @@ import org.joda.time.DateTime
|
|
|
15
15
|
@Title("Trade")
|
|
16
16
|
public class Trade public constructor(
|
|
17
17
|
tradeId: String? = null,
|
|
18
|
-
@Title("Instrument Id")
|
|
18
|
+
@field:Title("Instrument Id")
|
|
19
19
|
@GenesisType(Field.Type.STRING)
|
|
20
20
|
public var instrumentId: String, // instrument ref, required
|
|
21
21
|
@Title("Counterparty Id")
|
|
@@ -49,3 +49,9 @@ enum class Side {
|
|
|
49
49
|
BUY,
|
|
50
50
|
SELL,
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
/** Only referenced via List<> in custom DTOs — exercises enum collection export. */
|
|
54
|
+
enum class Priority {
|
|
55
|
+
LOW,
|
|
56
|
+
HIGH,
|
|
57
|
+
}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
package com.example
|
|
2
2
|
|
|
3
|
+
import com.example.dto.AnnotatedInput
|
|
4
|
+
import com.example.dto.BulkSideInput
|
|
5
|
+
import com.example.dto.ChargeAmendInput
|
|
3
6
|
import com.example.dto.FooInput
|
|
4
7
|
import com.example.dto.NestedInput
|
|
5
8
|
|
|
6
9
|
fun register() {
|
|
10
|
+
// eventHandler<FooInput>("GHOST")
|
|
7
11
|
eventHandler<FooInput>("FOO")
|
|
8
12
|
eventHandler<NestedInput>("BAR_BAZ")
|
|
13
|
+
eventHandler<ChargeAmendInput>("CHARGE_AMEND")
|
|
14
|
+
eventHandler<AnnotatedInput>("ANNOTATED")
|
|
15
|
+
eventHandler<BulkSideInput>("BULK_SIDE")
|
|
9
16
|
contextEventHandler<FooInput, String>(name = "CONTEXT_FOO")
|
|
10
17
|
// Full table DAO — resolved from generated-dao sources
|
|
11
18
|
eventHandler<Trade>("TRADE_INSERT", transactional = true)
|
|
@@ -5,6 +5,26 @@ data class FooInput(
|
|
|
5
5
|
/* optional bar, with comma */ val barId: String? = null,
|
|
6
6
|
)
|
|
7
7
|
|
|
8
|
+
data class AnnotatedInput(
|
|
9
|
+
@field:JsonProperty("x") val counterpartyId: String,
|
|
10
|
+
@param:NotNull val name: String,
|
|
11
|
+
@get:JsonIgnore val ignoredHint: String? = null,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
data class BulkSideInput(
|
|
15
|
+
val priorities: List<Priority>,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
data class AmendCellInput(
|
|
19
|
+
val maxSize: Int,
|
|
20
|
+
val maxInstrumentScore: Int,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
data class ChargeAmendInput(
|
|
24
|
+
val chargeAdditionId: String,
|
|
25
|
+
val cells: List<AmendCellInput>,
|
|
26
|
+
)
|
|
27
|
+
|
|
8
28
|
data class NestedInput(
|
|
9
29
|
val items: List<FooInput>,
|
|
10
30
|
)
|
package/test/generate.test.ts
CHANGED
|
@@ -31,7 +31,7 @@ suite('generates golden genesis-event-types.ts from fixture Kotlin module', asyn
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
assert.ok(result);
|
|
34
|
-
assert.equal(result?.eventCount,
|
|
34
|
+
assert.equal(result?.eventCount, 9);
|
|
35
35
|
|
|
36
36
|
const actual = readFileSync(outputPath, 'utf8').trim();
|
|
37
37
|
const expected = readFileSync(goldenPath, 'utf8').trim();
|
|
@@ -43,6 +43,26 @@ suite('maps handler name FOO to EVENT_FOO', async () => {
|
|
|
43
43
|
assert.is(actual.includes('EVENT_FOO: FooInputDetails'), true);
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
+
suite('ignores line-commented eventHandler registrations', async () => {
|
|
47
|
+
const actual = readFileSync(goldenPath, 'utf8');
|
|
48
|
+
assert.is(actual.includes('EVENT_GHOST'), false);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
suite('keeps properties with Kotlin use-site annotations', async () => {
|
|
52
|
+
const actual = readFileSync(goldenPath, 'utf8');
|
|
53
|
+
assert.is(actual.includes('export interface AnnotatedInputDetails'), true);
|
|
54
|
+
assert.is(actual.includes('COUNTERPARTY_ID: string'), true);
|
|
55
|
+
assert.is(actual.includes('NAME: string'), true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
suite('exports enums referenced only from List/Set properties', async () => {
|
|
59
|
+
const actual = readFileSync(goldenPath, 'utf8');
|
|
60
|
+
assert.is(actual.includes('PRIORITIES: Priority[]'), true);
|
|
61
|
+
assert.is(actual.includes('export const Priority = {'), true);
|
|
62
|
+
// Priority is not used as a bare enum field on any DTO/DAO — only via List<>.
|
|
63
|
+
assert.is(/PRIORITY\??: Priority\b/.test(actual), false);
|
|
64
|
+
});
|
|
65
|
+
|
|
46
66
|
suite('maps generated DAO Trade handler to EVENT_TRADE_INSERT', async () => {
|
|
47
67
|
const actual = readFileSync(goldenPath, 'utf8');
|
|
48
68
|
assert.is(actual.includes('EVENT_TRADE_INSERT: TradeDetails'), true);
|
|
@@ -85,4 +105,11 @@ suite('parses handlers with trailing named args (transactional)', async () => {
|
|
|
85
105
|
assert.is(actual.includes('EVENT_TRADE_INSERT: TradeDetails'), true);
|
|
86
106
|
});
|
|
87
107
|
|
|
108
|
+
suite('emits nested DTO interfaces not used as handler inputs', async () => {
|
|
109
|
+
const actual = readFileSync(goldenPath, 'utf8');
|
|
110
|
+
assert.is(actual.includes('export interface AmendCellInputDetails'), true);
|
|
111
|
+
assert.is(actual.includes('CELLS: AmendCellInputDetails[]'), true);
|
|
112
|
+
assert.is(actual.includes('EVENT_CHARGE_AMEND: ChargeAmendInputDetails'), true);
|
|
113
|
+
});
|
|
114
|
+
|
|
88
115
|
suite.run();
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["./src/config.ts","./src/index.ts","./src/naming.ts","./src/parse-dao.ts","./src/parse-enums.ts","./src/parse-kotlin.ts","./src/render.ts","./src/types.ts"],"version":"5.9.2"}
|
|
1
|
+
{"root":["./src/config.ts","./src/index.ts","./src/kotlin-parse-utils.ts","./src/naming.ts","./src/parse-dao.ts","./src/parse-enums.ts","./src/parse-kotlin.ts","./src/render.ts","./src/types.ts"],"version":"5.9.2"}
|