Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};
}
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/sites.js
Original file line number Diff line number Diff line change
Expand Up @@ -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>`, `Site ID.`)
.requiredOption(`--code <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))
Expand Down
2 changes: 1 addition & 1 deletion lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`;

Expand Down
16 changes: 8 additions & 8 deletions lib/type-generation/languages/csharp.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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:
case AttributeType.EMAIL:
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:
Expand Down Expand Up @@ -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) { %>,<% } %>
Expand All @@ -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) { %>,<% } %>
<% } -%>
)
{
Expand All @@ -93,9 +93,9 @@ public class <%= toPascalCase(collection.name) %>
// ENUM
if (attribute.format === 'enum') {
if (attribute.array) {
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(e => Enum.Parse<Models.<%- toPascalCase(attribute.key) %>>(e.ToString()!, true)).ToList()<%
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(e => Enum.Parse<Models.<%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>>(e.ToString()!, true)).ToList()<%
} else {
-%>Enum.Parse<Models.<%- toPascalCase(attribute.key) %>>(map["<%- attribute.key %>"].ToString()!, true)<%
-%>Enum.Parse<Models.<%- toPascalCase(collection.name) %><%- toPascalCase(attribute.key) %>>(map["<%- attribute.key %>"].ToString()!, true)<%
}
// RELATIONSHIP
} else if (attribute.type === 'relationship') {
Expand All @@ -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 {
Expand Down
14 changes: 7 additions & 7 deletions lib/type-generation/languages/dart.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ class Dart extends LanguageMeta {
return 'appwrite';
}

getType(attribute, collections) {
getType(attribute, collections, collectionName) {
let type = "";
switch (attribute.type) {
case AttributeType.STRING:
case AttributeType.EMAIL:
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:
Expand Down Expand Up @@ -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) { -%>,<% } %>
<% } -%>
Expand All @@ -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) %>({
Expand All @@ -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<dynamic>?)?.map((e) => <%- toPascalCase(attribute.key) %>.values.firstWhere((element) => element.name == e)).toList()<% } else { -%>
(map['<%= attribute.key %>'] as List<dynamic>?)?.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) { -%>
Expand Down
14 changes: 7 additions & 7 deletions lib/type-generation/languages/java.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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:
case AttributeType.EMAIL:
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:
Expand Down Expand Up @@ -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 ? ',' : ';' %>
<% } -%>
Expand All @@ -70,15 +70,15 @@ 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) %>() {
}

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) { -%>
Expand All @@ -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 %>;
}

Expand Down
8 changes: 4 additions & 4 deletions lib/type-generation/languages/kotlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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:
case AttributeType.EMAIL:
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:
Expand Down Expand Up @@ -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 ? ',' : '' %>
<% } -%>
Expand All @@ -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) { %>,<% } %>
<% } -%>
)
`;
Expand Down
18 changes: 9 additions & 9 deletions lib/type-generation/languages/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand All @@ -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:
Expand Down Expand Up @@ -60,25 +60,25 @@ 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 %>';
<% } -%>
}

<% } -%>
<% } -%>
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) { %>,<% } %>
<% } -%>
<% } -%>
) {
Expand All @@ -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) { %>
Expand Down
Loading