appwrite-cli 9.0.2 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/examples/databases/create-line-attribute.md +5 -0
- package/docs/examples/databases/create-point-attribute.md +5 -0
- package/docs/examples/databases/create-polygon-attribute.md +5 -0
- package/docs/examples/databases/update-line-attribute.md +5 -0
- package/docs/examples/databases/update-point-attribute.md +5 -0
- package/docs/examples/databases/update-polygon-attribute.md +5 -0
- package/docs/examples/tablesdb/create-line-column.md +5 -0
- package/docs/examples/tablesdb/create-point-column.md +5 -0
- package/docs/examples/tablesdb/create-polygon-column.md +5 -0
- package/docs/examples/tablesdb/update-line-column.md +5 -0
- package/docs/examples/tablesdb/update-point-column.md +5 -0
- package/docs/examples/tablesdb/update-polygon-column.md +5 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/databases.js +330 -0
- package/lib/commands/functions.js +2 -2
- package/lib/commands/generic.js +5 -5
- package/lib/commands/init.js +3 -1
- package/lib/commands/pull.js +8 -2
- package/lib/commands/push.js +27 -9
- package/lib/commands/tables-db.js +330 -0
- package/lib/commands/types.js +54 -15
- package/lib/config.js +57 -33
- package/lib/parser.js +1 -1
- package/lib/questions.js +6 -6
- package/lib/type-generation/languages/csharp.js +170 -0
- package/lib/type-generation/languages/javascript.js +2 -2
- package/lib/type-generation/languages/typescript.js +1 -1
- package/package.json +1 -1
- package/scoop/appwrite.config.json +3 -3
package/lib/parser.js
CHANGED
|
@@ -122,7 +122,7 @@ const parseError = (err) => {
|
|
|
122
122
|
} catch {
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
const version = '9.0
|
|
125
|
+
const version = '9.1.0';
|
|
126
126
|
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
|
|
127
127
|
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
|
|
128
128
|
|
package/lib/questions.js
CHANGED
|
@@ -5,7 +5,7 @@ const { projectsList } = require('./commands/projects');
|
|
|
5
5
|
const { organizationsList } = require('./commands/organizations');
|
|
6
6
|
const { teamsList } = require('./commands/teams');
|
|
7
7
|
const { functionsListRuntimes, functionsListSpecifications, functionsList } = require('./commands/functions');
|
|
8
|
-
const {
|
|
8
|
+
const { accountListMFAFactors } = require("./commands/account");
|
|
9
9
|
const { sdkForConsole } = require("./sdks");
|
|
10
10
|
const { validateRequired } = require("./validations");
|
|
11
11
|
const { paginate } = require('./paginate');
|
|
@@ -259,7 +259,7 @@ const questionsPullResources = [
|
|
|
259
259
|
{ name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
260
260
|
{ name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
261
261
|
{ name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' },
|
|
262
|
-
{ name: `Collections ${chalk.blackBright(`(
|
|
262
|
+
{ name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
|
|
263
263
|
]
|
|
264
264
|
}
|
|
265
265
|
]
|
|
@@ -671,7 +671,7 @@ const questionsPushResources = [
|
|
|
671
671
|
{ name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
672
672
|
{ name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
673
673
|
{ name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' },
|
|
674
|
-
{ name: `Collections ${chalk.blackBright(`(
|
|
674
|
+
{ name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
|
|
675
675
|
]
|
|
676
676
|
}
|
|
677
677
|
];
|
|
@@ -877,7 +877,7 @@ const questionsListFactors = [
|
|
|
877
877
|
message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
|
|
878
878
|
choices: async () => {
|
|
879
879
|
let client = await sdkForConsole(false);
|
|
880
|
-
const factors = await
|
|
880
|
+
const factors = await accountListMFAFactors({
|
|
881
881
|
sdk: client,
|
|
882
882
|
parseOutput: false
|
|
883
883
|
});
|
|
@@ -906,7 +906,7 @@ const questionsListFactors = [
|
|
|
906
906
|
}
|
|
907
907
|
];
|
|
908
908
|
|
|
909
|
-
const
|
|
909
|
+
const questionsMFAChallenge = [
|
|
910
910
|
{
|
|
911
911
|
type: "input",
|
|
912
912
|
name: "otp",
|
|
@@ -1019,7 +1019,7 @@ module.exports = {
|
|
|
1019
1019
|
questionsPushTeams,
|
|
1020
1020
|
questionsGetEntrypoint,
|
|
1021
1021
|
questionsListFactors,
|
|
1022
|
-
|
|
1022
|
+
questionsMFAChallenge,
|
|
1023
1023
|
questionsRunFunctions,
|
|
1024
1024
|
questionGetEndpoint,
|
|
1025
1025
|
questionsInitResources,
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/** @typedef {import('../attribute').Attribute} Attribute */
|
|
2
|
+
const { AttributeType } = require('../attribute');
|
|
3
|
+
const { LanguageMeta } = require("./language");
|
|
4
|
+
|
|
5
|
+
class CSharp extends LanguageMeta {
|
|
6
|
+
getType(attribute, collections) {
|
|
7
|
+
let type = "";
|
|
8
|
+
switch (attribute.type) {
|
|
9
|
+
case AttributeType.STRING:
|
|
10
|
+
case AttributeType.EMAIL:
|
|
11
|
+
case AttributeType.DATETIME:
|
|
12
|
+
type = "string";
|
|
13
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
14
|
+
type = LanguageMeta.toPascalCase(attribute.key);
|
|
15
|
+
}
|
|
16
|
+
break;
|
|
17
|
+
case AttributeType.INTEGER:
|
|
18
|
+
type = "long";
|
|
19
|
+
break;
|
|
20
|
+
case AttributeType.FLOAT:
|
|
21
|
+
type = "double";
|
|
22
|
+
break;
|
|
23
|
+
case AttributeType.BOOLEAN:
|
|
24
|
+
type = "bool";
|
|
25
|
+
break;
|
|
26
|
+
case AttributeType.RELATIONSHIP:
|
|
27
|
+
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
+
if (!relatedCollection) {
|
|
29
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
30
|
+
}
|
|
31
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
32
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
33
|
+
type = `List<${type}>`;
|
|
34
|
+
}
|
|
35
|
+
break;
|
|
36
|
+
default:
|
|
37
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
38
|
+
}
|
|
39
|
+
if (attribute.array) {
|
|
40
|
+
type = `List<${type}>`;
|
|
41
|
+
}
|
|
42
|
+
if (!attribute.required) {
|
|
43
|
+
type += "?";
|
|
44
|
+
}
|
|
45
|
+
return type;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getTemplate() {
|
|
49
|
+
return `/// This file is auto-generated by the Appwrite CLI.
|
|
50
|
+
/// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
51
|
+
|
|
52
|
+
#nullable enable
|
|
53
|
+
using System;
|
|
54
|
+
using System.Collections.Generic;
|
|
55
|
+
using System.Linq;
|
|
56
|
+
using System.Text.Json.Serialization;
|
|
57
|
+
|
|
58
|
+
namespace Appwrite.Models
|
|
59
|
+
{
|
|
60
|
+
<% for (const attribute of collection.attributes) { -%>
|
|
61
|
+
<% if (attribute.format === 'enum') { -%>
|
|
62
|
+
|
|
63
|
+
public enum <%- toPascalCase(attribute.key) %> {
|
|
64
|
+
<% for (const [index, element] of Object.entries(attribute.elements) ) { -%>
|
|
65
|
+
[JsonPropertyName("<%- element %>")]
|
|
66
|
+
<%- toPascalCase(element) %><% if (index < attribute.elements.length - 1) { %>,<% } %>
|
|
67
|
+
<% } -%>
|
|
68
|
+
}
|
|
69
|
+
<% } -%>
|
|
70
|
+
<% } %>
|
|
71
|
+
public class <%= toPascalCase(collection.name) %>
|
|
72
|
+
{
|
|
73
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
74
|
+
[JsonPropertyName("<%- attribute.key %>")]
|
|
75
|
+
public <%- getType(attribute, collections) %> <%= toPascalCase(attribute.key) %> { get; private set; }
|
|
76
|
+
|
|
77
|
+
<% } -%>
|
|
78
|
+
|
|
79
|
+
public <%= toPascalCase(collection.name) %>(
|
|
80
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
81
|
+
<%- getType(attribute, collections) %> <%= toCamelCase(attribute.key) %><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
82
|
+
<% } -%>
|
|
83
|
+
)
|
|
84
|
+
{
|
|
85
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
86
|
+
<%= toPascalCase(attribute.key) %> = <%= toCamelCase(attribute.key) %>;
|
|
87
|
+
<% } -%>
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
public static <%= toPascalCase(collection.name) %> From(Dictionary<string, object> map) => new <%= toPascalCase(collection.name) %>(
|
|
91
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
92
|
+
<%- toCamelCase(attribute.key) %>: <%
|
|
93
|
+
// ENUM
|
|
94
|
+
if (attribute.format === 'enum') {
|
|
95
|
+
if (attribute.array) {
|
|
96
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(e => Enum.Parse<Models.<%- toPascalCase(attribute.key) %>>(e.ToString()!, true)).ToList()<%
|
|
97
|
+
} else {
|
|
98
|
+
-%>Enum.Parse<Models.<%- toPascalCase(attribute.key) %>>(map["<%- attribute.key %>"].ToString()!, true)<%
|
|
99
|
+
}
|
|
100
|
+
// RELATIONSHIP
|
|
101
|
+
} else if (attribute.type === 'relationship') {
|
|
102
|
+
const relatedClass = toPascalCase(collections.find(c => c.$id === attribute.relatedCollection).name);
|
|
103
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany' || attribute.array) {
|
|
104
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(it => Models.<%- relatedClass %>.From((Dictionary<string, object>)it)).ToList()<%
|
|
105
|
+
} else {
|
|
106
|
+
-%>Models.<%- relatedClass %>.From((Dictionary<string, object>)map["<%- attribute.key %>"])<%
|
|
107
|
+
}
|
|
108
|
+
// ARRAY TYPES
|
|
109
|
+
} else if (attribute.array) {
|
|
110
|
+
if (attribute.type === 'string' || attribute.type === 'datetime' || attribute.type === 'email') {
|
|
111
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => x?.ToString())<%- attribute.required ? '.Where(x => x != null)' : '' %>.ToList()!<%
|
|
112
|
+
} else if (attribute.type === 'integer') {
|
|
113
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => <%- !attribute.required ? 'x == null ? (long?)null : ' : '' %>Convert.ToInt64(x)).ToList()<%
|
|
114
|
+
} else if (attribute.type === 'double') {
|
|
115
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => <%- !attribute.required ? 'x == null ? (double?)null : ' : '' %>Convert.ToDouble(x)).ToList()<%
|
|
116
|
+
} else if (attribute.type === 'boolean') {
|
|
117
|
+
-%>((IEnumerable<object>)map["<%- attribute.key %>"]).Select(x => <%- !attribute.required ? 'x == null ? (bool?)null : ' : '' %>(bool)x).ToList()<%
|
|
118
|
+
}
|
|
119
|
+
// SINGLE VALUE TYPES
|
|
120
|
+
} else if (attribute.type === 'integer') {
|
|
121
|
+
-%><%- !attribute.required ? 'map["' + attribute.key + '"] == null ? null : ' : '' %>Convert.ToInt64(map["<%- attribute.key %>"])<%
|
|
122
|
+
} else if (attribute.type === 'double') {
|
|
123
|
+
-%><%- !attribute.required ? 'map["' + attribute.key + '"] == null ? null : ' : '' %>Convert.ToDouble(map["<%- attribute.key %>"])<%
|
|
124
|
+
} else if (attribute.type === 'boolean') {
|
|
125
|
+
-%>(<%- getType(attribute, collections) %>)map["<%- attribute.key %>"]<%
|
|
126
|
+
} else if (attribute.type === 'string' || attribute.type === 'datetime' || attribute.type === 'email') {
|
|
127
|
+
-%>map["<%- attribute.key %>"]<%- !attribute.required ? '?' : '' %>.ToString()<%- attribute.required ? '!' : ''%><%
|
|
128
|
+
} else {
|
|
129
|
+
-%>default<%
|
|
130
|
+
}
|
|
131
|
+
-%><% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
132
|
+
<% } -%>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
public Dictionary<string, object?> ToMap() => new Dictionary<string, object?>()
|
|
136
|
+
{
|
|
137
|
+
<% for (const [index, attribute] of Object.entries(collection.attributes)) { -%>
|
|
138
|
+
{ "<%- attribute.key %>", <%
|
|
139
|
+
// ENUM
|
|
140
|
+
if (attribute.format === 'enum') {
|
|
141
|
+
if (attribute.array) {
|
|
142
|
+
-%><%= toPascalCase(attribute.key) %>?.Select(e => e.ToString()).ToList()<%
|
|
143
|
+
} else {
|
|
144
|
+
-%><%= toPascalCase(attribute.key) %>?.ToString()<%
|
|
145
|
+
}
|
|
146
|
+
// RELATIONSHIP
|
|
147
|
+
} else if (attribute.type === 'relationship') {
|
|
148
|
+
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany' || attribute.array) {
|
|
149
|
+
-%><%= toPascalCase(attribute.key) %>?.Select(e => e.ToMap()).ToList()<%
|
|
150
|
+
} else {
|
|
151
|
+
-%><%= toPascalCase(attribute.key) %>?.ToMap()<%
|
|
152
|
+
}
|
|
153
|
+
// OTHER
|
|
154
|
+
} else {
|
|
155
|
+
-%><%= toPascalCase(attribute.key) %><%
|
|
156
|
+
}
|
|
157
|
+
-%> }<% if (index < collection.attributes.length - 1) { %>,<% } %>
|
|
158
|
+
<% } -%>
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
getFileName(collection) {
|
|
166
|
+
return LanguageMeta.toPascalCase(collection.name) + ".cs";
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
module.exports = { CSharp };
|
|
@@ -66,7 +66,7 @@ class JavaScript extends LanguageMeta {
|
|
|
66
66
|
|
|
67
67
|
getTemplate() {
|
|
68
68
|
return `/**
|
|
69
|
-
* @typedef {import('${this._getAppwriteDependency()}').Models.
|
|
69
|
+
* @typedef {import('${this._getAppwriteDependency()}').Models.Row} Row
|
|
70
70
|
*/
|
|
71
71
|
|
|
72
72
|
// This file is auto-generated by the Appwrite CLI.
|
|
@@ -83,7 +83,7 @@ class JavaScript extends LanguageMeta {
|
|
|
83
83
|
<% } -%>
|
|
84
84
|
<% } -%>
|
|
85
85
|
<% for (const [index, collection] of Object.entries(collections)) { %>/**
|
|
86
|
-
* @typedef {
|
|
86
|
+
* @typedef {Row & {
|
|
87
87
|
<% for (const attribute of collection.attributes) { -%>
|
|
88
88
|
* <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
89
89
|
<% } -%>
|
|
@@ -88,7 +88,7 @@ export enum <%- toPascalCase(attribute.key) %> {
|
|
|
88
88
|
<% } -%>
|
|
89
89
|
<% } -%>
|
|
90
90
|
<% for (const [index, collection] of Object.entries(collections)) { -%>
|
|
91
|
-
export type <%- toPascalCase(collection.name) %> = Models.
|
|
91
|
+
export type <%- toPascalCase(collection.name) %> = Models.Row & {
|
|
92
92
|
<% for (const attribute of collection.attributes) { -%>
|
|
93
93
|
<%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
94
94
|
<% } -%>
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "appwrite-cli",
|
|
3
3
|
"homepage": "https://appwrite.io/support",
|
|
4
4
|
"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",
|
|
5
|
-
"version": "9.0
|
|
5
|
+
"version": "9.1.0",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "9.0
|
|
3
|
+
"version": "9.1.0",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/9.0
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/9.1.0/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/9.0
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/9.1.0/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|