ondc-code-generator 0.9.0 → 1.0.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/alpha/possible-json-paths.json +34134 -0
- package/alpha/table/rag-table-docs/confirm.md +3 -0
- package/alpha/table/rag-table-docs/init.md +3 -0
- package/alpha/table/rag-table-docs/on_confirm.md +3 -0
- package/alpha/table/rag-table-docs/on_init.md +3 -0
- package/alpha/table/rag-table-docs/on_search.md +3 -0
- package/alpha/table/rag-table-docs/on_select.md +3 -0
- package/alpha/table/rag-table-docs/on_status.md +3 -0
- package/alpha/table/rag-table-docs/on_update.md +3 -0
- package/alpha/table/rag-table-docs/search.md +3 -0
- package/alpha/table/rag-table-docs/select.md +3 -0
- package/alpha/table/rag-table-docs/status.md +3 -0
- package/alpha/table/rag-table-docs/update.md +3 -0
- package/dist/generator/config-compiler.d.ts +16 -2
- package/dist/generator/config-compiler.js +45 -19
- package/dist/generator/generators/classes/abstract-generator.d.ts +2 -0
- package/dist/generator/generators/documentation/md-generator.d.ts +2 -1
- package/dist/generator/generators/documentation/md-generator.js +3 -2
- package/dist/generator/generators/go/go-generator.js +1 -1
- package/dist/generator/generators/javascript/js-generator.js +1 -1
- package/dist/generator/generators/python/py-generator.js +1 -1
- package/dist/generator/generators/rag/rag-table-generator.d.ts +1 -1
- package/dist/generator/generators/rag/rag-table-generator.js +8 -2
- package/dist/generator/generators/typescript/ts-generator.js +1 -1
- package/dist/index.test.js +12 -3
- package/dist/types/build.d.ts +4 -0
- package/package.json +1 -1
|
@@ -3,11 +3,14 @@ action: confirm
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 45
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `confirm` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**36** leaf validation rule(s) applied to `confirm` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: init
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 63
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `init` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**49** leaf validation rule(s) applied to `init` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_confirm
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 146
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_confirm` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**109** leaf validation rule(s) applied to `on_confirm` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_init
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 128
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_init` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**95** leaf validation rule(s) applied to `on_init` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_search
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 145
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_search` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**115** leaf validation rule(s) applied to `on_search` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_select
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 81
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_select` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**61** leaf validation rule(s) applied to `on_select` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_status
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 135
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_status` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**101** leaf validation rule(s) applied to `on_status` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: on_update
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 146
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `on_update` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**109** leaf validation rule(s) applied to `on_update` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: search
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 110
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `search` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**88** leaf validation rule(s) applied to `search` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: select
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 52
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `select` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**40** leaf validation rule(s) applied to `select` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: status
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 26
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `status` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**22** leaf validation rule(s) applied to `status` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -3,11 +3,14 @@ action: update
|
|
|
3
3
|
codeName: L1validations
|
|
4
4
|
numTests: 33
|
|
5
5
|
generated: 2026-03-10
|
|
6
|
+
domain: -
|
|
7
|
+
version: -
|
|
6
8
|
---
|
|
7
9
|
|
|
8
10
|
# L1validations — `update` Validations (Table View)
|
|
9
11
|
|
|
10
12
|
**27** leaf validation rule(s) applied to `update` in the **L1validations** flow.
|
|
13
|
+
Domain: `-`, Version: `-`
|
|
11
14
|
Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.
|
|
12
15
|
|
|
13
16
|
---
|
|
@@ -15,15 +15,29 @@ export declare class ConfigCompiler {
|
|
|
15
15
|
errorDefinitions: ErrorDefinition[] | undefined;
|
|
16
16
|
generatorConfig: CodeGeneratorConfig | undefined;
|
|
17
17
|
language: SupportedLanguages;
|
|
18
|
+
domain?: string | string[];
|
|
19
|
+
version?: string;
|
|
18
20
|
private SchemaExtractionService;
|
|
19
21
|
constructor(language: SupportedLanguages);
|
|
20
22
|
initialize: (buildYaml: string, generatorConfig?: Partial<CodeGeneratorConfig>) => Promise<void>;
|
|
21
23
|
performValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
22
24
|
withMinimalValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
23
|
-
generateCode: (valConfig: ValidationConfig,
|
|
25
|
+
generateCode: (valConfig: ValidationConfig, codeGenConfig?: CodeGenConfig | string) => Promise<void>;
|
|
24
26
|
generateL0Schema: (outputPath?: string, type?: "json" | "typescript", absolutePath?: boolean) => Promise<void>;
|
|
25
27
|
generateValidPaths: () => Promise<Record<string, string[]>>;
|
|
26
|
-
generateValidationFromBuild: (
|
|
28
|
+
generateValidationFromBuild: (codeGenConfig: CodeGenConfig | string, outputPath?: string, absolutePath?: boolean, goPackageName?: string) => Promise<void>;
|
|
27
29
|
extractPayloadsFromBuild: (outputPath: string) => Promise<void>;
|
|
28
30
|
}
|
|
31
|
+
export type CodeGenConfig = {
|
|
32
|
+
codeName: string;
|
|
33
|
+
goPkgName?: string;
|
|
34
|
+
domain?: string | string[];
|
|
35
|
+
version?: string;
|
|
36
|
+
/** Skip full path/enum validations and run minimal checks only. Default: false */
|
|
37
|
+
minimal?: boolean;
|
|
38
|
+
/** Base output directory. Default: "./" */
|
|
39
|
+
outputPath?: string;
|
|
40
|
+
/** Treat outputPath as absolute (skip prepending "generated/<codeName>"). Default: false */
|
|
41
|
+
absolutePath?: boolean;
|
|
42
|
+
};
|
|
29
43
|
export {};
|
|
@@ -34,9 +34,10 @@ export class ConfigCompiler {
|
|
|
34
34
|
this.SchemaExtractionService.extractPossiblePaths(this.jsonSchemas);
|
|
35
35
|
const errors = this.buildData["x-errorcodes"];
|
|
36
36
|
this.errorDefinitions = errors.code;
|
|
37
|
+
this.domain = this.buildData.info?.domain;
|
|
38
|
+
this.version = this.buildData.info?.version;
|
|
37
39
|
};
|
|
38
40
|
this.performValidations = async (valConfig) => {
|
|
39
|
-
// try {
|
|
40
41
|
if (!this.buildData)
|
|
41
42
|
throw new Error("Build data not initialized");
|
|
42
43
|
if (!this.jsonSchemas)
|
|
@@ -46,22 +47,19 @@ export class ConfigCompiler {
|
|
|
46
47
|
if (!this.errorDefinitions)
|
|
47
48
|
throw new Error("Error definitions not initialized");
|
|
48
49
|
await new ConfigValidator("", valConfig, this.possibleJsonPaths, this.errorDefinitions).validate();
|
|
49
|
-
// } catch (e) {
|
|
50
|
-
// logger.error(e);
|
|
51
|
-
// throw new Error(e as any);
|
|
52
|
-
// }
|
|
53
50
|
};
|
|
54
51
|
this.withMinimalValidations = async (valConfig) => {
|
|
55
|
-
// try {
|
|
56
52
|
await new ConfigValidator("", valConfig, {}, [], {
|
|
57
53
|
minimal: true,
|
|
58
54
|
}).validate();
|
|
59
|
-
// } catch (e) {
|
|
60
|
-
// logger.error(e);
|
|
61
|
-
// throw new Error("validation failed");
|
|
62
55
|
};
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
this.generateCode = async (valConfig, codeGenConfig = "L1-Validations") => {
|
|
57
|
+
// Accept either the new CodeGenConfig object or the legacy positional
|
|
58
|
+
// string (codeName) so existing call-sites continue to work.
|
|
59
|
+
const config = typeof codeGenConfig === "string"
|
|
60
|
+
? { codeName: codeGenConfig }
|
|
61
|
+
: codeGenConfig;
|
|
62
|
+
const { codeName = "L1-Validations", goPkgName = "validationpkg", minimal = false, outputPath = "./", absolutePath = false, domain = this.domain, version = this.version, } = config;
|
|
65
63
|
try {
|
|
66
64
|
console.log("[ CODE GENERATION ] Starting code generation...");
|
|
67
65
|
valConfig = JSON.parse(JSON.stringify(valConfig));
|
|
@@ -82,35 +80,51 @@ export class ConfigCompiler {
|
|
|
82
80
|
case SupportedLanguages.Typescript:
|
|
83
81
|
await new TypescriptGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
84
82
|
codeName: codeName,
|
|
83
|
+
domain: domain,
|
|
84
|
+
version: version,
|
|
85
85
|
});
|
|
86
86
|
break;
|
|
87
87
|
case SupportedLanguages.Python:
|
|
88
88
|
await new PythonGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
89
89
|
codeName: codeName,
|
|
90
|
+
domain: domain,
|
|
91
|
+
version: version,
|
|
90
92
|
});
|
|
91
93
|
break;
|
|
92
94
|
case SupportedLanguages.Javascript:
|
|
93
95
|
await new JavascriptGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
94
96
|
codeName: codeName,
|
|
97
|
+
domain: domain,
|
|
98
|
+
version: version,
|
|
95
99
|
});
|
|
96
100
|
break;
|
|
97
101
|
case SupportedLanguages.Golang:
|
|
98
102
|
await new GoGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
99
103
|
codeName: codeName,
|
|
100
|
-
goPkgName:
|
|
104
|
+
goPkgName: goPkgName,
|
|
105
|
+
domain: domain,
|
|
106
|
+
version: version,
|
|
101
107
|
});
|
|
102
108
|
break;
|
|
103
109
|
case SupportedLanguages.Markdown:
|
|
104
|
-
await new MarkdownDocGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode(
|
|
110
|
+
await new MarkdownDocGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
111
|
+
codeName: codeName,
|
|
112
|
+
domain: domain,
|
|
113
|
+
version: version,
|
|
114
|
+
});
|
|
105
115
|
break;
|
|
106
116
|
case SupportedLanguages.RAG:
|
|
107
117
|
await new RagGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
108
118
|
codeName: codeName,
|
|
119
|
+
domain: domain,
|
|
120
|
+
version: version,
|
|
109
121
|
});
|
|
110
122
|
break;
|
|
111
123
|
case SupportedLanguages.RAG_TABLE:
|
|
112
124
|
await new RagTableGenerator(valConfig, this.errorDefinitions ?? [], targetPath).generateCode({
|
|
113
125
|
codeName: codeName,
|
|
126
|
+
domain: domain,
|
|
127
|
+
version: version,
|
|
114
128
|
});
|
|
115
129
|
break;
|
|
116
130
|
default:
|
|
@@ -156,19 +170,31 @@ export class ConfigCompiler {
|
|
|
156
170
|
this.generateValidPaths = async () => {
|
|
157
171
|
if (!this.possibleJsonPaths)
|
|
158
172
|
throw new Error("Possible paths not initialized");
|
|
159
|
-
// writeFileSync(
|
|
160
|
-
// "./validPaths.json",
|
|
161
|
-
// JSON.stringify(this.possibleJsonPaths, null, 2)
|
|
162
|
-
// );
|
|
163
173
|
return this.possibleJsonPaths;
|
|
164
174
|
};
|
|
165
|
-
this.generateValidationFromBuild = async (
|
|
175
|
+
this.generateValidationFromBuild = async (codeGenConfig, outputPath, absolutePath, goPackageName) => {
|
|
166
176
|
if (!this.buildData)
|
|
167
177
|
throw new Error("Build data not initialized");
|
|
168
178
|
const valConfig = this.buildData["x-validations"];
|
|
169
179
|
if (!valConfig)
|
|
170
180
|
throw new Error("No validation config found in build data");
|
|
171
|
-
|
|
181
|
+
// Support legacy positional call: (codeName, outputPath, absolutePath, goPkgName)
|
|
182
|
+
const config = typeof codeGenConfig === "string"
|
|
183
|
+
? {
|
|
184
|
+
codeName: codeGenConfig,
|
|
185
|
+
outputPath: outputPath ?? "./",
|
|
186
|
+
absolutePath: absolutePath ?? false,
|
|
187
|
+
goPkgName: goPackageName ?? "validationpkg",
|
|
188
|
+
domain: this.buildData.info?.domain,
|
|
189
|
+
version: this.buildData.info?.version,
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
...codeGenConfig,
|
|
193
|
+
domain: codeGenConfig.domain ?? this.buildData?.info?.domain,
|
|
194
|
+
version: codeGenConfig.version ??
|
|
195
|
+
this.buildData?.info?.version,
|
|
196
|
+
};
|
|
197
|
+
await this.generateCode(valConfig, config);
|
|
172
198
|
};
|
|
173
199
|
this.extractPayloadsFromBuild = async (outputPath) => {
|
|
174
200
|
if (!this.buildData)
|
|
@@ -3,6 +3,8 @@ import { ErrorDefinition } from "../../../types/error-codes";
|
|
|
3
3
|
export type CodeGeneratorProps = {
|
|
4
4
|
codeName: string;
|
|
5
5
|
goPkgName?: string;
|
|
6
|
+
domain?: string | string[];
|
|
7
|
+
version?: string;
|
|
6
8
|
};
|
|
7
9
|
export declare abstract class CodeGenerator {
|
|
8
10
|
validationConfig: ValidationConfig;
|
|
@@ -11,6 +11,7 @@ import { CodeGenerator, CodeGeneratorProps } from "../classes/abstract-generator
|
|
|
11
11
|
export declare class MarkdownDocGenerator extends CodeGenerator {
|
|
12
12
|
generateSessionDataCode(): Promise<void>;
|
|
13
13
|
generateUnitTestingCode(): Promise<void>;
|
|
14
|
+
codeConfig: CodeGeneratorProps | undefined;
|
|
14
15
|
generateValidationCode: () => Promise<void>;
|
|
15
|
-
generateCode: (
|
|
16
|
+
generateCode: (codeConfig: CodeGeneratorProps) => Promise<void>;
|
|
16
17
|
}
|
|
@@ -29,7 +29,7 @@ export class MarkdownDocGenerator extends CodeGenerator {
|
|
|
29
29
|
let finalMarkdown = "";
|
|
30
30
|
for (const action of Object.keys(testConfig)) {
|
|
31
31
|
const section = tableGen.buildActionMarkdown(action, action, // use action name as codeName heading inside the doc
|
|
32
|
-
testConfig[action]);
|
|
32
|
+
testConfig[action], this.codeConfig);
|
|
33
33
|
finalMarkdown += `\n\n${section}`;
|
|
34
34
|
}
|
|
35
35
|
finalMarkdown = finalMarkdown.trimStart();
|
|
@@ -41,7 +41,8 @@ export class MarkdownDocGenerator extends CodeGenerator {
|
|
|
41
41
|
}));
|
|
42
42
|
writeFileWithFsExtra(this.rootPath, "./page/style.css", cssData);
|
|
43
43
|
};
|
|
44
|
-
this.generateCode = async (
|
|
44
|
+
this.generateCode = async (codeConfig) => {
|
|
45
|
+
this.codeConfig = codeConfig; // store for use in generateValidationCode
|
|
45
46
|
await this.generateValidationCode();
|
|
46
47
|
};
|
|
47
48
|
}
|
|
@@ -42,7 +42,7 @@ export class GoGenerator extends CodeGenerator {
|
|
|
42
42
|
await writeAndFormatCode(this.rootPath, `./${this.codeConfig.goPkgName}/go.mod`, goModCode, "text");
|
|
43
43
|
await this.generateSessionDataCode();
|
|
44
44
|
await this.generateUnitTestingCode();
|
|
45
|
-
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode();
|
|
45
|
+
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode(codeConfig);
|
|
46
46
|
};
|
|
47
47
|
this.generateTestFunction = async (testObject) => {
|
|
48
48
|
const template = readFileSync(path.resolve(__dirname, "./templates/test-object.mustache"), "utf-8");
|
|
@@ -45,7 +45,7 @@ export class JavascriptGenerator extends CodeGenerator {
|
|
|
45
45
|
await this.generatePackageJson(codeConfig.codeName);
|
|
46
46
|
// Step 6: Generate documentation
|
|
47
47
|
logger.debug("Step 6: Generating documentation");
|
|
48
|
-
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode();
|
|
48
|
+
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode(codeConfig);
|
|
49
49
|
// Step 7: Clean up temporary files
|
|
50
50
|
logger.debug("Step 7: Cleaning up temporary files");
|
|
51
51
|
await this.cleanup();
|
|
@@ -107,7 +107,7 @@ export class PythonGenerator extends CodeGenerator {
|
|
|
107
107
|
await writeAndFormatCode(this.rootPath, "requirements.txt", requirements, "text");
|
|
108
108
|
await writeAndFormatCode(this.rootPath, "error.py", this.generateErrorFile(this.errorCodes), "python");
|
|
109
109
|
await writeAndFormatCode(this.rootPath, "__init__.py", this.generateIndexFile(apiNames, codeConfig.codeName), "python");
|
|
110
|
-
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode();
|
|
110
|
+
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode(codeConfig);
|
|
111
111
|
await this.generateSessionDataCode();
|
|
112
112
|
};
|
|
113
113
|
this.generateTestFunction = async (testObject) => {
|
|
@@ -26,7 +26,7 @@ export declare class RagTableGenerator extends CodeGenerator {
|
|
|
26
26
|
generateCode: (codeConfig: CodeGeneratorProps) => Promise<void>;
|
|
27
27
|
/** Collects rows and returns structured JSON for one action. */
|
|
28
28
|
private buildActionJson;
|
|
29
|
-
buildActionMarkdown(action: string, codeName: string, testArray: TestObject[]): string;
|
|
29
|
+
buildActionMarkdown(action: string, codeName: string, testArray: TestObject[], codeConfig: CodeGeneratorProps): string;
|
|
30
30
|
/**
|
|
31
31
|
* Walks the test tree depth-first.
|
|
32
32
|
*
|
|
@@ -33,7 +33,7 @@ export class RagTableGenerator extends CodeGenerator {
|
|
|
33
33
|
const rawJson = {};
|
|
34
34
|
for (const action of Object.keys(testConfig)) {
|
|
35
35
|
const testArray = testConfig[action];
|
|
36
|
-
const md = this.buildActionMarkdown(action, codeName, testArray);
|
|
36
|
+
const md = this.buildActionMarkdown(action, codeName, testArray, codeConfig);
|
|
37
37
|
writeFileWithFsExtra(this.rootPath, `./rag-table-docs/${action}.md`, md);
|
|
38
38
|
rawJson[action] = this.buildActionJson(action, codeName, testArray);
|
|
39
39
|
}
|
|
@@ -62,18 +62,23 @@ export class RagTableGenerator extends CodeGenerator {
|
|
|
62
62
|
rows: rows.map(({ index: _idx, ...rest }) => rest),
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
buildActionMarkdown(action, codeName, testArray) {
|
|
65
|
+
buildActionMarkdown(action, codeName, testArray, codeConfig) {
|
|
66
66
|
const rows = [];
|
|
67
67
|
this.collectRows(testArray, rows, "");
|
|
68
68
|
// Re-index after collection so numbering is clean
|
|
69
69
|
rows.forEach((r, i) => (r.index = i + 1));
|
|
70
70
|
const dateStr = new Date().toISOString().split("T")[0];
|
|
71
|
+
const domainText = Array.isArray(codeConfig.domain)
|
|
72
|
+
? codeConfig.domain.join(", ")
|
|
73
|
+
: (codeConfig.domain ?? "-");
|
|
71
74
|
const frontmatter = [
|
|
72
75
|
"---",
|
|
73
76
|
`action: ${action}`,
|
|
74
77
|
`codeName: ${codeName}`,
|
|
75
78
|
`numTests: ${rows.length}`,
|
|
76
79
|
`generated: ${dateStr}`,
|
|
80
|
+
`domain: ${domainText}`,
|
|
81
|
+
`version: ${codeConfig.version ?? "-"}`,
|
|
77
82
|
"---",
|
|
78
83
|
].join("\n");
|
|
79
84
|
const leafCount = rows.filter((r) => r.rowType === "leaf").length;
|
|
@@ -81,6 +86,7 @@ export class RagTableGenerator extends CodeGenerator {
|
|
|
81
86
|
`# ${codeName} — \`${action}\` Validations (Table View)`,
|
|
82
87
|
"",
|
|
83
88
|
`**${leafCount}** leaf validation rule(s) applied to \`${action}\` in the **${codeName}** flow.`,
|
|
89
|
+
`Domain: \`${domainText}\`, Version: \`${codeConfig.version ?? "-"}\``,
|
|
84
90
|
`Group rows (GRP) list their immediate sub-tests. Leaf rows (LF) show the actual validation logic.`,
|
|
85
91
|
"",
|
|
86
92
|
"---",
|
|
@@ -100,7 +100,7 @@ export class TypescriptGenerator extends CodeGenerator {
|
|
|
100
100
|
await this.generateValidationCode();
|
|
101
101
|
await writeAndFormatCode(this.rootPath, "error.ts", this.generateErrorFile(this.errorCodes), "typescript");
|
|
102
102
|
await writeAndFormatCode(this.rootPath, "index.ts", this.generateIndexFile(Object.keys(this.validationConfig[ConfigSyntax.Tests]), codeConfig.codeName), "typescript");
|
|
103
|
-
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode();
|
|
103
|
+
await new MarkdownDocGenerator(this.validationConfig, this.errorCodes, this.rootPath).generateCode(codeConfig);
|
|
104
104
|
await this.generateSessionDataCode();
|
|
105
105
|
};
|
|
106
106
|
this.generateTestFunction = async (testObject) => {
|
package/dist/index.test.js
CHANGED
|
@@ -14,15 +14,24 @@ const main = async () => {
|
|
|
14
14
|
await compiler.initialize(buildYaml);
|
|
15
15
|
const validPaths = await compiler.generateValidPaths();
|
|
16
16
|
writeFileSync(path.resolve(__dirname, "../alpha/possible-json-paths.json"), JSON.stringify(validPaths, null, 2), "utf-8");
|
|
17
|
-
await compiler.generateCode(valConfig,
|
|
17
|
+
await compiler.generateCode(valConfig, {
|
|
18
|
+
codeName: "L1_validations",
|
|
19
|
+
outputPath: "./alpha/python/",
|
|
20
|
+
});
|
|
18
21
|
const compilerTy = new ConfigCompiler(SupportedLanguages.Typescript);
|
|
19
22
|
await compilerTy.initialize(buildYaml);
|
|
20
|
-
await compilerTy.generateCode(valConfig,
|
|
23
|
+
await compilerTy.generateCode(valConfig, {
|
|
24
|
+
codeName: "L1_validations",
|
|
25
|
+
outputPath: "./alpha/typescript/",
|
|
26
|
+
});
|
|
21
27
|
await compilerTy.generateL0Schema("./alpha/typescript/L0_schema/");
|
|
22
28
|
await compilerTy.generateL0Schema("./alpha/json/", "json");
|
|
23
29
|
const compilerGo = new ConfigCompiler(SupportedLanguages.Golang);
|
|
24
30
|
await compilerGo.initialize(buildYaml);
|
|
25
|
-
await compilerGo.generateCode(valConfig,
|
|
31
|
+
await compilerGo.generateCode(valConfig, {
|
|
32
|
+
codeName: "L1_validations",
|
|
33
|
+
outputPath: "./alpha/golang/",
|
|
34
|
+
});
|
|
26
35
|
// JavaScript generation example
|
|
27
36
|
// const compilerJs = new ConfigCompiler(SupportedLanguages.Javascript);
|
|
28
37
|
// await compilerJs.initialize(buildYaml);
|
package/dist/types/build.d.ts
CHANGED