@judo/codegen 0.1.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.
@@ -0,0 +1,137 @@
1
+ /**
2
+ * Model reader — extracts structured data from .model XML files
3
+ * for use by the code generator.
4
+ *
5
+ * Uses fast-xml-parser for lightweight XML extraction.
6
+ */
7
+ export interface ExtractedModel {
8
+ /** All applications (actors) found in the model */
9
+ applications: ExtractedApplication[];
10
+ /** All unique pages across all applications */
11
+ pages: ExtractedPage[];
12
+ /** All elements with customImplementation="true" */
13
+ components: ExtractedComponent[];
14
+ /** Navigation items extracted for translation key generation */
15
+ navigationItems: ExtractedNavigationItem[];
16
+ /** All unique subTheme names found on visual elements */
17
+ subThemeNames: string[];
18
+ /** All data types (primitives + enumerations) from the model */
19
+ dataTypes: ExtractedDataType[];
20
+ /** All transfer types (ClassType data elements) from the model */
21
+ transferTypes: ExtractedTransferType[];
22
+ }
23
+ export interface ExtractedApplication {
24
+ name: string;
25
+ sourceId: string;
26
+ }
27
+ export interface ExtractedPage {
28
+ /** Human-readable page name from the model */
29
+ name: string;
30
+ /** The xmi:id (sourceId) of the PageDefinition */
31
+ sourceId: string;
32
+ /** Application this page belongs to */
33
+ applicationName: string;
34
+ /** The label from the model (for translation baseline generation) */
35
+ label?: string;
36
+ /** Whether this page opens in a dialog */
37
+ openInDialog: boolean;
38
+ /** Whether this is a dashboard page */
39
+ dashboard: boolean;
40
+ /** Container type (TABLE, FORM, VIEW) */
41
+ containerType?: string;
42
+ /** Actions available on this page */
43
+ actions: ExtractedAction[];
44
+ /** Named elements on this page (for visual property overrides) */
45
+ elements: ExtractedElement[];
46
+ }
47
+ export interface ExtractedAction {
48
+ /** Human-readable action name from the model */
49
+ name: string;
50
+ /** The xmi:id (sourceId) of the Action */
51
+ sourceId: string;
52
+ /** The @type of the ActionDefinition (e.g., "DeleteActionDefinition") */
53
+ actionDefinitionType: string;
54
+ /** The xmi:id of the ActionDefinition */
55
+ actionDefinitionSourceId: string;
56
+ }
57
+ export interface ExtractedComponent {
58
+ /** Human-readable element name from the model */
59
+ name: string;
60
+ /** The xmi:id (sourceId) of the VisualElement */
61
+ sourceId: string;
62
+ /** The @type of the VisualElement (e.g., "Flex") */
63
+ elementType: string;
64
+ /** Page this component belongs to (for context) */
65
+ pageName?: string;
66
+ /** Resolved annotation names on this element (e.g. ["useFancyText"]) */
67
+ annotations?: string[];
68
+ }
69
+ export interface ExtractedNavigationItem {
70
+ /** Human-readable name from the model */
71
+ name: string;
72
+ /** The xmi:id of the navigation item */
73
+ sourceId: string;
74
+ /** The display label */
75
+ label?: string;
76
+ }
77
+ export interface ExtractedElement {
78
+ /** Human-readable element name */
79
+ name: string;
80
+ /** Hierarchical dot-separated path from container root (e.g. "View.group.stars") */
81
+ path: string;
82
+ /** The xmi:id (sourceId) */
83
+ sourceId: string;
84
+ /** The @type of the VisualElement */
85
+ elementType: string;
86
+ /** The label from the model (for translation baseline generation) */
87
+ label?: string;
88
+ /** Resolved annotation names on this element (e.g. ["useFancyText", "dashboard"]) */
89
+ annotations?: string[];
90
+ }
91
+ export interface ExtractedDataType {
92
+ /** xmi:id of the data type */
93
+ xmiId: string;
94
+ /** xsi:type (e.g., "data:StringType", "data:NumericType") */
95
+ xsiType: string;
96
+ /** Name from the model (e.g., "types::String", "Gender") */
97
+ name: string;
98
+ /** For EnumerationType: member value names (e.g., ["MALE", "FEMALE"]) */
99
+ members?: string[];
100
+ }
101
+ export interface ExtractedTransferAttribute {
102
+ /** Attribute name (e.g., "city", "name") */
103
+ name: string;
104
+ /** Reference to the data type xmi:id */
105
+ dataTypeRef: string;
106
+ /** Whether the attribute is read-only */
107
+ isReadOnly: boolean;
108
+ /** Whether the attribute is required */
109
+ isRequired: boolean;
110
+ }
111
+ export interface ExtractedTransferRelation {
112
+ /** Relation name (e.g., "country", "items") */
113
+ name: string;
114
+ /** Reference to the target ClassType xmi:id */
115
+ targetRef: string;
116
+ /** Whether this is a collection relation */
117
+ isCollection: boolean;
118
+ }
119
+ export interface ExtractedTransferType {
120
+ /** The DTO name (e.g., "AddressDTO", "OrderDTO") */
121
+ name: string;
122
+ /** xmi:id of the ClassType */
123
+ xmiId: string;
124
+ /** Whether this is an actor type */
125
+ isActor: boolean;
126
+ /** Attributes on this type */
127
+ attributes: ExtractedTransferAttribute[];
128
+ /** Relations to other ClassTypes */
129
+ relations: ExtractedTransferRelation[];
130
+ }
131
+ /**
132
+ * Extract model information from XML content.
133
+ * This does a lightweight parse focused on what the codegen needs:
134
+ * pages, actions, and customImplementation elements.
135
+ */
136
+ export declare function extractModel(xmlContent: string): ExtractedModel;
137
+ //# sourceMappingURL=model-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model-reader.d.ts","sourceRoot":"","sources":["../src/model-reader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH,MAAM,WAAW,cAAc;IAC9B,mDAAmD;IACnD,YAAY,EAAE,oBAAoB,EAAE,CAAC;IACrC,+CAA+C;IAC/C,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,oDAAoD;IACpD,UAAU,EAAE,kBAAkB,EAAE,CAAC;IACjC,gEAAgE;IAChE,eAAe,EAAE,uBAAuB,EAAE,CAAC;IAC3C,yDAAyD;IACzD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gEAAgE;IAChE,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,kEAAkE;IAClE,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,oBAAoB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,uCAAuC;IACvC,eAAe,EAAE,MAAM,CAAC;IACxB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;I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AM,WAAW,iBAAiB;IACjC,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,6DAA6D;IAC7D,OAAO,EAAE,MAAM,CAAC;IAChB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,0BAA0B;IAC1C,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,yCAAyC;IACzC,UAAU,EAAE,OAAO,CAAC;IACpB,wCAAwC;IACxC,UAAU,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACzC,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,YAAY,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACrC,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,8BAA8B;IAC9B,UAAU,EAAE,0BAA0B,EAAE,CAAC;IACzC,oCAAoC;IACpC,SAAS,EAAE,yBAAyB,EAAE,CAAC;CACvC;AA2CD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,CA8O/D"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Name utilities for converting model names to TypeScript identifiers.
3
+ */
4
+ /**
5
+ * Convert a model page name to a TypeScript-safe identifier.
6
+ *
7
+ * Model page names use "::" separators, e.g.:
8
+ * - "Customer::customerOrders::AccessTablePage"
9
+ * - "AddressDTO::Form::group::country::LinkSetSelectorPage"
10
+ * - "Home::Order::ActionGroup::createNewOrder::Input::Form"
11
+ *
12
+ * We take the last meaningful segment and PascalCase it, deduplicating if needed.
13
+ */
14
+ export declare function toPageIdentifier(pageName: string): string;
15
+ /**
16
+ * Convert a model action name to a TypeScript-safe camelCase identifier.
17
+ *
18
+ * Action names like "Customer::customerOrders::Back" → "back"
19
+ * or "OrderDTO::OrderView::itemsGroup::items::TabularReferenceTableBulkDeleteAction" → "itemsBulkDelete"
20
+ */
21
+ export declare function toActionIdentifier(actionName: string): string;
22
+ /**
23
+ * Convert a model element name to a TypeScript-safe camelCase identifier.
24
+ */
25
+ export declare function toElementIdentifier(elementName: string): string;
26
+ /**
27
+ * Convert a model navigation item name to a clean PascalCase identifier
28
+ * suitable for use as a translation key segment.
29
+ *
30
+ * Navigation item names like "God::God::galaxies::NavigationItem" → "Galaxies"
31
+ * or "Admin::orders::NavigationItem" → "Orders"
32
+ */
33
+ export declare function toNavItemIdentifier(navItemName: string): string;
34
+ /**
35
+ * Convert a model component name to a TypeScript-safe PascalCase identifier.
36
+ */
37
+ export declare function toComponentIdentifier(componentName: string): string;
38
+ /**
39
+ * Convert a model transfer type or data type name to a TypeScript-safe PascalCase identifier.
40
+ *
41
+ * Transfer/data type names may contain "::" namespace separators:
42
+ * - "View::Galaxy" → "ViewGalaxy"
43
+ * - "ReadOnlyTest::SpaceShipTransfer" → "ReadOnlyTestSpaceShipTransfer"
44
+ * - "Galaxy" → "Galaxy" (no namespace)
45
+ */
46
+ export declare function toTransferIdentifier(name: string): string;
47
+ /**
48
+ * Create a safe key for use in Record types (for generated source-id maps).
49
+ * Uses the page name directly but sanitized.
50
+ */
51
+ export declare function toSafeKey(name: string): string;
52
+ /**
53
+ * Convert string to PascalCase.
54
+ */
55
+ export declare function toPascalCase(str: string): string;
56
+ /**
57
+ * Convert string to camelCase.
58
+ */
59
+ export declare function toCamelCase(str: string): string;
60
+ /**
61
+ * Deduplicate names in a list by appending numeric suffixes.
62
+ */
63
+ export declare function deduplicateNames(names: string[]): Map<string, string>;
64
+ //# sourceMappingURL=name-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"name-utils.d.ts","sourceRoot":"","sources":["../src/name-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUzD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAsC7D;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAW/D;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,CAEnE;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMzD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAG/C;AAeD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAerE"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@judo/codegen",
3
+ "version": "0.1.0",
4
+ "description": "Code generator for JUDO UI Runtime extensibility — produces type-safe customization interfaces from .model files",
5
+ "license": "EPL-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/BlackBeltTechnology/judo-frontend-runtime.git",
9
+ "directory": "packages/codegen"
10
+ },
11
+ "bin": {
12
+ "judo-codegen": "./dist/cli.js"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE",
17
+ "README.md"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "import": "./dist/index.js"
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "dependencies": {
34
+ "fast-xml-parser": "^5.3.6",
35
+ "@judo/model-api": "0.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^25.2.3",
39
+ "typescript": "^5.9.3",
40
+ "vite": "npm:rolldown-vite@7.3.1",
41
+ "vitest": "^4.0.18"
42
+ },
43
+ "scripts": {
44
+ "build": "vite build",
45
+ "test": "vitest run",
46
+ "test:watch": "vitest",
47
+ "test:coverage": "vitest run --coverage",
48
+ "type-check": "tsgo --noEmit"
49
+ }
50
+ }