@n8n/utils 1.37.1 → 1.38.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.
Files changed (231) hide show
  1. package/dist/assert.cjs +11 -2
  2. package/dist/assert.cjs.map +1 -0
  3. package/dist/assert.d.cts +5 -2
  4. package/dist/assert.d.mts +5 -2
  5. package/dist/assert.mjs +10 -2
  6. package/dist/assert.mjs.map +1 -0
  7. package/dist/client-assertion.cjs +49 -0
  8. package/dist/client-assertion.cjs.map +1 -0
  9. package/dist/client-assertion.d.cts +12 -0
  10. package/dist/client-assertion.d.mts +12 -0
  11. package/dist/client-assertion.mjs +48 -0
  12. package/dist/client-assertion.mjs.map +1 -0
  13. package/dist/create-event-queue.cjs +40 -2
  14. package/dist/create-event-queue.cjs.map +1 -0
  15. package/dist/create-event-queue.d.cts +7 -2
  16. package/dist/create-event-queue.d.mts +7 -2
  17. package/dist/create-event-queue.mjs +39 -2
  18. package/dist/create-event-queue.mjs.map +1 -0
  19. package/dist/ensure-error.cjs +15 -0
  20. package/dist/ensure-error.cjs.map +1 -0
  21. package/dist/ensure-error.mjs +9 -0
  22. package/dist/ensure-error.mjs.map +1 -0
  23. package/dist/errors/ensure-error.cjs +3 -0
  24. package/dist/errors/ensure-error.d.cts +5 -0
  25. package/dist/errors/ensure-error.d.mts +5 -0
  26. package/dist/errors/ensure-error.mjs +3 -0
  27. package/dist/event-bus.cjs +43 -2
  28. package/dist/event-bus.cjs.map +1 -0
  29. package/dist/event-bus.d.cts +14 -2
  30. package/dist/event-bus.d.mts +14 -2
  31. package/dist/event-bus.mjs +42 -2
  32. package/dist/event-bus.mjs.map +1 -0
  33. package/dist/files/is-windows-file-path.cjs +11 -2
  34. package/dist/files/is-windows-file-path.cjs.map +1 -0
  35. package/dist/files/is-windows-file-path.d.cts +5 -2
  36. package/dist/files/is-windows-file-path.d.mts +5 -2
  37. package/dist/files/is-windows-file-path.mjs +10 -2
  38. package/dist/files/is-windows-file-path.mjs.map +1 -0
  39. package/dist/files/sanitize-filename.cjs +61 -2
  40. package/dist/files/sanitize-filename.cjs.map +1 -0
  41. package/dist/files/sanitize-filename.d.cts +5 -2
  42. package/dist/files/sanitize-filename.d.mts +5 -2
  43. package/dist/files/sanitize-filename.mjs +60 -2
  44. package/dist/files/sanitize-filename.mjs.map +1 -0
  45. package/dist/format-pem-block.d.cts +5 -2
  46. package/dist/format-pem-block.d.mts +5 -2
  47. package/dist/generate-nano-id.cjs +28 -2
  48. package/dist/generate-nano-id.cjs.map +1 -0
  49. package/dist/generate-nano-id.d.cts +5 -2
  50. package/dist/generate-nano-id.d.mts +5 -2
  51. package/dist/generate-nano-id.mjs +28 -2
  52. package/dist/generate-nano-id.mjs.map +1 -0
  53. package/dist/get-jwt-expiry.cjs +22 -2
  54. package/dist/get-jwt-expiry.cjs.map +1 -0
  55. package/dist/get-jwt-expiry.d.cts +5 -2
  56. package/dist/get-jwt-expiry.d.mts +5 -2
  57. package/dist/get-jwt-expiry.mjs +21 -2
  58. package/dist/get-jwt-expiry.mjs.map +1 -0
  59. package/dist/is-record.cjs +8 -2
  60. package/dist/is-record.cjs.map +1 -0
  61. package/dist/is-record.d.cts +5 -2
  62. package/dist/is-record.d.mts +5 -2
  63. package/dist/is-record.mjs +7 -2
  64. package/dist/is-record.mjs.map +1 -0
  65. package/dist/number/smart-decimal.cjs +10 -2
  66. package/dist/number/smart-decimal.cjs.map +1 -0
  67. package/dist/number/smart-decimal.d.cts +5 -2
  68. package/dist/number/smart-decimal.d.mts +5 -2
  69. package/dist/number/smart-decimal.mjs +9 -2
  70. package/dist/number/smart-decimal.mjs.map +1 -0
  71. package/dist/placeholder.cjs +80 -7
  72. package/dist/placeholder.cjs.map +1 -0
  73. package/dist/placeholder.d.cts +14 -2
  74. package/dist/placeholder.d.mts +14 -2
  75. package/dist/placeholder.mjs +74 -2
  76. package/dist/placeholder.mjs.map +1 -0
  77. package/dist/promise/deferred-promise.cjs +14 -0
  78. package/dist/promise/deferred-promise.cjs.map +1 -0
  79. package/dist/promise/deferred-promise.d.cts +12 -0
  80. package/dist/promise/deferred-promise.d.mts +12 -0
  81. package/dist/promise/deferred-promise.mjs +13 -0
  82. package/dist/promise/deferred-promise.mjs.map +1 -0
  83. package/dist/result.cjs +30 -0
  84. package/dist/result.cjs.map +1 -0
  85. package/dist/result.d.cts +16 -0
  86. package/dist/result.d.mts +16 -0
  87. package/dist/result.mjs +28 -0
  88. package/dist/result.mjs.map +1 -0
  89. package/dist/retry.cjs +39 -2
  90. package/dist/retry.cjs.map +1 -0
  91. package/dist/retry.d.cts +6 -2
  92. package/dist/retry.d.mts +6 -2
  93. package/dist/retry.mjs +38 -2
  94. package/dist/retry.mjs.map +1 -0
  95. package/dist/scrub-secrets.cjs +44 -4
  96. package/dist/scrub-secrets.cjs.map +1 -0
  97. package/dist/scrub-secrets.d.cts +7 -2
  98. package/dist/scrub-secrets.d.mts +7 -2
  99. package/dist/scrub-secrets.mjs +41 -2
  100. package/dist/scrub-secrets.mjs.map +1 -0
  101. package/dist/search/re-rank-search-results.cjs +19 -2
  102. package/dist/search/re-rank-search-results.cjs.map +1 -0
  103. package/dist/search/re-rank-search-results.d.cts +13 -2
  104. package/dist/search/re-rank-search-results.d.mts +13 -2
  105. package/dist/search/re-rank-search-results.mjs +18 -2
  106. package/dist/search/re-rank-search-results.mjs.map +1 -0
  107. package/dist/search/sublime-search.cjs +182 -3
  108. package/dist/search/sublime-search.cjs.map +1 -0
  109. package/dist/search/sublime-search.d.cts +15 -2
  110. package/dist/search/sublime-search.d.mts +15 -2
  111. package/dist/search/sublime-search.mjs +180 -2
  112. package/dist/search/sublime-search.mjs.map +1 -0
  113. package/dist/sort/sort-by-property.cjs +12 -2
  114. package/dist/sort/sort-by-property.cjs.map +1 -0
  115. package/dist/sort/sort-by-property.d.cts +5 -2
  116. package/dist/sort/sort-by-property.d.mts +5 -2
  117. package/dist/sort/sort-by-property.mjs +11 -2
  118. package/dist/sort/sort-by-property.mjs.map +1 -0
  119. package/dist/string/truncate.cjs +32 -3
  120. package/dist/string/truncate.cjs.map +1 -0
  121. package/dist/string/truncate.d.cts +6 -2
  122. package/dist/string/truncate.d.mts +6 -2
  123. package/dist/string/truncate.mjs +30 -2
  124. package/dist/string/truncate.mjs.map +1 -0
  125. package/dist/types.d.cts +5 -2
  126. package/dist/types.d.mts +5 -2
  127. package/package.json +11 -12
  128. package/dist/assert2.cjs +0 -17
  129. package/dist/assert2.cjs.map +0 -1
  130. package/dist/assert2.d.cts +0 -5
  131. package/dist/assert2.d.mts +0 -5
  132. package/dist/assert2.mjs +0 -11
  133. package/dist/assert2.mjs.map +0 -1
  134. package/dist/create-event-queue2.cjs +0 -46
  135. package/dist/create-event-queue2.cjs.map +0 -1
  136. package/dist/create-event-queue2.d.cts +0 -7
  137. package/dist/create-event-queue2.d.mts +0 -7
  138. package/dist/create-event-queue2.mjs +0 -40
  139. package/dist/create-event-queue2.mjs.map +0 -1
  140. package/dist/event-bus2.cjs +0 -49
  141. package/dist/event-bus2.cjs.map +0 -1
  142. package/dist/event-bus2.d.cts +0 -14
  143. package/dist/event-bus2.d.mts +0 -14
  144. package/dist/event-bus2.mjs +0 -43
  145. package/dist/event-bus2.mjs.map +0 -1
  146. package/dist/format-pem-block2.d.cts +0 -5
  147. package/dist/format-pem-block2.d.mts +0 -5
  148. package/dist/generate-nano-id2.cjs +0 -34
  149. package/dist/generate-nano-id2.cjs.map +0 -1
  150. package/dist/generate-nano-id2.d.cts +0 -5
  151. package/dist/generate-nano-id2.d.mts +0 -5
  152. package/dist/generate-nano-id2.mjs +0 -29
  153. package/dist/generate-nano-id2.mjs.map +0 -1
  154. package/dist/get-jwt-expiry2.cjs +0 -28
  155. package/dist/get-jwt-expiry2.cjs.map +0 -1
  156. package/dist/get-jwt-expiry2.d.cts +0 -5
  157. package/dist/get-jwt-expiry2.d.mts +0 -5
  158. package/dist/get-jwt-expiry2.mjs +0 -22
  159. package/dist/get-jwt-expiry2.mjs.map +0 -1
  160. package/dist/index.cjs +0 -44
  161. package/dist/index.d.cts +0 -19
  162. package/dist/index.d.mts +0 -19
  163. package/dist/index.mjs +0 -19
  164. package/dist/is-record2.cjs +0 -14
  165. package/dist/is-record2.cjs.map +0 -1
  166. package/dist/is-record2.d.cts +0 -5
  167. package/dist/is-record2.d.mts +0 -5
  168. package/dist/is-record2.mjs +0 -8
  169. package/dist/is-record2.mjs.map +0 -1
  170. package/dist/is-windows-file-path.cjs +0 -17
  171. package/dist/is-windows-file-path.cjs.map +0 -1
  172. package/dist/is-windows-file-path.d.cts +0 -5
  173. package/dist/is-windows-file-path.d.mts +0 -5
  174. package/dist/is-windows-file-path.mjs +0 -11
  175. package/dist/is-windows-file-path.mjs.map +0 -1
  176. package/dist/placeholder2.cjs +0 -111
  177. package/dist/placeholder2.cjs.map +0 -1
  178. package/dist/placeholder2.d.cts +0 -14
  179. package/dist/placeholder2.d.mts +0 -14
  180. package/dist/placeholder2.mjs +0 -75
  181. package/dist/placeholder2.mjs.map +0 -1
  182. package/dist/re-rank-search-results.cjs +0 -25
  183. package/dist/re-rank-search-results.cjs.map +0 -1
  184. package/dist/re-rank-search-results.d.cts +0 -13
  185. package/dist/re-rank-search-results.d.mts +0 -13
  186. package/dist/re-rank-search-results.mjs +0 -19
  187. package/dist/re-rank-search-results.mjs.map +0 -1
  188. package/dist/retry2.cjs +0 -45
  189. package/dist/retry2.cjs.map +0 -1
  190. package/dist/retry2.d.cts +0 -6
  191. package/dist/retry2.d.mts +0 -6
  192. package/dist/retry2.mjs +0 -39
  193. package/dist/retry2.mjs.map +0 -1
  194. package/dist/sanitize-filename.cjs +0 -67
  195. package/dist/sanitize-filename.cjs.map +0 -1
  196. package/dist/sanitize-filename.d.cts +0 -5
  197. package/dist/sanitize-filename.d.mts +0 -5
  198. package/dist/sanitize-filename.mjs +0 -61
  199. package/dist/sanitize-filename.mjs.map +0 -1
  200. package/dist/scrub-secrets2.cjs +0 -59
  201. package/dist/scrub-secrets2.cjs.map +0 -1
  202. package/dist/scrub-secrets2.d.cts +0 -7
  203. package/dist/scrub-secrets2.d.mts +0 -7
  204. package/dist/scrub-secrets2.mjs +0 -41
  205. package/dist/scrub-secrets2.mjs.map +0 -1
  206. package/dist/smart-decimal.cjs +0 -16
  207. package/dist/smart-decimal.cjs.map +0 -1
  208. package/dist/smart-decimal.d.cts +0 -5
  209. package/dist/smart-decimal.d.mts +0 -5
  210. package/dist/smart-decimal.mjs +0 -10
  211. package/dist/smart-decimal.mjs.map +0 -1
  212. package/dist/sort-by-property.cjs +0 -18
  213. package/dist/sort-by-property.cjs.map +0 -1
  214. package/dist/sort-by-property.d.cts +0 -5
  215. package/dist/sort-by-property.d.mts +0 -5
  216. package/dist/sort-by-property.mjs +0 -12
  217. package/dist/sort-by-property.mjs.map +0 -1
  218. package/dist/sublime-search.cjs +0 -193
  219. package/dist/sublime-search.cjs.map +0 -1
  220. package/dist/sublime-search.d.cts +0 -15
  221. package/dist/sublime-search.d.mts +0 -15
  222. package/dist/sublime-search.mjs +0 -181
  223. package/dist/sublime-search.mjs.map +0 -1
  224. package/dist/truncate.cjs +0 -43
  225. package/dist/truncate.cjs.map +0 -1
  226. package/dist/truncate.d.cts +0 -6
  227. package/dist/truncate.d.mts +0 -6
  228. package/dist/truncate.mjs +0 -31
  229. package/dist/truncate.mjs.map +0 -1
  230. package/dist/types2.d.cts +0 -5
  231. package/dist/types2.d.mts +0 -5
package/dist/index.mjs DELETED
@@ -1,19 +0,0 @@
1
- import { t as assert } from "./assert2.mjs";
2
- import { t as createEventQueue } from "./create-event-queue2.mjs";
3
- import { t as createEventBus } from "./event-bus2.mjs";
4
- import { t as formatPemBlock } from "./format-pem-block2.mjs";
5
- import { t as generateNanoId } from "./generate-nano-id2.mjs";
6
- import { t as getJwtExpiry } from "./get-jwt-expiry2.mjs";
7
- import { t as retry } from "./retry2.mjs";
8
- import { t as smartDecimal } from "./smart-decimal.mjs";
9
- import { t as reRankSearchResults } from "./re-rank-search-results.mjs";
10
- import { n as sublimeSearch, t as DEFAULT_KEYS } from "./sublime-search.mjs";
11
- import { t as sortByProperty } from "./sort-by-property.mjs";
12
- import { n as truncateBeforeLast, t as truncate } from "./truncate.mjs";
13
- import { t as sanitizeFilename } from "./sanitize-filename.mjs";
14
- import { t as isWindowsFilePath } from "./is-windows-file-path.mjs";
15
- import { a as isPlaceholderString, i as hasPlaceholderDeep, n as findPlaceholderDetails, o as isPlaceholderValue, r as formatPlaceholderPath, t as extractPlaceholderLabels } from "./placeholder2.mjs";
16
- import { n as SECRET_VALUE_PATTERNS, r as scrubSecretsInText, t as SECRET_KEYS } from "./scrub-secrets2.mjs";
17
- import { t as isRecord } from "./is-record2.mjs";
18
-
19
- export { DEFAULT_KEYS, SECRET_KEYS, SECRET_VALUE_PATTERNS, assert, createEventBus, createEventQueue, extractPlaceholderLabels, findPlaceholderDetails, formatPemBlock, formatPlaceholderPath, generateNanoId, getJwtExpiry, hasPlaceholderDeep, isPlaceholderString, isPlaceholderValue, isRecord, isWindowsFilePath, reRankSearchResults, retry, sanitizeFilename, scrubSecretsInText, smartDecimal, sortByProperty, sublimeSearch, truncate, truncateBeforeLast };
@@ -1,14 +0,0 @@
1
-
2
- //#region src/is-record.ts
3
- function isRecord(value) {
4
- return typeof value === "object" && value !== null && !Array.isArray(value);
5
- }
6
-
7
- //#endregion
8
- Object.defineProperty(exports, 'isRecord', {
9
- enumerable: true,
10
- get: function () {
11
- return isRecord;
12
- }
13
- });
14
- //# sourceMappingURL=is-record2.cjs.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- //#region src/is-record.d.ts
2
- declare function isRecord(value: unknown): value is Record<string, unknown>;
3
- //#endregion
4
- export { isRecord as t };
5
- //# sourceMappingURL=is-record2.d.cts.map
@@ -1,5 +0,0 @@
1
- //#region src/is-record.d.ts
2
- declare function isRecord(value: unknown): value is Record<string, unknown>;
3
- //#endregion
4
- export { isRecord as t };
5
- //# sourceMappingURL=is-record2.d.mts.map
@@ -1,8 +0,0 @@
1
- //#region src/is-record.ts
2
- function isRecord(value) {
3
- return typeof value === "object" && value !== null && !Array.isArray(value);
4
- }
5
-
6
- //#endregion
7
- export { isRecord as t };
8
- //# sourceMappingURL=is-record2.mjs.map
@@ -1 +0,0 @@
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,17 +0,0 @@
1
-
2
- //#region src/files/is-windows-file-path.ts
3
- /**
4
- * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
5
- */
6
- function isWindowsFilePath(str) {
7
- return /^[a-zA-Z]:[\\/]/.test(str);
8
- }
9
-
10
- //#endregion
11
- Object.defineProperty(exports, 'isWindowsFilePath', {
12
- enumerable: true,
13
- get: function () {
14
- return isWindowsFilePath;
15
- }
16
- });
17
- //# sourceMappingURL=is-windows-file-path.cjs.map
@@ -1 +0,0 @@
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 +0,0 @@
1
- //#region src/files/is-windows-file-path.d.ts
2
- declare function isWindowsFilePath(str: string): boolean;
3
- //#endregion
4
- export { isWindowsFilePath as t };
5
- //# sourceMappingURL=is-windows-file-path.d.cts.map
@@ -1,5 +0,0 @@
1
- //#region src/files/is-windows-file-path.d.ts
2
- declare function isWindowsFilePath(str: string): boolean;
3
- //#endregion
4
- export { isWindowsFilePath as t };
5
- //# sourceMappingURL=is-windows-file-path.d.mts.map
@@ -1,11 +0,0 @@
1
- //#region src/files/is-windows-file-path.ts
2
- /**
3
- * Fast check if file path starts with a windows drive letter, e.g. 'C:/' or 'C:\\'
4
- */
5
- function isWindowsFilePath(str) {
6
- return /^[a-zA-Z]:[\\/]/.test(str);
7
- }
8
-
9
- //#endregion
10
- export { isWindowsFilePath as t };
11
- //# sourceMappingURL=is-windows-file-path.mjs.map
@@ -1 +0,0 @@
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,111 +0,0 @@
1
-
2
- //#region src/placeholder.ts
3
- const PLACEHOLDER_SUFFIX = "__>";
4
- const PLACEHOLDER_VALUE_PREFIX = "<__PLACEHOLDER_VALUE__";
5
- const PLACEHOLDER_REGEX = /<__PLACEHOLDER.*?__>/;
6
- /** Check if a value is a placeholder sentinel string (format: `<__PLACEHOLDER_VALUE__hint__>`). */
7
- function isPlaceholderString(value) {
8
- return typeof value === "string" && value.startsWith(PLACEHOLDER_VALUE_PREFIX) && value.endsWith(PLACEHOLDER_SUFFIX);
9
- }
10
- /** Recursively check if a value (string, array, or object) contains any placeholder sentinel strings. */
11
- function hasPlaceholderDeep(value) {
12
- if (typeof value === "string") return isPlaceholderString(value);
13
- if (Array.isArray(value)) return value.some(hasPlaceholderDeep);
14
- if (value !== null && typeof value === "object") return Object.values(value).some(hasPlaceholderDeep);
15
- return false;
16
- }
17
- /** Checks if a value is a placeholder value (matches the placeholder regex pattern). */
18
- function isPlaceholderValue(value) {
19
- if (typeof value !== "string") return false;
20
- return !!value.match(PLACEHOLDER_REGEX);
21
- }
22
- /**
23
- * Extracts the label from a single placeholder string.
24
- * Handles formats like:
25
- * - <__PLACEHOLDER_VALUE__label__>
26
- * - <__PLACEHOLDER__: label__>
27
- */
28
- function extractLabelFromPlaceholder(placeholder) {
29
- let label = placeholder.slice(14, -3);
30
- if (label.startsWith("_VALUE__")) label = label.slice(8);
31
- else if (label.startsWith("__:")) label = label.slice(3);
32
- else if (label.startsWith("__")) label = label.slice(2);
33
- return label.trim();
34
- }
35
- /**
36
- * Extracts all placeholder labels from a string value.
37
- * Handles both cases where the entire value is a placeholder and where
38
- * placeholders are embedded within code (e.g., Code node).
39
- * Returns an array of labels found.
40
- */
41
- function extractPlaceholderLabels(value) {
42
- if (typeof value !== "string") return [];
43
- const labels = [];
44
- const regex = new RegExp(PLACEHOLDER_REGEX.source, "g");
45
- let match;
46
- while ((match = regex.exec(value)) !== null) {
47
- const label = extractLabelFromPlaceholder(match[0]);
48
- if (label.length > 0) labels.push(label);
49
- }
50
- return labels;
51
- }
52
- /**
53
- * Recursively searches through a value (object, array, or primitive) to find
54
- * all placeholder values and their paths.
55
- */
56
- function findPlaceholderDetails(value, path = []) {
57
- if (typeof value === "string") return extractPlaceholderLabels(value).map((label) => ({
58
- path,
59
- label
60
- }));
61
- if (Array.isArray(value)) return value.flatMap((item, index) => findPlaceholderDetails(item, [...path, `[${index}]`]));
62
- if (value !== null && typeof value === "object") return Object.entries(value).flatMap(([key, nested]) => findPlaceholderDetails(nested, [...path, key]));
63
- return [];
64
- }
65
- /**
66
- * Formats a path array into a dot-notation string for display.
67
- * Array indices are preserved as [N] without leading dots.
68
- */
69
- function formatPlaceholderPath(path) {
70
- if (path.length === 0) return "parameters";
71
- return path.map((segment, index) => segment.startsWith("[") || index === 0 ? segment : `.${segment}`).join("");
72
- }
73
-
74
- //#endregion
75
- Object.defineProperty(exports, 'extractPlaceholderLabels', {
76
- enumerable: true,
77
- get: function () {
78
- return extractPlaceholderLabels;
79
- }
80
- });
81
- Object.defineProperty(exports, 'findPlaceholderDetails', {
82
- enumerable: true,
83
- get: function () {
84
- return findPlaceholderDetails;
85
- }
86
- });
87
- Object.defineProperty(exports, 'formatPlaceholderPath', {
88
- enumerable: true,
89
- get: function () {
90
- return formatPlaceholderPath;
91
- }
92
- });
93
- Object.defineProperty(exports, 'hasPlaceholderDeep', {
94
- enumerable: true,
95
- get: function () {
96
- return hasPlaceholderDeep;
97
- }
98
- });
99
- Object.defineProperty(exports, 'isPlaceholderString', {
100
- enumerable: true,
101
- get: function () {
102
- return isPlaceholderString;
103
- }
104
- });
105
- Object.defineProperty(exports, 'isPlaceholderValue', {
106
- enumerable: true,
107
- get: function () {
108
- return isPlaceholderValue;
109
- }
110
- });
111
- //# sourceMappingURL=placeholder2.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"placeholder2.cjs","names":["labels: string[]"],"sources":["../src/placeholder.ts"],"sourcesContent":["const PLACEHOLDER_PREFIX = '<__PLACEHOLDER';\nconst PLACEHOLDER_SUFFIX = '__>';\nconst PLACEHOLDER_VALUE_PREFIX = '<__PLACEHOLDER_VALUE__';\n\nconst PLACEHOLDER_REGEX = /<__PLACEHOLDER.*?__>/;\n\nexport interface PlaceholderDetail {\n\tpath: string[];\n\tlabel: string;\n}\n\n/** Check if a value is a placeholder sentinel string (format: `<__PLACEHOLDER_VALUE__hint__>`). */\nexport function isPlaceholderString(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.startsWith(PLACEHOLDER_VALUE_PREFIX) &&\n\t\tvalue.endsWith(PLACEHOLDER_SUFFIX)\n\t);\n}\n\n/** Recursively check if a value (string, array, or object) contains any placeholder sentinel strings. */\nexport function hasPlaceholderDeep(value: unknown): boolean {\n\tif (typeof value === 'string') return isPlaceholderString(value);\n\tif (Array.isArray(value)) return value.some(hasPlaceholderDeep);\n\tif (value !== null && typeof value === 'object') {\n\t\treturn Object.values(value as Record<string, unknown>).some(hasPlaceholderDeep);\n\t}\n\treturn false;\n}\n\n/** Checks if a value is a placeholder value (matches the placeholder regex pattern). */\nexport function isPlaceholderValue(value: unknown): boolean {\n\tif (typeof value !== 'string') return false;\n\treturn !!value.match(PLACEHOLDER_REGEX);\n}\n\n/**\n * Extracts the label from a single placeholder string.\n * Handles formats like:\n * - <__PLACEHOLDER_VALUE__label__>\n * - <__PLACEHOLDER__: label__>\n */\nfunction extractLabelFromPlaceholder(placeholder: string): string {\n\tlet label = placeholder.slice(PLACEHOLDER_PREFIX.length, -PLACEHOLDER_SUFFIX.length);\n\n\tif (label.startsWith('_VALUE__')) {\n\t\tlabel = label.slice('_VALUE__'.length);\n\t} else if (label.startsWith('__:')) {\n\t\tlabel = label.slice('__:'.length);\n\t} else if (label.startsWith('__')) {\n\t\tlabel = label.slice('__'.length);\n\t}\n\n\treturn label.trim();\n}\n\n/**\n * Extracts all placeholder labels from a string value.\n * Handles both cases where the entire value is a placeholder and where\n * placeholders are embedded within code (e.g., Code node).\n * Returns an array of labels found.\n */\nexport function extractPlaceholderLabels(value: unknown): string[] {\n\tif (typeof value !== 'string') return [];\n\n\tconst labels: string[] = [];\n\tconst regex = new RegExp(PLACEHOLDER_REGEX.source, 'g');\n\tlet match;\n\n\twhile ((match = regex.exec(value)) !== null) {\n\t\tconst label = extractLabelFromPlaceholder(match[0]);\n\t\tif (label.length > 0) {\n\t\t\tlabels.push(label);\n\t\t}\n\t}\n\n\treturn labels;\n}\n\n/**\n * Recursively searches through a value (object, array, or primitive) to find\n * all placeholder values and their paths.\n */\nexport function findPlaceholderDetails(value: unknown, path: string[] = []): PlaceholderDetail[] {\n\tif (typeof value === 'string') {\n\t\tconst labels = extractPlaceholderLabels(value);\n\t\treturn labels.map((label) => ({ path, label }));\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value.flatMap((item, index) => findPlaceholderDetails(item, [...path, `[${index}]`]));\n\t}\n\n\tif (value !== null && typeof value === 'object') {\n\t\treturn Object.entries(value).flatMap(([key, nested]) =>\n\t\t\tfindPlaceholderDetails(nested, [...path, key]),\n\t\t);\n\t}\n\n\treturn [];\n}\n\n/**\n * Formats a path array into a dot-notation string for display.\n * Array indices are preserved as [N] without leading dots.\n */\nexport function formatPlaceholderPath(path: string[]): string {\n\tif (path.length === 0) return 'parameters';\n\n\treturn path\n\t\t.map((segment, index) => (segment.startsWith('[') || index === 0 ? segment : `.${segment}`))\n\t\t.join('');\n}\n"],"mappings":";;AACA,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAEjC,MAAM,oBAAoB;;AAQ1B,SAAgB,oBAAoB,OAAyB;AAC5D,QACC,OAAO,UAAU,YACjB,MAAM,WAAW,yBAAyB,IAC1C,MAAM,SAAS,mBAAmB;;;AAKpC,SAAgB,mBAAmB,OAAyB;AAC3D,KAAI,OAAO,UAAU,SAAU,QAAO,oBAAoB,MAAM;AAChE,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,KAAK,mBAAmB;AAC/D,KAAI,UAAU,QAAQ,OAAO,UAAU,SACtC,QAAO,OAAO,OAAO,MAAiC,CAAC,KAAK,mBAAmB;AAEhF,QAAO;;;AAIR,SAAgB,mBAAmB,OAAyB;AAC3D,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAO,CAAC,CAAC,MAAM,MAAM,kBAAkB;;;;;;;;AASxC,SAAS,4BAA4B,aAA6B;CACjE,IAAI,QAAQ,YAAY,MAAM,IAA2B,GAA2B;AAEpF,KAAI,MAAM,WAAW,WAAW,CAC/B,SAAQ,MAAM,MAAM,EAAkB;UAC5B,MAAM,WAAW,MAAM,CACjC,SAAQ,MAAM,MAAM,EAAa;UACvB,MAAM,WAAW,KAAK,CAChC,SAAQ,MAAM,MAAM,EAAY;AAGjC,QAAO,MAAM,MAAM;;;;;;;;AASpB,SAAgB,yBAAyB,OAA0B;AAClE,KAAI,OAAO,UAAU,SAAU,QAAO,EAAE;CAExC,MAAMA,SAAmB,EAAE;CAC3B,MAAM,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,IAAI;CACvD,IAAI;AAEJ,SAAQ,QAAQ,MAAM,KAAK,MAAM,MAAM,MAAM;EAC5C,MAAM,QAAQ,4BAA4B,MAAM,GAAG;AACnD,MAAI,MAAM,SAAS,EAClB,QAAO,KAAK,MAAM;;AAIpB,QAAO;;;;;;AAOR,SAAgB,uBAAuB,OAAgB,OAAiB,EAAE,EAAuB;AAChG,KAAI,OAAO,UAAU,SAEpB,QADe,yBAAyB,MAAM,CAChC,KAAK,WAAW;EAAE;EAAM;EAAO,EAAE;AAGhD,KAAI,MAAM,QAAQ,MAAM,CACvB,QAAO,MAAM,SAAS,MAAM,UAAU,uBAAuB,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,GAAG,CAAC,CAAC;AAG7F,KAAI,UAAU,QAAQ,OAAO,UAAU,SACtC,QAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,YAC3C,uBAAuB,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,CAC9C;AAGF,QAAO,EAAE;;;;;;AAOV,SAAgB,sBAAsB,MAAwB;AAC7D,KAAI,KAAK,WAAW,EAAG,QAAO;AAE9B,QAAO,KACL,KAAK,SAAS,UAAW,QAAQ,WAAW,IAAI,IAAI,UAAU,IAAI,UAAU,IAAI,UAAW,CAC3F,KAAK,GAAG"}
@@ -1,14 +0,0 @@
1
- //#region src/placeholder.d.ts
2
- interface PlaceholderDetail {
3
- path: string[];
4
- label: string;
5
- }
6
- declare function isPlaceholderString(value: unknown): boolean;
7
- declare function hasPlaceholderDeep(value: unknown): boolean;
8
- declare function isPlaceholderValue(value: unknown): boolean;
9
- declare function extractPlaceholderLabels(value: unknown): string[];
10
- declare function findPlaceholderDetails(value: unknown, path?: string[]): PlaceholderDetail[];
11
- declare function formatPlaceholderPath(path: string[]): string;
12
- //#endregion
13
- export { hasPlaceholderDeep as a, formatPlaceholderPath as i, extractPlaceholderLabels as n, isPlaceholderString as o, findPlaceholderDetails as r, isPlaceholderValue as s, PlaceholderDetail as t };
14
- //# sourceMappingURL=placeholder2.d.cts.map
@@ -1,14 +0,0 @@
1
- //#region src/placeholder.d.ts
2
- interface PlaceholderDetail {
3
- path: string[];
4
- label: string;
5
- }
6
- declare function isPlaceholderString(value: unknown): boolean;
7
- declare function hasPlaceholderDeep(value: unknown): boolean;
8
- declare function isPlaceholderValue(value: unknown): boolean;
9
- declare function extractPlaceholderLabels(value: unknown): string[];
10
- declare function findPlaceholderDetails(value: unknown, path?: string[]): PlaceholderDetail[];
11
- declare function formatPlaceholderPath(path: string[]): string;
12
- //#endregion
13
- export { hasPlaceholderDeep as a, formatPlaceholderPath as i, extractPlaceholderLabels as n, isPlaceholderString as o, findPlaceholderDetails as r, isPlaceholderValue as s, PlaceholderDetail as t };
14
- //# sourceMappingURL=placeholder2.d.mts.map
@@ -1,75 +0,0 @@
1
- //#region src/placeholder.ts
2
- const PLACEHOLDER_SUFFIX = "__>";
3
- const PLACEHOLDER_VALUE_PREFIX = "<__PLACEHOLDER_VALUE__";
4
- const PLACEHOLDER_REGEX = /<__PLACEHOLDER.*?__>/;
5
- /** Check if a value is a placeholder sentinel string (format: `<__PLACEHOLDER_VALUE__hint__>`). */
6
- function isPlaceholderString(value) {
7
- return typeof value === "string" && value.startsWith(PLACEHOLDER_VALUE_PREFIX) && value.endsWith(PLACEHOLDER_SUFFIX);
8
- }
9
- /** Recursively check if a value (string, array, or object) contains any placeholder sentinel strings. */
10
- function hasPlaceholderDeep(value) {
11
- if (typeof value === "string") return isPlaceholderString(value);
12
- if (Array.isArray(value)) return value.some(hasPlaceholderDeep);
13
- if (value !== null && typeof value === "object") return Object.values(value).some(hasPlaceholderDeep);
14
- return false;
15
- }
16
- /** Checks if a value is a placeholder value (matches the placeholder regex pattern). */
17
- function isPlaceholderValue(value) {
18
- if (typeof value !== "string") return false;
19
- return !!value.match(PLACEHOLDER_REGEX);
20
- }
21
- /**
22
- * Extracts the label from a single placeholder string.
23
- * Handles formats like:
24
- * - <__PLACEHOLDER_VALUE__label__>
25
- * - <__PLACEHOLDER__: label__>
26
- */
27
- function extractLabelFromPlaceholder(placeholder) {
28
- let label = placeholder.slice(14, -3);
29
- if (label.startsWith("_VALUE__")) label = label.slice(8);
30
- else if (label.startsWith("__:")) label = label.slice(3);
31
- else if (label.startsWith("__")) label = label.slice(2);
32
- return label.trim();
33
- }
34
- /**
35
- * Extracts all placeholder labels from a string value.
36
- * Handles both cases where the entire value is a placeholder and where
37
- * placeholders are embedded within code (e.g., Code node).
38
- * Returns an array of labels found.
39
- */
40
- function extractPlaceholderLabels(value) {
41
- if (typeof value !== "string") return [];
42
- const labels = [];
43
- const regex = new RegExp(PLACEHOLDER_REGEX.source, "g");
44
- let match;
45
- while ((match = regex.exec(value)) !== null) {
46
- const label = extractLabelFromPlaceholder(match[0]);
47
- if (label.length > 0) labels.push(label);
48
- }
49
- return labels;
50
- }
51
- /**
52
- * Recursively searches through a value (object, array, or primitive) to find
53
- * all placeholder values and their paths.
54
- */
55
- function findPlaceholderDetails(value, path = []) {
56
- if (typeof value === "string") return extractPlaceholderLabels(value).map((label) => ({
57
- path,
58
- label
59
- }));
60
- if (Array.isArray(value)) return value.flatMap((item, index) => findPlaceholderDetails(item, [...path, `[${index}]`]));
61
- if (value !== null && typeof value === "object") return Object.entries(value).flatMap(([key, nested]) => findPlaceholderDetails(nested, [...path, key]));
62
- return [];
63
- }
64
- /**
65
- * Formats a path array into a dot-notation string for display.
66
- * Array indices are preserved as [N] without leading dots.
67
- */
68
- function formatPlaceholderPath(path) {
69
- if (path.length === 0) return "parameters";
70
- return path.map((segment, index) => segment.startsWith("[") || index === 0 ? segment : `.${segment}`).join("");
71
- }
72
-
73
- //#endregion
74
- export { isPlaceholderString as a, hasPlaceholderDeep as i, findPlaceholderDetails as n, isPlaceholderValue as o, formatPlaceholderPath as r, extractPlaceholderLabels as t };
75
- //# sourceMappingURL=placeholder2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"placeholder2.mjs","names":["labels: string[]"],"sources":["../src/placeholder.ts"],"sourcesContent":["const PLACEHOLDER_PREFIX = '<__PLACEHOLDER';\nconst PLACEHOLDER_SUFFIX = '__>';\nconst PLACEHOLDER_VALUE_PREFIX = '<__PLACEHOLDER_VALUE__';\n\nconst PLACEHOLDER_REGEX = /<__PLACEHOLDER.*?__>/;\n\nexport interface PlaceholderDetail {\n\tpath: string[];\n\tlabel: string;\n}\n\n/** Check if a value is a placeholder sentinel string (format: `<__PLACEHOLDER_VALUE__hint__>`). */\nexport function isPlaceholderString(value: unknown): boolean {\n\treturn (\n\t\ttypeof value === 'string' &&\n\t\tvalue.startsWith(PLACEHOLDER_VALUE_PREFIX) &&\n\t\tvalue.endsWith(PLACEHOLDER_SUFFIX)\n\t);\n}\n\n/** Recursively check if a value (string, array, or object) contains any placeholder sentinel strings. */\nexport function hasPlaceholderDeep(value: unknown): boolean {\n\tif (typeof value === 'string') return isPlaceholderString(value);\n\tif (Array.isArray(value)) return value.some(hasPlaceholderDeep);\n\tif (value !== null && typeof value === 'object') {\n\t\treturn Object.values(value as Record<string, unknown>).some(hasPlaceholderDeep);\n\t}\n\treturn false;\n}\n\n/** Checks if a value is a placeholder value (matches the placeholder regex pattern). */\nexport function isPlaceholderValue(value: unknown): boolean {\n\tif (typeof value !== 'string') return false;\n\treturn !!value.match(PLACEHOLDER_REGEX);\n}\n\n/**\n * Extracts the label from a single placeholder string.\n * Handles formats like:\n * - <__PLACEHOLDER_VALUE__label__>\n * - <__PLACEHOLDER__: label__>\n */\nfunction extractLabelFromPlaceholder(placeholder: string): string {\n\tlet label = placeholder.slice(PLACEHOLDER_PREFIX.length, -PLACEHOLDER_SUFFIX.length);\n\n\tif (label.startsWith('_VALUE__')) {\n\t\tlabel = label.slice('_VALUE__'.length);\n\t} else if (label.startsWith('__:')) {\n\t\tlabel = label.slice('__:'.length);\n\t} else if (label.startsWith('__')) {\n\t\tlabel = label.slice('__'.length);\n\t}\n\n\treturn label.trim();\n}\n\n/**\n * Extracts all placeholder labels from a string value.\n * Handles both cases where the entire value is a placeholder and where\n * placeholders are embedded within code (e.g., Code node).\n * Returns an array of labels found.\n */\nexport function extractPlaceholderLabels(value: unknown): string[] {\n\tif (typeof value !== 'string') return [];\n\n\tconst labels: string[] = [];\n\tconst regex = new RegExp(PLACEHOLDER_REGEX.source, 'g');\n\tlet match;\n\n\twhile ((match = regex.exec(value)) !== null) {\n\t\tconst label = extractLabelFromPlaceholder(match[0]);\n\t\tif (label.length > 0) {\n\t\t\tlabels.push(label);\n\t\t}\n\t}\n\n\treturn labels;\n}\n\n/**\n * Recursively searches through a value (object, array, or primitive) to find\n * all placeholder values and their paths.\n */\nexport function findPlaceholderDetails(value: unknown, path: string[] = []): PlaceholderDetail[] {\n\tif (typeof value === 'string') {\n\t\tconst labels = extractPlaceholderLabels(value);\n\t\treturn labels.map((label) => ({ path, label }));\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value.flatMap((item, index) => findPlaceholderDetails(item, [...path, `[${index}]`]));\n\t}\n\n\tif (value !== null && typeof value === 'object') {\n\t\treturn Object.entries(value).flatMap(([key, nested]) =>\n\t\t\tfindPlaceholderDetails(nested, [...path, key]),\n\t\t);\n\t}\n\n\treturn [];\n}\n\n/**\n * Formats a path array into a dot-notation string for display.\n * Array indices are preserved as [N] without leading dots.\n */\nexport function formatPlaceholderPath(path: string[]): string {\n\tif (path.length === 0) return 'parameters';\n\n\treturn path\n\t\t.map((segment, index) => (segment.startsWith('[') || index === 0 ? segment : `.${segment}`))\n\t\t.join('');\n}\n"],"mappings":";AACA,MAAM,qBAAqB;AAC3B,MAAM,2BAA2B;AAEjC,MAAM,oBAAoB;;AAQ1B,SAAgB,oBAAoB,OAAyB;AAC5D,QACC,OAAO,UAAU,YACjB,MAAM,WAAW,yBAAyB,IAC1C,MAAM,SAAS,mBAAmB;;;AAKpC,SAAgB,mBAAmB,OAAyB;AAC3D,KAAI,OAAO,UAAU,SAAU,QAAO,oBAAoB,MAAM;AAChE,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,KAAK,mBAAmB;AAC/D,KAAI,UAAU,QAAQ,OAAO,UAAU,SACtC,QAAO,OAAO,OAAO,MAAiC,CAAC,KAAK,mBAAmB;AAEhF,QAAO;;;AAIR,SAAgB,mBAAmB,OAAyB;AAC3D,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAO,CAAC,CAAC,MAAM,MAAM,kBAAkB;;;;;;;;AASxC,SAAS,4BAA4B,aAA6B;CACjE,IAAI,QAAQ,YAAY,MAAM,IAA2B,GAA2B;AAEpF,KAAI,MAAM,WAAW,WAAW,CAC/B,SAAQ,MAAM,MAAM,EAAkB;UAC5B,MAAM,WAAW,MAAM,CACjC,SAAQ,MAAM,MAAM,EAAa;UACvB,MAAM,WAAW,KAAK,CAChC,SAAQ,MAAM,MAAM,EAAY;AAGjC,QAAO,MAAM,MAAM;;;;;;;;AASpB,SAAgB,yBAAyB,OAA0B;AAClE,KAAI,OAAO,UAAU,SAAU,QAAO,EAAE;CAExC,MAAMA,SAAmB,EAAE;CAC3B,MAAM,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,IAAI;CACvD,IAAI;AAEJ,SAAQ,QAAQ,MAAM,KAAK,MAAM,MAAM,MAAM;EAC5C,MAAM,QAAQ,4BAA4B,MAAM,GAAG;AACnD,MAAI,MAAM,SAAS,EAClB,QAAO,KAAK,MAAM;;AAIpB,QAAO;;;;;;AAOR,SAAgB,uBAAuB,OAAgB,OAAiB,EAAE,EAAuB;AAChG,KAAI,OAAO,UAAU,SAEpB,QADe,yBAAyB,MAAM,CAChC,KAAK,WAAW;EAAE;EAAM;EAAO,EAAE;AAGhD,KAAI,MAAM,QAAQ,MAAM,CACvB,QAAO,MAAM,SAAS,MAAM,UAAU,uBAAuB,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,GAAG,CAAC,CAAC;AAG7F,KAAI,UAAU,QAAQ,OAAO,UAAU,SACtC,QAAO,OAAO,QAAQ,MAAM,CAAC,SAAS,CAAC,KAAK,YAC3C,uBAAuB,QAAQ,CAAC,GAAG,MAAM,IAAI,CAAC,CAC9C;AAGF,QAAO,EAAE;;;;;;AAOV,SAAgB,sBAAsB,MAAwB;AAC7D,KAAI,KAAK,WAAW,EAAG,QAAO;AAE9B,QAAO,KACL,KAAK,SAAS,UAAW,QAAQ,WAAW,IAAI,IAAI,UAAU,IAAI,UAAU,IAAI,UAAW,CAC3F,KAAK,GAAG"}
@@ -1,25 +0,0 @@
1
-
2
- //#region src/search/re-rank-search-results.ts
3
- function reRankSearchResults(searchResults, additionalFactors) {
4
- return searchResults.map(({ score, item }) => {
5
- return {
6
- score: score + Object.entries(additionalFactors).reduce((acc, [_, factorScores]) => {
7
- const factorScore = factorScores[item.key];
8
- if (factorScore) return acc + factorScore;
9
- return acc;
10
- }, 0),
11
- item
12
- };
13
- }).sort((a, b) => {
14
- return b.score - a.score;
15
- });
16
- }
17
-
18
- //#endregion
19
- Object.defineProperty(exports, 'reRankSearchResults', {
20
- enumerable: true,
21
- get: function () {
22
- return reRankSearchResults;
23
- }
24
- });
25
- //# sourceMappingURL=re-rank-search-results.cjs.map
@@ -1 +0,0 @@
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,13 +0,0 @@
1
- //#region src/search/re-rank-search-results.d.ts
2
- declare function reRankSearchResults<T extends {
3
- key: string;
4
- }>(searchResults: Array<{
5
- score: number;
6
- item: T;
7
- }>, additionalFactors: Record<string, Record<string, number>>): Array<{
8
- score: number;
9
- item: T;
10
- }>;
11
- //#endregion
12
- export { reRankSearchResults as t };
13
- //# sourceMappingURL=re-rank-search-results.d.cts.map
@@ -1,13 +0,0 @@
1
- //#region src/search/re-rank-search-results.d.ts
2
- declare function reRankSearchResults<T extends {
3
- key: string;
4
- }>(searchResults: Array<{
5
- score: number;
6
- item: T;
7
- }>, additionalFactors: Record<string, Record<string, number>>): Array<{
8
- score: number;
9
- item: T;
10
- }>;
11
- //#endregion
12
- export { reRankSearchResults as t };
13
- //# sourceMappingURL=re-rank-search-results.d.mts.map
@@ -1,19 +0,0 @@
1
- //#region src/search/re-rank-search-results.ts
2
- function reRankSearchResults(searchResults, additionalFactors) {
3
- return searchResults.map(({ score, item }) => {
4
- return {
5
- score: score + Object.entries(additionalFactors).reduce((acc, [_, factorScores]) => {
6
- const factorScore = factorScores[item.key];
7
- if (factorScore) return acc + factorScore;
8
- return acc;
9
- }, 0),
10
- item
11
- };
12
- }).sort((a, b) => {
13
- return b.score - a.score;
14
- });
15
- }
16
-
17
- //#endregion
18
- export { reRankSearchResults as t };
19
- //# sourceMappingURL=re-rank-search-results.mjs.map
@@ -1 +0,0 @@
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"}
package/dist/retry2.cjs DELETED
@@ -1,45 +0,0 @@
1
-
2
- //#region src/retry.ts
3
- /**
4
- * A utility that retries a function every `interval` milliseconds
5
- * until the function returns true or the maximum number of retries is reached.
6
- *
7
- * @param fn - A function that returns a boolean or a Promise resolving to a boolean.
8
- * @param interval - The time interval (in milliseconds) between each retry. Defaults to 1000.
9
- * @param maxRetries - The maximum number of retry attempts. Defaults to 3.
10
- * @param backoff - The backoff strategy to use: 'linear', 'exponential', or null.
11
- * @returns {Promise<boolean>} - A promise that resolves to:
12
- * - true: If the function returns true before reaching maxRetries.
13
- * - false: If the function never returns true or if an error occurs.
14
- */
15
- async function retry(fn, interval = 1e3, maxRetries = 3, backoff = "linear") {
16
- let attempt = 0;
17
- while (attempt < maxRetries) {
18
- attempt++;
19
- try {
20
- if (await fn()) return true;
21
- } catch (error) {
22
- console.error("Error during retry:", error);
23
- throw error;
24
- }
25
- if (attempt < maxRetries) {
26
- let computedInterval = interval;
27
- if (backoff === "linear") computedInterval = interval * attempt;
28
- else if (backoff === "exponential") {
29
- computedInterval = Math.pow(2, attempt - 1) * interval;
30
- computedInterval = Math.min(computedInterval, 3e4);
31
- }
32
- await new Promise((resolve) => setTimeout(resolve, computedInterval));
33
- }
34
- }
35
- return false;
36
- }
37
-
38
- //#endregion
39
- Object.defineProperty(exports, 'retry', {
40
- enumerable: true,
41
- get: function () {
42
- return retry;
43
- }
44
- });
45
- //# sourceMappingURL=retry2.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry2.cjs","names":[],"sources":["../src/retry.ts"],"sourcesContent":["type RetryFn = () => boolean | Promise<boolean>;\n\n/**\n * A utility that retries a function every `interval` milliseconds\n * until the function returns true or the maximum number of retries is reached.\n *\n * @param fn - A function that returns a boolean or a Promise resolving to a boolean.\n * @param interval - The time interval (in milliseconds) between each retry. Defaults to 1000.\n * @param maxRetries - The maximum number of retry attempts. Defaults to 3.\n * @param backoff - The backoff strategy to use: 'linear', 'exponential', or null.\n * @returns {Promise<boolean>} - A promise that resolves to:\n * - true: If the function returns true before reaching maxRetries.\n * - false: If the function never returns true or if an error occurs.\n */\nexport async function retry(\n\tfn: RetryFn,\n\tinterval: number = 1000,\n\tmaxRetries: number = 3,\n\tbackoff: 'exponential' | 'linear' | null = 'linear',\n): Promise<boolean> {\n\tlet attempt = 0;\n\n\twhile (attempt < maxRetries) {\n\t\tattempt++;\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tif (result) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Error during retry:', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Wait for the specified interval before the next attempt, if any attempts remain.\n\t\tif (attempt < maxRetries) {\n\t\t\tlet computedInterval = interval;\n\n\t\t\tif (backoff === 'linear') {\n\t\t\t\tcomputedInterval = interval * attempt;\n\t\t\t} else if (backoff === 'exponential') {\n\t\t\t\tcomputedInterval = Math.pow(2, attempt - 1) * interval;\n\t\t\t\tcomputedInterval = Math.min(computedInterval, 30000); // Cap the maximum interval to 30 seconds\n\t\t\t}\n\n\t\t\tawait new Promise<void>((resolve) => setTimeout(resolve, computedInterval));\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,eAAsB,MACrB,IACA,WAAmB,KACnB,aAAqB,GACrB,UAA2C,UACxB;CACnB,IAAI,UAAU;AAEd,QAAO,UAAU,YAAY;AAC5B;AACA,MAAI;AAEH,OADe,MAAM,IAAI,CAExB,QAAO;WAEA,OAAO;AACf,WAAQ,MAAM,uBAAuB,MAAM;AAC3C,SAAM;;AAIP,MAAI,UAAU,YAAY;GACzB,IAAI,mBAAmB;AAEvB,OAAI,YAAY,SACf,oBAAmB,WAAW;YACpB,YAAY,eAAe;AACrC,uBAAmB,KAAK,IAAI,GAAG,UAAU,EAAE,GAAG;AAC9C,uBAAmB,KAAK,IAAI,kBAAkB,IAAM;;AAGrD,SAAM,IAAI,SAAe,YAAY,WAAW,SAAS,iBAAiB,CAAC;;;AAI7E,QAAO"}
package/dist/retry2.d.cts DELETED
@@ -1,6 +0,0 @@
1
- //#region src/retry.d.ts
2
- type RetryFn = () => boolean | Promise<boolean>;
3
- declare function retry(fn: RetryFn, interval?: number, maxRetries?: number, backoff?: 'exponential' | 'linear' | null): Promise<boolean>;
4
- //#endregion
5
- export { retry as t };
6
- //# sourceMappingURL=retry2.d.cts.map
package/dist/retry2.d.mts DELETED
@@ -1,6 +0,0 @@
1
- //#region src/retry.d.ts
2
- type RetryFn = () => boolean | Promise<boolean>;
3
- declare function retry(fn: RetryFn, interval?: number, maxRetries?: number, backoff?: 'exponential' | 'linear' | null): Promise<boolean>;
4
- //#endregion
5
- export { retry as t };
6
- //# sourceMappingURL=retry2.d.mts.map
package/dist/retry2.mjs DELETED
@@ -1,39 +0,0 @@
1
- //#region src/retry.ts
2
- /**
3
- * A utility that retries a function every `interval` milliseconds
4
- * until the function returns true or the maximum number of retries is reached.
5
- *
6
- * @param fn - A function that returns a boolean or a Promise resolving to a boolean.
7
- * @param interval - The time interval (in milliseconds) between each retry. Defaults to 1000.
8
- * @param maxRetries - The maximum number of retry attempts. Defaults to 3.
9
- * @param backoff - The backoff strategy to use: 'linear', 'exponential', or null.
10
- * @returns {Promise<boolean>} - A promise that resolves to:
11
- * - true: If the function returns true before reaching maxRetries.
12
- * - false: If the function never returns true or if an error occurs.
13
- */
14
- async function retry(fn, interval = 1e3, maxRetries = 3, backoff = "linear") {
15
- let attempt = 0;
16
- while (attempt < maxRetries) {
17
- attempt++;
18
- try {
19
- if (await fn()) return true;
20
- } catch (error) {
21
- console.error("Error during retry:", error);
22
- throw error;
23
- }
24
- if (attempt < maxRetries) {
25
- let computedInterval = interval;
26
- if (backoff === "linear") computedInterval = interval * attempt;
27
- else if (backoff === "exponential") {
28
- computedInterval = Math.pow(2, attempt - 1) * interval;
29
- computedInterval = Math.min(computedInterval, 3e4);
30
- }
31
- await new Promise((resolve) => setTimeout(resolve, computedInterval));
32
- }
33
- }
34
- return false;
35
- }
36
-
37
- //#endregion
38
- export { retry as t };
39
- //# sourceMappingURL=retry2.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"retry2.mjs","names":[],"sources":["../src/retry.ts"],"sourcesContent":["type RetryFn = () => boolean | Promise<boolean>;\n\n/**\n * A utility that retries a function every `interval` milliseconds\n * until the function returns true or the maximum number of retries is reached.\n *\n * @param fn - A function that returns a boolean or a Promise resolving to a boolean.\n * @param interval - The time interval (in milliseconds) between each retry. Defaults to 1000.\n * @param maxRetries - The maximum number of retry attempts. Defaults to 3.\n * @param backoff - The backoff strategy to use: 'linear', 'exponential', or null.\n * @returns {Promise<boolean>} - A promise that resolves to:\n * - true: If the function returns true before reaching maxRetries.\n * - false: If the function never returns true or if an error occurs.\n */\nexport async function retry(\n\tfn: RetryFn,\n\tinterval: number = 1000,\n\tmaxRetries: number = 3,\n\tbackoff: 'exponential' | 'linear' | null = 'linear',\n): Promise<boolean> {\n\tlet attempt = 0;\n\n\twhile (attempt < maxRetries) {\n\t\tattempt++;\n\t\ttry {\n\t\t\tconst result = await fn();\n\t\t\tif (result) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconsole.error('Error during retry:', error);\n\t\t\tthrow error;\n\t\t}\n\n\t\t// Wait for the specified interval before the next attempt, if any attempts remain.\n\t\tif (attempt < maxRetries) {\n\t\t\tlet computedInterval = interval;\n\n\t\t\tif (backoff === 'linear') {\n\t\t\t\tcomputedInterval = interval * attempt;\n\t\t\t} else if (backoff === 'exponential') {\n\t\t\t\tcomputedInterval = Math.pow(2, attempt - 1) * interval;\n\t\t\t\tcomputedInterval = Math.min(computedInterval, 30000); // Cap the maximum interval to 30 seconds\n\t\t\t}\n\n\t\t\tawait new Promise<void>((resolve) => setTimeout(resolve, computedInterval));\n\t\t}\n\t}\n\n\treturn false;\n}\n"],"mappings":";;;;;;;;;;;;;AAcA,eAAsB,MACrB,IACA,WAAmB,KACnB,aAAqB,GACrB,UAA2C,UACxB;CACnB,IAAI,UAAU;AAEd,QAAO,UAAU,YAAY;AAC5B;AACA,MAAI;AAEH,OADe,MAAM,IAAI,CAExB,QAAO;WAEA,OAAO;AACf,WAAQ,MAAM,uBAAuB,MAAM;AAC3C,SAAM;;AAIP,MAAI,UAAU,YAAY;GACzB,IAAI,mBAAmB;AAEvB,OAAI,YAAY,SACf,oBAAmB,WAAW;YACpB,YAAY,eAAe;AACrC,uBAAmB,KAAK,IAAI,GAAG,UAAU,EAAE,GAAG;AAC9C,uBAAmB,KAAK,IAAI,kBAAkB,IAAM;;AAGrD,SAAM,IAAI,SAAe,YAAY,WAAW,SAAS,iBAAiB,CAAC;;;AAI7E,QAAO"}
@@ -1,67 +0,0 @@
1
-
2
- //#region src/files/sanitize-filename.ts
3
- const INVALID_CHARS_REGEX = /[<>:"/\\|?*\u0000-\u001F\u007F-\u009F]/g;
4
- const ZERO_WIDTH_CHARS_REGEX = /[\u200B-\u200D\u2060\uFEFF]/g;
5
- const UNICODE_SPACES_REGEX = /[\u00A0\u2000-\u200A]/g;
6
- const LEADING_TRAILING_DOTS_SPACES_REGEX = /^[\s.]+|[\s.]+$/g;
7
- const WINDOWS_RESERVED_NAMES = new Set([
8
- "CON",
9
- "PRN",
10
- "AUX",
11
- "NUL",
12
- "COM1",
13
- "COM2",
14
- "COM3",
15
- "COM4",
16
- "COM5",
17
- "COM6",
18
- "COM7",
19
- "COM8",
20
- "COM9",
21
- "LPT1",
22
- "LPT2",
23
- "LPT3",
24
- "LPT4",
25
- "LPT5",
26
- "LPT6",
27
- "LPT7",
28
- "LPT8",
29
- "LPT9"
30
- ]);
31
- const DEFAULT_FALLBACK_NAME = "untitled";
32
- const MAX_FILENAME_LENGTH = 200;
33
- /**
34
- * Sanitizes a filename to be compatible with Mac, Linux, and Windows file systems
35
- *
36
- * Main features:
37
- * - Replace invalid characters (e.g. ":" in hello:world)
38
- * - Handle Windows reserved names
39
- * - Limit filename length
40
- * - Normalize Unicode characters
41
- *
42
- * @param filename - The filename to sanitize (without extension)
43
- * @param maxLength - Maximum filename length (default: 200)
44
- * @returns A sanitized filename (without extension)
45
- *
46
- * @example
47
- * sanitizeFilename('hello:world') // returns 'hello_world'
48
- * sanitizeFilename('CON') // returns '_CON'
49
- * sanitizeFilename('') // returns 'untitled'
50
- */
51
- const sanitizeFilename = (filename, maxLength = MAX_FILENAME_LENGTH) => {
52
- if (!filename) return DEFAULT_FALLBACK_NAME;
53
- let baseName = filename.trim().replace(INVALID_CHARS_REGEX, "_").replace(ZERO_WIDTH_CHARS_REGEX, "").replace(UNICODE_SPACES_REGEX, " ").replace(LEADING_TRAILING_DOTS_SPACES_REGEX, "");
54
- if (!baseName) baseName = DEFAULT_FALLBACK_NAME;
55
- if (WINDOWS_RESERVED_NAMES.has(baseName.toUpperCase())) baseName = `_${baseName}`;
56
- if (baseName.length > maxLength) baseName = baseName.slice(0, maxLength);
57
- return baseName;
58
- };
59
-
60
- //#endregion
61
- Object.defineProperty(exports, 'sanitizeFilename', {
62
- enumerable: true,
63
- get: function () {
64
- return sanitizeFilename;
65
- }
66
- });
67
- //# sourceMappingURL=sanitize-filename.cjs.map