appwrite-cli 5.0.3 → 6.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.
Files changed (54) hide show
  1. package/README.md +4 -4
  2. package/docs/examples/functions/create-build.md +1 -1
  3. package/docs/examples/functions/create-execution.md +1 -0
  4. package/docs/examples/functions/create.md +1 -0
  5. package/docs/examples/functions/delete-execution.md +3 -0
  6. package/docs/examples/functions/update-deployment-build.md +3 -0
  7. package/docs/examples/functions/update.md +1 -0
  8. package/docs/examples/messaging/update-email.md +1 -0
  9. package/docs/examples/projects/create-j-w-t.md +4 -0
  10. package/docs/examples/projects/update-mock-numbers.md +3 -0
  11. package/docs/examples/projects/update-session-alerts.md +3 -0
  12. package/docs/examples/users/create-j-w-t.md +4 -0
  13. package/docs/examples/vcs/get-repository-contents.md +4 -0
  14. package/index.js +34 -7
  15. package/install.ps1 +3 -3
  16. package/install.sh +2 -2
  17. package/lib/client.js +19 -5
  18. package/lib/commands/account.js +307 -153
  19. package/lib/commands/assistant.js +8 -5
  20. package/lib/commands/avatars.js +116 -60
  21. package/lib/commands/console.js +8 -5
  22. package/lib/commands/databases.js +353 -164
  23. package/lib/commands/functions.js +310 -100
  24. package/lib/commands/generic.js +206 -54
  25. package/lib/commands/graphql.js +14 -8
  26. package/lib/commands/health.js +140 -71
  27. package/lib/commands/init.js +250 -155
  28. package/lib/commands/locale.js +50 -26
  29. package/lib/commands/messaging.js +363 -179
  30. package/lib/commands/migrations.js +98 -50
  31. package/lib/commands/project.js +38 -20
  32. package/lib/commands/projects.js +449 -144
  33. package/lib/commands/proxy.js +32 -17
  34. package/lib/commands/pull.js +231 -0
  35. package/lib/commands/push.js +1518 -0
  36. package/lib/commands/run.js +282 -0
  37. package/lib/commands/storage.js +160 -76
  38. package/lib/commands/teams.js +102 -50
  39. package/lib/commands/users.js +325 -135
  40. package/lib/commands/vcs.js +102 -29
  41. package/lib/config.js +190 -18
  42. package/lib/emulation/docker.js +187 -0
  43. package/lib/emulation/utils.js +177 -0
  44. package/lib/id.js +30 -0
  45. package/lib/paginate.js +1 -2
  46. package/lib/parser.js +69 -12
  47. package/lib/questions.js +462 -84
  48. package/lib/sdks.js +1 -1
  49. package/lib/spinner.js +103 -0
  50. package/lib/utils.js +248 -3
  51. package/lib/validations.js +17 -0
  52. package/package.json +6 -2
  53. package/scoop/appwrite.json +3 -3
  54. package/lib/commands/deploy.js +0 -941
@@ -4,7 +4,7 @@ const tar = require("tar");
4
4
  const ignore = require("ignore");
5
5
  const { promisify } = require('util');
6
6
  const libClient = require('../client.js');
7
- const { getAllFiles } = require('../utils.js');
7
+ const { getAllFiles, showConsoleLink } = require('../utils.js');
8
8
  const { Command } = require('commander');
9
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -42,6 +42,7 @@ const assistant = new Command("assistant").description(commandDescriptions['assi
42
42
  /**
43
43
  * @typedef {Object} AssistantChatRequestParams
44
44
  * @property {string} prompt Prompt. A string containing questions asked to the AI assistant.
45
+ * @property {boolean} overrideForCli
45
46
  * @property {boolean} parseOutput
46
47
  * @property {libClient | undefined} sdk
47
48
  */
@@ -49,8 +50,9 @@ const assistant = new Command("assistant").description(commandDescriptions['assi
49
50
  /**
50
51
  * @param {AssistantChatRequestParams} params
51
52
  */
52
- const assistantChat = async ({ prompt, parseOutput = true, sdk = undefined}) => {
53
- let client = !sdk ? await sdkForProject() : sdk;
53
+ const assistantChat = async ({prompt,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
54
+ let client = !sdk ? await sdkForProject() :
55
+ sdk;
54
56
  let apiPath = '/console/assistant';
55
57
  let payload = {};
56
58
  if (typeof prompt !== 'undefined') {
@@ -67,8 +69,9 @@ const assistantChat = async ({ prompt, parseOutput = true, sdk = undefined}) =>
67
69
  parse(response)
68
70
  success()
69
71
  }
70
-
72
+
71
73
  return response;
74
+
72
75
  }
73
76
 
74
77
  assistant
@@ -80,4 +83,4 @@ assistant
80
83
  module.exports = {
81
84
  assistant,
82
85
  assistantChat
83
- };
86
+ };
@@ -4,7 +4,7 @@ const tar = require("tar");
4
4
  const ignore = require("ignore");
5
5
  const { promisify } = require('util');
6
6
  const libClient = require('../client.js');
7
- const { getAllFiles } = require('../utils.js');
7
+ const { getAllFiles, showConsoleLink } = require('../utils.js');
8
8
  const { Command } = require('commander');
9
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -45,6 +45,7 @@ const avatars = new Command("avatars").description(commandDescriptions['avatars'
45
45
  * @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
46
46
  * @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
47
47
  * @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
48
+ * @property {boolean} overrideForCli
48
49
  * @property {boolean} parseOutput
49
50
  * @property {libClient | undefined} sdk
50
51
  * @property {string} destination
@@ -53,8 +54,9 @@ const avatars = new Command("avatars").description(commandDescriptions['avatars'
53
54
  /**
54
55
  * @param {AvatarsGetBrowserRequestParams} params
55
56
  */
56
- const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
57
- let client = !sdk ? await sdkForProject() : sdk;
57
+ const avatarsGetBrowser = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
58
+ let client = !sdk ? await sdkForProject() :
59
+ sdk;
58
60
  let apiPath = '/avatars/browsers/{code}'.replace('{code}', code);
59
61
  let payload = {};
60
62
  if (typeof width !== 'undefined') {
@@ -66,10 +68,12 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
66
68
  if (typeof quality !== 'undefined') {
67
69
  payload['quality'] = quality;
68
70
  }
69
- payload['project'] = localConfig.getProject().projectId
70
- payload['key'] = globalConfig.getKey();
71
- const queryParams = new URLSearchParams(payload);
72
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
71
+ if (!overrideForCli) {
72
+ payload['project'] = localConfig.getProject().projectId
73
+ payload['key'] = globalConfig.getKey();
74
+ const queryParams = new URLSearchParams(payload);
75
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
76
+ }
73
77
 
74
78
  let response = undefined;
75
79
 
@@ -77,22 +81,27 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
77
81
  'content-type': 'application/json',
78
82
  }, payload, 'arraybuffer');
79
83
 
80
- fs.writeFileSync(destination, response);
84
+ if (overrideForCli) {
85
+ response = Buffer.from(response);
86
+ }
81
87
 
88
+ fs.writeFileSync(destination, response);
82
89
  if (parseOutput) {
83
90
  parse(response)
84
91
  success()
85
92
  }
86
-
93
+
87
94
  return response;
95
+
88
96
  }
89
97
 
90
98
  /**
91
99
  * @typedef {Object} AvatarsGetCreditCardRequestParams
92
- * @property {CreditCard} 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.
100
+ * @property {CreditCard} code Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.
93
101
  * @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
94
102
  * @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
95
103
  * @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
104
+ * @property {boolean} overrideForCli
96
105
  * @property {boolean} parseOutput
97
106
  * @property {libClient | undefined} sdk
98
107
  * @property {string} destination
@@ -101,8 +110,9 @@ const avatarsGetBrowser = async ({ code, width, height, quality, parseOutput = t
101
110
  /**
102
111
  * @param {AvatarsGetCreditCardRequestParams} params
103
112
  */
104
- const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
105
- let client = !sdk ? await sdkForProject() : sdk;
113
+ const avatarsGetCreditCard = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
114
+ let client = !sdk ? await sdkForProject() :
115
+ sdk;
106
116
  let apiPath = '/avatars/credit-cards/{code}'.replace('{code}', code);
107
117
  let payload = {};
108
118
  if (typeof width !== 'undefined') {
@@ -114,10 +124,12 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
114
124
  if (typeof quality !== 'undefined') {
115
125
  payload['quality'] = quality;
116
126
  }
117
- payload['project'] = localConfig.getProject().projectId
118
- payload['key'] = globalConfig.getKey();
119
- const queryParams = new URLSearchParams(payload);
120
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
127
+ if (!overrideForCli) {
128
+ payload['project'] = localConfig.getProject().projectId
129
+ payload['key'] = globalConfig.getKey();
130
+ const queryParams = new URLSearchParams(payload);
131
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
132
+ }
121
133
 
122
134
  let response = undefined;
123
135
 
@@ -125,19 +137,24 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
125
137
  'content-type': 'application/json',
126
138
  }, payload, 'arraybuffer');
127
139
 
128
- fs.writeFileSync(destination, response);
140
+ if (overrideForCli) {
141
+ response = Buffer.from(response);
142
+ }
129
143
 
144
+ fs.writeFileSync(destination, response);
130
145
  if (parseOutput) {
131
146
  parse(response)
132
147
  success()
133
148
  }
134
-
149
+
135
150
  return response;
151
+
136
152
  }
137
153
 
138
154
  /**
139
155
  * @typedef {Object} AvatarsGetFaviconRequestParams
140
156
  * @property {string} url Website URL which you want to fetch the favicon from.
157
+ * @property {boolean} overrideForCli
141
158
  * @property {boolean} parseOutput
142
159
  * @property {libClient | undefined} sdk
143
160
  * @property {string} destination
@@ -146,17 +163,20 @@ const avatarsGetCreditCard = async ({ code, width, height, quality, parseOutput
146
163
  /**
147
164
  * @param {AvatarsGetFaviconRequestParams} params
148
165
  */
149
- const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, destination}) => {
150
- let client = !sdk ? await sdkForProject() : sdk;
166
+ const avatarsGetFavicon = async ({url,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
167
+ let client = !sdk ? await sdkForProject() :
168
+ sdk;
151
169
  let apiPath = '/avatars/favicon';
152
170
  let payload = {};
153
171
  if (typeof url !== 'undefined') {
154
172
  payload['url'] = url;
155
173
  }
156
- payload['project'] = localConfig.getProject().projectId
157
- payload['key'] = globalConfig.getKey();
158
- const queryParams = new URLSearchParams(payload);
159
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
174
+ if (!overrideForCli) {
175
+ payload['project'] = localConfig.getProject().projectId
176
+ payload['key'] = globalConfig.getKey();
177
+ const queryParams = new URLSearchParams(payload);
178
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
179
+ }
160
180
 
161
181
  let response = undefined;
162
182
 
@@ -164,14 +184,18 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
164
184
  'content-type': 'application/json',
165
185
  }, payload, 'arraybuffer');
166
186
 
167
- fs.writeFileSync(destination, response);
187
+ if (overrideForCli) {
188
+ response = Buffer.from(response);
189
+ }
168
190
 
191
+ fs.writeFileSync(destination, response);
169
192
  if (parseOutput) {
170
193
  parse(response)
171
194
  success()
172
195
  }
173
-
196
+
174
197
  return response;
198
+
175
199
  }
176
200
 
177
201
  /**
@@ -180,6 +204,7 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
180
204
  * @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
181
205
  * @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
182
206
  * @property {number} quality Image quality. Pass an integer between 0 to 100. Defaults to 100.
207
+ * @property {boolean} overrideForCli
183
208
  * @property {boolean} parseOutput
184
209
  * @property {libClient | undefined} sdk
185
210
  * @property {string} destination
@@ -188,8 +213,9 @@ const avatarsGetFavicon = async ({ url, parseOutput = true, sdk = undefined, des
188
213
  /**
189
214
  * @param {AvatarsGetFlagRequestParams} params
190
215
  */
191
- const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true, sdk = undefined, destination}) => {
192
- let client = !sdk ? await sdkForProject() : sdk;
216
+ const avatarsGetFlag = async ({code,width,height,quality,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
217
+ let client = !sdk ? await sdkForProject() :
218
+ sdk;
193
219
  let apiPath = '/avatars/flags/{code}'.replace('{code}', code);
194
220
  let payload = {};
195
221
  if (typeof width !== 'undefined') {
@@ -201,10 +227,12 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
201
227
  if (typeof quality !== 'undefined') {
202
228
  payload['quality'] = quality;
203
229
  }
204
- payload['project'] = localConfig.getProject().projectId
205
- payload['key'] = globalConfig.getKey();
206
- const queryParams = new URLSearchParams(payload);
207
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
230
+ if (!overrideForCli) {
231
+ payload['project'] = localConfig.getProject().projectId
232
+ payload['key'] = globalConfig.getKey();
233
+ const queryParams = new URLSearchParams(payload);
234
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
235
+ }
208
236
 
209
237
  let response = undefined;
210
238
 
@@ -212,14 +240,18 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
212
240
  'content-type': 'application/json',
213
241
  }, payload, 'arraybuffer');
214
242
 
215
- fs.writeFileSync(destination, response);
243
+ if (overrideForCli) {
244
+ response = Buffer.from(response);
245
+ }
216
246
 
247
+ fs.writeFileSync(destination, response);
217
248
  if (parseOutput) {
218
249
  parse(response)
219
250
  success()
220
251
  }
221
-
252
+
222
253
  return response;
254
+
223
255
  }
224
256
 
225
257
  /**
@@ -227,6 +259,7 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
227
259
  * @property {string} url Image URL which you want to crop.
228
260
  * @property {number} width Resize preview image width, Pass an integer between 0 to 2000. Defaults to 400.
229
261
  * @property {number} height Resize preview image height, Pass an integer between 0 to 2000. Defaults to 400.
262
+ * @property {boolean} overrideForCli
230
263
  * @property {boolean} parseOutput
231
264
  * @property {libClient | undefined} sdk
232
265
  * @property {string} destination
@@ -235,8 +268,9 @@ const avatarsGetFlag = async ({ code, width, height, quality, parseOutput = true
235
268
  /**
236
269
  * @param {AvatarsGetImageRequestParams} params
237
270
  */
238
- const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = undefined, destination}) => {
239
- let client = !sdk ? await sdkForProject() : sdk;
271
+ const avatarsGetImage = async ({url,width,height,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
272
+ let client = !sdk ? await sdkForProject() :
273
+ sdk;
240
274
  let apiPath = '/avatars/image';
241
275
  let payload = {};
242
276
  if (typeof url !== 'undefined') {
@@ -248,10 +282,12 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
248
282
  if (typeof height !== 'undefined') {
249
283
  payload['height'] = height;
250
284
  }
251
- payload['project'] = localConfig.getProject().projectId
252
- payload['key'] = globalConfig.getKey();
253
- const queryParams = new URLSearchParams(payload);
254
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
285
+ if (!overrideForCli) {
286
+ payload['project'] = localConfig.getProject().projectId
287
+ payload['key'] = globalConfig.getKey();
288
+ const queryParams = new URLSearchParams(payload);
289
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
290
+ }
255
291
 
256
292
  let response = undefined;
257
293
 
@@ -259,14 +295,18 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
259
295
  'content-type': 'application/json',
260
296
  }, payload, 'arraybuffer');
261
297
 
262
- fs.writeFileSync(destination, response);
298
+ if (overrideForCli) {
299
+ response = Buffer.from(response);
300
+ }
263
301
 
302
+ fs.writeFileSync(destination, response);
264
303
  if (parseOutput) {
265
304
  parse(response)
266
305
  success()
267
306
  }
268
-
307
+
269
308
  return response;
309
+
270
310
  }
271
311
 
272
312
  /**
@@ -275,6 +315,7 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
275
315
  * @property {number} width Image width. Pass an integer between 0 to 2000. Defaults to 100.
276
316
  * @property {number} height Image height. Pass an integer between 0 to 2000. Defaults to 100.
277
317
  * @property {string} background Changes background color. By default a random color will be picked and stay will persistent to the given name.
318
+ * @property {boolean} overrideForCli
278
319
  * @property {boolean} parseOutput
279
320
  * @property {libClient | undefined} sdk
280
321
  * @property {string} destination
@@ -283,8 +324,9 @@ const avatarsGetImage = async ({ url, width, height, parseOutput = true, sdk = u
283
324
  /**
284
325
  * @param {AvatarsGetInitialsRequestParams} params
285
326
  */
286
- const avatarsGetInitials = async ({ name, width, height, background, parseOutput = true, sdk = undefined, destination}) => {
287
- let client = !sdk ? await sdkForProject() : sdk;
327
+ const avatarsGetInitials = async ({name,width,height,background,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
328
+ let client = !sdk ? await sdkForProject() :
329
+ sdk;
288
330
  let apiPath = '/avatars/initials';
289
331
  let payload = {};
290
332
  if (typeof name !== 'undefined') {
@@ -299,10 +341,12 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
299
341
  if (typeof background !== 'undefined') {
300
342
  payload['background'] = background;
301
343
  }
302
- payload['project'] = localConfig.getProject().projectId
303
- payload['key'] = globalConfig.getKey();
304
- const queryParams = new URLSearchParams(payload);
305
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
344
+ if (!overrideForCli) {
345
+ payload['project'] = localConfig.getProject().projectId
346
+ payload['key'] = globalConfig.getKey();
347
+ const queryParams = new URLSearchParams(payload);
348
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
349
+ }
306
350
 
307
351
  let response = undefined;
308
352
 
@@ -310,14 +354,18 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
310
354
  'content-type': 'application/json',
311
355
  }, payload, 'arraybuffer');
312
356
 
313
- fs.writeFileSync(destination, response);
357
+ if (overrideForCli) {
358
+ response = Buffer.from(response);
359
+ }
314
360
 
361
+ fs.writeFileSync(destination, response);
315
362
  if (parseOutput) {
316
363
  parse(response)
317
364
  success()
318
365
  }
319
-
366
+
320
367
  return response;
368
+
321
369
  }
322
370
 
323
371
  /**
@@ -326,6 +374,7 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
326
374
  * @property {number} size QR code size. Pass an integer between 1 to 1000. Defaults to 400.
327
375
  * @property {number} margin Margin from edge. Pass an integer between 0 to 10. Defaults to 1.
328
376
  * @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.
377
+ * @property {boolean} overrideForCli
329
378
  * @property {boolean} parseOutput
330
379
  * @property {libClient | undefined} sdk
331
380
  * @property {string} destination
@@ -334,8 +383,9 @@ const avatarsGetInitials = async ({ name, width, height, background, parseOutput
334
383
  /**
335
384
  * @param {AvatarsGetQRRequestParams} params
336
385
  */
337
- const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true, sdk = undefined, destination}) => {
338
- let client = !sdk ? await sdkForProject() : sdk;
386
+ const avatarsGetQR = async ({text,size,margin,download,parseOutput = true, overrideForCli = false, sdk = undefined, destination}) => {
387
+ let client = !sdk ? await sdkForProject() :
388
+ sdk;
339
389
  let apiPath = '/avatars/qr';
340
390
  let payload = {};
341
391
  if (typeof text !== 'undefined') {
@@ -350,10 +400,12 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
350
400
  if (typeof download !== 'undefined') {
351
401
  payload['download'] = download;
352
402
  }
353
- payload['project'] = localConfig.getProject().projectId
354
- payload['key'] = globalConfig.getKey();
355
- const queryParams = new URLSearchParams(payload);
356
- apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
403
+ if (!overrideForCli) {
404
+ payload['project'] = localConfig.getProject().projectId
405
+ payload['key'] = globalConfig.getKey();
406
+ const queryParams = new URLSearchParams(payload);
407
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
408
+ }
357
409
 
358
410
  let response = undefined;
359
411
 
@@ -361,14 +413,18 @@ const avatarsGetQR = async ({ text, size, margin, download, parseOutput = true,
361
413
  'content-type': 'application/json',
362
414
  }, payload, 'arraybuffer');
363
415
 
364
- fs.writeFileSync(destination, response);
416
+ if (overrideForCli) {
417
+ response = Buffer.from(response);
418
+ }
365
419
 
420
+ fs.writeFileSync(destination, response);
366
421
  if (parseOutput) {
367
422
  parse(response)
368
423
  success()
369
424
  }
370
-
425
+
371
426
  return response;
427
+
372
428
  }
373
429
 
374
430
  avatars
@@ -384,7 +440,7 @@ avatars
384
440
  avatars
385
441
  .command(`getCreditCard`)
386
442
  .description(`The credit card endpoint will return you the icon of the credit card provider you need. 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. `)
387
- .requiredOption(`--code <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.`)
443
+ .requiredOption(`--code <code>`, `Credit Card Code. Possible values: amex, argencard, cabal, cencosud, diners, discover, elo, hipercard, jcb, mastercard, naranja, targeta-shopping, union-china-pay, visa, mir, maestro.`)
388
444
  .option(`--width <width>`, `Image width. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
389
445
  .option(`--height <height>`, `Image height. Pass an integer between 0 to 2000. Defaults to 100.`, parseInteger)
390
446
  .option(`--quality <quality>`, `Image quality. Pass an integer between 0 to 100. Defaults to 100.`, parseInteger)
@@ -446,4 +502,4 @@ module.exports = {
446
502
  avatarsGetImage,
447
503
  avatarsGetInitials,
448
504
  avatarsGetQR
449
- };
505
+ };
@@ -4,7 +4,7 @@ const tar = require("tar");
4
4
  const ignore = require("ignore");
5
5
  const { promisify } = require('util');
6
6
  const libClient = require('../client.js');
7
- const { getAllFiles } = require('../utils.js');
7
+ const { getAllFiles, showConsoleLink } = require('../utils.js');
8
8
  const { Command } = require('commander');
9
9
  const { sdkForProject, sdkForConsole } = require('../sdks')
10
10
  const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
@@ -41,6 +41,7 @@ const console = new Command("console").description(commandDescriptions['console'
41
41
 
42
42
  /**
43
43
  * @typedef {Object} ConsoleVariablesRequestParams
44
+ * @property {boolean} overrideForCli
44
45
  * @property {boolean} parseOutput
45
46
  * @property {libClient | undefined} sdk
46
47
  */
@@ -48,8 +49,9 @@ const console = new Command("console").description(commandDescriptions['console'
48
49
  /**
49
50
  * @param {ConsoleVariablesRequestParams} params
50
51
  */
51
- const consoleVariables = async ({ parseOutput = true, sdk = undefined}) => {
52
- let client = !sdk ? await sdkForProject() : sdk;
52
+ const consoleVariables = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
53
+ let client = !sdk ? await sdkForProject() :
54
+ sdk;
53
55
  let apiPath = '/console/variables';
54
56
  let payload = {};
55
57
 
@@ -63,8 +65,9 @@ const consoleVariables = async ({ parseOutput = true, sdk = undefined}) => {
63
65
  parse(response)
64
66
  success()
65
67
  }
66
-
68
+
67
69
  return response;
70
+
68
71
  }
69
72
 
70
73
  console
@@ -75,4 +78,4 @@ console
75
78
  module.exports = {
76
79
  console,
77
80
  consoleVariables
78
- };
81
+ };