resolveListKey maps an update key — optionally carrying an operation affix ("goals_replace", "remove_goals") — to its canonical list field and op.
(key string)
| 57 | // resolveListKey maps an update key — optionally carrying an operation affix |
| 58 | // ("goals_replace", "remove_goals") — to its canonical list field and op. |
| 59 | func resolveListKey(key string) (field string, op listOp, ok bool) { |
| 60 | k := strings.ToLower(strings.TrimSpace(key)) |
| 61 | op = opUpsert |
| 62 | for _, a := range opAffixes { |
| 63 | if strings.HasSuffix(k, "_"+a.affix) { |
| 64 | k, op = strings.TrimSuffix(k, "_"+a.affix), a.op |
| 65 | break |
| 66 | } |
| 67 | if strings.HasPrefix(k, a.affix+"_") { |
| 68 | k, op = strings.TrimPrefix(k, a.affix+"_"), a.op |
| 69 | break |
| 70 | } |
| 71 | } |
| 72 | field, ok = listFieldAliases[k] |
| 73 | return field, op, ok |
| 74 | } |
| 75 | |
| 76 | // splitListItems splits a comma/semicolon-separated value into items WITHOUT |
| 77 | // splitting inside parentheses/brackets, so "Quiz X (Anthropic, 60 questões)" |