@inweb/client 25.2.2

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.
Files changed (218) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +70 -0
  3. package/dist/client.js +21126 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/client.min.js +1 -0
  6. package/dist/client.module.js +7151 -0
  7. package/dist/client.module.js.map +1 -0
  8. package/lib/Api/Assembly.d.ts +339 -0
  9. package/lib/Api/ClashTest.d.ts +176 -0
  10. package/lib/Api/Client.d.ts +452 -0
  11. package/lib/Api/ClientEvents.d.ts +29 -0
  12. package/lib/Api/File.d.ts +568 -0
  13. package/lib/Api/HttpClient.d.ts +13 -0
  14. package/lib/Api/IAssembly.d.ts +14 -0
  15. package/lib/Api/IFile.d.ts +46 -0
  16. package/lib/Api/IHttpClient.d.ts +11 -0
  17. package/lib/Api/IUser.d.ts +11 -0
  18. package/lib/Api/Job.d.ts +142 -0
  19. package/lib/Api/Member.d.ts +85 -0
  20. package/lib/Api/Model.d.ts +147 -0
  21. package/lib/Api/Permission.d.ts +93 -0
  22. package/lib/Api/Project.d.ts +247 -0
  23. package/lib/Api/Role.d.ts +82 -0
  24. package/lib/Api/User.d.ts +197 -0
  25. package/lib/Api/impl/FetchError.d.ts +18 -0
  26. package/lib/Api/impl/Utils.d.ts +33 -0
  27. package/lib/Api/impl/http.d.ts +67 -0
  28. package/lib/ConvetMath.d.ts +29 -0
  29. package/lib/Viewer/CanvasEvents.d.ts +2 -0
  30. package/lib/Viewer/Commands/ApplyModelTransform.d.ts +2 -0
  31. package/lib/Viewer/Commands/ClearMarkup.d.ts +2 -0
  32. package/lib/Viewer/Commands/ClearSlices.d.ts +2 -0
  33. package/lib/Viewer/Commands/CreatePreview.d.ts +2 -0
  34. package/lib/Viewer/Commands/Explode.d.ts +2 -0
  35. package/lib/Viewer/Commands/GetDefaultViewPositions.d.ts +2 -0
  36. package/lib/Viewer/Commands/GetModels.d.ts +2 -0
  37. package/lib/Viewer/Commands/GetSelected.d.ts +2 -0
  38. package/lib/Viewer/Commands/HideSelected.d.ts +2 -0
  39. package/lib/Viewer/Commands/IsolateSelected.d.ts +2 -0
  40. package/lib/Viewer/Commands/RegenerateAll.d.ts +2 -0
  41. package/lib/Viewer/Commands/ResetView.d.ts +2 -0
  42. package/lib/Viewer/Commands/SelectModel.d.ts +2 -0
  43. package/lib/Viewer/Commands/SetActiveDragger.d.ts +2 -0
  44. package/lib/Viewer/Commands/SetDefaultViewPosition.d.ts +2 -0
  45. package/lib/Viewer/Commands/SetMarkupColor.d.ts +2 -0
  46. package/lib/Viewer/Commands/SetSelected.d.ts +2 -0
  47. package/lib/Viewer/Commands/ShowAll.d.ts +2 -0
  48. package/lib/Viewer/Commands/Unselect.d.ts +2 -0
  49. package/lib/Viewer/Commands/ZoomToExtents.d.ts +2 -0
  50. package/lib/Viewer/Commands/ZoomToObjects.d.ts +2 -0
  51. package/lib/Viewer/Commands/ZoomToSelected.d.ts +2 -0
  52. package/lib/Viewer/Commands.d.ts +3 -0
  53. package/lib/Viewer/Draggers/Actions/OrbitAction.d.ts +22 -0
  54. package/lib/Viewer/Draggers/Actions/PanAction.d.ts +18 -0
  55. package/lib/Viewer/Draggers/Actions/ZoomAction.d.ts +8 -0
  56. package/lib/Viewer/Draggers/Common/Geometry.d.ts +115 -0
  57. package/lib/Viewer/Draggers/Common/GestureManager.d.ts +41 -0
  58. package/lib/Viewer/Draggers/Common/OdBaseDragger.d.ts +54 -0
  59. package/lib/Viewer/Draggers/Common/OdaGeAction.d.ts +30 -0
  60. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.d.ts +31 -0
  61. package/lib/Viewer/Draggers/MeasureLineDragger/MeasureUtils.d.ts +20 -0
  62. package/lib/Viewer/Draggers/MeasureLineDragger/index.d.ts +24 -0
  63. package/lib/Viewer/Draggers/OdBaseCuttingPlaneDragger.d.ts +27 -0
  64. package/lib/Viewer/Draggers/OdCuttingPlaneXAxisDragger.d.ts +8 -0
  65. package/lib/Viewer/Draggers/OdCuttingPlaneYAxisDragger.d.ts +8 -0
  66. package/lib/Viewer/Draggers/OdCuttingPlaneZAxisDragger.d.ts +8 -0
  67. package/lib/Viewer/Draggers/OdOrbitDragger.d.ts +15 -0
  68. package/lib/Viewer/Draggers/OdPanDragger.d.ts +12 -0
  69. package/lib/Viewer/Draggers/OdZoomDragger.d.ts +12 -0
  70. package/lib/Viewer/Draggers/OdZoomWheelDragger.d.ts +11 -0
  71. package/lib/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.d.ts +19 -0
  72. package/lib/Viewer/Draggers/OdZoomWindowDragger/index.d.ts +14 -0
  73. package/lib/Viewer/Draggers/OdaLineDragger.d.ts +15 -0
  74. package/lib/Viewer/Draggers/OdaTextDragger.d.ts +16 -0
  75. package/lib/Viewer/Draggers/OdaWalkDragger.d.ts +30 -0
  76. package/lib/Viewer/Draggers/OrbitAroundBuildingDragger.d.ts +19 -0
  77. package/lib/Viewer/EventEmitter2.d.ts +54 -0
  78. package/lib/Viewer/ICommands.d.ts +25 -0
  79. package/lib/Viewer/IEventEmitter2.d.ts +13 -0
  80. package/lib/Viewer/IViewer.d.ts +27 -0
  81. package/lib/Viewer/Loaders/BaseLoader.d.ts +11 -0
  82. package/lib/Viewer/Loaders/LoaderFactory.d.ts +10 -0
  83. package/lib/Viewer/Loaders/TCSLoader.d.ts +5 -0
  84. package/lib/Viewer/Loaders/UpdaterController.d.ts +15 -0
  85. package/lib/Viewer/Loaders/VsfXLoader.d.ts +5 -0
  86. package/lib/Viewer/Loaders/VsfXPartialLoader.d.ts +5 -0
  87. package/lib/Viewer/Markup/Api/IMarkupArrow.d.ts +12 -0
  88. package/lib/Viewer/Markup/Api/IMarkupColorable.d.ts +5 -0
  89. package/lib/Viewer/Markup/Api/IMarkupEllipse.d.ts +15 -0
  90. package/lib/Viewer/Markup/Api/IMarkupImage.d.ts +15 -0
  91. package/lib/Viewer/Markup/Api/IMarkupLine.d.ts +11 -0
  92. package/lib/Viewer/Markup/Api/IMarkupObject.d.ts +12 -0
  93. package/lib/Viewer/Markup/Api/IMarkupRectangle.d.ts +15 -0
  94. package/lib/Viewer/Markup/Api/IMarkupText.d.ts +13 -0
  95. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaArrow.d.ts +32 -0
  96. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.d.ts +40 -0
  97. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaImage.d.ts +36 -0
  98. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaLine.d.ts +32 -0
  99. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.d.ts +38 -0
  100. package/lib/Viewer/Markup/Api/Impl/Konva/KonvaText.d.ts +37 -0
  101. package/lib/Viewer/Markup/IMarkup.d.ts +38 -0
  102. package/lib/Viewer/Markup/Impl/Konva/KonvaMarkup.d.ts +63 -0
  103. package/lib/Viewer/Markup/Impl/Konva/MarkupColor.d.ts +19 -0
  104. package/lib/Viewer/Markup/Impl/Visualize/VisualizeMarkup.d.ts +33 -0
  105. package/lib/Viewer/Markup/MarkupFactory.d.ts +7 -0
  106. package/lib/Viewer/Options.d.ts +228 -0
  107. package/lib/Viewer/OptionsEvents.d.ts +26 -0
  108. package/lib/Viewer/Viewer.d.ts +353 -0
  109. package/lib/Viewer/ViewerCommands.d.ts +23 -0
  110. package/lib/Viewer/ViewerEvents.d.ts +601 -0
  111. package/lib/Viewer/utils.d.ts +4 -0
  112. package/lib/index.d.ts +24 -0
  113. package/package.json +32 -0
  114. package/src/Api/Assembly.ts +678 -0
  115. package/src/Api/ClashTest.ts +290 -0
  116. package/src/Api/Client.ts +816 -0
  117. package/src/Api/ClientEvents.ts +31 -0
  118. package/src/Api/File.ts +962 -0
  119. package/src/Api/HttpClient.ts +73 -0
  120. package/src/Api/IAssembly.ts +37 -0
  121. package/src/Api/IFile.ts +74 -0
  122. package/src/Api/IHttpClient.ts +50 -0
  123. package/src/Api/IUser.ts +33 -0
  124. package/src/Api/Job.ts +253 -0
  125. package/src/Api/Member.ts +161 -0
  126. package/src/Api/Model.ts +259 -0
  127. package/src/Api/Permission.ts +173 -0
  128. package/src/Api/Project.ts +479 -0
  129. package/src/Api/Role.ts +158 -0
  130. package/src/Api/User.ts +357 -0
  131. package/src/Api/impl/FetchError.ts +48 -0
  132. package/src/Api/impl/Utils.ts +367 -0
  133. package/src/Api/impl/http.ts +92 -0
  134. package/src/ConvetMath.ts +372 -0
  135. package/src/Viewer/CanvasEvents.ts +41 -0
  136. package/src/Viewer/Commands/ApplyModelTransform.ts +70 -0
  137. package/src/Viewer/Commands/ClearMarkup.ts +28 -0
  138. package/src/Viewer/Commands/ClearSlices.ts +27 -0
  139. package/src/Viewer/Commands/CreatePreview.ts +33 -0
  140. package/src/Viewer/Commands/Explode.ts +38 -0
  141. package/src/Viewer/Commands/GetDefaultViewPositions.ts +36 -0
  142. package/src/Viewer/Commands/GetModels.ts +43 -0
  143. package/src/Viewer/Commands/GetSelected.ts +58 -0
  144. package/src/Viewer/Commands/HideSelected.ts +37 -0
  145. package/src/Viewer/Commands/IsolateSelected.ts +37 -0
  146. package/src/Viewer/Commands/RegenerateAll.ts +37 -0
  147. package/src/Viewer/Commands/ResetView.ts +43 -0
  148. package/src/Viewer/Commands/SelectModel.ts +52 -0
  149. package/src/Viewer/Commands/SetActiveDragger.ts +29 -0
  150. package/src/Viewer/Commands/SetDefaultViewPosition.ts +50 -0
  151. package/src/Viewer/Commands/SetMarkupColor.ts +29 -0
  152. package/src/Viewer/Commands/SetSelected.ts +47 -0
  153. package/src/Viewer/Commands/ShowAll.ts +37 -0
  154. package/src/Viewer/Commands/Unselect.ts +37 -0
  155. package/src/Viewer/Commands/ZoomToExtents.ts +43 -0
  156. package/src/Viewer/Commands/ZoomToObjects.ts +47 -0
  157. package/src/Viewer/Commands/ZoomToSelected.ts +39 -0
  158. package/src/Viewer/Commands.ts +81 -0
  159. package/src/Viewer/Draggers/Actions/OrbitAction.ts +250 -0
  160. package/src/Viewer/Draggers/Actions/PanAction.ts +102 -0
  161. package/src/Viewer/Draggers/Actions/ZoomAction.ts +45 -0
  162. package/src/Viewer/Draggers/Common/Geometry.ts +152 -0
  163. package/src/Viewer/Draggers/Common/GestureManager.ts +263 -0
  164. package/src/Viewer/Draggers/Common/OdBaseDragger.ts +270 -0
  165. package/src/Viewer/Draggers/Common/OdaGeAction.ts +146 -0
  166. package/src/Viewer/Draggers/MeasureLineDragger/MeasureLineItem.ts +248 -0
  167. package/src/Viewer/Draggers/MeasureLineDragger/MeasureUtils.ts +182 -0
  168. package/src/Viewer/Draggers/MeasureLineDragger/index.ts +166 -0
  169. package/src/Viewer/Draggers/OdBaseCuttingPlaneDragger.ts +182 -0
  170. package/src/Viewer/Draggers/OdCuttingPlaneXAxisDragger.ts +53 -0
  171. package/src/Viewer/Draggers/OdCuttingPlaneYAxisDragger.ts +53 -0
  172. package/src/Viewer/Draggers/OdCuttingPlaneZAxisDragger.ts +53 -0
  173. package/src/Viewer/Draggers/OdOrbitDragger.ts +70 -0
  174. package/src/Viewer/Draggers/OdPanDragger.ts +62 -0
  175. package/src/Viewer/Draggers/OdZoomDragger.ts +59 -0
  176. package/src/Viewer/Draggers/OdZoomWheelDragger.ts +103 -0
  177. package/src/Viewer/Draggers/OdZoomWindowDragger/OdSelectionFrame.ts +123 -0
  178. package/src/Viewer/Draggers/OdZoomWindowDragger/index.ts +75 -0
  179. package/src/Viewer/Draggers/OdaLineDragger.ts +80 -0
  180. package/src/Viewer/Draggers/OdaTextDragger.ts +118 -0
  181. package/src/Viewer/Draggers/OdaWalkDragger.ts +278 -0
  182. package/src/Viewer/Draggers/OrbitAroundBuildingDragger.ts +184 -0
  183. package/src/Viewer/EventEmitter2.ts +116 -0
  184. package/src/Viewer/ICommands.ts +53 -0
  185. package/src/Viewer/IEventEmitter2.ts +36 -0
  186. package/src/Viewer/IViewer.ts +55 -0
  187. package/src/Viewer/Loaders/BaseLoader.ts +40 -0
  188. package/src/Viewer/Loaders/LoaderFactory.ts +44 -0
  189. package/src/Viewer/Loaders/TCSLoader.ts +82 -0
  190. package/src/Viewer/Loaders/UpdaterController.ts +36 -0
  191. package/src/Viewer/Loaders/VsfXLoader.ts +87 -0
  192. package/src/Viewer/Loaders/VsfXPartialLoader.ts +208 -0
  193. package/src/Viewer/Markup/Api/IMarkupArrow.ts +15 -0
  194. package/src/Viewer/Markup/Api/IMarkupColorable.ts +4 -0
  195. package/src/Viewer/Markup/Api/IMarkupEllipse.ts +15 -0
  196. package/src/Viewer/Markup/Api/IMarkupImage.ts +15 -0
  197. package/src/Viewer/Markup/Api/IMarkupLine.ts +10 -0
  198. package/src/Viewer/Markup/Api/IMarkupObject.ts +15 -0
  199. package/src/Viewer/Markup/Api/IMarkupRectangle.ts +15 -0
  200. package/src/Viewer/Markup/Api/IMarkupText.ts +12 -0
  201. package/src/Viewer/Markup/Api/Impl/Konva/KonvaArrow.ts +119 -0
  202. package/src/Viewer/Markup/Api/Impl/Konva/KonvaEllipse.ts +113 -0
  203. package/src/Viewer/Markup/Api/Impl/Konva/KonvaImage.ts +121 -0
  204. package/src/Viewer/Markup/Api/Impl/Konva/KonvaLine.ts +99 -0
  205. package/src/Viewer/Markup/Api/Impl/Konva/KonvaRectangle.ts +113 -0
  206. package/src/Viewer/Markup/Api/Impl/Konva/KonvaText.ts +104 -0
  207. package/src/Viewer/Markup/IMarkup.ts +39 -0
  208. package/src/Viewer/Markup/Impl/Konva/KonvaMarkup.ts +872 -0
  209. package/src/Viewer/Markup/Impl/Konva/MarkupColor.ts +39 -0
  210. package/src/Viewer/Markup/Impl/Visualize/VisualizeMarkup.ts +273 -0
  211. package/src/Viewer/Markup/MarkupFactory.ts +32 -0
  212. package/src/Viewer/Options.ts +502 -0
  213. package/src/Viewer/OptionsEvents.ts +28 -0
  214. package/src/Viewer/Viewer.ts +1109 -0
  215. package/src/Viewer/ViewerCommands.ts +45 -0
  216. package/src/Viewer/ViewerEvents.ts +700 -0
  217. package/src/Viewer/utils.ts +74 -0
  218. package/src/index.ts +48 -0
@@ -0,0 +1,479 @@
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 { IShortUserDescription } from "./IUser";
26
+ import { Role } from "./Role";
27
+ import { Member } from "./Member";
28
+ import { json, text, userFullName, userInitials } from "./impl/Utils";
29
+
30
+ /**
31
+ * Projects are used to collaborate on models and track issues.
32
+ */
33
+ export class Project {
34
+ private _data: any;
35
+ protected httpClient: IHttpClient;
36
+
37
+ /**
38
+ * @param data - An object that implements project data storage.
39
+ * @param httpClient - Http client.
40
+ */
41
+ constructor(data: any, httpClient: IHttpClient) {
42
+ this.httpClient = httpClient;
43
+ this.data = data;
44
+ }
45
+
46
+ protected internalGet(relativePath: string) {
47
+ return this.httpClient.get(`/projects/${this.id}${relativePath}`);
48
+ }
49
+
50
+ protected internalPost(
51
+ relativePath: string,
52
+ body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
53
+ ) {
54
+ return this.httpClient.post(`/projects/${this.id}${relativePath}`, body);
55
+ }
56
+
57
+ protected internalPut(
58
+ relativePath: string,
59
+ body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null
60
+ ) {
61
+ return this.httpClient.put(`/projects/${this.id}${relativePath}`, body);
62
+ }
63
+
64
+ protected internalDelete(relativePath: string) {
65
+ return this.httpClient.delete(`/projects/${this.id}${relativePath}`);
66
+ }
67
+
68
+ /**
69
+ * Project features the user has access to.
70
+ *
71
+ * @property {string[]} project_actions - Actions are allowed to be performed: `update`,
72
+ * `createTopic`, `createDocument`.
73
+ * @readonly
74
+ */
75
+ get authorization(): any {
76
+ return this.data.authorization;
77
+ }
78
+
79
+ /**
80
+ * Project creation time (UTC) in the format specified in <a
81
+ * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
82
+ *
83
+ * @readonly
84
+ */
85
+ get createdAt(): string {
86
+ return this.data.createdAt;
87
+ }
88
+
89
+ /**
90
+ * Project custom fields object, to store custom data.
91
+ */
92
+ get customFields(): any {
93
+ return this.data.customFields;
94
+ }
95
+
96
+ set customFields(value: any) {
97
+ this.data.customFields = value;
98
+ }
99
+
100
+ /**
101
+ * Raw project data received from the server.
102
+ *
103
+ * @readonly
104
+ */
105
+ get data(): any {
106
+ return this._data;
107
+ }
108
+
109
+ private set data(value: any) {
110
+ this._data = value;
111
+ this._data.previewUrl = value.avatarUrl ? `${this.httpClient.serverUrl}/projects/${this._data.id}/preview` : "";
112
+ this._data.owner.avatarUrl = `${this.httpClient.serverUrl}/users/${this._data.owner.userId}/avatar`;
113
+ this._data.owner.fullName = userFullName(this._data.owner);
114
+ this._data.owner.initials = userInitials(this._data.owner.fullName);
115
+ }
116
+
117
+ /**
118
+ * Project description.
119
+ */
120
+ get description(): string {
121
+ return this.data.description;
122
+ }
123
+
124
+ set description(value: string) {
125
+ this.data.description = value;
126
+ }
127
+
128
+ /**
129
+ * Project end date in the format specified in <a
130
+ * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
131
+ */
132
+ get endDate(): string {
133
+ return this.data.endDate;
134
+ }
135
+
136
+ set endDate(value: string | Date) {
137
+ this.data.endDate = value instanceof Date ? value.toISOString() : value;
138
+ }
139
+
140
+ /**
141
+ * Unique project ID.
142
+ *
143
+ * @readonly
144
+ */
145
+ get id(): string {
146
+ return this.data.id;
147
+ }
148
+
149
+ /**
150
+ * The number of members in the project.
151
+ *
152
+ * @readonly
153
+ */
154
+ get memberCount(): number {
155
+ return this.data.memberCount;
156
+ }
157
+
158
+ /**
159
+ * The number of models in the project.
160
+ *
161
+ * @readonly
162
+ */
163
+ get modelCount(): number {
164
+ return this.data.modelCount;
165
+ }
166
+
167
+ /**
168
+ * Project name.
169
+ */
170
+ get name(): string {
171
+ return this.data.name;
172
+ }
173
+
174
+ set name(value: string) {
175
+ this.data.name = value;
176
+ }
177
+
178
+ /**
179
+ * Project owner information.
180
+ *
181
+ * @property {string} userId - User ID.
182
+ * @property {string} userName - User name.
183
+ * @property {string} name - First name.
184
+ * @property {string} lastName - Last name.
185
+ * @property {string} fullName - Full name.
186
+ * @property {string} initials - Initials.
187
+ * @property {string} email - User email.
188
+ * @property {string} avatarUrl - User avatar image URL.
189
+ * @readonly
190
+ */
191
+ get owner(): IShortUserDescription {
192
+ return this.data.owner;
193
+ }
194
+
195
+ /**
196
+ * Project preview image URL. Use [setPreview()]{@link Project#setPreview} to change preview image.
197
+ *
198
+ * @readonly
199
+ */
200
+ get previewUrl(): string {
201
+ return this._data.previewUrl;
202
+ }
203
+
204
+ /**
205
+ * `true` if project is public (shared) project.
206
+ */
207
+ get public(): boolean {
208
+ return this.data.public;
209
+ }
210
+
211
+ set public(value: boolean) {
212
+ this.data.public = value;
213
+ }
214
+
215
+ /**
216
+ * Project start date in the format specified in <a
217
+ * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
218
+ */
219
+ get startDate(): string {
220
+ return this.data.startDate;
221
+ }
222
+
223
+ set startDate(value: string | Date) {
224
+ this.data.startDate = value instanceof Date ? value.toISOString() : value;
225
+ }
226
+
227
+ /**
228
+ * The number of topics in the project.
229
+ *
230
+ * @readonly
231
+ */
232
+ get topicCount(): number {
233
+ return this.data.topicCount;
234
+ }
235
+
236
+ /**
237
+ * Project last update time (UTC) in the format specified in <a
238
+ * href="https://www.wikipedia.org/wiki/ISO_8601" target="_blank">ISO 8601</a>.
239
+ *
240
+ * @readonly
241
+ */
242
+ get updatedAt(): string {
243
+ return this.data.updatedAt;
244
+ }
245
+
246
+ /**
247
+ * Refresh project data.
248
+ *
249
+ * @async
250
+ */
251
+ async checkout(): Promise<Project> {
252
+ this.data = await json(this.internalGet(""));
253
+ return this;
254
+ }
255
+
256
+ /**
257
+ * Update project data on the server.
258
+ *
259
+ * @async
260
+ * @param data - Raw project data.
261
+ */
262
+ async update(data: any): Promise<Project> {
263
+ this.data = await json(this.internalPut("", data));
264
+ return this;
265
+ }
266
+
267
+ /**
268
+ * Delete the project from the server.
269
+ *
270
+ * @async
271
+ * @returns Returns the raw data of a deleted project.
272
+ */
273
+ delete(): Promise<any> {
274
+ return text(this.internalDelete("")).then((text) => {
275
+ // TODO fix for server 23.5 and below
276
+ try {
277
+ return JSON.parse(text);
278
+ } catch {
279
+ return { id: this.id };
280
+ }
281
+ });
282
+ }
283
+
284
+ /**
285
+ * Save project data changes to the server. Call this method to update project data on the
286
+ * server after any changes.
287
+ *
288
+ * @async
289
+ */
290
+ save(): Promise<Project> {
291
+ return this.update(this.data);
292
+ }
293
+
294
+ /**
295
+ * Set or remove the project preview.
296
+ *
297
+ * @async
298
+ * @param image - Preview image. Can be a <a
299
+ * href="https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/Data_URIs"
300
+ * target="_blank">Data URL</a> string, <a
301
+ * href="https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer"
302
+ * target="_blank">ArrayBuffer</a>, <a
303
+ * href="https://developer.mozilla.org/docs/Web/API/Blob/Blob" target="_blank">Blob</a> or
304
+ * Web API <a href="https://developer.mozilla.org/docs/Web/API/File"
305
+ * target="_blank">File</a> object. Setting the `image` to `null` will remove the preview.
306
+ */
307
+
308
+ async setPreview(image?: ArrayBuffer | Blob | globalThis.File | FormData | string | null) {
309
+ if (image) {
310
+ this.data = await json(this.internalPost("/preview", image));
311
+ } else {
312
+ this.data = await json(this.internalDelete("/preview"));
313
+ }
314
+ return this;
315
+ }
316
+
317
+ /**
318
+ * Returns a list of project roles. Project {@link Member | members} have different abilities
319
+ * depending on the role they have in a project.
320
+ *
321
+ * @async
322
+ */
323
+ getRoles(): Promise<Role[]> {
324
+ return json(this.internalGet("/roles")).then((array) =>
325
+ array.map((data) => new Role(data, this.id, this.httpClient))
326
+ );
327
+ }
328
+
329
+ /**
330
+ * Returns the role information.
331
+ *
332
+ * @async
333
+ * @param name - Role name.
334
+ */
335
+ getRole(name: string): Promise<Role> {
336
+ return json(this.internalGet(`/roles/${name}`)).then((data) => new Role(data, this.id, this.httpClient));
337
+ }
338
+
339
+ /**
340
+ * Create a new project role.
341
+ *
342
+ * @async
343
+ * @param name - Role name.
344
+ * @param description - Role description.
345
+ * @param permissions - Actions are allowed to be performed. See
346
+ * {@link Role#permissions | Role.permissions} for more details.
347
+ */
348
+ createRole(name: string, description: string, permissions: any): Promise<Role> {
349
+ return json(
350
+ this.internalPost("/roles", {
351
+ name,
352
+ description,
353
+ permissions: permissions || {},
354
+ })
355
+ ).then((data) => new Role(data, this.id, this.httpClient));
356
+ }
357
+
358
+ /**
359
+ * Delete project role.
360
+ *
361
+ * @async
362
+ * @param name - Role name.
363
+ * @returns Returns the raw data of a deleted role.
364
+ */
365
+ deleteRole(name: string): Promise<any> {
366
+ return json(this.internalDelete(`/roles/${name}`));
367
+ }
368
+
369
+ /**
370
+ * Returns a list of project members.
371
+ *
372
+ * @async
373
+ */
374
+ getMembers(): Promise<Member[]> {
375
+ return json(this.internalGet("/members")).then((array) =>
376
+ array.map((data) => new Member(data, this.id, this.httpClient))
377
+ );
378
+ }
379
+
380
+ /**
381
+ * Returns the member information.
382
+ *
383
+ * @async
384
+ * @param memberId - Member ID.
385
+ */
386
+ getMember(memberId: string): Promise<Member> {
387
+ return json(this.internalGet(`/members/${memberId}`)).then((data) => new Member(data, this.id, this.httpClient));
388
+ }
389
+
390
+ /**
391
+ * Add a user to the project to become a member and have permission to perform actions.
392
+ *
393
+ * @async
394
+ * @param userId - User ID.
395
+ * @param role - User role from the list of project roles.
396
+ */
397
+ addMember(userId: string, role: string): Promise<Member> {
398
+ return json(this.internalPost("/members", { userId, role })).then(
399
+ (data) => new Member(data, this.id, this.httpClient)
400
+ );
401
+ }
402
+
403
+ /**
404
+ * Remove a member from a project.
405
+ *
406
+ * @async
407
+ * @param memberId - Member ID.
408
+ * @returns Returns the raw data of a deleted member.
409
+ */
410
+ removeMember(memberId: string): Promise<any> {
411
+ return json(this.internalDelete(`/members/${memberId}`));
412
+ }
413
+
414
+ /**
415
+ * Information about the file (model) that can be reference in the project topics.
416
+ *
417
+ * @typedef {any} FileInformation
418
+ * @property {any[]} display_information - The list of fields to allow users to associate the
419
+ * file with a server model.
420
+ * @property {string} display_information.field_display_name - Field display name.
421
+ * @property {string} display_information.field_value - Field value.
422
+ * @property {any} file - The file reference object.
423
+ * @property {string} file.file_name - File name.
424
+ * @property {string} file.reference - File ID.
425
+ */
426
+
427
+ /**
428
+ * Returns a list of project files. To add a file to this list, create a `project` permission
429
+ * on the file using {@link File#createPermission | File.createPermission()}.
430
+ *
431
+ * @async
432
+ */
433
+ getFilesInformation(): Promise<any[]> {
434
+ return json(this.httpClient.get(`/bcf/3.0/projects/${this.data.id}/files_information`)).then((items) => {
435
+ items.forEach((item) => {
436
+ const getFieldValue = (displayName: string) => {
437
+ return (item.display_information.find((x) => x.field_display_name === displayName) || {}).field_value;
438
+ };
439
+
440
+ const previewUrl = `${this.httpClient.serverUrl}/files/${item.file.reference}/preview`;
441
+ const ownerAvatarUrl = `${this.httpClient.serverUrl}/users/${getFieldValue("Owner")}/avatar`;
442
+
443
+ const ownerFirstName = getFieldValue("Owner First Name");
444
+ const ownerLastName = getFieldValue("Owner Last Name");
445
+ const ownerUserName = getFieldValue("Owner User Name");
446
+ const ownerFullName = userFullName(ownerFirstName, ownerLastName, ownerUserName);
447
+ const ownerInitials = userInitials(ownerFullName);
448
+
449
+ item.display_information.push({ field_display_name: "Preview URL", field_value: previewUrl });
450
+ item.display_information.push({ field_display_name: "Owner Avatar URL", field_value: ownerAvatarUrl });
451
+ item.display_information.push({ field_display_name: "Owner Full Name", field_value: ownerFullName });
452
+ item.display_information.push({ field_display_name: "Owner Initials", field_value: ownerInitials });
453
+
454
+ // updatedBy since 24.10
455
+
456
+ const updatedByAvatarUrl = `${this.httpClient.serverUrl}/users/${getFieldValue("Updated By")}/avatar`;
457
+
458
+ const updatedByFirstName = getFieldValue("Updated By First Name");
459
+ const updatedByLastName = getFieldValue("Updated By Last Name");
460
+ const updatedByUserName = getFieldValue("Updated By User Name");
461
+ const updatedByFullName = userFullName(updatedByFirstName, updatedByLastName, updatedByUserName);
462
+ const updatedByInitials = userInitials(updatedByFullName);
463
+
464
+ item.display_information.push({ field_display_name: "Updated By Avatar URL", field_value: updatedByAvatarUrl });
465
+ item.display_information.push({ field_display_name: "Updated By Full Name", field_value: updatedByFullName });
466
+ item.display_information.push({ field_display_name: "Updated By Initials", field_value: updatedByInitials });
467
+
468
+ // geometryType since 24.12
469
+
470
+ const geometry = getFieldValue("Geometry Status");
471
+ const geometryGltf = getFieldValue("GeometryGltf Status");
472
+ const geometryType = geometry === "done" ? "vsfx" : geometryGltf === "done" ? "gltf" : "";
473
+
474
+ item.display_information.push({ field_display_name: "Geometry Type", field_value: geometryType });
475
+ });
476
+ return items;
477
+ });
478
+ }
479
+ }
@@ -0,0 +1,158 @@
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 { json } from "./impl/Utils";
26
+
27
+ /**
28
+ * A roles determines what permissions {@link User | users} have on a {@link Project | project}.
29
+ */
30
+ export class Role {
31
+ private _data: any;
32
+ protected projectId: string;
33
+ protected httpClient: IHttpClient;
34
+
35
+ /**
36
+ * @param data - An object that implements role data storage.
37
+ * @param projectId - Owner project ID.
38
+ * @param httpClient - Http client.
39
+ */
40
+ constructor(data: any, projectId: string, httpClient: IHttpClient) {
41
+ this.httpClient = httpClient;
42
+ this.projectId = projectId;
43
+ this.data = data;
44
+ }
45
+
46
+ private internalGet() {
47
+ return this.httpClient.get(`/projects/${this.projectId}/roles/${this.name}`);
48
+ }
49
+
50
+ private internalPut(body?: ArrayBuffer | Blob | globalThis.File | FormData | object | string | null) {
51
+ return this.httpClient.put(`/projects/${this.projectId}/roles/${this.name}`, body);
52
+ }
53
+
54
+ private internalDelete() {
55
+ return this.httpClient.delete(`/projects/${this.projectId}/roles/${this.name}`);
56
+ }
57
+
58
+ /**
59
+ * Role description.
60
+ */
61
+ get description(): string {
62
+ return this.data.description;
63
+ }
64
+
65
+ set description(value: string) {
66
+ this._data.description = value;
67
+ }
68
+
69
+ /**
70
+ * Raw role data received from the server.
71
+ *
72
+ * @readonly
73
+ */
74
+ get data(): any {
75
+ return this._data;
76
+ }
77
+
78
+ set data(value: any) {
79
+ this._data = value;
80
+ }
81
+
82
+ /**
83
+ * Role name.
84
+ */
85
+ get name(): string {
86
+ return this.data.name;
87
+ }
88
+
89
+ set name(value: string) {
90
+ this._data.name = value;
91
+ }
92
+
93
+ /**
94
+ * Role actions are allowed to be performed.
95
+ *
96
+ * @property {string[]} projectActions - Actions are allowed to be performed at the project
97
+ * level: `update`, `createTopic`, `createDocument`.
98
+ * @property {string[]} topicActions - Actions are allowed to be performed at the topic
99
+ * level: `update`, `updateBimSnippet`, `updateRelatedTopics`, `updateDocumentReferences`,
100
+ * `updateFiles`, `createComment`, `createViewpoint`, `delete`.
101
+ * @property {string[]} commentActions - Actions are allowed to be performed at the comment
102
+ * level: `update`, `delete`.
103
+ * @property {string[]} viewpointActions - Actions are allowed to be performed at the
104
+ * viewpoint level: `delete`.
105
+ * @property {string[]} odaGroupActions - Actions are allowed to be performed at the members
106
+ * level: `update`, `delete`.
107
+ * @property {string[]} odaRoleActions - Actions are allowed to be performed at the roles
108
+ * level: `update`, `delete`.
109
+ */
110
+ get permissions(): any {
111
+ return this.data.permissions;
112
+ }
113
+
114
+ set permissions(value: any) {
115
+ this.data.permissions = value || {};
116
+ }
117
+
118
+ /**
119
+ * Refresh role data.
120
+ *
121
+ * @async
122
+ */
123
+ async checkout(): Promise<Role> {
124
+ this.data = await json(this.internalGet());
125
+ return this;
126
+ }
127
+
128
+ /**
129
+ * Update role data on the server.
130
+ *
131
+ * @async
132
+ * @param data - Raw role data.
133
+ */
134
+ async update(data: any): Promise<Role> {
135
+ this.data = await json(this.internalPut(data));
136
+ return this;
137
+ }
138
+
139
+ /**
140
+ * Delete a role from the project.
141
+ *
142
+ * @async
143
+ * @returns Returns the raw data of a deleted role.
144
+ */
145
+ delete(): Promise<any> {
146
+ return json(this.internalDelete());
147
+ }
148
+
149
+ /**
150
+ * Save role data changes to the server. Call this method to update role data on the server
151
+ * after any changes.
152
+ *
153
+ * @async
154
+ */
155
+ save(): Promise<Role> {
156
+ return this.update(this.data);
157
+ }
158
+ }