@knime/hub-features 1.7.3 → 1.7.4
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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knime/hub-features",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
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,8 +31,8 @@
|
|
|
31
31
|
"lodash-es": "4.17.21",
|
|
32
32
|
"ofetch": "^1.4.1",
|
|
33
33
|
"typescript": "^5.4.5",
|
|
34
|
-
"@knime/components": "1.26.0",
|
|
35
34
|
"@knime/styles": "1.4.0",
|
|
35
|
+
"@knime/components": "1.26.0",
|
|
36
36
|
"@knime/utils": "1.4.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { merge } from "lodash-es";
|
|
1
|
+
import { FetchError, type FetchOptions } from "ofetch";
|
|
3
2
|
|
|
4
|
-
import type
|
|
3
|
+
import { type HubAvatarData, rfcErrors } from "@knime/hub-features";
|
|
5
4
|
import { VERSION_DEFAULT_LIMIT } from "@knime/hub-features/versions";
|
|
6
5
|
import type {
|
|
7
6
|
AssignedLabel,
|
|
@@ -13,40 +12,47 @@ import type {
|
|
|
13
12
|
WithLabels,
|
|
14
13
|
} from "@knime/hub-features/versions";
|
|
15
14
|
|
|
15
|
+
import { DEFAULT_API_BASE_URL } from "../../common/constants";
|
|
16
|
+
import { getFetchClient } from "../../common/ofetchClient";
|
|
17
|
+
|
|
16
18
|
type UseVersionsApiOptions = {
|
|
17
19
|
baseUrl?: string;
|
|
20
|
+
customFetchClientOptions?: FetchOptions;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
export const useVersionsApi = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
export const useVersionsApi = ({
|
|
24
|
+
baseUrl,
|
|
25
|
+
customFetchClientOptions,
|
|
26
|
+
}: UseVersionsApiOptions) => {
|
|
27
|
+
const $ofetch = getFetchClient(customFetchClientOptions);
|
|
24
28
|
|
|
25
|
-
|
|
29
|
+
const doHubRequest = (path: string, fetchOptions?: FetchOptions) => {
|
|
30
|
+
const res = `${baseUrl ?? DEFAULT_API_BASE_URL}${path}`;
|
|
31
|
+
const defaults: FetchOptions = {
|
|
26
32
|
method: "GET",
|
|
27
33
|
};
|
|
28
|
-
return fetch(res, {
|
|
29
|
-
...defaults,
|
|
30
|
-
...requestOptions,
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
try {
|
|
36
|
+
consola.trace("useVersionsApi::calling", {
|
|
37
|
+
path: res,
|
|
38
|
+
options: fetchOptions,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return $ofetch(res, {
|
|
42
|
+
...defaults,
|
|
43
|
+
...fetchOptions,
|
|
44
|
+
});
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (error instanceof FetchError) {
|
|
47
|
+
throw rfcErrors.tryParse(error);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
43
52
|
};
|
|
44
53
|
|
|
45
54
|
const fetchRepositoryItem = ({ itemId }: { itemId: string }) => {
|
|
46
|
-
return
|
|
47
|
-
`/repository/${itemId}`,
|
|
48
|
-
{},
|
|
49
|
-
) as Promise<RepositoryItem>;
|
|
55
|
+
return doHubRequest(`/repository/${itemId}`) as Promise<RepositoryItem>;
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
const fetchVersions = ({
|
|
@@ -62,7 +68,7 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
62
68
|
path += "?limit=-1";
|
|
63
69
|
}
|
|
64
70
|
|
|
65
|
-
return
|
|
71
|
+
return doHubRequest(path) as Promise<{
|
|
66
72
|
totalCount: number;
|
|
67
73
|
versions: Array<NamedItemVersion>;
|
|
68
74
|
}>;
|
|
@@ -75,9 +81,8 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
75
81
|
resourceType: "savepoint";
|
|
76
82
|
resourceId: string;
|
|
77
83
|
}) => {
|
|
78
|
-
return
|
|
84
|
+
return doHubRequest(
|
|
79
85
|
`/validation/validation/resources/${resourceType}/${resourceId}/labels`,
|
|
80
|
-
{},
|
|
81
86
|
).catch(() => ({ assignedLabels: [] })) as Promise<{
|
|
82
87
|
assignedLabels: Array<AssignedLabel>;
|
|
83
88
|
}>;
|
|
@@ -104,7 +109,7 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
104
109
|
title: string;
|
|
105
110
|
description: string;
|
|
106
111
|
}): Promise<NamedItemVersion> => {
|
|
107
|
-
return
|
|
112
|
+
return doHubRequest(`/repository/${projectItemId}/versions`, {
|
|
108
113
|
method: "POST",
|
|
109
114
|
body: JSON.stringify({
|
|
110
115
|
title,
|
|
@@ -118,14 +123,11 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
118
123
|
}: {
|
|
119
124
|
accountName: string;
|
|
120
125
|
}): Promise<HubAvatarData> => {
|
|
121
|
-
const accountInfo = await
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
headers: {
|
|
125
|
-
Prefer: "representation=minimal",
|
|
126
|
-
},
|
|
126
|
+
const accountInfo = await doHubRequest(`/accounts/name/${accountName}`, {
|
|
127
|
+
headers: {
|
|
128
|
+
Prefer: "representation=minimal",
|
|
127
129
|
},
|
|
128
|
-
);
|
|
130
|
+
});
|
|
129
131
|
|
|
130
132
|
return {
|
|
131
133
|
kind: accountInfo.type === "TEAM" ? "group" : "account",
|
|
@@ -134,7 +136,7 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
134
136
|
url: accountInfo.avatarUrl,
|
|
135
137
|
altText: `${accountInfo.realName ?? accountInfo.name} profile image`,
|
|
136
138
|
},
|
|
137
|
-
}
|
|
139
|
+
};
|
|
138
140
|
};
|
|
139
141
|
|
|
140
142
|
const loadSavepointMetadata = async (
|
|
@@ -160,7 +162,7 @@ export const useVersionsApi = ({ baseUrl }: UseVersionsApiOptions) => {
|
|
|
160
162
|
itemId: string;
|
|
161
163
|
limit?: number;
|
|
162
164
|
}) => {
|
|
163
|
-
return
|
|
165
|
+
return doHubRequest(
|
|
164
166
|
`/repository/${itemId}/savepoints?limit=${
|
|
165
167
|
limit ?? VERSION_DEFAULT_LIMIT
|
|
166
168
|
}`,
|
|
@@ -43,7 +43,7 @@ type UseFileUploadOptions = {
|
|
|
43
43
|
* It is a multi-step process which is described as follows:
|
|
44
44
|
*
|
|
45
45
|
* Step 1:
|
|
46
|
-
* First we need to prepare an upload. The items will
|
|
46
|
+
* First we need to prepare an upload. The items will be uploaded to a `parent` container
|
|
47
47
|
* identified by its id. Then, for each file we want to upload, we must provide paths relative
|
|
48
48
|
* to the parent that identify each file. Example:
|
|
49
49
|
* ```
|