@inweb/client 25.4.2 → 25.4.4

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
@@ -196,9 +196,8 @@
196
196
  return this._file.deleteViewpoint(guid);
197
197
  }
198
198
  /**
199
- * Returns viewpoint preview image as <a
200
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
201
- * target="_blank">Data URL</a>.
199
+ * Returns viewpoint preview image as
200
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
202
201
  *
203
202
  * @async
204
203
  * @param guid - Viewpoint GIID.
@@ -1029,26 +1028,54 @@
1029
1028
  getCdaTree() {
1030
1029
  return this.internalGet(`/properties/tree`).then((response) => response.json());
1031
1030
  }
1032
- // Reserved for future use
1031
+ /**
1032
+ * Returns a list of assembly viewpoints.
1033
+ *
1034
+ * @async
1035
+ */
1033
1036
  getViewpoints() {
1034
- console.warn("Assembly does not support viewpoints");
1035
- return Promise.resolve([]);
1037
+ return this.internalGet("/viewpoints")
1038
+ .then((response) => response.json())
1039
+ .then((viewpoints) => viewpoints.result);
1036
1040
  }
1041
+ /**
1042
+ * Add new assembly viewpoint. To create a new viewpoint use {@link Viewer.createViewpoint()}.
1043
+ *
1044
+ * @async
1045
+ * @param viewpoint - Viewpoint.
1046
+ */
1037
1047
  saveViewpoint(viewpoint) {
1038
- console.warn("Assembly does not support viewpoints");
1039
- return Promise.resolve({});
1048
+ return this.internalPost("/viewpoints", viewpoint).then((response) => response.json());
1040
1049
  }
1050
+ /**
1051
+ * Delete assembly viewpoint.
1052
+ *
1053
+ * @async
1054
+ * @param guid - Viewpoint GUID.
1055
+ * @returns Returns the raw data of a deleted viewpoint.
1056
+ */
1041
1057
  deleteViewpoint(guid) {
1042
- console.warn("Assembly does not support viewpoints");
1043
- return Promise.resolve({});
1058
+ return this.internalDelete(`/viewpoints/${guid}`).then((response) => response.json());
1044
1059
  }
1060
+ /**
1061
+ * Returns viewpoint preview image as
1062
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
1063
+ *
1064
+ * @async
1065
+ * @param guid - Viewpoint GUID.
1066
+ */
1045
1067
  getSnapshot(guid) {
1046
- console.warn("Assembly does not support viewpoints");
1047
- return Promise.resolve({});
1068
+ return this.internalGet(`/viewpoints/${guid}/snapshot`).then((response) => response.text());
1048
1069
  }
1070
+ /**
1071
+ * Returns viewpoint preview data.
1072
+ *
1073
+ * @async
1074
+ * @param guid - Viewpoint GUID.
1075
+ * @param bitmapGuid - Bitmap GUID.
1076
+ */
1049
1077
  getSnapshotData(guid, bitmapGuid) {
1050
- console.warn("Assembly does not support viewpoints");
1051
- return Promise.resolve("");
1078
+ return this.internalGet(`/viewpoints/${guid}/bitmaps/${bitmapGuid}`).then((response) => response.text());
1052
1079
  }
1053
1080
  /**
1054
1081
  * Download assembly resource file. Resource files are files that contain model scene
@@ -1316,7 +1343,7 @@
1316
1343
  });
1317
1344
  }
1318
1345
  default:
1319
- return Promise.reject(new FetchError(response.status, statusText(response.status)));
1346
+ return Promise.reject(new FetchError(response.status));
1320
1347
  }
1321
1348
  }
1322
1349
  return Promise.resolve(response);
@@ -2294,9 +2321,8 @@
2294
2321
  return this.internalDelete(`/viewpoints/${guid}`).then((response) => response.json());
2295
2322
  }
2296
2323
  /**
2297
- * Returns viewpoint preview image as <a
2298
- * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
2299
- * target="_blank">Data URL</a>.
2324
+ * Returns viewpoint preview image as
2325
+ * {@link https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs | Data URL}.
2300
2326
  *
2301
2327
  * @async
2302
2328
  * @param guid - Viewpoint GUID.
@@ -3642,7 +3668,7 @@
3642
3668
  constructor(params = {}) {
3643
3669
  super();
3644
3670
  this._serverUrl = "";
3645
- this._httpClient = new HttpClient("");
3671
+ this.httpClient = new HttpClient("");
3646
3672
  this._user = null;
3647
3673
  this.eventEmitter = this;
3648
3674
  this.configure(params);
@@ -3704,7 +3730,7 @@
3704
3730
  */
3705
3731
  configure(params) {
3706
3732
  this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
3707
- this._httpClient = new HttpClient(this.serverUrl);
3733
+ this.httpClient = new HttpClient(this.serverUrl);
3708
3734
  this._user = null;
3709
3735
  return this;
3710
3736
  }
@@ -3721,13 +3747,13 @@
3721
3747
  * @async
3722
3748
  */
3723
3749
  version() {
3724
- return this._httpClient
3750
+ return this.httpClient
3725
3751
  .get("/version")
3726
3752
  .then((response) => response.json())
3727
3753
  .then((data) => ({
3728
3754
  ...data,
3729
3755
  server: data.version,
3730
- client: "25.4.2",
3756
+ client: "25.4.4",
3731
3757
  }));
3732
3758
  }
3733
3759
  /**
@@ -3741,7 +3767,7 @@
3741
3767
  * `username` from email.
3742
3768
  */
3743
3769
  registerUser(email, password, userName) {
3744
- return this._httpClient
3770
+ return this.httpClient
3745
3771
  .post("/register", {
3746
3772
  email,
3747
3773
  password,
@@ -3758,7 +3784,7 @@
3758
3784
  * @param password - User password.
3759
3785
  */
3760
3786
  resendConfirmationEmail(email, password) {
3761
- return this._httpClient
3787
+ return this.httpClient
3762
3788
  .post("/register/email-confirmation", { email, password })
3763
3789
  .then((response) => response.json());
3764
3790
  }
@@ -3769,7 +3795,7 @@
3769
3795
  * @param emailConfirmationId - Confirmation code from the Confirmation Email.
3770
3796
  */
3771
3797
  confirmUserEmail(emailConfirmationId) {
3772
- return this._httpClient
3798
+ return this.httpClient
3773
3799
  .get(`/register/email-confirmation/${emailConfirmationId}`)
3774
3800
  .then((response) => response.json());
3775
3801
  }
@@ -3782,8 +3808,8 @@
3782
3808
  */
3783
3809
  async signInWithEmail(email, password) {
3784
3810
  const credentials = btoa(unescape(encodeURIComponent(email + ":" + password)));
3785
- this._httpClient.headers = { Authorization: "Basic " + credentials };
3786
- const response = await this._httpClient.get("/token");
3811
+ this.httpClient.headers = { Authorization: "Basic " + credentials };
3812
+ const response = await this.httpClient.get("/token");
3787
3813
  const data = await response.json();
3788
3814
  return this.setCurrentUser(data);
3789
3815
  }
@@ -3794,8 +3820,8 @@
3794
3820
  * @param token - An access token for authentication request. See {@link User.token} for more details.
3795
3821
  */
3796
3822
  async signInWithToken(token) {
3797
- this._httpClient.headers = { Authorization: token };
3798
- const response = await this._httpClient.get("/user");
3823
+ this.httpClient.headers = { Authorization: token };
3824
+ const response = await this.httpClient.get("/user");
3799
3825
  const data = await response.json();
3800
3826
  return this.setCurrentUser(data);
3801
3827
  }
@@ -3807,28 +3833,30 @@
3807
3833
  * - Open the `provider.url` link using `window.open()`.
3808
3834
  * - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
3809
3835
  * message if the `error` search parameter is present, or log in with the `token` search parameter.
3836
+ *
3837
+ * @async
3810
3838
  */
3811
3839
  getIdentityProviders() {
3812
- return this._httpClient.get("/identity").then((response) => response.json());
3840
+ return this.httpClient.get("/identity").then((response) => response.json());
3813
3841
  }
3814
3842
  // Save the current logged in user information for internal use.
3815
3843
  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;
3844
+ this._user = new User(data, this.httpClient);
3845
+ this.httpClient.headers = { Authorization: data.tokenInfo.token };
3846
+ this.httpClient.signInUserId = this._user.id;
3819
3847
  return this._user;
3820
3848
  }
3821
3849
  clearCurrentUser() {
3822
3850
  this._user = null;
3823
- this._httpClient.headers = {};
3824
- this._httpClient.signInUserId = "";
3851
+ this.httpClient.headers = {};
3852
+ this.httpClient.signInUserId = "";
3825
3853
  }
3826
3854
  /**
3827
3855
  * Returns the current logged in user information. Returns `null` if the user is not logged
3828
3856
  * in or the logged in user has deleted himself.
3829
3857
  */
3830
3858
  getCurrentUser() {
3831
- if (this._user && !this._httpClient.signInUserId)
3859
+ if (this._user && !this.httpClient.signInUserId)
3832
3860
  this._user = null;
3833
3861
  return this._user;
3834
3862
  }
@@ -3839,11 +3867,11 @@
3839
3867
  * @async
3840
3868
  */
3841
3869
  getUsers() {
3842
- return this._httpClient
3870
+ return this.httpClient
3843
3871
  .get("/users")
3844
3872
  .then((response) => response.json())
3845
3873
  .then((array) => array.map((data) => ({ id: data.id, ...data.userBrief })))
3846
- .then((array) => array.map((data) => new User(data, this._httpClient)));
3874
+ .then((array) => array.map((data) => new User(data, this.httpClient)));
3847
3875
  }
3848
3876
  /**
3849
3877
  * Returns the user information. Only admins can get other users, if the current logged in
@@ -3854,19 +3882,19 @@
3854
3882
  * @param userId - User ID.
3855
3883
  */
3856
3884
  getUser(userId) {
3857
- if (userId === this._httpClient.signInUserId) {
3858
- return this._httpClient
3885
+ if (userId === this.httpClient.signInUserId) {
3886
+ return this.httpClient
3859
3887
  .get("/user")
3860
3888
  .then((response) => response.json())
3861
3889
  .then((data) => ({ id: userId, ...data }))
3862
- .then((data) => new User(data, this._httpClient));
3890
+ .then((data) => new User(data, this.httpClient));
3863
3891
  }
3864
3892
  else {
3865
- return this._httpClient
3893
+ return this.httpClient
3866
3894
  .get(`/users/${userId}`)
3867
3895
  .then((response) => response.json())
3868
3896
  .then((data) => ({ id: data.id, ...data.userBrief }))
3869
- .then((data) => new User(data, this._httpClient));
3897
+ .then((data) => new User(data, this.httpClient));
3870
3898
  }
3871
3899
  }
3872
3900
  /**
@@ -3889,7 +3917,7 @@
3889
3917
  */
3890
3918
  createUser(email, password, params = {}) {
3891
3919
  const { isAdmin, userName, ...rest } = params;
3892
- return this._httpClient
3920
+ return this.httpClient
3893
3921
  .post("/users", {
3894
3922
  isAdmin,
3895
3923
  userBrief: {
@@ -3901,7 +3929,7 @@
3901
3929
  })
3902
3930
  .then((response) => response.json())
3903
3931
  .then((data) => ({ id: data.id, ...data.userBrief }))
3904
- .then((data) => new User(data, this._httpClient));
3932
+ .then((data) => new User(data, this.httpClient));
3905
3933
  }
3906
3934
  /**
3907
3935
  * Delete a user from the server. Only admins can delete users, if the current logged in user
@@ -3917,11 +3945,11 @@
3917
3945
  * @returns Returns the raw data of a deleted user.
3918
3946
  */
3919
3947
  deleteUser(userId) {
3920
- return this._httpClient
3948
+ return this.httpClient
3921
3949
  .delete(`/users/${userId}`)
3922
3950
  .then((response) => response.json())
3923
3951
  .then((data) => {
3924
- if (userId === this._httpClient.signInUserId) {
3952
+ if (userId === this.httpClient.signInUserId) {
3925
3953
  this.clearCurrentUser();
3926
3954
  }
3927
3955
  return data;
@@ -3982,13 +4010,13 @@
3982
4010
  let queryString = searchParams.toString();
3983
4011
  if (queryString)
3984
4012
  queryString = "?" + queryString;
3985
- return this._httpClient
4013
+ return this.httpClient
3986
4014
  .get(`/files${queryString}`)
3987
4015
  .then((response) => response.json())
3988
4016
  .then((files) => {
3989
4017
  return {
3990
4018
  ...files,
3991
- result: files.result.map((data) => new File(data, this._httpClient)),
4019
+ result: files.result.map((data) => new File(data, this.httpClient)),
3992
4020
  };
3993
4021
  });
3994
4022
  }
@@ -3999,10 +4027,10 @@
3999
4027
  * @param fileId - File ID.
4000
4028
  */
4001
4029
  getFile(fileId) {
4002
- return this._httpClient
4030
+ return this.httpClient
4003
4031
  .get(`/files/${fileId}`)
4004
4032
  .then((response) => response.json())
4005
- .then((data) => new File(data, this._httpClient));
4033
+ .then((data) => new File(data, this.httpClient));
4006
4034
  }
4007
4035
  /**
4008
4036
  * Upload a drawing or reference file to the server.
@@ -4039,14 +4067,14 @@
4039
4067
  properties: false,
4040
4068
  waitForDone: false,
4041
4069
  }) {
4042
- const result = await this._httpClient
4070
+ const result = await this.httpClient
4043
4071
  .uploadFile("/files", file, (progress) => {
4044
4072
  var _a;
4045
4073
  this.emitEvent({ type: "uploadprogress", data: progress, file });
4046
4074
  (_a = params.onProgress) === null || _a === void 0 ? void 0 : _a.call(params, progress, file);
4047
4075
  })
4048
4076
  .then((xhr) => JSON.parse(xhr.responseText))
4049
- .then((data) => new File(data, this._httpClient));
4077
+ .then((data) => new File(data, this.httpClient));
4050
4078
  const geometryType = typeof params.geometry === "string" ? params.geometry : "vsfx";
4051
4079
  const jobs = [];
4052
4080
  if (params.geometry)
@@ -4068,7 +4096,7 @@
4068
4096
  * @returns Returns the raw data of a deleted file.
4069
4097
  */
4070
4098
  deleteFile(fileId) {
4071
- return this._httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4099
+ return this.httpClient.delete(`/files/${fileId}`).then((response) => response.json());
4072
4100
  }
4073
4101
  /**
4074
4102
  * Download the drawing or reference file.
@@ -4081,7 +4109,7 @@
4081
4109
  * and abort it if desired.
4082
4110
  */
4083
4111
  downloadFile(fileId, onProgress, signal) {
4084
- return this._httpClient
4112
+ return this.httpClient
4085
4113
  .downloadFile(`/files/${fileId}/downloads`, onProgress, signal)
4086
4114
  .then((response) => response.arrayBuffer());
4087
4115
  }
@@ -4128,12 +4156,12 @@
4128
4156
  let queryString = searchParams.toString();
4129
4157
  if (queryString)
4130
4158
  queryString = "?" + queryString;
4131
- return this._httpClient
4159
+ return this.httpClient
4132
4160
  .get(`/jobs${queryString}`)
4133
4161
  .then((response) => response.json())
4134
4162
  .then((jobs) => ({
4135
4163
  ...jobs,
4136
- result: jobs.result.map((data) => new Job(data, this._httpClient)),
4164
+ result: jobs.result.map((data) => new Job(data, this.httpClient)),
4137
4165
  }));
4138
4166
  }
4139
4167
  /**
@@ -4143,10 +4171,10 @@
4143
4171
  * @param jobId - Job ID.
4144
4172
  */
4145
4173
  getJob(jobId) {
4146
- return this._httpClient
4174
+ return this.httpClient
4147
4175
  .get(`/jobs/${jobId}`)
4148
4176
  .then((response) => response.json())
4149
- .then((data) => new Job(data, this._httpClient));
4177
+ .then((data) => new Job(data, this.httpClient));
4150
4178
  }
4151
4179
  /**
4152
4180
  * Create a new job.
@@ -4167,14 +4195,14 @@
4167
4195
  * for the File Converter tool in form "--arg=value".
4168
4196
  */
4169
4197
  createJob(fileId, outputFormat, parameters) {
4170
- return this._httpClient
4198
+ return this.httpClient
4171
4199
  .post("/jobs", {
4172
4200
  fileId,
4173
4201
  outputFormat,
4174
4202
  parameters: parseArgs(parameters),
4175
4203
  })
4176
4204
  .then((response) => response.json())
4177
- .then((data) => new Job(data, this._httpClient));
4205
+ .then((data) => new Job(data, this.httpClient));
4178
4206
  }
4179
4207
  /**
4180
4208
  * Remove a job from the server job list. The method does not delete or stop jobs that are
@@ -4185,7 +4213,7 @@
4185
4213
  * @returns Returns the raw data of a deleted job.
4186
4214
  */
4187
4215
  deleteJob(jobId) {
4188
- return this._httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4216
+ return this.httpClient.delete(`/jobs/${jobId}`).then((response) => response.json());
4189
4217
  }
4190
4218
  /**
4191
4219
  * Result for assembly list.
@@ -4234,13 +4262,13 @@
4234
4262
  let queryString = searchParams.toString();
4235
4263
  if (queryString)
4236
4264
  queryString = "?" + queryString;
4237
- return this._httpClient
4265
+ return this.httpClient
4238
4266
  .get(`/assemblies${queryString}`)
4239
4267
  .then((response) => response.json())
4240
4268
  .then((assemblies) => {
4241
4269
  return {
4242
4270
  ...assemblies,
4243
- result: assemblies.result.map((data) => new Assembly(data, this._httpClient)),
4271
+ result: assemblies.result.map((data) => new Assembly(data, this.httpClient)),
4244
4272
  };
4245
4273
  });
4246
4274
  }
@@ -4251,10 +4279,10 @@
4251
4279
  * @param assemblyId - Assembly ID.
4252
4280
  */
4253
4281
  getAssembly(assemblyId) {
4254
- return this._httpClient
4282
+ return this.httpClient
4255
4283
  .get(`/assemblies/${assemblyId}`)
4256
4284
  .then((response) => response.json())
4257
- .then((data) => new Assembly(data, this._httpClient));
4285
+ .then((data) => new Assembly(data, this.httpClient));
4258
4286
  }
4259
4287
  /**
4260
4288
  * Create a new assembly.
@@ -4267,10 +4295,10 @@
4267
4295
  */
4268
4296
  createAssembly(files, name, params) {
4269
4297
  const { waitForDone } = params !== null && params !== void 0 ? params : {};
4270
- return this._httpClient
4298
+ return this.httpClient
4271
4299
  .post("/assemblies", { name, files })
4272
4300
  .then((response) => response.json())
4273
- .then((data) => new Assembly(data, this._httpClient))
4301
+ .then((data) => new Assembly(data, this.httpClient))
4274
4302
  .then((result) => (waitForDone ? result.waitForDone(params) : result));
4275
4303
  }
4276
4304
  /**
@@ -4281,7 +4309,7 @@
4281
4309
  * @returns Returns the raw data of a deleted assembly.
4282
4310
  */
4283
4311
  deleteAssembly(assemblyId) {
4284
- return this._httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4312
+ return this.httpClient.delete(`/assemblies/${assemblyId}`).then((response) => response.json());
4285
4313
  }
4286
4314
  /**
4287
4315
  * Result for project list.
@@ -4326,7 +4354,7 @@
4326
4354
  let queryString = searchParams.toString();
4327
4355
  if (queryString)
4328
4356
  queryString = "?" + queryString;
4329
- return this._httpClient
4357
+ return this.httpClient
4330
4358
  .get(`/projects${queryString}`)
4331
4359
  .then((response) => response.json())
4332
4360
  .then((projects) => {
@@ -4354,7 +4382,7 @@
4354
4382
  .then((projects) => {
4355
4383
  return {
4356
4384
  ...projects,
4357
- result: projects.result.map((data) => new Project(data, this._httpClient)),
4385
+ result: projects.result.map((data) => new Project(data, this.httpClient)),
4358
4386
  };
4359
4387
  });
4360
4388
  }
@@ -4365,10 +4393,10 @@
4365
4393
  * @param projectId - Project ID.
4366
4394
  */
4367
4395
  getProject(projectId) {
4368
- return this._httpClient
4396
+ return this.httpClient
4369
4397
  .get(`/projects/${projectId}`)
4370
4398
  .then((response) => response.json())
4371
- .then((data) => new Project(data, this._httpClient));
4399
+ .then((data) => new Project(data, this.httpClient));
4372
4400
  }
4373
4401
  /**
4374
4402
  * Create a new project.
@@ -4383,7 +4411,7 @@
4383
4411
  * target="_blank">Data URL</a>.
4384
4412
  */
4385
4413
  createProject(name, description, startDate, endDate, avatarUrl) {
4386
- return this._httpClient
4414
+ return this.httpClient
4387
4415
  .post("/projects", {
4388
4416
  name,
4389
4417
  description,
@@ -4392,7 +4420,7 @@
4392
4420
  avatarUrl,
4393
4421
  })
4394
4422
  .then((response) => response.json())
4395
- .then((data) => new Project(data, this._httpClient));
4423
+ .then((data) => new Project(data, this.httpClient));
4396
4424
  }
4397
4425
  /**
4398
4426
  * Delete the project from the server.
@@ -4402,7 +4430,7 @@
4402
4430
  * @returns Returns the raw data of a deleted project.
4403
4431
  */
4404
4432
  deleteProject(projectId) {
4405
- return this._httpClient
4433
+ return this.httpClient
4406
4434
  .delete(`/projects/${projectId}`)
4407
4435
  .then((response) => response.text())
4408
4436
  .then((text) => {
@@ -4418,11 +4446,12 @@
4418
4446
  }
4419
4447
 
4420
4448
  ///////////////////////////////////////////////////////////////////////////////
4421
- const version = "25.4.2";
4449
+ const version = "25.4.4";
4422
4450
 
4423
4451
  exports.Assembly = Assembly;
4424
4452
  exports.ClashTest = ClashTest;
4425
4453
  exports.Client = Client;
4454
+ exports.FetchError = FetchError;
4426
4455
  exports.File = File;
4427
4456
  exports.Job = Job;
4428
4457
  exports.Member = Member;
@@ -4432,6 +4461,7 @@
4432
4461
  exports.Role = Role;
4433
4462
  exports.User = User;
4434
4463
  exports.parseArgs = parseArgs;
4464
+ exports.statusText = statusText;
4435
4465
  exports.userFullName = userFullName;
4436
4466
  exports.userInitials = userInitials;
4437
4467
  exports.version = version;