M2a: server workspace, kvitt-domain, skeleton routes, OpenAPI match, Dockerfile
Cargo workspace (kvitt-domain, kvitt-server, kvitt-import), Rust 1.99.1 pinned. kvitt-domain passes every Rust vector and adds next_occurrence_date (D-015). kvitt-server: config, SQLite pool (WAL, §8.9 pragmas), migration 0001 identical to the contract schema, error type for all 25 codes, auth extractor and protocol layer, all 33 routes (E-1/E-2 implemented, the rest 501), utoipa document equal to contracts/openapi.yaml, seams for M3/M4/M9, serve/migrate/healthcheck. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
//! Invites: E-3 accept (all three kinds), E-12 create, E-13 list, E-14 cancel (SPEC §8.3, FR-2).
|
||||
//!
|
||||
//! Registered and annotated by M2a; M3 owns this file and implements the handlers (until then 501
|
||||
//! `not_implemented`).
|
||||
|
||||
use crate::api::{IdPath, not_implemented};
|
||||
use crate::auth::AdminDevice;
|
||||
use crate::error::AppError;
|
||||
use crate::openapi::responses::{BadRequest, Conflict, Forbidden, NotFound, Unprocessable};
|
||||
use crate::wire::{
|
||||
AcceptInviteRequest, AcceptInviteResponse, CreateInviteRequest, Invite, InviteList, UuidSchema,
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/invites/accept",
|
||||
operation_id = "acceptInvite",
|
||||
summary = "E-3 Pair a device with an invite code (all three invite kinds)",
|
||||
security(()),
|
||||
request_body(content = AcceptInviteRequest, content_type = "application/json; charset=utf-8"),
|
||||
responses(
|
||||
(status = 200, description = "Paired. The token is shown only here.", body = AcceptInviteResponse, content_type = "application/json; charset=utf-8"),
|
||||
(status = 400, response = BadRequest),
|
||||
(status = 409, response = Conflict),
|
||||
(status = 422, response = Unprocessable),
|
||||
)
|
||||
)]
|
||||
pub async fn accept_invite() -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/invites",
|
||||
operation_id = "createInvite",
|
||||
summary = "E-12 Create a partner or device invite (admin)",
|
||||
description = "Creating a `partner` invite cancels any pending one (AC-2.1).",
|
||||
request_body(content = CreateInviteRequest, content_type = "application/json; charset=utf-8"),
|
||||
responses(
|
||||
(status = 201, description = "The invite with `code` (12 characters, no hyphens) and `link` (`<public_url>/i/<code>`).", body = Invite, content_type = "application/json; charset=utf-8"),
|
||||
(status = 400, response = BadRequest),
|
||||
(status = 403, response = Forbidden),
|
||||
(status = 404, response = NotFound),
|
||||
(status = 409, response = Conflict),
|
||||
)
|
||||
)]
|
||||
pub async fn create_invite(_admin: AdminDevice) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/invites",
|
||||
operation_id = "listInvites",
|
||||
summary = "E-13 List pending invites (admin)",
|
||||
responses(
|
||||
(status = 200, description = "Pending invites only (not accepted, not cancelled, not expired), `code` and `link` null.", body = InviteList, content_type = "application/json; charset=utf-8"),
|
||||
(status = 403, response = Forbidden),
|
||||
)
|
||||
)]
|
||||
pub async fn list_invites(_admin: AdminDevice) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/invites/{invite_id}",
|
||||
operation_id = "cancelInvite",
|
||||
summary = "E-14 Cancel an invite (admin)",
|
||||
description = "Idempotent for an already cancelled invite.",
|
||||
params(
|
||||
("invite_id" = UuidSchema, Path, description = "Not a UUID is 404 `not_found`."),
|
||||
),
|
||||
responses(
|
||||
(status = 204, description = "Cancelled."),
|
||||
(status = 403, response = Forbidden),
|
||||
(status = 404, response = NotFound),
|
||||
)
|
||||
)]
|
||||
pub async fn cancel_invite(_admin: AdminDevice, IdPath(_invite_id): IdPath) -> AppError {
|
||||
not_implemented()
|
||||
}
|
||||
Reference in New Issue
Block a user