@shapediver/sdk.geometry-api-sdk-v2 1.0.6
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 +7 -0
- package/README.md +88 -0
- package/dist/ShapeDiverSdk.d.ts +45 -0
- package/dist/ShapeDiverSdk.d.ts.map +1 -0
- package/dist/ShapeDiverSdk.js +76 -0
- package/dist/ShapeDiverSdk.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts +12 -0
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverAnalyticsApi.js +30 -0
- package/dist/resources/ShapeDiverAnalyticsApi.js.map +1 -0
- package/dist/resources/ShapeDiverAssetApi.d.ts +40 -0
- package/dist/resources/ShapeDiverAssetApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverAssetApi.js +75 -0
- package/dist/resources/ShapeDiverAssetApi.js.map +1 -0
- package/dist/resources/ShapeDiverExportApi.d.ts +27 -0
- package/dist/resources/ShapeDiverExportApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverExportApi.js +53 -0
- package/dist/resources/ShapeDiverExportApi.js.map +1 -0
- package/dist/resources/ShapeDiverFileApi.d.ts +36 -0
- package/dist/resources/ShapeDiverFileApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverFileApi.js +66 -0
- package/dist/resources/ShapeDiverFileApi.js.map +1 -0
- package/dist/resources/ShapeDiverGltfApi.d.ts +15 -0
- package/dist/resources/ShapeDiverGltfApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverGltfApi.js +34 -0
- package/dist/resources/ShapeDiverGltfApi.js.map +1 -0
- package/dist/resources/ShapeDiverModelApi.d.ts +71 -0
- package/dist/resources/ShapeDiverModelApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverModelApi.js +125 -0
- package/dist/resources/ShapeDiverModelApi.js.map +1 -0
- package/dist/resources/ShapeDiverOutputApi.d.ts +27 -0
- package/dist/resources/ShapeDiverOutputApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverOutputApi.js +53 -0
- package/dist/resources/ShapeDiverOutputApi.js.map +1 -0
- package/dist/resources/ShapeDiverSdtfApi.d.ts +34 -0
- package/dist/resources/ShapeDiverSdtfApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverSdtfApi.js +64 -0
- package/dist/resources/ShapeDiverSdtfApi.js.map +1 -0
- package/dist/resources/ShapeDiverSessionApi.d.ts +32 -0
- package/dist/resources/ShapeDiverSessionApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverSessionApi.js +62 -0
- package/dist/resources/ShapeDiverSessionApi.js.map +1 -0
- package/dist/resources/ShapeDiverSystemApi.d.ts +33 -0
- package/dist/resources/ShapeDiverSystemApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverSystemApi.js +63 -0
- package/dist/resources/ShapeDiverSystemApi.js.map +1 -0
- package/dist/resources/ShapeDiverUtilsApi.d.ts +71 -0
- package/dist/resources/ShapeDiverUtilsApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverUtilsApi.js +171 -0
- package/dist/resources/ShapeDiverUtilsApi.js.map +1 -0
- package/dist/utils/utils.d.ts +3 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +9 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +58 -0
|
@@ -0,0 +1,63 @@
|
|
|
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.ShapeDiverSystemApi = void 0;
|
|
13
|
+
const sdk_geometry_api_sdk_core_1 = require("@shapediver/sdk.geometry-api-sdk-core");
|
|
14
|
+
class ShapeDiverSystemApi extends sdk_geometry_api_sdk_core_1.BaseResourceApi {
|
|
15
|
+
constructor(api) {
|
|
16
|
+
super(api);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Log the specified message.
|
|
20
|
+
*
|
|
21
|
+
* @param sessionId
|
|
22
|
+
* @param body
|
|
23
|
+
*/
|
|
24
|
+
log(sessionId, body) {
|
|
25
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
return yield this.api.post(this.buildSessionUri(sessionId) + "/log/message", body);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Remove a model with all it's components.
|
|
31
|
+
*
|
|
32
|
+
* **WARNING: This operation cannot be undone!**
|
|
33
|
+
*
|
|
34
|
+
* @param modelId
|
|
35
|
+
*/
|
|
36
|
+
pruneModel(modelId) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
return yield this.api.delete(`${this.buildSystemUri()}/model/${modelId}`);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Decrypt the given ticket.
|
|
43
|
+
*
|
|
44
|
+
* @param ticket
|
|
45
|
+
*/
|
|
46
|
+
decryptTicket(ticket) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
return yield this.api.get(this.buildTicketUri(ticket));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Create a new authentication group.
|
|
53
|
+
*
|
|
54
|
+
* @param body
|
|
55
|
+
*/
|
|
56
|
+
authGroup(body) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
return yield this.api.post(this.buildAuthGroupUri(), body);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.ShapeDiverSystemApi = ShapeDiverSystemApi;
|
|
63
|
+
//# sourceMappingURL=ShapeDiverSystemApi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapeDiverSystemApi.js","sourceRoot":"","sources":["../../src/resources/ShapeDiverSystemApi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAKA,qFAAyF;AAEzF,MAAa,mBAAoB,SAAQ,2CAAe;IAEpD,YAAa,GAAqB;QAC9B,KAAK,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED;;;;;OAKG;IACG,GAAG,CAAE,SAAiB,EAAE,IAAiC;;YAC3D,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAwB,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,GAAG,cAAc,EAAE,IAAI,CAAC,CAAA;QAC7G,CAAC;KAAA;IAED;;;;;;OAMG;IACG,UAAU,CAAE,OAAe;;YAC7B,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,CAAwB,GAAI,IAAI,CAAC,cAAc,EAAG,UAAW,OAAQ,EAAE,CAAC,CAAA;QACxG,CAAC;KAAA;IAED;;;;OAIG;IACG,aAAa,CAAE,MAAc;;YAC/B,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAwB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;QACjF,CAAC;KAAA;IAED;;;;OAIG;IACG,SAAS,CAAE,IAAyC;;YACtD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAwB,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,CAAC,CAAA;QACrF,CAAC;KAAA;CAEJ;AA7CD,kDA6CC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ShapeDiverRequestCustomization, ShapeDiverRequestExport, ShapeDiverResponseDto } from "@shapediver/api.geometry-api-dto-v2";
|
|
2
|
+
import { BaseResourceApi, ShapeDiverSdkApi } from "@shapediver/sdk.geometry-api-sdk-core";
|
|
3
|
+
import { ShapeDiverSdk } from "../ShapeDiverSdk";
|
|
4
|
+
export declare class ShapeDiverUtilsApi extends BaseResourceApi {
|
|
5
|
+
constructor(api: ShapeDiverSdkApi);
|
|
6
|
+
/**
|
|
7
|
+
* Upload the given file to the specified URL.
|
|
8
|
+
*
|
|
9
|
+
* @param href
|
|
10
|
+
* @param data
|
|
11
|
+
* @param type
|
|
12
|
+
*/
|
|
13
|
+
upload(href: string, data: ArrayBuffer, type: string): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Submit a customization request and wait for the result to be finished.
|
|
16
|
+
*
|
|
17
|
+
* @param sdk
|
|
18
|
+
* @param sessionId
|
|
19
|
+
* @param body
|
|
20
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
21
|
+
* @returns
|
|
22
|
+
*/
|
|
23
|
+
submitAndWaitForCustomization(sdk: ShapeDiverSdk, sessionId: string, body: ShapeDiverRequestCustomization, maxWaitMsec?: number): Promise<ShapeDiverResponseDto>;
|
|
24
|
+
/**
|
|
25
|
+
* Submit an export request and wait for the result to be finished.
|
|
26
|
+
*
|
|
27
|
+
* @param sdk
|
|
28
|
+
* @param sessionId
|
|
29
|
+
* @param body
|
|
30
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
31
|
+
* @returns
|
|
32
|
+
*/
|
|
33
|
+
submitAndWaitForExport(sdk: ShapeDiverSdk, sessionId: string, body: ShapeDiverRequestExport, maxWaitMsec?: number): Promise<ShapeDiverResponseDto>;
|
|
34
|
+
/**
|
|
35
|
+
* Given a DTO resulting from a customization request, wait for the results to be finished.
|
|
36
|
+
*
|
|
37
|
+
* @param sdk
|
|
38
|
+
* @param sessionId
|
|
39
|
+
* @param dto
|
|
40
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
private static waitForCustomizationResult;
|
|
44
|
+
/**
|
|
45
|
+
* Given a DTO resulting from an export request, wait for the result to be finished.
|
|
46
|
+
*
|
|
47
|
+
* @param sdk
|
|
48
|
+
* @param sessionId
|
|
49
|
+
* @param dto
|
|
50
|
+
* @param exportId
|
|
51
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
private static waitForExportResult;
|
|
55
|
+
/**
|
|
56
|
+
* Get the maximum delay which was reported for output versions.
|
|
57
|
+
*
|
|
58
|
+
* @param dto
|
|
59
|
+
* @returns maximum delay, -1 in case no delay was reported
|
|
60
|
+
*/
|
|
61
|
+
private static getMaxOutputDelay;
|
|
62
|
+
/**
|
|
63
|
+
* Get the delay which was reported for the export.
|
|
64
|
+
*
|
|
65
|
+
* @param dto
|
|
66
|
+
* @param exportId
|
|
67
|
+
* @returns delay, -1 in case no delay was reported
|
|
68
|
+
*/
|
|
69
|
+
private static getExportDelay;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=ShapeDiverUtilsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShapeDiverUtilsApi.d.ts","sourceRoot":"","sources":["../../src/resources/ShapeDiverUtilsApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,8BAA8B,EAC9B,uBAAuB,EACvB,qBAAqB,EAGxB,MAAM,qCAAqC,CAAA;AAC5C,OAAO,EAAE,eAAe,EAAmB,gBAAgB,EAAE,MAAM,uCAAuC,CAAA;AAC1G,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGhD,qBAAa,kBAAmB,SAAQ,eAAe;gBAEtC,GAAG,EAAE,gBAAgB;IAIlC;;;;;;OAMG;IACG,MAAM,CAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC;IAI1E;;;;;;;;OAQG;IACG,6BAA6B,CAC/B,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,8BAA8B,EACpC,WAAW,SAAK,GACjB,OAAO,CAAC,qBAAqB,CAAC;IAWjC;;;;;;;;OAQG;IACG,sBAAsB,CACxB,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,uBAAuB,EAC7B,WAAW,SAAK,GACjB,OAAO,CAAC,qBAAqB,CAAC;IAWjC;;;;;;;;OAQG;mBACkB,0BAA0B;IAuC/C;;;;;;;;;OASG;mBACkB,mBAAmB;IAsCxC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,cAAc;CAIhC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
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.ShapeDiverUtilsApi = void 0;
|
|
13
|
+
const sdk_geometry_api_sdk_core_1 = require("@shapediver/sdk.geometry-api-sdk-core");
|
|
14
|
+
const utils_1 = require("../utils/utils");
|
|
15
|
+
class ShapeDiverUtilsApi extends sdk_geometry_api_sdk_core_1.BaseResourceApi {
|
|
16
|
+
constructor(api) {
|
|
17
|
+
super(api);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Upload the given file to the specified URL.
|
|
21
|
+
*
|
|
22
|
+
* @param href
|
|
23
|
+
* @param data
|
|
24
|
+
* @param type
|
|
25
|
+
*/
|
|
26
|
+
upload(href, data, type) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
return yield this.api.put(href, data, { contentType: type, authorization: "disabled" });
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Submit a customization request and wait for the result to be finished.
|
|
33
|
+
*
|
|
34
|
+
* @param sdk
|
|
35
|
+
* @param sessionId
|
|
36
|
+
* @param body
|
|
37
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
submitAndWaitForCustomization(sdk, sessionId, body, maxWaitMsec = -1) {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
const startMsec = Date.now();
|
|
43
|
+
const dto = yield sdk.output.customize(sessionId, body);
|
|
44
|
+
const waitMsec = Date.now() - startMsec;
|
|
45
|
+
// Reduce the total max waiting time by the amount the customization-request took
|
|
46
|
+
maxWaitMsec = (maxWaitMsec < 0) ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec);
|
|
47
|
+
return ShapeDiverUtilsApi.waitForCustomizationResult(sdk, sessionId, dto, maxWaitMsec);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Submit an export request and wait for the result to be finished.
|
|
52
|
+
*
|
|
53
|
+
* @param sdk
|
|
54
|
+
* @param sessionId
|
|
55
|
+
* @param body
|
|
56
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
submitAndWaitForExport(sdk, sessionId, body, maxWaitMsec = -1) {
|
|
60
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const startMsec = Date.now();
|
|
62
|
+
const dto = yield sdk.export.compute(sessionId, body);
|
|
63
|
+
const waitMsec = Date.now() - startMsec;
|
|
64
|
+
// Reduce the total max waiting time by the amount the compute-request took
|
|
65
|
+
maxWaitMsec = (maxWaitMsec < 0) ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec);
|
|
66
|
+
return ShapeDiverUtilsApi.waitForExportResult(sdk, sessionId, dto, body.exports.id, maxWaitMsec);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Given a DTO resulting from a customization request, wait for the results to be finished.
|
|
71
|
+
*
|
|
72
|
+
* @param sdk
|
|
73
|
+
* @param sessionId
|
|
74
|
+
* @param dto
|
|
75
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
76
|
+
* @returns
|
|
77
|
+
*/
|
|
78
|
+
static waitForCustomizationResult(sdk, sessionId, dto, maxWaitMsec = -1) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
if (!dto.outputs)
|
|
81
|
+
throw new sdk_geometry_api_sdk_core_1.ShapeDiverError("The given DTO does not contain any outputs");
|
|
82
|
+
// Build new cache request
|
|
83
|
+
const outputVersions = {};
|
|
84
|
+
Object
|
|
85
|
+
.keys(dto.outputs)
|
|
86
|
+
.forEach(id => outputVersions[id] = dto.outputs[id].version);
|
|
87
|
+
let delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto);
|
|
88
|
+
const startMsec = Date.now();
|
|
89
|
+
while (delay > 0) {
|
|
90
|
+
// Check whether maxWaitMsec has been reached
|
|
91
|
+
if (maxWaitMsec >= 0) {
|
|
92
|
+
const waitMsec = Date.now() - startMsec;
|
|
93
|
+
if (waitMsec >= maxWaitMsec) {
|
|
94
|
+
throw new sdk_geometry_api_sdk_core_1.ShapeDiverError(`Maximum wait time of ${maxWaitMsec} ms reached`);
|
|
95
|
+
}
|
|
96
|
+
if (waitMsec + delay > maxWaitMsec) {
|
|
97
|
+
delay = maxWaitMsec - waitMsec;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
yield (0, utils_1.sleep)(delay);
|
|
101
|
+
// Send cache request
|
|
102
|
+
dto = yield sdk.output.getCache(sessionId, outputVersions);
|
|
103
|
+
delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto);
|
|
104
|
+
}
|
|
105
|
+
return dto;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Given a DTO resulting from an export request, wait for the result to be finished.
|
|
110
|
+
*
|
|
111
|
+
* @param sdk
|
|
112
|
+
* @param sessionId
|
|
113
|
+
* @param dto
|
|
114
|
+
* @param exportId
|
|
115
|
+
* @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
|
|
116
|
+
* @returns
|
|
117
|
+
*/
|
|
118
|
+
static waitForExportResult(sdk, sessionId, dto, exportId, maxWaitMsec = -1) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
if (!dto.exports)
|
|
121
|
+
throw new sdk_geometry_api_sdk_core_1.ShapeDiverError("The given DTO does not contain any exports");
|
|
122
|
+
// Build new cache request
|
|
123
|
+
const exportVersion = { [exportId]: dto.exports[exportId].version };
|
|
124
|
+
if (!dto.exports)
|
|
125
|
+
throw new sdk_geometry_api_sdk_core_1.ShapeDiverError(`Could not find any export with the id '${exportId}'`);
|
|
126
|
+
let delay = ShapeDiverUtilsApi.getExportDelay(dto, exportId);
|
|
127
|
+
const startMsec = Date.now();
|
|
128
|
+
while (delay > 0) {
|
|
129
|
+
// Check whether maxWaitMsec has been reached
|
|
130
|
+
if (maxWaitMsec >= 0) {
|
|
131
|
+
const waitMsec = Date.now() - startMsec;
|
|
132
|
+
if (waitMsec >= maxWaitMsec) {
|
|
133
|
+
throw new sdk_geometry_api_sdk_core_1.ShapeDiverError(`Maximum wait time of ${maxWaitMsec} ms reached`);
|
|
134
|
+
}
|
|
135
|
+
if (waitMsec + delay > maxWaitMsec) {
|
|
136
|
+
delay = maxWaitMsec - waitMsec;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
yield (0, utils_1.sleep)(delay);
|
|
140
|
+
// Send cache request
|
|
141
|
+
dto = yield sdk.export.getCache(sessionId, exportVersion);
|
|
142
|
+
delay = ShapeDiverUtilsApi.getExportDelay(dto, exportId);
|
|
143
|
+
}
|
|
144
|
+
return dto;
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Get the maximum delay which was reported for output versions.
|
|
149
|
+
*
|
|
150
|
+
* @param dto
|
|
151
|
+
* @returns maximum delay, -1 in case no delay was reported
|
|
152
|
+
*/
|
|
153
|
+
static getMaxOutputDelay(dto) {
|
|
154
|
+
return Math.max(...Object.values(dto.outputs)
|
|
155
|
+
.map(output => output)
|
|
156
|
+
.map(output => { var _a; return (_a = output.delay) !== null && _a !== void 0 ? _a : -1; }));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get the delay which was reported for the export.
|
|
160
|
+
*
|
|
161
|
+
* @param dto
|
|
162
|
+
* @param exportId
|
|
163
|
+
* @returns delay, -1 in case no delay was reported
|
|
164
|
+
*/
|
|
165
|
+
static getExportDelay(dto, exportId) {
|
|
166
|
+
var _a;
|
|
167
|
+
return (_a = dto.exports[exportId].delay) !== null && _a !== void 0 ? _a : -1;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.ShapeDiverUtilsApi = ShapeDiverUtilsApi;
|
|
171
|
+
//# source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;AAC/D,wBAAgB,KAAK,CAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = void 0;
|
|
4
|
+
/** Delays the response for the given number of milliseconds */
|
|
5
|
+
function sleep(ms) {
|
|
6
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
exports.sleep = sleep;
|
|
9
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AAC/D,SAAgB,KAAK,CAAE,EAAU;IAC7B,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAFD,sBAEC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shapediver/sdk.geometry-api-sdk-v2",
|
|
3
|
+
"version": "1.0.6",
|
|
4
|
+
"description": "SDK to communicate with the Geometry View API version 2",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"shapediver",
|
|
7
|
+
"sdk",
|
|
8
|
+
"geometry api",
|
|
9
|
+
"mgmt"
|
|
10
|
+
],
|
|
11
|
+
"author": "Matthias Reisacher <matt@shapediver.com>",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"directories": {
|
|
15
|
+
"test": "__tests__"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/shapediver/GeometryBackendSdkTypeScript.git"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "bash ../../scripts/test.sh",
|
|
26
|
+
"check": "tsc --noEmit",
|
|
27
|
+
"build": "bash ../../scripts/build.sh",
|
|
28
|
+
"build-dep": "bash ../../scripts/build-dep.sh"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/shapediver/GeometryBackendSdkTypeScript/issues"
|
|
32
|
+
},
|
|
33
|
+
"homepage": "https://github.com/shapediver/GeometryBackendSdkTypeScript#readme",
|
|
34
|
+
"typings": "dist/index.d.ts",
|
|
35
|
+
"jest": {
|
|
36
|
+
"preset": "ts-jest",
|
|
37
|
+
"testEnvironment": "node",
|
|
38
|
+
"testTimeout": 60000,
|
|
39
|
+
"setupFilesAfterEnv": [
|
|
40
|
+
"./test.config.js"
|
|
41
|
+
],
|
|
42
|
+
"testMatch": [
|
|
43
|
+
"**/__tests__/**/*.test.ts"
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"jest": "^27.2.4",
|
|
48
|
+
"lerna": "^3.22.1",
|
|
49
|
+
"typescript": "^4.4.3",
|
|
50
|
+
"webpack": "^5.55.1",
|
|
51
|
+
"webpack-cli": "^4.8.0",
|
|
52
|
+
"webpack-dev-server": "^4.3.0"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@shapediver/sdk.geometry-api-sdk-core": "^1.0.3",
|
|
56
|
+
"@shapediver/api.geometry-api-dto-v2": "^1.0.20"
|
|
57
|
+
}
|
|
58
|
+
}
|