@n8n/utils 1.39.0 → 1.41.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/json/to-json-value.cjs +40 -0
- package/dist/json/to-json-value.cjs.map +1 -0
- package/dist/json/to-json-value.d.cts +10 -0
- package/dist/json/to-json-value.d.mts +10 -0
- package/dist/json/to-json-value.mjs +39 -0
- package/dist/json/to-json-value.mjs.map +1 -0
- 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 +8 -8
- 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,40 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/json/to-json-value.ts
|
|
3
|
+
/**
|
|
4
|
+
* Recursively converts an arbitrary value into a JSON-safe representation.
|
|
5
|
+
*
|
|
6
|
+
* Handles `Buffer`, `Date`, `Error`, `bigint`, circular references, and
|
|
7
|
+
* non-finite numbers (`NaN`, `Infinity`). Values that have no JSON
|
|
8
|
+
* representation (`undefined`, functions, symbols) become `null`.
|
|
9
|
+
*/
|
|
10
|
+
function toJsonValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
11
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
12
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
13
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return null;
|
|
14
|
+
if (typeof value === "bigint") return value.toString();
|
|
15
|
+
if (Buffer.isBuffer(value)) return value.toString();
|
|
16
|
+
if (value instanceof Date) return value.toISOString();
|
|
17
|
+
if (value instanceof Error) return {
|
|
18
|
+
name: value.name,
|
|
19
|
+
message: value.message
|
|
20
|
+
};
|
|
21
|
+
if (Array.isArray(value)) return value.map((entry) => toJsonValue(entry, seen));
|
|
22
|
+
if (typeof value === "object") {
|
|
23
|
+
if (seen.has(value)) return "[Circular]";
|
|
24
|
+
seen.add(value);
|
|
25
|
+
const result = {};
|
|
26
|
+
for (const [key, entryValue] of Object.entries(value)) Object.defineProperty(result, key, {
|
|
27
|
+
value: toJsonValue(entryValue, seen),
|
|
28
|
+
enumerable: true,
|
|
29
|
+
writable: true,
|
|
30
|
+
configurable: true
|
|
31
|
+
});
|
|
32
|
+
seen.delete(value);
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
exports.toJsonValue = toJsonValue;
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=to-json-value.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-json-value.cjs","names":[],"sources":["../../src/json/to-json-value.ts"],"sourcesContent":["export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONObject = {\n\t[key: string]: JSONValue | undefined;\n};\n\nexport type JSONArray = JSONValue[];\n\n/**\n * Recursively converts an arbitrary value into a JSON-safe representation.\n *\n * Handles `Buffer`, `Date`, `Error`, `bigint`, circular references, and\n * non-finite numbers (`NaN`, `Infinity`). Values that have no JSON\n * representation (`undefined`, functions, symbols) become `null`.\n */\nexport function toJsonValue(value: unknown, seen = new WeakSet<object>()): JSONValue {\n\tif (value === null || typeof value === 'string' || typeof value === 'boolean') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'number') {\n\t\treturn Number.isFinite(value) ? value : null;\n\t}\n\n\tif (value === undefined || typeof value === 'function' || typeof value === 'symbol') {\n\t\treturn null;\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString();\n\t}\n\n\tif (Buffer.isBuffer(value)) {\n\t\treturn value.toString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tif (value instanceof Error) {\n\t\treturn {\n\t\t\tname: value.name,\n\t\t\tmessage: value.message,\n\t\t};\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => toJsonValue(entry, seen));\n\t}\n\n\tif (typeof value === 'object') {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\n\t\tseen.add(value);\n\t\tconst result: JSONObject = {};\n\t\tfor (const [key, entryValue] of Object.entries(value)) {\n\t\t\tObject.defineProperty(result, key, {\n\t\t\t\tvalue: toJsonValue(entryValue, seen),\n\t\t\t\tenumerable: true,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tseen.delete(value);\n\t\treturn result;\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;;AAeA,SAAgB,YAAY,OAAgB,uBAAO,IAAI,QAAgB,GAAc;CACpF,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,WACnE,OAAO;CAGR,IAAI,OAAO,UAAU,UACpB,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;CAGzC,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,cAAc,OAAO,UAAU,UAC1E,OAAO;CAGR,IAAI,OAAO,UAAU,UACpB,OAAO,MAAM,SAAS;CAGvB,IAAI,OAAO,SAAS,KAAK,GACxB,OAAO,MAAM,SAAS;CAGvB,IAAI,iBAAiB,MACpB,OAAO,MAAM,YAAY;CAG1B,IAAI,iBAAiB,OACpB,OAAO;EACN,MAAM,MAAM;EACZ,SAAS,MAAM;CAChB;CAGD,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,KAAK,UAAU,YAAY,OAAO,IAAI,CAAC;CAGrD,IAAI,OAAO,UAAU,UAAU;EAC9B,IAAI,KAAK,IAAI,KAAK,GACjB,OAAO;EAGR,KAAK,IAAI,KAAK;EACd,MAAM,SAAqB,CAAC;EAC5B,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,KAAK,GACnD,OAAO,eAAe,QAAQ,KAAK;GAClC,OAAO,YAAY,YAAY,IAAI;GACnC,YAAY;GACZ,UAAU;GACV,cAAc;EACf,CAAC;EAEF,KAAK,OAAO,KAAK;EACjB,OAAO;CACR;CAEA,OAAO;AACR"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/json/to-json-value.d.ts
|
|
2
|
+
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
3
|
+
type JSONObject = {
|
|
4
|
+
[key: string]: JSONValue | undefined;
|
|
5
|
+
};
|
|
6
|
+
type JSONArray = JSONValue[];
|
|
7
|
+
declare function toJsonValue(value: unknown, seen?: WeakSet<object>): JSONValue;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { JSONArray, JSONObject, JSONValue, toJsonValue };
|
|
10
|
+
//# sourceMappingURL=to-json-value.d.cts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/json/to-json-value.d.ts
|
|
2
|
+
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
|
3
|
+
type JSONObject = {
|
|
4
|
+
[key: string]: JSONValue | undefined;
|
|
5
|
+
};
|
|
6
|
+
type JSONArray = JSONValue[];
|
|
7
|
+
declare function toJsonValue(value: unknown, seen?: WeakSet<object>): JSONValue;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { JSONArray, JSONObject, JSONValue, toJsonValue };
|
|
10
|
+
//# sourceMappingURL=to-json-value.d.mts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
//#region src/json/to-json-value.ts
|
|
2
|
+
/**
|
|
3
|
+
* Recursively converts an arbitrary value into a JSON-safe representation.
|
|
4
|
+
*
|
|
5
|
+
* Handles `Buffer`, `Date`, `Error`, `bigint`, circular references, and
|
|
6
|
+
* non-finite numbers (`NaN`, `Infinity`). Values that have no JSON
|
|
7
|
+
* representation (`undefined`, functions, symbols) become `null`.
|
|
8
|
+
*/
|
|
9
|
+
function toJsonValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
10
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return value;
|
|
11
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
12
|
+
if (value === void 0 || typeof value === "function" || typeof value === "symbol") return null;
|
|
13
|
+
if (typeof value === "bigint") return value.toString();
|
|
14
|
+
if (Buffer.isBuffer(value)) return value.toString();
|
|
15
|
+
if (value instanceof Date) return value.toISOString();
|
|
16
|
+
if (value instanceof Error) return {
|
|
17
|
+
name: value.name,
|
|
18
|
+
message: value.message
|
|
19
|
+
};
|
|
20
|
+
if (Array.isArray(value)) return value.map((entry) => toJsonValue(entry, seen));
|
|
21
|
+
if (typeof value === "object") {
|
|
22
|
+
if (seen.has(value)) return "[Circular]";
|
|
23
|
+
seen.add(value);
|
|
24
|
+
const result = {};
|
|
25
|
+
for (const [key, entryValue] of Object.entries(value)) Object.defineProperty(result, key, {
|
|
26
|
+
value: toJsonValue(entryValue, seen),
|
|
27
|
+
enumerable: true,
|
|
28
|
+
writable: true,
|
|
29
|
+
configurable: true
|
|
30
|
+
});
|
|
31
|
+
seen.delete(value);
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { toJsonValue };
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=to-json-value.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-json-value.mjs","names":[],"sources":["../../src/json/to-json-value.ts"],"sourcesContent":["export type JSONValue = null | string | number | boolean | JSONObject | JSONArray;\n\nexport type JSONObject = {\n\t[key: string]: JSONValue | undefined;\n};\n\nexport type JSONArray = JSONValue[];\n\n/**\n * Recursively converts an arbitrary value into a JSON-safe representation.\n *\n * Handles `Buffer`, `Date`, `Error`, `bigint`, circular references, and\n * non-finite numbers (`NaN`, `Infinity`). Values that have no JSON\n * representation (`undefined`, functions, symbols) become `null`.\n */\nexport function toJsonValue(value: unknown, seen = new WeakSet<object>()): JSONValue {\n\tif (value === null || typeof value === 'string' || typeof value === 'boolean') {\n\t\treturn value;\n\t}\n\n\tif (typeof value === 'number') {\n\t\treturn Number.isFinite(value) ? value : null;\n\t}\n\n\tif (value === undefined || typeof value === 'function' || typeof value === 'symbol') {\n\t\treturn null;\n\t}\n\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString();\n\t}\n\n\tif (Buffer.isBuffer(value)) {\n\t\treturn value.toString();\n\t}\n\n\tif (value instanceof Date) {\n\t\treturn value.toISOString();\n\t}\n\n\tif (value instanceof Error) {\n\t\treturn {\n\t\t\tname: value.name,\n\t\t\tmessage: value.message,\n\t\t};\n\t}\n\n\tif (Array.isArray(value)) {\n\t\treturn value.map((entry) => toJsonValue(entry, seen));\n\t}\n\n\tif (typeof value === 'object') {\n\t\tif (seen.has(value)) {\n\t\t\treturn '[Circular]';\n\t\t}\n\n\t\tseen.add(value);\n\t\tconst result: JSONObject = {};\n\t\tfor (const [key, entryValue] of Object.entries(value)) {\n\t\t\tObject.defineProperty(result, key, {\n\t\t\t\tvalue: toJsonValue(entryValue, seen),\n\t\t\t\tenumerable: true,\n\t\t\t\twritable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t}\n\t\tseen.delete(value);\n\t\treturn result;\n\t}\n\n\treturn null;\n}\n"],"mappings":";;;;;;;;AAeA,SAAgB,YAAY,OAAgB,uBAAO,IAAI,QAAgB,GAAc;CACpF,IAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,OAAO,UAAU,WACnE,OAAO;CAGR,IAAI,OAAO,UAAU,UACpB,OAAO,OAAO,SAAS,KAAK,IAAI,QAAQ;CAGzC,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,cAAc,OAAO,UAAU,UAC1E,OAAO;CAGR,IAAI,OAAO,UAAU,UACpB,OAAO,MAAM,SAAS;CAGvB,IAAI,OAAO,SAAS,KAAK,GACxB,OAAO,MAAM,SAAS;CAGvB,IAAI,iBAAiB,MACpB,OAAO,MAAM,YAAY;CAG1B,IAAI,iBAAiB,OACpB,OAAO;EACN,MAAM,MAAM;EACZ,SAAS,MAAM;CAChB;CAGD,IAAI,MAAM,QAAQ,KAAK,GACtB,OAAO,MAAM,KAAK,UAAU,YAAY,OAAO,IAAI,CAAC;CAGrD,IAAI,OAAO,UAAU,UAAU;EAC9B,IAAI,KAAK,IAAI,KAAK,GACjB,OAAO;EAGR,KAAK,IAAI,KAAK;EACd,MAAM,SAAqB,CAAC;EAC5B,KAAK,MAAM,CAAC,KAAK,eAAe,OAAO,QAAQ,KAAK,GACnD,OAAO,eAAe,QAAQ,KAAK;GAClC,OAAO,YAAY,YAAY,IAAI;GACnC,YAAY;GACZ,UAAU;GACV,cAAc;EACf,CAAC;EAEF,KAAK,OAAO,KAAK;EACjB,OAAO;CACR;CAEA,OAAO;AACR"}
|
|
@@ -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
|