Skip to content

Commit 311d679

Browse files
authored
refactor: move the admin view types into piquel-common (#226)
The views of administration (what the admin dashboard shows, the CLI prints as JSON and the database crate decodes into) had a crate of their own, `piquel-admin-api`, holding one file. They are shared types, and `piquel-common` is the one home for shared types, so they move there and the workspace has one fewer crate. **What moved.** `crates/admin-api/src/lib.rs` is now `crates/common/src/admin.rs`, reached as `piquel_common::admin::X`. Every item keeps its visibility and docs, including the `Identity` and `Passkey` re-exports. No behaviour changes: only import paths, manifests and docs differ. **Feature gating.** The module sits behind a new `admin` feature, which enables the optional `serde_json` it needs. Auth, `crates/database` and `crates/ui` enable it. The Rust SDK (`crates/auth-sdk`) still builds `piquel-common` with no features, so it compiles nothing new. No view type implements `sqlx` traits (the database crate builds them with `query_as!`), so nothing new is needed under `sqlx`, and the offline query cache is unchanged. **`REGISTRATION_PATH`.** It is already gone: `git grep REGISTRATION_PATH` finds nothing on `main` (18259b7), so there is nothing to remove from `admin/service.rs`. **Docs.** The `crates/admin-api` row is gone from `docs/architecture/monorepo.md`, and the `crates/common` row describes the `admin` feature instead. `surfaces.md`, `database-crate.md`, the README and two code comments now name `piquel_common::admin`. **Checks run:** - `cargo fmt --all --check`: passes - `just lint` (clippy pedantic, `-D warnings`, plus ESLint): passes - `just doc` (`-D warnings`): passes - `just db test`: 258 of 258 tests pass, and the sqlx query cache check passes with no `.sqlx` changes - `cargo check -p piquel-auth`: passes; `cargo tree` shows the SDK pulls in only `piquel-common`'s default features - `cargo clippy -p piquel-common --no-default-features --features admin`: passes Reviewed lightly, as a change of paths only, by Claude Opus 5.5 on xhigh. Verdict: approved. It checked that: - only the module header changed in the move, at 98% similarity; - the SDK resolves piquel-common with default features only; - no reference to `admin-api` is left. Its two doc-wrap nits are applied. > [!NOTE] > Written by Claude Opus 5.5 in Claude Code and reviewed by Claude Opus 5.5 (via T3 Code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary This change consolidates the admin view types in `piquel-common` and removes the standalone `piquel-admin-api` crate. The types are available through `piquel_common::admin` when the new `admin` feature is enabled. ## Changes by scope - **Common crate:** Added the feature-gated `admin` module. It contains the administration views and request types, including `User`, `Client`, `Event`, and their search and pagination types. It re-exports `Identity` and `Passkey` from `protocol::api`. - **Feature and dependency wiring:** Added the `admin` feature to `piquel-common`, backed by optional `serde_json`. Enabled it for the auth service, database crate, and UI crate. The Rust SDK continues to use `piquel-common` without features. - **Crate removal and imports:** Removed `crates/admin-api` from the workspace and deleted its manifest. Updated auth, database, and UI imports to use `piquel_common::admin`. - **Documentation:** Updated the README and architecture docs to describe the new location of the admin views and the feature boundary. Updated related code comments to refer to `piquel_common::admin`. The change relocates the existing view types; it does not report changes to their behavior. The author reports that `REGISTRATION_PATH` was already absent from `main` at `18259b74`, and that the SQLx offline query cache is unchanged. ## Reported checks The author reports successful runs of `cargo fmt --all --check`, `just lint`, `just doc`, `just db test` (258 of 258 tests, with the SQLx query cache check passing), `cargo check -p piquel-auth`, and `cargo clippy -p piquel-common --no-default-features --features admin`. The author also reports that `cargo tree` confirms the SDK uses only `piquel-common`’s default features. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent ddd021b commit 311d679

32 files changed

Lines changed: 68 additions & 92 deletions

File tree

‎Cargo.lock‎

Lines changed: 0 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
resolver = "3"
33
members = [
44
"apps/auth-service",
5-
"crates/admin-api",
65
"crates/auth-sdk",
76
"crates/common",
87
"crates/crypto",
@@ -32,7 +31,6 @@ piquel-crypto = { path = "crates/crypto" }
3231
piquel-repository = { path = "crates/database" }
3332
piquel-telemetry = { path = "crates/telemetry" }
3433
piquel-auth = { path = "crates/auth-sdk" }
35-
piquel-admin-api = { path = "crates/admin-api" }
3634
piquel-ui = { path = "crates/ui" }
3735

3836
# External crates

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ just auth account alice emails remove <email-id> --reason "Asked by email"
222222
- Accounts are named by handle, ID or a verified email of an active account.
223223
- `--output json` prints the views the dashboard shows for `user search`
224224
(`UserPage`), `user show` (`UserDetail`), `audit` (`EventPage`), `client list`,
225-
`invite list` and `admin list`, as defined in `crates/admin-api`.
225+
`invite list` and `admin list`, as defined in `piquel_common::admin`.
226226
- `user disable`, `user recover`, `user undo-recovery`, `session revoke-all`,
227227
`admin revoke`, `client
228228
disable|suspend|delete`, and `account … passkeys revoke`, `identities unlink` and

‎apps/auth-service/Cargo.toml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ license.workspace = true
66
repository.workspace = true
77

88
[dependencies]
9-
piquel-admin-api.workspace = true
10-
piquel-common = { workspace = true, features = ["config", "email", "events"] }
9+
piquel-common = { workspace = true, features = ["admin", "config", "email", "events"] }
1110
piquel-crypto.workspace = true
1211
piquel-repository.workspace = true
1312
piquel-telemetry.workspace = true

‎apps/auth-service/src/admin/service.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use crate::{
1010
routes,
1111
};
1212
use chrono::Utc;
13-
use piquel_admin_api::{
14-
Administrator, Client, CreatedInvitation, Email, Event, EventPage, EventSearch, Invitation,
15-
UserDetail, UserPage,
16-
};
1713
use piquel_common::{
1814
AccountStatus, ClientId, DeliveryId, Handle, Personal, RecoveryId, SessionId, TokenId, UserId,
15+
admin::{
16+
Administrator, Client, CreatedInvitation, Email, Event, EventPage, EventSearch, Invitation,
17+
UserDetail, UserPage,
18+
},
1919
clients::{ClientField, ClientOwner, ClientRegistration},
2020
config::Origin,
2121
email::NormalizedEmail,

‎apps/auth-service/src/admin/tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ use crate::recovery::RecoveryLinks;
77
use crate::security::{CONFIRMATION_MAX_AGE, RequestContext, Session};
88
use crate::tests::until_blocked;
99
use chrono::{Duration, Utc};
10-
use piquel_admin_api::EventSearch;
1110
use piquel_common::{
1211
AccountStatus, AuthenticationMethod, DeliveryId, Handle, HandleError, Personal, SessionId,
1312
TokenId, UserId,
13+
admin::EventSearch,
1414
config::Origin,
1515
events::{DomainEvent, RevocationReason},
1616
protocol::{claims::Acr, step_up::StepUpRequirement},

‎apps/auth-service/src/cli/audit.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
use super::{CliError, Console, Output};
44
use crate::UserRef;
55
use clap::Args;
6-
use piquel_admin_api::{EventPage, EventSearch};
7-
use piquel_common::{EventId, events::Actor};
6+
use piquel_common::{
7+
EventId,
8+
admin::{EventPage, EventSearch},
9+
events::Actor,
10+
};
811

912
/// Page through recorded events, newest first, 100 at a time.
1013
#[derive(Args)]

‎apps/auth-service/src/cli/console.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub(super) enum OutputFormat {
4949
/// Tab-separated lines for people.
5050
Table,
5151
/// The view the admin dashboard shows, as JSON, for scripts: its shape is
52-
/// `piquel-admin-api`'s.
52+
/// `piquel_common::admin`'s.
5353
Json,
5454
}
5555

‎apps/auth-service/src/cli/user.rs‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ use super::{CliError, Confirm, Console, Output};
44
use crate::{AdminError, AuthConfig, Reason, UserRef, recovery::Revoke};
55
use chrono::{DateTime, Utc};
66
use clap::Subcommand;
7-
use piquel_admin_api::{UserDetail, UserPage};
8-
use piquel_common::{PasskeyId, UserId};
7+
use piquel_common::{
8+
PasskeyId, UserId,
9+
admin::{UserDetail, UserPage},
10+
};
911
use piquel_repository::{RecentRecovery, RecoveryState};
1012

1113
/// Accounts, in any status.

‎apps/auth-service/src/web/admin/administrators.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Who administers Piquel: the list, granting rights and revoking them.
22
33
use super::AdminApplication as App;
4-
use piquel_admin_api::GrantAdministrator;
5-
use piquel_common::UserId;
4+
use piquel_common::{UserId, admin::GrantAdministrator};
65
use piquel_ui::AdministratorRow;
76
use serde::de::IgnoredAny;
87
use topcoat::{

0 commit comments

Comments
 (0)