appwrite-cli 4.2.0 → 4.2.1
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/LICENSE.md +1 -1
- package/README.md +3 -3
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +61 -74
- package/lib/commands/account.js +550 -196
- package/lib/commands/assistant.js +42 -7
- package/lib/commands/avatars.js +197 -81
- package/lib/commands/console.js +42 -3
- package/lib/commands/databases.js +981 -552
- package/lib/commands/functions.js +561 -291
- package/lib/commands/graphql.js +58 -11
- package/lib/commands/health.js +325 -68
- package/lib/commands/locale.js +154 -17
- package/lib/commands/migrations.js +328 -147
- package/lib/commands/project.js +128 -33
- package/lib/commands/projects.js +788 -411
- package/lib/commands/proxy.js +113 -28
- package/lib/commands/storage.js +422 -207
- package/lib/commands/teams.js +279 -103
- package/lib/commands/users.js +550 -262
- package/lib/commands/vcs.js +186 -53
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright (c)
|
|
1
|
+
Copyright (c) 2024 Appwrite (https://appwrite.io) and individual contributors.
|
|
2
2
|
All rights reserved.
|
|
3
3
|
|
|
4
4
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Appwrite Command Line SDK
|
|
2
2
|
|
|
3
3
|

|
|
4
|
-

|
|
5
5
|
[](https://travis-ci.com/appwrite/sdk-generator)
|
|
6
6
|
[](https://twitter.com/appwrite)
|
|
7
7
|
[](https://appwrite.io/discord)
|
|
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
|
|
|
29
29
|
|
|
30
30
|
```sh
|
|
31
31
|
$ appwrite -v
|
|
32
|
-
4.2.
|
|
32
|
+
4.2.1
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -63,7 +63,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
|
|
|
63
63
|
Once the installation completes, you can verify your install using
|
|
64
64
|
```
|
|
65
65
|
$ appwrite -v
|
|
66
|
-
4.2.
|
|
66
|
+
4.2.1
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
## Getting Started
|
package/install.ps1
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
# You can use "View source" of this page to see the full script.
|
|
14
14
|
|
|
15
15
|
# REPO
|
|
16
|
-
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.
|
|
17
|
-
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.
|
|
16
|
+
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.1/appwrite-cli-win-x64.exe"
|
|
17
|
+
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.1/appwrite-cli-win-arm64.exe"
|
|
18
18
|
|
|
19
19
|
$APPWRITE_BINARY_NAME = "appwrite.exe"
|
|
20
20
|
|
package/install.sh
CHANGED
|
@@ -97,7 +97,7 @@ printSuccess() {
|
|
|
97
97
|
downloadBinary() {
|
|
98
98
|
echo "[2/4] Downloading executable for $OS ($ARCH) ..."
|
|
99
99
|
|
|
100
|
-
GITHUB_LATEST_VERSION="4.2.
|
|
100
|
+
GITHUB_LATEST_VERSION="4.2.1"
|
|
101
101
|
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
|
|
102
102
|
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
|
|
103
103
|
|
package/lib/client.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const https = require("https");
|
|
3
|
-
const
|
|
3
|
+
const { fetch, FormData, Agent } = require("undici");
|
|
4
4
|
const JSONbig = require("json-bigint")({ storeAsString: false });
|
|
5
|
-
const FormData = require("form-data");
|
|
6
5
|
const AppwriteException = require("./exception.js");
|
|
7
6
|
const { globalConfig } = require("./config.js");
|
|
8
7
|
|
|
9
8
|
class Client {
|
|
10
|
-
|
|
9
|
+
CHUNK_SIZE = 5*1024*1024; // 5MB
|
|
11
10
|
|
|
12
11
|
constructor() {
|
|
13
12
|
this.endpoint = 'https://HOSTNAME/v1';
|
|
@@ -16,8 +15,8 @@ class Client {
|
|
|
16
15
|
'x-sdk-name': 'Command Line',
|
|
17
16
|
'x-sdk-platform': 'console',
|
|
18
17
|
'x-sdk-language': 'cli',
|
|
19
|
-
'x-sdk-version': '4.2.
|
|
20
|
-
'user-agent' : `AppwriteCLI/4.2.
|
|
18
|
+
'x-sdk-version': '4.2.1',
|
|
19
|
+
'user-agent' : `AppwriteCLI/4.2.1 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
21
20
|
'X-Appwrite-Response-Format' : '1.4.0',
|
|
22
21
|
};
|
|
23
22
|
}
|
|
@@ -144,93 +143,81 @@ class Client {
|
|
|
144
143
|
return this;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
async call(
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
headers = {},
|
|
151
|
-
params = {},
|
|
152
|
-
responseType = "json"
|
|
153
|
-
) {
|
|
154
|
-
headers = Object.assign({}, this.headers, headers);
|
|
146
|
+
async call(method, path = "", headers = {}, params = {}, responseType = "json") {
|
|
147
|
+
headers = {...this.headers, ...headers};
|
|
148
|
+
const url = new URL(this.endpoint + path);
|
|
155
149
|
|
|
156
|
-
let
|
|
150
|
+
let body = undefined;
|
|
157
151
|
|
|
158
|
-
|
|
152
|
+
if (method.toUpperCase() === "GET") {
|
|
153
|
+
url.search = new URLSearchParams(Client.flatten(params)).toString();
|
|
154
|
+
} else if (headers["content-type"]?.toLowerCase().startsWith("multipart/form-data")) {
|
|
155
|
+
delete headers["content-type"];
|
|
156
|
+
const formData = new FormData();
|
|
159
157
|
|
|
160
|
-
|
|
161
|
-
const form = new FormData();
|
|
158
|
+
const flatParams = Client.flatten(params);
|
|
162
159
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
160
|
+
for (const [key, value] of Object.entries(flatParams)) {
|
|
161
|
+
if (value && value.type && value.type === "file") {
|
|
162
|
+
formData.append(key, value.file, value.filename);
|
|
163
|
+
} else {
|
|
164
|
+
formData.append(key, value);
|
|
165
|
+
}
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
168
|
+
body = formData;
|
|
169
|
+
} else {
|
|
170
|
+
body = JSON.stringify(params);
|
|
171
|
+
}
|
|
173
172
|
|
|
174
|
-
|
|
173
|
+
let response = undefined;
|
|
174
|
+
try {
|
|
175
|
+
response = await fetch(url.toString(), {
|
|
176
|
+
method: method.toUpperCase(),
|
|
177
|
+
headers,
|
|
178
|
+
body,
|
|
179
|
+
dispatcher: new Agent({
|
|
180
|
+
connect: {
|
|
181
|
+
rejectUnauthorized: !this.selfSigned,
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
});
|
|
185
|
+
} catch (error) {
|
|
186
|
+
throw new AppwriteException(error.message);
|
|
175
187
|
}
|
|
176
188
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
transformResponse: [ (data) => data ? JSONbig.parse(data) : data ],
|
|
187
|
-
responseType: responseType,
|
|
188
|
-
};
|
|
189
|
-
if (this.selfSigned == true) {
|
|
190
|
-
// Allow self signed requests
|
|
191
|
-
options.httpsAgent = new https.Agent({ rejectUnauthorized: false });
|
|
189
|
+
if (response.status >= 400) {
|
|
190
|
+
const text = await response.text();
|
|
191
|
+
let json = undefined;
|
|
192
|
+
try {
|
|
193
|
+
json = JSON.parse(text);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
throw new AppwriteException(text, response.status, "", text);
|
|
196
|
+
}
|
|
197
|
+
throw new AppwriteException(json.message, json.code, json.type, json);
|
|
192
198
|
}
|
|
199
|
+
|
|
200
|
+
if (responseType === "arraybuffer") {
|
|
201
|
+
const data = await response.arrayBuffer();
|
|
202
|
+
return data;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const text = await response.text();
|
|
206
|
+
let json = undefined;
|
|
193
207
|
try {
|
|
194
|
-
|
|
195
|
-
if (response.headers["set-cookie"]) {
|
|
196
|
-
globalConfig.setCookie(response.headers["set-cookie"][0]);
|
|
197
|
-
}
|
|
198
|
-
return response.data;
|
|
208
|
+
json = JSON.parse(text);
|
|
199
209
|
} catch (error) {
|
|
200
|
-
|
|
201
|
-
if (error.response && "data" in error.response) {
|
|
202
|
-
if (typeof error.response.data === "string") {
|
|
203
|
-
throw new AppwriteException(
|
|
204
|
-
error.response.data,
|
|
205
|
-
error.response.status,
|
|
206
|
-
error.response.data
|
|
207
|
-
);
|
|
208
|
-
} else {
|
|
209
|
-
throw new AppwriteException(
|
|
210
|
-
error.response.data.message,
|
|
211
|
-
error.response.status,
|
|
212
|
-
error.response.data
|
|
213
|
-
);
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
throw new AppwriteException(
|
|
217
|
-
error.response.statusText,
|
|
218
|
-
error.response.status,
|
|
219
|
-
error.response.data
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
} else {
|
|
223
|
-
throw new AppwriteException(error.message);
|
|
224
|
-
}
|
|
210
|
+
return text;
|
|
225
211
|
}
|
|
212
|
+
return json;
|
|
226
213
|
}
|
|
227
214
|
|
|
228
|
-
static flatten(data, prefix =
|
|
215
|
+
static flatten(data, prefix = '') {
|
|
229
216
|
let output = {};
|
|
230
217
|
|
|
231
218
|
for (const key in data) {
|
|
232
219
|
let value = data[key];
|
|
233
|
-
let finalKey = prefix ? prefix +
|
|
220
|
+
let finalKey = prefix ? prefix + '[' + key +']' : key;
|
|
234
221
|
|
|
235
222
|
if (Array.isArray(value)) {
|
|
236
223
|
output = Object.assign(output, Client.flatten(value, finalKey)); // @todo: handle name collision here if needed
|
|
@@ -243,4 +230,4 @@ class Client {
|
|
|
243
230
|
}
|
|
244
231
|
}
|
|
245
232
|
|
|
246
|
-
module.exports = Client;
|
|
233
|
+
module.exports = Client;
|