@n8n/utils 1.36.0 → 1.37.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/dist/create-event-queue.cjs +3 -0
- package/dist/create-event-queue.d.cts +2 -0
- package/dist/create-event-queue.d.mts +2 -0
- package/dist/create-event-queue.mjs +3 -0
- package/dist/{event-queue2.cjs → create-event-queue2.cjs} +2 -2
- package/dist/create-event-queue2.cjs.map +1 -0
- package/dist/{event-queue2.d.cts → create-event-queue2.d.cts} +2 -2
- package/dist/{event-queue2.d.mts → create-event-queue2.d.mts} +2 -2
- package/dist/{event-queue2.mjs → create-event-queue2.mjs} +2 -2
- package/dist/create-event-queue2.mjs.map +1 -0
- package/dist/files/is-windows-file-path.cjs +3 -0
- package/dist/files/is-windows-file-path.d.cts +2 -0
- package/dist/files/is-windows-file-path.d.mts +2 -0
- package/dist/files/is-windows-file-path.mjs +3 -0
- package/dist/files/sanitize-filename.cjs +3 -0
- package/dist/files/sanitize-filename.d.cts +2 -0
- package/dist/files/sanitize-filename.d.mts +2 -0
- package/dist/files/sanitize-filename.mjs +3 -0
- package/dist/format-pem-block.cjs +3 -0
- package/dist/format-pem-block.d.cts +2 -0
- package/dist/format-pem-block.d.mts +2 -0
- package/dist/format-pem-block.mjs +3 -0
- package/dist/format-pem-block2.cjs +47 -0
- package/dist/format-pem-block2.cjs.map +1 -0
- package/dist/format-pem-block2.d.cts +5 -0
- package/dist/format-pem-block2.d.mts +5 -0
- package/dist/format-pem-block2.mjs +41 -0
- package/dist/format-pem-block2.mjs.map +1 -0
- package/dist/generate-nano-id.cjs +3 -0
- package/dist/generate-nano-id.d.cts +2 -0
- package/dist/generate-nano-id.d.mts +2 -0
- package/dist/generate-nano-id.mjs +3 -0
- package/dist/{workflowId2.cjs → generate-nano-id2.cjs} +2 -2
- package/dist/generate-nano-id2.cjs.map +1 -0
- package/dist/{workflowId2.d.cts → generate-nano-id2.d.cts} +2 -2
- package/dist/{workflowId2.d.mts → generate-nano-id2.d.mts} +2 -2
- package/dist/{workflowId2.mjs → generate-nano-id2.mjs} +2 -2
- package/dist/generate-nano-id2.mjs.map +1 -0
- package/dist/get-jwt-expiry.cjs +3 -0
- package/dist/get-jwt-expiry.d.cts +2 -0
- package/dist/get-jwt-expiry.d.mts +2 -0
- package/dist/get-jwt-expiry.mjs +3 -0
- package/dist/{jwt2.cjs → get-jwt-expiry2.cjs} +2 -2
- package/dist/get-jwt-expiry2.cjs.map +1 -0
- package/dist/{jwt2.d.cts → get-jwt-expiry2.d.cts} +2 -2
- package/dist/{jwt2.d.mts → get-jwt-expiry2.d.mts} +2 -2
- package/dist/{jwt2.mjs → get-jwt-expiry2.mjs} +2 -2
- package/dist/get-jwt-expiry2.mjs.map +1 -0
- package/dist/index.cjs +23 -21
- package/dist/index.d.cts +12 -11
- package/dist/index.d.mts +12 -11
- package/dist/index.mjs +12 -11
- package/dist/is-record.cjs +3 -0
- package/dist/is-record.d.cts +2 -0
- package/dist/is-record.d.mts +2 -0
- package/dist/is-record.mjs +3 -0
- package/dist/{validation2.cjs → is-record2.cjs} +2 -2
- package/dist/is-record2.cjs.map +1 -0
- package/dist/{validation2.d.cts → is-record2.d.cts} +2 -2
- package/dist/{validation2.d.mts → is-record2.d.mts} +2 -2
- package/dist/{validation2.mjs → is-record2.mjs} +2 -2
- package/dist/is-record2.mjs.map +1 -0
- package/dist/{path.cjs → is-windows-file-path.cjs} +2 -2
- package/dist/is-windows-file-path.cjs.map +1 -0
- package/dist/{path.d.cts → is-windows-file-path.d.cts} +2 -2
- package/dist/{path.d.mts → is-windows-file-path.d.mts} +2 -2
- package/dist/{path.mjs → is-windows-file-path.mjs} +2 -2
- package/dist/is-windows-file-path.mjs.map +1 -0
- package/dist/number/smart-decimal.cjs +3 -0
- package/dist/number/smart-decimal.d.cts +2 -0
- package/dist/number/smart-decimal.d.mts +2 -0
- package/dist/number/smart-decimal.mjs +3 -0
- package/dist/{reRankSearchResults.cjs → re-rank-search-results.cjs} +2 -2
- package/dist/re-rank-search-results.cjs.map +1 -0
- package/dist/{reRankSearchResults.d.cts → re-rank-search-results.d.cts} +2 -2
- package/dist/{reRankSearchResults.d.mts → re-rank-search-results.d.mts} +2 -2
- package/dist/{reRankSearchResults.mjs → re-rank-search-results.mjs} +2 -2
- package/dist/re-rank-search-results.mjs.map +1 -0
- package/dist/{sanitize.cjs → sanitize-filename.cjs} +2 -2
- package/dist/sanitize-filename.cjs.map +1 -0
- package/dist/{sanitize.d.cts → sanitize-filename.d.cts} +2 -2
- package/dist/{sanitize.d.mts → sanitize-filename.d.mts} +2 -2
- package/dist/{sanitize.mjs → sanitize-filename.mjs} +2 -2
- package/dist/sanitize-filename.mjs.map +1 -0
- package/dist/search/re-rank-search-results.cjs +3 -0
- package/dist/search/re-rank-search-results.d.cts +2 -0
- package/dist/search/re-rank-search-results.d.mts +2 -0
- package/dist/search/re-rank-search-results.mjs +3 -0
- package/dist/search/sublime-search.cjs +4 -0
- package/dist/search/{sublimeSearch.d.cts → sublime-search.d.cts} +1 -1
- package/dist/search/{sublimeSearch.d.mts → sublime-search.d.mts} +1 -1
- package/dist/search/{sublimeSearch.mjs → sublime-search.mjs} +1 -1
- package/dist/{smartDecimal.cjs → smart-decimal.cjs} +2 -2
- package/dist/smart-decimal.cjs.map +1 -0
- package/dist/{smartDecimal.d.cts → smart-decimal.d.cts} +2 -2
- package/dist/{smartDecimal.d.mts → smart-decimal.d.mts} +2 -2
- package/dist/{smartDecimal.mjs → smart-decimal.mjs} +2 -2
- package/dist/smart-decimal.mjs.map +1 -0
- package/dist/sort/sort-by-property.cjs +3 -0
- package/dist/sort/sort-by-property.d.cts +2 -0
- package/dist/sort/sort-by-property.d.mts +2 -0
- package/dist/sort/sort-by-property.mjs +3 -0
- package/dist/{sortByProperty.cjs → sort-by-property.cjs} +2 -2
- package/dist/sort-by-property.cjs.map +1 -0
- package/dist/{sortByProperty.d.cts → sort-by-property.d.cts} +2 -2
- package/dist/{sortByProperty.d.mts → sort-by-property.d.mts} +2 -2
- package/dist/{sortByProperty.mjs → sort-by-property.mjs} +2 -2
- package/dist/sort-by-property.mjs.map +1 -0
- package/dist/{sublimeSearch.cjs → sublime-search.cjs} +2 -2
- package/dist/sublime-search.cjs.map +1 -0
- package/dist/{sublimeSearch.d.cts → sublime-search.d.cts} +2 -2
- package/dist/{sublimeSearch.d.mts → sublime-search.d.mts} +2 -2
- package/dist/{sublimeSearch.mjs → sublime-search.mjs} +2 -2
- package/dist/sublime-search.mjs.map +1 -0
- package/package.json +8 -8
- package/dist/event-queue.cjs +0 -3
- package/dist/event-queue.d.cts +0 -2
- package/dist/event-queue.d.mts +0 -2
- package/dist/event-queue.mjs +0 -3
- package/dist/event-queue2.cjs.map +0 -1
- package/dist/event-queue2.mjs.map +0 -1
- package/dist/files/path.cjs +0 -3
- package/dist/files/path.d.cts +0 -2
- package/dist/files/path.d.mts +0 -2
- package/dist/files/path.mjs +0 -3
- package/dist/files/sanitize.cjs +0 -3
- package/dist/files/sanitize.d.cts +0 -2
- package/dist/files/sanitize.d.mts +0 -2
- package/dist/files/sanitize.mjs +0 -3
- package/dist/jwt.cjs +0 -3
- package/dist/jwt.d.cts +0 -2
- package/dist/jwt.d.mts +0 -2
- package/dist/jwt.mjs +0 -3
- package/dist/jwt2.cjs.map +0 -1
- package/dist/jwt2.mjs.map +0 -1
- package/dist/number/smartDecimal.cjs +0 -3
- package/dist/number/smartDecimal.d.cts +0 -2
- package/dist/number/smartDecimal.d.mts +0 -2
- package/dist/number/smartDecimal.mjs +0 -3
- package/dist/path.cjs.map +0 -1
- package/dist/path.mjs.map +0 -1
- package/dist/reRankSearchResults.cjs.map +0 -1
- package/dist/reRankSearchResults.mjs.map +0 -1
- package/dist/sanitize.cjs.map +0 -1
- package/dist/sanitize.mjs.map +0 -1
- package/dist/search/reRankSearchResults.cjs +0 -3
- package/dist/search/reRankSearchResults.d.cts +0 -2
- package/dist/search/reRankSearchResults.d.mts +0 -2
- package/dist/search/reRankSearchResults.mjs +0 -3
- package/dist/search/sublimeSearch.cjs +0 -4
- package/dist/smartDecimal.cjs.map +0 -1
- package/dist/smartDecimal.mjs.map +0 -1
- package/dist/sort/sortByProperty.cjs +0 -3
- package/dist/sort/sortByProperty.d.cts +0 -2
- package/dist/sort/sortByProperty.d.mts +0 -2
- package/dist/sort/sortByProperty.mjs +0 -3
- package/dist/sortByProperty.cjs.map +0 -1
- package/dist/sortByProperty.mjs.map +0 -1
- package/dist/sublimeSearch.cjs.map +0 -1
- package/dist/sublimeSearch.mjs.map +0 -1
- package/dist/validation.cjs +0 -3
- package/dist/validation.d.cts +0 -2
- package/dist/validation.d.mts +0 -2
- package/dist/validation.mjs +0 -3
- package/dist/validation2.cjs.map +0 -1
- package/dist/validation2.mjs.map +0 -1
- package/dist/workflowId.cjs +0 -3
- package/dist/workflowId.d.cts +0 -2
- package/dist/workflowId.d.mts +0 -2
- package/dist/workflowId.mjs +0 -3
- package/dist/workflowId2.cjs.map +0 -1
- package/dist/workflowId2.mjs.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/
|
|
2
|
+
//#region src/is-record.ts
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
5
|
}
|
|
@@ -11,4 +11,4 @@ Object.defineProperty(exports, 'isRecord', {
|
|
|
11
11
|
return isRecord;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
//# sourceMappingURL=
|
|
14
|
+
//# sourceMappingURL=is-record2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-record2.cjs","names":[],"sources":["../src/is-record.ts"],"sourcesContent":["export function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"mappings":";;AAAA,SAAgB,SAAS,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/is-record.d.ts
|
|
2
2
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { isRecord as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=is-record2.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/is-record.d.ts
|
|
2
2
|
declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { isRecord as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=is-record2.d.mts.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/is-record.ts
|
|
2
2
|
function isRecord(value) {
|
|
3
3
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { isRecord as t };
|
|
8
|
-
//# sourceMappingURL=
|
|
8
|
+
//# sourceMappingURL=is-record2.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-record2.mjs","names":[],"sources":["../src/is-record.ts"],"sourcesContent":["export function isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n"],"mappings":";AAAA,SAAgB,SAAS,OAAkD;AAC1E,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/files/path.ts
|
|
2
|
+
//#region src/files/is-windows-file-path.ts
|
|
3
3
|
/**
|
|
4
4
|
* Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
|
|
5
5
|
*/
|
|
@@ -14,4 +14,4 @@ Object.defineProperty(exports, 'isWindowsFilePath', {
|
|
|
14
14
|
return isWindowsFilePath;
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
|
-
//# sourceMappingURL=path.cjs.map
|
|
17
|
+
//# sourceMappingURL=is-windows-file-path.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-windows-file-path.cjs","names":[],"sources":["../src/files/is-windows-file-path.ts"],"sourcesContent":["/**\n * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\\\'\n */\nexport function isWindowsFilePath(str: string) {\n\treturn /^[a-zA-Z]:[\\\\/]/.test(str);\n}\n"],"mappings":";;;;;AAGA,SAAgB,kBAAkB,KAAa;AAC9C,QAAO,kBAAkB,KAAK,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/files/path.d.ts
|
|
1
|
+
//#region src/files/is-windows-file-path.d.ts
|
|
2
2
|
declare function isWindowsFilePath(str: string): boolean;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { isWindowsFilePath as t };
|
|
5
|
-
//# sourceMappingURL=path.d.cts.map
|
|
5
|
+
//# sourceMappingURL=is-windows-file-path.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/files/path.d.ts
|
|
1
|
+
//#region src/files/is-windows-file-path.d.ts
|
|
2
2
|
declare function isWindowsFilePath(str: string): boolean;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { isWindowsFilePath as t };
|
|
5
|
-
//# sourceMappingURL=path.d.mts.map
|
|
5
|
+
//# sourceMappingURL=is-windows-file-path.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/files/path.ts
|
|
1
|
+
//#region src/files/is-windows-file-path.ts
|
|
2
2
|
/**
|
|
3
3
|
* Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
|
|
4
4
|
*/
|
|
@@ -8,4 +8,4 @@ function isWindowsFilePath(str) {
|
|
|
8
8
|
|
|
9
9
|
//#endregion
|
|
10
10
|
export { isWindowsFilePath as t };
|
|
11
|
-
//# sourceMappingURL=path.mjs.map
|
|
11
|
+
//# sourceMappingURL=is-windows-file-path.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"is-windows-file-path.mjs","names":[],"sources":["../src/files/is-windows-file-path.ts"],"sourcesContent":["/**\n * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\\\'\n */\nexport function isWindowsFilePath(str: string) {\n\treturn /^[a-zA-Z]:[\\\\/]/.test(str);\n}\n"],"mappings":";;;;AAGA,SAAgB,kBAAkB,KAAa;AAC9C,QAAO,kBAAkB,KAAK,IAAI"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/search/
|
|
2
|
+
//#region src/search/re-rank-search-results.ts
|
|
3
3
|
function reRankSearchResults(searchResults, additionalFactors) {
|
|
4
4
|
return searchResults.map(({ score, item }) => {
|
|
5
5
|
return {
|
|
@@ -22,4 +22,4 @@ Object.defineProperty(exports, 'reRankSearchResults', {
|
|
|
22
22
|
return reRankSearchResults;
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
|
-
//# sourceMappingURL=
|
|
25
|
+
//# sourceMappingURL=re-rank-search-results.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"re-rank-search-results.cjs","names":[],"sources":["../src/search/re-rank-search-results.ts"],"sourcesContent":["export function reRankSearchResults<T extends { key: string }>(\n\tsearchResults: Array<{ score: number; item: T }>,\n\tadditionalFactors: Record<string, Record<string, number>>,\n): Array<{ score: number; item: T }> {\n\treturn searchResults\n\t\t.map(({ score, item }) => {\n\t\t\t// For each additional factor, we check if it exists for the item and type,\n\t\t\t// and if so, we add the score to the item's score.\n\t\t\tconst additionalScore = Object.entries(additionalFactors).reduce((acc, [_, factorScores]) => {\n\t\t\t\tconst factorScore = factorScores[item.key];\n\t\t\t\tif (factorScore) {\n\t\t\t\t\treturn acc + factorScore;\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t}, 0);\n\n\t\t\treturn {\n\t\t\t\tscore: score + additionalScore,\n\t\t\t\titem,\n\t\t\t};\n\t\t})\n\t\t.sort((a, b) => {\n\t\t\treturn b.score - a.score;\n\t\t});\n}\n"],"mappings":";;AAAA,SAAgB,oBACf,eACA,mBACoC;AACpC,QAAO,cACL,KAAK,EAAE,OAAO,WAAW;AAYzB,SAAO;GACN,OAAO,QAVgB,OAAO,QAAQ,kBAAkB,CAAC,QAAQ,KAAK,CAAC,GAAG,kBAAkB;IAC5F,MAAM,cAAc,aAAa,KAAK;AACtC,QAAI,YACH,QAAO,MAAM;AAGd,WAAO;MACL,EAAE;GAIJ;GACA;GACA,CACD,MAAM,GAAG,MAAM;AACf,SAAO,EAAE,QAAQ,EAAE;GAClB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/re-rank-search-results.d.ts
|
|
2
2
|
declare function reRankSearchResults<T extends {
|
|
3
3
|
key: string;
|
|
4
4
|
}>(searchResults: Array<{
|
|
@@ -10,4 +10,4 @@ declare function reRankSearchResults<T extends {
|
|
|
10
10
|
}>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { reRankSearchResults as t };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=re-rank-search-results.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/re-rank-search-results.d.ts
|
|
2
2
|
declare function reRankSearchResults<T extends {
|
|
3
3
|
key: string;
|
|
4
4
|
}>(searchResults: Array<{
|
|
@@ -10,4 +10,4 @@ declare function reRankSearchResults<T extends {
|
|
|
10
10
|
}>;
|
|
11
11
|
//#endregion
|
|
12
12
|
export { reRankSearchResults as t };
|
|
13
|
-
//# sourceMappingURL=
|
|
13
|
+
//# sourceMappingURL=re-rank-search-results.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/re-rank-search-results.ts
|
|
2
2
|
function reRankSearchResults(searchResults, additionalFactors) {
|
|
3
3
|
return searchResults.map(({ score, item }) => {
|
|
4
4
|
return {
|
|
@@ -16,4 +16,4 @@ function reRankSearchResults(searchResults, additionalFactors) {
|
|
|
16
16
|
|
|
17
17
|
//#endregion
|
|
18
18
|
export { reRankSearchResults as t };
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=re-rank-search-results.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"re-rank-search-results.mjs","names":[],"sources":["../src/search/re-rank-search-results.ts"],"sourcesContent":["export function reRankSearchResults<T extends { key: string }>(\n\tsearchResults: Array<{ score: number; item: T }>,\n\tadditionalFactors: Record<string, Record<string, number>>,\n): Array<{ score: number; item: T }> {\n\treturn searchResults\n\t\t.map(({ score, item }) => {\n\t\t\t// For each additional factor, we check if it exists for the item and type,\n\t\t\t// and if so, we add the score to the item's score.\n\t\t\tconst additionalScore = Object.entries(additionalFactors).reduce((acc, [_, factorScores]) => {\n\t\t\t\tconst factorScore = factorScores[item.key];\n\t\t\t\tif (factorScore) {\n\t\t\t\t\treturn acc + factorScore;\n\t\t\t\t}\n\n\t\t\t\treturn acc;\n\t\t\t}, 0);\n\n\t\t\treturn {\n\t\t\t\tscore: score + additionalScore,\n\t\t\t\titem,\n\t\t\t};\n\t\t})\n\t\t.sort((a, b) => {\n\t\t\treturn b.score - a.score;\n\t\t});\n}\n"],"mappings":";AAAA,SAAgB,oBACf,eACA,mBACoC;AACpC,QAAO,cACL,KAAK,EAAE,OAAO,WAAW;AAYzB,SAAO;GACN,OAAO,QAVgB,OAAO,QAAQ,kBAAkB,CAAC,QAAQ,KAAK,CAAC,GAAG,kBAAkB;IAC5F,MAAM,cAAc,aAAa,KAAK;AACtC,QAAI,YACH,QAAO,MAAM;AAGd,WAAO;MACL,EAAE;GAIJ;GACA;GACA,CACD,MAAM,GAAG,MAAM;AACf,SAAO,EAAE,QAAQ,EAAE;GAClB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/files/sanitize.ts
|
|
2
|
+
//#region src/files/sanitize-filename.ts
|
|
3
3
|
const INVALID_CHARS_REGEX = /[<>:"/\\|?*\u0000-\u001F\u007F-\u009F]/g;
|
|
4
4
|
const ZERO_WIDTH_CHARS_REGEX = /[\u200B-\u200D\u2060\uFEFF]/g;
|
|
5
5
|
const UNICODE_SPACES_REGEX = /[\u00A0\u2000-\u200A]/g;
|
|
@@ -64,4 +64,4 @@ Object.defineProperty(exports, 'sanitizeFilename', {
|
|
|
64
64
|
return sanitizeFilename;
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
|
-
//# sourceMappingURL=sanitize.cjs.map
|
|
67
|
+
//# sourceMappingURL=sanitize-filename.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize-filename.cjs","names":[],"sources":["../src/files/sanitize-filename.ts"],"sourcesContent":["// Constants definition\n/* eslint-disable no-control-regex */\nconst INVALID_CHARS_REGEX = /[<>:\"/\\\\|?*\\u0000-\\u001F\\u007F-\\u009F]/g;\nconst ZERO_WIDTH_CHARS_REGEX = /[\\u200B-\\u200D\\u2060\\uFEFF]/g;\nconst UNICODE_SPACES_REGEX = /[\\u00A0\\u2000-\\u200A]/g;\nconst LEADING_TRAILING_DOTS_SPACES_REGEX = /^[\\s.]+|[\\s.]+$/g;\n/* eslint-enable no-control-regex */\n\nconst WINDOWS_RESERVED_NAMES = new Set([\n\t'CON',\n\t'PRN',\n\t'AUX',\n\t'NUL',\n\t'COM1',\n\t'COM2',\n\t'COM3',\n\t'COM4',\n\t'COM5',\n\t'COM6',\n\t'COM7',\n\t'COM8',\n\t'COM9',\n\t'LPT1',\n\t'LPT2',\n\t'LPT3',\n\t'LPT4',\n\t'LPT5',\n\t'LPT6',\n\t'LPT7',\n\t'LPT8',\n\t'LPT9',\n]);\n\nconst DEFAULT_FALLBACK_NAME = 'untitled';\nconst MAX_FILENAME_LENGTH = 200;\n\n/**\n * Sanitizes a filename to be compatible with Mac, Linux, and Windows file systems\n *\n * Main features:\n * - Replace invalid characters (e.g. \":\" in hello:world)\n * - Handle Windows reserved names\n * - Limit filename length\n * - Normalize Unicode characters\n *\n * @param filename - The filename to sanitize (without extension)\n * @param maxLength - Maximum filename length (default: 200)\n * @returns A sanitized filename (without extension)\n *\n * @example\n * sanitizeFilename('hello:world') // returns 'hello_world'\n * sanitizeFilename('CON') // returns '_CON'\n * sanitizeFilename('') // returns 'untitled'\n */\nexport const sanitizeFilename = (\n\tfilename: string,\n\tmaxLength: number = MAX_FILENAME_LENGTH,\n): string => {\n\t// Input validation\n\tif (!filename) {\n\t\treturn DEFAULT_FALLBACK_NAME;\n\t}\n\n\tlet baseName = filename\n\t\t.trim()\n\t\t.replace(INVALID_CHARS_REGEX, '_')\n\t\t.replace(ZERO_WIDTH_CHARS_REGEX, '')\n\t\t.replace(UNICODE_SPACES_REGEX, ' ')\n\t\t.replace(LEADING_TRAILING_DOTS_SPACES_REGEX, '');\n\n\t// Handle empty or invalid filenames after cleaning\n\tif (!baseName) {\n\t\tbaseName = DEFAULT_FALLBACK_NAME;\n\t}\n\n\t// Handle Windows reserved names\n\tif (WINDOWS_RESERVED_NAMES.has(baseName.toUpperCase())) {\n\t\tbaseName = `_${baseName}`;\n\t}\n\n\t// Truncate if too long\n\tif (baseName.length > maxLength) {\n\t\tbaseName = baseName.slice(0, maxLength);\n\t}\n\n\treturn baseName;\n};\n"],"mappings":";;AAEA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAC7B,MAAM,qCAAqC;AAG3C,MAAM,yBAAyB,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;AAEF,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;AAoB5B,MAAa,oBACZ,UACA,YAAoB,wBACR;AAEZ,KAAI,CAAC,SACJ,QAAO;CAGR,IAAI,WAAW,SACb,MAAM,CACN,QAAQ,qBAAqB,IAAI,CACjC,QAAQ,wBAAwB,GAAG,CACnC,QAAQ,sBAAsB,IAAI,CAClC,QAAQ,oCAAoC,GAAG;AAGjD,KAAI,CAAC,SACJ,YAAW;AAIZ,KAAI,uBAAuB,IAAI,SAAS,aAAa,CAAC,CACrD,YAAW,IAAI;AAIhB,KAAI,SAAS,SAAS,UACrB,YAAW,SAAS,MAAM,GAAG,UAAU;AAGxC,QAAO"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/files/sanitize.d.ts
|
|
1
|
+
//#region src/files/sanitize-filename.d.ts
|
|
2
2
|
declare const sanitizeFilename: (filename: string, maxLength?: number) => string;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { sanitizeFilename as t };
|
|
5
|
-
//# sourceMappingURL=sanitize.d.cts.map
|
|
5
|
+
//# sourceMappingURL=sanitize-filename.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/files/sanitize.d.ts
|
|
1
|
+
//#region src/files/sanitize-filename.d.ts
|
|
2
2
|
declare const sanitizeFilename: (filename: string, maxLength?: number) => string;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { sanitizeFilename as t };
|
|
5
|
-
//# sourceMappingURL=sanitize.d.mts.map
|
|
5
|
+
//# sourceMappingURL=sanitize-filename.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/files/sanitize.ts
|
|
1
|
+
//#region src/files/sanitize-filename.ts
|
|
2
2
|
const INVALID_CHARS_REGEX = /[<>:"/\\|?*\u0000-\u001F\u007F-\u009F]/g;
|
|
3
3
|
const ZERO_WIDTH_CHARS_REGEX = /[\u200B-\u200D\u2060\uFEFF]/g;
|
|
4
4
|
const UNICODE_SPACES_REGEX = /[\u00A0\u2000-\u200A]/g;
|
|
@@ -58,4 +58,4 @@ const sanitizeFilename = (filename, maxLength = MAX_FILENAME_LENGTH) => {
|
|
|
58
58
|
|
|
59
59
|
//#endregion
|
|
60
60
|
export { sanitizeFilename as t };
|
|
61
|
-
//# sourceMappingURL=sanitize.mjs.map
|
|
61
|
+
//# sourceMappingURL=sanitize-filename.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sanitize-filename.mjs","names":[],"sources":["../src/files/sanitize-filename.ts"],"sourcesContent":["// Constants definition\n/* eslint-disable no-control-regex */\nconst INVALID_CHARS_REGEX = /[<>:\"/\\\\|?*\\u0000-\\u001F\\u007F-\\u009F]/g;\nconst ZERO_WIDTH_CHARS_REGEX = /[\\u200B-\\u200D\\u2060\\uFEFF]/g;\nconst UNICODE_SPACES_REGEX = /[\\u00A0\\u2000-\\u200A]/g;\nconst LEADING_TRAILING_DOTS_SPACES_REGEX = /^[\\s.]+|[\\s.]+$/g;\n/* eslint-enable no-control-regex */\n\nconst WINDOWS_RESERVED_NAMES = new Set([\n\t'CON',\n\t'PRN',\n\t'AUX',\n\t'NUL',\n\t'COM1',\n\t'COM2',\n\t'COM3',\n\t'COM4',\n\t'COM5',\n\t'COM6',\n\t'COM7',\n\t'COM8',\n\t'COM9',\n\t'LPT1',\n\t'LPT2',\n\t'LPT3',\n\t'LPT4',\n\t'LPT5',\n\t'LPT6',\n\t'LPT7',\n\t'LPT8',\n\t'LPT9',\n]);\n\nconst DEFAULT_FALLBACK_NAME = 'untitled';\nconst MAX_FILENAME_LENGTH = 200;\n\n/**\n * Sanitizes a filename to be compatible with Mac, Linux, and Windows file systems\n *\n * Main features:\n * - Replace invalid characters (e.g. \":\" in hello:world)\n * - Handle Windows reserved names\n * - Limit filename length\n * - Normalize Unicode characters\n *\n * @param filename - The filename to sanitize (without extension)\n * @param maxLength - Maximum filename length (default: 200)\n * @returns A sanitized filename (without extension)\n *\n * @example\n * sanitizeFilename('hello:world') // returns 'hello_world'\n * sanitizeFilename('CON') // returns '_CON'\n * sanitizeFilename('') // returns 'untitled'\n */\nexport const sanitizeFilename = (\n\tfilename: string,\n\tmaxLength: number = MAX_FILENAME_LENGTH,\n): string => {\n\t// Input validation\n\tif (!filename) {\n\t\treturn DEFAULT_FALLBACK_NAME;\n\t}\n\n\tlet baseName = filename\n\t\t.trim()\n\t\t.replace(INVALID_CHARS_REGEX, '_')\n\t\t.replace(ZERO_WIDTH_CHARS_REGEX, '')\n\t\t.replace(UNICODE_SPACES_REGEX, ' ')\n\t\t.replace(LEADING_TRAILING_DOTS_SPACES_REGEX, '');\n\n\t// Handle empty or invalid filenames after cleaning\n\tif (!baseName) {\n\t\tbaseName = DEFAULT_FALLBACK_NAME;\n\t}\n\n\t// Handle Windows reserved names\n\tif (WINDOWS_RESERVED_NAMES.has(baseName.toUpperCase())) {\n\t\tbaseName = `_${baseName}`;\n\t}\n\n\t// Truncate if too long\n\tif (baseName.length > maxLength) {\n\t\tbaseName = baseName.slice(0, maxLength);\n\t}\n\n\treturn baseName;\n};\n"],"mappings":";AAEA,MAAM,sBAAsB;AAC5B,MAAM,yBAAyB;AAC/B,MAAM,uBAAuB;AAC7B,MAAM,qCAAqC;AAG3C,MAAM,yBAAyB,IAAI,IAAI;CACtC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA,CAAC;AAEF,MAAM,wBAAwB;AAC9B,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;AAoB5B,MAAa,oBACZ,UACA,YAAoB,wBACR;AAEZ,KAAI,CAAC,SACJ,QAAO;CAGR,IAAI,WAAW,SACb,MAAM,CACN,QAAQ,qBAAqB,IAAI,CACjC,QAAQ,wBAAwB,GAAG,CACnC,QAAQ,sBAAsB,IAAI,CAClC,QAAQ,oCAAoC,GAAG;AAGjD,KAAI,CAAC,SACJ,YAAW;AAIZ,KAAI,uBAAuB,IAAI,SAAS,aAAa,CAAC,CACrD,YAAW,IAAI;AAIhB,KAAI,SAAS,SAAS,UACrB,YAAW,SAAS,MAAM,GAAG,UAAU;AAGxC,QAAO"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as sublimeSearch, t as DEFAULT_KEYS } from "../
|
|
1
|
+
import { n as sublimeSearch, t as DEFAULT_KEYS } from "../sublime-search.cjs";
|
|
2
2
|
export { DEFAULT_KEYS, sublimeSearch };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as sublimeSearch, t as DEFAULT_KEYS } from "../
|
|
1
|
+
import { n as sublimeSearch, t as DEFAULT_KEYS } from "../sublime-search.mjs";
|
|
2
2
|
export { DEFAULT_KEYS, sublimeSearch };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/number/
|
|
2
|
+
//#region src/number/smart-decimal.ts
|
|
3
3
|
const smartDecimal = (value, decimals = 2) => {
|
|
4
4
|
if (Number.isInteger(value)) return value;
|
|
5
5
|
if (value.toString().split(".")[1].length <= decimals) return value;
|
|
@@ -13,4 +13,4 @@ Object.defineProperty(exports, 'smartDecimal', {
|
|
|
13
13
|
return smartDecimal;
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=smart-decimal.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-decimal.cjs","names":[],"sources":["../src/number/smart-decimal.ts"],"sourcesContent":["export const smartDecimal = (value: number, decimals = 2): number => {\n\t// Check if integer\n\tif (Number.isInteger(value)) {\n\t\treturn value;\n\t}\n\n\t// Check if it has only one decimal place\n\tif (value.toString().split('.')[1].length <= decimals) {\n\t\treturn value;\n\t}\n\n\treturn Number(value.toFixed(decimals));\n};\n"],"mappings":";;AAAA,MAAa,gBAAgB,OAAe,WAAW,MAAc;AAEpE,KAAI,OAAO,UAAU,MAAM,CAC1B,QAAO;AAIR,KAAI,MAAM,UAAU,CAAC,MAAM,IAAI,CAAC,GAAG,UAAU,SAC5C,QAAO;AAGR,QAAO,OAAO,MAAM,QAAQ,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/number/
|
|
1
|
+
//#region src/number/smart-decimal.d.ts
|
|
2
2
|
declare const smartDecimal: (value: number, decimals?: number) => number;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { smartDecimal as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=smart-decimal.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/number/
|
|
1
|
+
//#region src/number/smart-decimal.d.ts
|
|
2
2
|
declare const smartDecimal: (value: number, decimals?: number) => number;
|
|
3
3
|
//#endregion
|
|
4
4
|
export { smartDecimal as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=smart-decimal.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/number/
|
|
1
|
+
//#region src/number/smart-decimal.ts
|
|
2
2
|
const smartDecimal = (value, decimals = 2) => {
|
|
3
3
|
if (Number.isInteger(value)) return value;
|
|
4
4
|
if (value.toString().split(".")[1].length <= decimals) return value;
|
|
@@ -7,4 +7,4 @@ const smartDecimal = (value, decimals = 2) => {
|
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
9
9
|
export { smartDecimal as t };
|
|
10
|
-
//# sourceMappingURL=
|
|
10
|
+
//# sourceMappingURL=smart-decimal.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"smart-decimal.mjs","names":[],"sources":["../src/number/smart-decimal.ts"],"sourcesContent":["export const smartDecimal = (value: number, decimals = 2): number => {\n\t// Check if integer\n\tif (Number.isInteger(value)) {\n\t\treturn value;\n\t}\n\n\t// Check if it has only one decimal place\n\tif (value.toString().split('.')[1].length <= decimals) {\n\t\treturn value;\n\t}\n\n\treturn Number(value.toFixed(decimals));\n};\n"],"mappings":";AAAA,MAAa,gBAAgB,OAAe,WAAW,MAAc;AAEpE,KAAI,OAAO,UAAU,MAAM,CAC1B,QAAO;AAIR,KAAI,MAAM,UAAU,CAAC,MAAM,IAAI,CAAC,GAAG,UAAU,SAC5C,QAAO;AAGR,QAAO,OAAO,MAAM,QAAQ,SAAS,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/sort/
|
|
2
|
+
//#region src/sort/sort-by-property.ts
|
|
3
3
|
const sortByProperty = (property, arr, order = "asc") => arr.sort((a, b) => {
|
|
4
4
|
const result = String(a[property]).localeCompare(String(b[property]), void 0, {
|
|
5
5
|
numeric: true,
|
|
@@ -15,4 +15,4 @@ Object.defineProperty(exports, 'sortByProperty', {
|
|
|
15
15
|
return sortByProperty;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
//# sourceMappingURL=
|
|
18
|
+
//# sourceMappingURL=sort-by-property.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-property.cjs","names":[],"sources":["../src/sort/sort-by-property.ts"],"sourcesContent":["export const sortByProperty = <T>(\n\tproperty: keyof T,\n\tarr: T[],\n\torder: 'asc' | 'desc' = 'asc',\n): T[] =>\n\tarr.sort((a, b) => {\n\t\tconst result = String(a[property]).localeCompare(String(b[property]), undefined, {\n\t\t\tnumeric: true,\n\t\t\tsensitivity: 'base',\n\t\t});\n\t\treturn order === 'asc' ? result : -result;\n\t});\n"],"mappings":";;AAAA,MAAa,kBACZ,UACA,KACA,QAAwB,UAExB,IAAI,MAAM,GAAG,MAAM;CAClB,MAAM,SAAS,OAAO,EAAE,UAAU,CAAC,cAAc,OAAO,EAAE,UAAU,EAAE,QAAW;EAChF,SAAS;EACT,aAAa;EACb,CAAC;AACF,QAAO,UAAU,QAAQ,SAAS,CAAC;EAClC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/sort/
|
|
1
|
+
//#region src/sort/sort-by-property.d.ts
|
|
2
2
|
declare const sortByProperty: <T>(property: keyof T, arr: T[], order?: "asc" | "desc") => T[];
|
|
3
3
|
//#endregion
|
|
4
4
|
export { sortByProperty as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=sort-by-property.d.cts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//#region src/sort/
|
|
1
|
+
//#region src/sort/sort-by-property.d.ts
|
|
2
2
|
declare const sortByProperty: <T>(property: keyof T, arr: T[], order?: "asc" | "desc") => T[];
|
|
3
3
|
//#endregion
|
|
4
4
|
export { sortByProperty as t };
|
|
5
|
-
//# sourceMappingURL=
|
|
5
|
+
//# sourceMappingURL=sort-by-property.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/sort/
|
|
1
|
+
//#region src/sort/sort-by-property.ts
|
|
2
2
|
const sortByProperty = (property, arr, order = "asc") => arr.sort((a, b) => {
|
|
3
3
|
const result = String(a[property]).localeCompare(String(b[property]), void 0, {
|
|
4
4
|
numeric: true,
|
|
@@ -9,4 +9,4 @@ const sortByProperty = (property, arr, order = "asc") => arr.sort((a, b) => {
|
|
|
9
9
|
|
|
10
10
|
//#endregion
|
|
11
11
|
export { sortByProperty as t };
|
|
12
|
-
//# sourceMappingURL=
|
|
12
|
+
//# sourceMappingURL=sort-by-property.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sort-by-property.mjs","names":[],"sources":["../src/sort/sort-by-property.ts"],"sourcesContent":["export const sortByProperty = <T>(\n\tproperty: keyof T,\n\tarr: T[],\n\torder: 'asc' | 'desc' = 'asc',\n): T[] =>\n\tarr.sort((a, b) => {\n\t\tconst result = String(a[property]).localeCompare(String(b[property]), undefined, {\n\t\t\tnumeric: true,\n\t\t\tsensitivity: 'base',\n\t\t});\n\t\treturn order === 'asc' ? result : -result;\n\t});\n"],"mappings":";AAAA,MAAa,kBACZ,UACA,KACA,QAAwB,UAExB,IAAI,MAAM,GAAG,MAAM;CAClB,MAAM,SAAS,OAAO,EAAE,UAAU,CAAC,cAAc,OAAO,EAAE,UAAU,EAAE,QAAW;EAChF,SAAS;EACT,aAAa;EACb,CAAC;AACF,QAAO,UAAU,QAAQ,SAAS,CAAC;EAClC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
//#region src/search/
|
|
2
|
+
//#region src/search/sublime-search.ts
|
|
3
3
|
const SEQUENTIAL_BONUS = 60;
|
|
4
4
|
const SEPARATOR_BONUS = 38;
|
|
5
5
|
const CAMEL_BONUS = 30;
|
|
@@ -190,4 +190,4 @@ Object.defineProperty(exports, 'sublimeSearch', {
|
|
|
190
190
|
return sublimeSearch;
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
|
-
//# sourceMappingURL=
|
|
193
|
+
//# sourceMappingURL=sublime-search.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sublime-search.cjs","names":["bestRecursiveMatches: number[]","recursiveMatches: number[]","results: Array<{ score: number; item: T }>","itemMatchScore: number | undefined","result: { score: number; item: T }"],"sources":["../src/search/sublime-search.ts"],"sourcesContent":["/*\n * Constants and utility functions used for searching for node types in node creator component\n * based on https://github.com/forrestthewoods/lib_fts/blob/master/code/fts_fuzzy_match.js\n */\n\nconst SEQUENTIAL_BONUS = 60; // bonus for adjacent matches\nconst SEPARATOR_BONUS = 38; // bonus if match occurs after a separator\nconst CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower\nconst FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched\n\nconst LEADING_LETTER_PENALTY = -20; // penalty applied for every letter in str before the first match\nconst MAX_LEADING_LETTER_PENALTY = -200; // maximum penalty for leading letters\nconst UNMATCHED_LETTER_PENALTY = -2.5;\n\nexport const DEFAULT_KEYS = [\n\t{ key: 'properties.displayName', weight: 1.3 },\n\t{ key: 'properties.codex.alias', weight: 1 },\n];\n\n/**\n * Returns true if each character in pattern is found sequentially within target\n * @param {*} pattern string\n * @param {*} target string\n */\nfunction fuzzyMatchSimple(pattern: string, target: string): boolean {\n\tlet patternIdx = 0;\n\tlet strIdx = 0;\n\n\twhile (patternIdx < pattern.length && strIdx < target.length) {\n\t\tconst patternChar = pattern.charAt(patternIdx).toLowerCase();\n\t\tconst targetChar = target.charAt(strIdx).toLowerCase();\n\t\tif (patternChar === targetChar) {\n\t\t\tpatternIdx++;\n\t\t}\n\t\t++strIdx;\n\t}\n\n\treturn pattern.length !== 0 && target.length !== 0 && patternIdx === pattern.length;\n}\n\nfunction fuzzyMatchRecursive(\n\tpattern: string,\n\ttarget: string,\n\tpatternCurIndex: number,\n\ttargetCurrIndex: number,\n\ttargetMatches: null | number[],\n\tmatches: number[],\n\tmaxMatches: number,\n\tnextMatch: number,\n\trecursionCount: number,\n\trecursionLimit: number,\n): { matched: boolean; outScore: number } {\n\tlet outScore = 0;\n\n\t// Return if recursion limit is reached.\n\tif (++recursionCount >= recursionLimit) {\n\t\treturn { matched: false, outScore };\n\t}\n\n\t// Return if we reached ends of strings.\n\tif (patternCurIndex === pattern.length || targetCurrIndex === target.length) {\n\t\treturn { matched: false, outScore };\n\t}\n\n\t// Recursion params\n\tlet recursiveMatch = false;\n\tlet bestRecursiveMatches: number[] = [];\n\tlet bestRecursiveScore = 0;\n\n\t// Loop through pattern and str looking for a match.\n\tlet firstMatch = true;\n\twhile (patternCurIndex < pattern.length && targetCurrIndex < target.length) {\n\t\t// Match found.\n\t\tif (pattern[patternCurIndex].toLowerCase() === target[targetCurrIndex].toLowerCase()) {\n\t\t\tif (nextMatch >= maxMatches) {\n\t\t\t\treturn { matched: false, outScore };\n\t\t\t}\n\n\t\t\tif (firstMatch && targetMatches) {\n\t\t\t\tmatches = [...targetMatches];\n\t\t\t\tfirstMatch = false;\n\t\t\t}\n\n\t\t\tconst recursiveMatches: number[] = [];\n\t\t\tconst recursiveResult = fuzzyMatchRecursive(\n\t\t\t\tpattern,\n\t\t\t\ttarget,\n\t\t\t\tpatternCurIndex,\n\t\t\t\ttargetCurrIndex + 1,\n\t\t\t\tmatches,\n\t\t\t\trecursiveMatches,\n\t\t\t\tmaxMatches,\n\t\t\t\tnextMatch,\n\t\t\t\trecursionCount,\n\t\t\t\trecursionLimit,\n\t\t\t);\n\n\t\t\tconst recursiveScore = recursiveResult.outScore;\n\t\t\tif (recursiveResult.matched) {\n\t\t\t\t// Pick best recursive score.\n\t\t\t\tif (!recursiveMatch || recursiveScore > bestRecursiveScore) {\n\t\t\t\t\tbestRecursiveMatches = [...recursiveMatches];\n\t\t\t\t\tbestRecursiveScore = recursiveScore;\n\t\t\t\t}\n\t\t\t\trecursiveMatch = true;\n\t\t\t}\n\n\t\t\tmatches[nextMatch++] = targetCurrIndex;\n\t\t\t++patternCurIndex;\n\t\t}\n\t\t++targetCurrIndex;\n\t}\n\n\tconst matched = patternCurIndex === pattern.length;\n\n\tif (matched) {\n\t\toutScore = 100;\n\n\t\t// Apply leading letter penalty (if not n8n-prefixed)\n\t\tif (!target.toLowerCase().startsWith('n8n')) {\n\t\t\tlet penalty = LEADING_LETTER_PENALTY * matches[0];\n\t\t\tpenalty = penalty < MAX_LEADING_LETTER_PENALTY ? MAX_LEADING_LETTER_PENALTY : penalty;\n\t\t\toutScore += penalty;\n\t\t}\n\n\t\t//Apply unmatched penalty\n\t\tconst unmatched = target.length - nextMatch;\n\t\toutScore += UNMATCHED_LETTER_PENALTY * unmatched;\n\n\t\t// Apply ordering bonuses\n\t\tfor (let i = 0; i < nextMatch; i++) {\n\t\t\tconst currIdx = matches[i];\n\n\t\t\tif (i > 0) {\n\t\t\t\tconst prevIdx = matches[i - 1];\n\t\t\t\tif (currIdx === prevIdx + 1) {\n\t\t\t\t\toutScore += SEQUENTIAL_BONUS;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check for bonuses based on neighbor character value.\n\t\t\tif (currIdx > 0) {\n\t\t\t\t// Camel case\n\t\t\t\tconst neighbor = target[currIdx - 1];\n\t\t\t\tconst curr = target[currIdx];\n\t\t\t\tif (neighbor !== neighbor.toUpperCase() && curr !== curr.toLowerCase()) {\n\t\t\t\t\toutScore += CAMEL_BONUS;\n\t\t\t\t}\n\t\t\t\tconst isNeighbourSeparator = neighbor === '_' || neighbor === ' ';\n\t\t\t\tif (isNeighbourSeparator) {\n\t\t\t\t\toutScore += SEPARATOR_BONUS;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// First letter\n\t\t\t\toutScore += FIRST_LETTER_BONUS;\n\t\t\t}\n\t\t}\n\n\t\t// Return best result\n\t\tif (recursiveMatch && (!matched || bestRecursiveScore > outScore)) {\n\t\t\t// Recursive score is better than \"this\"\n\t\t\tmatches = [...bestRecursiveMatches];\n\t\t\toutScore = bestRecursiveScore;\n\t\t\treturn { matched: true, outScore };\n\t\t} else if (matched) {\n\t\t\t// \"this\" score is better than recursive\n\t\t\treturn { matched: true, outScore };\n\t\t} else {\n\t\t\treturn { matched: false, outScore };\n\t\t}\n\t}\n\treturn { matched: false, outScore };\n}\n\n/**\n * Does a fuzzy search to find pattern inside a string.\n * @param {*} pattern string pattern to search for\n * @param {*} target string string which is being searched\n * @returns [boolean, number] a boolean which tells if pattern was\n * found or not and a search score\n */\nfunction fuzzyMatch(pattern: string, target: string): { matched: boolean; outScore: number } {\n\tconst recursionCount = 0;\n\tconst recursionLimit = 5;\n\tconst matches: number[] = [];\n\tconst maxMatches = 256;\n\n\treturn fuzzyMatchRecursive(\n\t\tpattern,\n\t\ttarget,\n\t\t0 /* patternCurIndex */,\n\t\t0 /* strCurrIndex */,\n\t\tnull /* srcMatces */,\n\t\tmatches,\n\t\tmaxMatches,\n\t\t0 /* nextMatch */,\n\t\trecursionCount,\n\t\trecursionLimit,\n\t);\n}\n\n// prop = 'key'\n// prop = 'key1.key2'\n// prop = ['key1', 'key2']\nfunction getValue<T extends object>(obj: T, prop: string): unknown {\n\tif (obj.hasOwnProperty(prop)) {\n\t\treturn obj[prop as keyof T];\n\t}\n\n\tconst segments = prop.split('.');\n\n\tlet result = obj;\n\tlet i = 0;\n\twhile (result && i < segments.length) {\n\t\tconst key = segments[i] as keyof T;\n\t\tresult = result[key] as T;\n\t\ti++;\n\t}\n\treturn result;\n}\n\nfunction scoreSearchValue(filter: string, value: string, weight: number): number | undefined {\n\tif (!fuzzyMatchSimple(filter, value)) return undefined;\n\n\tconst match = fuzzyMatch(filter, value);\n\tif (!match.matched) return undefined;\n\n\treturn match.outScore * weight;\n}\n\nexport function sublimeSearch<T extends object>(\n\tfilter: string,\n\tdata: readonly T[],\n\tkeys: Array<{ key: string; weight: number }> = DEFAULT_KEYS,\n\tlimit?: number,\n): Array<{ score: number; item: T }> {\n\tconst results: Array<{ score: number; item: T }> = [];\n\n\tfor (const item of data) {\n\t\tlet itemMatchScore: number | undefined;\n\n\t\tfor (const { key, weight } of keys) {\n\t\t\tconst value = getValue(item, key);\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (const entry of value) {\n\t\t\t\t\tif (typeof entry !== 'string') continue;\n\n\t\t\t\t\tconst score = scoreSearchValue(filter, entry, weight);\n\t\t\t\t\tif (score !== undefined && (itemMatchScore === undefined || score > itemMatchScore)) {\n\t\t\t\t\t\titemMatchScore = score;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (typeof value === 'string') {\n\t\t\t\tconst score = scoreSearchValue(filter, value, weight);\n\t\t\t\tif (score !== undefined && (itemMatchScore === undefined || score > itemMatchScore)) {\n\t\t\t\t\titemMatchScore = score;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (itemMatchScore !== undefined) {\n\t\t\tconst result: { score: number; item: T } = {\n\t\t\t\tscore: itemMatchScore,\n\t\t\t\titem,\n\t\t\t};\n\n\t\t\tif (limit === undefined || results.length < limit) {\n\t\t\t\tresults.push(result);\n\t\t\t} else {\n\t\t\t\tlet lowestIndex = 0;\n\t\t\t\tlet lowestScore = results[0].score;\n\t\t\t\tfor (let i = 1; i < results.length; i++) {\n\t\t\t\t\tif (results[i].score < lowestScore) {\n\t\t\t\t\t\tlowestIndex = i;\n\t\t\t\t\t\tlowestScore = results[i].score;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (result.score > lowestScore) {\n\t\t\t\t\tresults[lowestIndex] = result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tresults.sort((a, b) => {\n\t\treturn b.score - a.score;\n\t});\n\n\treturn results;\n}\n"],"mappings":";;AAKA,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AACxB,MAAM,cAAc;AACpB,MAAM,qBAAqB;AAE3B,MAAM,yBAAyB;AAC/B,MAAM,6BAA6B;AACnC,MAAM,2BAA2B;AAEjC,MAAa,eAAe,CAC3B;CAAE,KAAK;CAA0B,QAAQ;CAAK,EAC9C;CAAE,KAAK;CAA0B,QAAQ;CAAG,CAC5C;;;;;;AAOD,SAAS,iBAAiB,SAAiB,QAAyB;CACnE,IAAI,aAAa;CACjB,IAAI,SAAS;AAEb,QAAO,aAAa,QAAQ,UAAU,SAAS,OAAO,QAAQ;AAG7D,MAFoB,QAAQ,OAAO,WAAW,CAAC,aAAa,KACzC,OAAO,OAAO,OAAO,CAAC,aAAa,CAErD;AAED,IAAE;;AAGH,QAAO,QAAQ,WAAW,KAAK,OAAO,WAAW,KAAK,eAAe,QAAQ;;AAG9E,SAAS,oBACR,SACA,QACA,iBACA,iBACA,eACA,SACA,YACA,WACA,gBACA,gBACyC;CACzC,IAAI,WAAW;AAGf,KAAI,EAAE,kBAAkB,eACvB,QAAO;EAAE,SAAS;EAAO;EAAU;AAIpC,KAAI,oBAAoB,QAAQ,UAAU,oBAAoB,OAAO,OACpE,QAAO;EAAE,SAAS;EAAO;EAAU;CAIpC,IAAI,iBAAiB;CACrB,IAAIA,uBAAiC,EAAE;CACvC,IAAI,qBAAqB;CAGzB,IAAI,aAAa;AACjB,Q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;AACrD,QAAI,UAAU,WAAc,mBAAmB,UAAa,QAAQ,gBACnE,kBAAiB;;;AAKpB,MAAI,mBAAmB,QAAW;GACjC,MAAMC,SAAqC;IAC1C,OAAO;IACP;IACA;AAED,OAAI,UAAU,UAAa,QAAQ,SAAS,MAC3C,SAAQ,KAAK,OAAO;QACd;IACN,IAAI,cAAc;IAClB,IAAI,cAAc,QAAQ,GAAG;AAC7B,SAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IACnC,KAAI,QAAQ,GAAG,QAAQ,aAAa;AACnC,mBAAc;AACd,mBAAc,QAAQ,GAAG;;AAG3B,QAAI,OAAO,QAAQ,YAClB,SAAQ,eAAe;;;;AAM3B,SAAQ,MAAM,GAAG,MAAM;AACtB,SAAO,EAAE,QAAQ,EAAE;GAClB;AAEF,QAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/sublime-search.d.ts
|
|
2
2
|
declare const DEFAULT_KEYS: {
|
|
3
3
|
key: string;
|
|
4
4
|
weight: number;
|
|
@@ -12,4 +12,4 @@ declare function sublimeSearch<T extends object>(filter: string, data: readonly
|
|
|
12
12
|
}>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { sublimeSearch as n, DEFAULT_KEYS as t };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=sublime-search.d.cts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/sublime-search.d.ts
|
|
2
2
|
declare const DEFAULT_KEYS: {
|
|
3
3
|
key: string;
|
|
4
4
|
weight: number;
|
|
@@ -12,4 +12,4 @@ declare function sublimeSearch<T extends object>(filter: string, data: readonly
|
|
|
12
12
|
}>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { sublimeSearch as n, DEFAULT_KEYS as t };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=sublime-search.d.mts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/search/
|
|
1
|
+
//#region src/search/sublime-search.ts
|
|
2
2
|
const SEQUENTIAL_BONUS = 60;
|
|
3
3
|
const SEPARATOR_BONUS = 38;
|
|
4
4
|
const CAMEL_BONUS = 30;
|
|
@@ -178,4 +178,4 @@ function sublimeSearch(filter, data, keys = DEFAULT_KEYS, limit) {
|
|
|
178
178
|
|
|
179
179
|
//#endregion
|
|
180
180
|
export { sublimeSearch as n, DEFAULT_KEYS as t };
|
|
181
|
-
//# sourceMappingURL=
|
|
181
|
+
//# sourceMappingURL=sublime-search.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sublime-search.mjs","names":["bestRecursiveMatches: number[]","recursiveMatches: number[]","results: Array<{ score: number; item: T }>","itemMatchScore: number | undefined","result: { score: number; item: T }"],"sources":["../src/search/sublime-search.ts"],"sourcesContent":["/*\n * Constants and utility functions used for searching for node types in node creator component\n * based on https://github.com/forrestthewoods/lib_fts/blob/master/code/fts_fuzzy_match.js\n */\n\nconst SEQUENTIAL_BONUS = 60; // bonus for adjacent matches\nconst SEPARATOR_BONUS = 38; // bonus if match occurs after a separator\nconst CAMEL_BONUS = 30; // bonus if match is uppercase and prev is lower\nconst FIRST_LETTER_BONUS = 15; // bonus if the first letter is matched\n\nconst LEADING_LETTER_PENALTY = -20; // penalty applied for every letter in str before the first match\nconst MAX_LEADING_LETTER_PENALTY = -200; // maximum penalty for leading letters\nconst UNMATCHED_LETTER_PENALTY = -2.5;\n\nexport const DEFAULT_KEYS = [\n\t{ key: 'properties.displayName', weight: 1.3 },\n\t{ key: 'properties.codex.alias', weight: 1 },\n];\n\n/**\n * Returns true if each character in pattern is found sequentially within target\n * @param {*} pattern string\n * @param {*} target string\n */\nfunction fuzzyMatchSimple(pattern: string, target: string): boolean {\n\tlet patternIdx = 0;\n\tlet strIdx = 0;\n\n\twhile (patternIdx < pattern.length && strIdx < target.length) {\n\t\tconst patternChar = pattern.charAt(patternIdx).toLowerCase();\n\t\tconst targetChar = target.charAt(strIdx).toLowerCase();\n\t\tif (patternChar === targetChar) {\n\t\t\tpatternIdx++;\n\t\t}\n\t\t++strIdx;\n\t}\n\n\treturn pattern.length !== 0 && target.length !== 0 && patternIdx === pattern.length;\n}\n\nfunction fuzzyMatchRecursive(\n\tpattern: string,\n\ttarget: string,\n\tpatternCurIndex: number,\n\ttargetCurrIndex: number,\n\ttargetMatches: null | number[],\n\tmatches: number[],\n\tmaxMatches: number,\n\tnextMatch: number,\n\trecursionCount: number,\n\trecursionLimit: number,\n): { matched: boolean; outScore: number } {\n\tlet outScore = 0;\n\n\t// Return if recursion limit is reached.\n\tif (++recursionCount >= recursionLimit) {\n\t\treturn { matched: false, outScore };\n\t}\n\n\t// Return if we reached ends of strings.\n\tif (patternCurIndex === pattern.length || targetCurrIndex === target.length) {\n\t\treturn { matched: false, outScore };\n\t}\n\n\t// Recursion params\n\tlet recursiveMatch = false;\n\tlet bestRecursiveMatches: number[] = [];\n\tlet bestRecursiveScore = 0;\n\n\t// Loop through pattern and str looking for a match.\n\tlet firstMatch = true;\n\twhile (patternCurIndex < pattern.length && targetCurrIndex < target.length) {\n\t\t// Match found.\n\t\tif (pattern[patternCurIndex].toLowerCase() === target[targetCurrIndex].toLowerCase()) {\n\t\t\tif (nextMatch >= maxMatches) {\n\t\t\t\treturn { matched: false, outScore };\n\t\t\t}\n\n\t\t\tif (firstMatch && targetMatches) {\n\t\t\t\tmatches = [...targetMatches];\n\t\t\t\tfirstMatch = false;\n\t\t\t}\n\n\t\t\tconst recursiveMatches: number[] = [];\n\t\t\tconst recursiveResult = fuzzyMatchRecursive(\n\t\t\t\tpattern,\n\t\t\t\ttarget,\n\t\t\t\tpatternCurIndex,\n\t\t\t\ttargetCurrIndex + 1,\n\t\t\t\tmatches,\n\t\t\t\trecursiveMatches,\n\t\t\t\tmaxMatches,\n\t\t\t\tnextMatch,\n\t\t\t\trecursionCount,\n\t\t\t\trecursionLimit,\n\t\t\t);\n\n\t\t\tconst recursiveScore = recursiveResult.outScore;\n\t\t\tif (recursiveResult.matched) {\n\t\t\t\t// Pick best recursive score.\n\t\t\t\tif (!recursiveMatch || recursiveScore > bestRecursiveScore) {\n\t\t\t\t\tbestRecursiveMatches = [...recursiveMatches];\n\t\t\t\t\tbestRecursiveScore = recursiveScore;\n\t\t\t\t}\n\t\t\t\trecursiveMatch = true;\n\t\t\t}\n\n\t\t\tmatches[nextMatch++] = targetCurrIndex;\n\t\t\t++patternCurIndex;\n\t\t}\n\t\t++targetCurrIndex;\n\t}\n\n\tconst matched = patternCurIndex === pattern.length;\n\n\tif (matched) {\n\t\toutScore = 100;\n\n\t\t// Apply leading letter penalty (if not n8n-prefixed)\n\t\tif (!target.toLowerCase().startsWith('n8n')) {\n\t\t\tlet penalty = LEADING_LETTER_PENALTY * matches[0];\n\t\t\tpenalty = penalty < MAX_LEADING_LETTER_PENALTY ? MAX_LEADING_LETTER_PENALTY : penalty;\n\t\t\toutScore += penalty;\n\t\t}\n\n\t\t//Apply unmatched penalty\n\t\tconst unmatched = target.length - nextMatch;\n\t\toutScore += UNMATCHED_LETTER_PENALTY * unmatched;\n\n\t\t// Apply ordering bonuses\n\t\tfor (let i = 0; i < nextMatch; i++) {\n\t\t\tconst currIdx = matches[i];\n\n\t\t\tif (i > 0) {\n\t\t\t\tconst prevIdx = matches[i - 1];\n\t\t\t\tif (currIdx === prevIdx + 1) {\n\t\t\t\t\toutScore += SEQUENTIAL_BONUS;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Check for bonuses based on neighbor character value.\n\t\t\tif (currIdx > 0) {\n\t\t\t\t// Camel case\n\t\t\t\tconst neighbor = target[currIdx - 1];\n\t\t\t\tconst curr = target[currIdx];\n\t\t\t\tif (neighbor !== neighbor.toUpperCase() && curr !== curr.toLowerCase()) {\n\t\t\t\t\toutScore += CAMEL_BONUS;\n\t\t\t\t}\n\t\t\t\tconst isNeighbourSeparator = neighbor === '_' || neighbor === ' ';\n\t\t\t\tif (isNeighbourSeparator) {\n\t\t\t\t\toutScore += SEPARATOR_BONUS;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// First letter\n\t\t\t\toutScore += FIRST_LETTER_BONUS;\n\t\t\t}\n\t\t}\n\n\t\t// Return best result\n\t\tif (recursiveMatch && (!matched || bestRecursiveScore > outScore)) {\n\t\t\t// Recursive score is better than \"this\"\n\t\t\tmatches = [...bestRecursiveMatches];\n\t\t\toutScore = bestRecursiveScore;\n\t\t\treturn { matched: true, outScore };\n\t\t} else if (matched) {\n\t\t\t// \"this\" score is better than recursive\n\t\t\treturn { matched: true, outScore };\n\t\t} else {\n\t\t\treturn { matched: false, outScore };\n\t\t}\n\t}\n\treturn { matched: false, outScore };\n}\n\n/**\n * Does a fuzzy search to find pattern inside a string.\n * @param {*} pattern string pattern to search for\n * @param {*} target string string which is being searched\n * @returns [boolean, number] a boolean which tells if pattern was\n * found or not and a search score\n */\nfunction fuzzyMatch(pattern: string, target: string): { matched: boolean; outScore: number } {\n\tconst recursionCount = 0;\n\tconst recursionLimit = 5;\n\tconst matches: number[] = [];\n\tconst maxMatches = 256;\n\n\treturn fuzzyMatchRecursive(\n\t\tpattern,\n\t\ttarget,\n\t\t0 /* patternCurIndex */,\n\t\t0 /* strCurrIndex */,\n\t\tnull /* srcMatces */,\n\t\tmatches,\n\t\tmaxMatches,\n\t\t0 /* nextMatch */,\n\t\trecursionCount,\n\t\trecursionLimit,\n\t);\n}\n\n// prop = 'key'\n// prop = 'key1.key2'\n// prop = ['key1', 'key2']\nfunction getValue<T extends object>(obj: T, prop: string): unknown {\n\tif (obj.hasOwnProperty(prop)) {\n\t\treturn obj[prop as keyof T];\n\t}\n\n\tconst segments = prop.split('.');\n\n\tlet result = obj;\n\tlet i = 0;\n\twhile (result && i < segments.length) {\n\t\tconst key = segments[i] as keyof T;\n\t\tresult = result[key] as T;\n\t\ti++;\n\t}\n\treturn result;\n}\n\nfunction scoreSearchValue(filter: string, value: string, weight: number): number | undefined {\n\tif (!fuzzyMatchSimple(filter, value)) return undefined;\n\n\tconst match = fuzzyMatch(filter, value);\n\tif (!match.matched) return undefined;\n\n\treturn match.outScore * weight;\n}\n\nexport function sublimeSearch<T extends object>(\n\tfilter: string,\n\tdata: readonly T[],\n\tkeys: Array<{ key: string; weight: number }> = DEFAULT_KEYS,\n\tlimit?: number,\n): Array<{ score: number; item: T }> {\n\tconst results: Array<{ score: number; item: T }> = [];\n\n\tfor (const item of data) {\n\t\tlet itemMatchScore: number | undefined;\n\n\t\tfor (const { key, weight } of keys) {\n\t\t\tconst value = getValue(item, key);\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\tfor (const entry of value) {\n\t\t\t\t\tif (typeof entry !== 'string') continue;\n\n\t\t\t\t\tconst score = scoreSearchValue(filter, entry, weight);\n\t\t\t\t\tif (score !== undefined && (itemMatchScore === undefined || score > itemMatchScore)) {\n\t\t\t\t\t\titemMatchScore = score;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (typeof value === 'string') {\n\t\t\t\tconst score = scoreSearchValue(filter, value, weight);\n\t\t\t\tif (score !== undefined && (itemMatchScore === undefined || score > itemMatchScore)) {\n\t\t\t\t\titemMatchScore = score;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (itemMatchScore !== undefined) {\n\t\t\tconst result: { score: number; item: T } = {\n\t\t\t\tscore: itemMatchScore,\n\t\t\t\titem,\n\t\t\t};\n\n\t\t\tif (limit === undefined || results.length < limit) {\n\t\t\t\tresults.push(result);\n\t\t\t} else {\n\t\t\t\tlet lowestIndex = 0;\n\t\t\t\tlet lowestScore = results[0].score;\n\t\t\t\tfor (let i = 1; i < results.length; i++) {\n\t\t\t\t\tif (results[i].score < lowestScore) {\n\t\t\t\t\t\tlowestIndex = i;\n\t\t\t\t\t\tlowestScore = results[i].score;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (result.score > lowestScore) {\n\t\t\t\t\tresults[l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cAAc,QAAQ,GAAG;AAC7B,SAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,IACnC,KAAI,QAAQ,GAAG,QAAQ,aAAa;AACnC,mBAAc;AACd,mBAAc,QAAQ,GAAG;;AAG3B,QAAI,OAAO,QAAQ,YAClB,SAAQ,eAAe;;;;AAM3B,SAAQ,MAAM,GAAG,MAAM;AACtB,SAAO,EAAE,QAAQ,EAAE;GAClB;AAEF,QAAO"}
|
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.37.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
7
|
-
"
|
|
8
|
-
"
|
|
7
|
+
"LICENSE.md",
|
|
8
|
+
"LICENSE_EE.md"
|
|
9
9
|
],
|
|
10
10
|
"main": "./dist/index.cjs",
|
|
11
11
|
"module": "./dist/index.mjs",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"nanoid": "3.3.8",
|
|
32
|
-
"@n8n/constants": "0.
|
|
32
|
+
"@n8n/constants": "0.29.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
"tsdown": "^0.16.5",
|
|
38
38
|
"typescript": "6.0.2",
|
|
39
39
|
"vite": "^8.0.2",
|
|
40
|
-
"vitest": "^4.1.
|
|
41
|
-
"@n8n/typescript-config": "1.
|
|
42
|
-
"@n8n/
|
|
43
|
-
"@n8n/
|
|
40
|
+
"vitest": "^4.1.9",
|
|
41
|
+
"@n8n/typescript-config": "1.7.0",
|
|
42
|
+
"@n8n/vitest-config": "1.16.0",
|
|
43
|
+
"@n8n/eslint-config": "0.0.1"
|
|
44
44
|
},
|
|
45
45
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
46
46
|
"homepage": "https://n8n.io",
|
package/dist/event-queue.cjs
DELETED
package/dist/event-queue.d.cts
DELETED
package/dist/event-queue.d.mts
DELETED
package/dist/event-queue.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-queue2.cjs","names":["queue: T[]"],"sources":["../src/event-queue.ts"],"sourcesContent":["/**\n * Create an event queue that processes events sequentially.\n *\n * @param processEvent - Async function that processes a single event.\n * @returns A function that enqueues events for processing.\n */\nexport function createEventQueue<T>(processEvent: (event: T) => Promise<void>) {\n\t// The internal queue holding events.\n\tconst queue: T[] = [];\n\n\t// Flag to indicate whether an event is currently being processed.\n\tlet processing = false;\n\n\t/**\n\t * Process the next event in the queue (if not already processing).\n\t */\n\tasync function processNext(): Promise<void> {\n\t\tif (processing || queue.length === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tprocessing = true;\n\t\tconst currentEvent = queue.shift();\n\n\t\tif (currentEvent !== undefined) {\n\t\t\ttry {\n\t\t\t\tawait processEvent(currentEvent);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error('Error processing event:', error);\n\t\t\t}\n\t\t}\n\n\t\tprocessing = false;\n\n\t\t// Recursively process the next event.\n\t\tawait processNext();\n\t}\n\n\t/**\n\t * Enqueue an event and trigger processing.\n\t *\n\t * @param event - The event to enqueue.\n\t */\n\tfunction enqueue(event: T): void {\n\t\tqueue.push(event);\n\t\tvoid processNext();\n\t}\n\n\treturn { enqueue };\n}\n"],"mappings":";;;;;;;;AAMA,SAAgB,iBAAoB,cAA2C;CAE9E,MAAMA,QAAa,EAAE;CAGrB,IAAI,aAAa;;;;CAKjB,eAAe,cAA6B;AAC3C,MAAI,cAAc,MAAM,WAAW,EAClC;AAGD,eAAa;EACb,MAAM,eAAe,MAAM,OAAO;AAElC,MAAI,iBAAiB,OACpB,KAAI;AACH,SAAM,aAAa,aAAa;WACxB,OAAO;AACf,WAAQ,MAAM,2BAA2B,MAAM;;AAIjD,eAAa;AAGb,QAAM,aAAa;;;;;;;CAQpB,SAAS,QAAQ,OAAgB;AAChC,QAAM,KAAK,MAAM;AACjB,EAAK,aAAa;;AAGnB,QAAO,EAAE,SAAS"}
|