@wirecat/cli-base 0.125.1 → 0.125.2
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
CHANGED
|
@@ -8,6 +8,31 @@ Versions before 0.8.0 are in the [git tags](https://github.com/WireCatLabs/cli-b
|
|
|
8
8
|
Every entry says what changed as a caller sees it, why, and what to watch for — the rules are
|
|
9
9
|
[`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog).
|
|
10
10
|
|
|
11
|
+
## 0.125.2 — 21.11.2026
|
|
12
|
+
|
|
13
|
+
### Security
|
|
14
|
+
|
|
15
|
+
- **A generated `api` group never offers a call whose answer may hold a credential deep inside.** The manifest's
|
|
16
|
+
`response.sensitive` was set only when the answer itself was marked, so a credential one field deep (an object's
|
|
17
|
+
`password`) was printed. It now holds when any field of the answer, behind references too, is marked, and cli-core
|
|
18
|
+
leaves those calls out of `api` with "it returns a credential". `adaptOpenApi` marks a string with
|
|
19
|
+
`format: password`, OpenAPI's word for a value to hide, unless it is `writeOnly` and so never in an answer. Regenerate and review the coverage diff: a call whose answer
|
|
20
|
+
holds such a field leaves the `api` group.
|
|
21
|
+
- **The WordPress converter marks an application password secret.** WordPress answers a new application password in
|
|
22
|
+
clear and its index marks no field secret, so the `api` group of a WordPress CLI offered
|
|
23
|
+
`users-application-passwords-create`. `wpJsonToOpenApi` now gives every read-only `password`, `secret` or `token`
|
|
24
|
+
field `format: password`. The application password routes' create, list, get, update and introspect leave `api`,
|
|
25
|
+
as their answers share the schema; both deletes stay. A post's or a user's `password`, which the caller sets, is not
|
|
26
|
+
marked. A CLI that left the route out with `exclude` may drop that exclusion.
|
|
27
|
+
|
|
28
|
+
### Fixed
|
|
29
|
+
|
|
30
|
+
- **Command names from paths no longer clash on WordPress's whole index.** A GET on a path that ends in a parameter,
|
|
31
|
+
with a GET one parameter deeper, is a list by that parameter: `block-types-list-namespace` beside
|
|
32
|
+
`block-types-get`. A DELETE on a collection beside a DELETE on its item is `…-delete-all`. Both pairs took one name
|
|
33
|
+
and stopped generation, so a CLI mapped one of them in `names.commands`. Mapped the list or the delete-all: nothing
|
|
34
|
+
changes. Mapped the item instead: the other one of the pair takes the new name, and its `api` key with it.
|
|
35
|
+
|
|
11
36
|
## 0.125.1 — 21.11.2026
|
|
12
37
|
|
|
13
38
|
### Fixed
|
package/dist/codegen/manifest.js
CHANGED
|
@@ -28,7 +28,8 @@ const toManifest = (operation, tree) => withoutUndefined({
|
|
|
28
28
|
? withoutUndefined({
|
|
29
29
|
confidence: operation.response.confidence,
|
|
30
30
|
schema: tree.responseName(operation.id),
|
|
31
|
-
|
|
31
|
+
// A credential one field deep is printed as surely as one at the top.
|
|
32
|
+
sensitive: holdsSecret(operation.response.schema, tree) || undefined,
|
|
32
33
|
})
|
|
33
34
|
: undefined,
|
|
34
35
|
});
|
package/dist/codegen/openapi.js
CHANGED
|
@@ -279,6 +279,10 @@ class Adapter {
|
|
|
279
279
|
node.enum = values.map(String);
|
|
280
280
|
if (source.format === "binary")
|
|
281
281
|
node.format = "binary";
|
|
282
|
+
// OpenAPI's own word for a value to hide; an answer that holds one is never printed. A writeOnly one is never
|
|
283
|
+
// in an answer, as FastAPI's SecretStr input.
|
|
284
|
+
if (source.format === "password" && source.writeOnly !== true)
|
|
285
|
+
node.sensitive = true;
|
|
282
286
|
if (typeof source.minLength === "number")
|
|
283
287
|
node.minLength = source.minLength;
|
|
284
288
|
if (typeof source.maxLength === "number")
|
package/dist/codegen/pipeline.js
CHANGED
|
@@ -43,17 +43,21 @@ const commandFromPath = (operation, all, names) => {
|
|
|
43
43
|
const collection = all.some((other) => other.binding.kind === "http" &&
|
|
44
44
|
((other.binding.method === "GET" && other.binding.path === path) ||
|
|
45
45
|
(other.binding.path.startsWith(`${path}/{`) && !other.binding.path.slice(path.length + 1).includes("/"))));
|
|
46
|
-
//
|
|
47
|
-
const
|
|
48
|
-
other.binding.method ===
|
|
46
|
+
// The same method one parameter deeper: this path holds items, though it may end in a parameter itself.
|
|
47
|
+
const holdsItems = all.some((other) => other.binding.kind === "http" &&
|
|
48
|
+
other.binding.method === method &&
|
|
49
49
|
other.binding.path.startsWith(`${path}/{`) &&
|
|
50
50
|
!other.binding.path.slice(path.length + 1).includes("/"));
|
|
51
|
+
const last = parts.at(-1) ?? "";
|
|
51
52
|
const verb = {
|
|
52
|
-
|
|
53
|
+
// WordPress's block-types/{namespace} beside block-types/{namespace}/{name}, and beside block-types' own list.
|
|
54
|
+
GET: onItem && holdsItems ? `list-${kebab(last.slice(1, -1))}` : onItem || last === "me" ? "get" : "list",
|
|
53
55
|
HEAD: "head",
|
|
54
|
-
DELETE
|
|
56
|
+
// A DELETE on the collection beside one on its item deletes them all (WordPress's application passwords).
|
|
57
|
+
DELETE: !onItem && holdsItems ? "delete-all" : "delete",
|
|
55
58
|
PATCH: "update",
|
|
56
|
-
|
|
59
|
+
// A PUT on the collection beside a PUT on its item is the "create or update by a unique value" (Attio's assert).
|
|
60
|
+
PUT: onItem ? "replace" : collection ? (holdsItems ? "upsert" : "replace") : "",
|
|
57
61
|
POST: onItem ? "update" : collection ? "create" : "",
|
|
58
62
|
}[method];
|
|
59
63
|
return [...words, verb].filter(Boolean).join("-");
|
|
@@ -25,7 +25,8 @@ export interface WpJsonResult {
|
|
|
25
25
|
* The OpenAPI document of the routes under `namespaces`. A route offers GET as a read, DELETE as a delete with its
|
|
26
26
|
* arguments in the query (`force=true`), and one write: POST where the route takes it, as WordPress takes the same
|
|
27
27
|
* call by POST, PUT and PATCH. A write's arguments are its JSON body. An array argument in the query travels as one
|
|
28
|
-
* comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name.
|
|
28
|
+
* comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name. A read-only credential
|
|
29
|
+
* field becomes `format: password`, so no generated command prints an answer that may hold it.
|
|
29
30
|
*/
|
|
30
31
|
export declare const wpJsonToOpenApi: (index: unknown, options: WpJsonOptions) => WpJsonResult;
|
|
31
32
|
/** The snapshot's entry in `provenance.json`. */
|
package/dist/codegen/wp-json.js
CHANGED
|
@@ -18,6 +18,11 @@ const object = (value) => !!value && typeof value === "object" && !Array.isArray
|
|
|
18
18
|
const DROPPED = new Set(["context", "readonly", "arg_options", "links", "$schema", "patternProperties", "required"]);
|
|
19
19
|
/** WordPress names the boolean type `bool` in a few block attributes. */
|
|
20
20
|
const typeName = (type) => type === "bool" ? "boolean" : Array.isArray(type) ? type.map(typeName) : type;
|
|
21
|
+
/**
|
|
22
|
+
* A secret WordPress makes and answers, as an application password's `password`: read-only, so no caller sets it. The
|
|
23
|
+
* index marks nothing secret, and a post's or a user's `password` is the caller's own input, never answered.
|
|
24
|
+
*/
|
|
25
|
+
const credential = (name, field) => object(field) && field.readonly === true && /(^|_)(password|secret|token)$/i.test(name);
|
|
21
26
|
/**
|
|
22
27
|
* One JSON Schema draft 4 node, as WordPress writes it, → its OpenAPI 3.1 form: a field's `required: true` joins its
|
|
23
28
|
* object's `required` list, a node with `properties` and no type is an object, and a draft 4 `exclusiveMinimum: true`
|
|
@@ -36,7 +41,10 @@ const schemaOf = (value, where) => {
|
|
|
36
41
|
if (key === "type")
|
|
37
42
|
out.type = typeName(field);
|
|
38
43
|
else if (key === "properties" && object(field))
|
|
39
|
-
out.properties = Object.fromEntries(Object.entries(field).map(([name, inner]) => [
|
|
44
|
+
out.properties = Object.fromEntries(Object.entries(field).map(([name, inner]) => [
|
|
45
|
+
name,
|
|
46
|
+
schemaOf(credential(name, inner) ? { ...inner, format: "password" } : inner, `${where}/properties/${name}`),
|
|
47
|
+
]));
|
|
40
48
|
else if (key === "items")
|
|
41
49
|
out.items = schemaOf(field, `${where}/items`);
|
|
42
50
|
else if ((key === "oneOf" || key === "anyOf") && Array.isArray(field))
|
|
@@ -133,7 +141,8 @@ const isList = (args) => "per_page" in args && "page" in args;
|
|
|
133
141
|
* The OpenAPI document of the routes under `namespaces`. A route offers GET as a read, DELETE as a delete with its
|
|
134
142
|
* arguments in the query (`force=true`), and one write: POST where the route takes it, as WordPress takes the same
|
|
135
143
|
* call by POST, PUT and PATCH. A write's arguments are its JSON body. An array argument in the query travels as one
|
|
136
|
-
* comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name.
|
|
144
|
+
* comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name. A read-only credential
|
|
145
|
+
* field becomes `format: password`, so no generated command prints an answer that may hold it.
|
|
137
146
|
*/
|
|
138
147
|
export const wpJsonToOpenApi = (index, options) => {
|
|
139
148
|
if (!object(index) || !object(index.routes))
|
|
@@ -52,6 +52,10 @@ what it cannot do yet.
|
|
|
52
52
|
| WordPress's REST index | `adaptOpenApi(wpJsonToOpenApi(readWpJson(dir), { namespaces: ["wp/v2"] }).document)`, the index written by `syncWpJson` |
|
|
53
53
|
| A Postman collection v2.0 or v2.1 (Braze) | `adaptOpenApi(postmanToOpenApi(collection, { variables }).document)`, the collection committed in `spec/<service>/` with its provenance; a POST that only reads gets an `effect` override |
|
|
54
54
|
|
|
55
|
+
A string with `format: password` (not `writeOnly`) is a credential: a call whose answer holds one anywhere gets
|
|
56
|
+
`response.sensitive` in the manifest, and cli-core offers no `api` command for it. `wpJsonToOpenApi` gives a read-only
|
|
57
|
+
`password`, `secret` or `token` field that format, as WordPress's index marks nothing secret.
|
|
58
|
+
|
|
55
59
|
`upgradeToOpenApi3` converts with [swagger-converter](https://github.com/apigee-127/swagger-converter) (1.2 → 2.0) and
|
|
56
60
|
[@scalar/openapi-upgrader](https://github.com/scalar/scalar/tree/main/packages/openapi-upgrader) (2.0 → 3.0). They are
|
|
57
61
|
optional peer dependencies of cli-base: a CLI that converts adds them to its `devDependencies`. Commit the source as the
|
|
@@ -105,8 +109,11 @@ From the source the generator reads:
|
|
|
105
109
|
runs any SQL). An override still wins.
|
|
106
110
|
- **`names`**: `{ commands, fromPath, segments }`. `commands` maps an operation id to its command. With `fromPath`,
|
|
107
111
|
the rest are named from the path and the method (`deals-list`, `deals-get`, `deals-create`, `deals-delete`,
|
|
108
|
-
`deals-batch-archive`), leaving out path parameters and versions (`v3`, `2026-03`), which `segments` cannot rename.
|
|
109
|
-
|
|
112
|
+
`deals-batch-archive`), leaving out path parameters and versions (`v3`, `2026-03`), which `segments` cannot rename.
|
|
113
|
+
A path that ends in a parameter yet holds items one parameter deeper lists by that parameter
|
|
114
|
+
(`block-types-list-namespace` beside `block-types-get`); a DELETE on a collection beside one on its item is
|
|
115
|
+
`…-delete-all`; a PUT there is `…-upsert`. A name that comes out empty or not in kebab case stops generation; map
|
|
116
|
+
that operation in `commands`. `segments` renames a path segment
|
|
110
117
|
or, with `""`, leaves it out: `{ "0-3": "deals", crm: "", objects: "" }`. Without `names` the command is the operation
|
|
111
118
|
id in kebab case, as before.
|
|
112
119
|
- **`permissions`**: `{ group, deletingFlags, forceFlags, shares, valueKeys }`. `group` is a name (`files`) or a function of the operation, for
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wirecat/cli-base",
|
|
3
|
-
"version": "0.125.
|
|
3
|
+
"version": "0.125.2",
|
|
4
4
|
"description": "The parts every command line tool needs: output modes, terminal rendering, error model, exit codes, credentials, clocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Viacheslav Ptsarev",
|