ondc-code-generator 0.5.1 → 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.
package/dist/constants/syntax.js
CHANGED
|
@@ -128,7 +128,6 @@ export const ReservedKeywords = new Set([
|
|
|
128
128
|
"hash",
|
|
129
129
|
"help",
|
|
130
130
|
"hex",
|
|
131
|
-
"id",
|
|
132
131
|
"input",
|
|
133
132
|
"int",
|
|
134
133
|
"isinstance",
|
|
@@ -148,7 +147,6 @@ export const ReservedKeywords = new Set([
|
|
|
148
147
|
"ord",
|
|
149
148
|
"pow",
|
|
150
149
|
"property",
|
|
151
|
-
"range",
|
|
152
150
|
"repr",
|
|
153
151
|
"reversed",
|
|
154
152
|
"round",
|
|
@@ -160,7 +158,6 @@ export const ReservedKeywords = new Set([
|
|
|
160
158
|
"str",
|
|
161
159
|
"sum",
|
|
162
160
|
"tuple",
|
|
163
|
-
"type",
|
|
164
161
|
"vars",
|
|
165
162
|
"zip",
|
|
166
163
|
// Python 3.x additional keywords
|
|
@@ -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 {
|