@shapediver/sdk.geometry-api-sdk-v2 1.8.3 → 1.9.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/ShapeDiverErrors.d.ts.map +1 -1
- package/dist/ShapeDiverErrors.js +1 -1
- package/dist/ShapeDiverErrors.js.map +1 -1
- package/dist/ShapeDiverSdk.d.ts.map +1 -1
- package/dist/ShapeDiverSdk.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js +3 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js.map +1 -1
- package/dist/resources/ShapeDiverArSceneApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverArSceneApi.js.map +1 -1
- package/dist/resources/ShapeDiverAssetApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverAssetApi.js.map +1 -1
- package/dist/resources/ShapeDiverExportApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverExportApi.js.map +1 -1
- package/dist/resources/ShapeDiverFileApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverFileApi.js +10 -7
- package/dist/resources/ShapeDiverFileApi.js.map +1 -1
- package/dist/resources/ShapeDiverGltfApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverGltfApi.js +4 -1
- package/dist/resources/ShapeDiverGltfApi.js.map +1 -1
- package/dist/resources/ShapeDiverModelApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverModelApi.js +52 -15
- package/dist/resources/ShapeDiverModelApi.js.map +1 -1
- package/dist/resources/ShapeDiverOutputApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverOutputApi.js +12 -4
- package/dist/resources/ShapeDiverOutputApi.js.map +1 -1
- package/dist/resources/ShapeDiverSdtfApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSdtfApi.js +9 -3
- package/dist/resources/ShapeDiverSdtfApi.js.map +1 -1
- package/dist/resources/ShapeDiverSessionApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSessionApi.js +3 -1
- package/dist/resources/ShapeDiverSessionApi.js.map +1 -1
- package/dist/resources/ShapeDiverSystemApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverSystemApi.js +18 -6
- package/dist/resources/ShapeDiverSystemApi.js.map +1 -1
- package/dist/resources/ShapeDiverTextureApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverTextureApi.js +3 -1
- package/dist/resources/ShapeDiverTextureApi.js.map +1 -1
- package/dist/resources/ShapeDiverUtilsApi.d.ts +3 -5
- package/dist/resources/ShapeDiverUtilsApi.d.ts.map +1 -1
- package/dist/resources/ShapeDiverUtilsApi.js +31 -15
- package/dist/resources/ShapeDiverUtilsApi.js.map +1 -1
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +9 -9
- package/dist/utils/utils.js.map +1 -1
- package/package.json +4 -2
- package/src/ShapeDiverErrors.ts +24 -23
- package/src/ShapeDiverSdk.ts +110 -109
- package/src/index.ts +15 -16
- package/src/resources/ShapeDiverAnalyticsApi.ts +30 -18
- package/src/resources/ShapeDiverArSceneApi.ts +68 -69
- package/src/resources/ShapeDiverAssetApi.ts +207 -183
- package/src/resources/ShapeDiverExportApi.ts +92 -77
- package/src/resources/ShapeDiverFileApi.ts +136 -108
- package/src/resources/ShapeDiverGltfApi.ts +41 -30
- package/src/resources/ShapeDiverModelApi.ts +351 -240
- package/src/resources/ShapeDiverOutputApi.ts +92 -56
- package/src/resources/ShapeDiverSdtfApi.ts +88 -54
- package/src/resources/ShapeDiverSessionApi.ts +104 -82
- package/src/resources/ShapeDiverSystemApi.ts +106 -70
- package/src/resources/ShapeDiverTextureApi.ts +24 -18
- package/src/resources/ShapeDiverUtilsApi.ts +290 -231
- package/src/utils/utils.ts +61 -53
|
@@ -1,123 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestFileUpload,
|
|
3
|
+
ShapeDiverResponseDto,
|
|
4
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
5
|
+
import {
|
|
6
|
+
BaseResourceApi,
|
|
7
|
+
ShapeDiverSdkApi,
|
|
8
|
+
ShapeDiverSdkApiResponseType,
|
|
9
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
10
|
+
import { sendRequest } from "../utils/utils";
|
|
11
|
+
|
|
12
|
+
const contentDisposition = require("content-disposition");
|
|
4
13
|
|
|
5
14
|
export interface ShapeDiverResponseFileInfo {
|
|
6
|
-
|
|
7
|
-
|
|
15
|
+
filename?: string;
|
|
16
|
+
size?: number;
|
|
8
17
|
}
|
|
9
18
|
|
|
10
19
|
export class ShapeDiverFileApi extends BaseResourceApi {
|
|
20
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
21
|
+
super(api);
|
|
22
|
+
}
|
|
11
23
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
/**
|
|
25
|
+
* List all file-assets of the given parameter.
|
|
26
|
+
*
|
|
27
|
+
* @param sessionId
|
|
28
|
+
* @param paramId
|
|
29
|
+
*/
|
|
30
|
+
async list(
|
|
31
|
+
sessionId: string,
|
|
32
|
+
paramId: string,
|
|
33
|
+
): Promise<ShapeDiverResponseDto> {
|
|
34
|
+
return await sendRequest(
|
|
35
|
+
async () =>
|
|
36
|
+
(
|
|
37
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
38
|
+
`${this.buildSessionUri(sessionId)}/file/${paramId}/list`,
|
|
39
|
+
)
|
|
40
|
+
)[1],
|
|
41
|
+
);
|
|
42
|
+
}
|
|
15
43
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Get information about a file-asset of a parameter.
|
|
46
|
+
*
|
|
47
|
+
* @param sessionId
|
|
48
|
+
* @param paramId
|
|
49
|
+
*/
|
|
50
|
+
async info(
|
|
51
|
+
sessionId: string,
|
|
52
|
+
paramId: string,
|
|
53
|
+
fileId: string,
|
|
54
|
+
): Promise<ShapeDiverResponseFileInfo> {
|
|
55
|
+
return await sendRequest(async () => {
|
|
56
|
+
const headers = (
|
|
57
|
+
await this.api.head(
|
|
58
|
+
`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
|
|
27
59
|
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get information about a file-asset of a parameter.
|
|
32
|
-
*
|
|
33
|
-
* @param sessionId
|
|
34
|
-
* @param paramId
|
|
35
|
-
*/
|
|
36
|
-
async info (
|
|
37
|
-
sessionId: string,
|
|
38
|
-
paramId: string,
|
|
39
|
-
fileId: string,
|
|
40
|
-
): Promise<ShapeDiverResponseFileInfo> {
|
|
41
|
-
return await sendRequest(async () => {
|
|
42
|
-
const headers = (await this.api.head(
|
|
43
|
-
`${ this.buildSessionUri(sessionId) }/file/${ paramId }/${ fileId }`,
|
|
44
|
-
))[0]
|
|
45
|
-
|
|
46
|
-
const res: ShapeDiverResponseFileInfo = {
|
|
47
|
-
size: Number(headers.get("Content-Length") || headers.get("content-length")),
|
|
48
|
-
}
|
|
60
|
+
)[0];
|
|
49
61
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
contentDisposition.indexOf("=") > 0
|
|
56
|
-
) {
|
|
57
|
-
res.filename = contentDisposition
|
|
58
|
-
.split("=")[1] // Extract filename
|
|
59
|
-
.slice(1, -1) // remove leading and trailing double quotes
|
|
60
|
-
}
|
|
62
|
+
const res: ShapeDiverResponseFileInfo = {
|
|
63
|
+
size: Number(
|
|
64
|
+
headers.get("Content-Length") || headers.get("content-length"),
|
|
65
|
+
),
|
|
66
|
+
};
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
68
|
+
// Extract filename from Content-Disposition header if available
|
|
69
|
+
const contentDispositionHeader =
|
|
70
|
+
headers.get("Content-Disposition") ||
|
|
71
|
+
headers.get("content-disposition");
|
|
72
|
+
if (typeof contentDispositionHeader === "string") {
|
|
73
|
+
try {
|
|
74
|
+
res.filename = contentDisposition.parse(
|
|
75
|
+
contentDispositionHeader,
|
|
76
|
+
).parameters.filename;
|
|
77
|
+
} catch (_) {
|
|
78
|
+
res.filename = undefined;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
65
81
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
* @param sessionId
|
|
70
|
-
* @param paramId
|
|
71
|
-
* @param fileId
|
|
72
|
-
*/
|
|
73
|
-
async get (
|
|
74
|
-
sessionId: string,
|
|
75
|
-
paramId: string,
|
|
76
|
-
fileId: string,
|
|
77
|
-
): Promise<ArrayBuffer> {
|
|
78
|
-
return await sendRequest(async () =>
|
|
79
|
-
(await this.api.get<ArrayBuffer>(
|
|
80
|
-
`${ this.buildSessionUri(sessionId) }/file/${ paramId }/${ fileId }`,
|
|
81
|
-
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
82
|
-
))[1],
|
|
83
|
-
)
|
|
84
|
-
}
|
|
82
|
+
return res;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
85
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
86
|
+
/**
|
|
87
|
+
* Download a file-asset.
|
|
88
|
+
*
|
|
89
|
+
* @param sessionId
|
|
90
|
+
* @param paramId
|
|
91
|
+
* @param fileId
|
|
92
|
+
*/
|
|
93
|
+
async get(
|
|
94
|
+
sessionId: string,
|
|
95
|
+
paramId: string,
|
|
96
|
+
fileId: string,
|
|
97
|
+
): Promise<ArrayBuffer> {
|
|
98
|
+
return await sendRequest(
|
|
99
|
+
async () =>
|
|
100
|
+
(
|
|
101
|
+
await this.api.get<ArrayBuffer>(
|
|
102
|
+
`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
|
|
103
|
+
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
104
|
+
)
|
|
105
|
+
)[1],
|
|
106
|
+
);
|
|
107
|
+
}
|
|
104
108
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
109
|
+
/**
|
|
110
|
+
* Delete a file-asset.
|
|
111
|
+
*
|
|
112
|
+
* @param sessionId
|
|
113
|
+
* @param paramId
|
|
114
|
+
* @param fileId
|
|
115
|
+
*/
|
|
116
|
+
async delete(
|
|
117
|
+
sessionId: string,
|
|
118
|
+
paramId: string,
|
|
119
|
+
fileId: string,
|
|
120
|
+
): Promise<ShapeDiverResponseDto> {
|
|
121
|
+
return await sendRequest(
|
|
122
|
+
async () =>
|
|
123
|
+
(
|
|
124
|
+
await this.api.delete<ShapeDiverResponseDto>(
|
|
125
|
+
`${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
|
|
126
|
+
)
|
|
127
|
+
)[1],
|
|
128
|
+
);
|
|
129
|
+
}
|
|
122
130
|
|
|
131
|
+
/**
|
|
132
|
+
* Request an Upload-URL for a file.
|
|
133
|
+
*
|
|
134
|
+
* @param sessionId
|
|
135
|
+
* @param body
|
|
136
|
+
*/
|
|
137
|
+
async requestUpload(
|
|
138
|
+
sessionId: string,
|
|
139
|
+
body: ShapeDiverRequestFileUpload,
|
|
140
|
+
): Promise<ShapeDiverResponseDto> {
|
|
141
|
+
return await sendRequest(
|
|
142
|
+
async () =>
|
|
143
|
+
(
|
|
144
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
145
|
+
this.buildSessionUri(sessionId) + "/file/upload",
|
|
146
|
+
body,
|
|
147
|
+
)
|
|
148
|
+
)[1],
|
|
149
|
+
);
|
|
150
|
+
}
|
|
123
151
|
}
|
|
@@ -1,34 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestGltfUploadQueryConversion,
|
|
3
|
+
ShapeDiverResponseDto,
|
|
4
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
5
|
+
import {
|
|
6
|
+
BaseResourceApi,
|
|
7
|
+
ShapeDiverSdkApi,
|
|
8
|
+
ShapeDiverSdkApiResponseType,
|
|
9
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
10
|
+
import { sendRequest } from "../utils/utils";
|
|
4
11
|
|
|
5
12
|
export class ShapeDiverGltfApi extends BaseResourceApi {
|
|
13
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
14
|
+
super(api);
|
|
15
|
+
}
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Upload a glTF file.
|
|
19
|
+
*
|
|
20
|
+
* @param sessionId
|
|
21
|
+
* @param body
|
|
22
|
+
* @param type
|
|
23
|
+
* @param queryConvert
|
|
24
|
+
*/
|
|
25
|
+
async upload(
|
|
26
|
+
sessionId: string,
|
|
27
|
+
body: ArrayBuffer,
|
|
28
|
+
type: string,
|
|
29
|
+
queryConvert: ShapeDiverRequestGltfUploadQueryConversion = ShapeDiverRequestGltfUploadQueryConversion.NONE,
|
|
30
|
+
): Promise<ShapeDiverResponseDto> {
|
|
31
|
+
return await sendRequest(
|
|
32
|
+
async () =>
|
|
33
|
+
(
|
|
34
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
35
|
+
`${this.buildSessionUri(sessionId)}/gltf?conversion=${queryConvert}`,
|
|
36
|
+
body,
|
|
37
|
+
{
|
|
38
|
+
contentType: type,
|
|
39
|
+
responseType: ShapeDiverSdkApiResponseType.JSON,
|
|
40
|
+
},
|
|
41
|
+
)
|
|
42
|
+
)[1],
|
|
43
|
+
);
|
|
44
|
+
}
|
|
34
45
|
}
|