@inweb/client 25.8.16 → 25.8.19

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/src/Api/Client.ts CHANGED
@@ -35,19 +35,18 @@ import { User } from "./User";
35
35
  import { parseArgs } from "./Utils";
36
36
 
37
37
  /**
38
- * The `Client.js` library class that provides methods to access the
39
- * {@link https://cloud.opendesign.com/docs/index.html#/opencloud_server | Open Cloud Server}
40
- * resources like Projects, Files, Issues etc.
38
+ * Provides methods for managing server resources such as users, files, assemblies, jobs, projects, etc.
41
39
  */
42
40
  export class Client extends EventEmitter2<ClientEventMap> {
43
41
  private _serverUrl = "";
44
- public httpClient: IHttpClient = new HttpClient("");
42
+ private _httpClient: IHttpClient = new HttpClient("");
45
43
  private _user: User | null = null;
46
44
  public eventEmitter: EventEmitter2 = this;
47
45
 
48
46
  /**
49
47
  * @param params - An object containing client configuration parameters.
50
- * @param params.serverUrl - Open Cloud Server URL.
48
+ * @param params.serverUrl - Open Cloud Server REST API base URL.
49
+ * @param params.url - Deprecated since `25.8`. Use `serverUrl` instead.
51
50
  */
52
51
  constructor(params: { serverUrl?: string; url?: string } = {}) {
53
52
  super();
@@ -55,7 +54,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
55
54
  }
56
55
 
57
56
  /**
58
- * Open Cloud Server URL. Use {@link configure | configure()} to change server URL.
57
+ * Open Cloud Server REST API base URL. Use {@link configure | configure()} to change server URL.
59
58
  *
60
59
  * @readonly
61
60
  */
@@ -64,7 +63,16 @@ export class Client extends EventEmitter2<ClientEventMap> {
64
63
  }
65
64
 
66
65
  /**
67
- * Deprecated since `25.3`. Use `Viewer.options()` instead to change Viewer parameters.
66
+ * HTTP client instance used to send REST API requests and receive responses from the server.
67
+ *
68
+ * @readonly
69
+ */
70
+ get httpClient(): IHttpClient {
71
+ return this._httpClient;
72
+ }
73
+
74
+ /**
75
+ * Deprecated since `25.3`. Use `Viewer.options()` instead to change `Viewer` parameters.
68
76
  *
69
77
  * @deprecated
70
78
  */
@@ -109,15 +117,16 @@ export class Client extends EventEmitter2<ClientEventMap> {
109
117
  }
110
118
 
111
119
  /**
112
- * Change the client configuration parameters.
120
+ * Changes the client parameters.
121
+ *
122
+ * After changing the parameters, you must re-login.
113
123
  *
114
- * @param params - An object containing new configuration parameters.
115
- * @param params.serverUrl - Open Cloud Server URL.
116
- * @returns Returns a reference to the `Client`.
124
+ * @param params - An object containing new parameters.
125
+ * @param params.serverUrl - Open Cloud Server REST API base URL.
117
126
  */
118
127
  configure(params: { serverUrl?: string }): this {
119
128
  this._serverUrl = (params.serverUrl || "").replace(/\/+$/, "");
120
- this.httpClient = new HttpClient(this.serverUrl);
129
+ this._httpClient = new HttpClient(this.serverUrl);
121
130
  this._user = null;
122
131
  return this;
123
132
  }
@@ -131,7 +140,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
131
140
  */
132
141
 
133
142
  /**
134
- * Returns server version.
143
+ * Returns client and server versions.
135
144
  */
136
145
  version(): Promise<any> {
137
146
  return this.httpClient
@@ -145,13 +154,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
145
154
  }
146
155
 
147
156
  /**
148
- * Register a new user with the specified email and password.
157
+ * Registers a new user on the server.
149
158
  *
150
- * @param email - User email. Cannot be empty.
159
+ * @param email - User email. Cannot be empty. Must be unique within the server.
151
160
  * @param password - User password. Cannot be empty. Password can only contain letters (a-z,
152
161
  * A-Z), numbers (0-9), and special characters (~!@#$%^&*()_-+={}[]<>|/'":;.,?).
153
- * @param userName - User name. Cannot be empty or blank if defined. Leave undefined to use
154
- * `username` from email.
162
+ * @param userName - User name. Cannot be empty or blank if defined. this to `undefined` to
163
+ * use `username` from email.
155
164
  */
156
165
  registerUser(email: string, password: string, userName?: string): Promise<any> {
157
166
  return this.httpClient
@@ -164,7 +173,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
164
173
  }
165
174
 
166
175
  /**
167
- * Resend the Confirmation Email to new user. If the user's email is already confirmed, an
176
+ * Resends a Confirmation Email to the new user. If the user's email is already confirmed, an
168
177
  * exception will be thrown.
169
178
  *
170
179
  * @param email - User email.
@@ -177,7 +186,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
177
186
  }
178
187
 
179
188
  /**
180
- * Confirm the user's email. If the user's email is already confirmed, an exception will be thrown.
189
+ * Marks the user's email address as confirmed. If the user's email is already confirmed, an
190
+ * exception will be thrown.
181
191
  *
182
192
  * @param emailConfirmationId - Confirmation code from the Confirmation Email.
183
193
  */
@@ -231,8 +241,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
231
241
  }
232
242
 
233
243
  /**
234
- * Returns the current logged in user information. Returns `null` if the user is not logged
235
- * in or the logged in user has deleted himself.
244
+ * Returns the current logged in user. Returns `null` if the user is not logged in or the
245
+ * logged in user has deleted themself.
236
246
  */
237
247
  getCurrentUser(): User | null {
238
248
  if (this._user && !this.httpClient.signInUserId) this._user = null;
@@ -240,13 +250,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
240
250
  }
241
251
 
242
252
  /**
243
- * Get the list of server indentity providers.
244
- *
245
- * To sign in with the provider in your web application:
246
- *
247
- * - Open the `provider.url` link using `window.open()`.
248
- * - Add a `/oauth` path (server-defined) handler to the router. In this handler, show an error
249
- * message if the `error` search parameter is present, or log in with the `token` search parameter.
253
+ * Returns the list of server enabled indentity providers.
250
254
  */
251
255
  getIdentityProviders(): Promise<any> {
252
256
  return this.httpClient.get("/identity").then((response) => response.json());
@@ -260,7 +264,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
260
264
  }
261
265
 
262
266
  /**
263
- * Change server settings.
267
+ * Changes the server settings.
264
268
  *
265
269
  * Only administrators can change server settings. If the current logged in user is not an
266
270
  * administrator, an exception will be thrown.
@@ -270,7 +274,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
270
274
  }
271
275
 
272
276
  /**
273
- * Returns a list of server users.
277
+ * Returns the list of server users.
274
278
  *
275
279
  * Only administrators can get a list of users. If the current logged in user is not an
276
280
  * administrator, an exception will be thrown.
@@ -284,7 +288,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
284
288
  }
285
289
 
286
290
  /**
287
- * Returns the user information.
291
+ * Returns information about the specified user.
288
292
  *
289
293
  * Only administrators can get other users. If the current logged in user is not an
290
294
  * administrator, they can only get themselves, otherwise an exception will be thrown.
@@ -310,18 +314,18 @@ export class Client extends EventEmitter2<ClientEventMap> {
310
314
  }
311
315
 
312
316
  /**
313
- * Create a new user.
317
+ * Creates a new user on the server.
314
318
  *
315
319
  * Only administrators can create users. If the current logged in user is not an
316
320
  * administrator, an exception will be thrown.
317
321
  *
318
- * @param email - User email. Cannot be empty.
322
+ * @param email - User email. Cannot be empty. Must be unique within the server.
319
323
  * @param password - User password. Cannot be empty. Password can only contain latin letters
320
324
  * (a-z, A-Z), numbers (0-9), and special characters (~!@#$%^&*()_-+={}[]<>|/'":;.,?).
321
325
  * @param params - Additional user data.
322
326
  * @param params.isAdmin - `true` if user is an administrator.
323
- * @param params.userName - User name. Cannot be empty or blank if defined. Leave undefined
324
- * to use `username` from email.
327
+ * @param params.userName - User name. Cannot be empty or blank if defined. Specify
328
+ * `undefined` to use `username` from email.
325
329
  * @param params.firstName - First name.
326
330
  * @param params.lastName - Last name.
327
331
  * @param params.canCreateProject - `true` if user is allowed to create a project.
@@ -358,7 +362,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
358
362
  }
359
363
 
360
364
  /**
361
- * Delete a user from the server.
365
+ * Deletes the specified user from the server.
362
366
  *
363
367
  * Only administrators can delete users. If the current logged in user is not an
364
368
  * administrator, an exception will be thrown.
@@ -366,7 +370,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
366
370
  * Administrators can delete themselves or other administrators. An administrator can only
367
371
  * delete themself if they is not the last administrator.
368
372
  *
369
- * You need to re-login to continue working after deleting the current logged in user.
373
+ * You need to re-login after deleting the current logged in user.
370
374
  *
371
375
  * @param userId - User ID.
372
376
  * @returns Returns the raw data of a deleted user.
@@ -399,17 +403,15 @@ export class Client extends EventEmitter2<ClientEventMap> {
399
403
  */
400
404
 
401
405
  /**
402
- * Returns a list of files the user has access to.
406
+ * Returns a list of files that the current logged in user has uploaded to the server or has access to.
403
407
  *
404
408
  * @param start - The starting index in the file list. Used for paging.
405
409
  * @param limit - The maximum number of files that should be returned per request. Used for paging.
406
- * @param name - Filter the files by part of the name.
410
+ * @param name - Filter the files by part of the name. Case sensitive.
407
411
  * @param ext - Filter the files by extension. Extension can be `dgn`, `dwf`, `dwg`, `dxf`,
408
412
  * `ifc`, `ifczip`, `nwc`, `nwd`, `obj`, `rcs`, `rfa`, `rvt`, `step`, `stl`, `stp`, `vsf`,
409
- * or any other drawing or reference file type extension. You can specify multiple
410
- * extensions on one string by separating them with a `|`.
411
- * @param ids - List of file IDs to return. You can specify multiple IDs on one `string` by
412
- * separating them with a `|`.
413
+ * or any other file type extension.
414
+ * @param ids - List of file IDs to return.
413
415
  * @param sortByDesc - Allows to specify the descending order of the result. By default,
414
416
  * files are sorted by name in ascending order.
415
417
  * @param {string} sortField - Allows to specify sort field.
@@ -454,7 +456,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
454
456
  }
455
457
 
456
458
  /**
457
- * Returns the file information.
459
+ * Returns information about the specified file.
458
460
  *
459
461
  * @param fileId - File ID.
460
462
  */
@@ -472,16 +474,16 @@ export class Client extends EventEmitter2<ClientEventMap> {
472
474
  *
473
475
  * - {@link UploadProgressEvent | uploadprogress}
474
476
  *
475
- * @param file - Web API {@link https://developer.mozilla.org/docs/Web/API/File | File} object
477
+ * @param file - {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object
476
478
  * are generally retrieved from a
477
479
  * {@link https://developer.mozilla.org/docs/Web/API/FileList | FileList} object returned as
478
480
  * a result of a user selecting files using the HTML `<input>` element.
479
481
  * @param params - An object containing upload parameters.
480
- * @param params.geometry - Create job to extract file geometry data. Can be:
482
+ * @param params.geometry - Create job to convert file geometry data. Can be:
481
483
  *
482
- * - `true` - Extract file geometry data into `VSFX` to open the file in `VisualizeJS` viewer.
483
- * - `vsfx` - Extract file geometry data into `VSFX` to open the file in `VisualizeJS` viewer.
484
- * - `gltf` - Extract file geometry data into `glTF` to open the file in `Three.js` viewer.
484
+ * - `true` - Convert file geometry data to `VSFX` format to open the file in `VisualizeJS` viewer.
485
+ * - `vsfx` - Convert file geometry data to `VSFX` format to open the file in `VisualizeJS` viewer.
486
+ * - `gltf` - Convert file geometry data to `glTF` format to open the file in `Three.js` viewer.
485
487
  *
486
488
  * @param params.properties - Create job to extract file properties.
487
489
  * @param params.waitForDone - Wait for geometry and properties jobs to complete.
@@ -490,7 +492,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
490
492
  * @param params.interval - The time, in milliseconds, the function should delay in between
491
493
  * checking jobs status.
492
494
  * @param params.signal - An
493
- * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController} *
495
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
494
496
  * signal, which can be used to abort waiting as desired.
495
497
  * @param params.onProgress - Upload progress callback.
496
498
  */
@@ -531,7 +533,10 @@ export class Client extends EventEmitter2<ClientEventMap> {
531
533
  }
532
534
 
533
535
  /**
534
- * Delete the drawing or reference file from the server.
536
+ * Deletes the specified file and all its versions from the server.
537
+ *
538
+ * You cannot delete a version file using `deleteFile()`, only the original file. To delete a
539
+ * version file use {@link File.deleteVersion | File.deleteVersion()}.
535
540
  *
536
541
  * @param fileId - File ID.
537
542
  * @returns Returns the raw data of a deleted file.
@@ -541,7 +546,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
541
546
  }
542
547
 
543
548
  /**
544
- * Download the drawing or reference file.
549
+ * Downloads the specified file from the server.
545
550
  *
546
551
  * @param fileId - File ID.
547
552
  * @param onProgress - Download progress callback.
@@ -567,10 +572,9 @@ export class Client extends EventEmitter2<ClientEventMap> {
567
572
  */
568
573
 
569
574
  /**
570
- * Returns a list of jobs created by current user.
575
+ * Returns a list of jobs started by the current logged in user.
571
576
  *
572
- * @param status - Filter the jobs by status. Status can be `waiting`, `inpogress`, `done` or
573
- * `failed`. You can specify multiple statuses on one `string` by separating them with a "|".
577
+ * @param status - Filter the jobs by status. Status can be `waiting`, `inpogress`, `done` or `failed`.
574
578
  * @param limit - The maximum number of jobs that should be returned per request. Used for paging.
575
579
  * @param start - The starting index in the job list. Used for paging.
576
580
  * @param sortByDesc - Allows to specify the descending order of the result. By default, jobs
@@ -608,7 +612,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
608
612
  }
609
613
 
610
614
  /**
611
- * Returns the job information.
615
+ * Returns information about the specified job.
612
616
  *
613
617
  * @param jobId - Job ID.
614
618
  */
@@ -620,15 +624,15 @@ export class Client extends EventEmitter2<ClientEventMap> {
620
624
  }
621
625
 
622
626
  /**
623
- * Create a new job.
627
+ * Runs a new job on the server for the sepecified file.
624
628
  *
625
629
  * @param fileId - File ID.
626
630
  * @param outputFormat - The job type. Can be one of:
627
631
  *
628
- * - `geometry` - Extract file geometry data into `VSFX`.
629
- * - `geometryGltf` - Extract file geometry data into `glTF`.
632
+ * - `geometry` - Convert file geometry data to `VSFX` format suitable for `VisualizeJS` viewer.
633
+ * - `geometryGltf` - Convert file geometry data to `glTF` format suitable for `Three.js` viewer.
630
634
  * - `properties` - Extract file properties.
631
- * - `validation` - Validate the file. Only for `IFC`.
635
+ * - `validation` - Validate the file. Only for `IFC` files.
632
636
  * - `dwg`, `obj`, `gltf`, `glb`, `vsf`, `pdf`, `3dpdf` - Export file to the one of the supported format.
633
637
  * - Other custom job name. Custom job runner must be registered in the job templates table
634
638
  * before creating a job.
@@ -648,8 +652,8 @@ export class Client extends EventEmitter2<ClientEventMap> {
648
652
  }
649
653
 
650
654
  /**
651
- * Remove a job from the server job list. The method does not delete or stop jobs that are
652
- * already being executed.
655
+ * Deletes the specified job from the server job list. Jobs that are in progress or have
656
+ * already been completed cannot be deleted.
653
657
  *
654
658
  * @param jobId - Job ID.
655
659
  * @returns Returns the raw data of a deleted job.
@@ -670,14 +674,13 @@ export class Client extends EventEmitter2<ClientEventMap> {
670
674
  */
671
675
 
672
676
  /**
673
- * Returns a list of assemblies the user has access to.
677
+ * Returns a list of assemblies created by the current logged in user.
674
678
  *
675
679
  * @param start - The starting index in the assembly list. Used for paging.
676
680
  * @param limit - The maximum number of assemblies that should be returned per request. Used
677
681
  * for paging.
678
- * @param name - Filter the assemblies by part of the name.
679
- * @param ids - List of assembly IDs to return. You can specify multiple IDs on one `string`
680
- * by separating them with a "|".
682
+ * @param name - Filter the assemblies by part of the name. Case sensitive.
683
+ * @param ids - List of assembly IDs to return.
681
684
  * @param sortByDesc - Allows to specify the descending order of the result. By default
682
685
  * assemblies are sorted by name in ascending order.
683
686
  * @param sortField - Allows to specify sort field.
@@ -717,7 +720,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
717
720
  }
718
721
 
719
722
  /**
720
- * Get assembly information.
723
+ * Returns information about the specified assembly.
721
724
  *
722
725
  * @param assemblyId - Assembly ID.
723
726
  */
@@ -729,12 +732,21 @@ export class Client extends EventEmitter2<ClientEventMap> {
729
732
  }
730
733
 
731
734
  /**
732
- * Create a new assembly.
735
+ * Creates a new assembly on the server.
733
736
  *
734
737
  * @param files - List of file IDs.
735
738
  * @param name - Assembly name.
736
- * @param params - An object containing upload parameters.
739
+ * @param params - Additional assembly creating parameters.
737
740
  * @param params.waitForDone - Wait for assembly to be created.
741
+ * @param params.timeout - The time, in milliseconds, that the function should wait for the
742
+ * assembly to be created. If the assembly is not created within this time, a TimeoutError
743
+ * exception will be thrown.
744
+ * @param params.interval - The time, in milliseconds, the function should delay in between
745
+ * checking assembly status.
746
+ * @param params.signal - An
747
+ * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
748
+ * signal, which can be used to abort waiting as desired.
749
+ * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
738
750
  */
739
751
  createAssembly(
740
752
  files: string[],
@@ -744,6 +756,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
744
756
  timeout?: number;
745
757
  interval?: number;
746
758
  signal?: AbortSignal;
759
+ onCheckout?: (assembly: Assembly, ready: boolean) => boolean;
747
760
  }
748
761
  ): Promise<Assembly> {
749
762
  const { waitForDone } = params ?? {};
@@ -755,7 +768,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
755
768
  }
756
769
 
757
770
  /**
758
- * Delete the assembly from the server.
771
+ * Deletes the specified assembly from the server.
759
772
  *
760
773
  * @param assemblyId - Assembly ID.
761
774
  * @returns Returns the raw data of a deleted assembly.
@@ -776,13 +789,12 @@ export class Client extends EventEmitter2<ClientEventMap> {
776
789
  */
777
790
 
778
791
  /**
779
- * Returns a list of projects the user has access to.
792
+ * Returns a list of projects that the currently logged in user has created or has access to.
780
793
  *
781
794
  * @param start - The starting index in the project list. Used for paging.
782
795
  * @param limit - The maximum number of projects that should be returned per request. Used for paging.
783
- * @param name - Filter the projects by part of the name.
784
- * @param ids - List of project IDs to return. You can specify multiple IDs on one `string`
785
- * by separating them with a "|".
796
+ * @param name - Filter the projects by part of the name. Case sensitive.
797
+ * @param ids - List of project IDs to return.
786
798
  * @param sortByDesc - Allows to specify the descending order of the result. By default
787
799
  * projects are sorted by name in ascending order.
788
800
  */
@@ -838,7 +850,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
838
850
  }
839
851
 
840
852
  /**
841
- * Returns the project information.
853
+ * Returns information about the specified project.
842
854
  *
843
855
  * @param projectId - Project ID.
844
856
  */
@@ -850,7 +862,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
850
862
  }
851
863
 
852
864
  /**
853
- * Create a new project.
865
+ * Creates a new project on the server.
854
866
  *
855
867
  * @param name - Project name.
856
868
  * @param description - Project description.
@@ -875,7 +887,7 @@ export class Client extends EventEmitter2<ClientEventMap> {
875
887
  }
876
888
 
877
889
  /**
878
- * Delete the project from the server.
890
+ * Deletes the specified project from the server.
879
891
  *
880
892
  * @param projectId - Project ID.
881
893
  * @returns Returns the raw data of a deleted project.
@@ -15,7 +15,7 @@ export interface UploadProgressEvent {
15
15
  data: number;
16
16
 
17
17
  /**
18
- * File object to upload.
18
+ * {@link https://developer.mozilla.org/docs/Web/API/File | Web API File} object to upload.
19
19
  */
20
20
  file: globalThis.File;
21
21
  }