@knime/utils 1.4.3 → 1.5.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 +16 -0
- package/package.json +2 -2
- package/src/filters.ts +1 -1
- package/src/formatHotkeys.ts +2 -2
- package/src/index.ts +4 -8
- package/src/promise/retryPromise.ts +0 -1
- package/src/uploadManager/index.ts +2 -2
- package/test-utils/muteConsole.ts +5 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @knime/utils
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 493c9f0: TS improvements
|
|
8
|
+
|
|
9
|
+
- removed namespaces: UploadManagerNS
|
|
10
|
+
- replaced any with fitting type or unknown/never
|
|
11
|
+
|
|
12
|
+
## 1.4.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [8e21558]
|
|
17
|
+
- @knime/styles@1.7.0
|
|
18
|
+
|
|
3
19
|
## 1.4.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@knime/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Internal utility functions and constants shared across @knime packages.",
|
|
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)",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"date-fns": "2.30.0",
|
|
11
11
|
"date-fns-tz": "2.0.0",
|
|
12
|
-
"@knime/styles": "1.
|
|
12
|
+
"@knime/styles": "1.7.0"
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
15
|
"consola": "3.x"
|
package/src/filters.ts
CHANGED
|
@@ -110,5 +110,5 @@ const modeDefinitions = [
|
|
|
110
110
|
// convert [{id: "key1", text: "asdf"}, ...] to {"key1": {id:"key1", text: "asdf"} ... }
|
|
111
111
|
export const filters: Record<
|
|
112
112
|
string,
|
|
113
|
-
FilterDefinition<
|
|
113
|
+
FilterDefinition<unknown, unknown, unknown>
|
|
114
114
|
> = Object.assign({}, ...modeDefinitions.map((obj) => ({ [obj.id]: obj })));
|
package/src/formatHotkeys.ts
CHANGED
|
@@ -73,8 +73,8 @@ export const formatHotkey = (hotkey: Hotkey): string => {
|
|
|
73
73
|
* Pipe function implementation. Receives a list of functions to execute in order
|
|
74
74
|
* and will pipe the parameter passed at the end to each function returning the final output
|
|
75
75
|
*/
|
|
76
|
-
const pipe = <T extends () =>
|
|
77
|
-
...fns: Array<(...args:
|
|
76
|
+
const pipe = <T extends () => string>(
|
|
77
|
+
...fns: Array<(...args: Hotkey[]) => ReturnType<T>>
|
|
78
78
|
) => fns.reduce((f, g) => (arg) => g(f(arg)));
|
|
79
79
|
|
|
80
80
|
const macKeyFormatter = pipe(
|
package/src/index.ts
CHANGED
|
@@ -37,15 +37,11 @@ import * as uploadManager from "./uploadManager";
|
|
|
37
37
|
|
|
38
38
|
const hotkeys = { formatHotkeys, formatHotkey, getDefaultSeparator };
|
|
39
39
|
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
export type KnownHotkey = _KnownHotkey;
|
|
43
|
-
}
|
|
40
|
+
export type Hotkey = _Hotkey;
|
|
41
|
+
export type KnownHotkey = _KnownHotkey;
|
|
44
42
|
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
export type UploadStateName = _UploadStateName;
|
|
48
|
-
}
|
|
43
|
+
export type UploaderConfig = _UploadManagerConfig;
|
|
44
|
+
export type UploadStateName = _UploadStateName;
|
|
49
45
|
|
|
50
46
|
export * from "./fileExtensions";
|
|
51
47
|
export * from "./hotkeys";
|
|
@@ -312,7 +312,7 @@ export const createUploadManager = (config: UploaderManagerConfig) => {
|
|
|
312
312
|
|
|
313
313
|
setFailed(
|
|
314
314
|
uploadId,
|
|
315
|
-
error instanceof Error ? error : new Error(error as
|
|
315
|
+
error instanceof Error ? error : new Error(error as string),
|
|
316
316
|
);
|
|
317
317
|
return;
|
|
318
318
|
}
|
|
@@ -333,7 +333,7 @@ export const createUploadManager = (config: UploaderManagerConfig) => {
|
|
|
333
333
|
};
|
|
334
334
|
|
|
335
335
|
const uploadFiles = (files: Array<{ uploadId: string; file: File }>) => {
|
|
336
|
-
const result: Array<Promise<
|
|
336
|
+
const result: Array<Promise<unknown>> = [];
|
|
337
337
|
|
|
338
338
|
for (const { uploadId, file } of files) {
|
|
339
339
|
result.push(uploadFileFromChunkIndex(uploadId, file));
|
|
@@ -8,8 +8,7 @@ const methods: ConsoleMethod[] = ["log", "warn", "error", "info"];
|
|
|
8
8
|
* @param f The function to run. Can be async.
|
|
9
9
|
* @returns The original function's return value
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
export default (f: Function) => {
|
|
11
|
+
export default (f: (...args: never[]) => Promise<unknown>) => {
|
|
13
12
|
const originals = methods.map((method) => console[method]);
|
|
14
13
|
methods.forEach((method) => {
|
|
15
14
|
console[method] = () => {};
|
|
@@ -38,7 +37,10 @@ export default (f: Function) => {
|
|
|
38
37
|
|
|
39
38
|
if (f.constructor.name === "AsyncFunction") {
|
|
40
39
|
// async
|
|
41
|
-
|
|
40
|
+
const result = f();
|
|
41
|
+
if (result instanceof Promise) {
|
|
42
|
+
return result.finally(restoreOriginals);
|
|
43
|
+
}
|
|
42
44
|
} else {
|
|
43
45
|
// sync
|
|
44
46
|
try {
|