@utilix-tech/sdk 0.78.0 → 0.80.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/CHANGELOG.md +8 -0
- package/README.md +21 -6
- package/dist/{ai_agent-CmrVjvYH.d.cts → ai_agent-DeCy0oZK.d.cts} +42 -2
- package/dist/{ai_agent-CmrVjvYH.d.ts → ai_agent-DeCy0oZK.d.ts} +42 -2
- package/dist/{chunk-EKIXOA7B.js → chunk-HJLGUNSO.js} +58 -1
- package/dist/{chunk-RP574L5Z.js → chunk-OFLNVDNX.js} +46 -1
- package/dist/{chunk-XT2BQWXT.js → chunk-RYSN5JNA.js} +49 -1
- package/dist/{chunk-34C6GXCC.js → chunk-WUOZHCIC.js} +217 -1
- package/dist/{code-46xO9xFf.d.cts → code-C4n621_i.d.cts} +30 -2
- package/dist/{code-46xO9xFf.d.ts → code-C4n621_i.d.ts} +30 -2
- package/dist/index.cjs +366 -0
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/{json-CaiYsGDQ.d.cts → json-Ca6gZCNB.d.cts} +45 -2
- package/dist/{json-CaiYsGDQ.d.ts → json-Ca6gZCNB.d.ts} +45 -2
- package/dist/tools/ai_agent.cjs +57 -0
- package/dist/tools/ai_agent.d.cts +1 -1
- package/dist/tools/ai_agent.d.ts +1 -1
- package/dist/tools/ai_agent.js +1 -1
- package/dist/tools/code.cjs +48 -0
- package/dist/tools/code.d.cts +1 -1
- package/dist/tools/code.d.ts +1 -1
- package/dist/tools/code.js +1 -1
- package/dist/tools/json.cjs +216 -0
- package/dist/tools/json.d.cts +1 -1
- package/dist/tools/json.d.ts +1 -1
- package/dist/tools/json.js +1 -1
- package/dist/tools/units.cjs +45 -0
- package/dist/tools/units.d.cts +1 -1
- package/dist/tools/units.d.ts +1 -1
- package/dist/tools/units.js +1 -1
- package/dist/{units-BqegyALA.d.ts → units-D7YRRwei.d.cts} +29 -2
- package/dist/{units-BqegyALA.d.cts → units-D7YRRwei.d.ts} +29 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -43,13 +43,16 @@ var __export = (target, all) => {
|
|
|
43
43
|
var json_exports = {};
|
|
44
44
|
__export(json_exports, {
|
|
45
45
|
applyJsonMergePatch: () => applyJsonMergePatch,
|
|
46
|
+
applyJsonPatch: () => applyJsonPatch,
|
|
46
47
|
csvToJson: () => csvToJson,
|
|
47
48
|
detectFormat: () => detectFormat,
|
|
48
49
|
diffJson: () => diffJson,
|
|
50
|
+
diffJsonPatch: () => diffJsonPatch,
|
|
49
51
|
evaluateJsonPath: () => evaluateJsonPath,
|
|
50
52
|
formatDiffLine: () => formatDiffLine,
|
|
51
53
|
formatJson: () => formatJson,
|
|
52
54
|
generateExample: () => generateExample,
|
|
55
|
+
generateJsonPatch: () => generateJsonPatch,
|
|
53
56
|
getJsonStats: () => getJsonStats,
|
|
54
57
|
inferGoType: () => inferGoType,
|
|
55
58
|
inferPythonType: () => inferPythonType,
|
|
@@ -1473,6 +1476,219 @@ function applyJsonMergePatch(targetJson, patchJson) {
|
|
|
1473
1476
|
}
|
|
1474
1477
|
return { result: mergeJsonPatch(target, patch) };
|
|
1475
1478
|
}
|
|
1479
|
+
function _escapeJsonPointerToken(token) {
|
|
1480
|
+
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
1481
|
+
}
|
|
1482
|
+
function _unescapeJsonPointerToken(token) {
|
|
1483
|
+
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
1484
|
+
}
|
|
1485
|
+
function _parseJsonPointer(pointer) {
|
|
1486
|
+
if (pointer === "") return [];
|
|
1487
|
+
if (!pointer.startsWith("/")) throw new Error(`Invalid JSON Pointer "${pointer}": must start with "/"`);
|
|
1488
|
+
return pointer.slice(1).split("/").map(_unescapeJsonPointerToken);
|
|
1489
|
+
}
|
|
1490
|
+
function _isPlainObject(value) {
|
|
1491
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1492
|
+
}
|
|
1493
|
+
function _deepEqual(a, b) {
|
|
1494
|
+
if (a === b) return true;
|
|
1495
|
+
if (typeof a !== typeof b) return false;
|
|
1496
|
+
if (Array.isArray(a) || Array.isArray(b)) {
|
|
1497
|
+
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) return false;
|
|
1498
|
+
return a.every((v, i) => _deepEqual(v, b[i]));
|
|
1499
|
+
}
|
|
1500
|
+
if (_isPlainObject(a) && _isPlainObject(b)) {
|
|
1501
|
+
const aKeys = Object.keys(a);
|
|
1502
|
+
const bKeys = Object.keys(b);
|
|
1503
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
1504
|
+
return aKeys.every((k) => k in b && _deepEqual(a[k], b[k]));
|
|
1505
|
+
}
|
|
1506
|
+
return false;
|
|
1507
|
+
}
|
|
1508
|
+
function _getByTokens(doc, tokens) {
|
|
1509
|
+
let current = doc;
|
|
1510
|
+
for (const token of tokens) {
|
|
1511
|
+
if (Array.isArray(current)) {
|
|
1512
|
+
const index = token === "-" ? current.length - 1 : parseInt(token, 10);
|
|
1513
|
+
if (!Number.isInteger(index) || index < 0 || index >= current.length) return { found: false, value: void 0 };
|
|
1514
|
+
current = current[index];
|
|
1515
|
+
} else if (_isPlainObject(current)) {
|
|
1516
|
+
if (!(token in current)) return { found: false, value: void 0 };
|
|
1517
|
+
current = current[token];
|
|
1518
|
+
} else {
|
|
1519
|
+
return { found: false, value: void 0 };
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return { found: true, value: current };
|
|
1523
|
+
}
|
|
1524
|
+
function diffJsonPatch(a, b) {
|
|
1525
|
+
const ops = [];
|
|
1526
|
+
_diffValue(a, b, "", ops);
|
|
1527
|
+
return ops;
|
|
1528
|
+
}
|
|
1529
|
+
function _diffValue(a, b, path, ops) {
|
|
1530
|
+
if (_deepEqual(a, b)) return;
|
|
1531
|
+
if (_isPlainObject(a) && _isPlainObject(b)) {
|
|
1532
|
+
for (const key of Object.keys(a)) {
|
|
1533
|
+
if (!(key in b)) ops.push({ op: "remove", path: `${path}/${_escapeJsonPointerToken(key)}` });
|
|
1534
|
+
}
|
|
1535
|
+
for (const key of Object.keys(b)) {
|
|
1536
|
+
const childPath = `${path}/${_escapeJsonPointerToken(key)}`;
|
|
1537
|
+
if (!(key in a)) {
|
|
1538
|
+
ops.push({ op: "add", path: childPath, value: b[key] });
|
|
1539
|
+
} else {
|
|
1540
|
+
_diffValue(a[key], b[key], childPath, ops);
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
1546
|
+
const minLen = Math.min(a.length, b.length);
|
|
1547
|
+
for (let i = 0; i < minLen; i++) {
|
|
1548
|
+
_diffValue(a[i], b[i], `${path}/${i}`, ops);
|
|
1549
|
+
}
|
|
1550
|
+
if (b.length > a.length) {
|
|
1551
|
+
for (let i = a.length; i < b.length; i++) ops.push({ op: "add", path: `${path}/${i}`, value: b[i] });
|
|
1552
|
+
} else if (a.length > b.length) {
|
|
1553
|
+
for (let i = a.length - 1; i >= b.length; i--) ops.push({ op: "remove", path: `${path}/${i}` });
|
|
1554
|
+
}
|
|
1555
|
+
return;
|
|
1556
|
+
}
|
|
1557
|
+
ops.push({ op: "replace", path, value: b });
|
|
1558
|
+
}
|
|
1559
|
+
function applyJsonPatch(target, operations) {
|
|
1560
|
+
let doc = JSON.parse(JSON.stringify(target ?? null));
|
|
1561
|
+
const applyOne = (op, index) => {
|
|
1562
|
+
if (op.path === void 0 || op.op === void 0) return `Operation ${index}: missing "op" or "path"`;
|
|
1563
|
+
let tokens;
|
|
1564
|
+
try {
|
|
1565
|
+
tokens = _parseJsonPointer(op.path);
|
|
1566
|
+
} catch (e) {
|
|
1567
|
+
return `Operation ${index}: ${e.message}`;
|
|
1568
|
+
}
|
|
1569
|
+
const setAt = (tgtTokens, value) => {
|
|
1570
|
+
if (tgtTokens.length === 0) {
|
|
1571
|
+
doc = value;
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
const parentTokens = tgtTokens.slice(0, -1);
|
|
1575
|
+
const lastToken = tgtTokens[tgtTokens.length - 1];
|
|
1576
|
+
const { found, value: parent } = _getByTokens(doc, parentTokens);
|
|
1577
|
+
if (!found) return `Operation ${index}: path "${op.path}" has no parent`;
|
|
1578
|
+
if (Array.isArray(parent)) {
|
|
1579
|
+
const idx = lastToken === "-" ? parent.length : parseInt(lastToken, 10);
|
|
1580
|
+
if (!Number.isInteger(idx) || idx < 0 || idx > parent.length) return `Operation ${index}: array index "${lastToken}" out of bounds`;
|
|
1581
|
+
parent.splice(idx, 0, value);
|
|
1582
|
+
} else if (_isPlainObject(parent)) {
|
|
1583
|
+
parent[lastToken] = value;
|
|
1584
|
+
} else {
|
|
1585
|
+
return `Operation ${index}: cannot add into a non-object, non-array value at "${op.path}"`;
|
|
1586
|
+
}
|
|
1587
|
+
return null;
|
|
1588
|
+
};
|
|
1589
|
+
const replaceAt = (tgtTokens, value) => {
|
|
1590
|
+
if (tgtTokens.length === 0) {
|
|
1591
|
+
doc = value;
|
|
1592
|
+
return null;
|
|
1593
|
+
}
|
|
1594
|
+
const parentTokens = tgtTokens.slice(0, -1);
|
|
1595
|
+
const lastToken = tgtTokens[tgtTokens.length - 1];
|
|
1596
|
+
const { found, value: parent } = _getByTokens(doc, parentTokens);
|
|
1597
|
+
if (!found) return `Operation ${index}: path "${op.path}" has no parent`;
|
|
1598
|
+
if (Array.isArray(parent)) {
|
|
1599
|
+
const idx = lastToken === "-" ? parent.length - 1 : parseInt(lastToken, 10);
|
|
1600
|
+
if (!Number.isInteger(idx) || idx < 0 || idx >= parent.length) return `Operation ${index}: array index "${lastToken}" out of bounds`;
|
|
1601
|
+
parent[idx] = value;
|
|
1602
|
+
} else if (_isPlainObject(parent)) {
|
|
1603
|
+
if (!(lastToken in parent)) return `Operation ${index}: path "${op.path}" does not exist`;
|
|
1604
|
+
parent[lastToken] = value;
|
|
1605
|
+
} else {
|
|
1606
|
+
return `Operation ${index}: cannot replace into a non-object, non-array value at "${op.path}"`;
|
|
1607
|
+
}
|
|
1608
|
+
return null;
|
|
1609
|
+
};
|
|
1610
|
+
const removeAt = (tgtTokens) => {
|
|
1611
|
+
if (tgtTokens.length === 0) return { error: `Operation ${index}: cannot remove the whole document (path "")` };
|
|
1612
|
+
const parentTokens = tgtTokens.slice(0, -1);
|
|
1613
|
+
const lastToken = tgtTokens[tgtTokens.length - 1];
|
|
1614
|
+
const { found, value: parent } = _getByTokens(doc, parentTokens);
|
|
1615
|
+
if (!found) return { error: `Operation ${index}: path "${op.path}" has no parent` };
|
|
1616
|
+
if (Array.isArray(parent)) {
|
|
1617
|
+
const idx = lastToken === "-" ? parent.length - 1 : parseInt(lastToken, 10);
|
|
1618
|
+
if (!Number.isInteger(idx) || idx < 0 || idx >= parent.length) return { error: `Operation ${index}: array index "${lastToken}" out of bounds` };
|
|
1619
|
+
const [removed] = parent.splice(idx, 1);
|
|
1620
|
+
return { error: null, removed };
|
|
1621
|
+
}
|
|
1622
|
+
if (_isPlainObject(parent)) {
|
|
1623
|
+
if (!(lastToken in parent)) return { error: `Operation ${index}: path "${op.path}" does not exist` };
|
|
1624
|
+
const removed = parent[lastToken];
|
|
1625
|
+
delete parent[lastToken];
|
|
1626
|
+
return { error: null, removed };
|
|
1627
|
+
}
|
|
1628
|
+
return { error: `Operation ${index}: cannot remove from a non-object, non-array value at "${op.path}"` };
|
|
1629
|
+
};
|
|
1630
|
+
switch (op.op) {
|
|
1631
|
+
case "add":
|
|
1632
|
+
return setAt(tokens, op.value);
|
|
1633
|
+
case "replace":
|
|
1634
|
+
return replaceAt(tokens, op.value);
|
|
1635
|
+
case "remove":
|
|
1636
|
+
return removeAt(tokens).error;
|
|
1637
|
+
case "test": {
|
|
1638
|
+
const { found, value } = _getByTokens(doc, tokens);
|
|
1639
|
+
if (!found) return `Operation ${index}: path "${op.path}" does not exist`;
|
|
1640
|
+
if (!_deepEqual(value, op.value)) return `Operation ${index}: test failed at "${op.path}"`;
|
|
1641
|
+
return null;
|
|
1642
|
+
}
|
|
1643
|
+
case "move": {
|
|
1644
|
+
if (!op.from) return `Operation ${index}: "move" requires "from"`;
|
|
1645
|
+
let fromTokens;
|
|
1646
|
+
try {
|
|
1647
|
+
fromTokens = _parseJsonPointer(op.from);
|
|
1648
|
+
} catch (e) {
|
|
1649
|
+
return `Operation ${index}: ${e.message}`;
|
|
1650
|
+
}
|
|
1651
|
+
const removal = removeAt(fromTokens);
|
|
1652
|
+
if (removal.error) return removal.error;
|
|
1653
|
+
return setAt(tokens, removal.removed);
|
|
1654
|
+
}
|
|
1655
|
+
case "copy": {
|
|
1656
|
+
if (!op.from) return `Operation ${index}: "copy" requires "from"`;
|
|
1657
|
+
let fromTokens;
|
|
1658
|
+
try {
|
|
1659
|
+
fromTokens = _parseJsonPointer(op.from);
|
|
1660
|
+
} catch (e) {
|
|
1661
|
+
return `Operation ${index}: ${e.message}`;
|
|
1662
|
+
}
|
|
1663
|
+
const { found, value } = _getByTokens(doc, fromTokens);
|
|
1664
|
+
if (!found) return `Operation ${index}: "from" path "${op.from}" does not exist`;
|
|
1665
|
+
return setAt(tokens, JSON.parse(JSON.stringify(value)));
|
|
1666
|
+
}
|
|
1667
|
+
default:
|
|
1668
|
+
return `Operation ${index}: unknown op "${op.op}"`;
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
for (let i = 0; i < operations.length; i++) {
|
|
1672
|
+
const err = applyOne(operations[i], i);
|
|
1673
|
+
if (err) return { error: err };
|
|
1674
|
+
}
|
|
1675
|
+
return { result: doc };
|
|
1676
|
+
}
|
|
1677
|
+
function generateJsonPatch(aJson, bJson) {
|
|
1678
|
+
let a;
|
|
1679
|
+
try {
|
|
1680
|
+
a = JSON.parse(aJson);
|
|
1681
|
+
} catch {
|
|
1682
|
+
return { error: "First document is not valid JSON" };
|
|
1683
|
+
}
|
|
1684
|
+
let b;
|
|
1685
|
+
try {
|
|
1686
|
+
b = JSON.parse(bJson);
|
|
1687
|
+
} catch {
|
|
1688
|
+
return { error: "Second document is not valid JSON" };
|
|
1689
|
+
}
|
|
1690
|
+
return { patch: diffJsonPatch(a, b) };
|
|
1691
|
+
}
|
|
1476
1692
|
|
|
1477
1693
|
// src/tools/encoding.ts
|
|
1478
1694
|
var encoding_exports = {};
|
|
@@ -8706,6 +8922,7 @@ __export(units_exports, {
|
|
|
8706
8922
|
calculateMovingAverages: () => calculateMovingAverages,
|
|
8707
8923
|
calculatePaybackPeriod: () => calculatePaybackPeriod,
|
|
8708
8924
|
calculatePercentageChange: () => calculatePercentageChange,
|
|
8925
|
+
calculateRealRateOfReturn: () => calculateRealRateOfReturn,
|
|
8709
8926
|
calculateRequiredBandwidth: () => calculateRequiredBandwidth,
|
|
8710
8927
|
calculateRoi: () => calculateRoi,
|
|
8711
8928
|
calculateRuleOf72: () => calculateRuleOf72,
|
|
@@ -11424,6 +11641,50 @@ function calculateRequiredBandwidth(fileSize, fileSizeUnit, targetSeconds) {
|
|
|
11424
11641
|
requiredMBps: requiredBitsPerSecond / 8 / 1e6
|
|
11425
11642
|
};
|
|
11426
11643
|
}
|
|
11644
|
+
var _REAL_RATE_FIELDS = ["nominalRatePercent", "inflationRatePercent", "realRatePercent"];
|
|
11645
|
+
function calculateRealRateOfReturn(input) {
|
|
11646
|
+
const provided = (v) => typeof v === "number" && Number.isFinite(v);
|
|
11647
|
+
const given = _REAL_RATE_FIELDS.filter((f) => provided(input[f]));
|
|
11648
|
+
if (given.length !== 2) {
|
|
11649
|
+
return { error: `Provide exactly two of nominalRatePercent, inflationRatePercent, realRatePercent (got ${given.length})` };
|
|
11650
|
+
}
|
|
11651
|
+
for (const f of given) {
|
|
11652
|
+
const v = input[f];
|
|
11653
|
+
if (v <= -100) return { error: `${f} must be greater than -100` };
|
|
11654
|
+
}
|
|
11655
|
+
const has = (f) => given.includes(f);
|
|
11656
|
+
const nominal0 = input.nominalRatePercent;
|
|
11657
|
+
const inflation0 = input.inflationRatePercent;
|
|
11658
|
+
const real0 = input.realRatePercent;
|
|
11659
|
+
let nominalRatePercent;
|
|
11660
|
+
let inflationRatePercent;
|
|
11661
|
+
let realRatePercent;
|
|
11662
|
+
let solvedFor;
|
|
11663
|
+
if (has("nominalRatePercent") && has("inflationRatePercent")) {
|
|
11664
|
+
nominalRatePercent = nominal0;
|
|
11665
|
+
inflationRatePercent = inflation0;
|
|
11666
|
+
realRatePercent = ((1 + nominal0 / 100) / (1 + inflation0 / 100) - 1) * 100;
|
|
11667
|
+
solvedFor = "realRatePercent";
|
|
11668
|
+
} else if (has("realRatePercent") && has("inflationRatePercent")) {
|
|
11669
|
+
realRatePercent = real0;
|
|
11670
|
+
inflationRatePercent = inflation0;
|
|
11671
|
+
nominalRatePercent = ((1 + real0 / 100) * (1 + inflation0 / 100) - 1) * 100;
|
|
11672
|
+
solvedFor = "nominalRatePercent";
|
|
11673
|
+
} else {
|
|
11674
|
+
nominalRatePercent = nominal0;
|
|
11675
|
+
realRatePercent = real0;
|
|
11676
|
+
inflationRatePercent = ((1 + nominal0 / 100) / (1 + real0 / 100) - 1) * 100;
|
|
11677
|
+
solvedFor = "inflationRatePercent";
|
|
11678
|
+
}
|
|
11679
|
+
const round4 = (n) => Math.round(n * 1e4) / 1e4;
|
|
11680
|
+
return {
|
|
11681
|
+
nominalRatePercent: round4(nominalRatePercent),
|
|
11682
|
+
inflationRatePercent: round4(inflationRatePercent),
|
|
11683
|
+
realRatePercent: round4(realRatePercent),
|
|
11684
|
+
given,
|
|
11685
|
+
solvedFor
|
|
11686
|
+
};
|
|
11687
|
+
}
|
|
11427
11688
|
|
|
11428
11689
|
// src/tools/network.ts
|
|
11429
11690
|
var network_exports = {};
|
|
@@ -16512,6 +16773,7 @@ __export(code_exports, {
|
|
|
16512
16773
|
minifySql: () => minifySql,
|
|
16513
16774
|
normalizeRef: () => normalizeRef,
|
|
16514
16775
|
parseCommitTrailers: () => parseCommitTrailers,
|
|
16776
|
+
parseConnectionString: () => parseConnectionString,
|
|
16515
16777
|
parseDockerImage: () => parseDockerImage,
|
|
16516
16778
|
parseEnv: () => parseEnv2,
|
|
16517
16779
|
parseGitCommand: () => parseGitCommand,
|
|
@@ -20344,6 +20606,53 @@ function validateAria(html) {
|
|
|
20344
20606
|
valid: issues.every((i) => i.severity !== "error")
|
|
20345
20607
|
};
|
|
20346
20608
|
}
|
|
20609
|
+
var CONNECTION_STRING_RE = /^([a-zA-Z][a-zA-Z0-9+.-]*):\/\/(?:([^@/?#]*)@)?([^/?#]*)(?:\/([^?#]*))?(?:\?([^#]*))?$/;
|
|
20610
|
+
function _parseConnectionHost(segment) {
|
|
20611
|
+
const ipv6Match = segment.match(/^\[([^\]]+)\](?::(\d+))?$/);
|
|
20612
|
+
if (ipv6Match) {
|
|
20613
|
+
return { host: ipv6Match[1], port: ipv6Match[2] ? parseInt(ipv6Match[2], 10) : null };
|
|
20614
|
+
}
|
|
20615
|
+
const lastColon = segment.lastIndexOf(":");
|
|
20616
|
+
if (lastColon === -1) return { host: segment, port: null };
|
|
20617
|
+
const portPart = segment.slice(lastColon + 1);
|
|
20618
|
+
if (!/^\d+$/.test(portPart)) return { host: segment, port: null };
|
|
20619
|
+
return { host: segment.slice(0, lastColon), port: parseInt(portPart, 10) };
|
|
20620
|
+
}
|
|
20621
|
+
function parseConnectionString(input) {
|
|
20622
|
+
if (!input || typeof input !== "string" || !input.trim()) {
|
|
20623
|
+
return { error: "Connection string is empty" };
|
|
20624
|
+
}
|
|
20625
|
+
const trimmed = input.trim();
|
|
20626
|
+
const match = trimmed.match(CONNECTION_STRING_RE);
|
|
20627
|
+
if (!match) {
|
|
20628
|
+
return { error: "Not a valid scheme://[user[:password]@]host[,host2][/database][?params] connection string" };
|
|
20629
|
+
}
|
|
20630
|
+
const [, scheme, userinfo, hostPart, databasePart, queryPart] = match;
|
|
20631
|
+
let user = null;
|
|
20632
|
+
let password = null;
|
|
20633
|
+
if (userinfo) {
|
|
20634
|
+
const sepIndex = userinfo.indexOf(":");
|
|
20635
|
+
if (sepIndex === -1) {
|
|
20636
|
+
user = decodeURIComponent(userinfo);
|
|
20637
|
+
} else {
|
|
20638
|
+
user = decodeURIComponent(userinfo.slice(0, sepIndex));
|
|
20639
|
+
password = decodeURIComponent(userinfo.slice(sepIndex + 1));
|
|
20640
|
+
}
|
|
20641
|
+
}
|
|
20642
|
+
const hosts = hostPart ? hostPart.split(",").filter(Boolean).map(_parseConnectionHost) : [];
|
|
20643
|
+
const database = databasePart ? decodeURIComponent(databasePart) : null;
|
|
20644
|
+
const params = {};
|
|
20645
|
+
if (queryPart) {
|
|
20646
|
+
for (const pair of queryPart.split("&")) {
|
|
20647
|
+
if (!pair) continue;
|
|
20648
|
+
const eqIndex = pair.indexOf("=");
|
|
20649
|
+
const key = eqIndex === -1 ? pair : pair.slice(0, eqIndex);
|
|
20650
|
+
const value = eqIndex === -1 ? "" : pair.slice(eqIndex + 1);
|
|
20651
|
+
params[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
20652
|
+
}
|
|
20653
|
+
}
|
|
20654
|
+
return { scheme, user, password, hosts, database, params };
|
|
20655
|
+
}
|
|
20347
20656
|
|
|
20348
20657
|
// src/tools/color.ts
|
|
20349
20658
|
var color_exports = {};
|
|
@@ -23928,6 +24237,7 @@ function generateMetaHtml2(tags) {
|
|
|
23928
24237
|
var ai_agent_exports = {};
|
|
23929
24238
|
__export(ai_agent_exports, {
|
|
23930
24239
|
MODEL_PRICING: () => MODEL_PRICING,
|
|
24240
|
+
calculateRetryBackoffSchedule: () => calculateRetryBackoffSchedule,
|
|
23931
24241
|
chunkText: () => chunkText,
|
|
23932
24242
|
compressHtml: () => compressHtml,
|
|
23933
24243
|
compressJson: () => compressJson,
|
|
@@ -25040,6 +25350,62 @@ function lintToolSchema(jsonText) {
|
|
|
25040
25350
|
const valid = !issues.some((i) => i.severity === "error");
|
|
25041
25351
|
return { toolCount: normalized.length, issues, valid };
|
|
25042
25352
|
}
|
|
25353
|
+
function calculateRetryBackoffSchedule(input) {
|
|
25354
|
+
const { baseDelayMs, multiplier, maxRetries, maxDelayMs, jitter = "none" } = input;
|
|
25355
|
+
if (!Number.isFinite(baseDelayMs) || baseDelayMs <= 0) {
|
|
25356
|
+
return { error: "baseDelayMs must be a finite number greater than zero" };
|
|
25357
|
+
}
|
|
25358
|
+
if (!Number.isFinite(multiplier) || multiplier < 1) {
|
|
25359
|
+
return { error: "multiplier must be a finite number of at least 1" };
|
|
25360
|
+
}
|
|
25361
|
+
if (!Number.isInteger(maxRetries) || maxRetries < 1 || maxRetries > 50) {
|
|
25362
|
+
return { error: "maxRetries must be a whole number between 1 and 50" };
|
|
25363
|
+
}
|
|
25364
|
+
if (maxDelayMs !== void 0 && maxDelayMs !== null) {
|
|
25365
|
+
if (!Number.isFinite(maxDelayMs) || maxDelayMs <= 0) {
|
|
25366
|
+
return { error: "maxDelayMs must be a finite number greater than zero when provided" };
|
|
25367
|
+
}
|
|
25368
|
+
}
|
|
25369
|
+
if (jitter !== "none" && jitter !== "full" && jitter !== "equal") {
|
|
25370
|
+
return { error: "jitter must be one of 'none', 'full', or 'equal'" };
|
|
25371
|
+
}
|
|
25372
|
+
const round0 = (n) => Math.round(n);
|
|
25373
|
+
const attempts = [];
|
|
25374
|
+
let totalBestCaseMs = 0;
|
|
25375
|
+
let totalWorstCaseMs = 0;
|
|
25376
|
+
for (let i = 1; i <= maxRetries; i++) {
|
|
25377
|
+
let nominal = baseDelayMs * Math.pow(multiplier, i - 1);
|
|
25378
|
+
if (maxDelayMs !== void 0 && maxDelayMs !== null) {
|
|
25379
|
+
nominal = Math.min(nominal, maxDelayMs);
|
|
25380
|
+
}
|
|
25381
|
+
let minDelay;
|
|
25382
|
+
let maxDelay;
|
|
25383
|
+
if (jitter === "full") {
|
|
25384
|
+
minDelay = 0;
|
|
25385
|
+
maxDelay = nominal;
|
|
25386
|
+
} else if (jitter === "equal") {
|
|
25387
|
+
minDelay = nominal / 2;
|
|
25388
|
+
maxDelay = nominal;
|
|
25389
|
+
} else {
|
|
25390
|
+
minDelay = nominal;
|
|
25391
|
+
maxDelay = nominal;
|
|
25392
|
+
}
|
|
25393
|
+
attempts.push({
|
|
25394
|
+
attempt: i,
|
|
25395
|
+
nominalDelayMs: round0(nominal),
|
|
25396
|
+
minDelayMs: round0(minDelay),
|
|
25397
|
+
maxDelayMs: round0(maxDelay)
|
|
25398
|
+
});
|
|
25399
|
+
totalBestCaseMs += minDelay;
|
|
25400
|
+
totalWorstCaseMs += maxDelay;
|
|
25401
|
+
}
|
|
25402
|
+
return {
|
|
25403
|
+
attempts,
|
|
25404
|
+
jitter,
|
|
25405
|
+
totalBestCaseMs: round0(totalBestCaseMs),
|
|
25406
|
+
totalWorstCaseMs: round0(totalWorstCaseMs)
|
|
25407
|
+
};
|
|
25408
|
+
}
|
|
25043
25409
|
|
|
25044
25410
|
// src/tools/media.ts
|
|
25045
25411
|
var media_exports = {};
|
package/dist/index.d.cts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { j as json } from './json-
|
|
1
|
+
export { j as json } from './json-Ca6gZCNB.cjs';
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.cjs';
|
|
3
3
|
export { h as hashing } from './hashing-CJjlvqS_.cjs';
|
|
4
4
|
export { t as text } from './text-CNn3whZA.cjs';
|
|
5
5
|
export { d as data } from './data-DIyBrJ6l.cjs';
|
|
6
6
|
export { g as generators } from './generators-DAXXrMvG.cjs';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.cjs';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-D7YRRwei.cjs';
|
|
9
9
|
export { n as network } from './network-BskZe1n2.cjs';
|
|
10
10
|
export { a as api } from './api-CQnIUrVB.cjs';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-C4n621_i.cjs';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.cjs';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.cjs';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.cjs';
|
|
15
|
-
export { a as ai_agent } from './ai_agent-
|
|
15
|
+
export { a as ai_agent } from './ai_agent-DeCy0oZK.cjs';
|
|
16
16
|
export { m as media } from './media-DF8BS-iA.cjs';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { j as json } from './json-
|
|
1
|
+
export { j as json } from './json-Ca6gZCNB.js';
|
|
2
2
|
export { e as encoding } from './encoding-Dk3wpmb3.js';
|
|
3
3
|
export { h as hashing } from './hashing-CJjlvqS_.js';
|
|
4
4
|
export { t as text } from './text-CNn3whZA.js';
|
|
5
5
|
export { d as data } from './data-DIyBrJ6l.js';
|
|
6
6
|
export { g as generators } from './generators-DAXXrMvG.js';
|
|
7
7
|
export { t as time } from './time-KqJjdqII.js';
|
|
8
|
-
export { u as units } from './units-
|
|
8
|
+
export { u as units } from './units-D7YRRwei.js';
|
|
9
9
|
export { n as network } from './network-BskZe1n2.js';
|
|
10
10
|
export { a as api } from './api-CQnIUrVB.js';
|
|
11
|
-
export { c as code } from './code-
|
|
11
|
+
export { c as code } from './code-C4n621_i.js';
|
|
12
12
|
export { c as color } from './color-tPwZCr9H.js';
|
|
13
13
|
export { c as css } from './css-Cf7AMGM-.js';
|
|
14
14
|
export { m as misc } from './misc-CA3N198T.js';
|
|
15
|
-
export { a as ai_agent } from './ai_agent-
|
|
15
|
+
export { a as ai_agent } from './ai_agent-DeCy0oZK.js';
|
|
16
16
|
export { m as media } from './media-DF8BS-iA.js';
|
|
17
17
|
|
|
18
18
|
declare const version = "0.1.0";
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export { media_exports as media } from './chunk-ZWFZRDQ4.js';
|
|
2
|
-
export { units_exports as units } from './chunk-
|
|
2
|
+
export { units_exports as units } from './chunk-OFLNVDNX.js';
|
|
3
3
|
export { network_exports as network } from './chunk-KWS4ZCYG.js';
|
|
4
4
|
export { api_exports as api } from './chunk-U2HREMZU.js';
|
|
5
|
-
export { code_exports as code } from './chunk-
|
|
5
|
+
export { code_exports as code } from './chunk-RYSN5JNA.js';
|
|
6
6
|
export { color_exports as color } from './chunk-BPVAB4P2.js';
|
|
7
7
|
export { css_exports as css } from './chunk-6YPV2AB5.js';
|
|
8
8
|
export { misc_exports as misc } from './chunk-GX7H6TAX.js';
|
|
9
|
-
export { ai_agent_exports as ai_agent } from './chunk-
|
|
10
|
-
export { json_exports as json } from './chunk-
|
|
9
|
+
export { ai_agent_exports as ai_agent } from './chunk-HJLGUNSO.js';
|
|
10
|
+
export { json_exports as json } from './chunk-WUOZHCIC.js';
|
|
11
11
|
export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
|
|
12
12
|
export { hashing_exports as hashing } from './chunk-PET2CGTH.js';
|
|
13
13
|
export { text_exports as text } from './chunk-QVOK3BXM.js';
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* - json-to-zod : jsonToZod
|
|
16
16
|
* - json-schema-to-typescript : jsonSchemaToTypescript
|
|
17
17
|
* - json-merge-patch : mergeJsonPatch, applyJsonMergePatch
|
|
18
|
+
* - json-patch : diffJsonPatch, applyJsonPatch, generateJsonPatch
|
|
18
19
|
*/
|
|
19
20
|
type ParseStatus = 'idle' | 'valid' | 'error';
|
|
20
21
|
interface JsonParseResult {
|
|
@@ -220,6 +221,43 @@ declare function mergeJsonPatch(target: unknown, patch: unknown): unknown;
|
|
|
220
221
|
declare function applyJsonMergePatch(targetJson: string, patchJson: string): MergePatchResult | {
|
|
221
222
|
error: string;
|
|
222
223
|
};
|
|
224
|
+
type JsonPatchOp = 'add' | 'remove' | 'replace' | 'move' | 'copy' | 'test';
|
|
225
|
+
interface JsonPatchOperation {
|
|
226
|
+
op: JsonPatchOp;
|
|
227
|
+
path: string;
|
|
228
|
+
value?: unknown;
|
|
229
|
+
from?: string;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Generates a minimal (naive, index-by-index for arrays) RFC 6902 JSON
|
|
233
|
+
* Patch document describing how to transform `a` into `b`. Object keys
|
|
234
|
+
* produce add/remove/replace; arrays are compared position by position,
|
|
235
|
+
* with removes emitted from the highest index down and adds appended at
|
|
236
|
+
* the end, so the resulting patch applies correctly in order. This is not
|
|
237
|
+
* a minimal-edit-distance diff (it won't detect a reordering as a move) —
|
|
238
|
+
* just a direct, deterministic structural comparison.
|
|
239
|
+
*/
|
|
240
|
+
declare function diffJsonPatch(a: unknown, b: unknown): JsonPatchOperation[];
|
|
241
|
+
/**
|
|
242
|
+
* Applies a sequence of RFC 6902 JSON Patch operations to a target
|
|
243
|
+
* document and returns the result, or an error naming the failing
|
|
244
|
+
* operation's index. Supports add, remove, replace, move, copy, and test.
|
|
245
|
+
* The input document is not mutated.
|
|
246
|
+
*/
|
|
247
|
+
declare function applyJsonPatch(target: unknown, operations: JsonPatchOperation[]): {
|
|
248
|
+
result: unknown;
|
|
249
|
+
} | {
|
|
250
|
+
error: string;
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* Convenience wrapper: diffs two JSON documents given as strings and
|
|
254
|
+
* returns the generated RFC 6902 patch, or a parse error.
|
|
255
|
+
*/
|
|
256
|
+
declare function generateJsonPatch(aJson: string, bJson: string): {
|
|
257
|
+
patch: JsonPatchOperation[];
|
|
258
|
+
} | {
|
|
259
|
+
error: string;
|
|
260
|
+
};
|
|
223
261
|
|
|
224
262
|
type json_ConvertOptions = ConvertOptions;
|
|
225
263
|
type json_CsvOptions = CsvOptions;
|
|
@@ -229,6 +267,8 @@ type json_GoField = GoField;
|
|
|
229
267
|
type json_GoStruct = GoStruct;
|
|
230
268
|
type json_JsonDiffResult = JsonDiffResult;
|
|
231
269
|
type json_JsonParseResult = JsonParseResult;
|
|
270
|
+
type json_JsonPatchOp = JsonPatchOp;
|
|
271
|
+
type json_JsonPatchOperation = JsonPatchOperation;
|
|
232
272
|
type json_JsonPathResult = JsonPathResult;
|
|
233
273
|
type json_JsonPointerResult = JsonPointerResult;
|
|
234
274
|
type json_JsonSchemaLike = JsonSchemaLike;
|
|
@@ -242,13 +282,16 @@ type json_ValidationError = ValidationError;
|
|
|
242
282
|
type json_ValidationResult = ValidationResult;
|
|
243
283
|
type json_ZodOptions = ZodOptions;
|
|
244
284
|
declare const json_applyJsonMergePatch: typeof applyJsonMergePatch;
|
|
285
|
+
declare const json_applyJsonPatch: typeof applyJsonPatch;
|
|
245
286
|
declare const json_csvToJson: typeof csvToJson;
|
|
246
287
|
declare const json_detectFormat: typeof detectFormat;
|
|
247
288
|
declare const json_diffJson: typeof diffJson;
|
|
289
|
+
declare const json_diffJsonPatch: typeof diffJsonPatch;
|
|
248
290
|
declare const json_evaluateJsonPath: typeof evaluateJsonPath;
|
|
249
291
|
declare const json_formatDiffLine: typeof formatDiffLine;
|
|
250
292
|
declare const json_formatJson: typeof formatJson;
|
|
251
293
|
declare const json_generateExample: typeof generateExample;
|
|
294
|
+
declare const json_generateJsonPatch: typeof generateJsonPatch;
|
|
252
295
|
declare const json_getJsonStats: typeof getJsonStats;
|
|
253
296
|
declare const json_inferGoType: typeof inferGoType;
|
|
254
297
|
declare const json_inferPythonType: typeof inferPythonType;
|
|
@@ -272,7 +315,7 @@ declare const json_validateJsonPath: typeof validateJsonPath;
|
|
|
272
315
|
declare const json_validateJsonString: typeof validateJsonString;
|
|
273
316
|
declare const json_yamlToJson: typeof yamlToJson;
|
|
274
317
|
declare namespace json {
|
|
275
|
-
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_MergePatchResult as MergePatchResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_applyJsonMergePatch as applyJsonMergePatch, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_mergeJsonPatch as mergeJsonPatch, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
318
|
+
export { type json_ConvertOptions as ConvertOptions, type json_CsvOptions as CsvOptions, type json_DiffNode as DiffNode, type json_DiffType as DiffType, type json_GoField as GoField, type json_GoStruct as GoStruct, type json_JsonDiffResult as JsonDiffResult, type json_JsonParseResult as JsonParseResult, type json_JsonPatchOp as JsonPatchOp, type json_JsonPatchOperation as JsonPatchOperation, type json_JsonPathResult as JsonPathResult, type json_JsonPointerResult as JsonPointerResult, type json_JsonSchemaLike as JsonSchemaLike, type json_JsonSchemaToTsOptions as JsonSchemaToTsOptions, type json_MergePatchResult as MergePatchResult, type json_ParseStatus as ParseStatus, type json_PythonClass as PythonClass, type json_PythonField as PythonField, type json_PythonMode as PythonMode, type json_ValidationError as ValidationError, type json_ValidationResult as ValidationResult, type json_ZodOptions as ZodOptions, json_applyJsonMergePatch as applyJsonMergePatch, json_applyJsonPatch as applyJsonPatch, json_csvToJson as csvToJson, json_detectFormat as detectFormat, json_diffJson as diffJson, json_diffJsonPatch as diffJsonPatch, json_evaluateJsonPath as evaluateJsonPath, json_formatDiffLine as formatDiffLine, json_formatJson as formatJson, json_generateExample as generateExample, json_generateJsonPatch as generateJsonPatch, json_getJsonStats as getJsonStats, json_inferGoType as inferGoType, json_inferPythonType as inferPythonType, json_inferType as inferType, json_jsonSchemaToTypescript as jsonSchemaToTypescript, json_jsonToCsv as jsonToCsv, json_jsonToGo as jsonToGo, json_jsonToPython as jsonToPython, json_jsonToTypescript as jsonToTypescript, json_jsonToYaml as jsonToYaml, json_jsonToZod as jsonToZod, json_mergeJsonPatch as mergeJsonPatch, json_minifyJson as minifyJson, json_parseJson as parseJson, json_parseStructs as parseStructs, json_resolveJsonPointer as resolveJsonPointer, json_toPascalCase as toPascalCase, json_toSnakeCase as toSnakeCase, json_validateJson as validateJson, json_validateJsonPath as validateJsonPath, json_validateJsonString as validateJsonString, json_yamlToJson as yamlToJson };
|
|
276
319
|
}
|
|
277
320
|
|
|
278
|
-
export {
|
|
321
|
+
export { validateJsonPath as $, getJsonStats as A, inferGoType as B, type ConvertOptions as C, type DiffNode as D, inferPythonType as E, inferType as F, type GoField as G, jsonSchemaToTypescript as H, jsonToCsv as I, type JsonDiffResult as J, jsonToGo as K, jsonToPython as L, type MergePatchResult as M, jsonToTypescript as N, jsonToYaml as O, type ParseStatus as P, jsonToZod as Q, mergeJsonPatch as R, minifyJson as S, parseJson as T, parseStructs as U, type ValidationError as V, resolveJsonPointer as W, toPascalCase as X, toSnakeCase as Y, type ZodOptions as Z, validateJson as _, type CsvOptions as a, validateJsonString as a0, yamlToJson as a1, type DiffType as b, type GoStruct as c, type JsonParseResult as d, type JsonPatchOp as e, type JsonPatchOperation as f, type JsonPathResult as g, type JsonPointerResult as h, type JsonSchemaLike as i, json as j, type JsonSchemaToTsOptions as k, type PythonClass as l, type PythonField as m, type PythonMode as n, type ValidationResult as o, applyJsonMergePatch as p, applyJsonPatch as q, csvToJson as r, detectFormat as s, diffJson as t, diffJsonPatch as u, evaluateJsonPath as v, formatDiffLine as w, formatJson as x, generateExample as y, generateJsonPatch as z };
|