appwrite-cli 4.2.0 → 4.2.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.
@@ -9,378 +9,635 @@ 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 health = new Command("health").description(commandDescriptions['health']).configureHelp({
14
39
  helpWidth: process.stdout.columns || 80
15
40
  })
16
41
 
17
- const healthGet = async ({ parseOutput = true, sdk = undefined}) => {
42
+ /**
43
+ * @typedef {Object} HealthGetRequestParams
44
+ * @property {boolean} parseOutput
45
+ * @property {libClient | undefined} sdk
46
+ */
18
47
 
48
+ /**
49
+ * @param {HealthGetRequestParams} params
50
+ */
51
+ const healthGet = async ({ parseOutput = true, sdk = undefined}) => {
19
52
  let client = !sdk ? await sdkForProject() : sdk;
53
+
20
54
  let apiPath = '/health';
21
55
  let payload = {};
56
+
57
+
22
58
  let response = undefined;
59
+
23
60
  response = await client.call('get', apiPath, {
24
61
  'content-type': 'application/json',
25
62
  }, payload);
63
+
26
64
 
27
65
  if (parseOutput) {
28
66
  parse(response)
29
67
  success()
30
68
  }
69
+
31
70
  return response;
32
71
  }
33
72
 
34
- const healthGetAntivirus = async ({ parseOutput = true, sdk = undefined}) => {
73
+ /**
74
+ * @typedef {Object} HealthGetAntivirusRequestParams
75
+ * @property {boolean} parseOutput
76
+ * @property {libClient | undefined} sdk
77
+ */
35
78
 
79
+ /**
80
+ * @param {HealthGetAntivirusRequestParams} params
81
+ */
82
+ const healthGetAntivirus = async ({ parseOutput = true, sdk = undefined}) => {
36
83
  let client = !sdk ? await sdkForProject() : sdk;
84
+
37
85
  let apiPath = '/health/anti-virus';
38
86
  let payload = {};
87
+
88
+
39
89
  let response = undefined;
90
+
40
91
  response = await client.call('get', apiPath, {
41
92
  'content-type': 'application/json',
42
93
  }, payload);
94
+
43
95
 
44
96
  if (parseOutput) {
45
97
  parse(response)
46
98
  success()
47
99
  }
100
+
48
101
  return response;
49
102
  }
50
103
 
51
- const healthGetCache = async ({ parseOutput = true, sdk = undefined}) => {
104
+ /**
105
+ * @typedef {Object} HealthGetCacheRequestParams
106
+ * @property {boolean} parseOutput
107
+ * @property {libClient | undefined} sdk
108
+ */
52
109
 
110
+ /**
111
+ * @param {HealthGetCacheRequestParams} params
112
+ */
113
+ const healthGetCache = async ({ parseOutput = true, sdk = undefined}) => {
53
114
  let client = !sdk ? await sdkForProject() : sdk;
115
+
54
116
  let apiPath = '/health/cache';
55
117
  let payload = {};
118
+
119
+
56
120
  let response = undefined;
121
+
57
122
  response = await client.call('get', apiPath, {
58
123
  'content-type': 'application/json',
59
124
  }, payload);
125
+
60
126
 
61
127
  if (parseOutput) {
62
128
  parse(response)
63
129
  success()
64
130
  }
131
+
65
132
  return response;
66
133
  }
67
134
 
68
- const healthGetDB = async ({ parseOutput = true, sdk = undefined}) => {
135
+ /**
136
+ * @typedef {Object} HealthGetDBRequestParams
137
+ * @property {boolean} parseOutput
138
+ * @property {libClient | undefined} sdk
139
+ */
69
140
 
141
+ /**
142
+ * @param {HealthGetDBRequestParams} params
143
+ */
144
+ const healthGetDB = async ({ parseOutput = true, sdk = undefined}) => {
70
145
  let client = !sdk ? await sdkForProject() : sdk;
146
+
71
147
  let apiPath = '/health/db';
72
148
  let payload = {};
149
+
150
+
73
151
  let response = undefined;
152
+
74
153
  response = await client.call('get', apiPath, {
75
154
  'content-type': 'application/json',
76
155
  }, payload);
156
+
77
157
 
78
158
  if (parseOutput) {
79
159
  parse(response)
80
160
  success()
81
161
  }
162
+
82
163
  return response;
83
164
  }
84
165
 
85
- const healthGetPubSub = async ({ parseOutput = true, sdk = undefined}) => {
166
+ /**
167
+ * @typedef {Object} HealthGetPubSubRequestParams
168
+ * @property {boolean} parseOutput
169
+ * @property {libClient | undefined} sdk
170
+ */
86
171
 
172
+ /**
173
+ * @param {HealthGetPubSubRequestParams} params
174
+ */
175
+ const healthGetPubSub = async ({ parseOutput = true, sdk = undefined}) => {
87
176
  let client = !sdk ? await sdkForProject() : sdk;
177
+
88
178
  let apiPath = '/health/pubsub';
89
179
  let payload = {};
180
+
181
+
90
182
  let response = undefined;
183
+
91
184
  response = await client.call('get', apiPath, {
92
185
  'content-type': 'application/json',
93
186
  }, payload);
187
+
94
188
 
95
189
  if (parseOutput) {
96
190
  parse(response)
97
191
  success()
98
192
  }
193
+
99
194
  return response;
100
195
  }
101
196
 
102
- const healthGetQueue = async ({ parseOutput = true, sdk = undefined}) => {
197
+ /**
198
+ * @typedef {Object} HealthGetQueueRequestParams
199
+ * @property {boolean} parseOutput
200
+ * @property {libClient | undefined} sdk
201
+ */
103
202
 
203
+ /**
204
+ * @param {HealthGetQueueRequestParams} params
205
+ */
206
+ const healthGetQueue = async ({ parseOutput = true, sdk = undefined}) => {
104
207
  let client = !sdk ? await sdkForProject() : sdk;
208
+
105
209
  let apiPath = '/health/queue';
106
210
  let payload = {};
211
+
212
+
107
213
  let response = undefined;
214
+
108
215
  response = await client.call('get', apiPath, {
109
216
  'content-type': 'application/json',
110
217
  }, payload);
218
+
111
219
 
112
220
  if (parseOutput) {
113
221
  parse(response)
114
222
  success()
115
223
  }
224
+
116
225
  return response;
117
226
  }
118
227
 
119
- const healthGetQueueBuilds = async ({ threshold, parseOutput = true, sdk = undefined}) => {
120
- /* @param {number} threshold */
228
+ /**
229
+ * @typedef {Object} HealthGetQueueBuildsRequestParams
230
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
231
+ * @property {boolean} parseOutput
232
+ * @property {libClient | undefined} sdk
233
+ */
121
234
 
235
+ /**
236
+ * @param {HealthGetQueueBuildsRequestParams} params
237
+ */
238
+ const healthGetQueueBuilds = async ({ threshold, parseOutput = true, sdk = undefined}) => {
122
239
  let client = !sdk ? await sdkForProject() : sdk;
240
+
123
241
  let apiPath = '/health/queue/builds';
124
242
  let payload = {};
125
-
126
- /** Query Params */
127
243
  if (typeof threshold !== 'undefined') {
128
244
  payload['threshold'] = threshold;
129
245
  }
246
+
247
+
130
248
  let response = undefined;
249
+
131
250
  response = await client.call('get', apiPath, {
132
251
  'content-type': 'application/json',
133
252
  }, payload);
253
+
134
254
 
135
255
  if (parseOutput) {
136
256
  parse(response)
137
257
  success()
138
258
  }
259
+
139
260
  return response;
140
261
  }
141
262
 
142
- const healthGetQueueCertificates = async ({ threshold, parseOutput = true, sdk = undefined}) => {
143
- /* @param {number} threshold */
263
+ /**
264
+ * @typedef {Object} HealthGetQueueCertificatesRequestParams
265
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
266
+ * @property {boolean} parseOutput
267
+ * @property {libClient | undefined} sdk
268
+ */
144
269
 
270
+ /**
271
+ * @param {HealthGetQueueCertificatesRequestParams} params
272
+ */
273
+ const healthGetQueueCertificates = async ({ threshold, parseOutput = true, sdk = undefined}) => {
145
274
  let client = !sdk ? await sdkForProject() : sdk;
275
+
146
276
  let apiPath = '/health/queue/certificates';
147
277
  let payload = {};
148
-
149
- /** Query Params */
150
278
  if (typeof threshold !== 'undefined') {
151
279
  payload['threshold'] = threshold;
152
280
  }
281
+
282
+
153
283
  let response = undefined;
284
+
154
285
  response = await client.call('get', apiPath, {
155
286
  'content-type': 'application/json',
156
287
  }, payload);
288
+
157
289
 
158
290
  if (parseOutput) {
159
291
  parse(response)
160
292
  success()
161
293
  }
294
+
162
295
  return response;
163
296
  }
164
297
 
298
+ /**
299
+ * @typedef {Object} HealthGetQueueDatabasesRequestParams
300
+ * @property {string} name Queue name for which to check the queue size
301
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
302
+ * @property {boolean} parseOutput
303
+ * @property {libClient | undefined} sdk
304
+ */
305
+
306
+ /**
307
+ * @param {HealthGetQueueDatabasesRequestParams} params
308
+ */
165
309
  const healthGetQueueDatabases = async ({ name, threshold, parseOutput = true, sdk = undefined}) => {
166
- /* @param {string} name */
167
- /* @param {number} threshold */
168
-
169
310
  let client = !sdk ? await sdkForProject() : sdk;
311
+
170
312
  let apiPath = '/health/queue/databases';
171
313
  let payload = {};
172
-
173
- /** Query Params */
174
314
  if (typeof name !== 'undefined') {
175
315
  payload['name'] = name;
176
316
  }
177
317
  if (typeof threshold !== 'undefined') {
178
318
  payload['threshold'] = threshold;
179
319
  }
320
+
321
+
180
322
  let response = undefined;
323
+
181
324
  response = await client.call('get', apiPath, {
182
325
  'content-type': 'application/json',
183
326
  }, payload);
327
+
184
328
 
185
329
  if (parseOutput) {
186
330
  parse(response)
187
331
  success()
188
332
  }
333
+
189
334
  return response;
190
335
  }
191
336
 
192
- const healthGetQueueDeletes = async ({ threshold, parseOutput = true, sdk = undefined}) => {
193
- /* @param {number} threshold */
337
+ /**
338
+ * @typedef {Object} HealthGetQueueDeletesRequestParams
339
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
340
+ * @property {boolean} parseOutput
341
+ * @property {libClient | undefined} sdk
342
+ */
194
343
 
344
+ /**
345
+ * @param {HealthGetQueueDeletesRequestParams} params
346
+ */
347
+ const healthGetQueueDeletes = async ({ threshold, parseOutput = true, sdk = undefined}) => {
195
348
  let client = !sdk ? await sdkForProject() : sdk;
349
+
196
350
  let apiPath = '/health/queue/deletes';
197
351
  let payload = {};
198
-
199
- /** Query Params */
200
352
  if (typeof threshold !== 'undefined') {
201
353
  payload['threshold'] = threshold;
202
354
  }
355
+
356
+
203
357
  let response = undefined;
358
+
204
359
  response = await client.call('get', apiPath, {
205
360
  'content-type': 'application/json',
206
361
  }, payload);
362
+
207
363
 
208
364
  if (parseOutput) {
209
365
  parse(response)
210
366
  success()
211
367
  }
368
+
212
369
  return response;
213
370
  }
214
371
 
215
- const healthGetQueueFunctions = async ({ threshold, parseOutput = true, sdk = undefined}) => {
216
- /* @param {number} threshold */
372
+ /**
373
+ * @typedef {Object} HealthGetQueueFunctionsRequestParams
374
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
375
+ * @property {boolean} parseOutput
376
+ * @property {libClient | undefined} sdk
377
+ */
217
378
 
379
+ /**
380
+ * @param {HealthGetQueueFunctionsRequestParams} params
381
+ */
382
+ const healthGetQueueFunctions = async ({ threshold, parseOutput = true, sdk = undefined}) => {
218
383
  let client = !sdk ? await sdkForProject() : sdk;
384
+
219
385
  let apiPath = '/health/queue/functions';
220
386
  let payload = {};
221
-
222
- /** Query Params */
223
387
  if (typeof threshold !== 'undefined') {
224
388
  payload['threshold'] = threshold;
225
389
  }
390
+
391
+
226
392
  let response = undefined;
393
+
227
394
  response = await client.call('get', apiPath, {
228
395
  'content-type': 'application/json',
229
396
  }, payload);
397
+
230
398
 
231
399
  if (parseOutput) {
232
400
  parse(response)
233
401
  success()
234
402
  }
403
+
235
404
  return response;
236
405
  }
237
406
 
238
- const healthGetQueueLogs = async ({ threshold, parseOutput = true, sdk = undefined}) => {
239
- /* @param {number} threshold */
407
+ /**
408
+ * @typedef {Object} HealthGetQueueLogsRequestParams
409
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
410
+ * @property {boolean} parseOutput
411
+ * @property {libClient | undefined} sdk
412
+ */
240
413
 
414
+ /**
415
+ * @param {HealthGetQueueLogsRequestParams} params
416
+ */
417
+ const healthGetQueueLogs = async ({ threshold, parseOutput = true, sdk = undefined}) => {
241
418
  let client = !sdk ? await sdkForProject() : sdk;
419
+
242
420
  let apiPath = '/health/queue/logs';
243
421
  let payload = {};
244
-
245
- /** Query Params */
246
422
  if (typeof threshold !== 'undefined') {
247
423
  payload['threshold'] = threshold;
248
424
  }
425
+
426
+
249
427
  let response = undefined;
428
+
250
429
  response = await client.call('get', apiPath, {
251
430
  'content-type': 'application/json',
252
431
  }, payload);
432
+
253
433
 
254
434
  if (parseOutput) {
255
435
  parse(response)
256
436
  success()
257
437
  }
438
+
258
439
  return response;
259
440
  }
260
441
 
261
- const healthGetQueueMails = async ({ threshold, parseOutput = true, sdk = undefined}) => {
262
- /* @param {number} threshold */
442
+ /**
443
+ * @typedef {Object} HealthGetQueueMailsRequestParams
444
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
445
+ * @property {boolean} parseOutput
446
+ * @property {libClient | undefined} sdk
447
+ */
263
448
 
449
+ /**
450
+ * @param {HealthGetQueueMailsRequestParams} params
451
+ */
452
+ const healthGetQueueMails = async ({ threshold, parseOutput = true, sdk = undefined}) => {
264
453
  let client = !sdk ? await sdkForProject() : sdk;
454
+
265
455
  let apiPath = '/health/queue/mails';
266
456
  let payload = {};
267
-
268
- /** Query Params */
269
457
  if (typeof threshold !== 'undefined') {
270
458
  payload['threshold'] = threshold;
271
459
  }
460
+
461
+
272
462
  let response = undefined;
463
+
273
464
  response = await client.call('get', apiPath, {
274
465
  'content-type': 'application/json',
275
466
  }, payload);
467
+
276
468
 
277
469
  if (parseOutput) {
278
470
  parse(response)
279
471
  success()
280
472
  }
473
+
281
474
  return response;
282
475
  }
283
476
 
284
- const healthGetQueueMessaging = async ({ threshold, parseOutput = true, sdk = undefined}) => {
285
- /* @param {number} threshold */
477
+ /**
478
+ * @typedef {Object} HealthGetQueueMessagingRequestParams
479
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
480
+ * @property {boolean} parseOutput
481
+ * @property {libClient | undefined} sdk
482
+ */
286
483
 
484
+ /**
485
+ * @param {HealthGetQueueMessagingRequestParams} params
486
+ */
487
+ const healthGetQueueMessaging = async ({ threshold, parseOutput = true, sdk = undefined}) => {
287
488
  let client = !sdk ? await sdkForProject() : sdk;
489
+
288
490
  let apiPath = '/health/queue/messaging';
289
491
  let payload = {};
290
-
291
- /** Query Params */
292
492
  if (typeof threshold !== 'undefined') {
293
493
  payload['threshold'] = threshold;
294
494
  }
495
+
496
+
295
497
  let response = undefined;
498
+
296
499
  response = await client.call('get', apiPath, {
297
500
  'content-type': 'application/json',
298
501
  }, payload);
502
+
299
503
 
300
504
  if (parseOutput) {
301
505
  parse(response)
302
506
  success()
303
507
  }
508
+
304
509
  return response;
305
510
  }
306
511
 
307
- const healthGetQueueMigrations = async ({ threshold, parseOutput = true, sdk = undefined}) => {
308
- /* @param {number} threshold */
512
+ /**
513
+ * @typedef {Object} HealthGetQueueMigrationsRequestParams
514
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
515
+ * @property {boolean} parseOutput
516
+ * @property {libClient | undefined} sdk
517
+ */
309
518
 
519
+ /**
520
+ * @param {HealthGetQueueMigrationsRequestParams} params
521
+ */
522
+ const healthGetQueueMigrations = async ({ threshold, parseOutput = true, sdk = undefined}) => {
310
523
  let client = !sdk ? await sdkForProject() : sdk;
524
+
311
525
  let apiPath = '/health/queue/migrations';
312
526
  let payload = {};
313
-
314
- /** Query Params */
315
527
  if (typeof threshold !== 'undefined') {
316
528
  payload['threshold'] = threshold;
317
529
  }
530
+
531
+
318
532
  let response = undefined;
533
+
319
534
  response = await client.call('get', apiPath, {
320
535
  'content-type': 'application/json',
321
536
  }, payload);
537
+
322
538
 
323
539
  if (parseOutput) {
324
540
  parse(response)
325
541
  success()
326
542
  }
543
+
327
544
  return response;
328
545
  }
329
546
 
330
- const healthGetQueueWebhooks = async ({ threshold, parseOutput = true, sdk = undefined}) => {
331
- /* @param {number} threshold */
547
+ /**
548
+ * @typedef {Object} HealthGetQueueWebhooksRequestParams
549
+ * @property {number} threshold Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.
550
+ * @property {boolean} parseOutput
551
+ * @property {libClient | undefined} sdk
552
+ */
332
553
 
554
+ /**
555
+ * @param {HealthGetQueueWebhooksRequestParams} params
556
+ */
557
+ const healthGetQueueWebhooks = async ({ threshold, parseOutput = true, sdk = undefined}) => {
333
558
  let client = !sdk ? await sdkForProject() : sdk;
559
+
334
560
  let apiPath = '/health/queue/webhooks';
335
561
  let payload = {};
336
-
337
- /** Query Params */
338
562
  if (typeof threshold !== 'undefined') {
339
563
  payload['threshold'] = threshold;
340
564
  }
565
+
566
+
341
567
  let response = undefined;
568
+
342
569
  response = await client.call('get', apiPath, {
343
570
  'content-type': 'application/json',
344
571
  }, payload);
572
+
345
573
 
346
574
  if (parseOutput) {
347
575
  parse(response)
348
576
  success()
349
577
  }
578
+
350
579
  return response;
351
580
  }
352
581
 
353
- const healthGetStorageLocal = async ({ parseOutput = true, sdk = undefined}) => {
582
+ /**
583
+ * @typedef {Object} HealthGetStorageLocalRequestParams
584
+ * @property {boolean} parseOutput
585
+ * @property {libClient | undefined} sdk
586
+ */
354
587
 
588
+ /**
589
+ * @param {HealthGetStorageLocalRequestParams} params
590
+ */
591
+ const healthGetStorageLocal = async ({ parseOutput = true, sdk = undefined}) => {
355
592
  let client = !sdk ? await sdkForProject() : sdk;
593
+
356
594
  let apiPath = '/health/storage/local';
357
595
  let payload = {};
596
+
597
+
358
598
  let response = undefined;
599
+
359
600
  response = await client.call('get', apiPath, {
360
601
  'content-type': 'application/json',
361
602
  }, payload);
603
+
362
604
 
363
605
  if (parseOutput) {
364
606
  parse(response)
365
607
  success()
366
608
  }
609
+
367
610
  return response;
368
611
  }
369
612
 
370
- const healthGetTime = async ({ parseOutput = true, sdk = undefined}) => {
613
+ /**
614
+ * @typedef {Object} HealthGetTimeRequestParams
615
+ * @property {boolean} parseOutput
616
+ * @property {libClient | undefined} sdk
617
+ */
371
618
 
619
+ /**
620
+ * @param {HealthGetTimeRequestParams} params
621
+ */
622
+ const healthGetTime = async ({ parseOutput = true, sdk = undefined}) => {
372
623
  let client = !sdk ? await sdkForProject() : sdk;
624
+
373
625
  let apiPath = '/health/time';
374
626
  let payload = {};
627
+
628
+
375
629
  let response = undefined;
630
+
376
631
  response = await client.call('get', apiPath, {
377
632
  'content-type': 'application/json',
378
633
  }, payload);
634
+
379
635
 
380
636
  if (parseOutput) {
381
637
  parse(response)
382
638
  success()
383
639
  }
640
+
384
641
  return response;
385
642
  }
386
643
 
@@ -489,22 +746,22 @@ health
489
746
 
490
747
  module.exports = {
491
748
  health,
492
- healthGet,
493
- healthGetAntivirus,
494
- healthGetCache,
495
- healthGetDB,
496
- healthGetPubSub,
497
- healthGetQueue,
498
- healthGetQueueBuilds,
499
- healthGetQueueCertificates,
500
- healthGetQueueDatabases,
501
- healthGetQueueDeletes,
502
- healthGetQueueFunctions,
503
- healthGetQueueLogs,
504
- healthGetQueueMails,
505
- healthGetQueueMessaging,
506
- healthGetQueueMigrations,
507
- healthGetQueueWebhooks,
508
- healthGetStorageLocal,
509
- healthGetTime
510
- };
749
+ healthGet,
750
+ healthGetAntivirus,
751
+ healthGetCache,
752
+ healthGetDB,
753
+ healthGetPubSub,
754
+ healthGetQueue,
755
+ healthGetQueueBuilds,
756
+ healthGetQueueCertificates,
757
+ healthGetQueueDatabases,
758
+ healthGetQueueDeletes,
759
+ healthGetQueueFunctions,
760
+ healthGetQueueLogs,
761
+ healthGetQueueMails,
762
+ healthGetQueueMessaging,
763
+ healthGetQueueMigrations,
764
+ healthGetQueueWebhooks,
765
+ healthGetStorageLocal,
766
+ healthGetTime
767
+ };