diff --git a/CHANGELOG.md b/CHANGELOG.md index ac162440..8e504417 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 11.1.1 + +* Fix duplicate `enums` during type generation by prefixing them with table name. For example, `enum MyEnum` will now be generated as `enum MyTableMyEnum` to avoid conflicts. + ## 11.1.0 * Add `total` parameter to list queries allowing skipping counting rows in a table for improved performance diff --git a/README.md b/README.md index c9251bad..5b384794 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using ```sh $ appwrite -v -11.1.0 +11.1.1 ``` ### Install using prebuilt binaries @@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc Once the installation completes, you can verify your install using ``` $ appwrite -v -11.1.0 +11.1.1 ``` ## Getting Started diff --git a/install.ps1 b/install.ps1 index 18f161bc..40c30c41 100644 --- a/install.ps1 +++ b/install.ps1 @@ -13,8 +13,8 @@ # You can use "View source" of this page to see the full script. # REPO -$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.0/appwrite-cli-win-x64.exe" -$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.0/appwrite-cli-win-arm64.exe" +$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.1/appwrite-cli-win-x64.exe" +$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.1/appwrite-cli-win-arm64.exe" $APPWRITE_BINARY_NAME = "appwrite.exe" diff --git a/install.sh b/install.sh index 11f3e43d..714616bb 100644 --- a/install.sh +++ b/install.sh @@ -97,7 +97,7 @@ printSuccess() { downloadBinary() { echo "[2/4] Downloading executable for $OS ($ARCH) ..." - GITHUB_LATEST_VERSION="11.1.0" + GITHUB_LATEST_VERSION="11.1.1" GITHUB_FILE="appwrite-cli-${OS}-${ARCH}" GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE" diff --git a/lib/client.js b/lib/client.js index 73a9ccb1..78cd5c6b 100644 --- a/lib/client.js +++ b/lib/client.js @@ -16,8 +16,8 @@ class Client { 'x-sdk-name': 'Command Line', 'x-sdk-platform': 'console', 'x-sdk-language': 'cli', - 'x-sdk-version': '11.1.0', - 'user-agent' : `AppwriteCLI/11.1.0 (${os.type()} ${os.version()}; ${os.arch()})`, + 'x-sdk-version': '11.1.1', + 'user-agent' : `AppwriteCLI/11.1.1 (${os.type()} ${os.version()}; ${os.arch()})`, 'X-Appwrite-Response-Format' : '1.8.0', }; } diff --git a/lib/commands/sites.js b/lib/commands/sites.js index 464e44a6..1f81d3e0 100644 --- a/lib/commands/sites.js +++ b/lib/commands/sites.js @@ -1478,7 +1478,7 @@ sites sites .command(`create-deployment`) - .description(`Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the function's deployment to use your new deployment ID.`) + .description(`Create a new site code deployment. Use this endpoint to upload a new version of your site code. To activate your newly uploaded code, you'll need to update the site's deployment to use your new deployment ID.`) .requiredOption(`--site-id `, `Site ID.`) .requiredOption(`--code `, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`) .requiredOption(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value)) diff --git a/lib/parser.js b/lib/parser.js index 86ecece1..89ee454c 100644 --- a/lib/parser.js +++ b/lib/parser.js @@ -122,7 +122,7 @@ const parseError = (err) => { } catch { } - const version = '11.1.0'; + const version = '11.1.1'; const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``; const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`; diff --git a/lib/type-generation/languages/csharp.js b/lib/type-generation/languages/csharp.js index 1df7c7cd..3914d159 100644 --- a/lib/type-generation/languages/csharp.js +++ b/lib/type-generation/languages/csharp.js @@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class CSharp extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = ""; switch (attribute.type) { case AttributeType.STRING: @@ -11,7 +11,7 @@ class CSharp extends LanguageMeta { case AttributeType.DATETIME: type = "string"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -60,7 +60,7 @@ namespace Appwrite.Models <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> -public enum <%- toPascalCase(attribute.key) %> { +public enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> { <% for (const [index, element] of Object.entries(attribute.elements) ) { -%> [JsonPropertyName("<%- element %>")] <%- toPascalCase(element) %><% if (index < attribute.elements.length - 1) { %>,<% } %> @@ -72,13 +72,13 @@ public class <%= toPascalCase(collection.name) %> { <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> [JsonPropertyName("<%- attribute.key %>")] - public <%- getType(attribute, collections) %> <%= toPascalCase(attribute.key) %> { get; private set; } + public <%- getType(attribute, collections, collection.name) %> <%= toPascalCase(attribute.key) %> { get; private set; } <% } -%> public <%= toPascalCase(collection.name) %>( <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> - <%- getType(attribute, collections) %> <%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1) { %>,<% } %> + <%- getType(attribute, collections, collection.name) %> <%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1) { %>,<% } %> <% } -%> ) { @@ -93,9 +93,9 @@ public class <%= toPascalCase(collection.name) %> // ENUM if (attribute.format === 'enum') { if (attribute.array) { - -%>((IEnumerable)map["<%- attribute.key %>"]).Select(e => Enum.Parse>(e.ToString()!, true)).ToList()<% + -%>((IEnumerable)map["<%- attribute.key %>"]).Select(e => Enum.Parse<%- toPascalCase(attribute.key) %>>(e.ToString()!, true)).ToList()<% } else { - -%>Enum.Parse>(map["<%- attribute.key %>"].ToString()!, true)<% + -%>Enum.Parse<%- toPascalCase(attribute.key) %>>(map["<%- attribute.key %>"].ToString()!, true)<% } // RELATIONSHIP } else if (attribute.type === 'relationship') { @@ -122,7 +122,7 @@ public class <%= toPascalCase(collection.name) %> } else if (attribute.type === 'double') { -%><%- !attribute.required ? 'map["' + attribute.key + '"] == null ? null : ' : '' %>Convert.ToDouble(map["<%- attribute.key %>"])<% } else if (attribute.type === 'boolean') { - -%>(<%- getType(attribute, collections) %>)map["<%- attribute.key %>"]<% + -%>(<%- getType(attribute, collections, collection.name) %>)map["<%- attribute.key %>"]<% } else if (attribute.type === 'string' || attribute.type === 'datetime' || attribute.type === 'email') { -%>map["<%- attribute.key %>"]<%- !attribute.required ? '?' : '' %>.ToString()<%- attribute.required ? '!' : ''%><% } else { diff --git a/lib/type-generation/languages/dart.js b/lib/type-generation/languages/dart.js index 73ea972a..d44efb93 100644 --- a/lib/type-generation/languages/dart.js +++ b/lib/type-generation/languages/dart.js @@ -40,7 +40,7 @@ class Dart extends LanguageMeta { return 'appwrite'; } - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = ""; switch (attribute.type) { case AttributeType.STRING: @@ -48,7 +48,7 @@ class Dart extends LanguageMeta { case AttributeType.DATETIME: type = "String"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -103,7 +103,7 @@ import '<%- toSnakeCase(related.name) %>.dart'; <% for (const attribute of __attrs) { -%> <% if (attribute.format === '${AttributeType.ENUM}') { -%> -enum <%- toPascalCase(attribute.key) %> { +enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> { <% for (const [index, element] of Object.entries(attribute.elements)) { -%> <%- strict ? toCamelCase(element) : element %><% if (index < attribute.elements.length - 1) { -%>,<% } %> <% } -%> @@ -113,7 +113,7 @@ enum <%- toPascalCase(attribute.key) %> { <% } -%> class <%= toPascalCase(collection.name) %> { <% for (const [index, attribute] of Object.entries(__attrs)) { -%> - <%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>; + <%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>; <% } -%> <%= toPascalCase(collection.name) %>({ @@ -128,10 +128,10 @@ class <%= toPascalCase(collection.name) %> { <%= strict ? toCamelCase(attribute.key) : attribute.key %>: <% if (attribute.type === '${AttributeType.STRING}' || attribute.type === '${AttributeType.EMAIL}' || attribute.type === '${AttributeType.DATETIME}') { -%> <% if (attribute.format === '${AttributeType.ENUM}') { -%> <% if (attribute.array) { -%> -(map['<%= attribute.key %>'] as List?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% } else { -%> +(map['<%= attribute.key %>'] as List?)?.map((e) => <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% } else { -%> <% if (!attribute.required) { -%> -map['<%= attribute.key %>'] != null ? <%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull : null<% } else { -%> -<%- toPascalCase(attribute.key) %>.values.firstWhere((e) => e.name == map['<%= attribute.key %>'])<% } -%> +map['<%= attribute.key %>'] != null ? <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.where((e) => e.name == map['<%= attribute.key %>']).firstOrNull : null<% } else { -%> +<%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>.values.firstWhere((e) => e.name == map['<%= attribute.key %>'])<% } -%> <% } -%> <% } else { -%> <% if (attribute.array) { -%> diff --git a/lib/type-generation/languages/java.js b/lib/type-generation/languages/java.js index 9ab86a82..dfcf5e20 100644 --- a/lib/type-generation/languages/java.js +++ b/lib/type-generation/languages/java.js @@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class Java extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = ""; switch (attribute.type) { case AttributeType.STRING: @@ -11,7 +11,7 @@ class Java extends LanguageMeta { case AttributeType.DATETIME: type = "String"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -61,7 +61,7 @@ public class <%- toPascalCase(collection.name) %> { <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> - public enum <%- toPascalCase(attribute.key) %> { + public enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> { <% for (const [index, element] of Object.entries(attribute.elements)) { -%> <%- strict ? toUpperSnakeCase(element) : element %><%- index < attribute.elements.length - 1 ? ',' : ';' %> <% } -%> @@ -70,7 +70,7 @@ public class <%- toPascalCase(collection.name) %> { <% } -%> <% } -%> <% for (const attribute of collection.attributes) { -%> - private <%- getType(attribute, collections) %> <%- strict ? toCamelCase(attribute.key) : attribute.key %>; + private <%- getType(attribute, collections, collection.name) %> <%- strict ? toCamelCase(attribute.key) : attribute.key %>; <% } -%> public <%- toPascalCase(collection.name) %>() { @@ -78,7 +78,7 @@ public class <%- toPascalCase(collection.name) %> { public <%- toPascalCase(collection.name) %>( <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> - <%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %> + <%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %><%- index < collection.attributes.length - 1 ? ',' : '' %> <% } -%> ) { <% for (const attribute of collection.attributes) { -%> @@ -87,11 +87,11 @@ public class <%- toPascalCase(collection.name) %> { } <% for (const attribute of collection.attributes) { -%> - public <%- getType(attribute, collections) %> get<%- toPascalCase(attribute.key) %>() { + public <%- getType(attribute, collections, collection.name) %> get<%- toPascalCase(attribute.key) %>() { return <%= strict ? toCamelCase(attribute.key) : attribute.key %>; } - public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>) { + public void set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections, collection.name) %> <%= strict ? toCamelCase(attribute.key) : attribute.key %>) { this.<%= strict ? toCamelCase(attribute.key) : attribute.key %> = <%= strict ? toCamelCase(attribute.key) : attribute.key %>; } diff --git a/lib/type-generation/languages/kotlin.js b/lib/type-generation/languages/kotlin.js index 2c377174..09df341a 100644 --- a/lib/type-generation/languages/kotlin.js +++ b/lib/type-generation/languages/kotlin.js @@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class Kotlin extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = ""; switch (attribute.type) { case AttributeType.STRING: @@ -11,7 +11,7 @@ class Kotlin extends LanguageMeta { case AttributeType.DATETIME: type = "String"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -61,7 +61,7 @@ import <%- toPascalCase(collections.find(c => c.$id === attribute.relatedCollect <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> -enum class <%- toPascalCase(attribute.key) %> { +enum class <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> { <% for (const [index, element] of Object.entries(attribute.elements)) { -%> <%- strict ? toUpperSnakeCase(element) : element %><%- index < attribute.elements.length - 1 ? ',' : '' %> <% } -%> @@ -71,7 +71,7 @@ enum class <%- toPascalCase(attribute.key) %> { <% } -%> data class <%- toPascalCase(collection.name) %>( <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> - val <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %><% if (index < collection.attributes.length - 1) { %>,<% } %> + val <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections, collection.name) %><% if (index < collection.attributes.length - 1) { %>,<% } %> <% } -%> ) `; diff --git a/lib/type-generation/languages/php.js b/lib/type-generation/languages/php.js index 942b585e..713ed200 100644 --- a/lib/type-generation/languages/php.js +++ b/lib/type-generation/languages/php.js @@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class PHP extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { if (attribute.array) { return "array"; } @@ -14,7 +14,7 @@ class PHP extends LanguageMeta { case AttributeType.DATETIME: type = "string"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -60,9 +60,9 @@ use Appwrite\\Models\\<%- toPascalCase(collections.find(c => c.$id === attribute <% } -%> <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> -enum <%- toPascalCase(attribute.key) %>: string { +enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>: string { <% for (const [index, element] of Object.entries(attribute.elements)) { -%> - case <%- strict ? toUpperSnakeCase(element) : element %> = '<%- element %>'; + case <%- toUpperSnakeCase(element) %> = '<%- element %>'; <% } -%> } @@ -70,15 +70,15 @@ enum <%- toPascalCase(attribute.key) %>: string { <% } -%> class <%- toPascalCase(collection.name) %> { <% for (const attribute of collection.attributes ){ -%> - private <%- getType(attribute, collections) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>; + private <%- getType(attribute, collections, collection.name) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>; <% } -%> public function __construct( <% for (const attribute of collection.attributes ){ -%> <% if (attribute.required) { -%> - <%- getType(attribute, collections).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %> + <%- getType(attribute, collections, collection.name).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %><% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %> <% } else { -%> - ?<%- getType(attribute, collections).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %> + ?<%- getType(attribute, collections, collection.name).replace('|null', '') %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %> = null<% if (collection.attributes.indexOf(attribute) < collection.attributes.length - 1) { %>,<% } %> <% } -%> <% } -%> ) { @@ -88,11 +88,11 @@ class <%- toPascalCase(collection.name) %> { } <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> - public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute, collections) %> { + public function get<%- toPascalCase(attribute.key) %>(): <%- getType(attribute, collections, collection.name) %> { return $this-><%- strict ? toCamelCase(attribute.key) : attribute.key %>; } - public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>): void { + public function set<%- toPascalCase(attribute.key) %>(<%- getType(attribute, collections, collection.name) %> $<%- strict ? toCamelCase(attribute.key) : attribute.key %>): void { $this-><%- strict ? toCamelCase(attribute.key) : attribute.key %> = $<%- strict ? toCamelCase(attribute.key) : attribute.key %>; } <% if (index < collection.attributes.length - 1) { %> diff --git a/lib/type-generation/languages/swift.js b/lib/type-generation/languages/swift.js index 4322404e..87557bb3 100644 --- a/lib/type-generation/languages/swift.js +++ b/lib/type-generation/languages/swift.js @@ -3,7 +3,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class Swift extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = ""; switch (attribute.type) { case AttributeType.STRING: @@ -11,7 +11,7 @@ class Swift extends LanguageMeta { case AttributeType.DATETIME: type = "String"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -53,7 +53,7 @@ class Swift extends LanguageMeta { <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> -public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable { +public enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable { <% for (const [index, element] of Object.entries(attribute.elements)) { -%> case <%- strict ? toCamelCase(element) : element %> = "<%- element %>" <% } -%> @@ -63,7 +63,7 @@ public enum <%- toPascalCase(attribute.key) %>: String, Codable, CaseIterable { <% } -%> public class <%- toPascalCase(collection.name) %>: Codable { <% for (const attribute of collection.attributes) { -%> - public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %> + public let <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections, collection.name) %> <% } %> enum CodingKeys: String, CodingKey { <% for (const attribute of collection.attributes) { -%> @@ -73,7 +73,7 @@ public class <%- toPascalCase(collection.name) %>: Codable { public init( <% for (const [index, attribute] of Object.entries(collection.attributes)) { -%> - <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %><% if (index < collection.attributes.length - 1) { %>,<% } %> + <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections, collection.name) %><% if (index < collection.attributes.length - 1) { %>,<% } %> <% } -%> ) { <% for (const attribute of collection.attributes) { -%> @@ -86,9 +86,9 @@ public class <%- toPascalCase(collection.name) %>: Codable { <% for (const attribute of collection.attributes) { -%> <% if (!(!attribute.required && attribute.default === null)) { -%> - self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>) + self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decode(<%- getType(attribute, collections, collection.name).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>) <% } else { -%> - self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute, collections).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>) + self.<%- strict ? toCamelCase(attribute.key) : attribute.key %> = try container.decodeIfPresent(<%- getType(attribute, collections, collection.name).replace('?', '') %>.self, forKey: .<%- strict ? toCamelCase(attribute.key) : attribute.key %>) <% } -%> <% } -%> } @@ -144,7 +144,7 @@ public class <%- toPascalCase(collection.name) %>: Codable { <% if ((attribute.type === 'string' || attribute.type === 'email' || attribute.type === 'datetime') && attribute.format !== 'enum') { -%> <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> String<% if (index < collection.attributes.length - 1) { %>,<% } %> <% } else if (attribute.type === 'string' && attribute.format === 'enum') { -%> - <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- toPascalCase(attribute.key) %>(rawValue: map["<%- attribute.key %>"] as! String)!<% if (index < collection.attributes.length - 1) { %>,<% } %> + <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>(rawValue: map["<%- attribute.key %>"] as! String)!<% if (index < collection.attributes.length - 1) { %>,<% } %> <% } else if (attribute.type === 'integer') { -%> <%- strict ? toCamelCase(attribute.key) : attribute.key %>: map["<%- attribute.key %>"] as<% if (!attribute.required) { %>?<% } else { %>!<% } %> Int<% if (index < collection.attributes.length - 1) { %>,<% } %> <% } else if (attribute.type === 'float') { -%> diff --git a/lib/type-generation/languages/typescript.js b/lib/type-generation/languages/typescript.js index c5bd044b..61a6fcb0 100644 --- a/lib/type-generation/languages/typescript.js +++ b/lib/type-generation/languages/typescript.js @@ -6,7 +6,7 @@ const { AttributeType } = require('../attribute'); const { LanguageMeta } = require("./language"); class TypeScript extends LanguageMeta { - getType(attribute, collections) { + getType(attribute, collections, collectionName) { let type = "" switch (attribute.type) { case AttributeType.STRING: @@ -16,7 +16,7 @@ class TypeScript extends LanguageMeta { case AttributeType.URL: type = "string"; if (attribute.format === AttributeType.ENUM) { - type = LanguageMeta.toPascalCase(attribute.key); + type = LanguageMeta.toPascalCase(collectionName) + LanguageMeta.toPascalCase(attribute.key); } break; case AttributeType.INTEGER: @@ -77,7 +77,7 @@ class TypeScript extends LanguageMeta { <% for (const collection of collections) { -%> <% for (const attribute of collection.attributes) { -%> <% if (attribute.format === 'enum') { -%> -export enum <%- toPascalCase(attribute.key) %> { +export enum <%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %> { <% const entries = Object.entries(attribute.elements); -%> <% for (let i = 0; i < entries.length; i++) { -%> <%- toUpperSnakeCase(entries[i][1]) %> = "<%- entries[i][1] %>"<% if (i !== entries.length - 1) { %>,<% } %> @@ -92,7 +92,7 @@ export type <%- toPascalCase(collection.name) %> = Models.Row & { <% for (const attribute of collection.attributes) { -%> <% const propertyName = strict ? toCamelCase(attribute.key) : attribute.key; -%> <% const isValidIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propertyName); -%> - <% if (isValidIdentifier) { %><%- propertyName %><% } else { %>"<%- propertyName %>"<% } %>: <%- getType(attribute, collections) %>; + <% if (isValidIdentifier) { %><%- propertyName %><% } else { %>"<%- propertyName %>"<% } %>: <%- getType(attribute, collections, collection.name) %>; <% } -%> }<% if (index < collections.length - 1) { %> <% } %> diff --git a/package.json b/package.json index 48abc56f..43c52e7c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "appwrite-cli", "homepage": "https://appwrite.io/support", "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API", - "version": "11.1.0", + "version": "11.1.1", "license": "BSD-3-Clause", "main": "index.js", "bin": { diff --git a/scoop/appwrite.config.json b/scoop/appwrite.config.json index 5a748508..625d78d3 100644 --- a/scoop/appwrite.config.json +++ b/scoop/appwrite.config.json @@ -1,12 +1,12 @@ { "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json", - "version": "11.1.0", + "version": "11.1.1", "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.", "homepage": "https://github.com/appwrite/sdk-for-cli", "license": "BSD-3-Clause", "architecture": { "64bit": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.0/appwrite-cli-win-x64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.1/appwrite-cli-win-x64.exe", "bin": [ [ "appwrite-cli-win-x64.exe", @@ -15,7 +15,7 @@ ] }, "arm64": { - "url": "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.0/appwrite-cli-win-arm64.exe", + "url": "https://github.com/appwrite/sdk-for-cli/releases/download/11.1.1/appwrite-cli-win-arm64.exe", "bin": [ [ "appwrite-cli-win-arm64.exe",