From 2bcaf6eada0d2e4b7ad034bf552496dab1954b0e Mon Sep 17 00:00:00 2001 From: Anatole Date: Sat, 20 May 2023 23:28:26 +0200 Subject: [PATCH 1/3] Paints V3 (API) --- data/model/cosmetic.model.go | 204 ++++++++++++++-- data/model/modelgql/cosmetic-gql.model.go | 76 +++++- go.mod | 2 +- go.sum | 4 +- internal/api/gql/v2/helpers/transform.go | 2 +- .../v3/resolvers/cosmetics/cosmetics.ops.go | 2 +- .../resolvers/mutation/mutation.cosmetics.go | 2 +- internal/api/gql/v3/schema/cosmetics.gql | 54 ++++- .../api/rest/v2/routes/cosmetics/cosmetics.go | 2 +- internal/api/rest/v3/docs/docs.go | 223 +++++++++++++++++- internal/api/rest/v3/docs/swagger.json | 223 +++++++++++++++++- k8s/production.template.yaml | 36 +-- 12 files changed, 757 insertions(+), 73 deletions(-) diff --git a/data/model/cosmetic.model.go b/data/model/cosmetic.model.go index e1cef340..f18cc9f2 100644 --- a/data/model/cosmetic.model.go +++ b/data/model/cosmetic.model.go @@ -27,16 +27,49 @@ const ( ) type CosmeticPaintModel struct { - ID primitive.ObjectID `json:"id"` - Name string `json:"name"` - Function CosmeticPaintFunction `json:"function" enums:"LINEAR_GRADIENT,RADIAL_GRADIENT,URL"` - Color *int32 `json:"color"` - Repeat bool `json:"repeat"` - Angle int32 `json:"angle"` - Shape string `json:"shape"` - ImageURL string `json:"image_url"` - Stops []CosmeticPaintGradientStop `json:"stops"` - Shadows []CosmeticPaintDropShadow `json:"shadows"` + ID primitive.ObjectID `json:"id"` + Name string `json:"name"` + Color *int32 `json:"color"` + // The canvas size for the paint + CanvasSize [2]float64 `json:"canvas_size" bson:"canvas_size"` + // The repeat mode of the canvas + CanvasRepeat CosmeticPaintCanvasRepeat `json:"canvas_repeat" bson:"canvas_repeat"` + // A list of gradients. There may be any amount, which can be stacked onto each other + Gradients []CosmeticPaintGradient `json:"gradients"` + // A list of shadows. There may be any amount, which can be stacked onto each other + Shadows []CosmeticPaintShadow `json:"shadows"` + Flairs []CosmeticPaintFlair `json:"flairs"` + Text *CosmeticPaintText `json:"text"` + // deprecated: use `gradients` + Function CosmeticPaintFunction `json:"function" enums:"LINEAR_GRADIENT,RADIAL_GRADIENT,URL"` + // deprecated: use `gradients` + Repeat bool `json:"repeat"` + // deprecated: use `gradients` + Angle int32 `json:"angle"` + // deprecated: use `gradients` + Shape string `json:"shape"` + // deprecated: use `gradients` + ImageURL string `json:"image_url"` + // deprecated: use `gradients` + Stops []CosmeticPaintGradientStop `json:"stops"` +} + +type CosmeticPaintGradient struct { + // The function used to generate the paint (i.e gradients or an image) + Function CosmeticPaintFunction `json:"function" bson:"function"` + // Gradient stops, a list of positions and colors + Stops []CosmeticPaintGradientStop `json:"stops" bson:"stops"` + // For a URL-based paint, the URL to an image + ImageURL string `json:"image_url,omitempty" bson:"image_url,omitempty"` + // For a radial gradient, the shape of the gradient + Shape string `json:"shape,omitempty" bson:"shape,omitempty"` + // The degree angle of the gradient (does not apply if function is URL) + Angle int32 `json:"angle,omitempty" bson:"angle,omitempty"` + // Whether or not the gradient repeats outside its original area + Repeat bool `json:"repeat" bson:"repeat"` + + // Gradient position (X/Y % values) + At [2]float64 `json:"at,omitempty" bson:"at,omitempty"` } type CosmeticPaintFunction string @@ -50,15 +83,78 @@ const ( type CosmeticPaintGradientStop struct { At float64 `json:"at"` Color int32 `json:"color"` + // the center position for the gradient. X/Y % values (for radial gradients only) + CenterAt [2]float64 `json:"center_at,omitempty" bson:"center_at,omitempty"` } -type CosmeticPaintDropShadow struct { +type CosmeticPaintCanvasRepeat string + +const ( + CosmeticPaintCanvasRepeatNone CosmeticPaintCanvasRepeat = "no-repeat" + CosmeticPaintCanvasRepeatX CosmeticPaintCanvasRepeat = "repeat-x" + CosmeticPaintCanvasRepeatY CosmeticPaintCanvasRepeat = "repeat-y" + CosmeticPaintCanvasRepeatRevert CosmeticPaintCanvasRepeat = "revert" + CosmeticPaintCanvasRepeatRound CosmeticPaintCanvasRepeat = "round" + CosmeticPaintCanvasRepeatSpace CosmeticPaintCanvasRepeat = "space" +) + +type CosmeticPaintShadow struct { OffsetX float64 `json:"x_offset"` OffsetY float64 `json:"y_offset"` Radius float64 `json:"radius"` Color int32 `json:"color"` } +type CosmeticPaintText struct { + // Weight multiplier for the text. Defaults to 9x is not specified + Weight uint8 `json:"weight,omitempty" bson:"weight,omitempty"` + // Shadows applied to the text + Shadows []CosmeticPaintShadow `json:"shadows,omitempty" bson:"shadows,omitempty"` + // Text tranformation + Transform CosmeticPaintTextTransform `json:"transform,omitempty" bson:"transform,omitempty"` + // Text stroke + Stroke *CosmeticPaintStroke `json:"stroke,omitempty" bson:"stroke,omitempty"` + // (css) font variant property. non-standard + Variant string `json:"variant" bson:"variant"` +} + +type CosmeticPaintStroke struct { + // Stroke color + Color int32 `json:"color" bson:"color"` + // Stroke width + Width float64 `json:"width" bson:"width"` +} + +type CosmeticPaintTextTransform string + +const ( + CosmeticPaintTextTransformUppercase CosmeticPaintTextTransform = "uppercase" + CosmeticPaintTextTransformLowercase CosmeticPaintTextTransform = "lowercase" +) + +type CosmeticPaintFlair struct { + // The kind of sprite + Kind CosmeticPaintFlairKind `json:"kind" bson:"kind"` + // The X offset of the flair (%) + OffsetX float64 `json:"x_offset" bson:"x_offset"` + // The Y offset of the flair (%) + OffsetY float64 `json:"y_offset" bson:"y_offset"` + // The width of the flair + Width float64 `json:"width" bson:"width"` + // The height of the flair + Height float64 `json:"height" bson:"height"` + // Base64-encoded image or vector data + Data string `json:"data" bson:"data"` +} + +type CosmeticPaintFlairKind string + +const ( + CosmeticPaintSpriteKindImage CosmeticPaintFlairKind = "IMAGE" + CosmeticPaintSpriteKindVector CosmeticPaintFlairKind = "VECTOR" + CosmeticPaintSpriteKindText CosmeticPaintFlairKind = "TEXT" +) + type CosmeticBadgeModel struct { ID primitive.ObjectID `json:"id"` Name string `json:"name"` @@ -108,28 +204,86 @@ func (x *modelizer) Paint(v structures.Cosmetic[structures.CosmeticDataPaint]) C } return CosmeticPaintModel{ - ID: v.ID, - Name: v.Name, - Function: CosmeticPaintFunction(v.Data.Function), - Color: color, - Repeat: v.Data.Repeat, - Angle: v.Data.Angle, - Shape: v.Data.Shape, - ImageURL: v.Data.ImageURL, - Stops: utils.Map(v.Data.Stops, func(v structures.CosmeticPaintGradientStop) CosmeticPaintGradientStop { - return CosmeticPaintGradientStop{ - At: v.At, - Color: v.Color.Sum(), + ID: v.ID, + Name: v.Name, + Function: CosmeticPaintFunction(v.Data.Function), + Color: color, + CanvasSize: v.Data.CanvasSize, + CanvasRepeat: CosmeticPaintCanvasRepeat(v.Data.CanvasRepeat), + Gradients: utils.Map(v.Data.Gradients, func(x structures.CosmeticPaintGradient) CosmeticPaintGradient { + return CosmeticPaintGradient{ + Function: CosmeticPaintFunction(x.Function), + Stops: utils.Map(x.Stops, func(x structures.CosmeticPaintGradientStop) CosmeticPaintGradientStop { + return CosmeticPaintGradientStop{ + At: x.At, + Color: x.Color.Sum(), + CenterAt: x.CenterAt, + } + }), + ImageURL: x.ImageURL, + Shape: x.Shape, + Angle: x.Angle, + Repeat: x.Repeat, + At: x.At, } }), - Shadows: utils.Map(v.Data.DropShadows, func(v structures.CosmeticPaintDropShadow) CosmeticPaintDropShadow { - return CosmeticPaintDropShadow{ + Shadows: utils.Map(v.Data.DropShadows, func(v structures.CosmeticPaintDropShadow) CosmeticPaintShadow { + return CosmeticPaintShadow{ OffsetX: v.OffsetX, OffsetY: v.OffsetY, Radius: v.Radius, Color: v.Color.Sum(), } }), + Flairs: utils.Map(v.Data.Flairs, func(v structures.CosmeticPaintFlair) CosmeticPaintFlair { + return CosmeticPaintFlair{ + Kind: CosmeticPaintFlairKind(v.Kind), + OffsetX: v.OffsetX, + OffsetY: v.OffsetY, + Width: v.Width, + Height: v.Height, + Data: v.Data, + } + }), + Text: func() *CosmeticPaintText { + if v.Data.Text == nil { + return nil + } + + return &CosmeticPaintText{ + Weight: v.Data.Text.Weight, + Shadows: utils.Map(v.Data.Text.Shadows, func(v structures.CosmeticPaintDropShadow) CosmeticPaintShadow { + return CosmeticPaintShadow{ + OffsetX: v.OffsetX, + OffsetY: v.OffsetY, + Radius: v.Radius, + Color: v.Color.Sum(), + } + }), + Transform: CosmeticPaintTextTransform(v.Data.Text.Transform), + Stroke: func() *CosmeticPaintStroke { + if v.Data.Text.Stroke == nil { + return nil + } + + return &CosmeticPaintStroke{ + Color: v.Data.Text.Stroke.Color.Sum(), + Width: v.Data.Text.Stroke.Width, + } + }(), + Variant: v.Data.Text.Variant, + } + }(), + Stops: utils.Map(v.Data.Stops, func(v structures.CosmeticPaintGradientStop) CosmeticPaintGradientStop { + return CosmeticPaintGradientStop{ + At: v.At, + Color: v.Color.Sum(), + } + }), + Repeat: v.Data.Repeat, + Angle: v.Data.Angle, + Shape: v.Data.Shape, + ImageURL: v.Data.ImageURL, } } diff --git a/data/model/modelgql/cosmetic-gql.model.go b/data/model/modelgql/cosmetic-gql.model.go index 31b7e797..57098576 100644 --- a/data/model/modelgql/cosmetic-gql.model.go +++ b/data/model/modelgql/cosmetic-gql.model.go @@ -13,15 +13,12 @@ func CosmeticPaint(xm model.CosmeticPaintModel) *gql_model.CosmeticPaint { } return &gql_model.CosmeticPaint{ - ID: xm.ID, - Name: xm.Name, - Function: gql_model.CosmeticPaintFunction(xm.Function), - Color: color, - Repeat: xm.Repeat, - Angle: int(xm.Angle), - Shape: utils.Ternary(xm.Shape != "", &xm.Shape, nil), - ImageURL: utils.Ternary(xm.ImageURL != "", &xm.ImageURL, nil), - Shadows: utils.Map(xm.Shadows, func(x model.CosmeticPaintDropShadow) *gql_model.CosmeticPaintShadow { + ID: xm.ID, + Name: xm.Name, + Color: color, + CanvasSize: xm.CanvasSize[:], + CanvasRepeat: string(xm.CanvasRepeat), + Shadows: utils.Map(xm.Shadows, func(x model.CosmeticPaintShadow) *gql_model.CosmeticPaintShadow { return &gql_model.CosmeticPaintShadow{ XOffset: x.OffsetX, YOffset: x.OffsetY, @@ -29,6 +26,67 @@ func CosmeticPaint(xm model.CosmeticPaintModel) *gql_model.CosmeticPaint { Color: int(x.Color), } }), + Gradients: utils.Map(xm.Gradients, func(x model.CosmeticPaintGradient) *gql_model.CosmeticPaintGradient { + return &gql_model.CosmeticPaintGradient{ + Function: gql_model.CosmeticPaintFunction(x.Function), + Stops: utils.Map(x.Stops, func(x model.CosmeticPaintGradientStop) *gql_model.CosmeticPaintStop { + return &gql_model.CosmeticPaintStop{ + At: x.At, + Color: int(x.Color), + CenterAt: x.CenterAt[:], + } + }), + Angle: int(x.Angle), + Repeat: x.Repeat, + ImageURL: &x.ImageURL, + Shape: &x.Shape, + At: x.At[:], + } + }), + Flairs: utils.Map(xm.Flairs, func(x model.CosmeticPaintFlair) *gql_model.CosmeticPaintFlair { + return &gql_model.CosmeticPaintFlair{ + Kind: gql_model.CosmeticPaintFlairKind(x.Kind), + XOffset: x.OffsetX, + YOffset: x.OffsetY, + Width: x.Width, + Height: x.Height, + Data: x.Data, + } + }), + Text: func() *gql_model.CosmeticPaintText { + if xm.Text == nil { + return nil + } + + return &gql_model.CosmeticPaintText{ + Weight: utils.PointerOf(int(xm.Text.Weight)), + Shadows: utils.Map(xm.Text.Shadows, func(x model.CosmeticPaintShadow) *gql_model.CosmeticPaintShadow { + return &gql_model.CosmeticPaintShadow{ + XOffset: x.OffsetX, + YOffset: x.OffsetY, + Radius: x.Radius, + Color: int(x.Color), + } + }), + Transform: utils.PointerOf(string(xm.Text.Transform)), + Stroke: func() *gql_model.CosmeticPaintStroke { + if xm.Text.Stroke == nil { + return nil + } + + return &gql_model.CosmeticPaintStroke{ + Color: int(xm.Text.Stroke.Color), + Width: xm.Text.Stroke.Width, + } + }(), + Variant: new(string), + } + }(), + Function: gql_model.CosmeticPaintFunction(xm.Function), + Repeat: xm.Repeat, + Angle: int(xm.Angle), + Shape: utils.Ternary(xm.Shape != "", &xm.Shape, nil), + ImageURL: utils.Ternary(xm.ImageURL != "", &xm.ImageURL, nil), Stops: utils.Map(xm.Stops, func(x model.CosmeticPaintGradientStop) *gql_model.CosmeticPaintStop { return &gql_model.CosmeticPaintStop{ At: x.At, diff --git a/go.mod b/go.mod index 06c4bbe8..32ab520a 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v1.14.0 - github.com/seventv/common v0.0.0-20230328045913-6c25d756c0ac + github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86 github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 github.com/seventv/message-queue/go v0.0.0-20220721124044-9fd23bda9643 diff --git a/go.sum b/go.sum index 9c9c6b00..4a9bd4e3 100644 --- a/go.sum +++ b/go.sum @@ -336,8 +336,8 @@ github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1Avp github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/seventv/common v0.0.0-20230328045913-6c25d756c0ac h1:wzCOShqABPrOqqvfAZdT8iVIaXx0WOU5QvYXvU9MvhM= -github.com/seventv/common v0.0.0-20230328045913-6c25d756c0ac/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= +github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86 h1:h2a2qf7GKuhcFt9ICgPZ683WQriXz2rMwahJDc8iGHY= +github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 h1:IqWrtt/yob45YnOQ5Wwkbf8qP22eKVtg0WzfyEkGnFg= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48/go.mod h1:T+ldp0YQe03s44+A5HHHI/jB3ZmWqOIaNouEqAS+1Dk= github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 h1:iU3wWepRTbkNoTAPR23m6TAW6Yb9pOMCYVr0K++OBAw= diff --git a/internal/api/gql/v2/helpers/transform.go b/internal/api/gql/v2/helpers/transform.go index af653369..8d5bc8c7 100644 --- a/internal/api/gql/v2/helpers/transform.go +++ b/internal/api/gql/v2/helpers/transform.go @@ -265,7 +265,7 @@ func CosmeticStructureToModel(s structures.Cosmetic[bson.Raw]) *model.UserCosmet f := strings.Replace(string(v.Data.Function), "_", "-", 1) f = strings.ToLower(f) - v.Data.Function = structures.CosmeticPaintFunction(f) + v.Data.Function = structures.CosmeticPaintGradientFunction(f) j, _ := json.Marshal(v.Data) diff --git a/internal/api/gql/v3/resolvers/cosmetics/cosmetics.ops.go b/internal/api/gql/v3/resolvers/cosmetics/cosmetics.ops.go index ec898fde..8480f85e 100644 --- a/internal/api/gql/v3/resolvers/cosmetics/cosmetics.ops.go +++ b/internal/api/gql/v3/resolvers/cosmetics/cosmetics.ops.go @@ -69,7 +69,7 @@ func (r *ResolverOps) UpdatePaint(ctx context.Context, obj *model.CosmeticOps, d Priority: 0, Name: def.Name, Data: structures.CosmeticDataPaint{ - Function: structures.CosmeticPaintFunction(def.Function), + Function: structures.CosmeticPaintGradientFunction(def.Function), Color: utils.PointerOf(utils.Color(mainColor)), Stops: stops, Repeat: def.Repeat, diff --git a/internal/api/gql/v3/resolvers/mutation/mutation.cosmetics.go b/internal/api/gql/v3/resolvers/mutation/mutation.cosmetics.go index 9432bdf5..dd7d2b40 100644 --- a/internal/api/gql/v3/resolvers/mutation/mutation.cosmetics.go +++ b/internal/api/gql/v3/resolvers/mutation/mutation.cosmetics.go @@ -58,7 +58,7 @@ func (r *Resolver) CreateCosmeticPaint(ctx context.Context, def model.CosmeticPa Priority: 0, Name: def.Name, Data: structures.CosmeticDataPaint{ - Function: structures.CosmeticPaintFunction(def.Function), + Function: structures.CosmeticPaintGradientFunction(def.Function), Color: utils.PointerOf(utils.Color(mainColor)), Stops: stops, Repeat: def.Repeat, diff --git a/internal/api/gql/v3/schema/cosmetics.gql b/internal/api/gql/v3/schema/cosmetics.gql index 179162be..b7d6b030 100644 --- a/internal/api/gql/v3/schema/cosmetics.gql +++ b/internal/api/gql/v3/schema/cosmetics.gql @@ -42,18 +42,36 @@ type CosmeticPaint implements Cosmetic { name: String! function: CosmeticPaintFunction! + @deprecated(reason: "use the 'gradients' property") color: Int + canvas_size: [Float!] + canvas_repeat: String! + gradients: [CosmeticPaintGradient!]! + shadows: [CosmeticPaintShadow!] + flairs: [CosmeticPaintFlair!] + text: CosmeticPaintText + angle: Int! @deprecated(reason: "use the 'gradients' property") + shape: String @deprecated(reason: "use the 'gradients' property") + image_url: String @deprecated(reason: "use the 'gradients' property") + repeat: Boolean! @deprecated(reason: "use the 'gradients' property") + stops: [CosmeticPaintStop!]! + @deprecated(reason: "use the 'gradients' property") +} + +type CosmeticPaintGradient { + function: CosmeticPaintFunction! + stops: [CosmeticPaintStop!]! angle: Int! - shape: String - image_url: String repeat: Boolean! - stops: [CosmeticPaintStop!]! - shadows: [CosmeticPaintShadow!]! + image_url: String + shape: String + at: [Float!] } type CosmeticPaintStop { at: Float! color: Int! + center_at: [Float!] } type CosmeticPaintShadow { @@ -63,6 +81,34 @@ type CosmeticPaintShadow { color: Int! } +type CosmeticPaintText { + weight: Int + shadows: [CosmeticPaintShadow!] + transform: String + stroke: CosmeticPaintStroke + variant: String +} + +type CosmeticPaintStroke { + color: Int! + width: Float! +} + +type CosmeticPaintFlair { + kind: CosmeticPaintFlairKind! + x_offset: Float! + y_offset: Float! + width: Float! + height: Float! + data: String! +} + +enum CosmeticPaintFlairKind { + IMAGE + VECTOR + TEXT +} + enum CosmeticKind { BADGE PAINT diff --git a/internal/api/rest/v2/routes/cosmetics/cosmetics.go b/internal/api/rest/v2/routes/cosmetics/cosmetics.go index 5a0e6272..e5be45bd 100644 --- a/internal/api/rest/v2/routes/cosmetics/cosmetics.go +++ b/internal/api/rest/v2/routes/cosmetics/cosmetics.go @@ -388,7 +388,7 @@ func (r *Route) generateCosmeticsData(ctx *rest.Ctx, idType string) (*model.Cosm f := strings.Replace(string(paint.Data.Function), "_", "-", 1) f = strings.ToLower(f) - paint.Data.Function = structures.CosmeticPaintFunction(f) + paint.Data.Function = structures.CosmeticPaintGradientFunction(f) b := createPaintResponse(paint.ToRaw(), cos.Users, idType) result.Paints = append(result.Paints, &b) diff --git a/internal/api/rest/v3/docs/docs.go b/internal/api/rest/v3/docs/docs.go index d15ade96..309d9ff5 100644 --- a/internal/api/rest/v3/docs/docs.go +++ b/internal/api/rest/v3/docs/docs.go @@ -391,23 +391,71 @@ const docTemplate = `{ } } }, - "model.CosmeticPaintDropShadow": { + "model.CosmeticPaintCanvasRepeat": { + "type": "string", + "enum": [ + "no-repeat", + "repeat-x", + "repeat-y", + "revert", + "round", + "space" + ], + "x-enum-varnames": [ + "CosmeticPaintCanvasRepeatNone", + "CosmeticPaintCanvasRepeatX", + "CosmeticPaintCanvasRepeatY", + "CosmeticPaintCanvasRepeatRevert", + "CosmeticPaintCanvasRepeatRound", + "CosmeticPaintCanvasRepeatSpace" + ] + }, + "model.CosmeticPaintFlair": { "type": "object", "properties": { - "color": { - "type": "integer" + "data": { + "description": "Base64-encoded image or vector data", + "type": "string" }, - "radius": { + "height": { + "description": "The height of the flair", + "type": "number" + }, + "kind": { + "description": "The kind of sprite", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintFlairKind" + } + ] + }, + "width": { + "description": "The width of the flair", "type": "number" }, "x_offset": { + "description": "The X offset of the flair (%)", "type": "number" }, "y_offset": { + "description": "The Y offset of the flair (%)", "type": "number" } } }, + "model.CosmeticPaintFlairKind": { + "type": "string", + "enum": [ + "IMAGE", + "VECTOR", + "TEXT" + ], + "x-enum-varnames": [ + "CosmeticPaintSpriteKindImage", + "CosmeticPaintSpriteKindVector", + "CosmeticPaintSpriteKindText" + ] + }, "model.CosmeticPaintFunction": { "type": "string", "enum": [ @@ -421,12 +469,62 @@ const docTemplate = `{ "CosmeticPaintFunctionImageURL" ] }, + "model.CosmeticPaintGradient": { + "type": "object", + "properties": { + "angle": { + "description": "The degree angle of the gradient (does not apply if function is URL)", + "type": "integer" + }, + "at": { + "description": "Gradient position (X/Y % values)", + "type": "array", + "items": { + "type": "number" + } + }, + "function": { + "description": "The function used to generate the paint (i.e gradients or an image)", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintFunction" + } + ] + }, + "image_url": { + "description": "For a URL-based paint, the URL to an image", + "type": "string" + }, + "repeat": { + "description": "Whether or not the gradient repeats outside its original area", + "type": "boolean" + }, + "shape": { + "description": "For a radial gradient, the shape of the gradient", + "type": "string" + }, + "stops": { + "description": "Gradient stops, a list of positions and colors", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintGradientStop" + } + } + } + }, "model.CosmeticPaintGradientStop": { "type": "object", "properties": { "at": { "type": "number" }, + "center_at": { + "description": "the center position for the gradient. X/Y % values (for radial gradients only)", + "type": "array", + "items": { + "type": "number" + } + }, "color": { "type": "integer" } @@ -436,12 +534,35 @@ const docTemplate = `{ "type": "object", "properties": { "angle": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "type": "integer" }, + "canvas_repeat": { + "description": "The repeat mode of the canvas", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" + } + ] + }, + "canvas_size": { + "description": "The canvas size for the paint", + "type": "array", + "items": { + "type": "number" + } + }, "color": { "type": "integer" }, + "flairs": { + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintFlair" + } + }, "function": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "enum": [ "LINEAR_GRADIENT", "RADIAL_GRADIENT", @@ -453,35 +574,127 @@ const docTemplate = `{ } ] }, + "gradients": { + "description": "A list of gradients. There may be any amount, which can be stacked onto each other", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintGradient" + } + }, "id": { "type": "string" }, "image_url": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "type": "string" }, "name": { "type": "string" }, "repeat": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "type": "boolean" }, "shadows": { + "description": "A list of shadows. There may be any amount, which can be stacked onto each other", "type": "array", "items": { - "$ref": "#/definitions/model.CosmeticPaintDropShadow" + "$ref": "#/definitions/model.CosmeticPaintShadow" } }, "shape": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "type": "string" }, "stops": { + "description": "deprecated: use ` + "`" + `gradients` + "`" + `", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop" } + }, + "text": { + "$ref": "#/definitions/model.CosmeticPaintText" } } }, + "model.CosmeticPaintShadow": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "radius": { + "type": "number" + }, + "x_offset": { + "type": "number" + }, + "y_offset": { + "type": "number" + } + } + }, + "model.CosmeticPaintStroke": { + "type": "object", + "properties": { + "color": { + "description": "Stroke color", + "type": "integer" + }, + "width": { + "description": "Stroke width", + "type": "number" + } + } + }, + "model.CosmeticPaintText": { + "type": "object", + "properties": { + "shadows": { + "description": "Shadows applied to the text", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintShadow" + } + }, + "stroke": { + "description": "Text stroke", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintStroke" + } + ] + }, + "transform": { + "description": "Text tranformation", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintTextTransform" + } + ] + }, + "variant": { + "description": "(css) font variant property. non-standard", + "type": "string" + }, + "weight": { + "description": "Weight multiplier for the text. Defaults to 9x is not specified", + "type": "integer" + } + } + }, + "model.CosmeticPaintTextTransform": { + "type": "string", + "enum": [ + "uppercase", + "lowercase" + ], + "x-enum-varnames": [ + "CosmeticPaintTextTransformUppercase", + "CosmeticPaintTextTransformLowercase" + ] + }, "model.EmoteFlagsModel": { "type": "integer", "enum": [ diff --git a/internal/api/rest/v3/docs/swagger.json b/internal/api/rest/v3/docs/swagger.json index 3f5da779..a16cb88b 100644 --- a/internal/api/rest/v3/docs/swagger.json +++ b/internal/api/rest/v3/docs/swagger.json @@ -387,23 +387,71 @@ } } }, - "model.CosmeticPaintDropShadow": { + "model.CosmeticPaintCanvasRepeat": { + "type": "string", + "enum": [ + "no-repeat", + "repeat-x", + "repeat-y", + "revert", + "round", + "space" + ], + "x-enum-varnames": [ + "CosmeticPaintCanvasRepeatNone", + "CosmeticPaintCanvasRepeatX", + "CosmeticPaintCanvasRepeatY", + "CosmeticPaintCanvasRepeatRevert", + "CosmeticPaintCanvasRepeatRound", + "CosmeticPaintCanvasRepeatSpace" + ] + }, + "model.CosmeticPaintFlair": { "type": "object", "properties": { - "color": { - "type": "integer" + "data": { + "description": "Base64-encoded image or vector data", + "type": "string" }, - "radius": { + "height": { + "description": "The height of the flair", + "type": "number" + }, + "kind": { + "description": "The kind of sprite", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintFlairKind" + } + ] + }, + "width": { + "description": "The width of the flair", "type": "number" }, "x_offset": { + "description": "The X offset of the flair (%)", "type": "number" }, "y_offset": { + "description": "The Y offset of the flair (%)", "type": "number" } } }, + "model.CosmeticPaintFlairKind": { + "type": "string", + "enum": [ + "IMAGE", + "VECTOR", + "TEXT" + ], + "x-enum-varnames": [ + "CosmeticPaintSpriteKindImage", + "CosmeticPaintSpriteKindVector", + "CosmeticPaintSpriteKindText" + ] + }, "model.CosmeticPaintFunction": { "type": "string", "enum": [ @@ -417,12 +465,62 @@ "CosmeticPaintFunctionImageURL" ] }, + "model.CosmeticPaintGradient": { + "type": "object", + "properties": { + "angle": { + "description": "The degree angle of the gradient (does not apply if function is URL)", + "type": "integer" + }, + "at": { + "description": "Gradient position (X/Y % values)", + "type": "array", + "items": { + "type": "number" + } + }, + "function": { + "description": "The function used to generate the paint (i.e gradients or an image)", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintFunction" + } + ] + }, + "image_url": { + "description": "For a URL-based paint, the URL to an image", + "type": "string" + }, + "repeat": { + "description": "Whether or not the gradient repeats outside its original area", + "type": "boolean" + }, + "shape": { + "description": "For a radial gradient, the shape of the gradient", + "type": "string" + }, + "stops": { + "description": "Gradient stops, a list of positions and colors", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintGradientStop" + } + } + } + }, "model.CosmeticPaintGradientStop": { "type": "object", "properties": { "at": { "type": "number" }, + "center_at": { + "description": "the center position for the gradient. X/Y % values (for radial gradients only)", + "type": "array", + "items": { + "type": "number" + } + }, "color": { "type": "integer" } @@ -432,12 +530,35 @@ "type": "object", "properties": { "angle": { + "description": "deprecated: use `gradients`", "type": "integer" }, + "canvas_repeat": { + "description": "The repeat mode of the canvas", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" + } + ] + }, + "canvas_size": { + "description": "The canvas size for the paint", + "type": "array", + "items": { + "type": "number" + } + }, "color": { "type": "integer" }, + "flairs": { + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintFlair" + } + }, "function": { + "description": "deprecated: use `gradients`", "enum": [ "LINEAR_GRADIENT", "RADIAL_GRADIENT", @@ -449,35 +570,127 @@ } ] }, + "gradients": { + "description": "A list of gradients. There may be any amount, which can be stacked onto each other", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintGradient" + } + }, "id": { "type": "string" }, "image_url": { + "description": "deprecated: use `gradients`", "type": "string" }, "name": { "type": "string" }, "repeat": { + "description": "deprecated: use `gradients`", "type": "boolean" }, "shadows": { + "description": "A list of shadows. There may be any amount, which can be stacked onto each other", "type": "array", "items": { - "$ref": "#/definitions/model.CosmeticPaintDropShadow" + "$ref": "#/definitions/model.CosmeticPaintShadow" } }, "shape": { + "description": "deprecated: use `gradients`", "type": "string" }, "stops": { + "description": "deprecated: use `gradients`", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop" } + }, + "text": { + "$ref": "#/definitions/model.CosmeticPaintText" } } }, + "model.CosmeticPaintShadow": { + "type": "object", + "properties": { + "color": { + "type": "integer" + }, + "radius": { + "type": "number" + }, + "x_offset": { + "type": "number" + }, + "y_offset": { + "type": "number" + } + } + }, + "model.CosmeticPaintStroke": { + "type": "object", + "properties": { + "color": { + "description": "Stroke color", + "type": "integer" + }, + "width": { + "description": "Stroke width", + "type": "number" + } + } + }, + "model.CosmeticPaintText": { + "type": "object", + "properties": { + "shadows": { + "description": "Shadows applied to the text", + "type": "array", + "items": { + "$ref": "#/definitions/model.CosmeticPaintShadow" + } + }, + "stroke": { + "description": "Text stroke", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintStroke" + } + ] + }, + "transform": { + "description": "Text tranformation", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintTextTransform" + } + ] + }, + "variant": { + "description": "(css) font variant property. non-standard", + "type": "string" + }, + "weight": { + "description": "Weight multiplier for the text. Defaults to 9x is not specified", + "type": "integer" + } + } + }, + "model.CosmeticPaintTextTransform": { + "type": "string", + "enum": [ + "uppercase", + "lowercase" + ], + "x-enum-varnames": [ + "CosmeticPaintTextTransformUppercase", + "CosmeticPaintTextTransformLowercase" + ] + }, "model.EmoteFlagsModel": { "type": "integer", "enum": [ diff --git a/k8s/production.template.yaml b/k8s/production.template.yaml index d9c7d8b5..c772b385 100644 --- a/k8s/production.template.yaml +++ b/k8s/production.template.yaml @@ -52,11 +52,11 @@ spec: fieldPath: metadata.name resources: limits: - cpu: 1000m - memory: 1792Mi + cpu: 1500m + memory: 3250Mi requests: - cpu: 750m - memory: 1792Mi + cpu: 1250m + memory: 3Gi volumeMounts: - name: config mountPath: /app/config.yaml @@ -169,7 +169,7 @@ data: max_page: 25 buckets: - gql_v3: [50, 2] + gql_v3: [85, 4] gql_v2: [5, 3] image_processing: [4, 60] emotes: @@ -203,27 +203,27 @@ data: beta_paint_entitlement_id: 63bdff9723e3c08ccb76494c chatterino: - version: 7.4.3 + version: 7.4.4 stable: win: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Installer.exe - portable_download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Portable.zip - update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Installer.exe + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Installer.exe + portable_download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Portable.zip + update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Installer.exe linux: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7-x86_64.AppImage + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7-x86_64.AppImage macos: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.dmg - update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.dmg + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.dmg + update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.dmg beta: win: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Installer.exe - portable_download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Portable.zip - update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.Installer.exe + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Installer.exe + portable_download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Portable.zip + update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.Installer.exe linux: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7-x86_64.AppImage + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7-x86_64.AppImage macos: - download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.dmg - update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.3/Chatterino7.dmg + download: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.dmg + update_exe: https://github.com/SevenTV/chatterino7/releases/download/v7.4.4/Chatterino7.dmg --- apiVersion: networking.k8s.io/v1 From 87ef25a3b338e8c2dc4137077d87beedbe44bace Mon Sep 17 00:00:00 2001 From: Anatole Date: Sat, 20 May 2023 23:51:59 +0200 Subject: [PATCH 2/3] remove deprecation notes so lint doesnt fail --- data/model/cosmetic.model.go | 12 ++++++------ go.mod | 2 +- go.sum | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/data/model/cosmetic.model.go b/data/model/cosmetic.model.go index f18cc9f2..fbed07fd 100644 --- a/data/model/cosmetic.model.go +++ b/data/model/cosmetic.model.go @@ -40,17 +40,17 @@ type CosmeticPaintModel struct { Shadows []CosmeticPaintShadow `json:"shadows"` Flairs []CosmeticPaintFlair `json:"flairs"` Text *CosmeticPaintText `json:"text"` - // deprecated: use `gradients` + // use `gradients` Function CosmeticPaintFunction `json:"function" enums:"LINEAR_GRADIENT,RADIAL_GRADIENT,URL"` - // deprecated: use `gradients` + // use `gradients` Repeat bool `json:"repeat"` - // deprecated: use `gradients` + // use `gradients` Angle int32 `json:"angle"` - // deprecated: use `gradients` + // use `gradients` Shape string `json:"shape"` - // deprecated: use `gradients` + // use `gradients` ImageURL string `json:"image_url"` - // deprecated: use `gradients` + // use `gradients` Stops []CosmeticPaintGradientStop `json:"stops"` } diff --git a/go.mod b/go.mod index 32ab520a..8f93a44b 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v1.14.0 - github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86 + github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680 github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 github.com/seventv/message-queue/go v0.0.0-20220721124044-9fd23bda9643 diff --git a/go.sum b/go.sum index 4a9bd4e3..430678bf 100644 --- a/go.sum +++ b/go.sum @@ -338,6 +338,8 @@ github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86 h1:h2a2qf7GKuhcFt9ICgPZ683WQriXz2rMwahJDc8iGHY= github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= +github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680 h1:qZS9KubLRpQ7FJlF65t9xjzQCcQEaxFv+/W+PJmb/HY= +github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 h1:IqWrtt/yob45YnOQ5Wwkbf8qP22eKVtg0WzfyEkGnFg= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48/go.mod h1:T+ldp0YQe03s44+A5HHHI/jB3ZmWqOIaNouEqAS+1Dk= github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 h1:iU3wWepRTbkNoTAPR23m6TAW6Yb9pOMCYVr0K++OBAw= From 272c49d15837963e7f72682d72fd95b3114beec1 Mon Sep 17 00:00:00 2001 From: Anatole Date: Fri, 26 May 2023 10:16:33 +0200 Subject: [PATCH 3/3] update gradient-local fields --- data/model/cosmetic.model.go | 35 +++++++++--------- data/model/modelgql/cosmetic-gql.model.go | 12 +++--- go.mod | 2 +- go.sum | 4 +- internal/api/gql/v3/schema/cosmetics.gql | 6 +-- internal/api/rest/v3/docs/docs.go | 45 +++++++++++------------ internal/api/rest/v3/docs/swagger.json | 45 +++++++++++------------ 7 files changed, 73 insertions(+), 76 deletions(-) diff --git a/data/model/cosmetic.model.go b/data/model/cosmetic.model.go index fbed07fd..c6771260 100644 --- a/data/model/cosmetic.model.go +++ b/data/model/cosmetic.model.go @@ -27,14 +27,9 @@ const ( ) type CosmeticPaintModel struct { - ID primitive.ObjectID `json:"id"` - Name string `json:"name"` - Color *int32 `json:"color"` - // The canvas size for the paint - CanvasSize [2]float64 `json:"canvas_size" bson:"canvas_size"` - // The repeat mode of the canvas - CanvasRepeat CosmeticPaintCanvasRepeat `json:"canvas_repeat" bson:"canvas_repeat"` - // A list of gradients. There may be any amount, which can be stacked onto each other + ID primitive.ObjectID `json:"id"` + Name string `json:"name"` + Color *int32 `json:"color"` Gradients []CosmeticPaintGradient `json:"gradients"` // A list of shadows. There may be any amount, which can be stacked onto each other Shadows []CosmeticPaintShadow `json:"shadows"` @@ -57,6 +52,13 @@ type CosmeticPaintModel struct { type CosmeticPaintGradient struct { // The function used to generate the paint (i.e gradients or an image) Function CosmeticPaintFunction `json:"function" bson:"function"` + // The repeat mode of the canvas + CanvasRepeat CosmeticPaintCanvasRepeat `json:"canvas_repeat" bson:"canvas_repeat"` + // The canvas size for the paint + Size [2]float64 `json:"canvas_size" bson:"canvas_size"` + // Gradient position (X/Y % values) + At [2]float64 `json:"at,omitempty" bson:"at,omitempty"` + // A list of gradients. There may be any amount, which can be stacked onto each other // Gradient stops, a list of positions and colors Stops []CosmeticPaintGradientStop `json:"stops" bson:"stops"` // For a URL-based paint, the URL to an image @@ -67,9 +69,6 @@ type CosmeticPaintGradient struct { Angle int32 `json:"angle,omitempty" bson:"angle,omitempty"` // Whether or not the gradient repeats outside its original area Repeat bool `json:"repeat" bson:"repeat"` - - // Gradient position (X/Y % values) - At [2]float64 `json:"at,omitempty" bson:"at,omitempty"` } type CosmeticPaintFunction string @@ -204,15 +203,15 @@ func (x *modelizer) Paint(v structures.Cosmetic[structures.CosmeticDataPaint]) C } return CosmeticPaintModel{ - ID: v.ID, - Name: v.Name, - Function: CosmeticPaintFunction(v.Data.Function), - Color: color, - CanvasSize: v.Data.CanvasSize, - CanvasRepeat: CosmeticPaintCanvasRepeat(v.Data.CanvasRepeat), + ID: v.ID, + Name: v.Name, + Function: CosmeticPaintFunction(v.Data.Function), + Color: color, Gradients: utils.Map(v.Data.Gradients, func(x structures.CosmeticPaintGradient) CosmeticPaintGradient { return CosmeticPaintGradient{ - Function: CosmeticPaintFunction(x.Function), + Function: CosmeticPaintFunction(x.Function), + CanvasRepeat: CosmeticPaintCanvasRepeat(x.CanvasRepeat), + Size: x.Size, Stops: utils.Map(x.Stops, func(x structures.CosmeticPaintGradientStop) CosmeticPaintGradientStop { return CosmeticPaintGradientStop{ At: x.At, diff --git a/data/model/modelgql/cosmetic-gql.model.go b/data/model/modelgql/cosmetic-gql.model.go index 57098576..983a16eb 100644 --- a/data/model/modelgql/cosmetic-gql.model.go +++ b/data/model/modelgql/cosmetic-gql.model.go @@ -13,11 +13,9 @@ func CosmeticPaint(xm model.CosmeticPaintModel) *gql_model.CosmeticPaint { } return &gql_model.CosmeticPaint{ - ID: xm.ID, - Name: xm.Name, - Color: color, - CanvasSize: xm.CanvasSize[:], - CanvasRepeat: string(xm.CanvasRepeat), + ID: xm.ID, + Name: xm.Name, + Color: color, Shadows: utils.Map(xm.Shadows, func(x model.CosmeticPaintShadow) *gql_model.CosmeticPaintShadow { return &gql_model.CosmeticPaintShadow{ XOffset: x.OffsetX, @@ -28,7 +26,9 @@ func CosmeticPaint(xm model.CosmeticPaintModel) *gql_model.CosmeticPaint { }), Gradients: utils.Map(xm.Gradients, func(x model.CosmeticPaintGradient) *gql_model.CosmeticPaintGradient { return &gql_model.CosmeticPaintGradient{ - Function: gql_model.CosmeticPaintFunction(x.Function), + Function: gql_model.CosmeticPaintFunction(x.Function), + CanvasRepeat: string(x.CanvasRepeat), + Size: x.Size[:], Stops: utils.Map(x.Stops, func(x model.CosmeticPaintGradientStop) *gql_model.CosmeticPaintStop { return &gql_model.CosmeticPaintStop{ At: x.At, diff --git a/go.mod b/go.mod index 8f93a44b..b84b8be7 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/json-iterator/go v1.1.12 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/prometheus/client_golang v1.14.0 - github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680 + github.com/seventv/common v0.0.0-20230523123640-a3d24613572e github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 github.com/seventv/message-queue/go v0.0.0-20220721124044-9fd23bda9643 diff --git a/go.sum b/go.sum index 430678bf..ce7fe097 100644 --- a/go.sum +++ b/go.sum @@ -336,10 +336,10 @@ github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee h1:8Iv5m6xEo1NR1Avp github.com/savsgio/gotils v0.0.0-20230208104028-c358bd845dee/go.mod h1:qwtSXrKuJh/zsFQ12yEE89xfCrGKK63Rr7ctU/uCo4g= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= -github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86 h1:h2a2qf7GKuhcFt9ICgPZ683WQriXz2rMwahJDc8iGHY= -github.com/seventv/common v0.0.0-20230520140750-fd55929f5a86/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680 h1:qZS9KubLRpQ7FJlF65t9xjzQCcQEaxFv+/W+PJmb/HY= github.com/seventv/common v0.0.0-20230520215117-329d4f6c8680/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= +github.com/seventv/common v0.0.0-20230523123640-a3d24613572e h1:T9UFnNeKoPcCuisHGQfPFuepJAPkf55OvH1COfLU9CA= +github.com/seventv/common v0.0.0-20230523123640-a3d24613572e/go.mod h1:jHHFe3uNMyzb/ReDqMvaI/A1euvV/PW/G+2PhcWQqWw= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48 h1:IqWrtt/yob45YnOQ5Wwkbf8qP22eKVtg0WzfyEkGnFg= github.com/seventv/compactdisc v0.0.0-20221006190906-ccfe99954e48/go.mod h1:T+ldp0YQe03s44+A5HHHI/jB3ZmWqOIaNouEqAS+1Dk= github.com/seventv/image-processor/go v0.0.0-20221128171540-d050701ac324 h1:iU3wWepRTbkNoTAPR23m6TAW6Yb9pOMCYVr0K++OBAw= diff --git a/internal/api/gql/v3/schema/cosmetics.gql b/internal/api/gql/v3/schema/cosmetics.gql index b7d6b030..c07b3f6c 100644 --- a/internal/api/gql/v3/schema/cosmetics.gql +++ b/internal/api/gql/v3/schema/cosmetics.gql @@ -44,8 +44,6 @@ type CosmeticPaint implements Cosmetic { function: CosmeticPaintFunction! @deprecated(reason: "use the 'gradients' property") color: Int - canvas_size: [Float!] - canvas_repeat: String! gradients: [CosmeticPaintGradient!]! shadows: [CosmeticPaintShadow!] flairs: [CosmeticPaintFlair!] @@ -60,12 +58,14 @@ type CosmeticPaint implements Cosmetic { type CosmeticPaintGradient { function: CosmeticPaintFunction! + canvas_repeat: String! + size: [Float!] + at: [Float!] stops: [CosmeticPaintStop!]! angle: Int! repeat: Boolean! image_url: String shape: String - at: [Float!] } type CosmeticPaintStop { diff --git a/internal/api/rest/v3/docs/docs.go b/internal/api/rest/v3/docs/docs.go index 309d9ff5..fe556ec5 100644 --- a/internal/api/rest/v3/docs/docs.go +++ b/internal/api/rest/v3/docs/docs.go @@ -483,6 +483,21 @@ const docTemplate = `{ "type": "number" } }, + "canvas_repeat": { + "description": "The repeat mode of the canvas", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" + } + ] + }, + "canvas_size": { + "description": "The canvas size for the paint", + "type": "array", + "items": { + "type": "number" + } + }, "function": { "description": "The function used to generate the paint (i.e gradients or an image)", "allOf": [ @@ -504,7 +519,7 @@ const docTemplate = `{ "type": "string" }, "stops": { - "description": "Gradient stops, a list of positions and colors", + "description": "A list of gradients. There may be any amount, which can be stacked onto each other\nGradient stops, a list of positions and colors", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop" @@ -534,24 +549,9 @@ const docTemplate = `{ "type": "object", "properties": { "angle": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "type": "integer" }, - "canvas_repeat": { - "description": "The repeat mode of the canvas", - "allOf": [ - { - "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" - } - ] - }, - "canvas_size": { - "description": "The canvas size for the paint", - "type": "array", - "items": { - "type": "number" - } - }, "color": { "type": "integer" }, @@ -562,7 +562,7 @@ const docTemplate = `{ } }, "function": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "enum": [ "LINEAR_GRADIENT", "RADIAL_GRADIENT", @@ -575,7 +575,6 @@ const docTemplate = `{ ] }, "gradients": { - "description": "A list of gradients. There may be any amount, which can be stacked onto each other", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradient" @@ -585,14 +584,14 @@ const docTemplate = `{ "type": "string" }, "image_url": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "type": "string" }, "name": { "type": "string" }, "repeat": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "type": "boolean" }, "shadows": { @@ -603,11 +602,11 @@ const docTemplate = `{ } }, "shape": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "type": "string" }, "stops": { - "description": "deprecated: use ` + "`" + `gradients` + "`" + `", + "description": "use ` + "`" + `gradients` + "`" + `", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop" diff --git a/internal/api/rest/v3/docs/swagger.json b/internal/api/rest/v3/docs/swagger.json index a16cb88b..516e7dc1 100644 --- a/internal/api/rest/v3/docs/swagger.json +++ b/internal/api/rest/v3/docs/swagger.json @@ -479,6 +479,21 @@ "type": "number" } }, + "canvas_repeat": { + "description": "The repeat mode of the canvas", + "allOf": [ + { + "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" + } + ] + }, + "canvas_size": { + "description": "The canvas size for the paint", + "type": "array", + "items": { + "type": "number" + } + }, "function": { "description": "The function used to generate the paint (i.e gradients or an image)", "allOf": [ @@ -500,7 +515,7 @@ "type": "string" }, "stops": { - "description": "Gradient stops, a list of positions and colors", + "description": "A list of gradients. There may be any amount, which can be stacked onto each other\nGradient stops, a list of positions and colors", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop" @@ -530,24 +545,9 @@ "type": "object", "properties": { "angle": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "type": "integer" }, - "canvas_repeat": { - "description": "The repeat mode of the canvas", - "allOf": [ - { - "$ref": "#/definitions/model.CosmeticPaintCanvasRepeat" - } - ] - }, - "canvas_size": { - "description": "The canvas size for the paint", - "type": "array", - "items": { - "type": "number" - } - }, "color": { "type": "integer" }, @@ -558,7 +558,7 @@ } }, "function": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "enum": [ "LINEAR_GRADIENT", "RADIAL_GRADIENT", @@ -571,7 +571,6 @@ ] }, "gradients": { - "description": "A list of gradients. There may be any amount, which can be stacked onto each other", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradient" @@ -581,14 +580,14 @@ "type": "string" }, "image_url": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "type": "string" }, "name": { "type": "string" }, "repeat": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "type": "boolean" }, "shadows": { @@ -599,11 +598,11 @@ } }, "shape": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "type": "string" }, "stops": { - "description": "deprecated: use `gradients`", + "description": "use `gradients`", "type": "array", "items": { "$ref": "#/definitions/model.CosmeticPaintGradientStop"