appwrite-cli 4.2.0 → 4.2.2
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/LICENSE.md +1 -1
- package/README.md +3 -3
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/client.js +66 -74
- package/lib/commands/account.js +458 -199
- package/lib/commands/assistant.js +40 -10
- package/lib/commands/avatars.js +171 -71
- package/lib/commands/console.js +40 -6
- package/lib/commands/databases.js +838 -555
- package/lib/commands/functions.js +493 -288
- package/lib/commands/generic.js +0 -1
- package/lib/commands/graphql.js +53 -14
- package/lib/commands/health.js +272 -71
- package/lib/commands/locale.js +131 -20
- package/lib/commands/migrations.js +282 -151
- package/lib/commands/project.js +111 -36
- package/lib/commands/projects.js +670 -415
- package/lib/commands/proxy.js +100 -32
- package/lib/commands/storage.js +374 -204
- package/lib/commands/teams.js +239 -107
- package/lib/commands/users.js +465 -266
- package/lib/commands/vcs.js +161 -57
- package/package.json +9 -9
- package/scoop/appwrite.json +3 -3
package/lib/commands/generic.js
CHANGED
package/lib/commands/graphql.js
CHANGED
|
@@ -9,62 +9,102 @@ const { Command } = require('commander');
|
|
|
9
9
|
const { sdkForProject, sdkForConsole } = require('../sdks')
|
|
10
10
|
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
|
|
11
11
|
const { localConfig, globalConfig } = require("../config");
|
|
12
|
+
const { File } = require('undici');
|
|
13
|
+
const { ReadableStream } = require('stream/web');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @param {fs.ReadStream} readStream
|
|
17
|
+
* @returns {ReadableStream}
|
|
18
|
+
*/
|
|
19
|
+
function convertReadStreamToReadableStream(readStream) {
|
|
20
|
+
return new ReadableStream({
|
|
21
|
+
start(controller) {
|
|
22
|
+
readStream.on("data", (chunk) => {
|
|
23
|
+
controller.enqueue(chunk);
|
|
24
|
+
});
|
|
25
|
+
readStream.on("end", () => {
|
|
26
|
+
controller.close();
|
|
27
|
+
});
|
|
28
|
+
readStream.on("error", (err) => {
|
|
29
|
+
controller.error(err);
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
cancel() {
|
|
33
|
+
readStream.destroy();
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
12
37
|
|
|
13
38
|
const graphql = new Command("graphql").description(commandDescriptions['graphql']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
40
|
+
})
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} GraphqlQueryRequestParams
|
|
44
|
+
* @property {object} query The query or queries to execute.
|
|
45
|
+
* @property {boolean} parseOutput
|
|
46
|
+
* @property {libClient | undefined} sdk
|
|
47
|
+
*/
|
|
19
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @param {GraphqlQueryRequestParams} params
|
|
51
|
+
*/
|
|
52
|
+
const graphqlQuery = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
20
53
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
21
54
|
let apiPath = '/graphql';
|
|
22
55
|
let payload = {};
|
|
23
|
-
|
|
24
|
-
/** Body Params */
|
|
25
56
|
if (typeof query !== 'undefined') {
|
|
26
57
|
payload['query'] = JSON.parse(query);
|
|
27
58
|
}
|
|
28
59
|
|
|
29
60
|
let response = undefined;
|
|
61
|
+
|
|
30
62
|
response = await client.call('post', apiPath, {
|
|
31
63
|
'x-sdk-graphql': 'true',
|
|
32
64
|
'content-type': 'application/json',
|
|
33
65
|
}, payload);
|
|
34
|
-
|
|
66
|
+
|
|
35
67
|
if (parseOutput) {
|
|
36
68
|
parse(response)
|
|
37
69
|
success()
|
|
38
70
|
}
|
|
71
|
+
|
|
39
72
|
return response;
|
|
40
73
|
}
|
|
41
74
|
|
|
42
|
-
|
|
43
|
-
|
|
75
|
+
/**
|
|
76
|
+
* @typedef {Object} GraphqlMutationRequestParams
|
|
77
|
+
* @property {object} query The query or queries to execute.
|
|
78
|
+
* @property {boolean} parseOutput
|
|
79
|
+
* @property {libClient | undefined} sdk
|
|
80
|
+
*/
|
|
44
81
|
|
|
82
|
+
/**
|
|
83
|
+
* @param {GraphqlMutationRequestParams} params
|
|
84
|
+
*/
|
|
85
|
+
const graphqlMutation = async ({ query, parseOutput = true, sdk = undefined}) => {
|
|
45
86
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
46
87
|
let apiPath = '/graphql/mutation';
|
|
47
88
|
let payload = {};
|
|
48
|
-
|
|
49
|
-
/** Body Params */
|
|
50
89
|
if (typeof query !== 'undefined') {
|
|
51
90
|
payload['query'] = JSON.parse(query);
|
|
52
91
|
}
|
|
53
92
|
|
|
54
93
|
let response = undefined;
|
|
94
|
+
|
|
55
95
|
response = await client.call('post', apiPath, {
|
|
56
96
|
'x-sdk-graphql': 'true',
|
|
57
97
|
'content-type': 'application/json',
|
|
58
98
|
}, payload);
|
|
59
|
-
|
|
99
|
+
|
|
60
100
|
if (parseOutput) {
|
|
61
101
|
parse(response)
|
|
62
102
|
success()
|
|
63
103
|
}
|
|
104
|
+
|
|
64
105
|
return response;
|
|
65
106
|
}
|
|
66
107
|
|
|
67
|
-
|
|
68
108
|
graphql
|
|
69
109
|
.command(`query`)
|
|
70
110
|
.description(`Execute a GraphQL mutation.`)
|
|
@@ -77,9 +117,8 @@ graphql
|
|
|
77
117
|
.requiredOption(`--query <query>`, `The query or queries to execute.`)
|
|
78
118
|
.action(actionRunner(graphqlMutation))
|
|
79
119
|
|
|
80
|
-
|
|
81
120
|
module.exports = {
|
|
82
121
|
graphql,
|
|
83
122
|
graphqlQuery,
|
|
84
123
|
graphqlMutation
|
|
85
|
-
};
|
|
124
|
+
};
|