appwrite-cli 16.0.0 → 17.1.0

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 (81) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +4 -4
  3. package/cli.ts +6 -0
  4. package/dist/bundle-win-arm64.mjs +1355 -773
  5. package/dist/cli.cjs +1327 -745
  6. package/dist/index.cjs +466 -572
  7. package/dist/index.js +494 -600
  8. package/dist/lib/commands/push.d.ts.map +1 -1
  9. package/dist/lib/commands/run.d.ts.map +1 -1
  10. package/dist/lib/commands/services/organizations.d.ts +3 -0
  11. package/dist/lib/commands/services/organizations.d.ts.map +1 -0
  12. package/dist/lib/commands/services/teams.d.ts.map +1 -1
  13. package/dist/lib/constants.d.ts +1 -1
  14. package/dist/lib/emulation/utils.d.ts.map +1 -1
  15. package/dist/lib/parser.d.ts.map +1 -1
  16. package/dist/lib/questions.d.ts.map +1 -1
  17. package/dist/lib/types.d.ts +1 -0
  18. package/dist/lib/types.d.ts.map +1 -1
  19. package/docs/examples/organizations/add-credit.md +5 -0
  20. package/docs/examples/organizations/cancel-downgrade.md +4 -0
  21. package/docs/examples/organizations/create-downgrade-feedback.md +8 -0
  22. package/docs/examples/organizations/create-invoice-payment.md +6 -0
  23. package/docs/examples/organizations/create-key.md +6 -0
  24. package/docs/examples/organizations/create.md +6 -0
  25. package/docs/examples/organizations/delete-backup-payment-method.md +4 -0
  26. package/docs/examples/organizations/delete-default-payment-method.md +4 -0
  27. package/docs/examples/organizations/delete-key.md +5 -0
  28. package/docs/examples/organizations/delete.md +4 -0
  29. package/docs/examples/organizations/estimation-create-organization.md +4 -0
  30. package/docs/examples/organizations/estimation-delete-organization.md +4 -0
  31. package/docs/examples/organizations/estimation-update-plan.md +5 -0
  32. package/docs/examples/organizations/get-aggregation.md +5 -0
  33. package/docs/examples/organizations/get-available-credits.md +4 -0
  34. package/docs/examples/organizations/get-credit.md +5 -0
  35. package/docs/examples/organizations/get-invoice-download.md +5 -0
  36. package/docs/examples/organizations/get-invoice-view.md +5 -0
  37. package/docs/examples/organizations/get-invoice.md +5 -0
  38. package/docs/examples/organizations/get-key.md +5 -0
  39. package/docs/examples/organizations/get-plan.md +4 -0
  40. package/docs/examples/organizations/get-scopes.md +4 -0
  41. package/docs/examples/organizations/get-usage.md +4 -0
  42. package/docs/examples/organizations/list-aggregations.md +4 -0
  43. package/docs/examples/organizations/list-credits.md +4 -0
  44. package/docs/examples/organizations/list-keys.md +4 -0
  45. package/docs/examples/organizations/list-regions.md +4 -0
  46. package/docs/examples/organizations/list.md +3 -0
  47. package/docs/examples/organizations/set-backup-payment-method.md +5 -0
  48. package/docs/examples/organizations/set-billing-address.md +5 -0
  49. package/docs/examples/organizations/set-billing-email.md +5 -0
  50. package/docs/examples/organizations/set-billing-tax-id.md +5 -0
  51. package/docs/examples/organizations/set-default-payment-method.md +5 -0
  52. package/docs/examples/organizations/update-budget.md +5 -0
  53. package/docs/examples/organizations/update-key.md +7 -0
  54. package/docs/examples/organizations/update-plan.md +5 -0
  55. package/docs/examples/organizations/validate-invoice.md +5 -0
  56. package/docs/examples/organizations/validate-payment.md +4 -0
  57. package/docs/examples/project/create-variable.md +1 -0
  58. package/docs/examples/project/update-variable.md +1 -2
  59. package/docs/examples/users/update-impersonator.md +5 -0
  60. package/install.ps1 +2 -2
  61. package/install.sh +1 -1
  62. package/lib/commands/push.ts +6 -24
  63. package/lib/commands/run.ts +5 -7
  64. package/lib/commands/services/account.ts +0 -169
  65. package/lib/commands/services/health.ts +0 -68
  66. package/lib/commands/services/migrations.ts +2 -2
  67. package/lib/commands/services/organizations.ts +517 -0
  68. package/lib/commands/services/project.ts +21 -12
  69. package/lib/commands/services/projects.ts +2 -14
  70. package/lib/commands/services/proxy.ts +2 -2
  71. package/lib/commands/services/teams.ts +10 -1
  72. package/lib/commands/services/users.ts +14 -1
  73. package/lib/commands/services/vcs.ts +2 -2
  74. package/lib/constants.ts +1 -1
  75. package/lib/emulation/utils.ts +3 -2
  76. package/lib/parser.ts +149 -27
  77. package/lib/questions.ts +15 -9
  78. package/lib/sdks.ts +1 -0
  79. package/lib/types.ts +1 -0
  80. package/package.json +1 -1
  81. package/scoop/appwrite.config.json +3 -3
@@ -0,0 +1,517 @@
1
+ import { Command } from "commander";
2
+ import { sdkForConsole } from "../../sdks.js";
3
+ import {
4
+ actionRunner,
5
+ commandDescriptions,
6
+ success,
7
+ parse,
8
+ parseBool,
9
+ parseInteger,
10
+ } from "../../parser.js";
11
+ import { Organizations } from "@appwrite.io/console";
12
+
13
+ let organizationsClient: Organizations | null = null;
14
+
15
+ const getOrganizationsClient = async (): Promise<Organizations> => {
16
+ if (!organizationsClient) {
17
+ const sdkClient = await sdkForConsole();
18
+ organizationsClient = new Organizations(sdkClient);
19
+ }
20
+ return organizationsClient;
21
+ };
22
+
23
+ export const organizations = new Command("organizations")
24
+ .description(commandDescriptions["organizations"] ?? "")
25
+ .configureHelp({
26
+ helpWidth: process.stdout.columns || 80,
27
+ });
28
+
29
+ organizations
30
+ .command(`list`)
31
+ .description(`Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.`)
32
+ .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: name, total, billingPlan, paymentMethodId, backupPaymentMethodId, platform`)
33
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
34
+ .action(
35
+ actionRunner(
36
+ async ({ queries, search }) =>
37
+ parse(await (await getOrganizationsClient()).list(queries, search)),
38
+ ),
39
+ );
40
+
41
+ organizations
42
+ .command(`create`)
43
+ .description(`Create a new organization.
44
+ `)
45
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
46
+ .requiredOption(`--name <name>`, `Organization name. Max length: 128 chars.`)
47
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
48
+ .option(`--payment-method-id <payment-method-id>`, `Payment method ID. Required for pro plans when trial is not available and user doesn't have default payment method set.`)
49
+ .option(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
50
+ .option(`--invites [invites...]`, `Additional member invites`)
51
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
52
+ .option(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
53
+ .option(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
54
+ .option(`--platform <platform>`, `Platform type`)
55
+ .action(
56
+ actionRunner(
57
+ async ({ organizationId, name, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget, platform }) =>
58
+ parse(await (await getOrganizationsClient()).create(organizationId, name, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget, platform)),
59
+ ),
60
+ );
61
+
62
+ organizations
63
+ .command(`estimation-create-organization`)
64
+ .description(`Get estimation for creating an organization.`)
65
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
66
+ .option(`--payment-method-id <payment-method-id>`, `Payment method ID. Required for pro plans when trial is not available and user doesn't have default payment method set.`)
67
+ .option(`--invites [invites...]`, `Additional member invites`)
68
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
69
+ .option(`--platform <platform>`, `Platform type`)
70
+ .action(
71
+ actionRunner(
72
+ async ({ billingPlan, paymentMethodId, invites, couponId, platform }) =>
73
+ parse(await (await getOrganizationsClient()).estimationCreateOrganization(billingPlan, paymentMethodId, invites, couponId, platform)),
74
+ ),
75
+ );
76
+
77
+ organizations
78
+ .command(`delete`)
79
+ .description(`Delete an organization.`)
80
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
81
+ .action(
82
+ actionRunner(
83
+ async ({ organizationId }) =>
84
+ parse(await (await getOrganizationsClient()).delete(organizationId)),
85
+ ),
86
+ );
87
+
88
+ organizations
89
+ .command(`list-aggregations`)
90
+ .description(`Get a list of all aggregations for an organization.`)
91
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
92
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: teamId, aggregationId, from, to`)
93
+ .action(
94
+ actionRunner(
95
+ async ({ organizationId, queries }) =>
96
+ parse(await (await getOrganizationsClient()).listAggregations(organizationId, queries)),
97
+ ),
98
+ );
99
+
100
+ organizations
101
+ .command(`get-aggregation`)
102
+ .description(`Get a specific aggregation using it's aggregation ID.`)
103
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
104
+ .requiredOption(`--aggregation-id <aggregation-id>`, `Invoice unique ID`)
105
+ .option(`--limit <limit>`, `Maximum number of project aggregations to return in response. By default will return maximum 5 results. Maximum of 10 results allowed per request.`, parseInteger)
106
+ .option(`--offset <offset>`, `Offset value. The default value is 0. Use this param to manage pagination.`, parseInteger)
107
+ .action(
108
+ actionRunner(
109
+ async ({ organizationId, aggregationId, limit, offset }) =>
110
+ parse(await (await getOrganizationsClient()).getAggregation(organizationId, aggregationId, limit, offset)),
111
+ ),
112
+ );
113
+
114
+ organizations
115
+ .command(`set-billing-address`)
116
+ .description(`Set a billing address for an organization.`)
117
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
118
+ .requiredOption(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
119
+ .action(
120
+ actionRunner(
121
+ async ({ organizationId, billingAddressId }) =>
122
+ parse(await (await getOrganizationsClient()).setBillingAddress(organizationId, billingAddressId)),
123
+ ),
124
+ );
125
+
126
+ organizations
127
+ .command(`set-billing-email`)
128
+ .description(`Set the current billing email for the organization.`)
129
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
130
+ .requiredOption(`--billing-email <billing-email>`, `Billing email for the organization.`)
131
+ .action(
132
+ actionRunner(
133
+ async ({ organizationId, billingEmail }) =>
134
+ parse(await (await getOrganizationsClient()).setBillingEmail(organizationId, billingEmail)),
135
+ ),
136
+ );
137
+
138
+ organizations
139
+ .command(`update-budget`)
140
+ .description(`Update the budget limit for an organization.`)
141
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
142
+ .requiredOption(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
143
+ .option(`--alerts [alerts...]`, `Budget alert limit percentage`)
144
+ .action(
145
+ actionRunner(
146
+ async ({ organizationId, budget, alerts }) =>
147
+ parse(await (await getOrganizationsClient()).updateBudget(organizationId, budget, alerts)),
148
+ ),
149
+ );
150
+
151
+ organizations
152
+ .command(`list-credits`)
153
+ .description(`List all credits for an organization.
154
+ `)
155
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
156
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/databases#querying-documents). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: teamId, couponId, credits, expiration, status`)
157
+ .action(
158
+ actionRunner(
159
+ async ({ organizationId, queries }) =>
160
+ parse(await (await getOrganizationsClient()).listCredits(organizationId, queries)),
161
+ ),
162
+ );
163
+
164
+ organizations
165
+ .command(`add-credit`)
166
+ .description(`Add credit to an organization using a coupon.`)
167
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
168
+ .requiredOption(`--coupon-id <coupon-id>`, `ID of the coupon`)
169
+ .action(
170
+ actionRunner(
171
+ async ({ organizationId, couponId }) =>
172
+ parse(await (await getOrganizationsClient()).addCredit(organizationId, couponId)),
173
+ ),
174
+ );
175
+
176
+ organizations
177
+ .command(`get-available-credits`)
178
+ .description(`Get total available valid credits for an organization.`)
179
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
180
+ .action(
181
+ actionRunner(
182
+ async ({ organizationId }) =>
183
+ parse(await (await getOrganizationsClient()).getAvailableCredits(organizationId)),
184
+ ),
185
+ );
186
+
187
+ organizations
188
+ .command(`get-credit`)
189
+ .description(`Get credit details.`)
190
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
191
+ .requiredOption(`--credit-id <credit-id>`, `Credit Unique ID`)
192
+ .action(
193
+ actionRunner(
194
+ async ({ organizationId, creditId }) =>
195
+ parse(await (await getOrganizationsClient()).getCredit(organizationId, creditId)),
196
+ ),
197
+ );
198
+
199
+ organizations
200
+ .command(`estimation-delete-organization`)
201
+ .description(`Get estimation for deleting an organization.`)
202
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
203
+ .action(
204
+ actionRunner(
205
+ async ({ organizationId }) =>
206
+ parse(await (await getOrganizationsClient()).estimationDeleteOrganization(organizationId)),
207
+ ),
208
+ );
209
+
210
+ organizations
211
+ .command(`estimation-update-plan`)
212
+ .description(`Get estimation for updating the organization plan.`)
213
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
214
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
215
+ .option(`--invites [invites...]`, `Additional member invites`)
216
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
217
+ .action(
218
+ actionRunner(
219
+ async ({ organizationId, billingPlan, invites, couponId }) =>
220
+ parse(await (await getOrganizationsClient()).estimationUpdatePlan(organizationId, billingPlan, invites, couponId)),
221
+ ),
222
+ );
223
+
224
+ organizations
225
+ .command(`create-downgrade-feedback`)
226
+ .description(`Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform.
227
+ `)
228
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
229
+ .requiredOption(`--reason <reason>`, `Feedback reason`)
230
+ .requiredOption(`--message <message>`, `Feedback message`)
231
+ .requiredOption(`--from-plan-id <from-plan-id>`, `Plan downgrading from`)
232
+ .requiredOption(`--to-plan-id <to-plan-id>`, `Plan downgrading to`)
233
+ .action(
234
+ actionRunner(
235
+ async ({ organizationId, reason, message, fromPlanId, toPlanId }) =>
236
+ parse(await (await getOrganizationsClient()).createDowngradeFeedback(organizationId, reason, message, fromPlanId, toPlanId)),
237
+ ),
238
+ );
239
+
240
+ organizations
241
+ .command(`get-invoice`)
242
+ .description(`Get an invoice by its unique ID.`)
243
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
244
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
245
+ .action(
246
+ actionRunner(
247
+ async ({ organizationId, invoiceId }) =>
248
+ parse(await (await getOrganizationsClient()).getInvoice(organizationId, invoiceId)),
249
+ ),
250
+ );
251
+
252
+ organizations
253
+ .command(`get-invoice-download`)
254
+ .description(`Download invoice in PDF`)
255
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
256
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
257
+ .action(
258
+ actionRunner(
259
+ async ({ organizationId, invoiceId }) =>
260
+ parse(await (await getOrganizationsClient()).getInvoiceDownload(organizationId, invoiceId)),
261
+ ),
262
+ );
263
+
264
+ organizations
265
+ .command(`create-invoice-payment`)
266
+ .description(`Initiate payment for failed invoice to pay live from console`)
267
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
268
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
269
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Payment method ID`)
270
+ .action(
271
+ actionRunner(
272
+ async ({ organizationId, invoiceId, paymentMethodId }) =>
273
+ parse(await (await getOrganizationsClient()).createInvoicePayment(organizationId, invoiceId, paymentMethodId)),
274
+ ),
275
+ );
276
+
277
+ organizations
278
+ .command(`validate-invoice`)
279
+ .description(`Validates the payment linked with the invoice and updates the invoice status if the payment status is changed.`)
280
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
281
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
282
+ .action(
283
+ actionRunner(
284
+ async ({ organizationId, invoiceId }) =>
285
+ parse(await (await getOrganizationsClient()).validateInvoice(organizationId, invoiceId)),
286
+ ),
287
+ );
288
+
289
+ organizations
290
+ .command(`get-invoice-view`)
291
+ .description(`View invoice in PDF`)
292
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
293
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
294
+ .action(
295
+ actionRunner(
296
+ async ({ organizationId, invoiceId }) =>
297
+ parse(await (await getOrganizationsClient()).getInvoiceView(organizationId, invoiceId)),
298
+ ),
299
+ );
300
+
301
+ organizations
302
+ .command(`list-keys`)
303
+ .description(`Get a list of all API keys from the current organization. `)
304
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
305
+ .option(
306
+ `--total [value]`,
307
+ `When set to false, the total count returned will be 0 and will not be calculated.`,
308
+ (value: string | undefined) =>
309
+ value === undefined ? true : parseBool(value),
310
+ )
311
+ .action(
312
+ actionRunner(
313
+ async ({ organizationId, total }) =>
314
+ parse(await (await getOrganizationsClient()).listKeys(organizationId, total)),
315
+ ),
316
+ );
317
+
318
+ organizations
319
+ .command(`create-key`)
320
+ .description(`Create a new organization API key.`)
321
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
322
+ .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
323
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`)
324
+ .option(`--expire <expire>`, `Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.`)
325
+ .action(
326
+ actionRunner(
327
+ async ({ organizationId, name, scopes, expire }) =>
328
+ parse(await (await getOrganizationsClient()).createKey(organizationId, name, scopes, expire)),
329
+ ),
330
+ );
331
+
332
+ organizations
333
+ .command(`get-key`)
334
+ .description(`Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including it's scopes.`)
335
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
336
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
337
+ .action(
338
+ actionRunner(
339
+ async ({ organizationId, keyId }) =>
340
+ parse(await (await getOrganizationsClient()).getKey(organizationId, keyId)),
341
+ ),
342
+ );
343
+
344
+ organizations
345
+ .command(`update-key`)
346
+ .description(`Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key.`)
347
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
348
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
349
+ .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
350
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`)
351
+ .option(`--expire <expire>`, `Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.`)
352
+ .action(
353
+ actionRunner(
354
+ async ({ organizationId, keyId, name, scopes, expire }) =>
355
+ parse(await (await getOrganizationsClient()).updateKey(organizationId, keyId, name, scopes, expire)),
356
+ ),
357
+ );
358
+
359
+ organizations
360
+ .command(`delete-key`)
361
+ .description(`Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls.`)
362
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
363
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
364
+ .action(
365
+ actionRunner(
366
+ async ({ organizationId, keyId }) =>
367
+ parse(await (await getOrganizationsClient()).deleteKey(organizationId, keyId)),
368
+ ),
369
+ );
370
+
371
+ organizations
372
+ .command(`set-default-payment-method`)
373
+ .description(`Set a organization's default payment method.`)
374
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
375
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Unique ID of payment method`)
376
+ .action(
377
+ actionRunner(
378
+ async ({ organizationId, paymentMethodId }) =>
379
+ parse(await (await getOrganizationsClient()).setDefaultPaymentMethod(organizationId, paymentMethodId)),
380
+ ),
381
+ );
382
+
383
+ organizations
384
+ .command(`delete-default-payment-method`)
385
+ .description(`Delete the default payment method for an organization.`)
386
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
387
+ .action(
388
+ actionRunner(
389
+ async ({ organizationId }) =>
390
+ parse(await (await getOrganizationsClient()).deleteDefaultPaymentMethod(organizationId)),
391
+ ),
392
+ );
393
+
394
+ organizations
395
+ .command(`set-backup-payment-method`)
396
+ .description(`Set an organization's backup payment method.
397
+ `)
398
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
399
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Unique ID of payment method`)
400
+ .action(
401
+ actionRunner(
402
+ async ({ organizationId, paymentMethodId }) =>
403
+ parse(await (await getOrganizationsClient()).setBackupPaymentMethod(organizationId, paymentMethodId)),
404
+ ),
405
+ );
406
+
407
+ organizations
408
+ .command(`delete-backup-payment-method`)
409
+ .description(`Delete a backup payment method for an organization.`)
410
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
411
+ .action(
412
+ actionRunner(
413
+ async ({ organizationId }) =>
414
+ parse(await (await getOrganizationsClient()).deleteBackupPaymentMethod(organizationId)),
415
+ ),
416
+ );
417
+
418
+ organizations
419
+ .command(`get-plan`)
420
+ .description(`Get the details of the current billing plan for an organization.`)
421
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
422
+ .action(
423
+ actionRunner(
424
+ async ({ organizationId }) =>
425
+ parse(await (await getOrganizationsClient()).getPlan(organizationId)),
426
+ ),
427
+ );
428
+
429
+ organizations
430
+ .command(`update-plan`)
431
+ .description(`Update the billing plan for an organization.`)
432
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
433
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
434
+ .option(`--payment-method-id <payment-method-id>`, `Payment method ID. Required for pro plans when trial is not available and user doesn't have default payment method set.`)
435
+ .option(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
436
+ .option(`--invites [invites...]`, `Additional member invites`)
437
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
438
+ .option(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
439
+ .option(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
440
+ .action(
441
+ actionRunner(
442
+ async ({ organizationId, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget }) =>
443
+ parse(await (await getOrganizationsClient()).updatePlan(organizationId, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget)),
444
+ ),
445
+ );
446
+
447
+ organizations
448
+ .command(`cancel-downgrade`)
449
+ .description(`Cancel the downgrade initiated for an organization.`)
450
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
451
+ .action(
452
+ actionRunner(
453
+ async ({ organizationId }) =>
454
+ parse(await (await getOrganizationsClient()).cancelDowngrade(organizationId)),
455
+ ),
456
+ );
457
+
458
+ organizations
459
+ .command(`list-regions`)
460
+ .description(`Get all available regions for an organization.`)
461
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
462
+ .action(
463
+ actionRunner(
464
+ async ({ organizationId }) =>
465
+ parse(await (await getOrganizationsClient()).listRegions(organizationId)),
466
+ ),
467
+ );
468
+
469
+ organizations
470
+ .command(`get-scopes`)
471
+ .description(`Get Scopes`)
472
+ .requiredOption(`--organization-id <organization-id>`, `Organization id`)
473
+ .option(`--project-id <project-id>`, `Project id`)
474
+ .action(
475
+ actionRunner(
476
+ async ({ organizationId, projectId }) =>
477
+ parse(await (await getOrganizationsClient()).getScopes(organizationId, projectId)),
478
+ ),
479
+ );
480
+
481
+ organizations
482
+ .command(`set-billing-tax-id`)
483
+ .description(`Set an organization's billing tax ID.`)
484
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
485
+ .requiredOption(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
486
+ .action(
487
+ actionRunner(
488
+ async ({ organizationId, taxId }) =>
489
+ parse(await (await getOrganizationsClient()).setBillingTaxId(organizationId, taxId)),
490
+ ),
491
+ );
492
+
493
+ organizations
494
+ .command(`get-usage`)
495
+ .description(`Get the usage data for an organization.`)
496
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
497
+ .option(`--start-date <start-date>`, `Starting date for the usage`)
498
+ .option(`--end-date <end-date>`, `End date for the usage`)
499
+ .action(
500
+ actionRunner(
501
+ async ({ organizationId, startDate, endDate }) =>
502
+ parse(await (await getOrganizationsClient()).getUsage(organizationId, startDate, endDate)),
503
+ ),
504
+ );
505
+
506
+ organizations
507
+ .command(`validate-payment`)
508
+ .description(`Validate payment for team after creation or upgrade.`)
509
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
510
+ .option(`--invites [invites...]`, `Additional member invites`)
511
+ .action(
512
+ actionRunner(
513
+ async ({ organizationId, invites }) =>
514
+ parse(await (await getOrganizationsClient()).validatePayment(organizationId, invites)),
515
+ ),
516
+ );
517
+
@@ -41,16 +41,25 @@ project
41
41
 
42
42
  project
43
43
  .command(`list-variables`)
44
- .description(`Get a list of all project variables. These variables will be accessible in all Appwrite Functions at runtime.`)
44
+ .description(`Get a list of all project environment variables.`)
45
+ .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: key, resourceType, resourceId, secret`)
46
+ .option(
47
+ `--total [value]`,
48
+ `When set to false, the total count returned will be 0 and will not be calculated.`,
49
+ (value: string | undefined) =>
50
+ value === undefined ? true : parseBool(value),
51
+ )
45
52
  .action(
46
53
  actionRunner(
47
- async () => parse(await (await getProjectClient()).listVariables()),
54
+ async ({ queries, total }) =>
55
+ parse(await (await getProjectClient()).listVariables(queries, total)),
48
56
  ),
49
57
  );
50
58
 
51
59
  project
52
60
  .command(`create-variable`)
53
- .description(`Create a new project variable. This variable will be accessible in all Appwrite Functions at runtime.`)
61
+ .description(`Create a new project environment variable. These variables can be accessed by all functions and sites in the project.`)
62
+ .requiredOption(`--variable-id <variable-id>`, `Variable ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
54
63
  .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
55
64
  .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
56
65
  .option(
@@ -61,15 +70,15 @@ project
61
70
  )
62
71
  .action(
63
72
  actionRunner(
64
- async ({ key, value, secret }) =>
65
- parse(await (await getProjectClient()).createVariable(key, value, secret)),
73
+ async ({ variableId, key, value, secret }) =>
74
+ parse(await (await getProjectClient()).createVariable(variableId, key, value, secret)),
66
75
  ),
67
76
  );
68
77
 
69
78
  project
70
79
  .command(`get-variable`)
71
- .description(`Get a project variable by its unique ID.`)
72
- .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
80
+ .description(`Get a variable by its unique ID. `)
81
+ .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
73
82
  .action(
74
83
  actionRunner(
75
84
  async ({ variableId }) =>
@@ -79,9 +88,9 @@ project
79
88
 
80
89
  project
81
90
  .command(`update-variable`)
82
- .description(`Update project variable by its unique ID. This variable will be accessible in all Appwrite Functions at runtime.`)
83
- .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
84
- .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
91
+ .description(`Update variable by its unique ID.`)
92
+ .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
93
+ .option(`--key <key>`, `Variable key. Max length: 255 chars.`)
85
94
  .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
86
95
  .option(
87
96
  `--secret [value]`,
@@ -98,8 +107,8 @@ project
98
107
 
99
108
  project
100
109
  .command(`delete-variable`)
101
- .description(`Delete a project variable by its unique ID. `)
102
- .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
110
+ .description(`Delete a variable by its unique ID. `)
111
+ .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
103
112
  .action(
104
113
  actionRunner(
105
114
  async ({ variableId }) =>
@@ -1,5 +1,5 @@
1
1
  import { Command } from "commander";
2
- import { sdkForProject } from "../../sdks.js";
2
+ import { sdkForConsole } from "../../sdks.js";
3
3
  import {
4
4
  actionRunner,
5
5
  commandDescriptions,
@@ -14,7 +14,7 @@ let projectsClient: Projects | null = null;
14
14
 
15
15
  const getProjectsClient = async (): Promise<Projects> => {
16
16
  if (!projectsClient) {
17
- const sdkClient = await sdkForProject();
17
+ const sdkClient = await sdkForConsole();
18
18
  projectsClient = new Projects(sdkClient);
19
19
  }
20
20
  return projectsClient;
@@ -270,18 +270,6 @@ projects
270
270
  ),
271
271
  );
272
272
 
273
- projects
274
- .command(`update-console-access`)
275
- .description(`Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity.
276
- `)
277
- .requiredOption(`--project-id <project-id>`, `Project ID`)
278
- .action(
279
- actionRunner(
280
- async ({ projectId }) =>
281
- parse(await (await getProjectsClient()).updateConsoleAccess(projectId)),
282
- ),
283
- );
284
-
285
273
  projects
286
274
  .command(`list-dev-keys`)
287
275
  .description(`List all the project\'s dev keys. Dev keys are project specific and allow you to bypass rate limits and get better error logging during development.'`)
@@ -1,5 +1,5 @@
1
1
  import { Command } from "commander";
2
- import { sdkForProject } from "../../sdks.js";
2
+ import { sdkForConsole } from "../../sdks.js";
3
3
  import {
4
4
  actionRunner,
5
5
  commandDescriptions,
@@ -14,7 +14,7 @@ let proxyClient: Proxy | null = null;
14
14
 
15
15
  const getProxyClient = async (): Promise<Proxy> => {
16
16
  if (!proxyClient) {
17
- const sdkClient = await sdkForProject();
17
+ const sdkClient = await sdkForConsole();
18
18
  proxyClient = new Proxy(sdkClient);
19
19
  }
20
20
  return proxyClient;
@@ -7,6 +7,7 @@ import {
7
7
  parse,
8
8
  parseBool,
9
9
  parseInteger,
10
+ hint,
10
11
  } from "../../parser.js";
11
12
  import { Teams } from "@appwrite.io/console";
12
13
 
@@ -14,7 +15,15 @@ let teamsClient: Teams | null = null;
14
15
 
15
16
  const getTeamsClient = async (): Promise<Teams> => {
16
17
  if (!teamsClient) {
17
- const sdkClient = await sdkForProject();
18
+ let sdkClient;
19
+ try {
20
+ sdkClient = await sdkForProject();
21
+ } catch (e) {
22
+ if (e instanceof Error && e.message.includes("Project is not set")) {
23
+ hint(`To manage console-level teams, use the 'organizations' command instead.`);
24
+ }
25
+ throw e;
26
+ }
18
27
  teamsClient = new Teams(sdkClient);
19
28
  }
20
29
  return teamsClient;