@shapediver/sdk.geometry-api-sdk-v2 1.8.2 → 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 +2 -2
- 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 +6 -3
- 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 +39 -23
- 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 +17 -18
- package/dist/utils/utils.js.map +1 -1
- package/package.json +11 -8
- package/src/ShapeDiverErrors.ts +34 -0
- package/src/ShapeDiverSdk.ts +114 -0
- package/src/index.ts +17 -0
- package/src/resources/ShapeDiverAnalyticsApi.ts +34 -0
- package/src/resources/ShapeDiverArSceneApi.ts +75 -0
- package/src/resources/ShapeDiverAssetApi.ts +213 -0
- package/src/resources/ShapeDiverExportApi.ts +100 -0
- package/src/resources/ShapeDiverFileApi.ts +151 -0
- package/src/resources/ShapeDiverGltfApi.ts +45 -0
- package/src/resources/ShapeDiverModelApi.ts +357 -0
- package/src/resources/ShapeDiverOutputApi.ts +100 -0
- package/src/resources/ShapeDiverSdtfApi.ts +95 -0
- package/src/resources/ShapeDiverSessionApi.ts +113 -0
- package/src/resources/ShapeDiverSystemApi.ts +116 -0
- package/src/resources/ShapeDiverTextureApi.ts +28 -0
- package/src/resources/ShapeDiverUtilsApi.ts +314 -0
- package/src/utils/utils.ts +97 -0
|
@@ -0,0 +1,45 @@
|
|
|
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";
|
|
11
|
+
|
|
12
|
+
export class ShapeDiverGltfApi extends BaseResourceApi {
|
|
13
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
14
|
+
super(api);
|
|
15
|
+
}
|
|
16
|
+
|
|
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
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestConfigure,
|
|
3
|
+
ShapeDiverRequestCustomization,
|
|
4
|
+
ShapeDiverRequestModel,
|
|
5
|
+
ShapeDiverRequestModelComputationQueryOrder,
|
|
6
|
+
ShapeDiverRequestModelComputationQueryStatus,
|
|
7
|
+
ShapeDiverRequestModelComputationQueryType,
|
|
8
|
+
ShapeDiverRequestParameterDefinition,
|
|
9
|
+
ShapeDiverResponseDto,
|
|
10
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
11
|
+
import {
|
|
12
|
+
BaseResourceApi,
|
|
13
|
+
ShapeDiverSdkApi,
|
|
14
|
+
ShapeDiverSdkApiResponseType,
|
|
15
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
16
|
+
import { sendRequest } from "../utils/utils";
|
|
17
|
+
|
|
18
|
+
export class ShapeDiverModelApi extends BaseResourceApi {
|
|
19
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
20
|
+
super(api);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Get information about a ShapeDiver Model.
|
|
25
|
+
*
|
|
26
|
+
* @param modelId
|
|
27
|
+
*/
|
|
28
|
+
async get(modelId: string): Promise<ShapeDiverResponseDto> {
|
|
29
|
+
return await sendRequest(
|
|
30
|
+
async () =>
|
|
31
|
+
(
|
|
32
|
+
await this.api.get<ShapeDiverResponseDto>(this.buildModelUri(modelId))
|
|
33
|
+
)[1],
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a new ShapeDiver Model.
|
|
39
|
+
*
|
|
40
|
+
* @param body
|
|
41
|
+
*/
|
|
42
|
+
async create(body: ShapeDiverRequestModel): Promise<ShapeDiverResponseDto> {
|
|
43
|
+
return await sendRequest(
|
|
44
|
+
async () =>
|
|
45
|
+
(await this.api.post<ShapeDiverResponseDto>(this.commonPath, body))[1],
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Update properties of a ShapeDiver Model.
|
|
51
|
+
*
|
|
52
|
+
* @param modelId
|
|
53
|
+
* @param body
|
|
54
|
+
*/
|
|
55
|
+
async update(
|
|
56
|
+
modelId: string,
|
|
57
|
+
body: ShapeDiverRequestModel,
|
|
58
|
+
): Promise<ShapeDiverResponseDto> {
|
|
59
|
+
return await sendRequest(
|
|
60
|
+
async () =>
|
|
61
|
+
(
|
|
62
|
+
await this.api.put<ShapeDiverResponseDto>(
|
|
63
|
+
this.buildModelUri(modelId),
|
|
64
|
+
body,
|
|
65
|
+
)
|
|
66
|
+
)[1],
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Delete a ShapeDiver Model.
|
|
72
|
+
*
|
|
73
|
+
* @param modelId
|
|
74
|
+
*/
|
|
75
|
+
async delete(modelId: string): Promise<ShapeDiverResponseDto> {
|
|
76
|
+
return await sendRequest(
|
|
77
|
+
async () =>
|
|
78
|
+
(
|
|
79
|
+
await this.api.delete<ShapeDiverResponseDto>(
|
|
80
|
+
this.buildModelUri(modelId),
|
|
81
|
+
)
|
|
82
|
+
)[1],
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* List models.
|
|
88
|
+
*/
|
|
89
|
+
async list(): Promise<ShapeDiverResponseDto> {
|
|
90
|
+
return await sendRequest(
|
|
91
|
+
async () =>
|
|
92
|
+
(
|
|
93
|
+
await this.api.get<ShapeDiverResponseDto>(`${this.commonPath}/list`)
|
|
94
|
+
)[1],
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Get configurations of the viewer.
|
|
100
|
+
*
|
|
101
|
+
* @param modelId
|
|
102
|
+
*/
|
|
103
|
+
async getConfig(modelId: string): Promise<ShapeDiverResponseDto> {
|
|
104
|
+
return await sendRequest(
|
|
105
|
+
async () =>
|
|
106
|
+
(
|
|
107
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
108
|
+
this.buildModelUri(modelId) + "/config",
|
|
109
|
+
)
|
|
110
|
+
)[1],
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create viewer configurations.
|
|
116
|
+
*
|
|
117
|
+
* @param modelId
|
|
118
|
+
* @param body
|
|
119
|
+
*/
|
|
120
|
+
async createConfig(
|
|
121
|
+
modelId: string,
|
|
122
|
+
body: ShapeDiverRequestConfigure,
|
|
123
|
+
): Promise<ShapeDiverResponseDto> {
|
|
124
|
+
return await sendRequest(
|
|
125
|
+
async () =>
|
|
126
|
+
(
|
|
127
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
128
|
+
this.buildModelUri(modelId) + "/config",
|
|
129
|
+
body,
|
|
130
|
+
)
|
|
131
|
+
)[1],
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Update viewer configurations.
|
|
137
|
+
*
|
|
138
|
+
* @param modelId
|
|
139
|
+
* @param body
|
|
140
|
+
*/
|
|
141
|
+
async updateConfig(
|
|
142
|
+
modelId: string,
|
|
143
|
+
body: ShapeDiverRequestConfigure,
|
|
144
|
+
): Promise<ShapeDiverResponseDto> {
|
|
145
|
+
return await sendRequest(
|
|
146
|
+
async () =>
|
|
147
|
+
(
|
|
148
|
+
await this.api.patch<ShapeDiverResponseDto>(
|
|
149
|
+
this.buildModelUri(modelId) + "/config",
|
|
150
|
+
body,
|
|
151
|
+
)
|
|
152
|
+
)[1],
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Download the Grasshopper file of the ShapeDiver Model.
|
|
158
|
+
*
|
|
159
|
+
* @param modelId
|
|
160
|
+
*/
|
|
161
|
+
async getFile(modelId: string): Promise<ArrayBuffer> {
|
|
162
|
+
return await sendRequest(
|
|
163
|
+
async () =>
|
|
164
|
+
(
|
|
165
|
+
await this.api.get<ArrayBuffer>(
|
|
166
|
+
this.buildModelUri(modelId) + "/file/download",
|
|
167
|
+
{
|
|
168
|
+
contentType: "application/json",
|
|
169
|
+
responseType: ShapeDiverSdkApiResponseType.DATA,
|
|
170
|
+
},
|
|
171
|
+
)
|
|
172
|
+
)[1],
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Set the default parameters for the ShapeDiver Model.
|
|
178
|
+
*
|
|
179
|
+
* @param modelId
|
|
180
|
+
* @param body
|
|
181
|
+
*/
|
|
182
|
+
async setDefaultParams(
|
|
183
|
+
modelId: string,
|
|
184
|
+
body: ShapeDiverRequestCustomization,
|
|
185
|
+
): Promise<ShapeDiverResponseDto> {
|
|
186
|
+
return await sendRequest(
|
|
187
|
+
async () =>
|
|
188
|
+
(
|
|
189
|
+
await this.api.patch<ShapeDiverResponseDto>(
|
|
190
|
+
this.buildModelUri(modelId) + "/parameter/defval",
|
|
191
|
+
body,
|
|
192
|
+
)
|
|
193
|
+
)[1],
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Updates the definitions of the given parameters.
|
|
199
|
+
*
|
|
200
|
+
* @param modelId
|
|
201
|
+
* @param body
|
|
202
|
+
*/
|
|
203
|
+
async updateParameterDefinitions(
|
|
204
|
+
modelId: string,
|
|
205
|
+
body: ShapeDiverRequestParameterDefinition,
|
|
206
|
+
): Promise<ShapeDiverResponseDto> {
|
|
207
|
+
return await sendRequest(
|
|
208
|
+
async () =>
|
|
209
|
+
(
|
|
210
|
+
await this.api.patch<ShapeDiverResponseDto>(
|
|
211
|
+
this.buildModelUri(modelId) + "/parameter",
|
|
212
|
+
body,
|
|
213
|
+
)
|
|
214
|
+
)[1],
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Query model computation statistics.
|
|
220
|
+
*
|
|
221
|
+
* @param modelId
|
|
222
|
+
* @param timestampFrom - Timestamp to query from
|
|
223
|
+
* @param timestampTo - Timestamp to query to.
|
|
224
|
+
* @param limit - How many items to return at most.
|
|
225
|
+
* @param strictLimit - Whether the limit shall be attained (if there are enough items).
|
|
226
|
+
* @param order - Order in which to query computation stats items.
|
|
227
|
+
* @param status - Filter computations by the result status.
|
|
228
|
+
* @param type - Filter computations by type.
|
|
229
|
+
* @param offset - Continuation token for pagination.
|
|
230
|
+
*/
|
|
231
|
+
async queryComputations(
|
|
232
|
+
modelId: string,
|
|
233
|
+
timestampFrom?: string,
|
|
234
|
+
timestampTo?: string,
|
|
235
|
+
limit?: number,
|
|
236
|
+
strictLimit?: boolean,
|
|
237
|
+
order?: ShapeDiverRequestModelComputationQueryOrder,
|
|
238
|
+
status?: ShapeDiverRequestModelComputationQueryStatus,
|
|
239
|
+
type?: ShapeDiverRequestModelComputationQueryType,
|
|
240
|
+
offset?: string,
|
|
241
|
+
): Promise<ShapeDiverResponseDto> {
|
|
242
|
+
// Build queries
|
|
243
|
+
const queries: string[] = [];
|
|
244
|
+
if (timestampFrom !== undefined)
|
|
245
|
+
queries.push("timestamp_from=" + timestampFrom);
|
|
246
|
+
if (timestampTo !== undefined) queries.push("timestamp_to=" + timestampTo);
|
|
247
|
+
if (limit !== undefined) queries.push("limit=" + limit);
|
|
248
|
+
if (strictLimit !== undefined) queries.push("strict_limit=" + strictLimit);
|
|
249
|
+
if (order !== undefined) queries.push("order=" + order);
|
|
250
|
+
if (status !== undefined) queries.push("status=" + status);
|
|
251
|
+
if (type !== undefined) queries.push("type=" + type);
|
|
252
|
+
if (offset !== undefined) queries.push("offset=" + offset);
|
|
253
|
+
|
|
254
|
+
return await sendRequest(
|
|
255
|
+
async () =>
|
|
256
|
+
(
|
|
257
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
258
|
+
this.buildModelUri(modelId) + "/computations?" + queries.join("&"),
|
|
259
|
+
)
|
|
260
|
+
)[1],
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Delete all export components that have been last used at or before {@link untilLastSeen} timestamp.
|
|
266
|
+
*
|
|
267
|
+
* @param modelId
|
|
268
|
+
* @param untilLastSeen - Timestamp, inclusive limit.
|
|
269
|
+
* Allowed Patterns: YYYY, YYYYMM, YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, YYYYMMDDhhmmss, YYYYMMDDhhmmssSSS
|
|
270
|
+
* @example
|
|
271
|
+
* untilLastSeen = "20221104112923123"
|
|
272
|
+
* represents the date-time "2022-11-04T11:29:23.123"
|
|
273
|
+
*/
|
|
274
|
+
async enqueueCleanupExports(
|
|
275
|
+
modelId: string,
|
|
276
|
+
untilLastSeen: string,
|
|
277
|
+
): Promise<ShapeDiverResponseDto> {
|
|
278
|
+
return await sendRequest(
|
|
279
|
+
async () =>
|
|
280
|
+
(
|
|
281
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
282
|
+
this.buildModelUri(modelId) +
|
|
283
|
+
"/cleanup/export?untilLastSeen=" +
|
|
284
|
+
untilLastSeen,
|
|
285
|
+
)
|
|
286
|
+
)[1],
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Delete all output components that have been last used at or before {@link untilLastSeen} timestamp.
|
|
292
|
+
*
|
|
293
|
+
* @param modelId
|
|
294
|
+
* @param untilLastSeen - Timestamp, inclusive limit.
|
|
295
|
+
* Allowed Patterns: YYYY, YYYYMM, YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, YYYYMMDDhhmmss, YYYYMMDDhhmmssSSS
|
|
296
|
+
* @example
|
|
297
|
+
* untilLastSeen = "20221104112923123"
|
|
298
|
+
* represents the date-time "2022-11-04T11:29:23.123"
|
|
299
|
+
*/
|
|
300
|
+
async enqueueCleanupOutputs(
|
|
301
|
+
modelId: string,
|
|
302
|
+
untilLastSeen: string,
|
|
303
|
+
): Promise<ShapeDiverResponseDto> {
|
|
304
|
+
return await sendRequest(
|
|
305
|
+
async () =>
|
|
306
|
+
(
|
|
307
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
308
|
+
this.buildModelUri(modelId) +
|
|
309
|
+
"/cleanup/output?untilLastSeen=" +
|
|
310
|
+
untilLastSeen,
|
|
311
|
+
)
|
|
312
|
+
)[1],
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/**
|
|
317
|
+
* Delete all texture components that have been last used at or before {@link untilLastSeen} timestamp.
|
|
318
|
+
*
|
|
319
|
+
* @param modelId
|
|
320
|
+
* @param untilLastSeen - Timestamp, inclusive limit.
|
|
321
|
+
* Allowed Patterns: YYYY, YYYYMM, YYYYMMDD, YYYYMMDDhh, YYYYMMDDhhmm, YYYYMMDDhhmmss, YYYYMMDDhhmmssSSS
|
|
322
|
+
* @example
|
|
323
|
+
* untilLastSeen = "20221104112923123"
|
|
324
|
+
* represents the date-time "2022-11-04T11:29:23.123"
|
|
325
|
+
*/
|
|
326
|
+
async enqueueCleanupTextures(
|
|
327
|
+
modelId: string,
|
|
328
|
+
untilLastSeen: string,
|
|
329
|
+
): Promise<ShapeDiverResponseDto> {
|
|
330
|
+
return await sendRequest(
|
|
331
|
+
async () =>
|
|
332
|
+
(
|
|
333
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
334
|
+
this.buildModelUri(modelId) +
|
|
335
|
+
"/cleanup/texture?untilLastSeen=" +
|
|
336
|
+
untilLastSeen,
|
|
337
|
+
)
|
|
338
|
+
)[1],
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Get the status of all running model cleanup processes.
|
|
344
|
+
*
|
|
345
|
+
* @param modelId
|
|
346
|
+
*/
|
|
347
|
+
async getCleanupStatus(modelId: string): Promise<ShapeDiverResponseDto> {
|
|
348
|
+
return await sendRequest(
|
|
349
|
+
async () =>
|
|
350
|
+
(
|
|
351
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
352
|
+
this.buildModelUri(modelId) + "/cleanup/status",
|
|
353
|
+
)
|
|
354
|
+
)[1],
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestCache,
|
|
3
|
+
ShapeDiverRequestCustomization,
|
|
4
|
+
ShapeDiverRequestOutputDefinition,
|
|
5
|
+
ShapeDiverResponseDto,
|
|
6
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
7
|
+
import {
|
|
8
|
+
BaseResourceApi,
|
|
9
|
+
ShapeDiverSdkApi,
|
|
10
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
11
|
+
import { sendRequest } from "../utils/utils";
|
|
12
|
+
|
|
13
|
+
export class ShapeDiverOutputApi extends BaseResourceApi {
|
|
14
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
15
|
+
super(api);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Request a specific version of an output.
|
|
20
|
+
*
|
|
21
|
+
* @param sessionId
|
|
22
|
+
* @param body
|
|
23
|
+
*/
|
|
24
|
+
async customize(
|
|
25
|
+
sessionId: string,
|
|
26
|
+
body: ShapeDiverRequestCustomization,
|
|
27
|
+
): Promise<ShapeDiverResponseDto> {
|
|
28
|
+
return await sendRequest(
|
|
29
|
+
async () =>
|
|
30
|
+
(
|
|
31
|
+
await this.api.put<ShapeDiverResponseDto>(
|
|
32
|
+
this.buildSessionUri(sessionId) + "/output",
|
|
33
|
+
body,
|
|
34
|
+
)
|
|
35
|
+
)[1],
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Check if a specific version of a requested output has been computed yet.
|
|
41
|
+
*
|
|
42
|
+
* @param sessionId
|
|
43
|
+
* @param body
|
|
44
|
+
*/
|
|
45
|
+
async getCache(
|
|
46
|
+
sessionId: string,
|
|
47
|
+
body: ShapeDiverRequestCache,
|
|
48
|
+
): Promise<ShapeDiverResponseDto> {
|
|
49
|
+
return await sendRequest(
|
|
50
|
+
async () =>
|
|
51
|
+
(
|
|
52
|
+
await this.api.put<ShapeDiverResponseDto>(
|
|
53
|
+
this.buildSessionUri(sessionId) + "/output/cache",
|
|
54
|
+
body,
|
|
55
|
+
)
|
|
56
|
+
)[1],
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Updates the definitions of the given outputs.
|
|
62
|
+
*
|
|
63
|
+
* @param modelId
|
|
64
|
+
* @param body
|
|
65
|
+
*/
|
|
66
|
+
async updateDefinitions(
|
|
67
|
+
modelId: string,
|
|
68
|
+
body: ShapeDiverRequestOutputDefinition,
|
|
69
|
+
): Promise<ShapeDiverResponseDto> {
|
|
70
|
+
return await sendRequest(
|
|
71
|
+
async () =>
|
|
72
|
+
(
|
|
73
|
+
await this.api.patch<ShapeDiverResponseDto>(
|
|
74
|
+
this.buildModelUri(modelId) + "/output",
|
|
75
|
+
body,
|
|
76
|
+
)
|
|
77
|
+
)[1],
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* List all cached versions of the specified output.
|
|
83
|
+
*
|
|
84
|
+
* @param sessionId
|
|
85
|
+
* @param outputId
|
|
86
|
+
*/
|
|
87
|
+
async listVersions(
|
|
88
|
+
sessionId: string,
|
|
89
|
+
outputId: string,
|
|
90
|
+
): Promise<ShapeDiverResponseDto> {
|
|
91
|
+
return await sendRequest(
|
|
92
|
+
async () =>
|
|
93
|
+
(
|
|
94
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
95
|
+
this.buildSessionUri(sessionId) + "/output/" + outputId + "/list",
|
|
96
|
+
)
|
|
97
|
+
)[1],
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestSdtfUpload,
|
|
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
|
+
export class ShapeDiverSdtfApi extends BaseResourceApi {
|
|
13
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
14
|
+
super(api);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* List all sdTF-assets of the given namespace.
|
|
19
|
+
*
|
|
20
|
+
* @param sessionId
|
|
21
|
+
* @param namespace
|
|
22
|
+
*/
|
|
23
|
+
async list(
|
|
24
|
+
sessionId: string,
|
|
25
|
+
namespace: string,
|
|
26
|
+
): Promise<ShapeDiverResponseDto> {
|
|
27
|
+
return await sendRequest(
|
|
28
|
+
async () =>
|
|
29
|
+
(
|
|
30
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
31
|
+
`${this.buildSessionUri(sessionId)}/sdtf/${namespace}/list`,
|
|
32
|
+
)
|
|
33
|
+
)[1],
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Download a sdTF-asset.
|
|
39
|
+
*
|
|
40
|
+
* @param sessionId
|
|
41
|
+
* @param sdtfId - Format: "<namespace>/<sdTF id>"
|
|
42
|
+
*/
|
|
43
|
+
async get(sessionId: string, sdtfId: string): Promise<ArrayBuffer> {
|
|
44
|
+
return await sendRequest(
|
|
45
|
+
async () =>
|
|
46
|
+
(
|
|
47
|
+
await this.api.get<ArrayBuffer>(
|
|
48
|
+
`${this.buildSessionUri(sessionId)}/sdtf/${sdtfId}`,
|
|
49
|
+
{ responseType: ShapeDiverSdkApiResponseType.DATA },
|
|
50
|
+
)
|
|
51
|
+
)[1],
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Delete a sdTF-asset.
|
|
57
|
+
*
|
|
58
|
+
* @param sessionId
|
|
59
|
+
* @param sdtfId
|
|
60
|
+
*/
|
|
61
|
+
async delete(
|
|
62
|
+
sessionId: string,
|
|
63
|
+
sdtfId: string,
|
|
64
|
+
): Promise<ShapeDiverResponseDto> {
|
|
65
|
+
return await sendRequest(
|
|
66
|
+
async () =>
|
|
67
|
+
(
|
|
68
|
+
await this.api.delete<ShapeDiverResponseDto>(
|
|
69
|
+
`${this.buildSessionUri(sessionId)}/sdtf/${sdtfId}`,
|
|
70
|
+
)
|
|
71
|
+
)[1],
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Request an Upload-URL for a sdTF-asset.
|
|
77
|
+
*
|
|
78
|
+
* @param sessionId
|
|
79
|
+
* @param body
|
|
80
|
+
*/
|
|
81
|
+
async requestUpload(
|
|
82
|
+
sessionId: string,
|
|
83
|
+
body: ShapeDiverRequestSdtfUpload,
|
|
84
|
+
): Promise<ShapeDiverResponseDto> {
|
|
85
|
+
return await sendRequest(
|
|
86
|
+
async () =>
|
|
87
|
+
(
|
|
88
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
89
|
+
this.buildSessionUri(sessionId) + "/sdtf/upload",
|
|
90
|
+
body,
|
|
91
|
+
)
|
|
92
|
+
)[1],
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ShapeDiverRequestCustomization,
|
|
3
|
+
ShapeDiverRequestExport,
|
|
4
|
+
ShapeDiverRequestTicket,
|
|
5
|
+
ShapeDiverResponseDto,
|
|
6
|
+
} from "@shapediver/api.geometry-api-dto-v2";
|
|
7
|
+
import {
|
|
8
|
+
BaseResourceApi,
|
|
9
|
+
ShapeDiverSdkApi,
|
|
10
|
+
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
11
|
+
import { sendRequest } from "../utils/utils";
|
|
12
|
+
|
|
13
|
+
export class ShapeDiverSessionApi extends BaseResourceApi {
|
|
14
|
+
constructor(api: ShapeDiverSdkApi) {
|
|
15
|
+
super(api);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Create a new ticket that allows to initialize new sessions for the
|
|
20
|
+
* specified model.
|
|
21
|
+
*
|
|
22
|
+
* @param modelId
|
|
23
|
+
* @param body
|
|
24
|
+
*/
|
|
25
|
+
async ticket(
|
|
26
|
+
modelId: string,
|
|
27
|
+
body: ShapeDiverRequestTicket,
|
|
28
|
+
): Promise<ShapeDiverResponseDto> {
|
|
29
|
+
return await sendRequest(
|
|
30
|
+
async () =>
|
|
31
|
+
(
|
|
32
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
33
|
+
this.buildModelUri(modelId) + "/ticket",
|
|
34
|
+
body,
|
|
35
|
+
)
|
|
36
|
+
)[1],
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Create a new session for a ShapeDiver Model via a ticket.
|
|
42
|
+
*
|
|
43
|
+
* @param ticket
|
|
44
|
+
* @param request - Optional customization or export request.
|
|
45
|
+
*/
|
|
46
|
+
async init(
|
|
47
|
+
ticket: string,
|
|
48
|
+
request?: ShapeDiverRequestCustomization | ShapeDiverRequestExport,
|
|
49
|
+
): Promise<ShapeDiverResponseDto> {
|
|
50
|
+
return await sendRequest(
|
|
51
|
+
async () =>
|
|
52
|
+
(
|
|
53
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
54
|
+
this.buildTicketUri(ticket),
|
|
55
|
+
request,
|
|
56
|
+
)
|
|
57
|
+
)[1],
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Create a new session for a ShapeDiver Model.
|
|
63
|
+
*
|
|
64
|
+
* @param ticket
|
|
65
|
+
* @param request - Optional customization or export request.
|
|
66
|
+
*/
|
|
67
|
+
async initForModel(
|
|
68
|
+
modelId: string,
|
|
69
|
+
request?: ShapeDiverRequestCustomization | ShapeDiverRequestExport,
|
|
70
|
+
): Promise<ShapeDiverResponseDto> {
|
|
71
|
+
return await sendRequest(
|
|
72
|
+
async () =>
|
|
73
|
+
(
|
|
74
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
75
|
+
this.buildModelUri(modelId) + "/session",
|
|
76
|
+
request,
|
|
77
|
+
)
|
|
78
|
+
)[1],
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Get the full description of a ShapeDiver Model.
|
|
84
|
+
*
|
|
85
|
+
* @param sessionId
|
|
86
|
+
*/
|
|
87
|
+
async default(sessionId: string): Promise<ShapeDiverResponseDto> {
|
|
88
|
+
return await sendRequest(
|
|
89
|
+
async () =>
|
|
90
|
+
(
|
|
91
|
+
await this.api.get<ShapeDiverResponseDto>(
|
|
92
|
+
this.buildSessionUri(sessionId) + "/default",
|
|
93
|
+
)
|
|
94
|
+
)[1],
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Close the specified session.
|
|
100
|
+
*
|
|
101
|
+
* @param sessionId
|
|
102
|
+
*/
|
|
103
|
+
async close(sessionId: string): Promise<ShapeDiverResponseDto> {
|
|
104
|
+
return await sendRequest(
|
|
105
|
+
async () =>
|
|
106
|
+
(
|
|
107
|
+
await this.api.post<ShapeDiverResponseDto>(
|
|
108
|
+
this.buildSessionUri(sessionId) + "/close",
|
|
109
|
+
)
|
|
110
|
+
)[1],
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|