diff --git a/CHANGELOG.md b/CHANGELOG.md index 017d282..f5afc2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,28 +1,5 @@ # Change Log -## 14.0.0 - -* Breaking: Changed createDeployment signature; activate option now optional with default true; parameter order updated -* Added TTL option for cached query results in listDocuments and listRows -* Added get-console-pausing health status command -* Added project management commands: update-console-access and update-status -* Updated site deployment docs to reflect new activate option -* Updated role length limit for teams to 81 characters -* Added appwriteImportSource and importExtension options to code generator - -## 13.6.1 - -* Fix ESLind warnings in generated files with `appwrite generate` command. - -## 13.6.0 - -* Fix large double values (e.g. `1.7976931348623157e+308`) being expanded into huge integer literals. -* Added `activities` command with `list-events` and `get-event`. -* Added `backups` command with full support for archives, policies, and restorations. -* Added account billing commands (addresses, coupons, invoices). -* Added account API key management commands. -* Added account payment method management commands (including provider and mandate updates). - ## 13.5.0 * New: Added CLI commands under projects: `list-schedules`, `create-schedule`, and `get-schedule` for managing project schedules. @@ -32,7 +9,6 @@ * Add `--queries` option to `list-keys` command * Add `--key-id` option to `create-key` command -* Add support for the new `Backups` service * Add `encrypt` param support to new string type attributes * Fix `bignumber.js` bundler conflict by removing direct dependency in favor of transitive dependency from `json-bigint` * Fix missing region in console failUrl for failed deployments diff --git a/cli.ts b/cli.ts index 9f0f803..50c54b8 100644 --- a/cli.ts +++ b/cli.ts @@ -25,8 +25,7 @@ import { update } from './lib/commands/update.js'; import { generate } from './lib/commands/generate.js'; import { account } from './lib/commands/services/account.js'; -import { activities } from './lib/commands/services/activities.js'; -import { backups } from './lib/commands/services/backups.js'; +import { console } from './lib/commands/services/console.js'; import { databases } from './lib/commands/services/databases.js'; import { functions } from './lib/commands/services/functions.js'; import { graphql } from './lib/commands/services/graphql.js'; @@ -135,8 +134,7 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) { .addCommand(generate) .addCommand(logout) .addCommand(account) - .addCommand(activities) - .addCommand(backups) + .addCommand(console) .addCommand(databases) .addCommand(functions) .addCommand(graphql) diff --git a/docs/examples/account/create-key.md b/docs/examples/account/create-key.md deleted file mode 100644 index f6ba12c..0000000 --- a/docs/examples/account/create-key.md +++ /dev/null @@ -1,5 +0,0 @@ -```bash -appwrite account create-key \ - --name \ - --scopes one two three -``` diff --git a/docs/examples/account/delete-key.md b/docs/examples/account/delete-key.md deleted file mode 100644 index 68ddaf8..0000000 --- a/docs/examples/account/delete-key.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite account delete-key \ - --key-id -``` diff --git a/docs/examples/account/get-key.md b/docs/examples/account/get-key.md deleted file mode 100644 index eb125dd..0000000 --- a/docs/examples/account/get-key.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite account get-key \ - --key-id -``` diff --git a/docs/examples/account/list-keys.md b/docs/examples/account/list-keys.md deleted file mode 100644 index 50e35f9..0000000 --- a/docs/examples/account/list-keys.md +++ /dev/null @@ -1,3 +0,0 @@ -```bash -appwrite account list-keys -``` diff --git a/docs/examples/account/update-key.md b/docs/examples/account/update-key.md deleted file mode 100644 index 197c706..0000000 --- a/docs/examples/account/update-key.md +++ /dev/null @@ -1,6 +0,0 @@ -```bash -appwrite account update-key \ - --key-id \ - --name \ - --scopes one two three -``` diff --git a/docs/examples/activities/get-event.md b/docs/examples/activities/get-event.md deleted file mode 100644 index 4d324e9..0000000 --- a/docs/examples/activities/get-event.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite activities get-event \ - --event-id -``` diff --git a/docs/examples/activities/list-events.md b/docs/examples/activities/list-events.md deleted file mode 100644 index 9fa160d..0000000 --- a/docs/examples/activities/list-events.md +++ /dev/null @@ -1,3 +0,0 @@ -```bash -appwrite activities list-events -``` diff --git a/docs/examples/backups/create-archive.md b/docs/examples/backups/create-archive.md deleted file mode 100644 index 984d4ce..0000000 --- a/docs/examples/backups/create-archive.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups create-archive \ - --services one two three -``` diff --git a/docs/examples/backups/create-policy.md b/docs/examples/backups/create-policy.md deleted file mode 100644 index 6e54a62..0000000 --- a/docs/examples/backups/create-policy.md +++ /dev/null @@ -1,7 +0,0 @@ -```bash -appwrite backups create-policy \ - --policy-id \ - --services one two three \ - --retention 1 \ - --schedule '' -``` diff --git a/docs/examples/backups/create-restoration.md b/docs/examples/backups/create-restoration.md deleted file mode 100644 index fea70a0..0000000 --- a/docs/examples/backups/create-restoration.md +++ /dev/null @@ -1,5 +0,0 @@ -```bash -appwrite backups create-restoration \ - --archive-id \ - --services one two three -``` diff --git a/docs/examples/backups/delete-archive.md b/docs/examples/backups/delete-archive.md deleted file mode 100644 index e849514..0000000 --- a/docs/examples/backups/delete-archive.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups delete-archive \ - --archive-id -``` diff --git a/docs/examples/backups/delete-policy.md b/docs/examples/backups/delete-policy.md deleted file mode 100644 index 966e457..0000000 --- a/docs/examples/backups/delete-policy.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups delete-policy \ - --policy-id -``` diff --git a/docs/examples/backups/get-archive.md b/docs/examples/backups/get-archive.md deleted file mode 100644 index e10f2d8..0000000 --- a/docs/examples/backups/get-archive.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups get-archive \ - --archive-id -``` diff --git a/docs/examples/backups/get-policy.md b/docs/examples/backups/get-policy.md deleted file mode 100644 index 5695e8a..0000000 --- a/docs/examples/backups/get-policy.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups get-policy \ - --policy-id -``` diff --git a/docs/examples/backups/get-restoration.md b/docs/examples/backups/get-restoration.md deleted file mode 100644 index c783082..0000000 --- a/docs/examples/backups/get-restoration.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups get-restoration \ - --restoration-id -``` diff --git a/docs/examples/backups/list-archives.md b/docs/examples/backups/list-archives.md deleted file mode 100644 index 81a64aa..0000000 --- a/docs/examples/backups/list-archives.md +++ /dev/null @@ -1,3 +0,0 @@ -```bash -appwrite backups list-archives -``` diff --git a/docs/examples/backups/list-policies.md b/docs/examples/backups/list-policies.md deleted file mode 100644 index 29feba3..0000000 --- a/docs/examples/backups/list-policies.md +++ /dev/null @@ -1,3 +0,0 @@ -```bash -appwrite backups list-policies -``` diff --git a/docs/examples/backups/list-restorations.md b/docs/examples/backups/list-restorations.md deleted file mode 100644 index aba2d2a..0000000 --- a/docs/examples/backups/list-restorations.md +++ /dev/null @@ -1,3 +0,0 @@ -```bash -appwrite backups list-restorations -``` diff --git a/docs/examples/backups/update-policy.md b/docs/examples/backups/update-policy.md deleted file mode 100644 index 7398094..0000000 --- a/docs/examples/backups/update-policy.md +++ /dev/null @@ -1,4 +0,0 @@ -```bash -appwrite backups update-policy \ - --policy-id -``` diff --git a/docs/examples/console/get-resource.md b/docs/examples/console/get-resource.md new file mode 100644 index 0000000..cfda823 --- /dev/null +++ b/docs/examples/console/get-resource.md @@ -0,0 +1,5 @@ +```bash +appwrite console get-resource \ + --value \ + --type rules +``` diff --git a/docs/examples/console/variables.md b/docs/examples/console/variables.md new file mode 100644 index 0000000..044ea4b --- /dev/null +++ b/docs/examples/console/variables.md @@ -0,0 +1,3 @@ +```bash +appwrite console variables +``` diff --git a/docs/examples/projects/update-status.md b/docs/examples/projects/update-status.md deleted file mode 100644 index 287957c..0000000 --- a/docs/examples/projects/update-status.md +++ /dev/null @@ -1,5 +0,0 @@ -```bash -appwrite projects update-status \ - --project-id \ - --status active -``` diff --git a/lib/commands/services/account.ts b/lib/commands/services/account.ts index 4b16105..8e41ccd 100644 --- a/lib/commands/services/account.ts +++ b/lib/commands/services/account.ts @@ -58,83 +58,6 @@ account ), ); -account - .command(`list-billing-addresses`) - .description(`List all billing addresses for a user.`) - .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: userId, expired, failed`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getAccountClient()).listBillingAddresses(queries)), - ), - ); - -account - .command(`create-billing-address`) - .description(`Add a new billing address to a user's account.`) - .requiredOption(`--country `, `Country`) - .requiredOption(`--city `, `City`) - .requiredOption(`--street-address `, `Street address`) - .option(`--address-line-2 `, `Address line 2`) - .option(`--state `, `State or province`) - .option(`--postal-code `, `Postal code`) - .action( - actionRunner( - async ({ country, city, streetAddress, addressLine2, state, postalCode }) => - parse(await (await getAccountClient()).createBillingAddress(country, city, streetAddress, addressLine2, state, postalCode)), - ), - ); - -account - .command(`get-billing-address`) - .description(`Get a specific billing address for a user using it's ID.`) - .requiredOption(`--billing-address-id `, `Unique ID of billing address`) - .action( - actionRunner( - async ({ billingAddressId }) => - parse(await (await getAccountClient()).getBillingAddress(billingAddressId)), - ), - ); - -account - .command(`update-billing-address`) - .description(`Update a specific billing address using it's ID.`) - .requiredOption(`--billing-address-id `, `Unique ID of billing address`) - .requiredOption(`--country `, `Country`) - .requiredOption(`--city `, `City`) - .requiredOption(`--street-address `, `Street address`) - .option(`--address-line-2 `, `Address line 2`) - .option(`--state `, `State or province`) - .option(`--postal-code `, `Postal code`) - .action( - actionRunner( - async ({ billingAddressId, country, city, streetAddress, addressLine2, state, postalCode }) => - parse(await (await getAccountClient()).updateBillingAddress(billingAddressId, country, city, streetAddress, addressLine2, state, postalCode)), - ), - ); - -account - .command(`delete-billing-address`) - .description(`Delete a specific billing address using it's ID.`) - .requiredOption(`--billing-address-id `, `Billing address unique ID`) - .action( - actionRunner( - async ({ billingAddressId }) => - parse(await (await getAccountClient()).deleteBillingAddress(billingAddressId)), - ), - ); - -account - .command(`get-coupon`) - .description(`Get coupon details for an account.`) - .requiredOption(`--coupon-id `, `ID of the coupon`) - .action( - actionRunner( - async ({ couponId }) => - parse(await (await getAccountClient()).getCoupon(couponId)), - ), - ); - account .command(`update-email`) .description(`Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request. @@ -177,17 +100,6 @@ account ), ); -account - .command(`list-invoices`) - .description(`List all invoices tied to an account.`) - .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, amount, currency, from, to, dueAt, attempts, status, grossAmount`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getAccountClient()).listInvoices(queries)), - ), - ); - account .command(`create-jwt`) .description(`Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.`) @@ -199,71 +111,6 @@ account ), ); -account - .command(`list-keys`) - .description(`Get a list of all API keys from the current account.`) - .option( - `--total [value]`, - `When set to false, the total count returned will be 0 and will not be calculated.`, - (value: string | undefined) => - value === undefined ? true : parseBool(value), - ) - .action( - actionRunner( - async ({ total }) => - parse(await (await getAccountClient()).listKeys(total)), - ), - ); - -account - .command(`create-key`) - .description(`Create a new account API key.`) - .requiredOption(`--name `, `Key name. Max length: 128 chars.`) - .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`) - .option(`--expire `, `Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.`) - .action( - actionRunner( - async ({ name, scopes, expire }) => - parse(await (await getAccountClient()).createKey(name, scopes, expire)), - ), - ); - -account - .command(`get-key`) - .description(`Get a key by its unique ID. This endpoint returns details about a specific API key in your account including it's scopes.`) - .requiredOption(`--key-id `, `Key unique ID.`) - .action( - actionRunner( - async ({ keyId }) => - parse(await (await getAccountClient()).getKey(keyId)), - ), - ); - -account - .command(`update-key`) - .description(`Update a key by its unique ID. Use this endpoint to update the name, scopes, or expiration time of an API key.`) - .requiredOption(`--key-id `, `Key unique ID.`) - .requiredOption(`--name `, `Key name. Max length: 128 chars.`) - .requiredOption(`--scopes [scopes...]`, `Key scopes list. Maximum of 100 scopes are allowed.`) - .option(`--expire `, `Expiration time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. Use null for unlimited expiration.`) - .action( - actionRunner( - async ({ keyId, name, scopes, expire }) => - parse(await (await getAccountClient()).updateKey(keyId, name, scopes, expire)), - ), - ); - -account - .command(`delete-key`) - .description(`Delete a key by its unique ID. Once deleted, the key can no longer be used to authenticate API calls.`) - .requiredOption(`--key-id `, `Key unique ID.`) - .action( - actionRunner( - async ({ keyId }) => - parse(await (await getAccountClient()).deleteKey(keyId)), - ), - ); - account .command(`list-logs`) .description(`Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.`) @@ -408,87 +255,6 @@ account ), ); -account - .command(`list-payment-methods`) - .description(`List payment methods for this account.`) - .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: userId, expired, failed`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getAccountClient()).listPaymentMethods(queries)), - ), - ); - -account - .command(`create-payment-method`) - .description(`Create a new payment method for the current user account.`) - .action( - actionRunner( - async () => parse(await (await getAccountClient()).createPaymentMethod()), - ), - ); - -account - .command(`get-payment-method`) - .description(`Get a specific payment method for the user.`) - .requiredOption(`--payment-method-id `, `Unique ID of payment method`) - .action( - actionRunner( - async ({ paymentMethodId }) => - parse(await (await getAccountClient()).getPaymentMethod(paymentMethodId)), - ), - ); - -account - .command(`update-payment-method`) - .description(`Update a new payment method for the current user account.`) - .requiredOption(`--payment-method-id `, `Unique ID of payment method`) - .requiredOption(`--expiry-month `, `Payment expiry month`, parseInteger) - .requiredOption(`--expiry-year `, `Expiry year`, parseInteger) - .option(`--state `, `State of the payment method country`) - .action( - actionRunner( - async ({ paymentMethodId, expiryMonth, expiryYear, state }) => - parse(await (await getAccountClient()).updatePaymentMethod(paymentMethodId, expiryMonth, expiryYear, state)), - ), - ); - -account - .command(`delete-payment-method`) - .description(`Delete a specific payment method from a user's account.`) - .requiredOption(`--payment-method-id `, `Unique ID of payment method`) - .action( - actionRunner( - async ({ paymentMethodId }) => - parse(await (await getAccountClient()).deletePaymentMethod(paymentMethodId)), - ), - ); - -account - .command(`update-payment-method-provider`) - .description(`Update payment method provider.`) - .requiredOption(`--payment-method-id `, `Unique ID of payment method`) - .requiredOption(`--provider-method-id `, `Payment method ID from the payment provider`) - .requiredOption(`--name `, `Name in the payment method`) - .option(`--state `, `State of the payment method country`) - .action( - actionRunner( - async ({ paymentMethodId, providerMethodId, name, state }) => - parse(await (await getAccountClient()).updatePaymentMethodProvider(paymentMethodId, providerMethodId, name, state)), - ), - ); - -account - .command(`update-payment-method-mandate-options`) - .description(`Update payment method mandate options.`) - .requiredOption(`--payment-method-id `, `Unique ID of payment method`) - .action( - actionRunner( - async ({ paymentMethodId }) => - parse(await (await getAccountClient()).updatePaymentMethodMandateOptions(paymentMethodId)), - ), - ); - account .command(`update-phone`) .description(`Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS.`) diff --git a/lib/commands/services/activities.ts b/lib/commands/services/activities.ts deleted file mode 100644 index 1d24280..0000000 --- a/lib/commands/services/activities.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { Command } from "commander"; -import { sdkForProject } from "../../sdks.js"; -import { - actionRunner, - commandDescriptions, - success, - parse, - parseBool, - parseInteger, -} from "../../parser.js"; -import { Activities } from "@appwrite.io/console"; - -let activitiesClient: Activities | null = null; - -const getActivitiesClient = async (): Promise => { - if (!activitiesClient) { - const sdkClient = await sdkForProject(); - activitiesClient = new Activities(sdkClient); - } - return activitiesClient; -}; - -export const activities = new Command("activities") - .description(commandDescriptions["activities"] ?? "") - .configureHelp({ - helpWidth: process.stdout.columns || 80, - }); - -activities - .command(`list-events`) - .description(`List all events for selected filters.`) - .option(`--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 attributes such as userId, teamId, etc.`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getActivitiesClient()).listEvents(queries)), - ), - ); - -activities - .command(`get-event`) - .description(`Get event by ID. -`) - .requiredOption(`--event-id `, `Event ID.`) - .action( - actionRunner( - async ({ eventId }) => - parse(await (await getActivitiesClient()).getEvent(eventId)), - ), - ); - diff --git a/lib/commands/services/backups.ts b/lib/commands/services/backups.ts deleted file mode 100644 index 69f9592..0000000 --- a/lib/commands/services/backups.ts +++ /dev/null @@ -1,184 +0,0 @@ -import { Command } from "commander"; -import { sdkForProject } from "../../sdks.js"; -import { - actionRunner, - commandDescriptions, - success, - parse, - parseBool, - parseInteger, -} from "../../parser.js"; -import { Backups } from "@appwrite.io/console"; - -let backupsClient: Backups | null = null; - -const getBackupsClient = async (): Promise => { - if (!backupsClient) { - const sdkClient = await sdkForProject(); - backupsClient = new Backups(sdkClient); - } - return backupsClient; -}; - -export const backups = new Command("backups") - .description(commandDescriptions["backups"] ?? "") - .configureHelp({ - helpWidth: process.stdout.columns || 80, - }); - -backups - .command(`list-archives`) - .description(`List all archives for a project.`) - .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.`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getBackupsClient()).listArchives(queries)), - ), - ); - -backups - .command(`create-archive`) - .description(`Create a new archive asynchronously for a project.`) - .requiredOption(`--services [services...]`, `Array of services to backup`) - .option(`--resource-id `, `Resource ID. When set, only this single resource will be backed up.`) - .action( - actionRunner( - async ({ services, resourceId }) => - parse(await (await getBackupsClient()).createArchive(services, resourceId)), - ), - ); - -backups - .command(`get-archive`) - .description(`Get a backup archive using it's ID.`) - .requiredOption(`--archive-id `, `Archive ID. Choose a custom ID\`. 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.`) - .action( - actionRunner( - async ({ archiveId }) => - parse(await (await getBackupsClient()).getArchive(archiveId)), - ), - ); - -backups - .command(`delete-archive`) - .description(`Delete an existing archive for a project.`) - .requiredOption(`--archive-id `, `Policy 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.`) - .action( - actionRunner( - async ({ archiveId }) => - parse(await (await getBackupsClient()).deleteArchive(archiveId)), - ), - ); - -backups - .command(`list-policies`) - .description(`List all policies for a project.`) - .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.`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getBackupsClient()).listPolicies(queries)), - ), - ); - -backups - .command(`create-policy`) - .description(`Create a new backup policy.`) - .requiredOption(`--policy-id `, `Policy 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.`) - .requiredOption(`--services [services...]`, `Array of services to backup`) - .requiredOption(`--retention `, `Days to keep backups before deletion`, parseInteger) - .requiredOption(`--schedule `, `Schedule CRON syntax.`) - .option(`--name `, `Policy name. Max length: 128 chars.`) - .option(`--resource-id `, `Resource ID. When set, only this single resource will be backed up.`) - .option( - `--enabled [value]`, - `Is policy enabled? When set to 'disabled', no backups will be taken`, - (value: string | undefined) => - value === undefined ? true : parseBool(value), - ) - .action( - actionRunner( - async ({ policyId, services, retention, schedule, name, resourceId, enabled }) => - parse(await (await getBackupsClient()).createPolicy(policyId, services, retention, schedule, name, resourceId, enabled)), - ), - ); - -backups - .command(`get-policy`) - .description(`Get a backup policy using it's ID.`) - .requiredOption(`--policy-id `, `Policy ID. Choose a custom ID\`. 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.`) - .action( - actionRunner( - async ({ policyId }) => - parse(await (await getBackupsClient()).getPolicy(policyId)), - ), - ); - -backups - .command(`update-policy`) - .description(`Update an existing policy using it's ID.`) - .requiredOption(`--policy-id `, `Policy ID. Choose a custom ID\`. 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.`) - .option(`--name `, `Policy name. Max length: 128 chars.`) - .option(`--retention `, `Days to keep backups before deletion`, parseInteger) - .option(`--schedule `, `Cron expression`) - .option( - `--enabled [value]`, - `Is Backup enabled? When set to 'disabled', No backup will be taken`, - (value: string | undefined) => - value === undefined ? true : parseBool(value), - ) - .action( - actionRunner( - async ({ policyId, name, retention, schedule, enabled }) => - parse(await (await getBackupsClient()).updatePolicy(policyId, name, retention, schedule, enabled)), - ), - ); - -backups - .command(`delete-policy`) - .description(`Delete a policy using it's ID.`) - .requiredOption(`--policy-id `, `Policy 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.`) - .action( - actionRunner( - async ({ policyId }) => - parse(await (await getBackupsClient()).deletePolicy(policyId)), - ), - ); - -backups - .command(`create-restoration`) - .description(`Create and trigger a new restoration for a backup on a project.`) - .requiredOption(`--archive-id `, `Backup archive ID to restore`) - .requiredOption(`--services [services...]`, `Array of services to restore`) - .option(`--new-resource-id `, `Unique 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.`) - .option(`--new-resource-name `, `Database name. Max length: 128 chars.`) - .action( - actionRunner( - async ({ archiveId, services, newResourceId, newResourceName }) => - parse(await (await getBackupsClient()).createRestoration(archiveId, services, newResourceId, newResourceName)), - ), - ); - -backups - .command(`list-restorations`) - .description(`List all backup restorations for a project.`) - .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.`) - .action( - actionRunner( - async ({ queries }) => - parse(await (await getBackupsClient()).listRestorations(queries)), - ), - ); - -backups - .command(`get-restoration`) - .description(`Get the current status of a backup restoration.`) - .requiredOption(`--restoration-id `, `Restoration ID. Choose a custom ID\`. 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.`) - .action( - actionRunner( - async ({ restorationId }) => - parse(await (await getBackupsClient()).getRestoration(restorationId)), - ), - ); - diff --git a/lib/commands/services/console.ts b/lib/commands/services/console.ts new file mode 100644 index 0000000..c45efda --- /dev/null +++ b/lib/commands/services/console.ts @@ -0,0 +1,49 @@ +import { Command } from "commander"; +import { sdkForProject } from "../../sdks.js"; +import { + actionRunner, + commandDescriptions, + success, + parse, + parseBool, + parseInteger, +} from "../../parser.js"; +import { Console } from "@appwrite.io/console"; + +let consoleClient: Console | null = null; + +const getConsoleClient = async (): Promise => { + if (!consoleClient) { + const sdkClient = await sdkForProject(); + consoleClient = new Console(sdkClient); + } + return consoleClient; +}; + +export const console = new Command("console") + .description(commandDescriptions["console"] ?? "") + .configureHelp({ + helpWidth: process.stdout.columns || 80, + }); + +console + .command(`get-resource`) + .description(`Check if a resource ID is available.`) + .requiredOption(`--value `, `Resource value.`) + .requiredOption(`--type `, `Resource type.`) + .action( + actionRunner( + async ({ value, type }) => + parse(await (await getConsoleClient()).getResource(value, type)), + ), + ); + +console + .command(`variables`) + .description(`Get all Environment Variables that are relevant for the console.`) + .action( + actionRunner( + async () => parse(await (await getConsoleClient()).variables()), + ), + ); + diff --git a/lib/commands/services/health.ts b/lib/commands/services/health.ts index 794969f..4ad11ca 100644 --- a/lib/commands/services/health.ts +++ b/lib/commands/services/health.ts @@ -64,19 +64,6 @@ health ), ); -health - .command(`get-console-pausing`) - .description(`Get console pausing health status. Monitors projects approaching the pause threshold to detect potential issues with console access tracking. -`) - .option(`--threshold `, `Percentage threshold of projects approaching pause. When hit (equal or higher), endpoint returns server error. Default value is 10.`, parseInteger) - .option(`--inactivity-days `, `Number of days of inactivity before a project is paused. Should match the plan's projectInactivityDays setting. Default value is 7.`, parseInteger) - .action( - actionRunner( - async ({ threshold, inactivityDays }) => - parse(await (await getHealthClient()).getConsolePausing(threshold, inactivityDays)), - ), - ); - health .command(`get-db`) .description(`Check the Appwrite database servers are up and connection is successful.`) @@ -106,28 +93,6 @@ health ), ); -health - .command(`get-queue-billing-project-aggregation`) - .description(`Get billing project aggregation queue.`) - .option(`--threshold `, `Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.`, parseInteger) - .action( - actionRunner( - async ({ threshold }) => - parse(await (await getHealthClient()).getQueueBillingProjectAggregation(threshold)), - ), - ); - -health - .command(`get-queue-billing-team-aggregation`) - .description(`Get billing team aggregation queue.`) - .option(`--threshold `, `Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.`, parseInteger) - .action( - actionRunner( - async ({ threshold }) => - parse(await (await getHealthClient()).getQueueBillingTeamAggregation(threshold)), - ), - ); - health .command(`get-queue-builds`) .description(`Get the number of builds that are waiting to be processed in the Appwrite internal queue server.`) @@ -139,17 +104,6 @@ health ), ); -health - .command(`get-queue-priority-builds`) - .description(`Get the priority builds queue size.`) - .option(`--threshold `, `Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 500.`, parseInteger) - .action( - actionRunner( - async ({ threshold }) => - parse(await (await getHealthClient()).getQueuePriorityBuilds(threshold)), - ), - ); - health .command(`get-queue-certificates`) .description(`Get the number of certificates that are waiting to be issued against [Letsencrypt](https://letsencrypt.org/) in the Appwrite internal queue server.`) @@ -252,17 +206,6 @@ health ), ); -health - .command(`get-queue-region-manager`) - .description(`Get region manager queue.`) - .option(`--threshold `, `Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100.`, parseInteger) - .action( - actionRunner( - async ({ threshold }) => - parse(await (await getHealthClient()).getQueueRegionManager(threshold)), - ), - ); - health .command(`get-queue-stats-resources`) .description(`Get the number of metrics that are waiting to be processed in the Appwrite stats resources queue.`) @@ -285,17 +228,6 @@ health ), ); -health - .command(`get-queue-threats`) - .description(`Get threats queue.`) - .option(`--threshold `, `Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 100.`, parseInteger) - .action( - actionRunner( - async ({ threshold }) => - parse(await (await getHealthClient()).getQueueThreats(threshold)), - ), - ); - health .command(`get-queue-webhooks`) .description(`Get the number of webhooks that are waiting to be processed in the Appwrite internal queue server.`) diff --git a/lib/commands/services/projects.ts b/lib/commands/services/projects.ts index 3c4e0ac..932c6b4 100644 --- a/lib/commands/services/projects.ts +++ b/lib/commands/services/projects.ts @@ -270,18 +270,6 @@ projects ), ); -projects - .command(`update-console-access`) - .description(`Record console access to a project. This endpoint updates the last accessed timestamp for the project to track console activity. -`) - .requiredOption(`--project-id `, `Project ID`) - .action( - actionRunner( - async ({ projectId }) => - parse(await (await getProjectsClient()).updateConsoleAccess(projectId)), - ), - ); - projects .command(`list-dev-keys`) .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.'`) @@ -557,7 +545,7 @@ projects .command(`create-schedule`) .description(`Create a new schedule for a resource.`) .requiredOption(`--project-id `, `Project unique ID.`) - .requiredOption(`--resource-type `, `The resource type for the schedule. Possible values: function, execution, message, backup.`) + .requiredOption(`--resource-type `, `The resource type for the schedule. Possible values: function, execution, message.`) .requiredOption(`--resource-id `, `The resource ID to associate with this schedule.`) .requiredOption(`--schedule `, `Schedule CRON expression.`) .option( @@ -651,19 +639,6 @@ projects ), ); -projects - .command(`update-status`) - .description(`Update the status of a project. Can be used to archive/restore projects, and to restore paused projects. When restoring a paused project, the console fingerprint header must be provided and the project must not be blocked for any reason other than inactivity. -`) - .requiredOption(`--project-id `, `Project ID`) - .requiredOption(`--status `, `New status for the project`) - .action( - actionRunner( - async ({ projectId, status }) => - parse(await (await getProjectsClient()).updateStatus(projectId, status)), - ), - ); - projects .command(`update-team`) .description(`Update the team ID of a project allowing for it to be transferred to another team.`) diff --git a/lib/commands/services/storage.ts b/lib/commands/services/storage.ts index a556f61..4f09069 100644 --- a/lib/commands/services/storage.ts +++ b/lib/commands/services/storage.ts @@ -63,7 +63,7 @@ storage (value: string | undefined) => value === undefined ? true : parseBool(value), ) - .option(`--maximum-file-size `, `Maximum file size allowed in bytes. Maximum allowed value is 5GB.`, parseInteger) + .option(`--maximum-file-size `, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger) .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`) .option(`--compression `, `Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`) .option( @@ -120,7 +120,7 @@ storage (value: string | undefined) => value === undefined ? true : parseBool(value), ) - .option(`--maximum-file-size `, `Maximum file size allowed in bytes. Maximum allowed value is 5GB.`, parseInteger) + .option(`--maximum-file-size `, `Maximum file size allowed in bytes. Maximum allowed value is 30MB.`, parseInteger) .option(`--allowed-file-extensions [allowed-file-extensions...]`, `Allowed file extensions. Maximum of 100 extensions are allowed, each 64 characters long.`) .option(`--compression `, `Compression algorithm chosen for compression. Can be one of none, [gzip](https://en.wikipedia.org/wiki/Gzip), or [zstd](https://en.wikipedia.org/wiki/Zstd), For file size above 20MB compression is skipped even if it's enabled`) .option( diff --git a/package.json b/package.json index e299040..c191ef3 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "windows-arm64": "esbuild cli.ts --bundle --loader:.hbs=text --platform=node --target=node18 --format=esm --external:fsevents --outfile=dist/bundle-win-arm64.mjs && pkg dist/bundle-win-arm64.mjs -t node18-win-arm64 -o build/appwrite-cli-win-arm64.exe" }, "dependencies": { - "@appwrite.io/console": "^4.0.0", + "@appwrite.io/console": "^3.1.0", "chalk": "4.1.2", "chokidar": "^3.6.0", "cli-progress": "^3.12.0",