@zeroxyz/cli 1.4.0 → 1.5.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/index.js +62 -13
- 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.
|
|
76585
|
+
version: "1.5.0"};
|
|
76586
76586
|
|
|
76587
76587
|
// src/app.ts
|
|
76588
76588
|
init_esm_shims();
|
|
@@ -147012,12 +147012,27 @@ var coerceToType = (value, type2) => {
|
|
|
147012
147012
|
}
|
|
147013
147013
|
return value;
|
|
147014
147014
|
};
|
|
147015
|
-
var sampleValueFor = (fieldName, propSchema) => {
|
|
147015
|
+
var sampleValueFor = (fieldName, propSchema, depth = 0) => {
|
|
147016
147016
|
const node = asNode(propSchema);
|
|
147017
147017
|
const type2 = schemaType(node);
|
|
147018
|
-
const
|
|
147019
|
-
|
|
147020
|
-
|
|
147018
|
+
const enumFirst = Array.isArray(node?.enum) && node.enum.length > 0 ? node.enum[0] : void 0;
|
|
147019
|
+
const fixed = node?.const ?? node?.example ?? node?.default ?? enumFirst;
|
|
147020
|
+
if (fixed !== void 0 && fixed !== null) {
|
|
147021
|
+
return coerceToType(fixed, type2);
|
|
147022
|
+
}
|
|
147023
|
+
if (node && depth < MAX_SCHEMA_DEPTH) {
|
|
147024
|
+
const props = asNode(node.properties);
|
|
147025
|
+
if (props && (type2 === "object" || type2 === void 0)) {
|
|
147026
|
+
const obj = {};
|
|
147027
|
+
for (const [k3, sub] of Object.entries(props)) {
|
|
147028
|
+
obj[k3] = sampleValueFor(k3, sub, depth + 1);
|
|
147029
|
+
}
|
|
147030
|
+
return obj;
|
|
147031
|
+
}
|
|
147032
|
+
if (type2 === "array") {
|
|
147033
|
+
const items = asNode(node.items);
|
|
147034
|
+
return items ? [sampleValueFor(fieldName, items, depth + 1)] : [];
|
|
147035
|
+
}
|
|
147021
147036
|
}
|
|
147022
147037
|
switch (type2) {
|
|
147023
147038
|
case "number":
|
|
@@ -147061,18 +147076,31 @@ var schemaTypeLabel = (node) => {
|
|
|
147061
147076
|
};
|
|
147062
147077
|
var constraintHint = (node) => {
|
|
147063
147078
|
const num2 = (k3) => typeof node[k3] === "number" ? node[k3] : void 0;
|
|
147079
|
+
const hints = [];
|
|
147064
147080
|
const min = num2("minimum");
|
|
147065
147081
|
const max = num2("maximum");
|
|
147066
|
-
if (min !== void 0 && max !== void 0)
|
|
147067
|
-
|
|
147068
|
-
if (
|
|
147082
|
+
if (min !== void 0 && max !== void 0)
|
|
147083
|
+
hints.push(`range: ${min}..${max}`);
|
|
147084
|
+
else if (min !== void 0) hints.push(`min: ${min}`);
|
|
147085
|
+
else if (max !== void 0) hints.push(`max: ${max}`);
|
|
147086
|
+
const exMin = num2("exclusiveMinimum");
|
|
147087
|
+
const exMax = num2("exclusiveMaximum");
|
|
147088
|
+
if (exMin !== void 0) hints.push(`> ${exMin}`);
|
|
147089
|
+
if (exMax !== void 0) hints.push(`< ${exMax}`);
|
|
147069
147090
|
const minLen = num2("minLength");
|
|
147070
147091
|
const maxLen = num2("maxLength");
|
|
147071
147092
|
if (minLen !== void 0 && maxLen !== void 0)
|
|
147072
|
-
|
|
147073
|
-
if (maxLen !== void 0)
|
|
147074
|
-
if (minLen !== void 0)
|
|
147075
|
-
|
|
147093
|
+
hints.push(`length: ${minLen}..${maxLen}`);
|
|
147094
|
+
else if (maxLen !== void 0) hints.push(`maxLength: ${maxLen}`);
|
|
147095
|
+
else if (minLen !== void 0) hints.push(`minLength: ${minLen}`);
|
|
147096
|
+
const minItems = num2("minItems");
|
|
147097
|
+
const maxItems = num2("maxItems");
|
|
147098
|
+
if (minItems !== void 0 && maxItems !== void 0)
|
|
147099
|
+
hints.push(`items: ${minItems}..${maxItems}`);
|
|
147100
|
+
else if (maxItems !== void 0) hints.push(`maxItems: ${maxItems}`);
|
|
147101
|
+
else if (minItems !== void 0) hints.push(`minItems: ${minItems}`);
|
|
147102
|
+
if (typeof node.pattern === "string") hints.push(`pattern: ${node.pattern}`);
|
|
147103
|
+
return hints.length > 0 ? hints.join(", ") : null;
|
|
147076
147104
|
};
|
|
147077
147105
|
var MAX_SCHEMA_DEPTH = 5;
|
|
147078
147106
|
var paramAttrs = (node, required3) => {
|
|
@@ -147115,6 +147143,17 @@ var renderParam = (name, propSchema, required3, depth = 0) => {
|
|
|
147115
147143
|
lines.push(...renderParam(`option ${i + 1}`, v, false, depth + 2));
|
|
147116
147144
|
});
|
|
147117
147145
|
}
|
|
147146
|
+
if (Array.isArray(node.allOf) && node.allOf.length > 0) {
|
|
147147
|
+
lines.push(`${pad9} must satisfy all of:`);
|
|
147148
|
+
node.allOf.forEach((v, i) => {
|
|
147149
|
+
lines.push(...renderParam(`part ${i + 1}`, v, false, depth + 2));
|
|
147150
|
+
});
|
|
147151
|
+
}
|
|
147152
|
+
if (typeof node.$ref === "string") {
|
|
147153
|
+
lines.push(
|
|
147154
|
+
`${pad9} \u26A0 schema reference not inlined (${node.$ref}) \u2014 shape incomplete, see provider docs`
|
|
147155
|
+
);
|
|
147156
|
+
}
|
|
147118
147157
|
return lines;
|
|
147119
147158
|
};
|
|
147120
147159
|
var renderProps = (node, depth = 0) => {
|
|
@@ -147134,7 +147173,17 @@ var buildSchemaSection = (capability) => {
|
|
|
147134
147173
|
capability.bodySchema,
|
|
147135
147174
|
capability.method
|
|
147136
147175
|
);
|
|
147137
|
-
|
|
147176
|
+
const lines = [...renderProps(queryParams), ...renderProps(body)];
|
|
147177
|
+
if (lines.length === 0) {
|
|
147178
|
+
const root = asNode(capability.bodySchema);
|
|
147179
|
+
const unresolved = (n) => !!n && (n.$ref !== void 0 || Array.isArray(n.allOf));
|
|
147180
|
+
if (unresolved(root ?? void 0) || unresolved(queryParams) || unresolved(body)) {
|
|
147181
|
+
return [
|
|
147182
|
+
" \u26A0 input schema could not be expanded ($ref/allOf not inlined) \u2014 use the verified example below or the provider's docs"
|
|
147183
|
+
];
|
|
147184
|
+
}
|
|
147185
|
+
}
|
|
147186
|
+
return lines;
|
|
147138
147187
|
};
|
|
147139
147188
|
var buildResponseSection = (capability) => {
|
|
147140
147189
|
const rs = asNode(capability.responseSchema);
|