appwrite-cli 1.1.1 → 1.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/Formula/appwrite.rb +1 -1
- package/LICENSE.md +2 -2
- package/README.md +4 -4
- package/docs/examples/account/create-phone-session.md +1 -1
- package/docs/examples/account/get-logs.md +2 -0
- package/docs/examples/account/get-sessions.md +1 -0
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/functions/create-build.md +4 -0
- package/docs/examples/graphql/mutation.md +2 -0
- package/docs/examples/graphql/query.md +2 -0
- package/docs/examples/locale/get-continents.md +1 -0
- package/docs/examples/locale/get-countries-e-u.md +1 -0
- package/docs/examples/locale/get-countries-phones.md +1 -0
- package/docs/examples/locale/get-countries.md +1 -0
- package/docs/examples/locale/get-currencies.md +1 -0
- package/docs/examples/locale/get-languages.md +1 -0
- package/docs/examples/projects/create.md +1 -0
- package/docs/examples/projects/update-auth-duration.md +3 -0
- package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
- package/docs/examples/projects/update-o-auth2.md +1 -0
- package/docs/examples/teams/get-memberships.md +4 -0
- package/docs/examples/users/get-logs.md +3 -0
- package/docs/examples/users/get-memberships.md +2 -0
- package/docs/examples/users/get-sessions.md +2 -0
- package/docs/examples/users/update-phone.md +1 -1
- package/index.js +14 -1
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +2 -2
- package/lib/commands/account.js +10 -8
- package/lib/commands/avatars.js +3 -1
- package/lib/commands/databases.js +12 -10
- package/lib/commands/deploy.js +86 -1
- package/lib/commands/functions.js +9 -7
- package/lib/commands/generic.js +9 -0
- package/lib/commands/graphql.js +85 -0
- package/lib/commands/health.js +3 -1
- package/lib/commands/init.js +27 -1
- package/lib/commands/locale.js +3 -1
- package/lib/commands/projects.js +85 -5
- package/lib/commands/storage.js +10 -8
- package/lib/commands/teams.js +5 -3
- package/lib/commands/users.js +11 -9
- package/lib/config.js +39 -0
- package/lib/parser.js +1 -0
- package/lib/questions.js +27 -0
- package/package.json +1 -1
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const pathLib = require('path');
|
|
3
|
+
const tar = require("tar");
|
|
4
|
+
const ignore = require("ignore");
|
|
5
|
+
const { promisify } = require('util');
|
|
6
|
+
const libClient = require('../client.js');
|
|
7
|
+
const { getAllFiles } = require('../utils.js');
|
|
8
|
+
const { Command } = require('commander');
|
|
9
|
+
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
|
+
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
|
+
const { localConfig, globalConfig } = require("../config");
|
|
12
|
+
|
|
13
|
+
const graphql = new Command("graphql").description(commandDescriptions['graphql']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
const graphqlQuery = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
18
|
+
/* @param {object} query */
|
|
19
|
+
|
|
20
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
21
|
+
let path = '/graphql';
|
|
22
|
+
let payload = {};
|
|
23
|
+
|
|
24
|
+
/** Body Params */
|
|
25
|
+
if (typeof query !== 'undefined') {
|
|
26
|
+
payload['query'] = JSON.parse(query);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let response = undefined;
|
|
30
|
+
response = await client.call('post', path, {
|
|
31
|
+
'x-sdk-graphql': 'true',
|
|
32
|
+
'content-type': 'application/json',
|
|
33
|
+
}, payload);
|
|
34
|
+
|
|
35
|
+
if (parseOutput) {
|
|
36
|
+
parse(response)
|
|
37
|
+
success()
|
|
38
|
+
}
|
|
39
|
+
return response;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const graphqlMutation = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
43
|
+
/* @param {object} query */
|
|
44
|
+
|
|
45
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
46
|
+
let path = '/graphql/mutation';
|
|
47
|
+
let payload = {};
|
|
48
|
+
|
|
49
|
+
/** Body Params */
|
|
50
|
+
if (typeof query !== 'undefined') {
|
|
51
|
+
payload['query'] = JSON.parse(query);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let response = undefined;
|
|
55
|
+
response = await client.call('post', path, {
|
|
56
|
+
'x-sdk-graphql': 'true',
|
|
57
|
+
'content-type': 'application/json',
|
|
58
|
+
}, payload);
|
|
59
|
+
|
|
60
|
+
if (parseOutput) {
|
|
61
|
+
parse(response)
|
|
62
|
+
success()
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
graphql
|
|
69
|
+
.command(`query`)
|
|
70
|
+
.description(`Execute a GraphQL mutation.`)
|
|
71
|
+
.requiredOption(`--query <query>`, `The query or queries to execute.`)
|
|
72
|
+
.action(actionRunner(graphqlQuery))
|
|
73
|
+
|
|
74
|
+
graphql
|
|
75
|
+
.command(`mutation`)
|
|
76
|
+
.description(`Execute a GraphQL mutation.`)
|
|
77
|
+
.requiredOption(`--query <query>`, `The query or queries to execute.`)
|
|
78
|
+
.action(actionRunner(graphqlMutation))
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
module.exports = {
|
|
82
|
+
graphql,
|
|
83
|
+
graphqlQuery,
|
|
84
|
+
graphqlMutation
|
|
85
|
+
};
|
package/lib/commands/health.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const health = new Command("health").description(commandDescriptions['health'])
|
|
13
|
+
const health = new Command("health").description(commandDescriptions['health']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const healthGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
|
package/lib/commands/init.js
CHANGED
|
@@ -3,7 +3,7 @@ const path = require("path");
|
|
|
3
3
|
const childProcess = require('child_process');
|
|
4
4
|
const { Command } = require("commander");
|
|
5
5
|
const inquirer = require("inquirer");
|
|
6
|
-
const { teamsCreate } = require("./teams");
|
|
6
|
+
const { teamsCreate, teamsList } = require("./teams");
|
|
7
7
|
const { projectsCreate } = require("./projects");
|
|
8
8
|
const { functionsCreate } = require("./functions");
|
|
9
9
|
const { databasesListCollections, databasesList } = require("./databases");
|
|
@@ -14,6 +14,9 @@ const { success, log, actionRunner, commandDescriptions } = require("../parser")
|
|
|
14
14
|
|
|
15
15
|
const init = new Command("init")
|
|
16
16
|
.description(commandDescriptions['init'])
|
|
17
|
+
.configureHelp({
|
|
18
|
+
helpWidth: process.stdout.columns || 80
|
|
19
|
+
})
|
|
17
20
|
.action(actionRunner(async (_options, command) => {
|
|
18
21
|
command.help();
|
|
19
22
|
}));
|
|
@@ -186,6 +189,24 @@ const initCollection = async ({ all, databaseId } = {}) => {
|
|
|
186
189
|
success();
|
|
187
190
|
}
|
|
188
191
|
|
|
192
|
+
const initTeam = async () => {
|
|
193
|
+
// TODO: Pagination?
|
|
194
|
+
let response = await teamsList({
|
|
195
|
+
queries: [ 'limit(100)' ],
|
|
196
|
+
parseOutput: false
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
let teams = response.teams;
|
|
200
|
+
log(`Found ${teams.length} teams`);
|
|
201
|
+
|
|
202
|
+
teams.forEach(async team => {
|
|
203
|
+
log(`Fetching ${team.name} ...`);
|
|
204
|
+
localConfig.addTeam(team);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
success();
|
|
208
|
+
}
|
|
209
|
+
|
|
189
210
|
init
|
|
190
211
|
.command("project")
|
|
191
212
|
.description("Initialise your Appwrite project")
|
|
@@ -203,6 +224,11 @@ init
|
|
|
203
224
|
.option(`--all`, `Flag to initialize all databases`)
|
|
204
225
|
.action(actionRunner(initCollection))
|
|
205
226
|
|
|
227
|
+
init
|
|
228
|
+
.command("team")
|
|
229
|
+
.description("Initialise your Appwrite teams")
|
|
230
|
+
.action(actionRunner(initTeam))
|
|
231
|
+
|
|
206
232
|
module.exports = {
|
|
207
233
|
init,
|
|
208
234
|
};
|
package/lib/commands/locale.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const locale = new Command("locale").description(commandDescriptions['locale'])
|
|
13
|
+
const locale = new Command("locale").description(commandDescriptions['locale']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const localeGet = async ({ parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
|
package/lib/commands/projects.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const projects = new Command("projects").description(commandDescriptions['projects'])
|
|
13
|
+
const projects = new Command("projects").description(commandDescriptions['projects']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const projectsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -39,10 +41,11 @@ const projectsList = async ({ queries, search, parseOutput = true, sdk = undefin
|
|
|
39
41
|
return response;
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
const projectsCreate = async ({ projectId, name, teamId, description, logo, url, legalName, legalCountry, legalState, legalCity, legalAddress, legalTaxId, parseOutput = true, sdk = undefined}) => {
|
|
44
|
+
const projectsCreate = async ({ projectId, name, teamId, region, description, logo, url, legalName, legalCountry, legalState, legalCity, legalAddress, legalTaxId, parseOutput = true, sdk = undefined}) => {
|
|
43
45
|
/* @param {string} projectId */
|
|
44
46
|
/* @param {string} name */
|
|
45
47
|
/* @param {string} teamId */
|
|
48
|
+
/* @param {string} region */
|
|
46
49
|
/* @param {string} description */
|
|
47
50
|
/* @param {string} logo */
|
|
48
51
|
/* @param {string} url */
|
|
@@ -70,6 +73,10 @@ const projectsCreate = async ({ projectId, name, teamId, description, logo, url,
|
|
|
70
73
|
payload['teamId'] = teamId;
|
|
71
74
|
}
|
|
72
75
|
|
|
76
|
+
if (typeof region !== 'undefined') {
|
|
77
|
+
payload['region'] = region;
|
|
78
|
+
}
|
|
79
|
+
|
|
73
80
|
if (typeof description !== 'undefined') {
|
|
74
81
|
payload['description'] = description;
|
|
75
82
|
}
|
|
@@ -231,6 +238,31 @@ const projectsDelete = async ({ projectId, password, parseOutput = true, sdk = u
|
|
|
231
238
|
return response;
|
|
232
239
|
}
|
|
233
240
|
|
|
241
|
+
const projectsUpdateAuthDuration = async ({ projectId, duration, parseOutput = true, sdk = undefined}) => {
|
|
242
|
+
/* @param {string} projectId */
|
|
243
|
+
/* @param {number} duration */
|
|
244
|
+
|
|
245
|
+
let client = !sdk ? await sdkForConsole() : sdk;
|
|
246
|
+
let path = '/projects/{projectId}/auth/duration'.replace('{projectId}', projectId);
|
|
247
|
+
let payload = {};
|
|
248
|
+
|
|
249
|
+
/** Body Params */
|
|
250
|
+
if (typeof duration !== 'undefined') {
|
|
251
|
+
payload['duration'] = duration;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
let response = undefined;
|
|
255
|
+
response = await client.call('patch', path, {
|
|
256
|
+
'content-type': 'application/json',
|
|
257
|
+
}, payload);
|
|
258
|
+
|
|
259
|
+
if (parseOutput) {
|
|
260
|
+
parse(response)
|
|
261
|
+
success()
|
|
262
|
+
}
|
|
263
|
+
return response;
|
|
264
|
+
}
|
|
265
|
+
|
|
234
266
|
const projectsUpdateAuthLimit = async ({ projectId, limit, parseOutput = true, sdk = undefined}) => {
|
|
235
267
|
/* @param {string} projectId */
|
|
236
268
|
/* @param {number} limit */
|
|
@@ -256,6 +288,31 @@ const projectsUpdateAuthLimit = async ({ projectId, limit, parseOutput = true, s
|
|
|
256
288
|
return response;
|
|
257
289
|
}
|
|
258
290
|
|
|
291
|
+
const projectsUpdateAuthSessionsLimit = async ({ projectId, limit, parseOutput = true, sdk = undefined}) => {
|
|
292
|
+
/* @param {string} projectId */
|
|
293
|
+
/* @param {number} limit */
|
|
294
|
+
|
|
295
|
+
let client = !sdk ? await sdkForConsole() : sdk;
|
|
296
|
+
let path = '/projects/{projectId}/auth/max-sessions'.replace('{projectId}', projectId);
|
|
297
|
+
let payload = {};
|
|
298
|
+
|
|
299
|
+
/** Body Params */
|
|
300
|
+
if (typeof limit !== 'undefined') {
|
|
301
|
+
payload['limit'] = limit;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let response = undefined;
|
|
305
|
+
response = await client.call('patch', path, {
|
|
306
|
+
'content-type': 'application/json',
|
|
307
|
+
}, payload);
|
|
308
|
+
|
|
309
|
+
if (parseOutput) {
|
|
310
|
+
parse(response)
|
|
311
|
+
success()
|
|
312
|
+
}
|
|
313
|
+
return response;
|
|
314
|
+
}
|
|
315
|
+
|
|
259
316
|
const projectsUpdateAuthStatus = async ({ projectId, method, status, parseOutput = true, sdk = undefined}) => {
|
|
260
317
|
/* @param {string} projectId */
|
|
261
318
|
/* @param {string} method */
|
|
@@ -509,11 +566,12 @@ const projectsDeleteKey = async ({ projectId, keyId, parseOutput = true, sdk = u
|
|
|
509
566
|
return response;
|
|
510
567
|
}
|
|
511
568
|
|
|
512
|
-
const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, parseOutput = true, sdk = undefined}) => {
|
|
569
|
+
const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, enabled, parseOutput = true, sdk = undefined}) => {
|
|
513
570
|
/* @param {string} projectId */
|
|
514
571
|
/* @param {string} provider */
|
|
515
572
|
/* @param {string} appId */
|
|
516
573
|
/* @param {string} secret */
|
|
574
|
+
/* @param {boolean} enabled */
|
|
517
575
|
|
|
518
576
|
let client = !sdk ? await sdkForConsole() : sdk;
|
|
519
577
|
let path = '/projects/{projectId}/oauth2'.replace('{projectId}', projectId);
|
|
@@ -532,6 +590,10 @@ const projectsUpdateOAuth2 = async ({ projectId, provider, appId, secret, parseO
|
|
|
532
590
|
payload['secret'] = secret;
|
|
533
591
|
}
|
|
534
592
|
|
|
593
|
+
if (typeof enabled !== 'undefined') {
|
|
594
|
+
payload['enabled'] = enabled;
|
|
595
|
+
}
|
|
596
|
+
|
|
535
597
|
let response = undefined;
|
|
536
598
|
response = await client.call('patch', path, {
|
|
537
599
|
'content-type': 'application/json',
|
|
@@ -920,16 +982,17 @@ const projectsUpdateWebhookSignature = async ({ projectId, webhookId, parseOutpu
|
|
|
920
982
|
projects
|
|
921
983
|
.command(`list`)
|
|
922
984
|
.description(``)
|
|
923
|
-
.option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name`)
|
|
985
|
+
.option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, teamId`)
|
|
924
986
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
925
987
|
.action(actionRunner(projectsList))
|
|
926
988
|
|
|
927
989
|
projects
|
|
928
990
|
.command(`create`)
|
|
929
991
|
.description(``)
|
|
930
|
-
.requiredOption(`--projectId <projectId>`, `Unique Id. Choose
|
|
992
|
+
.requiredOption(`--projectId <projectId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
931
993
|
.requiredOption(`--name <name>`, `Project name. Max length: 128 chars.`)
|
|
932
994
|
.requiredOption(`--teamId <teamId>`, `Team unique ID.`)
|
|
995
|
+
.option(`--region <region>`, `Project Region.`)
|
|
933
996
|
.option(`--description <description>`, `Project description. Max length: 256 chars.`)
|
|
934
997
|
.option(`--logo <logo>`, `Project logo.`)
|
|
935
998
|
.option(`--url <url>`, `Project URL.`)
|
|
@@ -970,6 +1033,13 @@ projects
|
|
|
970
1033
|
.requiredOption(`--password <password>`, `Your user password for confirmation. Must be at least 8 chars.`)
|
|
971
1034
|
.action(actionRunner(projectsDelete))
|
|
972
1035
|
|
|
1036
|
+
projects
|
|
1037
|
+
.command(`updateAuthDuration`)
|
|
1038
|
+
.description(``)
|
|
1039
|
+
.requiredOption(`--projectId <projectId>`, `Project unique ID.`)
|
|
1040
|
+
.requiredOption(`--duration <duration>`, `Project session length in seconds. Max length: 31536000 seconds.`, parseInteger)
|
|
1041
|
+
.action(actionRunner(projectsUpdateAuthDuration))
|
|
1042
|
+
|
|
973
1043
|
projects
|
|
974
1044
|
.command(`updateAuthLimit`)
|
|
975
1045
|
.description(``)
|
|
@@ -977,6 +1047,13 @@ projects
|
|
|
977
1047
|
.requiredOption(`--limit <limit>`, `Set the max number of users allowed in this project. Use 0 for unlimited.`, parseInteger)
|
|
978
1048
|
.action(actionRunner(projectsUpdateAuthLimit))
|
|
979
1049
|
|
|
1050
|
+
projects
|
|
1051
|
+
.command(`updateAuthSessionsLimit`)
|
|
1052
|
+
.description(``)
|
|
1053
|
+
.requiredOption(`--projectId <projectId>`, `Project unique ID.`)
|
|
1054
|
+
.requiredOption(`--limit <limit>`, `Set the max number of users allowed in this project. Value allowed is between 1-100. Default is 10`, parseInteger)
|
|
1055
|
+
.action(actionRunner(projectsUpdateAuthSessionsLimit))
|
|
1056
|
+
|
|
980
1057
|
projects
|
|
981
1058
|
.command(`updateAuthStatus`)
|
|
982
1059
|
.description(``)
|
|
@@ -1065,6 +1142,7 @@ projects
|
|
|
1065
1142
|
.requiredOption(`--provider <provider>`, `Provider Name`)
|
|
1066
1143
|
.option(`--appId <appId>`, `Provider app ID. Max length: 256 chars.`)
|
|
1067
1144
|
.option(`--secret <secret>`, `Provider secret key. Max length: 512 chars.`)
|
|
1145
|
+
.option(`--enabled <enabled>`, `Provider status. Set to 'false' to disable new session creation.`, parseBool)
|
|
1068
1146
|
.action(actionRunner(projectsUpdateOAuth2))
|
|
1069
1147
|
|
|
1070
1148
|
projects
|
|
@@ -1184,7 +1262,9 @@ module.exports = {
|
|
|
1184
1262
|
projectsGet,
|
|
1185
1263
|
projectsUpdate,
|
|
1186
1264
|
projectsDelete,
|
|
1265
|
+
projectsUpdateAuthDuration,
|
|
1187
1266
|
projectsUpdateAuthLimit,
|
|
1267
|
+
projectsUpdateAuthSessionsLimit,
|
|
1188
1268
|
projectsUpdateAuthStatus,
|
|
1189
1269
|
projectsListDomains,
|
|
1190
1270
|
projectsCreateDomain,
|
package/lib/commands/storage.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const storage = new Command("storage").description(commandDescriptions['storage'])
|
|
13
|
+
const storage = new Command("storage").description(commandDescriptions['storage']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const storageListBuckets = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -570,9 +572,9 @@ storage
|
|
|
570
572
|
storage
|
|
571
573
|
.command(`createBucket`)
|
|
572
574
|
.description(`Create a new storage bucket.`)
|
|
573
|
-
.requiredOption(`--bucketId <bucketId>`, `Unique Id. Choose
|
|
575
|
+
.requiredOption(`--bucketId <bucketId>`, `Unique Id. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
574
576
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
575
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
577
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
576
578
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
577
579
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
578
580
|
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self-hosted setups you can change the max limit by changing the '_APP_STORAGE_LIMIT' environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
|
|
@@ -593,7 +595,7 @@ storage
|
|
|
593
595
|
.description(`Update a storage bucket by its unique ID.`)
|
|
594
596
|
.requiredOption(`--bucketId <bucketId>`, `Bucket unique ID.`)
|
|
595
597
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
596
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
598
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
597
599
|
.option(`--fileSecurity <fileSecurity>`, `Enables configuring permissions for individual file. A user needs one of file or bucket level permissions to access a file. [Learn more about permissions](/docs/permissions).`, parseBool)
|
|
598
600
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
599
601
|
.option(`--maximumFileSize <maximumFileSize>`, `Maximum file size allowed in bytes. Maximum allowed value is 30MB. For self hosted version you can change the limit by changing _APP_STORAGE_LIMIT environment variable. [Learn more about storage environment variables](docs/environment-variables#storage)`, parseInteger)
|
|
@@ -611,7 +613,7 @@ storage
|
|
|
611
613
|
|
|
612
614
|
storage
|
|
613
615
|
.command(`listFiles`)
|
|
614
|
-
.description(`Get a list of all the user files. You can use the query params to filter your results
|
|
616
|
+
.description(`Get a list of all the user files. You can use the query params to filter your results.`)
|
|
615
617
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
616
618
|
.option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
|
|
617
619
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
@@ -621,9 +623,9 @@ storage
|
|
|
621
623
|
.command(`createFile`)
|
|
622
624
|
.description(`Create a new file. Before using this route, you should create a new bucket resource using either a [server integration](/docs/server/storage#storageCreateBucket) API or directly from your Appwrite console. Larger files should be uploaded using multiple requests with the [content-range](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Range) header to send a partial request with a maximum supported chunk of '5MB'. The 'content-range' header values should always be in bytes. When the first request is sent, the server will return the **File** object, and the subsequent part request must include the file's **id** in 'x-appwrite-id' header to allow the server to know that the partial upload is for the existing file and not for a new one. If you're creating a new file using one of the Appwrite SDKs, all the chunking logic will be managed by the SDK internally. `)
|
|
623
625
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
624
|
-
.requiredOption(`--fileId <fileId>`, `File ID. Choose
|
|
626
|
+
.requiredOption(`--fileId <fileId>`, `File ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
625
627
|
.requiredOption(`--file <file>`, `Binary file.`)
|
|
626
|
-
.option(`--permissions <permissions...>`, `An array of permission strings. By default the current user is granted
|
|
628
|
+
.option(`--permissions <permissions...>`, `An array of permission strings. By default, only the current user is granted all permissions. [Learn more about permissions](/docs/permissions).`)
|
|
627
629
|
.action(actionRunner(storageCreateFile))
|
|
628
630
|
|
|
629
631
|
storage
|
|
@@ -638,7 +640,7 @@ storage
|
|
|
638
640
|
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
639
641
|
.requiredOption(`--bucketId <bucketId>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](/docs/server/storage#createBucket).`)
|
|
640
642
|
.requiredOption(`--fileId <fileId>`, `File unique ID.`)
|
|
641
|
-
.option(`--permissions <permissions...>`, `An array of permission string. By default the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
643
|
+
.option(`--permissions <permissions...>`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
642
644
|
.action(actionRunner(storageUpdateFile))
|
|
643
645
|
|
|
644
646
|
storage
|
package/lib/commands/teams.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const teams = new Command("teams").description(commandDescriptions['teams'])
|
|
13
|
+
const teams = new Command("teams").description(commandDescriptions['teams']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const teamsList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -324,7 +326,7 @@ const teamsUpdateMembershipStatus = async ({ teamId, membershipId, userId, secre
|
|
|
324
326
|
|
|
325
327
|
teams
|
|
326
328
|
.command(`list`)
|
|
327
|
-
.description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.
|
|
328
329
|
|
|
329
330
|
In admin mode, this endpoint returns a list of all the teams in the current project. [Learn more about different API modes](/docs/admin).`)
|
|
331
|
+
.description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.`)
|
|
330
332
|
.option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total`)
|
|
331
333
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
332
334
|
.action(actionRunner(teamsList))
|
|
@@ -332,7 +334,7 @@ teams
|
|
|
332
334
|
teams
|
|
333
335
|
.command(`create`)
|
|
334
336
|
.description(`Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.`)
|
|
335
|
-
.requiredOption(`--teamId <teamId>`, `Team ID. Choose
|
|
337
|
+
.requiredOption(`--teamId <teamId>`, `Team ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
336
338
|
.requiredOption(`--name <name>`, `Team name. Max length: 128 chars.`)
|
|
337
339
|
.option(`--roles <roles...>`, `Array of strings. Use this param to set the roles in the team for the user who created it. The default role is **owner**. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`)
|
|
338
340
|
.action(actionRunner(teamsCreate))
|
package/lib/commands/users.js
CHANGED
|
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
12
|
|
|
13
|
-
const users = new Command("users").description(commandDescriptions['users'])
|
|
13
|
+
const users = new Command("users").description(commandDescriptions['users']).configureHelp({
|
|
14
|
+
helpWidth: process.stdout.columns || 80
|
|
15
|
+
})
|
|
14
16
|
|
|
15
17
|
const usersList = async ({ queries, search, parseOutput = true, sdk = undefined}) => {
|
|
16
18
|
/* @param {string[]} queries */
|
|
@@ -790,7 +792,7 @@ users
|
|
|
790
792
|
users
|
|
791
793
|
.command(`create`)
|
|
792
794
|
.description(`Create a new user.`)
|
|
793
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
795
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
794
796
|
.option(`--email <email>`, `User email.`)
|
|
795
797
|
.option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
|
|
796
798
|
.option(`--password <password>`, `Plain text user password. Must be at least 8 chars.`)
|
|
@@ -800,7 +802,7 @@ users
|
|
|
800
802
|
users
|
|
801
803
|
.command(`createArgon2User`)
|
|
802
804
|
.description(`Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
803
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
805
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
804
806
|
.requiredOption(`--email <email>`, `User email.`)
|
|
805
807
|
.requiredOption(`--password <password>`, `User password hashed using Argon2.`)
|
|
806
808
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -809,7 +811,7 @@ users
|
|
|
809
811
|
users
|
|
810
812
|
.command(`createBcryptUser`)
|
|
811
813
|
.description(`Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
812
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
814
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
813
815
|
.requiredOption(`--email <email>`, `User email.`)
|
|
814
816
|
.requiredOption(`--password <password>`, `User password hashed using Bcrypt.`)
|
|
815
817
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -818,7 +820,7 @@ users
|
|
|
818
820
|
users
|
|
819
821
|
.command(`createMD5User`)
|
|
820
822
|
.description(`Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
821
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
823
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
822
824
|
.requiredOption(`--email <email>`, `User email.`)
|
|
823
825
|
.requiredOption(`--password <password>`, `User password hashed using MD5.`)
|
|
824
826
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -827,7 +829,7 @@ users
|
|
|
827
829
|
users
|
|
828
830
|
.command(`createPHPassUser`)
|
|
829
831
|
.description(`Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
830
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
832
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or pass the string 'ID.unique()'to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
831
833
|
.requiredOption(`--email <email>`, `User email.`)
|
|
832
834
|
.requiredOption(`--password <password>`, `User password hashed using PHPass.`)
|
|
833
835
|
.option(`--name <name>`, `User name. Max length: 128 chars.`)
|
|
@@ -836,7 +838,7 @@ users
|
|
|
836
838
|
users
|
|
837
839
|
.command(`createScryptUser`)
|
|
838
840
|
.description(`Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
839
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
841
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
840
842
|
.requiredOption(`--email <email>`, `User email.`)
|
|
841
843
|
.requiredOption(`--password <password>`, `User password hashed using Scrypt.`)
|
|
842
844
|
.requiredOption(`--passwordSalt <passwordSalt>`, `Optional salt used to hash password.`)
|
|
@@ -850,7 +852,7 @@ users
|
|
|
850
852
|
users
|
|
851
853
|
.command(`createScryptModifiedUser`)
|
|
852
854
|
.description(`Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
853
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
855
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
854
856
|
.requiredOption(`--email <email>`, `User email.`)
|
|
855
857
|
.requiredOption(`--password <password>`, `User password hashed using Scrypt Modified.`)
|
|
856
858
|
.requiredOption(`--passwordSalt <passwordSalt>`, `Salt used to hash password.`)
|
|
@@ -862,7 +864,7 @@ users
|
|
|
862
864
|
users
|
|
863
865
|
.command(`createSHAUser`)
|
|
864
866
|
.description(`Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint to create users with a plain text password.`)
|
|
865
|
-
.requiredOption(`--userId <userId>`, `User ID. Choose
|
|
867
|
+
.requiredOption(`--userId <userId>`, `User ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
|
|
866
868
|
.requiredOption(`--email <email>`, `User email.`)
|
|
867
869
|
.requiredOption(`--password <password>`, `User password hashed using SHA.`)
|
|
868
870
|
.option(`--passwordVersion <passwordVersion>`, `Optional SHA version used to hash password. Allowed values are: 'sha1', 'sha224', 'sha256', 'sha384', 'sha512/224', 'sha512/256', 'sha512', 'sha3-224', 'sha3-256', 'sha3-384', 'sha3-512'`)
|
package/lib/config.js
CHANGED
|
@@ -166,6 +166,45 @@ class Local extends Config {
|
|
|
166
166
|
this.set("collections", collections);
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
getTeams() {
|
|
170
|
+
if (!this.has("teams")) {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
return this.get("teams");
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
getTeam($id) {
|
|
177
|
+
if (!this.has("teams")) {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
let teams = this.get("teams");
|
|
182
|
+
for (let i = 0; i < teams.length; i++) {
|
|
183
|
+
if (teams[i]['$id'] == $id) {
|
|
184
|
+
return teams[i];
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
addTeam(props) {
|
|
192
|
+
if (!this.has("teams")) {
|
|
193
|
+
this.set("teams", []);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
let teams = this.get("teams");
|
|
197
|
+
for (let i = 0; i < teams.length; i++) {
|
|
198
|
+
if (teams[i]['$id'] == props['$id']) {
|
|
199
|
+
teams[i] = props;
|
|
200
|
+
this.set("teams", teams);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
teams.push(props);
|
|
205
|
+
this.set("teams", teams);
|
|
206
|
+
}
|
|
207
|
+
|
|
169
208
|
getProject() {
|
|
170
209
|
if (!this.has("projectId") || !this.has("projectName")) {
|
|
171
210
|
return {};
|
package/lib/parser.js
CHANGED
|
@@ -149,6 +149,7 @@ const logo = "\n _ _ _ ___ __ _____
|
|
|
149
149
|
|
|
150
150
|
const commandDescriptions = {
|
|
151
151
|
"account": `The account command allows you to authenticate and manage a user account.`,
|
|
152
|
+
"graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
|
|
152
153
|
"avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
|
|
153
154
|
"databases": `The databases command allows you to create structured collections of documents, query and filter lists of documents.`,
|
|
154
155
|
"deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,
|
package/lib/questions.js
CHANGED
|
@@ -300,6 +300,32 @@ const questionsGetEntrypoint = [
|
|
|
300
300
|
},
|
|
301
301
|
]
|
|
302
302
|
|
|
303
|
+
const questionsDeployTeams = [
|
|
304
|
+
{
|
|
305
|
+
type: "checkbox",
|
|
306
|
+
name: "teams",
|
|
307
|
+
message: "Which teams would you like to deploy?",
|
|
308
|
+
choices: () => {
|
|
309
|
+
let teams = localConfig.getTeams();
|
|
310
|
+
if (teams.length === 0) {
|
|
311
|
+
throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
|
|
312
|
+
}
|
|
313
|
+
let choices = teams.map((team, idx) => {
|
|
314
|
+
return {
|
|
315
|
+
name: `${team.name} (${team['$id']})`,
|
|
316
|
+
value: team.$id
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
return choices;
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
type: "input",
|
|
324
|
+
name: "override",
|
|
325
|
+
message: 'Are you sure you want to override this team? This can lead to loss of data! Type "YES" to confirm.'
|
|
326
|
+
},
|
|
327
|
+
]
|
|
328
|
+
|
|
303
329
|
module.exports = {
|
|
304
330
|
questionsInitProject,
|
|
305
331
|
questionsLogin,
|
|
@@ -307,5 +333,6 @@ module.exports = {
|
|
|
307
333
|
questionsInitCollection,
|
|
308
334
|
questionsDeployFunctions,
|
|
309
335
|
questionsDeployCollections,
|
|
336
|
+
questionsDeployTeams,
|
|
310
337
|
questionsGetEntrypoint
|
|
311
338
|
};
|
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": "1.
|
|
5
|
+
"version": "1.2.1",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"bin": {
|