@appwrite.io/console 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (322) hide show
  1. package/README.md +3 -3
  2. package/dist/cjs/sdk.js +3353 -1497
  3. package/dist/cjs/sdk.js.map +1 -1
  4. package/dist/esm/sdk.js +3350 -1498
  5. package/dist/esm/sdk.js.map +1 -1
  6. package/dist/iife/sdk.js +3353 -1497
  7. package/docs/examples/account/create-anonymous-session.md +1 -1
  8. package/docs/examples/account/create-email-session.md +1 -1
  9. package/docs/examples/account/create-j-w-t.md +1 -1
  10. package/docs/examples/account/create-magic-u-r-l-session.md +1 -1
  11. package/docs/examples/account/create-o-auth2session.md +1 -1
  12. package/docs/examples/account/create-phone-session.md +1 -1
  13. package/docs/examples/account/create-phone-verification.md +1 -1
  14. package/docs/examples/account/create-recovery.md +1 -1
  15. package/docs/examples/account/create-verification.md +1 -1
  16. package/docs/examples/account/create.md +1 -1
  17. package/docs/examples/account/{create-with-invite-code.md → delete-identity.md} +2 -2
  18. package/docs/examples/account/delete-session.md +1 -1
  19. package/docs/examples/account/delete-sessions.md +1 -1
  20. package/docs/examples/account/get-prefs.md +1 -1
  21. package/docs/examples/account/get-session.md +1 -1
  22. package/docs/examples/account/get.md +1 -1
  23. package/docs/examples/account/list-identities.md +18 -0
  24. package/docs/examples/account/list-logs.md +1 -1
  25. package/docs/examples/account/list-sessions.md +1 -1
  26. package/docs/examples/account/update-email.md +1 -1
  27. package/docs/examples/account/update-magic-u-r-l-session.md +1 -1
  28. package/docs/examples/account/update-name.md +1 -1
  29. package/docs/examples/account/update-password.md +1 -1
  30. package/docs/examples/account/update-phone-session.md +1 -1
  31. package/docs/examples/account/update-phone-verification.md +1 -1
  32. package/docs/examples/account/update-phone.md +1 -1
  33. package/docs/examples/account/update-prefs.md +1 -1
  34. package/docs/examples/account/update-recovery.md +1 -1
  35. package/docs/examples/account/update-session.md +1 -1
  36. package/docs/examples/account/update-status.md +1 -1
  37. package/docs/examples/account/update-verification.md +1 -1
  38. package/docs/examples/assistant/chat.md +18 -0
  39. package/docs/examples/avatars/get-browser.md +1 -1
  40. package/docs/examples/avatars/get-credit-card.md +1 -1
  41. package/docs/examples/avatars/get-favicon.md +1 -1
  42. package/docs/examples/avatars/get-flag.md +1 -1
  43. package/docs/examples/avatars/get-image.md +1 -1
  44. package/docs/examples/avatars/get-initials.md +1 -1
  45. package/docs/examples/avatars/get-q-r.md +1 -1
  46. package/docs/examples/console/variables.md +1 -1
  47. package/docs/examples/databases/create-boolean-attribute.md +1 -1
  48. package/docs/examples/databases/create-collection.md +1 -1
  49. package/docs/examples/databases/create-datetime-attribute.md +1 -1
  50. package/docs/examples/databases/create-document.md +1 -1
  51. package/docs/examples/databases/create-email-attribute.md +1 -1
  52. package/docs/examples/databases/create-enum-attribute.md +1 -1
  53. package/docs/examples/databases/create-float-attribute.md +1 -1
  54. package/docs/examples/databases/create-index.md +1 -1
  55. package/docs/examples/databases/create-integer-attribute.md +1 -1
  56. package/docs/examples/databases/create-ip-attribute.md +1 -1
  57. package/docs/examples/databases/create-relationship-attribute.md +1 -1
  58. package/docs/examples/databases/create-string-attribute.md +1 -1
  59. package/docs/examples/databases/create-url-attribute.md +1 -1
  60. package/docs/examples/databases/create.md +1 -1
  61. package/docs/examples/databases/delete-attribute.md +1 -1
  62. package/docs/examples/databases/delete-collection.md +1 -1
  63. package/docs/examples/databases/delete-document.md +1 -1
  64. package/docs/examples/databases/delete-index.md +1 -1
  65. package/docs/examples/databases/delete.md +1 -1
  66. package/docs/examples/databases/get-attribute.md +1 -1
  67. package/docs/examples/databases/get-collection-usage.md +1 -1
  68. package/docs/examples/databases/get-collection.md +1 -1
  69. package/docs/examples/databases/get-database-usage.md +1 -1
  70. package/docs/examples/databases/get-document.md +1 -1
  71. package/docs/examples/databases/get-index.md +1 -1
  72. package/docs/examples/databases/get-usage.md +1 -1
  73. package/docs/examples/databases/get.md +1 -1
  74. package/docs/examples/databases/list-attributes.md +1 -1
  75. package/docs/examples/databases/list-collection-logs.md +1 -1
  76. package/docs/examples/databases/list-collections.md +1 -1
  77. package/docs/examples/databases/list-document-logs.md +1 -1
  78. package/docs/examples/databases/list-documents.md +1 -1
  79. package/docs/examples/databases/list-indexes.md +1 -1
  80. package/docs/examples/databases/list-logs.md +1 -1
  81. package/docs/examples/databases/list.md +1 -1
  82. package/docs/examples/databases/update-boolean-attribute.md +1 -1
  83. package/docs/examples/databases/update-collection.md +1 -1
  84. package/docs/examples/databases/update-datetime-attribute.md +1 -1
  85. package/docs/examples/databases/update-document.md +1 -1
  86. package/docs/examples/databases/update-email-attribute.md +1 -1
  87. package/docs/examples/databases/update-enum-attribute.md +1 -1
  88. package/docs/examples/databases/update-float-attribute.md +1 -1
  89. package/docs/examples/databases/update-integer-attribute.md +1 -1
  90. package/docs/examples/databases/update-ip-attribute.md +1 -1
  91. package/docs/examples/databases/update-relationship-attribute.md +1 -1
  92. package/docs/examples/databases/update-string-attribute.md +1 -1
  93. package/docs/examples/databases/update-url-attribute.md +1 -1
  94. package/docs/examples/databases/update.md +1 -1
  95. package/docs/examples/functions/create-build.md +1 -1
  96. package/docs/examples/functions/create-deployment.md +2 -2
  97. package/docs/examples/functions/create-execution.md +1 -1
  98. package/docs/examples/functions/create-variable.md +1 -1
  99. package/docs/examples/functions/create.md +2 -2
  100. package/docs/examples/functions/delete-deployment.md +1 -1
  101. package/docs/examples/functions/delete-variable.md +1 -1
  102. package/docs/examples/functions/delete.md +1 -1
  103. package/docs/examples/functions/download-deployment.md +14 -0
  104. package/docs/examples/functions/get-deployment.md +1 -1
  105. package/docs/examples/functions/get-execution.md +1 -1
  106. package/docs/examples/functions/get-function-usage.md +1 -1
  107. package/docs/examples/functions/get-usage.md +1 -1
  108. package/docs/examples/functions/get-variable.md +1 -1
  109. package/docs/examples/functions/get.md +1 -1
  110. package/docs/examples/functions/list-deployments.md +1 -1
  111. package/docs/examples/functions/list-executions.md +1 -1
  112. package/docs/examples/functions/list-runtimes.md +1 -1
  113. package/docs/examples/functions/list-variables.md +1 -1
  114. package/docs/examples/functions/list.md +1 -1
  115. package/docs/examples/functions/update-deployment.md +1 -1
  116. package/docs/examples/functions/update-variable.md +1 -1
  117. package/docs/examples/functions/update.md +1 -1
  118. package/docs/examples/graphql/mutation.md +1 -1
  119. package/docs/examples/graphql/query.md +1 -1
  120. package/docs/examples/health/get-antivirus.md +1 -1
  121. package/docs/examples/health/get-cache.md +1 -1
  122. package/docs/examples/health/get-d-b.md +1 -1
  123. package/docs/examples/health/get-pub-sub.md +1 -1
  124. package/docs/examples/health/get-queue-builds.md +18 -0
  125. package/docs/examples/health/get-queue-certificates.md +1 -1
  126. package/docs/examples/health/get-queue-databases.md +18 -0
  127. package/docs/examples/health/get-queue-deletes.md +18 -0
  128. package/docs/examples/health/get-queue-functions.md +1 -1
  129. package/docs/examples/health/get-queue-logs.md +1 -1
  130. package/docs/examples/health/get-queue-mails.md +18 -0
  131. package/docs/examples/health/get-queue-messaging.md +18 -0
  132. package/docs/examples/health/get-queue-migrations.md +18 -0
  133. package/docs/examples/health/get-queue-webhooks.md +1 -1
  134. package/docs/examples/health/get-queue.md +1 -1
  135. package/docs/examples/health/get-storage-local.md +1 -1
  136. package/docs/examples/health/get-time.md +1 -1
  137. package/docs/examples/health/get.md +1 -1
  138. package/docs/examples/locale/get.md +1 -1
  139. package/docs/examples/locale/list-codes.md +18 -0
  140. package/docs/examples/locale/list-continents.md +1 -1
  141. package/docs/examples/locale/list-countries-e-u.md +1 -1
  142. package/docs/examples/locale/list-countries-phones.md +1 -1
  143. package/docs/examples/locale/list-countries.md +1 -1
  144. package/docs/examples/locale/list-currencies.md +1 -1
  145. package/docs/examples/locale/list-languages.md +1 -1
  146. package/docs/examples/migrations/create-appwrite-migration.md +18 -0
  147. package/docs/examples/migrations/create-firebase-migration.md +18 -0
  148. package/docs/examples/migrations/create-firebase-o-auth-migration.md +18 -0
  149. package/docs/examples/migrations/create-n-host-migration.md +18 -0
  150. package/docs/examples/migrations/create-supabase-migration.md +18 -0
  151. package/docs/examples/migrations/delete-firebase-auth.md +18 -0
  152. package/docs/examples/migrations/delete.md +18 -0
  153. package/docs/examples/migrations/get-appwrite-report.md +18 -0
  154. package/docs/examples/migrations/get-firebase-report-o-auth.md +18 -0
  155. package/docs/examples/migrations/get-firebase-report.md +18 -0
  156. package/docs/examples/migrations/get-n-host-report.md +18 -0
  157. package/docs/examples/migrations/get-supabase-report.md +18 -0
  158. package/docs/examples/migrations/get.md +18 -0
  159. package/docs/examples/migrations/list-firebase-projects.md +18 -0
  160. package/docs/examples/migrations/list.md +18 -0
  161. package/docs/examples/migrations/retry.md +18 -0
  162. package/docs/examples/project/create-variable.md +18 -0
  163. package/docs/examples/project/delete-variable.md +18 -0
  164. package/docs/examples/project/get-usage.md +2 -2
  165. package/docs/examples/project/get-variable.md +18 -0
  166. package/docs/examples/project/list-variables.md +18 -0
  167. package/docs/examples/project/update-variable.md +18 -0
  168. package/docs/examples/projects/create-key.md +1 -1
  169. package/docs/examples/projects/create-platform.md +1 -1
  170. package/docs/examples/projects/create-webhook.md +1 -1
  171. package/docs/examples/projects/create.md +2 -2
  172. package/docs/examples/projects/delete-email-template.md +18 -0
  173. package/docs/examples/projects/delete-key.md +1 -1
  174. package/docs/examples/projects/delete-platform.md +1 -1
  175. package/docs/examples/projects/delete-sms-template.md +18 -0
  176. package/docs/examples/projects/delete-webhook.md +1 -1
  177. package/docs/examples/projects/delete.md +2 -2
  178. package/docs/examples/projects/get-email-template.md +18 -0
  179. package/docs/examples/projects/get-key.md +1 -1
  180. package/docs/examples/projects/get-platform.md +1 -1
  181. package/docs/examples/projects/get-sms-template.md +18 -0
  182. package/docs/examples/projects/get-webhook.md +1 -1
  183. package/docs/examples/projects/get.md +1 -1
  184. package/docs/examples/projects/list-keys.md +1 -1
  185. package/docs/examples/projects/list-platforms.md +1 -1
  186. package/docs/examples/projects/list-webhooks.md +1 -1
  187. package/docs/examples/projects/list.md +1 -1
  188. package/docs/examples/projects/update-auth-duration.md +1 -1
  189. package/docs/examples/projects/update-auth-limit.md +1 -1
  190. package/docs/examples/projects/update-auth-password-dictionary.md +1 -1
  191. package/docs/examples/projects/update-auth-password-history.md +1 -1
  192. package/docs/examples/projects/update-auth-sessions-limit.md +1 -1
  193. package/docs/examples/projects/update-auth-status.md +1 -1
  194. package/docs/examples/projects/update-email-template.md +18 -0
  195. package/docs/examples/projects/update-key.md +1 -1
  196. package/docs/examples/projects/update-o-auth2.md +1 -1
  197. package/docs/examples/projects/{delete-domain.md → update-personal-data-check.md} +2 -2
  198. package/docs/examples/projects/update-platform.md +1 -1
  199. package/docs/examples/projects/{create-domain.md → update-service-status-all.md} +2 -2
  200. package/docs/examples/projects/update-service-status.md +1 -1
  201. package/docs/examples/projects/update-sms-template.md +18 -0
  202. package/docs/examples/projects/{get-domain.md → update-smtp-configuration.md} +2 -2
  203. package/docs/examples/projects/{list-domains.md → update-team.md} +2 -2
  204. package/docs/examples/projects/update-webhook-signature.md +1 -1
  205. package/docs/examples/projects/update-webhook.md +1 -1
  206. package/docs/examples/projects/update.md +1 -1
  207. package/docs/examples/proxy/create-rule.md +18 -0
  208. package/docs/examples/proxy/delete-rule.md +18 -0
  209. package/docs/examples/proxy/get-rule.md +18 -0
  210. package/docs/examples/proxy/list-rules.md +18 -0
  211. package/docs/examples/proxy/update-rule-verification.md +18 -0
  212. package/docs/examples/storage/create-bucket.md +1 -1
  213. package/docs/examples/storage/create-file.md +1 -1
  214. package/docs/examples/storage/delete-bucket.md +1 -1
  215. package/docs/examples/storage/delete-file.md +1 -1
  216. package/docs/examples/storage/get-bucket-usage.md +1 -1
  217. package/docs/examples/storage/get-bucket.md +1 -1
  218. package/docs/examples/storage/get-file-download.md +1 -1
  219. package/docs/examples/storage/get-file-preview.md +1 -1
  220. package/docs/examples/storage/get-file-view.md +1 -1
  221. package/docs/examples/storage/get-file.md +1 -1
  222. package/docs/examples/storage/get-usage.md +1 -1
  223. package/docs/examples/storage/list-buckets.md +1 -1
  224. package/docs/examples/storage/list-files.md +1 -1
  225. package/docs/examples/storage/update-bucket.md +1 -1
  226. package/docs/examples/storage/update-file.md +1 -1
  227. package/docs/examples/teams/create-membership.md +2 -2
  228. package/docs/examples/teams/create.md +1 -1
  229. package/docs/examples/teams/delete-membership.md +1 -1
  230. package/docs/examples/teams/delete.md +1 -1
  231. package/docs/examples/teams/get-membership.md +1 -1
  232. package/docs/examples/teams/get-prefs.md +1 -1
  233. package/docs/examples/teams/get.md +1 -1
  234. package/docs/examples/teams/list-logs.md +1 -1
  235. package/docs/examples/teams/list-memberships.md +1 -1
  236. package/docs/examples/teams/list.md +1 -1
  237. package/docs/examples/teams/update-membership-status.md +1 -1
  238. package/docs/examples/teams/{update-membership-roles.md → update-membership.md} +2 -2
  239. package/docs/examples/teams/update-name.md +1 -1
  240. package/docs/examples/teams/update-prefs.md +1 -1
  241. package/docs/examples/users/create-argon2user.md +1 -1
  242. package/docs/examples/users/create-bcrypt-user.md +1 -1
  243. package/docs/examples/users/create-m-d5user.md +1 -1
  244. package/docs/examples/users/create-p-h-pass-user.md +1 -1
  245. package/docs/examples/users/create-s-h-a-user.md +1 -1
  246. package/docs/examples/users/create-scrypt-modified-user.md +1 -1
  247. package/docs/examples/users/create-scrypt-user.md +1 -1
  248. package/docs/examples/users/create.md +1 -1
  249. package/docs/examples/users/delete-identity.md +18 -0
  250. package/docs/examples/users/delete-session.md +1 -1
  251. package/docs/examples/users/delete-sessions.md +1 -1
  252. package/docs/examples/users/delete.md +1 -1
  253. package/docs/examples/users/get-prefs.md +1 -1
  254. package/docs/examples/users/get-usage.md +1 -1
  255. package/docs/examples/users/get.md +1 -1
  256. package/docs/examples/users/list-identities.md +18 -0
  257. package/docs/examples/users/list-logs.md +1 -1
  258. package/docs/examples/users/list-memberships.md +1 -1
  259. package/docs/examples/users/list-sessions.md +1 -1
  260. package/docs/examples/users/list.md +1 -1
  261. package/docs/examples/users/update-email-verification.md +1 -1
  262. package/docs/examples/users/update-email.md +1 -1
  263. package/docs/examples/users/update-labels.md +18 -0
  264. package/docs/examples/users/update-name.md +1 -1
  265. package/docs/examples/users/update-password.md +1 -1
  266. package/docs/examples/users/update-phone-verification.md +1 -1
  267. package/docs/examples/users/update-phone.md +1 -1
  268. package/docs/examples/users/update-prefs.md +1 -1
  269. package/docs/examples/users/update-status.md +1 -1
  270. package/docs/examples/vcs/create-repository-detection.md +18 -0
  271. package/docs/examples/vcs/create-repository.md +18 -0
  272. package/docs/examples/vcs/delete-installation.md +18 -0
  273. package/docs/examples/vcs/get-installation.md +18 -0
  274. package/docs/examples/vcs/get-repository.md +18 -0
  275. package/docs/examples/vcs/list-installations.md +18 -0
  276. package/docs/examples/vcs/list-repositories.md +18 -0
  277. package/docs/examples/vcs/list-repository-branches.md +18 -0
  278. package/docs/examples/vcs/update-external-deployments.md +18 -0
  279. package/package.json +3 -2
  280. package/src/client.ts +2 -2
  281. package/src/index.ts +4 -0
  282. package/src/models.ts +863 -233
  283. package/src/query.ts +1 -1
  284. package/src/role.ts +72 -6
  285. package/src/services/account.ts +1052 -1055
  286. package/src/services/assistant.ts +38 -0
  287. package/src/services/avatars.ts +338 -337
  288. package/src/services/console.ts +16 -16
  289. package/src/services/databases.ts +2170 -2140
  290. package/src/services/functions.ts +804 -657
  291. package/src/services/graphql.ts +47 -47
  292. package/src/services/health.ts +373 -204
  293. package/src/services/locale.ts +156 -137
  294. package/src/services/migrations.ts +707 -0
  295. package/src/services/project.ts +178 -20
  296. package/src/services/projects.ts +1511 -1256
  297. package/src/services/proxy.ts +150 -0
  298. package/src/services/storage.ts +572 -577
  299. package/src/services/teams.ts +498 -501
  300. package/src/services/users.ts +1091 -1001
  301. package/src/services/vcs.ts +272 -0
  302. package/types/index.d.ts +4 -0
  303. package/types/models.d.ts +863 -233
  304. package/types/role.d.ts +62 -0
  305. package/types/services/account.d.ts +116 -104
  306. package/types/services/assistant.d.ts +14 -0
  307. package/types/services/avatars.d.ts +18 -17
  308. package/types/services/console.d.ts +2 -2
  309. package/types/services/databases.d.ts +111 -105
  310. package/types/services/functions.d.ts +95 -55
  311. package/types/services/graphql.d.ts +4 -4
  312. package/types/services/health.d.ts +97 -26
  313. package/types/services/locale.d.ts +24 -14
  314. package/types/services/migrations.d.ts +185 -0
  315. package/types/services/project.d.ts +60 -3
  316. package/types/services/projects.d.ts +174 -104
  317. package/types/services/proxy.d.ts +59 -0
  318. package/types/services/storage.d.ts +29 -28
  319. package/types/services/teams.d.ts +36 -35
  320. package/types/services/users.d.ts +105 -66
  321. package/types/services/vcs.d.ts +97 -0
  322. package/docs/examples/projects/update-domain-verification.md +0 -18
@@ -10,1006 +10,1096 @@ export class Users extends Service {
10
10
  super(client);
11
11
  }
12
12
 
13
- /**
14
- * List Users
15
- *
16
- * Get a list of all the project's users. You can use the query params to
17
- * filter your results.
18
- *
19
- * @param {string[]} queries
20
- * @param {string} search
21
- * @throws {AppwriteException}
22
- * @returns {Promise}
23
- */
24
- async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>> {
25
- let path = '/users';
26
- let payload: Payload = {};
27
-
28
- if (typeof queries !== 'undefined') {
29
- payload['queries'] = queries;
30
- }
31
-
32
- if (typeof search !== 'undefined') {
33
- payload['search'] = search;
34
- }
35
-
36
- const uri = new URL(this.client.config.endpoint + path);
37
- return await this.client.call('get', uri, {
38
- 'content-type': 'application/json',
39
- }, payload);
40
- }
41
-
42
- /**
43
- * Create User
44
- *
45
- * Create a new user.
46
- *
47
- * @param {string} userId
48
- * @param {string} email
49
- * @param {string} phone
50
- * @param {string} password
51
- * @param {string} name
52
- * @throws {AppwriteException}
53
- * @returns {Promise}
54
- */
55
- async create<Preferences extends Models.Preferences>(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise<Models.User<Preferences>> {
56
- if (typeof userId === 'undefined') {
57
- throw new AppwriteException('Missing required parameter: "userId"');
58
- }
59
-
60
- let path = '/users';
61
- let payload: Payload = {};
62
-
63
- if (typeof userId !== 'undefined') {
64
- payload['userId'] = userId;
65
- }
66
-
67
- if (typeof email !== 'undefined') {
68
- payload['email'] = email;
69
- }
70
-
71
- if (typeof phone !== 'undefined') {
72
- payload['phone'] = phone;
73
- }
74
-
75
- if (typeof password !== 'undefined') {
76
- payload['password'] = password;
77
- }
78
-
79
- if (typeof name !== 'undefined') {
80
- payload['name'] = name;
81
- }
82
-
83
- const uri = new URL(this.client.config.endpoint + path);
84
- return await this.client.call('post', uri, {
85
- 'content-type': 'application/json',
86
- }, payload);
87
- }
88
-
89
- /**
90
- * Create User with Argon2 Password
91
- *
92
- * Create a new user. Password provided must be hashed with the
93
- * [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
94
- * /users](/docs/server/users#usersCreate) endpoint to create users with a
95
- * plain text password.
96
- *
97
- * @param {string} userId
98
- * @param {string} email
99
- * @param {string} password
100
- * @param {string} name
101
- * @throws {AppwriteException}
102
- * @returns {Promise}
103
- */
104
- async createArgon2User<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
105
- if (typeof userId === 'undefined') {
106
- throw new AppwriteException('Missing required parameter: "userId"');
107
- }
108
-
109
- if (typeof email === 'undefined') {
110
- throw new AppwriteException('Missing required parameter: "email"');
111
- }
112
-
113
- if (typeof password === 'undefined') {
114
- throw new AppwriteException('Missing required parameter: "password"');
115
- }
116
-
117
- let path = '/users/argon2';
118
- let payload: Payload = {};
119
-
120
- if (typeof userId !== 'undefined') {
121
- payload['userId'] = userId;
122
- }
123
-
124
- if (typeof email !== 'undefined') {
125
- payload['email'] = email;
126
- }
127
-
128
- if (typeof password !== 'undefined') {
129
- payload['password'] = password;
130
- }
131
-
132
- if (typeof name !== 'undefined') {
133
- payload['name'] = name;
134
- }
135
-
136
- const uri = new URL(this.client.config.endpoint + path);
137
- return await this.client.call('post', uri, {
138
- 'content-type': 'application/json',
139
- }, payload);
140
- }
141
-
142
- /**
143
- * Create User with Bcrypt Password
144
- *
145
- * Create a new user. Password provided must be hashed with the
146
- * [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
147
- * /users](/docs/server/users#usersCreate) endpoint to create users with a
148
- * plain text password.
149
- *
150
- * @param {string} userId
151
- * @param {string} email
152
- * @param {string} password
153
- * @param {string} name
154
- * @throws {AppwriteException}
155
- * @returns {Promise}
156
- */
157
- async createBcryptUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
158
- if (typeof userId === 'undefined') {
159
- throw new AppwriteException('Missing required parameter: "userId"');
160
- }
161
-
162
- if (typeof email === 'undefined') {
163
- throw new AppwriteException('Missing required parameter: "email"');
164
- }
165
-
166
- if (typeof password === 'undefined') {
167
- throw new AppwriteException('Missing required parameter: "password"');
168
- }
169
-
170
- let path = '/users/bcrypt';
171
- let payload: Payload = {};
172
-
173
- if (typeof userId !== 'undefined') {
174
- payload['userId'] = userId;
175
- }
176
-
177
- if (typeof email !== 'undefined') {
178
- payload['email'] = email;
179
- }
180
-
181
- if (typeof password !== 'undefined') {
182
- payload['password'] = password;
183
- }
184
-
185
- if (typeof name !== 'undefined') {
186
- payload['name'] = name;
187
- }
188
-
189
- const uri = new URL(this.client.config.endpoint + path);
190
- return await this.client.call('post', uri, {
191
- 'content-type': 'application/json',
192
- }, payload);
193
- }
194
-
195
- /**
196
- * Create User with MD5 Password
197
- *
198
- * Create a new user. Password provided must be hashed with the
199
- * [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
200
- * /users](/docs/server/users#usersCreate) endpoint to create users with a
201
- * plain text password.
202
- *
203
- * @param {string} userId
204
- * @param {string} email
205
- * @param {string} password
206
- * @param {string} name
207
- * @throws {AppwriteException}
208
- * @returns {Promise}
209
- */
210
- async createMD5User<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
211
- if (typeof userId === 'undefined') {
212
- throw new AppwriteException('Missing required parameter: "userId"');
213
- }
214
-
215
- if (typeof email === 'undefined') {
216
- throw new AppwriteException('Missing required parameter: "email"');
217
- }
218
-
219
- if (typeof password === 'undefined') {
220
- throw new AppwriteException('Missing required parameter: "password"');
221
- }
222
-
223
- let path = '/users/md5';
224
- let payload: Payload = {};
225
-
226
- if (typeof userId !== 'undefined') {
227
- payload['userId'] = userId;
228
- }
229
-
230
- if (typeof email !== 'undefined') {
231
- payload['email'] = email;
232
- }
233
-
234
- if (typeof password !== 'undefined') {
235
- payload['password'] = password;
236
- }
237
-
238
- if (typeof name !== 'undefined') {
239
- payload['name'] = name;
240
- }
241
-
242
- const uri = new URL(this.client.config.endpoint + path);
243
- return await this.client.call('post', uri, {
244
- 'content-type': 'application/json',
245
- }, payload);
246
- }
247
-
248
- /**
249
- * Create User with PHPass Password
250
- *
251
- * Create a new user. Password provided must be hashed with the
252
- * [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
253
- * /users](/docs/server/users#usersCreate) endpoint to create users with a
254
- * plain text password.
255
- *
256
- * @param {string} userId
257
- * @param {string} email
258
- * @param {string} password
259
- * @param {string} name
260
- * @throws {AppwriteException}
261
- * @returns {Promise}
262
- */
263
- async createPHPassUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
264
- if (typeof userId === 'undefined') {
265
- throw new AppwriteException('Missing required parameter: "userId"');
266
- }
267
-
268
- if (typeof email === 'undefined') {
269
- throw new AppwriteException('Missing required parameter: "email"');
270
- }
271
-
272
- if (typeof password === 'undefined') {
273
- throw new AppwriteException('Missing required parameter: "password"');
274
- }
275
-
276
- let path = '/users/phpass';
277
- let payload: Payload = {};
278
-
279
- if (typeof userId !== 'undefined') {
280
- payload['userId'] = userId;
281
- }
282
-
283
- if (typeof email !== 'undefined') {
284
- payload['email'] = email;
285
- }
286
-
287
- if (typeof password !== 'undefined') {
288
- payload['password'] = password;
289
- }
290
-
291
- if (typeof name !== 'undefined') {
292
- payload['name'] = name;
293
- }
294
-
295
- const uri = new URL(this.client.config.endpoint + path);
296
- return await this.client.call('post', uri, {
297
- 'content-type': 'application/json',
298
- }, payload);
299
- }
300
-
301
- /**
302
- * Create User with Scrypt Password
303
- *
304
- * Create a new user. Password provided must be hashed with the
305
- * [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
306
- * /users](/docs/server/users#usersCreate) endpoint to create users with a
307
- * plain text password.
308
- *
309
- * @param {string} userId
310
- * @param {string} email
311
- * @param {string} password
312
- * @param {string} passwordSalt
313
- * @param {number} passwordCpu
314
- * @param {number} passwordMemory
315
- * @param {number} passwordParallel
316
- * @param {number} passwordLength
317
- * @param {string} name
318
- * @throws {AppwriteException}
319
- * @returns {Promise}
320
- */
321
- async createScryptUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise<Models.User<Preferences>> {
322
- if (typeof userId === 'undefined') {
323
- throw new AppwriteException('Missing required parameter: "userId"');
324
- }
325
-
326
- if (typeof email === 'undefined') {
327
- throw new AppwriteException('Missing required parameter: "email"');
328
- }
329
-
330
- if (typeof password === 'undefined') {
331
- throw new AppwriteException('Missing required parameter: "password"');
332
- }
333
-
334
- if (typeof passwordSalt === 'undefined') {
335
- throw new AppwriteException('Missing required parameter: "passwordSalt"');
336
- }
337
-
338
- if (typeof passwordCpu === 'undefined') {
339
- throw new AppwriteException('Missing required parameter: "passwordCpu"');
340
- }
341
-
342
- if (typeof passwordMemory === 'undefined') {
343
- throw new AppwriteException('Missing required parameter: "passwordMemory"');
344
- }
345
-
346
- if (typeof passwordParallel === 'undefined') {
347
- throw new AppwriteException('Missing required parameter: "passwordParallel"');
348
- }
349
-
350
- if (typeof passwordLength === 'undefined') {
351
- throw new AppwriteException('Missing required parameter: "passwordLength"');
352
- }
353
-
354
- let path = '/users/scrypt';
355
- let payload: Payload = {};
356
-
357
- if (typeof userId !== 'undefined') {
358
- payload['userId'] = userId;
359
- }
360
-
361
- if (typeof email !== 'undefined') {
362
- payload['email'] = email;
363
- }
364
-
365
- if (typeof password !== 'undefined') {
366
- payload['password'] = password;
367
- }
368
-
369
- if (typeof passwordSalt !== 'undefined') {
370
- payload['passwordSalt'] = passwordSalt;
371
- }
372
-
373
- if (typeof passwordCpu !== 'undefined') {
374
- payload['passwordCpu'] = passwordCpu;
375
- }
376
-
377
- if (typeof passwordMemory !== 'undefined') {
378
- payload['passwordMemory'] = passwordMemory;
379
- }
380
-
381
- if (typeof passwordParallel !== 'undefined') {
382
- payload['passwordParallel'] = passwordParallel;
383
- }
384
-
385
- if (typeof passwordLength !== 'undefined') {
386
- payload['passwordLength'] = passwordLength;
387
- }
388
-
389
- if (typeof name !== 'undefined') {
390
- payload['name'] = name;
391
- }
392
-
393
- const uri = new URL(this.client.config.endpoint + path);
394
- return await this.client.call('post', uri, {
395
- 'content-type': 'application/json',
396
- }, payload);
397
- }
398
-
399
- /**
400
- * Create User with Scrypt Modified Password
401
- *
402
- * Create a new user. Password provided must be hashed with the [Scrypt
403
- * Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
404
- * algorithm. Use the [POST /users](/docs/server/users#usersCreate) endpoint
405
- * to create users with a plain text password.
406
- *
407
- * @param {string} userId
408
- * @param {string} email
409
- * @param {string} password
410
- * @param {string} passwordSalt
411
- * @param {string} passwordSaltSeparator
412
- * @param {string} passwordSignerKey
413
- * @param {string} name
414
- * @throws {AppwriteException}
415
- * @returns {Promise}
416
- */
417
- async createScryptModifiedUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise<Models.User<Preferences>> {
418
- if (typeof userId === 'undefined') {
419
- throw new AppwriteException('Missing required parameter: "userId"');
420
- }
421
-
422
- if (typeof email === 'undefined') {
423
- throw new AppwriteException('Missing required parameter: "email"');
424
- }
425
-
426
- if (typeof password === 'undefined') {
427
- throw new AppwriteException('Missing required parameter: "password"');
428
- }
429
-
430
- if (typeof passwordSalt === 'undefined') {
431
- throw new AppwriteException('Missing required parameter: "passwordSalt"');
432
- }
433
-
434
- if (typeof passwordSaltSeparator === 'undefined') {
435
- throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"');
436
- }
437
-
438
- if (typeof passwordSignerKey === 'undefined') {
439
- throw new AppwriteException('Missing required parameter: "passwordSignerKey"');
440
- }
441
-
442
- let path = '/users/scrypt-modified';
443
- let payload: Payload = {};
444
-
445
- if (typeof userId !== 'undefined') {
446
- payload['userId'] = userId;
447
- }
448
-
449
- if (typeof email !== 'undefined') {
450
- payload['email'] = email;
451
- }
452
-
453
- if (typeof password !== 'undefined') {
454
- payload['password'] = password;
455
- }
456
-
457
- if (typeof passwordSalt !== 'undefined') {
458
- payload['passwordSalt'] = passwordSalt;
459
- }
460
-
461
- if (typeof passwordSaltSeparator !== 'undefined') {
462
- payload['passwordSaltSeparator'] = passwordSaltSeparator;
463
- }
464
-
465
- if (typeof passwordSignerKey !== 'undefined') {
466
- payload['passwordSignerKey'] = passwordSignerKey;
467
- }
468
-
469
- if (typeof name !== 'undefined') {
470
- payload['name'] = name;
471
- }
472
-
473
- const uri = new URL(this.client.config.endpoint + path);
474
- return await this.client.call('post', uri, {
475
- 'content-type': 'application/json',
476
- }, payload);
477
- }
478
-
479
- /**
480
- * Create User with SHA Password
481
- *
482
- * Create a new user. Password provided must be hashed with the
483
- * [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
484
- * the [POST /users](/docs/server/users#usersCreate) endpoint to create users
485
- * with a plain text password.
486
- *
487
- * @param {string} userId
488
- * @param {string} email
489
- * @param {string} password
490
- * @param {string} passwordVersion
491
- * @param {string} name
492
- * @throws {AppwriteException}
493
- * @returns {Promise}
494
- */
495
- async createSHAUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordVersion?: string, name?: string): Promise<Models.User<Preferences>> {
496
- if (typeof userId === 'undefined') {
497
- throw new AppwriteException('Missing required parameter: "userId"');
498
- }
499
-
500
- if (typeof email === 'undefined') {
501
- throw new AppwriteException('Missing required parameter: "email"');
502
- }
503
-
504
- if (typeof password === 'undefined') {
505
- throw new AppwriteException('Missing required parameter: "password"');
506
- }
507
-
508
- let path = '/users/sha';
509
- let payload: Payload = {};
510
-
511
- if (typeof userId !== 'undefined') {
512
- payload['userId'] = userId;
513
- }
514
-
515
- if (typeof email !== 'undefined') {
516
- payload['email'] = email;
517
- }
518
-
519
- if (typeof password !== 'undefined') {
520
- payload['password'] = password;
521
- }
522
-
523
- if (typeof passwordVersion !== 'undefined') {
524
- payload['passwordVersion'] = passwordVersion;
525
- }
526
-
527
- if (typeof name !== 'undefined') {
528
- payload['name'] = name;
529
- }
530
-
531
- const uri = new URL(this.client.config.endpoint + path);
532
- return await this.client.call('post', uri, {
533
- 'content-type': 'application/json',
534
- }, payload);
535
- }
536
-
537
- /**
538
- * Get usage stats for the users API
539
- *
540
- *
541
- * @param {string} range
542
- * @throws {AppwriteException}
543
- * @returns {Promise}
544
- */
545
- async getUsage(range?: string): Promise<Models.UsageUsers> {
546
- let path = '/users/usage';
547
- let payload: Payload = {};
548
-
549
- if (typeof range !== 'undefined') {
550
- payload['range'] = range;
551
- }
552
-
553
- const uri = new URL(this.client.config.endpoint + path);
554
- return await this.client.call('get', uri, {
555
- 'content-type': 'application/json',
556
- }, payload);
557
- }
558
-
559
- /**
560
- * Get User
561
- *
562
- * Get a user by its unique ID.
563
- *
564
- * @param {string} userId
565
- * @throws {AppwriteException}
566
- * @returns {Promise}
567
- */
568
- async get<Preferences extends Models.Preferences>(userId: string): Promise<Models.User<Preferences>> {
569
- if (typeof userId === 'undefined') {
570
- throw new AppwriteException('Missing required parameter: "userId"');
571
- }
572
-
573
- let path = '/users/{userId}'.replace('{userId}', userId);
574
- let payload: Payload = {};
575
-
576
- const uri = new URL(this.client.config.endpoint + path);
577
- return await this.client.call('get', uri, {
578
- 'content-type': 'application/json',
579
- }, payload);
580
- }
581
-
582
- /**
583
- * Delete User
584
- *
585
- * Delete a user by its unique ID, thereby releasing it's ID. Since ID is
586
- * released and can be reused, all user-related resources like documents or
587
- * storage files should be deleted before user deletion. If you want to keep
588
- * ID reserved, use the [updateStatus](/docs/server/users#usersUpdateStatus)
589
- * endpoint instead.
590
- *
591
- * @param {string} userId
592
- * @throws {AppwriteException}
593
- * @returns {Promise}
594
- */
595
- async delete(userId: string): Promise<{}> {
596
- if (typeof userId === 'undefined') {
597
- throw new AppwriteException('Missing required parameter: "userId"');
598
- }
599
-
600
- let path = '/users/{userId}'.replace('{userId}', userId);
601
- let payload: Payload = {};
602
-
603
- const uri = new URL(this.client.config.endpoint + path);
604
- return await this.client.call('delete', uri, {
605
- 'content-type': 'application/json',
606
- }, payload);
607
- }
608
-
609
- /**
610
- * Update Email
611
- *
612
- * Update the user email by its unique ID.
613
- *
614
- * @param {string} userId
615
- * @param {string} email
616
- * @throws {AppwriteException}
617
- * @returns {Promise}
618
- */
619
- async updateEmail<Preferences extends Models.Preferences>(userId: string, email: string): Promise<Models.User<Preferences>> {
620
- if (typeof userId === 'undefined') {
621
- throw new AppwriteException('Missing required parameter: "userId"');
622
- }
623
-
624
- if (typeof email === 'undefined') {
625
- throw new AppwriteException('Missing required parameter: "email"');
626
- }
627
-
628
- let path = '/users/{userId}/email'.replace('{userId}', userId);
629
- let payload: Payload = {};
630
-
631
- if (typeof email !== 'undefined') {
632
- payload['email'] = email;
633
- }
634
-
635
- const uri = new URL(this.client.config.endpoint + path);
636
- return await this.client.call('patch', uri, {
637
- 'content-type': 'application/json',
638
- }, payload);
639
- }
640
-
641
- /**
642
- * List User Logs
643
- *
644
- * Get the user activity logs list by its unique ID.
645
- *
646
- * @param {string} userId
647
- * @param {string[]} queries
648
- * @throws {AppwriteException}
649
- * @returns {Promise}
650
- */
651
- async listLogs(userId: string, queries?: string[]): Promise<Models.LogList> {
652
- if (typeof userId === 'undefined') {
653
- throw new AppwriteException('Missing required parameter: "userId"');
654
- }
655
-
656
- let path = '/users/{userId}/logs'.replace('{userId}', userId);
657
- let payload: Payload = {};
658
-
659
- if (typeof queries !== 'undefined') {
660
- payload['queries'] = queries;
661
- }
662
-
663
- const uri = new URL(this.client.config.endpoint + path);
664
- return await this.client.call('get', uri, {
665
- 'content-type': 'application/json',
666
- }, payload);
667
- }
668
-
669
- /**
670
- * List User Memberships
671
- *
672
- * Get the user membership list by its unique ID.
673
- *
674
- * @param {string} userId
675
- * @throws {AppwriteException}
676
- * @returns {Promise}
677
- */
678
- async listMemberships(userId: string): Promise<Models.MembershipList> {
679
- if (typeof userId === 'undefined') {
680
- throw new AppwriteException('Missing required parameter: "userId"');
681
- }
682
-
683
- let path = '/users/{userId}/memberships'.replace('{userId}', userId);
684
- let payload: Payload = {};
685
-
686
- const uri = new URL(this.client.config.endpoint + path);
687
- return await this.client.call('get', uri, {
688
- 'content-type': 'application/json',
689
- }, payload);
690
- }
691
-
692
- /**
693
- * Update Name
694
- *
695
- * Update the user name by its unique ID.
696
- *
697
- * @param {string} userId
698
- * @param {string} name
699
- * @throws {AppwriteException}
700
- * @returns {Promise}
701
- */
702
- async updateName<Preferences extends Models.Preferences>(userId: string, name: string): Promise<Models.User<Preferences>> {
703
- if (typeof userId === 'undefined') {
704
- throw new AppwriteException('Missing required parameter: "userId"');
705
- }
706
-
707
- if (typeof name === 'undefined') {
708
- throw new AppwriteException('Missing required parameter: "name"');
709
- }
710
-
711
- let path = '/users/{userId}/name'.replace('{userId}', userId);
712
- let payload: Payload = {};
713
-
714
- if (typeof name !== 'undefined') {
715
- payload['name'] = name;
716
- }
717
-
718
- const uri = new URL(this.client.config.endpoint + path);
719
- return await this.client.call('patch', uri, {
720
- 'content-type': 'application/json',
721
- }, payload);
722
- }
723
-
724
- /**
725
- * Update Password
726
- *
727
- * Update the user password by its unique ID.
728
- *
729
- * @param {string} userId
730
- * @param {string} password
731
- * @throws {AppwriteException}
732
- * @returns {Promise}
733
- */
734
- async updatePassword<Preferences extends Models.Preferences>(userId: string, password: string): Promise<Models.User<Preferences>> {
735
- if (typeof userId === 'undefined') {
736
- throw new AppwriteException('Missing required parameter: "userId"');
737
- }
738
-
739
- if (typeof password === 'undefined') {
740
- throw new AppwriteException('Missing required parameter: "password"');
741
- }
742
-
743
- let path = '/users/{userId}/password'.replace('{userId}', userId);
744
- let payload: Payload = {};
745
-
746
- if (typeof password !== 'undefined') {
747
- payload['password'] = password;
748
- }
749
-
750
- const uri = new URL(this.client.config.endpoint + path);
751
- return await this.client.call('patch', uri, {
752
- 'content-type': 'application/json',
753
- }, payload);
754
- }
755
-
756
- /**
757
- * Update Phone
758
- *
759
- * Update the user phone by its unique ID.
760
- *
761
- * @param {string} userId
762
- * @param {string} number
763
- * @throws {AppwriteException}
764
- * @returns {Promise}
765
- */
766
- async updatePhone<Preferences extends Models.Preferences>(userId: string, number: string): Promise<Models.User<Preferences>> {
767
- if (typeof userId === 'undefined') {
768
- throw new AppwriteException('Missing required parameter: "userId"');
769
- }
770
-
771
- if (typeof number === 'undefined') {
772
- throw new AppwriteException('Missing required parameter: "number"');
773
- }
774
-
775
- let path = '/users/{userId}/phone'.replace('{userId}', userId);
776
- let payload: Payload = {};
777
-
778
- if (typeof number !== 'undefined') {
779
- payload['number'] = number;
780
- }
781
-
782
- const uri = new URL(this.client.config.endpoint + path);
783
- return await this.client.call('patch', uri, {
784
- 'content-type': 'application/json',
785
- }, payload);
786
- }
787
-
788
- /**
789
- * Get User Preferences
790
- *
791
- * Get the user preferences by its unique ID.
792
- *
793
- * @param {string} userId
794
- * @throws {AppwriteException}
795
- * @returns {Promise}
796
- */
797
- async getPrefs<Preferences extends Models.Preferences>(userId: string): Promise<Preferences> {
798
- if (typeof userId === 'undefined') {
799
- throw new AppwriteException('Missing required parameter: "userId"');
800
- }
801
-
802
- let path = '/users/{userId}/prefs'.replace('{userId}', userId);
803
- let payload: Payload = {};
804
-
805
- const uri = new URL(this.client.config.endpoint + path);
806
- return await this.client.call('get', uri, {
807
- 'content-type': 'application/json',
808
- }, payload);
809
- }
810
-
811
- /**
812
- * Update User Preferences
813
- *
814
- * Update the user preferences by its unique ID. The object you pass is stored
815
- * as is, and replaces any previous value. The maximum allowed prefs size is
816
- * 64kB and throws error if exceeded.
817
- *
818
- * @param {string} userId
819
- * @param {object} prefs
820
- * @throws {AppwriteException}
821
- * @returns {Promise}
822
- */
823
- async updatePrefs<Preferences extends Models.Preferences>(userId: string, prefs: object): Promise<Preferences> {
824
- if (typeof userId === 'undefined') {
825
- throw new AppwriteException('Missing required parameter: "userId"');
826
- }
827
-
828
- if (typeof prefs === 'undefined') {
829
- throw new AppwriteException('Missing required parameter: "prefs"');
830
- }
831
-
832
- let path = '/users/{userId}/prefs'.replace('{userId}', userId);
833
- let payload: Payload = {};
834
-
835
- if (typeof prefs !== 'undefined') {
836
- payload['prefs'] = prefs;
837
- }
838
-
839
- const uri = new URL(this.client.config.endpoint + path);
840
- return await this.client.call('patch', uri, {
841
- 'content-type': 'application/json',
842
- }, payload);
843
- }
844
-
845
- /**
846
- * List User Sessions
847
- *
848
- * Get the user sessions list by its unique ID.
849
- *
850
- * @param {string} userId
851
- * @throws {AppwriteException}
852
- * @returns {Promise}
853
- */
854
- async listSessions(userId: string): Promise<Models.SessionList> {
855
- if (typeof userId === 'undefined') {
856
- throw new AppwriteException('Missing required parameter: "userId"');
857
- }
858
-
859
- let path = '/users/{userId}/sessions'.replace('{userId}', userId);
860
- let payload: Payload = {};
861
-
862
- const uri = new URL(this.client.config.endpoint + path);
863
- return await this.client.call('get', uri, {
864
- 'content-type': 'application/json',
865
- }, payload);
866
- }
867
-
868
- /**
869
- * Delete User Sessions
870
- *
871
- * Delete all user's sessions by using the user's unique ID.
872
- *
873
- * @param {string} userId
874
- * @throws {AppwriteException}
875
- * @returns {Promise}
876
- */
877
- async deleteSessions(userId: string): Promise<{}> {
878
- if (typeof userId === 'undefined') {
879
- throw new AppwriteException('Missing required parameter: "userId"');
880
- }
881
-
882
- let path = '/users/{userId}/sessions'.replace('{userId}', userId);
883
- let payload: Payload = {};
884
-
885
- const uri = new URL(this.client.config.endpoint + path);
886
- return await this.client.call('delete', uri, {
887
- 'content-type': 'application/json',
888
- }, payload);
889
- }
890
-
891
- /**
892
- * Delete User Session
893
- *
894
- * Delete a user sessions by its unique ID.
895
- *
896
- * @param {string} userId
897
- * @param {string} sessionId
898
- * @throws {AppwriteException}
899
- * @returns {Promise}
900
- */
901
- async deleteSession(userId: string, sessionId: string): Promise<{}> {
902
- if (typeof userId === 'undefined') {
903
- throw new AppwriteException('Missing required parameter: "userId"');
904
- }
905
-
906
- if (typeof sessionId === 'undefined') {
907
- throw new AppwriteException('Missing required parameter: "sessionId"');
908
- }
909
-
910
- let path = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
911
- let payload: Payload = {};
912
-
913
- const uri = new URL(this.client.config.endpoint + path);
914
- return await this.client.call('delete', uri, {
915
- 'content-type': 'application/json',
916
- }, payload);
917
- }
918
-
919
- /**
920
- * Update User Status
921
- *
922
- * Update the user status by its unique ID. Use this endpoint as an
923
- * alternative to deleting a user if you want to keep user's ID reserved.
924
- *
925
- * @param {string} userId
926
- * @param {boolean} status
927
- * @throws {AppwriteException}
928
- * @returns {Promise}
929
- */
930
- async updateStatus<Preferences extends Models.Preferences>(userId: string, status: boolean): Promise<Models.User<Preferences>> {
931
- if (typeof userId === 'undefined') {
932
- throw new AppwriteException('Missing required parameter: "userId"');
933
- }
934
-
935
- if (typeof status === 'undefined') {
936
- throw new AppwriteException('Missing required parameter: "status"');
937
- }
938
-
939
- let path = '/users/{userId}/status'.replace('{userId}', userId);
940
- let payload: Payload = {};
941
-
942
- if (typeof status !== 'undefined') {
943
- payload['status'] = status;
944
- }
945
-
946
- const uri = new URL(this.client.config.endpoint + path);
947
- return await this.client.call('patch', uri, {
948
- 'content-type': 'application/json',
949
- }, payload);
950
- }
951
-
952
- /**
953
- * Update Email Verification
954
- *
955
- * Update the user email verification status by its unique ID.
956
- *
957
- * @param {string} userId
958
- * @param {boolean} emailVerification
959
- * @throws {AppwriteException}
960
- * @returns {Promise}
961
- */
962
- async updateEmailVerification<Preferences extends Models.Preferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>> {
963
- if (typeof userId === 'undefined') {
964
- throw new AppwriteException('Missing required parameter: "userId"');
965
- }
966
-
967
- if (typeof emailVerification === 'undefined') {
968
- throw new AppwriteException('Missing required parameter: "emailVerification"');
969
- }
970
-
971
- let path = '/users/{userId}/verification'.replace('{userId}', userId);
972
- let payload: Payload = {};
973
-
974
- if (typeof emailVerification !== 'undefined') {
975
- payload['emailVerification'] = emailVerification;
976
- }
977
-
978
- const uri = new URL(this.client.config.endpoint + path);
979
- return await this.client.call('patch', uri, {
980
- 'content-type': 'application/json',
981
- }, payload);
982
- }
983
-
984
- /**
985
- * Update Phone Verification
986
- *
987
- * Update the user phone verification status by its unique ID.
988
- *
989
- * @param {string} userId
990
- * @param {boolean} phoneVerification
991
- * @throws {AppwriteException}
992
- * @returns {Promise}
993
- */
994
- async updatePhoneVerification<Preferences extends Models.Preferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>> {
995
- if (typeof userId === 'undefined') {
996
- throw new AppwriteException('Missing required parameter: "userId"');
997
- }
998
-
999
- if (typeof phoneVerification === 'undefined') {
1000
- throw new AppwriteException('Missing required parameter: "phoneVerification"');
1001
- }
1002
-
1003
- let path = '/users/{userId}/verification/phone'.replace('{userId}', userId);
1004
- let payload: Payload = {};
1005
-
1006
- if (typeof phoneVerification !== 'undefined') {
1007
- payload['phoneVerification'] = phoneVerification;
1008
- }
1009
-
1010
- const uri = new URL(this.client.config.endpoint + path);
1011
- return await this.client.call('patch', uri, {
1012
- 'content-type': 'application/json',
1013
- }, payload);
13
+ /**
14
+ * List users
15
+ *
16
+ * Get a list of all the project's users. You can use the query params to
17
+ * filter your results.
18
+ *
19
+ * @param {string[]} queries
20
+ * @param {string} search
21
+ * @throws {AppwriteException}
22
+ * @returns {Promise}
23
+ */
24
+ async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.UserList<Preferences>> {
25
+ const apiPath = '/users';
26
+ const payload: Payload = {};
27
+
28
+ if (typeof queries !== 'undefined') {
29
+ payload['queries'] = queries;
1014
30
  }
31
+
32
+ if (typeof search !== 'undefined') {
33
+ payload['search'] = search;
34
+ }
35
+
36
+ const uri = new URL(this.client.config.endpoint + apiPath);
37
+ return await this.client.call('get', uri, {
38
+ 'content-type': 'application/json',
39
+ }, payload);
40
+ }
41
+
42
+ /**
43
+ * Create user
44
+ *
45
+ * Create a new user.
46
+ *
47
+ * @param {string} userId
48
+ * @param {string} email
49
+ * @param {string} phone
50
+ * @param {string} password
51
+ * @param {string} name
52
+ * @throws {AppwriteException}
53
+ * @returns {Promise}
54
+ */
55
+ async create<Preferences extends Models.Preferences>(userId: string, email?: string, phone?: string, password?: string, name?: string): Promise<Models.User<Preferences>> {
56
+ if (typeof userId === 'undefined') {
57
+ throw new AppwriteException('Missing required parameter: "userId"');
58
+ }
59
+
60
+ const apiPath = '/users';
61
+ const payload: Payload = {};
62
+
63
+ if (typeof userId !== 'undefined') {
64
+ payload['userId'] = userId;
65
+ }
66
+
67
+ if (typeof email !== 'undefined') {
68
+ payload['email'] = email;
69
+ }
70
+
71
+ if (typeof phone !== 'undefined') {
72
+ payload['phone'] = phone;
73
+ }
74
+
75
+ if (typeof password !== 'undefined') {
76
+ payload['password'] = password;
77
+ }
78
+
79
+ if (typeof name !== 'undefined') {
80
+ payload['name'] = name;
81
+ }
82
+
83
+ const uri = new URL(this.client.config.endpoint + apiPath);
84
+ return await this.client.call('post', uri, {
85
+ 'content-type': 'application/json',
86
+ }, payload);
87
+ }
88
+
89
+ /**
90
+ * Create user with Argon2 password
91
+ *
92
+ * Create a new user. Password provided must be hashed with the
93
+ * [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST
94
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
95
+ * create users with a plain text password.
96
+ *
97
+ * @param {string} userId
98
+ * @param {string} email
99
+ * @param {string} password
100
+ * @param {string} name
101
+ * @throws {AppwriteException}
102
+ * @returns {Promise}
103
+ */
104
+ async createArgon2User<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
105
+ if (typeof userId === 'undefined') {
106
+ throw new AppwriteException('Missing required parameter: "userId"');
107
+ }
108
+
109
+ if (typeof email === 'undefined') {
110
+ throw new AppwriteException('Missing required parameter: "email"');
111
+ }
112
+
113
+ if (typeof password === 'undefined') {
114
+ throw new AppwriteException('Missing required parameter: "password"');
115
+ }
116
+
117
+ const apiPath = '/users/argon2';
118
+ const payload: Payload = {};
119
+
120
+ if (typeof userId !== 'undefined') {
121
+ payload['userId'] = userId;
122
+ }
123
+
124
+ if (typeof email !== 'undefined') {
125
+ payload['email'] = email;
126
+ }
127
+
128
+ if (typeof password !== 'undefined') {
129
+ payload['password'] = password;
130
+ }
131
+
132
+ if (typeof name !== 'undefined') {
133
+ payload['name'] = name;
134
+ }
135
+
136
+ const uri = new URL(this.client.config.endpoint + apiPath);
137
+ return await this.client.call('post', uri, {
138
+ 'content-type': 'application/json',
139
+ }, payload);
140
+ }
141
+
142
+ /**
143
+ * Create user with bcrypt password
144
+ *
145
+ * Create a new user. Password provided must be hashed with the
146
+ * [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST
147
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
148
+ * create users with a plain text password.
149
+ *
150
+ * @param {string} userId
151
+ * @param {string} email
152
+ * @param {string} password
153
+ * @param {string} name
154
+ * @throws {AppwriteException}
155
+ * @returns {Promise}
156
+ */
157
+ async createBcryptUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
158
+ if (typeof userId === 'undefined') {
159
+ throw new AppwriteException('Missing required parameter: "userId"');
160
+ }
161
+
162
+ if (typeof email === 'undefined') {
163
+ throw new AppwriteException('Missing required parameter: "email"');
164
+ }
165
+
166
+ if (typeof password === 'undefined') {
167
+ throw new AppwriteException('Missing required parameter: "password"');
168
+ }
169
+
170
+ const apiPath = '/users/bcrypt';
171
+ const payload: Payload = {};
172
+
173
+ if (typeof userId !== 'undefined') {
174
+ payload['userId'] = userId;
175
+ }
176
+
177
+ if (typeof email !== 'undefined') {
178
+ payload['email'] = email;
179
+ }
180
+
181
+ if (typeof password !== 'undefined') {
182
+ payload['password'] = password;
183
+ }
184
+
185
+ if (typeof name !== 'undefined') {
186
+ payload['name'] = name;
187
+ }
188
+
189
+ const uri = new URL(this.client.config.endpoint + apiPath);
190
+ return await this.client.call('post', uri, {
191
+ 'content-type': 'application/json',
192
+ }, payload);
193
+ }
194
+
195
+ /**
196
+ * List Identities
197
+ *
198
+ * Get identities for all users.
199
+ *
200
+ * @param {string} queries
201
+ * @param {string} search
202
+ * @throws {AppwriteException}
203
+ * @returns {Promise}
204
+ */
205
+ async listIdentities(queries?: string, search?: string): Promise<Models.IdentityList> {
206
+ const apiPath = '/users/identities';
207
+ const payload: Payload = {};
208
+
209
+ if (typeof queries !== 'undefined') {
210
+ payload['queries'] = queries;
211
+ }
212
+
213
+ if (typeof search !== 'undefined') {
214
+ payload['search'] = search;
215
+ }
216
+
217
+ const uri = new URL(this.client.config.endpoint + apiPath);
218
+ return await this.client.call('get', uri, {
219
+ 'content-type': 'application/json',
220
+ }, payload);
221
+ }
222
+
223
+ /**
224
+ * Delete Identity
225
+ *
226
+ * Delete an identity by its unique ID.
227
+ *
228
+ * @param {string} identityId
229
+ * @throws {AppwriteException}
230
+ * @returns {Promise}
231
+ */
232
+ async deleteIdentity(identityId: string): Promise<{}> {
233
+ if (typeof identityId === 'undefined') {
234
+ throw new AppwriteException('Missing required parameter: "identityId"');
235
+ }
236
+
237
+ const apiPath = '/users/identities/{identityId}'.replace('{identityId}', identityId);
238
+ const payload: Payload = {};
239
+
240
+ const uri = new URL(this.client.config.endpoint + apiPath);
241
+ return await this.client.call('delete', uri, {
242
+ 'content-type': 'application/json',
243
+ }, payload);
244
+ }
245
+
246
+ /**
247
+ * Create user with MD5 password
248
+ *
249
+ * Create a new user. Password provided must be hashed with the
250
+ * [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST
251
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
252
+ * create users with a plain text password.
253
+ *
254
+ * @param {string} userId
255
+ * @param {string} email
256
+ * @param {string} password
257
+ * @param {string} name
258
+ * @throws {AppwriteException}
259
+ * @returns {Promise}
260
+ */
261
+ async createMD5User<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
262
+ if (typeof userId === 'undefined') {
263
+ throw new AppwriteException('Missing required parameter: "userId"');
264
+ }
265
+
266
+ if (typeof email === 'undefined') {
267
+ throw new AppwriteException('Missing required parameter: "email"');
268
+ }
269
+
270
+ if (typeof password === 'undefined') {
271
+ throw new AppwriteException('Missing required parameter: "password"');
272
+ }
273
+
274
+ const apiPath = '/users/md5';
275
+ const payload: Payload = {};
276
+
277
+ if (typeof userId !== 'undefined') {
278
+ payload['userId'] = userId;
279
+ }
280
+
281
+ if (typeof email !== 'undefined') {
282
+ payload['email'] = email;
283
+ }
284
+
285
+ if (typeof password !== 'undefined') {
286
+ payload['password'] = password;
287
+ }
288
+
289
+ if (typeof name !== 'undefined') {
290
+ payload['name'] = name;
291
+ }
292
+
293
+ const uri = new URL(this.client.config.endpoint + apiPath);
294
+ return await this.client.call('post', uri, {
295
+ 'content-type': 'application/json',
296
+ }, payload);
297
+ }
298
+
299
+ /**
300
+ * Create user with PHPass password
301
+ *
302
+ * Create a new user. Password provided must be hashed with the
303
+ * [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST
304
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
305
+ * create users with a plain text password.
306
+ *
307
+ * @param {string} userId
308
+ * @param {string} email
309
+ * @param {string} password
310
+ * @param {string} name
311
+ * @throws {AppwriteException}
312
+ * @returns {Promise}
313
+ */
314
+ async createPHPassUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, name?: string): Promise<Models.User<Preferences>> {
315
+ if (typeof userId === 'undefined') {
316
+ throw new AppwriteException('Missing required parameter: "userId"');
317
+ }
318
+
319
+ if (typeof email === 'undefined') {
320
+ throw new AppwriteException('Missing required parameter: "email"');
321
+ }
322
+
323
+ if (typeof password === 'undefined') {
324
+ throw new AppwriteException('Missing required parameter: "password"');
325
+ }
326
+
327
+ const apiPath = '/users/phpass';
328
+ const payload: Payload = {};
329
+
330
+ if (typeof userId !== 'undefined') {
331
+ payload['userId'] = userId;
332
+ }
333
+
334
+ if (typeof email !== 'undefined') {
335
+ payload['email'] = email;
336
+ }
337
+
338
+ if (typeof password !== 'undefined') {
339
+ payload['password'] = password;
340
+ }
341
+
342
+ if (typeof name !== 'undefined') {
343
+ payload['name'] = name;
344
+ }
345
+
346
+ const uri = new URL(this.client.config.endpoint + apiPath);
347
+ return await this.client.call('post', uri, {
348
+ 'content-type': 'application/json',
349
+ }, payload);
350
+ }
351
+
352
+ /**
353
+ * Create user with Scrypt password
354
+ *
355
+ * Create a new user. Password provided must be hashed with the
356
+ * [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST
357
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
358
+ * create users with a plain text password.
359
+ *
360
+ * @param {string} userId
361
+ * @param {string} email
362
+ * @param {string} password
363
+ * @param {string} passwordSalt
364
+ * @param {number} passwordCpu
365
+ * @param {number} passwordMemory
366
+ * @param {number} passwordParallel
367
+ * @param {number} passwordLength
368
+ * @param {string} name
369
+ * @throws {AppwriteException}
370
+ * @returns {Promise}
371
+ */
372
+ async createScryptUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordSalt: string, passwordCpu: number, passwordMemory: number, passwordParallel: number, passwordLength: number, name?: string): Promise<Models.User<Preferences>> {
373
+ if (typeof userId === 'undefined') {
374
+ throw new AppwriteException('Missing required parameter: "userId"');
375
+ }
376
+
377
+ if (typeof email === 'undefined') {
378
+ throw new AppwriteException('Missing required parameter: "email"');
379
+ }
380
+
381
+ if (typeof password === 'undefined') {
382
+ throw new AppwriteException('Missing required parameter: "password"');
383
+ }
384
+
385
+ if (typeof passwordSalt === 'undefined') {
386
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
387
+ }
388
+
389
+ if (typeof passwordCpu === 'undefined') {
390
+ throw new AppwriteException('Missing required parameter: "passwordCpu"');
391
+ }
392
+
393
+ if (typeof passwordMemory === 'undefined') {
394
+ throw new AppwriteException('Missing required parameter: "passwordMemory"');
395
+ }
396
+
397
+ if (typeof passwordParallel === 'undefined') {
398
+ throw new AppwriteException('Missing required parameter: "passwordParallel"');
399
+ }
400
+
401
+ if (typeof passwordLength === 'undefined') {
402
+ throw new AppwriteException('Missing required parameter: "passwordLength"');
403
+ }
404
+
405
+ const apiPath = '/users/scrypt';
406
+ const payload: Payload = {};
407
+
408
+ if (typeof userId !== 'undefined') {
409
+ payload['userId'] = userId;
410
+ }
411
+
412
+ if (typeof email !== 'undefined') {
413
+ payload['email'] = email;
414
+ }
415
+
416
+ if (typeof password !== 'undefined') {
417
+ payload['password'] = password;
418
+ }
419
+
420
+ if (typeof passwordSalt !== 'undefined') {
421
+ payload['passwordSalt'] = passwordSalt;
422
+ }
423
+
424
+ if (typeof passwordCpu !== 'undefined') {
425
+ payload['passwordCpu'] = passwordCpu;
426
+ }
427
+
428
+ if (typeof passwordMemory !== 'undefined') {
429
+ payload['passwordMemory'] = passwordMemory;
430
+ }
431
+
432
+ if (typeof passwordParallel !== 'undefined') {
433
+ payload['passwordParallel'] = passwordParallel;
434
+ }
435
+
436
+ if (typeof passwordLength !== 'undefined') {
437
+ payload['passwordLength'] = passwordLength;
438
+ }
439
+
440
+ if (typeof name !== 'undefined') {
441
+ payload['name'] = name;
442
+ }
443
+
444
+ const uri = new URL(this.client.config.endpoint + apiPath);
445
+ return await this.client.call('post', uri, {
446
+ 'content-type': 'application/json',
447
+ }, payload);
448
+ }
449
+
450
+ /**
451
+ * Create user with Scrypt modified password
452
+ *
453
+ * Create a new user. Password provided must be hashed with the [Scrypt
454
+ * Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc)
455
+ * algorithm. Use the [POST
456
+ * /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to
457
+ * create users with a plain text password.
458
+ *
459
+ * @param {string} userId
460
+ * @param {string} email
461
+ * @param {string} password
462
+ * @param {string} passwordSalt
463
+ * @param {string} passwordSaltSeparator
464
+ * @param {string} passwordSignerKey
465
+ * @param {string} name
466
+ * @throws {AppwriteException}
467
+ * @returns {Promise}
468
+ */
469
+ async createScryptModifiedUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordSalt: string, passwordSaltSeparator: string, passwordSignerKey: string, name?: string): Promise<Models.User<Preferences>> {
470
+ if (typeof userId === 'undefined') {
471
+ throw new AppwriteException('Missing required parameter: "userId"');
472
+ }
473
+
474
+ if (typeof email === 'undefined') {
475
+ throw new AppwriteException('Missing required parameter: "email"');
476
+ }
477
+
478
+ if (typeof password === 'undefined') {
479
+ throw new AppwriteException('Missing required parameter: "password"');
480
+ }
481
+
482
+ if (typeof passwordSalt === 'undefined') {
483
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
484
+ }
485
+
486
+ if (typeof passwordSaltSeparator === 'undefined') {
487
+ throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"');
488
+ }
489
+
490
+ if (typeof passwordSignerKey === 'undefined') {
491
+ throw new AppwriteException('Missing required parameter: "passwordSignerKey"');
492
+ }
493
+
494
+ const apiPath = '/users/scrypt-modified';
495
+ const payload: Payload = {};
496
+
497
+ if (typeof userId !== 'undefined') {
498
+ payload['userId'] = userId;
499
+ }
500
+
501
+ if (typeof email !== 'undefined') {
502
+ payload['email'] = email;
503
+ }
504
+
505
+ if (typeof password !== 'undefined') {
506
+ payload['password'] = password;
507
+ }
508
+
509
+ if (typeof passwordSalt !== 'undefined') {
510
+ payload['passwordSalt'] = passwordSalt;
511
+ }
512
+
513
+ if (typeof passwordSaltSeparator !== 'undefined') {
514
+ payload['passwordSaltSeparator'] = passwordSaltSeparator;
515
+ }
516
+
517
+ if (typeof passwordSignerKey !== 'undefined') {
518
+ payload['passwordSignerKey'] = passwordSignerKey;
519
+ }
520
+
521
+ if (typeof name !== 'undefined') {
522
+ payload['name'] = name;
523
+ }
524
+
525
+ const uri = new URL(this.client.config.endpoint + apiPath);
526
+ return await this.client.call('post', uri, {
527
+ 'content-type': 'application/json',
528
+ }, payload);
529
+ }
530
+
531
+ /**
532
+ * Create user with SHA password
533
+ *
534
+ * Create a new user. Password provided must be hashed with the
535
+ * [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use
536
+ * the [POST /users](https://appwrite.io/docs/server/users#usersCreate)
537
+ * endpoint to create users with a plain text password.
538
+ *
539
+ * @param {string} userId
540
+ * @param {string} email
541
+ * @param {string} password
542
+ * @param {string} passwordVersion
543
+ * @param {string} name
544
+ * @throws {AppwriteException}
545
+ * @returns {Promise}
546
+ */
547
+ async createSHAUser<Preferences extends Models.Preferences>(userId: string, email: string, password: string, passwordVersion?: string, name?: string): Promise<Models.User<Preferences>> {
548
+ if (typeof userId === 'undefined') {
549
+ throw new AppwriteException('Missing required parameter: "userId"');
550
+ }
551
+
552
+ if (typeof email === 'undefined') {
553
+ throw new AppwriteException('Missing required parameter: "email"');
554
+ }
555
+
556
+ if (typeof password === 'undefined') {
557
+ throw new AppwriteException('Missing required parameter: "password"');
558
+ }
559
+
560
+ const apiPath = '/users/sha';
561
+ const payload: Payload = {};
562
+
563
+ if (typeof userId !== 'undefined') {
564
+ payload['userId'] = userId;
565
+ }
566
+
567
+ if (typeof email !== 'undefined') {
568
+ payload['email'] = email;
569
+ }
570
+
571
+ if (typeof password !== 'undefined') {
572
+ payload['password'] = password;
573
+ }
574
+
575
+ if (typeof passwordVersion !== 'undefined') {
576
+ payload['passwordVersion'] = passwordVersion;
577
+ }
578
+
579
+ if (typeof name !== 'undefined') {
580
+ payload['name'] = name;
581
+ }
582
+
583
+ const uri = new URL(this.client.config.endpoint + apiPath);
584
+ return await this.client.call('post', uri, {
585
+ 'content-type': 'application/json',
586
+ }, payload);
587
+ }
588
+
589
+ /**
590
+ * Get usage stats for the users API
591
+ *
592
+ *
593
+ * @param {string} range
594
+ * @throws {AppwriteException}
595
+ * @returns {Promise}
596
+ */
597
+ async getUsage(range?: string): Promise<Models.UsageUsers> {
598
+ const apiPath = '/users/usage';
599
+ const payload: Payload = {};
600
+
601
+ if (typeof range !== 'undefined') {
602
+ payload['range'] = range;
603
+ }
604
+
605
+ const uri = new URL(this.client.config.endpoint + apiPath);
606
+ return await this.client.call('get', uri, {
607
+ 'content-type': 'application/json',
608
+ }, payload);
609
+ }
610
+
611
+ /**
612
+ * Get user
613
+ *
614
+ * Get a user by its unique ID.
615
+ *
616
+ * @param {string} userId
617
+ * @throws {AppwriteException}
618
+ * @returns {Promise}
619
+ */
620
+ async get<Preferences extends Models.Preferences>(userId: string): Promise<Models.User<Preferences>> {
621
+ if (typeof userId === 'undefined') {
622
+ throw new AppwriteException('Missing required parameter: "userId"');
623
+ }
624
+
625
+ const apiPath = '/users/{userId}'.replace('{userId}', userId);
626
+ const payload: Payload = {};
627
+
628
+ const uri = new URL(this.client.config.endpoint + apiPath);
629
+ return await this.client.call('get', uri, {
630
+ 'content-type': 'application/json',
631
+ }, payload);
632
+ }
633
+
634
+ /**
635
+ * Delete user
636
+ *
637
+ * Delete a user by its unique ID, thereby releasing it's ID. Since ID is
638
+ * released and can be reused, all user-related resources like documents or
639
+ * storage files should be deleted before user deletion. If you want to keep
640
+ * ID reserved, use the
641
+ * [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus)
642
+ * endpoint instead.
643
+ *
644
+ * @param {string} userId
645
+ * @throws {AppwriteException}
646
+ * @returns {Promise}
647
+ */
648
+ async delete(userId: string): Promise<{}> {
649
+ if (typeof userId === 'undefined') {
650
+ throw new AppwriteException('Missing required parameter: "userId"');
651
+ }
652
+
653
+ const apiPath = '/users/{userId}'.replace('{userId}', userId);
654
+ const payload: Payload = {};
655
+
656
+ const uri = new URL(this.client.config.endpoint + apiPath);
657
+ return await this.client.call('delete', uri, {
658
+ 'content-type': 'application/json',
659
+ }, payload);
660
+ }
661
+
662
+ /**
663
+ * Update email
664
+ *
665
+ * Update the user email by its unique ID.
666
+ *
667
+ * @param {string} userId
668
+ * @param {string} email
669
+ * @throws {AppwriteException}
670
+ * @returns {Promise}
671
+ */
672
+ async updateEmail<Preferences extends Models.Preferences>(userId: string, email: string): Promise<Models.User<Preferences>> {
673
+ if (typeof userId === 'undefined') {
674
+ throw new AppwriteException('Missing required parameter: "userId"');
675
+ }
676
+
677
+ if (typeof email === 'undefined') {
678
+ throw new AppwriteException('Missing required parameter: "email"');
679
+ }
680
+
681
+ const apiPath = '/users/{userId}/email'.replace('{userId}', userId);
682
+ const payload: Payload = {};
683
+
684
+ if (typeof email !== 'undefined') {
685
+ payload['email'] = email;
686
+ }
687
+
688
+ const uri = new URL(this.client.config.endpoint + apiPath);
689
+ return await this.client.call('patch', uri, {
690
+ 'content-type': 'application/json',
691
+ }, payload);
692
+ }
693
+
694
+ /**
695
+ * Update user labels
696
+ *
697
+ * Update the user labels by its unique ID.
698
+ *
699
+ * Labels can be used to grant access to resources. While teams are a way for
700
+ * user's to share access to a resource, labels can be defined by the
701
+ * developer to grant access without an invitation. See the [Permissions
702
+ * docs](https://appwrite.io/docs/permissions) for more info.
703
+ *
704
+ * @param {string} userId
705
+ * @param {string[]} labels
706
+ * @throws {AppwriteException}
707
+ * @returns {Promise}
708
+ */
709
+ async updateLabels<Preferences extends Models.Preferences>(userId: string, labels: string[]): Promise<Models.User<Preferences>> {
710
+ if (typeof userId === 'undefined') {
711
+ throw new AppwriteException('Missing required parameter: "userId"');
712
+ }
713
+
714
+ if (typeof labels === 'undefined') {
715
+ throw new AppwriteException('Missing required parameter: "labels"');
716
+ }
717
+
718
+ const apiPath = '/users/{userId}/labels'.replace('{userId}', userId);
719
+ const payload: Payload = {};
720
+
721
+ if (typeof labels !== 'undefined') {
722
+ payload['labels'] = labels;
723
+ }
724
+
725
+ const uri = new URL(this.client.config.endpoint + apiPath);
726
+ return await this.client.call('put', uri, {
727
+ 'content-type': 'application/json',
728
+ }, payload);
729
+ }
730
+
731
+ /**
732
+ * List user logs
733
+ *
734
+ * Get the user activity logs list by its unique ID.
735
+ *
736
+ * @param {string} userId
737
+ * @param {string[]} queries
738
+ * @throws {AppwriteException}
739
+ * @returns {Promise}
740
+ */
741
+ async listLogs(userId: string, queries?: string[]): Promise<Models.LogList> {
742
+ if (typeof userId === 'undefined') {
743
+ throw new AppwriteException('Missing required parameter: "userId"');
744
+ }
745
+
746
+ const apiPath = '/users/{userId}/logs'.replace('{userId}', userId);
747
+ const payload: Payload = {};
748
+
749
+ if (typeof queries !== 'undefined') {
750
+ payload['queries'] = queries;
751
+ }
752
+
753
+ const uri = new URL(this.client.config.endpoint + apiPath);
754
+ return await this.client.call('get', uri, {
755
+ 'content-type': 'application/json',
756
+ }, payload);
757
+ }
758
+
759
+ /**
760
+ * List user memberships
761
+ *
762
+ * Get the user membership list by its unique ID.
763
+ *
764
+ * @param {string} userId
765
+ * @throws {AppwriteException}
766
+ * @returns {Promise}
767
+ */
768
+ async listMemberships(userId: string): Promise<Models.MembershipList> {
769
+ if (typeof userId === 'undefined') {
770
+ throw new AppwriteException('Missing required parameter: "userId"');
771
+ }
772
+
773
+ const apiPath = '/users/{userId}/memberships'.replace('{userId}', userId);
774
+ const payload: Payload = {};
775
+
776
+ const uri = new URL(this.client.config.endpoint + apiPath);
777
+ return await this.client.call('get', uri, {
778
+ 'content-type': 'application/json',
779
+ }, payload);
780
+ }
781
+
782
+ /**
783
+ * Update name
784
+ *
785
+ * Update the user name by its unique ID.
786
+ *
787
+ * @param {string} userId
788
+ * @param {string} name
789
+ * @throws {AppwriteException}
790
+ * @returns {Promise}
791
+ */
792
+ async updateName<Preferences extends Models.Preferences>(userId: string, name: string): Promise<Models.User<Preferences>> {
793
+ if (typeof userId === 'undefined') {
794
+ throw new AppwriteException('Missing required parameter: "userId"');
795
+ }
796
+
797
+ if (typeof name === 'undefined') {
798
+ throw new AppwriteException('Missing required parameter: "name"');
799
+ }
800
+
801
+ const apiPath = '/users/{userId}/name'.replace('{userId}', userId);
802
+ const payload: Payload = {};
803
+
804
+ if (typeof name !== 'undefined') {
805
+ payload['name'] = name;
806
+ }
807
+
808
+ const uri = new URL(this.client.config.endpoint + apiPath);
809
+ return await this.client.call('patch', uri, {
810
+ 'content-type': 'application/json',
811
+ }, payload);
812
+ }
813
+
814
+ /**
815
+ * Update password
816
+ *
817
+ * Update the user password by its unique ID.
818
+ *
819
+ * @param {string} userId
820
+ * @param {string} password
821
+ * @throws {AppwriteException}
822
+ * @returns {Promise}
823
+ */
824
+ async updatePassword<Preferences extends Models.Preferences>(userId: string, password: string): Promise<Models.User<Preferences>> {
825
+ if (typeof userId === 'undefined') {
826
+ throw new AppwriteException('Missing required parameter: "userId"');
827
+ }
828
+
829
+ if (typeof password === 'undefined') {
830
+ throw new AppwriteException('Missing required parameter: "password"');
831
+ }
832
+
833
+ const apiPath = '/users/{userId}/password'.replace('{userId}', userId);
834
+ const payload: Payload = {};
835
+
836
+ if (typeof password !== 'undefined') {
837
+ payload['password'] = password;
838
+ }
839
+
840
+ const uri = new URL(this.client.config.endpoint + apiPath);
841
+ return await this.client.call('patch', uri, {
842
+ 'content-type': 'application/json',
843
+ }, payload);
844
+ }
845
+
846
+ /**
847
+ * Update phone
848
+ *
849
+ * Update the user phone by its unique ID.
850
+ *
851
+ * @param {string} userId
852
+ * @param {string} number
853
+ * @throws {AppwriteException}
854
+ * @returns {Promise}
855
+ */
856
+ async updatePhone<Preferences extends Models.Preferences>(userId: string, number: string): Promise<Models.User<Preferences>> {
857
+ if (typeof userId === 'undefined') {
858
+ throw new AppwriteException('Missing required parameter: "userId"');
859
+ }
860
+
861
+ if (typeof number === 'undefined') {
862
+ throw new AppwriteException('Missing required parameter: "number"');
863
+ }
864
+
865
+ const apiPath = '/users/{userId}/phone'.replace('{userId}', userId);
866
+ const payload: Payload = {};
867
+
868
+ if (typeof number !== 'undefined') {
869
+ payload['number'] = number;
870
+ }
871
+
872
+ const uri = new URL(this.client.config.endpoint + apiPath);
873
+ return await this.client.call('patch', uri, {
874
+ 'content-type': 'application/json',
875
+ }, payload);
876
+ }
877
+
878
+ /**
879
+ * Get user preferences
880
+ *
881
+ * Get the user preferences by its unique ID.
882
+ *
883
+ * @param {string} userId
884
+ * @throws {AppwriteException}
885
+ * @returns {Promise}
886
+ */
887
+ async getPrefs<Preferences extends Models.Preferences>(userId: string): Promise<Preferences> {
888
+ if (typeof userId === 'undefined') {
889
+ throw new AppwriteException('Missing required parameter: "userId"');
890
+ }
891
+
892
+ const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId);
893
+ const payload: Payload = {};
894
+
895
+ const uri = new URL(this.client.config.endpoint + apiPath);
896
+ return await this.client.call('get', uri, {
897
+ 'content-type': 'application/json',
898
+ }, payload);
899
+ }
900
+
901
+ /**
902
+ * Update user preferences
903
+ *
904
+ * Update the user preferences by its unique ID. The object you pass is stored
905
+ * as is, and replaces any previous value. The maximum allowed prefs size is
906
+ * 64kB and throws error if exceeded.
907
+ *
908
+ * @param {string} userId
909
+ * @param {object} prefs
910
+ * @throws {AppwriteException}
911
+ * @returns {Promise}
912
+ */
913
+ async updatePrefs<Preferences extends Models.Preferences>(userId: string, prefs: object): Promise<Preferences> {
914
+ if (typeof userId === 'undefined') {
915
+ throw new AppwriteException('Missing required parameter: "userId"');
916
+ }
917
+
918
+ if (typeof prefs === 'undefined') {
919
+ throw new AppwriteException('Missing required parameter: "prefs"');
920
+ }
921
+
922
+ const apiPath = '/users/{userId}/prefs'.replace('{userId}', userId);
923
+ const payload: Payload = {};
924
+
925
+ if (typeof prefs !== 'undefined') {
926
+ payload['prefs'] = prefs;
927
+ }
928
+
929
+ const uri = new URL(this.client.config.endpoint + apiPath);
930
+ return await this.client.call('patch', uri, {
931
+ 'content-type': 'application/json',
932
+ }, payload);
933
+ }
934
+
935
+ /**
936
+ * List user sessions
937
+ *
938
+ * Get the user sessions list by its unique ID.
939
+ *
940
+ * @param {string} userId
941
+ * @throws {AppwriteException}
942
+ * @returns {Promise}
943
+ */
944
+ async listSessions(userId: string): Promise<Models.SessionList> {
945
+ if (typeof userId === 'undefined') {
946
+ throw new AppwriteException('Missing required parameter: "userId"');
947
+ }
948
+
949
+ const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId);
950
+ const payload: Payload = {};
951
+
952
+ const uri = new URL(this.client.config.endpoint + apiPath);
953
+ return await this.client.call('get', uri, {
954
+ 'content-type': 'application/json',
955
+ }, payload);
956
+ }
957
+
958
+ /**
959
+ * Delete user sessions
960
+ *
961
+ * Delete all user's sessions by using the user's unique ID.
962
+ *
963
+ * @param {string} userId
964
+ * @throws {AppwriteException}
965
+ * @returns {Promise}
966
+ */
967
+ async deleteSessions(userId: string): Promise<{}> {
968
+ if (typeof userId === 'undefined') {
969
+ throw new AppwriteException('Missing required parameter: "userId"');
970
+ }
971
+
972
+ const apiPath = '/users/{userId}/sessions'.replace('{userId}', userId);
973
+ const payload: Payload = {};
974
+
975
+ const uri = new URL(this.client.config.endpoint + apiPath);
976
+ return await this.client.call('delete', uri, {
977
+ 'content-type': 'application/json',
978
+ }, payload);
979
+ }
980
+
981
+ /**
982
+ * Delete user session
983
+ *
984
+ * Delete a user sessions by its unique ID.
985
+ *
986
+ * @param {string} userId
987
+ * @param {string} sessionId
988
+ * @throws {AppwriteException}
989
+ * @returns {Promise}
990
+ */
991
+ async deleteSession(userId: string, sessionId: string): Promise<{}> {
992
+ if (typeof userId === 'undefined') {
993
+ throw new AppwriteException('Missing required parameter: "userId"');
994
+ }
995
+
996
+ if (typeof sessionId === 'undefined') {
997
+ throw new AppwriteException('Missing required parameter: "sessionId"');
998
+ }
999
+
1000
+ const apiPath = '/users/{userId}/sessions/{sessionId}'.replace('{userId}', userId).replace('{sessionId}', sessionId);
1001
+ const payload: Payload = {};
1002
+
1003
+ const uri = new URL(this.client.config.endpoint + apiPath);
1004
+ return await this.client.call('delete', uri, {
1005
+ 'content-type': 'application/json',
1006
+ }, payload);
1007
+ }
1008
+
1009
+ /**
1010
+ * Update user status
1011
+ *
1012
+ * Update the user status by its unique ID. Use this endpoint as an
1013
+ * alternative to deleting a user if you want to keep user's ID reserved.
1014
+ *
1015
+ * @param {string} userId
1016
+ * @param {boolean} status
1017
+ * @throws {AppwriteException}
1018
+ * @returns {Promise}
1019
+ */
1020
+ async updateStatus<Preferences extends Models.Preferences>(userId: string, status: boolean): Promise<Models.User<Preferences>> {
1021
+ if (typeof userId === 'undefined') {
1022
+ throw new AppwriteException('Missing required parameter: "userId"');
1023
+ }
1024
+
1025
+ if (typeof status === 'undefined') {
1026
+ throw new AppwriteException('Missing required parameter: "status"');
1027
+ }
1028
+
1029
+ const apiPath = '/users/{userId}/status'.replace('{userId}', userId);
1030
+ const payload: Payload = {};
1031
+
1032
+ if (typeof status !== 'undefined') {
1033
+ payload['status'] = status;
1034
+ }
1035
+
1036
+ const uri = new URL(this.client.config.endpoint + apiPath);
1037
+ return await this.client.call('patch', uri, {
1038
+ 'content-type': 'application/json',
1039
+ }, payload);
1040
+ }
1041
+
1042
+ /**
1043
+ * Update email verification
1044
+ *
1045
+ * Update the user email verification status by its unique ID.
1046
+ *
1047
+ * @param {string} userId
1048
+ * @param {boolean} emailVerification
1049
+ * @throws {AppwriteException}
1050
+ * @returns {Promise}
1051
+ */
1052
+ async updateEmailVerification<Preferences extends Models.Preferences>(userId: string, emailVerification: boolean): Promise<Models.User<Preferences>> {
1053
+ if (typeof userId === 'undefined') {
1054
+ throw new AppwriteException('Missing required parameter: "userId"');
1055
+ }
1056
+
1057
+ if (typeof emailVerification === 'undefined') {
1058
+ throw new AppwriteException('Missing required parameter: "emailVerification"');
1059
+ }
1060
+
1061
+ const apiPath = '/users/{userId}/verification'.replace('{userId}', userId);
1062
+ const payload: Payload = {};
1063
+
1064
+ if (typeof emailVerification !== 'undefined') {
1065
+ payload['emailVerification'] = emailVerification;
1066
+ }
1067
+
1068
+ const uri = new URL(this.client.config.endpoint + apiPath);
1069
+ return await this.client.call('patch', uri, {
1070
+ 'content-type': 'application/json',
1071
+ }, payload);
1072
+ }
1073
+
1074
+ /**
1075
+ * Update phone verification
1076
+ *
1077
+ * Update the user phone verification status by its unique ID.
1078
+ *
1079
+ * @param {string} userId
1080
+ * @param {boolean} phoneVerification
1081
+ * @throws {AppwriteException}
1082
+ * @returns {Promise}
1083
+ */
1084
+ async updatePhoneVerification<Preferences extends Models.Preferences>(userId: string, phoneVerification: boolean): Promise<Models.User<Preferences>> {
1085
+ if (typeof userId === 'undefined') {
1086
+ throw new AppwriteException('Missing required parameter: "userId"');
1087
+ }
1088
+
1089
+ if (typeof phoneVerification === 'undefined') {
1090
+ throw new AppwriteException('Missing required parameter: "phoneVerification"');
1091
+ }
1092
+
1093
+ const apiPath = '/users/{userId}/verification/phone'.replace('{userId}', userId);
1094
+ const payload: Payload = {};
1095
+
1096
+ if (typeof phoneVerification !== 'undefined') {
1097
+ payload['phoneVerification'] = phoneVerification;
1098
+ }
1099
+
1100
+ const uri = new URL(this.client.config.endpoint + apiPath);
1101
+ return await this.client.call('patch', uri, {
1102
+ 'content-type': 'application/json',
1103
+ }, payload);
1104
+ }
1015
1105
  };