appwrite-cli 1.1.1 → 2.0.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/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/create.md +1 -1
- package/docs/examples/account/update-password.md +1 -1
- package/docs/examples/account/update-phone.md +1 -1
- package/docs/examples/console/variables.md +1 -0
- package/docs/examples/databases/create-relationship-attribute.md +9 -0
- package/docs/examples/databases/get-document.md +2 -1
- package/docs/examples/databases/update-boolean-attribute.md +6 -0
- package/docs/examples/databases/update-datetime-attribute.md +6 -0
- package/docs/examples/databases/update-email-attribute.md +6 -0
- package/docs/examples/databases/update-enum-attribute.md +7 -0
- package/docs/examples/databases/update-float-attribute.md +8 -0
- package/docs/examples/databases/update-integer-attribute.md +8 -0
- package/docs/examples/databases/update-ip-attribute.md +6 -0
- package/docs/examples/databases/update-relationship-attribute.md +5 -0
- package/docs/examples/databases/update-string-attribute.md +6 -0
- package/docs/examples/databases/update-url-attribute.md +6 -0
- package/docs/examples/functions/{retry-build.md → create-build.md} +1 -1
- package/docs/examples/functions/create.md +1 -1
- package/docs/examples/functions/update.md +1 -1
- package/docs/examples/graphql/mutation.md +2 -0
- package/docs/examples/graphql/query.md +2 -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-password-dictionary.md +3 -0
- package/docs/examples/projects/update-auth-password-history.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/create-membership.md +3 -1
- package/docs/examples/teams/get-prefs.md +2 -0
- package/docs/examples/teams/{update.md → update-name.md} +1 -1
- package/docs/examples/teams/update-prefs.md +3 -0
- package/docs/examples/users/update-password.md +1 -1
- package/docs/examples/users/update-phone.md +1 -1
- package/index.js +16 -1
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +7 -7
- package/lib/commands/account.js +46 -11
- package/lib/commands/avatars.js +3 -1
- package/lib/commands/console.js +44 -0
- package/lib/commands/databases.js +735 -109
- package/lib/commands/deploy.js +350 -141
- package/lib/commands/functions.js +44 -16
- package/lib/commands/generic.js +15 -3
- package/lib/commands/graphql.js +85 -0
- package/lib/commands/health.js +3 -1
- package/lib/commands/init.js +224 -162
- package/lib/commands/locale.js +3 -1
- package/lib/commands/projects.js +223 -9
- package/lib/commands/storage.js +43 -13
- package/lib/commands/teams.js +107 -19
- package/lib/commands/users.js +62 -11
- package/lib/config.js +122 -5
- package/lib/parser.js +7 -2
- package/lib/questions.js +311 -257
- package/package.json +1 -1
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 */
|
|
@@ -56,42 +58,54 @@ const storageCreateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
56
58
|
let payload = {};
|
|
57
59
|
|
|
58
60
|
/** Body Params */
|
|
61
|
+
|
|
59
62
|
if (typeof bucketId !== 'undefined') {
|
|
60
63
|
payload['bucketId'] = bucketId;
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
|
|
63
67
|
if (typeof name !== 'undefined') {
|
|
64
68
|
payload['name'] = name;
|
|
65
69
|
}
|
|
66
70
|
|
|
71
|
+
permissions = permissions === true ? [] : permissions;
|
|
72
|
+
|
|
67
73
|
if (typeof permissions !== 'undefined') {
|
|
68
74
|
payload['permissions'] = permissions;
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
|
|
71
78
|
if (typeof fileSecurity !== 'undefined') {
|
|
72
79
|
payload['fileSecurity'] = fileSecurity;
|
|
73
80
|
}
|
|
74
81
|
|
|
82
|
+
|
|
75
83
|
if (typeof enabled !== 'undefined') {
|
|
76
84
|
payload['enabled'] = enabled;
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
|
|
79
88
|
if (typeof maximumFileSize !== 'undefined') {
|
|
80
89
|
payload['maximumFileSize'] = maximumFileSize;
|
|
81
90
|
}
|
|
82
91
|
|
|
92
|
+
allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
|
|
93
|
+
|
|
83
94
|
if (typeof allowedFileExtensions !== 'undefined') {
|
|
84
95
|
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
85
96
|
}
|
|
86
97
|
|
|
98
|
+
|
|
87
99
|
if (typeof compression !== 'undefined') {
|
|
88
100
|
payload['compression'] = compression;
|
|
89
101
|
}
|
|
90
102
|
|
|
103
|
+
|
|
91
104
|
if (typeof encryption !== 'undefined') {
|
|
92
105
|
payload['encryption'] = encryption;
|
|
93
106
|
}
|
|
94
107
|
|
|
108
|
+
|
|
95
109
|
if (typeof antivirus !== 'undefined') {
|
|
96
110
|
payload['antivirus'] = antivirus;
|
|
97
111
|
}
|
|
@@ -143,38 +157,49 @@ const storageUpdateBucket = async ({ bucketId, name, permissions, fileSecurity,
|
|
|
143
157
|
let payload = {};
|
|
144
158
|
|
|
145
159
|
/** Body Params */
|
|
160
|
+
|
|
146
161
|
if (typeof name !== 'undefined') {
|
|
147
162
|
payload['name'] = name;
|
|
148
163
|
}
|
|
149
164
|
|
|
165
|
+
permissions = permissions === true ? [] : permissions;
|
|
166
|
+
|
|
150
167
|
if (typeof permissions !== 'undefined') {
|
|
151
168
|
payload['permissions'] = permissions;
|
|
152
169
|
}
|
|
153
170
|
|
|
171
|
+
|
|
154
172
|
if (typeof fileSecurity !== 'undefined') {
|
|
155
173
|
payload['fileSecurity'] = fileSecurity;
|
|
156
174
|
}
|
|
157
175
|
|
|
176
|
+
|
|
158
177
|
if (typeof enabled !== 'undefined') {
|
|
159
178
|
payload['enabled'] = enabled;
|
|
160
179
|
}
|
|
161
180
|
|
|
181
|
+
|
|
162
182
|
if (typeof maximumFileSize !== 'undefined') {
|
|
163
183
|
payload['maximumFileSize'] = maximumFileSize;
|
|
164
184
|
}
|
|
165
185
|
|
|
186
|
+
allowedFileExtensions = allowedFileExtensions === true ? [] : allowedFileExtensions;
|
|
187
|
+
|
|
166
188
|
if (typeof allowedFileExtensions !== 'undefined') {
|
|
167
189
|
payload['allowedFileExtensions'] = allowedFileExtensions;
|
|
168
190
|
}
|
|
169
191
|
|
|
192
|
+
|
|
170
193
|
if (typeof compression !== 'undefined') {
|
|
171
194
|
payload['compression'] = compression;
|
|
172
195
|
}
|
|
173
196
|
|
|
197
|
+
|
|
174
198
|
if (typeof encryption !== 'undefined') {
|
|
175
199
|
payload['encryption'] = encryption;
|
|
176
200
|
}
|
|
177
201
|
|
|
202
|
+
|
|
178
203
|
if (typeof antivirus !== 'undefined') {
|
|
179
204
|
payload['antivirus'] = antivirus;
|
|
180
205
|
}
|
|
@@ -248,6 +273,7 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
248
273
|
let payload = {};
|
|
249
274
|
|
|
250
275
|
/** Body Params */
|
|
276
|
+
|
|
251
277
|
if (typeof fileId !== 'undefined') {
|
|
252
278
|
payload['fileId'] = fileId;
|
|
253
279
|
}
|
|
@@ -257,6 +283,8 @@ const storageCreateFile = async ({ bucketId, fileId, file, permissions, parseOut
|
|
|
257
283
|
payload['file'] = filePath;
|
|
258
284
|
}
|
|
259
285
|
|
|
286
|
+
permissions = permissions === true ? [] : permissions;
|
|
287
|
+
|
|
260
288
|
if (typeof permissions !== 'undefined') {
|
|
261
289
|
payload['permissions'] = permissions;
|
|
262
290
|
}
|
|
@@ -359,6 +387,8 @@ const storageUpdateFile = async ({ bucketId, fileId, permissions, parseOutput =
|
|
|
359
387
|
let payload = {};
|
|
360
388
|
|
|
361
389
|
/** Body Params */
|
|
390
|
+
permissions = permissions === true ? [] : permissions;
|
|
391
|
+
|
|
362
392
|
if (typeof permissions !== 'undefined') {
|
|
363
393
|
payload['permissions'] = permissions;
|
|
364
394
|
}
|
|
@@ -563,20 +593,20 @@ const storageGetBucketUsage = async ({ bucketId, range, parseOutput = true, sdk
|
|
|
563
593
|
storage
|
|
564
594
|
.command(`listBuckets`)
|
|
565
595
|
.description(`Get a list of all the storage buckets. You can use the query params to filter your results.`)
|
|
566
|
-
.option(`--queries
|
|
596
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: enabled, name, fileSecurity, maximumFileSize, encryption, antivirus`)
|
|
567
597
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
568
598
|
.action(actionRunner(storageListBuckets))
|
|
569
599
|
|
|
570
600
|
storage
|
|
571
601
|
.command(`createBucket`)
|
|
572
602
|
.description(`Create a new storage bucket.`)
|
|
573
|
-
.requiredOption(`--bucketId <bucketId>`, `Unique Id. Choose
|
|
603
|
+
.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
604
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
575
|
-
.option(`--permissions
|
|
605
|
+
.option(`--permissions [permissions...]`, `An array of permission strings. By default, no user is granted with any permissions. [Learn more about permissions](/docs/permissions).`)
|
|
576
606
|
.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
607
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
578
608
|
.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)
|
|
579
|
-
.option(`--allowedFileExtensions
|
|
609
|
+
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
580
610
|
.option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
581
611
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
582
612
|
.option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
|
|
@@ -593,11 +623,11 @@ storage
|
|
|
593
623
|
.description(`Update a storage bucket by its unique ID.`)
|
|
594
624
|
.requiredOption(`--bucketId <bucketId>`, `Bucket unique ID.`)
|
|
595
625
|
.requiredOption(`--name <name>`, `Bucket name`)
|
|
596
|
-
.option(`--permissions
|
|
626
|
+
.option(`--permissions [permissions...]`, `An array of permission strings. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
597
627
|
.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
628
|
.option(`--enabled <enabled>`, `Is bucket enabled?`, parseBool)
|
|
599
629
|
.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)
|
|
600
|
-
.option(`--allowedFileExtensions
|
|
630
|
+
.option(`--allowedFileExtensions [allowedFileExtensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`)
|
|
601
631
|
.option(`--compression <compression>`, `Compression algorithm choosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`)
|
|
602
632
|
.option(`--encryption <encryption>`, `Is encryption enabled? For file size above 20MB encryption is skipped even if it's enabled`, parseBool)
|
|
603
633
|
.option(`--antivirus <antivirus>`, `Is virus scanning enabled? For file size above 20MB AntiVirus scanning is skipped even if it's enabled`, parseBool)
|
|
@@ -611,9 +641,9 @@ storage
|
|
|
611
641
|
|
|
612
642
|
storage
|
|
613
643
|
.command(`listFiles`)
|
|
614
|
-
.description(`Get a list of all the user files. You can use the query params to filter your results
|
|
644
|
+
.description(`Get a list of all the user files. You can use the query params to filter your results.`)
|
|
615
645
|
.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
|
-
.option(`--queries
|
|
646
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, signature, mimeType, sizeOriginal, chunksTotal, chunksUploaded`)
|
|
617
647
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
618
648
|
.action(actionRunner(storageListFiles))
|
|
619
649
|
|
|
@@ -621,9 +651,9 @@ storage
|
|
|
621
651
|
.command(`createFile`)
|
|
622
652
|
.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
653
|
.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
|
|
625
|
-
.requiredOption(`--file <file>`, `Binary file.`)
|
|
626
|
-
.option(`--permissions
|
|
654
|
+
.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.`)
|
|
655
|
+
.requiredOption(`--file <file>`, `Binary file. Appwrite SDKs provide helpers to handle file input. [Learn about file input](/docs/storage#file-input).`)
|
|
656
|
+
.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
657
|
.action(actionRunner(storageCreateFile))
|
|
628
658
|
|
|
629
659
|
storage
|
|
@@ -638,7 +668,7 @@ storage
|
|
|
638
668
|
.description(`Update a file by its unique ID. Only users with write permissions have access to update this resource.`)
|
|
639
669
|
.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
670
|
.requiredOption(`--fileId <fileId>`, `File unique ID.`)
|
|
641
|
-
.option(`--permissions
|
|
671
|
+
.option(`--permissions [permissions...]`, `An array of permission string. By default, the current permissions are inherited. [Learn more about permissions](/docs/permissions).`)
|
|
642
672
|
.action(actionRunner(storageUpdateFile))
|
|
643
673
|
|
|
644
674
|
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 */
|
|
@@ -49,14 +51,18 @@ const teamsCreate = async ({ teamId, name, roles, parseOutput = true, sdk = unde
|
|
|
49
51
|
let payload = {};
|
|
50
52
|
|
|
51
53
|
/** Body Params */
|
|
54
|
+
|
|
52
55
|
if (typeof teamId !== 'undefined') {
|
|
53
56
|
payload['teamId'] = teamId;
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
|
|
56
60
|
if (typeof name !== 'undefined') {
|
|
57
61
|
payload['name'] = name;
|
|
58
62
|
}
|
|
59
63
|
|
|
64
|
+
roles = roles === true ? [] : roles;
|
|
65
|
+
|
|
60
66
|
if (typeof roles !== 'undefined') {
|
|
61
67
|
payload['roles'] = roles;
|
|
62
68
|
}
|
|
@@ -91,7 +97,7 @@ const teamsGet = async ({ teamId, parseOutput = true, sdk = undefined}) => {
|
|
|
91
97
|
return response;
|
|
92
98
|
}
|
|
93
99
|
|
|
94
|
-
const
|
|
100
|
+
const teamsUpdateName = async ({ teamId, name, parseOutput = true, sdk = undefined}) => {
|
|
95
101
|
/* @param {string} teamId */
|
|
96
102
|
/* @param {string} name */
|
|
97
103
|
|
|
@@ -100,6 +106,7 @@ const teamsUpdate = async ({ teamId, name, parseOutput = true, sdk = undefined})
|
|
|
100
106
|
let payload = {};
|
|
101
107
|
|
|
102
108
|
/** Body Params */
|
|
109
|
+
|
|
103
110
|
if (typeof name !== 'undefined') {
|
|
104
111
|
payload['name'] = name;
|
|
105
112
|
}
|
|
@@ -186,11 +193,13 @@ const teamsListMemberships = async ({ teamId, queries, search, parseOutput = tru
|
|
|
186
193
|
return response;
|
|
187
194
|
}
|
|
188
195
|
|
|
189
|
-
const teamsCreateMembership = async ({ teamId, email,
|
|
196
|
+
const teamsCreateMembership = async ({ teamId, roles, url, email, userId, phone, name, parseOutput = true, sdk = undefined}) => {
|
|
190
197
|
/* @param {string} teamId */
|
|
191
|
-
/* @param {string} email */
|
|
192
198
|
/* @param {string[]} roles */
|
|
193
199
|
/* @param {string} url */
|
|
200
|
+
/* @param {string} email */
|
|
201
|
+
/* @param {string} userId */
|
|
202
|
+
/* @param {string} phone */
|
|
194
203
|
/* @param {string} name */
|
|
195
204
|
|
|
196
205
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
@@ -198,18 +207,33 @@ const teamsCreateMembership = async ({ teamId, email, roles, url, name, parseOut
|
|
|
198
207
|
let payload = {};
|
|
199
208
|
|
|
200
209
|
/** Body Params */
|
|
210
|
+
|
|
201
211
|
if (typeof email !== 'undefined') {
|
|
202
212
|
payload['email'] = email;
|
|
203
213
|
}
|
|
204
214
|
|
|
215
|
+
|
|
216
|
+
if (typeof userId !== 'undefined') {
|
|
217
|
+
payload['userId'] = userId;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
if (typeof phone !== 'undefined') {
|
|
222
|
+
payload['phone'] = phone;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
roles = roles === true ? [] : roles;
|
|
226
|
+
|
|
205
227
|
if (typeof roles !== 'undefined') {
|
|
206
228
|
payload['roles'] = roles;
|
|
207
229
|
}
|
|
208
230
|
|
|
231
|
+
|
|
209
232
|
if (typeof url !== 'undefined') {
|
|
210
233
|
payload['url'] = url;
|
|
211
234
|
}
|
|
212
235
|
|
|
236
|
+
|
|
213
237
|
if (typeof name !== 'undefined') {
|
|
214
238
|
payload['name'] = name;
|
|
215
239
|
}
|
|
@@ -255,6 +279,8 @@ const teamsUpdateMembershipRoles = async ({ teamId, membershipId, roles, parseOu
|
|
|
255
279
|
let payload = {};
|
|
256
280
|
|
|
257
281
|
/** Body Params */
|
|
282
|
+
roles = roles === true ? [] : roles;
|
|
283
|
+
|
|
258
284
|
if (typeof roles !== 'undefined') {
|
|
259
285
|
payload['roles'] = roles;
|
|
260
286
|
}
|
|
@@ -301,10 +327,12 @@ const teamsUpdateMembershipStatus = async ({ teamId, membershipId, userId, secre
|
|
|
301
327
|
let payload = {};
|
|
302
328
|
|
|
303
329
|
/** Body Params */
|
|
330
|
+
|
|
304
331
|
if (typeof userId !== 'undefined') {
|
|
305
332
|
payload['userId'] = userId;
|
|
306
333
|
}
|
|
307
334
|
|
|
335
|
+
|
|
308
336
|
if (typeof secret !== 'undefined') {
|
|
309
337
|
payload['secret'] = secret;
|
|
310
338
|
}
|
|
@@ -321,20 +349,63 @@ const teamsUpdateMembershipStatus = async ({ teamId, membershipId, userId, secre
|
|
|
321
349
|
return response;
|
|
322
350
|
}
|
|
323
351
|
|
|
352
|
+
const teamsGetPrefs = async ({ teamId, parseOutput = true, sdk = undefined}) => {
|
|
353
|
+
/* @param {string} teamId */
|
|
354
|
+
|
|
355
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
356
|
+
let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
|
|
357
|
+
let payload = {};
|
|
358
|
+
let response = undefined;
|
|
359
|
+
response = await client.call('get', path, {
|
|
360
|
+
'content-type': 'application/json',
|
|
361
|
+
}, payload);
|
|
362
|
+
|
|
363
|
+
if (parseOutput) {
|
|
364
|
+
parse(response)
|
|
365
|
+
success()
|
|
366
|
+
}
|
|
367
|
+
return response;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
const teamsUpdatePrefs = async ({ teamId, prefs, parseOutput = true, sdk = undefined}) => {
|
|
371
|
+
/* @param {string} teamId */
|
|
372
|
+
/* @param {object} prefs */
|
|
373
|
+
|
|
374
|
+
let client = !sdk ? await sdkForProject() : sdk;
|
|
375
|
+
let path = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
|
|
376
|
+
let payload = {};
|
|
377
|
+
|
|
378
|
+
/** Body Params */
|
|
379
|
+
if (typeof prefs !== 'undefined') {
|
|
380
|
+
payload['prefs'] = JSON.parse(prefs);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
let response = undefined;
|
|
384
|
+
response = await client.call('put', path, {
|
|
385
|
+
'content-type': 'application/json',
|
|
386
|
+
}, payload);
|
|
387
|
+
|
|
388
|
+
if (parseOutput) {
|
|
389
|
+
parse(response)
|
|
390
|
+
success()
|
|
391
|
+
}
|
|
392
|
+
return response;
|
|
393
|
+
}
|
|
394
|
+
|
|
324
395
|
|
|
325
396
|
teams
|
|
326
397
|
.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
398
|
|
|
329
399
|
In admin mode, this endpoint returns a list of all the teams in the current project. [Learn more about different API modes](/docs/admin).`)
|
|
330
|
-
.
|
|
400
|
+
.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.`)
|
|
401
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, total`)
|
|
331
402
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
332
403
|
.action(actionRunner(teamsList))
|
|
333
404
|
|
|
334
405
|
teams
|
|
335
406
|
.command(`create`)
|
|
336
407
|
.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.`)
|
|
337
|
-
.requiredOption(`--teamId <teamId>`, `Team ID. Choose
|
|
408
|
+
.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.`)
|
|
338
409
|
.requiredOption(`--name <name>`, `Team name. Max length: 128 chars.`)
|
|
339
|
-
.option(`--roles
|
|
410
|
+
.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.`)
|
|
340
411
|
.action(actionRunner(teamsCreate))
|
|
341
412
|
|
|
342
413
|
teams
|
|
@@ -344,11 +415,11 @@ teams
|
|
|
344
415
|
.action(actionRunner(teamsGet))
|
|
345
416
|
|
|
346
417
|
teams
|
|
347
|
-
.command(`
|
|
348
|
-
.description(`Update
|
|
418
|
+
.command(`updateName`)
|
|
419
|
+
.description(`Update the team's name by its unique ID.`)
|
|
349
420
|
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
350
421
|
.requiredOption(`--name <name>`, `New team name. Max length: 128 chars.`)
|
|
351
|
-
.action(actionRunner(
|
|
422
|
+
.action(actionRunner(teamsUpdateName))
|
|
352
423
|
|
|
353
424
|
teams
|
|
354
425
|
.command(`delete`)
|
|
@@ -360,24 +431,26 @@ teams
|
|
|
360
431
|
.command(`listLogs`)
|
|
361
432
|
.description(`Get the team activity logs list by its unique ID.`)
|
|
362
433
|
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
363
|
-
.option(`--queries
|
|
434
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset`)
|
|
364
435
|
.action(actionRunner(teamsListLogs))
|
|
365
436
|
|
|
366
437
|
teams
|
|
367
438
|
.command(`listMemberships`)
|
|
368
439
|
.description(`Use this endpoint to list a team's members using the team's ID. All team members have read access to this endpoint.`)
|
|
369
440
|
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
370
|
-
.option(`--queries
|
|
441
|
+
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, teamId, invited, joined, confirm`)
|
|
371
442
|
.option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
|
|
372
443
|
.action(actionRunner(teamsListMemberships))
|
|
373
444
|
|
|
374
445
|
teams
|
|
375
446
|
.command(`createMembership`)
|
|
376
|
-
.description(`Invite a new member to join your team. If initiated from
|
|
447
|
+
.description(`Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn't exist. If initiated from a Server SDK, the new member will be added automatically to the team. You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID > email > phone number if you provide more than one of these parameters. Use the 'url' parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](/docs/client/teams#teamsUpdateMembershipStatus) endpoint to allow the user to accept the invitation to the team. Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console. `)
|
|
377
448
|
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
378
|
-
.requiredOption(`--
|
|
379
|
-
.requiredOption(`--roles <roles...>`, `Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`)
|
|
449
|
+
.requiredOption(`--roles [roles...]`, `Array of strings. Use this param to set the user roles in the team. A role can be any string. Learn more about [roles and permissions](/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`)
|
|
380
450
|
.requiredOption(`--url <url>`, `URL to redirect the user back to your app from the invitation email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
|
|
451
|
+
.option(`--email <email>`, `Email of the new team member.`)
|
|
452
|
+
.option(`--userId <userId>`, `ID of the user to be added to a team.`)
|
|
453
|
+
.option(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
|
|
381
454
|
.option(`--name <name>`, `Name of the new team member. Max length: 128 chars.`)
|
|
382
455
|
.action(actionRunner(teamsCreateMembership))
|
|
383
456
|
|
|
@@ -393,7 +466,7 @@ teams
|
|
|
393
466
|
.description(`Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](/docs/permissions).`)
|
|
394
467
|
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
395
468
|
.requiredOption(`--membershipId <membershipId>`, `Membership ID.`)
|
|
396
|
-
.requiredOption(`--roles
|
|
469
|
+
.requiredOption(`--roles [roles...]`, `An array of strings. Use this param to set the user's roles in the team. A role can be any string. Learn more about [roles and permissions](https://appwrite.io/docs/permissions). Maximum of 100 roles are allowed, each 32 characters long.`)
|
|
397
470
|
.action(actionRunner(teamsUpdateMembershipRoles))
|
|
398
471
|
|
|
399
472
|
teams
|
|
@@ -412,13 +485,26 @@ teams
|
|
|
412
485
|
.requiredOption(`--secret <secret>`, `Secret key.`)
|
|
413
486
|
.action(actionRunner(teamsUpdateMembershipStatus))
|
|
414
487
|
|
|
488
|
+
teams
|
|
489
|
+
.command(`getPrefs`)
|
|
490
|
+
.description(`Get the team's shared preferences by its unique ID. If a preference doesn't need to be shared by all team members, prefer storing them in [user preferences](/docs/client/account#accountGetPrefs).`)
|
|
491
|
+
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
492
|
+
.action(actionRunner(teamsGetPrefs))
|
|
493
|
+
|
|
494
|
+
teams
|
|
495
|
+
.command(`updatePrefs`)
|
|
496
|
+
.description(`Update the team's preferences by its unique ID. The object you pass is stored as is and replaces any previous value. The maximum allowed prefs size is 64kB and throws an error if exceeded.`)
|
|
497
|
+
.requiredOption(`--teamId <teamId>`, `Team ID.`)
|
|
498
|
+
.requiredOption(`--prefs <prefs>`, `Prefs key-value JSON object.`)
|
|
499
|
+
.action(actionRunner(teamsUpdatePrefs))
|
|
500
|
+
|
|
415
501
|
|
|
416
502
|
module.exports = {
|
|
417
503
|
teams,
|
|
418
504
|
teamsList,
|
|
419
505
|
teamsCreate,
|
|
420
506
|
teamsGet,
|
|
421
|
-
|
|
507
|
+
teamsUpdateName,
|
|
422
508
|
teamsDelete,
|
|
423
509
|
teamsListLogs,
|
|
424
510
|
teamsListMemberships,
|
|
@@ -426,5 +512,7 @@ module.exports = {
|
|
|
426
512
|
teamsGetMembership,
|
|
427
513
|
teamsUpdateMembershipRoles,
|
|
428
514
|
teamsDeleteMembership,
|
|
429
|
-
teamsUpdateMembershipStatus
|
|
515
|
+
teamsUpdateMembershipStatus,
|
|
516
|
+
teamsGetPrefs,
|
|
517
|
+
teamsUpdatePrefs
|
|
430
518
|
};
|