Skip to content

Commit 7eab876

Browse files
committed
Merge branch 'master' into PLA-2728
2 parents f83d589 + d1599fc commit 7eab876

File tree

7 files changed

+65
-59
lines changed

7 files changed

+65
-59
lines changed

templates/cli/lib/type-generation/languages/dart.js.twig

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,33 @@ import '<%- attribute.relatedCollection.toLowerCase() %>.dart';
5252
<% if (attribute.format === 'enum') { -%>
5353
enum <%- toPascalCase(attribute.key) %> {
5454
<% for (const element of attribute.elements) { -%>
55-
<%- element %>,
55+
<%- toSnakeCase(element) %>,
5656
<% } -%>
5757
}
5858

5959
<% } -%>
6060
<% } -%>
6161
class <%= toPascalCase(collection.name) %> {
6262
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
63-
<%- getType(attribute) %> <%- attribute.key %>;
63+
<%- getType(attribute) %> <%= toCamelCase(attribute.key) %>;
6464
<% } -%>
6565

6666
<%= toPascalCase(collection.name) %>({
6767
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
68-
<% if (attribute.required) { %>required <% } %>this.<%- attribute.key %>,
68+
<% if (attribute.required) { %>required <% } %>this.<%= toCamelCase(attribute.key) %>,
6969
<% } -%>
7070
});
7171

7272
factory <%= toPascalCase(collection.name) %>.fromMap(Map<String, dynamic> map) {
7373
return <%= toPascalCase(collection.name) %>(
7474
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
75-
<%- attribute.key %>: <% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') { -%>
75+
<%= toCamelCase(attribute.key) %>: <% if (attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') { -%>
7676
<% if (attribute.format === 'enum') { -%>
7777
<% if (attribute.array) { -%>
7878
(map['<%= attribute.key %>'] as List<dynamic>?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% if (!attribute.required) { %> ?? []<% } -%>
7979
<% } else { -%>
8080
<% if (!attribute.required) { -%>
81-
map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull : null<% } else { -%>
81+
map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull() : null<% } else { -%>
8282
<%- toPascalCase(attribute.key) %>.values.firstWhere((e) => e.name == map['<%= attribute.key %>'])<% } -%>
8383
<% } -%>
8484
<% } else { -%>
@@ -124,18 +124,18 @@ map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.relatedCollecti
124124
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
125125
"<%= attribute.key %>": <% if (attribute.type === 'relationship') { -%>
126126
<% if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') { -%>
127-
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()<% if (!attribute.required) { %> ?? []<% } -%>
127+
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.map((e) => e.toMap()).toList()<% if (!attribute.required) { %> ?? []<% } -%>
128128
<% } else { -%>
129-
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.toMap()<% if (!attribute.required) { %> ?? {}<% } -%>
129+
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.toMap()<% if (!attribute.required) { %> ?? {}<% } -%>
130130
<% } -%>
131131
<% } else if (attribute.format === 'enum') { -%>
132132
<% if (attribute.array) { -%>
133-
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% if (!attribute.required) { %> ?? []<% } -%>
133+
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.map((e) => e.name).toList()<% if (!attribute.required) { %> ?? []<% } -%>
134134
<% } else { -%>
135-
<%- attribute.key %><% if (!attribute.required) { %>?<% } %>.name<% if (!attribute.required) { %> ?? null<% } -%>
135+
<%= toCamelCase(attribute.key) %><% if (!attribute.required) { %>?<% } %>.name<% if (!attribute.required) { %> ?? null<% } -%>
136136
<% } -%>
137137
<% } else { -%>
138-
<%- attribute.key -%>
138+
<%= toCamelCase(attribute.key) -%>
139139
<% } -%>,
140140
<% } -%>
141141
};

templates/cli/lib/type-generation/languages/java.js.twig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Java extends LanguageMeta {
4444
import java.util.*;
4545
<% for (const attribute of collection.attributes) { -%>
4646
<% if (attribute.type === 'relationship') { -%>
47-
import <%- toPascalCase(attribute.relatedCollection) %>;
47+
import io.appwrite.models.<%- toPascalCase(attribute.relatedCollection) %>;
4848

4949
<% } -%>
5050
<% } -%>
@@ -54,36 +54,36 @@ public class <%- toPascalCase(collection.name) %> {
5454

5555
public enum <%- toPascalCase(attribute.key) %> {
5656
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
57-
<%- element %><%- index < attribute.elements.length - 1 ? ',' : ';' %>
57+
<%- toSnakeCase(element) %><%- index < attribute.elements.length - 1 ? ',' : ';' %>
5858
<% } -%>
5959
}
6060

6161
<% } -%>
6262
<% } -%>
6363
<% for (const attribute of collection.attributes) { -%>
64-
private <%- getType(attribute) %> <%- attribute.key %>;
64+
private <%- getType(attribute) %> <%- toCamelCase(attribute.key) %>;
6565
<% } -%>
6666

6767
public <%- toPascalCase(collection.name) %>() {
6868
}
6969

7070
public <%- toPascalCase(collection.name) %>(
7171
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
72-
<%- getType(attribute) %> <%- attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %>
72+
<%- getType(attribute) %> <%= toCamelCase(attribute.key) %><%- index < collection.attributes.length - 1 ? ',' : '' %>
7373
<% } -%>
7474
) {
7575
<% for (const attribute of collection.attributes) { -%>
76-
this.<%- attribute.key %> = <%- attribute.key %>;
76+
this.<%= toCamelCase(attribute.key) %> = <%= toCamelCase(attribute.key) %>;
7777
<% } -%>
7878
}
7979

8080
<% for (const attribute of collection.attributes) { -%>
8181
public <%- getType(attribute) %> get<%- toPascalCase(attribute.key) %>() {
82-
return <%- attribute.key %>;
82+
return <%= toCamelCase(attribute.key) %>;
8383
}
8484

85-
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> <%- attribute.key %>) {
86-
this.<%- attribute.key %> = <%- attribute.key %>;
85+
public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> <%= toCamelCase(attribute.key) %>) {
86+
this.<%= toCamelCase(attribute.key) %> = <%= toCamelCase(attribute.key) %>;
8787
}
8888

8989
<% } -%>
@@ -92,20 +92,20 @@ public class <%- toPascalCase(collection.name) %> {
9292
if (this == obj) return true;
9393
if (obj == null || getClass() != obj.getClass()) return false;
9494
<%- toPascalCase(collection.name) %> that = (<%- toPascalCase(collection.name) %>) obj;
95-
return <% collection.attributes.forEach((attr, index) => { %>Objects.equals(<%- attr.key %>, that.<%- attr.key %>)<% if (index < collection.attributes.length - 1) { %> &&
95+
return <% collection.attributes.forEach((attr, index) => { %>Objects.equals(<%= toCamelCase(attr.key) %>, that.<%= toCamelCase(attr.key) %>)<% if (index < collection.attributes.length - 1) { %> &&
9696
<% } }); %>;
9797
}
9898

9999
@Override
100100
public int hashCode() {
101-
return Objects.hash(<%- collection.attributes.map(attr => attr.key).join(', ') %>);
101+
return Objects.hash(<%= collection.attributes.map(attr => toCamelCase(attr.key)).join(', ') %>);
102102
}
103103

104104
@Override
105105
public String toString() {
106106
return "<%- toPascalCase(collection.name) %>{" +
107107
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
108-
"<%- attribute.key %>=" + <%- attribute.key %> +
108+
"<%= toCamelCase(attribute.key) %>=" + <%= toCamelCase(attribute.key) %> +
109109
<% } -%>
110110
'}';
111111
}

templates/cli/lib/type-generation/languages/javascript.js.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class JavaScript extends LanguageMeta {
6969
/**
7070
* @typedef {Object} <%- toPascalCase(collection.name) %>
7171
<% for (const attribute of collection.attributes) { -%>
72-
* @property {<%- getType(attribute) %>} <%- attribute.key %>
72+
* @property {<%- getType(attribute) %>} <%- toCamelCase(attribute.key) %>
7373
<% } -%>
7474
*/
7575

templates/cli/lib/type-generation/languages/kotlin.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ import <%- toPascalCase(attribute.relatedCollection) %>
5454
<% if (attribute.format === 'enum') { -%>
5555
enum class <%- toPascalCase(attribute.key) %> {
5656
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
57-
<%- element %><%- index < attribute.elements.length - 1 ? ',' : '' %>
57+
<%- toUpperSnakeCase(element) %><%- index < attribute.elements.length - 1 ? ',' : '' %>
5858
<% } -%>
5959
}
6060

6161
<% } -%>
6262
<% } -%>
6363
data class <%- toPascalCase(collection.name) %>(
6464
<% for (const attribute of collection.attributes) { -%>
65-
val <%- attribute.key %>: <%- getType(attribute) %>,
65+
val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>,
6666
<% } -%>
6767
)`;
6868
}

templates/cli/lib/type-generation/languages/php.js.twig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,40 @@ use Appwrite\\Models\\<%- toPascalCase(attribute.relatedCollection) %>;
5353
<% } -%>
5454
<% for (const attribute of collection.attributes) { -%>
5555
<% if (attribute.format === 'enum') { -%>
56-
enum <%- toPascalCase(attribute.key) %> {
56+
enum <%- toPascalCase(attribute.key) %>: string {
5757
<% for (const [index, element] of Object.entries(attribute.elements)) { -%>
58-
case <%- element.toUpperCase() %> = '<%- element %>';
58+
case <%- toUpperSnakeCase(element) %> = '<%- element %>';
5959
<% } -%>
6060
}
6161
6262
<% } -%>
6363
<% } -%>
6464
class <%- toPascalCase(collection.name) %> {
6565
<% for (const attribute of collection.attributes ){ -%>
66-
private <%- getType(attribute) %> $<%- attribute.key %>;
66+
private <%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>;
6767
<% } -%>
6868
6969
public function __construct(
7070
<% for (const attribute of collection.attributes ){ -%>
7171
<% if (attribute.required) { -%>
72-
<%- getType(attribute).replace('|null', '') %> $<%- attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
72+
<%- getType(attribute).replace('|null', '') %> $<%- toCamelCase(attribute.key) %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
7373
<% } else { -%>
74-
?<%- getType(attribute).replace('|null', '') %> $<%- attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
74+
?<%- getType(attribute).replace('|null', '') %> $<%- toCamelCase(attribute.key) %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %>
7575
<% } -%>
7676
<% } -%>
7777
) {
7878
<% for (const attribute of collection.attributes ){ -%>
79-
$this-><%- attribute.key %> = $<%- attribute.key %>;
79+
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
8080
<% } -%>
8181
}
8282
8383
<% for (const attribute of collection.attributes ){ -%>
8484
public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute) %> {
85-
return $this-><%- attribute.key %>;
85+
return $this-><%- toCamelCase(attribute.key) %>;
8686
}
8787
88-
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- attribute.key %>): void {
89-
$this-><%- attribute.key %> = $<%- attribute.key %>;
88+
public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute) %> $<%- toCamelCase(attribute.key) %>): void {
89+
$this-><%- toCamelCase(attribute.key) %> = $<%- toCamelCase(attribute.key) %>;
9090
}
9191
<% } -%>
9292
}`;

0 commit comments

Comments
 (0)