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