appwrite-cli 12.0.1 → 13.0.0-rc.2

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 (801) hide show
  1. package/.github/workflows/build-verify.yml +71 -0
  2. package/.github/workflows/npm-publish.yml +41 -22
  3. package/CHANGELOG.md +108 -100
  4. package/LICENSE.md +1 -1
  5. package/README.md +58 -35
  6. package/bun.lock +625 -0
  7. package/dist/bundle.cjs +94853 -0
  8. package/dist/index.d.ts +3 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +145 -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/generic.d.ts +17 -0
  17. package/dist/lib/commands/generic.d.ts.map +1 -0
  18. package/dist/lib/commands/generic.js +292 -0
  19. package/dist/lib/commands/generic.js.map +1 -0
  20. package/dist/lib/commands/init.d.ts +3 -0
  21. package/dist/lib/commands/init.d.ts.map +1 -0
  22. package/{lib → dist/lib}/commands/init.js +186 -270
  23. package/dist/lib/commands/init.js.map +1 -0
  24. package/dist/lib/commands/pull.d.ts +8 -0
  25. package/dist/lib/commands/pull.d.ts.map +1 -0
  26. package/{lib → dist/lib}/commands/pull.js +159 -280
  27. package/dist/lib/commands/pull.js.map +1 -0
  28. package/dist/lib/commands/push.d.ts +4 -0
  29. package/dist/lib/commands/push.d.ts.map +1 -0
  30. package/dist/lib/commands/push.js +2127 -0
  31. package/dist/lib/commands/push.js.map +1 -0
  32. package/dist/lib/commands/run.d.ts +3 -0
  33. package/dist/lib/commands/run.d.ts.map +1 -0
  34. package/{lib → dist/lib}/commands/run.js +146 -187
  35. package/dist/lib/commands/run.js.map +1 -0
  36. package/dist/lib/commands/services/account.d.ts +3 -0
  37. package/dist/lib/commands/services/account.d.ts.map +1 -0
  38. package/dist/lib/commands/services/account.js +306 -0
  39. package/dist/lib/commands/services/account.js.map +1 -0
  40. package/dist/lib/commands/services/avatars.d.ts +3 -0
  41. package/dist/lib/commands/services/avatars.d.ts.map +1 -0
  42. package/dist/lib/commands/services/avatars.js +118 -0
  43. package/dist/lib/commands/services/avatars.js.map +1 -0
  44. package/dist/lib/commands/services/console.d.ts +3 -0
  45. package/dist/lib/commands/services/console.d.ts.map +1 -0
  46. package/dist/lib/commands/services/console.js +41 -0
  47. package/dist/lib/commands/services/console.js.map +1 -0
  48. package/dist/lib/commands/services/databases.d.ts +3 -0
  49. package/dist/lib/commands/services/databases.d.ts.map +1 -0
  50. package/dist/lib/commands/services/databases.js +612 -0
  51. package/dist/lib/commands/services/databases.js.map +1 -0
  52. package/dist/lib/commands/services/functions.d.ts +3 -0
  53. package/dist/lib/commands/services/functions.d.ts.map +1 -0
  54. package/dist/lib/commands/services/functions.js +258 -0
  55. package/dist/lib/commands/services/functions.js.map +1 -0
  56. package/dist/lib/commands/services/graphql.d.ts +3 -0
  57. package/dist/lib/commands/services/graphql.d.ts.map +1 -0
  58. package/dist/lib/commands/services/graphql.js +28 -0
  59. package/dist/lib/commands/services/graphql.js.map +1 -0
  60. package/dist/lib/commands/services/health.d.ts +3 -0
  61. package/dist/lib/commands/services/health.d.ts.map +1 -0
  62. package/dist/lib/commands/services/health.js +123 -0
  63. package/dist/lib/commands/services/health.js.map +1 -0
  64. package/dist/lib/commands/services/locale.d.ts +3 -0
  65. package/dist/lib/commands/services/locale.d.ts.map +1 -0
  66. package/dist/lib/commands/services/locale.js +52 -0
  67. package/dist/lib/commands/services/locale.js.map +1 -0
  68. package/dist/lib/commands/services/messaging.d.ts +3 -0
  69. package/dist/lib/commands/services/messaging.d.ts.map +1 -0
  70. package/dist/lib/commands/services/messaging.js +505 -0
  71. package/dist/lib/commands/services/messaging.js.map +1 -0
  72. package/dist/lib/commands/services/migrations.d.ts +3 -0
  73. package/dist/lib/commands/services/migrations.d.ts.map +1 -0
  74. package/dist/lib/commands/services/migrations.js +135 -0
  75. package/dist/lib/commands/services/migrations.js.map +1 -0
  76. package/dist/lib/commands/services/project.d.ts +3 -0
  77. package/dist/lib/commands/services/project.d.ts.map +1 -0
  78. package/dist/lib/commands/services/project.js +54 -0
  79. package/dist/lib/commands/services/project.js.map +1 -0
  80. package/dist/lib/commands/services/projects.d.ts +3 -0
  81. package/dist/lib/commands/services/projects.d.ts.map +1 -0
  82. package/dist/lib/commands/services/projects.js +415 -0
  83. package/dist/lib/commands/services/projects.js.map +1 -0
  84. package/dist/lib/commands/services/proxy.d.ts +3 -0
  85. package/dist/lib/commands/services/proxy.d.ts.map +1 -0
  86. package/dist/lib/commands/services/proxy.js +68 -0
  87. package/dist/lib/commands/services/proxy.js.map +1 -0
  88. package/dist/lib/commands/services/sites.d.ts +3 -0
  89. package/dist/lib/commands/services/sites.d.ts.map +1 -0
  90. package/dist/lib/commands/services/sites.js +242 -0
  91. package/dist/lib/commands/services/sites.js.map +1 -0
  92. package/dist/lib/commands/services/storage.d.ts +3 -0
  93. package/dist/lib/commands/services/storage.d.ts.map +1 -0
  94. package/dist/lib/commands/services/storage.js +153 -0
  95. package/dist/lib/commands/services/storage.js.map +1 -0
  96. package/dist/lib/commands/services/tablesdb.d.ts +3 -0
  97. package/dist/lib/commands/services/tablesdb.d.ts.map +1 -0
  98. package/dist/lib/commands/services/tablesdb.js +605 -0
  99. package/dist/lib/commands/services/tablesdb.js.map +1 -0
  100. package/dist/lib/commands/services/teams.d.ts +3 -0
  101. package/dist/lib/commands/services/teams.d.ts.map +1 -0
  102. package/dist/lib/commands/services/teams.js +123 -0
  103. package/dist/lib/commands/services/teams.js.map +1 -0
  104. package/dist/lib/commands/services/tokens.d.ts +3 -0
  105. package/dist/lib/commands/services/tokens.d.ts.map +1 -0
  106. package/dist/lib/commands/services/tokens.js +49 -0
  107. package/dist/lib/commands/services/tokens.js.map +1 -0
  108. package/dist/lib/commands/services/users.d.ts +3 -0
  109. package/dist/lib/commands/services/users.d.ts.map +1 -0
  110. package/dist/lib/commands/services/users.js +312 -0
  111. package/dist/lib/commands/services/users.js.map +1 -0
  112. package/dist/lib/commands/services/vcs.d.ts +3 -0
  113. package/dist/lib/commands/services/vcs.d.ts.map +1 -0
  114. package/dist/lib/commands/services/vcs.js +87 -0
  115. package/dist/lib/commands/services/vcs.js.map +1 -0
  116. package/dist/lib/commands/types.d.ts +3 -0
  117. package/dist/lib/commands/types.d.ts.map +1 -0
  118. package/dist/lib/commands/types.js +151 -0
  119. package/dist/lib/commands/types.js.map +1 -0
  120. package/dist/lib/commands/update.d.ts +3 -0
  121. package/dist/lib/commands/update.d.ts.map +1 -0
  122. package/{lib → dist/lib}/commands/update.js +62 -79
  123. package/dist/lib/commands/update.js.map +1 -0
  124. package/dist/lib/config.d.ts +118 -0
  125. package/dist/lib/config.d.ts.map +1 -0
  126. package/{lib → dist/lib}/config.js +173 -232
  127. package/dist/lib/config.js.map +1 -0
  128. package/dist/lib/emulation/docker.d.ts +7 -0
  129. package/dist/lib/emulation/docker.d.ts.map +1 -0
  130. package/dist/lib/emulation/docker.js +224 -0
  131. package/dist/lib/emulation/docker.js.map +1 -0
  132. package/dist/lib/emulation/utils.d.ts +29 -0
  133. package/dist/lib/emulation/utils.d.ts.map +1 -0
  134. package/{lib → dist/lib}/emulation/utils.js +70 -91
  135. package/dist/lib/emulation/utils.js.map +1 -0
  136. package/dist/lib/id.d.ts +7 -0
  137. package/dist/lib/id.d.ts.map +1 -0
  138. package/{lib → dist/lib}/id.js +5 -8
  139. package/dist/lib/id.js.map +1 -0
  140. package/dist/lib/paginate.d.ts +9 -0
  141. package/dist/lib/paginate.d.ts.map +1 -0
  142. package/{lib → dist/lib}/paginate.js +10 -19
  143. package/dist/lib/paginate.js.map +1 -0
  144. package/dist/lib/parser.d.ts +18 -0
  145. package/dist/lib/parser.d.ts.map +1 -0
  146. package/dist/lib/parser.js +225 -0
  147. package/dist/lib/parser.js.map +1 -0
  148. package/dist/lib/questions.d.ts +59 -0
  149. package/dist/lib/questions.d.ts.map +1 -0
  150. package/{lib → dist/lib}/questions.js +393 -500
  151. package/dist/lib/questions.js.map +1 -0
  152. package/dist/lib/sdks.d.ts +4 -0
  153. package/dist/lib/sdks.d.ts.map +1 -0
  154. package/dist/lib/sdks.js +61 -0
  155. package/dist/lib/sdks.js.map +1 -0
  156. package/dist/lib/services.d.ts +13 -0
  157. package/dist/lib/services.d.ts.map +1 -0
  158. package/dist/lib/services.js +47 -0
  159. package/dist/lib/services.js.map +1 -0
  160. package/dist/lib/spinner.d.ts +28 -0
  161. package/dist/lib/spinner.d.ts.map +1 -0
  162. package/dist/lib/spinner.js +91 -0
  163. package/dist/lib/spinner.js.map +1 -0
  164. package/dist/lib/type-generation/attribute.d.ts +17 -0
  165. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  166. package/{lib → dist/lib}/type-generation/attribute.js +2 -5
  167. package/dist/lib/type-generation/attribute.js.map +1 -0
  168. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  169. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  170. package/dist/lib/type-generation/languages/csharp.js +180 -0
  171. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  172. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  173. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  174. package/dist/lib/type-generation/languages/dart.js +197 -0
  175. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  176. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  177. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  178. package/dist/lib/type-generation/languages/java.js +140 -0
  179. package/dist/lib/type-generation/languages/java.js.map +1 -0
  180. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  181. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  182. package/dist/lib/type-generation/languages/javascript.js +109 -0
  183. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  184. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  185. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  186. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  187. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  188. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  189. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  190. package/dist/lib/type-generation/languages/language.js +77 -0
  191. package/dist/lib/type-generation/languages/language.js.map +1 -0
  192. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  193. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  194. package/dist/lib/type-generation/languages/php.js +116 -0
  195. package/dist/lib/type-generation/languages/php.js.map +1 -0
  196. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  197. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  198. package/dist/lib/type-generation/languages/swift.js +179 -0
  199. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  200. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  201. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  202. package/dist/lib/type-generation/languages/typescript.js +115 -0
  203. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  204. package/dist/lib/types.d.ts +277 -0
  205. package/dist/lib/types.d.ts.map +1 -0
  206. package/dist/lib/types.js +2 -0
  207. package/dist/lib/types.js.map +1 -0
  208. package/dist/lib/utils.d.ts +15 -0
  209. package/dist/lib/utils.d.ts.map +1 -0
  210. package/{lib → dist/lib}/utils.js +125 -167
  211. package/dist/lib/utils.js.map +1 -0
  212. package/dist/lib/validations.d.ts +2 -0
  213. package/dist/lib/validations.d.ts.map +1 -0
  214. package/dist/lib/validations.js +16 -0
  215. package/dist/lib/validations.js.map +1 -0
  216. package/dist/package.json +67 -0
  217. package/dist/scripts/generate-commands.d.ts +2 -0
  218. package/dist/scripts/generate-commands.d.ts.map +1 -0
  219. package/dist/scripts/generate-commands.js +398 -0
  220. package/dist/scripts/generate-commands.js.map +1 -0
  221. package/index.ts +168 -0
  222. package/install.ps1 +2 -5
  223. package/install.sh +1 -2
  224. package/lib/client.ts +292 -0
  225. package/lib/commands/generic.ts +440 -0
  226. package/lib/commands/init.ts +713 -0
  227. package/lib/commands/pull.ts +668 -0
  228. package/lib/commands/push.ts +3183 -0
  229. package/lib/commands/run.ts +416 -0
  230. package/lib/commands/services/account.ts +832 -0
  231. package/lib/commands/services/avatars.ts +400 -0
  232. package/lib/commands/services/console.ts +73 -0
  233. package/lib/commands/services/databases.ts +2080 -0
  234. package/lib/commands/services/functions.ts +855 -0
  235. package/lib/commands/services/graphql.ts +47 -0
  236. package/lib/commands/services/health.ts +322 -0
  237. package/lib/commands/services/locale.ts +99 -0
  238. package/lib/commands/services/messaging.ts +1871 -0
  239. package/lib/commands/services/migrations.ts +421 -0
  240. package/lib/commands/services/project.ts +116 -0
  241. package/lib/commands/services/projects.ts +1317 -0
  242. package/lib/commands/services/proxy.ts +163 -0
  243. package/lib/commands/services/sites.ts +777 -0
  244. package/lib/commands/services/storage.ts +547 -0
  245. package/lib/commands/services/tablesdb.ts +1928 -0
  246. package/lib/commands/services/teams.ts +294 -0
  247. package/lib/commands/services/tokens.ts +106 -0
  248. package/lib/commands/services/users.ts +886 -0
  249. package/lib/commands/services/vcs.ts +268 -0
  250. package/lib/commands/types.ts +220 -0
  251. package/lib/commands/update.ts +255 -0
  252. package/lib/config.ts +969 -0
  253. package/lib/emulation/docker.ts +312 -0
  254. package/lib/emulation/utils.ts +207 -0
  255. package/lib/id.ts +30 -0
  256. package/lib/paginate.ts +77 -0
  257. package/lib/parser.ts +264 -0
  258. package/lib/questions.ts +1167 -0
  259. package/lib/sdks.ts +84 -0
  260. package/lib/services.ts +72 -0
  261. package/lib/spinner.ts +131 -0
  262. package/lib/type-generation/attribute.ts +18 -0
  263. package/lib/type-generation/languages/{csharp.js → csharp.ts} +27 -14
  264. package/lib/type-generation/languages/{dart.js → dart.ts} +61 -46
  265. package/lib/type-generation/languages/{java.js → java.ts} +31 -18
  266. package/lib/type-generation/languages/{javascript.js → javascript.ts} +35 -24
  267. package/lib/type-generation/languages/{kotlin.js → kotlin.ts} +27 -14
  268. package/lib/type-generation/languages/{language.js → language.ts} +45 -43
  269. package/lib/type-generation/languages/{php.js → php.ts} +28 -15
  270. package/lib/type-generation/languages/{swift.js → swift.ts} +27 -14
  271. package/lib/type-generation/languages/{typescript.js → typescript.ts} +43 -26
  272. package/lib/types.ts +304 -0
  273. package/lib/utils.ts +352 -0
  274. package/lib/validations.ts +20 -0
  275. package/package.json +36 -19
  276. package/scoop/appwrite.config.json +19 -29
  277. package/scripts/generate-commands.ts +539 -0
  278. package/tsconfig.json +24 -0
  279. package/.github/workflows/autoclose.yml +0 -11
  280. package/docs/examples/account/create-anonymous-session.md +0 -1
  281. package/docs/examples/account/create-email-password-session.md +0 -3
  282. package/docs/examples/account/create-email-token.md +0 -3
  283. package/docs/examples/account/create-email-verification.md +0 -2
  284. package/docs/examples/account/create-jwt.md +0 -1
  285. package/docs/examples/account/create-magic-url-token.md +0 -3
  286. package/docs/examples/account/create-mfa-authenticator.md +0 -2
  287. package/docs/examples/account/create-mfa-challenge.md +0 -2
  288. package/docs/examples/account/create-mfa-recovery-codes.md +0 -1
  289. package/docs/examples/account/create-o-auth-2-session.md +0 -2
  290. package/docs/examples/account/create-o-auth-2-token.md +0 -2
  291. package/docs/examples/account/create-phone-token.md +0 -3
  292. package/docs/examples/account/create-phone-verification.md +0 -1
  293. package/docs/examples/account/create-push-target.md +0 -3
  294. package/docs/examples/account/create-recovery.md +0 -3
  295. package/docs/examples/account/create-session.md +0 -3
  296. package/docs/examples/account/create-verification.md +0 -2
  297. package/docs/examples/account/create.md +0 -4
  298. package/docs/examples/account/delete-identity.md +0 -2
  299. package/docs/examples/account/delete-mfa-authenticator.md +0 -2
  300. package/docs/examples/account/delete-push-target.md +0 -2
  301. package/docs/examples/account/delete-session.md +0 -2
  302. package/docs/examples/account/delete-sessions.md +0 -1
  303. package/docs/examples/account/delete.md +0 -1
  304. package/docs/examples/account/get-mfa-recovery-codes.md +0 -1
  305. package/docs/examples/account/get-prefs.md +0 -1
  306. package/docs/examples/account/get-session.md +0 -2
  307. package/docs/examples/account/get.md +0 -1
  308. package/docs/examples/account/list-identities.md +0 -1
  309. package/docs/examples/account/list-logs.md +0 -1
  310. package/docs/examples/account/list-mfa-factors.md +0 -1
  311. package/docs/examples/account/list-sessions.md +0 -1
  312. package/docs/examples/account/update-email-verification.md +0 -3
  313. package/docs/examples/account/update-email.md +0 -3
  314. package/docs/examples/account/update-magic-url-session.md +0 -3
  315. package/docs/examples/account/update-mfa-authenticator.md +0 -3
  316. package/docs/examples/account/update-mfa-challenge.md +0 -3
  317. package/docs/examples/account/update-mfa-recovery-codes.md +0 -1
  318. package/docs/examples/account/update-mfa.md +0 -2
  319. package/docs/examples/account/update-name.md +0 -2
  320. package/docs/examples/account/update-password.md +0 -2
  321. package/docs/examples/account/update-phone-session.md +0 -3
  322. package/docs/examples/account/update-phone-verification.md +0 -3
  323. package/docs/examples/account/update-phone.md +0 -3
  324. package/docs/examples/account/update-prefs.md +0 -2
  325. package/docs/examples/account/update-push-target.md +0 -3
  326. package/docs/examples/account/update-recovery.md +0 -4
  327. package/docs/examples/account/update-session.md +0 -2
  328. package/docs/examples/account/update-status.md +0 -1
  329. package/docs/examples/account/update-verification.md +0 -3
  330. package/docs/examples/console/get-resource.md +0 -3
  331. package/docs/examples/console/variables.md +0 -1
  332. package/docs/examples/databases/create-boolean-attribute.md +0 -5
  333. package/docs/examples/databases/create-collection.md +0 -4
  334. package/docs/examples/databases/create-datetime-attribute.md +0 -5
  335. package/docs/examples/databases/create-document.md +0 -5
  336. package/docs/examples/databases/create-documents.md +0 -4
  337. package/docs/examples/databases/create-email-attribute.md +0 -5
  338. package/docs/examples/databases/create-enum-attribute.md +0 -6
  339. package/docs/examples/databases/create-float-attribute.md +0 -5
  340. package/docs/examples/databases/create-index.md +0 -6
  341. package/docs/examples/databases/create-integer-attribute.md +0 -5
  342. package/docs/examples/databases/create-ip-attribute.md +0 -5
  343. package/docs/examples/databases/create-line-attribute.md +0 -5
  344. package/docs/examples/databases/create-operations.md +0 -2
  345. package/docs/examples/databases/create-point-attribute.md +0 -5
  346. package/docs/examples/databases/create-polygon-attribute.md +0 -5
  347. package/docs/examples/databases/create-relationship-attribute.md +0 -5
  348. package/docs/examples/databases/create-string-attribute.md +0 -6
  349. package/docs/examples/databases/create-transaction.md +0 -1
  350. package/docs/examples/databases/create-url-attribute.md +0 -5
  351. package/docs/examples/databases/create.md +0 -3
  352. package/docs/examples/databases/decrement-document-attribute.md +0 -5
  353. package/docs/examples/databases/delete-attribute.md +0 -4
  354. package/docs/examples/databases/delete-collection.md +0 -3
  355. package/docs/examples/databases/delete-document.md +0 -4
  356. package/docs/examples/databases/delete-documents.md +0 -3
  357. package/docs/examples/databases/delete-index.md +0 -4
  358. package/docs/examples/databases/delete-transaction.md +0 -2
  359. package/docs/examples/databases/delete.md +0 -2
  360. package/docs/examples/databases/get-attribute.md +0 -4
  361. package/docs/examples/databases/get-collection-usage.md +0 -3
  362. package/docs/examples/databases/get-collection.md +0 -3
  363. package/docs/examples/databases/get-document.md +0 -4
  364. package/docs/examples/databases/get-index.md +0 -4
  365. package/docs/examples/databases/get-transaction.md +0 -2
  366. package/docs/examples/databases/get-usage.md +0 -2
  367. package/docs/examples/databases/get.md +0 -2
  368. package/docs/examples/databases/increment-document-attribute.md +0 -5
  369. package/docs/examples/databases/list-attributes.md +0 -3
  370. package/docs/examples/databases/list-collection-logs.md +0 -3
  371. package/docs/examples/databases/list-collections.md +0 -2
  372. package/docs/examples/databases/list-document-logs.md +0 -4
  373. package/docs/examples/databases/list-documents.md +0 -3
  374. package/docs/examples/databases/list-indexes.md +0 -3
  375. package/docs/examples/databases/list-logs.md +0 -2
  376. package/docs/examples/databases/list-transactions.md +0 -1
  377. package/docs/examples/databases/list-usage.md +0 -1
  378. package/docs/examples/databases/list.md +0 -1
  379. package/docs/examples/databases/update-boolean-attribute.md +0 -6
  380. package/docs/examples/databases/update-collection.md +0 -4
  381. package/docs/examples/databases/update-datetime-attribute.md +0 -6
  382. package/docs/examples/databases/update-document.md +0 -4
  383. package/docs/examples/databases/update-documents.md +0 -3
  384. package/docs/examples/databases/update-email-attribute.md +0 -6
  385. package/docs/examples/databases/update-enum-attribute.md +0 -7
  386. package/docs/examples/databases/update-float-attribute.md +0 -6
  387. package/docs/examples/databases/update-integer-attribute.md +0 -6
  388. package/docs/examples/databases/update-ip-attribute.md +0 -6
  389. package/docs/examples/databases/update-line-attribute.md +0 -5
  390. package/docs/examples/databases/update-point-attribute.md +0 -5
  391. package/docs/examples/databases/update-polygon-attribute.md +0 -5
  392. package/docs/examples/databases/update-relationship-attribute.md +0 -4
  393. package/docs/examples/databases/update-string-attribute.md +0 -6
  394. package/docs/examples/databases/update-transaction.md +0 -2
  395. package/docs/examples/databases/update-url-attribute.md +0 -6
  396. package/docs/examples/databases/update.md +0 -3
  397. package/docs/examples/databases/upsert-document.md +0 -5
  398. package/docs/examples/databases/upsert-documents.md +0 -4
  399. package/docs/examples/functions/create-deployment.md +0 -4
  400. package/docs/examples/functions/create-duplicate-deployment.md +0 -3
  401. package/docs/examples/functions/create-execution.md +0 -2
  402. package/docs/examples/functions/create-template-deployment.md +0 -7
  403. package/docs/examples/functions/create-variable.md +0 -4
  404. package/docs/examples/functions/create-vcs-deployment.md +0 -4
  405. package/docs/examples/functions/create.md +0 -4
  406. package/docs/examples/functions/delete-deployment.md +0 -3
  407. package/docs/examples/functions/delete-execution.md +0 -3
  408. package/docs/examples/functions/delete-variable.md +0 -3
  409. package/docs/examples/functions/delete.md +0 -2
  410. package/docs/examples/functions/get-deployment-download.md +0 -3
  411. package/docs/examples/functions/get-deployment.md +0 -3
  412. package/docs/examples/functions/get-execution.md +0 -3
  413. package/docs/examples/functions/get-template.md +0 -2
  414. package/docs/examples/functions/get-usage.md +0 -2
  415. package/docs/examples/functions/get-variable.md +0 -3
  416. package/docs/examples/functions/get.md +0 -2
  417. package/docs/examples/functions/list-deployments.md +0 -2
  418. package/docs/examples/functions/list-executions.md +0 -2
  419. package/docs/examples/functions/list-runtimes.md +0 -1
  420. package/docs/examples/functions/list-specifications.md +0 -1
  421. package/docs/examples/functions/list-templates.md +0 -1
  422. package/docs/examples/functions/list-usage.md +0 -1
  423. package/docs/examples/functions/list-variables.md +0 -2
  424. package/docs/examples/functions/list.md +0 -1
  425. package/docs/examples/functions/update-deployment-status.md +0 -3
  426. package/docs/examples/functions/update-function-deployment.md +0 -3
  427. package/docs/examples/functions/update-variable.md +0 -4
  428. package/docs/examples/functions/update.md +0 -3
  429. package/docs/examples/graphql/mutation.md +0 -2
  430. package/docs/examples/graphql/query.md +0 -2
  431. package/docs/examples/health/get-antivirus.md +0 -1
  432. package/docs/examples/health/get-cache.md +0 -1
  433. package/docs/examples/health/get-certificate.md +0 -1
  434. package/docs/examples/health/get-db.md +0 -1
  435. package/docs/examples/health/get-failed-jobs.md +0 -2
  436. package/docs/examples/health/get-pub-sub.md +0 -1
  437. package/docs/examples/health/get-queue-builds.md +0 -1
  438. package/docs/examples/health/get-queue-certificates.md +0 -1
  439. package/docs/examples/health/get-queue-databases.md +0 -1
  440. package/docs/examples/health/get-queue-deletes.md +0 -1
  441. package/docs/examples/health/get-queue-functions.md +0 -1
  442. package/docs/examples/health/get-queue-logs.md +0 -1
  443. package/docs/examples/health/get-queue-mails.md +0 -1
  444. package/docs/examples/health/get-queue-messaging.md +0 -1
  445. package/docs/examples/health/get-queue-migrations.md +0 -1
  446. package/docs/examples/health/get-queue-stats-resources.md +0 -1
  447. package/docs/examples/health/get-queue-usage.md +0 -1
  448. package/docs/examples/health/get-queue-webhooks.md +0 -1
  449. package/docs/examples/health/get-storage-local.md +0 -1
  450. package/docs/examples/health/get-storage.md +0 -1
  451. package/docs/examples/health/get-time.md +0 -1
  452. package/docs/examples/health/get.md +0 -1
  453. package/docs/examples/locale/get.md +0 -1
  454. package/docs/examples/locale/list-codes.md +0 -1
  455. package/docs/examples/locale/list-continents.md +0 -1
  456. package/docs/examples/locale/list-countries-eu.md +0 -1
  457. package/docs/examples/locale/list-countries-phones.md +0 -1
  458. package/docs/examples/locale/list-countries.md +0 -1
  459. package/docs/examples/locale/list-currencies.md +0 -1
  460. package/docs/examples/locale/list-languages.md +0 -1
  461. package/docs/examples/messaging/create-apns-provider.md +0 -3
  462. package/docs/examples/messaging/create-email.md +0 -4
  463. package/docs/examples/messaging/create-fcm-provider.md +0 -3
  464. package/docs/examples/messaging/create-mailgun-provider.md +0 -3
  465. package/docs/examples/messaging/create-msg-91-provider.md +0 -3
  466. package/docs/examples/messaging/create-push.md +0 -2
  467. package/docs/examples/messaging/create-resend-provider.md +0 -3
  468. package/docs/examples/messaging/create-sendgrid-provider.md +0 -3
  469. package/docs/examples/messaging/create-sms.md +0 -3
  470. package/docs/examples/messaging/create-smtp-provider.md +0 -4
  471. package/docs/examples/messaging/create-subscriber.md +0 -4
  472. package/docs/examples/messaging/create-telesign-provider.md +0 -3
  473. package/docs/examples/messaging/create-textmagic-provider.md +0 -3
  474. package/docs/examples/messaging/create-topic.md +0 -3
  475. package/docs/examples/messaging/create-twilio-provider.md +0 -3
  476. package/docs/examples/messaging/create-vonage-provider.md +0 -3
  477. package/docs/examples/messaging/delete-provider.md +0 -2
  478. package/docs/examples/messaging/delete-subscriber.md +0 -3
  479. package/docs/examples/messaging/delete-topic.md +0 -2
  480. package/docs/examples/messaging/delete.md +0 -2
  481. package/docs/examples/messaging/get-message.md +0 -2
  482. package/docs/examples/messaging/get-provider.md +0 -2
  483. package/docs/examples/messaging/get-subscriber.md +0 -3
  484. package/docs/examples/messaging/get-topic.md +0 -2
  485. package/docs/examples/messaging/list-message-logs.md +0 -2
  486. package/docs/examples/messaging/list-messages.md +0 -1
  487. package/docs/examples/messaging/list-provider-logs.md +0 -2
  488. package/docs/examples/messaging/list-providers.md +0 -1
  489. package/docs/examples/messaging/list-subscriber-logs.md +0 -2
  490. package/docs/examples/messaging/list-subscribers.md +0 -2
  491. package/docs/examples/messaging/list-targets.md +0 -2
  492. package/docs/examples/messaging/list-topic-logs.md +0 -2
  493. package/docs/examples/messaging/list-topics.md +0 -1
  494. package/docs/examples/messaging/update-apns-provider.md +0 -2
  495. package/docs/examples/messaging/update-email.md +0 -2
  496. package/docs/examples/messaging/update-fcm-provider.md +0 -2
  497. package/docs/examples/messaging/update-mailgun-provider.md +0 -2
  498. package/docs/examples/messaging/update-msg-91-provider.md +0 -2
  499. package/docs/examples/messaging/update-push.md +0 -2
  500. package/docs/examples/messaging/update-resend-provider.md +0 -2
  501. package/docs/examples/messaging/update-sendgrid-provider.md +0 -2
  502. package/docs/examples/messaging/update-sms.md +0 -2
  503. package/docs/examples/messaging/update-smtp-provider.md +0 -2
  504. package/docs/examples/messaging/update-telesign-provider.md +0 -2
  505. package/docs/examples/messaging/update-textmagic-provider.md +0 -2
  506. package/docs/examples/messaging/update-topic.md +0 -2
  507. package/docs/examples/messaging/update-twilio-provider.md +0 -2
  508. package/docs/examples/messaging/update-vonage-provider.md +0 -2
  509. package/docs/examples/migrations/create-appwrite-migration.md +0 -5
  510. package/docs/examples/migrations/create-csv-export.md +0 -3
  511. package/docs/examples/migrations/create-csv-import.md +0 -4
  512. package/docs/examples/migrations/create-firebase-migration.md +0 -3
  513. package/docs/examples/migrations/create-n-host-migration.md +0 -8
  514. package/docs/examples/migrations/create-supabase-migration.md +0 -7
  515. package/docs/examples/migrations/delete.md +0 -2
  516. package/docs/examples/migrations/get-appwrite-report.md +0 -5
  517. package/docs/examples/migrations/get-firebase-report.md +0 -3
  518. package/docs/examples/migrations/get-n-host-report.md +0 -8
  519. package/docs/examples/migrations/get-supabase-report.md +0 -7
  520. package/docs/examples/migrations/get.md +0 -2
  521. package/docs/examples/migrations/list.md +0 -1
  522. package/docs/examples/migrations/retry.md +0 -2
  523. package/docs/examples/project/create-variable.md +0 -3
  524. package/docs/examples/project/delete-variable.md +0 -2
  525. package/docs/examples/project/get-usage.md +0 -3
  526. package/docs/examples/project/get-variable.md +0 -2
  527. package/docs/examples/project/list-variables.md +0 -1
  528. package/docs/examples/project/update-variable.md +0 -3
  529. package/docs/examples/projects/create-dev-key.md +0 -4
  530. package/docs/examples/projects/create-jwt.md +0 -3
  531. package/docs/examples/projects/create-key.md +0 -4
  532. package/docs/examples/projects/create-platform.md +0 -4
  533. package/docs/examples/projects/create-smtp-test.md +0 -6
  534. package/docs/examples/projects/create-webhook.md +0 -6
  535. package/docs/examples/projects/create.md +0 -4
  536. package/docs/examples/projects/delete-dev-key.md +0 -3
  537. package/docs/examples/projects/delete-email-template.md +0 -4
  538. package/docs/examples/projects/delete-key.md +0 -3
  539. package/docs/examples/projects/delete-platform.md +0 -3
  540. package/docs/examples/projects/delete-sms-template.md +0 -4
  541. package/docs/examples/projects/delete-webhook.md +0 -3
  542. package/docs/examples/projects/delete.md +0 -2
  543. package/docs/examples/projects/get-dev-key.md +0 -3
  544. package/docs/examples/projects/get-email-template.md +0 -4
  545. package/docs/examples/projects/get-key.md +0 -3
  546. package/docs/examples/projects/get-platform.md +0 -3
  547. package/docs/examples/projects/get-sms-template.md +0 -4
  548. package/docs/examples/projects/get-webhook.md +0 -3
  549. package/docs/examples/projects/get.md +0 -2
  550. package/docs/examples/projects/list-dev-keys.md +0 -2
  551. package/docs/examples/projects/list-keys.md +0 -2
  552. package/docs/examples/projects/list-platforms.md +0 -2
  553. package/docs/examples/projects/list-webhooks.md +0 -2
  554. package/docs/examples/projects/list.md +0 -1
  555. package/docs/examples/projects/update-api-status-all.md +0 -3
  556. package/docs/examples/projects/update-api-status.md +0 -4
  557. package/docs/examples/projects/update-auth-duration.md +0 -3
  558. package/docs/examples/projects/update-auth-limit.md +0 -3
  559. package/docs/examples/projects/update-auth-password-dictionary.md +0 -3
  560. package/docs/examples/projects/update-auth-password-history.md +0 -3
  561. package/docs/examples/projects/update-auth-sessions-limit.md +0 -3
  562. package/docs/examples/projects/update-auth-status.md +0 -4
  563. package/docs/examples/projects/update-dev-key.md +0 -5
  564. package/docs/examples/projects/update-email-template.md +0 -6
  565. package/docs/examples/projects/update-key.md +0 -5
  566. package/docs/examples/projects/update-memberships-privacy.md +0 -5
  567. package/docs/examples/projects/update-mock-numbers.md +0 -3
  568. package/docs/examples/projects/update-o-auth-2.md +0 -3
  569. package/docs/examples/projects/update-personal-data-check.md +0 -3
  570. package/docs/examples/projects/update-platform.md +0 -4
  571. package/docs/examples/projects/update-service-status-all.md +0 -3
  572. package/docs/examples/projects/update-service-status.md +0 -4
  573. package/docs/examples/projects/update-session-alerts.md +0 -3
  574. package/docs/examples/projects/update-session-invalidation.md +0 -3
  575. package/docs/examples/projects/update-sms-template.md +0 -5
  576. package/docs/examples/projects/update-smtp.md +0 -3
  577. package/docs/examples/projects/update-team.md +0 -3
  578. package/docs/examples/projects/update-webhook-signature.md +0 -3
  579. package/docs/examples/projects/update-webhook.md +0 -7
  580. package/docs/examples/projects/update.md +0 -3
  581. package/docs/examples/proxy/create-api-rule.md +0 -2
  582. package/docs/examples/proxy/create-function-rule.md +0 -3
  583. package/docs/examples/proxy/create-redirect-rule.md +0 -6
  584. package/docs/examples/proxy/create-site-rule.md +0 -3
  585. package/docs/examples/proxy/delete-rule.md +0 -2
  586. package/docs/examples/proxy/get-rule.md +0 -2
  587. package/docs/examples/proxy/list-rules.md +0 -1
  588. package/docs/examples/proxy/update-rule-verification.md +0 -2
  589. package/docs/examples/sites/create-deployment.md +0 -4
  590. package/docs/examples/sites/create-duplicate-deployment.md +0 -3
  591. package/docs/examples/sites/create-template-deployment.md +0 -7
  592. package/docs/examples/sites/create-variable.md +0 -4
  593. package/docs/examples/sites/create-vcs-deployment.md +0 -4
  594. package/docs/examples/sites/create.md +0 -5
  595. package/docs/examples/sites/delete-deployment.md +0 -3
  596. package/docs/examples/sites/delete-log.md +0 -3
  597. package/docs/examples/sites/delete-variable.md +0 -3
  598. package/docs/examples/sites/delete.md +0 -2
  599. package/docs/examples/sites/get-deployment-download.md +0 -3
  600. package/docs/examples/sites/get-deployment.md +0 -3
  601. package/docs/examples/sites/get-log.md +0 -3
  602. package/docs/examples/sites/get-template.md +0 -2
  603. package/docs/examples/sites/get-usage.md +0 -2
  604. package/docs/examples/sites/get-variable.md +0 -3
  605. package/docs/examples/sites/get.md +0 -2
  606. package/docs/examples/sites/list-deployments.md +0 -2
  607. package/docs/examples/sites/list-frameworks.md +0 -1
  608. package/docs/examples/sites/list-logs.md +0 -2
  609. package/docs/examples/sites/list-specifications.md +0 -1
  610. package/docs/examples/sites/list-templates.md +0 -1
  611. package/docs/examples/sites/list-usage.md +0 -1
  612. package/docs/examples/sites/list-variables.md +0 -2
  613. package/docs/examples/sites/list.md +0 -1
  614. package/docs/examples/sites/update-deployment-status.md +0 -3
  615. package/docs/examples/sites/update-site-deployment.md +0 -3
  616. package/docs/examples/sites/update-variable.md +0 -4
  617. package/docs/examples/sites/update.md +0 -4
  618. package/docs/examples/storage/create-bucket.md +0 -3
  619. package/docs/examples/storage/create-file.md +0 -4
  620. package/docs/examples/storage/delete-bucket.md +0 -2
  621. package/docs/examples/storage/delete-file.md +0 -3
  622. package/docs/examples/storage/get-bucket-usage.md +0 -2
  623. package/docs/examples/storage/get-bucket.md +0 -2
  624. package/docs/examples/storage/get-file-download.md +0 -3
  625. package/docs/examples/storage/get-file-preview.md +0 -3
  626. package/docs/examples/storage/get-file-view.md +0 -3
  627. package/docs/examples/storage/get-file.md +0 -3
  628. package/docs/examples/storage/get-usage.md +0 -1
  629. package/docs/examples/storage/list-buckets.md +0 -1
  630. package/docs/examples/storage/list-files.md +0 -2
  631. package/docs/examples/storage/update-bucket.md +0 -3
  632. package/docs/examples/storage/update-file.md +0 -3
  633. package/docs/examples/tablesdb/create-boolean-column.md +0 -5
  634. package/docs/examples/tablesdb/create-datetime-column.md +0 -5
  635. package/docs/examples/tablesdb/create-email-column.md +0 -5
  636. package/docs/examples/tablesdb/create-enum-column.md +0 -6
  637. package/docs/examples/tablesdb/create-float-column.md +0 -5
  638. package/docs/examples/tablesdb/create-index.md +0 -6
  639. package/docs/examples/tablesdb/create-integer-column.md +0 -5
  640. package/docs/examples/tablesdb/create-ip-column.md +0 -5
  641. package/docs/examples/tablesdb/create-line-column.md +0 -5
  642. package/docs/examples/tablesdb/create-operations.md +0 -2
  643. package/docs/examples/tablesdb/create-point-column.md +0 -5
  644. package/docs/examples/tablesdb/create-polygon-column.md +0 -5
  645. package/docs/examples/tablesdb/create-relationship-column.md +0 -5
  646. package/docs/examples/tablesdb/create-row.md +0 -5
  647. package/docs/examples/tablesdb/create-rows.md +0 -4
  648. package/docs/examples/tablesdb/create-string-column.md +0 -6
  649. package/docs/examples/tablesdb/create-table.md +0 -4
  650. package/docs/examples/tablesdb/create-transaction.md +0 -1
  651. package/docs/examples/tablesdb/create-url-column.md +0 -5
  652. package/docs/examples/tablesdb/create.md +0 -3
  653. package/docs/examples/tablesdb/decrement-row-column.md +0 -5
  654. package/docs/examples/tablesdb/delete-column.md +0 -4
  655. package/docs/examples/tablesdb/delete-index.md +0 -4
  656. package/docs/examples/tablesdb/delete-row.md +0 -4
  657. package/docs/examples/tablesdb/delete-rows.md +0 -3
  658. package/docs/examples/tablesdb/delete-table.md +0 -3
  659. package/docs/examples/tablesdb/delete-transaction.md +0 -2
  660. package/docs/examples/tablesdb/delete.md +0 -2
  661. package/docs/examples/tablesdb/get-column.md +0 -4
  662. package/docs/examples/tablesdb/get-index.md +0 -4
  663. package/docs/examples/tablesdb/get-row.md +0 -4
  664. package/docs/examples/tablesdb/get-table-usage.md +0 -3
  665. package/docs/examples/tablesdb/get-table.md +0 -3
  666. package/docs/examples/tablesdb/get-transaction.md +0 -2
  667. package/docs/examples/tablesdb/get-usage.md +0 -2
  668. package/docs/examples/tablesdb/get.md +0 -2
  669. package/docs/examples/tablesdb/increment-row-column.md +0 -5
  670. package/docs/examples/tablesdb/list-columns.md +0 -3
  671. package/docs/examples/tablesdb/list-indexes.md +0 -3
  672. package/docs/examples/tablesdb/list-row-logs.md +0 -4
  673. package/docs/examples/tablesdb/list-rows.md +0 -3
  674. package/docs/examples/tablesdb/list-table-logs.md +0 -3
  675. package/docs/examples/tablesdb/list-tables.md +0 -2
  676. package/docs/examples/tablesdb/list-transactions.md +0 -1
  677. package/docs/examples/tablesdb/list-usage.md +0 -1
  678. package/docs/examples/tablesdb/list.md +0 -1
  679. package/docs/examples/tablesdb/update-boolean-column.md +0 -6
  680. package/docs/examples/tablesdb/update-datetime-column.md +0 -6
  681. package/docs/examples/tablesdb/update-email-column.md +0 -6
  682. package/docs/examples/tablesdb/update-enum-column.md +0 -7
  683. package/docs/examples/tablesdb/update-float-column.md +0 -6
  684. package/docs/examples/tablesdb/update-integer-column.md +0 -6
  685. package/docs/examples/tablesdb/update-ip-column.md +0 -6
  686. package/docs/examples/tablesdb/update-line-column.md +0 -5
  687. package/docs/examples/tablesdb/update-point-column.md +0 -5
  688. package/docs/examples/tablesdb/update-polygon-column.md +0 -5
  689. package/docs/examples/tablesdb/update-relationship-column.md +0 -4
  690. package/docs/examples/tablesdb/update-row.md +0 -4
  691. package/docs/examples/tablesdb/update-rows.md +0 -3
  692. package/docs/examples/tablesdb/update-string-column.md +0 -6
  693. package/docs/examples/tablesdb/update-table.md +0 -4
  694. package/docs/examples/tablesdb/update-transaction.md +0 -2
  695. package/docs/examples/tablesdb/update-url-column.md +0 -6
  696. package/docs/examples/tablesdb/update.md +0 -3
  697. package/docs/examples/tablesdb/upsert-row.md +0 -4
  698. package/docs/examples/tablesdb/upsert-rows.md +0 -4
  699. package/docs/examples/teams/create-membership.md +0 -3
  700. package/docs/examples/teams/create.md +0 -3
  701. package/docs/examples/teams/delete-membership.md +0 -3
  702. package/docs/examples/teams/delete.md +0 -2
  703. package/docs/examples/teams/get-membership.md +0 -3
  704. package/docs/examples/teams/get-prefs.md +0 -2
  705. package/docs/examples/teams/get.md +0 -2
  706. package/docs/examples/teams/list-logs.md +0 -2
  707. package/docs/examples/teams/list-memberships.md +0 -2
  708. package/docs/examples/teams/list.md +0 -1
  709. package/docs/examples/teams/update-membership-status.md +0 -5
  710. package/docs/examples/teams/update-membership.md +0 -4
  711. package/docs/examples/teams/update-name.md +0 -3
  712. package/docs/examples/teams/update-prefs.md +0 -3
  713. package/docs/examples/tokens/create-file-token.md +0 -3
  714. package/docs/examples/tokens/delete.md +0 -2
  715. package/docs/examples/tokens/get.md +0 -2
  716. package/docs/examples/tokens/list.md +0 -3
  717. package/docs/examples/tokens/update.md +0 -2
  718. package/docs/examples/users/create-argon-2-user.md +0 -4
  719. package/docs/examples/users/create-bcrypt-user.md +0 -4
  720. package/docs/examples/users/create-jwt.md +0 -2
  721. package/docs/examples/users/create-md-5-user.md +0 -4
  722. package/docs/examples/users/create-mfa-recovery-codes.md +0 -2
  723. package/docs/examples/users/create-ph-pass-user.md +0 -4
  724. package/docs/examples/users/create-scrypt-modified-user.md +0 -7
  725. package/docs/examples/users/create-scrypt-user.md +0 -9
  726. package/docs/examples/users/create-session.md +0 -2
  727. package/docs/examples/users/create-sha-user.md +0 -4
  728. package/docs/examples/users/create-target.md +0 -5
  729. package/docs/examples/users/create-token.md +0 -2
  730. package/docs/examples/users/create.md +0 -2
  731. package/docs/examples/users/delete-identity.md +0 -2
  732. package/docs/examples/users/delete-mfa-authenticator.md +0 -3
  733. package/docs/examples/users/delete-session.md +0 -3
  734. package/docs/examples/users/delete-sessions.md +0 -2
  735. package/docs/examples/users/delete-target.md +0 -3
  736. package/docs/examples/users/delete.md +0 -2
  737. package/docs/examples/users/get-mfa-recovery-codes.md +0 -2
  738. package/docs/examples/users/get-prefs.md +0 -2
  739. package/docs/examples/users/get-target.md +0 -3
  740. package/docs/examples/users/get-usage.md +0 -1
  741. package/docs/examples/users/get.md +0 -2
  742. package/docs/examples/users/list-identities.md +0 -1
  743. package/docs/examples/users/list-logs.md +0 -2
  744. package/docs/examples/users/list-memberships.md +0 -2
  745. package/docs/examples/users/list-mfa-factors.md +0 -2
  746. package/docs/examples/users/list-sessions.md +0 -2
  747. package/docs/examples/users/list-targets.md +0 -2
  748. package/docs/examples/users/list.md +0 -1
  749. package/docs/examples/users/update-email-verification.md +0 -3
  750. package/docs/examples/users/update-email.md +0 -3
  751. package/docs/examples/users/update-labels.md +0 -3
  752. package/docs/examples/users/update-mfa-recovery-codes.md +0 -2
  753. package/docs/examples/users/update-mfa.md +0 -3
  754. package/docs/examples/users/update-name.md +0 -3
  755. package/docs/examples/users/update-password.md +0 -3
  756. package/docs/examples/users/update-phone-verification.md +0 -3
  757. package/docs/examples/users/update-phone.md +0 -3
  758. package/docs/examples/users/update-prefs.md +0 -3
  759. package/docs/examples/users/update-status.md +0 -3
  760. package/docs/examples/users/update-target.md +0 -3
  761. package/docs/examples/vcs/create-repository-detection.md +0 -4
  762. package/docs/examples/vcs/create-repository.md +0 -4
  763. package/docs/examples/vcs/delete-installation.md +0 -2
  764. package/docs/examples/vcs/get-installation.md +0 -2
  765. package/docs/examples/vcs/get-repository-contents.md +0 -3
  766. package/docs/examples/vcs/get-repository.md +0 -3
  767. package/docs/examples/vcs/list-installations.md +0 -1
  768. package/docs/examples/vcs/list-repositories.md +0 -3
  769. package/docs/examples/vcs/list-repository-branches.md +0 -3
  770. package/docs/examples/vcs/update-external-deployments.md +0 -4
  771. package/index.js +0 -147
  772. package/lib/client.js +0 -254
  773. package/lib/commands/account.js +0 -2121
  774. package/lib/commands/console.js +0 -127
  775. package/lib/commands/databases.js +0 -3590
  776. package/lib/commands/functions.js +0 -1732
  777. package/lib/commands/generic.js +0 -330
  778. package/lib/commands/graphql.js +0 -126
  779. package/lib/commands/health.js +0 -869
  780. package/lib/commands/locale.js +0 -316
  781. package/lib/commands/messaging.js +0 -3116
  782. package/lib/commands/migrations.js +0 -830
  783. package/lib/commands/organizations.js +0 -48
  784. package/lib/commands/project.js +0 -302
  785. package/lib/commands/projects.js +0 -2626
  786. package/lib/commands/proxy.js +0 -403
  787. package/lib/commands/push.js +0 -2570
  788. package/lib/commands/sites.js +0 -1654
  789. package/lib/commands/storage.js +0 -995
  790. package/lib/commands/tables-db.js +0 -3569
  791. package/lib/commands/teams.js +0 -683
  792. package/lib/commands/tokens.js +0 -261
  793. package/lib/commands/types.js +0 -191
  794. package/lib/commands/users.js +0 -2022
  795. package/lib/commands/vcs.js +0 -484
  796. package/lib/emulation/docker.js +0 -264
  797. package/lib/exception.js +0 -9
  798. package/lib/parser.js +0 -250
  799. package/lib/sdks.js +0 -60
  800. package/lib/spinner.js +0 -104
  801. package/lib/validations.js +0 -17
@@ -1,2570 +0,0 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { parse: parseDotenv } = require('dotenv');
4
- const chalk = require('chalk');
5
- const inquirer = require("inquirer");
6
- const JSONbig = require("json-bigint")({ storeAsString: false });
7
- const { Command } = require("commander");
8
- const ID = require("../id");
9
- const { localConfig, globalConfig, KeysAttributes, KeysFunction, KeysSite, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable } = require("../config");
10
- const { Spinner, SPINNER_ARC, SPINNER_DOTS } = require('../spinner');
11
- const { paginate } = require('../paginate');
12
- const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsPushSites, questionsGetEntrypoint, questionsPushCollections, questionsPushTables, questionPushChanges, questionPushChangesConfirmation, questionsPushMessagingTopics, questionsPushResources } = require("../questions");
13
- const { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable } = require("../parser");
14
- const { proxyCreateFunctionRule, proxyCreateSiteRule, proxyListRules } = require('./proxy');
15
- const { consoleVariables } = require('./console');
16
- const { sdkForConsole } = require('../sdks')
17
- const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
18
- const { sitesGet, sitesCreate, sitesUpdate, sitesCreateDeployment, sitesGetDeployment, sitesCreateVariable, sitesListVariables, sitesDeleteVariable } = require('./sites');
19
- const {
20
- databasesGet,
21
- databasesCreate,
22
- databasesUpdate,
23
- databasesCreateBooleanAttribute,
24
- databasesGetCollection,
25
- databasesCreateCollection,
26
- databasesCreateStringAttribute,
27
- databasesCreateIntegerAttribute,
28
- databasesCreateFloatAttribute,
29
- databasesCreateEmailAttribute,
30
- databasesCreateDatetimeAttribute,
31
- databasesCreateIndex,
32
- databasesCreateUrlAttribute,
33
- databasesCreateIpAttribute,
34
- databasesCreateEnumAttribute,
35
- databasesUpdateBooleanAttribute,
36
- databasesUpdateStringAttribute,
37
- databasesUpdateIntegerAttribute,
38
- databasesUpdateFloatAttribute,
39
- databasesUpdateEmailAttribute,
40
- databasesUpdateDatetimeAttribute,
41
- databasesUpdateUrlAttribute,
42
- databasesUpdateIpAttribute,
43
- databasesUpdateEnumAttribute,
44
- databasesUpdateRelationshipAttribute,
45
- databasesCreateRelationshipAttribute,
46
- databasesCreatePointAttribute,
47
- databasesUpdatePointAttribute,
48
- databasesCreateLineAttribute,
49
- databasesUpdateLineAttribute,
50
- databasesCreatePolygonAttribute,
51
- databasesUpdatePolygonAttribute,
52
- databasesDeleteAttribute,
53
- databasesDeleteIndex,
54
- databasesListAttributes,
55
- databasesListIndexes,
56
- databasesUpdateCollection
57
- } = require("./databases");
58
- const {
59
- tablesDBCreate,
60
- tablesDBGet,
61
- tablesDBUpdate,
62
- tablesDBCreateTable,
63
- tablesDBGetTable,
64
- tablesDBUpdateTable,
65
- tablesDBList,
66
- tablesDBDelete,
67
- tablesDBListTables,
68
- tablesDBDeleteTable
69
- } = require("./tables-db");
70
- const {
71
- storageGetBucket, storageUpdateBucket, storageCreateBucket
72
- } = require("./storage");
73
- const {
74
- messagingGetTopic, messagingUpdateTopic, messagingCreateTopic
75
- } = require("./messaging");
76
- const {
77
- teamsGet,
78
- teamsUpdateName,
79
- teamsCreate
80
- } = require("./teams");
81
- const {
82
- projectsGet,
83
- projectsUpdate,
84
- projectsUpdateServiceStatus,
85
- projectsUpdateAuthStatus,
86
- projectsUpdateAuthDuration,
87
- projectsUpdateAuthLimit,
88
- projectsUpdateAuthSessionsLimit,
89
- projectsUpdateAuthPasswordDictionary,
90
- projectsUpdateAuthPasswordHistory,
91
- projectsUpdatePersonalDataCheck,
92
- projectsUpdateSessionAlerts,
93
- projectsUpdateMockNumbers,
94
- } = require("./projects");
95
- const { checkDeployConditions } = require('../utils');
96
-
97
- const STEP_SIZE = 100; // Resources
98
- const POLL_DEBOUNCE = 2000; // Milliseconds
99
- const POLL_MAX_DEBOUNCE = 1800; // Times of POLL_DEBOUNCE (1 hour)
100
- const POLL_DEFAULT_VALUE = 30;
101
-
102
- let pollMaxDebounces = POLL_DEFAULT_VALUE;
103
-
104
- const changeableKeys = ['status', 'required', 'xdefault', 'elements', 'min', 'max', 'default', 'error'];
105
-
106
- const awaitPools = {
107
- wipeAttributes: async (databaseId, collectionId, iteration = 1) => {
108
- if (iteration > pollMaxDebounces) {
109
- return false;
110
- }
111
-
112
- const { total } = await databasesListAttributes({
113
- databaseId,
114
- collectionId,
115
- queries: [JSON.stringify({ method: 'limit', values: [1] })],
116
- parseOutput: false
117
- });
118
-
119
- if (total === 0) {
120
- return true;
121
- }
122
-
123
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
124
- let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
125
- if (steps > 1 && iteration === 1) {
126
- pollMaxDebounces *= steps;
127
-
128
- log('Found a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
129
- }
130
- }
131
-
132
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
133
-
134
- return await awaitPools.wipeAttributes(
135
- databaseId,
136
- collectionId,
137
- iteration + 1
138
- );
139
- },
140
- wipeIndexes: async (databaseId, collectionId, iteration = 1) => {
141
- if (iteration > pollMaxDebounces) {
142
- return false;
143
- }
144
-
145
- const { total } = await databasesListIndexes({
146
- databaseId,
147
- collectionId,
148
- queries: [JSON.stringify({ method: 'limit', values: [1] })],
149
- parseOutput: false
150
- });
151
-
152
- if (total === 0) {
153
- return true;
154
- }
155
-
156
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
157
- let steps = Math.max(1, Math.ceil(total / STEP_SIZE));
158
- if (steps > 1 && iteration === 1) {
159
- pollMaxDebounces *= steps;
160
-
161
- log('Found a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
162
- }
163
- }
164
-
165
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
166
-
167
- return await awaitPools.wipeIndexes(
168
- databaseId,
169
- collectionId,
170
- iteration + 1
171
- );
172
- },
173
- deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
174
- if (iteration > pollMaxDebounces) {
175
- return false;
176
- }
177
-
178
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
179
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
180
- if (steps > 1 && iteration === 1) {
181
- pollMaxDebounces *= steps;
182
-
183
- log('Found a large number of attributes to be deleted. Increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
184
- }
185
- }
186
-
187
- const { attributes } = await paginate(databasesListAttributes, {
188
- databaseId,
189
- collectionId,
190
- parseOutput: false
191
- }, 100, 'attributes');
192
-
193
- const ready = attributeKeys.filter(attribute => attributes.includes(attribute.key));
194
-
195
- if (ready.length === 0) {
196
- return true;
197
- }
198
-
199
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
200
-
201
- return await awaitPools.expectAttributes(
202
- databaseId,
203
- collectionId,
204
- attributeKeys,
205
- iteration + 1
206
- );
207
- },
208
- expectAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
209
- if (iteration > pollMaxDebounces) {
210
- return false;
211
- }
212
-
213
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
214
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
215
- if (steps > 1 && iteration === 1) {
216
- pollMaxDebounces *= steps;
217
-
218
- log('Creating a large number of attributes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
219
- }
220
- }
221
-
222
- const { attributes } = await paginate(databasesListAttributes, {
223
- databaseId,
224
- collectionId,
225
- parseOutput: false
226
- }, 100, 'attributes');
227
-
228
- const ready = attributes
229
- .filter(attribute => {
230
- if (attributeKeys.includes(attribute.key)) {
231
- if (['stuck', 'failed'].includes(attribute.status)) {
232
- throw new Error(`Attribute '${attribute.key}' failed!`);
233
- }
234
-
235
- return attribute.status === 'available';
236
- }
237
-
238
- return false;
239
- })
240
- .map(attribute => attribute.key);
241
-
242
- if (ready.length === attributeKeys.length) {
243
- return true;
244
- }
245
-
246
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
247
-
248
- return await awaitPools.expectAttributes(
249
- databaseId,
250
- collectionId,
251
- attributeKeys,
252
- iteration + 1
253
- );
254
- },
255
- deleteIndexes: async (databaseId, collectionId, indexesKeys, iteration = 1) => {
256
- if (iteration > pollMaxDebounces) {
257
- return false;
258
- }
259
-
260
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
261
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
262
- if (steps > 1 && iteration === 1) {
263
- pollMaxDebounces *= steps;
264
-
265
- log('Found a large number of indexes to be deleted. Increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
266
- }
267
- }
268
-
269
- const { indexes } = await paginate(databasesListIndexes, {
270
- databaseId,
271
- collectionId,
272
- parseOutput: false
273
- }, 100, 'indexes');
274
-
275
- const ready = indexesKeys.filter(index => indexes.includes(index.key));
276
-
277
- if (ready.length === 0) {
278
- return true;
279
- }
280
-
281
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
282
-
283
- return await awaitPools.expectIndexes(
284
- databaseId,
285
- collectionId,
286
- indexesKeys,
287
- iteration + 1
288
- );
289
- },
290
- expectIndexes: async (databaseId, collectionId, indexKeys, iteration = 1) => {
291
- if (iteration > pollMaxDebounces) {
292
- return false;
293
- }
294
-
295
- if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
296
- let steps = Math.max(1, Math.ceil(indexKeys.length / STEP_SIZE));
297
- if (steps > 1 && iteration === 1) {
298
- pollMaxDebounces *= steps;
299
-
300
- log('Creating a large number of indexes, increasing timeout to ' + (pollMaxDebounces * POLL_DEBOUNCE / 1000 / 60) + ' minutes')
301
- }
302
- }
303
-
304
- const { indexes } = await paginate(databasesListIndexes, {
305
- databaseId,
306
- collectionId,
307
- parseOutput: false
308
- }, 100, 'indexes');
309
-
310
- const ready = indexes
311
- .filter((index) => {
312
- if (indexKeys.includes(index.key)) {
313
- if (['stuck', 'failed'].includes(index.status)) {
314
- throw new Error(`Index '${index.key}' failed!`);
315
- }
316
-
317
- return index.status === 'available';
318
- }
319
-
320
- return false;
321
- })
322
- .map(index => index.key);
323
-
324
- if (ready.length >= indexKeys.length) {
325
- return true;
326
- }
327
-
328
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE));
329
-
330
- return await awaitPools.expectIndexes(
331
- databaseId,
332
- collectionId,
333
- indexKeys,
334
- iteration + 1
335
- );
336
- },
337
- }
338
-
339
- const getConfirmation = async () => {
340
- if (cliConfig.force) {
341
- return true;
342
- }
343
-
344
- async function fixConfirmation() {
345
- const answers = await inquirer.prompt(questionPushChangesConfirmation);
346
- if (answers.changes !== 'YES' && answers.changes !== 'NO') {
347
- return await fixConfirmation();
348
- }
349
-
350
- return answers.changes;
351
- }
352
-
353
- let answers = await inquirer.prompt(questionPushChanges);
354
-
355
- if (answers.changes !== 'YES' && answers.changes !== 'NO') {
356
- answers.changes = await fixConfirmation();
357
- }
358
-
359
- if (answers.changes === 'YES') {
360
- return true;
361
- }
362
-
363
- warn('Skipping push action. Changes were not applied.');
364
- return false;
365
-
366
- };
367
- const isEmpty = (value) => (value === null || value === undefined || (typeof value === "string" && value.trim().length === 0) || (Array.isArray(value) && value.length === 0));
368
-
369
- const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = [], secondId = '', secondResourceName = '') => {
370
- log('Checking for changes ...');
371
- const changes = [];
372
-
373
- await Promise.all(resource.map(async (localResource) => {
374
- try {
375
- const options = {
376
- [resourceName]: localResource['$id'],
377
- parseOutput: false,
378
- };
379
-
380
- if (secondId !== '' && secondResourceName !== '') {
381
- options[secondResourceName] = localResource[secondId]
382
- }
383
-
384
- const remoteResource = await resourceGetFunction(options);
385
-
386
- for (let [key, value] of Object.entries(whitelistKeys(remoteResource, keys))) {
387
- if (skipKeys.includes(key)) {
388
- continue;
389
- }
390
-
391
- if (isEmpty(value) && isEmpty(localResource[key])) {
392
- continue;
393
- }
394
-
395
- if (Array.isArray(value) && Array.isArray(localResource[key])) {
396
- if (JSON.stringify(value) !== JSON.stringify(localResource[key])) {
397
- changes.push({
398
- id: localResource['$id'],
399
- key,
400
- remote: chalk.red(value.join('\n')),
401
- local: chalk.green(localResource[key].join('\n'))
402
- })
403
- }
404
- } else if (value !== localResource[key]) {
405
- changes.push({
406
- id: localResource['$id'],
407
- key,
408
- remote: chalk.red(value),
409
- local: chalk.green(localResource[key])
410
- })
411
- }
412
- }
413
- } catch (e) {
414
- if (Number(e.code) !== 404) {
415
- throw e;
416
- }
417
- }
418
- }));
419
-
420
- if (changes.length === 0) {
421
- return true;
422
- }
423
-
424
- drawTable(changes);
425
- if ((await getConfirmation()) === true) {
426
- return true;
427
- }
428
-
429
- success(`Successfully pushed 0 ${resourcePlural}.`);
430
- return false;
431
- }
432
-
433
- const getObjectChanges = (remote, local, index, what) => {
434
- const changes = [];
435
-
436
- if (remote[index] && local[index]) {
437
- for (let [service, status] of Object.entries(remote[index])) {
438
- const localValue = local[index][service];
439
- let valuesEqual = false;
440
-
441
- if (Array.isArray(status) && Array.isArray(localValue)) {
442
- valuesEqual = JSON.stringify(status) === JSON.stringify(localValue);
443
- } else {
444
- valuesEqual = status === localValue;
445
- }
446
-
447
- if (!valuesEqual) {
448
- changes.push({ group: what, setting: service, remote: chalk.red(status), local: chalk.green(localValue) })
449
- }
450
- }
451
- }
452
-
453
- return changes;
454
- }
455
-
456
- const createAttribute = (databaseId, collectionId, attribute) => {
457
- switch (attribute.type) {
458
- case 'string':
459
- switch (attribute.format) {
460
- case 'email':
461
- return databasesCreateEmailAttribute({
462
- databaseId,
463
- collectionId,
464
- key: attribute.key,
465
- required: attribute.required,
466
- xdefault: attribute.default,
467
- array: attribute.array,
468
- parseOutput: false
469
- })
470
- case 'url':
471
- return databasesCreateUrlAttribute({
472
- databaseId,
473
- collectionId,
474
- key: attribute.key,
475
- required: attribute.required,
476
- xdefault: attribute.default,
477
- array: attribute.array,
478
- parseOutput: false
479
- })
480
- case 'ip':
481
- return databasesCreateIpAttribute({
482
- databaseId,
483
- collectionId,
484
- key: attribute.key,
485
- required: attribute.required,
486
- xdefault: attribute.default,
487
- array: attribute.array,
488
- parseOutput: false
489
- })
490
- case 'enum':
491
- return databasesCreateEnumAttribute({
492
- databaseId,
493
- collectionId,
494
- key: attribute.key,
495
- elements: attribute.elements,
496
- required: attribute.required,
497
- xdefault: attribute.default,
498
- array: attribute.array,
499
- parseOutput: false
500
- })
501
- default:
502
- return databasesCreateStringAttribute({
503
- databaseId,
504
- collectionId,
505
- key: attribute.key,
506
- size: attribute.size,
507
- required: attribute.required,
508
- xdefault: attribute.default,
509
- array: attribute.array,
510
- encrypt: attribute.encrypt,
511
- parseOutput: false
512
- })
513
-
514
- }
515
- case 'integer':
516
- return databasesCreateIntegerAttribute({
517
- databaseId,
518
- collectionId,
519
- key: attribute.key,
520
- required: attribute.required,
521
- min: attribute.min,
522
- max: attribute.max,
523
- xdefault: attribute.default,
524
- array: attribute.array,
525
- parseOutput: false
526
- })
527
- case 'double':
528
- return databasesCreateFloatAttribute({
529
- databaseId,
530
- collectionId,
531
- key: attribute.key,
532
- required: attribute.required,
533
- min: attribute.min,
534
- max: attribute.max,
535
- xdefault: attribute.default,
536
- array: attribute.array,
537
- parseOutput: false
538
- })
539
- case 'boolean':
540
- return databasesCreateBooleanAttribute({
541
- databaseId,
542
- collectionId,
543
- key: attribute.key,
544
- required: attribute.required,
545
- xdefault: attribute.default,
546
- array: attribute.array,
547
- parseOutput: false
548
- })
549
- case 'datetime':
550
- return databasesCreateDatetimeAttribute({
551
- databaseId,
552
- collectionId,
553
- key: attribute.key,
554
- required: attribute.required,
555
- xdefault: attribute.default,
556
- array: attribute.array,
557
- parseOutput: false
558
- })
559
- case 'relationship':
560
- return databasesCreateRelationshipAttribute({
561
- databaseId,
562
- collectionId,
563
- relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
564
- type: attribute.relationType,
565
- twoWay: attribute.twoWay,
566
- key: attribute.key,
567
- twoWayKey: attribute.twoWayKey,
568
- onDelete: attribute.onDelete,
569
- parseOutput: false
570
- })
571
- case 'point':
572
- return databasesCreatePointAttribute({
573
- databaseId,
574
- collectionId,
575
- key:attribute.key,
576
- required:attribute.required,
577
- xdefault:attribute.default,
578
- parseOutput:false
579
- })
580
- case 'linestring':
581
- return databasesCreateLineAttribute({
582
- databaseId,
583
- collectionId,
584
- key:attribute.key,
585
- required:attribute.required,
586
- xdefault:attribute.default,
587
- parseOutput:false
588
- })
589
- case 'polygon':
590
- return databasesCreatePolygonAttribute({
591
- databaseId,
592
- collectionId,
593
- key:attribute.key,
594
- required:attribute.required,
595
- xdefault:attribute.default,
596
- parseOutput:false
597
- })
598
- default:
599
- throw new Error(`Unsupported attribute type: ${attribute.type}`);
600
- }
601
- }
602
-
603
- const updateAttribute = (databaseId, collectionId, attribute) => {
604
- switch (attribute.type) {
605
- case 'string':
606
- switch (attribute.format) {
607
- case 'email':
608
- return databasesUpdateEmailAttribute({
609
- databaseId,
610
- collectionId,
611
- key: attribute.key,
612
- required: attribute.required,
613
- xdefault: attribute.default,
614
- array: attribute.array,
615
- parseOutput: false
616
- })
617
- case 'url':
618
- return databasesUpdateUrlAttribute({
619
- databaseId,
620
- collectionId,
621
- key: attribute.key,
622
- required: attribute.required,
623
- xdefault: attribute.default,
624
- array: attribute.array,
625
- parseOutput: false
626
- })
627
- case 'ip':
628
- return databasesUpdateIpAttribute({
629
- databaseId,
630
- collectionId,
631
- key: attribute.key,
632
- required: attribute.required,
633
- xdefault: attribute.default,
634
- array: attribute.array,
635
- parseOutput: false
636
- })
637
- case 'enum':
638
- return databasesUpdateEnumAttribute({
639
- databaseId,
640
- collectionId,
641
- key: attribute.key,
642
- elements: attribute.elements,
643
- required: attribute.required,
644
- xdefault: attribute.default,
645
- array: attribute.array,
646
- parseOutput: false
647
- })
648
- default:
649
- return databasesUpdateStringAttribute({
650
- databaseId,
651
- collectionId,
652
- key: attribute.key,
653
- size: attribute.size,
654
- required: attribute.required,
655
- xdefault: attribute.default,
656
- array: attribute.array,
657
- parseOutput: false
658
- })
659
-
660
- }
661
- case 'integer':
662
- return databasesUpdateIntegerAttribute({
663
- databaseId,
664
- collectionId,
665
- key: attribute.key,
666
- required: attribute.required,
667
- min: attribute.min,
668
- max: attribute.max,
669
- xdefault: attribute.default,
670
- array: attribute.array,
671
- parseOutput: false
672
- })
673
- case 'double':
674
- return databasesUpdateFloatAttribute({
675
- databaseId,
676
- collectionId,
677
- key: attribute.key,
678
- required: attribute.required,
679
- min: attribute.min,
680
- max: attribute.max,
681
- xdefault: attribute.default,
682
- array: attribute.array,
683
- parseOutput: false
684
- })
685
- case 'boolean':
686
- return databasesUpdateBooleanAttribute({
687
- databaseId,
688
- collectionId,
689
- key: attribute.key,
690
- required: attribute.required,
691
- xdefault: attribute.default,
692
- array: attribute.array,
693
- parseOutput: false
694
- })
695
- case 'datetime':
696
- return databasesUpdateDatetimeAttribute({
697
- databaseId,
698
- collectionId,
699
- key: attribute.key,
700
- required: attribute.required,
701
- xdefault: attribute.default,
702
- array: attribute.array,
703
- parseOutput: false
704
- })
705
- case 'relationship':
706
- return databasesUpdateRelationshipAttribute({
707
- databaseId,
708
- collectionId,
709
- relatedCollectionId: attribute.relatedTable ?? attribute.relatedCollection,
710
- type: attribute.relationType,
711
- twoWay: attribute.twoWay,
712
- key: attribute.key,
713
- twoWayKey: attribute.twoWayKey,
714
- onDelete: attribute.onDelete,
715
- parseOutput: false
716
- })
717
- case 'point':
718
- return databasesUpdatePointAttribute({
719
- databaseId,
720
- collectionId,
721
- key:attribute.key,
722
- required:attribute.required,
723
- xdefault:attribute.default,
724
- parseOutput:false
725
- })
726
- case 'linestring':
727
- return databasesUpdateLineAttribute({
728
- databaseId,
729
- collectionId,
730
- key:attribute.key,
731
- required:attribute.required,
732
- xdefault:attribute.default,
733
- parseOutput:false
734
- })
735
- case 'polygon':
736
- return databasesUpdatePolygonAttribute({
737
- databaseId,
738
- collectionId,
739
- key:attribute.key,
740
- required:attribute.required,
741
- xdefault:attribute.default,
742
- parseOutput:false
743
- })
744
- default:
745
- throw new Error(`Unsupported attribute type: ${attribute.type}`);
746
- }
747
- }
748
- const deleteAttribute = async (collection, attribute, isIndex = false) => {
749
- log(`Deleting ${isIndex ? 'index' : 'attribute'} ${attribute.key} of ${collection.name} ( ${collection['$id']} )`);
750
-
751
- if (isIndex) {
752
- await databasesDeleteIndex({
753
- databaseId: collection['databaseId'],
754
- collectionId: collection['$id'],
755
- key: attribute.key,
756
- parseOutput: false
757
- });
758
- return;
759
- }
760
-
761
- await databasesDeleteAttribute({
762
- databaseId: collection['databaseId'],
763
- collectionId: collection['$id'],
764
- key: attribute.key,
765
- parseOutput: false
766
- });
767
- }
768
-
769
- const isEqual = (a, b) => {
770
- if (a === b) return true;
771
-
772
- if (a && b && typeof a === 'object' && typeof b === 'object') {
773
- if (a.constructor && a.constructor.name === 'BigNumber' &&
774
- b.constructor && b.constructor.name === 'BigNumber') {
775
- return a.eq(b);
776
- }
777
-
778
- if (typeof a.equals === 'function') {
779
- return a.equals(b);
780
- }
781
-
782
- if (typeof a.eq === 'function') {
783
- return a.eq(b);
784
- }
785
- }
786
-
787
- if (typeof a === 'number' && typeof b === 'number') {
788
- if (isNaN(a) && isNaN(b)) return true;
789
- if (!isFinite(a) && !isFinite(b)) return a === b;
790
- return Math.abs(a - b) < Number.EPSILON;
791
- }
792
-
793
- return false;
794
- };
795
-
796
- const compareAttribute = (remote, local, reason, key) => {
797
- if (isEmpty(remote) && isEmpty(local)) {
798
- return reason;
799
- }
800
-
801
- if (Array.isArray(remote) && Array.isArray(local)) {
802
- if (JSON.stringify(remote) !== JSON.stringify(local)) {
803
- const bol = reason === '' ? '' : '\n';
804
- reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
805
- }
806
- } else if (!isEqual(remote, local)) {
807
- const bol = reason === '' ? '' : '\n';
808
- reason += `${bol}${key} changed from ${chalk.red(remote)} to ${chalk.green(local)}`;
809
- }
810
-
811
- return reason
812
- }
813
-
814
-
815
- /**
816
- * Check if attribute non-changeable fields has been changed
817
- * If so return the differences as an object.
818
- * @param remote
819
- * @param local
820
- * @param collection
821
- * @param recreating when true will check only non-changeable keys
822
- * @returns {undefined|{reason: string, action: *, attribute, key: string}}
823
- */
824
- const checkAttributeChanges = (remote, local, collection, recreating = true) => {
825
- if (local === undefined) {
826
- return undefined;
827
- }
828
-
829
- const keyName = `${chalk.yellow(local.key)} in ${collection.name} (${collection['$id']})`;
830
- const action = chalk.cyan(recreating ? 'recreating' : 'changing');
831
- let reason = '';
832
- let attribute = recreating ? remote : local;
833
-
834
- for (let key of Object.keys(remote)) {
835
- if (!KeysAttributes.has(key)) {
836
- continue;
837
- }
838
-
839
- if (changeableKeys.includes(key)) {
840
- if (!recreating) {
841
- reason = compareAttribute(remote[key], local[key], reason, key)
842
- }
843
- continue;
844
- }
845
-
846
- if (!recreating) {
847
- continue;
848
- }
849
-
850
- reason = compareAttribute(remote[key], local[key], reason, key)
851
- }
852
-
853
- return reason === '' ? undefined : { key: keyName, attribute, reason, action };
854
- }
855
-
856
- /**
857
- * Check if attributes contain the given attribute
858
- * @param attribute
859
- * @param attributes
860
- * @returns {*}
861
- */
862
- const attributesContains = (attribute, attributes) => attributes.find((attr) => attr.key === attribute.key);
863
- const generateChangesObject = (attribute, collection, isAdding) => {
864
- return {
865
- key: `${chalk.yellow(attribute.key)} in ${collection.name} (${collection['$id']})`,
866
- attribute: attribute,
867
- reason: isAdding ? 'Field isn\'t present on the remote server' : 'Field isn\'t present on the appwrite.config.json file',
868
- action: isAdding ? chalk.green('adding') : chalk.red('deleting')
869
- };
870
-
871
- };
872
-
873
- /**
874
- * Filter deleted and recreated attributes,
875
- * return list of attributes to create
876
- * @returns {Promise<*|*[]>}
877
- */
878
- const attributesToCreate = async (remoteAttributes, localAttributes, collection, isIndex = false) => {
879
-
880
- const deleting = remoteAttributes.filter((attribute) => !attributesContains(attribute, localAttributes)).map((attr) => generateChangesObject(attr, collection, false));
881
- const adding = localAttributes.filter((attribute) => !attributesContains(attribute, remoteAttributes)).map((attr) => generateChangesObject(attr, collection, true));
882
- const conflicts = remoteAttributes.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection)).filter(attribute => attribute !== undefined);
883
- const changes = remoteAttributes.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection, false))
884
- .filter(attribute => attribute !== undefined)
885
- .filter(attribute => conflicts.filter(attr => attribute.key === attr.key).length !== 1);
886
-
887
- let changedAttributes = [];
888
- const changing = [...deleting, ...adding, ...conflicts, ...changes]
889
- if (changing.length === 0) {
890
- return changedAttributes;
891
- }
892
-
893
- log(!cliConfig.force ? 'There are pending changes in your collection deployment' : 'List of applied changes');
894
-
895
- drawTable(changing.map((change) => {
896
- return { Key: change.key, Action: change.action, Reason: change.reason, };
897
- }));
898
-
899
- if (!cliConfig.force) {
900
- if (deleting.length > 0 && !isIndex) {
901
- console.log(`${chalk.red('------------------------------------------------------')}`);
902
- console.log(`${chalk.red('| WARNING: Attribute deletion may cause loss of data |')}`);
903
- console.log(`${chalk.red('------------------------------------------------------')}`);
904
- console.log();
905
- }
906
- if (conflicts.length > 0 && !isIndex) {
907
- console.log(`${chalk.red('--------------------------------------------------------')}`);
908
- console.log(`${chalk.red('| WARNING: Attribute recreation may cause loss of data |')}`);
909
- console.log(`${chalk.red('--------------------------------------------------------')}`);
910
- console.log();
911
- }
912
-
913
- if ((await getConfirmation()) !== true) {
914
- return changedAttributes;
915
- }
916
- }
917
-
918
- if (conflicts.length > 0) {
919
- changedAttributes = conflicts.map((change) => change.attribute);
920
- await Promise.all(changedAttributes.map((changed) => deleteAttribute(collection, changed, isIndex)));
921
- remoteAttributes = remoteAttributes.filter((attribute) => !attributesContains(attribute, changedAttributes))
922
- }
923
-
924
- if (changes.length > 0) {
925
- changedAttributes = changes.map((change) => change.attribute);
926
- await Promise.all(changedAttributes.map((changed) => updateAttribute(collection['databaseId'], collection['$id'], changed)));
927
- }
928
-
929
- const deletingAttributes = deleting.map((change) => change.attribute);
930
- await Promise.all(deletingAttributes.map((attribute) => deleteAttribute(collection, attribute, isIndex)));
931
- const attributeKeys = [...remoteAttributes.map(attribute => attribute.key), ...deletingAttributes.map(attribute => attribute.key)]
932
-
933
- if (attributeKeys.length) {
934
- const deleteAttributesPoolStatus = await awaitPools.deleteAttributes(collection['databaseId'], collection['$id'], attributeKeys);
935
-
936
- if (!deleteAttributesPoolStatus) {
937
- throw new Error("Attribute deletion timed out.");
938
- }
939
- }
940
-
941
- return localAttributes.filter((attribute) => !attributesContains(attribute, remoteAttributes));
942
- }
943
- const createIndexes = async (indexes, collection) => {
944
- log(`Creating indexes ...`)
945
-
946
- for (let index of indexes) {
947
- await databasesCreateIndex({
948
- databaseId: collection['databaseId'],
949
- collectionId: collection['$id'],
950
- key: index.key,
951
- type: index.type,
952
- attributes: index.columns ?? index.attributes,
953
- orders: index.orders,
954
- parseOutput: false
955
- });
956
- }
957
-
958
- const result = await awaitPools.expectIndexes(
959
- collection['databaseId'],
960
- collection['$id'],
961
- indexes.map(index => index.key)
962
- );
963
-
964
- if (!result) {
965
- throw new Error('Index creation timed out.');
966
- }
967
-
968
- success(`Created ${indexes.length} indexes`);
969
- }
970
- const createAttributes = async (attributes, collection) => {
971
- for (let attribute of attributes) {
972
- if (attribute.side !== 'child') {
973
- await createAttribute(collection['databaseId'], collection['$id'], attribute);
974
- }
975
- }
976
-
977
- const result = await awaitPools.expectAttributes(
978
- collection['databaseId'],
979
- collection['$id'],
980
- collection.attributes.filter(attribute => attribute.side !== 'child').map(attribute => attribute.key)
981
- );
982
-
983
- if (!result) {
984
- throw new Error(`Attribute creation timed out.`);
985
- }
986
-
987
- success(`Created ${attributes.length} attributes`);
988
- }
989
- const createColumns = async (columns, table) => {
990
- for (let column of columns) {
991
- if (column.side !== 'child') {
992
- await createAttribute(table['databaseId'], table['$id'], column);
993
- }
994
- }
995
-
996
- const result = await awaitPools.expectAttributes(
997
- table['databaseId'],
998
- table['$id'],
999
- table.columns.filter(column => column.side !== 'child').map(column => column.key)
1000
- );
1001
-
1002
- if (!result) {
1003
- throw new Error(`Column creation timed out.`);
1004
- }
1005
-
1006
- success(`Created ${columns.length} columns`);
1007
- }
1008
-
1009
- const pushResources = async () => {
1010
- const actions = {
1011
- settings: pushSettings,
1012
- functions: pushFunction,
1013
- sites: pushSite,
1014
- collections: pushCollection,
1015
- tables: pushTable,
1016
- buckets: pushBucket,
1017
- teams: pushTeam,
1018
- messages: pushMessagingTopic
1019
- }
1020
-
1021
- if (cliConfig.all) {
1022
- for (let action of Object.values(actions)) {
1023
- await action({ returnOnZero: true });
1024
- }
1025
- } else {
1026
- const answers = await inquirer.prompt(questionsPushResources[0]);
1027
-
1028
- const action = actions[answers.resource];
1029
- if (action !== undefined) {
1030
- await action({ returnOnZero: true });
1031
- }
1032
- }
1033
- };
1034
-
1035
- const pushSettings = async () => {
1036
- checkDeployConditions(localConfig);
1037
-
1038
- try {
1039
- let response = await projectsGet({
1040
- parseOutput: false,
1041
- projectId: localConfig.getProject().projectId
1042
- });
1043
-
1044
- const remoteSettings = localConfig.createSettingsObject(response ?? {});
1045
- const localSettings = localConfig.getProject().projectSettings ?? {};
1046
-
1047
- log('Checking for changes ...');
1048
- const changes = [];
1049
-
1050
- changes.push(...(getObjectChanges(remoteSettings, localSettings, 'services', 'Service')));
1051
- changes.push(...(getObjectChanges(remoteSettings['auth'] ?? {}, localSettings['auth'] ?? {}, 'methods', 'Auth method')));
1052
- changes.push(...(getObjectChanges(remoteSettings['auth'] ?? {}, localSettings['auth'] ?? {}, 'security', 'Auth security')));
1053
-
1054
- if (changes.length > 0) {
1055
- drawTable(changes);
1056
- if ((await getConfirmation()) !== true) {
1057
- success(`Successfully pushed 0 project settings.`);
1058
- return;
1059
- }
1060
- }
1061
- } catch (e) {
1062
- }
1063
-
1064
- try {
1065
- log("Pushing project settings ...");
1066
-
1067
- const projectId = localConfig.getProject().projectId;
1068
- const projectName = localConfig.getProject().projectName;
1069
- const settings = localConfig.getProject().projectSettings ?? {};
1070
-
1071
- if (projectName) {
1072
- log("Applying project name ...");
1073
- await projectsUpdate({
1074
- projectId,
1075
- name: projectName,
1076
- parseOutput: false
1077
- });
1078
- }
1079
-
1080
- if (settings.services) {
1081
- log("Applying service statuses ...");
1082
- for (let [service, status] of Object.entries(settings.services)) {
1083
- await projectsUpdateServiceStatus({
1084
- projectId,
1085
- service,
1086
- status,
1087
- parseOutput: false
1088
- });
1089
- }
1090
- }
1091
-
1092
- if (settings.auth) {
1093
- if (settings.auth.security) {
1094
- log("Applying auth security settings ...");
1095
- await projectsUpdateAuthDuration({ projectId, duration: settings.auth.security.duration, parseOutput: false });
1096
- await projectsUpdateAuthLimit({ projectId, limit: settings.auth.security.limit, parseOutput: false });
1097
- await projectsUpdateAuthSessionsLimit({ projectId, limit: settings.auth.security.sessionsLimit, parseOutput: false });
1098
- await projectsUpdateAuthPasswordDictionary({ projectId, enabled: settings.auth.security.passwordDictionary, parseOutput: false });
1099
- await projectsUpdateAuthPasswordHistory({ projectId, limit: settings.auth.security.passwordHistory, parseOutput: false });
1100
- await projectsUpdatePersonalDataCheck({ projectId, enabled: settings.auth.security.personalDataCheck, parseOutput: false });
1101
- await projectsUpdateSessionAlerts({ projectId, alerts: settings.auth.security.sessionAlerts, parseOutput: false });
1102
- await projectsUpdateMockNumbers({ projectId, numbers: settings.auth.security.mockNumbers, parseOutput: false });
1103
- }
1104
-
1105
- if (settings.auth.methods) {
1106
- log("Applying auth methods statuses ...");
1107
-
1108
- for (let [method, status] of Object.entries(settings.auth.methods)) {
1109
- await projectsUpdateAuthStatus({
1110
- projectId,
1111
- method,
1112
- status,
1113
- parseOutput: false
1114
- });
1115
- }
1116
- }
1117
- }
1118
-
1119
- success(`Successfully pushed ${chalk.bold('all')} project settings.`);
1120
- } catch (e) {
1121
- throw e;
1122
- }
1123
- }
1124
-
1125
- const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero: false }) => {
1126
- process.chdir(localConfig.configDirectoryPath)
1127
-
1128
- const siteIds = [];
1129
-
1130
- if(siteId) {
1131
- siteIds.push(siteId);
1132
- } else if (cliConfig.all) {
1133
- checkDeployConditions(localConfig);
1134
- const sites = localConfig.getSites();
1135
- siteIds.push(...sites.map((site) => {
1136
- return site.$id;
1137
- }));
1138
- }
1139
-
1140
- if (siteIds.length <= 0) {
1141
- const answers = await inquirer.prompt(questionsPushSites[0]);
1142
- if (answers.sites) {
1143
- siteIds.push(...answers.sites);
1144
- }
1145
- }
1146
-
1147
- if (siteIds.length === 0) {
1148
- log("No sites found.");
1149
- hint("Use 'appwrite pull sites' to synchronize existing one, or use 'appwrite init site' to create a new one.");
1150
- return;
1151
- }
1152
-
1153
- let sites = siteIds.map((id) => {
1154
- const sites = localConfig.getSites();
1155
- const site = sites.find((s) => s.$id === id);
1156
-
1157
- if (!site) {
1158
- throw new Error("Site '" + id + "' not found.")
1159
- }
1160
-
1161
- return site;
1162
- });
1163
-
1164
- log('Validating sites ...');
1165
- // Validation is done BEFORE pushing so the deployment process can be run in async with progress update
1166
- for (let site of sites) {
1167
-
1168
- if (!site.buildCommand) {
1169
- log(`Site ${site.name} is missing build command.`);
1170
- const answers = await inquirer.prompt(questionsGetBuildCommand)
1171
- site.buildCommand = answers.buildCommand;
1172
- localConfig.addSite(site);
1173
- }
1174
- }
1175
-
1176
- if (!(await approveChanges(sites, sitesGet, KeysSite, 'siteId', 'sites', ['vars']))) {
1177
- return;
1178
- }
1179
-
1180
- log('Pushing sites ...');
1181
-
1182
- Spinner.start(false);
1183
- let successfullyPushed = 0;
1184
- let successfullyDeployed = 0;
1185
- const failedDeployments = [];
1186
- const errors = [];
1187
-
1188
- await Promise.all(sites.map(async (site) => {
1189
- let response = {};
1190
-
1191
- const ignore = site.ignore ? 'appwrite.config.json' : '.gitignore';
1192
- let siteExists = false;
1193
- let deploymentCreated = false;
1194
-
1195
- const updaterRow = new Spinner({ status: '', resource: site.name, id: site['$id'], end: `Ignoring using: ${ignore}` });
1196
-
1197
- updaterRow.update({ status: 'Getting' }).startSpinner(SPINNER_DOTS);
1198
-
1199
- try {
1200
- response = await sitesGet({
1201
- siteId: site['$id'],
1202
- parseOutput: false,
1203
- });
1204
- siteExists = true;
1205
- if (response.framework !== site.framework) {
1206
- updaterRow.fail({ errorMessage: `Framework mismatch! (local=${site.framework},remote=${response.framework}) Please delete remote site or update your appwrite.config.json` })
1207
- return;
1208
- }
1209
-
1210
- updaterRow.update({ status: 'Updating' }).replaceSpinner(SPINNER_ARC);
1211
-
1212
- response = await sitesUpdate({
1213
- siteId: site['$id'],
1214
- name: site.name,
1215
- framework: site.framework,
1216
- buildRuntime: site.buildRuntime,
1217
- specification: site.specification,
1218
- timeout: site.timeout,
1219
- enabled: site.enabled,
1220
- logging: site.logging,
1221
- adapter: site.adapter,
1222
- buildCommand: site.buildCommand,
1223
- installCommand: site.installCommand,
1224
- outputDirectory: site.outputDirectory,
1225
- fallbackFile: site.fallbackFile,
1226
- vars: JSON.stringify(response.vars),
1227
- parseOutput: false
1228
- });
1229
- } catch (e) {
1230
-
1231
- if (Number(e.code) === 404) {
1232
- siteExists = false;
1233
- } else {
1234
- errors.push(e);
1235
- updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1236
- return;
1237
- }
1238
- }
1239
-
1240
- if (!siteExists) {
1241
- updaterRow.update({ status: 'Creating' }).replaceSpinner(SPINNER_DOTS);
1242
-
1243
- try {
1244
- response = await sitesCreate({
1245
- siteId: site.$id,
1246
- name: site.name,
1247
- framework: site.framework,
1248
- specification: site.specification,
1249
- buildRuntime: site.buildRuntime,
1250
- buildCommand: site.buildCommand,
1251
- installCommand: site.installCommand,
1252
- outputDirectory: site.outputDirectory,
1253
- fallbackFile: site.fallbackFile,
1254
- adapter: site.adapter,
1255
- timeout: site.timeout,
1256
- enabled: site.enabled,
1257
- logging: site.logging,
1258
- parseOutput: false
1259
- });
1260
-
1261
- let domain = '';
1262
- try {
1263
- const variables = await consoleVariables({ parseOutput: false, sdk: await sdkForConsole() });
1264
- domain = ID.unique() + '.' + variables['_APP_DOMAIN_SITES'];
1265
- } catch (error) {
1266
- console.error('Error fetching console variables.');
1267
- throw error;
1268
- }
1269
-
1270
- try {
1271
- const rule = await proxyCreateSiteRule(
1272
- {
1273
- domain: domain,
1274
- siteId: site.$id
1275
- }
1276
- );
1277
- } catch (error) {
1278
- console.error('Error creating site rule.');
1279
- throw error;
1280
- }
1281
-
1282
- updaterRow.update({ status: 'Created' });
1283
- } catch (e) {
1284
- errors.push(e)
1285
- updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1286
- return;
1287
- }
1288
- }
1289
-
1290
- if (withVariables) {
1291
- updaterRow.update({ status: 'Creating variables' }).replaceSpinner(SPINNER_ARC);
1292
-
1293
- const { variables } = await paginate(sitesListVariables, {
1294
- siteId: site['$id'],
1295
- parseOutput: false
1296
- }, 100, 'variables');
1297
-
1298
- await Promise.all(variables.map(async variable => {
1299
- await sitesDeleteVariable({
1300
- siteId: site['$id'],
1301
- variableId: variable['$id'],
1302
- parseOutput: false
1303
- });
1304
- }));
1305
-
1306
- const envFileLocation = `${site['path']}/.env`;
1307
- let envVariables = [];
1308
- try {
1309
- if (fs.existsSync(envFileLocation)) {
1310
- const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
1311
- envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
1312
- }
1313
- } catch (error) {
1314
- // Handle parsing errors gracefully
1315
- envVariables = [];
1316
- }
1317
- await Promise.all(envVariables.map(async variable => {
1318
- await sitesCreateVariable({
1319
- siteId: site['$id'],
1320
- key: variable.key,
1321
- value: variable.value,
1322
- parseOutput: false,
1323
- secret: false
1324
- });
1325
- }));
1326
- }
1327
-
1328
- if (code === false) {
1329
- successfullyPushed++;
1330
- successfullyDeployed++;
1331
- updaterRow.update({ status: 'Pushed' });
1332
- updaterRow.stopSpinner();
1333
- return;
1334
- }
1335
-
1336
- try {
1337
- updaterRow.update({ status: 'Pushing' }).replaceSpinner(SPINNER_ARC);
1338
- response = await sitesCreateDeployment({
1339
- siteId: site['$id'],
1340
- buildCommand: site.buildCommand,
1341
- installCommand: site.installCommand,
1342
- outputDirectory: site.outputDirectory,
1343
- fallbackFile: site.fallbackFile,
1344
- code: site.path,
1345
- activate: true,
1346
- parseOutput: false
1347
- })
1348
-
1349
- updaterRow.update({ status: 'Pushed' });
1350
- deploymentCreated = true;
1351
- successfullyPushed++;
1352
- } catch (e) {
1353
- errors.push(e);
1354
-
1355
- switch (e.code) {
1356
- case 'ENOENT':
1357
- updaterRow.fail({ errorMessage: 'Not found in the current directory. Skipping...' })
1358
- break;
1359
- default:
1360
- updaterRow.fail({ errorMessage: e.message ?? 'An unknown error occurred. Please try again.' })
1361
- }
1362
- }
1363
-
1364
- if (deploymentCreated && !async) {
1365
- try {
1366
- const deploymentId = response['$id'];
1367
- updaterRow.update({ status: 'Deploying', end: 'Checking deployment status...' })
1368
- let pollChecks = 0;
1369
-
1370
- while (true) {
1371
- response = await sitesGetDeployment({
1372
- siteId: site['$id'],
1373
- deploymentId: deploymentId,
1374
- parseOutput: false
1375
- });
1376
-
1377
- const status = response['status'];
1378
- if (status === 'ready') {
1379
- successfullyDeployed++;
1380
-
1381
- let url = '';
1382
- const res = await proxyListRules({
1383
- parseOutput: false,
1384
- queries: [
1385
- JSON.stringify({ method: 'limit', values: [1] }),
1386
- JSON.stringify({ method: 'equal', "attribute": "deploymentResourceType", "values": ["site"] }),
1387
- JSON.stringify({ method: 'equal', "attribute": "deploymentResourceId", "values": [site['$id']] }),
1388
- JSON.stringify({ method: 'equal', "attribute": "trigger", "values": ["manual"] }),
1389
- ],
1390
- });
1391
-
1392
- if (Number(res.total) === 1) {
1393
- url = res.rules[0].domain;
1394
- }
1395
-
1396
- updaterRow.update({ status: 'Deployed', end: url });
1397
-
1398
- break;
1399
- } else if (status === 'failed') {
1400
- failedDeployments.push({ name: site['name'], $id: site['$id'], deployment: response['$id'] });
1401
- updaterRow.fail({ errorMessage: `Failed to deploy` });
1402
-
1403
- break;
1404
- } else {
1405
- updaterRow.update({ status: 'Deploying', end: `Current status: ${status}` })
1406
- }
1407
-
1408
- pollChecks++;
1409
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
1410
- }
1411
- } catch (e) {
1412
- errors.push(e);
1413
- updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
1414
- }
1415
- }
1416
-
1417
- updaterRow.stopSpinner();
1418
- }));
1419
-
1420
- Spinner.stop();
1421
-
1422
- failedDeployments.forEach((failed) => {
1423
- const { name, deployment, $id } = failed;
1424
- const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/sites/site-${$id}/deployments/deployment-${deployment}`;
1425
-
1426
- error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1427
- });
1428
-
1429
- if (!async) {
1430
- if (successfullyPushed === 0) {
1431
- error('No sites were pushed.');
1432
- } else if (successfullyDeployed !== successfullyPushed) {
1433
- warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} sites`)
1434
- } else {
1435
- success(`Successfully pushed ${successfullyPushed} sites.`);
1436
- }
1437
- } else {
1438
- success(`Successfully pushed ${successfullyPushed} sites.`);
1439
- }
1440
-
1441
- if (cliConfig.verbose) {
1442
- errors.forEach(e => {
1443
- console.error(e);
1444
- })
1445
- }
1446
- }
1447
-
1448
- const pushFunction = async ({ functionId, async, code, withVariables } = { returnOnZero: false }) => {
1449
- process.chdir(localConfig.configDirectoryPath)
1450
-
1451
- const functionIds = [];
1452
-
1453
- if (functionId) {
1454
- functionIds.push(functionId);
1455
- } else if (cliConfig.all) {
1456
- checkDeployConditions(localConfig);
1457
- const functions = localConfig.getFunctions();
1458
- functionIds.push(...functions.map((func) => {
1459
- return func.$id;
1460
- }));
1461
- }
1462
-
1463
- if (functionIds.length <= 0) {
1464
- const answers = await inquirer.prompt(questionsPushFunctions[0]);
1465
- if (answers.functions) {
1466
- functionIds.push(...answers.functions);
1467
- }
1468
- }
1469
-
1470
- if (functionIds.length === 0) {
1471
- log("No functions found.");
1472
- hint("Use 'appwrite pull functions' to synchronize existing one, or use 'appwrite init function' to create a new one.");
1473
- return;
1474
- }
1475
-
1476
- let functions = functionIds.map((id) => {
1477
- const functions = localConfig.getFunctions();
1478
- const func = functions.find((f) => f.$id === id);
1479
-
1480
- if (!func) {
1481
- throw new Error("Function '" + id + "' not found.")
1482
- }
1483
-
1484
- return func;
1485
- });
1486
-
1487
- log('Validating functions ...');
1488
- // Validation is done BEFORE pushing so the deployment process can be run in async with progress update
1489
- for (let func of functions) {
1490
-
1491
- if (!func.entrypoint) {
1492
- log(`Function ${func.name} is missing an entrypoint.`);
1493
- const answers = await inquirer.prompt(questionsGetEntrypoint)
1494
- func.entrypoint = answers.entrypoint;
1495
- localConfig.addFunction(func);
1496
- }
1497
- }
1498
-
1499
- if (!(await approveChanges(functions, functionsGet, KeysFunction, 'functionId', 'functions', ['vars']))) {
1500
- return;
1501
- }
1502
-
1503
- log('Pushing functions ...');
1504
-
1505
- Spinner.start(false);
1506
- let successfullyPushed = 0;
1507
- let successfullyDeployed = 0;
1508
- const failedDeployments = [];
1509
- const errors = [];
1510
-
1511
- await Promise.all(functions.map(async (func) => {
1512
- let response = {};
1513
-
1514
- const ignore = func.ignore ? 'appwrite.config.json' : '.gitignore';
1515
- let functionExists = false;
1516
- let deploymentCreated = false;
1517
-
1518
- const updaterRow = new Spinner({ status: '', resource: func.name, id: func['$id'], end: `Ignoring using: ${ignore}` });
1519
-
1520
- updaterRow.update({ status: 'Getting' }).startSpinner(SPINNER_DOTS);
1521
- try {
1522
- response = await functionsGet({
1523
- functionId: func['$id'],
1524
- parseOutput: false,
1525
- });
1526
- functionExists = true;
1527
- if (response.runtime !== func.runtime) {
1528
- updaterRow.fail({ errorMessage: `Runtime mismatch! (local=${func.runtime},remote=${response.runtime}) Please delete remote function or update your appwrite.config.json` })
1529
- return;
1530
- }
1531
-
1532
- updaterRow.update({ status: 'Updating' }).replaceSpinner(SPINNER_ARC);
1533
-
1534
- response = await functionsUpdate({
1535
- functionId: func['$id'],
1536
- name: func.name,
1537
- specification: func.specification,
1538
- execute: func.execute,
1539
- events: func.events,
1540
- schedule: func.schedule,
1541
- timeout: func.timeout,
1542
- enabled: func.enabled,
1543
- logging: func.logging,
1544
- entrypoint: func.entrypoint,
1545
- commands: func.commands,
1546
- scopes: func.scopes,
1547
- vars: JSON.stringify(response.vars),
1548
- parseOutput: false
1549
- });
1550
- } catch (e) {
1551
-
1552
- if (Number(e.code) === 404) {
1553
- functionExists = false;
1554
- } else {
1555
- errors.push(e);
1556
- updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1557
- return;
1558
- }
1559
- }
1560
-
1561
- if (!functionExists) {
1562
- updaterRow.update({ status: 'Creating' }).replaceSpinner(SPINNER_DOTS);
1563
-
1564
- try {
1565
- response = await functionsCreate({
1566
- functionId: func.$id,
1567
- name: func.name,
1568
- runtime: func.runtime,
1569
- specification: func.specification,
1570
- execute: func.execute,
1571
- events: func.events,
1572
- schedule: func.schedule,
1573
- timeout: func.timeout,
1574
- enabled: func.enabled,
1575
- logging: func.logging,
1576
- entrypoint: func.entrypoint,
1577
- commands: func.commands,
1578
- scopes: func.scopes,
1579
- parseOutput: false
1580
- });
1581
-
1582
- let domain = '';
1583
- try {
1584
- const variables = await consoleVariables({ parseOutput: false, sdk: await sdkForConsole() });
1585
- domain = ID.unique() + '.' + variables['_APP_DOMAIN_FUNCTIONS'];
1586
- } catch (error) {
1587
- console.error('Error fetching console variables.');
1588
- throw error;
1589
- }
1590
-
1591
- try {
1592
- const rule = await proxyCreateFunctionRule(
1593
- {
1594
- domain: domain,
1595
- functionId: func.$id
1596
- }
1597
- );
1598
- } catch (error) {
1599
- console.error('Error creating function rule.');
1600
- throw error;
1601
- }
1602
-
1603
- updaterRow.update({ status: 'Created' });
1604
- } catch (e) {
1605
- errors.push(e)
1606
- updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1607
- return;
1608
- }
1609
- }
1610
-
1611
- if (withVariables) {
1612
- updaterRow.update({ status: 'Updating variables' }).replaceSpinner(SPINNER_ARC);
1613
-
1614
- const { variables } = await paginate(functionsListVariables, {
1615
- functionId: func['$id'],
1616
- parseOutput: false
1617
- }, 100, 'variables');
1618
-
1619
- await Promise.all(variables.map(async variable => {
1620
- await functionsDeleteVariable({
1621
- functionId: func['$id'],
1622
- variableId: variable['$id'],
1623
- parseOutput: false
1624
- });
1625
- }));
1626
-
1627
- const envFileLocation = `${func['path']}/.env`;
1628
- let envVariables = [];
1629
- try {
1630
- if (fs.existsSync(envFileLocation)) {
1631
- const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
1632
- envVariables = Object.entries(envObject || {}).map(([key, value]) => ({ key, value }));
1633
- }
1634
- } catch (error) {
1635
- // Handle parsing errors gracefully
1636
- envVariables = [];
1637
- }
1638
- await Promise.all(envVariables.map(async variable => {
1639
- await functionsCreateVariable({
1640
- functionId: func['$id'],
1641
- variableId: ID.unique(),
1642
- key: variable.key,
1643
- value: variable.value,
1644
- parseOutput: false,
1645
- secret: false
1646
- });
1647
- }));
1648
- }
1649
-
1650
- if (code === false) {
1651
- successfullyPushed++;
1652
- successfullyDeployed++;
1653
- updaterRow.update({ status: 'Pushed' });
1654
- updaterRow.stopSpinner();
1655
- return;
1656
- }
1657
-
1658
- try {
1659
- updaterRow.update({ status: 'Pushing' }).replaceSpinner(SPINNER_ARC);
1660
- response = await functionsCreateDeployment({
1661
- functionId: func['$id'],
1662
- entrypoint: func.entrypoint,
1663
- commands: func.commands,
1664
- code: func.path,
1665
- activate: true,
1666
- parseOutput: false
1667
- })
1668
-
1669
- updaterRow.update({ status: 'Pushed' });
1670
- deploymentCreated = true;
1671
- successfullyPushed++;
1672
- } catch (e) {
1673
- errors.push(e);
1674
-
1675
- switch (e.code) {
1676
- case 'ENOENT':
1677
- updaterRow.fail({ errorMessage: 'Not found in the current directory. Skipping...' })
1678
- break;
1679
- default:
1680
- updaterRow.fail({ errorMessage: e.message ?? 'An unknown error occurred. Please try again.' })
1681
- }
1682
- }
1683
-
1684
- if (deploymentCreated && !async) {
1685
- try {
1686
- const deploymentId = response['$id'];
1687
- updaterRow.update({ status: 'Deploying', end: 'Checking deployment status...' })
1688
- let pollChecks = 0;
1689
-
1690
- while (true) {
1691
- response = await functionsGetDeployment({
1692
- functionId: func['$id'],
1693
- deploymentId: deploymentId,
1694
- parseOutput: false
1695
- });
1696
-
1697
-
1698
- const status = response['status'];
1699
- if (status === 'ready') {
1700
- successfullyDeployed++;
1701
-
1702
- let url = '';
1703
- const res = await proxyListRules({
1704
- parseOutput: false,
1705
- queries: [
1706
- JSON.stringify({ method: 'limit', values: [1] }),
1707
- JSON.stringify({ method: 'equal', "attribute": "deploymentResourceType", "values": ["function"] }),
1708
- JSON.stringify({ method: 'equal', "attribute": "deploymentResourceId", "values": [func['$id']] }),
1709
- JSON.stringify({ method: 'equal', "attribute": "trigger", "values": ["manual"] }),
1710
- ],
1711
- });
1712
-
1713
- if (Number(res.total) === 1) {
1714
- url = res.rules[0].domain;
1715
- }
1716
-
1717
- updaterRow.update({ status: 'Deployed', end: url });
1718
-
1719
- break;
1720
- } else if (status === 'failed') {
1721
- failedDeployments.push({ name: func['name'], $id: func['$id'], deployment: response['$id'] });
1722
- updaterRow.fail({ errorMessage: `Failed to deploy` });
1723
-
1724
- break;
1725
- } else {
1726
- updaterRow.update({ status: 'Deploying', end: `Current status: ${status}` })
1727
- }
1728
-
1729
- pollChecks++;
1730
- await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
1731
- }
1732
- } catch (e) {
1733
- errors.push(e);
1734
- updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
1735
- }
1736
- }
1737
-
1738
- updaterRow.stopSpinner();
1739
- }));
1740
-
1741
- Spinner.stop();
1742
-
1743
- failedDeployments.forEach((failed) => {
1744
- const { name, deployment, $id } = failed;
1745
- const failUrl = `${globalConfig.getEndpoint().slice(0, -3)}/console/project-${localConfig.getProject().projectId}/functions/function-${$id}/deployment-${deployment}`;
1746
-
1747
- error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1748
- });
1749
-
1750
- if (!async) {
1751
- if (successfullyPushed === 0) {
1752
- error('No functions were pushed.');
1753
- } else if (successfullyDeployed !== successfullyPushed) {
1754
- warn(`Successfully pushed ${successfullyDeployed} of ${successfullyPushed} functions`)
1755
- } else {
1756
- success(`Successfully pushed ${successfullyPushed} functions.`);
1757
- }
1758
- } else {
1759
- success(`Successfully pushed ${successfullyPushed} functions.`);
1760
- }
1761
-
1762
- if (cliConfig.verbose) {
1763
- errors.forEach(e => {
1764
- console.error(e);
1765
- })
1766
- }
1767
- }
1768
-
1769
- const checkAndApplyTablesDBChanges = async () => {
1770
- log('Checking for tablesDB changes ...');
1771
-
1772
- const localTablesDBs = localConfig.getTablesDBs();
1773
- const { databases: remoteTablesDBs } = await paginate(tablesDBList, { parseOutput: false }, 100, 'databases');
1774
-
1775
- if (localTablesDBs.length === 0 && remoteTablesDBs.length === 0) {
1776
- return { applied: false, resyncNeeded: false };
1777
- }
1778
-
1779
- const changes = [];
1780
- const toCreate = [];
1781
- const toUpdate = [];
1782
- const toDelete = [];
1783
-
1784
- // Check for deletions - remote DBs that aren't in local config
1785
- for (const remoteDB of remoteTablesDBs) {
1786
- const localDB = localTablesDBs.find(db => db.$id === remoteDB.$id);
1787
- if (!localDB) {
1788
- toDelete.push(remoteDB);
1789
- changes.push({
1790
- id: remoteDB.$id,
1791
- action: chalk.red('deleting'),
1792
- key: 'Database',
1793
- remote: remoteDB.name,
1794
- local: '(deleted locally)'
1795
- });
1796
- }
1797
- }
1798
-
1799
- // Check for additions and updates
1800
- for (const localDB of localTablesDBs) {
1801
- const remoteDB = remoteTablesDBs.find(db => db.$id === localDB.$id);
1802
-
1803
- if (!remoteDB) {
1804
- toCreate.push(localDB);
1805
- changes.push({
1806
- id: localDB.$id,
1807
- action: chalk.green('creating'),
1808
- key: 'Database',
1809
- remote: '(does not exist)',
1810
- local: localDB.name
1811
- });
1812
- } else {
1813
- let hasChanges = false;
1814
-
1815
- if (remoteDB.name !== localDB.name) {
1816
- hasChanges = true;
1817
- changes.push({
1818
- id: localDB.$id,
1819
- action: chalk.yellow('updating'),
1820
- key: 'Name',
1821
- remote: remoteDB.name,
1822
- local: localDB.name
1823
- });
1824
- }
1825
-
1826
- if (remoteDB.enabled !== localDB.enabled) {
1827
- hasChanges = true;
1828
- changes.push({
1829
- id: localDB.$id,
1830
- action: chalk.yellow('updating'),
1831
- key: 'Enabled',
1832
- remote: remoteDB.enabled,
1833
- local: localDB.enabled
1834
- });
1835
- }
1836
-
1837
- if (hasChanges) {
1838
- toUpdate.push(localDB);
1839
- }
1840
- }
1841
- }
1842
-
1843
- if (changes.length === 0) {
1844
- console.log('No changes found in tablesDB resource');
1845
- console.log();
1846
- return { applied: false, resyncNeeded: false };
1847
- }
1848
-
1849
- log('Found changes in tablesDB resource:');
1850
- drawTable(changes);
1851
-
1852
- if (toDelete.length > 0) {
1853
- console.log(`${chalk.red('------------------------------------------------------------------')}`);
1854
- console.log(`${chalk.red('| WARNING: Database deletion will also delete all related tables |')}`);
1855
- console.log(`${chalk.red('------------------------------------------------------------------')}`);
1856
- console.log();
1857
- }
1858
-
1859
- if ((await getConfirmation()) !== true) {
1860
- return { applied: false, resyncNeeded: false };
1861
- }
1862
-
1863
- // Apply deletions first
1864
- let needsResync = false;
1865
- for (const db of toDelete) {
1866
- try {
1867
- log(`Deleting database ${db.name} ( ${db.$id} ) ...`);
1868
- await tablesDBDelete({
1869
- databaseId: db.$id,
1870
- parseOutput: false
1871
- });
1872
- success(`Deleted ${db.name} ( ${db.$id} )`);
1873
- needsResync = true;
1874
- } catch (e) {
1875
- error(`Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`);
1876
- throw new Error(`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`);
1877
- }
1878
- }
1879
-
1880
- // Apply creations
1881
- for (const db of toCreate) {
1882
- try {
1883
- log(`Creating database ${db.name} ( ${db.$id} ) ...`);
1884
- await tablesDBCreate({
1885
- databaseId: db.$id,
1886
- name: db.name,
1887
- enabled: db.enabled,
1888
- parseOutput: false
1889
- });
1890
- success(`Created ${db.name} ( ${db.$id} )`);
1891
- } catch (e) {
1892
- error(`Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`);
1893
- throw new Error(`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`);
1894
- }
1895
- }
1896
-
1897
- // Apply updates
1898
- for (const db of toUpdate) {
1899
- try {
1900
- log(`Updating database ${db.name} ( ${db.$id} ) ...`);
1901
- await tablesDBUpdate({
1902
- databaseId: db.$id,
1903
- name: db.name,
1904
- enabled: db.enabled,
1905
- parseOutput: false
1906
- });
1907
- success(`Updated ${db.name} ( ${db.$id} )`);
1908
- } catch (e) {
1909
- error(`Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`);
1910
- throw new Error(`Database sync failed during update of ${db.$id}. Some changes may have been applied.`);
1911
- }
1912
- }
1913
-
1914
- if (toDelete.length === 0){
1915
- console.log();
1916
- }
1917
-
1918
- return { applied: true, resyncNeeded: needsResync };
1919
- };
1920
-
1921
- const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {
1922
- const tables = [];
1923
-
1924
- if (attempts) {
1925
- pollMaxDebounces = attempts;
1926
- }
1927
-
1928
- const { applied: tablesDBApplied, resyncNeeded } = await checkAndApplyTablesDBChanges();
1929
- if (resyncNeeded) {
1930
- log('Resyncing configuration due to tablesDB deletions ...');
1931
-
1932
- const remoteTablesDBs = (await paginate(tablesDBList, { parseOutput: false }, 100, 'databases')).databases;
1933
- const localTablesDBs = localConfig.getTablesDBs();
1934
-
1935
- const remoteDatabaseIds = new Set(remoteTablesDBs.map(db => db.$id));
1936
- const localTables = localConfig.getTables();
1937
- const validTables = localTables.filter(table => remoteDatabaseIds.has(table.databaseId));
1938
-
1939
- localConfig.set('tables', validTables);
1940
-
1941
- const validTablesDBs = localTablesDBs.filter(db => remoteDatabaseIds.has(db.$id));
1942
- localConfig.set('tablesDB', validTablesDBs);
1943
-
1944
- success('Configuration resynced successfully.');
1945
- console.log();
1946
- }
1947
-
1948
- log('Checking for deleted tables ...');
1949
- const localTablesDBs = localConfig.getTablesDBs();
1950
- const localTables = localConfig.getTables();
1951
- const tablesToDelete = [];
1952
-
1953
- for (const db of localTablesDBs) {
1954
- try {
1955
- const { tables: remoteTables } = await paginate(tablesDBListTables, {
1956
- databaseId: db.$id,
1957
- parseOutput: false
1958
- }, 100, 'tables');
1959
-
1960
- for (const remoteTable of remoteTables) {
1961
- const localTable = localTables.find(t => t.$id === remoteTable.$id && t.databaseId === db.$id);
1962
- if (!localTable) {
1963
- tablesToDelete.push({
1964
- ...remoteTable,
1965
- databaseId: db.$id,
1966
- databaseName: db.name
1967
- });
1968
- }
1969
- }
1970
- } catch (e) {
1971
- // Skip if database doesn't exist or other errors
1972
- }
1973
- }
1974
-
1975
- if (tablesToDelete.length > 0) {
1976
- log('Found tables that exist remotely but not locally:');
1977
- const deletionChanges = tablesToDelete.map(table => ({
1978
- id: table.$id,
1979
- action: chalk.red('deleting'),
1980
- key: 'Table',
1981
- database: table.databaseName,
1982
- remote: table.name,
1983
- local: '(deleted locally)'
1984
- }));
1985
- drawTable(deletionChanges);
1986
-
1987
- if ((await getConfirmation()) === true) {
1988
- for (const table of tablesToDelete) {
1989
- try {
1990
- log(`Deleting table ${table.name} ( ${table.$id} ) from database ${table.databaseName} ...`);
1991
- await tablesDBDeleteTable({
1992
- databaseId: table.databaseId,
1993
- tableId: table.$id,
1994
- parseOutput: false
1995
- });
1996
- success(`Deleted ${table.name} ( ${table.$id} )`);
1997
- } catch (e) {
1998
- error(`Failed to delete table ${table.name} ( ${table.$id} ): ${e.message}`);
1999
- }
2000
- }
2001
- }
2002
- } else {
2003
- console.log('No tables found to delete');
2004
- }
2005
- console.log();
2006
-
2007
- if (cliConfig.all) {
2008
- checkDeployConditions(localConfig);
2009
- tables.push(...localConfig.getTables());
2010
- } else {
2011
- const answers = await inquirer.prompt(questionsPushTables)
2012
- if (answers.tables) {
2013
- const configTables = new Map();
2014
- localConfig.getTables().forEach((c) => {
2015
- configTables.set(`${c['databaseId']}|${c['$id']}`, c);
2016
- });
2017
- answers.tables.forEach((a) => {
2018
- const table = configTables.get(a);
2019
- tables.push(table);
2020
- })
2021
- }
2022
- }
2023
-
2024
- if (tables.length === 0) {
2025
- log("No tables found.");
2026
- hint("Use 'appwrite pull tables' to synchronize existing one, or use 'appwrite init table' to create a new one.");
2027
- return;
2028
- }
2029
-
2030
- if (!(await approveChanges(tables, tablesDBGetTable, KeysTable, 'tableId', 'tables', ['columns', 'indexes'], 'databaseId', 'databaseId'))) {
2031
- return;
2032
- }
2033
- let tablesChanged = new Set();
2034
-
2035
- // Parallel tables actions
2036
- await Promise.all(tables.map(async (table) => {
2037
- try {
2038
- const remoteTable = await tablesDBGetTable({
2039
- databaseId: table['databaseId'],
2040
- tableId: table['$id'],
2041
- parseOutput: false,
2042
- });
2043
-
2044
- const changes = [];
2045
- if (remoteTable.name !== table.name) changes.push('name');
2046
- if (remoteTable.rowSecurity !== table.rowSecurity) changes.push('rowSecurity');
2047
- if (remoteTable.enabled !== table.enabled) changes.push('enabled');
2048
- if (JSON.stringify(remoteTable['$permissions']) !== JSON.stringify(table['$permissions'])) changes.push('permissions');
2049
-
2050
- if (changes.length > 0) {
2051
- await tablesDBUpdateTable({
2052
- databaseId: table['databaseId'],
2053
- tableId: table['$id'],
2054
- name: table.name,
2055
- parseOutput: false,
2056
- rowSecurity: table.rowSecurity,
2057
- permissions: table['$permissions']
2058
- })
2059
-
2060
- success(`Updated ${table.name} ( ${table['$id']} ) - ${changes.join(', ')}`);
2061
- tablesChanged.add(table['$id']);
2062
- }
2063
- table.remoteVersion = remoteTable;
2064
-
2065
- table.isExisted = true;
2066
- } catch
2067
- (e) {
2068
- if (Number(e.code) === 404) {
2069
- log(`Table ${table.name} does not exist in the project. Creating ... `);
2070
- await tablesDBCreateTable({
2071
- databaseId: table['databaseId'],
2072
- tableId: table['$id'],
2073
- name: table.name,
2074
- rowSecurity: table.rowSecurity,
2075
- permissions: table['$permissions'],
2076
- parseOutput: false
2077
- })
2078
-
2079
- success(`Created ${table.name} ( ${table['$id']} )`);
2080
- tablesChanged.add(table['$id']);
2081
- } else {
2082
- throw e;
2083
- }
2084
- }
2085
- }))
2086
-
2087
- // Serialize attribute actions
2088
- for (let table of tables) {
2089
- let columns = table.columns;
2090
- let indexes = table.indexes;
2091
-
2092
- if (table.isExisted) {
2093
- columns = await attributesToCreate(table.remoteVersion.columns, table.columns, table);
2094
- indexes = await attributesToCreate(table.remoteVersion.indexes, table.indexes, table, true);
2095
-
2096
- if ((Array.isArray(columns) && columns.length <= 0) && (Array.isArray(indexes) && indexes.length <= 0)) {
2097
- continue;
2098
- }
2099
- }
2100
-
2101
- log(`Pushing table ${table.name} ( ${table['databaseId']} - ${table['$id']} ) attributes`)
2102
-
2103
- try {
2104
- await createColumns(columns, table)
2105
- } catch (e) {
2106
- throw e;
2107
- }
2108
-
2109
- try {
2110
- await createIndexes(indexes, table);
2111
- } catch (e) {
2112
- throw e;
2113
- }
2114
- tablesChanged.add(table['$id']);
2115
- success(`Successfully pushed ${table.name} ( ${table['$id']} )`);
2116
- }
2117
-
2118
- success(`Successfully pushed ${tablesChanged.size} tables`);
2119
- }
2120
-
2121
- const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {
2122
- warn("appwrite push collection has been deprecated. Please consider using 'appwrite push tables' instead");
2123
- const collections = [];
2124
-
2125
- if (attempts) {
2126
- pollMaxDebounces = attempts;
2127
- }
2128
-
2129
- if (cliConfig.all) {
2130
- checkDeployConditions(localConfig);
2131
- collections.push(...localConfig.getCollections());
2132
- } else {
2133
- const answers = await inquirer.prompt(questionsPushCollections)
2134
- if (answers.collections) {
2135
- const configCollections = new Map();
2136
- localConfig.getCollections().forEach((c) => {
2137
- configCollections.set(`${c['databaseId']}|${c['$id']}`, c);
2138
- });
2139
- answers.collections.forEach((a) => {
2140
- const collection = configCollections.get(a);
2141
- collections.push(collection);
2142
- })
2143
- }
2144
- }
2145
-
2146
- if (collections.length === 0) {
2147
- log("No collections found.");
2148
- hint("Use 'appwrite pull collections' to synchronize existing one, or use 'appwrite init collection' to create a new one.");
2149
- return;
2150
- }
2151
-
2152
- const databases = Array.from(new Set(collections.map(collection => collection['databaseId'])));
2153
-
2154
- // Parallel db actions
2155
- await Promise.all(databases.map(async (databaseId) => {
2156
- const localDatabase = localConfig.getDatabase(databaseId);
2157
-
2158
- try {
2159
- const database = await databasesGet({
2160
- databaseId: databaseId,
2161
- parseOutput: false,
2162
- });
2163
-
2164
- if (database.name !== (localDatabase.name ?? databaseId)) {
2165
- await databasesUpdate({
2166
- databaseId: databaseId,
2167
- name: localDatabase.name ?? databaseId,
2168
- parseOutput: false
2169
- })
2170
-
2171
- success(`Updated ${localDatabase.name} ( ${databaseId} ) name`);
2172
- }
2173
- } catch (err) {
2174
- log(`Database ${databaseId} not found. Creating it now ...`);
2175
-
2176
- await databasesCreate({
2177
- databaseId: databaseId,
2178
- name: localDatabase.name ?? databaseId,
2179
- parseOutput: false,
2180
- });
2181
- }
2182
- }));
2183
-
2184
-
2185
- if (!(await approveChanges(collections, databasesGetCollection, KeysCollection, 'collectionId', 'collections', ['attributes', 'indexes'], 'databaseId', 'databaseId',))) {
2186
- return;
2187
- }
2188
- // Parallel collection actions
2189
- await Promise.all(collections.map(async (collection) => {
2190
- try {
2191
- const remoteCollection = await databasesGetCollection({
2192
- databaseId: collection['databaseId'],
2193
- collectionId: collection['$id'],
2194
- parseOutput: false,
2195
- });
2196
-
2197
- if (remoteCollection.name !== collection.name) {
2198
- await databasesUpdateCollection({
2199
- databaseId: collection['databaseId'],
2200
- collectionId: collection['$id'],
2201
- name: collection.name,
2202
- parseOutput: false
2203
- })
2204
-
2205
- success(`Updated ${collection.name} ( ${collection['$id']} ) name`);
2206
- }
2207
- collection.remoteVersion = remoteCollection;
2208
-
2209
- collection.isExisted = true;
2210
- } catch
2211
- (e) {
2212
- if (Number(e.code) === 404) {
2213
- log(`Collection ${collection.name} does not exist in the project. Creating ... `);
2214
- await databasesCreateCollection({
2215
- databaseId: collection['databaseId'],
2216
- collectionId: collection['$id'],
2217
- name: collection.name,
2218
- documentSecurity: collection.documentSecurity,
2219
- permissions: collection['$permissions'],
2220
- parseOutput: false
2221
- })
2222
- } else {
2223
- throw e;
2224
- }
2225
- }
2226
- }))
2227
- let numberOfCollections = 0;
2228
- // Serialize attribute actions
2229
- for (let collection of collections) {
2230
- let attributes = collection.attributes;
2231
- let indexes = collection.indexes;
2232
-
2233
- if (collection.isExisted) {
2234
- attributes = await attributesToCreate(collection.remoteVersion.attributes, collection.attributes, collection);
2235
- indexes = await attributesToCreate(collection.remoteVersion.indexes, collection.indexes, collection, true);
2236
-
2237
- if ((Array.isArray(attributes) && attributes.length <= 0) && (Array.isArray(indexes) && indexes.length <= 0)) {
2238
- continue;
2239
- }
2240
-
2241
- }
2242
-
2243
- log(`Pushing collection ${collection.name} ( ${collection['databaseId']} - ${collection['$id']} ) attributes`)
2244
-
2245
- try {
2246
- await createAttributes(attributes, collection)
2247
- } catch (e) {
2248
- throw e;
2249
- }
2250
-
2251
- try {
2252
- await createIndexes(indexes, collection);
2253
- } catch (e) {
2254
- throw e;
2255
- }
2256
- numberOfCollections++;
2257
- success(`Successfully pushed ${collection.name} ( ${collection['$id']} )`);
2258
- }
2259
-
2260
- success(`Successfully pushed ${numberOfCollections} collections`);
2261
- }
2262
-
2263
- const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
2264
- let response = {};
2265
-
2266
- let bucketIds = [];
2267
- const configBuckets = localConfig.getBuckets();
2268
-
2269
- if (cliConfig.all) {
2270
- checkDeployConditions(localConfig);
2271
- bucketIds.push(...configBuckets.map((b) => b.$id));
2272
- }
2273
-
2274
- if (bucketIds.length === 0) {
2275
- const answers = await inquirer.prompt(questionsPushBuckets[0])
2276
- if (answers.buckets) {
2277
- bucketIds.push(...answers.buckets);
2278
- }
2279
- }
2280
-
2281
- if (bucketIds.length === 0) {
2282
- log("No buckets found.");
2283
- hint("Use 'appwrite pull buckets' to synchronize existing one, or use 'appwrite init bucket' to create a new one.");
2284
- return;
2285
- }
2286
-
2287
- let buckets = [];
2288
-
2289
- for (const bucketId of bucketIds) {
2290
- const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
2291
- buckets.push(...idBuckets);
2292
- }
2293
-
2294
- if (!(await approveChanges(buckets, storageGetBucket, KeysStorage, 'bucketId', 'buckets'))) {
2295
- return;
2296
- }
2297
-
2298
- log('Pushing buckets ...');
2299
-
2300
- for (let bucket of buckets) {
2301
- log(`Pushing bucket ${chalk.bold(bucket['name'])} ...`);
2302
-
2303
- try {
2304
- response = await storageGetBucket({
2305
- bucketId: bucket['$id'],
2306
- parseOutput: false,
2307
- })
2308
-
2309
- await storageUpdateBucket({
2310
- bucketId: bucket['$id'],
2311
- name: bucket.name,
2312
- permissions: bucket['$permissions'],
2313
- fileSecurity: bucket.fileSecurity,
2314
- enabled: bucket.enabled,
2315
- maximumFileSize: bucket.maximumFileSize,
2316
- allowedFileExtensions: bucket.allowedFileExtensions,
2317
- encryption: bucket.encryption,
2318
- antivirus: bucket.antivirus,
2319
- compression: bucket.compression,
2320
- parseOutput: false
2321
- });
2322
- } catch (e) {
2323
- if (Number(e.code) === 404) {
2324
- log(`Bucket ${bucket.name} does not exist in the project. Creating ... `);
2325
-
2326
- response = await storageCreateBucket({
2327
- bucketId: bucket['$id'],
2328
- name: bucket.name,
2329
- permissions: bucket['$permissions'],
2330
- fileSecurity: bucket.fileSecurity,
2331
- enabled: bucket.enabled,
2332
- maximumFileSize: bucket.maximumFileSize,
2333
- allowedFileExtensions: bucket.allowedFileExtensions,
2334
- compression: bucket.compression,
2335
- encryption: bucket.encryption,
2336
- antivirus: bucket.antivirus,
2337
- parseOutput: false
2338
- })
2339
- } else {
2340
- throw e;
2341
- }
2342
- }
2343
- }
2344
-
2345
- success(`Successfully pushed ${buckets.length} buckets.`);
2346
- }
2347
-
2348
- const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2349
- let response = {};
2350
-
2351
- let teamIds = [];
2352
- const configTeams = localConfig.getTeams();
2353
-
2354
- if (cliConfig.all) {
2355
- checkDeployConditions(localConfig);
2356
- teamIds.push(...configTeams.map((t) => t.$id));
2357
- }
2358
-
2359
- if (teamIds.length === 0) {
2360
- const answers = await inquirer.prompt(questionsPushTeams[0])
2361
- if (answers.teams) {
2362
- teamIds.push(...answers.teams);
2363
- }
2364
- }
2365
-
2366
- if (teamIds.length === 0) {
2367
- log("No teams found.");
2368
- hint("Use 'appwrite pull teams' to synchronize existing one, or use 'appwrite init team' to create a new one.");
2369
- return;
2370
- }
2371
-
2372
- let teams = [];
2373
-
2374
- for (const teamId of teamIds) {
2375
- const idTeams = configTeams.filter((t) => t.$id === teamId);
2376
- teams.push(...idTeams);
2377
- }
2378
-
2379
- if (!(await approveChanges(teams, teamsGet, KeysTeams, 'teamId', 'teams'))) {
2380
- return;
2381
- }
2382
-
2383
-
2384
- log('Pushing teams ...');
2385
-
2386
- for (let team of teams) {
2387
- log(`Pushing team ${chalk.bold(team['name'])} ...`);
2388
-
2389
- try {
2390
- response = await teamsGet({
2391
- teamId: team['$id'],
2392
- parseOutput: false,
2393
- })
2394
-
2395
- await teamsUpdateName({
2396
- teamId: team['$id'],
2397
- name: team.name,
2398
- parseOutput: false
2399
- });
2400
- } catch (e) {
2401
- if (Number(e.code) === 404) {
2402
- log(`Team ${team.name} does not exist in the project. Creating ... `);
2403
-
2404
- response = await teamsCreate({
2405
- teamId: team['$id'],
2406
- name: team.name,
2407
- parseOutput: false
2408
- })
2409
- } else {
2410
- throw e;
2411
- }
2412
- }
2413
- }
2414
-
2415
- success(`Successfully pushed ${teams.length} teams.`);
2416
- }
2417
-
2418
- const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) => {
2419
- let response = {};
2420
-
2421
- let topicsIds = [];
2422
- const configTopics = localConfig.getMessagingTopics();
2423
-
2424
- if (cliConfig.all) {
2425
- checkDeployConditions(localConfig);
2426
- topicsIds.push(...configTopics.map((b) => b.$id));
2427
- }
2428
-
2429
- if (topicsIds.length === 0) {
2430
- const answers = await inquirer.prompt(questionsPushMessagingTopics[0])
2431
- if (answers.topics) {
2432
- topicsIds.push(...answers.topics);
2433
- }
2434
- }
2435
-
2436
- if (topicsIds.length === 0) {
2437
- log("No topics found.");
2438
- hint("Use 'appwrite pull topics' to synchronize existing one, or use 'appwrite init topic' to create a new one.");
2439
- return;
2440
- }
2441
-
2442
- let topics = [];
2443
-
2444
- for (const topicId of topicsIds) {
2445
- const idTopic = configTopics.filter((b) => b.$id === topicId);
2446
- topics.push(...idTopic);
2447
- }
2448
-
2449
- if (!(await approveChanges(topics, messagingGetTopic, KeysTopics, 'topicId', 'topics'))) {
2450
- return;
2451
- }
2452
-
2453
- log('Pushing topics ...');
2454
-
2455
- for (let topic of topics) {
2456
- log(`Pushing topic ${chalk.bold(topic['name'])} ...`);
2457
-
2458
- try {
2459
- response = await messagingGetTopic({
2460
- topicId: topic['$id'],
2461
- parseOutput: false
2462
- })
2463
- log(`Topic ${topic.name} ( ${topic['$id']} ) already exists.`);
2464
-
2465
- await messagingUpdateTopic({
2466
- topicId: topic['$id'],
2467
- name: topic.name,
2468
- subscribe: topic.subscribe,
2469
- parseOutput: false
2470
- });
2471
- } catch (e) {
2472
- if (Number(e.code) === 404) {
2473
- log(`Topic ${topic.name} does not exist in the project. Creating ... `);
2474
-
2475
- response = await messagingCreateTopic({
2476
- topicId: topic['$id'],
2477
- name: topic.name,
2478
- subscribe: topic.subscribe,
2479
- parseOutput: false
2480
- })
2481
-
2482
- success(`Created ${topic.name} ( ${topic['$id']} )`);
2483
- } else {
2484
- throw e;
2485
- }
2486
- }
2487
- }
2488
-
2489
- success(`Successfully pushed ${topics.length} topics.`);
2490
- }
2491
-
2492
- const push = new Command("push")
2493
- .description(commandDescriptions['push'])
2494
- .action(actionRunner(pushResources));
2495
-
2496
- push
2497
- .command("all")
2498
- .description("Push all resource.")
2499
- .action(actionRunner(() => {
2500
- cliConfig.all = true;
2501
- return pushResources();
2502
- }));
2503
-
2504
- push
2505
- .command("settings")
2506
- .description("Push project name, services and auth settings")
2507
- .action(actionRunner(pushSettings));
2508
-
2509
- push
2510
- .command("function")
2511
- .alias("functions")
2512
- .description("Push functions in the current directory.")
2513
- .option(`-f, --function-id <function-id>`, `ID of function to run`)
2514
- .option(`-A, --async`, `Don't wait for functions deployments status`)
2515
- .option("--no-code", "Don't push the function's code")
2516
- .option("--with-variables", `Push function variables.`)
2517
- .action(actionRunner(pushFunction));
2518
-
2519
- push
2520
- .command("site")
2521
- .alias("sites")
2522
- .description("Push sites in the current directory.")
2523
- .option(`-f, --site-id <site-id>`, `ID of site to run`)
2524
- .option(`-A, --async`, `Don't wait for sites deployments status`)
2525
- .option("--no-code", "Don't push the site's code")
2526
- .option("--with-variables", `Push site variables.`)
2527
- .action(actionRunner(pushSite));
2528
-
2529
- push
2530
- .command("collection")
2531
- .alias("collections")
2532
- .description("Push collections in the current project. (deprecated, please use 'push tables' instead)")
2533
- .option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
2534
- .action(actionRunner(pushCollection));
2535
-
2536
- push
2537
- .command("table")
2538
- .alias("tables")
2539
- .description("Push tables in the current project.")
2540
- .option(`-a, --attempts <numberOfAttempts>`, `Max number of attempts before timing out. default: 30.`)
2541
- .action(actionRunner(pushTable));
2542
-
2543
- push
2544
- .command("bucket")
2545
- .alias("buckets")
2546
- .description("Push buckets in the current project.")
2547
- .action(actionRunner(pushBucket));
2548
-
2549
- push
2550
- .command("team")
2551
- .alias("teams")
2552
- .description("Push teams in the current project.")
2553
- .action(actionRunner(pushTeam));
2554
-
2555
- push
2556
- .command("topic")
2557
- .alias("topics")
2558
- .description("Push messaging topics in the current project.")
2559
- .action(actionRunner(pushMessagingTopic));
2560
-
2561
- const deploy = new Command("deploy")
2562
- .description('Removed. Use appwrite push instead')
2563
- .action(actionRunner(async () => {
2564
- warn("appwrite deploy has been removed. Please use 'appwrite push' instead");
2565
- }));
2566
-
2567
- module.exports = {
2568
- push,
2569
- deploy
2570
- }