make ci catalog

This commit is contained in:
mr
2026-06-22 07:57:35 +02:00
parent 490bcdd8ea
commit 9302b6ca56
11 changed files with 276 additions and 51 deletions
+6 -5
View File
@@ -43,7 +43,8 @@ func (o *GeneralController) GetAll() {
Groups: groups,
Admin: true,
}
newWorkflow, err = newWorkflow.ExtractFromPlantUML(file, req)
var importWarnings []string
newWorkflow, importWarnings, err = newWorkflow.ExtractFromPlantUML(file, req)
if err != nil {
o.Data["json"] = map[string]interface{}{
"data": nil,
@@ -55,9 +56,10 @@ func (o *GeneralController) GetAll() {
}
o.Data["json"] = map[string]interface{}{
"data": newWorkflow,
"code": 200,
"error": nil,
"data": newWorkflow,
"code": 200,
"error": nil,
"warnings": importWarnings,
}
o.ServeJSON()
@@ -93,7 +95,6 @@ func Websocket(ctx context.Context, user string, groups []string, dataType int,
for {
select {
case msg, ok := <-infrastructure.SearchStream[user]:
fmt.Println("msg", msg, ok)
if !ok {
continue
}
+16 -6
View File
@@ -113,12 +113,12 @@ func (o *ResourceController) Search() {
limit, _ := strconv.Atoi(o.Ctx.Input.Query("limit"))
m := map[string][]utils.ShallowDBObject{}
fmt.Println(o.collection(false))
for _, col := range o.collection(false) {
if m[col.String()] == nil {
m[col.String()] = []utils.ShallowDBObject{}
}
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(nil, search, isDraft == "true", int64(offset), int64(limit))
fmt.Println(col, len(s.Data), s.Err)
m[col.String()] = append(m[col.String()], s.Data...)
}
mm := map[string]interface{}{}
@@ -154,6 +154,7 @@ func GetResource(typ oclib.LibDataEnum) interface{} {
// @Title Search
// @Description search workspace
// @Param type path string true "the type you want to get"
// @Param is_draft query string false
// @Param extend query string false "extend"
// @Param offset query string false
@@ -162,6 +163,7 @@ func GetResource(typ oclib.LibDataEnum) interface{} {
// @Success 200 {workspace} models.workspace
// @router /:type/extended/search [post]
func (o *ResourceController) SearchExtended() {
fmt.Println("THERE")
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
// store and return Id or post with UUIDLibDataEnum
isDraft := o.Ctx.Input.Query("is_draft")
@@ -175,6 +177,7 @@ func (o *ResourceController) SearchExtended() {
if m[col.String()] == nil {
m[col.String()] = []utils.ShallowDBObject{}
}
fmt.Println("filters", oclib.FiltersFromFlatMap(res, GetResource(col)))
s := oclib.NewRequest(col, user, peerID, groups, nil).Search(
oclib.FiltersFromFlatMap(res, GetResource(col)), "", isDraft == "true", int64(offset), int64(limit))
m[col.String()] = append(m[col.String()], s.Data...)
@@ -203,10 +206,8 @@ func (o *ResourceController) Get() {
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
extend := strings.Split(o.Ctx.Input.Query("extend"), ",")
fmt.Println("COLLECTIOn", o.collection(false))
for _, col := range o.collection(false) {
if d := oclib.NewRequest(col, user, peerID, groups, nil).LoadOne(id); d.Data != nil {
fmt.Println("EXTEND", d.Data.Extend(extend...), extend)
o.Data["json"] = oclib.GetExtend(d.Data, d.Data.Extend(extend...), map[tools.DataType]map[string]interface{}{})
break
} else {
@@ -235,12 +236,23 @@ func (o *ResourceController) Post() {
var res map[string]interface{}
json.Unmarshal(o.Ctx.Input.CopyBody(100000), &res)
// Block "add from discovered cache": refuse resources whose creator_id belongs to another peer.
// Resources discovered via decentralized search must go to the workspace, not the local catalog.
if creatorID, _ := res["creator_id"].(string); creatorID != "" && peerID != "" && creatorID != peerID {
o.Data["json"] = map[string]interface{}{
"data": nil,
"code": 403,
"err": "cannot add a resource created by another peer to the local catalog; use workspace instead",
}
o.ServeJSON()
return
}
// Remplace les sources privées (isReachable=false) par des clés opaques
// avant la persistance : le vrai path ne doit jamais sortir de ce peer.
replacePrivateSources(res)
data := oclib.NewRequest(libs[0], user, peerID, groups, nil).StoreOne(res)
fmt.Println(data.Data, res["name"], libs[0])
if data.Err == "" {
payload, _ := json.Marshal(data.Data.Serialize(data.Data))
infrastructure.EmitNATS(user, groups, tools.PropalgationMessage{
@@ -338,12 +350,10 @@ func (o *ResourceController) Put() {
// @Success 200 {resource} models.resource
// @router /:type/:id [delete]
func (o *ResourceController) Delete() {
fmt.Println("THERE")
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
id := o.Ctx.Input.Param(":id")
for _, col := range o.collection(false) {
data := oclib.NewRequest(col, user, peerID, groups, nil).DeleteOne(id)
fmt.Println(col, data, id)
if data.Err == "" {
o.Data["json"] = data
payload, _ := json.Marshal(data.Data.Serialize(data.Data))