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
@@ -1,91 +1,87 @@
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';
10
3
 
11
- class Teams extends Service {
12
-
13
- constructor(client)
14
- {
15
- super(client);
16
- }
4
+ export class Teams {
5
+ client: Client;
17
6
 
7
+ constructor(client: Client) {
8
+ this.client = client;
9
+ }
18
10
 
19
11
  /**
20
12
  * List teams
21
13
  *
22
- * Get a list of all the teams in which the current user is a member. You can
23
- * use the parameters to filter your results.
14
+ * Get a list of all the teams in which the current user is a member. You can use the parameters to filter your results.
24
15
  *
25
16
  * @param {string[]} queries
26
17
  * @param {string} search
27
18
  * @throws {AppwriteException}
28
- * @returns {Promise}
19
+ * @returns {Promise<Models.TeamList<Preferences>>}
29
20
  */
30
- async list(queries, search) {
21
+ async list<Preferences extends Models.Preferences>(queries?: string[], search?: string): Promise<Models.TeamList<Preferences>> {
31
22
  const apiPath = '/teams';
32
- let payload = {};
33
-
23
+ const payload: Payload = {};
34
24
  if (typeof queries !== 'undefined') {
35
25
  payload['queries'] = queries;
36
26
  }
37
-
38
27
  if (typeof search !== 'undefined') {
39
28
  payload['search'] = search;
40
29
  }
30
+ const uri = new URL(this.client.config.endpoint + apiPath);
41
31
 
42
- return await this.client.call('get', apiPath, {
32
+ const apiHeaders: { [header: string]: string } = {
43
33
  'content-type': 'application/json',
44
- }, payload);
45
- }
34
+ }
46
35
 
36
+ return await this.client.call(
37
+ 'get',
38
+ uri,
39
+ apiHeaders,
40
+ payload,
41
+ );
42
+ }
47
43
  /**
48
44
  * Create team
49
45
  *
50
- * Create a new team. The user who creates the team will automatically be
51
- * assigned as the owner of the team. Only the users with the owner role can
52
- * invite new members, add new owners and delete or update the team.
46
+ * Create a new team. The user who creates the team will automatically be assigned as the owner of the team. Only the users with the owner role can invite new members, add new owners and delete or update the team.
53
47
  *
54
48
  * @param {string} teamId
55
49
  * @param {string} name
56
50
  * @param {string[]} roles
57
51
  * @throws {AppwriteException}
58
- * @returns {Promise}
52
+ * @returns {Promise<Models.Team<Preferences>>}
59
53
  */
60
- async create(teamId, name, roles) {
61
- const apiPath = '/teams';
62
- let payload = {};
54
+ async create<Preferences extends Models.Preferences>(teamId: string, name: string, roles?: string[]): Promise<Models.Team<Preferences>> {
63
55
  if (typeof teamId === 'undefined') {
64
56
  throw new AppwriteException('Missing required parameter: "teamId"');
65
57
  }
66
-
67
58
  if (typeof name === 'undefined') {
68
59
  throw new AppwriteException('Missing required parameter: "name"');
69
60
  }
70
-
71
-
61
+ const apiPath = '/teams';
62
+ const payload: Payload = {};
72
63
  if (typeof teamId !== 'undefined') {
73
64
  payload['teamId'] = teamId;
74
65
  }
75
-
76
66
  if (typeof name !== 'undefined') {
77
67
  payload['name'] = name;
78
68
  }
79
-
80
69
  if (typeof roles !== 'undefined') {
81
70
  payload['roles'] = roles;
82
71
  }
72
+ const uri = new URL(this.client.config.endpoint + apiPath);
83
73
 
84
- return await this.client.call('post', apiPath, {
74
+ const apiHeaders: { [header: string]: string } = {
85
75
  'content-type': 'application/json',
86
- }, payload);
87
- }
76
+ }
88
77
 
78
+ return await this.client.call(
79
+ 'post',
80
+ uri,
81
+ apiHeaders,
82
+ payload,
83
+ );
84
+ }
89
85
  /**
90
86
  * Get team
91
87
  *
@@ -93,132 +89,137 @@ class Teams extends Service {
93
89
  *
94
90
  * @param {string} teamId
95
91
  * @throws {AppwriteException}
96
- * @returns {Promise}
92
+ * @returns {Promise<Models.Team<Preferences>>}
97
93
  */
98
- async get(teamId) {
99
- const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
100
- let payload = {};
94
+ async get<Preferences extends Models.Preferences>(teamId: string): Promise<Models.Team<Preferences>> {
101
95
  if (typeof teamId === 'undefined') {
102
96
  throw new AppwriteException('Missing required parameter: "teamId"');
103
97
  }
98
+ const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
99
+ const payload: Payload = {};
100
+ const uri = new URL(this.client.config.endpoint + apiPath);
104
101
 
105
-
106
- return await this.client.call('get', apiPath, {
102
+ const apiHeaders: { [header: string]: string } = {
107
103
  'content-type': 'application/json',
108
- }, payload);
109
- }
104
+ }
110
105
 
106
+ return await this.client.call(
107
+ 'get',
108
+ uri,
109
+ apiHeaders,
110
+ payload,
111
+ );
112
+ }
111
113
  /**
112
114
  * Update name
113
115
  *
114
- * Update the team's name by its unique ID.
116
+ * Update the team&#039;s name by its unique ID.
115
117
  *
116
118
  * @param {string} teamId
117
119
  * @param {string} name
118
120
  * @throws {AppwriteException}
119
- * @returns {Promise}
121
+ * @returns {Promise<Models.Team<Preferences>>}
120
122
  */
121
- async updateName(teamId, name) {
122
- const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
123
- let payload = {};
123
+ async updateName<Preferences extends Models.Preferences>(teamId: string, name: string): Promise<Models.Team<Preferences>> {
124
124
  if (typeof teamId === 'undefined') {
125
125
  throw new AppwriteException('Missing required parameter: "teamId"');
126
126
  }
127
-
128
127
  if (typeof name === 'undefined') {
129
128
  throw new AppwriteException('Missing required parameter: "name"');
130
129
  }
131
-
132
-
130
+ const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
131
+ const payload: Payload = {};
133
132
  if (typeof name !== 'undefined') {
134
133
  payload['name'] = name;
135
134
  }
135
+ const uri = new URL(this.client.config.endpoint + apiPath);
136
136
 
137
- return await this.client.call('put', apiPath, {
137
+ const apiHeaders: { [header: string]: string } = {
138
138
  'content-type': 'application/json',
139
- }, payload);
140
- }
139
+ }
141
140
 
141
+ return await this.client.call(
142
+ 'put',
143
+ uri,
144
+ apiHeaders,
145
+ payload,
146
+ );
147
+ }
142
148
  /**
143
149
  * Delete team
144
150
  *
145
- * Delete a team using its ID. Only team members with the owner role can
146
- * delete the team.
151
+ * Delete a team using its ID. Only team members with the owner role can delete the team.
147
152
  *
148
153
  * @param {string} teamId
149
154
  * @throws {AppwriteException}
150
- * @returns {Promise}
155
+ * @returns {Promise<{}>}
151
156
  */
152
- async delete(teamId) {
153
- const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
154
- let payload = {};
157
+ async delete(teamId: string): Promise<{}> {
155
158
  if (typeof teamId === 'undefined') {
156
159
  throw new AppwriteException('Missing required parameter: "teamId"');
157
160
  }
161
+ const apiPath = '/teams/{teamId}'.replace('{teamId}', teamId);
162
+ const payload: Payload = {};
163
+ const uri = new URL(this.client.config.endpoint + apiPath);
158
164
 
159
-
160
- return await this.client.call('delete', apiPath, {
165
+ const apiHeaders: { [header: string]: string } = {
161
166
  'content-type': 'application/json',
162
- }, payload);
163
- }
167
+ }
164
168
 
169
+ return await this.client.call(
170
+ 'delete',
171
+ uri,
172
+ apiHeaders,
173
+ payload,
174
+ );
175
+ }
165
176
  /**
166
177
  * List team memberships
167
178
  *
168
- * Use this endpoint to list a team's members using the team's ID. All team
169
- * members have read access to this endpoint.
179
+ * Use this endpoint to list a team&#039;s members using the team&#039;s ID. All team members have read access to this endpoint.
170
180
  *
171
181
  * @param {string} teamId
172
182
  * @param {string[]} queries
173
183
  * @param {string} search
174
184
  * @throws {AppwriteException}
175
- * @returns {Promise}
185
+ * @returns {Promise<Models.MembershipList>}
176
186
  */
177
- async listMemberships(teamId, queries, search) {
178
- const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
179
- let payload = {};
187
+ async listMemberships(teamId: string, queries?: string[], search?: string): Promise<Models.MembershipList> {
180
188
  if (typeof teamId === 'undefined') {
181
189
  throw new AppwriteException('Missing required parameter: "teamId"');
182
190
  }
183
-
184
-
191
+ const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
192
+ const payload: Payload = {};
185
193
  if (typeof queries !== 'undefined') {
186
194
  payload['queries'] = queries;
187
195
  }
188
-
189
196
  if (typeof search !== 'undefined') {
190
197
  payload['search'] = search;
191
198
  }
199
+ const uri = new URL(this.client.config.endpoint + apiPath);
192
200
 
193
- return await this.client.call('get', apiPath, {
201
+ const apiHeaders: { [header: string]: string } = {
194
202
  'content-type': 'application/json',
195
- }, payload);
196
- }
203
+ }
197
204
 
205
+ return await this.client.call(
206
+ 'get',
207
+ uri,
208
+ apiHeaders,
209
+ payload,
210
+ );
211
+ }
198
212
  /**
199
213
  * Create team membership
200
214
  *
201
- * Invite a new member to join your team. Provide an ID for existing users, or
202
- * invite unregistered users using an email or phone number. If initiated from
203
- * a Client SDK, Appwrite will send an email or sms with a link to join the
204
- * team to the invited user, and an account will be created for them if one
205
- * doesn't exist. If initiated from a Server SDK, the new member will be added
206
- * automatically to the team.
207
- *
208
- * You only need to provide one of a user ID, email, or phone number. Appwrite
209
- * will prioritize accepting the user ID > email > phone number if you provide
210
- * more than one of these parameters.
211
- *
212
- * Use the `url` parameter to redirect the user from the invitation email to
213
- * your app. After the user is redirected, use the [Update Team Membership
214
- * Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus)
215
- * endpoint to allow the user to accept the invitation to the team.
216
- *
217
- * Please note that to avoid a [Redirect
218
- * Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md)
219
- * Appwrite will accept the only redirect URLs under the domains you have
220
- * added as a platform on the Appwrite Console.
221
- *
215
+ * Invite a new member to join your team. Provide an ID for existing users, or invite unregistered users using an email or phone number. If initiated from a Client SDK, Appwrite will send an email or sms with a link to join the team to the invited user, and an account will be created for them if one doesn&#039;t exist. If initiated from a Server SDK, the new member will be added automatically to the team.
216
+
217
+ You only need to provide one of a user ID, email, or phone number. Appwrite will prioritize accepting the user ID &gt; email &gt; phone number if you provide more than one of these parameters.
218
+
219
+ Use the `url` parameter to redirect the user from the invitation email to your app. After the user is redirected, use the [Update Team Membership Status](https://appwrite.io/docs/references/cloud/client-web/teams#updateMembershipStatus) endpoint to allow the user to accept the invitation to the team.
220
+
221
+ Please note that to avoid a [Redirect Attack](https://github.com/OWASP/CheatSheetSeries/blob/master/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.md) Appwrite will accept the only redirect URLs under the domains you have added as a platform on the Appwrite Console.
222
+
222
223
  *
223
224
  * @param {string} teamId
224
225
  * @param {string[]} roles
@@ -228,252 +229,262 @@ class Teams extends Service {
228
229
  * @param {string} url
229
230
  * @param {string} name
230
231
  * @throws {AppwriteException}
231
- * @returns {Promise}
232
+ * @returns {Promise<Models.Membership>}
232
233
  */
233
- async createMembership(teamId, roles, email, userId, phone, url, name) {
234
- const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
235
- let payload = {};
234
+ async createMembership(teamId: string, roles: string[], email?: string, userId?: string, phone?: string, url?: string, name?: string): Promise<Models.Membership> {
236
235
  if (typeof teamId === 'undefined') {
237
236
  throw new AppwriteException('Missing required parameter: "teamId"');
238
237
  }
239
-
240
238
  if (typeof roles === 'undefined') {
241
239
  throw new AppwriteException('Missing required parameter: "roles"');
242
240
  }
243
-
244
-
241
+ const apiPath = '/teams/{teamId}/memberships'.replace('{teamId}', teamId);
242
+ const payload: Payload = {};
245
243
  if (typeof email !== 'undefined') {
246
244
  payload['email'] = email;
247
245
  }
248
-
249
246
  if (typeof userId !== 'undefined') {
250
247
  payload['userId'] = userId;
251
248
  }
252
-
253
249
  if (typeof phone !== 'undefined') {
254
250
  payload['phone'] = phone;
255
251
  }
256
-
257
252
  if (typeof roles !== 'undefined') {
258
253
  payload['roles'] = roles;
259
254
  }
260
-
261
255
  if (typeof url !== 'undefined') {
262
256
  payload['url'] = url;
263
257
  }
264
-
265
258
  if (typeof name !== 'undefined') {
266
259
  payload['name'] = name;
267
260
  }
261
+ const uri = new URL(this.client.config.endpoint + apiPath);
268
262
 
269
- return await this.client.call('post', apiPath, {
263
+ const apiHeaders: { [header: string]: string } = {
270
264
  'content-type': 'application/json',
271
- }, payload);
272
- }
265
+ }
273
266
 
267
+ return await this.client.call(
268
+ 'post',
269
+ uri,
270
+ apiHeaders,
271
+ payload,
272
+ );
273
+ }
274
274
  /**
275
275
  * Get team membership
276
276
  *
277
- * Get a team member by the membership unique id. All team members have read
278
- * access for this resource.
277
+ * Get a team member by the membership unique id. All team members have read access for this resource.
279
278
  *
280
279
  * @param {string} teamId
281
280
  * @param {string} membershipId
282
281
  * @throws {AppwriteException}
283
- * @returns {Promise}
282
+ * @returns {Promise<Models.Membership>}
284
283
  */
285
- async getMembership(teamId, membershipId) {
286
- const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
287
- let payload = {};
284
+ async getMembership(teamId: string, membershipId: string): Promise<Models.Membership> {
288
285
  if (typeof teamId === 'undefined') {
289
286
  throw new AppwriteException('Missing required parameter: "teamId"');
290
287
  }
291
-
292
288
  if (typeof membershipId === 'undefined') {
293
289
  throw new AppwriteException('Missing required parameter: "membershipId"');
294
290
  }
291
+ const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
292
+ const payload: Payload = {};
293
+ const uri = new URL(this.client.config.endpoint + apiPath);
295
294
 
296
-
297
- return await this.client.call('get', apiPath, {
295
+ const apiHeaders: { [header: string]: string } = {
298
296
  'content-type': 'application/json',
299
- }, payload);
300
- }
297
+ }
301
298
 
299
+ return await this.client.call(
300
+ 'get',
301
+ uri,
302
+ apiHeaders,
303
+ payload,
304
+ );
305
+ }
302
306
  /**
303
307
  * Update membership
304
308
  *
305
- * Modify the roles of a team member. Only team members with the owner role
306
- * have access to this endpoint. Learn more about [roles and
307
- * permissions](https://appwrite.io/docs/permissions).
308
- *
309
+ * Modify the roles of a team member. Only team members with the owner role have access to this endpoint. Learn more about [roles and permissions](https://appwrite.io/docs/permissions).
310
+
309
311
  *
310
312
  * @param {string} teamId
311
313
  * @param {string} membershipId
312
314
  * @param {string[]} roles
313
315
  * @throws {AppwriteException}
314
- * @returns {Promise}
316
+ * @returns {Promise<Models.Membership>}
315
317
  */
316
- async updateMembership(teamId, membershipId, roles) {
317
- const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
318
- let payload = {};
318
+ async updateMembership(teamId: string, membershipId: string, roles: string[]): Promise<Models.Membership> {
319
319
  if (typeof teamId === 'undefined') {
320
320
  throw new AppwriteException('Missing required parameter: "teamId"');
321
321
  }
322
-
323
322
  if (typeof membershipId === 'undefined') {
324
323
  throw new AppwriteException('Missing required parameter: "membershipId"');
325
324
  }
326
-
327
325
  if (typeof roles === 'undefined') {
328
326
  throw new AppwriteException('Missing required parameter: "roles"');
329
327
  }
330
-
331
-
328
+ const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
329
+ const payload: Payload = {};
332
330
  if (typeof roles !== 'undefined') {
333
331
  payload['roles'] = roles;
334
332
  }
333
+ const uri = new URL(this.client.config.endpoint + apiPath);
335
334
 
336
- return await this.client.call('patch', apiPath, {
335
+ const apiHeaders: { [header: string]: string } = {
337
336
  'content-type': 'application/json',
338
- }, payload);
339
- }
337
+ }
340
338
 
339
+ return await this.client.call(
340
+ 'patch',
341
+ uri,
342
+ apiHeaders,
343
+ payload,
344
+ );
345
+ }
341
346
  /**
342
347
  * Delete team membership
343
348
  *
344
- * This endpoint allows a user to leave a team or for a team owner to delete
345
- * the membership of any other team member. You can also use this endpoint to
346
- * delete a user membership even if it is not accepted.
349
+ * This endpoint allows a user to leave a team or for a team owner to delete the membership of any other team member. You can also use this endpoint to delete a user membership even if it is not accepted.
347
350
  *
348
351
  * @param {string} teamId
349
352
  * @param {string} membershipId
350
353
  * @throws {AppwriteException}
351
- * @returns {Promise}
354
+ * @returns {Promise<{}>}
352
355
  */
353
- async deleteMembership(teamId, membershipId) {
354
- const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
355
- let payload = {};
356
+ async deleteMembership(teamId: string, membershipId: string): Promise<{}> {
356
357
  if (typeof teamId === 'undefined') {
357
358
  throw new AppwriteException('Missing required parameter: "teamId"');
358
359
  }
359
-
360
360
  if (typeof membershipId === 'undefined') {
361
361
  throw new AppwriteException('Missing required parameter: "membershipId"');
362
362
  }
363
+ const apiPath = '/teams/{teamId}/memberships/{membershipId}'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
364
+ const payload: Payload = {};
365
+ const uri = new URL(this.client.config.endpoint + apiPath);
363
366
 
364
-
365
- return await this.client.call('delete', apiPath, {
367
+ const apiHeaders: { [header: string]: string } = {
366
368
  'content-type': 'application/json',
367
- }, payload);
368
- }
369
+ }
369
370
 
371
+ return await this.client.call(
372
+ 'delete',
373
+ uri,
374
+ apiHeaders,
375
+ payload,
376
+ );
377
+ }
370
378
  /**
371
379
  * Update team membership status
372
380
  *
373
- * Use this endpoint to allow a user to accept an invitation to join a team
374
- * after being redirected back to your app from the invitation email received
375
- * by the user.
376
- *
377
- * If the request is successful, a session for the user is automatically
378
- * created.
379
- *
381
+ * Use this endpoint to allow a user to accept an invitation to join a team after being redirected back to your app from the invitation email received by the user.
382
+
383
+ If the request is successful, a session for the user is automatically created.
384
+
380
385
  *
381
386
  * @param {string} teamId
382
387
  * @param {string} membershipId
383
388
  * @param {string} userId
384
389
  * @param {string} secret
385
390
  * @throws {AppwriteException}
386
- * @returns {Promise}
391
+ * @returns {Promise<Models.Membership>}
387
392
  */
388
- async updateMembershipStatus(teamId, membershipId, userId, secret) {
389
- const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
390
- let payload = {};
393
+ async updateMembershipStatus(teamId: string, membershipId: string, userId: string, secret: string): Promise<Models.Membership> {
391
394
  if (typeof teamId === 'undefined') {
392
395
  throw new AppwriteException('Missing required parameter: "teamId"');
393
396
  }
394
-
395
397
  if (typeof membershipId === 'undefined') {
396
398
  throw new AppwriteException('Missing required parameter: "membershipId"');
397
399
  }
398
-
399
400
  if (typeof userId === 'undefined') {
400
401
  throw new AppwriteException('Missing required parameter: "userId"');
401
402
  }
402
-
403
403
  if (typeof secret === 'undefined') {
404
404
  throw new AppwriteException('Missing required parameter: "secret"');
405
405
  }
406
-
407
-
406
+ const apiPath = '/teams/{teamId}/memberships/{membershipId}/status'.replace('{teamId}', teamId).replace('{membershipId}', membershipId);
407
+ const payload: Payload = {};
408
408
  if (typeof userId !== 'undefined') {
409
409
  payload['userId'] = userId;
410
410
  }
411
-
412
411
  if (typeof secret !== 'undefined') {
413
412
  payload['secret'] = secret;
414
413
  }
414
+ const uri = new URL(this.client.config.endpoint + apiPath);
415
415
 
416
- return await this.client.call('patch', apiPath, {
416
+ const apiHeaders: { [header: string]: string } = {
417
417
  'content-type': 'application/json',
418
- }, payload);
419
- }
418
+ }
420
419
 
420
+ return await this.client.call(
421
+ 'patch',
422
+ uri,
423
+ apiHeaders,
424
+ payload,
425
+ );
426
+ }
421
427
  /**
422
428
  * Get team preferences
423
429
  *
424
- * Get the team's shared preferences by its unique ID. If a preference doesn't
425
- * need to be shared by all team members, prefer storing them in [user
426
- * preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs).
430
+ * Get the team&#039;s shared preferences by its unique ID. If a preference doesn&#039;t need to be shared by all team members, prefer storing them in [user preferences](https://appwrite.io/docs/references/cloud/client-web/account#getPrefs).
427
431
  *
428
432
  * @param {string} teamId
429
433
  * @throws {AppwriteException}
430
- * @returns {Promise}
434
+ * @returns {Promise<Preferences>}
431
435
  */
432
- async getPrefs(teamId) {
433
- const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
434
- let payload = {};
436
+ async getPrefs<Preferences extends Models.Preferences>(teamId: string): Promise<Preferences> {
435
437
  if (typeof teamId === 'undefined') {
436
438
  throw new AppwriteException('Missing required parameter: "teamId"');
437
439
  }
440
+ const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
441
+ const payload: Payload = {};
442
+ const uri = new URL(this.client.config.endpoint + apiPath);
438
443
 
439
-
440
- return await this.client.call('get', apiPath, {
444
+ const apiHeaders: { [header: string]: string } = {
441
445
  'content-type': 'application/json',
442
- }, payload);
443
- }
446
+ }
444
447
 
448
+ return await this.client.call(
449
+ 'get',
450
+ uri,
451
+ apiHeaders,
452
+ payload,
453
+ );
454
+ }
445
455
  /**
446
456
  * Update preferences
447
457
  *
448
- * Update the team's preferences by its unique ID. The object you pass is
449
- * stored as is and replaces any previous value. The maximum allowed prefs
450
- * size is 64kB and throws an error if exceeded.
458
+ * Update the team&#039;s 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 an error if exceeded.
451
459
  *
452
460
  * @param {string} teamId
453
461
  * @param {object} prefs
454
462
  * @throws {AppwriteException}
455
- * @returns {Promise}
463
+ * @returns {Promise<Preferences>}
456
464
  */
457
- async updatePrefs(teamId, prefs) {
458
- const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
459
- let payload = {};
465
+ async updatePrefs<Preferences extends Models.Preferences>(teamId: string, prefs: object): Promise<Preferences> {
460
466
  if (typeof teamId === 'undefined') {
461
467
  throw new AppwriteException('Missing required parameter: "teamId"');
462
468
  }
463
-
464
469
  if (typeof prefs === 'undefined') {
465
470
  throw new AppwriteException('Missing required parameter: "prefs"');
466
471
  }
467
-
468
-
472
+ const apiPath = '/teams/{teamId}/prefs'.replace('{teamId}', teamId);
473
+ const payload: Payload = {};
469
474
  if (typeof prefs !== 'undefined') {
470
475
  payload['prefs'] = prefs;
471
476
  }
477
+ const uri = new URL(this.client.config.endpoint + apiPath);
472
478
 
473
- return await this.client.call('put', apiPath, {
479
+ const apiHeaders: { [header: string]: string } = {
474
480
  'content-type': 'application/json',
475
- }, payload);
481
+ }
482
+
483
+ return await this.client.call(
484
+ 'put',
485
+ uri,
486
+ apiHeaders,
487
+ payload,
488
+ );
476
489
  }
477
490
  }
478
-
479
- module.exports = Teams;