chirag-appwrite-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (491) hide show
  1. package/.github/workflows/npm-publish.yml +49 -0
  2. package/CHANGELOG.md +1 -0
  3. package/Formula/appwrite.rb +19 -0
  4. package/LICENSE.md +1 -0
  5. package/README.md +104 -0
  6. package/appwrite.json +164 -0
  7. package/docs/examples/account/create-anonymous-session.md +1 -0
  8. package/docs/examples/account/create-email-password-session.md +3 -0
  9. package/docs/examples/account/create-email-token.md +4 -0
  10. package/docs/examples/account/create-j-w-t.md +1 -0
  11. package/docs/examples/account/create-magic-u-r-l-token.md +5 -0
  12. package/docs/examples/account/create-mfa-authenticator.md +2 -0
  13. package/docs/examples/account/create-mfa-challenge.md +2 -0
  14. package/docs/examples/account/create-mfa-recovery-codes.md +1 -0
  15. package/docs/examples/account/create-o-auth2session.md +5 -0
  16. package/docs/examples/account/create-o-auth2token.md +5 -0
  17. package/docs/examples/account/create-phone-token.md +3 -0
  18. package/docs/examples/account/create-phone-verification.md +1 -0
  19. package/docs/examples/account/create-push-target.md +4 -0
  20. package/docs/examples/account/create-recovery.md +3 -0
  21. package/docs/examples/account/create-session.md +3 -0
  22. package/docs/examples/account/create-verification.md +2 -0
  23. package/docs/examples/account/create.md +5 -0
  24. package/docs/examples/account/delete-identity.md +2 -0
  25. package/docs/examples/account/delete-mfa-authenticator.md +2 -0
  26. package/docs/examples/account/delete-push-target.md +2 -0
  27. package/docs/examples/account/delete-session.md +2 -0
  28. package/docs/examples/account/delete-sessions.md +1 -0
  29. package/docs/examples/account/delete.md +1 -0
  30. package/docs/examples/account/get-mfa-recovery-codes.md +1 -0
  31. package/docs/examples/account/get-prefs.md +1 -0
  32. package/docs/examples/account/get-session.md +2 -0
  33. package/docs/examples/account/get.md +1 -0
  34. package/docs/examples/account/list-identities.md +2 -0
  35. package/docs/examples/account/list-logs.md +2 -0
  36. package/docs/examples/account/list-mfa-factors.md +1 -0
  37. package/docs/examples/account/list-sessions.md +1 -0
  38. package/docs/examples/account/update-email.md +3 -0
  39. package/docs/examples/account/update-m-f-a.md +2 -0
  40. package/docs/examples/account/update-magic-u-r-l-session.md +3 -0
  41. package/docs/examples/account/update-mfa-authenticator.md +3 -0
  42. package/docs/examples/account/update-mfa-challenge.md +3 -0
  43. package/docs/examples/account/update-mfa-recovery-codes.md +1 -0
  44. package/docs/examples/account/update-name.md +2 -0
  45. package/docs/examples/account/update-password.md +3 -0
  46. package/docs/examples/account/update-phone-session.md +3 -0
  47. package/docs/examples/account/update-phone-verification.md +3 -0
  48. package/docs/examples/account/update-phone.md +3 -0
  49. package/docs/examples/account/update-prefs.md +2 -0
  50. package/docs/examples/account/update-push-target.md +3 -0
  51. package/docs/examples/account/update-recovery.md +4 -0
  52. package/docs/examples/account/update-session.md +2 -0
  53. package/docs/examples/account/update-status.md +1 -0
  54. package/docs/examples/account/update-verification.md +3 -0
  55. package/docs/examples/avatars/get-browser.md +5 -0
  56. package/docs/examples/avatars/get-credit-card.md +5 -0
  57. package/docs/examples/avatars/get-favicon.md +2 -0
  58. package/docs/examples/avatars/get-flag.md +5 -0
  59. package/docs/examples/avatars/get-image.md +4 -0
  60. package/docs/examples/avatars/get-initials.md +5 -0
  61. package/docs/examples/avatars/get-q-r.md +5 -0
  62. package/docs/examples/console/get-resource.md +3 -0
  63. package/docs/examples/console/variables.md +1 -0
  64. package/docs/examples/databases/create-boolean-attribute.md +7 -0
  65. package/docs/examples/databases/create-collection.md +7 -0
  66. package/docs/examples/databases/create-datetime-attribute.md +7 -0
  67. package/docs/examples/databases/create-document.md +6 -0
  68. package/docs/examples/databases/create-documents.md +4 -0
  69. package/docs/examples/databases/create-email-attribute.md +7 -0
  70. package/docs/examples/databases/create-enum-attribute.md +8 -0
  71. package/docs/examples/databases/create-float-attribute.md +9 -0
  72. package/docs/examples/databases/create-index.md +8 -0
  73. package/docs/examples/databases/create-integer-attribute.md +9 -0
  74. package/docs/examples/databases/create-ip-attribute.md +7 -0
  75. package/docs/examples/databases/create-relationship-attribute.md +9 -0
  76. package/docs/examples/databases/create-string-attribute.md +9 -0
  77. package/docs/examples/databases/create-url-attribute.md +7 -0
  78. package/docs/examples/databases/create.md +4 -0
  79. package/docs/examples/databases/decrement-document-attribute.md +7 -0
  80. package/docs/examples/databases/delete-attribute.md +4 -0
  81. package/docs/examples/databases/delete-collection.md +3 -0
  82. package/docs/examples/databases/delete-document.md +4 -0
  83. package/docs/examples/databases/delete-documents.md +4 -0
  84. package/docs/examples/databases/delete-index.md +4 -0
  85. package/docs/examples/databases/delete.md +2 -0
  86. package/docs/examples/databases/get-attribute.md +4 -0
  87. package/docs/examples/databases/get-collection-usage.md +4 -0
  88. package/docs/examples/databases/get-collection.md +3 -0
  89. package/docs/examples/databases/get-database-usage.md +3 -0
  90. package/docs/examples/databases/get-document.md +5 -0
  91. package/docs/examples/databases/get-index.md +4 -0
  92. package/docs/examples/databases/get-usage.md +2 -0
  93. package/docs/examples/databases/get.md +2 -0
  94. package/docs/examples/databases/increment-document-attribute.md +7 -0
  95. package/docs/examples/databases/list-attributes.md +4 -0
  96. package/docs/examples/databases/list-collection-logs.md +4 -0
  97. package/docs/examples/databases/list-collections.md +4 -0
  98. package/docs/examples/databases/list-document-logs.md +5 -0
  99. package/docs/examples/databases/list-documents.md +4 -0
  100. package/docs/examples/databases/list-indexes.md +4 -0
  101. package/docs/examples/databases/list-logs.md +3 -0
  102. package/docs/examples/databases/list.md +3 -0
  103. package/docs/examples/databases/update-boolean-attribute.md +7 -0
  104. package/docs/examples/databases/update-collection.md +7 -0
  105. package/docs/examples/databases/update-datetime-attribute.md +7 -0
  106. package/docs/examples/databases/update-document.md +6 -0
  107. package/docs/examples/databases/update-documents.md +5 -0
  108. package/docs/examples/databases/update-email-attribute.md +7 -0
  109. package/docs/examples/databases/update-enum-attribute.md +8 -0
  110. package/docs/examples/databases/update-float-attribute.md +9 -0
  111. package/docs/examples/databases/update-integer-attribute.md +9 -0
  112. package/docs/examples/databases/update-ip-attribute.md +7 -0
  113. package/docs/examples/databases/update-relationship-attribute.md +6 -0
  114. package/docs/examples/databases/update-string-attribute.md +8 -0
  115. package/docs/examples/databases/update-url-attribute.md +7 -0
  116. package/docs/examples/databases/update.md +4 -0
  117. package/docs/examples/databases/upsert-document.md +6 -0
  118. package/docs/examples/databases/upsert-documents.md +4 -0
  119. package/docs/examples/functions/create-deployment.md +6 -0
  120. package/docs/examples/functions/create-duplicate-deployment.md +4 -0
  121. package/docs/examples/functions/create-execution.md +8 -0
  122. package/docs/examples/functions/create-template-deployment.md +7 -0
  123. package/docs/examples/functions/create-variable.md +5 -0
  124. package/docs/examples/functions/create-vcs-deployment.md +5 -0
  125. package/docs/examples/functions/create.md +19 -0
  126. package/docs/examples/functions/delete-deployment.md +3 -0
  127. package/docs/examples/functions/delete-execution.md +3 -0
  128. package/docs/examples/functions/delete-variable.md +3 -0
  129. package/docs/examples/functions/delete.md +2 -0
  130. package/docs/examples/functions/get-deployment-download.md +4 -0
  131. package/docs/examples/functions/get-deployment.md +3 -0
  132. package/docs/examples/functions/get-execution.md +3 -0
  133. package/docs/examples/functions/get-template.md +2 -0
  134. package/docs/examples/functions/get-usage.md +3 -0
  135. package/docs/examples/functions/get-variable.md +3 -0
  136. package/docs/examples/functions/get.md +2 -0
  137. package/docs/examples/functions/list-deployments.md +4 -0
  138. package/docs/examples/functions/list-executions.md +3 -0
  139. package/docs/examples/functions/list-runtimes.md +1 -0
  140. package/docs/examples/functions/list-specifications.md +1 -0
  141. package/docs/examples/functions/list-templates.md +5 -0
  142. package/docs/examples/functions/list-usage.md +2 -0
  143. package/docs/examples/functions/list-variables.md +2 -0
  144. package/docs/examples/functions/list.md +3 -0
  145. package/docs/examples/functions/update-deployment-status.md +3 -0
  146. package/docs/examples/functions/update-function-deployment.md +3 -0
  147. package/docs/examples/functions/update-variable.md +6 -0
  148. package/docs/examples/functions/update.md +19 -0
  149. package/docs/examples/graphql/mutation.md +2 -0
  150. package/docs/examples/graphql/query.md +2 -0
  151. package/docs/examples/health/get-antivirus.md +1 -0
  152. package/docs/examples/health/get-cache.md +1 -0
  153. package/docs/examples/health/get-certificate.md +2 -0
  154. package/docs/examples/health/get-d-b.md +1 -0
  155. package/docs/examples/health/get-failed-jobs.md +3 -0
  156. package/docs/examples/health/get-pub-sub.md +1 -0
  157. package/docs/examples/health/get-queue-builds.md +2 -0
  158. package/docs/examples/health/get-queue-certificates.md +2 -0
  159. package/docs/examples/health/get-queue-databases.md +3 -0
  160. package/docs/examples/health/get-queue-deletes.md +2 -0
  161. package/docs/examples/health/get-queue-functions.md +2 -0
  162. package/docs/examples/health/get-queue-logs.md +2 -0
  163. package/docs/examples/health/get-queue-mails.md +2 -0
  164. package/docs/examples/health/get-queue-messaging.md +2 -0
  165. package/docs/examples/health/get-queue-migrations.md +2 -0
  166. package/docs/examples/health/get-queue-stats-resources.md +2 -0
  167. package/docs/examples/health/get-queue-usage.md +2 -0
  168. package/docs/examples/health/get-queue-webhooks.md +2 -0
  169. package/docs/examples/health/get-storage-local.md +1 -0
  170. package/docs/examples/health/get-storage.md +1 -0
  171. package/docs/examples/health/get-time.md +1 -0
  172. package/docs/examples/health/get.md +1 -0
  173. package/docs/examples/locale/get.md +1 -0
  174. package/docs/examples/locale/list-codes.md +1 -0
  175. package/docs/examples/locale/list-continents.md +1 -0
  176. package/docs/examples/locale/list-countries-e-u.md +1 -0
  177. package/docs/examples/locale/list-countries-phones.md +1 -0
  178. package/docs/examples/locale/list-countries.md +1 -0
  179. package/docs/examples/locale/list-currencies.md +1 -0
  180. package/docs/examples/locale/list-languages.md +1 -0
  181. package/docs/examples/messaging/create-apns-provider.md +9 -0
  182. package/docs/examples/messaging/create-email.md +13 -0
  183. package/docs/examples/messaging/create-fcm-provider.md +5 -0
  184. package/docs/examples/messaging/create-mailgun-provider.md +11 -0
  185. package/docs/examples/messaging/create-msg91provider.md +7 -0
  186. package/docs/examples/messaging/create-push.md +20 -0
  187. package/docs/examples/messaging/create-sendgrid-provider.md +9 -0
  188. package/docs/examples/messaging/create-sms.md +8 -0
  189. package/docs/examples/messaging/create-smtp-provider.md +15 -0
  190. package/docs/examples/messaging/create-subscriber.md +4 -0
  191. package/docs/examples/messaging/create-telesign-provider.md +7 -0
  192. package/docs/examples/messaging/create-textmagic-provider.md +7 -0
  193. package/docs/examples/messaging/create-topic.md +4 -0
  194. package/docs/examples/messaging/create-twilio-provider.md +7 -0
  195. package/docs/examples/messaging/create-vonage-provider.md +7 -0
  196. package/docs/examples/messaging/delete-provider.md +2 -0
  197. package/docs/examples/messaging/delete-subscriber.md +3 -0
  198. package/docs/examples/messaging/delete-topic.md +2 -0
  199. package/docs/examples/messaging/delete.md +2 -0
  200. package/docs/examples/messaging/get-message.md +2 -0
  201. package/docs/examples/messaging/get-provider.md +2 -0
  202. package/docs/examples/messaging/get-subscriber.md +3 -0
  203. package/docs/examples/messaging/get-topic.md +2 -0
  204. package/docs/examples/messaging/list-message-logs.md +3 -0
  205. package/docs/examples/messaging/list-messages.md +3 -0
  206. package/docs/examples/messaging/list-provider-logs.md +3 -0
  207. package/docs/examples/messaging/list-providers.md +3 -0
  208. package/docs/examples/messaging/list-subscriber-logs.md +3 -0
  209. package/docs/examples/messaging/list-subscribers.md +4 -0
  210. package/docs/examples/messaging/list-targets.md +3 -0
  211. package/docs/examples/messaging/list-topic-logs.md +3 -0
  212. package/docs/examples/messaging/list-topics.md +3 -0
  213. package/docs/examples/messaging/update-apns-provider.md +9 -0
  214. package/docs/examples/messaging/update-email.md +13 -0
  215. package/docs/examples/messaging/update-fcm-provider.md +5 -0
  216. package/docs/examples/messaging/update-mailgun-provider.md +11 -0
  217. package/docs/examples/messaging/update-msg91provider.md +7 -0
  218. package/docs/examples/messaging/update-push.md +20 -0
  219. package/docs/examples/messaging/update-sendgrid-provider.md +9 -0
  220. package/docs/examples/messaging/update-sms.md +8 -0
  221. package/docs/examples/messaging/update-smtp-provider.md +15 -0
  222. package/docs/examples/messaging/update-telesign-provider.md +7 -0
  223. package/docs/examples/messaging/update-textmagic-provider.md +7 -0
  224. package/docs/examples/messaging/update-topic.md +4 -0
  225. package/docs/examples/messaging/update-twilio-provider.md +7 -0
  226. package/docs/examples/messaging/update-vonage-provider.md +7 -0
  227. package/docs/examples/migrations/create-appwrite-migration.md +5 -0
  228. package/docs/examples/migrations/create-csv-migration.md +4 -0
  229. package/docs/examples/migrations/create-firebase-migration.md +3 -0
  230. package/docs/examples/migrations/create-n-host-migration.md +9 -0
  231. package/docs/examples/migrations/create-supabase-migration.md +8 -0
  232. package/docs/examples/migrations/delete.md +2 -0
  233. package/docs/examples/migrations/get-appwrite-report.md +5 -0
  234. package/docs/examples/migrations/get-firebase-report.md +3 -0
  235. package/docs/examples/migrations/get-n-host-report.md +9 -0
  236. package/docs/examples/migrations/get-supabase-report.md +8 -0
  237. package/docs/examples/migrations/get.md +2 -0
  238. package/docs/examples/migrations/list.md +3 -0
  239. package/docs/examples/migrations/retry.md +2 -0
  240. package/docs/examples/project/create-variable.md +4 -0
  241. package/docs/examples/project/delete-variable.md +2 -0
  242. package/docs/examples/project/get-usage.md +4 -0
  243. package/docs/examples/project/get-variable.md +2 -0
  244. package/docs/examples/project/list-variables.md +1 -0
  245. package/docs/examples/project/update-variable.md +5 -0
  246. package/docs/examples/projects/create-dev-key.md +4 -0
  247. package/docs/examples/projects/create-j-w-t.md +4 -0
  248. package/docs/examples/projects/create-key.md +5 -0
  249. package/docs/examples/projects/create-platform.md +7 -0
  250. package/docs/examples/projects/create-smtp-test.md +11 -0
  251. package/docs/examples/projects/create-webhook.md +9 -0
  252. package/docs/examples/projects/create.md +14 -0
  253. package/docs/examples/projects/delete-dev-key.md +3 -0
  254. package/docs/examples/projects/delete-email-template.md +4 -0
  255. package/docs/examples/projects/delete-key.md +3 -0
  256. package/docs/examples/projects/delete-platform.md +3 -0
  257. package/docs/examples/projects/delete-sms-template.md +4 -0
  258. package/docs/examples/projects/delete-webhook.md +3 -0
  259. package/docs/examples/projects/delete.md +2 -0
  260. package/docs/examples/projects/get-dev-key.md +3 -0
  261. package/docs/examples/projects/get-email-template.md +4 -0
  262. package/docs/examples/projects/get-key.md +3 -0
  263. package/docs/examples/projects/get-platform.md +3 -0
  264. package/docs/examples/projects/get-sms-template.md +4 -0
  265. package/docs/examples/projects/get-webhook.md +3 -0
  266. package/docs/examples/projects/get.md +2 -0
  267. package/docs/examples/projects/list-dev-keys.md +3 -0
  268. package/docs/examples/projects/list-keys.md +2 -0
  269. package/docs/examples/projects/list-platforms.md +2 -0
  270. package/docs/examples/projects/list-webhooks.md +2 -0
  271. package/docs/examples/projects/list.md +3 -0
  272. package/docs/examples/projects/update-api-status-all.md +3 -0
  273. package/docs/examples/projects/update-api-status.md +4 -0
  274. package/docs/examples/projects/update-auth-duration.md +3 -0
  275. package/docs/examples/projects/update-auth-limit.md +3 -0
  276. package/docs/examples/projects/update-auth-password-dictionary.md +3 -0
  277. package/docs/examples/projects/update-auth-password-history.md +3 -0
  278. package/docs/examples/projects/update-auth-sessions-limit.md +3 -0
  279. package/docs/examples/projects/update-auth-status.md +4 -0
  280. package/docs/examples/projects/update-dev-key.md +5 -0
  281. package/docs/examples/projects/update-email-template.md +9 -0
  282. package/docs/examples/projects/update-key.md +6 -0
  283. package/docs/examples/projects/update-memberships-privacy.md +5 -0
  284. package/docs/examples/projects/update-mock-numbers.md +3 -0
  285. package/docs/examples/projects/update-o-auth2.md +6 -0
  286. package/docs/examples/projects/update-personal-data-check.md +3 -0
  287. package/docs/examples/projects/update-platform.md +7 -0
  288. package/docs/examples/projects/update-service-status-all.md +3 -0
  289. package/docs/examples/projects/update-service-status.md +4 -0
  290. package/docs/examples/projects/update-session-alerts.md +3 -0
  291. package/docs/examples/projects/update-sms-template.md +5 -0
  292. package/docs/examples/projects/update-smtp.md +11 -0
  293. package/docs/examples/projects/update-team.md +3 -0
  294. package/docs/examples/projects/update-webhook-signature.md +3 -0
  295. package/docs/examples/projects/update-webhook.md +10 -0
  296. package/docs/examples/projects/update.md +12 -0
  297. package/docs/examples/proxy/create-a-p-i-rule.md +2 -0
  298. package/docs/examples/proxy/create-function-rule.md +4 -0
  299. package/docs/examples/proxy/create-redirect-rule.md +6 -0
  300. package/docs/examples/proxy/create-site-rule.md +4 -0
  301. package/docs/examples/proxy/delete-rule.md +2 -0
  302. package/docs/examples/proxy/get-rule.md +2 -0
  303. package/docs/examples/proxy/list-rules.md +3 -0
  304. package/docs/examples/proxy/update-rule-verification.md +2 -0
  305. package/docs/examples/sites/create-deployment.md +7 -0
  306. package/docs/examples/sites/create-duplicate-deployment.md +3 -0
  307. package/docs/examples/sites/create-template-deployment.md +7 -0
  308. package/docs/examples/sites/create-variable.md +5 -0
  309. package/docs/examples/sites/create-vcs-deployment.md +5 -0
  310. package/docs/examples/sites/create.md +19 -0
  311. package/docs/examples/sites/delete-deployment.md +3 -0
  312. package/docs/examples/sites/delete-log.md +3 -0
  313. package/docs/examples/sites/delete-variable.md +3 -0
  314. package/docs/examples/sites/delete.md +2 -0
  315. package/docs/examples/sites/get-deployment-download.md +4 -0
  316. package/docs/examples/sites/get-deployment.md +3 -0
  317. package/docs/examples/sites/get-log.md +3 -0
  318. package/docs/examples/sites/get-template.md +2 -0
  319. package/docs/examples/sites/get-usage.md +3 -0
  320. package/docs/examples/sites/get-variable.md +3 -0
  321. package/docs/examples/sites/get.md +2 -0
  322. package/docs/examples/sites/list-deployments.md +4 -0
  323. package/docs/examples/sites/list-frameworks.md +1 -0
  324. package/docs/examples/sites/list-logs.md +3 -0
  325. package/docs/examples/sites/list-specifications.md +1 -0
  326. package/docs/examples/sites/list-templates.md +5 -0
  327. package/docs/examples/sites/list-usage.md +2 -0
  328. package/docs/examples/sites/list-variables.md +2 -0
  329. package/docs/examples/sites/list.md +3 -0
  330. package/docs/examples/sites/update-deployment-status.md +3 -0
  331. package/docs/examples/sites/update-site-deployment.md +3 -0
  332. package/docs/examples/sites/update-variable.md +6 -0
  333. package/docs/examples/sites/update.md +19 -0
  334. package/docs/examples/storage/create-bucket.md +11 -0
  335. package/docs/examples/storage/create-file.md +5 -0
  336. package/docs/examples/storage/delete-bucket.md +2 -0
  337. package/docs/examples/storage/delete-file.md +3 -0
  338. package/docs/examples/storage/get-bucket-usage.md +3 -0
  339. package/docs/examples/storage/get-bucket.md +2 -0
  340. package/docs/examples/storage/get-file-download.md +4 -0
  341. package/docs/examples/storage/get-file-preview.md +15 -0
  342. package/docs/examples/storage/get-file-view.md +4 -0
  343. package/docs/examples/storage/get-file.md +3 -0
  344. package/docs/examples/storage/get-usage.md +2 -0
  345. package/docs/examples/storage/list-buckets.md +3 -0
  346. package/docs/examples/storage/list-files.md +4 -0
  347. package/docs/examples/storage/update-bucket.md +11 -0
  348. package/docs/examples/storage/update-file.md +5 -0
  349. package/docs/examples/teams/create-membership.md +8 -0
  350. package/docs/examples/teams/create.md +4 -0
  351. package/docs/examples/teams/delete-membership.md +3 -0
  352. package/docs/examples/teams/delete.md +2 -0
  353. package/docs/examples/teams/get-membership.md +3 -0
  354. package/docs/examples/teams/get-prefs.md +2 -0
  355. package/docs/examples/teams/get.md +2 -0
  356. package/docs/examples/teams/list-logs.md +3 -0
  357. package/docs/examples/teams/list-memberships.md +4 -0
  358. package/docs/examples/teams/list.md +3 -0
  359. package/docs/examples/teams/update-membership-status.md +5 -0
  360. package/docs/examples/teams/update-membership.md +4 -0
  361. package/docs/examples/teams/update-name.md +3 -0
  362. package/docs/examples/teams/update-prefs.md +3 -0
  363. package/docs/examples/tokens/create-file-token.md +4 -0
  364. package/docs/examples/tokens/delete.md +2 -0
  365. package/docs/examples/tokens/get.md +2 -0
  366. package/docs/examples/tokens/list.md +4 -0
  367. package/docs/examples/tokens/update.md +3 -0
  368. package/docs/examples/users/create-argon2user.md +5 -0
  369. package/docs/examples/users/create-bcrypt-user.md +5 -0
  370. package/docs/examples/users/create-j-w-t.md +4 -0
  371. package/docs/examples/users/create-m-d5user.md +5 -0
  372. package/docs/examples/users/create-mfa-recovery-codes.md +2 -0
  373. package/docs/examples/users/create-p-h-pass-user.md +5 -0
  374. package/docs/examples/users/create-s-h-a-user.md +6 -0
  375. package/docs/examples/users/create-scrypt-modified-user.md +8 -0
  376. package/docs/examples/users/create-scrypt-user.md +10 -0
  377. package/docs/examples/users/create-session.md +2 -0
  378. package/docs/examples/users/create-target.md +7 -0
  379. package/docs/examples/users/create-token.md +4 -0
  380. package/docs/examples/users/create.md +6 -0
  381. package/docs/examples/users/delete-identity.md +2 -0
  382. package/docs/examples/users/delete-mfa-authenticator.md +3 -0
  383. package/docs/examples/users/delete-session.md +3 -0
  384. package/docs/examples/users/delete-sessions.md +2 -0
  385. package/docs/examples/users/delete-target.md +3 -0
  386. package/docs/examples/users/delete.md +2 -0
  387. package/docs/examples/users/get-mfa-recovery-codes.md +2 -0
  388. package/docs/examples/users/get-prefs.md +2 -0
  389. package/docs/examples/users/get-target.md +3 -0
  390. package/docs/examples/users/get-usage.md +2 -0
  391. package/docs/examples/users/get.md +2 -0
  392. package/docs/examples/users/list-identities.md +3 -0
  393. package/docs/examples/users/list-logs.md +3 -0
  394. package/docs/examples/users/list-memberships.md +4 -0
  395. package/docs/examples/users/list-mfa-factors.md +2 -0
  396. package/docs/examples/users/list-sessions.md +2 -0
  397. package/docs/examples/users/list-targets.md +3 -0
  398. package/docs/examples/users/list.md +3 -0
  399. package/docs/examples/users/update-email-verification.md +3 -0
  400. package/docs/examples/users/update-email.md +3 -0
  401. package/docs/examples/users/update-labels.md +3 -0
  402. package/docs/examples/users/update-mfa-recovery-codes.md +2 -0
  403. package/docs/examples/users/update-mfa.md +3 -0
  404. package/docs/examples/users/update-name.md +3 -0
  405. package/docs/examples/users/update-password.md +3 -0
  406. package/docs/examples/users/update-phone-verification.md +3 -0
  407. package/docs/examples/users/update-phone.md +3 -0
  408. package/docs/examples/users/update-prefs.md +3 -0
  409. package/docs/examples/users/update-status.md +3 -0
  410. package/docs/examples/users/update-target.md +6 -0
  411. package/docs/examples/vcs/create-repository-detection.md +5 -0
  412. package/docs/examples/vcs/create-repository.md +4 -0
  413. package/docs/examples/vcs/delete-installation.md +2 -0
  414. package/docs/examples/vcs/get-installation.md +2 -0
  415. package/docs/examples/vcs/get-repository-contents.md +5 -0
  416. package/docs/examples/vcs/get-repository.md +3 -0
  417. package/docs/examples/vcs/list-installations.md +3 -0
  418. package/docs/examples/vcs/list-repositories.md +4 -0
  419. package/docs/examples/vcs/list-repository-branches.md +3 -0
  420. package/docs/examples/vcs/update-external-deployments.md +4 -0
  421. package/functions/Starter function/.prettierrc.json +6 -0
  422. package/functions/Starter function/README.md +48 -0
  423. package/functions/Starter function/package-lock.json +60 -0
  424. package/functions/Starter function/package.json +16 -0
  425. package/functions/Starter function/src/main.js +35 -0
  426. package/generate/appwrite.d.ts +18 -0
  427. package/index.js +109 -0
  428. package/install.ps1 +98 -0
  429. package/install.sh +157 -0
  430. package/lib/client.js +259 -0
  431. package/lib/commands/account.js +2074 -0
  432. package/lib/commands/avatars.js +491 -0
  433. package/lib/commands/console.js +129 -0
  434. package/lib/commands/databases.js +2972 -0
  435. package/lib/commands/functions.js +1737 -0
  436. package/lib/commands/generic.js +328 -0
  437. package/lib/commands/graphql.js +128 -0
  438. package/lib/commands/health.js +891 -0
  439. package/lib/commands/init.js +566 -0
  440. package/lib/commands/locale.js +324 -0
  441. package/lib/commands/messaging.js +2970 -0
  442. package/lib/commands/migrations.js +751 -0
  443. package/lib/commands/organizations.js +48 -0
  444. package/lib/commands/project.js +308 -0
  445. package/lib/commands/projects.js +2615 -0
  446. package/lib/commands/proxy.js +406 -0
  447. package/lib/commands/pull.js +474 -0
  448. package/lib/commands/push.js +2117 -0
  449. package/lib/commands/run.js +330 -0
  450. package/lib/commands/sites.js +1663 -0
  451. package/lib/commands/storage.js +990 -0
  452. package/lib/commands/teams.js +682 -0
  453. package/lib/commands/tokens.js +261 -0
  454. package/lib/commands/types.js +156 -0
  455. package/lib/commands/users.js +2035 -0
  456. package/lib/commands/vcs.js +484 -0
  457. package/lib/config.js +705 -0
  458. package/lib/emulation/docker.js +264 -0
  459. package/lib/emulation/utils.js +186 -0
  460. package/lib/exception.js +9 -0
  461. package/lib/id.js +30 -0
  462. package/lib/paginate.js +52 -0
  463. package/lib/parser.js +246 -0
  464. package/lib/questions.js +1006 -0
  465. package/lib/sdks.js +60 -0
  466. package/lib/spinner.js +104 -0
  467. package/lib/type-generation/attribute.js +16 -0
  468. package/lib/type-generation/languages/dart.js +196 -0
  469. package/lib/type-generation/languages/java.js +130 -0
  470. package/lib/type-generation/languages/javascript.js +102 -0
  471. package/lib/type-generation/languages/kotlin.js +84 -0
  472. package/lib/type-generation/languages/language.js +125 -0
  473. package/lib/type-generation/languages/php.js +109 -0
  474. package/lib/type-generation/languages/swift.js +169 -0
  475. package/lib/type-generation/languages/typescript.js +102 -0
  476. package/lib/utils.js +289 -0
  477. package/lib/validations.js +17 -0
  478. package/package.json +50 -0
  479. package/scoop/appwrite.json +30 -0
  480. package/sites/JavaScript starter/.env.example +3 -0
  481. package/sites/JavaScript starter/LICENSE +21 -0
  482. package/sites/JavaScript starter/images/appwrite.svg +8 -0
  483. package/sites/JavaScript starter/images/javascript.svg +5 -0
  484. package/sites/JavaScript starter/index.html +250 -0
  485. package/sites/JavaScript starter/lib/appwrite.js +10 -0
  486. package/sites/JavaScript starter/package-lock.json +1431 -0
  487. package/sites/JavaScript starter/package.json +21 -0
  488. package/sites/JavaScript starter/readme.md +26 -0
  489. package/sites/JavaScript starter/src/javascript.svg +1 -0
  490. package/sites/JavaScript starter/style/app.css +20 -0
  491. package/sites/JavaScript starter/vite.config.js +7 -0
@@ -0,0 +1,1737 @@
1
+ const fs = require('fs');
2
+ const pathLib = require('path');
3
+ const tar = require("tar");
4
+ const ignore = require("ignore");
5
+ const { promisify } = require('util');
6
+ const libClient = require('../client.js');
7
+ const { getAllFiles, showConsoleLink } = require('../utils.js');
8
+ const { Command } = require('commander');
9
+ const { sdkForProject, sdkForConsole } = require('../sdks')
10
+ const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
11
+ const { localConfig, globalConfig } = require("../config");
12
+ const { File } = require('undici');
13
+ const { ReadableStream } = require('stream/web');
14
+
15
+ /**
16
+ * @param {fs.ReadStream} readStream
17
+ * @returns {ReadableStream}
18
+ */
19
+ function convertReadStreamToReadableStream(readStream) {
20
+ return new ReadableStream({
21
+ start(controller) {
22
+ readStream.on("data", (chunk) => {
23
+ controller.enqueue(chunk);
24
+ });
25
+ readStream.on("end", () => {
26
+ controller.close();
27
+ });
28
+ readStream.on("error", (err) => {
29
+ controller.error(err);
30
+ });
31
+ },
32
+ cancel() {
33
+ readStream.destroy();
34
+ },
35
+ });
36
+ }
37
+
38
+ const functions = new Command("functions").description(commandDescriptions['functions'] ?? '').configureHelp({
39
+ helpWidth: process.stdout.columns || 80
40
+ })
41
+
42
+ /**
43
+ * @typedef {Object} FunctionsListRequestParams
44
+ * @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId
45
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
46
+ * @property {boolean} overrideForCli
47
+ * @property {boolean} parseOutput
48
+ * @property {libClient | undefined} sdk
49
+ */
50
+
51
+ /**
52
+ * @param {FunctionsListRequestParams} params
53
+ */
54
+ const functionsList = async ({queries,search,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
55
+ let client = !sdk ? await sdkForProject() :
56
+ sdk;
57
+ let apiPath = '/functions';
58
+ let payload = {};
59
+ if (typeof queries !== 'undefined') {
60
+ payload['queries'] = queries;
61
+ }
62
+ if (typeof search !== 'undefined') {
63
+ payload['search'] = search;
64
+ }
65
+
66
+ let response = undefined;
67
+
68
+ response = await client.call('get', apiPath, {
69
+ }, payload);
70
+
71
+ if (parseOutput) {
72
+ if(console) {
73
+ showConsoleLink('functions', 'list');
74
+ } else {
75
+ parse(response)
76
+ }
77
+ }
78
+
79
+ return response;
80
+
81
+ }
82
+
83
+ /**
84
+ * @typedef {Object} FunctionsCreateRequestParams
85
+ * @property {string} functionId Function ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.
86
+ * @property {string} name Function name. Max length: 128 chars.
87
+ * @property {Runtime} runtime Execution runtime.
88
+ * @property {string[]} execute An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.
89
+ * @property {string[]} events Events list. Maximum of 100 events are allowed.
90
+ * @property {string} schedule Schedule CRON syntax.
91
+ * @property {number} timeout Function maximum execution time in seconds.
92
+ * @property {boolean} enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
93
+ * @property {boolean} logging When disabled, executions will exclude logs and errors, and will be slightly faster.
94
+ * @property {string} entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
95
+ * @property {string} commands Build Commands.
96
+ * @property {string[]} scopes List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.
97
+ * @property {string} installationId Appwrite Installation ID for VCS (Version Control System) deployment.
98
+ * @property {string} providerRepositoryId Repository ID of the repo linked to the function.
99
+ * @property {string} providerBranch Production branch for the repo linked to the function.
100
+ * @property {boolean} providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
101
+ * @property {string} providerRootDirectory Path to function code in the linked repo.
102
+ * @property {string} specification Runtime specification for the function and builds.
103
+ * @property {boolean} overrideForCli
104
+ * @property {boolean} parseOutput
105
+ * @property {libClient | undefined} sdk
106
+ */
107
+
108
+ /**
109
+ * @param {FunctionsCreateRequestParams} params
110
+ */
111
+ const functionsCreate = async ({functionId,name,runtime,execute,events,schedule,timeout,enabled,logging,entrypoint,commands,scopes,installationId,providerRepositoryId,providerBranch,providerSilentMode,providerRootDirectory,specification,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
112
+ let client = !sdk ? await sdkForProject() :
113
+ sdk;
114
+ let apiPath = '/functions';
115
+ let payload = {};
116
+ if (typeof functionId !== 'undefined') {
117
+ payload['functionId'] = functionId;
118
+ }
119
+ if (typeof name !== 'undefined') {
120
+ payload['name'] = name;
121
+ }
122
+ if (typeof runtime !== 'undefined') {
123
+ payload['runtime'] = runtime;
124
+ }
125
+ execute = execute === true ? [] : execute;
126
+ if (typeof execute !== 'undefined') {
127
+ payload['execute'] = execute;
128
+ }
129
+ events = events === true ? [] : events;
130
+ if (typeof events !== 'undefined') {
131
+ payload['events'] = events;
132
+ }
133
+ if (typeof schedule !== 'undefined') {
134
+ payload['schedule'] = schedule;
135
+ }
136
+ if (typeof timeout !== 'undefined') {
137
+ payload['timeout'] = timeout;
138
+ }
139
+ if (typeof enabled !== 'undefined') {
140
+ payload['enabled'] = enabled;
141
+ }
142
+ if (typeof logging !== 'undefined') {
143
+ payload['logging'] = logging;
144
+ }
145
+ if (typeof entrypoint !== 'undefined') {
146
+ payload['entrypoint'] = entrypoint;
147
+ }
148
+ if (typeof commands !== 'undefined') {
149
+ payload['commands'] = commands;
150
+ }
151
+ scopes = scopes === true ? [] : scopes;
152
+ if (typeof scopes !== 'undefined') {
153
+ payload['scopes'] = scopes;
154
+ }
155
+ if (typeof installationId !== 'undefined') {
156
+ payload['installationId'] = installationId;
157
+ }
158
+ if (typeof providerRepositoryId !== 'undefined') {
159
+ payload['providerRepositoryId'] = providerRepositoryId;
160
+ }
161
+ if (typeof providerBranch !== 'undefined') {
162
+ payload['providerBranch'] = providerBranch;
163
+ }
164
+ if (typeof providerSilentMode !== 'undefined') {
165
+ payload['providerSilentMode'] = providerSilentMode;
166
+ }
167
+ if (typeof providerRootDirectory !== 'undefined') {
168
+ payload['providerRootDirectory'] = providerRootDirectory;
169
+ }
170
+ if (typeof specification !== 'undefined') {
171
+ payload['specification'] = specification;
172
+ }
173
+
174
+ let response = undefined;
175
+
176
+ response = await client.call('post', apiPath, {
177
+ 'content-type': 'application/json',
178
+ }, payload);
179
+
180
+ if (parseOutput) {
181
+ parse(response)
182
+ }
183
+
184
+ return response;
185
+
186
+ }
187
+
188
+ /**
189
+ * @typedef {Object} FunctionsListRuntimesRequestParams
190
+ * @property {boolean} overrideForCli
191
+ * @property {boolean} parseOutput
192
+ * @property {libClient | undefined} sdk
193
+ */
194
+
195
+ /**
196
+ * @param {FunctionsListRuntimesRequestParams} params
197
+ */
198
+ const functionsListRuntimes = async ({parseOutput = true, overrideForCli = false, sdk = undefined}) => {
199
+ let client = !sdk ? await sdkForProject() :
200
+ sdk;
201
+ let apiPath = '/functions/runtimes';
202
+ let payload = {};
203
+
204
+ let response = undefined;
205
+
206
+ response = await client.call('get', apiPath, {
207
+ }, payload);
208
+
209
+ if (parseOutput) {
210
+ parse(response)
211
+ }
212
+
213
+ return response;
214
+
215
+ }
216
+
217
+ /**
218
+ * @typedef {Object} FunctionsListSpecificationsRequestParams
219
+ * @property {boolean} overrideForCli
220
+ * @property {boolean} parseOutput
221
+ * @property {libClient | undefined} sdk
222
+ */
223
+
224
+ /**
225
+ * @param {FunctionsListSpecificationsRequestParams} params
226
+ */
227
+ const functionsListSpecifications = async ({parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
228
+ let client = !sdk ? await sdkForProject() :
229
+ sdk;
230
+ let apiPath = '/functions/specifications';
231
+ let payload = {};
232
+
233
+ let response = undefined;
234
+
235
+ response = await client.call('get', apiPath, {
236
+ }, payload);
237
+
238
+ if (parseOutput) {
239
+ if(console) {
240
+ showConsoleLink('functions', 'listSpecifications');
241
+ } else {
242
+ parse(response)
243
+ }
244
+ }
245
+
246
+ return response;
247
+
248
+ }
249
+
250
+ /**
251
+ * @typedef {Object} FunctionsListTemplatesRequestParams
252
+ * @property {string[]} runtimes List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed.
253
+ * @property {string[]} useCases List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed.
254
+ * @property {number} limit Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.
255
+ * @property {number} offset Offset the list of returned templates. Maximum offset is 5000.
256
+ * @property {boolean} overrideForCli
257
+ * @property {boolean} parseOutput
258
+ * @property {libClient | undefined} sdk
259
+ */
260
+
261
+ /**
262
+ * @param {FunctionsListTemplatesRequestParams} params
263
+ */
264
+ const functionsListTemplates = async ({runtimes,useCases,limit,offset,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
265
+ let client = !sdk ? await sdkForProject() :
266
+ sdk;
267
+ let apiPath = '/functions/templates';
268
+ let payload = {};
269
+ if (typeof runtimes !== 'undefined') {
270
+ payload['runtimes'] = runtimes;
271
+ }
272
+ if (typeof useCases !== 'undefined') {
273
+ payload['useCases'] = useCases;
274
+ }
275
+ if (typeof limit !== 'undefined') {
276
+ payload['limit'] = limit;
277
+ }
278
+ if (typeof offset !== 'undefined') {
279
+ payload['offset'] = offset;
280
+ }
281
+
282
+ let response = undefined;
283
+
284
+ response = await client.call('get', apiPath, {
285
+ }, payload);
286
+
287
+ if (parseOutput) {
288
+ if(console) {
289
+ showConsoleLink('functions', 'listTemplates');
290
+ } else {
291
+ parse(response)
292
+ }
293
+ }
294
+
295
+ return response;
296
+
297
+ }
298
+
299
+ /**
300
+ * @typedef {Object} FunctionsGetTemplateRequestParams
301
+ * @property {string} templateId Template ID.
302
+ * @property {boolean} overrideForCli
303
+ * @property {boolean} parseOutput
304
+ * @property {libClient | undefined} sdk
305
+ */
306
+
307
+ /**
308
+ * @param {FunctionsGetTemplateRequestParams} params
309
+ */
310
+ const functionsGetTemplate = async ({templateId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
311
+ let client = !sdk ? await sdkForProject() :
312
+ sdk;
313
+ let apiPath = '/functions/templates/{templateId}'.replace('{templateId}', templateId);
314
+ let payload = {};
315
+
316
+ let response = undefined;
317
+
318
+ response = await client.call('get', apiPath, {
319
+ }, payload);
320
+
321
+ if (parseOutput) {
322
+ if(console) {
323
+ showConsoleLink('functions', 'getTemplate', templateId);
324
+ } else {
325
+ parse(response)
326
+ }
327
+ }
328
+
329
+ return response;
330
+
331
+ }
332
+
333
+ /**
334
+ * @typedef {Object} FunctionsListUsageRequestParams
335
+ * @property {FunctionUsageRange} range Date range.
336
+ * @property {boolean} overrideForCli
337
+ * @property {boolean} parseOutput
338
+ * @property {libClient | undefined} sdk
339
+ */
340
+
341
+ /**
342
+ * @param {FunctionsListUsageRequestParams} params
343
+ */
344
+ const functionsListUsage = async ({range,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
345
+ let client = !sdk ? await sdkForProject() :
346
+ sdk;
347
+ let apiPath = '/functions/usage';
348
+ let payload = {};
349
+ if (typeof range !== 'undefined') {
350
+ payload['range'] = range;
351
+ }
352
+
353
+ let response = undefined;
354
+
355
+ response = await client.call('get', apiPath, {
356
+ }, payload);
357
+
358
+ if (parseOutput) {
359
+ if(console) {
360
+ showConsoleLink('functions', 'listUsage');
361
+ } else {
362
+ parse(response)
363
+ }
364
+ }
365
+
366
+ return response;
367
+
368
+ }
369
+
370
+ /**
371
+ * @typedef {Object} FunctionsGetRequestParams
372
+ * @property {string} functionId Function ID.
373
+ * @property {boolean} overrideForCli
374
+ * @property {boolean} parseOutput
375
+ * @property {libClient | undefined} sdk
376
+ */
377
+
378
+ /**
379
+ * @param {FunctionsGetRequestParams} params
380
+ */
381
+ const functionsGet = async ({functionId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
382
+ let client = !sdk ? await sdkForProject() :
383
+ sdk;
384
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
385
+ let payload = {};
386
+
387
+ let response = undefined;
388
+
389
+ response = await client.call('get', apiPath, {
390
+ }, payload);
391
+
392
+ if (parseOutput) {
393
+ if(console) {
394
+ showConsoleLink('functions', 'get', functionId);
395
+ } else {
396
+ parse(response)
397
+ }
398
+ }
399
+
400
+ return response;
401
+
402
+ }
403
+
404
+ /**
405
+ * @typedef {Object} FunctionsUpdateRequestParams
406
+ * @property {string} functionId Function ID.
407
+ * @property {string} name Function name. Max length: 128 chars.
408
+ * @property {Runtime} runtime Execution runtime.
409
+ * @property {string[]} execute An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.
410
+ * @property {string[]} events Events list. Maximum of 100 events are allowed.
411
+ * @property {string} schedule Schedule CRON syntax.
412
+ * @property {number} timeout Maximum execution time in seconds.
413
+ * @property {boolean} enabled Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.
414
+ * @property {boolean} logging When disabled, executions will exclude logs and errors, and will be slightly faster.
415
+ * @property {string} entrypoint Entrypoint File. This path is relative to the "providerRootDirectory".
416
+ * @property {string} commands Build Commands.
417
+ * @property {string[]} scopes List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.
418
+ * @property {string} installationId Appwrite Installation ID for VCS (Version Controle System) deployment.
419
+ * @property {string} providerRepositoryId Repository ID of the repo linked to the function
420
+ * @property {string} providerBranch Production branch for the repo linked to the function
421
+ * @property {boolean} providerSilentMode Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.
422
+ * @property {string} providerRootDirectory Path to function code in the linked repo.
423
+ * @property {string} specification Runtime specification for the function and builds.
424
+ * @property {boolean} overrideForCli
425
+ * @property {boolean} parseOutput
426
+ * @property {libClient | undefined} sdk
427
+ */
428
+
429
+ /**
430
+ * @param {FunctionsUpdateRequestParams} params
431
+ */
432
+ const functionsUpdate = async ({functionId,name,runtime,execute,events,schedule,timeout,enabled,logging,entrypoint,commands,scopes,installationId,providerRepositoryId,providerBranch,providerSilentMode,providerRootDirectory,specification,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
433
+ let client = !sdk ? await sdkForProject() :
434
+ sdk;
435
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
436
+ let payload = {};
437
+ if (typeof name !== 'undefined') {
438
+ payload['name'] = name;
439
+ }
440
+ if (typeof runtime !== 'undefined') {
441
+ payload['runtime'] = runtime;
442
+ }
443
+ execute = execute === true ? [] : execute;
444
+ if (typeof execute !== 'undefined') {
445
+ payload['execute'] = execute;
446
+ }
447
+ events = events === true ? [] : events;
448
+ if (typeof events !== 'undefined') {
449
+ payload['events'] = events;
450
+ }
451
+ if (typeof schedule !== 'undefined') {
452
+ payload['schedule'] = schedule;
453
+ }
454
+ if (typeof timeout !== 'undefined') {
455
+ payload['timeout'] = timeout;
456
+ }
457
+ if (typeof enabled !== 'undefined') {
458
+ payload['enabled'] = enabled;
459
+ }
460
+ if (typeof logging !== 'undefined') {
461
+ payload['logging'] = logging;
462
+ }
463
+ if (typeof entrypoint !== 'undefined') {
464
+ payload['entrypoint'] = entrypoint;
465
+ }
466
+ if (typeof commands !== 'undefined') {
467
+ payload['commands'] = commands;
468
+ }
469
+ scopes = scopes === true ? [] : scopes;
470
+ if (typeof scopes !== 'undefined') {
471
+ payload['scopes'] = scopes;
472
+ }
473
+ if (typeof installationId !== 'undefined') {
474
+ payload['installationId'] = installationId;
475
+ }
476
+ if (typeof providerRepositoryId !== 'undefined') {
477
+ payload['providerRepositoryId'] = providerRepositoryId;
478
+ }
479
+ if (typeof providerBranch !== 'undefined') {
480
+ payload['providerBranch'] = providerBranch;
481
+ }
482
+ if (typeof providerSilentMode !== 'undefined') {
483
+ payload['providerSilentMode'] = providerSilentMode;
484
+ }
485
+ if (typeof providerRootDirectory !== 'undefined') {
486
+ payload['providerRootDirectory'] = providerRootDirectory;
487
+ }
488
+ if (typeof specification !== 'undefined') {
489
+ payload['specification'] = specification;
490
+ }
491
+
492
+ let response = undefined;
493
+
494
+ response = await client.call('put', apiPath, {
495
+ 'content-type': 'application/json',
496
+ }, payload);
497
+
498
+ if (parseOutput) {
499
+ parse(response)
500
+ }
501
+
502
+ return response;
503
+
504
+ }
505
+
506
+ /**
507
+ * @typedef {Object} FunctionsDeleteRequestParams
508
+ * @property {string} functionId Function ID.
509
+ * @property {boolean} overrideForCli
510
+ * @property {boolean} parseOutput
511
+ * @property {libClient | undefined} sdk
512
+ */
513
+
514
+ /**
515
+ * @param {FunctionsDeleteRequestParams} params
516
+ */
517
+ const functionsDelete = async ({functionId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
518
+ let client = !sdk ? await sdkForProject() :
519
+ sdk;
520
+ let apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
521
+ let payload = {};
522
+
523
+ let response = undefined;
524
+
525
+ response = await client.call('delete', apiPath, {
526
+ 'content-type': 'application/json',
527
+ }, payload);
528
+
529
+ if (parseOutput) {
530
+ parse(response)
531
+ }
532
+
533
+ return response;
534
+
535
+ }
536
+
537
+ /**
538
+ * @typedef {Object} FunctionsUpdateFunctionDeploymentRequestParams
539
+ * @property {string} functionId Function ID.
540
+ * @property {string} deploymentId Deployment ID.
541
+ * @property {boolean} overrideForCli
542
+ * @property {boolean} parseOutput
543
+ * @property {libClient | undefined} sdk
544
+ */
545
+
546
+ /**
547
+ * @param {FunctionsUpdateFunctionDeploymentRequestParams} params
548
+ */
549
+ const functionsUpdateFunctionDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
550
+ let client = !sdk ? await sdkForProject() :
551
+ sdk;
552
+ let apiPath = '/functions/{functionId}/deployment'.replace('{functionId}', functionId);
553
+ let payload = {};
554
+ if (typeof deploymentId !== 'undefined') {
555
+ payload['deploymentId'] = deploymentId;
556
+ }
557
+
558
+ let response = undefined;
559
+
560
+ response = await client.call('patch', apiPath, {
561
+ 'content-type': 'application/json',
562
+ }, payload);
563
+
564
+ if (parseOutput) {
565
+ parse(response)
566
+ }
567
+
568
+ return response;
569
+
570
+ }
571
+
572
+ /**
573
+ * @typedef {Object} FunctionsListDeploymentsRequestParams
574
+ * @property {string} functionId Function ID.
575
+ * @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type
576
+ * @property {string} search Search term to filter your list results. Max length: 256 chars.
577
+ * @property {boolean} overrideForCli
578
+ * @property {boolean} parseOutput
579
+ * @property {libClient | undefined} sdk
580
+ */
581
+
582
+ /**
583
+ * @param {FunctionsListDeploymentsRequestParams} params
584
+ */
585
+ const functionsListDeployments = async ({functionId,queries,search,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
586
+ let client = !sdk ? await sdkForProject() :
587
+ sdk;
588
+ let apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
589
+ let payload = {};
590
+ if (typeof queries !== 'undefined') {
591
+ payload['queries'] = queries;
592
+ }
593
+ if (typeof search !== 'undefined') {
594
+ payload['search'] = search;
595
+ }
596
+
597
+ let response = undefined;
598
+
599
+ response = await client.call('get', apiPath, {
600
+ }, payload);
601
+
602
+ if (parseOutput) {
603
+ if(console) {
604
+ showConsoleLink('functions', 'listDeployments', functionId);
605
+ } else {
606
+ parse(response)
607
+ }
608
+ }
609
+
610
+ return response;
611
+
612
+ }
613
+
614
+ /**
615
+ * @typedef {Object} FunctionsCreateDeploymentRequestParams
616
+ * @property {string} functionId Function ID.
617
+ * @property {string} code Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.
618
+ * @property {boolean} activate Automatically activate the deployment when it is finished building.
619
+ * @property {string} entrypoint Entrypoint File.
620
+ * @property {string} commands Build Commands.
621
+ * @property {boolean} overrideForCli
622
+ * @property {boolean} parseOutput
623
+ * @property {libClient | undefined} sdk
624
+ * @property {CallableFunction} onProgress
625
+ */
626
+
627
+ /**
628
+ * @param {FunctionsCreateDeploymentRequestParams} params
629
+ */
630
+ const functionsCreateDeployment = async ({functionId,code,activate,entrypoint,commands,parseOutput = true, overrideForCli = false, sdk = undefined,onProgress = () => {}}) => {
631
+ let client = !sdk ? await sdkForProject() :
632
+ sdk;
633
+ let apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
634
+ let payload = {};
635
+ if (typeof entrypoint !== 'undefined') {
636
+ payload['entrypoint'] = entrypoint;
637
+ }
638
+ if (typeof commands !== 'undefined') {
639
+ payload['commands'] = commands;
640
+ }
641
+ const folderPath = fs.realpathSync(code);
642
+ if (!fs.lstatSync(folderPath).isDirectory()) {
643
+ throw new Error('The path is not a directory.');
644
+ }
645
+
646
+ const ignorer = ignore();
647
+
648
+ const resourceId = functionId;
649
+ const resourceConfig = localConfig.getFunction(resourceId);
650
+
651
+ ignorer.add('.appwrite');
652
+
653
+ if (resourceConfig.ignore) {
654
+ ignorer.add(resourceConfig.ignore);
655
+ } else if (fs.existsSync(pathLib.join(code, '.gitignore'))) {
656
+ ignorer.add(fs.readFileSync(pathLib.join(code, '.gitignore')).toString());
657
+ }
658
+
659
+ const files = getAllFiles(code).map((file) => pathLib.relative(code, file)).filter((file) => !ignorer.ignores(file));
660
+
661
+ const archiveFileName = `functions-${resourceId}-code.tar.gz`;
662
+
663
+ await tar
664
+ .create({
665
+ gzip: true,
666
+ sync: true,
667
+ cwd: folderPath,
668
+ file: archiveFileName
669
+ }, files);
670
+
671
+ let archivePath = fs.realpathSync(archiveFileName)
672
+ if (typeof archivePath !== 'undefined') {
673
+ payload['code'] = archivePath;
674
+ code = archivePath;
675
+ }
676
+
677
+ const filePath = fs.realpathSync(code);
678
+ const nodeStream = fs.createReadStream(filePath);
679
+ const stream = convertReadStreamToReadableStream(nodeStream);
680
+
681
+ if (typeof filePath !== 'undefined') {
682
+ code = { type: 'file', stream, filename: pathLib.basename(filePath), size: fs.statSync(filePath).size };
683
+ payload['code'] = code
684
+ }
685
+ if (typeof activate !== 'undefined') {
686
+ payload['activate'] = activate;
687
+ }
688
+
689
+ const size = code.size;
690
+
691
+ const apiHeaders = {
692
+ 'content-type': 'multipart/form-data',
693
+ };
694
+
695
+ let id = undefined;
696
+ let response = undefined;
697
+
698
+ let chunksUploaded = 0;
699
+
700
+ let currentChunk = 1;
701
+ let currentPosition = 0;
702
+ let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
703
+
704
+ const uploadChunk = async (lastUpload = false) => {
705
+ if(currentChunk <= chunksUploaded) {
706
+ return;
707
+ }
708
+
709
+ const start = ((currentChunk - 1) * client.CHUNK_SIZE);
710
+ let end = start + currentPosition - 1;
711
+
712
+ if(!lastUpload || currentChunk !== 1) {
713
+ apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
714
+ }
715
+
716
+ let uploadableChunkTrimmed;
717
+
718
+ if(currentPosition + 1 >= client.CHUNK_SIZE) {
719
+ uploadableChunkTrimmed = uploadableChunk;
720
+ } else {
721
+ uploadableChunkTrimmed = new Uint8Array(currentPosition);
722
+ for(let i = 0; i <= currentPosition; i++) {
723
+ uploadableChunkTrimmed[i] = uploadableChunk[i];
724
+ }
725
+ }
726
+
727
+ if (id) {
728
+ apiHeaders['x-appwrite-id'] = id;
729
+ }
730
+
731
+ payload['code'] = { type: 'file', file: new File([uploadableChunkTrimmed], code.filename), filename: code.filename };
732
+
733
+ response = await client.call('post', apiPath, apiHeaders, payload);
734
+
735
+ if (!id) {
736
+ id = response['$id'];
737
+ }
738
+
739
+ if (onProgress !== null) {
740
+ onProgress({
741
+ $id: response['$id'],
742
+ progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
743
+ sizeUploaded: end+1,
744
+ chunksTotal: response['chunksTotal'],
745
+ chunksUploaded: response['chunksUploaded']
746
+ });
747
+ }
748
+
749
+ uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
750
+ currentChunk++;
751
+ currentPosition = 0;
752
+ }
753
+
754
+ for await (const chunk of code.stream) {
755
+ for(const b of chunk) {
756
+ uploadableChunk[currentPosition] = b;
757
+
758
+ currentPosition++;
759
+ if(currentPosition >= client.CHUNK_SIZE) {
760
+ await uploadChunk();
761
+ currentPosition = 0;
762
+ }
763
+ }
764
+ }
765
+
766
+ if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
767
+ await uploadChunk(true);
768
+ }
769
+
770
+ await fs.unlink(filePath,()=>{});
771
+
772
+ if (parseOutput) {
773
+ parse(response)
774
+ }
775
+
776
+ return response;
777
+ }
778
+
779
+ /**
780
+ * @typedef {Object} FunctionsCreateDuplicateDeploymentRequestParams
781
+ * @property {string} functionId Function ID.
782
+ * @property {string} deploymentId Deployment ID.
783
+ * @property {string} buildId Build unique ID.
784
+ * @property {boolean} overrideForCli
785
+ * @property {boolean} parseOutput
786
+ * @property {libClient | undefined} sdk
787
+ */
788
+
789
+ /**
790
+ * @param {FunctionsCreateDuplicateDeploymentRequestParams} params
791
+ */
792
+ const functionsCreateDuplicateDeployment = async ({functionId,deploymentId,buildId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
793
+ let client = !sdk ? await sdkForProject() :
794
+ sdk;
795
+ let apiPath = '/functions/{functionId}/deployments/duplicate'.replace('{functionId}', functionId);
796
+ let payload = {};
797
+ if (typeof deploymentId !== 'undefined') {
798
+ payload['deploymentId'] = deploymentId;
799
+ }
800
+ if (typeof buildId !== 'undefined') {
801
+ payload['buildId'] = buildId;
802
+ }
803
+
804
+ let response = undefined;
805
+
806
+ response = await client.call('post', apiPath, {
807
+ 'content-type': 'application/json',
808
+ }, payload);
809
+
810
+ if (parseOutput) {
811
+ parse(response)
812
+ }
813
+
814
+ return response;
815
+
816
+ }
817
+
818
+ /**
819
+ * @typedef {Object} FunctionsCreateTemplateDeploymentRequestParams
820
+ * @property {string} functionId Function ID.
821
+ * @property {string} repository Repository name of the template.
822
+ * @property {string} owner The name of the owner of the template.
823
+ * @property {string} rootDirectory Path to function code in the template repo.
824
+ * @property {string} version Version (tag) for the repo linked to the function template.
825
+ * @property {boolean} activate Automatically activate the deployment when it is finished building.
826
+ * @property {boolean} overrideForCli
827
+ * @property {boolean} parseOutput
828
+ * @property {libClient | undefined} sdk
829
+ */
830
+
831
+ /**
832
+ * @param {FunctionsCreateTemplateDeploymentRequestParams} params
833
+ */
834
+ const functionsCreateTemplateDeployment = async ({functionId,repository,owner,rootDirectory,version,activate,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
835
+ let client = !sdk ? await sdkForProject() :
836
+ sdk;
837
+ let apiPath = '/functions/{functionId}/deployments/template'.replace('{functionId}', functionId);
838
+ let payload = {};
839
+ if (typeof repository !== 'undefined') {
840
+ payload['repository'] = repository;
841
+ }
842
+ if (typeof owner !== 'undefined') {
843
+ payload['owner'] = owner;
844
+ }
845
+ if (typeof rootDirectory !== 'undefined') {
846
+ payload['rootDirectory'] = rootDirectory;
847
+ }
848
+ if (typeof version !== 'undefined') {
849
+ payload['version'] = version;
850
+ }
851
+ if (typeof activate !== 'undefined') {
852
+ payload['activate'] = activate;
853
+ }
854
+
855
+ let response = undefined;
856
+
857
+ response = await client.call('post', apiPath, {
858
+ 'content-type': 'application/json',
859
+ }, payload);
860
+
861
+ if (parseOutput) {
862
+ parse(response)
863
+ }
864
+
865
+ return response;
866
+
867
+ }
868
+
869
+ /**
870
+ * @typedef {Object} FunctionsCreateVcsDeploymentRequestParams
871
+ * @property {string} functionId Function ID.
872
+ * @property {VCSDeploymentType} type Type of reference passed. Allowed values are: branch, commit
873
+ * @property {string} reference VCS reference to create deployment from. Depending on type this can be: branch name, commit hash
874
+ * @property {boolean} activate Automatically activate the deployment when it is finished building.
875
+ * @property {boolean} overrideForCli
876
+ * @property {boolean} parseOutput
877
+ * @property {libClient | undefined} sdk
878
+ */
879
+
880
+ /**
881
+ * @param {FunctionsCreateVcsDeploymentRequestParams} params
882
+ */
883
+ const functionsCreateVcsDeployment = async ({functionId,type,reference,activate,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
884
+ let client = !sdk ? await sdkForProject() :
885
+ sdk;
886
+ let apiPath = '/functions/{functionId}/deployments/vcs'.replace('{functionId}', functionId);
887
+ let payload = {};
888
+ if (typeof type !== 'undefined') {
889
+ payload['type'] = type;
890
+ }
891
+ if (typeof reference !== 'undefined') {
892
+ payload['reference'] = reference;
893
+ }
894
+ if (typeof activate !== 'undefined') {
895
+ payload['activate'] = activate;
896
+ }
897
+
898
+ let response = undefined;
899
+
900
+ response = await client.call('post', apiPath, {
901
+ 'content-type': 'application/json',
902
+ }, payload);
903
+
904
+ if (parseOutput) {
905
+ parse(response)
906
+ }
907
+
908
+ return response;
909
+
910
+ }
911
+
912
+ /**
913
+ * @typedef {Object} FunctionsGetDeploymentRequestParams
914
+ * @property {string} functionId Function ID.
915
+ * @property {string} deploymentId Deployment ID.
916
+ * @property {boolean} overrideForCli
917
+ * @property {boolean} parseOutput
918
+ * @property {libClient | undefined} sdk
919
+ */
920
+
921
+ /**
922
+ * @param {FunctionsGetDeploymentRequestParams} params
923
+ */
924
+ const functionsGetDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
925
+ let client = !sdk ? await sdkForProject() :
926
+ sdk;
927
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
928
+ let payload = {};
929
+
930
+ let response = undefined;
931
+
932
+ response = await client.call('get', apiPath, {
933
+ }, payload);
934
+
935
+ if (parseOutput) {
936
+ if(console) {
937
+ showConsoleLink('functions', 'getDeployment', functionId, deploymentId);
938
+ } else {
939
+ parse(response)
940
+ }
941
+ }
942
+
943
+ return response;
944
+
945
+ }
946
+
947
+ /**
948
+ * @typedef {Object} FunctionsDeleteDeploymentRequestParams
949
+ * @property {string} functionId Function ID.
950
+ * @property {string} deploymentId Deployment ID.
951
+ * @property {boolean} overrideForCli
952
+ * @property {boolean} parseOutput
953
+ * @property {libClient | undefined} sdk
954
+ */
955
+
956
+ /**
957
+ * @param {FunctionsDeleteDeploymentRequestParams} params
958
+ */
959
+ const functionsDeleteDeployment = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
960
+ let client = !sdk ? await sdkForProject() :
961
+ sdk;
962
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
963
+ let payload = {};
964
+
965
+ let response = undefined;
966
+
967
+ response = await client.call('delete', apiPath, {
968
+ 'content-type': 'application/json',
969
+ }, payload);
970
+
971
+ if (parseOutput) {
972
+ parse(response)
973
+ }
974
+
975
+ return response;
976
+
977
+ }
978
+
979
+ /**
980
+ * @typedef {Object} FunctionsGetDeploymentDownloadRequestParams
981
+ * @property {string} functionId Function ID.
982
+ * @property {string} deploymentId Deployment ID.
983
+ * @property {DeploymentDownloadType} type Deployment file to download. Can be: &quot;source&quot;, &quot;output&quot;.
984
+ * @property {boolean} overrideForCli
985
+ * @property {boolean} parseOutput
986
+ * @property {libClient | undefined} sdk
987
+ * @property {string} destination
988
+ */
989
+
990
+ /**
991
+ * @param {FunctionsGetDeploymentDownloadRequestParams} params
992
+ */
993
+ const functionsGetDeploymentDownload = async ({functionId,deploymentId,type,parseOutput = true, overrideForCli = false, sdk = undefined, destination, console}) => {
994
+ let client = !sdk ? await sdkForProject() :
995
+ sdk;
996
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
997
+ let payload = {};
998
+ if (typeof type !== 'undefined') {
999
+ payload['type'] = type;
1000
+ }
1001
+ if (!overrideForCli) {
1002
+ payload['project'] = localConfig.getProject().projectId
1003
+ payload['key'] = globalConfig.getKey();
1004
+ const queryParams = new URLSearchParams(payload);
1005
+ apiPath = `${globalConfig.getEndpoint()}${apiPath}?${queryParams.toString()}`;
1006
+ }
1007
+
1008
+ let response = undefined;
1009
+
1010
+ response = await client.call('get', apiPath, {
1011
+ }, payload, 'arraybuffer');
1012
+
1013
+ if (overrideForCli) {
1014
+ response = Buffer.from(response);
1015
+ }
1016
+
1017
+ fs.writeFileSync(destination, response);
1018
+ if (parseOutput) {
1019
+ if(console) {
1020
+ showConsoleLink('functions', 'getDeploymentDownload', functionId, deploymentId);
1021
+ } else {
1022
+ parse(response)
1023
+ }
1024
+ }
1025
+
1026
+ return response;
1027
+
1028
+ }
1029
+
1030
+ /**
1031
+ * @typedef {Object} FunctionsUpdateDeploymentStatusRequestParams
1032
+ * @property {string} functionId Function ID.
1033
+ * @property {string} deploymentId Deployment ID.
1034
+ * @property {boolean} overrideForCli
1035
+ * @property {boolean} parseOutput
1036
+ * @property {libClient | undefined} sdk
1037
+ */
1038
+
1039
+ /**
1040
+ * @param {FunctionsUpdateDeploymentStatusRequestParams} params
1041
+ */
1042
+ const functionsUpdateDeploymentStatus = async ({functionId,deploymentId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1043
+ let client = !sdk ? await sdkForProject() :
1044
+ sdk;
1045
+ let apiPath = '/functions/{functionId}/deployments/{deploymentId}/status'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
1046
+ let payload = {};
1047
+
1048
+ let response = undefined;
1049
+
1050
+ response = await client.call('patch', apiPath, {
1051
+ 'content-type': 'application/json',
1052
+ }, payload);
1053
+
1054
+ if (parseOutput) {
1055
+ parse(response)
1056
+ }
1057
+
1058
+ return response;
1059
+
1060
+ }
1061
+
1062
+ /**
1063
+ * @typedef {Object} FunctionsListExecutionsRequestParams
1064
+ * @property {string} functionId Function ID.
1065
+ * @property {string[]} queries Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId
1066
+ * @property {boolean} overrideForCli
1067
+ * @property {boolean} parseOutput
1068
+ * @property {libClient | undefined} sdk
1069
+ */
1070
+
1071
+ /**
1072
+ * @param {FunctionsListExecutionsRequestParams} params
1073
+ */
1074
+ const functionsListExecutions = async ({functionId,queries,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
1075
+ let client = !sdk ? await sdkForProject() :
1076
+ sdk;
1077
+ let apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
1078
+ let payload = {};
1079
+ if (typeof queries !== 'undefined') {
1080
+ payload['queries'] = queries;
1081
+ }
1082
+
1083
+ let response = undefined;
1084
+
1085
+ response = await client.call('get', apiPath, {
1086
+ }, payload);
1087
+
1088
+ if (parseOutput) {
1089
+ if(console) {
1090
+ showConsoleLink('functions', 'listExecutions', functionId);
1091
+ } else {
1092
+ parse(response)
1093
+ }
1094
+ }
1095
+
1096
+ return response;
1097
+
1098
+ }
1099
+
1100
+ /**
1101
+ * @typedef {Object} FunctionsCreateExecutionRequestParams
1102
+ * @property {string} functionId Function ID.
1103
+ * @property {string} body HTTP body of execution. Default value is empty string.
1104
+ * @property {boolean} async Execute code in the background. Default value is false.
1105
+ * @property {string} xpath HTTP path of execution. Path can include query params. Default value is /
1106
+ * @property {ExecutionMethod} method HTTP method of execution. Default value is GET.
1107
+ * @property {object} headers HTTP headers of execution. Defaults to empty.
1108
+ * @property {string} scheduledAt Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.
1109
+ * @property {boolean} overrideForCli
1110
+ * @property {boolean} parseOutput
1111
+ * @property {libClient | undefined} sdk
1112
+ */
1113
+
1114
+ /**
1115
+ * @param {FunctionsCreateExecutionRequestParams} params
1116
+ */
1117
+ const functionsCreateExecution = async ({functionId,body,async,xpath,method,headers,scheduledAt,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1118
+ let client = !sdk ? await sdkForProject() :
1119
+ sdk;
1120
+ let apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
1121
+ let payload = {};
1122
+ if (typeof body !== 'undefined') {
1123
+ payload['body'] = body;
1124
+ }
1125
+ if (typeof async !== 'undefined') {
1126
+ payload['async'] = async;
1127
+ }
1128
+ if (typeof xpath !== 'undefined') {
1129
+ payload['path'] = xpath;
1130
+ }
1131
+ if (typeof method !== 'undefined') {
1132
+ payload['method'] = method;
1133
+ }
1134
+ if (typeof headers !== 'undefined') {
1135
+ payload['headers'] = JSON.parse(headers);
1136
+ }
1137
+ if (typeof scheduledAt !== 'undefined') {
1138
+ payload['scheduledAt'] = scheduledAt;
1139
+ }
1140
+
1141
+ let response = undefined;
1142
+
1143
+ response = await client.call('post', apiPath, {
1144
+ 'content-type': 'application/json',
1145
+ }, payload);
1146
+
1147
+ if (parseOutput) {
1148
+ parse(response)
1149
+ }
1150
+
1151
+ return response;
1152
+
1153
+ }
1154
+
1155
+ /**
1156
+ * @typedef {Object} FunctionsGetExecutionRequestParams
1157
+ * @property {string} functionId Function ID.
1158
+ * @property {string} executionId Execution ID.
1159
+ * @property {boolean} overrideForCli
1160
+ * @property {boolean} parseOutput
1161
+ * @property {libClient | undefined} sdk
1162
+ */
1163
+
1164
+ /**
1165
+ * @param {FunctionsGetExecutionRequestParams} params
1166
+ */
1167
+ const functionsGetExecution = async ({functionId,executionId,parseOutput = true, overrideForCli = false, sdk = undefined, console}) => {
1168
+ let client = !sdk ? await sdkForProject() :
1169
+ sdk;
1170
+ let apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
1171
+ let payload = {};
1172
+
1173
+ let response = undefined;
1174
+
1175
+ response = await client.call('get', apiPath, {
1176
+ }, payload);
1177
+
1178
+ if (parseOutput) {
1179
+ if(console) {
1180
+ showConsoleLink('functions', 'getExecution', functionId, executionId);
1181
+ } else {
1182
+ parse(response)
1183
+ }
1184
+ }
1185
+
1186
+ return response;
1187
+
1188
+ }
1189
+
1190
+ /**
1191
+ * @typedef {Object} FunctionsDeleteExecutionRequestParams
1192
+ * @property {string} functionId Function ID.
1193
+ * @property {string} executionId Execution ID.
1194
+ * @property {boolean} overrideForCli
1195
+ * @property {boolean} parseOutput
1196
+ * @property {libClient | undefined} sdk
1197
+ */
1198
+
1199
+ /**
1200
+ * @param {FunctionsDeleteExecutionRequestParams} params
1201
+ */
1202
+ const functionsDeleteExecution = async ({functionId,executionId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1203
+ let client = !sdk ? await sdkForProject() :
1204
+ sdk;
1205
+ let apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
1206
+ let payload = {};
1207
+
1208
+ let response = undefined;
1209
+
1210
+ response = await client.call('delete', apiPath, {
1211
+ 'content-type': 'application/json',
1212
+ }, payload);
1213
+
1214
+ if (parseOutput) {
1215
+ parse(response)
1216
+ }
1217
+
1218
+ return response;
1219
+
1220
+ }
1221
+
1222
+ /**
1223
+ * @typedef {Object} FunctionsGetUsageRequestParams
1224
+ * @property {string} functionId Function ID.
1225
+ * @property {FunctionUsageRange} range Date range.
1226
+ * @property {boolean} overrideForCli
1227
+ * @property {boolean} parseOutput
1228
+ * @property {libClient | undefined} sdk
1229
+ */
1230
+
1231
+ /**
1232
+ * @param {FunctionsGetUsageRequestParams} params
1233
+ */
1234
+ const functionsGetUsage = async ({functionId,range,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1235
+ let client = !sdk ? await sdkForProject() :
1236
+ sdk;
1237
+ let apiPath = '/functions/{functionId}/usage'.replace('{functionId}', functionId);
1238
+ let payload = {};
1239
+ if (typeof range !== 'undefined') {
1240
+ payload['range'] = range;
1241
+ }
1242
+
1243
+ let response = undefined;
1244
+
1245
+ response = await client.call('get', apiPath, {
1246
+ }, payload);
1247
+
1248
+ if (parseOutput) {
1249
+ parse(response)
1250
+ }
1251
+
1252
+ return response;
1253
+
1254
+ }
1255
+
1256
+ /**
1257
+ * @typedef {Object} FunctionsListVariablesRequestParams
1258
+ * @property {string} functionId Function unique ID.
1259
+ * @property {boolean} overrideForCli
1260
+ * @property {boolean} parseOutput
1261
+ * @property {libClient | undefined} sdk
1262
+ */
1263
+
1264
+ /**
1265
+ * @param {FunctionsListVariablesRequestParams} params
1266
+ */
1267
+ const functionsListVariables = async ({functionId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1268
+ let client = !sdk ? await sdkForProject() :
1269
+ sdk;
1270
+ let apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
1271
+ let payload = {};
1272
+
1273
+ let response = undefined;
1274
+
1275
+ response = await client.call('get', apiPath, {
1276
+ }, payload);
1277
+
1278
+ if (parseOutput) {
1279
+ parse(response)
1280
+ }
1281
+
1282
+ return response;
1283
+
1284
+ }
1285
+
1286
+ /**
1287
+ * @typedef {Object} FunctionsCreateVariableRequestParams
1288
+ * @property {string} functionId Function unique ID.
1289
+ * @property {string} key Variable key. Max length: 255 chars.
1290
+ * @property {string} value Variable value. Max length: 8192 chars.
1291
+ * @property {boolean} secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
1292
+ * @property {boolean} overrideForCli
1293
+ * @property {boolean} parseOutput
1294
+ * @property {libClient | undefined} sdk
1295
+ */
1296
+
1297
+ /**
1298
+ * @param {FunctionsCreateVariableRequestParams} params
1299
+ */
1300
+ const functionsCreateVariable = async ({functionId,key,value,secret,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1301
+ let client = !sdk ? await sdkForProject() :
1302
+ sdk;
1303
+ let apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
1304
+ let payload = {};
1305
+ if (typeof key !== 'undefined') {
1306
+ payload['key'] = key;
1307
+ }
1308
+ if (typeof value !== 'undefined') {
1309
+ payload['value'] = value;
1310
+ }
1311
+ if (typeof secret !== 'undefined') {
1312
+ payload['secret'] = secret;
1313
+ }
1314
+
1315
+ let response = undefined;
1316
+
1317
+ response = await client.call('post', apiPath, {
1318
+ 'content-type': 'application/json',
1319
+ }, payload);
1320
+
1321
+ if (parseOutput) {
1322
+ parse(response)
1323
+ }
1324
+
1325
+ return response;
1326
+
1327
+ }
1328
+
1329
+ /**
1330
+ * @typedef {Object} FunctionsGetVariableRequestParams
1331
+ * @property {string} functionId Function unique ID.
1332
+ * @property {string} variableId Variable unique ID.
1333
+ * @property {boolean} overrideForCli
1334
+ * @property {boolean} parseOutput
1335
+ * @property {libClient | undefined} sdk
1336
+ */
1337
+
1338
+ /**
1339
+ * @param {FunctionsGetVariableRequestParams} params
1340
+ */
1341
+ const functionsGetVariable = async ({functionId,variableId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1342
+ let client = !sdk ? await sdkForProject() :
1343
+ sdk;
1344
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
1345
+ let payload = {};
1346
+
1347
+ let response = undefined;
1348
+
1349
+ response = await client.call('get', apiPath, {
1350
+ }, payload);
1351
+
1352
+ if (parseOutput) {
1353
+ parse(response)
1354
+ }
1355
+
1356
+ return response;
1357
+
1358
+ }
1359
+
1360
+ /**
1361
+ * @typedef {Object} FunctionsUpdateVariableRequestParams
1362
+ * @property {string} functionId Function unique ID.
1363
+ * @property {string} variableId Variable unique ID.
1364
+ * @property {string} key Variable key. Max length: 255 chars.
1365
+ * @property {string} value Variable value. Max length: 8192 chars.
1366
+ * @property {boolean} secret Secret variables can be updated or deleted, but only functions can read them during build and runtime.
1367
+ * @property {boolean} overrideForCli
1368
+ * @property {boolean} parseOutput
1369
+ * @property {libClient | undefined} sdk
1370
+ */
1371
+
1372
+ /**
1373
+ * @param {FunctionsUpdateVariableRequestParams} params
1374
+ */
1375
+ const functionsUpdateVariable = async ({functionId,variableId,key,value,secret,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1376
+ let client = !sdk ? await sdkForProject() :
1377
+ sdk;
1378
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
1379
+ let payload = {};
1380
+ if (typeof key !== 'undefined') {
1381
+ payload['key'] = key;
1382
+ }
1383
+ if (typeof value !== 'undefined') {
1384
+ payload['value'] = value;
1385
+ }
1386
+ if (typeof secret !== 'undefined') {
1387
+ payload['secret'] = secret;
1388
+ }
1389
+
1390
+ let response = undefined;
1391
+
1392
+ response = await client.call('put', apiPath, {
1393
+ 'content-type': 'application/json',
1394
+ }, payload);
1395
+
1396
+ if (parseOutput) {
1397
+ parse(response)
1398
+ }
1399
+
1400
+ return response;
1401
+
1402
+ }
1403
+
1404
+ /**
1405
+ * @typedef {Object} FunctionsDeleteVariableRequestParams
1406
+ * @property {string} functionId Function unique ID.
1407
+ * @property {string} variableId Variable unique ID.
1408
+ * @property {boolean} overrideForCli
1409
+ * @property {boolean} parseOutput
1410
+ * @property {libClient | undefined} sdk
1411
+ */
1412
+
1413
+ /**
1414
+ * @param {FunctionsDeleteVariableRequestParams} params
1415
+ */
1416
+ const functionsDeleteVariable = async ({functionId,variableId,parseOutput = true, overrideForCli = false, sdk = undefined}) => {
1417
+ let client = !sdk ? await sdkForProject() :
1418
+ sdk;
1419
+ let apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
1420
+ let payload = {};
1421
+
1422
+ let response = undefined;
1423
+
1424
+ response = await client.call('delete', apiPath, {
1425
+ 'content-type': 'application/json',
1426
+ }, payload);
1427
+
1428
+ if (parseOutput) {
1429
+ parse(response)
1430
+ }
1431
+
1432
+ return response;
1433
+
1434
+ }
1435
+
1436
+ functions
1437
+ .command(`list`)
1438
+ .description(`Get a list of all the project's functions. You can use the query params to filter your results.`)
1439
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: name, enabled, runtime, deploymentId, schedule, scheduleNext, schedulePrevious, timeout, entrypoint, commands, installationId`)
1440
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
1441
+ .option(`--console`, `Get the resource console url`)
1442
+ .action(actionRunner(functionsList))
1443
+
1444
+ functions
1445
+ .command(`create`)
1446
+ .description(`Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API.`)
1447
+ .requiredOption(`--function-id <function-id>`, `Function ID. Choose a custom ID or generate a random ID with 'ID.unique()'. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars.`)
1448
+ .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
1449
+ .requiredOption(`--runtime <runtime>`, `Execution runtime.`)
1450
+ .option(`--execute [execute...]`, `An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.`)
1451
+ .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1452
+ .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
1453
+ .option(`--timeout <timeout>`, `Function maximum execution time in seconds.`, parseInteger)
1454
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
1455
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : parseBool(value))
1456
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
1457
+ .option(`--commands <commands>`, `Build Commands.`)
1458
+ .option(`--scopes [scopes...]`, `List of scopes allowed for API key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
1459
+ .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Control System) deployment.`)
1460
+ .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function.`)
1461
+ .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function.`)
1462
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : parseBool(value))
1463
+ .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
1464
+ .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
1465
+ .action(actionRunner(functionsCreate))
1466
+
1467
+ functions
1468
+ .command(`list-runtimes`)
1469
+ .description(`Get a list of all runtimes that are currently active on your instance.`)
1470
+ .action(actionRunner(functionsListRuntimes))
1471
+
1472
+ functions
1473
+ .command(`list-specifications`)
1474
+ .description(`List allowed function specifications for this instance.`)
1475
+ .option(`--console`, `Get the resource console url`)
1476
+ .action(actionRunner(functionsListSpecifications))
1477
+
1478
+ functions
1479
+ .command(`list-templates`)
1480
+ .description(`List available function templates. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.`)
1481
+ .option(`--runtimes [runtimes...]`, `List of runtimes allowed for filtering function templates. Maximum of 100 runtimes are allowed.`)
1482
+ .option(`--use-cases [use-cases...]`, `List of use cases allowed for filtering function templates. Maximum of 100 use cases are allowed.`)
1483
+ .option(`--limit <limit>`, `Limit the number of templates returned in the response. Default limit is 25, and maximum limit is 5000.`, parseInteger)
1484
+ .option(`--offset <offset>`, `Offset the list of returned templates. Maximum offset is 5000.`, parseInteger)
1485
+ .option(`--console`, `Get the resource console url`)
1486
+ .action(actionRunner(functionsListTemplates))
1487
+
1488
+ functions
1489
+ .command(`get-template`)
1490
+ .description(`Get a function template using ID. You can use template details in [createFunction](/docs/references/cloud/server-nodejs/functions#create) method.`)
1491
+ .requiredOption(`--template-id <template-id>`, `Template ID.`)
1492
+ .option(`--console`, `Get the resource console url`)
1493
+ .action(actionRunner(functionsGetTemplate))
1494
+
1495
+ functions
1496
+ .command(`list-usage`)
1497
+ .description(`Get usage metrics and statistics for all functions in the project. View statistics including total deployments, builds, logs, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1498
+ .option(`--range <range>`, `Date range.`)
1499
+ .option(`--console`, `Get the resource console url`)
1500
+ .action(actionRunner(functionsListUsage))
1501
+
1502
+ functions
1503
+ .command(`get`)
1504
+ .description(`Get a function by its unique ID.`)
1505
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1506
+ .option(`--console`, `Get the resource console url`)
1507
+ .action(actionRunner(functionsGet))
1508
+
1509
+ functions
1510
+ .command(`update`)
1511
+ .description(`Update function by its unique ID.`)
1512
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1513
+ .requiredOption(`--name <name>`, `Function name. Max length: 128 chars.`)
1514
+ .option(`--runtime <runtime>`, `Execution runtime.`)
1515
+ .option(`--execute [execute...]`, `An array of role strings with execution permissions. By default no user is granted with any execute permissions. [learn more about roles](https://appwrite.io/docs/permissions#permission-roles). Maximum of 100 roles are allowed, each 64 characters long.`)
1516
+ .option(`--events [events...]`, `Events list. Maximum of 100 events are allowed.`)
1517
+ .option(`--schedule <schedule>`, `Schedule CRON syntax.`)
1518
+ .option(`--timeout <timeout>`, `Maximum execution time in seconds.`, parseInteger)
1519
+ .option(`--enabled [value]`, `Is function enabled? When set to 'disabled', users cannot access the function but Server SDKs with and API key can still access the function. No data is lost when this is toggled.`, (value) => value === undefined ? true : parseBool(value))
1520
+ .option(`--logging [value]`, `When disabled, executions will exclude logs and errors, and will be slightly faster.`, (value) => value === undefined ? true : parseBool(value))
1521
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File. This path is relative to the "providerRootDirectory".`)
1522
+ .option(`--commands <commands>`, `Build Commands.`)
1523
+ .option(`--scopes [scopes...]`, `List of scopes allowed for API Key auto-generated for every execution. Maximum of 100 scopes are allowed.`)
1524
+ .option(`--installation-id <installation-id>`, `Appwrite Installation ID for VCS (Version Controle System) deployment.`)
1525
+ .option(`--provider-repository-id <provider-repository-id>`, `Repository ID of the repo linked to the function`)
1526
+ .option(`--provider-branch <provider-branch>`, `Production branch for the repo linked to the function`)
1527
+ .option(`--provider-silent-mode [value]`, `Is the VCS (Version Control System) connection in silent mode for the repo linked to the function? In silent mode, comments will not be made on commits and pull requests.`, (value) => value === undefined ? true : parseBool(value))
1528
+ .option(`--provider-root-directory <provider-root-directory>`, `Path to function code in the linked repo.`)
1529
+ .option(`--specification <specification>`, `Runtime specification for the function and builds.`)
1530
+ .action(actionRunner(functionsUpdate))
1531
+
1532
+ functions
1533
+ .command(`delete`)
1534
+ .description(`Delete a function by its unique ID.`)
1535
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1536
+ .action(actionRunner(functionsDelete))
1537
+
1538
+ functions
1539
+ .command(`update-function-deployment`)
1540
+ .description(`Update the function active deployment. Use this endpoint to switch the code deployment that should be used when visitor opens your function.`)
1541
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1542
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1543
+ .action(actionRunner(functionsUpdateFunctionDeployment))
1544
+
1545
+ functions
1546
+ .command(`list-deployments`)
1547
+ .description(`Get a list of all the function's code deployments. You can use the query params to filter your results.`)
1548
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1549
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: buildSize, sourceSize, totalSize, buildDuration, status, activate, type`)
1550
+ .option(`--search <search>`, `Search term to filter your list results. Max length: 256 chars.`)
1551
+ .option(`--console`, `Get the resource console url`)
1552
+ .action(actionRunner(functionsListDeployments))
1553
+
1554
+ functions
1555
+ .command(`create-deployment`)
1556
+ .description(`Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you'll need to update the function's deployment to use your new deployment UID. This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions). Use the "command" param to set the entrypoint used to execute your code.`)
1557
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1558
+ .requiredOption(`--code <code>`, `Gzip file with your code package. When used with the Appwrite CLI, pass the path to your code directory, and the CLI will automatically package your code. Use a path that is within the current directory.`)
1559
+ .requiredOption(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1560
+ .option(`--entrypoint <entrypoint>`, `Entrypoint File.`)
1561
+ .option(`--commands <commands>`, `Build Commands.`)
1562
+ .action(actionRunner(functionsCreateDeployment))
1563
+
1564
+ functions
1565
+ .command(`create-duplicate-deployment`)
1566
+ .description(`Create a new build for an existing function deployment. This endpoint allows you to rebuild a deployment with the updated function configuration, including its entrypoint and build commands if they have been modified. The build process will be queued and executed asynchronously. The original deployment's code will be preserved and used for the new build.`)
1567
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1568
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1569
+ .option(`--build-id <build-id>`, `Build unique ID.`)
1570
+ .action(actionRunner(functionsCreateDuplicateDeployment))
1571
+
1572
+ functions
1573
+ .command(`create-template-deployment`)
1574
+ .description(`Create a deployment based on a template. Use this endpoint with combination of [listTemplates](https://appwrite.io/docs/server/functions#listTemplates) to find the template details.`)
1575
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1576
+ .requiredOption(`--repository <repository>`, `Repository name of the template.`)
1577
+ .requiredOption(`--owner <owner>`, `The name of the owner of the template.`)
1578
+ .requiredOption(`--root-directory <root-directory>`, `Path to function code in the template repo.`)
1579
+ .requiredOption(`--version <version>`, `Version (tag) for the repo linked to the function template.`)
1580
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1581
+ .action(actionRunner(functionsCreateTemplateDeployment))
1582
+
1583
+ functions
1584
+ .command(`create-vcs-deployment`)
1585
+ .description(`Create a deployment when a function is connected to VCS. This endpoint lets you create deployment from a branch, commit, or a tag.`)
1586
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1587
+ .requiredOption(`--type <type>`, `Type of reference passed. Allowed values are: branch, commit`)
1588
+ .requiredOption(`--reference <reference>`, `VCS reference to create deployment from. Depending on type this can be: branch name, commit hash`)
1589
+ .option(`--activate [value]`, `Automatically activate the deployment when it is finished building.`, (value) => value === undefined ? true : parseBool(value))
1590
+ .action(actionRunner(functionsCreateVcsDeployment))
1591
+
1592
+ functions
1593
+ .command(`get-deployment`)
1594
+ .description(`Get a function deployment by its unique ID.`)
1595
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1596
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1597
+ .option(`--console`, `Get the resource console url`)
1598
+ .action(actionRunner(functionsGetDeployment))
1599
+
1600
+ functions
1601
+ .command(`delete-deployment`)
1602
+ .description(`Delete a code deployment by its unique ID.`)
1603
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1604
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1605
+ .action(actionRunner(functionsDeleteDeployment))
1606
+
1607
+ functions
1608
+ .command(`get-deployment-download`)
1609
+ .description(`Get a function deployment content by its unique ID. The endpoint response return with a 'Content-Disposition: attachment' header that tells the browser to start downloading the file to user downloads directory.`)
1610
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1611
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1612
+ .option(`--type <type>`, `Deployment file to download. Can be: "source", "output".`)
1613
+ .requiredOption(`--destination <path>`, `output file path.`)
1614
+ .option(`--console`, `Get the resource console url`)
1615
+ .action(actionRunner(functionsGetDeploymentDownload))
1616
+
1617
+ functions
1618
+ .command(`update-deployment-status`)
1619
+ .description(`Cancel an ongoing function deployment build. If the build is already in progress, it will be stopped and marked as canceled. If the build hasn't started yet, it will be marked as canceled without executing. You cannot cancel builds that have already completed (status 'ready') or failed. The response includes the final build status and details.`)
1620
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1621
+ .requiredOption(`--deployment-id <deployment-id>`, `Deployment ID.`)
1622
+ .action(actionRunner(functionsUpdateDeploymentStatus))
1623
+
1624
+ functions
1625
+ .command(`list-executions`)
1626
+ .description(`Get a list of all the current user function execution logs. You can use the query params to filter your results.`)
1627
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1628
+ .option(`--queries [queries...]`, `Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: trigger, status, responseStatusCode, duration, requestMethod, requestPath, deploymentId`)
1629
+ .option(`--console`, `Get the resource console url`)
1630
+ .action(actionRunner(functionsListExecutions))
1631
+
1632
+ functions
1633
+ .command(`create-execution`)
1634
+ .description(`Trigger a function execution. The returned object will return you the current execution status. You can ping the 'Get Execution' endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.`)
1635
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1636
+ .option(`--body <body>`, `HTTP body of execution. Default value is empty string.`)
1637
+ .option(`--async [value]`, `Execute code in the background. Default value is false.`, (value) => value === undefined ? true : parseBool(value))
1638
+ .option(`--xpath <xpath>`, `HTTP path of execution. Path can include query params. Default value is /`)
1639
+ .option(`--method <method>`, `HTTP method of execution. Default value is GET.`)
1640
+ .option(`--headers <headers>`, `HTTP headers of execution. Defaults to empty.`)
1641
+ .option(`--scheduled-at <scheduled-at>`, `Scheduled execution time in [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. DateTime value must be in future with precision in minutes.`)
1642
+ .action(actionRunner(functionsCreateExecution))
1643
+
1644
+ functions
1645
+ .command(`get-execution`)
1646
+ .description(`Get a function execution log by its unique ID.`)
1647
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1648
+ .requiredOption(`--execution-id <execution-id>`, `Execution ID.`)
1649
+ .option(`--console`, `Get the resource console url`)
1650
+ .action(actionRunner(functionsGetExecution))
1651
+
1652
+ functions
1653
+ .command(`delete-execution`)
1654
+ .description(`Delete a function execution by its unique ID.`)
1655
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1656
+ .requiredOption(`--execution-id <execution-id>`, `Execution ID.`)
1657
+ .action(actionRunner(functionsDeleteExecution))
1658
+
1659
+ functions
1660
+ .command(`get-usage`)
1661
+ .description(`Get usage metrics and statistics for a for a specific function. View statistics including total deployments, builds, executions, storage usage, and compute time. The response includes both current totals and historical data for each metric. Use the optional range parameter to specify the time window for historical data: 24h (last 24 hours), 30d (last 30 days), or 90d (last 90 days). If not specified, defaults to 30 days.`)
1662
+ .requiredOption(`--function-id <function-id>`, `Function ID.`)
1663
+ .option(`--range <range>`, `Date range.`)
1664
+ .action(actionRunner(functionsGetUsage))
1665
+
1666
+ functions
1667
+ .command(`list-variables`)
1668
+ .description(`Get a list of all variables of a specific function.`)
1669
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1670
+ .action(actionRunner(functionsListVariables))
1671
+
1672
+ functions
1673
+ .command(`create-variable`)
1674
+ .description(`Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.`)
1675
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1676
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1677
+ .requiredOption(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1678
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : parseBool(value))
1679
+ .action(actionRunner(functionsCreateVariable))
1680
+
1681
+ functions
1682
+ .command(`get-variable`)
1683
+ .description(`Get a variable by its unique ID.`)
1684
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1685
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1686
+ .action(actionRunner(functionsGetVariable))
1687
+
1688
+ functions
1689
+ .command(`update-variable`)
1690
+ .description(`Update variable by its unique ID.`)
1691
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1692
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1693
+ .requiredOption(`--key <key>`, `Variable key. Max length: 255 chars.`)
1694
+ .option(`--value <value>`, `Variable value. Max length: 8192 chars.`)
1695
+ .option(`--secret [value]`, `Secret variables can be updated or deleted, but only functions can read them during build and runtime.`, (value) => value === undefined ? true : parseBool(value))
1696
+ .action(actionRunner(functionsUpdateVariable))
1697
+
1698
+ functions
1699
+ .command(`delete-variable`)
1700
+ .description(`Delete a variable by its unique ID.`)
1701
+ .requiredOption(`--function-id <function-id>`, `Function unique ID.`)
1702
+ .requiredOption(`--variable-id <variable-id>`, `Variable unique ID.`)
1703
+ .action(actionRunner(functionsDeleteVariable))
1704
+
1705
+ module.exports = {
1706
+ functions,
1707
+ functionsList,
1708
+ functionsCreate,
1709
+ functionsListRuntimes,
1710
+ functionsListSpecifications,
1711
+ functionsListTemplates,
1712
+ functionsGetTemplate,
1713
+ functionsListUsage,
1714
+ functionsGet,
1715
+ functionsUpdate,
1716
+ functionsDelete,
1717
+ functionsUpdateFunctionDeployment,
1718
+ functionsListDeployments,
1719
+ functionsCreateDeployment,
1720
+ functionsCreateDuplicateDeployment,
1721
+ functionsCreateTemplateDeployment,
1722
+ functionsCreateVcsDeployment,
1723
+ functionsGetDeployment,
1724
+ functionsDeleteDeployment,
1725
+ functionsGetDeploymentDownload,
1726
+ functionsUpdateDeploymentStatus,
1727
+ functionsListExecutions,
1728
+ functionsCreateExecution,
1729
+ functionsGetExecution,
1730
+ functionsDeleteExecution,
1731
+ functionsGetUsage,
1732
+ functionsListVariables,
1733
+ functionsCreateVariable,
1734
+ functionsGetVariable,
1735
+ functionsUpdateVariable,
1736
+ functionsDeleteVariable
1737
+ };