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.
Files changed (283) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +145 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +89 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +227 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/commands/account.d.ts +379 -0
  12. package/dist/lib/commands/account.d.ts.map +1 -0
  13. package/dist/lib/commands/account.js +1228 -0
  14. package/dist/lib/commands/account.js.map +1 -0
  15. package/dist/lib/commands/console.d.ts +20 -0
  16. package/dist/lib/commands/console.d.ts.map +1 -0
  17. package/dist/lib/commands/console.js +78 -0
  18. package/dist/lib/commands/console.js.map +1 -0
  19. package/dist/lib/commands/databases.d.ts +732 -0
  20. package/dist/lib/commands/databases.d.ts.map +1 -0
  21. package/dist/lib/commands/databases.js +2196 -0
  22. package/dist/lib/commands/databases.js.map +1 -0
  23. package/dist/lib/commands/functions.d.ts +310 -0
  24. package/dist/lib/commands/functions.d.ts.map +1 -0
  25. package/dist/lib/commands/functions.js +1100 -0
  26. package/dist/lib/commands/functions.js.map +1 -0
  27. package/dist/lib/commands/generic.d.ts +17 -0
  28. package/dist/lib/commands/generic.d.ts.map +1 -0
  29. package/dist/lib/commands/generic.js +279 -0
  30. package/dist/lib/commands/generic.js.map +1 -0
  31. package/dist/lib/commands/graphql.d.ts +19 -0
  32. package/dist/lib/commands/graphql.d.ts.map +1 -0
  33. package/dist/lib/commands/graphql.js +77 -0
  34. package/dist/lib/commands/graphql.js.map +1 -0
  35. package/dist/lib/commands/health.d.ts +153 -0
  36. package/dist/lib/commands/health.d.ts.map +1 -0
  37. package/dist/lib/commands/health.js +464 -0
  38. package/dist/lib/commands/health.js.map +1 -0
  39. package/dist/lib/commands/init.d.ts +3 -0
  40. package/dist/lib/commands/init.d.ts.map +1 -0
  41. package/dist/lib/commands/init.js +518 -0
  42. package/dist/lib/commands/init.js.map +1 -0
  43. package/dist/lib/commands/locale.d.ts +53 -0
  44. package/dist/lib/commands/locale.d.ts.map +1 -0
  45. package/dist/lib/commands/locale.js +165 -0
  46. package/dist/lib/commands/locale.js.map +1 -0
  47. package/dist/lib/commands/messaging.d.ts +588 -0
  48. package/dist/lib/commands/messaging.d.ts.map +1 -0
  49. package/dist/lib/commands/messaging.js +2042 -0
  50. package/dist/lib/commands/messaging.js.map +1 -0
  51. package/dist/lib/commands/migrations.d.ts +150 -0
  52. package/dist/lib/commands/migrations.d.ts.map +1 -0
  53. package/dist/lib/commands/migrations.js +524 -0
  54. package/dist/lib/commands/migrations.js.map +1 -0
  55. package/dist/lib/commands/organizations.d.ts +11 -0
  56. package/dist/lib/commands/organizations.d.ts.map +1 -0
  57. package/dist/lib/commands/organizations.js +31 -0
  58. package/dist/lib/commands/organizations.js.map +1 -0
  59. package/dist/lib/commands/project.d.ts +53 -0
  60. package/dist/lib/commands/project.d.ts.map +1 -0
  61. package/dist/lib/commands/project.js +176 -0
  62. package/dist/lib/commands/project.js.map +1 -0
  63. package/dist/lib/commands/projects.d.ts +516 -0
  64. package/dist/lib/commands/projects.d.ts.map +1 -0
  65. package/dist/lib/commands/projects.js +1590 -0
  66. package/dist/lib/commands/projects.js.map +1 -0
  67. package/dist/lib/commands/proxy.d.ts +71 -0
  68. package/dist/lib/commands/proxy.d.ts.map +1 -0
  69. package/dist/lib/commands/proxy.js +240 -0
  70. package/dist/lib/commands/proxy.js.map +1 -0
  71. package/dist/lib/commands/pull.d.ts +8 -0
  72. package/dist/lib/commands/pull.d.ts.map +1 -0
  73. package/dist/lib/commands/pull.js +455 -0
  74. package/dist/lib/commands/pull.js.map +1 -0
  75. package/dist/lib/commands/push.d.ts +4 -0
  76. package/dist/lib/commands/push.d.ts.map +1 -0
  77. package/dist/lib/commands/push.js +2154 -0
  78. package/dist/lib/commands/push.js.map +1 -0
  79. package/dist/lib/commands/run.d.ts +3 -0
  80. package/dist/lib/commands/run.d.ts.map +1 -0
  81. package/dist/lib/commands/run.js +287 -0
  82. package/dist/lib/commands/run.js.map +1 -0
  83. package/dist/lib/commands/sites.d.ts +296 -0
  84. package/dist/lib/commands/sites.d.ts.map +1 -0
  85. package/dist/lib/commands/sites.js +1046 -0
  86. package/dist/lib/commands/sites.js.map +1 -0
  87. package/dist/lib/commands/storage.d.ts +170 -0
  88. package/dist/lib/commands/storage.d.ts.map +1 -0
  89. package/dist/lib/commands/storage.js +651 -0
  90. package/dist/lib/commands/storage.js.map +1 -0
  91. package/dist/lib/commands/tables-db.d.ts +728 -0
  92. package/dist/lib/commands/tables-db.d.ts.map +1 -0
  93. package/dist/lib/commands/tables-db.js +2198 -0
  94. package/dist/lib/commands/tables-db.js.map +1 -0
  95. package/dist/lib/commands/teams.d.ts +129 -0
  96. package/dist/lib/commands/teams.d.ts.map +1 -0
  97. package/dist/lib/commands/teams.js +403 -0
  98. package/dist/lib/commands/teams.js.map +1 -0
  99. package/dist/lib/commands/tokens.d.ts +48 -0
  100. package/dist/lib/commands/tokens.d.ts.map +1 -0
  101. package/dist/lib/commands/tokens.js +156 -0
  102. package/dist/lib/commands/tokens.js.map +1 -0
  103. package/dist/lib/commands/types.d.ts +3 -0
  104. package/dist/lib/commands/types.d.ts.map +1 -0
  105. package/dist/lib/commands/types.js +155 -0
  106. package/dist/lib/commands/types.js.map +1 -0
  107. package/dist/lib/commands/update.d.ts +3 -0
  108. package/dist/lib/commands/update.d.ts.map +1 -0
  109. package/dist/lib/commands/update.js +202 -0
  110. package/dist/lib/commands/update.js.map +1 -0
  111. package/dist/lib/commands/users.d.ts +382 -0
  112. package/dist/lib/commands/users.d.ts.map +1 -0
  113. package/dist/lib/commands/users.js +1195 -0
  114. package/dist/lib/commands/users.js.map +1 -0
  115. package/dist/lib/commands/vcs.d.ts +92 -0
  116. package/dist/lib/commands/vcs.d.ts.map +1 -0
  117. package/dist/lib/commands/vcs.js +276 -0
  118. package/dist/lib/commands/vcs.js.map +1 -0
  119. package/dist/lib/config.d.ts +118 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/{lib → dist/lib}/config.js +204 -325
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/emulation/docker.d.ts +15 -0
  124. package/dist/lib/emulation/docker.d.ts.map +1 -0
  125. package/dist/lib/emulation/docker.js +220 -0
  126. package/dist/lib/emulation/docker.js.map +1 -0
  127. package/dist/lib/emulation/utils.d.ts +29 -0
  128. package/dist/lib/emulation/utils.d.ts.map +1 -0
  129. package/dist/lib/emulation/utils.js +168 -0
  130. package/dist/lib/emulation/utils.js.map +1 -0
  131. package/dist/lib/exception.d.ts +8 -0
  132. package/dist/lib/exception.d.ts.map +1 -0
  133. package/dist/lib/exception.js +16 -0
  134. package/dist/lib/exception.js.map +1 -0
  135. package/dist/lib/id.d.ts +7 -0
  136. package/dist/lib/id.d.ts.map +1 -0
  137. package/dist/lib/id.js +32 -0
  138. package/dist/lib/id.js.map +1 -0
  139. package/dist/lib/paginate.d.ts +10 -0
  140. package/dist/lib/paginate.d.ts.map +1 -0
  141. package/{lib → dist/lib}/paginate.js +9 -15
  142. package/dist/lib/paginate.js.map +1 -0
  143. package/dist/lib/parser.d.ts +18 -0
  144. package/dist/lib/parser.d.ts.map +1 -0
  145. package/dist/lib/parser.js +237 -0
  146. package/dist/lib/parser.js.map +1 -0
  147. package/dist/lib/questions.d.ts +59 -0
  148. package/dist/lib/questions.d.ts.map +1 -0
  149. package/dist/lib/questions.js +995 -0
  150. package/dist/lib/questions.js.map +1 -0
  151. package/dist/lib/sdks.d.ts +4 -0
  152. package/dist/lib/sdks.d.ts.map +1 -0
  153. package/dist/lib/sdks.js +51 -0
  154. package/dist/lib/sdks.js.map +1 -0
  155. package/dist/lib/spinner.d.ts +28 -0
  156. package/dist/lib/spinner.d.ts.map +1 -0
  157. package/{lib → dist/lib}/spinner.js +34 -45
  158. package/dist/lib/spinner.js.map +1 -0
  159. package/dist/lib/type-generation/attribute.d.ts +17 -0
  160. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  161. package/dist/lib/type-generation/attribute.js +19 -0
  162. package/dist/lib/type-generation/attribute.js.map +1 -0
  163. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  164. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  165. package/dist/lib/type-generation/languages/csharp.js +180 -0
  166. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  167. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  168. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  169. package/dist/lib/type-generation/languages/dart.js +197 -0
  170. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  171. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  172. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  173. package/dist/lib/type-generation/languages/java.js +140 -0
  174. package/dist/lib/type-generation/languages/java.js.map +1 -0
  175. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  176. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  177. package/dist/lib/type-generation/languages/javascript.js +108 -0
  178. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  179. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  180. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  181. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  182. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  183. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  184. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  185. package/dist/lib/type-generation/languages/language.js +82 -0
  186. package/dist/lib/type-generation/languages/language.js.map +1 -0
  187. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  188. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  189. package/dist/lib/type-generation/languages/php.js +116 -0
  190. package/dist/lib/type-generation/languages/php.js.map +1 -0
  191. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  192. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  193. package/dist/lib/type-generation/languages/swift.js +179 -0
  194. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  195. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  196. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  197. package/dist/lib/type-generation/languages/typescript.js +112 -0
  198. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  199. package/dist/lib/types.d.ts +133 -0
  200. package/dist/lib/types.d.ts.map +1 -0
  201. package/dist/lib/types.js +3 -0
  202. package/dist/lib/types.js.map +1 -0
  203. package/dist/lib/utils.d.ts +15 -0
  204. package/dist/lib/utils.d.ts.map +1 -0
  205. package/{lib → dist/lib}/utils.js +74 -120
  206. package/dist/lib/utils.js.map +1 -0
  207. package/dist/lib/validations.d.ts +2 -0
  208. package/dist/lib/validations.d.ts.map +1 -0
  209. package/dist/lib/validations.js +20 -0
  210. package/dist/lib/validations.js.map +1 -0
  211. package/docs/examples/databases/upsert-document.md +1 -2
  212. package/index.ts +152 -0
  213. package/install.ps1 +2 -5
  214. package/install.sh +1 -2
  215. package/lib/client.ts +259 -0
  216. package/lib/commands/{account.js → account.ts} +408 -662
  217. package/lib/commands/console.ts +112 -0
  218. package/lib/commands/{databases.js → databases.ts} +818 -1136
  219. package/lib/commands/{functions.js → functions.ts} +381 -526
  220. package/lib/commands/{generic.js → generic.ts} +47 -39
  221. package/lib/commands/graphql.ts +110 -0
  222. package/lib/commands/{health.js → health.ts} +168 -284
  223. package/lib/commands/{init.js → init.ts} +68 -66
  224. package/lib/commands/{locale.js → locale.ts} +75 -121
  225. package/lib/commands/{messaging.js → messaging.ts} +699 -937
  226. package/lib/commands/{migrations.js → migrations.ts} +182 -258
  227. package/lib/commands/organizations.ts +46 -0
  228. package/lib/commands/{project.js → project.ts} +75 -111
  229. package/lib/commands/{projects.js → projects.ts} +587 -843
  230. package/lib/commands/{proxy.js → proxy.ts} +94 -140
  231. package/lib/commands/{pull.js → pull.ts} +54 -44
  232. package/lib/commands/{push.js → push.ts} +235 -191
  233. package/lib/commands/{run.js → run.ts} +61 -55
  234. package/lib/commands/{sites.js → sites.ts} +364 -504
  235. package/lib/commands/{storage.js → storage.ts} +216 -292
  236. package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
  237. package/lib/commands/{teams.js → teams.ts} +162 -236
  238. package/lib/commands/{tokens.js → tokens.ts} +70 -99
  239. package/lib/commands/{types.js → types.ts} +37 -35
  240. package/lib/commands/{update.js → update.ts} +25 -27
  241. package/lib/commands/{users.js → users.ts} +426 -644
  242. package/lib/commands/{vcs.js → vcs.ts} +118 -174
  243. package/lib/config.ts +854 -0
  244. package/lib/emulation/{docker.js → docker.ts} +39 -38
  245. package/lib/emulation/utils.ts +193 -0
  246. package/lib/exception.ts +20 -0
  247. package/lib/{id.js → id.ts} +5 -5
  248. package/lib/paginate.ts +63 -0
  249. package/lib/parser.ts +238 -0
  250. package/lib/{questions.js → questions.ts} +148 -156
  251. package/lib/sdks.ts +55 -0
  252. package/lib/spinner.ts +118 -0
  253. package/lib/type-generation/attribute.ts +17 -0
  254. package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -57
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -56
  257. package/lib/type-generation/languages/javascript.ts +111 -0
  258. package/lib/type-generation/languages/kotlin.ts +96 -0
  259. package/lib/type-generation/languages/language.ts +119 -0
  260. package/lib/type-generation/languages/{php.js → php.ts} +55 -53
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
  262. package/lib/type-generation/languages/typescript.ts +116 -0
  263. package/lib/types.ts +150 -0
  264. package/lib/utils.ts +322 -0
  265. package/lib/validations.ts +17 -0
  266. package/package.json +21 -12
  267. package/scoop/appwrite.config.json +3 -3
  268. package/tsconfig.json +30 -0
  269. package/index.js +0 -147
  270. package/lib/client.js +0 -254
  271. package/lib/commands/console.js +0 -127
  272. package/lib/commands/graphql.js +0 -126
  273. package/lib/commands/organizations.js +0 -48
  274. package/lib/emulation/utils.js +0 -186
  275. package/lib/exception.js +0 -9
  276. package/lib/parser.js +0 -250
  277. package/lib/sdks.js +0 -60
  278. package/lib/type-generation/attribute.js +0 -19
  279. package/lib/type-generation/languages/javascript.js +0 -111
  280. package/lib/type-generation/languages/kotlin.js +0 -94
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -116
  283. 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
- }
@@ -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
@@ -1,9 +0,0 @@
1
- class AppwriteException extends Error {
2
- constructor(message, code, response) {
3
- super(message);
4
- this.code = code;
5
- this.response = response;
6
- }
7
- }
8
-
9
- module.exports = AppwriteException;
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 };