Bỏ qua, đến nội dung

@digiforce-nc/plugin-record-history

Plugin lịch sử thay đổi bản ghi — ghi lại mọi thay đổi (create, update, destroy) trên bản ghi với chi tiết giá trị cũ → mới cho từng field.

Plugin này làm gì?

Khi cần biết ai đã sửa gì, khi nào trên một bản ghi, plugin tự động ghi lại mọi thay đổi thông qua DB hooks. Hệ thống sử dụng cơ chế snapshot + diff: chụp snapshot giá trị field trước và sau thay đổi, so sánh để tạo lịch sử chi tiết.

Tính năng chính

#Tính năngMô tả
1Auto-trackingGhi lại create, update, destroy qua DB hooks
2Field-level diffChi tiết giá trị cũ → mới cho từng field
3User attributionGhi nhận user thực hiện thay đổi
4Per-collection configBật/tắt tracking cho từng Collection và từng field
5Relation supportTheo dõi thay đổi trên relation fields
6Multi data sourceHỗ trợ tracking across nhiều data source
7Async processingSử dụng Event Queue để không ảnh hưởng response time

Database

Plugin sử dụng Database connection riêng (historyDB) cho các bảng lịch sử:

BảngMô tả
recordHistoriesLịch sử tổng: uuid, requestId, recordId, collectionName, dataSourceKey, action, userId
recordFieldHistoriesLịch sử per-field: fieldPath, before, after, options
recordFieldSnapshotsSnapshot giá trị hiện tại — dùng để tính diff
recordHistoryCollectionsCấu hình: Collection nào cần tracking
recordHistoryFieldsCấu hình: Field nào cần tracking trong mỗi Collection

API endpoints

EndpointMô tảQuyền
recordHistories:*Đọc lịch sử thay đổiAdmin
recordFieldHistories:*Đọc chi tiết thay đổi per-fieldAdmin
recordHistoryCollections:*Cấu hình trackingAdmin
recordHistoryTemplate:getLấy template hiển thịĐã đăng nhập

Dependencies

PackageVai trò
@digiforce-nc/serverServer framework — DB hooks, EventQueue
@digiforce-nc/databaseDatabase ORM
@digiforce-nc/clientClient UI framework
@digiforce-nc/cacheCache cho sync-snapshots

Mục lục chi tiết