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 {
|
func NewAsset(a *coredata.Asset) *Asset {
|
||||||
return &Asset{
|
asset := &Asset{
|
||||||
ID: a.ID,
|
ID: a.ID,
|
||||||
Name: a.Name,
|
Name: a.Name,
|
||||||
Amount: a.Amount,
|
Amount: a.Amount,
|
||||||
@@ -31,6 +31,13 @@ func NewAsset(a *coredata.Asset) *Asset {
|
|||||||
CreatedAt: a.CreatedAt,
|
CreatedAt: a.CreatedAt,
|
||||||
UpdatedAt: a.UpdatedAt,
|
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 {
|
func NewListAssetsOutput(assetPage *page.Page[*coredata.Asset, coredata.AssetOrderField]) ListAssetsOutput {
|
||||||
|
|||||||
@@ -15,12 +15,14 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"go.probo.inc/probo/pkg/coredata"
|
"go.probo.inc/probo/pkg/coredata"
|
||||||
"go.probo.inc/probo/pkg/page"
|
"go.probo.inc/probo/pkg/page"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry {
|
func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry {
|
||||||
return &AuditLogEntry{
|
entry := &AuditLogEntry{
|
||||||
ID: e.ID,
|
ID: e.ID,
|
||||||
OrganizationID: e.OrganizationID,
|
OrganizationID: e.OrganizationID,
|
||||||
ActorID: e.ActorID,
|
ActorID: e.ActorID,
|
||||||
@@ -30,6 +32,15 @@ func NewAuditLogEntry(e *coredata.AuditLogEntry) *AuditLogEntry {
|
|||||||
ResourceID: e.ResourceID,
|
ResourceID: e.ResourceID,
|
||||||
CreatedAt: e.CreatedAt,
|
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 {
|
func NewListAuditLogEntriesOutput(p *page.Page[*coredata.AuditLogEntry, coredata.AuditLogEntryOrderField]) ListAuditLogEntriesOutput {
|
||||||
|
|||||||
@@ -21,11 +21,12 @@ import (
|
|||||||
|
|
||||||
func NewFramework(f *coredata.Framework) *Framework {
|
func NewFramework(f *coredata.Framework) *Framework {
|
||||||
return &Framework{
|
return &Framework{
|
||||||
ID: f.ID,
|
ID: f.ID,
|
||||||
Name: f.Name,
|
OrganizationID: f.OrganizationID,
|
||||||
Description: f.Description,
|
Name: f.Name,
|
||||||
CreatedAt: f.CreatedAt,
|
Description: f.Description,
|
||||||
UpdatedAt: f.UpdatedAt,
|
CreatedAt: f.CreatedAt,
|
||||||
|
UpdatedAt: f.UpdatedAt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func NewObligation(o *coredata.Obligation) *Obligation {
|
func NewObligation(o *coredata.Obligation) *Obligation {
|
||||||
return &Obligation{
|
obligation := &Obligation{
|
||||||
ID: o.ID,
|
ID: o.ID,
|
||||||
OrganizationID: o.OrganizationID,
|
OrganizationID: o.OrganizationID,
|
||||||
SnapshotID: o.SnapshotID,
|
SnapshotID: o.SnapshotID,
|
||||||
@@ -37,6 +37,13 @@ func NewObligation(o *coredata.Obligation) *Obligation {
|
|||||||
CreatedAt: o.CreatedAt,
|
CreatedAt: o.CreatedAt,
|
||||||
UpdatedAt: o.UpdatedAt,
|
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 {
|
func NewListObligationsOutput(obligationPage *page.Page[*coredata.Obligation, coredata.ObligationOrderField]) ListObligationsOutput {
|
||||||
|
|||||||
@@ -23,12 +23,14 @@ func NewTask(t *coredata.Task) *Task {
|
|||||||
return &Task{
|
return &Task{
|
||||||
ID: t.ID,
|
ID: t.ID,
|
||||||
OrganizationID: t.OrganizationID,
|
OrganizationID: t.OrganizationID,
|
||||||
|
MeasureID: t.MeasureID,
|
||||||
Name: t.Name,
|
Name: t.Name,
|
||||||
Description: t.Description,
|
Description: t.Description,
|
||||||
State: t.State,
|
State: t.State,
|
||||||
Priority: t.Priority,
|
Priority: t.Priority,
|
||||||
Rank: t.Rank,
|
Rank: t.Rank,
|
||||||
TimeEstimate: t.TimeEstimate,
|
TimeEstimate: t.TimeEstimate,
|
||||||
|
AssignedToID: t.AssignedToID,
|
||||||
CreatedAt: t.CreatedAt,
|
CreatedAt: t.CreatedAt,
|
||||||
UpdatedAt: t.UpdatedAt,
|
UpdatedAt: t.UpdatedAt,
|
||||||
Deadline: t.Deadline,
|
Deadline: t.Deadline,
|
||||||
|
|||||||
Reference in New Issue
Block a user