(account: OnePasswordAccount)
| 570 | const serviceFor: ServiceForAccount = (account) => serviceForAuth(account.auth); |
| 571 | |
| 572 | const accountStatus = (account: OnePasswordAccount): Effect.Effect<AccountStatus, never> => |
| 573 | serviceFor(account).pipe( |
| 574 | Effect.flatMap((svc) => svc.listVaults()), |
| 575 | Effect.map((live) => { |
| 576 | const liveById = new Map(live.map((v) => [v.id, v.title])); |
| 577 | const missing = account.vaults.filter((vault) => !liveById.has(vault.id)); |
| 578 | return AccountStatus.make({ |
| 579 | id: account.id, |
| 580 | name: account.name, |
| 581 | connected: true, |
| 582 | vaultNames: account.vaults.map((vault) => liveById.get(vault.id) ?? vault.name), |
| 583 | ...(missing.length > 0 |
| 584 | ? { |
| 585 | error: `Configured vaults not found: ${missing |
| 586 | .map((vault) => vault.name) |
| 587 | .join(", ")}`, |
| 588 | } |
| 589 | : {}), |
| 590 | }); |
| 591 | }), |
| 592 | Effect.catchTag("OnePasswordError", (error) => |
| 593 | Effect.succeed( |
| 594 | AccountStatus.make({ |
| 595 | id: account.id, |
| 596 | name: account.name, |
| 597 | connected: false, |
| 598 | // oxlint-disable-next-line executor/no-unknown-error-message -- boundary: OnePasswordError carries a typed `message` |
| 599 | error: error.message, |
| 600 | }), |
| 601 | ), |
| 602 | ), |
| 603 | ); |
| 604 | |
| 605 | return { |
| 606 | /** Add or replace one account. A payload without an id creates a new |
nothing calls this directly
no test coverage detected