@shapediver/sdk.geometry-api-sdk-v2 1.9.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapeDiverSdk.d.ts +3 -0
- package/dist/ShapeDiverSdk.d.ts.map +1 -1
- package/dist/ShapeDiverSdk.js +5 -0
- package/dist/ShapeDiverSdk.js.map +1 -1
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts +6 -1
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js +36 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js.map +1 -1
- package/dist/resources/ShapeDiverArSceneApi.d.ts +3 -3
- package/dist/resources/ShapeDiverArSceneApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverArSceneApi.js +6 -6
- package/dist/resources/ShapeDiverArSceneApi.js.map +1 -1
- package/dist/resources/ShapeDiverAssetApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverAssetApi.js +12 -10
- package/dist/resources/ShapeDiverAssetApi.js.map +1 -1
- package/dist/resources/ShapeDiverExportApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverExportApi.js +4 -4
- package/dist/resources/ShapeDiverExportApi.js.map +1 -1
- package/dist/resources/ShapeDiverFileApi.d.ts +1 -1
- package/dist/resources/ShapeDiverFileApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverFileApi.js +7 -4
- package/dist/resources/ShapeDiverFileApi.js.map +1 -1
- package/dist/resources/ShapeDiverGltfApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverGltfApi.js +1 -1
- package/dist/resources/ShapeDiverGltfApi.js.map +1 -1
- package/dist/resources/ShapeDiverModelApi.d.ts +1 -1
- package/dist/resources/ShapeDiverModelApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverModelApi.js +18 -19
- package/dist/resources/ShapeDiverModelApi.js.map +1 -1
- package/dist/resources/ShapeDiverModelStateApi.d.ts +14 -0
- package/dist/resources/ShapeDiverModelStateApi.d.ts.map +1 -0
- package/dist/resources/ShapeDiverModelStateApi.js +104 -0
- package/dist/resources/ShapeDiverModelStateApi.js.map +1 -0
- package/dist/resources/ShapeDiverOutputApi.d.ts +1 -1
- package/dist/resources/ShapeDiverOutputApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverOutputApi.js +8 -5
- package/dist/resources/ShapeDiverOutputApi.js.map +1 -1
- package/dist/resources/ShapeDiverSdtfApi.d.ts +1 -1
- package/dist/resources/ShapeDiverSdtfApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSdtfApi.js +7 -4
- package/dist/resources/ShapeDiverSdtfApi.js.map +1 -1
- package/dist/resources/ShapeDiverSessionApi.d.ts +2 -2
- package/dist/resources/ShapeDiverSessionApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSessionApi.js +15 -5
- package/dist/resources/ShapeDiverSessionApi.js.map +1 -1
- package/dist/resources/ShapeDiverSystemApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSystemApi.js +2 -2
- package/dist/resources/ShapeDiverSystemApi.js.map +1 -1
- package/dist/resources/ShapeDiverTextureApi.d.ts +1 -1
- package/dist/resources/ShapeDiverTextureApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverTextureApi.js +5 -2
- package/dist/resources/ShapeDiverTextureApi.js.map +1 -1
- package/dist/resources/ShapeDiverUtilsApi.js +3 -3
- package/dist/resources/ShapeDiverUtilsApi.js.map +1 -1
- package/package.json +6 -6
- package/src/ShapeDiverSdk.ts +7 -0
- package/src/resources/ShapeDiverAnalyticsApi.ts +74 -0
- package/src/resources/ShapeDiverArSceneApi.ts +11 -9
- package/src/resources/ShapeDiverAssetApi.ts +19 -7
- package/src/resources/ShapeDiverExportApi.ts +4 -1
- package/src/resources/ShapeDiverFileApi.ts +8 -0
- package/src/resources/ShapeDiverGltfApi.ts +2 -1
- package/src/resources/ShapeDiverModelApi.ts +30 -13
- package/src/resources/ShapeDiverModelStateApi.ts +163 -0
- package/src/resources/ShapeDiverOutputApi.ts +10 -1
- package/src/resources/ShapeDiverSdtfApi.ts +8 -0
- package/src/resources/ShapeDiverSessionApi.ts +29 -0
- package/src/resources/ShapeDiverSystemApi.ts +2 -0
- package/src/resources/ShapeDiverTextureApi.ts +9 -1
- package/src/resources/ShapeDiverUtilsApi.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapediver/sdk.geometry-api-sdk-v2",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "SDK to communicate with the Geometry API version 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shapediver",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"jest": "~29.7.0",
|
|
50
|
-
"lerna": "8.1.
|
|
51
|
-
"typescript": "~5.5.
|
|
52
|
-
"webpack": "~5.
|
|
50
|
+
"lerna": "8.1.8",
|
|
51
|
+
"typescript": "~5.5.4",
|
|
52
|
+
"webpack": "~5.94.0",
|
|
53
53
|
"webpack-cli": "~5.1.4",
|
|
54
54
|
"webpack-dev-server": "~5.0.4"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@shapediver/sdk.geometry-api-sdk-core": "~1.
|
|
58
|
-
"@shapediver/api.geometry-api-dto-v2": "~1.
|
|
57
|
+
"@shapediver/sdk.geometry-api-sdk-core": "~1.5.0",
|
|
58
|
+
"@shapediver/api.geometry-api-dto-v2": "~1.23.0"
|
|
59
59
|
}
|
|
60
60
|
}
|
package/src/ShapeDiverSdk.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { ShapeDiverSessionApi } from "./resources/ShapeDiverSessionApi";
|
|
|
15
15
|
import { ShapeDiverSystemApi } from "./resources/ShapeDiverSystemApi";
|
|
16
16
|
import { ShapeDiverTextureApi } from "./resources/ShapeDiverTextureApi";
|
|
17
17
|
import { ShapeDiverUtilsApi } from "./resources/ShapeDiverUtilsApi";
|
|
18
|
+
import { ShapeDiverModelStateApi } from "./resources/ShapeDiverModelStateApi";
|
|
18
19
|
|
|
19
20
|
export function create(baseUrl: string, jwt?: string): ShapeDiverSdk {
|
|
20
21
|
return new ShapeDiverSdk(baseUrl, jwt);
|
|
@@ -28,6 +29,7 @@ export class ShapeDiverSdk extends BaseShapeDiverSdk {
|
|
|
28
29
|
private readonly _file: ShapeDiverFileApi;
|
|
29
30
|
private readonly _gltf: ShapeDiverGltfApi;
|
|
30
31
|
private readonly _model: ShapeDiverModelApi;
|
|
32
|
+
private readonly _modelState: ShapeDiverModelStateApi;
|
|
31
33
|
private readonly _output: ShapeDiverOutputApi;
|
|
32
34
|
private readonly _sdtf: ShapeDiverSdtfApi;
|
|
33
35
|
private readonly _session: ShapeDiverSessionApi;
|
|
@@ -52,6 +54,7 @@ export class ShapeDiverSdk extends BaseShapeDiverSdk {
|
|
|
52
54
|
this._file = new ShapeDiverFileApi(this.sdkApi);
|
|
53
55
|
this._gltf = new ShapeDiverGltfApi(this.sdkApi);
|
|
54
56
|
this._model = new ShapeDiverModelApi(this.sdkApi);
|
|
57
|
+
this._modelState = new ShapeDiverModelStateApi(this.sdkApi);
|
|
55
58
|
this._output = new ShapeDiverOutputApi(this.sdkApi);
|
|
56
59
|
this._sdtf = new ShapeDiverSdtfApi(this.sdkApi);
|
|
57
60
|
this._session = new ShapeDiverSessionApi(this.sdkApi);
|
|
@@ -88,6 +91,10 @@ export class ShapeDiverSdk extends BaseShapeDiverSdk {
|
|
|
88
91
|
return this._model;
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
get modelState(): ShapeDiverModelStateApi {
|
|
95
|
+
return this._modelState;
|
|
96
|
+
}
|
|
97
|
+
|
|
91
98
|
get output(): ShapeDiverOutputApi {
|
|
92
99
|
return this._output;
|
|
93
100
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ShapeDiverRequestAnalyticsCreditMetrics,
|
|
2
3
|
ShapeDiverRequestAnalyticsModel,
|
|
3
4
|
ShapeDiverResponseDto,
|
|
4
5
|
} from "@shapediver/api.geometry-api-dto-v2";
|
|
@@ -26,9 +27,82 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
26
27
|
(
|
|
27
28
|
await this.api.put<ShapeDiverResponseDto>(
|
|
28
29
|
this.buildAnalyticsUri() + "/session/model",
|
|
30
|
+
undefined,
|
|
29
31
|
body,
|
|
30
32
|
)
|
|
31
33
|
)[1],
|
|
32
34
|
);
|
|
33
35
|
}
|
|
36
|
+
|
|
37
|
+
/** Get credit metrics. */
|
|
38
|
+
async creditMetrics(
|
|
39
|
+
body: ShapeDiverRequestAnalyticsCreditMetrics,
|
|
40
|
+
): Promise<ShapeDiverResponseDto> {
|
|
41
|
+
return await sendRequest(
|
|
42
|
+
async () =>
|
|
43
|
+
(
|
|
44
|
+
await this.api.put<ShapeDiverResponseDto>(
|
|
45
|
+
this.buildAnalyticsUri() + "/credit-metrics",
|
|
46
|
+
undefined,
|
|
47
|
+
body,
|
|
48
|
+
)
|
|
49
|
+
)[1],
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Get credit metrics of all users active at timestamp. */
|
|
54
|
+
async userCreditMetrics(timestamp: string): Promise<ShapeDiverResponseDto> {
|
|
55
|
+
return await sendRequest(
|
|
56
|
+
async () =>
|
|
57
|
+
(
|
|
58
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
59
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/user`,
|
|
60
|
+
)
|
|
61
|
+
)[1],
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Get credit metrics of all organizations with users active at timestamp. */
|
|
66
|
+
async organizationCreditMetrics(
|
|
67
|
+
timestamp: string,
|
|
68
|
+
): Promise<ShapeDiverResponseDto> {
|
|
69
|
+
return await sendRequest(
|
|
70
|
+
async () =>
|
|
71
|
+
(
|
|
72
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
73
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/org`,
|
|
74
|
+
)
|
|
75
|
+
)[1],
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Get model credit metrics of the user at timestamp. */
|
|
80
|
+
async modelUserCreditMetrics(
|
|
81
|
+
userId: string,
|
|
82
|
+
timestamp: string,
|
|
83
|
+
): Promise<ShapeDiverResponseDto> {
|
|
84
|
+
return await sendRequest(
|
|
85
|
+
async () =>
|
|
86
|
+
(
|
|
87
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
88
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/user/${userId}`,
|
|
89
|
+
)
|
|
90
|
+
)[1],
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Get model credit metrics of the organization at timestamp. */
|
|
95
|
+
async modelOrganizationCreditMetrics(
|
|
96
|
+
orgId: string,
|
|
97
|
+
timestamp: string,
|
|
98
|
+
): Promise<ShapeDiverResponseDto> {
|
|
99
|
+
return await sendRequest(
|
|
100
|
+
async () =>
|
|
101
|
+
(
|
|
102
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
103
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/org/${orgId}`,
|
|
104
|
+
)
|
|
105
|
+
)[1],
|
|
106
|
+
);
|
|
107
|
+
}
|
|
34
108
|
}
|
|
@@ -13,14 +13,14 @@ export class ShapeDiverArSceneApi extends BaseResourceApi {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Checks the existence of the specific AR scene.
|
|
16
|
-
* @param
|
|
16
|
+
* @param id AR scene ID or Model-State ID.
|
|
17
17
|
* @returns `true` when the AR scene exists, otherwise `false`.
|
|
18
18
|
*/
|
|
19
|
-
async exists(
|
|
19
|
+
async exists(id: string): Promise<boolean> {
|
|
20
20
|
return await sendRequest(async () => {
|
|
21
21
|
try {
|
|
22
22
|
const [_, status] = await this.api.head(
|
|
23
|
-
`${this.buildArSceneUri()}/${
|
|
23
|
+
`${this.buildArSceneUri()}/${id}`,
|
|
24
24
|
{ disableAuthorization: true },
|
|
25
25
|
);
|
|
26
26
|
return status === 200;
|
|
@@ -36,13 +36,14 @@ export class ShapeDiverArSceneApi extends BaseResourceApi {
|
|
|
36
36
|
/**
|
|
37
37
|
* Download the glTF file of the specified AR scene.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
39
|
+
* @param id AR scene ID or Model-State ID.
|
|
40
40
|
* @returns Array of size 2: [0] = content data, [1] = content type
|
|
41
41
|
*/
|
|
42
|
-
async getGltf(
|
|
42
|
+
async getGltf(id: string): Promise<[ArrayBuffer, string]> {
|
|
43
43
|
return await sendRequest(async () => {
|
|
44
44
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
45
|
-
`${this.buildArSceneUri()}/${
|
|
45
|
+
`${this.buildArSceneUri()}/${id}/gltf`,
|
|
46
|
+
undefined,
|
|
46
47
|
{
|
|
47
48
|
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
48
49
|
disableAuthorization: true,
|
|
@@ -56,13 +57,14 @@ export class ShapeDiverArSceneApi extends BaseResourceApi {
|
|
|
56
57
|
/**
|
|
57
58
|
* Download the USDZ file of the specified AR scene.
|
|
58
59
|
*
|
|
59
|
-
* @param
|
|
60
|
+
* @param id AR scene ID or Model-State ID.
|
|
60
61
|
* @returns Array of size 2: [0] = content data, [1] = content type
|
|
61
62
|
*/
|
|
62
|
-
async getUsdz(
|
|
63
|
+
async getUsdz(id: string): Promise<[ArrayBuffer, string]> {
|
|
63
64
|
return await sendRequest(async () => {
|
|
64
65
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
65
|
-
`${this.buildArSceneUri()}/${
|
|
66
|
+
`${this.buildArSceneUri()}/${id}/usdz`,
|
|
67
|
+
undefined,
|
|
66
68
|
{
|
|
67
69
|
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
68
70
|
disableAuthorization: true,
|
|
@@ -33,6 +33,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
33
33
|
return await sendRequest(async () => {
|
|
34
34
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
35
35
|
`${this.buildSessionUri(sessionId)}/export/${assetData}`,
|
|
36
|
+
undefined,
|
|
36
37
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
37
38
|
);
|
|
38
39
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -53,6 +54,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
53
54
|
return await sendRequest(async () => {
|
|
54
55
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
55
56
|
`${this.buildSessionUri(sessionId)}/output/${assetData}`,
|
|
57
|
+
undefined,
|
|
56
58
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
57
59
|
);
|
|
58
60
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -75,6 +77,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
75
77
|
(
|
|
76
78
|
await this.api.get<ArrayBuffer>(
|
|
77
79
|
`${this.buildSessionUri(sessionId)}/output/${assetData}`,
|
|
80
|
+
undefined,
|
|
78
81
|
{
|
|
79
82
|
responseType: ShapeDiverSdkApiResponseType.JSON,
|
|
80
83
|
accept: "model/vnd.sdtf+json",
|
|
@@ -97,6 +100,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
97
100
|
return await sendRequest(async () => {
|
|
98
101
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
99
102
|
`${this.buildSessionUri(sessionId)}/texture/${assetData}`,
|
|
103
|
+
undefined,
|
|
100
104
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
101
105
|
);
|
|
102
106
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -116,6 +120,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
116
120
|
(
|
|
117
121
|
await this.api.get<ArrayBuffer>(
|
|
118
122
|
`${this.buildSessionUri(sessionId)}/gltf/${assetData}`,
|
|
123
|
+
undefined,
|
|
119
124
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
120
125
|
)
|
|
121
126
|
)[1],
|
|
@@ -134,6 +139,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
134
139
|
(
|
|
135
140
|
await this.api.get<ArrayBuffer>(
|
|
136
141
|
`${this.buildSessionUri(sessionId)}/usdz/${assetData}`,
|
|
142
|
+
undefined,
|
|
137
143
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
138
144
|
)
|
|
139
145
|
)[1],
|
|
@@ -151,21 +157,27 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
151
157
|
sessionId: string,
|
|
152
158
|
url: string,
|
|
153
159
|
): Promise<[ArrayBuffer, string]> {
|
|
154
|
-
let targetUrl: string;
|
|
160
|
+
let targetUrl: string, queries: string[];
|
|
155
161
|
|
|
156
162
|
if (apiAssetTextureUri.test(url) || cdnAssetTextureUri.test(url)) {
|
|
157
163
|
// Call ShapeDiver texture-asset URLs directly
|
|
158
164
|
targetUrl = url;
|
|
165
|
+
queries = [];
|
|
159
166
|
} else {
|
|
160
167
|
// All other source URLs are called via the download-image endpoint
|
|
161
|
-
targetUrl = `${this.buildSessionUri(sessionId)}/image
|
|
168
|
+
targetUrl = `${this.buildSessionUri(sessionId)}/image`;
|
|
169
|
+
queries = [`url=${encodeBase64(url)}`];
|
|
162
170
|
}
|
|
163
171
|
|
|
164
172
|
return await sendRequest(async () => {
|
|
165
|
-
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
174
|
+
targetUrl,
|
|
175
|
+
queries,
|
|
176
|
+
{
|
|
177
|
+
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
178
|
+
disableAuthorization: cdnAssetUri.test(url), // disable for CDN URLs
|
|
179
|
+
},
|
|
180
|
+
);
|
|
169
181
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
170
182
|
return [data, contentType];
|
|
171
183
|
});
|
|
@@ -202,7 +214,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
202
214
|
);
|
|
203
215
|
|
|
204
216
|
return await sendRequest(async () => {
|
|
205
|
-
const [header, data] = await this.api.get<ArrayBuffer>(url, {
|
|
217
|
+
const [header, data] = await this.api.get<ArrayBuffer>(url, undefined, {
|
|
206
218
|
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
207
219
|
disableAuthorization: cdnAssetUri.test(url), // disable for CDN URLs
|
|
208
220
|
});
|
|
@@ -30,6 +30,7 @@ export class ShapeDiverExportApi extends BaseResourceApi {
|
|
|
30
30
|
(
|
|
31
31
|
await this.api.put<ShapeDiverResponseDto>(
|
|
32
32
|
this.buildSessionUri(sessionId) + "/export",
|
|
33
|
+
undefined,
|
|
33
34
|
body,
|
|
34
35
|
)
|
|
35
36
|
)[1],
|
|
@@ -51,6 +52,7 @@ export class ShapeDiverExportApi extends BaseResourceApi {
|
|
|
51
52
|
(
|
|
52
53
|
await this.api.put<ShapeDiverResponseDto>(
|
|
53
54
|
this.buildSessionUri(sessionId) + "/export/cache",
|
|
55
|
+
undefined,
|
|
54
56
|
body,
|
|
55
57
|
)
|
|
56
58
|
)[1],
|
|
@@ -72,6 +74,7 @@ export class ShapeDiverExportApi extends BaseResourceApi {
|
|
|
72
74
|
(
|
|
73
75
|
await this.api.patch<ShapeDiverResponseDto>(
|
|
74
76
|
this.buildModelUri(modelId) + "/export",
|
|
77
|
+
undefined,
|
|
75
78
|
body,
|
|
76
79
|
)
|
|
77
80
|
)[1],
|
|
@@ -92,7 +95,7 @@ export class ShapeDiverExportApi extends BaseResourceApi {
|
|
|
92
95
|
async () =>
|
|
93
96
|
(
|
|
94
97
|
await this.api.get<ShapeDiverResponseDto>(
|
|
95
|
-
this.buildSessionUri(sessionId)
|
|
98
|
+
`${this.buildSessionUri(sessionId)}/export/${exportId}/list`,
|
|
96
99
|
)
|
|
97
100
|
)[1],
|
|
98
101
|
);
|
|
@@ -28,12 +28,18 @@ export class ShapeDiverFileApi extends BaseResourceApi {
|
|
|
28
28
|
async list(
|
|
29
29
|
sessionId: string,
|
|
30
30
|
paramId: string,
|
|
31
|
+
offset?: string,
|
|
31
32
|
): Promise<ShapeDiverResponseDto> {
|
|
33
|
+
// Build queries
|
|
34
|
+
const queries: string[] = [];
|
|
35
|
+
if (offset !== undefined) queries.push("offset=" + offset);
|
|
36
|
+
|
|
32
37
|
return await sendRequest(
|
|
33
38
|
async () =>
|
|
34
39
|
(
|
|
35
40
|
await this.api.get<ShapeDiverResponseDto>(
|
|
36
41
|
`${this.buildSessionUri(sessionId)}/file/${paramId}/list`,
|
|
42
|
+
queries,
|
|
37
43
|
)
|
|
38
44
|
)[1],
|
|
39
45
|
);
|
|
@@ -91,6 +97,7 @@ export class ShapeDiverFileApi extends BaseResourceApi {
|
|
|
91
97
|
(
|
|
92
98
|
await this.api.get<ArrayBuffer>(
|
|
93
99
|
`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
|
|
100
|
+
undefined,
|
|
94
101
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
95
102
|
)
|
|
96
103
|
)[1],
|
|
@@ -134,6 +141,7 @@ export class ShapeDiverFileApi extends BaseResourceApi {
|
|
|
134
141
|
(
|
|
135
142
|
await this.api.post<ShapeDiverResponseDto>(
|
|
136
143
|
this.buildSessionUri(sessionId) + "/file/upload",
|
|
144
|
+
undefined,
|
|
137
145
|
body,
|
|
138
146
|
)
|
|
139
147
|
)[1],
|
|
@@ -32,7 +32,8 @@ export class ShapeDiverGltfApi extends BaseResourceApi {
|
|
|
32
32
|
async () =>
|
|
33
33
|
(
|
|
34
34
|
await this.api.post<ShapeDiverResponseDto>(
|
|
35
|
-
`${this.buildSessionUri(sessionId)}/gltf
|
|
35
|
+
`${this.buildSessionUri(sessionId)}/gltf`,
|
|
36
|
+
[`conversion=${queryConvert}`],
|
|
36
37
|
body,
|
|
37
38
|
{
|
|
38
39
|
contentType: type,
|
|
@@ -42,7 +42,13 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
42
42
|
async create(body: ShapeDiverRequestModel): Promise<ShapeDiverResponseDto> {
|
|
43
43
|
return await sendRequest(
|
|
44
44
|
async () =>
|
|
45
|
-
(
|
|
45
|
+
(
|
|
46
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
47
|
+
this.commonPath,
|
|
48
|
+
undefined,
|
|
49
|
+
body,
|
|
50
|
+
)
|
|
51
|
+
)[1],
|
|
46
52
|
);
|
|
47
53
|
}
|
|
48
54
|
|
|
@@ -61,6 +67,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
61
67
|
(
|
|
62
68
|
await this.api.put<ShapeDiverResponseDto>(
|
|
63
69
|
this.buildModelUri(modelId),
|
|
70
|
+
undefined,
|
|
64
71
|
body,
|
|
65
72
|
)
|
|
66
73
|
)[1],
|
|
@@ -86,11 +93,18 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
86
93
|
/**
|
|
87
94
|
* List models.
|
|
88
95
|
*/
|
|
89
|
-
async list(): Promise<ShapeDiverResponseDto> {
|
|
96
|
+
async list(offset?: string): Promise<ShapeDiverResponseDto> {
|
|
97
|
+
// Build queries
|
|
98
|
+
const queries: string[] = [];
|
|
99
|
+
if (offset !== undefined) queries.push("offset=" + offset);
|
|
100
|
+
|
|
90
101
|
return await sendRequest(
|
|
91
102
|
async () =>
|
|
92
103
|
(
|
|
93
|
-
await this.api.get<ShapeDiverResponseDto>(
|
|
104
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
105
|
+
`${this.commonPath}/list`,
|
|
106
|
+
queries,
|
|
107
|
+
)
|
|
94
108
|
)[1],
|
|
95
109
|
);
|
|
96
110
|
}
|
|
@@ -126,6 +140,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
126
140
|
(
|
|
127
141
|
await this.api.post<ShapeDiverResponseDto>(
|
|
128
142
|
this.buildModelUri(modelId) + "/config",
|
|
143
|
+
undefined,
|
|
129
144
|
body,
|
|
130
145
|
)
|
|
131
146
|
)[1],
|
|
@@ -147,6 +162,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
147
162
|
(
|
|
148
163
|
await this.api.patch<ShapeDiverResponseDto>(
|
|
149
164
|
this.buildModelUri(modelId) + "/config",
|
|
165
|
+
undefined,
|
|
150
166
|
body,
|
|
151
167
|
)
|
|
152
168
|
)[1],
|
|
@@ -164,6 +180,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
164
180
|
(
|
|
165
181
|
await this.api.get<ArrayBuffer>(
|
|
166
182
|
this.buildModelUri(modelId) + "/file/download",
|
|
183
|
+
undefined,
|
|
167
184
|
{
|
|
168
185
|
contentType: "application/json",
|
|
169
186
|
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
@@ -188,6 +205,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
188
205
|
(
|
|
189
206
|
await this.api.patch<ShapeDiverResponseDto>(
|
|
190
207
|
this.buildModelUri(modelId) + "/parameter/defval",
|
|
208
|
+
undefined,
|
|
191
209
|
body,
|
|
192
210
|
)
|
|
193
211
|
)[1],
|
|
@@ -209,6 +227,7 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
209
227
|
(
|
|
210
228
|
await this.api.patch<ShapeDiverResponseDto>(
|
|
211
229
|
this.buildModelUri(modelId) + "/parameter",
|
|
230
|
+
undefined,
|
|
212
231
|
body,
|
|
213
232
|
)
|
|
214
233
|
)[1],
|
|
@@ -255,7 +274,8 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
255
274
|
async () =>
|
|
256
275
|
(
|
|
257
276
|
await this.api.get<ShapeDiverResponseDto>(
|
|
258
|
-
this.buildModelUri(modelId) + "/computations
|
|
277
|
+
this.buildModelUri(modelId) + "/computations",
|
|
278
|
+
queries,
|
|
259
279
|
)
|
|
260
280
|
)[1],
|
|
261
281
|
);
|
|
@@ -279,9 +299,8 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
279
299
|
async () =>
|
|
280
300
|
(
|
|
281
301
|
await this.api.post<ShapeDiverResponseDto>(
|
|
282
|
-
this.buildModelUri(modelId) +
|
|
283
|
-
|
|
284
|
-
untilLastSeen,
|
|
302
|
+
this.buildModelUri(modelId) + "/cleanup/export",
|
|
303
|
+
[`untilLastSeen=${untilLastSeen}`],
|
|
285
304
|
)
|
|
286
305
|
)[1],
|
|
287
306
|
);
|
|
@@ -305,9 +324,8 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
305
324
|
async () =>
|
|
306
325
|
(
|
|
307
326
|
await this.api.post<ShapeDiverResponseDto>(
|
|
308
|
-
this.buildModelUri(modelId) +
|
|
309
|
-
|
|
310
|
-
untilLastSeen,
|
|
327
|
+
this.buildModelUri(modelId) + "/cleanup/output",
|
|
328
|
+
[`untilLastSeen=${untilLastSeen}`],
|
|
311
329
|
)
|
|
312
330
|
)[1],
|
|
313
331
|
);
|
|
@@ -331,9 +349,8 @@ export class ShapeDiverModelApi extends BaseResourceApi {
|
|
|
331
349
|
async () =>
|
|
332
350
|
(
|
|
333
351
|
await this.api.post<ShapeDiverResponseDto>(
|
|
334
|
-
this.buildModelUri(modelId) +
|
|
335
|
-
|
|
336
|
-
untilLastSeen,
|
|
352
|
+
this.buildModelUri(modelId) + "/cleanup/texture",
|
|
353
|
+
[`untilLastSeen=${untilLastSeen}`],
|
|
337
354
|
)
|
|
338
355
|
)[1],
|
|
339
356
|
);
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BaseResourceApi,
|
|
3
|
+
ShapeDiverResponseError,
|
|
4
|
+
ShapeDiverSdkApi,
|
|
5
|
+
ShapeDiverSdkApiResponseType,
|
|
6
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
7
|
+
import { sendRequest } from "../utils/utils";
|
|
8
|
+
import {
|
|
9
|
+
ShapeDiverRequestModelState,
|
|
10
|
+
ShapeDiverResponseDto,
|
|
11
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
12
|
+
|
|
13
|
+
export class ShapeDiverModelStateApi extends BaseResourceApi {
|
|
14
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
15
|
+
super(api);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Checks the existence of a Model-State.
|
|
20
|
+
* @param modelStateId The ID of the Model-State.
|
|
21
|
+
* @returns A boolean indicating whether the Model-State exists.
|
|
22
|
+
*/
|
|
23
|
+
async exists(modelStateId: string): Promise<boolean> {
|
|
24
|
+
return await sendRequest(async () => {
|
|
25
|
+
try {
|
|
26
|
+
const [_, status] = await this.api.head(
|
|
27
|
+
this.buildModelStateUri(modelStateId),
|
|
28
|
+
{ disableAuthorization: true },
|
|
29
|
+
);
|
|
30
|
+
return status === 200;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
// A 404 HTTP status is returned when the Model-State was not found.
|
|
33
|
+
if (e instanceof ShapeDiverResponseError && e.status === 404)
|
|
34
|
+
return false;
|
|
35
|
+
else throw e;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Get a Model-State.
|
|
42
|
+
* @param modelStateId The ID of the Model-State.
|
|
43
|
+
*/
|
|
44
|
+
async get(modelStateId: string): Promise<ShapeDiverResponseDto> {
|
|
45
|
+
return await sendRequest(
|
|
46
|
+
async () =>
|
|
47
|
+
(
|
|
48
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
49
|
+
this.buildModelStateUri(modelStateId),
|
|
50
|
+
)
|
|
51
|
+
)[1],
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Delete a Model-State.
|
|
57
|
+
* @param modelStateId The ID of the Model-State.
|
|
58
|
+
*/
|
|
59
|
+
async delete(modelStateId: string): Promise<void> {
|
|
60
|
+
return await sendRequest(async () => {
|
|
61
|
+
await this.api.delete(this.buildModelStateUri(modelStateId));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get a Model-State's parameter and additional data.
|
|
67
|
+
* @param modelStateId The ID of the Model-State.
|
|
68
|
+
*/
|
|
69
|
+
async getData(modelStateId: string): Promise<ShapeDiverResponseDto> {
|
|
70
|
+
return await sendRequest(
|
|
71
|
+
async () =>
|
|
72
|
+
(
|
|
73
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
74
|
+
`${this.buildModelStateUri(modelStateId)}/data`,
|
|
75
|
+
)
|
|
76
|
+
)[1],
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Check if the Model-State has an image.
|
|
82
|
+
* @param modelStateId The ID of the Model-State.
|
|
83
|
+
* @returns A boolean indicating whether the Model-State has an image.
|
|
84
|
+
*/
|
|
85
|
+
async hasImage(modelStateId: string): Promise<boolean> {
|
|
86
|
+
return await sendRequest(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const [_, status] = await this.api.head(
|
|
89
|
+
`${this.buildModelStateUri(modelStateId)}/image`,
|
|
90
|
+
{ disableAuthorization: true },
|
|
91
|
+
);
|
|
92
|
+
return status === 200;
|
|
93
|
+
} catch (e) {
|
|
94
|
+
// A 404 HTTP status is returned when the Model-State image was not found.
|
|
95
|
+
if (e instanceof ShapeDiverResponseError && e.status === 404)
|
|
96
|
+
return false;
|
|
97
|
+
else throw e;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Downloads the Model-State image.
|
|
104
|
+
* @param modelStateId The ID of the Model-State.
|
|
105
|
+
* @returns Array of size 2: [0] = content data, [1] = content type.
|
|
106
|
+
*/
|
|
107
|
+
async getImage(modelStateId: string): Promise<[ArrayBuffer, string]> {
|
|
108
|
+
return await sendRequest(async () => {
|
|
109
|
+
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
110
|
+
`${this.buildModelStateUri(modelStateId)}/image`,
|
|
111
|
+
undefined,
|
|
112
|
+
{
|
|
113
|
+
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
114
|
+
disableAuthorization: true,
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
118
|
+
return [data, contentType];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* List Model-States of a ShapeDiver model.
|
|
124
|
+
* @param modelId The ID of the ShapeDiver model.
|
|
125
|
+
* @param offset The offset to start the list from.
|
|
126
|
+
*/
|
|
127
|
+
async list(modelId: string, offset?: string): Promise<ShapeDiverResponseDto> {
|
|
128
|
+
// Build queries
|
|
129
|
+
const queries: string[] = [];
|
|
130
|
+
if (offset !== undefined) queries.push("offset=" + offset);
|
|
131
|
+
|
|
132
|
+
return await sendRequest(
|
|
133
|
+
async () =>
|
|
134
|
+
(
|
|
135
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
136
|
+
`${this.buildModelStateUri()}/model/${modelId}/list`,
|
|
137
|
+
queries,
|
|
138
|
+
)
|
|
139
|
+
)[1],
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Create a new Model-State.
|
|
145
|
+
* @param modelId The ID of the ShapeDiver model.
|
|
146
|
+
* @param body The Model-State data.
|
|
147
|
+
*/
|
|
148
|
+
async create(
|
|
149
|
+
sessionId: string,
|
|
150
|
+
body: ShapeDiverRequestModelState,
|
|
151
|
+
): Promise<ShapeDiverResponseDto> {
|
|
152
|
+
return await sendRequest(
|
|
153
|
+
async () =>
|
|
154
|
+
(
|
|
155
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
156
|
+
`${this.buildSessionUri(sessionId)}/model-state`,
|
|
157
|
+
undefined,
|
|
158
|
+
body,
|
|
159
|
+
)
|
|
160
|
+
)[1],
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|