@@ -41,18 +41,27 @@ class Dart extends LanguageMeta {
4141 return type ;
4242 }
4343
44+ getCurrentDirectory ( ) {
45+ return process . cwd ( ) ;
46+ }
47+
4448 getTemplate ( ) {
4549 return `<% for (const attribute of collection.attributes) { -%>
4650<% if (attribute.type === 'relationship') { -%>
4751import '<%- attribute.relatedCollection.toLowerCase() %>.dart';
4852
4953<% } -%>
5054<% } -%>
55+ /**
56+ * This file is auto-generated by the Appwrite CLI.
57+ * You can regenerate it by running \`appwrite types -l dart ${ this . getCurrentDirectory ( ) } \`.
58+ */
59+
5160<% for (const attribute of collection.attributes) { -%>
5261<% if (attribute.format === 'enum') { -%>
5362enum <%- toPascalCase(attribute.key) %> {
54- <% for (const element of attribute.elements) { -%>
55- <%- toSnakeCase(element) %>,
63+ <% for (const [index, element] of Object.entries( attribute.elements) ) { -%>
64+ <%- toSnakeCase(element) %><% if (index < attribute.elements.length - 1) { %>,<% } %>
5665<% } -%>
5766}
5867
@@ -65,7 +74,7 @@ class <%= toPascalCase(collection.name) %> {
6574
6675 <%= toPascalCase(collection.name) %>({
6776 <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
68- <% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %>,
77+ <% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
6978 <% } -%>
7079});
7180
@@ -114,7 +123,7 @@ map['<%= attribute.key %>']<% if (!attribute.required) { %> ?? null<% } -%>
114123map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>']) : null<% } else { -%>
115124<%- toPascalCase(attribute.relatedCollection) %>.fromMap(map['<%= attribute.key %>'])<% } -%>
116125<% } -%>
117- <% } -%>,
126+ <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
118127<% } -%>
119128 );
120129 }
@@ -136,7 +145,7 @@ map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollecti
136145<% } -%>
137146<% } else { -%>
138147<%= toCamelCase(attribute.key) -%>
139- <% } -%>,
148+ <% } -%><% if (index < collection.attributes.length - 1) { %>,<% } %>
140149<% } -%>
141150 };
142151 }
0 commit comments