feat: фича-флаги конфигурации — клиент не сохраняет то, чего не понимает
Конфигурация хранит feature_flags (JSON-массив, NULL = нет) — какие данные она использует. Флаги выводятся из содержимого при каждом сохранении (internal/configfeatures). Если у конфигурации есть флаг, неизвестный этой версии, клиент отказывается её изменять: все write-пути отдают 409 unsupported_config_features со списком флагов, конфигуратор показывает баннер «обновите приложение» и блокирует сохранение. Push на сервер тоже отказывается, если серверная версия несёт неизвестный флаг; такое изменение остаётся в очереди до обновления. Первый флаг: sale_row_markups. Серверная миграция 034 добавляет колонку; до её применения запись идёт без колонки (с warning). Формат имён и реестр флагов — bible-local/02-architecture.md, ADL 2026-09-24. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b9652e3ac
commit
4e3b43dbd0
18 files changed
+579
-20
No files matched your search
@@ -3,6 +3,7 @@ package localdb
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.mchus.pro/mchus/quoteforge/internal/configfeatures"
|
||||
"git.mchus.pro/mchus/quoteforge/internal/models"
|
||||
)
|
||||
|
||||
@@ -62,6 +63,7 @@ func ConfigurationToLocal(cfg *models.Configuration) *LocalConfiguration {
|
||||
TotalPrice: cfg.TotalPrice,
|
||||
CustomPrice: cfg.CustomPrice,
|
||||
Notes: cfg.Notes,
|
||||
FeatureFlags: cfg.FeatureFlags,
|
||||
IsTemplate: cfg.IsTemplate,
|
||||
ServerCount: cfg.ServerCount,
|
||||
ServerModel: cfg.ServerModel,
|
||||
@@ -112,6 +114,8 @@ func LocalToConfiguration(local *LocalConfiguration) *models.Configuration {
|
||||
TotalPrice: local.TotalPrice,
|
||||
CustomPrice: local.CustomPrice,
|
||||
Notes: local.Notes,
|
||||
FeatureFlags: local.FeatureFlags,
|
||||
UnsupportedFeatures: configfeatures.Unknown(local.FeatureFlags),
|
||||
IsTemplate: local.IsTemplate,
|
||||
ServerCount: local.ServerCount,
|
||||
ServerModel: local.ServerModel,
|
||||
|
||||
@@ -102,6 +102,7 @@ type LocalConfiguration struct {
|
||||
TotalPrice *float64 `json:"total_price"`
|
||||
CustomPrice *float64 `json:"custom_price"`
|
||||
Notes string `json:"notes"`
|
||||
FeatureFlags models.FeatureFlags `gorm:"type:text" json:"feature_flags,omitempty"`
|
||||
IsTemplate bool `gorm:"default:false" json:"is_template"`
|
||||
ServerCount int `gorm:"default:1" json:"server_count"`
|
||||
ServerModel string `gorm:"size:100" json:"server_model,omitempty"`
|
||||
|
||||
@@ -5,6 +5,8 @@ import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"git.mchus.pro/mchus/quoteforge/internal/models"
|
||||
)
|
||||
|
||||
// BuildConfigurationSnapshot serializes the full local configuration state.
|
||||
@@ -21,6 +23,7 @@ func BuildConfigurationSnapshot(localCfg *LocalConfiguration) (string, error) {
|
||||
"total_price": localCfg.TotalPrice,
|
||||
"custom_price": localCfg.CustomPrice,
|
||||
"notes": localCfg.Notes,
|
||||
"feature_flags": localCfg.FeatureFlags,
|
||||
"is_template": localCfg.IsTemplate,
|
||||
"server_count": localCfg.ServerCount,
|
||||
"server_model": localCfg.ServerModel,
|
||||
@@ -60,6 +63,7 @@ func DecodeConfigurationSnapshot(data string) (*LocalConfiguration, error) {
|
||||
TotalPrice *float64 `json:"total_price"`
|
||||
CustomPrice *float64 `json:"custom_price"`
|
||||
Notes string `json:"notes"`
|
||||
FeatureFlags models.FeatureFlags `json:"feature_flags"`
|
||||
IsTemplate bool `json:"is_template"`
|
||||
ServerCount int `json:"server_count"`
|
||||
ServerModel string `json:"server_model"`
|
||||
@@ -95,6 +99,7 @@ func DecodeConfigurationSnapshot(data string) (*LocalConfiguration, error) {
|
||||
TotalPrice: snapshot.TotalPrice,
|
||||
CustomPrice: snapshot.CustomPrice,
|
||||
Notes: snapshot.Notes,
|
||||
FeatureFlags: snapshot.FeatureFlags,
|
||||
IsTemplate: snapshot.IsTemplate,
|
||||
ServerCount: snapshot.ServerCount,
|
||||
ServerModel: snapshot.ServerModel,
|
||||
|
||||
Reference in new issue
Block a user