appwrite-cli 0.15.0 → 0.17.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.
@@ -13,7 +13,6 @@ jobs:
13
13
  registry-url: 'https://registry.npmjs.org'
14
14
  - name: Setup binfmt with QEMU
15
15
  run: |
16
- sudo apt update
17
16
  sudo apt install qemu binfmt-support qemu-user-static
18
17
  update-binfmts --display
19
18
  - name: Setup ldid
package/README.md CHANGED
@@ -1,12 +1,12 @@
1
1
  # Appwrite Command Line SDK
2
2
 
3
3
  ![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
4
- ![Version](https://img.shields.io/badge/api%20version-0.13.0-blue.svg?style=flat-square)
4
+ ![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square)
5
5
  [![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
6
6
  [![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
7
7
  [![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
8
8
 
9
- **This SDK is compatible with Appwrite server version latest. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
9
+ **This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-cli/releases).**
10
10
 
11
11
  Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
12
12
 
@@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using
29
29
 
30
30
  ```sh
31
31
  $ appwrite -v
32
- 0.15.0
32
+ 0.17.1
33
33
  ```
34
34
 
35
35
  ### Install using prebuilt binaries
@@ -58,7 +58,7 @@ $ iwr -useb https://appwrite.io/cli/install.ps1 | iex
58
58
  Once the installation completes, you can verify your install using
59
59
  ```
60
60
  $ appwrite -v
61
- 0.15.0
61
+ 0.17.1
62
62
  ```
63
63
 
64
64
  ## Getting Started
@@ -0,0 +1 @@
1
+ appwrite account updateStatus
@@ -0,0 +1,4 @@
1
+ appwrite teams listLogs \
2
+ --teamId [TEAM_ID] \
3
+
4
+
@@ -0,0 +1,2 @@
1
+ appwrite users getMemberships \
2
+ --userId [USER_ID]
package/install.ps1 CHANGED
@@ -13,14 +13,17 @@
13
13
  # You can use "View source" of this page to see the full script.
14
14
 
15
15
  # REPO
16
- $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.15.0/appwrite-cli-win-x64.exe"
17
- $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.15.0/appwrite-cli-win-arm64.exe"
16
+ $GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.17.1/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.17.1/appwrite-cli-win-arm64.exe"
18
+
19
+ $APPWRITE_BINARY_NAME = "appwrite.exe"
18
20
 
19
21
  # Appwrite download directory
20
- $APPWRITE_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath "appwrite.exe"
22
+ $APPWRITE_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath $APPWRITE_BINARY_NAME
21
23
 
22
24
  # Appwrite CLI location
23
25
  $APPWRITE_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Appwrite"
26
+ $APPWRITE_INSTALL_PATH = Join-Path -Path "$APPWRITE_INSTALL_DIR" -ChildPath "$APPWRITE_BINARY_NAME"
24
27
 
25
28
  $USER_PATH_ENV_VAR = [Environment]::GetEnvironmentVariable("PATH", "User")
26
29
 
@@ -58,9 +61,9 @@ function DownloadBinary {
58
61
  } else {
59
62
  Invoke-WebRequest -Uri $GITHUB_x64_URL -OutFile $APPWRITE_DOWNLOAD_DIR
60
63
  }
61
-
62
64
 
63
- Move-Item $APPWRITE_DOWNLOAD_DIR $APPWRITE_INSTALL_DIR
65
+ New-Item -ItemType Directory -Path $APPWRITE_INSTALL_DIR
66
+ Move-Item $APPWRITE_DOWNLOAD_DIR $APPWRITE_INSTALL_PATH
64
67
  }
65
68
 
66
69
 
@@ -71,6 +74,7 @@ function Install {
71
74
  Write-Host "Skipping to add Appwrite to User Path."
72
75
  } else {
73
76
  [System.Environment]::SetEnvironmentVariable("PATH", $USER_PATH_ENV_VAR + ";$APPWRITE_INSTALL_DIR", "User")
77
+ $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User")
74
78
  }
75
79
  }
76
80
 
package/install.sh CHANGED
@@ -97,7 +97,7 @@ printSuccess() {
97
97
  downloadBinary() {
98
98
  echo "[2/4] Downloading executable for $OS ($ARCH) ..."
99
99
 
100
- GITHUB_LATEST_VERSION="0.15.0"
100
+ GITHUB_LATEST_VERSION="0.17.1"
101
101
  GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
102
102
  GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"
103
103
 
package/lib/client.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const os = require('os');
2
2
  const axios = require("axios");
3
+ const JSONbig = require("json-bigint")({ storeAsString: false });
3
4
  const FormData = require("form-data");
4
5
  const AppwriteException = require("./exception.js");
5
6
  const { globalConfig } = require("./config.js");
@@ -11,9 +12,9 @@ class Client {
11
12
  this.endpoint = 'https://HOSTNAME/v1';
12
13
  this.headers = {
13
14
  'content-type': '',
14
- 'x-sdk-version': 'appwrite:cli:0.15.0',
15
- 'User-Agent' : `AppwriteCLI/0.15.0 (${os.type()} ${os.version()}; ${os.arch()})`,
16
- 'X-Appwrite-Response-Format' : '0.13.0',
15
+ 'x-sdk-version': 'appwrite:cli:0.17.1',
16
+ 'User-Agent' : `AppwriteCLI/0.17.1 (${os.type()} ${os.version()}; ${os.arch()})`,
17
+ 'X-Appwrite-Response-Format' : '0.14.0',
17
18
  };
18
19
  }
19
20
 
@@ -180,11 +181,9 @@ class Client {
180
181
  params: method.toUpperCase() === "GET" ? params : {},
181
182
  headers: headers,
182
183
  data:
183
- method.toUpperCase() === "GET" ||
184
- contentType.startsWith("multipart/form-data")
185
- ? formData
186
- : params,
184
+ method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? formData : params,
187
185
  json: contentType.startsWith("application/json"),
186
+ transformRequest: method.toUpperCase() === "GET" || contentType.startsWith("multipart/form-data") ? undefined : (data) => JSONbig.stringify(data),
188
187
  responseType: responseType,
189
188
  };
190
189
  try {
@@ -1,7 +1,10 @@
1
1
  const fs = require('fs');
2
+ const pathLib = require('path');
2
3
  const tar = require("tar");
4
+ const ignore = require("ignore");
3
5
  const { promisify } = require('util');
4
6
  const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
5
8
  const { Command } = require('commander');
6
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
7
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -65,23 +68,6 @@ const accountCreate = async ({ userId, email, password, name, parseOutput = true
65
68
  return response;
66
69
  }
67
70
 
68
- const accountDelete = async ({ parseOutput = true, sdk = undefined}) => {
69
-
70
- let client = !sdk ? await sdkForProject() : sdk;
71
- let path = '/account';
72
- let payload = {};
73
- let response = undefined;
74
- response = await client.call('delete', path, {
75
- 'content-type': 'application/json',
76
- }, payload);
77
-
78
- if (parseOutput) {
79
- parse(response)
80
- success()
81
- }
82
- return response;
83
- }
84
-
85
71
  const accountUpdateEmail = async ({ email, password, parseOutput = true, sdk = undefined}) => {
86
72
  /* @param {string} email */
87
73
  /* @param {string} password */
@@ -234,7 +220,7 @@ const accountUpdatePrefs = async ({ prefs, parseOutput = true, sdk = undefined})
234
220
 
235
221
  /** Body Params */
236
222
  if (typeof prefs !== 'undefined') {
237
- payload['prefs'] = prefs;
223
+ payload['prefs'] = JSON.parse(prefs);
238
224
  }
239
225
 
240
226
  let response = undefined;
@@ -546,6 +532,23 @@ const accountDeleteSession = async ({ sessionId, parseOutput = true, sdk = undef
546
532
  return response;
547
533
  }
548
534
 
535
+ const accountUpdateStatus = async ({ parseOutput = true, sdk = undefined}) => {
536
+
537
+ let client = !sdk ? await sdkForProject() : sdk;
538
+ let path = '/account/status';
539
+ let payload = {};
540
+ let response = undefined;
541
+ response = await client.call('patch', path, {
542
+ 'content-type': 'application/json',
543
+ }, payload);
544
+
545
+ if (parseOutput) {
546
+ parse(response)
547
+ success()
548
+ }
549
+ return response;
550
+ }
551
+
549
552
  const accountCreateVerification = async ({ url, parseOutput = true, sdk = undefined}) => {
550
553
  /* @param {string} url */
551
554
 
@@ -614,11 +617,6 @@ account
614
617
  .option(`--name <name>`, `User name. Max length: 128 chars.`)
615
618
  .action(actionRunner(accountCreate))
616
619
 
617
- account
618
- .command(`delete`)
619
- .description(`Delete a currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. This is done to avoid deleted accounts being overtaken by new users with the same email address. Any user-related resources like documents or storage files should be deleted separately.`)
620
- .action(actionRunner(accountDelete))
621
-
622
620
  account
623
621
  .command(`updateEmail`)
624
622
  .description(`Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password. `)
@@ -646,7 +644,7 @@ account
646
644
 
647
645
  account
648
646
  .command(`updatePassword`)
649
- .description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth and Team Invites, oldPassword is optional.`)
647
+ .description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.`)
650
648
  .requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
651
649
  .option(`--oldPassword <oldPassword>`, `Current user password. Must be at least 8 chars.`)
652
650
  .action(actionRunner(accountUpdatePassword))
@@ -718,10 +716,10 @@ account
718
716
  account
719
717
  .command(`createOAuth2Session`)
720
718
  .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed. If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.. `)
721
- .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, vk, yahoo, yammer, yandex, wordpress, stripe.`)
719
+ .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, bitbucket, bitly, box, discord, dropbox, facebook, github, gitlab, google, linkedin, microsoft, notion, okta, paypal, paypalSandbox, salesforce, slack, spotify, tradeshift, tradeshiftBox, twitch, zoom, yahoo, yammer, yandex, wordpress, stripe.`)
722
720
  .option(`--success <success>`, `URL to redirect back to your app after a successful login attempt. 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.`)
723
721
  .option(`--failure <failure>`, `URL to redirect back to your app after a failed login attempt. 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.`)
724
- .option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes.`)
722
+ .option(`--scopes <scopes...>`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 128 characters long.`)
725
723
  .action(actionRunner(accountCreateOAuth2Session))
726
724
 
727
725
  account
@@ -732,7 +730,7 @@ account
732
730
 
733
731
  account
734
732
  .command(`updateSession`)
735
- .description(``)
733
+ .description(`Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token.`)
736
734
  .requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to update the current device session.`)
737
735
  .action(actionRunner(accountUpdateSession))
738
736
 
@@ -742,6 +740,11 @@ account
742
740
  .requiredOption(`--sessionId <sessionId>`, `Session ID. Use the string 'current' to delete the current device session.`)
743
741
  .action(actionRunner(accountDeleteSession))
744
742
 
743
+ account
744
+ .command(`updateStatus`)
745
+ .description(`Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.`)
746
+ .action(actionRunner(accountUpdateStatus))
747
+
745
748
  account
746
749
  .command(`createVerification`)
747
750
  .description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](/docs/client/account#accountUpdateVerification). The verification link sent to the user's email address is valid for 7 days. Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface. `)
@@ -760,7 +763,6 @@ module.exports = {
760
763
  account,
761
764
  accountGet,
762
765
  accountCreate,
763
- accountDelete,
764
766
  accountUpdateEmail,
765
767
  accountCreateJWT,
766
768
  accountGetLogs,
@@ -780,6 +782,7 @@ module.exports = {
780
782
  accountGetSession,
781
783
  accountUpdateSession,
782
784
  accountDeleteSession,
785
+ accountUpdateStatus,
783
786
  accountCreateVerification,
784
787
  accountUpdateVerification
785
- };
788
+ };
@@ -1,7 +1,10 @@
1
1
  const fs = require('fs');
2
+ const pathLib = require('path');
2
3
  const tar = require("tar");
4
+ const ignore = require("ignore");
3
5
  const { promisify } = require('util');
4
6
  const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
5
8
  const { Command } = require('commander');
6
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
7
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -271,7 +274,7 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
271
274
 
272
275
  avatars
273
276
  .command(`getBrowser`)
274
- .description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user /account/sessions endpoint. Use width, height and quality arguments to change the output settings.`)
277
+ .description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](/docs/client/account#accountGetSessions) endpoint. 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.`)
275
278
  .requiredOption(`--code <code>`, `Browser Code.`)
276
279
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
277
280
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -281,7 +284,7 @@ avatars
281
284
 
282
285
  avatars
283
286
  .command(`getCreditCard`)
284
- .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.`)
287
+ .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. `)
285
288
  .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.`)
286
289
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
287
290
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -298,7 +301,7 @@ avatars
298
301
 
299
302
  avatars
300
303
  .command(`getFlag`)
301
- .description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. Use width, height and quality arguments to change the output settings.`)
304
+ .description(`You can use this endpoint to show different country flags icons to your users. The code argument receives the 2 letter country code. 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. `)
302
305
  .requiredOption(`--code <code>`, `Country Code. ISO Alpha-2 country code format.`)
303
306
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
304
307
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -308,16 +311,16 @@ avatars
308
311
 
309
312
  avatars
310
313
  .command(`getImage`)
311
- .description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol.`)
314
+ .description(`Use this endpoint to fetch a remote image URL and crop it to any image size you want. This endpoint is very useful if you need to crop and display remote images in your app or in case you want to make sure a 3rd party image is properly served using a TLS protocol. 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 400x400px. `)
312
315
  .requiredOption(`--url <url>`, `Image URL which you want to crop.`)
313
- .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000.`, parseInteger)
314
- .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000.`, parseInteger)
316
+ .option(`--width <width>`, `Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
317
+ .option(`--height <height>`, `Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.`, parseInteger)
315
318
  .requiredOption(`--destination <path>`, `output file path.`)
316
319
  .action(actionRunner(avatarsGetImage))
317
320
 
318
321
  avatars
319
322
  .command(`getInitials`)
320
- .description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials.`)
323
+ .description(`Use this endpoint to show your user initials avatar icon on your website or app. By default, this route will try to print your logged-in user name or email initials. You can also overwrite the user name if you pass the 'name' parameter. If no name is given and no user is logged, an empty avatar will be returned. You can use the color and background params to change the avatar colors. By default, a random theme will be selected. The random theme will persist for the user's initials when reloading the same theme will always return for the same initials. 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. `)
321
324
  .option(`--name <name>`, `Full Name. When empty, current user name or email will be used. Max length: 128 chars.`)
322
325
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
323
326
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
@@ -328,9 +331,9 @@ avatars
328
331
 
329
332
  avatars
330
333
  .command(`getQR`)
331
- .description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image.`)
334
+ .description(`Converts a given plain text to a QR code image. You can use the query parameters to change the size and style of the resulting image. `)
332
335
  .requiredOption(`--text <text>`, `Plain text to be converted to QR code image.`)
333
- .option(`--size <size>`, `QR code size. Pass an integer between 0 to 1000. Defaults to 400.`, parseInteger)
336
+ .option(`--size <size>`, `QR code size. Pass an integer between 1 to 1000. Defaults to 400.`, parseInteger)
334
337
  .option(`--margin <margin>`, `Margin from edge. Pass an integer between 0 to 10. Defaults to 1.`, parseInteger)
335
338
  .option(`--download <download>`, `Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.`, parseBool)
336
339
  .requiredOption(`--destination <path>`, `output file path.`)
@@ -346,4 +349,4 @@ module.exports = {
346
349
  avatarsGetImage,
347
350
  avatarsGetInitials,
348
351
  avatarsGetQR
349
- };
352
+ };
@@ -1,7 +1,10 @@
1
1
  const fs = require('fs');
2
+ const pathLib = require('path');
2
3
  const tar = require("tar");
4
+ const ignore = require("ignore");
3
5
  const { promisify } = require('util');
4
6
  const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
5
8
  const { Command } = require('commander');
6
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
7
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -648,7 +651,7 @@ const databaseCreateDocument = async ({ collectionId, documentId, data, read, wr
648
651
  }
649
652
 
650
653
  if (typeof data !== 'undefined') {
651
- payload['data'] = data;
654
+ payload['data'] = JSON.parse(data);
652
655
  }
653
656
 
654
657
  if (typeof read !== 'undefined') {
@@ -703,7 +706,7 @@ const databaseUpdateDocument = async ({ collectionId, documentId, data, read, wr
703
706
 
704
707
  /** Body Params */
705
708
  if (typeof data !== 'undefined') {
706
- payload['data'] = data;
709
+ payload['data'] = JSON.parse(data);
707
710
  }
708
711
 
709
712
  if (typeof read !== 'undefined') {
@@ -962,7 +965,7 @@ database
962
965
  .description(`Create a new Collection.`)
963
966
  .requiredOption(`--collectionId <collectionId>`, `Unique Id. Choose your own unique ID or pass the string "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.`)
964
967
  .requiredOption(`--name <name>`, `Collection name. Max length: 128 chars.`)
965
- .requiredOption(`--permission <permission>`, `Permissions type model to use for reading documents in this collection. You can use collection-level permission set once on the collection using the 'read' and 'write' params, or you can set document-level permission where each document read and write params will decide who has access to read and write to each document individually. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
968
+ .requiredOption(`--permission <permission>`, `Specifies the permissions model used in this collection, which accepts either 'collection' or 'document'. For 'collection' level permission, the permissions specified in read and write params are applied to all documents in the collection. For 'document' level permissions, read and write permissions are specified in each document. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
966
969
  .requiredOption(`--read <read...>`, `An array of strings with read permissions. By default no user is granted with any read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
967
970
  .requiredOption(`--write <write...>`, `An array of strings with write permissions. By default no user is granted with any write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
968
971
  .action(actionRunner(databaseCreateCollection))
@@ -1021,7 +1024,7 @@ database
1021
1024
  .description(``)
1022
1025
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).`)
1023
1026
  .requiredOption(`--key <key>`, `Attribute Key.`)
1024
- .requiredOption(`--elements <elements...>`, `Array of elements in enumerated type. Uses length of longest element to determine size.`)
1027
+ .requiredOption(`--elements <elements...>`, `Array of elements in enumerated type. Uses length of longest element to determine size. Maximum of 100 elements are allowed, each 1024 characters long.`)
1025
1028
  .requiredOption(`--required <required>`, `Is attribute required?`, parseBool)
1026
1029
  .option(`--xdefault <xdefault>`, `Default value for attribute when not provided. Cannot be set when attribute is required.`)
1027
1030
  .option(`--array <array>`, `Is attribute an array?`, parseBool)
@@ -1100,13 +1103,13 @@ database
1100
1103
  .command(`listDocuments`)
1101
1104
  .description(`Get a list of all the user documents. You can use the query params to filter your results. On admin mode, this endpoint will return a list of all of the project's documents. [Learn more about different API modes](/docs/admin).`)
1102
1105
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).`)
1103
- .option(`--queries <queries...>`, `Array of query strings.`)
1106
+ .option(`--queries <queries...>`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/database#querying-documents). Maximum of 100 queries are allowed, each 128 characters long.`)
1104
1107
  .option(`--limit <limit>`, `Maximum number of documents to return in response. By default will return maximum 25 results. Maximum of 100 results allowed per request.`, parseInteger)
1105
1108
  .option(`--offset <offset>`, `Offset value. The default value is 0. Use this value to manage pagination. [learn more about pagination](https://appwrite.io/docs/pagination)`, parseInteger)
1106
1109
  .option(`--cursor <cursor>`, `ID of the document used as the starting point for the query, excluding the document itself. Should be used for efficient pagination when working with large sets of data. [learn more about pagination](https://appwrite.io/docs/pagination)`)
1107
1110
  .option(`--cursorDirection <cursorDirection>`, `Direction of the cursor.`)
1108
- .option(`--orderAttributes <orderAttributes...>`, `Array of attributes used to sort results.`)
1109
- .option(`--orderTypes <orderTypes...>`, `Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order.`)
1111
+ .option(`--orderAttributes <orderAttributes...>`, `Array of attributes used to sort results. Maximum of 100 order attributes are allowed, each 128 characters long.`)
1112
+ .option(`--orderTypes <orderTypes...>`, `Array of order directions for sorting attribtues. Possible values are DESC for descending order, or ASC for ascending order. Maximum of 100 order types are allowed.`)
1110
1113
  .action(actionRunner(databaseListDocuments))
1111
1114
 
1112
1115
  database
@@ -1131,14 +1134,14 @@ database
1131
1134
  .description(`Update a document by its unique ID. Using the patch method you can pass only specific fields that will get updated.`)
1132
1135
  .requiredOption(`--collectionId <collectionId>`, `Collection ID.`)
1133
1136
  .requiredOption(`--documentId <documentId>`, `Document ID.`)
1134
- .requiredOption(`--data <data>`, `Document data as JSON object.`)
1137
+ .requiredOption(`--data <data>`, `Document data as JSON object. Include only attribute and value pairs to be updated.`)
1135
1138
  .option(`--read <read...>`, `An array of strings with read permissions. By default inherits the existing read permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
1136
1139
  .option(`--write <write...>`, `An array of strings with write permissions. By default inherits the existing write permissions. [learn more about permissions](https://appwrite.io/docs/permissions) and get a full list of available permissions.`)
1137
1140
  .action(actionRunner(databaseUpdateDocument))
1138
1141
 
1139
1142
  database
1140
1143
  .command(`deleteDocument`)
1141
- .description(`Delete a document by its unique ID. This endpoint deletes only the parent documents, its attributes and relations to other documents. Child documents **will not** be deleted.`)
1144
+ .description(`Delete a document by its unique ID.`)
1142
1145
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).`)
1143
1146
  .requiredOption(`--documentId <documentId>`, `Document ID.`)
1144
1147
  .action(actionRunner(databaseDeleteDocument))
@@ -1164,8 +1167,8 @@ database
1164
1167
  .requiredOption(`--collectionId <collectionId>`, `Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/database#createCollection).`)
1165
1168
  .requiredOption(`--key <key>`, `Index Key.`)
1166
1169
  .requiredOption(`--type <type>`, `Index type.`)
1167
- .requiredOption(`--attributes <attributes...>`, `Array of attributes to index.`)
1168
- .option(`--orders <orders...>`, `Array of index orders.`)
1170
+ .requiredOption(`--attributes <attributes...>`, `Array of attributes to index. Maximum of 100 attributes are allowed, each 32 characters long.`)
1171
+ .option(`--orders <orders...>`, `Array of index orders. Maximum of 100 orders are allowed.`)
1169
1172
  .action(actionRunner(databaseCreateIndex))
1170
1173
 
1171
1174
  database
@@ -1235,4 +1238,4 @@ module.exports = {
1235
1238
  databaseListCollectionLogs,
1236
1239
  databaseGetUsage,
1237
1240
  databaseGetCollectionUsage
1238
- };
1241
+ };
@@ -1,4 +1,5 @@
1
1
  const inquirer = require("inquirer");
2
+ const JSONbig = require("json-bigint")({ storeAsString: false });
2
3
  const { Command } = require("commander");
3
4
  const { localConfig } = require("../config");
4
5
  const { questionsDeployFunctions, questionsGetEntrypoint, questionsDeployCollections } = require("../questions");
@@ -148,7 +149,7 @@ const deployFunction = async () => {
148
149
  let response = {};
149
150
 
150
151
  let answers = await inquirer.prompt(questionsDeployFunctions)
151
- let functions = answers.functions
152
+ let functions = answers.functions.map((func) => JSONbig.parse(func))
152
153
 
153
154
  for (let func of functions) {
154
155
  log(`Deploying function ${func.name} ( ${func['$id']} )`)
@@ -167,7 +168,7 @@ const deployFunction = async () => {
167
168
  functionId: func['$id'],
168
169
  name: func.name,
169
170
  execute: func.execute,
170
- vars: response.vars,
171
+ vars: JSON.stringify(response.vars),
171
172
  events: func.events,
172
173
  schedule: func.schedule,
173
174
  timeout: func.timeout,
@@ -181,7 +182,7 @@ const deployFunction = async () => {
181
182
  name: func.name,
182
183
  runtime: func.runtime,
183
184
  execute: func.execute,
184
- vars: func.vars,
185
+ vars: JSON.stringify(func.vars),
185
186
  events: func.events,
186
187
  schedule: func.schedule,
187
188
  timeout: func.timeout,
@@ -319,7 +320,7 @@ const createAttribute = async (collectionId, attribute) => {
319
320
  const deployCollection = async () => {
320
321
  let response = {};
321
322
  let answers = await inquirer.prompt(questionsDeployCollections[0])
322
- let collections = answers.collections
323
+ let collections = answers.collections.map((collection) => JSONbig.parse(collection));
323
324
 
324
325
  for (let collection of collections) {
325
326
  log(`Deploying collection ${collection.name} ( ${collection['$id']} )`)