Remove cookie_patterns legacy, migrate to tracker_patterns

Delete coredata.CookiePattern and all associated CRUD methods,
rename shared types (CookiePatternOrderField, CookiePatternFilter,
CookiePatternMatchType) to TrackerPattern equivalents, and migrate
all API surfaces (GraphQL, MCP, CLI, n8n) to tracker_pattern naming.

The worker was already migrated in the base branch; this commit
completes the removal by dropping the old GraphQL schema/resolvers,
service methods, CLI commands, and n8n operations that operated on
the legacy cookie_patterns table.

Signed-off-by: Émile Ré <emile@getprobo.com>
This commit is contained in:
Émile Ré
2026-05-06 10:21:33 +04:00
parent 21f92352d5
commit af6e420f54
39 changed files with 1008 additions and 2475 deletions

View File

@@ -31,7 +31,6 @@ import (
"go.probo.inc/probo/pkg/cmd/control"
cookiebanner "go.probo.inc/probo/pkg/cmd/cookie-banner"
cookiecategory "go.probo.inc/probo/pkg/cmd/cookie-category"
cookiepattern "go.probo.inc/probo/pkg/cmd/cookie-pattern"
"go.probo.inc/probo/pkg/cmd/datum"
"go.probo.inc/probo/pkg/cmd/document"
"go.probo.inc/probo/pkg/cmd/dpia"
@@ -48,6 +47,7 @@ import (
"go.probo.inc/probo/pkg/cmd/soa"
"go.probo.inc/probo/pkg/cmd/task"
"go.probo.inc/probo/pkg/cmd/tia"
trackerpattern "go.probo.inc/probo/pkg/cmd/tracker-pattern"
trustcenter "go.probo.inc/probo/pkg/cmd/trust-center"
"go.probo.inc/probo/pkg/cmd/user"
"go.probo.inc/probo/pkg/cmd/vendormgmt"
@@ -99,7 +99,7 @@ func NewCmdRoot(f *cmdutil.Factory) *cobra.Command {
cmd.AddCommand(control.NewCmdControl(f))
cmd.AddCommand(cookiebanner.NewCmdCookieBanner(f))
cmd.AddCommand(cookiecategory.NewCmdCookieCategory(f))
cmd.AddCommand(cookiepattern.NewCmdCookiePattern(f))
cmd.AddCommand(trackerpattern.NewCmdTrackerPattern(f))
cmd.AddCommand(datum.NewCmdDatum(f))
cmd.AddCommand(document.NewCmdDocument(f))
cmd.AddCommand(dpia.NewCmdDPIA(f))

View File

@@ -25,9 +25,9 @@ import (
)
const createMutation = `
mutation($input: CreateCookiePatternInput!) {
createCookiePattern(input: $input) {
cookiePatternEdge {
mutation($input: CreateTrackerPatternInput!) {
createTrackerPattern(input: $input) {
trackerPatternEdge {
node {
id
pattern
@@ -42,15 +42,15 @@ mutation($input: CreateCookiePatternInput!) {
`
type createResponse struct {
CreateCookiePattern struct {
CookiePatternEdge struct {
CreateTrackerPattern struct {
TrackerPatternEdge struct {
Node struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
DisplayName string `json:"displayName"`
} `json:"node"`
} `json:"cookiePatternEdge"`
} `json:"createCookiePattern"`
} `json:"trackerPatternEdge"`
} `json:"createTrackerPattern"`
}
func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
@@ -65,7 +65,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Create a new cookie pattern",
Short: "Create a new tracker pattern",
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
if err != nil {
@@ -87,7 +87,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
if f.IOStreams.IsInteractive() {
if flagPattern == "" {
if err := huh.NewInput().Title("Cookie pattern").Value(&flagPattern).Run(); err != nil {
if err := huh.NewInput().Title("Tracker pattern").Value(&flagPattern).Run(); err != nil {
return err
}
}
@@ -142,8 +142,8 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
return fmt.Errorf("cannot parse response: %w", err)
}
p := resp.CreateCookiePattern.CookiePatternEdge.Node
_, _ = fmt.Fprintf(f.IOStreams.Out, "Created cookie pattern %s (%s)\n", p.ID, p.DisplayName)
p := resp.CreateTrackerPattern.TrackerPatternEdge.Node
_, _ = fmt.Fprintf(f.IOStreams.Out, "Created tracker pattern %s (%s)\n", p.ID, p.DisplayName)
return nil
},
@@ -151,7 +151,7 @@ func NewCmdCreate(f *cmdutil.Factory) *cobra.Command {
cmd.Flags().StringVar(&flagCategoryID, "category-id", "", "Cookie category ID (required)")
_ = cmd.MarkFlagRequired("category-id")
cmd.Flags().StringVar(&flagPattern, "pattern", "", "Cookie pattern (required)")
cmd.Flags().StringVar(&flagPattern, "pattern", "", "Tracker pattern (required)")
cmd.Flags().StringVar(&flagMatchType, "match-type", "", "Match type: EXACT or PREFIX (required)")
cmd.Flags().StringVar(&flagDisplayName, "display-name", "", "Display name (required)")
cmd.Flags().StringVar(&flagDescription, "description", "", "Description")

View File

@@ -24,9 +24,9 @@ import (
)
const deleteMutation = `
mutation($input: DeleteCookiePatternInput!) {
deleteCookiePattern(input: $input) {
deletedCookiePatternId
mutation($input: DeleteTrackerPatternInput!) {
deleteTrackerPattern(input: $input) {
deletedTrackerPatternId
cookieBanner {
id
}
@@ -39,15 +39,15 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "delete <id>",
Short: "Delete a cookie pattern",
Short: "Delete a tracker pattern",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if !flagYes {
if !f.IOStreams.IsInteractive() {
return fmt.Errorf("cannot delete cookie pattern: confirmation required, use --yes to confirm")
return fmt.Errorf("cannot delete tracker pattern: confirmation required, use --yes to confirm")
}
var confirmed bool
if err := huh.NewConfirm().Title(fmt.Sprintf("Delete cookie pattern %s?", args[0])).Value(&confirmed).Run(); err != nil {
if err := huh.NewConfirm().Title(fmt.Sprintf("Delete tracker pattern %s?", args[0])).Value(&confirmed).Run(); err != nil {
return err
}
if !confirmed {
@@ -74,13 +74,13 @@ func NewCmdDelete(f *cmdutil.Factory) *cobra.Command {
)
_, err = client.Do(deleteMutation, map[string]any{
"input": map[string]any{"cookiePatternId": args[0]},
"input": map[string]any{"trackerPatternId": args[0]},
})
if err != nil {
return err
}
_, _ = fmt.Fprintf(f.IOStreams.Out, "Deleted cookie pattern %s\n", args[0])
_, _ = fmt.Fprintf(f.IOStreams.Out, "Deleted tracker pattern %s\n", args[0])
return nil
},

View File

@@ -28,13 +28,14 @@ query($id: ID!, $first: Int, $after: CursorKey) {
node(id: $id) {
__typename
... on CookieCategory {
cookiePatterns(first: $first, after: $after) {
trackerPatterns(first: $first, after: $after) {
totalCount
edges {
node {
id
pattern
matchType
trackerType
displayName
source
excluded
@@ -51,10 +52,11 @@ query($id: ID!, $first: Int, $after: CursorKey) {
}
`
type cookiePattern struct {
type trackerPattern struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
MatchType string `json:"matchType"`
TrackerType string `json:"trackerType"`
DisplayName string `json:"displayName"`
Source string `json:"source"`
Excluded bool `json:"excluded"`
@@ -70,7 +72,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "list",
Short: "List cookie patterns in a category",
Short: "List tracker patterns in a category",
Aliases: []string{"ls"},
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
@@ -103,11 +105,11 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
listQuery,
variables,
flagLimit,
func(data json.RawMessage) (*api.Connection[cookiePattern], error) {
func(data json.RawMessage) (*api.Connection[trackerPattern], error) {
var resp struct {
Node *struct {
Typename string `json:"__typename"`
CookiePatterns api.Connection[cookiePattern] `json:"cookiePatterns"`
Typename string `json:"__typename"`
TrackerPatterns api.Connection[trackerPattern] `json:"trackerPatterns"`
} `json:"node"`
}
if err := json.Unmarshal(data, &resp); err != nil {
@@ -119,7 +121,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
if resp.Node.Typename != "CookieCategory" {
return nil, fmt.Errorf("expected CookieCategory node, got %s", resp.Node.Typename)
}
return &resp.Node.CookiePatterns, nil
return &resp.Node.TrackerPatterns, nil
},
)
if err != nil {
@@ -131,7 +133,7 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
}
if len(patterns) == 0 {
_, _ = fmt.Fprintln(f.IOStreams.Out, "No cookie patterns found.")
_, _ = fmt.Fprintln(f.IOStreams.Out, "No tracker patterns found.")
return nil
}
@@ -145,14 +147,14 @@ func NewCmdList(f *cmdutil.Factory) *cobra.Command {
if p.LastMatchedAt != nil {
lastMatched = cmdutil.FormatTime(*p.LastMatchedAt)
}
rows = append(rows, []string{p.ID, p.Pattern, p.MatchType, p.DisplayName, p.Source, excluded, lastMatched})
rows = append(rows, []string{p.ID, p.Pattern, p.MatchType, p.TrackerType, p.DisplayName, p.Source, excluded, lastMatched})
}
t := cmdutil.NewTable("ID", "PATTERN", "MATCH TYPE", "DISPLAY NAME", "SOURCE", "EXCLUDED", "LAST MATCHED").Rows(rows...)
t := cmdutil.NewTable("ID", "PATTERN", "MATCH TYPE", "TRACKER TYPE", "DISPLAY NAME", "SOURCE", "EXCLUDED", "LAST MATCHED").Rows(rows...)
_, _ = fmt.Fprintln(f.IOStreams.Out, t)
if totalCount > len(patterns) {
_, _ = fmt.Fprintf(f.IOStreams.ErrOut, "\nShowing %d of %d cookie patterns\n", len(patterns), totalCount)
_, _ = fmt.Fprintf(f.IOStreams.ErrOut, "\nShowing %d of %d tracker patterns\n", len(patterns), totalCount)
}
return nil

View File

@@ -24,9 +24,9 @@ import (
)
const moveMutation = `
mutation($input: MoveCookiePatternToCategoryInput!) {
moveCookiePatternToCategory(input: $input) {
cookiePattern {
mutation($input: MoveTrackerPatternToCategoryInput!) {
moveTrackerPatternToCategory(input: $input) {
trackerPattern {
id
cookieCategory {
id
@@ -41,15 +41,15 @@ mutation($input: MoveCookiePatternToCategoryInput!) {
`
type moveResponse struct {
MoveCookiePatternToCategory struct {
CookiePattern struct {
MoveTrackerPatternToCategory struct {
TrackerPattern struct {
ID string `json:"id"`
CookieCategory struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"cookieCategory"`
} `json:"cookiePattern"`
} `json:"moveCookiePatternToCategory"`
} `json:"trackerPattern"`
} `json:"moveTrackerPatternToCategory"`
}
func NewCmdMove(f *cmdutil.Factory) *cobra.Command {
@@ -57,7 +57,7 @@ func NewCmdMove(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "move <id>",
Short: "Move a cookie pattern to a different category",
Short: "Move a tracker pattern to a different category",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
@@ -80,7 +80,7 @@ func NewCmdMove(f *cmdutil.Factory) *cobra.Command {
data, err := client.Do(moveMutation, map[string]any{
"input": map[string]any{
"cookiePatternId": args[0],
"trackerPatternId": args[0],
"targetCookieCategoryId": flagTargetCategoryID,
},
})
@@ -93,8 +93,8 @@ func NewCmdMove(f *cmdutil.Factory) *cobra.Command {
return fmt.Errorf("cannot parse response: %w", err)
}
p := resp.MoveCookiePatternToCategory.CookiePattern
_, _ = fmt.Fprintf(f.IOStreams.Out, "Moved cookie pattern %s to category %s\n", p.ID, p.CookieCategory.Name)
p := resp.MoveTrackerPatternToCategory.TrackerPattern
_, _ = fmt.Fprintf(f.IOStreams.Out, "Moved tracker pattern %s to category %s\n", p.ID, p.CookieCategory.Name)
return nil
},

View File

@@ -12,23 +12,23 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
package cookiepattern
package trackerpattern
import (
"github.com/spf13/cobra"
"go.probo.inc/probo/pkg/cmd/cmdutil"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/create"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/delete"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/list"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/move"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/update"
"go.probo.inc/probo/pkg/cmd/cookie-pattern/view"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/create"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/delete"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/list"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/move"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/update"
"go.probo.inc/probo/pkg/cmd/tracker-pattern/view"
)
func NewCmdCookiePattern(f *cmdutil.Factory) *cobra.Command {
func NewCmdTrackerPattern(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "cookie-pattern <command>",
Short: "Manage cookie patterns",
Use: "tracker-pattern <command>",
Short: "Manage tracker patterns",
}
cmd.AddCommand(list.NewCmdList(f))

View File

@@ -24,9 +24,9 @@ import (
)
const updateMutation = `
mutation($input: UpdateCookiePatternInput!) {
updateCookiePattern(input: $input) {
cookiePattern {
mutation($input: UpdateTrackerPatternInput!) {
updateTrackerPattern(input: $input) {
trackerPattern {
id
displayName
}
@@ -38,12 +38,12 @@ mutation($input: UpdateCookiePatternInput!) {
`
type updateResponse struct {
UpdateCookiePattern struct {
CookiePattern struct {
UpdateTrackerPattern struct {
TrackerPattern struct {
ID string `json:"id"`
DisplayName string `json:"displayName"`
} `json:"cookiePattern"`
} `json:"updateCookiePattern"`
} `json:"trackerPattern"`
} `json:"updateTrackerPattern"`
}
func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
@@ -56,7 +56,7 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "update <id>",
Short: "Update a cookie pattern",
Short: "Update a tracker pattern",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
cfg, err := f.Config()
@@ -77,7 +77,7 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
cmdutil.TokenRefreshOption(cfg, host, hc),
)
input := map[string]any{"cookiePatternId": args[0]}
input := map[string]any{"trackerPatternId": args[0]}
if cmd.Flags().Changed("display-name") {
input["displayName"] = flagDisplayName
@@ -106,8 +106,8 @@ func NewCmdUpdate(f *cmdutil.Factory) *cobra.Command {
return fmt.Errorf("cannot parse response: %w", err)
}
p := resp.UpdateCookiePattern.CookiePattern
_, _ = fmt.Fprintf(f.IOStreams.Out, "Updated cookie pattern %s (%s)\n", p.ID, p.DisplayName)
p := resp.UpdateTrackerPattern.TrackerPattern
_, _ = fmt.Fprintf(f.IOStreams.Out, "Updated tracker pattern %s (%s)\n", p.ID, p.DisplayName)
return nil
},

View File

@@ -28,10 +28,11 @@ const viewQuery = `
query($id: ID!) {
node(id: $id) {
__typename
... on CookiePattern {
... on TrackerPattern {
id
pattern
matchType
trackerType
displayName
maxAgeSeconds
description
@@ -51,6 +52,7 @@ type viewResponse struct {
ID string `json:"id"`
Pattern string `json:"pattern"`
MatchType string `json:"matchType"`
TrackerType string `json:"trackerType"`
DisplayName string `json:"displayName"`
MaxAgeSeconds *int `json:"maxAgeSeconds"`
Description *string `json:"description"`
@@ -67,7 +69,7 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
cmd := &cobra.Command{
Use: "view <id>",
Short: "View a cookie pattern",
Short: "View a tracker pattern",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
if err := cmdutil.ValidateOutputFlag(flagOutput); err != nil {
@@ -102,8 +104,8 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
return fmt.Errorf("cannot parse response: %w", err)
}
if resp.Node == nil || resp.Node.Typename != "CookiePattern" {
return fmt.Errorf("cookie pattern %s not found", args[0])
if resp.Node == nil || resp.Node.Typename != "TrackerPattern" {
return fmt.Errorf("tracker pattern %s not found", args[0])
}
if *flagOutput == cmdutil.OutputJSON {
@@ -120,6 +122,7 @@ func NewCmdView(f *cmdutil.Factory) *cobra.Command {
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("ID:"), v.ID)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Pattern:"), v.Pattern)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Match Type:"), v.MatchType)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Tracker Type:"), v.TrackerType)
_, _ = fmt.Fprintf(out, "%s%s\n", label.Render("Source:"), v.Source)
_, _ = fmt.Fprintf(out, "%s%v\n", label.Render("Excluded:"), v.Excluded)
if v.MaxAgeSeconds != nil {