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
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.questionsCreateSite = exports.questionsRunFunctions = exports.questionsMFAChallenge = exports.questionsListFactors = exports.questionsPushTeams = exports.questionsGetEntrypoint = exports.questionsPushMessagingTopics = exports.questionsPushBuckets = exports.questionPushChangesConfirmation = exports.questionPushChanges = exports.questionsPushTables = exports.questionsPushCollections = exports.questionsPushFunctions = exports.questionsPushSites = exports.questionsInitResources = exports.questionsPushResources = exports.questionsLogout = exports.questionGetEndpoint = exports.questionsLogin = exports.questionsPullCollection = exports.questionsCreateMessagingTopic = exports.questionsCreateTable = exports.questionsCreateCollection = exports.questionsCreateTeam = exports.questionsCreateBucket = exports.questionsCreateFunctionSelectTemplate = exports.questionsCreateFunction = exports.questionsPullSitesCode = exports.questionsPullSites = exports.questionsPullFunctionsCode = exports.questionsPullFunctions = exports.questionsPullResources = exports.questionsInitProjectAutopull = exports.questionsInitProject = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const client_1 = __importDefault(require("./client"));
|
|
9
|
+
const config_1 = require("./config");
|
|
10
|
+
const projects_1 = require("./commands/projects");
|
|
11
|
+
const organizations_1 = require("./commands/organizations");
|
|
12
|
+
const teams_1 = require("./commands/teams");
|
|
13
|
+
const functions_1 = require("./commands/functions");
|
|
14
|
+
const account_1 = require("./commands/account");
|
|
15
|
+
const sdks_1 = require("./sdks");
|
|
16
|
+
const validations_1 = require("./validations");
|
|
17
|
+
const paginate_1 = require("./paginate");
|
|
18
|
+
const utils_1 = require("./utils");
|
|
19
|
+
const databases_1 = require("./commands/databases");
|
|
20
|
+
const json_bigint_1 = __importDefault(require("json-bigint"));
|
|
21
|
+
const sites_1 = require("./commands/sites");
|
|
22
|
+
const JSONbigConfig = (0, json_bigint_1.default)({ storeAsString: false });
|
|
23
|
+
const whenOverride = (answers) => answers.override === undefined ? true : answers.override;
|
|
24
|
+
const getIgnores = (runtime) => {
|
|
25
|
+
const languge = runtime.split("-").slice(0, -1).join("-");
|
|
26
|
+
switch (languge) {
|
|
27
|
+
case 'cpp':
|
|
28
|
+
return ['build', 'CMakeFiles', 'CMakeCaches.txt'];
|
|
29
|
+
case 'dart':
|
|
30
|
+
return ['.packages', '.dart_tool'];
|
|
31
|
+
case 'deno':
|
|
32
|
+
return [];
|
|
33
|
+
case 'dotnet':
|
|
34
|
+
return ['bin', 'obj', '.nuget'];
|
|
35
|
+
case 'java':
|
|
36
|
+
case 'kotlin':
|
|
37
|
+
return ['build'];
|
|
38
|
+
case 'node':
|
|
39
|
+
case 'bun':
|
|
40
|
+
return ['node_modules', '.npm'];
|
|
41
|
+
case 'php':
|
|
42
|
+
return ['vendor'];
|
|
43
|
+
case 'python':
|
|
44
|
+
case 'python-ml':
|
|
45
|
+
return ['__pypackages__'];
|
|
46
|
+
case 'ruby':
|
|
47
|
+
return ['vendor'];
|
|
48
|
+
case 'rust':
|
|
49
|
+
return ['target', 'debug', '*.rs.bk', '*.pdb'];
|
|
50
|
+
case 'swift':
|
|
51
|
+
return ['.build', '.swiftpm'];
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
};
|
|
55
|
+
const getEntrypoint = (runtime) => {
|
|
56
|
+
const languge = runtime.split("-").slice(0, -1).join("-");
|
|
57
|
+
switch (languge) {
|
|
58
|
+
case 'dart':
|
|
59
|
+
return 'lib/main.dart';
|
|
60
|
+
case 'deno':
|
|
61
|
+
return 'src/main.ts';
|
|
62
|
+
case 'node':
|
|
63
|
+
return 'src/main.js';
|
|
64
|
+
case 'bun':
|
|
65
|
+
return 'src/main.ts';
|
|
66
|
+
case 'php':
|
|
67
|
+
return 'src/index.php';
|
|
68
|
+
case 'python':
|
|
69
|
+
case 'python-ml':
|
|
70
|
+
return 'src/main.py';
|
|
71
|
+
case 'ruby':
|
|
72
|
+
return 'lib/main.rb';
|
|
73
|
+
case 'rust':
|
|
74
|
+
return 'main.rs';
|
|
75
|
+
case 'swift':
|
|
76
|
+
return 'Sources/index.swift';
|
|
77
|
+
case 'cpp':
|
|
78
|
+
return 'src/main.cc';
|
|
79
|
+
case 'dotnet':
|
|
80
|
+
return 'src/Index.cs';
|
|
81
|
+
case 'java':
|
|
82
|
+
return 'src/Main.java';
|
|
83
|
+
case 'kotlin':
|
|
84
|
+
return 'src/Main.kt';
|
|
85
|
+
case 'go':
|
|
86
|
+
return 'main.go';
|
|
87
|
+
}
|
|
88
|
+
return undefined;
|
|
89
|
+
};
|
|
90
|
+
const getInstallCommand = (runtime) => {
|
|
91
|
+
const languge = runtime.split("-").slice(0, -1).join("-");
|
|
92
|
+
switch (languge) {
|
|
93
|
+
case 'dart':
|
|
94
|
+
return 'dart pub get';
|
|
95
|
+
case 'deno':
|
|
96
|
+
return "deno cache src/main.ts";
|
|
97
|
+
case 'node':
|
|
98
|
+
return 'npm install';
|
|
99
|
+
case 'bun':
|
|
100
|
+
return 'bun install';
|
|
101
|
+
case 'php':
|
|
102
|
+
return 'composer install';
|
|
103
|
+
case 'python':
|
|
104
|
+
case 'python-ml':
|
|
105
|
+
return 'pip install -r requirements.txt';
|
|
106
|
+
case 'ruby':
|
|
107
|
+
return 'bundle install';
|
|
108
|
+
case 'rust':
|
|
109
|
+
return 'cargo install';
|
|
110
|
+
case 'dotnet':
|
|
111
|
+
return 'dotnet restore';
|
|
112
|
+
case 'swift':
|
|
113
|
+
case 'java':
|
|
114
|
+
case 'kotlin':
|
|
115
|
+
case 'cpp':
|
|
116
|
+
return '';
|
|
117
|
+
}
|
|
118
|
+
return undefined;
|
|
119
|
+
};
|
|
120
|
+
exports.questionsInitProject = [
|
|
121
|
+
{
|
|
122
|
+
type: "confirm",
|
|
123
|
+
name: "override",
|
|
124
|
+
message: `An Appwrite project ( ${config_1.localConfig.getProject()['projectId']} ) is already associated with the current directory. Would you like to override`,
|
|
125
|
+
when() {
|
|
126
|
+
return Object.keys(config_1.localConfig.getProject()).length !== 0;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
type: "list",
|
|
131
|
+
name: "start",
|
|
132
|
+
when: whenOverride,
|
|
133
|
+
message: "How would you like to start?",
|
|
134
|
+
choices: [
|
|
135
|
+
{
|
|
136
|
+
name: "Create new project",
|
|
137
|
+
value: "new"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "Link directory to an existing project",
|
|
141
|
+
value: "existing"
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
type: "search-list",
|
|
147
|
+
name: "organization",
|
|
148
|
+
message: "Choose your organization",
|
|
149
|
+
choices: async () => {
|
|
150
|
+
let client = await (0, sdks_1.sdkForConsole)(true);
|
|
151
|
+
const { teams } = (0, utils_1.isCloud)()
|
|
152
|
+
? await (0, paginate_1.paginate)(organizations_1.organizationsList, { parseOutput: false, sdk: client }, 100, 'teams')
|
|
153
|
+
: await (0, paginate_1.paginate)(teams_1.teamsList, { parseOutput: false, sdk: client }, 100, 'teams');
|
|
154
|
+
let choices = teams.map((team, idx) => {
|
|
155
|
+
return {
|
|
156
|
+
name: `${team.name} (${team['$id']})`,
|
|
157
|
+
value: team['$id']
|
|
158
|
+
};
|
|
159
|
+
});
|
|
160
|
+
if (choices.length == 0) {
|
|
161
|
+
throw new Error(`No organizations found. Please create a new organization at ${config_1.globalConfig.getEndpoint().replace('/v1', '/console/onboarding')}`);
|
|
162
|
+
}
|
|
163
|
+
return choices;
|
|
164
|
+
},
|
|
165
|
+
when: whenOverride
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
type: "input",
|
|
169
|
+
name: "project",
|
|
170
|
+
message: "What would you like to name your project?",
|
|
171
|
+
default: "My Awesome Project",
|
|
172
|
+
when: (answer) => answer.start !== 'existing'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: "input",
|
|
176
|
+
name: "id",
|
|
177
|
+
message: "What ID would you like to have for your project?",
|
|
178
|
+
default: "unique()",
|
|
179
|
+
when: (answer) => answer.start !== 'existing'
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: "search-list",
|
|
183
|
+
name: "project",
|
|
184
|
+
message: "Choose your Appwrite project.",
|
|
185
|
+
choices: async (answers) => {
|
|
186
|
+
const queries = [
|
|
187
|
+
JSON.stringify({ method: 'equal', attribute: 'teamId', values: [answers.organization] }),
|
|
188
|
+
JSON.stringify({ method: 'orderDesc', attribute: '$id' })
|
|
189
|
+
];
|
|
190
|
+
const { projects } = await (0, paginate_1.paginate)(projects_1.projectsList, { parseOutput: false }, 100, 'projects', queries);
|
|
191
|
+
let choices = projects.map((project) => {
|
|
192
|
+
return {
|
|
193
|
+
name: `${project.name} (${project['$id']})`,
|
|
194
|
+
value: {
|
|
195
|
+
"$id": project['$id'],
|
|
196
|
+
"region": project.region || ''
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
});
|
|
200
|
+
if (choices.length === 0) {
|
|
201
|
+
throw new Error("No projects found. Please create a new project.");
|
|
202
|
+
}
|
|
203
|
+
return choices;
|
|
204
|
+
},
|
|
205
|
+
when: (answer) => answer.start === 'existing'
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
type: "list",
|
|
209
|
+
name: "region",
|
|
210
|
+
message: "Select your Appwrite Cloud region",
|
|
211
|
+
choices: async () => {
|
|
212
|
+
let client = await (0, sdks_1.sdkForConsole)(true);
|
|
213
|
+
let response = await client.call("GET", "/console/regions");
|
|
214
|
+
let regions = response.regions || [];
|
|
215
|
+
if (!regions.length) {
|
|
216
|
+
throw new Error("No regions found. Please check your network or Appwrite Cloud availability.");
|
|
217
|
+
}
|
|
218
|
+
return regions.filter((region) => !region.disabled).map((region) => ({
|
|
219
|
+
name: `${region.name} (${region.$id})`,
|
|
220
|
+
value: region.$id
|
|
221
|
+
}));
|
|
222
|
+
},
|
|
223
|
+
when: (answer) => {
|
|
224
|
+
if (answer.start === 'existing')
|
|
225
|
+
return false;
|
|
226
|
+
return (0, utils_1.isCloud)();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
];
|
|
230
|
+
exports.questionsInitProjectAutopull = [
|
|
231
|
+
{
|
|
232
|
+
type: "confirm",
|
|
233
|
+
name: "autopull",
|
|
234
|
+
message: `Would you like to pull all resources from project you just linked?`
|
|
235
|
+
},
|
|
236
|
+
];
|
|
237
|
+
exports.questionsPullResources = [
|
|
238
|
+
{
|
|
239
|
+
type: "list",
|
|
240
|
+
name: "resource",
|
|
241
|
+
message: "Which resources would you like to pull?",
|
|
242
|
+
choices: [
|
|
243
|
+
{ name: `Settings ${chalk_1.default.blackBright(`(Project)`)}`, value: 'settings' },
|
|
244
|
+
{ name: `Functions ${chalk_1.default.blackBright(`(Deployment)`)}`, value: 'functions' },
|
|
245
|
+
{ name: `Tables ${chalk_1.default.blackBright(`(TablesDB)`)}`, value: 'tables' },
|
|
246
|
+
{ name: `Buckets ${chalk_1.default.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
247
|
+
{ name: `Teams ${chalk_1.default.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
248
|
+
{ name: `Topics ${chalk_1.default.blackBright(`(Messaging)`)}`, value: 'messages' },
|
|
249
|
+
{ name: `Collections ${chalk_1.default.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
];
|
|
253
|
+
exports.questionsPullFunctions = [
|
|
254
|
+
{
|
|
255
|
+
type: "checkbox",
|
|
256
|
+
name: "functions",
|
|
257
|
+
message: "Which functions would you like to pull?",
|
|
258
|
+
validate: (value) => (0, validations_1.validateRequired)('function', value),
|
|
259
|
+
choices: async () => {
|
|
260
|
+
const { functions } = await (0, paginate_1.paginate)(functions_1.functionsList, { parseOutput: false }, 100, 'functions');
|
|
261
|
+
if (functions.length === 0) {
|
|
262
|
+
throw "We couldn't find any functions in your Appwrite project";
|
|
263
|
+
}
|
|
264
|
+
return functions.map((func) => {
|
|
265
|
+
return {
|
|
266
|
+
name: `${func.name} (${func.$id})`,
|
|
267
|
+
value: { ...func }
|
|
268
|
+
};
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
];
|
|
273
|
+
exports.questionsPullFunctionsCode = [
|
|
274
|
+
{
|
|
275
|
+
type: "confirm",
|
|
276
|
+
name: "override",
|
|
277
|
+
message: "Do you want to pull source code of the latest deployment?"
|
|
278
|
+
},
|
|
279
|
+
];
|
|
280
|
+
exports.questionsPullSites = [
|
|
281
|
+
{
|
|
282
|
+
type: "checkbox",
|
|
283
|
+
name: "sites",
|
|
284
|
+
message: "Which sites would you like to pull?",
|
|
285
|
+
validate: (value) => (0, validations_1.validateRequired)('site', value),
|
|
286
|
+
choices: async () => {
|
|
287
|
+
const { sites } = await (0, paginate_1.paginate)(sites_1.sitesList, { parseOutput: false }, 100, 'sites');
|
|
288
|
+
if (sites.length === 0) {
|
|
289
|
+
throw "We couldn't find any sites in your Appwrite project";
|
|
290
|
+
}
|
|
291
|
+
return sites.map((site) => {
|
|
292
|
+
return {
|
|
293
|
+
name: `${site.name} (${site.$id})`,
|
|
294
|
+
value: { ...site }
|
|
295
|
+
};
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
];
|
|
300
|
+
exports.questionsPullSitesCode = [
|
|
301
|
+
{
|
|
302
|
+
type: "confirm",
|
|
303
|
+
name: "override",
|
|
304
|
+
message: "Do you want to pull source code of the latest deployment?"
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
exports.questionsCreateFunction = [
|
|
308
|
+
{
|
|
309
|
+
type: "input",
|
|
310
|
+
name: "name",
|
|
311
|
+
message: "What would you like to name your function?",
|
|
312
|
+
default: "My Awesome Function"
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
type: "input",
|
|
316
|
+
name: "id",
|
|
317
|
+
message: "What ID would you like to have for your function?",
|
|
318
|
+
default: "unique()"
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
type: "list",
|
|
322
|
+
name: "runtime",
|
|
323
|
+
message: "What runtime would you like to use?",
|
|
324
|
+
choices: async () => {
|
|
325
|
+
let response = await (0, functions_1.functionsListRuntimes)({
|
|
326
|
+
parseOutput: false
|
|
327
|
+
});
|
|
328
|
+
let runtimes = response["runtimes"];
|
|
329
|
+
let choices = runtimes.map((runtime, idx) => {
|
|
330
|
+
return {
|
|
331
|
+
name: `${runtime.name} (${runtime['$id']})`,
|
|
332
|
+
value: {
|
|
333
|
+
id: runtime['$id'],
|
|
334
|
+
name: runtime['$id'].split('-')[0],
|
|
335
|
+
entrypoint: getEntrypoint(runtime['$id']),
|
|
336
|
+
ignore: getIgnores(runtime['$id']),
|
|
337
|
+
commands: getInstallCommand(runtime['$id'])
|
|
338
|
+
},
|
|
339
|
+
};
|
|
340
|
+
});
|
|
341
|
+
return choices;
|
|
342
|
+
},
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
type: "list",
|
|
346
|
+
name: "specification",
|
|
347
|
+
message: "What specification would you like to use?",
|
|
348
|
+
choices: async () => {
|
|
349
|
+
let response = await (0, functions_1.functionsListSpecifications)({
|
|
350
|
+
parseOutput: false
|
|
351
|
+
});
|
|
352
|
+
let specifications = response["specifications"];
|
|
353
|
+
let choices = specifications.map((spec, idx) => {
|
|
354
|
+
return {
|
|
355
|
+
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
356
|
+
value: spec.slug,
|
|
357
|
+
disabled: spec.enabled === false ? 'Upgrade to use' : false
|
|
358
|
+
};
|
|
359
|
+
});
|
|
360
|
+
return choices;
|
|
361
|
+
},
|
|
362
|
+
}
|
|
363
|
+
];
|
|
364
|
+
const questionsCreateFunctionSelectTemplate = (templates) => {
|
|
365
|
+
return [
|
|
366
|
+
{
|
|
367
|
+
type: "search-list",
|
|
368
|
+
name: "template",
|
|
369
|
+
message: "What template would you like to use?",
|
|
370
|
+
choices: templates.map((template) => {
|
|
371
|
+
const name = `${template[0].toUpperCase()}${template.split('').slice(1).join('')}`.replace(/[-_]/g, ' ');
|
|
372
|
+
return { value: template, name };
|
|
373
|
+
})
|
|
374
|
+
}
|
|
375
|
+
];
|
|
376
|
+
};
|
|
377
|
+
exports.questionsCreateFunctionSelectTemplate = questionsCreateFunctionSelectTemplate;
|
|
378
|
+
exports.questionsCreateBucket = [
|
|
379
|
+
{
|
|
380
|
+
type: "input",
|
|
381
|
+
name: "bucket",
|
|
382
|
+
message: "What would you like to name your bucket?",
|
|
383
|
+
default: "My Awesome Bucket"
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
type: "input",
|
|
387
|
+
name: "id",
|
|
388
|
+
message: "What ID would you like to have for your bucket?",
|
|
389
|
+
default: "unique()"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
type: "list",
|
|
393
|
+
name: "fileSecurity",
|
|
394
|
+
message: "Enable File-Security configuring permissions for individual file",
|
|
395
|
+
choices: ["No", "Yes"]
|
|
396
|
+
}
|
|
397
|
+
];
|
|
398
|
+
exports.questionsCreateTeam = [
|
|
399
|
+
{
|
|
400
|
+
type: "input",
|
|
401
|
+
name: "bucket",
|
|
402
|
+
message: "What would you like to name your team?",
|
|
403
|
+
default: "My Awesome Team"
|
|
404
|
+
},
|
|
405
|
+
{
|
|
406
|
+
type: "input",
|
|
407
|
+
name: "id",
|
|
408
|
+
message: "What ID would you like to have for your team?",
|
|
409
|
+
default: "unique()"
|
|
410
|
+
}
|
|
411
|
+
];
|
|
412
|
+
exports.questionsCreateCollection = [
|
|
413
|
+
{
|
|
414
|
+
type: "list",
|
|
415
|
+
name: "method",
|
|
416
|
+
message: "What database would you like to use for your collection",
|
|
417
|
+
choices: ["New", "Existing"],
|
|
418
|
+
when: async () => {
|
|
419
|
+
return config_1.localConfig.getDatabases().length !== 0;
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
type: "search-list",
|
|
424
|
+
name: "database",
|
|
425
|
+
message: "Choose the collection database",
|
|
426
|
+
choices: async () => {
|
|
427
|
+
const databases = config_1.localConfig.getDatabases();
|
|
428
|
+
let choices = databases.map((database, idx) => {
|
|
429
|
+
return {
|
|
430
|
+
name: `${database.name} (${database.$id})`,
|
|
431
|
+
value: database.$id
|
|
432
|
+
};
|
|
433
|
+
});
|
|
434
|
+
if (choices.length === 0) {
|
|
435
|
+
throw new Error("No databases found. Please create one in project console.");
|
|
436
|
+
}
|
|
437
|
+
return choices;
|
|
438
|
+
},
|
|
439
|
+
when: (answers) => (answers.method ?? '').toLowerCase() === 'existing'
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
type: "input",
|
|
443
|
+
name: "databaseName",
|
|
444
|
+
message: "What would you like to name your database?",
|
|
445
|
+
default: "My Awesome Database",
|
|
446
|
+
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
|
|
447
|
+
},
|
|
448
|
+
{
|
|
449
|
+
type: "input",
|
|
450
|
+
name: "databaseId",
|
|
451
|
+
message: "What ID would you like to have for your database?",
|
|
452
|
+
default: "unique()",
|
|
453
|
+
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: "input",
|
|
457
|
+
name: "collection",
|
|
458
|
+
message: "What would you like to name your collection?",
|
|
459
|
+
default: "My Awesome Collection"
|
|
460
|
+
},
|
|
461
|
+
{
|
|
462
|
+
type: "input",
|
|
463
|
+
name: "id",
|
|
464
|
+
message: "What ID would you like to have for your collection?",
|
|
465
|
+
default: "unique()"
|
|
466
|
+
},
|
|
467
|
+
{
|
|
468
|
+
type: "list",
|
|
469
|
+
name: "documentSecurity",
|
|
470
|
+
message: "Enable document security for configuring permissions for individual documents",
|
|
471
|
+
choices: ["No", "Yes"]
|
|
472
|
+
}
|
|
473
|
+
];
|
|
474
|
+
exports.questionsCreateTable = [
|
|
475
|
+
{
|
|
476
|
+
type: "list",
|
|
477
|
+
name: "method",
|
|
478
|
+
message: "What database would you like to use for your table?",
|
|
479
|
+
choices: ["New", "Existing"],
|
|
480
|
+
when: async () => {
|
|
481
|
+
return config_1.localConfig.getTablesDBs().length !== 0;
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
{
|
|
485
|
+
type: "search-list",
|
|
486
|
+
name: "database",
|
|
487
|
+
message: "Choose the table database",
|
|
488
|
+
choices: async () => {
|
|
489
|
+
const databases = config_1.localConfig.getTablesDBs();
|
|
490
|
+
let choices = databases.map((database, idx) => {
|
|
491
|
+
return {
|
|
492
|
+
name: `${database.name} (${database.$id})`,
|
|
493
|
+
value: database.$id
|
|
494
|
+
};
|
|
495
|
+
});
|
|
496
|
+
if (choices.length === 0) {
|
|
497
|
+
throw new Error("No databases found. Please create one in project console.");
|
|
498
|
+
}
|
|
499
|
+
return choices;
|
|
500
|
+
},
|
|
501
|
+
when: (answers) => (answers.method ?? '').toLowerCase() === 'existing'
|
|
502
|
+
},
|
|
503
|
+
{
|
|
504
|
+
type: "input",
|
|
505
|
+
name: "databaseName",
|
|
506
|
+
message: "What would you like to name your database?",
|
|
507
|
+
default: "My Awesome Database",
|
|
508
|
+
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
|
|
509
|
+
},
|
|
510
|
+
{
|
|
511
|
+
type: "input",
|
|
512
|
+
name: "databaseId",
|
|
513
|
+
message: "What ID would you like to have for your database?",
|
|
514
|
+
default: "unique()",
|
|
515
|
+
when: (answers) => (answers.method ?? '').toLowerCase() !== 'existing'
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
type: "input",
|
|
519
|
+
name: "table",
|
|
520
|
+
message: "What would you like to name your table?",
|
|
521
|
+
default: "My Awesome Table"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
type: "input",
|
|
525
|
+
name: "id",
|
|
526
|
+
message: "What ID would you like to have for your table?",
|
|
527
|
+
default: "unique()"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
type: "list",
|
|
531
|
+
name: "rowSecurity",
|
|
532
|
+
message: "Enable row security for configuring permissions for individual rows",
|
|
533
|
+
choices: ["No", "Yes"]
|
|
534
|
+
}
|
|
535
|
+
];
|
|
536
|
+
exports.questionsCreateMessagingTopic = [
|
|
537
|
+
{
|
|
538
|
+
type: "input",
|
|
539
|
+
name: "topic",
|
|
540
|
+
message: "What would you like to name your messaging topic?",
|
|
541
|
+
default: "My Awesome Topic"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
type: "input",
|
|
545
|
+
name: "id",
|
|
546
|
+
message: "What ID would you like to have for your messaging topic?",
|
|
547
|
+
default: "unique()"
|
|
548
|
+
}
|
|
549
|
+
];
|
|
550
|
+
exports.questionsPullCollection = [
|
|
551
|
+
{
|
|
552
|
+
type: "checkbox",
|
|
553
|
+
name: "databases",
|
|
554
|
+
message: "From which database would you like to pull collections?",
|
|
555
|
+
validate: (value) => (0, validations_1.validateRequired)('collection', value),
|
|
556
|
+
choices: async () => {
|
|
557
|
+
let response = await (0, databases_1.databasesList)({
|
|
558
|
+
parseOutput: false
|
|
559
|
+
});
|
|
560
|
+
let databases = response["databases"];
|
|
561
|
+
if (databases.length <= 0) {
|
|
562
|
+
throw new Error("No databases found. Please create one in project console.");
|
|
563
|
+
}
|
|
564
|
+
let choices = databases.map((database, idx) => {
|
|
565
|
+
return {
|
|
566
|
+
name: `${database.name} (${database.$id})`,
|
|
567
|
+
value: database.$id
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
return choices;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
];
|
|
574
|
+
exports.questionsLogin = [
|
|
575
|
+
{
|
|
576
|
+
type: "list",
|
|
577
|
+
name: "method",
|
|
578
|
+
message: "What you like to do?",
|
|
579
|
+
choices: [
|
|
580
|
+
{ name: 'Login to an account', value: 'login' },
|
|
581
|
+
{ name: 'Switch to an account', value: 'select' }
|
|
582
|
+
],
|
|
583
|
+
when: () => config_1.globalConfig.getSessions().length >= 2
|
|
584
|
+
},
|
|
585
|
+
{
|
|
586
|
+
type: "input",
|
|
587
|
+
name: "email",
|
|
588
|
+
message: "Enter your email",
|
|
589
|
+
validate(value) {
|
|
590
|
+
if (!value) {
|
|
591
|
+
return "Please enter your email";
|
|
592
|
+
}
|
|
593
|
+
return true;
|
|
594
|
+
},
|
|
595
|
+
when: (answers) => answers.method !== 'select'
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
type: "password",
|
|
599
|
+
name: "password",
|
|
600
|
+
message: "Enter your password",
|
|
601
|
+
mask: "*",
|
|
602
|
+
validate(value) {
|
|
603
|
+
if (!value) {
|
|
604
|
+
return "Please enter your password";
|
|
605
|
+
}
|
|
606
|
+
return true;
|
|
607
|
+
},
|
|
608
|
+
when: (answers) => answers.method !== 'select'
|
|
609
|
+
},
|
|
610
|
+
{
|
|
611
|
+
type: "search-list",
|
|
612
|
+
name: "accountId",
|
|
613
|
+
message: "Select an account to use",
|
|
614
|
+
choices() {
|
|
615
|
+
const sessions = config_1.globalConfig.getSessions();
|
|
616
|
+
const current = config_1.globalConfig.getCurrentSession();
|
|
617
|
+
const data = [];
|
|
618
|
+
const longestEmail = sessions.reduce((prev, current) => (prev && (prev.email ?? '').length > (current.email ?? '').length) ? prev : current).email.length;
|
|
619
|
+
sessions.forEach((session) => {
|
|
620
|
+
if (session.email) {
|
|
621
|
+
data.push({
|
|
622
|
+
current: current === session.id,
|
|
623
|
+
value: session.id,
|
|
624
|
+
name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk_1.default.green.bold('current') : ' '.repeat(6)} ${session.endpoint}`,
|
|
625
|
+
});
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
return data.sort((a, b) => Number(b.current) - Number(a.current));
|
|
629
|
+
},
|
|
630
|
+
when: (answers) => answers.method === 'select'
|
|
631
|
+
},
|
|
632
|
+
];
|
|
633
|
+
exports.questionGetEndpoint = [
|
|
634
|
+
{
|
|
635
|
+
type: "input",
|
|
636
|
+
name: "endpoint",
|
|
637
|
+
message: "Enter the endpoint of your Appwrite server",
|
|
638
|
+
default: "http://localhost/v1",
|
|
639
|
+
async validate(value) {
|
|
640
|
+
if (!value) {
|
|
641
|
+
return "Please enter a valid endpoint.";
|
|
642
|
+
}
|
|
643
|
+
let client = new client_1.default().setEndpoint(value);
|
|
644
|
+
try {
|
|
645
|
+
let response = await client.call('get', '/health/version');
|
|
646
|
+
if (response.version) {
|
|
647
|
+
return true;
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
throw new Error();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
catch (error) {
|
|
654
|
+
return "Invalid endpoint or your Appwrite server is not running as expected.";
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
];
|
|
659
|
+
exports.questionsLogout = [
|
|
660
|
+
{
|
|
661
|
+
type: "checkbox",
|
|
662
|
+
name: "accounts",
|
|
663
|
+
message: "Select accounts to logout from",
|
|
664
|
+
validate: (value) => (0, validations_1.validateRequired)('account', value),
|
|
665
|
+
choices() {
|
|
666
|
+
const sessions = config_1.globalConfig.getSessions();
|
|
667
|
+
const current = config_1.globalConfig.getCurrentSession();
|
|
668
|
+
const data = [];
|
|
669
|
+
const longestEmail = sessions.reduce((prev, current) => (prev && (prev.email ?? '').length > (current.email ?? '').length) ? prev : current).email.length;
|
|
670
|
+
sessions.forEach((session) => {
|
|
671
|
+
if (session.email) {
|
|
672
|
+
data.push({
|
|
673
|
+
current: current === session.id,
|
|
674
|
+
value: session.id,
|
|
675
|
+
name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk_1.default.green.bold('current') : ' '.repeat(6)} ${session.endpoint}`,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
});
|
|
679
|
+
return data.sort((a, b) => Number(b.current) - Number(a.current));
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
];
|
|
683
|
+
exports.questionsPushResources = [
|
|
684
|
+
{
|
|
685
|
+
type: "list",
|
|
686
|
+
name: "resource",
|
|
687
|
+
message: "Which resources would you like to push?",
|
|
688
|
+
choices: [
|
|
689
|
+
{ name: `Settings ${chalk_1.default.blackBright(`(Project)`)}`, value: 'settings' },
|
|
690
|
+
{ name: `Functions ${chalk_1.default.blackBright(`(Deployment)`)}`, value: 'functions' },
|
|
691
|
+
{ name: `Tables ${chalk_1.default.blackBright(`(TablesDB)`)}`, value: 'tables' },
|
|
692
|
+
{ name: `Buckets ${chalk_1.default.blackBright(`(Storage)`)}`, value: 'buckets' },
|
|
693
|
+
{ name: `Teams ${chalk_1.default.blackBright(`(Auth)`)}`, value: 'teams' },
|
|
694
|
+
{ name: `Topics ${chalk_1.default.blackBright(`(Messaging)`)}`, value: 'messages' },
|
|
695
|
+
{ name: `Collections ${chalk_1.default.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
];
|
|
699
|
+
exports.questionsInitResources = [
|
|
700
|
+
{
|
|
701
|
+
type: "list",
|
|
702
|
+
name: "resource",
|
|
703
|
+
message: "Which resource would you create?",
|
|
704
|
+
choices: [
|
|
705
|
+
{ name: 'Function', value: 'function' },
|
|
706
|
+
{ name: 'Site', value: 'site' },
|
|
707
|
+
{ name: 'Table', value: 'table' },
|
|
708
|
+
{ name: 'Bucket', value: 'bucket' },
|
|
709
|
+
{ name: 'Team', value: 'team' },
|
|
710
|
+
{ name: 'Topic', value: 'message' },
|
|
711
|
+
{ name: 'Collection', value: 'collection' }
|
|
712
|
+
]
|
|
713
|
+
}
|
|
714
|
+
];
|
|
715
|
+
exports.questionsPushSites = [
|
|
716
|
+
{
|
|
717
|
+
type: "checkbox",
|
|
718
|
+
name: "sites",
|
|
719
|
+
message: "Which sites would you like to push?",
|
|
720
|
+
validate: (value) => (0, validations_1.validateRequired)('site', value),
|
|
721
|
+
when: () => config_1.localConfig.getSites().length > 0,
|
|
722
|
+
choices: () => {
|
|
723
|
+
let sites = config_1.localConfig.getSites();
|
|
724
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
725
|
+
let choices = sites.map((site, idx) => {
|
|
726
|
+
return {
|
|
727
|
+
name: `${site.name} (${site.$id})`,
|
|
728
|
+
value: site.$id
|
|
729
|
+
};
|
|
730
|
+
});
|
|
731
|
+
return choices;
|
|
732
|
+
}
|
|
733
|
+
},
|
|
734
|
+
];
|
|
735
|
+
exports.questionsPushFunctions = [
|
|
736
|
+
{
|
|
737
|
+
type: "checkbox",
|
|
738
|
+
name: "functions",
|
|
739
|
+
message: "Which functions would you like to push?",
|
|
740
|
+
validate: (value) => (0, validations_1.validateRequired)('function', value),
|
|
741
|
+
when: () => config_1.localConfig.getFunctions().length > 0,
|
|
742
|
+
choices: () => {
|
|
743
|
+
let functions = config_1.localConfig.getFunctions();
|
|
744
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
745
|
+
let choices = functions.map((func, idx) => {
|
|
746
|
+
return {
|
|
747
|
+
name: `${func.name} (${func.$id})`,
|
|
748
|
+
value: func.$id
|
|
749
|
+
};
|
|
750
|
+
});
|
|
751
|
+
return choices;
|
|
752
|
+
}
|
|
753
|
+
},
|
|
754
|
+
];
|
|
755
|
+
exports.questionsPushCollections = [
|
|
756
|
+
{
|
|
757
|
+
type: "checkbox",
|
|
758
|
+
name: "collections",
|
|
759
|
+
message: "Which collections would you like to push?",
|
|
760
|
+
validate: (value) => (0, validations_1.validateRequired)('collection', value),
|
|
761
|
+
when: () => config_1.localConfig.getCollections().length > 0,
|
|
762
|
+
choices: () => {
|
|
763
|
+
let collections = config_1.localConfig.getCollections();
|
|
764
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
765
|
+
return collections.map((collection) => {
|
|
766
|
+
return {
|
|
767
|
+
name: `${collection.name} (${collection['databaseId']} - ${collection['$id']})`,
|
|
768
|
+
value: `${collection['databaseId']}|${collection['$id']}`
|
|
769
|
+
};
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
];
|
|
774
|
+
exports.questionsPushTables = [
|
|
775
|
+
{
|
|
776
|
+
type: "checkbox",
|
|
777
|
+
name: "tables",
|
|
778
|
+
message: "Which tables would you like to push?",
|
|
779
|
+
validate: (value) => (0, validations_1.validateRequired)('table', value),
|
|
780
|
+
when: () => config_1.localConfig.getTables().length > 0,
|
|
781
|
+
choices: () => {
|
|
782
|
+
let tables = config_1.localConfig.getTables();
|
|
783
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
784
|
+
return tables.map((table) => {
|
|
785
|
+
return {
|
|
786
|
+
name: `${table.name} (${table['databaseId']} - ${table['$id']})`,
|
|
787
|
+
value: `${table['databaseId']}|${table['$id']}`
|
|
788
|
+
};
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
];
|
|
793
|
+
exports.questionPushChanges = [
|
|
794
|
+
{
|
|
795
|
+
type: "input",
|
|
796
|
+
name: "changes",
|
|
797
|
+
message: `Are you sure you want to apply these changes? (YES/NO)`
|
|
798
|
+
}
|
|
799
|
+
];
|
|
800
|
+
exports.questionPushChangesConfirmation = [
|
|
801
|
+
{
|
|
802
|
+
type: "input",
|
|
803
|
+
name: "changes",
|
|
804
|
+
message: `Please type 'YES' or 'NO':`
|
|
805
|
+
}
|
|
806
|
+
];
|
|
807
|
+
exports.questionsPushBuckets = [
|
|
808
|
+
{
|
|
809
|
+
type: "checkbox",
|
|
810
|
+
name: "buckets",
|
|
811
|
+
message: "Which buckets would you like to push?",
|
|
812
|
+
validate: (value) => (0, validations_1.validateRequired)('bucket', value),
|
|
813
|
+
when: () => config_1.localConfig.getBuckets().length > 0,
|
|
814
|
+
choices: () => {
|
|
815
|
+
let buckets = config_1.localConfig.getBuckets();
|
|
816
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
817
|
+
return buckets.map((bucket) => {
|
|
818
|
+
return {
|
|
819
|
+
name: `${bucket.name} (${bucket['$id']})`,
|
|
820
|
+
value: bucket.$id
|
|
821
|
+
};
|
|
822
|
+
});
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
];
|
|
826
|
+
exports.questionsPushMessagingTopics = [
|
|
827
|
+
{
|
|
828
|
+
type: "checkbox",
|
|
829
|
+
name: "topics",
|
|
830
|
+
message: "Which messaging topic would you like to push?",
|
|
831
|
+
validate: (value) => (0, validations_1.validateRequired)('topics', value),
|
|
832
|
+
when: () => config_1.localConfig.getMessagingTopics().length > 0,
|
|
833
|
+
choices: () => {
|
|
834
|
+
let topics = config_1.localConfig.getMessagingTopics();
|
|
835
|
+
return topics.map((topic) => {
|
|
836
|
+
return {
|
|
837
|
+
name: `${topic.name} (${topic['$id']})`,
|
|
838
|
+
value: topic.$id
|
|
839
|
+
};
|
|
840
|
+
});
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
];
|
|
844
|
+
exports.questionsGetEntrypoint = [
|
|
845
|
+
{
|
|
846
|
+
type: "input",
|
|
847
|
+
name: "entrypoint",
|
|
848
|
+
message: "Enter the entrypoint",
|
|
849
|
+
default: null,
|
|
850
|
+
validate(value) {
|
|
851
|
+
if (!value) {
|
|
852
|
+
return "Please enter your entrypoint";
|
|
853
|
+
}
|
|
854
|
+
return true;
|
|
855
|
+
}
|
|
856
|
+
},
|
|
857
|
+
];
|
|
858
|
+
exports.questionsPushTeams = [
|
|
859
|
+
{
|
|
860
|
+
type: "checkbox",
|
|
861
|
+
name: "teams",
|
|
862
|
+
message: "Which teams would you like to push?",
|
|
863
|
+
validate: (value) => (0, validations_1.validateRequired)('team', value),
|
|
864
|
+
when: () => config_1.localConfig.getTeams().length > 0,
|
|
865
|
+
choices: () => {
|
|
866
|
+
let teams = config_1.localConfig.getTeams();
|
|
867
|
+
(0, utils_1.checkDeployConditions)(config_1.localConfig);
|
|
868
|
+
return teams.map((team) => {
|
|
869
|
+
return {
|
|
870
|
+
name: `${team.name} (${team['$id']})`,
|
|
871
|
+
value: team.$id
|
|
872
|
+
};
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
},
|
|
876
|
+
];
|
|
877
|
+
exports.questionsListFactors = [
|
|
878
|
+
{
|
|
879
|
+
type: "list",
|
|
880
|
+
name: "factor",
|
|
881
|
+
message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
|
|
882
|
+
choices: async () => {
|
|
883
|
+
let client = await (0, sdks_1.sdkForConsole)(false);
|
|
884
|
+
const factors = await (0, account_1.accountListMFAFactors)({
|
|
885
|
+
sdk: client,
|
|
886
|
+
parseOutput: false
|
|
887
|
+
});
|
|
888
|
+
const choices = [
|
|
889
|
+
{
|
|
890
|
+
name: `Authenticator app (Get a code from a third-party authenticator app)`,
|
|
891
|
+
value: 'totp'
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
name: `Email (Get a security code at your Appwrite email address)`,
|
|
895
|
+
value: 'email'
|
|
896
|
+
},
|
|
897
|
+
{
|
|
898
|
+
name: `SMS (Get a security code on your Appwrite phone number)`,
|
|
899
|
+
value: 'phone'
|
|
900
|
+
},
|
|
901
|
+
{
|
|
902
|
+
name: `Recovery code (Use one of your recovery codes for verification)`,
|
|
903
|
+
value: 'recoveryCode'
|
|
904
|
+
}
|
|
905
|
+
].filter((ch) => factors[ch.value] === true);
|
|
906
|
+
return choices;
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
];
|
|
910
|
+
exports.questionsMFAChallenge = [
|
|
911
|
+
{
|
|
912
|
+
type: "input",
|
|
913
|
+
name: "otp",
|
|
914
|
+
message: "Enter OTP",
|
|
915
|
+
validate(value) {
|
|
916
|
+
if (!value) {
|
|
917
|
+
return "Please enter OTP";
|
|
918
|
+
}
|
|
919
|
+
return true;
|
|
920
|
+
},
|
|
921
|
+
}
|
|
922
|
+
];
|
|
923
|
+
exports.questionsRunFunctions = [
|
|
924
|
+
{
|
|
925
|
+
type: "list",
|
|
926
|
+
name: "function",
|
|
927
|
+
message: "Which function would you like to develop locally?",
|
|
928
|
+
validate: (value) => (0, validations_1.validateRequired)('function', value),
|
|
929
|
+
choices: () => {
|
|
930
|
+
let functions = config_1.localConfig.getFunctions();
|
|
931
|
+
if (functions.length === 0) {
|
|
932
|
+
throw new Error("No functions found. Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
|
|
933
|
+
}
|
|
934
|
+
let choices = functions.map((func, idx) => {
|
|
935
|
+
return {
|
|
936
|
+
name: `${func.name} (${func.$id})`,
|
|
937
|
+
value: func.$id
|
|
938
|
+
};
|
|
939
|
+
});
|
|
940
|
+
return choices;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
];
|
|
944
|
+
exports.questionsCreateSite = [
|
|
945
|
+
{
|
|
946
|
+
type: "input",
|
|
947
|
+
name: "name",
|
|
948
|
+
message: "What would you like to name your site?",
|
|
949
|
+
default: "My Awesome Site"
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
type: "input",
|
|
953
|
+
name: "id",
|
|
954
|
+
message: "What ID would you like to have for your site?",
|
|
955
|
+
default: "unique()"
|
|
956
|
+
},
|
|
957
|
+
{
|
|
958
|
+
type: "list",
|
|
959
|
+
name: "framework",
|
|
960
|
+
message: "What framework would you like to use?",
|
|
961
|
+
choices: async () => {
|
|
962
|
+
let response = await (0, sites_1.sitesListFrameworks)({
|
|
963
|
+
parseOutput: false
|
|
964
|
+
});
|
|
965
|
+
let frameworks = response["frameworks"];
|
|
966
|
+
let choices = frameworks.map((framework) => {
|
|
967
|
+
return {
|
|
968
|
+
name: `${framework.name} (${framework.key})`,
|
|
969
|
+
value: framework,
|
|
970
|
+
};
|
|
971
|
+
});
|
|
972
|
+
return choices;
|
|
973
|
+
},
|
|
974
|
+
},
|
|
975
|
+
{
|
|
976
|
+
type: "list",
|
|
977
|
+
name: "specification",
|
|
978
|
+
message: "What specification would you like to use?",
|
|
979
|
+
choices: async () => {
|
|
980
|
+
let response = await (0, sites_1.sitesListSpecifications)({
|
|
981
|
+
parseOutput: false
|
|
982
|
+
});
|
|
983
|
+
let specifications = response["specifications"];
|
|
984
|
+
let choices = specifications.map((spec) => {
|
|
985
|
+
return {
|
|
986
|
+
name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
|
|
987
|
+
value: spec.slug,
|
|
988
|
+
disabled: spec.enabled === false ? 'Upgrade to use' : false
|
|
989
|
+
};
|
|
990
|
+
});
|
|
991
|
+
return choices;
|
|
992
|
+
},
|
|
993
|
+
}
|
|
994
|
+
];
|
|
995
|
+
//# sourceMappingURL=questions.js.map
|