ondc-code-generator 0.5.2 → 0.5.3
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.
|
@@ -21,7 +21,7 @@ export declare class ConfigCompiler {
|
|
|
21
21
|
performValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
22
22
|
withMinimalValidations: (valConfig: ValidationConfig) => Promise<void>;
|
|
23
23
|
generateCode: (valConfig: ValidationConfig, codeName?: string, minimal?: boolean, outputPath?: string) => Promise<void>;
|
|
24
|
-
generateL0Schema: () => Promise<void>;
|
|
24
|
+
generateL0Schema: (outputPath?: string, type?: "json" | "typescript") => Promise<void>;
|
|
25
25
|
generateValidPaths: () => Promise<Record<string, string[]>>;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
@@ -84,13 +84,19 @@ export class ConfigCompiler {
|
|
|
84
84
|
throw new Error("Language not supported");
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
|
-
this.generateL0Schema = async () => {
|
|
87
|
+
this.generateL0Schema = async (outputPath = "./", type = "typescript") => {
|
|
88
88
|
if (!this.jsonSchemas) {
|
|
89
89
|
throw new Error("Schemas not initialized");
|
|
90
90
|
}
|
|
91
|
+
const targetPath = `${outputPath}generated/L0-schemas/`;
|
|
91
92
|
for (const schema in this.jsonSchemas) {
|
|
92
93
|
const json = this.jsonSchemas[schema];
|
|
93
|
-
|
|
94
|
+
if (type === "typescript") {
|
|
95
|
+
writeAndFormatCode(targetPath, `${schema}.ts`, `export const ${schema} = ${JSON.stringify(json, null, 2)}`, "typescript");
|
|
96
|
+
}
|
|
97
|
+
else if (type === "json") {
|
|
98
|
+
writeAndFormatCode(targetPath, `${schema}.json`, JSON.stringify(json, null, 2), "json");
|
|
99
|
+
}
|
|
94
100
|
}
|
|
95
101
|
const actions = Object.keys(this.jsonSchemas).map((schema) => {
|
|
96
102
|
return {
|