@shapediver/viewer.session-engine.session-engine 1.15.6 → 2.0.1

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 (97) hide show
  1. package/dist/implementation/OutputLoader.d.ts +1 -1
  2. package/dist/implementation/OutputLoader.d.ts.map +1 -1
  3. package/dist/implementation/OutputLoader.js +2 -5
  4. package/dist/implementation/OutputLoader.js.map +1 -1
  5. package/dist/implementation/SessionData.d.ts +4 -3
  6. package/dist/implementation/SessionData.d.ts.map +1 -1
  7. package/dist/implementation/SessionData.js.map +1 -1
  8. package/dist/implementation/{Session.d.ts → SessionEngine.d.ts} +79 -17
  9. package/dist/implementation/SessionEngine.d.ts.map +1 -0
  10. package/dist/implementation/SessionEngine.js +1132 -0
  11. package/dist/implementation/SessionEngine.js.map +1 -0
  12. package/dist/implementation/SessionOutputData.d.ts +4 -3
  13. package/dist/implementation/SessionOutputData.d.ts.map +1 -1
  14. package/dist/implementation/SessionOutputData.js.map +1 -1
  15. package/dist/implementation/SessionTreeNode.d.ts +4 -4
  16. package/dist/implementation/SessionTreeNode.d.ts.map +1 -1
  17. package/dist/implementation/SessionTreeNode.js +1 -4
  18. package/dist/implementation/SessionTreeNode.js.map +1 -1
  19. package/dist/implementation/dto/Export.d.ts +37 -0
  20. package/dist/implementation/dto/Export.d.ts.map +1 -0
  21. package/dist/implementation/dto/Export.js +204 -0
  22. package/dist/implementation/dto/Export.js.map +1 -0
  23. package/dist/implementation/dto/FileParameter.d.ts +10 -0
  24. package/dist/implementation/dto/FileParameter.d.ts.map +1 -0
  25. package/dist/implementation/dto/FileParameter.js +99 -0
  26. package/dist/implementation/dto/FileParameter.js.map +1 -0
  27. package/dist/implementation/dto/Output.d.ts +42 -0
  28. package/dist/implementation/dto/Output.d.ts.map +1 -0
  29. package/dist/implementation/dto/Output.js +200 -0
  30. package/dist/implementation/dto/Output.js.map +1 -0
  31. package/dist/implementation/dto/Parameter.d.ts +39 -0
  32. package/dist/implementation/dto/Parameter.d.ts.map +1 -0
  33. package/dist/implementation/dto/Parameter.js +341 -0
  34. package/dist/implementation/dto/Parameter.js.map +1 -0
  35. package/dist/index.d.ts +15 -5
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +14 -3
  38. package/dist/index.js.map +1 -1
  39. package/dist/interfaces/ISessionData.d.ts +7 -0
  40. package/dist/interfaces/ISessionData.d.ts.map +1 -0
  41. package/dist/interfaces/ISessionData.js +3 -0
  42. package/dist/interfaces/ISessionData.js.map +1 -0
  43. package/dist/interfaces/ISessionEngine.d.ts +123 -0
  44. package/dist/interfaces/ISessionEngine.d.ts.map +1 -0
  45. package/dist/interfaces/ISessionEngine.js +59 -0
  46. package/dist/interfaces/ISessionEngine.js.map +1 -0
  47. package/dist/interfaces/ISessionOutputData.d.ts +7 -0
  48. package/dist/interfaces/ISessionOutputData.d.ts.map +1 -0
  49. package/dist/interfaces/ISessionOutputData.js +3 -0
  50. package/dist/interfaces/ISessionOutputData.js.map +1 -0
  51. package/dist/interfaces/ISessionTreeNode.d.ts +5 -0
  52. package/dist/interfaces/ISessionTreeNode.d.ts.map +1 -0
  53. package/dist/interfaces/ISessionTreeNode.js +3 -0
  54. package/dist/interfaces/ISessionTreeNode.js.map +1 -0
  55. package/dist/interfaces/dto/IExport.d.ts +10 -0
  56. package/dist/interfaces/dto/IExport.d.ts.map +1 -0
  57. package/dist/interfaces/{ISession.js → dto/IExport.js} +1 -1
  58. package/dist/interfaces/dto/IExport.js.map +1 -0
  59. package/dist/interfaces/dto/IFileParameter.d.ts +5 -0
  60. package/dist/interfaces/dto/IFileParameter.d.ts.map +1 -0
  61. package/dist/interfaces/dto/IFileParameter.js +3 -0
  62. package/dist/interfaces/dto/IFileParameter.js.map +1 -0
  63. package/dist/interfaces/dto/IOutput.d.ts +25 -0
  64. package/dist/interfaces/dto/IOutput.d.ts.map +1 -0
  65. package/dist/interfaces/dto/IOutput.js +3 -0
  66. package/dist/interfaces/dto/IOutput.js.map +1 -0
  67. package/dist/interfaces/dto/IParameter.d.ts +10 -0
  68. package/dist/interfaces/dto/IParameter.d.ts.map +1 -0
  69. package/dist/interfaces/dto/IParameter.js +3 -0
  70. package/dist/interfaces/dto/IParameter.js.map +1 -0
  71. package/package.json +18 -11
  72. package/src/implementation/OutputDelayException.ts +22 -0
  73. package/src/implementation/OutputLoader.ts +281 -0
  74. package/src/implementation/SessionData.ts +43 -0
  75. package/src/implementation/SessionEngine.ts +1267 -0
  76. package/src/implementation/SessionOutputData.ts +43 -0
  77. package/src/implementation/SessionTreeNode.ts +41 -0
  78. package/src/implementation/dto/Export.ts +223 -0
  79. package/src/implementation/dto/FileParameter.ts +71 -0
  80. package/src/implementation/dto/Output.ts +221 -0
  81. package/src/implementation/dto/Parameter.ts +340 -0
  82. package/src/index.ts +26 -0
  83. package/src/interfaces/ISessionData.ts +16 -0
  84. package/src/interfaces/ISessionEngine.ts +123 -0
  85. package/src/interfaces/ISessionOutputData.ts +16 -0
  86. package/src/interfaces/ISessionTreeNode.ts +9 -0
  87. package/src/interfaces/dto/IExport.ts +17 -0
  88. package/src/interfaces/dto/IFileParameter.ts +9 -0
  89. package/src/interfaces/dto/IOutput.ts +45 -0
  90. package/src/interfaces/dto/IParameter.ts +19 -0
  91. package/tsconfig.json +17 -0
  92. package/dist/implementation/Session.d.ts.map +0 -1
  93. package/dist/implementation/Session.js +0 -536
  94. package/dist/implementation/Session.js.map +0 -1
  95. package/dist/interfaces/ISession.d.ts +0 -32
  96. package/dist/interfaces/ISession.d.ts.map +0 -1
  97. package/dist/interfaces/ISession.js.map +0 -1
@@ -0,0 +1,43 @@
1
+ import { ShapeDiverResponseOutput } from '@shapediver/sdk.geometry-api-sdk-v2';
2
+ import { AbstractTreeNodeData, ITreeNodeData } from '@shapediver/viewer.shared.node-tree'
3
+ import { ISessionOutputData } from '../interfaces/ISessionOutputData';
4
+
5
+ export class SessionOutputData extends AbstractTreeNodeData implements ISessionOutputData {
6
+ // #region Properties (1)
7
+
8
+ #responseOutput: ShapeDiverResponseOutput;
9
+
10
+ // #endregion Properties (1)
11
+
12
+ // #region Constructors (1)
13
+
14
+ constructor(
15
+ responseOutput: ShapeDiverResponseOutput,
16
+ id?: string
17
+ ) {
18
+ super(id);
19
+ this.#responseOutput = responseOutput;
20
+ }
21
+
22
+ // #endregion Constructors (1)
23
+
24
+ // #region Public Accessors (2)
25
+
26
+ public get responseOutput(): ShapeDiverResponseOutput {
27
+ return this.#responseOutput;
28
+ }
29
+
30
+ public set responseOutput(value: ShapeDiverResponseOutput) {
31
+ this.#responseOutput = value;
32
+ }
33
+
34
+ // #endregion Public Accessors (2)
35
+
36
+ // #region Public Methods (1)
37
+
38
+ public clone(): ISessionOutputData {
39
+ return new SessionOutputData(this.responseOutput, this.id);
40
+ }
41
+
42
+ // #endregion Public Methods (1)
43
+ }
@@ -0,0 +1,41 @@
1
+ import { mat4 } from 'gl-matrix'
2
+ import { ITransformation, ITreeNode, ITreeNodeData, TreeNode } from '@shapediver/viewer.shared.node-tree'
3
+ import { ISessionTreeNode } from '../interfaces/ISessionTreeNode';
4
+
5
+ export class SessionTreeNode extends TreeNode implements ISessionTreeNode {
6
+ // #region Properties (1)
7
+
8
+ readonly #sessionNode: boolean = true;
9
+
10
+ // #endregion Properties (1)
11
+
12
+ // #region Constructors (1)
13
+
14
+ /**
15
+ * Special scene graph node for session data. Only to be created internally.
16
+ *
17
+ * @param name the name of the node
18
+ * @param parent the parent of this node
19
+ * @param data the array of data
20
+ * @param transformation the array of transformations
21
+ */
22
+ constructor(
23
+ name?: string,
24
+ parent?: ITreeNode,
25
+ data?: ITreeNodeData[],
26
+ transformations?: ITransformation[]
27
+ ) {
28
+ super(name, parent, data, transformations);
29
+ }
30
+
31
+ // #endregion Constructors (1)
32
+
33
+ // #region Public Accessors (1)
34
+
35
+ public get sessionNode(): boolean {
36
+ return this.#sessionNode;
37
+ }
38
+
39
+ // #endregion Public Accessors (1)
40
+
41
+ }
@@ -0,0 +1,223 @@
1
+ import { ShapeDiverResponseExport, ShapeDiverResponseExportContent, ShapeDiverResponseExportDefinitionType, ShapeDiverResponseExportResult, ShapeDiverResponseModelComputationStatus, ShapeDiverResponseParameterGroup } from "@shapediver/sdk.geometry-api-sdk-v2";
2
+ import { container } from "tsyringe";
3
+ import { EventEngine, EVENTTYPE, InputValidator, Logger, LOGGING_TOPIC, ShapeDiverBackendError, ShapeDiverViewerError, UuidGenerator } from "@shapediver/viewer.shared.services";
4
+ import { ITaskEvent, TASK_TYPE } from "@shapediver/viewer.shared.types";
5
+ import { IExport } from "../../interfaces/dto/IExport";
6
+ import { SessionEngine } from "../SessionEngine";
7
+
8
+ export class Export implements IExport {
9
+ // #region Properties (24)
10
+
11
+ readonly #eventEngine: EventEngine = <EventEngine>container.resolve(EventEngine);
12
+ readonly #id: string;
13
+ readonly #inputValidator: InputValidator = <InputValidator>container.resolve(InputValidator);
14
+ readonly #logger: Logger = <Logger>container.resolve(Logger);
15
+ readonly #name: string;
16
+ readonly #sessionEngine: SessionEngine;
17
+ readonly #type: ShapeDiverResponseExportDefinitionType;
18
+ readonly #uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
19
+
20
+ #content?: ShapeDiverResponseExportContent[];
21
+ #delay?: number;
22
+ #dependency!: string[];
23
+ #displayname?: string;
24
+ #filename?: string;
25
+ #group?: ShapeDiverResponseParameterGroup;
26
+ #hidden: boolean = false;
27
+ #maxWaitTime: number = 300000;
28
+ #msg?: string
29
+ #order?: number;
30
+ #result?: ShapeDiverResponseExportResult
31
+ #status_collect?: ShapeDiverResponseModelComputationStatus;
32
+ #status_computation?: ShapeDiverResponseModelComputationStatus;
33
+ #tooltip?: string;
34
+ #uid?: string;
35
+ #version?: string;
36
+
37
+ // #endregion Properties (24)
38
+
39
+ // #region Constructors (1)
40
+
41
+ constructor(exportDef: ShapeDiverResponseExport, sessionEngine: SessionEngine) {
42
+ this.#sessionEngine = sessionEngine;
43
+ this.#id = exportDef.id;
44
+ this.#name = exportDef.name;
45
+ this.#type = exportDef.type;
46
+
47
+ this.updateExportDefinition(exportDef);
48
+ }
49
+
50
+ // #endregion Constructors (1)
51
+
52
+ // #region Public Accessors (24)
53
+
54
+ public get content(): ShapeDiverResponseExportContent[] | undefined {
55
+ return this.#content;
56
+ }
57
+
58
+ public get delay(): number | undefined {
59
+ return this.#delay;
60
+ }
61
+
62
+ public get dependency(): string[] {
63
+ return this.#dependency;
64
+ }
65
+
66
+ public get displayname(): string | undefined {
67
+ return this.#displayname;
68
+ }
69
+
70
+ public set displayname(value: string | undefined) {
71
+ this.#displayname = value;
72
+ }
73
+
74
+ public get filename(): string | undefined {
75
+ return this.#filename;
76
+ }
77
+
78
+ public get group(): ShapeDiverResponseParameterGroup | undefined {
79
+ return this.#group;
80
+ }
81
+
82
+ public get hidden(): boolean {
83
+ return this.#hidden;
84
+ }
85
+
86
+ public set hidden(value: boolean) {
87
+ this.#hidden = value;
88
+ }
89
+
90
+ public get id(): string {
91
+ return this.#id;
92
+ }
93
+
94
+ public get maxWaitTime(): number {
95
+ return this.#maxWaitTime;
96
+ }
97
+
98
+ public set maxWaitTime(value: number) {
99
+ this.#maxWaitTime = value;
100
+ }
101
+
102
+ public get msg(): string | undefined {
103
+ return this.#msg;
104
+ }
105
+
106
+ public get name(): string {
107
+ return this.#name;
108
+ }
109
+
110
+ public get order(): number | undefined {
111
+ return this.#order;
112
+ }
113
+
114
+ public set order(value: number | undefined) {
115
+ this.#order = value;
116
+ }
117
+
118
+ public get result(): ShapeDiverResponseExportResult | undefined {
119
+ return this.#result;
120
+ }
121
+
122
+ public get status_collect(): ShapeDiverResponseModelComputationStatus | undefined {
123
+ return this.#status_collect;
124
+ }
125
+
126
+ public get status_computation(): ShapeDiverResponseModelComputationStatus | undefined {
127
+ return this.#status_computation;
128
+ }
129
+
130
+ public get tooltip(): string | undefined {
131
+ return this.#tooltip;
132
+ }
133
+
134
+ public set tooltip(value: string | undefined) {
135
+ this.#tooltip = value;
136
+ }
137
+
138
+ public get type(): ShapeDiverResponseExportDefinitionType {
139
+ return this.#type;
140
+ }
141
+
142
+ public get uid(): string | undefined {
143
+ return this.#uid;
144
+ }
145
+
146
+ public get version(): string | undefined {
147
+ return this.#version;
148
+ }
149
+
150
+ // #endregion Public Accessors (24)
151
+
152
+ // #region Public Methods (3)
153
+
154
+ public async request(parameters: { [key: string]: string } = {}): Promise<ShapeDiverResponseExport> {
155
+ const eventId = this.#uuidGenerator.create();
156
+ try {
157
+ const event: ITaskEvent = { type: TASK_TYPE.EXPORT_REQUEST, id: eventId, progress: 0, status: 'Requesting export' };
158
+ this.#eventEngine.emitEvent(EVENTTYPE.TASK.TASK_START, event);
159
+
160
+ this.#logger.debugLow(LOGGING_TOPIC.EXPORT, `Export(${this.#id}).request: Sending export request.`);
161
+ const currentParameters = this.#sessionEngine.parameterValues;
162
+ const exportParameters: { [key: string]: string } = {}
163
+
164
+ for (let parameter in currentParameters)
165
+ exportParameters[parameter] = parameters[parameter] || parameters[parameter] === '' ? parameters[parameter] : currentParameters[parameter];
166
+
167
+ this.#logger.info(LOGGING_TOPIC.EXPORT, `Export(${this.#id}).request: Sending export request with parameters ${JSON.stringify(exportParameters)}.`);
168
+
169
+ const exportDef = await this.#sessionEngine.requestExport(this.id, exportParameters, this.#maxWaitTime);
170
+ this.updateExportDefinition(exportDef);
171
+
172
+ const eventEnd: ITaskEvent = { type: TASK_TYPE.EXPORT_REQUEST, id: eventId, progress: 1, status: 'Returning export' };
173
+ this.#eventEngine.emitEvent(EVENTTYPE.TASK.TASK_END, eventEnd);
174
+
175
+ return exportDef;
176
+ } catch (e) {
177
+ const eventEnd: ITaskEvent = { type: TASK_TYPE.EXPORT_REQUEST, id: eventId, progress: 1, status: 'Export request failed' };
178
+ this.#eventEngine.emitEvent(EVENTTYPE.TASK.TASK_CANCEL, eventEnd);
179
+
180
+ if (e instanceof ShapeDiverViewerError || e instanceof ShapeDiverBackendError) throw e;
181
+ throw this.#logger.handleError(LOGGING_TOPIC.EXPORT, `Export(${this.#id}).request`, e);
182
+ }
183
+ }
184
+
185
+ public updateExport() {
186
+ const exportDef = this.#sessionEngine.exports[this.id];
187
+ this.#dependency = exportDef.dependency;
188
+ this.#uid = exportDef.uid;
189
+ this.#displayname = exportDef.displayname;
190
+ this.#order = exportDef.order;
191
+ this.#hidden = exportDef.hidden;
192
+ this.#tooltip = exportDef.tooltip;
193
+ this.#version = exportDef.version;
194
+ this.#delay = exportDef.delay;
195
+ this.#content = exportDef.content;
196
+ this.#msg = exportDef.msg;
197
+ this.#filename = exportDef.filename;
198
+ this.#result = exportDef.result;
199
+ this.#status_computation = exportDef.status_computation;
200
+ this.#status_collect = exportDef.status_collect;
201
+ this.#group = exportDef.group;
202
+ }
203
+
204
+ public updateExportDefinition(exportDef: ShapeDiverResponseExport) {
205
+ this.#dependency = exportDef.dependency;
206
+ this.#uid = exportDef.uid;
207
+ this.#displayname = exportDef.displayname;
208
+ this.#order = exportDef.order;
209
+ this.#hidden = exportDef.hidden;
210
+ this.#tooltip = exportDef.tooltip;
211
+ this.#version = exportDef.version;
212
+ this.#delay = exportDef.delay;
213
+ this.#content = exportDef.content;
214
+ this.#msg = exportDef.msg;
215
+ this.#filename = exportDef.filename;
216
+ this.#result = exportDef.result;
217
+ this.#status_computation = exportDef.status_computation;
218
+ this.#status_collect = exportDef.status_collect;
219
+ this.#group = exportDef.group;
220
+ }
221
+
222
+ // #endregion Public Methods (3)
223
+ }
@@ -0,0 +1,71 @@
1
+ import { ShapeDiverResponseParameter } from "@shapediver/sdk.geometry-api-sdk-v2";
2
+ import { Logger, LOGGING_TOPIC, ShapeDiverViewerSessionError, UuidGenerator } from "@shapediver/viewer.shared.services";
3
+ import { container } from "tsyringe";
4
+ import { IFileParameter } from "../../interfaces/dto/IFileParameter";
5
+ import { Parameter } from "./Parameter";
6
+ import * as MimeTypeUtils from "@shapediver/viewer.utils.mime-type"
7
+ import { SessionEngine } from "../SessionEngine";
8
+
9
+ export class FileParameter extends Parameter<File | Blob | string> implements IFileParameter {
10
+ // #region Properties (5)
11
+
12
+ readonly #logger: Logger = <Logger>container.resolve(Logger);
13
+ readonly #sessionEngine: SessionEngine;
14
+ readonly #uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
15
+
16
+ // #endregion Properties (5)
17
+
18
+ // #region Constructors (1)
19
+
20
+ constructor(paramDef: ShapeDiverResponseParameter, sessionEngine: SessionEngine) {
21
+ super(paramDef, sessionEngine);
22
+ this.#sessionEngine = sessionEngine;
23
+ }
24
+
25
+ // #endregion Constructors (1)
26
+
27
+ // #region Public Methods (1)
28
+
29
+ public async upload() {
30
+ if (!this.value) return this.defval;
31
+ if (typeof this.value === 'string' && this.value.length === 36 && this.#uuidGenerator.validate(this.value)) return this.value;
32
+
33
+ const data = new File(
34
+ [
35
+ typeof this.value === 'string' ?
36
+ new Blob([this.value], { type: 'text/plain' }) :
37
+ this.value
38
+ ],
39
+ 'upload',
40
+ { type: (<Blob | File>this.value).type }
41
+ );
42
+
43
+ let types = [data.type];
44
+ // get all endings that are possible for this type
45
+ const endings = MimeTypeUtils.mapMimeTypeToFileEndings(types);
46
+ // get all mimeTypes that are possible for these endings
47
+ endings.forEach((e: string) => types = types.concat(MimeTypeUtils.guessMimeTypeFromFilename(e)));
48
+
49
+ let type: string;
50
+ // check if one of the mime types is allowed
51
+ let allowedType = false;
52
+ for (let i = 0; i < types.length; i++) {
53
+ if (this.format?.includes(types[i])) {
54
+ allowedType = true;
55
+ type = types[i];
56
+ break;
57
+ }
58
+ }
59
+
60
+ if (!allowedType) {
61
+ const error = new ShapeDiverViewerSessionError(`Parameter(${this.id}).upload: Error uploading FileParameter, type of data (${data.type}) is not a valid type. Has to be ${this.format}.`);
62
+ throw this.#logger.handleError(LOGGING_TOPIC.PARAMETER, `Parameter(${this.id}).upload`, error);
63
+ }
64
+
65
+ this.#logger.debug(LOGGING_TOPIC.PARAMETER, `Parameter(${this.id}).upload: Uploading FileParameter.`);
66
+
67
+ return await this.#sessionEngine.uploadFile(this.id, data, type!)
68
+ }
69
+
70
+ // #endregion Public Methods (1)
71
+ }
@@ -0,0 +1,221 @@
1
+ import { ShapeDiverResponseModelComputationStatus, ShapeDiverResponseOutput } from "@shapediver/sdk.geometry-api-sdk-v2";
2
+ import { container } from "tsyringe";
3
+ import { ITreeNode, TreeNode } from "@shapediver/viewer.shared.node-tree";
4
+ import { InputValidator, UuidGenerator, LOGGING_TOPIC, ShapeDiverViewerError, ShapeDiverBackendError, Logger } from "@shapediver/viewer.shared.services";
5
+ import { IOutput, ShapeDiverResponseOutputContent, ShapeDiverResponseOutputChunk } from "../../interfaces/dto/IOutput";
6
+ import { SessionEngine } from "../SessionEngine";
7
+
8
+ export class Output implements IOutput {
9
+ // #region Properties (23)
10
+
11
+ readonly #id: string;
12
+ readonly #inputValidator: InputValidator = <InputValidator>container.resolve(InputValidator);
13
+ readonly #logger: Logger = <Logger>container.resolve(Logger);
14
+ readonly #name: string;
15
+ readonly #sessionEngine: SessionEngine;
16
+ readonly #uuidGenerator: UuidGenerator = <UuidGenerator>container.resolve(UuidGenerator);
17
+
18
+ #bbmax?: number[];
19
+ #bbmin?: number[];
20
+ #chunks?: ShapeDiverResponseOutputChunk[];
21
+ #content?: ShapeDiverResponseOutputContent[];
22
+ #delay?: number;
23
+ #dependency!: string[];
24
+ #displayname?: string;
25
+ #hidden: boolean = false;
26
+ #material?: string;
27
+ #msg?: string;
28
+ #order?: number;
29
+ #status_collect?: ShapeDiverResponseModelComputationStatus;
30
+ #status_computation?: ShapeDiverResponseModelComputationStatus;
31
+ #tooltip?: string;
32
+ #uid?: string;
33
+ #updateCallback: ((newNode?: ITreeNode, oldNode?: ITreeNode) => void) | null = null;
34
+ #version: string;
35
+
36
+ // #endregion Properties (23)
37
+
38
+ // #region Constructors (1)
39
+
40
+ constructor(outputDef: ShapeDiverResponseOutput, sessionEngine: SessionEngine) {
41
+ this.#sessionEngine = sessionEngine;
42
+
43
+ this.#id = outputDef.id;
44
+ this.#name = outputDef.name;
45
+ this.#version = outputDef.version;
46
+ this.updateOutputDefinition(outputDef);
47
+ }
48
+
49
+ // #endregion Constructors (1)
50
+
51
+ // #region Public Accessors (28)
52
+
53
+ public get bbmax(): number[] | undefined {
54
+ return this.#bbmax;
55
+ }
56
+
57
+ public get bbmin(): number[] | undefined {
58
+ return this.#bbmin;
59
+ }
60
+
61
+ public get chunks(): ShapeDiverResponseOutputChunk[] | undefined {
62
+ return this.#chunks;
63
+ }
64
+
65
+ public get content(): ShapeDiverResponseOutputContent[] | undefined {
66
+ return this.#content;
67
+ }
68
+
69
+ public set content(value: ShapeDiverResponseOutputContent[] | undefined) {
70
+ this.#content = value;
71
+ }
72
+
73
+ public get delay(): number | undefined {
74
+ return this.#delay;
75
+ }
76
+
77
+ public get dependency(): string[] {
78
+ return this.#dependency;
79
+ }
80
+
81
+ public get displayname(): string | undefined {
82
+ return this.#displayname;
83
+ }
84
+
85
+ public set displayname(value: string | undefined) {
86
+ this.#displayname = value;
87
+ }
88
+
89
+ public get format(): string[] {
90
+ return this.#content ? this.#content.map(c => c.format) : [];
91
+ }
92
+
93
+ public get freeze(): boolean {
94
+ return this.#sessionEngine.outputsFreeze[this.#id];
95
+ }
96
+
97
+ public set freeze(value: boolean) {
98
+ this.#sessionEngine.outputsFreeze[this.#id] = value;
99
+ }
100
+
101
+ public get hidden(): boolean {
102
+ return this.#hidden;
103
+ }
104
+
105
+ public set hidden(value: boolean) {
106
+ this.#hidden = value;
107
+ }
108
+
109
+ public get id(): string {
110
+ return this.#id;
111
+ }
112
+
113
+ public get material(): string | undefined {
114
+ return this.#material;
115
+ }
116
+
117
+ public get msg(): string | undefined {
118
+ return this.#msg;
119
+ }
120
+
121
+ public get name(): string {
122
+ return this.#name;
123
+ }
124
+
125
+ public get node(): ITreeNode {
126
+ return this.#sessionEngine.node.children.find(c => c.name === this.id)!;
127
+ }
128
+
129
+ public get order(): number | undefined {
130
+ return this.#order;
131
+ }
132
+
133
+ public set order(value: number | undefined) {
134
+ this.#order = value;
135
+ }
136
+
137
+ public get status_collect(): ShapeDiverResponseModelComputationStatus | undefined {
138
+ return this.#status_collect;
139
+ }
140
+
141
+ public get status_computation(): ShapeDiverResponseModelComputationStatus | undefined {
142
+ return this.#status_computation;
143
+ }
144
+
145
+ public get tooltip(): string | undefined {
146
+ return this.#tooltip;
147
+ }
148
+
149
+ public set tooltip(value: string | undefined) {
150
+ this.#tooltip = value;
151
+ }
152
+
153
+ public get uid(): string | undefined {
154
+ return this.#uid;
155
+ }
156
+
157
+ public get updateCallback(): ((newNode?: ITreeNode, oldNode?: ITreeNode) => void) | null {
158
+ return this.#updateCallback;
159
+ }
160
+
161
+ public set updateCallback(value: ((newNode?: ITreeNode, oldNode?: ITreeNode) => void) | null) {
162
+ this.#updateCallback = value;
163
+ }
164
+
165
+ public get version(): string {
166
+ return this.#version;
167
+ }
168
+
169
+ public set version(value: string) {
170
+ this.#version = value;
171
+ }
172
+
173
+ // #endregion Public Accessors (28)
174
+
175
+ // #region Public Methods (3)
176
+
177
+ public updateOutput(newNode?: TreeNode, oldNode?: TreeNode) {
178
+ const outputDef = this.#sessionEngine.outputs[this.id];
179
+ this.updateOutputDefinition(outputDef);
180
+
181
+ // add chunk nodes
182
+ if (this.chunks && newNode) {
183
+ for (let i = 0; i < newNode.children.length; i++) {
184
+ for (let j = 0; j < this.chunks.length; j++) {
185
+ this.chunks[j].node = newNode.children[i].children.find(child => child.name === this.chunks![j].id);
186
+ }
187
+ }
188
+ }
189
+
190
+ if (this.#updateCallback) this.#updateCallback(newNode, oldNode);
191
+ }
192
+
193
+ public async updateOutputContent(outputContent: ShapeDiverResponseOutputContent[], preventUpdate: boolean = false): Promise<ITreeNode | undefined> {
194
+ this.#sessionEngine.outputs[this.id].content = outputContent;
195
+ this.#sessionEngine.outputs[this.id].version = this.#uuidGenerator.create();
196
+ if (!preventUpdate) await this.#sessionEngine.updateOutputs();
197
+ return this.node;
198
+ }
199
+
200
+ public updateOutputDefinition(outputDef: ShapeDiverResponseOutput) {
201
+ this.#dependency = outputDef.dependency;
202
+ this.#uid = outputDef.uid;
203
+ this.#material = outputDef.material;
204
+ this.#chunks = outputDef.chunks;
205
+ this.#msg = outputDef.msg;
206
+ if (this.#msg !== undefined)
207
+ this.#logger.warn(LOGGING_TOPIC.OUTPUT, `Output(${this.id}): ${this.#msg}`);
208
+ this.#bbmin = outputDef.bbmin;
209
+ this.#bbmax = outputDef.bbmax;
210
+ this.#status_computation = outputDef.status_computation;
211
+ this.#status_collect = outputDef.status_collect;
212
+ this.#content = outputDef.content;
213
+ this.#delay = outputDef.delay;
214
+ this.#version = outputDef.version;
215
+ this.#displayname = outputDef.displayname;
216
+ this.#order = outputDef.order;
217
+ this.#hidden = outputDef.hidden;
218
+ }
219
+
220
+ // #endregion Public Methods (3)
221
+ }