@inweb/client 25.4.1 → 25.4.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
@@ -1316,7 +1316,7 @@
1316
1316
  });
1317
1317
  }
1318
1318
  default:
1319
- return Promise.reject(new FetchError(response.status, statusText(response.status)));
1319
+ return Promise.reject(new FetchError(response.status));
1320
1320
  }
1321
1321
  }
1322
1322
  return Promise.resolve(response);
@@ -3496,7 +3496,7 @@
3496
3496
  return this.data.projectsLimit;
3497
3497
  }
3498
3498
  /**
3499
- * The user's API key.
3499
+ * The user's access token (API key). Use {@link Client.signInWithToken()} to log in using token.
3500
3500
  *
3501
3501
  * @readonly
3502
3502
  */
@@ -3642,7 +3642,7 @@
3642
3642
  constructor(params = {}) {
3643
3643
  super();
3644
3644
  this._serverUrl = "";
3645
- this._httpClient = new HttpClient("");
3645
+ this.httpClient = new HttpClient("");
3646
3646
  this._user = null;
3647
3647
  this.eventEmitter = this;
3648
3648
  this.configure(params);
@@ -3704,7 +3704,7 @@
3704
3704
  */
3705
3705
  configure(params) {
3706
3706
  this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
3707
- this._httpClient = new HttpClient(this.serverUrl);
3707
+ this.httpClient = new HttpClient(this.serverUrl);
3708
3708
  this._user = null;
3709
3709
  return this;
3710
3710
  }
@@ -3721,13 +3721,13 @@
3721
3721
  * @async
3722
3722
  */
3723
3723
  version() {
3724
- return this._httpClient
3724
+ return this.httpClient
3725
3725
  .get("/version")
3726
3726
  .then((response) => response.json())
3727
3727
  .then((data) => ({
3728
3728
  ...data,
3729
3729
  server: data.version,
3730
- client: "25.4.1",
3730
+ client: "25.4.3",
3731
3731
  }));
3732
3732
  }
3733
3733
  /**
@@ -3741,7 +3741,7 @@
3741
3741
  * `username` from email.
3742
3742
  */
3743
3743
  registerUser(email, password, userName) {
3744
- return this._httpClient
3744
+ return this.httpClient
3745
3745
  .post("/register", {
3746
3746
  email,
3747
3747
  password,
@@ -3758,7 +3758,7 @@
3758
3758
  * @param password - User password.
3759
3759
  */
3760
3760
  resendConfirmationEmail(email, password) {
3761
- return this._httpClient
3761
+ return this.httpClient
3762
3762
  .post("/register/email-confirmation", { email, password })
3763
3763
  .then((response) => response.json());
3764
3764
  }
@@ -3769,7 +3769,7 @@
3769
3769
  * @param emailConfirmationId - Confirmation code from the Confirmation Email.
3770
3770
  */
3771
3771
  confirmUserEmail(emailConfirmationId) {
3772
- return this._httpClient
3772
+ return this.httpClient
3773
3773
  .get(`/register/email-confirmation/${emailConfirmationId}`)
3774
3774
  .then((response) => response.json());
3775
3775
  }
@@ -3782,42 +3782,53 @@
3782
3782
  */
3783
3783
  async signInWithEmail(email, password) {
3784
3784
  const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
3785
- this._httpClient.headers = { Authorization: "Basic " + credentials };
3786
- const response = await this._httpClient.get("/token");
3785
+ this.httpClient.headers = { Authorization: "Basic " + credentials };
3786
+ const response = await this.httpClient.get("/token");
3787
3787
  const data = await response.json();
3788
3788
  return this.setCurrentUser(data);
3789
3789
  }
3790
3790
  /**
3791
- * Log in an existing user using API Key.
3791
+ * Log in an existing user using access token (API Key).
3792
3792
  *
3793
3793
  * @async
3794
- * @param token - An access token for authentication request. See
3795
- * {@link User#token | User.token} for more details.
3794
+ * @param token - An access token for authentication request. See {@link User.token} for more details.
3796
3795
  */
3797
3796
  async signInWithToken(token) {
3798
- this._httpClient.headers = { Authorization: token };
3799
- const response = await this._httpClient.get("/user");
3797
+ this.httpClient.headers = { Authorization: token };
3798
+ const response = await this.httpClient.get("/user");
3800
3799
  const data = await response.json();
3801
3800
  return this.setCurrentUser(data);
3802
3801
  }
3802
+ /**
3803
+ * Get the list of server indentity providers.
3804
+ *
3805
+ * To sign in with the provider in your web application:
3806
+ *
3807
+ * - Open the `provider.url` link using `window.open()`.
3808
+ * - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
3809
+ * message if the `error` search parameter is present, or log in with the `token` search parameter.
3810
+ */
3811
+ getIdentityProviders() {
3812
+ return this.httpClient.get("/identity").then((response) => response.json());
3813
+ }
3803
3814
  // Save the current logged in user information for internal use.
3804
3815
  setCurrentUser(data) {
3805
- this._user = new User(data, this._httpClient);
3806
- this._httpClient.headers = { Authorization: data.tokenInfo.token };
3807
- this._httpClient.signInUserId = this._user.id;
3816
+ this._user = new User(data, this.httpClient);
3817
+ this.httpClient.headers = { Authorization: data.tokenInfo.token };
3818
+ this.httpClient.signInUserId = this._user.id;
3808
3819
  return this._user;
3809
3820
  }
3810
3821
  clearCurrentUser() {
3811
3822
  this._user = null;
3812
- this._httpClient.headers = {};
3813
- this._httpClient.signInUserId = "";
3823
+ this.httpClient.headers = {};
3824
+ this.httpClient.signInUserId = "";
3814
3825
  }
3815
3826
  /**
3816
3827
  * Returns the current logged in user information. Returns `null` if the user is not logged
3817
3828
  * in or the logged in user has deleted himself.
3818
3829
  */
3819
3830
  getCurrentUser() {
3820
- if (this._user && !this._httpClient.signInUserId)
3831
+ if (this._user && !this.httpClient.signInUserId)
3821
3832
  this._user = null;
3822
3833
  return this._user;
3823
3834
  }
@@ -3828,11 +3839,11 @@
3828
3839
  * @async
3829
3840
  */
3830
3841
  getUsers() {
3831
- return this._httpClient
3842
+ return this.httpClient
3832
3843
  .get("/users")
3833
3844
  .then((response) => response.json())
3834
3845
  .then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
3835
- .then((array) => array.map((data) => new User(data, this._httpClient)));
3846
+ .then((array) => array.map((data) => new User(data, this.httpClient)));
3836
3847
  }
3837
3848
  /**
3838
3849
  * Returns the user information. Only admins can get other users, if the current logged in
@@ -3843,19 +3854,19 @@
3843
3854
  * @param userId - User ID.
3844
3855
  */
3845
3856
  getUser(userId) {
3846
- if (userId === this._httpClient.signInUserId) {
3847
- return this._httpClient
3857
+ if (userId === this.httpClient.signInUserId) {
3858
+ return this.httpClient
3848
3859
  .get("/user")
3849
3860
  .then((response) => response.json())
3850
3861
  .then((data) => ({ id: userId, ...data }))
3851
- .then((data) => new User(data, this._httpClient));
3862
+ .then((data) => new User(data, this.httpClient));
3852
3863
  }
3853
3864
  else {
3854
- return this._httpClient
3865
+ return this.httpClient
3855
3866
  .get(`/users/${userId}`)
3856
3867
  .then((response) => response.json())
3857
3868
  .then((data) => ({ id: data.id, ...data.userBrief }))
3858
- .then((data) => new User(data, this._httpClient));
3869
+ .then((data) => new User(data, this.httpClient));
3859
3870
  }
3860
3871
  }
3861
3872
  /**
@@ -3878,7 +3889,7 @@
3878
3889
  */
3879
3890
  createUser(email, password, params = {}) {
3880
3891
  const { isAdmin, userName, ...rest } = params;
3881
- return this._httpClient
3892
+ return this.httpClient
3882
3893
  .post("/users", {
3883
3894
  isAdmin,
3884
3895
  userBrief: {
@@ -3890,7 +3901,7 @@
3890
3901
  })
3891
3902
  .then((response) => response.json())
3892
3903
  .then((data) => ({ id: data.id, ...data.userBrief }))
3893
- .then((data) => new User(data, this._httpClient));
3904
+ .then((data) => new User(data, this.httpClient));
3894
3905
  }
3895
3906
  /**
3896
3907
  * Delete a user from the server. Only admins can delete users, if the current logged in user
@@ -3906,11 +3917,11 @@
3906
3917
  * @returns Returns the raw data of a deleted user.
3907
3918
  */
3908
3919
  deleteUser(userId) {
3909
- return this._httpClient
3920
+ return this.httpClient
3910
3921
  .delete(`/users/${userId}`)
3911
3922
  .then((response) => response.json())
3912
3923
  .then((data) => {
3913
- if (userId === this._httpClient.signInUserId) {
3924
+ if (userId === this.httpClient.signInUserId) {
3914
3925
  this.clearCurrentUser();
3915
3926
  }
3916
3927
  return data;
@@ -3971,13 +3982,13 @@
3971
3982
  let queryString = searchParams.toString();
3972
3983
  if (queryString)
3973
3984
  queryString = "?" + queryString;
3974
- return this._httpClient
3985
+ return this.httpClient
3975
3986
  .get(`/files${queryString}`)
3976
3987
  .then((response) => response.json())
3977
3988
  .then((files) => {
3978
3989
  return {
3979
3990
  ...files,
3980
- result: files.result.map((data) => new File(data, this._httpClient)),
3991
+ result: files.result.map((data) => new File(data, this.httpClient)),
3981
3992
  };
3982
3993
  });
3983
3994
  }
@@ -3988,10 +3999,10 @@
3988
3999
  * @param fileId - File ID.
3989
4000
  */
3990
4001
  getFile(fileId) {
3991
- return this._httpClient
4002
+ return this.httpClient
3992
4003
  .get(`/files/${fileId}`)
3993
4004
  .then((response) => response.json())
3994
- .then((data) => new File(data, this._httpClient));
4005
+ .then((data) => new File(data, this.httpClient));
3995
4006
  }
3996
4007
  /**
3997
4008
  * Upload a drawing or reference file to the server.
@@ -4028,14 +4039,14 @@
4028
4039
  properties: false,
4029
4040
  waitForDone: false,
4030
4041
  }) {
4031
- const result = await this._httpClient
4042
+ const result = await this.httpClient
4032
4043
  .uploadFile("/files", file, (progress) => {
4033
4044
  var _a;
4034
4045
  this.emitEvent({ type: "uploadprogress", data: progress, file });
4035
4046
  (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
4036
4047
  })
4037
4048
  .then((xhr) => JSON.parse(xhr.responseText))
4038
- .then((data) => new File(data, this._httpClient));
4049
+ .then((data) => new File(data, this.httpClient));
4039
4050
  const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
4040
4051
  const jobs = [];
4041
4052
  if (params.geometry)
@@ -4057,7 +4068,7 @@
4057
4068
  * @returns Returns the raw data of a deleted file.
4058
4069
  */
4059
4070
  deleteFile(fileId) {
4060
- return this._httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4071
+ return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4061
4072
  }
4062
4073
  /**
4063
4074
  * Download the drawing or reference file.
@@ -4070,7 +4081,7 @@
4070
4081
  * and abort it if desired.
4071
4082
  */
4072
4083
  downloadFile(fileId, onProgress, signal) {
4073
- return this._httpClient
4084
+ return this.httpClient
4074
4085
  .downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
4075
4086
  .then((response) => response.arrayBuffer());
4076
4087
  }
@@ -4117,12 +4128,12 @@
4117
4128
  let queryString = searchParams.toString();
4118
4129
  if (queryString)
4119
4130
  queryString = "?" + queryString;
4120
- return this._httpClient
4131
+ return this.httpClient
4121
4132
  .get(`/jobs${queryString}`)
4122
4133
  .then((response) => response.json())
4123
4134
  .then((jobs) => ({
4124
4135
  ...jobs,
4125
- result: jobs.result.map((data) => new Job(data, this._httpClient)),
4136
+ result: jobs.result.map((data) => new Job(data, this.httpClient)),
4126
4137
  }));
4127
4138
  }
4128
4139
  /**
@@ -4132,10 +4143,10 @@
4132
4143
  * @param jobId - Job ID.
4133
4144
  */
4134
4145
  getJob(jobId) {
4135
- return this._httpClient
4146
+ return this.httpClient
4136
4147
  .get(`/jobs/${jobId}`)
4137
4148
  .then((response) => response.json())
4138
- .then((data) => new Job(data, this._httpClient));
4149
+ .then((data) => new Job(data, this.httpClient));
4139
4150
  }
4140
4151
  /**
4141
4152
  * Create a new job.
@@ -4156,14 +4167,14 @@
4156
4167
  * for the File Converter tool in form "--arg=value".
4157
4168
  */
4158
4169
  createJob(fileId, outputFormat, parameters) {
4159
- return this._httpClient
4170
+ return this.httpClient
4160
4171
  .post("/jobs", {
4161
4172
  fileId,
4162
4173
  outputFormat,
4163
4174
  parameters: parseArgs(parameters),
4164
4175
  })
4165
4176
  .then((response) => response.json())
4166
- .then((data) => new Job(data, this._httpClient));
4177
+ .then((data) => new Job(data, this.httpClient));
4167
4178
  }
4168
4179
  /**
4169
4180
  * Remove a job from the server job list. The method does not delete or stop jobs that are
@@ -4174,7 +4185,7 @@
4174
4185
  * @returns Returns the raw data of a deleted job.
4175
4186
  */
4176
4187
  deleteJob(jobId) {
4177
- return this._httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4188
+ return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4178
4189
  }
4179
4190
  /**
4180
4191
  * Result for assembly list.
@@ -4223,13 +4234,13 @@
4223
4234
  let queryString = searchParams.toString();
4224
4235
  if (queryString)
4225
4236
  queryString = "?" + queryString;
4226
- return this._httpClient
4237
+ return this.httpClient
4227
4238
  .get(`/assemblies${queryString}`)
4228
4239
  .then((response) => response.json())
4229
4240
  .then((assemblies) => {
4230
4241
  return {
4231
4242
  ...assemblies,
4232
- result: assemblies.result.map((data) => new Assembly(data, this._httpClient)),
4243
+ result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
4233
4244
  };
4234
4245
  });
4235
4246
  }
@@ -4240,10 +4251,10 @@
4240
4251
  * @param assemblyId - Assembly ID.
4241
4252
  */
4242
4253
  getAssembly(assemblyId) {
4243
- return this._httpClient
4254
+ return this.httpClient
4244
4255
  .get(`/assemblies/${assemblyId}`)
4245
4256
  .then((response) => response.json())
4246
- .then((data) => new Assembly(data, this._httpClient));
4257
+ .then((data) => new Assembly(data, this.httpClient));
4247
4258
  }
4248
4259
  /**
4249
4260
  * Create a new assembly.
@@ -4256,10 +4267,10 @@
4256
4267
  */
4257
4268
  createAssembly(files, name, params) {
4258
4269
  const { waitForDone } = params !== null && params !== void 0 ? params : {};
4259
- return this._httpClient
4270
+ return this.httpClient
4260
4271
  .post("/assemblies", { name, files })
4261
4272
  .then((response) => response.json())
4262
- .then((data) => new Assembly(data, this._httpClient))
4273
+ .then((data) => new Assembly(data, this.httpClient))
4263
4274
  .then((result) => (waitForDone ? result.waitForDone(params) : result));
4264
4275
  }
4265
4276
  /**
@@ -4270,7 +4281,7 @@
4270
4281
  * @returns Returns the raw data of a deleted assembly.
4271
4282
  */
4272
4283
  deleteAssembly(assemblyId) {
4273
- return this._httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4284
+ return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4274
4285
  }
4275
4286
  /**
4276
4287
  * Result for project list.
@@ -4315,7 +4326,7 @@
4315
4326
  let queryString = searchParams.toString();
4316
4327
  if (queryString)
4317
4328
  queryString = "?" + queryString;
4318
- return this._httpClient
4329
+ return this.httpClient
4319
4330
  .get(`/projects${queryString}`)
4320
4331
  .then((response) => response.json())
4321
4332
  .then((projects) => {
@@ -4343,7 +4354,7 @@
4343
4354
  .then((projects) => {
4344
4355
  return {
4345
4356
  ...projects,
4346
- result: projects.result.map((data) => new Project(data, this._httpClient)),
4357
+ result: projects.result.map((data) => new Project(data, this.httpClient)),
4347
4358
  };
4348
4359
  });
4349
4360
  }
@@ -4354,10 +4365,10 @@
4354
4365
  * @param projectId - Project ID.
4355
4366
  */
4356
4367
  getProject(projectId) {
4357
- return this._httpClient
4368
+ return this.httpClient
4358
4369
  .get(`/projects/${projectId}`)
4359
4370
  .then((response) => response.json())
4360
- .then((data) => new Project(data, this._httpClient));
4371
+ .then((data) => new Project(data, this.httpClient));
4361
4372
  }
4362
4373
  /**
4363
4374
  * Create a new project.
@@ -4372,7 +4383,7 @@
4372
4383
  * target="_blank">Data URL</a>.
4373
4384
  */
4374
4385
  createProject(name, description, startDate, endDate, avatarUrl) {
4375
- return this._httpClient
4386
+ return this.httpClient
4376
4387
  .post("/projects", {
4377
4388
  name,
4378
4389
  description,
@@ -4381,7 +4392,7 @@
4381
4392
  avatarUrl,
4382
4393
  })
4383
4394
  .then((response) => response.json())
4384
- .then((data) => new Project(data, this._httpClient));
4395
+ .then((data) => new Project(data, this.httpClient));
4385
4396
  }
4386
4397
  /**
4387
4398
  * Delete the project from the server.
@@ -4391,7 +4402,7 @@
4391
4402
  * @returns Returns the raw data of a deleted project.
4392
4403
  */
4393
4404
  deleteProject(projectId) {
4394
- return this._httpClient
4405
+ return this.httpClient
4395
4406
  .delete(`/projects/${projectId}`)
4396
4407
  .then((response) => response.text())
4397
4408
  .then((text) => {
@@ -4407,11 +4418,12 @@
4407
4418
  }
4408
4419
 
4409
4420
  ///////////////////////////////////////////////////////////////////////////////
4410
- const version = "25.4.1";
4421
+ const version = "25.4.3";
4411
4422
 
4412
4423
  exports.Assembly = Assembly;
4413
4424
  exports.ClashTest = ClashTest;
4414
4425
  exports.Client = Client;
4426
+ exports.FetchError = FetchError;
4415
4427
  exports.File = File;
4416
4428
  exports.Job = Job;
4417
4429
  exports.Member = Member;
@@ -4421,6 +4433,7 @@
4421
4433
  exports.Role = Role;
4422
4434
  exports.User = User;
4423
4435
  exports.parseArgs = parseArgs;
4436
+ exports.statusText = statusText;
4424
4437
  exports.userFullName = userFullName;
4425
4438
  exports.userInitials = userInitials;
4426
4439
  exports.version = version;