@knime/hub-features 1.28.0 → 1.29.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.
- package/CHANGELOG.md +26 -0
- package/package.json +6 -6
- package/src/analytics/schema/cloudhome-event-functions.ts +7 -9
- package/src/analytics/schema/code-generator.js +1 -3
- package/src/analytics/schema/editor-event-functions.ts +7 -9
- package/src/analytics/schema/schema.d.ts +12 -12
- package/src/analytics/schema/schema.json +13 -13
- package/src/httpClient/constants.ts +1 -0
- package/src/{common/ofetchClient.ts → httpClient/createHttpClient.ts} +6 -5
- package/src/httpClient/index.ts +2 -0
- package/src/index.ts +1 -0
- package/src/useDownloadArtifact/useDownloadArtifact.ts +2 -2
- package/src/useFileUpload/useFileUpload.ts +2 -2
- package/src/common/constants.ts +0 -1
- package/src/components/versions/components/CreateVersionForm.vue +0 -155
- package/src/components/versions/components/CurrentState.vue +0 -258
- package/src/components/versions/components/LabelList.vue +0 -253
- package/src/components/versions/components/ManageVersions.vue +0 -191
- package/src/components/versions/components/NoVersionItem.vue +0 -23
- package/src/components/versions/components/VersionHistory.vue +0 -138
- package/src/components/versions/components/VersionItem.vue +0 -278
- package/src/components/versions/components/VersionLimitInfo.vue +0 -37
- package/src/components/versions/composables/useVersionsApi.ts +0 -254
- package/src/components/versions/constants.ts +0 -3
- package/src/components/versions/index.ts +0 -7
- package/src/components/versions/types.ts +0 -77
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { type FetchOptions } from "ofetch";
|
|
2
|
-
|
|
3
|
-
import { type HubAvatarData, rfcErrors } from "@knime/hub-features";
|
|
4
|
-
import { VERSION_DEFAULT_LIMIT } from "@knime/hub-features/versions";
|
|
5
|
-
import type {
|
|
6
|
-
AssignedLabel,
|
|
7
|
-
ItemPermission,
|
|
8
|
-
ItemSavepoint,
|
|
9
|
-
NamedItemVersion,
|
|
10
|
-
RepositoryItem,
|
|
11
|
-
VersionLimit,
|
|
12
|
-
WithAvatar,
|
|
13
|
-
WithLabels,
|
|
14
|
-
} from "@knime/hub-features/versions";
|
|
15
|
-
|
|
16
|
-
import { getFetchClient } from "../../../common/ofetchClient";
|
|
17
|
-
|
|
18
|
-
type UseVersionsApiOptions = {
|
|
19
|
-
customFetchClientOptions?: FetchOptions;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const useVersionsApi = ({
|
|
23
|
-
customFetchClientOptions,
|
|
24
|
-
}: UseVersionsApiOptions) => {
|
|
25
|
-
const $ofetch = getFetchClient(customFetchClientOptions);
|
|
26
|
-
|
|
27
|
-
const doHubRequest = async (path: string, fetchOptions?: FetchOptions) => {
|
|
28
|
-
const defaults: FetchOptions = {
|
|
29
|
-
method: "GET",
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
consola.trace("useVersionsApi::calling", {
|
|
34
|
-
path,
|
|
35
|
-
options: fetchOptions,
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return await $ofetch(path, { ...defaults, ...fetchOptions });
|
|
39
|
-
} catch (error) {
|
|
40
|
-
throw rfcErrors.tryParse(error) ?? error;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const fetchRepositoryItem = ({ itemId }: { itemId: string }) => {
|
|
45
|
-
return doHubRequest(`/repository/${itemId}`) as Promise<RepositoryItem>;
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const fetchVersionLimit = ({ itemId }: { itemId: string }) => {
|
|
49
|
-
return doHubRequest(
|
|
50
|
-
`/repository/limits/${itemId}/item-versions`,
|
|
51
|
-
) as Promise<VersionLimit>;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const fetchVersions = ({
|
|
55
|
-
itemId,
|
|
56
|
-
loadAll,
|
|
57
|
-
}: {
|
|
58
|
-
itemId: string;
|
|
59
|
-
loadAll: boolean;
|
|
60
|
-
}) => {
|
|
61
|
-
let path = `/repository/${itemId}/versions`;
|
|
62
|
-
|
|
63
|
-
if (loadAll) {
|
|
64
|
-
path += "?limit=-1";
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return doHubRequest(path) as Promise<{
|
|
68
|
-
totalCount: number;
|
|
69
|
-
versions: Array<NamedItemVersion>;
|
|
70
|
-
}>;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
const fetchResourceLabels = async ({
|
|
74
|
-
resourceType,
|
|
75
|
-
resourceId,
|
|
76
|
-
}: {
|
|
77
|
-
resourceType: "savepoint";
|
|
78
|
-
resourceId: string;
|
|
79
|
-
}): Promise<{
|
|
80
|
-
assignedLabels: Array<AssignedLabel>;
|
|
81
|
-
}> => {
|
|
82
|
-
try {
|
|
83
|
-
return await doHubRequest(
|
|
84
|
-
`/validation/validation/resources/${resourceType}/${resourceId}/labels`,
|
|
85
|
-
);
|
|
86
|
-
} catch (error) {
|
|
87
|
-
consola.error("useVersionsApi::Failed to fetch resource labels", {
|
|
88
|
-
resourceId,
|
|
89
|
-
resourceType,
|
|
90
|
-
error,
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return { assignedLabels: [] };
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const deleteVersion = ({
|
|
98
|
-
itemId,
|
|
99
|
-
version,
|
|
100
|
-
}: {
|
|
101
|
-
itemId: string;
|
|
102
|
-
version: NamedItemVersion["version"];
|
|
103
|
-
}) => {
|
|
104
|
-
return doHubRequest(`/repository/${itemId}/versions/${version}`, {
|
|
105
|
-
method: "DELETE",
|
|
106
|
-
});
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
const restoreVersion = ({
|
|
110
|
-
itemId,
|
|
111
|
-
version,
|
|
112
|
-
}: {
|
|
113
|
-
itemId: string;
|
|
114
|
-
version: NamedItemVersion["version"];
|
|
115
|
-
}) => {
|
|
116
|
-
return doHubRequest(
|
|
117
|
-
`/repository/${itemId}/workingArea?fromVersion=${version}`,
|
|
118
|
-
{
|
|
119
|
-
method: "POST",
|
|
120
|
-
},
|
|
121
|
-
);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const discardUnversionedChanges = ({ itemId }: { itemId: string }) => {
|
|
125
|
-
return doHubRequest(`/repository/${itemId}/workingArea`, {
|
|
126
|
-
method: "DELETE",
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const createVersion = ({
|
|
131
|
-
itemId,
|
|
132
|
-
title,
|
|
133
|
-
description,
|
|
134
|
-
}: {
|
|
135
|
-
itemId: string;
|
|
136
|
-
title: string;
|
|
137
|
-
description: string;
|
|
138
|
-
}): Promise<NamedItemVersion> => {
|
|
139
|
-
return doHubRequest(`/repository/${itemId}/versions`, {
|
|
140
|
-
method: "POST",
|
|
141
|
-
body: JSON.stringify({
|
|
142
|
-
title,
|
|
143
|
-
description,
|
|
144
|
-
}),
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
const getAvatar = async ({
|
|
149
|
-
accountName,
|
|
150
|
-
}: {
|
|
151
|
-
accountName: string;
|
|
152
|
-
}): Promise<HubAvatarData> => {
|
|
153
|
-
try {
|
|
154
|
-
const accountInfo = await doHubRequest(`/accounts/name/${accountName}`, {
|
|
155
|
-
headers: {
|
|
156
|
-
Prefer: "representation=minimal",
|
|
157
|
-
},
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
return {
|
|
161
|
-
kind: accountInfo.type === "TEAM" ? "group" : "account",
|
|
162
|
-
name: accountInfo.name,
|
|
163
|
-
image: {
|
|
164
|
-
url: accountInfo.avatarUrl,
|
|
165
|
-
altText: `${accountInfo.realName ?? accountInfo.name} profile image`,
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
} catch (error) {
|
|
169
|
-
consola.error("useVersionsApi::Failed to fetch user avatar", {
|
|
170
|
-
accountName,
|
|
171
|
-
error,
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
return {
|
|
175
|
-
kind: "account",
|
|
176
|
-
name: "?",
|
|
177
|
-
tooltip: "unknown",
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
const loadSavepointMetadata = async (
|
|
183
|
-
savepoint: ItemSavepoint,
|
|
184
|
-
): Promise<WithAvatar & WithLabels> => {
|
|
185
|
-
const avatar = await getAvatar({
|
|
186
|
-
accountName: savepoint.version?.author ?? savepoint.author,
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
const labels = savepoint.itemVersionId
|
|
190
|
-
? await fetchResourceLabels({
|
|
191
|
-
resourceType: "savepoint",
|
|
192
|
-
resourceId: savepoint.itemVersionId,
|
|
193
|
-
}).then((response) => response.assignedLabels)
|
|
194
|
-
: [];
|
|
195
|
-
|
|
196
|
-
return { avatar, labels };
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
const fetchItemSavepoints = ({
|
|
200
|
-
itemId,
|
|
201
|
-
limit,
|
|
202
|
-
}: {
|
|
203
|
-
itemId: string;
|
|
204
|
-
limit?: number;
|
|
205
|
-
}) => {
|
|
206
|
-
return doHubRequest(
|
|
207
|
-
`/repository/${itemId}/savepoints?limit=${
|
|
208
|
-
limit ?? VERSION_DEFAULT_LIMIT
|
|
209
|
-
}`,
|
|
210
|
-
) as Promise<{
|
|
211
|
-
totalCount: number;
|
|
212
|
-
savepoints: Array<ItemSavepoint>;
|
|
213
|
-
}>;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
const fetchPermissions = async ({
|
|
217
|
-
itemId,
|
|
218
|
-
}: {
|
|
219
|
-
itemId: string;
|
|
220
|
-
}): Promise<ItemPermission[]> => {
|
|
221
|
-
const masonControlsMap = {
|
|
222
|
-
"knime:delete": "DELETE",
|
|
223
|
-
edit: "EDIT",
|
|
224
|
-
"knime:configuration": "CONFIGURATION",
|
|
225
|
-
"knime:move": "MOVE",
|
|
226
|
-
"knime:copy": "COPY",
|
|
227
|
-
} as const;
|
|
228
|
-
|
|
229
|
-
const repositoryItem = await fetchRepositoryItem({
|
|
230
|
-
itemId,
|
|
231
|
-
});
|
|
232
|
-
return Object.keys(repositoryItem["@controls"])
|
|
233
|
-
.filter((control) => control in masonControlsMap)
|
|
234
|
-
.map(
|
|
235
|
-
(control) => masonControlsMap[control as keyof typeof masonControlsMap],
|
|
236
|
-
);
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
fetchVersions,
|
|
241
|
-
fetchVersionLimit,
|
|
242
|
-
fetchResourceLabels,
|
|
243
|
-
fetchItemSavepoints,
|
|
244
|
-
fetchPermissions,
|
|
245
|
-
loadSavepointMetadata,
|
|
246
|
-
deleteVersion,
|
|
247
|
-
restoreVersion,
|
|
248
|
-
discardUnversionedChanges,
|
|
249
|
-
createVersion,
|
|
250
|
-
getAvatar,
|
|
251
|
-
};
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export type VersionsAPI = ReturnType<typeof useVersionsApi>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import CreateVersionForm from "./components/CreateVersionForm.vue";
|
|
2
|
-
import ManageVersions from "./components/ManageVersions.vue";
|
|
3
|
-
|
|
4
|
-
export { CreateVersionForm, ManageVersions };
|
|
5
|
-
export type * from "./types";
|
|
6
|
-
export * from "./constants";
|
|
7
|
-
export * from "./composables/useVersionsApi";
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { HubAvatarData } from "../avatars/HubAvatar.vue";
|
|
2
|
-
|
|
3
|
-
import type { CURRENT_STATE_VERSION, MOST_RECENT_VERSION } from "./constants";
|
|
4
|
-
|
|
5
|
-
// TODO: Generate from OpenAPI spec
|
|
6
|
-
export type NamedItemVersion = {
|
|
7
|
-
version: number | typeof CURRENT_STATE_VERSION | typeof MOST_RECENT_VERSION;
|
|
8
|
-
title: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
author: string;
|
|
11
|
-
authorAccountId?: string;
|
|
12
|
-
createdOn: string;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
interface MasonControl {
|
|
16
|
-
[key: string]: {
|
|
17
|
-
href: string;
|
|
18
|
-
method: string;
|
|
19
|
-
accept?: string[];
|
|
20
|
-
encoding?: string;
|
|
21
|
-
title?: string;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type RepositoryItem = {
|
|
26
|
-
path: string;
|
|
27
|
-
id: string;
|
|
28
|
-
type: string;
|
|
29
|
-
owner: string;
|
|
30
|
-
author: string;
|
|
31
|
-
createdOn: string;
|
|
32
|
-
"@controls": Array<MasonControl>;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type AssignedLabel = {
|
|
36
|
-
labelId: string;
|
|
37
|
-
message?: string;
|
|
38
|
-
createdAt?: string;
|
|
39
|
-
createdBy?: string; // UUID
|
|
40
|
-
label: {
|
|
41
|
-
name?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export type WithAvatar = { avatar: HubAvatarData };
|
|
47
|
-
export type WithLabels = { labels: Array<AssignedLabel> };
|
|
48
|
-
|
|
49
|
-
type ItemChange = {
|
|
50
|
-
author: string;
|
|
51
|
-
createdOn: string;
|
|
52
|
-
eventActionType: "ADDED" | "UPDATED" | "MOVED" | "RENAMED";
|
|
53
|
-
message: string;
|
|
54
|
-
authorAccountId?: string;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export type ItemSavepoint = {
|
|
58
|
-
author: string;
|
|
59
|
-
authorAccountId?: string;
|
|
60
|
-
lastEditedOn: string;
|
|
61
|
-
savepointNumber: number;
|
|
62
|
-
version?: NamedItemVersion;
|
|
63
|
-
itemVersionId?: string; // UUID
|
|
64
|
-
changes: Array<ItemChange>;
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type ItemPermission =
|
|
68
|
-
| "DELETE"
|
|
69
|
-
| "EDIT"
|
|
70
|
-
| "CONFIGURATION"
|
|
71
|
-
| "MOVE"
|
|
72
|
-
| "COPY";
|
|
73
|
-
|
|
74
|
-
export type VersionLimit = {
|
|
75
|
-
currentUsage: number;
|
|
76
|
-
limit?: number;
|
|
77
|
-
};
|