Giao diện
@digiforce-nc/plugin-mock-collections
Plugin collection giả lập — tạo collection với dữ liệu mock (faker) cho testing, demo và phát triển giao diện, không cần dữ liệu production thật.
Plugin này làm gì?
Khi phát triển UI hoặc chuẩn bị demo, cần dữ liệu trông thực tế nhưng không muốn dùng dữ liệu production. Plugin tạo mock collection với dữ liệu giả lập tự động: tên người, email, địa chỉ, số điện thoại, ngày tháng, ảnh... theo faker rules cấu hình cho từng field.
Sáu tính năng chính
| # | Tính năng | Chi tiết |
|---|---|---|
| 1 | Auto-generate | Sinh dữ liệu tự động theo faker rules cho mỗi field |
| 2 | Faker types | Hỗ trợ: name, email, phone, address, date, number, lorem, image... |
| 3 | Configurable | Cấu hình số lượng records và faker rule riêng cho từng field |
| 4 | Locale | Dữ liệu faker theo locale (vi, en, ja, ko...) — tên tiếng Việt, địa chỉ VN |
| 5 | Seed | Seed cố định để sinh data reproducible (cùng seed = cùng data) |
| 6 | Relation data | Tự động tạo dữ liệu cho relation fields (FK, M2M) |
Kiến trúc
Luồng sinh dữ liệu
Faker rules phổ biến
| Faker Rule | Ví dụ output (locale: vi) |
|---|---|
person.fullName | Nguyễn Văn An |
internet.email | an.nguyen@example.com |
phone.number | 0912 345 678 |
location.streetAddress | 123 Lê Lợi, Q.1, TP.HCM |
date.past | 2024-03-15 |
lorem.paragraph | Đoạn văn bản mẫu... |
number.int | 42 |
image.avatar | URL ảnh avatar |
Thành phần client
| Thành phần | Mô tả |
|---|---|
MockConfig | Giao diện cấu hình mock rules cho collection |
FakerRuleSelector | Dropdown chọn faker rule cho từng field |
GenerateButton | Nút sinh dữ liệu (với progress bar) |
MockPreview | Preview sample data trước khi sinh thật |
Dependencies
| Package | Vai trò |
|---|---|
@digiforce-nc/server | Server framework |
@digiforce-nc/database | Database ORM |
@digiforce-nc/client | Client UI framework |
@faker-js/faker | Faker data generator engine |
Mục lục chi tiết
(Xem trang tổng quan ở trên)