Core platform · ws_suns · 07/7/2026

sdk — Module SDK & CLI CORE

Bộ phát triển module: defineApp (backend models/associate/mountRoutes · frontend render/nav), manifest schema + validator, CLI dev / build / publish / deploy / create / seed, Module Federation dev-mode tự đăng ký với host.

Đánh giá: ✅ DX tốt · ⚠ thiếu template create · Chi tiết khuyến nghị ở mục 3 — tham chiếu hệ thống phổ biến.
1

Thành phần chính

Thành phầnVai trò
@opengate/module-sdk/node · /reactdefineApp 2 phía · useHostApi (hasPermission, navigate, getCurrentUser)
manifest schema + testValidate key/version/permissions/engines — có test (manifest-schema.test.js)
CLIdev (env riêng, migrations tự chạy, federation) · build (.ogapp) · publish (registry) · deploy (host trực tiếp)
@opengate/ui · typesUI kit dùng chung (AppLayout…) + type defs
2

Hiện trạng (đọc từ code)

  • DX vòng lặp dev → build → publish → install trọn vẹn, có tài liệu HUONG_DAN.md chi tiết
  • Convention chặt: tableName prefix key, permission 4 cấp, migration idempotent — checklist trước publish rõ ràng
  • opengate-module create hỏng: template opengate-app-base chưa tồn tại (ghi chú 06/10) — dev phải scaffold tay theo warehouse
  • ⚠ Manifest chưa có chỗ khai fields/scopeVars cho data scope (P1 của plan)
3

Khuyến nghị — tham chiếu hệ phổ biến

Tham chiếuKhuyến nghị
Shopify CLI / create-viteƯu tiên cao & rẻ: làm template create từ chính module student/warehouse tinh gọn — GĐ1 sắp scaffold 3 module mới (tuition/report/notify), mỗi lần scaffold tay là một lần lệch convention
VS Code extension APIBổ sung manifest v1.1: fields/scopeVars (plan data-scope P1) + bump minor moduleSdk — không breaking
npm workspacesThêm lệnh opengate-module lint: check tableName prefix, permission format, migration idempotent — tự động hóa checklist publish
4

Liên kết trong core

  • rt-host — tiêu thụ .ogapp
  • registry — đích publish
  • rt-authz — manifest permissions đổ vào catalog
Phân quyền

Ma trận tác nhân × năng lực

Core không phải module nghiệp vụ — thay ma trận vai trò bằng tác nhân × năng lực, kèm cơ chế/quyền gate từng năng lực. R đọc · W thực hiện · A duyệt.

Năng lựcCơ chế / quyền gateSUPEROWNER/QTHTDEVSVCUSER
dev / build / lint (đích P5)local, .env moduleW
publish lên registrytoken registry (đích P1)W
deploy trực tiếp vào hostOPENGATE_TOKEN của hostW
create từ template (đích P5)localW

SUPER = super admin CP · OWNER/QTHT = chủ workspace / quản trị WS · DEV = developer/publisher · SVC = service-to-service (runtime/hook) · USER = người dùng cuối. Mục ghi (đích) = theo khuyến nghị P1–P5, chưa có ở hiện trạng.