@shapediver/sdk.geometry-api-sdk-v2 1.10.0 → 1.12.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.map +1 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js +6 -20
- 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 +16 -11
- 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 +6 -18
- package/src/resources/ShapeDiverArSceneApi.ts +11 -9
- package/src/resources/ShapeDiverAssetApi.ts +27 -8
- 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.12.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
|
}
|
|
@@ -27,6 +27,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
27
27
|
(
|
|
28
28
|
await this.api.put<ShapeDiverResponseDto>(
|
|
29
29
|
this.buildAnalyticsUri() + "/session/model",
|
|
30
|
+
undefined,
|
|
30
31
|
body,
|
|
31
32
|
)
|
|
32
33
|
)[1],
|
|
@@ -42,6 +43,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
42
43
|
(
|
|
43
44
|
await this.api.put<ShapeDiverResponseDto>(
|
|
44
45
|
this.buildAnalyticsUri() + "/credit-metrics",
|
|
46
|
+
undefined,
|
|
45
47
|
body,
|
|
46
48
|
)
|
|
47
49
|
)[1],
|
|
@@ -54,10 +56,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
54
56
|
async () =>
|
|
55
57
|
(
|
|
56
58
|
await this.api.get<ShapeDiverResponseDto>(
|
|
57
|
-
this.buildAnalyticsUri()
|
|
58
|
-
"/credit-metrics/timestamp/" +
|
|
59
|
-
timestamp +
|
|
60
|
-
"/user",
|
|
59
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/user`,
|
|
61
60
|
)
|
|
62
61
|
)[1],
|
|
63
62
|
);
|
|
@@ -71,10 +70,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
71
70
|
async () =>
|
|
72
71
|
(
|
|
73
72
|
await this.api.get<ShapeDiverResponseDto>(
|
|
74
|
-
this.buildAnalyticsUri()
|
|
75
|
-
"/credit-metrics/timestamp/" +
|
|
76
|
-
timestamp +
|
|
77
|
-
"/org",
|
|
73
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/org`,
|
|
78
74
|
)
|
|
79
75
|
)[1],
|
|
80
76
|
);
|
|
@@ -89,11 +85,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
89
85
|
async () =>
|
|
90
86
|
(
|
|
91
87
|
await this.api.get<ShapeDiverResponseDto>(
|
|
92
|
-
this.buildAnalyticsUri()
|
|
93
|
-
"/credit-metrics/timestamp/" +
|
|
94
|
-
timestamp +
|
|
95
|
-
"/user/" +
|
|
96
|
-
userId,
|
|
88
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/user/${userId}`,
|
|
97
89
|
)
|
|
98
90
|
)[1],
|
|
99
91
|
);
|
|
@@ -108,11 +100,7 @@ export class ShapeDiverAnalyticsApi extends BaseResourceApi {
|
|
|
108
100
|
async () =>
|
|
109
101
|
(
|
|
110
102
|
await this.api.get<ShapeDiverResponseDto>(
|
|
111
|
-
this.buildAnalyticsUri()
|
|
112
|
-
"/credit-metrics/timestamp/" +
|
|
113
|
-
timestamp +
|
|
114
|
-
"/org/" +
|
|
115
|
-
orgId,
|
|
103
|
+
`${this.buildAnalyticsUri()}/credit-metrics/timestamp/${timestamp}/org/${orgId}`,
|
|
116
104
|
)
|
|
117
105
|
)[1],
|
|
118
106
|
);
|
|
@@ -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,
|
|
@@ -15,6 +15,9 @@ const cdnAssetExportUri = /.+\/cdn-asset-exports\/.+/;
|
|
|
15
15
|
const cdnAssetOutputUri = /.+\/cdn-asset-outputs\/.+/;
|
|
16
16
|
const cdnAssetTextureUri = /.+\/cdn-asset-textures\/.+/;
|
|
17
17
|
|
|
18
|
+
const directDownloadUri =
|
|
19
|
+
/^(http[s]?:\/\/)?(viewer|textures|downloads)\.shapediver\.com(\/.*)?$/;
|
|
20
|
+
|
|
18
21
|
export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
19
22
|
constructor(api: ShapeDiverSdkApi) {
|
|
20
23
|
super(api);
|
|
@@ -33,6 +36,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
33
36
|
return await sendRequest(async () => {
|
|
34
37
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
35
38
|
`${this.buildSessionUri(sessionId)}/export/${assetData}`,
|
|
39
|
+
undefined,
|
|
36
40
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
37
41
|
);
|
|
38
42
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -53,6 +57,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
53
57
|
return await sendRequest(async () => {
|
|
54
58
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
55
59
|
`${this.buildSessionUri(sessionId)}/output/${assetData}`,
|
|
60
|
+
undefined,
|
|
56
61
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
57
62
|
);
|
|
58
63
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -75,6 +80,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
75
80
|
(
|
|
76
81
|
await this.api.get<ArrayBuffer>(
|
|
77
82
|
`${this.buildSessionUri(sessionId)}/output/${assetData}`,
|
|
83
|
+
undefined,
|
|
78
84
|
{
|
|
79
85
|
responseType: ShapeDiverSdkApiResponseType.JSON,
|
|
80
86
|
accept: "model/vnd.sdtf+json",
|
|
@@ -97,6 +103,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
97
103
|
return await sendRequest(async () => {
|
|
98
104
|
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
99
105
|
`${this.buildSessionUri(sessionId)}/texture/${assetData}`,
|
|
106
|
+
undefined,
|
|
100
107
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
101
108
|
);
|
|
102
109
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
@@ -116,6 +123,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
116
123
|
(
|
|
117
124
|
await this.api.get<ArrayBuffer>(
|
|
118
125
|
`${this.buildSessionUri(sessionId)}/gltf/${assetData}`,
|
|
126
|
+
undefined,
|
|
119
127
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
120
128
|
)
|
|
121
129
|
)[1],
|
|
@@ -134,6 +142,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
134
142
|
(
|
|
135
143
|
await this.api.get<ArrayBuffer>(
|
|
136
144
|
`${this.buildSessionUri(sessionId)}/usdz/${assetData}`,
|
|
145
|
+
undefined,
|
|
137
146
|
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
138
147
|
)
|
|
139
148
|
)[1],
|
|
@@ -151,21 +160,31 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
151
160
|
sessionId: string,
|
|
152
161
|
url: string,
|
|
153
162
|
): Promise<[ArrayBuffer, string]> {
|
|
154
|
-
let targetUrl: string;
|
|
163
|
+
let targetUrl: string, queries: string[];
|
|
155
164
|
|
|
156
|
-
if (
|
|
165
|
+
if (
|
|
166
|
+
apiAssetTextureUri.test(url) ||
|
|
167
|
+
cdnAssetTextureUri.test(url) ||
|
|
168
|
+
directDownloadUri.test(url)
|
|
169
|
+
) {
|
|
157
170
|
// Call ShapeDiver texture-asset URLs directly
|
|
158
171
|
targetUrl = url;
|
|
172
|
+
queries = [];
|
|
159
173
|
} else {
|
|
160
174
|
// All other source URLs are called via the download-image endpoint
|
|
161
|
-
targetUrl = `${this.buildSessionUri(sessionId)}/image
|
|
175
|
+
targetUrl = `${this.buildSessionUri(sessionId)}/image`;
|
|
176
|
+
queries = [`url=${encodeBase64(url)}`];
|
|
162
177
|
}
|
|
163
178
|
|
|
164
179
|
return await sendRequest(async () => {
|
|
165
|
-
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
180
|
+
const [header, data] = await this.api.get<ArrayBuffer>(
|
|
181
|
+
targetUrl,
|
|
182
|
+
queries,
|
|
183
|
+
{
|
|
184
|
+
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
185
|
+
disableAuthorization: cdnAssetUri.test(url), // disable for CDN URLs
|
|
186
|
+
},
|
|
187
|
+
);
|
|
169
188
|
const contentType = header["Content-Type"] ?? header["content-type"];
|
|
170
189
|
return [data, contentType];
|
|
171
190
|
});
|
|
@@ -202,7 +221,7 @@ export class ShapeDiverAssetApi extends BaseResourceApi {
|
|
|
202
221
|
);
|
|
203
222
|
|
|
204
223
|
return await sendRequest(async () => {
|
|
205
|
-
const [header, data] = await this.api.get<ArrayBuffer>(url, {
|
|
224
|
+
const [header, data] = await this.api.get<ArrayBuffer>(url, undefined, {
|
|
206
225
|
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
207
226
|
disableAuthorization: cdnAssetUri.test(url), // disable for CDN URLs
|
|
208
227
|
});
|
|
@@ -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
|
+
}
|