ondc-code-generator 0.1.3 → 0.1.4
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.
|
@@ -19,6 +19,6 @@ export declare class ConfigCompiler {
|
|
|
19
19
|
performValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
20
20
|
generateCode: (valConfig: ValidationConfig, codeName?: string) => Promise<void>;
|
|
21
21
|
generateL0Schema: () => Promise<void>;
|
|
22
|
-
generateValidPaths: () => Promise<
|
|
22
|
+
generateValidPaths: () => Promise<Record<string, string[]>>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -5,7 +5,7 @@ import { SupportedLanguages } from "../types/compiler-types.js";
|
|
|
5
5
|
import { TypescriptGenerator } from "./generators/typescript/ts-generator.js";
|
|
6
6
|
import { ConfigValidator } from "./validators/config-validator.js";
|
|
7
7
|
import { writeAndFormatCode } from "../utils/fs-utils.js";
|
|
8
|
-
import { readFileSync
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
9
|
import Mustache from "mustache";
|
|
10
10
|
import { fileURLToPath } from "url";
|
|
11
11
|
import path from "path";
|
|
@@ -77,7 +77,11 @@ export class ConfigCompiler {
|
|
|
77
77
|
this.generateValidPaths = async () => {
|
|
78
78
|
if (!this.possibleJsonPaths)
|
|
79
79
|
throw new Error("Possible paths not initialized");
|
|
80
|
-
writeFileSync(
|
|
80
|
+
// writeFileSync(
|
|
81
|
+
// "./validPaths.json",
|
|
82
|
+
// JSON.stringify(this.possibleJsonPaths, null, 2)
|
|
83
|
+
// );
|
|
84
|
+
return this.possibleJsonPaths;
|
|
81
85
|
};
|
|
82
86
|
this.language = language;
|
|
83
87
|
this.SchemaExtactionService = new SchemaExtactionService();
|
|
@@ -117,7 +117,6 @@ export class TypescriptGenerator extends CodeGenerator {
|
|
|
117
117
|
return variables;
|
|
118
118
|
}
|
|
119
119
|
generateErrorFile(errors) {
|
|
120
|
-
console.log(errors);
|
|
121
120
|
const allCodes = errors.map((error) => error.code);
|
|
122
121
|
if (allCodes.length !== new Set(allCodes).size) {
|
|
123
122
|
throw new Error("Duplicate error codes found");
|
|
@@ -98,7 +98,6 @@ export class VariableValidator extends TestObjectValidator {
|
|
|
98
98
|
}
|
|
99
99
|
this.validateKey(key);
|
|
100
100
|
const value = this.targetObject[key];
|
|
101
|
-
console.log(value);
|
|
102
101
|
if (!isValidVariableValueType(value)) {
|
|
103
102
|
throw new Error(`Variable: ${key} should be a string or array of primitives at path ${this.validationPath}`);
|
|
104
103
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,23 @@
|
|
|
1
1
|
import { ConfigCompiler } from "./generator/config-compiler.js";
|
|
2
2
|
export { ConfigCompiler };
|
|
3
|
+
// import { readFileSync } from "fs";
|
|
4
|
+
// import path from "path";
|
|
5
|
+
// import { fileURLToPath } from "url";
|
|
6
|
+
// const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
// const __dirname = path.dirname(__filename);
|
|
8
|
+
// import { SupportedLanguages } from "./types/compiler-types.js";
|
|
9
|
+
// const main = async () => {
|
|
10
|
+
// const compiler = new ConfigCompiler(SupportedLanguages.Typescript);
|
|
11
|
+
// const buildPath = path.resolve(__dirname, "../samples/build.yaml");
|
|
12
|
+
// const valConfigPath = path.resolve(
|
|
13
|
+
// __dirname,
|
|
14
|
+
// "../samples/validation-config.json"
|
|
15
|
+
// );
|
|
16
|
+
// const buildYaml = readFileSync(buildPath, "utf-8");
|
|
17
|
+
// const valConfig = JSON.parse(readFileSync(valConfigPath, "utf-8"));
|
|
18
|
+
// await compiler.initialize(buildYaml);
|
|
19
|
+
// await compiler.generateCode(valConfig);
|
|
20
|
+
// };
|
|
21
|
+
// (async () => {
|
|
22
|
+
// await main();
|
|
23
|
+
// })();
|