@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.
@@ -23,14 +23,15 @@
23
23
 
24
24
  import { IHttpClient } from "./IHttpClient";
25
25
  import { FetchError } from "./FetchError";
26
- import { IAssociatedFileData, IAssemblyVersionInfo } from "./IAssembly";
26
+ import { IAssociatedFileData, IAssemblyVersionInfo, IModelTransformMatrix } from "./IAssembly";
27
27
  import { IShortUserDescription } from "./IUser";
28
28
  import { Model } from "./Model";
29
29
  import { ClashTest } from "./ClashTest";
30
30
  import { waitFor, userFullName, userInitials } from "./Utils";
31
31
 
32
32
  /**
33
- * The class representing a `assembly` entity.
33
+ * Provides properties and methods for obtaining information about an assembly on the server
34
+ * and managing its data.
34
35
  */
35
36
  export class Assembly {
36
37
  private _data: any;
@@ -39,8 +40,8 @@ export class Assembly {
39
40
  public path: string;
40
41
 
41
42
  /**
42
- * @param data - An object that implements assembly data storage.
43
- * @param httpClient - Http client.
43
+ * @param data - Raw assembly data received from the server.
44
+ * @param httpClient - HTTP client instance used to send REST API requests to the server.
44
45
  */
45
46
  constructor(data: any, httpClient: IHttpClient) {
46
47
  this.path = `/assemblies/${data.id}`;
@@ -130,9 +131,9 @@ export class Assembly {
130
131
  /**
131
132
  * Assembly geometry data type:
132
133
  *
133
- * - `vsfx` - VSFX, assembly can be opened in `VisualizeJS` viewer.
134
+ * - `vsfx` - `VSFX` format, assembly can be opened in `VisualizeJS` viewer.
134
135
  *
135
- * Returns an empty string if geometry data has not yet been extracted.
136
+ * Returns an empty string if the geometry data is not yet ready.
136
137
  */
137
138
  get geometryType(): string {
138
139
  return this.status === "done" ? "vsfx" : "";
@@ -227,7 +228,7 @@ export class Assembly {
227
228
  }
228
229
 
229
230
  /**
230
- * Refresh assembly data.
231
+ * Reloads assembly data from the server.
231
232
  */
232
233
  async checkout(): Promise<this> {
233
234
  const response = await this.internalGet("");
@@ -247,7 +248,7 @@ export class Assembly {
247
248
  }
248
249
 
249
250
  /**
250
- * Delete the assembly from the server.
251
+ * Deletes an assembly from the server.
251
252
  *
252
253
  * @returns Returns the raw data of a deleted assembly.
253
254
  */
@@ -256,8 +257,8 @@ export class Assembly {
256
257
  }
257
258
 
258
259
  /**
259
- * Save assembly data changes to the server. Call this method to update assembly data on the
260
- * server after any changes.
260
+ * Saves assembly properties changes to the server. Call this method to update assembly data
261
+ * on the server after any property changes.
261
262
  */
262
263
  save(): Promise<this> {
263
264
  return this.update(this.data);
@@ -284,39 +285,22 @@ export class Assembly {
284
285
  .then((array) => array.map((data: any) => new Model(data, this)));
285
286
  }
286
287
 
287
- /**
288
- * Transformation matrix.
289
- *
290
- * @typedef {any} Transform
291
- * @property {any} translate - Translation part, move along the X, Y, Z axes.
292
- * @property {number} translate.x - The value for substruct for X axes.
293
- * @property {number} translate.y - The value for substruct for Y axes.
294
- * @property {number} translate.z - The value for substruct for Z axes.
295
- * @property {any} rotation - Rotation part, rotate by the specified angle, around the
296
- * specified vector.
297
- * @property {number} rotation.x - X coordinate of the rotation vector.
298
- * @property {number} rotation.y - Y coordinate of the rotation vector.
299
- * @property {number} rotation.z - Z coordinate of the rotation vector.
300
- * @property {number} rotation.angle - The angle of rotation.
301
- * @property {number} scale - Scaling part, scale with multiplier, from center of extends.
302
- */
303
-
304
288
  /**
305
289
  * Returns a model transformation.
306
290
  *
307
- * @param handle - Model handle.
291
+ * @param handle - Model original handle.
308
292
  */
309
- getModelTransformMatrix(handle: string): any {
293
+ getModelTransformMatrix(handle: string): IModelTransformMatrix {
310
294
  return this.data.transform[handle];
311
295
  }
312
296
 
313
297
  /**
314
- * Set or delete a model transformation.
298
+ * Sets or removes a model transformation.
315
299
  *
316
- * @param handle - Model handle.
317
- * @param transform - Transformation matrix. To delete transformation provide this to `undefined`.
300
+ * @param handle - Model original handle.
301
+ * @param transform - Transformation matrix. Specify `undefined` to remove transformation.
318
302
  */
319
- setModelTransformMatrix(handle: string, transform: any): Promise<this> {
303
+ setModelTransformMatrix(handle: string, transform: IModelTransformMatrix): Promise<this> {
320
304
  const obj = { ...this.data.transform };
321
305
  obj[handle] = transform;
322
306
  return this.update({ transform: obj });
@@ -325,8 +309,8 @@ export class Assembly {
325
309
  /**
326
310
  * Returns the properties for an objects in the assembly.
327
311
  *
328
- * @param handles - Object original handle or handles array. Leave this parameter undefined
329
- * to get properties for all objects in the assembly.
312
+ * @param handles - Object original handle or handles array. Specify `undefined` to get
313
+ * properties for all objects in the assembly.
330
314
  * @returns {Promise<any>}
331
315
  */
332
316
  getProperties(handles?: string | string[]): Promise<any[]> {
@@ -364,7 +348,7 @@ export class Assembly {
364
348
  }
365
349
 
366
350
  /**
367
- * Returns the cda.json for an assembly.
351
+ * Returns the CDA tree for an assembly.
368
352
  */
369
353
  getCdaTree(): Promise<any[]> {
370
354
  return this.internalGet(`/properties/tree`).then((response) => response.json());
@@ -380,7 +364,7 @@ export class Assembly {
380
364
  }
381
365
 
382
366
  /**
383
- * Add new assembly viewpoint. To create a viewpoint use `Viewer.createViewpoint()`.
367
+ * Adds a new viewpoint to the assembly. To create a viewpoint use `Viewer.createViewpoint()`.
384
368
  *
385
369
  * @param viewpoint - Viewpoint.
386
370
  */
@@ -389,7 +373,7 @@ export class Assembly {
389
373
  }
390
374
 
391
375
  /**
392
- * Delete assembly viewpoint.
376
+ * Deletes the specified assembly viewpoint.
393
377
  *
394
378
  * @param guid - Viewpoint GUID.
395
379
  * @returns Returns the raw data of a deleted viewpoint.
@@ -419,7 +403,7 @@ export class Assembly {
419
403
  }
420
404
 
421
405
  /**
422
- * Download assembly resource file. Resource files are files that contain model scene
406
+ * Downloads an assembly resource file. Resource files are files that contain model scene
423
407
  * descriptions, or geometry data.
424
408
  *
425
409
  * @param dataId - Resource file name.
@@ -440,7 +424,7 @@ export class Assembly {
440
424
  }
441
425
 
442
426
  /**
443
- * Download a part of assembly resource file. Resource files are files that contain model
427
+ * Downloads a part of assembly resource file. Resource files are files that contain model
444
428
  * scene descriptions, or geometry data.
445
429
  *
446
430
  * @param dataId - Resource file name.
@@ -500,7 +484,7 @@ export class Assembly {
500
484
  }
501
485
 
502
486
  /**
503
- * Wait for assembly to be created. Assembly is created when it changes to `done` or `failed` status.
487
+ * Waits for assembly to be created. Assembly is created when it changes to `done` or `failed` status.
504
488
  *
505
489
  * @param params - An object containing waiting parameters.
506
490
  * @param params.timeout - The time, in milliseconds that the function should wait assembly.
@@ -531,15 +515,13 @@ export class Assembly {
531
515
  /**
532
516
  * Returns a list of assembly clash tests.
533
517
  *
534
- * @param {number} start - The starting index in the test list. Used for paging.
535
- * @param {number} limit - The maximum number of tests that should be returned per request.
536
- * Used for paging.
537
- * @param {string} name - Filter the tests by part of the name.
538
- * @param {string | string[]} ids - List of tests IDs to return. You can specify multiple IDs
539
- * on one `string` by separating them with a "|".
540
- * @param {bool} sortByDesc - Allows to specify the descending order of the result. By
541
- * default tests are sorted by name in ascending order.
542
- * @param {string} sortField - Allows to specify sort field.
518
+ * @param start - The starting index in the test list. Used for paging.
519
+ * @param limit - The maximum number of tests that should be returned per request. Used for paging.
520
+ * @param name - Filter the tests by part of the name. Case sensitive.
521
+ * @param ids - List of tests IDs to return.
522
+ * @param sortByDesc - Allows to specify the descending order of the result. By default tests
523
+ * are sorted by name in ascending order.
524
+ * @param sortField - Allows to specify sort field.
543
525
  */
544
526
  getClashTests(
545
527
  start?: number,
@@ -575,7 +557,7 @@ export class Assembly {
575
557
  }
576
558
 
577
559
  /**
578
- * Returns the assembly clash test information.
560
+ * Returns information about the specified assembly clash test.
579
561
  *
580
562
  * @param testId - Test ID.
581
563
  */
@@ -586,20 +568,39 @@ export class Assembly {
586
568
  }
587
569
 
588
570
  /**
589
- * Create assembly clash test. Assembly must be in a `done` state, otherwise the test will fail.
571
+ * Creates an assembly clash test. Assembly must be in a `done` state, otherwise the test will fail.
590
572
  *
591
573
  * @param name - Test name.
592
- * @param selectionTypeA - The type of first selection set for clash detection. Can be `all`,
593
- * `handles`, `models` or `searchquery`.
594
- * @param selectionTypeB - The type of second selection set for clash detection. Can be
595
- * `all`, `handles`, `models` or `searchquery`.
596
- * @param selectionSetA - First selection set for clash detection.
597
- * @param selectionSetB - Second selection set for clash detection.
574
+ * @param selectionTypeA - The type of first selection set for clash detection. Can be one of:
575
+ *
576
+ * - `all` - All file/assembly objects.
577
+ * - `handle` - Objects with original handles specified in the `selectionSetA`.
578
+ * - `models` - All objects of the models with original handles specified in the `selectionSetA`.
579
+ * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetA`.
580
+ *
581
+ * @param selectionTypeB - The type of second selection set for clash detection. Can be one of:
582
+ *
583
+ * - `all` - All file/assembly objects.
584
+ * - `handle` - Objects with original handles specified in the `selectionSetB`.
585
+ * - `models` - All objects of the models with original handles specified in the `selectionSetB`.
586
+ * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetB`.
587
+ *
588
+ * @param selectionSetA - First selection set for clash detection. Objects from
589
+ * `selectionSetA` will be tested against each others by objects from the `selectionSetB`
590
+ * during the test.
591
+ * @param selectionSetB - Second selection set for clash detection. Objects from
592
+ * `selectionSetB` will be tested against each others by objects from the `selectionSetA`
593
+ * during the test.
598
594
  * @param params - An object containing test parameters.
599
- * @param params.tolerance - The distance of separation between entities at which test begins
595
+ * @param params.tolerance - The distance of separation between objects at which test begins
600
596
  * detecting clashes.
601
- * @param params.clearance - The type of the clashes that the test detects: `true` for
602
- * `Сlearance clash` or `false` for `Hard clash`.
597
+ * @param params.clearance - The type of the clashes that the test detects:
598
+ *
599
+ * - `true` - Сlearance clash. A clash in which the object A may or may not intersect with
600
+ * object B, but comes within a distance of less than the `tolerance`.
601
+ * - `false` - Hard clash. A clash in which the object A intersects with object B by a distance
602
+ * of more than the `tolerance`.
603
+ *
603
604
  * @param params.waitForDone - Wait for test to complete.
604
605
  * @param params.timeout - The time, in milliseconds that the function should wait test. If
605
606
  * test is not complete during this time, the `TimeoutError` exception will be thrown.
@@ -643,7 +644,7 @@ export class Assembly {
643
644
  }
644
645
 
645
646
  /**
646
- * Delete assembly clash test.
647
+ * Deletes the specified assembly clash test.
647
648
  *
648
649
  * @param testId - Test ID.
649
650
  * @returns Returns the raw data of a deleted test.
@@ -26,7 +26,7 @@ import { IShortUserDescription } from "./IUser";
26
26
  import { waitFor, userFullName, userInitials } from "./Utils";
27
27
 
28
28
  /**
29
- * The base class provides information about the file/assembly clash detection test and test results.
29
+ * Provides properties and methods for obtaining information about a file/assembly clash detection test.
30
30
  */
31
31
  export class ClashTest {
32
32
  private _data: any;
@@ -34,9 +34,9 @@ export class ClashTest {
34
34
  public httpClient: IHttpClient;
35
35
 
36
36
  /**
37
- * @param data - Raw test data.
38
- * @param basePath - Clash tests API base path for the owner file/assembly.
39
- * @param httpClient - Http client.
37
+ * @param data - Raw test data received from the server.
38
+ * @param basePath - The clash test API base path of the file/assembly that owns the test.
39
+ * @param httpClient - HTTP client instance used to send REST API requests to the server.
40
40
  */
41
41
  constructor(data: any, basePath: string, httpClient: IHttpClient) {
42
42
  this.httpClient = httpClient;
@@ -59,10 +59,10 @@ export class ClashTest {
59
59
  /**
60
60
  * The type of the clashes that the test detects:
61
61
  *
62
- * - `Сlearance clash` (true) - a clash in which the entity A may or may not intersect with
63
- * entity B, but comes within a distance of less than the `tolerance`.
64
- * - `Hard clash` (false) - a clash in which the entity A intersects with entity B by a
65
- * distance of more than the `tolerance`.
62
+ * - `true` - Сlearance clash. A clash in which the object A may or may not intersect with
63
+ * object B, but comes within a distance of less than the {@link tolerance}.
64
+ * - `false` - Hard clash. A clash in which the object A intersects with object B by a distance
65
+ * of more than the {@link tolerance}.
66
66
  *
67
67
  * @readonly
68
68
  */
@@ -144,8 +144,8 @@ export class ClashTest {
144
144
  }
145
145
 
146
146
  /**
147
- * First selection set for clash detection. Entities from `selectionSetA` will be tested
148
- * against each others by entities from the `selectionSetB` during the test.
147
+ * First selection set for clash detection. Objects from `selectionSetA` will be tested
148
+ * against each others by objects from the `selectionSetB` during the test.
149
149
  *
150
150
  * @readonly
151
151
  */
@@ -156,10 +156,10 @@ export class ClashTest {
156
156
  /**
157
157
  * The type of first selection set for clash detection. Can be one of:
158
158
  *
159
- * - `all` - All file/assembly entities.
160
- * - `handle` - Entities with handles specified in the `selectionSetA`.
161
- * - `models` - Entities of file/assembly models specified in `selectionSetA`.
162
- * - `searchquery` - Entities retrieved by the search queries specified in `selectionSetA`.
159
+ * - `all` - All file/assembly objects.
160
+ * - `handle` - Objects with original handles specified in the `selectionSetA`.
161
+ * - `models` - All objects of the models with original handles specified in the `selectionSetA`.
162
+ * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetA`.
163
163
  *
164
164
  * @readonly
165
165
  */
@@ -168,8 +168,8 @@ export class ClashTest {
168
168
  }
169
169
 
170
170
  /**
171
- * Second selection set for clash detection. Entities from `selectionSetB` will be tested
172
- * against each others by entities from the `selectionSetA` during the test.
171
+ * Second selection set for clash detection. Objects from `selectionSetB` will be tested
172
+ * against each others by objects from the `selectionSetA` during the test.
173
173
  *
174
174
  * @readonly
175
175
  */
@@ -180,10 +180,10 @@ export class ClashTest {
180
180
  /**
181
181
  * The type of second selection set for clash detection. Can be one of:
182
182
  *
183
- * - `all` - All file/assembly entities.
184
- * - `handle` - Entities with handles specified in the `selectionSetB`.
185
- * - `models` - Entities of file/assembly models specified in `selectionSetB`.
186
- * - `searchquery` - Entities retrieved by the search queries specified in `selectionSetB`.
183
+ * - `all` - All file/assembly objects.
184
+ * - `handle` - Objects with original handles specified in the `selectionSetB`.
185
+ * - `models` - All objects of the models with original handles specified in the `selectionSetB`.
186
+ * - `searchquery` - Objects retrieved by the search queries specified in `selectionSetB`.
187
187
  *
188
188
  * @readonly
189
189
  */
@@ -201,7 +201,7 @@ export class ClashTest {
201
201
  }
202
202
 
203
203
  /**
204
- * The distance of separation between entities at which test begins detecting clashes.
204
+ * The distance of separation between objects at which test begins detecting clashes.
205
205
  *
206
206
  * @readonly
207
207
  */
@@ -210,7 +210,7 @@ export class ClashTest {
210
210
  }
211
211
 
212
212
  /**
213
- * Refresh test data.
213
+ * Reloads test data from the server.
214
214
  */
215
215
  async checkout(): Promise<this> {
216
216
  const response = await this.internalGet("");
@@ -219,7 +219,7 @@ export class ClashTest {
219
219
  }
220
220
 
221
221
  /**
222
- * Update test data on the server.
222
+ * Updates test data on the server.
223
223
  *
224
224
  * @param data - Raw test data.
225
225
  */
@@ -230,7 +230,7 @@ export class ClashTest {
230
230
  }
231
231
 
232
232
  /**
233
- * Remove a test from a file.
233
+ * Deletes a test and its results report from the server.
234
234
  *
235
235
  * @returns Returns the raw data of a deleted test.
236
236
  */
@@ -239,15 +239,15 @@ export class ClashTest {
239
239
  }
240
240
 
241
241
  /**
242
- * Save test data changes to the server. Call this method to update test data on the server
243
- * after any changes.
242
+ * Saves test properties changes to the server. Call this method to update test data on the
243
+ * server after any property changes.
244
244
  */
245
245
  save(): Promise<this> {
246
246
  return this.update(this.data);
247
247
  }
248
248
 
249
249
  /**
250
- * Wait for test to complete. Test is done when it changes to `done` or `failed` status.
250
+ * Waits for test to complete. Test is done when it changes to `done` or `failed` status.
251
251
  *
252
252
  * @param params - An object containing waiting parameters.
253
253
  * @param params.timeout - The time, in milliseconds that the function should wait test. If
@@ -257,9 +257,20 @@ export class ClashTest {
257
257
  * @param params.signal - An
258
258
  * {@link https://developer.mozilla.org/docs/Web/API/AbortController | AbortController}
259
259
  * signal, which can be used to abort waiting as desired.
260
+ * @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
260
261
  */
261
- waitForDone(params?: { timeout?: number; interval?: number; signal?: AbortSignal }): Promise<this> {
262
- const checkDone = () => this.checkout().then((test) => ["done", "failed"].includes(test.status));
262
+ waitForDone(params?: {
263
+ timeout?: number;
264
+ interval?: number;
265
+ signal?: AbortSignal;
266
+ onCheckout?: (test: ClashTest, ready: boolean) => boolean;
267
+ }): Promise<this> {
268
+ const checkDone = () =>
269
+ this.checkout().then((test) => {
270
+ const ready = ["done", "failed"].includes(test.status);
271
+ const cancel = params?.onCheckout?.(test, ready);
272
+ return cancel || ready;
273
+ });
263
274
  return waitFor(checkDone, params).then(() => this);
264
275
  }
265
276