feat(print): cloud↔local print-agent foundation (hub, pairing, registry)
CI/CD / CI · API (dotnet build + test) (push) Successful in 43s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 29s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m9s
CI/CD / CI · Admin Web (tsc) (push) Successful in 37s
CI/CD / CI · Website (tsc) (push) Successful in 46s
CI/CD / CI · Koja (tsc) (push) Successful in 49s
CI/CD / Deploy · all services (push) Has been cancelled
CI/CD / CI · API (dotnet build + test) (push) Successful in 43s
CI/CD / CI · Admin API (dotnet build) (push) Successful in 29s
CI/CD / CI · Dashboard (tsc) (push) Successful in 1m9s
CI/CD / CI · Admin Web (tsc) (push) Successful in 37s
CI/CD / CI · Website (tsc) (push) Successful in 46s
CI/CD / CI · Koja (tsc) (push) Successful in 49s
CI/CD / Deploy · all services (push) Has been cancelled
First phase of auto-discovered printing for cloud-hosted cafés whose printers are
on the local network (the cloud can't reach a LAN/USB printer directly). Adds:
- PrintAgent + PrintDevice entities (+ additive migration) — a per-café local
bridge and the printers it reports.
- PrintAgentHub (/hubs/print-agent): agents connect outbound, authenticated by a
token in access_token (not the user JWT); ReportPrinters upserts devices,
PrintJob is pushed to the agent, JobResult/Heartbeat come back.
- PrintAgentRegistry (singleton): tracks connected agents and dispatches a job to
one, awaiting its ack with a timeout.
- Pairing: POST /cafes/{id}/print-agents/pairing-code (ManagePrintSettings) issues
a short one-time code; anonymous POST /print-agent/claim redeems it for a
long-lived token (only its SHA-256 hash is stored). List + revoke endpoints,
online status from the registry.
Inert until Phase 2 routes jobs through it and the agent app (Phase 3) connects.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
namespace Meezi.Core.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// A local print bridge installed on a café PC. It connects outbound to the cloud
|
||||
/// over SignalR (authenticated by its token), reports the printers it can see, and
|
||||
/// relays print jobs to them — so the cloud can reach LAN/USB printers it could
|
||||
/// never connect to directly.
|
||||
/// </summary>
|
||||
public class PrintAgent : TenantEntity
|
||||
{
|
||||
public string? BranchId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Short one-time code shown in the dashboard; the agent exchanges it for a token.</summary>
|
||||
public string? PairingCode { get; set; }
|
||||
public DateTime? PairingCodeExpiresAt { get; set; }
|
||||
|
||||
/// <summary>SHA-256 (hex) of the long-lived agent token. Null until the agent is paired.</summary>
|
||||
public string? TokenHash { get; set; }
|
||||
|
||||
/// <summary>Last time the agent connected or sent a heartbeat (UTC).</summary>
|
||||
public DateTime? LastSeenAt { get; set; }
|
||||
|
||||
public bool Revoked { get; set; }
|
||||
|
||||
public Cafe Cafe { get; set; } = null!;
|
||||
public Branch? Branch { get; set; }
|
||||
public ICollection<PrintDevice> Devices { get; set; } = [];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Meezi.Core.Entities;
|
||||
|
||||
/// <summary>A printer discovered and reported by a <see cref="PrintAgent"/>.</summary>
|
||||
public class PrintDevice : TenantEntity
|
||||
{
|
||||
public string AgentId { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>Stable identifier the agent uses to print (OS printer name, or "ip:port").</summary>
|
||||
public string SystemName { get; set; } = string.Empty;
|
||||
public string DisplayName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>"usb" | "network" | "other".</summary>
|
||||
public string Kind { get; set; } = "other";
|
||||
|
||||
public DateTime LastSeenAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
public PrintAgent Agent { get; set; } = null!;
|
||||
}
|
||||
Reference in New Issue
Block a user