Files
easyai-ai-gateway/apps/api/internal/store/billing_config.go
T

29 lines
1.2 KiB
Go

package store
// EffectiveBillingConfigInput describes the billing layers used by runtime and
// catalog responses. LegacyPlatformModelConfig is retained only as a fallback
// for models that do not have an effective pricing rule set.
type EffectiveBillingConfigInput struct {
BaseConfig map[string]any
LegacyPlatformModelConfig map[string]any
InheritedRuleSetConfig map[string]any
ModelRuleSetConfig map[string]any
Override map[string]any
}
// ResolveEffectiveBillingConfig keeps inherited pricing rules authoritative over
// the legacy materialized snapshot. Explicit model rules and overrides retain
// their higher-priority exception semantics.
func ResolveEffectiveBillingConfig(input EffectiveBillingConfigInput) map[string]any {
config := mergeObjects(input.BaseConfig, nil)
if len(input.InheritedRuleSetConfig) > 0 {
config = mergeObjects(input.InheritedRuleSetConfig, nil)
} else if len(input.LegacyPlatformModelConfig) > 0 {
config = mergeObjects(input.LegacyPlatformModelConfig, nil)
}
if len(input.ModelRuleSetConfig) > 0 {
config = mergeObjects(input.ModelRuleSetConfig, nil)
}
return mergeObjects(config, input.Override)
}