Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Appwrite Command Line SDK

![License](https://img.shields.io/github/license/appwrite/sdk-for-cli.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.4-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.9.5-blue.svg?style=flat-square)
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite)
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord)
Expand Down Expand Up @@ -29,7 +29,7 @@ Once the installation is complete, you can verify the install using

```sh
$ appwrite -v
21.0.0
21.1.0
```

### Install using prebuilt binaries
Expand Down Expand Up @@ -83,7 +83,7 @@ $ scoop install https://raw.githubusercontent.com/appwrite/sdk-for-cli/master/sc
Once the installation completes, you can verify your install using
```
$ appwrite -v
21.0.0
21.1.0
```

## Getting Started
Expand Down
6 changes: 6 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,17 @@ import { locale } from './lib/commands/services/locale.js';
import { messaging } from './lib/commands/services/messaging.js';
import { migrations } from './lib/commands/services/migrations.js';
import { organizations } from './lib/commands/services/organizations.js';
import { presences } from './lib/commands/services/presences.js';
import { project } from './lib/commands/services/project.js';
import { projects } from './lib/commands/services/projects.js';
import { proxy } from './lib/commands/services/proxy.js';
import { advisor } from './lib/commands/services/advisor.js';
import { sites } from './lib/commands/services/sites.js';
import { storage } from './lib/commands/services/storage.js';
import { tablesDB } from './lib/commands/services/tables-db.js';
import { teams } from './lib/commands/services/teams.js';
import { tokens } from './lib/commands/services/tokens.js';
import { usage } from './lib/commands/services/usage.js';
import { users } from './lib/commands/services/users.js';
import { vcs } from './lib/commands/services/vcs.js';
import { webhooks } from './lib/commands/services/webhooks.js';
Expand Down Expand Up @@ -215,14 +218,17 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
.addCommand(messaging)
.addCommand(migrations)
.addCommand(organizations)
.addCommand(presences)
.addCommand(project)
.addCommand(projects)
.addCommand(proxy)
.addCommand(advisor)
.addCommand(sites)
.addCommand(storage)
.addCommand(tablesDB)
.addCommand(teams)
.addCommand(tokens)
.addCommand(usage)
.addCommand(users)
.addCommand(vcs)
.addCommand(webhooks)
Expand Down
4 changes: 4 additions & 0 deletions docs/examples/advisor/delete-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite advisor delete-report \
--report-id <REPORT_ID>
```
5 changes: 5 additions & 0 deletions docs/examples/advisor/get-insight.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```bash
appwrite advisor get-insight \
--report-id <REPORT_ID> \
--insight-id <INSIGHT_ID>
```
4 changes: 4 additions & 0 deletions docs/examples/advisor/get-report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite advisor get-report \
--report-id <REPORT_ID>
```
5 changes: 5 additions & 0 deletions docs/examples/advisor/list-insights.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```bash
appwrite advisor list-insights \
--report-id <REPORT_ID> \
--limit 25
```
4 changes: 4 additions & 0 deletions docs/examples/advisor/list-reports.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite advisor list-reports \
--limit 25
```
4 changes: 4 additions & 0 deletions docs/examples/presences/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite presences delete \
--presence-id <PRESENCE_ID>
```
3 changes: 3 additions & 0 deletions docs/examples/presences/get-usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bash
appwrite presences get-usage
```
4 changes: 4 additions & 0 deletions docs/examples/presences/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite presences get \
--presence-id <PRESENCE_ID>
```
4 changes: 4 additions & 0 deletions docs/examples/presences/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite presences list \
--limit 25
```
5 changes: 5 additions & 0 deletions docs/examples/presences/update-presence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
```bash
appwrite presences update-presence \
--presence-id <PRESENCE_ID> \
--user-id <USER_ID>
```
6 changes: 6 additions & 0 deletions docs/examples/presences/upsert.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```bash
appwrite presences upsert \
--presence-id <PRESENCE_ID> \
--user-id <USER_ID> \
--status <STATUS>
```
3 changes: 3 additions & 0 deletions docs/examples/project/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bash
appwrite project get
```
4 changes: 4 additions & 0 deletions docs/examples/project/update-deny-aliased-email-policy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite project update-deny-aliased-email-policy \
--enabled false
```
4 changes: 0 additions & 4 deletions docs/examples/project/update-deny-canonical-email-policy.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/examples/projects/get.md

This file was deleted.

4 changes: 4 additions & 0 deletions docs/examples/usage/list-events.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite usage list-events \
--limit 25
```
4 changes: 4 additions & 0 deletions docs/examples/usage/list-gauges.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite usage list-gauges \
--limit 25
```
4 changes: 2 additions & 2 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# You can use "View source" of this page to see the full script.

# REPO
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/21.0.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/21.0.0/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/21.1.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/21.1.0/appwrite-cli-win-arm64.exe"

$APPWRITE_BINARY_NAME = "appwrite.exe"

Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ verifyMacOSCodeSignature() {
downloadBinary() {
echo "[2/5] Downloading executable for $OS ($ARCH) ..."

GITHUB_LATEST_VERSION="21.0.0"
GITHUB_LATEST_VERSION="21.1.0"
GITHUB_FILE="appwrite-cli-${OS}-${ARCH}"
GITHUB_URL="https://github.com/$GITHUB_REPOSITORY_NAME/releases/download/$GITHUB_LATEST_VERSION/$GITHUB_FILE"

Expand Down
129 changes: 129 additions & 0 deletions lib/commands/services/advisor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { Command } from "commander";
import {
buildQueries,
collectQueryValue,
parseDeprecatedWhereQuery,
parseFilterQuery,
} from "../utils/query.js";
import { sdkForProject } from "../../sdks.js";
import {
actionRunner,
commandDescriptions,
success,
parse,
parseBool,
parseInteger,
} from "../../parser.js";
Comment on lines +10 to +16

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 The success symbol is imported but never called in this file — every action uses parse(...) instead. Since strict mode is off this won't break the build, but it is dead code. The same pattern exists in lib/commands/services/usage.ts.

Suggested change
actionRunner,
commandDescriptions,
success,
parse,
parseBool,
parseInteger,
} from "../../parser.js";
actionRunner,
commandDescriptions,
parse,
parseBool,
parseInteger,
} from "../../parser.js";

import { Advisor } from "@appwrite.io/console";

Check failure on line 17 in lib/commands/services/advisor.ts

View workflow job for this annotation

GitHub Actions / Build Validation

Module '"@appwrite.io/console"' has no exported member 'Advisor'.

let advisorClient: Advisor | null = null;

const getAdvisorClient = async (): Promise<Advisor> => {
if (!advisorClient) {
const sdkClient = await sdkForProject();
advisorClient = new Advisor(sdkClient);
}
return advisorClient;
};

export const advisor = new Command("advisor")
.description(commandDescriptions["advisor"] ?? "")
.configureHelp({
helpWidth: process.stdout.columns || 80,
});

const advisorListReportsCommand = advisor
.command(`list-reports`)
.description(`Get a list of all the project's analyzer reports. You can use the query params to filter your results.
`)
.option(`--queries [queries...]`, `Raw Appwrite JSON query strings (legacy). Use this for advanced queries or automation; for common filtering, sorting, and pagination prefer --filter, --sort-asc, --sort-desc, --limit, and --offset. When mixed, raw --queries are sent before generated flag 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: appId, type, targetType, target, analyzedAt`)
.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),
)
.option(`--filter <expression>`, `Filter using a simple comparison expression. Repeat for multiple filters. Supports field=value, field!=value, field>value, field>=value, field<value, and field<=value.`, (value: string, previous: string[] | undefined) => collectQueryValue(parseFilterQuery(value), previous))
.option(`--where <expression>`, `Deprecated. Use --filter instead. Filter using a simple comparison expression. Repeat for multiple filters.`, (value: string, previous: string[] | undefined) => collectQueryValue(parseDeprecatedWhereQuery(value), previous))
.option(`--sort-asc <attribute>`, `Sort results by an attribute in ascending order. Repeat for multiple sort fields.`, (value: string, previous: string[] | undefined) => collectQueryValue(value, previous))
.option(`--sort-desc <attribute>`, `Sort results by an attribute in descending order. Repeat for multiple sort fields.`, (value: string, previous: string[] | undefined) => collectQueryValue(value, previous))
.option(`--limit <limit>`, `Maximum number of results to return.`, parseInteger)
.option(`--offset <offset>`, `Number of results to skip.`, parseInteger)
.option(`--cursor-after <id>`, `Return results after this cursor ID.`)
.option(`--cursor-before <id>`, `Return results before this cursor ID.`)
.action(
actionRunner(
async ({ queries, total, filter, where, sortAsc, sortDesc, cursorAfter, cursorBefore, limit, offset }) =>
parse(await (await getAdvisorClient()).listReports(buildQueries({ queries, filter, where, sortAsc, sortDesc, cursorAfter, cursorBefore, limit, offset }), total)),
),
);


const advisorGetReportCommand = advisor
.command(`get-report`)
.description(`Get an analyzer report by its unique ID. The response includes the report's metadata and the nested insights it produced.
`)
.requiredOption(`--report-id <report-id>`, `Report ID.`)
.action(
actionRunner(
async ({ reportId }) =>
parse(await (await getAdvisorClient()).getReport(reportId)),
),
);


const advisorDeleteReportCommand = advisor
.command(`delete-report`)
.description(`Delete an analyzer report by its unique ID. Nested insights and CTA metadata are removed asynchronously by the deletes worker.
`)
.requiredOption(`--report-id <report-id>`, `Report ID.`)
.action(
actionRunner(
async ({ reportId }) =>
parse(await (await getAdvisorClient()).deleteReport(reportId)),
),
);


const advisorListInsightsCommand = advisor
.command(`list-insights`)
.description(`List the insights produced under a single analyzer report. You can use the query params to filter your results further.
`)
.requiredOption(`--report-id <report-id>`, `Parent report ID.`)
.option(`--queries [queries...]`, `Raw Appwrite JSON query strings (legacy). Use this for advanced queries or automation; for common filtering, sorting, and pagination prefer --filter, --sort-asc, --sort-desc, --limit, and --offset. When mixed, raw --queries are sent before generated flag 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: type, severity, status, resourceType, resourceId, parentResourceType, parentResourceId, analyzedAt, dismissedAt, dismissedBy`)
.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),
)
.option(`--filter <expression>`, `Filter using a simple comparison expression. Repeat for multiple filters. Supports field=value, field!=value, field>value, field>=value, field<value, and field<=value.`, (value: string, previous: string[] | undefined) => collectQueryValue(parseFilterQuery(value), previous))
.option(`--where <expression>`, `Deprecated. Use --filter instead. Filter using a simple comparison expression. Repeat for multiple filters.`, (value: string, previous: string[] | undefined) => collectQueryValue(parseDeprecatedWhereQuery(value), previous))
.option(`--sort-asc <attribute>`, `Sort results by an attribute in ascending order. Repeat for multiple sort fields.`, (value: string, previous: string[] | undefined) => collectQueryValue(value, previous))
.option(`--sort-desc <attribute>`, `Sort results by an attribute in descending order. Repeat for multiple sort fields.`, (value: string, previous: string[] | undefined) => collectQueryValue(value, previous))
.option(`--limit <limit>`, `Maximum number of results to return.`, parseInteger)
.option(`--offset <offset>`, `Number of results to skip.`, parseInteger)
.option(`--cursor-after <id>`, `Return results after this cursor ID.`)
.option(`--cursor-before <id>`, `Return results before this cursor ID.`)
.action(
actionRunner(
async ({ reportId, queries, total, filter, where, sortAsc, sortDesc, cursorAfter, cursorBefore, limit, offset }) =>
parse(await (await getAdvisorClient()).listInsights(reportId, buildQueries({ queries, filter, where, sortAsc, sortDesc, cursorAfter, cursorBefore, limit, offset }), total)),
),
);


const advisorGetInsightCommand = advisor
.command(`get-insight`)
.description(`Get an insight by its unique ID, scoped to its parent report.
`)
.requiredOption(`--report-id <report-id>`, `Parent report ID.`)
.requiredOption(`--insight-id <insight-id>`, `Insight ID.`)
.action(
actionRunner(
async ({ reportId, insightId }) =>
parse(await (await getAdvisorClient()).getInsight(reportId, insightId)),
),
);


Loading
Loading