appwrite-cli 12.0.1 → 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 +4 -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} +408 -662
- 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} +118 -174
- 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 -57
- package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
- package/lib/type-generation/languages/{java.js → java.ts} +58 -56
- 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 -53
- package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
- 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 -19
- package/lib/type-generation/languages/javascript.js +0 -111
- package/lib/type-generation/languages/kotlin.js +0 -94
- package/lib/type-generation/languages/language.js +0 -125
- package/lib/type-generation/languages/typescript.js +0 -116
- package/lib/validations.js +0 -17
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
const { sdkForProject } = require('../sdks')
|
|
2
|
-
const { parse } = require('../parser')
|
|
3
|
-
const { showConsoleLink } = require('../utils.js');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {Object} OrganizationsListRequestParams
|
|
7
|
-
* @property {string[]} 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: name, total, billingPlan
|
|
8
|
-
* @property {string} search Search term to filter your list results. Max length: 256 chars.
|
|
9
|
-
* @property {boolean} parseOutput
|
|
10
|
-
* @property {libClient | undefined} sdk
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @param {OrganizationsListRequestParams} params
|
|
15
|
-
*/
|
|
16
|
-
const organizationsList = async ({queries, search, parseOutput = true, sdk = undefined, console}) => {
|
|
17
|
-
let client = !sdk ? await sdkForProject() :
|
|
18
|
-
sdk;
|
|
19
|
-
let apiPath = '/organizations';
|
|
20
|
-
let payload = {};
|
|
21
|
-
if (typeof queries !== 'undefined') {
|
|
22
|
-
payload['queries'] = queries;
|
|
23
|
-
}
|
|
24
|
-
if (typeof search !== 'undefined') {
|
|
25
|
-
payload['search'] = search;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
let response = undefined;
|
|
29
|
-
|
|
30
|
-
response = await client.call('get', apiPath, {
|
|
31
|
-
'content-type': 'application/json',
|
|
32
|
-
}, payload);
|
|
33
|
-
|
|
34
|
-
if (parseOutput) {
|
|
35
|
-
if(console) {
|
|
36
|
-
showConsoleLink('organizations', 'list');
|
|
37
|
-
} else {
|
|
38
|
-
parse(response)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return response;
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
module.exports = {
|
|
47
|
-
organizationsList
|
|
48
|
-
}
|
package/lib/emulation/utils.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
const EventEmitter = require('node:events');
|
|
2
|
-
const { projectsCreateJWT } = require('../commands/projects');
|
|
3
|
-
const { localConfig } = require("../config");
|
|
4
|
-
const { usersGet, usersCreateJWT } = require("../commands/users");
|
|
5
|
-
const { log } = require("../parser");
|
|
6
|
-
|
|
7
|
-
const openRuntimesVersion = 'v4';
|
|
8
|
-
|
|
9
|
-
const runtimeNames = {
|
|
10
|
-
'node': 'Node.js',
|
|
11
|
-
'php': 'PHP',
|
|
12
|
-
'ruby': 'Ruby',
|
|
13
|
-
'python': 'Python',
|
|
14
|
-
'python-ml': 'Python (ML)',
|
|
15
|
-
'deno': 'Deno',
|
|
16
|
-
'dart': 'Dart',
|
|
17
|
-
'dotnet': '.NET',
|
|
18
|
-
'java': 'Java',
|
|
19
|
-
'swift': 'Swift',
|
|
20
|
-
'kotlin': 'Kotlin',
|
|
21
|
-
'bun': 'Bun',
|
|
22
|
-
'go': 'Go',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const systemTools = {
|
|
26
|
-
'node': {
|
|
27
|
-
isCompiled: false,
|
|
28
|
-
startCommand: "sh helpers/server.sh",
|
|
29
|
-
dependencyFiles: [ "package.json", "package-lock.json" ]
|
|
30
|
-
},
|
|
31
|
-
'php': {
|
|
32
|
-
isCompiled: false,
|
|
33
|
-
startCommand: "sh helpers/server.sh",
|
|
34
|
-
dependencyFiles: [ "composer.json", "composer.lock" ]
|
|
35
|
-
},
|
|
36
|
-
'ruby': {
|
|
37
|
-
isCompiled: false,
|
|
38
|
-
startCommand: "sh helpers/server.sh",
|
|
39
|
-
dependencyFiles: [ "Gemfile", "Gemfile.lock" ]
|
|
40
|
-
},
|
|
41
|
-
'python': {
|
|
42
|
-
isCompiled: false,
|
|
43
|
-
startCommand: "sh helpers/server.sh",
|
|
44
|
-
dependencyFiles: [ "requirements.txt", "requirements.lock" ]
|
|
45
|
-
},
|
|
46
|
-
'python-ml': {
|
|
47
|
-
isCompiled: false,
|
|
48
|
-
startCommand: "sh helpers/server.sh",
|
|
49
|
-
dependencyFiles: [ "requirements.txt", "requirements.lock" ]
|
|
50
|
-
},
|
|
51
|
-
'deno': {
|
|
52
|
-
isCompiled: false,
|
|
53
|
-
startCommand: "sh helpers/server.sh",
|
|
54
|
-
dependencyFiles: [ ]
|
|
55
|
-
},
|
|
56
|
-
'dart': {
|
|
57
|
-
isCompiled: true,
|
|
58
|
-
startCommand: "sh helpers/server.sh",
|
|
59
|
-
dependencyFiles: [ ]
|
|
60
|
-
},
|
|
61
|
-
'dotnet': {
|
|
62
|
-
isCompiled: true,
|
|
63
|
-
startCommand: "sh helpers/server.sh",
|
|
64
|
-
dependencyFiles: [ ]
|
|
65
|
-
},
|
|
66
|
-
'java': {
|
|
67
|
-
isCompiled: true,
|
|
68
|
-
startCommand: "sh helpers/server.sh",
|
|
69
|
-
dependencyFiles: [ ]
|
|
70
|
-
},
|
|
71
|
-
'swift': {
|
|
72
|
-
isCompiled: true,
|
|
73
|
-
startCommand: "sh helpers/server.sh",
|
|
74
|
-
dependencyFiles: [ ]
|
|
75
|
-
},
|
|
76
|
-
'kotlin': {
|
|
77
|
-
isCompiled: true,
|
|
78
|
-
startCommand: "sh helpers/server.sh",
|
|
79
|
-
dependencyFiles: [ ]
|
|
80
|
-
},
|
|
81
|
-
'bun': {
|
|
82
|
-
isCompiled: false,
|
|
83
|
-
startCommand: "sh helpers/server.sh",
|
|
84
|
-
dependencyFiles: [ "package.json", "package-lock.json", "bun.lockb" ]
|
|
85
|
-
},
|
|
86
|
-
'go': {
|
|
87
|
-
isCompiled: true,
|
|
88
|
-
startCommand: "sh helpers/server.sh",
|
|
89
|
-
dependencyFiles: [ ]
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const JwtManager = {
|
|
94
|
-
userJwt: null,
|
|
95
|
-
functionJwt: null,
|
|
96
|
-
|
|
97
|
-
timerWarn: null,
|
|
98
|
-
timerError: null,
|
|
99
|
-
|
|
100
|
-
async setup(userId = null, projectScopes = []) {
|
|
101
|
-
if(this.timerWarn) {
|
|
102
|
-
clearTimeout(this.timerWarn);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if(this.timerError) {
|
|
106
|
-
clearTimeout(this.timerError);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
this.timerWarn = setTimeout(() => {
|
|
110
|
-
log("Warning: Authorized JWT will expire in 5 minutes. Please stop and re-run the command to refresh tokens for 1 hour.");
|
|
111
|
-
}, 1000 * 60 * 55); // 55 mins
|
|
112
|
-
|
|
113
|
-
this.timerError = setTimeout(() => {
|
|
114
|
-
log("Warning: Authorized JWT just expired. Please stop and re-run the command to obtain new tokens with 1 hour validity.");
|
|
115
|
-
log("Some Appwrite API communication is not authorized now.")
|
|
116
|
-
}, 1000 * 60 * 60); // 60 mins
|
|
117
|
-
|
|
118
|
-
if(userId) {
|
|
119
|
-
await usersGet({
|
|
120
|
-
userId,
|
|
121
|
-
parseOutput: false
|
|
122
|
-
});
|
|
123
|
-
const userResponse = await usersCreateJWT({
|
|
124
|
-
userId,
|
|
125
|
-
duration: 60*60,
|
|
126
|
-
parseOutput: false
|
|
127
|
-
});
|
|
128
|
-
this.userJwt = userResponse.jwt;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const functionResponse = await projectsCreateJWT({
|
|
132
|
-
projectId: localConfig.getProject().projectId,
|
|
133
|
-
scopes: projectScopes,
|
|
134
|
-
duration: 60*60,
|
|
135
|
-
parseOutput: false
|
|
136
|
-
});
|
|
137
|
-
this.functionJwt = functionResponse.jwt;
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const Queue = {
|
|
142
|
-
files: [],
|
|
143
|
-
locked: false,
|
|
144
|
-
events: new EventEmitter(),
|
|
145
|
-
debounce: null,
|
|
146
|
-
push(file) {
|
|
147
|
-
if(!this.files.includes(file)) {
|
|
148
|
-
this.files.push(file);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if(!this.locked) {
|
|
152
|
-
this._trigger();
|
|
153
|
-
}
|
|
154
|
-
},
|
|
155
|
-
lock() {
|
|
156
|
-
this.files = [];
|
|
157
|
-
this.locked = true;
|
|
158
|
-
},
|
|
159
|
-
isEmpty() {
|
|
160
|
-
return this.files.length === 0
|
|
161
|
-
},
|
|
162
|
-
unlock() {
|
|
163
|
-
this.locked = false;
|
|
164
|
-
if(this.files.length > 0) {
|
|
165
|
-
this._trigger();
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
_trigger() {
|
|
169
|
-
if(this.debounce) {
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
this.debounce = setTimeout(() => {
|
|
174
|
-
this.events.emit('reload', { files: this.files });
|
|
175
|
-
this.debounce = null;
|
|
176
|
-
}, 300);
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
module.exports = {
|
|
181
|
-
openRuntimesVersion,
|
|
182
|
-
runtimeNames,
|
|
183
|
-
systemTools,
|
|
184
|
-
JwtManager,
|
|
185
|
-
Queue
|
|
186
|
-
}
|
package/lib/exception.js
DELETED
package/lib/parser.js
DELETED
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
const commander = require('commander');
|
|
3
|
-
const Table = require('cli-table3');
|
|
4
|
-
const { description } = require('../package.json');
|
|
5
|
-
const { globalConfig } = require("./config.js");
|
|
6
|
-
const os = require('os');
|
|
7
|
-
const Client = require("./client");
|
|
8
|
-
const { isCloud } = require("./utils");
|
|
9
|
-
|
|
10
|
-
const cliConfig = {
|
|
11
|
-
verbose: false,
|
|
12
|
-
json: false,
|
|
13
|
-
force: false,
|
|
14
|
-
all: false,
|
|
15
|
-
ids: [],
|
|
16
|
-
report: false,
|
|
17
|
-
reportData: {}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const parse = (data) => {
|
|
21
|
-
if (cliConfig.json) {
|
|
22
|
-
drawJSON(data);
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for (let key in data) {
|
|
27
|
-
if (data[key] === null) {
|
|
28
|
-
console.log(`${chalk.yellow.bold(key)} : null`);
|
|
29
|
-
} else if (Array.isArray(data[key])) {
|
|
30
|
-
console.log(`${chalk.yellow.bold.underline(key)}`);
|
|
31
|
-
if (typeof data[key][0] === 'object') {
|
|
32
|
-
drawTable(data[key]);
|
|
33
|
-
} else {
|
|
34
|
-
drawJSON(data[key]);
|
|
35
|
-
}
|
|
36
|
-
} else if (typeof data[key] === 'object') {
|
|
37
|
-
if (data[key]?.constructor?.name === 'BigNumber') {
|
|
38
|
-
console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
|
|
39
|
-
} else {
|
|
40
|
-
console.log(`${chalk.yellow.bold.underline(key)}`)
|
|
41
|
-
drawTable([data[key]]);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
console.log(`${chalk.yellow.bold(key)} : ${data[key]}`);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const drawTable = (data) => {
|
|
50
|
-
if (data.length == 0) {
|
|
51
|
-
console.log("[]")
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Create an object with all the keys in it
|
|
56
|
-
let obj = data.reduce((res, item) => ({ ...res, ...item }));
|
|
57
|
-
// Get those keys as an array
|
|
58
|
-
let keys = Object.keys(obj);
|
|
59
|
-
// Create an object with all keys set to the default value ''
|
|
60
|
-
let def = keys.reduce((result, key) => {
|
|
61
|
-
result[key] = '-'
|
|
62
|
-
return result;
|
|
63
|
-
}, {});
|
|
64
|
-
// Use object destrucuring to replace all default values with the ones we have
|
|
65
|
-
data = data.map((item) => ({ ...def, ...item }));
|
|
66
|
-
|
|
67
|
-
let columns = Object.keys(data[0]);
|
|
68
|
-
|
|
69
|
-
let table = new Table({
|
|
70
|
-
head: columns.map(c => chalk.cyan.italic.bold(c)),
|
|
71
|
-
chars: {
|
|
72
|
-
'top': ' ',
|
|
73
|
-
'top-mid': ' ',
|
|
74
|
-
'top-left': ' ',
|
|
75
|
-
'top-right': ' ',
|
|
76
|
-
'bottom': ' ',
|
|
77
|
-
'bottom-mid': ' ',
|
|
78
|
-
'bottom-left': ' ',
|
|
79
|
-
'bottom-right': ' ',
|
|
80
|
-
'left': ' ',
|
|
81
|
-
'left-mid': ' ',
|
|
82
|
-
'mid': chalk.cyan('─'),
|
|
83
|
-
'mid-mid': chalk.cyan('┼'),
|
|
84
|
-
'right': ' ',
|
|
85
|
-
'right-mid': ' ',
|
|
86
|
-
'middle': chalk.cyan('│')
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
data.forEach(row => {
|
|
91
|
-
let rowValues = [];
|
|
92
|
-
for (let key in row) {
|
|
93
|
-
if (row[key] === null) {
|
|
94
|
-
rowValues.push("-");
|
|
95
|
-
} else if (Array.isArray(row[key])) {
|
|
96
|
-
rowValues.push(JSON.stringify(row[key]));
|
|
97
|
-
} else if (typeof row[key] === 'object') {
|
|
98
|
-
rowValues.push(JSON.stringify(row[key]));
|
|
99
|
-
} else {
|
|
100
|
-
rowValues.push(row[key]);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
table.push(rowValues);
|
|
104
|
-
});
|
|
105
|
-
console.log(table.toString());
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
const drawJSON = (data) => {
|
|
109
|
-
console.log(JSON.stringify(data, null, 2));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const parseError = (err) => {
|
|
113
|
-
if (cliConfig.report) {
|
|
114
|
-
(async () => {
|
|
115
|
-
let appwriteVersion = 'unknown';
|
|
116
|
-
const endpoint = globalConfig.getEndpoint();
|
|
117
|
-
|
|
118
|
-
try {
|
|
119
|
-
const client = new Client().setEndpoint(endpoint);
|
|
120
|
-
const res = await client.call('get', '/health/version');
|
|
121
|
-
appwriteVersion = res.version;
|
|
122
|
-
} catch {
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const version = '12.0.1';
|
|
126
|
-
const stepsToReproduce = `Running \`appwrite ${cliConfig.reportData.data.args.join(' ')}\``;
|
|
127
|
-
const yourEnvironment = `CLI version: ${version}\nOperation System: ${os.type()}\nAppwrite version: ${appwriteVersion}\nIs Cloud: ${isCloud()}`;
|
|
128
|
-
|
|
129
|
-
const stack = '```\n' + err.stack + '\n```';
|
|
130
|
-
|
|
131
|
-
const githubIssueUrl = new URL('https://github.com/appwrite/appwrite/issues/new');
|
|
132
|
-
githubIssueUrl.searchParams.append('labels', 'bug');
|
|
133
|
-
githubIssueUrl.searchParams.append('template', 'bug.yaml');
|
|
134
|
-
githubIssueUrl.searchParams.append('title', `🐛 Bug Report: ${err.message}`);
|
|
135
|
-
githubIssueUrl.searchParams.append('actual-behavior', `CLI Error:\n${stack}`);
|
|
136
|
-
githubIssueUrl.searchParams.append('steps-to-reproduce', stepsToReproduce);
|
|
137
|
-
githubIssueUrl.searchParams.append('environment', yourEnvironment);
|
|
138
|
-
|
|
139
|
-
log(`To report this error you can:\n - Create a support ticket in our Discord server https://appwrite.io/discord \n - Create an issue in our Github\n ${githubIssueUrl.href}\n`);
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
error('\n Stack Trace: \n');
|
|
143
|
-
console.error(err);
|
|
144
|
-
process.exit(1);
|
|
145
|
-
})()
|
|
146
|
-
} else {
|
|
147
|
-
if (cliConfig.verbose) {
|
|
148
|
-
console.error(err);
|
|
149
|
-
} else {
|
|
150
|
-
log('For detailed error pass the --verbose or --report flag');
|
|
151
|
-
error(err.message);
|
|
152
|
-
}
|
|
153
|
-
process.exit(1);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
const actionRunner = (fn) => {
|
|
159
|
-
return (...args) => {
|
|
160
|
-
if (cliConfig.all && (Array.isArray(cliConfig.ids) && cliConfig.ids.length !== 0)) {
|
|
161
|
-
error(`The '--all' and '--id' flags cannot be used together.`);
|
|
162
|
-
process.exit(1);
|
|
163
|
-
}
|
|
164
|
-
return fn(...args).catch(parseError)
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const parseInteger = (value) => {
|
|
169
|
-
const parsedValue = parseInt(value, 10);
|
|
170
|
-
if (isNaN(parsedValue)) {
|
|
171
|
-
throw new commander.InvalidArgumentError('Not a number.');
|
|
172
|
-
}
|
|
173
|
-
return parsedValue;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const parseBool = (value) => {
|
|
177
|
-
if (value === 'true') return true;
|
|
178
|
-
if (value === 'false') return false;
|
|
179
|
-
throw new commander.InvalidArgumentError('Not a boolean.');
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const log = (message) => {
|
|
183
|
-
console.log(`${chalk.cyan.bold("ℹ Info:")} ${chalk.cyan(message ?? "")}`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const warn = (message) => {
|
|
187
|
-
console.log(`${chalk.yellow.bold("ℹ Warning:")} ${chalk.yellow(message ?? "")}`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const hint = (message) => {
|
|
191
|
-
console.log(`${chalk.cyan.bold("♥ Hint:")} ${chalk.cyan(message ?? "")}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const success = (message) => {
|
|
195
|
-
console.log(`${chalk.green.bold("✓ Success:")} ${chalk.green(message ?? "")}`);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
const error = (message) => {
|
|
199
|
-
console.error(`${chalk.red.bold("✗ Error:")} ${chalk.red(message ?? "")}`);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const logo = "\n _ _ _ ___ __ _____\n \/_\\ _ __ _ ____ ___ __(_) |_ ___ \/ __\\ \/ \/ \\_ \\\n \/\/_\\\\| '_ \\| '_ \\ \\ \/\\ \/ \/ '__| | __\/ _ \\ \/ \/ \/ \/ \/ \/\\\/\n \/ _ \\ |_) | |_) \\ V V \/| | | | || __\/ \/ \/___\/ \/___\/\\\/ \/_\n \\_\/ \\_\/ .__\/| .__\/ \\_\/\\_\/ |_| |_|\\__\\___| \\____\/\\____\/\\____\/\n |_| |_|\n\n";
|
|
203
|
-
|
|
204
|
-
const commandDescriptions = {
|
|
205
|
-
"account": `The account command allows you to authenticate and manage a user account.`,
|
|
206
|
-
"graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
|
|
207
|
-
"avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
|
|
208
|
-
"databases": `(Legacy) The databases command allows you to create structured collections of documents and query and filter lists of documents.`,
|
|
209
|
-
'tables-db': `The tables-db command allows you to create structured tables of columns and query and filter lists of rows.`,
|
|
210
|
-
"init": `The init command provides a convenient wrapper for creating and initializing projects, functions, collections, buckets, teams, and messaging-topics in Appwrite.`,
|
|
211
|
-
"push": `The push command provides a convenient wrapper for pushing your functions, collections, buckets, teams, and messaging-topics.`,
|
|
212
|
-
"run": `The run command allows you to run the project locally to allow easy development and quick debugging.`,
|
|
213
|
-
"functions": `The functions command allows you to view, create, and manage your Cloud Functions.`,
|
|
214
|
-
"health": `The health command allows you to both validate and monitor your Appwrite server's health.`,
|
|
215
|
-
"pull": `The pull command helps you pull your Appwrite project, functions, collections, buckets, teams, and messaging-topics`,
|
|
216
|
-
"locale": `The locale command allows you to customize your app based on your users' location.`,
|
|
217
|
-
"sites": `The sites command allows you to view, create and manage your Appwrite Sites.`,
|
|
218
|
-
"storage": `The storage command allows you to manage your project files.`,
|
|
219
|
-
"teams": `The teams command allows you to group users of your project to enable them to share read and write access to your project resources.`,
|
|
220
|
-
"update": `The update command allows you to update the Appwrite CLI to the latest version.`,
|
|
221
|
-
"users": `The users command allows you to manage your project users.`,
|
|
222
|
-
"projects": `The projects command allows you to manage your projects, add platforms, manage API keys, Dev Keys etc.`,
|
|
223
|
-
"project": `The project command allows you to manage project related resources like usage, variables, etc.`,
|
|
224
|
-
"client": `The client command allows you to configure your CLI`,
|
|
225
|
-
"login": `The login command allows you to authenticate and manage a user account.`,
|
|
226
|
-
"logout": `The logout command allows you to log out of your Appwrite account.`,
|
|
227
|
-
"whoami": `The whomai command gives information about the currently logged-in user.`,
|
|
228
|
-
"register": `Outputs the link to create an Appwrite account.`,
|
|
229
|
-
"console" : `The console command gives you access to the APIs used by the Appwrite Console.`,
|
|
230
|
-
"messaging": `The messaging command allows you to manage topics and targets and send messages.`,
|
|
231
|
-
"migrations": `The migrations command allows you to migrate data between services.`,
|
|
232
|
-
"vcs": `The vcs command allows you to interact with VCS providers and manage your code repositories.`,
|
|
233
|
-
"main": chalk.redBright(`${logo}${description}`),
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
module.exports = {
|
|
237
|
-
drawTable,
|
|
238
|
-
parse,
|
|
239
|
-
actionRunner,
|
|
240
|
-
parseInteger,
|
|
241
|
-
parseBool,
|
|
242
|
-
log,
|
|
243
|
-
warn,
|
|
244
|
-
hint,
|
|
245
|
-
success,
|
|
246
|
-
error,
|
|
247
|
-
commandDescriptions,
|
|
248
|
-
cliConfig,
|
|
249
|
-
drawTable
|
|
250
|
-
}
|
package/lib/sdks.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
const Client = require("./client");
|
|
2
|
-
const { globalConfig, localConfig } = require("./config");
|
|
3
|
-
|
|
4
|
-
const sdkForConsole = async (requiresAuth = true) => {
|
|
5
|
-
let client = new Client();
|
|
6
|
-
let endpoint = globalConfig.getEndpoint();
|
|
7
|
-
let cookie = globalConfig.getCookie()
|
|
8
|
-
let 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
|
-
const sdkForProject = async () => {
|
|
25
|
-
let client = new Client();
|
|
26
|
-
let endpoint = localConfig.getEndpoint() || globalConfig.getEndpoint();
|
|
27
|
-
let project = localConfig.getProject().projectId ? localConfig.getProject().projectId : globalConfig.getProject();
|
|
28
|
-
let key = globalConfig.getKey();
|
|
29
|
-
let cookie = globalConfig.getCookie()
|
|
30
|
-
let 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
|
-
};
|
|
56
|
-
|
|
57
|
-
module.exports = {
|
|
58
|
-
sdkForConsole,
|
|
59
|
-
sdkForProject,
|
|
60
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
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
|
-
};
|
|
16
|
-
|
|
17
|
-
module.exports = {
|
|
18
|
-
AttributeType,
|
|
19
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/** @typedef {import('../attribute').Attribute} Attribute */
|
|
2
|
-
const fs = require("fs");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
|
|
5
|
-
const { AttributeType } = require('../attribute');
|
|
6
|
-
const { LanguageMeta } = require("./language");
|
|
7
|
-
|
|
8
|
-
class JavaScript extends LanguageMeta {
|
|
9
|
-
getType(attribute, collections) {
|
|
10
|
-
let type = ""
|
|
11
|
-
switch (attribute.type) {
|
|
12
|
-
case AttributeType.STRING:
|
|
13
|
-
case AttributeType.EMAIL:
|
|
14
|
-
case AttributeType.DATETIME:
|
|
15
|
-
case AttributeType.IP:
|
|
16
|
-
case AttributeType.URL:
|
|
17
|
-
type = "string";
|
|
18
|
-
if (attribute.format === AttributeType.ENUM) {
|
|
19
|
-
type = LanguageMeta.toPascalCase(attribute.key);
|
|
20
|
-
}
|
|
21
|
-
break;
|
|
22
|
-
case AttributeType.INTEGER:
|
|
23
|
-
type = "number";
|
|
24
|
-
break;
|
|
25
|
-
case AttributeType.FLOAT:
|
|
26
|
-
type = "number";
|
|
27
|
-
break;
|
|
28
|
-
case AttributeType.BOOLEAN:
|
|
29
|
-
type = "boolean";
|
|
30
|
-
break;
|
|
31
|
-
case AttributeType.RELATIONSHIP:
|
|
32
|
-
const relatedCollection = collections.find(c => c.$id === attribute.relatedCollection);
|
|
33
|
-
if (!relatedCollection) {
|
|
34
|
-
throw new Error(`Related collection with ID '${attribute.relatedCollection}' not found.`);
|
|
35
|
-
}
|
|
36
|
-
type = LanguageMeta.toPascalCase(relatedCollection.name);
|
|
37
|
-
if ((attribute.relationType === 'oneToMany' && attribute.side === 'parent') || (attribute.relationType === 'manyToOne' && attribute.side === 'child') || attribute.relationType === 'manyToMany') {
|
|
38
|
-
type = `${type}[]`;
|
|
39
|
-
}
|
|
40
|
-
break;
|
|
41
|
-
case AttributeType.POINT:
|
|
42
|
-
type = "number[]";
|
|
43
|
-
break;
|
|
44
|
-
case AttributeType.LINESTRING:
|
|
45
|
-
type = "number[][]";
|
|
46
|
-
break;
|
|
47
|
-
case AttributeType.POLYGON:
|
|
48
|
-
type = "number[][][]";
|
|
49
|
-
break;
|
|
50
|
-
default:
|
|
51
|
-
throw new Error(`Unknown attribute type: ${attribute.type}`);
|
|
52
|
-
}
|
|
53
|
-
if (attribute.array) {
|
|
54
|
-
type += "[]";
|
|
55
|
-
}
|
|
56
|
-
if (!attribute.required && attribute.default === null) {
|
|
57
|
-
type += " | null";
|
|
58
|
-
}
|
|
59
|
-
return type;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
isSingleFile() {
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
_getAppwriteDependency() {
|
|
67
|
-
if (fs.existsSync(path.resolve(process.cwd(), 'package.json'))) {
|
|
68
|
-
const packageJsonRaw = fs.readFileSync(path.resolve(process.cwd(), 'package.json'));
|
|
69
|
-
const packageJson = JSON.parse(packageJsonRaw.toString('utf-8'));
|
|
70
|
-
return packageJson.dependencies['node-appwrite'] ? 'node-appwrite' : 'appwrite';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return "appwrite";
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
getTemplate() {
|
|
77
|
-
return `/**
|
|
78
|
-
* @typedef {import('${this._getAppwriteDependency()}').Models.Row} Row
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
// This file is auto-generated by the Appwrite CLI.
|
|
82
|
-
// You can regenerate it by running \`appwrite ${process.argv.slice(2).join(' ')}\`.
|
|
83
|
-
|
|
84
|
-
<% for (const collection of collections) { -%>
|
|
85
|
-
<% for (const attribute of collection.attributes) { -%>
|
|
86
|
-
<% if (attribute.format === 'enum') { -%>
|
|
87
|
-
/**
|
|
88
|
-
* @typedef {"<%- attribute.elements.join('"|"') %>"} <%- toPascalCase(attribute.key) %>
|
|
89
|
-
*/
|
|
90
|
-
|
|
91
|
-
<% } -%>
|
|
92
|
-
<% } -%>
|
|
93
|
-
<% } -%>
|
|
94
|
-
<% for (const [index, collection] of Object.entries(collections)) { %>/**
|
|
95
|
-
* @typedef {Row & {
|
|
96
|
-
<% for (const attribute of collection.attributes) { -%>
|
|
97
|
-
* <%- strict ? toCamelCase(attribute.key) : attribute.key %>: <%- getType(attribute, collections) %>;
|
|
98
|
-
<% } -%>
|
|
99
|
-
* }} <%- toPascalCase(collection.name) %>
|
|
100
|
-
*/
|
|
101
|
-
<% if (index < collections.length - 1) { %>
|
|
102
|
-
<% } -%>
|
|
103
|
-
<% } %>`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
getFileName(_) {
|
|
107
|
-
return "appwrite-types.js";
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
module.exports = { JavaScript };
|