Implement Canvas V2 subgraphs, assets and asynchronous AI execution
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
package platform
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func canvasIdempotencyKey(r *http.Request) string {
|
||||
return strings.ToLower(r.Header.Get("Idempotency-Key"))
|
||||
}
|
||||
func canvasExceededGraphLimits(raw json.RawMessage) bool {
|
||||
var doc struct {
|
||||
Nodes []json.RawMessage `json:"nodes"`
|
||||
Edges []json.RawMessage `json:"edges"`
|
||||
}
|
||||
if json.Unmarshal(raw, &doc) != nil {
|
||||
return false
|
||||
}
|
||||
if len(doc.Nodes) > 500 || len(doc.Edges) > 2000 {
|
||||
return true
|
||||
}
|
||||
for _, raw := range doc.Edges {
|
||||
var edge struct {
|
||||
Data struct {
|
||||
Path struct {
|
||||
Knots []json.RawMessage `json:"knots"`
|
||||
} `json:"path"`
|
||||
} `json:"data"`
|
||||
}
|
||||
if json.Unmarshal(raw, &edge) == nil && len(edge.Data.Path.Knots) > 64 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user