@thelllabs/winehaus-sdk 0.0.3 → 0.0.6

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.
@@ -85,25 +85,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
85
85
  return (mod && mod.__esModule) ? mod : { "default": mod };
86
86
  };
87
87
  Object.defineProperty(exports, "__esModule", { value: true });
88
- exports.Api = exports.HttpClient = exports.ContentType = exports.TenantUserEntityDtoStatusEnum = exports.TenantUserEntityDtoRolesEnum = exports.CreateTenantUserDtoRolesEnum = void 0;
89
- var CreateTenantUserDtoRolesEnum;
90
- (function (CreateTenantUserDtoRolesEnum) {
91
- CreateTenantUserDtoRolesEnum["Operator"] = "operator";
92
- CreateTenantUserDtoRolesEnum["Admin"] = "admin";
93
- CreateTenantUserDtoRolesEnum["Owner"] = "owner";
94
- })(CreateTenantUserDtoRolesEnum = exports.CreateTenantUserDtoRolesEnum || (exports.CreateTenantUserDtoRolesEnum = {}));
95
- var TenantUserEntityDtoRolesEnum;
96
- (function (TenantUserEntityDtoRolesEnum) {
97
- TenantUserEntityDtoRolesEnum["Operator"] = "operator";
98
- TenantUserEntityDtoRolesEnum["Admin"] = "admin";
99
- TenantUserEntityDtoRolesEnum["Owner"] = "owner";
100
- })(TenantUserEntityDtoRolesEnum = exports.TenantUserEntityDtoRolesEnum || (exports.TenantUserEntityDtoRolesEnum = {}));
101
- /** @example "enabled" */
102
- var TenantUserEntityDtoStatusEnum;
103
- (function (TenantUserEntityDtoStatusEnum) {
104
- TenantUserEntityDtoStatusEnum["Enabled"] = "enabled";
105
- TenantUserEntityDtoStatusEnum["Blocked"] = "blocked";
106
- })(TenantUserEntityDtoStatusEnum = exports.TenantUserEntityDtoStatusEnum || (exports.TenantUserEntityDtoStatusEnum = {}));
88
+ exports.Api = exports.HttpClient = exports.ContentType = exports.TenantUserStatusEnum = exports.TenantRoleEnum = exports.OrderByEnum = void 0;
89
+ var OrderByEnum;
90
+ (function (OrderByEnum) {
91
+ OrderByEnum["ASC"] = "ASC";
92
+ OrderByEnum["DESC"] = "DESC";
93
+ })(OrderByEnum = exports.OrderByEnum || (exports.OrderByEnum = {}));
94
+ var TenantRoleEnum;
95
+ (function (TenantRoleEnum) {
96
+ TenantRoleEnum["Operator"] = "operator";
97
+ TenantRoleEnum["Admin"] = "admin";
98
+ TenantRoleEnum["Owner"] = "owner";
99
+ })(TenantRoleEnum = exports.TenantRoleEnum || (exports.TenantRoleEnum = {}));
100
+ var TenantUserStatusEnum;
101
+ (function (TenantUserStatusEnum) {
102
+ TenantUserStatusEnum["Enabled"] = "enabled";
103
+ TenantUserStatusEnum["Blocked"] = "blocked";
104
+ })(TenantUserStatusEnum = exports.TenantUserStatusEnum || (exports.TenantUserStatusEnum = {}));
107
105
  var axios_1 = __importDefault(require("axios"));
108
106
  var ContentType;
109
107
  (function (ContentType) {
@@ -272,21 +270,93 @@ var Api = /** @class */ (function (_super) {
272
270
  return _this.request(__assign({ path: "/auth/signin", method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
273
271
  },
274
272
  };
273
+ _this.users = {
274
+ /**
275
+ * No description
276
+ *
277
+ * @tags Users
278
+ * @name UpdateUserPassword
279
+ * @request PATCH:/users/{userId}/password
280
+ * @secure
281
+ * @response `200` `UserEntityDto`
282
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
283
+ */
284
+ updateUserPassword: function (userId, data, params) {
285
+ if (params === void 0) { params = {}; }
286
+ return _this.request(__assign({ path: "/users/".concat(userId, "/password"), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
287
+ },
288
+ /**
289
+ * No description
290
+ *
291
+ * @tags Users
292
+ * @name UpdateUserProfile
293
+ * @request PATCH:/users/{userId}
294
+ * @secure
295
+ * @response `200` `UserEntityDto`
296
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
297
+ */
298
+ updateUserProfile: function (userId, data, params) {
299
+ if (params === void 0) { params = {}; }
300
+ return _this.request(__assign({ path: "/users/".concat(userId), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
301
+ },
302
+ };
275
303
  _this.admin = {
276
304
  /**
277
- * @description Gives some user access to the tenant. If there's no account attached to this users, it creates a new one
305
+ * @description Gives some user access to the tenant. If there's no user account attached to this users, it creates a new one
278
306
  *
279
- * @tags Admin Users
280
- * @name CreateTenantUser
307
+ * @tags Admin Tenant Users
308
+ * @name CreateOrUpdateTenantUserAndPermissionsByUserEmail
281
309
  * @request POST:/admin/tenants/{tenantId}/users
282
310
  * @secure
283
- * @response `201` `TenantUserEntityDto`
311
+ * @response `200` `TenantUserEntityDto`
284
312
  * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
285
313
  */
286
- createTenantUser: function (tenantId, data, params) {
314
+ createOrUpdateTenantUserAndPermissionsByUserEmail: function (tenantId, data, params) {
287
315
  if (params === void 0) { params = {}; }
288
316
  return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
289
317
  },
318
+ /**
319
+ * No description
320
+ *
321
+ * @tags Admin Tenant Users
322
+ * @name DisableTenantUser
323
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/disable
324
+ * @secure
325
+ * @response `204` `void`
326
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
327
+ */
328
+ disableTenantUser: function (tenantId, userId, params) {
329
+ if (params === void 0) { params = {}; }
330
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/disable"), method: "PATCH", secure: true }, params));
331
+ },
332
+ /**
333
+ * No description
334
+ *
335
+ * @tags Admin Tenant Users
336
+ * @name EnableTenantUser
337
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/enable
338
+ * @secure
339
+ * @response `204` `void`
340
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
341
+ */
342
+ enableTenantUser: function (tenantId, userId, params) {
343
+ if (params === void 0) { params = {}; }
344
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/enable"), method: "PATCH", secure: true }, params));
345
+ },
346
+ /**
347
+ * No description
348
+ *
349
+ * @tags Admin Tenant Users
350
+ * @name ListTenantUsers
351
+ * @request GET:/admin/tenants/{tenantId}/users
352
+ * @secure
353
+ * @response `200` `TenantUserEntityPaginationDto`
354
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
355
+ */
356
+ listTenantUsers: function (tenantId, query, params) {
357
+ if (params === void 0) { params = {}; }
358
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "GET", query: query, secure: true, format: "json" }, params));
359
+ },
290
360
  };
291
361
  return _this;
292
362
  }
package/dist/cjs/sdk.js CHANGED
@@ -150,13 +150,13 @@ var WinehausSDK = /** @class */ (function () {
150
150
  case 0:
151
151
  if (!(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 &&
152
152
  this.authToken &&
153
- this.refreshToken &&
153
+ // ToDO: Uncomment this this.refreshToken &&
154
154
  !refreshTokenUsed.has(this.refreshToken))) return [3 /*break*/, 4];
155
155
  refreshTokenUsed.add(this.refreshToken);
156
156
  _c.label = 1;
157
157
  case 1:
158
158
  _c.trys.push([1, 3, , 4]);
159
- return [4 /*yield*/, this.refreshTokens()];
159
+ return [4 /*yield*/, this.refreshTokens({ throwError: true })];
160
160
  case 2:
161
161
  _c.sent();
162
162
  return [3 /*break*/, 4];
@@ -184,10 +184,22 @@ var WinehausSDK = /** @class */ (function () {
184
184
  case 0:
185
185
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
186
186
  this.emitter.emit('connecting');
187
+ if (!((credential === null || credential === void 0 ? void 0 : credential.email) && (credential === null || credential === void 0 ? void 0 : credential.password))) return [3 /*break*/, 2];
187
188
  return [4 /*yield*/, this.authenticateAsUser(credential)];
188
189
  case 1:
189
190
  _a.sent();
190
- this.credential = credential;
191
+ this.signInCredential = credential;
192
+ return [3 /*break*/, 5];
193
+ case 2:
194
+ if (!(credential === null || credential === void 0 ? void 0 : credential.authToken)) return [3 /*break*/, 4];
195
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
196
+ return [4 /*yield*/, this.authenticateAsToken(credential)];
197
+ case 3:
198
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
199
+ _a.sent();
200
+ return [3 /*break*/, 5];
201
+ case 4: throw new Error("Invalid auth credential type format");
202
+ case 5:
191
203
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
192
204
  this.emitter.emit('connected');
193
205
  this.hookTimer();
@@ -196,14 +208,17 @@ var WinehausSDK = /** @class */ (function () {
196
208
  });
197
209
  });
198
210
  };
199
- WinehausSDK.prototype.reAuthenticate = function () {
211
+ WinehausSDK.prototype.reAuthenticate = function (opts) {
200
212
  return __awaiter(this, void 0, void 0, function () {
201
213
  return __generator(this, function (_a) {
202
214
  switch (_a.label) {
203
215
  case 0:
204
- if (!this.credential)
205
- throw new Error('No credential found');
206
- return [4 /*yield*/, this.authenticate(this.credential)];
216
+ if (!this.signInCredential) {
217
+ if (opts === null || opts === void 0 ? void 0 : opts.throwError)
218
+ new Error("No SignIn set to make re-auth");
219
+ return [2 /*return*/];
220
+ }
221
+ return [4 /*yield*/, this.authenticate(this.signInCredential, { avoidEvents: true })];
207
222
  case 1:
208
223
  _a.sent();
209
224
  return [2 /*return*/];
@@ -232,7 +247,8 @@ var WinehausSDK = /** @class */ (function () {
232
247
  return __generator(this, function (_b) {
233
248
  switch (_b.label) {
234
249
  case 0:
235
- if (!this.authToken || !this.refreshToken) {
250
+ //Todo: add || !this.refreshToken after implementing it here
251
+ if (!this.authToken) {
236
252
  return [2 /*return*/, this.clearTokens()];
237
253
  }
238
254
  if (!((_a = this.authTokenDecoded) === null || _a === void 0 ? void 0 : _a.exp)) {
@@ -277,14 +293,14 @@ var WinehausSDK = /** @class */ (function () {
277
293
  WinehausSDK.prototype.getRefreshToken = function () {
278
294
  return this.refreshToken.toString();
279
295
  };
280
- WinehausSDK.prototype.refreshTokens = function () {
296
+ WinehausSDK.prototype.refreshTokens = function (opts) {
281
297
  return __awaiter(this, void 0, void 0, function () {
282
298
  return __generator(this, function (_a) {
283
299
  switch (_a.label) {
284
300
  case 0:
285
301
  // ToDo: Refresh token is not implemented under this version. For a while, lets just re-auth
286
302
  this.clearTokens();
287
- return [4 /*yield*/, this.reAuthenticate()];
303
+ return [4 /*yield*/, this.reAuthenticate(opts)];
288
304
  case 1:
289
305
  _a.sent();
290
306
  return [2 /*return*/];
@@ -310,6 +326,14 @@ var WinehausSDK = /** @class */ (function () {
310
326
  });
311
327
  });
312
328
  };
329
+ WinehausSDK.prototype.authenticateAsToken = function (credential) {
330
+ return __awaiter(this, void 0, void 0, function () {
331
+ return __generator(this, function (_a) {
332
+ this.setTokens({ token: credential.authToken, refreshToken: credential.refreshToken });
333
+ return [2 /*return*/];
334
+ });
335
+ });
336
+ };
313
337
  WinehausSDK.prototype.setTokens = function (data) {
314
338
  this.setAuthToken(data.token);
315
339
  this.setRefreshToken(data.refreshToken);
@@ -80,24 +80,22 @@ var __rest = (this && this.__rest) || function (s, e) {
80
80
  }
81
81
  return t;
82
82
  };
83
- export var CreateTenantUserDtoRolesEnum;
84
- (function (CreateTenantUserDtoRolesEnum) {
85
- CreateTenantUserDtoRolesEnum["Operator"] = "operator";
86
- CreateTenantUserDtoRolesEnum["Admin"] = "admin";
87
- CreateTenantUserDtoRolesEnum["Owner"] = "owner";
88
- })(CreateTenantUserDtoRolesEnum || (CreateTenantUserDtoRolesEnum = {}));
89
- export var TenantUserEntityDtoRolesEnum;
90
- (function (TenantUserEntityDtoRolesEnum) {
91
- TenantUserEntityDtoRolesEnum["Operator"] = "operator";
92
- TenantUserEntityDtoRolesEnum["Admin"] = "admin";
93
- TenantUserEntityDtoRolesEnum["Owner"] = "owner";
94
- })(TenantUserEntityDtoRolesEnum || (TenantUserEntityDtoRolesEnum = {}));
95
- /** @example "enabled" */
96
- export var TenantUserEntityDtoStatusEnum;
97
- (function (TenantUserEntityDtoStatusEnum) {
98
- TenantUserEntityDtoStatusEnum["Enabled"] = "enabled";
99
- TenantUserEntityDtoStatusEnum["Blocked"] = "blocked";
100
- })(TenantUserEntityDtoStatusEnum || (TenantUserEntityDtoStatusEnum = {}));
83
+ export var OrderByEnum;
84
+ (function (OrderByEnum) {
85
+ OrderByEnum["ASC"] = "ASC";
86
+ OrderByEnum["DESC"] = "DESC";
87
+ })(OrderByEnum || (OrderByEnum = {}));
88
+ export var TenantRoleEnum;
89
+ (function (TenantRoleEnum) {
90
+ TenantRoleEnum["Operator"] = "operator";
91
+ TenantRoleEnum["Admin"] = "admin";
92
+ TenantRoleEnum["Owner"] = "owner";
93
+ })(TenantRoleEnum || (TenantRoleEnum = {}));
94
+ export var TenantUserStatusEnum;
95
+ (function (TenantUserStatusEnum) {
96
+ TenantUserStatusEnum["Enabled"] = "enabled";
97
+ TenantUserStatusEnum["Blocked"] = "blocked";
98
+ })(TenantUserStatusEnum || (TenantUserStatusEnum = {}));
101
99
  import axios from "axios";
102
100
  export var ContentType;
103
101
  (function (ContentType) {
@@ -266,21 +264,93 @@ var Api = /** @class */ (function (_super) {
266
264
  return _this.request(__assign({ path: "/auth/signin", method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
267
265
  },
268
266
  };
267
+ _this.users = {
268
+ /**
269
+ * No description
270
+ *
271
+ * @tags Users
272
+ * @name UpdateUserPassword
273
+ * @request PATCH:/users/{userId}/password
274
+ * @secure
275
+ * @response `200` `UserEntityDto`
276
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
277
+ */
278
+ updateUserPassword: function (userId, data, params) {
279
+ if (params === void 0) { params = {}; }
280
+ return _this.request(__assign({ path: "/users/".concat(userId, "/password"), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
281
+ },
282
+ /**
283
+ * No description
284
+ *
285
+ * @tags Users
286
+ * @name UpdateUserProfile
287
+ * @request PATCH:/users/{userId}
288
+ * @secure
289
+ * @response `200` `UserEntityDto`
290
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
291
+ */
292
+ updateUserProfile: function (userId, data, params) {
293
+ if (params === void 0) { params = {}; }
294
+ return _this.request(__assign({ path: "/users/".concat(userId), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
295
+ },
296
+ };
269
297
  _this.admin = {
270
298
  /**
271
- * @description Gives some user access to the tenant. If there's no account attached to this users, it creates a new one
299
+ * @description Gives some user access to the tenant. If there's no user account attached to this users, it creates a new one
272
300
  *
273
- * @tags Admin Users
274
- * @name CreateTenantUser
301
+ * @tags Admin Tenant Users
302
+ * @name CreateOrUpdateTenantUserAndPermissionsByUserEmail
275
303
  * @request POST:/admin/tenants/{tenantId}/users
276
304
  * @secure
277
- * @response `201` `TenantUserEntityDto`
305
+ * @response `200` `TenantUserEntityDto`
278
306
  * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
279
307
  */
280
- createTenantUser: function (tenantId, data, params) {
308
+ createOrUpdateTenantUserAndPermissionsByUserEmail: function (tenantId, data, params) {
281
309
  if (params === void 0) { params = {}; }
282
310
  return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
283
311
  },
312
+ /**
313
+ * No description
314
+ *
315
+ * @tags Admin Tenant Users
316
+ * @name DisableTenantUser
317
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/disable
318
+ * @secure
319
+ * @response `204` `void`
320
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
321
+ */
322
+ disableTenantUser: function (tenantId, userId, params) {
323
+ if (params === void 0) { params = {}; }
324
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/disable"), method: "PATCH", secure: true }, params));
325
+ },
326
+ /**
327
+ * No description
328
+ *
329
+ * @tags Admin Tenant Users
330
+ * @name EnableTenantUser
331
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/enable
332
+ * @secure
333
+ * @response `204` `void`
334
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
335
+ */
336
+ enableTenantUser: function (tenantId, userId, params) {
337
+ if (params === void 0) { params = {}; }
338
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/enable"), method: "PATCH", secure: true }, params));
339
+ },
340
+ /**
341
+ * No description
342
+ *
343
+ * @tags Admin Tenant Users
344
+ * @name ListTenantUsers
345
+ * @request GET:/admin/tenants/{tenantId}/users
346
+ * @secure
347
+ * @response `200` `TenantUserEntityPaginationDto`
348
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
349
+ */
350
+ listTenantUsers: function (tenantId, query, params) {
351
+ if (params === void 0) { params = {}; }
352
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "GET", query: query, secure: true, format: "json" }, params));
353
+ },
284
354
  };
285
355
  return _this;
286
356
  }
package/dist/esm/sdk.js CHANGED
@@ -121,13 +121,13 @@ var WinehausSDK = /** @class */ (function () {
121
121
  case 0:
122
122
  if (!(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 &&
123
123
  this.authToken &&
124
- this.refreshToken &&
124
+ // ToDO: Uncomment this this.refreshToken &&
125
125
  !refreshTokenUsed.has(this.refreshToken))) return [3 /*break*/, 4];
126
126
  refreshTokenUsed.add(this.refreshToken);
127
127
  _c.label = 1;
128
128
  case 1:
129
129
  _c.trys.push([1, 3, , 4]);
130
- return [4 /*yield*/, this.refreshTokens()];
130
+ return [4 /*yield*/, this.refreshTokens({ throwError: true })];
131
131
  case 2:
132
132
  _c.sent();
133
133
  return [3 /*break*/, 4];
@@ -155,10 +155,22 @@ var WinehausSDK = /** @class */ (function () {
155
155
  case 0:
156
156
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
157
157
  this.emitter.emit('connecting');
158
+ if (!((credential === null || credential === void 0 ? void 0 : credential.email) && (credential === null || credential === void 0 ? void 0 : credential.password))) return [3 /*break*/, 2];
158
159
  return [4 /*yield*/, this.authenticateAsUser(credential)];
159
160
  case 1:
160
161
  _a.sent();
161
- this.credential = credential;
162
+ this.signInCredential = credential;
163
+ return [3 /*break*/, 5];
164
+ case 2:
165
+ if (!(credential === null || credential === void 0 ? void 0 : credential.authToken)) return [3 /*break*/, 4];
166
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
167
+ return [4 /*yield*/, this.authenticateAsToken(credential)];
168
+ case 3:
169
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
170
+ _a.sent();
171
+ return [3 /*break*/, 5];
172
+ case 4: throw new Error("Invalid auth credential type format");
173
+ case 5:
162
174
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
163
175
  this.emitter.emit('connected');
164
176
  this.hookTimer();
@@ -167,14 +179,17 @@ var WinehausSDK = /** @class */ (function () {
167
179
  });
168
180
  });
169
181
  };
170
- WinehausSDK.prototype.reAuthenticate = function () {
182
+ WinehausSDK.prototype.reAuthenticate = function (opts) {
171
183
  return __awaiter(this, void 0, void 0, function () {
172
184
  return __generator(this, function (_a) {
173
185
  switch (_a.label) {
174
186
  case 0:
175
- if (!this.credential)
176
- throw new Error('No credential found');
177
- return [4 /*yield*/, this.authenticate(this.credential)];
187
+ if (!this.signInCredential) {
188
+ if (opts === null || opts === void 0 ? void 0 : opts.throwError)
189
+ new Error("No SignIn set to make re-auth");
190
+ return [2 /*return*/];
191
+ }
192
+ return [4 /*yield*/, this.authenticate(this.signInCredential, { avoidEvents: true })];
178
193
  case 1:
179
194
  _a.sent();
180
195
  return [2 /*return*/];
@@ -203,7 +218,8 @@ var WinehausSDK = /** @class */ (function () {
203
218
  return __generator(this, function (_b) {
204
219
  switch (_b.label) {
205
220
  case 0:
206
- if (!this.authToken || !this.refreshToken) {
221
+ //Todo: add || !this.refreshToken after implementing it here
222
+ if (!this.authToken) {
207
223
  return [2 /*return*/, this.clearTokens()];
208
224
  }
209
225
  if (!((_a = this.authTokenDecoded) === null || _a === void 0 ? void 0 : _a.exp)) {
@@ -248,14 +264,14 @@ var WinehausSDK = /** @class */ (function () {
248
264
  WinehausSDK.prototype.getRefreshToken = function () {
249
265
  return this.refreshToken.toString();
250
266
  };
251
- WinehausSDK.prototype.refreshTokens = function () {
267
+ WinehausSDK.prototype.refreshTokens = function (opts) {
252
268
  return __awaiter(this, void 0, void 0, function () {
253
269
  return __generator(this, function (_a) {
254
270
  switch (_a.label) {
255
271
  case 0:
256
272
  // ToDo: Refresh token is not implemented under this version. For a while, lets just re-auth
257
273
  this.clearTokens();
258
- return [4 /*yield*/, this.reAuthenticate()];
274
+ return [4 /*yield*/, this.reAuthenticate(opts)];
259
275
  case 1:
260
276
  _a.sent();
261
277
  return [2 /*return*/];
@@ -281,6 +297,14 @@ var WinehausSDK = /** @class */ (function () {
281
297
  });
282
298
  });
283
299
  };
300
+ WinehausSDK.prototype.authenticateAsToken = function (credential) {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ return __generator(this, function (_a) {
303
+ this.setTokens({ token: credential.authToken, refreshToken: credential.refreshToken });
304
+ return [2 /*return*/];
305
+ });
306
+ });
307
+ };
284
308
  WinehausSDK.prototype.setTokens = function (data) {
285
309
  this.setAuthToken(data.token);
286
310
  this.setRefreshToken(data.refreshToken);
@@ -7,12 +7,7 @@ export interface CreateTenantUserDto {
7
7
  */
8
8
  password?: string;
9
9
  /** @example ["operator"] */
10
- roles: CreateTenantUserDtoRolesEnum[];
11
- }
12
- export declare enum CreateTenantUserDtoRolesEnum {
13
- Operator = "operator",
14
- Admin = "admin",
15
- Owner = "owner"
10
+ roles: TenantRoleEnum[];
16
11
  }
17
12
  export interface HttpExceptionDto {
18
13
  /** @example null */
@@ -27,6 +22,32 @@ export interface HttpExceptionDto {
27
22
  /** @example "2022-07-25T17:24:07.042Z" */
28
23
  timestamp: string;
29
24
  }
25
+ export declare enum OrderByEnum {
26
+ ASC = "ASC",
27
+ DESC = "DESC"
28
+ }
29
+ export interface PaginationLinksDto {
30
+ /** @example "http://example.com?page=1" */
31
+ first?: string;
32
+ /** @example "http://example.com?page=3" */
33
+ last?: string;
34
+ /** @example "http://example.com?page=2" */
35
+ next?: string;
36
+ /** @example "http://example.com?page=1" */
37
+ prev?: string;
38
+ }
39
+ export interface PaginationMetaDto {
40
+ /** @example 1 */
41
+ currentPage: number;
42
+ /** @example 1 */
43
+ itemCount: number;
44
+ /** @example 1 */
45
+ itemsPerPage: number;
46
+ /** @example 1 */
47
+ totalItems?: number;
48
+ /** @example 1 */
49
+ totalPages?: number;
50
+ }
30
51
  export interface RequestPasswordResetDto {
31
52
  email: string;
32
53
  }
@@ -52,26 +73,44 @@ export interface SigninResponseDto {
52
73
  token: string;
53
74
  user: UserEntityDto;
54
75
  }
76
+ export declare enum TenantRoleEnum {
77
+ Operator = "operator",
78
+ Admin = "admin",
79
+ Owner = "owner"
80
+ }
55
81
  export interface TenantUserEntityDto {
56
- roles: TenantUserEntityDtoRolesEnum[];
82
+ roles: TenantRoleEnum[];
57
83
  /** @example "enabled" */
58
- status: TenantUserEntityDtoStatusEnum;
84
+ status: TenantUserStatusEnum;
59
85
  /** @format uuid */
60
86
  tenantId: string;
61
87
  user: UserEntityDto;
62
88
  /** @format uuid */
63
89
  userId: string;
64
90
  }
65
- export declare enum TenantUserEntityDtoRolesEnum {
66
- Operator = "operator",
67
- Admin = "admin",
68
- Owner = "owner"
91
+ export interface TenantUserEntityPaginationDto {
92
+ items: TenantUserEntityDto[];
93
+ links?: PaginationLinksDto;
94
+ meta: PaginationMetaDto;
69
95
  }
70
- /** @example "enabled" */
71
- export declare enum TenantUserEntityDtoStatusEnum {
96
+ export declare enum TenantUserStatusEnum {
72
97
  Enabled = "enabled",
73
98
  Blocked = "blocked"
74
99
  }
100
+ export interface UpdateUserPasswordDto {
101
+ /** @example "P@ssw0rd" */
102
+ currentPassword: string;
103
+ /**
104
+ * Password should include lowercase, uppercase and digits and have between 8 and 32 digits
105
+ * @example "P@ssw0rd"
106
+ */
107
+ password: string;
108
+ /** @example "P@ssw0rd" */
109
+ passwordConfirmation: string;
110
+ }
111
+ export interface UpdateUserProfileDto {
112
+ name: string;
113
+ }
75
114
  export interface UserEntityDto {
76
115
  /** @format date-time */
77
116
  createdAt?: string;
@@ -80,7 +119,7 @@ export interface UserEntityDto {
80
119
  email: string;
81
120
  /** @format uuid */
82
121
  id: string;
83
- name: string;
122
+ name?: string | null;
84
123
  /** @format date-time */
85
124
  updatedAt: string;
86
125
  }
@@ -146,17 +185,55 @@ export declare namespace Auth {
146
185
  type ResponseBody = SigninResponseDto;
147
186
  }
148
187
  }
188
+ export declare namespace Users {
189
+ /**
190
+ * No description
191
+ * @tags Users
192
+ * @name UpdateUserPassword
193
+ * @request PATCH:/users/{userId}/password
194
+ * @secure
195
+ * @response `200` `UserEntityDto`
196
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
197
+ */
198
+ namespace UpdateUserPassword {
199
+ type RequestParams = {
200
+ userId: string;
201
+ };
202
+ type RequestQuery = {};
203
+ type RequestBody = UpdateUserPasswordDto;
204
+ type RequestHeaders = {};
205
+ type ResponseBody = UserEntityDto;
206
+ }
207
+ /**
208
+ * No description
209
+ * @tags Users
210
+ * @name UpdateUserProfile
211
+ * @request PATCH:/users/{userId}
212
+ * @secure
213
+ * @response `200` `UserEntityDto`
214
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
215
+ */
216
+ namespace UpdateUserProfile {
217
+ type RequestParams = {
218
+ userId: string;
219
+ };
220
+ type RequestQuery = {};
221
+ type RequestBody = UpdateUserProfileDto;
222
+ type RequestHeaders = {};
223
+ type ResponseBody = UserEntityDto;
224
+ }
225
+ }
149
226
  export declare namespace Admin {
150
227
  /**
151
- * @description Gives some user access to the tenant. If there's no account attached to this users, it creates a new one
152
- * @tags Admin Users
153
- * @name CreateTenantUser
228
+ * @description Gives some user access to the tenant. If there's no user account attached to this users, it creates a new one
229
+ * @tags Admin Tenant Users
230
+ * @name CreateOrUpdateTenantUserAndPermissionsByUserEmail
154
231
  * @request POST:/admin/tenants/{tenantId}/users
155
232
  * @secure
156
- * @response `201` `TenantUserEntityDto`
233
+ * @response `200` `TenantUserEntityDto`
157
234
  * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
158
235
  */
159
- namespace CreateTenantUser {
236
+ namespace CreateOrUpdateTenantUserAndPermissionsByUserEmail {
160
237
  type RequestParams = {
161
238
  tenantId: string;
162
239
  };
@@ -165,6 +242,78 @@ export declare namespace Admin {
165
242
  type RequestHeaders = {};
166
243
  type ResponseBody = TenantUserEntityDto;
167
244
  }
245
+ /**
246
+ * No description
247
+ * @tags Admin Tenant Users
248
+ * @name DisableTenantUser
249
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/disable
250
+ * @secure
251
+ * @response `204` `void`
252
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
253
+ */
254
+ namespace DisableTenantUser {
255
+ type RequestParams = {
256
+ tenantId: string;
257
+ userId: string;
258
+ };
259
+ type RequestQuery = {};
260
+ type RequestBody = never;
261
+ type RequestHeaders = {};
262
+ type ResponseBody = void;
263
+ }
264
+ /**
265
+ * No description
266
+ * @tags Admin Tenant Users
267
+ * @name EnableTenantUser
268
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/enable
269
+ * @secure
270
+ * @response `204` `void`
271
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
272
+ */
273
+ namespace EnableTenantUser {
274
+ type RequestParams = {
275
+ tenantId: string;
276
+ userId: string;
277
+ };
278
+ type RequestQuery = {};
279
+ type RequestBody = never;
280
+ type RequestHeaders = {};
281
+ type ResponseBody = void;
282
+ }
283
+ /**
284
+ * No description
285
+ * @tags Admin Tenant Users
286
+ * @name ListTenantUsers
287
+ * @request GET:/admin/tenants/{tenantId}/users
288
+ * @secure
289
+ * @response `200` `TenantUserEntityPaginationDto`
290
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
291
+ */
292
+ namespace ListTenantUsers {
293
+ type RequestParams = {
294
+ tenantId: string;
295
+ };
296
+ type RequestQuery = {
297
+ /**
298
+ * @default 10
299
+ * @example 10
300
+ */
301
+ limit?: number;
302
+ orderBy?: OrderByEnum;
303
+ /**
304
+ * @default 1
305
+ * @example 1
306
+ */
307
+ page?: number;
308
+ roles?: TenantRoleEnum[];
309
+ search?: string;
310
+ sortBy?: string[];
311
+ status?: TenantUserStatusEnum[];
312
+ };
313
+ type RequestBody = never;
314
+ type RequestHeaders = {};
315
+ type ResponseBody = TenantUserEntityPaginationDto;
316
+ }
168
317
  }
169
318
  import type { AxiosInstance, AxiosRequestConfig, ResponseType } from "axios";
170
319
  export type QueryParamsType = Record<string | number, any>;
@@ -266,17 +415,90 @@ export declare class Api<SecurityDataType extends unknown> extends HttpClient<Se
266
415
  */
267
416
  signIn: (data: SigninDto, params?: RequestParams) => Promise<SigninResponseDto>;
268
417
  };
418
+ users: {
419
+ /**
420
+ * No description
421
+ *
422
+ * @tags Users
423
+ * @name UpdateUserPassword
424
+ * @request PATCH:/users/{userId}/password
425
+ * @secure
426
+ * @response `200` `UserEntityDto`
427
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
428
+ */
429
+ updateUserPassword: (userId: string, data: UpdateUserPasswordDto, params?: RequestParams) => Promise<UserEntityDto>;
430
+ /**
431
+ * No description
432
+ *
433
+ * @tags Users
434
+ * @name UpdateUserProfile
435
+ * @request PATCH:/users/{userId}
436
+ * @secure
437
+ * @response `200` `UserEntityDto`
438
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
439
+ */
440
+ updateUserProfile: (userId: string, data: UpdateUserProfileDto, params?: RequestParams) => Promise<UserEntityDto>;
441
+ };
269
442
  admin: {
270
443
  /**
271
- * @description Gives some user access to the tenant. If there's no account attached to this users, it creates a new one
444
+ * @description Gives some user access to the tenant. If there's no user account attached to this users, it creates a new one
272
445
  *
273
- * @tags Admin Users
274
- * @name CreateTenantUser
446
+ * @tags Admin Tenant Users
447
+ * @name CreateOrUpdateTenantUserAndPermissionsByUserEmail
275
448
  * @request POST:/admin/tenants/{tenantId}/users
276
449
  * @secure
277
- * @response `201` `TenantUserEntityDto`
450
+ * @response `200` `TenantUserEntityDto`
451
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
452
+ */
453
+ createOrUpdateTenantUserAndPermissionsByUserEmail: (tenantId: string, data: CreateTenantUserDto, params?: RequestParams) => Promise<TenantUserEntityDto>;
454
+ /**
455
+ * No description
456
+ *
457
+ * @tags Admin Tenant Users
458
+ * @name DisableTenantUser
459
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/disable
460
+ * @secure
461
+ * @response `204` `void`
462
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
463
+ */
464
+ disableTenantUser: (tenantId: string, userId: string, params?: RequestParams) => Promise<void>;
465
+ /**
466
+ * No description
467
+ *
468
+ * @tags Admin Tenant Users
469
+ * @name EnableTenantUser
470
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/enable
471
+ * @secure
472
+ * @response `204` `void`
473
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
474
+ */
475
+ enableTenantUser: (tenantId: string, userId: string, params?: RequestParams) => Promise<void>;
476
+ /**
477
+ * No description
478
+ *
479
+ * @tags Admin Tenant Users
480
+ * @name ListTenantUsers
481
+ * @request GET:/admin/tenants/{tenantId}/users
482
+ * @secure
483
+ * @response `200` `TenantUserEntityPaginationDto`
278
484
  * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
279
485
  */
280
- createTenantUser: (tenantId: string, data: CreateTenantUserDto, params?: RequestParams) => Promise<TenantUserEntityDto>;
486
+ listTenantUsers: (tenantId: string, query?: {
487
+ /**
488
+ * @default 10
489
+ * @example 10
490
+ */
491
+ limit?: number;
492
+ orderBy?: OrderByEnum;
493
+ /**
494
+ * @default 1
495
+ * @example 1
496
+ */
497
+ page?: number;
498
+ roles?: TenantRoleEnum[];
499
+ search?: string;
500
+ sortBy?: string[];
501
+ status?: TenantUserStatusEnum[];
502
+ }, params?: RequestParams) => Promise<TenantUserEntityPaginationDto>;
281
503
  };
282
504
  }
@@ -1,3 +1,4 @@
1
+ import { SigninDto } from './api/api';
1
2
  export interface SDKOptions {
2
3
  baseURL: string;
3
4
  autoRefresh?: boolean;
@@ -14,3 +15,8 @@ export type SDKEvents = {
14
15
  refreshToken: string;
15
16
  };
16
17
  };
18
+ export interface AuthenticatedCredential {
19
+ authToken: string;
20
+ refreshToken: string;
21
+ }
22
+ export type AuthCredential = SigninDto | AuthenticatedCredential;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { SDKOptions, ApiSecurityDataType, SDKEvents } from './interfaces';
2
+ import { SDKOptions, ApiSecurityDataType, SDKEvents, AuthCredential } from './interfaces';
3
3
  import { JwtPayload } from 'jwt-decode';
4
4
  import { Api, SigninDto } from './api/api';
5
5
  import { Emitter } from 'mitt';
@@ -11,7 +11,7 @@ export declare class WinehausSDK {
11
11
  protected refreshToken: string;
12
12
  protected options: SDKOptions;
13
13
  protected autoRefreshTimer: NodeJS.Timeout | undefined;
14
- protected credential: SigninDto | undefined;
14
+ protected signInCredential: SigninDto | undefined;
15
15
  emitter: Emitter<SDKEvents>;
16
16
  protected defaultOptions: Partial<SDKOptions>;
17
17
  constructor(options: SDKOptions);
@@ -20,10 +20,12 @@ export declare class WinehausSDK {
20
20
  private hookTimer;
21
21
  private hookInterceptors;
22
22
  clearTokens(): void;
23
- authenticate(credential: SigninDto, opts?: {
23
+ authenticate(credential: AuthCredential, opts?: {
24
24
  avoidEvents?: boolean;
25
25
  }): Promise<void>;
26
- reAuthenticate(): Promise<void>;
26
+ reAuthenticate(opts?: {
27
+ throwError?: boolean;
28
+ }): Promise<void>;
27
29
  isAuthenticated(): boolean;
28
30
  protected setAuthToken(token: string): void;
29
31
  triggerRefreshToken(): Promise<void>;
@@ -31,8 +33,11 @@ export declare class WinehausSDK {
31
33
  getAuthToken(): string;
32
34
  protected setRefreshToken(refreshToken: string): void;
33
35
  getRefreshToken(): string;
34
- refreshTokens(): Promise<void>;
36
+ refreshTokens(opts?: {
37
+ throwError?: boolean;
38
+ }): Promise<void>;
35
39
  private authenticateAsUser;
40
+ private authenticateAsToken;
36
41
  private setTokens;
37
42
  getAuthTokenDecoded(): JwtPayload | undefined;
38
43
  getRefreshTokenDecoded(): JwtPayload | undefined;
package/dist/umd/index.ts CHANGED
@@ -16087,13 +16087,13 @@ var WinehausSDK = /** @class */ (function () {
16087
16087
  case 0:
16088
16088
  if (!(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 401 &&
16089
16089
  this.authToken &&
16090
- this.refreshToken &&
16090
+ // ToDO: Uncomment this this.refreshToken &&
16091
16091
  !refreshTokenUsed.has(this.refreshToken))) return [3 /*break*/, 4];
16092
16092
  refreshTokenUsed.add(this.refreshToken);
16093
16093
  _c.label = 1;
16094
16094
  case 1:
16095
16095
  _c.trys.push([1, 3, , 4]);
16096
- return [4 /*yield*/, this.refreshTokens()];
16096
+ return [4 /*yield*/, this.refreshTokens({ throwError: true })];
16097
16097
  case 2:
16098
16098
  _c.sent();
16099
16099
  return [3 /*break*/, 4];
@@ -16121,10 +16121,22 @@ var WinehausSDK = /** @class */ (function () {
16121
16121
  case 0:
16122
16122
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
16123
16123
  this.emitter.emit('connecting');
16124
+ if (!((credential === null || credential === void 0 ? void 0 : credential.email) && (credential === null || credential === void 0 ? void 0 : credential.password))) return [3 /*break*/, 2];
16124
16125
  return [4 /*yield*/, this.authenticateAsUser(credential)];
16125
16126
  case 1:
16126
16127
  _a.sent();
16127
- this.credential = credential;
16128
+ this.signInCredential = credential;
16129
+ return [3 /*break*/, 5];
16130
+ case 2:
16131
+ if (!(credential === null || credential === void 0 ? void 0 : credential.authToken)) return [3 /*break*/, 4];
16132
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
16133
+ return [4 /*yield*/, this.authenticateAsToken(credential)];
16134
+ case 3:
16135
+ // ToDO add && (credential as any)?.refreshToken after refreshToken is ready
16136
+ _a.sent();
16137
+ return [3 /*break*/, 5];
16138
+ case 4: throw new Error("Invalid auth credential type format");
16139
+ case 5:
16128
16140
  if (!(opts === null || opts === void 0 ? void 0 : opts.avoidEvents))
16129
16141
  this.emitter.emit('connected');
16130
16142
  this.hookTimer();
@@ -16133,14 +16145,17 @@ var WinehausSDK = /** @class */ (function () {
16133
16145
  });
16134
16146
  });
16135
16147
  };
16136
- WinehausSDK.prototype.reAuthenticate = function () {
16148
+ WinehausSDK.prototype.reAuthenticate = function (opts) {
16137
16149
  return __awaiter(this, void 0, void 0, function () {
16138
16150
  return __generator(this, function (_a) {
16139
16151
  switch (_a.label) {
16140
16152
  case 0:
16141
- if (!this.credential)
16142
- throw new Error('No credential found');
16143
- return [4 /*yield*/, this.authenticate(this.credential)];
16153
+ if (!this.signInCredential) {
16154
+ if (opts === null || opts === void 0 ? void 0 : opts.throwError)
16155
+ new Error("No SignIn set to make re-auth");
16156
+ return [2 /*return*/];
16157
+ }
16158
+ return [4 /*yield*/, this.authenticate(this.signInCredential, { avoidEvents: true })];
16144
16159
  case 1:
16145
16160
  _a.sent();
16146
16161
  return [2 /*return*/];
@@ -16169,7 +16184,8 @@ var WinehausSDK = /** @class */ (function () {
16169
16184
  return __generator(this, function (_b) {
16170
16185
  switch (_b.label) {
16171
16186
  case 0:
16172
- if (!this.authToken || !this.refreshToken) {
16187
+ //Todo: add || !this.refreshToken after implementing it here
16188
+ if (!this.authToken) {
16173
16189
  return [2 /*return*/, this.clearTokens()];
16174
16190
  }
16175
16191
  if (!((_a = this.authTokenDecoded) === null || _a === void 0 ? void 0 : _a.exp)) {
@@ -16214,14 +16230,14 @@ var WinehausSDK = /** @class */ (function () {
16214
16230
  WinehausSDK.prototype.getRefreshToken = function () {
16215
16231
  return this.refreshToken.toString();
16216
16232
  };
16217
- WinehausSDK.prototype.refreshTokens = function () {
16233
+ WinehausSDK.prototype.refreshTokens = function (opts) {
16218
16234
  return __awaiter(this, void 0, void 0, function () {
16219
16235
  return __generator(this, function (_a) {
16220
16236
  switch (_a.label) {
16221
16237
  case 0:
16222
16238
  // ToDo: Refresh token is not implemented under this version. For a while, lets just re-auth
16223
16239
  this.clearTokens();
16224
- return [4 /*yield*/, this.reAuthenticate()];
16240
+ return [4 /*yield*/, this.reAuthenticate(opts)];
16225
16241
  case 1:
16226
16242
  _a.sent();
16227
16243
  return [2 /*return*/];
@@ -16247,6 +16263,14 @@ var WinehausSDK = /** @class */ (function () {
16247
16263
  });
16248
16264
  });
16249
16265
  };
16266
+ WinehausSDK.prototype.authenticateAsToken = function (credential) {
16267
+ return __awaiter(this, void 0, void 0, function () {
16268
+ return __generator(this, function (_a) {
16269
+ this.setTokens({ token: credential.authToken, refreshToken: credential.refreshToken });
16270
+ return [2 /*return*/];
16271
+ });
16272
+ });
16273
+ };
16250
16274
  WinehausSDK.prototype.setTokens = function (data) {
16251
16275
  this.setAuthToken(data.token);
16252
16276
  this.setRefreshToken(data.refreshToken);
@@ -18386,25 +18410,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
18386
18410
  return (mod && mod.__esModule) ? mod : { "default": mod };
18387
18411
  };
18388
18412
  Object.defineProperty(exports, "__esModule", ({ value: true }));
18389
- exports.Api = exports.HttpClient = exports.ContentType = exports.TenantUserEntityDtoStatusEnum = exports.TenantUserEntityDtoRolesEnum = exports.CreateTenantUserDtoRolesEnum = void 0;
18390
- var CreateTenantUserDtoRolesEnum;
18391
- (function (CreateTenantUserDtoRolesEnum) {
18392
- CreateTenantUserDtoRolesEnum["Operator"] = "operator";
18393
- CreateTenantUserDtoRolesEnum["Admin"] = "admin";
18394
- CreateTenantUserDtoRolesEnum["Owner"] = "owner";
18395
- })(CreateTenantUserDtoRolesEnum = exports.CreateTenantUserDtoRolesEnum || (exports.CreateTenantUserDtoRolesEnum = {}));
18396
- var TenantUserEntityDtoRolesEnum;
18397
- (function (TenantUserEntityDtoRolesEnum) {
18398
- TenantUserEntityDtoRolesEnum["Operator"] = "operator";
18399
- TenantUserEntityDtoRolesEnum["Admin"] = "admin";
18400
- TenantUserEntityDtoRolesEnum["Owner"] = "owner";
18401
- })(TenantUserEntityDtoRolesEnum = exports.TenantUserEntityDtoRolesEnum || (exports.TenantUserEntityDtoRolesEnum = {}));
18402
- /** @example "enabled" */
18403
- var TenantUserEntityDtoStatusEnum;
18404
- (function (TenantUserEntityDtoStatusEnum) {
18405
- TenantUserEntityDtoStatusEnum["Enabled"] = "enabled";
18406
- TenantUserEntityDtoStatusEnum["Blocked"] = "blocked";
18407
- })(TenantUserEntityDtoStatusEnum = exports.TenantUserEntityDtoStatusEnum || (exports.TenantUserEntityDtoStatusEnum = {}));
18413
+ exports.Api = exports.HttpClient = exports.ContentType = exports.TenantUserStatusEnum = exports.TenantRoleEnum = exports.OrderByEnum = void 0;
18414
+ var OrderByEnum;
18415
+ (function (OrderByEnum) {
18416
+ OrderByEnum["ASC"] = "ASC";
18417
+ OrderByEnum["DESC"] = "DESC";
18418
+ })(OrderByEnum = exports.OrderByEnum || (exports.OrderByEnum = {}));
18419
+ var TenantRoleEnum;
18420
+ (function (TenantRoleEnum) {
18421
+ TenantRoleEnum["Operator"] = "operator";
18422
+ TenantRoleEnum["Admin"] = "admin";
18423
+ TenantRoleEnum["Owner"] = "owner";
18424
+ })(TenantRoleEnum = exports.TenantRoleEnum || (exports.TenantRoleEnum = {}));
18425
+ var TenantUserStatusEnum;
18426
+ (function (TenantUserStatusEnum) {
18427
+ TenantUserStatusEnum["Enabled"] = "enabled";
18428
+ TenantUserStatusEnum["Blocked"] = "blocked";
18429
+ })(TenantUserStatusEnum = exports.TenantUserStatusEnum || (exports.TenantUserStatusEnum = {}));
18408
18430
  var axios_1 = __importDefault(__webpack_require__(6425));
18409
18431
  var ContentType;
18410
18432
  (function (ContentType) {
@@ -18573,21 +18595,93 @@ var Api = /** @class */ (function (_super) {
18573
18595
  return _this.request(__assign({ path: "/auth/signin", method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
18574
18596
  },
18575
18597
  };
18598
+ _this.users = {
18599
+ /**
18600
+ * No description
18601
+ *
18602
+ * @tags Users
18603
+ * @name UpdateUserPassword
18604
+ * @request PATCH:/users/{userId}/password
18605
+ * @secure
18606
+ * @response `200` `UserEntityDto`
18607
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
18608
+ */
18609
+ updateUserPassword: function (userId, data, params) {
18610
+ if (params === void 0) { params = {}; }
18611
+ return _this.request(__assign({ path: "/users/".concat(userId, "/password"), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
18612
+ },
18613
+ /**
18614
+ * No description
18615
+ *
18616
+ * @tags Users
18617
+ * @name UpdateUserProfile
18618
+ * @request PATCH:/users/{userId}
18619
+ * @secure
18620
+ * @response `200` `UserEntityDto`
18621
+ * @response `403` `HttpExceptionDto` You're not enabled to make this operation.
18622
+ */
18623
+ updateUserProfile: function (userId, data, params) {
18624
+ if (params === void 0) { params = {}; }
18625
+ return _this.request(__assign({ path: "/users/".concat(userId), method: "PATCH", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
18626
+ },
18627
+ };
18576
18628
  _this.admin = {
18577
18629
  /**
18578
- * @description Gives some user access to the tenant. If there's no account attached to this users, it creates a new one
18630
+ * @description Gives some user access to the tenant. If there's no user account attached to this users, it creates a new one
18579
18631
  *
18580
- * @tags Admin Users
18581
- * @name CreateTenantUser
18632
+ * @tags Admin Tenant Users
18633
+ * @name CreateOrUpdateTenantUserAndPermissionsByUserEmail
18582
18634
  * @request POST:/admin/tenants/{tenantId}/users
18583
18635
  * @secure
18584
- * @response `201` `TenantUserEntityDto`
18636
+ * @response `200` `TenantUserEntityDto`
18585
18637
  * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
18586
18638
  */
18587
- createTenantUser: function (tenantId, data, params) {
18639
+ createOrUpdateTenantUserAndPermissionsByUserEmail: function (tenantId, data, params) {
18588
18640
  if (params === void 0) { params = {}; }
18589
18641
  return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "POST", body: data, secure: true, type: ContentType.Json, format: "json" }, params));
18590
18642
  },
18643
+ /**
18644
+ * No description
18645
+ *
18646
+ * @tags Admin Tenant Users
18647
+ * @name DisableTenantUser
18648
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/disable
18649
+ * @secure
18650
+ * @response `204` `void`
18651
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
18652
+ */
18653
+ disableTenantUser: function (tenantId, userId, params) {
18654
+ if (params === void 0) { params = {}; }
18655
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/disable"), method: "PATCH", secure: true }, params));
18656
+ },
18657
+ /**
18658
+ * No description
18659
+ *
18660
+ * @tags Admin Tenant Users
18661
+ * @name EnableTenantUser
18662
+ * @request PATCH:/admin/tenants/{tenantId}/users/{userId}/enable
18663
+ * @secure
18664
+ * @response `204` `void`
18665
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
18666
+ */
18667
+ enableTenantUser: function (tenantId, userId, params) {
18668
+ if (params === void 0) { params = {}; }
18669
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users/").concat(userId, "/enable"), method: "PATCH", secure: true }, params));
18670
+ },
18671
+ /**
18672
+ * No description
18673
+ *
18674
+ * @tags Admin Tenant Users
18675
+ * @name ListTenantUsers
18676
+ * @request GET:/admin/tenants/{tenantId}/users
18677
+ * @secure
18678
+ * @response `200` `TenantUserEntityPaginationDto`
18679
+ * @response `403` `HttpExceptionDto` Need user with one of these roles: owner, admin
18680
+ */
18681
+ listTenantUsers: function (tenantId, query, params) {
18682
+ if (params === void 0) { params = {}; }
18683
+ return _this.request(__assign({ path: "/admin/tenants/".concat(tenantId, "/users"), method: "GET", query: query, secure: true, format: "json" }, params));
18684
+ },
18591
18685
  };
18592
18686
  return _this;
18593
18687
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thelllabs/winehaus-sdk",
3
- "version": "0.0.3",
3
+ "version": "0.0.6",
4
4
  "description": "Winehaus SDK",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",