@n8n/utils 1.48.1 → 1.49.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/dist/errors/ensure-error.cjs +1 -1
- package/dist/errors/ensure-error.cjs.map +1 -1
- package/dist/errors/ensure-error.mjs +1 -1
- package/dist/errors/ensure-error.mjs.map +1 -1
- package/dist/nodes-api-level.cjs +19 -0
- package/dist/nodes-api-level.cjs.map +1 -0
- package/dist/nodes-api-level.d.cts +7 -0
- package/dist/nodes-api-level.d.mts +7 -0
- package/dist/nodes-api-level.mjs +17 -0
- package/dist/nodes-api-level.mjs.map +1 -0
- package/dist/run-serially.cjs +16 -0
- package/dist/run-serially.cjs.map +1 -0
- package/dist/run-serially.d.cts +5 -0
- package/dist/run-serially.d.mts +5 -0
- package/dist/run-serially.mjs +15 -0
- package/dist/run-serially.mjs.map +1 -0
- package/package.json +9 -7
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
//#region src/errors/ensure-error.ts
|
|
3
3
|
/** Ensures `error` is an `Error */
|
|
4
4
|
function ensureError(error) {
|
|
5
|
-
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: error });
|
|
5
|
+
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: new Error(String(error)) });
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
exports.ensureError = ensureError;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-error.cjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\tcause: error,\n\t\t\t});\n}\n"],"mappings":";;;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,
|
|
1
|
+
{"version":3,"file":"ensure-error.cjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\t// Wrap this into an error, so error-reporter can report it\n\t\t\t\tcause: new Error(String(error)),\n\t\t\t});\n}\n"],"mappings":";;;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,EAGhE,OAAO,IAAI,MAAM,OAAO,KAAK,CAAC,EAC/B,CAAC;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/errors/ensure-error.ts
|
|
2
2
|
/** Ensures `error` is an `Error */
|
|
3
3
|
function ensureError(error) {
|
|
4
|
-
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: error });
|
|
4
|
+
return error instanceof Error ? error : new Error("Error that was not an instance of Error was thrown", { cause: new Error(String(error)) });
|
|
5
5
|
}
|
|
6
6
|
//#endregion
|
|
7
7
|
export { ensureError };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ensure-error.mjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\tcause: error,\n\t\t\t});\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,
|
|
1
|
+
{"version":3,"file":"ensure-error.mjs","names":[],"sources":["../../src/errors/ensure-error.ts"],"sourcesContent":["/** Ensures `error` is an `Error */\nexport function ensureError(error: unknown): Error {\n\treturn error instanceof Error\n\t\t? error\n\t\t: new Error('Error that was not an instance of Error was thrown', {\n\t\t\t\t// We should never throw anything except something that derives from Error\n\t\t\t\t// Wrap this into an error, so error-reporter can report it\n\t\t\t\tcause: new Error(String(error)),\n\t\t\t});\n}\n"],"mappings":";;AACA,SAAgB,YAAY,OAAuB;CAClD,OAAO,iBAAiB,QACrB,QACA,IAAI,MAAM,sDAAsD,EAGhE,OAAO,IAAI,MAAM,OAAO,KAAK,CAAC,EAC/B,CAAC;AACJ"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let semver = require("semver");
|
|
3
|
+
//#region src/nodes-api-level.ts
|
|
4
|
+
function parseNodesApiLevel(value) {
|
|
5
|
+
const text = typeof value === "number" && Number.isInteger(value) ? String(value) : value;
|
|
6
|
+
if (typeof text !== "string") return null;
|
|
7
|
+
const version = (0, semver.coerce)(text);
|
|
8
|
+
if (version === null || version.major < 1) return null;
|
|
9
|
+
if (text !== `${version.major}` && text !== `${version.major}.${version.minor}`) return null;
|
|
10
|
+
return version;
|
|
11
|
+
}
|
|
12
|
+
function formatNodesApiLevel({ major, minor }) {
|
|
13
|
+
return `${major}.${minor}`;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
exports.formatNodesApiLevel = formatNodesApiLevel;
|
|
17
|
+
exports.parseNodesApiLevel = parseNodesApiLevel;
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=nodes-api-level.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-api-level.cjs","names":[],"sources":["../src/nodes-api-level.ts"],"sourcesContent":["import { coerce, type SemVer } from 'semver';\n\n// A float is rejected, since an unquoted `3.10` in package.json is read as\n// the number `3.1`. The input must print back from its coerced version as\n// `<major>` or `<major>.<minor>`.\nexport function parseNodesApiLevel(value: unknown): SemVer | null {\n\tconst text = typeof value === 'number' && Number.isInteger(value) ? String(value) : value;\n\tif (typeof text !== 'string') return null;\n\n\tconst version = coerce(text);\n\tif (version === null || version.major < 1) return null;\n\tif (text !== `${version.major}` && text !== `${version.major}.${version.minor}`) return null;\n\n\treturn version;\n}\n\nexport function formatNodesApiLevel({ major, minor }: SemVer): string {\n\treturn `${major}.${minor}`;\n}\n"],"mappings":";;;AAKA,SAAgB,mBAAmB,OAA+B;CACjE,MAAM,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,IAAI,OAAO,KAAK,IAAI;CACpF,IAAI,OAAO,SAAS,UAAU,OAAO;CAErC,MAAM,WAAA,GAAA,OAAA,OAAA,CAAiB,IAAI;CAC3B,IAAI,YAAY,QAAQ,QAAQ,QAAQ,GAAG,OAAO;CAClD,IAAI,SAAS,GAAG,QAAQ,WAAW,SAAS,GAAG,QAAQ,MAAM,GAAG,QAAQ,SAAS,OAAO;CAExF,OAAO;AACR;AAEA,SAAgB,oBAAoB,EAAE,OAAO,SAAyB;CACrE,OAAO,GAAG,MAAM,GAAG;AACpB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SemVer } from "semver";
|
|
2
|
+
//#region src/nodes-api-level.d.ts
|
|
3
|
+
declare function parseNodesApiLevel(value: unknown): SemVer | null;
|
|
4
|
+
declare function formatNodesApiLevel({ major, minor }: SemVer): string;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { formatNodesApiLevel, parseNodesApiLevel };
|
|
7
|
+
//# sourceMappingURL=nodes-api-level.d.cts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SemVer } from "semver";
|
|
2
|
+
//#region src/nodes-api-level.d.ts
|
|
3
|
+
declare function parseNodesApiLevel(value: unknown): SemVer | null;
|
|
4
|
+
declare function formatNodesApiLevel({ major, minor }: SemVer): string;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { formatNodesApiLevel, parseNodesApiLevel };
|
|
7
|
+
//# sourceMappingURL=nodes-api-level.d.mts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { coerce } from "semver";
|
|
2
|
+
//#region src/nodes-api-level.ts
|
|
3
|
+
function parseNodesApiLevel(value) {
|
|
4
|
+
const text = typeof value === "number" && Number.isInteger(value) ? String(value) : value;
|
|
5
|
+
if (typeof text !== "string") return null;
|
|
6
|
+
const version = coerce(text);
|
|
7
|
+
if (version === null || version.major < 1) return null;
|
|
8
|
+
if (text !== `${version.major}` && text !== `${version.major}.${version.minor}`) return null;
|
|
9
|
+
return version;
|
|
10
|
+
}
|
|
11
|
+
function formatNodesApiLevel({ major, minor }) {
|
|
12
|
+
return `${major}.${minor}`;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { formatNodesApiLevel, parseNodesApiLevel };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=nodes-api-level.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes-api-level.mjs","names":[],"sources":["../src/nodes-api-level.ts"],"sourcesContent":["import { coerce, type SemVer } from 'semver';\n\n// A float is rejected, since an unquoted `3.10` in package.json is read as\n// the number `3.1`. The input must print back from its coerced version as\n// `<major>` or `<major>.<minor>`.\nexport function parseNodesApiLevel(value: unknown): SemVer | null {\n\tconst text = typeof value === 'number' && Number.isInteger(value) ? String(value) : value;\n\tif (typeof text !== 'string') return null;\n\n\tconst version = coerce(text);\n\tif (version === null || version.major < 1) return null;\n\tif (text !== `${version.major}` && text !== `${version.major}.${version.minor}`) return null;\n\n\treturn version;\n}\n\nexport function formatNodesApiLevel({ major, minor }: SemVer): string {\n\treturn `${major}.${minor}`;\n}\n"],"mappings":";;AAKA,SAAgB,mBAAmB,OAA+B;CACjE,MAAM,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,KAAK,IAAI,OAAO,KAAK,IAAI;CACpF,IAAI,OAAO,SAAS,UAAU,OAAO;CAErC,MAAM,UAAU,OAAO,IAAI;CAC3B,IAAI,YAAY,QAAQ,QAAQ,QAAQ,GAAG,OAAO;CAClD,IAAI,SAAS,GAAG,QAAQ,WAAW,SAAS,GAAG,QAAQ,MAAM,GAAG,QAAQ,SAAS,OAAO;CAExF,OAAO;AACR;AAEA,SAAgB,oBAAoB,EAAE,OAAO,SAAyB;CACrE,OAAO,GAAG,MAAM,GAAG;AACpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/run-serially.ts
|
|
3
|
+
/** Serialize work per key. A failed operation does not block later work. */
|
|
4
|
+
async function runSerially(pending, key, work) {
|
|
5
|
+
const run = (pending.get(key) ?? Promise.resolve()).catch(() => {}).then(work);
|
|
6
|
+
pending.set(key, run);
|
|
7
|
+
try {
|
|
8
|
+
return await run;
|
|
9
|
+
} finally {
|
|
10
|
+
if (pending.get(key) === run) pending.delete(key);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.runSerially = runSerially;
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=run-serially.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-serially.cjs","names":[],"sources":["../src/run-serially.ts"],"sourcesContent":["/** Serialize work per key. A failed operation does not block later work. */\nexport async function runSerially<T>(\n\tpending: Map<string, Promise<unknown>>,\n\tkey: string,\n\twork: () => Promise<T>,\n): Promise<T> {\n\tconst previous = pending.get(key) ?? Promise.resolve();\n\tconst run = previous.catch(() => {}).then(work);\n\tpending.set(key, run);\n\ttry {\n\t\treturn await run;\n\t} finally {\n\t\tif (pending.get(key) === run) pending.delete(key);\n\t}\n}\n"],"mappings":";;;AACA,eAAsB,YACrB,SACA,KACA,MACa;CAEb,MAAM,OADW,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAA,CAChC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAC9C,QAAQ,IAAI,KAAK,GAAG;CACpB,IAAI;EACH,OAAO,MAAM;CACd,UAAU;EACT,IAAI,QAAQ,IAAI,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG;CACjD;AACD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/run-serially.ts
|
|
2
|
+
/** Serialize work per key. A failed operation does not block later work. */
|
|
3
|
+
async function runSerially(pending, key, work) {
|
|
4
|
+
const run = (pending.get(key) ?? Promise.resolve()).catch(() => {}).then(work);
|
|
5
|
+
pending.set(key, run);
|
|
6
|
+
try {
|
|
7
|
+
return await run;
|
|
8
|
+
} finally {
|
|
9
|
+
if (pending.get(key) === run) pending.delete(key);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { runSerially };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=run-serially.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-serially.mjs","names":[],"sources":["../src/run-serially.ts"],"sourcesContent":["/** Serialize work per key. A failed operation does not block later work. */\nexport async function runSerially<T>(\n\tpending: Map<string, Promise<unknown>>,\n\tkey: string,\n\twork: () => Promise<T>,\n): Promise<T> {\n\tconst previous = pending.get(key) ?? Promise.resolve();\n\tconst run = previous.catch(() => {}).then(work);\n\tpending.set(key, run);\n\ttry {\n\t\treturn await run;\n\t} finally {\n\t\tif (pending.get(key) === run) pending.delete(key);\n\t}\n}\n"],"mappings":";;AACA,eAAsB,YACrB,SACA,KACA,MACa;CAEb,MAAM,OADW,QAAQ,IAAI,GAAG,KAAK,QAAQ,QAAQ,EAAA,CAChC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI;CAC9C,QAAQ,IAAI,KAAK,GAAG;CACpB,IAAI;EACH,OAAO,MAAM;CACd,UAAU;EACT,IAAI,QAAQ,IAAI,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG;CACjD;AACD"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n8n/utils",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.49.1",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"LICENSE_EE.md",
|
|
8
|
+
"LICENSE.md"
|
|
9
9
|
],
|
|
10
10
|
"exports": {
|
|
11
11
|
"./dist/*": {
|
|
@@ -27,19 +27,21 @@
|
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@n8n/constants": "0.
|
|
31
|
-
"nanoid": "3.3.18"
|
|
30
|
+
"@n8n/constants": "0.40.1",
|
|
31
|
+
"nanoid": "3.3.18",
|
|
32
|
+
"semver": "7.7.3"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"@n8n/eslint-config": "0.0.1",
|
|
35
36
|
"@n8n/typescript-config": "1.12.0",
|
|
36
|
-
"@n8n/vitest-config": "1.
|
|
37
|
+
"@n8n/vitest-config": "1.23.0",
|
|
37
38
|
"@testing-library/jest-dom": "^6.6.3",
|
|
39
|
+
"@types/semver": "^7.7.0",
|
|
38
40
|
"fast-check": "^3.23.2",
|
|
39
41
|
"tsdown": "^0.22.8",
|
|
40
42
|
"typescript": "7.0.2",
|
|
41
43
|
"vite": "^8.0.2",
|
|
42
|
-
"vitest": "
|
|
44
|
+
"vitest": "5.0.1"
|
|
43
45
|
},
|
|
44
46
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
45
47
|
"homepage": "https://n8n.io",
|