@shapediver/viewer.session-engine.session-engine 2.10.0 → 2.11.0

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 (44) hide show
  1. package/dist/implementation/OutputDelayException.js +5 -1
  2. package/dist/implementation/OutputDelayException.js.map +1 -1
  3. package/dist/implementation/OutputLoader.js +30 -26
  4. package/dist/implementation/OutputLoader.js.map +1 -1
  5. package/dist/implementation/SessionData.js +6 -2
  6. package/dist/implementation/SessionData.js.map +1 -1
  7. package/dist/implementation/SessionEngine.d.ts +13 -11
  8. package/dist/implementation/SessionEngine.d.ts.map +1 -1
  9. package/dist/implementation/SessionEngine.js +265 -236
  10. package/dist/implementation/SessionEngine.js.map +1 -1
  11. package/dist/implementation/SessionOutputData.js +6 -2
  12. package/dist/implementation/SessionOutputData.js.map +1 -1
  13. package/dist/implementation/SessionTreeNode.js +6 -2
  14. package/dist/implementation/SessionTreeNode.js.map +1 -1
  15. package/dist/implementation/dto/Export.js +17 -13
  16. package/dist/implementation/dto/Export.js.map +1 -1
  17. package/dist/implementation/dto/FileParameter.js +34 -7
  18. package/dist/implementation/dto/FileParameter.js.map +1 -1
  19. package/dist/implementation/dto/Output.d.ts +6 -6
  20. package/dist/implementation/dto/Output.d.ts.map +1 -1
  21. package/dist/implementation/dto/Output.js +19 -14
  22. package/dist/implementation/dto/Output.js.map +1 -1
  23. package/dist/implementation/dto/Parameter.js +60 -33
  24. package/dist/implementation/dto/Parameter.js.map +1 -1
  25. package/dist/index.js +20 -11
  26. package/dist/index.js.map +1 -1
  27. package/dist/interfaces/ISessionData.js +2 -1
  28. package/dist/interfaces/ISessionEngine.d.ts +6 -7
  29. package/dist/interfaces/ISessionEngine.d.ts.map +1 -1
  30. package/dist/interfaces/ISessionEngine.js +7 -5
  31. package/dist/interfaces/ISessionEngine.js.map +1 -1
  32. package/dist/interfaces/ISessionOutputData.js +2 -1
  33. package/dist/interfaces/ISessionTreeNode.js +2 -1
  34. package/dist/interfaces/dto/IExport.js +2 -1
  35. package/dist/interfaces/dto/IFileParameter.js +2 -1
  36. package/dist/interfaces/dto/IOutput.d.ts +1 -1
  37. package/dist/interfaces/dto/IOutput.d.ts.map +1 -1
  38. package/dist/interfaces/dto/IOutput.js +2 -1
  39. package/dist/interfaces/dto/IParameter.js +2 -1
  40. package/package.json +9 -9
  41. package/src/implementation/SessionEngine.ts +469 -406
  42. package/src/implementation/dto/Output.ts +16 -15
  43. package/src/interfaces/ISessionEngine.ts +49 -43
  44. package/src/interfaces/dto/IOutput.ts +1 -1
@@ -1,24 +1,65 @@
1
- import { HttpClient, HttpResponse, PerformanceEvaluator, UuidGenerator, SystemInfo, Logger, ShapeDiverViewerSessionError, ShapeDiverViewerError, Converter, SettingsEngine, EVENTTYPE, EventEngine, StateEngine, ShapeDiverViewerSettingsError, ShapeDiverGeometryBackendResponseError, ShapeDiverGeometryBackendRequestError } from '@shapediver/viewer.shared.services'
2
-
3
- import { OutputDelayException } from './OutputDelayException'
4
- import { OutputLoader, OutputLoaderTaskEventInfo } from './OutputLoader'
5
- import { SessionTreeNode } from './SessionTreeNode'
6
- import { ISessionEngine, ISettingsSections, PARAMETER_TYPE } from '../interfaces/ISessionEngine'
7
- import { SessionData } from './SessionData'
8
- import { create, ShapeDiverError as ShapeDiverBackendError, ShapeDiverResponseErrorType, ShapeDiverRequestGltfUploadQueryConversion, ShapeDiverResponseDto, ShapeDiverResponseError, ShapeDiverResponseExport, ShapeDiverResponseExportDefinitionType, ShapeDiverResponseOutput, ShapeDiverResponseParameter, ShapeDiverSdk, ShapeDiverSdkConfigType, ShapeDiverResponseModelComputationStatus, ShapeDiverRequestError, isGBResponseError } from '@shapediver/sdk.geometry-api-sdk-v2'
9
- import { ISessionTreeNode } from '../interfaces/ISessionTreeNode'
10
- import { ITree, ITreeNode, Tree, TreeNode } from '@shapediver/viewer.shared.node-tree'
11
- import { ITaskEvent, TASK_TYPE } from '@shapediver/viewer.shared.types'
12
- import { FileParameter } from './dto/FileParameter'
13
- import { IFileParameter } from '../interfaces/dto/IFileParameter'
14
- import { IExport } from '../interfaces/dto/IExport'
15
- import { IParameter } from '../interfaces/dto/IParameter'
16
- import { IOutput } from '../interfaces/dto/IOutput'
17
- import { Parameter } from './dto/Parameter'
18
- import { vec3 } from 'gl-matrix'
19
- import { Export } from './dto/Export'
20
- import { Output } from './dto/Output'
21
- import { convert, ISettings, latestVersion, validate, versions } from '@shapediver/viewer.settings'
1
+ import {
2
+ convert,
3
+ ISettings,
4
+ latestVersion,
5
+ validate,
6
+ versions
7
+ } from '@shapediver/viewer.settings';
8
+ import {
9
+ create,
10
+ isGBResponseError,
11
+ ShapeDiverError as ShapeDiverBackendError,
12
+ ShapeDiverRequestConfigure,
13
+ ShapeDiverRequestCustomization,
14
+ ShapeDiverRequestExport,
15
+ ShapeDiverRequestGltfUploadQueryConversion,
16
+ ShapeDiverResponseDto,
17
+ ShapeDiverResponseErrorType,
18
+ ShapeDiverResponseExport,
19
+ ShapeDiverResponseExportDefinitionType,
20
+ ShapeDiverResponseModelComputationStatus,
21
+ ShapeDiverResponseOutput,
22
+ ShapeDiverSdk,
23
+ ShapeDiverSdkConfigType
24
+ } from '@shapediver/sdk.geometry-api-sdk-v2';
25
+ import {
26
+ EventEngine,
27
+ EVENTTYPE,
28
+ HttpClient,
29
+ HttpResponse,
30
+ Logger,
31
+ PerformanceEvaluator,
32
+ SettingsEngine,
33
+ ShapeDiverViewerError,
34
+ ShapeDiverViewerSessionError,
35
+ ShapeDiverViewerSettingsError,
36
+ StateEngine,
37
+ SystemInfo,
38
+ UuidGenerator
39
+ } from '@shapediver/viewer.shared.services';
40
+ import { Export } from './dto/Export';
41
+ import { FileParameter } from './dto/FileParameter';
42
+ import { IExport } from '../interfaces/dto/IExport';
43
+ import { IFileParameter } from '../interfaces/dto/IFileParameter';
44
+ import { IOutput } from '../interfaces/dto/IOutput';
45
+ import { IParameter } from '../interfaces/dto/IParameter';
46
+ import { ISessionEngine, ISettingsSections, PARAMETER_TYPE } from '../interfaces/ISessionEngine';
47
+ import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
48
+ import { ITaskEvent, TASK_TYPE } from '@shapediver/viewer.shared.types';
49
+ import {
50
+ ITree,
51
+ ITreeNode,
52
+ Tree,
53
+ TreeNode
54
+ } from '@shapediver/viewer.shared.node-tree';
55
+ import { Output } from './dto/Output';
56
+ import { OutputDelayException } from './OutputDelayException';
57
+ import { OutputLoader, OutputLoaderTaskEventInfo } from './OutputLoader';
58
+ import { Parameter } from './dto/Parameter';
59
+ import { SessionData } from './SessionData';
60
+ import { SessionTreeNode } from './SessionTreeNode';
61
+ import { vec3 } from 'gl-matrix';
62
+ /* eslint-disable @typescript-eslint/no-empty-function */
22
63
 
23
64
  export class SessionEngine implements ISessionEngine {
24
65
  // #region Properties (43)
@@ -34,7 +75,7 @@ export class SessionEngine implements ISessionEngine {
34
75
  private readonly _outputs: { [key: string]: IOutput; } = {};
35
76
  private readonly _outputsFreeze: { [key: string]: boolean; } = {};
36
77
  private readonly _parameterValues: { [key: string]: string; } = {};
37
- private readonly _parameters: { [key: string]: IParameter<any>; } = {};
78
+ private readonly _parameters: { [key: string]: IParameter<unknown>; } = {};
38
79
  private readonly _performanceEvaluator = PerformanceEvaluator.instance;
39
80
  private readonly _sceneTree: ITree = Tree.instance;
40
81
  private readonly _sessionEngineId = (UuidGenerator.instance).create();
@@ -46,14 +87,14 @@ export class SessionEngine implements ISessionEngine {
46
87
  #customizationProcess!: string;
47
88
  #parameterHistory: {
48
89
  [key: string]: {
49
- value: any,
90
+ value: unknown,
50
91
  valueString: string
51
92
  }
52
93
  }[] = [];
53
94
  #parameterHistoryCall = false;
54
95
  #parameterHistoryForward: {
55
96
  [key: string]: {
56
- value: any,
97
+ value: unknown,
57
98
  valueString: string
58
99
  }
59
100
  }[] = [];
@@ -62,14 +103,14 @@ export class SessionEngine implements ISessionEngine {
62
103
  private _closed: boolean = false;
63
104
  private _customizeOnParameterChange: boolean = false;
64
105
  private _dataCache: {
65
- [key: string]: Promise<HttpResponse<any>>
106
+ [key: string]: Promise<HttpResponse<unknown>>
66
107
  } = {};
67
108
  private _excludeViewports: string[] = [];
68
109
  private _headers = {
69
- "X-ShapeDiver-Origin": (SystemInfo.instance).origin,
70
- "X-ShapeDiver-SessionEngineId": this._sessionEngineId,
71
- "X-ShapeDiver-BuildVersion": '',
72
- "X-ShapeDiver-BuildDate": ''
110
+ 'X-ShapeDiver-Origin': (SystemInfo.instance).origin,
111
+ 'X-ShapeDiver-SessionEngineId': this._sessionEngineId,
112
+ 'X-ShapeDiver-BuildVersion': '',
113
+ 'X-ShapeDiver-BuildDate': ''
73
114
  };
74
115
  private _initialized: boolean = false;
75
116
  private _jwtToken?: string;
@@ -115,7 +156,7 @@ export class SessionEngine implements ISessionEngine {
115
156
 
116
157
  // #endregion Constructors (1)
117
158
 
118
- // #region Public Accessors (24)
159
+ // #region Public Accessors (25)
119
160
 
120
161
  public get automaticSceneUpdate(): boolean {
121
162
  return this._automaticSceneUpdate;
@@ -192,7 +233,7 @@ export class SessionEngine implements ISessionEngine {
192
233
  return this._parameterValues;
193
234
  }
194
235
 
195
- public get parameters(): { [key: string]: IParameter<any>; } {
236
+ public get parameters(): { [key: string]: IParameter<unknown>; } {
196
237
  return this._parameters;
197
238
  }
198
239
 
@@ -213,149 +254,149 @@ export class SessionEngine implements ISessionEngine {
213
254
  }
214
255
 
215
256
  public get updateCallback(): ((newNode: ITreeNode, oldNode: ITreeNode) => void) | null {
216
- return this._updateCallback;
257
+ return this._updateCallback;
217
258
  }
218
259
 
219
260
  public set updateCallback(value: ((newNode: ITreeNode, oldNode: ITreeNode) => void) | null) {
220
- this._updateCallback = value;
261
+ this._updateCallback = value;
221
262
  }
222
263
 
223
264
  public get viewerSettings(): object | undefined {
224
265
  return this._viewerSettings;
225
266
  }
226
267
 
227
- // #endregion Public Accessors (24)
268
+ // #endregion Public Accessors (25)
228
269
 
229
- // #region Public Methods (24)
270
+ // #region Public Methods (25)
230
271
 
231
272
  public applySettings(response: ShapeDiverResponseDto, sections?: ISettingsSections) {
232
- sections = sections || {};
233
- if (sections.session === undefined) {
234
- sections.session = {
235
- parameter: { displayname: false, order: false, hidden: false },
236
- export: { displayname: false, order: false, hidden: false }
237
- };
238
- }
239
- if (sections.session.parameter === undefined)
240
- sections.session.parameter = { displayname: false, order: false, hidden: false, value: false };
241
- if (sections.session.export === undefined)
242
- sections.session.export = { displayname: false, order: false, hidden: false };
243
- if (sections.viewport === undefined)
244
- sections.viewport = { ar: false, scene: false, camera: false, light: false, environment: false, general: false, postprocessing: false };
245
-
246
- let config: object;
247
- if ((<ShapeDiverResponseDto>response).viewer !== undefined) {
248
- config = (<ShapeDiverResponseDto>response).viewer!.config;
249
- } else {
250
- throw new ShapeDiverViewerSettingsError('Session.applySettings: No config object available.');
251
- }
273
+ sections = sections || {};
274
+ if (sections.session === undefined) {
275
+ sections.session = {
276
+ parameter: { displayname: false, order: false, hidden: false },
277
+ export: { displayname: false, order: false, hidden: false }
278
+ };
279
+ }
280
+ if (sections.session.parameter === undefined)
281
+ sections.session.parameter = { displayname: false, order: false, hidden: false, value: false };
282
+ if (sections.session.export === undefined)
283
+ sections.session.export = { displayname: false, order: false, hidden: false };
284
+ if (sections.viewport === undefined)
285
+ sections.viewport = { ar: false, scene: false, camera: false, light: false, environment: false, general: false, postprocessing: false };
286
+
287
+ let config: object;
288
+ if ((<ShapeDiverResponseDto>response).viewer !== undefined) {
289
+ config = (<ShapeDiverResponseDto>response).viewer!.config;
290
+ } else {
291
+ throw new ShapeDiverViewerSettingsError('Session.applySettings: No config object available.');
292
+ }
252
293
 
253
- try {
254
- validate(config)
255
- } catch (e) {
256
- throw new ShapeDiverViewerSettingsError('Session.applySettings: Was not able to validate config object.');
257
- }
294
+ try {
295
+ validate(config);
296
+ } catch (e) {
297
+ throw new ShapeDiverViewerSettingsError('Session.applySettings: Was not able to validate config object.');
298
+ }
258
299
 
259
- const settings = <ISettings>convert(config, latestVersion);
300
+ const settings = <ISettings>convert(config, latestVersion);
260
301
 
261
- const exportMappingUid: { [key: string]: string | undefined } = {};
262
- if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden)
263
- if (response.exports)
264
- for (let exportId in response.exports)
265
- if (response.exports[exportId].uid !== undefined)
266
- exportMappingUid[response.exports[exportId].uid!] = exportId;
302
+ const exportMappingUid: { [key: string]: string | undefined } = {};
303
+ if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden)
304
+ if (response.exports)
305
+ for (const exportId in response.exports)
306
+ if (response.exports[exportId].uid !== undefined)
307
+ exportMappingUid[response.exports[exportId].uid!] = exportId;
267
308
 
268
- const currentSettings = this._settingsEngine.settings;
309
+ const currentSettings = this._settingsEngine.settings;
269
310
 
270
- // apply parameter settings
271
- if (sections.session.parameter.displayname || sections.session.parameter.order || sections.session.parameter.hidden || sections.session.parameter.value) {
272
- for (let p in this.parameters) {
273
- if (settings.session[p]) {
274
- if (sections.session.parameter.displayname) this.parameters[p].displayname = settings.session[p].displayname;
275
- if (sections.session.parameter.order) this.parameters[p].order = settings.session[p].order;
276
- if (sections.session.parameter.hidden) this.parameters[p].hidden = settings.session[p].hidden || false;
277
- }
311
+ // apply parameter settings
312
+ if (sections.session.parameter.displayname || sections.session.parameter.order || sections.session.parameter.hidden || sections.session.parameter.value) {
313
+ for (const p in this.parameters) {
314
+ if (settings.session[p]) {
315
+ if (sections.session.parameter.displayname) this.parameters[p].displayname = settings.session[p].displayname;
316
+ if (sections.session.parameter.order) this.parameters[p].order = settings.session[p].order;
317
+ if (sections.session.parameter.hidden) this.parameters[p].hidden = settings.session[p].hidden || false;
318
+ }
278
319
 
279
- if (response.parameters && response.parameters[p]) {
280
- if (sections.session.parameter.value) this.parameters[p].value = response.parameters[p].defval !== undefined ? response.parameters[p].defval : this.parameters[p].value;
281
- }
320
+ if (response.parameters && response.parameters[p]) {
321
+ if (sections.session.parameter.value) this.parameters[p].value = response.parameters[p].defval !== undefined ? response.parameters[p].defval : this.parameters[p].value;
282
322
  }
283
323
  }
324
+ }
284
325
 
285
- // apply export settings
286
- if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden) {
287
- for (let p in this.exports) {
288
- let idForSettings = '';
289
- if (settings.session[p]) {
290
- idForSettings = p;
291
- } else {
292
- const uid = this.exports[p].uid;
293
- if (!uid) continue;
294
- if (!exportMappingUid[uid]) continue;
295
- idForSettings = exportMappingUid[uid]!;
296
- }
297
- if (settings.session[idForSettings]) {
298
- if (sections.session.export.displayname) this.exports[p].displayname = settings.session[idForSettings].displayname;
299
- if (sections.session.export.order) this.exports[p].order = settings.session[idForSettings].order;
300
- if (sections.session.export.hidden) this.exports[p].hidden = settings.session[idForSettings].hidden || false;
301
- }
326
+ // apply export settings
327
+ if (sections.session.export.displayname || sections.session.export.order || sections.session.export.hidden) {
328
+ for (const p in this.exports) {
329
+ let idForSettings = '';
330
+ if (settings.session[p]) {
331
+ idForSettings = p;
332
+ } else {
333
+ const uid = this.exports[p].uid;
334
+ if (!uid) continue;
335
+ if (!exportMappingUid[uid]) continue;
336
+ idForSettings = exportMappingUid[uid]!;
337
+ }
338
+ if (settings.session[idForSettings]) {
339
+ if (sections.session.export.displayname) this.exports[p].displayname = settings.session[idForSettings].displayname;
340
+ if (sections.session.export.order) this.exports[p].order = settings.session[idForSettings].order;
341
+ if (sections.session.export.hidden) this.exports[p].hidden = settings.session[idForSettings].hidden || false;
302
342
  }
303
343
  }
344
+ }
304
345
 
305
- // apply ar settings
306
- if (sections.viewport.ar) {
307
- currentSettings.ar = settings.ar;
308
- currentSettings.general.transformation = settings.general.transformation;
309
- }
346
+ // apply ar settings
347
+ if (sections.viewport.ar) {
348
+ currentSettings.ar = settings.ar;
349
+ currentSettings.general.transformation = settings.general.transformation;
350
+ }
310
351
 
311
- // apply camera settings
312
- if (sections.viewport.camera)
313
- currentSettings.camera = settings.camera;
314
-
315
- // apply light settings
316
- if (sections.viewport.light)
317
- currentSettings.light = settings.light;
318
-
319
- // apply scene settings
320
- if (sections.viewport.scene) {
321
- currentSettings.environmentGeometry.gridColor = settings.environmentGeometry.gridColor;
322
- currentSettings.environmentGeometry.gridVisibility = settings.environmentGeometry.gridVisibility;
323
- currentSettings.environmentGeometry.groundPlaneColor = settings.environmentGeometry.groundPlaneColor;
324
- currentSettings.environmentGeometry.groundPlaneVisibility = settings.environmentGeometry.groundPlaneVisibility;
325
- currentSettings.environmentGeometry.groundPlaneShadowColor = settings.environmentGeometry.groundPlaneShadowColor;
326
- currentSettings.environmentGeometry.groundPlaneShadowVisibility = settings.environmentGeometry.groundPlaneShadowVisibility;
327
-
328
- currentSettings.rendering.shadows = settings.rendering.shadows;
329
- currentSettings.rendering.softShadows = settings.rendering.softShadows;
330
-
331
- currentSettings.rendering.automaticColorAdjustment = settings.rendering.automaticColorAdjustment;
332
- currentSettings.rendering.textureEncoding = settings.rendering.textureEncoding;
333
- currentSettings.rendering.outputEncoding = settings.rendering.outputEncoding;
334
- currentSettings.rendering.physicallyCorrectLights = settings.rendering.physicallyCorrectLights;
335
- currentSettings.rendering.toneMapping = settings.rendering.toneMapping;
336
- currentSettings.rendering.toneMappingExposure = settings.rendering.toneMappingExposure;
337
- }
352
+ // apply camera settings
353
+ if (sections.viewport.camera)
354
+ currentSettings.camera = settings.camera;
355
+
356
+ // apply light settings
357
+ if (sections.viewport.light)
358
+ currentSettings.light = settings.light;
359
+
360
+ // apply scene settings
361
+ if (sections.viewport.scene) {
362
+ currentSettings.environmentGeometry.gridColor = settings.environmentGeometry.gridColor;
363
+ currentSettings.environmentGeometry.gridVisibility = settings.environmentGeometry.gridVisibility;
364
+ currentSettings.environmentGeometry.groundPlaneColor = settings.environmentGeometry.groundPlaneColor;
365
+ currentSettings.environmentGeometry.groundPlaneVisibility = settings.environmentGeometry.groundPlaneVisibility;
366
+ currentSettings.environmentGeometry.groundPlaneShadowColor = settings.environmentGeometry.groundPlaneShadowColor;
367
+ currentSettings.environmentGeometry.groundPlaneShadowVisibility = settings.environmentGeometry.groundPlaneShadowVisibility;
368
+
369
+ currentSettings.rendering.shadows = settings.rendering.shadows;
370
+ currentSettings.rendering.softShadows = settings.rendering.softShadows;
371
+
372
+ currentSettings.rendering.automaticColorAdjustment = settings.rendering.automaticColorAdjustment;
373
+ currentSettings.rendering.textureEncoding = settings.rendering.textureEncoding;
374
+ currentSettings.rendering.outputEncoding = settings.rendering.outputEncoding;
375
+ currentSettings.rendering.physicallyCorrectLights = settings.rendering.physicallyCorrectLights;
376
+ currentSettings.rendering.toneMapping = settings.rendering.toneMapping;
377
+ currentSettings.rendering.toneMappingExposure = settings.rendering.toneMappingExposure;
378
+ }
338
379
 
339
- if (sections.viewport.general) {
340
- currentSettings.general.defaultMaterialColor = settings.general.defaultMaterialColor;
341
- currentSettings.general.commitParameters = settings.general.commitParameters;
342
- currentSettings.general.pointSize = settings.general.pointSize;
343
- }
380
+ if (sections.viewport.general) {
381
+ currentSettings.general.defaultMaterialColor = settings.general.defaultMaterialColor;
382
+ currentSettings.general.commitParameters = settings.general.commitParameters;
383
+ currentSettings.general.pointSize = settings.general.pointSize;
384
+ }
344
385
 
345
- // apply postprocessing settings
346
- if (sections.viewport.postprocessing)
347
- currentSettings.postprocessing = settings.postprocessing;
348
-
349
- // apply environment settings
350
- if (sections.viewport.environment) {
351
- currentSettings.environment.clearAlpha = settings.environment.clearAlpha;
352
- currentSettings.environment.clearColor = settings.environment.clearColor;
353
- currentSettings.environment.map = settings.environment.map;
354
- currentSettings.environment.mapAsBackground = settings.environment.mapAsBackground;
355
- currentSettings.environment.rotation = settings.environment.rotation;
356
- currentSettings.environment.blurriness = settings.environment.blurriness;
357
- currentSettings.environment.intensity = settings.environment.intensity;
358
- }
386
+ // apply postprocessing settings
387
+ if (sections.viewport.postprocessing)
388
+ currentSettings.postprocessing = settings.postprocessing;
389
+
390
+ // apply environment settings
391
+ if (sections.viewport.environment) {
392
+ currentSettings.environment.clearAlpha = settings.environment.clearAlpha;
393
+ currentSettings.environment.clearColor = settings.environment.clearColor;
394
+ currentSettings.environment.map = settings.environment.map;
395
+ currentSettings.environment.mapAsBackground = settings.environment.mapAsBackground;
396
+ currentSettings.environment.rotation = settings.environment.rotation;
397
+ currentSettings.environment.blurriness = settings.environment.blurriness;
398
+ currentSettings.environment.intensity = settings.environment.intensity;
399
+ }
359
400
  }
360
401
 
361
402
  public canGoBack(): boolean {
@@ -372,7 +413,7 @@ export class SessionEngine implements ISessionEngine {
372
413
  this.checkAvailability('close');
373
414
 
374
415
  try {
375
- this._httpClient.removeDataLoading(this._sessionId!)
416
+ this._httpClient.removeDataLoading(this._sessionId!);
376
417
  await this._sdk.session.close(this._sessionId!);
377
418
  if (this._automaticSceneUpdate) this.removeFromSceneTree(this._node);
378
419
 
@@ -389,7 +430,7 @@ export class SessionEngine implements ISessionEngine {
389
430
  * @param parameters the parameter set to update the session
390
431
  * @returns promise with a scene graph node
391
432
  */
392
- public async customize(force: boolean = false): Promise<ITreeNode> {
433
+ public async customize(force: boolean = false, waitForViewportUpdate: boolean = false): Promise<ITreeNode> {
393
434
  const eventId = this._uuidGenerator.create();
394
435
  const customizationId = this._uuidGenerator.create();
395
436
  try {
@@ -399,7 +440,7 @@ export class SessionEngine implements ISessionEngine {
399
440
  for (const parameterId in this.parameters)
400
441
  if (this.parameters[parameterId].sessionValue !== this.parameters[parameterId].value)
401
442
  changes = true;
402
- if(changes === false)
443
+ if (changes === false)
403
444
  return this.node;
404
445
  }
405
446
 
@@ -411,14 +452,14 @@ export class SessionEngine implements ISessionEngine {
411
452
 
412
453
  this._logger.debugLow(`Session(${this.id}).customize: Customizing session.`);
413
454
 
414
- for (let r in this._stateEngine.renderingEngines)
415
- if(!this.excludeViewports.includes(r))
455
+ for (const r in this._stateEngine.renderingEngines)
456
+ if (!this.excludeViewports.includes(r))
416
457
  this._stateEngine.renderingEngines[r].busy.push(customizationId);
417
458
 
418
459
  const eventFileUpload: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0.1, data: { sessionId: this.id }, status: 'Uploading file parameters' };
419
460
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_PROCESS, eventFileUpload);
420
461
 
421
- const fileParameterIds: { [key: string]: string } = {}
462
+ const fileParameterIds: { [key: string]: string } = {};
422
463
  // load file parameter first
423
464
  for (const parameterId in this.parameters) {
424
465
  if (this.parameters[parameterId] instanceof FileParameter) {
@@ -426,7 +467,7 @@ export class SessionEngine implements ISessionEngine {
426
467
 
427
468
  // OPTION TO SKIP - PART 1a
428
469
  if (this.#customizationProcess !== customizationId) {
429
- for (let r in this._stateEngine.renderingEngines)
470
+ for (const r in this._stateEngine.renderingEngines)
430
471
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
431
472
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
432
473
 
@@ -436,7 +477,7 @@ export class SessionEngine implements ISessionEngine {
436
477
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel1a);
437
478
  return new SessionTreeNode();
438
479
  } else if (this._closed === true) {
439
- for (let r in this._stateEngine.renderingEngines)
480
+ for (const r in this._stateEngine.renderingEngines)
440
481
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
441
482
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
442
483
 
@@ -451,7 +492,7 @@ export class SessionEngine implements ISessionEngine {
451
492
 
452
493
  // OPTION TO SKIP - PART 1b
453
494
  if (this.#customizationProcess !== customizationId) {
454
- for (let r in this._stateEngine.renderingEngines)
495
+ for (const r in this._stateEngine.renderingEngines)
455
496
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
456
497
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
457
498
 
@@ -460,7 +501,7 @@ export class SessionEngine implements ISessionEngine {
460
501
  this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
461
502
  return new SessionTreeNode();
462
503
  } else if (this._closed === true) {
463
- for (let r in this._stateEngine.renderingEngines)
504
+ for (const r in this._stateEngine.renderingEngines)
464
505
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
465
506
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
466
507
 
@@ -477,7 +518,7 @@ export class SessionEngine implements ISessionEngine {
477
518
 
478
519
  const parameterSet: {
479
520
  [key: string]: {
480
- value: any,
521
+ value: unknown,
481
522
  valueString: string
482
523
  }
483
524
  } = {};
@@ -487,7 +528,7 @@ export class SessionEngine implements ISessionEngine {
487
528
  parameterSet[parameterId] = {
488
529
  value: this.parameters[parameterId].value,
489
530
  valueString: this.parameters[parameterId].stringify()
490
- }
531
+ };
491
532
  }
492
533
 
493
534
  // update the session engine parameter values if everything succeeded
@@ -513,7 +554,7 @@ export class SessionEngine implements ISessionEngine {
513
554
 
514
555
  // OPTION TO SKIP - PART 2
515
556
  if (this.#customizationProcess !== customizationId) {
516
- for (let r in this._stateEngine.renderingEngines)
557
+ for (const r in this._stateEngine.renderingEngines)
517
558
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
518
559
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
519
560
 
@@ -522,7 +563,7 @@ export class SessionEngine implements ISessionEngine {
522
563
  this._logger.debug(`Session(${this.id}).customize: Session customization was exceeded by other customization request.`);
523
564
  return newNode;
524
565
  } else if ((this._closed as boolean) === true) { // I get a TS warning here that the type of _closed is "false", I think TS doesn't get that there is a promise inbetween
525
- for (let r in this._stateEngine.renderingEngines)
566
+ for (const r in this._stateEngine.renderingEngines)
526
567
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
527
568
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
528
569
 
@@ -547,8 +588,8 @@ export class SessionEngine implements ISessionEngine {
547
588
 
548
589
  // set the session values to the current ones in all parameters
549
590
  for (const parameterId in this.parameters)
550
- (<any>this.parameters[parameterId].sessionValue) = parameterSet[parameterId].value;
551
-
591
+ (<unknown>this.parameters[parameterId].sessionValue) = parameterSet[parameterId].value;
592
+
552
593
  // set the output content to what has been updated
553
594
  for (const outputId in this.outputs)
554
595
  this.outputs[outputId].updateOutput(
@@ -564,7 +605,7 @@ export class SessionEngine implements ISessionEngine {
564
605
 
565
606
  this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
566
607
 
567
- for (let r in this._stateEngine.renderingEngines)
608
+ for (const r in this._stateEngine.renderingEngines)
568
609
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
569
610
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
570
611
 
@@ -576,9 +617,10 @@ export class SessionEngine implements ISessionEngine {
576
617
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
577
618
 
578
619
  // update the viewports
579
- for (let r in this._stateEngine.renderingEngines)
580
- if(!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
581
- this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
620
+ if (waitForViewportUpdate)
621
+ for (const r in this._stateEngine.renderingEngines)
622
+ if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
623
+ this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
582
624
 
583
625
  // call the update callback function on the session
584
626
  if (this._updateCallback) this._updateCallback(newNode, oldNode);
@@ -595,7 +637,7 @@ export class SessionEngine implements ISessionEngine {
595
637
  const eventCancel: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customization failed' };
596
638
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventCancel);
597
639
 
598
- for (let r in this._stateEngine.renderingEngines)
640
+ for (const r in this._stateEngine.renderingEngines)
599
641
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
600
642
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
601
643
 
@@ -604,33 +646,33 @@ export class SessionEngine implements ISessionEngine {
604
646
  }
605
647
 
606
648
  public async customizeParallel(parameterValues: { [key: string]: string }): Promise<ITreeNode> {
607
- const eventId = this._uuidGenerator.create();
649
+ const eventId = this._uuidGenerator.create();
608
650
 
609
- const eventStart: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
610
- this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
651
+ const eventStart: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 0, data: { sessionId: this.id }, status: 'Customizing session' };
652
+ this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
611
653
 
612
- const parameterSet: {
613
- [key: string]: string
614
- } = {};
654
+ const parameterSet: {
655
+ [key: string]: string
656
+ } = {};
615
657
 
616
- // create a set of the current validated parameter values
617
- for (const parameterId in this.parameters)
618
- parameterSet[parameterId] = parameterValues[parameterId] !== undefined ? (' ' + parameterValues[parameterId]).slice(1) : this.parameters[parameterId].stringify()
658
+ // create a set of the current validated parameter values
659
+ for (const parameterId in this.parameters)
660
+ parameterSet[parameterId] = parameterValues[parameterId] !== undefined ? (' ' + parameterValues[parameterId]).slice(1) : this.parameters[parameterId].stringify();
619
661
 
620
- const newNode = await this.customizeSession(parameterSet, () => false, {
621
- eventId,
622
- type: TASK_TYPE.SESSION_CUSTOMIZATION,
623
- progressRange: {
624
- min: 0.0,
625
- max: 1
626
- },
627
- data: { sessionId: this.id }
628
- }, true);
629
- newNode.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
630
-
631
- const eventEnd: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
632
- this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
633
- return newNode;
662
+ const newNode = await this.customizeSession(parameterSet, () => false, {
663
+ eventId,
664
+ type: TASK_TYPE.SESSION_CUSTOMIZATION,
665
+ progressRange: {
666
+ min: 0.0,
667
+ max: 1
668
+ },
669
+ data: { sessionId: this.id }
670
+ }, true);
671
+ newNode.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
672
+
673
+ const eventEnd: ITaskEvent = { type: TASK_TYPE.SESSION_CUSTOMIZATION, id: eventId, progress: 1, data: { sessionId: this.id }, status: 'Session customized' };
674
+ this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
675
+ return newNode;
634
676
  }
635
677
 
636
678
  public async goBack(): Promise<ITreeNode> {
@@ -684,7 +726,7 @@ export class SessionEngine implements ISessionEngine {
684
726
  public async init(parameterValues?: {
685
727
  [key: string]: string;
686
728
  }, retry = false): Promise<void> {
687
- if (this._initialized === true)
729
+ if (this._initialized === true)
688
730
  throw new ShapeDiverViewerSessionError('Session.init: Session already initialized.');
689
731
 
690
732
  try {
@@ -695,13 +737,13 @@ export class SessionEngine implements ISessionEngine {
695
737
  for (const parameterNameOrId in parameterValues)
696
738
  parameterSet[parameterNameOrId] = (' ' + parameterValues[parameterNameOrId]).slice(1);
697
739
 
698
- if(this._ticket) {
740
+ if (this._ticket) {
699
741
  this._responseDto = await this._sdk.session.init(this._ticket, parameterSet);
700
- } else if(this._guid) {
742
+ } else if (this._guid) {
701
743
  this._responseDto = await this._sdk.session.initForModel(this._guid, parameterSet);
702
744
  } else {
703
745
  // we should never get here
704
- throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. Neither a ticket nor a guid are available.`)
746
+ throw new ShapeDiverViewerSessionError('Session.init: Initialization of session failed. Neither a ticket nor a guid are available.');
705
747
  }
706
748
  this._performanceEvaluator.endSection('sessionResponse');
707
749
 
@@ -709,18 +751,18 @@ export class SessionEngine implements ISessionEngine {
709
751
  this._viewerSettingsVersionBackend = this._responseDto.viewerSettingsVersion || latestVersion;
710
752
  this._sessionId = this._responseDto.sessionId;
711
753
  this._modelId = this._responseDto.model?.id;
712
-
754
+
713
755
  this._httpClient.addDataLoading(this._sessionId!, {
714
756
  getAsset: this._sdk.asset.getAsset.bind(this._sdk.asset),
715
757
  downloadTexture: this._sdk.asset.downloadImage.bind(this._sdk.asset),
716
- })
758
+ });
717
759
 
718
760
  this._settingsEngine.loadSettings(this._viewerSettings);
719
-
761
+
720
762
  if (!this._sessionId)
721
- throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. ResponseDto did not have a sessionId.`)
763
+ throw new ShapeDiverViewerSessionError('Session.init: Initialization of session failed. ResponseDto did not have a sessionId.');
722
764
  if (!this._modelId)
723
- throw new ShapeDiverViewerSessionError(`Session.init: Initialization of session failed. ResponseDto did not have a model.id.`)
765
+ throw new ShapeDiverViewerSessionError('Session.init: Initialization of session failed. ResponseDto did not have a model.id.');
724
766
 
725
767
  this.updateResponseDto(this._responseDto, parameterSet);
726
768
  this._initialized = true;
@@ -730,7 +772,6 @@ export class SessionEngine implements ISessionEngine {
730
772
  }
731
773
  }
732
774
 
733
-
734
775
  /**
735
776
  * Load the outputs and return the scene graph node of the result.
736
777
  * In case the outputs have a delay property, another customization request with the parameter set is sent.
@@ -739,25 +780,23 @@ export class SessionEngine implements ISessionEngine {
739
780
  * @param outputs the outputs to load
740
781
  * @returns promise with a scene graph node
741
782
  */
742
- public async loadOutputsParallel(responseDto: ShapeDiverResponseDto, cancelRequest: () => boolean = () => false, taskEventInfo: OutputLoaderTaskEventInfo, retry = false): Promise<ISessionTreeNode> {
783
+ public async loadOutputs(cancelRequest: () => boolean = () => false, taskEventInfo: OutputLoaderTaskEventInfo, retry = false): Promise<ISessionTreeNode> {
743
784
  this.checkAvailability();
744
785
 
745
- let outputs: {
746
- [key: string]: IOutput;
747
- } = {}
748
- let outputsFreeze: {
749
- [key: string]: boolean;
750
- } = {}
751
-
752
- for (let outputId in responseDto.outputs) {
753
- responseDto.outputs[outputId].id = outputId;
754
- if (this.outputsFreeze[outputId] === undefined) outputsFreeze[outputId] = false;
755
- outputs[outputId] = new Output(<ShapeDiverResponseOutput>responseDto.outputs[outputId], this);
756
- }
757
-
786
+ const o = Object.assign({}, this._outputs);
787
+ const of = Object.assign({}, this._outputsFreeze);
758
788
  try {
759
- const node = await this._outputLoader.loadOutputs(this._responseDto!.model?.name || 'model', outputs, outputsFreeze, taskEventInfo);
760
- node.data.push(new SessionData(responseDto));
789
+ const node = await this._outputLoader.loadOutputs(this._responseDto!.model?.name || 'model', o, of, taskEventInfo);
790
+ node.data.push(new SessionData(this._responseDto!));
791
+
792
+ if (cancelRequest()) return node;
793
+
794
+ if (this._automaticSceneUpdate) this.removeFromSceneTree(this._node);
795
+ this._node = node;
796
+ if (this._automaticSceneUpdate && this._closed === false) this.addToSceneTree(this._node);
797
+
798
+ this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
799
+
761
800
  return node;
762
801
  }
763
802
  catch (e) {
@@ -766,23 +805,23 @@ export class SessionEngine implements ISessionEngine {
766
805
  } else {
767
806
  await this.handleError(e, retry);
768
807
  if (cancelRequest()) return new SessionTreeNode();
769
- return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
808
+ return await this.loadOutputs(cancelRequest, taskEventInfo, true);
770
809
  }
771
810
 
772
811
  if (cancelRequest()) return new SessionTreeNode();
773
- let outputMapping: { [key: string]: string } = {};
774
- for (let output in outputs)
775
- outputMapping[output] = outputs[output].version;
812
+ const outputMapping: { [key: string]: string } = {};
813
+ for (const output in o)
814
+ outputMapping[output] = o[output].version;
776
815
 
777
816
  try {
778
817
  const responseDto = await this._sdk.output.getCache(this._sessionId!, outputMapping);
779
818
  if (cancelRequest()) return new SessionTreeNode();
780
819
  this.updateResponseDto(responseDto);
781
- return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
820
+ return await this.loadOutputs(cancelRequest, taskEventInfo);
782
821
  } catch (e) {
783
822
  await this.handleError(e, retry);
784
823
  if (cancelRequest()) return new SessionTreeNode();
785
- return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
824
+ return await this.loadOutputs(cancelRequest, taskEventInfo, true);
786
825
  }
787
826
  }
788
827
  }
@@ -795,23 +834,25 @@ export class SessionEngine implements ISessionEngine {
795
834
  * @param outputs the outputs to load
796
835
  * @returns promise with a scene graph node
797
836
  */
798
- public async loadOutputs(cancelRequest: () => boolean = () => false, taskEventInfo: OutputLoaderTaskEventInfo, retry = false): Promise<ISessionTreeNode> {
837
+ public async loadOutputsParallel(responseDto: ShapeDiverResponseDto, cancelRequest: () => boolean = () => false, taskEventInfo: OutputLoaderTaskEventInfo, retry = false): Promise<ISessionTreeNode> {
799
838
  this.checkAvailability();
800
839
 
801
- const o = Object.assign({}, this._outputs);
802
- const of = Object.assign({}, this._outputsFreeze);
803
- try {
804
- const node = await this._outputLoader.loadOutputs(this._responseDto!.model?.name || 'model', o, of, taskEventInfo);
805
- node.data.push(new SessionData(this._responseDto!));
806
-
807
- if (cancelRequest()) return node;
808
-
809
- if (this._automaticSceneUpdate) this.removeFromSceneTree(this._node);
810
- this._node = node;
811
- if (this._automaticSceneUpdate && this._closed === false) this.addToSceneTree(this._node);
840
+ const outputs: {
841
+ [key: string]: IOutput;
842
+ } = {};
843
+ const outputsFreeze: {
844
+ [key: string]: boolean;
845
+ } = {};
812
846
 
813
- this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
847
+ for (const outputId in responseDto.outputs) {
848
+ responseDto.outputs[outputId].id = outputId;
849
+ if (this.outputsFreeze[outputId] === undefined) outputsFreeze[outputId] = false;
850
+ outputs[outputId] = new Output(<ShapeDiverResponseOutput>responseDto.outputs[outputId], this);
851
+ }
814
852
 
853
+ try {
854
+ const node = await this._outputLoader.loadOutputs(this._responseDto!.model?.name || 'model', outputs, outputsFreeze, taskEventInfo);
855
+ node.data.push(new SessionData(responseDto));
815
856
  return node;
816
857
  }
817
858
  catch (e) {
@@ -820,23 +861,23 @@ export class SessionEngine implements ISessionEngine {
820
861
  } else {
821
862
  await this.handleError(e, retry);
822
863
  if (cancelRequest()) return new SessionTreeNode();
823
- return await this.loadOutputs(cancelRequest, taskEventInfo, true);
864
+ return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
824
865
  }
825
866
 
826
867
  if (cancelRequest()) return new SessionTreeNode();
827
- let outputMapping: { [key: string]: string } = {};
828
- for (let output in o)
829
- outputMapping[output] = o[output].version;
868
+ const outputMapping: { [key: string]: string } = {};
869
+ for (const output in outputs)
870
+ outputMapping[output] = outputs[output].version;
830
871
 
831
872
  try {
832
873
  const responseDto = await this._sdk.output.getCache(this._sessionId!, outputMapping);
833
874
  if (cancelRequest()) return new SessionTreeNode();
834
875
  this.updateResponseDto(responseDto);
835
- return await this.loadOutputs(cancelRequest, taskEventInfo);
876
+ return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
836
877
  } catch (e) {
837
878
  await this.handleError(e, retry);
838
879
  if (cancelRequest()) return new SessionTreeNode();
839
- return await this.loadOutputs(cancelRequest, taskEventInfo, true);
880
+ return await this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo, true);
840
881
  }
841
882
  }
842
883
  }
@@ -844,32 +885,8 @@ export class SessionEngine implements ISessionEngine {
844
885
  public async requestExport(exportId: string, parameters: { [key: string]: string }, maxWaitTime: number, retry = false): Promise<ShapeDiverResponseExport> {
845
886
  this.checkAvailability('export');
846
887
  try {
847
- const requestParameterSet: { [key: string]: string } = {};
848
-
849
- // first step, we convert all our names and displaynames to ids
850
- for (const parameterIdOrName in parameters) {
851
- // we prioritize id, then name and then displayname
852
- // if there are two parameters with the same name or displayname, we take the one that is found first (no way for us to evaluate which one the user meant)
853
- const parameterObject = Object.values(this._parameters).find(p => p.id === parameterIdOrName || p.name === parameterIdOrName || p.displayname === parameterIdOrName);
854
-
855
- // in case the key of the key value pair was neither the id, name or displayname, skip
856
- if(!parameterObject) continue;
857
-
858
- // deep copy into new dictionary
859
- requestParameterSet[parameterObject.id] = (' ' + parameters[parameterIdOrName]).slice(1);
860
- }
861
-
862
- // seconds step, fill all other parameter values that are currently not set
863
- const currentParameters = this.parameterValues;
864
- for (const parameterId in currentParameters) {
865
- // if already set by input values, skip
866
- if(requestParameterSet[parameterId] !== undefined) continue;
867
-
868
- // deep copy into new dictionary
869
- requestParameterSet[parameterId] = (' ' + currentParameters[parameterId]).slice(1);
870
- }
871
-
872
- const responseDto = await this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId!, { exports: { id: exportId }, parameters: requestParameterSet }, maxWaitTime)
888
+ const requestParameterSet = this.cleanExportParameters(parameters);
889
+ const responseDto = await this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId!, { exports: { id: exportId }, parameters: requestParameterSet }, maxWaitTime);
873
890
  this.updateResponseDto(responseDto);
874
891
  return this.exports[exportId];
875
892
  } catch (e) {
@@ -878,42 +895,55 @@ export class SessionEngine implements ISessionEngine {
878
895
  }
879
896
  }
880
897
 
898
+ public async requestExports(body: ShapeDiverRequestExport, maxWaitMsec?: number, retry = false): Promise<ShapeDiverResponseDto> {
899
+ this.checkAvailability('export');
900
+ try {
901
+ const requestParameterSet = this.cleanExportParameters(body.parameters);
902
+ const responseDto = await this._sdk.utils.submitAndWaitForExport(this._sdk, this._sessionId!, { exports: body.exports, parameters: requestParameterSet, outputs: body.outputs, max_wait_time: body.max_wait_time }, maxWaitMsec);
903
+ this.updateResponseDto(responseDto);
904
+ return responseDto;
905
+ } catch (e) {
906
+ await this.handleError(e, retry);
907
+ return await this.requestExports(body, maxWaitMsec, true);
908
+ }
909
+ }
910
+
881
911
  public resetSettings(sections?: ISettingsSections): void {
882
912
  if (!this._responseDto)
883
- throw new ShapeDiverViewerSessionError(`Session.resetSettings: responseDto not available.`);
884
-
885
- sections = sections || {};
886
- if (sections.session === undefined) {
887
- sections.session = {
888
- parameter: { displayname: true, order: true, hidden: true },
889
- export: { displayname: true, order: true, hidden: true }
890
- };
891
- }
892
- if (sections.session.parameter === undefined)
893
- sections.session.parameter = { displayname: true, order: true, hidden: true, value: true };
894
- if (sections.session.export === undefined)
895
- sections.session.export = { displayname: true, order: true, hidden: true };
896
- if (sections.viewport === undefined)
897
- sections.viewport = { ar: true, scene: true, camera: true, light: true, environment: true, general: true, postprocessing: true };
898
-
899
- return this.applySettings(this._responseDto, sections);
913
+ throw new ShapeDiverViewerSessionError('Session.resetSettings: responseDto not available.');
914
+
915
+ sections = sections || {};
916
+ if (sections.session === undefined) {
917
+ sections.session = {
918
+ parameter: { displayname: true, order: true, hidden: true },
919
+ export: { displayname: true, order: true, hidden: true }
920
+ };
921
+ }
922
+ if (sections.session.parameter === undefined)
923
+ sections.session.parameter = { displayname: true, order: true, hidden: true, value: true };
924
+ if (sections.session.export === undefined)
925
+ sections.session.export = { displayname: true, order: true, hidden: true };
926
+ if (sections.viewport === undefined)
927
+ sections.viewport = { ar: true, scene: true, camera: true, light: true, environment: true, general: true, postprocessing: true };
928
+
929
+ return this.applySettings(this._responseDto, sections);
900
930
  }
901
931
 
902
932
  public async saveDefaultParameterValues(): Promise<boolean> {
903
- this._logger.debugLow(`Session(${this.id}).saveDefaultParameters: Saving default parameters.`);
904
- const response = await this.saveDefaultParameters();
905
- if (response) {
906
- this._logger.debug(`Session(${this.id}).saveDefaultParameters: Saved default parameters.`);
907
- } else {
908
- throw new ShapeDiverViewerSessionError(`Session(${this.id}).saveDefaultParameters: Could not save default parameters.`);
909
- }
910
- return response;
933
+ this._logger.debugLow(`Session(${this.id}).saveDefaultParameters: Saving default parameters.`);
934
+ const response = await this.saveDefaultParameters();
935
+ if (response) {
936
+ this._logger.debug(`Session(${this.id}).saveDefaultParameters: Saved default parameters.`);
937
+ } else {
938
+ throw new ShapeDiverViewerSessionError(`Session(${this.id}).saveDefaultParameters: Could not save default parameters.`);
939
+ }
940
+ return response;
911
941
  }
912
942
 
913
943
  public async saveDefaultParameters(retry = false): Promise<boolean> {
914
944
  this.checkAvailability('defaultparam', true);
915
945
  try {
916
- await this._sdk.model.setDefaultParams(this._modelId!, this._parameterValues)
946
+ await this._sdk.model.setDefaultParams(this._modelId!, this._parameterValues);
917
947
  return true;
918
948
  } catch (e) {
919
949
  await this.handleError(e, retry);
@@ -993,22 +1023,22 @@ export class SessionEngine implements ISessionEngine {
993
1023
  }
994
1024
  }
995
1025
 
996
- public async saveSettings(json: any, retry = false): Promise<boolean> {
1026
+ public async saveSettings(json: unknown, retry = false): Promise<boolean> {
997
1027
  this.checkAvailability('configure', true);
998
-
1028
+
999
1029
  try {
1000
- validate(json, <versions>this._viewerSettingsVersion)
1001
-
1030
+ validate(json, <versions>this._viewerSettingsVersion);
1031
+
1002
1032
  // if viewer settings version is higher than backend settings version
1003
1033
  // convert to backend settings version
1004
- if(+this._viewerSettingsVersion > +this._viewerSettingsVersionBackend)
1005
- json = convert(json, <versions>this._viewerSettingsVersionBackend)
1034
+ if (+this._viewerSettingsVersion > +this._viewerSettingsVersionBackend)
1035
+ json = convert(json, <versions>this._viewerSettingsVersionBackend);
1006
1036
  } catch (e) {
1007
1037
  throw new ShapeDiverViewerSettingsError('Session.saveSettings: Settings could not be validated. ' + (<Error>e).message, <Error>e);
1008
- }
1009
-
1010
- try {
1011
- await this._sdk.model.updateConfig(this._modelId!, json);
1038
+ }
1039
+
1040
+ try {
1041
+ await this._sdk.model.updateConfig(this._modelId!, json as ShapeDiverRequestConfigure);
1012
1042
  return true;
1013
1043
  } catch (e) {
1014
1044
  await this.handleError(e, retry);
@@ -1017,60 +1047,60 @@ export class SessionEngine implements ISessionEngine {
1017
1047
  }
1018
1048
 
1019
1049
  public async saveUiProperties(saveInSettings: boolean = true): Promise<boolean> {
1020
- this._logger.debugLow(`Session(${this.id}).saveSessionProperties: Saving session properties.`);
1050
+ this._logger.debugLow(`Session(${this.id}).saveSessionProperties: Saving session properties.`);
1021
1051
 
1022
- // settings saving
1023
- this._saveSessionSettings();
1052
+ // settings saving
1053
+ this._saveSessionSettings();
1024
1054
 
1025
- let properties: {
1026
- [key: string]: {
1027
- displayname: string,
1028
- hidden: boolean,
1029
- order: number,
1030
- tooltip: string
1031
- }
1032
- } = {};
1033
- for (let p in this.parameters) {
1034
- properties[p] = {
1035
- displayname: this.parameters[p].displayname !== undefined ? this.parameters[p].displayname! : '',
1036
- hidden: this.parameters[p].hidden !== undefined ? this.parameters[p].hidden : false,
1037
- order: this.parameters[p].order !== undefined ? this.parameters[p].order! : 0,
1038
- tooltip: this.parameters[p].tooltip !== undefined ? this.parameters[p].tooltip! : '',
1039
- };
1040
- }
1041
- const responseP = Object.values(properties).length !== 0 ? await this.saveParameterProperties(properties) : true;
1042
-
1043
- properties = {};
1044
- for (let e in this.exports) {
1045
- properties[e] = {
1046
- displayname: this.exports[e].displayname !== undefined ? this.exports[e].displayname! : '',
1047
- hidden: this.exports[e].hidden !== undefined ? this.exports[e].hidden : false,
1048
- order: this.exports[e].order !== undefined ? this.exports[e].order! : 0,
1049
- tooltip: this.exports[e].tooltip !== undefined ? this.exports[e].tooltip! : '',
1050
- };
1051
- }
1052
- const responseE = Object.values(properties).length !== 0 ? await this.saveExportProperties(properties) : true;
1053
-
1054
- properties = {};
1055
- for (let o in this.outputs) {
1056
- properties[o] = {
1057
- displayname: this.outputs[o].displayname !== undefined ? this.outputs[o].displayname! : '',
1058
- hidden: this.outputs[o].hidden !== undefined ? this.outputs[o].hidden : false,
1059
- order: this.outputs[o].order !== undefined ? this.outputs[o].order! : 0,
1060
- tooltip: this.outputs[o].tooltip !== undefined ? this.outputs[o].tooltip! : '',
1061
- };
1055
+ let properties: {
1056
+ [key: string]: {
1057
+ displayname: string,
1058
+ hidden: boolean,
1059
+ order: number,
1060
+ tooltip: string
1062
1061
  }
1063
- const responseO = Object.values(properties).length !== 0 ? await this.saveOutputProperties(properties) : true;
1062
+ } = {};
1063
+ for (const p in this.parameters) {
1064
+ properties[p] = {
1065
+ displayname: this.parameters[p].displayname !== undefined ? this.parameters[p].displayname! : '',
1066
+ hidden: this.parameters[p].hidden !== undefined ? this.parameters[p].hidden : false,
1067
+ order: this.parameters[p].order !== undefined ? this.parameters[p].order! : 0,
1068
+ tooltip: this.parameters[p].tooltip !== undefined ? this.parameters[p].tooltip! : '',
1069
+ };
1070
+ }
1071
+ const responseP = Object.values(properties).length !== 0 ? await this.saveParameterProperties(properties) : true;
1072
+
1073
+ properties = {};
1074
+ for (const e in this.exports) {
1075
+ properties[e] = {
1076
+ displayname: this.exports[e].displayname !== undefined ? this.exports[e].displayname! : '',
1077
+ hidden: this.exports[e].hidden !== undefined ? this.exports[e].hidden : false,
1078
+ order: this.exports[e].order !== undefined ? this.exports[e].order! : 0,
1079
+ tooltip: this.exports[e].tooltip !== undefined ? this.exports[e].tooltip! : '',
1080
+ };
1081
+ }
1082
+ const responseE = Object.values(properties).length !== 0 ? await this.saveExportProperties(properties) : true;
1083
+
1084
+ properties = {};
1085
+ for (const o in this.outputs) {
1086
+ properties[o] = {
1087
+ displayname: this.outputs[o].displayname !== undefined ? this.outputs[o].displayname! : '',
1088
+ hidden: this.outputs[o].hidden !== undefined ? this.outputs[o].hidden : false,
1089
+ order: this.outputs[o].order !== undefined ? this.outputs[o].order! : 0,
1090
+ tooltip: this.outputs[o].tooltip !== undefined ? this.outputs[o].tooltip! : '',
1091
+ };
1092
+ }
1093
+ const responseO = Object.values(properties).length !== 0 ? await this.saveOutputProperties(properties) : true;
1064
1094
 
1065
- // save partial settings
1066
- const response = saveInSettings ? await this.saveSettings(this._settingsEngine.settings) : true;
1095
+ // save partial settings
1096
+ const response = saveInSettings ? await this.saveSettings(this._settingsEngine.settings) : true;
1067
1097
 
1068
- if (response && responseP && responseO && responseE) {
1069
- this._logger.debug(`Session(${this.id}).saveSessionProperties: Saved session properties.`);
1070
- } else {
1071
- this._logger.warn(`Session(${this.id}).saveSessionProperties: Could not save session properties.`);
1072
- }
1073
- return response && responseP && responseO && responseE;
1098
+ if (response && responseP && responseO && responseE) {
1099
+ this._logger.debug(`Session(${this.id}).saveSessionProperties: Saved session properties.`);
1100
+ } else {
1101
+ this._logger.warn(`Session(${this.id}).saveSessionProperties: Could not save session properties.`);
1102
+ }
1103
+ return response && responseP && responseO && responseE;
1074
1104
  }
1075
1105
 
1076
1106
  public async setJwtToken(value: string) {
@@ -1080,18 +1110,18 @@ export class SessionEngine implements ISessionEngine {
1080
1110
  try {
1081
1111
  this._sdk.setConfigurationValue(ShapeDiverSdkConfigType.JWT_TOKEN, value);
1082
1112
  const responseDto = await this._sdk.session.default(this._sessionId!);
1083
- if(this._responseDto) this._responseDto.actions = responseDto.actions;
1113
+ if (this._responseDto) this._responseDto.actions = responseDto.actions;
1084
1114
  } catch (e) {
1085
1115
  throw this._httpClient.convertError(e);
1086
1116
  }
1087
1117
  }
1088
1118
 
1089
- public async updateOutputs(taskEventInfo?: OutputLoaderTaskEventInfo): Promise<ITreeNode> {
1119
+ public async updateOutputs(taskEventInfo?: OutputLoaderTaskEventInfo, waitForViewportUpdate: boolean = false): Promise<ITreeNode> {
1090
1120
  const eventId = taskEventInfo ? taskEventInfo.eventId : this._uuidGenerator.create();
1091
1121
  const eventType = taskEventInfo ? taskEventInfo.type : TASK_TYPE.SESSION_OUTPUTS_UPDATE;
1092
1122
  const eventData = taskEventInfo ? taskEventInfo.data : { sessionId: this.id };
1093
1123
 
1094
- if(!taskEventInfo) {
1124
+ if (!taskEventInfo) {
1095
1125
  const eventStart: ITaskEvent = { type: eventType, id: eventId, progress: 0, data: eventData, status: 'Updating outputs' };
1096
1126
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, eventStart);
1097
1127
  }
@@ -1102,8 +1132,8 @@ export class SessionEngine implements ISessionEngine {
1102
1132
 
1103
1133
  this._logger.debugLow(`Session(${this.id}).updateOutputs: Updating Outputs.`);
1104
1134
 
1105
- for (let r in this._stateEngine.renderingEngines)
1106
- if(!this.excludeViewports.includes(r))
1135
+ for (const r in this._stateEngine.renderingEngines)
1136
+ if (!this.excludeViewports.includes(r))
1107
1137
  this._stateEngine.renderingEngines[r].busy.push(customizationId);
1108
1138
 
1109
1139
  const eventRequest: ITaskEvent = { type: eventType, id: eventId, progress: taskEventInfo ? (taskEventInfo.progressRange.max - taskEventInfo.progressRange.min) * 0.1 + taskEventInfo.progressRange.min : 0.1, data: eventData, status: 'Loading outputs' };
@@ -1124,7 +1154,7 @@ export class SessionEngine implements ISessionEngine {
1124
1154
 
1125
1155
  // OPTION TO SKIP - PART 1
1126
1156
  if (this.#customizationProcess !== customizationId) {
1127
- for (let r in this._stateEngine.renderingEngines)
1157
+ for (const r in this._stateEngine.renderingEngines)
1128
1158
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
1129
1159
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
1130
1160
 
@@ -1133,7 +1163,7 @@ export class SessionEngine implements ISessionEngine {
1133
1163
  this._logger.debug(`Session(${this.id}).updateOutputs: Output updating was exceeded by other request.`);
1134
1164
  return newNode;
1135
1165
  } else if (this._closed === true) {
1136
- for (let r in this._stateEngine.renderingEngines)
1166
+ for (const r in this._stateEngine.renderingEngines)
1137
1167
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
1138
1168
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
1139
1169
 
@@ -1149,7 +1179,7 @@ export class SessionEngine implements ISessionEngine {
1149
1179
  if (this.automaticSceneUpdate && this._closed === false) this.addToSceneTree(this.node);
1150
1180
 
1151
1181
  this._logger.debug(`Session(${this.id}).updateOutputs: Updating outputs finished, updating geometry.`);
1152
-
1182
+
1153
1183
  // set the output content to what has been updated
1154
1184
  for (const outputId in this.outputs) {
1155
1185
  this.outputs[outputId].updateOutput(
@@ -1165,21 +1195,22 @@ export class SessionEngine implements ISessionEngine {
1165
1195
  this._warningCreator();
1166
1196
  this.node.excludeViewports = JSON.parse(JSON.stringify(this._excludeViewports));
1167
1197
 
1168
- for (let r in this._stateEngine.renderingEngines)
1198
+ for (const r in this._stateEngine.renderingEngines)
1169
1199
  if (this._stateEngine.renderingEngines[r].busy.includes(customizationId))
1170
1200
  this._stateEngine.renderingEngines[r].busy.splice(this._stateEngine.renderingEngines[r].busy.indexOf(customizationId), 1);
1171
1201
 
1172
1202
  this._logger.debug(`Session(${this.id}).updateOutputs: Updated outputs.`);
1173
-
1174
- if(!taskEventInfo) {
1203
+
1204
+ if (!taskEventInfo) {
1175
1205
  const eventEnd: ITaskEvent = { type: eventType, id: eventId, progress: 1, data: eventData, status: 'Outputs updated' };
1176
1206
  this._eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
1177
1207
  }
1178
1208
 
1179
1209
  // update the viewports
1180
- for (let r in this._stateEngine.renderingEngines)
1181
- if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
1182
- this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).customize`);
1210
+ if (waitForViewportUpdate)
1211
+ for (const r in this._stateEngine.renderingEngines)
1212
+ if (!this.excludeViewports.includes(this._stateEngine.renderingEngines[r].id))
1213
+ this._stateEngine.renderingEngines[r].update(`SessionEngine(${this.id}).updateOutputs`);
1183
1214
 
1184
1215
  // call the update callback function on the session
1185
1216
  if (this._updateCallback) this._updateCallback(newNode, oldNode);
@@ -1199,14 +1230,14 @@ export class SessionEngine implements ISessionEngine {
1199
1230
  try {
1200
1231
  const responseDto = await this._sdk.file.requestUpload(this._sessionId!, {
1201
1232
  [parameterId]: { size: data.size, format: type }
1202
- })
1233
+ });
1203
1234
 
1204
1235
  if (responseDto && responseDto.asset && responseDto.asset.file && responseDto.asset.file[parameterId]) {
1205
1236
  const fileAsset = responseDto.asset.file[parameterId];
1206
1237
  await this._sdk.utils.upload(fileAsset.href, await data.arrayBuffer(), type);
1207
1238
  return fileAsset.id;
1208
1239
  } else {
1209
- throw new ShapeDiverViewerSessionError(`Session.uploadFile: Upload reply has not the required format.`);
1240
+ throw new ShapeDiverViewerSessionError('Session.uploadFile: Upload reply has not the required format.');
1210
1241
  }
1211
1242
  } catch (e) {
1212
1243
  await this.handleError(e, retry);
@@ -1218,8 +1249,8 @@ export class SessionEngine implements ISessionEngine {
1218
1249
  this.checkAvailability('gltf-upload');
1219
1250
  try {
1220
1251
  const responseDto = await this._sdk.gltf.upload(this._sessionId!, await blob.arrayBuffer(), 'model/gltf-binary', conversion);
1221
- if (!responseDto || !responseDto.gltf || !responseDto.gltf.href)
1222
- throw new ShapeDiverViewerSessionError(`Session.uploadGLTF: Upload reply has not the required format.`);
1252
+ if (!responseDto || !responseDto.gltf || !responseDto.gltf.href)
1253
+ throw new ShapeDiverViewerSessionError('Session.uploadGLTF: Upload reply has not the required format.');
1223
1254
  return responseDto;
1224
1255
  } catch (e) {
1225
1256
  await this.handleError(e, retry);
@@ -1227,9 +1258,9 @@ export class SessionEngine implements ISessionEngine {
1227
1258
  }
1228
1259
  }
1229
1260
 
1230
- // #endregion Public Methods (24)
1261
+ // #endregion Public Methods (25)
1231
1262
 
1232
- // #region Private Methods (10)
1263
+ // #region Private Methods (11)
1233
1264
 
1234
1265
  private _saveSessionSettings() {
1235
1266
  const parameters = this.parameters;
@@ -1242,26 +1273,26 @@ export class SessionEngine implements ISessionEngine {
1242
1273
  hidden: boolean;
1243
1274
  }
1244
1275
  } = {};
1245
- for (let p in parameters) {
1276
+ for (const p in parameters) {
1246
1277
  sessionProperties[p] = {
1247
1278
  order: parameters[p].order || 0,
1248
1279
  displayname: parameters[p].displayname || '',
1249
1280
  hidden: parameters[p].hidden
1250
- }
1281
+ };
1251
1282
  }
1252
- for (let e in exports) {
1283
+ for (const e in exports) {
1253
1284
  sessionProperties[e] = {
1254
1285
  order: exports[e].order || 0,
1255
1286
  displayname: exports[e].displayname || '',
1256
1287
  hidden: exports[e].hidden
1257
- }
1288
+ };
1258
1289
  }
1259
1290
  this._settingsEngine.session = sessionProperties;
1260
1291
 
1261
1292
  let orderedOutputs: IOutput[] = [];
1262
- for (let o in this.outputs) orderedOutputs.push(this.outputs[o]);
1293
+ for (const o in this.outputs) orderedOutputs.push(this.outputs[o]);
1263
1294
  orderedOutputs.sort((a, b) => ((a.order || Infinity) - (b.order || Infinity)));
1264
- let zerosOutputs = orderedOutputs.filter(x => x.order === 0);
1295
+ const zerosOutputs = orderedOutputs.filter(x => x.order === 0);
1265
1296
  orderedOutputs = orderedOutputs.filter((el) => { return !zerosOutputs.includes(el); });
1266
1297
  orderedOutputs = zerosOutputs.concat(orderedOutputs);
1267
1298
 
@@ -1308,22 +1339,51 @@ export class SessionEngine implements ISessionEngine {
1308
1339
 
1309
1340
  private checkAvailability(action?: string, checkForModelId = false) {
1310
1341
  if (!this._responseDto)
1311
- throw new ShapeDiverViewerSessionError(`Session.checkAvailability: responseDto not available.`);
1342
+ throw new ShapeDiverViewerSessionError('Session.checkAvailability: responseDto not available.');
1312
1343
 
1313
1344
  if (!this._sessionId)
1314
- throw new ShapeDiverViewerSessionError(`Session.checkAvailability: sessionId not available.`);
1345
+ throw new ShapeDiverViewerSessionError('Session.checkAvailability: sessionId not available.');
1315
1346
 
1316
1347
  if (checkForModelId && !this._modelId)
1317
- throw new ShapeDiverViewerSessionError(`Session.checkAvailability: modelId not available.`);
1348
+ throw new ShapeDiverViewerSessionError('Session.checkAvailability: modelId not available.');
1318
1349
 
1319
1350
  if (action && !this._responseDto.actions)
1320
- throw new ShapeDiverViewerSessionError(`Session.checkAvailability: actions not available.`);
1351
+ throw new ShapeDiverViewerSessionError('Session.checkAvailability: actions not available.');
1321
1352
 
1322
1353
  const responseDtoAction = this._responseDto.actions?.find(a => a.name === action);
1323
1354
  if (action && !responseDtoAction)
1324
1355
  throw new ShapeDiverViewerSessionError(`Session.checkAvailability: action ${action} not available.`);
1325
1356
  }
1326
1357
 
1358
+ private cleanExportParameters(parameters: ShapeDiverRequestCustomization): ShapeDiverRequestCustomization {
1359
+ const requestParameterSet: ShapeDiverRequestCustomization = {};
1360
+
1361
+ // first step, we convert all our names and displaynames to ids
1362
+ for (const parameterIdOrName in parameters) {
1363
+ // we prioritize id, then name and then displayname
1364
+ // if there are two parameters with the same name or displayname, we take the one that is found first (no way for us to evaluate which one the user meant)
1365
+ const parameterObject = Object.values(this._parameters).find(p => p.id === parameterIdOrName || p.name === parameterIdOrName || p.displayname === parameterIdOrName);
1366
+
1367
+ // in case the key of the key value pair was neither the id, name or displayname, skip
1368
+ if (!parameterObject) continue;
1369
+
1370
+ // copy into new dictionary
1371
+ requestParameterSet[parameterObject.id] = parameters[parameterIdOrName];
1372
+ }
1373
+
1374
+ // seconds step, fill all other parameter values that are currently not set
1375
+ const currentParameters = this.parameterValues;
1376
+ for (const parameterId in currentParameters) {
1377
+ // if already set by input values, skip
1378
+ if (requestParameterSet[parameterId] !== undefined) continue;
1379
+
1380
+ // deep copy into new dictionary
1381
+ requestParameterSet[parameterId] = (' ' + currentParameters[parameterId]).slice(1);
1382
+ }
1383
+
1384
+ return requestParameterSet;
1385
+ }
1386
+
1327
1387
  private async customizeInternal(cancelRequest: () => boolean, taskEventInfo: OutputLoaderTaskEventInfo): Promise<ISessionTreeNode> {
1328
1388
  return this.customizeSession(this._parameterValues, cancelRequest, taskEventInfo);
1329
1389
  }
@@ -1334,7 +1394,7 @@ export class SessionEngine implements ISessionEngine {
1334
1394
  this._performanceEvaluator.startSection('sessionResponse');
1335
1395
  const responseDto = await this._sdk.utils.submitAndWaitForCustomization(this._sdk, this._sessionId!, parameters);
1336
1396
  this._performanceEvaluator.endSection('sessionResponse');
1337
- if (cancelRequest()) return new SessionTreeNode();
1397
+ if (cancelRequest()) return new SessionTreeNode();
1338
1398
  if (parallel === false) this.updateResponseDto(responseDto);
1339
1399
  return parallel === false ? this.loadOutputs(cancelRequest, taskEventInfo) : this.loadOutputsParallel(responseDto, cancelRequest, taskEventInfo);
1340
1400
  } catch (e) {
@@ -1350,8 +1410,8 @@ export class SessionEngine implements ISessionEngine {
1350
1410
  // case 1: the session is no longer available
1351
1411
  // we try to re-initialize the session 3 times, if that does not work, we close it
1352
1412
 
1353
- this._logger.warn(`The session has been closed, trying to re-initialize.`);
1354
- if(this._sessionId) this._httpClient.removeDataLoading(this._sessionId)
1413
+ this._logger.warn('The session has been closed, trying to re-initialize.');
1414
+ if (this._sessionId) this._httpClient.removeDataLoading(this._sessionId);
1355
1415
 
1356
1416
  if (this._retryCounter < 3) {
1357
1417
  // we retry this 3 times, the `retry` option in the init function is set to true and passed on
@@ -1361,6 +1421,7 @@ export class SessionEngine implements ISessionEngine {
1361
1421
  } else {
1362
1422
  // the retries were exceeded, we close the session
1363
1423
  this._logger.warn('Tried to retry the connect multiple times, bearer token still not valid. Closing Session.');
1424
+ // eslint-disable-next-line no-empty
1364
1425
  try { await this._closeOnFailure(); } catch (e) { }
1365
1426
  throw this._httpClient.convertError(e);
1366
1427
  }
@@ -1375,12 +1436,14 @@ export class SessionEngine implements ISessionEngine {
1375
1436
  } else {
1376
1437
  // no bearer tokens are supplied, we close the session
1377
1438
  this._logger.warn('No retry possible, no new bearer token was supplied. Closing Session.');
1439
+ // eslint-disable-next-line no-empty
1378
1440
  try { await this._closeOnFailure(); } catch (e) { }
1379
1441
  throw this._httpClient.convertError(e);
1380
1442
  }
1381
1443
  } else {
1382
1444
  // the retries were exceeded, we close the session
1383
1445
  this._logger.warn('Tried to retry the connect multiple times, bearer token still not valid. Closing Session.');
1446
+ // eslint-disable-next-line no-empty
1384
1447
  try { await this._closeOnFailure(); } catch (e) { }
1385
1448
  throw this._httpClient.convertError(e);
1386
1449
  }
@@ -1403,7 +1466,7 @@ export class SessionEngine implements ISessionEngine {
1403
1466
  * @param ms the milliseconds
1404
1467
  * @returns promise that resolve after specified milliseconds
1405
1468
  */
1406
- private async timeout(ms: number): Promise<any> {
1469
+ private async timeout(ms: number): Promise<unknown> {
1407
1470
  return new Promise(resolve => setTimeout(resolve, ms));
1408
1471
  }
1409
1472
 
@@ -1417,7 +1480,7 @@ export class SessionEngine implements ISessionEngine {
1417
1480
 
1418
1481
  // convert parameters
1419
1482
  if (responseDto.parameters) {
1420
- for (let parameterId in responseDto.parameters) {
1483
+ for (const parameterId in responseDto.parameters) {
1421
1484
  this._responseDto.parameters = this._responseDto.parameters || {};
1422
1485
  this._responseDto.parameters[parameterId] = this._responseDto.parameters[parameterId] || responseDto.parameters[parameterId];
1423
1486
  }
@@ -1425,7 +1488,7 @@ export class SessionEngine implements ISessionEngine {
1425
1488
 
1426
1489
  // convert outputs
1427
1490
  if (responseDto.outputs) {
1428
- for (let outputId in responseDto.outputs) {
1491
+ for (const outputId in responseDto.outputs) {
1429
1492
  this._responseDto.outputs = this._responseDto.outputs || {};
1430
1493
  if ('version' in responseDto.outputs[outputId] || !(this._responseDto.outputs[outputId] && 'version' in this._responseDto.outputs[outputId]))
1431
1494
  this._responseDto.outputs[outputId] = responseDto.outputs[outputId];
@@ -1434,7 +1497,7 @@ export class SessionEngine implements ISessionEngine {
1434
1497
 
1435
1498
  // convert exports
1436
1499
  if (responseDto.exports) {
1437
- for (let exportId in responseDto.exports) {
1500
+ for (const exportId in responseDto.exports) {
1438
1501
  this._responseDto.exports = this._responseDto.exports || {};
1439
1502
  if ('version' in responseDto.exports[exportId] || !(this._responseDto.exports[exportId] && 'version' in this._responseDto.exports[exportId]))
1440
1503
  this._responseDto.exports[exportId] = responseDto.exports[exportId];
@@ -1443,12 +1506,12 @@ export class SessionEngine implements ISessionEngine {
1443
1506
 
1444
1507
  const parameterSet: {
1445
1508
  [key: string]: {
1446
- value: any,
1509
+ value: unknown,
1447
1510
  valueString: string
1448
1511
  }
1449
1512
  } = {};
1450
1513
 
1451
- for (let parameterId in this._responseDto.parameters) {
1514
+ for (const parameterId in this._responseDto.parameters) {
1452
1515
  if (this.parameters[parameterId]) continue;
1453
1516
  this._responseDto.parameters[parameterId].id = parameterId;
1454
1517
 
@@ -1471,15 +1534,15 @@ export class SessionEngine implements ISessionEngine {
1471
1534
  }
1472
1535
 
1473
1536
  // we don't have to do larger restrictions for this as the backend would have already thrown an error if the values were not correct
1474
- if(initialParameters) {
1537
+ if (initialParameters) {
1475
1538
  // check if the id is within the initial parameters
1476
- if(initialParameters[parameterId] !== undefined) {
1477
- this.parameters[parameterId].value = initialParameters[parameterId]
1478
- }
1539
+ if (initialParameters[parameterId] !== undefined) {
1540
+ this.parameters[parameterId].value = initialParameters[parameterId];
1541
+ }
1479
1542
  // check if the name is within the initial parameters
1480
- else if(initialParameters[this.parameters[parameterId].name] !== undefined) {
1543
+ else if (initialParameters[this.parameters[parameterId].name] !== undefined) {
1481
1544
  this.parameters[parameterId].value = initialParameters[this.parameters[parameterId].name];
1482
- }
1545
+ }
1483
1546
  // NOTE: At some point the checking may also be done with the displayname, this is the code for it
1484
1547
  // // check if the displayname is within the initial parameters
1485
1548
  // else if(this.parameters[parameterId].displayname && initialParameters[this.parameters[parameterId].displayname!] !== undefined) {
@@ -1490,7 +1553,7 @@ export class SessionEngine implements ISessionEngine {
1490
1553
  parameterSet[parameterId] = {
1491
1554
  value: this.parameters[parameterId].value,
1492
1555
  valueString: this.parameters[parameterId].stringify()
1493
- }
1556
+ };
1494
1557
 
1495
1558
  if (!this.initialized)
1496
1559
  this.parameterValues[parameterId] = parameterSet[parameterId].valueString;
@@ -1500,27 +1563,27 @@ export class SessionEngine implements ISessionEngine {
1500
1563
  if (!this.initialized)
1501
1564
  this.#parameterHistory.push(parameterSet);
1502
1565
 
1503
- for (let exportId in this._responseDto.exports) {
1566
+ for (const exportId in this._responseDto.exports) {
1504
1567
  if (this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.EMAIL || this._responseDto.exports[exportId].type === ShapeDiverResponseExportDefinitionType.DOWNLOAD) {
1505
- if(!this.exports[exportId]) {
1568
+ if (!this.exports[exportId]) {
1506
1569
  this._responseDto.exports[exportId].id = exportId;
1507
1570
  this.exports[exportId] = new Export(this._responseDto.exports[exportId], this);
1508
1571
  } else {
1509
- this.exports[exportId].updateExportDefinition(this._responseDto.exports[exportId])
1572
+ this.exports[exportId].updateExportDefinition(this._responseDto.exports[exportId]);
1510
1573
  }
1511
1574
  }
1512
1575
  }
1513
1576
 
1514
- for (let outputId in this._responseDto.outputs) {
1515
- if(!this.outputs[outputId]) {
1577
+ for (const outputId in this._responseDto.outputs) {
1578
+ if (!this.outputs[outputId]) {
1516
1579
  this._responseDto.outputs[outputId].id = outputId;
1517
1580
  if (this.outputsFreeze[outputId] === undefined) this.outputsFreeze[outputId] = false;
1518
1581
  this.outputs[outputId] = new Output(<ShapeDiverResponseOutput>this._responseDto.outputs[outputId], this);
1519
1582
  } else {
1520
- this.outputs[outputId].updateOutputDefinition(<ShapeDiverResponseOutput>this._responseDto.outputs[outputId])
1583
+ this.outputs[outputId].updateOutputDefinition(<ShapeDiverResponseOutput>this._responseDto.outputs[outputId]);
1521
1584
  }
1522
1585
  }
1523
1586
  }
1524
1587
 
1525
- // #endregion Private Methods (10)
1588
+ // #endregion Private Methods (11)
1526
1589
  }