@zenstackhq/language 3.4.0-beta.1 → 3.4.0-beta.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/index.cjs +11 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.cjs
CHANGED
|
@@ -7773,11 +7773,7 @@ var ZModelCodeGenerator = class {
|
|
|
7773
7773
|
return `${this.quote}${trimmedVal}${this.quote}`;
|
|
7774
7774
|
}
|
|
7775
7775
|
_generateModel(ast) {
|
|
7776
|
-
return `${ast.imports.map((d) => this.generate(d)).join("\n")}${ast.imports.length > 0 ? "\n\n" : ""}${ast.declarations.
|
|
7777
|
-
if (a.$type === "Enum" && b.$type !== "Enum") return 1;
|
|
7778
|
-
if (a.$type !== "Enum" && b.$type === "Enum") return -1;
|
|
7779
|
-
return 0;
|
|
7780
|
-
}).map((d) => this.generate(d)).join("\n\n")}`;
|
|
7776
|
+
return `${ast.imports.map((d) => this.generate(d)).join("\n")}${ast.imports.length > 0 ? "\n\n" : ""}${ast.declarations.map((d) => this.generate(d)).join("\n\n")}`;
|
|
7781
7777
|
}
|
|
7782
7778
|
_generateDataSource(ast) {
|
|
7783
7779
|
return `datasource ${ast.name} {
|
|
@@ -7788,12 +7784,20 @@ ${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}
|
|
|
7788
7784
|
return `import ${this.quotedStr(ast.path)}`;
|
|
7789
7785
|
}
|
|
7790
7786
|
_generateEnum(ast) {
|
|
7791
|
-
|
|
7787
|
+
const comments = `${ast.comments.join("\n")}
|
|
7788
|
+
`;
|
|
7789
|
+
return `${ast.comments.length > 0 ? comments : ""}enum ${ast.name} {
|
|
7792
7790
|
${ast.fields.map((x) => this.indent + this.generate(x)).join("\n")}${ast.attributes.length > 0 ? "\n\n" + ast.attributes.map((x) => this.indent + this.generate(x)).join("\n") : ""}
|
|
7793
7791
|
}`;
|
|
7794
7792
|
}
|
|
7795
7793
|
_generateEnumField(ast) {
|
|
7796
|
-
|
|
7794
|
+
const fieldLine = `${ast.name}${ast.attributes.length > 0 ? " " + ast.attributes.map((x) => this.generate(x)).join(" ") : ""}`;
|
|
7795
|
+
if (ast.comments.length === 0) {
|
|
7796
|
+
return fieldLine;
|
|
7797
|
+
}
|
|
7798
|
+
const commentLines = ast.comments.map((c, i) => i === 0 ? c : this.indent + c);
|
|
7799
|
+
return `${commentLines.join("\n")}
|
|
7800
|
+
${this.indent}${fieldLine}`;
|
|
7797
7801
|
}
|
|
7798
7802
|
_generateGenerator(ast) {
|
|
7799
7803
|
return `generator ${ast.name} {
|