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