@knime/hub-features 1.20.0 → 1.21.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 068203b: introduce new version for user activity events
8
+
9
+ ## 1.20.1
10
+
11
+ ### Patch Changes
12
+
13
+ - c877d5a: NXT-4373: improve upload api
14
+ - Updated dependencies [c877d5a]
15
+ - @knime/components@1.45.6
16
+
3
17
  ## 1.20.0
4
18
 
5
19
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.20.0",
3
+ "version": "1.21.0",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "repository": {
6
6
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  "lodash-es": "4.17.23",
37
37
  "ofetch": "^1.4.1",
38
38
  "typescript": "^5.8.3",
39
- "@knime/components": "1.45.5",
39
+ "@knime/components": "1.45.6",
40
40
  "@knime/utils": "1.10.0",
41
41
  "@knime/styles": "1.15.0"
42
42
  },
@@ -85,7 +85,19 @@ export type GenericEventHandlers = {
85
85
  [K in GenericEvent["kind"]]?: (event: GenericEventByKind<K>) => void;
86
86
  };
87
87
 
88
- export type UserActivityInfo = {
89
- idle: boolean;
90
- lastActive: string;
91
- };
88
+ export type UserActivityInfo =
89
+ | {
90
+ idle: boolean;
91
+ lastActive: string;
92
+ version?: "v0";
93
+ }
94
+ | {
95
+ /**
96
+ * active: *default* state, user is interacting with app but NO background task is running
97
+ * idle: user is NOT interacting and NO task is running
98
+ * background-task: whenever a background task is running, whether the user is interacting with app or not
99
+ */
100
+ state: "active" | "idle" | "background-task";
101
+ lastActive: string;
102
+ version: "v1";
103
+ };
@@ -34,6 +34,7 @@ type UseFileUploadOptions = {
34
34
  uploadId: string;
35
35
  filePartIds: Record<number, string>;
36
36
  parentId: string;
37
+ name: string;
37
38
  }) => void;
38
39
  onFileUploadFailed?: (payload: {
39
40
  uploadId: string;
@@ -193,8 +194,7 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
193
194
 
194
195
  // contains upload ids for files that have a processing step which was not finished yet
195
196
  const unprocessedUploads = reactive<Set<string>>(new Set());
196
- const isFileWithProcessing = (file: File) =>
197
- knimeFileFormats.KNWF.matches(file);
197
+ const isKNWFFile = (file: File) => knimeFileFormats.KNWF.matches(file);
198
198
 
199
199
  let useUploadManagerResult: ReturnType<typeof useUploadManager> | null = null;
200
200
 
@@ -219,11 +219,16 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
219
219
  useUploadManagerResult = useUploadManager({
220
220
  resolveFilePartUploadURL,
221
221
 
222
- onFileUploadComplete: ({ uploadId, filePartIds, parentId }) => {
222
+ onFileUploadComplete: ({ uploadId, filePartIds, parentId, name }) => {
223
223
  promise
224
224
  .retryPromise({ fn: () => completeUpload(uploadId, filePartIds) })
225
225
  .then(() => {
226
- options.onFileUploadComplete?.({ uploadId, filePartIds, parentId });
226
+ options.onFileUploadComplete?.({
227
+ uploadId,
228
+ filePartIds,
229
+ parentId,
230
+ name,
231
+ });
227
232
  })
228
233
  .catch((error) => {
229
234
  consola.error("Error attempting to complete upload", { error });
@@ -274,7 +279,12 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
274
279
  isPreparingUpload: computed(() => prepareQueueSize.value > 0),
275
280
  totalFilesBeingPrepared: computed(() => prepareQueueSize.value),
276
281
 
277
- start: async (parentId: string, files: File[]) => {
282
+ start: async (
283
+ parentId: string,
284
+ files: File[],
285
+ options: { isFileWithProcessing?: typeof isKNWFFile } = {},
286
+ ) => {
287
+ const { isFileWithProcessing = isKNWFFile } = options;
278
288
  const enqueableFiles = getEnqueueableFiles(files);
279
289
  const uploadSizeLimitBytes = getUploadSizeLimitBytes();
280
290
  const oversizedFiles = enqueableFiles.filter(
@@ -294,7 +304,7 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
294
304
 
295
305
  try {
296
306
  if (enqueableFiles.length === 0) {
297
- return;
307
+ return [];
298
308
  }
299
309
 
300
310
  prepareQueueSize.value += enqueableFiles.length;
@@ -313,9 +323,13 @@ export const useFileUpload = (options: UseFileUploadOptions = {}) => {
313
323
  }
314
324
  });
315
325
 
326
+ const uploadIds = uploadPayload.map((upload) => upload.uploadId);
327
+
316
328
  // accept floating promise, errors are handled inside the function
317
329
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
318
330
  useUploadManagerResult.start(parentId, uploadPayload);
331
+
332
+ return uploadIds;
319
333
  } catch (error) {
320
334
  throw rfcErrors.tryParse(error) ?? error;
321
335
  } finally {