appwrite-cli 17.0.0 → 17.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.
Files changed (98) hide show
  1. package/.github/workflows/ci.yml +1 -1
  2. package/.github/workflows/publish.yml +1 -1
  3. package/CHANGELOG.md +20 -0
  4. package/README.md +2 -2
  5. package/bun.lock +783 -0
  6. package/cli.ts +19 -1
  7. package/dist/bundle-win-arm64.mjs +1515 -744
  8. package/dist/cli.cjs +1515 -744
  9. package/dist/index.cjs +322 -118
  10. package/dist/index.js +322 -118
  11. package/dist/lib/client.d.ts +9 -0
  12. package/dist/lib/client.d.ts.map +1 -1
  13. package/dist/lib/commands/init.d.ts.map +1 -1
  14. package/dist/lib/commands/services/organizations.d.ts +3 -0
  15. package/dist/lib/commands/services/organizations.d.ts.map +1 -0
  16. package/dist/lib/commands/services/teams.d.ts.map +1 -1
  17. package/dist/lib/constants.d.ts +1 -1
  18. package/dist/lib/emulation/docker.d.ts.map +1 -1
  19. package/dist/lib/emulation/utils.d.ts.map +1 -1
  20. package/dist/lib/parser.d.ts.map +1 -1
  21. package/dist/lib/questions.d.ts.map +1 -1
  22. package/dist/lib/types.d.ts +3 -0
  23. package/dist/lib/types.d.ts.map +1 -1
  24. package/dist/lib/utils.d.ts +12 -0
  25. package/dist/lib/utils.d.ts.map +1 -1
  26. package/docs/examples/organizations/add-credit.md +5 -0
  27. package/docs/examples/organizations/cancel-downgrade.md +4 -0
  28. package/docs/examples/organizations/create-downgrade-feedback.md +8 -0
  29. package/docs/examples/organizations/create-invoice-payment.md +6 -0
  30. package/docs/examples/organizations/create-key.md +6 -0
  31. package/docs/examples/organizations/create.md +6 -0
  32. package/docs/examples/organizations/delete-backup-payment-method.md +4 -0
  33. package/docs/examples/organizations/delete-default-payment-method.md +4 -0
  34. package/docs/examples/organizations/delete-key.md +5 -0
  35. package/docs/examples/organizations/delete.md +4 -0
  36. package/docs/examples/organizations/estimation-create-organization.md +4 -0
  37. package/docs/examples/organizations/estimation-delete-organization.md +4 -0
  38. package/docs/examples/organizations/estimation-update-plan.md +5 -0
  39. package/docs/examples/organizations/get-aggregation.md +5 -0
  40. package/docs/examples/organizations/get-available-credits.md +4 -0
  41. package/docs/examples/organizations/get-credit.md +5 -0
  42. package/docs/examples/organizations/get-invoice-download.md +5 -0
  43. package/docs/examples/organizations/get-invoice-view.md +5 -0
  44. package/docs/examples/organizations/get-invoice.md +5 -0
  45. package/docs/examples/organizations/get-key.md +5 -0
  46. package/docs/examples/organizations/get-plan.md +4 -0
  47. package/docs/examples/organizations/get-scopes.md +4 -0
  48. package/docs/examples/organizations/get-usage.md +4 -0
  49. package/docs/examples/organizations/list-aggregations.md +4 -0
  50. package/docs/examples/organizations/list-credits.md +4 -0
  51. package/docs/examples/organizations/list-keys.md +4 -0
  52. package/docs/examples/organizations/list-regions.md +4 -0
  53. package/docs/examples/organizations/list.md +3 -0
  54. package/docs/examples/organizations/set-backup-payment-method.md +5 -0
  55. package/docs/examples/organizations/set-billing-address.md +5 -0
  56. package/docs/examples/organizations/set-billing-email.md +5 -0
  57. package/docs/examples/organizations/set-billing-tax-id.md +5 -0
  58. package/docs/examples/organizations/set-default-payment-method.md +5 -0
  59. package/docs/examples/organizations/update-budget.md +5 -0
  60. package/docs/examples/organizations/update-key.md +7 -0
  61. package/docs/examples/organizations/update-plan.md +5 -0
  62. package/docs/examples/organizations/validate-invoice.md +5 -0
  63. package/docs/examples/organizations/validate-payment.md +4 -0
  64. package/install.ps1 +2 -2
  65. package/install.sh +1 -1
  66. package/lib/client.ts +12 -0
  67. package/lib/commands/init.ts +109 -2
  68. package/lib/commands/services/account.ts +110 -55
  69. package/lib/commands/services/activities.ts +4 -2
  70. package/lib/commands/services/backups.ts +24 -12
  71. package/lib/commands/services/databases.ts +150 -75
  72. package/lib/commands/services/functions.ts +60 -30
  73. package/lib/commands/services/graphql.ts +4 -2
  74. package/lib/commands/services/health.ts +46 -23
  75. package/lib/commands/services/locale.ts +16 -8
  76. package/lib/commands/services/messaging.ts +96 -48
  77. package/lib/commands/services/migrations.ts +30 -16
  78. package/lib/commands/services/organizations.ts +555 -0
  79. package/lib/commands/services/project.ts +12 -6
  80. package/lib/commands/services/projects.ts +105 -53
  81. package/lib/commands/services/proxy.ts +18 -10
  82. package/lib/commands/services/sites.ts +58 -29
  83. package/lib/commands/services/storage.ts +30 -15
  84. package/lib/commands/services/tables-db.ts +148 -74
  85. package/lib/commands/services/teams.ts +38 -15
  86. package/lib/commands/services/tokens.ts +10 -5
  87. package/lib/commands/services/users.ts +88 -44
  88. package/lib/commands/services/vcs.ts +22 -12
  89. package/lib/commands/services/webhooks.ts +12 -6
  90. package/lib/constants.ts +1 -1
  91. package/lib/emulation/docker.ts +1 -0
  92. package/lib/emulation/utils.ts +3 -2
  93. package/lib/parser.ts +356 -77
  94. package/lib/questions.ts +8 -3
  95. package/lib/types.ts +3 -0
  96. package/lib/utils.ts +234 -0
  97. package/package.json +1 -1
  98. package/scoop/appwrite.config.json +3 -3
@@ -0,0 +1,555 @@
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
+ const organizationsListCommand = 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
+
42
+ const organizationsCreateCommand = organizations
43
+ .command(`create`)
44
+ .description(`Create a new organization.
45
+ `)
46
+ .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.`)
47
+ .requiredOption(`--name <name>`, `Organization name. Max length: 128 chars.`)
48
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
49
+ .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.`)
50
+ .option(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
51
+ .option(`--invites [invites...]`, `Additional member invites`)
52
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
53
+ .option(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
54
+ .option(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
55
+ .option(`--platform <platform>`, `Platform type`)
56
+ .action(
57
+ actionRunner(
58
+ async ({ organizationId, name, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget, platform }) =>
59
+ parse(await (await getOrganizationsClient()).create(organizationId, name, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget, platform)),
60
+ ),
61
+ );
62
+
63
+
64
+ const organizationsEstimationCreateOrganizationCommand = organizations
65
+ .command(`estimation-create-organization`)
66
+ .description(`Get estimation for creating an organization.`)
67
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
68
+ .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.`)
69
+ .option(`--invites [invites...]`, `Additional member invites`)
70
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
71
+ .option(`--platform <platform>`, `Platform type`)
72
+ .action(
73
+ actionRunner(
74
+ async ({ billingPlan, paymentMethodId, invites, couponId, platform }) =>
75
+ parse(await (await getOrganizationsClient()).estimationCreateOrganization(billingPlan, paymentMethodId, invites, couponId, platform)),
76
+ ),
77
+ );
78
+
79
+
80
+ const organizationsDeleteCommand = organizations
81
+ .command(`delete`)
82
+ .description(`Delete an organization.`)
83
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
84
+ .action(
85
+ actionRunner(
86
+ async ({ organizationId }) =>
87
+ parse(await (await getOrganizationsClient()).delete(organizationId)),
88
+ ),
89
+ );
90
+
91
+
92
+ const organizationsListAggregationsCommand = organizations
93
+ .command(`list-aggregations`)
94
+ .description(`Get a list of all aggregations for an organization.`)
95
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
96
+ .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`)
97
+ .action(
98
+ actionRunner(
99
+ async ({ organizationId, queries }) =>
100
+ parse(await (await getOrganizationsClient()).listAggregations(organizationId, queries)),
101
+ ),
102
+ );
103
+
104
+
105
+ const organizationsGetAggregationCommand = organizations
106
+ .command(`get-aggregation`)
107
+ .description(`Get a specific aggregation using it's aggregation ID.`)
108
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
109
+ .requiredOption(`--aggregation-id <aggregation-id>`, `Invoice unique ID`)
110
+ .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)
111
+ .option(`--offset <offset>`, `Offset value. The default value is 0. Use this param to manage pagination.`, parseInteger)
112
+ .action(
113
+ actionRunner(
114
+ async ({ organizationId, aggregationId, limit, offset }) =>
115
+ parse(await (await getOrganizationsClient()).getAggregation(organizationId, aggregationId, limit, offset)),
116
+ ),
117
+ );
118
+
119
+
120
+ const organizationsSetBillingAddressCommand = organizations
121
+ .command(`set-billing-address`)
122
+ .description(`Set a billing address for an organization.`)
123
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
124
+ .requiredOption(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
125
+ .action(
126
+ actionRunner(
127
+ async ({ organizationId, billingAddressId }) =>
128
+ parse(await (await getOrganizationsClient()).setBillingAddress(organizationId, billingAddressId)),
129
+ ),
130
+ );
131
+
132
+
133
+ const organizationsSetBillingEmailCommand = organizations
134
+ .command(`set-billing-email`)
135
+ .description(`Set the current billing email for the organization.`)
136
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
137
+ .requiredOption(`--billing-email <billing-email>`, `Billing email for the organization.`)
138
+ .action(
139
+ actionRunner(
140
+ async ({ organizationId, billingEmail }) =>
141
+ parse(await (await getOrganizationsClient()).setBillingEmail(organizationId, billingEmail)),
142
+ ),
143
+ );
144
+
145
+
146
+ const organizationsUpdateBudgetCommand = organizations
147
+ .command(`update-budget`)
148
+ .description(`Update the budget limit for an organization.`)
149
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
150
+ .requiredOption(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
151
+ .option(`--alerts [alerts...]`, `Budget alert limit percentage`)
152
+ .action(
153
+ actionRunner(
154
+ async ({ organizationId, budget, alerts }) =>
155
+ parse(await (await getOrganizationsClient()).updateBudget(organizationId, budget, alerts)),
156
+ ),
157
+ );
158
+
159
+
160
+ const organizationsListCreditsCommand = organizations
161
+ .command(`list-credits`)
162
+ .description(`List all credits for an organization.
163
+ `)
164
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
165
+ .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`)
166
+ .action(
167
+ actionRunner(
168
+ async ({ organizationId, queries }) =>
169
+ parse(await (await getOrganizationsClient()).listCredits(organizationId, queries)),
170
+ ),
171
+ );
172
+
173
+
174
+ const organizationsAddCreditCommand = organizations
175
+ .command(`add-credit`)
176
+ .description(`Add credit to an organization using a coupon.`)
177
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
178
+ .requiredOption(`--coupon-id <coupon-id>`, `ID of the coupon`)
179
+ .action(
180
+ actionRunner(
181
+ async ({ organizationId, couponId }) =>
182
+ parse(await (await getOrganizationsClient()).addCredit(organizationId, couponId)),
183
+ ),
184
+ );
185
+
186
+
187
+ const organizationsGetAvailableCreditsCommand = organizations
188
+ .command(`get-available-credits`)
189
+ .description(`Get total available valid credits for an organization.`)
190
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
191
+ .action(
192
+ actionRunner(
193
+ async ({ organizationId }) =>
194
+ parse(await (await getOrganizationsClient()).getAvailableCredits(organizationId)),
195
+ ),
196
+ );
197
+
198
+
199
+ const organizationsGetCreditCommand = organizations
200
+ .command(`get-credit`)
201
+ .description(`Get credit details.`)
202
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
203
+ .requiredOption(`--credit-id <credit-id>`, `Credit Unique ID`)
204
+ .action(
205
+ actionRunner(
206
+ async ({ organizationId, creditId }) =>
207
+ parse(await (await getOrganizationsClient()).getCredit(organizationId, creditId)),
208
+ ),
209
+ );
210
+
211
+
212
+ const organizationsEstimationDeleteOrganizationCommand = organizations
213
+ .command(`estimation-delete-organization`)
214
+ .description(`Get estimation for deleting an organization.`)
215
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
216
+ .action(
217
+ actionRunner(
218
+ async ({ organizationId }) =>
219
+ parse(await (await getOrganizationsClient()).estimationDeleteOrganization(organizationId)),
220
+ ),
221
+ );
222
+
223
+
224
+ const organizationsEstimationUpdatePlanCommand = organizations
225
+ .command(`estimation-update-plan`)
226
+ .description(`Get estimation for updating the organization plan.`)
227
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
228
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
229
+ .option(`--invites [invites...]`, `Additional member invites`)
230
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
231
+ .action(
232
+ actionRunner(
233
+ async ({ organizationId, billingPlan, invites, couponId }) =>
234
+ parse(await (await getOrganizationsClient()).estimationUpdatePlan(organizationId, billingPlan, invites, couponId)),
235
+ ),
236
+ );
237
+
238
+
239
+ const organizationsCreateDowngradeFeedbackCommand = organizations
240
+ .command(`create-downgrade-feedback`)
241
+ .description(`Submit feedback about downgrading from a paid plan to a lower tier. This helps the team understand user experience and improve the platform.
242
+ `)
243
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
244
+ .requiredOption(`--reason <reason>`, `Feedback reason`)
245
+ .requiredOption(`--message <message>`, `Feedback message`)
246
+ .requiredOption(`--from-plan-id <from-plan-id>`, `Plan downgrading from`)
247
+ .requiredOption(`--to-plan-id <to-plan-id>`, `Plan downgrading to`)
248
+ .action(
249
+ actionRunner(
250
+ async ({ organizationId, reason, message, fromPlanId, toPlanId }) =>
251
+ parse(await (await getOrganizationsClient()).createDowngradeFeedback(organizationId, reason, message, fromPlanId, toPlanId)),
252
+ ),
253
+ );
254
+
255
+
256
+ const organizationsGetInvoiceCommand = organizations
257
+ .command(`get-invoice`)
258
+ .description(`Get an invoice by its unique ID.`)
259
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
260
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
261
+ .action(
262
+ actionRunner(
263
+ async ({ organizationId, invoiceId }) =>
264
+ parse(await (await getOrganizationsClient()).getInvoice(organizationId, invoiceId)),
265
+ ),
266
+ );
267
+
268
+
269
+ const organizationsGetInvoiceDownloadCommand = organizations
270
+ .command(`get-invoice-download`)
271
+ .description(`Download invoice in PDF`)
272
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
273
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
274
+ .action(
275
+ actionRunner(
276
+ async ({ organizationId, invoiceId }) =>
277
+ parse(await (await getOrganizationsClient()).getInvoiceDownload(organizationId, invoiceId)),
278
+ ),
279
+ );
280
+
281
+
282
+ const organizationsCreateInvoicePaymentCommand = organizations
283
+ .command(`create-invoice-payment`)
284
+ .description(`Initiate payment for failed invoice to pay live from console`)
285
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
286
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
287
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Payment method ID`)
288
+ .action(
289
+ actionRunner(
290
+ async ({ organizationId, invoiceId, paymentMethodId }) =>
291
+ parse(await (await getOrganizationsClient()).createInvoicePayment(organizationId, invoiceId, paymentMethodId)),
292
+ ),
293
+ );
294
+
295
+
296
+ const organizationsValidateInvoiceCommand = organizations
297
+ .command(`validate-invoice`)
298
+ .description(`Validates the payment linked with the invoice and updates the invoice status if the payment status is changed.`)
299
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
300
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
301
+ .action(
302
+ actionRunner(
303
+ async ({ organizationId, invoiceId }) =>
304
+ parse(await (await getOrganizationsClient()).validateInvoice(organizationId, invoiceId)),
305
+ ),
306
+ );
307
+
308
+
309
+ const organizationsGetInvoiceViewCommand = organizations
310
+ .command(`get-invoice-view`)
311
+ .description(`View invoice in PDF`)
312
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
313
+ .requiredOption(`--invoice-id <invoice-id>`, `Invoice unique ID`)
314
+ .action(
315
+ actionRunner(
316
+ async ({ organizationId, invoiceId }) =>
317
+ parse(await (await getOrganizationsClient()).getInvoiceView(organizationId, invoiceId)),
318
+ ),
319
+ );
320
+
321
+
322
+ const organizationsListKeysCommand = organizations
323
+ .command(`list-keys`)
324
+ .description(`Get a list of all API keys from the current organization. `)
325
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
326
+ .option(
327
+ `--total [value]`,
328
+ `When set to false, the total count returned will be 0 and will not be calculated.`,
329
+ (value: string | undefined) =>
330
+ value === undefined ? true : parseBool(value),
331
+ )
332
+ .action(
333
+ actionRunner(
334
+ async ({ organizationId, total }) =>
335
+ parse(await (await getOrganizationsClient()).listKeys(organizationId, total)),
336
+ ),
337
+ );
338
+
339
+
340
+ const organizationsCreateKeyCommand = organizations
341
+ .command(`create-key`)
342
+ .description(`Create a new organization API key.`)
343
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
344
+ .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
345
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`)
346
+ .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.`)
347
+ .action(
348
+ actionRunner(
349
+ async ({ organizationId, name, scopes, expire }) =>
350
+ parse(await (await getOrganizationsClient()).createKey(organizationId, name, scopes, expire)),
351
+ ),
352
+ );
353
+
354
+
355
+ const organizationsGetKeyCommand = organizations
356
+ .command(`get-key`)
357
+ .description(`Get a key by its unique ID. This endpoint returns details about a specific API key in your organization including it's scopes.`)
358
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
359
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
360
+ .action(
361
+ actionRunner(
362
+ async ({ organizationId, keyId }) =>
363
+ parse(await (await getOrganizationsClient()).getKey(organizationId, keyId)),
364
+ ),
365
+ );
366
+
367
+
368
+ const organizationsUpdateKeyCommand = organizations
369
+ .command(`update-key`)
370
+ .description(`Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key.`)
371
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
372
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
373
+ .requiredOption(`--name <name>`, `Key name. Max length: 128 chars.`)
374
+ .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`)
375
+ .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.`)
376
+ .action(
377
+ actionRunner(
378
+ async ({ organizationId, keyId, name, scopes, expire }) =>
379
+ parse(await (await getOrganizationsClient()).updateKey(organizationId, keyId, name, scopes, expire)),
380
+ ),
381
+ );
382
+
383
+
384
+ const organizationsDeleteKeyCommand = organizations
385
+ .command(`delete-key`)
386
+ .description(`Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls.`)
387
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
388
+ .requiredOption(`--key-id <key-id>`, `Key unique ID.`)
389
+ .action(
390
+ actionRunner(
391
+ async ({ organizationId, keyId }) =>
392
+ parse(await (await getOrganizationsClient()).deleteKey(organizationId, keyId)),
393
+ ),
394
+ );
395
+
396
+
397
+ const organizationsSetDefaultPaymentMethodCommand = organizations
398
+ .command(`set-default-payment-method`)
399
+ .description(`Set a organization's default payment method.`)
400
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
401
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Unique ID of payment method`)
402
+ .action(
403
+ actionRunner(
404
+ async ({ organizationId, paymentMethodId }) =>
405
+ parse(await (await getOrganizationsClient()).setDefaultPaymentMethod(organizationId, paymentMethodId)),
406
+ ),
407
+ );
408
+
409
+
410
+ const organizationsDeleteDefaultPaymentMethodCommand = organizations
411
+ .command(`delete-default-payment-method`)
412
+ .description(`Delete the default payment method for an organization.`)
413
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
414
+ .action(
415
+ actionRunner(
416
+ async ({ organizationId }) =>
417
+ parse(await (await getOrganizationsClient()).deleteDefaultPaymentMethod(organizationId)),
418
+ ),
419
+ );
420
+
421
+
422
+ const organizationsSetBackupPaymentMethodCommand = organizations
423
+ .command(`set-backup-payment-method`)
424
+ .description(`Set an organization's backup payment method.
425
+ `)
426
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
427
+ .requiredOption(`--payment-method-id <payment-method-id>`, `Unique ID of payment method`)
428
+ .action(
429
+ actionRunner(
430
+ async ({ organizationId, paymentMethodId }) =>
431
+ parse(await (await getOrganizationsClient()).setBackupPaymentMethod(organizationId, paymentMethodId)),
432
+ ),
433
+ );
434
+
435
+
436
+ const organizationsDeleteBackupPaymentMethodCommand = organizations
437
+ .command(`delete-backup-payment-method`)
438
+ .description(`Delete a backup payment method for an organization.`)
439
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
440
+ .action(
441
+ actionRunner(
442
+ async ({ organizationId }) =>
443
+ parse(await (await getOrganizationsClient()).deleteBackupPaymentMethod(organizationId)),
444
+ ),
445
+ );
446
+
447
+
448
+ const organizationsGetPlanCommand = organizations
449
+ .command(`get-plan`)
450
+ .description(`Get the details of the current billing plan for an organization.`)
451
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
452
+ .action(
453
+ actionRunner(
454
+ async ({ organizationId }) =>
455
+ parse(await (await getOrganizationsClient()).getPlan(organizationId)),
456
+ ),
457
+ );
458
+
459
+
460
+ const organizationsUpdatePlanCommand = organizations
461
+ .command(`update-plan`)
462
+ .description(`Update the billing plan for an organization.`)
463
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
464
+ .requiredOption(`--billing-plan <billing-plan>`, `Organization billing plan chosen`)
465
+ .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.`)
466
+ .option(`--billing-address-id <billing-address-id>`, `Unique ID of billing address`)
467
+ .option(`--invites [invites...]`, `Additional member invites`)
468
+ .option(`--coupon-id <coupon-id>`, `Coupon id`)
469
+ .option(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
470
+ .option(`--budget <budget>`, `Budget limit for additional usage set for the organization`, parseInteger)
471
+ .action(
472
+ actionRunner(
473
+ async ({ organizationId, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget }) =>
474
+ parse(await (await getOrganizationsClient()).updatePlan(organizationId, billingPlan, paymentMethodId, billingAddressId, invites, couponId, taxId, budget)),
475
+ ),
476
+ );
477
+
478
+
479
+ const organizationsCancelDowngradeCommand = organizations
480
+ .command(`cancel-downgrade`)
481
+ .description(`Cancel the downgrade initiated for an organization.`)
482
+ .requiredOption(`--organization-id <organization-id>`, `Organization Unique ID`)
483
+ .action(
484
+ actionRunner(
485
+ async ({ organizationId }) =>
486
+ parse(await (await getOrganizationsClient()).cancelDowngrade(organizationId)),
487
+ ),
488
+ );
489
+
490
+
491
+ const organizationsListRegionsCommand = organizations
492
+ .command(`list-regions`)
493
+ .description(`Get all available regions for an organization.`)
494
+ .requiredOption(`--organization-id <organization-id>`, `Team ID.`)
495
+ .action(
496
+ actionRunner(
497
+ async ({ organizationId }) =>
498
+ parse(await (await getOrganizationsClient()).listRegions(organizationId)),
499
+ ),
500
+ );
501
+
502
+
503
+ const organizationsGetScopesCommand = organizations
504
+ .command(`get-scopes`)
505
+ .description(`Get Scopes`)
506
+ .requiredOption(`--organization-id <organization-id>`, `Organization id`)
507
+ .option(`--project-id <project-id>`, `Project id`)
508
+ .action(
509
+ actionRunner(
510
+ async ({ organizationId, projectId }) =>
511
+ parse(await (await getOrganizationsClient()).getScopes(organizationId, projectId)),
512
+ ),
513
+ );
514
+
515
+
516
+ const organizationsSetBillingTaxIdCommand = organizations
517
+ .command(`set-billing-tax-id`)
518
+ .description(`Set an organization's billing tax ID.`)
519
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
520
+ .requiredOption(`--tax-id <tax-id>`, `Tax Id associated to billing.`)
521
+ .action(
522
+ actionRunner(
523
+ async ({ organizationId, taxId }) =>
524
+ parse(await (await getOrganizationsClient()).setBillingTaxId(organizationId, taxId)),
525
+ ),
526
+ );
527
+
528
+
529
+ const organizationsGetUsageCommand = organizations
530
+ .command(`get-usage`)
531
+ .description(`Get the usage data for an organization.`)
532
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
533
+ .option(`--start-date <start-date>`, `Starting date for the usage`)
534
+ .option(`--end-date <end-date>`, `End date for the usage`)
535
+ .action(
536
+ actionRunner(
537
+ async ({ organizationId, startDate, endDate }) =>
538
+ parse(await (await getOrganizationsClient()).getUsage(organizationId, startDate, endDate)),
539
+ ),
540
+ );
541
+
542
+
543
+ const organizationsValidatePaymentCommand = organizations
544
+ .command(`validate-payment`)
545
+ .description(`Validate payment for team after creation or upgrade.`)
546
+ .requiredOption(`--organization-id <organization-id>`, `Organization ID`)
547
+ .option(`--invites [invites...]`, `Additional member invites`)
548
+ .action(
549
+ actionRunner(
550
+ async ({ organizationId, invites }) =>
551
+ parse(await (await getOrganizationsClient()).validatePayment(organizationId, invites)),
552
+ ),
553
+ );
554
+
555
+
@@ -26,7 +26,7 @@ export const project = new Command("project")
26
26
  helpWidth: process.stdout.columns || 80,
27
27
  });
28
28
 
29
- project
29
+ const projectGetUsageCommand = project
30
30
  .command(`get-usage`)
31
31
  .description(`Get comprehensive usage statistics for your project. View metrics including network requests, bandwidth, storage, function executions, database usage, and user activity. Specify a time range with startDate and endDate, and optionally set the data granularity with period (1h or 1d). The response includes both total counts and detailed breakdowns by resource, along with historical data over the specified period.`)
32
32
  .requiredOption(`--start-date <start-date>`, `Starting date for the usage`)
@@ -39,7 +39,8 @@ project
39
39
  ),
40
40
  );
41
41
 
42
- project
42
+
43
+ const projectListVariablesCommand = project
43
44
  .command(`list-variables`)
44
45
  .description(`Get a list of all project environment variables.`)
45
46
  .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`)
@@ -56,7 +57,8 @@ project
56
57
  ),
57
58
  );
58
59
 
59
- project
60
+
61
+ const projectCreateVariableCommand = project
60
62
  .command(`create-variable`)
61
63
  .description(`Create a new project environment variable. These variables can be accessed by all functions and sites in the project.`)
62
64
  .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.`)
@@ -75,7 +77,8 @@ project
75
77
  ),
76
78
  );
77
79
 
78
- project
80
+
81
+ const projectGetVariableCommand = project
79
82
  .command(`get-variable`)
80
83
  .description(`Get a variable by its unique ID. `)
81
84
  .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
@@ -86,7 +89,8 @@ project
86
89
  ),
87
90
  );
88
91
 
89
- project
92
+
93
+ const projectUpdateVariableCommand = project
90
94
  .command(`update-variable`)
91
95
  .description(`Update variable by its unique ID.`)
92
96
  .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
@@ -105,7 +109,8 @@ project
105
109
  ),
106
110
  );
107
111
 
108
- project
112
+
113
+ const projectDeleteVariableCommand = project
109
114
  .command(`delete-variable`)
110
115
  .description(`Delete a variable by its unique ID. `)
111
116
  .requiredOption(`--variable-id <variable-id>`, `Variable ID.`)
@@ -116,3 +121,4 @@ project
116
121
  ),
117
122
  );
118
123
 
124
+