Vận hành Tenant qua ops CLI — không SQL thủ công. Mọi thao tác có audit. Không chứa secret.
Nguồn sự thật:src/ops/cli.ts. Vòng đời:../platform/TENANT-LIFECYCLE.md.
Partner ops (Beta-4):PARTNER-OPERATIONS.md.
cd packages/platform-infrastructure
npm run ops -- <command> [flags] [--json]
Lệnh terminal (archive-tenant) bắt buộc--confirm; thiếu → exit 2.
| Việc | Lệnh |
|---|---|
Provision Tenant (→ provisioned) + gắn Partner | provision-tenant --partner <partnerId> --tenant <tenantId> [--name n] |
Kích hoạt (provisioned → active) | activate-tenant --tenant <tenantId> |
| Provision inventory mẫu | seed-inventory --tenant <tenantId> |
Suspend (active → suspended, thuận nghịch) | suspend-tenant --tenant <tenantId> [--reason r] |
Re-activate (suspended → active) | reactivate-tenant --tenant <tenantId> |
| Archive (terminal) | archive-tenant --tenant <tenantId> [--reason r] --confirm |
| Kiểm tra tình trạng Tenant | tenant-health --tenant <tenantId> |
| Xem lịch sử audit Tenant | show-audit --tenant <tenantId> |
# Cần Partner đã tồn tại (Beta-4): create-partner + activate-partner
npm run ops -- provision-tenant --partner <partnerId> --tenant t_acme --name "Acme" --json
# → { partner, tenantId, status:"provisioned" }
Tenant ở provisioned — booking chưa chạy.
npm run ops -- seed-inventory --tenant t_acme --json
# nạp listing/unit/price/availability mẫu ⇒ Availability trả dữ liệu thật
npm run ops -- activate-tenant --tenant t_acme --json # provisioned → active
Từ đây booking chạy (với Partner active + API key hợp lệ).
npm run ops -- suspend-tenant --tenant t_acme --reason nonpayment
Hiệu lực tức thì: availability/booking → 403 TENANT_INACTIVE. Inventory/key/reservation KHÔNG bị xoá (thuận nghịch).
npm run ops -- reactivate-tenant --tenant t_acme
Booking chạy lại — cùng inventory + cùng API key, không cấp lại.
npm run ops -- archive-tenant --tenant t_acme --reason offboarding --confirm
Terminal: booking bị chặn vĩnh viễn (403). Không hoàn tác.
npm run ops -- tenant-health --tenant t_acme --json
# → { tenantId, status, partnerId, listings, units, reservations }
Chỉ đọc, không secret. Dùng để xác nhận trạng thái + đếm inventory/booking trước/sau thao tác.
TENANT_INACTIVE). Phân biệt để chẩn đoán đúng lớp.tenant-health/show-audit chỉ metadata an toàn.tenants (bảng RLS) hợp lệ ngoài request path.