Skip to content

Commit

Permalink
Merge pull request #127 from appwrite/dev
Browse files Browse the repository at this point in the history
fix: minor bugs
  • Loading branch information
abnegate authored May 17, 2024
2 parents 908cd72 + 76d6878 commit 34b9366
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 45 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Command Line SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.4-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.5.6-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down
1 change: 1 addition & 0 deletions docs/examples/messaging/update-email.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ appwrite messaging updateEmail \




4 changes: 2 additions & 2 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class Client {

let cookies = response.headers.getSetCookie();
if (cookies && cookies.length > 0) {
globalConfig.setCookie(cookies[0]);
globalConfig.setCookie(cookies.join(";"));
}

const text = await response.text();
Expand Down Expand Up @@ -235,4 +235,4 @@ class Client {
}
}

module.exports = Client;
module.exports = Client;
4 changes: 2 additions & 2 deletions lib/commands/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -1679,13 +1679,13 @@ account

account
.command(`createMfaAuthenticator`)
.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.`)
.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.`)
.requiredOption(`--type <type>`, `Type of authenticator. Must be 'totp'`)
.action(actionRunner(accountCreateMfaAuthenticator))

account
.command(`updateMfaAuthenticator`)
.description(`Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#addAuthenticator) method.`)
.description(`Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method. add `)
.requiredOption(`--type <type>`, `Type of authenticator.`)
.requiredOption(`--otp <otp>`, `Valid verification token.`)
.action(actionRunner(accountUpdateMfaAuthenticator))
Expand Down
4 changes: 2 additions & 2 deletions lib/commands/avatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t

/**
* @typedef {Object} AvatarsGetCreditCardRequestParams
* @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.
* @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.
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
Expand Down Expand Up @@ -384,7 +384,7 @@ avatars
avatars
.command(`getCreditCard`)
.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. `)
.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.`)
.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.`)
.option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
.option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
.option(`--quality <quality>`, `Image quality. Pass an integer between 0 to 100. Defaults to 100.`, parseInteger)
Expand Down
11 changes: 5 additions & 6 deletions lib/commands/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ const {
teamsUpdate,
teamsCreate
} = require("./teams");
const { checkDeployConditions } = require('../utils');

const STEP_SIZE = 100; // Resources
const POOL_DEBOUNCE = 2000; // Milliseconds
Expand Down Expand Up @@ -245,6 +246,7 @@ const deployFunction = async ({ functionId, all, yes } = {}) => {
functionIds.push(functionId);
} else if (all) {
const functions = localConfig.getFunctions();
checkDeployConditions(localConfig);
if (functions.length === 0) {
throw new Error("No functions found in the current directory.");
}
Expand Down Expand Up @@ -535,6 +537,7 @@ const deployCollection = async ({ all, yes } = {}) => {
const collections = [];

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

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

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

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

Expand Down
58 changes: 32 additions & 26 deletions lib/commands/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const messagingListMessages = async ({ queries, search, parseOutput = true, sdk
* @property {string[]} targets List of Targets IDs.
* @property {string[]} cc Array of target IDs to be added as CC.
* @property {string[]} bcc Array of target IDs to be added as BCC.
* @property {string[]} attachments Array of compound bucket IDs to file IDs to be attached to the email.
* @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;.
* @property {boolean} draft Is message a draft
* @property {boolean} html Is content of type HTML
* @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.
Expand Down Expand Up @@ -170,14 +170,15 @@ const messagingCreateEmail = async ({ messageId, subject, content, topics, users
* @property {string[]} cc Array of target IDs to be added as CC.
* @property {string[]} bcc Array of target IDs to be added as BCC.
* @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.
* @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;.
* @property {boolean} parseOutput
* @property {libClient | undefined} sdk
*/

/**
* @param {MessagingUpdateEmailRequestParams} params
*/
const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, parseOutput = true, sdk = undefined}) => {
const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject, content, draft, html, cc, bcc, scheduledAt, attachments, parseOutput = true, sdk = undefined}) => {
let client = !sdk ? await sdkForProject() : sdk;
let apiPath = '/messaging/messages/email/{messageId}'.replace('{messageId}', messageId);
let payload = {};
Expand Down Expand Up @@ -216,6 +217,10 @@ const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject
if (typeof scheduledAt !== 'undefined') {
payload['scheduledAt'] = scheduledAt;
}
attachments = attachments === true ? [] : attachments;
if (typeof attachments !== 'undefined') {
payload['attachments'] = attachments;
}

let response = undefined;

Expand All @@ -241,7 +246,7 @@ const messagingUpdateEmail = async ({ messageId, topics, users, targets, subject
* @property {string[]} targets List of Targets IDs.
* @property {object} data Additional Data for push notification.
* @property {string} action Action for push notification.
* @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.
* @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;.
* @property {string} icon Icon for push notification. Available only for Android and Web Platform.
* @property {string} sound Sound for push notification. Available only for Android and IOS Platform.
* @property {string} color Color for push notification. Available only for Android Platform.
Expand Down Expand Up @@ -336,7 +341,7 @@ const messagingCreatePush = async ({ messageId, title, body, topics, users, targ
* @property {string} body Body for push notification.
* @property {object} data Additional Data for push notification.
* @property {string} action Action for push notification.
* @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.
* @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;.
* @property {string} icon Icon for push notification. Available only for Android and Web platforms.
* @property {string} sound Sound for push notification. Available only for Android and iOS platforms.
* @property {string} color Color for push notification. Available only for Android platforms.
Expand Down Expand Up @@ -1032,9 +1037,9 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
* @typedef {Object} MessagingCreateMsg91ProviderRequestParams
* @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.
* @property {string} name Provider name.
* @property {string} from Sender Phone number. Format this number with a leading &#039;+&#039; and a country code, e.g., +16175551212.
* @property {string} senderId Msg91 Sender ID.
* @property {string} authKey Msg91 Auth Key.
* @property {string} templateId Msg91 template ID
* @property {string} senderId Msg91 sender ID.
* @property {string} authKey Msg91 auth key.
* @property {boolean} enabled Set as enabled.
* @property {boolean} parseOutput
* @property {libClient | undefined} sdk
Expand All @@ -1043,7 +1048,7 @@ const messagingUpdateMailgunProvider = async ({ providerId, name, apiKey, domain
/**
* @param {MessagingCreateMsg91ProviderRequestParams} params
*/
const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId, authKey, enabled, parseOutput = true, sdk = undefined}) => {
const messagingCreateMsg91Provider = async ({ providerId, name, templateId, senderId, authKey, enabled, parseOutput = true, sdk = undefined}) => {
let client = !sdk ? await sdkForProject() : sdk;
let apiPath = '/messaging/providers/msg91';
let payload = {};
Expand All @@ -1053,8 +1058,8 @@ const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId,
if (typeof name !== 'undefined') {
payload['name'] = name;
}
if (typeof from !== 'undefined') {
payload['from'] = from;
if (typeof templateId !== 'undefined') {
payload['templateId'] = templateId;
}
if (typeof senderId !== 'undefined') {
payload['senderId'] = senderId;
Expand Down Expand Up @@ -1085,17 +1090,17 @@ const messagingCreateMsg91Provider = async ({ providerId, name, from, senderId,
* @property {string} providerId Provider ID.
* @property {string} name Provider name.
* @property {boolean} enabled Set as enabled.
* @property {string} senderId Msg91 Sender ID.
* @property {string} authKey Msg91 Auth Key.
* @property {string} from Sender number.
* @property {string} templateId Msg91 template ID.
* @property {string} senderId Msg91 sender ID.
* @property {string} authKey Msg91 auth key.
* @property {boolean} parseOutput
* @property {libClient | undefined} sdk
*/

/**
* @param {MessagingUpdateMsg91ProviderRequestParams} params
*/
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, senderId, authKey, from, parseOutput = true, sdk = undefined}) => {
const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, templateId, senderId, authKey, parseOutput = true, sdk = undefined}) => {
let client = !sdk ? await sdkForProject() : sdk;
let apiPath = '/messaging/providers/msg91/{providerId}'.replace('{providerId}', providerId);
let payload = {};
Expand All @@ -1105,15 +1110,15 @@ const messagingUpdateMsg91Provider = async ({ providerId, name, enabled, senderI
if (typeof enabled !== 'undefined') {
payload['enabled'] = enabled;
}
if (typeof templateId !== 'undefined') {
payload['templateId'] = templateId;
}
if (typeof senderId !== 'undefined') {
payload['senderId'] = senderId;
}
if (typeof authKey !== 'undefined') {
payload['authKey'] = authKey;
}
if (typeof from !== 'undefined') {
payload['from'] = from;
}

let response = undefined;

Expand Down Expand Up @@ -2297,7 +2302,7 @@ messaging
.option(`--targets [targets...]`, `List of Targets IDs.`)
.option(`--cc [cc...]`, `Array of target IDs to be added as CC.`)
.option(`--bcc [bcc...]`, `Array of target IDs to be added as BCC.`)
.option(`--attachments [attachments...]`, `Array of compound bucket IDs to file IDs to be attached to the email.`)
.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>.`)
.option(`--draft <draft>`, `Is message a draft`, parseBool)
.option(`--html <html>`, `Is content of type HTML`, parseBool)
.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.`)
Expand All @@ -2317,6 +2322,7 @@ messaging
.option(`--cc [cc...]`, `Array of target IDs to be added as CC.`)
.option(`--bcc [bcc...]`, `Array of target IDs to be added as BCC.`)
.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.`)
.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>.`)
.action(actionRunner(messagingUpdateEmail))

messaging
Expand All @@ -2330,7 +2336,7 @@ messaging
.option(`--targets [targets...]`, `List of Targets IDs.`)
.option(`--data <data>`, `Additional Data for push notification.`)
.option(`--action <action>`, `Action for push notification.`)
.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.`)
.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>.`)
.option(`--icon <icon>`, `Icon for push notification. Available only for Android and Web Platform.`)
.option(`--sound <sound>`, `Sound for push notification. Available only for Android and IOS Platform.`)
.option(`--color <color>`, `Color for push notification. Available only for Android Platform.`)
Expand All @@ -2351,7 +2357,7 @@ messaging
.option(`--body <body>`, `Body for push notification.`)
.option(`--data <data>`, `Additional Data for push notification.`)
.option(`--action <action>`, `Action for push notification.`)
.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.`)
.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>.`)
.option(`--icon <icon>`, `Icon for push notification. Available only for Android and Web platforms.`)
.option(`--sound <sound>`, `Sound for push notification. Available only for Android and iOS platforms.`)
.option(`--color <color>`, `Color for push notification. Available only for Android platforms.`)
Expand Down Expand Up @@ -2497,9 +2503,9 @@ messaging
.description(`Create a new MSG91 provider.`)
.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.`)
.requiredOption(`--name <name>`, `Provider name.`)
.option(`--from <from>`, `Sender Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
.option(`--templateId <templateId>`, `Msg91 template ID`)
.option(`--senderId <senderId>`, `Msg91 sender ID.`)
.option(`--authKey <authKey>`, `Msg91 auth key.`)
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
.action(actionRunner(messagingCreateMsg91Provider))

Expand All @@ -2509,9 +2515,9 @@ messaging
.requiredOption(`--providerId <providerId>`, `Provider ID.`)
.option(`--name <name>`, `Provider name.`)
.option(`--enabled <enabled>`, `Set as enabled.`, parseBool)
.option(`--senderId <senderId>`, `Msg91 Sender ID.`)
.option(`--authKey <authKey>`, `Msg91 Auth Key.`)
.option(`--from <from>`, `Sender number.`)
.option(`--templateId <templateId>`, `Msg91 template ID.`)
.option(`--senderId <senderId>`, `Msg91 sender ID.`)
.option(`--authKey <authKey>`, `Msg91 auth key.`)
.action(actionRunner(messagingUpdateMsg91Provider))

messaging
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ users

users
.command(`createToken`)
.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.`)
.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. `)
.requiredOption(`--userId <userId>`, `User ID.`)
.option(`--length <length>`, `Token length in characters. The default length is 6 characters`, parseInteger)
.option(`--expire <expire>`, `Token expiration period in seconds. The default expiration is 15 minutes.`, parseInteger)
Expand Down
Loading

0 comments on commit 34b9366

Please sign in to comment.