From 6535034d87988bca718ef740bdbf6041b4c15124 Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Wed, 18 Sep 2019 16:27:48 +0200 Subject: [PATCH] Add full support for handle on module/chart/page --- api/compose/spec.json | 54 ++++++++++++++++++++++++++++++++++ api/compose/spec/chart.json | 18 ++++++++++++ api/compose/spec/module.json | 18 ++++++++++++ api/compose/spec/page.json | 18 ++++++++++++ compose/repository/chart.go | 40 ++++++++++++------------- compose/repository/module.go | 3 ++ compose/repository/page.go | 54 +++++++++++++--------------------- compose/rest/chart.go | 3 ++ compose/rest/module.go | 3 ++ compose/rest/page.go | 3 ++ compose/rest/request/chart.go | 15 ++++++++++ compose/rest/request/module.go | 15 ++++++++++ compose/rest/request/page.go | 15 ++++++++++ compose/service/chart.go | 1 + compose/service/module.go | 1 + compose/service/page.go | 17 ++++++++--- compose/types/chart.go | 1 + compose/types/module.go | 1 + compose/types/page.go | 1 + docs/compose/README.md | 9 ++++++ 20 files changed, 231 insertions(+), 59 deletions(-) diff --git a/api/compose/spec.json b/api/compose/spec.json index c0f4947c9..226a76d29 100644 --- a/api/compose/spec.json +++ b/api/compose/spec.json @@ -207,6 +207,12 @@ "required": false, "title": "Search query" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Search by handle" + }, { "name": "page", "type": "uint", @@ -247,6 +253,12 @@ "required": true, "title": "Title" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Handle" + }, { "type": "string", "name": "description", @@ -324,6 +336,12 @@ "required": true, "title": "Title" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Handle" + }, { "type": "string", "name": "description", @@ -456,6 +474,12 @@ "required": false, "title": "Search by name" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Search by handle" + }, { "name": "page", "type": "uint", @@ -484,6 +508,12 @@ "required": true, "title": "Module Name" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Module handle" + }, { "type": "types.ModuleFieldSet", "name": "fields", @@ -536,6 +566,12 @@ "required": true, "title": "Module Name" }, + { + "type": "string", + "name": "handle", + "required": false, + "title": "Module Handle" + }, { "type": "types.ModuleFieldSet", "name": "fields", @@ -928,6 +964,12 @@ "title": "Search query to match against charts", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Search charts by handle", + "type": "string" + }, { "name": "page", "type": "uint", @@ -961,6 +1003,12 @@ "title": "Chart name", "type": "string", "required": true + }, + { + "name": "handle", + "title": "Chart handle", + "type": "string", + "required": false } ] } @@ -1008,6 +1056,12 @@ "type": "string", "required": true }, + { + "name": "handle", + "title": "Chart handle", + "type": "string", + "required": false + }, { "type": "*time.Time", "name": "updatedAt", diff --git a/api/compose/spec/chart.json b/api/compose/spec/chart.json index d2e5dc902..dd9b96161 100644 --- a/api/compose/spec/chart.json +++ b/api/compose/spec/chart.json @@ -36,6 +36,12 @@ "title": "Search query to match against charts", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Search charts by handle", + "type": "string" + }, { "name": "page", "required": false, @@ -69,6 +75,12 @@ "required": true, "title": "Chart name", "type": "string" + }, + { + "name": "handle", + "required": false, + "title": "Chart handle", + "type": "string" } ] } @@ -116,6 +128,12 @@ "title": "Chart name", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Chart handle", + "type": "string" + }, { "name": "updatedAt", "required": false, diff --git a/api/compose/spec/module.json b/api/compose/spec/module.json index 9928918e6..550f03061 100644 --- a/api/compose/spec/module.json +++ b/api/compose/spec/module.json @@ -44,6 +44,12 @@ "title": "Search by name", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Search by handle", + "type": "string" + }, { "name": "page", "required": false, @@ -72,6 +78,12 @@ "title": "Module Name", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Module handle", + "type": "string" + }, { "name": "fields", "required": true, @@ -124,6 +136,12 @@ "title": "Module Name", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Module Handle", + "type": "string" + }, { "name": "fields", "required": true, diff --git a/api/compose/spec/page.json b/api/compose/spec/page.json index ab63344c9..4a7679193 100644 --- a/api/compose/spec/page.json +++ b/api/compose/spec/page.json @@ -42,6 +42,12 @@ "title": "Search query", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Search by handle", + "type": "string" + }, { "name": "page", "required": false, @@ -82,6 +88,12 @@ "title": "Title", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Handle", + "type": "string" + }, { "name": "description", "required": false, @@ -159,6 +171,12 @@ "title": "Title", "type": "string" }, + { + "name": "handle", + "required": false, + "title": "Handle", + "type": "string" + }, { "name": "description", "required": false, diff --git a/compose/repository/chart.go b/compose/repository/chart.go index 6ed0423f1..0dbe76d21 100644 --- a/compose/repository/chart.go +++ b/compose/repository/chart.go @@ -2,6 +2,7 @@ package repository import ( "context" + "strings" "time" "github.com/titpetric/factory" @@ -61,35 +62,28 @@ func (r chart) query() squirrel.SelectBuilder { } func (r chart) FindByID(namespaceID, chartID uint64) (*types.Chart, error) { - var ( - query = r.query(). - Columns(r.columns()...). - Where("id = ?", chartID) - - c = &types.Chart{} - ) - - if namespaceID > 0 { - query = query.Where("rel_namespace = ?", namespaceID) - } - - return c, isFound(r.fetchOne(c, query), c.ID > 0, ErrChartNotFound) + return r.findOneBy(namespaceID, "id", chartID) } func (r chart) FindByHandle(namespaceID uint64, handle string) (*types.Chart, error) { - var ( - query = r.query(). - Columns(r.columns()...). - Where("handle = ?", handle) + return r.findOneBy(namespaceID, "LOWER(handle)", strings.ToLower(strings.TrimSpace(handle))) +} - c = &types.Chart{} +func (r chart) findOneBy(namespaceID uint64, field string, value interface{}) (*types.Chart, error) { + var c = &types.Chart{} + + err := r.findOneInNamespaceBy( + namespaceID, + r.query().Columns(r.columns()...), + squirrel.Eq{field: value}, + c, ) - if namespaceID > 0 { - query = query.Where("rel_namespace = ?", namespaceID) + if err == nil && c.ID == 0 { + return nil, ErrChartNotFound } - return c, isFound(r.fetchOne(c, query), c.ID > 0, ErrChartNotFound) + return c, nil } func (r chart) Find(filter types.ChartFilter) (set types.ChartSet, f types.ChartFilter, err error) { @@ -106,6 +100,10 @@ func (r chart) Find(filter types.ChartFilter) (set types.ChartSet, f types.Chart query = query.Where("name like ?", q) } + if f.Handle != "" { + query = query.Where("LOWER(handle) = ?", strings.ToLower(f.Handle)) + } + if f.Count, err = r.count(query); err != nil || f.Count == 0 { return } diff --git a/compose/repository/module.go b/compose/repository/module.go index 69bf8bb37..16f31da48 100644 --- a/compose/repository/module.go +++ b/compose/repository/module.go @@ -117,7 +117,10 @@ func (r module) Find(filter types.ModuleFilter) (set types.ModuleSet, f types.Mo if f.Name != "" { query = query.Where("LOWER(name) = ?", strings.ToLower(f.Name)) + } + if f.Handle != "" { + query = query.Where("LOWER(handle) = ?", strings.ToLower(f.Handle)) } if f.Count, err = r.count(query); err != nil || f.Count == 0 { diff --git a/compose/repository/page.go b/compose/repository/page.go index c899bcd61..6f54f28e2 100644 --- a/compose/repository/page.go +++ b/compose/repository/page.go @@ -2,6 +2,7 @@ package repository import ( "context" + "strings" "time" "github.com/titpetric/factory" @@ -67,51 +68,32 @@ func (r page) query() squirrel.SelectBuilder { } func (r page) FindByID(namespaceID, pageID uint64) (*types.Page, error) { - var ( - query = r.query(). - Columns(r.columns()...). - Where("id = ?", pageID) - - c = &types.Page{} - ) - - if namespaceID > 0 { - query = query.Where("rel_namespace = ?", namespaceID) - } - - return c, isFound(r.fetchOne(c, query), c.ID > 0, ErrPageNotFound) + return r.findOneBy(namespaceID, "id", pageID) } func (r page) FindByHandle(namespaceID uint64, handle string) (*types.Page, error) { - var ( - query = r.query(). - Columns(r.columns()...). - Where("handle = ?", handle) - - c = &types.Page{} - ) - - if namespaceID > 0 { - query = query.Where("rel_namespace = ?", namespaceID) - } - - return c, isFound(r.fetchOne(c, query), c.ID > 0, ErrPageNotFound) + return r.findOneBy(namespaceID, "handle", handle) } func (r page) FindByModuleID(namespaceID, moduleID uint64) (*types.Page, error) { - var ( - query = r.query(). - Columns(r.columns()...). - Where("rel_module = ?", moduleID) + return r.findOneBy(namespaceID, "rel_module", moduleID) +} - c = &types.Page{} +func (r page) findOneBy(namespaceID uint64, field string, value interface{}) (*types.Page, error) { + var p = &types.Page{} + + err := r.findOneInNamespaceBy( + namespaceID, + r.query().Columns(r.columns()...), + squirrel.Eq{field: value}, + p, ) - if namespaceID > 0 { - query = query.Where("rel_namespace = ?", namespaceID) + if err == nil && p.ID == 0 { + return nil, ErrPageNotFound } - return c, isFound(r.fetchOne(c, query), c.ID > 0, ErrPageNotFound) + return p, nil } func (r page) Find(filter types.PageFilter) (set types.PageSet, f types.PageFilter, err error) { @@ -129,6 +111,10 @@ func (r page) Find(filter types.PageFilter) (set types.PageSet, f types.PageFilt query = query.Where("self_id = 0") } + if f.Handle != "" { + query = query.Where("LOWER(handle) = ?", strings.ToLower(f.Handle)) + } + if f.Query != "" { q := "%" + f.Query + "%" query = query.Where("title LIKE ? OR description LIKE ?", q, q) diff --git a/compose/rest/chart.go b/compose/rest/chart.go index d2b7ebd05..577613dc8 100644 --- a/compose/rest/chart.go +++ b/compose/rest/chart.go @@ -52,6 +52,7 @@ func (ctrl Chart) List(ctx context.Context, r *request.ChartList) (interface{}, f := types.ChartFilter{ NamespaceID: r.NamespaceID, + Handle: r.Handle, Query: r.Query, PerPage: r.PerPage, Page: r.Page, @@ -66,6 +67,7 @@ func (ctrl Chart) Create(ctx context.Context, r *request.ChartCreate) (interface mod := &types.Chart{ NamespaceID: r.NamespaceID, Name: r.Name, + Handle: r.Handle, } if err = r.Config.Unmarshal(&mod.Config); err != nil { @@ -88,6 +90,7 @@ func (ctrl Chart) Update(ctx context.Context, r *request.ChartUpdate) (interface mod = &types.Chart{ ID: r.ChartID, Name: r.Name, + Handle: r.Handle, NamespaceID: r.NamespaceID, UpdatedAt: r.UpdatedAt, } diff --git a/compose/rest/module.go b/compose/rest/module.go index 00db1318b..fde7bbd40 100644 --- a/compose/rest/module.go +++ b/compose/rest/module.go @@ -73,6 +73,7 @@ func (ctrl *Module) List(ctx context.Context, r *request.ModuleList) (interface{ NamespaceID: r.NamespaceID, Query: r.Query, Name: r.Name, + Handle: r.Handle, PerPage: r.PerPage, Page: r.Page, } @@ -92,6 +93,7 @@ func (ctrl *Module) Create(ctx context.Context, r *request.ModuleCreate) (interf mod = &types.Module{ NamespaceID: r.NamespaceID, Name: r.Name, + Handle: r.Handle, Fields: r.Fields, Meta: r.Meta, } @@ -108,6 +110,7 @@ func (ctrl *Module) Update(ctx context.Context, r *request.ModuleUpdate) (interf ID: r.ModuleID, NamespaceID: r.NamespaceID, Name: r.Name, + Handle: r.Handle, Fields: r.Fields, Meta: r.Meta, UpdatedAt: r.UpdatedAt, diff --git a/compose/rest/page.go b/compose/rest/page.go index e4a9bad83..468980d25 100644 --- a/compose/rest/page.go +++ b/compose/rest/page.go @@ -54,6 +54,7 @@ func (ctrl *Page) List(ctx context.Context, r *request.PageList) (interface{}, e NamespaceID: r.NamespaceID, ParentID: r.SelfID, + Handle: r.Handle, Query: r.Query, PerPage: r.PerPage, Page: r.Page, @@ -76,6 +77,7 @@ func (ctrl *Page) Create(ctx context.Context, r *request.PageCreate) (interface{ SelfID: r.SelfID, ModuleID: r.ModuleID, Title: r.Title, + Handle: r.Handle, Description: r.Description, Visible: r.Visible, } @@ -108,6 +110,7 @@ func (ctrl *Page) Update(ctx context.Context, r *request.PageUpdate) (interface{ SelfID: r.SelfID, ModuleID: r.ModuleID, Title: r.Title, + Handle: r.Handle, Description: r.Description, Visible: r.Visible, } diff --git a/compose/rest/request/chart.go b/compose/rest/request/chart.go index 39499a94a..3447d7592 100644 --- a/compose/rest/request/chart.go +++ b/compose/rest/request/chart.go @@ -36,6 +36,7 @@ var _ = multipart.FileHeader{} // Chart list request parameters type ChartList struct { Query string + Handle string Page uint PerPage uint NamespaceID uint64 `json:",string"` @@ -49,6 +50,7 @@ func (r ChartList) Auditable() map[string]interface{} { var out = map[string]interface{}{} out["query"] = r.Query + out["handle"] = r.Handle out["page"] = r.Page out["perPage"] = r.PerPage out["namespaceID"] = r.NamespaceID @@ -86,6 +88,9 @@ func (r *ChartList) Fill(req *http.Request) (err error) { if val, ok := get["query"]; ok { r.Query = val } + if val, ok := get["handle"]; ok { + r.Handle = val + } if val, ok := get["page"]; ok { r.Page = parseUint(val) } @@ -103,6 +108,7 @@ var _ RequestFiller = NewChartList() type ChartCreate struct { Config sqlxTypes.JSONText Name string + Handle string NamespaceID uint64 `json:",string"` } @@ -115,6 +121,7 @@ func (r ChartCreate) Auditable() map[string]interface{} { out["config"] = r.Config out["name"] = r.Name + out["handle"] = r.Handle out["namespaceID"] = r.NamespaceID return out @@ -156,6 +163,9 @@ func (r *ChartCreate) Fill(req *http.Request) (err error) { if val, ok := post["name"]; ok { r.Name = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } r.NamespaceID = parseUInt64(chi.URLParam(req, "namespaceID")) return err @@ -223,6 +233,7 @@ type ChartUpdate struct { NamespaceID uint64 `json:",string"` Config sqlxTypes.JSONText Name string + Handle string UpdatedAt *time.Time } @@ -237,6 +248,7 @@ func (r ChartUpdate) Auditable() map[string]interface{} { out["namespaceID"] = r.NamespaceID out["config"] = r.Config out["name"] = r.Name + out["handle"] = r.Handle out["updatedAt"] = r.UpdatedAt return out @@ -280,6 +292,9 @@ func (r *ChartUpdate) Fill(req *http.Request) (err error) { if val, ok := post["name"]; ok { r.Name = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } if val, ok := post["updatedAt"]; ok { if r.UpdatedAt, err = parseISODatePtrWithErr(val); err != nil { diff --git a/compose/rest/request/module.go b/compose/rest/request/module.go index 22b6cb6b6..f42198054 100644 --- a/compose/rest/request/module.go +++ b/compose/rest/request/module.go @@ -38,6 +38,7 @@ var _ = multipart.FileHeader{} type ModuleList struct { Query string Name string + Handle string Page uint PerPage uint NamespaceID uint64 `json:",string"` @@ -52,6 +53,7 @@ func (r ModuleList) Auditable() map[string]interface{} { out["query"] = r.Query out["name"] = r.Name + out["handle"] = r.Handle out["page"] = r.Page out["perPage"] = r.PerPage out["namespaceID"] = r.NamespaceID @@ -92,6 +94,9 @@ func (r *ModuleList) Fill(req *http.Request) (err error) { if val, ok := get["name"]; ok { r.Name = val } + if val, ok := get["handle"]; ok { + r.Handle = val + } if val, ok := get["page"]; ok { r.Page = parseUint(val) } @@ -108,6 +113,7 @@ var _ RequestFiller = NewModuleList() // Module create request parameters type ModuleCreate struct { Name string + Handle string Fields types.ModuleFieldSet Meta sqlxTypes.JSONText NamespaceID uint64 `json:",string"` @@ -121,6 +127,7 @@ func (r ModuleCreate) Auditable() map[string]interface{} { var out = map[string]interface{}{} out["name"] = r.Name + out["handle"] = r.Handle out["fields"] = r.Fields out["meta"] = r.Meta out["namespaceID"] = r.NamespaceID @@ -158,6 +165,9 @@ func (r *ModuleCreate) Fill(req *http.Request) (err error) { if val, ok := post["name"]; ok { r.Name = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } if val, ok := post["meta"]; ok { if r.Meta, err = parseJSONTextWithErr(val); err != nil { @@ -230,6 +240,7 @@ type ModuleUpdate struct { ModuleID uint64 `json:",string"` NamespaceID uint64 `json:",string"` Name string + Handle string Fields types.ModuleFieldSet Meta sqlxTypes.JSONText UpdatedAt *time.Time @@ -245,6 +256,7 @@ func (r ModuleUpdate) Auditable() map[string]interface{} { out["moduleID"] = r.ModuleID out["namespaceID"] = r.NamespaceID out["name"] = r.Name + out["handle"] = r.Handle out["fields"] = r.Fields out["meta"] = r.Meta out["updatedAt"] = r.UpdatedAt @@ -284,6 +296,9 @@ func (r *ModuleUpdate) Fill(req *http.Request) (err error) { if val, ok := post["name"]; ok { r.Name = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } if val, ok := post["meta"]; ok { if r.Meta, err = parseJSONTextWithErr(val); err != nil { diff --git a/compose/rest/request/page.go b/compose/rest/request/page.go index f60426878..0a6265809 100644 --- a/compose/rest/request/page.go +++ b/compose/rest/request/page.go @@ -36,6 +36,7 @@ var _ = multipart.FileHeader{} type PageList struct { SelfID uint64 `json:",string"` Query string + Handle string Page uint PerPage uint NamespaceID uint64 `json:",string"` @@ -50,6 +51,7 @@ func (r PageList) Auditable() map[string]interface{} { out["selfID"] = r.SelfID out["query"] = r.Query + out["handle"] = r.Handle out["page"] = r.Page out["perPage"] = r.PerPage out["namespaceID"] = r.NamespaceID @@ -90,6 +92,9 @@ func (r *PageList) Fill(req *http.Request) (err error) { if val, ok := get["query"]; ok { r.Query = val } + if val, ok := get["handle"]; ok { + r.Handle = val + } if val, ok := get["page"]; ok { r.Page = parseUint(val) } @@ -108,6 +113,7 @@ type PageCreate struct { SelfID uint64 `json:",string"` ModuleID uint64 `json:",string"` Title string + Handle string Description string Visible bool Blocks sqlxTypes.JSONText @@ -124,6 +130,7 @@ func (r PageCreate) Auditable() map[string]interface{} { out["selfID"] = r.SelfID out["moduleID"] = r.ModuleID out["title"] = r.Title + out["handle"] = r.Handle out["description"] = r.Description out["visible"] = r.Visible out["blocks"] = r.Blocks @@ -168,6 +175,9 @@ func (r *PageCreate) Fill(req *http.Request) (err error) { if val, ok := post["title"]; ok { r.Title = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } if val, ok := post["description"]; ok { r.Description = val } @@ -299,6 +309,7 @@ type PageUpdate struct { SelfID uint64 `json:",string"` ModuleID uint64 `json:",string"` Title string + Handle string Description string Visible bool Blocks sqlxTypes.JSONText @@ -316,6 +327,7 @@ func (r PageUpdate) Auditable() map[string]interface{} { out["selfID"] = r.SelfID out["moduleID"] = r.ModuleID out["title"] = r.Title + out["handle"] = r.Handle out["description"] = r.Description out["visible"] = r.Visible out["blocks"] = r.Blocks @@ -361,6 +373,9 @@ func (r *PageUpdate) Fill(req *http.Request) (err error) { if val, ok := post["title"]; ok { r.Title = val } + if val, ok := post["handle"]; ok { + r.Handle = val + } if val, ok := post["description"]; ok { r.Description = val } diff --git a/compose/service/chart.go b/compose/service/chart.go index a40aa427f..ed8384f48 100644 --- a/compose/service/chart.go +++ b/compose/service/chart.go @@ -154,6 +154,7 @@ func (svc chart) Update(mod *types.Chart) (c *types.Chart, err error) { c.Config = mod.Config c.Name = mod.Name + c.Handle = mod.Handle return svc.chartRepo.Update(c) } diff --git a/compose/service/module.go b/compose/service/module.go index 28bdc1320..62e823c14 100644 --- a/compose/service/module.go +++ b/compose/service/module.go @@ -188,6 +188,7 @@ func (svc module) Update(mod *types.Module) (m *types.Module, err error) { } m.Name = mod.Name + m.Handle = mod.Handle m.Meta = mod.Meta m.Fields = mod.Fields diff --git a/compose/service/page.go b/compose/service/page.go index b6a2bad8b..61011a6c6 100644 --- a/compose/service/page.go +++ b/compose/service/page.go @@ -3,6 +3,7 @@ package service import ( "context" + "github.com/davecgh/go-spew/spew" "github.com/titpetric/factory" "go.uber.org/zap" @@ -250,18 +251,20 @@ func (svc page) Update(mod *types.Page) (p *types.Page, err error) { return nil, ErrNoUpdatePermissions.withStack() } - if err = svc.UniqueCheck(mod); err != nil { - return - } - p.ModuleID = mod.ModuleID p.SelfID = mod.SelfID p.Blocks = mod.Blocks p.Title = mod.Title + p.Handle = mod.Handle p.Description = mod.Description p.Visible = mod.Visible p.Weight = mod.Weight + spew.Dump(p.Handle) + if err = svc.UniqueCheck(p); err != nil { + return + } + p, err = svc.pageRepo.Update(p) return } @@ -269,6 +272,12 @@ func (svc page) Update(mod *types.Page) (p *types.Page, err error) { func (svc page) UniqueCheck(p *types.Page) (err error) { if p.Handle != "" { if e, _ := svc.pageRepo.FindByHandle(p.NamespaceID, p.Handle); e != nil && e.ID != p.ID { + spew.Dump( + e.ID, + e.Handle, + p.ID, + p.Handle, + ) return repository.ErrPageHandleNotUnique } } diff --git a/compose/types/chart.go b/compose/types/chart.go index 582625ce2..aae60e46c 100644 --- a/compose/types/chart.go +++ b/compose/types/chart.go @@ -41,6 +41,7 @@ type ( ChartFilter struct { NamespaceID uint64 `json:"namespaceID,string"` + Handle string `json:"handle"` Query string `json:"query"` Page uint `json:"page"` PerPage uint `json:"perPage"` diff --git a/compose/types/module.go b/compose/types/module.go index de32d8cc2..ca04dcd1b 100644 --- a/compose/types/module.go +++ b/compose/types/module.go @@ -25,6 +25,7 @@ type ( ModuleFilter struct { NamespaceID uint64 `json:"namespaceID,string"` Query string `json:"query"` + Handle string `json:"handle"` Name string `json:"name"` Page uint `json:"page"` PerPage uint `json:"perPage"` diff --git a/compose/types/page.go b/compose/types/page.go index 5f00b26d1..0f08b4e13 100644 --- a/compose/types/page.go +++ b/compose/types/page.go @@ -58,6 +58,7 @@ type ( NamespaceID uint64 `json:"namespaceID,string"` ParentID uint64 `json:"parentID,string,omitempty"` Root bool `json:"root,omitempty"` + Handle string `json:"handle"` Query string `json:"query"` Page uint `json:"page"` PerPage uint `json:"perPage"` diff --git a/docs/compose/README.md b/docs/compose/README.md index 3d3ef98a9..de75513ab 100644 --- a/docs/compose/README.md +++ b/docs/compose/README.md @@ -407,6 +407,7 @@ | Parameter | Type | Method | Description | Default | Required? | | --------- | ---- | ------ | ----------- | ------- | --------- | | query | string | GET | Search query to match against charts | N/A | NO | +| handle | string | GET | Search charts by handle | N/A | NO | | page | uint | GET | Page number (0 based) | N/A | NO | | perPage | uint | GET | Returned items per page (default 50) | N/A | NO | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | @@ -425,6 +426,7 @@ | --------- | ---- | ------ | ----------- | ------- | --------- | | config | sqlxTypes.JSONText | POST | Chart JSON | N/A | YES | | name | string | POST | Chart name | N/A | YES | +| handle | string | POST | Chart handle | N/A | NO | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | ## Read charts by ID @@ -458,6 +460,7 @@ | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | | config | sqlxTypes.JSONText | POST | Chart JSON | N/A | YES | | name | string | POST | Chart name | N/A | YES | +| handle | string | POST | Chart handle | N/A | NO | | updatedAt | *time.Time | POST | Last update (or creation) date | N/A | NO | ## Delete chart @@ -506,6 +509,7 @@ Compose module definitions | --------- | ---- | ------ | ----------- | ------- | --------- | | query | string | GET | Search query | N/A | NO | | name | string | GET | Search by name | N/A | NO | +| handle | string | GET | Search by handle | N/A | NO | | page | uint | GET | Page number (0 based) | N/A | NO | | perPage | uint | GET | Returned items per page (default 50) | N/A | NO | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | @@ -523,6 +527,7 @@ Compose module definitions | Parameter | Type | Method | Description | Default | Required? | | --------- | ---- | ------ | ----------- | ------- | --------- | | name | string | POST | Module Name | N/A | YES | +| handle | string | POST | Module handle | N/A | NO | | fields | types.ModuleFieldSet | POST | Fields JSON | N/A | YES | | meta | sqlxTypes.JSONText | POST | Module meta data | N/A | YES | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | @@ -557,6 +562,7 @@ Compose module definitions | moduleID | uint64 | PATH | Module ID | N/A | YES | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | | name | string | POST | Module Name | N/A | YES | +| handle | string | POST | Module Handle | N/A | NO | | fields | types.ModuleFieldSet | POST | Fields JSON | N/A | YES | | meta | sqlxTypes.JSONText | POST | Module meta data | N/A | YES | | updatedAt | *time.Time | POST | Last update (or creation) date | N/A | NO | @@ -738,6 +744,7 @@ Compose pages | --------- | ---- | ------ | ----------- | ------- | --------- | | selfID | uint64 | GET | Parent page ID | N/A | NO | | query | string | GET | Search query | N/A | NO | +| handle | string | GET | Search by handle | N/A | NO | | page | uint | GET | Page number (0 based) | N/A | NO | | perPage | uint | GET | Returned items per page (default 50) | N/A | NO | | namespaceID | uint64 | PATH | Namespace ID | N/A | YES | @@ -757,6 +764,7 @@ Compose pages | selfID | uint64 | POST | Parent Page ID | N/A | NO | | moduleID | uint64 | POST | Module ID | N/A | NO | | title | string | POST | Title | N/A | YES | +| handle | string | POST | Handle | N/A | NO | | description | string | POST | Description | N/A | NO | | visible | bool | POST | Visible in navigation | N/A | NO | | blocks | sqlxTypes.JSONText | POST | Blocks JSON | N/A | YES | @@ -808,6 +816,7 @@ Compose pages | selfID | uint64 | POST | Parent Page ID | N/A | NO | | moduleID | uint64 | POST | Module ID (optional) | N/A | NO | | title | string | POST | Title | N/A | YES | +| handle | string | POST | Handle | N/A | NO | | description | string | POST | Description | N/A | NO | | visible | bool | POST | Visible in navigation | N/A | NO | | blocks | sqlxTypes.JSONText | POST | Blocks JSON | N/A | YES |