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
@@ -0,0 +1,647 @@
1
+ import { Command } from "commander";
2
+ import { sdkForProject } from "../../sdks.js";
3
+ import {
4
+ actionRunner,
5
+ commandDescriptions,
6
+ success,
7
+ parse,
8
+ parseBool,
9
+ parseInteger,
10
+ } from "../../parser.js";
11
+ import {
12
+ Account,
13
+ AuthenticatorType,
14
+ AuthenticationFactor,
15
+ OAuthProvider,
16
+ } from "@appwrite.io/console";
17
+
18
+ let accountClient: Account | null = null;
19
+
20
+ const getAccountClient = async (): Promise<Account> => {
21
+ if (!accountClient) {
22
+ const sdkClient = await sdkForProject();
23
+ accountClient = new Account(sdkClient);
24
+ }
25
+ return accountClient;
26
+ };
27
+
28
+ export const account = new Command("account")
29
+ .description(commandDescriptions["account"] ?? "")
30
+ .configureHelp({
31
+ helpWidth: process.stdout.columns || 80,
32
+ });
33
+
34
+ account
35
+ .command(`get`)
36
+ .description(`Get the currently logged in user.`)
37
+ .action(
38
+ actionRunner(
39
+ async () => parse(await (await getAccountClient()).get()),
40
+ ),
41
+ );
42
+
43
+ account
44
+ .command(`create`)
45
+ .description(`Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession).`)
46
+ .requiredOption(`--user-id <user-id>`, `User ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
47
+ .requiredOption(`--email <email>`, `User email.`)
48
+ .requiredOption(`--password <password>`, `New user password. Must be between 8 and 256 chars.`)
49
+ .option(`--name <name>`, `User name. Max length: 128 chars.`)
50
+ .action(
51
+ actionRunner(
52
+ async ({ userId, email, password, name }) =>
53
+ parse(await (await getAccountClient()).create(userId, email, password, name)),
54
+ ),
55
+ );
56
+
57
+ account
58
+ .command(`delete`)
59
+ .description(`Delete the currently logged in user.`)
60
+ .action(
61
+ actionRunner(
62
+ async () => parse(await (await getAccountClient()).delete()),
63
+ ),
64
+ );
65
+
66
+ account
67
+ .command(`update-email`)
68
+ .description(`Update currently logged in user account email address. After changing user address, the user confirmation status will get reset. A new confirmation email is not sent automatically however you can use the send confirmation email endpoint again to send the confirmation email. For security measures, user password is required to complete this request.
69
+ This endpoint can also be used to convert an anonymous account to a normal one, by passing an email address and a new password.
70
+ `)
71
+ .requiredOption(`--email <email>`, `User email.`)
72
+ .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
73
+ .action(
74
+ actionRunner(
75
+ async ({ email, password }) =>
76
+ parse(await (await getAccountClient()).updateEmail(email, password)),
77
+ ),
78
+ );
79
+
80
+ account
81
+ .command(`list-identities`)
82
+ .description(`Get the list of identities for the currently logged in user.`)
83
+ .option(`--queries [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: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry`)
84
+ .option(
85
+ `--total [value]`,
86
+ `When set to false, the total count returned will be 0 and will not be calculated.`,
87
+ (value: string | undefined) =>
88
+ value === undefined ? true : parseBool(value),
89
+ )
90
+ .action(
91
+ actionRunner(
92
+ async ({ queries, total }) =>
93
+ parse(await (await getAccountClient()).listIdentities(queries, total)),
94
+ ),
95
+ );
96
+
97
+ account
98
+ .command(`delete-identity`)
99
+ .description(`Delete an identity by its unique ID.`)
100
+ .requiredOption(`--identity-id <identity-id>`, `Identity ID.`)
101
+ .action(
102
+ actionRunner(
103
+ async ({ identityId }) =>
104
+ parse(await (await getAccountClient()).deleteIdentity(identityId)),
105
+ ),
106
+ );
107
+
108
+ account
109
+ .command(`create-jwt`)
110
+ .description(`Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame.`)
111
+ .option(`--duration <duration>`, `Time in seconds before JWT expires. Default duration is 900 seconds, and maximum is 3600 seconds.`, parseInteger)
112
+ .action(
113
+ actionRunner(
114
+ async ({ duration }) =>
115
+ parse(await (await getAccountClient()).createJWT(duration)),
116
+ ),
117
+ );
118
+
119
+ account
120
+ .command(`list-logs`)
121
+ .description(`Get the list of latest security activity logs for the currently logged in user. Each log returns user IP address, location and date and time of log.`)
122
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset`)
123
+ .option(
124
+ `--total [value]`,
125
+ `When set to false, the total count returned will be 0 and will not be calculated.`,
126
+ (value: string | undefined) =>
127
+ value === undefined ? true : parseBool(value),
128
+ )
129
+ .action(
130
+ actionRunner(
131
+ async ({ queries, total }) =>
132
+ parse(await (await getAccountClient()).listLogs(queries, total)),
133
+ ),
134
+ );
135
+
136
+ account
137
+ .command(`update-mfa`)
138
+ .description(`Enable or disable MFA on an account.`)
139
+ .requiredOption(`--mfa <mfa>`, `Enable or disable MFA.`, parseBool)
140
+ .action(
141
+ actionRunner(
142
+ async ({ mfa }) =>
143
+ parse(await (await getAccountClient()).updateMFA(mfa)),
144
+ ),
145
+ );
146
+
147
+ account
148
+ .command(`create-mfa-authenticator`)
149
+ .description(`Add an authenticator app to be used as an MFA factor. Verify the authenticator using the [verify authenticator](/docs/references/cloud/client-web/account#updateMfaAuthenticator) method.`)
150
+ .requiredOption(`--type <type>`, `Type of authenticator. Must be \`totp\``)
151
+ .action(
152
+ actionRunner(
153
+ async ({ type }) =>
154
+ parse(await (await getAccountClient()).createMfaAuthenticator(type as AuthenticatorType)),
155
+ ),
156
+ );
157
+
158
+ account
159
+ .command(`update-mfa-authenticator`)
160
+ .description(`Verify an authenticator app after adding it using the [add authenticator](/docs/references/cloud/client-web/account#createMfaAuthenticator) method.`)
161
+ .requiredOption(`--type <type>`, `Type of authenticator.`)
162
+ .requiredOption(`--otp <otp>`, `Valid verification token.`)
163
+ .action(
164
+ actionRunner(
165
+ async ({ type, otp }) =>
166
+ parse(await (await getAccountClient()).updateMfaAuthenticator(type as AuthenticatorType, otp)),
167
+ ),
168
+ );
169
+
170
+ account
171
+ .command(`delete-mfa-authenticator`)
172
+ .description(`Delete an authenticator for a user by ID.`)
173
+ .requiredOption(`--type <type>`, `Type of authenticator.`)
174
+ .action(
175
+ actionRunner(
176
+ async ({ type }) =>
177
+ parse(await (await getAccountClient()).deleteMfaAuthenticator(type as AuthenticatorType)),
178
+ ),
179
+ );
180
+
181
+ account
182
+ .command(`create-mfa-challenge`)
183
+ .description(`Begin the process of MFA verification after sign-in. Finish the flow with [updateMfaChallenge](/docs/references/cloud/client-web/account#updateMfaChallenge) method.`)
184
+ .requiredOption(`--factor <factor>`, `Factor used for verification. Must be one of following: \`email\`, \`phone\`, \`totp\`, \`recoveryCode\`.`)
185
+ .action(
186
+ actionRunner(
187
+ async ({ factor }) =>
188
+ parse(await (await getAccountClient()).createMfaChallenge(factor as AuthenticationFactor)),
189
+ ),
190
+ );
191
+
192
+ account
193
+ .command(`update-mfa-challenge`)
194
+ .description(`Complete the MFA challenge by providing the one-time password. Finish the process of MFA verification by providing the one-time password. To begin the flow, use [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.`)
195
+ .requiredOption(`--challenge-id <challenge-id>`, `ID of the challenge.`)
196
+ .requiredOption(`--otp <otp>`, `Valid verification token.`)
197
+ .action(
198
+ actionRunner(
199
+ async ({ challengeId, otp }) =>
200
+ parse(await (await getAccountClient()).updateMfaChallenge(challengeId, otp)),
201
+ ),
202
+ );
203
+
204
+ account
205
+ .command(`list-mfa-factors`)
206
+ .description(`List the factors available on the account to be used as a MFA challange.`)
207
+ .action(
208
+ actionRunner(
209
+ async () => parse(await (await getAccountClient()).listMfaFactors()),
210
+ ),
211
+ );
212
+
213
+ account
214
+ .command(`get-mfa-recovery-codes`)
215
+ .description(`Get recovery codes that can be used as backup for MFA flow. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to read recovery codes.`)
216
+ .action(
217
+ actionRunner(
218
+ async () => parse(await (await getAccountClient()).getMfaRecoveryCodes()),
219
+ ),
220
+ );
221
+
222
+ account
223
+ .command(`create-mfa-recovery-codes`)
224
+ .description(`Generate recovery codes as backup for MFA flow. It's recommended to generate and show then immediately after user successfully adds their authehticator. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method.`)
225
+ .action(
226
+ actionRunner(
227
+ async () => parse(await (await getAccountClient()).createMfaRecoveryCodes()),
228
+ ),
229
+ );
230
+
231
+ account
232
+ .command(`update-mfa-recovery-codes`)
233
+ .description(`Regenerate recovery codes that can be used as backup for MFA flow. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method. An OTP challenge is required to regenreate recovery codes.`)
234
+ .action(
235
+ actionRunner(
236
+ async () => parse(await (await getAccountClient()).updateMfaRecoveryCodes()),
237
+ ),
238
+ );
239
+
240
+ account
241
+ .command(`update-name`)
242
+ .description(`Update currently logged in user account name.`)
243
+ .requiredOption(`--name <name>`, `User name. Max length: 128 chars.`)
244
+ .action(
245
+ actionRunner(
246
+ async ({ name }) =>
247
+ parse(await (await getAccountClient()).updateName(name)),
248
+ ),
249
+ );
250
+
251
+ account
252
+ .command(`update-password`)
253
+ .description(`Update currently logged in user password. For validation, user is required to pass in the new password, and the old password. For users created with OAuth, Team Invites and Magic URL, oldPassword is optional.`)
254
+ .requiredOption(`--password <password>`, `New user password. Must be at least 8 chars.`)
255
+ .option(`--old-password <old-password>`, `Current user password. Must be at least 8 chars.`)
256
+ .action(
257
+ actionRunner(
258
+ async ({ password, oldPassword }) =>
259
+ parse(await (await getAccountClient()).updatePassword(password, oldPassword)),
260
+ ),
261
+ );
262
+
263
+ account
264
+ .command(`update-phone`)
265
+ .description(`Update the currently logged in user's phone number. After updating the phone number, the phone verification status will be reset. A confirmation SMS is not sent automatically, however you can use the [POST /account/verification/phone](https://appwrite.io/docs/references/cloud/client-web/account#createPhoneVerification) endpoint to send a confirmation SMS.`)
266
+ .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
267
+ .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
268
+ .action(
269
+ actionRunner(
270
+ async ({ phone, password }) =>
271
+ parse(await (await getAccountClient()).updatePhone(phone, password)),
272
+ ),
273
+ );
274
+
275
+ account
276
+ .command(`get-prefs`)
277
+ .description(`Get the preferences as a key-value object for the currently logged in user.`)
278
+ .action(
279
+ actionRunner(
280
+ async () => parse(await (await getAccountClient()).getPrefs()),
281
+ ),
282
+ );
283
+
284
+ account
285
+ .command(`update-prefs`)
286
+ .description(`Update currently logged in user account preferences. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.`)
287
+ .requiredOption(`--prefs <prefs>`, `Prefs key-value JSON object.`)
288
+ .action(
289
+ actionRunner(
290
+ async ({ prefs }) =>
291
+ parse(await (await getAccountClient()).updatePrefs(JSON.parse(prefs))),
292
+ ),
293
+ );
294
+
295
+ account
296
+ .command(`create-recovery`)
297
+ .description(`Sends the user an email with a temporary secret key for password reset. When the user clicks the confirmation link he is redirected back to your app password reset URL with the secret key and email address values attached to the URL query string. Use the query string params to submit a request to the [PUT /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#updateRecovery) endpoint to complete the process. The verification link sent to the user's email address is valid for 1 hour.`)
298
+ .requiredOption(`--email <email>`, `User email.`)
299
+ .requiredOption(`--url <url>`, `URL to redirect the user back to your app from the recovery email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
300
+ .action(
301
+ actionRunner(
302
+ async ({ email, url }) =>
303
+ parse(await (await getAccountClient()).createRecovery(email, url)),
304
+ ),
305
+ );
306
+
307
+ account
308
+ .command(`update-recovery`)
309
+ .description(`Use this endpoint to complete the user account password reset. Both the **userId** and **secret** arguments will be passed as query parameters to the redirect URL you have provided when sending your request to the [POST /account/recovery](https://appwrite.io/docs/references/cloud/client-web/account#createRecovery) endpoint.
310
+
311
+ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.`)
312
+ .requiredOption(`--user-id <user-id>`, `User ID.`)
313
+ .requiredOption(`--secret <secret>`, `Valid reset token.`)
314
+ .requiredOption(`--password <password>`, `New user password. Must be between 8 and 256 chars.`)
315
+ .action(
316
+ actionRunner(
317
+ async ({ userId, secret, password }) =>
318
+ parse(await (await getAccountClient()).updateRecovery(userId, secret, password)),
319
+ ),
320
+ );
321
+
322
+ account
323
+ .command(`list-sessions`)
324
+ .description(`Get the list of active sessions across different devices for the currently logged in user.`)
325
+ .action(
326
+ actionRunner(
327
+ async () => parse(await (await getAccountClient()).listSessions()),
328
+ ),
329
+ );
330
+
331
+ account
332
+ .command(`delete-sessions`)
333
+ .description(`Delete all sessions from the user account and remove any sessions cookies from the end client.`)
334
+ .action(
335
+ actionRunner(
336
+ async () => parse(await (await getAccountClient()).deleteSessions()),
337
+ ),
338
+ );
339
+
340
+ account
341
+ .command(`create-anonymous-session`)
342
+ .description(`Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session).`)
343
+ .action(
344
+ actionRunner(
345
+ async () => parse(await (await getAccountClient()).createAnonymousSession()),
346
+ ),
347
+ );
348
+
349
+ account
350
+ .command(`create-email-password-session`)
351
+ .description(`Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
352
+
353
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).`)
354
+ .requiredOption(`--email <email>`, `User email.`)
355
+ .requiredOption(`--password <password>`, `User password. Must be at least 8 chars.`)
356
+ .action(
357
+ actionRunner(
358
+ async ({ email, password }) =>
359
+ parse(await (await getAccountClient()).createEmailPasswordSession(email, password)),
360
+ ),
361
+ );
362
+
363
+ account
364
+ .command(`update-magic-url-session`)
365
+ .description(`Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.`)
366
+ .requiredOption(`--user-id <user-id>`, `User ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
367
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
368
+ .action(
369
+ actionRunner(
370
+ async ({ userId, secret }) =>
371
+ parse(await (await getAccountClient()).updateMagicURLSession(userId, secret)),
372
+ ),
373
+ );
374
+
375
+ account
376
+ .command(`create-o-auth-2-session`)
377
+ .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
378
+
379
+ If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.
380
+
381
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
382
+ `)
383
+ .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.`)
384
+ .option(`--success <success>`, `URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
385
+ .option(`--failure <failure>`, `URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
386
+ .option(`--scopes [scopes...]`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.`)
387
+ .action(
388
+ actionRunner(
389
+ async ({ provider, success, failure, scopes }) => {
390
+ const url = (await getAccountClient()).createOAuth2Session(provider as OAuthProvider, success, failure, scopes);
391
+ if (url) console.log(url);
392
+ },
393
+ ),
394
+ );
395
+
396
+ account
397
+ .command(`update-phone-session`)
398
+ .description(`Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.`)
399
+ .requiredOption(`--user-id <user-id>`, `User ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
400
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
401
+ .action(
402
+ actionRunner(
403
+ async ({ userId, secret }) =>
404
+ parse(await (await getAccountClient()).updatePhoneSession(userId, secret)),
405
+ ),
406
+ );
407
+
408
+ account
409
+ .command(`create-session`)
410
+ .description(`Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login.`)
411
+ .requiredOption(`--user-id <user-id>`, `User ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
412
+ .requiredOption(`--secret <secret>`, `Secret of a token generated by login methods. For example, the \`createMagicURLToken\` or \`createPhoneToken\` methods.`)
413
+ .action(
414
+ actionRunner(
415
+ async ({ userId, secret }) =>
416
+ parse(await (await getAccountClient()).createSession(userId, secret)),
417
+ ),
418
+ );
419
+
420
+ account
421
+ .command(`get-session`)
422
+ .description(`Use this endpoint to get a logged in user's session using a Session ID. Inputting 'current' will return the current session being used.`)
423
+ .requiredOption(`--session-id <session-id>`, `Session ID. Use the string 'current' to get the current device session.`)
424
+ .action(
425
+ actionRunner(
426
+ async ({ sessionId }) =>
427
+ parse(await (await getAccountClient()).getSession(sessionId)),
428
+ ),
429
+ );
430
+
431
+ account
432
+ .command(`update-session`)
433
+ .description(`Use this endpoint to extend a session's length. Extending a session is useful when session expiry is short. If the session was created using an OAuth provider, this endpoint refreshes the access token from the provider.`)
434
+ .requiredOption(`--session-id <session-id>`, `Session ID. Use the string 'current' to update the current device session.`)
435
+ .action(
436
+ actionRunner(
437
+ async ({ sessionId }) =>
438
+ parse(await (await getAccountClient()).updateSession(sessionId)),
439
+ ),
440
+ );
441
+
442
+ account
443
+ .command(`delete-session`)
444
+ .description(`Logout the user. Use 'current' as the session ID to logout on this device, use a session ID to logout on another device. If you're looking to logout the user on all devices, use [Delete Sessions](https://appwrite.io/docs/references/cloud/client-web/account#deleteSessions) instead.`)
445
+ .requiredOption(`--session-id <session-id>`, `Session ID. Use the string 'current' to delete the current device session.`)
446
+ .action(
447
+ actionRunner(
448
+ async ({ sessionId }) =>
449
+ parse(await (await getAccountClient()).deleteSession(sessionId)),
450
+ ),
451
+ );
452
+
453
+ account
454
+ .command(`update-status`)
455
+ .description(`Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead.`)
456
+ .action(
457
+ actionRunner(
458
+ async () => parse(await (await getAccountClient()).updateStatus()),
459
+ ),
460
+ );
461
+
462
+ account
463
+ .command(`create-push-target`)
464
+ .description(`Use this endpoint to register a device for push notifications. Provide a target ID (custom or generated using ID.unique()), a device identifier (usually a device token), and optionally specify which provider should send notifications to this target. The target is automatically linked to the current session and includes device information like brand and model.`)
465
+ .requiredOption(`--target-id <target-id>`, `Target ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
466
+ .requiredOption(`--identifier <identifier>`, `The target identifier (token, email, phone etc.)`)
467
+ .option(`--provider-id <provider-id>`, `Provider ID. Message will be sent to this target from the specified provider ID. If no provider ID is set the first setup provider will be used.`)
468
+ .action(
469
+ actionRunner(
470
+ async ({ targetId, identifier, providerId }) =>
471
+ parse(await (await getAccountClient()).createPushTarget(targetId, identifier, providerId)),
472
+ ),
473
+ );
474
+
475
+ account
476
+ .command(`update-push-target`)
477
+ .description(`Update the currently logged in user's push notification target. You can modify the target's identifier (device token) and provider ID (token, email, phone etc.). The target must exist and belong to the current user. If you change the provider ID, notifications will be sent through the new messaging provider instead.`)
478
+ .requiredOption(`--target-id <target-id>`, `Target ID.`)
479
+ .requiredOption(`--identifier <identifier>`, `The target identifier (token, email, phone etc.)`)
480
+ .action(
481
+ actionRunner(
482
+ async ({ targetId, identifier }) =>
483
+ parse(await (await getAccountClient()).updatePushTarget(targetId, identifier)),
484
+ ),
485
+ );
486
+
487
+ account
488
+ .command(`delete-push-target`)
489
+ .description(`Delete a push notification target for the currently logged in user. After deletion, the device will no longer receive push notifications. The target must exist and belong to the current user.`)
490
+ .requiredOption(`--target-id <target-id>`, `Target ID.`)
491
+ .action(
492
+ actionRunner(
493
+ async ({ targetId }) =>
494
+ parse(await (await getAccountClient()).deletePushTarget(targetId)),
495
+ ),
496
+ );
497
+
498
+ account
499
+ .command(`create-email-token`)
500
+ .description(`Sends the user an email with a secret key for creating a session. If the email address has never been used, a **new account is created** using the provided \`userId\`. Otherwise, if the email address is already attached to an account, the **user ID is ignored**. Then, the user will receive an email with the one-time password. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.
501
+
502
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
503
+ `)
504
+ .requiredOption(`--user-id <user-id>`, `User ID. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.`)
505
+ .requiredOption(`--email <email>`, `User email.`)
506
+ .option(
507
+ `--phrase [value]`,
508
+ `Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.`,
509
+ (value: string | undefined) =>
510
+ value === undefined ? true : parseBool(value),
511
+ )
512
+ .action(
513
+ actionRunner(
514
+ async ({ userId, email, phrase }) =>
515
+ parse(await (await getAccountClient()).createEmailToken(userId, email, phrase)),
516
+ ),
517
+ );
518
+
519
+ account
520
+ .command(`create-magic-url-token`)
521
+ .description(`Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour.
522
+
523
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
524
+ `)
525
+ .requiredOption(`--user-id <user-id>`, `Unique Id. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the email address has never been used, a new account is created using the provided userId. Otherwise, if the email address is already attached to an account, the user ID is ignored.`)
526
+ .requiredOption(`--email <email>`, `User email.`)
527
+ .option(`--url <url>`, `URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
528
+ .option(
529
+ `--phrase [value]`,
530
+ `Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow.`,
531
+ (value: string | undefined) =>
532
+ value === undefined ? true : parseBool(value),
533
+ )
534
+ .action(
535
+ actionRunner(
536
+ async ({ userId, email, url, phrase }) =>
537
+ parse(await (await getAccountClient()).createMagicURLToken(userId, email, url, phrase)),
538
+ ),
539
+ );
540
+
541
+ account
542
+ .command(`create-o-auth-2-token`)
543
+ .description(`Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
544
+
545
+ If authentication succeeds, \`userId\` and \`secret\` of a token will be appended to the success URL as query parameters. These can be used to create a new session using the [Create session](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint.
546
+
547
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).`)
548
+ .requiredOption(`--provider <provider>`, `OAuth2 Provider. Currently, supported providers are: amazon, apple, auth0, authentik, autodesk, bitbucket, bitly, box, dailymotion, discord, disqus, dropbox, etsy, facebook, figma, github, gitlab, google, linkedin, microsoft, notion, oidc, okta, paypal, paypalSandbox, podio, salesforce, slack, spotify, stripe, tradeshift, tradeshiftBox, twitch, wordpress, yahoo, yammer, yandex, zoho, zoom.`)
549
+ .option(`--success <success>`, `URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
550
+ .option(`--failure <failure>`, `URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
551
+ .option(`--scopes [scopes...]`, `A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long.`)
552
+ .action(
553
+ actionRunner(
554
+ async ({ provider, success, failure, scopes }) => {
555
+ const url = (await getAccountClient()).createOAuth2Token(provider as OAuthProvider, success, failure, scopes);
556
+ if (url) console.log(url);
557
+ },
558
+ ),
559
+ );
560
+
561
+ account
562
+ .command(`create-phone-token`)
563
+ .description(`Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.
564
+
565
+ A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).`)
566
+ .requiredOption(`--user-id <user-id>`, `Unique Id. Choose a custom ID or generate a random ID with \`ID.unique()\`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. If the phone number has never been used, a new account is created using the provided userId. Otherwise, if the phone number is already attached to an account, the user ID is ignored.`)
567
+ .requiredOption(`--phone <phone>`, `Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212.`)
568
+ .action(
569
+ actionRunner(
570
+ async ({ userId, phone }) =>
571
+ parse(await (await getAccountClient()).createPhoneToken(userId, phone)),
572
+ ),
573
+ );
574
+
575
+ account
576
+ .command(`create-email-verification`)
577
+ .description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
578
+
579
+ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
580
+ `)
581
+ .requiredOption(`--url <url>`, `URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
582
+ .action(
583
+ actionRunner(
584
+ async ({ url }) =>
585
+ parse(await (await getAccountClient()).createEmailVerification(url)),
586
+ ),
587
+ );
588
+
589
+ account
590
+ .command(`create-verification`)
591
+ .description(`Use this endpoint to send a verification message to your user email address to confirm they are the valid owners of that address. Both the **userId** and **secret** arguments will be passed as query parameters to the URL you have provided to be attached to the verification email. The provided URL should redirect the user back to your app and allow you to complete the verification process by verifying both the **userId** and **secret** parameters. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updateVerification). The verification link sent to the user's email address is valid for 7 days.
592
+
593
+ Please note that in order to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md), the only valid redirect URLs are the ones from domains you have set when adding your platforms in the console interface.
594
+ `)
595
+ .requiredOption(`--url <url>`, `URL to redirect the user back to your app from the verification email. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API.`)
596
+ .action(
597
+ actionRunner(
598
+ async ({ url }) =>
599
+ parse(await (await getAccountClient()).createVerification(url)),
600
+ ),
601
+ );
602
+
603
+ account
604
+ .command(`update-email-verification`)
605
+ .description(`Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.`)
606
+ .requiredOption(`--user-id <user-id>`, `User ID.`)
607
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
608
+ .action(
609
+ actionRunner(
610
+ async ({ userId, secret }) =>
611
+ parse(await (await getAccountClient()).updateEmailVerification(userId, secret)),
612
+ ),
613
+ );
614
+
615
+ account
616
+ .command(`update-verification`)
617
+ .description(`Use this endpoint to complete the user email verification process. Use both the **userId** and **secret** parameters that were attached to your app URL to verify the user email ownership. If confirmed this route will return a 200 status code.`)
618
+ .requiredOption(`--user-id <user-id>`, `User ID.`)
619
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
620
+ .action(
621
+ actionRunner(
622
+ async ({ userId, secret }) =>
623
+ parse(await (await getAccountClient()).updateVerification(userId, secret)),
624
+ ),
625
+ );
626
+
627
+ account
628
+ .command(`create-phone-verification`)
629
+ .description(`Use this endpoint to send a verification SMS to the currently logged in user. This endpoint is meant for use after updating a user's phone number using the [accountUpdatePhone](https://appwrite.io/docs/references/cloud/client-web/account#updatePhone) endpoint. Learn more about how to [complete the verification process](https://appwrite.io/docs/references/cloud/client-web/account#updatePhoneVerification). The verification code sent to the user's phone number is valid for 15 minutes.`)
630
+ .action(
631
+ actionRunner(
632
+ async () => parse(await (await getAccountClient()).createPhoneVerification()),
633
+ ),
634
+ );
635
+
636
+ account
637
+ .command(`update-phone-verification`)
638
+ .description(`Use this endpoint to complete the user phone verification process. Use the **userId** and **secret** that were sent to your user's phone number to verify the user email ownership. If confirmed this route will return a 200 status code.`)
639
+ .requiredOption(`--user-id <user-id>`, `User ID.`)
640
+ .requiredOption(`--secret <secret>`, `Valid verification token.`)
641
+ .action(
642
+ actionRunner(
643
+ async ({ userId, secret }) =>
644
+ parse(await (await getAccountClient()).updatePhoneVerification(userId, secret)),
645
+ ),
646
+ );
647
+