@appconda/nextjs 1.0.18 → 1.0.20

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