diff --git a/README.md b/README.md index b71e81a..957c8a8 100644 --- a/README.md +++ b/README.md @@ -187,9 +187,10 @@ More: [permissions](https://github.com/WireCatLabs/wordpress-cli/blob/main/docs/ - Only self-hosted WordPress with application passwords. WordPress.com sites, which sign in with OAuth, are not supported. Sign-in through the browser is not there yet: you paste the password. - An Author or Contributor gets only their own posts, and no pages: WordPress refuses the pages list to both, and the - sync says so. A Contributor gets only their drafts and posts waiting for review. For both, a post that leaves their - view stays in the copy as it was: one deleted for good, or a Contributor's post an editor published. Only an Administrator gets the users list. Sign in as an Administrator for a full - copy. + sync says so. A Contributor gets only their drafts and posts waiting for review. A post that leaves their view and + that they may no longer read stays in the copy as it was, such as a Contributor's post an editor published. Only an + Administrator gets every user with their e-mail; other roles get the authors with published posts. Sign in as an + Administrator for a full copy. - No view counts. WordPress itself keeps none, and Jetpack stats are not supported. - A post with galleries, columns, embeds or iframes keeps its body: `posts update` changes its title, excerpt, tags and status only, unless you add `--replace-body`. diff --git a/changes/feat-pages-and-authors.md b/changes/feat-pages-and-authors.md new file mode 100644 index 0000000..f8b4e23 --- /dev/null +++ b/changes/feat-pages-and-authors.md @@ -0,0 +1,26 @@ +### Added + +- **`posts create --type page` and every write to a page.** A page is now written through WordPress's pages routes: + create, update, publish, schedule, unpublish, trash and delete for good. A page has no tags, so `--tags` on a page + stops with `content.write-unsupported`. `--dry-run` names the pages keys a page write checks. + +### Fixed + +- **An Editor or Author gets the authors.** WordPress lists the users with their e-mail to an Administrator only, and + the sync got no authors at all for any other role. It now reads them the way WordPress answers every role: the + authors with published posts, by name, without e-mail. The sync names this as a gap. +- **An Author or Contributor sync reads only the changes, and sees a post deleted for good.** Each sync read every post + again, and a post deleted for good stayed in the copy. Later syncs now read only what changed. Once a day the sync + reads each post that left the list once more: a post the site deleted for good is marked deleted, and one the role + may no longer read stays as it was. +- **A post's text keeps its `-` list marker** instead of turning `- one` into `* one`. +- **`posts publish --at-time` with a past time names `--at-time`** in its error, not `--at`. + +### Changed — may break callers + +- **cli-core 0.716.0 and cli-base 0.125.3.** cli-base now marks a new application password in an answer as secret, + so the `api` group no longer offers any call whose answer can hold one: `users-application-passwords-create`, + `-list`, `-get`, `-update` and `-introspect-list`. The hand-written exclusion of that route is gone, and + `api users-application-passwords-delete-all` is back, asking first like every delete. +- **`posts.delete: deny` also stops `api pages-delete`.** A page's delete route checked only `pages.delete`, so the + content key did not reach it, as it already did for the posts route and for creating and updating a page. diff --git a/contracts/help.snap b/contracts/help.snap index d077975..1780bdb 100644 --- a/contracts/help.snap +++ b/contracts/help.snap @@ -17,6 +17,7 @@ Works with: pbx Asterisk PBX calls and recordings, searchable with your other WireCat data notion Notion pages and databases as local text, searchable with your other WireCat data ydisk Yandex Disk folders as local text, searchable with your other WireCat data + linear Linear issues and projects, searchable with your other WireCat data Next: wordpress commands every command, by section wordpress help options output, offline, timeouts, dry run diff --git a/contracts/mcp-catalogue.json b/contracts/mcp-catalogue.json index eadce12..c04bdfb 100644 --- a/contracts/mcp-catalogue.json +++ b/contracts/mcp-catalogue.json @@ -127,10 +127,8 @@ "api users-get": "read", "api users-update": "write", "api users-delete": "write", - "api users-application-passwords-get": "read", - "api users-application-passwords-update": "write", + "api users-application-passwords-delete-all": "write", "api users-application-passwords-delete": "write", - "api users-application-passwords-introspect-list": "read", "api users-me-get": "read", "api users-me-create": "write", "api users-me-delete": "write", diff --git a/contracts/wirecat.json b/contracts/wirecat.json index b0866b4..a398b97 100644 --- a/contracts/wirecat.json +++ b/contracts/wirecat.json @@ -1611,26 +1611,14 @@ { "path": [ "api", - "users-application-passwords-get" + "users-application-passwords-delete-all" ], - "summary": "getWpV2UsersByUserIdApplicationPasswordsByUuid — read (GET…", - "effects": { - "remote": "read", - "local": "none" - }, - "permission": "api.users-application-passwords-get" - }, - { - "path": [ - "api", - "users-application-passwords-update" - ], - "summary": "postWpV2UsersByUserIdApplicationPasswordsByUuid — write (POST…", + "summary": "deleteWpV2UsersByUserIdApplicationPasswords — destructive (DELETE…", "effects": { "remote": "write", "local": "none" }, - "permission": "api.users-application-passwords-update" + "permission": "api.users-application-passwords-delete-all" }, { "path": [ @@ -1644,18 +1632,6 @@ }, "permission": "api.users-application-passwords-delete" }, - { - "path": [ - "api", - "users-application-passwords-introspect-list" - ], - "summary": "getWpV2UsersByUserIdApplicationPasswordsIntrospect — read (GET…", - "effects": { - "remote": "read", - "local": "none" - }, - "permission": "api.users-application-passwords-introspect-list" - }, { "path": [ "api", diff --git a/docs/commands.md b/docs/commands.md index b78e76a..30498f1 100644 --- a/docs/commands.md +++ b/docs/commands.md @@ -2448,40 +2448,21 @@ wordpress api users-delete [options] **Example:** `wordpress personal api users-delete --id --reassign ` -### `wordpress api users-application-passwords-get` +### `wordpress api users-application-passwords-delete-all` -getWpV2UsersByUserIdApplicationPasswordsByUuid — read (GET /wp/v2/users/{user_id}/application-passwords/{uuid}) - -```sh -wordpress api users-application-passwords-get [options] -``` - -| Option | What it does | -|---|---| -| `--user-id ` | user_id. | -| `--uuid ` | uuid. | -| `--context ` | Scope under which the request is made; determines fields present in response. | - -**Example:** `wordpress personal api users-application-passwords-get --user-id --uuid ` - -### `wordpress api users-application-passwords-update` - -postWpV2UsersByUserIdApplicationPasswordsByUuid — write (POST /wp/v2/users/{user_id}/application-passwords/{uuid}) +deleteWpV2UsersByUserIdApplicationPasswords — destructive (DELETE /wp/v2/users/{user_id}/application-passwords) **Changes something in the service.** ```sh -wordpress api users-application-passwords-update [options] +wordpress api users-application-passwords-delete-all [options] ``` | Option | What it does | |---|---| | `--user-id ` | user_id. | -| `--uuid ` | uuid. | -| `--body ` | the request body as JSON; - reads it from stdin. | -| `--body-file ` | the request body from a JSON file; - is stdin. | -**Example:** `wordpress personal api users-application-passwords-update --user-id --uuid ` +**Example:** `wordpress personal api users-application-passwords-delete-all --user-id ` ### `wordpress api users-application-passwords-delete` @@ -2500,21 +2481,6 @@ wordpress api users-application-passwords-delete [options] **Example:** `wordpress personal api users-application-passwords-delete --user-id --uuid ` -### `wordpress api users-application-passwords-introspect-list` - -getWpV2UsersByUserIdApplicationPasswordsIntrospect — read (GET /wp/v2/users/{user_id}/application-passwords/introspect) - -```sh -wordpress api users-application-passwords-introspect-list [options] -``` - -| Option | What it does | -|---|---| -| `--user-id ` | user_id. | -| `--context ` | Scope under which the request is made; determines fields present in response. | - -**Example:** `wordpress personal api users-application-passwords-introspect-list --user-id ` - ### `wordpress api users-me-get` getWpV2UsersMe — read (GET /wp/v2/users/me) diff --git a/docs/dev/API_COVERAGE.md b/docs/dev/API_COVERAGE.md index 172f976..e4c8764 100644 --- a/docs/dev/API_COVERAGE.md +++ b/docs/dev/API_COVERAGE.md @@ -6,7 +6,7 @@ Run: pnpm generate # API coverage -147 operations from openapi unknown. +150 operations from openapi unknown. | Operation | Call | Command | Effect | Request source | Status | Summary | |---|---|---|---|---|---|---| @@ -136,6 +136,9 @@ Run: pnpm generate | `getWpV2UsersById` | `GET /wp/v2/users/{id}` | `wordpress api users-get` | read | — | generated | | | `postWpV2UsersById` | `POST /wp/v2/users/{id}` | `wordpress api users-update` | write | contract | generated | | | `deleteWpV2UsersById` | `DELETE /wp/v2/users/{id}` | `wordpress api users-delete` | destructive | — | generated | | +| `getWpV2UsersByUserIdApplicationPasswords` | `GET /wp/v2/users/{user_id}/application-passwords` | `wordpress api users-application-passwords-list` | read | — | generated | | +| `postWpV2UsersByUserIdApplicationPasswords` | `POST /wp/v2/users/{user_id}/application-passwords` | `wordpress api users-application-passwords-create` | write | contract | generated | | +| `deleteWpV2UsersByUserIdApplicationPasswords` | `DELETE /wp/v2/users/{user_id}/application-passwords` | `wordpress api users-application-passwords-delete-all` | destructive | — | generated | | | `getWpV2UsersByUserIdApplicationPasswordsByUuid` | `GET /wp/v2/users/{user_id}/application-passwords/{uuid}` | `wordpress api users-application-passwords-get` | read | — | generated | | | `postWpV2UsersByUserIdApplicationPasswordsByUuid` | `POST /wp/v2/users/{user_id}/application-passwords/{uuid}` | `wordpress api users-application-passwords-update` | write | contract | generated | | | `deleteWpV2UsersByUserIdApplicationPasswordsByUuid` | `DELETE /wp/v2/users/{user_id}/application-passwords/{uuid}` | `wordpress api users-application-passwords-delete` | destructive | — | generated | | @@ -243,6 +246,7 @@ Run: pnpm generate | `postWpV2Templates` | `templates.publish` | always | | `deleteWpV2UsersById` | `users.delete` | always | | `deleteWpV2UsersById` | `users.delete.force` | query `force` is true | +| `deleteWpV2UsersByUserIdApplicationPasswords` | `users.delete` | always | | `deleteWpV2UsersByUserIdApplicationPasswordsByUuid` | `users.delete` | always | | `deleteWpV2UsersMe` | `users.delete` | always | | `deleteWpV2UsersMe` | `users.delete.force` | query `force` is true | @@ -284,7 +288,6 @@ Run: pnpm generate - `/wp/v2/templates/(?P([^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)[\/\w%-]+)/revisions/(?P[\d]+)`: left out, as its value may hold a slash, which no path segment carries - `/wp/v2/themes/(?P[^\/:<>\*\?"\|]+(?:\/[^\/:<>\*\?"\|]+)?)`: left out, as its value may hold a slash, which no path segment carries - `/wp/v2/users/(?P[\d]+)`: PUT, PATCH left out, as POST does the same -- `/wp/v2/users/(?P(?:[\d]+|me))/application-passwords`: excluded — its POST creates an application password and answers with it in clear. The CLI signs in through session start - `/wp/v2/users/(?P(?:[\d]+|me))/application-passwords/(?P[\w\-]+)`: PUT, PATCH left out, as POST does the same - `/wp/v2/users/me`: PUT, PATCH left out, as POST does the same - `/wp/v2/widgets/(?P[\w\-]+)`: PUT, PATCH left out, as POST does the same diff --git a/docs/dev/live-checks.txt b/docs/dev/live-checks.txt index 1ed7d86..4b0dd53 100644 --- a/docs/dev/live-checks.txt +++ b/docs/dev/live-checks.txt @@ -2,3 +2,5 @@ 0.1.0 7e53d4b7c1019e891e3ecf90b6ab46ed18eb5f7b 2026-11-19 scripts/live.sh v2:066644ffc909024bc3fafdcc3719dea658a13d1f97b81f1f628b79fb010c63d4 0.1.1 96ac241ba20fab5610f82365bd5277eebf684ecb 2026-11-19 scripts/live.sh v2:7025787aec7dcfd8ec43a65d7cebd26ad2fc4c11b96c861e4d1f6fce669d1aa3 0.1.2 7cf92fea715012e3c113522ffcffb373f7e28066 2026-11-19 scripts/live.sh v2:4a1845a1d741d206b26a9d4ee86fa46753cf3095a74deb2cd96934d62f36de68 +0.1.2 b25ff9d21928bf217c74ccd75f37174eb427ee4b 2026-11-21 scripts/live.sh v2:e4564e7d90c5a1ca41d2c157edf28ad61603970d622e423d6b70a1a67b9a2e73 +0.1.2 60cde46dde8ddaa5c5d446d2054c12f34145e4e4 2026-11-21 scripts/live.sh v2:f167775a6dccda03576b9ac30fa10529f36b23b6842405c3eb1fa4979c789e79 diff --git a/docs/dev/test-matrix.md b/docs/dev/test-matrix.md index 7fad32d..826fa39 100644 --- a/docs/dev/test-matrix.md +++ b/docs/dev/test-matrix.md @@ -7,7 +7,7 @@ ran it · ⛔ not tested offline, with the reason and where it is checked instea Measured from the test run (`coverage/argv.jsonl`), not searched for — see [TESTING.md](TESTING.md) for how, and for the states and failures that cut across commands. -**878 ✅ · 24 ⛔ · 0 ❌** — 192 commands, 710 options. +**868 ✅ · 24 ⛔ · 0 ❌** — 190 commands, 702 options. | Command | Option | | Note | |---|---|---|---| @@ -719,21 +719,11 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see | `api users-delete` | `--id` | ✅ | | | `api users-delete` | `--force` | ✅ | | | `api users-delete` | `--reassign` | ✅ | | -| `api users-application-passwords-get` | | ✅ | | -| `api users-application-passwords-get` | `--user-id` | ✅ | | -| `api users-application-passwords-get` | `--uuid` | ✅ | | -| `api users-application-passwords-get` | `--context` | ✅ | | -| `api users-application-passwords-update` | | ✅ | | -| `api users-application-passwords-update` | `--user-id` | ✅ | | -| `api users-application-passwords-update` | `--uuid` | ✅ | | -| `api users-application-passwords-update` | `--body` | ✅ | | -| `api users-application-passwords-update` | `--body-file` | ✅ | | +| `api users-application-passwords-delete-all` | | ✅ | | +| `api users-application-passwords-delete-all` | `--user-id` | ✅ | | | `api users-application-passwords-delete` | | ✅ | | | `api users-application-passwords-delete` | `--user-id` | ✅ | | | `api users-application-passwords-delete` | `--uuid` | ✅ | | -| `api users-application-passwords-introspect-list` | | ✅ | | -| `api users-application-passwords-introspect-list` | `--user-id` | ✅ | | -| `api users-application-passwords-introspect-list` | `--context` | ✅ | | | `api users-me-get` | | ✅ | | | `api users-me-get` | `--context` | ✅ | | | `api users-me-create` | | ✅ | | diff --git a/docs/index.md b/docs/index.md index 363efaf..ec3a6df 100644 --- a/docs/index.md +++ b/docs/index.md @@ -122,8 +122,10 @@ password. - Only self-hosted WordPress with application passwords. WordPress.com sites are not supported. - You paste the application password. Sign-in through the browser is on the [roadmap](roadmap.md). - An Author or Contributor gets only their own posts, and no pages: WordPress refuses the pages list to both. A - Contributor gets only their drafts and posts waiting for review. For both, a post that leaves their view stays in - the copy as it was: one deleted for good, or a Contributor's post an editor published. Only an Administrator gets the users list. Sync reports each of these as a gap. + Contributor gets only their drafts and posts waiting for review. A post that leaves their view and that they may no + longer read stays in the copy as it was, such as a Contributor's post an editor published. Only an Administrator + gets every user with their e-mail; other roles get the authors with published posts. Sync reports each of these as + a gap. - No view counts. WordPress itself keeps none, and Jetpack stats are not supported. `posts stats` shows only what the copy has. - Plugin fields, such as those of SEO or custom field plugins, have no flags. The `api` group sends them in a raw diff --git a/docs/installation.md b/docs/installation.md index 3ff697b..1ddb7d4 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -20,8 +20,9 @@ permissions allow. - A self-hosted WordPress site, version 5.7 or later, reached over https. WordPress makes application passwords only there. WordPress.com sites are not supported. - A user on the site. For a full copy, the user should be an Administrator. An Editor gets every post and page, but - WordPress lists the users to an Administrator only. An Author or Contributor gets only their own posts, and no pages: - WordPress refuses them the pages list. A Contributor gets only their drafts and posts waiting for review. + WordPress gives every user and their e-mail to an Administrator only: an Editor gets the authors with published + posts. An Author or Contributor gets only their own posts, and no pages: WordPress refuses them the pages list. A + Contributor gets only their drafts and posts waiting for review. - For the command line: Node.js 22.16 or a later 22.x, or Node.js 24 or later. Node 23 is not supported. ## Install the tool diff --git a/docs/permissions.md b/docs/permissions.md index 1b60833..9b199a1 100644 --- a/docs/permissions.md +++ b/docs/permissions.md @@ -53,6 +53,12 @@ run it yourself in a terminal. | `posts.delete.force` | `ask` | `posts delete --allow-delete`, which deletes for good. | | Every read | `allow` | `sync`, `posts list`, `posts show` and the other reads. | +A write to a page goes through the pages routes, so it also checks their keys: `pages.publish` when it publishes or +schedules the page, or updates a page that is published or scheduled; `pages.delete` when it deletes the page, to the +trash or for good; and `pages.delete.force` with `--allow-delete`. Each asks by default. After a yes to the `posts` +key, the same action on the page is not asked again. `posts publish` and `posts unpublish` still ask `posts.update` +a second time, for a post and a page, until the next cli-core release. + ## The api group `wordpress blog api` reaches every WordPress operation, and checks the same publishing and deleting keys: diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 6b6ad9a..ca1791d 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -34,7 +34,7 @@ wordpress blog session status --check # asks your site whose password it is | No **Application Passwords** section in your profile | The site needs WordPress 5.7 or later over https, and a plugin or the host may turn the section off. Ask the site's admin. | | A WordPress.com address | WordPress.com sites are not supported, only self-hosted WordPress. | | `posts list` is empty | Run `wordpress blog sync` first. Posts are read from the copy it makes. | -| `sync` names gaps, or pages are missing | An Author or Contributor sign-in cannot list pages and gets only their own posts; a Contributor only their drafts and posts waiting for review. Only an Administrator lists the users. Sign in as an Administrator for a full copy, or as an Editor for every post and page. | +| `sync` names gaps, or pages are missing | An Author or Contributor sign-in cannot list pages and gets only their own posts; a Contributor only their drafts and posts waiting for review. Only an Administrator gets every user with an e-mail; other roles get the authors with published posts. Sign in as an Administrator for a full copy, or as an Editor for every post and page. | | A change on the site is missing from the copy | Run `sync`. If the post is not yours and you sign in as an Author or Contributor, see the row above. | | `content.conflict` | The post changed on the site since the last sync. Run `sync`, look at the post again, then retry. | | `content.lossy-body` | The post has galleries, columns, embeds or iframes that Markdown cannot keep. Change only its title, excerpt, tags or status, or add `--replace-body` to write the body anyway and flatten them. See [when a write stops](usage.md#when-a-write-stops). | diff --git a/docs/usage.md b/docs/usage.md index d3f6516..4ec0e72 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -50,10 +50,11 @@ for good. A post in the trash stays in the copy, with its status. A sync names each gap: what your WordPress role may not read. With an Author or Contributor sign-in, the sync copies your own posts and skips the pages, as WordPress refuses the pages list to both. A Contributor gets only their drafts -and posts waiting for review. For both, each sync reads all of your posts again, not only the changes, and a post -that leaves your view stays in the copy as it was: one deleted for good, or a Contributor's post an editor published. -Only an Administrator gets the users list, so an Editor's copy has every post and page but no users. Sign in as an -Administrator for a full copy. +and posts waiting for review. Later syncs read only the changes for these roles too. Once a day the sync reads again, +by its id, each post your list no longer shows: a post deleted for good is marked deleted, and one you may no longer +read (a Contributor's post an editor published) stays in the copy as it was. Only an Administrator gets every user with +their e-mail. Other roles get the authors with published posts, by name. Sign in as an Administrator for a full +copy. `--max-pages` caps the requests in one run. The next sync goes on from where it stopped. @@ -98,7 +99,7 @@ wordpress blog channels list # the site this profile copies ``` `posts create --tags` and the `tag:` filter take the ids that `tags list` shows. `users list` also names the person -the store knows by the same e-mail, from your other WireCat tools. +the store knows by the same e-mail, from your other WireCat tools. Only an Administrator's copy has the e-mails. ## Write a draft @@ -107,11 +108,14 @@ wordpress blog posts create --title "Version 3" --text-file notes.md --descripti cat notes.md | wordpress blog posts create --title "Version 3" --text-file - wordpress blog posts update 63 --title "Version 3 is out" wordpress blog posts update 63 --text-file notes-v2.md --slug version-3 +wordpress blog posts create --type page --title "Contact" --text-file contact.md ``` `posts create` always makes a draft. Publishing is its own step. The text is Markdown, from a file or from stdin with `--text-file -`. `--description` sets the excerpt, the short text that lists show. `--tags` takes tag and -category ids and replaces the ones the post had. `--slug` is the last part of the post's address. +category ids and replaces the ones the post had. `--slug` is the last part of the post's address. `--type page` +makes a page. Every other write finds out by itself if the id is a page. A page has no tags, so `--tags` on a page +stops with `content.write-unsupported`. `posts update` changes the fields you name. A change to a published or scheduled post is public, so it checks `posts.publish` too. diff --git a/lint/audit-differences.json b/lint/audit-differences.json index fe51488..81a82cf 100644 --- a/lint/audit-differences.json +++ b/lint/audit-differences.json @@ -1 +1,9 @@ -[] +[ + { + "group": "wordpress", + "rule": "same-error-reason", + "target": "reason account-remove.unknown-profile=account-rename.unknown-profile", + "reason": "one failure under two names, from cli-core 0.716.0, that every CLI of the family prints (FIND-2855)", + "review_after": "2026-12-05" + } +] diff --git a/package.json b/package.json index 124d2f7..a3ead93 100644 --- a/package.json +++ b/package.json @@ -61,8 +61,8 @@ "source:check": "node --experimental-strip-types scripts/source-check.ts" }, "dependencies": { - "@wirecat/cli-base": "0.124.0", - "@wirecat/cli-core": "0.710.0", + "@wirecat/cli-base": "0.125.3", + "@wirecat/cli-core": "0.716.0", "commander": "15.0.0", "valibot": "1.5.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 05e8c40..76254fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,11 +13,11 @@ importers: .: dependencies: '@wirecat/cli-base': - specifier: 0.124.0 - version: 0.124.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) + specifier: 0.125.3 + version: 0.125.3(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core': - specifier: 0.710.0 - version: 0.710.0(@wirecat/cli-base@0.124.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) + specifier: 0.716.0 + version: 0.716.0(@wirecat/cli-base@0.125.3(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) commander: specifier: 15.0.0 version: 15.0.0 @@ -1185,8 +1185,8 @@ packages: '@wasm-audio-decoders/opus-ml@0.0.3': resolution: {integrity: sha512-SEeTmk0eb3q5etJA/NHCRWW6BivTx9tqvNTmG0kg2ynuATEQRUZnwQE6Ibvl1BBvqIGHqI57+qyJMWmJBwb5XQ==} - '@wirecat/cli-base@0.124.0': - resolution: {integrity: sha512-kl/6+PqN7sWkWqYvI2ujvoDK6PaUBvY7NTB5oDYk0CQdqWDV2MqYxgR1BXxwWDB88SzUA5GpN7x0ykVHksjfaQ==} + '@wirecat/cli-base@0.125.3': + resolution: {integrity: sha512-9nl18agKsPzN6dW+b52HyPkPOPB8pmQWThNO3KD2irL3j4YfHdBk+LesLWAcJrppzmE6gSmo1pprL+qeN+GfSw==} engines: {node: '>=22'} hasBin: true peerDependencies: @@ -1213,13 +1213,13 @@ packages: '@wirecat/cli-core-sqlite@1.1.0': resolution: {integrity: sha512-GpGlh/dAIX/nblBYCdT6DfWSLFxav9mxxeELQAfEuw+QZdT9unKxbi5xa02s/s4JS1P7n0PQx2sCABj4FlMRNw==} - '@wirecat/cli-core@0.710.0': - resolution: {integrity: sha512-cZ/eLpANwnL6JyDa/YmmRDCpNEKwbMLjE2OhGKLW8U6itxRCRjF64xYl6C30R9OpqFz/ZvkTLmNuzb+Iqrszwg==} + '@wirecat/cli-core@0.716.0': + resolution: {integrity: sha512-ph/oVDm0HdlZm6pw+zBidHyBPyd0dxAL4LqhItcjG48W8E2H++4kGI/wqr4JqE2S/dW9reYO+mQW8CtEyqv3Bw==} engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: '@napi-rs/canvas': '>=0.1.69 <2' - '@wirecat/cli-base': '>=0.120.0 <1.0.0' + '@wirecat/cli-base': '>=0.125.0 <1.0.0' commander: '>=15' mysql2: ^3.24.6 pg: ^8.23.1 @@ -3340,12 +3340,13 @@ snapshots: dependencies: '@wasm-audio-decoders/common': 9.0.7 - '@wirecat/cli-base@0.124.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5)': + '@wirecat/cli-base@0.125.3(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5)': dependencies: '@valibot/to-json-schema': 1.8.0(valibot@1.5.0(typescript@7.0.2)) cli-table3: 0.6.5 cross-spawn: 7.0.6 valibot: 1.5.0(typescript@7.0.2) + yaml: 2.9.1 optionalDependencies: '@napi-rs/keyring': 2.1.2 commander: 15.0.0 @@ -3360,7 +3361,7 @@ snapshots: '@wirecat/cli-core-sqlite@1.1.0': {} - '@wirecat/cli-core@0.710.0(@wirecat/cli-base@0.124.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': + '@wirecat/cli-core@0.716.0(@wirecat/cli-base@0.125.3(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': dependencies: '@anthropic-ai/sdk': 1.3.0(zod@4.6.7) '@bomb.sh/tab': 0.0.22(commander@15.0.0) @@ -3370,7 +3371,7 @@ snapshots: '@valibot/to-json-schema': 1.8.0(valibot@1.5.0(typescript@7.0.2)) '@wasm-audio-decoders/flac': 0.2.11 '@wasm-audio-decoders/ogg-vorbis': 0.1.20 - '@wirecat/cli-base': 0.124.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) + '@wirecat/cli-base': 0.125.3(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core-onnx': 1.2.0 '@wirecat/cli-core-sqlite': 1.1.0 '@xmldom/xmldom': 0.9.12 diff --git a/scripts/spec-model.ts b/scripts/spec-model.ts index 76dbf89..1523664 100644 --- a/scripts/spec-model.ts +++ b/scripts/spec-model.ts @@ -14,12 +14,6 @@ export const specModel = async ( ): Promise<{ model: ApiModel; notes: string[]; overrides: Record }> => { const { document, omissions, overrides } = wpJsonToOpenApi(readWpJson(join(root, "spec/wordpress")), { namespaces: NAMESPACES, - // The converter marks no field sensitive, so cli-core cannot see that this answer holds a new password. Only a - // whole route can be left out, so its list and delete-all go too. - exclude: { - "/wp/v2/users/(?P(?:[\\d]+|me))/application-passwords": - "its POST creates an application password and answers with it in clear. The CLI signs in through session start", - }, }) return { model: adaptOpenApi(document), notes: omissions, overrides } } diff --git a/skills/wordpress-cli/SKILL.md b/skills/wordpress-cli/SKILL.md index 554cabd..3e08a13 100644 --- a/skills/wordpress-cli/SKILL.md +++ b/skills/wordpress-cli/SKILL.md @@ -46,8 +46,8 @@ unless the task says. `type:page`, `tag:`, `author:`, `published:` with a time, `>=`, or `[a TO b]`. - **Ids are strings.** Pass them back unchanged. - **Missing is not absent.** A sync can be partial and still exit `0`: read `complete` and its gaps. An Author or - Contributor sign-in gets only their own posts and no pages, and only an Administrator lists the users. Say so when - it matters, and do not claim a post is not there. + Contributor sign-in gets only their own posts and no pages. Only an Administrator gets every user with an e-mail; + other roles get the authors with published posts. Say so when it matters, and do not claim a post is not there. - **No view counts.** WordPress keeps none. `posts stats` holds only what the store has. ## Write and publish @@ -61,7 +61,8 @@ wordpress blog posts unpublish 63 # back to a draft wordpress blog posts delete 63 # to the trash ``` -- Writes reach posts only. A page is read, and a write to one stops with `content.write-unsupported`. +- Writes reach posts and pages. `posts create --type page` makes a page, and every other write finds the type by the + id. A page has no tags: `--tags` on a page stops with `content.write-unsupported`. - `posts create` always makes a **draft**. Text is Markdown from `--text-file `, or `--text-file -` for stdin. `--description` is the excerpt. `--tags` takes ids and replaces the post's tags. - **Publish only when the owner asked for it** in this task, for this post. A draft is the default answer to "write a diff --git a/skills/wordpress-cli/references/api.md b/skills/wordpress-cli/references/api.md index 15e979c..51d057e 100644 --- a/skills/wordpress-cli/references/api.md +++ b/skills/wordpress-cli/references/api.md @@ -38,7 +38,7 @@ Effects: `read` changes nothing; `write` changes the service; `destructive` dele | templates | `wordpress skill show api-templates` | 3 | 2 | 1 | 0 | | themes | `wordpress skill show api-themes` | 1 | 1 | 0 | 0 | | types | `wordpress skill show api-types` | 2 | 2 | 0 | 0 | -| users | `wordpress skill show api-users` | 12 | 5 | 4 | 3 | +| users | `wordpress skill show api-users` | 10 | 3 | 3 | 4 | | widget-types | `wordpress skill show api-widget-types` | 4 | 2 | 2 | 0 | | widgets | `wordpress skill show api-widgets` | 5 | 2 | 2 | 1 | | wp\_pattern\_category | `wordpress skill show api-wp-pattern-category` | 5 | 2 | 2 | 1 | diff --git a/skills/wordpress-cli/references/api/api-pages.md b/skills/wordpress-cli/references/api/api-pages.md index 5050c12..96716d8 100644 --- a/skills/wordpress-cli/references/api/api-pages.md +++ b/skills/wordpress-cli/references/api/api-pages.md @@ -53,7 +53,7 @@ - What: deleteWpV2PagesById — destructive (DELETE /wp/v2/pages/{id}) - Call: `DELETE /wp/v2/pages/{id}`, effect: destructive -- Permission keys: `pages.delete`, `pages.delete.force` +- Permission keys: `pages.delete`, `pages.delete.force`, `posts.delete` | Flag | Required | What | |---|---|---| diff --git a/skills/wordpress-cli/references/api/api-users.md b/skills/wordpress-cli/references/api/api-users.md index 6a02cbd..ece020f 100644 --- a/skills/wordpress-cli/references/api/api-users.md +++ b/skills/wordpress-cli/references/api/api-users.md @@ -13,39 +13,15 @@ | `--user-id ` | yes | user\_id | | `--uuid ` | yes | uuid | -## `wordpress api users-application-passwords-get [options]` +## `wordpress api users-application-passwords-delete-all [options]` -- What: getWpV2UsersByUserIdApplicationPasswordsByUuid — read (GET… -- Call: `GET /wp/v2/users/{user_id}/application-passwords/{uuid}`, effect: read - -| Flag | Required | What | -|---|---|---| -| `--user-id ` | yes | user\_id | -| `--uuid ` | yes | uuid | -| `--context ` | no | Scope under which the request is made; determines fields present in response. | - -## `wordpress api users-application-passwords-introspect-list [options]` - -- What: getWpV2UsersByUserIdApplicationPasswordsIntrospect — read (GET… -- Call: `GET /wp/v2/users/{user_id}/application-passwords/introspect`, effect: read - -| Flag | Required | What | -|---|---|---| -| `--user-id ` | yes | user\_id | -| `--context ` | no | Scope under which the request is made; determines fields present in response. | - -## `wordpress api users-application-passwords-update [options]` - -- What: postWpV2UsersByUserIdApplicationPasswordsByUuid — write (POST… -- Call: `POST /wp/v2/users/{user_id}/application-passwords/{uuid}`, effect: write -- Body: `PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest` +- What: deleteWpV2UsersByUserIdApplicationPasswords — destructive (DELETE… +- Call: `DELETE /wp/v2/users/{user_id}/application-passwords`, effect: destructive +- Permission keys: `users.delete` | Flag | Required | What | |---|---|---| | `--user-id ` | yes | user\_id | -| `--uuid ` | yes | uuid | -| `--body ` | no | the request body as JSON; - reads it from stdin | -| `--body-file ` | no | the request body from a JSON file; - is stdin | ## `wordpress api users-create [options]` diff --git a/src/api.test.ts b/src/api.test.ts index 79322f6..a6c2de1 100644 --- a/src/api.test.ts +++ b/src/api.test.ts @@ -62,6 +62,19 @@ it("the spec offers operations", () => { expect(API.manifest.operations.length).toBeGreaterThan(0) }) +// A new application password comes back in clear: cli-base marks the field secret, and the api group never offers +// the call that answers with it, nor the list of them. +it("offers no call that answers with an application password", () => { + const commands = API.manifest.operations.map((one) => one.command) + expect(commands).not.toContain("users-application-passwords-create") + expect(commands).not.toContain("users-application-passwords-list") + expect(commands).not.toContain("users-application-passwords-get") + expect(commands).not.toContain("users-application-passwords-update") + expect(commands).not.toContain("users-application-passwords-introspect-list") + expect(commands).toContain("users-application-passwords-delete") + expect(commands).toContain("users-application-passwords-delete-all") +}) + it("api show describes an operation from the generated files, without calling the service", async () => { const [operation] = API.manifest.operations const service = fake() diff --git a/src/commands/content.ts b/src/commands/content.ts index ab59707..f7926ec 100644 --- a/src/commands/content.ts +++ b/src/commands/content.ts @@ -6,8 +6,8 @@ import { type ContentRun, contentSourceFromManifest, contentWriterFromManifest, + openContentStore, } from "@wirecat/cli-core/content" -import { openCrmStore } from "@wirecat/cli-core/crm/cli" import { Pacer, pacePathFor } from "@wirecat/cli-core/sends" import type { MessageStore } from "@wirecat/cli-core/store" import { Command } from "commander" @@ -51,7 +51,7 @@ const write = serviceApiWriter(API_OPTIONS) const open = async (command: Command, { readOnly }: { readOnly: boolean }): Promise => { const { env, profile, environment } = contextOf(command) - const { store, account } = await openCrmStore({ + const { store, account } = await openContentStore({ app: IDENTITY, env, profile, diff --git a/src/config.ts b/src/config.ts index 117967b..a50704f 100644 --- a/src/config.ts +++ b/src/config.ts @@ -15,13 +15,15 @@ import { IDENTITY } from "./identity.js" */ /** * The content command each raw write does the same as, so `posts.create: deny` also stops `api posts-create` and - * `api pages-create` (WC-PERM-22). Deletes need no entry: the generator gave them `posts.delete` already. + * `api pages-create` (WC-PERM-22). A post's delete needs no entry: the generator gave it `posts.delete` already, and a + * page's only `pages.delete`. */ const COMMAND_KEYS: Readonly> = { "posts-create": "posts.create", "posts-update": "posts.update", "pages-create": "posts.create", "pages-update": "posts.update", + "pages-delete": "posts.delete", } const offered = serviceApiOperations(manifest).offered @@ -39,12 +41,32 @@ export const API = { const api = serviceApiPermissions(API) /** The content commands write through the api group's operations, whose own keys the run checks too. */ -const API_KEYS: Readonly> = { - "posts.create": "api.posts-create", - "posts.update": "api.posts-update", - "posts.publish": "api.posts-update", - "posts.unpublish": "api.posts-update", - "posts.delete": "api.posts-delete", +const NOT_PAGE = "the post is not a page" +const API_KEYS: Readonly> = { + "posts.create": { key: "api.posts-create", when: NOT_PAGE }, + "posts.update": { key: "api.posts-update", when: NOT_PAGE }, + "posts.publish": { key: "api.posts-update", when: NOT_PAGE }, + "posts.unpublish": { key: "api.posts-update", when: NOT_PAGE }, + "posts.delete": { key: "api.posts-delete", when: NOT_PAGE }, +} +const PAGE = "the post is a page" +/** A page goes through the pages routes, whose publish and delete keys are the pages' own. */ +const PAGE_KEYS: Readonly> = { + "posts.create": [{ key: "api.pages-create", when: PAGE }], + "posts.update": [ + { key: "api.pages-update", when: PAGE }, + { key: "pages.publish", when: "the post is a page that is published or scheduled" }, + ], + "posts.publish": [ + { key: "api.pages-update", when: PAGE }, + { key: "pages.publish", when: PAGE }, + ], + "posts.unpublish": [{ key: "api.pages-update", when: PAGE }], + "posts.delete": [ + { key: "api.pages-delete", when: PAGE }, + { key: "pages.delete", when: PAGE }, + { key: "pages.delete.force", when: "the post is a page, with --allow-delete" }, + ], } // cli-core lets every api write but a delete run unasked. These install code, give a user a role, or change what @@ -76,7 +98,8 @@ export const permissions = commandPermissions({ extra: [...new Set([...api.extra, ...CONTENT_WRITE_KEYS])], alsoChecks: (path) => { const own = API_KEYS[path.join(".")] - return [...api.alsoChecks(path), ...contentAlsoChecks(path), ...(own ? [own] : [])] + const page = PAGE_KEYS[path.join(".")] ?? [] + return [...api.alsoChecks(path), ...contentAlsoChecks(path), ...(own ? [own] : []), ...page] }, defaults: { ...api.defaults, ...SITE_WIDE_WRITES, ...CONTENT_WRITE_DEFAULTS }, }) diff --git a/src/content-options.test.ts b/src/content-options.test.ts index cb7c06c..d25f47d 100644 --- a/src/content-options.test.ts +++ b/src/content-options.test.ts @@ -22,7 +22,6 @@ it("every option of the content commands runs over a synced copy", async () => { const ran = (argv: string[]) => runCli(["options", ...argv, "--json"], { keyring, service }) const synced = await ran(["sync", "--rescan", "--max-pages", "50"]) expect(synced.code, synced.err).toBe(0) - // Pages are read but not written: the config's writes name the posts route only. const listed = (await ran(["posts", "list"])).json() as { items: { external_id: string; type: string }[] } const [first, second] = listed.items.filter((one) => one.type === "post").map((one) => one.external_id) as [ string, @@ -129,3 +128,105 @@ it("every option of the content commands runs over a synced copy", async () => { expect(erased).toMatchObject({ key: "posts.delete", level: "ask" }) expect(erased.also?.map(({ key }) => key)).toEqual(expect.arrayContaining(["posts.delete.force", "api.posts-delete"])) }) + +// FIND-2816: a page was read but not written; the config's writes.page names the pages routes. +it("writes a page through the pages routes, and refuses tags on it", async () => { + const keyring = memoryKeyring() + const [login, password] = FAKE_API_TOKEN.split(":") as [string, string] + const started = await runCli(["pages", "session", "start", "--site", FAKE_SITE, "--login", login, "--json"], { + keyring, + service: fakeServiceApi(), + stdin: password, + }) + expect(started.code, started.err).toBe(0) + const service = contentManifestFake(SOURCE, { api: API.manifest }) + const ran = (argv: string[]) => runCli(["pages", ...argv, "--json"], { keyring, service }) + expect((await ran(["sync"])).code).toBe(0) + const page = (id: string) => + service.rows.post?.[1]?.find((one) => String(one.id) === id) as Record | undefined + const ok = async (argv: string[]) => { + const answer = await ran(argv) + expect(answer.code, `${argv.join(" ")}: ${answer.err}`).toBe(0) + return answer.json() as { item: { post: { external_id: string; type: string } } } + } + const made = await ok(["posts", "create", "--type", "page", "--title", "Contact", "--yes"]) + const id = made.item.post.external_id + expect(made.item.post.type).toBe("page") + expect(page(id)).toMatchObject({ status: "draft", title: { raw: "Contact" } }) + await ok(["posts", "update", id, "--title", "Contact us", "--yes"]) + expect(page(id)).toMatchObject({ title: { raw: "Contact us" } }) + await ok(["posts", "publish", id, "--yes"]) + expect(page(id)?.status).toBe("publish") + await ok(["posts", "unpublish", id, "--yes"]) + expect(page(id)?.status).toBe("draft") + await ok(["posts", "publish", id, "--at-time", "2030-01-01T10:00:00Z", "--yes"]) + expect(page(id)).toMatchObject({ status: "future", date_gmt: "2030-01-01T10:00:00Z" }) + const tagged = await ran(["posts", "update", id, "--tags", service.ids("term")[0] as string, "--yes"]) + expect(tagged.err).toContain("content.write-unsupported") + await ok(["posts", "delete", id, "--yes"]) + expect(page(id)?.status).toBe("trash") + await ok(["posts", "delete", id, "--allow-delete", "--yes"]) + expect(page(id)).toBeUndefined() + expect(service.writes).toEqual([ + "postWpV2Pages", + "postWpV2PagesById", + "postWpV2PagesById", + "postWpV2PagesById", + "postWpV2PagesById", + "deleteWpV2PagesById", + "deleteWpV2PagesById", + ]) + expect(service.refusals).toEqual([]) + + type Preview = { item: { permission: { also?: { key: string }[] } } } + const preview = (await ran(["posts", "publish", id, "--dry-run"])).json() as Preview + expect(preview.item.permission.also?.map(({ key }) => key)).toEqual( + expect.arrayContaining(["api.pages-update", "pages.publish"]), + ) +}) + +// FIND-2815: an Editor is refused the users with context=edit; the config's fallback reads them with context=view. +it("lists the authors to a sign-in refused the users list, and names the gap", async () => { + const keyring = memoryKeyring() + const [login, password] = FAKE_API_TOKEN.split(":") as [string, string] + const started = await runCli(["editor", "session", "start", "--site", FAKE_SITE, "--login", login, "--json"], { + keyring, + service: fakeServiceApi(), + stdin: password, + }) + expect(started.code, started.err).toBe(0) + const service = contentManifestFake(SOURCE, { api: API.manifest, denied: ["getWpV2Users"] }) + const ran = (argv: string[]) => runCli(["editor", ...argv, "--json"], { keyring, service }) + const synced = (await ran(["sync"])).json() as { item: { gaps: { kind: string; scope?: string }[] } } + expect(synced.item.gaps).toContainEqual(expect.objectContaining({ kind: "author", scope: "list_users" })) + const users = (await ran(["users", "list"])).json() as { items: { external_id: string }[] } + expect(users.items.map((one) => one.external_id).sort()).toEqual(service.ids("author").sort()) + expect(service.refusals).toEqual([]) +}) + +// An author without published posts is left out of the context=view list and refused when read alone: absence from +// a list is never deletion, so the copy keeps them. +it("keeps an author the fallback list leaves out", async () => { + const keyring = memoryKeyring() + const [login, password] = FAKE_API_TOKEN.split(":") as [string, string] + await runCli(["editor", "session", "start", "--site", FAKE_SITE, "--login", login, "--json"], { + keyring, + service: fakeServiceApi(), + stdin: password, + }) + const admin = contentManifestFake(SOURCE, { api: API.manifest }) + expect((await runCli(["editor", "sync", "--json"], { keyring, service: admin })).code).toBe(0) + const quiet = admin.ids("author")[0] as string + const editor = contentManifestFake(SOURCE, { + api: API.manifest, + denied: ["getWpV2Users"], + hidden: { author: [quiet] }, + }) + const resynced = await runCli(["editor", "sync", "--rescan", "--json"], { keyring, service: editor }) + expect(resynced.code, resynced.err).toBe(0) + const users = (await runCli(["editor", "users", "list", "--json"], { keyring, service: editor })).json() as { + items: { external_id: string; deleted_at?: string | null }[] + } + expect(users.items.find((one) => one.external_id === quiet)).toMatchObject({ external_id: quiet }) + expect(users.items.find((one) => one.external_id === quiet)?.deleted_at ?? null).toBeNull() +}) diff --git a/src/generated/definitions.ts b/src/generated/definitions.ts index 6016e55..eacda51 100644 --- a/src/generated/definitions.ts +++ b/src/generated/definitions.ts @@ -4537,6 +4537,7 @@ export const definitions: Readonly> = { password: { description: "The generated password. Only available after adding an application.", type: "string", + sensitive: true, }, uuid: { description: "The unique identifier for the application password.", @@ -7735,6 +7736,32 @@ export const definitions: Readonly> = { }, required: [], }, + PostWpV2UsersByUserIdApplicationPasswordsRequest: { + type: "object", + properties: { + app_id: { + description: + "A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace.", + type: "union", + of: [ + { + type: "string", + }, + { + type: "string", + enum: [""], + }, + ], + }, + name: { + description: "The name of the application password.", + type: "string", + minLength: 1, + pattern: ".*\\S.*", + }, + }, + required: ["name"], + }, PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest: { type: "object", properties: { diff --git a/src/generated/manifest.ts b/src/generated/manifest.ts index 71856c0..84dd4dd 100644 --- a/src/generated/manifest.ts +++ b/src/generated/manifest.ts @@ -7990,6 +7990,104 @@ export const operations: readonly ManifestOperation[] = [ }, ], }, + { + id: "getWpV2UsersByUserIdApplicationPasswords", + command: "users-application-passwords-list", + binding: { + kind: "http", + method: "GET", + path: "/wp/v2/users/{user_id}/application-passwords", + }, + effect: "read", + tags: ["users"], + parameters: [ + { + name: "user_id", + in: "path", + required: true, + schema: { + type: "string", + pattern: "^(?:(?:[\\d]+|me))$", + }, + }, + { + name: "context", + in: "query", + required: false, + schema: { + description: "Scope under which the request is made; determines fields present in response.", + default: "view", + type: "string", + enum: ["view", "embed", "edit"], + }, + description: "Scope under which the request is made; determines fields present in response.", + }, + ], + response: { + confidence: "contract", + schema: "ApplicationPassword", + sensitive: true, + }, + }, + { + id: "postWpV2UsersByUserIdApplicationPasswords", + command: "users-application-passwords-create", + binding: { + kind: "http", + method: "POST", + path: "/wp/v2/users/{user_id}/application-passwords", + }, + effect: "write", + tags: ["users"], + parameters: [ + { + name: "user_id", + in: "path", + required: true, + schema: { + type: "string", + pattern: "^(?:(?:[\\d]+|me))$", + }, + }, + ], + request: { + required: true, + confidence: "contract", + schema: "PostWpV2UsersByUserIdApplicationPasswordsRequest", + }, + response: { + confidence: "contract", + schema: "ApplicationPassword", + sensitive: true, + }, + }, + { + id: "deleteWpV2UsersByUserIdApplicationPasswords", + command: "users-application-passwords-delete-all", + binding: { + kind: "http", + method: "DELETE", + path: "/wp/v2/users/{user_id}/application-passwords", + }, + effect: "destructive", + tags: ["users"], + permissions: [ + { + key: "users.delete", + }, + ], + parameters: [ + { + name: "user_id", + in: "path", + required: true, + schema: { + type: "string", + pattern: "^(?:(?:[\\d]+|me))$", + }, + }, + ], + }, { id: "getWpV2UsersByUserIdApplicationPasswordsByUuid", command: "users-application-passwords-get", @@ -8035,6 +8133,7 @@ export const operations: readonly ManifestOperation[] = [ response: { confidence: "contract", schema: "ApplicationPassword", + sensitive: true, }, }, { @@ -8075,6 +8174,7 @@ export const operations: readonly ManifestOperation[] = [ response: { confidence: "contract", schema: "ApplicationPassword", + sensitive: true, }, }, { @@ -8149,6 +8249,7 @@ export const operations: readonly ManifestOperation[] = [ response: { confidence: "contract", schema: "ApplicationPassword", + sensitive: true, }, }, { diff --git a/src/generated/schemas.ts b/src/generated/schemas.ts index cf6ea86..5a5ab61 100644 --- a/src/generated/schemas.ts +++ b/src/generated/schemas.ts @@ -2387,6 +2387,14 @@ export const PostWpV2UsersByIdRequest: v.GenericSchema = v.looseObject({ + app_id: v.optional(v.union([v.string(), v.picklist([""])])), + name: v.pipe(v.string(), v.minLength(1), v.regex(/.*\S.*/)), +}) + export const PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest: v.GenericSchema< unknown, T.PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest @@ -2584,6 +2592,7 @@ export const schemas = { GetWpV2UsersResponse, PostWpV2UsersRequest, PostWpV2UsersByIdRequest, + PostWpV2UsersByUserIdApplicationPasswordsRequest, PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest, PostWpV2UsersMeRequest, PostWpV2WidgetTypesByIdEncodeRequest, diff --git a/src/generated/types.ts b/src/generated/types.ts index ff79e0e..e96a759 100644 --- a/src/generated/types.ts +++ b/src/generated/types.ts @@ -3251,6 +3251,13 @@ export type PostWpV2UsersByIdRequest = { username?: string } +export type PostWpV2UsersByUserIdApplicationPasswordsRequest = { + /** A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace. */ + app_id?: string | "" + /** The name of the application password. */ + name: string +} + export type PostWpV2UsersByUserIdApplicationPasswordsByUuidRequest = { /** A UUID provided by the application to uniquely identify it. It is recommended to use an UUID v5 with the URL or DNS namespace. */ app_id?: string | "" @@ -3494,6 +3501,9 @@ export interface Responses { getWpV2UsersById: User postWpV2UsersById: User deleteWpV2UsersById: unknown + getWpV2UsersByUserIdApplicationPasswords: ApplicationPassword + postWpV2UsersByUserIdApplicationPasswords: ApplicationPassword + deleteWpV2UsersByUserIdApplicationPasswords: unknown getWpV2UsersByUserIdApplicationPasswordsByUuid: ApplicationPassword postWpV2UsersByUserIdApplicationPasswordsByUuid: ApplicationPassword deleteWpV2UsersByUserIdApplicationPasswordsByUuid: unknown diff --git a/src/generated/wirecat-config.ts b/src/generated/wirecat-config.ts index 8b6f430..a33b788 100644 --- a/src/generated/wirecat-config.ts +++ b/src/generated/wirecat-config.ts @@ -45,6 +45,14 @@ export const SOURCE: Readonly> & { optional: { message: "only an administrator lists the users", scope: "list_users", + fallback: { + query: { + context: "view", + }, + message: + "only an administrator lists every user and their e-mail: these are the authors with published posts", + scope: "list_users", + }, }, }, ], @@ -347,5 +355,40 @@ export const SOURCE: Readonly> & { unpublish: { status: "draft", }, + page: { + create: { + operation: "postWpV2Pages", + body: { + status: "draft", + }, + }, + update: { + operation: "postWpV2PagesById", + path: { + id: "{id}", + }, + }, + trash: { + operation: "deleteWpV2PagesById", + path: { + id: "{id}", + }, + }, + delete: { + operation: "deleteWpV2PagesById", + path: { + id: "{id}", + }, + query: { + force: true, + }, + }, + fields: { + title: "title.raw", + body: "content.raw", + excerpt: "excerpt.raw", + slug: "slug", + }, + }, }, } diff --git a/wirecat.config.ts b/wirecat.config.ts index 03c6b09..6f1c261 100644 --- a/wirecat.config.ts +++ b/wirecat.config.ts @@ -89,7 +89,18 @@ export default defineCli({ // biome-ignore lint/security/noSecrets: an operation id, not a secret get: { operation: "getWpV2UsersById", path: { id: "{id}" }, query: { context: "edit" } }, map: { externalId: "id", name: "name", email: "email", slug: "slug" }, - optional: { message: "only an administrator lists the users", scope: "list_users" }, + optional: { + message: "only an administrator lists the users", + scope: "list_users", + // WordPress refuses context=edit without list_users, and lists in context=view the authors with published + // posts, without their e-mail (checked on 6.9.4 as an Editor and an Author). + fallback: { + query: { context: "view" }, + message: + "only an administrator lists every user and their e-mail: these are the authors with published posts", + scope: "list_users", + }, + }, }, ], // A tag's or category's name and slug are public. An Author or Contributor may not edit terms: no context=edit. @@ -123,6 +134,15 @@ export default defineCli({ publish: { status: "publish" }, schedule: { status: "future", date_gmt: "{at}" }, unpublish: { status: "draft" }, + // A page has no tags or categories. + page: { + create: { operation: "postWpV2Pages", body: { status: "draft" } }, + // biome-ignore lint/security/noSecrets: an operation id, not a secret + update: { operation: "postWpV2PagesById", path: { id: "{id}" } }, + trash: { operation: "deleteWpV2PagesById", path: { id: "{id}" } }, + delete: { operation: "deleteWpV2PagesById", path: { id: "{id}" }, query: { force: true } }, + fields: { title: "title.raw", body: "content.raw", excerpt: "excerpt.raw", slug: "slug" }, + }, }, }, })