@xyo-network/xl1-cli-lib 1.10.2 → 1.12.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/node/index.mjs +19 -52
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/optionsFromGlobalZodRegistry.d.ts +3 -0
- package/dist/node/optionsFromGlobalZodRegistry.d.ts.map +1 -0
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts +5 -1
- package/dist/node/orchestration/actor/implementation/ProducerActor.d.ts.map +1 -1
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts +5 -1
- package/dist/node/orchestration/actor/implementation/ValidatorActor.d.ts.map +1 -1
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts +5 -2
- package/dist/node/orchestration/repository/lib/repositoryFromArchivist.d.ts.map +1 -1
- package/dist/node/runCLI.d.ts.map +1 -1
- package/dist/node/xl1.mjs +19 -52
- package/dist/node/xl1.mjs.map +1 -1
- package/package.json +33 -33
- package/src/optionsFromGlobalZodRegistry.ts +19 -0
- package/src/runCLI.ts +6 -8
- package/src/spec/BootstrapChain.spec.ts +3 -3
- package/dist/node/optionsFromZodSchema.d.ts +0 -4
- package/dist/node/optionsFromZodSchema.d.ts.map +0 -1
- package/src/optionsFromZodSchema.ts +0 -69
package/dist/node/index.mjs
CHANGED
|
@@ -1436,7 +1436,7 @@ var initServices = async (context) => {
|
|
|
1436
1436
|
// src/runCLI.ts
|
|
1437
1437
|
import { deepMerge } from "@xylabs/object";
|
|
1438
1438
|
import { isDefined as isDefined13 } from "@xylabs/typeof";
|
|
1439
|
-
import {
|
|
1439
|
+
import { ConfigZod } from "@xyo-network/xl1-protocol-sdk";
|
|
1440
1440
|
import yargs from "yargs";
|
|
1441
1441
|
import { hideBin } from "yargs/helpers";
|
|
1442
1442
|
import { ZodError } from "zod";
|
|
@@ -1512,50 +1512,19 @@ var initLogger = (config3) => {
|
|
|
1512
1512
|
return logger;
|
|
1513
1513
|
};
|
|
1514
1514
|
|
|
1515
|
-
// src/
|
|
1516
|
-
import {
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
ZodOptional
|
|
1523
|
-
} from "zod";
|
|
1524
|
-
var collectOptions = (zodType, path = [], out = {}) => {
|
|
1525
|
-
if (zodType instanceof ZodObject) {
|
|
1526
|
-
const shape = zodType.shape;
|
|
1527
|
-
for (const [k, v] of Object.entries(shape)) {
|
|
1528
|
-
collectOptions(v, [...path, k], out);
|
|
1529
|
-
}
|
|
1530
|
-
return out;
|
|
1531
|
-
}
|
|
1532
|
-
const def = zodType._def;
|
|
1533
|
-
if (def?.innerType instanceof ZodObject) {
|
|
1534
|
-
const shape = def.innerType.shape;
|
|
1535
|
-
for (const [k, v] of Object.entries(shape)) {
|
|
1536
|
-
collectOptions(v, [...path, k], out);
|
|
1537
|
-
}
|
|
1538
|
-
return out;
|
|
1539
|
-
}
|
|
1540
|
-
const options = {};
|
|
1541
|
-
options.describe = def.description;
|
|
1542
|
-
options.default = typeof def.defaultValue === "function" ? def.defaultValue() : def.defaultValue;
|
|
1543
|
-
let type = "string";
|
|
1544
|
-
const typeName = def.typeName === ZodDefault.name || def.typeName === ZodOptional.name ? def.innerType._def.typeName : def.typeName;
|
|
1545
|
-
if (typeName === ZodBoolean.name) type = "boolean";
|
|
1546
|
-
if (typeName === ZodNumber.name || def.coerce) type = "number";
|
|
1547
|
-
if (typeName === ZodEnum.name) {
|
|
1548
|
-
options.choices = Object.values(def.innerType.enum);
|
|
1549
|
-
}
|
|
1550
|
-
options.type = type;
|
|
1551
|
-
const key = path.join(".");
|
|
1552
|
-
out[key] = options;
|
|
1553
|
-
return out;
|
|
1554
|
-
};
|
|
1555
|
-
var optionsFromZodSchema = (schema) => {
|
|
1515
|
+
// src/optionsFromGlobalZodRegistry.ts
|
|
1516
|
+
import { isUsageMeta } from "@xyo-network/xl1-protocol-sdk";
|
|
1517
|
+
import { globalRegistry } from "zod";
|
|
1518
|
+
var usageMetaToOptions = (meta) => {
|
|
1519
|
+
return meta;
|
|
1520
|
+
};
|
|
1521
|
+
var optionsFromGlobalZodRegistry = () => {
|
|
1556
1522
|
const opts = {};
|
|
1557
|
-
for (const
|
|
1558
|
-
|
|
1523
|
+
for (const schema of globalRegistry._map.values()) {
|
|
1524
|
+
if (isUsageMeta(schema)) {
|
|
1525
|
+
if (schema.hidden) continue;
|
|
1526
|
+
opts[schema.title] = usageMetaToOptions(schema);
|
|
1527
|
+
}
|
|
1559
1528
|
}
|
|
1560
1529
|
return opts;
|
|
1561
1530
|
};
|
|
@@ -1613,7 +1582,7 @@ var waitForHostPort = (host, port) => {
|
|
|
1613
1582
|
|
|
1614
1583
|
// src/runCLI.ts
|
|
1615
1584
|
var config;
|
|
1616
|
-
var version = isDefined13("1.
|
|
1585
|
+
var version = isDefined13("1.11.0") ? "1.11.0" : "unknown";
|
|
1617
1586
|
var getContextFromConfig = (config3) => {
|
|
1618
1587
|
const logger = initLogger(config3);
|
|
1619
1588
|
const orchestrator = new Orchestrator(logger);
|
|
@@ -1645,21 +1614,19 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
1645
1614
|
// foo.bar → { foo: { bar } }
|
|
1646
1615
|
"populate--": true
|
|
1647
1616
|
// Populate -- with all options so we can detected user-supplied vs defaults
|
|
1648
|
-
}).env("XL1").scriptName("xl1").
|
|
1617
|
+
}).env("XL1").scriptName("xl1").middleware((argv2) => {
|
|
1649
1618
|
try {
|
|
1650
1619
|
const parsedConfigFile = tryParseConfig();
|
|
1651
1620
|
const parsedConfigArgs = argv2;
|
|
1652
1621
|
const mergedConfig = deepMerge(parsedConfigArgs, parsedConfigFile);
|
|
1653
|
-
config =
|
|
1622
|
+
config = ConfigZod.parse(mergedConfig);
|
|
1654
1623
|
} catch (err) {
|
|
1655
1624
|
if (err instanceof ZodError) {
|
|
1656
|
-
|
|
1657
|
-
console.error(`${issue.path.join(".")} \u2192 ${issue.message}`);
|
|
1658
|
-
}
|
|
1625
|
+
console.error(`${err.message}`);
|
|
1659
1626
|
}
|
|
1660
1627
|
throw new Error("Invalid configuration");
|
|
1661
1628
|
}
|
|
1662
|
-
}).options(
|
|
1629
|
+
}).options(optionsFromGlobalZodRegistry()).wrap(y.terminalWidth()).command("api", "Run a XL1 API Node", (yargs2) => {
|
|
1663
1630
|
return yargs2.command("$0", "Run a XL1 API Node", () => {
|
|
1664
1631
|
}, () => {
|
|
1665
1632
|
const context = getContextFromConfig(config);
|
|
@@ -1677,7 +1644,7 @@ $0 <command> [options]`).parserConfiguration({
|
|
|
1677
1644
|
runApi({ ...context, config });
|
|
1678
1645
|
await waitForHostPort("localhost", config.api.port);
|
|
1679
1646
|
await runProducer({ ...context, config });
|
|
1680
|
-
}).help().alias("help", "h").argv;
|
|
1647
|
+
}).help().alias("help", "h").version(version).argv;
|
|
1681
1648
|
await argv;
|
|
1682
1649
|
}
|
|
1683
1650
|
|