appwrite-cli 12.0.1 → 13.0.0-rc.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.
- package/CHANGELOG.md +4 -0
- package/README.md +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +89 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +227 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/account.d.ts +379 -0
- package/dist/lib/commands/account.d.ts.map +1 -0
- package/dist/lib/commands/account.js +1228 -0
- package/dist/lib/commands/account.js.map +1 -0
- package/dist/lib/commands/console.d.ts +20 -0
- package/dist/lib/commands/console.d.ts.map +1 -0
- package/dist/lib/commands/console.js +78 -0
- package/dist/lib/commands/console.js.map +1 -0
- package/dist/lib/commands/databases.d.ts +732 -0
- package/dist/lib/commands/databases.d.ts.map +1 -0
- package/dist/lib/commands/databases.js +2196 -0
- package/dist/lib/commands/databases.js.map +1 -0
- package/dist/lib/commands/functions.d.ts +310 -0
- package/dist/lib/commands/functions.d.ts.map +1 -0
- package/dist/lib/commands/functions.js +1100 -0
- package/dist/lib/commands/functions.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +279 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/graphql.d.ts +19 -0
- package/dist/lib/commands/graphql.d.ts.map +1 -0
- package/dist/lib/commands/graphql.js +77 -0
- package/dist/lib/commands/graphql.js.map +1 -0
- package/dist/lib/commands/health.d.ts +153 -0
- package/dist/lib/commands/health.d.ts.map +1 -0
- package/dist/lib/commands/health.js +464 -0
- package/dist/lib/commands/health.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +518 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/locale.d.ts +53 -0
- package/dist/lib/commands/locale.d.ts.map +1 -0
- package/dist/lib/commands/locale.js +165 -0
- package/dist/lib/commands/locale.js.map +1 -0
- package/dist/lib/commands/messaging.d.ts +588 -0
- package/dist/lib/commands/messaging.d.ts.map +1 -0
- package/dist/lib/commands/messaging.js +2042 -0
- package/dist/lib/commands/messaging.js.map +1 -0
- package/dist/lib/commands/migrations.d.ts +150 -0
- package/dist/lib/commands/migrations.d.ts.map +1 -0
- package/dist/lib/commands/migrations.js +524 -0
- package/dist/lib/commands/migrations.js.map +1 -0
- package/dist/lib/commands/organizations.d.ts +11 -0
- package/dist/lib/commands/organizations.d.ts.map +1 -0
- package/dist/lib/commands/organizations.js +31 -0
- package/dist/lib/commands/organizations.js.map +1 -0
- package/dist/lib/commands/project.d.ts +53 -0
- package/dist/lib/commands/project.d.ts.map +1 -0
- package/dist/lib/commands/project.js +176 -0
- package/dist/lib/commands/project.js.map +1 -0
- package/dist/lib/commands/projects.d.ts +516 -0
- package/dist/lib/commands/projects.d.ts.map +1 -0
- package/dist/lib/commands/projects.js +1590 -0
- package/dist/lib/commands/projects.js.map +1 -0
- package/dist/lib/commands/proxy.d.ts +71 -0
- package/dist/lib/commands/proxy.d.ts.map +1 -0
- package/dist/lib/commands/proxy.js +240 -0
- package/dist/lib/commands/proxy.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +8 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +455 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +4 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +2154 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +287 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/sites.d.ts +296 -0
- package/dist/lib/commands/sites.d.ts.map +1 -0
- package/dist/lib/commands/sites.js +1046 -0
- package/dist/lib/commands/sites.js.map +1 -0
- package/dist/lib/commands/storage.d.ts +170 -0
- package/dist/lib/commands/storage.d.ts.map +1 -0
- package/dist/lib/commands/storage.js +651 -0
- package/dist/lib/commands/storage.js.map +1 -0
- package/dist/lib/commands/tables-db.d.ts +728 -0
- package/dist/lib/commands/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/tables-db.js +2198 -0
- package/dist/lib/commands/tables-db.js.map +1 -0
- package/dist/lib/commands/teams.d.ts +129 -0
- package/dist/lib/commands/teams.d.ts.map +1 -0
- package/dist/lib/commands/teams.js +403 -0
- package/dist/lib/commands/teams.js.map +1 -0
- package/dist/lib/commands/tokens.d.ts +48 -0
- package/dist/lib/commands/tokens.d.ts.map +1 -0
- package/dist/lib/commands/tokens.js +156 -0
- package/dist/lib/commands/tokens.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +155 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +202 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/users.d.ts +382 -0
- package/dist/lib/commands/users.d.ts.map +1 -0
- package/dist/lib/commands/users.js +1195 -0
- package/dist/lib/commands/users.js.map +1 -0
- package/dist/lib/commands/vcs.d.ts +92 -0
- package/dist/lib/commands/vcs.d.ts.map +1 -0
- package/dist/lib/commands/vcs.js +276 -0
- package/dist/lib/commands/vcs.js.map +1 -0
- package/dist/lib/config.d.ts +118 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/{lib → dist/lib}/config.js +204 -325
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +15 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +220 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +168 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/exception.d.ts +8 -0
- package/dist/lib/exception.d.ts.map +1 -0
- package/dist/lib/exception.js +16 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +32 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +10 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/{lib → dist/lib}/paginate.js +9 -15
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +237 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +995 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +51 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/{lib → dist/lib}/spinner.js +34 -45
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +19 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +108 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +82 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +112 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +133 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{lib → dist/lib}/utils.js +74 -120
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +20 -0
- package/dist/lib/validations.js.map +1 -0
- package/docs/examples/databases/upsert-document.md +1 -2
- package/index.ts +152 -0
- package/install.ps1 +2 -5
- package/install.sh +1 -2
- package/lib/client.ts +259 -0
- package/lib/commands/{account.js → account.ts} +408 -662
- package/lib/commands/console.ts +112 -0
- package/lib/commands/{databases.js → databases.ts} +818 -1136
- package/lib/commands/{functions.js → functions.ts} +381 -526
- package/lib/commands/{generic.js → generic.ts} +47 -39
- package/lib/commands/graphql.ts +110 -0
- package/lib/commands/{health.js → health.ts} +168 -284
- package/lib/commands/{init.js → init.ts} +68 -66
- package/lib/commands/{locale.js → locale.ts} +75 -121
- package/lib/commands/{messaging.js → messaging.ts} +699 -937
- package/lib/commands/{migrations.js → migrations.ts} +182 -258
- package/lib/commands/organizations.ts +46 -0
- package/lib/commands/{project.js → project.ts} +75 -111
- package/lib/commands/{projects.js → projects.ts} +587 -843
- package/lib/commands/{proxy.js → proxy.ts} +94 -140
- package/lib/commands/{pull.js → pull.ts} +54 -44
- package/lib/commands/{push.js → push.ts} +235 -191
- package/lib/commands/{run.js → run.ts} +61 -55
- package/lib/commands/{sites.js → sites.ts} +364 -504
- package/lib/commands/{storage.js → storage.ts} +216 -292
- package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
- package/lib/commands/{teams.js → teams.ts} +162 -236
- package/lib/commands/{tokens.js → tokens.ts} +70 -99
- package/lib/commands/{types.js → types.ts} +37 -35
- package/lib/commands/{update.js → update.ts} +25 -27
- package/lib/commands/{users.js → users.ts} +426 -644
- package/lib/commands/{vcs.js → vcs.ts} +118 -174
- package/lib/config.ts +854 -0
- package/lib/emulation/{docker.js → docker.ts} +39 -38
- package/lib/emulation/utils.ts +193 -0
- package/lib/exception.ts +20 -0
- package/lib/{id.js → id.ts} +5 -5
- package/lib/paginate.ts +63 -0
- package/lib/parser.ts +238 -0
- package/lib/{questions.js → questions.ts} +148 -156
- package/lib/sdks.ts +55 -0
- package/lib/spinner.ts +118 -0
- package/lib/type-generation/attribute.ts +17 -0
- package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -57
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
- package/lib/type-generation/languages/{java.js → java.ts} +58 -56
- package/lib/type-generation/languages/javascript.ts +111 -0
- package/lib/type-generation/languages/kotlin.ts +96 -0
- package/lib/type-generation/languages/language.ts +119 -0
- package/lib/type-generation/languages/{php.js → php.ts} +55 -53
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
- package/lib/type-generation/languages/typescript.ts +116 -0
- package/lib/types.ts +150 -0
- package/lib/utils.ts +322 -0
- package/lib/validations.ts +17 -0
- package/package.json +21 -12
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +30 -0
- package/index.js +0 -147
- package/lib/client.js +0 -254
- package/lib/commands/console.js +0 -127
- package/lib/commands/graphql.js +0 -126
- package/lib/commands/organizations.js +0 -48
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/parser.js +0 -250
- package/lib/sdks.js +0 -60
- package/lib/type-generation/attribute.js +0 -19
- package/lib/type-generation/languages/javascript.js +0 -111
- package/lib/type-generation/languages/kotlin.js +0 -94
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -116
- package/lib/validations.js +0 -17
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -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
|
-
|
|
32
|
+
13.0.0-rc.1
|
|
33
33
|
```
|
|
34
34
|
|
|
35
35
|
### Install using prebuilt binaries
|
|
@@ -60,7 +60,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
|
|
|
60
60
|
Once the installation completes, you can verify your install using
|
|
61
61
|
```
|
|
62
62
|
$ appwrite -v
|
|
63
|
-
|
|
63
|
+
13.0.0-rc.1
|
|
64
64
|
```
|
|
65
65
|
|
|
66
66
|
## Getting Started
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
/** Required to set max width of the help commands */
|
|
5
|
+
const oldWidth = process.stdout.columns;
|
|
6
|
+
process.stdout.columns = 100;
|
|
7
|
+
/** ---------------------------------------------- */
|
|
8
|
+
const program = require("commander");
|
|
9
|
+
const chalk = require("chalk");
|
|
10
|
+
const { version } = require('../package.json');
|
|
11
|
+
const parser_1 = require("./lib/parser");
|
|
12
|
+
const generic_1 = require("./lib/commands/generic");
|
|
13
|
+
const utils_1 = require("./lib/utils");
|
|
14
|
+
const inquirer = require("inquirer");
|
|
15
|
+
const generic_2 = require("./lib/commands/generic");
|
|
16
|
+
const init_1 = require("./lib/commands/init");
|
|
17
|
+
const types_1 = require("./lib/commands/types");
|
|
18
|
+
const pull_1 = require("./lib/commands/pull");
|
|
19
|
+
const run_1 = require("./lib/commands/run");
|
|
20
|
+
const push_1 = require("./lib/commands/push");
|
|
21
|
+
const update_1 = require("./lib/commands/update");
|
|
22
|
+
const account_1 = require("./lib/commands/account");
|
|
23
|
+
const console_1 = require("./lib/commands/console");
|
|
24
|
+
const databases_1 = require("./lib/commands/databases");
|
|
25
|
+
const functions_1 = require("./lib/commands/functions");
|
|
26
|
+
const graphql_1 = require("./lib/commands/graphql");
|
|
27
|
+
const health_1 = require("./lib/commands/health");
|
|
28
|
+
const locale_1 = require("./lib/commands/locale");
|
|
29
|
+
const messaging_1 = require("./lib/commands/messaging");
|
|
30
|
+
const migrations_1 = require("./lib/commands/migrations");
|
|
31
|
+
const project_1 = require("./lib/commands/project");
|
|
32
|
+
const projects_1 = require("./lib/commands/projects");
|
|
33
|
+
const proxy_1 = require("./lib/commands/proxy");
|
|
34
|
+
const sites_1 = require("./lib/commands/sites");
|
|
35
|
+
const storage_1 = require("./lib/commands/storage");
|
|
36
|
+
const tables_db_1 = require("./lib/commands/tables-db");
|
|
37
|
+
const teams_1 = require("./lib/commands/teams");
|
|
38
|
+
const tokens_1 = require("./lib/commands/tokens");
|
|
39
|
+
const users_1 = require("./lib/commands/users");
|
|
40
|
+
const vcs_1 = require("./lib/commands/vcs");
|
|
41
|
+
inquirer.registerPrompt('search-list', require('inquirer-search-list'));
|
|
42
|
+
/**
|
|
43
|
+
* Check for updates and show version information
|
|
44
|
+
*/
|
|
45
|
+
async function checkVersion() {
|
|
46
|
+
process.stdout.write(chalk.bold(`appwrite version ${version}`) + '\n');
|
|
47
|
+
try {
|
|
48
|
+
const latestVersion = await (0, utils_1.getLatestVersion)();
|
|
49
|
+
const comparison = (0, utils_1.compareVersions)(version, latestVersion);
|
|
50
|
+
if (comparison > 0) {
|
|
51
|
+
// Current version is older than latest
|
|
52
|
+
process.stdout.write(chalk.yellow(`\n⚠️ A newer version is available: ${chalk.bold(latestVersion)}`) + '\n');
|
|
53
|
+
process.stdout.write(chalk.cyan(`💡 Run '${chalk.bold('appwrite update')}' to update to the latest version.`) + '\n');
|
|
54
|
+
}
|
|
55
|
+
else if (comparison === 0) {
|
|
56
|
+
process.stdout.write(chalk.green('\n✅ You are running the latest version!') + '\n');
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
// Current version is newer than latest (pre-release/dev)
|
|
60
|
+
process.stdout.write(chalk.blue('\n🚀 You are running a pre-release or development version.') + '\n');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
// Silently fail version check, just show current version
|
|
65
|
+
process.stdout.write(chalk.gray('\n(Unable to check for updates)') + '\n');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Intercept version flag before Commander.js processes it
|
|
69
|
+
if (process.argv.includes('-v') || process.argv.includes('--version')) {
|
|
70
|
+
(async () => {
|
|
71
|
+
await checkVersion();
|
|
72
|
+
process.exit(0);
|
|
73
|
+
})();
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
program
|
|
77
|
+
.description(parser_1.commandDescriptions['main'])
|
|
78
|
+
.configureHelp({
|
|
79
|
+
helpWidth: process.stdout.columns || 80,
|
|
80
|
+
sortSubcommands: true,
|
|
81
|
+
})
|
|
82
|
+
.helpOption('-h, --help', 'Display help for command')
|
|
83
|
+
.version(version, '-v, --version', 'Output the version number')
|
|
84
|
+
.option('-V, --verbose', 'Show complete error log')
|
|
85
|
+
.option('-j, --json', 'Output in JSON format')
|
|
86
|
+
.hook('preAction', generic_2.migrate)
|
|
87
|
+
.option('-f,--force', 'Flag to confirm all warnings')
|
|
88
|
+
.option('-a,--all', 'Flag to push all resources')
|
|
89
|
+
.option('--id [id...]', 'Flag to pass a list of ids for a given action')
|
|
90
|
+
.option('--report', 'Enable reporting in case of CLI errors')
|
|
91
|
+
.on('option:json', () => {
|
|
92
|
+
parser_1.cliConfig.json = true;
|
|
93
|
+
})
|
|
94
|
+
.on('option:verbose', () => {
|
|
95
|
+
parser_1.cliConfig.verbose = true;
|
|
96
|
+
})
|
|
97
|
+
.on('option:report', function () {
|
|
98
|
+
parser_1.cliConfig.report = true;
|
|
99
|
+
parser_1.cliConfig.reportData = { data: this };
|
|
100
|
+
})
|
|
101
|
+
.on('option:force', () => {
|
|
102
|
+
parser_1.cliConfig.force = true;
|
|
103
|
+
})
|
|
104
|
+
.on('option:all', () => {
|
|
105
|
+
parser_1.cliConfig.all = true;
|
|
106
|
+
})
|
|
107
|
+
.on('option:id', function () {
|
|
108
|
+
parser_1.cliConfig.ids = this.opts().id;
|
|
109
|
+
})
|
|
110
|
+
.showSuggestionAfterError()
|
|
111
|
+
.addCommand(generic_2.whoami)
|
|
112
|
+
.addCommand(generic_2.register)
|
|
113
|
+
.addCommand(generic_2.login)
|
|
114
|
+
.addCommand(init_1.init)
|
|
115
|
+
.addCommand(pull_1.pull)
|
|
116
|
+
.addCommand(push_1.push)
|
|
117
|
+
.addCommand(types_1.types)
|
|
118
|
+
.addCommand(push_1.deploy)
|
|
119
|
+
.addCommand(run_1.run)
|
|
120
|
+
.addCommand(update_1.update)
|
|
121
|
+
.addCommand(generic_2.logout)
|
|
122
|
+
.addCommand(account_1.account)
|
|
123
|
+
.addCommand(console_1.console)
|
|
124
|
+
.addCommand(databases_1.databases)
|
|
125
|
+
.addCommand(functions_1.functions)
|
|
126
|
+
.addCommand(graphql_1.graphql)
|
|
127
|
+
.addCommand(health_1.health)
|
|
128
|
+
.addCommand(locale_1.locale)
|
|
129
|
+
.addCommand(messaging_1.messaging)
|
|
130
|
+
.addCommand(migrations_1.migrations)
|
|
131
|
+
.addCommand(project_1.project)
|
|
132
|
+
.addCommand(projects_1.projects)
|
|
133
|
+
.addCommand(proxy_1.proxy)
|
|
134
|
+
.addCommand(sites_1.sites)
|
|
135
|
+
.addCommand(storage_1.storage)
|
|
136
|
+
.addCommand(tables_db_1.tablesDB)
|
|
137
|
+
.addCommand(teams_1.teams)
|
|
138
|
+
.addCommand(tokens_1.tokens)
|
|
139
|
+
.addCommand(users_1.users)
|
|
140
|
+
.addCommand(vcs_1.vcs)
|
|
141
|
+
.addCommand(generic_1.client)
|
|
142
|
+
.parse(process.argv);
|
|
143
|
+
process.stdout.columns = oldWidth;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAEA,qDAAqD;AACrD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,OAA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AAC,aAAM,CAAC;SAClB,UAAU,CAAC,SAAG,CAAC;SACf,UAAU,CAAC,eAAM,CAAC;SAClB,UAAU,CAAC,gBAAM,CAAC;SAClB,UAAU,CAAC,iBAAO,CAAC;SACnB,UAAU,CAAC,iBAAO,CAAC;SACnB,UAAU,CAAC,qBAAS,CAAC;SACrB,UAAU,CAAC,qBAAS,CAAC;SACrB,UAAU,CAAC,iBAAO,CAAC;SACnB,UAAU,CAAC,eAAM,CAAC;SAClB,UAAU,CAAC,eAAM,CAAC;SAClB,UAAU,CAAC,qBAAS,CAAC;SACrB,UAAU,CAAC,uBAAU,CAAC;SACtB,UAAU,CAAC,iBAAO,CAAC;SACnB,UAAU,CAAC,mBAAQ,CAAC;SACpB,UAAU,CAAC,aAAK,CAAC;SACjB,UAAU,CAAC,aAAK,CAAC;SACjB,UAAU,CAAC,iBAAO,CAAC;SACnB,UAAU,CAAC,oBAAQ,CAAC;SACpB,UAAU,CAAC,aAAK,CAAC;SACjB,UAAU,CAAC,eAAM,CAAC;SAClB,UAAU,CAAC,aAAK,CAAC;SACjB,UAAU,CAAC,SAAG,CAAC;SACf,UAAU,CAAC,gBAAM,CAAC;SAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEzB,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { Headers, RequestParams, ResponseType } from './types';
|
|
2
|
+
declare class Client {
|
|
3
|
+
private readonly CHUNK_SIZE;
|
|
4
|
+
private endpoint;
|
|
5
|
+
private headers;
|
|
6
|
+
private selfSigned;
|
|
7
|
+
constructor();
|
|
8
|
+
/**
|
|
9
|
+
* Set Cookie
|
|
10
|
+
*
|
|
11
|
+
* Your cookie
|
|
12
|
+
*
|
|
13
|
+
* @param {string} cookie
|
|
14
|
+
*
|
|
15
|
+
* @return self
|
|
16
|
+
*/
|
|
17
|
+
setCookie(cookie: string): this;
|
|
18
|
+
/**
|
|
19
|
+
* Set Project
|
|
20
|
+
*
|
|
21
|
+
* Your project ID
|
|
22
|
+
*
|
|
23
|
+
* @param {string} project
|
|
24
|
+
*
|
|
25
|
+
* @return self
|
|
26
|
+
*/
|
|
27
|
+
setProject(project: string): this;
|
|
28
|
+
/**
|
|
29
|
+
* Set Key
|
|
30
|
+
*
|
|
31
|
+
* Your secret API key
|
|
32
|
+
*
|
|
33
|
+
* @param {string} key
|
|
34
|
+
*
|
|
35
|
+
* @return self
|
|
36
|
+
*/
|
|
37
|
+
setKey(key: string): this;
|
|
38
|
+
/**
|
|
39
|
+
* Set JWT
|
|
40
|
+
*
|
|
41
|
+
* Your secret JSON Web Token
|
|
42
|
+
*
|
|
43
|
+
* @param {string} jwt
|
|
44
|
+
*
|
|
45
|
+
* @return self
|
|
46
|
+
*/
|
|
47
|
+
setJWT(jwt: string): this;
|
|
48
|
+
/**
|
|
49
|
+
* Set Locale
|
|
50
|
+
*
|
|
51
|
+
* @param {string} locale
|
|
52
|
+
*
|
|
53
|
+
* @return self
|
|
54
|
+
*/
|
|
55
|
+
setLocale(locale: string): this;
|
|
56
|
+
/**
|
|
57
|
+
* Set Mode
|
|
58
|
+
*
|
|
59
|
+
* @param {string} mode
|
|
60
|
+
*
|
|
61
|
+
* @return self
|
|
62
|
+
*/
|
|
63
|
+
setMode(mode: string): this;
|
|
64
|
+
/**
|
|
65
|
+
* Set self signed.
|
|
66
|
+
*
|
|
67
|
+
* @param {bool} status
|
|
68
|
+
*
|
|
69
|
+
* @return this
|
|
70
|
+
*/
|
|
71
|
+
setSelfSigned(status: boolean): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set endpoint.
|
|
74
|
+
*
|
|
75
|
+
* @param {string} endpoint
|
|
76
|
+
*
|
|
77
|
+
* @return this
|
|
78
|
+
*/
|
|
79
|
+
setEndpoint(endpoint: string): this;
|
|
80
|
+
/**
|
|
81
|
+
* @param {string} key
|
|
82
|
+
* @param {string} value
|
|
83
|
+
*/
|
|
84
|
+
addHeader(key: string, value: string): this;
|
|
85
|
+
call<T = unknown>(method: string, path?: string, headers?: Headers, params?: RequestParams, responseType?: ResponseType): Promise<T>;
|
|
86
|
+
static flatten(data: RequestParams, prefix?: string): Record<string, unknown>;
|
|
87
|
+
}
|
|
88
|
+
export = Client;
|
|
89
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAc,MAAM,SAAS,CAAC;AAIhF,cAAM,MAAM;IACR,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAmB;IAC9C,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,UAAU,CAAU;;IAgB5B;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B;;;;;;;;OAQG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAKjC;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKzB;;;;;;;;OAQG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAKzB;;;;;;OAMG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAK/B;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK3B;;;;;;OAMG;IACH,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAKpC;;;;;;OAMG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IASnC;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAKrC,IAAI,CAAC,CAAC,GAAG,OAAO,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,GAAE,MAAW,EACjB,OAAO,GAAE,OAAY,EACrB,MAAM,GAAE,aAAkB,EAC1B,YAAY,GAAE,YAAqB,GACpC,OAAO,CAAC,CAAC,CAAC;IAuFb,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,GAAE,MAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAgBpF;AAED,SAAS,MAAM,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const os = require("os");
|
|
3
|
+
const undici_1 = require("undici");
|
|
4
|
+
const JSONbig = require("json-bigint");
|
|
5
|
+
const AppwriteException = require("./exception");
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const chalk = require("chalk");
|
|
8
|
+
const JSONBigInt = JSONbig({ storeAsString: false });
|
|
9
|
+
class Client {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.CHUNK_SIZE = 5 * 1024 * 1024; // 5MB
|
|
12
|
+
this.endpoint = 'https://cloud.appwrite.io/v1';
|
|
13
|
+
this.selfSigned = false;
|
|
14
|
+
this.headers = {
|
|
15
|
+
'content-type': '',
|
|
16
|
+
'x-sdk-name': 'Command Line',
|
|
17
|
+
'x-sdk-platform': 'console',
|
|
18
|
+
'x-sdk-language': 'cli',
|
|
19
|
+
'x-sdk-version': '13.0.0-rc.1',
|
|
20
|
+
'user-agent': `AppwriteCLI/13.0.0-rc.1 (${os.type()} ${os.version()}; ${os.arch()})`,
|
|
21
|
+
'X-Appwrite-Response-Format': '1.8.0',
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set Cookie
|
|
26
|
+
*
|
|
27
|
+
* Your cookie
|
|
28
|
+
*
|
|
29
|
+
* @param {string} cookie
|
|
30
|
+
*
|
|
31
|
+
* @return self
|
|
32
|
+
*/
|
|
33
|
+
setCookie(cookie) {
|
|
34
|
+
this.addHeader('cookie', cookie);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Set Project
|
|
39
|
+
*
|
|
40
|
+
* Your project ID
|
|
41
|
+
*
|
|
42
|
+
* @param {string} project
|
|
43
|
+
*
|
|
44
|
+
* @return self
|
|
45
|
+
*/
|
|
46
|
+
setProject(project) {
|
|
47
|
+
this.addHeader('X-Appwrite-Project', project);
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set Key
|
|
52
|
+
*
|
|
53
|
+
* Your secret API key
|
|
54
|
+
*
|
|
55
|
+
* @param {string} key
|
|
56
|
+
*
|
|
57
|
+
* @return self
|
|
58
|
+
*/
|
|
59
|
+
setKey(key) {
|
|
60
|
+
this.addHeader('X-Appwrite-Key', key);
|
|
61
|
+
return this;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Set JWT
|
|
65
|
+
*
|
|
66
|
+
* Your secret JSON Web Token
|
|
67
|
+
*
|
|
68
|
+
* @param {string} jwt
|
|
69
|
+
*
|
|
70
|
+
* @return self
|
|
71
|
+
*/
|
|
72
|
+
setJWT(jwt) {
|
|
73
|
+
this.addHeader('X-Appwrite-JWT', jwt);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Set Locale
|
|
78
|
+
*
|
|
79
|
+
* @param {string} locale
|
|
80
|
+
*
|
|
81
|
+
* @return self
|
|
82
|
+
*/
|
|
83
|
+
setLocale(locale) {
|
|
84
|
+
this.addHeader('X-Appwrite-Locale', locale);
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Set Mode
|
|
89
|
+
*
|
|
90
|
+
* @param {string} mode
|
|
91
|
+
*
|
|
92
|
+
* @return self
|
|
93
|
+
*/
|
|
94
|
+
setMode(mode) {
|
|
95
|
+
this.addHeader('X-Appwrite-Mode', mode);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Set self signed.
|
|
100
|
+
*
|
|
101
|
+
* @param {bool} status
|
|
102
|
+
*
|
|
103
|
+
* @return this
|
|
104
|
+
*/
|
|
105
|
+
setSelfSigned(status) {
|
|
106
|
+
this.selfSigned = status;
|
|
107
|
+
return this;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Set endpoint.
|
|
111
|
+
*
|
|
112
|
+
* @param {string} endpoint
|
|
113
|
+
*
|
|
114
|
+
* @return this
|
|
115
|
+
*/
|
|
116
|
+
setEndpoint(endpoint) {
|
|
117
|
+
if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
|
|
118
|
+
throw new AppwriteException('Invalid endpoint URL: ' + endpoint);
|
|
119
|
+
}
|
|
120
|
+
this.endpoint = endpoint;
|
|
121
|
+
return this;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* @param {string} key
|
|
125
|
+
* @param {string} value
|
|
126
|
+
*/
|
|
127
|
+
addHeader(key, value) {
|
|
128
|
+
this.headers[key.toLowerCase()] = value;
|
|
129
|
+
return this;
|
|
130
|
+
}
|
|
131
|
+
async call(method, path = '', headers = {}, params = {}, responseType = 'json') {
|
|
132
|
+
const mergedHeaders = { ...this.headers, ...headers };
|
|
133
|
+
const url = new URL(this.endpoint + path);
|
|
134
|
+
let body = undefined;
|
|
135
|
+
if (method.toUpperCase() === 'GET') {
|
|
136
|
+
url.search = new URLSearchParams(Client.flatten(params)).toString();
|
|
137
|
+
}
|
|
138
|
+
else if (mergedHeaders['content-type']?.toLowerCase().startsWith('multipart/form-data')) {
|
|
139
|
+
delete mergedHeaders['content-type'];
|
|
140
|
+
const formData = new undici_1.FormData();
|
|
141
|
+
const flatParams = Client.flatten(params);
|
|
142
|
+
for (const [key, value] of Object.entries(flatParams)) {
|
|
143
|
+
if (value && typeof value === 'object' && 'type' in value && value.type === 'file') {
|
|
144
|
+
const fileUpload = value;
|
|
145
|
+
formData.append(key, fileUpload.file, fileUpload.filename);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
formData.append(key, value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
body = formData;
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
body = JSONBigInt.stringify(params);
|
|
155
|
+
}
|
|
156
|
+
let response = undefined;
|
|
157
|
+
try {
|
|
158
|
+
response = await (0, undici_1.fetch)(url.toString(), {
|
|
159
|
+
method: method.toUpperCase(),
|
|
160
|
+
headers: mergedHeaders,
|
|
161
|
+
body,
|
|
162
|
+
dispatcher: new undici_1.Agent({
|
|
163
|
+
connect: {
|
|
164
|
+
rejectUnauthorized: !this.selfSigned,
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
throw new AppwriteException(error.message);
|
|
171
|
+
}
|
|
172
|
+
if (response.status >= 400) {
|
|
173
|
+
const text = await response.text();
|
|
174
|
+
let json = undefined;
|
|
175
|
+
try {
|
|
176
|
+
json = JSON.parse(text);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
throw new AppwriteException(text, response.status, '', text);
|
|
180
|
+
}
|
|
181
|
+
if (path !== '/account' && json.code === 401 && json.type === 'user_more_factors_required') {
|
|
182
|
+
console.log(`${chalk.cyan.bold('ℹ Info')} ${chalk.cyan('Unusable account found, removing...')}`);
|
|
183
|
+
const current = config_1.globalConfig.getCurrentSession();
|
|
184
|
+
config_1.globalConfig.setCurrentSession('');
|
|
185
|
+
config_1.globalConfig.removeSession(current);
|
|
186
|
+
}
|
|
187
|
+
throw new AppwriteException(json.message || text, json.code, json.type, text);
|
|
188
|
+
}
|
|
189
|
+
if (responseType === 'arraybuffer') {
|
|
190
|
+
const data = await response.arrayBuffer();
|
|
191
|
+
return data;
|
|
192
|
+
}
|
|
193
|
+
const cookies = response.headers.getSetCookie();
|
|
194
|
+
if (cookies && cookies.length > 0) {
|
|
195
|
+
for (const cookie of cookies) {
|
|
196
|
+
if (cookie.startsWith('a_session_console=')) {
|
|
197
|
+
config_1.globalConfig.setCookie(cookie);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
const text = await response.text();
|
|
202
|
+
let json = undefined;
|
|
203
|
+
try {
|
|
204
|
+
json = JSONBigInt.parse(text);
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
return text;
|
|
208
|
+
}
|
|
209
|
+
return json;
|
|
210
|
+
}
|
|
211
|
+
static flatten(data, prefix = '') {
|
|
212
|
+
let output = {};
|
|
213
|
+
for (const key in data) {
|
|
214
|
+
const value = data[key];
|
|
215
|
+
const finalKey = prefix ? prefix + '[' + key + ']' : key;
|
|
216
|
+
if (Array.isArray(value)) {
|
|
217
|
+
output = { ...output, ...Client.flatten(value, finalKey) };
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
output[finalKey] = value;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return output;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
module.exports = Client;
|
|
227
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../lib/client.ts"],"names":[],"mappings":";AAAA,yBAA0B;AAC1B,mCAAgD;AAChD,uCAAwC;AACxC,iDAAkD;AAClD,qCAAwC;AACxC,+BAAgC;AAGhC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;AAErD,MAAM,MAAM;IAMR;QALiB,eAAU,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,MAAM;QAMjD,IAAI,CAAC,QAAQ,GAAG,8BAA8B,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG;YACX,cAAc,EAAE,EAAE;YAClB,YAAY,EAAE,cAAc;YAC5B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