@shapediver/viewer.session 3.0.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.
- package/LICENSE +73 -0
- package/README.md +1 -0
- package/dist/implementation/ExportApi.d.ts +36 -0
- package/dist/implementation/ExportApi.d.ts.map +1 -0
- package/dist/implementation/ExportApi.js +140 -0
- package/dist/implementation/ExportApi.js.map +1 -0
- package/dist/implementation/FileParameterApi.d.ts +10 -0
- package/dist/implementation/FileParameterApi.d.ts.map +1 -0
- package/dist/implementation/FileParameterApi.js +50 -0
- package/dist/implementation/FileParameterApi.js.map +1 -0
- package/dist/implementation/OutputApi.d.ts +38 -0
- package/dist/implementation/OutputApi.d.ts.map +1 -0
- package/dist/implementation/OutputApi.js +165 -0
- package/dist/implementation/OutputApi.js.map +1 -0
- package/dist/implementation/ParameterApi.d.ts +38 -0
- package/dist/implementation/ParameterApi.d.ts.map +1 -0
- package/dist/implementation/ParameterApi.js +151 -0
- package/dist/implementation/ParameterApi.js.map +1 -0
- package/dist/implementation/SessionApi.d.ts +98 -0
- package/dist/implementation/SessionApi.d.ts.map +1 -0
- package/dist/implementation/SessionApi.js +361 -0
- package/dist/implementation/SessionApi.js.map +1 -0
- package/dist/implementation/data/OutputApiData.d.ts +20 -0
- package/dist/implementation/data/OutputApiData.d.ts.map +1 -0
- package/dist/implementation/data/OutputApiData.js +51 -0
- package/dist/implementation/data/OutputApiData.js.map +1 -0
- package/dist/implementation/data/SessionApiData.d.ts +20 -0
- package/dist/implementation/data/SessionApiData.d.ts.map +1 -0
- package/dist/implementation/data/SessionApiData.js +51 -0
- package/dist/implementation/data/SessionApiData.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +120 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/IExportApi.d.ts +27 -0
- package/dist/interfaces/IExportApi.d.ts.map +1 -0
- package/dist/interfaces/IExportApi.js +3 -0
- package/dist/interfaces/IExportApi.js.map +1 -0
- package/dist/interfaces/IFileParameterApi.d.ts +35 -0
- package/dist/interfaces/IFileParameterApi.d.ts.map +1 -0
- package/dist/interfaces/IFileParameterApi.js +3 -0
- package/dist/interfaces/IFileParameterApi.js.map +1 -0
- package/dist/interfaces/IOutputApi.d.ts +75 -0
- package/dist/interfaces/IOutputApi.d.ts.map +1 -0
- package/dist/interfaces/IOutputApi.js +3 -0
- package/dist/interfaces/IOutputApi.js.map +1 -0
- package/dist/interfaces/IParameterApi.d.ts +46 -0
- package/dist/interfaces/IParameterApi.d.ts.map +1 -0
- package/dist/interfaces/IParameterApi.js +3 -0
- package/dist/interfaces/IParameterApi.js.map +1 -0
- package/dist/interfaces/ISessionApi.d.ts +477 -0
- package/dist/interfaces/ISessionApi.d.ts.map +1 -0
- package/dist/interfaces/ISessionApi.js +3 -0
- package/dist/interfaces/ISessionApi.js.map +1 -0
- package/dist/interfaces/data/IOutputApiData.d.ts +7 -0
- package/dist/interfaces/data/IOutputApiData.d.ts.map +1 -0
- package/dist/interfaces/data/IOutputApiData.js +3 -0
- package/dist/interfaces/data/IOutputApiData.js.map +1 -0
- package/dist/interfaces/data/ISessionApiData.d.ts +7 -0
- package/dist/interfaces/data/ISessionApiData.d.ts.map +1 -0
- package/dist/interfaces/data/ISessionApiData.js +3 -0
- package/dist/interfaces/data/ISessionApiData.js.map +1 -0
- package/dist/main.d.ts +37 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +96 -0
- package/dist/main.js.map +1 -0
- package/package.json +63 -0
- package/src/implementation/ExportApi.ts +158 -0
- package/src/implementation/FileParameterApi.ts +34 -0
- package/src/implementation/OutputApi.ts +178 -0
- package/src/implementation/ParameterApi.ts +176 -0
- package/src/implementation/SessionApi.ts +408 -0
- package/src/implementation/data/OutputApiData.ts +53 -0
- package/src/implementation/data/SessionApiData.ts +53 -0
- package/src/index.ts +225 -0
- package/src/interfaces/IExportApi.ts +29 -0
- package/src/interfaces/IFileParameterApi.ts +39 -0
- package/src/interfaces/IOutputApi.ts +85 -0
- package/src/interfaces/IParameterApi.ts +55 -0
- package/src/interfaces/ISessionApi.ts +461 -0
- package/src/interfaces/data/IOutputApiData.ts +16 -0
- package/src/interfaces/data/ISessionApiData.ts +16 -0
- package/src/main.ts +95 -0
- package/tsconfig.json +17 -0
package/dist/main.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createSession = exports.sessions = void 0;
|
|
13
|
+
const viewer_creation_control_center_session_1 = require("@shapediver/viewer.creation-control-center.session");
|
|
14
|
+
const viewer_shared_services_1 = require("@shapediver/viewer.shared.services");
|
|
15
|
+
const SessionApi_1 = require("./implementation/SessionApi");
|
|
16
|
+
const viewer_api_general_1 = require("@shapediver/viewer.api.general");
|
|
17
|
+
const creationControlCenterSession = viewer_creation_control_center_session_1.CreationControlCenterSession.instance;
|
|
18
|
+
const inputValidator = viewer_shared_services_1.InputValidator.instance;
|
|
19
|
+
const logger = viewer_shared_services_1.Logger.instance;
|
|
20
|
+
/**
|
|
21
|
+
* The sessions that are currently being used.
|
|
22
|
+
*/
|
|
23
|
+
exports.sessions = {};
|
|
24
|
+
// Whenever a session or viewport is added or removed, this update is called.
|
|
25
|
+
creationControlCenterSession.updateSessions = (sessionEngines) => {
|
|
26
|
+
for (const s in sessionEngines)
|
|
27
|
+
if (!exports.sessions[s])
|
|
28
|
+
exports.sessions[s] = new SessionApi_1.SessionApi(sessionEngines[s]);
|
|
29
|
+
for (const s in exports.sessions)
|
|
30
|
+
if (!sessionEngines[s])
|
|
31
|
+
delete exports.sessions[s];
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Create and initialize a session with a model hosted on a
|
|
35
|
+
* {@link https://help.shapediver.com/doc/Geometry-Backend.1863942173.html|ShapeDiver Geometry Backend},
|
|
36
|
+
* using the provided ticket/guid and modelViewUrl.
|
|
37
|
+
* Returns a session api object allowing to control the session.
|
|
38
|
+
*
|
|
39
|
+
* A JWT can be specified for authorizing the API calls to the Geometry Backend.
|
|
40
|
+
* The model's settings on the Geometry Backend might require a JWT to be provided.
|
|
41
|
+
*
|
|
42
|
+
* By default the outputs of the model for its default parameter values will be loaded.
|
|
43
|
+
*
|
|
44
|
+
* An optional identifier for the session can be provided. This identifier can be used to retrieve the
|
|
45
|
+
* api object from {@link sessions}. In case no identifier is provided, a unique one will be generated.
|
|
46
|
+
*
|
|
47
|
+
* @param properties.ticket The ticket for direct embedding of the model represented by the session. This identifies the model on the Geometry Backend. If no ticket was provided, a {@link guid} has to be provided instead.
|
|
48
|
+
* @param properties.guid The geometry backend model id (guid). This identifies the model on the Geometry Backend. A {@link jwtToken} is needed for authentication. If no guid was provided, a {@link ticket} has to be provided instead.
|
|
49
|
+
* @param properties.modelViewUrl The modelViewUrl of the {@link https://help.shapediver.com/doc/Geometry-Backend.1863942173.html|ShapeDiver Geometry Backend} hosting the model.
|
|
50
|
+
* @param properties.jwtToken The JWT to use for authorizing the API calls to the Geometry Backend.
|
|
51
|
+
* @param properties.id The unique identifier to use for the session.
|
|
52
|
+
* @param properties.waitForOutputs Option to wait for the outputs to be loaded, or return immediately after creation of the session. (default: true)
|
|
53
|
+
* @param properties.loadOutputs Option to load the outputs, or not load them until the first call of {@link ISession.customize}. (default: true)
|
|
54
|
+
* @param properties.loadSdtf Option to load the SDTF data. The data is not loaded by default as it can be quite large. (default: false)
|
|
55
|
+
* @param properties.excludeViewports Option to exclude some viewports from the start. Can be accessed via {@link ISession.excludeViewports}.
|
|
56
|
+
* @param properties.initialParameterValues The initial set of parameter values to use. Map from parameter id to parameter value. The default value will be used for any parameter not specified.
|
|
57
|
+
* @param properties.allowOutputLoading Option to allow the outputs to be loaded, or to prevent them from being loaded. (default: true)
|
|
58
|
+
* @returns
|
|
59
|
+
*/
|
|
60
|
+
const createSession = (properties) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
(0, viewer_api_general_1.showConsoleMessage)();
|
|
62
|
+
logger.debug(`createSession: Creating and initializing session with properties ${JSON.stringify(properties)}.`);
|
|
63
|
+
// input validation
|
|
64
|
+
inputValidator.validateAndError('createSession', properties, 'object');
|
|
65
|
+
inputValidator.validateAndError('createSession', properties.ticket, 'string', false);
|
|
66
|
+
inputValidator.validateAndError('createSession', properties.guid, 'string', false);
|
|
67
|
+
inputValidator.validateAndError('createSession', properties.modelViewUrl, 'string');
|
|
68
|
+
inputValidator.validateAndError('createSession', properties.jwtToken, 'string', false);
|
|
69
|
+
inputValidator.validateAndError('createSession', properties.id, 'string', false);
|
|
70
|
+
inputValidator.validateAndError('createSession', properties.waitForOutputs, 'boolean', false);
|
|
71
|
+
inputValidator.validateAndError('createSession', properties.loadOutputs, 'boolean', false);
|
|
72
|
+
inputValidator.validateAndError('createSession', properties.loadSdtf, 'boolean', false);
|
|
73
|
+
inputValidator.validateAndError('createSession', properties.excludeViewports, 'stringArray', false);
|
|
74
|
+
inputValidator.validateAndError('createSession', properties.initialParameterValues, 'object', false);
|
|
75
|
+
if (properties.initialParameterValues)
|
|
76
|
+
for (const p in properties.initialParameterValues)
|
|
77
|
+
inputValidator.validateAndError('createSession', properties.initialParameterValues[p], 'string');
|
|
78
|
+
// we either expect a ticket or guid + jwtToken, error if we get both
|
|
79
|
+
if (properties.ticket !== undefined && properties.guid !== undefined)
|
|
80
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('createSession: A ticket and a guid were provided for the session creation. Please only provide one or the other. The session was not created.');
|
|
81
|
+
// we either expect a ticket or guid + jwtToken, error if we get none
|
|
82
|
+
if (properties.ticket === undefined && properties.guid === undefined)
|
|
83
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('createSession: Neither a ticket nor a guid were provided for the session creation. Please provide one or the other. The session was not created.');
|
|
84
|
+
// we either expect a guid + jwtToken, error if the jwtToken is missing
|
|
85
|
+
if (properties.guid !== undefined && properties.jwtToken === undefined)
|
|
86
|
+
throw new viewer_shared_services_1.ShapeDiverViewerSessionError('createSession: When creating a session with a guid, a jwtToken is required, please provide one. The session was not created.');
|
|
87
|
+
if (properties.waitForOutputs === undefined)
|
|
88
|
+
properties.waitForOutputs = true;
|
|
89
|
+
if (properties.loadOutputs === undefined)
|
|
90
|
+
properties.loadOutputs = true;
|
|
91
|
+
const sessionEngine = yield creationControlCenterSession.createSessionEngine(properties);
|
|
92
|
+
exports.sessions[sessionEngine.id] = new SessionApi_1.SessionApi(sessionEngine);
|
|
93
|
+
return exports.sessions[sessionEngine.id];
|
|
94
|
+
});
|
|
95
|
+
exports.createSession = createSession;
|
|
96
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+GAA4J;AAC5J,+EAA0G;AAE1G,4DAAyD;AAEzD,uEAAoE;AAEpE,MAAM,4BAA4B,GAAkC,qEAA4B,CAAC,QAAQ,CAAC;AAC1G,MAAM,cAAc,GAAmB,uCAAc,CAAC,QAAQ,CAAC;AAC/D,MAAM,MAAM,GAAW,+BAAM,CAAC,QAAQ,CAAC;AAEvC;;GAEG;AACU,QAAA,QAAQ,GAAoC,EAAE,CAAC;AAE5D,6EAA6E;AAC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GAAG,IAAI,CAAC;IAExE,MAAM,aAAa,GAAG,MAAM,4BAA4B,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;IACzF,gBAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,uBAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,OAAO,gBAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,CAAC;AACtC,CAAC,CAAA,CAAC;AAtCW,QAAA,aAAa,iBAsCxB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shapediver/viewer.session",
|
|
3
|
+
"version": "3.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"webgl",
|
|
7
|
+
"shapediver",
|
|
8
|
+
"viewer",
|
|
9
|
+
"augumented-reality",
|
|
10
|
+
"webgl",
|
|
11
|
+
"grasshopper",
|
|
12
|
+
"typescript",
|
|
13
|
+
"3d"
|
|
14
|
+
],
|
|
15
|
+
"author": "Michael Oppitz <michael@shapediver.com>",
|
|
16
|
+
"license": "polyform-noncommercial-1.0.0",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"directories": {
|
|
19
|
+
"test": "__tests__"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src",
|
|
24
|
+
"package.json",
|
|
25
|
+
"README.md",
|
|
26
|
+
"tsconfig.json"
|
|
27
|
+
],
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/shapediver/Viewer.git"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"check": "tsc --noEmit",
|
|
37
|
+
"build": "bash ../../scripts/building/build.sh",
|
|
38
|
+
"build-watch": "bash ../../scripts/building/build-watch.sh",
|
|
39
|
+
"build-dep": "bash ../../scripts/building/build-dep.sh",
|
|
40
|
+
"doc": "typedoc"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/shapediver/Viewer/issues"
|
|
44
|
+
},
|
|
45
|
+
"homepage": "https://github.com/shapediver/Viewer#readme",
|
|
46
|
+
"typings": "dist/index.d.ts",
|
|
47
|
+
"jest": {
|
|
48
|
+
"preset": "ts-jest",
|
|
49
|
+
"testEnvironment": "jsdom"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@shapediver/sdk.geometry-api-sdk-v2": "1.8.2",
|
|
53
|
+
"@shapediver/viewer.api.general": "3.0.0",
|
|
54
|
+
"@shapediver/viewer.creation-control-center.session": "3.0.0",
|
|
55
|
+
"@shapediver/viewer.data-engine.gltf-converter": "3.0.0",
|
|
56
|
+
"@shapediver/viewer.data-engine.shared-types": "3.0.0",
|
|
57
|
+
"@shapediver/viewer.session-engine.session-engine": "3.0.0",
|
|
58
|
+
"@shapediver/viewer.shared.math": "3.0.0",
|
|
59
|
+
"@shapediver/viewer.shared.node-tree": "3.0.0",
|
|
60
|
+
"@shapediver/viewer.shared.services": "3.0.0"
|
|
61
|
+
},
|
|
62
|
+
"gitHead": "b6b0010bf5d5652aa338df8016405d97f33fcabb"
|
|
63
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { IExport } from '@shapediver/viewer.session-engine.session-engine';
|
|
2
|
+
import { IExportApi } from '../interfaces/IExportApi';
|
|
3
|
+
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
4
|
+
import {
|
|
5
|
+
ShapeDiverResponseExport,
|
|
6
|
+
ShapeDiverResponseExportContent,
|
|
7
|
+
ShapeDiverResponseExportDefinitionType,
|
|
8
|
+
ShapeDiverResponseExportResult,
|
|
9
|
+
ShapeDiverResponseModelComputationStatus,
|
|
10
|
+
ShapeDiverResponseParameterGroup
|
|
11
|
+
} from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
12
|
+
|
|
13
|
+
export class ExportApi implements IExportApi {
|
|
14
|
+
// #region Properties (3)
|
|
15
|
+
|
|
16
|
+
readonly #export: IExport;
|
|
17
|
+
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
18
|
+
readonly #logger: Logger = Logger.instance;
|
|
19
|
+
|
|
20
|
+
// #endregion Properties (3)
|
|
21
|
+
|
|
22
|
+
// #region Constructors (1)
|
|
23
|
+
|
|
24
|
+
constructor(exportD: IExport) {
|
|
25
|
+
this.#export = exportD;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// #endregion Constructors (1)
|
|
29
|
+
|
|
30
|
+
// #region Public Getters And Setters (24)
|
|
31
|
+
|
|
32
|
+
public get content(): ShapeDiverResponseExportContent[] | undefined {
|
|
33
|
+
return this.#export.content;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public get delay(): number | undefined {
|
|
37
|
+
return this.#export.delay;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public get dependency(): string[] {
|
|
41
|
+
return this.#export.dependency;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public get displayname(): string | undefined {
|
|
45
|
+
return this.#export.displayname;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public set displayname(value: string | undefined) {
|
|
49
|
+
const scope = 'displayname';
|
|
50
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, value, 'string', false);
|
|
51
|
+
this.#export.displayname = value;
|
|
52
|
+
this.#logger.debug(`ExportApi.${scope}: ${scope} was updated to ${this.#export.displayname}.`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public get filename(): string | undefined {
|
|
56
|
+
return this.#export.filename;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public get group(): ShapeDiverResponseParameterGroup | undefined {
|
|
60
|
+
return this.#export.group;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public get hidden(): boolean {
|
|
64
|
+
return this.#export.hidden;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public set hidden(value: boolean) {
|
|
68
|
+
const scope = 'hidden';
|
|
69
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, value, 'boolean');
|
|
70
|
+
this.#export.hidden = value;
|
|
71
|
+
this.#logger.debug(`ExportApi.${scope}: ${scope} was updated to ${this.#export.hidden}.`);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
public get id(): string {
|
|
75
|
+
return this.#export.id;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public get maxWaitTime(): number {
|
|
79
|
+
return this.#export.maxWaitTime;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public set maxWaitTime(value: number) {
|
|
83
|
+
const scope = 'maxWaitTime';
|
|
84
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, value, 'number');
|
|
85
|
+
this.#export.maxWaitTime = value;
|
|
86
|
+
this.#logger.debug(`ExportApi.${scope}: ${scope} was updated to ${this.#export.maxWaitTime}.`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public get msg(): string | undefined {
|
|
90
|
+
return this.#export.msg;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get name(): string {
|
|
94
|
+
return this.#export.name;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public get order(): number | undefined {
|
|
98
|
+
return this.#export.order;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public set order(value: number | undefined) {
|
|
102
|
+
const scope = 'order';
|
|
103
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, value, 'number', false);
|
|
104
|
+
this.#export.order = value;
|
|
105
|
+
this.#logger.debug(`ExportApi.${scope}: ${scope} was updated to ${this.#export.order}.`);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
public get result(): ShapeDiverResponseExportResult | undefined {
|
|
109
|
+
return this.#export.result;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public get status_collect(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
113
|
+
return this.#export.status_collect;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
public get status_computation(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
117
|
+
return this.#export.status_computation;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public get tooltip(): string | undefined {
|
|
121
|
+
return this.#export.tooltip;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public set tooltip(value: string | undefined) {
|
|
125
|
+
const scope = 'tooltip';
|
|
126
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, value, 'string', false);
|
|
127
|
+
this.#export.tooltip = value;
|
|
128
|
+
this.#logger.debug(`ExportApi.${scope}: ${scope} was updated to ${this.#export.tooltip}.`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public get type(): ShapeDiverResponseExportDefinitionType {
|
|
132
|
+
return this.#export.type;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public get uid(): string | undefined {
|
|
136
|
+
return this.#export.uid;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public get version(): string | undefined {
|
|
140
|
+
return this.#export.version;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// #endregion Public Getters And Setters (24)
|
|
144
|
+
|
|
145
|
+
// #region Public Methods (2)
|
|
146
|
+
|
|
147
|
+
public async request(parameters: { [key: string]: unknown } = {}): Promise<ShapeDiverResponseExport> {
|
|
148
|
+
const scope = 'request';
|
|
149
|
+
this.#inputValidator.validateAndError(`ExportApi.${scope}`, parameters, 'object');
|
|
150
|
+
return this.#export.request(parameters);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
public updateExport() {
|
|
154
|
+
this.#export.updateExport();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// #endregion Public Methods (2)
|
|
158
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IFileParameter } from '@shapediver/viewer.session-engine.session-engine';
|
|
2
|
+
import { IFileParameterApi } from '../interfaces/IFileParameterApi';
|
|
3
|
+
import { Logger } from '@shapediver/viewer.shared.services';
|
|
4
|
+
import { ParameterApi } from './ParameterApi';
|
|
5
|
+
|
|
6
|
+
export class FileParameterApi extends ParameterApi<File | Blob | string> implements IFileParameterApi {
|
|
7
|
+
// #region Properties (2)
|
|
8
|
+
|
|
9
|
+
readonly #logger: Logger = Logger.instance;
|
|
10
|
+
readonly #parameter: IFileParameter;
|
|
11
|
+
|
|
12
|
+
// #endregion Properties (2)
|
|
13
|
+
|
|
14
|
+
// #region Constructors (1)
|
|
15
|
+
|
|
16
|
+
constructor(parameter: IFileParameter) {
|
|
17
|
+
super(parameter);
|
|
18
|
+
this.#parameter = parameter;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// #endregion Constructors (1)
|
|
22
|
+
|
|
23
|
+
// #region Public Methods (2)
|
|
24
|
+
|
|
25
|
+
public async getFilename(fileId?: string): Promise<string | undefined> {
|
|
26
|
+
return this.#parameter.getFilename(fileId);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public upload(): Promise<string> {
|
|
30
|
+
return this.#parameter.upload();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// #endregion Public Methods (2)
|
|
34
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { InputValidator, Logger } from '@shapediver/viewer.shared.services';
|
|
2
|
+
import { IOutput, ShapeDiverResponseOutputChunk, ShapeDiverResponseOutputContent } from '@shapediver/viewer.session-engine.session-engine';
|
|
3
|
+
import { IOutputApi } from '../interfaces/IOutputApi';
|
|
4
|
+
import { ITreeNode } from '@shapediver/viewer.shared.node-tree';
|
|
5
|
+
import { OutputApiData } from './data/OutputApiData';
|
|
6
|
+
import { ShapeDiverResponseModelComputationStatus } from '@shapediver/sdk.geometry-api-sdk-v2';
|
|
7
|
+
|
|
8
|
+
export class OutputApi implements IOutputApi {
|
|
9
|
+
// #region Properties (3)
|
|
10
|
+
|
|
11
|
+
readonly #inputValidator: InputValidator = InputValidator.instance;
|
|
12
|
+
readonly #logger: Logger = Logger.instance;
|
|
13
|
+
readonly #output: IOutput;
|
|
14
|
+
|
|
15
|
+
// #endregion Properties (3)
|
|
16
|
+
|
|
17
|
+
// #region Constructors (1)
|
|
18
|
+
|
|
19
|
+
constructor(output: IOutput) {
|
|
20
|
+
this.#output = output;
|
|
21
|
+
this.#output.updateCallback = (newNode?: ITreeNode) => {
|
|
22
|
+
if (newNode && newNode.data.findIndex(d => d instanceof OutputApiData) === -1)
|
|
23
|
+
newNode.addData(new OutputApiData(this));
|
|
24
|
+
};
|
|
25
|
+
this.#output.updateCallback(this.node);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// #endregion Constructors (1)
|
|
29
|
+
|
|
30
|
+
// #region Public Getters And Setters (28)
|
|
31
|
+
|
|
32
|
+
public get bbmax(): number[] | undefined {
|
|
33
|
+
return this.#output.bbmax;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public get bbmin(): number[] | undefined {
|
|
37
|
+
return this.#output.bbmin;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public get chunks(): ShapeDiverResponseOutputChunk[] | undefined {
|
|
41
|
+
return this.#output.chunks;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public get content(): ShapeDiverResponseOutputContent[] | undefined {
|
|
45
|
+
return this.#output.content;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public get delay(): number | undefined {
|
|
49
|
+
return this.#output.delay;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public get dependency(): string[] {
|
|
53
|
+
return this.#output.dependency;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public get displayname(): string | undefined {
|
|
57
|
+
return this.#output.displayname;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public set displayname(value: string | undefined) {
|
|
61
|
+
const scope = 'displayname';
|
|
62
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'string', false);
|
|
63
|
+
this.#output.displayname = value;
|
|
64
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.displayname}.`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public get format(): string[] {
|
|
68
|
+
return this.#output.format;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public get freeze(): boolean {
|
|
72
|
+
return this.#output.freeze;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public set freeze(value: boolean) {
|
|
76
|
+
const scope = 'freeze';
|
|
77
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'boolean');
|
|
78
|
+
this.#output.freeze = value;
|
|
79
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.freeze}.`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public get hidden(): boolean {
|
|
83
|
+
return this.#output.hidden;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public set hidden(value: boolean) {
|
|
87
|
+
const scope = 'hidden';
|
|
88
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'boolean');
|
|
89
|
+
this.#output.hidden = value;
|
|
90
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.hidden}.`);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
public get id(): string {
|
|
94
|
+
return this.#output.id;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public get material(): string | undefined {
|
|
98
|
+
return this.#output.material;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public get msg(): string | undefined {
|
|
102
|
+
return this.#output.msg;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public get name(): string {
|
|
106
|
+
return this.#output.name;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
public get node(): ITreeNode | undefined {
|
|
110
|
+
return this.#output.node;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
public get order(): number | undefined {
|
|
114
|
+
return this.#output.order;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public set order(value: number | undefined) {
|
|
118
|
+
const scope = 'order';
|
|
119
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'number', false);
|
|
120
|
+
this.#output.order = value;
|
|
121
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.order}.`);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
public get status_collect(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
125
|
+
return this.#output.status_collect;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public get status_computation(): ShapeDiverResponseModelComputationStatus | undefined {
|
|
129
|
+
return this.#output.status_computation;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public get tooltip(): string | undefined {
|
|
133
|
+
return this.#output.tooltip;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public set tooltip(value: string | undefined) {
|
|
137
|
+
const scope = 'tooltip';
|
|
138
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'string', false);
|
|
139
|
+
this.#output.tooltip = value;
|
|
140
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${this.#output.tooltip}.`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public get uid(): string | undefined {
|
|
144
|
+
return this.#output.uid;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public get updateCallback(): ((newNode?: ITreeNode, oldNode?: ITreeNode) => void | Promise<void>) | null {
|
|
148
|
+
return this.#output.updateCallback;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public set updateCallback(value: ((newNode?: ITreeNode, oldNode?: ITreeNode) => void | Promise<void>) | null) {
|
|
152
|
+
const scope = 'updateCallback';
|
|
153
|
+
if (value) this.#inputValidator.validateAndError(`OutputApi.${scope}`, value, 'function', false);
|
|
154
|
+
this.#output.updateCallback = async (newNode?: ITreeNode, oldNode?: ITreeNode) => {
|
|
155
|
+
if (newNode && newNode.data.findIndex(d => d instanceof OutputApiData) === -1)
|
|
156
|
+
newNode.addData(new OutputApiData(this));
|
|
157
|
+
if (value) await Promise.resolve(value(newNode, oldNode));
|
|
158
|
+
};
|
|
159
|
+
this.#logger.debug(`OutputApi.${scope}: ${scope} was updated to ${value}.`);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public get version(): string {
|
|
163
|
+
return this.#output.version;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// #endregion Public Getters And Setters (28)
|
|
167
|
+
|
|
168
|
+
// #region Public Methods (1)
|
|
169
|
+
|
|
170
|
+
public async updateOutputContent(outputContent: ShapeDiverResponseOutputContent[], preventUpdate: boolean = false): Promise<ITreeNode | undefined> {
|
|
171
|
+
const scope = 'updateOutputContent';
|
|
172
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, outputContent, 'array');
|
|
173
|
+
this.#inputValidator.validateAndError(`OutputApi.${scope}`, preventUpdate, 'boolean');
|
|
174
|
+
return this.#output.updateOutputContent(outputContent, preventUpdate);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// #endregion Public Methods (1)
|
|
178
|
+
}
|