Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions changes/refactor-shared-account-remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
### Changed — may break callers

- **`account remove --delete-data` refuses with `account-remove.account-shared`, detail `account`.** It was
`account-remove.portal-shared` with detail `portal`. The command is now cli-core's shared CRM one (`@wirecat/cli-core`
0.722.0). It still refuses while another profile here reads the same portal, even one whose session ended. Under
`--dry-run` it now warns and lists what would go, where it used to fail.
- **`account remove --delete-data` refuses when b24 cannot tell which portal another profile holds**
(`account-remove.account-unknown`, detail `profile`): a profile whose saved webhook is unreadable and that
`session start` never remembered. `--keep-data` still removes.
- **`session start` refuses a second sign-in to the same portal and user with the shared words.** The reason stays
`session.duplicate`; its detail `portal` is now `account`, and the message says to end the other profile with
`b24 <profile> session end`. A webhook sign-in to a profile named `files` or `foreign-contacts`, folders every
portal shares, is refused with `profile.reserved`.
1 change: 1 addition & 0 deletions contracts/help.snap
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Works with:
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
wordpress WordPress posts and pages, searchable with your other WireCat data
linear Linear issues and projects, searchable with your other WireCat data

Start here: b24 work session start (any profile name works)
Next: b24 commands every command, by section
Expand Down
26 changes: 13 additions & 13 deletions contracts/wirecat.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,19 +71,6 @@
"local": "read"
}
},
{
"path": [
"account",
"remove"
],
"summary": "sign this profile out and forget it, keeping or deleting its data",
"effects": {
"remote": "none",
"local": "write"
},
"permission": "account.remove",
"entity": "account_removal"
},
{
"path": [
"sync"
Expand Down Expand Up @@ -721,6 +708,19 @@
"permission": "search.all",
"entity": "hit"
},
{
"path": [
"account",
"remove"
],
"summary": "sign this profile out and forget it, keeping or deleting its data",
"effects": {
"remote": "none",
"local": "write"
},
"permission": "account.remove",
"entity": "account_removal"
},
{
"path": [
"products",
Expand Down
48 changes: 24 additions & 24 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,30 +118,6 @@ b24 session list

**Example:** `b24 session list`, `b24 session list --json`

## `b24 account`

this profile on this computer

### `b24 account remove`

sign the profile out, then forget it on this computer: its settings, its saved sign-in and its files; --keep-data leaves its messages in the store, where search still finds them, --delete-data deletes them; asks first, or --yes

**Changes something on this computer only.**

```sh
b24 account remove [options]
```

| Option | What it does |
|---|---|
| `--keep-data` | leave what the store holds of this account, still searchable. |
| `--delete-data` | delete what the store and the tool's own files hold of this account. |
| `--dry-run` | list what it would remove and keep, and change nothing. |

**Returns:** account removal — profile, data, dry_run, account, revoked, config_file, removed, kept; every field: b24 commands info account remove

**Example:** `b24 personal account remove --keep-data --dry-run`, `b24 personal account remove --delete-data --yes`

## `b24 sync`

bring the CRM's copy in the local store up to date: pipelines, companies, contacts, deals and leads that changed since the last sync, or everything with --rescan; a run stops before its deadline or --max-pages and the next one goes on from there
Expand Down Expand Up @@ -1146,6 +1122,30 @@ b24 search all <query> [options]

**Example:** `b24 work search all Example LLC`, `b24 work search all website --only crm --json`

## `b24 account`

this profile on this computer

### `b24 account remove`

sign the profile out, then forget it on this computer: its settings, its saved sign-in and its files; --keep-data leaves its messages in the store, where search still finds them, --delete-data deletes them; asks first, or --yes

**Changes something on this computer only.**

```sh
b24 account remove [options]
```

| Option | What it does |
|---|---|
| `--keep-data` | leave what the store holds of this account, still searchable. |
| `--delete-data` | delete what the store and the tool's own files hold of this account. |
| `--dry-run` | list what it would remove and keep, and change nothing. |

**Returns:** account removal — profile, data, dry_run, account, revoked, config_file, removed, kept; every field: b24 commands info account remove

**Example:** `b24 personal account remove --keep-data --dry-run`, `b24 personal account remove --delete-data --yes`

## `b24 products`

read the portal's product catalog
Expand Down
8 changes: 4 additions & 4 deletions docs/dev/test-matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see
| `session status` | `--check` | ✅ | |
| `session end` | | ✅ | |
| `session list` | | ✅ | |
| `account remove` | | ✅ | |
| `account remove` | `--keep-data` | ✅ | |
| `account remove` | `--delete-data` | ✅ | |
| `account remove` | `--dry-run` | ✅ | |
| `sync` | | ✅ | |
| `sync` | `--rescan` | ✅ | |
| `sync` | `--max-pages` | ✅ | |
Expand Down Expand Up @@ -176,6 +172,10 @@ Measured from the test run (`coverage/argv.jsonl`), not searched for — see
| `search all` | `--page` | ✅ | |
| `search all` | `--exact` | ✅ | |
| `search all` | `--timezone` | ✅ | |
| `account remove` | | ✅ | |
| `account remove` | `--keep-data` | ✅ | |
| `account remove` | `--delete-data` | ✅ | |
| `account remove` | `--dry-run` | ✅ | |
| `products list` | | ✅ | |
| `products list` | `--limit` | ✅ | |
| `products list` | `--page` | ✅ | |
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"docs:spell": "cspell lint --config cspell.json --no-progress --no-summary README.md SECURITY.md CHANGELOG.md AGENTS.md CLAUDE.md 'docs/*.md' 'skills/**/*.md'"
},
"dependencies": {
"@wirecat/cli-core": "0.710.0",
"@wirecat/cli-core": "0.722.0",
"commander": "15.0.0",
"valibot": "1.5.0"
},
Expand All @@ -71,7 +71,7 @@
"@cspell/dict-ru_ru": "2.3.4",
"@types/node": "22.20.5",
"@vitest/coverage-v8": "5.0.5",
"@wirecat/cli-base": "0.124.0",
"@wirecat/cli-base": "0.127.0",
"@wirecat/cli-testing": "0.7.0",
"cspell": "10.4.0",
"esbuild": "0.28.2",
Expand Down
25 changes: 13 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 45 additions & 1 deletion src/commands/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,57 @@ describe("account remove", () => {
)
const refused = await b24(["work", "account", "remove", "--delete-data", "--yes", "--json"], { keyring })
expect(refused.code).not.toBe(0)
expect(refused.json().error).toMatchObject({ code: "conflict", reason: "account-remove.portal-shared" })
expect(refused.json().error).toMatchObject({
code: "conflict",
reason: "account-remove.account-shared",
details: { profiles: ["home"], account: "example.bitrix24.test" },
})
expect(keyring.get("bitrix24-cli", "token:work")).toBe(FAKE_HOOK)
const kept = await b24(["work", "account", "remove", "--keep-data", "--yes", "--json"], { keyring })
expect(kept.code).toBe(0)
expect(keyring.get("bitrix24-cli", "token:home")).toBe(COLLEAGUE_HOOK)
})

it("--delete-data --dry-run warns that another profile reads the same portal, and changes nothing", async () => {
const { keyring } = await syncedWork()
const colleague = fakePortal({ "user.current": ok({ ID: "9" }), "user.admin": ok(false), "department.get": ok([]) })
expect((await b24(["home", "session", "start"], { keyring, portal: colleague, stdin: COLLEAGUE_HOOK })).code).toBe(
0,
)
const ran = await b24(["work", "account", "remove", "--delete-data", "--dry-run", "--json"], { keyring })
expect(ran.code).toBe(0)
expect(ran.err).toContain("without --dry-run this refuses: home also reads Bitrix24 account example.bitrix24.test")
expect(await storedAccounts()).toContain("bitrix24:example.bitrix24.test")
})

it("--delete-data still refuses when the other profile's webhook is unreadable, from what session start kept", async () => {
const { keyring } = await syncedWork()
const colleague = fakePortal({ "user.current": ok({ ID: "9" }), "user.admin": ok(false), "department.get": ok([]) })
expect((await b24(["home", "session", "start"], { keyring, portal: colleague, stdin: COLLEAGUE_HOOK })).code).toBe(
0,
)
keyring.set("bitrix24-cli", "token:home", "not a webhook")
const refused = await b24(["work", "account", "remove", "--delete-data", "--yes", "--json"], { keyring })
expect(refused.json().error).toMatchObject({ code: "conflict", reason: "account-remove.account-shared" })
expect(await storedAccounts()).toContain("bitrix24:example.bitrix24.test")
})

it("--delete-data refuses when nothing tells which portal another profile holds", async () => {
const { keyring } = await syncedWork()
const accounts = join(process.env.B24_STATE_DIR ?? "", "accounts")
writeFileSync(join(accounts, "home.json"), `${JSON.stringify({ account: "unknown" })}\n`)
keyring.set("bitrix24-cli", "token:home", "not a webhook")
const refused = await b24(["work", "account", "remove", "--delete-data", "--yes", "--json"], { keyring })
expect(refused.json().error).toMatchObject({
code: "conflict",
reason: "account-remove.account-unknown",
details: { profile: "home" },
})
expect(keyring.get("bitrix24-cli", "token:work")).toBe(FAKE_HOOK)
expect(await storedAccounts()).toContain("bitrix24:example.bitrix24.test")
expect((await b24(["work", "account", "remove", "--keep-data", "--yes", "--json"], { keyring })).code).toBe(0)
})

it("asks what happens to the data, and refuses without --yes when it cannot ask", async () => {
const { keyring } = await syncedWork()
const unchosen = await b24(["work", "account", "remove", "--json"], { keyring })
Expand Down
Loading
Loading