@zeroxyz/cli 1.3.0 → 1.4.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.
Files changed (2) hide show
  1. package/dist/index.js +43 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76582,7 +76582,7 @@ init_esm_shims();
76582
76582
 
76583
76583
  // package.json
76584
76584
  var package_default = {
76585
- version: "1.3.0"};
76585
+ version: "1.4.0"};
76586
76586
 
76587
76587
  // src/app.ts
76588
76588
  init_esm_shims();
@@ -147074,22 +147074,50 @@ var constraintHint = (node) => {
147074
147074
  if (minLen !== void 0) return `minLength: ${minLen}`;
147075
147075
  return null;
147076
147076
  };
147077
- var renderParam = (name, propSchema, required3) => {
147078
- const node = asNode(propSchema) ?? {};
147077
+ var MAX_SCHEMA_DEPTH = 5;
147078
+ var paramAttrs = (node, required3) => {
147079
147079
  const attrs = [schemaTypeLabel(node)];
147080
147080
  if (required3) attrs.push("required");
147081
+ if (node.const !== void 0)
147082
+ attrs.push(`const: ${JSON.stringify(node.const)}`);
147081
147083
  if (node.default !== void 0)
147082
147084
  attrs.push(`default: ${JSON.stringify(node.default)}`);
147083
147085
  if (Array.isArray(node.enum))
147084
147086
  attrs.push(`one of: ${node.enum.map((v) => String(v)).join(" | ")}`);
147087
+ if (typeof node.format === "string") attrs.push(`format: ${node.format}`);
147085
147088
  const hint = constraintHint(node);
147086
147089
  if (hint) attrs.push(hint);
147087
- const lines = [` ${name} (${attrs.join(", ")})`];
147090
+ return attrs.join(", ");
147091
+ };
147092
+ var renderParam = (name, propSchema, required3, depth = 0) => {
147093
+ const node = asNode(propSchema) ?? {};
147094
+ const pad9 = ` ${" ".repeat(depth)}`;
147095
+ const lines = [`${pad9}${name} (${paramAttrs(node, required3)})`];
147088
147096
  const desc = typeof node.description === "string" ? node.description.trim() : "";
147089
- if (desc) lines.push(` ${desc}`);
147097
+ if (desc) lines.push(`${pad9} ${desc}`);
147098
+ if (depth >= MAX_SCHEMA_DEPTH) return lines;
147099
+ if (asNode(node.properties)) {
147100
+ lines.push(...renderProps(node, depth + 1));
147101
+ }
147102
+ const items = asNode(node.items);
147103
+ if (items) {
147104
+ if (asNode(items.properties)) {
147105
+ lines.push(`${pad9} each item (${schemaTypeLabel(items)}):`);
147106
+ lines.push(...renderProps(items, depth + 2));
147107
+ } else {
147108
+ lines.push(`${pad9} each item (${paramAttrs(items, false)})`);
147109
+ }
147110
+ }
147111
+ const variants = Array.isArray(node.oneOf) ? node.oneOf : Array.isArray(node.anyOf) ? node.anyOf : null;
147112
+ if (variants && variants.length > 0) {
147113
+ lines.push(`${pad9} one of these shapes:`);
147114
+ variants.forEach((v, i) => {
147115
+ lines.push(...renderParam(`option ${i + 1}`, v, false, depth + 2));
147116
+ });
147117
+ }
147090
147118
  return lines;
147091
147119
  };
147092
- var renderProps = (node) => {
147120
+ var renderProps = (node, depth = 0) => {
147093
147121
  const props = node ? asNode(node.properties) : null;
147094
147122
  if (!props) return [];
147095
147123
  const entries = Object.entries(props);
@@ -147098,7 +147126,7 @@ var renderProps = (node) => {
147098
147126
  Array.isArray(node?.required) ? node.required.filter((x2) => typeof x2 === "string") : []
147099
147127
  );
147100
147128
  return entries.flatMap(
147101
- ([name, schema]) => renderParam(name, schema, requiredSet.has(name))
147129
+ ([name, schema]) => renderParam(name, schema, requiredSet.has(name), depth)
147102
147130
  );
147103
147131
  };
147104
147132
  var buildSchemaSection = (capability) => {
@@ -147126,6 +147154,13 @@ var buildResponseSection = (capability) => {
147126
147154
  }
147127
147155
  return [];
147128
147156
  };
147157
+ var buildVerifiedExampleSection = (capability) => {
147158
+ const req = capability.example?.request;
147159
+ if (req === void 0 || req === null) return [];
147160
+ const json3 = typeof req === "string" ? req : JSON.stringify(req);
147161
+ const truncated = json3.length > 600 ? `${json3.slice(0, 600)}\u2026` : json3;
147162
+ return ["", "Verified example (request):", ` ${truncated}`];
147163
+ };
147129
147164
  var buildTryItExample = (capability) => {
147130
147165
  const method = capability.method.toUpperCase();
147131
147166
  const lines = ["", "Try it:"];
@@ -147199,6 +147234,7 @@ var formatCapability = (capability) => {
147199
147234
  lines.push("", "Parameters:");
147200
147235
  lines.push(...schemaLines);
147201
147236
  }
147237
+ lines.push(...buildVerifiedExampleSection(capability));
147202
147238
  lines.push(...buildResponseSection(capability));
147203
147239
  lines.push(...buildTryItExample(capability));
147204
147240
  return lines.join("\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeroxyz/cli",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "zero": "dist/index.js",