@inweb/client 25.2.2 → 25.2.8
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/LICENSE +20 -20
- package/README.md +70 -70
- package/dist/client.js +12369 -11952
- package/dist/client.js.map +1 -1
- package/dist/client.min.js +1 -1
- package/dist/client.module.js +714 -235
- package/dist/client.module.js.map +1 -1
- package/lib/Api/Assembly.d.ts +338 -338
- package/lib/Api/ClashTest.d.ts +175 -175
- package/lib/Api/Client.d.ts +451 -451
- package/lib/Api/ClientEvents.d.ts +28 -28
- package/lib/Api/File.d.ts +567 -567
- package/lib/Api/HttpClient.d.ts +12 -12
- package/lib/Api/IAssembly.d.ts +13 -13
- package/lib/Api/IFile.d.ts +45 -45
- package/lib/Api/IHttpClient.d.ts +10 -10
- package/lib/Api/IUser.d.ts +10 -10
- package/lib/Api/Job.d.ts +141 -141
- package/lib/Api/Member.d.ts +84 -84
- package/lib/Api/Model.d.ts +146 -146
- package/lib/Api/Permission.d.ts +92 -92
- package/lib/Api/Project.d.ts +246 -246
- package/lib/Api/Role.d.ts +81 -81
- package/lib/Api/User.d.ts +196 -196
- package/lib/Api/impl/FetchError.d.ts +17 -17
- package/lib/Api/impl/Utils.d.ts +32 -32
- package/lib/Api/impl/http.d.ts +66 -66
- package/lib/ConvetMath.d.ts +28 -28
- package/lib/Viewer/CanvasEvents.d.ts +1 -1
- package/lib/Viewer/Commands/ApplyModelTransform.d.ts +1 -1
- package/lib/Viewer/Commands/ClearMarkup.d.ts +1 -1
- package/lib/Viewer/Commands/ClearSlices.d.ts +1 -1
- package/lib/Viewer/Commands/CreatePreview.d.ts +1 -1
- package/lib/Viewer/Commands/Explode.d.ts +1 -1
- package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +1 -1
- package/lib/Viewer/Commands/GetModels.d.ts +1 -1
- package/lib/Viewer/Commands/GetSelected.d.ts +1 -1
- package/lib/Viewer/Commands/HideSelected.d.ts +1 -1
- package/lib/Viewer/Commands/IsolateSelected.d.ts +1 -1
- package/lib/Viewer/Commands/RegenerateAll.d.ts +1 -1
- package/lib/Viewer/Commands/ResetView.d.ts +1 -1
- package/lib/Viewer/Commands/SelectModel.d.ts +1 -1
- package/lib/Viewer/Commands/SetActiveDragger.d.ts +1 -1
- package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +1 -1
- package/lib/Viewer/Commands/SetMarkupColor.d.ts +1 -1
- package/lib/Viewer/Commands/SetSelected.d.ts +1 -1
- package/lib/Viewer/Commands/ShowAll.d.ts +1 -1
- package/lib/Viewer/Commands/Unselect.d.ts +1 -1
- package/lib/Viewer/Commands/ZoomToExtents.d.ts +1 -1
- package/lib/Viewer/Commands/ZoomToObjects.d.ts +1 -1
- package/lib/Viewer/Commands/ZoomToSelected.d.ts +1 -1
- package/lib/Viewer/Commands.d.ts +2 -2
- package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +21 -21
- package/lib/Viewer/Draggers/Actions/PanAction.d.ts +17 -17
- package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +7 -7
- package/lib/Viewer/Draggers/Common/Geometry.d.ts +114 -114
- package/lib/Viewer/Draggers/Common/GestureManager.d.ts +40 -40
- package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +53 -53
- package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +29 -29
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +30 -30
- package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +19 -19
- package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +23 -23
- package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +26 -26
- package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +7 -7
- package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +7 -7
- package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +7 -7
- package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +14 -14
- package/lib/Viewer/Draggers/OdPanDragger.d.ts +11 -11
- package/lib/Viewer/Draggers/OdZoomDragger.d.ts +11 -11
- package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +10 -10
- package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +18 -18
- package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +13 -13
- package/lib/Viewer/Draggers/OdaLineDragger.d.ts +14 -14
- package/lib/Viewer/Draggers/OdaTextDragger.d.ts +15 -15
- package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +29 -29
- package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +18 -18
- package/lib/Viewer/EventEmitter2.d.ts +53 -53
- package/lib/Viewer/ICommands.d.ts +24 -24
- package/lib/Viewer/IEventEmitter2.d.ts +12 -12
- package/lib/Viewer/IViewer.d.ts +28 -26
- package/lib/Viewer/Loaders/BaseLoader.d.ts +10 -10
- package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -9
- package/lib/Viewer/Loaders/TCSLoader.d.ts +4 -4
- package/lib/Viewer/Loaders/UpdaterController.d.ts +14 -14
- package/lib/Viewer/Loaders/VsfXLoader.d.ts +4 -4
- package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +4 -4
- package/lib/Viewer/Loaders/VsfXStreamingLoader.d.ts +5 -0
- package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +21 -11
- package/lib/Viewer/Markup/Api/IMarkupCloud.d.ts +15 -0
- package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +4 -4
- package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +14 -14
- package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +14 -14
- package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +18 -10
- package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +11 -11
- package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +14 -14
- package/lib/Viewer/Markup/Api/IMarkupText.d.ts +12 -12
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +46 -31
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaCloud.d.ts +36 -0
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -39
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -35
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +35 -31
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -37
- package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -36
- package/lib/Viewer/Markup/IMarkup.d.ts +38 -37
- package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +71 -62
- package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +18 -18
- package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -32
- package/lib/Viewer/Markup/MarkupFactory.d.ts +6 -6
- package/lib/Viewer/Options.d.ts +238 -227
- package/lib/Viewer/OptionsEvents.d.ts +25 -25
- package/lib/Viewer/Viewer.d.ts +358 -352
- package/lib/Viewer/ViewerCommands.d.ts +22 -22
- package/lib/Viewer/ViewerEvents.d.ts +600 -600
- package/lib/Viewer/utils.d.ts +3 -3
- package/lib/index.d.ts +23 -23
- package/package.json +38 -32
- package/src/Api/Assembly.ts +678 -678
- package/src/Api/ClashTest.ts +290 -290
- package/src/Api/Client.ts +816 -816
- package/src/Api/ClientEvents.ts +31 -31
- package/src/Api/File.ts +962 -962
- package/src/Api/HttpClient.ts +73 -73
- package/src/Api/IAssembly.ts +37 -37
- package/src/Api/IFile.ts +74 -74
- package/src/Api/IHttpClient.ts +50 -50
- package/src/Api/IUser.ts +33 -33
- package/src/Api/Job.ts +253 -253
- package/src/Api/Member.ts +161 -161
- package/src/Api/Model.ts +259 -259
- package/src/Api/Permission.ts +173 -173
- package/src/Api/Project.ts +479 -479
- package/src/Api/Role.ts +158 -158
- package/src/Api/User.ts +357 -357
- package/src/Api/impl/FetchError.ts +48 -48
- package/src/Api/impl/Utils.ts +367 -367
- package/src/Api/impl/http.ts +92 -92
- package/src/ConvetMath.ts +372 -372
- package/src/Viewer/CanvasEvents.ts +41 -41
- package/src/Viewer/Commands/ApplyModelTransform.ts +70 -70
- package/src/Viewer/Commands/ClearMarkup.ts +28 -28
- package/src/Viewer/Commands/ClearSlices.ts +27 -27
- package/src/Viewer/Commands/CreatePreview.ts +33 -33
- package/src/Viewer/Commands/Explode.ts +38 -38
- package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -36
- package/src/Viewer/Commands/GetModels.ts +43 -43
- package/src/Viewer/Commands/GetSelected.ts +58 -58
- package/src/Viewer/Commands/HideSelected.ts +37 -37
- package/src/Viewer/Commands/IsolateSelected.ts +37 -37
- package/src/Viewer/Commands/RegenerateAll.ts +37 -37
- package/src/Viewer/Commands/ResetView.ts +43 -43
- package/src/Viewer/Commands/SelectModel.ts +52 -52
- package/src/Viewer/Commands/SetActiveDragger.ts +29 -29
- package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -50
- package/src/Viewer/Commands/SetMarkupColor.ts +29 -29
- package/src/Viewer/Commands/SetSelected.ts +47 -47
- package/src/Viewer/Commands/ShowAll.ts +37 -37
- package/src/Viewer/Commands/Unselect.ts +37 -37
- package/src/Viewer/Commands/ZoomToExtents.ts +43 -43
- package/src/Viewer/Commands/ZoomToObjects.ts +47 -47
- package/src/Viewer/Commands/ZoomToSelected.ts +39 -39
- package/src/Viewer/Commands.ts +81 -81
- package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -250
- package/src/Viewer/Draggers/Actions/PanAction.ts +102 -102
- package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -45
- package/src/Viewer/Draggers/Common/Geometry.ts +152 -152
- package/src/Viewer/Draggers/Common/GestureManager.ts +263 -263
- package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -270
- package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -146
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -248
- package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -182
- package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -166
- package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -182
- package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -53
- package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -53
- package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -53
- package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -70
- package/src/Viewer/Draggers/OdPanDragger.ts +62 -62
- package/src/Viewer/Draggers/OdZoomDragger.ts +59 -59
- package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -103
- package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -123
- package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -75
- package/src/Viewer/Draggers/OdaLineDragger.ts +80 -80
- package/src/Viewer/Draggers/OdaTextDragger.ts +118 -118
- package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -278
- package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -184
- package/src/Viewer/EventEmitter2.ts +116 -116
- package/src/Viewer/ICommands.ts +53 -53
- package/src/Viewer/IEventEmitter2.ts +36 -36
- package/src/Viewer/IViewer.ts +58 -55
- package/src/Viewer/Loaders/BaseLoader.ts +40 -40
- package/src/Viewer/Loaders/LoaderFactory.ts +47 -44
- package/src/Viewer/Loaders/TCSLoader.ts +82 -82
- package/src/Viewer/Loaders/UpdaterController.ts +36 -36
- package/src/Viewer/Loaders/VsfXLoader.ts +65 -87
- package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -208
- package/src/Viewer/Loaders/VsfXStreamingLoader.ts +87 -0
- package/src/Viewer/Markup/Api/IMarkupArrow.ts +12 -15
- package/src/Viewer/Markup/Api/IMarkupCloud.ts +15 -0
- package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -4
- package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -15
- package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -15
- package/src/Viewer/Markup/Api/IMarkupLine.ts +20 -10
- package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -15
- package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -15
- package/src/Viewer/Markup/Api/IMarkupText.ts +12 -12
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +117 -119
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaCloud.ts +208 -0
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +118 -113
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +123 -121
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +130 -99
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +119 -113
- package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +110 -104
- package/src/Viewer/Markup/IMarkup.ts +40 -39
- package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +1144 -872
- package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -39
- package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +231 -273
- package/src/Viewer/Markup/MarkupFactory.ts +32 -32
- package/src/Viewer/Options.ts +522 -502
- package/src/Viewer/OptionsEvents.ts +28 -28
- package/src/Viewer/Viewer.ts +1191 -1109
- package/src/Viewer/ViewerCommands.ts +45 -45
- package/src/Viewer/ViewerEvents.ts +700 -700
- package/src/Viewer/utils.ts +74 -74
- package/src/index.ts +48 -48
package/src/Api/Assembly.ts
CHANGED
|
@@ -1,678 +1,678 @@
|
|
|
1
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
-
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
-
// All rights reserved.
|
|
4
|
-
//
|
|
5
|
-
// This software and its documentation and related materials are owned by
|
|
6
|
-
// the Alliance. The software may only be incorporated into application
|
|
7
|
-
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
-
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
-
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
-
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
-
// protected by copyright law and international treaty provisions. Application
|
|
12
|
-
// programs incorporating this software must include the following statement
|
|
13
|
-
// with their copyright notices:
|
|
14
|
-
//
|
|
15
|
-
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
-
// license agreement with Open Design Alliance.
|
|
17
|
-
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
-
// All rights reserved.
|
|
19
|
-
//
|
|
20
|
-
// By use of this software, its documentation or related materials, you
|
|
21
|
-
// acknowledge and accept the above terms.
|
|
22
|
-
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
-
|
|
24
|
-
import { IHttpClient } from "./IHttpClient";
|
|
25
|
-
import { IAssociatedFileData, IAssemblyVersionInfo } from "./IAssembly";
|
|
26
|
-
import { IShortUserDescription } from "./IUser";
|
|
27
|
-
import { Model } from "./Model";
|
|
28
|
-
import { ClashTest } from "./ClashTest";
|
|
29
|
-
import { json, downloadProgress, downloadPartOfFile, waitFor, userFullName, userInitials } from "./impl/Utils";
|
|
30
|
-
import { FetchError } from "./impl/FetchError";
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* The class representing a `assembly` entity.
|
|
34
|
-
*/
|
|
35
|
-
export class Assembly {
|
|
36
|
-
private _data: any;
|
|
37
|
-
private _useVersion: number | undefined;
|
|
38
|
-
public httpClient: IHttpClient;
|
|
39
|
-
public path: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param data - An object that implements assembly data storage.
|
|
43
|
-
* @param httpClient - Http client.
|
|
44
|
-
*/
|
|
45
|
-
constructor(data: any, httpClient: IHttpClient) {
|
|
46
|
-
this.path = `/assemblies/${data.id}`;
|
|
47
|
-
this.httpClient = httpClient;
|
|
48
|
-
this.data = data;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
public appendVersionParam(relativePath: string): string {
|
|
52
|
-
if (this._useVersion === undefined) return relativePath;
|
|
53
|
-
|
|
54
|
-
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
55
|
-
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
protected internalGet(relativePath: string, signal?: AbortSignal) {
|
|
59
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
60
|
-
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
protected internalPost(
|
|
64
|
-
relativePath: string,
|
|
65
|
-
body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
|
|
66
|
-
) {
|
|
67
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
68
|
-
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
protected internalPut(
|
|
72
|
-
relativePath: string,
|
|
73
|
-
body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
|
|
74
|
-
) {
|
|
75
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
76
|
-
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected internalDelete(relativePath: string) {
|
|
80
|
-
relativePath = this.appendVersionParam(relativePath);
|
|
81
|
-
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
async partialDownloadResource(
|
|
85
|
-
dataId: string,
|
|
86
|
-
onProgress?: (progress: number, downloaded: Uint8Array) => void,
|
|
87
|
-
signal?: AbortSignal
|
|
88
|
-
): Promise<void> {
|
|
89
|
-
let pathname = `${this.path}/downloads/${dataId}`;
|
|
90
|
-
pathname = this.appendVersionParam(pathname);
|
|
91
|
-
|
|
92
|
-
// TODO: replace with $get to handle fetch errors
|
|
93
|
-
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
94
|
-
headers: this.httpClient.headers,
|
|
95
|
-
signal,
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// TODO: use ReadableStream pipeTo()
|
|
99
|
-
const contentLength = response.headers.get("Content-Length") ?? "";
|
|
100
|
-
const total = parseInt(contentLength, 10);
|
|
101
|
-
const reader = response.body.getReader();
|
|
102
|
-
let loaded = 0;
|
|
103
|
-
while (true) {
|
|
104
|
-
const { done, value } = await reader.read();
|
|
105
|
-
if (done) break;
|
|
106
|
-
loaded += value.byteLength;
|
|
107
|
-
if (typeof onProgress === "function") onProgress(loaded / total, value);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
downloadFileRange(
|
|
112
|
-
requestId: number,
|
|
113
|
-
records: any | null,
|
|
114
|
-
dataId: string,
|
|
115
|
-
onProgress?: (progress: number, downloaded: Uint8Array, requestId: number) => void,
|
|
116
|
-
signal?: AbortSignal
|
|
117
|
-
): Promise<void> {
|
|
118
|
-
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
119
|
-
pathname = this.appendVersionParam(pathname);
|
|
120
|
-
return downloadPartOfFile(
|
|
121
|
-
requestId,
|
|
122
|
-
records,
|
|
123
|
-
`${this.httpClient.serverUrl}${pathname}`,
|
|
124
|
-
this.httpClient.headers,
|
|
125
|
-
onProgress,
|
|
126
|
-
signal
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Reserved for future use
|
|
131
|
-
|
|
132
|
-
get activeVersion(): number {
|
|
133
|
-
return this.data.activeVersion;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* List of unique files from which the assembly was created.
|
|
138
|
-
*
|
|
139
|
-
* @readonly
|
|
140
|
-
*/
|
|
141
|
-
get associatedFiles(): IAssociatedFileData[] {
|
|
142
|
-
return this.data.associatedFiles;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Assembly creation time (UTC) in the format specified in <a
|
|
147
|
-
* href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
|
|
148
|
-
*
|
|
149
|
-
* @readonly
|
|
150
|
-
*/
|
|
151
|
-
get created(): string {
|
|
152
|
-
return this.data.created;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Raw assembly data received from the server.
|
|
157
|
-
*
|
|
158
|
-
* @readonly
|
|
159
|
-
*/
|
|
160
|
-
get data(): any {
|
|
161
|
-
return this._data;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
private set data(value: any) {
|
|
165
|
-
this._data = value;
|
|
166
|
-
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
167
|
-
this._data.owner.fullName = userFullName(this._data.owner);
|
|
168
|
-
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
169
|
-
// associatedFiles since 23.12
|
|
170
|
-
this._data.associatedFiles ??= [];
|
|
171
|
-
this._data.associatedFiles.forEach((file) => (file.link = `${this.httpClient.serverUrl}/files/${file.fileId}`));
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* List of file IDs from which the assembly was created.
|
|
176
|
-
*
|
|
177
|
-
* @readonly
|
|
178
|
-
*/
|
|
179
|
-
get files(): string[] {
|
|
180
|
-
return this.data.files;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Assembly geometry data type:
|
|
185
|
-
*
|
|
186
|
-
* - `vsfx` - VSFX, assembly can be opened in `VisualizeJS` viewer.
|
|
187
|
-
*
|
|
188
|
-
* Returns an empty string if geometry data has not yet been extracted.
|
|
189
|
-
*/
|
|
190
|
-
get geometryType(): string {
|
|
191
|
-
return this.status === "done" ? "vsfx" : "";
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Unique assembly ID.
|
|
196
|
-
*
|
|
197
|
-
* @readonly
|
|
198
|
-
*/
|
|
199
|
-
get id(): string {
|
|
200
|
-
return this.data.id;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Assembly name.
|
|
205
|
-
*/
|
|
206
|
-
get name(): string {
|
|
207
|
-
return this.data.name;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
set name(value: string) {
|
|
211
|
-
this.data.name = value;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// Reserved for future use
|
|
215
|
-
|
|
216
|
-
get originalAssemblyId(): string {
|
|
217
|
-
return this.data.originalAssemblyId;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* Assembly owner information.
|
|
222
|
-
*
|
|
223
|
-
* @property {string} userId - User ID.
|
|
224
|
-
* @property {string} userName - User name.
|
|
225
|
-
* @property {string} name - First name.
|
|
226
|
-
* @property {string} lastName - Last name.
|
|
227
|
-
* @property {string} fullName - Full name.
|
|
228
|
-
* @property {string} initials - Initials.
|
|
229
|
-
* @property {string} email - User email.
|
|
230
|
-
* @property {string} avatarUrl - User avatar image URL.
|
|
231
|
-
* @readonly
|
|
232
|
-
*/
|
|
233
|
-
get owner(): IShortUserDescription {
|
|
234
|
-
return this.data.owner;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Reserved for future use
|
|
238
|
-
|
|
239
|
-
get previewUrl(): string {
|
|
240
|
-
return this.data.previewUrl ?? "";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* List of assembly related job IDs.
|
|
245
|
-
*
|
|
246
|
-
* @readonly
|
|
247
|
-
*/
|
|
248
|
-
get relatedJobs(): string[] {
|
|
249
|
-
return this.data.relatedJobs;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* Assembly geometry data and properties status. Can be `waiting`, `inprogress`, `done` or `failed`.
|
|
254
|
-
*
|
|
255
|
-
* An assemblies without geometry data cannot be opened in viewer.
|
|
256
|
-
*
|
|
257
|
-
* @readonly
|
|
258
|
-
*/
|
|
259
|
-
get status(): string {
|
|
260
|
-
return this.data.status;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Assembly type. Returns an `assembly`.
|
|
265
|
-
*
|
|
266
|
-
* @readonly
|
|
267
|
-
*/
|
|
268
|
-
get type(): string {
|
|
269
|
-
return "assembly";
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Reserved for future use
|
|
273
|
-
|
|
274
|
-
get version(): number {
|
|
275
|
-
return this.data.version;
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
get versions(): IAssemblyVersionInfo[] {
|
|
279
|
-
return this.data.versions;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Refresh assembly data.
|
|
284
|
-
*
|
|
285
|
-
* @async
|
|
286
|
-
*/
|
|
287
|
-
async checkout(): Promise<Assembly> {
|
|
288
|
-
this.data = await json(this.internalGet(""));
|
|
289
|
-
return this;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Updates assembly data on the server.
|
|
294
|
-
*
|
|
295
|
-
* @async
|
|
296
|
-
* @param data - Raw assembly data.
|
|
297
|
-
*/
|
|
298
|
-
async update(data: any): Promise<Assembly> {
|
|
299
|
-
this.data = await json(this.internalPut("", data));
|
|
300
|
-
return this;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Delete the assembly from the server.
|
|
305
|
-
*
|
|
306
|
-
* @async
|
|
307
|
-
* @returns Returns the raw data of a deleted assembly.
|
|
308
|
-
*/
|
|
309
|
-
delete(): Promise<any> {
|
|
310
|
-
return json(this.internalDelete(""));
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Save assembly data changes to the server. Call this method to update assembly data on the
|
|
315
|
-
* server after any changes.
|
|
316
|
-
*
|
|
317
|
-
* @async
|
|
318
|
-
*/
|
|
319
|
-
save(): Promise<Assembly> {
|
|
320
|
-
return this.update(this.data);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
// Reserved for future use
|
|
324
|
-
|
|
325
|
-
setPreview(image?: ArrayBuffer | Blob | globalThis.File | FormData | string | null) {
|
|
326
|
-
console.warn("Assembly does not support preview");
|
|
327
|
-
return Promise.resolve(this);
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Returns list of assembly models.
|
|
332
|
-
*
|
|
333
|
-
* @async
|
|
334
|
-
*/
|
|
335
|
-
getModels(): Promise<Model[]> {
|
|
336
|
-
return json(this.internalGet("/geometry")).then((array) => array.map((data) => new Model(data, this)));
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* Transformation matrix.
|
|
341
|
-
*
|
|
342
|
-
* @typedef {any} Transform
|
|
343
|
-
* @property {any} translate - Translation part, move along the X, Y, Z axes.
|
|
344
|
-
* @property {number} translate.x - The value for substruct for X axes.
|
|
345
|
-
* @property {number} translate.y - The value for substruct for Y axes.
|
|
346
|
-
* @property {number} translate.z - The value for substruct for Z axes.
|
|
347
|
-
* @property {any} rotation - Rotation part, rotate by the specified angle, around the
|
|
348
|
-
* specified vector.
|
|
349
|
-
* @property {number} rotation.x - X coordinate of the rotation vector.
|
|
350
|
-
* @property {number} rotation.y - Y coordinate of the rotation vector.
|
|
351
|
-
* @property {number} rotation.z - Z coordinate of the rotation vector.
|
|
352
|
-
* @property {number} rotation.angle - The angle of rotation.
|
|
353
|
-
* @property {number} scale - Scaling part, scale with multiplier, from center of extends.
|
|
354
|
-
*/
|
|
355
|
-
|
|
356
|
-
/**
|
|
357
|
-
* Returns a model transformation.
|
|
358
|
-
*
|
|
359
|
-
* @param handle - Model handle.
|
|
360
|
-
*/
|
|
361
|
-
getModelTransformMatrix(handle: string): any {
|
|
362
|
-
return this.data.transform[handle];
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/**
|
|
366
|
-
* Set or delete a model transformation.
|
|
367
|
-
*
|
|
368
|
-
* @async
|
|
369
|
-
* @param handle - Model handle.
|
|
370
|
-
* @param transform - Transformation matrix. To delete transformation provide this to `undefined`.
|
|
371
|
-
*/
|
|
372
|
-
setModelTransformMatrix(handle: string, transform: any): Promise<Assembly> {
|
|
373
|
-
const obj = { ...this.data.transform };
|
|
374
|
-
obj[handle] = transform;
|
|
375
|
-
return this.update({ transform: obj });
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* Returns the properties for an objects in the assembly.
|
|
380
|
-
*
|
|
381
|
-
* @async
|
|
382
|
-
* @param handles - Object original handle or handles array. Leave this parameter undefined
|
|
383
|
-
* to get properties for all objects in the assembly.
|
|
384
|
-
* @returns {Promise<any>}
|
|
385
|
-
*/
|
|
386
|
-
getProperties(handles?: string | string[]): Promise<any[]> {
|
|
387
|
-
return json(this.internalGet(handles !== undefined ? `/properties?handles=${handles}` : "/properties"));
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Returns the list of original handles for an objects in the file that match the specified
|
|
392
|
-
* patterns. Search patterns may be combined using query operators.
|
|
393
|
-
*
|
|
394
|
-
* @async
|
|
395
|
-
* @example <caption>Simple search pattern.</caption>
|
|
396
|
-
* searchPattern = {
|
|
397
|
-
* key: "Category",
|
|
398
|
-
* value: "OST_Stairs",
|
|
399
|
-
* };
|
|
400
|
-
*
|
|
401
|
-
* @example <caption>Search patterns combination.</caption>
|
|
402
|
-
* searchPattern = {
|
|
403
|
-
* $or: [
|
|
404
|
-
* {
|
|
405
|
-
* $and: [
|
|
406
|
-
* { key: "Category", value: "OST_GenericModel" },
|
|
407
|
-
* { key: "Level", value: "03 - Floor" },
|
|
408
|
-
* ],
|
|
409
|
-
* },
|
|
410
|
-
* { key: "Category", value: "OST_Stairs" },
|
|
411
|
-
* ],
|
|
412
|
-
* };
|
|
413
|
-
*
|
|
414
|
-
* @param searchPattern - Search pattern or combination of the patterns, see example below.
|
|
415
|
-
*/
|
|
416
|
-
searchProperties(searchPattern: any): Promise<any[]> {
|
|
417
|
-
return json(this.internalPost("/properties/search", searchPattern));
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* Returns the cda.json for an assembly.
|
|
422
|
-
*
|
|
423
|
-
* @async
|
|
424
|
-
*/
|
|
425
|
-
getCdaTree(): Promise<any[]> {
|
|
426
|
-
return json(this.internalGet(`/properties/tree`));
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// Reserved for future use
|
|
430
|
-
|
|
431
|
-
getViewpoints(): Promise<[]> {
|
|
432
|
-
console.warn("Assembly does not support viewpoints");
|
|
433
|
-
return Promise.resolve([]);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
saveViewpoint(viewpoint: any): Promise<any> {
|
|
437
|
-
console.warn("Assembly does not support viewpoints");
|
|
438
|
-
return Promise.resolve({});
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
deleteViewpoint(guid: any): Promise<any> {
|
|
442
|
-
console.warn("Assembly does not support viewpoints");
|
|
443
|
-
return Promise.resolve({});
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
getSnapshot(guid: any): Promise<any> {
|
|
447
|
-
console.warn("Assembly does not support viewpoints");
|
|
448
|
-
return Promise.resolve({});
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
getSnapshotData(guid: any, bitmapGuid: any): Promise<string> {
|
|
452
|
-
console.warn("Assembly does not support viewpoints");
|
|
453
|
-
return Promise.resolve("");
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Download assembly resource data, such as geometry data.
|
|
458
|
-
*
|
|
459
|
-
* @async
|
|
460
|
-
* @param dataId - Resource ID.
|
|
461
|
-
* @param onProgress - Download progress callback.
|
|
462
|
-
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
463
|
-
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
464
|
-
* and abort it if desired.
|
|
465
|
-
*/
|
|
466
|
-
downloadResource(
|
|
467
|
-
dataId: string,
|
|
468
|
-
onProgress?: (progress: number) => void,
|
|
469
|
-
signal?: AbortSignal
|
|
470
|
-
): Promise<ArrayBuffer> {
|
|
471
|
-
return this.internalGet(`/downloads/${dataId}`, signal)
|
|
472
|
-
.then((response) => downloadProgress(response, onProgress))
|
|
473
|
-
.then((response) => response.arrayBuffer());
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
// Reserved for future use
|
|
477
|
-
|
|
478
|
-
getReferences(signal?: AbortSignal) {
|
|
479
|
-
return Promise.resolve({ fileId: "", references: [] });
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
/**
|
|
483
|
-
* Wait for assembly to be created. Assembly is created when it changes to `done` or `failed` status.
|
|
484
|
-
*
|
|
485
|
-
* @async
|
|
486
|
-
* @param params - An object containing waiting parameters.
|
|
487
|
-
* @param params.timeout - The time, in milliseconds that the function should wait assembly.
|
|
488
|
-
* If assembly is not created during this time, the `TimeoutError` exception will be thrown.
|
|
489
|
-
* @param params.interval - The time, in milliseconds, the function should delay in between
|
|
490
|
-
* checking assembly status.
|
|
491
|
-
* @param params.signal- An <a
|
|
492
|
-
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
493
|
-
* signal object instance, which can be used to abort waiting as desired.
|
|
494
|
-
* @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
|
|
495
|
-
* @returns {Promise<Assembly>}
|
|
496
|
-
*/
|
|
497
|
-
waitForDone(params?: {
|
|
498
|
-
timeout?: number;
|
|
499
|
-
interval?: number;
|
|
500
|
-
signal?: AbortSignal;
|
|
501
|
-
onCheckout?: (assembly: Assembly, ready: boolean) => boolean;
|
|
502
|
-
}): Promise<Assembly> {
|
|
503
|
-
const checkDone = () =>
|
|
504
|
-
this.checkout().then((assembly) => {
|
|
505
|
-
const ready = ["done", "failed"].includes(assembly.status);
|
|
506
|
-
const cancel = params?.onCheckout?.(assembly, ready);
|
|
507
|
-
return cancel || ready;
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
return waitFor(checkDone, params).then(() => this);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
/**
|
|
514
|
-
* Returns a list of assembly clash tests.
|
|
515
|
-
*
|
|
516
|
-
* @async
|
|
517
|
-
* @param {number} start - The starting index in the test list. Used for paging.
|
|
518
|
-
* @param {number} limit - The maximum number of tests that should be returned per request.
|
|
519
|
-
* Used for paging.
|
|
520
|
-
* @param {string} name - Filter the tests by part of the name.
|
|
521
|
-
* @param {string | string[]} ids - List of tests IDs to return. You can specify multiple IDs
|
|
522
|
-
* on one `string` by separating them with a "|".
|
|
523
|
-
* @param {bool} sortByDesc - Allows to specify the descending order of the result. By
|
|
524
|
-
* default tests are sorted by name in ascending order.
|
|
525
|
-
* @param {string} sortField - Allows to specify sort field.
|
|
526
|
-
*/
|
|
527
|
-
getClashTests(
|
|
528
|
-
start?: number,
|
|
529
|
-
limit?: number,
|
|
530
|
-
name?: string,
|
|
531
|
-
ids?: string | string[],
|
|
532
|
-
sortByDesc?: boolean,
|
|
533
|
-
sortField?: string
|
|
534
|
-
): Promise<{ allSize: number; start: number; limit: number; result: ClashTest[]; size: number }> {
|
|
535
|
-
const searchParams = new URLSearchParams();
|
|
536
|
-
if (start > 0) searchParams.set("start", start.toString());
|
|
537
|
-
if (limit > 0) searchParams.set("limit", limit.toString());
|
|
538
|
-
if (name) searchParams.set("name", name);
|
|
539
|
-
if (ids) {
|
|
540
|
-
if (Array.isArray(ids)) ids = ids.join("|");
|
|
541
|
-
if (typeof ids === "string") ids = ids.trim();
|
|
542
|
-
if (ids) searchParams.set("id", ids);
|
|
543
|
-
}
|
|
544
|
-
if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
545
|
-
if (sortField) searchParams.set("sortField", sortField);
|
|
546
|
-
|
|
547
|
-
let queryString = searchParams.toString();
|
|
548
|
-
if (queryString) queryString = "?" + queryString;
|
|
549
|
-
|
|
550
|
-
return this.internalGet(`/clashes${queryString}`)
|
|
551
|
-
.then((response) => response.json())
|
|
552
|
-
.then((tests) => {
|
|
553
|
-
return {
|
|
554
|
-
...tests,
|
|
555
|
-
result: tests.result.map((data) => new ClashTest(data, this.path, this.httpClient)),
|
|
556
|
-
};
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* Returns the assembly clash test information.
|
|
562
|
-
*
|
|
563
|
-
* @async
|
|
564
|
-
* @param testId - Test ID.
|
|
565
|
-
*/
|
|
566
|
-
getClashTest(testId: string): Promise<ClashTest> {
|
|
567
|
-
return this.internalGet(`/clashes/${testId}`)
|
|
568
|
-
.then((response) => response.json())
|
|
569
|
-
.then((data) => new ClashTest(data, this.path, this.httpClient));
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
/**
|
|
573
|
-
* Create assembly clash test. Assembly must be in a `done` state, otherwise the test will fail.
|
|
574
|
-
*
|
|
575
|
-
* @async
|
|
576
|
-
* @param name - Test name.
|
|
577
|
-
* @param selectionTypeA - The type of first selection set for clash detection. Can be `all`,
|
|
578
|
-
* `handles`, `models` or `searchquery`.
|
|
579
|
-
* @param selectionTypeB - The type of second selection set for clash detection. Can be
|
|
580
|
-
* `all`, `handles`, `models` or `searchquery`.
|
|
581
|
-
* @param selectionSetA - First selection set for clash detection.
|
|
582
|
-
* @param selectionSetB - Second selection set for clash detection.
|
|
583
|
-
* @param params - An object containing test parameters.
|
|
584
|
-
* @param params.tolerance - The distance of separation between entities at which test begins
|
|
585
|
-
* detecting clashes.
|
|
586
|
-
* @param params.clearance - The type of the clashes that the test detects: `true` for
|
|
587
|
-
* `Сlearance clash` or `false` for `Hard clash`.
|
|
588
|
-
* @param params.waitForDone - Wait for test to complete.
|
|
589
|
-
* @param params.timeout - The time, in milliseconds that the function should wait test. If
|
|
590
|
-
* test is not complete during this time, the `TimeoutError` exception will be thrown.
|
|
591
|
-
* @param params.interval - The time, in milliseconds, the function should delay in between
|
|
592
|
-
* checking test status.
|
|
593
|
-
* @param params.signal- An <a
|
|
594
|
-
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
595
|
-
* signal object instance, which can be used to abort waiting as desired.
|
|
596
|
-
*/
|
|
597
|
-
createClashTest(
|
|
598
|
-
name: string,
|
|
599
|
-
selectionTypeA: string,
|
|
600
|
-
selectionTypeB: string,
|
|
601
|
-
selectionSetA?: string | string[],
|
|
602
|
-
selectionSetB?: string | string[],
|
|
603
|
-
params?: {
|
|
604
|
-
tolerance?: number | string;
|
|
605
|
-
clearance?: boolean;
|
|
606
|
-
waitForDone?: boolean;
|
|
607
|
-
timeout?: number;
|
|
608
|
-
interval?: number;
|
|
609
|
-
signal?: AbortSignal;
|
|
610
|
-
}
|
|
611
|
-
): Promise<ClashTest> {
|
|
612
|
-
const { tolerance, clearance, waitForDone } = params ?? {};
|
|
613
|
-
if (!Array.isArray(selectionSetA)) selectionSetA = [selectionSetA];
|
|
614
|
-
if (!Array.isArray(selectionSetB)) selectionSetB = [selectionSetB];
|
|
615
|
-
|
|
616
|
-
return this.internalPost("/clashes", {
|
|
617
|
-
name,
|
|
618
|
-
selectionTypeA,
|
|
619
|
-
selectionTypeB,
|
|
620
|
-
selectionSetA,
|
|
621
|
-
selectionSetB,
|
|
622
|
-
tolerance,
|
|
623
|
-
clearance,
|
|
624
|
-
})
|
|
625
|
-
.then((response) => response.json())
|
|
626
|
-
.then((data) => new ClashTest(data, this.path, this.httpClient))
|
|
627
|
-
.then((result) => (waitForDone ? result.waitForDone(params) : result));
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* Delete assembly clash test.
|
|
632
|
-
*
|
|
633
|
-
* @async
|
|
634
|
-
* @param testId - Test ID.
|
|
635
|
-
* @returns Returns the raw data of a deleted test.
|
|
636
|
-
*/
|
|
637
|
-
deleteClashTest(testId: string): Promise<any> {
|
|
638
|
-
return this.internalDelete(`/clashes/${testId}`).then((response) => response.json());
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
// Reserved for future use
|
|
642
|
-
|
|
643
|
-
updateVersion(
|
|
644
|
-
files?: string[],
|
|
645
|
-
params: {
|
|
646
|
-
waitForDone?: boolean;
|
|
647
|
-
timeout?: number;
|
|
648
|
-
interval?: number;
|
|
649
|
-
signal?: AbortSignal;
|
|
650
|
-
onProgress?: (progress: number, file: globalThis.File) => void;
|
|
651
|
-
} = {
|
|
652
|
-
waitForDone: false,
|
|
653
|
-
}
|
|
654
|
-
): Promise<Assembly> {
|
|
655
|
-
return Promise.reject(new Error("Assembly version support will be implemeted in a future release"));
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
getVersions(): Promise<Assembly[] | undefined> {
|
|
659
|
-
return Promise.resolve(undefined);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
getVersion(version: number): Promise<Assembly> {
|
|
663
|
-
return Promise.reject(new FetchError(404));
|
|
664
|
-
}
|
|
665
|
-
|
|
666
|
-
deleteVersion(version: number): Promise<any> {
|
|
667
|
-
return Promise.reject(new FetchError(404));
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
setActiveVersion(version: number) {
|
|
671
|
-
return this.update({ activeVersion: version });
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
useVersion(version?: number) {
|
|
675
|
-
this._useVersion = undefined;
|
|
676
|
-
return this;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
1
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
// Copyright (C) 2002-2021, Open Design Alliance (the "Alliance").
|
|
3
|
+
// All rights reserved.
|
|
4
|
+
//
|
|
5
|
+
// This software and its documentation and related materials are owned by
|
|
6
|
+
// the Alliance. The software may only be incorporated into application
|
|
7
|
+
// programs owned by members of the Alliance, subject to a signed
|
|
8
|
+
// Membership Agreement and Supplemental Software License Agreement with the
|
|
9
|
+
// Alliance. The structure and organization of this software are the valuable
|
|
10
|
+
// trade secrets of the Alliance and its suppliers. The software is also
|
|
11
|
+
// protected by copyright law and international treaty provisions. Application
|
|
12
|
+
// programs incorporating this software must include the following statement
|
|
13
|
+
// with their copyright notices:
|
|
14
|
+
//
|
|
15
|
+
// This application incorporates Open Design Alliance software pursuant to a
|
|
16
|
+
// license agreement with Open Design Alliance.
|
|
17
|
+
// Open Design Alliance Copyright (C) 2002-2021 by Open Design Alliance.
|
|
18
|
+
// All rights reserved.
|
|
19
|
+
//
|
|
20
|
+
// By use of this software, its documentation or related materials, you
|
|
21
|
+
// acknowledge and accept the above terms.
|
|
22
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
23
|
+
|
|
24
|
+
import { IHttpClient } from "./IHttpClient";
|
|
25
|
+
import { IAssociatedFileData, IAssemblyVersionInfo } from "./IAssembly";
|
|
26
|
+
import { IShortUserDescription } from "./IUser";
|
|
27
|
+
import { Model } from "./Model";
|
|
28
|
+
import { ClashTest } from "./ClashTest";
|
|
29
|
+
import { json, downloadProgress, downloadPartOfFile, waitFor, userFullName, userInitials } from "./impl/Utils";
|
|
30
|
+
import { FetchError } from "./impl/FetchError";
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The class representing a `assembly` entity.
|
|
34
|
+
*/
|
|
35
|
+
export class Assembly {
|
|
36
|
+
private _data: any;
|
|
37
|
+
private _useVersion: number | undefined;
|
|
38
|
+
public httpClient: IHttpClient;
|
|
39
|
+
public path: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param data - An object that implements assembly data storage.
|
|
43
|
+
* @param httpClient - Http client.
|
|
44
|
+
*/
|
|
45
|
+
constructor(data: any, httpClient: IHttpClient) {
|
|
46
|
+
this.path = `/assemblies/${data.id}`;
|
|
47
|
+
this.httpClient = httpClient;
|
|
48
|
+
this.data = data;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public appendVersionParam(relativePath: string): string {
|
|
52
|
+
if (this._useVersion === undefined) return relativePath;
|
|
53
|
+
|
|
54
|
+
const delimiter = relativePath.includes("?") ? "&" : "?";
|
|
55
|
+
return `${relativePath}${delimiter}version=${this._useVersion}`;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
protected internalGet(relativePath: string, signal?: AbortSignal) {
|
|
59
|
+
relativePath = this.appendVersionParam(relativePath);
|
|
60
|
+
return this.httpClient.get(`${this.path}${relativePath}`, signal);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
protected internalPost(
|
|
64
|
+
relativePath: string,
|
|
65
|
+
body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
|
|
66
|
+
) {
|
|
67
|
+
relativePath = this.appendVersionParam(relativePath);
|
|
68
|
+
return this.httpClient.post(`${this.path}${relativePath}`, body);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
protected internalPut(
|
|
72
|
+
relativePath: string,
|
|
73
|
+
body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
|
|
74
|
+
) {
|
|
75
|
+
relativePath = this.appendVersionParam(relativePath);
|
|
76
|
+
return this.httpClient.put(`${this.path}${relativePath}`, body);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
protected internalDelete(relativePath: string) {
|
|
80
|
+
relativePath = this.appendVersionParam(relativePath);
|
|
81
|
+
return this.httpClient.delete(`${this.path}${relativePath}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async partialDownloadResource(
|
|
85
|
+
dataId: string,
|
|
86
|
+
onProgress?: (progress: number, downloaded: Uint8Array) => void,
|
|
87
|
+
signal?: AbortSignal
|
|
88
|
+
): Promise<void> {
|
|
89
|
+
let pathname = `${this.path}/downloads/${dataId}`;
|
|
90
|
+
pathname = this.appendVersionParam(pathname);
|
|
91
|
+
|
|
92
|
+
// TODO: replace with $get to handle fetch errors
|
|
93
|
+
const response = await fetch(`${this.httpClient.serverUrl}${pathname}`, {
|
|
94
|
+
headers: this.httpClient.headers,
|
|
95
|
+
signal,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// TODO: use ReadableStream pipeTo()
|
|
99
|
+
const contentLength = response.headers.get("Content-Length") ?? "";
|
|
100
|
+
const total = parseInt(contentLength, 10);
|
|
101
|
+
const reader = response.body.getReader();
|
|
102
|
+
let loaded = 0;
|
|
103
|
+
while (true) {
|
|
104
|
+
const { done, value } = await reader.read();
|
|
105
|
+
if (done) break;
|
|
106
|
+
loaded += value.byteLength;
|
|
107
|
+
if (typeof onProgress === "function") onProgress(loaded / total, value);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
downloadFileRange(
|
|
112
|
+
requestId: number,
|
|
113
|
+
records: any | null,
|
|
114
|
+
dataId: string,
|
|
115
|
+
onProgress?: (progress: number, downloaded: Uint8Array, requestId: number) => void,
|
|
116
|
+
signal?: AbortSignal
|
|
117
|
+
): Promise<void> {
|
|
118
|
+
let pathname = `${this.path}/downloads/${dataId}?requestId=${requestId}`;
|
|
119
|
+
pathname = this.appendVersionParam(pathname);
|
|
120
|
+
return downloadPartOfFile(
|
|
121
|
+
requestId,
|
|
122
|
+
records,
|
|
123
|
+
`${this.httpClient.serverUrl}${pathname}`,
|
|
124
|
+
this.httpClient.headers,
|
|
125
|
+
onProgress,
|
|
126
|
+
signal
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Reserved for future use
|
|
131
|
+
|
|
132
|
+
get activeVersion(): number {
|
|
133
|
+
return this.data.activeVersion;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* List of unique files from which the assembly was created.
|
|
138
|
+
*
|
|
139
|
+
* @readonly
|
|
140
|
+
*/
|
|
141
|
+
get associatedFiles(): IAssociatedFileData[] {
|
|
142
|
+
return this.data.associatedFiles;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Assembly creation time (UTC) in the format specified in <a
|
|
147
|
+
* href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
|
|
148
|
+
*
|
|
149
|
+
* @readonly
|
|
150
|
+
*/
|
|
151
|
+
get created(): string {
|
|
152
|
+
return this.data.created;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Raw assembly data received from the server.
|
|
157
|
+
*
|
|
158
|
+
* @readonly
|
|
159
|
+
*/
|
|
160
|
+
get data(): any {
|
|
161
|
+
return this._data;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private set data(value: any) {
|
|
165
|
+
this._data = value;
|
|
166
|
+
this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
|
|
167
|
+
this._data.owner.fullName = userFullName(this._data.owner);
|
|
168
|
+
this._data.owner.initials = userInitials(this._data.owner.fullName);
|
|
169
|
+
// associatedFiles since 23.12
|
|
170
|
+
this._data.associatedFiles ??= [];
|
|
171
|
+
this._data.associatedFiles.forEach((file) => (file.link = `${this.httpClient.serverUrl}/files/${file.fileId}`));
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* List of file IDs from which the assembly was created.
|
|
176
|
+
*
|
|
177
|
+
* @readonly
|
|
178
|
+
*/
|
|
179
|
+
get files(): string[] {
|
|
180
|
+
return this.data.files;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Assembly geometry data type:
|
|
185
|
+
*
|
|
186
|
+
* - `vsfx` - VSFX, assembly can be opened in `VisualizeJS` viewer.
|
|
187
|
+
*
|
|
188
|
+
* Returns an empty string if geometry data has not yet been extracted.
|
|
189
|
+
*/
|
|
190
|
+
get geometryType(): string {
|
|
191
|
+
return this.status === "done" ? "vsfx" : "";
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Unique assembly ID.
|
|
196
|
+
*
|
|
197
|
+
* @readonly
|
|
198
|
+
*/
|
|
199
|
+
get id(): string {
|
|
200
|
+
return this.data.id;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Assembly name.
|
|
205
|
+
*/
|
|
206
|
+
get name(): string {
|
|
207
|
+
return this.data.name;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
set name(value: string) {
|
|
211
|
+
this.data.name = value;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Reserved for future use
|
|
215
|
+
|
|
216
|
+
get originalAssemblyId(): string {
|
|
217
|
+
return this.data.originalAssemblyId;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Assembly owner information.
|
|
222
|
+
*
|
|
223
|
+
* @property {string} userId - User ID.
|
|
224
|
+
* @property {string} userName - User name.
|
|
225
|
+
* @property {string} name - First name.
|
|
226
|
+
* @property {string} lastName - Last name.
|
|
227
|
+
* @property {string} fullName - Full name.
|
|
228
|
+
* @property {string} initials - Initials.
|
|
229
|
+
* @property {string} email - User email.
|
|
230
|
+
* @property {string} avatarUrl - User avatar image URL.
|
|
231
|
+
* @readonly
|
|
232
|
+
*/
|
|
233
|
+
get owner(): IShortUserDescription {
|
|
234
|
+
return this.data.owner;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Reserved for future use
|
|
238
|
+
|
|
239
|
+
get previewUrl(): string {
|
|
240
|
+
return this.data.previewUrl ?? "";
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* List of assembly related job IDs.
|
|
245
|
+
*
|
|
246
|
+
* @readonly
|
|
247
|
+
*/
|
|
248
|
+
get relatedJobs(): string[] {
|
|
249
|
+
return this.data.relatedJobs;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Assembly geometry data and properties status. Can be `waiting`, `inprogress`, `done` or `failed`.
|
|
254
|
+
*
|
|
255
|
+
* An assemblies without geometry data cannot be opened in viewer.
|
|
256
|
+
*
|
|
257
|
+
* @readonly
|
|
258
|
+
*/
|
|
259
|
+
get status(): string {
|
|
260
|
+
return this.data.status;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Assembly type. Returns an `assembly`.
|
|
265
|
+
*
|
|
266
|
+
* @readonly
|
|
267
|
+
*/
|
|
268
|
+
get type(): string {
|
|
269
|
+
return "assembly";
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Reserved for future use
|
|
273
|
+
|
|
274
|
+
get version(): number {
|
|
275
|
+
return this.data.version;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
get versions(): IAssemblyVersionInfo[] {
|
|
279
|
+
return this.data.versions;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Refresh assembly data.
|
|
284
|
+
*
|
|
285
|
+
* @async
|
|
286
|
+
*/
|
|
287
|
+
async checkout(): Promise<Assembly> {
|
|
288
|
+
this.data = await json(this.internalGet(""));
|
|
289
|
+
return this;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Updates assembly data on the server.
|
|
294
|
+
*
|
|
295
|
+
* @async
|
|
296
|
+
* @param data - Raw assembly data.
|
|
297
|
+
*/
|
|
298
|
+
async update(data: any): Promise<Assembly> {
|
|
299
|
+
this.data = await json(this.internalPut("", data));
|
|
300
|
+
return this;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Delete the assembly from the server.
|
|
305
|
+
*
|
|
306
|
+
* @async
|
|
307
|
+
* @returns Returns the raw data of a deleted assembly.
|
|
308
|
+
*/
|
|
309
|
+
delete(): Promise<any> {
|
|
310
|
+
return json(this.internalDelete(""));
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Save assembly data changes to the server. Call this method to update assembly data on the
|
|
315
|
+
* server after any changes.
|
|
316
|
+
*
|
|
317
|
+
* @async
|
|
318
|
+
*/
|
|
319
|
+
save(): Promise<Assembly> {
|
|
320
|
+
return this.update(this.data);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Reserved for future use
|
|
324
|
+
|
|
325
|
+
setPreview(image?: ArrayBuffer | Blob | globalThis.File | FormData | string | null) {
|
|
326
|
+
console.warn("Assembly does not support preview");
|
|
327
|
+
return Promise.resolve(this);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Returns list of assembly models.
|
|
332
|
+
*
|
|
333
|
+
* @async
|
|
334
|
+
*/
|
|
335
|
+
getModels(): Promise<Model[]> {
|
|
336
|
+
return json(this.internalGet("/geometry")).then((array) => array.map((data) => new Model(data, this)));
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Transformation matrix.
|
|
341
|
+
*
|
|
342
|
+
* @typedef {any} Transform
|
|
343
|
+
* @property {any} translate - Translation part, move along the X, Y, Z axes.
|
|
344
|
+
* @property {number} translate.x - The value for substruct for X axes.
|
|
345
|
+
* @property {number} translate.y - The value for substruct for Y axes.
|
|
346
|
+
* @property {number} translate.z - The value for substruct for Z axes.
|
|
347
|
+
* @property {any} rotation - Rotation part, rotate by the specified angle, around the
|
|
348
|
+
* specified vector.
|
|
349
|
+
* @property {number} rotation.x - X coordinate of the rotation vector.
|
|
350
|
+
* @property {number} rotation.y - Y coordinate of the rotation vector.
|
|
351
|
+
* @property {number} rotation.z - Z coordinate of the rotation vector.
|
|
352
|
+
* @property {number} rotation.angle - The angle of rotation.
|
|
353
|
+
* @property {number} scale - Scaling part, scale with multiplier, from center of extends.
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Returns a model transformation.
|
|
358
|
+
*
|
|
359
|
+
* @param handle - Model handle.
|
|
360
|
+
*/
|
|
361
|
+
getModelTransformMatrix(handle: string): any {
|
|
362
|
+
return this.data.transform[handle];
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Set or delete a model transformation.
|
|
367
|
+
*
|
|
368
|
+
* @async
|
|
369
|
+
* @param handle - Model handle.
|
|
370
|
+
* @param transform - Transformation matrix. To delete transformation provide this to `undefined`.
|
|
371
|
+
*/
|
|
372
|
+
setModelTransformMatrix(handle: string, transform: any): Promise<Assembly> {
|
|
373
|
+
const obj = { ...this.data.transform };
|
|
374
|
+
obj[handle] = transform;
|
|
375
|
+
return this.update({ transform: obj });
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* Returns the properties for an objects in the assembly.
|
|
380
|
+
*
|
|
381
|
+
* @async
|
|
382
|
+
* @param handles - Object original handle or handles array. Leave this parameter undefined
|
|
383
|
+
* to get properties for all objects in the assembly.
|
|
384
|
+
* @returns {Promise<any>}
|
|
385
|
+
*/
|
|
386
|
+
getProperties(handles?: string | string[]): Promise<any[]> {
|
|
387
|
+
return json(this.internalGet(handles !== undefined ? `/properties?handles=${handles}` : "/properties"));
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/**
|
|
391
|
+
* Returns the list of original handles for an objects in the file that match the specified
|
|
392
|
+
* patterns. Search patterns may be combined using query operators.
|
|
393
|
+
*
|
|
394
|
+
* @async
|
|
395
|
+
* @example <caption>Simple search pattern.</caption>
|
|
396
|
+
* searchPattern = {
|
|
397
|
+
* key: "Category",
|
|
398
|
+
* value: "OST_Stairs",
|
|
399
|
+
* };
|
|
400
|
+
*
|
|
401
|
+
* @example <caption>Search patterns combination.</caption>
|
|
402
|
+
* searchPattern = {
|
|
403
|
+
* $or: [
|
|
404
|
+
* {
|
|
405
|
+
* $and: [
|
|
406
|
+
* { key: "Category", value: "OST_GenericModel" },
|
|
407
|
+
* { key: "Level", value: "03 - Floor" },
|
|
408
|
+
* ],
|
|
409
|
+
* },
|
|
410
|
+
* { key: "Category", value: "OST_Stairs" },
|
|
411
|
+
* ],
|
|
412
|
+
* };
|
|
413
|
+
*
|
|
414
|
+
* @param searchPattern - Search pattern or combination of the patterns, see example below.
|
|
415
|
+
*/
|
|
416
|
+
searchProperties(searchPattern: any): Promise<any[]> {
|
|
417
|
+
return json(this.internalPost("/properties/search", searchPattern));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Returns the cda.json for an assembly.
|
|
422
|
+
*
|
|
423
|
+
* @async
|
|
424
|
+
*/
|
|
425
|
+
getCdaTree(): Promise<any[]> {
|
|
426
|
+
return json(this.internalGet(`/properties/tree`));
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Reserved for future use
|
|
430
|
+
|
|
431
|
+
getViewpoints(): Promise<[]> {
|
|
432
|
+
console.warn("Assembly does not support viewpoints");
|
|
433
|
+
return Promise.resolve([]);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
saveViewpoint(viewpoint: any): Promise<any> {
|
|
437
|
+
console.warn("Assembly does not support viewpoints");
|
|
438
|
+
return Promise.resolve({});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
deleteViewpoint(guid: any): Promise<any> {
|
|
442
|
+
console.warn("Assembly does not support viewpoints");
|
|
443
|
+
return Promise.resolve({});
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
getSnapshot(guid: any): Promise<any> {
|
|
447
|
+
console.warn("Assembly does not support viewpoints");
|
|
448
|
+
return Promise.resolve({});
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
getSnapshotData(guid: any, bitmapGuid: any): Promise<string> {
|
|
452
|
+
console.warn("Assembly does not support viewpoints");
|
|
453
|
+
return Promise.resolve("");
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
/**
|
|
457
|
+
* Download assembly resource data, such as geometry data.
|
|
458
|
+
*
|
|
459
|
+
* @async
|
|
460
|
+
* @param dataId - Resource ID.
|
|
461
|
+
* @param onProgress - Download progress callback.
|
|
462
|
+
* @param signal - An <a href="https://developer.mozilla.org/docs/Web/API/AbortSignal" target
|
|
463
|
+
* ="_blank">AbortSignal</a> object instance. Allows to communicate with a fetch request
|
|
464
|
+
* and abort it if desired.
|
|
465
|
+
*/
|
|
466
|
+
downloadResource(
|
|
467
|
+
dataId: string,
|
|
468
|
+
onProgress?: (progress: number) => void,
|
|
469
|
+
signal?: AbortSignal
|
|
470
|
+
): Promise<ArrayBuffer> {
|
|
471
|
+
return this.internalGet(`/downloads/${dataId}`, signal)
|
|
472
|
+
.then((response) => downloadProgress(response, onProgress))
|
|
473
|
+
.then((response) => response.arrayBuffer());
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
// Reserved for future use
|
|
477
|
+
|
|
478
|
+
getReferences(signal?: AbortSignal) {
|
|
479
|
+
return Promise.resolve({ fileId: "", references: [] });
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Wait for assembly to be created. Assembly is created when it changes to `done` or `failed` status.
|
|
484
|
+
*
|
|
485
|
+
* @async
|
|
486
|
+
* @param params - An object containing waiting parameters.
|
|
487
|
+
* @param params.timeout - The time, in milliseconds that the function should wait assembly.
|
|
488
|
+
* If assembly is not created during this time, the `TimeoutError` exception will be thrown.
|
|
489
|
+
* @param params.interval - The time, in milliseconds, the function should delay in between
|
|
490
|
+
* checking assembly status.
|
|
491
|
+
* @param params.signal- An <a
|
|
492
|
+
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
493
|
+
* signal object instance, which can be used to abort waiting as desired.
|
|
494
|
+
* @param params.onCheckout - Waiting progress callback. Return `true` to cancel waiting.
|
|
495
|
+
* @returns {Promise<Assembly>}
|
|
496
|
+
*/
|
|
497
|
+
waitForDone(params?: {
|
|
498
|
+
timeout?: number;
|
|
499
|
+
interval?: number;
|
|
500
|
+
signal?: AbortSignal;
|
|
501
|
+
onCheckout?: (assembly: Assembly, ready: boolean) => boolean;
|
|
502
|
+
}): Promise<Assembly> {
|
|
503
|
+
const checkDone = () =>
|
|
504
|
+
this.checkout().then((assembly) => {
|
|
505
|
+
const ready = ["done", "failed"].includes(assembly.status);
|
|
506
|
+
const cancel = params?.onCheckout?.(assembly, ready);
|
|
507
|
+
return cancel || ready;
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
return waitFor(checkDone, params).then(() => this);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Returns a list of assembly clash tests.
|
|
515
|
+
*
|
|
516
|
+
* @async
|
|
517
|
+
* @param {number} start - The starting index in the test list. Used for paging.
|
|
518
|
+
* @param {number} limit - The maximum number of tests that should be returned per request.
|
|
519
|
+
* Used for paging.
|
|
520
|
+
* @param {string} name - Filter the tests by part of the name.
|
|
521
|
+
* @param {string | string[]} ids - List of tests IDs to return. You can specify multiple IDs
|
|
522
|
+
* on one `string` by separating them with a "|".
|
|
523
|
+
* @param {bool} sortByDesc - Allows to specify the descending order of the result. By
|
|
524
|
+
* default tests are sorted by name in ascending order.
|
|
525
|
+
* @param {string} sortField - Allows to specify sort field.
|
|
526
|
+
*/
|
|
527
|
+
getClashTests(
|
|
528
|
+
start?: number,
|
|
529
|
+
limit?: number,
|
|
530
|
+
name?: string,
|
|
531
|
+
ids?: string | string[],
|
|
532
|
+
sortByDesc?: boolean,
|
|
533
|
+
sortField?: string
|
|
534
|
+
): Promise<{ allSize: number; start: number; limit: number; result: ClashTest[]; size: number }> {
|
|
535
|
+
const searchParams = new URLSearchParams();
|
|
536
|
+
if (start > 0) searchParams.set("start", start.toString());
|
|
537
|
+
if (limit > 0) searchParams.set("limit", limit.toString());
|
|
538
|
+
if (name) searchParams.set("name", name);
|
|
539
|
+
if (ids) {
|
|
540
|
+
if (Array.isArray(ids)) ids = ids.join("|");
|
|
541
|
+
if (typeof ids === "string") ids = ids.trim();
|
|
542
|
+
if (ids) searchParams.set("id", ids);
|
|
543
|
+
}
|
|
544
|
+
if (sortByDesc !== undefined) searchParams.set("sortBy", sortByDesc ? "desc" : "asc");
|
|
545
|
+
if (sortField) searchParams.set("sortField", sortField);
|
|
546
|
+
|
|
547
|
+
let queryString = searchParams.toString();
|
|
548
|
+
if (queryString) queryString = "?" + queryString;
|
|
549
|
+
|
|
550
|
+
return this.internalGet(`/clashes${queryString}`)
|
|
551
|
+
.then((response) => response.json())
|
|
552
|
+
.then((tests) => {
|
|
553
|
+
return {
|
|
554
|
+
...tests,
|
|
555
|
+
result: tests.result.map((data) => new ClashTest(data, this.path, this.httpClient)),
|
|
556
|
+
};
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/**
|
|
561
|
+
* Returns the assembly clash test information.
|
|
562
|
+
*
|
|
563
|
+
* @async
|
|
564
|
+
* @param testId - Test ID.
|
|
565
|
+
*/
|
|
566
|
+
getClashTest(testId: string): Promise<ClashTest> {
|
|
567
|
+
return this.internalGet(`/clashes/${testId}`)
|
|
568
|
+
.then((response) => response.json())
|
|
569
|
+
.then((data) => new ClashTest(data, this.path, this.httpClient));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Create assembly clash test. Assembly must be in a `done` state, otherwise the test will fail.
|
|
574
|
+
*
|
|
575
|
+
* @async
|
|
576
|
+
* @param name - Test name.
|
|
577
|
+
* @param selectionTypeA - The type of first selection set for clash detection. Can be `all`,
|
|
578
|
+
* `handles`, `models` or `searchquery`.
|
|
579
|
+
* @param selectionTypeB - The type of second selection set for clash detection. Can be
|
|
580
|
+
* `all`, `handles`, `models` or `searchquery`.
|
|
581
|
+
* @param selectionSetA - First selection set for clash detection.
|
|
582
|
+
* @param selectionSetB - Second selection set for clash detection.
|
|
583
|
+
* @param params - An object containing test parameters.
|
|
584
|
+
* @param params.tolerance - The distance of separation between entities at which test begins
|
|
585
|
+
* detecting clashes.
|
|
586
|
+
* @param params.clearance - The type of the clashes that the test detects: `true` for
|
|
587
|
+
* `Сlearance clash` or `false` for `Hard clash`.
|
|
588
|
+
* @param params.waitForDone - Wait for test to complete.
|
|
589
|
+
* @param params.timeout - The time, in milliseconds that the function should wait test. If
|
|
590
|
+
* test is not complete during this time, the `TimeoutError` exception will be thrown.
|
|
591
|
+
* @param params.interval - The time, in milliseconds, the function should delay in between
|
|
592
|
+
* checking test status.
|
|
593
|
+
* @param params.signal- An <a
|
|
594
|
+
* href="https://developer.mozilla.org/docs/Web/API/AbortController">AbortController</a>
|
|
595
|
+
* signal object instance, which can be used to abort waiting as desired.
|
|
596
|
+
*/
|
|
597
|
+
createClashTest(
|
|
598
|
+
name: string,
|
|
599
|
+
selectionTypeA: string,
|
|
600
|
+
selectionTypeB: string,
|
|
601
|
+
selectionSetA?: string | string[],
|
|
602
|
+
selectionSetB?: string | string[],
|
|
603
|
+
params?: {
|
|
604
|
+
tolerance?: number | string;
|
|
605
|
+
clearance?: boolean;
|
|
606
|
+
waitForDone?: boolean;
|
|
607
|
+
timeout?: number;
|
|
608
|
+
interval?: number;
|
|
609
|
+
signal?: AbortSignal;
|
|
610
|
+
}
|
|
611
|
+
): Promise<ClashTest> {
|
|
612
|
+
const { tolerance, clearance, waitForDone } = params ?? {};
|
|
613
|
+
if (!Array.isArray(selectionSetA)) selectionSetA = [selectionSetA];
|
|
614
|
+
if (!Array.isArray(selectionSetB)) selectionSetB = [selectionSetB];
|
|
615
|
+
|
|
616
|
+
return this.internalPost("/clashes", {
|
|
617
|
+
name,
|
|
618
|
+
selectionTypeA,
|
|
619
|
+
selectionTypeB,
|
|
620
|
+
selectionSetA,
|
|
621
|
+
selectionSetB,
|
|
622
|
+
tolerance,
|
|
623
|
+
clearance,
|
|
624
|
+
})
|
|
625
|
+
.then((response) => response.json())
|
|
626
|
+
.then((data) => new ClashTest(data, this.path, this.httpClient))
|
|
627
|
+
.then((result) => (waitForDone ? result.waitForDone(params) : result));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Delete assembly clash test.
|
|
632
|
+
*
|
|
633
|
+
* @async
|
|
634
|
+
* @param testId - Test ID.
|
|
635
|
+
* @returns Returns the raw data of a deleted test.
|
|
636
|
+
*/
|
|
637
|
+
deleteClashTest(testId: string): Promise<any> {
|
|
638
|
+
return this.internalDelete(`/clashes/${testId}`).then((response) => response.json());
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Reserved for future use
|
|
642
|
+
|
|
643
|
+
updateVersion(
|
|
644
|
+
files?: string[],
|
|
645
|
+
params: {
|
|
646
|
+
waitForDone?: boolean;
|
|
647
|
+
timeout?: number;
|
|
648
|
+
interval?: number;
|
|
649
|
+
signal?: AbortSignal;
|
|
650
|
+
onProgress?: (progress: number, file: globalThis.File) => void;
|
|
651
|
+
} = {
|
|
652
|
+
waitForDone: false,
|
|
653
|
+
}
|
|
654
|
+
): Promise<Assembly> {
|
|
655
|
+
return Promise.reject(new Error("Assembly version support will be implemeted in a future release"));
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
getVersions(): Promise<Assembly[] | undefined> {
|
|
659
|
+
return Promise.resolve(undefined);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
getVersion(version: number): Promise<Assembly> {
|
|
663
|
+
return Promise.reject(new FetchError(404));
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
deleteVersion(version: number): Promise<any> {
|
|
667
|
+
return Promise.reject(new FetchError(404));
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
setActiveVersion(version: number) {
|
|
671
|
+
return this.update({ activeVersion: version });
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
useVersion(version?: number) {
|
|
675
|
+
this._useVersion = undefined;
|
|
676
|
+
return this;
|
|
677
|
+
}
|
|
678
|
+
}
|