appwrite-cli 2.0.1 → 3.0.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.
Files changed (102) hide show
  1. package/README.md +11 -6
  2. package/docs/examples/account/delete-identity.md +2 -0
  3. package/docs/examples/account/list-identities.md +2 -0
  4. package/docs/examples/assistant/chat.md +2 -0
  5. package/docs/examples/databases/create-collection.md +1 -0
  6. package/docs/examples/databases/create-string-attribute.md +1 -0
  7. package/docs/examples/databases/create.md +2 -1
  8. package/docs/examples/databases/list-attributes.md +2 -1
  9. package/docs/examples/databases/list-indexes.md +2 -1
  10. package/docs/examples/databases/update.md +2 -1
  11. package/docs/examples/functions/create-deployment.md +3 -2
  12. package/docs/examples/functions/create-execution.md +3 -0
  13. package/docs/examples/functions/create.md +12 -0
  14. package/docs/examples/functions/download-deployment.md +3 -0
  15. package/docs/examples/functions/update.md +9 -0
  16. package/docs/examples/health/get-pub-sub.md +1 -0
  17. package/docs/examples/health/get-queue.md +1 -0
  18. package/docs/examples/locale/list-codes.md +1 -0
  19. package/docs/examples/migrations/create-appwrite-migration.md +5 -0
  20. package/docs/examples/migrations/create-firebase-migration.md +3 -0
  21. package/docs/examples/migrations/create-firebase-o-auth-migration.md +3 -0
  22. package/docs/examples/migrations/create-n-host-migration.md +9 -0
  23. package/docs/examples/migrations/create-supabase-migration.md +8 -0
  24. package/docs/examples/migrations/delete-firebase-auth.md +1 -0
  25. package/docs/examples/migrations/delete.md +2 -0
  26. package/docs/examples/migrations/get-appwrite-report.md +5 -0
  27. package/docs/examples/migrations/get-firebase-report-o-auth.md +3 -0
  28. package/docs/examples/migrations/get-firebase-report.md +3 -0
  29. package/docs/examples/migrations/get-n-host-report.md +9 -0
  30. package/docs/examples/migrations/get-supabase-report.md +8 -0
  31. package/docs/examples/migrations/get.md +2 -0
  32. package/docs/examples/migrations/list-firebase-projects.md +1 -0
  33. package/docs/examples/migrations/list.md +3 -0
  34. package/docs/examples/migrations/retry.md +2 -0
  35. package/docs/examples/project/create-variable.md +3 -0
  36. package/docs/examples/project/delete-variable.md +2 -0
  37. package/docs/examples/project/get-usage.md +2 -0
  38. package/docs/examples/project/get-variable.md +2 -0
  39. package/docs/examples/project/list-variables.md +1 -0
  40. package/docs/examples/project/update-variable.md +4 -0
  41. package/docs/examples/projects/create.md +1 -1
  42. package/docs/examples/projects/delete-email-template.md +4 -0
  43. package/docs/examples/projects/delete-sms-template.md +4 -0
  44. package/docs/examples/projects/delete.md +1 -2
  45. package/docs/examples/projects/get-email-template.md +4 -0
  46. package/docs/examples/projects/get-sms-template.md +4 -0
  47. package/docs/examples/projects/update-email-template.md +9 -0
  48. package/docs/examples/projects/update-personal-data-check.md +3 -0
  49. package/docs/examples/projects/update-service-status-all.md +3 -0
  50. package/docs/examples/projects/update-sms-template.md +5 -0
  51. package/docs/examples/projects/update-smtp-configuration.md +11 -0
  52. package/docs/examples/projects/update-team.md +3 -0
  53. package/docs/examples/proxy/create-rule.md +4 -0
  54. package/docs/examples/proxy/delete-rule.md +2 -0
  55. package/docs/examples/proxy/get-rule.md +2 -0
  56. package/docs/examples/proxy/list-rules.md +3 -0
  57. package/docs/examples/proxy/update-rule-verification.md +2 -0
  58. package/docs/examples/storage/update-file.md +1 -0
  59. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +1 -1
  60. package/docs/examples/users/delete-identity.md +2 -0
  61. package/docs/examples/users/list-identities.md +3 -0
  62. package/docs/examples/users/update-labels.md +3 -0
  63. package/docs/examples/vcs/create-repository-detection.md +4 -0
  64. package/docs/examples/vcs/create-repository.md +4 -0
  65. package/docs/examples/vcs/delete-installation.md +2 -0
  66. package/docs/examples/vcs/get-installation.md +2 -0
  67. package/docs/examples/vcs/get-repository.md +3 -0
  68. package/docs/examples/vcs/list-installations.md +3 -0
  69. package/docs/examples/vcs/list-repositories.md +3 -0
  70. package/docs/examples/vcs/list-repository-branches.md +3 -0
  71. package/docs/examples/vcs/update-external-deployments.md +4 -0
  72. package/index.js +10 -0
  73. package/install.ps1 +2 -2
  74. package/install.sh +1 -1
  75. package/lib/client.js +3 -3
  76. package/lib/commands/account.js +122 -67
  77. package/lib/commands/assistant.js +53 -0
  78. package/lib/commands/avatars.js +21 -21
  79. package/lib/commands/console.js +2 -2
  80. package/lib/commands/databases.js +146 -104
  81. package/lib/commands/functions.js +277 -70
  82. package/lib/commands/generic.js +1 -0
  83. package/lib/commands/graphql.js +4 -4
  84. package/lib/commands/health.js +68 -22
  85. package/lib/commands/locale.js +37 -14
  86. package/lib/commands/migrations.js +708 -0
  87. package/lib/commands/project.js +204 -0
  88. package/lib/commands/projects.js +459 -196
  89. package/lib/commands/proxy.js +177 -0
  90. package/lib/commands/storage.js +47 -40
  91. package/lib/commands/teams.js +33 -33
  92. package/lib/commands/users.js +147 -52
  93. package/lib/commands/vcs.js +305 -0
  94. package/lib/config.js +1 -2
  95. package/lib/parser.js +2 -2
  96. package/package.json +1 -1
  97. package/scoop/appwrite.json +30 -0
  98. package/docs/examples/projects/create-domain.md +0 -3
  99. package/docs/examples/projects/delete-domain.md +0 -3
  100. package/docs/examples/projects/get-domain.md +0 -3
  101. package/docs/examples/projects/list-domains.md +0 -2
  102. package/docs/examples/projects/update-domain-verification.md +0 -3
@@ -0,0 +1,204 @@
1
+ const fs = require('fs');
2
+ const pathLib = require('path');
3
+ const tar = require("tar");
4
+ const ignore = require("ignore");
5
+ const { promisify } = require('util');
6
+ const libClient = require('../client.js');
7
+ const { getAllFiles } = require('../utils.js');
8
+ const { Command } = require('commander');
9
+ const { sdkForProject, sdkForConsole } = require('../sdks')
10
+ const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
+ const { localConfig, globalConfig } = require("../config");
12
+
13
+ const project = new Command("project").description(commandDescriptions['project']).configureHelp({
14
+ helpWidth: process.stdout.columns || 80
15
+ })
16
+
17
+ const projectGetUsage = async ({ range, parseOutput = true, sdk = undefined}) => {
18
+ /* @param {string} range */
19
+
20
+ let client = !sdk ? await sdkForProject() : sdk;
21
+ let apiPath = '/project/usage';
22
+ let payload = {};
23
+
24
+ /** Query Params */
25
+ if (typeof range !== 'undefined') {
26
+ payload['range'] = range;
27
+ }
28
+ let response = undefined;
29
+ response = await client.call('get', apiPath, {
30
+ 'content-type': 'application/json',
31
+ }, payload);
32
+
33
+ if (parseOutput) {
34
+ parse(response)
35
+ success()
36
+ }
37
+ return response;
38
+ }
39
+
40
+ const projectListVariables = async ({ parseOutput = true, sdk = undefined}) => {
41
+
42
+ let client = !sdk ? await sdkForProject() : sdk;
43
+ let apiPath = '/project/variables';
44
+ let payload = {};
45
+ let response = undefined;
46
+ response = await client.call('get', apiPath, {
47
+ 'content-type': 'application/json',
48
+ }, payload);
49
+
50
+ if (parseOutput) {
51
+ parse(response)
52
+ success()
53
+ }
54
+ return response;
55
+ }
56
+
57
+ const projectCreateVariable = async ({ key, value, parseOutput = true, sdk = undefined}) => {
58
+ /* @param {string} key */
59
+ /* @param {string} value */
60
+
61
+ let client = !sdk ? await sdkForProject() : sdk;
62
+ let apiPath = '/project/variables';
63
+ let payload = {};
64
+
65
+ /** Body Params */
66
+
67
+ if (typeof key !== 'undefined') {
68
+ payload['key'] = key;
69
+ }
70
+
71
+
72
+ if (typeof value !== 'undefined') {
73
+ payload['value'] = value;
74
+ }
75
+
76
+ let response = undefined;
77
+ response = await client.call('post', apiPath, {
78
+ 'content-type': 'application/json',
79
+ }, payload);
80
+
81
+ if (parseOutput) {
82
+ parse(response)
83
+ success()
84
+ }
85
+ return response;
86
+ }
87
+
88
+ const projectGetVariable = async ({ variableId, parseOutput = true, sdk = undefined}) => {
89
+ /* @param {string} variableId */
90
+
91
+ let client = !sdk ? await sdkForProject() : sdk;
92
+ let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
93
+ let payload = {};
94
+ let response = undefined;
95
+ response = await client.call('get', apiPath, {
96
+ 'content-type': 'application/json',
97
+ }, payload);
98
+
99
+ if (parseOutput) {
100
+ parse(response)
101
+ success()
102
+ }
103
+ return response;
104
+ }
105
+
106
+ const projectUpdateVariable = async ({ variableId, key, value, parseOutput = true, sdk = undefined}) => {
107
+ /* @param {string} variableId */
108
+ /* @param {string} key */
109
+ /* @param {string} value */
110
+
111
+ let client = !sdk ? await sdkForProject() : sdk;
112
+ let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
113
+ let payload = {};
114
+
115
+ /** Body Params */
116
+
117
+ if (typeof key !== 'undefined') {
118
+ payload['key'] = key;
119
+ }
120
+
121
+
122
+ if (typeof value !== 'undefined') {
123
+ payload['value'] = value;
124
+ }
125
+
126
+ let response = undefined;
127
+ response = await client.call('put', apiPath, {
128
+ 'content-type': 'application/json',
129
+ }, payload);
130
+
131
+ if (parseOutput) {
132
+ parse(response)
133
+ success()
134
+ }
135
+ return response;
136
+ }
137
+
138
+ const projectDeleteVariable = async ({ variableId, parseOutput = true, sdk = undefined}) => {
139
+ /* @param {string} variableId */
140
+
141
+ let client = !sdk ? await sdkForProject() : sdk;
142
+ let apiPath = '/project/variables/{variableId}'.replace('{variableId}', variableId);
143
+ let payload = {};
144
+ let response = undefined;
145
+ response = await client.call('delete', apiPath, {
146
+ 'content-type': 'application/json',
147
+ }, payload);
148
+
149
+ if (parseOutput) {
150
+ parse(response)
151
+ success()
152
+ }
153
+ return response;
154
+ }
155
+
156
+
157
+ project
158
+ .command(`getUsage`)
159
+ .description(``)
160
+ .option(`--range <range>`, `Date range.`)
161
+ .action(actionRunner(projectGetUsage))
162
+
163
+ project
164
+ .command(`listVariables`)
165
+ .description(`Get a list of all project variables. These variables will be accessible in all Appwrite Functions at runtime.`)
166
+ .action(actionRunner(projectListVariables))
167
+
168
+ project
169
+ .command(`createVariable`)
170
+ .description(`Create a new project variable. This variable will be accessible in all Appwrite Functions at runtime.`)
171
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
172
+ .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
173
+ .action(actionRunner(projectCreateVariable))
174
+
175
+ project
176
+ .command(`getVariable`)
177
+ .description(`Get a project variable by its unique ID.`)
178
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
179
+ .action(actionRunner(projectGetVariable))
180
+
181
+ project
182
+ .command(`updateVariable`)
183
+ .description(`Update project variable by its unique ID. This variable will be accessible in all Appwrite Functions at runtime.`)
184
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
185
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
186
+ .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
187
+ .action(actionRunner(projectUpdateVariable))
188
+
189
+ project
190
+ .command(`deleteVariable`)
191
+ .description(`Delete a project variable by its unique ID. `)
192
+ .requiredOption(`--variableId <variableId>`, `Variable unique ID.`)
193
+ .action(actionRunner(projectDeleteVariable))
194
+
195
+
196
+ module.exports = {
197
+ project,
198
+ projectGetUsage,
199
+ projectListVariables,
200
+ projectCreateVariable,
201
+ projectGetVariable,
202
+ projectUpdateVariable,
203
+ projectDeleteVariable
204
+ };