@n8n/utils 1.39.0 → 1.40.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/assert.cjs +2 -2
- package/dist/assert.cjs.map +1 -1
- package/dist/assert.mjs +1 -1
- package/dist/assert.mjs.map +1 -1
- package/dist/client-assertion.cjs +3 -3
- package/dist/client-assertion.cjs.map +1 -1
- package/dist/client-assertion.mjs +2 -3
- package/dist/client-assertion.mjs.map +1 -1
- package/dist/create-event-queue.cjs +2 -2
- package/dist/create-event-queue.cjs.map +1 -1
- package/dist/create-event-queue.mjs +1 -1
- package/dist/create-event-queue.mjs.map +1 -1
- package/dist/errors/ensure-error.cjs +9 -2
- package/dist/errors/ensure-error.cjs.map +1 -0
- package/dist/errors/ensure-error.mjs +8 -2
- package/dist/errors/ensure-error.mjs.map +1 -0
- package/dist/event-bus.cjs +2 -2
- package/dist/event-bus.cjs.map +1 -1
- package/dist/event-bus.d.cts +1 -1
- package/dist/event-bus.d.mts +1 -1
- package/dist/event-bus.mjs +1 -1
- package/dist/event-bus.mjs.map +1 -1
- package/dist/files/is-windows-file-path.cjs +2 -2
- package/dist/files/is-windows-file-path.cjs.map +1 -1
- package/dist/files/is-windows-file-path.mjs +1 -1
- package/dist/files/is-windows-file-path.mjs.map +1 -1
- package/dist/files/sanitize-filename.cjs +3 -3
- package/dist/files/sanitize-filename.cjs.map +1 -1
- package/dist/files/sanitize-filename.mjs +2 -2
- package/dist/files/sanitize-filename.mjs.map +1 -1
- package/dist/format-pem-block.cjs +41 -2
- package/dist/format-pem-block.cjs.map +1 -0
- package/dist/format-pem-block.mjs +40 -2
- package/dist/format-pem-block.mjs.map +1 -0
- package/dist/generate-nano-id.cjs +4 -5
- package/dist/generate-nano-id.cjs.map +1 -1
- package/dist/generate-nano-id.mjs +1 -2
- package/dist/generate-nano-id.mjs.map +1 -1
- package/dist/get-jwt-expiry.cjs +2 -2
- package/dist/get-jwt-expiry.cjs.map +1 -1
- package/dist/get-jwt-expiry.mjs +1 -1
- package/dist/get-jwt-expiry.mjs.map +1 -1
- package/dist/is-record.cjs +2 -2
- package/dist/is-record.cjs.map +1 -1
- package/dist/is-record.mjs +1 -1
- package/dist/is-record.mjs.map +1 -1
- package/dist/lazy-import.cjs +23 -0
- package/dist/lazy-import.cjs.map +1 -0
- package/dist/lazy-import.d.cts +5 -0
- package/dist/lazy-import.d.mts +5 -0
- package/dist/lazy-import.mjs +22 -0
- package/dist/lazy-import.mjs.map +1 -0
- package/dist/number/smart-decimal.cjs +2 -2
- package/dist/number/smart-decimal.cjs.map +1 -1
- package/dist/number/smart-decimal.mjs +1 -1
- package/dist/number/smart-decimal.mjs.map +1 -1
- package/dist/placeholder.cjs +2 -2
- package/dist/placeholder.cjs.map +1 -1
- package/dist/placeholder.mjs +1 -1
- package/dist/placeholder.mjs.map +1 -1
- package/dist/promise/deferred-promise.cjs +2 -2
- package/dist/promise/deferred-promise.cjs.map +1 -1
- package/dist/promise/deferred-promise.mjs +1 -1
- package/dist/promise/deferred-promise.mjs.map +1 -1
- package/dist/result.cjs +5 -4
- package/dist/result.cjs.map +1 -1
- package/dist/result.mjs +4 -4
- package/dist/result.mjs.map +1 -1
- package/dist/retry.cjs +2 -2
- package/dist/retry.cjs.map +1 -1
- package/dist/retry.mjs +1 -1
- package/dist/retry.mjs.map +1 -1
- package/dist/scrub-secrets.cjs +2 -2
- package/dist/scrub-secrets.cjs.map +1 -1
- package/dist/scrub-secrets.mjs +1 -1
- package/dist/scrub-secrets.mjs.map +1 -1
- package/dist/search/re-rank-search-results.cjs +2 -2
- package/dist/search/re-rank-search-results.cjs.map +1 -1
- package/dist/search/re-rank-search-results.mjs +1 -1
- package/dist/search/re-rank-search-results.mjs.map +1 -1
- package/dist/search/sublime-search.cjs +2 -2
- package/dist/search/sublime-search.cjs.map +1 -1
- package/dist/search/sublime-search.mjs +1 -1
- package/dist/search/sublime-search.mjs.map +1 -1
- package/dist/sort/sort-by-property.cjs +2 -2
- package/dist/sort/sort-by-property.cjs.map +1 -1
- package/dist/sort/sort-by-property.d.cts +1 -1
- package/dist/sort/sort-by-property.d.mts +1 -1
- package/dist/sort/sort-by-property.mjs +1 -1
- package/dist/sort/sort-by-property.mjs.map +1 -1
- package/dist/string/truncate.cjs +2 -2
- package/dist/string/truncate.cjs.map +1 -1
- package/dist/string/truncate.mjs +1 -1
- package/dist/string/truncate.mjs.map +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +7 -7
- package/dist/ensure-error.cjs +0 -15
- package/dist/ensure-error.cjs.map +0 -1
- package/dist/ensure-error.mjs +0 -9
- package/dist/ensure-error.mjs.map +0 -1
- package/dist/format-pem-block2.cjs +0 -47
- package/dist/format-pem-block2.cjs.map +0 -1
- package/dist/format-pem-block2.mjs +0 -41
- package/dist/format-pem-block2.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-jwt-expiry.cjs","names":[],"sources":["../src/get-jwt-expiry.ts"],"sourcesContent":["/**\n * Decode the payload of a JWT without verifying the signature.\n * Returns the `exp` claim (seconds since epoch) or undefined.\n *\n * Use only for trusted tokens (e.g. ones we just received from our own proxy)\n * where the goal is scheduling refresh, not authenticating the issuer.\n */\nexport function getJwtExpiry(jwt: string): number | undefined {\n\tconst parts = jwt.split('.');\n\tif (parts.length !== 3) return undefined;\n\ttry {\n\t\tconst payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString()) as {\n\t\t\texp?: number;\n\t\t};\n\t\treturn typeof payload.exp === 'number' ? payload.exp : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,aAAa,KAAiC;CAC7D,MAAM,QAAQ,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"get-jwt-expiry.cjs","names":[],"sources":["../src/get-jwt-expiry.ts"],"sourcesContent":["/**\n * Decode the payload of a JWT without verifying the signature.\n * Returns the `exp` claim (seconds since epoch) or undefined.\n *\n * Use only for trusted tokens (e.g. ones we just received from our own proxy)\n * where the goal is scheduling refresh, not authenticating the issuer.\n */\nexport function getJwtExpiry(jwt: string): number | undefined {\n\tconst parts = jwt.split('.');\n\tif (parts.length !== 3) return undefined;\n\ttry {\n\t\tconst payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString()) as {\n\t\t\texp?: number;\n\t\t};\n\t\treturn typeof payload.exp === 'number' ? payload.exp : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;;AAOA,SAAgB,aAAa,KAAiC;CAC7D,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;CAC/B,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI,WAAW,CAAC,CAAC,SAAS,CAAC;EAGxE,OAAO,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM,KAAA;CACxD,QAAQ;EACP;CACD;AACD"}
|
package/dist/get-jwt-expiry.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-jwt-expiry.mjs","names":[],"sources":["../src/get-jwt-expiry.ts"],"sourcesContent":["/**\n * Decode the payload of a JWT without verifying the signature.\n * Returns the `exp` claim (seconds since epoch) or undefined.\n *\n * Use only for trusted tokens (e.g. ones we just received from our own proxy)\n * where the goal is scheduling refresh, not authenticating the issuer.\n */\nexport function getJwtExpiry(jwt: string): number | undefined {\n\tconst parts = jwt.split('.');\n\tif (parts.length !== 3) return undefined;\n\ttry {\n\t\tconst payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString()) as {\n\t\t\texp?: number;\n\t\t};\n\t\treturn typeof payload.exp === 'number' ? payload.exp : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,aAAa,KAAiC;CAC7D,MAAM,QAAQ,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"get-jwt-expiry.mjs","names":[],"sources":["../src/get-jwt-expiry.ts"],"sourcesContent":["/**\n * Decode the payload of a JWT without verifying the signature.\n * Returns the `exp` claim (seconds since epoch) or undefined.\n *\n * Use only for trusted tokens (e.g. ones we just received from our own proxy)\n * where the goal is scheduling refresh, not authenticating the issuer.\n */\nexport function getJwtExpiry(jwt: string): number | undefined {\n\tconst parts = jwt.split('.');\n\tif (parts.length !== 3) return undefined;\n\ttry {\n\t\tconst payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString()) as {\n\t\t\texp?: number;\n\t\t};\n\t\treturn typeof payload.exp === 'number' ? payload.exp : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,aAAa,KAAiC;CAC7D,MAAM,QAAQ,IAAI,MAAM,GAAG;CAC3B,IAAI,MAAM,WAAW,GAAG,OAAO,KAAA;CAC/B,IAAI;EACH,MAAM,UAAU,KAAK,MAAM,OAAO,KAAK,MAAM,IAAI,WAAW,CAAC,CAAC,SAAS,CAAC;EAGxE,OAAO,OAAO,QAAQ,QAAQ,WAAW,QAAQ,MAAM,KAAA;CACxD,QAAQ;EACP;CACD;AACD"}
|
package/dist/is-record.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/is-record.ts
|
|
3
3
|
function isRecord(value) {
|
|
4
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
//#endregion
|
|
8
7
|
exports.isRecord = isRecord;
|
|
8
|
+
|
|
9
9
|
//# sourceMappingURL=is-record.cjs.map
|
package/dist/is-record.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-record.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;
|
|
1
|
+
{"version":3,"file":"is-record.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;CAC1E,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E"}
|
package/dist/is-record.mjs
CHANGED
package/dist/is-record.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-record.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;
|
|
1
|
+
{"version":3,"file":"is-record.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;CAC1E,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC3E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/lazy-import.ts
|
|
3
|
+
/**
|
|
4
|
+
* Lazily `import()` a dual-published (ESM + CJS) dependency while keeping the
|
|
5
|
+
* `require`-condition types the rest of a CommonJS / NodeNext package resolves
|
|
6
|
+
* via top-level `import type`.
|
|
7
|
+
*
|
|
8
|
+
* Under `moduleResolution: NodeNext` a top-level `import type { X } from 'pkg'`
|
|
9
|
+
* in a CommonJS module resolves `pkg`'s `require`-condition declarations
|
|
10
|
+
* (`.d.cts`), while `await import('pkg')` resolves the `import`-condition
|
|
11
|
+
* declarations (`.d.ts`); TypeScript treats the two identically-named types as
|
|
12
|
+
* unrelated. Pass the module namespace type (via `import type * as NS`) as `T`
|
|
13
|
+
* and the returned value is typed as the same declaration copy the callers use.
|
|
14
|
+
*
|
|
15
|
+
* @param loader thunk performing the dynamic import, e.g. `() => import('pkg')`
|
|
16
|
+
*/
|
|
17
|
+
async function lazyImport(loader) {
|
|
18
|
+
return await loader();
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.lazyImport = lazyImport;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=lazy-import.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-import.cjs","names":[],"sources":["../src/lazy-import.ts"],"sourcesContent":["/**\n * Lazily `import()` a dual-published (ESM + CJS) dependency while keeping the\n * `require`-condition types the rest of a CommonJS / NodeNext package resolves\n * via top-level `import type`.\n *\n * Under `moduleResolution: NodeNext` a top-level `import type { X } from 'pkg'`\n * in a CommonJS module resolves `pkg`'s `require`-condition declarations\n * (`.d.cts`), while `await import('pkg')` resolves the `import`-condition\n * declarations (`.d.ts`); TypeScript treats the two identically-named types as\n * unrelated. Pass the module namespace type (via `import type * as NS`) as `T`\n * and the returned value is typed as the same declaration copy the callers use.\n *\n * @param loader thunk performing the dynamic import, e.g. `() => import('pkg')`\n */\nexport async function lazyImport<T>(loader: () => Promise<unknown>): Promise<T> {\n\treturn (await loader()) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,eAAsB,WAAc,QAA4C;CAC/E,OAAQ,MAAM,OAAO;AACtB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/lazy-import.ts
|
|
2
|
+
/**
|
|
3
|
+
* Lazily `import()` a dual-published (ESM + CJS) dependency while keeping the
|
|
4
|
+
* `require`-condition types the rest of a CommonJS / NodeNext package resolves
|
|
5
|
+
* via top-level `import type`.
|
|
6
|
+
*
|
|
7
|
+
* Under `moduleResolution: NodeNext` a top-level `import type { X } from 'pkg'`
|
|
8
|
+
* in a CommonJS module resolves `pkg`'s `require`-condition declarations
|
|
9
|
+
* (`.d.cts`), while `await import('pkg')` resolves the `import`-condition
|
|
10
|
+
* declarations (`.d.ts`); TypeScript treats the two identically-named types as
|
|
11
|
+
* unrelated. Pass the module namespace type (via `import type * as NS`) as `T`
|
|
12
|
+
* and the returned value is typed as the same declaration copy the callers use.
|
|
13
|
+
*
|
|
14
|
+
* @param loader thunk performing the dynamic import, e.g. `() => import('pkg')`
|
|
15
|
+
*/
|
|
16
|
+
async function lazyImport(loader) {
|
|
17
|
+
return await loader();
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { lazyImport };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=lazy-import.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-import.mjs","names":[],"sources":["../src/lazy-import.ts"],"sourcesContent":["/**\n * Lazily `import()` a dual-published (ESM + CJS) dependency while keeping the\n * `require`-condition types the rest of a CommonJS / NodeNext package resolves\n * via top-level `import type`.\n *\n * Under `moduleResolution: NodeNext` a top-level `import type { X } from 'pkg'`\n * in a CommonJS module resolves `pkg`'s `require`-condition declarations\n * (`.d.cts`), while `await import('pkg')` resolves the `import`-condition\n * declarations (`.d.ts`); TypeScript treats the two identically-named types as\n * unrelated. Pass the module namespace type (via `import type * as NS`) as `T`\n * and the returned value is typed as the same declaration copy the callers use.\n *\n * @param loader thunk performing the dynamic import, e.g. `() => import('pkg')`\n */\nexport async function lazyImport<T>(loader: () => Promise<unknown>): Promise<T> {\n\treturn (await loader()) as T;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,eAAsB,WAAc,QAA4C;CAC/E,OAAQ,MAAM,OAAO;AACtB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
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;
|
|
6
6
|
return Number(value.toFixed(decimals));
|
|
7
7
|
};
|
|
8
|
-
|
|
9
8
|
//#endregion
|
|
10
9
|
exports.smartDecimal = smartDecimal;
|
|
10
|
+
|
|
11
11
|
//# sourceMappingURL=smart-decimal.cjs.map
|
|
@@ -1 +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;
|
|
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;CAEpE,IAAI,OAAO,UAAU,KAAK,GACzB,OAAO;CAIR,IAAI,MAAM,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,UAC5C,OAAO;CAGR,OAAO,OAAO,MAAM,QAAQ,QAAQ,CAAC;AACtC"}
|
|
@@ -1 +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;
|
|
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;CAEpE,IAAI,OAAO,UAAU,KAAK,GACzB,OAAO;CAIR,IAAI,MAAM,SAAS,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,UAAU,UAC5C,OAAO;CAGR,OAAO,OAAO,MAAM,QAAQ,QAAQ,CAAC;AACtC"}
|
package/dist/placeholder.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/placeholder.ts
|
|
3
3
|
const PLACEHOLDER_SUFFIX = "__>";
|
|
4
4
|
const PLACEHOLDER_VALUE_PREFIX = "<__PLACEHOLDER_VALUE__";
|
|
@@ -70,7 +70,6 @@ function formatPlaceholderPath(path) {
|
|
|
70
70
|
if (path.length === 0) return "parameters";
|
|
71
71
|
return path.map((segment, index) => segment.startsWith("[") || index === 0 ? segment : `.${segment}`).join("");
|
|
72
72
|
}
|
|
73
|
-
|
|
74
73
|
//#endregion
|
|
75
74
|
exports.extractPlaceholderLabels = extractPlaceholderLabels;
|
|
76
75
|
exports.findPlaceholderDetails = findPlaceholderDetails;
|
|
@@ -78,4 +77,5 @@ exports.formatPlaceholderPath = formatPlaceholderPath;
|
|
|
78
77
|
exports.hasPlaceholderDeep = hasPlaceholderDeep;
|
|
79
78
|
exports.isPlaceholderString = isPlaceholderString;
|
|
80
79
|
exports.isPlaceholderValue = isPlaceholderValue;
|
|
80
|
+
|
|
81
81
|
//# sourceMappingURL=placeholder.cjs.map
|
package/dist/placeholder.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder.cjs","names":[
|
|
1
|
+
{"version":3,"file":"placeholder.cjs","names":[],"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;CAC5D,OACC,OAAO,UAAU,YACjB,MAAM,WAAW,wBAAwB,KACzC,MAAM,SAAS,kBAAkB;AAEnC;;AAGA,SAAgB,mBAAmB,OAAyB;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO,oBAAoB,KAAK;CAC/D,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,kBAAkB;CAC9D,IAAI,UAAU,QAAQ,OAAO,UAAU,UACtC,OAAO,OAAO,OAAO,KAAgC,CAAC,CAAC,KAAK,kBAAkB;CAE/E,OAAO;AACR;;AAGA,SAAgB,mBAAmB,OAAyB;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,CAAC,CAAC,MAAM,MAAM,iBAAiB;AACvC;;;;;;;AAQA,SAAS,4BAA4B,aAA6B;CACjE,IAAI,QAAQ,YAAY,MAAM,IAA2B,EAA0B;CAEnF,IAAI,MAAM,WAAW,UAAU,GAC9B,QAAQ,MAAM,MAAM,CAAiB;MAC/B,IAAI,MAAM,WAAW,KAAK,GAChC,QAAQ,MAAM,MAAM,CAAY;MAC1B,IAAI,MAAM,WAAW,IAAI,GAC/B,QAAQ,MAAM,MAAM,CAAW;CAGhC,OAAO,MAAM,KAAK;AACnB;;;;;;;AAQA,SAAgB,yBAAyB,OAA0B;CAClE,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;CAEvC,MAAM,SAAmB,CAAC;CAC1B,MAAM,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,GAAG;CACtD,IAAI;CAEJ,QAAQ,QAAQ,MAAM,KAAK,KAAK,OAAO,MAAM;EAC5C,MAAM,QAAQ,4BAA4B,MAAM,EAAE;EAClD,IAAI,MAAM,SAAS,GAClB,OAAO,KAAK,KAAK;CAEnB;CAEA,OAAO;AACR;;;;;AAMA,SAAgB,uBAAuB,OAAgB,OAAiB,CAAC,GAAwB;CAChG,IAAI,OAAO,UAAU,UAEpB,OADe,yBAAyB,KAC5B,CAAC,CAAC,KAAK,WAAW;EAAE;EAAM;CAAM,EAAE;CAG/C,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,SAAS,MAAM,UAAU,uBAAuB,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;CAG5F,IAAI,UAAU,QAAQ,OAAO,UAAU,UACtC,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,YAC3C,uBAAuB,QAAQ,CAAC,GAAG,MAAM,GAAG,CAAC,CAC9C;CAGD,OAAO,CAAC;AACT;;;;;AAMA,SAAgB,sBAAsB,MAAwB;CAC7D,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OAAO,KACL,KAAK,SAAS,UAAW,QAAQ,WAAW,GAAG,KAAK,UAAU,IAAI,UAAU,IAAI,SAAU,CAAC,CAC3F,KAAK,EAAE;AACV"}
|
package/dist/placeholder.mjs
CHANGED
|
@@ -69,7 +69,7 @@ function formatPlaceholderPath(path) {
|
|
|
69
69
|
if (path.length === 0) return "parameters";
|
|
70
70
|
return path.map((segment, index) => segment.startsWith("[") || index === 0 ? segment : `.${segment}`).join("");
|
|
71
71
|
}
|
|
72
|
-
|
|
73
72
|
//#endregion
|
|
74
73
|
export { extractPlaceholderLabels, findPlaceholderDetails, formatPlaceholderPath, hasPlaceholderDeep, isPlaceholderString, isPlaceholderValue };
|
|
74
|
+
|
|
75
75
|
//# sourceMappingURL=placeholder.mjs.map
|
package/dist/placeholder.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder.mjs","names":[
|
|
1
|
+
{"version":3,"file":"placeholder.mjs","names":[],"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;CAC5D,OACC,OAAO,UAAU,YACjB,MAAM,WAAW,wBAAwB,KACzC,MAAM,SAAS,kBAAkB;AAEnC;;AAGA,SAAgB,mBAAmB,OAAyB;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO,oBAAoB,KAAK;CAC/D,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,kBAAkB;CAC9D,IAAI,UAAU,QAAQ,OAAO,UAAU,UACtC,OAAO,OAAO,OAAO,KAAgC,CAAC,CAAC,KAAK,kBAAkB;CAE/E,OAAO;AACR;;AAGA,SAAgB,mBAAmB,OAAyB;CAC3D,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,CAAC,CAAC,MAAM,MAAM,iBAAiB;AACvC;;;;;;;AAQA,SAAS,4BAA4B,aAA6B;CACjE,IAAI,QAAQ,YAAY,MAAM,IAA2B,EAA0B;CAEnF,IAAI,MAAM,WAAW,UAAU,GAC9B,QAAQ,MAAM,MAAM,CAAiB;MAC/B,IAAI,MAAM,WAAW,KAAK,GAChC,QAAQ,MAAM,MAAM,CAAY;MAC1B,IAAI,MAAM,WAAW,IAAI,GAC/B,QAAQ,MAAM,MAAM,CAAW;CAGhC,OAAO,MAAM,KAAK;AACnB;;;;;;;AAQA,SAAgB,yBAAyB,OAA0B;CAClE,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC;CAEvC,MAAM,SAAmB,CAAC;CAC1B,MAAM,QAAQ,IAAI,OAAO,kBAAkB,QAAQ,GAAG;CACtD,IAAI;CAEJ,QAAQ,QAAQ,MAAM,KAAK,KAAK,OAAO,MAAM;EAC5C,MAAM,QAAQ,4BAA4B,MAAM,EAAE;EAClD,IAAI,MAAM,SAAS,GAClB,OAAO,KAAK,KAAK;CAEnB;CAEA,OAAO;AACR;;;;;AAMA,SAAgB,uBAAuB,OAAgB,OAAiB,CAAC,GAAwB;CAChG,IAAI,OAAO,UAAU,UAEpB,OADe,yBAAyB,KAC5B,CAAC,CAAC,KAAK,WAAW;EAAE;EAAM;CAAM,EAAE;CAG/C,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,SAAS,MAAM,UAAU,uBAAuB,MAAM,CAAC,GAAG,MAAM,IAAI,MAAM,EAAE,CAAC,CAAC;CAG5F,IAAI,UAAU,QAAQ,OAAO,UAAU,UACtC,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,SAAS,CAAC,KAAK,YAC3C,uBAAuB,QAAQ,CAAC,GAAG,MAAM,GAAG,CAAC,CAC9C;CAGD,OAAO,CAAC;AACT;;;;;AAMA,SAAgB,sBAAsB,MAAwB;CAC7D,IAAI,KAAK,WAAW,GAAG,OAAO;CAE9B,OAAO,KACL,KAAK,SAAS,UAAW,QAAQ,WAAW,GAAG,KAAK,UAAU,IAAI,UAAU,IAAI,SAAU,CAAC,CAC3F,KAAK,EAAE;AACV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/promise/deferred-promise.ts
|
|
3
3
|
function createDeferredPromise() {
|
|
4
4
|
const deferred = {};
|
|
@@ -8,7 +8,7 @@ function createDeferredPromise() {
|
|
|
8
8
|
});
|
|
9
9
|
return deferred;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
//#endregion
|
|
13
12
|
exports.createDeferredPromise = createDeferredPromise;
|
|
13
|
+
|
|
14
14
|
//# sourceMappingURL=deferred-promise.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-promise.cjs","names":[
|
|
1
|
+
{"version":3,"file":"deferred-promise.cjs","names":[],"sources":["../../src/promise/deferred-promise.ts"],"sourcesContent":["type ResolveFn<T> = (result: T | PromiseLike<T>) => void;\ntype RejectFn = (error: Error) => void;\n\nexport interface IDeferredPromise<T> {\n\tpromise: Promise<T>;\n\tresolve: ResolveFn<T>;\n\treject: RejectFn;\n}\n\nexport function createDeferredPromise<T = void>(): IDeferredPromise<T> {\n\tconst deferred: Partial<IDeferredPromise<T>> = {};\n\tdeferred.promise = new Promise<T>((resolve, reject) => {\n\t\tdeferred.resolve = resolve;\n\t\tdeferred.reject = reject;\n\t});\n\treturn deferred as IDeferredPromise<T>;\n}\n"],"mappings":";;AASA,SAAgB,wBAAuD;CACtE,MAAM,WAAyC,CAAC;CAChD,SAAS,UAAU,IAAI,SAAY,SAAS,WAAW;EACtD,SAAS,UAAU;EACnB,SAAS,SAAS;CACnB,CAAC;CACD,OAAO;AACR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deferred-promise.mjs","names":[
|
|
1
|
+
{"version":3,"file":"deferred-promise.mjs","names":[],"sources":["../../src/promise/deferred-promise.ts"],"sourcesContent":["type ResolveFn<T> = (result: T | PromiseLike<T>) => void;\ntype RejectFn = (error: Error) => void;\n\nexport interface IDeferredPromise<T> {\n\tpromise: Promise<T>;\n\tresolve: ResolveFn<T>;\n\treject: RejectFn;\n}\n\nexport function createDeferredPromise<T = void>(): IDeferredPromise<T> {\n\tconst deferred: Partial<IDeferredPromise<T>> = {};\n\tdeferred.promise = new Promise<T>((resolve, reject) => {\n\t\tdeferred.resolve = resolve;\n\t\tdeferred.reject = reject;\n\t});\n\treturn deferred as IDeferredPromise<T>;\n}\n"],"mappings":";AASA,SAAgB,wBAAuD;CACtE,MAAM,WAAyC,CAAC;CAChD,SAAS,UAAU,IAAI,SAAY,SAAS,WAAW;EACtD,SAAS,UAAU;EACnB,SAAS,SAAS;CACnB,CAAC;CACD,OAAO;AACR"}
|
package/dist/result.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_errors_ensure_error = require("./errors/ensure-error.cjs");
|
|
3
3
|
//#region src/result.ts
|
|
4
4
|
const createResultOk = (data) => ({
|
|
5
5
|
ok: true,
|
|
@@ -19,12 +19,13 @@ const toResult = (fn) => {
|
|
|
19
19
|
try {
|
|
20
20
|
return createResultOk(fn());
|
|
21
21
|
} catch (e) {
|
|
22
|
-
|
|
22
|
+
const error = require_errors_ensure_error.ensureError(e);
|
|
23
|
+
return createResultError(error);
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
|
|
26
26
|
//#endregion
|
|
27
27
|
exports.createResultError = createResultError;
|
|
28
28
|
exports.createResultOk = createResultOk;
|
|
29
29
|
exports.toResult = toResult;
|
|
30
|
+
|
|
30
31
|
//# sourceMappingURL=result.cjs.map
|
package/dist/result.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.cjs","names":["ensureError"],"sources":["../src/result.ts"],"sourcesContent":["import { ensureError } from './errors/ensure-error';\n\nexport type ResultOk<T> = { ok: true; result: T };\nexport type ResultError<E> = { ok: false; error: E };\nexport type Result<T, E> = ResultOk<T> | ResultError<E>;\n\nexport const createResultOk = <T>(data: T): ResultOk<T> => ({\n\tok: true,\n\tresult: data,\n});\n\nexport const createResultError = <E = unknown>(error: E): ResultError<E> => ({\n\tok: false,\n\terror,\n});\n\n/**\n * Executes the given function and converts it to a Result object.\n *\n * @example\n * const result = toResult(() => fs.writeFileSync('file.txt', 'Hello, World!'));\n */\nexport const toResult = <T, E extends Error = Error>(fn: () => T): Result<T, E> => {\n\ttry {\n\t\treturn createResultOk<T>(fn());\n\t} catch (e) {\n\t\tconst error = ensureError(e);\n\t\treturn createResultError<E>(error as E);\n\t}\n};\n"],"mappings":";;;AAMA,MAAa,kBAAqB,UAA0B;CAC3D,IAAI;CACJ,QAAQ;
|
|
1
|
+
{"version":3,"file":"result.cjs","names":["ensureError"],"sources":["../src/result.ts"],"sourcesContent":["import { ensureError } from './errors/ensure-error';\n\nexport type ResultOk<T> = { ok: true; result: T };\nexport type ResultError<E> = { ok: false; error: E };\nexport type Result<T, E> = ResultOk<T> | ResultError<E>;\n\nexport const createResultOk = <T>(data: T): ResultOk<T> => ({\n\tok: true,\n\tresult: data,\n});\n\nexport const createResultError = <E = unknown>(error: E): ResultError<E> => ({\n\tok: false,\n\terror,\n});\n\n/**\n * Executes the given function and converts it to a Result object.\n *\n * @example\n * const result = toResult(() => fs.writeFileSync('file.txt', 'Hello, World!'));\n */\nexport const toResult = <T, E extends Error = Error>(fn: () => T): Result<T, E> => {\n\ttry {\n\t\treturn createResultOk<T>(fn());\n\t} catch (e) {\n\t\tconst error = ensureError(e);\n\t\treturn createResultError<E>(error as E);\n\t}\n};\n"],"mappings":";;;AAMA,MAAa,kBAAqB,UAA0B;CAC3D,IAAI;CACJ,QAAQ;AACT;AAEA,MAAa,qBAAkC,WAA8B;CAC5E,IAAI;CACJ;AACD;;;;;;;AAQA,MAAa,YAAwC,OAA8B;CAClF,IAAI;EACH,OAAO,eAAkB,GAAG,CAAC;CAC9B,SAAS,GAAG;EACX,MAAM,QAAQA,4BAAAA,YAAY,CAAC;EAC3B,OAAO,kBAAqB,KAAU;CACvC;AACD"}
|
package/dist/result.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ensureError } from "./errors/ensure-error.mjs";
|
|
3
2
|
//#region src/result.ts
|
|
4
3
|
const createResultOk = (data) => ({
|
|
5
4
|
ok: true,
|
|
@@ -19,10 +18,11 @@ const toResult = (fn) => {
|
|
|
19
18
|
try {
|
|
20
19
|
return createResultOk(fn());
|
|
21
20
|
} catch (e) {
|
|
22
|
-
|
|
21
|
+
const error = ensureError(e);
|
|
22
|
+
return createResultError(error);
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
|
|
26
25
|
//#endregion
|
|
27
26
|
export { createResultError, createResultOk, toResult };
|
|
27
|
+
|
|
28
28
|
//# sourceMappingURL=result.mjs.map
|
package/dist/result.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.mjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["import { ensureError } from './errors/ensure-error';\n\nexport type ResultOk<T> = { ok: true; result: T };\nexport type ResultError<E> = { ok: false; error: E };\nexport type Result<T, E> = ResultOk<T> | ResultError<E>;\n\nexport const createResultOk = <T>(data: T): ResultOk<T> => ({\n\tok: true,\n\tresult: data,\n});\n\nexport const createResultError = <E = unknown>(error: E): ResultError<E> => ({\n\tok: false,\n\terror,\n});\n\n/**\n * Executes the given function and converts it to a Result object.\n *\n * @example\n * const result = toResult(() => fs.writeFileSync('file.txt', 'Hello, World!'));\n */\nexport const toResult = <T, E extends Error = Error>(fn: () => T): Result<T, E> => {\n\ttry {\n\t\treturn createResultOk<T>(fn());\n\t} catch (e) {\n\t\tconst error = ensureError(e);\n\t\treturn createResultError<E>(error as E);\n\t}\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"result.mjs","names":[],"sources":["../src/result.ts"],"sourcesContent":["import { ensureError } from './errors/ensure-error';\n\nexport type ResultOk<T> = { ok: true; result: T };\nexport type ResultError<E> = { ok: false; error: E };\nexport type Result<T, E> = ResultOk<T> | ResultError<E>;\n\nexport const createResultOk = <T>(data: T): ResultOk<T> => ({\n\tok: true,\n\tresult: data,\n});\n\nexport const createResultError = <E = unknown>(error: E): ResultError<E> => ({\n\tok: false,\n\terror,\n});\n\n/**\n * Executes the given function and converts it to a Result object.\n *\n * @example\n * const result = toResult(() => fs.writeFileSync('file.txt', 'Hello, World!'));\n */\nexport const toResult = <T, E extends Error = Error>(fn: () => T): Result<T, E> => {\n\ttry {\n\t\treturn createResultOk<T>(fn());\n\t} catch (e) {\n\t\tconst error = ensureError(e);\n\t\treturn createResultError<E>(error as E);\n\t}\n};\n"],"mappings":";;AAMA,MAAa,kBAAqB,UAA0B;CAC3D,IAAI;CACJ,QAAQ;AACT;AAEA,MAAa,qBAAkC,WAA8B;CAC5E,IAAI;CACJ;AACD;;;;;;;AAQA,MAAa,YAAwC,OAA8B;CAClF,IAAI;EACH,OAAO,eAAkB,GAAG,CAAC;CAC9B,SAAS,GAAG;EACX,MAAM,QAAQ,YAAY,CAAC;EAC3B,OAAO,kBAAqB,KAAU;CACvC;AACD"}
|
package/dist/retry.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/retry.ts
|
|
3
3
|
/**
|
|
4
4
|
* A utility that retries a function every `interval` milliseconds
|
|
@@ -34,7 +34,7 @@ async function retry(fn, interval = 1e3, maxRetries = 3, backoff = "linear") {
|
|
|
34
34
|
}
|
|
35
35
|
return false;
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
//#endregion
|
|
39
38
|
exports.retry = retry;
|
|
39
|
+
|
|
40
40
|
//# sourceMappingURL=retry.cjs.map
|
package/dist/retry.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.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;
|
|
1
|
+
{"version":3,"file":"retry.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;CAEd,OAAO,UAAU,YAAY;EAC5B;EACA,IAAI;GAEH,IAAI,MADiB,GAAG,GAEvB,OAAO;EAET,SAAS,OAAO;GACf,QAAQ,MAAM,uBAAuB,KAAK;GAC1C,MAAM;EACP;EAGA,IAAI,UAAU,YAAY;GACzB,IAAI,mBAAmB;GAEvB,IAAI,YAAY,UACf,mBAAmB,WAAW;QACxB,IAAI,YAAY,eAAe;IACrC,mBAAmB,KAAK,IAAI,GAAG,UAAU,CAAC,IAAI;IAC9C,mBAAmB,KAAK,IAAI,kBAAkB,GAAK;GACpD;GAEA,MAAM,IAAI,SAAe,YAAY,WAAW,SAAS,gBAAgB,CAAC;EAC3E;CACD;CAEA,OAAO;AACR"}
|
package/dist/retry.mjs
CHANGED
package/dist/retry.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.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;
|
|
1
|
+
{"version":3,"file":"retry.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;CAEd,OAAO,UAAU,YAAY;EAC5B;EACA,IAAI;GAEH,IAAI,MADiB,GAAG,GAEvB,OAAO;EAET,SAAS,OAAO;GACf,QAAQ,MAAM,uBAAuB,KAAK;GAC1C,MAAM;EACP;EAGA,IAAI,UAAU,YAAY;GACzB,IAAI,mBAAmB;GAEvB,IAAI,YAAY,UACf,mBAAmB,WAAW;QACxB,IAAI,YAAY,eAAe;IACrC,mBAAmB,KAAK,IAAI,GAAG,UAAU,CAAC,IAAI;IAC9C,mBAAmB,KAAK,IAAI,kBAAkB,GAAK;GACpD;GAEA,MAAM,IAAI,SAAe,YAAY,WAAW,SAAS,gBAAgB,CAAC;EAC3E;CACD;CAEA,OAAO;AACR"}
|
package/dist/scrub-secrets.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/scrub-secrets.ts
|
|
3
3
|
/**
|
|
4
4
|
* Replace common credential patterns in free-form text with `[REDACTED]`.
|
|
@@ -37,9 +37,9 @@ function scrubSecretsInText(input) {
|
|
|
37
37
|
for (const pattern of SECRET_VALUE_PATTERNS) out = out.replace(pattern, "[REDACTED]");
|
|
38
38
|
return out;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
40
|
//#endregion
|
|
42
41
|
exports.SECRET_KEYS = SECRET_KEYS;
|
|
43
42
|
exports.SECRET_VALUE_PATTERNS = SECRET_VALUE_PATTERNS;
|
|
44
43
|
exports.scrubSecretsInText = scrubSecretsInText;
|
|
44
|
+
|
|
45
45
|
//# sourceMappingURL=scrub-secrets.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrub-secrets.cjs","names":[
|
|
1
|
+
{"version":3,"file":"scrub-secrets.cjs","names":[],"sources":["../src/scrub-secrets.ts"],"sourcesContent":["/**\n * Replace common credential patterns in free-form text with `[REDACTED]`.\n *\n * Used before persisting or transmitting user-supplied text (telemetry\n * excerpts, eval report HTML, free-form feedback) where keys/tokens\n * accidentally pasted into prompts or command lines could otherwise leak\n * downstream.\n *\n * Conservative by design: matches well-known prefixed tokens, explicit\n * `key=value` pairs, and quoted JSON/JS-object fields with sensitive\n * names. We don't attempt to redact arbitrary long opaque strings — false\n * positives on file paths, IDs, or base64 payloads would make the output\n * unreadable.\n */\nexport const SECRET_KEYS =\n\t'password|passwd|secret|credentials?|api[_-]?key|authorization|access[_-]?token|refresh[_-]?token|id[_-]?token|session[_-]?token|auth[_-]?token';\n\nexport const SECRET_VALUE_PATTERNS: readonly RegExp[] = [\n\t// PEM private-key blocks (RSA/EC/DSA/OpenSSH/PGP). Whole block, multiline.\n\t/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----[\\s\\S]*?-----END (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/g,\n\t// JWTs: `eyJ<header>.eyJ<payload>.<signature>` (both leading segments are\n\t// base64url of a `{\"` object, which makes this highly distinctive).\n\t/\\beyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+/g,\n\t// Authorization-header substrings: `Bearer <token>`, `Basic <token>`, `Token <token>`\n\t/\\b(?:Bearer|Basic|Token)\\s+[A-Za-z0-9._~+/=-]{12,}/gi,\n\t// OpenAI / Anthropic API keys\n\t/\\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}/g,\n\t// Stripe secret/restricted/publishable keys (`sk_live_…`, `rk_test_…`, …)\n\t/\\b(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{16,}/g,\n\t// Google API keys\n\t/\\bAIza[0-9A-Za-z_-]{35}\\b/g,\n\t// Slack tokens (xoxb, xoxp, xoxa, xoxr, xoxs, xoxo)\n\t/\\bxox[abprso]-[A-Za-z0-9-]{10,}/g,\n\t// GitHub tokens (ghp, ghs, gho, ghr, ghu)\n\t/\\bgh[psoru]_[A-Za-z0-9]{20,}/g,\n\t// GitHub fine-grained personal access tokens\n\t/\\bgithub_pat_[A-Za-z0-9_]{22,}/g,\n\t// AWS access key id\n\t/\\bAKIA[0-9A-Z]{16}\\b/g,\n\t// Telegram bot token (`<bot id>:<35-char secret>`, also inside `/bot…/` URLs)\n\t/\\b(?:bot)?\\d{8,10}:[A-Za-z0-9_-]{35}\\b/g,\n\t// Credentials embedded in a URL: `scheme://user:password@` — redact the userinfo.\n\t/(?<=:\\/\\/)[^\\s:/@]+:[^\\s:/@]+(?=@)/g,\n\t// JSON-shaped `\"key\": \"value\"` — matches the quoted field as a whole.\n\t// Run before the loose pattern so nested objects like\n\t// `{\"credentials\": {\"apiKey\": \"...\"}}` don't have the outer key consume\n\t// the inner key on its way to a non-quoted (object) value. The value\n\t// body uses the unrolled JSON-string idiom `(?:[^\"\\\\\\r\\n]|\\\\.)*`: the\n\t// negated class excludes the backslash so a backslash can only be consumed\n\t// by the `\\\\.` escape branch. Keep the two alternatives disjoint (don't\n\t// fold `\\\\` back into the negated class) — that keeps every run of\n\t// backslashes to a single, unambiguous parse, so matching stays fast on any\n\t// input. An escaped quote inside the value (`\"abc\\\"def\"`) still doesn't end\n\t// the match early, via the escape branch. The negative lookahead skips\n\t// values that are already a `[redacted]` / `[REDACTED]` / typed\n\t// `[REDACTED:<type>:<index>]` placeholder so this stays idempotent when\n\t// chained behind upstream object-walking redaction (langsmith trace\n\t// payloads, mcp-browser markers).\n\tnew RegExp(\n\t\t`\"(?:${SECRET_KEYS})\"\\\\s*:\\\\s*\"(?!\\\\[(?:redacted|REDACTED)(?::[^\"\\\\]]*)?\\\\]\")(?:[^\"\\\\\\\\\\\\r\\\\n]|\\\\\\\\.)*\"`,\n\t\t'gi',\n\t),\n\t// JS-object-shaped `'key': 'value'`\n\tnew RegExp(\n\t\t`'(?:${SECRET_KEYS})'\\\\s*:\\\\s*'(?!\\\\[(?:redacted|REDACTED)(?::[^'\\\\]]*)?\\\\]')(?:[^'\\\\\\\\\\\\r\\\\n]|\\\\\\\\.)*'`,\n\t\t'gi',\n\t),\n\t// Generic `password=...` / `api_key=...` / `secret=...` style assignments.\n\t// The negative lookbehind skips a keyword sitting at the `<type>` position of\n\t// an upstream `[REDACTED:<type>:<index>]` marker (e.g. mcp-browser output), so\n\t// the `secret:1]` tail isn't re-matched into a nested `[REDACTED:[REDACTED]`.\n\t// Checking only the `[REDACTED:` prefix suffices: inside a marker a keyword can\n\t// only start a `\\b` match right after that prefix — every other keyword-shaped\n\t// substring is preceded by `_` (snake_case type slug) or a digit, so no word\n\t// boundary opens there. The value lookahead skips values that are already a\n\t// redaction placeholder (bracketed, typed, or URL-safe bare form) — the same\n\t// idempotency convention as the quoted forms.\n\tnew RegExp(\n\t\t`(?<!\\\\[(?:redacted|REDACTED):)\\\\b(?:${SECRET_KEYS})\\\\s*[:=]\\\\s*(?!\\\\[?(?:redacted|REDACTED)\\\\b)\\\\S+`,\n\t\t'gi',\n\t),\n];\n\nexport function scrubSecretsInText(input: string): string {\n\tlet out = input;\n\tfor (const pattern of SECRET_VALUE_PATTERNS) {\n\t\tout = out.replace(pattern, '[REDACTED]');\n\t}\n\treturn out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAcA,MAAa,cACZ;AAED,MAAa,wBAA2C;CAEvD;CAGA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAgBA,IAAI,OACH,OAAO,YAAY,uFACnB,IACD;CAEA,IAAI,OACH,OAAO,YAAY,uFACnB,IACD;CAWA,IAAI,OACH,uCAAuC,YAAY,oDACnD,IACD;AACD;AAEA,SAAgB,mBAAmB,OAAuB;CACzD,IAAI,MAAM;CACV,KAAK,MAAM,WAAW,uBACrB,MAAM,IAAI,QAAQ,SAAS,YAAY;CAExC,OAAO;AACR"}
|
package/dist/scrub-secrets.mjs
CHANGED
|
@@ -36,7 +36,7 @@ function scrubSecretsInText(input) {
|
|
|
36
36
|
for (const pattern of SECRET_VALUE_PATTERNS) out = out.replace(pattern, "[REDACTED]");
|
|
37
37
|
return out;
|
|
38
38
|
}
|
|
39
|
-
|
|
40
39
|
//#endregion
|
|
41
40
|
export { SECRET_KEYS, SECRET_VALUE_PATTERNS, scrubSecretsInText };
|
|
41
|
+
|
|
42
42
|
//# sourceMappingURL=scrub-secrets.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrub-secrets.mjs","names":[
|
|
1
|
+
{"version":3,"file":"scrub-secrets.mjs","names":[],"sources":["../src/scrub-secrets.ts"],"sourcesContent":["/**\n * Replace common credential patterns in free-form text with `[REDACTED]`.\n *\n * Used before persisting or transmitting user-supplied text (telemetry\n * excerpts, eval report HTML, free-form feedback) where keys/tokens\n * accidentally pasted into prompts or command lines could otherwise leak\n * downstream.\n *\n * Conservative by design: matches well-known prefixed tokens, explicit\n * `key=value` pairs, and quoted JSON/JS-object fields with sensitive\n * names. We don't attempt to redact arbitrary long opaque strings — false\n * positives on file paths, IDs, or base64 payloads would make the output\n * unreadable.\n */\nexport const SECRET_KEYS =\n\t'password|passwd|secret|credentials?|api[_-]?key|authorization|access[_-]?token|refresh[_-]?token|id[_-]?token|session[_-]?token|auth[_-]?token';\n\nexport const SECRET_VALUE_PATTERNS: readonly RegExp[] = [\n\t// PEM private-key blocks (RSA/EC/DSA/OpenSSH/PGP). Whole block, multiline.\n\t/-----BEGIN (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----[\\s\\S]*?-----END (?:RSA |EC |DSA |OPENSSH |PGP )?PRIVATE KEY-----/g,\n\t// JWTs: `eyJ<header>.eyJ<payload>.<signature>` (both leading segments are\n\t// base64url of a `{\"` object, which makes this highly distinctive).\n\t/\\beyJ[A-Za-z0-9_-]+\\.eyJ[A-Za-z0-9_-]+\\.[A-Za-z0-9_-]+/g,\n\t// Authorization-header substrings: `Bearer <token>`, `Basic <token>`, `Token <token>`\n\t/\\b(?:Bearer|Basic|Token)\\s+[A-Za-z0-9._~+/=-]{12,}/gi,\n\t// OpenAI / Anthropic API keys\n\t/\\bsk-(?:ant-|proj-)?[A-Za-z0-9_-]{16,}/g,\n\t// Stripe secret/restricted/publishable keys (`sk_live_…`, `rk_test_…`, …)\n\t/\\b(?:sk|rk|pk)_(?:live|test)_[A-Za-z0-9]{16,}/g,\n\t// Google API keys\n\t/\\bAIza[0-9A-Za-z_-]{35}\\b/g,\n\t// Slack tokens (xoxb, xoxp, xoxa, xoxr, xoxs, xoxo)\n\t/\\bxox[abprso]-[A-Za-z0-9-]{10,}/g,\n\t// GitHub tokens (ghp, ghs, gho, ghr, ghu)\n\t/\\bgh[psoru]_[A-Za-z0-9]{20,}/g,\n\t// GitHub fine-grained personal access tokens\n\t/\\bgithub_pat_[A-Za-z0-9_]{22,}/g,\n\t// AWS access key id\n\t/\\bAKIA[0-9A-Z]{16}\\b/g,\n\t// Telegram bot token (`<bot id>:<35-char secret>`, also inside `/bot…/` URLs)\n\t/\\b(?:bot)?\\d{8,10}:[A-Za-z0-9_-]{35}\\b/g,\n\t// Credentials embedded in a URL: `scheme://user:password@` — redact the userinfo.\n\t/(?<=:\\/\\/)[^\\s:/@]+:[^\\s:/@]+(?=@)/g,\n\t// JSON-shaped `\"key\": \"value\"` — matches the quoted field as a whole.\n\t// Run before the loose pattern so nested objects like\n\t// `{\"credentials\": {\"apiKey\": \"...\"}}` don't have the outer key consume\n\t// the inner key on its way to a non-quoted (object) value. The value\n\t// body uses the unrolled JSON-string idiom `(?:[^\"\\\\\\r\\n]|\\\\.)*`: the\n\t// negated class excludes the backslash so a backslash can only be consumed\n\t// by the `\\\\.` escape branch. Keep the two alternatives disjoint (don't\n\t// fold `\\\\` back into the negated class) — that keeps every run of\n\t// backslashes to a single, unambiguous parse, so matching stays fast on any\n\t// input. An escaped quote inside the value (`\"abc\\\"def\"`) still doesn't end\n\t// the match early, via the escape branch. The negative lookahead skips\n\t// values that are already a `[redacted]` / `[REDACTED]` / typed\n\t// `[REDACTED:<type>:<index>]` placeholder so this stays idempotent when\n\t// chained behind upstream object-walking redaction (langsmith trace\n\t// payloads, mcp-browser markers).\n\tnew RegExp(\n\t\t`\"(?:${SECRET_KEYS})\"\\\\s*:\\\\s*\"(?!\\\\[(?:redacted|REDACTED)(?::[^\"\\\\]]*)?\\\\]\")(?:[^\"\\\\\\\\\\\\r\\\\n]|\\\\\\\\.)*\"`,\n\t\t'gi',\n\t),\n\t// JS-object-shaped `'key': 'value'`\n\tnew RegExp(\n\t\t`'(?:${SECRET_KEYS})'\\\\s*:\\\\s*'(?!\\\\[(?:redacted|REDACTED)(?::[^'\\\\]]*)?\\\\]')(?:[^'\\\\\\\\\\\\r\\\\n]|\\\\\\\\.)*'`,\n\t\t'gi',\n\t),\n\t// Generic `password=...` / `api_key=...` / `secret=...` style assignments.\n\t// The negative lookbehind skips a keyword sitting at the `<type>` position of\n\t// an upstream `[REDACTED:<type>:<index>]` marker (e.g. mcp-browser output), so\n\t// the `secret:1]` tail isn't re-matched into a nested `[REDACTED:[REDACTED]`.\n\t// Checking only the `[REDACTED:` prefix suffices: inside a marker a keyword can\n\t// only start a `\\b` match right after that prefix — every other keyword-shaped\n\t// substring is preceded by `_` (snake_case type slug) or a digit, so no word\n\t// boundary opens there. The value lookahead skips values that are already a\n\t// redaction placeholder (bracketed, typed, or URL-safe bare form) — the same\n\t// idempotency convention as the quoted forms.\n\tnew RegExp(\n\t\t`(?<!\\\\[(?:redacted|REDACTED):)\\\\b(?:${SECRET_KEYS})\\\\s*[:=]\\\\s*(?!\\\\[?(?:redacted|REDACTED)\\\\b)\\\\S+`,\n\t\t'gi',\n\t),\n];\n\nexport function scrubSecretsInText(input: string): string {\n\tlet out = input;\n\tfor (const pattern of SECRET_VALUE_PATTERNS) {\n\t\tout = out.replace(pattern, '[REDACTED]');\n\t}\n\treturn out;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,cACZ;AAED,MAAa,wBAA2C;CAEvD;CAGA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAEA;CAgBA,IAAI,OACH,OAAO,YAAY,uFACnB,IACD;CAEA,IAAI,OACH,OAAO,YAAY,uFACnB,IACD;CAWA,IAAI,OACH,uCAAuC,YAAY,oDACnD,IACD;AACD;AAEA,SAAgB,mBAAmB,OAAuB;CACzD,IAAI,MAAM;CACV,KAAK,MAAM,WAAW,uBACrB,MAAM,IAAI,QAAQ,SAAS,YAAY;CAExC,OAAO;AACR"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/search/re-rank-search-results.ts
|
|
3
3
|
function reRankSearchResults(searchResults, additionalFactors) {
|
|
4
4
|
return searchResults.map(({ score, item }) => {
|
|
@@ -14,7 +14,7 @@ function reRankSearchResults(searchResults, additionalFactors) {
|
|
|
14
14
|
return b.score - a.score;
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
|
-
|
|
18
17
|
//#endregion
|
|
19
18
|
exports.reRankSearchResults = reRankSearchResults;
|
|
19
|
+
|
|
20
20
|
//# sourceMappingURL=re-rank-search-results.cjs.map
|
|
@@ -1 +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;
|
|
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;CACpC,OAAO,cACL,KAAK,EAAE,OAAO,WAAW;EAYzB,OAAO;GACN,OAAO,QAVgB,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,KAAK,CAAC,GAAG,kBAAkB;IAC5F,MAAM,cAAc,aAAa,KAAK;IACtC,IAAI,aACH,OAAO,MAAM;IAGd,OAAO;GACR,GAAG,CAG2B;GAC7B;EACD;CACD,CAAC,CAAC,CACD,MAAM,GAAG,MAAM;EACf,OAAO,EAAE,QAAQ,EAAE;CACpB,CAAC;AACH"}
|
|
@@ -1 +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;
|
|
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;CACpC,OAAO,cACL,KAAK,EAAE,OAAO,WAAW;EAYzB,OAAO;GACN,OAAO,QAVgB,OAAO,QAAQ,iBAAiB,CAAC,CAAC,QAAQ,KAAK,CAAC,GAAG,kBAAkB;IAC5F,MAAM,cAAc,aAAa,KAAK;IACtC,IAAI,aACH,OAAO,MAAM;IAGd,OAAO;GACR,GAAG,CAG2B;GAC7B;EACD;CACD,CAAC,CAAC,CACD,MAAM,GAAG,MAAM;EACf,OAAO,EAAE,QAAQ,EAAE;CACpB,CAAC;AACH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
//#region src/search/sublime-search.ts
|
|
3
3
|
const SEQUENTIAL_BONUS = 60;
|
|
4
4
|
const SEPARATOR_BONUS = 38;
|
|
@@ -176,8 +176,8 @@ function sublimeSearch(filter, data, keys = DEFAULT_KEYS, limit) {
|
|
|
176
176
|
});
|
|
177
177
|
return results;
|
|
178
178
|
}
|
|
179
|
-
|
|
180
179
|
//#endregion
|
|
181
180
|
exports.DEFAULT_KEYS = DEFAULT_KEYS;
|
|
182
181
|
exports.sublimeSearch = sublimeSearch;
|
|
182
|
+
|
|
183
183
|
//# sourceMappingURL=sublime-search.cjs.map
|