appwrite-cli 12.0.1 → 13.0.0-rc.1

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 (283) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +145 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/client.d.ts +89 -0
  8. package/dist/lib/client.d.ts.map +1 -0
  9. package/dist/lib/client.js +227 -0
  10. package/dist/lib/client.js.map +1 -0
  11. package/dist/lib/commands/account.d.ts +379 -0
  12. package/dist/lib/commands/account.d.ts.map +1 -0
  13. package/dist/lib/commands/account.js +1228 -0
  14. package/dist/lib/commands/account.js.map +1 -0
  15. package/dist/lib/commands/console.d.ts +20 -0
  16. package/dist/lib/commands/console.d.ts.map +1 -0
  17. package/dist/lib/commands/console.js +78 -0
  18. package/dist/lib/commands/console.js.map +1 -0
  19. package/dist/lib/commands/databases.d.ts +732 -0
  20. package/dist/lib/commands/databases.d.ts.map +1 -0
  21. package/dist/lib/commands/databases.js +2196 -0
  22. package/dist/lib/commands/databases.js.map +1 -0
  23. package/dist/lib/commands/functions.d.ts +310 -0
  24. package/dist/lib/commands/functions.d.ts.map +1 -0
  25. package/dist/lib/commands/functions.js +1100 -0
  26. package/dist/lib/commands/functions.js.map +1 -0
  27. package/dist/lib/commands/generic.d.ts +17 -0
  28. package/dist/lib/commands/generic.d.ts.map +1 -0
  29. package/dist/lib/commands/generic.js +279 -0
  30. package/dist/lib/commands/generic.js.map +1 -0
  31. package/dist/lib/commands/graphql.d.ts +19 -0
  32. package/dist/lib/commands/graphql.d.ts.map +1 -0
  33. package/dist/lib/commands/graphql.js +77 -0
  34. package/dist/lib/commands/graphql.js.map +1 -0
  35. package/dist/lib/commands/health.d.ts +153 -0
  36. package/dist/lib/commands/health.d.ts.map +1 -0
  37. package/dist/lib/commands/health.js +464 -0
  38. package/dist/lib/commands/health.js.map +1 -0
  39. package/dist/lib/commands/init.d.ts +3 -0
  40. package/dist/lib/commands/init.d.ts.map +1 -0
  41. package/dist/lib/commands/init.js +518 -0
  42. package/dist/lib/commands/init.js.map +1 -0
  43. package/dist/lib/commands/locale.d.ts +53 -0
  44. package/dist/lib/commands/locale.d.ts.map +1 -0
  45. package/dist/lib/commands/locale.js +165 -0
  46. package/dist/lib/commands/locale.js.map +1 -0
  47. package/dist/lib/commands/messaging.d.ts +588 -0
  48. package/dist/lib/commands/messaging.d.ts.map +1 -0
  49. package/dist/lib/commands/messaging.js +2042 -0
  50. package/dist/lib/commands/messaging.js.map +1 -0
  51. package/dist/lib/commands/migrations.d.ts +150 -0
  52. package/dist/lib/commands/migrations.d.ts.map +1 -0
  53. package/dist/lib/commands/migrations.js +524 -0
  54. package/dist/lib/commands/migrations.js.map +1 -0
  55. package/dist/lib/commands/organizations.d.ts +11 -0
  56. package/dist/lib/commands/organizations.d.ts.map +1 -0
  57. package/dist/lib/commands/organizations.js +31 -0
  58. package/dist/lib/commands/organizations.js.map +1 -0
  59. package/dist/lib/commands/project.d.ts +53 -0
  60. package/dist/lib/commands/project.d.ts.map +1 -0
  61. package/dist/lib/commands/project.js +176 -0
  62. package/dist/lib/commands/project.js.map +1 -0
  63. package/dist/lib/commands/projects.d.ts +516 -0
  64. package/dist/lib/commands/projects.d.ts.map +1 -0
  65. package/dist/lib/commands/projects.js +1590 -0
  66. package/dist/lib/commands/projects.js.map +1 -0
  67. package/dist/lib/commands/proxy.d.ts +71 -0
  68. package/dist/lib/commands/proxy.d.ts.map +1 -0
  69. package/dist/lib/commands/proxy.js +240 -0
  70. package/dist/lib/commands/proxy.js.map +1 -0
  71. package/dist/lib/commands/pull.d.ts +8 -0
  72. package/dist/lib/commands/pull.d.ts.map +1 -0
  73. package/dist/lib/commands/pull.js +455 -0
  74. package/dist/lib/commands/pull.js.map +1 -0
  75. package/dist/lib/commands/push.d.ts +4 -0
  76. package/dist/lib/commands/push.d.ts.map +1 -0
  77. package/dist/lib/commands/push.js +2154 -0
  78. package/dist/lib/commands/push.js.map +1 -0
  79. package/dist/lib/commands/run.d.ts +3 -0
  80. package/dist/lib/commands/run.d.ts.map +1 -0
  81. package/dist/lib/commands/run.js +287 -0
  82. package/dist/lib/commands/run.js.map +1 -0
  83. package/dist/lib/commands/sites.d.ts +296 -0
  84. package/dist/lib/commands/sites.d.ts.map +1 -0
  85. package/dist/lib/commands/sites.js +1046 -0
  86. package/dist/lib/commands/sites.js.map +1 -0
  87. package/dist/lib/commands/storage.d.ts +170 -0
  88. package/dist/lib/commands/storage.d.ts.map +1 -0
  89. package/dist/lib/commands/storage.js +651 -0
  90. package/dist/lib/commands/storage.js.map +1 -0
  91. package/dist/lib/commands/tables-db.d.ts +728 -0
  92. package/dist/lib/commands/tables-db.d.ts.map +1 -0
  93. package/dist/lib/commands/tables-db.js +2198 -0
  94. package/dist/lib/commands/tables-db.js.map +1 -0
  95. package/dist/lib/commands/teams.d.ts +129 -0
  96. package/dist/lib/commands/teams.d.ts.map +1 -0
  97. package/dist/lib/commands/teams.js +403 -0
  98. package/dist/lib/commands/teams.js.map +1 -0
  99. package/dist/lib/commands/tokens.d.ts +48 -0
  100. package/dist/lib/commands/tokens.d.ts.map +1 -0
  101. package/dist/lib/commands/tokens.js +156 -0
  102. package/dist/lib/commands/tokens.js.map +1 -0
  103. package/dist/lib/commands/types.d.ts +3 -0
  104. package/dist/lib/commands/types.d.ts.map +1 -0
  105. package/dist/lib/commands/types.js +155 -0
  106. package/dist/lib/commands/types.js.map +1 -0
  107. package/dist/lib/commands/update.d.ts +3 -0
  108. package/dist/lib/commands/update.d.ts.map +1 -0
  109. package/dist/lib/commands/update.js +202 -0
  110. package/dist/lib/commands/update.js.map +1 -0
  111. package/dist/lib/commands/users.d.ts +382 -0
  112. package/dist/lib/commands/users.d.ts.map +1 -0
  113. package/dist/lib/commands/users.js +1195 -0
  114. package/dist/lib/commands/users.js.map +1 -0
  115. package/dist/lib/commands/vcs.d.ts +92 -0
  116. package/dist/lib/commands/vcs.d.ts.map +1 -0
  117. package/dist/lib/commands/vcs.js +276 -0
  118. package/dist/lib/commands/vcs.js.map +1 -0
  119. package/dist/lib/config.d.ts +118 -0
  120. package/dist/lib/config.d.ts.map +1 -0
  121. package/{lib → dist/lib}/config.js +204 -325
  122. package/dist/lib/config.js.map +1 -0
  123. package/dist/lib/emulation/docker.d.ts +15 -0
  124. package/dist/lib/emulation/docker.d.ts.map +1 -0
  125. package/dist/lib/emulation/docker.js +220 -0
  126. package/dist/lib/emulation/docker.js.map +1 -0
  127. package/dist/lib/emulation/utils.d.ts +29 -0
  128. package/dist/lib/emulation/utils.d.ts.map +1 -0
  129. package/dist/lib/emulation/utils.js +168 -0
  130. package/dist/lib/emulation/utils.js.map +1 -0
  131. package/dist/lib/exception.d.ts +8 -0
  132. package/dist/lib/exception.d.ts.map +1 -0
  133. package/dist/lib/exception.js +16 -0
  134. package/dist/lib/exception.js.map +1 -0
  135. package/dist/lib/id.d.ts +7 -0
  136. package/dist/lib/id.d.ts.map +1 -0
  137. package/dist/lib/id.js +32 -0
  138. package/dist/lib/id.js.map +1 -0
  139. package/dist/lib/paginate.d.ts +10 -0
  140. package/dist/lib/paginate.d.ts.map +1 -0
  141. package/{lib → dist/lib}/paginate.js +9 -15
  142. package/dist/lib/paginate.js.map +1 -0
  143. package/dist/lib/parser.d.ts +18 -0
  144. package/dist/lib/parser.d.ts.map +1 -0
  145. package/dist/lib/parser.js +237 -0
  146. package/dist/lib/parser.js.map +1 -0
  147. package/dist/lib/questions.d.ts +59 -0
  148. package/dist/lib/questions.d.ts.map +1 -0
  149. package/dist/lib/questions.js +995 -0
  150. package/dist/lib/questions.js.map +1 -0
  151. package/dist/lib/sdks.d.ts +4 -0
  152. package/dist/lib/sdks.d.ts.map +1 -0
  153. package/dist/lib/sdks.js +51 -0
  154. package/dist/lib/sdks.js.map +1 -0
  155. package/dist/lib/spinner.d.ts +28 -0
  156. package/dist/lib/spinner.d.ts.map +1 -0
  157. package/{lib → dist/lib}/spinner.js +34 -45
  158. package/dist/lib/spinner.js.map +1 -0
  159. package/dist/lib/type-generation/attribute.d.ts +17 -0
  160. package/dist/lib/type-generation/attribute.d.ts.map +1 -0
  161. package/dist/lib/type-generation/attribute.js +19 -0
  162. package/dist/lib/type-generation/attribute.js.map +1 -0
  163. package/dist/lib/type-generation/languages/csharp.d.ts +7 -0
  164. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -0
  165. package/dist/lib/type-generation/languages/csharp.js +180 -0
  166. package/dist/lib/type-generation/languages/csharp.js.map +1 -0
  167. package/dist/lib/type-generation/languages/dart.d.ts +8 -0
  168. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -0
  169. package/dist/lib/type-generation/languages/dart.js +197 -0
  170. package/dist/lib/type-generation/languages/dart.js.map +1 -0
  171. package/dist/lib/type-generation/languages/java.d.ts +7 -0
  172. package/dist/lib/type-generation/languages/java.d.ts.map +1 -0
  173. package/dist/lib/type-generation/languages/java.js +140 -0
  174. package/dist/lib/type-generation/languages/java.js.map +1 -0
  175. package/dist/lib/type-generation/languages/javascript.d.ts +9 -0
  176. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -0
  177. package/dist/lib/type-generation/languages/javascript.js +108 -0
  178. package/dist/lib/type-generation/languages/javascript.js.map +1 -0
  179. package/dist/lib/type-generation/languages/kotlin.d.ts +7 -0
  180. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -0
  181. package/dist/lib/type-generation/languages/kotlin.js +95 -0
  182. package/dist/lib/type-generation/languages/kotlin.js.map +1 -0
  183. package/dist/lib/type-generation/languages/language.d.ts +43 -0
  184. package/dist/lib/type-generation/languages/language.d.ts.map +1 -0
  185. package/dist/lib/type-generation/languages/language.js +82 -0
  186. package/dist/lib/type-generation/languages/language.js.map +1 -0
  187. package/dist/lib/type-generation/languages/php.d.ts +7 -0
  188. package/dist/lib/type-generation/languages/php.d.ts.map +1 -0
  189. package/dist/lib/type-generation/languages/php.js +116 -0
  190. package/dist/lib/type-generation/languages/php.js.map +1 -0
  191. package/dist/lib/type-generation/languages/swift.d.ts +7 -0
  192. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -0
  193. package/dist/lib/type-generation/languages/swift.js +179 -0
  194. package/dist/lib/type-generation/languages/swift.js.map +1 -0
  195. package/dist/lib/type-generation/languages/typescript.d.ts +9 -0
  196. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -0
  197. package/dist/lib/type-generation/languages/typescript.js +112 -0
  198. package/dist/lib/type-generation/languages/typescript.js.map +1 -0
  199. package/dist/lib/types.d.ts +133 -0
  200. package/dist/lib/types.d.ts.map +1 -0
  201. package/dist/lib/types.js +3 -0
  202. package/dist/lib/types.js.map +1 -0
  203. package/dist/lib/utils.d.ts +15 -0
  204. package/dist/lib/utils.d.ts.map +1 -0
  205. package/{lib → dist/lib}/utils.js +74 -120
  206. package/dist/lib/utils.js.map +1 -0
  207. package/dist/lib/validations.d.ts +2 -0
  208. package/dist/lib/validations.d.ts.map +1 -0
  209. package/dist/lib/validations.js +20 -0
  210. package/dist/lib/validations.js.map +1 -0
  211. package/docs/examples/databases/upsert-document.md +1 -2
  212. package/index.ts +152 -0
  213. package/install.ps1 +2 -5
  214. package/install.sh +1 -2
  215. package/lib/client.ts +259 -0
  216. package/lib/commands/{account.js → account.ts} +408 -662
  217. package/lib/commands/console.ts +112 -0
  218. package/lib/commands/{databases.js → databases.ts} +818 -1136
  219. package/lib/commands/{functions.js → functions.ts} +381 -526
  220. package/lib/commands/{generic.js → generic.ts} +47 -39
  221. package/lib/commands/graphql.ts +110 -0
  222. package/lib/commands/{health.js → health.ts} +168 -284
  223. package/lib/commands/{init.js → init.ts} +68 -66
  224. package/lib/commands/{locale.js → locale.ts} +75 -121
  225. package/lib/commands/{messaging.js → messaging.ts} +699 -937
  226. package/lib/commands/{migrations.js → migrations.ts} +182 -258
  227. package/lib/commands/organizations.ts +46 -0
  228. package/lib/commands/{project.js → project.ts} +75 -111
  229. package/lib/commands/{projects.js → projects.ts} +587 -843
  230. package/lib/commands/{proxy.js → proxy.ts} +94 -140
  231. package/lib/commands/{pull.js → pull.ts} +54 -44
  232. package/lib/commands/{push.js → push.ts} +235 -191
  233. package/lib/commands/{run.js → run.ts} +61 -55
  234. package/lib/commands/{sites.js → sites.ts} +364 -504
  235. package/lib/commands/{storage.js → storage.ts} +216 -292
  236. package/lib/commands/{tables-db.js → tables-db.ts} +817 -1126
  237. package/lib/commands/{teams.js → teams.ts} +162 -236
  238. package/lib/commands/{tokens.js → tokens.ts} +70 -99
  239. package/lib/commands/{types.js → types.ts} +37 -35
  240. package/lib/commands/{update.js → update.ts} +25 -27
  241. package/lib/commands/{users.js → users.ts} +426 -644
  242. package/lib/commands/{vcs.js → vcs.ts} +118 -174
  243. package/lib/config.ts +854 -0
  244. package/lib/emulation/{docker.js → docker.ts} +39 -38
  245. package/lib/emulation/utils.ts +193 -0
  246. package/lib/exception.ts +20 -0
  247. package/lib/{id.js → id.ts} +5 -5
  248. package/lib/paginate.ts +63 -0
  249. package/lib/parser.ts +238 -0
  250. package/lib/{questions.js → questions.ts} +148 -156
  251. package/lib/sdks.ts +55 -0
  252. package/lib/spinner.ts +118 -0
  253. package/lib/type-generation/attribute.ts +17 -0
  254. package/lib/type-generation/languages/{csharp.js → csharp.ts} +59 -57
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -89
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -56
  257. package/lib/type-generation/languages/javascript.ts +111 -0
  258. package/lib/type-generation/languages/kotlin.ts +96 -0
  259. package/lib/type-generation/languages/language.ts +119 -0
  260. package/lib/type-generation/languages/{php.js → php.ts} +55 -53
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -57
  262. package/lib/type-generation/languages/typescript.ts +116 -0
  263. package/lib/types.ts +150 -0
  264. package/lib/utils.ts +322 -0
  265. package/lib/validations.ts +17 -0
  266. package/package.json +21 -12
  267. package/scoop/appwrite.config.json +3 -3
  268. package/tsconfig.json +30 -0
  269. package/index.js +0 -147
  270. package/lib/client.js +0 -254
  271. package/lib/commands/console.js +0 -127
  272. package/lib/commands/graphql.js +0 -126
  273. package/lib/commands/organizations.js +0 -48
  274. package/lib/emulation/utils.js +0 -186
  275. package/lib/exception.js +0 -9
  276. package/lib/parser.js +0 -250
  277. package/lib/sdks.js +0 -60
  278. package/lib/type-generation/attribute.js +0 -19
  279. package/lib/type-generation/languages/javascript.js +0 -111
  280. package/lib/type-generation/languages/kotlin.js +0 -94
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -116
  283. package/lib/validations.js +0 -17
@@ -1,22 +1,22 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const { parse: parseDotenv } = require('dotenv');
4
- const chalk = require('chalk');
5
- const inquirer = require("inquirer");
6
- const JSONbig = require("json-bigint")({ storeAsString: false });
7
- const { Command } = require("commander");
8
- const ID = require("../id");
9
- const { localConfig, globalConfig, KeysAttributes, KeysFunction, KeysSite, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable } = require("../config");
10
- const { Spinner, SPINNER_ARC, SPINNER_DOTS } = require('../spinner');
11
- const { paginate } = require('../paginate');
12
- const { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsPushSites, questionsGetEntrypoint, questionsPushCollections, questionsPushTables, questionPushChanges, questionPushChangesConfirmation, questionsPushMessagingTopics, questionsPushResources } = require("../questions");
13
- const { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable } = require("../parser");
14
- const { proxyCreateFunctionRule, proxyCreateSiteRule, proxyListRules } = require('./proxy');
15
- const { consoleVariables } = require('./console');
16
- const { sdkForConsole } = require('../sdks')
17
- const { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } = require('./functions');
18
- const { sitesGet, sitesCreate, sitesUpdate, sitesCreateDeployment, sitesGetDeployment, sitesCreateVariable, sitesListVariables, sitesDeleteVariable } = require('./sites');
19
- const {
1
+ import fs = require('fs');
2
+ import path = require('path');
3
+ import { parse as parseDotenv } from 'dotenv';
4
+ import chalk from 'chalk';
5
+ import inquirer from "inquirer";
6
+ import JSONbig from "json-bigint";
7
+ import { Command } from "commander";
8
+ import ID from "../id";
9
+ import { localConfig, globalConfig, KeysAttributes, KeysFunction, KeysSite, whitelistKeys, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable } from "../config";
10
+ import { Spinner, SPINNER_ARC, SPINNER_DOTS } from '../spinner';
11
+ import { paginate } from '../paginate';
12
+ import { questionsPushBuckets, questionsPushTeams, questionsPushFunctions, questionsPushSites, questionsGetEntrypoint, questionsPushCollections, questionsPushTables, questionPushChanges, questionPushChangesConfirmation, questionsPushMessagingTopics, questionsPushResources } from "../questions";
13
+ import { cliConfig, actionRunner, success, warn, log, hint, error, commandDescriptions, drawTable } from "../parser";
14
+ import { proxyCreateFunctionRule, proxyCreateSiteRule, proxyListRules } from './proxy';
15
+ import { consoleVariables } from './console';
16
+ import { sdkForConsole } from '../sdks';
17
+ import { functionsGet, functionsCreate, functionsUpdate, functionsCreateDeployment, functionsGetDeployment, functionsListVariables, functionsDeleteVariable, functionsCreateVariable } from './functions';
18
+ import { sitesGet, sitesCreate, sitesUpdate, sitesCreateDeployment, sitesGetDeployment, sitesCreateVariable, sitesListVariables, sitesDeleteVariable } from './sites';
19
+ import {
20
20
  databasesGet,
21
21
  databasesCreate,
22
22
  databasesUpdate,
@@ -54,8 +54,8 @@ const {
54
54
  databasesListAttributes,
55
55
  databasesListIndexes,
56
56
  databasesUpdateCollection
57
- } = require("./databases");
58
- const {
57
+ } from "./databases";
58
+ import {
59
59
  tablesDBCreate,
60
60
  tablesDBGet,
61
61
  tablesDBUpdate,
@@ -66,19 +66,19 @@ const {
66
66
  tablesDBDelete,
67
67
  tablesDBListTables,
68
68
  tablesDBDeleteTable
69
- } = require("./tables-db");
70
- const {
69
+ } from "./tables-db";
70
+ import {
71
71
  storageGetBucket, storageUpdateBucket, storageCreateBucket
72
- } = require("./storage");
73
- const {
72
+ } from "./storage";
73
+ import {
74
74
  messagingGetTopic, messagingUpdateTopic, messagingCreateTopic
75
- } = require("./messaging");
76
- const {
75
+ } from "./messaging";
76
+ import {
77
77
  teamsGet,
78
78
  teamsUpdateName,
79
79
  teamsCreate
80
- } = require("./teams");
81
- const {
80
+ } from "./teams";
81
+ import {
82
82
  projectsGet,
83
83
  projectsUpdate,
84
84
  projectsUpdateServiceStatus,
@@ -91,8 +91,10 @@ const {
91
91
  projectsUpdatePersonalDataCheck,
92
92
  projectsUpdateSessionAlerts,
93
93
  projectsUpdateMockNumbers,
94
- } = require("./projects");
95
- const { checkDeployConditions } = require('../utils');
94
+ } from "./projects";
95
+ import { checkDeployConditions } from '../utils';
96
+
97
+ const JSONbigNative = JSONbig({ storeAsString: false });
96
98
 
97
99
  const STEP_SIZE = 100; // Resources
98
100
  const POLL_DEBOUNCE = 2000; // Milliseconds
@@ -103,8 +105,17 @@ let pollMaxDebounces = POLL_DEFAULT_VALUE;
103
105
 
104
106
  const changeableKeys = ['status', 'required', 'xdefault', 'elements', 'min', 'max', 'default', 'error'];
105
107
 
106
- const awaitPools = {
107
- wipeAttributes: async (databaseId, collectionId, iteration = 1) => {
108
+ interface AwaitPools {
109
+ wipeAttributes: (databaseId: string, collectionId: string, iteration?: number) => Promise<boolean>;
110
+ wipeIndexes: (databaseId: string, collectionId: string, iteration?: number) => Promise<boolean>;
111
+ deleteAttributes: (databaseId: string, collectionId: string, attributeKeys: any[], iteration?: number) => Promise<boolean>;
112
+ expectAttributes: (databaseId: string, collectionId: string, attributeKeys: string[], iteration?: number) => Promise<boolean>;
113
+ deleteIndexes: (databaseId: string, collectionId: string, indexesKeys: any[], iteration?: number) => Promise<boolean>;
114
+ expectIndexes: (databaseId: string, collectionId: string, indexKeys: string[], iteration?: number) => Promise<boolean>;
115
+ }
116
+
117
+ const awaitPools: AwaitPools = {
118
+ wipeAttributes: async (databaseId: string, collectionId: string, iteration: number = 1): Promise<boolean> => {
108
119
  if (iteration > pollMaxDebounces) {
109
120
  return false;
110
121
  }
@@ -137,7 +148,7 @@ const awaitPools = {
137
148
  iteration + 1
138
149
  );
139
150
  },
140
- wipeIndexes: async (databaseId, collectionId, iteration = 1) => {
151
+ wipeIndexes: async (databaseId: string, collectionId: string, iteration: number = 1): Promise<boolean> => {
141
152
  if (iteration > pollMaxDebounces) {
142
153
  return false;
143
154
  }
@@ -170,7 +181,7 @@ const awaitPools = {
170
181
  iteration + 1
171
182
  );
172
183
  },
173
- deleteAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
184
+ deleteAttributes: async (databaseId: string, collectionId: string, attributeKeys: any[], iteration: number = 1): Promise<boolean> => {
174
185
  if (iteration > pollMaxDebounces) {
175
186
  return false;
176
187
  }
@@ -190,7 +201,7 @@ const awaitPools = {
190
201
  parseOutput: false
191
202
  }, 100, 'attributes');
192
203
 
193
- const ready = attributeKeys.filter(attribute => attributes.includes(attribute.key));
204
+ const ready = attributeKeys.filter((attribute: any) => attributes.includes(attribute.key));
194
205
 
195
206
  if (ready.length === 0) {
196
207
  return true;
@@ -205,7 +216,7 @@ const awaitPools = {
205
216
  iteration + 1
206
217
  );
207
218
  },
208
- expectAttributes: async (databaseId, collectionId, attributeKeys, iteration = 1) => {
219
+ expectAttributes: async (databaseId: string, collectionId: string, attributeKeys: string[], iteration: number = 1): Promise<boolean> => {
209
220
  if (iteration > pollMaxDebounces) {
210
221
  return false;
211
222
  }
@@ -226,7 +237,7 @@ const awaitPools = {
226
237
  }, 100, 'attributes');
227
238
 
228
239
  const ready = attributes
229
- .filter(attribute => {
240
+ .filter((attribute: any) => {
230
241
  if (attributeKeys.includes(attribute.key)) {
231
242
  if (['stuck', 'failed'].includes(attribute.status)) {
232
243
  throw new Error(`Attribute '${attribute.key}' failed!`);
@@ -237,7 +248,7 @@ const awaitPools = {
237
248
 
238
249
  return false;
239
250
  })
240
- .map(attribute => attribute.key);
251
+ .map((attribute: any) => attribute.key);
241
252
 
242
253
  if (ready.length === attributeKeys.length) {
243
254
  return true;
@@ -252,13 +263,13 @@ const awaitPools = {
252
263
  iteration + 1
253
264
  );
254
265
  },
255
- deleteIndexes: async (databaseId, collectionId, indexesKeys, iteration = 1) => {
266
+ deleteIndexes: async (databaseId: string, collectionId: string, indexesKeys: any[], iteration: number = 1): Promise<boolean> => {
256
267
  if (iteration > pollMaxDebounces) {
257
268
  return false;
258
269
  }
259
270
 
260
271
  if (pollMaxDebounces === POLL_DEFAULT_VALUE) {
261
- let steps = Math.max(1, Math.ceil(attributeKeys.length / STEP_SIZE));
272
+ let steps = Math.max(1, Math.ceil(indexesKeys.length / STEP_SIZE));
262
273
  if (steps > 1 && iteration === 1) {
263
274
  pollMaxDebounces *= steps;
264
275
 
@@ -272,7 +283,7 @@ const awaitPools = {
272
283
  parseOutput: false
273
284
  }, 100, 'indexes');
274
285
 
275
- const ready = indexesKeys.filter(index => indexes.includes(index.key));
286
+ const ready = indexesKeys.filter((index: any) => indexes.includes(index.key));
276
287
 
277
288
  if (ready.length === 0) {
278
289
  return true;
@@ -287,7 +298,7 @@ const awaitPools = {
287
298
  iteration + 1
288
299
  );
289
300
  },
290
- expectIndexes: async (databaseId, collectionId, indexKeys, iteration = 1) => {
301
+ expectIndexes: async (databaseId: string, collectionId: string, indexKeys: string[], iteration: number = 1): Promise<boolean> => {
291
302
  if (iteration > pollMaxDebounces) {
292
303
  return false;
293
304
  }
@@ -308,7 +319,7 @@ const awaitPools = {
308
319
  }, 100, 'indexes');
309
320
 
310
321
  const ready = indexes
311
- .filter((index) => {
322
+ .filter((index: any) => {
312
323
  if (indexKeys.includes(index.key)) {
313
324
  if (['stuck', 'failed'].includes(index.status)) {
314
325
  throw new Error(`Index '${index.key}' failed!`);
@@ -319,7 +330,7 @@ const awaitPools = {
319
330
 
320
331
  return false;
321
332
  })
322
- .map(index => index.key);
333
+ .map((index: any) => index.key);
323
334
 
324
335
  if (ready.length >= indexKeys.length) {
325
336
  return true;
@@ -336,12 +347,12 @@ const awaitPools = {
336
347
  },
337
348
  }
338
349
 
339
- const getConfirmation = async () => {
350
+ const getConfirmation = async (): Promise<boolean> => {
340
351
  if (cliConfig.force) {
341
352
  return true;
342
353
  }
343
354
 
344
- async function fixConfirmation() {
355
+ async function fixConfirmation(): Promise<string> {
345
356
  const answers = await inquirer.prompt(questionPushChangesConfirmation);
346
357
  if (answers.changes !== 'YES' && answers.changes !== 'NO') {
347
358
  return await fixConfirmation();
@@ -364,15 +375,15 @@ const getConfirmation = async () => {
364
375
  return false;
365
376
 
366
377
  };
367
- const isEmpty = (value) => (value === null || value === undefined || (typeof value === "string" && value.trim().length === 0) || (Array.isArray(value) && value.length === 0));
378
+ const isEmpty = (value: any): boolean => (value === null || value === undefined || (typeof value === "string" && value.trim().length === 0) || (Array.isArray(value) && value.length === 0));
368
379
 
369
- const approveChanges = async (resource, resourceGetFunction, keys, resourceName, resourcePlural, skipKeys = [], secondId = '', secondResourceName = '') => {
380
+ const approveChanges = async (resource: any[], resourceGetFunction: Function, keys: Set<string>, resourceName: string, resourcePlural: string, skipKeys: string[] = [], secondId: string = '', secondResourceName: string = ''): Promise<boolean> => {
370
381
  log('Checking for changes ...');
371
- const changes = [];
382
+ const changes: any[] = [];
372
383
 
373
384
  await Promise.all(resource.map(async (localResource) => {
374
385
  try {
375
- const options = {
386
+ const options: Record<string, any> = {
376
387
  [resourceName]: localResource['$id'],
377
388
  parseOutput: false,
378
389
  };
@@ -397,7 +408,7 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
397
408
  changes.push({
398
409
  id: localResource['$id'],
399
410
  key,
400
- remote: chalk.red(value.join('\n')),
411
+ remote: chalk.red((value as string[]).join('\n')),
401
412
  local: chalk.green(localResource[key].join('\n'))
402
413
  })
403
414
  }
@@ -410,7 +421,7 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
410
421
  })
411
422
  }
412
423
  }
413
- } catch (e) {
424
+ } catch (e: any) {
414
425
  if (Number(e.code) !== 404) {
415
426
  throw e;
416
427
  }
@@ -430,8 +441,8 @@ const approveChanges = async (resource, resourceGetFunction, keys, resourceName,
430
441
  return false;
431
442
  }
432
443
 
433
- const getObjectChanges = (remote, local, index, what) => {
434
- const changes = [];
444
+ const getObjectChanges = (remote: any, local: any, index: string, what: string): any[] => {
445
+ const changes: any[] = [];
435
446
 
436
447
  if (remote[index] && local[index]) {
437
448
  for (let [service, status] of Object.entries(remote[index])) {
@@ -453,7 +464,7 @@ const getObjectChanges = (remote, local, index, what) => {
453
464
  return changes;
454
465
  }
455
466
 
456
- const createAttribute = (databaseId, collectionId, attribute) => {
467
+ const createAttribute = (databaseId: string, collectionId: string, attribute: any): Promise<any> => {
457
468
  switch (attribute.type) {
458
469
  case 'string':
459
470
  switch (attribute.format) {
@@ -600,7 +611,7 @@ const createAttribute = (databaseId, collectionId, attribute) => {
600
611
  }
601
612
  }
602
613
 
603
- const updateAttribute = (databaseId, collectionId, attribute) => {
614
+ const updateAttribute = (databaseId: string, collectionId: string, attribute: any): Promise<any> => {
604
615
  switch (attribute.type) {
605
616
  case 'string':
606
617
  switch (attribute.format) {
@@ -745,7 +756,7 @@ const updateAttribute = (databaseId, collectionId, attribute) => {
745
756
  throw new Error(`Unsupported attribute type: ${attribute.type}`);
746
757
  }
747
758
  }
748
- const deleteAttribute = async (collection, attribute, isIndex = false) => {
759
+ const deleteAttribute = async (collection: any, attribute: any, isIndex: boolean = false): Promise<void> => {
749
760
  log(`Deleting ${isIndex ? 'index' : 'attribute'} ${attribute.key} of ${collection.name} ( ${collection['$id']} )`);
750
761
 
751
762
  if (isIndex) {
@@ -766,7 +777,7 @@ const deleteAttribute = async (collection, attribute, isIndex = false) => {
766
777
  });
767
778
  }
768
779
 
769
- const isEqual = (a, b) => {
780
+ const isEqual = (a: any, b: any): boolean => {
770
781
  if (a === b) return true;
771
782
 
772
783
  if (a && b && typeof a === 'object' && typeof b === 'object') {
@@ -793,7 +804,7 @@ const isEqual = (a, b) => {
793
804
  return false;
794
805
  };
795
806
 
796
- const compareAttribute = (remote, local, reason, key) => {
807
+ const compareAttribute = (remote: any, local: any, reason: string, key: string): string => {
797
808
  if (isEmpty(remote) && isEmpty(local)) {
798
809
  return reason;
799
810
  }
@@ -811,17 +822,18 @@ const compareAttribute = (remote, local, reason, key) => {
811
822
  return reason
812
823
  }
813
824
 
825
+ interface AttributeChange {
826
+ key: string;
827
+ attribute: any;
828
+ reason: string;
829
+ action: string;
830
+ }
814
831
 
815
832
  /**
816
833
  * Check if attribute non-changeable fields has been changed
817
834
  * If so return the differences as an object.
818
- * @param remote
819
- * @param local
820
- * @param collection
821
- * @param recreating when true will check only non-changeable keys
822
- * @returns {undefined|{reason: string, action: *, attribute, key: string}}
823
835
  */
824
- const checkAttributeChanges = (remote, local, collection, recreating = true) => {
836
+ const checkAttributeChanges = (remote: any, local: any, collection: any, recreating: boolean = true): AttributeChange | undefined => {
825
837
  if (local === undefined) {
826
838
  return undefined;
827
839
  }
@@ -855,36 +867,32 @@ const checkAttributeChanges = (remote, local, collection, recreating = true) =>
855
867
 
856
868
  /**
857
869
  * Check if attributes contain the given attribute
858
- * @param attribute
859
- * @param attributes
860
- * @returns {*}
861
870
  */
862
- const attributesContains = (attribute, attributes) => attributes.find((attr) => attr.key === attribute.key);
863
- const generateChangesObject = (attribute, collection, isAdding) => {
871
+ const attributesContains = (attribute: any, attributes: any[]): any => attributes.find((attr) => attr.key === attribute.key);
872
+
873
+ const generateChangesObject = (attribute: any, collection: any, isAdding: boolean): AttributeChange => {
864
874
  return {
865
875
  key: `${chalk.yellow(attribute.key)} in ${collection.name} (${collection['$id']})`,
866
876
  attribute: attribute,
867
877
  reason: isAdding ? 'Field isn\'t present on the remote server' : 'Field isn\'t present on the appwrite.config.json file',
868
878
  action: isAdding ? chalk.green('adding') : chalk.red('deleting')
869
879
  };
870
-
871
880
  };
872
881
 
873
882
  /**
874
883
  * Filter deleted and recreated attributes,
875
884
  * return list of attributes to create
876
- * @returns {Promise<*|*[]>}
877
885
  */
878
- const attributesToCreate = async (remoteAttributes, localAttributes, collection, isIndex = false) => {
886
+ const attributesToCreate = async (remoteAttributes: any[], localAttributes: any[], collection: any, isIndex: boolean = false): Promise<any[]> => {
879
887
 
880
888
  const deleting = remoteAttributes.filter((attribute) => !attributesContains(attribute, localAttributes)).map((attr) => generateChangesObject(attr, collection, false));
881
889
  const adding = localAttributes.filter((attribute) => !attributesContains(attribute, remoteAttributes)).map((attr) => generateChangesObject(attr, collection, true));
882
- const conflicts = remoteAttributes.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection)).filter(attribute => attribute !== undefined);
890
+ const conflicts = remoteAttributes.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection)).filter(attribute => attribute !== undefined) as AttributeChange[];
883
891
  const changes = remoteAttributes.map((attribute) => checkAttributeChanges(attribute, attributesContains(attribute, localAttributes), collection, false))
884
892
  .filter(attribute => attribute !== undefined)
885
- .filter(attribute => conflicts.filter(attr => attribute.key === attr.key).length !== 1);
893
+ .filter(attribute => conflicts.filter(attr => attribute!.key === attr.key).length !== 1) as AttributeChange[];
886
894
 
887
- let changedAttributes = [];
895
+ let changedAttributes: any[] = [];
888
896
  const changing = [...deleting, ...adding, ...conflicts, ...changes]
889
897
  if (changing.length === 0) {
890
898
  return changedAttributes;
@@ -928,7 +936,7 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
928
936
 
929
937
  const deletingAttributes = deleting.map((change) => change.attribute);
930
938
  await Promise.all(deletingAttributes.map((attribute) => deleteAttribute(collection, attribute, isIndex)));
931
- const attributeKeys = [...remoteAttributes.map(attribute => attribute.key), ...deletingAttributes.map(attribute => attribute.key)]
939
+ const attributeKeys = [...remoteAttributes.map((attribute: any) => attribute.key), ...deletingAttributes.map((attribute: any) => attribute.key)]
932
940
 
933
941
  if (attributeKeys.length) {
934
942
  const deleteAttributesPoolStatus = await awaitPools.deleteAttributes(collection['databaseId'], collection['$id'], attributeKeys);
@@ -940,7 +948,8 @@ const attributesToCreate = async (remoteAttributes, localAttributes, collection,
940
948
 
941
949
  return localAttributes.filter((attribute) => !attributesContains(attribute, remoteAttributes));
942
950
  }
943
- const createIndexes = async (indexes, collection) => {
951
+
952
+ const createIndexes = async (indexes: any[], collection: any): Promise<void> => {
944
953
  log(`Creating indexes ...`)
945
954
 
946
955
  for (let index of indexes) {
@@ -958,7 +967,7 @@ const createIndexes = async (indexes, collection) => {
958
967
  const result = await awaitPools.expectIndexes(
959
968
  collection['databaseId'],
960
969
  collection['$id'],
961
- indexes.map(index => index.key)
970
+ indexes.map((index: any) => index.key)
962
971
  );
963
972
 
964
973
  if (!result) {
@@ -967,7 +976,8 @@ const createIndexes = async (indexes, collection) => {
967
976
 
968
977
  success(`Created ${indexes.length} indexes`);
969
978
  }
970
- const createAttributes = async (attributes, collection) => {
979
+
980
+ const createAttributes = async (attributes: any[], collection: any): Promise<void> => {
971
981
  for (let attribute of attributes) {
972
982
  if (attribute.side !== 'child') {
973
983
  await createAttribute(collection['databaseId'], collection['$id'], attribute);
@@ -977,7 +987,7 @@ const createAttributes = async (attributes, collection) => {
977
987
  const result = await awaitPools.expectAttributes(
978
988
  collection['databaseId'],
979
989
  collection['$id'],
980
- collection.attributes.filter(attribute => attribute.side !== 'child').map(attribute => attribute.key)
990
+ collection.attributes.filter((attribute: any) => attribute.side !== 'child').map((attribute: any) => attribute.key)
981
991
  );
982
992
 
983
993
  if (!result) {
@@ -986,7 +996,8 @@ const createAttributes = async (attributes, collection) => {
986
996
 
987
997
  success(`Created ${attributes.length} attributes`);
988
998
  }
989
- const createColumns = async (columns, table) => {
999
+
1000
+ const createColumns = async (columns: any[], table: any): Promise<void> => {
990
1001
  for (let column of columns) {
991
1002
  if (column.side !== 'child') {
992
1003
  await createAttribute(table['databaseId'], table['$id'], column);
@@ -996,7 +1007,7 @@ const createColumns = async (columns, table) => {
996
1007
  const result = await awaitPools.expectAttributes(
997
1008
  table['databaseId'],
998
1009
  table['$id'],
999
- table.columns.filter(column => column.side !== 'child').map(column => column.key)
1010
+ table.columns.filter((column: any) => column.side !== 'child').map((column: any) => column.key)
1000
1011
  );
1001
1012
 
1002
1013
  if (!result) {
@@ -1006,8 +1017,8 @@ const createColumns = async (columns, table) => {
1006
1017
  success(`Created ${columns.length} columns`);
1007
1018
  }
1008
1019
 
1009
- const pushResources = async () => {
1010
- const actions = {
1020
+ const pushResources = async (): Promise<void> => {
1021
+ const actions: Record<string, (options?: any) => Promise<void>> = {
1011
1022
  settings: pushSettings,
1012
1023
  functions: pushFunction,
1013
1024
  sites: pushSite,
@@ -1032,7 +1043,7 @@ const pushResources = async () => {
1032
1043
  }
1033
1044
  };
1034
1045
 
1035
- const pushSettings = async () => {
1046
+ const pushSettings = async (): Promise<void> => {
1036
1047
  checkDeployConditions(localConfig);
1037
1048
 
1038
1049
  try {
@@ -1045,7 +1056,7 @@ const pushSettings = async () => {
1045
1056
  const localSettings = localConfig.getProject().projectSettings ?? {};
1046
1057
 
1047
1058
  log('Checking for changes ...');
1048
- const changes = [];
1059
+ const changes: any[] = [];
1049
1060
 
1050
1061
  changes.push(...(getObjectChanges(remoteSettings, localSettings, 'services', 'Service')));
1051
1062
  changes.push(...(getObjectChanges(remoteSettings['auth'] ?? {}, localSettings['auth'] ?? {}, 'methods', 'Auth method')));
@@ -1122,17 +1133,25 @@ const pushSettings = async () => {
1122
1133
  }
1123
1134
  }
1124
1135
 
1125
- const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero: false }) => {
1136
+ interface PushSiteOptions {
1137
+ siteId?: string;
1138
+ async?: boolean;
1139
+ code?: boolean;
1140
+ withVariables?: boolean;
1141
+ returnOnZero?: boolean;
1142
+ }
1143
+
1144
+ const pushSite = async({ siteId, async: asyncDeploy, code, withVariables }: PushSiteOptions = { returnOnZero: false }): Promise<void> => {
1126
1145
  process.chdir(localConfig.configDirectoryPath)
1127
1146
 
1128
- const siteIds = [];
1147
+ const siteIds: string[] = [];
1129
1148
 
1130
1149
  if(siteId) {
1131
1150
  siteIds.push(siteId);
1132
1151
  } else if (cliConfig.all) {
1133
1152
  checkDeployConditions(localConfig);
1134
1153
  const sites = localConfig.getSites();
1135
- siteIds.push(...sites.map((site) => {
1154
+ siteIds.push(...sites.map((site: any) => {
1136
1155
  return site.$id;
1137
1156
  }));
1138
1157
  }
@@ -1150,9 +1169,9 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1150
1169
  return;
1151
1170
  }
1152
1171
 
1153
- let sites = siteIds.map((id) => {
1172
+ let sites = siteIds.map((id: string) => {
1154
1173
  const sites = localConfig.getSites();
1155
- const site = sites.find((s) => s.$id === id);
1174
+ const site = sites.find((s: any) => s.$id === id);
1156
1175
 
1157
1176
  if (!site) {
1158
1177
  throw new Error("Site '" + id + "' not found.")
@@ -1167,8 +1186,8 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1167
1186
 
1168
1187
  if (!site.buildCommand) {
1169
1188
  log(`Site ${site.name} is missing build command.`);
1170
- const answers = await inquirer.prompt(questionsGetBuildCommand)
1171
- site.buildCommand = answers.buildCommand;
1189
+ const answers = await inquirer.prompt(questionsGetEntrypoint)
1190
+ site.buildCommand = answers.entrypoint;
1172
1191
  localConfig.addSite(site);
1173
1192
  }
1174
1193
  }
@@ -1182,11 +1201,11 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1182
1201
  Spinner.start(false);
1183
1202
  let successfullyPushed = 0;
1184
1203
  let successfullyDeployed = 0;
1185
- const failedDeployments = [];
1186
- const errors = [];
1204
+ const failedDeployments: any[] = [];
1205
+ const errors: any[] = [];
1187
1206
 
1188
- await Promise.all(sites.map(async (site) => {
1189
- let response = {};
1207
+ await Promise.all(sites.map(async (site: any) => {
1208
+ let response: any = {};
1190
1209
 
1191
1210
  const ignore = site.ignore ? 'appwrite.config.json' : '.gitignore';
1192
1211
  let siteExists = false;
@@ -1226,7 +1245,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1226
1245
  vars: JSON.stringify(response.vars),
1227
1246
  parseOutput: false
1228
1247
  });
1229
- } catch (e) {
1248
+ } catch (e: any) {
1230
1249
 
1231
1250
  if (Number(e.code) === 404) {
1232
1251
  siteExists = false;
@@ -1280,7 +1299,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1280
1299
  }
1281
1300
 
1282
1301
  updaterRow.update({ status: 'Created' });
1283
- } catch (e) {
1302
+ } catch (e: any) {
1284
1303
  errors.push(e)
1285
1304
  updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1286
1305
  return;
@@ -1295,7 +1314,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1295
1314
  parseOutput: false
1296
1315
  }, 100, 'variables');
1297
1316
 
1298
- await Promise.all(variables.map(async variable => {
1317
+ await Promise.all(variables.map(async (variable: any) => {
1299
1318
  await sitesDeleteVariable({
1300
1319
  siteId: site['$id'],
1301
1320
  variableId: variable['$id'],
@@ -1304,7 +1323,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1304
1323
  }));
1305
1324
 
1306
1325
  const envFileLocation = `${site['path']}/.env`;
1307
- let envVariables = [];
1326
+ let envVariables: Array<{key: string; value: string}> = [];
1308
1327
  try {
1309
1328
  if (fs.existsSync(envFileLocation)) {
1310
1329
  const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
@@ -1314,7 +1333,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1314
1333
  // Handle parsing errors gracefully
1315
1334
  envVariables = [];
1316
1335
  }
1317
- await Promise.all(envVariables.map(async variable => {
1336
+ await Promise.all(envVariables.map(async (variable) => {
1318
1337
  await sitesCreateVariable({
1319
1338
  siteId: site['$id'],
1320
1339
  key: variable.key,
@@ -1349,7 +1368,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1349
1368
  updaterRow.update({ status: 'Pushed' });
1350
1369
  deploymentCreated = true;
1351
1370
  successfullyPushed++;
1352
- } catch (e) {
1371
+ } catch (e: any) {
1353
1372
  errors.push(e);
1354
1373
 
1355
1374
  switch (e.code) {
@@ -1361,7 +1380,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1361
1380
  }
1362
1381
  }
1363
1382
 
1364
- if (deploymentCreated && !async) {
1383
+ if (deploymentCreated && !asyncDeploy) {
1365
1384
  try {
1366
1385
  const deploymentId = response['$id'];
1367
1386
  updaterRow.update({ status: 'Deploying', end: 'Checking deployment status...' })
@@ -1408,7 +1427,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1408
1427
  pollChecks++;
1409
1428
  await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
1410
1429
  }
1411
- } catch (e) {
1430
+ } catch (e: any) {
1412
1431
  errors.push(e);
1413
1432
  updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
1414
1433
  }
@@ -1426,7 +1445,7 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1426
1445
  error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1427
1446
  });
1428
1447
 
1429
- if (!async) {
1448
+ if (!asyncDeploy) {
1430
1449
  if (successfullyPushed === 0) {
1431
1450
  error('No sites were pushed.');
1432
1451
  } else if (successfullyDeployed !== successfullyPushed) {
@@ -1445,17 +1464,25 @@ const pushSite = async({ siteId, async, code, withVariables } = { returnOnZero:
1445
1464
  }
1446
1465
  }
1447
1466
 
1448
- const pushFunction = async ({ functionId, async, code, withVariables } = { returnOnZero: false }) => {
1467
+ interface PushFunctionOptions {
1468
+ functionId?: string;
1469
+ async?: boolean;
1470
+ code?: boolean;
1471
+ withVariables?: boolean;
1472
+ returnOnZero?: boolean;
1473
+ }
1474
+
1475
+ const pushFunction = async ({ functionId, async: asyncDeploy, code, withVariables }: PushFunctionOptions = { returnOnZero: false }): Promise<void> => {
1449
1476
  process.chdir(localConfig.configDirectoryPath)
1450
1477
 
1451
- const functionIds = [];
1478
+ const functionIds: string[] = [];
1452
1479
 
1453
1480
  if (functionId) {
1454
1481
  functionIds.push(functionId);
1455
1482
  } else if (cliConfig.all) {
1456
1483
  checkDeployConditions(localConfig);
1457
1484
  const functions = localConfig.getFunctions();
1458
- functionIds.push(...functions.map((func) => {
1485
+ functionIds.push(...functions.map((func: any) => {
1459
1486
  return func.$id;
1460
1487
  }));
1461
1488
  }
@@ -1473,9 +1500,9 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1473
1500
  return;
1474
1501
  }
1475
1502
 
1476
- let functions = functionIds.map((id) => {
1503
+ let functions = functionIds.map((id: string) => {
1477
1504
  const functions = localConfig.getFunctions();
1478
- const func = functions.find((f) => f.$id === id);
1505
+ const func = functions.find((f: any) => f.$id === id);
1479
1506
 
1480
1507
  if (!func) {
1481
1508
  throw new Error("Function '" + id + "' not found.")
@@ -1505,11 +1532,11 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1505
1532
  Spinner.start(false);
1506
1533
  let successfullyPushed = 0;
1507
1534
  let successfullyDeployed = 0;
1508
- const failedDeployments = [];
1509
- const errors = [];
1535
+ const failedDeployments: any[] = [];
1536
+ const errors: any[] = [];
1510
1537
 
1511
- await Promise.all(functions.map(async (func) => {
1512
- let response = {};
1538
+ await Promise.all(functions.map(async (func: any) => {
1539
+ let response: any = {};
1513
1540
 
1514
1541
  const ignore = func.ignore ? 'appwrite.config.json' : '.gitignore';
1515
1542
  let functionExists = false;
@@ -1547,7 +1574,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1547
1574
  vars: JSON.stringify(response.vars),
1548
1575
  parseOutput: false
1549
1576
  });
1550
- } catch (e) {
1577
+ } catch (e: any) {
1551
1578
 
1552
1579
  if (Number(e.code) === 404) {
1553
1580
  functionExists = false;
@@ -1601,7 +1628,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1601
1628
  }
1602
1629
 
1603
1630
  updaterRow.update({ status: 'Created' });
1604
- } catch (e) {
1631
+ } catch (e: any) {
1605
1632
  errors.push(e)
1606
1633
  updaterRow.fail({ errorMessage: e.message ?? 'General error occurs please try again' });
1607
1634
  return;
@@ -1616,7 +1643,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1616
1643
  parseOutput: false
1617
1644
  }, 100, 'variables');
1618
1645
 
1619
- await Promise.all(variables.map(async variable => {
1646
+ await Promise.all(variables.map(async (variable: any) => {
1620
1647
  await functionsDeleteVariable({
1621
1648
  functionId: func['$id'],
1622
1649
  variableId: variable['$id'],
@@ -1625,7 +1652,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1625
1652
  }));
1626
1653
 
1627
1654
  const envFileLocation = `${func['path']}/.env`;
1628
- let envVariables = [];
1655
+ let envVariables: Array<{key: string; value: string}> = [];
1629
1656
  try {
1630
1657
  if (fs.existsSync(envFileLocation)) {
1631
1658
  const envObject = parseDotenv(fs.readFileSync(envFileLocation, 'utf8'));
@@ -1635,7 +1662,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1635
1662
  // Handle parsing errors gracefully
1636
1663
  envVariables = [];
1637
1664
  }
1638
- await Promise.all(envVariables.map(async variable => {
1665
+ await Promise.all(envVariables.map(async (variable) => {
1639
1666
  await functionsCreateVariable({
1640
1667
  functionId: func['$id'],
1641
1668
  variableId: ID.unique(),
@@ -1669,7 +1696,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1669
1696
  updaterRow.update({ status: 'Pushed' });
1670
1697
  deploymentCreated = true;
1671
1698
  successfullyPushed++;
1672
- } catch (e) {
1699
+ } catch (e: any) {
1673
1700
  errors.push(e);
1674
1701
 
1675
1702
  switch (e.code) {
@@ -1681,7 +1708,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1681
1708
  }
1682
1709
  }
1683
1710
 
1684
- if (deploymentCreated && !async) {
1711
+ if (deploymentCreated && !asyncDeploy) {
1685
1712
  try {
1686
1713
  const deploymentId = response['$id'];
1687
1714
  updaterRow.update({ status: 'Deploying', end: 'Checking deployment status...' })
@@ -1694,7 +1721,6 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1694
1721
  parseOutput: false
1695
1722
  });
1696
1723
 
1697
-
1698
1724
  const status = response['status'];
1699
1725
  if (status === 'ready') {
1700
1726
  successfullyDeployed++;
@@ -1729,7 +1755,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1729
1755
  pollChecks++;
1730
1756
  await new Promise(resolve => setTimeout(resolve, POLL_DEBOUNCE * 1.5));
1731
1757
  }
1732
- } catch (e) {
1758
+ } catch (e: any) {
1733
1759
  errors.push(e);
1734
1760
  updaterRow.fail({ errorMessage: e.message ?? 'Unknown error occurred. Please try again' })
1735
1761
  }
@@ -1747,7 +1773,7 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1747
1773
  error(`Deployment of ${name} has failed. Check at ${failUrl} for more details\n`);
1748
1774
  });
1749
1775
 
1750
- if (!async) {
1776
+ if (!asyncDeploy) {
1751
1777
  if (successfullyPushed === 0) {
1752
1778
  error('No functions were pushed.');
1753
1779
  } else if (successfullyDeployed !== successfullyPushed) {
@@ -1766,7 +1792,12 @@ const pushFunction = async ({ functionId, async, code, withVariables } = { retur
1766
1792
  }
1767
1793
  }
1768
1794
 
1769
- const checkAndApplyTablesDBChanges = async () => {
1795
+ interface TablesDBChangesResult {
1796
+ applied: boolean;
1797
+ resyncNeeded: boolean;
1798
+ }
1799
+
1800
+ const checkAndApplyTablesDBChanges = async (): Promise<TablesDBChangesResult> => {
1770
1801
  log('Checking for tablesDB changes ...');
1771
1802
 
1772
1803
  const localTablesDBs = localConfig.getTablesDBs();
@@ -1776,14 +1807,14 @@ const checkAndApplyTablesDBChanges = async () => {
1776
1807
  return { applied: false, resyncNeeded: false };
1777
1808
  }
1778
1809
 
1779
- const changes = [];
1780
- const toCreate = [];
1781
- const toUpdate = [];
1782
- const toDelete = [];
1810
+ const changes: any[] = [];
1811
+ const toCreate: any[] = [];
1812
+ const toUpdate: any[] = [];
1813
+ const toDelete: any[] = [];
1783
1814
 
1784
1815
  // Check for deletions - remote DBs that aren't in local config
1785
1816
  for (const remoteDB of remoteTablesDBs) {
1786
- const localDB = localTablesDBs.find(db => db.$id === remoteDB.$id);
1817
+ const localDB = localTablesDBs.find((db: any) => db.$id === remoteDB.$id);
1787
1818
  if (!localDB) {
1788
1819
  toDelete.push(remoteDB);
1789
1820
  changes.push({
@@ -1798,7 +1829,7 @@ const checkAndApplyTablesDBChanges = async () => {
1798
1829
 
1799
1830
  // Check for additions and updates
1800
1831
  for (const localDB of localTablesDBs) {
1801
- const remoteDB = remoteTablesDBs.find(db => db.$id === localDB.$id);
1832
+ const remoteDB = remoteTablesDBs.find((db: any) => db.$id === localDB.$id);
1802
1833
 
1803
1834
  if (!remoteDB) {
1804
1835
  toCreate.push(localDB);
@@ -1871,7 +1902,7 @@ const checkAndApplyTablesDBChanges = async () => {
1871
1902
  });
1872
1903
  success(`Deleted ${db.name} ( ${db.$id} )`);
1873
1904
  needsResync = true;
1874
- } catch (e) {
1905
+ } catch (e: any) {
1875
1906
  error(`Failed to delete database ${db.name} ( ${db.$id} ): ${e.message}`);
1876
1907
  throw new Error(`Database sync failed during deletion of ${db.$id}. Some changes may have been applied.`);
1877
1908
  }
@@ -1888,7 +1919,7 @@ const checkAndApplyTablesDBChanges = async () => {
1888
1919
  parseOutput: false
1889
1920
  });
1890
1921
  success(`Created ${db.name} ( ${db.$id} )`);
1891
- } catch (e) {
1922
+ } catch (e: any) {
1892
1923
  error(`Failed to create database ${db.name} ( ${db.$id} ): ${e.message}`);
1893
1924
  throw new Error(`Database sync failed during creation of ${db.$id}. Some changes may have been applied.`);
1894
1925
  }
@@ -1905,7 +1936,7 @@ const checkAndApplyTablesDBChanges = async () => {
1905
1936
  parseOutput: false
1906
1937
  });
1907
1938
  success(`Updated ${db.name} ( ${db.$id} )`);
1908
- } catch (e) {
1939
+ } catch (e: any) {
1909
1940
  error(`Failed to update database ${db.name} ( ${db.$id} ): ${e.message}`);
1910
1941
  throw new Error(`Database sync failed during update of ${db.$id}. Some changes may have been applied.`);
1911
1942
  }
@@ -1918,8 +1949,13 @@ const checkAndApplyTablesDBChanges = async () => {
1918
1949
  return { applied: true, resyncNeeded: needsResync };
1919
1950
  };
1920
1951
 
1921
- const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {
1922
- const tables = [];
1952
+ interface PushTableOptions {
1953
+ returnOnZero?: boolean;
1954
+ attempts?: number;
1955
+ }
1956
+
1957
+ const pushTable = async ({ returnOnZero, attempts }: PushTableOptions = { returnOnZero: false }): Promise<void> => {
1958
+ const tables: any[] = [];
1923
1959
 
1924
1960
  if (attempts) {
1925
1961
  pollMaxDebounces = attempts;
@@ -1932,13 +1968,13 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1932
1968
  const remoteTablesDBs = (await paginate(tablesDBList, { parseOutput: false }, 100, 'databases')).databases;
1933
1969
  const localTablesDBs = localConfig.getTablesDBs();
1934
1970
 
1935
- const remoteDatabaseIds = new Set(remoteTablesDBs.map(db => db.$id));
1971
+ const remoteDatabaseIds = new Set(remoteTablesDBs.map((db: any) => db.$id));
1936
1972
  const localTables = localConfig.getTables();
1937
- const validTables = localTables.filter(table => remoteDatabaseIds.has(table.databaseId));
1973
+ const validTables = localTables.filter((table: any) => remoteDatabaseIds.has(table.databaseId));
1938
1974
 
1939
1975
  localConfig.set('tables', validTables);
1940
1976
 
1941
- const validTablesDBs = localTablesDBs.filter(db => remoteDatabaseIds.has(db.$id));
1977
+ const validTablesDBs = localTablesDBs.filter((db: any) => remoteDatabaseIds.has(db.$id));
1942
1978
  localConfig.set('tablesDB', validTablesDBs);
1943
1979
 
1944
1980
  success('Configuration resynced successfully.');
@@ -1948,7 +1984,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1948
1984
  log('Checking for deleted tables ...');
1949
1985
  const localTablesDBs = localConfig.getTablesDBs();
1950
1986
  const localTables = localConfig.getTables();
1951
- const tablesToDelete = [];
1987
+ const tablesToDelete: any[] = [];
1952
1988
 
1953
1989
  for (const db of localTablesDBs) {
1954
1990
  try {
@@ -1958,7 +1994,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1958
1994
  }, 100, 'tables');
1959
1995
 
1960
1996
  for (const remoteTable of remoteTables) {
1961
- const localTable = localTables.find(t => t.$id === remoteTable.$id && t.databaseId === db.$id);
1997
+ const localTable = localTables.find((t: any) => t.$id === remoteTable.$id && t.databaseId === db.$id);
1962
1998
  if (!localTable) {
1963
1999
  tablesToDelete.push({
1964
2000
  ...remoteTable,
@@ -1974,7 +2010,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1974
2010
 
1975
2011
  if (tablesToDelete.length > 0) {
1976
2012
  log('Found tables that exist remotely but not locally:');
1977
- const deletionChanges = tablesToDelete.map(table => ({
2013
+ const deletionChanges = tablesToDelete.map((table: any) => ({
1978
2014
  id: table.$id,
1979
2015
  action: chalk.red('deleting'),
1980
2016
  key: 'Table',
@@ -1994,7 +2030,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
1994
2030
  parseOutput: false
1995
2031
  });
1996
2032
  success(`Deleted ${table.name} ( ${table.$id} )`);
1997
- } catch (e) {
2033
+ } catch (e: any) {
1998
2034
  error(`Failed to delete table ${table.name} ( ${table.$id} ): ${e.message}`);
1999
2035
  }
2000
2036
  }
@@ -2011,10 +2047,10 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
2011
2047
  const answers = await inquirer.prompt(questionsPushTables)
2012
2048
  if (answers.tables) {
2013
2049
  const configTables = new Map();
2014
- localConfig.getTables().forEach((c) => {
2050
+ localConfig.getTables().forEach((c: any) => {
2015
2051
  configTables.set(`${c['databaseId']}|${c['$id']}`, c);
2016
2052
  });
2017
- answers.tables.forEach((a) => {
2053
+ answers.tables.forEach((a: any) => {
2018
2054
  const table = configTables.get(a);
2019
2055
  tables.push(table);
2020
2056
  })
@@ -2033,7 +2069,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
2033
2069
  let tablesChanged = new Set();
2034
2070
 
2035
2071
  // Parallel tables actions
2036
- await Promise.all(tables.map(async (table) => {
2072
+ await Promise.all(tables.map(async (table: any) => {
2037
2073
  try {
2038
2074
  const remoteTable = await tablesDBGetTable({
2039
2075
  databaseId: table['databaseId'],
@@ -2041,7 +2077,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
2041
2077
  parseOutput: false,
2042
2078
  });
2043
2079
 
2044
- const changes = [];
2080
+ const changes: string[] = [];
2045
2081
  if (remoteTable.name !== table.name) changes.push('name');
2046
2082
  if (remoteTable.rowSecurity !== table.rowSecurity) changes.push('rowSecurity');
2047
2083
  if (remoteTable.enabled !== table.enabled) changes.push('enabled');
@@ -2063,8 +2099,7 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
2063
2099
  table.remoteVersion = remoteTable;
2064
2100
 
2065
2101
  table.isExisted = true;
2066
- } catch
2067
- (e) {
2102
+ } catch (e: any) {
2068
2103
  if (Number(e.code) === 404) {
2069
2104
  log(`Table ${table.name} does not exist in the project. Creating ... `);
2070
2105
  await tablesDBCreateTable({
@@ -2118,9 +2153,14 @@ const pushTable = async ({ returnOnZero, attempts } = { returnOnZero: false }) =
2118
2153
  success(`Successfully pushed ${tablesChanged.size} tables`);
2119
2154
  }
2120
2155
 
2121
- const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false }) => {
2156
+ interface PushCollectionOptions {
2157
+ returnOnZero?: boolean;
2158
+ attempts?: number;
2159
+ }
2160
+
2161
+ const pushCollection = async ({ returnOnZero, attempts }: PushCollectionOptions = { returnOnZero: false }): Promise<void> => {
2122
2162
  warn("appwrite push collection has been deprecated. Please consider using 'appwrite push tables' instead");
2123
- const collections = [];
2163
+ const collections: any[] = [];
2124
2164
 
2125
2165
  if (attempts) {
2126
2166
  pollMaxDebounces = attempts;
@@ -2133,10 +2173,10 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
2133
2173
  const answers = await inquirer.prompt(questionsPushCollections)
2134
2174
  if (answers.collections) {
2135
2175
  const configCollections = new Map();
2136
- localConfig.getCollections().forEach((c) => {
2176
+ localConfig.getCollections().forEach((c: any) => {
2137
2177
  configCollections.set(`${c['databaseId']}|${c['$id']}`, c);
2138
2178
  });
2139
- answers.collections.forEach((a) => {
2179
+ answers.collections.forEach((a: any) => {
2140
2180
  const collection = configCollections.get(a);
2141
2181
  collections.push(collection);
2142
2182
  })
@@ -2149,10 +2189,10 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
2149
2189
  return;
2150
2190
  }
2151
2191
 
2152
- const databases = Array.from(new Set(collections.map(collection => collection['databaseId'])));
2192
+ const databases = Array.from(new Set(collections.map((collection: any) => collection['databaseId'])));
2153
2193
 
2154
2194
  // Parallel db actions
2155
- await Promise.all(databases.map(async (databaseId) => {
2195
+ await Promise.all(databases.map(async (databaseId: any) => {
2156
2196
  const localDatabase = localConfig.getDatabase(databaseId);
2157
2197
 
2158
2198
  try {
@@ -2181,12 +2221,11 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
2181
2221
  }
2182
2222
  }));
2183
2223
 
2184
-
2185
2224
  if (!(await approveChanges(collections, databasesGetCollection, KeysCollection, 'collectionId', 'collections', ['attributes', 'indexes'], 'databaseId', 'databaseId',))) {
2186
2225
  return;
2187
2226
  }
2188
2227
  // Parallel collection actions
2189
- await Promise.all(collections.map(async (collection) => {
2228
+ await Promise.all(collections.map(async (collection: any) => {
2190
2229
  try {
2191
2230
  const remoteCollection = await databasesGetCollection({
2192
2231
  databaseId: collection['databaseId'],
@@ -2207,8 +2246,7 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
2207
2246
  collection.remoteVersion = remoteCollection;
2208
2247
 
2209
2248
  collection.isExisted = true;
2210
- } catch
2211
- (e) {
2249
+ } catch (e: any) {
2212
2250
  if (Number(e.code) === 404) {
2213
2251
  log(`Collection ${collection.name} does not exist in the project. Creating ... `);
2214
2252
  await databasesCreateCollection({
@@ -2260,15 +2298,19 @@ const pushCollection = async ({ returnOnZero, attempts } = { returnOnZero: false
2260
2298
  success(`Successfully pushed ${numberOfCollections} collections`);
2261
2299
  }
2262
2300
 
2263
- const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
2264
- let response = {};
2301
+ interface PushBucketOptions {
2302
+ returnOnZero?: boolean;
2303
+ }
2304
+
2305
+ const pushBucket = async ({ returnOnZero }: PushBucketOptions = { returnOnZero: false }): Promise<void> => {
2306
+ let response: any = {};
2265
2307
 
2266
- let bucketIds = [];
2308
+ let bucketIds: string[] = [];
2267
2309
  const configBuckets = localConfig.getBuckets();
2268
2310
 
2269
2311
  if (cliConfig.all) {
2270
2312
  checkDeployConditions(localConfig);
2271
- bucketIds.push(...configBuckets.map((b) => b.$id));
2313
+ bucketIds.push(...configBuckets.map((b: any) => b.$id));
2272
2314
  }
2273
2315
 
2274
2316
  if (bucketIds.length === 0) {
@@ -2284,10 +2326,10 @@ const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
2284
2326
  return;
2285
2327
  }
2286
2328
 
2287
- let buckets = [];
2329
+ let buckets: any[] = [];
2288
2330
 
2289
2331
  for (const bucketId of bucketIds) {
2290
- const idBuckets = configBuckets.filter((b) => b.$id === bucketId);
2332
+ const idBuckets = configBuckets.filter((b: any) => b.$id === bucketId);
2291
2333
  buckets.push(...idBuckets);
2292
2334
  }
2293
2335
 
@@ -2319,7 +2361,7 @@ const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
2319
2361
  compression: bucket.compression,
2320
2362
  parseOutput: false
2321
2363
  });
2322
- } catch (e) {
2364
+ } catch (e: any) {
2323
2365
  if (Number(e.code) === 404) {
2324
2366
  log(`Bucket ${bucket.name} does not exist in the project. Creating ... `);
2325
2367
 
@@ -2345,15 +2387,19 @@ const pushBucket = async ({ returnOnZero } = { returnOnZero: false }) => {
2345
2387
  success(`Successfully pushed ${buckets.length} buckets.`);
2346
2388
  }
2347
2389
 
2348
- const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2349
- let response = {};
2390
+ interface PushTeamOptions {
2391
+ returnOnZero?: boolean;
2392
+ }
2393
+
2394
+ const pushTeam = async ({ returnOnZero }: PushTeamOptions = { returnOnZero: false }): Promise<void> => {
2395
+ let response: any = {};
2350
2396
 
2351
- let teamIds = [];
2397
+ let teamIds: string[] = [];
2352
2398
  const configTeams = localConfig.getTeams();
2353
2399
 
2354
2400
  if (cliConfig.all) {
2355
2401
  checkDeployConditions(localConfig);
2356
- teamIds.push(...configTeams.map((t) => t.$id));
2402
+ teamIds.push(...configTeams.map((t: any) => t.$id));
2357
2403
  }
2358
2404
 
2359
2405
  if (teamIds.length === 0) {
@@ -2369,10 +2415,10 @@ const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2369
2415
  return;
2370
2416
  }
2371
2417
 
2372
- let teams = [];
2418
+ let teams: any[] = [];
2373
2419
 
2374
2420
  for (const teamId of teamIds) {
2375
- const idTeams = configTeams.filter((t) => t.$id === teamId);
2421
+ const idTeams = configTeams.filter((t: any) => t.$id === teamId);
2376
2422
  teams.push(...idTeams);
2377
2423
  }
2378
2424
 
@@ -2380,7 +2426,6 @@ const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2380
2426
  return;
2381
2427
  }
2382
2428
 
2383
-
2384
2429
  log('Pushing teams ...');
2385
2430
 
2386
2431
  for (let team of teams) {
@@ -2397,7 +2442,7 @@ const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2397
2442
  name: team.name,
2398
2443
  parseOutput: false
2399
2444
  });
2400
- } catch (e) {
2445
+ } catch (e: any) {
2401
2446
  if (Number(e.code) === 404) {
2402
2447
  log(`Team ${team.name} does not exist in the project. Creating ... `);
2403
2448
 
@@ -2415,15 +2460,19 @@ const pushTeam = async ({ returnOnZero } = { returnOnZero: false }) => {
2415
2460
  success(`Successfully pushed ${teams.length} teams.`);
2416
2461
  }
2417
2462
 
2418
- const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) => {
2419
- let response = {};
2463
+ interface PushMessagingTopicOptions {
2464
+ returnOnZero?: boolean;
2465
+ }
2466
+
2467
+ const pushMessagingTopic = async ({ returnOnZero }: PushMessagingTopicOptions = { returnOnZero: false }): Promise<void> => {
2468
+ let response: any = {};
2420
2469
 
2421
- let topicsIds = [];
2470
+ let topicsIds: string[] = [];
2422
2471
  const configTopics = localConfig.getMessagingTopics();
2423
2472
 
2424
2473
  if (cliConfig.all) {
2425
2474
  checkDeployConditions(localConfig);
2426
- topicsIds.push(...configTopics.map((b) => b.$id));
2475
+ topicsIds.push(...configTopics.map((b: any) => b.$id));
2427
2476
  }
2428
2477
 
2429
2478
  if (topicsIds.length === 0) {
@@ -2439,10 +2488,10 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) =>
2439
2488
  return;
2440
2489
  }
2441
2490
 
2442
- let topics = [];
2491
+ let topics: any[] = [];
2443
2492
 
2444
2493
  for (const topicId of topicsIds) {
2445
- const idTopic = configTopics.filter((b) => b.$id === topicId);
2494
+ const idTopic = configTopics.filter((b: any) => b.$id === topicId);
2446
2495
  topics.push(...idTopic);
2447
2496
  }
2448
2497
 
@@ -2468,7 +2517,7 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) =>
2468
2517
  subscribe: topic.subscribe,
2469
2518
  parseOutput: false
2470
2519
  });
2471
- } catch (e) {
2520
+ } catch (e: any) {
2472
2521
  if (Number(e.code) === 404) {
2473
2522
  log(`Topic ${topic.name} does not exist in the project. Creating ... `);
2474
2523
 
@@ -2489,7 +2538,7 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) =>
2489
2538
  success(`Successfully pushed ${topics.length} topics.`);
2490
2539
  }
2491
2540
 
2492
- const push = new Command("push")
2541
+ export const push = new Command("push")
2493
2542
  .description(commandDescriptions['push'])
2494
2543
  .action(actionRunner(pushResources));
2495
2544
 
@@ -2558,13 +2607,8 @@ push
2558
2607
  .description("Push messaging topics in the current project.")
2559
2608
  .action(actionRunner(pushMessagingTopic));
2560
2609
 
2561
- const deploy = new Command("deploy")
2610
+ export const deploy = new Command("deploy")
2562
2611
  .description('Removed. Use appwrite push instead')
2563
2612
  .action(actionRunner(async () => {
2564
2613
  warn("appwrite deploy has been removed. Please use 'appwrite push' instead");
2565
2614
  }));
2566
-
2567
- module.exports = {
2568
- push,
2569
- deploy
2570
- }