appwrite-cli 13.0.0-rc.1 → 13.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (430) hide show
  1. package/.github/workflows/publish.yml +68 -0
  2. package/CHANGELOG.md +10 -1
  3. package/LICENSE.md +1 -1
  4. package/README.md +3 -3
  5. package/cli.ts +152 -0
  6. package/dist/bundle.cjs +95813 -0
  7. package/dist/cli.d.ts +3 -0
  8. package/dist/cli.d.ts.map +1 -0
  9. package/dist/cli.js +145 -0
  10. package/dist/cli.js.map +1 -0
  11. package/dist/index.d.ts +10 -2
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7 -142
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/client.d.ts +2 -3
  16. package/dist/lib/client.d.ts.map +1 -1
  17. package/dist/lib/client.js +57 -45
  18. package/dist/lib/client.js.map +1 -1
  19. package/dist/lib/commands/config.d.ts +562 -0
  20. package/dist/lib/commands/config.d.ts.map +1 -0
  21. package/dist/lib/commands/config.js +416 -0
  22. package/dist/lib/commands/config.js.map +1 -0
  23. package/dist/lib/commands/db.d.ts +34 -0
  24. package/dist/lib/commands/db.d.ts.map +1 -0
  25. package/dist/lib/commands/db.js +247 -0
  26. package/dist/lib/commands/db.js.map +1 -0
  27. package/dist/lib/commands/errors.d.ts +68 -0
  28. package/dist/lib/commands/errors.d.ts.map +1 -0
  29. package/dist/lib/commands/errors.js +72 -0
  30. package/dist/lib/commands/errors.js.map +1 -0
  31. package/dist/lib/commands/generic.d.ts +2 -2
  32. package/dist/lib/commands/generic.d.ts.map +1 -1
  33. package/dist/lib/commands/generic.js +170 -157
  34. package/dist/lib/commands/generic.js.map +1 -1
  35. package/dist/lib/commands/init.d.ts +1 -1
  36. package/dist/lib/commands/init.d.ts.map +1 -1
  37. package/dist/lib/commands/init.js +201 -192
  38. package/dist/lib/commands/init.js.map +1 -1
  39. package/dist/lib/commands/pull.d.ts +105 -3
  40. package/dist/lib/commands/pull.d.ts.map +1 -1
  41. package/dist/lib/commands/pull.js +530 -370
  42. package/dist/lib/commands/pull.js.map +1 -1
  43. package/dist/lib/commands/push.d.ts +106 -0
  44. package/dist/lib/commands/push.d.ts.map +1 -1
  45. package/dist/lib/commands/push.js +1432 -1830
  46. package/dist/lib/commands/push.js.map +1 -1
  47. package/dist/lib/commands/run.d.ts +1 -1
  48. package/dist/lib/commands/run.d.ts.map +1 -1
  49. package/dist/lib/commands/run.js +129 -127
  50. package/dist/lib/commands/run.js.map +1 -1
  51. package/dist/lib/commands/schema.d.ts +59 -0
  52. package/dist/lib/commands/schema.d.ts.map +1 -0
  53. package/dist/lib/commands/schema.js +86 -0
  54. package/dist/lib/commands/schema.js.map +1 -0
  55. package/dist/lib/commands/services/account.d.ts +3 -0
  56. package/dist/lib/commands/services/account.d.ts.map +1 -0
  57. package/dist/lib/commands/services/account.js +328 -0
  58. package/dist/lib/commands/services/account.js.map +1 -0
  59. package/dist/lib/commands/services/console.d.ts +3 -0
  60. package/dist/lib/commands/services/console.d.ts.map +1 -0
  61. package/dist/lib/commands/services/console.js +28 -0
  62. package/dist/lib/commands/services/console.js.map +1 -0
  63. package/dist/lib/commands/services/databases.d.ts +3 -0
  64. package/dist/lib/commands/services/databases.d.ts.map +1 -0
  65. package/dist/lib/commands/services/databases.js +620 -0
  66. package/dist/lib/commands/services/databases.js.map +1 -0
  67. package/dist/lib/commands/services/functions.d.ts +3 -0
  68. package/dist/lib/commands/services/functions.d.ts.map +1 -0
  69. package/dist/lib/commands/services/functions.js +266 -0
  70. package/dist/lib/commands/services/functions.js.map +1 -0
  71. package/dist/lib/commands/services/graphql.d.ts +3 -0
  72. package/dist/lib/commands/services/graphql.d.ts.map +1 -0
  73. package/dist/lib/commands/services/graphql.js +28 -0
  74. package/dist/lib/commands/services/graphql.js.map +1 -0
  75. package/dist/lib/commands/services/health.d.ts +3 -0
  76. package/dist/lib/commands/services/health.d.ts.map +1 -0
  77. package/dist/lib/commands/services/health.js +123 -0
  78. package/dist/lib/commands/services/health.js.map +1 -0
  79. package/dist/lib/commands/services/locale.d.ts +3 -0
  80. package/dist/lib/commands/services/locale.d.ts.map +1 -0
  81. package/dist/lib/commands/services/locale.js +52 -0
  82. package/dist/lib/commands/services/locale.js.map +1 -0
  83. package/dist/lib/commands/services/messaging.d.ts +3 -0
  84. package/dist/lib/commands/services/messaging.d.ts.map +1 -0
  85. package/dist/lib/commands/services/messaging.js +505 -0
  86. package/dist/lib/commands/services/messaging.js.map +1 -0
  87. package/dist/lib/commands/services/migrations.d.ts +3 -0
  88. package/dist/lib/commands/services/migrations.d.ts.map +1 -0
  89. package/dist/lib/commands/services/migrations.js +135 -0
  90. package/dist/lib/commands/services/migrations.js.map +1 -0
  91. package/dist/lib/commands/services/project.d.ts +3 -0
  92. package/dist/lib/commands/services/project.d.ts.map +1 -0
  93. package/dist/lib/commands/services/project.js +54 -0
  94. package/dist/lib/commands/services/project.js.map +1 -0
  95. package/dist/lib/commands/services/projects.d.ts +3 -0
  96. package/dist/lib/commands/services/projects.d.ts.map +1 -0
  97. package/dist/lib/commands/services/projects.js +415 -0
  98. package/dist/lib/commands/services/projects.js.map +1 -0
  99. package/dist/lib/commands/services/proxy.d.ts +3 -0
  100. package/dist/lib/commands/services/proxy.d.ts.map +1 -0
  101. package/dist/lib/commands/services/proxy.js +68 -0
  102. package/dist/lib/commands/services/proxy.js.map +1 -0
  103. package/dist/lib/commands/services/sites.d.ts +3 -0
  104. package/dist/lib/commands/services/sites.d.ts.map +1 -0
  105. package/dist/lib/commands/services/sites.js +250 -0
  106. package/dist/lib/commands/services/sites.js.map +1 -0
  107. package/dist/lib/commands/services/storage.d.ts +3 -0
  108. package/dist/lib/commands/services/storage.d.ts.map +1 -0
  109. package/dist/lib/commands/services/storage.js +175 -0
  110. package/dist/lib/commands/services/storage.js.map +1 -0
  111. package/dist/lib/commands/services/tables-db.d.ts +3 -0
  112. package/dist/lib/commands/services/tables-db.d.ts.map +1 -0
  113. package/dist/lib/commands/services/tables-db.js +613 -0
  114. package/dist/lib/commands/services/tables-db.js.map +1 -0
  115. package/dist/lib/commands/services/teams.d.ts +3 -0
  116. package/dist/lib/commands/services/teams.d.ts.map +1 -0
  117. package/dist/lib/commands/services/teams.js +123 -0
  118. package/dist/lib/commands/services/teams.js.map +1 -0
  119. package/dist/lib/commands/services/tokens.d.ts +3 -0
  120. package/dist/lib/commands/services/tokens.d.ts.map +1 -0
  121. package/dist/lib/commands/services/tokens.js +49 -0
  122. package/dist/lib/commands/services/tokens.js.map +1 -0
  123. package/dist/lib/commands/services/users.d.ts +3 -0
  124. package/dist/lib/commands/services/users.d.ts.map +1 -0
  125. package/dist/lib/commands/services/users.js +312 -0
  126. package/dist/lib/commands/services/users.js.map +1 -0
  127. package/dist/lib/commands/services/vcs.d.ts +3 -0
  128. package/dist/lib/commands/services/vcs.d.ts.map +1 -0
  129. package/dist/lib/commands/services/vcs.js +87 -0
  130. package/dist/lib/commands/services/vcs.js.map +1 -0
  131. package/dist/lib/commands/types.d.ts +1 -1
  132. package/dist/lib/commands/types.d.ts.map +1 -1
  133. package/dist/lib/commands/types.js +53 -57
  134. package/dist/lib/commands/types.js.map +1 -1
  135. package/dist/lib/commands/update.d.ts +1 -1
  136. package/dist/lib/commands/update.d.ts.map +1 -1
  137. package/dist/lib/commands/update.js +69 -69
  138. package/dist/lib/commands/update.js.map +1 -1
  139. package/dist/lib/commands/utils/attributes.d.ts +47 -0
  140. package/dist/lib/commands/utils/attributes.d.ts.map +1 -0
  141. package/dist/lib/commands/utils/attributes.js +514 -0
  142. package/dist/lib/commands/utils/attributes.js.map +1 -0
  143. package/dist/lib/commands/utils/change-approval.d.ts +25 -0
  144. package/dist/lib/commands/utils/change-approval.d.ts.map +1 -0
  145. package/dist/lib/commands/utils/change-approval.js +129 -0
  146. package/dist/lib/commands/utils/change-approval.js.map +1 -0
  147. package/dist/lib/commands/utils/database-sync.d.ts +10 -0
  148. package/dist/lib/commands/utils/database-sync.d.ts.map +1 -0
  149. package/dist/lib/commands/utils/database-sync.js +136 -0
  150. package/dist/lib/commands/utils/database-sync.js.map +1 -0
  151. package/dist/lib/commands/utils/deployment.d.ts +34 -0
  152. package/dist/lib/commands/utils/deployment.d.ts.map +1 -0
  153. package/dist/lib/commands/utils/deployment.js +109 -0
  154. package/dist/lib/commands/utils/deployment.js.map +1 -0
  155. package/dist/lib/commands/utils/error-formatter.d.ts +19 -0
  156. package/dist/lib/commands/utils/error-formatter.d.ts.map +1 -0
  157. package/dist/lib/commands/utils/error-formatter.js +333 -0
  158. package/dist/lib/commands/utils/error-formatter.js.map +1 -0
  159. package/dist/lib/commands/utils/pools.d.ts +16 -0
  160. package/dist/lib/commands/utils/pools.d.ts.map +1 -0
  161. package/dist/lib/commands/utils/pools.js +198 -0
  162. package/dist/lib/commands/utils/pools.js.map +1 -0
  163. package/dist/lib/config.d.ts +41 -40
  164. package/dist/lib/config.d.ts.map +1 -1
  165. package/dist/lib/config.js +264 -239
  166. package/dist/lib/config.js.map +1 -1
  167. package/dist/lib/constants.d.ts +14 -0
  168. package/dist/lib/constants.d.ts.map +1 -0
  169. package/dist/lib/constants.js +19 -0
  170. package/dist/lib/constants.js.map +1 -0
  171. package/dist/lib/emulation/docker.d.ts +4 -12
  172. package/dist/lib/emulation/docker.d.ts.map +1 -1
  173. package/dist/lib/emulation/docker.js +159 -142
  174. package/dist/lib/emulation/docker.js.map +1 -1
  175. package/dist/lib/emulation/utils.d.ts +1 -1
  176. package/dist/lib/emulation/utils.d.ts.map +1 -1
  177. package/dist/lib/emulation/utils.js +55 -58
  178. package/dist/lib/emulation/utils.js.map +1 -1
  179. package/dist/lib/id.d.ts +1 -1
  180. package/dist/lib/id.d.ts.map +1 -1
  181. package/dist/lib/id.js +13 -18
  182. package/dist/lib/id.js.map +1 -1
  183. package/dist/lib/paginate.d.ts +3 -4
  184. package/dist/lib/paginate.d.ts.map +1 -1
  185. package/dist/lib/paginate.js +7 -10
  186. package/dist/lib/paginate.js.map +1 -1
  187. package/dist/lib/parser.d.ts +1 -1
  188. package/dist/lib/parser.d.ts.map +1 -1
  189. package/dist/lib/parser.js +92 -103
  190. package/dist/lib/parser.js.map +1 -1
  191. package/dist/lib/questions.d.ts +1 -1
  192. package/dist/lib/questions.d.ts.map +1 -1
  193. package/dist/lib/questions.js +381 -385
  194. package/dist/lib/questions.js.map +1 -1
  195. package/dist/lib/sdks.d.ts +1 -1
  196. package/dist/lib/sdks.d.ts.map +1 -1
  197. package/dist/lib/sdks.js +39 -30
  198. package/dist/lib/sdks.js.map +1 -1
  199. package/dist/lib/services.d.ts +13 -0
  200. package/dist/lib/services.d.ts.map +1 -0
  201. package/dist/lib/services.js +47 -0
  202. package/dist/lib/services.js.map +1 -0
  203. package/dist/lib/spinner.d.ts +1 -1
  204. package/dist/lib/spinner.d.ts.map +1 -1
  205. package/dist/lib/spinner.js +25 -27
  206. package/dist/lib/spinner.js.map +1 -1
  207. package/dist/lib/type-generation/attribute.d.ts +1 -1
  208. package/dist/lib/type-generation/attribute.d.ts.map +1 -1
  209. package/dist/lib/type-generation/attribute.js +14 -17
  210. package/dist/lib/type-generation/attribute.js.map +1 -1
  211. package/dist/lib/type-generation/languages/csharp.d.ts +1 -1
  212. package/dist/lib/type-generation/languages/csharp.d.ts.map +1 -1
  213. package/dist/lib/type-generation/languages/csharp.js +34 -34
  214. package/dist/lib/type-generation/languages/csharp.js.map +1 -1
  215. package/dist/lib/type-generation/languages/dart.d.ts +1 -1
  216. package/dist/lib/type-generation/languages/dart.d.ts.map +1 -1
  217. package/dist/lib/type-generation/languages/dart.js +57 -57
  218. package/dist/lib/type-generation/languages/dart.js.map +1 -1
  219. package/dist/lib/type-generation/languages/java.d.ts +1 -1
  220. package/dist/lib/type-generation/languages/java.d.ts.map +1 -1
  221. package/dist/lib/type-generation/languages/java.js +35 -35
  222. package/dist/lib/type-generation/languages/java.js.map +1 -1
  223. package/dist/lib/type-generation/languages/javascript.d.ts +1 -1
  224. package/dist/lib/type-generation/languages/javascript.d.ts.map +1 -1
  225. package/dist/lib/type-generation/languages/javascript.js +45 -44
  226. package/dist/lib/type-generation/languages/javascript.js.map +1 -1
  227. package/dist/lib/type-generation/languages/kotlin.d.ts +1 -1
  228. package/dist/lib/type-generation/languages/kotlin.d.ts.map +1 -1
  229. package/dist/lib/type-generation/languages/kotlin.js +35 -35
  230. package/dist/lib/type-generation/languages/kotlin.js.map +1 -1
  231. package/dist/lib/type-generation/languages/language.d.ts.map +1 -1
  232. package/dist/lib/type-generation/languages/language.js +32 -37
  233. package/dist/lib/type-generation/languages/language.js.map +1 -1
  234. package/dist/lib/type-generation/languages/php.d.ts +1 -1
  235. package/dist/lib/type-generation/languages/php.d.ts.map +1 -1
  236. package/dist/lib/type-generation/languages/php.js +34 -34
  237. package/dist/lib/type-generation/languages/php.js.map +1 -1
  238. package/dist/lib/type-generation/languages/swift.d.ts +1 -1
  239. package/dist/lib/type-generation/languages/swift.d.ts.map +1 -1
  240. package/dist/lib/type-generation/languages/swift.js +35 -35
  241. package/dist/lib/type-generation/languages/swift.js.map +1 -1
  242. package/dist/lib/type-generation/languages/typescript.d.ts +1 -1
  243. package/dist/lib/type-generation/languages/typescript.d.ts.map +1 -1
  244. package/dist/lib/type-generation/languages/typescript.js +49 -46
  245. package/dist/lib/type-generation/languages/typescript.js.map +1 -1
  246. package/dist/lib/types.d.ts +38 -108
  247. package/dist/lib/types.d.ts.map +1 -1
  248. package/dist/lib/types.js +1 -2
  249. package/dist/lib/utils.d.ts +3 -0
  250. package/dist/lib/utils.d.ts.map +1 -1
  251. package/dist/lib/utils.js +142 -98
  252. package/dist/lib/utils.js.map +1 -1
  253. package/dist/lib/validations.d.ts.map +1 -1
  254. package/dist/lib/validations.js +2 -6
  255. package/dist/lib/validations.js.map +1 -1
  256. package/dist/package.json +68 -0
  257. package/index.ts +25 -149
  258. package/install.ps1 +2 -2
  259. package/install.sh +1 -1
  260. package/lib/client.ts +261 -220
  261. package/lib/commands/config.ts +494 -0
  262. package/lib/commands/db.ts +324 -0
  263. package/lib/commands/errors.ts +93 -0
  264. package/lib/commands/generic.ts +371 -269
  265. package/lib/commands/init.ts +631 -519
  266. package/lib/commands/pull.ts +827 -453
  267. package/lib/commands/push.ts +2191 -2349
  268. package/lib/commands/run.ts +382 -302
  269. package/lib/commands/schema.ts +122 -0
  270. package/lib/commands/services/account.ts +647 -0
  271. package/lib/commands/services/console.ts +52 -0
  272. package/lib/commands/services/databases.ts +1163 -0
  273. package/lib/commands/services/functions.ts +536 -0
  274. package/lib/commands/services/graphql.ts +50 -0
  275. package/lib/commands/services/health.ts +260 -0
  276. package/lib/commands/services/locale.ts +102 -0
  277. package/lib/commands/services/messaging.ts +1052 -0
  278. package/lib/commands/services/migrations.ts +249 -0
  279. package/lib/commands/services/project.ts +112 -0
  280. package/lib/commands/services/projects.ts +785 -0
  281. package/lib/commands/services/proxy.ts +135 -0
  282. package/lib/commands/services/sites.ts +505 -0
  283. package/lib/commands/services/storage.ts +338 -0
  284. package/lib/commands/services/tables-db.ts +1150 -0
  285. package/lib/commands/services/teams.ts +232 -0
  286. package/lib/commands/services/tokens.ts +94 -0
  287. package/lib/commands/services/users.ts +616 -0
  288. package/lib/commands/services/vcs.ts +165 -0
  289. package/lib/commands/types.ts +145 -118
  290. package/lib/commands/update.ts +189 -159
  291. package/lib/commands/utils/attributes.ts +719 -0
  292. package/lib/commands/utils/change-approval.ts +186 -0
  293. package/lib/commands/utils/database-sync.ts +180 -0
  294. package/lib/commands/utils/deployment.ts +184 -0
  295. package/lib/commands/utils/error-formatter.ts +417 -0
  296. package/lib/commands/utils/pools.ts +355 -0
  297. package/lib/config.ts +766 -687
  298. package/lib/constants.ts +22 -0
  299. package/lib/emulation/docker.ts +277 -216
  300. package/lib/emulation/utils.ts +188 -174
  301. package/lib/id.ts +23 -23
  302. package/lib/paginate.ts +69 -55
  303. package/lib/parser.ts +220 -189
  304. package/lib/questions.ts +1024 -948
  305. package/lib/sdks.ts +84 -51
  306. package/lib/services.ts +72 -0
  307. package/lib/spinner.ts +112 -99
  308. package/lib/type-generation/attribute.ts +15 -14
  309. package/lib/type-generation/languages/csharp.ts +71 -60
  310. package/lib/type-generation/languages/dart.ts +106 -93
  311. package/lib/type-generation/languages/java.ts +69 -58
  312. package/lib/type-generation/languages/javascript.ts +84 -73
  313. package/lib/type-generation/languages/kotlin.ts +71 -60
  314. package/lib/type-generation/languages/language.ts +103 -95
  315. package/lib/type-generation/languages/php.ts +67 -56
  316. package/lib/type-generation/languages/swift.ts +71 -60
  317. package/lib/type-generation/languages/typescript.ts +93 -76
  318. package/lib/types.ts +50 -125
  319. package/lib/utils.ts +304 -233
  320. package/lib/validations.ts +17 -14
  321. package/package.json +31 -22
  322. package/scoop/appwrite.config.json +3 -3
  323. package/tsconfig.json +7 -13
  324. package/.github/workflows/autoclose.yml +0 -11
  325. package/.github/workflows/npm-publish.yml +0 -49
  326. package/dist/lib/commands/account.d.ts +0 -379
  327. package/dist/lib/commands/account.d.ts.map +0 -1
  328. package/dist/lib/commands/account.js +0 -1228
  329. package/dist/lib/commands/account.js.map +0 -1
  330. package/dist/lib/commands/console.d.ts +0 -20
  331. package/dist/lib/commands/console.d.ts.map +0 -1
  332. package/dist/lib/commands/console.js +0 -78
  333. package/dist/lib/commands/console.js.map +0 -1
  334. package/dist/lib/commands/databases.d.ts +0 -732
  335. package/dist/lib/commands/databases.d.ts.map +0 -1
  336. package/dist/lib/commands/databases.js +0 -2196
  337. package/dist/lib/commands/databases.js.map +0 -1
  338. package/dist/lib/commands/functions.d.ts +0 -310
  339. package/dist/lib/commands/functions.d.ts.map +0 -1
  340. package/dist/lib/commands/functions.js +0 -1100
  341. package/dist/lib/commands/functions.js.map +0 -1
  342. package/dist/lib/commands/graphql.d.ts +0 -19
  343. package/dist/lib/commands/graphql.d.ts.map +0 -1
  344. package/dist/lib/commands/graphql.js +0 -77
  345. package/dist/lib/commands/graphql.js.map +0 -1
  346. package/dist/lib/commands/health.d.ts +0 -153
  347. package/dist/lib/commands/health.d.ts.map +0 -1
  348. package/dist/lib/commands/health.js +0 -464
  349. package/dist/lib/commands/health.js.map +0 -1
  350. package/dist/lib/commands/locale.d.ts +0 -53
  351. package/dist/lib/commands/locale.d.ts.map +0 -1
  352. package/dist/lib/commands/locale.js +0 -165
  353. package/dist/lib/commands/locale.js.map +0 -1
  354. package/dist/lib/commands/messaging.d.ts +0 -588
  355. package/dist/lib/commands/messaging.d.ts.map +0 -1
  356. package/dist/lib/commands/messaging.js +0 -2042
  357. package/dist/lib/commands/messaging.js.map +0 -1
  358. package/dist/lib/commands/migrations.d.ts +0 -150
  359. package/dist/lib/commands/migrations.d.ts.map +0 -1
  360. package/dist/lib/commands/migrations.js +0 -524
  361. package/dist/lib/commands/migrations.js.map +0 -1
  362. package/dist/lib/commands/organizations.d.ts +0 -11
  363. package/dist/lib/commands/organizations.d.ts.map +0 -1
  364. package/dist/lib/commands/organizations.js +0 -31
  365. package/dist/lib/commands/organizations.js.map +0 -1
  366. package/dist/lib/commands/project.d.ts +0 -53
  367. package/dist/lib/commands/project.d.ts.map +0 -1
  368. package/dist/lib/commands/project.js +0 -176
  369. package/dist/lib/commands/project.js.map +0 -1
  370. package/dist/lib/commands/projects.d.ts +0 -516
  371. package/dist/lib/commands/projects.d.ts.map +0 -1
  372. package/dist/lib/commands/projects.js +0 -1590
  373. package/dist/lib/commands/projects.js.map +0 -1
  374. package/dist/lib/commands/proxy.d.ts +0 -71
  375. package/dist/lib/commands/proxy.d.ts.map +0 -1
  376. package/dist/lib/commands/proxy.js +0 -240
  377. package/dist/lib/commands/proxy.js.map +0 -1
  378. package/dist/lib/commands/sites.d.ts +0 -296
  379. package/dist/lib/commands/sites.d.ts.map +0 -1
  380. package/dist/lib/commands/sites.js +0 -1046
  381. package/dist/lib/commands/sites.js.map +0 -1
  382. package/dist/lib/commands/storage.d.ts +0 -170
  383. package/dist/lib/commands/storage.d.ts.map +0 -1
  384. package/dist/lib/commands/storage.js +0 -651
  385. package/dist/lib/commands/storage.js.map +0 -1
  386. package/dist/lib/commands/tables-db.d.ts +0 -728
  387. package/dist/lib/commands/tables-db.d.ts.map +0 -1
  388. package/dist/lib/commands/tables-db.js +0 -2198
  389. package/dist/lib/commands/tables-db.js.map +0 -1
  390. package/dist/lib/commands/teams.d.ts +0 -129
  391. package/dist/lib/commands/teams.d.ts.map +0 -1
  392. package/dist/lib/commands/teams.js +0 -403
  393. package/dist/lib/commands/teams.js.map +0 -1
  394. package/dist/lib/commands/tokens.d.ts +0 -48
  395. package/dist/lib/commands/tokens.d.ts.map +0 -1
  396. package/dist/lib/commands/tokens.js +0 -156
  397. package/dist/lib/commands/tokens.js.map +0 -1
  398. package/dist/lib/commands/users.d.ts +0 -382
  399. package/dist/lib/commands/users.d.ts.map +0 -1
  400. package/dist/lib/commands/users.js +0 -1195
  401. package/dist/lib/commands/users.js.map +0 -1
  402. package/dist/lib/commands/vcs.d.ts +0 -92
  403. package/dist/lib/commands/vcs.d.ts.map +0 -1
  404. package/dist/lib/commands/vcs.js +0 -276
  405. package/dist/lib/commands/vcs.js.map +0 -1
  406. package/dist/lib/exception.d.ts +0 -8
  407. package/dist/lib/exception.d.ts.map +0 -1
  408. package/dist/lib/exception.js +0 -16
  409. package/dist/lib/exception.js.map +0 -1
  410. package/lib/commands/account.ts +0 -1867
  411. package/lib/commands/console.ts +0 -112
  412. package/lib/commands/databases.ts +0 -3272
  413. package/lib/commands/functions.ts +0 -1587
  414. package/lib/commands/graphql.ts +0 -110
  415. package/lib/commands/health.ts +0 -753
  416. package/lib/commands/locale.ts +0 -270
  417. package/lib/commands/messaging.ts +0 -2878
  418. package/lib/commands/migrations.ts +0 -754
  419. package/lib/commands/organizations.ts +0 -46
  420. package/lib/commands/project.ts +0 -266
  421. package/lib/commands/projects.ts +0 -2370
  422. package/lib/commands/proxy.ts +0 -357
  423. package/lib/commands/sites.ts +0 -1514
  424. package/lib/commands/storage.ts +0 -919
  425. package/lib/commands/tables-db.ts +0 -3260
  426. package/lib/commands/teams.ts +0 -609
  427. package/lib/commands/tokens.ts +0 -232
  428. package/lib/commands/users.ts +0 -1804
  429. package/lib/commands/vcs.ts +0 -428
  430. package/lib/exception.ts +0 -20
@@ -1,86 +1,143 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.KeysTable = exports.KeysCollection = exports.KeysTeams = exports.KeysStorage = exports.KeysTopics = exports.KeysFunction = exports.KeysSite = exports.KeysAttributes = exports.globalConfig = exports.localConfig = void 0;
4
- exports.whitelistKeys = whitelistKeys;
5
- const os = require("os");
6
- const fs = require("fs");
7
- const _path = require("path");
8
- const process = require("process");
9
- const JSONbig = require("json-bigint");
1
+ import os from "os";
2
+ import fs from "fs";
3
+ import _path from "path";
4
+ import process from "process";
5
+ import JSONbig from "json-bigint";
6
+ import { createSettingsObject } from "./utils.js";
7
+ import { SDK_TITLE_LOWER } from "./constants.js";
10
8
  const JSONBigInt = JSONbig({ storeAsString: false });
11
- const KeysVars = new Set(['key', 'value']);
12
- const KeysSite = new Set(['path', '$id', 'name', 'enabled', 'logging', 'timeout', 'framework', 'buildRuntime', 'adapter', 'installCommand', 'buildCommand', 'outputDirectory', 'fallbackFile', 'specification', 'vars']);
13
- exports.KeysSite = KeysSite;
14
- const KeysFunction = new Set(['path', '$id', 'execute', 'name', 'enabled', 'logging', 'runtime', 'specification', 'scopes', 'events', 'schedule', 'timeout', 'entrypoint', 'commands', 'vars']);
15
- exports.KeysFunction = KeysFunction;
16
- const KeysDatabase = new Set(['$id', 'name', 'enabled']);
17
- const KeysCollection = new Set(['$id', '$permissions', 'databaseId', 'name', 'enabled', 'documentSecurity', 'attributes', 'indexes']);
18
- exports.KeysCollection = KeysCollection;
19
- const KeysTable = new Set(['$id', '$permissions', 'databaseId', 'name', 'enabled', 'rowSecurity', 'columns', 'indexes']);
20
- exports.KeysTable = KeysTable;
21
- const KeysStorage = new Set(['$id', '$permissions', 'fileSecurity', 'name', 'enabled', 'maximumFileSize', 'allowedFileExtensions', 'compression', 'encryption', 'antivirus']);
22
- exports.KeysStorage = KeysStorage;
23
- const KeysTopics = new Set(['$id', 'name', 'subscribe']);
24
- exports.KeysTopics = KeysTopics;
25
- const KeysTeams = new Set(['$id', 'name']);
26
- exports.KeysTeams = KeysTeams;
9
+ const KeysVars = new Set(["key", "value"]);
10
+ const KeysSite = new Set([
11
+ "path",
12
+ "$id",
13
+ "name",
14
+ "enabled",
15
+ "logging",
16
+ "timeout",
17
+ "framework",
18
+ "buildRuntime",
19
+ "adapter",
20
+ "installCommand",
21
+ "buildCommand",
22
+ "outputDirectory",
23
+ "fallbackFile",
24
+ "specification",
25
+ "vars",
26
+ ]);
27
+ const KeysFunction = new Set([
28
+ "path",
29
+ "$id",
30
+ "execute",
31
+ "name",
32
+ "enabled",
33
+ "logging",
34
+ "runtime",
35
+ "specification",
36
+ "scopes",
37
+ "events",
38
+ "schedule",
39
+ "timeout",
40
+ "entrypoint",
41
+ "commands",
42
+ "vars",
43
+ ]);
44
+ const KeysDatabase = new Set(["$id", "name", "enabled"]);
45
+ const KeysCollection = new Set([
46
+ "$id",
47
+ "$permissions",
48
+ "databaseId",
49
+ "name",
50
+ "enabled",
51
+ "documentSecurity",
52
+ "attributes",
53
+ "indexes",
54
+ ]);
55
+ const KeysTable = new Set([
56
+ "$id",
57
+ "$permissions",
58
+ "databaseId",
59
+ "name",
60
+ "enabled",
61
+ "rowSecurity",
62
+ "columns",
63
+ "indexes",
64
+ ]);
65
+ const KeysStorage = new Set([
66
+ "$id",
67
+ "$permissions",
68
+ "fileSecurity",
69
+ "name",
70
+ "enabled",
71
+ "maximumFileSize",
72
+ "allowedFileExtensions",
73
+ "compression",
74
+ "encryption",
75
+ "antivirus",
76
+ ]);
77
+ const KeysTopics = new Set(["$id", "name", "subscribe"]);
78
+ const KeysTeams = new Set(["$id", "name"]);
27
79
  const KeysAttributes = new Set([
28
- 'key',
29
- 'type',
30
- 'required',
31
- 'array',
32
- 'size',
33
- 'default',
80
+ "key",
81
+ "type",
82
+ "required",
83
+ "array",
84
+ "size",
85
+ "default",
34
86
  // integer and float
35
- 'min',
36
- 'max',
87
+ "min",
88
+ "max",
37
89
  // email, enum, URL, IP, and datetime
38
- 'format',
90
+ "format",
39
91
  // enum
40
- 'elements',
92
+ "elements",
41
93
  // relationship
42
- 'relatedCollection',
43
- 'relationType',
44
- 'twoWay',
45
- 'twoWayKey',
46
- 'onDelete',
47
- 'side',
94
+ "relatedCollection",
95
+ "relationType",
96
+ "twoWay",
97
+ "twoWayKey",
98
+ "onDelete",
99
+ "side",
48
100
  // Indexes
49
- 'attributes',
50
- 'orders',
101
+ "attributes",
102
+ "orders",
51
103
  // Strings
52
- 'encrypt',
104
+ "encrypt",
53
105
  ]);
54
- exports.KeysAttributes = KeysAttributes;
55
106
  const KeysColumns = new Set([
56
- 'key',
57
- 'type',
58
- 'required',
59
- 'array',
60
- 'size',
61
- 'default',
107
+ "key",
108
+ "type",
109
+ "required",
110
+ "array",
111
+ "size",
112
+ "default",
62
113
  // integer and float
63
- 'min',
64
- 'max',
114
+ "min",
115
+ "max",
65
116
  // email, enum, URL, IP, and datetime
66
- 'format',
117
+ "format",
67
118
  // enum
68
- 'elements',
119
+ "elements",
69
120
  // relationship
70
- 'relatedTable',
71
- 'relationType',
72
- 'twoWay',
73
- 'twoWayKey',
74
- 'onDelete',
75
- 'side',
121
+ "relatedTable",
122
+ "relationType",
123
+ "twoWay",
124
+ "twoWayKey",
125
+ "onDelete",
126
+ "side",
76
127
  // Indexes
77
- 'columns',
78
- 'orders',
128
+ "columns",
129
+ "orders",
79
130
  // Strings
80
- 'encrypt',
131
+ "encrypt",
132
+ ]);
133
+ const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
134
+ const KeyIndexesColumns = new Set([
135
+ "key",
136
+ "type",
137
+ "status",
138
+ "columns",
139
+ "orders",
81
140
  ]);
82
- const KeyIndexes = new Set(['key', 'type', 'status', 'attributes', 'orders']);
83
- const KeyIndexesColumns = new Set(['key', 'type', 'status', 'columns', 'orders']);
84
141
  function whitelistKeys(value, keys, nestedKeys = {}) {
85
142
  if (Array.isArray(value)) {
86
143
  const newValue = [];
@@ -103,6 +160,8 @@ function whitelistKeys(value, keys, nestedKeys = {}) {
103
160
  return newValue;
104
161
  }
105
162
  class Config {
163
+ path;
164
+ data;
106
165
  constructor(path) {
107
166
  this.path = path;
108
167
  this.data = {};
@@ -122,7 +181,9 @@ class Config {
122
181
  if (!fs.existsSync(dir)) {
123
182
  fs.mkdirSync(dir, { recursive: true });
124
183
  }
125
- fs.writeFileSync(this.path, JSONBigInt.stringify(this.data, null, 4), { mode: 0o600 });
184
+ fs.writeFileSync(this.path, JSONBigInt.stringify(this.data, null, 4), {
185
+ mode: 0o600,
186
+ });
126
187
  }
127
188
  get(key) {
128
189
  return this.data[key];
@@ -163,7 +224,7 @@ class Config {
163
224
  }
164
225
  const entities = this.get(entityType);
165
226
  for (let i = 0; i < entities.length; i++) {
166
- if (entities[i]['$id'] == $id) {
227
+ if (entities[i]["$id"] == $id) {
167
228
  return entities[i];
168
229
  }
169
230
  }
@@ -176,7 +237,7 @@ class Config {
176
237
  }
177
238
  const entities = this.get(entityType);
178
239
  for (let i = 0; i < entities.length; i++) {
179
- if (entities[i]['$id'] == props['$id']) {
240
+ if (entities[i]["$id"] == props["$id"]) {
180
241
  entities[i] = props;
181
242
  this.set(entityType, entities);
182
243
  return;
@@ -187,13 +248,15 @@ class Config {
187
248
  }
188
249
  }
189
250
  class Local extends Config {
251
+ static CONFIG_FILE_PATH = `${SDK_TITLE_LOWER}.config.json`;
252
+ static CONFIG_FILE_PATH_LEGACY = `${SDK_TITLE_LOWER}.json`;
253
+ configDirectoryPath = "";
190
254
  constructor(path = Local.CONFIG_FILE_PATH, legacyPath = Local.CONFIG_FILE_PATH_LEGACY) {
191
255
  let absolutePath = Local.findConfigFile(path) || Local.findConfigFile(legacyPath);
192
256
  if (!absolutePath) {
193
257
  absolutePath = `${process.cwd()}/${path}`;
194
258
  }
195
259
  super(absolutePath);
196
- this.configDirectoryPath = '';
197
260
  this.configDirectoryPath = _path.dirname(absolutePath);
198
261
  }
199
262
  static findConfigFile(filename) {
@@ -215,24 +278,24 @@ class Local extends Config {
215
278
  return _path.dirname(this.path);
216
279
  }
217
280
  getEndpoint() {
218
- return this.get('endpoint') || '';
281
+ return this.get("endpoint") || "";
219
282
  }
220
283
  setEndpoint(endpoint) {
221
- this.set('endpoint', endpoint);
284
+ this.set("endpoint", endpoint);
222
285
  }
223
286
  getSites() {
224
- if (!this.has('sites')) {
287
+ if (!this.has("sites")) {
225
288
  return [];
226
289
  }
227
- return this.get('sites');
290
+ return this.get("sites") ?? [];
228
291
  }
229
292
  getSite($id) {
230
- if (!this.has('sites')) {
293
+ if (!this.has("sites")) {
231
294
  return {};
232
295
  }
233
- const sites = this.get('sites');
296
+ const sites = this.get("sites") ?? [];
234
297
  for (let i = 0; i < sites.length; i++) {
235
- if (sites[i]['$id'] == $id) {
298
+ if (sites[i]["$id"] == $id) {
236
299
  return sites[i];
237
300
  }
238
301
  }
@@ -242,36 +305,36 @@ class Local extends Config {
242
305
  props = whitelistKeys(props, KeysSite, {
243
306
  vars: KeysVars,
244
307
  });
245
- if (!this.has('sites')) {
246
- this.set('sites', []);
308
+ if (!this.has("sites")) {
309
+ this.set("sites", []);
247
310
  }
248
- const sites = this.get('sites');
311
+ const sites = this.get("sites") ?? [];
249
312
  for (let i = 0; i < sites.length; i++) {
250
- if (sites[i]['$id'] == props['$id']) {
313
+ if (sites[i]["$id"] == props["$id"]) {
251
314
  sites[i] = {
252
315
  ...sites[i],
253
316
  ...props,
254
317
  };
255
- this.set('sites', sites);
318
+ this.set("sites", sites);
256
319
  return;
257
320
  }
258
321
  }
259
322
  sites.push(props);
260
- this.set('sites', sites);
323
+ this.set("sites", sites);
261
324
  }
262
325
  getFunctions() {
263
- if (!this.has('functions')) {
326
+ if (!this.has("functions")) {
264
327
  return [];
265
328
  }
266
- return this.get('functions');
329
+ return this.get("functions") ?? [];
267
330
  }
268
331
  getFunction($id) {
269
- if (!this.has('functions')) {
332
+ if (!this.has("functions")) {
270
333
  return {};
271
334
  }
272
- const functions = this.get('functions');
335
+ const functions = this.get("functions") ?? [];
273
336
  for (let i = 0; i < functions.length; i++) {
274
- if (functions[i]['$id'] == $id) {
337
+ if (functions[i]["$id"] == $id) {
275
338
  return functions[i];
276
339
  }
277
340
  }
@@ -281,36 +344,36 @@ class Local extends Config {
281
344
  props = whitelistKeys(props, KeysFunction, {
282
345
  vars: KeysVars,
283
346
  });
284
- if (!this.has('functions')) {
285
- this.set('functions', []);
347
+ if (!this.has("functions")) {
348
+ this.set("functions", []);
286
349
  }
287
- const functions = this.get('functions');
350
+ const functions = this.get("functions") ?? [];
288
351
  for (let i = 0; i < functions.length; i++) {
289
- if (functions[i]['$id'] == props['$id']) {
352
+ if (functions[i]["$id"] == props["$id"]) {
290
353
  functions[i] = {
291
354
  ...functions[i],
292
355
  ...props,
293
356
  };
294
- this.set('functions', functions);
357
+ this.set("functions", functions);
295
358
  return;
296
359
  }
297
360
  }
298
361
  functions.push(props);
299
- this.set('functions', functions);
362
+ this.set("functions", functions);
300
363
  }
301
364
  getCollections() {
302
- if (!this.has('collections')) {
365
+ if (!this.has("collections")) {
303
366
  return [];
304
367
  }
305
- return this.get('collections');
368
+ return this.get("collections") ?? [];
306
369
  }
307
370
  getCollection($id) {
308
- if (!this.has('collections')) {
371
+ if (!this.has("collections")) {
309
372
  return {};
310
373
  }
311
- const collections = this.get('collections');
374
+ const collections = this.get("collections") ?? [];
312
375
  for (let i = 0; i < collections.length; i++) {
313
- if (collections[i]['$id'] == $id) {
376
+ if (collections[i]["$id"] == $id) {
314
377
  return collections[i];
315
378
  }
316
379
  }
@@ -321,33 +384,34 @@ class Local extends Config {
321
384
  attributes: KeysAttributes,
322
385
  indexes: KeyIndexes,
323
386
  });
324
- if (!this.has('collections')) {
325
- this.set('collections', []);
387
+ if (!this.has("collections")) {
388
+ this.set("collections", []);
326
389
  }
327
- const collections = this.get('collections');
390
+ const collections = this.get("collections") ?? [];
328
391
  for (let i = 0; i < collections.length; i++) {
329
- if (collections[i]['$id'] == props['$id'] && collections[i]['databaseId'] == props['databaseId']) {
392
+ if (collections[i]["$id"] == props["$id"] &&
393
+ collections[i]["databaseId"] == props["databaseId"]) {
330
394
  collections[i] = props;
331
- this.set('collections', collections);
395
+ this.set("collections", collections);
332
396
  return;
333
397
  }
334
398
  }
335
399
  collections.push(props);
336
- this.set('collections', collections);
400
+ this.set("collections", collections);
337
401
  }
338
402
  getTables() {
339
- if (!this.has('tables')) {
403
+ if (!this.has("tables")) {
340
404
  return [];
341
405
  }
342
- return this.get('tables');
406
+ return this.get("tables") ?? [];
343
407
  }
344
408
  getTable($id) {
345
- if (!this.has('tables')) {
409
+ if (!this.has("tables")) {
346
410
  return {};
347
411
  }
348
- const tables = this.get('tables');
412
+ const tables = this.get("tables") ?? [];
349
413
  for (let i = 0; i < tables.length; i++) {
350
- if (tables[i]['$id'] == $id) {
414
+ if (tables[i]["$id"] == $id) {
351
415
  return tables[i];
352
416
  }
353
417
  }
@@ -358,33 +422,34 @@ class Local extends Config {
358
422
  columns: KeysColumns,
359
423
  indexes: KeyIndexesColumns,
360
424
  });
361
- if (!this.has('tables')) {
362
- this.set('tables', []);
425
+ if (!this.has("tables")) {
426
+ this.set("tables", []);
363
427
  }
364
- const tables = this.get('tables');
428
+ const tables = this.get("tables") ?? [];
365
429
  for (let i = 0; i < tables.length; i++) {
366
- if (tables[i]['$id'] == props['$id'] && tables[i]['databaseId'] == props['databaseId']) {
430
+ if (tables[i]["$id"] == props["$id"] &&
431
+ tables[i]["databaseId"] == props["databaseId"]) {
367
432
  tables[i] = props;
368
- this.set('tables', tables);
433
+ this.set("tables", tables);
369
434
  return;
370
435
  }
371
436
  }
372
437
  tables.push(props);
373
- this.set('tables', tables);
438
+ this.set("tables", tables);
374
439
  }
375
440
  getBuckets() {
376
- if (!this.has('buckets')) {
441
+ if (!this.has("buckets")) {
377
442
  return [];
378
443
  }
379
- return this.get('buckets');
444
+ return this.get("buckets") ?? [];
380
445
  }
381
446
  getBucket($id) {
382
- if (!this.has('buckets')) {
447
+ if (!this.has("buckets")) {
383
448
  return {};
384
449
  }
385
- const buckets = this.get('buckets');
450
+ const buckets = this.get("buckets") ?? [];
386
451
  for (let i = 0; i < buckets.length; i++) {
387
- if (buckets[i]['$id'] == $id) {
452
+ if (buckets[i]["$id"] == $id) {
388
453
  return buckets[i];
389
454
  }
390
455
  }
@@ -392,85 +457,85 @@ class Local extends Config {
392
457
  }
393
458
  addBucket(props) {
394
459
  props = whitelistKeys(props, KeysStorage);
395
- if (!this.has('buckets')) {
396
- this.set('buckets', []);
460
+ if (!this.has("buckets")) {
461
+ this.set("buckets", []);
397
462
  }
398
- const buckets = this.get('buckets');
463
+ const buckets = this.get("buckets") ?? [];
399
464
  for (let i = 0; i < buckets.length; i++) {
400
- if (buckets[i]['$id'] == props['$id']) {
465
+ if (buckets[i]["$id"] == props["$id"]) {
401
466
  buckets[i] = props;
402
- this.set('buckets', buckets);
467
+ this.set("buckets", buckets);
403
468
  return;
404
469
  }
405
470
  }
406
471
  buckets.push(props);
407
- this.set('buckets', buckets);
472
+ this.set("buckets", buckets);
408
473
  }
409
474
  getMessagingTopics() {
410
- if (!this.has('topics')) {
475
+ if (!this.has("topics")) {
411
476
  return [];
412
477
  }
413
- return this.get('topics');
478
+ return this.get("topics") ?? [];
414
479
  }
415
480
  getMessagingTopic($id) {
416
- if (!this.has('topics')) {
481
+ if (!this.has("topics")) {
417
482
  return {};
418
483
  }
419
- const topic = this.get('topics');
420
- for (let i = 0; i < topic.length; i++) {
421
- if (topic[i]['$id'] == $id) {
422
- return topic[i];
484
+ const topics = this.get("topics") ?? [];
485
+ for (let i = 0; i < topics.length; i++) {
486
+ if (topics[i]["$id"] == $id) {
487
+ return topics[i];
423
488
  }
424
489
  }
425
490
  return {};
426
491
  }
427
492
  addMessagingTopic(props) {
428
493
  props = whitelistKeys(props, KeysTopics);
429
- if (!this.has('topics')) {
430
- this.set('topics', []);
494
+ if (!this.has("topics")) {
495
+ this.set("topics", []);
431
496
  }
432
- const topics = this.get('topics');
497
+ const topics = this.get("topics") ?? [];
433
498
  for (let i = 0; i < topics.length; i++) {
434
- if (topics[i]['$id'] === props['$id']) {
499
+ if (topics[i]["$id"] === props["$id"]) {
435
500
  topics[i] = props;
436
- this.set('topics', topics);
501
+ this.set("topics", topics);
437
502
  return;
438
503
  }
439
504
  }
440
505
  topics.push(props);
441
- this.set('topics', topics);
506
+ this.set("topics", topics);
442
507
  }
443
508
  getTablesDBs() {
444
- return this._getDBEntities('tablesDB');
509
+ return this._getDBEntities("tablesDB");
445
510
  }
446
511
  getTablesDB($id) {
447
- return this._getDBEntity('tablesDB', $id);
512
+ return this._getDBEntity("tablesDB", $id);
448
513
  }
449
514
  addTablesDB(props) {
450
- this._addDBEntity('tablesDB', props, KeysDatabase);
515
+ this._addDBEntity("tablesDB", props, KeysDatabase);
451
516
  }
452
517
  getDatabases() {
453
- return this._getDBEntities('databases');
518
+ return this._getDBEntities("databases");
454
519
  }
455
520
  getDatabase($id) {
456
- return this._getDBEntity('databases', $id);
521
+ return this._getDBEntity("databases", $id);
457
522
  }
458
523
  addDatabase(props) {
459
- this._addDBEntity('databases', props, KeysDatabase);
524
+ this._addDBEntity("databases", props, KeysDatabase);
460
525
  }
461
526
  getTeams() {
462
- if (!this.has('teams')) {
527
+ if (!this.has("teams")) {
463
528
  return [];
464
529
  }
465
- return this.get('teams');
530
+ return this.get("teams") ?? [];
466
531
  }
467
532
  getTeam($id) {
468
- if (!this.has('teams')) {
533
+ if (!this.has("teams")) {
469
534
  return {};
470
535
  }
471
- const teams = this.get('teams');
536
+ const teams = this.get("teams") ?? [];
472
537
  for (let i = 0; i < teams.length; i++) {
473
- if (teams[i]['$id'] == $id) {
538
+ if (teams[i]["$id"] == $id) {
474
539
  return teams[i];
475
540
  }
476
541
  }
@@ -478,90 +543,72 @@ class Local extends Config {
478
543
  }
479
544
  addTeam(props) {
480
545
  props = whitelistKeys(props, KeysTeams);
481
- if (!this.has('teams')) {
482
- this.set('teams', []);
546
+ if (!this.has("teams")) {
547
+ this.set("teams", []);
483
548
  }
484
- const teams = this.get('teams');
549
+ const teams = this.get("teams") ?? [];
485
550
  for (let i = 0; i < teams.length; i++) {
486
- if (teams[i]['$id'] == props['$id']) {
551
+ if (teams[i]["$id"] == props["$id"]) {
487
552
  teams[i] = props;
488
- this.set('teams', teams);
553
+ this.set("teams", teams);
489
554
  return;
490
555
  }
491
556
  }
492
557
  teams.push(props);
493
- this.set('teams', teams);
558
+ this.set("teams", teams);
494
559
  }
495
560
  getProject() {
496
- if (!this.has('projectId')) {
561
+ if (!this.has("projectId")) {
497
562
  return {};
498
563
  }
499
564
  return {
500
- projectId: this.get('projectId'),
501
- projectName: this.get('projectName'),
502
- projectSettings: this.get('settings'),
565
+ projectId: this.get("projectId"),
566
+ projectName: this.get("projectName"),
567
+ projectSettings: this.get("settings"),
503
568
  };
504
569
  }
505
- setProject(projectId, projectName = '', projectSettings = undefined) {
506
- this.set('projectId', projectId);
507
- if (projectName !== '') {
508
- this.set('projectName', projectName);
570
+ setProject(projectId, projectName = "", project) {
571
+ this.set("projectId", projectId);
572
+ if (projectName !== "") {
573
+ this.set("projectName", projectName);
509
574
  }
510
- if (projectSettings === undefined) {
575
+ if (project === undefined) {
511
576
  return;
512
577
  }
513
- this.set('settings', this.createSettingsObject(projectSettings));
514
- }
515
- createSettingsObject(projectSettings) {
516
- return {
517
- services: {
518
- account: projectSettings.serviceStatusForAccount,
519
- avatars: projectSettings.serviceStatusForAvatars,
520
- databases: projectSettings.serviceStatusForDatabases,
521
- locale: projectSettings.serviceStatusForLocale,
522
- health: projectSettings.serviceStatusForHealth,
523
- storage: projectSettings.serviceStatusForStorage,
524
- teams: projectSettings.serviceStatusForTeams,
525
- users: projectSettings.serviceStatusForUsers,
526
- sites: projectSettings.serviceStatusForSites,
527
- functions: projectSettings.serviceStatusForFunctions,
528
- graphql: projectSettings.serviceStatusForGraphql,
529
- messaging: projectSettings.serviceStatusForMessaging,
530
- },
531
- auth: {
532
- methods: {
533
- jwt: projectSettings.authJWT,
534
- phone: projectSettings.authPhone,
535
- invites: projectSettings.authInvites,
536
- anonymous: projectSettings.authAnonymous,
537
- 'email-otp': projectSettings.authEmailOtp,
538
- 'magic-url': projectSettings.authUsersAuthMagicURL,
539
- 'email-password': projectSettings.authEmailPassword,
540
- },
541
- security: {
542
- duration: projectSettings.authDuration,
543
- limit: projectSettings.authLimit,
544
- sessionsLimit: projectSettings.authSessionsLimit,
545
- passwordHistory: projectSettings.authPasswordHistory,
546
- passwordDictionary: projectSettings.authPasswordDictionary,
547
- personalDataCheck: projectSettings.authPersonalDataCheck,
548
- sessionAlerts: projectSettings.authSessionAlerts,
549
- mockNumbers: projectSettings.authMockNumbers,
550
- },
551
- },
552
- };
578
+ this.set("settings", createSettingsObject(project));
553
579
  }
554
580
  }
555
- Local.CONFIG_FILE_PATH = 'appwrite.config.json';
556
- Local.CONFIG_FILE_PATH_LEGACY = 'appwrite.json';
557
581
  class Global extends Config {
582
+ static CONFIG_FILE_PATH = `.${SDK_TITLE_LOWER}/prefs.json`;
583
+ static PREFERENCE_CURRENT = "current";
584
+ static PREFERENCE_ENDPOINT = "endpoint";
585
+ static PREFERENCE_EMAIL = "email";
586
+ static PREFERENCE_SELF_SIGNED = "selfSigned";
587
+ static PREFERENCE_COOKIE = "cookie";
588
+ static PREFERENCE_PROJECT = "project";
589
+ static PREFERENCE_KEY = "key";
590
+ static PREFERENCE_LOCALE = "locale";
591
+ static PREFERENCE_MODE = "mode";
592
+ static IGNORE_ATTRIBUTES = [
593
+ Global.PREFERENCE_CURRENT,
594
+ Global.PREFERENCE_SELF_SIGNED,
595
+ Global.PREFERENCE_ENDPOINT,
596
+ Global.PREFERENCE_COOKIE,
597
+ Global.PREFERENCE_PROJECT,
598
+ Global.PREFERENCE_KEY,
599
+ Global.PREFERENCE_LOCALE,
600
+ Global.PREFERENCE_MODE,
601
+ ];
602
+ static MODE_ADMIN = "admin";
603
+ static MODE_DEFAULT = "default";
604
+ static PROJECT_CONSOLE = "console";
558
605
  constructor(path = Global.CONFIG_FILE_PATH) {
559
606
  const homeDir = os.homedir();
560
607
  super(`${homeDir}/${path}`);
561
608
  }
562
609
  getCurrentSession() {
563
610
  if (!this.has(Global.PREFERENCE_CURRENT)) {
564
- return '';
611
+ return "";
565
612
  }
566
613
  return this.get(Global.PREFERENCE_CURRENT);
567
614
  }
@@ -600,7 +647,7 @@ class Global extends Config {
600
647
  }
601
648
  getEmail() {
602
649
  if (!this.hasFrom(Global.PREFERENCE_EMAIL)) {
603
- return '';
650
+ return "";
604
651
  }
605
652
  return this.getFrom(Global.PREFERENCE_EMAIL);
606
653
  }
@@ -609,7 +656,7 @@ class Global extends Config {
609
656
  }
610
657
  getEndpoint() {
611
658
  if (!this.hasFrom(Global.PREFERENCE_ENDPOINT)) {
612
- return '';
659
+ return "";
613
660
  }
614
661
  return this.getFrom(Global.PREFERENCE_ENDPOINT);
615
662
  }
@@ -627,7 +674,7 @@ class Global extends Config {
627
674
  }
628
675
  getCookie() {
629
676
  if (!this.hasFrom(Global.PREFERENCE_COOKIE)) {
630
- return '';
677
+ return "";
631
678
  }
632
679
  return this.getFrom(Global.PREFERENCE_COOKIE);
633
680
  }
@@ -636,7 +683,7 @@ class Global extends Config {
636
683
  }
637
684
  getProject() {
638
685
  if (!this.hasFrom(Global.PREFERENCE_PROJECT)) {
639
- return '';
686
+ return "";
640
687
  }
641
688
  return this.getFrom(Global.PREFERENCE_PROJECT);
642
689
  }
@@ -645,7 +692,7 @@ class Global extends Config {
645
692
  }
646
693
  getKey() {
647
694
  if (!this.hasFrom(Global.PREFERENCE_KEY)) {
648
- return '';
695
+ return "";
649
696
  }
650
697
  return this.getFrom(Global.PREFERENCE_KEY);
651
698
  }
@@ -676,29 +723,7 @@ class Global extends Config {
676
723
  }
677
724
  }
678
725
  }
679
- Global.CONFIG_FILE_PATH = '.appwrite/prefs.json';
680
- Global.PREFERENCE_CURRENT = 'current';
681
- Global.PREFERENCE_ENDPOINT = 'endpoint';
682
- Global.PREFERENCE_EMAIL = 'email';
683
- Global.PREFERENCE_SELF_SIGNED = 'selfSigned';
684
- Global.PREFERENCE_COOKIE = 'cookie';
685
- Global.PREFERENCE_PROJECT = 'project';
686
- Global.PREFERENCE_KEY = 'key';
687
- Global.PREFERENCE_LOCALE = 'locale';
688
- Global.PREFERENCE_MODE = 'mode';
689
- Global.IGNORE_ATTRIBUTES = [
690
- Global.PREFERENCE_CURRENT,
691
- Global.PREFERENCE_SELF_SIGNED,
692
- Global.PREFERENCE_ENDPOINT,
693
- Global.PREFERENCE_COOKIE,
694
- Global.PREFERENCE_PROJECT,
695
- Global.PREFERENCE_KEY,
696
- Global.PREFERENCE_LOCALE,
697
- Global.PREFERENCE_MODE,
698
- ];
699
- Global.MODE_ADMIN = 'admin';
700
- Global.MODE_DEFAULT = 'default';
701
- Global.PROJECT_CONSOLE = 'console';
702
- exports.localConfig = new Local();
703
- exports.globalConfig = new Global();
726
+ export const localConfig = new Local();
727
+ export const globalConfig = new Global();
728
+ export { KeysAttributes, KeysSite, KeysFunction, KeysTopics, KeysStorage, KeysTeams, KeysCollection, KeysTable, whitelistKeys, };
704
729
  //# sourceMappingURL=config.js.map