appwrite-cli 12.0.0 → 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 +8 -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} +410 -664
  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} +122 -173
  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 -48
  255. package/lib/type-generation/languages/{dart.js → dart.ts} +91 -80
  256. package/lib/type-generation/languages/{java.js → java.ts} +58 -47
  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 -48
  261. package/lib/type-generation/languages/{swift.js → swift.ts} +59 -48
  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 -16
  279. package/lib/type-generation/languages/javascript.js +0 -102
  280. package/lib/type-generation/languages/kotlin.js +0 -85
  281. package/lib/type-generation/languages/language.js +0 -125
  282. package/lib/type-generation/languages/typescript.js +0 -107
  283. package/lib/validations.js +0 -17
@@ -1,187 +1,180 @@
1
- const os = require('os');
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");
2
6
  const fs = require("fs");
3
7
  const _path = require("path");
4
8
  const process = require("process");
5
- const JSONbig = require("json-bigint")({ storeAsString: false });
6
-
7
- const KeysVars = new Set(["key", "value"]);
8
- const KeysSite = new Set(["path", "$id", "name", "enabled", "logging", "timeout", "framework", "buildRuntime", "adapter", "installCommand", "buildCommand", "outputDirectory", "fallbackFile", "specification", "vars"]);
9
- const KeysFunction = new Set(["path", "$id", "execute", "name", "enabled", "logging", "runtime", "specification", "scopes", "events", "schedule", "timeout", "entrypoint", "commands", "vars"]);
10
- const KeysDatabase = new Set(["$id", "name", "enabled"]);
11
- const KeysCollection = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "documentSecurity", "attributes", "indexes"]);
12
- const KeysTable = new Set(["$id", "$permissions", "databaseId", "name", "enabled", "rowSecurity", "columns", "indexes"]);
13
- const KeysStorage = new Set(["$id", "$permissions", "fileSecurity", "name", "enabled", "maximumFileSize", "allowedFileExtensions", "compression", "encryption", "antivirus"]);
14
- const KeysTopics = new Set(["$id", "name", "subscribe"]);
15
- const KeysTeams = new Set(["$id", "name"]);
9
+ const JSONbig = require("json-bigint");
10
+ 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;
16
27
  const KeysAttributes = new Set([
17
- "key",
18
- "type",
19
- "required",
20
- "array",
21
- "size",
22
- "default",
28
+ 'key',
29
+ 'type',
30
+ 'required',
31
+ 'array',
32
+ 'size',
33
+ 'default',
23
34
  // integer and float
24
- "min",
25
- "max",
35
+ 'min',
36
+ 'max',
26
37
  // email, enum, URL, IP, and datetime
27
- "format",
38
+ 'format',
28
39
  // enum
29
- "elements",
40
+ 'elements',
30
41
  // relationship
31
- "relatedCollection",
32
- "relationType",
33
- "twoWay",
34
- "twoWayKey",
35
- "onDelete",
36
- "side",
42
+ 'relatedCollection',
43
+ 'relationType',
44
+ 'twoWay',
45
+ 'twoWayKey',
46
+ 'onDelete',
47
+ 'side',
37
48
  // Indexes
38
- "attributes",
39
- "orders",
49
+ 'attributes',
50
+ 'orders',
40
51
  // Strings
41
- "encrypt",
52
+ 'encrypt',
42
53
  ]);
54
+ exports.KeysAttributes = KeysAttributes;
43
55
  const KeysColumns = new Set([
44
- "key",
45
- "type",
46
- "required",
47
- "array",
48
- "size",
49
- "default",
56
+ 'key',
57
+ 'type',
58
+ 'required',
59
+ 'array',
60
+ 'size',
61
+ 'default',
50
62
  // integer and float
51
- "min",
52
- "max",
63
+ 'min',
64
+ 'max',
53
65
  // email, enum, URL, IP, and datetime
54
- "format",
66
+ 'format',
55
67
  // enum
56
- "elements",
68
+ 'elements',
57
69
  // relationship
58
- "relatedTable",
59
- "relationType",
60
- "twoWay",
61
- "twoWayKey",
62
- "onDelete",
63
- "side",
70
+ 'relatedTable',
71
+ 'relationType',
72
+ 'twoWay',
73
+ 'twoWayKey',
74
+ 'onDelete',
75
+ 'side',
64
76
  // Indexes
65
- "columns",
66
- "orders",
77
+ 'columns',
78
+ 'orders',
67
79
  // Strings
68
- "encrypt",
80
+ 'encrypt',
69
81
  ]);
70
- const KeyIndexes = new Set(["key", "type", "status", "attributes", "orders"]);
71
- const KeyIndexesColumns = new Set(["key", "type", "status", "columns", "orders"]);
72
-
82
+ const KeyIndexes = new Set(['key', 'type', 'status', 'attributes', 'orders']);
83
+ const KeyIndexesColumns = new Set(['key', 'type', 'status', 'columns', 'orders']);
73
84
  function whitelistKeys(value, keys, nestedKeys = {}) {
74
85
  if (Array.isArray(value)) {
75
86
  const newValue = [];
76
-
77
87
  for (const item of value) {
78
88
  newValue.push(whitelistKeys(item, keys, nestedKeys));
79
89
  }
80
-
81
90
  return newValue;
82
91
  }
83
-
84
92
  const newValue = {};
85
93
  Object.keys(value).forEach((key) => {
86
94
  if (keys.has(key)) {
87
95
  if (nestedKeys[key]) {
88
96
  newValue[key] = whitelistKeys(value[key], nestedKeys[key]);
89
- } else {
97
+ }
98
+ else {
90
99
  newValue[key] = value[key];
91
100
  }
92
101
  }
93
102
  });
94
103
  return newValue;
95
104
  }
96
-
97
105
  class Config {
98
106
  constructor(path) {
99
107
  this.path = path;
108
+ this.data = {};
100
109
  this.read();
101
110
  }
102
-
103
111
  read() {
104
112
  try {
105
113
  const file = fs.readFileSync(this.path).toString();
106
- this.data = JSONbig.parse(file);
107
- } catch (e) {
114
+ this.data = JSONBigInt.parse(file);
115
+ }
116
+ catch (e) {
108
117
  this.data = {};
109
118
  }
110
119
  }
111
-
112
120
  write() {
113
- let dir = _path.dirname(this.path)
121
+ const dir = _path.dirname(this.path);
114
122
  if (!fs.existsSync(dir)) {
115
123
  fs.mkdirSync(dir, { recursive: true });
116
124
  }
117
- fs.writeFileSync(this.path, JSONbig.stringify(this.data, null, 4), { mode: 0o600 });
125
+ fs.writeFileSync(this.path, JSONBigInt.stringify(this.data, null, 4), { mode: 0o600 });
118
126
  }
119
-
120
127
  get(key) {
121
128
  return this.data[key];
122
129
  }
123
-
124
130
  set(key, value) {
125
131
  this.data[key] = value;
126
132
  this.write();
127
133
  }
128
-
129
134
  delete(key) {
130
135
  delete this.data[key];
131
136
  this.write();
132
137
  }
133
-
134
138
  clear() {
135
139
  this.data = {};
136
140
  this.write();
137
141
  }
138
-
139
142
  has(key) {
140
143
  return this.data[key] !== undefined;
141
144
  }
142
-
143
145
  keys() {
144
146
  return Object.keys(this.data);
145
147
  }
146
-
147
148
  values() {
148
149
  return Object.values(this.data);
149
150
  }
150
-
151
151
  toString() {
152
- return JSONbig.stringify(this.data, null, 4);
152
+ return JSONBigInt.stringify(this.data, null, 4);
153
153
  }
154
-
155
154
  _getDBEntities(entityType) {
156
155
  if (!this.has(entityType)) {
157
156
  return [];
158
157
  }
159
158
  return this.get(entityType);
160
159
  }
161
-
162
160
  _getDBEntity(entityType, $id) {
163
161
  if (!this.has(entityType)) {
164
162
  return {};
165
163
  }
166
-
167
- let entities = this.get(entityType);
164
+ const entities = this.get(entityType);
168
165
  for (let i = 0; i < entities.length; i++) {
169
166
  if (entities[i]['$id'] == $id) {
170
167
  return entities[i];
171
168
  }
172
169
  }
173
-
174
170
  return {};
175
171
  }
176
-
177
172
  _addDBEntity(entityType, props, keysSet, nestedKeys = {}) {
178
173
  props = whitelistKeys(props, keysSet, nestedKeys);
179
-
180
174
  if (!this.has(entityType)) {
181
175
  this.set(entityType, []);
182
176
  }
183
-
184
- let entities = this.get(entityType);
177
+ const entities = this.get(entityType);
185
178
  for (let i = 0; i < entities.length; i++) {
186
179
  if (entities[i]['$id'] == props['$id']) {
187
180
  entities[i] = props;
@@ -193,409 +186,332 @@ class Config {
193
186
  this.set(entityType, entities);
194
187
  }
195
188
  }
196
-
197
189
  class Local extends Config {
198
- static CONFIG_FILE_PATH = "appwrite.config.json";
199
- static CONFIG_FILE_PATH_LEGACY = "appwrite.json";
200
- configDirectoryPath = ""
201
-
202
190
  constructor(path = Local.CONFIG_FILE_PATH, legacyPath = Local.CONFIG_FILE_PATH_LEGACY) {
203
191
  let absolutePath = Local.findConfigFile(path) || Local.findConfigFile(legacyPath);
204
-
205
192
  if (!absolutePath) {
206
193
  absolutePath = `${process.cwd()}/${path}`;
207
194
  }
208
-
209
195
  super(absolutePath);
196
+ this.configDirectoryPath = '';
210
197
  this.configDirectoryPath = _path.dirname(absolutePath);
211
198
  }
212
-
213
199
  static findConfigFile(filename) {
214
200
  let currentPath = process.cwd();
215
-
216
201
  while (true) {
217
202
  const filePath = `${currentPath}/${filename}`;
218
-
219
203
  if (fs.existsSync(filePath)) {
220
204
  return filePath;
221
205
  }
222
-
223
206
  const parentDirectory = _path.dirname(currentPath);
224
207
  if (parentDirectory === currentPath) {
225
208
  break;
226
209
  }
227
210
  currentPath = parentDirectory;
228
211
  }
229
-
230
212
  return null;
231
213
  }
232
-
233
214
  getDirname() {
234
- return _path.dirname(this.path)
215
+ return _path.dirname(this.path);
235
216
  }
236
-
237
217
  getEndpoint() {
238
218
  return this.get('endpoint') || '';
239
219
  }
240
-
241
220
  setEndpoint(endpoint) {
242
221
  this.set('endpoint', endpoint);
243
222
  }
244
-
245
223
  getSites() {
246
- if (!this.has("sites")) {
224
+ if (!this.has('sites')) {
247
225
  return [];
248
226
  }
249
- return this.get("sites");
227
+ return this.get('sites');
250
228
  }
251
-
252
229
  getSite($id) {
253
- if (!this.has("sites")) {
230
+ if (!this.has('sites')) {
254
231
  return {};
255
232
  }
256
-
257
- let sites = this.get("sites");
233
+ const sites = this.get('sites');
258
234
  for (let i = 0; i < sites.length; i++) {
259
235
  if (sites[i]['$id'] == $id) {
260
236
  return sites[i];
261
237
  }
262
238
  }
263
-
264
239
  return {};
265
240
  }
266
-
267
241
  addSite(props) {
268
242
  props = whitelistKeys(props, KeysSite, {
269
- vars: KeysVars
243
+ vars: KeysVars,
270
244
  });
271
-
272
- if (!this.has("sites")) {
273
- this.set("sites", []);
245
+ if (!this.has('sites')) {
246
+ this.set('sites', []);
274
247
  }
275
-
276
- let sites = this.get("sites");
248
+ const sites = this.get('sites');
277
249
  for (let i = 0; i < sites.length; i++) {
278
250
  if (sites[i]['$id'] == props['$id']) {
279
251
  sites[i] = {
280
252
  ...sites[i],
281
- ...props
253
+ ...props,
282
254
  };
283
- this.set("sites", sites);
255
+ this.set('sites', sites);
284
256
  return;
285
257
  }
286
258
  }
287
-
288
259
  sites.push(props);
289
- this.set("sites", sites);
260
+ this.set('sites', sites);
290
261
  }
291
-
292
262
  getFunctions() {
293
- if (!this.has("functions")) {
263
+ if (!this.has('functions')) {
294
264
  return [];
295
265
  }
296
- return this.get("functions");
266
+ return this.get('functions');
297
267
  }
298
-
299
268
  getFunction($id) {
300
- if (!this.has("functions")) {
269
+ if (!this.has('functions')) {
301
270
  return {};
302
271
  }
303
-
304
- let functions = this.get("functions");
272
+ const functions = this.get('functions');
305
273
  for (let i = 0; i < functions.length; i++) {
306
274
  if (functions[i]['$id'] == $id) {
307
275
  return functions[i];
308
276
  }
309
277
  }
310
-
311
278
  return {};
312
279
  }
313
-
314
280
  addFunction(props) {
315
281
  props = whitelistKeys(props, KeysFunction, {
316
- vars: KeysVars
282
+ vars: KeysVars,
317
283
  });
318
-
319
- if (!this.has("functions")) {
320
- this.set("functions", []);
284
+ if (!this.has('functions')) {
285
+ this.set('functions', []);
321
286
  }
322
-
323
- let functions = this.get("functions");
287
+ const functions = this.get('functions');
324
288
  for (let i = 0; i < functions.length; i++) {
325
289
  if (functions[i]['$id'] == props['$id']) {
326
290
  functions[i] = {
327
291
  ...functions[i],
328
- ...props
292
+ ...props,
329
293
  };
330
- this.set("functions", functions);
294
+ this.set('functions', functions);
331
295
  return;
332
296
  }
333
297
  }
334
-
335
298
  functions.push(props);
336
- this.set("functions", functions);
299
+ this.set('functions', functions);
337
300
  }
338
-
339
301
  getCollections() {
340
- if (!this.has("collections")) {
302
+ if (!this.has('collections')) {
341
303
  return [];
342
304
  }
343
- return this.get("collections");
305
+ return this.get('collections');
344
306
  }
345
-
346
307
  getCollection($id) {
347
- if (!this.has("collections")) {
308
+ if (!this.has('collections')) {
348
309
  return {};
349
310
  }
350
-
351
- let collections = this.get("collections");
311
+ const collections = this.get('collections');
352
312
  for (let i = 0; i < collections.length; i++) {
353
313
  if (collections[i]['$id'] == $id) {
354
314
  return collections[i];
355
315
  }
356
316
  }
357
-
358
317
  return {};
359
318
  }
360
-
361
319
  addCollection(props) {
362
320
  props = whitelistKeys(props, KeysCollection, {
363
321
  attributes: KeysAttributes,
364
- indexes: KeyIndexes
322
+ indexes: KeyIndexes,
365
323
  });
366
-
367
- if (!this.has("collections")) {
368
- this.set("collections", []);
324
+ if (!this.has('collections')) {
325
+ this.set('collections', []);
369
326
  }
370
-
371
- let collections = this.get("collections");
327
+ const collections = this.get('collections');
372
328
  for (let i = 0; i < collections.length; i++) {
373
329
  if (collections[i]['$id'] == props['$id'] && collections[i]['databaseId'] == props['databaseId']) {
374
330
  collections[i] = props;
375
- this.set("collections", collections);
331
+ this.set('collections', collections);
376
332
  return;
377
333
  }
378
334
  }
379
335
  collections.push(props);
380
- this.set("collections", collections);
336
+ this.set('collections', collections);
381
337
  }
382
-
383
338
  getTables() {
384
- if (!this.has("tables")) {
339
+ if (!this.has('tables')) {
385
340
  return [];
386
341
  }
387
- return this.get("tables");
342
+ return this.get('tables');
388
343
  }
389
-
390
344
  getTable($id) {
391
- if (!this.has("tables")) {
345
+ if (!this.has('tables')) {
392
346
  return {};
393
347
  }
394
-
395
- let tables = this.get("tables");
348
+ const tables = this.get('tables');
396
349
  for (let i = 0; i < tables.length; i++) {
397
350
  if (tables[i]['$id'] == $id) {
398
351
  return tables[i];
399
352
  }
400
353
  }
401
-
402
354
  return {};
403
355
  }
404
-
405
356
  addTable(props) {
406
357
  props = whitelistKeys(props, KeysTable, {
407
358
  columns: KeysColumns,
408
- indexes: KeyIndexesColumns
359
+ indexes: KeyIndexesColumns,
409
360
  });
410
-
411
- if (!this.has("tables")) {
412
- this.set("tables", []);
361
+ if (!this.has('tables')) {
362
+ this.set('tables', []);
413
363
  }
414
-
415
- let tables = this.get("tables");
364
+ const tables = this.get('tables');
416
365
  for (let i = 0; i < tables.length; i++) {
417
366
  if (tables[i]['$id'] == props['$id'] && tables[i]['databaseId'] == props['databaseId']) {
418
367
  tables[i] = props;
419
- this.set("tables", tables);
368
+ this.set('tables', tables);
420
369
  return;
421
370
  }
422
371
  }
423
372
  tables.push(props);
424
- this.set("tables", tables);
373
+ this.set('tables', tables);
425
374
  }
426
-
427
375
  getBuckets() {
428
- if (!this.has("buckets")) {
376
+ if (!this.has('buckets')) {
429
377
  return [];
430
378
  }
431
- return this.get("buckets");
379
+ return this.get('buckets');
432
380
  }
433
-
434
381
  getBucket($id) {
435
- if (!this.has("buckets")) {
382
+ if (!this.has('buckets')) {
436
383
  return {};
437
384
  }
438
-
439
- let buckets = this.get("buckets");
385
+ const buckets = this.get('buckets');
440
386
  for (let i = 0; i < buckets.length; i++) {
441
387
  if (buckets[i]['$id'] == $id) {
442
388
  return buckets[i];
443
389
  }
444
390
  }
445
-
446
391
  return {};
447
392
  }
448
-
449
393
  addBucket(props) {
450
394
  props = whitelistKeys(props, KeysStorage);
451
-
452
- if (!this.has("buckets")) {
453
- this.set("buckets", []);
395
+ if (!this.has('buckets')) {
396
+ this.set('buckets', []);
454
397
  }
455
-
456
- let buckets = this.get("buckets");
398
+ const buckets = this.get('buckets');
457
399
  for (let i = 0; i < buckets.length; i++) {
458
400
  if (buckets[i]['$id'] == props['$id']) {
459
401
  buckets[i] = props;
460
- this.set("buckets", buckets);
402
+ this.set('buckets', buckets);
461
403
  return;
462
404
  }
463
405
  }
464
406
  buckets.push(props);
465
- this.set("buckets", buckets);
407
+ this.set('buckets', buckets);
466
408
  }
467
-
468
409
  getMessagingTopics() {
469
- if (!this.has("topics")) {
410
+ if (!this.has('topics')) {
470
411
  return [];
471
412
  }
472
- return this.get("topics");
413
+ return this.get('topics');
473
414
  }
474
-
475
415
  getMessagingTopic($id) {
476
- if (!this.has("topics")) {
416
+ if (!this.has('topics')) {
477
417
  return {};
478
418
  }
479
-
480
- let topic = this.get("topics");
419
+ const topic = this.get('topics');
481
420
  for (let i = 0; i < topic.length; i++) {
482
421
  if (topic[i]['$id'] == $id) {
483
422
  return topic[i];
484
423
  }
485
424
  }
486
-
487
425
  return {};
488
426
  }
489
-
490
427
  addMessagingTopic(props) {
491
428
  props = whitelistKeys(props, KeysTopics);
492
-
493
- if (!this.has("topics")) {
494
- this.set("topics", []);
429
+ if (!this.has('topics')) {
430
+ this.set('topics', []);
495
431
  }
496
-
497
- let topics = this.get("topics");
432
+ const topics = this.get('topics');
498
433
  for (let i = 0; i < topics.length; i++) {
499
434
  if (topics[i]['$id'] === props['$id']) {
500
435
  topics[i] = props;
501
- this.set("topics", topics);
436
+ this.set('topics', topics);
502
437
  return;
503
438
  }
504
439
  }
505
440
  topics.push(props);
506
- this.set("topics", topics);
441
+ this.set('topics', topics);
507
442
  }
508
-
509
443
  getTablesDBs() {
510
- return this._getDBEntities("tablesDB");
444
+ return this._getDBEntities('tablesDB');
511
445
  }
512
-
513
446
  getTablesDB($id) {
514
- return this._getDBEntity("tablesDB", $id);
447
+ return this._getDBEntity('tablesDB', $id);
515
448
  }
516
-
517
449
  addTablesDB(props) {
518
- this._addDBEntity("tablesDB", props, KeysDatabase);
450
+ this._addDBEntity('tablesDB', props, KeysDatabase);
519
451
  }
520
-
521
452
  getDatabases() {
522
- return this._getDBEntities("databases");
453
+ return this._getDBEntities('databases');
523
454
  }
524
-
525
455
  getDatabase($id) {
526
- return this._getDBEntity("databases", $id);
456
+ return this._getDBEntity('databases', $id);
527
457
  }
528
-
529
458
  addDatabase(props) {
530
- this._addDBEntity("databases", props, KeysDatabase);
459
+ this._addDBEntity('databases', props, KeysDatabase);
531
460
  }
532
-
533
461
  getTeams() {
534
- if (!this.has("teams")) {
462
+ if (!this.has('teams')) {
535
463
  return [];
536
464
  }
537
- return this.get("teams");
465
+ return this.get('teams');
538
466
  }
539
-
540
467
  getTeam($id) {
541
- if (!this.has("teams")) {
468
+ if (!this.has('teams')) {
542
469
  return {};
543
470
  }
544
-
545
- let teams = this.get("teams");
471
+ const teams = this.get('teams');
546
472
  for (let i = 0; i < teams.length; i++) {
547
473
  if (teams[i]['$id'] == $id) {
548
474
  return teams[i];
549
475
  }
550
476
  }
551
-
552
477
  return {};
553
478
  }
554
-
555
479
  addTeam(props) {
556
480
  props = whitelistKeys(props, KeysTeams);
557
- if (!this.has("teams")) {
558
- this.set("teams", []);
481
+ if (!this.has('teams')) {
482
+ this.set('teams', []);
559
483
  }
560
-
561
- let teams = this.get("teams");
484
+ const teams = this.get('teams');
562
485
  for (let i = 0; i < teams.length; i++) {
563
486
  if (teams[i]['$id'] == props['$id']) {
564
487
  teams[i] = props;
565
- this.set("teams", teams);
488
+ this.set('teams', teams);
566
489
  return;
567
490
  }
568
491
  }
569
492
  teams.push(props);
570
- this.set("teams", teams);
493
+ this.set('teams', teams);
571
494
  }
572
-
573
495
  getProject() {
574
- if (!this.has("projectId")) {
496
+ if (!this.has('projectId')) {
575
497
  return {};
576
498
  }
577
-
578
499
  return {
579
- projectId: this.get("projectId"),
580
- projectName: this.get("projectName"),
581
- projectSettings: this.get('settings')
500
+ projectId: this.get('projectId'),
501
+ projectName: this.get('projectName'),
502
+ projectSettings: this.get('settings'),
582
503
  };
583
504
  }
584
-
585
505
  setProject(projectId, projectName = '', projectSettings = undefined) {
586
- this.set("projectId", projectId);
587
-
506
+ this.set('projectId', projectId);
588
507
  if (projectName !== '') {
589
- this.set("projectName", projectName);
508
+ this.set('projectName', projectName);
590
509
  }
591
-
592
510
  if (projectSettings === undefined) {
593
511
  return;
594
512
  }
595
-
596
513
  this.set('settings', this.createSettingsObject(projectSettings));
597
514
  }
598
-
599
515
  createSettingsObject(projectSettings) {
600
516
  return {
601
517
  services: {
@@ -618,9 +534,9 @@ class Local extends Config {
618
534
  phone: projectSettings.authPhone,
619
535
  invites: projectSettings.authInvites,
620
536
  anonymous: projectSettings.authAnonymous,
621
- "email-otp": projectSettings.authEmailOtp,
622
- "magic-url": projectSettings.authUsersAuthMagicURL,
623
- "email-password": projectSettings.authEmailPassword
537
+ 'email-otp': projectSettings.authEmailOtp,
538
+ 'magic-url': projectSettings.authUsersAuthMagicURL,
539
+ 'email-password': projectSettings.authEmailPassword,
624
540
  },
625
541
  security: {
626
542
  duration: projectSettings.authDuration,
@@ -630,196 +546,159 @@ class Local extends Config {
630
546
  passwordDictionary: projectSettings.authPasswordDictionary,
631
547
  personalDataCheck: projectSettings.authPersonalDataCheck,
632
548
  sessionAlerts: projectSettings.authSessionAlerts,
633
- mockNumbers: projectSettings.authMockNumbers
549
+ mockNumbers: projectSettings.authMockNumbers,
634
550
  },
635
- }
551
+ },
636
552
  };
637
553
  }
638
554
  }
639
-
555
+ Local.CONFIG_FILE_PATH = 'appwrite.config.json';
556
+ Local.CONFIG_FILE_PATH_LEGACY = 'appwrite.json';
640
557
  class Global extends Config {
641
- static CONFIG_FILE_PATH = ".appwrite/prefs.json";
642
-
643
- static PREFERENCE_CURRENT = "current";
644
- static PREFERENCE_ENDPOINT = "endpoint";
645
- static PREFERENCE_EMAIL = "email";
646
- static PREFERENCE_SELF_SIGNED = "selfSigned";
647
- static PREFERENCE_COOKIE = "cookie";
648
- static PREFERENCE_PROJECT = "project";
649
- static PREFERENCE_KEY = "key";
650
- static PREFERENCE_LOCALE = "locale";
651
- static PREFERENCE_MODE = "mode";
652
-
653
- static IGNORE_ATTRIBUTES = [Global.PREFERENCE_CURRENT, Global.PREFERENCE_SELF_SIGNED, Global.PREFERENCE_ENDPOINT, Global.PREFERENCE_COOKIE, Global.PREFERENCE_PROJECT, Global.PREFERENCE_KEY, Global.PREFERENCE_LOCALE, Global.PREFERENCE_MODE];
654
-
655
- static MODE_ADMIN = "admin";
656
- static MODE_DEFAULT = "default";
657
-
658
- static PROJECT_CONSOLE = "console";
659
-
660
558
  constructor(path = Global.CONFIG_FILE_PATH) {
661
559
  const homeDir = os.homedir();
662
560
  super(`${homeDir}/${path}`);
663
561
  }
664
-
665
562
  getCurrentSession() {
666
563
  if (!this.has(Global.PREFERENCE_CURRENT)) {
667
- return "";
564
+ return '';
668
565
  }
669
566
  return this.get(Global.PREFERENCE_CURRENT);
670
567
  }
671
-
672
568
  setCurrentSession(session) {
673
569
  if (session !== undefined) {
674
570
  this.set(Global.PREFERENCE_CURRENT, session);
675
571
  }
676
572
  }
677
-
678
573
  getSessionIds() {
679
574
  return Object.keys(this.data).filter((key) => !Global.IGNORE_ATTRIBUTES.includes(key));
680
575
  }
681
-
682
576
  getSessions() {
683
- const sessions = Object.keys(this.data).filter((key) => !Global.IGNORE_ATTRIBUTES.includes(key))
577
+ const sessions = Object.keys(this.data).filter((key) => !Global.IGNORE_ATTRIBUTES.includes(key));
684
578
  const current = this.getCurrentSession();
685
-
686
579
  const sessionMap = new Map();
687
-
688
580
  sessions.forEach((sessionId) => {
689
- const email = this.data[sessionId][Global.PREFERENCE_EMAIL];
690
- const endpoint = this.data[sessionId][Global.PREFERENCE_ENDPOINT];
581
+ const sessionData = this.data[sessionId];
582
+ const email = sessionData[Global.PREFERENCE_EMAIL];
583
+ const endpoint = sessionData[Global.PREFERENCE_ENDPOINT];
691
584
  const key = `${email}|${endpoint}`;
692
-
693
585
  if (sessionId === current || !sessionMap.has(key)) {
694
586
  sessionMap.set(key, {
695
587
  id: sessionId,
696
- endpoint: this.data[sessionId][Global.PREFERENCE_ENDPOINT],
697
- email: this.data[sessionId][Global.PREFERENCE_EMAIL]
588
+ endpoint: sessionData[Global.PREFERENCE_ENDPOINT],
589
+ email: sessionData[Global.PREFERENCE_EMAIL],
698
590
  });
699
591
  }
700
592
  });
701
-
702
593
  return Array.from(sessionMap.values());
703
594
  }
704
-
705
595
  addSession(session, data) {
706
596
  this.set(session, data);
707
597
  }
708
-
709
598
  removeSession(session) {
710
599
  this.delete(session);
711
600
  }
712
-
713
601
  getEmail() {
714
602
  if (!this.hasFrom(Global.PREFERENCE_EMAIL)) {
715
- return "";
603
+ return '';
716
604
  }
717
-
718
605
  return this.getFrom(Global.PREFERENCE_EMAIL);
719
606
  }
720
-
721
607
  setEmail(email) {
722
608
  this.setTo(Global.PREFERENCE_EMAIL, email);
723
609
  }
724
-
725
610
  getEndpoint() {
726
611
  if (!this.hasFrom(Global.PREFERENCE_ENDPOINT)) {
727
- return "";
612
+ return '';
728
613
  }
729
-
730
614
  return this.getFrom(Global.PREFERENCE_ENDPOINT);
731
615
  }
732
-
733
616
  setEndpoint(endpoint) {
734
617
  this.setTo(Global.PREFERENCE_ENDPOINT, endpoint);
735
618
  }
736
-
737
619
  getSelfSigned() {
738
620
  if (!this.hasFrom(Global.PREFERENCE_SELF_SIGNED)) {
739
621
  return false;
740
622
  }
741
623
  return this.getFrom(Global.PREFERENCE_SELF_SIGNED);
742
624
  }
743
-
744
625
  setSelfSigned(selfSigned) {
745
626
  this.setTo(Global.PREFERENCE_SELF_SIGNED, selfSigned);
746
627
  }
747
-
748
628
  getCookie() {
749
629
  if (!this.hasFrom(Global.PREFERENCE_COOKIE)) {
750
- return "";
630
+ return '';
751
631
  }
752
632
  return this.getFrom(Global.PREFERENCE_COOKIE);
753
633
  }
754
-
755
634
  setCookie(cookie) {
756
635
  this.setTo(Global.PREFERENCE_COOKIE, cookie);
757
636
  }
758
-
759
637
  getProject() {
760
638
  if (!this.hasFrom(Global.PREFERENCE_PROJECT)) {
761
- return "";
639
+ return '';
762
640
  }
763
641
  return this.getFrom(Global.PREFERENCE_PROJECT);
764
642
  }
765
-
766
643
  setProject(project) {
767
644
  this.setTo(Global.PREFERENCE_PROJECT, project);
768
645
  }
769
-
770
646
  getKey() {
771
647
  if (!this.hasFrom(Global.PREFERENCE_KEY)) {
772
- return "";
648
+ return '';
773
649
  }
774
650
  return this.getFrom(Global.PREFERENCE_KEY);
775
651
  }
776
-
777
652
  setKey(key) {
778
653
  this.setTo(Global.PREFERENCE_KEY, key);
779
654
  }
780
-
781
655
  hasFrom(key) {
782
656
  const current = this.getCurrentSession();
783
-
784
657
  if (current) {
785
658
  const config = this.get(current) ?? {};
786
-
787
659
  return config[key] !== undefined;
788
660
  }
661
+ return false;
789
662
  }
790
-
791
663
  getFrom(key) {
792
664
  const current = this.getCurrentSession();
793
-
794
665
  if (current) {
795
666
  const config = this.get(current) ?? {};
796
-
797
667
  return config[key];
798
668
  }
799
669
  }
800
-
801
670
  setTo(key, value) {
802
671
  const current = this.getCurrentSession();
803
-
804
672
  if (current) {
805
673
  const config = this.get(current);
806
-
807
674
  config[key] = value;
808
675
  this.write();
809
676
  }
810
677
  }
811
678
  }
812
-
813
- module.exports = {
814
- localConfig: new Local(),
815
- globalConfig: new Global(),
816
- KeysAttributes,
817
- KeysSite,
818
- KeysFunction,
819
- KeysTopics,
820
- KeysStorage,
821
- KeysTeams,
822
- KeysCollection,
823
- KeysTable,
824
- whitelistKeys
825
- };
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();
704
+ //# sourceMappingURL=config.js.map