@inweb/client 25.6.1 → 25.6.3

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.
package/dist/client.js CHANGED
@@ -928,6 +928,10 @@
928
928
  console.warn("Assembly does not support preview");
929
929
  return Promise.resolve(this);
930
930
  }
931
+ deletePreview() {
932
+ console.warn("Assembly does not support preview");
933
+ return Promise.resolve(this);
934
+ }
931
935
  /**
932
936
  * Returns list of assembly models.
933
937
  *
@@ -1832,8 +1836,8 @@
1832
1836
  /**
1833
1837
  * Update job data on the server.
1834
1838
  *
1835
- * Only admins can update job data, if the current logged in user does not have administrator
1836
- * rights, an exception will be thrown.
1839
+ * Only administrators can update job data, if the current logged in user is not an
1840
+ * administrator, an exception will be thrown.
1837
1841
  *
1838
1842
  * @async
1839
1843
  * @param data - Raw job data.
@@ -2056,7 +2060,7 @@
2056
2060
  return this.data.owner;
2057
2061
  }
2058
2062
  /**
2059
- * File preview image URL. Use {@link File#setPreview | setPreview()} to change preview image.
2063
+ * File preview image URL. Use {@link File.setPreview | setPreview()} to change preview image.
2060
2064
  *
2061
2065
  * @readonly
2062
2066
  */
@@ -2187,17 +2191,31 @@
2187
2191
  * Set or remove the file preview.
2188
2192
  *
2189
2193
  * @async
2190
- * @param image - Preview image. Can be a <a
2191
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
2192
- * target="_blank">Data URL</a> string, <a
2193
- * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"
2194
- * target="_blank">ArrayBuffer</a>, <a
2195
- * href="https://developer.mozilla.org/docs/Web/API/Blob/Blob" target="_blank">Blob</a> or
2196
- * Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
2197
- * target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
2194
+ * @param image - Preview image.Can be a
2195
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}
2196
+ * string,
2197
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
2198
+ * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob} or Web API
2199
+ * {@link https://developer.mozilla.org/docs/Web/API/File | File} object. Setting the
2200
+ * `image` to `null` will remove the preview.
2198
2201
  */
2199
2202
  async setPreview(image) {
2200
- const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
2203
+ if (!image) {
2204
+ await this.deletePreview();
2205
+ }
2206
+ else {
2207
+ const response = await this.internalPost("/preview", image);
2208
+ this.data = await response.json();
2209
+ }
2210
+ return this;
2211
+ }
2212
+ /**
2213
+ * Remove the file preview.
2214
+ *
2215
+ * @async
2216
+ */
2217
+ async deletePreview() {
2218
+ const response = await this.internalDelete("/preview");
2201
2219
  this.data = await response.json();
2202
2220
  return this;
2203
2221
  }
@@ -3108,7 +3126,7 @@
3108
3126
  return this.data.owner;
3109
3127
  }
3110
3128
  /**
3111
- * Project preview image URL. Use [setPreview()]{@link Project#setPreview} to change preview image.
3129
+ * Project preview image URL. Use {@link Project.setPreview | setPreview()} to change preview image.
3112
3130
  *
3113
3131
  * @readonly
3114
3132
  */
@@ -3204,17 +3222,31 @@
3204
3222
  * Set or remove the project preview.
3205
3223
  *
3206
3224
  * @async
3207
- * @param image - Preview image. Can be a <a
3208
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
3209
- * target="_blank">Data URL</a> string, <a
3210
- * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"
3211
- * target="_blank">ArrayBuffer</a>, <a
3212
- * href="https://developer.mozilla.org/docs/Web/API/Blob/Blob" target="_blank">Blob</a> or
3213
- * Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
3214
- * target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
3225
+ * @param image - Preview image. Can be a
3226
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}
3227
+ * string,
3228
+ * {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer | ArrayBuffer},
3229
+ * {@link https://developer.mozilla.org/docs/Web/API/Blob/Blob | Blob} or Web API
3230
+ * {@link https://developer.mozilla.org/docs/Web/API/File | File} object. Setting the
3231
+ * `image` to `null` will remove the preview.
3215
3232
  */
3216
3233
  async setPreview(image) {
3217
- const response = await (image ? this.internalPost("/preview", image) : this.internalDelete("/preview"));
3234
+ if (!image) {
3235
+ await this.deletePreview();
3236
+ }
3237
+ else {
3238
+ const response = await this.internalPost("/preview", image);
3239
+ this.data = await response.json();
3240
+ }
3241
+ return this;
3242
+ }
3243
+ /**
3244
+ * Remove the project preview.
3245
+ *
3246
+ * @async
3247
+ */
3248
+ async deletePreview() {
3249
+ const response = await this.internalDelete("/preview");
3218
3250
  this.data = await response.json();
3219
3251
  return this;
3220
3252
  }
@@ -3387,7 +3419,7 @@
3387
3419
  this.data = data;
3388
3420
  }
3389
3421
  /**
3390
- * User avatar image URL. Use {@link User#setAvatar | setAvatar()} to change avatar image.
3422
+ * User avatar image URL. Use {@link User.setAvatar | setAvatar()} to change avatar image.
3391
3423
  *
3392
3424
  * @readonly
3393
3425
  */
@@ -3482,7 +3514,7 @@
3482
3514
  return this.data.initials;
3483
3515
  }
3484
3516
  /**
3485
- * `true` if user is has an administrator rights.
3517
+ * `true` if user is an administrator.
3486
3518
  */
3487
3519
  get isAdmin() {
3488
3520
  return this.data.isAdmin;
@@ -3552,8 +3584,8 @@
3552
3584
  /**
3553
3585
  * Refresh user data.
3554
3586
  *
3555
- * Only admins can checkout other users, if the current logged in user does not have
3556
- * administrator rights, hi can only checkout himself, otherwise an exception will be thrown.
3587
+ * Only administrators can checkout other users, if the current logged in user is not an
3588
+ * administrator, they can only checkout themselves, otherwise an exception will be thrown.
3557
3589
  */
3558
3590
  async checkout() {
3559
3591
  if (this.httpClient.signInUserIsAdmin) {
@@ -3574,8 +3606,8 @@
3574
3606
  /**
3575
3607
  * Update user data on the server.
3576
3608
  *
3577
- * Only admins can update other users, if the current logged in user does not have
3578
- * administrator rights, hi can only update himself, otherwise an exception will be thrown.
3609
+ * Only administrators can update other users, if the current logged in user is not an
3610
+ * administrator, they can only update themself, otherwise an exception will be thrown.
3579
3611
  *
3580
3612
  * @async
3581
3613
  * @param data - Raw user data.
@@ -3599,11 +3631,11 @@
3599
3631
  /**
3600
3632
  * Delete a user from the server.
3601
3633
  *
3602
- * Only admins can delete users, if the current logged in user does not have administrator
3603
- * rights, an exception will be thrown.
3634
+ * Only administrators can delete users, if the current logged in user is not an
3635
+ * administrator, an exception will be thrown.
3604
3636
  *
3605
- * Admins can delete themselves or other admins. An admin can only delete himself if he is
3606
- * not the last administrator.
3637
+ * Administrators can delete themselves or other administrators. An administrator can only
3638
+ * delete themself if they is not the last administrator.
3607
3639
  *
3608
3640
  * You need to re-login to continue working after deleting the current logged in user.
3609
3641
  *
@@ -3640,8 +3672,8 @@
3640
3672
  /**
3641
3673
  * Set or remove the user avatar.
3642
3674
  *
3643
- * Only admins can set the avatar of other users, if the current logged in user does not have
3644
- * administrator rights, he can only set his own avatar, otherwise an exception will be thrown.
3675
+ * Only administrators can set the avatar of other users, if the current logged in user is
3676
+ * not an administrator, they can only set their avatar, otherwise an exception will be thrown.
3645
3677
  *
3646
3678
  * @async
3647
3679
  * @param image - Avatar image. Can be a
@@ -3674,9 +3706,8 @@
3674
3706
  /**
3675
3707
  * Remove the user avatar.
3676
3708
  *
3677
- * Only admins can remove the avatar of other users, if the current logged in user does not
3678
- * have administrator rights, they can only remove their own avatar, otherwise an exception
3679
- * will be thrown.
3709
+ * Only administrators can remove the avatar of other users, if the current logged in user is
3710
+ * not an administrator, they can only remove their avatar, otherwise an exception will be thrown.
3680
3711
  *
3681
3712
  * @async
3682
3713
  */
@@ -3696,6 +3727,36 @@
3696
3727
  }
3697
3728
  return this;
3698
3729
  }
3730
+ /**
3731
+ * Change the user password.
3732
+ *
3733
+ * Only administrators can change the passwords of other users, if the current logged in user
3734
+ * is not an administrator, they can only change their password, otherwise an exception will
3735
+ * be thrown.
3736
+ *
3737
+ * To change their password, non-administrator users must provide their old password.
3738
+ *
3739
+ * @async
3740
+ * @param newPassword - New user password.
3741
+ * @param oldPassword - Old user password. Only required for non-administrator users to
3742
+ * change their password.
3743
+ */
3744
+ async changePassword(newPassword, oldPassword) {
3745
+ if (this.httpClient.signInUserIsAdmin) {
3746
+ const response = await this.httpClient.put(`/users/${this.id}/password`, { new: newPassword });
3747
+ const data = await response.json();
3748
+ this.data = { id: data.id, ...data.userBrief };
3749
+ }
3750
+ else if (this.id === this.httpClient.signInUserId) {
3751
+ const response = await this.httpClient.put("/user/password", { old: oldPassword, new: newPassword });
3752
+ const data = await response.json();
3753
+ this.data = { id: this.id, ...data };
3754
+ }
3755
+ else {
3756
+ return Promise.reject(new FetchError(403));
3757
+ }
3758
+ return this;
3759
+ }
3699
3760
  }
3700
3761
 
3701
3762
  ///////////////////////////////////////////////////////////////////////////////
@@ -3797,7 +3858,7 @@
3797
3858
  .then((data) => ({
3798
3859
  ...data,
3799
3860
  server: data.version,
3800
- client: "25.6.1",
3861
+ client: "25.6.3",
3801
3862
  }));
3802
3863
  }
3803
3864
  /**
@@ -3917,8 +3978,8 @@
3917
3978
  /**
3918
3979
  * Change server settings.
3919
3980
  *
3920
- * Only admins can change server settings, if the current logged in user does not have
3921
- * administrator rights, an exception will be thrown.
3981
+ * Only administrators can change server settings, if the current logged in user is not an
3982
+ * administrator, an exception will be thrown.
3922
3983
  *
3923
3984
  * @async
3924
3985
  */
@@ -3928,8 +3989,8 @@
3928
3989
  /**
3929
3990
  * Returns a list of server users.
3930
3991
  *
3931
- * Only admins can get a list of users, if the current logged in user does not have
3932
- * administrator rights, an exception will be thrown.
3992
+ * Only administrators can get a list of users, if the current logged in user is not an
3993
+ * administrator, an exception will be thrown.
3933
3994
  *
3934
3995
  * @async
3935
3996
  */
@@ -3943,8 +4004,8 @@
3943
4004
  /**
3944
4005
  * Returns the user information.
3945
4006
  *
3946
- * Only admins can get other users, if the current logged in user does not have administrator
3947
- * rights, hi can only get himself, otherwise an exception will be thrown.
4007
+ * Only administrators can get other users, if the currently logged in user is not an
4008
+ * administrator, they can only get themselves, otherwise an exception will be thrown.
3948
4009
  *
3949
4010
  * @async
3950
4011
  * @param userId - User ID.
@@ -3971,8 +4032,8 @@
3971
4032
  /**
3972
4033
  * Create a new user.
3973
4034
  *
3974
- * Only admins can create users, if the current logged in user does not have administrator
3975
- * rights, an exception will be thrown.
4035
+ * Only administrators can create users, if the current logged in user is not an
4036
+ * administrator, an exception will be thrown.
3976
4037
  *
3977
4038
  * @async
3978
4039
  * @param email - User email. Cannot be empty.
@@ -4007,11 +4068,11 @@
4007
4068
  /**
4008
4069
  * Delete a user from the server.
4009
4070
  *
4010
- * Only admins can delete users, if the current logged in user does not have administrator
4011
- * rights, an exception will be thrown.
4071
+ * Only administrators can delete users, if the current logged in user is not an
4072
+ * administrator, an exception will be thrown.
4012
4073
  *
4013
- * Admins can delete themselves or other admins. An admin can only delete himself if he is
4014
- * not the last administrator.
4074
+ * Administrators can delete themselves or other administrators. An administrator can only
4075
+ * delete themself if they is not the last administrator.
4015
4076
  *
4016
4077
  * You need to re-login to continue working after deleting the current logged in user.
4017
4078
  *
@@ -4486,17 +4547,14 @@
4486
4547
  * @param description - Project description.
4487
4548
  * @param startDate - Project start date.
4488
4549
  * @param endDate - Project end date.
4489
- * @param avatarUrl - Project preview image URL. Can be
4490
- * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
4491
4550
  */
4492
- createProject(name, description, startDate, endDate, avatarUrl) {
4551
+ createProject(name, description, startDate, endDate) {
4493
4552
  return this.httpClient
4494
4553
  .post("/projects", {
4495
4554
  name,
4496
4555
  description,
4497
4556
  startDate: startDate instanceof Date ? startDate.toISOString() : startDate,
4498
4557
  endDate: endDate instanceof Date ? endDate.toISOString() : endDate,
4499
- avatarUrl,
4500
4558
  })
4501
4559
  .then((response) => response.json())
4502
4560
  .then((data) => new Project(data, this.httpClient));
@@ -4525,7 +4583,7 @@
4525
4583
  }
4526
4584
 
4527
4585
  ///////////////////////////////////////////////////////////////////////////////
4528
- const version = "25.6.1";
4586
+ const version = "25.6.3";
4529
4587
 
4530
4588
  exports.Assembly = Assembly;
4531
4589
  exports.ClashTest = ClashTest;