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