Integration
@nx/assettích hợp bằng cách được mount như các IGNIS component bên trong các ứng dụng host — không phải bằng các lời gọi mạng giữa các service. Phụ thuộc bên ngoài duy nhất của nó là S3/Minio.
1. Service anh em
Direction:←được mount bởi (host tiêu thụ asset).
| Sister | Direction | Surface | Contract | Auth | Failure Mode | Idempotency |
|---|---|---|---|---|---|---|
@nx/commerce | ← | host.component(ApplicationAssetComponent) | in-process component | host JWT/Basic | component init throw → host boot fail | n/a |
@nx/finance | ← | host.component(ApplicationAssetBanksVNComponent) | in-process component | route public | — | n/a |
@nx/ledger | ← | ApplicationAssetComponent + MetaLinkRepository cho upload PDF/XLSX được tạo | in-process | host JWT/Basic | lỗi upload được log cho từng file | upload không idempotent |
@nx/core | → | import MetaLink, PostgresCoreDataSource, EnvironmentKeys, crudPermissions | TypeScript dependency | — | compile-time | n/a |
2. Hệ thống bên ngoài
| System | Direction | Surface | Auth | Failure Mode |
|---|---|---|---|---|
| S3 / Minio | → | BunS3Helper (@venizia/ignis-helpers/bun-s3) | APP_ENV_S3_ACCESS_KEY / APP_ENV_S3_SECRET_KEY | helper throw → 4xx/5xx tới client; upload cũng bắt lỗi MetaLink |
3. Luồng cross-service quan trọng
3.1 Commerce mount asset cho media sản phẩm
| Bước | Chi tiết |
|---|---|
| 2 | Tham số kết nối S3 được đọc khi construct qua applicationEnvironment.get() |
| 4 | Controller mount dưới base path của host (vd /v1/api/commerce/assets) |
3.2 Ledger upload một tài liệu được tạo
4. Tính ổn định Contract
| Surface | Stability | Versioning |
|---|---|---|
host.component(ApplicationAssetComponent) | stable | TypeScript export |
REST /assets, /meta-links, /assets/banks-vn | stable | host URL prefix /v1/ |
BindingKeys.APPLICATION_S3_STORAGE_HELPER | stable | string key (lưu ý: namespace @nx/commerce) |
Đường dẫn StaticAssetComponent presigned-URL | không hoạt động | đã comment trong source — không phụ thuộc vào nó |