Fix missing fields in MCP type serializers
Framework was missing OrganizationID, Task was missing MeasureID and AssignedToID, Asset was missing SnapshotID, AuditLogEntry was missing Metadata, and Obligation was missing SourceID. All these fields were defined in the MCP generated types but never set by their converters. Signed-off-by: Sacha Al Himdani <sacha@getprobo.com>
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func NewAsset(a *coredata.Asset) *Asset {
|
||||
return &Asset{
|
||||
asset := &Asset{
|
||||
ID: a.ID,
|
||||
Name: a.Name,
|
||||
Amount: a.Amount,
|
||||
@@ -31,6 +31,13 @@ func NewAsset(a *coredata.Asset) *Asset {
|
||||
CreatedAt: a.CreatedAt,
|
||||
UpdatedAt: a.UpdatedAt,
|
||||
}
|
||||
|
||||
if a.SnapshotID != nil {
|
||||
s := a.SnapshotID.String()
|
||||
asset.SnapshotID = &s
|
||||
}
|
||||
|
||||
return asset
|
||||
}
|
||||
|
||||
func NewListAssetsOutput(assetPage *page.Page[*coredata.Asset, coredata.AssetOrderField]) ListAssetsOutput {
|
||||
|
||||
@@ -15,12 +15,14 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go.probo.inc/probo/pkg/coredata"
|
||||
"go.probo.inc/probo/pkg/page"
|
||||
)
|
||||
|
||||
func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry {
|
||||
return &AuditLogEntry{
|
||||
entry := &AuditLogEntry{
|
||||
ID: e.ID,
|
||||
OrganizationID: e.OrganizationID,
|
||||
ActorID: e.ActorID,
|
||||
@@ -30,6 +32,15 @@ func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry {
|
||||
ResourceID: e.ResourceID,
|
||||
CreatedAt: e.CreatedAt,
|
||||
}
|
||||
|
||||
if len(e.Metadata) > 0 {
|
||||
var m map[string]any
|
||||
if json.Unmarshal(e.Metadata, &m) == nil {
|
||||
entry.Metadata = &m
|
||||
}
|
||||
}
|
||||
|
||||
return entry
|
||||
}
|
||||
|
||||
func NewListAuditLogEntriesOutput(p *page.Page[*coredata.AuditLogEntry, coredata.AuditLogEntryOrderField]) ListAuditLogEntriesOutput {
|
||||
|
||||
@@ -21,11 +21,12 @@ import (
|
||||
|
||||
func NewFramework(f *coredata.Framework) *Framework {
|
||||
return &Framework{
|
||||
ID: f.ID,
|
||||
Name: f.Name,
|
||||
Description: f.Description,
|
||||
CreatedAt: f.CreatedAt,
|
||||
UpdatedAt: f.UpdatedAt,
|
||||
ID: f.ID,
|
||||
OrganizationID: f.OrganizationID,
|
||||
Name: f.Name,
|
||||
Description: f.Description,
|
||||
CreatedAt: f.CreatedAt,
|
||||
UpdatedAt: f.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
func NewObligation(o *coredata.Obligation) *Obligation {
|
||||
return &Obligation{
|
||||
obligation := &Obligation{
|
||||
ID: o.ID,
|
||||
OrganizationID: o.OrganizationID,
|
||||
SnapshotID: o.SnapshotID,
|
||||
@@ -37,6 +37,13 @@ func NewObligation(o *coredata.Obligation) *Obligation {
|
||||
CreatedAt: o.CreatedAt,
|
||||
UpdatedAt: o.UpdatedAt,
|
||||
}
|
||||
|
||||
if o.SourceID != nil {
|
||||
s := o.SourceID.String()
|
||||
obligation.SourceID = &s
|
||||
}
|
||||
|
||||
return obligation
|
||||
}
|
||||
|
||||
func NewListObligationsOutput(obligationPage *page.Page[*coredata.Obligation, coredata.ObligationOrderField]) ListObligationsOutput {
|
||||
|
||||
@@ -23,12 +23,14 @@ func NewTask(t *coredata.Task) *Task {
|
||||
return &Task{
|
||||
ID: t.ID,
|
||||
OrganizationID: t.OrganizationID,
|
||||
MeasureID: t.MeasureID,
|
||||
Name: t.Name,
|
||||
Description: t.Description,
|
||||
State: t.State,
|
||||
Priority: t.Priority,
|
||||
Rank: t.Rank,
|
||||
TimeEstimate: t.TimeEstimate,
|
||||
AssignedToID: t.AssignedToID,
|
||||
CreatedAt: t.CreatedAt,
|
||||
UpdatedAt: t.UpdatedAt,
|
||||
Deadline: t.Deadline,
|
||||
|
||||
Reference in New Issue
Block a user