appwrite-cli 0.15.0 → 0.16.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.
@@ -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
@@ -6,7 +6,7 @@
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.13.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.16.0
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.16.0
62
62
  ```
63
63
 
64
64
  ## Getting Started
package/install.ps1 CHANGED
@@ -13,8 +13,8 @@
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.16.0/appwrite-cli-win-x64.exe"
17
+ $GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/0.16.0/appwrite-cli-win-arm64.exe"
18
18
 
19
19
  # Appwrite download directory
20
20
  $APPWRITE_DOWNLOAD_DIR = Join-Path -Path $env:TEMP -ChildPath "appwrite.exe"
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.16.0"
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
@@ -11,8 +11,8 @@ class Client {
11
11
  this.endpoint = 'https://HOSTNAME/v1';
12
12
  this.headers = {
13
13
  'content-type': '',
14
- 'x-sdk-version': 'appwrite:cli:0.15.0',
15
- 'User-Agent' : `AppwriteCLI/0.15.0 (${os.type()} ${os.version()}; ${os.arch()})`,
14
+ 'x-sdk-version': 'appwrite:cli:0.16.0',
15
+ 'User-Agent' : `AppwriteCLI/0.16.0 (${os.type()} ${os.version()}; ${os.arch()})`,
16
16
  'X-Appwrite-Response-Format' : '0.13.0',
17
17
  };
18
18
  }
@@ -234,7 +234,7 @@ const accountUpdatePrefs = async ({ prefs, parseOutput = true, sdk = undefined})
234
234
 
235
235
  /** Body Params */
236
236
  if (typeof prefs !== 'undefined') {
237
- payload['prefs'] = prefs;
237
+ payload['prefs'] = JSON.parse(prefs);
238
238
  }
239
239
 
240
240
  let response = undefined;
@@ -782,4 +782,4 @@ module.exports = {
782
782
  accountDeleteSession,
783
783
  accountCreateVerification,
784
784
  accountUpdateVerification
785
- };
785
+ };
@@ -346,4 +346,4 @@ module.exports = {
346
346
  avatarsGetImage,
347
347
  avatarsGetInitials,
348
348
  avatarsGetQR
349
- };
349
+ };
@@ -648,7 +648,7 @@ const databaseCreateDocument = async ({ collectionId, documentId, data, read, wr
648
648
  }
649
649
 
650
650
  if (typeof data !== 'undefined') {
651
- payload['data'] = data;
651
+ payload['data'] = JSON.parse(data);
652
652
  }
653
653
 
654
654
  if (typeof read !== 'undefined') {
@@ -703,7 +703,7 @@ const databaseUpdateDocument = async ({ collectionId, documentId, data, read, wr
703
703
 
704
704
  /** Body Params */
705
705
  if (typeof data !== 'undefined') {
706
- payload['data'] = data;
706
+ payload['data'] = JSON.parse(data);
707
707
  }
708
708
 
709
709
  if (typeof read !== 'undefined') {
@@ -1235,4 +1235,4 @@ module.exports = {
1235
1235
  databaseListCollectionLogs,
1236
1236
  databaseGetUsage,
1237
1237
  databaseGetCollectionUsage
1238
- };
1238
+ };
@@ -84,7 +84,7 @@ const functionsCreate = async ({ functionId, name, execute, runtime, vars, event
84
84
  }
85
85
 
86
86
  if (typeof vars !== 'undefined') {
87
- payload['vars'] = vars;
87
+ payload['vars'] = JSON.parse(vars);
88
88
  }
89
89
 
90
90
  if (typeof events !== 'undefined') {
@@ -169,7 +169,7 @@ const functionsUpdate = async ({ functionId, name, execute, vars, events, schedu
169
169
  }
170
170
 
171
171
  if (typeof vars !== 'undefined') {
172
- payload['vars'] = vars;
172
+ payload['vars'] = JSON.parse(vars);
173
173
  }
174
174
 
175
175
  if (typeof events !== 'undefined') {
@@ -287,6 +287,7 @@ const functionsCreateDeployment = async ({ functionId, entrypoint, code, activat
287
287
  let archivePath = fs.realpathSync('code.tar.gz')
288
288
  if (typeof archivePath !== 'undefined') {
289
289
  payload['code'] = archivePath;
290
+ code = archivePath;
290
291
  }
291
292
 
292
293
  if (typeof activate !== 'undefined') {
@@ -301,46 +302,53 @@ const functionsCreateDeployment = async ({ functionId, entrypoint, code, activat
301
302
 
302
303
  response = await client.call('post', path, {
303
304
  'content-type': 'multipart/form-data',
304
- }, payload);
305
+ }, payload).catch(err => {
306
+ fs.unlinkSync(archivePath);
307
+ throw err
308
+ });
305
309
  } else {
306
310
  const streamFilePath = payload['code'];
307
311
  let id = undefined;
308
312
 
313
+ let counter = 0;
309
314
  const totalCounters = Math.ceil(size / libClient.CHUNK_SIZE);
310
315
 
311
- for (let counter = 0; counter < totalCounters; counter++) {
312
- const start = (counter * libClient.CHUNK_SIZE);
313
- const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
314
- const headers = {
315
- 'content-type': 'multipart/form-data',
316
- 'content-range': 'bytes ' + start + '-' + end + '/' + size
317
- };
318
-
319
- if (id) {
320
- headers['x-appwrite-id'] = id;
321
- }
322
-
323
- const stream = fs.createReadStream(streamFilePath, {
324
- start,
325
- end
316
+ const headers = {
317
+ 'content-type': 'multipart/form-data',
318
+ };
319
+
320
+
321
+ for (counter; counter < totalCounters; counter++) {
322
+ const start = (counter * libClient.CHUNK_SIZE);
323
+ const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
324
+
325
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
326
+
327
+ if (id) {
328
+ headers['x-appwrite-id'] = id;
329
+ }
330
+
331
+ const stream = fs.createReadStream(streamFilePath, {
332
+ start,
333
+ end
334
+ });
335
+ payload['code'] = stream;
336
+
337
+ response = await client.call('post', path, headers, payload);
338
+
339
+ if (!id) {
340
+ id = response['$id'];
341
+ }
342
+
343
+ if (onProgress !== null) {
344
+ onProgress({
345
+ $id: response['$id'],
346
+ progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
347
+ sizeUploaded: end+1,
348
+ chunksTotal: response['chunksTotal'],
349
+ chunksUploaded: response['chunksUploaded']
326
350
  });
327
- payload['code'] = stream;
328
-
329
- response = await client.call('post', path, headers, payload);
330
-
331
- if (!id) {
332
- id = response['$id'];
333
- }
334
-
335
- if (onProgress !== null) {
336
- onProgress({
337
- $id: response['$id'],
338
- progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
339
- sizeUploaded: end+1,
340
- chunksTotal: response['chunksTotal'],
341
- chunksUploaded: response['chunksUploaded']
342
- });
343
- }
351
+ }
344
352
  }
345
353
  }
346
354
 
@@ -699,4 +707,4 @@ module.exports = {
699
707
  functionsCreateExecution,
700
708
  functionsGetExecution,
701
709
  functionsGetUsage
702
- };
710
+ };
@@ -266,4 +266,4 @@ module.exports = {
266
266
  healthGetQueueWebhooks,
267
267
  healthGetStorageLocal,
268
268
  healthGetTime
269
- };
269
+ };
@@ -174,4 +174,4 @@ module.exports = {
174
174
  localeGetCountriesPhones,
175
175
  localeGetCurrencies,
176
176
  localeGetLanguages
177
- };
177
+ };
@@ -1188,4 +1188,4 @@ module.exports = {
1188
1188
  projectsGetWebhook,
1189
1189
  projectsUpdateWebhook,
1190
1190
  projectsDeleteWebhook
1191
- };
1191
+ };
@@ -303,46 +303,57 @@ const storageCreateFile = async ({ bucketId, fileId, file, read, write, parseOut
303
303
 
304
304
  response = await client.call('post', path, {
305
305
  'content-type': 'multipart/form-data',
306
- }, payload);
306
+ }, payload)
307
307
  } else {
308
308
  const streamFilePath = payload['file'];
309
309
  let id = undefined;
310
310
 
311
+ let counter = 0;
311
312
  const totalCounters = Math.ceil(size / libClient.CHUNK_SIZE);
312
313
 
313
- for (let counter = 0; counter < totalCounters; counter++) {
314
- const start = (counter * libClient.CHUNK_SIZE);
315
- const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
316
- const headers = {
317
- 'content-type': 'multipart/form-data',
318
- 'content-range': 'bytes ' + start + '-' + end + '/' + size
319
- };
320
-
321
- if (id) {
322
- headers['x-appwrite-id'] = id;
323
- }
324
-
325
- const stream = fs.createReadStream(streamFilePath, {
326
- start,
327
- end
314
+ const headers = {
315
+ 'content-type': 'multipart/form-data',
316
+ };
317
+
318
+ if(fileId != 'unique()') {
319
+ try {
320
+ response = await client.call('get', path + '/' + fileId, headers);
321
+ counter = response.chunksUploaded;
322
+ } catch(e) {
323
+ }
324
+ }
325
+
326
+ for (counter; counter < totalCounters; counter++) {
327
+ const start = (counter * libClient.CHUNK_SIZE);
328
+ const end = Math.min((((counter * libClient.CHUNK_SIZE) + libClient.CHUNK_SIZE) - 1), size);
329
+
330
+ headers['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
331
+
332
+ if (id) {
333
+ headers['x-appwrite-id'] = id;
334
+ }
335
+
336
+ const stream = fs.createReadStream(streamFilePath, {
337
+ start,
338
+ end
339
+ });
340
+ payload['file'] = stream;
341
+
342
+ response = await client.call('post', path, headers, payload);
343
+
344
+ if (!id) {
345
+ id = response['$id'];
346
+ }
347
+
348
+ if (onProgress !== null) {
349
+ onProgress({
350
+ $id: response['$id'],
351
+ progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
352
+ sizeUploaded: end+1,
353
+ chunksTotal: response['chunksTotal'],
354
+ chunksUploaded: response['chunksUploaded']
328
355
  });
329
- payload['file'] = stream;
330
-
331
- response = await client.call('post', path, headers, payload);
332
-
333
- if (!id) {
334
- id = response['$id'];
335
- }
336
-
337
- if (onProgress !== null) {
338
- onProgress({
339
- $id: response['$id'],
340
- progress: Math.min((counter+1) * libClient.CHUNK_SIZE, size) / size * 100,
341
- sizeUploaded: end+1,
342
- chunksTotal: response['chunksTotal'],
343
- chunksUploaded: response['chunksUploaded']
344
- });
345
- }
356
+ }
346
357
  }
347
358
  }
348
359
 
@@ -752,4 +763,4 @@ module.exports = {
752
763
  storageGetFileView,
753
764
  storageGetUsage,
754
765
  storageGetBucketUsage
755
- };
766
+ };
@@ -432,4 +432,4 @@ module.exports = {
432
432
  teamsUpdateMembershipRoles,
433
433
  teamsDeleteMembership,
434
434
  teamsUpdateMembershipStatus
435
- };
435
+ };
@@ -285,7 +285,7 @@ const usersUpdatePrefs = async ({ userId, prefs, parseOutput = true, sdk = undef
285
285
 
286
286
  /** Body Params */
287
287
  if (typeof prefs !== 'undefined') {
288
- payload['prefs'] = prefs;
288
+ payload['prefs'] = JSON.parse(prefs);
289
289
  }
290
290
 
291
291
  let response = undefined;
@@ -539,4 +539,4 @@ module.exports = {
539
539
  usersDeleteSession,
540
540
  usersUpdateStatus,
541
541
  usersUpdateVerification
542
- };
542
+ };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "appwrite-cli",
3
3
  "homepage": "https://appwrite.io/support",
4
4
  "description": "Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API",
5
- "version": "0.15.0",
5
+ "version": "0.16.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -22,12 +22,12 @@
22
22
  "windows-arm64": "pkg -t node16-win-arm64 -o build/appwrite-cli-win-arm64.exe package.json"
23
23
  },
24
24
  "dependencies": {
25
- "axios": "^0.24.0",
25
+ "axios": "^0.26.1",
26
26
  "chalk": "4.1.2",
27
27
  "cli-table3": "^0.6.1",
28
- "commander": "^8.3.0",
28
+ "commander": "^9.0.0",
29
29
  "form-data": "^4.0.0",
30
- "inquirer": "^8.2.0",
30
+ "inquirer": "^8.2.1",
31
31
  "tar": "^6.1.11"
32
32
  },
33
33
  "devDependencies": {