Skip to content

Commit 65150b3

Browse files
committed
chore: regenerate sdk
1 parent 25a7969 commit 65150b3

File tree

9 files changed

+70
-19
lines changed

9 files changed

+70
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
* Add Type generation fixes:
2626
* Properly handle enum attributes in dart, java and kotlin
27-
* Fix initialisation of null attributes in dart's fromMap method
27+
* Fix initialisation of null attributes in dart's fromMap method
2828
* Fix relationships and enums in swift
2929

3030
## 8.0.1

lib/type-generation/languages/dart.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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') { -%>
4751
import '<%- 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') { -%>
5362
enum <%- 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<% } -%>
114123
map['<%= 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
}

lib/type-generation/languages/java.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,18 @@ class Java extends LanguageMeta {
3838
return type;
3939
}
4040

41+
getCurrentDirectory() {
42+
return process.cwd();
43+
}
44+
4145
getTemplate() {
4246
return `package io.appwrite.models;
4347
48+
/**
49+
* This file is auto-generated by the Appwrite CLI.
50+
* You can regenerate it by running \`appwrite types -l java ${this.getCurrentDirectory()}\`.
51+
*/
52+
4453
import java.util.*;
4554
<% for (const attribute of collection.attributes) { -%>
4655
<% if (attribute.type === 'relationship') { -%>

lib/type-generation/languages/javascript.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class JavaScript extends LanguageMeta {
4040
if (attribute.array) {
4141
type += "[]";
4242
}
43-
if (!attribute.required) {
44-
type += "|null|undefined";
43+
if (!attribute.required && attribute.default === null) {
44+
type += "|null";
4545
}
4646
return type;
4747
}
@@ -60,19 +60,26 @@ class JavaScript extends LanguageMeta {
6060
return "appwrite";
6161
}
6262

63+
getCurrentDirectory() {
64+
return process.cwd();
65+
}
66+
6367
getTemplate() {
6468
return `/**
6569
* @typedef {import('${this._getAppwriteDependency()}').Models.Document} Document
6670
*/
6771
72+
/**
73+
* This file is auto-generated by the Appwrite CLI.
74+
* You can regenerate it by running \`appwrite types -l js ${this.getCurrentDirectory()}\`.
75+
*/
6876
<% for (const collection of collections) { %>
6977
/**
7078
* @typedef {Object} <%- toPascalCase(collection.name) %>
7179
<% for (const attribute of collection.attributes) { -%>
7280
* @property {<%- getType(attribute) %>} <%- toCamelCase(attribute.key) %>
7381
<% } -%>
7482
*/
75-
7683
<% } %>`;
7784
}
7885

lib/type-generation/languages/kotlin.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ class Kotlin extends LanguageMeta {
3535
if (attribute.array) {
3636
type = "List<" + type + ">";
3737
}
38-
if (!attribute.required) {
38+
if (!attribute.required && attribute.default === null) {
3939
type += "?";
4040
}
4141
return type;
4242
}
4343

44+
getCurrentDirectory() {
45+
return process.cwd();
46+
}
47+
4448
getTemplate() {
4549
return `package io.appwrite.models
4650
@@ -50,6 +54,11 @@ import <%- toPascalCase(attribute.relatedCollection) %>
5054
5155
<% } -%>
5256
<% } -%>
57+
/**
58+
* This file is auto-generated by the Appwrite CLI.
59+
* You can regenerate it by running \`appwrite types -l kotlin ${this.getCurrentDirectory()}\`.
60+
*/
61+
5362
<% for (const attribute of collection.attributes) { -%>
5463
<% if (attribute.format === 'enum') { -%>
5564
enum class <%- toPascalCase(attribute.key) %> {
@@ -61,8 +70,8 @@ enum class <%- toPascalCase(attribute.key) %> {
6170
<% } -%>
6271
<% } -%>
6372
data class <%- toPascalCase(collection.name) %>(
64-
<% for (const attribute of collection.attributes) { -%>
65-
val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %>,
73+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
74+
val <%- toCamelCase(attribute.key) %>: <%- getType(attribute) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
6675
<% } -%>
6776
)`;
6877
}

lib/type-generation/languages/php.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,25 @@ class PHP extends LanguageMeta {
3535
default:
3636
throw new Error(`Unknown attribute type: ${attribute.type}`);
3737
}
38-
if (!attribute.required) {
38+
if (!attribute.required && attribute.default === null) {
3939
type += "|null";
4040
}
4141
return type;
4242
}
4343

44+
getCurrentDirectory() {
45+
return process.cwd();
46+
}
47+
4448
getTemplate() {
4549
return `<?php
4650
namespace Appwrite\\Models;
4751
52+
/**
53+
* This file is auto-generated by the Appwrite CLI.
54+
* You can regenerate it by running \`appwrite types -l php ${this.getCurrentDirectory()}\`.
55+
*/
56+
4857
<% for (const attribute of collection.attributes) { -%>
4958
<% if (attribute.type === 'relationship' && !(attribute.relationType === 'manyToMany') && !(attribute.relationType === 'oneToMany' && attribute.side === 'parent')) { -%>
5059
use Appwrite\\Models\\<%- toPascalCase(attribute.relatedCollection) %>;

lib/type-generation/languages/swift.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,22 @@ class Swift extends LanguageMeta {
3535
if (attribute.array) {
3636
type = "[" + type + "]";
3737
}
38-
if (!attribute.required) {
38+
if (!attribute.required && attribute.default === null) {
3939
type += "?";
4040
}
4141
return type;
4242
}
4343

44+
getCurrentDirectory() {
45+
return process.cwd();
46+
}
47+
4448
getTemplate() {
4549
return `import Foundation
4650
51+
/// This file is auto-generated by the Appwrite CLI.
52+
/// You can regenerate it by running \`appwrite types -l swift ${this.getCurrentDirectory()}\`.
53+
4754
<% for (const attribute of collection.attributes) { -%>
4855
<% if (attribute.format === 'enum') { -%>
4956
public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable {

lib/type-generation/languages/typescript.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ class TypeScript extends LanguageMeta {
7171
getTemplate() {
7272
return `import { type Models } from '${this._getAppwriteDependency()}';
7373
74-
// This file is auto-generated by the Appwrite CLI.
75-
// You can regenerate it by running \`appwrite types -l ts ${this.getCurrentDirectory()}\`.
74+
/**
75+
* This file is auto-generated by the Appwrite CLI.
76+
* You can regenerate it by running \`appwrite types -l ts ${this.getCurrentDirectory()}\`.
77+
*/
7678
7779
<% for (const collection of collections) { -%>
7880
<% for (const attribute of collection.attributes) { -%>

lib/utils.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const fs = require("fs");
22
const path = require("path");
33
const net = require("net");
44
const childProcess = require('child_process');
5+
const chalk = require('chalk');
56
const { localConfig, globalConfig } = require("./config");
6-
const { success } = require('./parser')
77

88
function getAllFiles(folder) {
99
const files = [];
@@ -105,8 +105,7 @@ function showConsoleLink(serviceName, action, ...ids) {
105105
return;
106106
}
107107

108-
109-
success(url);
108+
console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(url)}`);
110109
}
111110

112111
function getAccountPath(action) {

0 commit comments

Comments
 (0)