@devness/useai-cli 0.4.5 → 0.4.7
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/index.js +346 -207
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ var __export = (target, all) => {
|
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
|
-
import { Command as
|
|
9
|
+
import { Command as Command11 } from "commander";
|
|
10
10
|
|
|
11
11
|
// ../shared/dist/constants/paths.js
|
|
12
12
|
import { join } from "path";
|
|
@@ -30,7 +30,7 @@ var SYSTEMD_SERVICE_PATH = join(homedir(), ".config", "systemd", "user", "useai-
|
|
|
30
30
|
var WINDOWS_STARTUP_SCRIPT_PATH = join(process.env["APPDATA"] ?? join(homedir(), "AppData", "Roaming"), "Microsoft", "Windows", "Start Menu", "Programs", "Startup", "useai-daemon.vbs");
|
|
31
31
|
|
|
32
32
|
// ../shared/dist/constants/version.js
|
|
33
|
-
var VERSION = "0.4.
|
|
33
|
+
var VERSION = "0.4.7";
|
|
34
34
|
|
|
35
35
|
// ../shared/dist/constants/defaults.js
|
|
36
36
|
var DEFAULT_CONFIG = {
|
|
@@ -1079,41 +1079,41 @@ var ZodType = class {
|
|
|
1079
1079
|
get description() {
|
|
1080
1080
|
return this._def.description;
|
|
1081
1081
|
}
|
|
1082
|
-
_getType(
|
|
1083
|
-
return getParsedType(
|
|
1082
|
+
_getType(input2) {
|
|
1083
|
+
return getParsedType(input2.data);
|
|
1084
1084
|
}
|
|
1085
|
-
_getOrReturnCtx(
|
|
1085
|
+
_getOrReturnCtx(input2, ctx) {
|
|
1086
1086
|
return ctx || {
|
|
1087
|
-
common:
|
|
1088
|
-
data:
|
|
1089
|
-
parsedType: getParsedType(
|
|
1087
|
+
common: input2.parent.common,
|
|
1088
|
+
data: input2.data,
|
|
1089
|
+
parsedType: getParsedType(input2.data),
|
|
1090
1090
|
schemaErrorMap: this._def.errorMap,
|
|
1091
|
-
path:
|
|
1092
|
-
parent:
|
|
1091
|
+
path: input2.path,
|
|
1092
|
+
parent: input2.parent
|
|
1093
1093
|
};
|
|
1094
1094
|
}
|
|
1095
|
-
_processInputParams(
|
|
1095
|
+
_processInputParams(input2) {
|
|
1096
1096
|
return {
|
|
1097
1097
|
status: new ParseStatus(),
|
|
1098
1098
|
ctx: {
|
|
1099
|
-
common:
|
|
1100
|
-
data:
|
|
1101
|
-
parsedType: getParsedType(
|
|
1099
|
+
common: input2.parent.common,
|
|
1100
|
+
data: input2.data,
|
|
1101
|
+
parsedType: getParsedType(input2.data),
|
|
1102
1102
|
schemaErrorMap: this._def.errorMap,
|
|
1103
|
-
path:
|
|
1104
|
-
parent:
|
|
1103
|
+
path: input2.path,
|
|
1104
|
+
parent: input2.parent
|
|
1105
1105
|
}
|
|
1106
1106
|
};
|
|
1107
1107
|
}
|
|
1108
|
-
_parseSync(
|
|
1109
|
-
const result = this._parse(
|
|
1108
|
+
_parseSync(input2) {
|
|
1109
|
+
const result = this._parse(input2);
|
|
1110
1110
|
if (isAsync(result)) {
|
|
1111
1111
|
throw new Error("Synchronous parse encountered promise.");
|
|
1112
1112
|
}
|
|
1113
1113
|
return result;
|
|
1114
1114
|
}
|
|
1115
|
-
_parseAsync(
|
|
1116
|
-
const result = this._parse(
|
|
1115
|
+
_parseAsync(input2) {
|
|
1116
|
+
const result = this._parse(input2);
|
|
1117
1117
|
return Promise.resolve(result);
|
|
1118
1118
|
}
|
|
1119
1119
|
parse(data, params) {
|
|
@@ -1439,13 +1439,13 @@ function isValidCidr(ip, version) {
|
|
|
1439
1439
|
return false;
|
|
1440
1440
|
}
|
|
1441
1441
|
var ZodString = class _ZodString extends ZodType {
|
|
1442
|
-
_parse(
|
|
1442
|
+
_parse(input2) {
|
|
1443
1443
|
if (this._def.coerce) {
|
|
1444
|
-
|
|
1444
|
+
input2.data = String(input2.data);
|
|
1445
1445
|
}
|
|
1446
|
-
const parsedType = this._getType(
|
|
1446
|
+
const parsedType = this._getType(input2);
|
|
1447
1447
|
if (parsedType !== ZodParsedType.string) {
|
|
1448
|
-
const ctx2 = this._getOrReturnCtx(
|
|
1448
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
1449
1449
|
addIssueToContext(ctx2, {
|
|
1450
1450
|
code: ZodIssueCode.invalid_type,
|
|
1451
1451
|
expected: ZodParsedType.string,
|
|
@@ -1457,8 +1457,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1457
1457
|
let ctx = void 0;
|
|
1458
1458
|
for (const check of this._def.checks) {
|
|
1459
1459
|
if (check.kind === "min") {
|
|
1460
|
-
if (
|
|
1461
|
-
ctx = this._getOrReturnCtx(
|
|
1460
|
+
if (input2.data.length < check.value) {
|
|
1461
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1462
1462
|
addIssueToContext(ctx, {
|
|
1463
1463
|
code: ZodIssueCode.too_small,
|
|
1464
1464
|
minimum: check.value,
|
|
@@ -1470,8 +1470,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1470
1470
|
status.dirty();
|
|
1471
1471
|
}
|
|
1472
1472
|
} else if (check.kind === "max") {
|
|
1473
|
-
if (
|
|
1474
|
-
ctx = this._getOrReturnCtx(
|
|
1473
|
+
if (input2.data.length > check.value) {
|
|
1474
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1475
1475
|
addIssueToContext(ctx, {
|
|
1476
1476
|
code: ZodIssueCode.too_big,
|
|
1477
1477
|
maximum: check.value,
|
|
@@ -1483,10 +1483,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1483
1483
|
status.dirty();
|
|
1484
1484
|
}
|
|
1485
1485
|
} else if (check.kind === "length") {
|
|
1486
|
-
const tooBig =
|
|
1487
|
-
const tooSmall =
|
|
1486
|
+
const tooBig = input2.data.length > check.value;
|
|
1487
|
+
const tooSmall = input2.data.length < check.value;
|
|
1488
1488
|
if (tooBig || tooSmall) {
|
|
1489
|
-
ctx = this._getOrReturnCtx(
|
|
1489
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1490
1490
|
if (tooBig) {
|
|
1491
1491
|
addIssueToContext(ctx, {
|
|
1492
1492
|
code: ZodIssueCode.too_big,
|
|
@@ -1509,8 +1509,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1509
1509
|
status.dirty();
|
|
1510
1510
|
}
|
|
1511
1511
|
} else if (check.kind === "email") {
|
|
1512
|
-
if (!emailRegex.test(
|
|
1513
|
-
ctx = this._getOrReturnCtx(
|
|
1512
|
+
if (!emailRegex.test(input2.data)) {
|
|
1513
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1514
1514
|
addIssueToContext(ctx, {
|
|
1515
1515
|
validation: "email",
|
|
1516
1516
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1522,8 +1522,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1522
1522
|
if (!emojiRegex) {
|
|
1523
1523
|
emojiRegex = new RegExp(_emojiRegex, "u");
|
|
1524
1524
|
}
|
|
1525
|
-
if (!emojiRegex.test(
|
|
1526
|
-
ctx = this._getOrReturnCtx(
|
|
1525
|
+
if (!emojiRegex.test(input2.data)) {
|
|
1526
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1527
1527
|
addIssueToContext(ctx, {
|
|
1528
1528
|
validation: "emoji",
|
|
1529
1529
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1532,8 +1532,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1532
1532
|
status.dirty();
|
|
1533
1533
|
}
|
|
1534
1534
|
} else if (check.kind === "uuid") {
|
|
1535
|
-
if (!uuidRegex.test(
|
|
1536
|
-
ctx = this._getOrReturnCtx(
|
|
1535
|
+
if (!uuidRegex.test(input2.data)) {
|
|
1536
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1537
1537
|
addIssueToContext(ctx, {
|
|
1538
1538
|
validation: "uuid",
|
|
1539
1539
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1542,8 +1542,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1542
1542
|
status.dirty();
|
|
1543
1543
|
}
|
|
1544
1544
|
} else if (check.kind === "nanoid") {
|
|
1545
|
-
if (!nanoidRegex.test(
|
|
1546
|
-
ctx = this._getOrReturnCtx(
|
|
1545
|
+
if (!nanoidRegex.test(input2.data)) {
|
|
1546
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1547
1547
|
addIssueToContext(ctx, {
|
|
1548
1548
|
validation: "nanoid",
|
|
1549
1549
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1552,8 +1552,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1552
1552
|
status.dirty();
|
|
1553
1553
|
}
|
|
1554
1554
|
} else if (check.kind === "cuid") {
|
|
1555
|
-
if (!cuidRegex.test(
|
|
1556
|
-
ctx = this._getOrReturnCtx(
|
|
1555
|
+
if (!cuidRegex.test(input2.data)) {
|
|
1556
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1557
1557
|
addIssueToContext(ctx, {
|
|
1558
1558
|
validation: "cuid",
|
|
1559
1559
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1562,8 +1562,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1562
1562
|
status.dirty();
|
|
1563
1563
|
}
|
|
1564
1564
|
} else if (check.kind === "cuid2") {
|
|
1565
|
-
if (!cuid2Regex.test(
|
|
1566
|
-
ctx = this._getOrReturnCtx(
|
|
1565
|
+
if (!cuid2Regex.test(input2.data)) {
|
|
1566
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1567
1567
|
addIssueToContext(ctx, {
|
|
1568
1568
|
validation: "cuid2",
|
|
1569
1569
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1572,8 +1572,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1572
1572
|
status.dirty();
|
|
1573
1573
|
}
|
|
1574
1574
|
} else if (check.kind === "ulid") {
|
|
1575
|
-
if (!ulidRegex.test(
|
|
1576
|
-
ctx = this._getOrReturnCtx(
|
|
1575
|
+
if (!ulidRegex.test(input2.data)) {
|
|
1576
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1577
1577
|
addIssueToContext(ctx, {
|
|
1578
1578
|
validation: "ulid",
|
|
1579
1579
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1583,9 +1583,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1583
1583
|
}
|
|
1584
1584
|
} else if (check.kind === "url") {
|
|
1585
1585
|
try {
|
|
1586
|
-
new URL(
|
|
1586
|
+
new URL(input2.data);
|
|
1587
1587
|
} catch {
|
|
1588
|
-
ctx = this._getOrReturnCtx(
|
|
1588
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1589
1589
|
addIssueToContext(ctx, {
|
|
1590
1590
|
validation: "url",
|
|
1591
1591
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1595,9 +1595,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1595
1595
|
}
|
|
1596
1596
|
} else if (check.kind === "regex") {
|
|
1597
1597
|
check.regex.lastIndex = 0;
|
|
1598
|
-
const testResult = check.regex.test(
|
|
1598
|
+
const testResult = check.regex.test(input2.data);
|
|
1599
1599
|
if (!testResult) {
|
|
1600
|
-
ctx = this._getOrReturnCtx(
|
|
1600
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1601
1601
|
addIssueToContext(ctx, {
|
|
1602
1602
|
validation: "regex",
|
|
1603
1603
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1606,10 +1606,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1606
1606
|
status.dirty();
|
|
1607
1607
|
}
|
|
1608
1608
|
} else if (check.kind === "trim") {
|
|
1609
|
-
|
|
1609
|
+
input2.data = input2.data.trim();
|
|
1610
1610
|
} else if (check.kind === "includes") {
|
|
1611
|
-
if (!
|
|
1612
|
-
ctx = this._getOrReturnCtx(
|
|
1611
|
+
if (!input2.data.includes(check.value, check.position)) {
|
|
1612
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1613
1613
|
addIssueToContext(ctx, {
|
|
1614
1614
|
code: ZodIssueCode.invalid_string,
|
|
1615
1615
|
validation: { includes: check.value, position: check.position },
|
|
@@ -1618,12 +1618,12 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1618
1618
|
status.dirty();
|
|
1619
1619
|
}
|
|
1620
1620
|
} else if (check.kind === "toLowerCase") {
|
|
1621
|
-
|
|
1621
|
+
input2.data = input2.data.toLowerCase();
|
|
1622
1622
|
} else if (check.kind === "toUpperCase") {
|
|
1623
|
-
|
|
1623
|
+
input2.data = input2.data.toUpperCase();
|
|
1624
1624
|
} else if (check.kind === "startsWith") {
|
|
1625
|
-
if (!
|
|
1626
|
-
ctx = this._getOrReturnCtx(
|
|
1625
|
+
if (!input2.data.startsWith(check.value)) {
|
|
1626
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1627
1627
|
addIssueToContext(ctx, {
|
|
1628
1628
|
code: ZodIssueCode.invalid_string,
|
|
1629
1629
|
validation: { startsWith: check.value },
|
|
@@ -1632,8 +1632,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1632
1632
|
status.dirty();
|
|
1633
1633
|
}
|
|
1634
1634
|
} else if (check.kind === "endsWith") {
|
|
1635
|
-
if (!
|
|
1636
|
-
ctx = this._getOrReturnCtx(
|
|
1635
|
+
if (!input2.data.endsWith(check.value)) {
|
|
1636
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1637
1637
|
addIssueToContext(ctx, {
|
|
1638
1638
|
code: ZodIssueCode.invalid_string,
|
|
1639
1639
|
validation: { endsWith: check.value },
|
|
@@ -1643,8 +1643,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1643
1643
|
}
|
|
1644
1644
|
} else if (check.kind === "datetime") {
|
|
1645
1645
|
const regex = datetimeRegex(check);
|
|
1646
|
-
if (!regex.test(
|
|
1647
|
-
ctx = this._getOrReturnCtx(
|
|
1646
|
+
if (!regex.test(input2.data)) {
|
|
1647
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1648
1648
|
addIssueToContext(ctx, {
|
|
1649
1649
|
code: ZodIssueCode.invalid_string,
|
|
1650
1650
|
validation: "datetime",
|
|
@@ -1654,8 +1654,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
} else if (check.kind === "date") {
|
|
1656
1656
|
const regex = dateRegex;
|
|
1657
|
-
if (!regex.test(
|
|
1658
|
-
ctx = this._getOrReturnCtx(
|
|
1657
|
+
if (!regex.test(input2.data)) {
|
|
1658
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1659
1659
|
addIssueToContext(ctx, {
|
|
1660
1660
|
code: ZodIssueCode.invalid_string,
|
|
1661
1661
|
validation: "date",
|
|
@@ -1665,8 +1665,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1665
1665
|
}
|
|
1666
1666
|
} else if (check.kind === "time") {
|
|
1667
1667
|
const regex = timeRegex(check);
|
|
1668
|
-
if (!regex.test(
|
|
1669
|
-
ctx = this._getOrReturnCtx(
|
|
1668
|
+
if (!regex.test(input2.data)) {
|
|
1669
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1670
1670
|
addIssueToContext(ctx, {
|
|
1671
1671
|
code: ZodIssueCode.invalid_string,
|
|
1672
1672
|
validation: "time",
|
|
@@ -1675,8 +1675,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1675
1675
|
status.dirty();
|
|
1676
1676
|
}
|
|
1677
1677
|
} else if (check.kind === "duration") {
|
|
1678
|
-
if (!durationRegex.test(
|
|
1679
|
-
ctx = this._getOrReturnCtx(
|
|
1678
|
+
if (!durationRegex.test(input2.data)) {
|
|
1679
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1680
1680
|
addIssueToContext(ctx, {
|
|
1681
1681
|
validation: "duration",
|
|
1682
1682
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1685,8 +1685,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1685
1685
|
status.dirty();
|
|
1686
1686
|
}
|
|
1687
1687
|
} else if (check.kind === "ip") {
|
|
1688
|
-
if (!isValidIP(
|
|
1689
|
-
ctx = this._getOrReturnCtx(
|
|
1688
|
+
if (!isValidIP(input2.data, check.version)) {
|
|
1689
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1690
1690
|
addIssueToContext(ctx, {
|
|
1691
1691
|
validation: "ip",
|
|
1692
1692
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1695,8 +1695,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1695
1695
|
status.dirty();
|
|
1696
1696
|
}
|
|
1697
1697
|
} else if (check.kind === "jwt") {
|
|
1698
|
-
if (!isValidJWT(
|
|
1699
|
-
ctx = this._getOrReturnCtx(
|
|
1698
|
+
if (!isValidJWT(input2.data, check.alg)) {
|
|
1699
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1700
1700
|
addIssueToContext(ctx, {
|
|
1701
1701
|
validation: "jwt",
|
|
1702
1702
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1705,8 +1705,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1705
1705
|
status.dirty();
|
|
1706
1706
|
}
|
|
1707
1707
|
} else if (check.kind === "cidr") {
|
|
1708
|
-
if (!isValidCidr(
|
|
1709
|
-
ctx = this._getOrReturnCtx(
|
|
1708
|
+
if (!isValidCidr(input2.data, check.version)) {
|
|
1709
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1710
1710
|
addIssueToContext(ctx, {
|
|
1711
1711
|
validation: "cidr",
|
|
1712
1712
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1715,8 +1715,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1715
1715
|
status.dirty();
|
|
1716
1716
|
}
|
|
1717
1717
|
} else if (check.kind === "base64") {
|
|
1718
|
-
if (!base64Regex.test(
|
|
1719
|
-
ctx = this._getOrReturnCtx(
|
|
1718
|
+
if (!base64Regex.test(input2.data)) {
|
|
1719
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1720
1720
|
addIssueToContext(ctx, {
|
|
1721
1721
|
validation: "base64",
|
|
1722
1722
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1725,8 +1725,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1725
1725
|
status.dirty();
|
|
1726
1726
|
}
|
|
1727
1727
|
} else if (check.kind === "base64url") {
|
|
1728
|
-
if (!base64urlRegex.test(
|
|
1729
|
-
ctx = this._getOrReturnCtx(
|
|
1728
|
+
if (!base64urlRegex.test(input2.data)) {
|
|
1729
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
1730
1730
|
addIssueToContext(ctx, {
|
|
1731
1731
|
validation: "base64url",
|
|
1732
1732
|
code: ZodIssueCode.invalid_string,
|
|
@@ -1738,7 +1738,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1738
1738
|
util.assertNever(check);
|
|
1739
1739
|
}
|
|
1740
1740
|
}
|
|
1741
|
-
return { status: status.value, value:
|
|
1741
|
+
return { status: status.value, value: input2.data };
|
|
1742
1742
|
}
|
|
1743
1743
|
_regex(regex, validation, message) {
|
|
1744
1744
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1999,13 +1999,13 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1999
1999
|
this.max = this.lte;
|
|
2000
2000
|
this.step = this.multipleOf;
|
|
2001
2001
|
}
|
|
2002
|
-
_parse(
|
|
2002
|
+
_parse(input2) {
|
|
2003
2003
|
if (this._def.coerce) {
|
|
2004
|
-
|
|
2004
|
+
input2.data = Number(input2.data);
|
|
2005
2005
|
}
|
|
2006
|
-
const parsedType = this._getType(
|
|
2006
|
+
const parsedType = this._getType(input2);
|
|
2007
2007
|
if (parsedType !== ZodParsedType.number) {
|
|
2008
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2008
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2009
2009
|
addIssueToContext(ctx2, {
|
|
2010
2010
|
code: ZodIssueCode.invalid_type,
|
|
2011
2011
|
expected: ZodParsedType.number,
|
|
@@ -2017,8 +2017,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2017
2017
|
const status = new ParseStatus();
|
|
2018
2018
|
for (const check of this._def.checks) {
|
|
2019
2019
|
if (check.kind === "int") {
|
|
2020
|
-
if (!util.isInteger(
|
|
2021
|
-
ctx = this._getOrReturnCtx(
|
|
2020
|
+
if (!util.isInteger(input2.data)) {
|
|
2021
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2022
2022
|
addIssueToContext(ctx, {
|
|
2023
2023
|
code: ZodIssueCode.invalid_type,
|
|
2024
2024
|
expected: "integer",
|
|
@@ -2028,9 +2028,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2028
2028
|
status.dirty();
|
|
2029
2029
|
}
|
|
2030
2030
|
} else if (check.kind === "min") {
|
|
2031
|
-
const tooSmall = check.inclusive ?
|
|
2031
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
2032
2032
|
if (tooSmall) {
|
|
2033
|
-
ctx = this._getOrReturnCtx(
|
|
2033
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2034
2034
|
addIssueToContext(ctx, {
|
|
2035
2035
|
code: ZodIssueCode.too_small,
|
|
2036
2036
|
minimum: check.value,
|
|
@@ -2042,9 +2042,9 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2042
2042
|
status.dirty();
|
|
2043
2043
|
}
|
|
2044
2044
|
} else if (check.kind === "max") {
|
|
2045
|
-
const tooBig = check.inclusive ?
|
|
2045
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
2046
2046
|
if (tooBig) {
|
|
2047
|
-
ctx = this._getOrReturnCtx(
|
|
2047
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2048
2048
|
addIssueToContext(ctx, {
|
|
2049
2049
|
code: ZodIssueCode.too_big,
|
|
2050
2050
|
maximum: check.value,
|
|
@@ -2056,8 +2056,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2056
2056
|
status.dirty();
|
|
2057
2057
|
}
|
|
2058
2058
|
} else if (check.kind === "multipleOf") {
|
|
2059
|
-
if (floatSafeRemainder(
|
|
2060
|
-
ctx = this._getOrReturnCtx(
|
|
2059
|
+
if (floatSafeRemainder(input2.data, check.value) !== 0) {
|
|
2060
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2061
2061
|
addIssueToContext(ctx, {
|
|
2062
2062
|
code: ZodIssueCode.not_multiple_of,
|
|
2063
2063
|
multipleOf: check.value,
|
|
@@ -2066,8 +2066,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2066
2066
|
status.dirty();
|
|
2067
2067
|
}
|
|
2068
2068
|
} else if (check.kind === "finite") {
|
|
2069
|
-
if (!Number.isFinite(
|
|
2070
|
-
ctx = this._getOrReturnCtx(
|
|
2069
|
+
if (!Number.isFinite(input2.data)) {
|
|
2070
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2071
2071
|
addIssueToContext(ctx, {
|
|
2072
2072
|
code: ZodIssueCode.not_finite,
|
|
2073
2073
|
message: check.message
|
|
@@ -2078,7 +2078,7 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
2078
2078
|
util.assertNever(check);
|
|
2079
2079
|
}
|
|
2080
2080
|
}
|
|
2081
|
-
return { status: status.value, value:
|
|
2081
|
+
return { status: status.value, value: input2.data };
|
|
2082
2082
|
}
|
|
2083
2083
|
gte(value, message) {
|
|
2084
2084
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -2230,25 +2230,25 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
2230
2230
|
this.min = this.gte;
|
|
2231
2231
|
this.max = this.lte;
|
|
2232
2232
|
}
|
|
2233
|
-
_parse(
|
|
2233
|
+
_parse(input2) {
|
|
2234
2234
|
if (this._def.coerce) {
|
|
2235
2235
|
try {
|
|
2236
|
-
|
|
2236
|
+
input2.data = BigInt(input2.data);
|
|
2237
2237
|
} catch {
|
|
2238
|
-
return this._getInvalidInput(
|
|
2238
|
+
return this._getInvalidInput(input2);
|
|
2239
2239
|
}
|
|
2240
2240
|
}
|
|
2241
|
-
const parsedType = this._getType(
|
|
2241
|
+
const parsedType = this._getType(input2);
|
|
2242
2242
|
if (parsedType !== ZodParsedType.bigint) {
|
|
2243
|
-
return this._getInvalidInput(
|
|
2243
|
+
return this._getInvalidInput(input2);
|
|
2244
2244
|
}
|
|
2245
2245
|
let ctx = void 0;
|
|
2246
2246
|
const status = new ParseStatus();
|
|
2247
2247
|
for (const check of this._def.checks) {
|
|
2248
2248
|
if (check.kind === "min") {
|
|
2249
|
-
const tooSmall = check.inclusive ?
|
|
2249
|
+
const tooSmall = check.inclusive ? input2.data < check.value : input2.data <= check.value;
|
|
2250
2250
|
if (tooSmall) {
|
|
2251
|
-
ctx = this._getOrReturnCtx(
|
|
2251
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2252
2252
|
addIssueToContext(ctx, {
|
|
2253
2253
|
code: ZodIssueCode.too_small,
|
|
2254
2254
|
type: "bigint",
|
|
@@ -2259,9 +2259,9 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
2259
2259
|
status.dirty();
|
|
2260
2260
|
}
|
|
2261
2261
|
} else if (check.kind === "max") {
|
|
2262
|
-
const tooBig = check.inclusive ?
|
|
2262
|
+
const tooBig = check.inclusive ? input2.data > check.value : input2.data >= check.value;
|
|
2263
2263
|
if (tooBig) {
|
|
2264
|
-
ctx = this._getOrReturnCtx(
|
|
2264
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2265
2265
|
addIssueToContext(ctx, {
|
|
2266
2266
|
code: ZodIssueCode.too_big,
|
|
2267
2267
|
type: "bigint",
|
|
@@ -2272,8 +2272,8 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
2272
2272
|
status.dirty();
|
|
2273
2273
|
}
|
|
2274
2274
|
} else if (check.kind === "multipleOf") {
|
|
2275
|
-
if (
|
|
2276
|
-
ctx = this._getOrReturnCtx(
|
|
2275
|
+
if (input2.data % check.value !== BigInt(0)) {
|
|
2276
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2277
2277
|
addIssueToContext(ctx, {
|
|
2278
2278
|
code: ZodIssueCode.not_multiple_of,
|
|
2279
2279
|
multipleOf: check.value,
|
|
@@ -2285,10 +2285,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
2285
2285
|
util.assertNever(check);
|
|
2286
2286
|
}
|
|
2287
2287
|
}
|
|
2288
|
-
return { status: status.value, value:
|
|
2288
|
+
return { status: status.value, value: input2.data };
|
|
2289
2289
|
}
|
|
2290
|
-
_getInvalidInput(
|
|
2291
|
-
const ctx = this._getOrReturnCtx(
|
|
2290
|
+
_getInvalidInput(input2) {
|
|
2291
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2292
2292
|
addIssueToContext(ctx, {
|
|
2293
2293
|
code: ZodIssueCode.invalid_type,
|
|
2294
2294
|
expected: ZodParsedType.bigint,
|
|
@@ -2397,13 +2397,13 @@ ZodBigInt.create = (params) => {
|
|
|
2397
2397
|
});
|
|
2398
2398
|
};
|
|
2399
2399
|
var ZodBoolean = class extends ZodType {
|
|
2400
|
-
_parse(
|
|
2400
|
+
_parse(input2) {
|
|
2401
2401
|
if (this._def.coerce) {
|
|
2402
|
-
|
|
2402
|
+
input2.data = Boolean(input2.data);
|
|
2403
2403
|
}
|
|
2404
|
-
const parsedType = this._getType(
|
|
2404
|
+
const parsedType = this._getType(input2);
|
|
2405
2405
|
if (parsedType !== ZodParsedType.boolean) {
|
|
2406
|
-
const ctx = this._getOrReturnCtx(
|
|
2406
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2407
2407
|
addIssueToContext(ctx, {
|
|
2408
2408
|
code: ZodIssueCode.invalid_type,
|
|
2409
2409
|
expected: ZodParsedType.boolean,
|
|
@@ -2411,7 +2411,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
2411
2411
|
});
|
|
2412
2412
|
return INVALID;
|
|
2413
2413
|
}
|
|
2414
|
-
return OK(
|
|
2414
|
+
return OK(input2.data);
|
|
2415
2415
|
}
|
|
2416
2416
|
};
|
|
2417
2417
|
ZodBoolean.create = (params) => {
|
|
@@ -2422,13 +2422,13 @@ ZodBoolean.create = (params) => {
|
|
|
2422
2422
|
});
|
|
2423
2423
|
};
|
|
2424
2424
|
var ZodDate = class _ZodDate extends ZodType {
|
|
2425
|
-
_parse(
|
|
2425
|
+
_parse(input2) {
|
|
2426
2426
|
if (this._def.coerce) {
|
|
2427
|
-
|
|
2427
|
+
input2.data = new Date(input2.data);
|
|
2428
2428
|
}
|
|
2429
|
-
const parsedType = this._getType(
|
|
2429
|
+
const parsedType = this._getType(input2);
|
|
2430
2430
|
if (parsedType !== ZodParsedType.date) {
|
|
2431
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2431
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2432
2432
|
addIssueToContext(ctx2, {
|
|
2433
2433
|
code: ZodIssueCode.invalid_type,
|
|
2434
2434
|
expected: ZodParsedType.date,
|
|
@@ -2436,8 +2436,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2436
2436
|
});
|
|
2437
2437
|
return INVALID;
|
|
2438
2438
|
}
|
|
2439
|
-
if (Number.isNaN(
|
|
2440
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2439
|
+
if (Number.isNaN(input2.data.getTime())) {
|
|
2440
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2441
2441
|
addIssueToContext(ctx2, {
|
|
2442
2442
|
code: ZodIssueCode.invalid_date
|
|
2443
2443
|
});
|
|
@@ -2447,8 +2447,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2447
2447
|
let ctx = void 0;
|
|
2448
2448
|
for (const check of this._def.checks) {
|
|
2449
2449
|
if (check.kind === "min") {
|
|
2450
|
-
if (
|
|
2451
|
-
ctx = this._getOrReturnCtx(
|
|
2450
|
+
if (input2.data.getTime() < check.value) {
|
|
2451
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2452
2452
|
addIssueToContext(ctx, {
|
|
2453
2453
|
code: ZodIssueCode.too_small,
|
|
2454
2454
|
message: check.message,
|
|
@@ -2460,8 +2460,8 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2460
2460
|
status.dirty();
|
|
2461
2461
|
}
|
|
2462
2462
|
} else if (check.kind === "max") {
|
|
2463
|
-
if (
|
|
2464
|
-
ctx = this._getOrReturnCtx(
|
|
2463
|
+
if (input2.data.getTime() > check.value) {
|
|
2464
|
+
ctx = this._getOrReturnCtx(input2, ctx);
|
|
2465
2465
|
addIssueToContext(ctx, {
|
|
2466
2466
|
code: ZodIssueCode.too_big,
|
|
2467
2467
|
message: check.message,
|
|
@@ -2478,7 +2478,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
2478
2478
|
}
|
|
2479
2479
|
return {
|
|
2480
2480
|
status: status.value,
|
|
2481
|
-
value: new Date(
|
|
2481
|
+
value: new Date(input2.data.getTime())
|
|
2482
2482
|
};
|
|
2483
2483
|
}
|
|
2484
2484
|
_addCheck(check) {
|
|
@@ -2531,10 +2531,10 @@ ZodDate.create = (params) => {
|
|
|
2531
2531
|
});
|
|
2532
2532
|
};
|
|
2533
2533
|
var ZodSymbol = class extends ZodType {
|
|
2534
|
-
_parse(
|
|
2535
|
-
const parsedType = this._getType(
|
|
2534
|
+
_parse(input2) {
|
|
2535
|
+
const parsedType = this._getType(input2);
|
|
2536
2536
|
if (parsedType !== ZodParsedType.symbol) {
|
|
2537
|
-
const ctx = this._getOrReturnCtx(
|
|
2537
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2538
2538
|
addIssueToContext(ctx, {
|
|
2539
2539
|
code: ZodIssueCode.invalid_type,
|
|
2540
2540
|
expected: ZodParsedType.symbol,
|
|
@@ -2542,7 +2542,7 @@ var ZodSymbol = class extends ZodType {
|
|
|
2542
2542
|
});
|
|
2543
2543
|
return INVALID;
|
|
2544
2544
|
}
|
|
2545
|
-
return OK(
|
|
2545
|
+
return OK(input2.data);
|
|
2546
2546
|
}
|
|
2547
2547
|
};
|
|
2548
2548
|
ZodSymbol.create = (params) => {
|
|
@@ -2552,10 +2552,10 @@ ZodSymbol.create = (params) => {
|
|
|
2552
2552
|
});
|
|
2553
2553
|
};
|
|
2554
2554
|
var ZodUndefined = class extends ZodType {
|
|
2555
|
-
_parse(
|
|
2556
|
-
const parsedType = this._getType(
|
|
2555
|
+
_parse(input2) {
|
|
2556
|
+
const parsedType = this._getType(input2);
|
|
2557
2557
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2558
|
-
const ctx = this._getOrReturnCtx(
|
|
2558
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2559
2559
|
addIssueToContext(ctx, {
|
|
2560
2560
|
code: ZodIssueCode.invalid_type,
|
|
2561
2561
|
expected: ZodParsedType.undefined,
|
|
@@ -2563,7 +2563,7 @@ var ZodUndefined = class extends ZodType {
|
|
|
2563
2563
|
});
|
|
2564
2564
|
return INVALID;
|
|
2565
2565
|
}
|
|
2566
|
-
return OK(
|
|
2566
|
+
return OK(input2.data);
|
|
2567
2567
|
}
|
|
2568
2568
|
};
|
|
2569
2569
|
ZodUndefined.create = (params) => {
|
|
@@ -2573,10 +2573,10 @@ ZodUndefined.create = (params) => {
|
|
|
2573
2573
|
});
|
|
2574
2574
|
};
|
|
2575
2575
|
var ZodNull = class extends ZodType {
|
|
2576
|
-
_parse(
|
|
2577
|
-
const parsedType = this._getType(
|
|
2576
|
+
_parse(input2) {
|
|
2577
|
+
const parsedType = this._getType(input2);
|
|
2578
2578
|
if (parsedType !== ZodParsedType.null) {
|
|
2579
|
-
const ctx = this._getOrReturnCtx(
|
|
2579
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2580
2580
|
addIssueToContext(ctx, {
|
|
2581
2581
|
code: ZodIssueCode.invalid_type,
|
|
2582
2582
|
expected: ZodParsedType.null,
|
|
@@ -2584,7 +2584,7 @@ var ZodNull = class extends ZodType {
|
|
|
2584
2584
|
});
|
|
2585
2585
|
return INVALID;
|
|
2586
2586
|
}
|
|
2587
|
-
return OK(
|
|
2587
|
+
return OK(input2.data);
|
|
2588
2588
|
}
|
|
2589
2589
|
};
|
|
2590
2590
|
ZodNull.create = (params) => {
|
|
@@ -2598,8 +2598,8 @@ var ZodAny = class extends ZodType {
|
|
|
2598
2598
|
super(...arguments);
|
|
2599
2599
|
this._any = true;
|
|
2600
2600
|
}
|
|
2601
|
-
_parse(
|
|
2602
|
-
return OK(
|
|
2601
|
+
_parse(input2) {
|
|
2602
|
+
return OK(input2.data);
|
|
2603
2603
|
}
|
|
2604
2604
|
};
|
|
2605
2605
|
ZodAny.create = (params) => {
|
|
@@ -2613,8 +2613,8 @@ var ZodUnknown = class extends ZodType {
|
|
|
2613
2613
|
super(...arguments);
|
|
2614
2614
|
this._unknown = true;
|
|
2615
2615
|
}
|
|
2616
|
-
_parse(
|
|
2617
|
-
return OK(
|
|
2616
|
+
_parse(input2) {
|
|
2617
|
+
return OK(input2.data);
|
|
2618
2618
|
}
|
|
2619
2619
|
};
|
|
2620
2620
|
ZodUnknown.create = (params) => {
|
|
@@ -2624,8 +2624,8 @@ ZodUnknown.create = (params) => {
|
|
|
2624
2624
|
});
|
|
2625
2625
|
};
|
|
2626
2626
|
var ZodNever = class extends ZodType {
|
|
2627
|
-
_parse(
|
|
2628
|
-
const ctx = this._getOrReturnCtx(
|
|
2627
|
+
_parse(input2) {
|
|
2628
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2629
2629
|
addIssueToContext(ctx, {
|
|
2630
2630
|
code: ZodIssueCode.invalid_type,
|
|
2631
2631
|
expected: ZodParsedType.never,
|
|
@@ -2641,10 +2641,10 @@ ZodNever.create = (params) => {
|
|
|
2641
2641
|
});
|
|
2642
2642
|
};
|
|
2643
2643
|
var ZodVoid = class extends ZodType {
|
|
2644
|
-
_parse(
|
|
2645
|
-
const parsedType = this._getType(
|
|
2644
|
+
_parse(input2) {
|
|
2645
|
+
const parsedType = this._getType(input2);
|
|
2646
2646
|
if (parsedType !== ZodParsedType.undefined) {
|
|
2647
|
-
const ctx = this._getOrReturnCtx(
|
|
2647
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
2648
2648
|
addIssueToContext(ctx, {
|
|
2649
2649
|
code: ZodIssueCode.invalid_type,
|
|
2650
2650
|
expected: ZodParsedType.void,
|
|
@@ -2652,7 +2652,7 @@ var ZodVoid = class extends ZodType {
|
|
|
2652
2652
|
});
|
|
2653
2653
|
return INVALID;
|
|
2654
2654
|
}
|
|
2655
|
-
return OK(
|
|
2655
|
+
return OK(input2.data);
|
|
2656
2656
|
}
|
|
2657
2657
|
};
|
|
2658
2658
|
ZodVoid.create = (params) => {
|
|
@@ -2662,8 +2662,8 @@ ZodVoid.create = (params) => {
|
|
|
2662
2662
|
});
|
|
2663
2663
|
};
|
|
2664
2664
|
var ZodArray = class _ZodArray extends ZodType {
|
|
2665
|
-
_parse(
|
|
2666
|
-
const { ctx, status } = this._processInputParams(
|
|
2665
|
+
_parse(input2) {
|
|
2666
|
+
const { ctx, status } = this._processInputParams(input2);
|
|
2667
2667
|
const def = this._def;
|
|
2668
2668
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
2669
2669
|
addIssueToContext(ctx, {
|
|
@@ -2803,10 +2803,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2803
2803
|
this._cached = { shape, keys };
|
|
2804
2804
|
return this._cached;
|
|
2805
2805
|
}
|
|
2806
|
-
_parse(
|
|
2807
|
-
const parsedType = this._getType(
|
|
2806
|
+
_parse(input2) {
|
|
2807
|
+
const parsedType = this._getType(input2);
|
|
2808
2808
|
if (parsedType !== ZodParsedType.object) {
|
|
2809
|
-
const ctx2 = this._getOrReturnCtx(
|
|
2809
|
+
const ctx2 = this._getOrReturnCtx(input2);
|
|
2810
2810
|
addIssueToContext(ctx2, {
|
|
2811
2811
|
code: ZodIssueCode.invalid_type,
|
|
2812
2812
|
expected: ZodParsedType.object,
|
|
@@ -2814,7 +2814,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2814
2814
|
});
|
|
2815
2815
|
return INVALID;
|
|
2816
2816
|
}
|
|
2817
|
-
const { status, ctx } = this._processInputParams(
|
|
2817
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
2818
2818
|
const { shape, keys: shapeKeys } = this._getCached();
|
|
2819
2819
|
const extraKeys = [];
|
|
2820
2820
|
if (!(this._def.catchall instanceof ZodNever && this._def.unknownKeys === "strip")) {
|
|
@@ -3127,8 +3127,8 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
3127
3127
|
});
|
|
3128
3128
|
};
|
|
3129
3129
|
var ZodUnion = class extends ZodType {
|
|
3130
|
-
_parse(
|
|
3131
|
-
const { ctx } = this._processInputParams(
|
|
3130
|
+
_parse(input2) {
|
|
3131
|
+
const { ctx } = this._processInputParams(input2);
|
|
3132
3132
|
const options = this._def.options;
|
|
3133
3133
|
function handleResults(results) {
|
|
3134
3134
|
for (const result of results) {
|
|
@@ -3249,8 +3249,8 @@ var getDiscriminator = (type) => {
|
|
|
3249
3249
|
}
|
|
3250
3250
|
};
|
|
3251
3251
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
3252
|
-
_parse(
|
|
3253
|
-
const { ctx } = this._processInputParams(
|
|
3252
|
+
_parse(input2) {
|
|
3253
|
+
const { ctx } = this._processInputParams(input2);
|
|
3254
3254
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3255
3255
|
addIssueToContext(ctx, {
|
|
3256
3256
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3363,8 +3363,8 @@ function mergeValues(a, b) {
|
|
|
3363
3363
|
}
|
|
3364
3364
|
}
|
|
3365
3365
|
var ZodIntersection = class extends ZodType {
|
|
3366
|
-
_parse(
|
|
3367
|
-
const { status, ctx } = this._processInputParams(
|
|
3366
|
+
_parse(input2) {
|
|
3367
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3368
3368
|
const handleParsed = (parsedLeft, parsedRight) => {
|
|
3369
3369
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
3370
3370
|
return INVALID;
|
|
@@ -3416,8 +3416,8 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
3416
3416
|
});
|
|
3417
3417
|
};
|
|
3418
3418
|
var ZodTuple = class _ZodTuple extends ZodType {
|
|
3419
|
-
_parse(
|
|
3420
|
-
const { status, ctx } = this._processInputParams(
|
|
3419
|
+
_parse(input2) {
|
|
3420
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3421
3421
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
3422
3422
|
addIssueToContext(ctx, {
|
|
3423
3423
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3489,8 +3489,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
3489
3489
|
get valueSchema() {
|
|
3490
3490
|
return this._def.valueType;
|
|
3491
3491
|
}
|
|
3492
|
-
_parse(
|
|
3493
|
-
const { status, ctx } = this._processInputParams(
|
|
3492
|
+
_parse(input2) {
|
|
3493
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3494
3494
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
3495
3495
|
addIssueToContext(ctx, {
|
|
3496
3496
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3542,8 +3542,8 @@ var ZodMap = class extends ZodType {
|
|
|
3542
3542
|
get valueSchema() {
|
|
3543
3543
|
return this._def.valueType;
|
|
3544
3544
|
}
|
|
3545
|
-
_parse(
|
|
3546
|
-
const { status, ctx } = this._processInputParams(
|
|
3545
|
+
_parse(input2) {
|
|
3546
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3547
3547
|
if (ctx.parsedType !== ZodParsedType.map) {
|
|
3548
3548
|
addIssueToContext(ctx, {
|
|
3549
3549
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3602,8 +3602,8 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
3602
3602
|
});
|
|
3603
3603
|
};
|
|
3604
3604
|
var ZodSet = class _ZodSet extends ZodType {
|
|
3605
|
-
_parse(
|
|
3606
|
-
const { status, ctx } = this._processInputParams(
|
|
3605
|
+
_parse(input2) {
|
|
3606
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3607
3607
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
3608
3608
|
addIssueToContext(ctx, {
|
|
3609
3609
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3691,8 +3691,8 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3691
3691
|
super(...arguments);
|
|
3692
3692
|
this.validate = this.implement;
|
|
3693
3693
|
}
|
|
3694
|
-
_parse(
|
|
3695
|
-
const { ctx } = this._processInputParams(
|
|
3694
|
+
_parse(input2) {
|
|
3695
|
+
const { ctx } = this._processInputParams(input2);
|
|
3696
3696
|
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3697
3697
|
addIssueToContext(ctx, {
|
|
3698
3698
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3795,8 +3795,8 @@ var ZodLazy = class extends ZodType {
|
|
|
3795
3795
|
get schema() {
|
|
3796
3796
|
return this._def.getter();
|
|
3797
3797
|
}
|
|
3798
|
-
_parse(
|
|
3799
|
-
const { ctx } = this._processInputParams(
|
|
3798
|
+
_parse(input2) {
|
|
3799
|
+
const { ctx } = this._processInputParams(input2);
|
|
3800
3800
|
const lazySchema = this._def.getter();
|
|
3801
3801
|
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
3802
3802
|
}
|
|
@@ -3809,9 +3809,9 @@ ZodLazy.create = (getter, params) => {
|
|
|
3809
3809
|
});
|
|
3810
3810
|
};
|
|
3811
3811
|
var ZodLiteral = class extends ZodType {
|
|
3812
|
-
_parse(
|
|
3813
|
-
if (
|
|
3814
|
-
const ctx = this._getOrReturnCtx(
|
|
3812
|
+
_parse(input2) {
|
|
3813
|
+
if (input2.data !== this._def.value) {
|
|
3814
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3815
3815
|
addIssueToContext(ctx, {
|
|
3816
3816
|
received: ctx.data,
|
|
3817
3817
|
code: ZodIssueCode.invalid_literal,
|
|
@@ -3819,7 +3819,7 @@ var ZodLiteral = class extends ZodType {
|
|
|
3819
3819
|
});
|
|
3820
3820
|
return INVALID;
|
|
3821
3821
|
}
|
|
3822
|
-
return { status: "valid", value:
|
|
3822
|
+
return { status: "valid", value: input2.data };
|
|
3823
3823
|
}
|
|
3824
3824
|
get value() {
|
|
3825
3825
|
return this._def.value;
|
|
@@ -3840,9 +3840,9 @@ function createZodEnum(values, params) {
|
|
|
3840
3840
|
});
|
|
3841
3841
|
}
|
|
3842
3842
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3843
|
-
_parse(
|
|
3844
|
-
if (typeof
|
|
3845
|
-
const ctx = this._getOrReturnCtx(
|
|
3843
|
+
_parse(input2) {
|
|
3844
|
+
if (typeof input2.data !== "string") {
|
|
3845
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3846
3846
|
const expectedValues = this._def.values;
|
|
3847
3847
|
addIssueToContext(ctx, {
|
|
3848
3848
|
expected: util.joinValues(expectedValues),
|
|
@@ -3854,8 +3854,8 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3854
3854
|
if (!this._cache) {
|
|
3855
3855
|
this._cache = new Set(this._def.values);
|
|
3856
3856
|
}
|
|
3857
|
-
if (!this._cache.has(
|
|
3858
|
-
const ctx = this._getOrReturnCtx(
|
|
3857
|
+
if (!this._cache.has(input2.data)) {
|
|
3858
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3859
3859
|
const expectedValues = this._def.values;
|
|
3860
3860
|
addIssueToContext(ctx, {
|
|
3861
3861
|
received: ctx.data,
|
|
@@ -3864,7 +3864,7 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3864
3864
|
});
|
|
3865
3865
|
return INVALID;
|
|
3866
3866
|
}
|
|
3867
|
-
return OK(
|
|
3867
|
+
return OK(input2.data);
|
|
3868
3868
|
}
|
|
3869
3869
|
get options() {
|
|
3870
3870
|
return this._def.values;
|
|
@@ -3905,9 +3905,9 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3905
3905
|
};
|
|
3906
3906
|
ZodEnum.create = createZodEnum;
|
|
3907
3907
|
var ZodNativeEnum = class extends ZodType {
|
|
3908
|
-
_parse(
|
|
3908
|
+
_parse(input2) {
|
|
3909
3909
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3910
|
-
const ctx = this._getOrReturnCtx(
|
|
3910
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
3911
3911
|
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
|
3912
3912
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3913
3913
|
addIssueToContext(ctx, {
|
|
@@ -3920,7 +3920,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3920
3920
|
if (!this._cache) {
|
|
3921
3921
|
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3922
3922
|
}
|
|
3923
|
-
if (!this._cache.has(
|
|
3923
|
+
if (!this._cache.has(input2.data)) {
|
|
3924
3924
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3925
3925
|
addIssueToContext(ctx, {
|
|
3926
3926
|
received: ctx.data,
|
|
@@ -3929,7 +3929,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3929
3929
|
});
|
|
3930
3930
|
return INVALID;
|
|
3931
3931
|
}
|
|
3932
|
-
return OK(
|
|
3932
|
+
return OK(input2.data);
|
|
3933
3933
|
}
|
|
3934
3934
|
get enum() {
|
|
3935
3935
|
return this._def.values;
|
|
@@ -3946,8 +3946,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3946
3946
|
unwrap() {
|
|
3947
3947
|
return this._def.type;
|
|
3948
3948
|
}
|
|
3949
|
-
_parse(
|
|
3950
|
-
const { ctx } = this._processInputParams(
|
|
3949
|
+
_parse(input2) {
|
|
3950
|
+
const { ctx } = this._processInputParams(input2);
|
|
3951
3951
|
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
|
3952
3952
|
addIssueToContext(ctx, {
|
|
3953
3953
|
code: ZodIssueCode.invalid_type,
|
|
@@ -3979,8 +3979,8 @@ var ZodEffects = class extends ZodType {
|
|
|
3979
3979
|
sourceType() {
|
|
3980
3980
|
return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3981
3981
|
}
|
|
3982
|
-
_parse(
|
|
3983
|
-
const { status, ctx } = this._processInputParams(
|
|
3982
|
+
_parse(input2) {
|
|
3983
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
3984
3984
|
const effect = this._def.effect || null;
|
|
3985
3985
|
const checkCtx = {
|
|
3986
3986
|
addIssue: (arg) => {
|
|
@@ -4112,12 +4112,12 @@ ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
|
4112
4112
|
});
|
|
4113
4113
|
};
|
|
4114
4114
|
var ZodOptional = class extends ZodType {
|
|
4115
|
-
_parse(
|
|
4116
|
-
const parsedType = this._getType(
|
|
4115
|
+
_parse(input2) {
|
|
4116
|
+
const parsedType = this._getType(input2);
|
|
4117
4117
|
if (parsedType === ZodParsedType.undefined) {
|
|
4118
4118
|
return OK(void 0);
|
|
4119
4119
|
}
|
|
4120
|
-
return this._def.innerType._parse(
|
|
4120
|
+
return this._def.innerType._parse(input2);
|
|
4121
4121
|
}
|
|
4122
4122
|
unwrap() {
|
|
4123
4123
|
return this._def.innerType;
|
|
@@ -4131,12 +4131,12 @@ ZodOptional.create = (type, params) => {
|
|
|
4131
4131
|
});
|
|
4132
4132
|
};
|
|
4133
4133
|
var ZodNullable = class extends ZodType {
|
|
4134
|
-
_parse(
|
|
4135
|
-
const parsedType = this._getType(
|
|
4134
|
+
_parse(input2) {
|
|
4135
|
+
const parsedType = this._getType(input2);
|
|
4136
4136
|
if (parsedType === ZodParsedType.null) {
|
|
4137
4137
|
return OK(null);
|
|
4138
4138
|
}
|
|
4139
|
-
return this._def.innerType._parse(
|
|
4139
|
+
return this._def.innerType._parse(input2);
|
|
4140
4140
|
}
|
|
4141
4141
|
unwrap() {
|
|
4142
4142
|
return this._def.innerType;
|
|
@@ -4150,8 +4150,8 @@ ZodNullable.create = (type, params) => {
|
|
|
4150
4150
|
});
|
|
4151
4151
|
};
|
|
4152
4152
|
var ZodDefault = class extends ZodType {
|
|
4153
|
-
_parse(
|
|
4154
|
-
const { ctx } = this._processInputParams(
|
|
4153
|
+
_parse(input2) {
|
|
4154
|
+
const { ctx } = this._processInputParams(input2);
|
|
4155
4155
|
let data = ctx.data;
|
|
4156
4156
|
if (ctx.parsedType === ZodParsedType.undefined) {
|
|
4157
4157
|
data = this._def.defaultValue();
|
|
@@ -4175,8 +4175,8 @@ ZodDefault.create = (type, params) => {
|
|
|
4175
4175
|
});
|
|
4176
4176
|
};
|
|
4177
4177
|
var ZodCatch = class extends ZodType {
|
|
4178
|
-
_parse(
|
|
4179
|
-
const { ctx } = this._processInputParams(
|
|
4178
|
+
_parse(input2) {
|
|
4179
|
+
const { ctx } = this._processInputParams(input2);
|
|
4180
4180
|
const newCtx = {
|
|
4181
4181
|
...ctx,
|
|
4182
4182
|
common: {
|
|
@@ -4228,10 +4228,10 @@ ZodCatch.create = (type, params) => {
|
|
|
4228
4228
|
});
|
|
4229
4229
|
};
|
|
4230
4230
|
var ZodNaN = class extends ZodType {
|
|
4231
|
-
_parse(
|
|
4232
|
-
const parsedType = this._getType(
|
|
4231
|
+
_parse(input2) {
|
|
4232
|
+
const parsedType = this._getType(input2);
|
|
4233
4233
|
if (parsedType !== ZodParsedType.nan) {
|
|
4234
|
-
const ctx = this._getOrReturnCtx(
|
|
4234
|
+
const ctx = this._getOrReturnCtx(input2);
|
|
4235
4235
|
addIssueToContext(ctx, {
|
|
4236
4236
|
code: ZodIssueCode.invalid_type,
|
|
4237
4237
|
expected: ZodParsedType.nan,
|
|
@@ -4239,7 +4239,7 @@ var ZodNaN = class extends ZodType {
|
|
|
4239
4239
|
});
|
|
4240
4240
|
return INVALID;
|
|
4241
4241
|
}
|
|
4242
|
-
return { status: "valid", value:
|
|
4242
|
+
return { status: "valid", value: input2.data };
|
|
4243
4243
|
}
|
|
4244
4244
|
};
|
|
4245
4245
|
ZodNaN.create = (params) => {
|
|
@@ -4250,8 +4250,8 @@ ZodNaN.create = (params) => {
|
|
|
4250
4250
|
};
|
|
4251
4251
|
var BRAND = /* @__PURE__ */ Symbol("zod_brand");
|
|
4252
4252
|
var ZodBranded = class extends ZodType {
|
|
4253
|
-
_parse(
|
|
4254
|
-
const { ctx } = this._processInputParams(
|
|
4253
|
+
_parse(input2) {
|
|
4254
|
+
const { ctx } = this._processInputParams(input2);
|
|
4255
4255
|
const data = ctx.data;
|
|
4256
4256
|
return this._def.type._parse({
|
|
4257
4257
|
data,
|
|
@@ -4264,8 +4264,8 @@ var ZodBranded = class extends ZodType {
|
|
|
4264
4264
|
}
|
|
4265
4265
|
};
|
|
4266
4266
|
var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
4267
|
-
_parse(
|
|
4268
|
-
const { status, ctx } = this._processInputParams(
|
|
4267
|
+
_parse(input2) {
|
|
4268
|
+
const { status, ctx } = this._processInputParams(input2);
|
|
4269
4269
|
if (ctx.common.async) {
|
|
4270
4270
|
const handleAsync = async () => {
|
|
4271
4271
|
const inResult = await this._def.in._parseAsync({
|
|
@@ -4319,8 +4319,8 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
4319
4319
|
}
|
|
4320
4320
|
};
|
|
4321
4321
|
var ZodReadonly = class extends ZodType {
|
|
4322
|
-
_parse(
|
|
4323
|
-
const result = this._def.innerType._parse(
|
|
4322
|
+
_parse(input2) {
|
|
4323
|
+
const result = this._def.innerType._parse(input2);
|
|
4324
4324
|
const freeze = (data) => {
|
|
4325
4325
|
if (isValid(data)) {
|
|
4326
4326
|
data.value = Object.freeze(data.value);
|
|
@@ -5944,8 +5944,145 @@ var serveCommand = new Command9("serve").description("Open the local UseAI dashb
|
|
|
5944
5944
|
process.on("SIGTERM", shutdown);
|
|
5945
5945
|
});
|
|
5946
5946
|
|
|
5947
|
+
// src/commands/login.ts
|
|
5948
|
+
import { Command as Command10 } from "commander";
|
|
5949
|
+
import chalk9 from "chalk";
|
|
5950
|
+
import { input } from "@inquirer/prompts";
|
|
5951
|
+
var API_URL = "https://api.useai.dev";
|
|
5952
|
+
async function apiCall(endpoint, body) {
|
|
5953
|
+
const res = await fetch(`${API_URL}${endpoint}`, {
|
|
5954
|
+
method: "POST",
|
|
5955
|
+
headers: { "Content-Type": "application/json" },
|
|
5956
|
+
body: JSON.stringify(body)
|
|
5957
|
+
});
|
|
5958
|
+
const data = await res.json();
|
|
5959
|
+
if (!res.ok) {
|
|
5960
|
+
throw new Error(data.message ?? `Request failed (${res.status})`);
|
|
5961
|
+
}
|
|
5962
|
+
return data;
|
|
5963
|
+
}
|
|
5964
|
+
var loginCommand = new Command10("login").description("Login to useai.dev").action(async () => {
|
|
5965
|
+
try {
|
|
5966
|
+
const config = getConfig();
|
|
5967
|
+
if (config.auth?.token) {
|
|
5968
|
+
console.log(chalk9.dim(` Already logged in as ${chalk9.bold(config.auth.user.email)}`));
|
|
5969
|
+
console.log(chalk9.dim(" Run `useai logout` to switch accounts."));
|
|
5970
|
+
return;
|
|
5971
|
+
}
|
|
5972
|
+
const email = await input({
|
|
5973
|
+
message: "Email:",
|
|
5974
|
+
validate: (v) => v.includes("@") || "Please enter a valid email"
|
|
5975
|
+
});
|
|
5976
|
+
console.log(chalk9.dim(" Sending verification code..."));
|
|
5977
|
+
try {
|
|
5978
|
+
await apiCall("/api/auth/send-otp", { email });
|
|
5979
|
+
} catch (err) {
|
|
5980
|
+
if (err.message.includes("rate") || err.message.includes("Too many")) {
|
|
5981
|
+
console.log(chalk9.red(" Too many requests. Please wait a minute and try again."));
|
|
5982
|
+
return;
|
|
5983
|
+
}
|
|
5984
|
+
throw err;
|
|
5985
|
+
}
|
|
5986
|
+
console.log(chalk9.green(" \u2713 Code sent to your email"));
|
|
5987
|
+
console.log("");
|
|
5988
|
+
let attempts = 0;
|
|
5989
|
+
const maxAttempts = 3;
|
|
5990
|
+
let success2 = false;
|
|
5991
|
+
while (attempts < maxAttempts && !success2) {
|
|
5992
|
+
const code = await input({
|
|
5993
|
+
message: 'Enter 6-digit code (or "resend"):',
|
|
5994
|
+
validate: (v) => {
|
|
5995
|
+
if (v.toLowerCase() === "resend") return true;
|
|
5996
|
+
return /^\d{6}$/.test(v) || 'Code must be 6 digits (or type "resend")';
|
|
5997
|
+
}
|
|
5998
|
+
});
|
|
5999
|
+
if (code.toLowerCase() === "resend") {
|
|
6000
|
+
console.log(chalk9.dim(" Resending code..."));
|
|
6001
|
+
try {
|
|
6002
|
+
await apiCall("/api/auth/send-otp", { email });
|
|
6003
|
+
console.log(chalk9.green(" \u2713 New code sent"));
|
|
6004
|
+
console.log("");
|
|
6005
|
+
continue;
|
|
6006
|
+
} catch (err) {
|
|
6007
|
+
if (err.message.includes("rate") || err.message.includes("Too many")) {
|
|
6008
|
+
console.log(chalk9.yellow(" Please wait before requesting a new code."));
|
|
6009
|
+
continue;
|
|
6010
|
+
}
|
|
6011
|
+
throw err;
|
|
6012
|
+
}
|
|
6013
|
+
}
|
|
6014
|
+
try {
|
|
6015
|
+
const result = await apiCall("/api/auth/verify-otp", { email, code });
|
|
6016
|
+
if (result?.token) {
|
|
6017
|
+
updateConfig({
|
|
6018
|
+
auth: {
|
|
6019
|
+
token: result.token,
|
|
6020
|
+
user: {
|
|
6021
|
+
id: result.user.id,
|
|
6022
|
+
email: result.user.email,
|
|
6023
|
+
username: result.user.username
|
|
6024
|
+
}
|
|
6025
|
+
}
|
|
6026
|
+
});
|
|
6027
|
+
console.log("");
|
|
6028
|
+
console.log(chalk9.green(` \u2713 Logged in as ${chalk9.bold(result.user.email)}`));
|
|
6029
|
+
if (result.user.username) {
|
|
6030
|
+
console.log(chalk9.dim(` username: ${result.user.username}`));
|
|
6031
|
+
}
|
|
6032
|
+
console.log("");
|
|
6033
|
+
console.log(chalk9.dim(" Your sessions and milestones will sync to useai.dev"));
|
|
6034
|
+
success2 = true;
|
|
6035
|
+
}
|
|
6036
|
+
} catch (err) {
|
|
6037
|
+
attempts++;
|
|
6038
|
+
if (err.message.includes("expired") || err.message.includes("No valid OTP")) {
|
|
6039
|
+
console.log(chalk9.red(" Code expired. Sending a new one..."));
|
|
6040
|
+
await apiCall("/api/auth/send-otp", { email });
|
|
6041
|
+
console.log(chalk9.green(" \u2713 New code sent"));
|
|
6042
|
+
attempts = 0;
|
|
6043
|
+
continue;
|
|
6044
|
+
}
|
|
6045
|
+
if (err.message.includes("Too many attempts")) {
|
|
6046
|
+
console.log(chalk9.red(" Too many attempts. Sending a new code..."));
|
|
6047
|
+
await apiCall("/api/auth/send-otp", { email });
|
|
6048
|
+
console.log(chalk9.green(" \u2713 New code sent"));
|
|
6049
|
+
attempts = 0;
|
|
6050
|
+
continue;
|
|
6051
|
+
}
|
|
6052
|
+
const remaining = maxAttempts - attempts;
|
|
6053
|
+
if (remaining > 0) {
|
|
6054
|
+
console.log(chalk9.red(` Invalid code. ${remaining} attempt(s) remaining.`));
|
|
6055
|
+
} else {
|
|
6056
|
+
console.log(chalk9.red(" Too many invalid attempts. Please try again later."));
|
|
6057
|
+
return;
|
|
6058
|
+
}
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
if (!success2) {
|
|
6062
|
+
console.log(chalk9.red(" Login failed. Please try again."));
|
|
6063
|
+
}
|
|
6064
|
+
} catch (err) {
|
|
6065
|
+
if (err.name === "ExitPromptError" || err.message?.includes("force closed")) {
|
|
6066
|
+
console.log("");
|
|
6067
|
+
console.log(chalk9.dim(" Cancelled."));
|
|
6068
|
+
return;
|
|
6069
|
+
}
|
|
6070
|
+
console.log(chalk9.red(` Login failed: ${err.message}`));
|
|
6071
|
+
}
|
|
6072
|
+
});
|
|
6073
|
+
var logoutCommand = new Command10("logout").description("Logout from useai.dev").action(() => {
|
|
6074
|
+
const config = getConfig();
|
|
6075
|
+
if (!config.auth) {
|
|
6076
|
+
console.log(chalk9.dim(" Not logged in."));
|
|
6077
|
+
return;
|
|
6078
|
+
}
|
|
6079
|
+
const email = config.auth.user.email;
|
|
6080
|
+
updateConfig({ auth: void 0 });
|
|
6081
|
+
console.log(chalk9.green(` \u2713 Logged out from ${email}`));
|
|
6082
|
+
});
|
|
6083
|
+
|
|
5947
6084
|
// src/index.ts
|
|
5948
|
-
var program = new
|
|
6085
|
+
var program = new Command11();
|
|
5949
6086
|
program.name("useai").description("useai.dev \u2014 Track your AI-assisted development workflow").version(VERSION);
|
|
5950
6087
|
program.addCommand(statsCommand);
|
|
5951
6088
|
program.addCommand(statusCommand);
|
|
@@ -5956,4 +6093,6 @@ program.addCommand(purgeCommand);
|
|
|
5956
6093
|
program.addCommand(mcpCommand);
|
|
5957
6094
|
program.addCommand(daemonCommand);
|
|
5958
6095
|
program.addCommand(serveCommand);
|
|
6096
|
+
program.addCommand(loginCommand);
|
|
6097
|
+
program.addCommand(logoutCommand);
|
|
5959
6098
|
program.parse();
|