chirag-appwrite-cli 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (823) hide show
  1. package/.github/workflows/build-verify.yml +71 -0
  2. package/.github/workflows/npm-publish.yml +41 -22
  3. package/CHANGELOG.md +190 -1
  4. package/LICENSE.md +12 -1
  5. package/README.md +182 -15
  6. package/bun.lock +627 -0
  7. package/dist/bundle.cjs +108228 -0
  8. package/dist/index.d.ts +7 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +149 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/lib/client.d.ts +88 -0
  13. package/dist/lib/client.d.ts.map +1 -0
  14. package/dist/lib/client.js +238 -0
  15. package/dist/lib/client.js.map +1 -0
  16. package/dist/lib/commands/config.d.ts +557 -0
  17. package/dist/lib/commands/config.d.ts.map +1 -0
  18. package/dist/lib/commands/config.js +415 -0
  19. package/dist/lib/commands/config.js.map +1 -0
  20. package/dist/lib/commands/db.d.ts +34 -0
  21. package/dist/lib/commands/db.d.ts.map +1 -0
  22. package/dist/lib/commands/db.js +247 -0
  23. package/dist/lib/commands/db.js.map +1 -0
  24. package/dist/lib/commands/errors.d.ts +68 -0
  25. package/dist/lib/commands/errors.d.ts.map +1 -0
  26. package/dist/lib/commands/errors.js +72 -0
  27. package/dist/lib/commands/errors.js.map +1 -0
  28. package/dist/lib/commands/generic.d.ts +17 -0
  29. package/dist/lib/commands/generic.d.ts.map +1 -0
  30. package/dist/lib/commands/generic.js +292 -0
  31. package/dist/lib/commands/generic.js.map +1 -0
  32. package/dist/lib/commands/init.d.ts +3 -0
  33. package/dist/lib/commands/init.d.ts.map +1 -0
  34. package/dist/lib/commands/init.js +526 -0
  35. package/dist/lib/commands/init.js.map +1 -0
  36. package/dist/lib/commands/pull.d.ts +110 -0
  37. package/dist/lib/commands/pull.d.ts.map +1 -0
  38. package/dist/lib/commands/pull.js +626 -0
  39. package/dist/lib/commands/pull.js.map +1 -0
  40. package/dist/lib/commands/push.d.ts +82 -0
  41. package/dist/lib/commands/push.d.ts.map +1 -0
  42. package/dist/lib/commands/push.js +1666 -0
  43. package/dist/lib/commands/push.js.map +1 -0
  44. package/dist/lib/commands/run.d.ts +3 -0
  45. package/dist/lib/commands/run.d.ts.map +1 -0
  46. package/dist/lib/commands/run.js +289 -0
  47. package/dist/lib/commands/run.js.map +1 -0
  48. package/dist/lib/commands/schema.d.ts +57 -0
  49. package/dist/lib/commands/schema.d.ts.map +1 -0
  50. package/dist/lib/commands/schema.js +75 -0
  51. package/dist/lib/commands/schema.js.map +1 -0
  52. package/dist/lib/commands/services/account.d.ts +3 -0
  53. package/dist/lib/commands/services/account.d.ts.map +1 -0
  54. package/dist/lib/commands/services/account.js +306 -0
  55. package/dist/lib/commands/services/account.js.map +1 -0
  56. package/dist/lib/commands/services/avatars.d.ts +3 -0
  57. package/dist/lib/commands/services/avatars.d.ts.map +1 -0
  58. package/dist/lib/commands/services/avatars.js +118 -0
  59. package/dist/lib/commands/services/avatars.js.map +1 -0
  60. package/dist/lib/commands/services/console.d.ts +3 -0
  61. package/dist/lib/commands/services/console.d.ts.map +1 -0
  62. package/dist/lib/commands/services/console.js +41 -0
  63. package/dist/lib/commands/services/console.js.map +1 -0
  64. package/dist/lib/commands/services/databases.d.ts +3 -0
  65. package/dist/lib/commands/services/databases.d.ts.map +1 -0
  66. package/dist/lib/commands/services/databases.js +612 -0
  67. package/dist/lib/commands/services/databases.js.map +1 -0
  68. package/dist/lib/commands/services/functions.d.ts +3 -0
  69. package/dist/lib/commands/services/functions.d.ts.map +1 -0
  70. package/dist/lib/commands/services/functions.js +258 -0
  71. package/dist/lib/commands/services/functions.js.map +1 -0
  72. package/dist/lib/commands/services/graphql.d.ts +3 -0
  73. package/dist/lib/commands/services/graphql.d.ts.map +1 -0
  74. package/dist/lib/commands/services/graphql.js +28 -0
  75. package/dist/lib/commands/services/graphql.js.map +1 -0
  76. package/dist/lib/commands/services/health.d.ts +3 -0
  77. package/dist/lib/commands/services/health.d.ts.map +1 -0
  78. package/dist/lib/commands/services/health.js +123 -0
  79. package/dist/lib/commands/services/health.js.map +1 -0
  80. package/dist/lib/commands/services/locale.d.ts +3 -0
  81. package/dist/lib/commands/services/locale.d.ts.map +1 -0
  82. package/dist/lib/commands/services/locale.js +52 -0
  83. package/dist/lib/commands/services/locale.js.map +1 -0
  84. package/dist/lib/commands/services/messaging.d.ts +3 -0
  85. package/dist/lib/commands/services/messaging.d.ts.map +1 -0
  86. package/dist/lib/commands/services/messaging.js +505 -0
  87. package/dist/lib/commands/services/messaging.js.map +1 -0
  88. package/dist/lib/commands/services/migrations.d.ts +3 -0
  89. package/dist/lib/commands/services/migrations.d.ts.map +1 -0
  90. package/dist/lib/commands/services/migrations.js +135 -0
  91. package/dist/lib/commands/services/migrations.js.map +1 -0
  92. package/dist/lib/commands/services/project.d.ts +3 -0
  93. package/dist/lib/commands/services/project.d.ts.map +1 -0
  94. package/dist/lib/commands/services/project.js +54 -0
  95. package/dist/lib/commands/services/project.js.map +1 -0
  96. package/dist/lib/commands/services/projects.d.ts +3 -0
  97. package/dist/lib/commands/services/projects.d.ts.map +1 -0
  98. package/dist/lib/commands/services/projects.js +415 -0
  99. package/dist/lib/commands/services/projects.js.map +1 -0
  100. package/dist/lib/commands/services/proxy.d.ts +3 -0
  101. package/dist/lib/commands/services/proxy.d.ts.map +1 -0
  102. package/dist/lib/commands/services/proxy.js +68 -0
  103. package/dist/lib/commands/services/proxy.js.map +1 -0
  104. package/dist/lib/commands/services/sites.d.ts +3 -0
  105. package/dist/lib/commands/services/sites.d.ts.map +1 -0
  106. package/dist/lib/commands/services/sites.js +242 -0
  107. package/dist/lib/commands/services/sites.js.map +1 -0
  108. package/dist/lib/commands/services/storage.d.ts +3 -0
  109. package/dist/lib/commands/services/storage.d.ts.map +1 -0
  110. package/dist/lib/commands/services/storage.js +153 -0
  111. package/dist/lib/commands/services/storage.js.map +1 -0
  112. package/dist/lib/commands/services/tablesdb.d.ts +3 -0
  113. package/dist/lib/commands/services/tablesdb.d.ts.map +1 -0
  114. package/dist/lib/commands/services/tablesdb.js +605 -0
  115. package/dist/lib/commands/services/tablesdb.js.map +1 -0
  116. package/dist/lib/commands/services/teams.d.ts +3 -0
  117. package/dist/lib/commands/services/teams.d.ts.map +1 -0
  118. package/dist/lib/commands/services/teams.js +123 -0
  119. package/dist/lib/commands/services/teams.js.map +1 -0
  120. package/dist/lib/commands/services/tokens.d.ts +3 -0
  121. package/dist/lib/commands/services/tokens.d.ts.map +1 -0
  122. package/dist/lib/commands/services/tokens.js +49 -0
  123. package/dist/lib/commands/services/tokens.js.map +1 -0
  124. package/dist/lib/commands/services/users.d.ts +3 -0
  125. package/dist/lib/commands/services/users.d.ts.map +1 -0
  126. package/dist/lib/commands/services/users.js +312 -0
  127. package/dist/lib/commands/services/users.js.map +1 -0
  128. package/dist/lib/commands/services/vcs.d.ts +3 -0
  129. package/dist/lib/commands/services/vcs.d.ts.map +1 -0
  130. package/dist/lib/commands/services/vcs.js +87 -0
  131. package/dist/lib/commands/services/vcs.js.map +1 -0
  132. package/dist/lib/commands/types.d.ts +3 -0
  133. package/dist/lib/commands/types.d.ts.map +1 -0
  134. package/dist/lib/commands/types.js +151 -0
  135. package/dist/lib/commands/types.js.map +1 -0
  136. package/dist/lib/commands/update.d.ts +3 -0
  137. package/dist/lib/commands/update.d.ts.map +1 -0
  138. package/dist/lib/commands/update.js +201 -0
  139. package/dist/lib/commands/update.js.map +1 -0
  140. package/dist/lib/commands/utils/attributes.d.ts +46 -0
  141. package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
  142. package/dist/lib/commands/utils/attributes.js +521 -0
  143. package/dist/lib/commands/utils/attributes.js.map +1 -0
  144. package/dist/lib/commands/utils/change-approval.d.ts +25 -0
  145. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
  146. package/dist/lib/commands/utils/change-approval.js +129 -0
  147. package/dist/lib/commands/utils/change-approval.js.map +1 -0
  148. package/dist/lib/commands/utils/database-sync.d.ts +10 -0
  149. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
  150. package/dist/lib/commands/utils/database-sync.js +136 -0
  151. package/dist/lib/commands/utils/database-sync.js.map +1 -0
  152. package/dist/lib/commands/utils/deployment.d.ts +34 -0
  153. package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
  154. package/dist/lib/commands/utils/deployment.js +108 -0
  155. package/dist/lib/commands/utils/deployment.js.map +1 -0
  156. package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
  157. package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
  158. package/dist/lib/commands/utils/error-formatter.js +333 -0
  159. package/dist/lib/commands/utils/error-formatter.js.map +1 -0
  160. package/dist/lib/commands/utils/pools.d.ts +16 -0
  161. package/dist/lib/commands/utils/pools.d.ts.map +1 -0
  162. package/dist/lib/commands/utils/pools.js +197 -0
  163. package/dist/lib/commands/utils/pools.js.map +1 -0
  164. package/dist/lib/config.d.ts +119 -0
  165. package/dist/lib/config.d.ts.map +1 -0
  166. package/dist/lib/config.js +728 -0
  167. package/dist/lib/config.js.map +1 -0
  168. package/dist/lib/emulation/docker.d.ts +7 -0
  169. package/dist/lib/emulation/docker.d.ts.map +1 -0
  170. package/dist/lib/emulation/docker.js +224 -0
  171. package/dist/lib/emulation/docker.js.map +1 -0
  172. package/dist/lib/emulation/utils.d.ts +29 -0
  173. package/dist/lib/emulation/utils.d.ts.map +1 -0
  174. package/dist/lib/emulation/utils.js +165 -0
  175. package/dist/lib/emulation/utils.js.map +1 -0
  176. package/dist/lib/id.d.ts +7 -0
  177. package/dist/lib/id.d.ts.map +1 -0
  178. package/dist/lib/id.js +27 -0
  179. package/dist/lib/id.js.map +1 -0
  180. package/dist/lib/paginate.d.ts +9 -0
  181. package/dist/lib/paginate.d.ts.map +1 -0
  182. package/dist/lib/paginate.js +43 -0
  183. package/dist/lib/paginate.js.map +1 -0
  184. package/dist/lib/parser.d.ts +18 -0
  185. package/dist/lib/parser.d.ts.map +1 -0
  186. package/dist/lib/parser.js +225 -0
  187. package/dist/lib/parser.js.map +1 -0
  188. package/dist/lib/questions.d.ts +59 -0
  189. package/dist/lib/questions.d.ts.map +1 -0
  190. package/dist/lib/questions.js +991 -0
  191. package/dist/lib/questions.js.map +1 -0
  192. package/dist/lib/sdks.d.ts +4 -0
  193. package/dist/lib/sdks.d.ts.map +1 -0
  194. package/dist/lib/sdks.js +61 -0
  195. package/dist/lib/sdks.js.map +1 -0
  196. package/dist/lib/services.d.ts +13 -0
  197. package/dist/lib/services.d.ts.map +1 -0
  198. package/dist/lib/services.js +47 -0
  199. package/dist/lib/services.js.map +1 -0
  200. package/dist/lib/spinner.d.ts +28 -0
  201. package/dist/lib/spinner.d.ts.map +1 -0
  202. package/dist/lib/spinner.js +91 -0
  203. package/dist/lib/spinner.js.map +1 -0
  204. package/dist/lib/type-generation/attribute.d.ts +17 -0
  205. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  206. package/dist/lib/type-generation/attribute.js +16 -0
  207. package/dist/lib/type-generation/attribute.js.map +1 -0
  208. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  209. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  210. package/dist/lib/type-generation/languages/csharp.js +180 -0
  211. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  212. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  213. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  214. package/dist/lib/type-generation/languages/dart.js +197 -0
  215. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  216. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  217. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  218. package/dist/lib/type-generation/languages/java.js +140 -0
  219. package/dist/lib/type-generation/languages/java.js.map +1 -0
  220. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  221. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  222. package/dist/lib/type-generation/languages/javascript.js +109 -0
  223. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  224. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  225. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  226. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  227. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  228. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  229. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  230. package/dist/lib/type-generation/languages/language.js +77 -0
  231. package/dist/lib/type-generation/languages/language.js.map +1 -0
  232. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  233. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  234. package/dist/lib/type-generation/languages/php.js +116 -0
  235. package/dist/lib/type-generation/languages/php.js.map +1 -0
  236. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  237. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  238. package/dist/lib/type-generation/languages/swift.js +179 -0
  239. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  240. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  241. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  242. package/dist/lib/type-generation/languages/typescript.js +115 -0
  243. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  244. package/dist/lib/types.d.ts +63 -0
  245. package/dist/lib/types.d.ts.map +1 -0
  246. package/dist/lib/types.js +2 -0
  247. package/dist/lib/types.js.map +1 -0
  248. package/dist/lib/utils.d.ts +18 -0
  249. package/dist/lib/utils.d.ts.map +1 -0
  250. package/dist/lib/utils.js +323 -0
  251. package/dist/lib/utils.js.map +1 -0
  252. package/dist/lib/validations.d.ts +2 -0
  253. package/dist/lib/validations.d.ts.map +1 -0
  254. package/dist/lib/validations.js +16 -0
  255. package/dist/lib/validations.js.map +1 -0
  256. package/dist/package.json +68 -0
  257. package/dist/scripts/generate-commands.d.ts +2 -0
  258. package/dist/scripts/generate-commands.d.ts.map +1 -0
  259. package/dist/scripts/generate-commands.js +398 -0
  260. package/dist/scripts/generate-commands.js.map +1 -0
  261. package/dist/sites/profile-website/src/lib/utils.d.ts +4 -0
  262. package/dist/sites/profile-website/src/lib/utils.d.ts.map +1 -0
  263. package/dist/sites/profile-website/src/lib/utils.js +32 -0
  264. package/dist/sites/profile-website/src/lib/utils.js.map +1 -0
  265. package/dist/sites/profile-website/tailwind.config.d.ts +3 -0
  266. package/dist/sites/profile-website/tailwind.config.d.ts.map +1 -0
  267. package/dist/sites/profile-website/tailwind.config.js +110 -0
  268. package/dist/sites/profile-website/tailwind.config.js.map +1 -0
  269. package/dist/test.d.ts +2 -0
  270. package/dist/test.d.ts.map +1 -0
  271. package/dist/test.js +38 -0
  272. package/dist/test.js.map +1 -0
  273. package/index.ts +190 -0
  274. package/install.ps1 +5 -8
  275. package/install.sh +4 -5
  276. package/lib/client.ts +292 -0
  277. package/lib/commands/config.ts +493 -0
  278. package/lib/commands/db.ts +324 -0
  279. package/lib/commands/errors.ts +93 -0
  280. package/lib/commands/generic.ts +440 -0
  281. package/lib/commands/init.ts +713 -0
  282. package/lib/commands/pull.ts +944 -0
  283. package/lib/commands/push.ts +2355 -0
  284. package/lib/commands/run.ts +416 -0
  285. package/lib/commands/schema.ts +103 -0
  286. package/lib/commands/services/account.ts +832 -0
  287. package/lib/commands/services/avatars.ts +400 -0
  288. package/lib/commands/services/console.ts +73 -0
  289. package/lib/commands/services/databases.ts +2080 -0
  290. package/lib/commands/services/functions.ts +855 -0
  291. package/lib/commands/services/graphql.ts +47 -0
  292. package/lib/commands/services/health.ts +322 -0
  293. package/lib/commands/services/locale.ts +99 -0
  294. package/lib/commands/services/messaging.ts +1871 -0
  295. package/lib/commands/services/migrations.ts +421 -0
  296. package/lib/commands/services/project.ts +116 -0
  297. package/lib/commands/services/projects.ts +1317 -0
  298. package/lib/commands/services/proxy.ts +163 -0
  299. package/lib/commands/services/sites.ts +777 -0
  300. package/lib/commands/services/storage.ts +547 -0
  301. package/lib/commands/services/tablesdb.ts +1928 -0
  302. package/lib/commands/services/teams.ts +294 -0
  303. package/lib/commands/services/tokens.ts +106 -0
  304. package/lib/commands/services/users.ts +886 -0
  305. package/lib/commands/services/vcs.ts +268 -0
  306. package/lib/commands/types.ts +220 -0
  307. package/lib/commands/update.ts +245 -0
  308. package/lib/commands/utils/attributes.ts +734 -0
  309. package/lib/commands/utils/change-approval.ts +186 -0
  310. package/lib/commands/utils/database-sync.ts +180 -0
  311. package/lib/commands/utils/deployment.ts +180 -0
  312. package/lib/commands/utils/error-formatter.ts +417 -0
  313. package/lib/commands/utils/pools.ts +354 -0
  314. package/lib/config.ts +932 -0
  315. package/lib/emulation/docker.ts +312 -0
  316. package/lib/emulation/utils.ts +207 -0
  317. package/lib/id.ts +30 -0
  318. package/lib/paginate.ts +77 -0
  319. package/lib/parser.ts +264 -0
  320. package/lib/questions.ts +1167 -0
  321. package/lib/sdks.ts +84 -0
  322. package/lib/services.ts +72 -0
  323. package/lib/spinner.ts +131 -0
  324. package/lib/type-generation/attribute.ts +18 -0
  325. package/lib/type-generation/languages/csharp.ts +192 -0
  326. package/lib/type-generation/languages/dart.ts +217 -0
  327. package/lib/type-generation/languages/java.ts +152 -0
  328. package/lib/type-generation/languages/javascript.ts +122 -0
  329. package/lib/type-generation/languages/kotlin.ts +107 -0
  330. package/lib/type-generation/languages/language.ts +127 -0
  331. package/lib/type-generation/languages/php.ts +128 -0
  332. package/lib/type-generation/languages/swift.ts +191 -0
  333. package/lib/type-generation/languages/typescript.ts +133 -0
  334. package/lib/types.ts +75 -0
  335. package/lib/utils.ts +394 -0
  336. package/lib/validations.ts +20 -0
  337. package/package.json +39 -21
  338. package/scoop/appwrite.config.json +20 -0
  339. package/scripts/generate-commands.ts +539 -0
  340. package/tsconfig.json +24 -0
  341. package/appwrite.json +0 -164
  342. package/docs/examples/account/create-anonymous-session.md +0 -1
  343. package/docs/examples/account/create-email-password-session.md +0 -3
  344. package/docs/examples/account/create-email-token.md +0 -4
  345. package/docs/examples/account/create-j-w-t.md +0 -1
  346. package/docs/examples/account/create-magic-u-r-l-token.md +0 -5
  347. package/docs/examples/account/create-mfa-authenticator.md +0 -2
  348. package/docs/examples/account/create-mfa-challenge.md +0 -2
  349. package/docs/examples/account/create-mfa-recovery-codes.md +0 -1
  350. package/docs/examples/account/create-o-auth2session.md +0 -5
  351. package/docs/examples/account/create-o-auth2token.md +0 -5
  352. package/docs/examples/account/create-phone-token.md +0 -3
  353. package/docs/examples/account/create-phone-verification.md +0 -1
  354. package/docs/examples/account/create-push-target.md +0 -4
  355. package/docs/examples/account/create-recovery.md +0 -3
  356. package/docs/examples/account/create-session.md +0 -3
  357. package/docs/examples/account/create-verification.md +0 -2
  358. package/docs/examples/account/create.md +0 -5
  359. package/docs/examples/account/delete-identity.md +0 -2
  360. package/docs/examples/account/delete-mfa-authenticator.md +0 -2
  361. package/docs/examples/account/delete-push-target.md +0 -2
  362. package/docs/examples/account/delete-session.md +0 -2
  363. package/docs/examples/account/delete-sessions.md +0 -1
  364. package/docs/examples/account/delete.md +0 -1
  365. package/docs/examples/account/get-mfa-recovery-codes.md +0 -1
  366. package/docs/examples/account/get-prefs.md +0 -1
  367. package/docs/examples/account/get-session.md +0 -2
  368. package/docs/examples/account/get.md +0 -1
  369. package/docs/examples/account/list-identities.md +0 -2
  370. package/docs/examples/account/list-logs.md +0 -2
  371. package/docs/examples/account/list-mfa-factors.md +0 -1
  372. package/docs/examples/account/list-sessions.md +0 -1
  373. package/docs/examples/account/update-email.md +0 -3
  374. package/docs/examples/account/update-m-f-a.md +0 -2
  375. package/docs/examples/account/update-magic-u-r-l-session.md +0 -3
  376. package/docs/examples/account/update-mfa-authenticator.md +0 -3
  377. package/docs/examples/account/update-mfa-challenge.md +0 -3
  378. package/docs/examples/account/update-mfa-recovery-codes.md +0 -1
  379. package/docs/examples/account/update-name.md +0 -2
  380. package/docs/examples/account/update-password.md +0 -3
  381. package/docs/examples/account/update-phone-session.md +0 -3
  382. package/docs/examples/account/update-phone-verification.md +0 -3
  383. package/docs/examples/account/update-phone.md +0 -3
  384. package/docs/examples/account/update-prefs.md +0 -2
  385. package/docs/examples/account/update-push-target.md +0 -3
  386. package/docs/examples/account/update-recovery.md +0 -4
  387. package/docs/examples/account/update-session.md +0 -2
  388. package/docs/examples/account/update-status.md +0 -1
  389. package/docs/examples/account/update-verification.md +0 -3
  390. package/docs/examples/avatars/get-browser.md +0 -5
  391. package/docs/examples/avatars/get-credit-card.md +0 -5
  392. package/docs/examples/avatars/get-favicon.md +0 -2
  393. package/docs/examples/avatars/get-flag.md +0 -5
  394. package/docs/examples/avatars/get-image.md +0 -4
  395. package/docs/examples/avatars/get-initials.md +0 -5
  396. package/docs/examples/avatars/get-q-r.md +0 -5
  397. package/docs/examples/console/get-resource.md +0 -3
  398. package/docs/examples/console/variables.md +0 -1
  399. package/docs/examples/databases/create-boolean-attribute.md +0 -7
  400. package/docs/examples/databases/create-collection.md +0 -7
  401. package/docs/examples/databases/create-datetime-attribute.md +0 -7
  402. package/docs/examples/databases/create-document.md +0 -6
  403. package/docs/examples/databases/create-documents.md +0 -4
  404. package/docs/examples/databases/create-email-attribute.md +0 -7
  405. package/docs/examples/databases/create-enum-attribute.md +0 -8
  406. package/docs/examples/databases/create-float-attribute.md +0 -9
  407. package/docs/examples/databases/create-index.md +0 -8
  408. package/docs/examples/databases/create-integer-attribute.md +0 -9
  409. package/docs/examples/databases/create-ip-attribute.md +0 -7
  410. package/docs/examples/databases/create-relationship-attribute.md +0 -9
  411. package/docs/examples/databases/create-string-attribute.md +0 -9
  412. package/docs/examples/databases/create-url-attribute.md +0 -7
  413. package/docs/examples/databases/create.md +0 -4
  414. package/docs/examples/databases/decrement-document-attribute.md +0 -7
  415. package/docs/examples/databases/delete-attribute.md +0 -4
  416. package/docs/examples/databases/delete-collection.md +0 -3
  417. package/docs/examples/databases/delete-document.md +0 -4
  418. package/docs/examples/databases/delete-documents.md +0 -4
  419. package/docs/examples/databases/delete-index.md +0 -4
  420. package/docs/examples/databases/delete.md +0 -2
  421. package/docs/examples/databases/get-attribute.md +0 -4
  422. package/docs/examples/databases/get-collection-usage.md +0 -4
  423. package/docs/examples/databases/get-collection.md +0 -3
  424. package/docs/examples/databases/get-database-usage.md +0 -3
  425. package/docs/examples/databases/get-document.md +0 -5
  426. package/docs/examples/databases/get-index.md +0 -4
  427. package/docs/examples/databases/get-usage.md +0 -2
  428. package/docs/examples/databases/get.md +0 -2
  429. package/docs/examples/databases/increment-document-attribute.md +0 -7
  430. package/docs/examples/databases/list-attributes.md +0 -4
  431. package/docs/examples/databases/list-collection-logs.md +0 -4
  432. package/docs/examples/databases/list-collections.md +0 -4
  433. package/docs/examples/databases/list-document-logs.md +0 -5
  434. package/docs/examples/databases/list-documents.md +0 -4
  435. package/docs/examples/databases/list-indexes.md +0 -4
  436. package/docs/examples/databases/list-logs.md +0 -3
  437. package/docs/examples/databases/list.md +0 -3
  438. package/docs/examples/databases/update-boolean-attribute.md +0 -7
  439. package/docs/examples/databases/update-collection.md +0 -7
  440. package/docs/examples/databases/update-datetime-attribute.md +0 -7
  441. package/docs/examples/databases/update-document.md +0 -6
  442. package/docs/examples/databases/update-documents.md +0 -5
  443. package/docs/examples/databases/update-email-attribute.md +0 -7
  444. package/docs/examples/databases/update-enum-attribute.md +0 -8
  445. package/docs/examples/databases/update-float-attribute.md +0 -9
  446. package/docs/examples/databases/update-integer-attribute.md +0 -9
  447. package/docs/examples/databases/update-ip-attribute.md +0 -7
  448. package/docs/examples/databases/update-relationship-attribute.md +0 -6
  449. package/docs/examples/databases/update-string-attribute.md +0 -8
  450. package/docs/examples/databases/update-url-attribute.md +0 -7
  451. package/docs/examples/databases/update.md +0 -4
  452. package/docs/examples/databases/upsert-document.md +0 -6
  453. package/docs/examples/databases/upsert-documents.md +0 -4
  454. package/docs/examples/functions/create-deployment.md +0 -6
  455. package/docs/examples/functions/create-duplicate-deployment.md +0 -4
  456. package/docs/examples/functions/create-execution.md +0 -8
  457. package/docs/examples/functions/create-template-deployment.md +0 -7
  458. package/docs/examples/functions/create-variable.md +0 -5
  459. package/docs/examples/functions/create-vcs-deployment.md +0 -5
  460. package/docs/examples/functions/create.md +0 -19
  461. package/docs/examples/functions/delete-deployment.md +0 -3
  462. package/docs/examples/functions/delete-execution.md +0 -3
  463. package/docs/examples/functions/delete-variable.md +0 -3
  464. package/docs/examples/functions/delete.md +0 -2
  465. package/docs/examples/functions/get-deployment-download.md +0 -4
  466. package/docs/examples/functions/get-deployment.md +0 -3
  467. package/docs/examples/functions/get-execution.md +0 -3
  468. package/docs/examples/functions/get-template.md +0 -2
  469. package/docs/examples/functions/get-usage.md +0 -3
  470. package/docs/examples/functions/get-variable.md +0 -3
  471. package/docs/examples/functions/get.md +0 -2
  472. package/docs/examples/functions/list-deployments.md +0 -4
  473. package/docs/examples/functions/list-executions.md +0 -3
  474. package/docs/examples/functions/list-runtimes.md +0 -1
  475. package/docs/examples/functions/list-specifications.md +0 -1
  476. package/docs/examples/functions/list-templates.md +0 -5
  477. package/docs/examples/functions/list-usage.md +0 -2
  478. package/docs/examples/functions/list-variables.md +0 -2
  479. package/docs/examples/functions/list.md +0 -3
  480. package/docs/examples/functions/update-deployment-status.md +0 -3
  481. package/docs/examples/functions/update-function-deployment.md +0 -3
  482. package/docs/examples/functions/update-variable.md +0 -6
  483. package/docs/examples/functions/update.md +0 -19
  484. package/docs/examples/graphql/mutation.md +0 -2
  485. package/docs/examples/graphql/query.md +0 -2
  486. package/docs/examples/health/get-antivirus.md +0 -1
  487. package/docs/examples/health/get-cache.md +0 -1
  488. package/docs/examples/health/get-certificate.md +0 -2
  489. package/docs/examples/health/get-d-b.md +0 -1
  490. package/docs/examples/health/get-failed-jobs.md +0 -3
  491. package/docs/examples/health/get-pub-sub.md +0 -1
  492. package/docs/examples/health/get-queue-builds.md +0 -2
  493. package/docs/examples/health/get-queue-certificates.md +0 -2
  494. package/docs/examples/health/get-queue-databases.md +0 -3
  495. package/docs/examples/health/get-queue-deletes.md +0 -2
  496. package/docs/examples/health/get-queue-functions.md +0 -2
  497. package/docs/examples/health/get-queue-logs.md +0 -2
  498. package/docs/examples/health/get-queue-mails.md +0 -2
  499. package/docs/examples/health/get-queue-messaging.md +0 -2
  500. package/docs/examples/health/get-queue-migrations.md +0 -2
  501. package/docs/examples/health/get-queue-stats-resources.md +0 -2
  502. package/docs/examples/health/get-queue-usage.md +0 -2
  503. package/docs/examples/health/get-queue-webhooks.md +0 -2
  504. package/docs/examples/health/get-storage-local.md +0 -1
  505. package/docs/examples/health/get-storage.md +0 -1
  506. package/docs/examples/health/get-time.md +0 -1
  507. package/docs/examples/health/get.md +0 -1
  508. package/docs/examples/locale/get.md +0 -1
  509. package/docs/examples/locale/list-codes.md +0 -1
  510. package/docs/examples/locale/list-continents.md +0 -1
  511. package/docs/examples/locale/list-countries-e-u.md +0 -1
  512. package/docs/examples/locale/list-countries-phones.md +0 -1
  513. package/docs/examples/locale/list-countries.md +0 -1
  514. package/docs/examples/locale/list-currencies.md +0 -1
  515. package/docs/examples/locale/list-languages.md +0 -1
  516. package/docs/examples/messaging/create-apns-provider.md +0 -9
  517. package/docs/examples/messaging/create-email.md +0 -13
  518. package/docs/examples/messaging/create-fcm-provider.md +0 -5
  519. package/docs/examples/messaging/create-mailgun-provider.md +0 -11
  520. package/docs/examples/messaging/create-msg91provider.md +0 -7
  521. package/docs/examples/messaging/create-push.md +0 -20
  522. package/docs/examples/messaging/create-sendgrid-provider.md +0 -9
  523. package/docs/examples/messaging/create-sms.md +0 -8
  524. package/docs/examples/messaging/create-smtp-provider.md +0 -15
  525. package/docs/examples/messaging/create-subscriber.md +0 -4
  526. package/docs/examples/messaging/create-telesign-provider.md +0 -7
  527. package/docs/examples/messaging/create-textmagic-provider.md +0 -7
  528. package/docs/examples/messaging/create-topic.md +0 -4
  529. package/docs/examples/messaging/create-twilio-provider.md +0 -7
  530. package/docs/examples/messaging/create-vonage-provider.md +0 -7
  531. package/docs/examples/messaging/delete-provider.md +0 -2
  532. package/docs/examples/messaging/delete-subscriber.md +0 -3
  533. package/docs/examples/messaging/delete-topic.md +0 -2
  534. package/docs/examples/messaging/delete.md +0 -2
  535. package/docs/examples/messaging/get-message.md +0 -2
  536. package/docs/examples/messaging/get-provider.md +0 -2
  537. package/docs/examples/messaging/get-subscriber.md +0 -3
  538. package/docs/examples/messaging/get-topic.md +0 -2
  539. package/docs/examples/messaging/list-message-logs.md +0 -3
  540. package/docs/examples/messaging/list-messages.md +0 -3
  541. package/docs/examples/messaging/list-provider-logs.md +0 -3
  542. package/docs/examples/messaging/list-providers.md +0 -3
  543. package/docs/examples/messaging/list-subscriber-logs.md +0 -3
  544. package/docs/examples/messaging/list-subscribers.md +0 -4
  545. package/docs/examples/messaging/list-targets.md +0 -3
  546. package/docs/examples/messaging/list-topic-logs.md +0 -3
  547. package/docs/examples/messaging/list-topics.md +0 -3
  548. package/docs/examples/messaging/update-apns-provider.md +0 -9
  549. package/docs/examples/messaging/update-email.md +0 -13
  550. package/docs/examples/messaging/update-fcm-provider.md +0 -5
  551. package/docs/examples/messaging/update-mailgun-provider.md +0 -11
  552. package/docs/examples/messaging/update-msg91provider.md +0 -7
  553. package/docs/examples/messaging/update-push.md +0 -20
  554. package/docs/examples/messaging/update-sendgrid-provider.md +0 -9
  555. package/docs/examples/messaging/update-sms.md +0 -8
  556. package/docs/examples/messaging/update-smtp-provider.md +0 -15
  557. package/docs/examples/messaging/update-telesign-provider.md +0 -7
  558. package/docs/examples/messaging/update-textmagic-provider.md +0 -7
  559. package/docs/examples/messaging/update-topic.md +0 -4
  560. package/docs/examples/messaging/update-twilio-provider.md +0 -7
  561. package/docs/examples/messaging/update-vonage-provider.md +0 -7
  562. package/docs/examples/migrations/create-appwrite-migration.md +0 -5
  563. package/docs/examples/migrations/create-csv-migration.md +0 -4
  564. package/docs/examples/migrations/create-firebase-migration.md +0 -3
  565. package/docs/examples/migrations/create-n-host-migration.md +0 -9
  566. package/docs/examples/migrations/create-supabase-migration.md +0 -8
  567. package/docs/examples/migrations/delete.md +0 -2
  568. package/docs/examples/migrations/get-appwrite-report.md +0 -5
  569. package/docs/examples/migrations/get-firebase-report.md +0 -3
  570. package/docs/examples/migrations/get-n-host-report.md +0 -9
  571. package/docs/examples/migrations/get-supabase-report.md +0 -8
  572. package/docs/examples/migrations/get.md +0 -2
  573. package/docs/examples/migrations/list.md +0 -3
  574. package/docs/examples/migrations/retry.md +0 -2
  575. package/docs/examples/project/create-variable.md +0 -4
  576. package/docs/examples/project/delete-variable.md +0 -2
  577. package/docs/examples/project/get-usage.md +0 -4
  578. package/docs/examples/project/get-variable.md +0 -2
  579. package/docs/examples/project/list-variables.md +0 -1
  580. package/docs/examples/project/update-variable.md +0 -5
  581. package/docs/examples/projects/create-dev-key.md +0 -4
  582. package/docs/examples/projects/create-j-w-t.md +0 -4
  583. package/docs/examples/projects/create-key.md +0 -5
  584. package/docs/examples/projects/create-platform.md +0 -7
  585. package/docs/examples/projects/create-smtp-test.md +0 -11
  586. package/docs/examples/projects/create-webhook.md +0 -9
  587. package/docs/examples/projects/create.md +0 -14
  588. package/docs/examples/projects/delete-dev-key.md +0 -3
  589. package/docs/examples/projects/delete-email-template.md +0 -4
  590. package/docs/examples/projects/delete-key.md +0 -3
  591. package/docs/examples/projects/delete-platform.md +0 -3
  592. package/docs/examples/projects/delete-sms-template.md +0 -4
  593. package/docs/examples/projects/delete-webhook.md +0 -3
  594. package/docs/examples/projects/delete.md +0 -2
  595. package/docs/examples/projects/get-dev-key.md +0 -3
  596. package/docs/examples/projects/get-email-template.md +0 -4
  597. package/docs/examples/projects/get-key.md +0 -3
  598. package/docs/examples/projects/get-platform.md +0 -3
  599. package/docs/examples/projects/get-sms-template.md +0 -4
  600. package/docs/examples/projects/get-webhook.md +0 -3
  601. package/docs/examples/projects/get.md +0 -2
  602. package/docs/examples/projects/list-dev-keys.md +0 -3
  603. package/docs/examples/projects/list-keys.md +0 -2
  604. package/docs/examples/projects/list-platforms.md +0 -2
  605. package/docs/examples/projects/list-webhooks.md +0 -2
  606. package/docs/examples/projects/list.md +0 -3
  607. package/docs/examples/projects/update-api-status-all.md +0 -3
  608. package/docs/examples/projects/update-api-status.md +0 -4
  609. package/docs/examples/projects/update-auth-duration.md +0 -3
  610. package/docs/examples/projects/update-auth-limit.md +0 -3
  611. package/docs/examples/projects/update-auth-password-dictionary.md +0 -3
  612. package/docs/examples/projects/update-auth-password-history.md +0 -3
  613. package/docs/examples/projects/update-auth-sessions-limit.md +0 -3
  614. package/docs/examples/projects/update-auth-status.md +0 -4
  615. package/docs/examples/projects/update-dev-key.md +0 -5
  616. package/docs/examples/projects/update-email-template.md +0 -9
  617. package/docs/examples/projects/update-key.md +0 -6
  618. package/docs/examples/projects/update-memberships-privacy.md +0 -5
  619. package/docs/examples/projects/update-mock-numbers.md +0 -3
  620. package/docs/examples/projects/update-o-auth2.md +0 -6
  621. package/docs/examples/projects/update-personal-data-check.md +0 -3
  622. package/docs/examples/projects/update-platform.md +0 -7
  623. package/docs/examples/projects/update-service-status-all.md +0 -3
  624. package/docs/examples/projects/update-service-status.md +0 -4
  625. package/docs/examples/projects/update-session-alerts.md +0 -3
  626. package/docs/examples/projects/update-sms-template.md +0 -5
  627. package/docs/examples/projects/update-smtp.md +0 -11
  628. package/docs/examples/projects/update-team.md +0 -3
  629. package/docs/examples/projects/update-webhook-signature.md +0 -3
  630. package/docs/examples/projects/update-webhook.md +0 -10
  631. package/docs/examples/projects/update.md +0 -12
  632. package/docs/examples/proxy/create-a-p-i-rule.md +0 -2
  633. package/docs/examples/proxy/create-function-rule.md +0 -4
  634. package/docs/examples/proxy/create-redirect-rule.md +0 -6
  635. package/docs/examples/proxy/create-site-rule.md +0 -4
  636. package/docs/examples/proxy/delete-rule.md +0 -2
  637. package/docs/examples/proxy/get-rule.md +0 -2
  638. package/docs/examples/proxy/list-rules.md +0 -3
  639. package/docs/examples/proxy/update-rule-verification.md +0 -2
  640. package/docs/examples/sites/create-deployment.md +0 -7
  641. package/docs/examples/sites/create-duplicate-deployment.md +0 -3
  642. package/docs/examples/sites/create-template-deployment.md +0 -7
  643. package/docs/examples/sites/create-variable.md +0 -5
  644. package/docs/examples/sites/create-vcs-deployment.md +0 -5
  645. package/docs/examples/sites/create.md +0 -19
  646. package/docs/examples/sites/delete-deployment.md +0 -3
  647. package/docs/examples/sites/delete-log.md +0 -3
  648. package/docs/examples/sites/delete-variable.md +0 -3
  649. package/docs/examples/sites/delete.md +0 -2
  650. package/docs/examples/sites/get-deployment-download.md +0 -4
  651. package/docs/examples/sites/get-deployment.md +0 -3
  652. package/docs/examples/sites/get-log.md +0 -3
  653. package/docs/examples/sites/get-template.md +0 -2
  654. package/docs/examples/sites/get-usage.md +0 -3
  655. package/docs/examples/sites/get-variable.md +0 -3
  656. package/docs/examples/sites/get.md +0 -2
  657. package/docs/examples/sites/list-deployments.md +0 -4
  658. package/docs/examples/sites/list-frameworks.md +0 -1
  659. package/docs/examples/sites/list-logs.md +0 -3
  660. package/docs/examples/sites/list-specifications.md +0 -1
  661. package/docs/examples/sites/list-templates.md +0 -5
  662. package/docs/examples/sites/list-usage.md +0 -2
  663. package/docs/examples/sites/list-variables.md +0 -2
  664. package/docs/examples/sites/list.md +0 -3
  665. package/docs/examples/sites/update-deployment-status.md +0 -3
  666. package/docs/examples/sites/update-site-deployment.md +0 -3
  667. package/docs/examples/sites/update-variable.md +0 -6
  668. package/docs/examples/sites/update.md +0 -19
  669. package/docs/examples/storage/create-bucket.md +0 -11
  670. package/docs/examples/storage/create-file.md +0 -5
  671. package/docs/examples/storage/delete-bucket.md +0 -2
  672. package/docs/examples/storage/delete-file.md +0 -3
  673. package/docs/examples/storage/get-bucket-usage.md +0 -3
  674. package/docs/examples/storage/get-bucket.md +0 -2
  675. package/docs/examples/storage/get-file-download.md +0 -4
  676. package/docs/examples/storage/get-file-preview.md +0 -15
  677. package/docs/examples/storage/get-file-view.md +0 -4
  678. package/docs/examples/storage/get-file.md +0 -3
  679. package/docs/examples/storage/get-usage.md +0 -2
  680. package/docs/examples/storage/list-buckets.md +0 -3
  681. package/docs/examples/storage/list-files.md +0 -4
  682. package/docs/examples/storage/update-bucket.md +0 -11
  683. package/docs/examples/storage/update-file.md +0 -5
  684. package/docs/examples/teams/create-membership.md +0 -8
  685. package/docs/examples/teams/create.md +0 -4
  686. package/docs/examples/teams/delete-membership.md +0 -3
  687. package/docs/examples/teams/delete.md +0 -2
  688. package/docs/examples/teams/get-membership.md +0 -3
  689. package/docs/examples/teams/get-prefs.md +0 -2
  690. package/docs/examples/teams/get.md +0 -2
  691. package/docs/examples/teams/list-logs.md +0 -3
  692. package/docs/examples/teams/list-memberships.md +0 -4
  693. package/docs/examples/teams/list.md +0 -3
  694. package/docs/examples/teams/update-membership-status.md +0 -5
  695. package/docs/examples/teams/update-membership.md +0 -4
  696. package/docs/examples/teams/update-name.md +0 -3
  697. package/docs/examples/teams/update-prefs.md +0 -3
  698. package/docs/examples/tokens/create-file-token.md +0 -4
  699. package/docs/examples/tokens/delete.md +0 -2
  700. package/docs/examples/tokens/get.md +0 -2
  701. package/docs/examples/tokens/list.md +0 -4
  702. package/docs/examples/tokens/update.md +0 -3
  703. package/docs/examples/users/create-argon2user.md +0 -5
  704. package/docs/examples/users/create-bcrypt-user.md +0 -5
  705. package/docs/examples/users/create-j-w-t.md +0 -4
  706. package/docs/examples/users/create-m-d5user.md +0 -5
  707. package/docs/examples/users/create-mfa-recovery-codes.md +0 -2
  708. package/docs/examples/users/create-p-h-pass-user.md +0 -5
  709. package/docs/examples/users/create-s-h-a-user.md +0 -6
  710. package/docs/examples/users/create-scrypt-modified-user.md +0 -8
  711. package/docs/examples/users/create-scrypt-user.md +0 -10
  712. package/docs/examples/users/create-session.md +0 -2
  713. package/docs/examples/users/create-target.md +0 -7
  714. package/docs/examples/users/create-token.md +0 -4
  715. package/docs/examples/users/create.md +0 -6
  716. package/docs/examples/users/delete-identity.md +0 -2
  717. package/docs/examples/users/delete-mfa-authenticator.md +0 -3
  718. package/docs/examples/users/delete-session.md +0 -3
  719. package/docs/examples/users/delete-sessions.md +0 -2
  720. package/docs/examples/users/delete-target.md +0 -3
  721. package/docs/examples/users/delete.md +0 -2
  722. package/docs/examples/users/get-mfa-recovery-codes.md +0 -2
  723. package/docs/examples/users/get-prefs.md +0 -2
  724. package/docs/examples/users/get-target.md +0 -3
  725. package/docs/examples/users/get-usage.md +0 -2
  726. package/docs/examples/users/get.md +0 -2
  727. package/docs/examples/users/list-identities.md +0 -3
  728. package/docs/examples/users/list-logs.md +0 -3
  729. package/docs/examples/users/list-memberships.md +0 -4
  730. package/docs/examples/users/list-mfa-factors.md +0 -2
  731. package/docs/examples/users/list-sessions.md +0 -2
  732. package/docs/examples/users/list-targets.md +0 -3
  733. package/docs/examples/users/list.md +0 -3
  734. package/docs/examples/users/update-email-verification.md +0 -3
  735. package/docs/examples/users/update-email.md +0 -3
  736. package/docs/examples/users/update-labels.md +0 -3
  737. package/docs/examples/users/update-mfa-recovery-codes.md +0 -2
  738. package/docs/examples/users/update-mfa.md +0 -3
  739. package/docs/examples/users/update-name.md +0 -3
  740. package/docs/examples/users/update-password.md +0 -3
  741. package/docs/examples/users/update-phone-verification.md +0 -3
  742. package/docs/examples/users/update-phone.md +0 -3
  743. package/docs/examples/users/update-prefs.md +0 -3
  744. package/docs/examples/users/update-status.md +0 -3
  745. package/docs/examples/users/update-target.md +0 -6
  746. package/docs/examples/vcs/create-repository-detection.md +0 -5
  747. package/docs/examples/vcs/create-repository.md +0 -4
  748. package/docs/examples/vcs/delete-installation.md +0 -2
  749. package/docs/examples/vcs/get-installation.md +0 -2
  750. package/docs/examples/vcs/get-repository-contents.md +0 -5
  751. package/docs/examples/vcs/get-repository.md +0 -3
  752. package/docs/examples/vcs/list-installations.md +0 -3
  753. package/docs/examples/vcs/list-repositories.md +0 -4
  754. package/docs/examples/vcs/list-repository-branches.md +0 -3
  755. package/docs/examples/vcs/update-external-deployments.md +0 -4
  756. package/functions/Starter function/.prettierrc.json +0 -6
  757. package/functions/Starter function/README.md +0 -48
  758. package/functions/Starter function/package-lock.json +0 -60
  759. package/functions/Starter function/package.json +0 -16
  760. package/functions/Starter function/src/main.js +0 -35
  761. package/generate/appwrite.d.ts +0 -18
  762. package/index.js +0 -109
  763. package/lib/client.js +0 -259
  764. package/lib/commands/account.js +0 -2074
  765. package/lib/commands/avatars.js +0 -491
  766. package/lib/commands/console.js +0 -129
  767. package/lib/commands/databases.js +0 -2972
  768. package/lib/commands/functions.js +0 -1737
  769. package/lib/commands/generic.js +0 -328
  770. package/lib/commands/graphql.js +0 -128
  771. package/lib/commands/health.js +0 -891
  772. package/lib/commands/init.js +0 -566
  773. package/lib/commands/locale.js +0 -324
  774. package/lib/commands/messaging.js +0 -2970
  775. package/lib/commands/migrations.js +0 -751
  776. package/lib/commands/organizations.js +0 -48
  777. package/lib/commands/project.js +0 -308
  778. package/lib/commands/projects.js +0 -2615
  779. package/lib/commands/proxy.js +0 -406
  780. package/lib/commands/pull.js +0 -474
  781. package/lib/commands/push.js +0 -2117
  782. package/lib/commands/run.js +0 -330
  783. package/lib/commands/sites.js +0 -1663
  784. package/lib/commands/storage.js +0 -990
  785. package/lib/commands/teams.js +0 -682
  786. package/lib/commands/tokens.js +0 -261
  787. package/lib/commands/types.js +0 -156
  788. package/lib/commands/users.js +0 -2035
  789. package/lib/commands/vcs.js +0 -484
  790. package/lib/config.js +0 -705
  791. package/lib/emulation/docker.js +0 -264
  792. package/lib/emulation/utils.js +0 -186
  793. package/lib/exception.js +0 -9
  794. package/lib/id.js +0 -30
  795. package/lib/paginate.js +0 -52
  796. package/lib/parser.js +0 -246
  797. package/lib/questions.js +0 -1006
  798. package/lib/sdks.js +0 -60
  799. package/lib/spinner.js +0 -104
  800. package/lib/type-generation/attribute.js +0 -16
  801. package/lib/type-generation/languages/dart.js +0 -196
  802. package/lib/type-generation/languages/java.js +0 -130
  803. package/lib/type-generation/languages/javascript.js +0 -102
  804. package/lib/type-generation/languages/kotlin.js +0 -84
  805. package/lib/type-generation/languages/language.js +0 -125
  806. package/lib/type-generation/languages/php.js +0 -109
  807. package/lib/type-generation/languages/swift.js +0 -169
  808. package/lib/type-generation/languages/typescript.js +0 -102
  809. package/lib/utils.js +0 -289
  810. package/lib/validations.js +0 -17
  811. package/scoop/appwrite.json +0 -30
  812. package/sites/JavaScript starter/.env.example +0 -3
  813. package/sites/JavaScript starter/LICENSE +0 -21
  814. package/sites/JavaScript starter/images/appwrite.svg +0 -8
  815. package/sites/JavaScript starter/images/javascript.svg +0 -5
  816. package/sites/JavaScript starter/index.html +0 -250
  817. package/sites/JavaScript starter/lib/appwrite.js +0 -10
  818. package/sites/JavaScript starter/package-lock.json +0 -1431
  819. package/sites/JavaScript starter/package.json +0 -21
  820. package/sites/JavaScript starter/readme.md +0 -26
  821. package/sites/JavaScript starter/src/javascript.svg +0 -1
  822. package/sites/JavaScript starter/style/app.css +0 -20
  823. package/sites/JavaScript starter/vite.config.js +0 -7
@@ -0,0 +1,1666 @@
1
+ import fs from "fs";
2
+ import { parse as parseDotenv } from "dotenv";
3
+ import chalk from "chalk";
4
+ import inquirer from "inquirer";
5
+ import { Command } from "commander";
6
+ import ID from "../id.js";
7
+ import { localConfig, globalConfig, KeysFunction, KeysSite, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable, } from "../config.js";
8
+ import { createSettingsObject } from "../utils.js";
9
+ import { Spinner, SPINNER_DOTS } from "../spinner.js";
10
+ import { paginate } from "../paginate.js";
11
+ import { pushDeployment } from "./utils/deployment.js";
12
+ import { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsPushSites, questionsGetEntrypoint, questionsPushCollections, questionsPushTables, questionsPushMessagingTopics, questionsPushResources, } from "../questions.js";
13
+ import { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable, } from "../parser.js";
14
+ import { getProxyService, getConsoleService, getFunctionsService, getSitesService, getDatabasesService, getTablesDBService, getStorageService, getMessagingService, getTeamsService, getProjectsService, } from "../services.js";
15
+ import { sdkForProject, sdkForConsole } from "../sdks.js";
16
+ import { AppwriteException, Query, } from "@appwrite.io/console";
17
+ import { checkDeployConditions } from "../utils.js";
18
+ import { Pools } from "./utils/pools.js";
19
+ import { Attributes } from "./utils/attributes.js";
20
+ import { getConfirmation, approveChanges, getObjectChanges, } from "./utils/change-approval.js";
21
+ import { checkAndApplyTablesDBChanges } from "./utils/database-sync.js";
22
+ const POLL_DEBOUNCE = 2000; // Milliseconds
23
+ const POLL_DEFAULT_VALUE = 30;
24
+ export class Push {
25
+ projectClient;
26
+ consoleClient;
27
+ constructor(projectClient, consoleClient) {
28
+ this.projectClient = projectClient;
29
+ this.consoleClient = consoleClient;
30
+ }
31
+ async pushResources(config, options = { all: true, skipDeprecated: true }) {
32
+ const { skipDeprecated = true } = options;
33
+ const results = {};
34
+ const allErrors = [];
35
+ const shouldPushAll = options.all === true;
36
+ // Push settings
37
+ if ((shouldPushAll || options.settings) &&
38
+ (config.projectName || config.settings)) {
39
+ try {
40
+ log("Pushing settings ...");
41
+ await this.pushSettings({
42
+ projectId: config.projectId,
43
+ projectName: config.projectName,
44
+ settings: config.settings,
45
+ });
46
+ results.settings = { success: true };
47
+ }
48
+ catch (e) {
49
+ allErrors.push(e);
50
+ results.settings = { success: false, error: e.message };
51
+ }
52
+ }
53
+ // Push buckets
54
+ if ((shouldPushAll || options.buckets) &&
55
+ config.buckets &&
56
+ config.buckets.length > 0) {
57
+ try {
58
+ log("Pushing buckets ...");
59
+ const result = await this.pushBuckets(config.buckets);
60
+ results.buckets = result;
61
+ allErrors.push(...result.errors);
62
+ }
63
+ catch (e) {
64
+ allErrors.push(e);
65
+ results.buckets = { successfullyPushed: 0, errors: [e] };
66
+ }
67
+ }
68
+ // Push teams
69
+ if ((shouldPushAll || options.teams) &&
70
+ config.teams &&
71
+ config.teams.length > 0) {
72
+ try {
73
+ log("Pushing teams ...");
74
+ const result = await this.pushTeams(config.teams);
75
+ results.teams = result;
76
+ allErrors.push(...result.errors);
77
+ }
78
+ catch (e) {
79
+ allErrors.push(e);
80
+ results.teams = { successfullyPushed: 0, errors: [e] };
81
+ }
82
+ }
83
+ // Push messaging topics
84
+ if ((shouldPushAll || options.topics) &&
85
+ config.topics &&
86
+ config.topics.length > 0) {
87
+ try {
88
+ log("Pushing topics ...");
89
+ const result = await this.pushMessagingTopics(config.topics);
90
+ results.topics = result;
91
+ allErrors.push(...result.errors);
92
+ }
93
+ catch (e) {
94
+ allErrors.push(e);
95
+ results.topics = { successfullyPushed: 0, errors: [e] };
96
+ }
97
+ }
98
+ // Push functions
99
+ if ((shouldPushAll || options.functions) &&
100
+ config.functions &&
101
+ config.functions.length > 0) {
102
+ try {
103
+ log("Pushing functions ...");
104
+ const result = await this.pushFunctions(config.functions, options.functionOptions);
105
+ results.functions = result;
106
+ allErrors.push(...result.errors);
107
+ }
108
+ catch (e) {
109
+ allErrors.push(e);
110
+ results.functions = {
111
+ successfullyPushed: 0,
112
+ successfullyDeployed: 0,
113
+ failedDeployments: [],
114
+ errors: [e],
115
+ };
116
+ }
117
+ }
118
+ // Push sites
119
+ if ((shouldPushAll || options.sites) &&
120
+ config.sites &&
121
+ config.sites.length > 0) {
122
+ try {
123
+ log("Pushing sites ...");
124
+ const result = await this.pushSites(config.sites, options.siteOptions);
125
+ results.sites = result;
126
+ allErrors.push(...result.errors);
127
+ }
128
+ catch (e) {
129
+ allErrors.push(e);
130
+ results.sites = {
131
+ successfullyPushed: 0,
132
+ successfullyDeployed: 0,
133
+ failedDeployments: [],
134
+ errors: [e],
135
+ };
136
+ }
137
+ }
138
+ // Push tables
139
+ if ((shouldPushAll || options.tables) &&
140
+ config.tables &&
141
+ config.tables.length > 0) {
142
+ try {
143
+ log("Pushing tables ...");
144
+ const result = await this.pushTables(config.tables);
145
+ results.tables = result;
146
+ allErrors.push(...result.errors);
147
+ }
148
+ catch (e) {
149
+ allErrors.push(e);
150
+ results.tables = { successfullyPushed: 0, errors: [e] };
151
+ }
152
+ }
153
+ // Push collections (unless skipDeprecated is true)
154
+ if (!skipDeprecated &&
155
+ (shouldPushAll || options.collections) &&
156
+ config.collections &&
157
+ config.collections.length > 0) {
158
+ try {
159
+ log("Pushing collections ...");
160
+ // Add database names to collections
161
+ const collectionsWithDbNames = config.collections.map((collection) => {
162
+ const database = config.databases?.find((db) => db.$id === collection.databaseId);
163
+ return {
164
+ ...collection,
165
+ databaseName: database?.name ?? collection.databaseId,
166
+ };
167
+ });
168
+ const result = await this.pushCollections(collectionsWithDbNames);
169
+ results.collections = result;
170
+ allErrors.push(...result.errors);
171
+ }
172
+ catch (e) {
173
+ allErrors.push(e);
174
+ results.collections = { successfullyPushed: 0, errors: [e] };
175
+ }
176
+ }
177
+ return {
178
+ results,
179
+ errors: allErrors,
180
+ };
181
+ }
182
+ async pushSettings(config) {
183
+ const projectsService = await getProjectsService(this.consoleClient);
184
+ const projectId = config.projectId;
185
+ const projectName = config.projectName;
186
+ const settings = config.settings ?? {};
187
+ if (projectName) {
188
+ await projectsService.update({
189
+ projectId: projectId,
190
+ name: projectName,
191
+ });
192
+ }
193
+ if (settings.services) {
194
+ for (let [service, status] of Object.entries(settings.services)) {
195
+ await projectsService.updateServiceStatus({
196
+ projectId: projectId,
197
+ service: service,
198
+ status: status,
199
+ });
200
+ }
201
+ }
202
+ if (settings.auth) {
203
+ if (settings.auth.security) {
204
+ await projectsService.updateAuthDuration({
205
+ projectId,
206
+ duration: settings.auth.security.duration,
207
+ });
208
+ await projectsService.updateAuthLimit({
209
+ projectId,
210
+ limit: settings.auth.security.limit,
211
+ });
212
+ await projectsService.updateAuthSessionsLimit({
213
+ projectId,
214
+ limit: settings.auth.security.sessionsLimit,
215
+ });
216
+ await projectsService.updateAuthPasswordDictionary({
217
+ projectId,
218
+ enabled: settings.auth.security.passwordDictionary,
219
+ });
220
+ await projectsService.updateAuthPasswordHistory({
221
+ projectId,
222
+ limit: settings.auth.security.passwordHistory,
223
+ });
224
+ await projectsService.updatePersonalDataCheck({
225
+ projectId,
226
+ enabled: settings.auth.security.personalDataCheck,
227
+ });
228
+ await projectsService.updateSessionAlerts({
229
+ projectId,
230
+ alerts: settings.auth.security.sessionAlerts,
231
+ });
232
+ await projectsService.updateMockNumbers({
233
+ projectId,
234
+ numbers: settings.auth.security.mockNumbers,
235
+ });
236
+ }
237
+ if (settings.auth.methods) {
238
+ for (let [method, status] of Object.entries(settings.auth.methods)) {
239
+ await projectsService.updateAuthStatus({
240
+ projectId,
241
+ method: method,
242
+ status: status,
243
+ });
244
+ }
245
+ }
246
+ }
247
+ }
248
+ async pushBuckets(buckets) {
249
+ let successfullyPushed = 0;
250
+ const errors = [];
251
+ for (const bucket of buckets) {
252
+ try {
253
+ log(`Pushing bucket ${chalk.bold(bucket["name"])} ...`);
254
+ const storageService = await getStorageService(this.projectClient);
255
+ try {
256
+ await storageService.getBucket(bucket["$id"]);
257
+ await storageService.updateBucket({
258
+ bucketId: bucket["$id"],
259
+ name: bucket.name,
260
+ permissions: bucket["$permissions"],
261
+ fileSecurity: bucket.fileSecurity,
262
+ enabled: bucket.enabled,
263
+ maximumFileSize: bucket.maximumFileSize,
264
+ allowedFileExtensions: bucket.allowedFileExtensions,
265
+ encryption: bucket.encryption,
266
+ antivirus: bucket.antivirus,
267
+ compression: bucket.compression,
268
+ });
269
+ }
270
+ catch (e) {
271
+ if (e instanceof AppwriteException && Number(e.code) === 404) {
272
+ await storageService.createBucket({
273
+ bucketId: bucket["$id"],
274
+ name: bucket.name,
275
+ permissions: bucket["$permissions"],
276
+ fileSecurity: bucket.fileSecurity,
277
+ enabled: bucket.enabled,
278
+ maximumFileSize: bucket.maximumFileSize,
279
+ allowedFileExtensions: bucket.allowedFileExtensions,
280
+ compression: bucket.compression,
281
+ encryption: bucket.encryption,
282
+ antivirus: bucket.antivirus,
283
+ });
284
+ }
285
+ else {
286
+ throw e;
287
+ }
288
+ }
289
+ successfullyPushed++;
290
+ }
291
+ catch (e) {
292
+ errors.push(e);
293
+ error(`Failed to push bucket ${bucket["name"]}: ${e.message}`);
294
+ }
295
+ }
296
+ return {
297
+ successfullyPushed,
298
+ errors,
299
+ };
300
+ }
301
+ async pushTeams(teams) {
302
+ let successfullyPushed = 0;
303
+ const errors = [];
304
+ for (const team of teams) {
305
+ try {
306
+ log(`Pushing team ${chalk.bold(team["name"])} ...`);
307
+ const teamsService = await getTeamsService(this.projectClient);
308
+ try {
309
+ await teamsService.get(team["$id"]);
310
+ await teamsService.updateName({
311
+ teamId: team["$id"],
312
+ name: team.name,
313
+ });
314
+ }
315
+ catch (e) {
316
+ if (e instanceof AppwriteException && Number(e.code) === 404) {
317
+ await teamsService.create({
318
+ teamId: team["$id"],
319
+ name: team.name,
320
+ });
321
+ }
322
+ else {
323
+ throw e;
324
+ }
325
+ }
326
+ successfullyPushed++;
327
+ }
328
+ catch (e) {
329
+ errors.push(e);
330
+ error(`Failed to push team ${team["name"]}: ${e.message}`);
331
+ }
332
+ }
333
+ return {
334
+ successfullyPushed,
335
+ errors,
336
+ };
337
+ }
338
+ async pushMessagingTopics(topics) {
339
+ let successfullyPushed = 0;
340
+ const errors = [];
341
+ for (const topic of topics) {
342
+ try {
343
+ log(`Pushing topic ${chalk.bold(topic["name"])} ...`);
344
+ const messagingService = await getMessagingService(this.projectClient);
345
+ try {
346
+ await messagingService.getTopic(topic["$id"]);
347
+ await messagingService.updateTopic({
348
+ topicId: topic["$id"],
349
+ name: topic.name,
350
+ subscribe: topic.subscribe,
351
+ });
352
+ }
353
+ catch (e) {
354
+ if (e instanceof AppwriteException && Number(e.code) === 404) {
355
+ await messagingService.createTopic({
356
+ topicId: topic["$id"],
357
+ name: topic.name,
358
+ subscribe: topic.subscribe,
359
+ });
360
+ }
361
+ else {
362
+ throw e;
363
+ }
364
+ }
365
+ success(`Created ${topic.name} ( ${topic["$id"]} )`);
366
+ successfullyPushed++;
367
+ }
368
+ catch (e) {
369
+ errors.push(e);
370
+ error(`Failed to push topic ${topic["name"]}: ${e.message}`);
371
+ }
372
+ }
373
+ return {
374
+ successfullyPushed,
375
+ errors,
376
+ };
377
+ }
378
+ async pushFunctions(functions, options = {}) {
379
+ const { async: asyncDeploy, code, withVariables } = options;
380
+ Spinner.start(false);
381
+ let successfullyPushed = 0;
382
+ let successfullyDeployed = 0;
383
+ const failedDeployments = [];
384
+ const errors = [];
385
+ await Promise.all(functions.map(async (func) => {
386
+ let response = {};
387
+ const ignore = func.ignore ? "appwrite.config.json" : ".gitignore";
388
+ let functionExists = false;
389
+ let deploymentCreated = false;
390
+ const updaterRow = new Spinner({
391
+ status: "",
392
+ resource: func.name,
393
+ id: func["$id"],
394
+ end: `Ignoring using: ${ignore}`,
395
+ });
396
+ updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
397
+ const functionsService = await getFunctionsService(this.projectClient);
398
+ try {
399
+ response = await functionsService.get({ functionId: func["$id"] });
400
+ functionExists = true;
401
+ if (response.runtime !== func.runtime) {
402
+ updaterRow.fail({
403
+ errorMessage: `Runtime mismatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.config.json`,
404
+ });
405
+ return;
406
+ }
407
+ updaterRow
408
+ .update({ status: "Updating" })
409
+ .replaceSpinner(SPINNER_DOTS);
410
+ response = await functionsService.update({
411
+ functionId: func["$id"],
412
+ name: func.name,
413
+ runtime: func.runtime,
414
+ execute: func.execute,
415
+ events: func.events,
416
+ schedule: func.schedule,
417
+ timeout: func.timeout,
418
+ enabled: func.enabled,
419
+ logging: func.logging,
420
+ entrypoint: func.entrypoint,
421
+ commands: func.commands,
422
+ scopes: func.scopes,
423
+ specification: func.specification,
424
+ });
425
+ }
426
+ catch (e) {
427
+ if (Number(e.code) === 404) {
428
+ functionExists = false;
429
+ }
430
+ else {
431
+ errors.push(e);
432
+ updaterRow.fail({
433
+ errorMessage: e.message ?? "General error occurs please try again",
434
+ });
435
+ return;
436
+ }
437
+ }
438
+ if (!functionExists) {
439
+ updaterRow
440
+ .update({ status: "Creating" })
441
+ .replaceSpinner(SPINNER_DOTS);
442
+ try {
443
+ response = await functionsService.create({
444
+ functionId: func.$id,
445
+ name: func.name,
446
+ runtime: func.runtime,
447
+ execute: func.execute,
448
+ events: func.events,
449
+ schedule: func.schedule,
450
+ timeout: func.timeout,
451
+ enabled: func.enabled,
452
+ logging: func.logging,
453
+ entrypoint: func.entrypoint,
454
+ commands: func.commands,
455
+ scopes: func.scopes,
456
+ specification: func.specification,
457
+ });
458
+ let domain = "";
459
+ try {
460
+ const consoleService = await getConsoleService(this.projectClient);
461
+ const variables = await consoleService.variables();
462
+ domain = ID.unique() + "." + variables["_APP_DOMAIN_FUNCTIONS"];
463
+ }
464
+ catch (error) {
465
+ console.error("Error fetching console variables.");
466
+ throw error;
467
+ }
468
+ try {
469
+ const proxyService = await getProxyService(this.projectClient);
470
+ await proxyService.createFunctionRule(domain, func.$id);
471
+ }
472
+ catch (error) {
473
+ console.error("Error creating function rule.");
474
+ throw error;
475
+ }
476
+ updaterRow.update({ status: "Created" });
477
+ }
478
+ catch (e) {
479
+ errors.push(e);
480
+ updaterRow.fail({
481
+ errorMessage: e.message ?? "General error occurs please try again",
482
+ });
483
+ return;
484
+ }
485
+ }
486
+ if (withVariables) {
487
+ updaterRow
488
+ .update({ status: "Updating variables" })
489
+ .replaceSpinner(SPINNER_DOTS);
490
+ const functionsServiceForVars = await getFunctionsService(this.projectClient);
491
+ const { variables } = await paginate(async (args) => {
492
+ return await functionsServiceForVars.listVariables({
493
+ functionId: args.functionId,
494
+ });
495
+ }, {
496
+ functionId: func["$id"],
497
+ }, 100, "variables");
498
+ await Promise.all(variables.map(async (variable) => {
499
+ const functionsServiceDel = await getFunctionsService(this.projectClient);
500
+ await functionsServiceDel.deleteVariable({
501
+ functionId: func["$id"],
502
+ variableId: variable["$id"],
503
+ });
504
+ }));
505
+ const envFileLocation = `${func["path"]}/.env`;
506
+ let envVariables = [];
507
+ try {
508
+ if (fs.existsSync(envFileLocation)) {
509
+ const envObject = parseDotenv(fs.readFileSync(envFileLocation, "utf8"));
510
+ envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
511
+ }
512
+ }
513
+ catch (error) {
514
+ envVariables = [];
515
+ }
516
+ await Promise.all(envVariables.map(async (variable) => {
517
+ const functionsServiceCreate = await getFunctionsService(this.projectClient);
518
+ await functionsServiceCreate.createVariable({
519
+ functionId: func["$id"],
520
+ key: variable.key,
521
+ value: variable.value,
522
+ secret: false,
523
+ });
524
+ }));
525
+ }
526
+ if (code === false) {
527
+ successfullyPushed++;
528
+ successfullyDeployed++;
529
+ updaterRow.update({ status: "Pushed" });
530
+ updaterRow.stopSpinner();
531
+ return;
532
+ }
533
+ try {
534
+ updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
535
+ const functionsServiceDeploy = await getFunctionsService(this.projectClient);
536
+ const result = await pushDeployment({
537
+ resourcePath: func.path,
538
+ createDeployment: async (codeFile) => {
539
+ return await functionsServiceDeploy.createDeployment({
540
+ functionId: func["$id"],
541
+ entrypoint: func.entrypoint,
542
+ commands: func.commands,
543
+ code: codeFile,
544
+ activate: true,
545
+ });
546
+ },
547
+ pollForStatus: false,
548
+ });
549
+ response = result.deployment;
550
+ updaterRow.update({ status: "Pushed" });
551
+ deploymentCreated = true;
552
+ successfullyPushed++;
553
+ }
554
+ catch (e) {
555
+ errors.push(e);
556
+ switch (e.code) {
557
+ case "ENOENT":
558
+ updaterRow.fail({
559
+ errorMessage: "Not found in the current directory. Skipping...",
560
+ });
561
+ break;
562
+ default:
563
+ updaterRow.fail({
564
+ errorMessage: e.message ?? "An unknown error occurred. Please try again.",
565
+ });
566
+ }
567
+ }
568
+ if (deploymentCreated && !asyncDeploy) {
569
+ try {
570
+ const deploymentId = response["$id"];
571
+ updaterRow.update({
572
+ status: "Deploying",
573
+ end: "Checking deployment status...",
574
+ });
575
+ while (true) {
576
+ const functionsServicePoll = await getFunctionsService(this.projectClient);
577
+ response = await functionsServicePoll.getDeployment({
578
+ functionId: func["$id"],
579
+ deploymentId: deploymentId,
580
+ });
581
+ const status = response["status"];
582
+ if (status === "ready") {
583
+ successfullyDeployed++;
584
+ let url = "";
585
+ const proxyServiceUrl = await getProxyService(this.projectClient);
586
+ const res = await proxyServiceUrl.listRules({
587
+ queries: [
588
+ Query.limit(1),
589
+ Query.equal("deploymentResourceType", "function"),
590
+ Query.equal("deploymentResourceId", func["$id"]),
591
+ Query.equal("trigger", "manual"),
592
+ ],
593
+ });
594
+ if (Number(res.total) === 1) {
595
+ url = `https://${res.rules[0].domain}`;
596
+ }
597
+ updaterRow.update({ status: "Deployed", end: url });
598
+ break;
599
+ }
600
+ else if (status === "failed") {
601
+ failedDeployments.push({
602
+ name: func["name"],
603
+ $id: func["$id"],
604
+ deployment: response["$id"],
605
+ });
606
+ updaterRow.fail({ errorMessage: `Failed to deploy` });
607
+ break;
608
+ }
609
+ else {
610
+ updaterRow.update({
611
+ status: "Deploying",
612
+ end: `Current status: ${status}`,
613
+ });
614
+ }
615
+ await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
616
+ }
617
+ }
618
+ catch (e) {
619
+ errors.push(e);
620
+ updaterRow.fail({
621
+ errorMessage: e.message ?? "Unknown error occurred. Please try again",
622
+ });
623
+ }
624
+ }
625
+ updaterRow.stopSpinner();
626
+ }));
627
+ Spinner.stop();
628
+ return {
629
+ successfullyPushed,
630
+ successfullyDeployed,
631
+ failedDeployments,
632
+ errors,
633
+ };
634
+ }
635
+ async pushSites(sites, options = {}) {
636
+ const { async: asyncDeploy, code, withVariables } = options;
637
+ Spinner.start(false);
638
+ let successfullyPushed = 0;
639
+ let successfullyDeployed = 0;
640
+ const failedDeployments = [];
641
+ const errors = [];
642
+ await Promise.all(sites.map(async (site) => {
643
+ let response = {};
644
+ const ignore = site.ignore ? "appwrite.config.json" : ".gitignore";
645
+ let siteExists = false;
646
+ let deploymentCreated = false;
647
+ const updaterRow = new Spinner({
648
+ status: "",
649
+ resource: site.name,
650
+ id: site["$id"],
651
+ end: `Ignoring using: ${ignore}`,
652
+ });
653
+ updaterRow.update({ status: "Getting" }).startSpinner(SPINNER_DOTS);
654
+ const sitesService = await getSitesService(this.projectClient);
655
+ try {
656
+ response = await sitesService.get({ siteId: site["$id"] });
657
+ siteExists = true;
658
+ if (response.framework !== site.framework) {
659
+ updaterRow.fail({
660
+ errorMessage: `Framework mismatch! (local=${site.framework},remote=${response.framework}) Please delete remote site or update your appwrite.config.json`,
661
+ });
662
+ return;
663
+ }
664
+ updaterRow
665
+ .update({ status: "Updating" })
666
+ .replaceSpinner(SPINNER_DOTS);
667
+ response = await sitesService.update({
668
+ siteId: site["$id"],
669
+ name: site.name,
670
+ framework: site.framework,
671
+ enabled: site.enabled,
672
+ logging: site.logging,
673
+ timeout: site.timeout,
674
+ installCommand: site.installCommand,
675
+ buildCommand: site.buildCommand,
676
+ outputDirectory: site.outputDirectory,
677
+ buildRuntime: site.buildRuntime,
678
+ adapter: site.adapter,
679
+ specification: site.specification,
680
+ });
681
+ }
682
+ catch (e) {
683
+ if (Number(e.code) === 404) {
684
+ siteExists = false;
685
+ }
686
+ else {
687
+ errors.push(e);
688
+ updaterRow.fail({
689
+ errorMessage: e.message ?? "General error occurs please try again",
690
+ });
691
+ return;
692
+ }
693
+ }
694
+ if (!siteExists) {
695
+ updaterRow
696
+ .update({ status: "Creating" })
697
+ .replaceSpinner(SPINNER_DOTS);
698
+ try {
699
+ response = await sitesService.create({
700
+ siteId: site.$id,
701
+ name: site.name,
702
+ framework: site.framework,
703
+ enabled: site.enabled,
704
+ logging: site.logging,
705
+ timeout: site.timeout,
706
+ installCommand: site.installCommand,
707
+ buildCommand: site.buildCommand,
708
+ outputDirectory: site.outputDirectory,
709
+ buildRuntime: site.buildRuntime,
710
+ adapter: site.adapter,
711
+ specification: site.specification,
712
+ });
713
+ let domain = "";
714
+ try {
715
+ const consoleService = await getConsoleService(this.projectClient);
716
+ const variables = await consoleService.variables();
717
+ domain = ID.unique() + "." + variables["_APP_DOMAIN_SITES"];
718
+ }
719
+ catch (error) {
720
+ console.error("Error fetching console variables.");
721
+ throw error;
722
+ }
723
+ try {
724
+ const proxyService = await getProxyService(this.projectClient);
725
+ await proxyService.createSiteRule(domain, site.$id);
726
+ }
727
+ catch (error) {
728
+ console.error("Error creating site rule.");
729
+ throw error;
730
+ }
731
+ updaterRow.update({ status: "Created" });
732
+ }
733
+ catch (e) {
734
+ errors.push(e);
735
+ updaterRow.fail({
736
+ errorMessage: e.message ?? "General error occurs please try again",
737
+ });
738
+ return;
739
+ }
740
+ }
741
+ if (withVariables) {
742
+ updaterRow
743
+ .update({ status: "Creating variables" })
744
+ .replaceSpinner(SPINNER_DOTS);
745
+ const sitesServiceForVars = await getSitesService(this.projectClient);
746
+ const { variables } = await paginate(async (args) => {
747
+ return await sitesServiceForVars.listVariables({
748
+ siteId: args.siteId,
749
+ });
750
+ }, {
751
+ siteId: site["$id"],
752
+ }, 100, "variables");
753
+ await Promise.all(variables.map(async (variable) => {
754
+ const sitesServiceDel = await getSitesService(this.projectClient);
755
+ await sitesServiceDel.deleteVariable({
756
+ siteId: site["$id"],
757
+ variableId: variable["$id"],
758
+ });
759
+ }));
760
+ const envFileLocation = `${site["path"]}/.env`;
761
+ let envVariables = [];
762
+ try {
763
+ if (fs.existsSync(envFileLocation)) {
764
+ const envObject = parseDotenv(fs.readFileSync(envFileLocation, "utf8"));
765
+ envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
766
+ }
767
+ }
768
+ catch (error) {
769
+ envVariables = [];
770
+ }
771
+ await Promise.all(envVariables.map(async (variable) => {
772
+ const sitesServiceCreate = await getSitesService(this.projectClient);
773
+ await sitesServiceCreate.createVariable({
774
+ siteId: site["$id"],
775
+ key: variable.key,
776
+ value: variable.value,
777
+ secret: false,
778
+ });
779
+ }));
780
+ }
781
+ if (code === false) {
782
+ successfullyPushed++;
783
+ successfullyDeployed++;
784
+ updaterRow.update({ status: "Pushed" });
785
+ updaterRow.stopSpinner();
786
+ return;
787
+ }
788
+ try {
789
+ updaterRow.update({ status: "Pushing" }).replaceSpinner(SPINNER_DOTS);
790
+ const sitesServiceDeploy = await getSitesService(this.projectClient);
791
+ const result = await pushDeployment({
792
+ resourcePath: site.path,
793
+ createDeployment: async (codeFile) => {
794
+ return await sitesServiceDeploy.createDeployment({
795
+ siteId: site["$id"],
796
+ installCommand: site.installCommand,
797
+ buildCommand: site.buildCommand,
798
+ outputDirectory: site.outputDirectory,
799
+ code: codeFile,
800
+ activate: true,
801
+ });
802
+ },
803
+ pollForStatus: false,
804
+ });
805
+ response = result.deployment;
806
+ updaterRow.update({ status: "Pushed" });
807
+ deploymentCreated = true;
808
+ successfullyPushed++;
809
+ }
810
+ catch (e) {
811
+ errors.push(e);
812
+ switch (e.code) {
813
+ case "ENOENT":
814
+ updaterRow.fail({
815
+ errorMessage: "Not found in the current directory. Skipping...",
816
+ });
817
+ break;
818
+ default:
819
+ updaterRow.fail({
820
+ errorMessage: e.message ?? "An unknown error occurred. Please try again.",
821
+ });
822
+ }
823
+ }
824
+ if (deploymentCreated && !asyncDeploy) {
825
+ try {
826
+ const deploymentId = response["$id"];
827
+ updaterRow.update({
828
+ status: "Deploying",
829
+ end: "Checking deployment status...",
830
+ });
831
+ while (true) {
832
+ const sitesServicePoll = await getSitesService(this.projectClient);
833
+ response = await sitesServicePoll.getDeployment({
834
+ siteId: site["$id"],
835
+ deploymentId: deploymentId,
836
+ });
837
+ const status = response["status"];
838
+ if (status === "ready") {
839
+ successfullyDeployed++;
840
+ let url = "";
841
+ const proxyServiceUrl = await getProxyService(this.projectClient);
842
+ const res = await proxyServiceUrl.listRules([
843
+ Query.limit(1),
844
+ Query.equal("deploymentResourceType", "site"),
845
+ Query.equal("deploymentResourceId", site["$id"]),
846
+ Query.equal("trigger", "manual"),
847
+ ]);
848
+ if (Number(res.total) === 1) {
849
+ url = `https://${res.rules[0].domain}`;
850
+ }
851
+ updaterRow.update({ status: "Deployed", end: url });
852
+ break;
853
+ }
854
+ else if (status === "failed") {
855
+ failedDeployments.push({
856
+ name: site["name"],
857
+ $id: site["$id"],
858
+ deployment: response["$id"],
859
+ });
860
+ updaterRow.fail({ errorMessage: `Failed to deploy` });
861
+ break;
862
+ }
863
+ else {
864
+ updaterRow.update({
865
+ status: "Deploying",
866
+ end: `Current status: ${status}`,
867
+ });
868
+ }
869
+ await new Promise((resolve) => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
870
+ }
871
+ }
872
+ catch (e) {
873
+ errors.push(e);
874
+ updaterRow.fail({
875
+ errorMessage: e.message ?? "Unknown error occurred. Please try again",
876
+ });
877
+ }
878
+ }
879
+ updaterRow.stopSpinner();
880
+ }));
881
+ Spinner.stop();
882
+ return {
883
+ successfullyPushed,
884
+ successfullyDeployed,
885
+ failedDeployments,
886
+ errors,
887
+ };
888
+ }
889
+ async pushTables(tables, attempts) {
890
+ const pollMaxDebounces = attempts ?? POLL_DEFAULT_VALUE;
891
+ const pools = new Pools(pollMaxDebounces);
892
+ const attributes = new Attributes(pools);
893
+ let tablesChanged = new Set();
894
+ const errors = [];
895
+ // Parallel tables actions
896
+ await Promise.all(tables.map(async (table) => {
897
+ try {
898
+ const tablesService = await getTablesDBService(this.projectClient);
899
+ const remoteTable = await tablesService.getTable({
900
+ databaseId: table["databaseId"],
901
+ tableId: table["$id"],
902
+ });
903
+ const changes = [];
904
+ if (remoteTable.name !== table.name)
905
+ changes.push("name");
906
+ if (remoteTable.rowSecurity !== table.rowSecurity)
907
+ changes.push("rowSecurity");
908
+ if (remoteTable.enabled !== table.enabled)
909
+ changes.push("enabled");
910
+ if (JSON.stringify(remoteTable["$permissions"]) !==
911
+ JSON.stringify(table["$permissions"]))
912
+ changes.push("permissions");
913
+ if (changes.length > 0) {
914
+ await tablesService.updateTable(table["databaseId"], table["$id"], table.name, table.rowSecurity, table["$permissions"]);
915
+ success(`Updated ${table.name} ( ${table["$id"]} ) - ${changes.join(", ")}`);
916
+ tablesChanged.add(table["$id"]);
917
+ }
918
+ table.remoteVersion = remoteTable;
919
+ table.isExisted = true;
920
+ }
921
+ catch (e) {
922
+ if (Number(e.code) === 404) {
923
+ log(`Table ${table.name} does not exist in the project. Creating ... `);
924
+ const tablesService = await getTablesDBService(this.projectClient);
925
+ await tablesService.createTable(table["databaseId"], table["$id"], table.name, table.rowSecurity, table["$permissions"]);
926
+ success(`Created ${table.name} ( ${table["$id"]} )`);
927
+ tablesChanged.add(table["$id"]);
928
+ }
929
+ else {
930
+ errors.push(e);
931
+ throw e;
932
+ }
933
+ }
934
+ }));
935
+ // Serialize attribute actions
936
+ for (let table of tables) {
937
+ let columns = table.columns;
938
+ let indexes = table.indexes;
939
+ if (table.isExisted) {
940
+ columns = await attributes.attributesToCreate(table.remoteVersion.columns, table.columns, table);
941
+ indexes = await attributes.attributesToCreate(table.remoteVersion.indexes, table.indexes, table, true);
942
+ if (Array.isArray(columns) &&
943
+ columns.length <= 0 &&
944
+ Array.isArray(indexes) &&
945
+ indexes.length <= 0) {
946
+ continue;
947
+ }
948
+ }
949
+ log(`Pushing table ${table.name} ( ${table["databaseId"]} - ${table["$id"]} ) attributes`);
950
+ try {
951
+ await attributes.createColumns(columns, table);
952
+ }
953
+ catch (e) {
954
+ errors.push(e);
955
+ throw e;
956
+ }
957
+ try {
958
+ await attributes.createIndexes(indexes, table);
959
+ }
960
+ catch (e) {
961
+ errors.push(e);
962
+ throw e;
963
+ }
964
+ tablesChanged.add(table["$id"]);
965
+ success(`Successfully pushed ${table.name} ( ${table["$id"]} )`);
966
+ }
967
+ return {
968
+ successfullyPushed: tablesChanged.size,
969
+ errors,
970
+ };
971
+ }
972
+ async pushCollections(collections) {
973
+ const pools = new Pools(POLL_DEFAULT_VALUE);
974
+ const attributes = new Attributes(pools);
975
+ const errors = [];
976
+ const databases = Array.from(new Set(collections.map((collection) => collection["databaseId"])));
977
+ // Parallel db actions
978
+ await Promise.all(databases.map(async (databaseId) => {
979
+ const databasesService = await getDatabasesService(this.projectClient);
980
+ try {
981
+ const database = await databasesService.get(databaseId);
982
+ // Note: We can't get the local database name here since we don't have access to localConfig
983
+ // This will need to be handled by the caller if needed
984
+ const localDatabaseName = collections.find((c) => c.databaseId === databaseId)
985
+ ?.databaseName ?? databaseId;
986
+ if (database.name !== localDatabaseName) {
987
+ await databasesService.update(databaseId, localDatabaseName);
988
+ success(`Updated ${localDatabaseName} ( ${databaseId} ) name`);
989
+ }
990
+ }
991
+ catch (err) {
992
+ log(`Database ${databaseId} not found. Creating it now ...`);
993
+ const localDatabaseName = collections.find((c) => c.databaseId === databaseId)
994
+ ?.databaseName ?? databaseId;
995
+ await databasesService.create(databaseId, localDatabaseName);
996
+ }
997
+ }));
998
+ // Parallel collection actions
999
+ await Promise.all(collections.map(async (collection) => {
1000
+ try {
1001
+ const databasesService = await getDatabasesService(this.projectClient);
1002
+ const remoteCollection = await databasesService.getCollection(collection["databaseId"], collection["$id"]);
1003
+ if (remoteCollection.name !== collection.name) {
1004
+ await databasesService.updateCollection(collection["databaseId"], collection["$id"], collection.name);
1005
+ success(`Updated ${collection.name} ( ${collection["$id"]} ) name`);
1006
+ }
1007
+ collection.remoteVersion = remoteCollection;
1008
+ collection.isExisted = true;
1009
+ }
1010
+ catch (e) {
1011
+ if (Number(e.code) === 404) {
1012
+ log(`Collection ${collection.name} does not exist in the project. Creating ... `);
1013
+ const databasesService = await getDatabasesService(this.projectClient);
1014
+ await databasesService.createCollection(collection["databaseId"], collection["$id"], collection.name, collection.documentSecurity, collection["$permissions"]);
1015
+ }
1016
+ else {
1017
+ errors.push(e);
1018
+ throw e;
1019
+ }
1020
+ }
1021
+ }));
1022
+ let numberOfCollections = 0;
1023
+ // Serialize attribute actions
1024
+ for (let collection of collections) {
1025
+ let collectionAttributes = collection.attributes;
1026
+ let indexes = collection.indexes;
1027
+ if (collection.isExisted) {
1028
+ collectionAttributes = await attributes.attributesToCreate(collection.remoteVersion.attributes, collection.attributes, collection);
1029
+ indexes = await attributes.attributesToCreate(collection.remoteVersion.indexes, collection.indexes, collection, true);
1030
+ if (Array.isArray(collectionAttributes) &&
1031
+ collectionAttributes.length <= 0 &&
1032
+ Array.isArray(indexes) &&
1033
+ indexes.length <= 0) {
1034
+ continue;
1035
+ }
1036
+ }
1037
+ log(`Pushing collection ${collection.name} ( ${collection["databaseId"]} - ${collection["$id"]} ) attributes`);
1038
+ try {
1039
+ await attributes.createAttributes(collectionAttributes, collection);
1040
+ }
1041
+ catch (e) {
1042
+ errors.push(e);
1043
+ throw e;
1044
+ }
1045
+ try {
1046
+ await attributes.createIndexes(indexes, collection);
1047
+ }
1048
+ catch (e) {
1049
+ errors.push(e);
1050
+ throw e;
1051
+ }
1052
+ numberOfCollections++;
1053
+ success(`Successfully pushed ${collection.name} ( ${collection["$id"]} )`);
1054
+ }
1055
+ return {
1056
+ successfullyPushed: numberOfCollections,
1057
+ errors,
1058
+ };
1059
+ }
1060
+ }
1061
+ async function createPushInstance() {
1062
+ const projectClient = await sdkForProject();
1063
+ const consoleClient = await sdkForConsole();
1064
+ return new Push(projectClient, consoleClient);
1065
+ }
1066
+ const pushResources = async ({ skipDeprecated = false, } = {}) => {
1067
+ if (cliConfig.all) {
1068
+ checkDeployConditions(localConfig);
1069
+ const pushInstance = await createPushInstance();
1070
+ const config = localConfig.getProject();
1071
+ await pushInstance.pushResources(config, {
1072
+ skipDeprecated,
1073
+ functionOptions: { code: true, withVariables: false },
1074
+ siteOptions: { code: true, withVariables: false },
1075
+ });
1076
+ }
1077
+ else {
1078
+ const actions = {
1079
+ settings: pushSettings,
1080
+ functions: pushFunction,
1081
+ sites: pushSite,
1082
+ collections: pushCollection,
1083
+ tables: pushTable,
1084
+ buckets: pushBucket,
1085
+ teams: pushTeam,
1086
+ messages: pushMessagingTopic,
1087
+ };
1088
+ if (skipDeprecated) {
1089
+ delete actions.collections;
1090
+ }
1091
+ const answers = await inquirer.prompt(questionsPushResources);
1092
+ const action = actions[answers.resource];
1093
+ if (action !== undefined) {
1094
+ await action();
1095
+ }
1096
+ }
1097
+ };
1098
+ const pushSettings = async () => {
1099
+ checkDeployConditions(localConfig);
1100
+ try {
1101
+ const projectsService = await getProjectsService();
1102
+ let response = await projectsService.get(localConfig.getProject().projectId);
1103
+ const remoteSettings = createSettingsObject(response);
1104
+ const localSettings = localConfig.getProject().projectSettings ?? {};
1105
+ log("Checking for changes ...");
1106
+ const changes = [];
1107
+ changes.push(...getObjectChanges(remoteSettings, localSettings, "services", "Service"));
1108
+ changes.push(...getObjectChanges(remoteSettings["auth"] ?? {}, localSettings["auth"] ?? {}, "methods", "Auth method"));
1109
+ changes.push(...getObjectChanges(remoteSettings["auth"] ?? {}, localSettings["auth"] ?? {}, "security", "Auth security"));
1110
+ if (changes.length > 0) {
1111
+ drawTable(changes);
1112
+ if ((await getConfirmation()) !== true) {
1113
+ success(`Successfully pushed 0 project settings.`);
1114
+ return;
1115
+ }
1116
+ }
1117
+ }
1118
+ catch (e) { }
1119
+ try {
1120
+ log("Pushing project settings ...");
1121
+ const pushInstance = await createPushInstance();
1122
+ const config = localConfig.getProject();
1123
+ const settings = config.projectSettings ?? {};
1124
+ if (config.projectName) {
1125
+ log("Applying project name ...");
1126
+ }
1127
+ if (settings.services) {
1128
+ log("Applying service statuses ...");
1129
+ }
1130
+ if (settings.auth) {
1131
+ if (settings.auth.security) {
1132
+ log("Applying auth security settings ...");
1133
+ }
1134
+ if (settings.auth.methods) {
1135
+ log("Applying auth methods statuses ...");
1136
+ }
1137
+ }
1138
+ await pushInstance.pushSettings({
1139
+ projectId: config.projectId,
1140
+ projectName: config.projectName,
1141
+ settings: config.projectSettings,
1142
+ });
1143
+ success(`Successfully pushed ${chalk.bold("all")} project settings.`);
1144
+ }
1145
+ catch (e) {
1146
+ throw e;
1147
+ }
1148
+ };
1149
+ const pushSite = async ({ siteId, async: asyncDeploy, code, withVariables, } = {}) => {
1150
+ process.chdir(localConfig.configDirectoryPath);
1151
+ const siteIds = [];
1152
+ if (siteId) {
1153
+ siteIds.push(siteId);
1154
+ }
1155
+ else if (cliConfig.all) {
1156
+ checkDeployConditions(localConfig);
1157
+ const sites = localConfig.getSites();
1158
+ siteIds.push(...sites.map((site) => {
1159
+ return site.$id;
1160
+ }));
1161
+ }
1162
+ if (siteIds.length <= 0) {
1163
+ const answers = await inquirer.prompt(questionsPushSites);
1164
+ if (answers.sites) {
1165
+ siteIds.push(...answers.sites);
1166
+ }
1167
+ }
1168
+ if (siteIds.length === 0) {
1169
+ log("No sites found.");
1170
+ hint("Use 'appwrite pull sites' to synchronize existing one, or use 'appwrite init site' to create a new one.");
1171
+ return;
1172
+ }
1173
+ let sites = siteIds.map((id) => {
1174
+ const sites = localConfig.getSites();
1175
+ const site = sites.find((s) => s.$id === id);
1176
+ if (!site) {
1177
+ throw new Error("Site '" + id + "' not found.");
1178
+ }
1179
+ return site;
1180
+ });
1181
+ log("Validating sites ...");
1182
+ // Validation is done BEFORE pushing so the deployment process can be run in async with progress update
1183
+ for (let site of sites) {
1184
+ if (!site.buildCommand) {
1185
+ log(`Site ${site.name} is missing build command.`);
1186
+ const answers = await inquirer.prompt(questionsGetEntrypoint);
1187
+ site.buildCommand = answers.entrypoint;
1188
+ localConfig.addSite(site);
1189
+ }
1190
+ }
1191
+ if (!(await approveChanges(sites, async (args) => {
1192
+ const sitesService = await getSitesService();
1193
+ return await sitesService.get({ siteId: args.siteId });
1194
+ }, KeysSite, "siteId", "sites", ["vars"]))) {
1195
+ return;
1196
+ }
1197
+ log("Pushing sites ...");
1198
+ const pushInstance = await createPushInstance();
1199
+ const result = await pushInstance.pushSites(sites, {
1200
+ async: asyncDeploy,
1201
+ code,
1202
+ withVariables,
1203
+ });
1204
+ const { successfullyPushed, successfullyDeployed, failedDeployments, errors, } = result;
1205
+ failedDeployments.forEach((failed) => {
1206
+ const { name, deployment, $id } = failed;
1207
+ const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/sites/site-${$id}/deployments/deployment-${deployment}`;
1208
+ error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1209
+ });
1210
+ if (!asyncDeploy) {
1211
+ if (successfullyPushed === 0) {
1212
+ error("No sites were pushed.");
1213
+ }
1214
+ else if (successfullyDeployed !== successfullyPushed) {
1215
+ warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} sites`);
1216
+ }
1217
+ else {
1218
+ success(`Successfully pushed ${successfullyPushed} sites.`);
1219
+ }
1220
+ }
1221
+ else {
1222
+ success(`Successfully pushed ${successfullyPushed} sites.`);
1223
+ }
1224
+ if (cliConfig.verbose) {
1225
+ errors.forEach((e) => {
1226
+ console.error(e);
1227
+ });
1228
+ }
1229
+ };
1230
+ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariables, } = {}) => {
1231
+ process.chdir(localConfig.configDirectoryPath);
1232
+ const functionIds = [];
1233
+ if (functionId) {
1234
+ functionIds.push(functionId);
1235
+ }
1236
+ else if (cliConfig.all) {
1237
+ checkDeployConditions(localConfig);
1238
+ const functions = localConfig.getFunctions();
1239
+ functionIds.push(...functions.map((func) => {
1240
+ return func.$id;
1241
+ }));
1242
+ }
1243
+ if (functionIds.length <= 0) {
1244
+ const answers = await inquirer.prompt(questionsPushFunctions);
1245
+ if (answers.functions) {
1246
+ functionIds.push(...answers.functions);
1247
+ }
1248
+ }
1249
+ if (functionIds.length === 0) {
1250
+ log("No functions found.");
1251
+ hint("Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
1252
+ return;
1253
+ }
1254
+ let functions = functionIds.map((id) => {
1255
+ const functions = localConfig.getFunctions();
1256
+ const func = functions.find((f) => f.$id === id);
1257
+ if (!func) {
1258
+ throw new Error("Function '" + id + "' not found.");
1259
+ }
1260
+ return func;
1261
+ });
1262
+ log("Validating functions ...");
1263
+ for (let func of functions) {
1264
+ if (!func.entrypoint) {
1265
+ log(`Function ${func.name} is missing an entrypoint.`);
1266
+ const answers = await inquirer.prompt(questionsGetEntrypoint);
1267
+ func.entrypoint = answers.entrypoint;
1268
+ localConfig.addFunction(func);
1269
+ }
1270
+ }
1271
+ if (!(await approveChanges(functions, async (args) => {
1272
+ const functionsService = await getFunctionsService();
1273
+ return await functionsService.get({ functionId: args.functionId });
1274
+ }, KeysFunction, "functionId", "functions", ["vars"]))) {
1275
+ return;
1276
+ }
1277
+ log("Pushing functions ...");
1278
+ const pushInstance = await createPushInstance();
1279
+ const result = await pushInstance.pushFunctions(functions, {
1280
+ async: asyncDeploy,
1281
+ code,
1282
+ withVariables,
1283
+ });
1284
+ const { successfullyPushed, successfullyDeployed, failedDeployments, errors, } = result;
1285
+ failedDeployments.forEach((failed) => {
1286
+ const { name, deployment, $id } = failed;
1287
+ const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
1288
+ error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1289
+ });
1290
+ if (!asyncDeploy) {
1291
+ if (successfullyPushed === 0) {
1292
+ error("No functions were pushed.");
1293
+ }
1294
+ else if (successfullyDeployed !== successfullyPushed) {
1295
+ warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} functions`);
1296
+ }
1297
+ else {
1298
+ success(`Successfully pushed ${successfullyPushed} functions.`);
1299
+ }
1300
+ }
1301
+ else {
1302
+ success(`Successfully pushed ${successfullyPushed} functions.`);
1303
+ }
1304
+ if (cliConfig.verbose) {
1305
+ errors.forEach((e) => {
1306
+ console.error(e);
1307
+ });
1308
+ }
1309
+ };
1310
+ const pushTable = async ({ attempts, } = {}) => {
1311
+ const tables = [];
1312
+ const { resyncNeeded } = await checkAndApplyTablesDBChanges();
1313
+ if (resyncNeeded) {
1314
+ log("Resyncing configuration due to tables deletions ...");
1315
+ const remoteTablesDBs = (await paginate(async (args) => {
1316
+ const tablesService = await getTablesDBService();
1317
+ return await tablesService.list(args.queries || []);
1318
+ }, {}, 100, "databases")).databases;
1319
+ const localTablesDBs = localConfig.getTablesDBs();
1320
+ const remoteDatabaseIds = new Set(remoteTablesDBs.map((db) => db.$id));
1321
+ const localTables = localConfig.getTables();
1322
+ const validTables = localTables.filter((table) => remoteDatabaseIds.has(table.databaseId));
1323
+ localConfig.set("tables", validTables);
1324
+ const validTablesDBs = localTablesDBs.filter((db) => remoteDatabaseIds.has(db.$id));
1325
+ localConfig.set("tables", validTablesDBs);
1326
+ success("Configuration resynced successfully.");
1327
+ console.log();
1328
+ }
1329
+ log("Checking for deleted tables ...");
1330
+ const localTablesDBs = localConfig.getTablesDBs();
1331
+ const localTables = localConfig.getTables();
1332
+ const tablesToDelete = [];
1333
+ for (const db of localTablesDBs) {
1334
+ try {
1335
+ const { tables: remoteTables } = await paginate(async (args) => {
1336
+ const tablesService = await getTablesDBService();
1337
+ return await tablesService.listTables(args.databaseId, args.queries || []);
1338
+ }, {
1339
+ databaseId: db.$id,
1340
+ }, 100, "tables");
1341
+ for (const remoteTable of remoteTables) {
1342
+ const localTable = localTables.find((t) => t.$id === remoteTable.$id && t.databaseId === db.$id);
1343
+ if (!localTable) {
1344
+ tablesToDelete.push({
1345
+ ...remoteTable,
1346
+ databaseId: db.$id,
1347
+ databaseName: db.name,
1348
+ });
1349
+ }
1350
+ }
1351
+ }
1352
+ catch (e) {
1353
+ // Skip if database doesn't exist or other errors
1354
+ }
1355
+ }
1356
+ if (tablesToDelete.length > 0) {
1357
+ log("Found tables that exist remotely but not locally:");
1358
+ const deletionChanges = tablesToDelete.map((table) => ({
1359
+ id: table.$id,
1360
+ action: chalk.red("deleting"),
1361
+ key: "Table",
1362
+ database: table.databaseName,
1363
+ remote: table.name,
1364
+ local: "(deleted locally)",
1365
+ }));
1366
+ drawTable(deletionChanges);
1367
+ if ((await getConfirmation()) === true) {
1368
+ for (const table of tablesToDelete) {
1369
+ try {
1370
+ log(`Deleting table ${table.name} ( ${table.$id} ) from database ${table.databaseName} ...`);
1371
+ const tablesService = await getTablesDBService();
1372
+ await tablesService.deleteTable(table.databaseId, table.$id);
1373
+ success(`Deleted ${table.name} ( ${table.$id} )`);
1374
+ }
1375
+ catch (e) {
1376
+ error(`Failed to delete table ${table.name} ( ${table.$id} ): ${e.message}`);
1377
+ }
1378
+ }
1379
+ }
1380
+ }
1381
+ if (cliConfig.all) {
1382
+ checkDeployConditions(localConfig);
1383
+ tables.push(...localConfig.getTables());
1384
+ }
1385
+ else {
1386
+ const answers = await inquirer.prompt(questionsPushTables);
1387
+ if (answers.tables) {
1388
+ const configTables = new Map();
1389
+ localConfig.getTables().forEach((c) => {
1390
+ configTables.set(`${c["databaseId"]}|${c["$id"]}`, c);
1391
+ });
1392
+ answers.tables.forEach((a) => {
1393
+ const table = configTables.get(a);
1394
+ tables.push(table);
1395
+ });
1396
+ }
1397
+ }
1398
+ if (tables.length === 0) {
1399
+ log("No tables found.");
1400
+ hint("Use 'appwrite pull tables' to synchronize existing one, or use 'appwrite init table' to create a new one.");
1401
+ return;
1402
+ }
1403
+ if (!(await approveChanges(tables, async (args) => {
1404
+ const tablesService = await getTablesDBService();
1405
+ return await tablesService.getTable(args.databaseId, args.tableId);
1406
+ }, KeysTable, "tableId", "tables", ["columns", "indexes"], "databaseId", "databaseId"))) {
1407
+ return;
1408
+ }
1409
+ log("Pushing tables ...");
1410
+ const pushInstance = await createPushInstance();
1411
+ const result = await pushInstance.pushTables(tables, attempts);
1412
+ const { successfullyPushed, errors } = result;
1413
+ if (successfullyPushed === 0) {
1414
+ error("No tables were pushed.");
1415
+ }
1416
+ else {
1417
+ success(`Successfully pushed ${successfullyPushed} tables.`);
1418
+ }
1419
+ if (cliConfig.verbose) {
1420
+ errors.forEach((e) => console.error(e));
1421
+ }
1422
+ };
1423
+ const pushCollection = async ({} = {}) => {
1424
+ warn("appwrite push collection has been deprecated. Please consider using 'appwrite push tables' instead");
1425
+ const collections = [];
1426
+ if (cliConfig.all) {
1427
+ checkDeployConditions(localConfig);
1428
+ collections.push(...localConfig.getCollections());
1429
+ }
1430
+ else {
1431
+ const answers = await inquirer.prompt(questionsPushCollections);
1432
+ if (answers.collections) {
1433
+ const configCollections = new Map();
1434
+ localConfig.getCollections().forEach((c) => {
1435
+ configCollections.set(`${c["databaseId"]}|${c["$id"]}`, c);
1436
+ });
1437
+ answers.collections.forEach((a) => {
1438
+ const collection = configCollections.get(a);
1439
+ collections.push(collection);
1440
+ });
1441
+ }
1442
+ }
1443
+ if (collections.length === 0) {
1444
+ log("No collections found.");
1445
+ hint("Use 'appwrite pull collections' to synchronize existing one, or use 'appwrite init collection' to create a new one.");
1446
+ return;
1447
+ }
1448
+ // Add database names to collections for the class method
1449
+ collections.forEach((collection) => {
1450
+ const localDatabase = localConfig.getDatabase(collection.databaseId);
1451
+ collection.databaseName = localDatabase.name ?? collection.databaseId;
1452
+ });
1453
+ if (!(await approveChanges(collections, async (args) => {
1454
+ const databasesService = await getDatabasesService();
1455
+ return await databasesService.getCollection(args.databaseId, args.collectionId);
1456
+ }, KeysCollection, "collectionId", "collections", ["attributes", "indexes"], "databaseId", "databaseId"))) {
1457
+ return;
1458
+ }
1459
+ log("Pushing collections ...");
1460
+ const pushInstance = await createPushInstance();
1461
+ const result = await pushInstance.pushCollections(collections);
1462
+ const { successfullyPushed, errors } = result;
1463
+ if (successfullyPushed === 0) {
1464
+ error("No collections were pushed.");
1465
+ }
1466
+ else {
1467
+ success(`Successfully pushed ${successfullyPushed} collections.`);
1468
+ }
1469
+ if (cliConfig.verbose) {
1470
+ errors.forEach((e) => console.error(e));
1471
+ }
1472
+ };
1473
+ const pushBucket = async () => {
1474
+ let bucketIds = [];
1475
+ const configBuckets = localConfig.getBuckets();
1476
+ if (cliConfig.all) {
1477
+ checkDeployConditions(localConfig);
1478
+ bucketIds.push(...configBuckets.map((b) => b.$id));
1479
+ }
1480
+ if (bucketIds.length === 0) {
1481
+ const answers = await inquirer.prompt(questionsPushBuckets);
1482
+ if (answers.buckets) {
1483
+ bucketIds.push(...answers.buckets);
1484
+ }
1485
+ }
1486
+ if (bucketIds.length === 0) {
1487
+ log("No buckets found.");
1488
+ hint("Use 'appwrite pull buckets' to synchronize existing one, or use 'appwrite init bucket' to create a new one.");
1489
+ return;
1490
+ }
1491
+ let buckets = [];
1492
+ for (const bucketId of bucketIds) {
1493
+ const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
1494
+ buckets.push(...idBuckets);
1495
+ }
1496
+ if (!(await approveChanges(buckets, async (args) => {
1497
+ const storageService = await getStorageService();
1498
+ return await storageService.getBucket(args.bucketId);
1499
+ }, KeysStorage, "bucketId", "buckets"))) {
1500
+ return;
1501
+ }
1502
+ log("Pushing buckets ...");
1503
+ const pushInstance = await createPushInstance();
1504
+ const result = await pushInstance.pushBuckets(buckets);
1505
+ const { successfullyPushed, errors } = result;
1506
+ if (successfullyPushed === 0) {
1507
+ error("No buckets were pushed.");
1508
+ }
1509
+ else {
1510
+ success(`Successfully pushed ${successfullyPushed} buckets.`);
1511
+ }
1512
+ if (cliConfig.verbose) {
1513
+ errors.forEach((e) => console.error(e));
1514
+ }
1515
+ };
1516
+ const pushTeam = async () => {
1517
+ let teamIds = [];
1518
+ const configTeams = localConfig.getTeams();
1519
+ if (cliConfig.all) {
1520
+ checkDeployConditions(localConfig);
1521
+ teamIds.push(...configTeams.map((t) => t.$id));
1522
+ }
1523
+ if (teamIds.length === 0) {
1524
+ const answers = await inquirer.prompt(questionsPushTeams);
1525
+ if (answers.teams) {
1526
+ teamIds.push(...answers.teams);
1527
+ }
1528
+ }
1529
+ if (teamIds.length === 0) {
1530
+ log("No teams found.");
1531
+ hint("Use 'appwrite pull teams' to synchronize existing one, or use 'appwrite init team' to create a new one.");
1532
+ return;
1533
+ }
1534
+ let teams = [];
1535
+ for (const teamId of teamIds) {
1536
+ const idTeams = configTeams.filter((t) => t.$id === teamId);
1537
+ teams.push(...idTeams);
1538
+ }
1539
+ if (!(await approveChanges(teams, async (args) => {
1540
+ const teamsService = await getTeamsService();
1541
+ return await teamsService.get(args.teamId);
1542
+ }, KeysTeams, "teamId", "teams"))) {
1543
+ return;
1544
+ }
1545
+ log("Pushing teams ...");
1546
+ const pushInstance = await createPushInstance();
1547
+ const result = await pushInstance.pushTeams(teams);
1548
+ const { successfullyPushed, errors } = result;
1549
+ if (successfullyPushed === 0) {
1550
+ error("No teams were pushed.");
1551
+ }
1552
+ else {
1553
+ success(`Successfully pushed ${successfullyPushed} teams.`);
1554
+ }
1555
+ if (cliConfig.verbose) {
1556
+ errors.forEach((e) => console.error(e));
1557
+ }
1558
+ };
1559
+ const pushMessagingTopic = async () => {
1560
+ let topicsIds = [];
1561
+ const configTopics = localConfig.getMessagingTopics();
1562
+ if (cliConfig.all) {
1563
+ checkDeployConditions(localConfig);
1564
+ topicsIds.push(...configTopics.map((b) => b.$id));
1565
+ }
1566
+ if (topicsIds.length === 0) {
1567
+ const answers = await inquirer.prompt(questionsPushMessagingTopics);
1568
+ if (answers.topics) {
1569
+ topicsIds.push(...answers.topics);
1570
+ }
1571
+ }
1572
+ if (topicsIds.length === 0) {
1573
+ log("No topics found.");
1574
+ hint("Use 'appwrite pull topics' to synchronize existing one, or use 'appwrite init topic' to create a new one.");
1575
+ return;
1576
+ }
1577
+ let topics = [];
1578
+ for (const topicId of topicsIds) {
1579
+ const idTopic = configTopics.filter((b) => b.$id === topicId);
1580
+ topics.push(...idTopic);
1581
+ }
1582
+ if (!(await approveChanges(topics, async (args) => {
1583
+ const messagingService = await getMessagingService();
1584
+ return await messagingService.getTopic(args.topicId);
1585
+ }, KeysTopics, "topicId", "topics"))) {
1586
+ return;
1587
+ }
1588
+ log("Pushing topics ...");
1589
+ const pushInstance = await createPushInstance();
1590
+ const result = await pushInstance.pushMessagingTopics(topics);
1591
+ const { successfullyPushed, errors } = result;
1592
+ if (successfullyPushed === 0) {
1593
+ error("No topics were pushed.");
1594
+ }
1595
+ else {
1596
+ success(`Successfully pushed ${successfullyPushed} topics.`);
1597
+ }
1598
+ if (cliConfig.verbose) {
1599
+ errors.forEach((e) => console.error(e));
1600
+ }
1601
+ };
1602
+ export const push = new Command("push")
1603
+ .description(commandDescriptions["push"])
1604
+ .action(actionRunner(() => pushResources({ skipDeprecated: true })));
1605
+ push
1606
+ .command("all")
1607
+ .description("Push all resource.")
1608
+ .action(actionRunner(() => {
1609
+ cliConfig.all = true;
1610
+ return pushResources({ skipDeprecated: true });
1611
+ }));
1612
+ push
1613
+ .command("settings")
1614
+ .description("Push project name, services and auth settings")
1615
+ .action(actionRunner(pushSettings));
1616
+ push
1617
+ .command("function")
1618
+ .alias("functions")
1619
+ .description("Push functions in the current directory.")
1620
+ .option(`-f, --function-id <function-id>`, `ID of function to run`)
1621
+ .option(`-A, --async`, `Don't wait for functions deployments status`)
1622
+ .option("--no-code", "Don't push the function's code")
1623
+ .option("--with-variables", `Push function variables.`)
1624
+ .action(actionRunner(pushFunction));
1625
+ push
1626
+ .command("site")
1627
+ .alias("sites")
1628
+ .description("Push sites in the current directory.")
1629
+ .option(`-f, --site-id <site-id>`, `ID of site to run`)
1630
+ .option(`-A, --async`, `Don't wait for sites deployments status`)
1631
+ .option("--no-code", "Don't push the site's code")
1632
+ .option("--with-variables", `Push site variables.`)
1633
+ .action(actionRunner(pushSite));
1634
+ push
1635
+ .command("collection")
1636
+ .alias("collections")
1637
+ .description("Push collections in the current project. (deprecated, please use 'push tables' instead)")
1638
+ .option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
1639
+ .action(actionRunner(pushCollection));
1640
+ push
1641
+ .command("table")
1642
+ .alias("tables")
1643
+ .description("Push tables in the current project.")
1644
+ .option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
1645
+ .action(actionRunner(pushTable));
1646
+ push
1647
+ .command("bucket")
1648
+ .alias("buckets")
1649
+ .description("Push buckets in the current project.")
1650
+ .action(actionRunner(pushBucket));
1651
+ push
1652
+ .command("team")
1653
+ .alias("teams")
1654
+ .description("Push teams in the current project.")
1655
+ .action(actionRunner(pushTeam));
1656
+ push
1657
+ .command("topic")
1658
+ .alias("topics")
1659
+ .description("Push messaging topics in the current project.")
1660
+ .action(actionRunner(pushMessagingTopic));
1661
+ export const deploy = new Command("deploy")
1662
+ .description("Removed. Use appwrite push instead")
1663
+ .action(actionRunner(async () => {
1664
+ warn("appwrite deploy has been removed. Please use 'appwrite push' instead");
1665
+ }));
1666
+ //# sourceMappingURL=push.js.map