appwrite-cli 13.4.0 → 13.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/README.md +2 -2
- package/cli.ts +4 -2
- package/dist/bundle-win-arm64.mjs +1633 -2075
- package/dist/cli.cjs +1633 -2075
- package/dist/index.cjs +109645 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +780 -1831
- package/dist/lib/commands/generators/base.d.ts +16 -5
- package/dist/lib/commands/generators/base.d.ts.map +1 -1
- package/dist/lib/commands/generators/typescript/databases.d.ts.map +1 -1
- package/dist/lib/commands/push.d.ts +1 -0
- package/dist/lib/commands/push.d.ts.map +1 -1
- package/dist/lib/commands/schema.d.ts.map +1 -1
- package/dist/lib/commands/services/activities.d.ts +3 -0
- package/dist/lib/commands/services/activities.d.ts.map +1 -0
- package/dist/lib/commands/services/backups.d.ts +3 -0
- package/dist/lib/commands/services/backups.d.ts.map +1 -0
- package/dist/lib/commands/utils/attributes.d.ts +3 -1
- package/dist/lib/commands/utils/attributes.d.ts.map +1 -1
- package/dist/lib/commands/utils/pools.d.ts +3 -1
- package/dist/lib/commands/utils/pools.d.ts.map +1 -1
- package/dist/lib/constants.d.ts +1 -1
- package/dist/lib/json.d.ts.map +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/docs/examples/account/create-key.md +5 -0
- package/docs/examples/account/delete-key.md +4 -0
- package/docs/examples/account/get-key.md +4 -0
- package/docs/examples/account/list-keys.md +3 -0
- package/docs/examples/account/update-key.md +6 -0
- package/docs/examples/activities/get-event.md +4 -0
- package/docs/examples/activities/list-events.md +3 -0
- package/docs/examples/backups/create-archive.md +4 -0
- package/docs/examples/backups/create-policy.md +7 -0
- package/docs/examples/backups/create-restoration.md +5 -0
- package/docs/examples/backups/delete-archive.md +4 -0
- package/docs/examples/backups/delete-policy.md +4 -0
- package/docs/examples/backups/get-archive.md +4 -0
- package/docs/examples/backups/get-policy.md +4 -0
- package/docs/examples/backups/get-restoration.md +4 -0
- package/docs/examples/backups/list-archives.md +3 -0
- package/docs/examples/backups/list-policies.md +3 -0
- package/docs/examples/backups/list-restorations.md +3 -0
- package/docs/examples/backups/update-policy.md +4 -0
- package/docs/examples/projects/create-schedule.md +7 -0
- package/docs/examples/projects/get-schedule.md +5 -0
- package/docs/examples/projects/list-schedules.md +4 -0
- package/index.ts +1 -0
- package/install.ps1 +2 -2
- package/install.sh +1 -1
- package/lib/commands/generators/base.ts +30 -9
- package/lib/commands/generators/typescript/databases.ts +12 -18
- package/lib/commands/push.ts +276 -201
- package/lib/commands/schema.ts +1 -3
- package/lib/commands/services/account.ts +234 -0
- package/lib/commands/services/activities.ts +51 -0
- package/lib/commands/services/backups.ts +184 -0
- package/lib/commands/services/health.ts +55 -0
- package/lib/commands/services/migrations.ts +1 -1
- package/lib/commands/services/projects.ts +51 -0
- package/lib/commands/services/storage.ts +2 -2
- package/lib/commands/utils/attributes.ts +9 -6
- package/lib/commands/utils/pools.ts +9 -6
- package/lib/constants.ts +1 -1
- package/lib/json.ts +14 -7
- package/lib/utils.ts +15 -0
- package/package.json +19 -5
- package/scoop/appwrite.config.json +3 -3
- package/dist/lib/commands/services/console.d.ts +0 -3
- package/dist/lib/commands/services/console.d.ts.map +0 -1
- package/docs/examples/console/get-resource.md +0 -5
- package/docs/examples/console/variables.md +0 -3
- package/lib/commands/services/console.ts +0 -49
|
@@ -4,6 +4,7 @@ import { KeysAttributes } from "../../config.js";
|
|
|
4
4
|
import { log, success, error, cliConfig, drawTable } from "../../parser.js";
|
|
5
5
|
import { Pools } from "./pools.js";
|
|
6
6
|
import inquirer from "inquirer";
|
|
7
|
+
import type { Client } from "@appwrite.io/console";
|
|
7
8
|
|
|
8
9
|
const changeableKeys = [
|
|
9
10
|
"status",
|
|
@@ -53,9 +54,11 @@ const questionPushChangesConfirmation = [
|
|
|
53
54
|
export class Attributes {
|
|
54
55
|
private pools: Pools;
|
|
55
56
|
private skipConfirmation: boolean;
|
|
57
|
+
private client?: Client;
|
|
56
58
|
|
|
57
|
-
constructor(pools?: Pools, skipConfirmation = false) {
|
|
58
|
-
this.
|
|
59
|
+
constructor(pools?: Pools, skipConfirmation = false, client?: Client) {
|
|
60
|
+
this.client = client;
|
|
61
|
+
this.pools = pools || new Pools(undefined, client);
|
|
59
62
|
this.skipConfirmation = skipConfirmation;
|
|
60
63
|
}
|
|
61
64
|
|
|
@@ -197,7 +200,7 @@ export class Attributes {
|
|
|
197
200
|
collectionId: string,
|
|
198
201
|
attribute: any,
|
|
199
202
|
): Promise<any> => {
|
|
200
|
-
const databasesService = await getDatabasesService();
|
|
203
|
+
const databasesService = await getDatabasesService(this.client);
|
|
201
204
|
switch (attribute.type) {
|
|
202
205
|
case "string":
|
|
203
206
|
switch (attribute.format) {
|
|
@@ -373,7 +376,7 @@ export class Attributes {
|
|
|
373
376
|
collectionId: string,
|
|
374
377
|
attribute: any,
|
|
375
378
|
): Promise<any> => {
|
|
376
|
-
const databasesService = await getDatabasesService();
|
|
379
|
+
const databasesService = await getDatabasesService(this.client);
|
|
377
380
|
switch (attribute.type) {
|
|
378
381
|
case "string":
|
|
379
382
|
switch (attribute.format) {
|
|
@@ -533,7 +536,7 @@ export class Attributes {
|
|
|
533
536
|
`Deleting ${isIndex ? "index" : "attribute"} ${attribute.key} of ${collection.name} ( ${collection["$id"]} )`,
|
|
534
537
|
);
|
|
535
538
|
|
|
536
|
-
const databasesService = await getDatabasesService();
|
|
539
|
+
const databasesService = await getDatabasesService(this.client);
|
|
537
540
|
if (isIndex) {
|
|
538
541
|
await databasesService.deleteIndex(
|
|
539
542
|
collection["databaseId"],
|
|
@@ -733,7 +736,7 @@ export class Attributes {
|
|
|
733
736
|
): Promise<void> => {
|
|
734
737
|
log(`Creating indexes ...`);
|
|
735
738
|
|
|
736
|
-
const databasesService = await getDatabasesService();
|
|
739
|
+
const databasesService = await getDatabasesService(this.client);
|
|
737
740
|
for (let index of indexes) {
|
|
738
741
|
await databasesService.createIndex({
|
|
739
742
|
databaseId: collection["databaseId"],
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { getDatabasesService } from "../../services.js";
|
|
2
2
|
import { paginate } from "../../paginate.js";
|
|
3
3
|
import { log } from "../../parser.js";
|
|
4
|
+
import type { Client } from "@appwrite.io/console";
|
|
4
5
|
|
|
5
6
|
export class Pools {
|
|
6
7
|
private STEP_SIZE = 100; // Resources
|
|
7
8
|
private POLL_DEBOUNCE = 2000; // Milliseconds
|
|
8
9
|
private pollMaxDebounces = 30;
|
|
9
10
|
private POLL_DEFAULT_VALUE = 30;
|
|
11
|
+
private client?: Client;
|
|
10
12
|
|
|
11
|
-
constructor(pollMaxDebounces?: number) {
|
|
13
|
+
constructor(pollMaxDebounces?: number, client?: Client) {
|
|
14
|
+
this.client = client;
|
|
12
15
|
if (pollMaxDebounces) {
|
|
13
16
|
this.pollMaxDebounces = pollMaxDebounces;
|
|
14
17
|
}
|
|
@@ -23,7 +26,7 @@ export class Pools {
|
|
|
23
26
|
return false;
|
|
24
27
|
}
|
|
25
28
|
|
|
26
|
-
const databasesService = await getDatabasesService();
|
|
29
|
+
const databasesService = await getDatabasesService(this.client);
|
|
27
30
|
const response = await databasesService.listAttributes(
|
|
28
31
|
databaseId,
|
|
29
32
|
collectionId,
|
|
@@ -62,7 +65,7 @@ export class Pools {
|
|
|
62
65
|
return false;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
const databasesService = await getDatabasesService();
|
|
68
|
+
const databasesService = await getDatabasesService(this.client);
|
|
66
69
|
const response = await databasesService.listIndexes(
|
|
67
70
|
databaseId,
|
|
68
71
|
collectionId,
|
|
@@ -117,7 +120,7 @@ export class Pools {
|
|
|
117
120
|
|
|
118
121
|
const { attributes } = await paginate(
|
|
119
122
|
async (args: any) => {
|
|
120
|
-
const databasesService = await getDatabasesService();
|
|
123
|
+
const databasesService = await getDatabasesService(this.client);
|
|
121
124
|
return await databasesService.listAttributes({
|
|
122
125
|
databaseId: args.databaseId,
|
|
123
126
|
collectionId: args.collectionId,
|
|
@@ -175,7 +178,7 @@ export class Pools {
|
|
|
175
178
|
|
|
176
179
|
const { attributes } = await paginate(
|
|
177
180
|
async (args: any) => {
|
|
178
|
-
const databasesService = await getDatabasesService();
|
|
181
|
+
const databasesService = await getDatabasesService(this.client);
|
|
179
182
|
return await databasesService.listAttributes(
|
|
180
183
|
args.databaseId,
|
|
181
184
|
args.collectionId,
|
|
@@ -243,7 +246,7 @@ export class Pools {
|
|
|
243
246
|
|
|
244
247
|
const { indexes } = await paginate(
|
|
245
248
|
async (args: any) => {
|
|
246
|
-
const databasesService = await getDatabasesService();
|
|
249
|
+
const databasesService = await getDatabasesService(this.client);
|
|
247
250
|
return await databasesService.listIndexes(
|
|
248
251
|
args.databaseId,
|
|
249
252
|
args.collectionId,
|
package/lib/constants.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SDK
|
|
2
2
|
export const SDK_TITLE = 'Appwrite';
|
|
3
3
|
export const SDK_TITLE_LOWER = 'appwrite';
|
|
4
|
-
export const SDK_VERSION = '13.
|
|
4
|
+
export const SDK_VERSION = '13.6.0';
|
|
5
5
|
export const SDK_NAME = 'Command Line';
|
|
6
6
|
export const SDK_PLATFORM = 'console';
|
|
7
7
|
export const SDK_LANGUAGE = 'cli';
|
package/lib/json.ts
CHANGED
|
@@ -5,14 +5,18 @@ const JSONbigSerializer = JSONbigModule({ useNativeBigInt: true });
|
|
|
5
5
|
|
|
6
6
|
const MAX_SAFE = BigInt(Number.MAX_SAFE_INTEGER);
|
|
7
7
|
const MIN_SAFE = BigInt(Number.MIN_SAFE_INTEGER);
|
|
8
|
+
const MAX_INT64 = BigInt("9223372036854775807");
|
|
9
|
+
const MIN_INT64 = BigInt("-9223372036854775808");
|
|
8
10
|
|
|
9
11
|
function isBigNumber(value: any): boolean {
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
return (
|
|
13
|
+
value !== null &&
|
|
14
|
+
typeof value === "object" &&
|
|
15
|
+
value._isBigNumber === true &&
|
|
16
|
+
typeof value.isInteger === "function" &&
|
|
17
|
+
typeof value.toFixed === "function" &&
|
|
18
|
+
typeof value.toNumber === "function"
|
|
19
|
+
);
|
|
16
20
|
}
|
|
17
21
|
|
|
18
22
|
function reviver(_key: string, value: any): any {
|
|
@@ -23,7 +27,10 @@ function reviver(_key: string, value: any): any {
|
|
|
23
27
|
if (bi >= MIN_SAFE && bi <= MAX_SAFE) {
|
|
24
28
|
return Number(str);
|
|
25
29
|
}
|
|
26
|
-
|
|
30
|
+
if (bi >= MIN_INT64 && bi <= MAX_INT64) {
|
|
31
|
+
return bi;
|
|
32
|
+
}
|
|
33
|
+
return value.toNumber();
|
|
27
34
|
}
|
|
28
35
|
return value.toNumber();
|
|
29
36
|
}
|
package/lib/utils.ts
CHANGED
|
@@ -160,6 +160,21 @@ export function isCloud(): boolean {
|
|
|
160
160
|
return hostname.endsWith("appwrite.io");
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
export function arrayEqualsUnordered(left: unknown, right: unknown): boolean {
|
|
164
|
+
const a = Array.isArray(left)
|
|
165
|
+
? [...left].map((item) => String(item)).sort()
|
|
166
|
+
: [];
|
|
167
|
+
const b = Array.isArray(right)
|
|
168
|
+
? [...right].map((item) => String(item)).sort()
|
|
169
|
+
: [];
|
|
170
|
+
|
|
171
|
+
if (a.length !== b.length) {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return a.every((value, index) => value === b[index]);
|
|
176
|
+
}
|
|
177
|
+
|
|
163
178
|
/**
|
|
164
179
|
* Filters an object to only include fields defined in a Zod object schema.
|
|
165
180
|
* Uses the schema's shape to determine allowed keys.
|
package/package.json
CHANGED
|
@@ -3,10 +3,23 @@
|
|
|
3
3
|
"type": "module",
|
|
4
4
|
"homepage": "https://appwrite.io/support",
|
|
5
5
|
"description": "Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API",
|
|
6
|
-
"version": "13.
|
|
6
|
+
"version": "13.6.0",
|
|
7
7
|
"license": "BSD-3-Clause",
|
|
8
|
-
"main": "dist/index.
|
|
8
|
+
"main": "dist/index.cjs",
|
|
9
|
+
"module": "dist/index.js",
|
|
9
10
|
"types": "dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"default": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"require": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"default": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
},
|
|
10
23
|
"bin": {
|
|
11
24
|
"appwrite": "dist/cli.cjs"
|
|
12
25
|
},
|
|
@@ -17,8 +30,9 @@
|
|
|
17
30
|
"scripts": {
|
|
18
31
|
"build": "npm run build:types && npm run build:runtime",
|
|
19
32
|
"build:types": "tsc -p tsconfig.json --emitDeclarationOnly",
|
|
20
|
-
"build:runtime": "npm run build:lib:
|
|
21
|
-
"build:lib:
|
|
33
|
+
"build:runtime": "npm run build:lib:esm && npm run build:lib:cjs && npm run build:cli",
|
|
34
|
+
"build:lib:esm": "esbuild index.ts --bundle --platform=node --target=node18 --format=esm --loader:.hbs=text --outfile=dist/index.js",
|
|
35
|
+
"build:lib:cjs": "esbuild index.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --outfile=dist/index.cjs",
|
|
22
36
|
"build:cli": "esbuild cli.ts --bundle --platform=node --target=node18 --format=cjs --loader:.hbs=text --external:fsevents --outfile=dist/cli.cjs",
|
|
23
37
|
"format": "prettier --write \"**/*.{js,ts,json,md}\"",
|
|
24
38
|
"generate": "tsx scripts/generate-commands.ts",
|
|
@@ -32,7 +46,7 @@
|
|
|
32
46
|
"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"
|
|
33
47
|
},
|
|
34
48
|
"dependencies": {
|
|
35
|
-
"@appwrite.io/console": "^
|
|
49
|
+
"@appwrite.io/console": "^3.1.0",
|
|
36
50
|
"chalk": "4.1.2",
|
|
37
51
|
"chokidar": "^3.6.0",
|
|
38
52
|
"cli-progress": "^3.12.0",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/ScoopInstaller/Scoop/master/schema.json",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.6.0",
|
|
4
4
|
"description": "The Appwrite CLI is a command-line application that allows you to interact with Appwrite and perform server-side tasks using your terminal.",
|
|
5
5
|
"homepage": "https://github.com/appwrite/sdk-for-cli",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"architecture": {
|
|
8
8
|
"64bit": {
|
|
9
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.
|
|
9
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.0/appwrite-cli-win-x64.exe",
|
|
10
10
|
"bin": [
|
|
11
11
|
[
|
|
12
12
|
"appwrite-cli-win-x64.exe",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
]
|
|
16
16
|
},
|
|
17
17
|
"arm64": {
|
|
18
|
-
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.
|
|
18
|
+
"url": "https://github.com/appwrite/sdk-for-cli/releases/download/13.6.0/appwrite-cli-win-arm64.exe",
|
|
19
19
|
"bin": [
|
|
20
20
|
[
|
|
21
21
|
"appwrite-cli-win-arm64.exe",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../../../lib/commands/services/console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsBpC,eAAO,MAAM,OAAO,SAIhB,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Command } from "commander";
|
|
2
|
-
import { sdkForProject } from "../../sdks.js";
|
|
3
|
-
import {
|
|
4
|
-
actionRunner,
|
|
5
|
-
commandDescriptions,
|
|
6
|
-
success,
|
|
7
|
-
parse,
|
|
8
|
-
parseBool,
|
|
9
|
-
parseInteger,
|
|
10
|
-
} from "../../parser.js";
|
|
11
|
-
import { Console } from "@appwrite.io/console";
|
|
12
|
-
|
|
13
|
-
let consoleClient: Console | null = null;
|
|
14
|
-
|
|
15
|
-
const getConsoleClient = async (): Promise<Console> => {
|
|
16
|
-
if (!consoleClient) {
|
|
17
|
-
const sdkClient = await sdkForProject();
|
|
18
|
-
consoleClient = new Console(sdkClient);
|
|
19
|
-
}
|
|
20
|
-
return consoleClient;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const console = new Command("console")
|
|
24
|
-
.description(commandDescriptions["console"] ?? "")
|
|
25
|
-
.configureHelp({
|
|
26
|
-
helpWidth: process.stdout.columns || 80,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
console
|
|
30
|
-
.command(`get-resource`)
|
|
31
|
-
.description(`Check if a resource ID is available.`)
|
|
32
|
-
.requiredOption(`--value <value>`, `Resource value.`)
|
|
33
|
-
.requiredOption(`--type <type>`, `Resource type.`)
|
|
34
|
-
.action(
|
|
35
|
-
actionRunner(
|
|
36
|
-
async ({ value, type }) =>
|
|
37
|
-
parse(await (await getConsoleClient()).getResource(value, type)),
|
|
38
|
-
),
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
console
|
|
42
|
-
.command(`variables`)
|
|
43
|
-
.description(`Get all Environment Variables that are relevant for the console.`)
|
|
44
|
-
.action(
|
|
45
|
-
actionRunner(
|
|
46
|
-
async () => parse(await (await getConsoleClient()).variables()),
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
|