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,56 +1,51 @@
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 { Runtime } from '../enums/runtime';
4
+ import { ExecutionMethod } from '../enums/execution-method';
10
5
 
11
- class Functions extends Service {
12
-
13
- constructor(client)
14
- {
15
- super(client);
16
- }
6
+ export class Functions {
7
+ client: Client;
17
8
 
9
+ constructor(client: Client) {
10
+ this.client = client;
11
+ }
18
12
 
19
13
  /**
20
14
  * List functions
21
15
  *
22
- * Get a list of all the project's functions. You can use the query params to
23
- * filter your results.
16
+ * Get a list of all the project's functions. You can use the query params to filter your results.
24
17
  *
25
18
  * @param {string[]} queries
26
19
  * @param {string} search
27
20
  * @throws {AppwriteException}
28
- * @returns {Promise}
21
+ * @returns {Promise<Models.FunctionList>}
29
22
  */
30
- async list(queries, search) {
23
+ async list(queries?: string[], search?: string): Promise<Models.FunctionList> {
31
24
  const apiPath = '/functions';
32
- let payload = {};
33
-
25
+ const payload: Payload = {};
34
26
  if (typeof queries !== 'undefined') {
35
27
  payload['queries'] = queries;
36
28
  }
37
-
38
29
  if (typeof search !== 'undefined') {
39
30
  payload['search'] = search;
40
31
  }
32
+ const uri = new URL(this.client.config.endpoint + apiPath);
41
33
 
42
- return await this.client.call('get', apiPath, {
34
+ const apiHeaders: { [header: string]: string } = {
43
35
  'content-type': 'application/json',
44
- }, payload);
45
- }
36
+ }
46
37
 
38
+ return await this.client.call(
39
+ 'get',
40
+ uri,
41
+ apiHeaders,
42
+ payload,
43
+ );
44
+ }
47
45
  /**
48
46
  * Create function
49
47
  *
50
- * Create a new function. You can pass a list of
51
- * [permissions](https://appwrite.io/docs/permissions) to allow different
52
- * project users or team with access to execute the function using the client
53
- * API.
48
+ * Create a new function. You can pass a list of [permissions](https://appwrite.io/docs/permissions) to allow different project users or team with access to execute the function using the client API.
54
49
  *
55
50
  * @param {string} functionId
56
51
  * @param {string} name
@@ -73,126 +68,117 @@ class Functions extends Service {
73
68
  * @param {string} templateRootDirectory
74
69
  * @param {string} templateBranch
75
70
  * @throws {AppwriteException}
76
- * @returns {Promise}
71
+ * @returns {Promise<Models.Function>}
77
72
  */
78
- async create(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory, templateRepository, templateOwner, templateRootDirectory, templateBranch) {
79
- const apiPath = '/functions';
80
- let payload = {};
73
+ async create(functionId: string, name: string, runtime: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string, templateRepository?: string, templateOwner?: string, templateRootDirectory?: string, templateBranch?: string): Promise<Models.Function> {
81
74
  if (typeof functionId === 'undefined') {
82
75
  throw new AppwriteException('Missing required parameter: "functionId"');
83
76
  }
84
-
85
77
  if (typeof name === 'undefined') {
86
78
  throw new AppwriteException('Missing required parameter: "name"');
87
79
  }
88
-
89
80
  if (typeof runtime === 'undefined') {
90
81
  throw new AppwriteException('Missing required parameter: "runtime"');
91
82
  }
92
-
93
-
83
+ const apiPath = '/functions';
84
+ const payload: Payload = {};
94
85
  if (typeof functionId !== 'undefined') {
95
86
  payload['functionId'] = functionId;
96
87
  }
97
-
98
88
  if (typeof name !== 'undefined') {
99
89
  payload['name'] = name;
100
90
  }
101
-
102
91
  if (typeof runtime !== 'undefined') {
103
92
  payload['runtime'] = runtime;
104
93
  }
105
-
106
94
  if (typeof execute !== 'undefined') {
107
95
  payload['execute'] = execute;
108
96
  }
109
-
110
97
  if (typeof events !== 'undefined') {
111
98
  payload['events'] = events;
112
99
  }
113
-
114
100
  if (typeof schedule !== 'undefined') {
115
101
  payload['schedule'] = schedule;
116
102
  }
117
-
118
103
  if (typeof timeout !== 'undefined') {
119
104
  payload['timeout'] = timeout;
120
105
  }
121
-
122
106
  if (typeof enabled !== 'undefined') {
123
107
  payload['enabled'] = enabled;
124
108
  }
125
-
126
109
  if (typeof logging !== 'undefined') {
127
110
  payload['logging'] = logging;
128
111
  }
129
-
130
112
  if (typeof entrypoint !== 'undefined') {
131
113
  payload['entrypoint'] = entrypoint;
132
114
  }
133
-
134
115
  if (typeof commands !== 'undefined') {
135
116
  payload['commands'] = commands;
136
117
  }
137
-
138
118
  if (typeof installationId !== 'undefined') {
139
119
  payload['installationId'] = installationId;
140
120
  }
141
-
142
121
  if (typeof providerRepositoryId !== 'undefined') {
143
122
  payload['providerRepositoryId'] = providerRepositoryId;
144
123
  }
145
-
146
124
  if (typeof providerBranch !== 'undefined') {
147
125
  payload['providerBranch'] = providerBranch;
148
126
  }
149
-
150
127
  if (typeof providerSilentMode !== 'undefined') {
151
128
  payload['providerSilentMode'] = providerSilentMode;
152
129
  }
153
-
154
130
  if (typeof providerRootDirectory !== 'undefined') {
155
131
  payload['providerRootDirectory'] = providerRootDirectory;
156
132
  }
157
-
158
133
  if (typeof templateRepository !== 'undefined') {
159
134
  payload['templateRepository'] = templateRepository;
160
135
  }
161
-
162
136
  if (typeof templateOwner !== 'undefined') {
163
137
  payload['templateOwner'] = templateOwner;
164
138
  }
165
-
166
139
  if (typeof templateRootDirectory !== 'undefined') {
167
140
  payload['templateRootDirectory'] = templateRootDirectory;
168
141
  }
169
-
170
142
  if (typeof templateBranch !== 'undefined') {
171
143
  payload['templateBranch'] = templateBranch;
172
144
  }
145
+ const uri = new URL(this.client.config.endpoint + apiPath);
173
146
 
174
- return await this.client.call('post', apiPath, {
147
+ const apiHeaders: { [header: string]: string } = {
175
148
  'content-type': 'application/json',
176
- }, payload);
177
- }
149
+ }
178
150
 
151
+ return await this.client.call(
152
+ 'post',
153
+ uri,
154
+ apiHeaders,
155
+ payload,
156
+ );
157
+ }
179
158
  /**
180
159
  * List runtimes
181
160
  *
182
161
  * Get a list of all runtimes that are currently active on your instance.
183
162
  *
184
163
  * @throws {AppwriteException}
185
- * @returns {Promise}
164
+ * @returns {Promise<Models.RuntimeList>}
186
165
  */
187
- async listRuntimes() {
166
+ async listRuntimes(): Promise<Models.RuntimeList> {
188
167
  const apiPath = '/functions/runtimes';
189
- let payload = {};
168
+ const payload: Payload = {};
169
+ const uri = new URL(this.client.config.endpoint + apiPath);
190
170
 
191
- return await this.client.call('get', apiPath, {
171
+ const apiHeaders: { [header: string]: string } = {
192
172
  'content-type': 'application/json',
193
- }, payload);
194
- }
173
+ }
195
174
 
175
+ return await this.client.call(
176
+ 'get',
177
+ uri,
178
+ apiHeaders,
179
+ payload,
180
+ );
181
+ }
196
182
  /**
197
183
  * Get function
198
184
  *
@@ -200,21 +186,27 @@ class Functions extends Service {
200
186
  *
201
187
  * @param {string} functionId
202
188
  * @throws {AppwriteException}
203
- * @returns {Promise}
189
+ * @returns {Promise<Models.Function>}
204
190
  */
205
- async get(functionId) {
206
- const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
207
- let payload = {};
191
+ async get(functionId: string): Promise<Models.Function> {
208
192
  if (typeof functionId === 'undefined') {
209
193
  throw new AppwriteException('Missing required parameter: "functionId"');
210
194
  }
195
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
196
+ const payload: Payload = {};
197
+ const uri = new URL(this.client.config.endpoint + apiPath);
211
198
 
212
-
213
- return await this.client.call('get', apiPath, {
199
+ const apiHeaders: { [header: string]: string } = {
214
200
  'content-type': 'application/json',
215
- }, payload);
216
- }
201
+ }
217
202
 
203
+ return await this.client.call(
204
+ 'get',
205
+ uri,
206
+ apiHeaders,
207
+ payload,
208
+ );
209
+ }
218
210
  /**
219
211
  * Update function
220
212
  *
@@ -237,85 +229,75 @@ class Functions extends Service {
237
229
  * @param {boolean} providerSilentMode
238
230
  * @param {string} providerRootDirectory
239
231
  * @throws {AppwriteException}
240
- * @returns {Promise}
232
+ * @returns {Promise<Models.Function>}
241
233
  */
242
- async update(functionId, name, runtime, execute, events, schedule, timeout, enabled, logging, entrypoint, commands, installationId, providerRepositoryId, providerBranch, providerSilentMode, providerRootDirectory) {
243
- const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
244
- let payload = {};
234
+ async update(functionId: string, name: string, runtime?: Runtime, execute?: string[], events?: string[], schedule?: string, timeout?: number, enabled?: boolean, logging?: boolean, entrypoint?: string, commands?: string, installationId?: string, providerRepositoryId?: string, providerBranch?: string, providerSilentMode?: boolean, providerRootDirectory?: string): Promise<Models.Function> {
245
235
  if (typeof functionId === 'undefined') {
246
236
  throw new AppwriteException('Missing required parameter: "functionId"');
247
237
  }
248
-
249
238
  if (typeof name === 'undefined') {
250
239
  throw new AppwriteException('Missing required parameter: "name"');
251
240
  }
252
-
253
-
241
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
242
+ const payload: Payload = {};
254
243
  if (typeof name !== 'undefined') {
255
244
  payload['name'] = name;
256
245
  }
257
-
258
246
  if (typeof runtime !== 'undefined') {
259
247
  payload['runtime'] = runtime;
260
248
  }
261
-
262
249
  if (typeof execute !== 'undefined') {
263
250
  payload['execute'] = execute;
264
251
  }
265
-
266
252
  if (typeof events !== 'undefined') {
267
253
  payload['events'] = events;
268
254
  }
269
-
270
255
  if (typeof schedule !== 'undefined') {
271
256
  payload['schedule'] = schedule;
272
257
  }
273
-
274
258
  if (typeof timeout !== 'undefined') {
275
259
  payload['timeout'] = timeout;
276
260
  }
277
-
278
261
  if (typeof enabled !== 'undefined') {
279
262
  payload['enabled'] = enabled;
280
263
  }
281
-
282
264
  if (typeof logging !== 'undefined') {
283
265
  payload['logging'] = logging;
284
266
  }
285
-
286
267
  if (typeof entrypoint !== 'undefined') {
287
268
  payload['entrypoint'] = entrypoint;
288
269
  }
289
-
290
270
  if (typeof commands !== 'undefined') {
291
271
  payload['commands'] = commands;
292
272
  }
293
-
294
273
  if (typeof installationId !== 'undefined') {
295
274
  payload['installationId'] = installationId;
296
275
  }
297
-
298
276
  if (typeof providerRepositoryId !== 'undefined') {
299
277
  payload['providerRepositoryId'] = providerRepositoryId;
300
278
  }
301
-
302
279
  if (typeof providerBranch !== 'undefined') {
303
280
  payload['providerBranch'] = providerBranch;
304
281
  }
305
-
306
282
  if (typeof providerSilentMode !== 'undefined') {
307
283
  payload['providerSilentMode'] = providerSilentMode;
308
284
  }
309
-
310
285
  if (typeof providerRootDirectory !== 'undefined') {
311
286
  payload['providerRootDirectory'] = providerRootDirectory;
312
287
  }
288
+ const uri = new URL(this.client.config.endpoint + apiPath);
313
289
 
314
- return await this.client.call('put', apiPath, {
290
+ const apiHeaders: { [header: string]: string } = {
315
291
  'content-type': 'application/json',
316
- }, payload);
317
- }
292
+ }
318
293
 
294
+ return await this.client.call(
295
+ 'put',
296
+ uri,
297
+ apiHeaders,
298
+ payload,
299
+ );
300
+ }
319
301
  /**
320
302
  * Delete function
321
303
  *
@@ -323,197 +305,118 @@ class Functions extends Service {
323
305
  *
324
306
  * @param {string} functionId
325
307
  * @throws {AppwriteException}
326
- * @returns {Promise}
308
+ * @returns {Promise<{}>}
327
309
  */
328
- async delete(functionId) {
329
- const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
330
- let payload = {};
310
+ async delete(functionId: string): Promise<{}> {
331
311
  if (typeof functionId === 'undefined') {
332
312
  throw new AppwriteException('Missing required parameter: "functionId"');
333
313
  }
314
+ const apiPath = '/functions/{functionId}'.replace('{functionId}', functionId);
315
+ const payload: Payload = {};
316
+ const uri = new URL(this.client.config.endpoint + apiPath);
334
317
 
335
-
336
- return await this.client.call('delete', apiPath, {
318
+ const apiHeaders: { [header: string]: string } = {
337
319
  'content-type': 'application/json',
338
- }, payload);
339
- }
320
+ }
340
321
 
322
+ return await this.client.call(
323
+ 'delete',
324
+ uri,
325
+ apiHeaders,
326
+ payload,
327
+ );
328
+ }
341
329
  /**
342
330
  * List deployments
343
331
  *
344
- * Get a list of all the project's code deployments. You can use the query
345
- * params to filter your results.
332
+ * Get a list of all the project&#039;s code deployments. You can use the query params to filter your results.
346
333
  *
347
334
  * @param {string} functionId
348
335
  * @param {string[]} queries
349
336
  * @param {string} search
350
337
  * @throws {AppwriteException}
351
- * @returns {Promise}
338
+ * @returns {Promise<Models.DeploymentList>}
352
339
  */
353
- async listDeployments(functionId, queries, search) {
354
- const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
355
- let payload = {};
340
+ async listDeployments(functionId: string, queries?: string[], search?: string): Promise<Models.DeploymentList> {
356
341
  if (typeof functionId === 'undefined') {
357
342
  throw new AppwriteException('Missing required parameter: "functionId"');
358
343
  }
359
-
360
-
344
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
345
+ const payload: Payload = {};
361
346
  if (typeof queries !== 'undefined') {
362
347
  payload['queries'] = queries;
363
348
  }
364
-
365
349
  if (typeof search !== 'undefined') {
366
350
  payload['search'] = search;
367
351
  }
352
+ const uri = new URL(this.client.config.endpoint + apiPath);
368
353
 
369
- return await this.client.call('get', apiPath, {
354
+ const apiHeaders: { [header: string]: string } = {
370
355
  'content-type': 'application/json',
371
- }, payload);
372
- }
356
+ }
373
357
 
358
+ return await this.client.call(
359
+ 'get',
360
+ uri,
361
+ apiHeaders,
362
+ payload,
363
+ );
364
+ }
374
365
  /**
375
366
  * Create deployment
376
367
  *
377
- * Create a new function code deployment. Use this endpoint to upload a new
378
- * version of your code function. To execute your newly uploaded code, you'll
379
- * need to update the function's deployment to use your new deployment UID.
380
- *
381
- * This endpoint accepts a tar.gz file compressed with your code. Make sure to
382
- * include any dependencies your code has within the compressed file. You can
383
- * learn more about code packaging in the [Appwrite Cloud Functions
384
- * tutorial](https://appwrite.io/docs/functions).
385
- *
386
- * Use the "command" param to set the entrypoint used to execute your code.
368
+ * Create a new function code deployment. Use this endpoint to upload a new version of your code function. To execute your newly uploaded code, you&#039;ll need to update the function&#039;s deployment to use your new deployment UID.
369
+
370
+ This endpoint accepts a tar.gz file compressed with your code. Make sure to include any dependencies your code has within the compressed file. You can learn more about code packaging in the [Appwrite Cloud Functions tutorial](https://appwrite.io/docs/functions).
371
+
372
+ Use the &quot;command&quot; param to set the entrypoint used to execute your code.
387
373
  *
388
374
  * @param {string} functionId
389
- * @param {InputFile} code
375
+ * @param {File} code
390
376
  * @param {boolean} activate
391
377
  * @param {string} entrypoint
392
378
  * @param {string} commands
393
- * @param {CallableFunction} onProgress
394
379
  * @throws {AppwriteException}
395
- * @returns {Promise}
380
+ * @returns {Promise<Models.Deployment>}
396
381
  */
397
- async createDeployment(functionId, code, activate, entrypoint, commands, onProgress = () => {}) {
398
- const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
399
- let payload = {};
382
+ async createDeployment(functionId: string, code: File, activate: boolean, entrypoint?: string, commands?: string, onProgress = (progress: UploadProgress) => {}): Promise<Models.Deployment> {
400
383
  if (typeof functionId === 'undefined') {
401
384
  throw new AppwriteException('Missing required parameter: "functionId"');
402
385
  }
403
-
404
386
  if (typeof code === 'undefined') {
405
387
  throw new AppwriteException('Missing required parameter: "code"');
406
388
  }
407
-
408
389
  if (typeof activate === 'undefined') {
409
390
  throw new AppwriteException('Missing required parameter: "activate"');
410
391
  }
411
-
412
-
392
+ const apiPath = '/functions/{functionId}/deployments'.replace('{functionId}', functionId);
393
+ const payload: Payload = {};
413
394
  if (typeof entrypoint !== 'undefined') {
414
395
  payload['entrypoint'] = entrypoint;
415
396
  }
416
-
417
397
  if (typeof commands !== 'undefined') {
418
398
  payload['commands'] = commands;
419
399
  }
420
-
421
400
  if (typeof code !== 'undefined') {
422
401
  payload['code'] = code;
423
402
  }
424
-
425
403
  if (typeof activate !== 'undefined') {
426
- payload['activate'] = activate.toString();
404
+ payload['activate'] = activate;
427
405
  }
406
+ const uri = new URL(this.client.config.endpoint + apiPath);
428
407
 
429
-
430
- const size = code.size;
431
-
432
- const apiHeaders = {
408
+ const apiHeaders: { [header: string]: string } = {
433
409
  'content-type': 'multipart/form-data',
434
- };
435
-
436
- let id = undefined;
437
- let response = undefined;
438
-
439
- let chunksUploaded = 0;
440
-
441
-
442
- let currentChunk = 1;
443
- let currentPosition = 0;
444
- let uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
445
-
446
-
447
- const uploadChunk = async (lastUpload = false) => {
448
- if(currentChunk <= chunksUploaded) {
449
- return;
450
- }
451
-
452
- const start = ((currentChunk - 1) * client.CHUNK_SIZE);
453
- let end = start + currentPosition - 1;
454
-
455
- if(!lastUpload || currentChunk !== 1) {
456
- apiHeaders['content-range'] = 'bytes ' + start + '-' + end + '/' + size;
457
- }
458
-
459
- let uploadableChunkTrimmed;
460
-
461
- if(currentPosition + 1 >= client.CHUNK_SIZE) {
462
- uploadableChunkTrimmed = uploadableChunk;
463
- } else {
464
- uploadableChunkTrimmed = new Uint8Array(currentPosition);
465
- for(let i = 0; i <= currentPosition; i++) {
466
- uploadableChunkTrimmed[i] = uploadableChunk[i];
467
- }
468
- }
469
-
470
- if (id) {
471
- apiHeaders['x-appwrite-id'] = id;
472
- }
473
-
474
- payload['code'] = { type: 'file', file: new File([uploadableChunkTrimmed], code.filename), filename: code.filename };
475
-
476
- response = await this.client.call('post', apiPath, apiHeaders, payload);
477
-
478
- if (!id) {
479
- id = response['$id'];
480
- }
481
-
482
- if (onProgress !== null) {
483
- onProgress({
484
- $id: response['$id'],
485
- progress: Math.min((currentChunk) * client.CHUNK_SIZE, size) / size * 100,
486
- sizeUploaded: end+1,
487
- chunksTotal: response['chunksTotal'],
488
- chunksUploaded: response['chunksUploaded']
489
- });
490
- }
491
-
492
- uploadableChunk = new Uint8Array(client.CHUNK_SIZE);
493
- currentChunk++;
494
- currentPosition = 0;
495
410
  }
496
411
 
497
- for await (const chunk of code.stream) {
498
- for(const b of chunk) {
499
- uploadableChunk[currentPosition] = b;
500
-
501
- currentPosition++;
502
- if(currentPosition >= client.CHUNK_SIZE) {
503
- await uploadChunk();
504
- currentPosition = 0;
505
- }
506
- }
507
- }
508
-
509
- if (currentPosition > 0) { // Check if there's any remaining data for the last chunk
510
- await uploadChunk(true);
511
- }
512
-
513
- return response;
514
-
412
+ return await this.client.chunkedUpload(
413
+ 'post',
414
+ uri,
415
+ apiHeaders,
416
+ payload,
417
+ onProgress
418
+ );
515
419
  }
516
-
517
420
  /**
518
421
  * Get deployment
519
422
  *
@@ -522,54 +425,62 @@ class Functions extends Service {
522
425
  * @param {string} functionId
523
426
  * @param {string} deploymentId
524
427
  * @throws {AppwriteException}
525
- * @returns {Promise}
428
+ * @returns {Promise<Models.Deployment>}
526
429
  */
527
- async getDeployment(functionId, deploymentId) {
528
- const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
529
- let payload = {};
430
+ async getDeployment(functionId: string, deploymentId: string): Promise<Models.Deployment> {
530
431
  if (typeof functionId === 'undefined') {
531
432
  throw new AppwriteException('Missing required parameter: "functionId"');
532
433
  }
533
-
534
434
  if (typeof deploymentId === 'undefined') {
535
435
  throw new AppwriteException('Missing required parameter: "deploymentId"');
536
436
  }
437
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
438
+ const payload: Payload = {};
439
+ const uri = new URL(this.client.config.endpoint + apiPath);
537
440
 
538
-
539
- return await this.client.call('get', apiPath, {
441
+ const apiHeaders: { [header: string]: string } = {
540
442
  'content-type': 'application/json',
541
- }, payload);
542
- }
443
+ }
543
444
 
445
+ return await this.client.call(
446
+ 'get',
447
+ uri,
448
+ apiHeaders,
449
+ payload,
450
+ );
451
+ }
544
452
  /**
545
453
  * Update function deployment
546
454
  *
547
- * Update the function code deployment ID using the unique function ID. Use
548
- * this endpoint to switch the code deployment that should be executed by the
549
- * execution endpoint.
455
+ * Update the function code deployment ID using the unique function ID. Use this endpoint to switch the code deployment that should be executed by the execution endpoint.
550
456
  *
551
457
  * @param {string} functionId
552
458
  * @param {string} deploymentId
553
459
  * @throws {AppwriteException}
554
- * @returns {Promise}
460
+ * @returns {Promise<Models.Function>}
555
461
  */
556
- async updateDeployment(functionId, deploymentId) {
557
- const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
558
- let payload = {};
462
+ async updateDeployment(functionId: string, deploymentId: string): Promise<Models.Function> {
559
463
  if (typeof functionId === 'undefined') {
560
464
  throw new AppwriteException('Missing required parameter: "functionId"');
561
465
  }
562
-
563
466
  if (typeof deploymentId === 'undefined') {
564
467
  throw new AppwriteException('Missing required parameter: "deploymentId"');
565
468
  }
469
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
470
+ const payload: Payload = {};
471
+ const uri = new URL(this.client.config.endpoint + apiPath);
566
472
 
567
-
568
- return await this.client.call('patch', apiPath, {
473
+ const apiHeaders: { [header: string]: string } = {
569
474
  'content-type': 'application/json',
570
- }, payload);
571
- }
475
+ }
572
476
 
477
+ return await this.client.call(
478
+ 'patch',
479
+ uri,
480
+ apiHeaders,
481
+ payload,
482
+ );
483
+ }
573
484
  /**
574
485
  * Delete deployment
575
486
  *
@@ -578,126 +489,139 @@ class Functions extends Service {
578
489
  * @param {string} functionId
579
490
  * @param {string} deploymentId
580
491
  * @throws {AppwriteException}
581
- * @returns {Promise}
492
+ * @returns {Promise<{}>}
582
493
  */
583
- async deleteDeployment(functionId, deploymentId) {
584
- const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
585
- let payload = {};
494
+ async deleteDeployment(functionId: string, deploymentId: string): Promise<{}> {
586
495
  if (typeof functionId === 'undefined') {
587
496
  throw new AppwriteException('Missing required parameter: "functionId"');
588
497
  }
589
-
590
498
  if (typeof deploymentId === 'undefined') {
591
499
  throw new AppwriteException('Missing required parameter: "deploymentId"');
592
500
  }
501
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
502
+ const payload: Payload = {};
503
+ const uri = new URL(this.client.config.endpoint + apiPath);
593
504
 
594
-
595
- return await this.client.call('delete', apiPath, {
505
+ const apiHeaders: { [header: string]: string } = {
596
506
  'content-type': 'application/json',
597
- }, payload);
598
- }
507
+ }
599
508
 
509
+ return await this.client.call(
510
+ 'delete',
511
+ uri,
512
+ apiHeaders,
513
+ payload,
514
+ );
515
+ }
600
516
  /**
601
517
  * Create build
602
518
  *
603
- * Create a new build for an Appwrite Function deployment. This endpoint can
604
- * be used to retry a failed build.
519
+ * Create a new build for an Appwrite Function deployment. This endpoint can be used to retry a failed build.
605
520
  *
606
521
  * @param {string} functionId
607
522
  * @param {string} deploymentId
608
523
  * @param {string} buildId
609
524
  * @throws {AppwriteException}
610
- * @returns {Promise}
525
+ * @returns {Promise<{}>}
611
526
  */
612
- async createBuild(functionId, deploymentId, buildId) {
613
- const apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
614
- let payload = {};
527
+ async createBuild(functionId: string, deploymentId: string, buildId: string): Promise<{}> {
615
528
  if (typeof functionId === 'undefined') {
616
529
  throw new AppwriteException('Missing required parameter: "functionId"');
617
530
  }
618
-
619
531
  if (typeof deploymentId === 'undefined') {
620
532
  throw new AppwriteException('Missing required parameter: "deploymentId"');
621
533
  }
622
-
623
534
  if (typeof buildId === 'undefined') {
624
535
  throw new AppwriteException('Missing required parameter: "buildId"');
625
536
  }
537
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/builds/{buildId}'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId).replace('{buildId}', buildId);
538
+ const payload: Payload = {};
539
+ const uri = new URL(this.client.config.endpoint + apiPath);
626
540
 
627
-
628
- return await this.client.call('post', apiPath, {
541
+ const apiHeaders: { [header: string]: string } = {
629
542
  'content-type': 'application/json',
630
- }, payload);
631
- }
543
+ }
632
544
 
545
+ return await this.client.call(
546
+ 'post',
547
+ uri,
548
+ apiHeaders,
549
+ payload,
550
+ );
551
+ }
633
552
  /**
634
553
  * Download Deployment
635
554
  *
636
- * Get a Deployment's contents by its unique ID. This endpoint supports range
637
- * requests for partial or streaming file download.
555
+ * Get a Deployment&#039;s contents by its unique ID. This endpoint supports range requests for partial or streaming file download.
638
556
  *
639
557
  * @param {string} functionId
640
558
  * @param {string} deploymentId
641
559
  * @throws {AppwriteException}
642
- * @returns {Promise}
560
+ * @returns {Promise<ArrayBuffer>}
643
561
  */
644
- async downloadDeployment(functionId, deploymentId) {
645
- const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
646
- let payload = {};
562
+ async downloadDeployment(functionId: string, deploymentId: string): Promise<ArrayBuffer> {
647
563
  if (typeof functionId === 'undefined') {
648
564
  throw new AppwriteException('Missing required parameter: "functionId"');
649
565
  }
650
-
651
566
  if (typeof deploymentId === 'undefined') {
652
567
  throw new AppwriteException('Missing required parameter: "deploymentId"');
653
568
  }
569
+ const apiPath = '/functions/{functionId}/deployments/{deploymentId}/download'.replace('{functionId}', functionId).replace('{deploymentId}', deploymentId);
570
+ const payload: Payload = {};
571
+ const uri = new URL(this.client.config.endpoint + apiPath);
654
572
 
655
-
656
- return await this.client.call('get', apiPath, {
573
+ const apiHeaders: { [header: string]: string } = {
657
574
  'content-type': 'application/json',
658
- }, payload, 'arraybuffer');
659
- }
575
+ }
660
576
 
577
+ return await this.client.call(
578
+ 'get',
579
+ uri,
580
+ apiHeaders,
581
+ payload,
582
+ 'arrayBuffer'
583
+ );
584
+ }
661
585
  /**
662
586
  * List executions
663
587
  *
664
- * Get a list of all the current user function execution logs. You can use the
665
- * query params to filter your results.
588
+ * Get a list of all the current user function execution logs. You can use the query params to filter your results.
666
589
  *
667
590
  * @param {string} functionId
668
591
  * @param {string[]} queries
669
592
  * @param {string} search
670
593
  * @throws {AppwriteException}
671
- * @returns {Promise}
594
+ * @returns {Promise<Models.ExecutionList>}
672
595
  */
673
- async listExecutions(functionId, queries, search) {
674
- const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
675
- let payload = {};
596
+ async listExecutions(functionId: string, queries?: string[], search?: string): Promise<Models.ExecutionList> {
676
597
  if (typeof functionId === 'undefined') {
677
598
  throw new AppwriteException('Missing required parameter: "functionId"');
678
599
  }
679
-
680
-
600
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
601
+ const payload: Payload = {};
681
602
  if (typeof queries !== 'undefined') {
682
603
  payload['queries'] = queries;
683
604
  }
684
-
685
605
  if (typeof search !== 'undefined') {
686
606
  payload['search'] = search;
687
607
  }
608
+ const uri = new URL(this.client.config.endpoint + apiPath);
688
609
 
689
- return await this.client.call('get', apiPath, {
610
+ const apiHeaders: { [header: string]: string } = {
690
611
  'content-type': 'application/json',
691
- }, payload);
692
- }
612
+ }
693
613
 
614
+ return await this.client.call(
615
+ 'get',
616
+ uri,
617
+ apiHeaders,
618
+ payload,
619
+ );
620
+ }
694
621
  /**
695
622
  * Create execution
696
623
  *
697
- * Trigger a function execution. The returned object will return you the
698
- * current execution status. You can ping the `Get Execution` endpoint to get
699
- * updates on the current execution status. Once this endpoint is called, your
700
- * function execution process will start asynchronously.
624
+ * Trigger a function execution. The returned object will return you the current execution status. You can ping the `Get Execution` endpoint to get updates on the current execution status. Once this endpoint is called, your function execution process will start asynchronously.
701
625
  *
702
626
  * @param {string} functionId
703
627
  * @param {string} body
@@ -706,41 +630,42 @@ class Functions extends Service {
706
630
  * @param {ExecutionMethod} method
707
631
  * @param {object} headers
708
632
  * @throws {AppwriteException}
709
- * @returns {Promise}
633
+ * @returns {Promise<Models.Execution>}
710
634
  */
711
- async createExecution(functionId, body, async, xpath, method, headers) {
712
- const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
713
- let payload = {};
635
+ async createExecution(functionId: string, body?: string, async?: boolean, xpath?: string, method?: ExecutionMethod, headers?: object): Promise<Models.Execution> {
714
636
  if (typeof functionId === 'undefined') {
715
637
  throw new AppwriteException('Missing required parameter: "functionId"');
716
638
  }
717
-
718
-
639
+ const apiPath = '/functions/{functionId}/executions'.replace('{functionId}', functionId);
640
+ const payload: Payload = {};
719
641
  if (typeof body !== 'undefined') {
720
642
  payload['body'] = body;
721
643
  }
722
-
723
644
  if (typeof async !== 'undefined') {
724
645
  payload['async'] = async;
725
646
  }
726
-
727
647
  if (typeof xpath !== 'undefined') {
728
648
  payload['path'] = xpath;
729
649
  }
730
-
731
650
  if (typeof method !== 'undefined') {
732
651
  payload['method'] = method;
733
652
  }
734
-
735
653
  if (typeof headers !== 'undefined') {
736
654
  payload['headers'] = headers;
737
655
  }
656
+ const uri = new URL(this.client.config.endpoint + apiPath);
738
657
 
739
- return await this.client.call('post', apiPath, {
658
+ const apiHeaders: { [header: string]: string } = {
740
659
  'content-type': 'application/json',
741
- }, payload);
742
- }
660
+ }
743
661
 
662
+ return await this.client.call(
663
+ 'post',
664
+ uri,
665
+ apiHeaders,
666
+ payload,
667
+ );
668
+ }
744
669
  /**
745
670
  * Get execution
746
671
  *
@@ -749,25 +674,30 @@ class Functions extends Service {
749
674
  * @param {string} functionId
750
675
  * @param {string} executionId
751
676
  * @throws {AppwriteException}
752
- * @returns {Promise}
677
+ * @returns {Promise<Models.Execution>}
753
678
  */
754
- async getExecution(functionId, executionId) {
755
- const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
756
- let payload = {};
679
+ async getExecution(functionId: string, executionId: string): Promise<Models.Execution> {
757
680
  if (typeof functionId === 'undefined') {
758
681
  throw new AppwriteException('Missing required parameter: "functionId"');
759
682
  }
760
-
761
683
  if (typeof executionId === 'undefined') {
762
684
  throw new AppwriteException('Missing required parameter: "executionId"');
763
685
  }
686
+ const apiPath = '/functions/{functionId}/executions/{executionId}'.replace('{functionId}', functionId).replace('{executionId}', executionId);
687
+ const payload: Payload = {};
688
+ const uri = new URL(this.client.config.endpoint + apiPath);
764
689
 
765
-
766
- return await this.client.call('get', apiPath, {
690
+ const apiHeaders: { [header: string]: string } = {
767
691
  'content-type': 'application/json',
768
- }, payload);
769
- }
692
+ }
770
693
 
694
+ return await this.client.call(
695
+ 'get',
696
+ uri,
697
+ apiHeaders,
698
+ payload,
699
+ );
700
+ }
771
701
  /**
772
702
  * List variables
773
703
  *
@@ -775,62 +705,69 @@ class Functions extends Service {
775
705
  *
776
706
  * @param {string} functionId
777
707
  * @throws {AppwriteException}
778
- * @returns {Promise}
708
+ * @returns {Promise<Models.VariableList>}
779
709
  */
780
- async listVariables(functionId) {
781
- const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
782
- let payload = {};
710
+ async listVariables(functionId: string): Promise<Models.VariableList> {
783
711
  if (typeof functionId === 'undefined') {
784
712
  throw new AppwriteException('Missing required parameter: "functionId"');
785
713
  }
714
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
715
+ const payload: Payload = {};
716
+ const uri = new URL(this.client.config.endpoint + apiPath);
786
717
 
787
-
788
- return await this.client.call('get', apiPath, {
718
+ const apiHeaders: { [header: string]: string } = {
789
719
  'content-type': 'application/json',
790
- }, payload);
791
- }
720
+ }
792
721
 
722
+ return await this.client.call(
723
+ 'get',
724
+ uri,
725
+ apiHeaders,
726
+ payload,
727
+ );
728
+ }
793
729
  /**
794
730
  * Create variable
795
731
  *
796
- * Create a new function environment variable. These variables can be accessed
797
- * in the function at runtime as environment variables.
732
+ * Create a new function environment variable. These variables can be accessed in the function at runtime as environment variables.
798
733
  *
799
734
  * @param {string} functionId
800
735
  * @param {string} key
801
736
  * @param {string} value
802
737
  * @throws {AppwriteException}
803
- * @returns {Promise}
738
+ * @returns {Promise<Models.Variable>}
804
739
  */
805
- async createVariable(functionId, key, value) {
806
- const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
807
- let payload = {};
740
+ async createVariable(functionId: string, key: string, value: string): Promise<Models.Variable> {
808
741
  if (typeof functionId === 'undefined') {
809
742
  throw new AppwriteException('Missing required parameter: "functionId"');
810
743
  }
811
-
812
744
  if (typeof key === 'undefined') {
813
745
  throw new AppwriteException('Missing required parameter: "key"');
814
746
  }
815
-
816
747
  if (typeof value === 'undefined') {
817
748
  throw new AppwriteException('Missing required parameter: "value"');
818
749
  }
819
-
820
-
750
+ const apiPath = '/functions/{functionId}/variables'.replace('{functionId}', functionId);
751
+ const payload: Payload = {};
821
752
  if (typeof key !== 'undefined') {
822
753
  payload['key'] = key;
823
754
  }
824
-
825
755
  if (typeof value !== 'undefined') {
826
756
  payload['value'] = value;
827
757
  }
758
+ const uri = new URL(this.client.config.endpoint + apiPath);
828
759
 
829
- return await this.client.call('post', apiPath, {
760
+ const apiHeaders: { [header: string]: string } = {
830
761
  'content-type': 'application/json',
831
- }, payload);
832
- }
762
+ }
833
763
 
764
+ return await this.client.call(
765
+ 'post',
766
+ uri,
767
+ apiHeaders,
768
+ payload,
769
+ );
770
+ }
834
771
  /**
835
772
  * Get variable
836
773
  *
@@ -839,25 +776,30 @@ class Functions extends Service {
839
776
  * @param {string} functionId
840
777
  * @param {string} variableId
841
778
  * @throws {AppwriteException}
842
- * @returns {Promise}
779
+ * @returns {Promise<Models.Variable>}
843
780
  */
844
- async getVariable(functionId, variableId) {
845
- const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
846
- let payload = {};
781
+ async getVariable(functionId: string, variableId: string): Promise<Models.Variable> {
847
782
  if (typeof functionId === 'undefined') {
848
783
  throw new AppwriteException('Missing required parameter: "functionId"');
849
784
  }
850
-
851
785
  if (typeof variableId === 'undefined') {
852
786
  throw new AppwriteException('Missing required parameter: "variableId"');
853
787
  }
788
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
789
+ const payload: Payload = {};
790
+ const uri = new URL(this.client.config.endpoint + apiPath);
854
791
 
855
-
856
- return await this.client.call('get', apiPath, {
792
+ const apiHeaders: { [header: string]: string } = {
857
793
  'content-type': 'application/json',
858
- }, payload);
859
- }
794
+ }
860
795
 
796
+ return await this.client.call(
797
+ 'get',
798
+ uri,
799
+ apiHeaders,
800
+ payload,
801
+ );
802
+ }
861
803
  /**
862
804
  * Update variable
863
805
  *
@@ -868,37 +810,39 @@ class Functions extends Service {
868
810
  * @param {string} key
869
811
  * @param {string} value
870
812
  * @throws {AppwriteException}
871
- * @returns {Promise}
813
+ * @returns {Promise<Models.Variable>}
872
814
  */
873
- async updateVariable(functionId, variableId, key, value) {
874
- const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
875
- let payload = {};
815
+ async updateVariable(functionId: string, variableId: string, key: string, value?: string): Promise<Models.Variable> {
876
816
  if (typeof functionId === 'undefined') {
877
817
  throw new AppwriteException('Missing required parameter: "functionId"');
878
818
  }
879
-
880
819
  if (typeof variableId === 'undefined') {
881
820
  throw new AppwriteException('Missing required parameter: "variableId"');
882
821
  }
883
-
884
822
  if (typeof key === 'undefined') {
885
823
  throw new AppwriteException('Missing required parameter: "key"');
886
824
  }
887
-
888
-
825
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
826
+ const payload: Payload = {};
889
827
  if (typeof key !== 'undefined') {
890
828
  payload['key'] = key;
891
829
  }
892
-
893
830
  if (typeof value !== 'undefined') {
894
831
  payload['value'] = value;
895
832
  }
833
+ const uri = new URL(this.client.config.endpoint + apiPath);
896
834
 
897
- return await this.client.call('put', apiPath, {
835
+ const apiHeaders: { [header: string]: string } = {
898
836
  'content-type': 'application/json',
899
- }, payload);
900
- }
837
+ }
901
838
 
839
+ return await this.client.call(
840
+ 'put',
841
+ uri,
842
+ apiHeaders,
843
+ payload,
844
+ );
845
+ }
902
846
  /**
903
847
  * Delete variable
904
848
  *
@@ -907,24 +851,28 @@ class Functions extends Service {
907
851
  * @param {string} functionId
908
852
  * @param {string} variableId
909
853
  * @throws {AppwriteException}
910
- * @returns {Promise}
854
+ * @returns {Promise<{}>}
911
855
  */
912
- async deleteVariable(functionId, variableId) {
913
- const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
914
- let payload = {};
856
+ async deleteVariable(functionId: string, variableId: string): Promise<{}> {
915
857
  if (typeof functionId === 'undefined') {
916
858
  throw new AppwriteException('Missing required parameter: "functionId"');
917
859
  }
918
-
919
860
  if (typeof variableId === 'undefined') {
920
861
  throw new AppwriteException('Missing required parameter: "variableId"');
921
862
  }
863
+ const apiPath = '/functions/{functionId}/variables/{variableId}'.replace('{functionId}', functionId).replace('{variableId}', variableId);
864
+ const payload: Payload = {};
865
+ const uri = new URL(this.client.config.endpoint + apiPath);
922
866
 
923
-
924
- return await this.client.call('delete', apiPath, {
867
+ const apiHeaders: { [header: string]: string } = {
925
868
  'content-type': 'application/json',
926
- }, payload);
869
+ }
870
+
871
+ return await this.client.call(
872
+ 'delete',
873
+ uri,
874
+ apiHeaders,
875
+ payload,
876
+ );
927
877
  }
928
878
  }
929
-
930
- module.exports = Functions;