@shapediver/sdk.geometry-api-sdk-v2 1.8.3 → 1.9.1

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.
Files changed (67) hide show
  1. package/dist/ShapeDiverErrors.d.ts.map +1 -1
  2. package/dist/ShapeDiverErrors.js +1 -1
  3. package/dist/ShapeDiverErrors.js.map +1 -1
  4. package/dist/ShapeDiverSdk.d.ts.map +1 -1
  5. package/dist/ShapeDiverSdk.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +1 -1
  10. package/dist/resources/ShapeDiverAnalyticsApi.js +3 -1
  11. package/dist/resources/ShapeDiverAnalyticsApi.js.map +1 -1
  12. package/dist/resources/ShapeDiverArSceneApi.d.ts.map +1 -1
  13. package/dist/resources/ShapeDiverArSceneApi.js.map +1 -1
  14. package/dist/resources/ShapeDiverAssetApi.d.ts.map +1 -1
  15. package/dist/resources/ShapeDiverAssetApi.js.map +1 -1
  16. package/dist/resources/ShapeDiverExportApi.d.ts.map +1 -1
  17. package/dist/resources/ShapeDiverExportApi.js.map +1 -1
  18. package/dist/resources/ShapeDiverFileApi.d.ts.map +1 -1
  19. package/dist/resources/ShapeDiverFileApi.js +4 -8
  20. package/dist/resources/ShapeDiverFileApi.js.map +1 -1
  21. package/dist/resources/ShapeDiverGltfApi.d.ts.map +1 -1
  22. package/dist/resources/ShapeDiverGltfApi.js +4 -1
  23. package/dist/resources/ShapeDiverGltfApi.js.map +1 -1
  24. package/dist/resources/ShapeDiverModelApi.d.ts.map +1 -1
  25. package/dist/resources/ShapeDiverModelApi.js +52 -15
  26. package/dist/resources/ShapeDiverModelApi.js.map +1 -1
  27. package/dist/resources/ShapeDiverOutputApi.d.ts.map +1 -1
  28. package/dist/resources/ShapeDiverOutputApi.js +12 -4
  29. package/dist/resources/ShapeDiverOutputApi.js.map +1 -1
  30. package/dist/resources/ShapeDiverSdtfApi.d.ts.map +1 -1
  31. package/dist/resources/ShapeDiverSdtfApi.js +9 -3
  32. package/dist/resources/ShapeDiverSdtfApi.js.map +1 -1
  33. package/dist/resources/ShapeDiverSessionApi.d.ts.map +1 -1
  34. package/dist/resources/ShapeDiverSessionApi.js +3 -1
  35. package/dist/resources/ShapeDiverSessionApi.js.map +1 -1
  36. package/dist/resources/ShapeDiverSystemApi.d.ts.map +1 -1
  37. package/dist/resources/ShapeDiverSystemApi.js +18 -6
  38. package/dist/resources/ShapeDiverSystemApi.js.map +1 -1
  39. package/dist/resources/ShapeDiverTextureApi.d.ts.map +1 -1
  40. package/dist/resources/ShapeDiverTextureApi.js +3 -1
  41. package/dist/resources/ShapeDiverTextureApi.js.map +1 -1
  42. package/dist/resources/ShapeDiverUtilsApi.d.ts +3 -5
  43. package/dist/resources/ShapeDiverUtilsApi.d.ts.map +1 -1
  44. package/dist/resources/ShapeDiverUtilsApi.js +32 -15
  45. package/dist/resources/ShapeDiverUtilsApi.js.map +1 -1
  46. package/dist/utils/utils.d.ts +3 -1
  47. package/dist/utils/utils.d.ts.map +1 -1
  48. package/dist/utils/utils.js +35 -9
  49. package/dist/utils/utils.js.map +1 -1
  50. package/package.json +2 -2
  51. package/src/ShapeDiverErrors.ts +24 -23
  52. package/src/ShapeDiverSdk.ts +110 -109
  53. package/src/index.ts +15 -16
  54. package/src/resources/ShapeDiverAnalyticsApi.ts +30 -18
  55. package/src/resources/ShapeDiverArSceneApi.ts +68 -69
  56. package/src/resources/ShapeDiverAssetApi.ts +207 -183
  57. package/src/resources/ShapeDiverExportApi.ts +92 -77
  58. package/src/resources/ShapeDiverFileApi.ts +127 -108
  59. package/src/resources/ShapeDiverGltfApi.ts +41 -30
  60. package/src/resources/ShapeDiverModelApi.ts +351 -240
  61. package/src/resources/ShapeDiverOutputApi.ts +92 -56
  62. package/src/resources/ShapeDiverSdtfApi.ts +88 -54
  63. package/src/resources/ShapeDiverSessionApi.ts +104 -82
  64. package/src/resources/ShapeDiverSystemApi.ts +106 -70
  65. package/src/resources/ShapeDiverTextureApi.ts +24 -18
  66. package/src/resources/ShapeDiverUtilsApi.ts +294 -231
  67. package/src/utils/utils.ts +100 -54
@@ -1,255 +1,318 @@
1
1
  import {
2
- ShapeDiverRequestCache,
3
- ShapeDiverRequestCustomization,
4
- ShapeDiverRequestExport,
5
- ShapeDiverResponseDto,
6
- ShapeDiverResponseExport,
7
- ShapeDiverResponseOutput,
8
- } from "@shapediver/api.geometry-api-dto-v2"
2
+ ShapeDiverRequestCache,
3
+ ShapeDiverRequestCustomization,
4
+ ShapeDiverRequestExport,
5
+ ShapeDiverResponseDto,
6
+ ShapeDiverResponseAssetUploadHeaders,
7
+ ShapeDiverResponseExport,
8
+ ShapeDiverResponseOutput,
9
+ } from "@shapediver/api.geometry-api-dto-v2";
9
10
  import {
10
- BaseResourceApi,
11
- ShapeDiverError,
12
- ShapeDiverSdkApi,
13
- ShapeDiverSdkApiResponseType,
14
- } from "@shapediver/sdk.geometry-api-sdk-core"
15
- import { ShapeDiverSdk } from "../ShapeDiverSdk"
16
- import { sendRequest, sleep } from "../utils/utils"
11
+ BaseResourceApi,
12
+ ShapeDiverError,
13
+ ShapeDiverSdkApi,
14
+ ShapeDiverSdkApiResponseType,
15
+ } from "@shapediver/sdk.geometry-api-sdk-core";
16
+ import { ShapeDiverSdk } from "../ShapeDiverSdk";
17
+ import {
18
+ contentDispositionFromFilename,
19
+ sendRequest,
20
+ sleep,
21
+ } from "../utils/utils";
17
22
 
18
23
  // TypeScript wrapper for a response type that depend on an input type
19
24
  type ShapeDiverSdkUtilsDownloadType<T extends ShapeDiverSdkApiResponseType> =
20
- T extends ShapeDiverSdkApiResponseType.TEXT ? string :
21
- T extends ShapeDiverSdkApiResponseType.JSON ? Record<string, any> :
22
- T extends ShapeDiverSdkApiResponseType.DATA ? ArrayBuffer :
23
- never;
25
+ T extends ShapeDiverSdkApiResponseType.TEXT
26
+ ? string
27
+ : T extends ShapeDiverSdkApiResponseType.JSON
28
+ ? Record<string, any>
29
+ : T extends ShapeDiverSdkApiResponseType.DATA
30
+ ? ArrayBuffer
31
+ : never;
24
32
 
25
33
  export class ShapeDiverUtilsApi extends BaseResourceApi {
34
+ constructor(api: ShapeDiverSdkApi) {
35
+ super(api);
36
+ }
26
37
 
27
- constructor(api: ShapeDiverSdkApi) {
28
- super(api)
29
- }
38
+ /**
39
+ * Upload the given file to the specified URL.
40
+ *
41
+ * @param url - The target URL of the upload request.
42
+ * @param data - The data that should be uploaded.
43
+ * @param contentType - Indicate the original media type of the resource.
44
+ * @param filename - The name of the file to be uploaded. When a filename has been specified in
45
+ * the request-upload call, then the same filename has to be specified for the upload as well.
46
+ */
47
+ async upload(
48
+ url: string,
49
+ data: ArrayBuffer | Record<string, any> | string,
50
+ contentType: string,
51
+ filename?: string,
52
+ ): Promise<any> {
53
+ return await sendRequest(async () =>
54
+ this.api.put<any>(url, data, {
55
+ contentType: contentType,
56
+ contentDisposition: filename
57
+ ? contentDispositionFromFilename(filename)
58
+ : undefined,
59
+ responseType: ShapeDiverSdkApiResponseType.JSON,
60
+ disableAuthorization: true,
61
+ disableCustomHeaders: true,
62
+ }),
63
+ );
64
+ }
30
65
 
31
- /**
32
- * Upload the given file to the specified URL.
33
- *
34
- * @param url - The target URL of the upload request.
35
- * @param data - The data that should be uploaded.
36
- * @param contentType - Indicate the original media type of the resource.
37
- * @param filename - The name of the file to be uploaded. When a filename has been specified in
38
- * the request-upload call, then the same filename has to be specified for the upload as well.
39
- */
40
- async upload(
41
- url: string,
42
- data: ArrayBuffer | Record<string, any> | string,
43
- contentType: string,
44
- filename?: string,
45
- ): Promise<any> {
46
- return await sendRequest(async () => this.api.put<any>(url, data, {
47
- contentType: contentType,
48
- contentDisposition: (filename) ? `attachment; filename="${filename}"` : undefined,
49
- responseType: ShapeDiverSdkApiResponseType.JSON,
50
- disableAuthorization: true,
51
- disableCustomHeaders: true,
52
- }))
53
- }
66
+ /**
67
+ * Upload the given asset to the specified ShapeDiver URL.
68
+ *
69
+ * @param url - The ShapeDiver URL of the upload request.
70
+ * @param data - The data that should be uploaded.
71
+ * @param headers - The headers object that was returned from the request-upload call.
72
+ */
73
+ async uploadAsset(
74
+ url: string,
75
+ data: ArrayBuffer | Record<string, any> | string,
76
+ headers: ShapeDiverResponseAssetUploadHeaders,
77
+ ): Promise<any> {
78
+ return await sendRequest(async () =>
79
+ this.api.put<any>(url, data, {
80
+ contentType: headers.contentType,
81
+ contentDisposition: headers.contentDisposition,
82
+ responseType: ShapeDiverSdkApiResponseType.JSON,
83
+ disableAuthorization: true,
84
+ disableCustomHeaders: true,
85
+ }),
86
+ );
87
+ }
54
88
 
55
- /**
56
- * Download from the given URL.
57
- *
58
- * @param url - The target URL of the download request.
59
- * @param responseType - Indicates the type of data that the server should respond with if possible.
60
- * @returns Array of size 2: [0] = response headers, [1] = response data
61
- */
62
- async download<T extends ShapeDiverSdkApiResponseType>(url: string, responseType: T): Promise<[
63
- Record<string, any>,
64
- ShapeDiverSdkUtilsDownloadType<T>,
65
- ]> {
66
- return await sendRequest(async () => this.api.get<any>(url, {
67
- contentType: "application/json",
68
- responseType: responseType,
69
- disableAuthorization: true,
70
- disableCustomHeaders: true,
71
- }))
72
- }
89
+ /**
90
+ * Download from the given URL.
91
+ *
92
+ * @param url - The target URL of the download request.
93
+ * @param responseType - Indicates the type of data that the server should respond with if possible.
94
+ * @returns Array of size 2: [0] = response headers, [1] = response data
95
+ */
96
+ async download<T extends ShapeDiverSdkApiResponseType>(
97
+ url: string,
98
+ responseType: T,
99
+ ): Promise<[Record<string, any>, ShapeDiverSdkUtilsDownloadType<T>]> {
100
+ return await sendRequest(async () =>
101
+ this.api.get<any>(url, {
102
+ contentType: "application/json",
103
+ responseType: responseType,
104
+ disableAuthorization: true,
105
+ disableCustomHeaders: true,
106
+ }),
107
+ );
108
+ }
73
109
 
74
- /**
75
- * Submit a customization request and wait for the result to be finished.
76
- *
77
- * @param sdk
78
- * @param sessionId
79
- * @param body
80
- * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
81
- * @throws {@link ShapeDiverError} in case a maximum duration has been specified and is exceeded.
82
- * @returns
83
- */
84
- async submitAndWaitForCustomization(
85
- sdk: ShapeDiverSdk,
86
- sessionId: string,
87
- body: ShapeDiverRequestCustomization,
88
- maxWaitMsec = -1,
89
- ): Promise<ShapeDiverResponseDto> {
90
- const startMsec = Date.now()
91
- const dto = await sendRequest(async () => sdk.output.customize(sessionId, body))
92
- const waitMsec = Date.now() - startMsec
93
-
94
- // Reduce the total max waiting time by the amount the customization-request took
95
- maxWaitMsec = (maxWaitMsec < 0) ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec)
96
-
97
- return ShapeDiverUtilsApi.waitForCustomizationResult(sdk, sessionId, dto, maxWaitMsec)
98
- }
110
+ /**
111
+ * Submit a customization request and wait for the result to be finished.
112
+ *
113
+ * @param sdk
114
+ * @param sessionId
115
+ * @param body
116
+ * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
117
+ * @throws {@link ShapeDiverError} in case a maximum duration has been specified and is exceeded.
118
+ * @returns
119
+ */
120
+ async submitAndWaitForCustomization(
121
+ sdk: ShapeDiverSdk,
122
+ sessionId: string,
123
+ body: ShapeDiverRequestCustomization,
124
+ maxWaitMsec = -1,
125
+ ): Promise<ShapeDiverResponseDto> {
126
+ const startMsec = Date.now();
127
+ const dto = await sendRequest(async () =>
128
+ sdk.output.customize(sessionId, body),
129
+ );
130
+ const waitMsec = Date.now() - startMsec;
99
131
 
100
- /**
101
- * Submit an export request and wait for the result to be finished.
102
- *
103
- * @param sdk
104
- * @param sessionId
105
- * @param body
106
- * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
107
- * @throws {@link ShapeDiverError} in case a maximum duration has been specified and is exceeded.
108
- * @returns
109
- */
110
- async submitAndWaitForExport(
111
- sdk: ShapeDiverSdk,
112
- sessionId: string,
113
- body: ShapeDiverRequestExport,
114
- maxWaitMsec = -1,
115
- ): Promise<ShapeDiverResponseDto> {
116
- const startMsec = Date.now()
117
- const dto = await sendRequest(async () => sdk.export.compute(sessionId, body))
118
- const waitMsec = Date.now() - startMsec
119
-
120
- // Reduce the total max waiting time by the amount the compute-request took
121
- maxWaitMsec = (maxWaitMsec < 0) ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec)
122
-
123
- return ShapeDiverUtilsApi.waitForExportResult(sdk, sessionId, body, dto, maxWaitMsec)
124
- }
132
+ // Reduce the total max waiting time by the amount the customization-request took
133
+ maxWaitMsec =
134
+ maxWaitMsec < 0 ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec);
135
+
136
+ return ShapeDiverUtilsApi.waitForCustomizationResult(
137
+ sdk,
138
+ sessionId,
139
+ dto,
140
+ maxWaitMsec,
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Submit an export request and wait for the result to be finished.
146
+ *
147
+ * @param sdk
148
+ * @param sessionId
149
+ * @param body
150
+ * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
151
+ * @throws {@link ShapeDiverError} in case a maximum duration has been specified and is exceeded.
152
+ * @returns
153
+ */
154
+ async submitAndWaitForExport(
155
+ sdk: ShapeDiverSdk,
156
+ sessionId: string,
157
+ body: ShapeDiverRequestExport,
158
+ maxWaitMsec = -1,
159
+ ): Promise<ShapeDiverResponseDto> {
160
+ const startMsec = Date.now();
161
+ const dto = await sendRequest(async () =>
162
+ sdk.export.compute(sessionId, body),
163
+ );
164
+ const waitMsec = Date.now() - startMsec;
165
+
166
+ // Reduce the total max waiting time by the amount the compute-request took
167
+ maxWaitMsec =
168
+ maxWaitMsec < 0 ? maxWaitMsec : Math.max(0, maxWaitMsec - waitMsec);
169
+
170
+ return ShapeDiverUtilsApi.waitForExportResult(
171
+ sdk,
172
+ sessionId,
173
+ body,
174
+ dto,
175
+ maxWaitMsec,
176
+ );
177
+ }
178
+
179
+ /**
180
+ * Given a DTO resulting from a customization request, wait for the results to be finished.
181
+ *
182
+ * @param sdk
183
+ * @param sessionId
184
+ * @param dto
185
+ * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
186
+ * @returns
187
+ */
188
+ private static async waitForCustomizationResult(
189
+ sdk: ShapeDiverSdk,
190
+ sessionId: string,
191
+ dto: ShapeDiverResponseDto,
192
+ maxWaitMsec = -1,
193
+ ): Promise<ShapeDiverResponseDto> {
194
+ if (!dto.outputs) return dto;
125
195
 
126
- /**
127
- * Given a DTO resulting from a customization request, wait for the results to be finished.
128
- *
129
- * @param sdk
130
- * @param sessionId
131
- * @param dto
132
- * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
133
- * @returns
134
- */
135
- private static async waitForCustomizationResult(
136
- sdk: ShapeDiverSdk,
137
- sessionId: string,
138
- dto: ShapeDiverResponseDto,
139
- maxWaitMsec = -1,
140
- ): Promise<ShapeDiverResponseDto> {
141
- if (!dto.outputs) return dto
142
-
143
- // Build new cache request
144
- const outputVersions: ShapeDiverRequestCache = {}
145
- Object
146
- .keys(dto.outputs)
147
- .forEach(id => outputVersions[id] = (dto.outputs![id] as ShapeDiverResponseOutput).version)
148
-
149
- let delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto)
150
- const startMsec = Date.now()
151
-
152
- while (delay > 0) {
153
- // Check whether maxWaitMsec has been reached
154
- if (maxWaitMsec >= 0) {
155
- const waitMsec = Date.now() - startMsec
156
- if (waitMsec >= maxWaitMsec) {
157
- throw new ShapeDiverError(`Maximum wait time of ${maxWaitMsec} ms reached`)
158
- }
159
- if (waitMsec + delay > maxWaitMsec) {
160
- delay = maxWaitMsec - waitMsec
161
- }
162
- }
163
-
164
- await sleep(delay)
165
-
166
- // Send cache request
167
- dto = await sendRequest(async () => sdk.output.getCache(sessionId, outputVersions))
168
- delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto)
196
+ // Build new cache request
197
+ const outputVersions: ShapeDiverRequestCache = {};
198
+ Object.keys(dto.outputs).forEach(
199
+ (id) =>
200
+ (outputVersions[id] = (
201
+ dto.outputs![id] as ShapeDiverResponseOutput
202
+ ).version),
203
+ );
204
+
205
+ let delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto);
206
+ const startMsec = Date.now();
207
+
208
+ while (delay > 0) {
209
+ // Check whether maxWaitMsec has been reached
210
+ if (maxWaitMsec >= 0) {
211
+ const waitMsec = Date.now() - startMsec;
212
+ if (waitMsec >= maxWaitMsec) {
213
+ throw new ShapeDiverError(
214
+ `Maximum wait time of ${maxWaitMsec} ms reached`,
215
+ );
216
+ }
217
+ if (waitMsec + delay > maxWaitMsec) {
218
+ delay = maxWaitMsec - waitMsec;
169
219
  }
220
+ }
170
221
 
171
- return dto
222
+ await sleep(delay);
223
+
224
+ // Send cache request
225
+ dto = await sendRequest(async () =>
226
+ sdk.output.getCache(sessionId, outputVersions),
227
+ );
228
+ delay = ShapeDiverUtilsApi.getMaxOutputDelay(dto);
172
229
  }
173
230
 
174
- /**
175
- * Given a DTO resulting from an export request, wait for the result to be finished.
176
- *
177
- * @param sdk
178
- * @param sessionId
179
- * @param dto
180
- * @param exportIds
181
- * @param outputIds
182
- * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
183
- * @returns
184
- */
185
- private static async waitForExportResult(
186
- sdk: ShapeDiverSdk,
187
- sessionId: string,
188
- body: ShapeDiverRequestExport,
189
- dto: ShapeDiverResponseDto,
190
- maxWaitMsec = -1,
191
- ): Promise<ShapeDiverResponseDto> {
192
- let delay = ShapeDiverUtilsApi.getMaxExportDelay(dto, body)
193
- const startMsec = Date.now()
194
-
195
- while (delay > 0) {
196
- // Check whether maxWaitMsec has been reached
197
- if (maxWaitMsec >= 0) {
198
- const waitMsec = Date.now() - startMsec
199
- if (waitMsec >= maxWaitMsec) {
200
- throw new ShapeDiverError(`Maximum wait time of ${maxWaitMsec} ms reached`)
201
- }
202
- if (waitMsec + delay > maxWaitMsec) {
203
- delay = maxWaitMsec - waitMsec
204
- }
205
- }
206
-
207
- await sleep(delay)
208
-
209
- // Send cache request
210
- dto = await sendRequest(async () => sdk.export.getCache(sessionId, body))
211
- delay = ShapeDiverUtilsApi.getMaxExportDelay(dto, body)
231
+ return dto;
232
+ }
233
+
234
+ /**
235
+ * Given a DTO resulting from an export request, wait for the result to be finished.
236
+ *
237
+ * @param sdk
238
+ * @param sessionId
239
+ * @param dto
240
+ * @param exportIds
241
+ * @param outputIds
242
+ * @param maxWaitMsec - Maximum duration to wait for result (in milliseconds), pass value < 0 to disable limit.
243
+ * @returns
244
+ */
245
+ private static async waitForExportResult(
246
+ sdk: ShapeDiverSdk,
247
+ sessionId: string,
248
+ body: ShapeDiverRequestExport,
249
+ dto: ShapeDiverResponseDto,
250
+ maxWaitMsec = -1,
251
+ ): Promise<ShapeDiverResponseDto> {
252
+ let delay = ShapeDiverUtilsApi.getMaxExportDelay(dto, body);
253
+ const startMsec = Date.now();
254
+
255
+ while (delay > 0) {
256
+ // Check whether maxWaitMsec has been reached
257
+ if (maxWaitMsec >= 0) {
258
+ const waitMsec = Date.now() - startMsec;
259
+ if (waitMsec >= maxWaitMsec) {
260
+ throw new ShapeDiverError(
261
+ `Maximum wait time of ${maxWaitMsec} ms reached`,
262
+ );
212
263
  }
264
+ if (waitMsec + delay > maxWaitMsec) {
265
+ delay = maxWaitMsec - waitMsec;
266
+ }
267
+ }
213
268
 
214
- return dto
215
- }
269
+ await sleep(delay);
216
270
 
217
- /**
218
- * Get the maximum delay that was reported for output versions.
219
- *
220
- * @returns maximum delay, -1 in case no delay was reported
221
- */
222
- private static getMaxOutputDelay(dto: ShapeDiverResponseDto): number {
223
- return Math.max(
224
- ...Object.values(dto.outputs!)
225
- .map(output => output as ShapeDiverResponseOutput)
226
- .map(output => output.delay ?? -1),
227
- )
271
+ // Send cache request
272
+ dto = await sendRequest(async () => sdk.export.getCache(sessionId, body));
273
+ delay = ShapeDiverUtilsApi.getMaxExportDelay(dto, body);
228
274
  }
229
275
 
230
- /**
231
- * Get the maximum delay that was reported for the exports. If outputs have been reported as
232
- * well, their delay time is included too.
233
- *
234
- * @returns delay, -1 in case no delay was reported
235
- */
236
- private static getMaxExportDelay(
237
- dto: ShapeDiverResponseDto,
238
- body: ShapeDiverRequestExport,
239
- ): number {
240
- const exports = (Array.isArray(body.exports)) ? body.exports : [body.exports.id]
241
- const outputs = body.outputs ?? []
242
-
243
- return Math.max(
244
- ...Object.values(dto.exports ?? {})
245
- .filter(e => exports.includes(e.id))
246
- .map(e => e as ShapeDiverResponseExport)
247
- .map(e => e.delay ?? -1),
248
- ...Object.values(dto.outputs ?? {})
249
- .filter(o => outputs.includes(o.id))
250
- .map(o => o as ShapeDiverResponseOutput)
251
- .map(o => o.delay ?? -1),
252
- )
253
- }
276
+ return dto;
277
+ }
278
+
279
+ /**
280
+ * Get the maximum delay that was reported for output versions.
281
+ *
282
+ * @returns maximum delay, -1 in case no delay was reported
283
+ */
284
+ private static getMaxOutputDelay(dto: ShapeDiverResponseDto): number {
285
+ return Math.max(
286
+ ...Object.values(dto.outputs!)
287
+ .map((output) => output as ShapeDiverResponseOutput)
288
+ .map((output) => output.delay ?? -1),
289
+ );
290
+ }
291
+
292
+ /**
293
+ * Get the maximum delay that was reported for the exports. If outputs have been reported as
294
+ * well, their delay time is included too.
295
+ *
296
+ * @returns delay, -1 in case no delay was reported
297
+ */
298
+ private static getMaxExportDelay(
299
+ dto: ShapeDiverResponseDto,
300
+ body: ShapeDiverRequestExport,
301
+ ): number {
302
+ const exports = Array.isArray(body.exports)
303
+ ? body.exports
304
+ : [body.exports.id];
305
+ const outputs = body.outputs ?? [];
254
306
 
307
+ return Math.max(
308
+ ...Object.values(dto.exports ?? {})
309
+ .filter((e) => exports.includes(e.id))
310
+ .map((e) => e as ShapeDiverResponseExport)
311
+ .map((e) => e.delay ?? -1),
312
+ ...Object.values(dto.outputs ?? {})
313
+ .filter((o) => outputs.includes(o.id))
314
+ .map((o) => o as ShapeDiverResponseOutput)
315
+ .map((o) => o.delay ?? -1),
316
+ );
317
+ }
255
318
  }