Remove plugin data query projection
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"browser.local/platform/domain"
|
||||
)
|
||||
|
||||
func mergePluginDataValues(existing, incoming map[string]any) map[string]any {
|
||||
merged := domain.CopyGameClientBridgePayload(existing)
|
||||
if merged == nil {
|
||||
merged = make(map[string]any, len(incoming))
|
||||
}
|
||||
for key, value := range incoming {
|
||||
merged[key] = value
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
func pluginDataRowKey(value map[string]any, keys []string) (string, error) {
|
||||
parts := make([]string, len(keys))
|
||||
for index, key := range keys {
|
||||
item, exists := value[key]
|
||||
if !exists || item == nil || strings.TrimSpace(fmt.Sprint(item)) == "" {
|
||||
return "", validationError("declared plugin data row is missing an upsert key")
|
||||
}
|
||||
encoded, err := json.Marshal(item)
|
||||
if err != nil {
|
||||
return "", validationError("declared plugin data row upsert key is invalid")
|
||||
}
|
||||
parts[index] = string(encoded)
|
||||
}
|
||||
if len(parts) == 1 {
|
||||
var key string
|
||||
if err := json.Unmarshal([]byte(parts[0]), &key); err == nil {
|
||||
return key, nil
|
||||
}
|
||||
}
|
||||
return strings.Join(parts, "\x1f"), nil
|
||||
}
|
||||
Reference in New Issue
Block a user