@inweb/client 25.4.2 → 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);
@@ -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.2",
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,8 +3782,8 @@
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
  }
@@ -3794,8 +3794,8 @@
3794
3794
  * @param token - An access token for authentication request. See {@link User.token} for more details.
3795
3795
  */
3796
3796
  async signInWithToken(token) {
3797
- this._httpClient.headers = { Authorization: token };
3798
- const response = await this._httpClient.get("/user");
3797
+ this.httpClient.headers = { Authorization: token };
3798
+ const response = await this.httpClient.get("/user");
3799
3799
  const data = await response.json();
3800
3800
  return this.setCurrentUser(data);
3801
3801
  }
@@ -3809,26 +3809,26 @@
3809
3809
  * message if the `error` search parameter is present, or log in with the `token` search parameter.
3810
3810
  */
3811
3811
  getIdentityProviders() {
3812
- return this._httpClient.get("/identity").then((response) => response.json());
3812
+ return this.httpClient.get("/identity").then((response) => response.json());
3813
3813
  }
3814
3814
  // Save the current logged in user information for internal use.
3815
3815
  setCurrentUser(data) {
3816
- this._user = new User(data, this._httpClient);
3817
- this._httpClient.headers = { Authorization: data.tokenInfo.token };
3818
- 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;
3819
3819
  return this._user;
3820
3820
  }
3821
3821
  clearCurrentUser() {
3822
3822
  this._user = null;
3823
- this._httpClient.headers = {};
3824
- this._httpClient.signInUserId = "";
3823
+ this.httpClient.headers = {};
3824
+ this.httpClient.signInUserId = "";
3825
3825
  }
3826
3826
  /**
3827
3827
  * Returns the current logged in user information. Returns `null` if the user is not logged
3828
3828
  * in or the logged in user has deleted himself.
3829
3829
  */
3830
3830
  getCurrentUser() {
3831
- if (this._user && !this._httpClient.signInUserId)
3831
+ if (this._user && !this.httpClient.signInUserId)
3832
3832
  this._user = null;
3833
3833
  return this._user;
3834
3834
  }
@@ -3839,11 +3839,11 @@
3839
3839
  * @async
3840
3840
  */
3841
3841
  getUsers() {
3842
- return this._httpClient
3842
+ return this.httpClient
3843
3843
  .get("/users")
3844
3844
  .then((response) => response.json())
3845
3845
  .then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
3846
- .then((array) => array.map((data) => new User(data, this._httpClient)));
3846
+ .then((array) => array.map((data) => new User(data, this.httpClient)));
3847
3847
  }
3848
3848
  /**
3849
3849
  * Returns the user information. Only admins can get other users, if the current logged in
@@ -3854,19 +3854,19 @@
3854
3854
  * @param userId - User ID.
3855
3855
  */
3856
3856
  getUser(userId) {
3857
- if (userId === this._httpClient.signInUserId) {
3858
- return this._httpClient
3857
+ if (userId === this.httpClient.signInUserId) {
3858
+ return this.httpClient
3859
3859
  .get("/user")
3860
3860
  .then((response) => response.json())
3861
3861
  .then((data) => ({ id: userId, ...data }))
3862
- .then((data) => new User(data, this._httpClient));
3862
+ .then((data) => new User(data, this.httpClient));
3863
3863
  }
3864
3864
  else {
3865
- return this._httpClient
3865
+ return this.httpClient
3866
3866
  .get(`/users/${userId}`)
3867
3867
  .then((response) => response.json())
3868
3868
  .then((data) => ({ id: data.id, ...data.userBrief }))
3869
- .then((data) => new User(data, this._httpClient));
3869
+ .then((data) => new User(data, this.httpClient));
3870
3870
  }
3871
3871
  }
3872
3872
  /**
@@ -3889,7 +3889,7 @@
3889
3889
  */
3890
3890
  createUser(email, password, params = {}) {
3891
3891
  const { isAdmin, userName, ...rest } = params;
3892
- return this._httpClient
3892
+ return this.httpClient
3893
3893
  .post("/users", {
3894
3894
  isAdmin,
3895
3895
  userBrief: {
@@ -3901,7 +3901,7 @@
3901
3901
  })
3902
3902
  .then((response) => response.json())
3903
3903
  .then((data) => ({ id: data.id, ...data.userBrief }))
3904
- .then((data) => new User(data, this._httpClient));
3904
+ .then((data) => new User(data, this.httpClient));
3905
3905
  }
3906
3906
  /**
3907
3907
  * Delete a user from the server. Only admins can delete users, if the current logged in user
@@ -3917,11 +3917,11 @@
3917
3917
  * @returns Returns the raw data of a deleted user.
3918
3918
  */
3919
3919
  deleteUser(userId) {
3920
- return this._httpClient
3920
+ return this.httpClient
3921
3921
  .delete(`/users/${userId}`)
3922
3922
  .then((response) => response.json())
3923
3923
  .then((data) => {
3924
- if (userId === this._httpClient.signInUserId) {
3924
+ if (userId === this.httpClient.signInUserId) {
3925
3925
  this.clearCurrentUser();
3926
3926
  }
3927
3927
  return data;
@@ -3982,13 +3982,13 @@
3982
3982
  let queryString = searchParams.toString();
3983
3983
  if (queryString)
3984
3984
  queryString = "?" + queryString;
3985
- return this._httpClient
3985
+ return this.httpClient
3986
3986
  .get(`/files${queryString}`)
3987
3987
  .then((response) => response.json())
3988
3988
  .then((files) => {
3989
3989
  return {
3990
3990
  ...files,
3991
- result: files.result.map((data) => new File(data, this._httpClient)),
3991
+ result: files.result.map((data) => new File(data, this.httpClient)),
3992
3992
  };
3993
3993
  });
3994
3994
  }
@@ -3999,10 +3999,10 @@
3999
3999
  * @param fileId - File ID.
4000
4000
  */
4001
4001
  getFile(fileId) {
4002
- return this._httpClient
4002
+ return this.httpClient
4003
4003
  .get(`/files/${fileId}`)
4004
4004
  .then((response) => response.json())
4005
- .then((data) => new File(data, this._httpClient));
4005
+ .then((data) => new File(data, this.httpClient));
4006
4006
  }
4007
4007
  /**
4008
4008
  * Upload a drawing or reference file to the server.
@@ -4039,14 +4039,14 @@
4039
4039
  properties: false,
4040
4040
  waitForDone: false,
4041
4041
  }) {
4042
- const result = await this._httpClient
4042
+ const result = await this.httpClient
4043
4043
  .uploadFile("/files", file, (progress) => {
4044
4044
  var _a;
4045
4045
  this.emitEvent({ type: "uploadprogress", data: progress, file });
4046
4046
  (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
4047
4047
  })
4048
4048
  .then((xhr) => JSON.parse(xhr.responseText))
4049
- .then((data) => new File(data, this._httpClient));
4049
+ .then((data) => new File(data, this.httpClient));
4050
4050
  const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
4051
4051
  const jobs = [];
4052
4052
  if (params.geometry)
@@ -4068,7 +4068,7 @@
4068
4068
  * @returns Returns the raw data of a deleted file.
4069
4069
  */
4070
4070
  deleteFile(fileId) {
4071
- return this._httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4071
+ return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4072
4072
  }
4073
4073
  /**
4074
4074
  * Download the drawing or reference file.
@@ -4081,7 +4081,7 @@
4081
4081
  * and abort it if desired.
4082
4082
  */
4083
4083
  downloadFile(fileId, onProgress, signal) {
4084
- return this._httpClient
4084
+ return this.httpClient
4085
4085
  .downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
4086
4086
  .then((response) => response.arrayBuffer());
4087
4087
  }
@@ -4128,12 +4128,12 @@
4128
4128
  let queryString = searchParams.toString();
4129
4129
  if (queryString)
4130
4130
  queryString = "?" + queryString;
4131
- return this._httpClient
4131
+ return this.httpClient
4132
4132
  .get(`/jobs${queryString}`)
4133
4133
  .then((response) => response.json())
4134
4134
  .then((jobs) => ({
4135
4135
  ...jobs,
4136
- result: jobs.result.map((data) => new Job(data, this._httpClient)),
4136
+ result: jobs.result.map((data) => new Job(data, this.httpClient)),
4137
4137
  }));
4138
4138
  }
4139
4139
  /**
@@ -4143,10 +4143,10 @@
4143
4143
  * @param jobId - Job ID.
4144
4144
  */
4145
4145
  getJob(jobId) {
4146
- return this._httpClient
4146
+ return this.httpClient
4147
4147
  .get(`/jobs/${jobId}`)
4148
4148
  .then((response) => response.json())
4149
- .then((data) => new Job(data, this._httpClient));
4149
+ .then((data) => new Job(data, this.httpClient));
4150
4150
  }
4151
4151
  /**
4152
4152
  * Create a new job.
@@ -4167,14 +4167,14 @@
4167
4167
  * for the File Converter tool in form "--arg=value".
4168
4168
  */
4169
4169
  createJob(fileId, outputFormat, parameters) {
4170
- return this._httpClient
4170
+ return this.httpClient
4171
4171
  .post("/jobs", {
4172
4172
  fileId,
4173
4173
  outputFormat,
4174
4174
  parameters: parseArgs(parameters),
4175
4175
  })
4176
4176
  .then((response) => response.json())
4177
- .then((data) => new Job(data, this._httpClient));
4177
+ .then((data) => new Job(data, this.httpClient));
4178
4178
  }
4179
4179
  /**
4180
4180
  * Remove a job from the server job list. The method does not delete or stop jobs that are
@@ -4185,7 +4185,7 @@
4185
4185
  * @returns Returns the raw data of a deleted job.
4186
4186
  */
4187
4187
  deleteJob(jobId) {
4188
- return this._httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4188
+ return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4189
4189
  }
4190
4190
  /**
4191
4191
  * Result for assembly list.
@@ -4234,13 +4234,13 @@
4234
4234
  let queryString = searchParams.toString();
4235
4235
  if (queryString)
4236
4236
  queryString = "?" + queryString;
4237
- return this._httpClient
4237
+ return this.httpClient
4238
4238
  .get(`/assemblies${queryString}`)
4239
4239
  .then((response) => response.json())
4240
4240
  .then((assemblies) => {
4241
4241
  return {
4242
4242
  ...assemblies,
4243
- result: assemblies.result.map((data) => new Assembly(data, this._httpClient)),
4243
+ result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
4244
4244
  };
4245
4245
  });
4246
4246
  }
@@ -4251,10 +4251,10 @@
4251
4251
  * @param assemblyId - Assembly ID.
4252
4252
  */
4253
4253
  getAssembly(assemblyId) {
4254
- return this._httpClient
4254
+ return this.httpClient
4255
4255
  .get(`/assemblies/${assemblyId}`)
4256
4256
  .then((response) => response.json())
4257
- .then((data) => new Assembly(data, this._httpClient));
4257
+ .then((data) => new Assembly(data, this.httpClient));
4258
4258
  }
4259
4259
  /**
4260
4260
  * Create a new assembly.
@@ -4267,10 +4267,10 @@
4267
4267
  */
4268
4268
  createAssembly(files, name, params) {
4269
4269
  const { waitForDone } = params !== null && params !== void 0 ? params : {};
4270
- return this._httpClient
4270
+ return this.httpClient
4271
4271
  .post("/assemblies", { name, files })
4272
4272
  .then((response) => response.json())
4273
- .then((data) => new Assembly(data, this._httpClient))
4273
+ .then((data) => new Assembly(data, this.httpClient))
4274
4274
  .then((result) => (waitForDone ? result.waitForDone(params) : result));
4275
4275
  }
4276
4276
  /**
@@ -4281,7 +4281,7 @@
4281
4281
  * @returns Returns the raw data of a deleted assembly.
4282
4282
  */
4283
4283
  deleteAssembly(assemblyId) {
4284
- return this._httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4284
+ return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4285
4285
  }
4286
4286
  /**
4287
4287
  * Result for project list.
@@ -4326,7 +4326,7 @@
4326
4326
  let queryString = searchParams.toString();
4327
4327
  if (queryString)
4328
4328
  queryString = "?" + queryString;
4329
- return this._httpClient
4329
+ return this.httpClient
4330
4330
  .get(`/projects${queryString}`)
4331
4331
  .then((response) => response.json())
4332
4332
  .then((projects) => {
@@ -4354,7 +4354,7 @@
4354
4354
  .then((projects) => {
4355
4355
  return {
4356
4356
  ...projects,
4357
- result: projects.result.map((data) => new Project(data, this._httpClient)),
4357
+ result: projects.result.map((data) => new Project(data, this.httpClient)),
4358
4358
  };
4359
4359
  });
4360
4360
  }
@@ -4365,10 +4365,10 @@
4365
4365
  * @param projectId - Project ID.
4366
4366
  */
4367
4367
  getProject(projectId) {
4368
- return this._httpClient
4368
+ return this.httpClient
4369
4369
  .get(`/projects/${projectId}`)
4370
4370
  .then((response) => response.json())
4371
- .then((data) => new Project(data, this._httpClient));
4371
+ .then((data) => new Project(data, this.httpClient));
4372
4372
  }
4373
4373
  /**
4374
4374
  * Create a new project.
@@ -4383,7 +4383,7 @@
4383
4383
  * target="_blank">Data URL</a>.
4384
4384
  */
4385
4385
  createProject(name, description, startDate, endDate, avatarUrl) {
4386
- return this._httpClient
4386
+ return this.httpClient
4387
4387
  .post("/projects", {
4388
4388
  name,
4389
4389
  description,
@@ -4392,7 +4392,7 @@
4392
4392
  avatarUrl,
4393
4393
  })
4394
4394
  .then((response) => response.json())
4395
- .then((data) => new Project(data, this._httpClient));
4395
+ .then((data) => new Project(data, this.httpClient));
4396
4396
  }
4397
4397
  /**
4398
4398
  * Delete the project from the server.
@@ -4402,7 +4402,7 @@
4402
4402
  * @returns Returns the raw data of a deleted project.
4403
4403
  */
4404
4404
  deleteProject(projectId) {
4405
- return this._httpClient
4405
+ return this.httpClient
4406
4406
  .delete(`/projects/${projectId}`)
4407
4407
  .then((response) => response.text())
4408
4408
  .then((text) => {
@@ -4418,11 +4418,12 @@
4418
4418
  }
4419
4419
 
4420
4420
  ///////////////////////////////////////////////////////////////////////////////
4421
- const version = "25.4.2";
4421
+ const version = "25.4.3";
4422
4422
 
4423
4423
  exports.Assembly = Assembly;
4424
4424
  exports.ClashTest = ClashTest;
4425
4425
  exports.Client = Client;
4426
+ exports.FetchError = FetchError;
4426
4427
  exports.File = File;
4427
4428
  exports.Job = Job;
4428
4429
  exports.Member = Member;
@@ -4432,6 +4433,7 @@
4432
4433
  exports.Role = Role;
4433
4434
  exports.User = User;
4434
4435
  exports.parseArgs = parseArgs;
4436
+ exports.statusText = statusText;
4435
4437
  exports.userFullName = userFullName;
4436
4438
  exports.userInitials = userInitials;
4437
4439
  exports.version = version;