appwrite-cli 12.0.0 → 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 +8 -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} +410 -664
- 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} +122 -173
- 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 -48
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
- package/lib/type-generation/languages/{java.js → java.ts} +58 -47
- 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 -48
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
- 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 -16
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -85
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -107
- package/lib/validations.js +0 -17
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param {fs.ReadStream} readStream
|
|
17
|
-
* @returns {ReadableStream}
|
|
18
|
-
*/
|
|
19
|
-
function convertReadStreamToReadableStream(readStream) {
|
|
1
|
+
import fs = require('fs');
|
|
2
|
+
import pathLib = require('path');
|
|
3
|
+
import tar = require('tar');
|
|
4
|
+
import ignore = require('ignore');
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
import Client from '../client';
|
|
7
|
+
import { getAllFiles, showConsoleLink } from '../utils';
|
|
8
|
+
import { Command } from 'commander';
|
|
9
|
+
import { sdkForProject, sdkForConsole } from '../sdks';
|
|
10
|
+
import { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log, warn } from '../parser';
|
|
11
|
+
import { localConfig, globalConfig } from '../config';
|
|
12
|
+
import { File } from 'undici';
|
|
13
|
+
import { ReadableStream } from 'stream/web';
|
|
14
|
+
|
|
15
|
+
function convertReadStreamToReadableStream(readStream: fs.ReadStream): ReadableStream {
|
|
20
16
|
return new ReadableStream({
|
|
21
17
|
start(controller) {
|
|
22
|
-
readStream.on("data", (chunk) => {
|
|
18
|
+
readStream.on("data", (chunk: Buffer) => {
|
|
23
19
|
controller.enqueue(chunk);
|
|
24
20
|
});
|
|
25
21
|
readStream.on("end", () => {
|
|
26
22
|
controller.close();
|
|
27
23
|
});
|
|
28
|
-
readStream.on("error", (err) => {
|
|
24
|
+
readStream.on("error", (err: Error) => {
|
|
29
25
|
controller.error(err);
|
|
30
26
|
});
|
|
31
27
|
},
|
|
@@ -35,25 +31,22 @@ function convertReadStreamToReadableStream(readStream) {
|
|
|
35
31
|
});
|
|
36
32
|
}
|
|
37
33
|
|
|
38
|
-
const tokens = new Command("tokens").description(commandDescriptions['tokens'] ?? '').configureHelp({
|
|
34
|
+
export const tokens = new Command("tokens").description(commandDescriptions['tokens'] ?? '').configureHelp({
|
|
39
35
|
helpWidth: process.stdout.columns || 80
|
|
40
36
|
})
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
* @param {TokensListRequestParams} params
|
|
55
|
-
*/
|
|
56
|
-
const tokensList = async ({bucketId,fileId,queries,total,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
38
|
+
interface TokensListRequestParams {
|
|
39
|
+
bucketId: string;
|
|
40
|
+
fileId: string;
|
|
41
|
+
queries?: string[];
|
|
42
|
+
total?: boolean;
|
|
43
|
+
overrideForCli?: boolean;
|
|
44
|
+
parseOutput?: boolean;
|
|
45
|
+
sdk?: Client;
|
|
46
|
+
console?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const tokensList = async ({bucketId,fileId,queries,total,parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole}: TokensListRequestParams): Promise<any> => {
|
|
57
50
|
let client = !sdk ? await sdkForProject() :
|
|
58
51
|
sdk;
|
|
59
52
|
let apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
@@ -71,7 +64,7 @@ const tokensList = async ({bucketId,fileId,queries,total,parseOutput = true, ove
|
|
|
71
64
|
}, payload);
|
|
72
65
|
|
|
73
66
|
if (parseOutput) {
|
|
74
|
-
if(
|
|
67
|
+
if(showConsole) {
|
|
75
68
|
showConsoleLink('tokens', 'list', bucketId, fileId);
|
|
76
69
|
} else {
|
|
77
70
|
parse(response)
|
|
@@ -81,20 +74,16 @@ const tokensList = async ({bucketId,fileId,queries,total,parseOutput = true, ove
|
|
|
81
74
|
return response;
|
|
82
75
|
|
|
83
76
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {TokensCreateFileTokenRequestParams} params
|
|
96
|
-
*/
|
|
97
|
-
const tokensCreateFileToken = async ({bucketId,fileId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
77
|
+
interface TokensCreateFileTokenRequestParams {
|
|
78
|
+
bucketId: string;
|
|
79
|
+
fileId: string;
|
|
80
|
+
expire?: string;
|
|
81
|
+
overrideForCli?: boolean;
|
|
82
|
+
parseOutput?: boolean;
|
|
83
|
+
sdk?: Client;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const tokensCreateFileToken = async ({bucketId,fileId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}: TokensCreateFileTokenRequestParams): Promise<any> => {
|
|
98
87
|
let client = !sdk ? await sdkForProject() :
|
|
99
88
|
sdk;
|
|
100
89
|
let apiPath = '/tokens/buckets/{bucketId}/files/{fileId}'.replace('{bucketId}', bucketId).replace('{fileId}', fileId);
|
|
@@ -116,18 +105,15 @@ const tokensCreateFileToken = async ({bucketId,fileId,expire,parseOutput = true,
|
|
|
116
105
|
return response;
|
|
117
106
|
|
|
118
107
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
* @param {TokensGetRequestParams} params
|
|
129
|
-
*/
|
|
130
|
-
const tokensGet = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
|
|
108
|
+
interface TokensGetRequestParams {
|
|
109
|
+
tokenId: string;
|
|
110
|
+
overrideForCli?: boolean;
|
|
111
|
+
parseOutput?: boolean;
|
|
112
|
+
sdk?: Client;
|
|
113
|
+
console?: boolean;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export const tokensGet = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined, console: showConsole}: TokensGetRequestParams): Promise<any> => {
|
|
131
117
|
let client = !sdk ? await sdkForProject() :
|
|
132
118
|
sdk;
|
|
133
119
|
let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
@@ -139,7 +125,7 @@ const tokensGet = async ({tokenId,parseOutput = true, overrideForCli = false, sd
|
|
|
139
125
|
}, payload);
|
|
140
126
|
|
|
141
127
|
if (parseOutput) {
|
|
142
|
-
if(
|
|
128
|
+
if(showConsole) {
|
|
143
129
|
showConsoleLink('tokens', 'get', tokenId);
|
|
144
130
|
} else {
|
|
145
131
|
parse(response)
|
|
@@ -149,19 +135,15 @@ const tokensGet = async ({tokenId,parseOutput = true, overrideForCli = false, sd
|
|
|
149
135
|
return response;
|
|
150
136
|
|
|
151
137
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {TokensUpdateRequestParams} params
|
|
163
|
-
*/
|
|
164
|
-
const tokensUpdate = async ({tokenId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
138
|
+
interface TokensUpdateRequestParams {
|
|
139
|
+
tokenId: string;
|
|
140
|
+
expire?: string;
|
|
141
|
+
overrideForCli?: boolean;
|
|
142
|
+
parseOutput?: boolean;
|
|
143
|
+
sdk?: Client;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export const tokensUpdate = async ({tokenId,expire,parseOutput = true, overrideForCli = false, sdk = undefined}: TokensUpdateRequestParams): Promise<any> => {
|
|
165
147
|
let client = !sdk ? await sdkForProject() :
|
|
166
148
|
sdk;
|
|
167
149
|
let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
@@ -183,18 +165,14 @@ const tokensUpdate = async ({tokenId,expire,parseOutput = true, overrideForCli =
|
|
|
183
165
|
return response;
|
|
184
166
|
|
|
185
167
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* @param {TokensDeleteRequestParams} params
|
|
196
|
-
*/
|
|
197
|
-
const tokensDelete = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
|
|
168
|
+
interface TokensDeleteRequestParams {
|
|
169
|
+
tokenId: string;
|
|
170
|
+
overrideForCli?: boolean;
|
|
171
|
+
parseOutput?: boolean;
|
|
172
|
+
sdk?: Client;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export const tokensDelete = async ({tokenId,parseOutput = true, overrideForCli = false, sdk = undefined}: TokensDeleteRequestParams): Promise<any> => {
|
|
198
176
|
let client = !sdk ? await sdkForProject() :
|
|
199
177
|
sdk;
|
|
200
178
|
let apiPath = '/tokens/{tokenId}'.replace('{tokenId}', tokenId);
|
|
@@ -219,7 +197,7 @@ tokens
|
|
|
219
197
|
.requiredOption(`--bucket-id <bucket-id>`, `Storage bucket unique ID. You can create a new storage bucket using the Storage service [server integration](https://appwrite.io/docs/server/storage#createBucket).`)
|
|
220
198
|
.requiredOption(`--file-id <file-id>`, `File unique ID.`)
|
|
221
199
|
.option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: expire`)
|
|
222
|
-
.option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value) => value === undefined ? true : parseBool(value))
|
|
200
|
+
.option(`--total [value]`, `When set to false, the total count returned will be 0 and will not be calculated.`, (value: string | undefined) => value === undefined ? true : parseBool(value))
|
|
223
201
|
.option(`--console`, `Get the resource console url`)
|
|
224
202
|
.action(actionRunner(tokensList))
|
|
225
203
|
|
|
@@ -251,11 +229,4 @@ tokens
|
|
|
251
229
|
.requiredOption(`--token-id <token-id>`, `Token ID.`)
|
|
252
230
|
.action(actionRunner(tokensDelete))
|
|
253
231
|
|
|
254
|
-
|
|
255
|
-
tokens,
|
|
256
|
-
tokensList,
|
|
257
|
-
tokensCreateFileToken,
|
|
258
|
-
tokensGet,
|
|
259
|
-
tokensUpdate,
|
|
260
|
-
tokensDelete
|
|
261
|
-
};
|
|
232
|
+
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
*/
|
|
21
|
-
function createLanguageMeta(language) {
|
|
1
|
+
import ejs = require('ejs');
|
|
2
|
+
import fs = require('fs');
|
|
3
|
+
import path = require('path');
|
|
4
|
+
import { LanguageMeta, detectLanguage, Collection } from '../type-generation/languages/language';
|
|
5
|
+
import { Command, Option, Argument } from 'commander';
|
|
6
|
+
import { localConfig } from '../config';
|
|
7
|
+
import { success, log, warn, actionRunner } from '../parser';
|
|
8
|
+
import { PHP } from '../type-generation/languages/php';
|
|
9
|
+
import { TypeScript } from '../type-generation/languages/typescript';
|
|
10
|
+
import { Kotlin } from '../type-generation/languages/kotlin';
|
|
11
|
+
import { Swift } from '../type-generation/languages/swift';
|
|
12
|
+
import { Java } from '../type-generation/languages/java';
|
|
13
|
+
import { Dart } from '../type-generation/languages/dart';
|
|
14
|
+
import { JavaScript } from '../type-generation/languages/javascript';
|
|
15
|
+
import { CSharp } from '../type-generation/languages/csharp';
|
|
16
|
+
|
|
17
|
+
type SupportedLanguage = 'ts' | 'js' | 'php' | 'kotlin' | 'swift' | 'java' | 'dart' | 'cs';
|
|
18
|
+
|
|
19
|
+
function createLanguageMeta(language: SupportedLanguage): LanguageMeta {
|
|
22
20
|
switch (language) {
|
|
23
21
|
case "ts":
|
|
24
22
|
return new TypeScript();
|
|
@@ -47,7 +45,7 @@ const templateHelpers = {
|
|
|
47
45
|
toSnakeCase: LanguageMeta.toSnakeCase,
|
|
48
46
|
toKebabCase: LanguageMeta.toKebabCase,
|
|
49
47
|
toUpperSnakeCase: LanguageMeta.toUpperSnakeCase
|
|
50
|
-
}
|
|
48
|
+
};
|
|
51
49
|
|
|
52
50
|
const typesOutputArgument = new Argument(
|
|
53
51
|
"<output-directory>",
|
|
@@ -67,7 +65,12 @@ const typesStrictOption = new Option(
|
|
|
67
65
|
)
|
|
68
66
|
.default(false);
|
|
69
67
|
|
|
70
|
-
|
|
68
|
+
interface TypesOptions {
|
|
69
|
+
language: string;
|
|
70
|
+
strict: boolean;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const typesCommand = actionRunner(async (rawOutputDirectory: string, {language, strict}: TypesOptions) => {
|
|
71
74
|
if (language === "auto") {
|
|
72
75
|
language = detectLanguage();
|
|
73
76
|
log(`Detected language: ${language}`);
|
|
@@ -77,13 +80,13 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
77
80
|
warn(`Strict mode enabled: Field names will be converted to follow ${language} conventions`);
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
const meta = createLanguageMeta(language);
|
|
83
|
+
const meta = createLanguageMeta(language as SupportedLanguage);
|
|
81
84
|
|
|
82
85
|
const rawOutputPath = rawOutputDirectory;
|
|
83
86
|
const outputExt = path.extname(rawOutputPath);
|
|
84
87
|
const isFileOutput = !!outputExt;
|
|
85
88
|
let outputDirectory = rawOutputPath;
|
|
86
|
-
let singleFileDestination = null;
|
|
89
|
+
let singleFileDestination: string | null = null;
|
|
87
90
|
|
|
88
91
|
if (isFileOutput) {
|
|
89
92
|
if (meta.isSingleFile()) {
|
|
@@ -102,7 +105,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
102
105
|
|
|
103
106
|
// Try tables first, fallback to collections
|
|
104
107
|
let tables = localConfig.getTables();
|
|
105
|
-
let collections = [];
|
|
108
|
+
let collections: any[] = [];
|
|
106
109
|
let dataSource = 'tables';
|
|
107
110
|
|
|
108
111
|
if (tables.length === 0) {
|
|
@@ -116,7 +119,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
// Use tables if available, otherwise use collections
|
|
119
|
-
let dataItems = tables.length > 0 ? tables : collections;
|
|
122
|
+
let dataItems: any[] = tables.length > 0 ? tables : collections;
|
|
120
123
|
const itemType = tables.length > 0 ? 'tables' : 'collections';
|
|
121
124
|
|
|
122
125
|
// Normalize tables data: rename 'columns' to 'attributes' for template compatibility
|
|
@@ -125,7 +128,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
125
128
|
const { columns, ...rest } = table;
|
|
126
129
|
return {
|
|
127
130
|
...rest,
|
|
128
|
-
attributes: (columns || []).map(column => {
|
|
131
|
+
attributes: (columns || []).map((column: any) => {
|
|
129
132
|
if (column.relatedTable) {
|
|
130
133
|
const { relatedTable, ...columnRest } = column;
|
|
131
134
|
return {
|
|
@@ -139,12 +142,12 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
139
142
|
});
|
|
140
143
|
}
|
|
141
144
|
|
|
142
|
-
log(`Found ${dataItems.length} ${itemType}: ${dataItems.map(c => c.name).join(", ")}`);
|
|
145
|
+
log(`Found ${dataItems.length} ${itemType}: ${dataItems.map((c: any) => c.name).join(", ")}`);
|
|
143
146
|
|
|
144
147
|
// Use columns if available, otherwise use attributes
|
|
145
148
|
const resourceType = tables.length > 0 ? 'columns' : 'attributes';
|
|
146
149
|
|
|
147
|
-
const totalAttributes = dataItems.reduce((count, item) => count + (item.attributes || []).length, 0);
|
|
150
|
+
const totalAttributes = dataItems.reduce((count: number, item: any) => count + (item.attributes || []).length, 0);
|
|
148
151
|
log(`Found ${totalAttributes} ${resourceType} across all ${itemType}`);
|
|
149
152
|
|
|
150
153
|
const templater = ejs.compile(meta.getTemplate());
|
|
@@ -154,7 +157,7 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
154
157
|
collections: dataItems,
|
|
155
158
|
strict,
|
|
156
159
|
...templateHelpers,
|
|
157
|
-
getType: meta.getType,
|
|
160
|
+
getType: meta.getType.bind(meta),
|
|
158
161
|
});
|
|
159
162
|
|
|
160
163
|
const destination = singleFileDestination || path.join(outputDirectory, meta.getFileName());
|
|
@@ -168,10 +171,10 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
168
171
|
collection: item,
|
|
169
172
|
strict,
|
|
170
173
|
...templateHelpers,
|
|
171
|
-
getType: meta.getType,
|
|
174
|
+
getType: meta.getType.bind(meta),
|
|
172
175
|
});
|
|
173
176
|
|
|
174
|
-
const destination = path.join(outputDirectory, meta.getFileName(item));
|
|
177
|
+
const destination = path.join(outputDirectory, meta.getFileName(item as Collection));
|
|
175
178
|
|
|
176
179
|
fs.writeFileSync(destination, content);
|
|
177
180
|
log(`Added types for ${item.name} to ${destination}`);
|
|
@@ -181,11 +184,10 @@ const typesCommand = actionRunner(async (rawOutputDirectory, {language, strict})
|
|
|
181
184
|
success(`Generated types for all the listed ${itemType}`);
|
|
182
185
|
});
|
|
183
186
|
|
|
184
|
-
const types = new Command("types")
|
|
187
|
+
export const types = new Command("types")
|
|
185
188
|
.description("Generate types for your Appwrite project")
|
|
186
189
|
.addArgument(typesOutputArgument)
|
|
187
190
|
.addOption(typesLanguageOption)
|
|
188
191
|
.addOption(typesStrictOption)
|
|
189
192
|
.action(actionRunner(typesCommand));
|
|
190
193
|
|
|
191
|
-
module.exports = { types };
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const {
|
|
10
|
-
const { version } = require("../../package.json");
|
|
1
|
+
import fs = require('fs');
|
|
2
|
+
import path = require('path');
|
|
3
|
+
import { spawn } from 'child_process';
|
|
4
|
+
import { Command } from 'commander';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
import inquirer from 'inquirer';
|
|
7
|
+
import { success, log, warn, error, hint, actionRunner, commandDescriptions } from '../parser';
|
|
8
|
+
import { getLatestVersion, compareVersions } from '../utils';
|
|
9
|
+
const { version } = require('../../../package.json');
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Check if the CLI was installed via npm
|
|
14
13
|
*/
|
|
15
|
-
const isInstalledViaNpm = () => {
|
|
14
|
+
const isInstalledViaNpm = (): boolean => {
|
|
16
15
|
try {
|
|
17
16
|
const scriptPath = process.argv[1];
|
|
18
17
|
|
|
@@ -36,7 +35,7 @@ const isInstalledViaNpm = () => {
|
|
|
36
35
|
/**
|
|
37
36
|
* Check if the CLI was installed via Homebrew
|
|
38
37
|
*/
|
|
39
|
-
const isInstalledViaHomebrew = () => {
|
|
38
|
+
const isInstalledViaHomebrew = (): boolean => {
|
|
40
39
|
try {
|
|
41
40
|
const scriptPath = process.argv[1];
|
|
42
41
|
return scriptPath.includes('/opt/homebrew/') || scriptPath.includes('/usr/local/Cellar/');
|
|
@@ -45,12 +44,10 @@ const isInstalledViaHomebrew = () => {
|
|
|
45
44
|
}
|
|
46
45
|
};
|
|
47
46
|
|
|
48
|
-
|
|
49
|
-
|
|
50
47
|
/**
|
|
51
48
|
* Execute command and return promise
|
|
52
49
|
*/
|
|
53
|
-
const execCommand = (command, args = [], options = {}) => {
|
|
50
|
+
const execCommand = (command: string, args: string[] = [], options: any = {}): Promise<void> => {
|
|
54
51
|
return new Promise((resolve, reject) => {
|
|
55
52
|
const child = spawn(command, args, {
|
|
56
53
|
stdio: 'inherit',
|
|
@@ -75,13 +72,13 @@ const execCommand = (command, args = [], options = {}) => {
|
|
|
75
72
|
/**
|
|
76
73
|
* Update via npm
|
|
77
74
|
*/
|
|
78
|
-
const updateViaNpm = async () => {
|
|
75
|
+
const updateViaNpm = async (): Promise<void> => {
|
|
79
76
|
try {
|
|
80
77
|
await execCommand('npm', ['install', '-g', 'appwrite-cli@latest']);
|
|
81
78
|
console.log("");
|
|
82
79
|
success("Updated to latest version via npm!");
|
|
83
80
|
hint("Run 'appwrite --version' to verify the new version.");
|
|
84
|
-
} catch (e) {
|
|
81
|
+
} catch (e: any) {
|
|
85
82
|
if (e.message.includes('EEXIST') || e.message.includes('file already exists')) {
|
|
86
83
|
console.log("");
|
|
87
84
|
success("Latest version is already installed via npm!");
|
|
@@ -97,13 +94,13 @@ const updateViaNpm = async () => {
|
|
|
97
94
|
/**
|
|
98
95
|
* Update via Homebrew
|
|
99
96
|
*/
|
|
100
|
-
const updateViaHomebrew = async () => {
|
|
97
|
+
const updateViaHomebrew = async (): Promise<void> => {
|
|
101
98
|
try {
|
|
102
99
|
await execCommand('brew', ['upgrade', 'appwrite']);
|
|
103
100
|
console.log("");
|
|
104
101
|
success("Updated to latest version via Homebrew!");
|
|
105
102
|
hint("Run 'appwrite --version' to verify the new version.");
|
|
106
|
-
} catch (e) {
|
|
103
|
+
} catch (e: any) {
|
|
107
104
|
if (e.message.includes('already installed') || e.message.includes('up-to-date')) {
|
|
108
105
|
console.log("");
|
|
109
106
|
success("Latest version is already installed via Homebrew!");
|
|
@@ -119,7 +116,7 @@ const updateViaHomebrew = async () => {
|
|
|
119
116
|
/**
|
|
120
117
|
* Show manual update instructions
|
|
121
118
|
*/
|
|
122
|
-
const showManualInstructions = (latestVersion) => {
|
|
119
|
+
const showManualInstructions = (latestVersion: string): void => {
|
|
123
120
|
log("Manual update options:");
|
|
124
121
|
console.log("");
|
|
125
122
|
|
|
@@ -138,7 +135,7 @@ const showManualInstructions = (latestVersion) => {
|
|
|
138
135
|
/**
|
|
139
136
|
* Show interactive menu for choosing update method
|
|
140
137
|
*/
|
|
141
|
-
const chooseUpdateMethod = async (latestVersion) => {
|
|
138
|
+
const chooseUpdateMethod = async (latestVersion: string): Promise<void> => {
|
|
142
139
|
const choices = [
|
|
143
140
|
{ name: 'NPM', value: 'npm' },
|
|
144
141
|
{ name: 'Homebrew', value: 'homebrew' },
|
|
@@ -167,10 +164,14 @@ const chooseUpdateMethod = async (latestVersion) => {
|
|
|
167
164
|
}
|
|
168
165
|
};
|
|
169
166
|
|
|
167
|
+
interface UpdateOptions {
|
|
168
|
+
manual?: boolean;
|
|
169
|
+
}
|
|
170
|
+
|
|
170
171
|
/**
|
|
171
172
|
* Main update function
|
|
172
173
|
*/
|
|
173
|
-
const updateCli = async ({ manual } = {}) => {
|
|
174
|
+
const updateCli = async ({ manual }: UpdateOptions = {}): Promise<void> => {
|
|
174
175
|
try {
|
|
175
176
|
const latestVersion = await getLatestVersion();
|
|
176
177
|
|
|
@@ -201,18 +202,15 @@ const updateCli = async ({ manual } = {}) => {
|
|
|
201
202
|
await chooseUpdateMethod(latestVersion);
|
|
202
203
|
}
|
|
203
204
|
|
|
204
|
-
} catch (e) {
|
|
205
|
+
} catch (e: any) {
|
|
205
206
|
console.log("");
|
|
206
207
|
error(`Failed to check for updates: ${e.message}`);
|
|
207
208
|
hint("You can manually check for updates at: https://github.com/appwrite-cli/releases");
|
|
208
209
|
}
|
|
209
210
|
};
|
|
210
211
|
|
|
211
|
-
const update = new Command("update")
|
|
212
|
+
export const update = new Command("update")
|
|
212
213
|
.description("Update the Appwrite CLI to the latest version")
|
|
213
214
|
.option("--manual", "Show manual update instructions instead of auto-updating")
|
|
214
215
|
.action(actionRunner(updateCli));
|
|
215
216
|
|
|
216
|
-
module.exports = {
|
|
217
|
-
update
|
|
218
|
-
};
|