node-appwrite 12.0.0 → 12.1.0-rc.4

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 (296) hide show
  1. package/.travis.yml +18 -8
  2. package/dist/client.d.mts +131 -0
  3. package/dist/client.d.ts +131 -0
  4. package/dist/client.js +302 -0
  5. package/dist/client.js.map +1 -0
  6. package/dist/client.mjs +295 -0
  7. package/dist/client.mjs.map +1 -0
  8. package/dist/enums/authentication-factor.d.mts +8 -0
  9. package/dist/enums/authentication-factor.d.ts +8 -0
  10. package/dist/enums/authentication-factor.js +13 -0
  11. package/dist/enums/authentication-factor.js.map +1 -0
  12. package/dist/enums/authentication-factor.mjs +11 -0
  13. package/dist/enums/authentication-factor.mjs.map +1 -0
  14. package/dist/enums/authenticator-type.d.mts +5 -0
  15. package/dist/enums/authenticator-type.d.ts +5 -0
  16. package/dist/enums/authenticator-type.js +10 -0
  17. package/dist/enums/authenticator-type.js.map +1 -0
  18. package/dist/enums/authenticator-type.mjs +8 -0
  19. package/dist/enums/authenticator-type.mjs.map +1 -0
  20. package/dist/enums/browser.d.mts +18 -0
  21. package/dist/enums/browser.d.ts +18 -0
  22. package/dist/enums/browser.js +23 -0
  23. package/dist/enums/browser.js.map +1 -0
  24. package/dist/enums/browser.mjs +21 -0
  25. package/dist/enums/browser.mjs.map +1 -0
  26. package/dist/enums/compression.d.mts +7 -0
  27. package/dist/enums/compression.d.ts +7 -0
  28. package/dist/enums/compression.js +12 -0
  29. package/dist/enums/compression.js.map +1 -0
  30. package/dist/enums/compression.mjs +10 -0
  31. package/dist/enums/compression.mjs.map +1 -0
  32. package/dist/enums/credit-card.d.mts +20 -0
  33. package/dist/enums/credit-card.d.ts +20 -0
  34. package/dist/enums/credit-card.js +25 -0
  35. package/dist/enums/credit-card.js.map +1 -0
  36. package/dist/enums/credit-card.mjs +23 -0
  37. package/dist/enums/credit-card.mjs.map +1 -0
  38. package/dist/enums/execution-method.d.mts +10 -0
  39. package/dist/enums/execution-method.d.ts +10 -0
  40. package/dist/enums/execution-method.js +15 -0
  41. package/dist/enums/execution-method.js.map +1 -0
  42. package/dist/enums/execution-method.mjs +13 -0
  43. package/dist/enums/execution-method.mjs.map +1 -0
  44. package/dist/enums/flag.d.mts +198 -0
  45. package/dist/enums/flag.d.ts +198 -0
  46. package/dist/enums/flag.js +203 -0
  47. package/dist/enums/flag.js.map +1 -0
  48. package/dist/enums/flag.mjs +201 -0
  49. package/dist/enums/flag.mjs.map +1 -0
  50. package/dist/enums/image-format.d.mts +9 -0
  51. package/dist/enums/image-format.d.ts +9 -0
  52. package/dist/enums/image-format.js +14 -0
  53. package/dist/enums/image-format.js.map +1 -0
  54. package/dist/enums/image-format.mjs +12 -0
  55. package/dist/enums/image-format.mjs.map +1 -0
  56. package/dist/enums/image-gravity.d.mts +13 -0
  57. package/dist/enums/image-gravity.d.ts +13 -0
  58. package/dist/enums/image-gravity.js +18 -0
  59. package/dist/enums/image-gravity.js.map +1 -0
  60. package/dist/enums/image-gravity.mjs +16 -0
  61. package/dist/enums/image-gravity.mjs.map +1 -0
  62. package/dist/enums/index-type.d.mts +7 -0
  63. package/dist/enums/index-type.d.ts +7 -0
  64. package/dist/enums/index-type.js +12 -0
  65. package/dist/enums/index-type.js.map +1 -0
  66. package/dist/enums/index-type.mjs +10 -0
  67. package/dist/enums/index-type.mjs.map +1 -0
  68. package/dist/enums/messaging-provider-type.d.mts +7 -0
  69. package/dist/enums/messaging-provider-type.d.ts +7 -0
  70. package/dist/enums/messaging-provider-type.js +12 -0
  71. package/dist/enums/messaging-provider-type.js.map +1 -0
  72. package/dist/enums/messaging-provider-type.mjs +10 -0
  73. package/dist/enums/messaging-provider-type.mjs.map +1 -0
  74. package/dist/enums/name.d.mts +17 -0
  75. package/dist/enums/name.d.ts +17 -0
  76. package/dist/enums/name.js +22 -0
  77. package/dist/enums/name.js.map +1 -0
  78. package/dist/enums/name.mjs +20 -0
  79. package/dist/enums/name.mjs.map +1 -0
  80. package/dist/enums/o-auth-provider.d.mts +43 -0
  81. package/dist/enums/o-auth-provider.d.ts +43 -0
  82. package/dist/enums/o-auth-provider.js +48 -0
  83. package/dist/enums/o-auth-provider.js.map +1 -0
  84. package/dist/enums/o-auth-provider.mjs +46 -0
  85. package/dist/enums/o-auth-provider.mjs.map +1 -0
  86. package/dist/enums/password-hash.d.mts +15 -0
  87. package/dist/enums/password-hash.d.ts +15 -0
  88. package/dist/enums/password-hash.js +20 -0
  89. package/dist/enums/password-hash.js.map +1 -0
  90. package/dist/enums/password-hash.mjs +18 -0
  91. package/dist/enums/password-hash.mjs.map +1 -0
  92. package/dist/enums/relation-mutate.d.mts +7 -0
  93. package/dist/enums/relation-mutate.d.ts +7 -0
  94. package/dist/enums/relation-mutate.js +12 -0
  95. package/dist/enums/relation-mutate.js.map +1 -0
  96. package/dist/enums/relation-mutate.mjs +10 -0
  97. package/dist/enums/relation-mutate.mjs.map +1 -0
  98. package/dist/enums/relationship-type.d.mts +8 -0
  99. package/dist/enums/relationship-type.d.ts +8 -0
  100. package/dist/enums/relationship-type.js +13 -0
  101. package/dist/enums/relationship-type.js.map +1 -0
  102. package/dist/enums/relationship-type.mjs +11 -0
  103. package/dist/enums/relationship-type.mjs.map +1 -0
  104. package/dist/enums/runtime.d.mts +48 -0
  105. package/dist/enums/runtime.d.ts +48 -0
  106. package/dist/enums/runtime.js +53 -0
  107. package/dist/enums/runtime.js.map +1 -0
  108. package/dist/enums/runtime.mjs +51 -0
  109. package/dist/enums/runtime.mjs.map +1 -0
  110. package/dist/enums/smtp-encryption.d.mts +7 -0
  111. package/dist/enums/smtp-encryption.d.ts +7 -0
  112. package/dist/enums/smtp-encryption.js +12 -0
  113. package/dist/enums/smtp-encryption.js.map +1 -0
  114. package/dist/enums/smtp-encryption.mjs +10 -0
  115. package/dist/enums/smtp-encryption.mjs.map +1 -0
  116. package/dist/id.d.mts +7 -0
  117. package/dist/id.d.ts +7 -0
  118. package/dist/id.js +29 -0
  119. package/dist/id.js.map +1 -0
  120. package/dist/id.mjs +27 -0
  121. package/dist/id.mjs.map +1 -0
  122. package/dist/index.d.mts +35 -0
  123. package/dist/index.d.ts +35 -0
  124. package/dist/index.js +180 -0
  125. package/dist/index.js.map +1 -0
  126. package/dist/index.mjs +35 -0
  127. package/dist/index.mjs.map +1 -0
  128. package/dist/inputFile.d.mts +9 -0
  129. package/dist/inputFile.d.ts +9 -0
  130. package/dist/inputFile.js +23 -0
  131. package/dist/inputFile.js.map +1 -0
  132. package/dist/inputFile.mjs +21 -0
  133. package/dist/inputFile.mjs.map +1 -0
  134. package/dist/models.d.mts +2406 -0
  135. package/dist/models.d.ts +2406 -0
  136. package/dist/models.js +4 -0
  137. package/dist/models.js.map +1 -0
  138. package/dist/models.mjs +3 -0
  139. package/dist/models.mjs.map +1 -0
  140. package/dist/permission.d.mts +9 -0
  141. package/dist/permission.d.ts +9 -0
  142. package/dist/permission.js +23 -0
  143. package/dist/permission.js.map +1 -0
  144. package/dist/permission.mjs +21 -0
  145. package/dist/permission.mjs.map +1 -0
  146. package/dist/query.d.mts +35 -0
  147. package/dist/query.d.ts +35 -0
  148. package/dist/query.js +49 -0
  149. package/dist/query.js.map +1 -0
  150. package/dist/query.mjs +47 -0
  151. package/dist/query.mjs.map +1 -0
  152. package/dist/role.d.mts +72 -0
  153. package/dist/role.d.ts +72 -0
  154. package/dist/role.js +96 -0
  155. package/dist/role.js.map +1 -0
  156. package/dist/role.mjs +94 -0
  157. package/dist/role.mjs.map +1 -0
  158. package/dist/services/account.d.mts +478 -0
  159. package/dist/services/account.d.ts +478 -0
  160. package/dist/services/account.js +1331 -0
  161. package/dist/services/account.js.map +1 -0
  162. package/dist/services/account.mjs +1329 -0
  163. package/dist/services/account.mjs.map +1 -0
  164. package/dist/services/avatars.d.mts +118 -0
  165. package/dist/services/avatars.d.ts +118 -0
  166. package/dist/services/avatars.js +297 -0
  167. package/dist/services/avatars.js.map +1 -0
  168. package/dist/services/avatars.mjs +295 -0
  169. package/dist/services/avatars.mjs.map +1 -0
  170. package/dist/services/databases.d.mts +606 -0
  171. package/dist/services/databases.d.ts +606 -0
  172. package/dist/services/databases.js +1908 -0
  173. package/dist/services/databases.js.map +1 -0
  174. package/dist/services/databases.mjs +1906 -0
  175. package/dist/services/databases.mjs.map +1 -0
  176. package/dist/services/functions.d.mts +287 -0
  177. package/dist/services/functions.d.ts +287 -0
  178. package/dist/services/functions.js +837 -0
  179. package/dist/services/functions.js.map +1 -0
  180. package/dist/services/functions.mjs +835 -0
  181. package/dist/services/functions.mjs.map +1 -0
  182. package/dist/services/graphql.d.mts +30 -0
  183. package/dist/services/graphql.d.ts +30 -0
  184. package/dist/services/graphql.js +73 -0
  185. package/dist/services/graphql.js.map +1 -0
  186. package/dist/services/graphql.mjs +71 -0
  187. package/dist/services/graphql.mjs.map +1 -0
  188. package/dist/services/health.d.mts +235 -0
  189. package/dist/services/health.d.ts +235 -0
  190. package/dist/services/health.js +584 -0
  191. package/dist/services/health.js.map +1 -0
  192. package/dist/services/health.mjs +582 -0
  193. package/dist/services/health.mjs.map +1 -0
  194. package/dist/services/locale.d.mts +84 -0
  195. package/dist/services/locale.d.ts +84 -0
  196. package/dist/services/locale.js +189 -0
  197. package/dist/services/locale.js.map +1 -0
  198. package/dist/services/locale.mjs +187 -0
  199. package/dist/services/locale.mjs.map +1 -0
  200. package/dist/services/messaging.d.mts +688 -0
  201. package/dist/services/messaging.d.ts +688 -0
  202. package/dist/services/messaging.js +2152 -0
  203. package/dist/services/messaging.js.map +1 -0
  204. package/dist/services/messaging.mjs +2150 -0
  205. package/dist/services/messaging.mjs.map +1 -0
  206. package/dist/services/storage.d.mts +193 -0
  207. package/dist/services/storage.d.ts +193 -0
  208. package/dist/services/storage.js +550 -0
  209. package/dist/services/storage.js.map +1 -0
  210. package/dist/services/storage.mjs +548 -0
  211. package/dist/services/storage.mjs.map +1 -0
  212. package/dist/services/teams.d.mts +171 -0
  213. package/dist/services/teams.d.ts +171 -0
  214. package/dist/services/teams.js +466 -0
  215. package/dist/services/teams.js.map +1 -0
  216. package/dist/services/teams.mjs +464 -0
  217. package/dist/services/teams.mjs.map +1 -0
  218. package/dist/services/users.d.mts +490 -0
  219. package/dist/services/users.d.ts +490 -0
  220. package/dist/services/users.js +1464 -0
  221. package/dist/services/users.js.map +1 -0
  222. package/dist/services/users.mjs +1462 -0
  223. package/dist/services/users.mjs.map +1 -0
  224. package/docs/examples/functions/create-deployment.md +1 -1
  225. package/docs/examples/storage/create-file.md +1 -1
  226. package/package.json +35 -5
  227. package/src/client.ts +366 -0
  228. package/src/enums/authentication-factor.ts +6 -0
  229. package/src/enums/authenticator-type.ts +3 -0
  230. package/src/enums/browser.ts +16 -0
  231. package/src/enums/compression.ts +5 -0
  232. package/src/enums/credit-card.ts +18 -0
  233. package/src/enums/execution-method.ts +8 -0
  234. package/src/enums/flag.ts +196 -0
  235. package/src/enums/image-format.ts +7 -0
  236. package/src/enums/image-gravity.ts +11 -0
  237. package/src/enums/index-type.ts +5 -0
  238. package/src/enums/messaging-provider-type.ts +5 -0
  239. package/src/enums/name.ts +15 -0
  240. package/src/enums/o-auth-provider.ts +41 -0
  241. package/src/enums/password-hash.ts +13 -0
  242. package/src/enums/relation-mutate.ts +5 -0
  243. package/src/enums/relationship-type.ts +6 -0
  244. package/src/enums/runtime.ts +46 -0
  245. package/src/enums/smtp-encryption.ts +5 -0
  246. package/src/id.ts +28 -0
  247. package/src/index.ts +35 -0
  248. package/src/inputFile.ts +23 -0
  249. package/src/models.ts +2404 -0
  250. package/src/permission.ts +22 -0
  251. package/src/query.ts +101 -0
  252. package/{lib/role.js → src/role.ts} +23 -25
  253. package/src/services/account.ts +1418 -0
  254. package/src/services/avatars.ts +312 -0
  255. package/{lib/services/databases.js → src/services/databases.ts} +644 -638
  256. package/{lib/services/functions.js → src/services/functions.ts} +317 -369
  257. package/{lib/services/graphql.js → src/services/graphql.ts} +35 -34
  258. package/src/services/health.ts +629 -0
  259. package/src/services/locale.ts +205 -0
  260. package/{lib/services/messaging.js → src/services/messaging.ts} +658 -633
  261. package/{lib/services/storage.js → src/services/storage.ts} +211 -298
  262. package/{lib/services/teams.js → src/services/teams.ts} +211 -200
  263. package/{lib/services/users.js → src/services/users.ts} +603 -519
  264. package/tsconfig.json +18 -0
  265. package/tsup.config.js +19 -0
  266. package/index.d.ts +0 -6656
  267. package/index.js +0 -75
  268. package/lib/client.js +0 -245
  269. package/lib/enums/authentication-factor.js +0 -8
  270. package/lib/enums/authenticator-type.js +0 -5
  271. package/lib/enums/browser.js +0 -18
  272. package/lib/enums/compression.js +0 -7
  273. package/lib/enums/credit-card.js +0 -20
  274. package/lib/enums/execution-method.js +0 -10
  275. package/lib/enums/flag.js +0 -198
  276. package/lib/enums/image-format.js +0 -9
  277. package/lib/enums/image-gravity.js +0 -13
  278. package/lib/enums/index-type.js +0 -7
  279. package/lib/enums/messaging-provider-type.js +0 -7
  280. package/lib/enums/name.js +0 -17
  281. package/lib/enums/o-auth-provider.js +0 -43
  282. package/lib/enums/password-hash.js +0 -15
  283. package/lib/enums/relation-mutate.js +0 -7
  284. package/lib/enums/relationship-type.js +0 -8
  285. package/lib/enums/runtime.js +0 -48
  286. package/lib/enums/smtp-encryption.js +0 -7
  287. package/lib/exception.js +0 -10
  288. package/lib/id.js +0 -12
  289. package/lib/inputFile.js +0 -117
  290. package/lib/permission.js +0 -24
  291. package/lib/query.js +0 -90
  292. package/lib/service.js +0 -10
  293. package/lib/services/account.js +0 -1365
  294. package/lib/services/avatars.js +0 -325
  295. package/lib/services/health.js +0 -513
  296. package/lib/services/locale.js +0 -169
@@ -0,0 +1,1462 @@
1
+ import { AppwriteException } from '../client';
2
+
3
+ class Users {
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ /**
8
+ * List users
9
+ *
10
+ * Get a list of all the project's users. You can use the query params to filter your results.
11
+ *
12
+ * @param {string[]} queries
13
+ * @param {string} search
14
+ * @throws {AppwriteException}
15
+ * @returns {Promise<Models.UserList<Preferences>>}
16
+ */
17
+ async list(queries, search) {
18
+ const apiPath = "/users";
19
+ const payload = {};
20
+ if (typeof queries !== "undefined") {
21
+ payload["queries"] = queries;
22
+ }
23
+ if (typeof search !== "undefined") {
24
+ payload["search"] = search;
25
+ }
26
+ const uri = new URL(this.client.config.endpoint + apiPath);
27
+ const apiHeaders = {
28
+ "content-type": "application/json"
29
+ };
30
+ return await this.client.call(
31
+ "get",
32
+ uri,
33
+ apiHeaders,
34
+ payload
35
+ );
36
+ }
37
+ /**
38
+ * Create user
39
+ *
40
+ * Create a new user.
41
+ *
42
+ * @param {string} userId
43
+ * @param {string} email
44
+ * @param {string} phone
45
+ * @param {string} password
46
+ * @param {string} name
47
+ * @throws {AppwriteException}
48
+ * @returns {Promise<Models.User<Preferences>>}
49
+ */
50
+ async create(userId, email, phone, password, name) {
51
+ if (typeof userId === "undefined") {
52
+ throw new AppwriteException('Missing required parameter: "userId"');
53
+ }
54
+ const apiPath = "/users";
55
+ const payload = {};
56
+ if (typeof userId !== "undefined") {
57
+ payload["userId"] = userId;
58
+ }
59
+ if (typeof email !== "undefined") {
60
+ payload["email"] = email;
61
+ }
62
+ if (typeof phone !== "undefined") {
63
+ payload["phone"] = phone;
64
+ }
65
+ if (typeof password !== "undefined") {
66
+ payload["password"] = password;
67
+ }
68
+ if (typeof name !== "undefined") {
69
+ payload["name"] = name;
70
+ }
71
+ const uri = new URL(this.client.config.endpoint + apiPath);
72
+ const apiHeaders = {
73
+ "content-type": "application/json"
74
+ };
75
+ return await this.client.call(
76
+ "post",
77
+ uri,
78
+ apiHeaders,
79
+ payload
80
+ );
81
+ }
82
+ /**
83
+ * Create user with Argon2 password
84
+ *
85
+ * Create a new user. Password provided must be hashed with the [Argon2](https://en.wikipedia.org/wiki/Argon2) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
86
+ *
87
+ * @param {string} userId
88
+ * @param {string} email
89
+ * @param {string} password
90
+ * @param {string} name
91
+ * @throws {AppwriteException}
92
+ * @returns {Promise<Models.User<Preferences>>}
93
+ */
94
+ async createArgon2User(userId, email, password, name) {
95
+ if (typeof userId === "undefined") {
96
+ throw new AppwriteException('Missing required parameter: "userId"');
97
+ }
98
+ if (typeof email === "undefined") {
99
+ throw new AppwriteException('Missing required parameter: "email"');
100
+ }
101
+ if (typeof password === "undefined") {
102
+ throw new AppwriteException('Missing required parameter: "password"');
103
+ }
104
+ const apiPath = "/users/argon2";
105
+ const payload = {};
106
+ if (typeof userId !== "undefined") {
107
+ payload["userId"] = userId;
108
+ }
109
+ if (typeof email !== "undefined") {
110
+ payload["email"] = email;
111
+ }
112
+ if (typeof password !== "undefined") {
113
+ payload["password"] = password;
114
+ }
115
+ if (typeof name !== "undefined") {
116
+ payload["name"] = name;
117
+ }
118
+ const uri = new URL(this.client.config.endpoint + apiPath);
119
+ const apiHeaders = {
120
+ "content-type": "application/json"
121
+ };
122
+ return await this.client.call(
123
+ "post",
124
+ uri,
125
+ apiHeaders,
126
+ payload
127
+ );
128
+ }
129
+ /**
130
+ * Create user with bcrypt password
131
+ *
132
+ * Create a new user. Password provided must be hashed with the [Bcrypt](https://en.wikipedia.org/wiki/Bcrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
133
+ *
134
+ * @param {string} userId
135
+ * @param {string} email
136
+ * @param {string} password
137
+ * @param {string} name
138
+ * @throws {AppwriteException}
139
+ * @returns {Promise<Models.User<Preferences>>}
140
+ */
141
+ async createBcryptUser(userId, email, password, name) {
142
+ if (typeof userId === "undefined") {
143
+ throw new AppwriteException('Missing required parameter: "userId"');
144
+ }
145
+ if (typeof email === "undefined") {
146
+ throw new AppwriteException('Missing required parameter: "email"');
147
+ }
148
+ if (typeof password === "undefined") {
149
+ throw new AppwriteException('Missing required parameter: "password"');
150
+ }
151
+ const apiPath = "/users/bcrypt";
152
+ const payload = {};
153
+ if (typeof userId !== "undefined") {
154
+ payload["userId"] = userId;
155
+ }
156
+ if (typeof email !== "undefined") {
157
+ payload["email"] = email;
158
+ }
159
+ if (typeof password !== "undefined") {
160
+ payload["password"] = password;
161
+ }
162
+ if (typeof name !== "undefined") {
163
+ payload["name"] = name;
164
+ }
165
+ const uri = new URL(this.client.config.endpoint + apiPath);
166
+ const apiHeaders = {
167
+ "content-type": "application/json"
168
+ };
169
+ return await this.client.call(
170
+ "post",
171
+ uri,
172
+ apiHeaders,
173
+ payload
174
+ );
175
+ }
176
+ /**
177
+ * List Identities
178
+ *
179
+ * Get identities for all users.
180
+ *
181
+ * @param {string[]} queries
182
+ * @param {string} search
183
+ * @throws {AppwriteException}
184
+ * @returns {Promise<Models.IdentityList>}
185
+ */
186
+ async listIdentities(queries, search) {
187
+ const apiPath = "/users/identities";
188
+ const payload = {};
189
+ if (typeof queries !== "undefined") {
190
+ payload["queries"] = queries;
191
+ }
192
+ if (typeof search !== "undefined") {
193
+ payload["search"] = search;
194
+ }
195
+ const uri = new URL(this.client.config.endpoint + apiPath);
196
+ const apiHeaders = {
197
+ "content-type": "application/json"
198
+ };
199
+ return await this.client.call(
200
+ "get",
201
+ uri,
202
+ apiHeaders,
203
+ payload
204
+ );
205
+ }
206
+ /**
207
+ * Delete identity
208
+ *
209
+ * Delete an identity by its unique ID.
210
+ *
211
+ * @param {string} identityId
212
+ * @throws {AppwriteException}
213
+ * @returns {Promise<{}>}
214
+ */
215
+ async deleteIdentity(identityId) {
216
+ if (typeof identityId === "undefined") {
217
+ throw new AppwriteException('Missing required parameter: "identityId"');
218
+ }
219
+ const apiPath = "/users/identities/{identityId}".replace("{identityId}", identityId);
220
+ const payload = {};
221
+ const uri = new URL(this.client.config.endpoint + apiPath);
222
+ const apiHeaders = {
223
+ "content-type": "application/json"
224
+ };
225
+ return await this.client.call(
226
+ "delete",
227
+ uri,
228
+ apiHeaders,
229
+ payload
230
+ );
231
+ }
232
+ /**
233
+ * Create user with MD5 password
234
+ *
235
+ * Create a new user. Password provided must be hashed with the [MD5](https://en.wikipedia.org/wiki/MD5) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
236
+ *
237
+ * @param {string} userId
238
+ * @param {string} email
239
+ * @param {string} password
240
+ * @param {string} name
241
+ * @throws {AppwriteException}
242
+ * @returns {Promise<Models.User<Preferences>>}
243
+ */
244
+ async createMD5User(userId, email, password, name) {
245
+ if (typeof userId === "undefined") {
246
+ throw new AppwriteException('Missing required parameter: "userId"');
247
+ }
248
+ if (typeof email === "undefined") {
249
+ throw new AppwriteException('Missing required parameter: "email"');
250
+ }
251
+ if (typeof password === "undefined") {
252
+ throw new AppwriteException('Missing required parameter: "password"');
253
+ }
254
+ const apiPath = "/users/md5";
255
+ const payload = {};
256
+ if (typeof userId !== "undefined") {
257
+ payload["userId"] = userId;
258
+ }
259
+ if (typeof email !== "undefined") {
260
+ payload["email"] = email;
261
+ }
262
+ if (typeof password !== "undefined") {
263
+ payload["password"] = password;
264
+ }
265
+ if (typeof name !== "undefined") {
266
+ payload["name"] = name;
267
+ }
268
+ const uri = new URL(this.client.config.endpoint + apiPath);
269
+ const apiHeaders = {
270
+ "content-type": "application/json"
271
+ };
272
+ return await this.client.call(
273
+ "post",
274
+ uri,
275
+ apiHeaders,
276
+ payload
277
+ );
278
+ }
279
+ /**
280
+ * Create user with PHPass password
281
+ *
282
+ * Create a new user. Password provided must be hashed with the [PHPass](https://www.openwall.com/phpass/) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
283
+ *
284
+ * @param {string} userId
285
+ * @param {string} email
286
+ * @param {string} password
287
+ * @param {string} name
288
+ * @throws {AppwriteException}
289
+ * @returns {Promise<Models.User<Preferences>>}
290
+ */
291
+ async createPHPassUser(userId, email, password, name) {
292
+ if (typeof userId === "undefined") {
293
+ throw new AppwriteException('Missing required parameter: "userId"');
294
+ }
295
+ if (typeof email === "undefined") {
296
+ throw new AppwriteException('Missing required parameter: "email"');
297
+ }
298
+ if (typeof password === "undefined") {
299
+ throw new AppwriteException('Missing required parameter: "password"');
300
+ }
301
+ const apiPath = "/users/phpass";
302
+ const payload = {};
303
+ if (typeof userId !== "undefined") {
304
+ payload["userId"] = userId;
305
+ }
306
+ if (typeof email !== "undefined") {
307
+ payload["email"] = email;
308
+ }
309
+ if (typeof password !== "undefined") {
310
+ payload["password"] = password;
311
+ }
312
+ if (typeof name !== "undefined") {
313
+ payload["name"] = name;
314
+ }
315
+ const uri = new URL(this.client.config.endpoint + apiPath);
316
+ const apiHeaders = {
317
+ "content-type": "application/json"
318
+ };
319
+ return await this.client.call(
320
+ "post",
321
+ uri,
322
+ apiHeaders,
323
+ payload
324
+ );
325
+ }
326
+ /**
327
+ * Create user with Scrypt password
328
+ *
329
+ * Create a new user. Password provided must be hashed with the [Scrypt](https://github.com/Tarsnap/scrypt) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
330
+ *
331
+ * @param {string} userId
332
+ * @param {string} email
333
+ * @param {string} password
334
+ * @param {string} passwordSalt
335
+ * @param {number} passwordCpu
336
+ * @param {number} passwordMemory
337
+ * @param {number} passwordParallel
338
+ * @param {number} passwordLength
339
+ * @param {string} name
340
+ * @throws {AppwriteException}
341
+ * @returns {Promise<Models.User<Preferences>>}
342
+ */
343
+ async createScryptUser(userId, email, password, passwordSalt, passwordCpu, passwordMemory, passwordParallel, passwordLength, name) {
344
+ if (typeof userId === "undefined") {
345
+ throw new AppwriteException('Missing required parameter: "userId"');
346
+ }
347
+ if (typeof email === "undefined") {
348
+ throw new AppwriteException('Missing required parameter: "email"');
349
+ }
350
+ if (typeof password === "undefined") {
351
+ throw new AppwriteException('Missing required parameter: "password"');
352
+ }
353
+ if (typeof passwordSalt === "undefined") {
354
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
355
+ }
356
+ if (typeof passwordCpu === "undefined") {
357
+ throw new AppwriteException('Missing required parameter: "passwordCpu"');
358
+ }
359
+ if (typeof passwordMemory === "undefined") {
360
+ throw new AppwriteException('Missing required parameter: "passwordMemory"');
361
+ }
362
+ if (typeof passwordParallel === "undefined") {
363
+ throw new AppwriteException('Missing required parameter: "passwordParallel"');
364
+ }
365
+ if (typeof passwordLength === "undefined") {
366
+ throw new AppwriteException('Missing required parameter: "passwordLength"');
367
+ }
368
+ const apiPath = "/users/scrypt";
369
+ const payload = {};
370
+ if (typeof userId !== "undefined") {
371
+ payload["userId"] = userId;
372
+ }
373
+ if (typeof email !== "undefined") {
374
+ payload["email"] = email;
375
+ }
376
+ if (typeof password !== "undefined") {
377
+ payload["password"] = password;
378
+ }
379
+ if (typeof passwordSalt !== "undefined") {
380
+ payload["passwordSalt"] = passwordSalt;
381
+ }
382
+ if (typeof passwordCpu !== "undefined") {
383
+ payload["passwordCpu"] = passwordCpu;
384
+ }
385
+ if (typeof passwordMemory !== "undefined") {
386
+ payload["passwordMemory"] = passwordMemory;
387
+ }
388
+ if (typeof passwordParallel !== "undefined") {
389
+ payload["passwordParallel"] = passwordParallel;
390
+ }
391
+ if (typeof passwordLength !== "undefined") {
392
+ payload["passwordLength"] = passwordLength;
393
+ }
394
+ if (typeof name !== "undefined") {
395
+ payload["name"] = name;
396
+ }
397
+ const uri = new URL(this.client.config.endpoint + apiPath);
398
+ const apiHeaders = {
399
+ "content-type": "application/json"
400
+ };
401
+ return await this.client.call(
402
+ "post",
403
+ uri,
404
+ apiHeaders,
405
+ payload
406
+ );
407
+ }
408
+ /**
409
+ * Create user with Scrypt modified password
410
+ *
411
+ * Create a new user. Password provided must be hashed with the [Scrypt Modified](https://gist.github.com/Meldiron/eecf84a0225eccb5a378d45bb27462cc) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
412
+ *
413
+ * @param {string} userId
414
+ * @param {string} email
415
+ * @param {string} password
416
+ * @param {string} passwordSalt
417
+ * @param {string} passwordSaltSeparator
418
+ * @param {string} passwordSignerKey
419
+ * @param {string} name
420
+ * @throws {AppwriteException}
421
+ * @returns {Promise<Models.User<Preferences>>}
422
+ */
423
+ async createScryptModifiedUser(userId, email, password, passwordSalt, passwordSaltSeparator, passwordSignerKey, name) {
424
+ if (typeof userId === "undefined") {
425
+ throw new AppwriteException('Missing required parameter: "userId"');
426
+ }
427
+ if (typeof email === "undefined") {
428
+ throw new AppwriteException('Missing required parameter: "email"');
429
+ }
430
+ if (typeof password === "undefined") {
431
+ throw new AppwriteException('Missing required parameter: "password"');
432
+ }
433
+ if (typeof passwordSalt === "undefined") {
434
+ throw new AppwriteException('Missing required parameter: "passwordSalt"');
435
+ }
436
+ if (typeof passwordSaltSeparator === "undefined") {
437
+ throw new AppwriteException('Missing required parameter: "passwordSaltSeparator"');
438
+ }
439
+ if (typeof passwordSignerKey === "undefined") {
440
+ throw new AppwriteException('Missing required parameter: "passwordSignerKey"');
441
+ }
442
+ const apiPath = "/users/scrypt-modified";
443
+ const payload = {};
444
+ if (typeof userId !== "undefined") {
445
+ payload["userId"] = userId;
446
+ }
447
+ if (typeof email !== "undefined") {
448
+ payload["email"] = email;
449
+ }
450
+ if (typeof password !== "undefined") {
451
+ payload["password"] = password;
452
+ }
453
+ if (typeof passwordSalt !== "undefined") {
454
+ payload["passwordSalt"] = passwordSalt;
455
+ }
456
+ if (typeof passwordSaltSeparator !== "undefined") {
457
+ payload["passwordSaltSeparator"] = passwordSaltSeparator;
458
+ }
459
+ if (typeof passwordSignerKey !== "undefined") {
460
+ payload["passwordSignerKey"] = passwordSignerKey;
461
+ }
462
+ if (typeof name !== "undefined") {
463
+ payload["name"] = name;
464
+ }
465
+ const uri = new URL(this.client.config.endpoint + apiPath);
466
+ const apiHeaders = {
467
+ "content-type": "application/json"
468
+ };
469
+ return await this.client.call(
470
+ "post",
471
+ uri,
472
+ apiHeaders,
473
+ payload
474
+ );
475
+ }
476
+ /**
477
+ * Create user with SHA password
478
+ *
479
+ * Create a new user. Password provided must be hashed with the [SHA](https://en.wikipedia.org/wiki/Secure_Hash_Algorithm) algorithm. Use the [POST /users](https://appwrite.io/docs/server/users#usersCreate) endpoint to create users with a plain text password.
480
+ *
481
+ * @param {string} userId
482
+ * @param {string} email
483
+ * @param {string} password
484
+ * @param {PasswordHash} passwordVersion
485
+ * @param {string} name
486
+ * @throws {AppwriteException}
487
+ * @returns {Promise<Models.User<Preferences>>}
488
+ */
489
+ async createSHAUser(userId, email, password, passwordVersion, name) {
490
+ if (typeof userId === "undefined") {
491
+ throw new AppwriteException('Missing required parameter: "userId"');
492
+ }
493
+ if (typeof email === "undefined") {
494
+ throw new AppwriteException('Missing required parameter: "email"');
495
+ }
496
+ if (typeof password === "undefined") {
497
+ throw new AppwriteException('Missing required parameter: "password"');
498
+ }
499
+ const apiPath = "/users/sha";
500
+ const payload = {};
501
+ if (typeof userId !== "undefined") {
502
+ payload["userId"] = userId;
503
+ }
504
+ if (typeof email !== "undefined") {
505
+ payload["email"] = email;
506
+ }
507
+ if (typeof password !== "undefined") {
508
+ payload["password"] = password;
509
+ }
510
+ if (typeof passwordVersion !== "undefined") {
511
+ payload["passwordVersion"] = passwordVersion;
512
+ }
513
+ if (typeof name !== "undefined") {
514
+ payload["name"] = name;
515
+ }
516
+ const uri = new URL(this.client.config.endpoint + apiPath);
517
+ const apiHeaders = {
518
+ "content-type": "application/json"
519
+ };
520
+ return await this.client.call(
521
+ "post",
522
+ uri,
523
+ apiHeaders,
524
+ payload
525
+ );
526
+ }
527
+ /**
528
+ * Get user
529
+ *
530
+ * Get a user by its unique ID.
531
+ *
532
+ * @param {string} userId
533
+ * @throws {AppwriteException}
534
+ * @returns {Promise<Models.User<Preferences>>}
535
+ */
536
+ async get(userId) {
537
+ if (typeof userId === "undefined") {
538
+ throw new AppwriteException('Missing required parameter: "userId"');
539
+ }
540
+ const apiPath = "/users/{userId}".replace("{userId}", userId);
541
+ const payload = {};
542
+ const uri = new URL(this.client.config.endpoint + apiPath);
543
+ const apiHeaders = {
544
+ "content-type": "application/json"
545
+ };
546
+ return await this.client.call(
547
+ "get",
548
+ uri,
549
+ apiHeaders,
550
+ payload
551
+ );
552
+ }
553
+ /**
554
+ * Delete user
555
+ *
556
+ * Delete a user by its unique ID, thereby releasing it&#039;s ID. Since ID is released and can be reused, all user-related resources like documents or storage files should be deleted before user deletion. If you want to keep ID reserved, use the [updateStatus](https://appwrite.io/docs/server/users#usersUpdateStatus) endpoint instead.
557
+ *
558
+ * @param {string} userId
559
+ * @throws {AppwriteException}
560
+ * @returns {Promise<{}>}
561
+ */
562
+ async delete(userId) {
563
+ if (typeof userId === "undefined") {
564
+ throw new AppwriteException('Missing required parameter: "userId"');
565
+ }
566
+ const apiPath = "/users/{userId}".replace("{userId}", userId);
567
+ const payload = {};
568
+ const uri = new URL(this.client.config.endpoint + apiPath);
569
+ const apiHeaders = {
570
+ "content-type": "application/json"
571
+ };
572
+ return await this.client.call(
573
+ "delete",
574
+ uri,
575
+ apiHeaders,
576
+ payload
577
+ );
578
+ }
579
+ /**
580
+ * Update email
581
+ *
582
+ * Update the user email by its unique ID.
583
+ *
584
+ * @param {string} userId
585
+ * @param {string} email
586
+ * @throws {AppwriteException}
587
+ * @returns {Promise<Models.User<Preferences>>}
588
+ */
589
+ async updateEmail(userId, email) {
590
+ if (typeof userId === "undefined") {
591
+ throw new AppwriteException('Missing required parameter: "userId"');
592
+ }
593
+ if (typeof email === "undefined") {
594
+ throw new AppwriteException('Missing required parameter: "email"');
595
+ }
596
+ const apiPath = "/users/{userId}/email".replace("{userId}", userId);
597
+ const payload = {};
598
+ if (typeof email !== "undefined") {
599
+ payload["email"] = email;
600
+ }
601
+ const uri = new URL(this.client.config.endpoint + apiPath);
602
+ const apiHeaders = {
603
+ "content-type": "application/json"
604
+ };
605
+ return await this.client.call(
606
+ "patch",
607
+ uri,
608
+ apiHeaders,
609
+ payload
610
+ );
611
+ }
612
+ /**
613
+ * Update user labels
614
+ *
615
+ * Update the user labels by its unique ID.
616
+
617
+ Labels can be used to grant access to resources. While teams are a way for user&#039;s to share access to a resource, labels can be defined by the developer to grant access without an invitation. See the [Permissions docs](https://appwrite.io/docs/permissions) for more info.
618
+ *
619
+ * @param {string} userId
620
+ * @param {string[]} labels
621
+ * @throws {AppwriteException}
622
+ * @returns {Promise<Models.User<Preferences>>}
623
+ */
624
+ async updateLabels(userId, labels) {
625
+ if (typeof userId === "undefined") {
626
+ throw new AppwriteException('Missing required parameter: "userId"');
627
+ }
628
+ if (typeof labels === "undefined") {
629
+ throw new AppwriteException('Missing required parameter: "labels"');
630
+ }
631
+ const apiPath = "/users/{userId}/labels".replace("{userId}", userId);
632
+ const payload = {};
633
+ if (typeof labels !== "undefined") {
634
+ payload["labels"] = labels;
635
+ }
636
+ const uri = new URL(this.client.config.endpoint + apiPath);
637
+ const apiHeaders = {
638
+ "content-type": "application/json"
639
+ };
640
+ return await this.client.call(
641
+ "put",
642
+ uri,
643
+ apiHeaders,
644
+ payload
645
+ );
646
+ }
647
+ /**
648
+ * List user logs
649
+ *
650
+ * Get the user activity logs list by its unique ID.
651
+ *
652
+ * @param {string} userId
653
+ * @param {string[]} queries
654
+ * @throws {AppwriteException}
655
+ * @returns {Promise<Models.LogList>}
656
+ */
657
+ async listLogs(userId, queries) {
658
+ if (typeof userId === "undefined") {
659
+ throw new AppwriteException('Missing required parameter: "userId"');
660
+ }
661
+ const apiPath = "/users/{userId}/logs".replace("{userId}", userId);
662
+ const payload = {};
663
+ if (typeof queries !== "undefined") {
664
+ payload["queries"] = queries;
665
+ }
666
+ const uri = new URL(this.client.config.endpoint + apiPath);
667
+ const apiHeaders = {
668
+ "content-type": "application/json"
669
+ };
670
+ return await this.client.call(
671
+ "get",
672
+ uri,
673
+ apiHeaders,
674
+ payload
675
+ );
676
+ }
677
+ /**
678
+ * List user memberships
679
+ *
680
+ * Get the user membership list by its unique ID.
681
+ *
682
+ * @param {string} userId
683
+ * @throws {AppwriteException}
684
+ * @returns {Promise<Models.MembershipList>}
685
+ */
686
+ async listMemberships(userId) {
687
+ if (typeof userId === "undefined") {
688
+ throw new AppwriteException('Missing required parameter: "userId"');
689
+ }
690
+ const apiPath = "/users/{userId}/memberships".replace("{userId}", userId);
691
+ const payload = {};
692
+ const uri = new URL(this.client.config.endpoint + apiPath);
693
+ const apiHeaders = {
694
+ "content-type": "application/json"
695
+ };
696
+ return await this.client.call(
697
+ "get",
698
+ uri,
699
+ apiHeaders,
700
+ payload
701
+ );
702
+ }
703
+ /**
704
+ * Update MFA
705
+ *
706
+ * Enable or disable MFA on a user account.
707
+ *
708
+ * @param {string} userId
709
+ * @param {boolean} mfa
710
+ * @throws {AppwriteException}
711
+ * @returns {Promise<Models.User<Preferences>>}
712
+ */
713
+ async updateMfa(userId, mfa) {
714
+ if (typeof userId === "undefined") {
715
+ throw new AppwriteException('Missing required parameter: "userId"');
716
+ }
717
+ if (typeof mfa === "undefined") {
718
+ throw new AppwriteException('Missing required parameter: "mfa"');
719
+ }
720
+ const apiPath = "/users/{userId}/mfa".replace("{userId}", userId);
721
+ const payload = {};
722
+ if (typeof mfa !== "undefined") {
723
+ payload["mfa"] = mfa;
724
+ }
725
+ const uri = new URL(this.client.config.endpoint + apiPath);
726
+ const apiHeaders = {
727
+ "content-type": "application/json"
728
+ };
729
+ return await this.client.call(
730
+ "patch",
731
+ uri,
732
+ apiHeaders,
733
+ payload
734
+ );
735
+ }
736
+ /**
737
+ * Delete Authenticator
738
+ *
739
+ * Delete an authenticator app.
740
+ *
741
+ * @param {string} userId
742
+ * @param {AuthenticatorType} type
743
+ * @throws {AppwriteException}
744
+ * @returns {Promise<Models.User<Preferences>>}
745
+ */
746
+ async deleteMfaAuthenticator(userId, type) {
747
+ if (typeof userId === "undefined") {
748
+ throw new AppwriteException('Missing required parameter: "userId"');
749
+ }
750
+ if (typeof type === "undefined") {
751
+ throw new AppwriteException('Missing required parameter: "type"');
752
+ }
753
+ const apiPath = "/users/{userId}/mfa/authenticators/{type}".replace("{userId}", userId).replace("{type}", type);
754
+ const payload = {};
755
+ const uri = new URL(this.client.config.endpoint + apiPath);
756
+ const apiHeaders = {
757
+ "content-type": "application/json"
758
+ };
759
+ return await this.client.call(
760
+ "delete",
761
+ uri,
762
+ apiHeaders,
763
+ payload
764
+ );
765
+ }
766
+ /**
767
+ * List Factors
768
+ *
769
+ * List the factors available on the account to be used as a MFA challange.
770
+ *
771
+ * @param {string} userId
772
+ * @throws {AppwriteException}
773
+ * @returns {Promise<Models.MfaFactors>}
774
+ */
775
+ async listMfaFactors(userId) {
776
+ if (typeof userId === "undefined") {
777
+ throw new AppwriteException('Missing required parameter: "userId"');
778
+ }
779
+ const apiPath = "/users/{userId}/mfa/factors".replace("{userId}", userId);
780
+ const payload = {};
781
+ const uri = new URL(this.client.config.endpoint + apiPath);
782
+ const apiHeaders = {
783
+ "content-type": "application/json"
784
+ };
785
+ return await this.client.call(
786
+ "get",
787
+ uri,
788
+ apiHeaders,
789
+ payload
790
+ );
791
+ }
792
+ /**
793
+ * Get MFA Recovery Codes
794
+ *
795
+ * Get recovery codes that can be used as backup for MFA flow by User ID. Before getting codes, they must be generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.
796
+ *
797
+ * @param {string} userId
798
+ * @throws {AppwriteException}
799
+ * @returns {Promise<Models.MfaRecoveryCodes>}
800
+ */
801
+ async getMfaRecoveryCodes(userId) {
802
+ if (typeof userId === "undefined") {
803
+ throw new AppwriteException('Missing required parameter: "userId"');
804
+ }
805
+ const apiPath = "/users/{userId}/mfa/recovery-codes".replace("{userId}", userId);
806
+ const payload = {};
807
+ const uri = new URL(this.client.config.endpoint + apiPath);
808
+ const apiHeaders = {
809
+ "content-type": "application/json"
810
+ };
811
+ return await this.client.call(
812
+ "get",
813
+ uri,
814
+ apiHeaders,
815
+ payload
816
+ );
817
+ }
818
+ /**
819
+ * Regenerate MFA Recovery Codes
820
+ *
821
+ * Regenerate recovery codes that can be used as backup for MFA flow by User ID. Before regenerating codes, they must be first generated using [createMfaRecoveryCodes](/docs/references/cloud/client-web/account#createMfaRecoveryCodes) method.
822
+ *
823
+ * @param {string} userId
824
+ * @throws {AppwriteException}
825
+ * @returns {Promise<Models.MfaRecoveryCodes>}
826
+ */
827
+ async updateMfaRecoveryCodes(userId) {
828
+ if (typeof userId === "undefined") {
829
+ throw new AppwriteException('Missing required parameter: "userId"');
830
+ }
831
+ const apiPath = "/users/{userId}/mfa/recovery-codes".replace("{userId}", userId);
832
+ const payload = {};
833
+ const uri = new URL(this.client.config.endpoint + apiPath);
834
+ const apiHeaders = {
835
+ "content-type": "application/json"
836
+ };
837
+ return await this.client.call(
838
+ "put",
839
+ uri,
840
+ apiHeaders,
841
+ payload
842
+ );
843
+ }
844
+ /**
845
+ * Create MFA Recovery Codes
846
+ *
847
+ * Generate recovery codes used as backup for MFA flow for User ID. Recovery codes can be used as a MFA verification type in [createMfaChallenge](/docs/references/cloud/client-web/account#createMfaChallenge) method by client SDK.
848
+ *
849
+ * @param {string} userId
850
+ * @throws {AppwriteException}
851
+ * @returns {Promise<Models.MfaRecoveryCodes>}
852
+ */
853
+ async createMfaRecoveryCodes(userId) {
854
+ if (typeof userId === "undefined") {
855
+ throw new AppwriteException('Missing required parameter: "userId"');
856
+ }
857
+ const apiPath = "/users/{userId}/mfa/recovery-codes".replace("{userId}", userId);
858
+ const payload = {};
859
+ const uri = new URL(this.client.config.endpoint + apiPath);
860
+ const apiHeaders = {
861
+ "content-type": "application/json"
862
+ };
863
+ return await this.client.call(
864
+ "patch",
865
+ uri,
866
+ apiHeaders,
867
+ payload
868
+ );
869
+ }
870
+ /**
871
+ * Update name
872
+ *
873
+ * Update the user name by its unique ID.
874
+ *
875
+ * @param {string} userId
876
+ * @param {string} name
877
+ * @throws {AppwriteException}
878
+ * @returns {Promise<Models.User<Preferences>>}
879
+ */
880
+ async updateName(userId, name) {
881
+ if (typeof userId === "undefined") {
882
+ throw new AppwriteException('Missing required parameter: "userId"');
883
+ }
884
+ if (typeof name === "undefined") {
885
+ throw new AppwriteException('Missing required parameter: "name"');
886
+ }
887
+ const apiPath = "/users/{userId}/name".replace("{userId}", userId);
888
+ const payload = {};
889
+ if (typeof name !== "undefined") {
890
+ payload["name"] = name;
891
+ }
892
+ const uri = new URL(this.client.config.endpoint + apiPath);
893
+ const apiHeaders = {
894
+ "content-type": "application/json"
895
+ };
896
+ return await this.client.call(
897
+ "patch",
898
+ uri,
899
+ apiHeaders,
900
+ payload
901
+ );
902
+ }
903
+ /**
904
+ * Update password
905
+ *
906
+ * Update the user password by its unique ID.
907
+ *
908
+ * @param {string} userId
909
+ * @param {string} password
910
+ * @throws {AppwriteException}
911
+ * @returns {Promise<Models.User<Preferences>>}
912
+ */
913
+ async updatePassword(userId, password) {
914
+ if (typeof userId === "undefined") {
915
+ throw new AppwriteException('Missing required parameter: "userId"');
916
+ }
917
+ if (typeof password === "undefined") {
918
+ throw new AppwriteException('Missing required parameter: "password"');
919
+ }
920
+ const apiPath = "/users/{userId}/password".replace("{userId}", userId);
921
+ const payload = {};
922
+ if (typeof password !== "undefined") {
923
+ payload["password"] = password;
924
+ }
925
+ const uri = new URL(this.client.config.endpoint + apiPath);
926
+ const apiHeaders = {
927
+ "content-type": "application/json"
928
+ };
929
+ return await this.client.call(
930
+ "patch",
931
+ uri,
932
+ apiHeaders,
933
+ payload
934
+ );
935
+ }
936
+ /**
937
+ * Update phone
938
+ *
939
+ * Update the user phone by its unique ID.
940
+ *
941
+ * @param {string} userId
942
+ * @param {string} number
943
+ * @throws {AppwriteException}
944
+ * @returns {Promise<Models.User<Preferences>>}
945
+ */
946
+ async updatePhone(userId, number) {
947
+ if (typeof userId === "undefined") {
948
+ throw new AppwriteException('Missing required parameter: "userId"');
949
+ }
950
+ if (typeof number === "undefined") {
951
+ throw new AppwriteException('Missing required parameter: "number"');
952
+ }
953
+ const apiPath = "/users/{userId}/phone".replace("{userId}", userId);
954
+ const payload = {};
955
+ if (typeof number !== "undefined") {
956
+ payload["number"] = number;
957
+ }
958
+ const uri = new URL(this.client.config.endpoint + apiPath);
959
+ const apiHeaders = {
960
+ "content-type": "application/json"
961
+ };
962
+ return await this.client.call(
963
+ "patch",
964
+ uri,
965
+ apiHeaders,
966
+ payload
967
+ );
968
+ }
969
+ /**
970
+ * Get user preferences
971
+ *
972
+ * Get the user preferences by its unique ID.
973
+ *
974
+ * @param {string} userId
975
+ * @throws {AppwriteException}
976
+ * @returns {Promise<Preferences>}
977
+ */
978
+ async getPrefs(userId) {
979
+ if (typeof userId === "undefined") {
980
+ throw new AppwriteException('Missing required parameter: "userId"');
981
+ }
982
+ const apiPath = "/users/{userId}/prefs".replace("{userId}", userId);
983
+ const payload = {};
984
+ const uri = new URL(this.client.config.endpoint + apiPath);
985
+ const apiHeaders = {
986
+ "content-type": "application/json"
987
+ };
988
+ return await this.client.call(
989
+ "get",
990
+ uri,
991
+ apiHeaders,
992
+ payload
993
+ );
994
+ }
995
+ /**
996
+ * Update user preferences
997
+ *
998
+ * Update the user preferences by its unique ID. The object you pass is stored as is, and replaces any previous value. The maximum allowed prefs size is 64kB and throws error if exceeded.
999
+ *
1000
+ * @param {string} userId
1001
+ * @param {object} prefs
1002
+ * @throws {AppwriteException}
1003
+ * @returns {Promise<Preferences>}
1004
+ */
1005
+ async updatePrefs(userId, prefs) {
1006
+ if (typeof userId === "undefined") {
1007
+ throw new AppwriteException('Missing required parameter: "userId"');
1008
+ }
1009
+ if (typeof prefs === "undefined") {
1010
+ throw new AppwriteException('Missing required parameter: "prefs"');
1011
+ }
1012
+ const apiPath = "/users/{userId}/prefs".replace("{userId}", userId);
1013
+ const payload = {};
1014
+ if (typeof prefs !== "undefined") {
1015
+ payload["prefs"] = prefs;
1016
+ }
1017
+ const uri = new URL(this.client.config.endpoint + apiPath);
1018
+ const apiHeaders = {
1019
+ "content-type": "application/json"
1020
+ };
1021
+ return await this.client.call(
1022
+ "patch",
1023
+ uri,
1024
+ apiHeaders,
1025
+ payload
1026
+ );
1027
+ }
1028
+ /**
1029
+ * List user sessions
1030
+ *
1031
+ * Get the user sessions list by its unique ID.
1032
+ *
1033
+ * @param {string} userId
1034
+ * @throws {AppwriteException}
1035
+ * @returns {Promise<Models.SessionList>}
1036
+ */
1037
+ async listSessions(userId) {
1038
+ if (typeof userId === "undefined") {
1039
+ throw new AppwriteException('Missing required parameter: "userId"');
1040
+ }
1041
+ const apiPath = "/users/{userId}/sessions".replace("{userId}", userId);
1042
+ const payload = {};
1043
+ const uri = new URL(this.client.config.endpoint + apiPath);
1044
+ const apiHeaders = {
1045
+ "content-type": "application/json"
1046
+ };
1047
+ return await this.client.call(
1048
+ "get",
1049
+ uri,
1050
+ apiHeaders,
1051
+ payload
1052
+ );
1053
+ }
1054
+ /**
1055
+ * Create session
1056
+ *
1057
+ * Creates a session for a user. Returns an immediately usable session object.
1058
+
1059
+ If you want to generate a token for a custom authentication flow, use the [POST /users/{userId}/tokens](https://appwrite.io/docs/server/users#createToken) endpoint.
1060
+ *
1061
+ * @param {string} userId
1062
+ * @throws {AppwriteException}
1063
+ * @returns {Promise<Models.Session>}
1064
+ */
1065
+ async createSession(userId) {
1066
+ if (typeof userId === "undefined") {
1067
+ throw new AppwriteException('Missing required parameter: "userId"');
1068
+ }
1069
+ const apiPath = "/users/{userId}/sessions".replace("{userId}", userId);
1070
+ const payload = {};
1071
+ const uri = new URL(this.client.config.endpoint + apiPath);
1072
+ const apiHeaders = {
1073
+ "content-type": "application/json"
1074
+ };
1075
+ return await this.client.call(
1076
+ "post",
1077
+ uri,
1078
+ apiHeaders,
1079
+ payload
1080
+ );
1081
+ }
1082
+ /**
1083
+ * Delete user sessions
1084
+ *
1085
+ * Delete all user&#039;s sessions by using the user&#039;s unique ID.
1086
+ *
1087
+ * @param {string} userId
1088
+ * @throws {AppwriteException}
1089
+ * @returns {Promise<{}>}
1090
+ */
1091
+ async deleteSessions(userId) {
1092
+ if (typeof userId === "undefined") {
1093
+ throw new AppwriteException('Missing required parameter: "userId"');
1094
+ }
1095
+ const apiPath = "/users/{userId}/sessions".replace("{userId}", userId);
1096
+ const payload = {};
1097
+ const uri = new URL(this.client.config.endpoint + apiPath);
1098
+ const apiHeaders = {
1099
+ "content-type": "application/json"
1100
+ };
1101
+ return await this.client.call(
1102
+ "delete",
1103
+ uri,
1104
+ apiHeaders,
1105
+ payload
1106
+ );
1107
+ }
1108
+ /**
1109
+ * Delete user session
1110
+ *
1111
+ * Delete a user sessions by its unique ID.
1112
+ *
1113
+ * @param {string} userId
1114
+ * @param {string} sessionId
1115
+ * @throws {AppwriteException}
1116
+ * @returns {Promise<{}>}
1117
+ */
1118
+ async deleteSession(userId, sessionId) {
1119
+ if (typeof userId === "undefined") {
1120
+ throw new AppwriteException('Missing required parameter: "userId"');
1121
+ }
1122
+ if (typeof sessionId === "undefined") {
1123
+ throw new AppwriteException('Missing required parameter: "sessionId"');
1124
+ }
1125
+ const apiPath = "/users/{userId}/sessions/{sessionId}".replace("{userId}", userId).replace("{sessionId}", sessionId);
1126
+ const payload = {};
1127
+ const uri = new URL(this.client.config.endpoint + apiPath);
1128
+ const apiHeaders = {
1129
+ "content-type": "application/json"
1130
+ };
1131
+ return await this.client.call(
1132
+ "delete",
1133
+ uri,
1134
+ apiHeaders,
1135
+ payload
1136
+ );
1137
+ }
1138
+ /**
1139
+ * Update user status
1140
+ *
1141
+ * Update the user status by its unique ID. Use this endpoint as an alternative to deleting a user if you want to keep user&#039;s ID reserved.
1142
+ *
1143
+ * @param {string} userId
1144
+ * @param {boolean} status
1145
+ * @throws {AppwriteException}
1146
+ * @returns {Promise<Models.User<Preferences>>}
1147
+ */
1148
+ async updateStatus(userId, status) {
1149
+ if (typeof userId === "undefined") {
1150
+ throw new AppwriteException('Missing required parameter: "userId"');
1151
+ }
1152
+ if (typeof status === "undefined") {
1153
+ throw new AppwriteException('Missing required parameter: "status"');
1154
+ }
1155
+ const apiPath = "/users/{userId}/status".replace("{userId}", userId);
1156
+ const payload = {};
1157
+ if (typeof status !== "undefined") {
1158
+ payload["status"] = status;
1159
+ }
1160
+ const uri = new URL(this.client.config.endpoint + apiPath);
1161
+ const apiHeaders = {
1162
+ "content-type": "application/json"
1163
+ };
1164
+ return await this.client.call(
1165
+ "patch",
1166
+ uri,
1167
+ apiHeaders,
1168
+ payload
1169
+ );
1170
+ }
1171
+ /**
1172
+ * List User Targets
1173
+ *
1174
+ * List the messaging targets that are associated with a user.
1175
+ *
1176
+ * @param {string} userId
1177
+ * @param {string[]} queries
1178
+ * @throws {AppwriteException}
1179
+ * @returns {Promise<Models.TargetList>}
1180
+ */
1181
+ async listTargets(userId, queries) {
1182
+ if (typeof userId === "undefined") {
1183
+ throw new AppwriteException('Missing required parameter: "userId"');
1184
+ }
1185
+ const apiPath = "/users/{userId}/targets".replace("{userId}", userId);
1186
+ const payload = {};
1187
+ if (typeof queries !== "undefined") {
1188
+ payload["queries"] = queries;
1189
+ }
1190
+ const uri = new URL(this.client.config.endpoint + apiPath);
1191
+ const apiHeaders = {
1192
+ "content-type": "application/json"
1193
+ };
1194
+ return await this.client.call(
1195
+ "get",
1196
+ uri,
1197
+ apiHeaders,
1198
+ payload
1199
+ );
1200
+ }
1201
+ /**
1202
+ * Create User Target
1203
+ *
1204
+ * Create a messaging target.
1205
+ *
1206
+ * @param {string} userId
1207
+ * @param {string} targetId
1208
+ * @param {MessagingProviderType} providerType
1209
+ * @param {string} identifier
1210
+ * @param {string} providerId
1211
+ * @param {string} name
1212
+ * @throws {AppwriteException}
1213
+ * @returns {Promise<Models.Target>}
1214
+ */
1215
+ async createTarget(userId, targetId, providerType, identifier, providerId, name) {
1216
+ if (typeof userId === "undefined") {
1217
+ throw new AppwriteException('Missing required parameter: "userId"');
1218
+ }
1219
+ if (typeof targetId === "undefined") {
1220
+ throw new AppwriteException('Missing required parameter: "targetId"');
1221
+ }
1222
+ if (typeof providerType === "undefined") {
1223
+ throw new AppwriteException('Missing required parameter: "providerType"');
1224
+ }
1225
+ if (typeof identifier === "undefined") {
1226
+ throw new AppwriteException('Missing required parameter: "identifier"');
1227
+ }
1228
+ const apiPath = "/users/{userId}/targets".replace("{userId}", userId);
1229
+ const payload = {};
1230
+ if (typeof targetId !== "undefined") {
1231
+ payload["targetId"] = targetId;
1232
+ }
1233
+ if (typeof providerType !== "undefined") {
1234
+ payload["providerType"] = providerType;
1235
+ }
1236
+ if (typeof identifier !== "undefined") {
1237
+ payload["identifier"] = identifier;
1238
+ }
1239
+ if (typeof providerId !== "undefined") {
1240
+ payload["providerId"] = providerId;
1241
+ }
1242
+ if (typeof name !== "undefined") {
1243
+ payload["name"] = name;
1244
+ }
1245
+ const uri = new URL(this.client.config.endpoint + apiPath);
1246
+ const apiHeaders = {
1247
+ "content-type": "application/json"
1248
+ };
1249
+ return await this.client.call(
1250
+ "post",
1251
+ uri,
1252
+ apiHeaders,
1253
+ payload
1254
+ );
1255
+ }
1256
+ /**
1257
+ * Get User Target
1258
+ *
1259
+ * Get a user&#039;s push notification target by ID.
1260
+ *
1261
+ * @param {string} userId
1262
+ * @param {string} targetId
1263
+ * @throws {AppwriteException}
1264
+ * @returns {Promise<Models.Target>}
1265
+ */
1266
+ async getTarget(userId, targetId) {
1267
+ if (typeof userId === "undefined") {
1268
+ throw new AppwriteException('Missing required parameter: "userId"');
1269
+ }
1270
+ if (typeof targetId === "undefined") {
1271
+ throw new AppwriteException('Missing required parameter: "targetId"');
1272
+ }
1273
+ const apiPath = "/users/{userId}/targets/{targetId}".replace("{userId}", userId).replace("{targetId}", targetId);
1274
+ const payload = {};
1275
+ const uri = new URL(this.client.config.endpoint + apiPath);
1276
+ const apiHeaders = {
1277
+ "content-type": "application/json"
1278
+ };
1279
+ return await this.client.call(
1280
+ "get",
1281
+ uri,
1282
+ apiHeaders,
1283
+ payload
1284
+ );
1285
+ }
1286
+ /**
1287
+ * Update User target
1288
+ *
1289
+ * Update a messaging target.
1290
+ *
1291
+ * @param {string} userId
1292
+ * @param {string} targetId
1293
+ * @param {string} identifier
1294
+ * @param {string} providerId
1295
+ * @param {string} name
1296
+ * @throws {AppwriteException}
1297
+ * @returns {Promise<Models.Target>}
1298
+ */
1299
+ async updateTarget(userId, targetId, identifier, providerId, name) {
1300
+ if (typeof userId === "undefined") {
1301
+ throw new AppwriteException('Missing required parameter: "userId"');
1302
+ }
1303
+ if (typeof targetId === "undefined") {
1304
+ throw new AppwriteException('Missing required parameter: "targetId"');
1305
+ }
1306
+ const apiPath = "/users/{userId}/targets/{targetId}".replace("{userId}", userId).replace("{targetId}", targetId);
1307
+ const payload = {};
1308
+ if (typeof identifier !== "undefined") {
1309
+ payload["identifier"] = identifier;
1310
+ }
1311
+ if (typeof providerId !== "undefined") {
1312
+ payload["providerId"] = providerId;
1313
+ }
1314
+ if (typeof name !== "undefined") {
1315
+ payload["name"] = name;
1316
+ }
1317
+ const uri = new URL(this.client.config.endpoint + apiPath);
1318
+ const apiHeaders = {
1319
+ "content-type": "application/json"
1320
+ };
1321
+ return await this.client.call(
1322
+ "patch",
1323
+ uri,
1324
+ apiHeaders,
1325
+ payload
1326
+ );
1327
+ }
1328
+ /**
1329
+ * Delete user target
1330
+ *
1331
+ * Delete a messaging target.
1332
+ *
1333
+ * @param {string} userId
1334
+ * @param {string} targetId
1335
+ * @throws {AppwriteException}
1336
+ * @returns {Promise<{}>}
1337
+ */
1338
+ async deleteTarget(userId, targetId) {
1339
+ if (typeof userId === "undefined") {
1340
+ throw new AppwriteException('Missing required parameter: "userId"');
1341
+ }
1342
+ if (typeof targetId === "undefined") {
1343
+ throw new AppwriteException('Missing required parameter: "targetId"');
1344
+ }
1345
+ const apiPath = "/users/{userId}/targets/{targetId}".replace("{userId}", userId).replace("{targetId}", targetId);
1346
+ const payload = {};
1347
+ const uri = new URL(this.client.config.endpoint + apiPath);
1348
+ const apiHeaders = {
1349
+ "content-type": "application/json"
1350
+ };
1351
+ return await this.client.call(
1352
+ "delete",
1353
+ uri,
1354
+ apiHeaders,
1355
+ payload
1356
+ );
1357
+ }
1358
+ /**
1359
+ * Create token
1360
+ *
1361
+ * Returns a token with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [PUT /account/sessions/custom](https://appwrite.io/docs/references/cloud/client-web/account#updateCustomSession) endpoint to complete the login process.
1362
+ *
1363
+ * @param {string} userId
1364
+ * @param {number} length
1365
+ * @param {number} expire
1366
+ * @throws {AppwriteException}
1367
+ * @returns {Promise<Models.Token>}
1368
+ */
1369
+ async createToken(userId, length, expire) {
1370
+ if (typeof userId === "undefined") {
1371
+ throw new AppwriteException('Missing required parameter: "userId"');
1372
+ }
1373
+ const apiPath = "/users/{userId}/tokens".replace("{userId}", userId);
1374
+ const payload = {};
1375
+ if (typeof length !== "undefined") {
1376
+ payload["length"] = length;
1377
+ }
1378
+ if (typeof expire !== "undefined") {
1379
+ payload["expire"] = expire;
1380
+ }
1381
+ const uri = new URL(this.client.config.endpoint + apiPath);
1382
+ const apiHeaders = {
1383
+ "content-type": "application/json"
1384
+ };
1385
+ return await this.client.call(
1386
+ "post",
1387
+ uri,
1388
+ apiHeaders,
1389
+ payload
1390
+ );
1391
+ }
1392
+ /**
1393
+ * Update email verification
1394
+ *
1395
+ * Update the user email verification status by its unique ID.
1396
+ *
1397
+ * @param {string} userId
1398
+ * @param {boolean} emailVerification
1399
+ * @throws {AppwriteException}
1400
+ * @returns {Promise<Models.User<Preferences>>}
1401
+ */
1402
+ async updateEmailVerification(userId, emailVerification) {
1403
+ if (typeof userId === "undefined") {
1404
+ throw new AppwriteException('Missing required parameter: "userId"');
1405
+ }
1406
+ if (typeof emailVerification === "undefined") {
1407
+ throw new AppwriteException('Missing required parameter: "emailVerification"');
1408
+ }
1409
+ const apiPath = "/users/{userId}/verification".replace("{userId}", userId);
1410
+ const payload = {};
1411
+ if (typeof emailVerification !== "undefined") {
1412
+ payload["emailVerification"] = emailVerification;
1413
+ }
1414
+ const uri = new URL(this.client.config.endpoint + apiPath);
1415
+ const apiHeaders = {
1416
+ "content-type": "application/json"
1417
+ };
1418
+ return await this.client.call(
1419
+ "patch",
1420
+ uri,
1421
+ apiHeaders,
1422
+ payload
1423
+ );
1424
+ }
1425
+ /**
1426
+ * Update phone verification
1427
+ *
1428
+ * Update the user phone verification status by its unique ID.
1429
+ *
1430
+ * @param {string} userId
1431
+ * @param {boolean} phoneVerification
1432
+ * @throws {AppwriteException}
1433
+ * @returns {Promise<Models.User<Preferences>>}
1434
+ */
1435
+ async updatePhoneVerification(userId, phoneVerification) {
1436
+ if (typeof userId === "undefined") {
1437
+ throw new AppwriteException('Missing required parameter: "userId"');
1438
+ }
1439
+ if (typeof phoneVerification === "undefined") {
1440
+ throw new AppwriteException('Missing required parameter: "phoneVerification"');
1441
+ }
1442
+ const apiPath = "/users/{userId}/verification/phone".replace("{userId}", userId);
1443
+ const payload = {};
1444
+ if (typeof phoneVerification !== "undefined") {
1445
+ payload["phoneVerification"] = phoneVerification;
1446
+ }
1447
+ const uri = new URL(this.client.config.endpoint + apiPath);
1448
+ const apiHeaders = {
1449
+ "content-type": "application/json"
1450
+ };
1451
+ return await this.client.call(
1452
+ "patch",
1453
+ uri,
1454
+ apiHeaders,
1455
+ payload
1456
+ );
1457
+ }
1458
+ }
1459
+
1460
+ export { Users };
1461
+ //# sourceMappingURL=out.js.map
1462
+ //# sourceMappingURL=users.mjs.map