Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 16.0.0

* Breaking: Moved webhook commands from `projects` to new `webhooks` service.

## 15.1.0

* Added `resolveFileParam` to convert file or directory paths into `File` objects and tar.gz packages
Expand Down
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.8.1-blue.svg?style=flat-square)
![Version](https://img.shields.io/badge/api%20version-1.8.2-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
15.1.0
16.0.0
```

### Install using prebuilt binaries
Expand Down Expand Up @@ -60,7 +60,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
15.1.0
16.0.0
```

## Getting Started
Expand Down
2 changes: 2 additions & 0 deletions cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import { teams } from './lib/commands/services/teams.js';
import { tokens } from './lib/commands/services/tokens.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';

const { version } = packageJson;
inquirer.registerPrompt('search-list', inquirerSearchList);
Expand Down Expand Up @@ -154,6 +155,7 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
.addCommand(tokens)
.addCommand(users)
.addCommand(vcs)
.addCommand(webhooks)
.addCommand(client)
.parse(process.argv);

Expand Down
8 changes: 0 additions & 8 deletions docs/examples/projects/create-webhook.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/examples/projects/delete-webhook.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/examples/projects/get-webhook.md

This file was deleted.

4 changes: 0 additions & 4 deletions docs/examples/projects/list-webhooks.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/examples/projects/update-webhook-signature.md

This file was deleted.

9 changes: 0 additions & 9 deletions docs/examples/projects/update-webhook.md

This file was deleted.

7 changes: 7 additions & 0 deletions docs/examples/webhooks/create.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```bash
appwrite webhooks create \
--webhook-id <WEBHOOK_ID> \
--url '' \
--name <NAME> \
--events one two three
```
4 changes: 4 additions & 0 deletions docs/examples/webhooks/delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite webhooks delete \
--webhook-id <WEBHOOK_ID>
```
4 changes: 4 additions & 0 deletions docs/examples/webhooks/get.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite webhooks get \
--webhook-id <WEBHOOK_ID>
```
3 changes: 3 additions & 0 deletions docs/examples/webhooks/list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```bash
appwrite webhooks list
```
4 changes: 4 additions & 0 deletions docs/examples/webhooks/update-signature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```bash
appwrite webhooks update-signature \
--webhook-id <WEBHOOK_ID>
```
7 changes: 7 additions & 0 deletions docs/examples/webhooks/update.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
```bash
appwrite webhooks update \
--webhook-id <WEBHOOK_ID> \
--name <NAME> \
--url '' \
--events one two three
```
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/15.1.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/15.1.0/appwrite-cli-win-arm64.exe"
$GITHUB_x64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/16.0.0/appwrite-cli-win-x64.exe"
$GITHUB_arm64_URL = "https://github.com/appwrite/sdk-for-cli/releases/download/16.0.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 @@ -96,7 +96,7 @@ printSuccess() {
downloadBinary() {
echo "[2/4] Downloading executable for $OS ($ARCH) ..."

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

Expand Down
42 changes: 36 additions & 6 deletions lib/commands/generators/typescript/databases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,18 @@ ${
});
}

/**
* Deduplicate entities by composite key ($id + databaseId).
* Keeps the last occurrence to match addTable/addCollection semantics.
*/
private dedupeEntities<T extends Entity>(entities: T[]): T[] {
const seen = new Map<string, T>();
for (const entity of entities) {
seen.set(`${entity.databaseId}:${entity.$id}`, entity);
}
return Array.from(seen.values());
}

async generate(
config: ConfigType,
options?: GenerateOptions,
Expand All @@ -437,9 +449,20 @@ ${
options?.appwriteImportSource ?? getAppwriteDependency();
const importExt = options?.importExtension ?? detectImportExtension();

// Deduplicate entities to guard against corrupted configs
const dedupedConfig = { ...config };
if (dedupedConfig.tables && dedupedConfig.tables.length > 0) {
dedupedConfig.tables = this.dedupeEntities(dedupedConfig.tables);
}
if (dedupedConfig.collections && dedupedConfig.collections.length > 0) {
dedupedConfig.collections = this.dedupeEntities(
dedupedConfig.collections,
);
}

const hasEntities =
(config.tables && config.tables.length > 0) ||
(config.collections && config.collections.length > 0);
(dedupedConfig.tables && dedupedConfig.tables.length > 0) ||
(dedupedConfig.collections && dedupedConfig.collections.length > 0);

if (!hasEntities) {
console.log(
Expand All @@ -449,15 +472,22 @@ ${
dbContent: "// No tables or collections found in configuration\n",
typesContent: "// No tables or collections found in configuration\n",
indexContent: this.generateIndexFile(importExt),
constantsContent: this.generateConstantsFile(config, appwriteDep),
constantsContent: this.generateConstantsFile(
dedupedConfig,
appwriteDep,
),
};
}

return {
dbContent: this.generateDatabasesFile(config, importExt, appwriteDep),
typesContent: this.generateTypesFile(config, appwriteDep),
dbContent: this.generateDatabasesFile(
dedupedConfig,
importExt,
appwriteDep,
),
typesContent: this.generateTypesFile(dedupedConfig, appwriteDep),
indexContent: this.generateIndexFile(importExt),
constantsContent: this.generateConstantsFile(config, appwriteDep),
constantsContent: this.generateConstantsFile(dedupedConfig, appwriteDep),
};
}
}
42 changes: 30 additions & 12 deletions lib/commands/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,8 @@ export class Pull {
}

const { functions: allFunctions } = await paginate(
async () => new Functions(this.projectClient).list(),
async (args) =>
new Functions(this.projectClient).list(args.queries as string[]),
{},
100,
"functions",
Expand Down Expand Up @@ -366,7 +367,8 @@ export class Pull {
}

const { sites: fetchedSites } = await paginate(
async () => new Sites(this.projectClient).list(),
async (args) =>
new Sites(this.projectClient).list(args.queries as string[]),
{},
100,
"sites",
Expand Down Expand Up @@ -463,7 +465,8 @@ export class Pull {
}

const { databases } = await paginate(
async () => new Databases(this.projectClient).list(),
async (args) =>
new Databases(this.projectClient).list(args.queries as string[]),
{},
100,
"databases",
Expand All @@ -479,8 +482,11 @@ export class Pull {
allDatabases.push(database);

const { collections } = await paginate(
async () =>
new Databases(this.projectClient).listCollections(database.$id),
async (args) =>
new Databases(this.projectClient).listCollections(
database.$id,
args.queries as string[],
),
{},
100,
"collections",
Expand Down Expand Up @@ -529,7 +535,10 @@ export class Pull {
}

const { databases } = await paginate(
async () => new TablesDB(this.projectClient).list(),
async (args) =>
new TablesDB(this.projectClient).list({
queries: args.queries as string[],
}),
{},
100,
"databases",
Expand All @@ -545,7 +554,11 @@ export class Pull {
allDatabases.push(filterBySchema(database, DatabaseSchema));

const { tables } = await paginate(
async () => new TablesDB(this.projectClient).listTables(database.$id),
async (args) =>
new TablesDB(this.projectClient).listTables({
databaseId: database.$id,
queries: args.queries as string[],
}),
{},
100,
"tables",
Expand Down Expand Up @@ -599,7 +612,8 @@ export class Pull {
}

const { buckets } = await paginate(
async () => new Storage(this.projectClient).listBuckets(),
async (args) =>
new Storage(this.projectClient).listBuckets(args.queries as string[]),
{},
100,
"buckets",
Expand Down Expand Up @@ -638,7 +652,8 @@ export class Pull {
}

const { teams } = await paginate(
async () => new Teams(this.projectClient).list(),
async (args) =>
new Teams(this.projectClient).list(args.queries as string[]),
{},
100,
"teams",
Expand Down Expand Up @@ -672,7 +687,8 @@ export class Pull {
}

const { topics } = await paginate(
async () => new Messaging(this.projectClient).listTopics(),
async (args) =>
new Messaging(this.projectClient).listTopics(args.queries as string[]),
{},
100,
"topics",
Expand Down Expand Up @@ -763,7 +779,8 @@ const pullFunctions = async ({
const functionsToCheck = cliConfig.all
? (
await paginate(
async () => (await getFunctionsService()).list(),
async (args) =>
(await getFunctionsService()).list(args.queries as string[]),
{},
100,
"functions",
Expand Down Expand Up @@ -811,7 +828,8 @@ const pullSites = async ({
const sitesToCheck = cliConfig.all
? (
await paginate(
async () => (await getSitesService()).list(),
async (args) =>
(await getSitesService()).list(args.queries as string[]),
{},
100,
"sites",
Expand Down
Loading
Loading