appwrite-cli 12.0.0 → 13.0.0-rc.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.
- package/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +145 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/client.d.ts +89 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +227 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/commands/account.d.ts +379 -0
- package/dist/lib/commands/account.d.ts.map +1 -0
- package/dist/lib/commands/account.js +1228 -0
- package/dist/lib/commands/account.js.map +1 -0
- package/dist/lib/commands/console.d.ts +20 -0
- package/dist/lib/commands/console.d.ts.map +1 -0
- package/dist/lib/commands/console.js +78 -0
- package/dist/lib/commands/console.js.map +1 -0
- package/dist/lib/commands/databases.d.ts +732 -0
- package/dist/lib/commands/databases.d.ts.map +1 -0
- package/dist/lib/commands/databases.js +2196 -0
- package/dist/lib/commands/databases.js.map +1 -0
- package/dist/lib/commands/functions.d.ts +310 -0
- package/dist/lib/commands/functions.d.ts.map +1 -0
- package/dist/lib/commands/functions.js +1100 -0
- package/dist/lib/commands/functions.js.map +1 -0
- package/dist/lib/commands/generic.d.ts +17 -0
- package/dist/lib/commands/generic.d.ts.map +1 -0
- package/dist/lib/commands/generic.js +279 -0
- package/dist/lib/commands/generic.js.map +1 -0
- package/dist/lib/commands/graphql.d.ts +19 -0
- package/dist/lib/commands/graphql.d.ts.map +1 -0
- package/dist/lib/commands/graphql.js +77 -0
- package/dist/lib/commands/graphql.js.map +1 -0
- package/dist/lib/commands/health.d.ts +153 -0
- package/dist/lib/commands/health.d.ts.map +1 -0
- package/dist/lib/commands/health.js +464 -0
- package/dist/lib/commands/health.js.map +1 -0
- package/dist/lib/commands/init.d.ts +3 -0
- package/dist/lib/commands/init.d.ts.map +1 -0
- package/dist/lib/commands/init.js +518 -0
- package/dist/lib/commands/init.js.map +1 -0
- package/dist/lib/commands/locale.d.ts +53 -0
- package/dist/lib/commands/locale.d.ts.map +1 -0
- package/dist/lib/commands/locale.js +165 -0
- package/dist/lib/commands/locale.js.map +1 -0
- package/dist/lib/commands/messaging.d.ts +588 -0
- package/dist/lib/commands/messaging.d.ts.map +1 -0
- package/dist/lib/commands/messaging.js +2042 -0
- package/dist/lib/commands/messaging.js.map +1 -0
- package/dist/lib/commands/migrations.d.ts +150 -0
- package/dist/lib/commands/migrations.d.ts.map +1 -0
- package/dist/lib/commands/migrations.js +524 -0
- package/dist/lib/commands/migrations.js.map +1 -0
- package/dist/lib/commands/organizations.d.ts +11 -0
- package/dist/lib/commands/organizations.d.ts.map +1 -0
- package/dist/lib/commands/organizations.js +31 -0
- package/dist/lib/commands/organizations.js.map +1 -0
- package/dist/lib/commands/project.d.ts +53 -0
- package/dist/lib/commands/project.d.ts.map +1 -0
- package/dist/lib/commands/project.js +176 -0
- package/dist/lib/commands/project.js.map +1 -0
- package/dist/lib/commands/projects.d.ts +516 -0
- package/dist/lib/commands/projects.d.ts.map +1 -0
- package/dist/lib/commands/projects.js +1590 -0
- package/dist/lib/commands/projects.js.map +1 -0
- package/dist/lib/commands/proxy.d.ts +71 -0
- package/dist/lib/commands/proxy.d.ts.map +1 -0
- package/dist/lib/commands/proxy.js +240 -0
- package/dist/lib/commands/proxy.js.map +1 -0
- package/dist/lib/commands/pull.d.ts +8 -0
- package/dist/lib/commands/pull.d.ts.map +1 -0
- package/dist/lib/commands/pull.js +455 -0
- package/dist/lib/commands/pull.js.map +1 -0
- package/dist/lib/commands/push.d.ts +4 -0
- package/dist/lib/commands/push.d.ts.map +1 -0
- package/dist/lib/commands/push.js +2154 -0
- package/dist/lib/commands/push.js.map +1 -0
- package/dist/lib/commands/run.d.ts +3 -0
- package/dist/lib/commands/run.d.ts.map +1 -0
- package/dist/lib/commands/run.js +287 -0
- package/dist/lib/commands/run.js.map +1 -0
- package/dist/lib/commands/sites.d.ts +296 -0
- package/dist/lib/commands/sites.d.ts.map +1 -0
- package/dist/lib/commands/sites.js +1046 -0
- package/dist/lib/commands/sites.js.map +1 -0
- package/dist/lib/commands/storage.d.ts +170 -0
- package/dist/lib/commands/storage.d.ts.map +1 -0
- package/dist/lib/commands/storage.js +651 -0
- package/dist/lib/commands/storage.js.map +1 -0
- package/dist/lib/commands/tables-db.d.ts +728 -0
- package/dist/lib/commands/tables-db.d.ts.map +1 -0
- package/dist/lib/commands/tables-db.js +2198 -0
- package/dist/lib/commands/tables-db.js.map +1 -0
- package/dist/lib/commands/teams.d.ts +129 -0
- package/dist/lib/commands/teams.d.ts.map +1 -0
- package/dist/lib/commands/teams.js +403 -0
- package/dist/lib/commands/teams.js.map +1 -0
- package/dist/lib/commands/tokens.d.ts +48 -0
- package/dist/lib/commands/tokens.d.ts.map +1 -0
- package/dist/lib/commands/tokens.js +156 -0
- package/dist/lib/commands/tokens.js.map +1 -0
- package/dist/lib/commands/types.d.ts +3 -0
- package/dist/lib/commands/types.d.ts.map +1 -0
- package/dist/lib/commands/types.js +155 -0
- package/dist/lib/commands/types.js.map +1 -0
- package/dist/lib/commands/update.d.ts +3 -0
- package/dist/lib/commands/update.d.ts.map +1 -0
- package/dist/lib/commands/update.js +202 -0
- package/dist/lib/commands/update.js.map +1 -0
- package/dist/lib/commands/users.d.ts +382 -0
- package/dist/lib/commands/users.d.ts.map +1 -0
- package/dist/lib/commands/users.js +1195 -0
- package/dist/lib/commands/users.js.map +1 -0
- package/dist/lib/commands/vcs.d.ts +92 -0
- package/dist/lib/commands/vcs.d.ts.map +1 -0
- package/dist/lib/commands/vcs.js +276 -0
- package/dist/lib/commands/vcs.js.map +1 -0
- package/dist/lib/config.d.ts +118 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/{lib → dist/lib}/config.js +204 -325
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/emulation/docker.d.ts +15 -0
- package/dist/lib/emulation/docker.d.ts.map +1 -0
- package/dist/lib/emulation/docker.js +220 -0
- package/dist/lib/emulation/docker.js.map +1 -0
- package/dist/lib/emulation/utils.d.ts +29 -0
- package/dist/lib/emulation/utils.d.ts.map +1 -0
- package/dist/lib/emulation/utils.js +168 -0
- package/dist/lib/emulation/utils.js.map +1 -0
- package/dist/lib/exception.d.ts +8 -0
- package/dist/lib/exception.d.ts.map +1 -0
- package/dist/lib/exception.js +16 -0
- package/dist/lib/exception.js.map +1 -0
- package/dist/lib/id.d.ts +7 -0
- package/dist/lib/id.d.ts.map +1 -0
- package/dist/lib/id.js +32 -0
- package/dist/lib/id.js.map +1 -0
- package/dist/lib/paginate.d.ts +10 -0
- package/dist/lib/paginate.d.ts.map +1 -0
- package/{lib → dist/lib}/paginate.js +9 -15
- package/dist/lib/paginate.js.map +1 -0
- package/dist/lib/parser.d.ts +18 -0
- package/dist/lib/parser.d.ts.map +1 -0
- package/dist/lib/parser.js +237 -0
- package/dist/lib/parser.js.map +1 -0
- package/dist/lib/questions.d.ts +59 -0
- package/dist/lib/questions.d.ts.map +1 -0
- package/dist/lib/questions.js +995 -0
- package/dist/lib/questions.js.map +1 -0
- package/dist/lib/sdks.d.ts +4 -0
- package/dist/lib/sdks.d.ts.map +1 -0
- package/dist/lib/sdks.js +51 -0
- package/dist/lib/sdks.js.map +1 -0
- package/dist/lib/spinner.d.ts +28 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/{lib → dist/lib}/spinner.js +34 -45
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/type-generation/attribute.d.ts +17 -0
- package/dist/lib/type-generation/attribute.d.ts.map +1 -0
- package/dist/lib/type-generation/attribute.js +19 -0
- package/dist/lib/type-generation/attribute.js.map +1 -0
- package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
- package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/csharp.js +180 -0
- package/dist/lib/type-generation/languages/csharp.js.map +1 -0
- package/dist/lib/type-generation/languages/dart.d.ts +8 -0
- package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/dart.js +197 -0
- package/dist/lib/type-generation/languages/dart.js.map +1 -0
- package/dist/lib/type-generation/languages/java.d.ts +7 -0
- package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/java.js +140 -0
- package/dist/lib/type-generation/languages/java.js.map +1 -0
- package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
- package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/javascript.js +108 -0
- package/dist/lib/type-generation/languages/javascript.js.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
- package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/kotlin.js +95 -0
- package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
- package/dist/lib/type-generation/languages/language.d.ts +43 -0
- package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/language.js +82 -0
- package/dist/lib/type-generation/languages/language.js.map +1 -0
- package/dist/lib/type-generation/languages/php.d.ts +7 -0
- package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/php.js +116 -0
- package/dist/lib/type-generation/languages/php.js.map +1 -0
- package/dist/lib/type-generation/languages/swift.d.ts +7 -0
- package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/swift.js +179 -0
- package/dist/lib/type-generation/languages/swift.js.map +1 -0
- package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
- package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
- package/dist/lib/type-generation/languages/typescript.js +112 -0
- package/dist/lib/type-generation/languages/typescript.js.map +1 -0
- package/dist/lib/types.d.ts +133 -0
- package/dist/lib/types.d.ts.map +1 -0
- package/dist/lib/types.js +3 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/utils.d.ts +15 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/{lib → dist/lib}/utils.js +74 -120
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/validations.d.ts +2 -0
- package/dist/lib/validations.d.ts.map +1 -0
- package/dist/lib/validations.js +20 -0
- package/dist/lib/validations.js.map +1 -0
- package/docs/examples/databases/upsert-document.md +1 -2
- package/index.ts +152 -0
- package/install.ps1 +2 -5
- package/install.sh +1 -2
- package/lib/client.ts +259 -0
- package/lib/commands/{account.js → account.ts} +410 -664
- package/lib/commands/console.ts +112 -0
- package/lib/commands/{databases.js → databases.ts} +818 -1136
- package/lib/commands/{functions.js → functions.ts} +381 -526
- package/lib/commands/{generic.js → generic.ts} +47 -39
- package/lib/commands/graphql.ts +110 -0
- package/lib/commands/{health.js → health.ts} +168 -284
- package/lib/commands/{init.js → init.ts} +68 -66
- package/lib/commands/{locale.js → locale.ts} +75 -121
- package/lib/commands/{messaging.js → messaging.ts} +699 -937
- package/lib/commands/{migrations.js → migrations.ts} +182 -258
- package/lib/commands/organizations.ts +46 -0
- package/lib/commands/{project.js → project.ts} +75 -111
- package/lib/commands/{projects.js → projects.ts} +587 -843
- package/lib/commands/{proxy.js → proxy.ts} +94 -140
- package/lib/commands/{pull.js → pull.ts} +54 -44
- package/lib/commands/{push.js → push.ts} +235 -191
- package/lib/commands/{run.js → run.ts} +61 -55
- package/lib/commands/{sites.js → sites.ts} +364 -504
- package/lib/commands/{storage.js → storage.ts} +216 -292
- package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
- package/lib/commands/{teams.js → teams.ts} +162 -236
- package/lib/commands/{tokens.js → tokens.ts} +70 -99
- package/lib/commands/{types.js → types.ts} +37 -35
- package/lib/commands/{update.js → update.ts} +25 -27
- package/lib/commands/{users.js → users.ts} +426 -644
- package/lib/commands/{vcs.js → vcs.ts} +122 -173
- package/lib/config.ts +854 -0
- package/lib/emulation/{docker.js → docker.ts} +39 -38
- package/lib/emulation/utils.ts +193 -0
- package/lib/exception.ts +20 -0
- package/lib/{id.js → id.ts} +5 -5
- package/lib/paginate.ts +63 -0
- package/lib/parser.ts +238 -0
- package/lib/{questions.js → questions.ts} +148 -156
- package/lib/sdks.ts +55 -0
- package/lib/spinner.ts +118 -0
- package/lib/type-generation/attribute.ts +17 -0
- package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -48
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
- package/lib/type-generation/languages/{java.js → java.ts} +58 -47
- package/lib/type-generation/languages/javascript.ts +111 -0
- package/lib/type-generation/languages/kotlin.ts +96 -0
- package/lib/type-generation/languages/language.ts +119 -0
- package/lib/type-generation/languages/{php.js → php.ts} +55 -48
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
- package/lib/type-generation/languages/typescript.ts +116 -0
- package/lib/types.ts +150 -0
- package/lib/utils.ts +322 -0
- package/lib/validations.ts +17 -0
- package/package.json +21 -12
- package/scoop/appwrite.config.json +3 -3
- package/tsconfig.json +30 -0
- package/index.js +0 -147
- package/lib/client.js +0 -254
- package/lib/commands/console.js +0 -127
- package/lib/commands/graphql.js +0 -126
- package/lib/commands/organizations.js +0 -48
- package/lib/emulation/utils.js +0 -186
- package/lib/exception.js +0 -9
- package/lib/parser.js +0 -250
- package/lib/sdks.js +0 -60
- package/lib/type-generation/attribute.js +0 -16
- package/lib/type-generation/languages/javascript.js +0 -102
- package/lib/type-generation/languages/kotlin.js +0 -85
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -107
- package/lib/validations.js +0 -17
package/lib/sdks.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import Client = require('./client');
|
|
2
|
+
import { globalConfig, localConfig } from './config';
|
|
3
|
+
|
|
4
|
+
export const sdkForConsole = async (requiresAuth: boolean = true): Promise<Client> => {
|
|
5
|
+
const client = new Client();
|
|
6
|
+
const endpoint = globalConfig.getEndpoint();
|
|
7
|
+
const cookie = globalConfig.getCookie();
|
|
8
|
+
const selfSigned = globalConfig.getSelfSigned();
|
|
9
|
+
|
|
10
|
+
if (requiresAuth && cookie === '') {
|
|
11
|
+
throw new Error('Session not found. Please run `appwrite login` to create a session');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
client
|
|
15
|
+
.setEndpoint(endpoint)
|
|
16
|
+
.setCookie(cookie)
|
|
17
|
+
.setProject('console')
|
|
18
|
+
.setSelfSigned(selfSigned)
|
|
19
|
+
.setLocale('en-US');
|
|
20
|
+
|
|
21
|
+
return client;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const sdkForProject = async (): Promise<Client> => {
|
|
25
|
+
const client = new Client();
|
|
26
|
+
const endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
|
|
27
|
+
const project = localConfig.getProject().projectId ? localConfig.getProject().projectId : globalConfig.getProject();
|
|
28
|
+
const key = globalConfig.getKey();
|
|
29
|
+
const cookie = globalConfig.getCookie();
|
|
30
|
+
const selfSigned = globalConfig.getSelfSigned();
|
|
31
|
+
|
|
32
|
+
if (!project) {
|
|
33
|
+
throw new Error('Project is not set. Please run `appwrite init project` to initialize the current directory with an Appwrite project.');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
client
|
|
37
|
+
.setEndpoint(endpoint)
|
|
38
|
+
.setProject(project)
|
|
39
|
+
.setSelfSigned(selfSigned)
|
|
40
|
+
.setLocale('en-US');
|
|
41
|
+
|
|
42
|
+
if (cookie) {
|
|
43
|
+
return client
|
|
44
|
+
.setCookie(cookie)
|
|
45
|
+
.setMode('admin');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (key) {
|
|
49
|
+
return client
|
|
50
|
+
.setKey(key)
|
|
51
|
+
.setMode('default');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
throw new Error('Session not found. Please run `appwrite login` to create a session.');
|
|
55
|
+
};
|
package/lib/spinner.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import progress = require('cli-progress');
|
|
2
|
+
import chalk = require('chalk');
|
|
3
|
+
|
|
4
|
+
const SPINNER_ARC = 'arc';
|
|
5
|
+
const SPINNER_DOTS = 'dots';
|
|
6
|
+
|
|
7
|
+
interface SpinnerConfig {
|
|
8
|
+
interval: number;
|
|
9
|
+
frames: string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface SpinnerPayload {
|
|
13
|
+
status: string;
|
|
14
|
+
resource: string;
|
|
15
|
+
id: string;
|
|
16
|
+
prefix?: string;
|
|
17
|
+
end?: string;
|
|
18
|
+
errorMessage?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const spinners: Record<string, SpinnerConfig> = {
|
|
22
|
+
[SPINNER_ARC]: {
|
|
23
|
+
interval: 100,
|
|
24
|
+
frames: ['◜', '◠', '◝', '◞', '◡', '◟'],
|
|
25
|
+
},
|
|
26
|
+
[SPINNER_DOTS]: {
|
|
27
|
+
interval: 80,
|
|
28
|
+
frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
class Spinner {
|
|
33
|
+
static updatesBar: progress.MultiBar;
|
|
34
|
+
private bar: progress.SingleBar;
|
|
35
|
+
private spinnerInterval?: NodeJS.Timeout;
|
|
36
|
+
|
|
37
|
+
static start(clearOnComplete: boolean = true, hideCursor: boolean = true): void {
|
|
38
|
+
Spinner.updatesBar = new progress.MultiBar({
|
|
39
|
+
format: this.formatter,
|
|
40
|
+
hideCursor,
|
|
41
|
+
clearOnComplete,
|
|
42
|
+
stopOnComplete: true,
|
|
43
|
+
linewrap: true,
|
|
44
|
+
noTTYOutput: true,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static stop(): void {
|
|
49
|
+
Spinner.updatesBar.stop();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
static formatter(options: any, params: any, payload: SpinnerPayload): string {
|
|
53
|
+
const status = payload.status.padEnd(12);
|
|
54
|
+
const middle = `${payload.resource} (${payload.id})`.padEnd(40);
|
|
55
|
+
|
|
56
|
+
let prefix = chalk.cyan(payload.prefix ?? '⧗');
|
|
57
|
+
let start = chalk.cyan(status);
|
|
58
|
+
let end = chalk.yellow(payload.end ?? '');
|
|
59
|
+
|
|
60
|
+
if (status.toLowerCase().trim() === 'pushed') {
|
|
61
|
+
start = chalk.greenBright.bold(status);
|
|
62
|
+
prefix = chalk.greenBright.bold('✓');
|
|
63
|
+
end = '';
|
|
64
|
+
} else if (status.toLowerCase().trim() === 'deploying') {
|
|
65
|
+
start = chalk.cyanBright.bold(status);
|
|
66
|
+
} else if (status.toLowerCase().trim() === 'deployed') {
|
|
67
|
+
start = chalk.green.bold(status);
|
|
68
|
+
prefix = chalk.green.bold('✓');
|
|
69
|
+
} else if (status.toLowerCase().trim() === 'error') {
|
|
70
|
+
start = chalk.red.bold(status);
|
|
71
|
+
prefix = chalk.red.bold('✗');
|
|
72
|
+
end = chalk.red(payload.errorMessage ?? '');
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return Spinner.line(prefix, start, middle, end);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
static line(prefix: string, start: string, middle: string, end: string, separator: string = '•'): string {
|
|
79
|
+
return `${prefix} ${start} ${separator} ${middle} ${!end ? '' : separator} ${end}`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
constructor(payload: SpinnerPayload, total: number = 100, startValue: number = 0) {
|
|
83
|
+
this.bar = Spinner.updatesBar.create(total, startValue, payload);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
update(payload: Partial<SpinnerPayload>): this {
|
|
87
|
+
this.bar.update(payload);
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
fail(payload: Partial<SpinnerPayload>): void {
|
|
92
|
+
this.stopSpinner();
|
|
93
|
+
this.update({ status: 'Error', ...payload });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
startSpinner(name: string): void {
|
|
97
|
+
let spinnerFrame = 1;
|
|
98
|
+
const spinner = spinners[name] ?? spinners['dots'];
|
|
99
|
+
|
|
100
|
+
this.spinnerInterval = setInterval(() => {
|
|
101
|
+
if (spinnerFrame === spinner.frames.length) spinnerFrame = 1;
|
|
102
|
+
this.bar.update({ prefix: spinner.frames[spinnerFrame++] });
|
|
103
|
+
}, spinner.interval);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
stopSpinner(): void {
|
|
107
|
+
if (this.spinnerInterval) {
|
|
108
|
+
clearInterval(this.spinnerInterval);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
replaceSpinner(name: string): void {
|
|
113
|
+
this.stopSpinner();
|
|
114
|
+
this.startSpinner(name);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export { Spinner, SPINNER_ARC, SPINNER_DOTS };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const AttributeType = {
|
|
2
|
+
STRING: 'string',
|
|
3
|
+
INTEGER: 'integer',
|
|
4
|
+
FLOAT: 'double',
|
|
5
|
+
BOOLEAN: 'boolean',
|
|
6
|
+
DATETIME: 'datetime',
|
|
7
|
+
EMAIL: 'email',
|
|
8
|
+
IP: 'ip',
|
|
9
|
+
URL: 'url',
|
|
10
|
+
ENUM: 'enum',
|
|
11
|
+
RELATIONSHIP: 'relationship',
|
|
12
|
+
POINT: 'point',
|
|
13
|
+
LINESTRING: 'linestring',
|
|
14
|
+
POLYGON: 'polygon',
|
|
15
|
+
} as const;
|
|
16
|
+
|
|
17
|
+
export type AttributeTypeValue = typeof AttributeType[keyof typeof AttributeType];
|
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { LanguageMeta } = require("./language");
|
|
1
|
+
import { AttributeType } from '../attribute';
|
|
2
|
+
import { LanguageMeta, Attribute, Collection } from './language';
|
|
4
3
|
|
|
5
|
-
class CSharp extends LanguageMeta {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
export class CSharp extends LanguageMeta {
|
|
5
|
+
getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string {
|
|
6
|
+
let type = '';
|
|
7
|
+
switch (attribute.type) {
|
|
8
|
+
case AttributeType.STRING:
|
|
9
|
+
case AttributeType.EMAIL:
|
|
10
|
+
case AttributeType.DATETIME:
|
|
11
|
+
type = 'string';
|
|
12
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
13
|
+
type = LanguageMeta.toPascalCase(collectionName!) + LanguageMeta.toPascalCase(attribute.key);
|
|
14
|
+
}
|
|
15
|
+
break;
|
|
16
|
+
case AttributeType.INTEGER:
|
|
17
|
+
type = 'long';
|
|
18
|
+
break;
|
|
19
|
+
case AttributeType.FLOAT:
|
|
20
|
+
type = 'double';
|
|
21
|
+
break;
|
|
22
|
+
case AttributeType.BOOLEAN:
|
|
23
|
+
type = 'bool';
|
|
24
|
+
break;
|
|
25
|
+
case AttributeType.RELATIONSHIP:
|
|
26
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
27
|
+
if (!relatedCollection) {
|
|
28
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
29
|
+
}
|
|
30
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
31
|
+
if (
|
|
32
|
+
(attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
33
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
34
|
+
attribute.relationType === 'manyToMany'
|
|
35
|
+
) {
|
|
36
|
+
type = `List<${type}>`;
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case AttributeType.POINT:
|
|
40
|
+
type = 'List<double>';
|
|
41
|
+
break;
|
|
42
|
+
case AttributeType.LINESTRING:
|
|
43
|
+
type = 'List<List<double>>';
|
|
44
|
+
break;
|
|
45
|
+
case AttributeType.POLYGON:
|
|
46
|
+
type = 'List<List<List<double>>>';
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
15
50
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type = "long";
|
|
19
|
-
break;
|
|
20
|
-
case AttributeType.FLOAT:
|
|
21
|
-
type = "double";
|
|
22
|
-
break;
|
|
23
|
-
case AttributeType.BOOLEAN:
|
|
24
|
-
type = "bool";
|
|
25
|
-
break;
|
|
26
|
-
case AttributeType.RELATIONSHIP:
|
|
27
|
-
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
-
if (!relatedCollection) {
|
|
29
|
-
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
51
|
+
if (attribute.array) {
|
|
52
|
+
type = `List<${type}>`;
|
|
30
53
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type = `List<${type}>`;
|
|
54
|
+
if (!attribute.required) {
|
|
55
|
+
type += '?';
|
|
34
56
|
}
|
|
35
|
-
|
|
36
|
-
default:
|
|
37
|
-
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
38
|
-
}
|
|
39
|
-
if (attribute.array) {
|
|
40
|
-
type = `List<${type}>`;
|
|
57
|
+
return type;
|
|
41
58
|
}
|
|
42
|
-
if (!attribute.required) {
|
|
43
|
-
type += "?";
|
|
44
|
-
}
|
|
45
|
-
return type;
|
|
46
|
-
}
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
60
|
+
getTemplate(): string {
|
|
61
|
+
return `/// This file is auto-generated by the Appwrite CLI.
|
|
50
62
|
/// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
51
63
|
|
|
52
64
|
#nullable enable
|
|
@@ -160,11 +172,10 @@ public class <%= toPascalCase(collection.name) %>
|
|
|
160
172
|
}
|
|
161
173
|
}
|
|
162
174
|
`;
|
|
163
|
-
|
|
175
|
+
}
|
|
164
176
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
getFileName(collection: Collection): string {
|
|
178
|
+
return LanguageMeta.toPascalCase(collection.name) + '.cs';
|
|
179
|
+
}
|
|
168
180
|
}
|
|
169
181
|
|
|
170
|
-
module.exports = { CSharp };
|
|
@@ -1,89 +1,101 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import fs = require('fs');
|
|
2
|
+
import path = require('path');
|
|
3
|
+
import { AttributeType } from '../attribute';
|
|
4
|
+
import { LanguageMeta, Attribute, Collection } from './language';
|
|
5
|
+
|
|
6
|
+
export class Dart extends LanguageMeta {
|
|
7
|
+
getPackageName(): string {
|
|
8
|
+
const pubspecPath = path.join(process.cwd(), 'pubspec.yaml');
|
|
9
|
+
if (fs.existsSync(pubspecPath)) {
|
|
10
|
+
const pubspecContent = fs.readFileSync(pubspecPath, 'utf8');
|
|
11
|
+
const lines = pubspecContent.split('\n');
|
|
12
|
+
|
|
13
|
+
const dependenciesIndex = lines.findIndex((line) => line.trim() === 'dependencies:');
|
|
14
|
+
|
|
15
|
+
if (dependenciesIndex !== -1) {
|
|
16
|
+
const indent = lines[dependenciesIndex].search(/\S|$/);
|
|
17
|
+
const dependencies: string[] = [];
|
|
18
|
+
for (let i = dependenciesIndex + 1; i < lines.length; i++) {
|
|
19
|
+
const line = lines[i];
|
|
20
|
+
if (line.trim() === '') continue;
|
|
21
|
+
|
|
22
|
+
const lineIndent = line.search(/\S|$/);
|
|
23
|
+
if (lineIndent <= indent && line.trim() !== '') {
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
dependencies.push(line.trim());
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
dependencies.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (dependencies.some(dep => dep.startsWith('appwrite:'))) {
|
|
35
|
-
return 'appwrite';
|
|
30
|
+
if (dependencies.some((dep) => dep.startsWith('dart_appwrite:'))) {
|
|
31
|
+
return 'dart_appwrite';
|
|
32
|
+
}
|
|
33
|
+
if (dependencies.some((dep) => dep.startsWith('appwrite:'))) {
|
|
34
|
+
return 'appwrite';
|
|
35
|
+
}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
}
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
return 'appwrite';
|
|
40
|
+
}
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string {
|
|
43
|
+
let type = '';
|
|
44
|
+
switch (attribute.type) {
|
|
45
|
+
case AttributeType.STRING:
|
|
46
|
+
case AttributeType.EMAIL:
|
|
47
|
+
case AttributeType.DATETIME:
|
|
48
|
+
type = 'String';
|
|
49
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
50
|
+
type = LanguageMeta.toPascalCase(collectionName!) + LanguageMeta.toPascalCase(attribute.key);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case AttributeType.INTEGER:
|
|
54
|
+
type = 'int';
|
|
55
|
+
break;
|
|
56
|
+
case AttributeType.FLOAT:
|
|
57
|
+
type = 'double';
|
|
58
|
+
break;
|
|
59
|
+
case AttributeType.BOOLEAN:
|
|
60
|
+
type = 'bool';
|
|
61
|
+
break;
|
|
62
|
+
case AttributeType.RELATIONSHIP:
|
|
63
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
64
|
+
if (!relatedCollection) {
|
|
65
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
66
|
+
}
|
|
67
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
68
|
+
if (
|
|
69
|
+
(attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
70
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
71
|
+
attribute.relationType === 'manyToMany'
|
|
72
|
+
) {
|
|
73
|
+
type = `List<${type}>`;
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
case AttributeType.POINT:
|
|
77
|
+
type = 'List<double>';
|
|
78
|
+
break;
|
|
79
|
+
case AttributeType.LINESTRING:
|
|
80
|
+
type = 'List<List<double>>';
|
|
81
|
+
break;
|
|
82
|
+
case AttributeType.POLYGON:
|
|
83
|
+
type = 'List<List<List<double>>>';
|
|
84
|
+
break;
|
|
85
|
+
default:
|
|
86
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
52
87
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
type = "int";
|
|
56
|
-
break;
|
|
57
|
-
case AttributeType.FLOAT:
|
|
58
|
-
type = "double";
|
|
59
|
-
break;
|
|
60
|
-
case AttributeType.BOOLEAN:
|
|
61
|
-
type = "bool";
|
|
62
|
-
break;
|
|
63
|
-
case AttributeType.RELATIONSHIP:
|
|
64
|
-
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
65
|
-
if (!relatedCollection) {
|
|
66
|
-
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
88
|
+
if (attribute.array) {
|
|
89
|
+
type = `List<${type}>`;
|
|
67
90
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
type = `List<${type}>`;
|
|
91
|
+
if (!attribute.required) {
|
|
92
|
+
type += '?';
|
|
71
93
|
}
|
|
72
|
-
|
|
73
|
-
default:
|
|
74
|
-
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
75
|
-
}
|
|
76
|
-
if (attribute.array) {
|
|
77
|
-
type = `List<${type}>`;
|
|
94
|
+
return type;
|
|
78
95
|
}
|
|
79
|
-
if (!attribute.required) {
|
|
80
|
-
type += "?";
|
|
81
|
-
}
|
|
82
|
-
return type;
|
|
83
|
-
}
|
|
84
96
|
|
|
85
|
-
|
|
86
|
-
|
|
97
|
+
getTemplate(): string {
|
|
98
|
+
return `// This file is auto-generated by the Appwrite CLI.
|
|
87
99
|
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
88
100
|
<% const __relatedImportsSeen = new Set();
|
|
89
101
|
const sortedAttributes = collection.attributes.slice().sort((a, b) => {
|
|
@@ -183,11 +195,10 @@ map['<%= attribute.key %>'] != null ? <%- toPascalCase(collections.find(c => c.$
|
|
|
183
195
|
}
|
|
184
196
|
}
|
|
185
197
|
`;
|
|
186
|
-
|
|
198
|
+
}
|
|
187
199
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
200
|
+
getFileName(collection: Collection): string {
|
|
201
|
+
return LanguageMeta.toSnakeCase(collection.name) + '.dart';
|
|
202
|
+
}
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
module.exports = { Dart };
|
|
@@ -1,49 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { AttributeType } from '../attribute';
|
|
2
|
+
import { LanguageMeta, Attribute, Collection } from './language';
|
|
3
|
+
|
|
4
|
+
export class Java extends LanguageMeta {
|
|
5
|
+
getType(attribute: Attribute, collections?: Collection[], collectionName?: string): string {
|
|
6
|
+
let type = '';
|
|
7
|
+
switch (attribute.type) {
|
|
8
|
+
case AttributeType.STRING:
|
|
9
|
+
case AttributeType.EMAIL:
|
|
10
|
+
case AttributeType.DATETIME:
|
|
11
|
+
type = 'String';
|
|
12
|
+
if (attribute.format === AttributeType.ENUM) {
|
|
13
|
+
type = LanguageMeta.toPascalCase(collectionName!) + LanguageMeta.toPascalCase(attribute.key);
|
|
14
|
+
}
|
|
15
|
+
break;
|
|
16
|
+
case AttributeType.INTEGER:
|
|
17
|
+
type = 'Integer';
|
|
18
|
+
break;
|
|
19
|
+
case AttributeType.FLOAT:
|
|
20
|
+
type = 'Double';
|
|
21
|
+
break;
|
|
22
|
+
case AttributeType.BOOLEAN:
|
|
23
|
+
type = 'Boolean';
|
|
24
|
+
break;
|
|
25
|
+
case AttributeType.RELATIONSHIP:
|
|
26
|
+
const relatedCollection = collections?.find((c) => c.$id === attribute.relatedCollection);
|
|
27
|
+
if (!relatedCollection) {
|
|
28
|
+
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
29
|
+
}
|
|
30
|
+
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
31
|
+
if (
|
|
32
|
+
(attribute.relationType === 'oneToMany' && attribute.side === 'parent') ||
|
|
33
|
+
(attribute.relationType === 'manyToOne' && attribute.side === 'child') ||
|
|
34
|
+
attribute.relationType === 'manyToMany'
|
|
35
|
+
) {
|
|
36
|
+
type = 'List<' + type + '>';
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case AttributeType.POINT:
|
|
40
|
+
type = 'List<Double>';
|
|
41
|
+
break;
|
|
42
|
+
case AttributeType.LINESTRING:
|
|
43
|
+
type = 'List<List<Double>>';
|
|
44
|
+
break;
|
|
45
|
+
case AttributeType.POLYGON:
|
|
46
|
+
type = 'List<List<List<Double>>>';
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
15
50
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type = "int";
|
|
19
|
-
break;
|
|
20
|
-
case AttributeType.FLOAT:
|
|
21
|
-
type = "double";
|
|
22
|
-
break;
|
|
23
|
-
case AttributeType.BOOLEAN:
|
|
24
|
-
type = "boolean";
|
|
25
|
-
break;
|
|
26
|
-
case AttributeType.RELATIONSHIP:
|
|
27
|
-
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
28
|
-
if (!relatedCollection) {
|
|
29
|
-
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
51
|
+
if (attribute.array) {
|
|
52
|
+
type = 'List<' + type + '>';
|
|
30
53
|
}
|
|
31
|
-
type
|
|
32
|
-
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
33
|
-
type = "List<" + type + ">";
|
|
34
|
-
}
|
|
35
|
-
break;
|
|
36
|
-
default:
|
|
37
|
-
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
38
|
-
}
|
|
39
|
-
if (attribute.array) {
|
|
40
|
-
type = "List<" + type + ">";
|
|
54
|
+
return type;
|
|
41
55
|
}
|
|
42
|
-
return type;
|
|
43
|
-
}
|
|
44
56
|
|
|
45
|
-
|
|
46
|
-
|
|
57
|
+
getTemplate(): string {
|
|
58
|
+
return `package io.appwrite.models;
|
|
47
59
|
|
|
48
60
|
/**
|
|
49
61
|
* This file is auto-generated by the Appwrite CLI.
|
|
@@ -120,11 +132,10 @@ public class <%- toPascalCase(collection.name) %> {
|
|
|
120
132
|
}
|
|
121
133
|
}
|
|
122
134
|
`;
|
|
123
|
-
|
|
135
|
+
}
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
getFileName(collection: Collection): string {
|
|
138
|
+
return LanguageMeta.toPascalCase(collection.name) + '.java';
|
|
139
|
+
}
|
|
128
140
|
}
|
|
129
141
|
|
|
130
|
-
module.exports = { Java };
|