appwrite-cli 4.1.0 → 4.2.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.
@@ -0,0 +1,51 @@
1
+ const paginate = async (action, args = {}, limit = 100, wrapper = '') => {
2
+ let pageNumber = 0;
3
+ let results = [];
4
+ let total = 0;
5
+
6
+ while (true) {
7
+ const offset = pageNumber * limit;
8
+
9
+ // Merge the limit and offset into the args
10
+ const response = await action({
11
+ ...args,
12
+ queries: [
13
+ `limit(${limit})`,
14
+ `offset(${offset})`
15
+ ]
16
+ });
17
+
18
+ if (wrapper === '') {
19
+ if (response.length === 0) {
20
+ break;
21
+ }
22
+ results = results.concat(response);
23
+ } else {
24
+ if (response[wrapper].length === 0) {
25
+ break;
26
+ }
27
+ results = results.concat(response[wrapper]);
28
+ }
29
+
30
+ total = response.total;
31
+
32
+ if (results.length >= total) {
33
+ break;
34
+ }
35
+
36
+ pageNumber++;
37
+ }
38
+
39
+ if (wrapper === '') {
40
+ return results;
41
+ }
42
+
43
+ return {
44
+ [wrapper]: results,
45
+ total,
46
+ };
47
+ }
48
+
49
+ module.exports = {
50
+ paginate
51
+ };
package/lib/questions.js CHANGED
@@ -309,13 +309,12 @@ const questionsDeployCollections = [
309
309
  if (collections.length === 0) {
310
310
  throw new Error("No collections found in the current directory. Run `appwrite init collection` to fetch all your collections.");
311
311
  }
312
- let choices = collections.map((collection, idx) => {
312
+ return collections.map(collection => {
313
313
  return {
314
314
  name: `${collection.name} (${collection['databaseId']} - ${collection['$id']})`,
315
315
  value: `${collection['databaseId']}|${collection['$id']}`
316
316
  }
317
- })
318
- return choices;
317
+ });
319
318
  }
320
319
  },
321
320
  {
@@ -335,13 +334,12 @@ const questionsDeployBuckets = [
335
334
  if (buckets.length === 0) {
336
335
  throw new Error("No buckets found in the current directory. Run `appwrite init bucket` to fetch all your buckets.");
337
336
  }
338
- let choices = buckets.map((bucket, idx) => {
337
+ return buckets.map(bucket => {
339
338
  return {
340
339
  name: `${bucket.name} (${bucket['$id']})`,
341
340
  value: bucket.$id
342
341
  }
343
- })
344
- return choices;
342
+ });
345
343
  }
346
344
  },
347
345
  {
@@ -359,7 +357,7 @@ const questionsGetEntrypoint = [
359
357
  default: null,
360
358
  validate(value) {
361
359
  if (!value) {
362
- return "Please enter your enrtypoint";
360
+ return "Please enter your entrypoint";
363
361
  }
364
362
  return true;
365
363
  }
@@ -376,13 +374,12 @@ const questionsDeployTeams = [
376
374
  if (teams.length === 0) {
377
375
  throw new Error("No teams found in the current directory. Run `appwrite init team` to fetch all your teams.");
378
376
  }
379
- let choices = teams.map((team, idx) => {
377
+ return teams.map(team => {
380
378
  return {
381
379
  name: `${team.name} (${team['$id']})`,
382
380
  value: team.$id
383
381
  }
384
- })
385
- return choices;
382
+ });
386
383
  }
387
384
  },
388
385
  {
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": "4.1.0",
5
+ "version": "4.2.0",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "index.js",
8
8
  "bin": {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
5
5
  "homepage": "https://github.com/appwrite/sdk-for-cli",
6
6
  "license": "BSD-3-Clause",
7
7
  "architecture": {
8
8
  "64bit": {
9
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.1.0/appwrite-cli-win-x64.exe",
9
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.0/appwrite-cli-win-x64.exe",
10
10
  "bin": [
11
11
  [
12
12
  "appwrite-cli-win-x64.exe",
@@ -15,7 +15,7 @@
15
15
  ]
16
16
  },
17
17
  "arm64": {
18
- "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.1.0/appwrite-cli-win-arm64.exe",
18
+ "url": "https://github.com/appwrite/sdk-for-cli/releases/download/4.2.0/appwrite-cli-win-arm64.exe",
19
19
  "bin": [
20
20
  [
21
21
  "appwrite-cli-win-arm64.exe",