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
|
@@ -9,45 +9,75 @@ 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 assistant = new Command("assistant").description(commandDescriptions['assistant']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
40
|
+
})
|
|
16
41
|
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} AssistantChatRequestParams
|
|
44
|
+
* @property {string} prompt Prompt. A string containing questions asked to the AI assistant.
|
|
45
|
+
* @property {boolean} parseOutput
|
|
46
|
+
* @property {libClient | undefined} sdk
|
|
47
|
+
*/
|
|
19
48
|
|
|
49
|
+
/**
|
|
50
|
+
* @param {AssistantChatRequestParams} params
|
|
51
|
+
*/
|
|
52
|
+
const assistantChat = async ({ prompt, parseOutput = true, sdk = undefined}) => {
|
|
20
53
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
21
54
|
let apiPath = '/console/assistant';
|
|
22
55
|
let payload = {};
|
|
23
|
-
|
|
24
|
-
/** Body Params */
|
|
25
|
-
|
|
26
56
|
if (typeof prompt !== 'undefined') {
|
|
27
57
|
payload['prompt'] = prompt;
|
|
28
58
|
}
|
|
29
59
|
|
|
30
60
|
let response = undefined;
|
|
61
|
+
|
|
31
62
|
response = await client.call('post', apiPath, {
|
|
32
63
|
'content-type': 'application/json',
|
|
33
64
|
}, payload);
|
|
34
|
-
|
|
65
|
+
|
|
35
66
|
if (parseOutput) {
|
|
36
67
|
parse(response)
|
|
37
68
|
success()
|
|
38
69
|
}
|
|
70
|
+
|
|
39
71
|
return response;
|
|
40
72
|
}
|
|
41
73
|
|
|
42
|
-
|
|
43
74
|
assistant
|
|
44
75
|
.command(`chat`)
|
|
45
76
|
.description(``)
|
|
46
77
|
.requiredOption(`--prompt <prompt>`, `Prompt. A string containing questions asked to the AI assistant.`)
|
|
47
78
|
.action(actionRunner(assistantChat))
|
|
48
79
|
|
|
49
|
-
|
|
50
80
|
module.exports = {
|
|
51
81
|
assistant,
|
|
52
82
|
assistantChat
|
|
53
|
-
};
|
|
83
|
+
};
|
package/lib/commands/avatars.js
CHANGED
|
@@ -9,22 +9,54 @@ 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 avatars = new Command("avatars").description(commandDescriptions['avatars']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
16
|
-
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} AvatarsGetBrowserRequestParams
|
|
44
|
+
* @property {string} code Browser Code.
|
|
45
|
+
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
46
|
+
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
47
|
+
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
48
|
+
* @property {boolean} parseOutput
|
|
49
|
+
* @property {libClient | undefined} sdk
|
|
50
|
+
* @property {string} destination
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* @param {AvatarsGetBrowserRequestParams} params
|
|
55
|
+
*/
|
|
17
56
|
const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
|
|
18
|
-
/* @param {string} code */
|
|
19
|
-
/* @param {number} width */
|
|
20
|
-
/* @param {number} height */
|
|
21
|
-
/* @param {number} quality */
|
|
22
|
-
|
|
23
57
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
24
58
|
let apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
|
|
25
59
|
let payload = {};
|
|
26
|
-
|
|
27
|
-
/** Query Params */
|
|
28
60
|
if (typeof width !== 'undefined') {
|
|
29
61
|
payload['width'] = width;
|
|
30
62
|
}
|
|
@@ -39,29 +71,40 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
|
|
|
39
71
|
const queryParams = new URLSearchParams(payload);
|
|
40
72
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
41
73
|
|
|
42
|
-
|
|
74
|
+
let response = undefined;
|
|
75
|
+
|
|
76
|
+
response = await client.call('get', apiPath, {
|
|
43
77
|
'content-type': 'application/json',
|
|
44
78
|
}, payload, 'arraybuffer');
|
|
45
79
|
|
|
46
80
|
fs.writeFileSync(destination, response);
|
|
47
81
|
|
|
48
|
-
if (parseOutput) {
|
|
49
|
-
|
|
82
|
+
if (parseOutput) {
|
|
83
|
+
parse(response)
|
|
50
84
|
success()
|
|
51
85
|
}
|
|
86
|
+
|
|
87
|
+
return response;
|
|
52
88
|
}
|
|
53
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @typedef {Object} AvatarsGetCreditCardRequestParams
|
|
92
|
+
* @property {string} code Credit Card Code. Possible values: amex, argencard, cabal, censosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
|
|
93
|
+
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
94
|
+
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
95
|
+
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
96
|
+
* @property {boolean} parseOutput
|
|
97
|
+
* @property {libClient | undefined} sdk
|
|
98
|
+
* @property {string} destination
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {AvatarsGetCreditCardRequestParams} params
|
|
103
|
+
*/
|
|
54
104
|
const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
|
|
55
|
-
/* @param {string} code */
|
|
56
|
-
/* @param {number} width */
|
|
57
|
-
/* @param {number} height */
|
|
58
|
-
/* @param {number} quality */
|
|
59
|
-
|
|
60
105
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
61
106
|
let apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
|
|
62
107
|
let payload = {};
|
|
63
|
-
|
|
64
|
-
/** Query Params */
|
|
65
108
|
if (typeof width !== 'undefined') {
|
|
66
109
|
payload['width'] = width;
|
|
67
110
|
}
|
|
@@ -76,26 +119,37 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
|
|
|
76
119
|
const queryParams = new URLSearchParams(payload);
|
|
77
120
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
78
121
|
|
|
79
|
-
|
|
122
|
+
let response = undefined;
|
|
123
|
+
|
|
124
|
+
response = await client.call('get', apiPath, {
|
|
80
125
|
'content-type': 'application/json',
|
|
81
126
|
}, payload, 'arraybuffer');
|
|
82
127
|
|
|
83
128
|
fs.writeFileSync(destination, response);
|
|
84
129
|
|
|
85
|
-
if (parseOutput) {
|
|
86
|
-
|
|
130
|
+
if (parseOutput) {
|
|
131
|
+
parse(response)
|
|
87
132
|
success()
|
|
88
133
|
}
|
|
134
|
+
|
|
135
|
+
return response;
|
|
89
136
|
}
|
|
90
137
|
|
|
138
|
+
/**
|
|
139
|
+
* @typedef {Object} AvatarsGetFaviconRequestParams
|
|
140
|
+
* @property {string} url Website URL which you want to fetch the favicon from.
|
|
141
|
+
* @property {boolean} parseOutput
|
|
142
|
+
* @property {libClient | undefined} sdk
|
|
143
|
+
* @property {string} destination
|
|
144
|
+
*/
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* @param {AvatarsGetFaviconRequestParams} params
|
|
148
|
+
*/
|
|
91
149
|
const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, destination}) => {
|
|
92
|
-
/* @param {string} url */
|
|
93
|
-
|
|
94
150
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
95
151
|
let apiPath = '/avatars/favicon';
|
|
96
152
|
let payload = {};
|
|
97
|
-
|
|
98
|
-
/** Query Params */
|
|
99
153
|
if (typeof url !== 'undefined') {
|
|
100
154
|
payload['url'] = url;
|
|
101
155
|
}
|
|
@@ -104,29 +158,40 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
|
|
|
104
158
|
const queryParams = new URLSearchParams(payload);
|
|
105
159
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
106
160
|
|
|
107
|
-
|
|
161
|
+
let response = undefined;
|
|
162
|
+
|
|
163
|
+
response = await client.call('get', apiPath, {
|
|
108
164
|
'content-type': 'application/json',
|
|
109
165
|
}, payload, 'arraybuffer');
|
|
110
166
|
|
|
111
167
|
fs.writeFileSync(destination, response);
|
|
112
168
|
|
|
113
|
-
if (parseOutput) {
|
|
114
|
-
|
|
169
|
+
if (parseOutput) {
|
|
170
|
+
parse(response)
|
|
115
171
|
success()
|
|
116
172
|
}
|
|
173
|
+
|
|
174
|
+
return response;
|
|
117
175
|
}
|
|
118
176
|
|
|
177
|
+
/**
|
|
178
|
+
* @typedef {Object} AvatarsGetFlagRequestParams
|
|
179
|
+
* @property {string} code Country Code. ISO Alpha-2 country code format.
|
|
180
|
+
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
181
|
+
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
182
|
+
* @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
|
|
183
|
+
* @property {boolean} parseOutput
|
|
184
|
+
* @property {libClient | undefined} sdk
|
|
185
|
+
* @property {string} destination
|
|
186
|
+
*/
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* @param {AvatarsGetFlagRequestParams} params
|
|
190
|
+
*/
|
|
119
191
|
const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
|
|
120
|
-
/* @param {string} code */
|
|
121
|
-
/* @param {number} width */
|
|
122
|
-
/* @param {number} height */
|
|
123
|
-
/* @param {number} quality */
|
|
124
|
-
|
|
125
192
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
126
193
|
let apiPath = '/avatars/flags/{code}'.replace('{code}', code);
|
|
127
194
|
let payload = {};
|
|
128
|
-
|
|
129
|
-
/** Query Params */
|
|
130
195
|
if (typeof width !== 'undefined') {
|
|
131
196
|
payload['width'] = width;
|
|
132
197
|
}
|
|
@@ -141,28 +206,39 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
|
|
|
141
206
|
const queryParams = new URLSearchParams(payload);
|
|
142
207
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
143
208
|
|
|
144
|
-
|
|
209
|
+
let response = undefined;
|
|
210
|
+
|
|
211
|
+
response = await client.call('get', apiPath, {
|
|
145
212
|
'content-type': 'application/json',
|
|
146
213
|
}, payload, 'arraybuffer');
|
|
147
214
|
|
|
148
215
|
fs.writeFileSync(destination, response);
|
|
149
216
|
|
|
150
|
-
if (parseOutput) {
|
|
151
|
-
|
|
217
|
+
if (parseOutput) {
|
|
218
|
+
parse(response)
|
|
152
219
|
success()
|
|
153
220
|
}
|
|
221
|
+
|
|
222
|
+
return response;
|
|
154
223
|
}
|
|
155
224
|
|
|
225
|
+
/**
|
|
226
|
+
* @typedef {Object} AvatarsGetImageRequestParams
|
|
227
|
+
* @property {string} url Image URL which you want to crop.
|
|
228
|
+
* @property {number} width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.
|
|
229
|
+
* @property {number} height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.
|
|
230
|
+
* @property {boolean} parseOutput
|
|
231
|
+
* @property {libClient | undefined} sdk
|
|
232
|
+
* @property {string} destination
|
|
233
|
+
*/
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* @param {AvatarsGetImageRequestParams} params
|
|
237
|
+
*/
|
|
156
238
|
const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = undefined, destination}) => {
|
|
157
|
-
/* @param {string} url */
|
|
158
|
-
/* @param {number} width */
|
|
159
|
-
/* @param {number} height */
|
|
160
|
-
|
|
161
239
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
162
240
|
let apiPath = '/avatars/image';
|
|
163
241
|
let payload = {};
|
|
164
|
-
|
|
165
|
-
/** Query Params */
|
|
166
242
|
if (typeof url !== 'undefined') {
|
|
167
243
|
payload['url'] = url;
|
|
168
244
|
}
|
|
@@ -177,29 +253,40 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
|
|
|
177
253
|
const queryParams = new URLSearchParams(payload);
|
|
178
254
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
179
255
|
|
|
180
|
-
|
|
256
|
+
let response = undefined;
|
|
257
|
+
|
|
258
|
+
response = await client.call('get', apiPath, {
|
|
181
259
|
'content-type': 'application/json',
|
|
182
260
|
}, payload, 'arraybuffer');
|
|
183
261
|
|
|
184
262
|
fs.writeFileSync(destination, response);
|
|
185
263
|
|
|
186
|
-
if (parseOutput) {
|
|
187
|
-
|
|
264
|
+
if (parseOutput) {
|
|
265
|
+
parse(response)
|
|
188
266
|
success()
|
|
189
267
|
}
|
|
268
|
+
|
|
269
|
+
return response;
|
|
190
270
|
}
|
|
191
271
|
|
|
272
|
+
/**
|
|
273
|
+
* @typedef {Object} AvatarsGetInitialsRequestParams
|
|
274
|
+
* @property {string} name Full Name. When empty, current user name or email will be used. Max length: 128 chars.
|
|
275
|
+
* @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
|
|
276
|
+
* @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
|
|
277
|
+
* @property {string} background Changes background color. By default a random color will be picked and stay will persistent to the given name.
|
|
278
|
+
* @property {boolean} parseOutput
|
|
279
|
+
* @property {libClient | undefined} sdk
|
|
280
|
+
* @property {string} destination
|
|
281
|
+
*/
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @param {AvatarsGetInitialsRequestParams} params
|
|
285
|
+
*/
|
|
192
286
|
const avatarsGetInitials = async ({ name, width, height, background, parseOutput = true, sdk = undefined, destination}) => {
|
|
193
|
-
/* @param {string} name */
|
|
194
|
-
/* @param {number} width */
|
|
195
|
-
/* @param {number} height */
|
|
196
|
-
/* @param {string} background */
|
|
197
|
-
|
|
198
287
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
199
288
|
let apiPath = '/avatars/initials';
|
|
200
289
|
let payload = {};
|
|
201
|
-
|
|
202
|
-
/** Query Params */
|
|
203
290
|
if (typeof name !== 'undefined') {
|
|
204
291
|
payload['name'] = name;
|
|
205
292
|
}
|
|
@@ -217,29 +304,40 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
|
|
|
217
304
|
const queryParams = new URLSearchParams(payload);
|
|
218
305
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
219
306
|
|
|
220
|
-
|
|
307
|
+
let response = undefined;
|
|
308
|
+
|
|
309
|
+
response = await client.call('get', apiPath, {
|
|
221
310
|
'content-type': 'application/json',
|
|
222
311
|
}, payload, 'arraybuffer');
|
|
223
312
|
|
|
224
313
|
fs.writeFileSync(destination, response);
|
|
225
314
|
|
|
226
|
-
if (parseOutput) {
|
|
227
|
-
|
|
315
|
+
if (parseOutput) {
|
|
316
|
+
parse(response)
|
|
228
317
|
success()
|
|
229
318
|
}
|
|
319
|
+
|
|
320
|
+
return response;
|
|
230
321
|
}
|
|
231
322
|
|
|
323
|
+
/**
|
|
324
|
+
* @typedef {Object} AvatarsGetQRRequestParams
|
|
325
|
+
* @property {string} text Plain text to be converted to QR code image.
|
|
326
|
+
* @property {number} size QR code size. Pass an integer between 1 to 1000. Defaults to 400.
|
|
327
|
+
* @property {number} margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
|
|
328
|
+
* @property {boolean} download Return resulting image with 'Content-Disposition: attachment ' headers for the browser to start downloading it. Pass 0 for no header, or 1 for otherwise. Default value is set to 0.
|
|
329
|
+
* @property {boolean} parseOutput
|
|
330
|
+
* @property {libClient | undefined} sdk
|
|
331
|
+
* @property {string} destination
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* @param {AvatarsGetQRRequestParams} params
|
|
336
|
+
*/
|
|
232
337
|
const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true, sdk = undefined, destination}) => {
|
|
233
|
-
/* @param {string} text */
|
|
234
|
-
/* @param {number} size */
|
|
235
|
-
/* @param {number} margin */
|
|
236
|
-
/* @param {boolean} download */
|
|
237
|
-
|
|
238
338
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
239
339
|
let apiPath = '/avatars/qr';
|
|
240
340
|
let payload = {};
|
|
241
|
-
|
|
242
|
-
/** Query Params */
|
|
243
341
|
if (typeof text !== 'undefined') {
|
|
244
342
|
payload['text'] = text;
|
|
245
343
|
}
|
|
@@ -257,19 +355,22 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
|
|
|
257
355
|
const queryParams = new URLSearchParams(payload);
|
|
258
356
|
apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
|
|
259
357
|
|
|
260
|
-
|
|
358
|
+
let response = undefined;
|
|
359
|
+
|
|
360
|
+
response = await client.call('get', apiPath, {
|
|
261
361
|
'content-type': 'application/json',
|
|
262
362
|
}, payload, 'arraybuffer');
|
|
263
363
|
|
|
264
364
|
fs.writeFileSync(destination, response);
|
|
265
365
|
|
|
266
|
-
if (parseOutput) {
|
|
267
|
-
|
|
366
|
+
if (parseOutput) {
|
|
367
|
+
parse(response)
|
|
268
368
|
success()
|
|
269
369
|
}
|
|
370
|
+
|
|
371
|
+
return response;
|
|
270
372
|
}
|
|
271
373
|
|
|
272
|
-
|
|
273
374
|
avatars
|
|
274
375
|
.command(`getBrowser`)
|
|
275
376
|
.description(`You can use this endpoint to show different browser icons to your users. The code argument receives the browser code as it appears in your user [GET /account/sessions](https://appwrite.io/docs/references/cloud/client-web/account#getSessions) endpoint. Use width, height and quality arguments to change the output settings. When one dimension is specified and the other is 0, the image is scaled with preserved aspect ratio. If both dimensions are 0, the API provides an image at source quality. If dimensions are not specified, the default size of image returned is 100x100px.`)
|
|
@@ -336,7 +437,6 @@ avatars
|
|
|
336
437
|
.requiredOption(`--destination <path>`, `output file path.`)
|
|
337
438
|
.action(actionRunner(avatarsGetQR))
|
|
338
439
|
|
|
339
|
-
|
|
340
440
|
module.exports = {
|
|
341
441
|
avatars,
|
|
342
442
|
avatarsGetBrowser,
|
|
@@ -346,4 +446,4 @@ module.exports = {
|
|
|
346
446
|
avatarsGetImage,
|
|
347
447
|
avatarsGetInitials,
|
|
348
448
|
avatarsGetQR
|
|
349
|
-
};
|
|
449
|
+
};
|
package/lib/commands/console.js
CHANGED
|
@@ -9,36 +9,70 @@ 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 console = new Command("console").description(commandDescriptions['console']).configureHelp({
|
|
14
39
|
helpWidth: process.stdout.columns || 80
|
|
15
|
-
|
|
40
|
+
})
|
|
16
41
|
|
|
17
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {Object} ConsoleVariablesRequestParams
|
|
44
|
+
* @property {boolean} parseOutput
|
|
45
|
+
* @property {libClient | undefined} sdk
|
|
46
|
+
*/
|
|
18
47
|
|
|
48
|
+
/**
|
|
49
|
+
* @param {ConsoleVariablesRequestParams} params
|
|
50
|
+
*/
|
|
51
|
+
const consoleVariables = async ({ parseOutput = true, sdk = undefined}) => {
|
|
19
52
|
let client = !sdk ? await sdkForProject() : sdk;
|
|
20
53
|
let apiPath = '/console/variables';
|
|
21
54
|
let payload = {};
|
|
55
|
+
|
|
22
56
|
let response = undefined;
|
|
57
|
+
|
|
23
58
|
response = await client.call('get', apiPath, {
|
|
24
59
|
'content-type': 'application/json',
|
|
25
60
|
}, payload);
|
|
26
|
-
|
|
61
|
+
|
|
27
62
|
if (parseOutput) {
|
|
28
63
|
parse(response)
|
|
29
64
|
success()
|
|
30
65
|
}
|
|
66
|
+
|
|
31
67
|
return response;
|
|
32
68
|
}
|
|
33
69
|
|
|
34
|
-
|
|
35
70
|
console
|
|
36
71
|
.command(`variables`)
|
|
37
72
|
.description(`Get all Environment Variables that are relevant for the console.`)
|
|
38
73
|
.action(actionRunner(consoleVariables))
|
|
39
74
|
|
|
40
|
-
|
|
41
75
|
module.exports = {
|
|
42
76
|
console,
|
|
43
77
|
consoleVariables
|
|
44
|
-
};
|
|
78
|
+
};
|