@knime/hub-features 1.10.4 → 1.10.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.10.6
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [8e21558]
8
+ - @knime/styles@1.7.0
9
+ - @knime/components@1.30.1
10
+ - @knime/utils@1.4.4
11
+
12
+ ## 1.10.5
13
+
14
+ ### Patch Changes
15
+
16
+ - 805588d: update async download flow in useDownloadArtifact to reflect api changes
17
+
3
18
  ## 1.10.4
4
19
 
5
20
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.10.4",
3
+ "version": "1.10.6",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "homepage": "https://knime.github.io/webapps-common/",
6
6
  "license": "GPL 3 and Additional Permissions according to Sec. 7 (SEE the file LICENSE)",
@@ -31,9 +31,9 @@
31
31
  "lodash-es": "4.17.21",
32
32
  "ofetch": "^1.4.1",
33
33
  "typescript": "^5.4.5",
34
- "@knime/components": "1.30.0",
35
- "@knime/styles": "1.6.0",
36
- "@knime/utils": "1.4.3"
34
+ "@knime/components": "1.30.1",
35
+ "@knime/styles": "1.7.0",
36
+ "@knime/utils": "1.4.4"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "consola": "3.x",
@@ -18,8 +18,20 @@ type ArtifactStatusResponse = {
18
18
  downloadUrl?: string;
19
19
  };
20
20
 
21
- type RequestDownloadResponse = {
22
- downloadId: string;
21
+ // Initial request can have either download url (if it can be downloaded immediately) or download id (to poll for the status)
22
+ type RequestDownloadResponse =
23
+ | {
24
+ downloadId: string;
25
+ }
26
+ | {
27
+ downloadUrl: string;
28
+ };
29
+
30
+ // type guard
31
+ const hasDownloadUrl = (
32
+ response: RequestDownloadResponse,
33
+ ): response is { downloadUrl: string } => {
34
+ return "downloadUrl" in response;
23
35
  };
24
36
 
25
37
  /**
@@ -255,24 +267,20 @@ export const useDownloadArtifact = (
255
267
  query: { version },
256
268
  },
257
269
  );
258
- const downloadId = response.downloadId;
259
-
260
- const downloadStatusResponse = await fetchDownloadStatus({ downloadId });
261
-
262
- if (
263
- // download is ready immediately, no polling needed
264
- downloadStatusResponse?.status === "READY" &&
265
- downloadStatusResponse?.downloadUrl
266
- ) {
267
- openDownload(downloadStatusResponse.downloadUrl);
268
- } else {
269
- await pollDownloadItem({
270
- itemId,
271
- version,
272
- downloadId,
273
- name,
274
- });
270
+
271
+ // if download is ready, open url immediately
272
+ if (hasDownloadUrl(response)) {
273
+ openDownload(response.downloadUrl);
274
+ return;
275
275
  }
276
+
277
+ // otherwise start polling download status
278
+ await pollDownloadItem({
279
+ itemId,
280
+ version,
281
+ downloadId: response.downloadId,
282
+ name,
283
+ });
276
284
  } catch (error: unknown) {
277
285
  // here only errors thrown by the initial requests are caught;
278
286
  // errors occurring while polling will be handled in pollDownloadItem