appwrite-cli 13.0.0-rc.1 → 13.0.0-rc.3

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 (430) hide show
  1. package/.github/workflows/publish.yml +68 -0
  2. package/CHANGELOG.md +10 -1
  3. package/LICENSE.md +1 -1
  4. package/README.md +3 -3
  5. package/cli.ts +152 -0
  6. package/dist/bundle.cjs +95813 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +145 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/index.d.ts +10 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7 -142
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/client.d.ts +2 -3
  16. package/dist/lib/client.d.ts.map +1 -1
  17. package/dist/lib/client.js +57 -45
  18. package/dist/lib/client.js.map +1 -1
  19. package/dist/lib/commands/config.d.ts +562 -0
  20. package/dist/lib/commands/config.d.ts.map +1 -0
  21. package/dist/lib/commands/config.js +416 -0
  22. package/dist/lib/commands/config.js.map +1 -0
  23. package/dist/lib/commands/db.d.ts +34 -0
  24. package/dist/lib/commands/db.d.ts.map +1 -0
  25. package/dist/lib/commands/db.js +247 -0
  26. package/dist/lib/commands/db.js.map +1 -0
  27. package/dist/lib/commands/errors.d.ts +68 -0
  28. package/dist/lib/commands/errors.d.ts.map +1 -0
  29. package/dist/lib/commands/errors.js +72 -0
  30. package/dist/lib/commands/errors.js.map +1 -0
  31. package/dist/lib/commands/generic.d.ts +2 -2
  32. package/dist/lib/commands/generic.d.ts.map +1 -1
  33. package/dist/lib/commands/generic.js +170 -157
  34. package/dist/lib/commands/generic.js.map +1 -1
  35. package/dist/lib/commands/init.d.ts +1 -1
  36. package/dist/lib/commands/init.d.ts.map +1 -1
  37. package/dist/lib/commands/init.js +201 -192
  38. package/dist/lib/commands/init.js.map +1 -1
  39. package/dist/lib/commands/pull.d.ts +105 -3
  40. package/dist/lib/commands/pull.d.ts.map +1 -1
  41. package/dist/lib/commands/pull.js +530 -370
  42. package/dist/lib/commands/pull.js.map +1 -1
  43. package/dist/lib/commands/push.d.ts +106 -0
  44. package/dist/lib/commands/push.d.ts.map +1 -1
  45. package/dist/lib/commands/push.js +1432 -1830
  46. package/dist/lib/commands/push.js.map +1 -1
  47. package/dist/lib/commands/run.d.ts +1 -1
  48. package/dist/lib/commands/run.d.ts.map +1 -1
  49. package/dist/lib/commands/run.js +129 -127
  50. package/dist/lib/commands/run.js.map +1 -1
  51. package/dist/lib/commands/schema.d.ts +59 -0
  52. package/dist/lib/commands/schema.d.ts.map +1 -0
  53. package/dist/lib/commands/schema.js +86 -0
  54. package/dist/lib/commands/schema.js.map +1 -0
  55. package/dist/lib/commands/services/account.d.ts +3 -0
  56. package/dist/lib/commands/services/account.d.ts.map +1 -0
  57. package/dist/lib/commands/services/account.js +328 -0
  58. package/dist/lib/commands/services/account.js.map +1 -0
  59. package/dist/lib/commands/services/console.d.ts +3 -0
  60. package/dist/lib/commands/services/console.d.ts.map +1 -0
  61. package/dist/lib/commands/services/console.js +28 -0
  62. package/dist/lib/commands/services/console.js.map +1 -0
  63. package/dist/lib/commands/services/databases.d.ts +3 -0
  64. package/dist/lib/commands/services/databases.d.ts.map +1 -0
  65. package/dist/lib/commands/services/databases.js +620 -0
  66. package/dist/lib/commands/services/databases.js.map +1 -0
  67. package/dist/lib/commands/services/functions.d.ts +3 -0
  68. package/dist/lib/commands/services/functions.d.ts.map +1 -0
  69. package/dist/lib/commands/services/functions.js +266 -0
  70. package/dist/lib/commands/services/functions.js.map +1 -0
  71. package/dist/lib/commands/services/graphql.d.ts +3 -0
  72. package/dist/lib/commands/services/graphql.d.ts.map +1 -0
  73. package/dist/lib/commands/services/graphql.js +28 -0
  74. package/dist/lib/commands/services/graphql.js.map +1 -0
  75. package/dist/lib/commands/services/health.d.ts +3 -0
  76. package/dist/lib/commands/services/health.d.ts.map +1 -0
  77. package/dist/lib/commands/services/health.js +123 -0
  78. package/dist/lib/commands/services/health.js.map +1 -0
  79. package/dist/lib/commands/services/locale.d.ts +3 -0
  80. package/dist/lib/commands/services/locale.d.ts.map +1 -0
  81. package/dist/lib/commands/services/locale.js +52 -0
  82. package/dist/lib/commands/services/locale.js.map +1 -0
  83. package/dist/lib/commands/services/messaging.d.ts +3 -0
  84. package/dist/lib/commands/services/messaging.d.ts.map +1 -0
  85. package/dist/lib/commands/services/messaging.js +505 -0
  86. package/dist/lib/commands/services/messaging.js.map +1 -0
  87. package/dist/lib/commands/services/migrations.d.ts +3 -0
  88. package/dist/lib/commands/services/migrations.d.ts.map +1 -0
  89. package/dist/lib/commands/services/migrations.js +135 -0
  90. package/dist/lib/commands/services/migrations.js.map +1 -0
  91. package/dist/lib/commands/services/project.d.ts +3 -0
  92. package/dist/lib/commands/services/project.d.ts.map +1 -0
  93. package/dist/lib/commands/services/project.js +54 -0
  94. package/dist/lib/commands/services/project.js.map +1 -0
  95. package/dist/lib/commands/services/projects.d.ts +3 -0
  96. package/dist/lib/commands/services/projects.d.ts.map +1 -0
  97. package/dist/lib/commands/services/projects.js +415 -0
  98. package/dist/lib/commands/services/projects.js.map +1 -0
  99. package/dist/lib/commands/services/proxy.d.ts +3 -0
  100. package/dist/lib/commands/services/proxy.d.ts.map +1 -0
  101. package/dist/lib/commands/services/proxy.js +68 -0
  102. package/dist/lib/commands/services/proxy.js.map +1 -0
  103. package/dist/lib/commands/services/sites.d.ts +3 -0
  104. package/dist/lib/commands/services/sites.d.ts.map +1 -0
  105. package/dist/lib/commands/services/sites.js +250 -0
  106. package/dist/lib/commands/services/sites.js.map +1 -0
  107. package/dist/lib/commands/services/storage.d.ts +3 -0
  108. package/dist/lib/commands/services/storage.d.ts.map +1 -0
  109. package/dist/lib/commands/services/storage.js +175 -0
  110. package/dist/lib/commands/services/storage.js.map +1 -0
  111. package/dist/lib/commands/services/tables-db.d.ts +3 -0
  112. package/dist/lib/commands/services/tables-db.d.ts.map +1 -0
  113. package/dist/lib/commands/services/tables-db.js +613 -0
  114. package/dist/lib/commands/services/tables-db.js.map +1 -0
  115. package/dist/lib/commands/services/teams.d.ts +3 -0
  116. package/dist/lib/commands/services/teams.d.ts.map +1 -0
  117. package/dist/lib/commands/services/teams.js +123 -0
  118. package/dist/lib/commands/services/teams.js.map +1 -0
  119. package/dist/lib/commands/services/tokens.d.ts +3 -0
  120. package/dist/lib/commands/services/tokens.d.ts.map +1 -0
  121. package/dist/lib/commands/services/tokens.js +49 -0
  122. package/dist/lib/commands/services/tokens.js.map +1 -0
  123. package/dist/lib/commands/services/users.d.ts +3 -0
  124. package/dist/lib/commands/services/users.d.ts.map +1 -0
  125. package/dist/lib/commands/services/users.js +312 -0
  126. package/dist/lib/commands/services/users.js.map +1 -0
  127. package/dist/lib/commands/services/vcs.d.ts +3 -0
  128. package/dist/lib/commands/services/vcs.d.ts.map +1 -0
  129. package/dist/lib/commands/services/vcs.js +87 -0
  130. package/dist/lib/commands/services/vcs.js.map +1 -0
  131. package/dist/lib/commands/types.d.ts +1 -1
  132. package/dist/lib/commands/types.d.ts.map +1 -1
  133. package/dist/lib/commands/types.js +53 -57
  134. package/dist/lib/commands/types.js.map +1 -1
  135. package/dist/lib/commands/update.d.ts +1 -1
  136. package/dist/lib/commands/update.d.ts.map +1 -1
  137. package/dist/lib/commands/update.js +69 -69
  138. package/dist/lib/commands/update.js.map +1 -1
  139. package/dist/lib/commands/utils/attributes.d.ts +47 -0
  140. package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
  141. package/dist/lib/commands/utils/attributes.js +514 -0
  142. package/dist/lib/commands/utils/attributes.js.map +1 -0
  143. package/dist/lib/commands/utils/change-approval.d.ts +25 -0
  144. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
  145. package/dist/lib/commands/utils/change-approval.js +129 -0
  146. package/dist/lib/commands/utils/change-approval.js.map +1 -0
  147. package/dist/lib/commands/utils/database-sync.d.ts +10 -0
  148. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
  149. package/dist/lib/commands/utils/database-sync.js +136 -0
  150. package/dist/lib/commands/utils/database-sync.js.map +1 -0
  151. package/dist/lib/commands/utils/deployment.d.ts +34 -0
  152. package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
  153. package/dist/lib/commands/utils/deployment.js +109 -0
  154. package/dist/lib/commands/utils/deployment.js.map +1 -0
  155. package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
  156. package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
  157. package/dist/lib/commands/utils/error-formatter.js +333 -0
  158. package/dist/lib/commands/utils/error-formatter.js.map +1 -0
  159. package/dist/lib/commands/utils/pools.d.ts +16 -0
  160. package/dist/lib/commands/utils/pools.d.ts.map +1 -0
  161. package/dist/lib/commands/utils/pools.js +198 -0
  162. package/dist/lib/commands/utils/pools.js.map +1 -0
  163. package/dist/lib/config.d.ts +41 -40
  164. package/dist/lib/config.d.ts.map +1 -1
  165. package/dist/lib/config.js +264 -239
  166. package/dist/lib/config.js.map +1 -1
  167. package/dist/lib/constants.d.ts +14 -0
  168. package/dist/lib/constants.d.ts.map +1 -0
  169. package/dist/lib/constants.js +19 -0
  170. package/dist/lib/constants.js.map +1 -0
  171. package/dist/lib/emulation/docker.d.ts +4 -12
  172. package/dist/lib/emulation/docker.d.ts.map +1 -1
  173. package/dist/lib/emulation/docker.js +159 -142
  174. package/dist/lib/emulation/docker.js.map +1 -1
  175. package/dist/lib/emulation/utils.d.ts +1 -1
  176. package/dist/lib/emulation/utils.d.ts.map +1 -1
  177. package/dist/lib/emulation/utils.js +55 -58
  178. package/dist/lib/emulation/utils.js.map +1 -1
  179. package/dist/lib/id.d.ts +1 -1
  180. package/dist/lib/id.d.ts.map +1 -1
  181. package/dist/lib/id.js +13 -18
  182. package/dist/lib/id.js.map +1 -1
  183. package/dist/lib/paginate.d.ts +3 -4
  184. package/dist/lib/paginate.d.ts.map +1 -1
  185. package/dist/lib/paginate.js +7 -10
  186. package/dist/lib/paginate.js.map +1 -1
  187. package/dist/lib/parser.d.ts +1 -1
  188. package/dist/lib/parser.d.ts.map +1 -1
  189. package/dist/lib/parser.js +92 -103
  190. package/dist/lib/parser.js.map +1 -1
  191. package/dist/lib/questions.d.ts +1 -1
  192. package/dist/lib/questions.d.ts.map +1 -1
  193. package/dist/lib/questions.js +381 -385
  194. package/dist/lib/questions.js.map +1 -1
  195. package/dist/lib/sdks.d.ts +1 -1
  196. package/dist/lib/sdks.d.ts.map +1 -1
  197. package/dist/lib/sdks.js +39 -30
  198. package/dist/lib/sdks.js.map +1 -1
  199. package/dist/lib/services.d.ts +13 -0
  200. package/dist/lib/services.d.ts.map +1 -0
  201. package/dist/lib/services.js +47 -0
  202. package/dist/lib/services.js.map +1 -0
  203. package/dist/lib/spinner.d.ts +1 -1
  204. package/dist/lib/spinner.d.ts.map +1 -1
  205. package/dist/lib/spinner.js +25 -27
  206. package/dist/lib/spinner.js.map +1 -1
  207. package/dist/lib/type-generation/attribute.d.ts +1 -1
  208. package/dist/lib/type-generation/attribute.d.ts.map +1 -1
  209. package/dist/lib/type-generation/attribute.js +14 -17
  210. package/dist/lib/type-generation/attribute.js.map +1 -1
  211. package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
  212. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
  213. package/dist/lib/type-generation/languages/csharp.js +34 -34
  214. package/dist/lib/type-generation/languages/csharp.js.map +1 -1
  215. package/dist/lib/type-generation/languages/dart.d.ts +1 -1
  216. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
  217. package/dist/lib/type-generation/languages/dart.js +57 -57
  218. package/dist/lib/type-generation/languages/dart.js.map +1 -1
  219. package/dist/lib/type-generation/languages/java.d.ts +1 -1
  220. package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
  221. package/dist/lib/type-generation/languages/java.js +35 -35
  222. package/dist/lib/type-generation/languages/java.js.map +1 -1
  223. package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
  224. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
  225. package/dist/lib/type-generation/languages/javascript.js +45 -44
  226. package/dist/lib/type-generation/languages/javascript.js.map +1 -1
  227. package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
  228. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
  229. package/dist/lib/type-generation/languages/kotlin.js +35 -35
  230. package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
  231. package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
  232. package/dist/lib/type-generation/languages/language.js +32 -37
  233. package/dist/lib/type-generation/languages/language.js.map +1 -1
  234. package/dist/lib/type-generation/languages/php.d.ts +1 -1
  235. package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
  236. package/dist/lib/type-generation/languages/php.js +34 -34
  237. package/dist/lib/type-generation/languages/php.js.map +1 -1
  238. package/dist/lib/type-generation/languages/swift.d.ts +1 -1
  239. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
  240. package/dist/lib/type-generation/languages/swift.js +35 -35
  241. package/dist/lib/type-generation/languages/swift.js.map +1 -1
  242. package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
  243. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
  244. package/dist/lib/type-generation/languages/typescript.js +49 -46
  245. package/dist/lib/type-generation/languages/typescript.js.map +1 -1
  246. package/dist/lib/types.d.ts +38 -108
  247. package/dist/lib/types.d.ts.map +1 -1
  248. package/dist/lib/types.js +1 -2
  249. package/dist/lib/utils.d.ts +3 -0
  250. package/dist/lib/utils.d.ts.map +1 -1
  251. package/dist/lib/utils.js +142 -98
  252. package/dist/lib/utils.js.map +1 -1
  253. package/dist/lib/validations.d.ts.map +1 -1
  254. package/dist/lib/validations.js +2 -6
  255. package/dist/lib/validations.js.map +1 -1
  256. package/dist/package.json +68 -0
  257. package/index.ts +25 -149
  258. package/install.ps1 +2 -2
  259. package/install.sh +1 -1
  260. package/lib/client.ts +261 -220
  261. package/lib/commands/config.ts +494 -0
  262. package/lib/commands/db.ts +324 -0
  263. package/lib/commands/errors.ts +93 -0
  264. package/lib/commands/generic.ts +371 -269
  265. package/lib/commands/init.ts +631 -519
  266. package/lib/commands/pull.ts +827 -453
  267. package/lib/commands/push.ts +2191 -2349
  268. package/lib/commands/run.ts +382 -302
  269. package/lib/commands/schema.ts +122 -0
  270. package/lib/commands/services/account.ts +647 -0
  271. package/lib/commands/services/console.ts +52 -0
  272. package/lib/commands/services/databases.ts +1163 -0
  273. package/lib/commands/services/functions.ts +536 -0
  274. package/lib/commands/services/graphql.ts +50 -0
  275. package/lib/commands/services/health.ts +260 -0
  276. package/lib/commands/services/locale.ts +102 -0
  277. package/lib/commands/services/messaging.ts +1052 -0
  278. package/lib/commands/services/migrations.ts +249 -0
  279. package/lib/commands/services/project.ts +112 -0
  280. package/lib/commands/services/projects.ts +785 -0
  281. package/lib/commands/services/proxy.ts +135 -0
  282. package/lib/commands/services/sites.ts +505 -0
  283. package/lib/commands/services/storage.ts +338 -0
  284. package/lib/commands/services/tables-db.ts +1150 -0
  285. package/lib/commands/services/teams.ts +232 -0
  286. package/lib/commands/services/tokens.ts +94 -0
  287. package/lib/commands/services/users.ts +616 -0
  288. package/lib/commands/services/vcs.ts +165 -0
  289. package/lib/commands/types.ts +145 -118
  290. package/lib/commands/update.ts +189 -159
  291. package/lib/commands/utils/attributes.ts +719 -0
  292. package/lib/commands/utils/change-approval.ts +186 -0
  293. package/lib/commands/utils/database-sync.ts +180 -0
  294. package/lib/commands/utils/deployment.ts +184 -0
  295. package/lib/commands/utils/error-formatter.ts +417 -0
  296. package/lib/commands/utils/pools.ts +355 -0
  297. package/lib/config.ts +766 -687
  298. package/lib/constants.ts +22 -0
  299. package/lib/emulation/docker.ts +277 -216
  300. package/lib/emulation/utils.ts +188 -174
  301. package/lib/id.ts +23 -23
  302. package/lib/paginate.ts +69 -55
  303. package/lib/parser.ts +220 -189
  304. package/lib/questions.ts +1024 -948
  305. package/lib/sdks.ts +84 -51
  306. package/lib/services.ts +72 -0
  307. package/lib/spinner.ts +112 -99
  308. package/lib/type-generation/attribute.ts +15 -14
  309. package/lib/type-generation/languages/csharp.ts +71 -60
  310. package/lib/type-generation/languages/dart.ts +106 -93
  311. package/lib/type-generation/languages/java.ts +69 -58
  312. package/lib/type-generation/languages/javascript.ts +84 -73
  313. package/lib/type-generation/languages/kotlin.ts +71 -60
  314. package/lib/type-generation/languages/language.ts +103 -95
  315. package/lib/type-generation/languages/php.ts +67 -56
  316. package/lib/type-generation/languages/swift.ts +71 -60
  317. package/lib/type-generation/languages/typescript.ts +93 -76
  318. package/lib/types.ts +50 -125
  319. package/lib/utils.ts +304 -233
  320. package/lib/validations.ts +17 -14
  321. package/package.json +31 -22
  322. package/scoop/appwrite.config.json +3 -3
  323. package/tsconfig.json +7 -13
  324. package/.github/workflows/autoclose.yml +0 -11
  325. package/.github/workflows/npm-publish.yml +0 -49
  326. package/dist/lib/commands/account.d.ts +0 -379
  327. package/dist/lib/commands/account.d.ts.map +0 -1
  328. package/dist/lib/commands/account.js +0 -1228
  329. package/dist/lib/commands/account.js.map +0 -1
  330. package/dist/lib/commands/console.d.ts +0 -20
  331. package/dist/lib/commands/console.d.ts.map +0 -1
  332. package/dist/lib/commands/console.js +0 -78
  333. package/dist/lib/commands/console.js.map +0 -1
  334. package/dist/lib/commands/databases.d.ts +0 -732
  335. package/dist/lib/commands/databases.d.ts.map +0 -1
  336. package/dist/lib/commands/databases.js +0 -2196
  337. package/dist/lib/commands/databases.js.map +0 -1
  338. package/dist/lib/commands/functions.d.ts +0 -310
  339. package/dist/lib/commands/functions.d.ts.map +0 -1
  340. package/dist/lib/commands/functions.js +0 -1100
  341. package/dist/lib/commands/functions.js.map +0 -1
  342. package/dist/lib/commands/graphql.d.ts +0 -19
  343. package/dist/lib/commands/graphql.d.ts.map +0 -1
  344. package/dist/lib/commands/graphql.js +0 -77
  345. package/dist/lib/commands/graphql.js.map +0 -1
  346. package/dist/lib/commands/health.d.ts +0 -153
  347. package/dist/lib/commands/health.d.ts.map +0 -1
  348. package/dist/lib/commands/health.js +0 -464
  349. package/dist/lib/commands/health.js.map +0 -1
  350. package/dist/lib/commands/locale.d.ts +0 -53
  351. package/dist/lib/commands/locale.d.ts.map +0 -1
  352. package/dist/lib/commands/locale.js +0 -165
  353. package/dist/lib/commands/locale.js.map +0 -1
  354. package/dist/lib/commands/messaging.d.ts +0 -588
  355. package/dist/lib/commands/messaging.d.ts.map +0 -1
  356. package/dist/lib/commands/messaging.js +0 -2042
  357. package/dist/lib/commands/messaging.js.map +0 -1
  358. package/dist/lib/commands/migrations.d.ts +0 -150
  359. package/dist/lib/commands/migrations.d.ts.map +0 -1
  360. package/dist/lib/commands/migrations.js +0 -524
  361. package/dist/lib/commands/migrations.js.map +0 -1
  362. package/dist/lib/commands/organizations.d.ts +0 -11
  363. package/dist/lib/commands/organizations.d.ts.map +0 -1
  364. package/dist/lib/commands/organizations.js +0 -31
  365. package/dist/lib/commands/organizations.js.map +0 -1
  366. package/dist/lib/commands/project.d.ts +0 -53
  367. package/dist/lib/commands/project.d.ts.map +0 -1
  368. package/dist/lib/commands/project.js +0 -176
  369. package/dist/lib/commands/project.js.map +0 -1
  370. package/dist/lib/commands/projects.d.ts +0 -516
  371. package/dist/lib/commands/projects.d.ts.map +0 -1
  372. package/dist/lib/commands/projects.js +0 -1590
  373. package/dist/lib/commands/projects.js.map +0 -1
  374. package/dist/lib/commands/proxy.d.ts +0 -71
  375. package/dist/lib/commands/proxy.d.ts.map +0 -1
  376. package/dist/lib/commands/proxy.js +0 -240
  377. package/dist/lib/commands/proxy.js.map +0 -1
  378. package/dist/lib/commands/sites.d.ts +0 -296
  379. package/dist/lib/commands/sites.d.ts.map +0 -1
  380. package/dist/lib/commands/sites.js +0 -1046
  381. package/dist/lib/commands/sites.js.map +0 -1
  382. package/dist/lib/commands/storage.d.ts +0 -170
  383. package/dist/lib/commands/storage.d.ts.map +0 -1
  384. package/dist/lib/commands/storage.js +0 -651
  385. package/dist/lib/commands/storage.js.map +0 -1
  386. package/dist/lib/commands/tables-db.d.ts +0 -728
  387. package/dist/lib/commands/tables-db.d.ts.map +0 -1
  388. package/dist/lib/commands/tables-db.js +0 -2198
  389. package/dist/lib/commands/tables-db.js.map +0 -1
  390. package/dist/lib/commands/teams.d.ts +0 -129
  391. package/dist/lib/commands/teams.d.ts.map +0 -1
  392. package/dist/lib/commands/teams.js +0 -403
  393. package/dist/lib/commands/teams.js.map +0 -1
  394. package/dist/lib/commands/tokens.d.ts +0 -48
  395. package/dist/lib/commands/tokens.d.ts.map +0 -1
  396. package/dist/lib/commands/tokens.js +0 -156
  397. package/dist/lib/commands/tokens.js.map +0 -1
  398. package/dist/lib/commands/users.d.ts +0 -382
  399. package/dist/lib/commands/users.d.ts.map +0 -1
  400. package/dist/lib/commands/users.js +0 -1195
  401. package/dist/lib/commands/users.js.map +0 -1
  402. package/dist/lib/commands/vcs.d.ts +0 -92
  403. package/dist/lib/commands/vcs.d.ts.map +0 -1
  404. package/dist/lib/commands/vcs.js +0 -276
  405. package/dist/lib/commands/vcs.js.map +0 -1
  406. package/dist/lib/exception.d.ts +0 -8
  407. package/dist/lib/exception.d.ts.map +0 -1
  408. package/dist/lib/exception.js +0 -16
  409. package/dist/lib/exception.js.map +0 -1
  410. package/lib/commands/account.ts +0 -1867
  411. package/lib/commands/console.ts +0 -112
  412. package/lib/commands/databases.ts +0 -3272
  413. package/lib/commands/functions.ts +0 -1587
  414. package/lib/commands/graphql.ts +0 -110
  415. package/lib/commands/health.ts +0 -753
  416. package/lib/commands/locale.ts +0 -270
  417. package/lib/commands/messaging.ts +0 -2878
  418. package/lib/commands/migrations.ts +0 -754
  419. package/lib/commands/organizations.ts +0 -46
  420. package/lib/commands/project.ts +0 -266
  421. package/lib/commands/projects.ts +0 -2370
  422. package/lib/commands/proxy.ts +0 -357
  423. package/lib/commands/sites.ts +0 -1514
  424. package/lib/commands/storage.ts +0 -919
  425. package/lib/commands/tables-db.ts +0 -3260
  426. package/lib/commands/teams.ts +0 -609
  427. package/lib/commands/tokens.ts +0 -232
  428. package/lib/commands/users.ts +0 -1804
  429. package/lib/commands/vcs.ts +0 -428
  430. package/lib/exception.ts +0 -20
package/lib/questions.ts CHANGED
@@ -1,1090 +1,1166 @@
1
- import chalk from 'chalk';
2
- import Client from './client';
3
- import { localConfig, globalConfig } from './config';
4
- import { projectsList } from './commands/projects';
5
- import { organizationsList } from './commands/organizations';
6
- import { teamsList } from './commands/teams';
7
- import { functionsListRuntimes, functionsListSpecifications, functionsList } from './commands/functions';
8
- import { accountListMFAFactors } from './commands/account';
9
- import { sdkForConsole } from './sdks';
10
- import { validateRequired } from './validations';
11
- import { paginate } from './paginate';
12
- import { isPortTaken, checkDeployConditions, isCloud } from './utils';
13
- import { databasesList } from './commands/databases';
14
- import JSONbig from 'json-bigint';
15
- import { sitesListFrameworks, sitesListSpecifications, sitesList } from './commands/sites';
16
-
17
- const JSONbigConfig = JSONbig({ storeAsString: false });
1
+ import chalk from "chalk";
2
+ import { localConfig, globalConfig } from "./config.js";
3
+ import { sdkForConsole } from "./sdks.js";
4
+ import { validateRequired } from "./validations.js";
5
+ import { paginate } from "./paginate.js";
6
+ import { checkDeployConditions, isCloud } from "./utils.js";
7
+ import { Account, Client } from "@appwrite.io/console";
8
+ import {
9
+ getOrganizationsService,
10
+ getTeamsService,
11
+ getProjectsService,
12
+ getFunctionsService,
13
+ getSitesService,
14
+ getDatabasesService,
15
+ } from "./services.js";
16
+ import { SDK_TITLE, DEFAULT_ENDPOINT, EXECUTABLE_NAME } from "./constants.js";
18
17
 
19
18
  interface Answers {
20
- override?: boolean;
21
- method?: string;
22
- start?: string;
23
- organization?: string;
24
- [key: string]: any;
19
+ override?: boolean;
20
+ method?: string;
21
+ start?: string;
22
+ organization?: string;
23
+ [key: string]: any;
25
24
  }
26
25
 
27
26
  interface Choice {
28
- name: string;
29
- value: any;
30
- disabled?: boolean | string;
31
- current?: boolean;
27
+ name: string;
28
+ value: any;
29
+ disabled?: boolean | string;
30
+ current?: boolean;
32
31
  }
33
32
 
34
33
  interface Question {
35
- type: string;
36
- name: string;
37
- message: string;
38
- default?: any;
39
- when?: ((answers: Answers) => boolean | Promise<boolean>) | boolean;
40
- choices?: (() => Promise<Choice[]> | Choice[]) | Choice[];
41
- validate?: (value: any) => boolean | string | Promise<boolean | string>;
42
- mask?: string;
34
+ type: string;
35
+ name: string;
36
+ message: string;
37
+ default?: any;
38
+ when?: ((answers: Answers) => boolean | Promise<boolean>) | boolean;
39
+ choices?:
40
+ | ((answers: Answers) => Promise<Choice[]> | Choice[])
41
+ | (() => Promise<Choice[]> | Choice[])
42
+ | Choice[]
43
+ | string[];
44
+ validate?: (value: any) => boolean | string | Promise<boolean | string>;
45
+ mask?: string;
43
46
  }
44
47
 
45
- const whenOverride = (answers: Answers): boolean => answers.override === undefined ? true : answers.override;
48
+ const whenOverride = (answers: Answers): boolean =>
49
+ answers.override === undefined ? true : answers.override;
46
50
 
47
51
  const getIgnores = (runtime: string): string[] => {
48
- const languge = runtime.split("-").slice(0, -1).join("-");
49
-
50
- switch (languge) {
51
- case 'cpp':
52
- return ['build', 'CMakeFiles', 'CMakeCaches.txt'];
53
- case 'dart':
54
- return ['.packages', '.dart_tool'];
55
- case 'deno':
56
- return [];
57
- case 'dotnet':
58
- return ['bin', 'obj', '.nuget'];
59
- case 'java':
60
- case 'kotlin':
61
- return ['build'];
62
- case 'node':
63
- case 'bun':
64
- return ['node_modules', '.npm'];
65
- case 'php':
66
- return ['vendor'];
67
- case 'python':
68
- case 'python-ml':
69
- return ['__pypackages__'];
70
- case 'ruby':
71
- return ['vendor'];
72
- case 'rust':
73
- return ['target', 'debug', '*.rs.bk', '*.pdb'];
74
- case 'swift':
75
- return ['.build', '.swiftpm'];
76
- }
77
-
78
- return [];
52
+ const language = runtime.split("-").slice(0, -1).join("-");
53
+
54
+ switch (language) {
55
+ case "cpp":
56
+ return ["build", "CMakeFiles", "CMakeCaches.txt"];
57
+ case "dart":
58
+ return [".packages", ".dart_tool"];
59
+ case "deno":
60
+ return [];
61
+ case "dotnet":
62
+ return ["bin", "obj", ".nuget"];
63
+ case "java":
64
+ case "kotlin":
65
+ return ["build"];
66
+ case "node":
67
+ case "bun":
68
+ return ["node_modules", ".npm"];
69
+ case "php":
70
+ return ["vendor"];
71
+ case "python":
72
+ case "python-ml":
73
+ return ["__pypackages__"];
74
+ case "ruby":
75
+ return ["vendor"];
76
+ case "rust":
77
+ return ["target", "debug", "*.rs.bk", "*.pdb"];
78
+ case "swift":
79
+ return [".build", ".swiftpm"];
80
+ }
81
+
82
+ return [];
79
83
  };
80
84
 
81
85
  const getEntrypoint = (runtime: string): string | undefined => {
82
- const languge = runtime.split("-").slice(0, -1).join("-");
83
-
84
- switch (languge) {
85
- case 'dart':
86
- return 'lib/main.dart';
87
- case 'deno':
88
- return 'src/main.ts';
89
- case 'node':
90
- return 'src/main.js';
91
- case 'bun':
92
- return 'src/main.ts';
93
- case 'php':
94
- return 'src/index.php';
95
- case 'python':
96
- case 'python-ml':
97
- return 'src/main.py';
98
- case 'ruby':
99
- return 'lib/main.rb';
100
- case 'rust':
101
- return 'main.rs';
102
- case 'swift':
103
- return 'Sources/index.swift';
104
- case 'cpp':
105
- return 'src/main.cc';
106
- case 'dotnet':
107
- return 'src/Index.cs';
108
- case 'java':
109
- return 'src/Main.java';
110
- case 'kotlin':
111
- return 'src/Main.kt';
112
- case 'go':
113
- return 'main.go';
114
- }
115
-
116
- return undefined;
86
+ const language = runtime.split("-").slice(0, -1).join("-");
87
+
88
+ switch (language) {
89
+ case "dart":
90
+ return "lib/main.dart";
91
+ case "deno":
92
+ return "src/main.ts";
93
+ case "node":
94
+ return "src/main.js";
95
+ case "bun":
96
+ return "src/main.ts";
97
+ case "php":
98
+ return "src/index.php";
99
+ case "python":
100
+ case "python-ml":
101
+ return "src/main.py";
102
+ case "ruby":
103
+ return "lib/main.rb";
104
+ case "rust":
105
+ return "main.rs";
106
+ case "swift":
107
+ return "Sources/index.swift";
108
+ case "cpp":
109
+ return "src/main.cc";
110
+ case "dotnet":
111
+ return "src/Index.cs";
112
+ case "java":
113
+ return "src/Main.java";
114
+ case "kotlin":
115
+ return "src/Main.kt";
116
+ case "go":
117
+ return "main.go";
118
+ }
119
+
120
+ return undefined;
117
121
  };
118
122
 
119
123
  const getInstallCommand = (runtime: string): string | undefined => {
120
- const languge = runtime.split("-").slice(0, -1).join("-");
121
-
122
- switch (languge) {
123
- case 'dart':
124
- return 'dart pub get';
125
- case 'deno':
126
- return "deno cache src/main.ts";
127
- case 'node':
128
- return 'npm install';
129
- case 'bun':
130
- return 'bun install';
131
- case 'php':
132
- return 'composer install';
133
- case 'python':
134
- case 'python-ml':
135
- return 'pip install -r requirements.txt';
136
- case 'ruby':
137
- return 'bundle install';
138
- case 'rust':
139
- return 'cargo install';
140
- case 'dotnet':
141
- return 'dotnet restore';
142
- case 'swift':
143
- case 'java':
144
- case 'kotlin':
145
- case 'cpp':
146
- return '';
147
- }
148
-
149
- return undefined;
124
+ const language = runtime.split("-").slice(0, -1).join("-");
125
+
126
+ switch (language) {
127
+ case "dart":
128
+ return "dart pub get";
129
+ case "deno":
130
+ return "deno cache src/main.ts";
131
+ case "node":
132
+ return "npm install";
133
+ case "bun":
134
+ return "bun install";
135
+ case "php":
136
+ return "composer install";
137
+ case "python":
138
+ case "python-ml":
139
+ return "pip install -r requirements.txt";
140
+ case "ruby":
141
+ return "bundle install";
142
+ case "rust":
143
+ return "cargo install";
144
+ case "dotnet":
145
+ return "dotnet restore";
146
+ case "swift":
147
+ case "java":
148
+ case "kotlin":
149
+ case "cpp":
150
+ return "";
151
+ }
152
+
153
+ return undefined;
150
154
  };
151
155
 
152
156
  export const questionsInitProject: Question[] = [
153
- {
154
- type: "confirm",
155
- name: "override",
156
- message:
157
- `An Appwrite project ( ${localConfig.getProject()['projectId']} ) is already associated with the current directory. Would you like to override`,
158
- when() {
159
- return Object.keys(localConfig.getProject()).length !== 0;
160
- }
157
+ {
158
+ type: "confirm",
159
+ name: "override",
160
+ message: `An ${SDK_TITLE} project ( ${localConfig.getProject()["projectId"]} ) is already associated with the current directory. Would you like to override it?`,
161
+ when() {
162
+ return Object.keys(localConfig.getProject()).length !== 0;
161
163
  },
162
- {
163
- type: "list",
164
- name: "start",
165
- when: whenOverride,
166
- message: "How would you like to start?",
167
- choices: [
168
- {
169
- name: "Create new project",
170
- value: "new"
171
- },
172
- {
173
- name: "Link directory to an existing project",
174
- value: "existing"
175
- }
176
- ]
164
+ },
165
+ {
166
+ type: "list",
167
+ name: "start",
168
+ when: whenOverride,
169
+ message: "How would you like to start?",
170
+ choices: [
171
+ {
172
+ name: "Create new project",
173
+ value: "new",
174
+ },
175
+ {
176
+ name: "Link directory to an existing project",
177
+ value: "existing",
178
+ },
179
+ ],
180
+ },
181
+ {
182
+ type: "search-list",
183
+ name: "organization",
184
+ message: "Choose your organization",
185
+ choices: async () => {
186
+ let client = await sdkForConsole(true);
187
+ const { teams } = isCloud()
188
+ ? await paginate(
189
+ async (opts: { sdk?: Client } = {}) =>
190
+ (await getOrganizationsService(opts.sdk)).list(),
191
+ { sdk: client },
192
+ 100,
193
+ "teams",
194
+ )
195
+ : await paginate(
196
+ async (opts: { sdk?: Client } = {}) =>
197
+ (await getTeamsService(opts.sdk)).list(),
198
+ { parseOutput: false, sdk: client },
199
+ 100,
200
+ "teams",
201
+ );
202
+
203
+ let choices = teams.map((team: any, idx: number) => {
204
+ return {
205
+ name: `${team.name} (${team["$id"]})`,
206
+ value: team["$id"],
207
+ };
208
+ });
209
+
210
+ if (choices.length == 0) {
211
+ throw new Error(
212
+ `No organizations found. Please create a new organization at ${globalConfig.getEndpoint().replace("/v1", "/console/onboarding")}`,
213
+ );
214
+ }
215
+
216
+ return choices;
177
217
  },
178
- {
179
- type: "search-list",
180
- name: "organization",
181
- message: "Choose your organization",
182
- choices: async () => {
183
- let client = await sdkForConsole(true);
184
- const { teams } = isCloud()
185
- ? await paginate(organizationsList, { parseOutput: false, sdk: client }, 100, 'teams')
186
- : await paginate(teamsList, { parseOutput: false, sdk: client }, 100, 'teams');
187
-
188
- let choices = teams.map((team: any, idx: number) => {
189
- return {
190
- name: `${team.name} (${team['$id']})`,
191
- value: team['$id']
192
- }
193
- })
194
-
195
- if (choices.length == 0) {
196
- throw new Error(`No organizations found. Please create a new organization at ${globalConfig.getEndpoint().replace('/v1', '/console/onboarding')}`)
197
- }
198
-
199
- return choices;
200
- },
201
- when: whenOverride
218
+ when: whenOverride,
219
+ },
220
+ {
221
+ type: "input",
222
+ name: "project",
223
+ message: "What would you like to name your project?",
224
+ default: "My Awesome Project",
225
+ when: (answer: Answers) => answer.start !== "existing",
226
+ },
227
+ {
228
+ type: "input",
229
+ name: "id",
230
+ message: "What ID would you like to have for your project?",
231
+ default: "unique()",
232
+ when: (answer: Answers) => answer.start !== "existing",
233
+ },
234
+ {
235
+ type: "search-list",
236
+ name: "project",
237
+ message: `Choose your ${SDK_TITLE} project.`,
238
+ choices: async (answers: Answers) => {
239
+ const queries = [
240
+ JSON.stringify({
241
+ method: "equal",
242
+ attribute: "teamId",
243
+ values: [answers.organization],
244
+ }),
245
+ JSON.stringify({ method: "orderDesc", attribute: "$id" }),
246
+ ];
247
+
248
+ const { projects } = await paginate(
249
+ async () => (await getProjectsService()).list(queries),
250
+ { parseOutput: false },
251
+ 100,
252
+ "projects",
253
+ queries,
254
+ );
255
+
256
+ let choices = projects.map((project: any) => {
257
+ return {
258
+ name: `${project.name} (${project["$id"]})`,
259
+ value: {
260
+ $id: project["$id"],
261
+ region: project.region || "",
262
+ },
263
+ };
264
+ });
265
+
266
+ if (choices.length === 0) {
267
+ throw new Error("No projects found. Please create a new project.");
268
+ }
269
+
270
+ return choices;
202
271
  },
203
- {
204
- type: "input",
205
- name: "project",
206
- message: "What would you like to name your project?",
207
- default: "My Awesome Project",
208
- when: (answer: Answers) => answer.start !== 'existing'
209
- },
210
- {
211
- type: "input",
212
- name: "id",
213
- message: "What ID would you like to have for your project?",
214
- default: "unique()",
215
- when: (answer: Answers) => answer.start !== 'existing'
272
+ when: (answer: Answers) => answer.start === "existing",
273
+ },
274
+ {
275
+ type: "list",
276
+ name: "region",
277
+ message: `Select your ${SDK_TITLE} Cloud region`,
278
+ choices: async () => {
279
+ let client = await sdkForConsole(true);
280
+ const endpoint = globalConfig.getEndpoint() || DEFAULT_ENDPOINT;
281
+ let response = (await client.call(
282
+ "GET",
283
+ new URL(endpoint + "/console/regions"),
284
+ )) as { regions: any[] };
285
+ let regions = response.regions || [];
286
+ if (!regions.length) {
287
+ throw new Error(
288
+ "No regions found. Please check your network or Appwrite Cloud availability.",
289
+ );
290
+ }
291
+ return regions
292
+ .filter((region: any) => !region.disabled)
293
+ .map((region: any) => ({
294
+ name: `${region.name} (${region.$id})`,
295
+ value: region.$id,
296
+ }));
216
297
  },
217
- {
218
- type: "search-list",
219
- name: "project",
220
- message: "Choose your Appwrite project.",
221
- choices: async (answers: Answers) => {
222
- const queries = [
223
- JSON.stringify({ method: 'equal', attribute: 'teamId', values: [answers.organization] }),
224
- JSON.stringify({ method: 'orderDesc', attribute: '$id' })
225
- ]
226
-
227
- const { projects } = await paginate(projectsList, { parseOutput: false }, 100, 'projects', queries);
228
-
229
- let choices = projects.map((project: any) => {
230
- return {
231
- name: `${project.name} (${project['$id']})`,
232
- value: {
233
- "$id": project['$id'],
234
- "region": project.region || ''
235
- }
236
- }
237
- })
238
-
239
- if (choices.length === 0) {
240
- throw new Error("No projects found. Please create a new project.")
241
- }
242
-
243
- return choices;
244
- },
245
- when: (answer: Answers) => answer.start === 'existing'
298
+ when: (answer: Answers) => {
299
+ if (answer.start === "existing") return false;
300
+ return isCloud();
246
301
  },
247
- {
248
- type: "list",
249
- name: "region",
250
- message: "Select your Appwrite Cloud region",
251
- choices: async () => {
252
- let client = await sdkForConsole(true);
253
- let response = await client.call("GET", "/console/regions");
254
- let regions = response.regions || [];
255
- if (!regions.length) {
256
- throw new Error("No regions found. Please check your network or Appwrite Cloud availability.");
257
- }
258
- return regions.filter((region: any) => !region.disabled).map((region: any) => ({
259
- name: `${region.name} (${region.$id})`,
260
- value: region.$id
261
- }));
262
- },
263
- when: (answer: Answers) => {
264
- if (answer.start === 'existing') return false;
265
- return isCloud();
266
- }
267
- }
302
+ },
268
303
  ];
269
304
 
270
305
  export const questionsInitProjectAutopull: Question[] = [
271
- {
272
- type: "confirm",
273
- name: "autopull",
274
- message:
275
- `Would you like to pull all resources from project you just linked?`
276
- },
306
+ {
307
+ type: "confirm",
308
+ name: "autopull",
309
+ message: `Would you like to pull all resources from the project you just linked?`,
310
+ },
277
311
  ];
278
312
 
279
313
  export const questionsPullResources: Question[] = [
280
- {
281
- type: "list",
282
- name: "resource",
283
- message: "Which resources would you like to pull?",
284
- choices: [
285
- { name: `Settings ${chalk.blackBright(`(Project)`)}`, value: 'settings' },
286
- { name: `Functions ${chalk.blackBright(`(Deployment)`)}`, value: 'functions' },
287
- { name: `Tables ${chalk.blackBright(`(TablesDB)`)}`, value: 'tables' },
288
- { name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
289
- { name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
290
- { name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' },
291
- { name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
292
- ]
293
- }
314
+ {
315
+ type: "list",
316
+ name: "resource",
317
+ message: "Which resources would you like to pull?",
318
+ choices: [
319
+ { name: `Settings ${chalk.blackBright(`(Project)`)}`, value: "settings" },
320
+ {
321
+ name: `Functions ${chalk.blackBright(`(Deployment)`)}`,
322
+ value: "functions",
323
+ },
324
+ { name: `Tables ${chalk.blackBright(`(TablesDB)`)}`, value: "tables" },
325
+ { name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: "buckets" },
326
+ { name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: "teams" },
327
+ { name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: "messages" },
328
+ {
329
+ name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`,
330
+ value: "collections",
331
+ },
332
+ ],
333
+ },
294
334
  ];
295
335
 
296
336
  export const questionsPullFunctions: Question[] = [
297
- {
298
- type: "checkbox",
299
- name: "functions",
300
- message: "Which functions would you like to pull?",
301
- validate: (value: any) => validateRequired('function', value),
302
- choices: async () => {
303
- const { functions } = await paginate(functionsList, { parseOutput: false }, 100, 'functions');
304
-
305
- if (functions.length === 0) {
306
- throw "We couldn't find any functions in your Appwrite project";
307
- }
308
- return functions.map((func: any) => {
309
- return {
310
- name: `${func.name} (${func.$id})`,
311
- value: { ...func }
312
- }
313
- });
314
- }
315
- }
337
+ {
338
+ type: "checkbox",
339
+ name: "functions",
340
+ message: "Which functions would you like to pull?",
341
+ validate: (value: any) => validateRequired("function", value),
342
+ choices: async () => {
343
+ const { functions } = await paginate(
344
+ async () => (await getFunctionsService()).list(),
345
+ { parseOutput: false },
346
+ 100,
347
+ "functions",
348
+ );
349
+
350
+ if (functions.length === 0) {
351
+ throw `We couldn't find any functions in your ${SDK_TITLE} project`;
352
+ }
353
+ return functions.map((func: any) => {
354
+ return {
355
+ name: `${func.name} (${func.$id})`,
356
+ value: { ...func },
357
+ };
358
+ });
359
+ },
360
+ },
316
361
  ];
317
362
 
318
363
  export const questionsPullFunctionsCode: Question[] = [
319
- {
320
- type: "confirm",
321
- name: "override",
322
- message: "Do you want to pull source code of the latest deployment?"
323
- },
364
+ {
365
+ type: "confirm",
366
+ name: "override",
367
+ message: "Do you want to pull source code of the latest deployment?",
368
+ },
324
369
  ];
325
370
 
326
371
  export const questionsPullSites: Question[] = [
327
- {
328
- type: "checkbox",
329
- name: "sites",
330
- message: "Which sites would you like to pull?",
331
- validate: (value: any) => validateRequired('site', value),
332
- choices: async () => {
333
- const { sites } = await paginate(sitesList, { parseOutput: false }, 100, 'sites');
334
-
335
- if (sites.length === 0) {
336
- throw "We couldn't find any sites in your Appwrite project";
337
- }
338
- return sites.map((site: any) => {
339
- return {
340
- name: `${site.name} (${site.$id})`,
341
- value: { ...site }
342
- }
343
- });
344
- }
345
- }
372
+ {
373
+ type: "checkbox",
374
+ name: "sites",
375
+ message: "Which sites would you like to pull?",
376
+ validate: (value: any) => validateRequired("site", value),
377
+ choices: async () => {
378
+ const { sites } = await paginate(
379
+ async () => (await getSitesService()).list(),
380
+ { parseOutput: false },
381
+ 100,
382
+ "sites",
383
+ );
384
+
385
+ if (sites.length === 0) {
386
+ throw `We couldn't find any sites in your ${SDK_TITLE} project`;
387
+ }
388
+ return sites.map((site: any) => {
389
+ return {
390
+ name: `${site.name} (${site.$id})`,
391
+ value: { ...site },
392
+ };
393
+ });
394
+ },
395
+ },
346
396
  ];
347
397
 
348
398
  export const questionsPullSitesCode: Question[] = [
349
- {
350
- type: "confirm",
351
- name: "override",
352
- message: "Do you want to pull source code of the latest deployment?"
353
- },
399
+ {
400
+ type: "confirm",
401
+ name: "override",
402
+ message: "Do you want to pull source code of the latest deployment?",
403
+ },
354
404
  ];
355
405
 
356
406
  export const questionsCreateFunction: Question[] = [
357
- {
358
- type: "input",
359
- name: "name",
360
- message: "What would you like to name your function?",
361
- default: "My Awesome Function"
407
+ {
408
+ type: "input",
409
+ name: "name",
410
+ message: "What would you like to name your function?",
411
+ default: "My Awesome Function",
412
+ },
413
+ {
414
+ type: "input",
415
+ name: "id",
416
+ message: "What ID would you like to have for your function?",
417
+ default: "unique()",
418
+ },
419
+ {
420
+ type: "list",
421
+ name: "runtime",
422
+ message: "What runtime would you like to use?",
423
+ choices: async () => {
424
+ let response = await (await getFunctionsService()).listRuntimes();
425
+ let runtimes = response["runtimes"];
426
+ let choices = runtimes.map((runtime: any, idx: number) => {
427
+ return {
428
+ name: `${runtime.name} (${runtime["$id"]})`,
429
+ value: {
430
+ id: runtime["$id"],
431
+ name: runtime["$id"].split("-")[0],
432
+ entrypoint: getEntrypoint(runtime["$id"]),
433
+ ignore: getIgnores(runtime["$id"]),
434
+ commands: getInstallCommand(runtime["$id"]),
435
+ },
436
+ };
437
+ });
438
+ return choices;
362
439
  },
363
- {
364
- type: "input",
365
- name: "id",
366
- message: "What ID would you like to have for your function?",
367
- default: "unique()"
440
+ },
441
+ {
442
+ type: "list",
443
+ name: "specification",
444
+ message: "What specification would you like to use?",
445
+ choices: async () => {
446
+ let response = await (await getFunctionsService()).listSpecifications();
447
+ let specifications = response["specifications"];
448
+ let choices = specifications.map((spec: any, idx: number) => {
449
+ return {
450
+ name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
451
+ value: spec.slug,
452
+ disabled: spec.enabled === false ? "Upgrade to use" : false,
453
+ };
454
+ });
455
+ return choices;
368
456
  },
369
- {
370
- type: "list",
371
- name: "runtime",
372
- message: "What runtime would you like to use?",
373
- choices: async () => {
374
- let response = await functionsListRuntimes({
375
- parseOutput: false
376
- })
377
- let runtimes = response["runtimes"]
378
- let choices = runtimes.map((runtime: any, idx: number) => {
379
- return {
380
- name: `${runtime.name} (${runtime['$id']})`,
381
- value: {
382
- id: runtime['$id'],
383
- name: runtime['$id'].split('-')[0],
384
- entrypoint: getEntrypoint(runtime['$id']),
385
- ignore: getIgnores(runtime['$id']),
386
- commands: getInstallCommand(runtime['$id'])
387
- },
388
- }
389
- })
390
- return choices;
391
- },
392
- },
393
- {
394
- type: "list",
395
- name: "specification",
396
- message: "What specification would you like to use?",
397
- choices: async () => {
398
- let response = await functionsListSpecifications({
399
- parseOutput: false
400
- })
401
- let specifications = response["specifications"]
402
- let choices = specifications.map((spec: any, idx: number) => {
403
- return {
404
- name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
405
- value: spec.slug,
406
- disabled: spec.enabled === false ? 'Upgrade to use' : false
407
- }
408
- })
409
- return choices;
410
- },
411
- }
457
+ },
412
458
  ];
413
459
 
414
- export const questionsCreateFunctionSelectTemplate = (templates: string[]): Question[] => {
415
- return [
416
- {
417
- type: "search-list",
418
- name: "template",
419
- message: "What template would you like to use?",
420
- choices: templates.map((template) => {
421
- const name = `${template[0].toUpperCase()}${template.split('').slice(1).join('')}`.replace(/[-_]/g, ' ');
422
-
423
- return { value: template, name }
424
- })
425
- }
426
- ];
460
+ export const questionsCreateFunctionSelectTemplate = (
461
+ templates: string[],
462
+ ): Question[] => {
463
+ return [
464
+ {
465
+ type: "search-list",
466
+ name: "template",
467
+ message: "What template would you like to use?",
468
+ choices: templates.map((template) => {
469
+ const name =
470
+ `${template[0].toUpperCase()}${template.split("").slice(1).join("")}`.replace(
471
+ /[-_]/g,
472
+ " ",
473
+ );
474
+
475
+ return { value: template, name };
476
+ }),
477
+ },
478
+ ];
427
479
  };
428
480
 
429
481
  export const questionsCreateBucket: Question[] = [
430
- {
431
- type: "input",
432
- name: "bucket",
433
- message: "What would you like to name your bucket?",
434
- default: "My Awesome Bucket"
435
- },
436
- {
437
- type: "input",
438
- name: "id",
439
- message: "What ID would you like to have for your bucket?",
440
- default: "unique()"
441
- },
442
- {
443
- type: "list",
444
- name: "fileSecurity",
445
- message: "Enable File-Security configuring permissions for individual file",
446
- choices: ["No", "Yes"]
447
- }
482
+ {
483
+ type: "input",
484
+ name: "bucket",
485
+ message: "What would you like to name your bucket?",
486
+ default: "My Awesome Bucket",
487
+ },
488
+ {
489
+ type: "input",
490
+ name: "id",
491
+ message: "What ID would you like to have for your bucket?",
492
+ default: "unique()",
493
+ },
494
+ {
495
+ type: "list",
496
+ name: "fileSecurity",
497
+ message: "Enable File-Security configuring permissions for individual file",
498
+ choices: ["No", "Yes"],
499
+ },
448
500
  ];
449
501
 
450
502
  export const questionsCreateTeam: Question[] = [
451
- {
452
- type: "input",
453
- name: "bucket",
454
- message: "What would you like to name your team?",
455
- default: "My Awesome Team"
456
- },
457
- {
458
- type: "input",
459
- name: "id",
460
- message: "What ID would you like to have for your team?",
461
- default: "unique()"
462
- }
503
+ {
504
+ type: "input",
505
+ name: "team",
506
+ message: "What would you like to name your team?",
507
+ default: "My Awesome Team",
508
+ },
509
+ {
510
+ type: "input",
511
+ name: "id",
512
+ message: "What ID would you like to have for your team?",
513
+ default: "unique()",
514
+ },
463
515
  ];
464
516
 
465
517
  export const questionsCreateCollection: Question[] = [
466
- {
467
- type: "list",
468
- name: "method",
469
- message: "What database would you like to use for your collection",
470
- choices: ["New", "Existing"],
471
- when: async () => {
472
- return localConfig.getDatabases().length !== 0;
473
- }
518
+ {
519
+ type: "list",
520
+ name: "method",
521
+ message: "What database would you like to use for your collection",
522
+ choices: ["New", "Existing"],
523
+ when: async () => {
524
+ return localConfig.getDatabases().length !== 0;
474
525
  },
475
- {
476
- type: "search-list",
477
- name: "database",
478
- message: "Choose the collection database",
479
- choices: async () => {
480
- const databases = localConfig.getDatabases();
481
-
482
- let choices = databases.map((database: any, idx: number) => {
483
- return {
484
- name: `${database.name} (${database.$id})`,
485
- value: database.$id
486
- }
487
- })
488
-
489
- if (choices.length === 0) {
490
- throw new Error("No databases found. Please create one in project console.")
491
- }
492
-
493
- return choices;
494
- },
495
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() === 'existing'
496
- },
497
- {
498
- type: "input",
499
- name: "databaseName",
500
- message: "What would you like to name your database?",
501
- default: "My Awesome Database",
502
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() !== 'existing'
503
- },
504
- {
505
- type: "input",
506
- name: "databaseId",
507
- message: "What ID would you like to have for your database?",
508
- default: "unique()",
509
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() !== 'existing'
510
- },
511
- {
512
- type: "input",
513
- name: "collection",
514
- message: "What would you like to name your collection?",
515
- default: "My Awesome Collection"
526
+ },
527
+ {
528
+ type: "search-list",
529
+ name: "database",
530
+ message: "Choose the collection database",
531
+ choices: async () => {
532
+ const databases = localConfig.getDatabases();
533
+
534
+ let choices = databases.map((database: any, idx: number) => {
535
+ return {
536
+ name: `${database.name} (${database.$id})`,
537
+ value: database.$id,
538
+ };
539
+ });
540
+
541
+ if (choices.length === 0) {
542
+ throw new Error(
543
+ "No databases found. Please create one in project console.",
544
+ );
545
+ }
546
+
547
+ return choices;
516
548
  },
517
- {
518
- type: "input",
519
- name: "id",
520
- message: "What ID would you like to have for your collection?",
521
- default: "unique()"
522
- },
523
- {
524
- type: "list",
525
- name: "documentSecurity",
526
- message: "Enable document security for configuring permissions for individual documents",
527
- choices: ["No", "Yes"]
528
- }
549
+ when: (answers: Answers) =>
550
+ (answers.method ?? "").toLowerCase() === "existing",
551
+ },
552
+ {
553
+ type: "input",
554
+ name: "databaseName",
555
+ message: "What would you like to name your database?",
556
+ default: "My Awesome Database",
557
+ when: (answers: Answers) =>
558
+ (answers.method ?? "").toLowerCase() !== "existing",
559
+ },
560
+ {
561
+ type: "input",
562
+ name: "databaseId",
563
+ message: "What ID would you like to have for your database?",
564
+ default: "unique()",
565
+ when: (answers: Answers) =>
566
+ (answers.method ?? "").toLowerCase() !== "existing",
567
+ },
568
+ {
569
+ type: "input",
570
+ name: "collection",
571
+ message: "What would you like to name your collection?",
572
+ default: "My Awesome Collection",
573
+ },
574
+ {
575
+ type: "input",
576
+ name: "id",
577
+ message: "What ID would you like to have for your collection?",
578
+ default: "unique()",
579
+ },
580
+ {
581
+ type: "list",
582
+ name: "documentSecurity",
583
+ message:
584
+ "Enable document security for configuring permissions for individual documents",
585
+ choices: ["No", "Yes"],
586
+ },
529
587
  ];
530
588
 
531
589
  export const questionsCreateTable: Question[] = [
532
- {
533
- type: "list",
534
- name: "method",
535
- message: "What database would you like to use for your table?",
536
- choices: ["New", "Existing"],
537
- when: async () => {
538
- return localConfig.getTablesDBs().length !== 0;
539
- }
590
+ {
591
+ type: "list",
592
+ name: "method",
593
+ message: "What database would you like to use for your table?",
594
+ choices: ["New", "Existing"],
595
+ when: async () => {
596
+ return localConfig.getTablesDBs().length !== 0;
540
597
  },
541
- {
542
- type: "search-list",
543
- name: "database",
544
- message: "Choose the table database",
545
- choices: async () => {
546
- const databases = localConfig.getTablesDBs();
547
-
548
- let choices = databases.map((database: any, idx: number) => {
549
- return {
550
- name: `${database.name} (${database.$id})`,
551
- value: database.$id
552
- }
553
- })
554
-
555
- if (choices.length === 0) {
556
- throw new Error("No databases found. Please create one in project console.")
557
- }
558
-
559
- return choices;
560
- },
561
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() === 'existing'
562
- },
563
- {
564
- type: "input",
565
- name: "databaseName",
566
- message: "What would you like to name your database?",
567
- default: "My Awesome Database",
568
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() !== 'existing'
598
+ },
599
+ {
600
+ type: "search-list",
601
+ name: "database",
602
+ message: "Choose the table database",
603
+ choices: async () => {
604
+ const databases = localConfig.getTablesDBs();
605
+
606
+ let choices = databases.map((database: any, idx: number) => {
607
+ return {
608
+ name: `${database.name} (${database.$id})`,
609
+ value: database.$id,
610
+ };
611
+ });
612
+
613
+ if (choices.length === 0) {
614
+ throw new Error(
615
+ "No databases found. Please create one in project console.",
616
+ );
617
+ }
618
+
619
+ return choices;
569
620
  },
570
- {
571
- type: "input",
572
- name: "databaseId",
573
- message: "What ID would you like to have for your database?",
574
- default: "unique()",
575
- when: (answers: Answers) => (answers.method ?? '').toLowerCase() !== 'existing'
576
- },
577
- {
578
- type: "input",
579
- name: "table",
580
- message: "What would you like to name your table?",
581
- default: "My Awesome Table"
582
- },
583
- {
584
- type: "input",
585
- name: "id",
586
- message: "What ID would you like to have for your table?",
587
- default: "unique()"
588
- },
589
- {
590
- type: "list",
591
- name: "rowSecurity",
592
- message: "Enable row security for configuring permissions for individual rows",
593
- choices: ["No", "Yes"]
594
- }
621
+ when: (answers: Answers) =>
622
+ (answers.method ?? "").toLowerCase() === "existing",
623
+ },
624
+ {
625
+ type: "input",
626
+ name: "databaseName",
627
+ message: "What would you like to name your database?",
628
+ default: "My Awesome Database",
629
+ when: (answers: Answers) =>
630
+ (answers.method ?? "").toLowerCase() !== "existing",
631
+ },
632
+ {
633
+ type: "input",
634
+ name: "databaseId",
635
+ message: "What ID would you like to have for your database?",
636
+ default: "unique()",
637
+ when: (answers: Answers) =>
638
+ (answers.method ?? "").toLowerCase() !== "existing",
639
+ },
640
+ {
641
+ type: "input",
642
+ name: "table",
643
+ message: "What would you like to name your table?",
644
+ default: "My Awesome Table",
645
+ },
646
+ {
647
+ type: "input",
648
+ name: "id",
649
+ message: "What ID would you like to have for your table?",
650
+ default: "unique()",
651
+ },
652
+ {
653
+ type: "list",
654
+ name: "rowSecurity",
655
+ message:
656
+ "Enable row security for configuring permissions for individual rows",
657
+ choices: ["No", "Yes"],
658
+ },
595
659
  ];
596
660
 
597
661
  export const questionsCreateMessagingTopic: Question[] = [
598
- {
599
- type: "input",
600
- name: "topic",
601
- message: "What would you like to name your messaging topic?",
602
- default: "My Awesome Topic"
603
- },
604
- {
605
- type: "input",
606
- name: "id",
607
- message: "What ID would you like to have for your messaging topic?",
608
- default: "unique()"
609
- }
662
+ {
663
+ type: "input",
664
+ name: "topic",
665
+ message: "What would you like to name your messaging topic?",
666
+ default: "My Awesome Topic",
667
+ },
668
+ {
669
+ type: "input",
670
+ name: "id",
671
+ message: "What ID would you like to have for your messaging topic?",
672
+ default: "unique()",
673
+ },
610
674
  ];
611
675
 
612
676
  export const questionsPullCollection: Question[] = [
613
- {
614
- type: "checkbox",
615
- name: "databases",
616
- message: "From which database would you like to pull collections?",
617
- validate: (value: any) => validateRequired('collection', value),
618
- choices: async () => {
619
- let response = await databasesList({
620
- parseOutput: false
621
- })
622
- let databases = response["databases"]
623
-
624
- if (databases.length <= 0) {
625
- throw new Error("No databases found. Please create one in project console.")
626
- }
627
- let choices = databases.map((database: any, idx: number) => {
628
- return {
629
- name: `${database.name} (${database.$id})`,
630
- value: database.$id
631
- }
632
- })
633
- return choices;
634
- }
635
- }
677
+ {
678
+ type: "checkbox",
679
+ name: "databases",
680
+ message: "From which database would you like to pull collections?",
681
+ validate: (value: any) => validateRequired("collection", value),
682
+ choices: async () => {
683
+ let response = await (await getDatabasesService()).list();
684
+ let databases = response["databases"];
685
+
686
+ if (databases.length <= 0) {
687
+ throw new Error(
688
+ "No databases found. Please create one in project console.",
689
+ );
690
+ }
691
+ let choices = databases.map((database: any, idx: number) => {
692
+ return {
693
+ name: `${database.name} (${database.$id})`,
694
+ value: database.$id,
695
+ };
696
+ });
697
+ return choices;
698
+ },
699
+ },
636
700
  ];
637
701
 
638
702
  export const questionsLogin: Question[] = [
639
- {
640
- type: "list",
641
- name: "method",
642
- message: "What you like to do?",
643
- choices: [
644
- { name: 'Login to an account', value: 'login' },
645
- { name: 'Switch to an account', value: 'select' }
646
- ],
647
- when: () => globalConfig.getSessions().length >= 2
648
- },
649
- {
650
- type: "input",
651
- name: "email",
652
- message: "Enter your email",
653
- validate(value: string) {
654
- if (!value) {
655
- return "Please enter your email";
656
- }
657
- return true;
658
- },
659
- when: (answers: Answers) => answers.method !== 'select'
703
+ {
704
+ type: "list",
705
+ name: "method",
706
+ message: "What would you like to do?",
707
+ choices: [
708
+ { name: "Login to an account", value: "login" },
709
+ { name: "Switch to an account", value: "select" },
710
+ ],
711
+ when: () => globalConfig.getSessions().length >= 2,
712
+ },
713
+ {
714
+ type: "input",
715
+ name: "email",
716
+ message: "Enter your email",
717
+ validate(value: string) {
718
+ if (!value) {
719
+ return "Please enter your email";
720
+ }
721
+ return true;
660
722
  },
661
- {
662
- type: "password",
663
- name: "password",
664
- message: "Enter your password",
665
- mask: "*",
666
- validate(value: string) {
667
- if (!value) {
668
- return "Please enter your password";
669
- }
670
- return true;
671
- },
672
- when: (answers: Answers) => answers.method !== 'select'
723
+ when: (answers: Answers) => answers.method !== "select",
724
+ },
725
+ {
726
+ type: "password",
727
+ name: "password",
728
+ message: "Enter your password",
729
+ mask: "*",
730
+ validate(value: string) {
731
+ if (!value) {
732
+ return "Please enter your password";
733
+ }
734
+ return true;
673
735
  },
674
- {
675
- type: "search-list",
676
- name: "accountId",
677
- message: "Select an account to use",
678
- choices() {
679
- const sessions = globalConfig.getSessions();
680
- const current = globalConfig.getCurrentSession();
681
-
682
- const data: Choice[] = [];
683
-
684
- const longestEmail = sessions.reduce((prev: any, current: any) => (prev && (prev.email ?? '').length > (current.email ?? '').length) ? prev : current).email.length;
685
-
686
- sessions.forEach((session: any) => {
687
- if (session.email) {
688
- data.push({
689
- current: current === session.id,
690
- value: session.id,
691
- name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk.green.bold('current') : ' '.repeat(6)} ${session.endpoint}`,
692
- });
693
- }
694
- })
695
-
696
- return data.sort((a, b) => Number(b.current) - Number(a.current))
697
- },
698
- when: (answers: Answers) => answers.method === 'select'
736
+ when: (answers: Answers) => answers.method !== "select",
737
+ },
738
+ {
739
+ type: "search-list",
740
+ name: "accountId",
741
+ message: "Select an account to use",
742
+ choices() {
743
+ const sessions = globalConfig.getSessions();
744
+ const current = globalConfig.getCurrentSession();
745
+
746
+ const data: Choice[] = [];
747
+
748
+ const longestEmail = sessions.reduce((prev: any, current: any) =>
749
+ prev && (prev.email ?? "").length > (current.email ?? "").length
750
+ ? prev
751
+ : current,
752
+ ).email.length;
753
+
754
+ sessions.forEach((session: any) => {
755
+ if (session.email) {
756
+ data.push({
757
+ current: current === session.id,
758
+ value: session.id,
759
+ name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk.green.bold("current") : " ".repeat(6)} ${session.endpoint}`,
760
+ });
761
+ }
762
+ });
763
+
764
+ return data.sort((a, b) => Number(b.current) - Number(a.current));
699
765
  },
766
+ when: (answers: Answers) => answers.method === "select",
767
+ },
700
768
  ];
701
769
 
702
770
  export const questionGetEndpoint: Question[] = [
703
- {
704
- type: "input",
705
- name: "endpoint",
706
- message: "Enter the endpoint of your Appwrite server",
707
- default: "http://localhost/v1",
708
- async validate(value: string) {
709
- if (!value) {
710
- return "Please enter a valid endpoint.";
711
- }
712
- let client = new Client().setEndpoint(value);
713
- try {
714
- let response = await client.call('get', '/health/version');
715
- if (response.version) {
716
- return true;
717
- } else {
718
- throw new Error();
719
- }
720
- } catch (error) {
721
- return "Invalid endpoint or your Appwrite server is not running as expected.";
722
- }
771
+ {
772
+ type: "input",
773
+ name: "endpoint",
774
+ message: `Enter the endpoint of your ${SDK_TITLE} server`,
775
+ default: "http://localhost/v1",
776
+ async validate(value: string) {
777
+ if (!value) {
778
+ return "Please enter a valid endpoint.";
779
+ }
780
+ let client = new Client().setEndpoint(value);
781
+ try {
782
+ let response = (await client.call(
783
+ "get",
784
+ new URL(value + "/health/version"),
785
+ )) as { version?: string };
786
+ if (response.version) {
787
+ return true;
788
+ } else {
789
+ throw new Error();
723
790
  }
724
- }
791
+ } catch (error) {
792
+ return "Invalid endpoint or your Appwrite server is not running as expected.";
793
+ }
794
+ },
795
+ },
725
796
  ];
726
797
 
727
798
  export const questionsLogout: Question[] = [
728
- {
729
- type: "checkbox",
730
- name: "accounts",
731
- message: "Select accounts to logout from",
732
- validate: (value: any) => validateRequired('account', value),
733
- choices() {
734
- const sessions = globalConfig.getSessions();
735
- const current = globalConfig.getCurrentSession();
736
-
737
- const data: Choice[] = [];
738
-
739
- const longestEmail = sessions.reduce((prev: any, current: any) => (prev && (prev.email ?? '').length > (current.email ?? '').length) ? prev : current).email.length;
740
-
741
- sessions.forEach((session: any) => {
742
- if (session.email) {
743
- data.push({
744
- current: current === session.id,
745
- value: session.id,
746
- name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk.green.bold('current') : ' '.repeat(6)} ${session.endpoint}`,
747
- });
748
- }
749
- })
750
-
751
- return data.sort((a, b) => Number(b.current) - Number(a.current))
799
+ {
800
+ type: "checkbox",
801
+ name: "accounts",
802
+ message: "Select accounts to logout from",
803
+ validate: (value: any) => validateRequired("account", value),
804
+ choices() {
805
+ const sessions = globalConfig.getSessions();
806
+ const current = globalConfig.getCurrentSession();
807
+
808
+ const data: Choice[] = [];
809
+
810
+ const longestEmail = sessions.reduce((prev: any, current: any) =>
811
+ prev && (prev.email ?? "").length > (current.email ?? "").length
812
+ ? prev
813
+ : current,
814
+ ).email.length;
815
+
816
+ sessions.forEach((session: any) => {
817
+ if (session.email) {
818
+ data.push({
819
+ current: current === session.id,
820
+ value: session.id,
821
+ name: `${session.email.padEnd(longestEmail)} ${current === session.id ? chalk.green.bold("current") : " ".repeat(6)} ${session.endpoint}`,
822
+ });
752
823
  }
753
- }
824
+ });
825
+
826
+ return data.sort((a, b) => Number(b.current) - Number(a.current));
827
+ },
828
+ },
754
829
  ];
755
830
 
756
831
  export const questionsPushResources: Question[] = [
757
- {
758
- type: "list",
759
- name: "resource",
760
- message: "Which resources would you like to push?",
761
- choices: [
762
- { name: `Settings ${chalk.blackBright(`(Project)`)}`, value: 'settings' },
763
- { name: `Functions ${chalk.blackBright(`(Deployment)`)}`, value: 'functions' },
764
- { name: `Tables ${chalk.blackBright(`(TablesDB)`)}`, value: 'tables' },
765
- { name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: 'buckets' },
766
- { name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: 'teams' },
767
- { name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: 'messages' },
768
- { name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`, value: 'collections' }
769
- ]
770
- }
832
+ {
833
+ type: "list",
834
+ name: "resource",
835
+ message: "Which resources would you like to push?",
836
+ choices: [
837
+ { name: `Settings ${chalk.blackBright(`(Project)`)}`, value: "settings" },
838
+ {
839
+ name: `Functions ${chalk.blackBright(`(Deployment)`)}`,
840
+ value: "functions",
841
+ },
842
+ { name: `Tables ${chalk.blackBright(`(TablesDB)`)}`, value: "tables" },
843
+ { name: `Buckets ${chalk.blackBright(`(Storage)`)}`, value: "buckets" },
844
+ { name: `Teams ${chalk.blackBright(`(Auth)`)}`, value: "teams" },
845
+ { name: `Topics ${chalk.blackBright(`(Messaging)`)}`, value: "messages" },
846
+ {
847
+ name: `Collections ${chalk.blackBright(`(Legacy Databases)`)}`,
848
+ value: "collections",
849
+ },
850
+ ],
851
+ },
771
852
  ];
772
853
 
773
854
  export const questionsInitResources: Question[] = [
774
- {
775
- type: "list",
776
- name: "resource",
777
- message: "Which resource would you create?",
778
- choices: [
779
- { name: 'Function', value: 'function' },
780
- { name: 'Site', value: 'site' },
781
- { name: 'Table', value: 'table' },
782
- { name: 'Bucket', value: 'bucket' },
783
- { name: 'Team', value: 'team' },
784
- { name: 'Topic', value: 'message' },
785
- { name: 'Collection', value: 'collection' }
786
- ]
787
- }
855
+ {
856
+ type: "list",
857
+ name: "resource",
858
+ message: "Which resource would you create?",
859
+ choices: [
860
+ { name: "Function", value: "function" },
861
+ { name: "Site", value: "site" },
862
+ { name: "Table", value: "table" },
863
+ { name: "Bucket", value: "bucket" },
864
+ { name: "Team", value: "team" },
865
+ { name: "Topic", value: "message" },
866
+ { name: "Collection", value: "collection" },
867
+ ],
868
+ },
788
869
  ];
789
870
 
790
871
  export const questionsPushSites: Question[] = [
791
- {
792
- type: "checkbox",
793
- name: "sites",
794
- message: "Which sites would you like to push?",
795
- validate: (value: any) => validateRequired('site', value),
796
- when: () => localConfig.getSites().length > 0,
797
- choices: () => {
798
- let sites = localConfig.getSites();
799
- checkDeployConditions(localConfig)
800
- let choices = sites.map((site: any, idx: number) => {
801
- return {
802
- name: `${site.name} (${site.$id})`,
803
- value: site.$id
804
- }
805
- })
806
- return choices;
807
- }
872
+ {
873
+ type: "checkbox",
874
+ name: "sites",
875
+ message: "Which sites would you like to push?",
876
+ validate: (value: any) => validateRequired("site", value),
877
+ when: () => localConfig.getSites().length > 0,
878
+ choices: () => {
879
+ let sites = localConfig.getSites();
880
+ checkDeployConditions(localConfig);
881
+ let choices = sites.map((site: any, idx: number) => {
882
+ return {
883
+ name: `${site.name} (${site.$id})`,
884
+ value: site.$id,
885
+ };
886
+ });
887
+ return choices;
808
888
  },
889
+ },
809
890
  ];
810
891
 
811
892
  export const questionsPushFunctions: Question[] = [
812
- {
813
- type: "checkbox",
814
- name: "functions",
815
- message: "Which functions would you like to push?",
816
- validate: (value: any) => validateRequired('function', value),
817
- when: () => localConfig.getFunctions().length > 0,
818
- choices: () => {
819
- let functions = localConfig.getFunctions();
820
- checkDeployConditions(localConfig)
821
- let choices = functions.map((func: any, idx: number) => {
822
- return {
823
- name: `${func.name} (${func.$id})`,
824
- value: func.$id
825
- }
826
- })
827
- return choices;
828
- }
893
+ {
894
+ type: "checkbox",
895
+ name: "functions",
896
+ message: "Which functions would you like to push?",
897
+ validate: (value: any) => validateRequired("function", value),
898
+ when: () => localConfig.getFunctions().length > 0,
899
+ choices: () => {
900
+ let functions = localConfig.getFunctions();
901
+ checkDeployConditions(localConfig);
902
+ let choices = functions.map((func: any, idx: number) => {
903
+ return {
904
+ name: `${func.name} (${func.$id})`,
905
+ value: func.$id,
906
+ };
907
+ });
908
+ return choices;
829
909
  },
910
+ },
830
911
  ];
831
912
 
832
913
  export const questionsPushCollections: Question[] = [
833
- {
834
- type: "checkbox",
835
- name: "collections",
836
- message: "Which collections would you like to push?",
837
- validate: (value: any) => validateRequired('collection', value),
838
- when: () => localConfig.getCollections().length > 0,
839
- choices: () => {
840
- let collections = localConfig.getCollections();
841
- checkDeployConditions(localConfig)
842
-
843
- return collections.map((collection: any) => {
844
- return {
845
- name: `${collection.name} (${collection['databaseId']} - ${collection['$id']})`,
846
- value: `${collection['databaseId']}|${collection['$id']}`
847
- }
848
- });
849
- }
850
- }
914
+ {
915
+ type: "checkbox",
916
+ name: "collections",
917
+ message: "Which collections would you like to push?",
918
+ validate: (value: any) => validateRequired("collection", value),
919
+ when: () => localConfig.getCollections().length > 0,
920
+ choices: () => {
921
+ let collections = localConfig.getCollections();
922
+ checkDeployConditions(localConfig);
923
+
924
+ return collections.map((collection: any) => {
925
+ return {
926
+ name: `${collection.name} (${collection["databaseId"]} - ${collection["$id"]})`,
927
+ value: `${collection["databaseId"]}|${collection["$id"]}`,
928
+ };
929
+ });
930
+ },
931
+ },
851
932
  ];
852
933
 
853
934
  export const questionsPushTables: Question[] = [
854
- {
855
- type: "checkbox",
856
- name: "tables",
857
- message: "Which tables would you like to push?",
858
- validate: (value: any) => validateRequired('table', value),
859
- when: () => localConfig.getTables().length > 0,
860
- choices: () => {
861
- let tables = localConfig.getTables();
862
- checkDeployConditions(localConfig)
863
-
864
- return tables.map((table: any) => {
865
- return {
866
- name: `${table.name} (${table['databaseId']} - ${table['$id']})`,
867
- value: `${table['databaseId']}|${table['$id']}`
868
- }
869
- });
870
- }
871
- }
935
+ {
936
+ type: "checkbox",
937
+ name: "tables",
938
+ message: "Which tables would you like to push?",
939
+ validate: (value: any) => validateRequired("table", value),
940
+ when: () => localConfig.getTables().length > 0,
941
+ choices: () => {
942
+ let tables = localConfig.getTables();
943
+ checkDeployConditions(localConfig);
944
+
945
+ return tables.map((table: any) => {
946
+ return {
947
+ name: `${table.name} (${table["databaseId"]} - ${table["$id"]})`,
948
+ value: `${table["databaseId"]}|${table["$id"]}`,
949
+ };
950
+ });
951
+ },
952
+ },
872
953
  ];
873
954
 
874
955
  export const questionPushChanges: Question[] = [
875
- {
876
- type: "input",
877
- name: "changes",
878
- message: `Are you sure you want to apply these changes? (YES/NO)`
879
- }
956
+ {
957
+ type: "input",
958
+ name: "changes",
959
+ message: `Are you sure you want to apply these changes? (YES/NO)`,
960
+ },
880
961
  ];
881
962
 
882
963
  export const questionPushChangesConfirmation: Question[] = [
883
- {
884
- type: "input",
885
- name: "changes",
886
- message: `Please type 'YES' or 'NO':`
887
- }
964
+ {
965
+ type: "input",
966
+ name: "changes",
967
+ message: `Please type 'YES' or 'NO':`,
968
+ },
888
969
  ];
889
970
 
890
971
  export const questionsPushBuckets: Question[] = [
891
- {
892
- type: "checkbox",
893
- name: "buckets",
894
- message: "Which buckets would you like to push?",
895
- validate: (value: any) => validateRequired('bucket', value),
896
- when: () => localConfig.getBuckets().length > 0,
897
- choices: () => {
898
- let buckets = localConfig.getBuckets();
899
- checkDeployConditions(localConfig)
900
-
901
- return buckets.map((bucket: any) => {
902
- return {
903
- name: `${bucket.name} (${bucket['$id']})`,
904
- value: bucket.$id
905
- }
906
- });
907
- }
908
- }
972
+ {
973
+ type: "checkbox",
974
+ name: "buckets",
975
+ message: "Which buckets would you like to push?",
976
+ validate: (value: any) => validateRequired("bucket", value),
977
+ when: () => localConfig.getBuckets().length > 0,
978
+ choices: () => {
979
+ let buckets = localConfig.getBuckets();
980
+ checkDeployConditions(localConfig);
981
+
982
+ return buckets.map((bucket: any) => {
983
+ return {
984
+ name: `${bucket.name} (${bucket["$id"]})`,
985
+ value: bucket.$id,
986
+ };
987
+ });
988
+ },
989
+ },
909
990
  ];
910
991
 
911
992
  export const questionsPushMessagingTopics: Question[] = [
912
- {
913
- type: "checkbox",
914
- name: "topics",
915
- message: "Which messaging topic would you like to push?",
916
- validate: (value: any) => validateRequired('topics', value),
917
- when: () => localConfig.getMessagingTopics().length > 0,
918
- choices: () => {
919
- let topics = localConfig.getMessagingTopics();
920
-
921
- return topics.map((topic: any) => {
922
- return {
923
- name: `${topic.name} (${topic['$id']})`,
924
- value: topic.$id
925
- }
926
- });
927
- }
928
- }
993
+ {
994
+ type: "checkbox",
995
+ name: "topics",
996
+ message: "Which messaging topic would you like to push?",
997
+ validate: (value: any) => validateRequired("topics", value),
998
+ when: () => localConfig.getMessagingTopics().length > 0,
999
+ choices: () => {
1000
+ let topics = localConfig.getMessagingTopics();
1001
+
1002
+ return topics.map((topic: any) => {
1003
+ return {
1004
+ name: `${topic.name} (${topic["$id"]})`,
1005
+ value: topic.$id,
1006
+ };
1007
+ });
1008
+ },
1009
+ },
929
1010
  ];
930
1011
 
931
1012
  export const questionsGetEntrypoint: Question[] = [
932
- {
933
- type: "input",
934
- name: "entrypoint",
935
- message: "Enter the entrypoint",
936
- default: null,
937
- validate(value: string) {
938
- if (!value) {
939
- return "Please enter your entrypoint";
940
- }
941
- return true;
942
- }
1013
+ {
1014
+ type: "input",
1015
+ name: "entrypoint",
1016
+ message: "Enter the entrypoint",
1017
+ validate(value: string) {
1018
+ if (!value) {
1019
+ return "Please enter your entrypoint";
1020
+ }
1021
+ return true;
943
1022
  },
1023
+ },
944
1024
  ];
945
1025
 
946
1026
  export const questionsPushTeams: Question[] = [
947
- {
948
- type: "checkbox",
949
- name: "teams",
950
- message: "Which teams would you like to push?",
951
- validate: (value: any) => validateRequired('team', value),
952
- when: () => localConfig.getTeams().length > 0,
953
- choices: () => {
954
- let teams = localConfig.getTeams();
955
- checkDeployConditions(localConfig);
956
-
957
- return teams.map((team: any) => {
958
- return {
959
- name: `${team.name} (${team['$id']})`,
960
- value: team.$id
961
- }
962
- });
963
- }
1027
+ {
1028
+ type: "checkbox",
1029
+ name: "teams",
1030
+ message: "Which teams would you like to push?",
1031
+ validate: (value: any) => validateRequired("team", value),
1032
+ when: () => localConfig.getTeams().length > 0,
1033
+ choices: () => {
1034
+ let teams = localConfig.getTeams();
1035
+ checkDeployConditions(localConfig);
1036
+
1037
+ return teams.map((team: any) => {
1038
+ return {
1039
+ name: `${team.name} (${team["$id"]})`,
1040
+ value: team.$id,
1041
+ };
1042
+ });
964
1043
  },
1044
+ },
965
1045
  ];
966
1046
 
967
1047
  export const questionsListFactors: Question[] = [
968
- {
969
- type: "list",
970
- name: "factor",
971
- message: "Your account is protected by multi-factor authentication. Please choose one for verification.",
972
- choices: async () => {
973
- let client = await sdkForConsole(false);
974
- const factors = await accountListMFAFactors({
975
- sdk: client,
976
- parseOutput: false
977
- });
978
-
979
- const choices = [
980
- {
981
- name: `Authenticator app (Get a code from a third-party authenticator app)`,
982
- value: 'totp'
983
- },
984
- {
985
- name: `Email (Get a security code at your Appwrite email address)`,
986
- value: 'email'
987
- },
988
- {
989
- name: `SMS (Get a security code on your Appwrite phone number)`,
990
- value: 'phone'
991
- },
992
- {
993
- name: `Recovery code (Use one of your recovery codes for verification)`,
994
- value: 'recoveryCode'
995
- }
996
- ].filter((ch) => factors[ch.value] === true);
997
-
998
- return choices;
999
- }
1000
- }
1048
+ {
1049
+ type: "list",
1050
+ name: "factor",
1051
+ message:
1052
+ "Your account is protected by multi-factor authentication. Please choose one for verification.",
1053
+ choices: async () => {
1054
+ let client = await sdkForConsole(false);
1055
+ const accountClient = new Account(client);
1056
+ const factors = await accountClient.listMfaFactors();
1057
+
1058
+ const choices = [
1059
+ {
1060
+ name: `Authenticator app (Get a code from a third-party authenticator app)`,
1061
+ value: "totp",
1062
+ },
1063
+ {
1064
+ name: `Email (Get a security code at your ${SDK_TITLE} email address)`,
1065
+ value: "email",
1066
+ },
1067
+ {
1068
+ name: `SMS (Get a security code on your ${SDK_TITLE} phone number)`,
1069
+ value: "phone",
1070
+ },
1071
+ {
1072
+ name: `Recovery code (Use one of your recovery codes for verification)`,
1073
+ value: "recoveryCode",
1074
+ },
1075
+ ].filter((ch) => factors[ch.value] === true);
1076
+
1077
+ return choices;
1078
+ },
1079
+ },
1001
1080
  ];
1002
1081
 
1003
1082
  export const questionsMFAChallenge: Question[] = [
1004
- {
1005
- type: "input",
1006
- name: "otp",
1007
- message: "Enter OTP",
1008
- validate(value: string) {
1009
- if (!value) {
1010
- return "Please enter OTP";
1011
- }
1012
- return true;
1013
- },
1014
- }
1083
+ {
1084
+ type: "input",
1085
+ name: "otp",
1086
+ message: "Enter OTP",
1087
+ validate(value: string) {
1088
+ if (!value) {
1089
+ return "Please enter OTP";
1090
+ }
1091
+ return true;
1092
+ },
1093
+ },
1015
1094
  ];
1016
1095
 
1017
1096
  export const questionsRunFunctions: Question[] = [
1018
- {
1019
- type: "list",
1020
- name: "function",
1021
- message: "Which function would you like to develop locally?",
1022
- validate: (value: any) => validateRequired('function', value),
1023
- choices: () => {
1024
- let functions = localConfig.getFunctions();
1025
- if (functions.length === 0) {
1026
- throw new Error("No functions found. Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
1027
- }
1028
- let choices = functions.map((func: any, idx: number) => {
1029
- return {
1030
- name: `${func.name} (${func.$id})`,
1031
- value: func.$id
1032
- }
1033
- })
1034
- return choices;
1035
- }
1036
- }
1097
+ {
1098
+ type: "list",
1099
+ name: "function",
1100
+ message: "Which function would you like to develop locally?",
1101
+ validate: (value: any) => validateRequired("function", value),
1102
+ choices: () => {
1103
+ let functions = localConfig.getFunctions();
1104
+ if (functions.length === 0) {
1105
+ throw new Error(
1106
+ `No functions found. Use '${EXECUTABLE_NAME} pull functions' to synchronize existing one, or use '${EXECUTABLE_NAME} init function' to create a new one.`,
1107
+ );
1108
+ }
1109
+ let choices = functions.map((func: any, idx: number) => {
1110
+ return {
1111
+ name: `${func.name} (${func.$id})`,
1112
+ value: func.$id,
1113
+ };
1114
+ });
1115
+ return choices;
1116
+ },
1117
+ },
1037
1118
  ];
1038
1119
 
1039
1120
  export const questionsCreateSite: Question[] = [
1040
- {
1041
- type: "input",
1042
- name: "name",
1043
- message: "What would you like to name your site?",
1044
- default: "My Awesome Site"
1045
- },
1046
- {
1047
- type: "input",
1048
- name: "id",
1049
- message: "What ID would you like to have for your site?",
1050
- default: "unique()"
1121
+ {
1122
+ type: "input",
1123
+ name: "name",
1124
+ message: "What would you like to name your site?",
1125
+ default: "My Awesome Site",
1126
+ },
1127
+ {
1128
+ type: "input",
1129
+ name: "id",
1130
+ message: "What ID would you like to have for your site?",
1131
+ default: "unique()",
1132
+ },
1133
+ {
1134
+ type: "list",
1135
+ name: "framework",
1136
+ message: "What framework would you like to use?",
1137
+ choices: async () => {
1138
+ let response = await (await getSitesService()).listFrameworks();
1139
+ let frameworks = response["frameworks"];
1140
+ let choices = frameworks.map((framework: any) => {
1141
+ return {
1142
+ name: `${framework.name} (${framework.key})`,
1143
+ value: framework,
1144
+ };
1145
+ });
1146
+ return choices;
1051
1147
  },
1052
- {
1053
- type: "list",
1054
- name: "framework",
1055
- message: "What framework would you like to use?",
1056
- choices: async () => {
1057
- let response = await sitesListFrameworks({
1058
- parseOutput: false
1059
- });
1060
- let frameworks = response["frameworks"];
1061
- let choices = frameworks.map((framework: any) => {
1062
- return {
1063
- name: `${framework.name} (${framework.key})`,
1064
- value: framework,
1065
- }
1066
- });
1067
- return choices;
1068
- },
1148
+ },
1149
+ {
1150
+ type: "list",
1151
+ name: "specification",
1152
+ message: "What specification would you like to use?",
1153
+ choices: async () => {
1154
+ let response = await (await getSitesService()).listSpecifications();
1155
+ let specifications = response["specifications"];
1156
+ let choices = specifications.map((spec: any) => {
1157
+ return {
1158
+ name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
1159
+ value: spec.slug,
1160
+ disabled: spec.enabled === false ? "Upgrade to use" : false,
1161
+ };
1162
+ });
1163
+ return choices;
1069
1164
  },
1070
- {
1071
- type: "list",
1072
- name: "specification",
1073
- message: "What specification would you like to use?",
1074
- choices: async () => {
1075
- let response = await sitesListSpecifications({
1076
- parseOutput: false
1077
- });
1078
- let specifications = response["specifications"];
1079
- let choices = specifications.map((spec: any) => {
1080
- return {
1081
- name: `${spec.cpus} CPU, ${spec.memory}MB RAM`,
1082
- value: spec.slug,
1083
- disabled: spec.enabled === false ? 'Upgrade to use' : false
1084
- }
1085
- });
1086
- return choices;
1087
- },
1088
- }
1165
+ },
1089
1166
  ];
1090
-