Skip to content

Commit 76d6878

Browse files
committed
fix: minor bugs
1 parent 795b3f1 commit 76d6878

File tree

10 files changed

+64
-45
lines changed

10 files changed

+64
-45
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Appwrite Command Line SDK
22

33
![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4-
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
4+
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
55
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
66
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
77
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)

docs/examples/messaging/update-email.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ appwrite messaging updateEmail \
1010

1111

1212

13+

lib/client.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Client {
204204

205205
let cookies = response.headers.getSetCookie();
206206
if (cookies && cookies.length > 0) {
207-
globalConfig.setCookie(cookies[0]);
207+
globalConfig.setCookie(cookies.join(";"));
208208
}
209209

210210
const text = await response.text();
@@ -235,4 +235,4 @@ class Client {
235235
}
236236
}
237237

238-
module.exports = Client;
238+
module.exports = Client;

lib/commands/account.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,13 +1679,13 @@ account
16791679

16801680
account
16811681
.command(`createMfaAuthenticator`)
1682-
.description(`Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#verifyAuthenticator) method.`)
1682+
.description(`Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.`)
16831683
.requiredOption(`--type <type>`, `Type of authenticator. Must be 'totp'`)
16841684
.action(actionRunner(accountCreateMfaAuthenticator))
16851685

16861686
account
16871687
.command(`updateMfaAuthenticator`)
1688-
.description(`Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.`)
1688+
.description(`Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add `)
16891689
.requiredOption(`--type <type>`, `Type of authenticator.`)
16901690
.requiredOption(`--otp <otp>`, `Valid verification token.`)
16911691
.action(actionRunner(accountUpdateMfaAuthenticator))

lib/commands/avatars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
8989

9090
/**
9191
* @typedef {Object} AvatarsGetCreditCardRequestParams
92-
* @property {CreditCard} code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
92+
* @property {CreditCard} code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
9393
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
9494
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
9595
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
@@ -384,7 +384,7 @@ avatars
384384
avatars
385385
.command(`getCreditCard`)
386386
.description(`The credit card endpoint will return you the icon of the credit card provider you need. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px. `)
387-
.requiredOption(`--code <code>`, `Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.`)
387+
.requiredOption(`--code <code>`, `Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.`)
388388
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
389389
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
390390
.option(`--quality <quality>`, `Image quality. Pass an integer between 0 to 100. Defaults to 100.`, parseInteger)

lib/commands/deploy.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const {
3737
teamsUpdate,
3838
teamsCreate
3939
} = require("./teams");
40+
const { checkDeployConditions } = require('../utils');
4041

4142
const STEP_SIZE = 100; // Resources
4243
const POOL_DEBOUNCE = 2000; // Milliseconds
@@ -245,6 +246,7 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
245246
functionIds.push(functionId);
246247
} else if (all) {
247248
const functions = localConfig.getFunctions();
249+
checkDeployConditions(localConfig);
248250
if (functions.length === 0) {
249251
throw new Error("No functions found in the current directory.");
250252
}
@@ -535,6 +537,7 @@ const deployCollection = async ({ all, yes } = {}) => {
535537
const collections = [];
536538

537539
if (all) {
540+
checkDeployConditions(localConfig);
538541
if (localConfig.getCollections().length === 0) {
539542
throw new Error("No collections found in the current directory. Run `appwrite init collection` to fetch all your collections.");
540543
}
@@ -757,9 +760,7 @@ const deployBucket = async ({ all, yes } = {}) => {
757760
const configBuckets = localConfig.getBuckets();
758761

759762
if (all) {
760-
if (configBuckets.length === 0) {
761-
throw new Error("No buckets found in the current directory. Run `appwrite init bucket` to fetch all your buckets.");
762-
}
763+
checkDeployConditions(localConfig);
763764
bucketIds.push(...configBuckets.map((b) => b.$id));
764765
}
765766

@@ -844,9 +845,7 @@ const deployTeam = async ({ all, yes } = {}) => {
844845
const configTeams = localConfig.getTeams();
845846

846847
if (all) {
847-
if (configTeams.length === 0) {
848-
throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
849-
}
848+
checkDeployConditions(localConfig);
850849
teamIds.push(...configTeams.map((t) => t.$id));
851850
}
852851

lib/commands/messaging.js

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const messagingListMessages = async ({ queries, search, parseOutput = true, sdk
8585
* @property {string[]} targets List of Targets IDs.
8686
* @property {string[]} cc Array of target IDs to be added as CC.
8787
* @property {string[]} bcc Array of target IDs to be added as BCC.
88-
* @property {string[]} attachments Array of compound bucket IDs to file IDs to be attached to the email.
88+
* @property {string[]} attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as &lt;BUCKET_ID&gt;:&lt;FILE_ID&gt;.
8989
* @property {boolean} draft Is message a draft
9090
* @property {boolean} html Is content of type HTML
9191
* @property {string} scheduledAt Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
@@ -170,14 +170,15 @@ const messagingCreateEmail = async ({ messageId, subject, content, topics, users
170170
* @property {string[]} cc Array of target IDs to be added as CC.
171171
* @property {string[]} bcc Array of target IDs to be added as BCC.
172172
* @property {string} scheduledAt Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.
173+
* @property {string[]} attachments Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as &lt;BUCKET_ID&gt;:&lt;FILE_ID&gt;.
173174
* @property {boolean} parseOutput
174175
* @property {libClient | undefined} sdk
175176
*/
176177

177178
/**
178179
* @param {MessagingUpdateEmailRequestParams} params
179180
*/
180-
const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, parseOutput = true, sdk = undefined}) => {
181+
const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, attachments, parseOutput = true, sdk = undefined}) => {
181182
let client = !sdk ? await sdkForProject() : sdk;
182183
let apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId);
183184
let payload = {};
@@ -216,6 +217,10 @@ const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject
216217
if (typeof scheduledAt !== 'undefined') {
217218
payload['scheduledAt'] = scheduledAt;
218219
}
220+
attachments = attachments === true ? [] : attachments;
221+
if (typeof attachments !== 'undefined') {
222+
payload['attachments'] = attachments;
223+
}
219224

220225
let response = undefined;
221226

@@ -241,7 +246,7 @@ const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject
241246
* @property {string[]} targets List of Targets IDs.
242247
* @property {object} data Additional Data for push notification.
243248
* @property {string} action Action for push notification.
244-
* @property {string} image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.
249+
* @property {string} image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as &lt;BUCKET_ID&gt;:&lt;FILE_ID&gt;.
245250
* @property {string} icon Icon for push notification. Available only for Android and Web Platform.
246251
* @property {string} sound Sound for push notification. Available only for Android and IOS Platform.
247252
* @property {string} color Color for push notification. Available only for Android Platform.
@@ -336,7 +341,7 @@ const messagingCreatePush = async ({ messageId, title, body, topics, users, targ
336341
* @property {string} body Body for push notification.
337342
* @property {object} data Additional Data for push notification.
338343
* @property {string} action Action for push notification.
339-
* @property {string} image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.
344+
* @property {string} image Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as &lt;BUCKET_ID&gt;:&lt;FILE_ID&gt;.
340345
* @property {string} icon Icon for push notification. Available only for Android and Web platforms.
341346
* @property {string} sound Sound for push notification. Available only for Android and iOS platforms.
342347
* @property {string} color Color for push notification. Available only for Android platforms.
@@ -1032,9 +1037,9 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
10321037
* @typedef {Object} MessagingCreateMsg91ProviderRequestParams
10331038
* @property {string} providerId Provider ID. Choose a custom ID or generate a random ID with &#039;ID.unique()&#039;. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can&#039;t start with a special char. Max length is 36 chars.
10341039
* @property {string} name Provider name.
1035-
* @property {string} from Sender Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
1036-
* @property {string} senderId Msg91 Sender ID.
1037-
* @property {string} authKey Msg91 Auth Key.
1040+
* @property {string} templateId Msg91 template ID
1041+
* @property {string} senderId Msg91 sender ID.
1042+
* @property {string} authKey Msg91 auth key.
10381043
* @property {boolean} enabled Set as enabled.
10391044
* @property {boolean} parseOutput
10401045
* @property {libClient | undefined} sdk
@@ -1043,7 +1048,7 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
10431048
/**
10441049
* @param {MessagingCreateMsg91ProviderRequestParams} params
10451050
*/
1046-
const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId, authKey, enabled, parseOutput = true, sdk = undefined}) => {
1051+
const messagingCreateMsg91Provider = async ({ providerId, name, templateId, senderId, authKey, enabled, parseOutput = true, sdk = undefined}) => {
10471052
let client = !sdk ? await sdkForProject() : sdk;
10481053
let apiPath = '/messaging/providers/msg91';
10491054
let payload = {};
@@ -1053,8 +1058,8 @@ const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId,
10531058
if (typeof name !== 'undefined') {
10541059
payload['name'] = name;
10551060
}
1056-
if (typeof from !== 'undefined') {
1057-
payload['from'] = from;
1061+
if (typeof templateId !== 'undefined') {
1062+
payload['templateId'] = templateId;
10581063
}
10591064
if (typeof senderId !== 'undefined') {
10601065
payload['senderId'] = senderId;
@@ -1085,17 +1090,17 @@ const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId,
10851090
* @property {string} providerId Provider ID.
10861091
* @property {string} name Provider name.
10871092
* @property {boolean} enabled Set as enabled.
1088-
* @property {string} senderId Msg91 Sender ID.
1089-
* @property {string} authKey Msg91 Auth Key.
1090-
* @property {string} from Sender number.
1093+
* @property {string} templateId Msg91 template ID.
1094+
* @property {string} senderId Msg91 sender ID.
1095+
* @property {string} authKey Msg91 auth key.
10911096
* @property {boolean} parseOutput
10921097
* @property {libClient | undefined} sdk
10931098
*/
10941099

10951100
/**
10961101
* @param {MessagingUpdateMsg91ProviderRequestParams} params
10971102
*/
1098-
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, senderId, authKey, from, parseOutput = true, sdk = undefined}) => {
1103+
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, templateId, senderId, authKey, parseOutput = true, sdk = undefined}) => {
10991104
let client = !sdk ? await sdkForProject() : sdk;
11001105
let apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId);
11011106
let payload = {};
@@ -1105,15 +1110,15 @@ const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, senderI
11051110
if (typeof enabled !== 'undefined') {
11061111
payload['enabled'] = enabled;
11071112
}
1113+
if (typeof templateId !== 'undefined') {
1114+
payload['templateId'] = templateId;
1115+
}
11081116
if (typeof senderId !== 'undefined') {
11091117
payload['senderId'] = senderId;
11101118
}
11111119
if (typeof authKey !== 'undefined') {
11121120
payload['authKey'] = authKey;
11131121
}
1114-
if (typeof from !== 'undefined') {
1115-
payload['from'] = from;
1116-
}
11171122

11181123
let response = undefined;
11191124

@@ -2297,7 +2302,7 @@ messaging
22972302
.option(`--targets [targets...]`, `List of Targets IDs.`)
22982303
.option(`--cc [cc...]`, `Array of target IDs to be added as CC.`)
22992304
.option(`--bcc [bcc...]`, `Array of target IDs to be added as BCC.`)
2300-
.option(`--attachments [attachments...]`, `Array of compound bucket IDs to file IDs to be attached to the email.`)
2305+
.option(`--attachments [attachments...]`, `Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.`)
23012306
.option(`--draft <draft>`, `Is message a draft`, parseBool)
23022307
.option(`--html <html>`, `Is content of type HTML`, parseBool)
23032308
.option(`--scheduledAt <scheduledAt>`, `Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.`)
@@ -2317,6 +2322,7 @@ messaging
23172322
.option(`--cc [cc...]`, `Array of target IDs to be added as CC.`)
23182323
.option(`--bcc [bcc...]`, `Array of target IDs to be added as BCC.`)
23192324
.option(`--scheduledAt <scheduledAt>`, `Scheduled delivery time for message in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future.`)
2325+
.option(`--attachments [attachments...]`, `Array of compound ID strings of bucket IDs and file IDs to be attached to the email. They should be formatted as <BUCKET_ID>:<FILE_ID>.`)
23202326
.action(actionRunner(messagingUpdateEmail))
23212327

23222328
messaging
@@ -2330,7 +2336,7 @@ messaging
23302336
.option(`--targets [targets...]`, `List of Targets IDs.`)
23312337
.option(`--data <data>`, `Additional Data for push notification.`)
23322338
.option(`--action <action>`, `Action for push notification.`)
2333-
.option(`--image <image>`, `Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.`)
2339+
.option(`--image <image>`, `Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.`)
23342340
.option(`--icon <icon>`, `Icon for push notification. Available only for Android and Web Platform.`)
23352341
.option(`--sound <sound>`, `Sound for push notification. Available only for Android and IOS Platform.`)
23362342
.option(`--color <color>`, `Color for push notification. Available only for Android Platform.`)
@@ -2351,7 +2357,7 @@ messaging
23512357
.option(`--body <body>`, `Body for push notification.`)
23522358
.option(`--data <data>`, `Additional Data for push notification.`)
23532359
.option(`--action <action>`, `Action for push notification.`)
2354-
.option(`--image <image>`, `Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage.`)
2360+
.option(`--image <image>`, `Image for push notification. Must be a compound bucket ID to file ID of a jpeg, png, or bmp image in Appwrite Storage. It should be formatted as <BUCKET_ID>:<FILE_ID>.`)
23552361
.option(`--icon <icon>`, `Icon for push notification. Available only for Android and Web platforms.`)
23562362
.option(`--sound <sound>`, `Sound for push notification. Available only for Android and iOS platforms.`)
23572363
.option(`--color <color>`, `Color for push notification. Available only for Android platforms.`)
@@ -2497,9 +2503,9 @@ messaging
24972503
.description(`Create a new MSG91 provider.`)
24982504
.requiredOption(`--providerId <providerId>`, `Provider 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.`)
24992505
.requiredOption(`--name <name>`, `Provider name.`)
2500-
.option(`--from <from>`, `Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
2501-
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
2502-
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
2506+
.option(`--templateId <templateId>`, `Msg91 template ID`)
2507+
.option(`--senderId <senderId>`, `Msg91 sender ID.`)
2508+
.option(`--authKey <authKey>`, `Msg91 auth key.`)
25032509
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
25042510
.action(actionRunner(messagingCreateMsg91Provider))
25052511

@@ -2509,9 +2515,9 @@ messaging
25092515
.requiredOption(`--providerId <providerId>`, `Provider ID.`)
25102516
.option(`--name <name>`, `Provider name.`)
25112517
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
2512-
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
2513-
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
2514-
.option(`--from <from>`, `Sender number.`)
2518+
.option(`--templateId <templateId>`, `Msg91 template ID.`)
2519+
.option(`--senderId <senderId>`, `Msg91 sender ID.`)
2520+
.option(`--authKey <authKey>`, `Msg91 auth key.`)
25152521
.action(actionRunner(messagingUpdateMsg91Provider))
25162522

25172523
messaging

lib/commands/users.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1823,7 +1823,7 @@ users
18231823

18241824
users
18251825
.command(`createToken`)
1826-
.description(`Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process.`)
1826+
.description(`Returns a token with a secret key for creating a session. Use the user ID and secret and submit a request to the [PUT /account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. `)
18271827
.requiredOption(`--userId <userId>`, `User ID.`)
18281828
.option(`--length <length>`, `Token length in characters. The default length is 6 characters`, parseInteger)
18291829
.option(`--expire <expire>`, `Token expiration period in seconds. The default expiration is 15 minutes.`, parseInteger)

0 commit comments

Comments
 (0)